"use strict";(()=>{var e={};e.id=8217,e.ids=[8217],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")},72922:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>g,patchFetch:()=>x,requestAsyncStorage:()=>m,routeModule:()=>p,serverHooks:()=>f,staticGenerationAsyncStorage:()=>w});var s={};r.r(s),r.d(s,{GET:()=>c,POST:()=>l});var a=r(49303),i=r(88716),n=r(60670),u=r(87070),o=r(8194),d=r(73218);async function c(){try{let{superAdmin:e,error:t}=await (0,d.WC)("cms:read");if(t)return t;let r=await o._.cmsPage.findMany({orderBy:{createdAt:"asc"}});return u.NextResponse.json({pages:r})}catch{return u.NextResponse.json({error:"Server error"},{status:500})}}async function l(e){try{let{superAdmin:t,error:r}=await (0,d.WC)("cms:write");if(r)return r;let{slug:s,title:a,content:i}=await e.json();if(!s||!a)return u.NextResponse.json({error:"Slug dan judul wajib diisi"},{status:400});let n=s.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"");if(await o._.cmsPage.findUnique({where:{slug:n}}))return u.NextResponse.json({error:"Slug sudah digunakan"},{status:400});let c=await o._.cmsPage.create({data:{slug:n,title:a,content:i||""}});return u.NextResponse.json({page:c},{status:201})}catch{return u.NextResponse.json({error:"Server error"},{status:500})}}let p=new a.AppRouteRouteModule({definition:{kind:i.x.APP_ROUTE,page:"/api/superadmin/cms/route",pathname:"/api/superadmin/cms",filename:"route",bundlePath:"app/api/superadmin/cms/route"},resolvedPagePath:"D:\\PROJECT\\resto-saas\\src\\app\\api\\superadmin\\cms\\route.ts",nextConfigOutput:"",userland:s}),{requestAsyncStorage:m,staticGenerationAsyncStorage:w,serverHooks:f}=p,g="/api/superadmin/cms/route";function x(){return(0,n.patchFetch)({serverHooks:f,staticGenerationAsyncStorage:w})}},8194:(e,t,r)=>{r.d(t,{_:()=>a});let s=require("@prisma/client"),a=globalThis.prisma??new s.PrismaClient},73218:(e,t,r)=>{r.d(t,{KV:()=>l,TM:()=>c,WC:()=>p});var s=r(41482),a=r.n(s),i=r(71615),n=r(87070),u=r(8194),o=r(579);let d=process.env.JWT_SECRET||"fallback-secret-change-me";function c(e){return a().sign({...e,isSuperAdmin:!0},d,{expiresIn:"7d"})}async function l(){let e=await (0,i.cookies)(),t=e.get("sa_token")?.value;if(!t)return null;let r=function(e){try{let t=a().verify(e,d);if(!t.isSuperAdmin)return null;return t}catch{return null}}(t);if(!r)return null;let s=await u._.superAdmin.findUnique({where:{id:r.superAdminId}});return s&&s.isActive?s:null}async function p(e){let t=await l();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:()=>i,j$:()=>s});let s=Object.values({SUPERADMIN:"superadmin",ADMIN:"admin",FINANCE:"finance",SUPPORT:"support",CONTENT:"content",VIEWER:"viewer"}),a={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=a[e];return!!r&&r.includes(t)}}};var t=require("../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[8948,5972,4261],()=>r(72922));module.exports=s})();