"use strict";(()=>{var e={};e.id=736,e.ids=[736],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")},66762:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>m,patchFetch:()=>h,requestAsyncStorage:()=>d,routeModule:()=>c,serverHooks:()=>f,staticGenerationAsyncStorage:()=>x});var n={};r.r(n),r.d(n,{PUT:()=>p});var s=r(49303),a=r(88716),i=r(60670),o=r(87070),u=r(8194),l=r(95456);async function p(e){try{let t=await (0,l.ts)();if(!t)return o.NextResponse.json({error:"Unauthorized"},{status:401});let{positions:r}=await e.json();if(!Array.isArray(r)||0===r.length)return o.NextResponse.json({error:"positions array diperlukan"},{status:400});let n=r.map(e=>e.id),s=await u._.restTable.findMany({where:{id:{in:n}},include:{store:{select:{tenantId:!0}}}}),a=new Set(s.filter(e=>e.store.tenantId===t.tenantId).map(e=>e.id));return await u._.$transaction(r.filter(e=>a.has(e.id)).map(e=>u._.restTable.update({where:{id:e.id},data:{posX:e.posX??null,posY:e.posY??null,...void 0!==e.floorAreaId&&{floorAreaId:e.floorAreaId||null}}}))),o.NextResponse.json({success:!0})}catch{return o.NextResponse.json({error:"Server error"},{status:500})}}let c=new s.AppRouteRouteModule({definition:{kind:a.x.APP_ROUTE,page:"/api/tables/positions/route",pathname:"/api/tables/positions",filename:"route",bundlePath:"app/api/tables/positions/route"},resolvedPagePath:"D:\\PROJECT\\resto-saas\\src\\app\\api\\tables\\positions\\route.ts",nextConfigOutput:"",userland:n}),{requestAsyncStorage:d,staticGenerationAsyncStorage:x,serverHooks:f}=c,m="/api/tables/positions/route";function h(){return(0,i.patchFetch)({serverHooks:f,staticGenerationAsyncStorage:x})}},95456:(e,t,r)=>{r.d(t,{Gv:()=>c,MH:()=>m,PT:()=>h,RA:()=>d,WX:()=>x,c_:()=>p,ts:()=>f});var n=r(41482),s=r.n(n),a=r(42023),i=r.n(a),o=r(71615),u=r(8194);let l=process.env.JWT_SECRET||"fallback-secret-change-me";async function p(e){return i().hash(e,12)}async function c(e,t){return i().compare(e,t)}function d(e){return s().sign(e,l,{expiresIn:"7d"})}function x(e){try{return s().verify(e,l)}catch{return null}}async function f(){let e=await (0,o.cookies)(),t=e.get("token")?.value;if(!t)return null;let r=x(t);return r?await u._.user.findUnique({where:{id:r.userId},include:{tenant:!0,store:!0}}):null}function m(e,t){return t.includes(e)}function h(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(66762));module.exports=n})();