"use strict";(()=>{var e={};e.id=4823,e.ids=[4823],e.modules={72934:e=>{e.exports=require("next/dist/client/components/action-async-storage.external.js")},54580:e=>{e.exports=require("next/dist/client/components/request-async-storage.external.js")},45869:e=>{e.exports=require("next/dist/client/components/static-generation-async-storage.external.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")},78893:e=>{e.exports=require("buffer")},84770:e=>{e.exports=require("crypto")},76162:e=>{e.exports=require("stream")},21764:e=>{e.exports=require("util")},31467:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>x,patchFetch:()=>g,requestAsyncStorage:()=>p,routeModule:()=>m,serverHooks:()=>d,staticGenerationAsyncStorage:()=>f});var i={};r.r(i),r.d(i,{GET:()=>l});var n=r(49303),s=r(88716),a=r(60670),o=r(87070),u=r(39655),c=r(8194);async function l(){try{let e=await (0,u.Of)();if(!e)return o.NextResponse.json({error:"Unauthorized"},{status:401});let t=await c._.affiliateCommission.findMany({where:{affiliateId:e.id},include:{tenant:{select:{name:!0}}},orderBy:{createdAt:"desc"}});return o.NextResponse.json({commissions:t.map(e=>({id:e.id,tenantName:e.tenant.name,subscriptionAmount:Number(e.subscriptionAmount),commissionRate:Number(e.commissionRate),commissionAmount:Number(e.commissionAmount),status:e.status,createdAt:e.createdAt}))})}catch(e){return console.error("Affiliate commissions error:",e),o.NextResponse.json({error:"Server error"},{status:500})}}let m=new n.AppRouteRouteModule({definition:{kind:s.x.APP_ROUTE,page:"/api/affiliate/commissions/route",pathname:"/api/affiliate/commissions",filename:"route",bundlePath:"app/api/affiliate/commissions/route"},resolvedPagePath:"D:\\PROJECT\\resto-saas\\src\\app\\api\\affiliate\\commissions\\route.ts",nextConfigOutput:"",userland:i}),{requestAsyncStorage:p,staticGenerationAsyncStorage:f,serverHooks:d}=m,x="/api/affiliate/commissions/route";function g(){return(0,a.patchFetch)({serverHooks:d,staticGenerationAsyncStorage:f})}},39655:(e,t,r)=>{r.d(t,{No:()=>c,Of:()=>l,PX:()=>u});var i=r(41482),n=r.n(i),s=r(71615),a=r(8194);let o=process.env.JWT_SECRET||"fallback-secret-change-me";function u(e){return n().sign({...e,isAffiliate:!0},o,{expiresIn:"7d"})}async function c(){let e=await (0,s.cookies)(),t=e.get("aff_token")?.value;if(!t)return null;let r=function(e){try{let t=n().verify(e,o);if(!t.isAffiliate)return null;return t}catch{return null}}(t);return r&&await a._.affiliate.findUnique({where:{id:r.affiliateId}})||null}async function l(){return await c()||null}},8194:(e,t,r)=>{r.d(t,{_:()=>n});let i=require("@prisma/client"),n=globalThis.prisma??new i.PrismaClient}};var t=require("../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),i=t.X(0,[8948,5972,4261],()=>r(31467));module.exports=i})();