"use strict";(()=>{var e={};e.id=6452,e.ids=[6452],e.modules={53524:e=>{e.exports=require("@prisma/client")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},6113:e=>{e.exports=require("crypto")},50396:(e,t,a)=>{a.r(t),a.d(t,{headerHooks:()=>g,originalPathname:()=>f,patchFetch:()=>v,requestAsyncStorage:()=>d,routeModule:()=>c,serverHooks:()=>m,staticGenerationAsyncStorage:()=>w,staticGenerationBailout:()=>h});var r={};a.r(r),a.d(r,{POST:()=>l});var i=a(95419),s=a(69108),n=a(99678),o=a(78070),p=a(34490),u=a(6113);async function l(e){try{let{pageId:t,referrer:a,w:r,eventType:i,label:s}=await e.json();if(!t)return o.Z.json({error:"pageId required"},{status:400});if(!await p.prisma.page.findUnique({where:{id:t},select:{id:!0}}))return o.Z.json({error:"Page not found"},{status:404});let n="desktop";r&&r<768?n="mobile":r&&r<1024&&(n="tablet");let l=e.headers.get("x-forwarded-for"),c=e.headers.get("x-real-ip"),d=l?.split(",")[0]?.trim()||c||"unknown",w=(0,u.createHash)("sha256").update(d+t).digest("hex").slice(0,16),m=i||"view";if("view"===m){let e=new Date(Date.now()-36e5);if(await p.prisma.pageView.findFirst({where:{pageId:t,ipHash:w,eventType:"view",timestamp:{gte:e}}}))return o.Z.json({ok:!0,deduplicated:!0})}return await p.prisma.pageView.create({data:{pageId:t,referrer:a?a.slice(0,500):null,device:n,ipHash:w,eventType:m,label:s?s.slice(0,50):null}}),"view"===m&&await p.prisma.page.update({where:{id:t},data:{viewsCount:{increment:1}}}),o.Z.json({ok:!0})}catch(e){return console.error("[analytics/track] Error:",e),o.Z.json({error:"Tracking failed"},{status:500})}}let c=new i.AppRouteRouteModule({definition:{kind:s.x.APP_ROUTE,page:"/api/analytics/track/route",pathname:"/api/analytics/track",filename:"route",bundlePath:"app/api/analytics/track/route"},resolvedPagePath:"C:\\test2\\pagecraft-ai\\src\\app\\api\\analytics\\track\\route.ts",nextConfigOutput:"standalone",userland:r}),{requestAsyncStorage:d,staticGenerationAsyncStorage:w,serverHooks:m,headerHooks:g,staticGenerationBailout:h}=c,f="/api/analytics/track/route";function v(){return(0,n.patchFetch)({serverHooks:m,staticGenerationAsyncStorage:w})}},34490:(e,t,a)=>{a.d(t,{prisma:()=>i});var r=a(53524);let i=globalThis.prisma??new r.PrismaClient}};var t=require("../../../../webpack-runtime.js");t.C(e);var a=e=>t(t.s=e),r=t.X(0,[1638,6206],()=>a(50396));module.exports=r})();