"use strict";(()=>{var e={};e.id=36,e.ids=[36],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")},80439:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>x,patchFetch:()=>g,requestAsyncStorage:()=>w,routeModule:()=>m,serverHooks:()=>h,staticGenerationAsyncStorage:()=>f});var a={};r.r(a),r.d(a,{POST:()=>c});var s=r(49303),i=r(88716),n=r(60670),o=r(87070),u=r(8194),d=r(42023),l=r.n(d),p=r(73218);async function c(e){try{let{email:t,password:r}=await e.json();if(!t||!r)return o.NextResponse.json({error:"Email dan password wajib diisi"},{status:400});let a=await u._.superAdmin.findUnique({where:{email:t}});if(!a)return o.NextResponse.json({error:"Email atau password salah"},{status:401});if(!a.isActive)return o.NextResponse.json({error:"Akun tidak aktif"},{status:403});if(!await l().compare(r,a.password))return o.NextResponse.json({error:"Email atau password salah"},{status:401});let s=(0,p.TM)({superAdminId:a.id,email:a.email,role:a.role}),i=o.NextResponse.json({superAdmin:{id:a.id,name:a.name,email:a.email,role:a.role}});return i.cookies.set("sa_token",s,{httpOnly:!0,secure:!0,sameSite:"lax",maxAge:604800,path:"/"}),i}catch(e){return console.error("Super admin login error:",e),o.NextResponse.json({error:"Terjadi kesalahan server"},{status:500})}}let m=new s.AppRouteRouteModule({definition:{kind:i.x.APP_ROUTE,page:"/api/superadmin/auth/login/route",pathname:"/api/superadmin/auth/login",filename:"route",bundlePath:"app/api/superadmin/auth/login/route"},resolvedPagePath:"D:\\PROJECT\\resto-saas\\src\\app\\api\\superadmin\\auth\\login\\route.ts",nextConfigOutput:"",userland:a}),{requestAsyncStorage:w,staticGenerationAsyncStorage:f,serverHooks:h}=m,x="/api/superadmin/auth/login/route";function g(){return(0,n.patchFetch)({serverHooks:h,staticGenerationAsyncStorage:f})}},8194:(e,t,r)=>{r.d(t,{_:()=>s});let a=require("@prisma/client"),s=globalThis.prisma??new a.PrismaClient},73218:(e,t,r)=>{r.d(t,{KV:()=>p,TM:()=>l,WC:()=>c});var a=r(41482),s=r.n(a),i=r(71615),n=r(87070),o=r(8194),u=r(579);let d=process.env.JWT_SECRET||"fallback-secret-change-me";function l(e){return s().sign({...e,isSuperAdmin:!0},d,{expiresIn:"7d"})}async function p(){let e=await (0,i.cookies)(),t=e.get("sa_token")?.value;if(!t)return null;let r=function(e){try{let t=s().verify(e,d);if(!t.isSuperAdmin)return null;return t}catch{return null}}(t);if(!r)return null;let a=await o._.superAdmin.findUnique({where:{id:r.superAdminId}});return a&&a.isActive?a:null}async function c(e){let t=await p();return t?(0,u.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:()=>i,j$:()=>a});let a=Object.values({SUPERADMIN:"superadmin",ADMIN:"admin",FINANCE:"finance",SUPPORT:"support",CONTENT:"content",VIEWER:"viewer"}),s={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 i(e,t){let r=s[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,2023],()=>r(80439));module.exports=a})();