"use strict";(()=>{var e={};e.id=108,e.ids=[108],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")},25488:(e,t,n)=>{n.r(t),n.d(t,{originalPathname:()=>f,patchFetch:()=>h,requestAsyncStorage:()=>x,routeModule:()=>m,serverHooks:()=>I,staticGenerationAsyncStorage:()=>y});var r={};n.r(r),n.d(r,{DELETE:()=>p,PUT:()=>l});var a=n(49303),s=n(88716),i=n(60670),u=n(87070),o=n(8194),c=n(95456),d=n(57662);async function l(e,{params:t}){try{let n=await (0,c.ts)();if(!n)return u.NextResponse.json({error:"Unauthorized"},{status:401});let{id:r}=await t,a=await e.json(),s=await o._.menuItem.update({where:{id:r,tenantId:n.tenantId},data:a,include:{category:!0}});return(0,d.w)({tenantId:n.tenantId,userId:n.id,userName:n.name,userRole:n.role,action:"UPDATE",entity:"Menu",entityId:r,description:`Mengubah menu "${s.name}"`,meta:{changes:a,name:s.name}}),u.NextResponse.json({menuItem:s})}catch{return u.NextResponse.json({error:"Server error"},{status:500})}}async function p(e,{params:t}){try{let e=await (0,c.ts)();if(!e)return u.NextResponse.json({error:"Unauthorized"},{status:401});let{id:n}=await t,r=await o._.menuItem.findFirst({where:{id:n,tenantId:e.tenantId},select:{name:!0}});return await o._.menuItem.update({where:{id:n,tenantId:e.tenantId},data:{isActive:!1}}),(0,d.w)({tenantId:e.tenantId,userId:e.id,userName:e.name,userRole:e.role,action:"DELETE",entity:"Menu",entityId:n,description:`Menghapus menu "${r?.name||n}"`}),u.NextResponse.json({success:!0})}catch{return u.NextResponse.json({error:"Server error"},{status:500})}}let m=new a.AppRouteRouteModule({definition:{kind:s.x.APP_ROUTE,page:"/api/menu/[id]/route",pathname:"/api/menu/[id]",filename:"route",bundlePath:"app/api/menu/[id]/route"},resolvedPagePath:"D:\\PROJECT\\resto-saas\\src\\app\\api\\menu\\[id]\\route.ts",nextConfigOutput:"",userland:r}),{requestAsyncStorage:x,staticGenerationAsyncStorage:y,serverHooks:I}=m,f="/api/menu/[id]/route";function h(){return(0,i.patchFetch)({serverHooks:I,staticGenerationAsyncStorage:y})}},57662:(e,t,n)=>{n.d(t,{w:()=>s});var r=n(8194);async function a(e){return r._.auditLog.create({data:{tenantId:e.tenantId,userId:e.userId||null,userName:e.userName||null,userRole:e.userRole||null,action:e.action,entity:e.entity,entityId:e.entityId||null,description:e.description,meta:e.meta?JSON.stringify(e.meta):null}})}function s(e){a(e).catch(e=>{console.error("[AuditLog] Failed to log activity:",e)})}},95456:(e,t,n)=>{n.d(t,{Gv:()=>l,MH:()=>y,PT:()=>I,RA:()=>p,WX:()=>m,c_:()=>d,ts:()=>x});var r=n(41482),a=n.n(r),s=n(42023),i=n.n(s),u=n(71615),o=n(8194);let c=process.env.JWT_SECRET||"fallback-secret-change-me";async function d(e){return i().hash(e,12)}async function l(e,t){return i().compare(e,t)}function p(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,u.cookies)(),t=e.get("token")?.value;if(!t)return null;let n=m(t);return n?await o._.user.findUnique({where:{id:n.userId},include:{tenant:!0,store:!0}}):null}function y(e,t){return t.includes(e)}function I(e){return!["owner","admin"].includes(e.role)&&!!e.storeId&&!!e.store&&!e.store.isActive}},8194:(e,t,n)=>{n.d(t,{_:()=>a});let r=require("@prisma/client"),a=globalThis.prisma??new r.PrismaClient}};var t=require("../../../../webpack-runtime.js");t.C(e);var n=e=>t(t.s=e),r=t.X(0,[8948,5972,4261,2023],()=>n(25488));module.exports=r})();