"use strict";(()=>{var e={};e.id=9961,e.ids=[9961],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")},99463:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>f,patchFetch:()=>h,requestAsyncStorage:()=>x,routeModule:()=>m,serverHooks:()=>y,staticGenerationAsyncStorage:()=>g});var n={};r.r(n),r.d(n,{GET:()=>l,POST:()=>p});var s=r(49303),a=r(88716),o=r(60670),i=r(87070),u=r(8194),c=r(95456),d=r(57662);async function l(){try{let e=await (0,c.ts)();if(!e)return i.NextResponse.json({error:"Unauthorized"},{status:401});let t=await u._.category.findMany({where:{tenantId:e.tenantId,isActive:!0},include:{_count:{select:{menuItems:!0}},kitchenStation:{select:{id:!0,name:!0,color:!0}}},orderBy:{sortOrder:"asc"}});return i.NextResponse.json({categories:t})}catch{return i.NextResponse.json({error:"Server error"},{status:500})}}async function p(e){try{let t=await (0,c.ts)();if(!t)return i.NextResponse.json({error:"Unauthorized"},{status:401});if(!["owner","admin","manager"].includes(t.role))return i.NextResponse.json({error:"Forbidden"},{status:403});let{name:r,sortOrder:n}=await e.json();if(!r)return i.NextResponse.json({error:"Nama kategori wajib diisi"},{status:400});let s=await u._.category.create({data:{tenantId:t.tenantId,name:r,sortOrder:n||0}});return(0,d.w)({tenantId:t.tenantId,userId:t.id,userName:t.name,userRole:t.role,action:"CREATE",entity:"Category",entityId:s.id,description:`Menambahkan kategori "${r}"`}),i.NextResponse.json({category:s},{status:201})}catch{return i.NextResponse.json({error:"Server error"},{status:500})}}let m=new s.AppRouteRouteModule({definition:{kind:a.x.APP_ROUTE,page:"/api/categories/route",pathname:"/api/categories",filename:"route",bundlePath:"app/api/categories/route"},resolvedPagePath:"D:\\PROJECT\\resto-saas\\src\\app\\api\\categories\\route.ts",nextConfigOutput:"",userland:n}),{requestAsyncStorage:x,staticGenerationAsyncStorage:g,serverHooks:y}=m,f="/api/categories/route";function h(){return(0,o.patchFetch)({serverHooks:y,staticGenerationAsyncStorage:g})}},57662:(e,t,r)=>{r.d(t,{w:()=>a});var n=r(8194);async function s(e){return n._.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 a(e){s(e).catch(e=>{console.error("[AuditLog] Failed to log activity:",e)})}},95456:(e,t,r)=>{r.d(t,{Gv:()=>l,MH:()=>g,PT:()=>y,RA:()=>p,WX:()=>m,c_:()=>d,ts:()=>x});var n=r(41482),s=r.n(n),a=r(42023),o=r.n(a),i=r(71615),u=r(8194);let c=process.env.JWT_SECRET||"fallback-secret-change-me";async function d(e){return o().hash(e,12)}async function l(e,t){return o().compare(e,t)}function p(e){return s().sign(e,c,{expiresIn:"7d"})}function m(e){try{return s().verify(e,c)}catch{return null}}async function x(){let e=await (0,i.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 g(e,t){return t.includes(e)}function y(e){return!["owner","admin"].includes(e.role)&&!!e.storeId&&!!e.store&&!e.store.isActive}},8194:(e,t,r)=>{r.d(t,{_:()=>s});let n=require("@prisma/client"),s=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(99463));module.exports=n})();