"use strict";(()=>{var e={};e.id=7541,e.ids=[7541],e.modules={2934:e=>{e.exports=require("next/dist/client/components/action-async-storage.external.js")},4580:e=>{e.exports=require("next/dist/client/components/request-async-storage.external.js")},5869:e=>{e.exports=require("next/dist/client/components/static-generation-async-storage.external.js")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},2211:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>x,patchFetch:()=>f,requestAsyncStorage:()=>h,routeModule:()=>d,serverHooks:()=>m,staticGenerationAsyncStorage:()=>y});var s={};r.r(s),r.d(s,{DELETE:()=>p,GET:()=>l});var o=r(9303),n=r(8716),a=r(670),i=r(7070),u=r(5655),c=r(987);async function l(e){try{let t=(0,u.e)(),{data:{user:r},error:s}=await t.auth.getUser();if(s||!r)return i.NextResponse.json({success:!1,error:"Unauthorized"},{status:401});let{searchParams:o}=new URL(e.url),n=Math.min(parseInt(o.get("limit")??"20"),100),a=parseInt(o.get("offset")??"0"),c=o.get("search")??"",l=o.get("style")??"",p=t.from("storyboard_history").select("*",{count:"exact"}).eq("user_id",r.id).order("created_at",{ascending:!1}).range(a,a+n-1);l&&"all"!==l&&(p=p.eq("style",l)),c&&(p=p.or(`source_title.ilike.%${c}%,source_platform.ilike.%${c}%`));let{data:d,count:h,error:y}=await p;if(y)throw y;return i.NextResponse.json({success:!0,data:d??[],total:h??0})}catch(e){return console.error("[storyboard/history]",e),i.NextResponse.json({success:!1,error:"Internal server error"},{status:500})}}async function p(e){if(!(0,c._)(e))return i.NextResponse.json((0,c.E)(),{status:403});try{let t=(0,u.e)(),{data:{user:r},error:s}=await t.auth.getUser();if(s||!r)return i.NextResponse.json({success:!1,error:"Unauthorized"},{status:401});let{searchParams:o}=new URL(e.url),n=o.get("id");if(!n)return i.NextResponse.json({success:!1,error:"ID diperlukan"},{status:400});let{error:a}=await t.from("storyboard_history").delete().eq("id",n).eq("user_id",r.id);if(a)throw a;return i.NextResponse.json({success:!0})}catch(e){return console.error("[storyboard/history DELETE]",e),i.NextResponse.json({success:!1,error:"Internal server error"},{status:500})}}let d=new o.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/storyboard/history/route",pathname:"/api/storyboard/history",filename:"route",bundlePath:"app/api/storyboard/history/route"},resolvedPagePath:"/home/user/.workspace/projects/promptmotion-ai/src/app/api/storyboard/history/route.ts",nextConfigOutput:"",userland:s}),{requestAsyncStorage:h,staticGenerationAsyncStorage:y,serverHooks:m}=d,x="/api/storyboard/history/route";function f(){return(0,a.patchFetch)({serverHooks:m,staticGenerationAsyncStorage:y})}},987:(e,t,r)=>{function s(e){let t=e.headers.get("origin");if(!t)return!0;let r="http://localhost:3000";if(new Set([r,"http://localhost:3000","http://localhost:3001","http://127.0.0.1:3000"].filter(Boolean)).has(t))return!0;try{let e=new URL(t).hostname,s=r?new URL(r).hostname:"";if(s&&(e===s||e.endsWith(`.${s}`)))return!0}catch{}return!1}function o(){return{success:!1,error:"Forbidden: invalid request origin"}}r.d(t,{E:()=>o,_:()=>s})},5655:(e,t,r)=>{r.d(t,{e:()=>n});var s=r(5238),o=r(1615);function n(){let e=(0,o.cookies)();return(0,s.l)("https://dummy.supabase.co","eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.dummy",{cookies:{getAll:()=>e.getAll(),setAll(t){try{t.forEach(({name:t,value:r,options:s})=>e.set(t,r,s))}catch{}}}})}}};var t=require("../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[9276,6164,5972],()=>r(2211));module.exports=s})();