"use strict";(()=>{var e={};e.id=9715,e.ids=[9715],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")},84584:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>h,patchFetch:()=>w,requestAsyncStorage:()=>f,routeModule:()=>p,serverHooks:()=>m,staticGenerationAsyncStorage:()=>x});var n={};t.r(n),t.d(n,{GET:()=>d,POST:()=>l});var s=t(49303),o=t(88716),a=t(60670),i=t(87070),u=t(8194),c=t(95456);async function d(e){try{let r=await (0,c.ts)();if(!r)return i.NextResponse.json({error:"Unauthorized"},{status:401});let t=e.nextUrl.searchParams.get("storeId");if(!t)return i.NextResponse.json({error:"storeId diperlukan"},{status:400});if(!await u._.store.findFirst({where:{id:t,tenantId:r.tenantId}}))return i.NextResponse.json({error:"Store not found"},{status:404});let n=await u._.floorArea.findMany({where:{storeId:t},orderBy:{sortOrder:"asc"},include:{_count:{select:{tables:!0}}}});return i.NextResponse.json({floorAreas:n})}catch{return i.NextResponse.json({error:"Server error"},{status:500})}}async function l(e){try{let r=await (0,c.ts)();if(!r)return i.NextResponse.json({error:"Unauthorized"},{status:401});let{storeId:t,name:n}=await e.json();if(!t||!n?.trim())return i.NextResponse.json({error:"storeId dan nama diperlukan"},{status:400});if(!await u._.store.findFirst({where:{id:t,tenantId:r.tenantId}}))return i.NextResponse.json({error:"Store not found"},{status:404});let s=await u._.floorArea.findFirst({where:{storeId:t},orderBy:{sortOrder:"desc"}}),o=await u._.floorArea.create({data:{storeId:t,name:n.trim(),sortOrder:(s?.sortOrder??-1)+1}});return i.NextResponse.json({floorArea:o},{status:201})}catch{return i.NextResponse.json({error:"Server error"},{status:500})}}let p=new s.AppRouteRouteModule({definition:{kind:o.x.APP_ROUTE,page:"/api/floor-areas/route",pathname:"/api/floor-areas",filename:"route",bundlePath:"app/api/floor-areas/route"},resolvedPagePath:"D:\\PROJECT\\resto-saas\\src\\app\\api\\floor-areas\\route.ts",nextConfigOutput:"",userland:n}),{requestAsyncStorage:f,staticGenerationAsyncStorage:x,serverHooks:m}=p,h="/api/floor-areas/route";function w(){return(0,a.patchFetch)({serverHooks:m,staticGenerationAsyncStorage:x})}},95456:(e,r,t)=>{t.d(r,{Gv:()=>l,MH:()=>m,PT:()=>h,RA:()=>p,WX:()=>f,c_:()=>d,ts:()=>x});var n=t(41482),s=t.n(n),o=t(42023),a=t.n(o),i=t(71615),u=t(8194);let c=process.env.JWT_SECRET||"fallback-secret-change-me";async function d(e){return a().hash(e,12)}async function l(e,r){return a().compare(e,r)}function p(e){return s().sign(e,c,{expiresIn:"7d"})}function f(e){try{return s().verify(e,c)}catch{return null}}async function x(){let e=await (0,i.cookies)(),r=e.get("token")?.value;if(!r)return null;let t=f(r);return t?await u._.user.findUnique({where:{id:t.userId},include:{tenant:!0,store:!0}}):null}function m(e,r){return r.includes(e)}function h(e){return!["owner","admin"].includes(e.role)&&!!e.storeId&&!!e.store&&!e.store.isActive}},8194:(e,r,t)=>{t.d(r,{_:()=>s});let n=require("@prisma/client"),s=globalThis.prisma??new n.PrismaClient}};var r=require("../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),n=r.X(0,[8948,5972,4261,2023],()=>t(84584));module.exports=n})();