"use strict";(()=>{var e={};e.id=6467,e.ids=[6467],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")},25885:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>w,patchFetch:()=>h,requestAsyncStorage:()=>c,routeModule:()=>p,serverHooks:()=>f,staticGenerationAsyncStorage:()=>m});var a={};r.r(a),r.d(a,{GET:()=>u});var i=r(49303),s=r(88716),n=r(60670),d=r(87070),o=r(73218),l=r(8194);async function u(){try{let{error:e}=await (0,o.WC)("affiliates:read");if(e)return e;let t=await l._.affiliateWithdrawal.findMany({include:{affiliate:{select:{name:!0,email:!0}}},orderBy:{createdAt:"desc"},take:100});return d.NextResponse.json({withdrawals:t.map(e=>({id:e.id,affiliateName:e.affiliate.name,affiliateEmail:e.affiliate.email,amount:Number(e.amount),bankName:e.bankName,bankAccount:e.bankAccount,bankHolder:e.bankHolder,status:e.status,adminNotes:e.adminNotes,processedAt:e.processedAt,createdAt:e.createdAt}))})}catch(e){return console.error("Superadmin affiliate withdrawals error:",e),d.NextResponse.json({error:"Server error"},{status:500})}}let p=new i.AppRouteRouteModule({definition:{kind:s.x.APP_ROUTE,page:"/api/superadmin/affiliates/withdrawals/route",pathname:"/api/superadmin/affiliates/withdrawals",filename:"route",bundlePath:"app/api/superadmin/affiliates/withdrawals/route"},resolvedPagePath:"D:\\PROJECT\\resto-saas\\src\\app\\api\\superadmin\\affiliates\\withdrawals\\route.ts",nextConfigOutput:"",userland:a}),{requestAsyncStorage:c,staticGenerationAsyncStorage:m,serverHooks:f}=p,w="/api/superadmin/affiliates/withdrawals/route";function h(){return(0,n.patchFetch)({serverHooks:f,staticGenerationAsyncStorage:m})}},8194:(e,t,r)=>{r.d(t,{_:()=>i});let a=require("@prisma/client"),i=globalThis.prisma??new a.PrismaClient},73218:(e,t,r)=>{r.d(t,{KV:()=>p,TM:()=>u,WC:()=>c});var a=r(41482),i=r.n(a),s=r(71615),n=r(87070),d=r(8194),o=r(579);let l=process.env.JWT_SECRET||"fallback-secret-change-me";function u(e){return i().sign({...e,isSuperAdmin:!0},l,{expiresIn:"7d"})}async function p(){let e=await (0,s.cookies)(),t=e.get("sa_token")?.value;if(!t)return null;let r=function(e){try{let t=i().verify(e,l);if(!t.isSuperAdmin)return null;return t}catch{return null}}(t);if(!r)return null;let a=await d._.superAdmin.findUnique({where:{id:r.superAdminId}});return a&&a.isActive?a:null}async function c(e){let t=await p();return t?(0,o.Fs)(t.role,e)?{superAdmin:t,error:null}:{superAdmin:null,error:n.NextResponse.json({error:"Anda tidak memiliki akses untuk fitur ini"},{status:403})}:{superAdmin:null,error:n.NextResponse.json({error:"Tidak terautentikasi"},{status:401})}}},579:(e,t,r)=>{r.d(t,{Fs:()=>s,j$:()=>a});let a=Object.values({SUPERADMIN:"superadmin",ADMIN:"admin",FINANCE:"finance",SUPPORT:"support",CONTENT:"content",VIEWER:"viewer"}),i={superadmin:["dashboard:read","plans:read","plans:write","tenants:read","tenants:write","subscriptions:read","subscriptions:write","payment_settings:read","payment_settings:write","withdrawals:read","withdrawals:write","tickets:read","tickets:write","cms:read","cms:write","staff:read","staff:write","affiliates:read","affiliates:write","email_settings:read","email_settings:write"],admin:["dashboard:read","plans:read","plans:write","tenants:read","tenants:write","subscriptions:read","subscriptions:write","payment_settings:read","payment_settings:write","withdrawals:read","withdrawals:write","tickets:read","tickets:write","cms:read","cms:write","affiliates:read","affiliates:write","email_settings:read","email_settings:write"],finance:["dashboard:read","subscriptions:read","payment_settings:read","payment_settings:write","withdrawals:read","withdrawals:write","affiliates:read"],support:["dashboard:read","tenants:read","tickets:read","tickets:write"],content:["dashboard:read","cms:read","cms:write"],viewer:["dashboard:read"]};function s(e,t){let r=i[e];return!!r&&r.includes(t)}}};var t=require("../../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),a=t.X(0,[8948,5972,4261],()=>r(25885));module.exports=a})();