"use strict";(()=>{var e={};e.id=489,e.ids=[489],e.modules={92885:e=>{e.exports=require("@supabase/supabase-js")},20399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},1455:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>E,patchFetch:()=>x,requestAsyncStorage:()=>b,routeModule:()=>h,serverHooks:()=>y,staticGenerationAsyncStorage:()=>m});var o={};t.r(o),t.d(o,{GET:()=>f,dynamic:()=>u});var s=t(49303),n=t(88716),a=t(60670),i=t(87070),l=t(92885),c=t(74016);let u="force-dynamic",d=process.env.NEXT_PUBLIC_SUPABASE_URL||"",g=process.env.SUPABASE_SERVICE_ROLE_KEY||"";async function p(e){return e.map(e=>{if((0,c.Lt)(e.text))return null;let r=e.handle||(e.did.startsWith("did:plc:")?`${e.did.substring(8,16)}...`:`${e.did.substring(0,8)}...`);return{id:e.id,uri:e.uri,cid:e.cid,authorDid:e.did,authorHandle:r,text:(0,c.oO)(e.text),emoji:e.emoji,createdAt:e.created_at}}).filter(e=>null!==e)}async function f(e){console.log(`
=== DIRECT FEED REQUEST @ ${new Date().toISOString()} ===`),console.log(`URL: ${e.url}`);try{let r=new URL(e.url).searchParams.get("before");if(console.log(`Request params: beforeCursor=${r||"none"}`),!d||!g)return console.error("Missing Supabase credentials"),i.NextResponse.json({error:"Server configuration error"},{status:500});let t=(0,l.createClient)(d,g),{data:o}=await t.from("flushing_records").select("id").order("id",{ascending:!1}).limit(1);console.log("Highest ID in database:",o?.[0]?.id||"unknown");let s=[];if(r){console.log(`Fetching entries older than ID ${r}`);let{data:e,error:o}=await t.from("flushing_records").select("*").lt("id",r).order("id",{ascending:!1}).limit(20);if(o)throw Error(`Database query error: ${o.message}`);s=e||[]}else{try{let e=`
          SELECT * FROM flushing_records 
          ORDER BY id DESC 
          LIMIT 20
        `;console.log("Executing direct SQL query:",e);let{data:r,error:o}=await t.rpc("execute_raw_query",{raw_query:e});if(o)console.error("Raw SQL query error:",o);else if(r&&Array.isArray(r)&&r.length>0){console.log(`✅ Direct SQL query successful, found ${r.length} entries`),s=r;let e=await p(s);return i.NextResponse.json({entries:e,source:"direct-sql"})}}catch(e){console.error("Exception executing raw SQL:",e)}try{console.log("Trying RPC function approach");let{data:e,error:r}=await t.rpc("get_latest_entries",{max_entries:20});if(r)console.error("RPC function error:",r);else if(e&&Array.isArray(e)&&e.length>0){console.log(`✅ RPC function query successful, found ${e.length} entries`),s=e;let r=await p(s);return i.NextResponse.json({entries:r,source:"rpc-function"})}}catch(e){console.error("Exception in RPC function:",e)}console.log("Falling back to standard query builder");let{data:e,error:r}=await t.from("flushing_records").select("*").order("id",{ascending:!1}).limit(20);if(r)throw Error(`Fallback query error: ${r.message}`);s=e||[]}if(console.log(`Query returned ${s.length} entries`),s.length>0){console.log("Top 5 entries:");for(let e=0;e<Math.min(5,s.length);e++){let r=s[e];console.log(`  ${e+1}. ID: ${r.id}, Handle: ${r.handle||"unknown"}, Text: "${r.text.substring(0,20)}..."`)}}else console.warn("No entries found - this may indicate a database problem");let n=await p(s);return i.NextResponse.json({entries:n,source:"standard-query"})}catch(e){return console.error("Error in direct feed API:",e),i.NextResponse.json({error:"Failed to fetch feed",message:e.message},{status:500})}}let h=new s.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/bluesky/feed-direct/route",pathname:"/api/bluesky/feed-direct",filename:"route",bundlePath:"app/api/bluesky/feed-direct/route"},resolvedPagePath:"/Users/dame/Library/Mobile Documents/com~apple~CloudDocs/Software/flushes/app/src/app/api/bluesky/feed-direct/route.ts",nextConfigOutput:"standalone",userland:o}),{requestAsyncStorage:b,staticGenerationAsyncStorage:m,serverHooks:y}=h,E="/api/bluesky/feed-direct/route";function x(){return(0,a.patchFetch)({serverHooks:y,staticGenerationAsyncStorage:m})}},74016:(e,r,t)=>{t.d(r,{Lt:()=>n,oO:()=>a});let o=["slur","racist","bigot","bigotry","homophobic","transphobic","fuck","damn","ass","asshole","bitch","kill","murder","attack","violence","harm","hurt","retard","retarded","idiot","stupid","dumb","penis","vagina","dick","cock","pussy","sex","masturbate","orgasm","horny","erection","blowjob","handjob","viagra","cialis","enlarge","cryptocurrency","bitcoin","ethereum","make money","get rich","earn fast","pyramid","scheme","discord.gg","telegram.me"],s=[/\bc[hH][iIl1][nN][kKsS]?\b/,/\bc[oO]{2}[nN][sS]?\b/,/\bf[aA][gG]{1,2}([oOeE][tT]?|[iIyY][nNeE]?)?s?\b/,/\bk[iIyY][kK][eE][sS]?\b/,/\bn[iIl1oO][gG]{2}([aAeE][rR]?|[lL][eE][tT]|[nNoO][gG])?s?\b/,/\bn[iIl1oO][gG]{2}[aAeE][sS]\b/,/\bt[rR][aA][nN][nN][iIyY][eE]?[sS]?\b/];function n(e){if(!e)return!1;let r=e.toLowerCase().replace(/0/g,"o").replace(/1/g,"i").replace(/3/g,"e").replace(/4/g,"a").replace(/5/g,"s").replace(/\$/g,"s").replace(/@/g,"a").replace(/!/g,"i").replace(/\*/g,"").replace(/\./g,"").replace(/-/g,"").replace(/_/g,"").replace(/\s+/g," ");for(let r of s)if(r.test(e))return!0;return o.some(e=>{if(RegExp(`\\b${e}\\b`,"i").test(r))return!0;let t=e.split("").join("\\s*");return!!RegExp(`\\b${t}\\b`,"i").test(r)||e.length<=4&&RegExp(e,"i").test(r)})}function a(e){if(!e)return e;let r=e;return o.forEach(e=>{let t=RegExp(`\\b${e}\\b`,"gi");r=r.replace(t,"*".repeat(e.length))}),o.forEach(e=>{if(e.length>2){let t=e.split("").join("\\s*"),o=RegExp(`\\b${t}\\b`,"gi");r=r.replace(o,e=>"*".repeat(e.replace(/\s+/g,"").length))}}),o.filter(e=>e.length<=4).forEach(e=>{let t=RegExp(`(?<!\\w)${e}(?!\\w)`,"gi");r=r.replace(t,"*".repeat(e.length))}),r}}};var r=require("../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),o=r.X(0,[276,972],()=>t(1455));module.exports=o})();