"use strict";(()=>{var e={};e.id=6453,e.ids=[6453],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")},6005:e=>{e.exports=require("node:crypto")},51556:(e,t,s)=>{s.r(t),s.d(t,{originalPathname:()=>f,patchFetch:()=>A,requestAsyncStorage:()=>y,routeModule:()=>m,serverHooks:()=>x,staticGenerationAsyncStorage:()=>g});var r={};s.r(r),s.d(r,{GET:()=>l,POST:()=>p});var a=s(49303),n=s(88716),o=s(60670),i=s(87070),c=s(19191),d=s(70446),u=s(90455);async function p(e){let t=await (0,d.Gg)(),s=(0,u.LP)(t)||(0,u.I2)(),r=await e.json(),a=t.user?.id??-1,n=t.storageLatitude||41.327546,o=t.storageLongitude||19.818698,p=t.langCode||"al";try{let e={customer:{id:a},regId:t.fcmToken||"",business:{restaurantID:r.restaurantId},address:{id:r.addressId||t.primaryAddress?.id||1,latitude:n,longitude:o,addressStreet:r.address||t.primaryAddress?.address||"",addressDetails:r.addressDetails||t.primaryAddress?.addressdetails||"",city:{id:t.cityId||1}},zone:{zoneNumber:1,minimumOrder:r.minimumOrder||0,transportcost:r.transportCost||0,deliveryTime:r.deliveryTime||50},discount:{id:r.discount?.id||0,couponCode:r.discount?.couponCode||""},items:r.items},d=await (0,c.q)("/carts/v1/create",{apiBase:"mobile",method:"POST",token:s,langCode:p,body:e,cache:"no-store"});if(d.statusMessage?.status===200||d.statusMessage?.success)return i.NextResponse.json({success:!0,data:d.data,cartId:d.data?.id});return i.NextResponse.json({success:!1,message:d.statusMessage?.message||"Failed to create cart"},{status:400})}catch(e){return console.error("[cart/create] ERROR:",e),i.NextResponse.json({success:!1,message:e.message||"Cart creation failed"},{status:500})}}async function l(){return i.NextResponse.json({success:!0,items:[]})}let m=new a.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/cart/route",pathname:"/api/cart",filename:"route",bundlePath:"app/api/cart/route"},resolvedPagePath:"/Users/ferlando/Desktop/baboon-nextjs/app/api/cart/route.ts",nextConfigOutput:"standalone",userland:r}),{requestAsyncStorage:y,staticGenerationAsyncStorage:g,serverHooks:x}=m,f="/api/cart/route";function A(){return(0,o.patchFetch)({serverHooks:x,staticGenerationAsyncStorage:g})}},19191:(e,t,s)=>{s.d(t,{F:()=>o,q:()=>n});var r=s(47090),a=s(70446);async function n(e,t={}){let{apiBase:s="mobile",method:n="GET",body:o,token:i,langCode:c,notificationToken:d,headers:u={},revalidate:p,cache:l}=t,m=r.Y8[s],y=`${m}${e.startsWith("/")?e:"/"+e}`,g={"Content-Type":"application/json","User-Agent":"BaboonWeb",...u};i&&(g.Authorization=i),c&&(g.langCode=c);let x=d;if(!x)try{x=(await (0,a.Gg)()).fcmToken}catch{}x&&(g.notificationToken=x);let f={method:n,headers:g};o&&"GET"!==n&&(f.body=JSON.stringify(o)),void 0!==p&&(f.next={revalidate:p}),l&&(f.cache=l);let A=await fetch(y,f);if(!A.ok)throw Error(`API request failed: ${A.status} ${A.statusText}`);return A.json()}async function o(e,t={}){let{apiBase:s="mobile",method:n="GET",body:o,token:i,langCode:c,notificationToken:d,headers:u={}}=t,p=r.Y8[s],l=`${p}${e.startsWith("/")?e:"/"+e}`,m={"Content-Type":"application/json","User-Agent":"BaboonWeb",...u};i&&(m.Authorization=i),c&&(m.langCode=c);let y=d;if(!y)try{y=(await (0,a.Gg)()).fcmToken}catch{}y&&(m.notificationToken=y);let g={method:n,headers:m};return o&&"GET"!==n&&(g.body=JSON.stringify(o)),fetch(l,g)}},90455:(e,t,s)=>{function r(e){return e.token?e.token:e.user?.token?e.user.token:process.env.BABOON_APP_BUSINESS_TOKEN||""}function a(){return process.env.BABOON_APP_BUSINESS_TOKEN||""}s.d(t,{I2:()=>a,LP:()=>r})},47090:(e,t,s)=>{s.d(t,{RF:()=>r,Y8:()=>n,pH:()=>a});let r=["al","en","it"],a={AL:{latitude:41.327546,longitude:19.818698,cityId:1,countryId:1},XK:{latitude:42.662914,longitude:21.165503,cityId:2,countryId:2}},n={mobile:process.env.BABOON_API_MOBILE_URL,legacy:process.env.BABOON_API_URL,sysadmin:process.env.BABOON_API_SYSADMIN_URL,payment:process.env.BABOON_API_PAYMENT_URL}},70446:(e,t,s)=>{s.d(t,{Gg:()=>i,dx:()=>n,l7:()=>o,yK:()=>c});var r=s(78632),a=s(71615);let n={password:process.env.SESSION_SECRET,cookieName:"baboon-session",cookieOptions:{secure:!0,httpOnly:!0,sameSite:"lax",maxAge:604800}},o={...n,cookieName:"baboon-admin-session"};async function i(){let e=await (0,a.cookies)();return(0,r.iW)(e,n)}async function c(){let e=await (0,a.cookies)();return(0,r.iW)(e,o)}}};var t=require("../../../webpack-runtime.js");t.C(e);var s=e=>t(t.s=e),r=t.X(0,[8948,3314,8632,5972],()=>s(51556));module.exports=r})();