"use strict";(()=>{var e={};e.id=6343,e.ids=[6343],e.modules={53524:e=>{e.exports=require("@prisma/client")},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")},64528:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>x,patchFetch:()=>m,requestAsyncStorage:()=>c,routeModule:()=>l,serverHooks:()=>y,staticGenerationAsyncStorage:()=>h});var s={};t.r(s),t.d(s,{GET:()=>p,POST:()=>d});var o=t(49303),a=t(88716),n=t(60670),i=t(87070),u=t(72331);async function p(e){let{searchParams:r}=new URL(e.url),t=r.get("userId");if(!t)return i.NextResponse.json({error:"User ID required"},{status:400});try{let e=await u._.watchHistory.findMany({where:{userId:t},orderBy:{lastWatched:"desc"},take:20});return i.NextResponse.json({history:e})}catch(e){return console.error("History API Error:",e),i.NextResponse.json({error:"Internal server error"},{status:500})}}async function d(e){try{let{userId:r,dramaId:t,title:s,image:o,provider:a,episode:n,episodeId:p,totalEpisodes:d}=await e.json();if(!r||!t)return i.NextResponse.json({error:"Missing required fields"},{status:400});"GoodShort"===a&&(a="GS");let l=await u._.watchHistory.upsert({where:{userId_dramaId:{userId:r,dramaId:t}},update:{episode:n,episodeId:String(p),title:s,image:o,provider:a,lastWatched:new Date,totalEpisodes:d||0},create:{userId:r,dramaId:t,title:s,image:o,provider:a,episode:n,episodeId:String(p),totalEpisodes:d||0}});return i.NextResponse.json({success:!0,history:l})}catch(e){return console.error("History Save Error:",e),i.NextResponse.json({error:"Internal server error"},{status:500})}}let l=new o.AppRouteRouteModule({definition:{kind:a.x.APP_ROUTE,page:"/api/user/history/route",pathname:"/api/user/history",filename:"route",bundlePath:"app/api/user/history/route"},resolvedPagePath:"C:\\Users\\MSI\\Downloads\\film\\app\\api\\user\\history\\route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:c,staticGenerationAsyncStorage:h,serverHooks:y}=l,x="/api/user/history/route";function m(){return(0,n.patchFetch)({serverHooks:y,staticGenerationAsyncStorage:h})}},72331:(e,r,t)=>{t.d(r,{_:()=>o});var s=t(53524);let o=global.prisma||new s.PrismaClient}};var r=require("../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),s=r.X(0,[8948,5972],()=>t(64528));module.exports=s})();