"use strict";(()=>{var e={};e.id=9827,e.ids=[9827],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")},82193:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>v,patchFetch:()=>h,requestAsyncStorage:()=>m,routeModule:()=>l,serverHooks:()=>f,staticGenerationAsyncStorage:()=>x});var n={};r.r(n),r.d(n,{GET:()=>d,POST:()=>p});var a=r(49303),s=r(88716),i=r(60670),o=r(87070),u=r(8194),c=r(95456);async function d(e,{params:t}){try{let e=await (0,c.ts)();if(!e)return o.NextResponse.json({error:"Unauthorized"},{status:401});let{id:r}=await t,n=await u._.menuVariantGroup.findMany({where:{menuItemId:r,menuItem:{tenantId:e.tenantId}},include:{variants:{orderBy:{sortOrder:"asc"}}},orderBy:{sortOrder:"asc"}});return o.NextResponse.json({variantGroups:n})}catch{return o.NextResponse.json({error:"Server error"},{status:500})}}async function p(e,{params:t}){try{let r=await (0,c.ts)();if(!r)return o.NextResponse.json({error:"Unauthorized"},{status:401});if(!["owner","admin","manager"].includes(r.role))return o.NextResponse.json({error:"Forbidden"},{status:403});let{id:n}=await t;if(!await u._.menuItem.findFirst({where:{id:n,tenantId:r.tenantId}}))return o.NextResponse.json({error:"Menu item tidak ditemukan"},{status:404});let{name:a,required:s,maxSelect:i,variants:d}=await e.json();if(!a||!d||0===d.length)return o.NextResponse.json({error:"Nama grup dan minimal 1 varian wajib diisi"},{status:400});let p=await u._.menuVariantGroup.create({data:{menuItemId:n,name:a,required:s||!1,maxSelect:i||1,variants:{create:d.map((e,t)=>({name:e.name,priceAdjustment:e.priceAdjustment||0,sortOrder:t}))}},include:{variants:!0}});return o.NextResponse.json({variantGroup:p},{status:201})}catch{return o.NextResponse.json({error:"Server error"},{status:500})}}let l=new a.AppRouteRouteModule({definition:{kind:s.x.APP_ROUTE,page:"/api/menu/[id]/variants/route",pathname:"/api/menu/[id]/variants",filename:"route",bundlePath:"app/api/menu/[id]/variants/route"},resolvedPagePath:"D:\\PROJECT\\resto-saas\\src\\app\\api\\menu\\[id]\\variants\\route.ts",nextConfigOutput:"",userland:n}),{requestAsyncStorage:m,staticGenerationAsyncStorage:x,serverHooks:f}=l,v="/api/menu/[id]/variants/route";function h(){return(0,i.patchFetch)({serverHooks:f,staticGenerationAsyncStorage:x})}},95456:(e,t,r)=>{r.d(t,{Gv:()=>p,MH:()=>f,PT:()=>v,RA:()=>l,WX:()=>m,c_:()=>d,ts:()=>x});var n=r(41482),a=r.n(n),s=r(42023),i=r.n(s),o=r(71615),u=r(8194);let c=process.env.JWT_SECRET||"fallback-secret-change-me";async function d(e){return i().hash(e,12)}async function p(e,t){return i().compare(e,t)}function l(e){return a().sign(e,c,{expiresIn:"7d"})}function m(e){try{return a().verify(e,c)}catch{return null}}async function x(){let e=await (0,o.cookies)(),t=e.get("token")?.value;if(!t)return null;let r=m(t);return r?await u._.user.findUnique({where:{id:r.userId},include:{tenant:!0,store:!0}}):null}function f(e,t){return t.includes(e)}function v(e){return!["owner","admin"].includes(e.role)&&!!e.storeId&&!!e.store&&!e.store.isActive}},8194:(e,t,r)=>{r.d(t,{_:()=>a});let n=require("@prisma/client"),a=globalThis.prisma??new n.PrismaClient}};var t=require("../../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),n=t.X(0,[8948,5972,4261,2023],()=>r(82193));module.exports=n})();