@shophost/react 2.0.57 → 2.0.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/admin/customer/components/customer-details/index.d.ts +1 -0
- package/admin/customer/components/customers-list/columns.d.ts +3 -0
- package/admin/customer/components/customers-list/index.d.ts +1 -0
- package/admin/customer/views/customer-detail-view.d.ts +1 -0
- package/admin/customer/views/customers-view.d.ts +1 -0
- package/admin/order/components/orders-list/columns.d.ts +1 -1
- package/admin/reservation/components/reservations-list/reservation-edit-form.d.ts +9 -0
- package/admin/router/resolve.d.ts +7 -0
- package/admin/router/routes.d.ts +2 -0
- package/admin-client.cjs +1 -1
- package/admin-client.js +2097 -1968
- package/index.react-server.cjs +1 -1
- package/index.react-server.mjs +1 -1
- package/package.json +3 -3
- package/react.css +1 -1
package/admin-client.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";const e=require("react/jsx-runtime"),A=require("@tanstack/react-query"),xs=require("next-themes"),h=require("react"),J=require("react-hot-toast"),ot=require("better-auth/client/plugins"),fs=require("better-auth/react"),Z=require("react-hook-form"),N=require("lucide-react"),ys=require("@vercel/blob/client"),ze=require("next/image.js"),aa=require("use-debounce"),v=require("classnames"),Vn=require("use-mask-input"),ya=require("@headlessui/react"),M=require("@remixicon/react"),B=require("next/link.js"),D=require("next/navigation.js"),be=require("@hookform/resolvers/zod"),I=require("date-fns"),qn=require("@shophost/client"),d=require("@hono/zod-openapi"),ar=require("@radix-ui/react-slot"),Oe=require("tailwind-variants"),bs=require("clsx"),js=require("tailwind-merge"),Hn=require("@radix-ui/react-label"),ae=require("recharts"),he=require("@internationalized/date"),Un=require("@radix-ui/react-popover"),ws=require("@react-aria/datepicker"),Zn=require("@react-stately/datepicker"),_n=require("date-fns/locale"),Ta=require("react-day-picker"),G=require("cmdk"),$n=require("@radix-ui/react-dialog"),Wn=require("react-phone-number-input"),vs=require("react-phone-number-input/flags"),Kn=require("@radix-ui/react-switch"),Gn=require("@radix-ui/react-radio-group"),Xn=require("tailwindcss/colors"),Yn=require("@radix-ui/react-navigation-menu"),Ee=require("@tanstack/react-table"),eo=require("@radix-ui/react-checkbox"),ao=require("@radix-ui/react-dropdown-menu"),to=require("@radix-ui/react-select"),Ge=require("zod");function Te(a){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const r in a)if(r!=="default"){const s=Object.getOwnPropertyDescriptor(a,r);Object.defineProperty(t,r,s.get?s:{enumerable:!0,get:()=>a[r]})}}return t.default=a,Object.freeze(t)}const z=Te(h),ks=Te(Hn),se=Te(Un),re=Te($n),vt=Te(Wn),lt=Te(Kn),tr=Te(Gn),dt=Te(Yn),Ur=Te(eo),ye=Te(ao),de=Te(to),oe=new A.QueryClient({defaultOptions:{queries:{retry:!1,refetchInterval:!1,refetchOnWindowFocus:!1}}}),Ns=h.createContext(null),rr=({baseUrl:a,children:t})=>{const r=h.useMemo(()=>qn.initClient({baseUrl:a,throwOnUnknownStatus:!0,baseHeaders:{},credentials:"include"}),[a]);return e.jsx(Ns.Provider,{value:{client:r,baseUrl:a},children:t})},P=()=>{const a=h.useContext(Ns);if(!a)throw new Error("useAPI must be used within a APIProvider");return a},As=h.createContext(null),ro=({client:a,children:t})=>e.jsx(As.Provider,{value:a,children:t});function Ja(){const a=h.useContext(As);if(!a)throw new Error("useAdminAuth must be used within AdminProvider");return a}const Cs=h.createContext(null),so=({config:a,children:t})=>e.jsx(Cs.Provider,{value:a,children:t});function Ss(){const a=h.useContext(Cs);if(!a)throw new Error("useAdminConfig must be used within AdminProvider");return a}const zs=h.createContext(null),io=({routes:a,children:t})=>e.jsx(zs.Provider,{value:a,children:t});function $(){const a=h.useContext(zs);if(!a)throw new Error("useAdminRoutes must be used within AdminProvider");return a}function Is(a){return fs.createAuthClient({baseURL:a,plugins:[ot.inferAdditionalFields(),ot.organizationClient()]})}const _t=new Map;function Es(a){return _t.has(a)||_t.set(a,Is(a)),_t.get(a)}function Ds(a){const t=a.replace(/\/$/,"");return{home:t,signIn:`${t}/auth/sign-in`,signUp:`${t}/auth/sign-up`,organizations:`${t}/organizations`,dashboard:r=>`${t}/${r}/dashboard`,liveOrders:r=>`${t}/${r}/live-orders`,orders:r=>`${t}/${r}/orders`,reservations:r=>`${t}/${r}/reservations`,products:r=>`${t}/${r}/products`,productCreate:r=>`${t}/${r}/products/create`,productEdit:(r,s)=>`${t}/${r}/products/${s}`,productCategories:r=>`${t}/${r}/product-categories`,productCategoryCreate:r=>`${t}/${r}/product-categories/create`,productCategoryEdit:(r,s)=>`${t}/${r}/product-categories/${s}`,manufacturers:r=>`${t}/${r}/manufacturers`,manufacturerCreate:r=>`${t}/${r}/manufacturers/create`,manufacturerEdit:(r,s)=>`${t}/${r}/manufacturers/${s}`,settings:r=>`${t}/${r}/settings`,settingsIntegrations:r=>`${t}/${r}/settings/integrations`,settingsIntegrationsCreate:r=>`${t}/${r}/settings/integrations/create`,settingsIntegration:(r,s)=>`${t}/${r}/settings/integrations/${s}`,settingsOpeningTimes:r=>`${t}/${r}/settings/opening-times`,settingsShippingMethods:r=>`${t}/${r}/settings/shipping-methods`,settingsShippingMethodCreate:r=>`${t}/${r}/settings/shipping-methods/create`,settingsShippingMethodEdit:(r,s)=>`${t}/${r}/settings/shipping-methods/${s}`,settingsAccess:r=>`${t}/${r}/settings/access`,settingsAccessInvite:r=>`${t}/${r}/settings/access/invite`,settingsAccessMemberEdit:(r,s)=>`${t}/${r}/settings/access/${s}`}}function no({config:a,children:t}){const r=h.useMemo(()=>Es(a.apiBaseUrl),[a.apiBaseUrl]),s=h.useMemo(()=>Ds(a.basePath),[a.basePath]);return e.jsx(A.QueryClientProvider,{client:oe,children:e.jsxs("div",{className:"shophost-admin",children:[e.jsx(xs.ThemeProvider,{defaultTheme:"light",attribute:"class",children:e.jsx(rr,{baseUrl:a.apiBaseUrl,children:e.jsx(ro,{client:r,children:e.jsx(so,{config:a,children:e.jsx(io,{routes:s,children:t})})})})}),e.jsx(J.Toaster,{})]})})}const _a="shophost-cart",oo={items:[],isInitialized:!1,modifierModal:null,totalAmount:0,itemCount:0,removedItemsAlert:!1},Rs=(a,t)=>a.reduce((r,s)=>{const i=t(s.productId);if(!i)return r;const n=s.quantity||1;let o=Number(i.discountedBasePrice??i.basePrice??0)*n;return s.modifierGroups&&s.modifierGroups.length>0&&s.modifierGroups.forEach(l=>{var m;const c=(m=i.modifierGroups)==null?void 0:m.find(u=>u.id===l.id);c&&l.modifiers.forEach(u=>{const p=c.modifiers.find(g=>g.id===u.id);if(p){const g=u.quantity||1;o+=Number(p.price??0)*g*n}})}),r+o},0),we=(a,t="USD",r="en-US")=>new Intl.NumberFormat(r,{style:"currency",currency:t}).format(a),lo=(a,t,r="en-US")=>{const s=t(a.productId);return!s||!a.modifierGroups||a.modifierGroups.length===0?"":a.modifierGroups.filter(i=>i&&i.modifiers).map(i=>{var c,m,u,p;const n=(c=s.modifierGroups)==null?void 0:c.find(g=>g&&g.id===i.id);if(!n||!n.modifiers)return"";const o=((u=(m=n.translations)==null?void 0:m.find(g=>g&&g.locale===r))==null?void 0:u.title)||(n.translations&&n.translations.length>0?(p=n.translations[0])==null?void 0:p.title:"")||"",l=(i.modifiers||[]).filter(g=>g).map(g=>{const x=n.modifiers.find(f=>f&&f.id===g.id);if(!x)return"";const y=x.title||"",j=g.quantity||1;return j>1?`${y} (${j})`:y}).filter(Boolean).join(", ");return o?`${o}: ${l}`:l}).filter(Boolean).join(" | ")},Fs=(a,t,r)=>a.find(s=>Xe(s,{productId:t,modifierGroups:r})),Xe=(a,t)=>{if(a.productId!==t.productId)return!1;const r=t.modifierGroups??[],s=a.modifierGroups??[];return r.length===0?s.length===0:co(s,r)},co=(a,t)=>{if(a.length!==t.length)return!1;const r=[...t];return a.every(s=>{const i=r.findIndex(n=>{if(s.id!==n.id||s.modifiers.length!==n.modifiers.length)return!1;const o=[...n.modifiers];return s.modifiers.every(l=>{const c=o.findIndex(m=>l.id===m.id&&(l.quantity||1)===(m.quantity||1));return c>=0?(o.splice(c,1),!0):!1})});return i>=0?(r.splice(i,1),!0):!1})},mo=a=>!a.modifierGroups||a.modifierGroups.length===0?!1:a.modifierGroups.some(t=>t.selectMin>0),uo=(a,t)=>{var r,s,i;if(a.length===0)return{valid:!0};for(const n of a){const o=((r=t.find(u=>u.groupId===n.id))==null?void 0:r.modifierIds.length)||0,l=n.selectMin??0,c=n.selectMax??0,m=("title"in n?n.title:void 0)||("translations"in n?(i=(s=n.translations)==null?void 0:s[0])==null?void 0:i.title:void 0)||"Option";if(l>0&&o<l)return{valid:!1,message:`Please select at least ${l} ${m}`};if(c>0&&o>c)return{valid:!1,message:`You can select at most ${c} ${m}`}}return{valid:!0}},la=a=>a.reduce((t,r)=>t+(r.quantity||1),0),po=(a,t)=>a.findIndex(r=>Xe(r,{productId:t.productId,modifierGroups:t.modifierGroups})),go=(a,t,r)=>a.map(s=>Xe(s,t)?{...s,quantity:r}:s),ho=(a,t)=>a.filter(r=>!Xe(r,t)),xo=(a,t)=>{const r=po(a,t);return r===-1?[...a,t]:a.map((s,i)=>i===r?{...s,quantity:(s.quantity||1)+(t.quantity||1)}:s)},fo=(a,t)=>!a.modifierGroups||a.modifierGroups.length===0?!0:!t.modifierGroups||t.modifierGroups.length===0?!1:a.modifierGroups.every(r=>{var i;const s=(i=t.modifierGroups)==null?void 0:i.find(n=>n.id===r.id);return s?r.modifiers.every(n=>{var o;return!!((o=s.modifiers)!=null&&o.find(l=>l.id===n.id))}):!1}),Ms=(a,t)=>{switch(t.type){case"INITIALIZE_CART":{const r=t.payload;return{...a,items:r,itemCount:la(r)}}case"REPLACE_ITEMS":{const r=t.payload;return{...a,items:r,itemCount:la(r)}}case"SET_INITIALIZED":return{...a,isInitialized:t.payload};case"ADD_ITEM":{const r=xo(a.items,t.payload);return{...a,items:r,itemCount:la(r)}}case"UPDATE_ITEM_QUANTITY":{const{productId:r,quantity:s,modifierGroups:i}=t.payload;if(s<=0)return Ms(a,{type:"REMOVE_ITEM",payload:{productId:r,modifierGroups:i}});const n=go(a.items,{productId:r,modifierGroups:i},s);return{...a,items:n,itemCount:la(n)}}case"REMOVE_ITEM":{const r=ho(a.items,t.payload);return{...a,items:r,itemCount:la(r)}}case"CLEAR_CART":return{...a,items:[],itemCount:0,totalAmount:0};case"OPEN_MODIFIERS_MODAL":return{...a,modifierModal:t.payload};case"CLOSE_MODIFIERS_MODAL":return{...a,modifierModal:null};case"UPDATE_TOTALS":{const{productsData:r}=t.payload,s=a.items.reduce((i,n)=>{const o=r[n.productId];if(!o)return i;const l=Number(o.discountedBasePrice??o.basePrice??0);return i+l*(n.quantity||1)},0);return{...a,totalAmount:s}}case"REMOVE_UNAVAILABLE_PRODUCTS":{const{productsData:r,showAlert:s}=t.payload,i=a.items.length,n=a.items.filter(l=>{const c=r[l.productId];return c?fo(l,c):!1}),o=n.length<i;return{...a,items:n,itemCount:la(n),removedItemsAlert:!!(s&&o)}}case"REMOVE_INVALID_PRODUCTS":{const{invalidProductIds:r}=t.payload,s=a.items.filter(i=>!r.includes(i.productId));return{...a,items:s,itemCount:la(s)}}default:return a}};function Ps(a,t,r,s){const i=Number(t.discountedBasePrice??t.basePrice??0),n=we((a.quantity||1)*i,r,s),o=a.modifierGroups?a.modifierGroups.map(c=>{const m=t.modifierGroups.find(p=>p.id===c.id);if(!m)return null;const u=c.modifiers.map(p=>{var x;const g=(x=m.modifiers)==null?void 0:x.find(y=>y.id===p.id);return g?g.title:""}).filter(Boolean).join(", ");return u?`${m.title}: ${u}`:null}).filter(Boolean):[],l=t.images&&t.images.length>0?t.images[0]:void 0;return{title:t.title??t.slug??"Untitled product",subtitle:o,image:l,price:n,unitPrice:we(i,r,s),quantity:a.quantity||1}}const Bs=h.createContext(void 0),yo=({children:a,initialOrganization:t,organizationId:r})=>{const{client:s}=P(),i=A.useQuery({queryKey:["organization",r],queryFn:async()=>{const n=await s.organization.getOrganization({params:{organizationId:r}});if(n.status!==200)throw new Error("Failed to fetch product data");return n.body},initialData:t??void 0,placeholderData:A.keepPreviousData,enabled:!!r});return e.jsx(Bs.Provider,{value:{organizationId:r,loading:i.isLoading,organization:i.data,error:i.error},children:a})},ve=()=>{const a=h.useContext(Bs);if(a===void 0)throw new Error("useOrganization must be used within a OrganizationProvider");return a},sr=h.createContext(void 0),ha=a=>a.map(t=>({...t,modifierGroups:t.modifierGroups??[],quantity:t.quantity||1})),bo=()=>typeof window>"u"?!1:new URLSearchParams(window.location.search).get("clearCart")==="true",jo=(a,t)=>t.length>0?"Some items were removed from your cart because they are no longer available.":a.some(r=>r.reason==="out_of_stock")?"We updated your cart because some items are now out of stock.":a.some(r=>r.reason==="insufficient_stock")?"We reduced some item quantities in your cart because stock changed.":"We updated your cart because availability changed.",wo=350,Fe={adjustments:[],invalidProductIds:[],normalizedItems:[],products:{},shipping:void 0,subtotal:0,total:0},Ts=({children:a,locale:t="en",organizationId:r})=>{const{organization:s}=ve(),i=s==null?void 0:s.configuration.defaultCurrency,{client:n}=P(),[o,l]=h.useState(null),[c,m]=h.useState(null),[{items:u,isInitialized:p,modifierModal:g,totalAmount:x,itemCount:y},j]=h.useReducer(Ms,oo),f=g!==null,b=(g==null?void 0:g.product)??null,w=(g==null?void 0:g.quantity)??1,k=g==null?void 0:g.onAdded,[C,F]=h.useState(Fe),[Q,O]=h.useState(!1),E=h.useRef(u),S=h.useRef(0),T=h.useRef(null),W=h.useRef(null),fe=h.useRef(void 0),Je=h.useRef([]);h.useEffect(()=>{E.current=u},[u]);const ce=h.useCallback(L=>{j({type:"REPLACE_ITEMS",payload:ha(L)})},[]),na=h.useCallback((L,V)=>{F(L);const K=ha(L.normalizedItems),je=JSON.stringify(K),ge=JSON.stringify(ha(E.current)),qe=L.adjustments.length>0||L.invalidProductIds.length>0;return je!==ge&&ce(K),qe&&(V==null?void 0:V.showAlert)!==!1&&alert(jo(L.adjustments,L.invalidProductIds)),L},[ce]),Ce=h.useCallback(()=>{T.current&&(clearTimeout(T.current),T.current=null)},[]),X=h.useCallback(L=>{const V=Je.current;Je.current=[],V.forEach(({resolve:K})=>K(L))},[]),Y=h.useCallback(L=>{const V=Je.current;Je.current=[],V.forEach(({reject:K})=>K(L))},[]),ie=h.useCallback(async(L,V)=>{Ce(),W.current=null,fe.current=void 0;const K=ha(L);if(K.length===0)return F(Fe),ce([]),X(Fe),Fe;const je=++S.current;O(!0);try{const ge=await n.cart.getCartData({params:{organizationId:r},query:{locale:t},body:{items:K,shippingMethodId:c==null?void 0:c.id}});if(ge.status!==200)throw new Error("Failed to sync cart");const qe=je===S.current?na(ge.body,{showAlert:V==null?void 0:V.showAdjustmentAlert}):ge.body;return X(qe),qe}catch(ge){throw Y(ge),ge}finally{je===S.current&&O(!1)}},[na,Ce,n.cart,t,r,ce,X,Y,c==null?void 0:c.id]),ga=h.useCallback((L,V)=>{const K=ha(L);return K.length===0?(Ce(),W.current=null,fe.current=void 0,F(Fe),ce([]),X(Fe),Promise.resolve(Fe)):(W.current=K,fe.current=V,new Promise((je,ge)=>{Je.current.push({resolve:je,reject:ge}),Ce(),T.current=setTimeout(()=>{T.current=null;const qe=W.current??[],oa=fe.current;W.current=null,fe.current=void 0,ie(qe,oa).catch(()=>{})},wo)}))},[Ce,ce,X,ie]);h.useEffect(()=>{(()=>{if(bo()){localStorage.removeItem(_a),F(Fe),j({type:"INITIALIZE_CART",payload:[]}),j({type:"SET_INITIALIZED",payload:!0});return}const L=localStorage.getItem(_a);if(L)try{const V=JSON.parse(L);j({type:"INITIALIZE_CART",payload:V})}catch(V){console.error("Failed to parse cart from localStorage:",V)}j({type:"SET_INITIALIZED",payload:!0})})()},[]),h.useEffect(()=>{p&&localStorage.setItem(_a,JSON.stringify(u))},[u,p]),h.useEffect(()=>()=>{Ce()},[Ce]),h.useEffect(()=>{if(p){if(E.current.length===0){F(Fe);return}ie(E.current,{showAdjustmentAlert:!1}).catch(L=>{console.error("Failed to hydrate cart data:",L)})}},[p,c==null?void 0:c.id,ie]),h.useEffect(()=>{j({type:"UPDATE_TOTALS",payload:{productsData:C.products}})},[u,C]);const ee=h.useCallback(L=>{const V=ha(L);ce(V),ie(V,{showAdjustmentAlert:!1}).catch(K=>{console.error("Failed to replace cart items:",K)})},[ce,ie]),Ie=h.useCallback(async(L,V)=>{const K={...L,modifierGroups:L.modifierGroups??[],quantity:L.quantity||1},je=Fs(E.current,K.productId,K.modifierGroups)?E.current.map(ge=>Xe(ge,{productId:K.productId,modifierGroups:K.modifierGroups})?{...ge,quantity:(ge.quantity||1)+(K.quantity||1)}:ge):[...E.current,K];return ce(je),ie(je,V)},[ce,ie]),Ke=h.useCallback(async(L,V,K,je)=>{const ge=E.current,qe=V<=0?ge.filter(oa=>!Xe(oa,{productId:L,modifierGroups:K})):ge.map(oa=>Xe(oa,{productId:L,modifierGroups:K})?{...oa,quantity:V}:oa);return ce(qe),ga(qe,je)},[ce,ga]),Tr=h.useCallback((L,V)=>{const K=E.current.filter(je=>!Xe(je,{productId:L,modifierGroups:V}));ce(K),ga(K,{showAdjustmentAlert:!1}).catch(je=>{console.error("Failed to remove cart item:",je)})},[ce,ga]),Qr=h.useCallback(()=>{Ce(),W.current=null,fe.current=void 0,X(Fe),localStorage.removeItem(_a),F(Fe),j({type:"CLEAR_CART"})},[Ce,X]),Or=h.useCallback(()=>{console.log("Checkout clicked, implement onCheckout handler")},[]),Lr=h.useCallback((L,V)=>{const K={product:L,quantity:(V==null?void 0:V.quantity)??1,onAdded:V==null?void 0:V.onAdded};j({type:"OPEN_MODIFIERS_MODAL",payload:K})},[]),Jr=h.useCallback(()=>{j({type:"CLOSE_MODIFIERS_MODAL"})},[]),Ve=C.products,Ut=C.shipping,Zt=h.useMemo(()=>Rs(u,L=>Ve[L]),[u,Ve]),Vr=Zt+(Ut??0),qr=!p||u.length>0&&(!Object.keys(Ve).length||Q&&u.some(L=>Ve[L.productId]===void 0)),Hr=h.useMemo(()=>Object.keys(Ve).length?u.map(L=>{const V=Ve[L.productId];return V?Ps(L,V,i??"USD",t):null}).filter(L=>L!==null):[],[i,u,t,Ve]),Jn=h.useMemo(()=>({locale:t,organizationId:r,items:u,total:Vr,shipping:Ut,subtotal:Zt,products:Ve,addItem:Ie,removeItem:Tr,updateItemQuantity:Ke,clearCart:Qr,itemCount:y,totalAmount:x,replaceItems:ee,onCheckoutClick:Or,openModifiersModal:Lr,closeModifiersModal:Jr,modifierModal:g,isModifiersModalOpen:f,selectedProduct:b,pendingModalQuantity:w,onModalAddToCart:k,isProductsLoading:qr,paymentMethod:o,setPaymentMethod:l,shippingMethod:c,setShippingMethod:m,formattedCartItems:Hr}),[t,r,u,Vr,Ut,Zt,Ve,Ie,Tr,Ke,Qr,y,x,ee,Or,Lr,Jr,g,f,b,w,k,qr,o,l,c,m,Hr]);return e.jsx(sr.Provider,{value:Jn,children:a})},kt=()=>{const a=h.useContext(sr),{client:t}=P();if(a===void 0)throw new Error("useCart must be used within a CartProvider");const r=h.useCallback(async(l,c)=>{if(c)return c;const m=a.products[l];if(m)return m;const u=await t.product.getProduct({params:{organizationId:a.organizationId,id:l},query:{locale:a.locale}});if(u.status!==200||!u.body)throw new Error(`Failed to fetch product ${l}`);return u.body},[t.product,a.locale,a.organizationId,a.products]),s=h.useCallback(async({productId:l,quantity:c=1,modifierGroups:m,product:u,onAdded:p})=>{var y;const g=(j=m??[])=>a.addItem({productId:l,quantity:c,modifierGroups:j}).then(()=>(p==null||p(),{openedModifiers:!1}));if(m!=null&&m.length)return g(m);const x=await r(l,u);return(y=x.modifierGroups)!=null&&y.length?(a.openModifiersModal(x,{onAdded:p,quantity:c}),{openedModifiers:!0}):g()},[a,r]),i=h.useCallback(({productId:l,quantity:c,modifierGroups:m})=>a.updateItemQuantity(l,c,m),[a]),n=h.useCallback(({productId:l,modifierGroups:c})=>{a.removeItem(l,c)},[a]),o=h.useCallback(l=>s({productId:l.id,product:l}),[s]);return{items:a.items,total:a.total,subtotal:a.subtotal,shipping:a.shipping,loading:a.isProductsLoading,formattedCartItems:a.formattedCartItems,add:s,update:i,remove:n,addProductToCart:o,clearCart:a.clearCart,itemCount:a.itemCount,rawCart:a.items,onCheckoutClick:a.onCheckoutClick,totalAmount:a.totalAmount,paymentMethod:a.paymentMethod,setPaymentMethod:a.setPaymentMethod,shippingMethod:a.shippingMethod,setShippingMethod:a.setShippingMethod,replaceItems:a.replaceItems}},Va=()=>{const a=h.useContext(sr);if(a===void 0)throw new Error("useCart must be used within a CartProvider");return a},Qs=(a="en")=>{const[t,r]=h.useState(a),s=h.useCallback((c,m,u="")=>{if(!c||c.length===0)return u;const p=c.find(x=>x.locale===t);if(p&&p[m])return p[m];const g=c[0];return g&&g[m]?g[m]:u},[t]),i=h.useCallback((c,m="Product")=>s(c==null?void 0:c.translations,"title",m),[s]),n=h.useCallback((c,m="")=>s(c==null?void 0:c.translations,"description",m),[s]),o=h.useCallback((c,m="Category")=>s(c==null?void 0:c.translations,"title",m),[s]),l=h.useCallback((c,m="Options")=>c.title,[s]);return{locale:t,setLocale:r,getTranslation:s,getProductName:i,getProductDescription:n,getCategoryName:o,getModifierGroupName:l}},vo=a=>a.map(t=>({groupId:t.id,modifierIds:[]})),Zr=(a,t,r)=>{const s=a.findIndex(i=>i.groupId===t);return s===-1?[...a,{groupId:t,modifierIds:r([])}]:a.map((i,n)=>n===s?{...i,modifierIds:r(i.modifierIds)}:i)},Os=(a=[])=>{const[t,r]=h.useState([]),[s,i]=h.useState(null);h.useEffect(()=>{r(vo(a)),i(null)},[a]);const n=h.useCallback((p,g)=>{r(x=>Zr(x,p,y=>y.includes(g)?y.filter(j=>j!==g):[...y,g])),i(null)},[]),o=h.useCallback((p,g)=>{r(x=>Zr(x,p,()=>[g])),i(null)},[]),l=h.useCallback((p,g)=>{const x=t.find(y=>y.groupId===p);return x?x.modifierIds.includes(g):!1},[t]),c=h.useCallback(()=>{const p=uo(a,t);return!p.valid&&p.message?i(p.message):i(null),p.valid},[a,t]),m=h.useMemo(()=>t.filter(p=>p.modifierIds.length>0).map(p=>({id:p.groupId,modifiers:p.modifierIds.map(g=>({id:g,quantity:1}))})),[t]),u=h.useCallback(()=>m,[m]);return{selections:t,toggleModifier:n,selectModifier:o,isModifierSelected:l,validateSelections:c,validationError:s,getCartModifierGroups:u}},ko={common:{cart:"Cart",checkout:"Checkout",products:"Products",home:"Home",search:"Search",loading:"Loading...",add:"Add",remove:"Remove",close:"Close",back:"Back",next:"Next",continue:"Continue",submit:"Submit",cancel:"Cancel",apply:"Apply",save:"Save",aboutUs:"About Us",ourStory:"Our Story",menu:"Menu",reservations:"Reservations",orderOnline:"Order Online",checkOurMenu:"Check Our Menu",privacyPolicy:"Privacy Policy",termsAndConditions:"Terms and Conditions",orderNow:"Order Now",makeReservation:"Make a Reservation"},product:{addToCart:"Add to cart",outOfStock:"Out of stock",stockAdjusted:"We adjusted the quantity to match current stock.",quantity:"Quantity",price:"Price",total:"Total",description:"Description",options:"Options",modifiers:"Modifiers"},checkout:{yourOrder:"Your Order",orderSummary:"Order Summary",delivery:"Delivery",address:"Address",payment:"Payment",confirmation:"Confirmation",deliveryDetails:"Delivery Details",paymentMethod:"Payment Method",placeOrder:"Place Order",subtotal:"Subtotal",total:"Total"},ourStory:{title:"Our Story",subtitle:"From the shores of South India to the heart of Poland – authentic flavors, unforgettable experiences",by:"By",paragraph1:"When Madras Bistro opened its doors in 2018, it marked a historic moment as Poland's first authentic South Indian restaurant. Our journey began with a simple yet profound vision: to introduce the rich, vibrant flavors of South India to the Polish culinary landscape.",paragraph2:"Our founders, inspired by their deep roots in Tamil Nadu, embarked on this venture after noticing that while North Indian cuisine had found its place in Poland, the diverse and distinctive flavors of South India remained undiscovered territory. They dreamed of creating a space where the aromatic spices, coconut-infused curries, and delicate dosas of their homeland could be experienced in their authentic form.",paragraph3:"The path wasn't always easy. Sourcing traditional ingredients, perfecting recipes that stayed true to their South Indian origins while appealing to Polish palates, and educating diners about a cuisine so different from what they knew – these were challenges we embraced with passion. Our chefs, trained in the time-honored techniques of South Indian cooking, worked tirelessly to ensure every dish that left our kitchen carried the essence of the regions they represented.",paragraph4:"Today, Madras Bistro stands as a cultural bridge between Poland and South India. We take pride in having introduced countless Polish diners to the joy of breaking a crispy dosa, savoring the complex flavors of a well-prepared sambar, and experiencing the unique combination of spices that makes South Indian cuisine so distinctive.",paragraph5:"Our story continues to unfold with each meal we serve, as we remain committed to our founding vision: bringing the authentic taste of South India to Poland, one delicious dish at a time.",paragraph6:"I warmly invite you to join us on this culinary adventure and discover the distinctive tastes of South India – a cuisine still new to many in Poland but certain to delight your palate with its rich traditions and bold flavors.",signature:"- Chef Victor",description:"Learn about Madras Bistro's journey in Krakow, bringing authentic South Indian cuisine with passion and tradition. Discover our story and culinary roots!"},menuSection:{title:"Discover our menu",description:"Our menu is a collection of the most popular dishes from south india."},orderOnline:{title:"Order Online",description:"Craving South Indian food? Order online from Madras Bistro in Krakow for delicious dosas, curries, and more. Fast, fresh, and authentic, delivered to you!"},hero:{title:"Discover South Indian Cuisine that's Beyond Delicious",subtitle:"Embark on a flavorful journey rich in tradition and vibrant spices."},introSection:{title:"Madras Bistro: Five Regions, One Extraordinary Table",paragraph1:"Step into a world where spices whisper ancient secrets and aromas tell tales of distant shores. At Madras Bistro, the diverse culinary heritage of South India comes alive on your plate—a gastronomic tapestry woven from the traditions of Tamil Nadu, Kerala, Andhra Pradesh, Karnataka, and Sri Lanka. Our kitchen celebrates this rich mosaic of regional cuisines, where coastal treasures meet inland specialties in a harmonious expression of flavor.",paragraph2:"In this tropical paradise, the climate nurtures abundant coconut groves and rice fields, giving birth to a culinary tradition that celebrates fresh ingredients and complex flavors. Unlike the heavy, cream-based dishes familiar to many, South Indian cuisine is a delicate dance of spices, featuring iconic dishes like crispy dosas, soft idlis, and tangy sambars that speak to centuries of culinary innovation. Each bite tells a story of coastal markets, family traditions, and a deep connection to the land."},reservationSection:{title:"Reserve Your Table",description:"Experience authentic South Indian cuisine in a warm, inviting atmosphere. Make a reservation for a memorable dining experience."},testimonialsSection:{title:"Google Reviews",description:"See what our customers are saying about us",testimonials:[{name:"Konrad Górski",company:"Appy.com",text:"A bistro worth visiting for fans of Indian flavors. They serve Indian cuisine and from the north of Sri Lanka. I ate delicious milk chicken with aromatic jeera rice. The bistro is small (3 tables) and modest, but you can listen to Indian music hits."},{name:"Sophia Mackney",company:"Nobi Bank",text:"My husband and I chanced upon this restaurant last Thursday whilst on a short break to Krakow from the UK. This small eatery with just 2 or 3 tables is run by the very friendly and obliging owner/chef and is conveniently located facing Ghetto Heroes Square. The Masala Uttapam, Masala Dosa, Kerala Chicken Curry, Chicken Roast and Masala Chai that we had were absolutely delicious. I highly recommend this restaurant to any lovers of South Indian food."},{name:"Sridevi Madbhavi",company:"Sync",text:"Absolutely mouthwatering food! The owner (also the chef) is extremely passionate about the customers experience, and you can feel his expertise in every bite. Highly recommend the ghee dosa (he made it extra crispy for us on request). It tastes like home, is SO authentic. The only downside is that I'll miss the food terribly when I leave Kraków!"},{name:"Bijeesh KB",company:"Appicu",text:"If you're looking for a place that serves real Malabar food, this is definitely the spot. Highly recommended for anyone craving a taste of home!"}]},orderTracking:{orderPlaced:"Order Placed",orderPlacedDesc:"Your order has been received and is waiting to be accepted",orderAccepted:"Order Accepted",orderAcceptedDesc:"Your order has been accepted and is being processed",readyForDispatch:"Ready for Dispatch",readyForDispatchDesc:"Your order is packed and ready to be shipped",orderDispatched:"Order Dispatched",orderDispatchedDesc:"Your order is on its way to you",orderDelivered:"Order Delivered",orderDeliveredDesc:"Your order has been delivered",orderCancelled:"Order Cancelled",orderCancelledDesc:"Your order has been cancelled",price:"Price",quantity:"Quantity",subtotal:"Subtotal",total:"Total",poweredBy:"Powered by",reference:"Reference",status:"Status"},reservation:{reservationDetails:"Reservation Details",name:"Name",phone:"Phone",guests:"Guests",date:"Date",reference:"Reference",status:"Status",notSpecified:"Not specified",invalidDate:"Invalid date",requestSent:"Reservation Request Sent",requestSentDesc:"Your reservation request has been received and is waiting to be confirmed by the restaurant",confirmed:"Reservation Confirmed",confirmedDesc:"Your reservation has been confirmed",cancelled:"Reservation Cancelled",cancelledDesc:"Your reservation has been cancelled",pendingStatus:"Pending",confirmedStatus:"Confirmed",cancelledStatus:"Cancelled",bookingEnabled:"Reservations are enabled",bookingEnabledDesc:"You can send a booking request below and the restaurant will review it shortly.",bookingDisabled:"Reservations are currently unavailable",bookingDisabledDesc:"This restaurant is not accepting reservations right now. Please contact them directly for assistance.",poweredBy:"Powered by"},homepage:{description:"Discover Madras Bistro, Krakow's first South Indian restaurant. Savor authentic flavors, vibrant spices, and traditional dishes in a cozy setting. Visit us today!"},menu:{description:"Explore the Madras Bistro menu featuring authentic South Indian dishes like dosas, curries, and biryanis. Fresh ingredients, bold flavors in Krakow!"},privacyPolicy:{description:"Read Madras Bistro's Privacy Policy to understand how we protect your data and ensure a secure experience while enjoying our South Indian cuisine in Krakow."},termsAndConditions:{description:"Review the Terms and Conditions for using Madras Bistro's website and services in Krakow. Learn about our policies for online orders and dining."}},No={common:{cart:"Koszyk",checkout:"Zamówienie",products:"Produkty",home:"Strona główna",search:"Szukaj",loading:"Ładowanie...",add:"Dodaj",remove:"Usuń",close:"Zamknij",back:"Wstecz",next:"Dalej",continue:"Kontynuuj",submit:"Wyślij",cancel:"Anuluj",apply:"Zastosuj",save:"Zapisz",aboutUs:"O nas",ourStory:"O Nas",menu:"Menu",reservations:"Rezerwacje",orderOnline:"Zamów online",checkOurMenu:"Sprawdź nasze menu",privacyPolicy:"Polityka prywatności",termsAndConditions:"Warunki korzystania",orderNow:"Zamów teraz",makeReservation:"Zarezerwuj stolik"},product:{addToCart:"Dodaj do koszyka",outOfStock:"Brak w magazynie",stockAdjusted:"Dostosowaliśmy ilość do aktualnie dostępnego stanu.",quantity:"Ilość",price:"Cena",total:"Razem",description:"Opis",options:"Opcje",modifiers:"Modyfikatory"},checkout:{yourOrder:"Twoje zamówienie",orderSummary:"Podsumowanie zamówienia",delivery:"Dostawa",address:"Adres",payment:"Płatność",confirmation:"Potwierdzenie",deliveryDetails:"Szczegóły dostawy",paymentMethod:"Metoda płatności",placeOrder:"Złóż zamówienie",subtotal:"Suma częściowa",total:"Razem"},ourStory:{title:"Nasza historia",subtitle:"Z wybrzeży Południowych Indii do serca Polski – autentyczne smaki, niezapomniane doświadczenia",by:"Autor",paragraph1:"Kiedy Madras Bistro otworzyło swoje drzwi w 2018 roku, był to historyczny moment jako pierwsza autentyczna restauracja południowoindyjska w Polsce. Nasza podróż rozpoczęła się od prostej, ale głębokiej wizji: wprowadzenia bogatych, żywych smaków Południowych Indii do polskiego krajobrazu kulinarnego.",paragraph2:"Nasi założyciele, zainspirowani swoimi głębokimi korzeniami w Tamil Nadu, rozpoczęli tę przygodę po zauważeniu, że podczas gdy kuchnia północnoindyjska znalazła swoje miejsce w Polsce, różnorodne i charakterystyczne smaki Południowych Indii pozostały nieodkrytym terytorium. Marzyli o stworzeniu miejsca, gdzie aromatyczne przyprawy, curry nasycone kokosem i delikatne dosa z ich ojczyzny mogłyby być doświadczane w autentycznej formie.",paragraph3:"Droga nie zawsze była łatwa. Pozyskiwanie tradycyjnych składników, doskonalenie przepisów, które pozostały wierne południowoindyjskim korzeniom, a jednocześnie trafiały w gusta polskich podniebień, oraz edukowanie gości o kuchni tak różnej od tego, co znali – to były wyzwania, które przyjęliśmy z pasją. Nasi szefowie kuchni, wyszkoleni w tradycyjnych technikach gotowania południowoindyjskiego, pracowali niestrudzenie, aby zapewnić, że każde danie opuszczające naszą kuchnię niosło w sobie esencję regionów, które reprezentowali.",paragraph4:"Dziś Madras Bistro stoi jako kulturowy most między Polską a Południowymi Indiami. Jesteśmy dumni z tego, że wprowadziliśmy niezliczonych polskich gości w radość przełamywania chrupiącej dosy, smakowania złożonych smaków dobrze przygotowanego sambaru i doświadczania unikalnej kombinacji przypraw, która sprawia, że kuchnia południowoindyjska jest tak wyjątkowa.",paragraph5:"Nasza historia nadal rozwija się z każdym posiłkiem, który serwujemy, ponieważ pozostajemy wierni naszej wizji założycielskiej: przywiezienia autentycznego smaku Południowych Indii do Polski, jedno pyszne danie na raz.",paragraph6:"Serdecznie zapraszam do przyłączenia się do tej kulinarnej przygody i odkrycia charakterystycznych smaków Południowych Indii – kuchni nadal nowej dla wielu w Polsce, ale z pewnością zachwycającej podniebienie bogatymi tradycjami i wyrazistymi smakami.",signature:"- Szef kuchni Victor",description:"Poznaj historię Madras Bistro w Krakowie, które wprowadza autentyczną kuchnię południowoindyjską z pasją i tradycją. Odkryj naszą historię i kulinarne korzenie!"},menuSection:{title:"Odkryj nasze menu",description:"Nasze menu to kolekcja najpopularniejszych dań z południowych Indii."},orderOnline:{title:"Zamów online",description:"Masz ochotę na południowoindyjskie jedzenie? Zamów online z Madras Bistro w Krakowie pyszne dosa, curry i więcej. Szybkie, świeże i autentyczne, dostarczone prosto do Ciebie!"},hero:{title:"Odkryj przepyszną południowo indyjską kuchnie",subtitle:"Wyrusz w pełną smaków podróż bogatą w tradycję i wyraziste przyprawy."},introSection:{title:"Madras Bistro: Pięć regionów, jeden wyjątkowy stół",paragraph1:"Wejdź do świata, gdzie przyprawy szepczą dawne sekrety, a aromaty opowiadają historie z dalekich brzegów. W Madras Bistro różnorodne dziedzictwo kulinarne Południowych Indii ożywa na Twoim talerzu — gastronomiczna tkanina utkana z tradycji Tamil Nadu, Kerali, Andhra Pradesh, Karnataki i Sri Lanki. Nasza kuchnia celebruje tę bogatą mozaikę regionalnych kuchni, gdzie nadmorskie skarby spotykają się z wewnątrznymi specjałami w harmonijnym wyrażeniu smaku.",paragraph2:"W tym tropikalnym raju klimat sprzyja obfitym palmom kokosowym i polom ryżowym, dając początek tradycji kulinarnej, która celebruje świeże składniki i złożone smaki. W przeciwieństwie do ciężkich, kremowych dań znanych wielu osobom, kuchnia południowoindyjska to delikatny taniec przypraw, z takimi ikonicznymi daniami jak chrupiące dosy, miękkie idli i pikantne sambary, które mówią o wiekach kulinarnych innowacji. Każdy kęs opowiada historię nadmorskich targów, rodzinnych tradycji i głębokiego związku z ziemią."},reservationSection:{title:"Zarezerwuj stolik",description:"Doświadcz autentycznej kuchni południowoindyjskiej w ciepłej, przyjaznej atmosferze. Dokonaj rezerwacji na niezapomniane doświadczenie kulinarne."},testimonialsSection:{title:"Opinie Google",description:"Zobacz, co mówią o nas nasi klienci",testimonials:[{name:"Konrad Górski",company:"Appy.com",text:"Bistro warte odwiedzenia dla fanów indyjskich smaków. Serwują kuchnię indyjską i z północy Sri Lanki. Zjadłem pysznego kurczaka w mleku z aromatycznym ryżem jeera. Bistro jest małe (3 stoliki) i skromne, ale można posłuchać indyjskich hitów muzycznych."},{name:"Sophia Mackney",company:"Nobi Bank",text:"Ja i mój mąż przypadkowo trafiliśmy do tej restauracji w zeszły czwartek podczas krótkiego pobytu w Krakowie z Wielkiej Brytanii. Ta mała jadłodajnia z zaledwie 2 lub 3 stolikami jest prowadzona przez bardzo przyjaznego i uczynnego właściciela/szefa kuchni i jest dogodnie zlokalizowana naprzeciwko Placu Bohaterów Getta. Masala Uttapam, Masala Dosa, Curry z Kurczakiem Kerala, Kurczak Pieczony i Masala Chai, które jedliśmy, były absolutnie pyszne. Gorąco polecam tę restaurację wszystkim miłośnikom południowo-indyjskiej kuchni."},{name:"Sridevi Madbhavi",company:"Sync",text:"Absolutnie pyszne jedzenie! Właściciel (również szef kuchni) jest niezwykle zaangażowany w doświadczenia klientów i można poczuć jego doświadczenie w każdym kęsie. Gorąco polecam ghee dosa (zrobił je dla nas ekstra chrupiące na prośbę). Smakuje jak w domu, jest BARDZO autentyczne. Jedynym minusem jest to, że będę tęsknić za tym jedzeniem, gdy opuszczę Kraków!"},{name:"Bijeesh KB",company:"Appicu",text:"Jeśli szukasz miejsca, które serwuje prawdziwe jedzenie Malabar, to zdecydowanie jest to odpowiednie miejsce. Gorąco polecane dla każdego, kto tęskni za smakiem domu!"}]},orderTracking:{orderPlaced:"Zamówienie złożone",orderPlacedDesc:"Twoje zamówienie zostało odebrane i czeka na akceptację",orderAccepted:"Zamówienie zaakceptowane",orderAcceptedDesc:"Twoje zamówienie zostało zaakceptowane i jest przetwarzane",readyForDispatch:"Gotowe do wysyłki",readyForDispatchDesc:"Twoje zamówienie jest spakowane i gotowe do wysyłki",orderDispatched:"Zamówienie wysłane",orderDispatchedDesc:"Twoje zamówienie jest w drodze do Ciebie",orderDelivered:"Zamówienie dostarczone",orderDeliveredDesc:"Twoje zamówienie zostało dostarczone",orderCancelled:"Zamówienie anulowane",orderCancelledDesc:"Twoje zamówienie zostało anulowane",price:"Cena",quantity:"Ilość",subtotal:"Suma częściowa",total:"Razem",poweredBy:"Wspierane przez",reference:"Numer referencyjny",status:"Status"},reservation:{reservationDetails:"Szczegóły rezerwacji",name:"Imię i nazwisko",phone:"Telefon",guests:"Liczba gości",date:"Data",reference:"Numer referencyjny",status:"Status",notSpecified:"Nie określono",invalidDate:"Nieprawidłowa data",requestSent:"Prośba o rezerwację wysłana",requestSentDesc:"Twoja prośba o rezerwację została odebrana i czeka na potwierdzenie przez restaurację",confirmed:"Rezerwacja potwierdzona",confirmedDesc:"Twoja rezerwacja została potwierdzona",cancelled:"Rezerwacja anulowana",cancelledDesc:"Twoja rezerwacja została anulowana",pendingStatus:"Oczekujące",confirmedStatus:"Potwierdzone",cancelledStatus:"Anulowane",bookingEnabled:"Rezerwacje są włączone",bookingEnabledDesc:"Możesz wysłać prośbę o rezerwację poniżej, a restauracja wkrótce ją sprawdzi.",bookingDisabled:"Rezerwacje są obecnie niedostępne",bookingDisabledDesc:"Ta restauracja nie przyjmuje teraz rezerwacji. Skontaktuj się z nią bezpośrednio, aby uzyskać pomoc.",poweredBy:"Wspierane przez"},homepage:{description:"Odkryj Madras Bistro, pierwszą restaurację południowoindyjską w Krakowie. Skosztuj autentycznych smaków, żywych przypraw i tradycyjnych dań w przytulnym otoczeniu. Odwiedź nas już dziś!"},menu:{description:"Zapoznaj się z menu Madras Bistro oferującym autentyczne południowoindyjskie dania jak dosa, curry i biryani. Świeże składniki, wyraziste smaki w Krakowie!"},privacyPolicy:{description:"Przeczytaj Politykę Prywatności Madras Bistro, aby zrozumieć, jak chronimy Twoje dane i zapewniamy bezpieczne doświadczenie podczas delektowania się naszą południowoindyjską kuchnią w Krakowie."},termsAndConditions:{description:"Zapoznaj się z Warunkami korzystania ze strony internetowej i usług Madras Bistro w Krakowie. Dowiedz się o naszych zasadach dotyczących zamówień online i dań w restauracji."}},_r={en:ko,pl:No},Ls=h.createContext(void 0),Ao=({children:a,locale:t})=>{const r=h.useCallback(i=>{const n=i.split(".");let o=_r[t];for(const l of n)if(o&&typeof o=="object"&&l in o)o=o[l];else return i;return typeof o=="string"?o:i},[t]),s={locale:t,translations:_r[t],t:r};return e.jsx(Ls.Provider,{value:s,children:a})},qa=()=>{const a=h.useContext(Ls);if(a===void 0)throw new Error("useTranslation must be used within a TranslationProvider");return a},Js=h.createContext(null),Co=a=>{if(a==null||a==="")return null;const t=typeof a=="string"?Number.parseInt(a,10):a;return Number.isFinite(t)?t:null},Vs=({children:a,locale:t="en"})=>{const{modifierModal:r,closeModifiersModal:s,addItem:i,items:n}=Va(),{t:o}=qa(),l=(r==null?void 0:r.product)??null,c=h.useMemo(()=>(l==null?void 0:l.modifierGroups)??[],[l]),[m,u]=h.useState(1),[p,g]=h.useState(!1),[x,y]=h.useState(null),{toggleModifier:j,selectModifier:f,isModifierSelected:b,validateSelections:w,validationError:k,getCartModifierGroups:C}=Os(c),{getProductName:F,getModifierGroupName:Q}=Qs(t),O=h.useMemo(()=>l?n.filter(ee=>ee.productId===l.id).reduce((ee,Ie)=>ee+(Ie.quantity||1),0):0,[n,l]),E=Co(l==null?void 0:l.availableQuantity),S=E===null?null:Math.max(E-O,0),T=S!==null&&m>=S,W=S===0;h.useEffect(()=>{if(!r)return;const ee=r.quantity??1;g(!1),y(null),u(S===null?ee:Math.min(ee,Math.max(S,1)))},[S,r]);const fe=h.useCallback(()=>{y(null),u(ee=>S===null?ee+1:Math.min(ee+1,S))},[S]),Je=h.useCallback(()=>{y(null),u(ee=>ee>1?ee-1:1)},[]),ce=h.useCallback(ee=>{if(!ee.trim()){u(1),y(null);return}const Ie=Number.parseInt(ee,10);if(!Number.isFinite(Ie))return;const Ke=Math.max(Ie,1);if(S!==null&&Ke>S){u(Math.max(S,1)),y(o(S===0?"product.outOfStock":"product.stockAdjusted"));return}u(Ke),y(null)},[S,o]),na=h.useCallback(async()=>{var Ie;if(p||!l||!w()||W){W&&y(o("product.outOfStock"));return}const ee=S===null?m:Math.min(m,S);g(!0);try{const Ke=await i({productId:l.id,quantity:ee,modifierGroups:C()},{showAdjustmentAlert:!1});if(Ke.invalidProductIds.includes(l.id)){y(o("product.outOfStock"));return}if(Ke.adjustments.length>0){y(o("product.stockAdjusted"));return}y(null),u(1),s(),(Ie=r==null?void 0:r.onAdded)==null||Ie.call(r)}finally{g(!1)}},[i,s,C,p,r,l,m,w,W,S,o]),Ce=c.length>0,X=h.useMemo(()=>l?"title"in l?l.title??"":F(l,""):"",[F,l]),Y=h.useCallback(ee=>ee.selectMax>1||ee.selectMax===0,[]),ie=h.useCallback((ee,Ie)=>ee.price>0?` (+${we(ee.price,Ie,t)})`:"",[t]),ga={isOpen:r!==null,onClose:s,product:l,productName:X,hasModifiers:Ce,quantity:m,handleIncrement:fe,handleDecrement:Je,handleQuantityInput:ce,isIncrementDisabled:T,isSubmitting:p,isOutOfStock:W,maxQuantity:S,stockMessage:x,handleAddToCart:na,validationError:k,modifierGroups:c,isModifierSelected:b,isMultiSelect:Y,toggleModifier:j,selectModifier:f,getModifierGroupName:Q,formatModifierPrice:ie,locale:t};return e.jsx(Js.Provider,{value:ga,children:a})},Ha=()=>{const a=h.useContext(Js);if(!a)throw new Error("useModifiers must be used within a ModifiersProvider");return a},So=a=>{if(a==null||a==="")return null;const t=typeof a=="string"?Number.parseInt(a,10):a;return Number.isFinite(t)?t:null},qs=({className:a,emptyCartComponent:t,renderItem:r,loadingComponent:s})=>{const{organization:i}=ve(),{locale:n,items:o,removeItem:l,updateItemQuantity:c,products:m,isProductsLoading:u}=Va();return!i||u?s:o.length===0?t:e.jsx("div",{className:a||"flex-1 overflow-y-auto",children:m&&o.map(p=>{const g=m[p.productId];if(!g)return null;const x=o.filter(k=>k.productId===p.productId).reduce((k,C)=>k+(C.quantity||1),0)-(p.quantity||1),y=So(g.availableQuantity),j=y===null?null:Math.max(y-x,0),f=()=>l(p.productId,p.modifierGroups),b=k=>{c(p.productId,k,p.modifierGroups).catch(C=>{console.error("Failed to update cart item quantity:",C)})},w=Ps(p,g,i.configuration.defaultCurrency,n);return e.jsx(h.Fragment,{children:r({...w,maxQuantity:j,remove:f,updateQuantity:b})},`${p.productId}-${JSON.stringify(p.modifierGroups)}`)})})},Hs=({title:a,subtitle:t,image:r,price:s,quantity:i,maxQuantity:n,remove:o,updateQuantity:l})=>{const[c,m]=h.useState(String(i)),u=n!=null&&i>=n;h.useEffect(()=>{m(String(i))},[i]);const p=h.useCallback(()=>{const g=Number.parseInt(c,10);if(Number.isNaN(g)){m(String(i));return}if(g<=0){o();return}if(n!=null){l(Math.min(g,n));return}l(g)},[c,n,i,o,l]);return e.jsx("div",{className:v("p-1 mb-3 transition-shadow"),children:e.jsxs("div",{className:"grid grid-cols-5",children:[e.jsx("div",{className:"shrink-0 w-full h-full mr-3 overflow-hidden col-span-2",children:r?e.jsx(ze,{width:100,height:100,src:r.url,alt:a,className:"w-full h-32 object-cover border rounded-md overflow-hidden"}):e.jsx("div",{className:"bg-slate-100 h-full rounded-md flex items-center justify-center",children:e.jsx("span",{className:"text-slate-400",children:"No image"})})}),e.jsxs("div",{className:"flex-1 min-w-0 pl-4 col-span-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-black text-slate-800 font-red-hat-display leading-tight",children:a}),t&&e.jsx("p",{className:"text-xs font-medium text-gray-600 dark:text-gray-400",children:t}),e.jsx("p",{className:"text-xs font-medium text-gray-600 dark:text-gray-400 mt-1",children:s})]}),e.jsx("div",{className:"mt-3 flex items-center justify-between",children:e.jsxs("div",{className:"inline-flex items-center overflow-hidden rounded-lg bg-white",children:[e.jsx("button",{type:"button",className:"storefront-primary-action flex h-8 w-8 cursor-pointer items-center justify-center text-sm font-semibold transition-colors",onClick:()=>i<=1?o():l(Math.max(1,i-1)),"aria-label":"Decrease quantity",children:"-"}),e.jsx("input",{type:"number",min:1,step:1,inputMode:"numeric",value:c,onChange:g=>{const x=g.target.value;(x===""||/^[0-9]+$/.test(x))&&m(x)},onBlur:p,onKeyDown:g=>{g.key==="Enter"&&g.currentTarget.blur()},className:"h-8 w-11 border-x border-slate-200 bg-white px-0 text-center text-sm font-semibold text-slate-700 outline-none transition-colors focus:bg-slate-50 [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none","aria-label":"Quantity"}),e.jsx("button",{type:"button",className:"storefront-primary-action flex h-8 w-8 cursor-pointer items-center justify-center text-sm font-semibold transition-colors",onClick:()=>l(i+1),"aria-label":"Increase quantity",disabled:u,children:"+"})]})})]})]})})},zo=e.jsx("div",{className:"flex items-center justify-center h-32",children:e.jsxs("svg",{"aria-hidden":"true",className:"storefront-primary-fill text-gray-200 animate-spin dark:text-gray-600 h-8 w-8",viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",fill:"currentColor"}),e.jsx("path",{d:"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",fill:"currentFill"})]})}),Io=e.jsxs("div",{className:"text-center py-4 text-sm text-slate-500 flex flex-col items-center",children:[e.jsx("div",{className:"bg-slate-100 p-2 rounded-full mb-2",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M3 3h2l.4 2M7 13h10l4-8H5.4M7 13L5.4 5M7 13l-2.293 2.293c-.63.63-.184 1.707.707 1.707H17m0 0a2 2 0 100 4 2 2 0 000-4zm-8 2a2 2 0 11-4 0 2 2 0 014 0z"})})}),e.jsx("p",{className:"font-medium",children:"Your cart is empty"})]}),Eo=a=>e.jsx(Hs,{...a}),Us=({checkoutHref:a="/checkout/customer-details",checkoutLabel:t="Checkout",title:r="Shopping bag",className:s="bg-white shadow-xl rounded-lg overflow-hidden h-full flex flex-col",bodyClassName:i="max-h-80 md:max-h-[550px] overflow-y-auto p-4 md:p-3 space-y-3 h-full",headerClassName:n="storefront-primary-bg py-3 px-3 border-b border-slate-100 flex justify-between items-center",onClose:o,showCloseButton:l=!!o,emptyCartComponent:c=Io,loadingComponent:m=zo,renderFooter:u,renderHeader:p,renderItem:g=Eo})=>{const{itemCount:x,total:y,locale:j}=Va(),{organization:f}=ve(),b=(f==null?void 0:f.configuration.defaultCurrency)??"USD",w=we(y,b,j),k={checkoutHref:a,checkoutLabel:t,close:o??(()=>{}),formattedTotal:w,itemCount:x,total:y};return e.jsxs("div",{className:s,children:[p?p({onClose:o,showCloseButton:l,title:r}):e.jsxs("div",{className:n,children:[e.jsx("h3",{className:"text-lg font-black font-red-hat-display text-white",children:r}),l&&o&&e.jsx("button",{onClick:o,className:"storefront-primary-bg-hover text-white p-1 rounded-full transition-colors","aria-label":"Close cart",type:"button",children:e.jsx(M.RiCloseLine,{className:"h-5 w-5"})})]}),e.jsx("div",{className:i,children:e.jsx(qs,{renderItem:C=>g(C),loadingComponent:m,emptyCartComponent:c})}),x>0&&(u?u(k):e.jsxs("div",{className:"flex items-center px-4 py-4 border-t border-t-slate-200 mt-auto w-full",children:[e.jsx("div",{className:"w-[125px] font-medium h-[45px] rounded-lg flex items-center text-sm justify-center border border-slate-200 whitespace-nowrap mr-2",children:w}),e.jsx(B,{href:a,className:"storefront-primary-action btn text-sm rounded-lg w-full",onClick:o,children:t})]}))]})},Do=({isOpen:a,onClose:t,checkoutHref:r="/checkout/customer-details",checkoutLabel:s="Checkout",title:i="Shopping bag",className:n,contentClassName:o,emptyCartComponent:l,loadingComponent:c,renderFooter:m,renderItem:u})=>{const p=h.useRef(null),[g,x]=h.useState(null),[y,j]=h.useState(null),f=50,b=C=>{j(null),x(C.targetTouches[0].clientY)},w=C=>{j(C.targetTouches[0].clientY)},k=()=>{!g||!y||(y-g>f&&t(),x(null),j(null))};return e.jsxs(e.Fragment,{children:[a&&e.jsx("div",{className:"fixed inset-0 bg-black opacity-40 z-40 transition-opacity",onClick:t,"aria-hidden":"true"}),e.jsx(ya.Transition,{show:a,as:h.Fragment,enter:"transition ease-in-out duration-300 transform",enterFrom:"translate-y-full",enterTo:"translate-y-0",leave:"transition ease-in-out duration-300 transform",leaveFrom:"translate-y-0",leaveTo:"translate-y-full",children:e.jsx("div",{className:v("fixed bottom-0 right-0 h-[85vh] w-full sm:w-96 z-50 shadow-xl flex flex-col",n),children:e.jsx("div",{className:"h-full",ref:p,onTouchStart:b,onTouchMove:w,onTouchEnd:k,children:e.jsx(Us,{checkoutHref:r,checkoutLabel:s,title:i,className:v("bg-white shadow-xl rounded-lg overflow-hidden h-full flex flex-col",o),onClose:t,emptyCartComponent:l,loadingComponent:c,renderFooter:m,renderItem:u})})})})]})},Ro=[{value:"USD",label:"United States Dollar"},{value:"EUR",label:"Euro"},{value:"GBP",label:"British Pound Sterling"},{value:"JPY",label:"Japanese Yen"},{value:"AUD",label:"Australian Dollar"},{value:"CAD",label:"Canadian Dollar"},{value:"CHF",label:"Swiss Franc"},{value:"CNY",label:"Chinese Yuan"},{value:"SEK",label:"Swedish Krona"},{value:"NZD",label:"New Zealand Dollar"},{value:"MXN",label:"Mexican Peso"},{value:"SGD",label:"Singapore Dollar"},{value:"HKD",label:"Hong Kong Dollar"},{value:"NOK",label:"Norwegian Krone"},{value:"KRW",label:"South Korean Won"},{value:"TRY",label:"Turkish Lira"},{value:"RUB",label:"Russian Ruble"},{value:"INR",label:"Indian Rupee"},{value:"BRL",label:"Brazilian Real"},{value:"ZAR",label:"South African Rand"},{value:"DKK",label:"Danish Krone"},{value:"PLN",label:"Polish Złoty"},{value:"THB",label:"Thai Baht"},{value:"IDR",label:"Indonesian Rupiah"},{value:"HUF",label:"Hungarian Forint"},{value:"CZK",label:"Czech Koruna"},{value:"ILS",label:"Israeli New Shekel"},{value:"PHP",label:"Philippine Peso"},{value:"AED",label:"United Arab Emirates Dirham"},{value:"COP",label:"Colombian Peso"},{value:"SAR",label:"Saudi Riyal"},{value:"MYR",label:"Malaysian Ringgit"},{value:"RON",label:"Romanian Leu"}],Nt=d.z.enum(["USD","EUR","GBP","JPY","AUD","CAD","CHF","CNY","SEK","NZD","MXN","SGD","HKD","NOK","KRW","TRY","RUB","INR","BRL","ZAR","DKK","PLN","THB","IDR","HUF","CZK","ILS","PHP","AED","COP","SAR","MYR","RON"]).openapi({description:"The currency code for the transaction."}),Gt=d.z.enum(["delivery","pickup"]),Fo=d.z.enum(["card","blik","paypal","bank_transfer","cash_on_delivery"]).openapi({description:"The payment method used for the order",example:"card"});d.z.object({from:d.z.coerce.date().openapi({description:"Start of the reporting range",example:"2026-01-01T00:00:00.000Z"}),to:d.z.coerce.date().openapi({description:"End of the reporting range",example:"2026-01-30T23:59:59.999Z"})});const Mo=d.z.object({from:d.z.date(),to:d.z.date()}).openapi("AnalyticsRange"),Po=d.z.object({currency:Nt,totalSales:d.z.number().min(0),paidOrders:d.z.number().int().min(0),averageOrderValue:d.z.number().min(0),reservations:d.z.number().int().min(0),guests:d.z.number().int().min(0)}).openapi("AnalyticsSummary"),Bo=d.z.object({date:d.z.date(),label:d.z.string(),totalSales:d.z.number().min(0),paidOrders:d.z.number().int().min(0)}).openapi("SalesByDayPoint"),To=d.z.object({date:d.z.date(),label:d.z.string(),reservations:d.z.number().int().min(0),guests:d.z.number().int().min(0)}).openapi("ReservationsByDayPoint"),Qo=d.z.object({method:Fo,count:d.z.number().int().min(0),totalSales:d.z.number().min(0)}).openapi("PaymentMethodBreakdownItem"),Oo=d.z.object({method:Gt,count:d.z.number().int().min(0),totalSales:d.z.number().min(0)}).openapi("FulfilmentBreakdownItem");d.z.object({range:Mo,summary:Po,salesByDay:d.z.array(Bo),reservationsByDay:d.z.array(To),paymentMethods:d.z.array(Qo),fulfilmentMethods:d.z.array(Oo)}).openapi("AnalyticsOverview"),d.z.object({id:d.z.string().openapi({example:"clf9876543210abcdef",description:"ID of the member"}),organizationId:d.z.string().openapi({example:"cju0z9k4z0000l1qg5z1z1z1z",description:"ID of the organization"}),userId:d.z.string().openapi({example:"usr_123",description:"ID of the user"}),role:d.z.string().openapi({example:"owner",description:"Role of the member in the organization"}),createdAt:d.z.date(),user:d.z.object({id:d.z.string(),firstname:d.z.string(),lastname:d.z.string(),email:d.z.string(),image:d.z.string().nullable().optional()}).openapi({description:"User details"})}).openapi("Member"),d.z.object({id:d.z.string().openapi({example:"inv_123",description:"ID of the invitation"}),organizationId:d.z.string().openapi({example:"cju0z9k4z0000l1qg5z1z1z1z",description:"ID of the organization"}),email:d.z.string().email().openapi({example:"user@example.com",description:"Email of the invited user"}),role:d.z.string().nullable().optional().openapi({example:"member",description:"Role assigned to the invitation"}),status:d.z.string().openapi({example:"pending",description:"Status of the invitation"}),expiresAt:d.z.date().openapi({description:"Expiration date of the invitation"}),inviterId:d.z.string().openapi({description:"ID of the user who created the invitation"}),createdAt:d.z.date().optional()}).openapi("Invitation");const Lo=d.z.object({email:d.z.string().email("A valid email is required").openapi({example:"user@example.com",description:"Email of the user to invite"}),role:d.z.string().min(1,"Role is required").openapi({example:"member",description:"Role to assign to the invited user"})}).openapi("CreateInvitation"),Jo=d.z.object({role:d.z.string().min(1,"Role is required").openapi({example:"admin",description:"New role for the member"})}).openapi("UpdateMemberRole");d.z.object({id:d.z.string().openapi({example:"inv_123",description:"ID of the invitation"}),organizationId:d.z.string().openapi({example:"cju0z9k4z0000l1qg5z1z1z1z",description:"ID of the organization"}),role:d.z.string().nullable().optional().openapi({example:"member",description:"Role assigned to the invitation"}),expiresAt:d.z.date().openapi({description:"Expiration date of the invitation"}),organization:d.z.object({id:d.z.string(),name:d.z.string()}).openapi({description:"Organization details"})}).openapi("UserInvitation");const wa=(...a)=>(t,r)=>{const{translations:s,defaultLocale:i}=t;if(s===void 0&&i===void 0)return;if(!Array.isArray(s)||s.length===0){r.addIssue({code:d.z.ZodIssueCode.custom,message:"Missing translation for the default locale",path:["translations"]});return}if(typeof i!="string"||!i.trim()){r.addIssue({code:d.z.ZodIssueCode.custom,message:"Default locale is required when translations are provided",path:["defaultLocale"]});return}const n=s.findIndex(o=>o.locale===i);if(n===-1){r.addIssue({code:d.z.ZodIssueCode.custom,message:"Missing translation for the default locale",path:["translations"]});return}a.forEach(o=>{const l=s[n][o];(typeof l!="string"||!l.trim())&&r.addIssue({code:d.z.ZodIssueCode.custom,message:"This field is required",path:["translations",n,o]})})},At=new Map([["af","Afrikaans"],["sq","Albanian"],["ar_dz","Arabic (Algeria)"],["ar_bh","Arabic (Bahrain)"],["ar_eg","Arabic (Egypt)"],["ar_iq","Arabic (Iraq)"],["ar_jo","Arabic (Jordan)"],["ar_kw","Arabic (Kuwait)"],["ar_lb","Arabic (Lebanon)"],["ar_ly","Arabic (Libya)"],["ar_ma","Arabic (Morocco)"],["ar_om","Arabic (Oman)"],["ar_qa","Arabic (Qatar)"],["ar_sa","Arabic (Saudi Arabia)"],["ar_sy","Arabic (Syria)"],["ar_tn","Arabic (Tunisia)"],["ar_ae","Arabic (U.A.E.)"],["ar_ye","Arabic (Yemen)"],["eu","Basque"],["be","Belarusian"],["bg","Bulgarian"],["ca","Catalan"],["zh_hk","Chinese (Hong Kong)"],["zh_cn","Chinese (PRC)"],["zh_sg","Chinese (Singapore)"],["zh_tw","Chinese (Taiwan)"],["hr","Croatian"],["cs","Czech"],["da","Danish"],["nl_be","Dutch (Belgium)"],["nl","Dutch (Standard)"],["en","English"],["en_au","English (Australia)"],["en_bz","English (Belize)"],["en_ca","English (Canada)"],["en_ie","English (Ireland)"],["en_jm","English (Jamaica)"],["en_nz","English (New Zealand)"],["en_za","English (South Africa)"],["en_tt","English (Trinidad)"],["en_gb","English (United Kingdom)"],["en_us","English (United States)"],["et","Estonian"],["fo","Faeroese"],["fa","Farsi"],["fi","Finnish"],["fr_be","French (Belgium)"],["fr_ca","French (Canada)"],["fr_lu","French (Luxembourg)"],["fr","French (Standard)"],["fr_ch","French (Switzerland)"],["gd","Gaelic (Scotland)"],["de_at","German (Austria)"],["de_li","German (Liechtenstein)"],["de_lu","German (Luxembourg)"],["de","German (Standard)"],["de_ch","German (Switzerland)"],["el","Greek"],["he","Hebrew"],["hi","Hindi"],["hu","Hungarian"],["is","Icelandic"],["id","Indonesian"],["ga","Irish"],["it","Italian (Standard)"],["it_ch","Italian (Switzerland)"],["ja","Japanese"],["ko","Korean"],["ku","Kurdish"],["lv","Latvian"],["lt","Lithuanian"],["mk","Macedonian (FYROM)"],["ml","Malayalam"],["ms","Malaysian"],["mt","Maltese"],["no","Norwegian"],["nb","Norwegian (Bokmål)"],["nn","Norwegian (Nynorsk)"],["pl","Polish"],["pt_br","Portuguese (Brazil)"],["pt","Portuguese (Portugal)"],["pa","Punjabi"],["rm","Rhaeto-Romanic"],["ro","Romanian"],["ro_md","Romanian (Republic of Moldova)"],["ru","Russian"],["ru_md","Russian (Republic of Moldova)"],["sr","Serbian"],["sk","Slovak"],["sl","Slovenian"],["sb","Sorbian"],["es_ar","Spanish (Argentina)"],["es_bo","Spanish (Bolivia)"],["es_cl","Spanish (Chile)"],["es_co","Spanish (Colombia)"],["es_cr","Spanish (Costa Rica)"],["es_do","Spanish (Dominican Republic)"],["es_ec","Spanish (Ecuador)"],["es_sv","Spanish (El Salvador)"],["es_gt","Spanish (Guatemala)"],["es_hn","Spanish (Honduras)"],["es_mx","Spanish (Mexico)"],["es","Spanish (Spain)"],["sv","Swedish"],["sv_fi","Swedish (Finland)"],["th","Thai"],["tr","Turkish"],["uk","Ukrainian"],["ur","Urdu"],["vi","Vietnamese"],["cy","Welsh"],["ji","Yiddish"],["zu","Zulu"]]),$r=Array.from(At.entries()).map(([a,t])=>({value:a,label:t})),We=d.z.enum(["af","sq","ar_dz","ar_bh","ar_eg","ar_iq","ar_jo","ar_kw","ar_lb","ar_ly","ar_ma","ar_om","ar_qa","ar_sa","ar_sy","ar_tn","ar_ae","ar_ye","eu","be","bg","ca","zh_hk","zh_cn","zh_sg","zh_tw","hr","cs","da","nl_be","nl","en","en_au","en_bz","en_ca","en_ie","en_jm","en_nz","en_za","en_tt","en_gb","en_us","et","fo","fa","fi","fr_be","fr_ca","fr_lu","fr","fr_ch","gd","de_at","de_li","de_lu","de","de_ch","el","he","hi","hu","is","id","ga","it","it_ch","ja","ko","ku","lv","lt","mk","ml","ms","mt","no","nb","nn","pl","pt_br","pt","pa","rm","ro","ro_md","ru","ru_md","sr","sk","sl","sb","es_ar","es_bo","es_cl","es_co","es_cr","es_do","es_ec","es_sv","es_gt","es_hn","es_mx","es","sv","sv_fi","th","tr","uk","ur","vi","cy","ji","zu"]).openapi({description:"Enum for locale values",example:"en"}),Zs=d.z.union([d.z.string(),d.z.number(),d.z.null()]).optional().transform(a=>{if(a==null||a==="")return null;if(typeof a=="number")return a;const t=Number(a);return isNaN(t)?a:t}).pipe(d.z.number().nonnegative({message:"This field must be a positive number"}).nullable().refine(a=>a===null||a>=0,{message:"Price must be positive"})),ct=d.z.coerce.number().min(.1,"This field must be positive").refine(a=>/^\d+(\.\d{1,2})?$/.test(a.toString()),{message:"This field can have a maximum of two decimal points"}),Vo=d.z.union([d.z.string(),d.z.number(),d.z.null()]).optional().transform(a=>{if(a==null||a==="")return null;if(typeof a=="number")return a;const t=Number(a);return Number.isNaN(t)?a:t}).pipe(d.z.number().int({message:"This field must be a whole number"}).nonnegative({message:"This field must be zero or greater"}).nullable()),qo=d.z.object({type:d.z.literal("blob.generate-client-token"),payload:d.z.object({pathname:d.z.string(),callbackUrl:d.z.string(),multipart:d.z.boolean(),clientPayload:d.z.string().nullable()})}),Ho=d.z.object({type:d.z.literal("blob.upload-completed"),payload:d.z.object({blob:d.z.any(),tokenPayload:d.z.string().nullable().optional()})});d.z.discriminatedUnion("type",[qo,Ho]),d.z.discriminatedUnion("type",[d.z.object({type:d.z.literal("blob.generate-client-token"),clientToken:d.z.string()}),d.z.object({type:d.z.literal("blob.upload-completed"),response:d.z.literal("ok")})]),d.z.object({mimeType:d.z.string().min(1,"MIME type is required").openapi({example:"image/png",description:"MIME type of the file"}),size:d.z.number().min(1,"Size is required").openapi({example:1024,description:"Size of the file in bytes"}),filename:d.z.string().min(1,"Filename is required").openapi({example:"example.png",description:"Name of the file"}),organizationId:d.z.string().optional().openapi({example:"clm1234567890abcdef",description:"ID of the organization"})});const ta=d.z.object({id:d.z.string().min(1,"ID is required").openapi({example:"clf9876543210abcdef",description:"ID of the file"}),url:d.z.string().min(1,"Path is required").openapi({example:"/path/to/file",description:"Path of the file"}),mimeType:d.z.string().min(1,"MIME type is required").openapi({example:"image/png",description:"MIME type of the file"}),size:d.z.number().min(1,"Size is required").openapi({example:1024,description:"Size of the file in bytes"}),filename:d.z.string().min(1,"Filename is required").openapi({example:"example.png",description:"Name of the file"})}).openapi("UploadedFile"),Ct=d.z.object({id:d.z.string().openapi({example:"clf9876543210abcdef",description:"ID of the product category"}),slug:d.z.string().openapi({example:"electronics",description:"Slug of the product category"}),image:ta.nullable().optional().openapi({description:"Image of the product category"}),createdAt:d.z.date(),publishedAt:d.z.date().nullable().optional().openapi({description:"Timestamp when the product category was published"}),translations:d.z.array(d.z.object({locale:d.z.string().min(1,"Locale is required").openapi({example:"en-US",description:"Locale code for the translation"}),title:d.z.string().default("").openapi({example:"Electronics",description:"Name of the product category in the specified locale"}),description:d.z.string().max(6e3,"Maximum character limit is 6000").nullable().default("").optional().openapi({example:"A category for electronic devices.",description:"Description of the product category in the specified locale"})})).openapi({description:"List of translations for the product category"})}).openapi("ProductCategory");Ct.omit({translations:!0}).extend({title:d.z.string().default(""),description:d.z.string().default("")}).openapi("LocalizedProductCategory");const Uo=Ct.pick({slug:!0,image:!0,translations:!0}).extend({defaultLocale:d.z.string().min(1,"Default locale is required").openapi({description:"The default locale for the product category"}),imageId:d.z.string().cuid().optional().openapi({description:"ID of the image for the product category"})}).superRefine(wa("title")).openapi("CreateProductCategory"),Zo=Ct.pick({slug:!0,image:!0,translations:!0}).extend({defaultLocale:d.z.string().min(1,"Default locale is required").openapi({description:"The default locale for the product category"}),imageId:d.z.string().cuid().optional().nullable().openapi({description:"ID of the image for the product category"})}).partial().superRefine(wa("title")).openapi("UpdateProductCategory"),_s=d.z.object({id:d.z.string().cuid().optional(),title:d.z.string().min(1,"This field is required").openapi({example:"Large",description:"Title of the modifier"}),sku:d.z.coerce.string().optional().openapi({example:"csd9876543210abcdef",description:"Stock Keeping Unit identifier"}),price:d.z.coerce.number().optional().default(0).openapi({example:2.5,description:"Price of the modifier"})}).openapi("Modifier"),$s=d.z.object({id:d.z.string().cuid(),selectMin:d.z.coerce.number().min(0).openapi({example:1,description:"Minimum number of modifiers that can be selected"}),selectMax:d.z.coerce.number().min(0).openapi({example:1,description:"Maximum number of modifiers that can be selected"}),defaultLocale:We.optional(),modifiers:d.z.array(_s).optional().openapi({}),translations:d.z.array(d.z.object({locale:We,title:d.z.string().optional().openapi({example:"Size",description:"Title of the modifier group"})}))}).openapi("ModifierGroup"),_o=$s.extend({title:d.z.string().default("").nullable()}).omit({translations:!0}).openapi("LocalizedModifierGroup"),Ws=d.z.object({selectMin:d.z.coerce.number().min(0).openapi({example:1,description:"Minimum number of modifiers that can be selected"}),selectMax:d.z.coerce.number().min(0).openapi({example:1,description:"Maximum number of modifiers that can be selected"}),defaultLocale:We.optional(),modifiers:d.z.array(_s).optional().openapi({}),translations:d.z.array(d.z.object({locale:We,title:d.z.string().optional().openapi({example:"Size",description:"Title of the modifier group"})}))}).refine(a=>a.selectMax>=a.selectMin,{message:"Maximum selections must be greater than or equal to minimum selections",path:["selectMax"]}).refine(a=>{var r;const t=((r=a.modifiers)==null?void 0:r.length)||0;return a.selectMax<=t},{message:"Maximum selections cannot exceed the total number of modifiers",path:["selectMax"]}).superRefine(wa("title")).openapi("CreateOrUpdateModifierGroup"),Ks=d.z.object({id:d.z.string().cuid().openapi({example:"clf9876543210abcdef",description:"ID of the product"}),slug:d.z.string().optional().openapi({example:"premium-watch",description:"Unique slug for the product"}),sku:d.z.string().optional().openapi({example:"PRM-WATCH-01",description:"Stock Keeping Unit identifier"}),availableQuantity:Vo.openapi({example:12,description:"Available stock quantity. Null means unlimited inventory."}),basePrice:ct,discountedBasePrice:Zs,currency:d.z.string().openapi({example:"USD",description:"Currency code for pricing"}),images:d.z.array(ta).optional().openapi({description:"List of product images"}),modifierGroups:d.z.array($s).optional().openapi({description:"List of product modifier groups"}),categories:d.z.array(Ct).openapi({example:["cju0z9k4z0000l1qg5z1z1z"],description:"IDs of associated product categories"}),manufacturerId:d.z.string().cuid().nullable().optional().openapi({description:"ID of associated manufacturer"}),createdAt:d.z.date(),publishedAt:d.z.date().nullable().optional(),translations:d.z.array(d.z.object({locale:We,title:d.z.coerce.string().optional().openapi({example:"Premium Watch",description:"Product name in specified locale"}),description:d.z.string().nullable().optional().openapi({example:"High-quality premium watch",description:"Product description in specified locale"})})).optional(),metadata:d.z.record(d.z.string().min(1,"Key cannot be empty").max(50,"Key too long").regex(/^[a-zA-Z][a-zA-Z0-9_-]*$/,"Key must start with letter and contain only letters, numbers, underscore, or dash"),d.z.string().min(1,"Value cannot be empty").max(200,"Value too long")).optional().nullable()}).openapi("Product"),$o=Ks.extend({title:d.z.string().default(""),description:d.z.string().nullable().default(""),modifierGroups:d.z.array(_o),categories:d.z.array(d.z.object({id:d.z.string().cuid().openapi({example:"cju0z9k4z0000l1qg5z1z1z",description:"ID of the product category"})})).default([])}).omit({translations:!0}).openapi("LocalizedProduct"),Gs=Ks.pick({slug:!0,sku:!0,availableQuantity:!0,basePrice:!0,discountedBasePrice:!0,currency:!0,images:!0,manufacturerId:!0,translations:!0,metadata:!0}).extend({defaultLocale:d.z.string().min(1,"Default locale is required").openapi({example:"en-US",description:"Default translation locale"}),modifierGroups:d.z.array(Ws).optional().openapi({description:"List of product modifier groups"}),categories:d.z.array(d.z.string()).optional().openapi({example:["cju0z9k4z0000l1qg5z1z1z"],description:"IDs of associated product categories"})}),Wo=Gs.superRefine((a,t)=>(a.discountedBasePrice!==null&&a.discountedBasePrice!==void 0&&a.discountedBasePrice>a.basePrice&&t.addIssue({code:d.z.ZodIssueCode.custom,path:["discountedBasePrice"],message:"Discounted price cannot exceed base price"}),wa("title")(a,t))).openapi("CreateProduct"),Ko=Gs.partial().superRefine((a,t)=>(a.discountedBasePrice!==null&&a.discountedBasePrice!==void 0&&a.basePrice&&a.discountedBasePrice>a.basePrice&&t.addIssue({code:d.z.ZodIssueCode.custom,path:["discountedBasePrice"],message:"Discounted price cannot exceed base price"}),wa("title")(a,t))).openapi("UpdateProduct"),Go=d.z.record(d.z.string().openapi({example:"clf9876543210abcdef",description:"ID of the product in the cart"}),$o),St=d.z.object({productId:d.z.string().cuid().openapi({example:"clf9876543210abcdef",description:"ID of the product in the cart"}),quantity:d.z.number().default(1).optional().openapi({example:2,description:"Quantity of this item in the cart"}),modifierGroups:d.z.array(d.z.object({id:d.z.string().cuid().openapi({example:"clg1234567890abcdef",description:"ID of the modifier group"}),modifiers:d.z.array(d.z.object({id:d.z.string().cuid().openapi({example:"clh9876543210abcdef",description:"ID of the selected modifier"}),quantity:d.z.number().default(1).openapi({example:1,description:"Quantity of this modifier"})}))}))}).openapi("CartItem"),Xo=d.z.object({items:d.z.array(St),shippingMethodId:d.z.string().cuid().optional()}),Yo=d.z.enum(["invalid_product","out_of_stock","insufficient_stock"]).openapi("CartAdjustmentReason"),el=d.z.object({productId:d.z.string().cuid().openapi({example:"clf9876543210abcdef",description:"ID of the affected product"}),modifierGroups:St.shape.modifierGroups.optional(),reason:Yo,requestedQuantity:d.z.number().int().min(0).openapi({example:3,description:"Quantity requested by the customer"}),resolvedQuantity:d.z.number().int().min(0).openapi({example:1,description:"Quantity accepted after stock normalization"})}).openapi("CartAdjustment"),al=d.z.object({invalidProductIds:d.z.array(d.z.string()),normalizedItems:d.z.array(St),adjustments:d.z.array(el),products:Go,shipping:d.z.number().optional(),subtotal:d.z.number(),total:d.z.number()});al.extend({message:d.z.string()}).openapi("CartConflict"),d.z.object({status:d.z.number().openapi({example:404,description:"The HTTP status code"}),message:d.z.string().openapi({example:"Not found",description:"The error message"})}),d.z.object({"accept-language":d.z.string().optional().openapi({example:"en-US",description:"Accept-Language header",param:{in:"header",name:"accept-language"}}),cookie:d.z.string().optional().openapi({example:"session=1234567890",description:"Cookie header",param:{in:"header",name:"cookie"}})}).openapi("Headers");const tl=d.z.string().min(1).openapi({example:"stripe",description:"Integration type key"}),ir=d.z.enum(["card","blik"]).openapi({example:"card",description:"Stripe payment method"});d.z.object({paymentMethods:d.z.array(ir).max(2).optional(),secretKey:d.z.string().trim().min(1).optional(),webhookSecret:d.z.string().trim().min(1).optional()}).strict(),d.z.object({apiKey:d.z.string().trim().min(1).optional(),fromEmail:d.z.string().trim().email().optional()}).strict();const zt=d.z.object({paymentMethods:d.z.array(ir).max(2).openapi({example:["card","blik"],description:"Enabled Stripe payment methods for the organization"}),hasSecretKey:d.z.boolean().openapi({example:!0,description:"Whether the Stripe API key has been configured"}),hasWebhookSecret:d.z.boolean().openapi({example:!0,description:"Whether the Stripe webhook signing secret has been configured"})}).strict().openapi("StripeIntegrationConfig"),rl=d.z.object({paymentMethods:d.z.array(ir).max(2).openapi({example:["card","blik"],description:"Enabled Stripe payment methods for the organization"}),secretKey:d.z.string().trim().min(1).optional().openapi({example:"sk_live_123456789",description:"Stripe secret API key for the organization"}),webhookSecret:d.z.string().trim().min(1).optional().openapi({example:"whsec_123456789",description:"Stripe webhook signing secret for the organization"})}).strict().openapi("UpsertStripeIntegrationConfig"),It=d.z.object({hasApiKey:d.z.boolean().openapi({example:!0,description:"Whether the Resend API key has been configured"}),fromEmail:d.z.string().trim().email().optional().openapi({example:"orders@example.com",description:"Verified sender email used for transactional messages"})}).strict().openapi("ResendIntegrationConfig"),sl=d.z.object({apiKey:d.z.string().trim().min(1).optional().openapi({example:"re_123456789",description:"Resend API key for the organization"}),fromEmail:d.z.string().trim().email().optional().openapi({example:"orders@example.com",description:"Verified sender email used for transactional messages"})}).strict().openapi("UpsertResendIntegrationConfig"),il=d.z.record(d.z.string(),d.z.unknown()).openapi("IntegrationConfig");d.z.object({organizationId:d.z.string().openapi({example:"clm1234567890abcdef",description:"Organization ID"}),type:tl,config:il.openapi({description:"Stored integration configuration JSON"}),createdAt:d.z.date().openapi({description:"Timestamp when the integration was created"}),updatedAt:d.z.date().openapi({description:"Timestamp when the integration was last updated"})}).openapi("Integration"),d.z.object({config:d.z.unknown().openapi({example:{paymentMethods:["card","blik"],secretKey:"sk_live_123456789",webhookSecret:"whsec_123456789"},description:"Integration configuration payload. Validation depends on the integration type."})}).openapi("UpsertIntegration"),d.z.object({id:d.z.string().openapi({example:"clm1234567890abcdef",description:"User's ID"}),email:d.z.string().openapi({example:"user@example.com",description:"User's email address",format:"email"}),firstname:d.z.string().openapi({example:"John",description:"User's first name"}),lastname:d.z.string().openapi({example:"Doe",description:"User's last name"}),image:d.z.string().nullable().optional().openapi({example:"https://example.com/image.jpg",description:"User's profile image"}),name:d.z.string().nullable().optional().openapi({description:"User's full name (optional)"})}).openapi("User");const nl=d.z.object({page:d.z.coerce.number().optional().default(1).openapi({example:1,description:"Page number"}),limit:d.z.coerce.number().optional().default(10).openapi({example:50,description:"Number of items per page"}),search:d.z.string().optional().openapi({example:"Apple",description:"Search query"}),published:d.z.coerce.boolean().optional().openapi({example:!0,description:"Whether to filter by published items"}),locale:We.optional()});d.z.object({isFirstPage:d.z.boolean().openapi({example:!0,description:"Whether the current page is the first page"}),isLastPage:d.z.boolean().openapi({example:!1,description:"Whether the current page is the last page"}),currentPage:d.z.number().openapi({example:1,description:"The current page number"}),previousPage:d.z.number().nullable().openapi({example:0,description:"The previous page number"}),nextPage:d.z.number().nullable().openapi({example:2,description:"The next page number"}),pageCount:d.z.number().openapi({example:5,description:"The total number of pages"}),totalCount:d.z.number().openapi({example:50,description:"The total number of items"})}).openapi("PaginationMeta");const va=d.z.object({id:d.z.string().cuid().openapi({example:"clf9876543210abcdef",description:"The unique identifier of the address"}),firstname:d.z.string().optional().nullable().openapi({example:"John",description:"The first name of the recipient"}),lastname:d.z.string().optional().nullable().openapi({example:"Doe",description:"The last name of the recipient"}),phone:d.z.string().optional().nullable().openapi({example:"+1234567890",description:"Phone number of the recipient"}),addressLineOne:d.z.string().openapi({example:"123 Main Street",description:"The first line of the address"}),doorNumber:d.z.string().nullable().optional().openapi({description:"The door number of the address"}),addressLineTwo:d.z.string().nullable().optional().openapi({example:"Suite 100",description:"The second line of the address"}),zipCode:d.z.string().optional().openapi({example:"12345",description:"The postal code of the address"}),city:d.z.string().openapi({example:"New York",description:"The city of the address"}),country:d.z.string().openapi({example:"USA",description:"The country of the address"}),placeId:d.z.string().openapi({example:"ChIJN1t_tKlj4AR4GeTYWZ7frY",description:"The Google Place ID for the address"}),deliveryInstructions:d.z.string().nullable().optional().openapi({example:"Leave at the door",description:"Delivery instructions for the address"})}).openapi("Address"),Et=va.pick({addressLineOne:!0,doorNumber:!0,addressLineTwo:!0,zipCode:!0,city:!0,country:!0,placeId:!0}).openapi("CreateAddress"),Xs=Et.partial().openapi("UpdateAddress"),ol=va.extend({firstname:d.z.string().min(2,"First Name must be at least 2 characters").openapi({example:"John",description:"The first name of the recipient"}),lastname:d.z.string().min(1,"Last Name must be at least 2 characters").openapi({example:"Doe",description:"The last name of the recipient"}),phone:d.z.string().min(4).openapi({example:"+1234567890",description:"Phone number of the recepient"})}),Ys=ol.pick({firstname:!0,lastname:!0,phone:!0,addressLineOne:!0,addressLineTwo:!0,doorNumber:!0,zipCode:!0,city:!0,country:!0,placeId:!0,deliveryInstructions:!0});Ys.partial().extend({placeId:d.z.string().min(1,"This field is required").openapi({example:"ChIJN1t_tKlj4AR4GeTYWZ7frY",description:"The Google Place ID for the address"})}).openapi("UpdateShippingAddress");const nr=d.z.enum(["card","blik","cash_on_delivery","paypal"]).openapi({description:"The payment method",example:"card"}),or=d.z.enum(["stripe","revolut","payu","not_applicable"]).openapi({description:"The payment method",example:"card"}),ll=d.z.enum(["pending","succeeded","refunded","failed","canceled"]).openapi({description:"The payment status",example:"pending"});d.z.object({id:d.z.string().min(1),provider:or,method:nr,description:d.z.string().min(1)}).openapi({description:"The payment method",example:{provider:"stripe",type:"card"}});const dl=d.z.object({id:d.z.string().cuid().min(1),method:nr,provider:or,status:ll,shipping:d.z.number().min(0).default(0),subtotal:d.z.number().min(0),total:d.z.number().min(0),discount:d.z.number().min(0).default(0),currency:Nt}),Wr=d.z.object({id:d.z.string().optional().openapi({example:"clf9876543210abcdef",description:"ID of the shipping zone"}),title:d.z.string().min(1,"Title is required").openapi({example:"Zone 1",description:"Title of the shipping zone"}),distanceUpto:ct.openapi({example:10,description:"Ending distance for the shipping zone"}),price:ct.openapi({example:5.99,description:"Price for shipping in this zone"}),minimumOrderAmount:Zs.openapi({example:50,description:"Minimum order amount for this shipping zone"}),eta:d.z.string().min(1,"ETA is required").openapi({example:"2-3 days",description:"Estimated time of arrival for this shipping zone"})}).openapi("ShippingZone"),ei=d.z.object({id:d.z.string().openapi({example:"clf9876543210abcdef",description:"ID of the shipping method"}),title:d.z.string().min(1,"Title is required").openapi({example:"Standard Shipping",description:"Title of the shipping method"}),providerName:d.z.string().min(1,"Provider name is required").openapi({example:"FedEx",description:"Name of the shipping provider"}),providerLogo:ta.nullable().optional().openapi({description:"Logo of the shipping provider"}),requireDateOfDelivery:d.z.coerce.boolean().optional().openapi({example:!0,description:"Whether the delivery time should be selected"}),shippingZones:d.z.array(Wr).openapi({description:"List of shipping zones for this shipping method"}),eligibleShippingZone:Wr.optional(),createdAt:d.z.date(),updatedAt:d.z.date()}).openapi("ShippingMethod"),ai=ei.pick({title:!0,providerName:!0,providerLogo:!0,requireDateOfDelivery:!0,shippingZones:!0}).extend({providerLogoId:d.z.string().cuid().optional().openapi({example:"clf9876543210abcdef",description:"ID reference to the provider logo file"})}).openapi("CreateShippingMethod"),cl=ai.partial().openapi("UpdateShippingMethod"),ml=d.z.enum(["draft","pending","accepted","ready-for-dispatch","dispatched","completed","cancelled"]).openapi({description:"Status of the order",example:"accepted"}),ul=d.z.object({translations:d.z.array(d.z.object({locale:We.openapi({description:"Locale of the translation",example:"en-US"}),title:d.z.string().openapi({description:"Title of the ordered product",example:"Premium Watch"}),subtitle:d.z.string().openapi({description:"Additional details about the ordered item, including modifiers",example:"Color: Silver, Size: Large"})})).openapi({description:"Translations for the order item"}),rawData:St,unitPrice:d.z.number().min(0).openapi({description:"Price per unit of the item",example:299.99}),image:ta.nullable().optional(),totalPrice:d.z.number().min(0).openapi({description:"Total price for this item (unitPrice × quantity)",example:599.98}),quantity:d.z.number().min(1).openapi({description:"Number of units ordered",example:2}),productSnapshotId:d.z.string().cuid()}).openapi("OrderItem"),pl=d.z.object({productId:d.z.string().cuid(),title:d.z.string(),requestedQuantity:d.z.number().int().min(1),availableQuantity:d.z.number().int().min(0)}).openapi("InventoryConflictItem");d.z.object({id:d.z.string().openapi({description:"Unique identifier for the order",example:"clj1234567890abcdef"}),referenceId:d.z.string().openapi({description:"External reference ID for the order",example:"ORD-12345"}),status:ml.optional(),token:d.z.string().openapi({description:"Security token for order verification",example:"a1b2c3d4e5f6g7h8i9j0"}),expiresAt:d.z.date().openapi({description:"Expiration date for the order",example:"2023-12-31T23:59:59Z"}),items:d.z.array(ul).min(1).openapi({description:"Array of items in the order"}),shippingMethod:ei.nullable().openapi({description:"Shipping method selected for the order"}),acceptedAt:d.z.date().nullable().optional().openapi({description:"Date when the order was accepted",example:"2023-06-15T14:30:00Z"}),dispatchedAt:d.z.date().nullable().optional().openapi({description:"Date when the order was dispatched",example:"2023-06-16T09:15:00Z"}),readyForDispatchAt:d.z.date().nullable().optional().openapi({description:"Date when the order was ready for dispatch",example:"2023-06-16T09:15:00Z"}),createdAt:d.z.date().openapi({description:"Date when the order was created",example:"2023-06-15T14:30:00Z"}),completedAt:d.z.date().nullable().optional().openapi({description:"Date when the order was completed",example:"2023-06-18T11:45:00Z"}),cancelledAt:d.z.date().nullable().optional().openapi({description:"Date when the order was cancelled",example:"2023-06-14T16:20:00Z"}),inventoryDeductedAt:d.z.date().nullable().optional().openapi({description:"Date when the paid order inventory was deducted",example:"2023-06-15T14:30:00Z"}),inventoryConflictAt:d.z.date().nullable().optional().openapi({description:"Date when the paid order was flagged for manual inventory review",example:"2023-06-15T14:30:00Z"}),inventoryConflictItems:d.z.array(pl).nullable().optional().openapi({description:"List of line items that could not be deducted after payment"}),shippingAddress:va.nullable().optional(),fulfilmentMethod:Gt.openapi({description:"Method of order fulfilment (pickup or delivery)",example:"delivery"}),currency:Nt.openapi({description:"Currency used for the order",example:"USD"}),payment:dl}).transform(a=>{let t;return a.cancelledAt?t="cancelled":a.completedAt?t="completed":a.dispatchedAt?t="dispatched":a.readyForDispatchAt?t="ready-for-dispatch":a.acceptedAt?t="accepted":t="pending",{...a,status:t}}).openapi("Order"),Xo.extend({fulfilmentMethod:Gt.default("delivery"),payment:d.z.object({provider:or,method:nr}),checkoutBaseUrl:d.z.string().url()}).refine(a=>a.fulfilmentMethod!=="delivery"||a.shippingMethodId!==void 0,{message:"shippingMethodId is required when fulfilmentMethod is 'delivery'",path:["shippingMethodId"]}).openapi("CreateOrder");const Kr=d.z.object({monday:d.z.string().nullable().openapi({example:"09:00",description:"Opening time for Monday"}),tuesday:d.z.string().nullable().openapi({example:"09:00",description:"Opening time for Tuesday"}),wednesday:d.z.string().nullable().openapi({example:"09:00",description:"Opening time for Wednesday"}),thursday:d.z.string().nullable().openapi({example:"09:00",description:"Opening time for Thursday"}),friday:d.z.string().nullable().openapi({example:"09:00",description:"Opening time for Friday"}),saturday:d.z.string().nullable().openapi({example:"09:00",description:"Opening time for Saturday"}),sunday:d.z.string().nullable().openapi({example:"09:00",description:"Opening time for Sunday"})}).openapi("TimeSchedule"),ti=d.z.object({id:d.z.string().openapi({example:"clm1234567890abcdef",description:"Unique identifier for the organization configuration"}),hostname:d.z.coerce.string().optional().openapi({example:"store.example.com",description:"Hostname associated with the organization"}),countriesShipping:d.z.array(d.z.string()).openapi({example:["US","CA"],description:"List of countries where shipping is available"}),stripeAccountId:d.z.coerce.string().optional().openapi({example:"acct_123456789",description:"Stripe account ID associated with the organization"}),enableHostCheckout:d.z.boolean().openapi({example:!0,description:"Indicates if host checkout is enabled"}),enableHostTracking:d.z.boolean().openapi({example:!0,description:"Indicates if host tracking is enabled"}),isAcceptingOrders:d.z.boolean().openapi({example:!0,description:"Indicates if the organization is currently accepting orders"}),isAcceptingReservations:d.z.boolean().openapi({example:!0,description:"Indicates if the organization is currently accepting reservations"}),isOpen:d.z.boolean().default(!1).openapi({example:!0,description:"Indicates if the organization is currently open"}),defaultLocale:We,supportedLocales:d.z.array(We).openapi({description:"List of supported locales for the organization"}),openingTimes:Kr.optional(),closingTimes:Kr.optional(),facebookProfile:d.z.string().nullable().optional().openapi({example:"https://www.facebook.com/example",description:"Facebook profile URL for the organization"}),instagramProfile:d.z.string().nullable().optional().openapi({example:"https://www.instagram.com/example",description:"Instagram profile URL for the organization"}),xProfile:d.z.string().nullable().optional().openapi({example:"https://www.x.com/example",description:"X profile URL for the organization"}),defaultCurrency:Nt.openapi({example:"USD",description:"Default currency for the organization"}),createdAt:d.z.date().openapi({description:"Timestamp when the organization configuration was created"})}).openapi("OrganizationConfiguration"),gl=ti.pick({hostname:!0,countriesShipping:!0,stripeAccountId:!0,enableHostCheckout:!0,enableHostTracking:!0,isAcceptingOrders:!0,isAcceptingReservations:!0,defaultLocale:!0,supportedLocales:!0,defaultCurrency:!0,openingTimes:!0,closingTimes:!0,facebookProfile:!0,instagramProfile:!0,xProfile:!0}).partial().openapi("UpdateOrganizationConfiguration"),hl=d.z.object({id:d.z.string().openapi({example:"clm1234567890abcdef",description:"The unique identifier of the organization"}),name:d.z.string().openapi({example:"Acme Store",description:"The name of the organization"}),phone:d.z.string().min(1,"Phone number is required").openapi({example:"+48123456890",description:"The phone number of the organization"}),email:d.z.string().email().optional().openapi({example:"john.doe@example.com",description:"The email address of the organization"}),createdAt:d.z.date().openapi({example:"2022-01-01T00:00:00.000Z",description:"The date and time the organization was created"}),legalEntityId:d.z.string().nullable().openapi({example:"clm1234567890abcdef",description:"The unique identifier of the legal entity associated with the organization"}),address:va,configuration:ti.openapi({description:"The configuration settings for the organization"}),logo:d.z.string().url().optional().nullable().openapi({example:"https://example.com/logo.jpg",description:"The logo of the organization"}),logoFile:ta.optional().nullable().openapi({description:"The logo of the organization"})}).openapi("Organization"),ri=hl.pick({name:!0,phone:!0,email:!0,logoFile:!0}).extend({logoId:d.z.string().optional().nullable().openapi({example:"clm1234567890abcdef",description:"The unique identifier of the thumbnail image associated with the organization"}),address:Et}).openapi("CreateOrganization"),lr=ri.extend({address:Xs,configuration:gl}).partial().openapi("UpdateOrganization"),xl=d.z.object({id:d.z.string().openapi({example:"clf9876543210abcdef",description:"ID of the manufacturer"}),name:d.z.string().openapi({example:"Tech Innovators Inc.",description:"Name of the manufacturer"}),logo:ta.nullable().optional().openapi({description:"Logo of the manufacturer"}),createdAt:d.z.date(),translations:d.z.array(d.z.object({locale:d.z.string().min(1,"Locale is required").openapi({example:"en-US",description:"Locale code for the translation"}),about:d.z.string().max(6e3,"Maximum character limit is 6000").nullable().optional().openapi({example:"Tech Innovators Inc. is a technology company.",description:"Description about the manufacturer in the specified locale"})})).optional().openapi({description:"List of translations for the manufacturer"})}).openapi("Manufacturer");xl.omit({translations:!0}).extend({about:d.z.string().nullable().optional().default("")}).openapi("LocalizedManufacturer");const fl=d.z.object({name:d.z.string().min(1,"Name is required").openapi({example:"Apple Inc.",description:"Name of the manufacturer"}),defaultLocale:d.z.string().min(1,"Default locale is required").openapi({example:"en-US",description:"The default locale for the manufacturer"}),logo:ta.nullable().optional().openapi({description:"Logo of the manufacturer"}),translations:d.z.array(d.z.object({locale:d.z.string().min(1,"Locale is required").openapi({example:"en-US",description:"Locale code for the translation"}),about:d.z.string().max(6e3,"Maximum character limit is 6000").nullable().optional().openapi({example:"Apple Inc. is a multinational technology company.",description:"Description about the manufacturer in the specified locale"})})).min(1,"Translations are required").openapi({description:"List of translations for the manufacturer"}),logoId:d.z.string().optional().openapi({example:"clf9876543210abcdef",description:"ID reference to the manufacturer's logo file"})}).superRefine(wa("about")).openapi("CreateManufacturer"),yl=d.z.object({name:d.z.string().min(1,"Name is required").optional().openapi({example:"Apple Inc. Updated",description:"Name of the manufacturer"}),logo:ta.nullable().optional().openapi({description:"Logo of the manufacturer"}),defaultLocale:d.z.string().min(1,"Default locale is required").openapi({description:"The default locale for the manufacturer"}),logoId:d.z.string().nullable().optional().openapi({example:"clf9876543210abcdef",description:"ID reference to the manufacturer's logo file"}),translations:d.z.array(d.z.object({locale:d.z.string().min(1,"Locale is required").openapi({example:"en-US",description:"Locale code for the translation"}),about:d.z.string().max(6e3,"Maximum character limit is 6000").nullable().optional().openapi({example:"Apple Inc. is a multinational technology company.",description:"Description about the manufacturer in the specified locale"})})).optional().openapi({description:"List of translations for the manufacturer"})}).openapi("UpdateManufacturer");d.z.object({id:d.z.string().openapi({example:"clm1234567890abcdef",description:"The unique identifier of the legal entity"}),name:d.z.string().openapi({example:"Acme Corporation",description:"The name of the legal entity"}),taxId:d.z.string().min(2).max(20).openapi({example:"PL1234567890",description:"The TAX ID of the legal entity"}),email:d.z.string().email().nullable().openapi({example:"contact@acme.com",description:"The email of the legal entity",format:"email"}),phone:d.z.string().nullable().openapi({example:"+48123456789",description:"The phone number of the legal entity"}),createdAt:d.z.date().openapi({description:"The date and time when the legal entity was created",format:"date-time"}),address:va.required().openapi({description:"The address of the legal entity"})}).openapi("LegalEntity"),d.z.object({name:d.z.string().min(1,"Name is required").openapi({example:"Acme Corporation",description:"The name of the legal entity"}),taxId:d.z.string().min(2).max(20).openapi({example:"PL1234567890",description:"The TAX ID of the legal entity"}),email:d.z.string().email().optional().openapi({example:"contact@acme.com",description:"The email of the legal entity",format:"email"}),phone:d.z.string().optional().openapi({example:"+48123456789",description:"The phone number of the legal entity"}),address:Et.required().openapi({description:"The address of the legal entity"})}).openapi("CreateLegalEntity"),d.z.object({name:d.z.string().min(1,"Name is required").optional().openapi({example:"Acme Corporation",description:"The name of the legal entity"}),taxId:d.z.string().min(2).max(20).openapi({example:"PL1234567890",description:"The TAX ID of the legal entity"}),email:d.z.string().email().optional().openapi({example:"contact@acme.com",description:"The email of the legal entity",format:"email"}),phone:d.z.string().optional().openapi({example:"+48123456789",description:"The phone number of the legal entity"}),address:Xs.required().openapi({description:"The address of the legal entity"})}).openapi("UpdateLegalEntity");const bl=d.z.object({id:d.z.string().openapi({example:"clf9876543210abcdef",description:"ID of the customer"}),firstname:d.z.string().nullable().optional().openapi({example:"John Doe",description:"Name of the customer"}),email:d.z.string().nullable().optional().openapi({example:"john.doe@example.com",description:"Email of the customer"}),phone:d.z.string().nullable().optional().openapi({example:"+1234567890",description:"Phone number of the customer"}),address:va.nullable().optional().openapi({description:"Address of the customer"}),createdAt:d.z.date(),updatedAt:d.z.date()}).openapi("Customer"),jl=bl.pick({firstname:!0,email:!0,phone:!0}).extend({address:Et}).openapi("Customer");jl.partial().openapi("UpdateCustomer");const dr=d.z.object({email:d.z.string().min(1,"Email is required").email("Invalid email").openapi({example:"user@example.com",description:"User's email address"}),password:d.z.string().min(1,"Password is required").min(8,"Password must be more than 8 characters").max(32,"Password must be less than 32 characters").openapi({example:"password123",description:"User's password"}),firstname:d.z.string().min(1,"First name is required").max(32,"First name must be less than 32 characters").openapi({example:"John",description:"User's first name"}),lastname:d.z.string().min(1,"Last name is required").max(32,"Last name must be less than 32 characters").openapi({example:"Doe",description:"User's last name"})}).openapi("SignUp"),si=dr.pick({email:!0,password:!0}).openapi("SignIn"),wl=d.z.object({organizationId:d.z.string().cuid().min(1,"organizationId is required").openapi({example:"ckel0e8qw00004n5p5w6fznym",description:"The organization ID"})}).openapi("OrganizationParams");wl.extend({id:d.z.string().cuid().min(1,"id is required").openapi({example:"ckel0e8qw00004n5p5w6fznym",description:"The organization ID"})}).openapi("OrganizationWithIdParams"),d.z.object({placeId:d.z.string().openapi({example:"ChIJN1t_tKlj4AR4GeTYWZ7frY",description:"The Google Place ID for the address"}),text:d.z.string().openapi({example:"123 Main Street, New York, USA",description:"The description of the place"}),addressLineOne:d.z.string().openapi({example:"123 Main Street",description:"The first line of the address"}),addressLineTwo:d.z.string().optional().openapi({example:"Suite 100",description:"The second line of the address"}),latitude:d.z.number().optional().openapi({example:40.712776,description:"The latitude of the coordinate"}),longitude:d.z.number().optional().openapi({example:-74.005974,description:"The longitude of the coordinate"})}).openapi("Place"),d.z.object({addressLineOne:d.z.string().openapi({example:"123 Main Street",description:"The first line of the address"}),zipCode:d.z.string().optional().openapi({example:"12345",description:"The postal code of the address"}),city:d.z.string().openapi({example:"New York",description:"The city of the address"}),country:d.z.string().openapi({example:"USA",description:"The ISO 3166-1 alpha-2 country code"})}).openapi("PlaceDetails");const $t=a=>d.z.any().transform(t=>typeof t=="string"?t.trim():"").refine(t=>t.length>0,{message:`${a} is required`}),vl=d.z.any().transform(a=>a==null||a===""?Number.NaN:Number(a)).refine(a=>Number.isFinite(a)&&a>0,{message:"Number of guests is required"}),kl=d.z.any().refine(a=>a!=null&&a!=="",{message:"Reservation date is required"}).transform(a=>new Date(a)).refine(a=>!Number.isNaN(a.getTime()),{message:"Reservation date is required"}),Nl=d.z.object({id:d.z.string().openapi({description:"Unique identifier for the order",example:"clj1234567890abcdef"}),firstname:d.z.string().openapi({description:"Customer's first name",example:"John"}),lastname:d.z.string().openapi({description:"Customer's last name",example:"Doe"}),guests:ct,phone:d.z.string().openapi({description:"Customer's phone number",example:"+1234567890"}),date:d.z.coerce.date().openapi({description:"Reservation date and time",example:"2023-06-14T16:20:00Z"}),referenceId:d.z.string().openapi({description:"External reference ID for the order",example:"ORD-12345"}),acceptedAt:d.z.date().nullable().optional().openapi({description:"Date when the order was accepted",example:"2023-06-15T14:30:00Z"}),cancelledAt:d.z.date().nullable().optional().openapi({description:"Date when the order was cancelled",example:"2023-06-14T16:20:00Z"}),createdAt:d.z.date().nullable().optional().openapi({description:"Date when the order was created",example:"2023-06-14T16:20:00Z"})}).openapi("Reservation"),Al=Nl.pick({firstname:!0,lastname:!0,guests:!0,phone:!0,date:!0}).extend({firstname:$t("First name").openapi({description:"Customer's first name",example:"John"}),lastname:$t("Last name").openapi({description:"Customer's last name",example:"Doe"}),guests:vl.openapi({description:"Number of guests included in the reservation",example:2}),phone:$t("Phone number").openapi({description:"Customer's phone number",example:"+1234567890"}),date:kl.openapi({description:"Reservation date and time",example:"2023-06-14T16:20:00Z"})}).openapi("CreateReservation");nl.extend({from:d.z.coerce.date().optional().openapi({description:"Filter reservations scheduled from this date and time",example:"2026-03-01T00:00:00.000Z"}),to:d.z.coerce.date().optional().openapi({description:"Filter reservations scheduled up to this date and time",example:"2026-03-31T23:59:59.999Z"})}).openapi("ReservationListQuery");function ua(...a){return js.twMerge(bs(...a))}const ii=["focus:ring-2","focus:ring-blue-200 dark:focus:ring-blue-700/30","focus:border-blue-500 dark:focus:border-blue-700"],ka=["outline outline-offset-2 outline-0 focus-visible:outline-2","outline-blue-500 dark:outline-blue-500"],Cl=["ring-2","border-red-500 dark:border-red-700","ring-red-200 dark:ring-red-700/30"],ni=Oe.tv({base:["relative inline-flex items-center justify-center whitespace-nowrap rounded-lg border px-3 py-2 text-center text-sm font-medium shadow-2xs transition-all duration-100 ease-in-out cursor-pointer","disabled:pointer-events-none disabled:shadow-none disabled:cursor-not-allowed",ka],variants:{variant:{primary:["border-transparent","storefront-primary-action"],secondary:["border-gray-200 dark:border-gray-800","text-gray-900 dark:text-gray-50","bg-white dark:bg-gray-950","hover:bg-gray-50 dark:hover:bg-gray-900/60","disabled:text-gray-400","dark:disabled:text-gray-600"],light:["shadow-none","border-transparent","text-gray-900 dark:text-gray-50","bg-gray-200 dark:bg-gray-900","hover:bg-gray-300/70 dark:hover:bg-gray-800/80","disabled:bg-gray-100 disabled:text-gray-400","dark:disabled:bg-gray-800 dark:disabled:text-gray-600"],ghost:["shadow-none","border-transparent","text-gray-900 dark:text-gray-50","bg-transparent hover:bg-gray-100 dark:hover:bg-gray-800/80","disabled:text-gray-400","dark:disabled:text-gray-600"],destructive:["text-white","border-transparent","bg-red-600 dark:bg-red-700","hover:bg-red-700 dark:hover:bg-red-600","disabled:bg-red-300 disabled:text-white","dark:disabled:bg-red-950 dark:disabled:text-red-400"]}},defaultVariants:{variant:"primary"}}),te=h.forwardRef(({asChild:a,isLoading:t=!1,loadingText:r,className:s,disabled:i,variant:n,children:o,...l},c)=>{const m=a?ar.Slot:"button";return e.jsx(m,{ref:c,className:v(ni({variant:n}),s),disabled:i||t,...l,children:t?e.jsxs("span",{className:"pointer-events-none flex shrink-0 items-center justify-center gap-1.5",children:[e.jsx(M.RiLoader2Fill,{className:"size-4 shrink-0 animate-spin","aria-hidden":"true"}),e.jsx("span",{className:"sr-only",children:r||"Loading"}),r||"Loading"]}):o})});te.displayName="Button";const Gr=[{continent:"America",items:[{value:"US",label:"United States",flag:"🇺🇸"},{value:"CA",label:"Canada",flag:"🇨🇦"},{value:"MX",label:"Mexico",flag:"🇲🇽"},{value:"BR",label:"Brazil",flag:"🇧🇷"},{value:"AR",label:"Argentina",flag:"🇦🇷"},{value:"CO",label:"Colombia",flag:"🇨🇴"},{value:"CL",label:"Chile",flag:"🇨🇱"},{value:"PE",label:"Peru",flag:"🇵🇪"}]},{continent:"Europe",items:[{value:"GB",label:"United Kingdom",flag:"🇬🇧"},{value:"FR",label:"France",flag:"🇫🇷"},{value:"DE",label:"Germany",flag:"🇩🇪"},{value:"PL",label:"Poland",flag:"🇵🇱"},{value:"IT",label:"Italy",flag:"🇮🇹"},{value:"ES",label:"Spain",flag:"🇪🇸"},{value:"NL",label:"Netherlands",flag:"🇳🇱"},{value:"PT",label:"Portugal",flag:"🇵🇹"},{value:"SE",label:"Sweden",flag:"🇸🇪"},{value:"NO",label:"Norway",flag:"🇳🇴"},{value:"DK",label:"Denmark",flag:"🇩🇰"},{value:"FI",label:"Finland",flag:"🇫🇮"},{value:"CH",label:"Switzerland",flag:"🇨🇭"},{value:"IE",label:"Ireland",flag:"🇮🇪"},{value:"BE",label:"Belgium",flag:"🇧🇪"},{value:"AT",label:"Austria",flag:"🇦🇹"},{value:"GR",label:"Greece",flag:"🇬🇷"}]},{continent:"Asia",items:[{value:"CN",label:"China",flag:"🇨🇳"},{value:"JP",label:"Japan",flag:"🇯🇵"},{value:"IN",label:"India",flag:"🇮🇳"},{value:"KR",label:"South Korea",flag:"🇰🇷"},{value:"SG",label:"Singapore",flag:"🇸🇬"},{value:"MY",label:"Malaysia",flag:"🇲🇾"},{value:"ID",label:"Indonesia",flag:"🇮🇩"},{value:"TH",label:"Thailand",flag:"🇹🇭"},{value:"VN",label:"Vietnam",flag:"🇻🇳"},{value:"AE",label:"United Arab Emirates",flag:"🇦🇪"},{value:"SA",label:"Saudi Arabia",flag:"🇸🇦"}]},{continent:"Oceania",items:[{value:"AU",label:"Australia",flag:"🇦🇺"},{value:"NZ",label:"New Zealand",flag:"🇳🇿"},{value:"FJ",label:"Fiji",flag:"🇫🇯"},{value:"PG",label:"Papua New Guinea",flag:"🇵🇬"}]},{continent:"Africa",items:[{value:"ZA",label:"South Africa",flag:"🇿🇦"},{value:"NG",label:"Nigeria",flag:"🇳🇬"},{value:"MA",label:"Morocco",flag:"🇲🇦"},{value:"EG",label:"Egypt",flag:"🇪🇬"},{value:"KE",label:"Kenya",flag:"🇰🇪"},{value:"GH",label:"Ghana",flag:"🇬🇭"},{value:"ET",label:"Ethiopia",flag:"🇪🇹"}]}],Dt=a=>e.jsx(re.Root,{...a});Dt.displayName="Dialog";const oi=re.Trigger;oi.displayName="DialogTrigger";const li=re.Close;li.displayName="DialogClose";const di=re.Portal;di.displayName="DialogPortal";const ci=h.forwardRef(({className:a,...t},r)=>e.jsx(re.Overlay,{ref:r,className:v("fixed inset-0 z-50 overflow-y-auto","bg-black/70","data-[state=open]:animate-dialogOverlayShow",a),...t}));ci.displayName="DialogOverlay";const Rt=h.forwardRef(({className:a,...t},r)=>e.jsx(di,{children:e.jsx(ci,{children:e.jsx(re.Content,{ref:r,className:v("fixed left-1/2 top-1/2 z-50 w-[100vw] max-w-lg -translate-x-1/2 -translate-y-1/2 overflow-y-auto rounded-md border p-6 shadow-lg","border-gray-200 dark:border-gray-900","bg-white dark:bg-[#090E1A]","data-[state=open]:animate-dialogContentShow",ka,a),...t})})}));Rt.displayName="DialogContent";const mi=({className:a,...t})=>e.jsx("div",{className:v("flex flex-col gap-y-1",a),...t});mi.displayName="DialogHeader";const cr=h.forwardRef(({className:a,...t},r)=>e.jsx(re.Title,{ref:r,className:v("text-lg font-semibold","text-gray-900 dark:text-gray-50",a),...t}));cr.displayName="DialogTitle";const ui=h.forwardRef(({className:a,...t},r)=>e.jsx(re.Description,{ref:r,className:v("text-gray-500 dark:text-gray-500",a),...t}));ui.displayName="DialogDescription";const pi=({className:a,...t})=>e.jsx("div",{className:v("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...t});pi.displayName="DialogFooter";const Ua=z.forwardRef(({className:a,...t},r)=>e.jsx(G.Command,{ref:r,className:v("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",a),...t}));Ua.displayName=G.Command.displayName;const Sl=({children:a,...t})=>e.jsx(Dt,{...t,children:e.jsx(Rt,{className:"overflow-hidden p-0",children:e.jsx(Ua,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:a})})}),Ft=z.forwardRef(({className:a,...t},r)=>e.jsxs("div",{className:"flex items-center border-b pl-3","cmdk-input-wrapper":"",children:[e.jsx(N.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(G.Command.Input,{ref:r,className:v("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",a),...t})]}));Ft.displayName=G.Command.Input.displayName;const Mt=z.forwardRef(({className:a,...t},r)=>e.jsx(G.Command.List,{ref:r,className:v("max-h-[300px] overflow-y-auto overflow-x-hidden",a),...t}));Mt.displayName=G.Command.List.displayName;const Pt=z.forwardRef((a,t)=>e.jsx(G.Command.Empty,{ref:t,className:"py-6 text-center text-sm",...a}));Pt.displayName=G.Command.Empty.displayName;const Bt=z.forwardRef(({className:a,...t},r)=>e.jsx(G.Command.Group,{ref:r,className:v("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",a),...t}));Bt.displayName=G.Command.Group.displayName;const gi=z.forwardRef(({className:a,...t},r)=>e.jsx(G.Command.Separator,{ref:r,className:v("-mx-1 h-px bg-border",a),...t}));gi.displayName=G.Command.Separator.displayName;const Tt=z.forwardRef(({className:a,...t},r)=>e.jsx(G.Command.Item,{ref:r,className:v("relative flex cursor-default gap-2 select-none items-center rounded-xs px-2 py-1.5 text-sm outline-hidden data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",a),...t}));Tt.displayName=G.Command.Item.displayName;const hi=({className:a,...t})=>e.jsx("span",{className:v("ml-auto text-xs tracking-widest text-muted-foreground",a),...t});hi.displayName="CommandShortcut";const Na=a=>e.jsx(se.Root,{...a});Na.displayName="Popover";const Aa=z.forwardRef((a,t)=>e.jsx(se.Trigger,{ref:t,...a}));Aa.displayName="PopoverTrigger";const xi=z.forwardRef((a,t)=>e.jsx(se.Anchor,{ref:t,...a}));xi.displayName="PopoverAnchor";const fi=z.forwardRef((a,t)=>e.jsx(se.Close,{ref:t,...a}));fi.displayName="PopoverClose";const Ca=z.forwardRef(({className:a,sideOffset:t=10,side:r="bottom",align:s="center",collisionPadding:i,...n},o)=>e.jsx(se.Portal,{children:e.jsx(se.Content,{ref:o,sideOffset:t,side:r,align:s,collisionPadding:i,avoidCollisions:!0,className:ua("max-h-[var(--radix-popper-available-height)] min-w-60 overflow-hidden rounded-md border p-2.5 text-sm shadow-md","border-gray-200 dark:border-gray-800","text-gray-900 dark:text-gray-50","bg-white dark:bg-gray-950","will-change-[transform,opacity]","data-[state=closed]:animate-hide","data-[state=open]:data-[side=bottom]:animate-slideDownAndFade data-[state=open]:data-[side=left]:animate-slideLeftAndFade data-[state=open]:data-[side=right]:animate-slideRightAndFade data-[state=open]:data-[side=top]:animate-slideUpAndFade",a),onWheel:l=>{l.stopPropagation(),l.deltaY>0?l.currentTarget.dispatchEvent(new KeyboardEvent("keydown",{key:"ArrowDown"})):l.currentTarget.dispatchEvent(new KeyboardEvent("keydown",{key:"ArrowUp"}))},...n})}));Ca.displayName="PopoverContent";const yi=({value:a,onChange:t,disabled:r})=>{const s=h.useId(),[i,n]=h.useState(!1),o=Gr.map(l=>l.items.find(c=>c.value===a)).filter(Boolean)[0];return e.jsx("div",{className:"mt-2",children:e.jsxs(Na,{open:r?!1:i,onOpenChange:r?void 0:n,children:[e.jsx(Aa,{asChild:!0,children:e.jsxs(te,{id:s,role:"combobox",disabled:r,"aria-expanded":i,variant:"secondary",className:"w-full justify-between shadow-2xs! bg-background px-3 py-2.5 font-normal outline-offset-0 hover:bg-background focus-visible:border-ring focus-visible:outline-[3px] focus-visible:outline-ring/20 disabled:opacity-50 disabled:cursor-not-allowed",children:[a?e.jsxs("span",{className:"flex min-w-0 items-center gap-2 mr-auto",children:[e.jsx("span",{className:"text-lg leading-none",children:o==null?void 0:o.flag}),e.jsx("span",{className:"truncate",children:o==null?void 0:o.label})]}):e.jsx("span",{className:"text-muted-foreground",children:"Select country"}),e.jsx(N.ChevronDown,{size:16,strokeWidth:2,className:"shrink-0 text-muted-foreground/80","aria-hidden":"true"})]})}),e.jsx(Ca,{className:"w-full min-w-[var(--radix-popper-anchor-width)] border-input -mt-1 z-50",align:"start",children:e.jsxs(Ua,{className:"p-0",children:[e.jsx(Ft,{className:"w-full border-none",style:{boxShadow:"none"},placeholder:"Search country..."}),e.jsxs(Mt,{children:[e.jsx(Pt,{children:"No country found."}),Gr.map(l=>e.jsx(h.Fragment,{children:e.jsx(Bt,{heading:l.continent,children:l.items.map(c=>e.jsxs(Tt,{value:c.label,className:"cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-800",onSelect:()=>{t(c.value??""),n(!1)},children:[e.jsx("span",{className:"text-lg leading-none",children:c.flag})," ",c.label,a===c.value&&e.jsx(N.Check,{size:16,strokeWidth:2,className:"ml-auto"})]},c.value))})},l.continent))]})]})})]})})},zl=Oe.tv({base:["relative block w-full rounded-lg border px-2.5 py-2.5 shadow-2xs outline-hidden transition sm:text-sm","border-gray-200 dark:border-gray-800","text-gray-900 dark:text-gray-50","placeholder-gray-400 dark:placeholder-gray-500","bg-white dark:bg-gray-950","disabled:border-gray-300 disabled:bg-gray-100 disabled:text-gray-400","dark:disabled:border-gray-700 dark:disabled:bg-gray-800 dark:disabled:text-gray-500",ii],variants:{hasError:{true:Cl},enableStepper:{false:"[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none"},multiline:{true:"resize-y min-h-[100px]",false:"truncate appearance-none"}}}),De=h.forwardRef(({className:a,inputClassName:t,hasError:r,enableStepper:s=!0,type:i,multiline:n=!1,prefix:o,suffix:l,...c},m)=>{const[u,p]=h.useState(i),g=i==="password"&&!n,x=i==="search"&&!n,y=i==="textarea"?"textarea":"input";return e.jsxs("div",{className:v("relative w-full",a),children:[o&&e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center px-3 text-slate-600 dark:text-gray-600 z-10 text-sm border-r border-gray-200",children:o}),e.jsx(y,{ref:m,type:g?u:i,className:v(zl({hasError:r,enableStepper:n?!1:s,multiline:n}),{"pl-16":o,"pl-8":!o&&x,"pr-10":l||!l&&g},t),...c}),!o&&x&&e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-2 text-gray-400 dark:text-gray-600",children:e.jsx(M.RiSearchLine,{className:"size-[1.125rem]"})}),l&&e.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2 text-gray-400 dark:text-gray-600",children:l}),!l&&g&&e.jsx("div",{className:"absolute inset-y-0 right-0 flex items-center pr-3",children:e.jsx("button",{type:"button",onClick:()=>p(u==="password"?"text":"password"),className:v(ka,"text-gray-400 hover:text-gray-500 dark:text-gray-600"),children:u==="password"?e.jsx(M.RiEyeFill,{className:"size-5"}):e.jsx(M.RiEyeOffFill,{className:"size-5"})})})]})});De.displayName="Input";const bi=({...a})=>{const t=h.useId();return e.jsx("div",{className:"mt-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(De,{id:t,type:"email",inputClassName:"peer ps-9",...a}),e.jsx("div",{className:"pointer-events-none absolute inset-y-0 start-0 flex items-center justify-center ps-3 text-muted-foreground/80 peer-disabled:opacity-50",children:e.jsx(N.MailIcon,{size:16})})]})})},ji=a=>{const{client:t}=P(),[r,s]=h.useState(!1),[i,n]=h.useState(0),o=async u=>{const{body:p,status:g}=await t.file.createTemporaryFile({body:{filename:u.name,mimeType:u.type,size:u.size,organizationId:a.organizationId}});if(g!==201)throw new Error("Failed to create temporary file");const x=await ys.upload(u.name,u,{access:"public",handleUploadUrl:`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/files/token/vercel`,clientPayload:JSON.stringify({fileId:p==null?void 0:p.id}),onUploadProgress(y){n(y.percentage)}});return{id:p.id,filename:u.name,mimeType:u.type,size:u.size,url:x.url}},l=async u=>{var p;if((p=u.target.files)!=null&&p[0]){s(!0);try{const g=await o(u.target.files[0]);if(a.multiple){const x=a.value??[];a.onChange([...x,g])}else a.onChange(g)}catch(g){console.error(g)}finally{s(!1)}}},c=u=>{if(a.multiple){if(!a.value)return a.onChange(void 0);const p=a.value.filter(g=>g.id!==u);a.onChange(p.length?p:void 0)}else a.onChange(void 0)},m=()=>{if(a.value){const u=a.multiple?a.value:[a.value];return e.jsxs("div",{className:"flex",children:[u.map(p=>e.jsx("div",{className:"flex flex-col w-40 h-40 mr-3 transition-all rounded-lg relative animate-fade",children:e.jsxs("div",{className:"relative h-full w-40",children:[e.jsx("button",{className:"absolute w-6 h-6 bg-black flex items-center justify-center rounded-md right-1 top-1",onClick:()=>c(p.id),children:e.jsx(N.XIcon,{className:"w-4 h-4 text-white"})}),e.jsx(ze,{src:p.url,alt:p.filename,width:160,height:160,className:"w-40 h-40 rounded-md object-cover"})]})},p.id)),a.multiple&&e.jsxs("div",{className:"group flex relative flex-col w-40 h-40 items-center justify-center cursor-pointer border-2 border-gray-200 border-dashed transition-all rounded-lg hover:bg-gray-100 hover:border-gray-300",children:[e.jsx("div",{className:"flex flex-col items-center justify-center",children:r?e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"animate-spin w-4 h-4 fill-current shrink-0 mb-2",viewBox:"0 0 16 16",children:e.jsx("path",{d:"M8 16a7.928 7.928 0 01-3.428-.77l.857-1.807A6.006 6.006 0 0014 8c0-3.309-2.691-6-6-6a6.006 6.006 0 00-5.422 8.572l-1.806.859A7.929 7.929 0 010 8c0-4.411 3.589-8 8-8s8 3.589 8 8-3.589 8-8 8z"})}),e.jsxs("span",{className:"text-sm",children:["Uploading... (",i,"%)"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(N.CloudUpload,{className:"w-12 h-12 text-gray-300 group-hover:text-gray-600 transition-all stroke-1"}),e.jsx("p",{className:"pt-1 text-sm font-medium text-gray-400 group-hover:text-gray-600",children:"Upload an image"})]})}),e.jsx("input",{type:"file",className:"opacity-0 w-full h-full absolute cursor-pointer",onChange:l,accept:"image/png, image/gif, image/jpeg"})]},"upload-placeholder")]})}return e.jsxs("div",{className:"group flex relative flex-col items-center justify-center cursor-pointer w-full h-40 border-2 border-gray-200 border-dashed transition-all rounded-lg hover:bg-gray-100 hover:border-gray-300",children:[e.jsx("div",{className:"flex flex-col items-center justify-center",children:r?e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"animate-spin w-4 h-4 fill-current shrink-0 mb-2",viewBox:"0 0 16 16",children:e.jsx("path",{d:"M8 16a7.928 7.928 0 01-3.428-.77l.857-1.807A6.006 6.006 0 0014 8c0-3.309-2.691-6-6-6a6.006 6.006 0 00-5.422 8.572l-1.806.859A7.929 7.929 0 010 8c0-4.411 3.589-8 8-8s8 3.589 8 8-3.589 8-8 8z"})}),e.jsxs("span",{className:"text-sm",children:["Uploading... (",i,"%)"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(N.CloudUpload,{className:"w-12 h-12 text-gray-300 group-hover:text-gray-600 transition-all stroke-1"}),e.jsx("p",{className:"pt-1 text-sm font-medium text-gray-400 group-hover:text-gray-600",children:"Upload an image"})]})}),e.jsx("input",{type:"file",className:"opacity-0 w-full h-full absolute cursor-pointer",onChange:l,accept:"image/png, image/gif, image/jpeg"})]},"upload-placeholder")};return e.jsx("div",{className:"flex items-center w-full mt-2",children:m()})},Qt=({value:a,onChange:t,placeholder:r="Search for a place"})=>{const{client:s}=P(),i=h.useId(),[n,o]=h.useState(!1),[l,c]=h.useState(""),[m,u]=h.useState(null),p=h.useRef(null),[g]=aa.useDebounce(l,300);h.useEffect(()=>{a&&(m==null?void 0:m.text)!==a&&c(a)},[a,m]);const{data:x=[],error:y,isLoading:j}=A.useQuery({queryKey:["autocomplete",g],queryFn:async()=>{if(!g||g.length<2)return[];const b=await s.location.getPredictions({query:{query:g}});if(b.status!==200)throw new Error("Failed to fetch predictions");return Array.isArray(b.body)?b.body:(console.warn("API did not return an array:",b.body),[])},enabled:g.length>=2,refetchOnWindowFocus:!1}),f=b=>{u(b),c(b.text);const w={placeId:b.placeId,text:b.text,addressLineOne:b.addressLineOne,addressLineTwo:b.addressLineTwo};t(w),o(!1)};return h.useEffect(()=>{n&&p.current&&p.current.focus()},[n]),e.jsxs("div",{className:"mt-2 relative",children:[e.jsxs(Na,{open:n,onOpenChange:o,children:[e.jsx(Aa,{asChild:!0,children:e.jsxs(te,{id:i,role:"combobox","aria-expanded":n,variant:"secondary",className:"w-full shadow-2xs! bg-background px-2! py-1 min-h-[41.6px] font-normal outline-offset-0 hover:bg-background focus-visible:border-ring focus-visible:outline-[3px] focus-visible:outline-ring/20",onClick:()=>o(!n),children:[a?e.jsx("span",{className:"px-1 text-sm truncate mr-auto",children:a}):e.jsx("span",{className:"px-1 text-sm text-gray-400 mr-auto",children:r}),e.jsx(N.ChevronDown,{size:16,strokeWidth:2,className:"shrink-0 text-muted-foreground/80","aria-hidden":"true"})]})}),e.jsxs(Ca,{className:"w-full min-w-[var(--radix-popper-anchor-width)] border-input -mt-1 z-50 p-0",align:"start",children:[e.jsxs("div",{className:"flex items-center border-b px-3 py-2",children:[e.jsx(N.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx("input",{ref:p,placeholder:"Search places...",className:"flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",value:l,onChange:b=>{c(b.target.value),b.target.value.length>=2&&o(!0)}})]}),e.jsxs("div",{className:"max-h-[300px] overflow-y-auto",children:[j&&e.jsxs("div",{className:"py-6 text-center",children:[e.jsx(N.Loader2,{className:"h-4 w-4 animate-spin mx-auto"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"Searching places..."})]}),!j&&l.length<2&&e.jsx("p",{className:"py-6 text-center text-sm text-muted-foreground",children:"Type at least 2 characters to search"}),!j&&l.length>=2&&x.length===0&&e.jsx("p",{className:"py-6 text-center text-sm text-muted-foreground",children:"No places found"}),!j&&l.length>=2&&x.length>0&&e.jsxs("div",{className:"py-1",children:[e.jsxs("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:["Found ",x.length," results"]}),x.map((b,w)=>e.jsxs("div",{className:"relative flex cursor-pointer select-none items-center rounded-xs px-2 py-2 text-sm outline-hidden hover:bg-gray-100 dark:hover:bg-gray-800",onClick:()=>f(b),children:[e.jsxs("div",{className:"flex flex-col grow",children:[e.jsx("span",{children:b.addressLineOne||b.text}),b.addressLineTwo&&e.jsx("span",{className:"text-xs text-muted-foreground",children:b.addressLineTwo})]}),(m==null?void 0:m.placeId)===b.placeId&&e.jsx(N.Check,{size:16,strokeWidth:2,className:"ml-auto"})]},`${b.placeId||"place"}-${w}`))]})]})]})]}),y&&e.jsxs("p",{className:"text-xs text-red-500 mt-1",children:["Error fetching results: ",y.message]})]})},wi=h.forwardRef(({...a},t)=>e.jsx(De,{...a,inputClassName:"border-l-0 rounded-l-none",ref:t,className:""}));wi.displayName="PhoneInput";const Il=({disabled:a,value:t,onChange:r,options:s})=>{const i=n=>{r(n.target.value)};return e.jsxs("div",{className:"relative inline-flex items-center self-stretch rounded-s-lg border border-gray-200 dark:border-gray-800 bg-background py-2 pe-2 ps-3 text-muted-foreground transition-shadow focus-within:z-10 focus-within:border-ring focus-within:outline-hidden focus-within:ring-[3px] focus-within:ring-ring/20 hover:bg-accent hover:text-foreground has-disabled:pointer-events-none has-disabled:opacity-50",children:[e.jsxs("div",{className:"inline-flex items-center gap-1","aria-hidden":"true",children:[e.jsx(vi,{country:t,countryName:t,"aria-hidden":"true"}),e.jsx("span",{className:"text-muted-foreground/80",children:e.jsx(N.ChevronDown,{size:16,strokeWidth:2,"aria-hidden":"true"})})]}),e.jsxs("select",{disabled:a,value:t,onChange:i,className:"absolute inset-0 text-sm opacity-0","aria-label":"Select country",children:[e.jsx("option",{value:"",children:"Select a country"},"default"),s.filter(n=>n.value).map((n,o)=>e.jsxs("option",{value:n.value,children:[n.label," ",n.value&&`+${vt.getCountryCallingCode(n.value)}`]},n.value??`empty-${o}`))]})]})},vi=({country:a,countryName:t})=>{const r=vs[a];return e.jsx("span",{className:"w-5 overflow-hidden rounded-xs",children:r?e.jsx(r,{title:t}):e.jsx(N.Phone,{size:16,"aria-hidden":"true"})})},ki=({value:a,onChange:t,onBlur:r})=>{const s=h.useId();return e.jsx("div",{className:"mt-2",children:e.jsx(vt.default,{id:s,className:"flex rounded-lg shadow-2xs shadow-black/5",international:!0,flagComponent:vi,countrySelectComponent:Il,inputComponent:wi,placeholder:"Enter phone number",value:a,onChange:i=>t(i??""),onBlur:r})})},Ni=({options:a,value:t,onChange:r,multiple:s=!1,placeholder:i})=>{var u;const n=h.useId(),[o,l]=h.useState(!1),c=p=>{if(s){let g;Array.isArray(t)&&t.includes(p)?g=t.filter(x=>x!==p):g=Array.isArray(t)?[...t,p]:[p],r(g)}else r(p),l(!1)},m=p=>{if(s&&Array.isArray(t)){const g=t.filter(x=>x!==p);r(g)}};return e.jsx("div",{className:"mt-2",children:e.jsxs(Na,{open:o,onOpenChange:l,children:[e.jsx(Aa,{asChild:!0,children:e.jsxs(te,{id:n,role:"combobox","aria-expanded":o,variant:"secondary",className:"w-full justify-between shadow-2xs! bg-background px-2! py-1 min-h-[41.6px] font-normal outline-offset-0 hover:bg-background focus-visible:border-ring focus-visible:outline-[3px] focus-visible:outline-ring/20",children:[(t==null?void 0:t.length)>0?e.jsx("div",{className:"flex flex-wrap gap-2",children:Array.isArray(t)?t.map(p=>{const g=a.find(x=>x.value===p);return g?e.jsxs("span",{className:"animate-fadeIn relative inline-flex cursor-default items-center rounded-md border border-border bg-background px-2 py-1 text-xs font-medium text-secondary-foreground transition-all hover:bg-background disabled:cursor-not-allowed disabled:opacity-50",children:[g.label,e.jsx(N.X,{size:12,onClick:x=>{x.preventDefault(),m(p)},className:"cursor-pointer ml-1"})]},p):null}):e.jsx("span",{className:"px-1 text-sm",children:(u=a.find(p=>p.value===t))==null?void 0:u.label})}):e.jsx("span",{className:"px-1 text-sm text-gray-400",children:i||(s?"Select options":"Select an option")}),e.jsx(N.ChevronDown,{size:16,strokeWidth:2,className:"shrink-0 text-muted-foreground/80","aria-hidden":"true"})]})}),e.jsx(Ca,{className:"w-full min-w-[var(--radix-popper-anchor-width)] border-input -mt-1 z-50 p-0",align:"start",children:e.jsxs(Ua,{className:"p-0",children:[e.jsx(Ft,{className:"w-full border-none pl-0",style:{boxShadow:"none"},placeholder:"Search..."}),e.jsxs(Mt,{children:[e.jsx(Pt,{children:"No options found."}),e.jsx(Bt,{children:a.map(p=>e.jsxs(Tt,{value:p.label,className:"cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-800",onSelect:()=>c(p.value),children:[p.label,(s?t.includes(p.value):t===p.value)&&e.jsx(N.Check,{size:16,strokeWidth:2,className:"ml-auto"})]},p.value))})]})]})})]})})},El=Oe.tv({slots:{root:["group relative isolate inline-flex shrink-0 cursor-pointer items-center rounded-full p-0.5 shadow-inner outline-hidden ring-1 ring-inset transition-all","bg-gray-200 dark:bg-gray-950","ring-black/5 dark:ring-gray-800","data-[state=checked]:bg-blue-600 dark:data-[state=checked]:bg-blue-600","data-disabled:cursor-default","data-disabled:data-[state=checked]:bg-blue-200","data-disabled:data-[state=checked]:ring-gray-300","dark:data-disabled:data-[state=checked]:ring-gray-900","dark:data-disabled:data-[state=checked]:bg-blue-900","data-disabled:data-[state=unchecked]:ring-gray-300","data-disabled:data-[state=unchecked]:bg-gray-100","dark:data-disabled:data-[state=unchecked]:ring-gray-700","dark:data-disabled:data-[state=unchecked]:bg-gray-800",ka],thumb:["pointer-events-none relative inline-block transform appearance-none rounded-full border-none shadow-lg outline-hidden transition-all duration-150 ease-in-out focus:border-none focus:outline-hidden focus:outline-transparent","bg-white dark:bg-gray-50","group-data-disabled:shadow-none","group-data-disabled:bg-gray-50 dark:group-data-disabled:bg-gray-500"]},variants:{size:{default:{root:"h-7 w-14",thumb:"h-4 w-4 data-[state=checked]:translate-x-7 data-[state=unchecked]:translate-x-0"},small:{root:"h-4 w-7",thumb:"h-3 w-3 data-[state=checked]:translate-x-3 data-[state=unchecked]:translate-x-0"}}},defaultVariants:{size:"default"}}),mr=h.forwardRef(({className:a,size:t,...r},s)=>{const{root:i,thumb:n}=El({size:t});return e.jsx(lt.Root,{ref:s,className:v(i(),a),...r,children:e.jsx(lt.Thumb,{className:v(n())})})});mr.displayName="Switch";const Ai=h.forwardRef(({className:a,type:t,...r},s)=>e.jsx("input",{type:t,className:ua("flex h-10 w-full rounded-md border border-gray-200 bg-white px-3 py-2 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-hidden focus:ring-2 focus:ring-blue-500 focus:border-transparent disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-50 dark:placeholder:text-gray-500",a),ref:s,...r}));Ai.displayName="TextInput";function ur({className:a,...t}){const r=h.useId();return e.jsx(Ai,{id:r,placeholder:"00:00",className:v(a,"mt-2"),ref:Vn.withMask("99:99",{placeholder:"-",showMaskOnHover:!1}),...t})}const Re=z.forwardRef(({className:a,disabled:t,...r},s)=>e.jsx(ks.Root,{ref:s,className:ua("text-sm leading-none font-medium","text-gray-900 dark:text-gray-50",{"text-gray-400 dark:text-gray-600":t},a),"aria-disabled":t,...r}));Re.displayName="Label";const Dl=({value:a,onChange:t,disabled:r})=>{const s=()=>{const f=new Date,b=new Date(f);return b.setMinutes(f.getMinutes()+30),b},i=h.useMemo(()=>{const f=[],b=new Date;for(let w=0;w<7;w++){const k=new Date(b);k.setDate(b.getDate()+w),k.setHours(0,0,0,0),f.push(k)}return f},[]),n=f=>{const b=s();if(f.toDateString()!==new Date().toDateString())return!0;if(b.getHours()>=21&&b.getMinutes()>0)return!1;for(let w=11;w<=21;w++){const k=new Date(f);if(k.setHours(w,0,0,0),k>b)return!0}return!1},o=f=>!n(f),l=h.useMemo(()=>i.find(f=>!o(f))||null,[i]),[c,m]=h.useState(a||l),[u,p]=h.useState(a?`${a.getHours()}:${a.getMinutes()===0?"00":a.getMinutes()}`:null),g=h.useMemo(()=>{if(!c)return[];const f=[],b=s(),w=c.toDateString()===new Date().toDateString();for(let k=11;k<=21;k++){const C=new Date(c);C.setHours(k,0,0,0),(!w||C>b)&&f.push(`${k}:00`)}return f},[c]),x=f=>{const b=f.toLocaleDateString("en-US",{weekday:"short"}),w=f.toLocaleDateString("en-US",{month:"short"}),k=f.getDate();return{weekday:b,month:w,day:k}},y=f=>{m(f),p(null)},j=f=>{if(p(f),c){const[b]=f.split(":").map(Number),w=new Date(c);w.setHours(b,0,0,0),t(w)}};return h.useEffect(()=>{!c&&l&&m(l)},[]),e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"col-span-4 mt-4",children:[e.jsx(Re,{htmlFor:"date",children:"Select Date"}),e.jsx("div",{className:"grid grid-cols-7 gap-2 mt-2",children:i.map((f,b)=>{const{weekday:w,month:k,day:C}=x(f),F=o(f);return e.jsx("button",{type:"button",disabled:F,className:`p-2 text-center border rounded-md ${F?"opacity-50 cursor-not-allowed":"cursor-pointer"} ${c&&c.toDateString()===f.toDateString()?"storefront-primary-action":"bg-white hover:bg-gray-100"}`,onClick:()=>!F&&y(f),children:e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("span",{className:"text-xs font-medium",children:w}),e.jsx("span",{className:"text-xl font-black font-red-hat-display",children:C}),e.jsx("span",{className:"text-xs font-medium",children:k})]})},b)})})]}),c&&g.length>0&&e.jsxs("div",{className:"col-span-4 mt-4",children:[e.jsx(Re,{htmlFor:"time",children:"Select Time"}),e.jsx("div",{className:"grid grid-cols-5 gap-2 mt-2",children:g.map((f,b)=>e.jsx("button",{type:"button",className:`p-2 text-sm text-center border rounded-md font-medium cursor-pointer ${u===f?"storefront-primary-action":"bg-white hover:bg-gray-100"}`,onClick:()=>j(f),children:f},b))})]})]})},Ci=({name:a,type:t,placeholder:r,multiple:s,options:i,disabled:n,prefix:o})=>{const{watch:l,register:c,setValue:m}=Z.useFormContext(),u=["country","file","location","phone-number","select","switch","week-time"].includes(t);h.useEffect(()=>{u&&c(a)},[u,a,c]);const p=g=>m(a,g,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0});switch(t){case"email":return e.jsx(bi,{...c(a),placeholder:r});case"file":return e.jsx(ji,{value:l(a),multiple:s,onChange:g=>p(g)});case"week-time":return e.jsx(Dl,{value:l(a),onChange:g=>p(g)});case"phone-number":return e.jsx(ki,{value:l(a),onChange:g=>p(g)});case"country":return e.jsx(yi,{value:l(a),onChange:g=>p(g),disabled:n});case"select":{const g=s?l(a)||[]:l(a)||"";if(!i)throw new Error("Options are required for select input");return e.jsx(Ni,{options:i,value:g,onChange:x=>p(x),placeholder:r,multiple:s})}case"switch":return e.jsx(mr,{size:"default",className:"mt-2",value:l(a),onCheckedChange:g=>p(g)});case"location":return e.jsx(Qt,{value:l(a),onChange:g=>p(g.addressLineOne)});case"time":return e.jsx(ur,{value:l(a),...c(a)});default:return e.jsx(De,{...c(a),type:t,rows:t==="textarea"?4:void 0,placeholder:r,className:"mt-2",prefix:o})}},Si=(a,t)=>!a||typeof a!="object"?void 0:t?t.replace(/\[/g,".").replace(/\]/g,"").split(".").filter(Boolean).reduce((r,s)=>{if(r!=null)return r[s]},a):a,Ne=({type:a="text",name:t,label:r,className:s,locale:i,placeholder:n,multiple:o,options:l,localizable:c,prefix:m,disabled:u})=>{const{errors:p}=Z.useFormState(),g=Si(p,t);return e.jsxs("div",{className:v("w-full",s),children:[typeof r=="string"&&e.jsxs(Re,{htmlFor:t,className:"font-medium flex items-center justify-between",children:[e.jsxs("span",{className:"flex items-center",children:[r,c&&e.jsx(N.LanguagesIcon,{className:"w-4 h-4 ml-1 text-gray-500"})]}),i&&c&&e.jsxs("span",{className:"flex items-center text-xs text-gray-500 ml-1 bg-gray-100 px-1 py-0.5 rounded-sm",children:[At.get(i)," (",i,")"]})]}),e.jsx(Ci,{type:a,name:t,placeholder:n,options:l,multiple:o,prefix:m,disabled:u}),(g==null?void 0:g.message)&&e.jsx("p",{className:"mt-1 text-sm text-red-500",children:g.message})]})},zi=({isOpen:a,onClose:t,children:r})=>e.jsx(ya.Transition,{show:a,as:h.Fragment,children:e.jsx(ya.Dialog,{as:"div",className:"fixed inset-0 overflow-hidden",onClose:t,children:e.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[e.jsx(ya.TransitionChild,{as:h.Fragment,enter:"ease-in-out duration-500",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in-out duration-500",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:e.jsx("div",{className:"fixed inset-0 bg-black/75 z-20 transition-opacity"})}),e.jsx("div",{className:"fixed h-1/2 top-0 right-0 z-30 max-w-full flex",children:e.jsx(ya.TransitionChild,{as:h.Fragment,enter:"transform transition ease-in-out duration-500",enterFrom:"-translate-y-full",enterTo:"translate-y-0",leave:"transform transition ease-in-out duration-500",leaveFrom:"translate-y-0",leaveTo:"-translate-y-full",children:e.jsx(ya.DialogPanel,{className:"relative w-screen h-full",children:e.jsx("div",{className:"max-h-screen bg-gray-900 flex flex-col py-6 shadow-xl overflow-y-scroll",children:r})})})})]})})}),Rl=v("hidden h-6 select-none items-center justify-center rounded-md bg-gray-800 px-2 font-mono text-xs text-gray-400 ring-1 ring-inset ring-gray-700 transition sm:flex"),Ii=({open:a=!1,onOpenChange:t,defaultOpen:r=!1,disableAutoFocus:s=!0,children:i})=>e.jsxs(se.Root,{open:a,onOpenChange:t,defaultOpen:r,children:[e.jsx(se.Anchor,{className:v("fixed inset-x-0 bottom-8 mx-auto flex w-fit items-center")}),e.jsx(se.Portal,{children:e.jsx(se.Content,{side:"top",sideOffset:0,onOpenAutoFocus:n=>{s&&n.preventDefault()},className:v("z-50","data-[state=closed]:animate-hide","data-[side=top]:animate-slideUpAndFade"),children:i})})]});Ii.displayName="CommandBar";const Ei=z.forwardRef(({className:a,...t},r)=>e.jsx("div",{ref:r,className:v("px-3 py-2.5 text-sm tabular-nums text-gray-300",a),...t}));Ei.displayName="CommandBar.Value";const Di=z.forwardRef(({className:a,...t},r)=>e.jsx("div",{ref:r,className:v("relative flex items-center rounded-lg bg-gray-900 px-1 shadow-lg shadow-black/30 dark:ring-1 dark:ring-white/10",a),...t}));Di.displayName="CommandBarBar";const Ri=z.forwardRef(({className:a,...t},r)=>e.jsx("div",{ref:r,className:v("h-4 w-px bg-gray-700",a),...t}));Ri.displayName="CommandBar.Seperator";const Fi=z.forwardRef(({className:a,type:t="button",label:r,action:s,shortcut:i,disabled:n,...o},l)=>(z.useEffect(()=>{const c=m=>{m.key===i.shortcut&&(m.preventDefault(),m.stopPropagation(),s())};return n||document.addEventListener("keydown",c),()=>{document.removeEventListener("keydown",c)}},[s,i,n]),e.jsx("span",{className:v("flex items-center gap-x-2 rounded-lg bg-gray-900 p-1 text-base font-medium text-gray-50 outline-hidden transition focus:z-10 sm:text-sm","sm:last-of-type:-mr-1",a),children:e.jsxs("button",{ref:l,type:t,onClick:s,disabled:n,className:v("flex items-center gap-x-2 rounded-md px-1 py-1 hover:bg-gray-800","focus-visible:bg-gray-800 focus-visible:hover:bg-gray-800","disabled:text-gray-500",ka),...o,children:[e.jsx("span",{children:r}),e.jsx("span",{className:Rl,children:i.label?i.label.toUpperCase():i.shortcut.toUpperCase()})]})})));Fi.displayName="CommandBar.Command";const mt=z.forwardRef(({className:a,...t},r)=>e.jsx(tr.Root,{ref:r,className:ua("grid gap-2",a),...t}));mt.displayName="RadioCardGroup";const ut=z.forwardRef(({className:a,...t},r)=>e.jsx("div",{className:ua("relative flex size-4 shrink-0 appearance-none items-center justify-center rounded-full border shadow-2xs outline-hidden","border-gray-300 dark:border-gray-800","bg-white dark:bg-gray-950","group-data-[state=checked]:border-0 group-data-[state=checked]:border-transparent group-data-[state=checked]:bg-blue-600","group-data-disabled:border","group-data-disabled:border-gray-300 group-data-disabled:bg-gray-100 group-data-disabled:text-gray-400","dark:group-data-disabled:border-gray-700 dark:group-data-disabled:bg-gray-800",ka,a),children:e.jsx(tr.Indicator,{ref:r,className:"flex items-center justify-center",...t,children:e.jsx("div",{className:ua("size size-1.5 shrink-0 rounded-full","bg-white","group-data-disabled:bg-gray-400 dark:group-data-disabled:bg-gray-500")})})}));ut.displayName="RadioCardGroupIndicator";const pt=z.forwardRef(({className:a,children:t,...r},s)=>e.jsx(tr.Item,{ref:s,className:ua("group relative w-full rounded-lg border p-4 text-left shadow-2xs transition-all focus:outline-hidden","bg-white dark:bg-gray-950","border-gray-200 dark:border-gray-800","data-[state=checked]:border-blue-600 dark:data-[state=checked]:border-blue-600",ii,a),...r,children:t}));pt.displayName="RadioCardItem";const Mi=Oe.tv({base:v("inline-flex items-center gap-x-1 whitespace-nowrap rounded-sm px-1.5 py-0.5 text-xs font-semibold ring-1"),variants:{variant:{default:["bg-blue-50 text-blue-800 ring-blue-500/30","dark:bg-blue-400/10 dark:text-blue-400 dark:ring-blue-400/30"],neutral:["bg-gray-50 text-gray-700 ring-gray-500/30","dark:bg-gray-400/10 dark:text-gray-300 dark:ring-gray-400/20"],success:["bg-emerald-50 text-emerald-800 ring-emerald-600/30","dark:bg-emerald-400/10 dark:text-emerald-400 dark:ring-emerald-400/20"],error:["bg-red-50 text-red-800 ring-red-600/20","dark:bg-red-400/10 dark:text-red-400 dark:ring-red-400/20"],warning:["bg-yellow-50 text-yellow-800 ring-yellow-600/30","dark:bg-yellow-400/10 dark:text-yellow-500 dark:ring-yellow-400/20"]}},defaultVariants:{variant:"default"}}),pr=h.forwardRef(({className:a,variant:t,...r},s)=>e.jsx("span",{ref:s,className:v(Mi({variant:t}),a),...r}));pr.displayName="Badge";const ja=h.forwardRef(({className:a,children:t,...r},s)=>e.jsx("div",{ref:s,className:v("mx-auto my-6 flex w-full items-center justify-between gap-3 text-sm col-span-full","text-gray-500 dark:text-gray-500",a),...r,children:t?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:v("h-[1px] w-full","bg-gray-200 dark:bg-gray-800")}),e.jsx("div",{className:"whitespace-nowrap text-inherit",children:t}),e.jsx("div",{className:v("h-[1px] w-full","bg-gray-200 dark:bg-gray-800")})]}):e.jsx("div",{className:v("h-[0.5px] w-full","bg-gray-200 dark:bg-gray-800")})}));ja.displayName="Divider";const Fl=({initialData:a,shippingAndPaymentPageUrl:t})=>{const{itemCount:r}=kt(),s=D.useRouter(),{client:i}=P(),n=Z.useForm({resolver:be.zodResolver(Ys),reValidateMode:"onChange",defaultValues:a?{firstname:a.firstname,lastname:a.lastname,phone:a.phone,addressLineOne:a.addressLineOne,placeId:a.placeId,doorNumber:a.doorNumber,zipCode:a.zipCode,city:a.city,country:a.country,deliveryInstructions:a.deliveryInstructions}:void 0}),o=n.watch("placeId"),l=n.watch("addressLineOne");h.useEffect(()=>{(async()=>{if(o){const{status:p,body:g}=await i.location.getPlaceDetails({params:{placeId:o}});if(p!==200)throw new Error("Failed to fetch place details");n.setValue("zipCode",g.zipCode,{shouldValidate:!0,shouldDirty:!0}),n.setValue("city",g.city,{shouldValidate:!0,shouldDirty:!0}),n.setValue("country",g.country,{shouldValidate:!0,shouldDirty:!0})}})()},[n,o]);const c=A.useMutation({mutationFn:async p=>{const{status:g,body:x}=await i.shipping.createShippingAddress({body:p});if(g!==201)throw new Error("Failed to create shipping address");return x},onSuccess:()=>{s.push(t)}}),m=A.useMutation({mutationFn:async p=>{const{status:g,body:x}=await i.shipping.updateShippingAddress({body:p});if(g!==200)throw new Error("Failed to update shipping address");return x},onSuccess:()=>s.push(t)}),u=p=>{(a?m:c).mutate(p)};return e.jsx("div",{className:"flex flex-col gap-4",children:e.jsx(Z.FormProvider,{...n,children:e.jsxs("form",{onSubmit:n.handleSubmit(u),children:[e.jsxs("div",{className:"grid grid-cols-4 gap-x-4 gap-y-4 mt-3",children:[e.jsx(Ne,{name:"firstname",label:"First Name",type:"text",className:"col-span-2",placeholder:"e.g. John"}),e.jsx(Ne,{name:"lastname",label:"Last Name",type:"text",className:"col-span-2",placeholder:"e.g. Doe"}),e.jsx(Ne,{name:"phone",label:"Phone",type:"phone-number",className:"col-span-4",placeholder:"e.g. +48 123 456 789"}),e.jsxs("div",{className:"col-span-4 md:col-span-3 text-sm text-gray-500",children:[e.jsx(Re,{htmlFor:"address.addressLineOne",className:"font-medium flex items-center justify-between",children:"Street Address"}),e.jsx(Qt,{onChange:p=>{n.setValue("addressLineOne",p.addressLineOne,{shouldValidate:!0,shouldDirty:!0}),n.setValue("placeId",p.placeId,{shouldValidate:!0,shouldDirty:!0})},value:l}),n.formState.errors.addressLineOne&&e.jsx("p",{className:"mt-1 text-sm text-red-500",children:String(n.formState.errors.addressLineOne.message??"")})]}),e.jsx(Ne,{name:"doorNumber",label:"Door Number",type:"text",className:"md:col-span-1 col-span-2",placeholder:"e.g. 123"}),e.jsx(Ne,{name:"zipCode",label:"Postal Code",type:"text",className:"col-span-2",placeholder:"e.g. 12345"}),e.jsx(Ne,{name:"city",label:"City",type:"text",className:"col-span-2",placeholder:"e.g. Kraków"}),e.jsx(Ne,{name:"country",label:"Country",type:"country",className:"col-span-2 md:col-span-4",disabled:!0}),e.jsx(Ne,{name:"deliveryInstructions",label:"Notes / Instructions",type:"textarea",className:"col-span-4",placeholder:"e.g. 4th floor, code 12345"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-2 w-full mt-8",children:[e.jsx(te,{variant:"secondary",className:"shadow-none",type:"button",onClick:()=>s.push("/"),children:"Back"}),e.jsx(te,{type:"submit",className:"shadow-none",isLoading:c.isPending||m.isPending,disabled:r===0,loadingText:"Saving...",children:"Save & Continue"})]})]})})})},Ml=()=>e.jsxs("div",{className:"animate-pulse space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[e.jsx("div",{className:"h-[40px] bg-gray-100 rounded-sm col-span-2"}),e.jsx("div",{className:"h-[40px] bg-gray-100 rounded-sm col-span-2"})]}),e.jsx("div",{className:"h-[70px] bg-gray-100 rounded-sm"}),e.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[e.jsx("div",{className:"h-[40px] bg-gray-100 rounded-sm col-span-3"}),e.jsx("div",{className:"h-[40px] bg-gray-100 rounded-sm col-span-1"})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[e.jsx("div",{className:"h-[40px] bg-gray-100 rounded-sm col-span-2"}),e.jsx("div",{className:"h-[40px] bg-gray-100 rounded-sm col-span-2"})]}),e.jsx("div",{className:"h-[40px] bg-gray-100 rounded-sm"}),e.jsx("div",{className:"h-[100px] bg-gray-100 rounded-sm"}),e.jsx("div",{className:"h-[40px] bg-gray-100 rounded-sm mt-8"})]}),Xt=({shippingAndPaymentPageUrl:a="/checkout/shipping-and-payment"})=>{const t=D.useRouter(),{client:r}=P(),{data:s,isLoading:i,error:n}=A.useQuery({queryKey:["shippingAddress"],queryFn:async()=>{const{status:l,body:c}=await r.shipping.getShippingAddress();if(l!==200)throw new Error("Failed to fetch shipping address");return c}}),o=()=>{t.push(a)};return i?e.jsx(Ml,{}):n?e.jsxs("div",{className:"p-4 rounded-lg bg-red-50 text-red-700",children:[e.jsx("p",{className:"font-semibold",children:"Failed to load shipping address"}),e.jsx("p",{className:"text-xs",children:"Please try refreshing the page or contact support if the issue persists."})]}):e.jsxs("div",{className:"flex flex-col gap-4 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col gap-y-1",children:[e.jsx("h1",{className:"text-[32px] font-red-hat-display font-black dark:text-blue-500",children:"Shipping Details"}),e.jsx("p",{className:"text-gray-500",children:"Please fill in the your shipping details to continue."})]}),e.jsx(Fl,{initialData:s??null,onSuccess:o,shippingAndPaymentPageUrl:a},s==null?void 0:s.id)]})},Pl=()=>e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"animate-pulse space-y-4",children:e.jsx("div",{className:"space-y-2",children:[1,2,3].map(a=>e.jsxs("div",{className:"flex items-center gap-3 p-4 border rounded-lg",children:[e.jsx("div",{className:"h-4 w-4 bg-gray-100 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-5 w-32 bg-gray-100 rounded-sm"}),e.jsx("div",{className:"h-4 w-24 bg-gray-100 rounded-sm"})]})]},a))})}),e.jsx("div",{className:"animate-pulse space-y-4 mt-8",children:e.jsx("div",{className:"space-y-2",children:[1,2].map(a=>e.jsxs("div",{className:"flex items-center gap-3 p-4 border rounded-lg",children:[e.jsx("div",{className:"h-4 w-4 bg-gray-100 rounded-full"}),e.jsx("div",{className:"h-5 w-24 bg-gray-100 rounded-sm"})]},a))})}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-2 w-full mt-4",children:[e.jsx("div",{className:"h-10 bg-gray-100 rounded-sm"}),e.jsx("div",{className:"h-10 bg-gray-100 rounded-sm"})]})]}),Bl=({shippingMethods:a,paymentMethods:t,customerDetailsPageUrl:r})=>{const s=D.useRouter(),{client:i,baseUrl:n}=P(),{organizationId:o}=ve(),{items:l,shippingMethod:c,paymentMethod:m,setPaymentMethod:u,setShippingMethod:p,replaceItems:g}=kt(),x=A.useMutation({mutationFn:async()=>{if(!c)throw new Error("Please select a shipping method");if(!m)throw new Error("Please select a payment method");const{body:j,status:f}=await i.order.createOrder({params:{organizationId:o},body:{items:l,shippingMethodId:c==null?void 0:c.id,fulfilmentMethod:"delivery",payment:{provider:m.provider,method:m.method},checkoutBaseUrl:n}});if(f===409){const b=j;throw b.normalizedItems&&g(b.normalizedItems),new Error(b.message??"Some items changed availability before payment started.")}if(f!==201)throw new Error((j==null?void 0:j.message)??"Failed to create order");return j.redirectUrl&&(window.location.href=j.redirectUrl),j}}),y=()=>{x.mutate()};return h.useEffect(()=>{a.length===1&&p(a[0])},[p,a]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("h2",{className:"text-[32px] font-red-hat-display font-black",children:"Shipping Method"}),e.jsx("p",{className:"text-gray-500",children:"Select a shipping method"})]}),e.jsx(mt,{className:"flex flex-col gap-2",value:c==null?void 0:c.id,children:a.map(j=>e.jsx(pt,{value:j.id,disabled:!j.eligibleShippingZone,onClick:()=>p(j),children:e.jsxs("div",{className:v("flex items-center gap-3",{"opacity-60 cursor-not-allowed":!j.eligibleShippingZone}),children:[e.jsx(ut,{}),e.jsx("div",{children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center",children:[e.jsxs("span",{className:"leading-5 font-red-hat-display font-black mr-2",children:[j.title," (",j.providerName,")"]}),!j.eligibleShippingZone&&e.jsx(pr,{variant:"error",children:"Not Available"})]}),j.eligibleShippingZone&&e.jsxs("p",{className:"text-xs font-medium text-gray-500 mt-0.5",children:["Shipping Fee: ",j.eligibleShippingZone.price," zł ",e.jsx("br",{}),"ETA: ",j.eligibleShippingZone.eta]}),!j.eligibleShippingZone&&e.jsxs("p",{className:"mt-0.5 text-xs text-gray-500",children:["Sorry, this address is too far for delivery ",e.jsx("br",{})," from our store."]})]})})]})},j.id))}),e.jsxs("div",{className:"flex flex-col gap-1 mt-3",children:[e.jsx("h2",{className:"text-[32px] font-red-hat-display font-black",children:"Payment Method"}),e.jsx("p",{className:"text-gray-500",children:"Select a payment method"})]}),e.jsx(mt,{className:"flex flex-col gap-3",value:m==null?void 0:m.id,children:t.map(j=>e.jsx(pt,{value:j.id,onClick:()=>u(j),children:e.jsxs("div",{className:v("flex items-center gap-3"),children:[e.jsx(ut,{}),e.jsxs("div",{children:[e.jsx("p",{className:"font-red-hat-display font-black mr-2 capitalize",children:j.method}),e.jsxs("p",{className:"text-xs font-medium text-gray-500 capitalize",children:[j.provider," • ",j.description]})]})]})},j.id))}),x.error&&e.jsx("div",{className:"p-4 mt-2 rounded-lg bg-red-50 text-red-700",children:e.jsx("p",{className:"text-sm",children:x.error.message})}),e.jsx("div",{children:e.jsxs("p",{className:"text-sm text-gray-500 mt-2 block",children:["By confirming this order you agree to our"," ",e.jsx(B,{href:"/terms-and-conditions",className:"storefront-primary-text storefront-primary-text-hover mr-1",children:"Terms & Conditions"}),"and"," ",e.jsx(B,{href:"/privacy-policy",className:"storefront-primary-text storefront-primary-text-hover mr-1",children:"Privacy Policy"})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-2 w-full mt-3",children:[e.jsx(te,{variant:"secondary",className:"shadow-none",onClick:()=>s.push(r),children:"Back"}),e.jsx(te,{className:"shadow-none",onClick:y,isLoading:x.isPending,children:"Pay & Confirm"})]})]})},Pi=({customerDetailsPageUrl:a="/checkout/customer-details"})=>{const{client:t}=P(),{organizationId:r}=ve(),s=D.useRouter(),i=A.useQuery({queryKey:["shippingAddress"],queryFn:async()=>{const{status:c,body:m}=await t.shipping.getShippingAddress();if(c!==200)throw new Error("Failed to fetch shipping address");return m||s.push(a),m}}),n=A.useQuery({queryKey:["shipping-and-payment-eligibility"],queryFn:async()=>{const{body:c,status:m}=await t.shippingMethod.accessEligibility({params:{organizationId:r}});if(m!==200)throw new Error("Failed to fetch shipping methods");return c}}),o=A.useQuery({queryKey:["payment-methods"],queryFn:async()=>{const{body:c,status:m}=await t.payment.getAvailablePaymentMethods({params:{organizationId:r}});if(m!==200)throw new Error((c==null?void 0:c.message)??"Failed to fetch payment methods");if(!(c!=null&&c.length))throw new Error("No payment methods are configured for this organization");return c}}),l=n.error||i.error||o.error;if(l){const c=l instanceof Error?l.message:"Please try refreshing the page or contact support if the issue persists.";return e.jsxs("div",{className:"p-4 rounded-lg bg-red-50 text-red-700",children:[e.jsx("p",{className:"font-semibold",children:"Unable to load checkout options"}),e.jsx("p",{className:"text-xs",children:c})]})}return n.isLoading||i.isLoading||o.isLoading?e.jsx(Pl,{}):e.jsx("div",{className:"flex flex-col gap-3 animate-fade-in",children:e.jsx(Bl,{shippingMethods:n.data??[],paymentMethods:o.data??[],customerDetailsPageUrl:a})})},Tl=a=>fs.createAuthClient({baseURL:a,plugins:[ot.inferAdditionalFields(),ot.organizationClient()]}),Bi=h.createContext(void 0),Ql=({children:a,baseURL:t})=>{const r=h.useMemo(()=>Tl(t),[t]);return e.jsx(Bi.Provider,{value:r,children:a})},Le=()=>{const a=h.useContext(Bi);if(a===void 0)throw new Error("useAuth must be used within a AuthProvider");return a},Ol=()=>e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"animate-pulse",children:[1,2].map(a=>e.jsxs("div",{className:"flex items-center w-full mb-5 sm:mb-7",children:[e.jsx("div",{className:"w-14 sm:w-32 h-10 sm:h-24 overflow-hidden rounded-lg bg-white/10"}),e.jsxs("div",{className:"pl-3 md:pl-5 flex-1",children:[e.jsx("div",{className:"h-4 bg-white/10 rounded-sm w-3/4 mb-2"}),e.jsx("div",{className:"h-3 bg-white/10 rounded-sm w-1/2 mb-2"}),e.jsx("div",{className:"text-white text-xs opacity-50 whitespace-nowrap sm:block hidden",children:e.jsx("div",{className:"h-3 bg-white/10 rounded-sm w-24 mb-2"})}),e.jsx("div",{className:"text-white text-sm font-semibold whitespace-nowrap mt-2 sm:block hidden",children:e.jsx("div",{className:"h-4 bg-white/10 rounded-sm w-16"})})]}),e.jsxs("div",{className:"ml-auto pl-4 text-right sm:hidden",children:[e.jsx("div",{className:"h-4 bg-white/10 rounded-sm w-16 mb-2"}),e.jsx("div",{className:"h-3 bg-white/10 rounded-sm w-20"})]})]},a))}),e.jsx("hr",{className:" md:flex opacity-10 my-4 sm:my-4"}),e.jsxs("div",{className:"mt-3 flex items-center",children:[e.jsx("div",{className:"h-4 w-20 bg-white/10 rounded-sm animate-pulse"}),e.jsx("div",{className:"h-4 w-16 bg-white/10 rounded-sm animate-pulse ml-auto"})]}),e.jsxs("div",{className:"mt-3 flex items-center",children:[e.jsx("div",{className:"h-4 w-20 bg-white/10 rounded-sm animate-pulse"}),e.jsx("div",{className:"h-4 w-16 bg-white/10 rounded-sm animate-pulse ml-auto"})]}),e.jsx("hr",{className:" md:flex opacity-10 my-4 sm:my-4"}),e.jsxs("div",{className:"mt-4 flex justify-between",children:[e.jsx("div",{className:"h-5 w-16 bg-white/10 rounded-sm animate-pulse"}),e.jsx("div",{className:"h-5 w-24 bg-white/10 rounded-sm animate-pulse"})]})]}),gr=({loading:a=!1,items:t,total:r,subtotal:s,shipping:i,discount:n,currency:o})=>a?e.jsx(Ol,{}):t.length===0?e.jsx("div",{className:"px-7 pt-10 pb-0 md:pt-0 md:px-0",children:e.jsx("div",{className:"my-3 sm:my-6 sm:pb-1",children:e.jsxs("div",{className:"text-center py-6",children:[e.jsx("p",{className:"text-white font-red-hat-display text-xl font-black mb-4",children:"Your shopping cart is empty. Add some products to get started."}),e.jsx(B,{href:"/",className:"text-white hover:text-white/80 underline text-sm",children:"View products"})]})})}):e.jsxs("div",{className:"px-7 pt-10 pb-0 md:pt-0 md:px-0",children:[e.jsx("div",{className:"my-3 sm:my-6 sm:pb-1",children:t.map(({title:l,subtitle:c,image:m,price:u,unitPrice:p,quantity:g},x)=>e.jsx("div",{children:e.jsxs("div",{className:"flex items-center w-full mb-5 sm:mb-7",children:[e.jsx("div",{className:"w-14 sm:min-w-32 h-10 sm:h-24 overflow-hidden rounded-lg",children:m!=null&&m.url?e.jsx(ze,{width:100,height:100,src:m.url,alt:"",className:"w-full h-full object-cover"}):e.jsx("div",{className:"bg-slate-100 w-full h-full flex items-center justify-center",children:e.jsx("span",{className:"text-slate-400 text-xs",children:"No image"})})}),e.jsxs("div",{className:"pl-3 md:pl-5",children:[e.jsx("div",{className:"flex font-red-hat-display h4 text-white text-sm items-center",children:l}),c&&c.map((y,j)=>e.jsx("div",{className:"text-white text-xs opacity-50",children:y},j)),e.jsxs("div",{className:"text-white text-xs opacity-50 whitespace-nowrap sm:block hidden",children:["Price: ",p," | Quantity: x ",g]}),e.jsx("div",{className:"font-red-hat-display h4 text-white text-sm whitespace-nowrap mt-2 sm:block hidden",children:u})]}),e.jsxs("div",{className:"ml-auto pl-4 text-right sm:hidden",children:[e.jsx("div",{className:"font-red-hat-display h4 text-white text-sm whitespace-nowrap",children:u}),e.jsxs("div",{className:"text-white text-xs opacity-50 whitespace-nowrap",children:["Quantity: ",g]})]})]})},x))}),e.jsx("hr",{className:" md:flex opacity-10 my-4 sm:my-4"}),typeof i=="number"&&e.jsxs("div",{className:"mt-3 flex items-center",children:[e.jsx("h2",{className:"text-xs xl:text-sm text-white opacity-40 font-red-hat-display",children:"Shipping"}),e.jsx("h3",{className:"text-xs xl:text-sm text-white opacity-40 ml-auto font-red-hat-display",children:we(i,o)})]}),e.jsxs("div",{className:"mt-3 flex items-center",children:[e.jsx("h2",{className:"text-xs xl:text-sm text-white opacity-40 font-red-hat-display",children:"Subtotal"}),e.jsx("h3",{className:"text-xs xl:text-sm text-white opacity-40 ml-auto font-red-hat-display",children:we(s,o)})]}),n?e.jsxs("div",{className:"mt-3 flex items-center",children:[e.jsx("h2",{className:"text-xs xl:text-sm text-white opacity-40",children:"Discount"}),e.jsxs("h3",{className:"text-xs xl:text-sm text-white opacity-40 ml-auto",children:["- ",we(s,o)]})]}):null,e.jsx("hr",{className:" md:flex opacity-10 my-4 sm:my-4"}),e.jsxs("div",{className:"mt-4 flex justify-between",children:[e.jsx("h2",{className:"text-sm xl:text-lg text-white font-black font-red-hat-display",children:"Total"}),e.jsx("h3",{className:"xl:text-lg text-white font-black font-red-hat-display",children:we(r,o)})]})]}),Ll=()=>e.jsxs("header",{className:"fixed flex justify-between px-2 md:px-6 py-4 md:py-12 z-50 bg-gray-900 md:bg-transparent w-full",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("span",{children:e.jsx(N.ChevronLeft,{className:"w-5 h-5 text-white"})}),e.jsx("div",{className:"ml-1.5 w-7 xl:w-8 h-7 xl:h-8 bg-gray-300 animate-pulse rounded-full"}),e.jsx("div",{className:"ml-2 bg-gray-300 animate-pulse h-5 xl:h-6 w-24 xl:w-28 rounded"})]}),e.jsxs("div",{className:"flex items-center",children:[e.jsxs("div",{className:"mr-6 flex items-center",children:[e.jsx("div",{className:"w-8 h-8 bg-gray-300 animate-pulse rounded-full mr-2"}),e.jsx("div",{className:"bg-gray-300 animate-pulse h-4 w-16 rounded"})]}),e.jsxs("div",{className:"flex md:hidden items-center",children:[e.jsx("div",{className:"bg-gray-300 animate-pulse h-3 w-12 rounded mr-1.5"}),e.jsx(N.ShoppingBasketIcon,{className:"w-5 h-5 text-gray-300"})]})]})]}),Jl=()=>{const a=D.useRouter(),{useSession:t,signOut:r}=Le(),{data:s}=t(),i=()=>{var l;if(!((l=s==null?void 0:s.user)!=null&&l.name))return"";const o=s.user.name.split(" ");return o.length===1?o[0].charAt(0):`${o[0].charAt(0)}${o[o.length-1].charAt(0)}`},n=async()=>{await r(),a.push("/account/sign-in")};return e.jsx("div",{className:"hidden md:block",children:e.jsxs(Na,{children:[e.jsx(Aa,{className:"flex items-center focus:outline-hidden group",children:s!=null&&s.user?e.jsx("div",{className:"w-8 h-8 rounded-full overflow-hidden flex items-center justify-center bg-blue-500 text-white relative transition-transform duration-200 group-hover:scale-110 group-hover:ring-2 group-hover:ring-white/50 group-hover:ring-offset-1 group-hover:cursor-pointer",children:s.user.image?e.jsx("img",{src:s.user.image,alt:s.user.name||"User",className:"w-full h-full object-cover"}):e.jsx("span",{className:"font-medium text-sm",children:i()})}):e.jsxs("div",{className:"flex items-center text-white group-hover:text-blue-300 transition-colors duration-200",children:[e.jsx(N.UserIcon,{className:"w-5 h-5 mr-1 group-hover:scale-110 transition-transform duration-200"}),e.jsx("span",{children:"Guest"})]})}),e.jsx(Ca,{className:"w-52 min-w-52 p-0 py-1 data-[state=open]:animate-slideDownAndFade z-50",align:"end",sideOffset:5,forceMount:!0,children:s!=null&&s.user?e.jsxs(e.Fragment,{children:[e.jsxs(B,{href:"/account",className:"flex items-center gap-2 px-4 py-2 text-sm font-medium text-gray-700 transition hover:bg-gray-100",children:[e.jsx(N.LayoutDashboardIcon,{className:"h-4 w-4"}),"My account"]}),e.jsxs(B,{href:"/account/orders",className:"flex items-center gap-2 px-4 py-2 text-sm font-medium text-gray-700 transition hover:bg-gray-100",children:[e.jsx(N.ShoppingBagIcon,{className:"h-4 w-4"}),"Orders"]}),e.jsxs(B,{href:"/account/reservations",className:"flex items-center gap-2 px-4 py-2 text-sm font-medium text-gray-700 transition hover:bg-gray-100",children:[e.jsx(N.CalendarDaysIcon,{className:"h-4 w-4"}),"Reservations"]}),e.jsxs("button",{onClick:n,className:"flex w-full items-center gap-2 px-4 py-2 text-sm font-medium text-gray-700 transition hover:bg-gray-100",children:[e.jsx(N.LogOutIcon,{className:"h-4 w-4"}),"Logout"]})]}):e.jsxs(B,{href:"/account/sign-in",className:"flex items-center gap-2 px-4 py-2 text-sm font-medium text-gray-700 transition hover:bg-gray-100",children:[e.jsx(N.UserIcon,{className:"h-4 w-4"}),"Sign in"]})})]})})},Za=({summary:a})=>{const{organization:t,loading:r}=ve(),[s,i]=h.useState(!1);if(r)return e.jsx(Ll,{});const n=(t==null?void 0:t.name)??"",o=t==null?void 0:t.logoFile,l=(t==null?void 0:t.configuration.defaultCurrency)??"USD";return e.jsxs(e.Fragment,{children:[e.jsxs("header",{className:"fixed flex justify-between px-2 md:px-6 py-4 md:py-12 z-50 bg-gray-900 md:bg-transparent w-full",children:[e.jsxs(B,{href:"/",className:"flex items-center",children:[e.jsx("span",{children:e.jsx(N.ChevronLeft,{className:"w-5 h-5 text-white"})}),o?e.jsx("span",{className:"ml-1.5 w-7 xl:w-8 h-7 xl:h-8 overflow-hidden rounded-full",children:e.jsx(ze,{src:o.url,alt:n,className:"w-full h-full",width:32,height:32})}):e.jsx("div",{className:"flex items-center justify-center w-8 h-8 bg-blue-500 rounded-full text-white text-sm uppercase font-semibold",children:e.jsx("span",{children:n.slice(0,2)})}),n?e.jsx("span",{className:"xl:text-lg font-black text-white ml-2 font-red-hat-display",children:n}):null]}),e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"mr-6",children:e.jsx(Jl,{})}),a&&e.jsx("div",{className:"flex md:hidden",children:s?e.jsx("button",{className:"flex items-center text-white mr-2 animate-fade",onClick:()=>i(!1),children:e.jsx(N.XIcon,{className:"w-5 h-5"})},1):e.jsxs("button",{className:"flex items-center text-white mr-2 animate-fade",onClick:()=>i(!0),children:[e.jsx("span",{className:"text-xs text-white font-semibold mr-1.5",children:we(a.total,l)}),e.jsx(N.ShoppingBasketIcon,{className:"w-5 h-5"})]},2)})]})]}),a&&e.jsx(zi,{isOpen:s,onClose:()=>i(!1),children:e.jsx(gr,{total:a.total,items:a.items,shipping:a.shipping,subtotal:a.subtotal,currency:l})})]})},Ti=({children:a,description:t,title:r})=>{const s=r||t;return e.jsxs(e.Fragment,{children:[e.jsx(Za,{}),e.jsx("div",{children:e.jsxs("div",{className:"flex flex-col md:flex-row h-screen w-screen relative",children:[e.jsx("div",{className:"hidden md:flex items-center justify-end w-full md:w-1/2 h-full px-16 xl:px-24 relative",children:e.jsx("div",{className:"absolute inset-0 z-0",children:e.jsx(ze,{src:"/images/15750.jpg",alt:"Authentication background",fill:!0,className:"object-cover brightness-50",priority:!0})})}),e.jsx("div",{className:"flex flex-col items-start 2xl:items-start w-full md:w-1/2 h-full px-6 sm:px-12 xl:px-24 py-8 md:overflow-y-auto relative",children:e.jsxs("div",{className:"py-10 xl:py-24 md:my-auto animate-fade w-full md:max-w-[432px]",children:[s&&e.jsxs("div",{className:"mb-4 flex flex-col gap-y-1",children:[r&&e.jsx("h1",{className:"text-[32px] font-red-hat-display font-black",children:r}),t&&e.jsx("p",{className:"text-gray-500",children:t})]}),a]})})]})})]})},Xr=({children:a})=>{const{useSession:t}=Le(),r=D.useRouter(),{data:s,isPending:i}=t();return h.useEffect(()=>{if(!i&&s)return r.push("/checkout/customer-details")},[s,i,r]),i?e.jsx("div",{className:"flex flex-col items-center justify-center h-screen w-screen bg-gray-900",children:e.jsx("div",{className:"mb-4",children:e.jsx("div",{className:"storefront-primary-border animate-spin rounded-full h-18 w-18 border-b-2"})})}):e.jsx(Ti,{children:a})},da=({children:a})=>{const{useSession:t}=Le(),r=D.useRouter(),{data:s,isPending:i}=t();return h.useEffect(()=>{if(!i&&!s)return r.push("/account/sign-in")},[s,i,r]),i?e.jsx("div",{className:"flex flex-col items-center justify-center h-screen w-screen bg-gray-900",children:e.jsx("div",{className:"mb-4"})}):a},Vl={danger:"border-red-200 bg-red-50 text-red-700",info:"border-sky-200 bg-sky-50 text-sky-700",neutral:"border-stone-200 bg-stone-100 text-stone-700",success:"border-emerald-200 bg-emerald-50 text-emerald-700",warning:"border-amber-200 bg-amber-50 text-amber-700"},Ye=(a,t="Not available",r="MMM d, yyyy")=>{if(!a)return t;const s=new Date(a);return I.isValid(s)?I.format(s,r):t},Qi=a=>{switch(a){case"accepted":return"Accepted";case"ready-for-dispatch":return"Preparing";case"dispatched":return"On the way";case"completed":return"Completed";case"cancelled":return"Cancelled";default:return"Pending"}},Oi=a=>{switch(a){case"accepted":case"ready-for-dispatch":return"info";case"dispatched":case"completed":return"success";case"cancelled":return"danger";default:return"warning"}},Li=a=>a.cancelledAt?"Cancelled":a.acceptedAt?"Confirmed":"Pending",Ji=a=>a.cancelledAt?"danger":a.acceptedAt?"success":"warning",ql=a=>{if(!a)return"A";const t=a.split(" ").filter(Boolean);return t.length===0?"A":t.length===1?t[0].slice(0,1).toUpperCase():`${t[0].slice(0,1)}${t[t.length-1].slice(0,1)}`.toUpperCase()},Ot=({actions:a,children:t,description:r,eyebrow:s,title:i})=>e.jsxs(e.Fragment,{children:[e.jsx(Za,{}),e.jsx("main",{className:"min-h-screen bg-[linear-gradient(180deg,#0f172a_0px,#0f172a_180px,#f5f1e8_180px,#faf7f2_100%)] pb-16 pt-28 sm:pt-32",children:e.jsx("div",{className:"mx-auto max-w-6xl px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"overflow-hidden rounded-[32px] border border-stone-200 bg-white shadow-[0_24px_80px_rgba(15,23,42,0.12)]",children:[e.jsx("div",{className:"border-b border-stone-200 bg-[radial-gradient(circle_at_top_left,rgba(20,184,166,0.16),transparent_34%),linear-gradient(135deg,#fff7ed_0%,#ffffff_45%,#f8fafc_100%)] px-6 py-8 sm:px-8 lg:px-10",children:e.jsxs("div",{className:"flex flex-col gap-6 lg:flex-row lg:items-end lg:justify-between",children:[e.jsxs("div",{className:"max-w-2xl",children:[s?e.jsx("p",{className:"mb-3 text-xs font-semibold uppercase tracking-[0.28em] text-stone-500",children:s}):null,e.jsx("h1",{className:"font-red-hat-display text-3xl font-black text-stone-950 sm:text-[40px] sm:leading-tight",children:i}),r?e.jsx("p",{className:"mt-3 max-w-xl text-sm leading-6 text-stone-600 sm:text-base",children:r}):null]}),a?e.jsx("div",{className:"flex flex-wrap gap-3 lg:justify-end",children:a}):null]})}),e.jsx("div",{className:"px-6 py-6 sm:px-8 sm:py-8 lg:px-10",children:t})]})})})]}),ba=({action:a,children:t,className:r,description:s,title:i})=>e.jsxs("section",{className:v("rounded-[28px] border border-stone-200 bg-stone-50/80 p-5 sm:p-6",r),children:[e.jsxs("div",{className:"mb-5 flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-red-hat-display text-xl font-black text-stone-950",children:i}),s?e.jsx("p",{className:"mt-1 text-sm leading-6 text-stone-600",children:s}):null]}),a]}),t]}),gt=({children:a,className:t,tone:r="neutral"})=>e.jsx("span",{className:v("inline-flex items-center rounded-full border px-3 py-1 text-xs font-semibold uppercase tracking-wide",Vl[r],t),children:a}),ea=({actionHref:a,actionLabel:t,description:r,icon:s,title:i})=>e.jsxs("div",{className:"rounded-[24px] border border-dashed border-stone-300 bg-white px-6 py-10 text-center",children:[e.jsx("div",{className:"mx-auto flex h-14 w-14 items-center justify-center rounded-2xl bg-stone-100 text-stone-700",children:e.jsx(s,{className:"h-6 w-6"})}),e.jsx("h3",{className:"mt-4 font-red-hat-display text-xl font-black text-stone-950",children:i}),e.jsx("p",{className:"mx-auto mt-2 max-w-md text-sm leading-6 text-stone-600",children:r}),a&&t?e.jsx("div",{className:"mt-5",children:e.jsx(te,{asChild:!0,children:e.jsx(B,{href:a,children:t})})}):null]}),hr=({description:a="Loading your latest activity.",title:t})=>e.jsxs(Ot,{eyebrow:"My account",title:t,description:a,children:[e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-4",children:Array.from({length:4}).map((r,s)=>e.jsx("div",{className:"h-36 animate-pulse rounded-[24px] border border-stone-200 bg-stone-100"},s))}),e.jsxs("div",{className:"mt-6 grid gap-6 lg:grid-cols-2",children:[e.jsx("div",{className:"h-80 animate-pulse rounded-[28px] border border-stone-200 bg-stone-100"}),e.jsx("div",{className:"h-80 animate-pulse rounded-[28px] border border-stone-200 bg-stone-100"})]})]}),ht=({href:a,label:t})=>e.jsxs(B,{href:a,className:"inline-flex items-center gap-1 text-sm font-semibold text-stone-700 transition hover:text-stone-950",children:[t,e.jsx(N.ArrowRightIcon,{className:"h-4 w-4"})]}),Hl=a=>{const t=a.items.map(r=>{var s;return(s=r.translations[0])==null?void 0:s.title}).filter(Boolean);return t.length===0?"Order placed":t.length===1?t[0]:`${t[0]} +${t.length-1} more`},Yr=({description:a,href:t,icon:r,title:s})=>e.jsxs(B,{href:t,className:"storefront-primary-border-hover group rounded-[24px] border border-stone-200 bg-white p-5 transition duration-200 hover:-translate-y-0.5 hover:shadow-lg",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.22em] text-stone-500",children:"Quick access"}),e.jsxs("div",{className:"mt-3 flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-red-hat-display text-xl font-black text-stone-950",children:s}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-stone-600",children:a})]}),e.jsx("span",{className:"storefront-primary-group-accent inline-flex h-11 w-11 shrink-0 items-center justify-center rounded-2xl bg-stone-100 text-stone-700 transition",children:e.jsx(r,{className:"h-5 w-5"})})]})]}),Ul=()=>{var p,g,x;const{client:a}=P(),{useSession:t}=Le(),{organization:r,organizationId:s}=ve(),{data:i}=t(),n=A.useQuery({queryKey:["account","orders",s],enabled:!!s&&!!(i!=null&&i.user),queryFn:async()=>{const{body:y,status:j}=await a.order.getMyOrders({params:{organizationId:s},query:{limit:4,page:1}});if(j!==200)throw new Error("Failed to fetch your orders");return y}}),o=A.useQuery({queryKey:["account","reservations",s],enabled:!!s&&!!(i!=null&&i.user),queryFn:async()=>{const{body:y,status:j}=await a.reservation.getMyReservations({params:{organizationId:s},query:{limit:4,page:1}});if(j!==200)throw new Error("Failed to fetch your reservations");return y}});if(!(i!=null&&i.user))return null;if(n.isLoading||o.isLoading)return e.jsx(hr,{title:"Your account"});const l=((p=n.data)==null?void 0:p.list)??[],c=((g=o.data)==null?void 0:g.list)??[],m=[...c].filter(y=>!y.cancelledAt&&!!y.date&&new Date(y.date).getTime()>Date.now()).sort((y,j)=>new Date(y.date??0).getTime()-new Date(j.date??0).getTime())[0],u=i.user.firstname??((x=i.user.name)==null?void 0:x.split(" ").filter(Boolean)[0])??"there";return e.jsxs(Ot,{eyebrow:"My account",title:`Welcome back, ${u}`,description:"Track recent orders, revisit reservation history, and jump straight into the parts of your account you use most.",actions:e.jsxs(e.Fragment,{children:[e.jsx(te,{asChild:!0,variant:"secondary",children:e.jsx(B,{href:"/account/orders",children:"View orders"})}),e.jsx(te,{asChild:!0,children:e.jsx(B,{href:"/account/reservations",children:"Reservation history"})})]}),children:[e.jsxs("div",{className:"grid gap-6 lg:grid-cols-[1.25fr_0.95fr]",children:[e.jsx(ba,{title:"Recent orders",description:"A quick look at what you ordered most recently.",action:e.jsx(ht,{href:"/account/orders",label:"See all"}),children:n.isError?e.jsx(ea,{icon:N.ShoppingBagIcon,title:"Orders unavailable",description:"We couldn't load your recent orders just now. Please refresh and try again."}):l.length===0?e.jsx(ea,{icon:N.ShoppingBagIcon,title:"Your order history will appear here",description:"Once you place an order, you'll be able to track its progress and reopen the details from this account page.",actionHref:"/",actionLabel:"Browse the menu"}):e.jsx("div",{className:"space-y-4",children:l.map(y=>e.jsx(B,{href:`/account/orders/${y.id}`,className:"storefront-primary-border-hover group block rounded-[24px] border border-stone-200 bg-white p-5 transition duration-200 hover:-translate-y-0.5 hover:shadow-lg",children:e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"font-red-hat-display text-lg font-black text-stone-950",children:Hl(y)}),e.jsx(gt,{tone:Oi(y.status),children:Qi(y.status)})]}),e.jsxs("p",{className:"mt-2 text-sm leading-6 text-stone-600",children:["Ref ",y.referenceId," • ",y.items.length," item",y.items.length===1?"":"s"," •"," ",y.fulfilmentMethod==="delivery"?"Delivery":"Pickup"]})]}),e.jsxs("div",{className:"text-left sm:text-right",children:[e.jsx("p",{className:"text-lg font-black text-stone-950",children:we(y.payment.total,y.currency)}),e.jsx("p",{className:"mt-1 text-sm text-stone-500",children:Ye(y.createdAt,"Recently")})]})]})},y.id))})}),e.jsxs("div",{className:"grid gap-6",children:[e.jsx(ba,{title:"Jump into your history",description:"The two most useful places for signed-in guests.",children:e.jsxs("div",{className:"grid gap-4",children:[e.jsx(Yr,{href:"/account/orders",icon:N.ShoppingBagIcon,title:"Orders list",description:"Review every purchase, total paid, fulfilment method, and live order status."}),e.jsx(Yr,{href:"/account/reservations",icon:N.CalendarDaysIcon,title:"Reservation history",description:"See confirmed, pending, and cancelled bookings in one place."})]})}),e.jsx(ba,{title:"Profile snapshot",description:"A quick summary of the details tied to this account.",children:e.jsxs("div",{className:"rounded-[24px] border border-stone-200 bg-white p-5",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"flex h-14 w-14 items-center justify-center rounded-2xl bg-stone-900 text-lg font-black text-white",children:ql(i.user.name)}),e.jsxs("div",{children:[e.jsx("p",{className:"font-red-hat-display text-lg font-black text-stone-950",children:i.user.name}),e.jsx("p",{className:"text-sm text-stone-500",children:i.user.email})]})]}),e.jsxs("div",{className:"mt-5 grid gap-3 rounded-[20px] bg-stone-50 p-4 text-sm text-stone-600",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx(N.UserIcon,{className:"h-4 w-4"}),"First name"]}),e.jsx("span",{className:"font-semibold text-stone-900",children:i.user.firstname})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx(N.UserIcon,{className:"h-4 w-4"}),"Last name"]}),e.jsx("span",{className:"font-semibold text-stone-900",children:i.user.lastname})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx(N.CalendarDaysIcon,{className:"h-4 w-4"}),"Upcoming reservation"]}),e.jsx("span",{className:"font-semibold text-stone-900",children:m?Ye(m.date,"Not scheduled","MMM d, yyyy"):"Nothing booked"})]})]}),e.jsx("div",{className:"mt-5",children:e.jsx(te,{asChild:!0,variant:"secondary",children:e.jsx(B,{href:"/account/reservations/book",children:"Book a table"})})})]})})]})]}),e.jsx("div",{className:"mt-6",children:e.jsx(ba,{title:"Reservation activity",description:"Your most recent table bookings and their current status.",action:e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx(te,{asChild:!0,variant:"secondary",children:e.jsx(B,{href:"/account/reservations/book",children:"Book a table"})}),e.jsx(ht,{href:"/account/reservations",label:"Open history"})]}),children:o.isError?e.jsx(ea,{icon:N.CalendarDaysIcon,title:"Reservations unavailable",description:"We couldn't load your reservation history just now. Please refresh and try again."}):c.length===0?e.jsx(ea,{icon:N.CalendarDaysIcon,title:"No reservations yet",description:"When you reserve a table, the details and status updates will show up here.",actionHref:"/account/reservations/book",actionLabel:"Book a table"}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:c.map(y=>e.jsx(B,{href:`/account/reservations/${y.id}`,className:"storefront-primary-border-hover group rounded-[24px] border border-stone-200 bg-white p-5 transition duration-200 hover:-translate-y-0.5 hover:shadow-lg",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"font-red-hat-display text-lg font-black text-stone-950",children:Ye(y.date,"Date pending","MMM d, yyyy")}),e.jsx(gt,{tone:Ji(y),children:Li(y)})]}),e.jsxs("p",{className:"mt-2 text-sm leading-6 text-stone-600",children:["Ref ",y.referenceId," • ",y.guests," ","guest",y.guests===1?"":"s"]})]}),e.jsx("p",{className:"text-sm font-medium text-stone-500",children:Ye(y.date,"Awaiting confirmation","h:mm a")})]})},y.id))})})})]})},Vi=()=>e.jsx(da,{children:e.jsx(Ul,{})}),qi=()=>e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex flex-col md:flex-row h-screen w-screen relative",children:[e.jsx("div",{className:"hidden md:flex items-center justify-end w-full md:w-1/2 h-full px-16 xl:px-24 bg-gray-900 md:overflow-y-auto",children:e.jsx("div",{className:"w-96 animate-fade",children:e.jsx("div",{className:"pl-6",children:e.jsxs("div",{className:"px-7 pt-10 pb-0 md:pt-0 md:px-0",children:[[1,2].map(a=>e.jsxs("div",{className:"flex items-center w-full mb-5 sm:mb-7",children:[e.jsx("div",{className:"w-14 sm:w-32 h-10 sm:h-24 overflow-hidden rounded-lg bg-gray-700 animate-pulse"}),e.jsxs("div",{className:"pl-3 md:pl-5 w-full",children:[e.jsx("div",{className:"h-4 bg-gray-700 rounded-sm w-3/4 mb-2 animate-pulse"}),e.jsx("div",{className:"h-3 bg-gray-700 rounded-sm w-1/2 mb-2 animate-pulse"}),e.jsx("div",{className:"h-3 bg-gray-700 rounded-sm w-1/4 animate-pulse"})]})]},a)),e.jsx("hr",{className:"opacity-10 my-4 sm:my-4"}),e.jsxs("div",{className:"mt-3 flex items-center",children:[e.jsx("div",{className:"h-3 bg-gray-700 rounded-sm w-20 animate-pulse"}),e.jsx("div",{className:"h-3 bg-gray-700 rounded-sm w-16 ml-auto animate-pulse"})]}),e.jsxs("div",{className:"mt-3 flex items-center",children:[e.jsx("div",{className:"h-3 bg-gray-700 rounded-sm w-16 animate-pulse"}),e.jsx("div",{className:"h-3 bg-gray-700 rounded-sm w-16 ml-auto animate-pulse"})]}),e.jsx("hr",{className:"opacity-10 my-4 sm:my-4"}),e.jsxs("div",{className:"mt-4 flex justify-between",children:[e.jsx("div",{className:"h-5 bg-gray-700 rounded-sm w-16 animate-pulse"}),e.jsx("div",{className:"h-5 bg-gray-700 rounded-sm w-20 animate-pulse"})]})]})})})}),e.jsx("div",{className:"flex flex-col items-start 2xl:items-start w-full md:w-1/2 h-full px-6 sm:px-12 xl:px-24 py-8 md:overflow-y-auto relative",children:e.jsxs("div",{className:"md:my-auto animate-fade w-full md:max-w-[432px]",children:[e.jsx("div",{className:"h-8 bg-gray-200 rounded-sm w-64 mb-4 animate-pulse"}),e.jsxs("div",{className:"mb-8",children:[e.jsx("div",{className:"h-4 bg-gray-200 rounded-sm w-48 mb-2 animate-pulse"}),e.jsx("div",{className:"h-4 bg-gray-200 rounded-sm w-40 animate-pulse"})]}),e.jsx("div",{className:"mt-8 space-y-4",children:e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-4 top-0 h-full w-0.5 bg-gray-200"}),[1,2,3,4,5].map(a=>e.jsxs("div",{className:"ml-9 mb-8 relative",children:[e.jsx("div",{className:"absolute -left-9 mt-1.5",children:e.jsx("div",{className:"h-8 w-8 rounded-full bg-gray-200 animate-pulse"})}),e.jsx("div",{className:"h-5 bg-gray-200 rounded-sm w-40 mb-2 animate-pulse"}),e.jsx("div",{className:"h-3 bg-gray-200 rounded-sm w-64 mb-2 animate-pulse"}),e.jsx("div",{className:"h-3 bg-gray-200 rounded-sm w-24 animate-pulse"})]},a))]})})]})})]})}),Zl=({className:a})=>e.jsx("svg",{className:a,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 13l4 4L19 7"})}),_l=({className:a})=>e.jsx("svg",{className:a,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})}),$l=({className:a})=>e.jsxs("svg",{"aria-hidden":"true",className:a,viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",fill:"currentColor"}),e.jsx("path",{d:"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",fill:"currentFill"})]}),Hi=({title:a,description:t,active:r,date:s,cancelled:i=!1,showConfetti:n=!1})=>{const o=m=>{if(!m)return null;const u=new Date(m);return I.isValid(u)?I.format(u,"MMM d, yyyy - h:mm a"):null},l=!!s,c=r&&!s;return e.jsxs("div",{className:"relative flex items-start gap-4 pb-8",children:[e.jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-full shrink-0",children:e.jsxs("div",{className:v("w-8 h-8 rounded-full flex items-center justify-center",{"bg-green-100 border-green-500 border-[3px]":l&&!n,"bg-violet-100 border-violet-500 border-[3px]":l&&n,"bg-white":!s,"border-gray-200 border-[3px]":!s&&!r,"bg-red-100 border-red-500 border-[3px]":i}),children:[s&&!n&&!i&&e.jsx(Zl,{className:"w-4 h-4 text-green-500"}),l&&n&&e.jsx(N.PartyPopperIcon,{className:"w-4 h-4 text-violet-500"}),i&&e.jsx(_l,{className:"w-4 h-4 text-red-500"}),c&&e.jsx($l,{className:"text-gray-200 animate-spin dark:text-gray-600 fill-blue-600 w-full"})]})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:v("font-black font-red-hat-display",{"text-red-500":i,"text-gray-900":l,"text-gray-500":!i&&!l}),children:a}),e.jsx("p",{className:v("text-sm font-medium",{"text-red-500":i,"text-gray-600":l,"text-gray-400":!i&&!l}),children:t}),o(s)&&e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:o(s)})]})]})},Wl=({orderId:a})=>{const{client:t}=P(),{clearCart:r}=Va(),{organization:s,organizationId:i}=ve(),n=D.useSearchParams(),o=D.useRouter(),l=D.usePathname(),{t:c}=qa(),m=s==null?void 0:s.configuration.defaultCurrency;h.useEffect(()=>{if((n==null?void 0:n.get("clearCart"))==="true"&&l){r();const f=new URLSearchParams(Array.from(n.entries()));f.delete("clearCart");const b=f.toString()?`${l}?${f.toString()}`:l;o.replace(b)}},[r,n,o,l]);const{data:u,isLoading:p,error:g}=A.useQuery({queryKey:["order",a],refetchInterval:({state:f})=>{var b,w;return((b=f.data)==null?void 0:b.status)!=="completed"&&((w=f.data)==null?void 0:w.status)!=="cancelled"?30*1e3:!1},queryFn:async()=>{const{status:f,body:b}=await t.order.getOrder({params:{id:a,organizationId:i}});if(f!==200)throw new Error("Failed to fetch shipping address");return b}}),x=h.useMemo(()=>u?u==null?void 0:u.items.map(f=>({title:f.translations[0].title,subtitle:[f.translations[0].subtitle],price:we(f.unitPrice,m??"USD"),unitPrice:we(f.unitPrice,m??"USD"),quantity:f.quantity,image:f.image})):[],[u,m]);if(!u||p)return e.jsx(qi,{});const{status:y}=u,j=[{title:c("orderTracking.orderPlaced"),description:c("orderTracking.orderPlacedDesc"),date:new Date(u.expiresAt),active:!1},{title:c("orderTracking.orderAccepted"),description:c("orderTracking.orderAcceptedDesc"),date:u.acceptedAt,active:!u.acceptedAt},{title:c("orderTracking.readyForDispatch"),description:c("orderTracking.readyForDispatchDesc"),date:u.readyForDispatchAt,active:y==="accepted"},{title:c("orderTracking.orderDispatched"),description:c("orderTracking.orderDispatchedDesc"),date:u.dispatchedAt,active:y==="ready-for-dispatch"},{title:c("orderTracking.orderDelivered"),description:c("orderTracking.orderDeliveredDesc"),date:u.completedAt,active:y==="dispatched",showConfetti:!0}];return u.status==="cancelled"&&j.push({title:c("orderTracking.orderCancelled"),description:c("orderTracking.orderCancelledDesc"),date:u.cancelledAt,active:!!u.cancelledAt,cancelled:!0}),e.jsxs(e.Fragment,{children:[e.jsx(Za,{summary:{total:u.payment.total,subtotal:u.payment.subtotal,shipping:u.payment.shipping,items:x}}),e.jsx("div",{children:e.jsxs("div",{className:"flex flex-col md:flex-row h-screen w-screen relative",children:[e.jsx("div",{className:"hidden md:flex items-center justify-end w-full md:w-1/2 h-full px-16 xl:px-24 bg-gray-900 md:overflow-y-auto",children:e.jsx("div",{className:"w-96 animate-fade",children:e.jsxs("div",{className:"pl-6",children:[e.jsx(gr,{items:x,total:u.payment.total,subtotal:u.payment.subtotal,shipping:u.payment.shipping,currency:m??"USD"}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 text-center mt-14 w-full",children:[c("orderTracking.poweredBy")," ",e.jsx("a",{href:"https://shophost.io",className:"text-blue-500 hover:text-blue-600 dark:text-blue-500 dark:hover:text-blue-400",children:"shophost.io"})]})]})})}),e.jsx("div",{className:"flex flex-col items-start 2xl:items-start w-full md:w-1/2 h-full px-6 sm:px-12 xl:px-24 py-8 md:overflow-y-auto relative",children:e.jsxs("div",{className:"md:my-auto animate-fade w-full md:max-w-[432px] pt-14 sm:pt-0",children:[e.jsx("h1",{className:"h3 mb-1 font-red-hat-display",children:c("checkout.yourOrder")}),e.jsxs("div",{className:"mb-8",children:[e.jsxs("p",{className:"text-sm font-medium text-gray-500",children:[c("orderTracking.reference"),": ",u.referenceId]}),e.jsxs("p",{className:"text-sm font-medium text-gray-500",children:[c("orderTracking.status"),":"," ",e.jsx("span",{className:`capitalize font-semibold ${u.status==="cancelled"?"text-red-600":"text-green-600"}`,children:u.status})]})]}),e.jsx("div",{className:"mt-8 space-y-4",children:e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-4 top-0 w-0.5 bg-gray-200",style:{height:`calc(100% - ${j.length>1?"4rem":"0rem"})`}}),j.map((f,b)=>e.jsx(Hi,{...f},b))]})})]})})]})})]})},Kl=a=>{const t=a.items.map(r=>{var s;return(s=r.translations[0])==null?void 0:s.title}).filter(Boolean);return t.length===0?"Order placed":t.length===1?t[0]:`${t[0]} +${t.length-1} more`},Gl=()=>{var o;const{client:a}=P(),{useSession:t}=Le(),{organizationId:r}=ve(),{data:s}=t(),i=A.useQuery({queryKey:["account","orders","history",r],enabled:!!r&&!!(s!=null&&s.user),queryFn:async()=>{const{body:l,status:c}=await a.order.getMyOrders({params:{organizationId:r},query:{limit:20,page:1}});if(c!==200)throw new Error("Failed to fetch your orders");return l}});if(!(s!=null&&s.user))return null;if(i.isLoading)return e.jsx(hr,{title:"Your orders",description:"Loading your order history."});const n=((o=i.data)==null?void 0:o.list)??[];return e.jsx(Ot,{eyebrow:"My account",title:"Your orders",description:"Everything you've ordered lives here, including totals, fulfilment details, and live status updates.",actions:e.jsxs(e.Fragment,{children:[e.jsx(te,{asChild:!0,variant:"secondary",children:e.jsx(B,{href:"/account",children:"Back to account"})}),e.jsx(te,{asChild:!0,children:e.jsx(B,{href:"/account/reservations",children:"Reservation history"})})]}),children:e.jsx("div",{children:e.jsx(ba,{title:"Order history",description:"Open any order to review the full tracker and line items.",action:e.jsx(ht,{href:"/account",label:"Back to dashboard"}),children:i.isError?e.jsx(ea,{icon:N.ShoppingBagIcon,title:"We couldn't load your orders",description:"Please refresh the page and try again. Your order tracker will be back as soon as the connection recovers."}):n.length===0?e.jsx(ea,{icon:N.ShoppingBagIcon,title:"No orders yet",description:"Once you buy something, this page becomes your personal record of what you ordered and how each order progressed.",actionHref:"/",actionLabel:"Start shopping"}):e.jsx("div",{className:"space-y-4",children:n.map(l=>e.jsx(B,{href:`/account/orders/${l.id}`,className:"storefront-primary-border-hover group block rounded-[24px] border border-stone-200 bg-white p-5 transition duration-200 hover:-translate-y-0.5 hover:shadow-lg",children:e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"font-red-hat-display text-lg font-black text-stone-950",children:Kl(l)}),e.jsx(gt,{tone:Oi(l.status),children:Qi(l.status)})]}),e.jsxs("p",{className:"mt-2 text-sm leading-6 text-stone-600",children:["Ref ",l.referenceId," • ",l.items.length," item",l.items.length===1?"":"s"," •"," ",l.fulfilmentMethod==="delivery"?"Delivery":"Pickup"]}),e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:l.items.slice(0,3).map((c,m)=>{var u;return e.jsx("span",{className:"rounded-full border border-stone-200 bg-stone-50 px-3 py-1 text-xs font-medium text-stone-600",children:((u=c.translations[0])==null?void 0:u.title)??"Item"},`${l.id}-${m}`)})})]}),e.jsxs("div",{className:"shrink-0 text-left lg:text-right",children:[e.jsx("p",{className:"text-lg font-black text-stone-950",children:we(l.payment.total,l.currency)}),e.jsx("p",{className:"mt-1 text-sm text-stone-500",children:Ye(l.createdAt,"Recently")}),e.jsx("p",{className:"mt-3 text-sm font-semibold text-stone-700 transition group-hover:text-stone-950",children:"View details"})]})]})},l.id))})})})})},Xl=(a,t,r)=>{if(t.length===0)return;let s=a;for(let i=0;i<t.length;i+=1){const n=String(t[i]);if(i===t.length-1){s[n]=r;return}s[n]??(s[n]={}),s=s[n]}},Yl=a=>async t=>{const r=await a.safeParseAsync(t);if(r.success)return{values:r.data,errors:{}};const s={};for(const i of r.error.issues)Xl(s,i.path.filter(n=>typeof n=="string"||typeof n=="number"),{type:i.code,message:i.message});return{values:{},errors:s}},ed=({initialData:a})=>{var u;const{client:t}=P(),{organizationId:r,organization:s}=ve(),{t:i}=qa(),n=D.useRouter(),o=(u=s==null?void 0:s.configuration)==null?void 0:u.isAcceptingReservations,l=[s==null?void 0:s.phone,s==null?void 0:s.email].filter(p=>!!p),c=Z.useForm({resolver:Yl(Al),reValidateMode:"onChange",defaultValues:{firstname:a.firstname,lastname:a.lastname}}),m=A.useMutation({mutationFn:async p=>{const{status:g,body:x}=await t.reservation.createReservation({body:p,params:{organizationId:r}});if(g!==201)throw new Error("Failed to create shipping address");return x},onSuccess:p=>{n.push(`/account/reservations/${p.id}`)}});return e.jsxs("div",{className:"flex flex-col gap-4",children:[s&&o===!1&&e.jsxs("div",{className:"rounded-[28px] border border-amber-200 bg-amber-50 px-5 py-4 text-amber-950",children:[e.jsx("h2",{className:"font-red-hat-display text-lg font-black",children:i("reservation.bookingDisabled")}),e.jsx("p",{className:"mt-2 text-sm leading-6",children:i("reservation.bookingDisabledDesc")}),l.length>0&&e.jsx("div",{className:"mt-3 text-sm font-medium",children:l.map(p=>e.jsx("div",{children:p},p))})]}),o===!1?e.jsx(te,{variant:"secondary",className:"shadow-none",type:"button",onClick:()=>n.push("/"),children:"Back"}):e.jsx(Z.FormProvider,{...c,children:e.jsxs("form",{onSubmit:c.handleSubmit(p=>m.mutate(p)),children:[e.jsxs("div",{className:"grid grid-cols-4 gap-x-4 gap-y-4 mt-3",children:[e.jsx(Ne,{name:"firstname",label:"First Name",type:"text",className:"col-span-2",placeholder:"e.g. John"}),e.jsx(Ne,{name:"lastname",label:"Last Name",type:"text",className:"col-span-2",placeholder:"e.g. Doe"}),e.jsx(Ne,{name:"phone",label:"Phone",type:"phone-number",className:"col-span-4",placeholder:"e.g. +48 123 456 789"}),e.jsx(Ne,{name:"guests",label:"Number of Guests",type:"number",className:"col-span-4",placeholder:"e.g. 2"}),e.jsx(Ne,{name:"date",type:"week-time",className:"col-span-4 -mt-4"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-2 w-full mt-8",children:[e.jsx(te,{variant:"secondary",className:"shadow-none",type:"button",onClick:()=>n.push("/"),children:"Back"}),e.jsx(te,{type:"submit",className:"shadow-none",isLoading:m.isPending,loadingText:"Saving...",children:"Send Request"})]})]})})]})},ad=()=>{const{useSession:a}=Le(),{organization:t}=ve(),{data:r}=a(),s=t!=null&&t.name?`Enter your details to book a table at ${t.name}`:"Enter your details to book a table";return r!=null&&r.user?e.jsx(Ti,{title:"Book a table",description:s,children:e.jsx(ed,{initialData:{firstname:r.user.firstname,lastname:r.user.lastname}})}):null},es=(a,t)=>{if(!a)return t("reservation.notSpecified");const r=new Date(a);return I.isValid(r)?I.format(r,"MMM d, yyyy - h:mm a"):t("reservation.invalidDate")},td=({reservationId:a})=>{const{client:t}=P(),{organizationId:r}=ve(),{t:s}=qa(),{data:i,isLoading:n}=A.useQuery({queryKey:["reservation",a],queryFn:async()=>{const{status:c,body:m}=await t.reservation.getReservation({params:{reservationId:a,organizationId:r}});if(c!==200)throw new Error("Failed to fetch reservation");return m},refetchInterval:({state:c})=>{var m,u;return!((m=c.data)!=null&&m.acceptedAt)&&!((u=c.data)!=null&&u.cancelledAt)?30*1e3:!1}});if(!i||n)return e.jsx(qi,{});const o=[{title:s("reservation.requestSent"),description:s("reservation.requestSentDesc"),date:i.createdAt||new Date,active:!1},{title:s("reservation.confirmed"),description:s("reservation.confirmedDesc"),date:i.acceptedAt,active:!i.acceptedAt,showConfetti:!!i.acceptedAt}];i.cancelledAt&&o.push({title:s("reservation.cancelled"),description:s("reservation.cancelledDesc"),date:i.cancelledAt,active:!1,cancelled:!0});const l=()=>i.cancelledAt?s("reservation.cancelledStatus"):i.acceptedAt?s("reservation.confirmedStatus"):s("reservation.pendingStatus");return e.jsxs(e.Fragment,{children:[e.jsx(Za,{}),e.jsxs("div",{className:"flex flex-col md:flex-row h-screen w-screen relative",children:[e.jsx("div",{className:"hidden md:flex items-center justify-end w-full md:w-1/2 h-full px-16 xl:px-24 bg-gray-900 md:overflow-y-auto",children:e.jsx("div",{className:"w-96 animate-fade",children:e.jsxs("div",{className:"pl-6",children:[e.jsxs("div",{className:"px-7 pt-10 pb-0 md:pt-0 md:px-0",children:[e.jsx("div",{className:"my-3 sm:my-6 sm:pb-1",children:e.jsxs("div",{className:"flex flex-col w-full mb-5 sm:mb-3",children:[e.jsx("h2",{className:"text-xl font-bold text-white mb-2",children:s("reservation.reservationDetails")}),e.jsxs("p",{className:"text-white font-medium text-sm mb-1",children:[e.jsxs("span",{className:"opacity-70 font-semibold",children:[s("reservation.name"),":"]})," ",i.firstname," ",i.lastname]}),e.jsxs("p",{className:"text-white font-medium text-sm mb-1",children:[e.jsxs("span",{className:"opacity-70 font-semibold",children:[s("reservation.phone"),":"]})," ",i.phone]}),e.jsxs("p",{className:"text-white font-medium text-sm mb-1",children:[e.jsxs("span",{className:"opacity-70 font-semibold",children:[s("reservation.guests"),":"]})," ",i.guests]}),e.jsxs("p",{className:"text-white font-medium text-sm mb-1",children:[e.jsxs("span",{className:"opacity-70 font-semibold",children:[s("reservation.date"),":"]})," ",es(i.date,s)]})]})}),e.jsx("hr",{className:"opacity-10 my-4 sm:my-4"}),e.jsx("div",{className:"mt-4",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("h2",{className:"text-sm xl:text-lg text-white font-black font-red-hat-display",children:s("common.makeReservation")}),e.jsx("span",{className:`ml-auto py-1 px-3 rounded-full text-sm font-semibold ${i.cancelledAt?"bg-red-100 text-red-800":i.acceptedAt?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"}`,children:l()})]})})]}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 text-center mt-14 w-full",children:[s("reservation.poweredBy")," ",e.jsx("a",{href:"https://shophost.io",className:"text-blue-500 hover:text-blue-600 dark:text-blue-500 dark:hover:text-blue-400",children:"shophost.io"})]})]})})}),e.jsx("div",{className:"flex flex-col items-start 2xl:items-start w-full md:w-1/2 h-full px-6 sm:px-12 xl:px-24 py-8 md:overflow-y-auto relative animate-fade-in",children:e.jsxs("div",{className:"md:my-auto animate-fade w-full md:max-w-[432px] pt-14 sm:pt-0",children:[e.jsx("h1",{className:"h3 mb-1 font-red-hat-display",children:s("common.makeReservation")}),e.jsxs("div",{className:"mb-8",children:[e.jsxs("p",{className:"text-sm font-medium text-gray-500",children:[s("reservation.reference"),": ",i.referenceId]}),e.jsxs("p",{className:"text-sm font-medium text-gray-500",children:[s("reservation.status"),":"," ",e.jsx("span",{className:`capitalize font-semibold ${i.cancelledAt?"text-red-600":i.acceptedAt?"text-green-600":"text-yellow-600"}`,children:l()})]}),e.jsxs("div",{className:"mt-10 border-b pb-6 md:hidden",children:[e.jsx("div",{className:"flex items-center",children:e.jsx("h2",{className:"text-lg font-black font-red-hat-display text-gray-900",children:s("reservation.reservationDetails")})}),e.jsxs("p",{className:"text-sm font-medium text-gray-600 mb-1",children:[e.jsxs("span",{className:"font-semibold",children:[s("reservation.name"),":"]})," ",i.firstname," ",i.lastname]}),e.jsxs("p",{className:"text-sm font-medium text-gray-600 mb-1",children:[e.jsxs("span",{className:"font-semibold",children:[s("reservation.phone"),":"]})," ",i.phone]}),e.jsxs("p",{className:"text-sm text-gray-600 mb-1",children:[e.jsxs("span",{className:"font-semibold",children:[s("reservation.guests"),":"]})," ",i.guests]}),e.jsxs("p",{className:"text-sm font-medium text-gray-600 mb-1",children:[e.jsxs("span",{className:"font-semibold",children:[s("reservation.date"),":"]})," ",es(i.date,s)]})]})]}),e.jsx("div",{className:"mt-8 space-y-4",children:e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-4 top-0 w-0.5 bg-gray-200",style:{height:`calc(100% - ${o.length>1?"4rem":"0rem"})`}}),o.map((c,m)=>e.jsx(Hi,{...c},m))]})})]})})]})]})},rd=()=>{var o;const{client:a}=P(),{useSession:t}=Le(),{organizationId:r}=ve(),{data:s}=t(),i=A.useQuery({queryKey:["account","reservations","history",r],enabled:!!r&&!!(s!=null&&s.user),queryFn:async()=>{const{body:l,status:c}=await a.reservation.getMyReservations({params:{organizationId:r},query:{limit:20,page:1}});if(c!==200)throw new Error("Failed to fetch your reservations");return l}});if(!(s!=null&&s.user))return null;if(i.isLoading)return e.jsx(hr,{title:"Reservation history",description:"Loading your reservations."});const n=((o=i.data)==null?void 0:o.list)??[];return e.jsx(Ot,{eyebrow:"My account",title:"Reservation history",description:"Keep track of upcoming tables, past visits, and every booking status change in one place.",actions:e.jsxs(e.Fragment,{children:[e.jsx(te,{asChild:!0,variant:"secondary",children:e.jsx(B,{href:"/account",children:"Back to account"})}),e.jsx(te,{asChild:!0,children:e.jsx(B,{href:"/account/reservations/book",children:"Book a table"})})]}),children:e.jsx("div",{children:e.jsx(ba,{title:"Your bookings",description:"Open any reservation to review the confirmation timeline and details.",action:e.jsx(ht,{href:"/account",label:"Back to dashboard"}),children:i.isError?e.jsx(ea,{icon:N.CalendarDaysIcon,title:"We couldn't load your reservations",description:"Please refresh the page and try again. Your booking history will return as soon as the connection is restored."}):n.length===0?e.jsx(ea,{icon:N.CalendarDaysIcon,title:"No reservations yet",description:"Once you book a table, this page will keep the full history of confirmed, pending, and cancelled reservations.",actionHref:"/account/reservations/book",actionLabel:"Book a table"}):e.jsx("div",{className:"space-y-4",children:n.map(l=>e.jsx(B,{href:`/account/reservations/${l.id}`,className:"storefront-primary-border-hover group block rounded-[24px] border border-stone-200 bg-white p-5 transition duration-200 hover:-translate-y-0.5 hover:shadow-lg",children:e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"font-red-hat-display text-lg font-black text-stone-950",children:Ye(l.date,"Date pending","EEEE, MMM d")}),e.jsx(gt,{tone:Ji(l),children:Li(l)})]}),e.jsxs("p",{className:"mt-2 text-sm leading-6 text-stone-600",children:["Ref ",l.referenceId," • ",l.guests," ","guest",l.guests===1?"":"s"]}),e.jsxs("div",{className:"mt-4 inline-flex rounded-full border border-stone-200 bg-stone-50 px-3 py-1 text-xs font-medium text-stone-600",children:["Reserved under ",l.firstname," ",l.lastname]})]}),e.jsxs("div",{className:"shrink-0 text-left lg:text-right",children:[e.jsx("p",{className:"text-lg font-black text-stone-950",children:Ye(l.date,"Awaiting time","h:mm a")}),e.jsxs("p",{className:"mt-1 text-sm text-stone-500",children:["Created"," ",Ye(l.createdAt,"Recently")]}),e.jsx("p",{className:"mt-3 text-sm font-semibold text-stone-700 transition group-hover:text-stone-950",children:"View details"})]})]})},l.id))})})})})},sd=()=>{const a=D.useSearchParams(),{signIn:t}=Le(),{baseUrl:r}=P(),s=(a==null?void 0:a.get("redirect"))??"/checkout/customer-details",{register:i,handleSubmit:n,formState:{errors:o,isSubmitting:l}}=Z.useForm({resolver:be.zodResolver(si),shouldFocusError:!0}),c=async u=>{await t.email({email:u.email,password:u.password,callbackURL:`${r}${s}`})},m=async u=>{u.preventDefault(),await t.social({provider:"google",callbackURL:`${r}${s}`})};return e.jsxs("div",{className:"flex w-full flex-col items-start sm:max-w-sm",children:[e.jsxs("div",{className:"mt-6 flex flex-col",children:[e.jsx("h1",{className:"h4 font-black font-red-hat-display",children:"Log in"}),e.jsxs("p",{className:"mt-1 text-sm text-gray-700 dark:text-gray-300",children:["Login or create an account to continue. Don’t have an account?"," ",e.jsx(B,{className:"storefront-primary-text storefront-primary-text-hover",href:`/account/sign-up?redirect=${s}`,children:"Sign up"})]})]}),e.jsxs("div",{className:"mt-10 w-full",children:[e.jsx("div",{className:"gap-2 sm:flex sm:flex-row sm:items-center",children:e.jsxs(te,{variant:"secondary",type:"button",className:"mt-2 w-full sm:mt-0 shadow-none inline-flex items-center gap-2",onClick:m,children:[e.jsx(M.RiGoogleFill,{className:"size-4","aria-hidden":"true"}),"Login with Google"]})}),e.jsx(ja,{className:"my-6",children:"or"}),e.jsxs("form",{onSubmit:n(c),className:"flex w-full flex-col gap-y-6",children:[e.jsxs("div",{className:"flex flex-col gap-y-4",children:[e.jsxs("div",{className:"flex flex-col space-y-2",children:[e.jsx(Re,{htmlFor:"email-form-item",className:"font-medium",children:"Email"}),e.jsx(De,{type:"email",autoComplete:"email",id:"email-form-item",placeholder:"emily.ross@acme.ch",...i("email")}),o.email&&e.jsx("span",{className:"text-sm text-red-500",children:o.email.message})]}),e.jsxs("div",{className:"flex flex-col space-y-2",children:[e.jsx(Re,{htmlFor:"password-form-item",className:"font-medium",children:"Password"}),e.jsx(De,{type:"password",autoComplete:"current-password",id:"password-form-item",placeholder:"Password",...i("password")}),o.password&&e.jsx("span",{className:"text-sm text-red-500",children:o.password.message})]})]}),e.jsx(te,{type:"submit",className:"shadow-none",isLoading:l,children:l?"Submitting...":"Continue"})]})]}),e.jsx(ja,{}),e.jsxs("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:["Forgot your password?"," ",e.jsx("a",{className:"storefront-primary-text storefront-primary-text-hover",href:"#",children:"Reset password"})]})]})},id=()=>e.jsx(sd,{}),nd=()=>{const a=D.useSearchParams(),{signUp:t,signIn:r}=Le(),{baseUrl:s}=P(),i=(a==null?void 0:a.get("redirect"))??"/checkout/customer-details",{register:n,handleSubmit:o,formState:{errors:l}}=Z.useForm({resolver:be.zodResolver(dr),shouldFocusError:!0}),{isPending:c,isError:m,mutate:u}=A.useMutation({onMutate:async g=>t.email({email:g.email,password:g.password,name:`${g.firstname} ${g.lastname}`,firstname:g.firstname,lastname:g.lastname,callbackURL:`${s}${i}`})}),p=async g=>(g.preventDefault(),r.social({provider:"google",callbackURL:`${s}${i}`}));return e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex w-full flex-col items-start md:max-w-sm",children:[e.jsxs("div",{className:"mt-6 flex flex-col",children:[e.jsx("h1",{className:"h4 font-black font-red-hat-display",children:"Create an account"}),e.jsxs("p",{className:"mt-1 text-sm text-gray-700 dark:text-gray-300",children:["Already have an account?"," ",e.jsx(B,{className:"storefront-primary-text storefront-primary-text-hover",href:"/account/sign-in",children:"Sign in"})]})]}),e.jsxs("div",{className:"mt-10 w-full",children:[e.jsx("div",{className:"gap-2 sm:flex sm:flex-row sm:items-center",children:e.jsxs(te,{variant:"secondary",type:"button",className:"mt-2 w-full sm:mt-0 inline-flex items-center gap-2 shadow-none",onClick:p,children:[e.jsx(M.RiGoogleFill,{className:"size-4","aria-hidden":"true"}),"Signin with Google"]})}),e.jsx(ja,{className:"my-6",children:"or"}),e.jsxs("form",{onSubmit:o(g=>u(g)),className:"flex w-full flex-col gap-y-6",children:[e.jsxs("div",{className:"flex flex-col gap-y-4",children:[e.jsxs("div",{className:"flex flex-col space-y-2",children:[e.jsx(Re,{htmlFor:"email-form-item",className:"font-medium",children:"First Name"}),e.jsx(De,{type:"text",id:"email-form-item",placeholder:"Emily",...n("firstname")}),l.firstname&&e.jsx("span",{className:"text-sm text-red-500",children:l.firstname.message})]}),e.jsxs("div",{className:"flex flex-col space-y-2",children:[e.jsx(Re,{htmlFor:"email-form-item",className:"font-medium",children:"Last Name"}),e.jsx(De,{type:"text",id:"email-form-item",placeholder:"Emily",...n("lastname")}),l.lastname&&e.jsx("span",{className:"text-sm text-red-500",children:l.lastname.message})]}),e.jsxs("div",{className:"flex flex-col space-y-2",children:[e.jsx(Re,{htmlFor:"email-form-item",className:"font-medium",children:"Email"}),e.jsx(De,{type:"email",autoComplete:"email",id:"email-form-item",placeholder:"emily.ross@acme.ch",...n("email")}),l.email&&e.jsx("span",{className:"text-sm text-red-500",children:l.email.message})]}),e.jsxs("div",{className:"flex flex-col space-y-2",children:[e.jsx(Re,{htmlFor:"password-form-item",className:"font-medium",children:"Password"}),e.jsx(De,{type:"password",autoComplete:"current-password",id:"password-form-item",placeholder:"Password",...n("password")}),l.password&&e.jsx("span",{className:"text-sm text-red-500",children:l.password.message})]})]}),m&&e.jsx("span",{className:"text-sm text-red-500",children:"An error occurred, please try again."}),e.jsx(te,{type:"submit",isLoading:c,children:c?"Submitting...":"Continue"})]})]}),e.jsx(ja,{}),e.jsxs("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:["Forgot your password?"," ",e.jsx("a",{className:"storefront-primary-text storefront-primary-text-hover",href:"#",children:"Reset password"})]})]})})},od=()=>e.jsx(nd,{}),ld=()=>{const{segments:a}=D.useParams(),[t,...r]=a??[];if(!t)return e.jsx(da,{children:e.jsx(Vi,{})});switch(t){case"sign-in":return r.length!==0?D.notFound():e.jsx(Xr,{children:e.jsx(id,{})});case"sign-up":return r.length!==0?D.notFound():e.jsx(Xr,{children:e.jsx(od,{})});case"orders":return r.length>1?D.notFound():r.length===0?e.jsx(da,{children:e.jsx(Gl,{})}):e.jsx(da,{children:e.jsx(Wl,{orderId:r[0]})});case"reservations":return r.length>1?D.notFound():r.length===0?e.jsx(da,{children:e.jsx(rd,{})}):r[0]==="book"?e.jsx(da,{children:e.jsx(ad,{})}):e.jsx(da,{children:e.jsx(td,{reservationId:r[0]})});default:return D.notFound()}},dd=a=>{if(a[0]==="reservation"&&a.length===1)return e.jsx(Xt,{});if(a.length!==1)return D.notFound();switch(a[0]){case"customer-details":return e.jsx(Xt,{});case"shipping-and-payment":return e.jsx(Pi,{});default:return D.notFound()}},cd=()=>{const a=D.useParams(),{useSession:t}=Le(),r=D.useRouter(),{data:s,isPending:i}=t(),{loading:n,formattedCartItems:o,total:l,subtotal:c,shipping:m}=kt(),{organization:u,loading:p}=ve(),g=(a==null?void 0:a.segments)||[];if(h.useEffect(()=>{!i&&!s&&r.push("/account/sign-in?redirect=/checkout/customer-details")},[s,i,r]),p||n||i)return e.jsx("div",{className:"flex flex-col items-center justify-center h-screen w-screen bg-gray-900",children:e.jsx("div",{className:"mb-4",children:e.jsx("div",{className:"storefront-primary-border animate-spin rounded-full h-18 w-18 border-b-2"})})});if(!u)return e.jsx("div",{className:"flex flex-col items-center justify-center h-screen w-screen bg-gray-900",children:e.jsx("h1",{className:"text-2xl font-bold",children:"Organization not found"})});if(!u.configuration.isAcceptingOrders||!u.configuration.isOpen){const x=[u.phone,u.email].filter(y=>!!y);return e.jsx("div",{className:"flex flex-col items-center justify-center h-screen w-screen bg-gray-900 text-center animate-fade-in",children:u.configuration.isOpen?e.jsxs("div",{className:"relative z-10 max-w-[800px] px-10",children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-black font-red-hat-display text-white",children:"Unfortunately, We're currently not accepting online orders."}),e.jsxs("p",{className:"text-gray-100 font-medium mt-3 text-lg mt-",children:["Please contact us directly for any inquiries.",x.map(y=>e.jsxs(h.Fragment,{children:[e.jsx("br",{}),y]},y))]}),e.jsx(B,{className:"storefront-primary-action btn-sm mt-6 rounded-lg shrink-0",href:"/",children:"Back to Homepage"})]}):e.jsxs("div",{className:"relative z-10",children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-black font-red-hat-display text-white",children:"Sorry, we're currently closed"}),e.jsxs("p",{className:"text-gray-100 font-medium mt-3 text-lg mt-",children:["Please contact us directly for any inquiries.",x.map(y=>e.jsxs(h.Fragment,{children:[e.jsx("br",{}),y]},y))]}),e.jsx(B,{className:"storefront-primary-action btn-sm mt-6 rounded-lg shrink-0",href:"/",children:"Back to Homepage"})]})})}return e.jsxs(e.Fragment,{children:[e.jsx(Za,{summary:{total:l,subtotal:c,shipping:m,items:o}}),e.jsx("div",{children:e.jsxs("div",{className:"flex flex-col md:flex-row h-screen w-screen relative",children:[e.jsx("div",{className:"hidden md:flex items-center justify-end w-full md:w-1/2 h-full px-16 xl:px-24 bg-gray-900 md:overflow-y-auto",children:e.jsxs("div",{className:"w-96 animate-fade",children:[e.jsx("div",{className:"pl-6",children:e.jsx(gr,{items:o,total:l,subtotal:c,shipping:m,currency:u.configuration.defaultCurrency||"USD"})}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 text-center mt-14 w-full",children:["Powered by"," ",e.jsx("a",{href:"https://shophost.io",className:"storefront-primary-text storefront-primary-text-hover",children:"shophost.io"})]})]})}),e.jsx("div",{className:"flex flex-col items-start 2xl:items-start w-full md:w-1/2 h-full px-6 sm:px-12 xl:px-24 py-8 md:overflow-y-auto relative",children:e.jsx("div",{className:"py-10 xl:py-24 md:my-auto animate-fade w-full md:max-w-[432px]",children:dd(g)})})]})})]})},Ui=({children:a})=>{const{isOpen:t,onClose:r,product:s,modifierGroups:i,hasModifiers:n,productName:o,quantity:l,handleIncrement:c,handleDecrement:m,handleQuantityInput:u,isIncrementDisabled:p,isSubmitting:g,isOutOfStock:x,maxQuantity:y,stockMessage:j,handleAddToCart:f,validationError:b}=Ha();if(!s)return null;const w=l<=1;return a({modifierGroups:i,hasModifiers:n,product:s,isOpen:t,onClose:r,productName:o,quantity:l,onIncrement:c,onDecrement:m,onQuantityInput:u,isDecrementDisabled:w,isIncrementDisabled:p,isSubmitting:g,isOutOfStock:x,maxQuantity:y,stockMessage:j,onAddToCart:f,validationError:b})},Zi=({children:a,group:t,renderOptions:r})=>{const{getModifierGroupName:s}=Ha(),i=s(t),n=t.selectMin>0;let o=null;return t.selectMin>0&&t.selectMax>0&&(o=t.selectMin===t.selectMax?`${t.selectMin} option`:`${t.selectMin}-${t.selectMax}`),a({group:t,groupName:i,isRequired:n,selectionRequirements:o,renderOptions:r})},_i=({children:a,modifier:t,groupId:r})=>{var y;const{isModifierSelected:s,isMultiSelect:i,toggleModifier:n,selectModifier:o,formatModifierPrice:l,product:c,locale:m}=Ha(),u=s(r,t.id),p=(y=c==null?void 0:c.modifierGroups)==null?void 0:y.find(j=>j.id===r),g=p?i(p):!1,x=l(t,(c==null?void 0:c.currency)??"USD");return a({modifier:t,isSelected:u,onSelect:()=>{g?n(r,t.id):o(r,t.id)},isMultiSelect:g,formattedPrice:x})},md=e.jsx("div",{className:"p-4 text-center text-gray-500",children:"This product has no modifiers."}),ud=({addToCartLabel:a="Add to Cart",emptyState:t=md,panelClassName:r,renderFooter:s,renderGroup:i,renderHeader:n,renderOption:o})=>{const{t:l}=qa();return e.jsx(Ui,{children:({isOpen:c,onClose:m,product:u,modifierGroups:p,quantity:g,onIncrement:x,onDecrement:y,isDecrementDisabled:j,isIncrementDisabled:f,isSubmitting:b,isOutOfStock:w,maxQuantity:k,onAddToCart:C,onQuantityInput:F,stockMessage:Q,validationError:O})=>e.jsx(Dt,{open:c,onOpenChange:E=>{E||m()},children:e.jsxs(Rt,{className:v("w-[calc(100vw)] max-w-[calc(100vw)] sm:max-w-md max-h-[75vh] sm:max-h-[90vh] overflow-x-hidden overflow-y-auto p-0 h-min","top-auto left-1/2 right-auto bottom-0 -translate-x-1/2 translate-y-0 rounded-t-xl rounded-b-none border-none","sm:top-1/2 sm:left-1/2 sm:right-auto sm:bottom-auto sm:-translate-x-1/2 sm:-translate-y-1/2 sm:rounded-xl sm:border",r),children:[n?n({onClose:m,product:u}):e.jsxs("div",{className:"flex justify-between items-start pb-3",children:[e.jsx("div",{className:"absolute left-1/2 -translate-x-1/2 top-2 w-12 h-1.5 bg-gray-300 rounded-full sm:hidden"}),e.jsxs("div",{children:[e.jsx(cr,{className:"text-2xl font-black font-red-hat-display",children:u.title}),e.jsx("p",{className:"text-sm text-gray-500",children:u.description})]}),e.jsx("button",{type:"button",onClick:m,className:"cursor-pointer text-gray-500 hover:text-gray-700 text-2xl leading-none","aria-label":"Close modal",children:"×"})]}),p.length>0?e.jsxs("div",{children:[p.map(E=>e.jsx(Zi,{group:E,renderOptions:()=>E.modifiers.map(S=>e.jsx(_i,{modifier:S,groupId:E.id,children:T=>o?o(T):e.jsxs("div",{className:v("mb-1.5 flex cursor-pointer items-center rounded-lg border px-3 py-2 text-sm font-medium text-gray-600 dark:text-gray-400",T.isSelected?"border-blue-500 bg-blue-50":"border-gray-200"),onClick:T.onSelect,children:[e.jsx("input",{type:T.isMultiSelect?"checkbox":"radio",checked:T.isSelected,className:"mr-2",onChange:W=>W.preventDefault()}),e.jsxs("span",{children:[T.modifier.title,T.formattedPrice]})]})},S.id)),children:S=>i?i(S):e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"font-medium mb-2",children:[e.jsxs("div",{className:"flex items-center font-black font-red-hat-display text-lg",children:[S.groupName,S.isRequired&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),S.selectionRequirements&&e.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Select ",S.selectionRequirements]})]}),e.jsx("div",{children:S.renderOptions()})]})},E.id)),(O||Q)&&e.jsx("div",{className:"mb-2 text-sm text-red-500",children:O||Q})]}):t,s?s({isDecrementDisabled:j,isIncrementDisabled:f,isSubmitting:b,isOutOfStock:w,maxQuantity:k,onAddToCart:C,onDecrement:y,onIncrement:x,onQuantityInput:F,quantity:g,stockMessage:Q,validationError:O}):e.jsxs("div",{className:"flex items-center mt-8 border-t pt-4",children:[e.jsx("div",{children:e.jsxs("div",{className:"flex items-center justify-center gap-2.5",children:[e.jsx("button",{type:"button",onClick:y,className:v("flex h-9 min-w-9 items-center justify-center rounded-lg border text-base",j||b?"cursor-not-allowed opacity-50":"cursor-pointer"),"aria-label":"Decrease quantity",disabled:j||b,children:"-"}),e.jsx(De,{min:1,max:w?1:k??void 0,step:1,value:g,onChange:E=>F(E.target.value),disabled:b,inputClassName:"h-9 px-2 text-center",className:"max-w-10 min-w-10","aria-label":"Quantity"}),e.jsx("button",{type:"button",onClick:x,className:v("flex h-9 min-w-9 items-center justify-center rounded-lg border text-base",f||b?"cursor-not-allowed opacity-50":"cursor-pointer"),"aria-label":"Increase quantity",disabled:f||b,children:"+"})]})}),e.jsx("div",{className:"pl-4 sm:pl-5 w-full",children:e.jsx("button",{type:"button",onClick:C,className:"storefront-primary-action btn text-sm rounded-lg w-full",disabled:w||b,children:b?e.jsxs("span",{className:"inline-flex items-center justify-center gap-2",children:[e.jsx(M.RiLoader2Fill,{className:"size-4 animate-spin","aria-hidden":"true"}),l("common.loading")]}):w?"Out of stock":a})})]})]})})})},pd=({children:a,minQuantity:t=1})=>{const{quantity:r,handleIncrement:s,handleDecrement:i,handleQuantityInput:n,isIncrementDisabled:o}=Ha(),l=r<=t;return a({quantity:r,onIncrement:s,onDecrement:i,onQuantityInput:n,isDecrementDisabled:l,isIncrementDisabled:o})},gd=({children:a,locale:t="en"})=>e.jsx(Vs,{locale:t,children:a}),hd=(a,t=[])=>{const[r,s]=h.useState(null),[i,n]=h.useState(!0),[o,l]=h.useState(null),c=JSON.stringify(t.map(m=>m.id));return h.useEffect(()=>{(async()=>{n(!0);try{const m=t.find(u=>u.id===a);if(m)s(m);else throw new Error(`Product with ID ${a} not found`)}catch(m){l(m instanceof Error?m:new Error("Failed to fetch product"))}finally{n(!1)}})()},[a,c]),{product:r,loading:i,error:o}},xd=(a,t=[])=>{const[r,s]=h.useState({}),[i,n]=h.useState(!0),[o,l]=h.useState(null),c=JSON.stringify(a.sort());return h.useEffect(()=>{const m=async()=>{n(!0);try{const u=t.filter(g=>a.includes(g.id)).reduce((g,x)=>(g[x.id]=x,g),{});s(u);const p=a.filter(g=>!u[g]);p.length>0&&console.warn(`Products with IDs ${p.join(", ")} not found`)}catch(u){l(u instanceof Error?u:new Error("Failed to fetch products"))}finally{n(!1)}};a.length>0?m():(s({}),n(!1))},[c,t]),{products:r,getProduct:m=>r[m]||null,loading:i,error:o}},fd=[{id:"product-1",slug:"classic-burger",sku:"BURGER-001",basePrice:12.99,discountedBasePrice:null,currency:"USD",images:[{id:"img-1",url:"https://images.unsplash.com/photo-1568901346375-23c9450c58cd?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1000&q=80",mimeType:"image/jpeg",size:65783,filename:"classic-burger.jpeg"}],modifierGroups:[],categories:[{id:"cat-1",slug:"burgers",createdAt:"2023-01-01T00:00:00.000Z",translations:[{locale:"en",title:"Burgers",description:""},{locale:"pl",title:"Burgery",description:""}]}],manufacturerId:null,createdAt:"2023-01-01T00:00:00.000Z",publishedAt:"2023-01-01T00:00:00.000Z",translations:[{locale:"en",title:"Classic Burger",description:"A juicy beef patty with lettuce, tomato, onion, and our special sauce on a toasted bun."},{locale:"pl",title:"Klasyczny Burger",description:"Soczysta wołowina z sałatą, pomidorem, cebulą i naszym specjalnym sosem na opiekanej bułce."}]},{id:"product-2",slug:"custom-pizza",sku:"PIZZA-001",basePrice:14.99,discountedBasePrice:null,currency:"USD",images:[{id:"img-2",url:"https://images.unsplash.com/photo-1513104890138-7c749659a591?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1000&q=80",mimeType:"image/jpeg",size:75783,filename:"custom-pizza.jpeg"}],modifierGroups:[{id:"mod-group-1",selectMin:1,selectMax:1,modifiers:[{id:"mod-1-1",title:"Thin Crust",sku:null,price:0},{id:"mod-1-2",title:"Regular Crust",sku:null,price:0},{id:"mod-1-3",title:"Thick Crust",sku:null,price:2}],translations:[{locale:"en",title:"Crust Type"},{locale:"pl",title:"Rodzaj Ciasta"}]},{id:"mod-group-2",selectMin:1,selectMax:1,modifiers:[{id:"mod-2-1",title:"Tomato Sauce",sku:null,price:0},{id:"mod-2-2",title:"White Sauce",sku:null,price:0},{id:"mod-2-3",title:"BBQ Sauce",sku:null,price:0}],translations:[{locale:"en",title:"Sauce"},{locale:"pl",title:"Sos"}]}],categories:[{id:"cat-2",slug:"pizza",createdAt:"2023-01-01T00:00:00.000Z",translations:[{locale:"en",title:"Pizza",description:""},{locale:"pl",title:"Pizza",description:""}]}],manufacturerId:null,createdAt:"2023-01-01T00:00:00.000Z",publishedAt:"2023-01-01T00:00:00.000Z",translations:[{locale:"en",title:"Custom Pizza",description:"Build your own pizza with your choice of crust and sauce. Comes with cheese and tomatoes."},{locale:"pl",title:"Pizza Własna",description:"Zbuduj własną pizzę z wybranym rodzajem ciasta i sosu. Zawiera ser i pomidory."}]},{id:"product-3",slug:"build-your-salad",sku:"SALAD-001",basePrice:9.99,discountedBasePrice:null,currency:"USD",images:[{id:"img-3",url:"https://images.unsplash.com/photo-1512621776951-a57141f2eefd?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1000&q=80",mimeType:"image/jpeg",size:55783,filename:"build-your-salad.jpeg"}],modifierGroups:[{id:"mod-group-3",selectMin:0,selectMax:5,modifiers:[{id:"mod-3-1",title:"Grilled Chicken",sku:null,price:2.5},{id:"mod-3-2",title:"Bacon",sku:null,price:1.5},{id:"mod-3-3",title:"Avocado",sku:null,price:2},{id:"mod-3-4",title:"Feta Cheese",sku:null,price:1},{id:"mod-3-5",title:"Boiled Egg",sku:null,price:1}],translations:[{locale:"en",title:"Toppings"},{locale:"pl",title:"Dodatki"}]},{id:"mod-group-4",selectMin:0,selectMax:1,modifiers:[{id:"mod-4-1",title:"Ranch",sku:null,price:0},{id:"mod-4-2",title:"Balsamic Vinaigrette",sku:null,price:0},{id:"mod-4-3",title:"Caesar",sku:null,price:0},{id:"mod-4-4",title:"Olive Oil & Lemon",sku:null,price:0}],translations:[{locale:"en",title:"Dressing"},{locale:"pl",title:"Dressing"}]}],categories:[{id:"cat-3",slug:"salads",createdAt:"2023-01-01T00:00:00.000Z",translations:[{locale:"en",title:"Salads",description:""},{locale:"pl",title:"Sałatki",description:""}]}],manufacturerId:null,createdAt:"2023-01-01T00:00:00.000Z",publishedAt:"2023-01-01T00:00:00.000Z",translations:[{locale:"en",title:"Build Your Salad",description:"Fresh mixed greens with cherry tomatoes, cucumber, and red onion. Add your favorite toppings and dressing."},{locale:"pl",title:"Skomponuj Swoją Sałatkę",description:"Świeże mieszane sałaty z pomidorkami koktajlowymi, ogórkiem i czerwoną cebulą. Dodaj ulubione dodatki i dressing."}]}],yd=new A.QueryClient({defaultOptions:{queries:{retry:!1,refetchInterval:!1,refetchOnWindowFocus:!1}}}),xt="#ffffff",as="#0f172a",$i=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/,bd=/^(?:rgb|rgba|hsl|hsla|oklch|oklab|var)\([^;{}]+\)$/i,jd=/^(?:bg-)?([a-z]+(?:-[a-z]+)*)-(\d{2,3})$/,Yt=Xn,wd=Yt.teal,ts=wd[500],vd=a=>{const t=a.trim();if(t.length===4||t.length===5){const[r,...s]=t;return`${r}${s.map(i=>`${i}${i}`).join("")}`}return t},Wt=a=>{const t=a/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4},rs=a=>{const t=vd(a).slice(1,7),r=Number.parseInt(t.slice(0,2),16),s=Number.parseInt(t.slice(2,4),16),i=Number.parseInt(t.slice(4,6),16);return .2126*Wt(r)+.7152*Wt(s)+.0722*Wt(i)},ss=(a,t)=>{const r=rs(a),s=rs(t),i=Math.max(r,s),n=Math.min(r,s);return(i+.05)/(n+.05)},is=a=>{if($i.test(a)){const r=ss(a,"#ffffff"),s=ss(a,"#000000");return r>=s?xt:as}const t=a.match(/^oklch\(([\d.]+)%/i);return t&&Number.parseFloat(t[1])>=78?as:xt},kd=a=>{const t=a.match(jd);if(t){const[,i,n]=t,o=Yt[i];if(o&&typeof o!="string")return o[n]}const r=a.replace(/^bg-/,""),s=Yt[r];if(typeof s=="string")return s},Nd=a=>{const t=a==null?void 0:a.trim();if(!t)return{color:ts,foreground:xt};const r=kd(t);return r?{color:r,foreground:is(r)}:$i.test(t)||bd.test(t)?{color:t,foreground:is(t)}:{color:ts,foreground:xt}},Ad=a=>{const{color:t,foreground:r}=Nd(a==null?void 0:a.primaryColor);return`:root{--storefront-primary:${t};--storefront-primary-foreground:${r};}`},Cd=({appearance:a,children:t})=>{const r=a!=null&&a.primaryColor?Ad(a):null;return e.jsxs(e.Fragment,{children:[r?e.jsx("style",{"data-shophost-storefront-appearance":!0,suppressHydrationWarning:!0,children:r}):null,t]})},Sd=({appearance:a,baseUrl:t,children:r,initialOrganization:s,locale:i="en",modifiersModal:n,organizationId:o})=>e.jsx(Cd,{appearance:a,children:e.jsx(Ao,{locale:i,children:e.jsx(Ql,{baseURL:t,children:e.jsx(rr,{baseUrl:t,children:e.jsx(A.QueryClientProvider,{client:yd,children:e.jsx(yo,{initialOrganization:s,organizationId:o,children:e.jsx(Ts,{locale:i,organizationId:o,children:e.jsxs(Vs,{locale:i,children:[r,n]})})})})})})})});function U(...a){return js.twMerge(bs(...a))}const Sa=["focus:ring-2","focus:ring-blue-200 dark:focus:ring-blue-700/30","focus:border-blue-500 dark:focus:border-blue-700"],Ae=["outline outline-offset-2 outline-0 focus-visible:outline-2","outline-blue-500 dark:outline-blue-500"],Lt=["ring-2","border-red-500 dark:border-red-700","ring-red-200 dark:ring-red-700/30"],zd=(a,t=0)=>Intl.NumberFormat("us",{minimumFractionDigits:t,maximumFractionDigits:t}).format(Number(a)).toString(),xe={currency:(a,t="USD")=>new Intl.NumberFormat("en-US",{style:"currency",currency:t}).format(a),unit:a=>`${zd(a)}`},Id=Oe.tv({base:["relative inline-flex items-center justify-center whitespace-nowrap rounded-lg border px-3 py-2 text-center text-sm font-medium shadow-xs transition-all duration-100 ease-in-out","disabled:pointer-events-none disabled:shadow-none",Ae],variants:{variant:{primary:["border-transparent","text-white dark:text-white","bg-blue-600 dark:bg-blue-500","shadow-[0_16px_8px_rgba(31,31,31,0.01),0_12px_6px_rgba(31,31,31,0.04),0_4px_4px_rgba(31,31,31,0.07),0_1.5px_3px_rgba(31,31,31,0.08),0_0_0_1px_#2563eb,inset_0_1px_2px_hsla(0,0%,100%,0.12)] dark:outline-0 outline outline-2 outline-transparent outline-offset-2","hover:bg-blue-500 dark:hover:bg-blue-600","disabled:bg-blue-100 disabled:text-gray-400","dark:disabled:bg-blue-800 dark:disabled:text-blue-400"],secondary:["border-gray-200 dark:border-gray-800","text-gray-900 dark:text-gray-50","bg-white dark:bg-gray-950","shadow-[0_1px_1px_0.5px_rgba(51,51,51,.04),0_3px_3px_-1.5px_rgba(51,51,51,.02),0_6px_6px_-3px_rgba(51,51,51,.04),0_12px_12px_-6px_rgba(51,51,51,.04),0_24px_24px_-12px_rgba(51,51,51,.04),0_48px_48px_-24px_rgba(51,51,51,.04),0_0_0_1px_rgba(51,51,51,.1),inset_0_-1px_1px_-0.5px_rgba(51,51,51,.06)] outline outline-2 dark:outline-0 outline-transparent outline-offset-2","hover:bg-gray-50 dark:hover:bg-gray-900/60","disabled:text-gray-400","dark:disabled:text-gray-600"],light:["shadow-none","border-transparent","text-gray-900 dark:text-gray-50","bg-gray-200 dark:bg-gray-900","hover:bg-gray-300/70 dark:hover:bg-gray-800/80","disabled:bg-gray-100 disabled:text-gray-400","dark:disabled:bg-gray-800 dark:disabled:text-gray-600"],ghost:["shadow-none","border-transparent","text-gray-900 dark:text-gray-50","bg-transparent hover:bg-gray-100 dark:hover:bg-gray-800/80","disabled:text-gray-400","dark:disabled:text-gray-600"],destructive:["text-white","border-transparent","bg-red-600 dark:bg-red-700","hover:bg-red-700 dark:hover:bg-red-600","disabled:bg-red-300 disabled:text-white","dark:disabled:bg-red-950 dark:disabled:text-red-400"]}},defaultVariants:{variant:"primary"}}),R=h.forwardRef(({asChild:a,isLoading:t=!1,loadingText:r,className:s,disabled:i,variant:n,children:o,...l},c)=>{const m=a?ar.Slot:"button";return e.jsx(m,{ref:c,className:v(Id({variant:n}),s),disabled:i||t,...l,children:t?e.jsxs("span",{className:"pointer-events-none flex shrink-0 items-center justify-center gap-1.5",children:[e.jsx(M.RiLoader2Fill,{className:"size-4 shrink-0 animate-spin","aria-hidden":"true"}),e.jsx("span",{className:"sr-only",children:r||"Loading"}),r||"Loading"]}):o})});R.displayName="Button";function xr({onReset:a}){return e.jsx("div",{className:"shophost-admin flex h-screen flex-col items-center justify-center gap-4",children:e.jsx("div",{className:"py-8 px-4 mx-auto max-w-(--breakpoint-xl) pb-64 lg:px-6",children:e.jsxs("div",{className:"mx-auto max-w-(--breakpoint-sm) text-center",children:[e.jsx("h1",{className:"mb-4 text-7xl tracking-tight font-extrabold lg:text-9xl text-red-500 dark:text-primary-500",children:"500"}),e.jsx("p",{className:"mb-3 font-red-hat-display text-3xl tracking-tight font-bold text-gray-800 md:text-4xl dark:text-white",children:"Something went wrong"}),e.jsxs("p",{className:"mb-4 text-lg text-gray-500 dark:text-gray-400",children:["We are sorry, but there was an unexpected error. ",e.jsx("br",{}),"Please try reloading the page."]}),a&&e.jsx(R,{className:"mt-3",onClick:a,children:"Reload Page"})]})})})}const Jt=h.createContext({});function Ed({children:a,organizationId:t,id:r}){return e.jsx(Jt.Provider,{value:{organizationId:t,id:r},children:a})}function Dd(){return h.useContext(Jt)}function _(){const{organizationId:a}=h.useContext(Jt);if(!a)throw new Error("useOrgId called outside an org-scoped route");return a}function za(){const{id:a}=h.useContext(Jt);if(!a)throw new Error("useRouteId called outside a detail route");return a}const Rd=h.createContext(void 0),Fd=({children:a,initialState:t=!1})=>{const[r,s]=h.useState(t);return e.jsx(Rd.Provider,{value:{flyoutOpen:r,setFlyoutOpen:s},children:a})},pe=({className:a,...t})=>e.jsxs("svg",{"aria-hidden":"true",className:v("text-gray-200 animate-spin dark:text-gray-600 fill-blue-600",a),viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:[e.jsx("path",{d:"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",fill:"currentColor"}),e.jsx("path",{d:"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",fill:"currentFill"})]}),Wi=h.createContext(null),ns=({children:a})=>{var c,m,u,p,g;const{client:t}=P(),{organizationId:r}=Dd(),s=A.useQuery({queryKey:["organizations"],queryFn:async()=>{const{body:x,status:y}=await t.organization.getOrganizations();if(y!==200)throw y!==401&&J.error("Failed to update organizations list. Please refresh the page or try again later."),new Error("Failed to fetch organizations");return x},retry:!1}),i=A.useQuery({queryKey:["organization",r],queryFn:async()=>{const{body:x,status:y}=await t.organization.getOrganization({params:{organizationId:r}});if(y!==200)throw y!==401&&J.error("Failed to fetch organization. Please try refreshing the page or try again later."),new Error("Failed to fetch organizations");return x},enabled:!!r}),n=((c=i.data)==null?void 0:c.configuration.defaultLocale)??"en",o=((m=i.data)==null?void 0:m.configuration.defaultCurrency)??"USD",l=((p=(u=i.data)==null?void 0:u.configuration.supportedLocales)==null?void 0:p.sort(x=>x===n?-1:1))||["en"];return e.jsx(Wi.Provider,{value:{defaultLocale:n,defaultCurrency:o,supportedLocales:l,organizations:{loading:s.isLoading,data:((g=s.data)==null?void 0:g.list)??[],error:s.isError},organization:{loading:i.isLoading,data:i.data??null,error:i.isError}},children:i.isLoading||s.isLoading?e.jsx("div",{className:"flex justify-center items-center h-screen mt-5",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(pe,{className:"w-12 h-12"}),e.jsx("p",{className:"text-gray-500 text-sm mt-3",children:"Loading data..."})]})}):a})},ke=()=>{const a=h.useContext(Wi);if(!a)throw new Error("useOrganization must be used within a OrganizationProvider");return a},Md="redirect";function Pd(a){return a.startsWith("/")&&!a.startsWith("//")}function Bd(a,t){return a===t||a.startsWith(`${t}/`)}function Vt(a,t){return!a||!Pd(a)||!Bd(a,t.home)||a===t.signIn||a===t.signUp?t.home:a}function fr(a,t){const r=new URLSearchParams({[Md]:t});return`${a}?${r.toString()}`}function Ki(a,t,r){const s=Vt(t,r);return new URL(s,a).toString()}const H=h.forwardRef(({className:a,children:t,...r},s)=>e.jsx("div",{ref:s,className:v("mx-auto my-6 flex w-full items-center justify-between gap-3 text-sm col-span-full","text-gray-500 dark:text-gray-500",a),...r,children:t?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:v("h-[1px] w-full","bg-gray-200 dark:bg-gray-800")}),e.jsx("div",{className:"whitespace-nowrap text-inherit",children:t}),e.jsx("div",{className:v("h-[1px] w-full","bg-gray-200 dark:bg-gray-800")})]}):e.jsx("div",{className:v("h-[0.5px] w-full","bg-gray-200 dark:bg-gray-800")})}));H.displayName="Divider";const Td=Oe.tv({base:["relative block w-full rounded-lg border px-2.5 py-2.5 shadow-xs outline-hidden transition sm:text-sm","border-gray-200 dark:border-gray-800","text-gray-900 dark:text-gray-50","placeholder-gray-400 dark:placeholder-gray-500","bg-white dark:bg-gray-950","disabled:border-gray-300 disabled:bg-gray-100 disabled:text-gray-400","dark:disabled:border-gray-700 dark:disabled:bg-gray-800 dark:disabled:text-gray-500",Sa],variants:{hasError:{true:Lt},enableStepper:{false:"[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none"},multiline:{true:"resize-y min-h-[100px]",false:"truncate appearance-none"}}}),le=h.forwardRef(({className:a,inputClassName:t,hasError:r,enableStepper:s=!0,type:i,multiline:n=!1,prefix:o,suffix:l,copyValue:c,copySuccessMessage:m="Copied to clipboard.",copyErrorMessage:u="Failed to copy to clipboard. Please try again.",...p},g)=>{const[x,y]=h.useState(i),[j,f]=h.useState(!1),b=i==="password"&&!n,w=i==="search"&&!n,k=!!c,C=i==="textarea"?"textarea":"input",F=async()=>{if(c)try{f(!0),await navigator.clipboard.writeText(c),J.success(m)}catch{J.error(u)}finally{f(!1)}};return e.jsxs("div",{className:v("relative w-full",a),children:[o&&e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center px-3 text-slate-600 dark:text-gray-600 z-10 text-sm border-r border-gray-200",children:o}),e.jsx(C,{ref:g,type:b?x:i,className:v(Td({hasError:r,enableStepper:n?!1:s,multiline:n}),{"pl-16":o,"pl-8":!o&&w,"pr-24":k,"pr-10":!k&&(l||!l&&b)},t),...p}),!o&&w&&e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-2 text-gray-400 dark:text-gray-600",children:e.jsx(M.RiSearchLine,{className:"size-[1.125rem]"})}),k&&e.jsx("div",{className:"absolute inset-y-0 right-0 flex items-center pr-1.5",children:e.jsxs(R,{type:"button",variant:"ghost",onClick:F,isLoading:j,loadingText:"Copying...",className:"h-8 cursor-pointer px-2 text-xs hover:text-gray-600 dark:hover:bg-gray-800",children:[e.jsx(N.CopyIcon,{className:"size-4","aria-hidden":"true"}),e.jsx("span",{className:"sr-only",children:"Copy value"})]})}),!k&&l&&e.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2 text-gray-400 dark:text-gray-600",children:l}),!k&&!l&&b&&e.jsx("div",{className:"absolute inset-y-0 right-0 flex items-center pr-3",children:e.jsx("button",{type:"button",onClick:()=>y(x==="password"?"text":"password"),className:v(Ae,"text-gray-400 hover:text-gray-500 dark:text-gray-600"),children:x==="password"?e.jsx(M.RiEyeFill,{className:"size-5"}):e.jsx(M.RiEyeOffFill,{className:"size-5"})})})]})});le.displayName="Input";const me=z.forwardRef(({className:a,disabled:t,...r},s)=>e.jsx(ks.Root,{ref:s,className:U("text-sm leading-none","text-gray-900 dark:text-gray-50",{"text-gray-400 dark:text-gray-600":t},a),"aria-disabled":t,...r}));me.displayName="Label";const Qd=()=>{const a=D.useRouter(),t=D.useSearchParams(),r=Ja(),s=$(),i=r.signIn,n=Vt(t==null?void 0:t.get("redirect"),s),{register:o,handleSubmit:l,formState:{errors:c,isSubmitting:m}}=Z.useForm({resolver:be.zodResolver(si),shouldFocusError:!0}),u=()=>a.push(n),p=async x=>{await i.email({email:x.email,password:x.password,fetchOptions:{onSuccess:u}})},g=async()=>{await i.social({provider:"google",callbackURL:Ki(window.location.origin,n,s)})};return e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex w-full flex-col items-start sm:max-w-sm",children:[e.jsx("div",{className:"relative flex items-center justify-center rounded-lg bg-white p-3 shadow-lg ring-1 ring-black/5",children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:481,zoomAndPan:"magnify",viewBox:"0 0 360.75 362.250002",height:483,preserveAspectRatio:"xMidYMid meet",className:"size-8 text-blue-500 dark:text-blue-500",children:[e.jsxs("defs",{children:[e.jsx("filter",{x:"0%",y:"0%",width:"100%",height:"100%",id:"2330832e18",children:e.jsx("feColorMatrix",{values:"0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0",colorInterpolationFilters:"sRGB"})}),e.jsx("clipPath",{id:"5855bcb1c8",children:e.jsx("path",{d:"M 49 49.945312 L 357 49.945312 L 357 361.257812 L 49 361.257812 Z M 49 49.945312 ",clipRule:"nonzero"})}),e.jsx("clipPath",{id:"2af377de26",children:e.jsx("path",{d:"M 226.65625 348.957031 L 345.746094 229.867188 C 359.820312 215.792969 359.820312 193.058594 345.746094 178.984375 L 228.101562 61.339844 C 220.160156 53.398438 209.515625 49.070312 198.328125 49.070312 L 50.730469 49.070312 L 180.644531 178.984375 C 194.71875 193.058594 194.71875 215.792969 180.644531 229.867188 L 49.285156 361.226562 L 196.882812 361.226562 C 208.070312 361.226562 218.71875 356.714844 226.65625 348.957031 Z M 226.65625 348.957031 ",clipRule:"nonzero"})}),e.jsx("image",{x:0,y:0,width:313,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAATkAAAE5CAYAAADr4VfxAAAABmJLR0QA/wD/AP+gvaeTAAAEKklEQVR4nO3UMQqAMBQFQeP9D51aUYSAIssM/CbwSLdj+4dxcXfvT7eys7Gx+Xbz5l8H+/kBoETkgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSJsw7gNx2VB9PQAAAABJRU5ErkJggg==",id:"dfad2cd726",height:313,preserveAspectRatio:"xMidYMid meet"}),e.jsx("mask",{id:"161eaca8d9",children:e.jsx("g",{filter:"url(#2330832e18)",children:e.jsx("g",{children:e.jsx("image",{x:0,y:0,width:313,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAATkAAAE5CAYAAADr4VfxAAAABmJLR0QA/wD/AP+gvaeTAAAEKklEQVR4nO3UMQqAMBQFQeP9D51aUYSAIssM/CbwSLdj+4dxcXfvT7eys7Gx+Xbz5l8H+/kBoETkgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSJsw7gNx2VB9PQAAAABJRU5ErkJggg==",height:313,preserveAspectRatio:"xMidYMid meet"})})})}),e.jsx("clipPath",{id:"5d3dc395e3",children:e.jsx("rect",{x:0,width:313,y:0,height:313})}),e.jsx("pattern",{id:"2569dd48be",patternUnits:"userSpaceOnUse",width:313,patternTransform:"matrix(0.997934, 0, 0, -0.997934, 48.148759, 361.331903)",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 313 313",height:313,x:0,y:0,children:e.jsx("g",{children:e.jsx("g",{clipPath:"url(#5d3dc395e3)",children:e.jsx("g",{mask:"url(#161eaca8d9)",children:e.jsx("rect",{x:"-127.777762",width:"520.555524",fill:"#8c52ff",height:"522.72",y:"-80.78",fillOpacity:1})})})})}),e.jsx("clipPath",{id:"2302aeb2c7",children:e.jsx("path",{d:"M 0.246094 0.90625 L 308 0.90625 L 308 312.21875 L 0.246094 312.21875 Z M 0.246094 0.90625 ",clipRule:"nonzero"})}),e.jsx("clipPath",{id:"d6b3633872",children:e.jsx("path",{d:"M 177.617188 299.917969 L 296.707031 180.828125 C 310.78125 166.753906 310.78125 144.019531 296.707031 129.945312 L 179.0625 12.300781 C 171.121094 4.363281 160.476562 0.03125 149.289062 0.03125 L 1.691406 0.03125 L 131.605469 129.945312 C 145.679688 144.019531 145.679688 166.753906 131.605469 180.828125 L 0.246094 312.1875 L 147.84375 312.1875 C 159.03125 312.1875 169.679688 307.675781 177.617188 299.917969 Z M 177.617188 299.917969 ",clipRule:"nonzero"})}),e.jsx("image",{x:0,y:0,width:312,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAATgAAAE5CAYAAAAEIzzPAAAABmJLR0QA/wD/AP+gvaeTAAAEKElEQVR4nO3UMQ6AIAAEQfH/j7bGQhqVZDOT0EAudDuO/cbDWb3bvLf76x8bmy83k/N+AVAhcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2RdVgkDcV9ZT24AAAAASUVORK5CYII=",id:"f9fee20a49",height:313,preserveAspectRatio:"xMidYMid meet"}),e.jsx("mask",{id:"8bb974956b",children:e.jsx("g",{filter:"url(#2330832e18)",children:e.jsx("g",{children:e.jsx("image",{x:0,y:0,width:312,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAATgAAAE5CAYAAAAEIzzPAAAABmJLR0QA/wD/AP+gvaeTAAAEKElEQVR4nO3UMQ6AIAAEQfH/j7bGQhqVZDOT0EAudDuO/cbDWb3bvLf76x8bmy83k/N+AVAhcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2RdVgkDcV9ZT24AAAAASUVORK5CYII=",height:313,preserveAspectRatio:"xMidYMid meet"})})})}),e.jsx("clipPath",{id:"4f6b6cd058",children:e.jsx("rect",{x:0,width:312,y:0,height:313})}),e.jsx("pattern",{id:"80e461df2c",patternUnits:"userSpaceOnUse",width:312,patternTransform:"matrix(0.997934, 0, 0, -0.997934, 0.247933, 312.433143)",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 312 313",height:313,x:0,y:0,children:e.jsx("g",{children:e.jsx("g",{clipPath:"url(#4f6b6cd058)",children:e.jsx("g",{mask:"url(#8bb974956b)",children:e.jsx("rect",{x:"-79.777762",width:"520.555524",fill:"#8c52ff",height:"522.72",y:"-129.78",fillOpacity:1})})})})})]}),e.jsx("g",{clipPath:"url(#5855bcb1c8)",children:e.jsx("g",{clipPath:"url(#2af377de26)",children:e.jsx("path",{fill:"url(#2569dd48be)",d:"M 359.820312 361.226562 L 49.289062 361.226562 L 49.289062 49.945312 L 359.820312 49.945312 Z M 359.820312 361.226562 ",fillRule:"nonzero"})})}),e.jsx("g",{clipPath:"url(#2302aeb2c7)",children:e.jsx("g",{clipPath:"url(#d6b3633872)",children:e.jsx("path",{fill:"url(#80e461df2c)",d:"M 310.78125 312.1875 L 0.25 312.1875 L 0.25 0.90625 L 310.78125 0.90625 Z M 310.78125 312.1875 ",fillRule:"nonzero"})})})]})}),e.jsxs("div",{className:"mt-6 flex flex-col",children:[e.jsx("h1",{className:"text-lg font-semibold text-gray-900 dark:text-gray-50",children:"Log in to Shophost"}),e.jsxs("p",{className:"mt-1 text-sm text-gray-700 dark:text-gray-300",children:["Don’t have an account?"," ",e.jsx(B,{className:"text-blue-500 hover:text-blue-600 dark:text-blue-500 dark:hover:text-blue-400",href:fr(s.signUp,n),children:"Sign up"})]})]}),e.jsxs("div",{className:"mt-10 w-full",children:[e.jsx("div",{className:"gap-2 sm:flex sm:flex-row sm:items-center",children:e.jsxs(R,{variant:"secondary",type:"button",className:"mt-2 w-full sm:mt-0 shadow-none inline-flex items-center gap-2",onClick:g,children:[e.jsx(M.RiGoogleFill,{className:"size-4","aria-hidden":"true"}),"Login with Google"]})}),e.jsx(H,{className:"my-6",children:"or"}),e.jsxs("form",{onSubmit:l(p),className:"flex w-full flex-col gap-y-6",children:[e.jsxs("div",{className:"flex flex-col gap-y-4",children:[e.jsxs("div",{className:"flex flex-col space-y-2",children:[e.jsx(me,{htmlFor:"email-form-item",className:"font-medium",children:"Email"}),e.jsx(le,{type:"email",autoComplete:"email",id:"email-form-item",placeholder:"emily.ross@acme.ch",...o("email")}),c.email&&e.jsx("span",{className:"text-sm text-red-500",children:c.email.message})]}),e.jsxs("div",{className:"flex flex-col space-y-2",children:[e.jsx(me,{htmlFor:"password-form-item",className:"font-medium",children:"Password"}),e.jsx(le,{type:"password",autoComplete:"current-password",id:"password-form-item",placeholder:"Password",...o("password")}),c.password&&e.jsx("span",{className:"text-sm text-red-500",children:c.password.message})]})]}),e.jsx(R,{type:"submit",isLoading:m,children:m?"Submitting...":"Continue"})]})]}),e.jsx(H,{}),e.jsxs("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:["Forgot your password?"," ",e.jsx("a",{className:"text-blue-500 hover:text-blue-600 dark:text-blue-500 dark:hover:text-blue-400",href:"#",children:"Reset password"})]})]})})};function Gi({children:a}){const{appearance:t}=Ss(),r=t==null?void 0:t.loginImage;return e.jsxs("div",{className:"flex w-full min-h-screen",children:[r&&e.jsx("div",{className:"hidden lg:block relative w-1/2 overflow-hidden",children:e.jsx(ze,{src:r,alt:"Login Visual",width:4e3,height:2250,className:"w-full h-full object-cover min-h-screen"})}),e.jsx("div",{className:`w-full ${r?"lg:w-1/2":""} flex items-center justify-center p-8`,children:e.jsx("div",{className:"w-full max-w-md space-y-8",children:a})})]})}function Od(){return e.jsx(Gi,{children:e.jsx(Qd,{})})}const Ld=()=>{const a=D.useRouter(),t=D.useSearchParams(),r=Ja(),s=$(),{signIn:i,signUp:n}=r,o=Vt(t==null?void 0:t.get("redirect"),s),{register:l,handleSubmit:c,formState:{errors:m}}=Z.useForm({resolver:be.zodResolver(dr),shouldFocusError:!0}),u=()=>a.push(o),{isPending:p,isError:g,mutate:x}=A.useMutation({onMutate:async j=>n.email({email:j.email,password:j.password,name:`${j.firstname} ${j.lastname}`,firstname:j.firstname,lastname:j.lastname,fetchOptions:{onSuccess:u}})}),y=async()=>i.social({provider:"google",callbackURL:Ki(window.location.origin,o,s)});return e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex w-full flex-col items-start sm:max-w-sm",children:[e.jsx("div",{className:"relative flex items-center justify-center rounded-lg bg-white p-3 shadow-lg ring-1 ring-black/5",children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:481,zoomAndPan:"magnify",viewBox:"0 0 360.75 362.250002",height:483,preserveAspectRatio:"xMidYMid meet",className:"size-8 text-blue-500 dark:text-blue-500",children:[e.jsxs("defs",{children:[e.jsx("filter",{x:"0%",y:"0%",width:"100%",height:"100%",id:"2330832e18",children:e.jsx("feColorMatrix",{values:"0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0",colorInterpolationFilters:"sRGB"})}),e.jsx("clipPath",{id:"5855bcb1c8",children:e.jsx("path",{d:"M 49 49.945312 L 357 49.945312 L 357 361.257812 L 49 361.257812 Z M 49 49.945312 ",clipRule:"nonzero"})}),e.jsx("clipPath",{id:"2af377de26",children:e.jsx("path",{d:"M 226.65625 348.957031 L 345.746094 229.867188 C 359.820312 215.792969 359.820312 193.058594 345.746094 178.984375 L 228.101562 61.339844 C 220.160156 53.398438 209.515625 49.070312 198.328125 49.070312 L 50.730469 49.070312 L 180.644531 178.984375 C 194.71875 193.058594 194.71875 215.792969 180.644531 229.867188 L 49.285156 361.226562 L 196.882812 361.226562 C 208.070312 361.226562 218.71875 356.714844 226.65625 348.957031 Z M 226.65625 348.957031 ",clipRule:"nonzero"})}),e.jsx("image",{x:0,y:0,width:313,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAATkAAAE5CAYAAADr4VfxAAAABmJLR0QA/wD/AP+gvaeTAAAEKklEQVR4nO3UMQqAMBQFQeP9D51aUYSAIssM/CbwSLdj+4dxcXfvT7eys7Gx+Xbz5l8H+/kBoETkgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSJsw7gNx2VB9PQAAAABJRU5ErkJggg==",id:"dfad2cd726",height:313,preserveAspectRatio:"xMidYMid meet"}),e.jsx("mask",{id:"161eaca8d9",children:e.jsx("g",{filter:"url(#2330832e18)",children:e.jsx("g",{children:e.jsx("image",{x:0,y:0,width:313,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAATkAAAE5CAYAAADr4VfxAAAABmJLR0QA/wD/AP+gvaeTAAAEKklEQVR4nO3UMQqAMBQFQeP9D51aUYSAIssM/CbwSLdj+4dxcXfvT7eys7Gx+Xbz5l8H+/kBoETkgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSJsw7gNx2VB9PQAAAABJRU5ErkJggg==",height:313,preserveAspectRatio:"xMidYMid meet"})})})}),e.jsx("clipPath",{id:"5d3dc395e3",children:e.jsx("rect",{x:0,width:313,y:0,height:313})}),e.jsx("pattern",{id:"2569dd48be",patternUnits:"userSpaceOnUse",width:313,patternTransform:"matrix(0.997934, 0, 0, -0.997934, 48.148759, 361.331903)",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 313 313",height:313,x:0,y:0,children:e.jsx("g",{children:e.jsx("g",{clipPath:"url(#5d3dc395e3)",children:e.jsx("g",{mask:"url(#161eaca8d9)",children:e.jsx("rect",{x:"-127.777762",width:"520.555524",fill:"#8c52ff",height:"522.72",y:"-80.78",fillOpacity:1})})})})}),e.jsx("clipPath",{id:"2302aeb2c7",children:e.jsx("path",{d:"M 0.246094 0.90625 L 308 0.90625 L 308 312.21875 L 0.246094 312.21875 Z M 0.246094 0.90625 ",clipRule:"nonzero"})}),e.jsx("clipPath",{id:"d6b3633872",children:e.jsx("path",{d:"M 177.617188 299.917969 L 296.707031 180.828125 C 310.78125 166.753906 310.78125 144.019531 296.707031 129.945312 L 179.0625 12.300781 C 171.121094 4.363281 160.476562 0.03125 149.289062 0.03125 L 1.691406 0.03125 L 131.605469 129.945312 C 145.679688 144.019531 145.679688 166.753906 131.605469 180.828125 L 0.246094 312.1875 L 147.84375 312.1875 C 159.03125 312.1875 169.679688 307.675781 177.617188 299.917969 Z M 177.617188 299.917969 ",clipRule:"nonzero"})}),e.jsx("image",{x:0,y:0,width:312,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAATgAAAE5CAYAAAAEIzzPAAAABmJLR0QA/wD/AP+gvaeTAAAEKElEQVR4nO3UMQ6AIAAEQfH/j7bGQhqVZDOT0EAudDuO/cbDWb3bvLf76x8bmy83k/N+AVAhcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2RdVgkDcV9ZT24AAAAASUVORK5CYII=",id:"f9fee20a49",height:313,preserveAspectRatio:"xMidYMid meet"}),e.jsx("mask",{id:"8bb974956b",children:e.jsx("g",{filter:"url(#2330832e18)",children:e.jsx("g",{children:e.jsx("image",{x:0,y:0,width:312,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAATgAAAE5CAYAAAAEIzzPAAAABmJLR0QA/wD/AP+gvaeTAAAEKElEQVR4nO3UMQ6AIAAEQfH/j7bGQhqVZDOT0EAudDuO/cbDWb3bvLf76x8bmy83k/N+AVAhcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2RdVgkDcV9ZT24AAAAASUVORK5CYII=",height:313,preserveAspectRatio:"xMidYMid meet"})})})}),e.jsx("clipPath",{id:"4f6b6cd058",children:e.jsx("rect",{x:0,width:312,y:0,height:313})}),e.jsx("pattern",{id:"80e461df2c",patternUnits:"userSpaceOnUse",width:312,patternTransform:"matrix(0.997934, 0, 0, -0.997934, 0.247933, 312.433143)",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 312 313",height:313,x:0,y:0,children:e.jsx("g",{children:e.jsx("g",{clipPath:"url(#4f6b6cd058)",children:e.jsx("g",{mask:"url(#8bb974956b)",children:e.jsx("rect",{x:"-79.777762",width:"520.555524",fill:"#8c52ff",height:"522.72",y:"-129.78",fillOpacity:1})})})})})]}),e.jsx("g",{clipPath:"url(#5855bcb1c8)",children:e.jsx("g",{clipPath:"url(#2af377de26)",children:e.jsx("path",{fill:"url(#2569dd48be)",d:"M 359.820312 361.226562 L 49.289062 361.226562 L 49.289062 49.945312 L 359.820312 49.945312 Z M 359.820312 361.226562 ",fillRule:"nonzero"})})}),e.jsx("g",{clipPath:"url(#2302aeb2c7)",children:e.jsx("g",{clipPath:"url(#d6b3633872)",children:e.jsx("path",{fill:"url(#80e461df2c)",d:"M 310.78125 312.1875 L 0.25 312.1875 L 0.25 0.90625 L 310.78125 0.90625 Z M 310.78125 312.1875 ",fillRule:"nonzero"})})})]})}),e.jsxs("div",{className:"mt-6 flex flex-col",children:[e.jsx("h1",{className:"text-lg font-semibold text-gray-900 dark:text-gray-50",children:"Log in to Shophost"}),e.jsxs("p",{className:"mt-1 text-sm text-gray-700 dark:text-gray-300",children:["Already have an account?"," ",e.jsx(B,{className:"text-blue-500 hover:text-blue-600 dark:text-blue-500 dark:hover:text-blue-400",href:fr(s.signIn,o),children:"Sign in"})]})]}),e.jsxs("div",{className:"mt-10 w-full",children:[e.jsx("div",{className:"gap-2 sm:flex sm:flex-row sm:items-center",children:e.jsx(R,{asChild:!0,variant:"secondary",className:"mt-2 w-full sm:mt-0",children:e.jsxs("button",{className:"inline-flex items-center gap-2",onClick:y,children:[e.jsx(M.RiGoogleFill,{className:"size-4","aria-hidden":"true"}),"Signin with Google"]})})}),e.jsx(H,{className:"my-6",children:"or"}),e.jsxs("form",{onSubmit:c(j=>x(j)),className:"flex w-full flex-col gap-y-6",children:[e.jsxs("div",{className:"flex flex-col gap-y-4",children:[e.jsxs("div",{className:"flex flex-col space-y-2",children:[e.jsx(me,{htmlFor:"email-form-item",className:"font-medium",children:"First Name"}),e.jsx(le,{type:"text",id:"email-form-item",placeholder:"Emily",...l("firstname")}),m.firstname&&e.jsx("span",{className:"text-sm text-red-500",children:m.firstname.message})]}),e.jsxs("div",{className:"flex flex-col space-y-2",children:[e.jsx(me,{htmlFor:"email-form-item",className:"font-medium",children:"Last Name"}),e.jsx(le,{type:"text",id:"email-form-item",placeholder:"Emily",...l("lastname")}),m.lastname&&e.jsx("span",{className:"text-sm text-red-500",children:m.lastname.message})]}),e.jsxs("div",{className:"flex flex-col space-y-2",children:[e.jsx(me,{htmlFor:"email-form-item",className:"font-medium",children:"Email"}),e.jsx(le,{type:"email",autoComplete:"email",id:"email-form-item",placeholder:"emily.ross@acme.ch",...l("email")}),m.email&&e.jsx("span",{className:"text-sm text-red-500",children:m.email.message})]}),e.jsxs("div",{className:"flex flex-col space-y-2",children:[e.jsx(me,{htmlFor:"password-form-item",className:"font-medium",children:"Password"}),e.jsx(le,{type:"password",autoComplete:"current-password",id:"password-form-item",placeholder:"Password",...l("password")}),m.password&&e.jsx("span",{className:"text-sm text-red-500",children:m.password.message})]})]}),g&&e.jsx("span",{className:"text-sm text-red-500",children:"An error occurred, please try again."}),e.jsx(R,{type:"submit",isLoading:p,children:p?"Submitting...":"Continue"})]})]}),e.jsx(H,{}),e.jsxs("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:["Forgot your password?"," ",e.jsx("a",{className:"text-blue-500 hover:text-blue-600 dark:text-blue-500 dark:hover:text-blue-400",href:"#",children:"Reset password"})]})]})})};function Jd(){return e.jsx(Gi,{children:e.jsx(Ld,{})})}const pa=h.forwardRef(({className:a,asChild:t,...r},s)=>{const i=t?ar.Slot:"div";return e.jsx(i,{ref:s,className:v("relative w-full rounded-xl border p-6 text-left shadow-xs","bg-white dark:bg-[#090E1A]","border-gray-200 dark:border-gray-900",a),...r})});pa.displayName="Card";const Qa=z.forwardRef(({onClick:a,icon:t,disabled:r,...s},i)=>{const n=t;return e.jsx("button",{ref:i,type:"button",disabled:r,className:v("flex size-8 shrink-0 select-none items-center justify-center rounded border p-1 outline-hidden transition sm:size-[30px]","text-gray-600 hover:text-gray-800","dark:text-gray-400 dark:hover:text-gray-200","border-gray-300 dark:border-gray-800","hover:bg-gray-50 active:bg-gray-100","dark:hover:bg-gray-900 dark:active:bg-gray-800","disabled:pointer-events-none","disabled:border-gray-200 dark:disabled:border-gray-800","disabled:text-gray-400 dark:disabled:text-gray-600",Ae),onClick:a,...s,children:e.jsx(n,{className:"size-full shrink-0"})})});Qa.displayName="NavigationButton";function os({displayMonth:a,displayIndex:t,enableYearNavigation:r,disableNavigation:s,numberOfMonths:i,startMonth:n,endMonth:o}){const l=Ta.useNavigation(),c=a,m=t??0,u=m<=0,p=m===i-1,g=i>1&&(u||!p),x=i>1&&(p||!u),y=l.previousMonth,j=l.nextMonth,f=l.goToMonth,b=!n||I.addYears(c,-1).getTime()>=n.getTime(),w=!o||I.addYears(c,1).getTime()<=o.getTime(),k=()=>{!y||!b||f(I.addYears(c,-1))},C=()=>{!j||!w||f(I.addYears(c,1))};return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[r&&!x&&e.jsx(Qa,{disabled:s||!y||!b,"aria-label":"Go to previous year",onClick:k,icon:M.RiArrowLeftDoubleLine}),!x&&e.jsx(Qa,{disabled:s||!y,"aria-label":"Go to previous month",onClick:()=>y&&f(y),icon:M.RiArrowLeftSLine})]}),e.jsx("div",{role:"presentation","aria-live":"polite",className:"text-sm font-medium capitalize tabular-nums text-gray-900 dark:text-gray-50",children:I.format(c,"LLLL yyy")}),e.jsxs("div",{className:"flex items-center gap-1",children:[!g&&e.jsx(Qa,{disabled:s||!j,"aria-label":"Go to next month",onClick:()=>j&&f(j),icon:M.RiArrowRightSLine}),r&&!g&&e.jsx(Qa,{disabled:s||!j||!w,"aria-label":"Go to next year",onClick:C,icon:M.RiArrowRightDoubleLine})]})]})}const Xi=a=>{const t=a.enableYearNavigation??!1,r=a.weekStartsOn??1,s=a.numberOfMonths??1,i=a.disableNavigation,n=a.fromMonth??(a.fromYear?new Date(a.fromYear,0,1):void 0),o=a.toMonth??(a.toYear?new Date(a.toYear,11,1):void 0),l={months:"flex space-y-0",month:"space-y-4 p-3",caption:"p-4",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"w-9 font-medium text-sm sm:text-xs text-center text-gray-400 dark:text-gray-600 pb-2",row:"mt-0.5 flex w-full",cell:v("relative p-0 text-center focus-within:relative","text-gray-900 dark:text-gray-50"),day:v("size-9 rounded text-sm text-gray-900 focus:z-10 dark:text-gray-50","hover:bg-gray-200 dark:hover:bg-gray-700",Ae),day_today:"font-semibold",day_selected:v("rounded","bg-blue-600 text-gray-50","dark:bg-blue-500 dark:text-gray-50"),day_disabled:"text-gray-300! dark:text-gray-700! line-through hover:bg-transparent",day_outside:"text-gray-400 dark:text-gray-600",day_range_middle:v("rounded-none!","bg-gray-100! text-gray-900!","dark:bg-gray-900! dark:text-gray-50!"),day_range_start:"rounded-r-none rounded-l!",day_range_end:"rounded-l-none rounded-r!",...a.classNames},c={...a.components,Caption:({displayMonth:k,displayIndex:C})=>e.jsx(os,{displayMonth:k,displayIndex:C,enableYearNavigation:t,disableNavigation:i,numberOfMonths:s,startMonth:n,endMonth:o}),Chevron:()=>e.jsx("span",{}),Nav:()=>e.jsx("span",{}),MonthCaption:({calendarMonth:k,displayIndex:C})=>e.jsx(os,{displayMonth:k.date,displayIndex:C,enableYearNavigation:t,disableNavigation:i,numberOfMonths:s,startMonth:n,endMonth:o})},m={weekStartsOn:r,numberOfMonths:s,disableNavigation:i,showOutsideDays:s===1,className:v(a.className),classNames:l,components:c};if(a.mode==="range"){const{enableYearNavigation:k,className:C,classNames:F,components:Q,weekStartsOn:O,numberOfMonths:E,...S}=a,T={...S,...m,mode:"range"};return e.jsx(Ta.DayPicker,{...T})}if(a.mode==="multiple"){const{enableYearNavigation:k,className:C,classNames:F,components:Q,weekStartsOn:O,numberOfMonths:E,...S}=a,T={...S,...m,mode:"multiple"};return e.jsx(Ta.DayPicker,{...T})}if(a.mode==="default"){const{enableYearNavigation:k,className:C,classNames:F,components:Q,weekStartsOn:O,numberOfMonths:E,...S}=a,T={...S,...m,mode:"default"};return e.jsx(Ta.DayPicker,{...T})}const{enableYearNavigation:u,className:p,classNames:g,components:x,mode:y,weekStartsOn:j,numberOfMonths:f,...b}=a,w={...b,...m,mode:"single"};return e.jsx(Ta.DayPicker,{...w})};Xi.displayName="Calendar";const Vd=()=>{const a=typeof window<"u"?window.navigator.language:"en-US",t=new Intl.DateTimeFormat(a,{hour:"numeric"}).format();return Number.isInteger(Number(t))},qd=({segment:a,state:t})=>{const r=z.useRef(null),{segmentProps:s}=ws.useDateSegment(a,t,r),i=a.type==="literal"&&a.text===":",n=a.type==="literal"&&a.text===" ",o=i||n;return e.jsxs("div",{...s,ref:r,className:U("relative block w-full appearance-none rounded-md border px-2.5 py-1.5 text-left uppercase tabular-nums shadow-xs outline-hidden transition sm:text-sm","border-gray-300 dark:border-gray-800","text-gray-900 dark:text-gray-50","bg-white dark:bg-gray-950",Sa,"invalid:border-red-500 invalid:ring-2 invalid:ring-red-200 group-aria-invalid/time-input:border-red-500 group-aria-invalid/time-input:ring-2 group-aria-invalid/time-input:ring-red-200 dark:group-aria-invalid/time-input:ring-red-400/20",{"w-fit! border-none bg-transparent px-0 text-gray-400 shadow-none":o,hidden:n,"border-gray-300 bg-gray-100 text-gray-400 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-500":t.isDisabled,"bg-transparent! text-gray-400!":!a.isEditable}),children:[e.jsx("span",{"aria-hidden":"true",className:U("pointer-events-none block w-full text-left text-gray-700 sm:text-sm",{hidden:!a.isPlaceholder,"h-0":!a.isPlaceholder}),children:a.placeholder}),a.isPlaceholder?" ":a.text]})},er=z.forwardRef(({hourCycle:a,...t},r)=>{const s=z.useRef(null);z.useImperativeHandle(r,()=>s==null?void 0:s.current);const i=window!==void 0?window.navigator.language:"en-US",n=Zn.useTimeFieldState({hourCycle:a,locale:i,shouldForceLeadingZeros:!0,autoFocus:!0,...t}),{fieldProps:o}=ws.useTimeField({...t,hourCycle:a,shouldForceLeadingZeros:!0},n,s);return e.jsx("div",{...o,ref:s,className:"group/time-input inline-flex w-full gap-x-2",children:n.segments.map((l,c)=>e.jsx(qd,{segment:l,state:n},c))})});er.displayName="TimeInput";const Hd=Oe.tv({base:["peer flex w-full cursor-pointer appearance-none items-center gap-x-2 truncate rounded-md border px-3 py-2 shadow-xs outline-hidden transition-all sm:text-sm","bg-white dark:bg-gray-950","border-gray-300 dark:border-gray-800","text-gray-900 dark:text-gray-50","placeholder-gray-400 dark:placeholder-gray-500","hover:bg-gray-50 dark:hover:bg-gray-950/50","disabled:pointer-events-none","disabled:bg-gray-100 disabled:text-gray-400","dark:disabled:border-gray-800 dark:disabled:bg-gray-800 dark:disabled:text-gray-500",Sa],variants:{hasError:{true:Lt}}}),Yi=z.forwardRef(({className:a,children:t,placeholder:r,hasError:s,...i},n)=>e.jsx(se.Trigger,{asChild:!0,children:e.jsxs("button",{ref:n,className:U(Hd({hasError:s}),a),...i,children:[e.jsx(M.RiCalendar2Fill,{className:"size-5 shrink-0 text-gray-400 dark:text-gray-600"}),e.jsx("span",{className:"flex-1 overflow-hidden text-ellipsis whitespace-nowrap text-left text-gray-900 dark:text-gray-50",children:t||(r?e.jsx("span",{className:"text-gray-400 dark:text-gray-600",children:r}):null)})]})}));Yi.displayName="DatePicker.Trigger";const en=z.forwardRef(({align:a,className:t,children:r,...s},i)=>e.jsx(se.Portal,{children:e.jsx(se.Content,{ref:i,sideOffset:10,side:"bottom",align:a,avoidCollisions:!0,onOpenAutoFocus:n=>n.preventDefault(),className:U("relative z-50 w-fit rounded-md border text-sm shadow-xl shadow-black/[2.5%]","min-w-[calc(var(--radix-select-trigger-width)-2px)] max-w-[95vw]","border-gray-200 dark:border-gray-800","bg-white dark:bg-gray-950","will-change-[transform,opacity]","data-[state=closed]:animate-hide","data-[state=open]:data-[side=bottom]:animate-slideDownAndFade data-[state=open]:data-[side=left]:animate-slideLeftAndFade data-[state=open]:data-[side=right]:animate-slideRightAndFade data-[state=open]:data-[side=top]:animate-slideUpAndFade",t),...s,children:r})}));en.displayName="DatePicker.CalendarPopover";const an=({presets:a,onSelect:t,currentValue:r})=>{const s=m=>"dateRange"in m,i=m=>"date"in m,n=m=>{s(m)?t(m.dateRange):i(m)&&t(m.date)},o=(m,u)=>m.getDate()===u.getDate()&&m.getMonth()===u.getMonth()&&m.getFullYear()===u.getFullYear(),l=(m,u)=>{const p=m.from,g=u.from;let x=!1;p&&g&&o(p,g)&&(x=!0);const y=m.to,j=u.to;let f=!1;return y&&j&&o(y,j)&&(f=!0),x&&f},c=m=>{if(s(m)){const u=r;return u&&l(u,m.dateRange)}else if(i(m)){const u=r;return u&&o(u,m.date)}return!1};return e.jsx("ul",{className:"flex items-start gap-x-2 sm:flex-col",children:a.map((m,u)=>e.jsx("li",{className:"sm:w-full sm:py-px",children:e.jsx("button",{title:m.label,className:U("relative w-full overflow-hidden text-ellipsis whitespace-nowrap rounded border px-2.5 py-1.5 text-left text-base shadow-xs outline-hidden transition-all sm:border-none sm:py-2 sm:text-sm sm:shadow-none","text-gray-700 dark:text-gray-300","border-gray-200 dark:border-gray-800",Ae,"focus-visible:bg-gray-100 dark:focus-visible:bg-gray-900","hover:bg-gray-100 dark:hover:bg-gray-900",{"bg-gray-100 dark:bg-gray-900":c(m)}),onClick:()=>n(m),"aria-label":`Select ${m.label}`,children:e.jsx("span",{children:m.label})})},u))})};an.displayName="DatePicker.PresetContainer";const ls=(a,t,r)=>{const s=!Vd();let i;return r?i=s?I.format(a,"dd MMM, yyyy h:mm a",{locale:t}):I.format(a,"dd MMM, yyyy HH:mm",{locale:t}):i=I.format(a,"dd MMM, yyyy",{locale:t}),i},Ud=({defaultValue:a,value:t,onChange:r,presets:s,disabled:i,disableNavigation:n,disabledDays:o,enableYearNavigation:l=!1,locale:c=_n.enUS,showTimePicker:m,placeholder:u="Select date range",hasError:p,translations:g,align:x="center",className:y,...j})=>{const[f,b]=z.useState(!1),[w,k]=z.useState(t??a??void 0),[C,F]=z.useState(w==null?void 0:w.from),[Q,O]=z.useState(t!=null&&t.from?new he.Time(t.from.getHours(),t.from.getMinutes()):a!=null&&a.from?new he.Time(a.from.getHours(),a.from.getMinutes()):new he.Time(0,0)),[E,S]=z.useState(t!=null&&t.to?new he.Time(t.to.getHours(),t.to.getMinutes()):a!=null&&a.to?new he.Time(a.to.getHours(),a.to.getMinutes()):new he.Time(0,0)),T=z.useMemo(()=>w,[f]);z.useEffect(()=>{k(t??a??void 0)},[t,a]),z.useEffect(()=>{w&&F(w.from)},[w]),z.useEffect(()=>{f||F(w==null?void 0:w.from)},[f]);const W=X=>{const Y=X;m&&(Y!=null&&Y.from&&!Q&&O(new he.Time(0,0)),Y!=null&&Y.to&&!E&&S(new he.Time(0,0)),Y!=null&&Y.from&&Q&&(Y.from.setHours(Q.hour),Y.from.setMinutes(Q.minute)),Y!=null&&Y.to&&E&&(Y.to.setHours(E.hour),Y.to.setMinutes(E.minute))),k(Y)},fe=()=>{k(T),O(T!=null&&T.from?new he.Time(T.from.getHours(),T.from.getMinutes()):new he.Time(0,0)),S(T!=null&&T.to?new he.Time(T.to.getHours(),T.to.getMinutes()):new he.Time(0,0)),b(!1)},Je=X=>{X||fe(),b(X)},ce=(X,Y)=>{switch(Y){case"start":O(X);break;case"end":S(X);break}if(w){if(Y==="start"){if(!w.from)return;const ie=new Date(w.from.getTime());X?(ie.setHours(X.hour),ie.setMinutes(X.minute)):(ie.setHours(0),ie.setMinutes(0)),k({...w,from:ie})}if(Y==="end"){if(!w.to)return;const ie=new Date(w.to.getTime());X?(ie.setHours(X.hour),ie.setMinutes(X.minute)):(ie.setHours(0),ie.setMinutes(0)),k({...w,to:ie})}}};z.useEffect(()=>{k(t??a??void 0),O(t!=null&&t.from?new he.Time(t.from.getHours(),t.from.getMinutes()):a!=null&&a.from?new he.Time(a.from.getHours(),a.from.getMinutes()):new he.Time(0,0)),S(t!=null&&t.to?new he.Time(t.to.getHours(),t.to.getMinutes()):a!=null&&a.to?new he.Time(a.to.getHours(),a.to.getMinutes()):new he.Time(0,0))},[t,a]);const na=z.useMemo(()=>w?`${w.from?ls(w.from,c,m):""} - ${w.to?ls(w.to,c,m):""}`:null,[w,c,m]),Ce=()=>{b(!1),r==null||r(w)};return e.jsxs(se.Root,{"tremor-id":"tremor-raw",open:f,onOpenChange:Je,children:[e.jsx(Yi,{placeholder:u,disabled:i,className:y,hasError:p,"aria-required":j.required||j["aria-required"],"aria-invalid":j["aria-invalid"],"aria-label":j["aria-label"],"aria-labelledby":j["aria-labelledby"],children:na}),e.jsx(en,{align:x,children:e.jsx("div",{className:"flex",children:e.jsxs("div",{className:"flex flex-col overflow-x-auto sm:flex-row sm:items-start",children:[s&&s.length>0&&e.jsx("div",{className:U("relative flex h-16 w-full items-center sm:h-full sm:w-40","border-b border-gray-200 sm:border-b-0 sm:border-r dark:border-gray-800","overflow-auto"),children:e.jsx("div",{className:"absolute px-3 sm:inset-0 sm:left-0 sm:p-2",children:e.jsx(an,{currentValue:w,presets:s,onSelect:W})})}),e.jsxs("div",{className:"overflow-x-auto",children:[e.jsx(Xi,{mode:"range",selected:w,onSelect:W,month:C,onMonthChange:F,numberOfMonths:2,disabled:o,disableNavigation:n,enableYearNavigation:l,locale:c,initialFocus:!0,classNames:{months:"flex flex-row divide-x divide-gray-200 dark:divide-gray-800 overflow-x-auto"},...j}),m&&e.jsxs("div",{className:"flex items-center justify-evenly gap-x-3 border-t border-gray-200 p-3 dark:border-gray-800",children:[e.jsxs("div",{className:"flex flex-1 items-center gap-x-2",children:[e.jsxs("span",{className:"dark:text-gray-30 text-gray-700",children:[(g==null?void 0:g.start)??"Start",":"]}),e.jsx(er,{value:Q,onChange:X=>ce(X,"start"),"aria-label":"Start date time",isDisabled:!(w!=null&&w.from),isRequired:j.required})]}),e.jsx(M.RiSubtractFill,{className:"size-4 shrink-0 text-gray-400"}),e.jsxs("div",{className:"flex flex-1 items-center gap-x-2",children:[e.jsxs("span",{className:"dark:text-gray-30 text-gray-700",children:[(g==null?void 0:g.end)??"End",":"]}),e.jsx(er,{value:E,onChange:X=>ce(X,"end"),"aria-label":"End date time",isDisabled:!(w!=null&&w.to),isRequired:j.required})]})]}),e.jsxs("div",{className:"border-t border-gray-200 p-3 sm:flex sm:items-center sm:justify-between dark:border-gray-800",children:[e.jsxs("p",{className:"tabular-nums text-gray-900 dark:text-gray-50",children:[e.jsxs("span",{className:"text-gray-700 dark:text-gray-300",children:[(g==null?void 0:g.range)??"Range",":"]})," ",e.jsx("span",{className:"font-medium",children:na})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-x-2 sm:mt-0",children:[e.jsx(R,{variant:"secondary",className:"h-8 w-full sm:w-fit",type:"button",onClick:fe,children:(g==null?void 0:g.cancel)??"Cancel"}),e.jsx(R,{variant:"primary",className:"h-8 w-full sm:w-fit",type:"button",onClick:Ce,children:(g==null?void 0:g.apply)??"Apply"})]})]})]})]})})})]})},Zd=(a,t)=>{const{toYear:r,fromYear:s,fromMonth:i,toMonth:n,fromDay:o,toDay:l}=t;if(a&&a.length>0){const c=s,m=r;a.forEach(u=>{var p,g,x,y,j,f;if("date"in u){const b=u.date.getFullYear();if(s&&b<s)throw new Error(`Preset ${u.label} is before fromYear ${c}.`);if(r&&b>r)throw new Error(`Preset ${u.label} is after toYear ${m}.`);if(i&&u.date.getMonth()<i.getMonth())throw new Error(`Preset ${u.label} is before fromMonth ${i}.`);if(n&&u.date.getMonth()>n.getMonth())throw new Error(`Preset ${u.label} is after toMonth ${n}.`);if(o&&u.date.getDate()<o.getDate())throw new Error(`Preset ${u.label} is before fromDay ${o}.`);if(l&&u.date.getDate()>l.getDate())throw new Error(`Preset ${u.label} is after toDay ${I.format(l,"MMM dd, yyyy")}.`)}if("dateRange"in u){const b=(p=u.dateRange.from)==null?void 0:p.getFullYear(),w=(g=u.dateRange.to)==null?void 0:g.getFullYear();if(b&&s&&b<s)throw new Error(`Preset ${u.label}'s 'from' is before fromYear ${c}.`);if(w&&r&&w>r)throw new Error(`Preset ${u.label}'s 'to' is after toYear ${m}.`);if(i){const k=(x=u.dateRange.from)==null?void 0:x.getMonth();if(k&&k<i.getMonth())throw new Error(`Preset ${u.label}'s 'from' is before fromMonth ${I.format(i,"MMM, yyyy")}.`)}if(n){const k=(y=u.dateRange.to)==null?void 0:y.getMonth();if(k&&k>n.getMonth())throw new Error(`Preset ${u.label}'s 'to' is after toMonth ${I.format(n,"MMM, yyyy")}.`)}if(o){const k=(j=u.dateRange.from)==null?void 0:j.getDate();if(k&&k<o.getDate())throw new Error(`Preset ${u.dateRange.from}'s 'from' is before fromDay ${I.format(o,"MMM dd, yyyy")}.`)}if(l){const k=(f=u.dateRange.to)==null?void 0:f.getDate();if(k&&k>l.getDate())throw new Error(`Preset ${u.label}'s 'to' is after toDay ${I.format(l,"MMM dd, yyyy")}.`)}}})}},tn=({presets:a,...t})=>(a&&Zd(a,t),e.jsx(Ud,{presets:a,...t}));tn.displayName="DateRangePicker";const _d=new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:1}),$d={bank_transfer:"Bank transfer",blik:"BLIK",card:"Card",cash_on_delivery:"Cash on delivery",paypal:"PayPal"},Wd={delivery:"Delivery",pickup:"Pickup"},$a=["#0f766e","#fb923c"],Wa=a=>typeof a=="number"?a:typeof a=="string"?Number(a):Array.isArray(a)&&a.length>0?Number(a[0]):0;function Kd(){const{client:a}=P(),t=_(),r=h.useMemo(()=>new Date,[]),[s,i]=h.useState({from:I.subDays(r,29),to:r}),n=h.useMemo(()=>{const f=(s==null?void 0:s.from)??I.subDays(r,29),b=(s==null?void 0:s.to)??(s==null?void 0:s.from)??r;return{from:I.startOfDay(f),to:I.endOfDay(b)}},[s,r]),{data:o,error:l,isError:c,isLoading:m,isRefetching:u,refetch:p}=A.useQuery({queryKey:["dashboard-overview",t,n.from.toISOString(),n.to.toISOString()],queryFn:async()=>{const{body:f,status:b}=await a.analytics.getOverview({params:{organizationId:t},query:{from:n.from.toISOString(),to:n.to.toISOString()}});if(b!==200||!f)throw new Error("Failed to fetch dashboard overview");return f},placeholderData:A.keepPreviousData}),g=(o==null?void 0:o.summary.currency)??"USD",x=((o==null?void 0:o.paymentMethods)??[]).map(f=>({...f,label:$d[f.method]??f.method})),y=((o==null?void 0:o.fulfilmentMethods)??[]).map(f=>({...f,label:Wd[f.method]??f.method})),j=y.reduce((f,b)=>f+b.count,0);return e.jsxs("section",{"aria-labelledby":"dashboard-overview",children:[e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-end lg:justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold text-gray-900 sm:text-2xl dark:text-gray-50",children:"Overview"}),e.jsx("p",{className:"mt-1 text-sm text-gray-600 dark:text-gray-400",children:"Live store performance across orders, reservations, and payment behaviour."})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[u?e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Updating…"}):null,e.jsx(tn,{value:s,onChange:i,className:"w-full sm:w-fit",toDate:r,align:"end"})]})]}),c&&!o?e.jsx(pa,{className:"mt-8 border-red-200 dark:border-red-950",children:e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-50",children:"Dashboard data unavailable"}),e.jsx("p",{className:"mt-1 text-sm text-gray-600 dark:text-gray-400",children:l instanceof Error?l.message:"We could not load the dashboard metrics for this range."})]}),e.jsxs(R,{onClick:()=>p(),className:"gap-2",children:[e.jsx(M.RiRefreshLine,{className:"size-4","aria-hidden":"true"}),"Retry"]})]})}):null,e.jsx("div",{className:"mt-8 grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-4",children:m&&!o?Array.from({length:4}).map((f,b)=>e.jsx(Pa,{className:"h-[148px]"},b)):o?e.jsxs(e.Fragment,{children:[e.jsx(Ka,{icon:M.RiMoneyDollarCircleLine,title:"Paid sales",value:xe.currency(o.summary.totalSales,g),description:"Successful payments in the selected range"}),e.jsx(Ka,{icon:M.RiShoppingBag3Line,title:"Paid orders",value:xe.unit(o.summary.paidOrders),description:`Average order value ${xe.currency(o.summary.averageOrderValue,g)}`}),e.jsx(Ka,{icon:M.RiCalendarCheckLine,title:"Reservations",value:xe.unit(o.summary.reservations),description:"Scheduled reservations in the selected range"}),e.jsx(Ka,{icon:M.RiGroupLine,title:"Reserved guests",value:xe.unit(o.summary.guests),description:"Total covers booked from reservations"})]}):null}),e.jsx("div",{className:"mt-4 grid grid-cols-1 gap-4 xl:grid-cols-2",children:m&&!o?e.jsxs(e.Fragment,{children:[e.jsx(Pa,{className:"h-[360px]"}),e.jsx(Pa,{className:"h-[360px]"})]}):o?e.jsxs(e.Fragment,{children:[e.jsx(Ga,{title:"Paid sales by day",value:xe.currency(o.summary.totalSales,g),description:"Gross paid revenue recognised on each order day.",children:e.jsx(ae.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ae.AreaChart,{data:o.salesByDay,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"salesGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#0f766e",stopOpacity:.28}),e.jsx("stop",{offset:"95%",stopColor:"#0f766e",stopOpacity:.02})]})}),e.jsx(ae.CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb",vertical:!1}),e.jsx(ae.XAxis,{dataKey:"label",axisLine:!1,tickLine:!1,tick:{fill:"#6b7280",fontSize:12}}),e.jsx(ae.YAxis,{axisLine:!1,tickLine:!1,width:48,tickFormatter:f=>_d.format(f),tick:{fill:"#6b7280",fontSize:12}}),e.jsx(ae.Tooltip,{formatter:(f,b)=>{const w=Wa(f);return[String(b)==="totalSales"?xe.currency(w,g):xe.unit(w),String(b)==="totalSales"?"Sales":"Paid orders"]},contentStyle:Xa,labelStyle:Ya}),e.jsx(ae.Area,{type:"monotone",dataKey:"totalSales",stroke:"#0f766e",strokeWidth:2.5,fill:"url(#salesGradient)",name:"totalSales"})]})})}),e.jsx(Ga,{title:"Reservations per day",value:xe.unit(o.summary.reservations),description:"Bookings are grouped by reservation date, not submission time.",children:e.jsx(ae.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ae.BarChart,{data:o.reservationsByDay,children:[e.jsx(ae.CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb",vertical:!1}),e.jsx(ae.XAxis,{dataKey:"label",axisLine:!1,tickLine:!1,tick:{fill:"#6b7280",fontSize:12}}),e.jsx(ae.YAxis,{allowDecimals:!1,axisLine:!1,tickLine:!1,width:36,tick:{fill:"#6b7280",fontSize:12}}),e.jsx(ae.Tooltip,{formatter:(f,b)=>[xe.unit(Wa(f)),String(b)==="guests"?"Guests":"Reservations"],contentStyle:Xa,labelStyle:Ya}),e.jsx(ae.Bar,{dataKey:"reservations",name:"reservations",fill:"#fb923c",radius:[8,8,0,0]})]})})})]}):null}),e.jsx("div",{className:"mt-4 grid grid-cols-1 gap-4 xl:grid-cols-2",children:m&&!o?e.jsxs(e.Fragment,{children:[e.jsx(Pa,{className:"h-[320px]"}),e.jsx(Pa,{className:"h-[320px]"})]}):o?e.jsxs(e.Fragment,{children:[e.jsx(Ga,{title:"Payment methods",value:xe.unit(x.reduce((f,b)=>f+b.count,0)),description:"Successful orders grouped by how guests paid.",children:x.length>0?e.jsx(ae.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ae.BarChart,{data:x,layout:"vertical",margin:{left:12,right:12},children:[e.jsx(ae.CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb",horizontal:!1}),e.jsx(ae.XAxis,{type:"number",allowDecimals:!1,axisLine:!1,tickLine:!1,tick:{fill:"#6b7280",fontSize:12}}),e.jsx(ae.YAxis,{dataKey:"label",type:"category",axisLine:!1,tickLine:!1,width:110,tick:{fill:"#374151",fontSize:12}}),e.jsx(ae.Tooltip,{formatter:(f,b,w)=>{const k=Wa(f),C=w&&typeof w=="object"&&"payload"in w?w.payload:{totalSales:0};return String(b)==="count"?[xe.unit(k),"Orders"]:[xe.currency(C.totalSales,g),"Sales"]},contentStyle:Xa,labelStyle:Ya}),e.jsx(ae.Bar,{dataKey:"count",name:"count",fill:"#2563eb",radius:[0,8,8,0]})]})}):e.jsx(ds,{message:"No paid orders in the selected range."})}),e.jsx(Ga,{title:"Fulfilment mix",value:xe.unit(j),description:"Non-cancelled orders split by delivery and pickup.",children:j>0?e.jsxs("div",{className:"grid h-full grid-cols-1 gap-4 md:grid-cols-[1.2fr_0.8fr]",children:[e.jsx(ae.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ae.PieChart,{children:[e.jsx(ae.Pie,{data:y,dataKey:"count",nameKey:"label",innerRadius:68,outerRadius:100,paddingAngle:4,children:y.map((f,b)=>e.jsx(ae.Cell,{fill:$a[b%$a.length]},f.method))}),e.jsx(ae.Tooltip,{formatter:(f,b,w)=>{const k=Wa(f),C=w&&typeof w=="object"&&"payload"in w?w.payload:{label:"Orders"};return[`${xe.unit(k)} orders`,C.label]},contentStyle:Xa,labelStyle:Ya})]})}),e.jsx("div",{className:"flex flex-col justify-center gap-3",children:y.map((f,b)=>e.jsxs("div",{className:"rounded-lg border border-gray-200 p-4 dark:border-gray-800",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"size-2.5 rounded-full",style:{backgroundColor:$a[b%$a.length]}}),e.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-gray-50",children:f.label})]}),e.jsxs("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:[Math.round(f.count/j*100),"%"]})]}),e.jsx("div",{className:"mt-2 text-lg font-semibold text-gray-900 dark:text-gray-50",children:xe.unit(f.count)}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:xe.currency(f.totalSales,g)})]},f.method))})]}):e.jsx(ds,{message:"No orders in the selected range."})})]}):null})]})}function Ka({description:a,icon:t,title:r,value:s}){return e.jsx(pa,{className:"overflow-hidden",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-600 dark:text-gray-400",children:r}),e.jsx("p",{className:"mt-3 text-3xl font-bold tracking-tight text-gray-900 dark:text-gray-50 font-red-hat-display",children:s}),e.jsx("p",{className:"mt-2 max-w-xs text-sm text-gray-500 dark:text-gray-400",children:a})]}),e.jsx("div",{className:"rounded-full bg-gray-100 p-3 text-gray-700 dark:bg-gray-900 dark:text-gray-200",children:e.jsx(t,{className:"size-5","aria-hidden":"true"})})]})})}function Ga({children:a,description:t,title:r,value:s}){return e.jsxs(pa,{className:"flex min-h-[320px] flex-col",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-50",children:r}),e.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:t})]}),e.jsx("div",{className:"text-right",children:e.jsx("p",{className:"text-2xl font-bold tracking-tight text-gray-900 dark:text-gray-50 font-red-hat-display",children:s})})]}),e.jsx("div",{className:"mt-6 min-h-[220px] flex-1",children:a})]})}function Pa({className:a}){return e.jsx(pa,{className:U("animate-pulse",a),children:e.jsx("div",{className:"h-full rounded-xl bg-gray-100 dark:bg-gray-900"})})}function ds({message:a}){return e.jsx("div",{className:"flex h-full items-center justify-center rounded-xl border border-dashed border-gray-200 bg-gray-50 text-sm text-gray-500 dark:border-gray-800 dark:bg-gray-950 dark:text-gray-400",children:a})}const Xa={border:"1px solid #e5e7eb",borderRadius:"12px",boxShadow:"0 10px 30px rgba(15, 23, 42, 0.08)",backgroundColor:"#ffffff"},Ya={color:"#111827",fontWeight:600},rn=(a,t,r)=>{if(a==null)return r;const s=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split(".").filter(Boolean);let i=a;for(let n=0;n<s.length;n++){const o=s[n];if(i==null||!(o in i))return r;i=i[o]}return i===void 0?r:i},cs=[{continent:"America",items:[{value:"US",label:"United States",flag:"🇺🇸"},{value:"CA",label:"Canada",flag:"🇨🇦"},{value:"MX",label:"Mexico",flag:"🇲🇽"},{value:"BR",label:"Brazil",flag:"🇧🇷"},{value:"AR",label:"Argentina",flag:"🇦🇷"},{value:"CO",label:"Colombia",flag:"🇨🇴"},{value:"CL",label:"Chile",flag:"🇨🇱"},{value:"PE",label:"Peru",flag:"🇵🇪"}]},{continent:"Europe",items:[{value:"GB",label:"United Kingdom",flag:"🇬🇧"},{value:"FR",label:"France",flag:"🇫🇷"},{value:"DE",label:"Germany",flag:"🇩🇪"},{value:"PL",label:"Poland",flag:"🇵🇱"},{value:"IT",label:"Italy",flag:"🇮🇹"},{value:"ES",label:"Spain",flag:"🇪🇸"},{value:"NL",label:"Netherlands",flag:"🇳🇱"},{value:"PT",label:"Portugal",flag:"🇵🇹"},{value:"SE",label:"Sweden",flag:"🇸🇪"},{value:"NO",label:"Norway",flag:"🇳🇴"},{value:"DK",label:"Denmark",flag:"🇩🇰"},{value:"FI",label:"Finland",flag:"🇫🇮"},{value:"CH",label:"Switzerland",flag:"🇨🇭"},{value:"IE",label:"Ireland",flag:"🇮🇪"},{value:"BE",label:"Belgium",flag:"🇧🇪"},{value:"AT",label:"Austria",flag:"🇦🇹"},{value:"GR",label:"Greece",flag:"🇬🇷"}]},{continent:"Asia",items:[{value:"CN",label:"China",flag:"🇨🇳"},{value:"JP",label:"Japan",flag:"🇯🇵"},{value:"IN",label:"India",flag:"🇮🇳"},{value:"KR",label:"South Korea",flag:"🇰🇷"},{value:"SG",label:"Singapore",flag:"🇸🇬"},{value:"MY",label:"Malaysia",flag:"🇲🇾"},{value:"ID",label:"Indonesia",flag:"🇮🇩"},{value:"TH",label:"Thailand",flag:"🇹🇭"},{value:"VN",label:"Vietnam",flag:"🇻🇳"},{value:"AE",label:"United Arab Emirates",flag:"🇦🇪"},{value:"SA",label:"Saudi Arabia",flag:"🇸🇦"}]},{continent:"Oceania",items:[{value:"AU",label:"Australia",flag:"🇦🇺"},{value:"NZ",label:"New Zealand",flag:"🇳🇿"},{value:"FJ",label:"Fiji",flag:"🇫🇯"},{value:"PG",label:"Papua New Guinea",flag:"🇵🇬"}]},{continent:"Africa",items:[{value:"ZA",label:"South Africa",flag:"🇿🇦"},{value:"NG",label:"Nigeria",flag:"🇳🇬"},{value:"MA",label:"Morocco",flag:"🇲🇦"},{value:"EG",label:"Egypt",flag:"🇪🇬"},{value:"KE",label:"Kenya",flag:"🇰🇪"},{value:"GH",label:"Ghana",flag:"🇬🇭"},{value:"ET",label:"Ethiopia",flag:"🇪🇹"}]}],Ia=a=>e.jsx(re.Root,{...a});Ia.displayName="Dialog";const sn=re.Trigger;sn.displayName="DialogTrigger";const yr=re.Close;yr.displayName="DialogClose";const nn=re.Portal;nn.displayName="DialogPortal";const on=h.forwardRef(({className:a,...t},r)=>e.jsx(re.Overlay,{ref:r,className:v("fixed inset-0 z-50 overflow-y-auto","bg-black/70","data-[state=open]:animate-dialogOverlayShow",a),...t}));on.displayName="DialogOverlay";const Ea=h.forwardRef(({className:a,...t},r)=>e.jsx(nn,{children:e.jsx(on,{children:e.jsx(re.Content,{ref:r,className:v("fixed left-1/2 top-1/2 z-50 w-[95vw] max-w-lg -translate-x-1/2 -translate-y-1/2 overflow-y-auto rounded-md border p-6 shadow-lg","border-gray-200 dark:border-gray-900","bg-white dark:bg-[#090E1A]","data-[state=open]:animate-dialogContentShow",Ae,a),...t})})}));Ea.displayName="DialogContent";const Da=({className:a,...t})=>e.jsx("div",{className:v("flex flex-col gap-y-1",a),...t});Da.displayName="DialogHeader";const Ra=h.forwardRef(({className:a,...t},r)=>e.jsx(re.Title,{ref:r,className:v("text-lg font-bold font-red-hat-display","text-gray-900 dark:text-gray-50",a),...t}));Ra.displayName="DialogTitle";const qt=h.forwardRef(({className:a,...t},r)=>e.jsx(re.Description,{ref:r,className:v("text-gray-500 dark:text-gray-500",a),...t}));qt.displayName="DialogDescription";const br=({className:a,...t})=>e.jsx("div",{className:v("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...t});br.displayName="DialogFooter";const jr=z.forwardRef(({className:a,...t},r)=>e.jsx(G.Command,{ref:r,className:v("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",a),...t}));jr.displayName=G.Command.displayName;const wr=z.forwardRef(({className:a,...t},r)=>e.jsxs("div",{className:"flex items-center border-b pl-3","cmdk-input-wrapper":"",children:[e.jsx(N.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(G.Command.Input,{ref:r,className:v("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",a),...t})]}));wr.displayName=G.Command.Input.displayName;const vr=z.forwardRef(({className:a,...t},r)=>e.jsx(G.Command.List,{ref:r,className:v("max-h-[300px] overflow-y-auto overflow-x-hidden",a),...t}));vr.displayName=G.Command.List.displayName;const kr=z.forwardRef((a,t)=>e.jsx(G.Command.Empty,{ref:t,className:"py-6 text-center text-sm",...a}));kr.displayName=G.Command.Empty.displayName;const Nr=z.forwardRef(({className:a,...t},r)=>e.jsx(G.Command.Group,{ref:r,className:v("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",a),...t}));Nr.displayName=G.Command.Group.displayName;const Gd=z.forwardRef(({className:a,...t},r)=>e.jsx(G.Command.Separator,{ref:r,className:v("-mx-1 h-px bg-border",a),...t}));Gd.displayName=G.Command.Separator.displayName;const Ar=z.forwardRef(({className:a,...t},r)=>e.jsx(G.Command.Item,{ref:r,className:v("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-hidden data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",a),...t}));Ar.displayName=G.Command.Item.displayName;const Cr=a=>e.jsx(se.Root,{...a});Cr.displayName="Popover";const Sr=z.forwardRef((a,t)=>e.jsx(se.Trigger,{ref:t,...a}));Sr.displayName="PopoverTrigger";const Xd=z.forwardRef((a,t)=>e.jsx(se.Anchor,{ref:t,...a}));Xd.displayName="PopoverAnchor";const Yd=z.forwardRef((a,t)=>e.jsx(se.Close,{ref:t,...a}));Yd.displayName="PopoverClose";const zr=z.forwardRef(({className:a,sideOffset:t=10,side:r="bottom",align:s="center",collisionPadding:i,...n},o)=>e.jsx(se.Portal,{children:e.jsx(se.Content,{ref:o,sideOffset:t,side:r,align:s,collisionPadding:i,avoidCollisions:!0,className:U("max-h-[var(--radix-popper-available-height)] min-w-60 overflow-hidden rounded-md border p-2.5 text-sm shadow-md","border-gray-200 dark:border-gray-800","text-gray-900 dark:text-gray-50","bg-white dark:bg-gray-950","will-change-[transform,opacity]","data-[state=closed]:animate-hide","data-[state=open]:data-[side=bottom]:animate-slideDownAndFade data-[state=open]:data-[side=left]:animate-slideLeftAndFade data-[state=open]:data-[side=right]:animate-slideRightAndFade data-[state=open]:data-[side=top]:animate-slideUpAndFade",a),onWheel:l=>{l.stopPropagation(),l.deltaY>0?l.currentTarget.dispatchEvent(new KeyboardEvent("keydown",{key:"ArrowDown"})):l.currentTarget.dispatchEvent(new KeyboardEvent("keydown",{key:"ArrowUp"}))},...n})}));zr.displayName="PopoverContent";const ec=({value:a,onChange:t})=>{const r=h.useId(),[s,i]=h.useState(!1),n=cs.map(o=>o.items.find(l=>l.value===a)).filter(Boolean)[0];return e.jsx("div",{className:"mt-2",children:e.jsxs(Cr,{open:s,onOpenChange:i,children:[e.jsx(Sr,{asChild:!0,children:e.jsxs(R,{id:r,role:"combobox","aria-expanded":s,variant:"secondary",className:"w-full justify-between shadow-xs! bg-background px-3 py-2.5 font-normal outline-offset-0 hover:bg-background focus-visible:border-ring focus-visible:outline-[3px] focus-visible:outline-ring/20",children:[a?e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"text-lg leading-none",children:n==null?void 0:n.flag}),e.jsx("span",{className:"truncate",children:n==null?void 0:n.label})]}):e.jsx("span",{className:"text-muted-foreground",children:"Select country"}),e.jsx(N.ChevronDown,{size:16,strokeWidth:2,className:"shrink-0 text-muted-foreground/80","aria-hidden":"true"})]})}),e.jsx(zr,{className:"w-full min-w-[var(--radix-popper-anchor-width)] border-input -mt-1 z-50",align:"start",children:e.jsxs(jr,{className:"p-0",children:[e.jsx(wr,{className:"w-full border-none",style:{boxShadow:"none"},placeholder:"Search country..."}),e.jsxs(vr,{children:[e.jsx(kr,{children:"No country found."}),cs.map(o=>e.jsx(h.Fragment,{children:e.jsx(Nr,{heading:o.continent,children:o.items.map(l=>e.jsxs(Ar,{value:l.label,className:"cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-800",onSelect:()=>{t(l.value??""),i(!1)},children:[e.jsx("span",{className:"text-lg leading-none",children:l.flag})," ",l.label,a===l.value&&e.jsx(N.Check,{size:16,strokeWidth:2,className:"ml-auto"})]},l.value))})},o.continent))]})]})})]})})},ac=({...a})=>{const t=h.useId();return e.jsx("div",{className:"mt-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(le,{id:t,type:"email",inputClassName:"peer ps-9",...a}),e.jsx("div",{className:"pointer-events-none absolute inset-y-0 start-0 flex items-center justify-center ps-3 text-muted-foreground/80 peer-disabled:opacity-50",children:e.jsx(N.AtSign,{size:16,strokeWidth:2,"aria-hidden":"true"})})]})})},tc=a=>{const{client:t}=P(),[r,s]=h.useState(!1),[i,n]=h.useState(0),o=async u=>{const{body:p,status:g}=await t.file.createTemporaryFile({body:{filename:u.name,mimeType:u.type,size:u.size,organizationId:a.organizationId}});if(g!==201)throw new Error("Failed to create temporary file");const x=await ys.upload(u.name,u,{access:"public",handleUploadUrl:`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/files/token/vercel`,clientPayload:JSON.stringify({fileId:p==null?void 0:p.id}),onUploadProgress(y){n(y.percentage)}});return{id:p.id,filename:u.name,mimeType:u.type,size:u.size,url:x.url}},l=async u=>{var p;if((p=u.target.files)!=null&&p[0]){s(!0);try{const g=await o(u.target.files[0]);if(a.multiple){const x=a.value??[];a.onChange([...x,g])}else a.onChange(g)}catch(g){console.error(g)}finally{s(!1)}}},c=u=>{if(a.multiple){if(!a.value)return a.onChange(void 0);const p=a.value.filter(g=>g.id!==u);a.onChange(p.length?p:void 0)}else a.onChange(void 0)},m=()=>{if(a.value){const u=a.multiple?a.value:[a.value];return e.jsxs("div",{className:"flex",children:[u.map(p=>e.jsx("div",{className:"flex flex-col w-40 h-40 mr-3 transition-all rounded-lg relative animate-fade",children:e.jsxs("div",{className:"relative h-full w-40",children:[e.jsx("button",{className:"absolute w-6 h-6 bg-black flex items-center justify-center rounded-md right-1 top-1",onClick:()=>c(p.id),children:e.jsx(N.XIcon,{className:"w-4 h-4 text-white"})}),e.jsx(ze,{src:p.url,alt:p.filename,width:160,height:160,className:"w-40 h-40 rounded-md object-cover"})]})},p.id)),a.multiple&&e.jsxs("div",{className:"group flex relative flex-col w-40 h-40 items-center justify-center cursor-pointer border-2 border-gray-200 border-dashed transition-all rounded-lg hover:bg-gray-100 hover:border-gray-300",children:[e.jsx("div",{className:"flex flex-col items-center justify-center",children:r?e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"animate-spin w-4 h-4 fill-current shrink-0 mb-2",viewBox:"0 0 16 16",children:e.jsx("path",{d:"M8 16a7.928 7.928 0 01-3.428-.77l.857-1.807A6.006 6.006 0 0014 8c0-3.309-2.691-6-6-6a6.006 6.006 0 00-5.422 8.572l-1.806.859A7.929 7.929 0 010 8c0-4.411 3.589-8 8-8s8 3.589 8 8-3.589 8-8 8z"})}),e.jsxs("span",{className:"text-sm",children:["Uploading... (",i,"%)"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(N.CloudUpload,{className:"w-12 h-12 text-gray-300 group-hover:text-gray-600 transition-all stroke-1"}),e.jsx("p",{className:"pt-1 text-sm font-medium text-gray-400 group-hover:text-gray-600",children:"Upload an image"})]})}),e.jsx("input",{type:"file",className:"opacity-0 w-full h-full absolute cursor-pointer",onChange:l,accept:"image/png, image/gif, image/jpeg"})]},"upload-placeholder")]})}return e.jsxs("div",{className:"group flex relative flex-col items-center justify-center cursor-pointer w-full h-40 border-2 border-gray-200 border-dashed transition-all rounded-lg hover:bg-gray-100 hover:border-gray-300",children:[e.jsx("div",{className:"flex flex-col items-center justify-center",children:r?e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"animate-spin w-4 h-4 fill-current shrink-0 mb-2",viewBox:"0 0 16 16",children:e.jsx("path",{d:"M8 16a7.928 7.928 0 01-3.428-.77l.857-1.807A6.006 6.006 0 0014 8c0-3.309-2.691-6-6-6a6.006 6.006 0 00-5.422 8.572l-1.806.859A7.929 7.929 0 010 8c0-4.411 3.589-8 8-8s8 3.589 8 8-3.589 8-8 8z"})}),e.jsxs("span",{className:"text-sm",children:["Uploading... (",i,"%)"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(N.CloudUpload,{className:"w-12 h-12 text-gray-300 group-hover:text-gray-600 transition-all stroke-1"}),e.jsx("p",{className:"pt-1 text-sm font-medium text-gray-400 group-hover:text-gray-600",children:"Upload an image"})]})}),e.jsx("input",{type:"file",className:"opacity-0 w-full h-full absolute cursor-pointer",onChange:l,accept:"image/png, image/gif, image/jpeg"})]},"upload-placeholder")};return e.jsx("div",{className:"flex items-center w-full mt-2",children:m()})},ln=h.forwardRef(({...a},t)=>e.jsx(le,{...a,inputClassName:"border-l-0 rounded-l-none",ref:t,className:""}));ln.displayName="PhoneInput";const rc=({disabled:a,value:t,onChange:r,options:s})=>{const i=n=>{r(n.target.value)};return e.jsxs("div",{className:"relative inline-flex items-center self-stretch rounded-s-lg border border-gray-200 dark:border-gray-800 bg-background py-2 pe-2 ps-3 text-muted-foreground transition-shadow focus-within:z-10 focus-within:border-ring focus-within:outline-hidden focus-within:ring-[3px] focus-within:ring-ring/20 hover:bg-accent hover:text-foreground has-disabled:pointer-events-none has-disabled:opacity-50",children:[e.jsxs("div",{className:"inline-flex items-center gap-1","aria-hidden":"true",children:[e.jsx(dn,{country:t,countryName:t,"aria-hidden":"true"}),e.jsx("span",{className:"text-muted-foreground/80",children:e.jsx(N.ChevronDown,{size:16,strokeWidth:2,"aria-hidden":"true"})})]}),e.jsxs("select",{disabled:a,value:t,onChange:i,className:"absolute inset-0 text-sm opacity-0","aria-label":"Select country",children:[e.jsx("option",{value:"",children:"Select a country"},"default"),s.filter(n=>n.value).map((n,o)=>e.jsxs("option",{value:n.value,children:[n.label," ",n.value&&`+${vt.getCountryCallingCode(n.value)}`]},n.value??`empty-${o}`))]})]})},dn=({country:a,countryName:t})=>{const r=vs[a];return e.jsx("span",{className:"w-5 overflow-hidden rounded-sm",children:r?e.jsx(r,{title:t}):e.jsx(N.Phone,{size:16,"aria-hidden":"true"})})},sc=({value:a,onChange:t,onBlur:r})=>{const s=h.useId();return e.jsx("div",{className:"mt-2",children:e.jsx(vt.default,{id:s,className:"flex rounded-lg shadow-xs shadow-black/5",international:!0,flagComponent:dn,countrySelectComponent:rc,inputComponent:ln,placeholder:"Enter phone number",value:a,onChange:i=>t(i??""),onBlur:r})})},ic=({options:a,value:t,onChange:r,multiple:s=!1,placeholder:i})=>{var u;const n=h.useId(),[o,l]=h.useState(!1),c=p=>{if(s){let g;Array.isArray(t)&&t.includes(p)?g=t.filter(x=>x!==p):g=Array.isArray(t)?[...t,p]:[p],r(g)}else r(p),l(!1)},m=p=>{if(s&&Array.isArray(t)){const g=t.filter(x=>x!==p);r(g)}};return e.jsx("div",{className:"mt-2",children:e.jsxs(Cr,{open:o,onOpenChange:l,children:[e.jsx(Sr,{asChild:!0,children:e.jsxs(R,{id:n,role:"combobox","aria-expanded":o,variant:"secondary",className:"w-full justify-between shadow-xs! bg-background px-2! py-1 min-h-[41.6px] font-normal outline-offset-0 hover:bg-background focus-visible:border-ring focus-visible:outline-[3px] focus-visible:outline-ring/20",children:[(t==null?void 0:t.length)>0?e.jsx("div",{className:"flex flex-wrap gap-2",children:Array.isArray(t)?t.map(p=>{const g=a.find(x=>x.value===p);return g?e.jsxs("span",{className:"animate-fadeIn relative inline-flex cursor-default items-center rounded-md border border-border bg-background px-2 py-1 text-xs font-medium text-secondary-foreground transition-all hover:bg-background disabled:cursor-not-allowed disabled:opacity-50",children:[g.label,e.jsx(N.X,{size:12,onClick:x=>{x.preventDefault(),m(p)},className:"cursor-pointer ml-1"})]},p):null}):e.jsx("span",{className:"px-1 text-sm",children:(u=a.find(p=>p.value===t))==null?void 0:u.label})}):e.jsx("span",{className:"px-1 text-sm text-gray-400",children:i||(s?"Select options":"Select an option")}),e.jsx(N.ChevronDown,{size:16,strokeWidth:2,className:"shrink-0 text-muted-foreground/80","aria-hidden":"true"})]})}),e.jsx(zr,{className:"w-full min-w-[var(--radix-popper-anchor-width)] border-input -mt-1 z-50 p-0",align:"start",children:e.jsxs(jr,{className:"p-0",children:[e.jsx(wr,{className:"w-full border-none pl-0",style:{boxShadow:"none"},placeholder:"Search..."}),e.jsxs(vr,{children:[e.jsx(kr,{children:"No options found."}),e.jsx(Nr,{children:a.map(p=>e.jsxs(Ar,{value:p.label,className:"cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-800",onSelect:()=>c(p.value),children:[p.label,(s?t.includes(p.value):t===p.value)&&e.jsx(N.Check,{size:16,strokeWidth:2,className:"ml-auto"})]},p.value))})]})]})})]})})},nc=Oe.tv({slots:{root:["group relative isolate inline-flex shrink-0 cursor-pointer items-center rounded-full p-0.5 shadow-inner outline-hidden ring-1 ring-inset transition-all","bg-gray-200 dark:bg-gray-950","ring-black/5 dark:ring-gray-800","data-[state=checked]:bg-blue-600 dark:data-[state=checked]:bg-blue-600","data-disabled:cursor-default","data-disabled:data-[state=checked]:bg-blue-200","data-disabled:data-[state=checked]:ring-gray-300","dark:data-disabled:data-[state=checked]:ring-gray-900","dark:data-disabled:data-[state=checked]:bg-blue-900","data-disabled:data-[state=unchecked]:ring-gray-300","data-disabled:data-[state=unchecked]:bg-gray-100","dark:data-disabled:data-[state=unchecked]:ring-gray-700","dark:data-disabled:data-[state=unchecked]:bg-gray-800",Ae],thumb:["pointer-events-none relative inline-block transform appearance-none rounded-full border-none shadow-lg outline-hidden transition-all duration-150 ease-in-out focus:border-none focus:outline-hidden focus:outline-transparent","bg-white dark:bg-gray-50","group-data-disabled:shadow-none","group-data-disabled:bg-gray-50 dark:group-data-disabled:bg-gray-500"]},variants:{size:{default:{root:"h-7 w-14",thumb:"h-4 w-4 data-[state=checked]:translate-x-7 data-[state=unchecked]:translate-x-0"},small:{root:"h-4 w-7",thumb:"h-3 w-3 data-[state=checked]:translate-x-3 data-[state=unchecked]:translate-x-0"}}},defaultVariants:{size:"default"}}),cn=h.forwardRef(({className:a,size:t,...r},s)=>{const{root:i,thumb:n}=nc({size:t});return e.jsx(lt.Root,{ref:s,className:v(i(),a),...r,children:e.jsx(lt.Thumb,{className:v(n())})})});cn.displayName="Switch";const oc=({name:a,type:t,placeholder:r,multiple:s,options:i,prefix:n})=>{const{watch:o,register:l,setFocus:c,setValue:m}=Z.useFormContext();switch(t){case"email":return e.jsx(ac,{...l(a),placeholder:r});case"file":return e.jsx(tc,{value:o(a),multiple:s,onChange:u=>m(a,u)});case"phone-number":return e.jsx(sc,{value:o("phone"),onChange:u=>m("phone",u),onBlur:()=>c("phone")});case"country":return e.jsx(ec,{value:o(a),onChange:u=>m(a,u)});case"select":{const u=s?o(a)||[]:o(a)||"";if(!i)throw new Error("Options are required for select input");return e.jsx(ic,{options:i,value:u,onChange:p=>m(a,p),placeholder:r,multiple:s})}case"switch":return e.jsx(cn,{size:"default",className:"mr-2",checked:o(a),onCheckedChange:u=>m(a,u)});case"time":return e.jsx(ur,{value:o(a),onChange:u=>m(a,u.target.value),className:"mt-2"});default:return e.jsx(le,{...l(a),type:t,rows:t==="textarea"?4:void 0,placeholder:r,className:"mt-2",prefix:n})}},lc=(a,t)=>!a||typeof a!="object"?void 0:t?t.replace(/\[/g,".").replace(/\]/g,"").split(".").filter(Boolean).reduce((r,s)=>{if(r!=null)return r[s]},a):a,Pe=({type:a="text",name:t,label:r,className:s,locale:i,placeholder:n,multiple:o,options:l,localizable:c,prefix:m})=>{const{errors:u}=Z.useFormState(),p=lc(u,t);return e.jsxs("div",{className:v("w-full",{"flex items-center flex-row-reverse justify-end":a==="switch"},s),children:[typeof r=="string"&&e.jsxs(me,{htmlFor:t,className:"font-medium flex items-center justify-between",children:[e.jsxs("span",{className:"flex items-center",children:[r,c&&e.jsx(N.LanguagesIcon,{className:"w-4 h-4 ml-1 text-gray-500"})]}),i&&c&&e.jsxs("span",{className:"flex items-center text-xs text-gray-500 ml-1 bg-gray-100 px-1 py-0.5 rounded",children:[At.get(i)," (",i,")"]})]}),e.jsx(oc,{type:a,name:t,placeholder:n,options:l,multiple:o,prefix:m}),(p==null?void 0:p.message)&&e.jsx("p",{className:"mt-1 text-sm text-red-500",children:p.message})]})},dc=({form:a,config:t,columns:r=2})=>{var c;const{errors:s}=Z.useFormState(),i=rn(s,t.name),{fields:n,append:o,remove:l}=Z.useFieldArray({control:a.control,name:t.name});return(c=t.fields)!=null&&c.length?e.jsx(e.Fragment,{children:e.jsxs("div",{className:"w-full col-span-full",children:[t.label&&e.jsx("h4",{className:"text-2xl flex items-center justify-between font-semibold",children:t.label}),t.description&&e.jsx("p",{className:"text-sm text-gray-500",children:t.description}),n.map((m,u)=>{var p;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:v("grid gap-5 w-full border-l-[8px] border-blue-500 pl-5 py-3 mt-6",{"grid-cols-1":r===1,"grid-cols-2":r===2,"grid-cols-3":r===3,"grid-cols-4":r===4}),children:(p=t.fields)==null?void 0:p.map(({name:g,label:x,type:y,colspan:j,localizable:f,multiple:b,options:w,placeholder:k,prefix:C})=>e.jsx(Pe,{name:`${t.name}[${u}].${g}`,label:x,type:y??"text",localizable:f,className:v({"col-span-1":j===1,"col-span-2":j===2,"col-span-3":j===3,"col-span-4":j===4}),placeholder:k,multiple:b,options:w,prefix:C},t.name+g))},m.id),u<n.length-1&&e.jsx(H,{})]})}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsxs("button",{type:"button",className:"relative my-2 inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-md border px-2 py-1 text-center text-sm font-medium shadow-xs transition-all duration-100 ease-in-out disabled:pointer-events-none disabled:shadow-none outline outline-offset-2 outline-0 focus-visible:outline-2 outline-blue-500 dark:outline-blue-500 border-gray-300 dark:border-gray-800 text-gray-900 dark:text-gray-50 bg-white dark:bg-gray-950 hover:bg-gray-50 dark:hover:bg-gray-900/60 disabled:text-gray-400 dark:disabled:text-gray-600",onClick:()=>o({}),children:[e.jsx(N.PlusCircleIcon,{className:"w-4 h-4 text-blue-500"}),"Add New"]}),n.length>1&&e.jsxs("button",{type:"button",className:"relative my-2 inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-md border px-2 py-1 text-center text-sm font-medium shadow-xs transition-all duration-100 ease-in-out disabled:pointer-events-none disabled:shadow-none outline outline-offset-2 outline-0 focus-visible:outline-2 outline-blue-500 dark:outline-blue-500 border-gray-300 dark:border-gray-800 text-gray-900 dark:text-gray-50 bg-white dark:bg-gray-950 hover:bg-gray-50 dark:hover:bg-gray-900/60 disabled:text-gray-400 dark:disabled:text-gray-600",onClick:()=>l(n.length-1),children:[e.jsx(N.XCircleIcon,{className:"w-4 h-4 text-red-500"}),"Remove"]})]}),(i==null?void 0:i.message)&&e.jsx("p",{className:"mt-1 text-sm text-red-500",children:i.message})]})}):null},cc=({config:a,columns:t=2})=>{var i;const{errors:r}=Z.useFormState(),s=rn(r,a.name);return(i=a.fields)!=null&&i.length?e.jsxs("div",{className:"w-full col-span-full",children:[a.label&&e.jsx("h4",{className:"text-2xl font-semibold mb-2",children:a.label}),a.description&&e.jsx("p",{className:"text-sm text-gray-500 mb-3",children:a.description}),e.jsx("div",{className:v("grid gap-5",{"grid-cols-1":t===1,"grid-cols-2":t===2,"grid-cols-3":t===3,"grid-cols-4":t===4}),children:a.fields.map(({name:n,label:o,type:l,colspan:c,localizable:m,multiple:u,options:p,placeholder:g,prefix:x})=>e.jsx(Pe,{name:`${a.name}.${n}`,label:o,type:l??"text",localizable:m,className:v({"col-span-1":c===1,"col-span-2":c===2,"col-span-3":c===3,"col-span-4":c===4}),placeholder:g,multiple:u,options:p,prefix:x},`${a.name}.${n}`))}),(s==null?void 0:s.message)&&e.jsx("p",{className:"mt-1 text-sm text-red-500",children:s.message})]}):null};function mc(a,t){const{asChild:r,children:s}=a;if(!r)return typeof t=="function"?t(s):t;const i=h.Children.only(s);return h.cloneElement(i,{children:typeof t=="function"?t(i.props.children):t})}const Ir=h.forwardRef(({className:a,children:t,...r},s)=>e.jsx(dt.Root,{ref:s,...r,asChild:!1,children:e.jsx(dt.List,{className:v("flex items-center justify-start whitespace-nowrap border-b [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","border-gray-200 dark:border-gray-800",a),children:t})}));Ir.displayName="TabNavigation";const Er=h.forwardRef(({asChild:a,disabled:t,className:r,children:s,...i},n)=>e.jsx(dt.Item,{className:"flex","aria-disabled":t,children:e.jsx(dt.Link,{"aria-disabled":t,className:v("group relative flex shrink-0 select-none items-center justify-center",t?"pointer-events-none":""),ref:n,onSelect:()=>{},asChild:a,...i,children:mc({asChild:a,children:s},o=>e.jsx("span",{className:v("-mb-px flex items-center justify-center whitespace-nowrap border-b-2 border-transparent px-3 pb-2 text-sm font-medium transition-all","text-gray-500 dark:text-gray-500","group-hover:text-gray-700 dark:group-hover:text-gray-400","group-hover:border-gray-300 dark:group-hover:border-gray-400","group-data-active:border-blue-600 group-data-active:text-blue-600","dark:group-data-active:border-blue-500 dark:group-data-active:text-blue-500",t?"pointer-events-none text-gray-300 dark:text-gray-700":"",Ae,r),children:o}))})}));Er.displayName="TabNavigationLink";const Be=({form:a,okText:t,config:r,loading:s,onCancel:i,cancelText:n,columns:o=2,onSubmit:l})=>{const c=a.watch("translations"),{organization:m,defaultLocale:u,supportedLocales:p}=ke(),[g,x]=h.useState(),y=h.useMemo(()=>r.some(f=>f.localizable),[r]);h.useEffect(()=>{m.data&&x(u)},[m.data,u,a,p,c]),h.useEffect(()=>{a.formState.errors.translations&&x(u)},[u,a.formState.errors.translations]);const j=e.jsxs("div",{className:U("grid gap-5 w-full",{"grid-cols-1":o===1,"grid-cols-2":o===2,"grid-cols-3":o===3,"grid-cols-4":o===4}),children:[y&&e.jsx("div",{className:"col-span-full",children:e.jsx(Ir,{className:"col-span-full mb-3",children:p.map(f=>{const b=f===u;return e.jsx(Er,{active:f===g,onClick:()=>x(f),className:"cursor-pointer",children:e.jsxs(e.Fragment,{children:[At.get(f)," ",b&&"(Default)"]})},f)})})}),r.map(f=>{const{name:b,label:w,type:k,colspan:C,localizable:F,multiple:Q,options:O,placeholder:E,prefix:S}=f,T=!F||!g?b:`translations[${p==null?void 0:p.indexOf(g)}].${b}`;return k==="object"?e.jsx(cc,{config:f},b):k==="array"?e.jsx(dc,{form:a,config:f},b):e.jsx(Pe,{name:T,label:w,type:k??"text",localizable:F,className:U({"col-span-1":C===1,"col-span-2":C===2,"col-span-3":C===3,"col-span-4":C===4}),placeholder:E,multiple:Q,options:O,locale:g,prefix:S},T)}),l&&e.jsxs("div",{className:"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2 mt-6 col-span-full border-t pt-7",children:[i&&e.jsx(R,{type:"button",className:"w-full sm:w-fit",variant:"secondary",onClick:i,children:n??"Cancel"}),e.jsx(R,{type:"submit",className:"w-full sm:w-fit",isLoading:s,loadingText:"Saving...",children:t??"Save Data"})]})]});return l?e.jsx(Z.FormProvider,{...a,children:e.jsx("form",{onSubmit:a.handleSubmit(f=>l(f)),children:j})}):e.jsx("div",{className:"w-full",children:j})},uc=[{name:"name",label:"Manufacturer Name",type:"text",placeholder:"Acme Inc.",colspan:2},{name:"about",label:"About",type:"textarea",placeholder:"Lorem ipsum dolor sit amet, consectetur adipiscing elit.",colspan:2,localizable:!0},{name:"logo",label:"Logo",type:"file"}],mn=({initialData:a})=>{const{client:t}=P(),r=D.useRouter(),s=$(),i=_(),{defaultLocale:n,supportedLocales:o}=ke(),l=a?yl:fl,c=Z.useForm({resolver:be.zodResolver(l),defaultValues:a?{defaultLocale:n,name:a.name,logo:a.logo,translations:a.translations}:{defaultLocale:n,translations:o.map(x=>({locale:x}))}}),m=A.useMutation({mutationFn:async x=>{var f;const y={name:x.name,defaultLocale:x.defaultLocale,translations:x.translations,logoId:(f=x.logo)==null?void 0:f.id},{status:j}=await t.manufacturer.createManufacturer({params:{organizationId:i},body:y});if(j!==201)throw J.error("Failed to create manufacturer. Please try again later."),new Error("Failed to create manufacturer")}}),u=A.useMutation({mutationFn:async x=>{var f;const y={name:x.name,defaultLocale:x.defaultLocale,translations:x.translations,logoId:((f=x.logo)==null?void 0:f.id)||null},{status:j}=await t.manufacturer.updateManufacturer({params:{organizationId:i,id:a.id},body:y});if(j!==200)throw J.error("Failed to update manufacturer. Please try again later."),new Error("Failed to update manufacturer")}}),p=async()=>{J.success("Manufacturer saved successfully"),r.push(s.manufacturers(i)),await oe.invalidateQueries({queryKey:["manufacturers"]})},g=x=>{a?u.mutate(x,{onSuccess:p}):m.mutate(x,{onSuccess:p})};return e.jsx(Be,{form:c,config:uc,onSubmit:g,loading:m.isPending||u.isPending,cancelText:"Go back",okText:a?"Update Manufacturer":"Create Manufacturer"})};function pc(){return e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-gray-900 sm:text-xl dark:text-gray-50",children:"Create Manufacturer"}),e.jsx(H,{}),e.jsx("div",{className:"pt-6",children:e.jsx("div",{className:"space-y-10",children:e.jsx("section",{"aria-labelledby":"manufacturer-info",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"manufacturer-info",className:"scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Manufacturer Information"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Enter the information about the manufacturer."})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsx(mn,{})})]})})})})]})}function gc(){const a=_(),t=za(),{client:r}=P(),{isLoading:s,data:i}=A.useQuery({queryKey:["manufacturers",a,t],queryFn:async()=>{const{status:n,body:o}=await r.manufacturer.getManufacturer({params:{id:t,organizationId:a}});if(n!==200)throw J.error("Failed to fetch manufacturer. Please refresh or try again later."),new Error("Failed to fetch manufacturer");return o},throwOnError:!0,placeholderData:A.keepPreviousData});return e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-gray-900 sm:text-xl dark:text-gray-50",children:"Edit Manufacturer"}),e.jsx(H,{}),e.jsx("div",{className:"pt-6",children:e.jsx("div",{className:"space-y-10",children:e.jsx("section",{"aria-labelledby":"manufacturer-info",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"manufacturer-info",className:"scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Manufacturer Information"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Enter the information about the manufacturer."})]}),e.jsx("div",{className:"md:col-span-2",children:s||!i?e.jsx("div",{className:"flex justify-center items-center h-screen mt-5",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(pe,{className:"w-12 h-12"}),e.jsx("p",{className:"text-gray-500 text-sm mt-3",children:"Loading data..."})]})}):e.jsx(mn,{initialData:i})})]})})})})]})}const hc=h.forwardRef(({className:a,children:t,...r},s)=>e.jsx("div",{ref:s,children:e.jsx("div",{className:U("w-full overflow-auto whitespace-nowrap",a),...r,children:t})}));hc.displayName="TableRoot";const Dr=h.forwardRef(({className:a,...t},r)=>e.jsx("table",{ref:r,className:U("w-full caption-bottom border-b","border-gray-200 dark:border-gray-800",a),...t}));Dr.displayName="Table";const Rr=h.forwardRef(({className:a,...t},r)=>e.jsx("thead",{ref:r,className:U(a),...t}));Rr.displayName="TableHead";const ca=h.forwardRef(({className:a,...t},r)=>e.jsx("th",{ref:r,className:U("border-b px-4 py-3.5 text-left text-sm font-semibold","text-gray-900 dark:text-gray-50","border-gray-200 dark:border-gray-800",a),...t}));ca.displayName="TableHeaderCell";const Fr=h.forwardRef(({className:a,...t},r)=>e.jsx("tbody",{ref:r,className:U("divide-y","divide-gray-200 dark:divide-gray-800",a),...t}));Fr.displayName="TableBody";const ma=h.forwardRef(({className:a,...t},r)=>e.jsx("tr",{ref:r,className:U("[&_td:last-child]:pr-4 [&_th:last-child]:pr-4","[&_td:first-child]:pl-4 [&_th:first-child]:pl-4",a),...t}));ma.displayName="TableRow";const _e=h.forwardRef(({className:a,...t},r)=>e.jsx("td",{ref:r,className:U("p-4 text-sm","text-gray-600 dark:text-gray-400",a),...t}));_e.displayName="TableCell";const xc=h.forwardRef(({className:a,...t},r)=>e.jsx("tfoot",{ref:r,className:U("border-t text-left font-medium","text-gray-900 dark:text-gray-50","border-gray-200 dark:border-gray-800",a),...t}));xc.displayName="TableFoot";const fc=h.forwardRef(({className:a,...t},r)=>e.jsx("caption",{ref:r,className:U("mt-3 px-3 text-center text-sm","text-gray-500 dark:text-gray-500",a),...t}));fc.displayName="TableCaption";const yc=v("hidden h-6 select-none items-center justify-center rounded-md bg-gray-800 px-2 font-mono text-xs text-gray-400 ring-1 ring-inset ring-gray-700 transition sm:flex"),un=({open:a=!1,onOpenChange:t,defaultOpen:r=!1,disableAutoFocus:s=!0,children:i})=>e.jsxs(se.Root,{open:a,onOpenChange:t,defaultOpen:r,children:[e.jsx(se.Anchor,{className:v("fixed inset-x-0 bottom-8 mx-auto flex w-fit items-center")}),e.jsx(se.Portal,{children:e.jsx(se.Content,{side:"top",sideOffset:0,onOpenAutoFocus:n=>{s&&n.preventDefault()},className:v("z-50","data-[state=closed]:animate-hide","data-[side=top]:animate-slideUpAndFade"),children:i})})]});un.displayName="CommandBar";const pn=z.forwardRef(({className:a,...t},r)=>e.jsx("div",{ref:r,className:v("px-3 py-2.5 text-sm tabular-nums text-gray-300",a),...t}));pn.displayName="CommandBar.Value";const gn=z.forwardRef(({className:a,...t},r)=>e.jsx("div",{ref:r,className:v("relative flex items-center rounded-lg bg-gray-900 px-1 shadow-lg shadow-black/30 dark:ring-1 dark:ring-white/10",a),...t}));gn.displayName="CommandBarBar";const st=z.forwardRef(({className:a,...t},r)=>e.jsx("div",{ref:r,className:v("h-4 w-px bg-gray-700",a),...t}));st.displayName="CommandBar.Seperator";const it=z.forwardRef(({className:a,type:t="button",label:r,action:s,shortcut:i,disabled:n,...o},l)=>(z.useEffect(()=>{const c=m=>{m.key===i.shortcut&&(m.preventDefault(),m.stopPropagation(),s())};return n||document.addEventListener("keydown",c),()=>{document.removeEventListener("keydown",c)}},[s,i,n]),e.jsx("span",{className:v("flex items-center gap-x-2 rounded-lg bg-gray-900 p-1 text-base font-medium text-gray-50 outline-hidden transition focus:z-10 sm:text-sm","sm:last-of-type:-mr-1",a),children:e.jsxs("button",{ref:l,type:t,onClick:s,disabled:n,className:v("flex items-center gap-x-2 rounded-md px-1 py-1 hover:bg-gray-800","focus-visible:bg-gray-800 focus-visible:hover:bg-gray-800","disabled:text-gray-500",Ae),...o,children:[e.jsx("span",{children:r}),e.jsx("span",{className:yc,children:i.label?i.label.toUpperCase():i.shortcut.toUpperCase()})]})})));it.displayName="CommandBar.Command";function bc({table:a,rowSelection:t}){const r=Object.keys(t).length>0;return e.jsx(un,{open:r,children:e.jsxs(gn,{children:[e.jsxs(pn,{children:[Object.keys(t).length," selected"]}),e.jsx(st,{}),e.jsx(it,{label:"Edit",action:()=>{console.log("Edit")},shortcut:{shortcut:"e"}}),e.jsx(st,{}),e.jsx(it,{label:"Delete",action:()=>{console.log("Delete")},shortcut:{shortcut:"d"}}),e.jsx(st,{}),e.jsx(it,{label:"Reset",action:()=>{a.resetRowSelection()},shortcut:{shortcut:"Escape",label:"esc"}})]})})}function jc({meta:a,table:t}){const r=D.useSearchParams(),s=D.useRouter(),i=D.usePathname(),n=Number((r==null?void 0:r.get("page"))||"1"),o=(g,x)=>{const y=new URLSearchParams(r==null?void 0:r.toString());return y.set(g,x),y.toString()},l=g=>{s.push(`${i}?${o("page",g.toString())}`)},c=[{icon:M.RiArrowLeftDoubleLine,onClick:()=>l(1),disabled:!(a!=null&&a.previousPage),srText:"First page",mobileView:"hidden sm:block"},{icon:M.RiArrowLeftSLine,onClick:()=>l(n-1),disabled:!(a!=null&&a.previousPage),srText:"Previous page",mobileView:""},{icon:M.RiArrowRightSLine,onClick:()=>l(n+1),disabled:!(a!=null&&a.nextPage),srText:"Next page",mobileView:""},{icon:M.RiArrowRightDoubleLine,onClick:()=>l(a.pageCount),disabled:!(a!=null&&a.nextPage),srText:"Last page",mobileView:"hidden sm:block"}],m=t.getFilteredRowModel().rows.length,u=t.getState().pagination.pageIndex*15+1,p=Math.min(m,u+15-1);return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"text-sm tabular-nums text-gray-500",children:[t.getFilteredSelectedRowModel().rows.length," of ",m," row(s) selected."]}),e.jsxs("div",{className:"flex items-center gap-x-6 lg:gap-x-8",children:[e.jsxs("p",{className:"hidden text-sm tabular-nums text-gray-500 sm:block",children:["Showing"," ",e.jsxs("span",{className:"font-medium text-gray-900 dark:text-gray-50",children:[u,"-",p]})," ","of"," ",e.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-50",children:m})]}),e.jsx("div",{className:"flex items-center gap-x-1.5",children:c.map((g,x)=>e.jsxs(R,{variant:"secondary",className:v(g.mobileView,"p-1.5"),onClick:()=>{g.onClick(),t.resetRowSelection()},disabled:g.disabled,children:[e.jsx("span",{className:"sr-only",children:g.srText}),e.jsx(g.icon,{className:"size-4 shrink-0","aria-hidden":"true"})]},x))})]})]})}function Fa({meta:a,columns:t,error:r,data:s,loading:i,className:n,refetch:o}){var g,x;const l=_(),c=$(),[m,u]=z.useState({}),p=Ee.useReactTable({data:s,columns:t,state:{rowSelection:m},enableRowSelection:!0,getFilteredRowModel:Ee.getFilteredRowModel(),onRowSelectionChange:u,getCoreRowModel:Ee.getCoreRowModel(),getSortedRowModel:Ee.getSortedRowModel(),manualPagination:!0,meta:{...a,organizationId:l,refetch:o,routes:c}});return e.jsx(e.Fragment,{children:e.jsxs("div",{className:v("space-y-6 relative",n),children:[e.jsxs("div",{className:"relative overflow-hidden overflow-x-auto",children:[i&&!s?e.jsx("div",{className:"flex items-center justify-center h-48",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(pe,{className:"w-10 h-10"}),e.jsx("p",{className:"text-gray-500 text-xs mt-1",children:"Loading..."})]})}):e.jsxs(e.Fragment,{children:[e.jsxs(Dr,{children:[e.jsx(Rr,{children:p.getHeaderGroups().map(y=>e.jsx(ma,{className:"border-y border-gray-200 dark:border-gray-800 back",children:y.headers.map(j=>{var f;return e.jsx(ca,{className:v("whitespace-nowrap py-1 text-sm sm:text-xs",(f=j.column.columnDef.meta)==null?void 0:f.className),children:Ee.flexRender(j.column.columnDef.header,j.getContext())},j.id)})},y.id))}),e.jsxs(Fr,{children:[r&&e.jsx(ma,{children:e.jsx(_e,{colSpan:t.length,className:"h-24 text-center text-red-500",children:"An error occurred while fetching data. Please refresh the site and try again."})}),((g=p.getRowModel().rows)==null?void 0:g.length)>0&&p.getRowModel().rows.map(y=>e.jsx(ma,{className:"group select-none hover:bg-gray-50 dark:hover:bg-gray-900",children:y.getVisibleCells().map((j,f)=>{var b;return e.jsxs(_e,{className:v(y.getIsSelected()?"bg-gray-50 dark:bg-gray-900":"","relative whitespace-nowrap py-1 text-gray-600 first:w-10 dark:text-gray-400",(b=j.column.columnDef.meta)==null?void 0:b.className),children:[f===0&&y.getIsSelected()&&e.jsx("div",{className:"absolute inset-y-0 left-0 w-0.5 bg-blue-600 dark:bg-blue-500"}),Ee.flexRender(j.column.columnDef.cell,j.getContext())]},j.id)})},y.id)),((x=p.getRowModel().rows)==null?void 0:x.length)===0&&!i&&e.jsx(ma,{children:e.jsx(_e,{colSpan:t.length,className:"h-24 text-center",children:"No results."})})]})]}),i&&s&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-white bg-opacity-75 dark:bg-gray-900 dark:bg-opacity-75",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(pe,{className:"w-10 h-10"}),e.jsx("p",{className:"text-gray-500 text-xs mt-1",children:"Loading..."})]})})]}),e.jsx(bc,{table:p,rowSelection:m})]}),a&&e.jsx(jc,{meta:a,table:p})]})})}const wc=Oe.tv({base:["relative block w-full appearance-none rounded-md border px-2.5 py-1.5 outline-hidden transition sm:text-sm","border-transparent dark:border-gray-800","text-gray-900 dark:text-gray-50","placeholder-gray-400 dark:placeholder-gray-500","bg-gray-100 dark:bg-gray-950","disabled:border-gray-300 disabled:bg-gray-100 disabled:text-gray-400","dark:disabled:border-gray-700 dark:disabled:bg-gray-800 dark:disabled:text-gray-500",Sa,"[&::--webkit-search-cancel-button]:hidden [&::-webkit-search-cancel-button]:hidden [&::-webkit-search-decoration]:hidden"],variants:{hasError:{true:Lt},enableStepper:{true:"[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none"}}}),Ma=z.forwardRef(({className:a,inputClassName:t,hasError:r,enableStepper:s,type:i="search",...n},o)=>e.jsxs("div",{className:v("relative w-full",a),children:[e.jsx("input",{ref:o,type:i,className:v(wc({hasError:r,enableStepper:s}),"pl-8",t),...n}),e.jsx("div",{className:v("pointer-events-none absolute bottom-0 left-2 flex h-full items-center justify-center","text-gray-400 dark:text-gray-600"),children:e.jsx(M.RiSearchLine,{className:"size-[1.125rem] shrink-0","aria-hidden":"true"})})]}));Ma.displayName="Searchbar";const Qe=h.forwardRef(({className:a,checked:t,...r},s)=>e.jsx(Ur.Root,{ref:s,...r,checked:t,className:v("relative inline-flex size-4 shrink-0 appearance-none items-center justify-center rounded shadow-xs outline-hidden ring-1 ring-inset transition duration-100 enabled:cursor-pointer","text-white dark:text-gray-50","bg-white dark:bg-gray-950","ring-gray-300 dark:ring-gray-800","data-disabled:bg-gray-100 data-disabled:text-gray-400 data-disabled:ring-gray-300","dark:data-disabled:bg-gray-800 dark:data-disabled:text-gray-500 dark:data-disabled:ring-gray-700","enabled:data-[state=checked]:bg-blue-600 enabled:data-[state=checked]:ring-0 enabled:data-[state=checked]:ring-transparent","enabled:data-[state=indeterminate]:bg-blue-600 enabled:data-[state=indeterminate]:ring-0 enabled:data-[state=indeterminate]:ring-transparent",Ae,a),children:e.jsx(Ur.Indicator,{asChild:!0,className:"flex size-full items-center justify-center",children:t==="indeterminate"?e.jsx("svg",{"aria-hidden":"true",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("line",{stroke:"currentColor",strokeLinecap:"round",strokeWidth:"2",x1:"4",x2:"12",y1:"8",y2:"8"})}):e.jsx("svg",{"aria-hidden":"true",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M11.2 5.59998L6.79999 9.99998L4.79999 7.99998",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})})})}));Qe.displayName="Checkbox";function q({column:a,title:t,className:r}){return a.getCanSort()?e.jsxs("div",{onClick:a.getToggleSortingHandler(),className:v(a.columnDef.enableSorting===!0?"-mx-2 inline-flex cursor-pointer select-none items-center gap-2 rounded-md px-2 py-1 hover:bg-gray-50 dark:hover:bg-gray-900":""),children:[e.jsx("span",{children:t}),a.getCanSort()?e.jsxs("div",{className:"-space-y-2",children:[e.jsx(M.RiArrowUpSLine,{className:v("size-3.5 text-gray-900 dark:text-gray-50",a.getIsSorted()==="desc"?"opacity-30":""),"aria-hidden":"true"}),e.jsx(M.RiArrowDownSLine,{className:v("size-3.5 text-gray-900 dark:text-gray-50",a.getIsSorted()==="asc"?"opacity-30":""),"aria-hidden":"true"})]}):null]}):e.jsx("div",{className:v(r),children:t})}const ra=ye.Root;ra.displayName="DropdownMenu";const sa=ye.Trigger;sa.displayName="DropdownMenuTrigger";const La=ye.Group;La.displayName="DropdownMenuGroup";const hn=ye.Sub;hn.displayName="DropdownMenuSubMenu";const xn=ye.RadioGroup;xn.displayName="DropdownMenuRadioGroup";const fn=z.forwardRef(({className:a,children:t,...r},s)=>e.jsxs(ye.SubTrigger,{ref:s,className:v("relative flex cursor-default select-none items-center rounded py-1.5 pl-2 pr-1 outline-hidden transition-colors data-[state=checked]:font-semibold sm:text-sm","text-gray-900 dark:text-gray-50","data-disabled:pointer-events-none data-disabled:text-gray-400 data-disabled:hover:bg-none dark:data-disabled:text-gray-600","focus-visible:bg-gray-100 data-[state=open]:bg-gray-100 dark:focus-visible:bg-gray-900 dark:data-[state=open]:bg-gray-900","hover:bg-gray-100 dark:hover:bg-gray-900",a),...r,children:[t,e.jsx(M.RiArrowRightSLine,{className:"ml-auto size-4 shrink-0 text-gray-500","aria-hidden":"true"})]}));fn.displayName="DropdownMenuSubMenuTrigger";const yn=z.forwardRef(({className:a,collisionPadding:t=8,...r},s)=>e.jsx(ye.Portal,{children:e.jsx(ye.SubContent,{ref:s,collisionPadding:t,className:v("relative z-50 overflow-hidden rounded-md border p-1 shadow-xl shadow-black/[2.5%]","min-w-32","max-h-[var(--radix-popper-available-height)]","bg-white dark:bg-gray-950","text-gray-900 dark:text-gray-50","border-gray-200 dark:border-gray-800","will-change-[transform,opacity]","data-[state=closed]:animate-hide","data-[side=bottom]:animate-slideDownAndFade data-[side=left]:animate-slideLeftAndFade data-[side=right]:animate-slideRightAndFade data-[side=top]:animate-slideUpAndFade",a),...r})}));yn.displayName="DropdownMenuSubMenuContent";const ia=z.forwardRef(({className:a,sideOffset:t=8,collisionPadding:r=8,align:s="center",loop:i=!0,...n},o)=>e.jsx(ye.Portal,{children:e.jsx(ye.Content,{ref:o,className:v("relative z-50 overflow-hidden rounded-md border p-1 shadow-xl shadow-black/[2.5%]","min-w-[calc(var(--radix-dropdown-menu-trigger-width))]","max-h-[var(--radix-popper-available-height)]","bg-white dark:bg-gray-950","text-gray-900 dark:text-gray-50","border-gray-200 dark:border-gray-800","will-change-[transform,opacity]","data-[state=closed]:animate-hide","data-[side=bottom]:animate-slideDownAndFade data-[side=left]:animate-slideLeftAndFade data-[side=right]:animate-slideRightAndFade data-[side=top]:animate-slideUpAndFade",a),sideOffset:t,align:s,collisionPadding:r,loop:i,...n})}));ia.displayName="DropdownMenuContent";const Se=z.forwardRef(({className:a,shortcut:t,hint:r,children:s,...i},n)=>e.jsxs(ye.Item,{ref:n,className:v("group/DropdownMenuItem relative flex cursor-pointer select-none items-center rounded py-1.5 pl-2 pr-1 outline-hidden transition-colors data-[state=checked]:font-semibold sm:text-sm","text-gray-900 dark:text-gray-50","data-disabled:pointer-events-none data-disabled:text-gray-400 data-disabled:hover:bg-none dark:data-disabled:text-gray-600","focus-visible:bg-gray-100 dark:focus-visible:bg-gray-900","hover:bg-gray-100 dark:hover:bg-gray-900",a),...i,children:[s,r&&e.jsx("span",{className:v("ml-auto pl-2 text-sm text-gray-400 dark:text-gray-600"),children:r}),t&&e.jsx("span",{className:v("ml-auto pl-2 text-sm text-gray-400 dark:text-gray-600"),children:t})]}));Se.displayName="DropdownMenuItem";const vc=z.forwardRef(({className:a,hint:t,shortcut:r,children:s,checked:i,...n},o)=>e.jsxs(ye.CheckboxItem,{ref:o,className:v("relative flex cursor-pointer select-none items-center gap-x-2 rounded py-1.5 pl-8 pr-1 outline-hidden transition-colors data-[state=checked]:font-semibold sm:text-sm","text-gray-900 dark:text-gray-50","data-disabled:pointer-events-none data-disabled:text-gray-400 data-disabled:hover:bg-none dark:data-disabled:text-gray-600","focus-visible:bg-gray-100 dark:focus-visible:bg-gray-900","hover:bg-gray-100 dark:hover:bg-gray-900",a),checked:i,...n,children:[e.jsx("span",{className:"absolute left-2 flex size-4 items-center justify-center",children:e.jsx(ye.ItemIndicator,{children:e.jsx(M.RiCheckLine,{"aria-hidden":"true",className:"size-full shrink-0 text-gray-800 dark:text-gray-200"})})}),s,t&&e.jsx("span",{className:v("ml-auto text-sm font-normal text-gray-400 dark:text-gray-600"),children:t}),r&&e.jsx("span",{className:v("ml-auto text-sm font-normal tracking-widest text-gray-400 dark:border-gray-800 dark:text-gray-600"),children:r})]}));vc.displayName="DropdownMenuCheckboxItem";const nt=z.forwardRef(({className:a,hint:t,shortcut:r,children:s,iconType:i="radio",...n},o)=>e.jsxs(ye.RadioItem,{ref:o,className:v("group/DropdownMenuRadioItem relative flex cursor-pointer select-none items-center gap-x-2 rounded py-1.5 pl-8 pr-1 outline-hidden transition-colors data-[state=checked]:font-semibold sm:text-sm","text-gray-900 dark:text-gray-50","data-disabled:pointer-events-none data-disabled:text-gray-400 data-disabled:hover:bg-none dark:data-disabled:text-gray-600","focus-visible:bg-gray-100 dark:focus-visible:bg-gray-900","hover:bg-gray-100 dark:hover:bg-gray-900",a),...n,children:[i==="radio"?e.jsxs("span",{className:"absolute left-2 flex size-4 items-center justify-center",children:[e.jsx(M.RiRadioButtonFill,{"aria-hidden":"true",className:"size-full shrink-0 text-blue-500 group-data-[state=checked]/DropdownMenuRadioItem:flex group-data-[state=unchecked]/DropdownMenuRadioItem:hidden dark:text-blue-500"}),e.jsx(M.RiCheckboxBlankCircleLine,{"aria-hidden":"true",className:"size-full shrink-0 text-gray-300 group-data-[state=unchecked]/DropdownMenuRadioItem:flex group-data-[state=checked]/DropdownMenuRadioItem:hidden dark:text-gray-700"})]}):i==="check"?e.jsx("span",{className:"absolute left-2 flex size-4 items-center justify-center",children:e.jsx(M.RiCheckLine,{"aria-hidden":"true",className:"size-full shrink-0 text-gray-800 group-data-[state=checked]/DropdownMenuRadioItem:flex group-data-[state=unchecked]/DropdownMenuRadioItem:hidden dark:text-gray-200"})}):null,s,t&&e.jsx("span",{className:v("ml-auto text-sm font-normal text-gray-400 dark:text-gray-600"),children:t}),r&&e.jsx("span",{className:v("ml-auto text-sm font-normal tracking-widest text-gray-400 dark:border-gray-800 dark:text-gray-600"),children:r})]}));nt.displayName="DropdownMenuRadioItem";const Ht=z.forwardRef(({className:a,...t},r)=>e.jsx(ye.Label,{ref:r,className:v("px-2 py-2 text-xs font-medium tracking-wide","text-gray-500 dark:text-gray-500",a),...t}));Ht.displayName="DropdownMenuLabel";const kc=z.forwardRef(({className:a,...t},r)=>e.jsx(ye.Separator,{ref:r,className:v("-mx-1 my-1 h-px border-t border-gray-200 dark:border-gray-800",a),...t}));kc.displayName="DropdownMenuSeparator";const Ba=Ee.createColumnHelper(),Nc=[Ba.display({id:"select",header:({table:a})=>e.jsx(Qe,{checked:a.getIsAllPageRowsSelected()?!0:a.getIsSomeRowsSelected()?"indeterminate":!1,onCheckedChange:()=>a.toggleAllPageRowsSelected(),className:"translate-y-0.5","aria-label":"Select all"}),cell:({row:a})=>e.jsx(Qe,{checked:a.getIsSelected(),onCheckedChange:()=>a.toggleSelected(),className:"translate-y-0.5","aria-label":"Select row"}),enableSorting:!1,enableHiding:!1,meta:{displayName:"Select"}}),Ba.accessor("name",{header:({column:a})=>e.jsx(q,{column:a,title:"Name"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"Name"},cell:({row:a,table:t})=>{var i,n,o;const r=(i=t.options.meta)==null?void 0:i.organizationId,s=a.original.id;return e.jsx(B,{href:((o=(n=t.options.meta)==null?void 0:n.routes)==null?void 0:o.manufacturerEdit(r,s))??`/admin/${r}/manufacturers/${s}`,className:"text-blue-500 hover:underline",children:a.getValue("name")||"-"})}}),Ba.accessor("translations",{header:({column:a})=>e.jsx(q,{column:a,title:"About"}),enableSorting:!1,meta:{className:"text-left",displayName:"About"},cell:({row:a})=>{var t;return((t=a.getValue("translations").find(r=>r.about))==null?void 0:t.about)||"-"}}),Ba.accessor("createdAt",{header:({column:a})=>e.jsx(q,{column:a,title:"Created At"}),enableSorting:!1,meta:{className:"text-left",displayName:"Created At"},cell:({row:a})=>{const t=a.getValue("createdAt");return new Date(t).toLocaleDateString()}}),Ba.display({id:"edit",header:"Edit",enableSorting:!1,enableHiding:!1,meta:{className:"text-right",displayName:"Edit"},cell:({row:a,table:t})=>{var i,n,o;const r=(i=t.options.meta)==null?void 0:i.organizationId,s=a.original.id;return e.jsxs(ra,{children:[e.jsx(sa,{asChild:!0,children:e.jsx(R,{variant:"ghost",className:"group aspect-square px-1.5 py-0! h-8! hover:border hover:border-gray-300 data-[state=open]:border-gray-300 data-[state=open]:bg-gray-50 dark:hover:border-gray-700 dark:data-[state=open]:border-gray-700 dark:data-[state=open]:bg-gray-900",children:e.jsx(M.RiMoreFill,{className:"size-4 shrink-0 text-gray-500 group-hover:text-gray-700 group-data-[state=open]:text-gray-700 dark:group-hover:text-gray-300 dark:group-data-[state=open]:text-gray-300","aria-hidden":"true"})})}),e.jsxs(ia,{align:"end",className:"min-w-40",children:[e.jsx(Se,{children:e.jsx(B,{href:((o=(n=t.options.meta)==null?void 0:n.routes)==null?void 0:o.manufacturerEdit(r,s))??`/admin/${r}/manufacturers/${s}`,className:"block",children:"Edit"})}),e.jsx(Se,{className:"text-red-600 dark:text-red-500",children:"Delete"})]})]})}})],Ac=()=>{const{client:a}=P(),t=$(),r=_(),s=D.useSearchParams(),[i,n]=h.useState(""),[o]=aa.useDebounce(i,300),l=Number((s==null?void 0:s.get("page"))||"1"),{isLoading:c,isRefetching:m,isError:u,data:p}=A.useQuery({queryKey:["manufacturers",r,l,o],queryFn:async()=>{const{body:g,status:x}=await a.manufacturer.getManufacturers({params:{organizationId:r},query:{page:l,limit:10,search:o}});if(x!==200)throw new Error("Failed to fetch organizations");return g},placeholderData:A.keepPreviousData});return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 sm:gap-x-6",children:[e.jsx("div",{className:"flex w-full flex-col gap-2 sm:w-fit sm:flex-row sm:items-center",children:e.jsx(Ma,{type:"search",placeholder:"Search by manufaturer...",value:i,onChange:g=>n(g.target.value),className:"w-full sm:max-w-[250px] sm:[&>input]:h-[40px]"})}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(R,{asChild:!0,className:"hidden gap-x-2 px-2 py-1.5 text-sm sm:text-xs lg:flex",children:e.jsxs(B,{href:t.manufacturerCreate(r),children:["Create Manufacturer",e.jsx(N.PlusIcon,{className:"size-4 shrink-0","aria-hidden":"true"})]})})})]}),e.jsx(Fa,{error:u,loading:c||m,meta:p!=null&&p.meta?{...p==null?void 0:p.meta,currentPage:l}:void 0,data:(p==null?void 0:p.list)||[],columns:Nc,className:"mt-8"})]})};function Cc(){return e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-xl font-semibold text-gray-900 sm:text-2xl dark:text-gray-50",children:"Manufacturers"}),e.jsx("div",{className:"mt-4 sm:mt-6 lg:mt-6",children:e.jsx(Ac,{})})]})}const Sc=Oe.tv({base:v("inline-flex items-center gap-x-1 whitespace-nowrap rounded px-1.5 py-0.5 text-xs font-semibold ring-1"),variants:{variant:{default:["bg-blue-50 text-blue-800 ring-blue-500/30","dark:bg-blue-400/10 dark:text-blue-400 dark:ring-blue-400/30"],neutral:["bg-gray-50 text-gray-700 ring-gray-500/30","dark:bg-gray-400/10 dark:text-gray-300 dark:ring-gray-400/20"],success:["bg-emerald-50 text-emerald-800 ring-emerald-600/30","dark:bg-emerald-400/10 dark:text-emerald-400 dark:ring-emerald-400/20"],error:["bg-red-50 text-red-800 ring-red-600/20","dark:bg-red-400/10 dark:text-red-400 dark:ring-red-400/20"],warning:["bg-yellow-50 text-yellow-800 ring-yellow-600/30","dark:bg-yellow-400/10 dark:text-yellow-500 dark:ring-yellow-400/20"]}},defaultVariants:{variant:"default"}}),ue=h.forwardRef(({className:a,variant:t,...r},s)=>e.jsx("span",{ref:s,className:v(Sc({variant:t}),a),...r}));ue.displayName="Badge";const zc=({organizationId:a,id:t,status:r,refetch:s})=>{var y;const{client:i}=P(),n=A.useMutation({mutationFn:async({operation:j})=>{if((await i.order.updateStatus({params:{id:t,organizationId:a,operation:j}})).status!==200)throw new Error("Failed to update order status");return s()}}),o=(()=>{switch(r){case"pending":return"Accept";case"accepted":return"Ready";case"ready-for-dispatch":return"Dispatch";case"dispatched":return"Complete";case"completed":return"Completed";case"cancelled":return"Cancelled";default:return"Unknown"}})(),l=()=>{const j=(()=>{switch(r){case"pending":return"accepted";case"accepted":return"ready-for-dispatch";case"ready-for-dispatch":return"dispatched";case"dispatched":return"completed";default:return null}})();j&&n.mutate({operation:j})},c=()=>{n.mutate({operation:"cancelled"})},m=n.isPending,u=(y=n.variables)==null?void 0:y.operation,p=m&&u==="cancelled",g=m&&u!=="cancelled",x=r!=="completed"&&r!=="cancelled";return e.jsxs("div",{className:"flex items-center gap-2 min-w-28",children:[e.jsxs("button",{onClick:c,disabled:m||r==="cancelled"||r==="completed",className:"relative my-2 inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-md border px-2 py-1 text-center text-sm font-medium shadow-xs transition-all duration-100 ease-in-out disabled:pointer-events-none disabled:shadow-none outline outline-offset-2 outline-0 focus-visible:outline-2 outline-blue-500 dark:outline-blue-500 border-gray-300 dark:border-gray-800 text-gray-900 dark:text-gray-50 bg-white dark:bg-gray-950 hover:bg-gray-50 dark:hover:bg-gray-900/60 disabled:text-gray-400 dark:disabled:text-gray-600","tremor-id":"tremor-raw",children:[p?"Loading...":"Cancel",e.jsx(N.X,{className:"w-4 h-4 text-red-600 dark:text-red-500"})]}),x&&e.jsxs("button",{onClick:l,disabled:m,className:"relative my-2 inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-md border px-2 py-1 text-center text-sm font-medium shadow-xs transition-all duration-100 ease-in-out disabled:pointer-events-none disabled:shadow-none outline outline-offset-2 outline-0 focus-visible:outline-2 outline-blue-500 dark:outline-blue-500 border-gray-300 dark:border-gray-800 text-gray-900 dark:text-gray-50 bg-white dark:bg-gray-950 hover:bg-gray-50 dark:hover:bg-gray-900/60 disabled:text-gray-400 dark:disabled:text-gray-600","tremor-id":"tremor-raw",children:[g?"Loading...":o,e.jsx(N.CheckCircle,{className:"w-4 h-4 text-emerald-600 dark:text-emerald-500"})]})]})},Ic=a=>t=>new Intl.NumberFormat("en-US",{style:"currency",currency:a.currency||"PLN"}).format(t),ms={draft:{variant:"neutral",label:"Draft"},pending:{variant:"warning",label:"Pending"},accepted:{variant:"default",label:"Accepted"},"ready-for-dispatch":{variant:"default",label:"Ready for Dispatch"},dispatched:{variant:"default",label:"Dispatched"},completed:{variant:"success",label:"Completed"},cancelled:{variant:"error",label:"Cancelled"}},us={pending:{variant:"warning",label:"Pending"},succeeded:{variant:"success",label:"Paid"},refunded:{variant:"neutral",label:"Refunded"},failed:{variant:"error",label:"Failed"},canceled:{variant:"error",label:"Canceled"}},Ec={card:"Card",blik:"BLIK",cash_on_delivery:"Cash on Delivery",paypal:"PayPal"},et=({icon:a,title:t})=>e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("span",{className:"text-gray-400 dark:text-gray-500",children:a}),e.jsx("h3",{className:"text-sm font-bold text-gray-500 dark:text-gray-400 tracking-wide font-red-hat-display",children:t})]}),ps=({label:a,children:t})=>e.jsxs("div",{className:"flex justify-between items-center py-1.5",children:[e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:a}),e.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:t})]}),Dc=({open:a,onOpenChange:t,order:r})=>{var c,m,u,p,g,x,y,j,f,b;if(!r)return null;const s=Ic(r),i=ms[r.status||"pending"]??ms.pending,n=us[((c=r.payment)==null?void 0:c.status)||"pending"]??us.pending,o=[{label:"Created",date:r.createdAt},{label:"Accepted",date:r.acceptedAt},{label:"Ready for Dispatch",date:r.readyForDispatchAt},{label:"Dispatched",date:r.dispatchedAt},{label:"Completed",date:r.completedAt},...r.status==="cancelled"||r.cancelledAt?[{label:"Cancelled",date:r.cancelledAt}]:[]],l=r.shippingAddress;return e.jsx(Ia,{open:a,onOpenChange:t,children:e.jsxs(Ea,{className:"sm:max-w-2xl overflow-y-auto max-h-[90vh] !p-0",children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white dark:bg-[#090E1A] border-b border-gray-200 dark:border-gray-800 px-5 pt-5 pb-3",children:e.jsx(Da,{children:e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs(Ra,{className:"text-lg",children:["Order #",r.referenceId]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ue,{variant:i.variant,children:i.label}),e.jsx(ue,{variant:n.variant,children:n.label}),r.fulfilmentMethod==="pickup"&&e.jsx(ue,{variant:"neutral",children:"Pickup"})]})]}),e.jsx(yr,{className:"rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 p-1.5 -mt-1 -mr-1.5 transition-colors",children:e.jsx(N.X,{className:"h-4 w-4"})})]})})}),e.jsxs("div",{className:"px-5 pb-5 space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-5 pt-4",children:[e.jsxs("div",{children:[e.jsx(et,{icon:e.jsx(N.CreditCard,{className:"h-4 w-4"}),title:"Payment"}),e.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800 p-3 space-y-0.5",children:[e.jsx(ps,{label:"Method",children:Ec[((m=r.payment)==null?void 0:m.method)||""]||((u=r.payment)==null?void 0:u.method)||"N/A"}),e.jsx(ps,{label:"Provider",children:e.jsx("span",{className:"capitalize",children:((p=r.payment)==null?void 0:p.provider)==="not_applicable"?"N/A":((g=r.payment)==null?void 0:g.provider)||"N/A"})})]})]}),e.jsxs("div",{children:[e.jsx(et,{icon:r.fulfilmentMethod==="pickup"?e.jsx(N.MapPin,{className:"h-4 w-4"}):e.jsx(N.Truck,{className:"h-4 w-4"}),title:r.fulfilmentMethod==="pickup"?"Pickup":"Shipping"}),e.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800 p-3",children:[l?e.jsxs("div",{className:"text-sm space-y-0.5",children:[e.jsxs("p",{className:"font-medium text-gray-900 dark:text-gray-100",children:[l.firstname," ",l.lastname]}),e.jsxs("p",{className:"text-gray-500 dark:text-gray-400",children:[l.addressLineOne,l.doorNumber?` / ${l.doorNumber}`:""]}),e.jsxs("p",{className:"text-gray-500 dark:text-gray-400",children:[l.zipCode,", ",l.city]}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:l.country}),l.phone&&e.jsx("p",{className:"text-gray-500 dark:text-gray-400 pt-1",children:l.phone})]}):e.jsx("p",{className:"text-sm text-gray-400",children:"No address provided"}),r.fulfilmentMethod==="delivery"&&((x=r.shippingMethod)==null?void 0:x.title)&&e.jsx("div",{className:"mt-2 pt-2 border-t border-gray-100 dark:border-gray-800",children:e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:["via"," ",e.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:r.shippingMethod.title})]})})]})]})]}),r.inventoryConflictAt&&r.inventoryConflictItems&&r.inventoryConflictItems.length>0&&e.jsx("div",{className:"rounded-lg border border-yellow-200 bg-yellow-50 p-4 dark:border-yellow-900/50 dark:bg-yellow-950/20",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(N.AlertTriangle,{className:"h-5 w-5 text-yellow-600 dark:text-yellow-400 shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-yellow-900 dark:text-yellow-200",children:"Manual inventory review required"}),e.jsx("ul",{className:"mt-1.5 space-y-0.5 text-sm text-yellow-800 dark:text-yellow-300",children:r.inventoryConflictItems.map(w=>e.jsxs("li",{children:[w.title,": requested ",w.requestedQuantity,", available ",w.availableQuantity]},w.productId))})]})]})}),e.jsxs("div",{children:[e.jsx(et,{icon:e.jsx(N.Package,{className:"h-4 w-4"}),title:"Items"}),e.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800 overflow-hidden",children:[e.jsx("div",{className:"divide-y divide-gray-100 dark:divide-gray-800",children:r.items.map((w,k)=>{const C=w.translations.find(F=>F.locale==="en")||w.translations[0];return e.jsxs("div",{className:"flex items-center gap-3 p-3",children:[w.image&&e.jsx("div",{className:"h-12 w-12 rounded-md overflow-hidden shrink-0 bg-gray-100 dark:bg-gray-800",children:e.jsx("img",{src:w.image.url,alt:(C==null?void 0:C.title)||"Product",className:"h-full w-full object-cover"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 truncate",children:(C==null?void 0:C.title)||"Product"}),(C==null?void 0:C.subtitle)&&e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:C.subtitle})]}),e.jsxs("div",{className:"text-right shrink-0",children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:s(w.totalPrice)}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:[w.quantity," × ",s(w.unitPrice)]})]})]},k)})}),e.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-800 bg-gray-50 dark:bg-gray-900/50 px-3 py-3 space-y-1.5",children:[e.jsxs("div",{className:"flex justify-between text-sm text-gray-500 dark:text-gray-400",children:[e.jsx("span",{children:"Subtotal"}),e.jsx("span",{children:s(Number((y=r.payment)==null?void 0:y.subtotal)||0)})]}),((j=r.payment)==null?void 0:j.shipping)!=null&&r.payment.shipping>0&&e.jsxs("div",{className:"flex justify-between text-sm text-gray-500 dark:text-gray-400",children:[e.jsx("span",{children:"Shipping"}),e.jsx("span",{children:s(r.payment.shipping)})]}),((f=r.payment)==null?void 0:f.discount)!=null&&r.payment.discount>0&&e.jsxs("div",{className:"flex justify-between text-sm text-green-600 dark:text-green-400",children:[e.jsx("span",{children:"Discount"}),e.jsxs("span",{children:["-",s(r.payment.discount)]})]}),e.jsxs("div",{className:"flex justify-between text-sm font-semibold text-gray-900 dark:text-gray-100 pt-1.5 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("span",{children:"Total"}),e.jsx("span",{children:s(Number((b=r.payment)==null?void 0:b.total)||0)})]})]})]})]}),e.jsxs("div",{children:[e.jsx(et,{icon:e.jsx(N.Calendar,{className:"h-4 w-4"}),title:"Timeline"}),e.jsx("div",{className:"relative",children:o.map((w,k)=>{const C=!!w.date,F=w.label==="Cancelled",Q=k===o.length-1;return e.jsxs("div",{className:"relative flex items-start gap-3 pb-4 last:pb-0",children:[!Q&&e.jsx("div",{className:`absolute left-[5px] top-3 bottom-0 w-0.5 ${C?"bg-emerald-500":"bg-gray-200 dark:bg-gray-800"}`}),e.jsx("div",{className:`relative z-10 mt-0.5 h-3 w-3 rounded-full border-2 shrink-0 ${F&&C?"border-red-500 bg-red-500":C?"border-emerald-500 bg-emerald-500":"border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-950"}`}),e.jsxs("div",{className:"flex-1 -mt-0.5",children:[e.jsx("p",{className:`text-sm leading-tight ${C?"font-medium text-gray-900 dark:text-gray-100":"text-gray-400 dark:text-gray-600"}`,children:w.label}),C&&w.date&&e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:I.format(new Date(w.date),"dd MMM yyyy, HH:mm")})]})]},w.label)})})]})]})]})})},Rc=({order:a})=>{const[t,r]=h.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>r(!0),className:"text-blue-500 hover:underline",children:String(a.id).slice(-5)}),e.jsx(Dc,{open:t,onOpenChange:r,order:a})]})},Fc=({order:a,table:t})=>{const r=t.options.meta,s=(r==null?void 0:r.organizationId)||"",i=typeof(r==null?void 0:r.refetch)=="function"?r.refetch:()=>{};return e.jsx(zc,{organizationId:s,id:a.id,status:a.status,refetch:i})},He=Ee.createColumnHelper(),Mc=a=>{var t;return a.inventoryConflictAt?e.jsx(ue,{variant:"warning",children:"Manual review"}):((t=a.payment)==null?void 0:t.status)==="succeeded"&&a.inventoryDeductedAt?e.jsx(ue,{variant:"success",children:"Deducted"}):e.jsx(ue,{variant:"neutral",children:"Pending"})},Pc=[He.accessor("id",{header:({column:a})=>e.jsx(q,{column:a,title:"ID"}),meta:{className:"text-left",displayName:"ID"},cell:({row:a})=>e.jsx(Rc,{order:a.original}),enableSorting:!0,enableHiding:!1}),He.accessor("referenceId",{header:({column:a})=>e.jsx(q,{column:a,title:"Reference ID"}),cell:({row:a})=>e.jsx("div",{className:"w-[100px]",children:a.getValue("referenceId")}),meta:{className:"text-left",displayName:"ID"},enableSorting:!1,enableHiding:!1}),He.display({id:"customer",meta:{className:"text-left",displayName:"ID"},header:({column:a})=>e.jsx(q,{column:a,title:"Customer"}),cell:({row:a})=>{var s,i;const t=((s=a.original.shippingAddress)==null?void 0:s.firstname)||"",r=((i=a.original.shippingAddress)==null?void 0:i.lastname)||"";return e.jsx("div",{children:`${t} ${r}`.trim()||"N/A"})}}),He.accessor("payment.total",{meta:{className:"text-left",displayName:"ID"},enableSorting:!0,enableHiding:!1,header:({column:a})=>e.jsx(q,{column:a,title:"Total"}),cell:({row:a})=>{const t=parseFloat(a.original.payment.total.toString()),r=new Intl.NumberFormat("en-US",{style:"currency",currency:a.original.currency||"PLN"}).format(t);return e.jsx("div",{className:"font-medium",children:r})}}),He.accessor("createdAt",{meta:{className:"text-left",displayName:"ID"},enableSorting:!0,enableHiding:!1,header:({column:a})=>e.jsx(q,{column:a,title:"Date & Time"}),cell:({row:a})=>{const t=a.getValue("createdAt");return t?I.format(new Date(t),"dd.MM.yyyy HH:mm"):"N/A"}}),He.display({id:"paymentMethod",header:({column:a})=>e.jsx(q,{column:a,title:"Payment Method"}),cell:({row:a})=>{var r;const t=(r=a.original.payment)==null?void 0:r.method;return e.jsx("div",{children:t||"N/A"})}}),He.display({id:"address",meta:{className:"text-left",displayName:"ID"},header:({column:a})=>e.jsx(q,{column:a,title:"Address"}),cell:({row:a})=>{var n,o,l,c;const t=((n=a.original.shippingAddress)==null?void 0:n.addressLineOne)||"",r=((o=a.original.shippingAddress)==null?void 0:o.city)||"",s=((l=a.original.shippingAddress)==null?void 0:l.doorNumber)||"",i=((c=a.original.shippingAddress)==null?void 0:c.zipCode)||"";return e.jsxs("div",{children:[e.jsxs("div",{children:[t," ",s?` / ${s}`:""]}),e.jsxs("div",{children:[i?`${i}, `:"",r]})]})}}),He.display({id:"inventory",meta:{className:"text-left",displayName:"Inventory"},header:({column:a})=>e.jsx(q,{column:a,title:"Inventory"}),cell:({row:a})=>Mc(a.original)}),He.display({id:"status",header:({column:a})=>e.jsx(q,{column:a,title:"Actions"}),cell:({row:a,table:t})=>e.jsx(Fc,{order:a.original,table:t})})],Bc=()=>{const{client:a}=P(),t=_(),r=D.useSearchParams(),[s,i]=h.useState(""),[n]=aa.useDebounce(s,300),o=Number((r==null?void 0:r.get("page"))||"1"),{isLoading:l,isRefetching:c,isError:m,data:u,refetch:p}=A.useQuery({queryKey:["orders",t,o,n],queryFn:async()=>{const{body:g,status:x}=await a.order.getOrders({params:{organizationId:t},query:{page:o,limit:10,search:n}});if(x!==200)throw new Error("Failed to fetch orders");return g},placeholderData:A.keepPreviousData});return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap items-center justify-between gap-2 sm:gap-x-6",children:e.jsx("div",{className:"flex w-full flex-col gap-2 sm:w-fit sm:flex-row sm:items-center",children:e.jsx(Ma,{type:"search",placeholder:"Search by order reference...",value:s,onChange:g=>i(g.target.value),className:"w-full sm:max-w-[250px] sm:[&>input]:h-[40px]"})})}),e.jsx(Fa,{error:m,loading:l||c,meta:u!=null&&u.meta?{...u==null?void 0:u.meta,currentPage:o}:void 0,data:(u==null?void 0:u.list)||[],columns:Pc,className:"mt-8",refetch:p})]})};function Tc(){return e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-xl font-semibold text-gray-900 sm:text-2xl dark:text-gray-50",children:"Orders List"}),e.jsx("div",{className:"mt-4 sm:mt-6 lg:mt-6",children:e.jsx(Bc,{})})]})}const bn=({onClose:a,initialData:t})=>{var m;const{client:r}=P(),s=Z.useForm({resolver:be.zodResolver(t?lr:ri),defaultValues:{...t}}),i=s.watch("address.placeId"),n=s.watch("address.addressLineOne");h.useEffect(()=>{(async()=>{if(i){const{status:u,body:p}=await r.location.getPlaceDetails({params:{placeId:i}});if(u!==200)throw new Error("Failed to fetch place details");s.setValue("address.zipCode",p.zipCode,{shouldValidate:!0}),s.setValue("address.city",p.city,{shouldValidate:!0}),s.setValue("address.country",p.country,{shouldValidate:!0})}})()},[s,i]);const o=A.useMutation({mutationFn:async u=>{const{logoFile:p,...g}=u;return await r.organization.createOrganization({body:{...g,logoId:p==null?void 0:p.id}})},onSuccess:async()=>{await oe.invalidateQueries({queryKey:["organizations"]}),a&&a()}}),l=A.useMutation({mutationFn:async u=>{if(!t)throw new Error("Cannot update organization without initial data");const{logoFile:p,...g}=u;return await r.organization.updateOrganization({params:{organizationId:t.id},body:{...g,logoId:p==null?void 0:p.id}})},onSuccess:async()=>{await oe.invalidateQueries({queryKey:["organizations"]}),a&&a()}}),c=u=>{t?l.mutate(u):o.mutate(u)};return e.jsx("div",{className:"mt-6",children:e.jsx(Z.FormProvider,{...s,children:e.jsxs("form",{onSubmit:s.handleSubmit(u=>c(u)),className:"grid gap-5 grid-cols-4",children:[t&&e.jsxs("div",{className:"col-span-2",children:[e.jsx(me,{htmlFor:"organization-id",className:"font-medium flex items-center justify-between",children:"Organization ID"}),e.jsx("div",{className:"relative mt-2",children:e.jsx(le,{id:"organization-id",value:t.id,disabled:!0,readOnly:!0,className:"w-full",copyValue:t.id,copySuccessMessage:"Organization ID copied to clipboard.",copyErrorMessage:"Failed to copy organization ID. Please try again."})})]}),e.jsx(Pe,{name:"name",label:"Organization Name",placeholder:"Acme Inc.",className:"col-span-2"}),e.jsx(Pe,{name:"email",type:"email",label:"Support Email",placeholder:"john.doe@example.com",className:"col-span-2"}),e.jsx(Pe,{name:"phone",type:"phone-number",label:"Phone Number",placeholder:"Enter phone number",className:"col-span-2"}),e.jsxs("div",{className:"col-span-4 text-sm text-gray-500",children:[e.jsx(me,{htmlFor:"address.addressLineOne",className:"font-medium flex items-center justify-between",children:"Street / Address Line 1"}),e.jsx(Qt,{onChange:u=>{s.setValue("address.addressLineOne",u.addressLineOne,{shouldValidate:!0}),s.setValue("address.placeId",u.placeId,{shouldValidate:!0})},value:n??""}),((m=s.formState.errors.address)==null?void 0:m.addressLineOne)&&e.jsx("p",{className:"mt-1 text-sm text-red-500",children:s.formState.errors.address.addressLineOne.message})]}),e.jsx(Pe,{name:"address.addressLineTwo",label:"Door / Address Line 2",placeholder:"Apt 123",className:"col-span-2"}),e.jsx(Pe,{name:"address.zipCode",label:"Postal Code",placeholder:"12345",className:"col-span-2"}),e.jsx(Pe,{name:"address.city",label:"City",placeholder:"New York",className:"col-span-2"}),e.jsx(Pe,{name:"address.country",label:"Country",placeholder:"United States",className:"col-span-2",type:"country"}),e.jsx(Pe,{name:"logoFile",label:"Logo",type:"file",className:"col-span-2"}),e.jsxs("div",{className:"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2 mt-5 col-span-full border-t pt-7",children:[a&&e.jsx(R,{type:"button",className:"w-full sm:w-fit",variant:"secondary",onClick:a,children:"Cancel"}),e.jsx(R,{type:"submit",className:"w-full sm:w-fit",isLoading:o.isPending||l.isPending,loadingText:"Saving...",children:t?"Update Data":"Create Organization"})]})]})})})},Qc=({invitation:a})=>{var s;const{client:t}=P(),r=A.useMutation({mutationFn:async()=>{const{status:i}=await t.access.acceptInvitation({params:{invitationId:a.id}});if(i!==200)throw new Error("Failed to accept invitation")},onSuccess:async()=>{J.success(`Joined ${a.organization.name}`),await oe.invalidateQueries({queryKey:["organizations"]}),await oe.invalidateQueries({queryKey:["user-invitations"]})},onError:i=>{J.error((i==null?void 0:i.message)||"Failed to accept invitation")}});return e.jsxs("div",{className:"relative flex items-center rounded-md border border-dashed border-emerald-300 bg-emerald-50/50 px-4 py-3 shadow-xs dark:border-emerald-700 dark:bg-emerald-950/20",children:[e.jsx("span",{className:"absolute inset-x-0 top-1/2 h-10 w-1 -translate-y-1/2 rounded-r-md bg-emerald-500 dark:bg-emerald-500","aria-hidden":"true"}),e.jsx("div",{className:"rounded-full ml-2",children:e.jsxs("div",{className:"rounded-full h-14 w-14 bg-emerald-500 text-white text-xl flex items-center justify-center",children:[a.organization.name.charAt(0).toUpperCase(),(s=a.organization.name.charAt(1))==null?void 0:s.toUpperCase()]})}),e.jsxs("div",{className:"border-l border-emerald-200 dark:border-emerald-800 ml-6 pl-6 flex justify-between items-center w-full",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-lg font-semibold text-gray-900 dark:text-gray-50",children:a.organization.name}),e.jsx("span",{className:"inline-flex items-center rounded-md bg-emerald-100 px-2 py-0.5 text-xs font-medium text-emerald-700 dark:bg-emerald-900 dark:text-emerald-300",children:"Invited"})]}),e.jsx("p",{className:"flex items-center gap-2",children:e.jsxs("span",{className:"text-sm text-gray-500 dark:text-gray-500",children:["You have been invited as"," ",e.jsx("span",{className:"font-medium",children:a.role??"member"})]})})]}),e.jsx("div",{children:e.jsx("button",{onClick:()=>r.mutate(),disabled:r.isPending,className:"block rounded-full text-emerald-500 p-2 hover:bg-emerald-500 hover:text-white hover:translate-y-[-2px] hover:shadow-lg transition mr-2 border border-emerald-200 dark:border-emerald-700/60 hover:border-emerald-500 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:translate-y-0 disabled:hover:shadow-none",children:e.jsx(N.CheckIcon,{className:"w-5 h-5"})})})]})]})},Oc=()=>{const[a,t]=h.useState(!1),r=$(),{client:s}=P(),{organizations:i}=ke(),{data:n}=A.useQuery({queryKey:["user-invitations"],queryFn:async()=>{const{body:l,status:c}=await s.access.getUserInvitations();return c!==200?[]:l}}),o=()=>t(!1);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"max-w-4xl mx-auto py-8 px-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold text-gray-900 dark:text-gray-50",children:"Organizations"}),e.jsx("p",{className:"text-gray-500 sm:text-sm/6 dark:text-gray-500",children:"Select a organization to get started."})]}),e.jsx("div",{className:"w-min h-min",children:e.jsxs(R,{onClick:()=>t(!0),variant:"primary",children:[e.jsx(N.PlusIcon,{className:"w-4 h-4 mr-1"})," Add New"]})})]}),i.loading?e.jsx("div",{className:"flex justify-center items-center h-32 mt-5",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsxs("svg",{"aria-hidden":"true",className:"w-8 h-8 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600",viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",fill:"currentColor"}),e.jsx("path",{d:"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",fill:"currentFill"})]}),e.jsx("p",{className:"text-gray-500 text-sm mt-2",children:"Loading organizations..."})]})}):e.jsxs("div",{className:"grid grid-cols-1 gap-y-3 gap-x-4 animate-fade-in mt-5",children:[n==null?void 0:n.map(l=>e.jsx(Qc,{invitation:l},l.id)),i.data.map(l=>{var c,m;return e.jsxs("div",{className:"relative flex items-center rounded-md border border-gray-200 bg-white px-4 py-3 shadow-xs dark:border-gray-800 dark:bg-gray-900",children:[e.jsx("span",{className:"absolute inset-x-0 top-1/2 h-10 w-1 -translate-y-1/2 rounded-r-md bg-blue-500 dark:bg-blue-500","aria-hidden":"true"}),l.logoFile?e.jsx(ze,{src:l.logoFile.url,alt:l.name,width:100,height:100,className:"rounded-lg ml-2 h-16 w-16 object-cover"}):e.jsx("div",{className:"rounded-full ml-2",children:e.jsxs("div",{className:"rounded-full h-14 w-14 bg-blue-500 text-white text-xl flex items-center justify-center",children:[l.name.charAt(0).toUpperCase(),l.name.charAt(1).toUpperCase()]})}),e.jsxs("div",{className:"border-l ml-6 pl-6 flex justify-between items-center w-full",children:[e.jsxs("div",{children:[e.jsx("p",{className:"flex items-center justify-between gap-2",children:e.jsx("span",{className:"text-lg font-semibold text-gray-900 dark:text-gray-50",children:l.name})}),e.jsx("p",{className:"flex items-center justify-between gap-2",children:e.jsxs("span",{className:"text-sm text-gray-500 dark:text-gray-500",children:[(c=l.address)==null?void 0:c.addressLineOne,","," ",(m=l.address)==null?void 0:m.city]})})]}),e.jsx("div",{children:e.jsx(B,{className:"block rounded-full text-blue-500 p-2 hover:bg-blue-500 hover:text-white hover:translate-y-[-2px] hover:shadow-lg transition mr-2 border border-gray-200 dark:border-gray-700/60 hover:border-blue-500",href:r.dashboard(l.id),children:e.jsx(N.ArrowRight,{className:"w-5 h-5"})})})]})]},l.id)})]})]}),e.jsxs(Ia,{onOpenChange:o,open:a,children:[e.jsx(sn,{className:"w-full text-left"}),e.jsxs(Ea,{className:"sm:max-w-xl",children:[e.jsxs(Da,{children:[e.jsx(Ra,{children:"Create a Organization"}),e.jsx(qt,{className:"mt-1 text-sm leading-6",children:"Fill in the details below to create a new organization"})]}),e.jsx(bn,{onClose:o})]})]})]})};function Lc(){const{appearance:a}=Ss(),t=a==null?void 0:a.organizationImage;return e.jsxs("div",{className:"flex w-full min-h-screen",children:[t&&e.jsx("div",{className:"hidden lg:block relative w-1/2 overflow-hidden",children:e.jsx(ze,{src:t,alt:"Organization Visual",width:4e3,height:2250,className:"w-full h-full object-cover min-h-screen"})}),e.jsx("div",{className:`w-full ${t?"lg:w-1/2":""} flex items-center justify-center p-8`,children:e.jsx("div",{className:"w-full max-w-md space-y-8",children:e.jsx(Oc,{})})})]})}const ft=de.Root;ft.displayName="Select";const Jc=de.Group;Jc.displayName="SelectGroup";const yt=de.Value;yt.displayName="SelectValue";const Vc=[v("group/trigger flex w-full select-none items-center justify-between gap-2 truncate rounded-md border px-3 py-2 shadow-xs outline-hidden transition sm:text-sm","border-gray-300 dark:border-gray-800","text-gray-900 dark:text-gray-50","data-placeholder:text-gray-500 dark:data-placeholder:text-gray-500","bg-white dark:bg-gray-950","hover:bg-gray-50 dark:hover:bg-gray-950/50","data-disabled:bg-gray-100 data-disabled:text-gray-400","dark:data-disabled:border-gray-700 dark:data-disabled:bg-gray-800 dark:data-disabled:text-gray-500",Sa)],bt=h.forwardRef(({className:a,hasError:t,children:r,...s},i)=>e.jsxs(de.Trigger,{ref:i,className:v(Vc,t?Lt:"",a),...s,children:[e.jsx("span",{className:"truncate",children:r}),e.jsx(de.Icon,{asChild:!0,children:e.jsx(M.RiArrowDownSLine,{className:v("-mr-1 size-5 shrink-0","text-gray-400 dark:text-gray-600","group-data-disabled/trigger:text-gray-300 dark:group-data-disabled/trigger:text-gray-600")})})]}));bt.displayName="SelectTrigger";const jn=h.forwardRef(({className:a,...t},r)=>e.jsx(de.ScrollUpButton,{ref:r,className:v("flex cursor-default items-center justify-center py-1",a),...t,children:e.jsx(M.RiArrowUpSLine,{className:"size-3 shrink-0","aria-hidden":"true"})}));jn.displayName=de.ScrollUpButton.displayName;const wn=h.forwardRef(({className:a,...t},r)=>e.jsx(de.ScrollDownButton,{ref:r,className:v("flex cursor-default items-center justify-center py-1",a),...t,children:e.jsx(M.RiArrowDownSLine,{className:"size-3 shrink-0","aria-hidden":"true"})}));wn.displayName=de.ScrollDownButton.displayName;const jt=h.forwardRef(({className:a,position:t="popper",children:r,sideOffset:s=8,collisionPadding:i=10,...n},o)=>e.jsx(de.Portal,{children:e.jsxs(de.Content,{ref:o,className:v("relative z-50 overflow-hidden rounded-md border shadow-xl shadow-black/[2.5%]","min-w-[calc(var(--radix-select-trigger-width)-2px)] max-w-[95vw]","max-h-(--radix-select-content-available-height)","bg-white dark:bg-gray-950","text-gray-900 dark:text-gray-50","border-gray-200 dark:border-gray-800","will-change-[transform,opacity]","data-[state=closed]:animate-hide","data-[side=bottom]:animate-slideDownAndFade data-[side=left]:animate-slideLeftAndFade data-[side=right]:animate-slideRightAndFade data-[side=top]:animate-slideUpAndFade",a),sideOffset:s,position:t,collisionPadding:i,...n,children:[e.jsx(jn,{}),e.jsx(de.Viewport,{className:v("p-1",t==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[calc(var(--radix-select-trigger-width))]"),children:r}),e.jsx(wn,{})]})}));jt.displayName="SelectContent";const qc=h.forwardRef(({className:a,...t},r)=>e.jsx(de.Label,{ref:r,className:v("px-3 py-2 text-xs font-medium tracking-wide","text-gray-500 dark:text-gray-500",a),...t}));qc.displayName="SelectGroupLabel";const $e=h.forwardRef(({className:a,children:t,...r},s)=>e.jsxs(de.Item,{ref:s,className:v("grid cursor-pointer grid-cols-[1fr_20px] gap-x-2 rounded px-3 py-2 outline-hidden transition-colors data-[state=checked]:font-semibold sm:text-sm","text-gray-900 dark:text-gray-50","data-disabled:pointer-events-none data-disabled:text-gray-400 data-disabled:hover:bg-none dark:data-disabled:text-gray-600","focus-visible:bg-gray-100 dark:focus-visible:bg-gray-900","hover:bg-gray-100 dark:hover:bg-gray-900",a),...r,children:[e.jsx(de.ItemText,{className:"flex-1 truncate",children:t}),e.jsx(de.ItemIndicator,{children:e.jsx(M.RiCheckLine,{className:"size-5 shrink-0 text-gray-800 dark:text-gray-200","aria-hidden":"true"})})]}));$e.displayName="SelectItem";const Hc=h.forwardRef(({className:a,children:t,period:r,...s},i)=>e.jsxs(de.Item,{ref:i,className:v("relative flex cursor-pointer items-center rounded py-2 pl-8 pr-3 outline-hidden transition-colors data-[state=checked]:font-semibold sm:text-sm","text-gray-900 dark:text-gray-50","data-disabled:pointer-events-none data-disabled:text-gray-400 data-disabled:hover:bg-none dark:data-disabled:text-gray-600","focus-visible:bg-gray-100 dark:focus-visible:bg-gray-900","hover:bg-gray-100 dark:hover:bg-gray-900",a),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(de.ItemIndicator,{children:e.jsx(M.RiCheckLine,{className:"size-5 shrink-0 text-gray-800 dark:text-gray-200","aria-hidden":"true"})})}),e.jsxs("div",{className:"flex w-full items-center",children:[e.jsx("span",{className:"w-40 sm:w-32",children:e.jsx(de.ItemText,{children:t})}),e.jsx("span",{children:(r==null?void 0:r.from)&&(r==null?void 0:r.to)&&e.jsxs("span",{className:"whitespace-nowrap font-normal text-gray-400",children:[I.format(r.from,"MMM d, yyyy")," –"," ",I.format(r.to,"MMM d, yyyy")]})})]})]}));Hc.displayName="SelectItemPeriod";const Uc=h.forwardRef(({className:a,...t},r)=>e.jsx(de.Separator,{ref:r,className:v("-mx-1 my-1 h-px","bg-gray-300 dark:bg-gray-700",a),...t}));Uc.displayName="SelectSeparator";const xa=Ee.createColumnHelper(),Zc=({row:a,table:t})=>{var m,u;const{client:r}=P(),s=a.original.id,i=a.getValue("publishedAt"),n=(m=t.options.meta)==null?void 0:m.organizationId,o=(u=t.options.meta)==null?void 0:u.refetch,l=A.useMutation({mutationFn:async()=>{if((await r.productCategory.updateStatus({params:{id:s,organizationId:n,operation:i?"unpublish":"publish"}})).status!==200)throw new Error("Failed to update product category status");o&&await o()}}),c=()=>{l.mutate()};return l.isPending?e.jsx("div",{className:"min-w-28",children:e.jsxs("button",{className:"relative my-2 inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-md border px-2 py-1 text-center text-sm font-medium shadow-xs transition-all duration-100 ease-in-out disabled:pointer-events-none disabled:shadow-none outline outline-offset-2 outline-0 focus-visible:outline-2 outline-blue-500 dark:outline-blue-500 border-gray-300 dark:border-gray-800 text-gray-900 dark:text-gray-50 bg-white dark:bg-gray-950 hover:bg-gray-50 dark:hover:bg-gray-900/60 disabled:text-gray-400 dark:disabled:text-gray-600","tremor-id":"tremor-raw",disabled:!0,children:[e.jsx(pe,{className:"w-4 h-4"})," Saving..."]})}):e.jsx("div",{className:"min-w-28",children:e.jsxs("button",{onClick:c,className:"relative my-2 inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-md border px-2 py-1 text-center text-sm font-medium shadow-xs transition-all duration-100 ease-in-out disabled:pointer-events-none disabled:shadow-none outline outline-offset-2 outline-0 focus-visible:outline-2 outline-blue-500 dark:outline-blue-500 border-gray-300 dark:border-gray-800 text-gray-900 dark:text-gray-50 bg-white dark:bg-gray-950 hover:bg-gray-50 dark:hover:bg-gray-900/60 disabled:text-gray-400 dark:disabled:text-gray-600","tremor-id":"tremor-raw",children:[i?e.jsx(N.CheckCircle,{className:"w-4 h-4 text-emerald-600 dark:text-emerald-500"}):e.jsx(N.EyeOffIcon,{className:"w-4 h-4 text-red-600 dark:text-red-500"}),i?"Published":"Draft"]})})},_c=({row:a,table:t})=>{var c,m,u,p;const{client:r}=P(),s=a.original.id,i=(c=t.options.meta)==null?void 0:c.organizationId,n=(m=t.options.meta)==null?void 0:m.refetch,o=A.useMutation({mutationFn:async()=>{if((await r.productCategory.deleteProductCategory({params:{id:s,organizationId:i}})).status!==204)throw new Error("Failed to delete product category");n&&await n()}}),l=()=>{window.confirm("Are you sure you want to delete this product category? This action cannot be undone.")&&o.mutate()};return e.jsxs(ra,{children:[e.jsx(sa,{asChild:!0,children:e.jsx(R,{variant:"ghost",className:"group aspect-square px-1.5 py-0! h-8! hover:border hover:border-gray-300 data-[state=open]:border-gray-300 data-[state=open]:bg-gray-50 dark:hover:border-gray-700 dark:data-[state=open]:border-gray-700 dark:data-[state=open]:bg-gray-900",disabled:o.isPending,children:o.isPending?e.jsx(pe,{className:"size-4 shrink-0"}):e.jsx(M.RiMoreFill,{className:"size-4 shrink-0 text-gray-500 group-hover:text-gray-700 group-data-[state=open]:text-gray-700 dark:group-hover:text-gray-300 dark:group-data-[state=open]:text-gray-300","aria-hidden":"true"})})}),e.jsxs(ia,{align:"end",className:"min-w-40",children:[e.jsx(Se,{children:e.jsxs(B,{href:((p=(u=t.options.meta)==null?void 0:u.routes)==null?void 0:p.productCategoryEdit(i,s))??`/admin/${i}/product-categories/${s}`,className:"block flex items-center gap-2",children:[e.jsx(N.PencilIcon,{className:"w-4 h-4"}),"Edit"]})}),e.jsx(Se,{className:"text-red-600 dark:text-red-500 cursor-pointer",onClick:l,disabled:o.isPending,children:e.jsxs("div",{className:"flex items-center gap-2",children:[o.isPending?e.jsx(pe,{className:"w-4 h-4"}):e.jsx(N.Trash2,{className:"w-4 h-4"}),o.isPending?"Deleting...":"Delete"]})})]})]})},$c=[xa.display({id:"select",header:({table:a})=>e.jsx(Qe,{checked:a.getIsAllPageRowsSelected()?!0:a.getIsSomeRowsSelected()?"indeterminate":!1,onCheckedChange:()=>a.toggleAllPageRowsSelected(),className:"translate-y-0.5","aria-label":"Select all"}),cell:({row:a})=>e.jsx(Qe,{checked:a.getIsSelected(),onCheckedChange:()=>a.toggleSelected(),className:"translate-y-0.5","aria-label":"Select row"}),enableSorting:!1,enableHiding:!1,meta:{displayName:"Select"}}),xa.accessor("title",{header:({column:a})=>e.jsx(q,{column:a,title:"Title"}),enableSorting:!1,meta:{className:"text-left",displayName:"Title"},cell:({row:a,table:t})=>{var i,n,o;const r=(i=t.options.meta)==null?void 0:i.organizationId,s=a.original.id;return e.jsx(B,{href:((o=(n=t.options.meta)==null?void 0:n.routes)==null?void 0:o.productCategoryEdit(r,s))??`/admin/${r}/product-categories/${s}`,className:"text-blue-500 hover:underline",children:a.getValue("title")||"-"})}}),xa.accessor("slug",{header:({column:a})=>e.jsx(q,{column:a,title:"Slug"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"Slug"}}),xa.accessor("publishedAt",{header:({column:a})=>e.jsx(q,{column:a,title:"Status"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"Status"},cell:({row:a,table:t})=>e.jsx(Zc,{row:a,table:t})}),xa.accessor("createdAt",{header:({column:a})=>e.jsx(q,{column:a,title:"Created At"}),enableSorting:!1,meta:{className:"text-left",displayName:"Created At"},cell:({row:a})=>{const t=a.getValue("createdAt");return new Date(t).toLocaleDateString()}}),xa.display({id:"edit",header:"Edit",enableSorting:!1,enableHiding:!1,meta:{className:"text-right",displayName:"Edit"},cell:({row:a,table:t})=>e.jsx(_c,{row:a,table:t})})],Wc=()=>{const{client:a}=P(),t=$(),{defaultLocale:r}=ke(),s=_(),i=D.usePathname(),n=D.useRouter(),o=D.useSearchParams(),[l,c]=h.useState(""),[m,u]=h.useState("all"),p=Number((o==null?void 0:o.get("page"))||"1"),[g]=aa.useDebounce(l,300),x=m==="all"?void 0:m,y=(F,Q)=>{const O=new URLSearchParams(o==null?void 0:o.toString());return O.set(F,Q),O.toString()},j=()=>{p!==1&&n.replace(`${i}?${y("page","1")}`)},{isLoading:f,isRefetching:b,isError:w,data:k,refetch:C}=A.useQuery({queryKey:["productCategories",s,p,g,x,r],queryFn:async()=>{const{body:F,status:Q}=await a.productCategory.getProductCategories({params:{organizationId:s},query:{page:p,limit:10,search:g,locale:r,publishedStatus:x}});if(Q!==200)throw new Error("Failed to fetch product categories");return F},placeholderData:A.keepPreviousData});return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 sm:gap-x-6",children:[e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:w-fit sm:flex-row sm:items-center",children:[e.jsx(Ma,{type:"search",placeholder:"Search by product category...",value:l,onChange:F=>{c(F.target.value),j()},className:"w-full sm:max-w-[250px] sm:[&>input]:h-[40px]"}),e.jsxs(ft,{value:m,onValueChange:F=>{u(F),j()},children:[e.jsx(bt,{className:"w-full sm:w-[190px]",children:e.jsx(yt,{placeholder:"All statuses"})}),e.jsxs(jt,{children:[e.jsx($e,{value:"all",children:"All statuses"}),e.jsx($e,{value:"published",children:"Published"}),e.jsx($e,{value:"unpublished",children:"Unpublished"})]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(R,{asChild:!0,className:"hidden gap-x-2 px-2 py-1.5 text-sm sm:text-xs lg:flex",children:e.jsxs(B,{href:t.productCategoryCreate(s),children:["Create Product Category",e.jsx(N.PlusIcon,{className:"size-4 shrink-0","aria-hidden":"true"})]})})})]}),e.jsx(Fa,{error:w,loading:f||b,meta:k==null?void 0:k.meta,data:(k==null?void 0:k.list)||[],columns:$c,className:"mt-8",refetch:C})]})};function Kc(){return e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-xl font-semibold text-gray-900 sm:text-2xl dark:text-gray-50",children:"Product Categories"}),e.jsx("div",{className:"mt-4 sm:mt-6 lg:mt-6",children:e.jsx(Wc,{})})]})}const Gc=[{name:"slug",label:"Slug",type:"text",placeholder:"electronics",colspan:2},{name:"title",label:"Title",type:"text",placeholder:"Electronics",colspan:2,localizable:!0},{name:"description",label:"Description",type:"textarea",placeholder:"All electronic devices and accessories.",colspan:2,localizable:!0},{name:"image",label:"Image",type:"file"}],vn=({initialData:a})=>{const{client:t}=P(),r=D.useRouter(),s=$(),i=_(),{defaultLocale:n,supportedLocales:o}=ke(),l=a?Zo:Uo,c=Z.useForm({resolver:be.zodResolver(l),defaultValues:a?{defaultLocale:n,slug:a.slug,image:a.image,translations:a.translations}:{defaultLocale:n,translations:o.map(x=>({locale:x}))}}),m=A.useMutation({mutationFn:async x=>{var f;const y={slug:x.slug,defaultLocale:x.defaultLocale,translations:x.translations,imageId:(f=x.image)==null?void 0:f.id},{status:j}=await t.productCategory.createProductCategory({params:{organizationId:i},body:y});if(j!==201)throw J.error("Failed to create product category. Please try again later."),new Error("Failed to create product category")}}),u=A.useMutation({mutationFn:async x=>{var f;const y={slug:x.slug,defaultLocale:x.defaultLocale,translations:x.translations,imageId:((f=x.image)==null?void 0:f.id)||null},{status:j}=await t.productCategory.updateProductCategory({params:{organizationId:i,id:a.id},body:y});if(j!==200)throw J.error("Failed to update product category. Please try again later."),new Error("Failed to update product category")}}),p=async()=>{J.success("Product category saved successfully"),r.push(s.productCategories(i)),await oe.invalidateQueries({queryKey:["productCategories"]})},g=x=>{a?u.mutate(x,{onSuccess:p}):m.mutate(x,{onSuccess:p})};return e.jsx(Be,{form:c,config:Gc,onSubmit:g,loading:m.isPending||u.isPending,cancelText:"Go back",okText:a?"Update Product Category":"Create Product Category"})};function Xc(){return e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-gray-900 sm:text-xl dark:text-gray-50",children:"Create Product Category"}),e.jsx(H,{}),e.jsx("div",{className:"pt-6",children:e.jsx("div",{className:"space-y-10",children:e.jsx("section",{"aria-labelledby":"product-category-info",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"product-category-info",className:"scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Product Category Information"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Enter the information about the product category."})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsx(vn,{})})]})})})})]})}function Yc(){const a=_(),t=za(),{client:r}=P(),{isLoading:s,data:i}=A.useQuery({queryKey:["productCategories",a,t],queryFn:async()=>{const{status:n,body:o}=await r.productCategory.getProductCategory({params:{id:t,organizationId:a}});if(n!==200)throw J.error("Failed to fetch product category. Please refresh or try again later."),new Error("Failed to fetch product category");return o},throwOnError:!0,placeholderData:A.keepPreviousData});return e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-gray-900 sm:text-xl dark:text-gray-50",children:"Edit Product Category"}),e.jsx(H,{}),e.jsx("div",{className:"pt-6",children:e.jsx("div",{className:"space-y-10",children:e.jsx("section",{"aria-labelledby":"product-category-info",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"product-category-info",className:"scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Product Category Information"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Enter the information about the product category."})]}),e.jsx("div",{className:"md:col-span-2",children:s||!i?e.jsx("div",{className:"flex justify-center items-center h-[500px] mt-5",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(pe,{className:"w-12 h-12"}),e.jsx("p",{className:"text-gray-500 text-sm mt-3",children:"Loading data..."})]})}):e.jsx(vn,{initialData:i})})]})})})})]})}const em=({form:a})=>{const{client:t}=P(),r=_(),{data:s}=A.useQuery({queryKey:["product-categories",r],queryFn:async()=>{const o=await t.productCategory.getProductCategories({params:{organizationId:r},query:{limit:100}});if(o.status!==200)throw new Error("Failed to fetch product categories");return o.body.list.map(l=>({label:l.translations[0].title||"",value:l.id}))},throwOnError:!0}),{data:i}=A.useQuery({queryKey:["manufacturers",r],queryFn:async()=>{const o=await t.manufacturer.getManufacturers({params:{organizationId:r},query:{limit:100}});if(o.status!==200)throw new Error("Failed to fetch product categories");return o.body.list.map(l=>({label:l.name,value:l.id}))},throwOnError:!0}),n=[{name:"title",label:"Title",type:"text",placeholder:"Enter product name",colspan:2,localizable:!0},{name:"description",label:"Description",type:"textarea",placeholder:"Enter product description",colspan:2,localizable:!0},{name:"slug",label:"Slug",type:"text",placeholder:"Enter a URL-friendly slug"},{name:"sku",label:"SKU (Stock Keeping Unit)",type:"text",placeholder:"Enter SKU"},{name:"categories",label:"Categories",type:"select",options:s||[],multiple:!0},{name:"manufacturerId",label:"Manufacturer",type:"select",options:i||[]},{name:"images",label:"Images",type:"file",multiple:!0,colspan:2}];return e.jsx("section",{"aria-labelledby":"product-information",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"product-information",className:"text-lg scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Basic Information"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Enter the basic information of your product, including the name, description, base price, and other essential details."})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsx(Be,{form:a,config:n})})]})})},am=({form:a})=>{const[t,r]=h.useState([]);h.useEffect(()=>{const l=a.getValues("metadata")||{},c=Object.entries(l);c.length>0&&r(c.map(([m,u],p)=>({id:`metadata-${p}-${Date.now()}`,key:m,value:u})))},[a]);const s=h.useCallback(l=>{const c={};l.forEach(m=>{m.key&&m.value&&(c[m.key]=m.value)}),a.setValue("metadata",Object.keys(c).length>0?c:void 0)},[a]),i=()=>{const l={id:`metadata-${Date.now()}`,key:"",value:""},c=[...t,l];r(c)},n=l=>{const c=t.filter((m,u)=>u!==l);r(c),s(c)},o=(l,c,m)=>{const u=[...t];u[l][c]=m,r(u),s(u)};return e.jsx("section",{"aria-labelledby":"product-metadata",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"product-metadata",className:"text-lg scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Metadata"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Add custom key-value pairs to store additional information about your product. Keys must start with a letter and contain only letters, numbers, underscores, or dashes."})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsxs("div",{className:"space-y-4",children:[t.map((l,c)=>e.jsxs("div",{className:"flex gap-4 items-start",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(me,{htmlFor:`metadata-key-${c}`,className:"font-medium",children:"Key"}),e.jsx(le,{id:`metadata-key-${c}`,type:"text",value:l.key,onChange:m=>o(c,"key",m.target.value),placeholder:"e.g., color, size, weight",className:"mt-2"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx(me,{htmlFor:`metadata-value-${c}`,className:"font-medium",children:"Value"}),e.jsx(le,{id:`metadata-value-${c}`,type:"text",value:l.value,onChange:m=>o(c,"value",m.target.value),placeholder:"e.g., red, large, 2.5kg",className:"mt-2"})]}),e.jsx(R,{type:"button",variant:"destructive",className:"mt-8 min-w-[42px] h-[42px] p-0",onClick:()=>n(c),children:e.jsx(N.TrashIcon,{className:"w-4 h-4"})})]},l.id)),t.length===0&&e.jsx("p",{className:"text-sm text-gray-500 italic",children:"No metadata added yet. Click the button below to add key-value pairs."}),e.jsxs(R,{type:"button",variant:"secondary",onClick:i,className:"w-full shadow-none mt-2",children:[e.jsx(N.PlusIcon,{className:"w-4 h-4 mr-2"}),"Add Row"]})]})})]})})},tm=({open:a,onClose:t,initialData:r,onSubmit:s})=>{const{defaultLocale:i,supportedLocales:n}=ke(),o=Z.useForm({resolver:be.zodResolver(Ws),defaultValues:r?{...r,defaultLocale:i}:{defaultLocale:i,translations:n.map(p=>({locale:p,title:""})),modifiers:[{title:"",price:0}]}}),{fields:l,append:c,remove:m}=Z.useFieldArray({control:o.control,name:"modifiers"}),u=p=>{s(p),t(),o.reset({defaultLocale:i,translations:n.map(g=>({locale:g,title:""})),modifiers:[{title:"",price:0}]})};return e.jsx(Ia,{open:a,onOpenChange:t,children:e.jsxs(Ea,{className:"max-w-[710px]",children:[e.jsxs(Da,{children:[e.jsx(Ra,{children:"New Modifier Group"}),e.jsx(qt,{className:"text-sm mb-5",children:"Modifiers allow you to create different variants of the same product. Create or choose existing modifiers for your product."})]}),e.jsxs(Z.FormProvider,{...o,children:[e.jsx(Be,{form:o,config:[{name:"title",label:"Group Title",type:"text",placeholder:'For example: "Spice Level" or "Select toppings".',colspan:2,localizable:!0},{name:"selectMin",label:"Select Min",type:"number",placeholder:"Minimum selections",colspan:1},{name:"selectMax",label:"Select Max",type:"number",placeholder:"Maximum selections",colspan:1}]}),e.jsx("h3",{className:"text-lg font-semibold mt-6",children:"Modifier Options"}),e.jsx("p",{className:"text-sm text-gray-500 mb-6 mt-1",children:"Add options to this modifier group. Modifier options are the different variants of the product. The price adds to the base price of the product. Leave the price as 0 if it's free."}),l.map((p,g)=>e.jsxs("div",{className:"mb-4 flex",children:[e.jsx(Be,{form:o,columns:2,config:[{name:`modifiers.${g}.title`,label:"Title",type:"text",placeholder:'eg: "Mild" or "Pepperoni"',colspan:1},{name:`modifiers.${g}.price`,label:"Price",type:"number",placeholder:"Price for this modifier",colspan:1,prefix:"USD"}]}),l.length>1&&e.jsx(R,{type:"button",variant:"destructive",className:"mt-auto ml-4 min-w-[42px] h-[42px] p-0! shadow-none!",onClick:()=>m(g),children:e.jsx(N.XIcon,{className:"w-4 h-4"})})]},p.id)),e.jsx(R,{type:"button",variant:"secondary",className:"mb-4 mt-4 ml-auto w-full shadow-none",onClick:()=>c({title:"",price:0}),children:"Add Another Option"}),e.jsx(H,{className:"mt-8 mb-6"}),e.jsxs("div",{className:"flex justify-end space-x-3 mt-6 col-span-full",children:[e.jsx(R,{type:"button",className:"w-full sm:w-fit",variant:"secondary",onClick:t,children:"Cancel"}),e.jsx(R,{type:"button",className:"w-full sm:w-fit",onClick:o.handleSubmit(u),children:r?"Save Modifier Group":"Create Modifier Group"})]})]})]})})},rm=({form:a})=>{const{control:t}=a,{defaultLocale:r}=ke(),{fields:s,append:i,remove:n,update:o}=Z.useFieldArray({control:t,name:"modifierGroups"}),[l,c]=h.useState(!1),[m,u]=h.useState(null),p=f=>({...f,defaultLocale:f.defaultLocale??r,modifiers:f.modifiers??[]}),g=f=>{f.preventDefault(),u(null),c(!0)},x=f=>{u(f),c(!0)},y=f=>{if(m===null){i(p(f)),c(!1);return}o(m,p(f)),c(!1)},j=()=>{i({defaultLocale:r,selectMin:1,selectMax:1,modifiers:[{title:"Łagodny (Mild)",sku:"null",price:0},{title:"Średni (Medium)",sku:"null",price:0},{title:"Ostry (Spicy)",sku:"null",price:0}],translations:[{locale:"en",title:"Spice Level"},{locale:"pl",title:"Ostrość"}]})};return e.jsxs("section",{"aria-labelledby":"product-modifiers",className:"min-h-[200px]",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"product-modifiers",className:"text-lg scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Product Modifiers (Optional)"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Modifiers allow you to create different variants of the same product. Create or choose existing modifiers for your product."})]}),e.jsx("div",{className:"md:col-span-2",children:s.length===0?e.jsxs("div",{className:"text-center flex-col justify-center items-center",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"No Modifier Groups"}),e.jsx("p",{className:"text-gray-500 max-w-[500px] mx-auto mt-1",children:"If your product has different options or variants, you can add modifier groups to manage them."}),e.jsxs("div",{className:"flex space-x-3 mx-auto w-min mt-6",children:[e.jsxs(R,{type:"button",variant:"secondary",className:"shadow-none",onClick:j,children:[e.jsx(N.BookCopyIcon,{className:"w-4 h-4 mr-2"})," Add From Template"]}),e.jsxs(R,{type:"button",variant:"secondary",className:"shadow-none",onClick:g,children:[e.jsx(N.PlusIcon,{className:"w-4 h-4 mr-2"})," Create Modifier Group"]})]})]}):e.jsxs("div",{className:"space-y-10",children:[e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsxs(R,{type:"button",variant:"secondary",className:"shadow-none",onClick:j,children:[e.jsx(N.BookCopyIcon,{className:"w-4 h-4 mr-2"})," Add From Template"]}),e.jsxs(R,{type:"button",variant:"secondary",className:"shadow-none",onClick:g,children:[e.jsx(N.PlusIcon,{className:"w-4 h-4 mr-2"})," Create Modifier Group"]})]}),e.jsx("div",{className:"space-y-4",children:s.map((f,b)=>{var w;return e.jsxs("div",{className:"p-4 border rounded-md",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-lg font-semibold",children:f.translations[0].title||"Unnamed Group"}),e.jsxs("div",{children:[e.jsx("button",{type:"button",onClick:()=>x(b),className:"text-blue-500 font-medium hover:underline text-sm mr-4",children:"Edit"}),e.jsx("button",{type:"button",onClick:()=>n(b),className:"text-red-500 font-medium hover:underline text-sm p-0!",children:"Remove"})]})]}),e.jsxs("p",{className:"text-sm text-gray-500 mt-3",children:["Min: ",f.selectMin," | Max: ",f.selectMax]}),e.jsxs("p",{className:"text-sm text-gray-500 mt-1",children:["Available Options:"," ",(w=f.modifiers)==null?void 0:w.map(k=>k==null?void 0:k.title).join(",")]})]},f.id)})})]})})]}),e.jsx(tm,{open:l,initialData:m===null?null:s[m],onSubmit:y,onClose:()=>{c(!1),u(null)}},m)]})},sm=({form:a,loading:t})=>{const{defaultCurrency:r}=ke(),s=[{name:"basePrice",label:"Base Price",type:"number",placeholder:"Enter base price",prefix:r},{name:"discountedBasePrice",label:"Discounted Price",type:"number",placeholder:"Enter discounted price",prefix:r},{name:"availableQuantity",label:"Available Quantity",type:"number",placeholder:"Leave blank for unlimited stock"}];return e.jsx("section",{"aria-labelledby":"product-information",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"product-information",className:"text-lg scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Pricing"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Enter the pricing details of your product, including the base price and discounted price."})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx(Be,{form:a,config:s,loading:t}),e.jsx("p",{className:"mt-3 text-xs text-gray-500",children:"Leave available quantity blank to keep inventory unlimited."})]})]})})},kn=({initialData:a})=>{var j,f;const{client:t}=P(),r=D.useRouter(),s=$(),i=_(),{defaultCurrency:n,defaultLocale:o,supportedLocales:l}=ke(),c=a==null?void 0:a.id,m=a?Ko:Wo,u=Z.useForm({resolver:be.zodResolver(m),defaultValues:a?{...a,defaultLocale:o,categories:(j=a.categories)==null?void 0:j.map(b=>b.id),translations:a.translations,images:a.images,metadata:a.metadata,modifierGroups:(f=a.modifierGroups)==null?void 0:f.map(b=>({...b,defaultLocale:o,translations:b.translations,modifiers:b.modifiers}))}:{defaultLocale:o,translations:l.map(b=>({locale:b})),currency:n}}),p=A.useMutation({mutationFn:async b=>{const{status:w}=await t.product.createProduct({params:{organizationId:i},body:b});if(w!==201)throw new Error("Failed to create product")}}),g=A.useMutation({mutationFn:async b=>{const{status:w}=await t.product.updateProduct({params:{organizationId:i,id:c},body:b});if(w!==200)throw new Error("Failed to update product")}}),x=async()=>{J.success("Product saved successfully"),r.push(s.products(i)),await oe.invalidateQueries({queryKey:["products"]}),c&&await oe.invalidateQueries({queryKey:["product",i,c]})},y=b=>{a?g.mutate(b,{onSuccess:x}):p.mutate(b,{onSuccess:x})};return e.jsx(Z.FormProvider,{...u,children:e.jsxs("form",{onSubmit:u.handleSubmit(b=>y(b)),className:"space-y-14",children:[e.jsx(em,{form:u}),e.jsx(H,{}),e.jsx(sm,{form:u}),e.jsx(H,{}),e.jsx(rm,{form:u}),e.jsx(H,{}),e.jsx(am,{form:u}),e.jsx(H,{}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsxs(R,{type:"button",variant:"secondary",onClick:()=>r.push(s.products(i)),children:[e.jsx(N.ChevronLeft,{className:"w-4 h-4 mr-2"})," Cancel"]}),e.jsxs(R,{type:"submit",isLoading:p.isPending||g.isPending,loadingText:"Saving...",children:[e.jsx(N.CheckIcon,{className:"w-4 h-4 mr-2"})," ",a?"Save Product":"Create Product"]})]})]})})};function im(){return e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-gray-900 sm:text-xl dark:text-gray-50",children:"Create Product"}),e.jsx(H,{}),e.jsx("div",{className:"pt-6",children:e.jsx("div",{className:"space-y-10",children:e.jsx(kn,{})})})]})}function nm(){const a=_(),t=za(),{client:r}=P(),{data:s,isLoading:i}=A.useQuery({queryKey:["product",a,t],queryFn:async()=>{const{status:n,body:o}=await r.product.getProduct({params:{organizationId:a,id:t}});if(n!==200)throw J.error("Failed to load product"),new Error("Failed to fetch product");return o}});return e.jsxs("div",{className:"space-y-6",children:[e.jsx("h1",{className:"text-xl font-semibold text-gray-900 sm:text-2xl dark:text-gray-50",children:"Edit Product"}),e.jsx(H,{}),i?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(pe,{className:"w-8 h-8"})}):e.jsx("div",{className:"pt-6",children:e.jsx(kn,{initialData:s})})]})}const Ue=Ee.createColumnHelper(),Nn=a=>{if(a==null||a==="")return null;const t=typeof a=="string"?Number.parseInt(a,10):a;return Number.isFinite(t)?t:null},om=({row:a,table:t})=>{var m;const{client:r}=P(),s=a.original.id,i=a.getValue("publishedAt"),n=(m=t.options.meta)==null?void 0:m.organizationId,o=t.options.meta.refetch,l=A.useMutation({mutationFn:async()=>{if((await r.product.updateStatus({params:{id:s,organizationId:n,operation:i?"unpublish":"publish"}})).status!==200)throw new Error("Failed to update product status");await o()}}),c=()=>{l.mutate()};return l.isPending?e.jsx("div",{className:"min-w-28",children:e.jsxs("button",{className:"relative my-2 inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-md border px-2 py-1 text-center text-sm font-medium shadow-xs transition-all duration-100 ease-in-out disabled:pointer-events-none disabled:shadow-none outline outline-offset-2 outline-0 focus-visible:outline-2 outline-blue-500 dark:outline-blue-500 border-gray-300 dark:border-gray-800 text-gray-900 dark:text-gray-50 bg-white dark:bg-gray-950 hover:bg-gray-50 dark:hover:bg-gray-900/60 disabled:text-gray-400 dark:disabled:text-gray-600","tremor-id":"tremor-raw",disabled:!0,children:[e.jsx(pe,{className:"w-4 h-4"})," Saving..."]})}):e.jsx("div",{className:"min-w-28",children:e.jsxs("button",{onClick:c,className:"relative my-2 inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-md border px-2 py-1 text-center text-sm font-medium shadow-xs transition-all duration-100 ease-in-out disabled:pointer-events-none disabled:shadow-none outline outline-offset-2 outline-0 focus-visible:outline-2 outline-blue-500 dark:outline-blue-500 border-gray-300 dark:border-gray-800 text-gray-900 dark:text-gray-50 bg-white dark:bg-gray-950 hover:bg-gray-50 dark:hover:bg-gray-900/60 disabled:text-gray-400 dark:disabled:text-gray-600","tremor-id":"tremor-raw",children:[i?e.jsx(N.CheckCircle,{className:"w-4 h-4 text-emerald-600 dark:text-emerald-500"}):e.jsx(N.EyeOffIcon,{className:"w-4 h-4 text-red-600 dark:text-red-500"}),i?"Published":"Draft"]})})},lm=({row:a,table:t})=>{var f,b,w;const{client:r}=P(),s=a.original.id,i=Nn(a.original.availableQuantity),n=(f=t.options.meta)==null?void 0:f.organizationId,o=t.options.meta.refetch,[l,c]=h.useState(!1),[m,u]=h.useState(!1),[p,g]=h.useState(i==null?"":String(i));h.useEffect(()=>{m&&g(i==null?"":String(i))},[i,m]);const x=A.useMutation({mutationFn:async()=>{if((await r.product.deleteProduct({params:{id:s,organizationId:n}})).status!==204)throw new Error("Failed to delete product");await o()}}),y=A.useMutation({mutationFn:async()=>{const k=p.trim()===""?null:Number.parseInt(p,10);if(k!==null&&(!Number.isInteger(k)||k<0))throw new Error("Stock quantity must be a whole number greater than or equal to 0.");if((await r.product.updateProduct({params:{id:s,organizationId:n},body:{availableQuantity:k}})).status!==200)throw new Error("Failed to update product stock");await o(),u(!1)}}),j=()=>{window.confirm("Are you sure you want to delete this product? This action cannot be undone.")&&x.mutate()};return e.jsxs(e.Fragment,{children:[e.jsxs(ra,{open:l,onOpenChange:c,children:[e.jsx(sa,{asChild:!0,children:e.jsx(R,{variant:"ghost",className:"group aspect-square px-1.5 py-0! h-8! hover:border hover:border-gray-300 data-[state=open]:border-gray-300 data-[state=open]:bg-gray-50 dark:hover:border-gray-700 dark:data-[state=open]:border-gray-700 dark:data-[state=open]:bg-gray-900",disabled:x.isPending||y.isPending,children:x.isPending||y.isPending?e.jsx(pe,{className:"size-4 shrink-0"}):e.jsx(M.RiMoreFill,{className:"size-4 shrink-0 text-gray-500 group-hover:text-gray-700 group-data-[state=open]:text-gray-700 dark:group-hover:text-gray-300 dark:group-data-[state=open]:text-gray-300","aria-hidden":"true"})})}),e.jsxs(ia,{align:"end",className:"min-w-40",children:[e.jsx(Se,{children:e.jsxs(B,{href:((w=(b=t.options.meta)==null?void 0:b.routes)==null?void 0:w.productEdit(n,s))??`/admin/${n}/products/${s}`,className:"block flex items-center gap-2",children:[e.jsx(N.PencilIcon,{className:"w-4 h-4"}),"Edit"]})}),e.jsx(Se,{className:"cursor-pointer",onSelect:()=>{c(!1),u(!0)},children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N.PackageIcon,{className:"w-4 h-4"}),"Update Stock"]})}),e.jsx(Se,{className:"text-red-600 dark:text-red-500 cursor-pointer",onClick:j,disabled:x.isPending,children:e.jsxs("div",{className:"flex items-center gap-2",children:[x.isPending?e.jsx(pe,{className:"w-4 h-4"}):e.jsx(N.Trash2,{className:"w-4 h-4"}),x.isPending?"Deleting...":"Delete"]})})]})]}),e.jsx(Ia,{open:m,onOpenChange:u,children:e.jsxs(Ea,{children:[e.jsxs(Da,{children:[e.jsx(Ra,{children:"Update Stock"}),e.jsx(qt,{children:"Leave this blank to keep the product inventory unlimited."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(me,{htmlFor:`stock-${s}`,children:"Available quantity"}),e.jsx(le,{id:`stock-${s}`,type:"number",min:0,step:1,value:p,onChange:k=>g(k.target.value),placeholder:"Unlimited stock"})]}),e.jsxs(br,{className:"mt-6",children:[e.jsx(R,{type:"button",variant:"secondary",onClick:()=>u(!1),children:"Cancel"}),e.jsx(R,{type:"button",onClick:()=>y.mutate(),isLoading:y.isPending,loadingText:"Saving...",children:"Save Stock"})]})]})})]})},gs=({amount:a,fallbackCurrency:t})=>{var n;const{defaultLocale:r,organization:s}=ke(),i=((n=s.data)==null?void 0:n.configuration.defaultCurrency)??t??"USD";return a==null?"-":we(a,i,r)},dm=[Ue.display({id:"select",header:({table:a})=>e.jsx(Qe,{checked:a.getIsAllPageRowsSelected()?!0:a.getIsSomeRowsSelected()?"indeterminate":!1,onCheckedChange:()=>a.toggleAllPageRowsSelected(),className:"translate-y-0.5","aria-label":"Select all"}),cell:({row:a})=>e.jsx(Qe,{checked:a.getIsSelected(),onCheckedChange:()=>a.toggleSelected(),className:"translate-y-0.5","aria-label":"Select row"}),enableSorting:!1,enableHiding:!1,meta:{displayName:"Select"}}),Ue.accessor("title",{header:({column:a})=>e.jsx(q,{column:a,title:"Title"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"Title"},cell:({row:a,table:t})=>{var i,n,o;const r=(i=t.options.meta)==null?void 0:i.organizationId,s=a.original.id;return e.jsx(B,{href:((o=(n=t.options.meta)==null?void 0:n.routes)==null?void 0:o.productEdit(r,s))??`/admin/${r}/products/${s}`,className:"text-blue-500 hover:underline",children:a.getValue("title")||"-"})}}),Ue.accessor("sku",{header:({column:a})=>e.jsx(q,{column:a,title:"SKU"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"SKU"},cell:({row:a})=>a.getValue("sku")||"-"}),Ue.accessor("availableQuantity",{header:({column:a})=>e.jsx(q,{column:a,title:"Stock"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"Stock"},cell:({row:a})=>{const t=Nn(a.original.availableQuantity);return t===null?e.jsx(ue,{variant:"neutral",children:"Unlimited"}):t===0?e.jsx(ue,{variant:"warning",children:"Out of stock"}):e.jsx("span",{children:t})}}),Ue.accessor("basePrice",{header:({column:a})=>e.jsx(q,{column:a,title:"Base Price"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"Base Price"},cell:({row:a})=>{const t=a.getValue("basePrice");return e.jsx(gs,{amount:t,fallbackCurrency:a.original.currency})}}),Ue.accessor("discountedBasePrice",{header:({column:a})=>e.jsx(q,{column:a,title:"Discounted Price"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"Discounted Price"},cell:({row:a})=>{const t=a.getValue("discountedBasePrice");return e.jsx(gs,{amount:t,fallbackCurrency:a.original.currency})}}),Ue.accessor("publishedAt",{header:({column:a})=>e.jsx(q,{column:a,title:"Status"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"Slug"},cell:({row:a,table:t})=>e.jsx(om,{row:a,table:t})}),Ue.accessor("createdAt",{header:({column:a})=>e.jsx(q,{column:a,title:"Created At"}),enableSorting:!1,meta:{className:"text-left",displayName:"Created At"},cell:({row:a})=>{const t=a.getValue("createdAt");return new Date(t).toLocaleDateString()}}),Ue.display({id:"edit",header:"Edit",enableSorting:!1,enableHiding:!1,meta:{className:"text-right",displayName:"Edit"},cell:({row:a,table:t})=>e.jsx(lm,{row:a,table:t})})],cm=()=>{const{client:a}=P(),t=$(),{defaultLocale:r}=ke(),s=_(),i=D.usePathname(),n=D.useRouter(),o=D.useSearchParams(),[l,c]=h.useState(""),[m,u]=h.useState("all"),[p,g]=h.useState("all"),[x]=aa.useDebounce(l,300),y=Number((o==null?void 0:o.get("page"))||"1"),j=m==="all"?void 0:m,f=p==="all"?void 0:p,b=(S,T)=>{const W=new URLSearchParams(o==null?void 0:o.toString());return W.set(S,T),W.toString()},w=()=>{y!==1&&n.replace(`${i}?${b("page","1")}`)},{data:k=[]}=A.useQuery({queryKey:["productCategoriesFilter",s,r],queryFn:async()=>{const{body:S,status:T}=await a.productCategory.getProductCategories({params:{organizationId:s},query:{limit:100,locale:r}});if(T!==200)throw new Error("Failed to fetch product categories");return S.list.map(W=>({label:W.title||"Untitled category",value:W.id}))},placeholderData:[]}),{isLoading:C,isRefetching:F,isError:Q,data:O,refetch:E}=A.useQuery({queryKey:["products",s,y,x,j,f,r],queryFn:async()=>{const{body:S,status:T}=await a.product.getProducts({params:{organizationId:s},query:{page:y,limit:10,search:x,locale:r,categoryId:j,publishedStatus:f}});if(T!==200)throw new Error("Failed to fetch products");return S},placeholderData:A.keepPreviousData});return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 sm:gap-x-6",children:[e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:w-fit sm:flex-row sm:items-center",children:[e.jsx(Ma,{type:"search",placeholder:"Search products...",value:l,onChange:S=>{c(S.target.value),w()},className:"w-full sm:max-w-[250px] sm:[&>input]:h-[40px]"}),e.jsxs(ft,{value:m,onValueChange:S=>{u(S),w()},children:[e.jsx(bt,{className:"w-full sm:w-[220px]",children:e.jsx(yt,{placeholder:"All categories"})}),e.jsxs(jt,{children:[e.jsx($e,{value:"all",children:"All categories"}),k.map(S=>e.jsx($e,{value:S.value,children:S.label},S.value))]})]}),e.jsxs(ft,{value:p,onValueChange:S=>{g(S),w()},children:[e.jsx(bt,{className:"w-full sm:w-[190px]",children:e.jsx(yt,{placeholder:"All statuses"})}),e.jsxs(jt,{children:[e.jsx($e,{value:"all",children:"All statuses"}),e.jsx($e,{value:"published",children:"Published"}),e.jsx($e,{value:"unpublished",children:"Unpublished"})]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(R,{asChild:!0,className:"hidden gap-x-2 px-2 py-1.5 text-sm sm:text-xs lg:flex",children:e.jsxs(B,{href:t.productCreate(s),children:["Create Product",e.jsx(N.PlusIcon,{className:"size-4 shrink-0","aria-hidden":"true"})]})})})]}),e.jsx(Fa,{error:Q,loading:C||F,meta:O!=null&&O.meta?{...O==null?void 0:O.meta,currentPage:y}:void 0,data:(O==null?void 0:O.list)||[],columns:dm,className:"mt-8",refetch:E})]})};function mm(){return e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-xl font-semibold text-gray-900 sm:text-2xl dark:text-gray-50",children:"Products"}),e.jsx("div",{className:"mt-4 sm:mt-6 lg:mt-6",children:e.jsx(cm,{})})]})}const An=({organizationId:a,id:t,acceptedAt:r,cancelledAt:s,refetch:i,className:n,compact:o=!1})=>{var b;const{client:l}=P(),c=A.useMutation({mutationFn:async({operation:w})=>{if((await l.reservation.updateReservationStatus({params:{organizationId:a,reservationId:t,operation:w},body:{}})).status!==200)throw new Error("Failed to update reservation status");return i()}}),m=()=>{c.mutate({operation:"accept"})},u=()=>{c.mutate({operation:"cancel"})},p=c.isPending,g=(b=c.variables)==null?void 0:b.operation,x=p&&g==="cancel",y=p&&g==="accept",j=!r&&!s,f=!s;return e.jsxs("div",{className:U("flex items-center gap-2 min-w-28 min-h-[45px]",o?"min-h-0 min-w-0":"",n),children:[f&&e.jsxs("button",{onClick:u,disabled:p,className:U("relative inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-md border px-2 py-1 text-center text-sm font-medium shadow-xs transition-all duration-100 ease-in-out disabled:pointer-events-none disabled:shadow-none outline outline-offset-2 outline-0 focus-visible:outline-2 outline-blue-500 dark:outline-blue-500 border-gray-300 dark:border-gray-800 text-gray-900 dark:text-gray-50 bg-white dark:bg-gray-950 hover:bg-gray-50 dark:hover:bg-gray-900/60 disabled:text-gray-400 dark:disabled:text-gray-600",o?"my-0":"my-2"),children:[x?"Loading...":"Cancel",e.jsx(N.X,{className:"w-4 h-4 text-red-600 dark:text-red-500"})]}),j&&e.jsxs("button",{onClick:m,disabled:p,className:U("relative inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-md border px-2 py-1 text-center text-sm font-medium shadow-xs transition-all duration-100 ease-in-out disabled:pointer-events-none disabled:shadow-none outline outline-offset-2 outline-0 focus-visible:outline-2 outline-blue-500 dark:outline-blue-500 border-gray-300 dark:border-gray-800 text-gray-900 dark:text-gray-50 bg-white dark:bg-gray-950 hover:bg-gray-50 dark:hover:bg-gray-900/60 disabled:text-gray-400 dark:disabled:text-gray-600",o?"my-0":"my-2"),children:[y?"Loading...":"Accept",e.jsx(N.CheckCircle,{className:"w-4 h-4 text-emerald-600 dark:text-emerald-500"})]})]})},Kt=({icon:a,title:t})=>e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("span",{className:"text-gray-400 dark:text-gray-500",children:a}),e.jsx("h3",{className:"text-sm font-bold text-gray-500 dark:text-gray-400 tracking-wide font-red-hat-display",children:t})]}),at=({label:a,children:t})=>e.jsxs("div",{className:"flex justify-between items-center py-1.5",children:[e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:a}),e.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:t})]}),um=a=>a.cancelledAt?{variant:"error",label:"Cancelled"}:a.acceptedAt?{variant:"success",label:"Accepted"}:{variant:"warning",label:"Pending"},Cn=({open:a,onOpenChange:t,organizationId:r,reservation:s,refetch:i})=>{const n=um(s),o=[{label:"Created",date:s.createdAt},{label:"Accepted",date:s.acceptedAt},...s.cancelledAt?[{label:"Cancelled",date:s.cancelledAt}]:[]];return e.jsx(Ia,{open:a,onOpenChange:t,children:e.jsxs(Ea,{className:"sm:max-w-lg overflow-y-auto max-h-[90vh] !p-0",children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white dark:bg-[#090E1A] border-b border-gray-200 dark:border-gray-800 px-5 pt-5 pb-3",children:e.jsx(Da,{children:e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs(Ra,{className:"text-lg",children:["Reservation #",s.referenceId]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(ue,{variant:n.variant,children:n.label})})]}),e.jsx(yr,{className:"rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 p-1.5 -mt-1 -mr-1.5 transition-colors",children:e.jsx(N.X,{className:"h-4 w-4"})})]})})}),e.jsxs("div",{className:"px-5 pb-5 space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-5 pt-4",children:[e.jsxs("div",{children:[e.jsx(Kt,{icon:e.jsx(N.User,{className:"h-4 w-4"}),title:"Guest"}),e.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800 p-3 space-y-0.5",children:[e.jsxs(at,{label:"Name",children:[s.firstname," ",s.lastname]}),e.jsx(at,{label:"Phone",children:s.phone||"N/A"})]})]}),e.jsxs("div",{children:[e.jsx(Kt,{icon:e.jsx(N.Users,{className:"h-4 w-4"}),title:"Details"}),e.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800 p-3 space-y-0.5",children:[e.jsx(at,{label:"Guests",children:s.guests}),e.jsx(at,{label:"Date",children:s.date?I.format(new Date(s.date),"dd MMM yyyy, HH:mm"):"N/A"})]})]})]}),e.jsxs("div",{children:[e.jsx(Kt,{icon:e.jsx(N.Calendar,{className:"h-4 w-4"}),title:"Timeline"}),e.jsx("div",{className:"relative",children:o.map((l,c)=>{const m=!!l.date,u=l.label==="Cancelled",p=c===o.length-1;return e.jsxs("div",{className:"relative flex items-start gap-3 pb-4 last:pb-0",children:[!p&&e.jsx("div",{className:`absolute left-[5px] top-3 bottom-0 w-0.5 ${m?"bg-emerald-500":"bg-gray-200 dark:bg-gray-800"}`}),e.jsx("div",{className:`relative z-10 mt-0.5 h-3 w-3 rounded-full border-2 shrink-0 ${u&&m?"border-red-500 bg-red-500":m?"border-emerald-500 bg-emerald-500":"border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-950"}`}),e.jsxs("div",{className:"flex-1 -mt-0.5",children:[e.jsx("p",{className:`text-sm leading-tight ${m?"font-medium text-gray-900 dark:text-gray-100":"text-gray-400 dark:text-gray-600"}`,children:l.label}),m&&l.date&&e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:I.format(new Date(l.date),"dd MMM yyyy, HH:mm")})]})]},l.label)})})]})]}),r&&i?e.jsxs(br,{className:"border-t border-gray-200 px-5 py-4 dark:border-gray-800 sm:items-center sm:justify-between sm:space-x-0",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-gray-900 dark:text-gray-50",children:"Update reservation"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:"Confirm pending requests or cancel a reservation directly from this panel."})]}),e.jsx(An,{acceptedAt:s.acceptedAt,cancelledAt:s.cancelledAt,className:"justify-end",compact:!0,id:s.id,organizationId:r,refetch:i})]}):null]})})},pm=({organizationId:a,refetch:t,reservation:r})=>{const[s,i]=h.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>i(!0),className:"text-blue-500 hover:underline",children:String(r.id).slice(-5)}),e.jsx(Cn,{open:s,onOpenChange:i,organizationId:a,reservation:r,refetch:t})]})},gm=({reservation:a,table:t})=>{const r=t.options.meta,s=(r==null?void 0:r.organizationId)||"",i=typeof(r==null?void 0:r.refetch)=="function"?r.refetch:()=>{};return e.jsx(An,{organizationId:s,id:a.id,acceptedAt:a.acceptedAt,cancelledAt:a.cancelledAt,refetch:i})},Ze=Ee.createColumnHelper(),hm=[Ze.accessor("id",{header:({column:a})=>e.jsx(q,{column:a,title:"ID"}),meta:{className:"text-left",displayName:"ID"},cell:({row:a,table:t})=>{const r=t.options.meta,s=(r==null?void 0:r.organizationId)||"",i=typeof(r==null?void 0:r.refetch)=="function"?r.refetch:()=>{};return e.jsx(pm,{organizationId:s,refetch:i,reservation:a.original})},enableSorting:!0,enableHiding:!1}),Ze.accessor("referenceId",{header:({column:a})=>e.jsx(q,{column:a,title:"Reference ID"}),cell:({row:a})=>e.jsx("div",{className:"w-[100px]",children:a.getValue("referenceId")}),meta:{className:"text-left",displayName:"Reference ID"},enableSorting:!1,enableHiding:!1}),Ze.display({id:"customer",meta:{className:"text-left",displayName:"Customer"},header:({column:a})=>e.jsx(q,{column:a,title:"Customer"}),cell:({row:a})=>{const t=a.original.firstname||"",r=a.original.lastname||"";return e.jsx("div",{children:`${t} ${r}`.trim()||"N/A"})}}),Ze.accessor("guests",{meta:{className:"text-left",displayName:"Guests"},enableSorting:!0,enableHiding:!1,header:({column:a})=>e.jsx(q,{column:a,title:"Guests"}),cell:({row:a})=>e.jsx("div",{className:"font-medium",children:a.original.guests})}),Ze.accessor("phone",{meta:{className:"text-left",displayName:"Phone"},enableSorting:!1,enableHiding:!1,header:({column:a})=>e.jsx(q,{column:a,title:"Phone"}),cell:({row:a})=>e.jsx("div",{children:a.original.phone||"N/A"})}),Ze.accessor("date",{meta:{className:"text-left",displayName:"Reservation Date"},enableSorting:!0,enableHiding:!1,header:({column:a})=>e.jsx(q,{column:a,title:"Reservation Date"}),cell:({row:a})=>{const t=a.getValue("date");return t?I.format(new Date(t),"dd.MM.yyyy HH:mm"):"N/A"}}),Ze.accessor("createdAt",{meta:{className:"text-left",displayName:"Created At"},enableSorting:!0,enableHiding:!1,header:({column:a})=>e.jsx(q,{column:a,title:"Created At"}),cell:({row:a})=>{const t=a.getValue("createdAt");return t?I.format(new Date(t),"dd.MM.yyyy HH:mm"):"N/A"}}),Ze.display({id:"status",meta:{className:"text-left",displayName:"Status"},header:({column:a})=>e.jsx(q,{column:a,title:"Status"}),cell:({row:a})=>{const t=a.original.acceptedAt;return a.original.cancelledAt?e.jsx("div",{className:"text-red-600 font-medium",children:"Cancelled"}):t?e.jsx("div",{className:"text-green-600 font-medium",children:"Accepted"}):e.jsx("div",{className:"text-yellow-600 font-medium",children:"Pending"})}}),Ze.display({id:"actions",header:({column:a})=>e.jsx(q,{column:a,title:"Actions"}),cell:({row:a,table:t})=>e.jsx(gm,{reservation:a.original,table:t})})];function Sn({options:a,value:t,onValueChange:r,className:s}){return e.jsx("div",{className:U("inline-flex items-center rounded-lg bg-gray-100 p-0.5 dark:bg-gray-900 w-min",s),children:a.map(i=>{const n=i.value===t;return e.jsx("button",{type:"button",onClick:()=>r(i.value),className:U("rounded-md px-2.5 py-1 text-xs font-medium transition-all duration-150",n?"bg-white text-gray-900 shadow-sm dark:bg-gray-800 dark:text-gray-50":"text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200"),children:i.label},i.value)})})}const tt=1,xm=[{label:"Month",value:"month"},{label:"Week",value:"week"},{label:"Day",value:"day"}],Mr=a=>a.cancelledAt?"cancelled":a.acceptedAt?"accepted":"pending",Pr=a=>a==="accepted"?{badgeVariant:"success",dotClassName:"bg-emerald-500",label:"Accepted"}:a==="cancelled"?{badgeVariant:"error",dotClassName:"bg-red-500",label:"Cancelled"}:{badgeVariant:"warning",dotClassName:"bg-yellow-500",label:"Pending"},rt=a=>I.format(a,"yyyy-MM-dd"),wt=(a,t)=>t==="day"?{from:I.startOfDay(a),to:I.endOfDay(a)}:t==="week"?{from:I.startOfWeek(a,{weekStartsOn:tt}),to:I.endOfWeek(a,{weekStartsOn:tt})}:{from:I.startOfWeek(I.startOfMonth(a),{weekStartsOn:tt}),to:I.endOfWeek(I.endOfMonth(a),{weekStartsOn:tt})},hs=(a,t,r)=>t==="day"?I.addDays(a,r):t==="week"?I.addWeeks(a,r):I.addMonths(a,r),fm=(a,t)=>{if(t==="day")return I.format(a,"EEEE, d MMMM yyyy");if(t==="week"){const{from:r,to:s}=wt(a,t);return`${I.format(r,"d MMM")} - ${I.format(s,"d MMM yyyy")}`}return I.format(a,"MMMM yyyy")},ym=({onOpen:a,reservation:t})=>{const r=new Date(t.date),s=Mr(t),i=Pr(s);return e.jsxs("button",{type:"button",onClick:()=>a(t.id),className:"flex w-full items-center gap-1.5 rounded-md px-1.5 py-1 text-left text-[11px] leading-tight transition hover:bg-gray-100 dark:hover:bg-gray-800",children:[e.jsx("span",{className:U("size-1.5 shrink-0 rounded-full",i.dotClassName)}),e.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-100",children:I.format(r,"HH:mm")}),e.jsxs("span",{className:"truncate text-gray-500 dark:text-gray-400",children:[t.firstname," ",t.lastname]})]})},bm=({onOpen:a,reservation:t})=>{const r=new Date(t.date),s=Mr(t),i=Pr(s),n=t.guests===1?"guest":"guests";return e.jsxs("button",{type:"button",onClick:()=>a(t.id),className:"w-full rounded-lg border border-gray-200 bg-white p-3 text-left transition hover:border-gray-300 dark:border-gray-800 dark:bg-gray-950 dark:hover:border-gray-700",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:I.format(r,"HH:mm")}),e.jsxs("p",{className:"mt-0.5 text-sm font-medium text-gray-900 dark:text-gray-50",children:[t.firstname," ",t.lastname]})]}),e.jsx(ue,{variant:i.badgeVariant,children:i.label})]}),e.jsxs("p",{className:"mt-1.5 text-xs text-gray-500 dark:text-gray-400",children:[t.guests," ",n," · Ref ",t.referenceId]})]})};function jm({currentDate:a,error:t,loading:r,onCurrentDateChange:s,onRetry:i,onViewChange:n,organizationId:o,reservations:l,refetch:c,view:m}){const[u,p]=h.useState(null),g=new Date,x=[...l].sort((k,C)=>new Date(k.date).getTime()-new Date(C.date).getTime()),y=new Map;for(const k of x){const C=rt(new Date(k.date)),F=y.get(C)??[];F.push(k),y.set(C,F)}const j=x.find(k=>k.id===u)??null,f=()=>{var O;const{from:k,to:C}=wt(a,"month"),F=I.eachDayOfInterval({start:k,end:C}),Q=[];for(let E=0;E<F.length;E+=7)Q.push(F.slice(E,E+7));return e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("div",{className:"min-w-[700px]",children:[e.jsx("div",{className:"grid grid-cols-7 border-b border-gray-200 dark:border-gray-800",children:(O=Q[0])==null?void 0:O.map(E=>e.jsx("div",{className:"px-2 py-2 text-center text-xs font-medium text-gray-500 dark:text-gray-400",children:I.format(E,"EEE")},E.toISOString()))}),e.jsx("div",{className:"grid grid-cols-7",children:Q.flatMap(E=>E.map(S=>{const T=y.get(rt(S))??[],W=Math.max(T.length-3,0);return e.jsxs("div",{className:U("min-h-[130px] border-b border-r border-gray-200 p-1.5 dark:border-gray-800",!I.isSameMonth(S,a)&&"bg-gray-50/50 dark:bg-gray-900/30"),children:[e.jsx("button",{type:"button",onClick:()=>{s(S),n("day")},className:U("mb-1 inline-flex size-7 items-center justify-center rounded-full text-xs font-medium transition-colors",I.isToday(S)?"bg-blue-600 text-white dark:bg-blue-500":I.isSameMonth(S,a)?"text-gray-900 hover:bg-gray-100 dark:text-gray-100 dark:hover:bg-gray-800":"text-gray-400 hover:bg-gray-100 dark:text-gray-500 dark:hover:bg-gray-800"),children:I.format(S,"d")}),e.jsxs("div",{className:"space-y-0.5",children:[T.slice(0,3).map(fe=>e.jsx(ym,{onOpen:p,reservation:fe},fe.id)),W>0?e.jsxs("button",{type:"button",onClick:()=>{s(S),n("day")},className:"w-full px-1.5 py-0.5 text-left text-[11px] font-medium text-gray-400 hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300",children:["+",W," more"]}):null]})]},S.toISOString())}))})]})})},b=()=>{const{from:k,to:C}=wt(a,"week"),F=I.eachDayOfInterval({start:k,end:C});return e.jsx("div",{className:"overflow-x-auto",children:e.jsx("div",{className:"grid min-w-[900px] auto-rows-fr grid-cols-7 gap-px overflow-hidden rounded-lg border border-gray-200 bg-gray-200 dark:border-gray-800 dark:bg-gray-800 min-h-[800px]",children:F.map(Q=>{const O=y.get(rt(Q))??[];return e.jsxs("div",{className:U("flex min-h-[400px] flex-col bg-white p-3 dark:bg-gray-950",I.isToday(Q)&&"bg-blue-50/30 dark:bg-blue-950/10"),children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:I.format(Q,"EEE")}),e.jsx("p",{className:U("text-lg font-semibold",I.isToday(Q)?"text-blue-600 dark:text-blue-400":"text-gray-900 dark:text-gray-50"),children:I.format(Q,"d")})]}),e.jsx("div",{className:"flex-1 space-y-2",children:O.length===0?e.jsx("p",{className:"py-4 text-center text-xs text-gray-400 dark:text-gray-500",children:"No reservations"}):O.map(E=>{const S=new Date(E.date),T=Mr(E),W=Pr(T),fe=E.guests===1?"guest":"guests";return e.jsxs("button",{type:"button",onClick:()=>p(E.id),className:"w-full rounded-md bg-gray-50 p-2 text-left transition hover:bg-gray-100 dark:bg-gray-900 dark:hover:bg-gray-800",children:[e.jsxs("div",{className:"flex items-start justify-between gap-1",children:[e.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:I.format(S,"HH:mm")}),e.jsx("span",{className:U("size-2 shrink-0 rounded-full mt-1",W.dotClassName)})]}),e.jsxs("p",{className:"mt-0.5 text-sm font-medium text-gray-900 dark:text-gray-50",children:[E.firstname," ",E.lastname]}),e.jsxs("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:[E.guests," ",fe]})]},E.id)})})]},Q.toISOString())})})})},w=()=>{const k=y.get(rt(a))??x;return e.jsx("div",{className:"space-y-2",children:k.length===0?e.jsxs("div",{className:"rounded-lg border border-dashed border-gray-200 px-4 py-10 text-center dark:border-gray-800",children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-50",children:"No reservations scheduled"}),e.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:"Try another day or switch to the weekly or monthly view."})]}):k.map(C=>{const F=new Date(C.date);return e.jsxs("div",{className:"flex gap-3 rounded-lg border border-gray-200 bg-white p-3 dark:border-gray-800 dark:bg-gray-950",children:[e.jsx("div",{className:"flex w-16 shrink-0 flex-col items-center justify-center rounded-md bg-gray-50 py-2 dark:bg-gray-900",children:e.jsx("p",{className:"text-lg font-semibold text-gray-900 dark:text-gray-50",children:I.format(F,"HH:mm")})}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(bm,{onOpen:p,reservation:C})})]},C.id)})})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-6 border-t pt-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{type:"button",className:"inline-flex size-7 items-center justify-center rounded-md text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-50",onClick:()=>s(hs(a,m,-1)),children:e.jsx(N.ChevronLeft,{className:"size-4","aria-hidden":"true"})}),e.jsx("button",{type:"button",className:"inline-flex size-7 items-center justify-center rounded-md text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-50",onClick:()=>s(hs(a,m,1)),children:e.jsx(N.ChevronRight,{className:"size-4","aria-hidden":"true"})})]}),e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-50",children:fm(a,m)}),e.jsxs("div",{className:"flex items-center gap-2 sm:ml-auto",children:[e.jsx("button",{type:"button",className:"inline-flex h-7 items-center justify-center rounded-md border border-gray-200 px-2.5 text-xs font-medium text-gray-700 transition-colors hover:bg-gray-50 dark:border-gray-800 dark:text-gray-300 dark:hover:bg-gray-800",onClick:()=>s(g),children:"Today"}),e.jsx(Sn,{options:xm,value:m,onValueChange:n})]})]}),e.jsx("div",{className:"mt-4",children:t&&!r?e.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50/60 p-4 dark:border-red-950 dark:bg-red-950/20",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-gray-50",children:"Failed to load reservations"}),e.jsx("p",{className:"mt-0.5 text-sm text-gray-500 dark:text-gray-400",children:"Could not load reservations for this range."})]}),e.jsxs("button",{type:"button",onClick:()=>i(),className:"inline-flex items-center gap-2 rounded-lg border border-gray-200 bg-white px-3 py-2 text-sm font-medium text-gray-900 shadow-xs transition hover:bg-gray-50 dark:border-gray-800 dark:bg-gray-950 dark:text-gray-50 dark:hover:bg-gray-900",children:[e.jsx(M.RiRefreshLine,{className:"size-4","aria-hidden":"true"}),"Retry"]})]})}):r&&l.length===0?e.jsx("div",{className:"flex min-h-[300px] items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(pe,{className:"size-8"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Loading reservations..."})]})}):x.length===0?e.jsxs("div",{className:"rounded-lg border border-dashed border-gray-200 px-4 py-10 text-center dark:border-gray-800",children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-50",children:"No reservations found"}),e.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:"No bookings in this range. Try another date."})]}):m==="month"?f():m==="week"?b():w()})]}),j?e.jsx(Cn,{open:!0,onOpenChange:k=>{k||p(null)},organizationId:o,reservation:j,refetch:c}):null]})}const wm=100,vm=[{label:"Calendar",value:"calendar"},{label:"List",value:"list"}],km=()=>{var C,F;const{client:a}=P(),t=_(),r=D.usePathname(),s=D.useRouter(),i=D.useSearchParams(),[n,o]=h.useState(""),[l,c]=h.useState("calendar"),[m,u]=h.useState("week"),[p,g]=h.useState(()=>new Date),[x]=aa.useDebounce(n,300),y=Number((i==null?void 0:i.get("page"))||"1"),j=wt(p,m),f=(Q,O)=>{const E=new URLSearchParams(i==null?void 0:i.toString());return E.set(Q,O),E.toString()},b=()=>{y!==1&&s.replace(`${r}?${f("page","1")}`)},w=A.useQuery({queryKey:["reservations",t,y,x],queryFn:async()=>{const{body:Q,status:O}=await a.reservation.getReservations({params:{organizationId:t},query:{page:y,limit:10,search:x}});if(O!==200)throw new Error("Failed to fetch reservations");return Q},enabled:l==="list",placeholderData:A.keepPreviousData}),k=A.useQuery({queryKey:["reservations-calendar",t,x,m,j.from.toISOString(),j.to.toISOString()],queryFn:async()=>{const Q=async S=>{const{body:T,status:W}=await a.reservation.getReservations({params:{organizationId:t},query:{page:S,limit:wm,search:x,from:j.from.toISOString(),to:j.to.toISOString()}});if(W!==200)throw new Error("Failed to fetch reservations");return T},O=await Q(1);if(O.meta.pageCount<=1)return O.list;const E=await Promise.all(Array.from({length:O.meta.pageCount-1},(S,T)=>Q(T+2)));return[O,...E].flatMap(S=>S.list)},enabled:l==="calendar",placeholderData:A.keepPreviousData});return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-end lg:justify-between",children:[e.jsx("div",{className:"flex w-full flex-col gap-3 sm:flex-row sm:items-center",children:e.jsx(Ma,{type:"search",placeholder:"Search by name or reference...",value:n,onChange:Q=>{o(Q.target.value),b()},className:"w-full sm:max-w-[320px] sm:[&>input]:h-[40px]"})}),e.jsx(Sn,{options:vm,value:l,onValueChange:c})]}),l==="calendar"?e.jsx(jm,{currentDate:p,error:k.isError,loading:k.isLoading||k.isRefetching,onCurrentDateChange:g,onRetry:k.refetch,onViewChange:u,organizationId:t,reservations:k.data||[],refetch:k.refetch,view:m}):e.jsx(Fa,{error:w.isError,loading:w.isLoading||w.isRefetching,meta:(C=w.data)!=null&&C.meta?{...w.data.meta,currentPage:y}:void 0,data:((F=w.data)==null?void 0:F.list)||[],columns:hm,className:"mt-8",refetch:w.refetch})]})};function Nm(){return e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-xl font-semibold text-gray-900 sm:text-2xl dark:text-gray-50",children:"Reservations List"}),e.jsx("div",{className:"mt-4 sm:mt-6 lg:mt-6",children:e.jsx(km,{})})]})}const Am=[{label:"Owner",value:"owner"},{label:"Admin",value:"admin"},{label:"Member",value:"member"}],zn=({initialData:a})=>{const{client:t}=P(),r=D.useRouter(),s=$(),i=_(),n=!!a,o=n?Jo:Lo,l=Z.useForm({resolver:be.zodResolver(o),defaultValues:n?{role:a.role}:{email:"",role:"member"}}),c=A.useMutation({mutationFn:async g=>{const{status:x}=await t.access.createInvitation({params:{organizationId:i},body:g});if(x!==201)throw new Error("Failed to create invitation")}}),m=A.useMutation({mutationFn:async g=>{const{status:x}=await t.access.updateMemberRole({params:{organizationId:i,memberId:a.id},body:g});if(x!==200)throw new Error("Failed to update member role")}}),u=async()=>{J.success(n?"Member role updated successfully":"Invitation sent successfully"),r.push(s.settingsAccess(i)),await oe.invalidateQueries({queryKey:["access-members"]}),await oe.invalidateQueries({queryKey:["access-invitations"]})},p=g=>{n?m.mutate({role:g.role},{onSuccess:u}):c.mutate(g,{onSuccess:u})};return e.jsx(Z.FormProvider,{...l,children:e.jsxs("form",{onSubmit:l.handleSubmit(g=>p(g)),className:"space-y-14",children:[e.jsx("section",{"aria-labelledby":"access-information",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"access-information",className:"text-lg scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:n?"Edit Member Role":"Invite User"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:n?`Update the role for ${a.user.firstname} ${a.user.lastname}`:"Send an invitation to a new team member"})]}),e.jsxs("div",{className:"md:col-span-2",children:[n&&e.jsxs("div",{className:"mb-5",children:[e.jsx(me,{htmlFor:"member-email",className:"font-medium",children:"Email"}),e.jsx(le,{id:"member-email",value:a.user.email,disabled:!0,readOnly:!0,className:"w-full mt-2"})]}),e.jsx(Be,{form:l,config:[...n?[]:[{name:"email",label:"Email",type:"email",placeholder:"user@example.com",colspan:2}],{name:"role",label:"Role",type:"select",options:Am,colspan:2}]})]})]})}),e.jsx(H,{}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsxs(R,{type:"button",variant:"secondary",onClick:()=>r.push(s.settingsAccess(i)),children:[e.jsx(N.ChevronLeft,{className:"w-4 h-4 mr-2"})," Cancel"]}),e.jsxs(R,{type:"submit",isLoading:c.isPending||m.isPending,loadingText:"Saving...",children:[e.jsx(N.CheckIcon,{className:"w-4 h-4 mr-2"})," ",n?"Save Role":"Send Invitation"]})]})]})})};function Cm(){return e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-gray-900 sm:text-xl dark:text-gray-50",children:"Invite User"}),e.jsx(H,{}),e.jsx("div",{className:"pt-6",children:e.jsx("div",{className:"space-y-10",children:e.jsx(zn,{})})})]})}const Sm=()=>{var u;const{client:a}=P(),t=_(),r=$(),s=D.useSearchParams(),[i]=h.useState(""),[n]=aa.useDebounce(i,300),o=Number((s==null?void 0:s.get("page"))||"1"),l=A.useMutation({mutationFn:async p=>{const{status:g}=await a.access.deleteMember({params:{organizationId:t,memberId:p}});if(g!==204)throw new Error("Failed to remove member")},onSuccess:async()=>{J.success("Member removed successfully"),await oe.invalidateQueries({queryKey:["access-members"]})},onError:p=>{J.error((p==null?void 0:p.message)||"Failed to remove member")}}),{isLoading:c,data:m}=A.useQuery({queryKey:["access-members",t,o,n],queryFn:async()=>{const{body:p,status:g}=await a.access.getMembers({params:{organizationId:t},query:{page:o,limit:10,search:n}});if(g!==200)throw new Error("Failed to fetch members");return p},placeholderData:A.keepPreviousData});return c?e.jsx("div",{className:"flex items-center justify-center h-24 mt-4",children:e.jsx(pe,{className:"w-6 h-6"})}):(u=m==null?void 0:m.list)!=null&&u.length?e.jsx("ul",{className:"mt-4 divide-y divide-gray-200 dark:divide-gray-800",children:m.list.map(p=>{const g=p.user.firstname.charAt(0).toUpperCase()+p.user.lastname.charAt(0).toUpperCase();return e.jsxs("li",{className:"flex items-center justify-between gap-x-6 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-x-4 truncate",children:[e.jsx("span",{className:"hidden size-9 shrink-0 items-center justify-center rounded-full border border-gray-300 bg-white text-xs text-gray-700 sm:flex dark:border-gray-800 dark:bg-gray-950 dark:text-gray-300","aria-hidden":"true",children:g}),e.jsxs("div",{className:"truncate",children:[e.jsxs("p",{className:"truncate text-sm font-medium text-gray-900 dark:text-gray-50",children:[p.user.firstname," ",p.user.lastname]}),e.jsx("p",{className:"truncate text-xs text-gray-500",children:p.user.email})]})]}),e.jsxs("div",{className:"flex items-center gap-x-4",children:[e.jsx("span",{className:"inline-flex items-center rounded-md bg-gray-100 px-2 py-0.5 text-xs font-medium text-gray-600 dark:bg-gray-800 dark:text-gray-400",children:p.role.charAt(0).toUpperCase()+p.role.slice(1)}),e.jsx(B,{href:r.settingsAccessMemberEdit(t,p.id),className:"text-sm font-medium text-indigo-600 hover:text-indigo-500 dark:text-indigo-400 dark:hover:text-indigo-300",children:"Edit"}),e.jsx("button",{onClick:()=>l.mutate(p.id),disabled:l.isPending,className:"text-sm font-medium text-red-600 hover:text-red-500 dark:text-red-400 dark:hover:text-red-300 disabled:opacity-50",children:"Delete"})]})]},p.id)})}):e.jsx("p",{className:"text-sm text-gray-500 py-4 mt-4",children:"No members found."})},zm=()=>{const{client:a}=P(),t=_(),{isLoading:r,data:s}=A.useQuery({queryKey:["access-invitations",t],queryFn:async()=>{const{body:n,status:o}=await a.access.getInvitations({params:{organizationId:t}});if(o!==200)throw new Error("Failed to fetch invitations");return n}}),i=A.useMutation({mutationFn:async n=>{const{status:o}=await a.access.deleteInvitation({params:{organizationId:t,invitationId:n}});if(o!==204)throw new Error("Failed to revoke invitation")},onSuccess:async()=>{J.success("Invitation revoked"),await oe.invalidateQueries({queryKey:["access-invitations",t]})},onError:n=>{J.error((n==null?void 0:n.message)||"Failed to revoke invitation")}});return r?e.jsx("div",{className:"flex items-center justify-center h-24",children:e.jsx(pe,{className:"w-6 h-6"})}):!s||s.length===0?e.jsx("p",{className:"text-sm text-gray-500 py-4",children:"No pending invitations."}):e.jsx("div",{className:"relative overflow-hidden overflow-x-auto",children:e.jsxs(Dr,{children:[e.jsx(Rr,{children:e.jsxs(ma,{className:"border-y border-gray-200 dark:border-gray-800",children:[e.jsx(ca,{className:"whitespace-nowrap py-1 text-sm sm:text-xs",children:"Email"}),e.jsx(ca,{className:"whitespace-nowrap py-1 text-sm sm:text-xs",children:"Role"}),e.jsx(ca,{className:"whitespace-nowrap py-1 text-sm sm:text-xs",children:"Status"}),e.jsx(ca,{className:"whitespace-nowrap py-1 text-sm sm:text-xs",children:"Expires"}),e.jsx(ca,{className:"whitespace-nowrap py-1 text-sm sm:text-xs text-right",children:"Actions"})]})}),e.jsx(Fr,{children:s.map(n=>e.jsxs(ma,{className:"group select-none hover:bg-gray-50 dark:hover:bg-gray-900",children:[e.jsx(_e,{className:"whitespace-nowrap py-1 text-gray-600 dark:text-gray-400",children:n.email}),e.jsx(_e,{className:"whitespace-nowrap py-1 text-gray-600 dark:text-gray-400",children:e.jsx("span",{className:"inline-flex items-center rounded-md bg-gray-100 px-2 py-0.5 text-xs font-medium text-gray-600 dark:bg-gray-800 dark:text-gray-400",children:n.role?n.role.charAt(0).toUpperCase()+n.role.slice(1):"-"})}),e.jsx(_e,{className:"whitespace-nowrap py-1 text-gray-600 dark:text-gray-400",children:e.jsx("span",{className:"inline-flex items-center rounded-md bg-yellow-50 px-2 py-0.5 text-xs font-medium text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400",children:n.status.charAt(0).toUpperCase()+n.status.slice(1)})}),e.jsx(_e,{className:"whitespace-nowrap py-1 text-gray-600 dark:text-gray-400",children:new Date(n.expiresAt).toLocaleDateString()}),e.jsx(_e,{className:"whitespace-nowrap py-1 text-right",children:e.jsx("button",{onClick:()=>i.mutate(n.id),disabled:i.isPending,className:"inline-flex items-center rounded-md p-1 text-gray-400 hover:text-red-600 hover:bg-red-50 dark:hover:text-red-400 dark:hover:bg-red-900/20 transition disabled:opacity-50",children:e.jsx(N.Trash2,{className:"w-4 h-4"})})})]},n.id))})]})})};function Im(){const a=_(),t=$();return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"sm:flex sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Members"}),e.jsx("p",{className:"text-sm leading-6 text-gray-500",children:"Manage team members and their roles within your organization."})]}),e.jsx(R,{asChild:!0,className:"hidden gap-x-2 px-2 py-1.5 text-sm sm:text-xs lg:flex",children:e.jsxs(B,{href:t.settingsAccessInvite(a),children:["Invite User",e.jsx(N.PlusIcon,{className:"size-4 shrink-0","aria-hidden":"true"})]})})]}),e.jsx(Sm,{}),e.jsxs("div",{className:"mt-12",children:[e.jsx("h3",{className:"scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Pending Invitations"}),e.jsx("p",{className:"text-sm leading-6 text-gray-500",children:"Invitations that have been sent but not yet accepted."}),e.jsx("div",{className:"mt-4",children:e.jsx(zm,{})})]})]})}function Em(){const a=_(),t=za(),{client:r}=P(),{isLoading:s,data:i}=A.useQuery({queryKey:["access-members",a,t],queryFn:async()=>{const{status:n,body:o}=await r.access.getMember({params:{organizationId:a,memberId:t}});if(n!==200)throw J.error("Failed to fetch member. Please refresh or try again later."),new Error("Failed to fetch member");return o},throwOnError:!0,placeholderData:A.keepPreviousData});return e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-gray-900 sm:text-xl dark:text-gray-50",children:"Edit Member"}),e.jsx(H,{}),e.jsx("div",{className:"pt-6",children:e.jsx("div",{className:"space-y-10",children:s||!i?e.jsx("div",{className:"flex justify-center items-center h-screen mt-5",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(pe,{className:"w-12 h-12"}),e.jsx("p",{className:"text-gray-500 text-sm mt-3",children:"Loading data..."})]})}):e.jsx(zn,{initialData:i})})})]})}const In=[{type:"stripe",name:"Stripe",description:"Payments and webhook delivery",configurable:!0},{type:"resend",name:"Resend",description:"Transactional email delivery for orders and reservations",configurable:!0},{type:"wolt",name:"Wolt",description:"Marketplace and delivery sync",configurable:!1},{type:"payu",name:"PayU",description:"Alternative payments provider",configurable:!1}];function Br(a){return In.find(t=>t.type===a)}function Oa(a){var t;return((t=Br(a))==null?void 0:t.name)??a.split(/[-_]/).filter(Boolean).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}const Dm=a=>{if(!a)return{label:"Available",variant:"warning"};if(a.type==="stripe"){const t=zt.safeParse(a.config);if(t.success)return t.data.hasSecretKey&&t.data.hasWebhookSecret?{label:"Configured",variant:"success"}:{label:"Needs setup",variant:"warning"}}if(a.type==="resend"){const t=It.safeParse(a.config);if(t.success)return t.data.hasApiKey&&t.data.fromEmail?{label:"Configured",variant:"success"}:{label:"Needs setup",variant:"warning"}}return{label:"Configured",variant:"success"}};function Rm(){const a=_(),t=$(),{client:r}=P(),s=A.useQuery({queryKey:["organization-integrations",a],queryFn:async()=>{const{body:i,status:n}=await r.integration.getIntegrations({params:{organizationId:a}});if(n!==200)throw new Error("Failed to load integrations");return i}});return e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-gray-900 sm:text-xl dark:text-gray-50",children:"Add Integration"}),e.jsx(H,{}),e.jsx("div",{className:"pt-6",children:s.isLoading?e.jsx("div",{className:"flex h-32 items-center justify-center",children:e.jsx(pe,{className:"h-6 w-6"})}):s.isError?e.jsx("p",{className:"text-sm text-red-500",children:"Failed to load integration catalog."}):e.jsx("div",{className:"grid gap-5 md:grid-cols-2 xl:grid-cols-3",children:In.map(i=>{var l;const n=((l=s.data)==null?void 0:l.find(c=>c.type===i.type))??null,o=Dm(n);return e.jsxs(pa,{className:"flex flex-col justify-between",children:[e.jsx("div",{children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-50",children:i.name}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:i.description})]}),e.jsx(ue,{variant:i.configurable?o.variant:"neutral",children:i.configurable?o.label:"Coming soon"})]})}),e.jsx("div",{className:"mt-6",children:i.configurable?e.jsx(R,{asChild:!0,className:"w-full justify-center gap-2",children:e.jsxs(B,{href:t.settingsIntegration(a,i.type),children:[n?"Edit Integration":"Select",e.jsx(N.ArrowRightIcon,{className:"h-4 w-4"})]})}):e.jsx(R,{type:"button",variant:"secondary",className:"w-full justify-center",disabled:!0,children:"Not available yet"})})]},i.type)})})})]})}const Fm=Ge.z.object({apiKey:Ge.z.string(),fromEmail:Ge.z.string().trim().email("Enter a valid sender email.")}),Mm=a=>{const t=It.safeParse(a==null?void 0:a.config);return t.success?t.data:void 0};function Pm(){var g;const{client:a}=P(),t=_(),r=D.useRouter(),s=$(),i=Z.useForm({resolver:be.zodResolver(Fm),defaultValues:{apiKey:"",fromEmail:""}}),n=((g=A.useQuery({queryKey:["organization-integrations",t],queryFn:async()=>{const{body:x,status:y}=await a.integration.getIntegrations({params:{organizationId:t}});if(y!==200)throw new Error("Failed to load integrations.");return x}}).data)==null?void 0:g.find(x=>x.type==="resend"))??null,o=Mm(n),l=n?s.settingsIntegrations(t):s.settingsIntegrationsCreate(t),c=(n==null?void 0:n.updatedAt)??"new";h.useEffect(()=>{i.reset({apiKey:"",fromEmail:(o==null?void 0:o.fromEmail)??""})},[i,c]);const m=A.useMutation({mutationFn:async({apiKey:x,fromEmail:y})=>{var k;const j=x.trim(),f=y.trim(),b=sl.safeParse({apiKey:j||void 0,fromEmail:f||void 0});if(!b.success)throw new Error(((k=b.error.issues[0])==null?void 0:k.message)??"Invalid Resend configuration.");const{status:w}=await a.integration.upsertIntegration({params:{organizationId:t,type:"resend"},body:{config:b.data}});if(w!==200)throw new Error("Failed to update Resend integration.");await oe.invalidateQueries({queryKey:["organization-integrations",t]})},onSuccess:()=>{J.success("Resend integration updated."),r.push(s.settingsIntegrations(t))},onError:x=>{J.error(x.message||"Failed to update Resend integration.")}}),u=A.useMutation({mutationFn:async()=>{const{status:x}=await a.integration.deleteIntegration({params:{organizationId:t,type:"resend"}});if(x!==204)throw new Error("Failed to remove Resend integration.");await oe.invalidateQueries({queryKey:["organization-integrations",t]})},onSuccess:()=>{J.success("Resend integration removed."),r.push(s.settingsIntegrations(t))},onError:x=>{J.error(x.message||"Failed to remove Resend integration.")}}),p=x=>{if(i.clearErrors("apiKey"),!(o!=null&&o.hasApiKey)&&!x.apiKey.trim()){i.setError("apiKey",{type:"manual",message:"Resend API key is required."});return}m.mutate(x)};return e.jsxs("form",{onSubmit:i.handleSubmit(p),className:"space-y-14",children:[e.jsx("section",{"aria-labelledby":"resend-sender",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"resend-sender",className:"scroll-mt-10 text-lg font-semibold text-gray-900 dark:text-gray-50",children:"Sender Identity"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Use a verified sender address from your Resend account for order and reservation emails."})]}),e.jsx("div",{className:"space-y-5 md:col-span-2",children:e.jsxs("div",{children:[e.jsx(me,{htmlFor:"resend-from-email",children:"Sender Email"}),e.jsx(le,{id:"resend-from-email",type:"email",className:"mt-2",placeholder:"orders@example.com",hasError:!!i.formState.errors.fromEmail,...i.register("fromEmail")}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-gray-500",children:"This address must be verified in Resend. The organization name is used automatically as the display name."}),i.formState.errors.fromEmail&&e.jsx("p",{className:"mt-2 text-sm text-red-500",children:i.formState.errors.fromEmail.message})]})})]})}),e.jsx(H,{}),e.jsx("section",{"aria-labelledby":"resend-api-access",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"resend-api-access",className:"scroll-mt-10 text-lg font-semibold text-gray-900 dark:text-gray-50",children:"API Access"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Save the Resend API key used to deliver transactional emails for this organization."})]}),e.jsx("div",{className:"space-y-5 md:col-span-2",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(me,{htmlFor:"resend-api-key",children:"API Key"}),o!=null&&o.hasApiKey?e.jsx(ue,{variant:"success",children:"Configured"}):e.jsx(ue,{variant:"warning",children:"Required"})]}),e.jsx(le,{id:"resend-api-key",type:"password",className:"mt-2",placeholder:o!=null&&o.hasApiKey?"Leave blank to keep the saved API key":"re_...",hasError:!!i.formState.errors.apiKey,...i.register("apiKey")}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-gray-500",children:"Saved API keys are never returned to the browser. Leave this blank to keep the currently stored key."}),i.formState.errors.apiKey&&e.jsx("p",{className:"mt-2 text-sm text-red-500",children:i.formState.errors.apiKey.message})]})})]})}),e.jsx(H,{}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsxs(R,{type:"button",variant:"secondary",onClick:()=>r.push(l),children:[e.jsx(N.ChevronLeft,{className:"mr-2 h-4 w-4"})," Cancel"]}),n&&e.jsxs(R,{type:"button",variant:"secondary",className:"text-red-600 dark:text-red-400",onClick:()=>u.mutate(),isLoading:u.isPending,loadingText:"Removing...",children:[e.jsx(N.Trash2Icon,{className:"mr-2 h-4 w-4"})," Remove"]}),e.jsxs(R,{type:"submit",isLoading:m.isPending,loadingText:"Saving...",children:[e.jsx(N.CheckIcon,{className:"mr-2 h-4 w-4"})," Save Integration"]})]})]})}const Bm=Ge.z.object({paymentMethods:Ge.z.array(Ge.z.enum(["card","blik"])),secretKey:Ge.z.string(),webhookSecret:Ge.z.string()}),Tm=[{value:"card",label:"Card",description:"Visa, Mastercard, American Express and other card payments."},{value:"blik",label:"BLIK",description:"Popular one-time code payments in Poland."}],Qm=a=>{const t=zt.safeParse(a==null?void 0:a.config);return t.success?t.data:void 0};function Om(){var f;const{client:a,baseUrl:t}=P(),r=_(),s=D.useRouter(),i=$(),n=`${t.replace(/\/$/,"")}/api/webhook/payment/stripe/${r}`,o=Z.useForm({resolver:be.zodResolver(Bm),defaultValues:{paymentMethods:["card"],secretKey:"",webhookSecret:""}}),l=((f=A.useQuery({queryKey:["organization-integrations",r],queryFn:async()=>{const{body:b,status:w}=await a.integration.getIntegrations({params:{organizationId:r}});if(w!==200)throw new Error("Failed to load integrations.");return b}}).data)==null?void 0:f.find(b=>b.type==="stripe"))??null,c=Qm(l),m=l?i.settingsIntegrations(r):i.settingsIntegrationsCreate(r),u=(l==null?void 0:l.updatedAt)??"new";h.useEffect(()=>{o.reset({paymentMethods:(c==null?void 0:c.paymentMethods)??["card"],secretKey:"",webhookSecret:""})},[o,u]);const p=A.useMutation({mutationFn:async({paymentMethods:b,secretKey:w,webhookSecret:k})=>{var E;const C=w.trim(),F=k.trim(),Q=rl.safeParse({paymentMethods:b,secretKey:C||void 0,webhookSecret:F||void 0});if(!Q.success)throw new Error(((E=Q.error.issues[0])==null?void 0:E.message)??"Invalid Stripe configuration.");const{status:O}=await a.integration.upsertIntegration({params:{organizationId:r,type:"stripe"},body:{config:Q.data}});if(O!==200)throw new Error("Failed to update Stripe integration.");await oe.invalidateQueries({queryKey:["organization-integrations",r]})},onSuccess:()=>{J.success("Stripe integration updated."),s.push(i.settingsIntegrations(r))},onError:b=>{J.error(b.message||"Failed to update Stripe integration.")}}),g=A.useMutation({mutationFn:async()=>{const{status:b}=await a.integration.deleteIntegration({params:{organizationId:r,type:"stripe"}});if(b!==204)throw new Error("Failed to remove Stripe integration.");await oe.invalidateQueries({queryKey:["organization-integrations",r]})},onSuccess:()=>{J.success("Stripe integration removed."),s.push(i.settingsIntegrations(r))},onError:b=>{J.error(b.message||"Failed to remove Stripe integration.")}}),x=o.watch("paymentMethods"),y=(b,w)=>{const k=o.getValues("paymentMethods"),C=w?Array.from(new Set([...k,b])):k.filter(F=>F!==b);o.setValue("paymentMethods",C,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0})},j=b=>{o.clearErrors(["secretKey","webhookSecret"]);let w=!1;!(c!=null&&c.hasSecretKey)&&!b.secretKey.trim()&&(o.setError("secretKey",{type:"manual",message:"Stripe API key is required."}),w=!0),!(c!=null&&c.hasWebhookSecret)&&!b.webhookSecret.trim()&&(o.setError("webhookSecret",{type:"manual",message:"Stripe webhook secret is required."}),w=!0),!w&&p.mutate(b)};return e.jsxs("form",{onSubmit:o.handleSubmit(j),className:"space-y-14",children:[e.jsx("section",{"aria-labelledby":"stripe-payment-methods",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"stripe-payment-methods",className:"scroll-mt-10 text-lg font-semibold text-gray-900 dark:text-gray-50",children:"Payment Methods"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Choose which Stripe payment methods should be available at checkout."})]}),e.jsx("div",{className:"space-y-4 md:col-span-2",children:Tm.map(b=>e.jsxs("label",{className:"flex items-start gap-3 rounded-lg border border-gray-200 p-4 dark:border-gray-800",children:[e.jsx(Qe,{checked:x.includes(b.value),onCheckedChange:w=>y(b.value,w),className:"mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-50",children:b.label}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:b.description})]})]},b.value))})]})}),e.jsx(H,{}),e.jsx("section",{"aria-labelledby":"stripe-api-access",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"stripe-api-access",className:"scroll-mt-10 text-lg font-semibold text-gray-900 dark:text-gray-50",children:"API Access"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Save the Stripe secret API key used to create checkout sessions."})]}),e.jsx("div",{className:"space-y-5 md:col-span-2",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(me,{htmlFor:"stripe-secret-key",children:"Secret API Key"}),c!=null&&c.hasSecretKey?e.jsx(ue,{variant:"success",children:"Configured"}):e.jsx(ue,{variant:"warning",children:"Required"})]}),e.jsx(le,{id:"stripe-secret-key",type:"password",className:"mt-2",placeholder:c!=null&&c.hasSecretKey?"Leave blank to keep the saved API key":"sk_live_...",hasError:!!o.formState.errors.secretKey,...o.register("secretKey")}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-gray-500",children:"Saved API keys are never returned to the browser. Leave this blank to keep the currently stored key."}),o.formState.errors.secretKey&&e.jsx("p",{className:"mt-2 text-sm text-red-500",children:o.formState.errors.secretKey.message})]})})]})}),e.jsx(H,{}),e.jsx("section",{"aria-labelledby":"stripe-webhooks",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"stripe-webhooks",className:"scroll-mt-10 text-lg font-semibold text-gray-900 dark:text-gray-50",children:"Stripe Webhooks"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Copy the endpoint into Stripe, then paste the webhook secret here to save it as the Stripe integration config."})]}),e.jsxs("div",{className:"space-y-5 md:col-span-2",children:[e.jsxs("div",{children:[e.jsx(me,{htmlFor:"stripe-webhook-endpoint",children:"Webhook Endpoint"}),e.jsx(le,{id:"stripe-webhook-endpoint",value:n,disabled:!0,readOnly:!0,className:"mt-2",copyValue:n,copySuccessMessage:"Stripe webhook endpoint copied to clipboard.",copyErrorMessage:"Failed to copy Stripe webhook endpoint. Please try again."})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(me,{htmlFor:"stripe-webhook-secret",children:"Webhook Secret"}),c!=null&&c.hasWebhookSecret?e.jsx(ue,{variant:"success",children:"Configured"}):e.jsx(ue,{variant:"warning",children:"Required"})]}),e.jsx(le,{id:"stripe-webhook-secret",type:"password",className:"mt-2",placeholder:c!=null&&c.hasWebhookSecret?"Leave blank to keep the saved webhook secret":"whsec_...",hasError:!!o.formState.errors.webhookSecret,...o.register("webhookSecret")}),e.jsxs("p",{className:"mt-2 text-sm leading-6 text-gray-500",children:["Stripe config is validated server-side for the"," ",e.jsx("code",{children:"stripe"})," integration type before it is saved. Saved secrets are never returned in API responses."]}),o.formState.errors.webhookSecret&&e.jsx("p",{className:"mt-2 text-sm text-red-500",children:o.formState.errors.webhookSecret.message})]})]})]})}),e.jsx(H,{}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsxs(R,{type:"button",variant:"secondary",onClick:()=>s.push(m),children:[e.jsx(N.ChevronLeft,{className:"mr-2 h-4 w-4"})," Cancel"]}),l&&e.jsxs(R,{type:"button",variant:"secondary",className:"text-red-600 dark:text-red-400",onClick:()=>g.mutate(),isLoading:g.isPending,loadingText:"Removing...",children:[e.jsx(N.Trash2Icon,{className:"mr-2 h-4 w-4"})," Remove"]}),e.jsxs(R,{type:"submit",isLoading:p.isPending,loadingText:"Saving...",children:[e.jsx(N.CheckIcon,{className:"mr-2 h-4 w-4"})," Save Integration"]})]})]})}function Lm(){const a=za(),t=_(),r=$(),s=D.useRouter(),i=Br(a);return a==="stripe"?e.jsxs("div",{children:[e.jsxs("h1",{className:"text-lg font-semibold text-gray-900 sm:text-xl dark:text-gray-50",children:[Oa(a)," Integration"]}),e.jsx(H,{}),e.jsx("div",{className:"pt-6",children:e.jsx(Om,{})})]}):a==="resend"?e.jsxs("div",{children:[e.jsxs("h1",{className:"text-lg font-semibold text-gray-900 sm:text-xl dark:text-gray-50",children:[Oa(a)," Integration"]}),e.jsx(H,{}),e.jsx("div",{className:"pt-6",children:e.jsx(Pm,{})})]}):e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-gray-900 sm:text-xl dark:text-gray-50",children:(i==null?void 0:i.name)??Oa(a)}),e.jsx(H,{}),e.jsxs("div",{className:"pt-6",children:[e.jsx("p",{className:"text-sm leading-6 text-gray-500",children:"This integration does not have a configuration form yet."}),e.jsx("div",{className:"mt-6",children:e.jsx(R,{type:"button",variant:"secondary",onClick:()=>s.push(r.settingsIntegrationsCreate(t)),children:"Back to Integration Catalog"})})]})]})}const Jm=a=>{if(a.type==="stripe"){const t=zt.safeParse(a.config);return t.success?!t.data.hasSecretKey||!t.data.hasWebhookSecret?"Stripe setup needs attention":t.data.paymentMethods.length===0?"Stripe is connected with no payment methods enabled":`Enabled methods: ${t.data.paymentMethods.map(r=>r==="blik"?"BLIK":"Card").join(", ")}`:"Stripe configuration saved"}if(a.type==="resend"){const t=It.safeParse(a.config);return t.success?t.data.hasApiKey?t.data.fromEmail?`Sender: ${t.data.fromEmail}`:"Resend sender email is missing":"Resend setup needs attention":"Resend configuration saved"}return"Configuration saved"},Vm=a=>{if(a.type==="stripe"){const t=zt.safeParse(a.config);if(t.success)return t.data.hasSecretKey&&t.data.hasWebhookSecret?{label:"Configured",variant:"success"}:{label:"Needs setup",variant:"warning"}}if(a.type==="resend"){const t=It.safeParse(a.config);if(t.success)return t.data.hasApiKey&&t.data.fromEmail?{label:"Configured",variant:"success"}:{label:"Needs setup",variant:"warning"}}return{label:"Configured",variant:"success"}};function qm(){var n;const{client:a}=P(),t=_(),r=$(),s=A.useQuery({queryKey:["organization-integrations",t],queryFn:async()=>{const{body:o,status:l}=await a.integration.getIntegrations({params:{organizationId:t}});if(l!==200)throw new Error("Failed to fetch integrations");return o}}),i=A.useMutation({mutationFn:async o=>{const{status:l}=await a.integration.deleteIntegration({params:{organizationId:t,type:o}});if(l!==204)throw new Error("Failed to delete integration")},onSuccess:async()=>{J.success("Integration removed successfully"),await oe.invalidateQueries({queryKey:["organization-integrations",t]})},onError:o=>{J.error(o.message||"Failed to delete integration")}});return s.isLoading?e.jsx("div",{className:"mt-4 flex h-24 items-center justify-center",children:e.jsx(pe,{className:"h-6 w-6"})}):s.isError?e.jsx("p",{className:"mt-4 py-4 text-sm text-red-500",children:"Failed to load integrations."}):(n=s.data)!=null&&n.length?e.jsx("ul",{className:"mt-4 divide-y divide-gray-200 dark:divide-gray-800",children:s.data.map(o=>{const l=Br(o.type),c=Oa(o.type),m=Vm(o);return e.jsxs("li",{className:"flex items-center justify-between gap-x-6 py-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-x-3",children:[e.jsx("p",{className:"truncate text-sm font-medium text-gray-900 dark:text-gray-50",children:c}),e.jsx(ue,{variant:m.variant,children:m.label})]}),e.jsx("p",{className:"mt-1 truncate text-xs text-gray-500",children:Jm(o)}),(l==null?void 0:l.description)&&e.jsx("p",{className:"mt-1 truncate text-xs text-gray-500",children:l.description}),e.jsxs("p",{className:"mt-1 truncate text-xs text-gray-500",children:["Updated ",new Date(o.updatedAt).toLocaleString()]})]}),e.jsxs("div",{className:"flex items-center gap-x-4",children:[e.jsx(B,{href:r.settingsIntegration(t,o.type),className:"text-sm font-medium text-indigo-600 hover:text-indigo-500 dark:text-indigo-400 dark:hover:text-indigo-300",children:"Edit"}),e.jsx("button",{type:"button",onClick:()=>i.mutate(o.type),disabled:i.isPending,className:"text-sm font-medium text-red-600 hover:text-red-500 disabled:opacity-50 dark:text-red-400 dark:hover:text-red-300",children:"Delete"})]})]},`${o.organizationId}:${o.type}`)})}):e.jsx("p",{className:"mt-4 py-4 text-sm text-gray-500",children:"No integrations configured yet."})}function Hm(){const a=_(),t=$();return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"sm:flex sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Integrations"}),e.jsx("p",{className:"text-sm leading-6 text-gray-500",children:"Manage the integrations currently connected to your organization."})]}),e.jsx(R,{asChild:!0,className:"hidden gap-x-2 px-2 py-1.5 text-sm sm:text-xs lg:flex",children:e.jsxs(B,{href:t.settingsIntegrationsCreate(a),children:["Add Integration",e.jsx(N.PlusIcon,{className:"size-4 shrink-0","aria-hidden":"true"})]})})]}),e.jsx(qm,{})]})}const Um=[{name:"configuration.openingTimes.monday",label:"Monday",type:"time"},{name:"configuration.closingTimes.monday",label:"",type:"time"},{name:"configuration.openingTimes.tuesday",label:"Tuesday",type:"time"},{name:"configuration.closingTimes.tuesday",label:"",type:"time"},{name:"configuration.openingTimes.wednesday",label:"Wednesday",type:"time"},{name:"configuration.closingTimes.wednesday",label:"",type:"time"},{name:"configuration.openingTimes.thursday",label:"Thursday",type:"time"},{name:"configuration.closingTimes.thursday",label:"",type:"time"},{name:"configuration.openingTimes.friday",label:"Friday",type:"time"},{name:"configuration.closingTimes.friday",label:"",type:"time"},{name:"configuration.openingTimes.saturday",label:"Saturday",type:"time"},{name:"configuration.closingTimes.saturday",label:"",type:"time"},{name:"configuration.openingTimes.sunday",label:"Sunday",type:"time"},{name:"configuration.closingTimes.sunday",label:"",type:"time"},{name:"configuration.isAcceptingOrders",label:"Accepting Orders",type:"switch"},{name:"configuration.isAcceptingReservations",label:"Accepting Reservations",type:"switch"}],Zm=({onClose:a,initialData:t})=>{var o,l,c,m,u,p,g;const{client:r}=P(),s=Z.useForm({resolver:be.zodResolver(lr),defaultValues:{configuration:{defaultLocale:(o=t==null?void 0:t.configuration)==null?void 0:o.defaultLocale,supportedLocales:(l=t==null?void 0:t.configuration)==null?void 0:l.supportedLocales,defaultCurrency:(c=t==null?void 0:t.configuration)==null?void 0:c.defaultCurrency,openingTimes:(m=t==null?void 0:t.configuration)==null?void 0:m.openingTimes,closingTimes:(u=t==null?void 0:t.configuration)==null?void 0:u.closingTimes,isAcceptingOrders:(p=t==null?void 0:t.configuration)==null?void 0:p.isAcceptingOrders,isAcceptingReservations:(g=t==null?void 0:t.configuration)==null?void 0:g.isAcceptingReservations}}}),{isPending:i,mutate:n}=A.useMutation({mutationFn:async({configuration:x})=>{const{status:y}=await r.organization.updateOrganization({params:{organizationId:t==null?void 0:t.id},body:{configuration:x}});if(y!==200)throw J.error("Failed to update organization. Please try again later."),new Error("Failed to update organization");return await oe.invalidateQueries({queryKey:["organizations"]}),a&&a()}});return e.jsx(Be,{form:s,config:Um,onSubmit:x=>n(x),onCancel:a,loading:i,cancelText:"Go back",okText:"Save Schedule"})};function _m(){const{organization:a}=ke();return a.data?e.jsx("div",{className:"space-y-10",children:e.jsx("section",{"aria-labelledby":"opening-times",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"opening-times",className:"scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Opening and Closing Times"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Set the opening and closing times for your organization"})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsx(Zm,{initialData:a.data})})]})})}):e.jsx("div",{children:"Loading..."})}const En=({initialData:a})=>{var p;const{client:t}=P(),r=D.useRouter(),s=$(),i=_(),n=a?cl:ai,o=Z.useForm({resolver:be.zodResolver(n),defaultValues:a?{title:a.title,providerName:a.providerName,providerLogoId:(p=a.providerLogo)==null?void 0:p.id,requireDateOfDelivery:a.requireDateOfDelivery,shippingZones:a.shippingZones}:{shippingZones:[{}]}}),l=A.useMutation({mutationFn:async g=>{const{status:x}=await t.shippingMethod.createShippingMethod({params:{organizationId:i},body:g});if(x!==201)throw J.error("Failed to create shipping method. Please try again later."),new Error("Failed to create shipping method")}}),c=A.useMutation({mutationFn:async g=>{const{status:x}=await t.shippingMethod.updateShippingMethod({params:{organizationId:i,id:a.id},body:g});if(x!==200)throw J.error("Failed to update shipping method. Please try again later."),new Error("Failed to update shipping method")}}),m=async()=>{J.success("Shipping method saved successfully"),r.push(s.settingsShippingMethods(i)),await oe.invalidateQueries({queryKey:["shipping-and-payment"]})},u=g=>{a?c.mutate(g,{onSuccess:m}):l.mutate(g,{onSuccess:m})};return e.jsx(Z.FormProvider,{...o,children:e.jsxs("form",{onSubmit:o.handleSubmit(g=>u(g)),className:"space-y-14",children:[e.jsx("section",{"aria-labelledby":"Basic Information",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"product-information",className:"text-lg scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Basic Information"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Enter the information about your shipping method including title, shipping provider's name and logo"})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsx(Be,{form:o,config:[{name:"title",label:"Title",type:"text",placeholder:"Standard Shipping",colspan:2},{name:"providerName",label:"Provider Name",type:"text",placeholder:"FedEx",colspan:2},{name:"providerLogoId",label:"Provider Logo",type:"file"},{name:"requireDateOfDelivery",label:"Require Date of Delivery?",type:"switch",colspan:2}]})})]})}),e.jsx(H,{}),e.jsx("section",{"aria-labelledby":"product-information",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"product-information",className:"text-lg scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Shipping Zones"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Set pricing and minimum order based on delivery zones"})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsx(Be,{form:o,config:[{name:"shippingZones",type:"array",fields:[{name:"title",label:"Title",type:"text",placeholder:"Zone 1"},{name:"distanceUpto",label:"Distance To (km)",type:"number",placeholder:"10"},{name:"price",label:"Shipping Price",type:"number",placeholder:"5.99",prefix:"USD"},{name:"minimumOrderAmount",label:"Minimum Order Amount",type:"number",placeholder:"50",prefix:"USD"},{name:"eta",label:"Estimated Time of Arrival",type:"text",placeholder:"2-3 days"}]}]})})]})}),e.jsx(H,{}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsxs(R,{type:"button",variant:"secondary",onClick:()=>r.push(s.settingsShippingMethods(i)),children:[e.jsx(N.ChevronLeft,{className:"w-4 h-4 mr-2"})," Cancel"]}),e.jsxs(R,{type:"submit",isLoading:l.isPending||c.isPending,loadingText:"Saving...",children:[e.jsx(N.CheckIcon,{className:"w-4 h-4 mr-2"})," ",a?"Save Product":"Create Shipping Method"]})]})]})})};function $m(){return e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-gray-900 sm:text-xl dark:text-gray-50",children:"Create Shipping Method"}),e.jsx(H,{}),e.jsx("div",{className:"pt-6",children:e.jsx("div",{className:"space-y-10",children:e.jsx(En,{})})})]})}function Wm(){const a=_(),t=za(),{client:r}=P(),{isLoading:s,data:i}=A.useQuery({queryKey:["shipping-and-payment",a,t],queryFn:async()=>{const{status:n,body:o}=await r.shippingMethod.getShippingMethod({params:{id:t,organizationId:a}});if(n!==200)throw J.error("Failed to fetch shipping method. Please refresh or try again later."),new Error("Failed to fetch shipping method");return o},throwOnError:!0,placeholderData:A.keepPreviousData});return e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-gray-900 sm:text-xl dark:text-gray-50",children:"Edit Shipping Method"}),e.jsx(H,{}),e.jsx("div",{className:"pt-6",children:e.jsx("div",{className:"space-y-10",children:s||!i?e.jsx("div",{className:"flex justify-center items-center h-screen mt-5",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(pe,{className:"w-12 h-12"}),e.jsx("p",{className:"text-gray-500 text-sm mt-3",children:"Loading data..."})]})}):e.jsx(En,{initialData:i})})})]})}const fa=Ee.createColumnHelper(),Km=[fa.display({id:"select",header:({table:a})=>e.jsx(Qe,{checked:a.getIsAllPageRowsSelected()?!0:a.getIsSomeRowsSelected()?"indeterminate":!1,onCheckedChange:()=>a.toggleAllPageRowsSelected(),className:"translate-y-0.5","aria-label":"Select all"}),cell:({row:a})=>e.jsx(Qe,{checked:a.getIsSelected(),onCheckedChange:()=>a.toggleSelected(),className:"translate-y-0.5","aria-label":"Select row"}),enableSorting:!1,enableHiding:!1,meta:{displayName:"Select"}}),fa.accessor("id",{header:({column:a})=>e.jsx(q,{column:a,title:"Id"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"ID"},cell:({row:a,table:t})=>{var s,i,n;const r=(s=t.options.meta)==null?void 0:s.organizationId;return e.jsx(B,{href:((n=(i=t.options.meta)==null?void 0:i.routes)==null?void 0:n.settingsShippingMethodEdit(r,a.getValue("id")))??`/admin/${r}/settings/shipping-methods/${a.getValue("id")}`,className:"text-blue-500",children:a.getValue("id")})}}),fa.accessor("title",{header:({column:a})=>e.jsx(q,{column:a,title:"Title"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"Title"}}),fa.accessor("providerName",{header:({column:a})=>e.jsx(q,{column:a,title:"Provider Name"}),enableSorting:!0,meta:{className:"text-left",displayName:"Provider Name"}}),fa.accessor("shippingZones",{header:({column:a})=>e.jsx(q,{column:a,title:"Shipping Zones"}),enableSorting:!1,meta:{className:"text-left",displayName:"Shipping Zones"},cell:({row:a})=>a.getValue("shippingZones").map(t=>t.title).join(", ")||"-"}),fa.display({id:"edit",header:"Edit",enableSorting:!1,enableHiding:!1,meta:{className:"text-right",displayName:"Edit"},cell:({row:a,table:t})=>{var s,i,n;const r=(s=t.options.meta)==null?void 0:s.organizationId;return e.jsxs(ra,{children:[e.jsx(sa,{asChild:!0,children:e.jsx(R,{variant:"ghost",className:"group aspect-square px-1.5 py-0! h-8! hover:border hover:border-gray-300 data-[state=open]:border-gray-300 data-[state=open]:bg-gray-50 dark:hover:border-gray-700 dark:data-[state=open]:border-gray-700 dark:data-[state=open]:bg-gray-900",children:e.jsx(M.RiMoreFill,{className:"size-4 shrink-0 text-gray-500 group-hover:text-gray-700 group-data-[state=open]:text-gray-700 dark:group-hover:text-gray-300 dark:group-data-[state=open]:text-gray-300","aria-hidden":"true"})})}),e.jsxs(ia,{align:"end",className:"min-w-40",children:[e.jsx(Se,{children:e.jsx(B,{href:((n=(i=t.options.meta)==null?void 0:i.routes)==null?void 0:n.settingsShippingMethodEdit(r,a.getValue("id")))??`/admin/${r}/settings/shipping-methods/${a.getValue("id")}`,className:"block",children:"Edit"})}),e.jsx(Se,{className:"text-red-600 dark:text-red-500",children:"Delete"})]})]})}})],Gm=()=>{const{client:a}=P(),t=_(),r=D.useSearchParams(),[s]=h.useState(""),[i]=aa.useDebounce(s,300),n=Number((r==null?void 0:r.get("page"))||"1"),{isLoading:o,isRefetching:l,isError:c,data:m}=A.useQuery({queryKey:["shipping-and-payment",t,n,i],queryFn:async()=>{const{body:u,status:p}=await a.shippingMethod.getShippingMethods({params:{organizationId:t},query:{page:n,limit:10,search:i}});if(p!==200)throw new Error("Failed to fetch shipping methods");return u},placeholderData:A.keepPreviousData});return e.jsx("div",{children:e.jsx(Fa,{error:c,loading:o||l,meta:m!=null&&m.meta?{...m==null?void 0:m.meta,currentPage:n}:void 0,data:(m==null?void 0:m.list)||[],columns:Km,className:"mt-8"})})};function Xm(){const a=_(),t=$();return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"sm:flex sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{id:"existing-users",className:"scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Shipping Methods"}),e.jsx("p",{className:"text-sm leading-6 text-gray-500",children:"Set up delivery zones, pricing based on distance, and manage shipping methods and providers for your organization."})]}),e.jsx(R,{asChild:!0,className:"hidden gap-x-2 px-2 py-1.5 text-sm sm:text-xs lg:flex",children:e.jsxs(B,{href:t.settingsShippingMethodCreate(a),children:["Create Shipping Method",e.jsx(N.PlusIcon,{className:"size-4 shrink-0","aria-hidden":"true"})]})})]}),e.jsx(Gm,{})]})}function Me({children:a}){const t=D.usePathname(),r=_(),s=$(),i=[{name:"General",href:s.settings(r)},{name:"Integrations",href:s.settingsIntegrations(r)},{name:"Shipping Methods",href:s.settingsShippingMethods(r)},{name:"Opening Times",href:s.settingsOpeningTimes(r)},{name:"Access",href:s.settingsAccess(r)},{name:"API Keys",href:`${s.settings(r)}/api-keys`}];return t!=null&&t.match(/\/settings\/shipping-methods\/[^/]+$/)||t!=null&&t.match(/\/settings\/access\/[^/]+$/)||t!=null&&t.match(/\/settings\/integrations\/[^/]+$/)?e.jsx("div",{children:a}):e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-gray-900 sm:text-2xl dark:text-gray-50",children:"Settings"}),e.jsx(Ir,{className:"mt-4 sm:mt-6 lg:mt-6",children:i.map(n=>e.jsx(Er,{asChild:!0,active:t===n.href,children:e.jsx(B,{href:n.href,children:n.name})},n.name))}),e.jsx("div",{className:"pt-6",children:a})]})}const Ym=[{name:"configuration.defaultLocale",label:"Default Locale",type:"select",placeholder:"",options:$r},{name:"configuration.supportedLocales",label:"Supported Locales",type:"select",placeholder:"Select locales",multiple:!0,options:$r},{name:"configuration.defaultCurrency",label:"Currency",type:"select",placeholder:"Acme Inc.",options:Ro}],eu=({onClose:a,initialData:t})=>{var o,l,c;const{client:r}=P(),s=Z.useForm({resolver:be.zodResolver(lr),defaultValues:{configuration:{defaultLocale:(o=t==null?void 0:t.configuration)==null?void 0:o.defaultLocale,supportedLocales:(l=t==null?void 0:t.configuration)==null?void 0:l.supportedLocales,defaultCurrency:(c=t==null?void 0:t.configuration)==null?void 0:c.defaultCurrency}}}),{isPending:i,mutate:n}=A.useMutation({mutationFn:async({configuration:m})=>{const{status:u}=await r.organization.updateOrganization({params:{organizationId:t==null?void 0:t.id},body:{configuration:m}});if(u!==200)throw J.error("Failed to update organization. Please try again later."),new Error("Failed to update organization");return await oe.invalidateQueries({queryKey:["organizations"]}),a&&a()}});return e.jsx(Be,{form:s,config:Ym,onSubmit:m=>n(m),onCancel:a,loading:i,cancelText:"Go back",okText:"Save Settings"})};function au(){const{organization:a}=ke(),{client:t}=P(),r=_(),s=D.useRouter(),i=$(),n=A.useMutation({mutationFn:async()=>{const{status:o}=await t.access.leaveOrganization({params:{organizationId:r}});if(o!==204)throw new Error("Failed to leave organization")},onSuccess:async()=>{J.success("You have left the organization"),await oe.invalidateQueries({queryKey:["organizations"]}),s.push(i.organizations)},onError:o=>{J.error((o==null?void 0:o.message)||"Failed to leave organization")}});return a.data?e.jsxs("div",{className:"space-y-10",children:[e.jsx("section",{"aria-labelledby":"org-information",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"org-information",className:"scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Organization Information"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Manage your organization information."})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsx(bn,{initialData:a.data})})]})}),e.jsx(H,{}),e.jsx("section",{"aria-labelledby":"locale-settings",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"locale-settings",className:"scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Currency and Locale"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Set the currency and languages you support"})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsx(eu,{initialData:a.data})})]})}),e.jsx(H,{}),e.jsx("section",{"aria-labelledby":"danger-zone",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"danger-zone",className:"scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Danger zone"}),e.jsxs("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:["Manage general workspace. Contact system admin for more information."," ",e.jsxs("a",{href:"#",className:"inline-flex items-center gap-1 text-indigo-600 hover:underline hover:underline-offset-4 dark:text-indigo-400",children:["Learn more",e.jsx(N.ExternalLinkIcon,{className:"size-4 shrink-0","aria-hidden":"true"})]})]})]}),e.jsx("div",{className:"space-y-6 md:col-span-2",children:e.jsx(pa,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-10",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-gray-50",children:"Leave workspace"}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-gray-500",children:"Revoke your access to this team. Other people you have added to the workspace will remain."})]}),e.jsx(R,{variant:"secondary",className:"text-red-600 dark:text-red-500",onClick:()=>n.mutate(),isLoading:n.isPending,loadingText:"Leaving...",children:"Leave"})]})})})]})})]}):e.jsx("div",{children:"Loading..."})}function ne(a,t){return{label:"Home",href:t.dashboard(a)}}function tu(a,t){switch(a.type){case"home":case"sign-in":case"sign-up":case"organizations":case"not-found":return[];case"dashboard":return[{label:"Home"}];case"orders":return[ne(a.orgId,t),{label:"Orders"}];case"reservations":return[ne(a.orgId,t),{label:"Reservations"}];case"products-list":return[ne(a.orgId,t),{label:"Products"}];case"product-create":return[ne(a.orgId,t),{label:"Products",href:t.products(a.orgId)},{label:"Create Product"}];case"product-edit":return[ne(a.orgId,t),{label:"Products",href:t.products(a.orgId)},{label:"Edit Product"}];case"product-categories-list":return[ne(a.orgId,t),{label:"Product Categories"}];case"product-category-create":return[ne(a.orgId,t),{label:"Product Categories",href:t.productCategories(a.orgId)},{label:"Create Product Category"}];case"product-category-edit":return[ne(a.orgId,t),{label:"Product Categories",href:t.productCategories(a.orgId)},{label:"Edit Product Category"}];case"manufacturers-list":return[ne(a.orgId,t),{label:"Manufacturers"}];case"manufacturer-create":return[ne(a.orgId,t),{label:"Manufacturers",href:t.manufacturers(a.orgId)},{label:"Create Manufacturer"}];case"manufacturer-edit":return[ne(a.orgId,t),{label:"Manufacturers",href:t.manufacturers(a.orgId)},{label:"Edit Manufacturer"}];case"settings":return[ne(a.orgId,t),{label:"Settings"}];case"settings-opening-times":return[ne(a.orgId,t),{label:"Settings",href:t.settings(a.orgId)},{label:"Opening Times"}];case"settings-integrations":return[ne(a.orgId,t),{label:"Settings",href:t.settings(a.orgId)},{label:"Integrations"}];case"settings-integrations-create":return[ne(a.orgId,t),{label:"Settings",href:t.settings(a.orgId)},{label:"Integrations",href:t.settingsIntegrations(a.orgId)},{label:"Add Integration"}];case"settings-integration":return[ne(a.orgId,t),{label:"Settings",href:t.settings(a.orgId)},{label:"Integrations",href:t.settingsIntegrations(a.orgId)},{label:Oa(a.id)}];case"shipping-methods-list":return[ne(a.orgId,t),{label:"Settings",href:t.settings(a.orgId)},{label:"Shipping Methods"}];case"shipping-method-create":return[ne(a.orgId,t),{label:"Settings",href:t.settings(a.orgId)},{label:"Shipping Methods",href:t.settingsShippingMethods(a.orgId)},{label:"Create Shipping Method"}];case"shipping-method-edit":return[ne(a.orgId,t),{label:"Settings",href:t.settings(a.orgId)},{label:"Shipping Methods",href:t.settingsShippingMethods(a.orgId)},{label:"Edit Shipping Method"}];case"access-list":return[ne(a.orgId,t),{label:"Settings",href:t.settings(a.orgId)},{label:"Access"}];case"access-invite":return[ne(a.orgId,t),{label:"Settings",href:t.settings(a.orgId)},{label:"Access",href:t.settingsAccess(a.orgId)},{label:"Invite User"}];case"access-member-edit":return[ne(a.orgId,t),{label:"Settings",href:t.settings(a.orgId)},{label:"Access",href:t.settingsAccess(a.orgId)},{label:"Edit Member"}]}}function ru({view:a}){const t=$(),r=tu(a,t);return r.length===0?null:e.jsx("nav",{"aria-label":"Breadcrumb",className:"mb-4 overflow-x-auto pb-1",children:e.jsx("ol",{className:"flex min-w-max items-center text-sm text-gray-500 dark:text-gray-400",children:r.map((s,i)=>{const n=i===r.length-1;return e.jsxs("li",{className:"flex items-center",children:[i>0?e.jsx(N.ChevronRightIcon,{className:"mx-1 size-3.5 shrink-0 text-gray-400 dark:text-gray-500","aria-hidden":"true"}):null,s.href&&!n?e.jsx(B,{href:s.href,className:"whitespace-nowrap rounded-sm transition hover:text-gray-900 dark:hover:text-gray-200",children:s.label}):e.jsx("span",{"aria-current":n?"page":void 0,className:n?"whitespace-nowrap font-medium text-gray-900 dark:text-gray-50":"whitespace-nowrap",children:s.label})]},`${s.label}-${i}`)})})})}const su=()=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:451,zoomAndPan:"magnify",viewBox:"0 0 338.25 101.249998",height:135,preserveAspectRatio:"xMidYMid meet",className:"h-auto w-3/4 mr-5 text-[#15203a] dark:text-white",children:[e.jsxs("defs",{children:[e.jsx("filter",{x:"0%",y:"0%",width:"100%",height:"100%",id:"e96f145012",children:e.jsx("feColorMatrix",{values:"0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0",colorInterpolationFilters:"sRGB"})}),e.jsx("g",{}),e.jsx("clipPath",{id:"2854c0f5ba",children:e.jsx("path",{d:"M 280.070312 29.789062 L 335.910156 29.789062 L 335.910156 85.628906 L 280.070312 85.628906 Z M 280.070312 29.789062 ",clipRule:"nonzero"})}),e.jsx("clipPath",{id:"a2b4eafd05",children:e.jsx("path",{d:"M 312.023438 83.421875 L 333.382812 62.0625 C 335.910156 59.535156 335.910156 55.460938 333.382812 52.933594 L 312.285156 31.835938 C 310.859375 30.410156 308.949219 29.632812 306.941406 29.632812 L 280.46875 29.632812 L 303.773438 52.933594 C 306.296875 55.460938 306.296875 59.535156 303.773438 62.0625 L 280.210938 85.621094 L 306.683594 85.621094 C 308.691406 85.621094 310.601562 84.8125 312.023438 83.421875 Z M 312.023438 83.421875 ",clipRule:"nonzero"})}),e.jsx("image",{x:0,y:0,width:57,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADkAAAA5CAYAAACMGIOFAAAABmJLR0QA/wD/AP+gvaeTAAAAdElEQVRoge3PMQqEQBAAwXVB//9kEwMD9eAwKrthYGBgoJZx3xxjrMdsp/1qft3f+PHvfc4HJFNIpZBKIZVCKoVUCqkUUimkUkilkEohlUIqhVQKqRRSKaRSSKWQSiGVQiqFVAqpFFIppFJIpZBKIZU+gdwB24gBccg7AIAAAAAASUVORK5CYII=",id:"c594f9d06d",height:57,preserveAspectRatio:"xMidYMid meet"}),e.jsx("mask",{id:"1f1a4971c6",children:e.jsx("g",{filter:"url(#e96f145012)",children:e.jsx("g",{children:e.jsx("image",{x:0,y:0,width:57,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADkAAAA5CAYAAACMGIOFAAAABmJLR0QA/wD/AP+gvaeTAAAAdElEQVRoge3PMQqEQBAAwXVB//9kEwMD9eAwKrthYGBgoJZx3xxjrMdsp/1qft3f+PHvfc4HJFNIpZBKIZVCKoVUCqkUUimkUkilkEohlUIqhVQKqRRSKaRSSKWQSiGVQiqFVAqpFFIppFJIpZBKIZU+gdwB24gBccg7AIAAAAAASUVORK5CYII=",height:57,preserveAspectRatio:"xMidYMid meet"})})})}),e.jsx("clipPath",{id:"d584d4a10b",children:e.jsx("rect",{x:0,width:57,y:0,height:57})}),e.jsx("pattern",{id:"ca59399d09",patternUnits:"userSpaceOnUse",width:57,patternTransform:"matrix(0.992647, 0, 0, -0.992647, 279.805145, 86.320587)",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 57 57",height:57,x:0,y:0,children:e.jsx("g",{children:e.jsx("g",{clipPath:"url(#d584d4a10b)",children:e.jsx("g",{mask:"url(#1f1a4971c6)",children:e.jsx("rect",{x:"-356.844005",width:"490.68801",fill:"#8c52ff",height:"146.88",y:"-37.48",fillOpacity:1})})})})}),e.jsx("clipPath",{id:"058149a1c1",children:e.jsx("path",{d:"M 271.277344 20.996094 L 327 20.996094 L 327 76.832031 L 271.277344 76.832031 Z M 271.277344 20.996094 ",clipRule:"nonzero"})}),e.jsx("clipPath",{id:"3a8b0dae6b",children:e.jsx("path",{d:"M 303.230469 74.625 L 324.589844 53.265625 C 327.113281 50.742188 327.113281 46.664062 324.589844 44.140625 L 303.488281 23.039062 C 302.0625 21.613281 300.15625 20.839844 298.148438 20.839844 L 271.675781 20.839844 L 294.976562 44.140625 C 297.5 46.664062 297.5 50.742188 294.976562 53.265625 L 271.414062 76.824219 L 297.890625 76.824219 C 299.894531 76.824219 301.804688 76.015625 303.230469 74.625 Z M 303.230469 74.625 ",clipRule:"nonzero"})}),e.jsx("image",{x:0,y:0,width:57,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADkAAAA5CAYAAACMGIOFAAAABmJLR0QA/wD/AP+gvaeTAAAAbklEQVRoge3PwQmAAAwEwaho/yVbgfrQ17gLeR0EZpnrlpk5Zma/ubf7Fz+e9m29QTKFVAqpFFIppFJIpZBKIZVCKoVUCqkUUimkUkilkEohlUIqhVQKqRRSKaRSSKWQSiGVQiqFVAqpFFLpF8gT2vQBcSod/NEAAAAASUVORK5CYII=",id:"85d98eb3ed",height:57,preserveAspectRatio:"xMidYMid meet"}),e.jsx("mask",{id:"712d9ec0cc",children:e.jsx("g",{filter:"url(#e96f145012)",children:e.jsx("g",{children:e.jsx("image",{x:0,y:0,width:57,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADkAAAA5CAYAAACMGIOFAAAABmJLR0QA/wD/AP+gvaeTAAAAbklEQVRoge3PwQmAAAwEwaho/yVbgfrQ17gLeR0EZpnrlpk5Zma/ubf7Fz+e9m29QTKFVAqpFFIppFJIpZBKIZVCKoVUCqkUUimkUkilkEohlUIqhVQKqRRSKaRSSKWQSiGVQiqFVAqpFFLpF8gT2vQBcSod/NEAAAAASUVORK5CYII=",height:57,preserveAspectRatio:"xMidYMid meet"})})})}),e.jsx("clipPath",{id:"66291c0f48",children:e.jsx("rect",{x:0,width:57,y:0,height:57})}),e.jsx("pattern",{id:"82194e6edc",patternUnits:"userSpaceOnUse",width:57,patternTransform:"matrix(0.992647, 0, 0, -0.992647, 270.871322, 77.386763)",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 57 57",height:57,x:0,y:0,children:e.jsx("g",{children:e.jsx("g",{clipPath:"url(#66291c0f48)",children:e.jsx("g",{mask:"url(#712d9ec0cc)",children:e.jsx("rect",{x:"-347.844005",width:"490.68801",fill:"#8c52ff",height:"146.88",y:"-46.48",fillOpacity:1})})})})})]}),e.jsx("g",{fill:"currentColor",fillOpacity:1,children:e.jsx("g",{transform:"translate(19.705917, 70.793676)",children:e.jsx("g",{children:e.jsx("path",{d:"M 16.359375 0.0625 C 13.921875 0.0625 11.773438 -0.289062 9.921875 -1 C 8.441406 -1.59375 6.925781 -2.570312 5.375 -3.9375 C 3.601562 -5.5625 2.476562 -7.578125 2 -9.984375 C 1.8125 -10.753906 1.71875 -11.53125 1.71875 -12.3125 C 1.675781 -12.570312 1.675781 -12.832031 1.71875 -13.09375 L 1.71875 -13.46875 L 9.3125 -13.359375 L 9.3125 -13.421875 C 9.3125 -12.054688 9.609375 -10.925781 10.203125 -10.03125 C 11.304688 -8.375 13.359375 -7.546875 16.359375 -7.546875 C 21.160156 -7.546875 23.5625 -8.671875 23.5625 -10.921875 C 23.5625 -13.109375 21.085938 -14.476562 16.140625 -15.03125 C 13.285156 -15.363281 10.84375 -15.953125 8.8125 -16.796875 C 6.925781 -17.578125 5.394531 -18.613281 4.21875 -19.90625 C 2.550781 -21.757812 1.71875 -23.90625 1.71875 -26.34375 C 1.71875 -27.851562 1.992188 -29.273438 2.546875 -30.609375 C 2.953125 -31.609375 3.507812 -32.515625 4.21875 -33.328125 C 6.800781 -36.242188 10.90625 -37.703125 16.53125 -37.703125 C 19.894531 -37.703125 22.738281 -37.039062 25.0625 -35.71875 C 26.832031 -34.71875 28.273438 -33.382812 29.390625 -31.71875 C 30.203125 -30.457031 30.773438 -29.015625 31.109375 -27.390625 C 31.222656 -26.835938 31.296875 -26.285156 31.328125 -25.734375 C 31.367188 -25.546875 31.390625 -25.359375 31.390625 -25.171875 L 31.390625 -24.84375 L 23.796875 -24.84375 L 23.796875 -24.78125 C 23.828125 -25.894531 23.546875 -26.835938 22.953125 -27.609375 C 21.773438 -29.273438 19.632812 -30.109375 16.53125 -30.109375 C 14.644531 -30.109375 13.085938 -29.867188 11.859375 -29.390625 C 10.347656 -28.796875 9.59375 -27.945312 9.59375 -26.84375 C 9.59375 -24.550781 12.050781 -23.125 16.96875 -22.5625 C 22.507812 -21.9375 26.503906 -20.21875 28.953125 -17.40625 C 30.578125 -15.488281 31.390625 -13.328125 31.390625 -10.921875 L 31.390625 -10.421875 C 31.390625 -10.203125 31.367188 -9.984375 31.328125 -9.765625 C 31.296875 -9.171875 31.222656 -8.613281 31.109375 -8.09375 C 30.734375 -6.613281 30.03125 -5.300781 29 -4.15625 C 27.78125 -2.789062 26.132812 -1.738281 24.0625 -1 C 22 -0.289062 19.429688 0.0625 16.359375 0.0625 Z M 16.359375 0.0625 "})})})}),e.jsx("g",{fill:"currentColor",fillOpacity:1,children:e.jsx("g",{transform:"translate(52.748732, 70.793676)",children:e.jsx("g",{children:e.jsx("path",{d:"M 30.78125 0 L 23.5625 0 L 23.5625 -14.078125 L 23.515625 -14.078125 L 23.515625 -14.25 C 23.515625 -16.175781 22.828125 -17.820312 21.453125 -19.1875 C 20.085938 -20.550781 18.425781 -21.234375 16.46875 -21.234375 C 14.550781 -21.234375 12.890625 -20.53125 11.484375 -19.125 C 10.078125 -17.726562 9.410156 -16.066406 9.484375 -14.140625 L 9.484375 -14.078125 L 9.421875 -14.078125 L 9.421875 0 L 1.65625 0 L 1.65625 -36.046875 L 9.421875 -36.046875 L 9.421875 -24.953125 C 11.160156 -27.023438 13.492188 -28.191406 16.421875 -28.453125 C 20.484375 -28.785156 23.84375 -27.726562 26.5 -25.28125 C 29.351562 -22.65625 30.78125 -18.976562 30.78125 -14.25 Z M 30.78125 0 "})})})}),e.jsx("g",{fill:"currentColor",fillOpacity:1,children:e.jsx("g",{transform:"translate(85.181699, 70.793676)",children:e.jsx("g",{children:e.jsx("path",{d:"M 14.8125 -28.5625 C 18.757812 -28.59375 22.117188 -27.222656 24.890625 -24.453125 C 27.703125 -21.640625 29.109375 -18.273438 29.109375 -14.359375 C 29.148438 -10.398438 27.785156 -7.035156 25.015625 -4.265625 C 22.234375 -1.460938 18.882812 -0.0390625 14.96875 0 C 11.007812 0.0390625 7.628906 -1.328125 4.828125 -4.109375 C 2.015625 -6.878906 0.609375 -10.242188 0.609375 -14.203125 C 0.566406 -18.148438 1.9375 -21.507812 4.71875 -24.28125 C 7.488281 -27.09375 10.851562 -28.519531 14.8125 -28.5625 Z M 19.859375 -9.3125 C 21.222656 -10.6875 21.90625 -12.351562 21.90625 -14.3125 C 21.90625 -16.226562 21.203125 -17.890625 19.796875 -19.296875 C 18.390625 -20.628906 16.726562 -21.296875 14.8125 -21.296875 C 12.882812 -21.296875 11.238281 -20.613281 9.875 -19.25 C 8.5 -17.800781 7.8125 -16.132812 7.8125 -14.25 C 7.8125 -12.332031 8.515625 -10.671875 9.921875 -9.265625 C 11.296875 -7.890625 12.960938 -7.203125 14.921875 -7.203125 C 16.910156 -7.273438 18.554688 -7.976562 19.859375 -9.3125 Z M 19.859375 -9.3125 "})})})}),e.jsx("g",{fill:"currentColor",fillOpacity:1,children:e.jsx("g",{transform:"translate(114.89805, 70.793676)",children:e.jsx("g",{children:e.jsx("path",{d:"M 16.53125 -28.5625 C 20.445312 -28.59375 23.8125 -27.222656 26.625 -24.453125 C 29.425781 -21.679688 30.847656 -18.316406 30.890625 -14.359375 C 30.921875 -10.441406 29.550781 -7.078125 26.78125 -4.265625 C 24.007812 -1.460938 20.644531 -0.0390625 16.6875 0 C 13.46875 0 11.046875 -1.015625 9.421875 -3.046875 L 9.421875 10.640625 L 1.65625 10.640625 L 1.65625 -28.5 L 9.421875 -28.5 L 9.421875 -25.515625 C 10.941406 -27.472656 13.3125 -28.488281 16.53125 -28.5625 Z M 21.625 -9.3125 C 23.03125 -10.71875 23.695312 -12.382812 23.625 -14.3125 C 23.625 -16.269531 22.941406 -17.929688 21.578125 -19.296875 C 20.171875 -20.628906 18.503906 -21.296875 16.578125 -21.296875 C 14.617188 -21.296875 12.957031 -20.613281 11.59375 -19.25 C 10.21875 -17.800781 9.53125 -16.132812 9.53125 -14.25 C 9.613281 -12.25 10.316406 -10.585938 11.640625 -9.265625 C 13.015625 -7.890625 14.679688 -7.203125 16.640625 -7.203125 C 18.628906 -7.273438 20.289062 -7.976562 21.625 -9.3125 Z M 21.625 -9.3125 "})})})}),e.jsx("g",{fill:"currentColor",fillOpacity:1,children:e.jsx("g",{transform:"translate(146.665722, 70.793676)",children:e.jsx("g",{children:e.jsx("path",{d:"M 30.78125 0 L 23.5625 0 L 23.5625 -14.078125 L 23.515625 -14.078125 L 23.515625 -14.25 C 23.515625 -16.175781 22.828125 -17.820312 21.453125 -19.1875 C 20.085938 -20.550781 18.425781 -21.234375 16.46875 -21.234375 C 14.550781 -21.234375 12.890625 -20.53125 11.484375 -19.125 C 10.078125 -17.726562 9.410156 -16.066406 9.484375 -14.140625 L 9.484375 -14.078125 L 9.421875 -14.078125 L 9.421875 0 L 1.65625 0 L 1.65625 -36.046875 L 9.421875 -36.046875 L 9.421875 -24.953125 C 11.160156 -27.023438 13.492188 -28.191406 16.421875 -28.453125 C 20.484375 -28.785156 23.84375 -27.726562 26.5 -25.28125 C 29.351562 -22.65625 30.78125 -18.976562 30.78125 -14.25 Z M 30.78125 0 "})})})}),e.jsx("g",{fill:"currentColor",fillOpacity:1,children:e.jsx("g",{transform:"translate(179.09869, 70.793676)",children:e.jsx("g",{children:e.jsx("path",{d:"M 14.8125 -28.5625 C 18.757812 -28.59375 22.117188 -27.222656 24.890625 -24.453125 C 27.703125 -21.640625 29.109375 -18.273438 29.109375 -14.359375 C 29.148438 -10.398438 27.785156 -7.035156 25.015625 -4.265625 C 22.234375 -1.460938 18.882812 -0.0390625 14.96875 0 C 11.007812 0.0390625 7.628906 -1.328125 4.828125 -4.109375 C 2.015625 -6.878906 0.609375 -10.242188 0.609375 -14.203125 C 0.566406 -18.148438 1.9375 -21.507812 4.71875 -24.28125 C 7.488281 -27.09375 10.851562 -28.519531 14.8125 -28.5625 Z M 19.859375 -9.3125 C 21.222656 -10.6875 21.90625 -12.351562 21.90625 -14.3125 C 21.90625 -16.226562 21.203125 -17.890625 19.796875 -19.296875 C 18.390625 -20.628906 16.726562 -21.296875 14.8125 -21.296875 C 12.882812 -21.296875 11.238281 -20.613281 9.875 -19.25 C 8.5 -17.800781 7.8125 -16.132812 7.8125 -14.25 C 7.8125 -12.332031 8.515625 -10.671875 9.921875 -9.265625 C 11.296875 -7.890625 12.960938 -7.203125 14.921875 -7.203125 C 16.910156 -7.273438 18.554688 -7.976562 19.859375 -9.3125 Z M 19.859375 -9.3125 "})})})}),e.jsx("g",{fill:"currentColor",fillOpacity:1,children:e.jsx("g",{transform:"translate(208.81504, 70.793676)",children:e.jsx("g",{children:e.jsx("path",{d:"M 13.203125 0 C 11.273438 0 9.59375 -0.296875 8.15625 -0.890625 C 7.007812 -1.296875 5.828125 -2.050781 4.609375 -3.15625 C 2.492188 -5.113281 1.53125 -7.59375 1.71875 -10.59375 L 1.71875 -11.203125 L 7.9375 -11.09375 L 8.421875 -11.09375 L 8.421875 -10.640625 C 8.460938 -9.722656 8.664062 -8.96875 9.03125 -8.375 C 9.664062 -7.300781 11.054688 -6.765625 13.203125 -6.765625 C 14.972656 -6.765625 16.25 -6.96875 17.03125 -7.375 C 17.4375 -7.5625 17.710938 -7.800781 17.859375 -8.09375 C 17.929688 -8.207031 17.96875 -8.316406 17.96875 -8.421875 L 18.015625 -8.703125 C 18.015625 -9.484375 17.40625 -10.113281 16.1875 -10.59375 C 15.707031 -10.78125 15.15625 -10.925781 14.53125 -11.03125 C 14.050781 -11.144531 13.515625 -11.238281 12.921875 -11.3125 C 10.703125 -11.53125 8.851562 -11.972656 7.375 -12.640625 C 5.894531 -13.234375 4.675781 -14.046875 3.71875 -15.078125 C 2.382812 -16.597656 1.71875 -18.335938 1.71875 -20.296875 C 1.71875 -21.515625 1.941406 -22.640625 2.390625 -23.671875 C 2.722656 -24.484375 3.164062 -25.207031 3.71875 -25.84375 C 5.707031 -28.132812 8.90625 -29.28125 13.3125 -29.28125 C 15.9375 -29.28125 18.15625 -28.757812 19.96875 -27.71875 C 21.375 -26.945312 22.5 -25.894531 23.34375 -24.5625 C 24.007812 -23.5625 24.472656 -22.398438 24.734375 -21.078125 C 24.804688 -20.628906 24.859375 -20.203125 24.890625 -19.796875 L 24.890625 -18.625 L 18.1875 -18.625 L 18.1875 -19.46875 C 18.15625 -19.613281 18.140625 -19.757812 18.140625 -19.90625 C 18.023438 -20.3125 17.875 -20.644531 17.6875 -20.90625 C 16.875 -22.007812 15.414062 -22.5625 13.3125 -22.5625 C 10.207031 -22.5625 8.65625 -21.914062 8.65625 -20.625 C 8.65625 -19.957031 9.023438 -19.421875 9.765625 -19.015625 C 10.535156 -18.535156 11.847656 -18.1875 13.703125 -17.96875 C 17.953125 -17.519531 21.035156 -16.171875 22.953125 -13.921875 C 24.242188 -12.398438 24.890625 -10.660156 24.890625 -8.703125 L 24.890625 -8.3125 L 24.84375 -7.8125 C 24.84375 -7.332031 24.785156 -6.890625 24.671875 -6.484375 C 24.378906 -5.304688 23.828125 -4.253906 23.015625 -3.328125 C 22.085938 -2.210938 20.789062 -1.378906 19.125 -0.828125 C 17.46875 -0.273438 15.492188 0 13.203125 0 Z M 13.203125 0 "})})})}),e.jsx("g",{fill:"currentColor",fillOpacity:1,children:e.jsx("g",{transform:"translate(235.371259, 70.793676)",children:e.jsx("g",{children:e.jsx("path",{d:"M 22.234375 -28.5625 L 22.234375 -20.796875 L 15.859375 -20.796875 L 15.859375 0 L 8.09375 0 L 8.09375 -20.796875 L 1.65625 -20.796875 L 1.65625 -28.5625 L 8.09375 -28.5625 L 8.09375 -38.546875 L 15.859375 -38.546875 L 15.859375 -28.5625 Z M 22.234375 -28.5625 "})})})}),e.jsx("g",{fill:"currentColor",fillOpacity:1,children:e.jsx("g",{transform:"translate(259.266309, 70.793676)",children:e.jsx("g",{children:e.jsx("path",{d:"M 9.421875 0 L 1.65625 0 L 1.65625 -7.765625 L 9.421875 -7.765625 Z M 9.421875 0 "})})})}),e.jsx("g",{clipPath:"url(#2854c0f5ba)",children:e.jsx("g",{clipPath:"url(#a2b4eafd05)",children:e.jsx("path",{fill:"url(#ca59399d09)",d:"M 335.910156 85.621094 L 280.214844 85.621094 L 280.214844 29.789062 L 335.910156 29.789062 Z M 335.910156 85.621094 ",fillRule:"nonzero"})})}),e.jsx("g",{clipPath:"url(#058149a1c1)",children:e.jsx("g",{clipPath:"url(#3a8b0dae6b)",children:e.jsx("path",{fill:"url(#82194e6edc)",d:"M 327.113281 76.824219 L 271.417969 76.824219 L 271.417969 20.992188 L 327.113281 20.992188 Z M 327.113281 76.824219 ",fillRule:"nonzero"})})})]}),Dn=a=>e.jsx(re.Root,{...a});Dn.displayName="Drawer";const Rn=z.forwardRef(({className:a,...t},r)=>e.jsx(re.Trigger,{ref:r,className:v(a),...t}));Rn.displayName="Drawer.Trigger";const Fn=z.forwardRef(({className:a,...t},r)=>e.jsx(re.Close,{ref:r,className:v(a),...t}));Fn.displayName="Drawer.Close";const Mn=re.Portal;Mn.displayName="DrawerPortal";const Pn=z.forwardRef(({className:a,...t},r)=>e.jsx(re.Overlay,{ref:r,className:v("fixed inset-0 z-50 overflow-y-auto","bg-black/30","data-[state=closed]:animate-hide data-[state=open]:animate-dialogOverlayShow",a),...t,style:{animationDuration:"400ms",animationFillMode:"backwards"}}));Pn.displayName="DrawerOverlay";const Bn=z.forwardRef(({className:a,...t},r)=>e.jsx(Mn,{children:e.jsx(Pn,{children:e.jsx(re.Content,{ref:r,className:v("fixed inset-y-2 mx-auto flex w-[95vw] flex-1 flex-col overflow-y-auto rounded-md border p-4 shadow-lg focus:outline-hidden max-sm:inset-x-2 sm:inset-y-2 sm:right-2 sm:max-w-lg sm:p-6","border-gray-200 dark:border-gray-900","bg-white dark:bg-[#090E1A]","data-[state=closed]:animate-drawerSlideRightAndFade data-[state=open]:animate-drawerSlideLeftAndFade",Ae,a),...t})})}));Bn.displayName="DrawerContent";const Tn=z.forwardRef(({children:a,className:t,...r},s)=>e.jsxs("div",{ref:s,className:"flex items-start justify-between gap-x-4 border-b border-gray-200 pb-4 dark:border-gray-900",...r,children:[e.jsx("div",{className:v("mt-1 flex flex-col gap-y-1",t),children:a}),e.jsx(re.Close,{asChild:!0,children:e.jsx(R,{variant:"ghost",className:"aspect-square p-1 hover:bg-gray-100 dark:hover:bg-gray-400/10",children:e.jsx(M.RiCloseLine,{className:"size-6","aria-hidden":"true"})})})]}));Tn.displayName="Drawer.Header";const Qn=z.forwardRef(({className:a,...t},r)=>e.jsx(re.Title,{ref:r,className:v("text-base font-semibold","text-gray-900 dark:text-gray-50",a),...t}));Qn.displayName="DrawerTitle";const On=z.forwardRef(({className:a,...t},r)=>e.jsx("div",{ref:r,className:v("flex-1 py-4",a),...t}));On.displayName="Drawer.Body";const iu=z.forwardRef(({className:a,...t},r)=>e.jsx(re.Description,{ref:r,className:v("text-gray-500 dark:text-gray-500",a),...t}));iu.displayName="DrawerDescription";function nu(){const a=D.usePathname(),t=_(),r=$();if(!t)return null;const s=[{name:"Dashboard",href:r.dashboard(t),icon:N.HomeIcon},{name:"Live Orders",href:r.liveOrders(t),icon:N.RadioIcon},{name:"Orders",href:r.orders(t),icon:N.LogsIcon},{name:"Reservations",href:r.reservations(t),icon:N.CalendarCheckIcon},{name:"Products",href:r.products(t),icon:N.PackageIcon},{name:"Categories",href:r.productCategories(t),icon:N.BoxesIcon},{name:"Manufacturers",href:r.manufacturers(t),icon:N.FactoryIcon},{name:"Settings",href:r.settings(t),icon:M.RiSettings5Line}];return e.jsxs(Dn,{children:[e.jsx(Rn,{asChild:!0,children:e.jsx(R,{variant:"ghost","aria-label":"open sidebar",className:"group flex items-center rounded-md p-2 text-sm font-medium hover:bg-gray-100 data-[state=open]:bg-gray-100 data-[state=open]:bg-gray-400/10 dark:hover:bg-gray-400/10",children:e.jsx(M.RiMenuLine,{className:"size-6 shrink-0 sm:size-5","aria-hidden":"true"})})}),e.jsxs(Bn,{className:"sm:max-w-lg",children:[e.jsx(Tn,{children:e.jsx(Qn,{children:"Navigation"})}),e.jsx(On,{children:e.jsx("nav",{"aria-label":"mobile navigation links",className:"flex flex-1 flex-col space-y-10",children:e.jsx("ul",{role:"list",className:"space-y-1.5",children:s.map(i=>e.jsx("li",{children:e.jsx(Fn,{asChild:!0,children:e.jsxs(B,{href:i.href,className:U(a===i.href||a!=null&&a.startsWith(i.href)?"text-blue-600 dark:text-blue-400":"text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-50","flex items-center gap-x-2.5 rounded-md px-2 py-1.5 text-base font-medium transition hover:bg-gray-100 sm:text-sm dark:hover:bg-gray-900",Ae),children:[e.jsx(i.icon,{className:"size-5 shrink-0","aria-hidden":"true"}),i.name]})})},i.name))})})})]})]})}const ou=()=>{var l;const[a,t]=h.useState(!1),r=h.useRef(null),{organizations:s,organization:i}=ke(),n=D.useRouter(),o=$();return e.jsx(e.Fragment,{children:e.jsxs(ra,{open:a,onOpenChange:t,modal:!1,children:[e.jsx(sa,{asChild:!0,children:i.data&&e.jsxs("button",{className:v("flex w-full items-center gap-x-2.5 rounded-md border border-gray-300 bg-white p-2 text-sm shadow-xs transition-all hover:bg-gray-50 dark:border-gray-800 dark:bg-gray-950 dark:hover:bg-gray-900",Sa),children:[i.data.logoFile?e.jsx(ze,{src:i.data.logoFile.url,alt:i.data.name,width:40,height:40,className:"flex aspect-square size-8 items-center justify-center rounded"}):e.jsxs("span",{className:"flex aspect-square size-8 items-center justify-center rounded bg-blue-600 p-2 text-xs font-medium text-white dark:bg-blue-500 uppercase","aria-hidden":"true",children:[i.data.name[0],i.data.name[1]]}),e.jsxs("div",{className:"flex w-full items-center justify-between gap-x-4 truncate",children:[e.jsxs("div",{className:"truncate text-left",children:[e.jsx("p",{className:"truncate whitespace-nowrap text-sm font-medium text-gray-900 dark:text-gray-50",children:i.data.name}),e.jsx("p",{className:"whitespace-nowrap text-left text-xs text-gray-700 dark:text-gray-300",children:(l=i.data.address)==null?void 0:l.addressLineOne})]}),e.jsx(M.RiExpandUpDownLine,{className:"size-5 shrink-0 text-gray-500","aria-hidden":"true"})]})]})}),e.jsx(ia,{hidden:!1,onCloseAutoFocus:c=>{r.current&&(r.current.focus(),r.current=null,c.preventDefault())},children:e.jsxs(La,{children:[e.jsxs(Ht,{children:["Workspaces (",s.data.length,")"]}),s.data.map(c=>{var m;return e.jsx(Se,{onClick:()=>n.push(o.dashboard(c.id)),children:e.jsxs("div",{className:"flex w-full items-center gap-x-2.5",children:[c.logoFile?e.jsx(ze,{src:c.logoFile.url,alt:c.name,width:40,height:40,className:"flex aspect-square size-8 items-center justify-center rounded"}):e.jsxs("span",{className:"flex aspect-square size-8 items-center justify-center rounded bg-blue-600 p-2 text-xs font-medium text-white dark:bg-blue-500 uppercase","aria-hidden":"true",children:[c.name[0],c.name[1]]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-50",children:c.name}),e.jsx("p",{className:"text-xs text-gray-700 dark:text-gray-400",children:(m=c.address)==null?void 0:m.addressLineOne})]})]})},c.id)})]})})]})})},lu=()=>{const[a,t]=h.useState(!1),r=h.useRef(null),{organizations:s,organization:i}=ke(),n=D.useRouter(),o=$();return e.jsxs(ra,{open:a,onOpenChange:t,modal:!1,children:[e.jsx(sa,{asChild:!0,children:i.data&&e.jsxs("button",{className:"flex items-center gap-x-1.5 rounded-md p-2 hover:bg-gray-100 focus:outline-hidden dark:hover:bg-gray-900",children:[i.data.logoFile?e.jsx(ze,{src:i.data.logoFile.url,alt:i.data.name,width:28,height:28,className:"flex aspect-square size-7 items-center justify-center rounded"}):e.jsxs("span",{className:"flex aspect-square size-7 items-center justify-center rounded bg-blue-600 p-2 text-xs font-medium text-white dark:bg-blue-500 uppercase","aria-hidden":"true",children:[i.data.name[0],i.data.name[1]]}),e.jsx(M.RiArrowRightSLine,{className:"size-4 shrink-0 text-gray-500","aria-hidden":"true"}),e.jsxs("div",{className:"flex w-full items-center justify-between gap-x-3 truncate",children:[e.jsx("p",{className:"truncate whitespace-nowrap text-sm font-medium text-gray-900 dark:text-gray-50",children:i.data.name}),e.jsx(M.RiExpandUpDownLine,{className:"size-4 shrink-0 text-gray-500","aria-hidden":"true"})]})]})}),e.jsx(ia,{className:"min-w-72!",onCloseAutoFocus:l=>{r.current&&(r.current.focus(),r.current=null,l.preventDefault())},children:e.jsxs(La,{children:[e.jsxs(Ht,{children:["Workspaces (",s.data.length,")"]}),s.data.map(l=>{var c;return e.jsx(Se,{onClick:()=>n.push(o.dashboard(l.id)),children:e.jsxs("div",{className:"flex w-full items-center gap-x-2.5",children:[l.logoFile?e.jsx(ze,{src:l.logoFile.url,alt:l.name,width:28,height:28,className:"flex aspect-square size-7 items-center justify-center rounded"}):e.jsxs("span",{className:"flex aspect-square size-7 items-center justify-center rounded bg-blue-600 p-2 text-xs font-medium text-white dark:bg-blue-500 uppercase","aria-hidden":"true",children:[l.name[0],l.name[1]]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-50",children:l.name}),e.jsx("p",{className:"text-xs text-gray-700 dark:text-gray-400",children:(c=l.address)==null?void 0:c.addressLineOne})]})]})},l.id)})]})})]})};function Ln({children:a,align:t="start"}){var p,g;const r=D.useRouter(),[s,i]=z.useState(!1),{theme:n,setTheme:o}=xs.useTheme(),l=Ja(),c=$(),m=l.useSession();z.useEffect(()=>{i(!0)},[]);const u=()=>l.signOut({fetchOptions:{onSuccess:()=>r.push(c.signIn)}});return s?e.jsx(e.Fragment,{children:e.jsxs(ra,{children:[e.jsx(sa,{asChild:!0,children:a}),e.jsxs(ia,{align:t,children:[e.jsx(Ht,{children:(g=(p=m.data)==null?void 0:p.user)==null?void 0:g.email}),e.jsx(La,{children:e.jsxs(hn,{children:[e.jsx(fn,{children:"Theme"}),e.jsx(yn,{children:e.jsxs(xn,{value:n,onValueChange:x=>{o(x)},children:[e.jsxs(nt,{"aria-label":"Switch to Light Mode",value:"light",iconType:"check",children:[e.jsx(M.RiSunLine,{className:"size-4 shrink-0","aria-hidden":"true"}),"Light"]}),e.jsxs(nt,{"aria-label":"Switch to Dark Mode",value:"dark",iconType:"check",children:[e.jsx(M.RiMoonLine,{className:"size-4 shrink-0","aria-hidden":"true"}),"Dark"]}),e.jsxs(nt,{"aria-label":"Switch to System Mode",value:"system",iconType:"check",children:[e.jsx(M.RiComputerLine,{className:"size-4 shrink-0","aria-hidden":"true"}),"System"]})]})}),e.jsx(La,{children:e.jsx(Se,{onClick:u,className:"text-red-500",children:"Sign out"})})]})})]})]})}):null}const du=()=>{var s;const a=Ja().useSession(),{firstname:t,lastname:r}=((s=a.data)==null?void 0:s.user)||{};return e.jsx(Ln,{children:e.jsxs(R,{"aria-label":"User settings",variant:"ghost",className:U(Ae,"group flex w-full items-center justify-between rounded-md p-2 text-sm font-medium text-gray-900 hover:bg-gray-100 data-[state=open]:bg-gray-100 data-[state=open]:bg-gray-400/10 dark:hover:bg-gray-400/10"),children:[e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-full border border-gray-300 bg-white text-xs text-gray-700 dark:border-gray-800 dark:bg-gray-950 dark:text-gray-300","aria-hidden":"true",children:[t==null?void 0:t.charAt(0),r==null?void 0:r.charAt(0)]}),e.jsxs("span",{children:[t," ",r]})]}),e.jsx(M.RiMore2Fill,{className:"size-4 shrink-0 text-gray-500 group-hover:text-gray-700 dark:group-hover:text-gray-400","aria-hidden":"true"})]})})},cu=()=>e.jsx(Ln,{align:"end",children:e.jsx(R,{"aria-label":"User settings",variant:"ghost",className:U("group flex items-center rounded-md p-1 text-sm font-medium text-gray-900 hover:bg-gray-100 data-[state=open]:bg-gray-100 data-[state=open]:bg-gray-400/10 dark:hover:bg-gray-400/10"),children:e.jsx("span",{className:"flex size-7 shrink-0 items-center justify-center rounded-full border border-gray-300 bg-white text-xs text-gray-700 dark:border-gray-800 dark:bg-gray-950 dark:text-gray-300","aria-hidden":"true",children:"ES"})})});function mu(){const a=D.usePathname(),t=_(),r=$(),s=[{name:"Home",href:r.dashboard(t),icon:N.HomeIcon},{name:"Live Orders",href:r.liveOrders(t),icon:N.RadioIcon},{name:"Orders List",href:r.orders(t),icon:N.LogsIcon},{name:"Reservations",href:r.reservations(t),icon:N.CalendarCheckIcon},{name:"Products",href:r.products(t),icon:N.PackageIcon},{name:"Product Categories",href:r.productCategories(t),icon:N.BoxesIcon},{name:"Manufacturers",href:r.manufacturers(t),icon:N.FactoryIcon},{name:"Customers",href:`${r.dashboard(t)}/customers`,icon:N.UserCircleIcon},{name:"Settings",href:r.settings(t),icon:M.RiSettings5Line}],i=n=>a===n||(a==null?void 0:a.startsWith(n));return e.jsxs(e.Fragment,{children:[e.jsx("nav",{className:"hidden lg:fixed lg:inset-y-0 lg:z-50 lg:flex lg:w-72 lg:flex-col",children:e.jsxs("aside",{className:"flex grow flex-col gap-y-6 overflow-y-auto border-r border-gray-200 bg-slate-50 p-4 dark:border-gray-800 dark:bg-gray-950",children:[e.jsx(B,{href:r.home,className:"-ml-2",children:e.jsx(su,{})}),e.jsx("hr",{className:"block border-t border-gray-200 dark:border-gray-800 -mt-3 mb-1"}),e.jsx(ou,{}),e.jsx("nav",{"aria-label":"core navigation links",className:"flex flex-1 flex-col space-y-10",children:e.jsx("ul",{role:"list",className:"space-y-0.5",children:s.map(n=>e.jsx("li",{children:e.jsxs(B,{href:n.href,className:v(i(n.href)?"text-blue-600 dark:text-blue-400":"text-gray-700 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-50","flex items-center gap-x-2.5 rounded-md px-2 py-1.5 text-sm font-medium transition hover:bg-gray-100 dark:hover:bg-gray-900",Ae),children:[e.jsx(n.icon,{className:"size-4 shrink-0","aria-hidden":"true"}),n.name]})},n.name))})}),e.jsx("div",{className:"mt-auto",children:e.jsx(du,{})})]})}),e.jsxs("div",{className:"sticky top-0 z-40 flex h-16 shrink-0 items-center justify-between border-b border-gray-200 bg-white px-2 shadow-xs sm:gap-x-6 sm:px-4 lg:hidden dark:border-gray-800 dark:bg-gray-950",children:[e.jsx(lu,{}),e.jsxs("div",{className:"flex items-center gap-1 sm:gap-2",children:[e.jsx(cu,{}),e.jsx(nu,{})]})]})]})}function uu({children:a,view:t}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bg-slate-50 dark:hidden w-1/2 absolute top-0 left-0 h-screen"}),e.jsxs("div",{className:"mx-auto max-w-(--breakpoint-2xl)",children:[e.jsx(mu,{}),e.jsx("main",{className:"lg:pl-72 bg-white dark:bg-gray-950 z-10 relative min-h-screen",children:e.jsx("div",{className:"relative",children:e.jsxs("div",{className:"p-4 sm:px-6 sm:pb-10 sm:pt-10 lg:px-10 lg:pt-[34px]",children:[e.jsx(ru,{view:t}),a]})})})]})]})}function pu(a){if(a.length===0)return{type:"home"};const[t,r,s,i,n]=a;if(t==="auth")return r==="sign-in"?{type:"sign-in"}:r==="sign-up"?{type:"sign-up"}:{type:"not-found"};if(t==="organizations")return{type:"organizations"};const o=t;return r?r==="dashboard"?{type:"dashboard",orgId:o}:r==="orders"?{type:"orders",orgId:o}:r==="reservations"?{type:"reservations",orgId:o}:r==="products"?s?s==="create"?{type:"product-create",orgId:o}:{type:"product-edit",orgId:o,id:s}:{type:"products-list",orgId:o}:r==="product-categories"?s?s==="create"?{type:"product-category-create",orgId:o}:{type:"product-category-edit",orgId:o,id:s}:{type:"product-categories-list",orgId:o}:r==="manufacturers"?s?s==="create"?{type:"manufacturer-create",orgId:o}:{type:"manufacturer-edit",orgId:o,id:s}:{type:"manufacturers-list",orgId:o}:r==="settings"?s?s==="integrations"?i?i==="create"?{type:"settings-integrations-create",orgId:o}:{type:"settings-integration",orgId:o,id:i}:{type:"settings-integrations",orgId:o}:s==="opening-times"?{type:"settings-opening-times",orgId:o}:s==="shipping-methods"?i?i==="create"?{type:"shipping-method-create",orgId:o}:{type:"shipping-method-edit",orgId:o,id:i}:{type:"shipping-methods-list",orgId:o}:s==="access"?i?i==="invite"?{type:"access-invite",orgId:o}:{type:"access-member-edit",orgId:o,id:i}:{type:"access-list",orgId:o}:{type:"settings",orgId:o}:{type:"settings",orgId:o}:{type:"not-found"}:{type:"not-found"}}function gu({segments:a}){const t=Ja(),r=$(),s=D.useRouter(),i=D.usePathname(),n=D.useSearchParams(),{data:o,isPending:l}=t.useSession(),c=pu(a),m=c.type==="sign-in"||c.type==="sign-up",u=c.type==="home"||c.type==="organizations",p=n==null?void 0:n.get("redirect"),g=n==null?void 0:n.toString(),x=i?`${i}${g?`?${g}`:""}`:r.home,y=m?Vt(p,r):x;if(h.useEffect(()=>{if(!l){if(!o&&!m){s.replace(fr(r.signIn,y));return}o&&m&&s.replace(y)}},[o,l,m,s,r.signIn,y]),l)return e.jsx("div",{className:"flex justify-center items-center h-screen",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600"})});if(m){if(c.type==="sign-in")return e.jsx(Od,{});if(c.type==="sign-up")return e.jsx(Jd,{})}if(!o)return null;if(u)return e.jsx(ns,{children:e.jsx(Lc,{})});if(c.type==="not-found")return e.jsx(xr,{});const j="orgId"in c?c.orgId:void 0,f="id"in c?c.id:void 0;return e.jsx(Ed,{organizationId:j,id:f,children:e.jsx(ns,{children:e.jsx(Fd,{children:e.jsx(uu,{view:c,children:hu(c)})})})})}function hu(a){switch(a.type){case"dashboard":return e.jsx(Kd,{});case"orders":return e.jsx(Tc,{});case"reservations":return e.jsx(Nm,{});case"products-list":return e.jsx(mm,{});case"product-create":return e.jsx(im,{});case"product-edit":return e.jsx(nm,{});case"product-categories-list":return e.jsx(Kc,{});case"product-category-create":return e.jsx(Xc,{});case"product-category-edit":return e.jsx(Yc,{});case"manufacturers-list":return e.jsx(Cc,{});case"manufacturer-create":return e.jsx(pc,{});case"manufacturer-edit":return e.jsx(gc,{});case"settings":return e.jsx(Me,{children:e.jsx(au,{})});case"settings-opening-times":return e.jsx(Me,{children:e.jsx(_m,{})});case"settings-integrations":return e.jsx(Me,{children:e.jsx(Hm,{})});case"settings-integrations-create":return e.jsx(Me,{children:e.jsx(Rm,{})});case"settings-integration":return e.jsx(Me,{children:e.jsx(Lm,{})});case"shipping-methods-list":return e.jsx(Me,{children:e.jsx(Xm,{})});case"shipping-method-create":return e.jsx(Me,{children:e.jsx($m,{})});case"shipping-method-edit":return e.jsx(Me,{children:e.jsx(Wm,{})});case"access-list":return e.jsx(Me,{children:e.jsx(Im,{})});case"access-invite":return e.jsx(Me,{children:e.jsx(Cm,{})});case"access-member-edit":return e.jsx(Me,{children:e.jsx(Em,{})});default:return e.jsx(xr,{})}}exports.APIProvider=rr,exports.AccountHomePage=Vi,exports.AccountPages=ld,exports.AdminProvider=no,exports.AdminRouter=gu,exports.Badge=pr,exports.Button=te,exports.CartDrawer=Do,exports.CartDrawerItem=Hs,exports.CartItems=qs,exports.CartPanel=Us,exports.CartProvider=Ts,exports.CheckoutPages=cd,exports.Command=Ua,exports.CommandBar=Ii,exports.CommandBarBar=Di,exports.CommandBarCommand=Fi,exports.CommandBarSeperator=Ri,exports.CommandBarValue=Ei,exports.CommandDialog=Sl,exports.CommandEmpty=Pt,exports.CommandGroup=Bt,exports.CommandInput=Ft,exports.CommandItem=Tt,exports.CommandList=Mt,exports.CommandSeparator=gi,exports.CommandShortcut=hi,exports.CountryInput=yi,exports.CustomerDetailsPage=Xt,exports.Dialog=Dt,exports.DialogClose=li,exports.DialogContent=Rt,exports.DialogDescription=ui,exports.DialogFooter=pi,exports.DialogHeader=mi,exports.DialogTitle=cr,exports.DialogTrigger=oi,exports.Divider=ja,exports.EmailInput=bi,exports.ErrorView=xr,exports.ImageUploadInput=ji,exports.Input=Ci,exports.InputGroup=Ne,exports.Label=Re,exports.LocationInput=Qt,exports.ModifierContainer=Ui,exports.ModifiersDialog=ud,exports.ModifiersGroup=Zi,exports.ModifiersModal=gd,exports.ModifiersOption=_i,exports.PhoneNumberInput=ki,exports.Popover=Na,exports.PopoverAnchor=xi,exports.PopoverClose=fi,exports.PopoverContent=Ca,exports.PopoverTrigger=Aa,exports.QuantityControl=pd,exports.RadioCardGroup=mt,exports.RadioCardGroupIndicator=ut,exports.RadioCardItem=pt,exports.SelectInput=Ni,exports.ShippingAndPaymentPage=Pi,exports.ShophostProvider=Sd,exports.SliderOver=zi,exports.Switch=mr,exports.TextInput=De,exports.TimeInput=ur,exports.badgeVariants=Mi,exports.buttonVariants=ni,exports.calculateCartTotal=Rs,exports.createAdminAuthClient=Is,exports.createRoutes=Ds,exports.findCartItem=Fs,exports.formatPrice=we,exports.getAdminAuthClient=Es,exports.getFieldError=Si,exports.getFormattedModifiers=lo,exports.mockProducts=fd,exports.productRequiresModifiers=mo,exports.useAPI=P,exports.useCart=kt,exports.useCartContext=Va,exports.useLocalization=Qs,exports.useModifierSelection=Os,exports.useModifiers=Ha,exports.useMultipleProductDetails=xd,exports.useOrganization=ve,exports.useProductDetails=hd;
|
|
2
|
+
"use strict";const e=require("react/jsx-runtime"),A=require("@tanstack/react-query"),ws=require("next-themes"),x=require("react"),J=require("react-hot-toast"),dt=require("better-auth/client/plugins"),ks=require("better-auth/react"),U=require("react-hook-form"),N=require("lucide-react"),Ns=require("@vercel/blob/client"),Ie=require("next/image.js"),Ke=require("use-debounce"),w=require("classnames"),Yn=require("use-mask-input"),va=require("@headlessui/react"),P=require("@remixicon/react"),B=require("next/link.js"),E=require("next/navigation.js"),fe=require("@hookform/resolvers/zod"),I=require("date-fns"),eo=require("@shophost/client"),d=require("@hono/zod-openapi"),tr=require("@radix-ui/react-slot"),Le=require("tailwind-variants"),As=require("clsx"),Cs=require("tailwind-merge"),ao=require("@radix-ui/react-label"),to=require("@radix-ui/react-dialog"),Se=require("@tanstack/react-table"),ro=require("@radix-ui/react-popover"),ae=require("recharts"),he=require("@internationalized/date"),Ss=require("@react-aria/datepicker"),so=require("@react-stately/datepicker"),io=require("date-fns/locale"),Oa=require("react-day-picker"),G=require("cmdk"),no=require("react-phone-number-input"),zs=require("react-phone-number-input/flags"),oo=require("@radix-ui/react-switch"),lo=require("@radix-ui/react-radio-group"),co=require("tailwindcss/colors"),mo=require("@radix-ui/react-navigation-menu"),uo=require("@radix-ui/react-checkbox"),po=require("@radix-ui/react-dropdown-menu"),go=require("@radix-ui/react-select"),Ye=require("zod");function Qe(a){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const r in a)if(r!=="default"){const s=Object.getOwnPropertyDescriptor(a,r);Object.defineProperty(t,r,s.get?s:{enumerable:!0,get:()=>a[r]})}}return t.default=a,Object.freeze(t)}const z=Qe(x),Is=Qe(ao),re=Qe(to),ie=Qe(ro),Nt=Qe(no),ct=Qe(oo),rr=Qe(lo),mt=Qe(mo),_r=Qe(uo),be=Qe(po),me=Qe(go),oe=new A.QueryClient({defaultOptions:{queries:{retry:!1,refetchInterval:!1,refetchOnWindowFocus:!1}}}),Es=x.createContext(null),sr=({baseUrl:a,children:t})=>{const r=x.useMemo(()=>eo.initClient({baseUrl:a,throwOnUnknownStatus:!0,baseHeaders:{},credentials:"include"}),[a]);return e.jsx(Es.Provider,{value:{client:r,baseUrl:a},children:t})},M=()=>{const a=x.useContext(Es);if(!a)throw new Error("useAPI must be used within a APIProvider");return a},Ds=x.createContext(null),ho=({client:a,children:t})=>e.jsx(Ds.Provider,{value:a,children:t});function qa(){const a=x.useContext(Ds);if(!a)throw new Error("useAdminAuth must be used within AdminProvider");return a}const Rs=x.createContext(null),xo=({config:a,children:t})=>e.jsx(Rs.Provider,{value:a,children:t});function Fs(){const a=x.useContext(Rs);if(!a)throw new Error("useAdminConfig must be used within AdminProvider");return a}const Ms=x.createContext(null),fo=({routes:a,children:t})=>e.jsx(Ms.Provider,{value:a,children:t});function _(){const a=x.useContext(Ms);if(!a)throw new Error("useAdminRoutes must be used within AdminProvider");return a}function Ps(a){return ks.createAuthClient({baseURL:a,plugins:[dt.inferAdditionalFields(),dt.organizationClient()]})}const Wt=new Map;function Bs(a){return Wt.has(a)||Wt.set(a,Ps(a)),Wt.get(a)}function Ts(a){const t=a.replace(/\/$/,"");return{home:t,signIn:`${t}/auth/sign-in`,signUp:`${t}/auth/sign-up`,organizations:`${t}/organizations`,dashboard:r=>`${t}/${r}/dashboard`,liveOrders:r=>`${t}/${r}/live-orders`,orders:r=>`${t}/${r}/orders`,reservations:r=>`${t}/${r}/reservations`,customers:r=>`${t}/${r}/customers`,customerDetail:(r,s)=>`${t}/${r}/customers/${s}`,products:r=>`${t}/${r}/products`,productCreate:r=>`${t}/${r}/products/create`,productEdit:(r,s)=>`${t}/${r}/products/${s}`,productCategories:r=>`${t}/${r}/product-categories`,productCategoryCreate:r=>`${t}/${r}/product-categories/create`,productCategoryEdit:(r,s)=>`${t}/${r}/product-categories/${s}`,manufacturers:r=>`${t}/${r}/manufacturers`,manufacturerCreate:r=>`${t}/${r}/manufacturers/create`,manufacturerEdit:(r,s)=>`${t}/${r}/manufacturers/${s}`,settings:r=>`${t}/${r}/settings`,settingsIntegrations:r=>`${t}/${r}/settings/integrations`,settingsIntegrationsCreate:r=>`${t}/${r}/settings/integrations/create`,settingsIntegration:(r,s)=>`${t}/${r}/settings/integrations/${s}`,settingsOpeningTimes:r=>`${t}/${r}/settings/opening-times`,settingsShippingMethods:r=>`${t}/${r}/settings/shipping-methods`,settingsShippingMethodCreate:r=>`${t}/${r}/settings/shipping-methods/create`,settingsShippingMethodEdit:(r,s)=>`${t}/${r}/settings/shipping-methods/${s}`,settingsAccess:r=>`${t}/${r}/settings/access`,settingsAccessInvite:r=>`${t}/${r}/settings/access/invite`,settingsAccessMemberEdit:(r,s)=>`${t}/${r}/settings/access/${s}`}}function yo({config:a,children:t}){const r=x.useMemo(()=>Bs(a.apiBaseUrl),[a.apiBaseUrl]),s=x.useMemo(()=>Ts(a.basePath),[a.basePath]);return e.jsx(A.QueryClientProvider,{client:oe,children:e.jsxs("div",{className:"shophost-admin",children:[e.jsx(ws.ThemeProvider,{defaultTheme:"light",attribute:"class",children:e.jsx(sr,{baseUrl:a.apiBaseUrl,children:e.jsx(ho,{client:r,children:e.jsx(xo,{config:a,children:e.jsx(fo,{routes:s,children:t})})})})}),e.jsx(J.Toaster,{})]})})}const Wa="shophost-cart",bo={items:[],isInitialized:!1,modifierModal:null,totalAmount:0,itemCount:0,removedItemsAlert:!1},Qs=(a,t)=>a.reduce((r,s)=>{const i=t(s.productId);if(!i)return r;const n=s.quantity||1;let o=Number(i.discountedBasePrice??i.basePrice??0)*n;return s.modifierGroups&&s.modifierGroups.length>0&&s.modifierGroups.forEach(l=>{var m;const c=(m=i.modifierGroups)==null?void 0:m.find(u=>u.id===l.id);c&&l.modifiers.forEach(u=>{const p=c.modifiers.find(g=>g.id===u.id);if(p){const g=u.quantity||1;o+=Number(p.price??0)*g*n}})}),r+o},0),we=(a,t="USD",r="en-US")=>new Intl.NumberFormat(r,{style:"currency",currency:t}).format(a),jo=(a,t,r="en-US")=>{const s=t(a.productId);return!s||!a.modifierGroups||a.modifierGroups.length===0?"":a.modifierGroups.filter(i=>i&&i.modifiers).map(i=>{var c,m,u,p;const n=(c=s.modifierGroups)==null?void 0:c.find(g=>g&&g.id===i.id);if(!n||!n.modifiers)return"";const o=((u=(m=n.translations)==null?void 0:m.find(g=>g&&g.locale===r))==null?void 0:u.title)||(n.translations&&n.translations.length>0?(p=n.translations[0])==null?void 0:p.title:"")||"",l=(i.modifiers||[]).filter(g=>g).map(g=>{const h=n.modifiers.find(y=>y&&y.id===g.id);if(!h)return"";const f=h.title||"",b=g.quantity||1;return b>1?`${f} (${b})`:f}).filter(Boolean).join(", ");return o?`${o}: ${l}`:l}).filter(Boolean).join(" | ")},Os=(a,t,r)=>a.find(s=>ea(s,{productId:t,modifierGroups:r})),ea=(a,t)=>{if(a.productId!==t.productId)return!1;const r=t.modifierGroups??[],s=a.modifierGroups??[];return r.length===0?s.length===0:vo(s,r)},vo=(a,t)=>{if(a.length!==t.length)return!1;const r=[...t];return a.every(s=>{const i=r.findIndex(n=>{if(s.id!==n.id||s.modifiers.length!==n.modifiers.length)return!1;const o=[...n.modifiers];return s.modifiers.every(l=>{const c=o.findIndex(m=>l.id===m.id&&(l.quantity||1)===(m.quantity||1));return c>=0?(o.splice(c,1),!0):!1})});return i>=0?(r.splice(i,1),!0):!1})},wo=a=>!a.modifierGroups||a.modifierGroups.length===0?!1:a.modifierGroups.some(t=>t.selectMin>0),ko=(a,t)=>{var r,s,i;if(a.length===0)return{valid:!0};for(const n of a){const o=((r=t.find(u=>u.groupId===n.id))==null?void 0:r.modifierIds.length)||0,l=n.selectMin??0,c=n.selectMax??0,m=("title"in n?n.title:void 0)||("translations"in n?(i=(s=n.translations)==null?void 0:s[0])==null?void 0:i.title:void 0)||"Option";if(l>0&&o<l)return{valid:!1,message:`Please select at least ${l} ${m}`};if(c>0&&o>c)return{valid:!1,message:`You can select at most ${c} ${m}`}}return{valid:!0}},da=a=>a.reduce((t,r)=>t+(r.quantity||1),0),No=(a,t)=>a.findIndex(r=>ea(r,{productId:t.productId,modifierGroups:t.modifierGroups})),Ao=(a,t,r)=>a.map(s=>ea(s,t)?{...s,quantity:r}:s),Co=(a,t)=>a.filter(r=>!ea(r,t)),So=(a,t)=>{const r=No(a,t);return r===-1?[...a,t]:a.map((s,i)=>i===r?{...s,quantity:(s.quantity||1)+(t.quantity||1)}:s)},zo=(a,t)=>!a.modifierGroups||a.modifierGroups.length===0?!0:!t.modifierGroups||t.modifierGroups.length===0?!1:a.modifierGroups.every(r=>{var i;const s=(i=t.modifierGroups)==null?void 0:i.find(n=>n.id===r.id);return s?r.modifiers.every(n=>{var o;return!!((o=s.modifiers)!=null&&o.find(l=>l.id===n.id))}):!1}),Ls=(a,t)=>{switch(t.type){case"INITIALIZE_CART":{const r=t.payload;return{...a,items:r,itemCount:da(r)}}case"REPLACE_ITEMS":{const r=t.payload;return{...a,items:r,itemCount:da(r)}}case"SET_INITIALIZED":return{...a,isInitialized:t.payload};case"ADD_ITEM":{const r=So(a.items,t.payload);return{...a,items:r,itemCount:da(r)}}case"UPDATE_ITEM_QUANTITY":{const{productId:r,quantity:s,modifierGroups:i}=t.payload;if(s<=0)return Ls(a,{type:"REMOVE_ITEM",payload:{productId:r,modifierGroups:i}});const n=Ao(a.items,{productId:r,modifierGroups:i},s);return{...a,items:n,itemCount:da(n)}}case"REMOVE_ITEM":{const r=Co(a.items,t.payload);return{...a,items:r,itemCount:da(r)}}case"CLEAR_CART":return{...a,items:[],itemCount:0,totalAmount:0};case"OPEN_MODIFIERS_MODAL":return{...a,modifierModal:t.payload};case"CLOSE_MODIFIERS_MODAL":return{...a,modifierModal:null};case"UPDATE_TOTALS":{const{productsData:r}=t.payload,s=a.items.reduce((i,n)=>{const o=r[n.productId];if(!o)return i;const l=Number(o.discountedBasePrice??o.basePrice??0);return i+l*(n.quantity||1)},0);return{...a,totalAmount:s}}case"REMOVE_UNAVAILABLE_PRODUCTS":{const{productsData:r,showAlert:s}=t.payload,i=a.items.length,n=a.items.filter(l=>{const c=r[l.productId];return c?zo(l,c):!1}),o=n.length<i;return{...a,items:n,itemCount:da(n),removedItemsAlert:!!(s&&o)}}case"REMOVE_INVALID_PRODUCTS":{const{invalidProductIds:r}=t.payload,s=a.items.filter(i=>!r.includes(i.productId));return{...a,items:s,itemCount:da(s)}}default:return a}};function Js(a,t,r,s){const i=Number(t.discountedBasePrice??t.basePrice??0),n=we((a.quantity||1)*i,r,s),o=a.modifierGroups?a.modifierGroups.map(c=>{const m=t.modifierGroups.find(p=>p.id===c.id);if(!m)return null;const u=c.modifiers.map(p=>{var h;const g=(h=m.modifiers)==null?void 0:h.find(f=>f.id===p.id);return g?g.title:""}).filter(Boolean).join(", ");return u?`${m.title}: ${u}`:null}).filter(Boolean):[],l=t.images&&t.images.length>0?t.images[0]:void 0;return{title:t.title??t.slug??"Untitled product",subtitle:o,image:l,price:n,unitPrice:we(i,r,s),quantity:a.quantity||1}}const Vs=x.createContext(void 0),Io=({children:a,initialOrganization:t,organizationId:r})=>{const{client:s}=M(),i=A.useQuery({queryKey:["organization",r],queryFn:async()=>{const n=await s.organization.getOrganization({params:{organizationId:r}});if(n.status!==200)throw new Error("Failed to fetch product data");return n.body},initialData:t??void 0,placeholderData:A.keepPreviousData,enabled:!!r});return e.jsx(Vs.Provider,{value:{organizationId:r,loading:i.isLoading,organization:i.data,error:i.error},children:a})},ke=()=>{const a=x.useContext(Vs);if(a===void 0)throw new Error("useOrganization must be used within a OrganizationProvider");return a},ir=x.createContext(void 0),ya=a=>a.map(t=>({...t,modifierGroups:t.modifierGroups??[],quantity:t.quantity||1})),Eo=()=>typeof window>"u"?!1:new URLSearchParams(window.location.search).get("clearCart")==="true",Do=(a,t)=>t.length>0?"Some items were removed from your cart because they are no longer available.":a.some(r=>r.reason==="out_of_stock")?"We updated your cart because some items are now out of stock.":a.some(r=>r.reason==="insufficient_stock")?"We reduced some item quantities in your cart because stock changed.":"We updated your cart because availability changed.",Ro=350,Fe={adjustments:[],invalidProductIds:[],normalizedItems:[],products:{},shipping:void 0,subtotal:0,total:0},qs=({children:a,locale:t="en",organizationId:r})=>{const{organization:s}=ke(),i=s==null?void 0:s.configuration.defaultCurrency,{client:n}=M(),[o,l]=x.useState(null),[c,m]=x.useState(null),[{items:u,isInitialized:p,modifierModal:g,totalAmount:h,itemCount:f},b]=x.useReducer(Ls,bo),y=g!==null,j=(g==null?void 0:g.product)??null,v=(g==null?void 0:g.quantity)??1,k=g==null?void 0:g.onAdded,[C,F]=x.useState(Fe),[T,O]=x.useState(!1),R=x.useRef(u),S=x.useRef(0),Q=x.useRef(null),W=x.useRef(null),ye=x.useRef(void 0),Ve=x.useRef([]);x.useEffect(()=>{R.current=u},[u]);const ue=x.useCallback(L=>{b({type:"REPLACE_ITEMS",payload:ya(L)})},[]),oa=x.useCallback((L,q)=>{F(L);const K=ya(L.normalizedItems),ve=JSON.stringify(K),ge=JSON.stringify(ya(R.current)),He=L.adjustments.length>0||L.invalidProductIds.length>0;return ve!==ge&&ue(K),He&&(q==null?void 0:q.showAlert)!==!1&&alert(Do(L.adjustments,L.invalidProductIds)),L},[ue]),Ce=x.useCallback(()=>{Q.current&&(clearTimeout(Q.current),Q.current=null)},[]),X=x.useCallback(L=>{const q=Ve.current;Ve.current=[],q.forEach(({resolve:K})=>K(L))},[]),Y=x.useCallback(L=>{const q=Ve.current;Ve.current=[],q.forEach(({reject:K})=>K(L))},[]),ce=x.useCallback(async(L,q)=>{Ce(),W.current=null,ye.current=void 0;const K=ya(L);if(K.length===0)return F(Fe),ue([]),X(Fe),Fe;const ve=++S.current;O(!0);try{const ge=await n.cart.getCartData({params:{organizationId:r},query:{locale:t},body:{items:K,shippingMethodId:c==null?void 0:c.id}});if(ge.status!==200)throw new Error("Failed to sync cart");const He=ve===S.current?oa(ge.body,{showAlert:q==null?void 0:q.showAdjustmentAlert}):ge.body;return X(He),He}catch(ge){throw Y(ge),ge}finally{ve===S.current&&O(!1)}},[oa,Ce,n.cart,t,r,ue,X,Y,c==null?void 0:c.id]),fa=x.useCallback((L,q)=>{const K=ya(L);return K.length===0?(Ce(),W.current=null,ye.current=void 0,F(Fe),ue([]),X(Fe),Promise.resolve(Fe)):(W.current=K,ye.current=q,new Promise((ve,ge)=>{Ve.current.push({resolve:ve,reject:ge}),Ce(),Q.current=setTimeout(()=>{Q.current=null;const He=W.current??[],la=ye.current;W.current=null,ye.current=void 0,ce(He,la).catch(()=>{})},Ro)}))},[Ce,ue,X,ce]);x.useEffect(()=>{(()=>{if(Eo()){localStorage.removeItem(Wa),F(Fe),b({type:"INITIALIZE_CART",payload:[]}),b({type:"SET_INITIALIZED",payload:!0});return}const L=localStorage.getItem(Wa);if(L)try{const q=JSON.parse(L);b({type:"INITIALIZE_CART",payload:q})}catch(q){console.error("Failed to parse cart from localStorage:",q)}b({type:"SET_INITIALIZED",payload:!0})})()},[]),x.useEffect(()=>{p&&localStorage.setItem(Wa,JSON.stringify(u))},[u,p]),x.useEffect(()=>()=>{Ce()},[Ce]),x.useEffect(()=>{if(p){if(R.current.length===0){F(Fe);return}ce(R.current,{showAdjustmentAlert:!1}).catch(L=>{console.error("Failed to hydrate cart data:",L)})}},[p,c==null?void 0:c.id,ce]),x.useEffect(()=>{b({type:"UPDATE_TOTALS",payload:{productsData:C.products}})},[u,C]);const ee=x.useCallback(L=>{const q=ya(L);ue(q),ce(q,{showAdjustmentAlert:!1}).catch(K=>{console.error("Failed to replace cart items:",K)})},[ue,ce]),Ee=x.useCallback(async(L,q)=>{const K={...L,modifierGroups:L.modifierGroups??[],quantity:L.quantity||1},ve=Os(R.current,K.productId,K.modifierGroups)?R.current.map(ge=>ea(ge,{productId:K.productId,modifierGroups:K.modifierGroups})?{...ge,quantity:(ge.quantity||1)+(K.quantity||1)}:ge):[...R.current,K];return ue(ve),ce(ve,q)},[ue,ce]),Ge=x.useCallback(async(L,q,K,ve)=>{const ge=R.current,He=q<=0?ge.filter(la=>!ea(la,{productId:L,modifierGroups:K})):ge.map(la=>ea(la,{productId:L,modifierGroups:K})?{...la,quantity:q}:la);return ue(He),fa(He,ve)},[ue,fa]),Lr=x.useCallback((L,q)=>{const K=R.current.filter(ve=>!ea(ve,{productId:L,modifierGroups:q}));ue(K),fa(K,{showAdjustmentAlert:!1}).catch(ve=>{console.error("Failed to remove cart item:",ve)})},[ue,fa]),Jr=x.useCallback(()=>{Ce(),W.current=null,ye.current=void 0,X(Fe),localStorage.removeItem(Wa),F(Fe),b({type:"CLEAR_CART"})},[Ce,X]),Vr=x.useCallback(()=>{console.log("Checkout clicked, implement onCheckout handler")},[]),qr=x.useCallback((L,q)=>{const K={product:L,quantity:(q==null?void 0:q.quantity)??1,onAdded:q==null?void 0:q.onAdded};b({type:"OPEN_MODIFIERS_MODAL",payload:K})},[]),Hr=x.useCallback(()=>{b({type:"CLOSE_MODIFIERS_MODAL"})},[]),qe=C.products,$t=C.shipping,_t=x.useMemo(()=>Qs(u,L=>qe[L]),[u,qe]),Ur=_t+($t??0),Zr=!p||u.length>0&&(!Object.keys(qe).length||T&&u.some(L=>qe[L.productId]===void 0)),$r=x.useMemo(()=>Object.keys(qe).length?u.map(L=>{const q=qe[L.productId];return q?Js(L,q,i??"USD",t):null}).filter(L=>L!==null):[],[i,u,t,qe]),Xn=x.useMemo(()=>({locale:t,organizationId:r,items:u,total:Ur,shipping:$t,subtotal:_t,products:qe,addItem:Ee,removeItem:Lr,updateItemQuantity:Ge,clearCart:Jr,itemCount:f,totalAmount:h,replaceItems:ee,onCheckoutClick:Vr,openModifiersModal:qr,closeModifiersModal:Hr,modifierModal:g,isModifiersModalOpen:y,selectedProduct:j,pendingModalQuantity:v,onModalAddToCart:k,isProductsLoading:Zr,paymentMethod:o,setPaymentMethod:l,shippingMethod:c,setShippingMethod:m,formattedCartItems:$r}),[t,r,u,Ur,$t,_t,qe,Ee,Lr,Ge,Jr,f,h,ee,Vr,qr,Hr,g,y,j,v,k,Zr,o,l,c,m,$r]);return e.jsx(ir.Provider,{value:Xn,children:a})},At=()=>{const a=x.useContext(ir),{client:t}=M();if(a===void 0)throw new Error("useCart must be used within a CartProvider");const r=x.useCallback(async(l,c)=>{if(c)return c;const m=a.products[l];if(m)return m;const u=await t.product.getProduct({params:{organizationId:a.organizationId,id:l},query:{locale:a.locale}});if(u.status!==200||!u.body)throw new Error(`Failed to fetch product ${l}`);return u.body},[t.product,a.locale,a.organizationId,a.products]),s=x.useCallback(async({productId:l,quantity:c=1,modifierGroups:m,product:u,onAdded:p})=>{var f;const g=(b=m??[])=>a.addItem({productId:l,quantity:c,modifierGroups:b}).then(()=>(p==null||p(),{openedModifiers:!1}));if(m!=null&&m.length)return g(m);const h=await r(l,u);return(f=h.modifierGroups)!=null&&f.length?(a.openModifiersModal(h,{onAdded:p,quantity:c}),{openedModifiers:!0}):g()},[a,r]),i=x.useCallback(({productId:l,quantity:c,modifierGroups:m})=>a.updateItemQuantity(l,c,m),[a]),n=x.useCallback(({productId:l,modifierGroups:c})=>{a.removeItem(l,c)},[a]),o=x.useCallback(l=>s({productId:l.id,product:l}),[s]);return{items:a.items,total:a.total,subtotal:a.subtotal,shipping:a.shipping,loading:a.isProductsLoading,formattedCartItems:a.formattedCartItems,add:s,update:i,remove:n,addProductToCart:o,clearCart:a.clearCart,itemCount:a.itemCount,rawCart:a.items,onCheckoutClick:a.onCheckoutClick,totalAmount:a.totalAmount,paymentMethod:a.paymentMethod,setPaymentMethod:a.setPaymentMethod,shippingMethod:a.shippingMethod,setShippingMethod:a.setShippingMethod,replaceItems:a.replaceItems}},Ha=()=>{const a=x.useContext(ir);if(a===void 0)throw new Error("useCart must be used within a CartProvider");return a},Hs=(a="en")=>{const[t,r]=x.useState(a),s=x.useCallback((c,m,u="")=>{if(!c||c.length===0)return u;const p=c.find(h=>h.locale===t);if(p&&p[m])return p[m];const g=c[0];return g&&g[m]?g[m]:u},[t]),i=x.useCallback((c,m="Product")=>s(c==null?void 0:c.translations,"title",m),[s]),n=x.useCallback((c,m="")=>s(c==null?void 0:c.translations,"description",m),[s]),o=x.useCallback((c,m="Category")=>s(c==null?void 0:c.translations,"title",m),[s]),l=x.useCallback((c,m="Options")=>c.title,[s]);return{locale:t,setLocale:r,getTranslation:s,getProductName:i,getProductDescription:n,getCategoryName:o,getModifierGroupName:l}},Fo=a=>a.map(t=>({groupId:t.id,modifierIds:[]})),Wr=(a,t,r)=>{const s=a.findIndex(i=>i.groupId===t);return s===-1?[...a,{groupId:t,modifierIds:r([])}]:a.map((i,n)=>n===s?{...i,modifierIds:r(i.modifierIds)}:i)},Us=(a=[])=>{const[t,r]=x.useState([]),[s,i]=x.useState(null);x.useEffect(()=>{r(Fo(a)),i(null)},[a]);const n=x.useCallback((p,g)=>{r(h=>Wr(h,p,f=>f.includes(g)?f.filter(b=>b!==g):[...f,g])),i(null)},[]),o=x.useCallback((p,g)=>{r(h=>Wr(h,p,()=>[g])),i(null)},[]),l=x.useCallback((p,g)=>{const h=t.find(f=>f.groupId===p);return h?h.modifierIds.includes(g):!1},[t]),c=x.useCallback(()=>{const p=ko(a,t);return!p.valid&&p.message?i(p.message):i(null),p.valid},[a,t]),m=x.useMemo(()=>t.filter(p=>p.modifierIds.length>0).map(p=>({id:p.groupId,modifiers:p.modifierIds.map(g=>({id:g,quantity:1}))})),[t]),u=x.useCallback(()=>m,[m]);return{selections:t,toggleModifier:n,selectModifier:o,isModifierSelected:l,validateSelections:c,validationError:s,getCartModifierGroups:u}},Mo={common:{cart:"Cart",checkout:"Checkout",products:"Products",home:"Home",search:"Search",loading:"Loading...",add:"Add",remove:"Remove",close:"Close",back:"Back",next:"Next",continue:"Continue",submit:"Submit",cancel:"Cancel",apply:"Apply",save:"Save",aboutUs:"About Us",ourStory:"Our Story",menu:"Menu",reservations:"Reservations",orderOnline:"Order Online",checkOurMenu:"Check Our Menu",privacyPolicy:"Privacy Policy",termsAndConditions:"Terms and Conditions",orderNow:"Order Now",makeReservation:"Make a Reservation"},product:{addToCart:"Add to cart",outOfStock:"Out of stock",stockAdjusted:"We adjusted the quantity to match current stock.",quantity:"Quantity",price:"Price",total:"Total",description:"Description",options:"Options",modifiers:"Modifiers"},checkout:{yourOrder:"Your Order",orderSummary:"Order Summary",delivery:"Delivery",address:"Address",payment:"Payment",confirmation:"Confirmation",deliveryDetails:"Delivery Details",paymentMethod:"Payment Method",placeOrder:"Place Order",subtotal:"Subtotal",total:"Total"},ourStory:{title:"Our Story",subtitle:"From the shores of South India to the heart of Poland – authentic flavors, unforgettable experiences",by:"By",paragraph1:"When Madras Bistro opened its doors in 2018, it marked a historic moment as Poland's first authentic South Indian restaurant. Our journey began with a simple yet profound vision: to introduce the rich, vibrant flavors of South India to the Polish culinary landscape.",paragraph2:"Our founders, inspired by their deep roots in Tamil Nadu, embarked on this venture after noticing that while North Indian cuisine had found its place in Poland, the diverse and distinctive flavors of South India remained undiscovered territory. They dreamed of creating a space where the aromatic spices, coconut-infused curries, and delicate dosas of their homeland could be experienced in their authentic form.",paragraph3:"The path wasn't always easy. Sourcing traditional ingredients, perfecting recipes that stayed true to their South Indian origins while appealing to Polish palates, and educating diners about a cuisine so different from what they knew – these were challenges we embraced with passion. Our chefs, trained in the time-honored techniques of South Indian cooking, worked tirelessly to ensure every dish that left our kitchen carried the essence of the regions they represented.",paragraph4:"Today, Madras Bistro stands as a cultural bridge between Poland and South India. We take pride in having introduced countless Polish diners to the joy of breaking a crispy dosa, savoring the complex flavors of a well-prepared sambar, and experiencing the unique combination of spices that makes South Indian cuisine so distinctive.",paragraph5:"Our story continues to unfold with each meal we serve, as we remain committed to our founding vision: bringing the authentic taste of South India to Poland, one delicious dish at a time.",paragraph6:"I warmly invite you to join us on this culinary adventure and discover the distinctive tastes of South India – a cuisine still new to many in Poland but certain to delight your palate with its rich traditions and bold flavors.",signature:"- Chef Victor",description:"Learn about Madras Bistro's journey in Krakow, bringing authentic South Indian cuisine with passion and tradition. Discover our story and culinary roots!"},menuSection:{title:"Discover our menu",description:"Our menu is a collection of the most popular dishes from south india."},orderOnline:{title:"Order Online",description:"Craving South Indian food? Order online from Madras Bistro in Krakow for delicious dosas, curries, and more. Fast, fresh, and authentic, delivered to you!"},hero:{title:"Discover South Indian Cuisine that's Beyond Delicious",subtitle:"Embark on a flavorful journey rich in tradition and vibrant spices."},introSection:{title:"Madras Bistro: Five Regions, One Extraordinary Table",paragraph1:"Step into a world where spices whisper ancient secrets and aromas tell tales of distant shores. At Madras Bistro, the diverse culinary heritage of South India comes alive on your plate—a gastronomic tapestry woven from the traditions of Tamil Nadu, Kerala, Andhra Pradesh, Karnataka, and Sri Lanka. Our kitchen celebrates this rich mosaic of regional cuisines, where coastal treasures meet inland specialties in a harmonious expression of flavor.",paragraph2:"In this tropical paradise, the climate nurtures abundant coconut groves and rice fields, giving birth to a culinary tradition that celebrates fresh ingredients and complex flavors. Unlike the heavy, cream-based dishes familiar to many, South Indian cuisine is a delicate dance of spices, featuring iconic dishes like crispy dosas, soft idlis, and tangy sambars that speak to centuries of culinary innovation. Each bite tells a story of coastal markets, family traditions, and a deep connection to the land."},reservationSection:{title:"Reserve Your Table",description:"Experience authentic South Indian cuisine in a warm, inviting atmosphere. Make a reservation for a memorable dining experience."},testimonialsSection:{title:"Google Reviews",description:"See what our customers are saying about us",testimonials:[{name:"Konrad Górski",company:"Appy.com",text:"A bistro worth visiting for fans of Indian flavors. They serve Indian cuisine and from the north of Sri Lanka. I ate delicious milk chicken with aromatic jeera rice. The bistro is small (3 tables) and modest, but you can listen to Indian music hits."},{name:"Sophia Mackney",company:"Nobi Bank",text:"My husband and I chanced upon this restaurant last Thursday whilst on a short break to Krakow from the UK. This small eatery with just 2 or 3 tables is run by the very friendly and obliging owner/chef and is conveniently located facing Ghetto Heroes Square. The Masala Uttapam, Masala Dosa, Kerala Chicken Curry, Chicken Roast and Masala Chai that we had were absolutely delicious. I highly recommend this restaurant to any lovers of South Indian food."},{name:"Sridevi Madbhavi",company:"Sync",text:"Absolutely mouthwatering food! The owner (also the chef) is extremely passionate about the customers experience, and you can feel his expertise in every bite. Highly recommend the ghee dosa (he made it extra crispy for us on request). It tastes like home, is SO authentic. The only downside is that I'll miss the food terribly when I leave Kraków!"},{name:"Bijeesh KB",company:"Appicu",text:"If you're looking for a place that serves real Malabar food, this is definitely the spot. Highly recommended for anyone craving a taste of home!"}]},orderTracking:{orderPlaced:"Order Placed",orderPlacedDesc:"Your order has been received and is waiting to be accepted",orderAccepted:"Order Accepted",orderAcceptedDesc:"Your order has been accepted and is being processed",readyForDispatch:"Ready for Dispatch",readyForDispatchDesc:"Your order is packed and ready to be shipped",orderDispatched:"Order Dispatched",orderDispatchedDesc:"Your order is on its way to you",orderDelivered:"Order Delivered",orderDeliveredDesc:"Your order has been delivered",orderCancelled:"Order Cancelled",orderCancelledDesc:"Your order has been cancelled",price:"Price",quantity:"Quantity",subtotal:"Subtotal",total:"Total",poweredBy:"Powered by",reference:"Reference",status:"Status"},reservation:{reservationDetails:"Reservation Details",name:"Name",phone:"Phone",guests:"Guests",date:"Date",reference:"Reference",status:"Status",notSpecified:"Not specified",invalidDate:"Invalid date",requestSent:"Reservation Request Sent",requestSentDesc:"Your reservation request has been received and is waiting to be confirmed by the restaurant",confirmed:"Reservation Confirmed",confirmedDesc:"Your reservation has been confirmed",cancelled:"Reservation Cancelled",cancelledDesc:"Your reservation has been cancelled",pendingStatus:"Pending",confirmedStatus:"Confirmed",cancelledStatus:"Cancelled",bookingEnabled:"Reservations are enabled",bookingEnabledDesc:"You can send a booking request below and the restaurant will review it shortly.",bookingDisabled:"Reservations are currently unavailable",bookingDisabledDesc:"This restaurant is not accepting reservations right now. Please contact them directly for assistance.",poweredBy:"Powered by"},homepage:{description:"Discover Madras Bistro, Krakow's first South Indian restaurant. Savor authentic flavors, vibrant spices, and traditional dishes in a cozy setting. Visit us today!"},menu:{description:"Explore the Madras Bistro menu featuring authentic South Indian dishes like dosas, curries, and biryanis. Fresh ingredients, bold flavors in Krakow!"},privacyPolicy:{description:"Read Madras Bistro's Privacy Policy to understand how we protect your data and ensure a secure experience while enjoying our South Indian cuisine in Krakow."},termsAndConditions:{description:"Review the Terms and Conditions for using Madras Bistro's website and services in Krakow. Learn about our policies for online orders and dining."}},Po={common:{cart:"Koszyk",checkout:"Zamówienie",products:"Produkty",home:"Strona główna",search:"Szukaj",loading:"Ładowanie...",add:"Dodaj",remove:"Usuń",close:"Zamknij",back:"Wstecz",next:"Dalej",continue:"Kontynuuj",submit:"Wyślij",cancel:"Anuluj",apply:"Zastosuj",save:"Zapisz",aboutUs:"O nas",ourStory:"O Nas",menu:"Menu",reservations:"Rezerwacje",orderOnline:"Zamów online",checkOurMenu:"Sprawdź nasze menu",privacyPolicy:"Polityka prywatności",termsAndConditions:"Warunki korzystania",orderNow:"Zamów teraz",makeReservation:"Zarezerwuj stolik"},product:{addToCart:"Dodaj do koszyka",outOfStock:"Brak w magazynie",stockAdjusted:"Dostosowaliśmy ilość do aktualnie dostępnego stanu.",quantity:"Ilość",price:"Cena",total:"Razem",description:"Opis",options:"Opcje",modifiers:"Modyfikatory"},checkout:{yourOrder:"Twoje zamówienie",orderSummary:"Podsumowanie zamówienia",delivery:"Dostawa",address:"Adres",payment:"Płatność",confirmation:"Potwierdzenie",deliveryDetails:"Szczegóły dostawy",paymentMethod:"Metoda płatności",placeOrder:"Złóż zamówienie",subtotal:"Suma częściowa",total:"Razem"},ourStory:{title:"Nasza historia",subtitle:"Z wybrzeży Południowych Indii do serca Polski – autentyczne smaki, niezapomniane doświadczenia",by:"Autor",paragraph1:"Kiedy Madras Bistro otworzyło swoje drzwi w 2018 roku, był to historyczny moment jako pierwsza autentyczna restauracja południowoindyjska w Polsce. Nasza podróż rozpoczęła się od prostej, ale głębokiej wizji: wprowadzenia bogatych, żywych smaków Południowych Indii do polskiego krajobrazu kulinarnego.",paragraph2:"Nasi założyciele, zainspirowani swoimi głębokimi korzeniami w Tamil Nadu, rozpoczęli tę przygodę po zauważeniu, że podczas gdy kuchnia północnoindyjska znalazła swoje miejsce w Polsce, różnorodne i charakterystyczne smaki Południowych Indii pozostały nieodkrytym terytorium. Marzyli o stworzeniu miejsca, gdzie aromatyczne przyprawy, curry nasycone kokosem i delikatne dosa z ich ojczyzny mogłyby być doświadczane w autentycznej formie.",paragraph3:"Droga nie zawsze była łatwa. Pozyskiwanie tradycyjnych składników, doskonalenie przepisów, które pozostały wierne południowoindyjskim korzeniom, a jednocześnie trafiały w gusta polskich podniebień, oraz edukowanie gości o kuchni tak różnej od tego, co znali – to były wyzwania, które przyjęliśmy z pasją. Nasi szefowie kuchni, wyszkoleni w tradycyjnych technikach gotowania południowoindyjskiego, pracowali niestrudzenie, aby zapewnić, że każde danie opuszczające naszą kuchnię niosło w sobie esencję regionów, które reprezentowali.",paragraph4:"Dziś Madras Bistro stoi jako kulturowy most między Polską a Południowymi Indiami. Jesteśmy dumni z tego, że wprowadziliśmy niezliczonych polskich gości w radość przełamywania chrupiącej dosy, smakowania złożonych smaków dobrze przygotowanego sambaru i doświadczania unikalnej kombinacji przypraw, która sprawia, że kuchnia południowoindyjska jest tak wyjątkowa.",paragraph5:"Nasza historia nadal rozwija się z każdym posiłkiem, który serwujemy, ponieważ pozostajemy wierni naszej wizji założycielskiej: przywiezienia autentycznego smaku Południowych Indii do Polski, jedno pyszne danie na raz.",paragraph6:"Serdecznie zapraszam do przyłączenia się do tej kulinarnej przygody i odkrycia charakterystycznych smaków Południowych Indii – kuchni nadal nowej dla wielu w Polsce, ale z pewnością zachwycającej podniebienie bogatymi tradycjami i wyrazistymi smakami.",signature:"- Szef kuchni Victor",description:"Poznaj historię Madras Bistro w Krakowie, które wprowadza autentyczną kuchnię południowoindyjską z pasją i tradycją. Odkryj naszą historię i kulinarne korzenie!"},menuSection:{title:"Odkryj nasze menu",description:"Nasze menu to kolekcja najpopularniejszych dań z południowych Indii."},orderOnline:{title:"Zamów online",description:"Masz ochotę na południowoindyjskie jedzenie? Zamów online z Madras Bistro w Krakowie pyszne dosa, curry i więcej. Szybkie, świeże i autentyczne, dostarczone prosto do Ciebie!"},hero:{title:"Odkryj przepyszną południowo indyjską kuchnie",subtitle:"Wyrusz w pełną smaków podróż bogatą w tradycję i wyraziste przyprawy."},introSection:{title:"Madras Bistro: Pięć regionów, jeden wyjątkowy stół",paragraph1:"Wejdź do świata, gdzie przyprawy szepczą dawne sekrety, a aromaty opowiadają historie z dalekich brzegów. W Madras Bistro różnorodne dziedzictwo kulinarne Południowych Indii ożywa na Twoim talerzu — gastronomiczna tkanina utkana z tradycji Tamil Nadu, Kerali, Andhra Pradesh, Karnataki i Sri Lanki. Nasza kuchnia celebruje tę bogatą mozaikę regionalnych kuchni, gdzie nadmorskie skarby spotykają się z wewnątrznymi specjałami w harmonijnym wyrażeniu smaku.",paragraph2:"W tym tropikalnym raju klimat sprzyja obfitym palmom kokosowym i polom ryżowym, dając początek tradycji kulinarnej, która celebruje świeże składniki i złożone smaki. W przeciwieństwie do ciężkich, kremowych dań znanych wielu osobom, kuchnia południowoindyjska to delikatny taniec przypraw, z takimi ikonicznymi daniami jak chrupiące dosy, miękkie idli i pikantne sambary, które mówią o wiekach kulinarnych innowacji. Każdy kęs opowiada historię nadmorskich targów, rodzinnych tradycji i głębokiego związku z ziemią."},reservationSection:{title:"Zarezerwuj stolik",description:"Doświadcz autentycznej kuchni południowoindyjskiej w ciepłej, przyjaznej atmosferze. Dokonaj rezerwacji na niezapomniane doświadczenie kulinarne."},testimonialsSection:{title:"Opinie Google",description:"Zobacz, co mówią o nas nasi klienci",testimonials:[{name:"Konrad Górski",company:"Appy.com",text:"Bistro warte odwiedzenia dla fanów indyjskich smaków. Serwują kuchnię indyjską i z północy Sri Lanki. Zjadłem pysznego kurczaka w mleku z aromatycznym ryżem jeera. Bistro jest małe (3 stoliki) i skromne, ale można posłuchać indyjskich hitów muzycznych."},{name:"Sophia Mackney",company:"Nobi Bank",text:"Ja i mój mąż przypadkowo trafiliśmy do tej restauracji w zeszły czwartek podczas krótkiego pobytu w Krakowie z Wielkiej Brytanii. Ta mała jadłodajnia z zaledwie 2 lub 3 stolikami jest prowadzona przez bardzo przyjaznego i uczynnego właściciela/szefa kuchni i jest dogodnie zlokalizowana naprzeciwko Placu Bohaterów Getta. Masala Uttapam, Masala Dosa, Curry z Kurczakiem Kerala, Kurczak Pieczony i Masala Chai, które jedliśmy, były absolutnie pyszne. Gorąco polecam tę restaurację wszystkim miłośnikom południowo-indyjskiej kuchni."},{name:"Sridevi Madbhavi",company:"Sync",text:"Absolutnie pyszne jedzenie! Właściciel (również szef kuchni) jest niezwykle zaangażowany w doświadczenia klientów i można poczuć jego doświadczenie w każdym kęsie. Gorąco polecam ghee dosa (zrobił je dla nas ekstra chrupiące na prośbę). Smakuje jak w domu, jest BARDZO autentyczne. Jedynym minusem jest to, że będę tęsknić za tym jedzeniem, gdy opuszczę Kraków!"},{name:"Bijeesh KB",company:"Appicu",text:"Jeśli szukasz miejsca, które serwuje prawdziwe jedzenie Malabar, to zdecydowanie jest to odpowiednie miejsce. Gorąco polecane dla każdego, kto tęskni za smakiem domu!"}]},orderTracking:{orderPlaced:"Zamówienie złożone",orderPlacedDesc:"Twoje zamówienie zostało odebrane i czeka na akceptację",orderAccepted:"Zamówienie zaakceptowane",orderAcceptedDesc:"Twoje zamówienie zostało zaakceptowane i jest przetwarzane",readyForDispatch:"Gotowe do wysyłki",readyForDispatchDesc:"Twoje zamówienie jest spakowane i gotowe do wysyłki",orderDispatched:"Zamówienie wysłane",orderDispatchedDesc:"Twoje zamówienie jest w drodze do Ciebie",orderDelivered:"Zamówienie dostarczone",orderDeliveredDesc:"Twoje zamówienie zostało dostarczone",orderCancelled:"Zamówienie anulowane",orderCancelledDesc:"Twoje zamówienie zostało anulowane",price:"Cena",quantity:"Ilość",subtotal:"Suma częściowa",total:"Razem",poweredBy:"Wspierane przez",reference:"Numer referencyjny",status:"Status"},reservation:{reservationDetails:"Szczegóły rezerwacji",name:"Imię i nazwisko",phone:"Telefon",guests:"Liczba gości",date:"Data",reference:"Numer referencyjny",status:"Status",notSpecified:"Nie określono",invalidDate:"Nieprawidłowa data",requestSent:"Prośba o rezerwację wysłana",requestSentDesc:"Twoja prośba o rezerwację została odebrana i czeka na potwierdzenie przez restaurację",confirmed:"Rezerwacja potwierdzona",confirmedDesc:"Twoja rezerwacja została potwierdzona",cancelled:"Rezerwacja anulowana",cancelledDesc:"Twoja rezerwacja została anulowana",pendingStatus:"Oczekujące",confirmedStatus:"Potwierdzone",cancelledStatus:"Anulowane",bookingEnabled:"Rezerwacje są włączone",bookingEnabledDesc:"Możesz wysłać prośbę o rezerwację poniżej, a restauracja wkrótce ją sprawdzi.",bookingDisabled:"Rezerwacje są obecnie niedostępne",bookingDisabledDesc:"Ta restauracja nie przyjmuje teraz rezerwacji. Skontaktuj się z nią bezpośrednio, aby uzyskać pomoc.",poweredBy:"Wspierane przez"},homepage:{description:"Odkryj Madras Bistro, pierwszą restaurację południowoindyjską w Krakowie. Skosztuj autentycznych smaków, żywych przypraw i tradycyjnych dań w przytulnym otoczeniu. Odwiedź nas już dziś!"},menu:{description:"Zapoznaj się z menu Madras Bistro oferującym autentyczne południowoindyjskie dania jak dosa, curry i biryani. Świeże składniki, wyraziste smaki w Krakowie!"},privacyPolicy:{description:"Przeczytaj Politykę Prywatności Madras Bistro, aby zrozumieć, jak chronimy Twoje dane i zapewniamy bezpieczne doświadczenie podczas delektowania się naszą południowoindyjską kuchnią w Krakowie."},termsAndConditions:{description:"Zapoznaj się z Warunkami korzystania ze strony internetowej i usług Madras Bistro w Krakowie. Dowiedz się o naszych zasadach dotyczących zamówień online i dań w restauracji."}},Kr={en:Mo,pl:Po},Zs=x.createContext(void 0),Bo=({children:a,locale:t})=>{const r=x.useCallback(i=>{const n=i.split(".");let o=Kr[t];for(const l of n)if(o&&typeof o=="object"&&l in o)o=o[l];else return i;return typeof o=="string"?o:i},[t]),s={locale:t,translations:Kr[t],t:r};return e.jsx(Zs.Provider,{value:s,children:a})},Ua=()=>{const a=x.useContext(Zs);if(a===void 0)throw new Error("useTranslation must be used within a TranslationProvider");return a},$s=x.createContext(null),To=a=>{if(a==null||a==="")return null;const t=typeof a=="string"?Number.parseInt(a,10):a;return Number.isFinite(t)?t:null},_s=({children:a,locale:t="en"})=>{const{modifierModal:r,closeModifiersModal:s,addItem:i,items:n}=Ha(),{t:o}=Ua(),l=(r==null?void 0:r.product)??null,c=x.useMemo(()=>(l==null?void 0:l.modifierGroups)??[],[l]),[m,u]=x.useState(1),[p,g]=x.useState(!1),[h,f]=x.useState(null),{toggleModifier:b,selectModifier:y,isModifierSelected:j,validateSelections:v,validationError:k,getCartModifierGroups:C}=Us(c),{getProductName:F,getModifierGroupName:T}=Hs(t),O=x.useMemo(()=>l?n.filter(ee=>ee.productId===l.id).reduce((ee,Ee)=>ee+(Ee.quantity||1),0):0,[n,l]),R=To(l==null?void 0:l.availableQuantity),S=R===null?null:Math.max(R-O,0),Q=S!==null&&m>=S,W=S===0;x.useEffect(()=>{if(!r)return;const ee=r.quantity??1;g(!1),f(null),u(S===null?ee:Math.min(ee,Math.max(S,1)))},[S,r]);const ye=x.useCallback(()=>{f(null),u(ee=>S===null?ee+1:Math.min(ee+1,S))},[S]),Ve=x.useCallback(()=>{f(null),u(ee=>ee>1?ee-1:1)},[]),ue=x.useCallback(ee=>{if(!ee.trim()){u(1),f(null);return}const Ee=Number.parseInt(ee,10);if(!Number.isFinite(Ee))return;const Ge=Math.max(Ee,1);if(S!==null&&Ge>S){u(Math.max(S,1)),f(o(S===0?"product.outOfStock":"product.stockAdjusted"));return}u(Ge),f(null)},[S,o]),oa=x.useCallback(async()=>{var Ee;if(p||!l||!v()||W){W&&f(o("product.outOfStock"));return}const ee=S===null?m:Math.min(m,S);g(!0);try{const Ge=await i({productId:l.id,quantity:ee,modifierGroups:C()},{showAdjustmentAlert:!1});if(Ge.invalidProductIds.includes(l.id)){f(o("product.outOfStock"));return}if(Ge.adjustments.length>0){f(o("product.stockAdjusted"));return}f(null),u(1),s(),(Ee=r==null?void 0:r.onAdded)==null||Ee.call(r)}finally{g(!1)}},[i,s,C,p,r,l,m,v,W,S,o]),Ce=c.length>0,X=x.useMemo(()=>l?"title"in l?l.title??"":F(l,""):"",[F,l]),Y=x.useCallback(ee=>ee.selectMax>1||ee.selectMax===0,[]),ce=x.useCallback((ee,Ee)=>ee.price>0?` (+${we(ee.price,Ee,t)})`:"",[t]),fa={isOpen:r!==null,onClose:s,product:l,productName:X,hasModifiers:Ce,quantity:m,handleIncrement:ye,handleDecrement:Ve,handleQuantityInput:ue,isIncrementDisabled:Q,isSubmitting:p,isOutOfStock:W,maxQuantity:S,stockMessage:h,handleAddToCart:oa,validationError:k,modifierGroups:c,isModifierSelected:j,isMultiSelect:Y,toggleModifier:b,selectModifier:y,getModifierGroupName:T,formatModifierPrice:ce,locale:t};return e.jsx($s.Provider,{value:fa,children:a})},Za=()=>{const a=x.useContext($s);if(!a)throw new Error("useModifiers must be used within a ModifiersProvider");return a},Qo=a=>{if(a==null||a==="")return null;const t=typeof a=="string"?Number.parseInt(a,10):a;return Number.isFinite(t)?t:null},Ws=({className:a,emptyCartComponent:t,renderItem:r,loadingComponent:s})=>{const{organization:i}=ke(),{locale:n,items:o,removeItem:l,updateItemQuantity:c,products:m,isProductsLoading:u}=Ha();return!i||u?s:o.length===0?t:e.jsx("div",{className:a||"flex-1 overflow-y-auto",children:m&&o.map(p=>{const g=m[p.productId];if(!g)return null;const h=o.filter(k=>k.productId===p.productId).reduce((k,C)=>k+(C.quantity||1),0)-(p.quantity||1),f=Qo(g.availableQuantity),b=f===null?null:Math.max(f-h,0),y=()=>l(p.productId,p.modifierGroups),j=k=>{c(p.productId,k,p.modifierGroups).catch(C=>{console.error("Failed to update cart item quantity:",C)})},v=Js(p,g,i.configuration.defaultCurrency,n);return e.jsx(x.Fragment,{children:r({...v,maxQuantity:b,remove:y,updateQuantity:j})},`${p.productId}-${JSON.stringify(p.modifierGroups)}`)})})},Ks=({title:a,subtitle:t,image:r,price:s,quantity:i,maxQuantity:n,remove:o,updateQuantity:l})=>{const[c,m]=x.useState(String(i)),u=n!=null&&i>=n;x.useEffect(()=>{m(String(i))},[i]);const p=x.useCallback(()=>{const g=Number.parseInt(c,10);if(Number.isNaN(g)){m(String(i));return}if(g<=0){o();return}if(n!=null){l(Math.min(g,n));return}l(g)},[c,n,i,o,l]);return e.jsx("div",{className:w("p-1 mb-3 transition-shadow"),children:e.jsxs("div",{className:"grid grid-cols-5",children:[e.jsx("div",{className:"shrink-0 w-full h-full mr-3 overflow-hidden col-span-2",children:r?e.jsx(Ie,{width:100,height:100,src:r.url,alt:a,className:"w-full h-32 object-cover border rounded-md overflow-hidden"}):e.jsx("div",{className:"bg-slate-100 h-full rounded-md flex items-center justify-center",children:e.jsx("span",{className:"text-slate-400",children:"No image"})})}),e.jsxs("div",{className:"flex-1 min-w-0 pl-4 col-span-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-black text-slate-800 font-red-hat-display leading-tight",children:a}),t&&e.jsx("p",{className:"text-xs font-medium text-gray-600 dark:text-gray-400",children:t}),e.jsx("p",{className:"text-xs font-medium text-gray-600 dark:text-gray-400 mt-1",children:s})]}),e.jsx("div",{className:"mt-3 flex items-center justify-between",children:e.jsxs("div",{className:"inline-flex items-center overflow-hidden rounded-lg bg-white",children:[e.jsx("button",{type:"button",className:"storefront-primary-action flex h-8 w-8 cursor-pointer items-center justify-center text-sm font-semibold transition-colors",onClick:()=>i<=1?o():l(Math.max(1,i-1)),"aria-label":"Decrease quantity",children:"-"}),e.jsx("input",{type:"number",min:1,step:1,inputMode:"numeric",value:c,onChange:g=>{const h=g.target.value;(h===""||/^[0-9]+$/.test(h))&&m(h)},onBlur:p,onKeyDown:g=>{g.key==="Enter"&&g.currentTarget.blur()},className:"h-8 w-11 border-x border-slate-200 bg-white px-0 text-center text-sm font-semibold text-slate-700 outline-none transition-colors focus:bg-slate-50 [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none","aria-label":"Quantity"}),e.jsx("button",{type:"button",className:"storefront-primary-action flex h-8 w-8 cursor-pointer items-center justify-center text-sm font-semibold transition-colors",onClick:()=>l(i+1),"aria-label":"Increase quantity",disabled:u,children:"+"})]})})]})]})})},Oo=e.jsx("div",{className:"flex items-center justify-center h-32",children:e.jsxs("svg",{"aria-hidden":"true",className:"storefront-primary-fill text-gray-200 animate-spin dark:text-gray-600 h-8 w-8",viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",fill:"currentColor"}),e.jsx("path",{d:"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",fill:"currentFill"})]})}),Lo=e.jsxs("div",{className:"text-center py-4 text-sm text-slate-500 flex flex-col items-center",children:[e.jsx("div",{className:"bg-slate-100 p-2 rounded-full mb-2",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M3 3h2l.4 2M7 13h10l4-8H5.4M7 13L5.4 5M7 13l-2.293 2.293c-.63.63-.184 1.707.707 1.707H17m0 0a2 2 0 100 4 2 2 0 000-4zm-8 2a2 2 0 11-4 0 2 2 0 014 0z"})})}),e.jsx("p",{className:"font-medium",children:"Your cart is empty"})]}),Jo=a=>e.jsx(Ks,{...a}),Gs=({checkoutHref:a="/checkout/customer-details",checkoutLabel:t="Checkout",title:r="Shopping bag",className:s="bg-white shadow-xl rounded-lg overflow-hidden h-full flex flex-col",bodyClassName:i="max-h-80 md:max-h-[550px] overflow-y-auto p-4 md:p-3 space-y-3 h-full",headerClassName:n="storefront-primary-bg py-3 px-3 border-b border-slate-100 flex justify-between items-center",onClose:o,showCloseButton:l=!!o,emptyCartComponent:c=Lo,loadingComponent:m=Oo,renderFooter:u,renderHeader:p,renderItem:g=Jo})=>{const{itemCount:h,total:f,locale:b}=Ha(),{organization:y}=ke(),j=(y==null?void 0:y.configuration.defaultCurrency)??"USD",v=we(f,j,b),k={checkoutHref:a,checkoutLabel:t,close:o??(()=>{}),formattedTotal:v,itemCount:h,total:f};return e.jsxs("div",{className:s,children:[p?p({onClose:o,showCloseButton:l,title:r}):e.jsxs("div",{className:n,children:[e.jsx("h3",{className:"text-lg font-black font-red-hat-display text-white",children:r}),l&&o&&e.jsx("button",{onClick:o,className:"storefront-primary-bg-hover text-white p-1 rounded-full transition-colors","aria-label":"Close cart",type:"button",children:e.jsx(P.RiCloseLine,{className:"h-5 w-5"})})]}),e.jsx("div",{className:i,children:e.jsx(Ws,{renderItem:C=>g(C),loadingComponent:m,emptyCartComponent:c})}),h>0&&(u?u(k):e.jsxs("div",{className:"flex items-center px-4 py-4 border-t border-t-slate-200 mt-auto w-full",children:[e.jsx("div",{className:"w-[125px] font-medium h-[45px] rounded-lg flex items-center text-sm justify-center border border-slate-200 whitespace-nowrap mr-2",children:v}),e.jsx(B,{href:a,className:"storefront-primary-action btn text-sm rounded-lg w-full",onClick:o,children:t})]}))]})},Vo=({isOpen:a,onClose:t,checkoutHref:r="/checkout/customer-details",checkoutLabel:s="Checkout",title:i="Shopping bag",className:n,contentClassName:o,emptyCartComponent:l,loadingComponent:c,renderFooter:m,renderItem:u})=>{const p=x.useRef(null),[g,h]=x.useState(null),[f,b]=x.useState(null),y=50,j=C=>{b(null),h(C.targetTouches[0].clientY)},v=C=>{b(C.targetTouches[0].clientY)},k=()=>{!g||!f||(f-g>y&&t(),h(null),b(null))};return e.jsxs(e.Fragment,{children:[a&&e.jsx("div",{className:"fixed inset-0 bg-black opacity-40 z-40 transition-opacity",onClick:t,"aria-hidden":"true"}),e.jsx(va.Transition,{show:a,as:x.Fragment,enter:"transition ease-in-out duration-300 transform",enterFrom:"translate-y-full",enterTo:"translate-y-0",leave:"transition ease-in-out duration-300 transform",leaveFrom:"translate-y-0",leaveTo:"translate-y-full",children:e.jsx("div",{className:w("fixed bottom-0 right-0 h-[85vh] w-full sm:w-96 z-50 shadow-xl flex flex-col",n),children:e.jsx("div",{className:"h-full",ref:p,onTouchStart:j,onTouchMove:v,onTouchEnd:k,children:e.jsx(Gs,{checkoutHref:r,checkoutLabel:s,title:i,className:w("bg-white shadow-xl rounded-lg overflow-hidden h-full flex flex-col",o),onClose:t,emptyCartComponent:l,loadingComponent:c,renderFooter:m,renderItem:u})})})})]})},qo=[{value:"USD",label:"United States Dollar"},{value:"EUR",label:"Euro"},{value:"GBP",label:"British Pound Sterling"},{value:"JPY",label:"Japanese Yen"},{value:"AUD",label:"Australian Dollar"},{value:"CAD",label:"Canadian Dollar"},{value:"CHF",label:"Swiss Franc"},{value:"CNY",label:"Chinese Yuan"},{value:"SEK",label:"Swedish Krona"},{value:"NZD",label:"New Zealand Dollar"},{value:"MXN",label:"Mexican Peso"},{value:"SGD",label:"Singapore Dollar"},{value:"HKD",label:"Hong Kong Dollar"},{value:"NOK",label:"Norwegian Krone"},{value:"KRW",label:"South Korean Won"},{value:"TRY",label:"Turkish Lira"},{value:"RUB",label:"Russian Ruble"},{value:"INR",label:"Indian Rupee"},{value:"BRL",label:"Brazilian Real"},{value:"ZAR",label:"South African Rand"},{value:"DKK",label:"Danish Krone"},{value:"PLN",label:"Polish Złoty"},{value:"THB",label:"Thai Baht"},{value:"IDR",label:"Indonesian Rupiah"},{value:"HUF",label:"Hungarian Forint"},{value:"CZK",label:"Czech Koruna"},{value:"ILS",label:"Israeli New Shekel"},{value:"PHP",label:"Philippine Peso"},{value:"AED",label:"United Arab Emirates Dirham"},{value:"COP",label:"Colombian Peso"},{value:"SAR",label:"Saudi Riyal"},{value:"MYR",label:"Malaysian Ringgit"},{value:"RON",label:"Romanian Leu"}],Ct=d.z.enum(["USD","EUR","GBP","JPY","AUD","CAD","CHF","CNY","SEK","NZD","MXN","SGD","HKD","NOK","KRW","TRY","RUB","INR","BRL","ZAR","DKK","PLN","THB","IDR","HUF","CZK","ILS","PHP","AED","COP","SAR","MYR","RON"]).openapi({description:"The currency code for the transaction."}),nr=d.z.enum(["delivery","pickup"]),Ho=d.z.enum(["card","blik","paypal","bank_transfer","cash_on_delivery"]).openapi({description:"The payment method used for the order",example:"card"});d.z.object({from:d.z.coerce.date().openapi({description:"Start of the reporting range",example:"2026-01-01T00:00:00.000Z"}),to:d.z.coerce.date().openapi({description:"End of the reporting range",example:"2026-01-30T23:59:59.999Z"})});const Uo=d.z.object({from:d.z.date(),to:d.z.date()}).openapi("AnalyticsRange"),Zo=d.z.object({currency:Ct,totalSales:d.z.number().min(0),paidOrders:d.z.number().int().min(0),averageOrderValue:d.z.number().min(0),reservations:d.z.number().int().min(0),guests:d.z.number().int().min(0)}).openapi("AnalyticsSummary"),$o=d.z.object({date:d.z.date(),label:d.z.string(),totalSales:d.z.number().min(0),paidOrders:d.z.number().int().min(0)}).openapi("SalesByDayPoint"),_o=d.z.object({date:d.z.date(),label:d.z.string(),reservations:d.z.number().int().min(0),guests:d.z.number().int().min(0)}).openapi("ReservationsByDayPoint"),Wo=d.z.object({method:Ho,count:d.z.number().int().min(0),totalSales:d.z.number().min(0)}).openapi("PaymentMethodBreakdownItem"),Ko=d.z.object({method:nr,count:d.z.number().int().min(0),totalSales:d.z.number().min(0)}).openapi("FulfilmentBreakdownItem");d.z.object({range:Uo,summary:Zo,salesByDay:d.z.array($o),reservationsByDay:d.z.array(_o),paymentMethods:d.z.array(Wo),fulfilmentMethods:d.z.array(Ko)}).openapi("AnalyticsOverview"),d.z.object({id:d.z.string().openapi({example:"clf9876543210abcdef",description:"ID of the member"}),organizationId:d.z.string().openapi({example:"cju0z9k4z0000l1qg5z1z1z1z",description:"ID of the organization"}),userId:d.z.string().openapi({example:"usr_123",description:"ID of the user"}),role:d.z.string().openapi({example:"owner",description:"Role of the member in the organization"}),createdAt:d.z.date(),user:d.z.object({id:d.z.string(),firstname:d.z.string(),lastname:d.z.string(),email:d.z.string(),image:d.z.string().nullable().optional()}).openapi({description:"User details"})}).openapi("Member"),d.z.object({id:d.z.string().openapi({example:"inv_123",description:"ID of the invitation"}),organizationId:d.z.string().openapi({example:"cju0z9k4z0000l1qg5z1z1z1z",description:"ID of the organization"}),email:d.z.string().email().openapi({example:"user@example.com",description:"Email of the invited user"}),role:d.z.string().nullable().optional().openapi({example:"member",description:"Role assigned to the invitation"}),status:d.z.string().openapi({example:"pending",description:"Status of the invitation"}),expiresAt:d.z.date().openapi({description:"Expiration date of the invitation"}),inviterId:d.z.string().openapi({description:"ID of the user who created the invitation"}),createdAt:d.z.date().optional()}).openapi("Invitation");const Go=d.z.object({email:d.z.string().email("A valid email is required").openapi({example:"user@example.com",description:"Email of the user to invite"}),role:d.z.string().min(1,"Role is required").openapi({example:"member",description:"Role to assign to the invited user"})}).openapi("CreateInvitation"),Xo=d.z.object({role:d.z.string().min(1,"Role is required").openapi({example:"admin",description:"New role for the member"})}).openapi("UpdateMemberRole");d.z.object({id:d.z.string().openapi({example:"inv_123",description:"ID of the invitation"}),organizationId:d.z.string().openapi({example:"cju0z9k4z0000l1qg5z1z1z1z",description:"ID of the organization"}),role:d.z.string().nullable().optional().openapi({example:"member",description:"Role assigned to the invitation"}),expiresAt:d.z.date().openapi({description:"Expiration date of the invitation"}),organization:d.z.object({id:d.z.string(),name:d.z.string()}).openapi({description:"Organization details"})}).openapi("UserInvitation");const Aa=(...a)=>(t,r)=>{const{translations:s,defaultLocale:i}=t;if(s===void 0&&i===void 0)return;if(!Array.isArray(s)||s.length===0){r.addIssue({code:d.z.ZodIssueCode.custom,message:"Missing translation for the default locale",path:["translations"]});return}if(typeof i!="string"||!i.trim()){r.addIssue({code:d.z.ZodIssueCode.custom,message:"Default locale is required when translations are provided",path:["defaultLocale"]});return}const n=s.findIndex(o=>o.locale===i);if(n===-1){r.addIssue({code:d.z.ZodIssueCode.custom,message:"Missing translation for the default locale",path:["translations"]});return}a.forEach(o=>{const l=s[n][o];(typeof l!="string"||!l.trim())&&r.addIssue({code:d.z.ZodIssueCode.custom,message:"This field is required",path:["translations",n,o]})})},St=new Map([["af","Afrikaans"],["sq","Albanian"],["ar_dz","Arabic (Algeria)"],["ar_bh","Arabic (Bahrain)"],["ar_eg","Arabic (Egypt)"],["ar_iq","Arabic (Iraq)"],["ar_jo","Arabic (Jordan)"],["ar_kw","Arabic (Kuwait)"],["ar_lb","Arabic (Lebanon)"],["ar_ly","Arabic (Libya)"],["ar_ma","Arabic (Morocco)"],["ar_om","Arabic (Oman)"],["ar_qa","Arabic (Qatar)"],["ar_sa","Arabic (Saudi Arabia)"],["ar_sy","Arabic (Syria)"],["ar_tn","Arabic (Tunisia)"],["ar_ae","Arabic (U.A.E.)"],["ar_ye","Arabic (Yemen)"],["eu","Basque"],["be","Belarusian"],["bg","Bulgarian"],["ca","Catalan"],["zh_hk","Chinese (Hong Kong)"],["zh_cn","Chinese (PRC)"],["zh_sg","Chinese (Singapore)"],["zh_tw","Chinese (Taiwan)"],["hr","Croatian"],["cs","Czech"],["da","Danish"],["nl_be","Dutch (Belgium)"],["nl","Dutch (Standard)"],["en","English"],["en_au","English (Australia)"],["en_bz","English (Belize)"],["en_ca","English (Canada)"],["en_ie","English (Ireland)"],["en_jm","English (Jamaica)"],["en_nz","English (New Zealand)"],["en_za","English (South Africa)"],["en_tt","English (Trinidad)"],["en_gb","English (United Kingdom)"],["en_us","English (United States)"],["et","Estonian"],["fo","Faeroese"],["fa","Farsi"],["fi","Finnish"],["fr_be","French (Belgium)"],["fr_ca","French (Canada)"],["fr_lu","French (Luxembourg)"],["fr","French (Standard)"],["fr_ch","French (Switzerland)"],["gd","Gaelic (Scotland)"],["de_at","German (Austria)"],["de_li","German (Liechtenstein)"],["de_lu","German (Luxembourg)"],["de","German (Standard)"],["de_ch","German (Switzerland)"],["el","Greek"],["he","Hebrew"],["hi","Hindi"],["hu","Hungarian"],["is","Icelandic"],["id","Indonesian"],["ga","Irish"],["it","Italian (Standard)"],["it_ch","Italian (Switzerland)"],["ja","Japanese"],["ko","Korean"],["ku","Kurdish"],["lv","Latvian"],["lt","Lithuanian"],["mk","Macedonian (FYROM)"],["ml","Malayalam"],["ms","Malaysian"],["mt","Maltese"],["no","Norwegian"],["nb","Norwegian (Bokmål)"],["nn","Norwegian (Nynorsk)"],["pl","Polish"],["pt_br","Portuguese (Brazil)"],["pt","Portuguese (Portugal)"],["pa","Punjabi"],["rm","Rhaeto-Romanic"],["ro","Romanian"],["ro_md","Romanian (Republic of Moldova)"],["ru","Russian"],["ru_md","Russian (Republic of Moldova)"],["sr","Serbian"],["sk","Slovak"],["sl","Slovenian"],["sb","Sorbian"],["es_ar","Spanish (Argentina)"],["es_bo","Spanish (Bolivia)"],["es_cl","Spanish (Chile)"],["es_co","Spanish (Colombia)"],["es_cr","Spanish (Costa Rica)"],["es_do","Spanish (Dominican Republic)"],["es_ec","Spanish (Ecuador)"],["es_sv","Spanish (El Salvador)"],["es_gt","Spanish (Guatemala)"],["es_hn","Spanish (Honduras)"],["es_mx","Spanish (Mexico)"],["es","Spanish (Spain)"],["sv","Swedish"],["sv_fi","Swedish (Finland)"],["th","Thai"],["tr","Turkish"],["uk","Ukrainian"],["ur","Urdu"],["vi","Vietnamese"],["cy","Welsh"],["ji","Yiddish"],["zu","Zulu"]]),Gr=Array.from(St.entries()).map(([a,t])=>({value:a,label:t})),We=d.z.enum(["af","sq","ar_dz","ar_bh","ar_eg","ar_iq","ar_jo","ar_kw","ar_lb","ar_ly","ar_ma","ar_om","ar_qa","ar_sa","ar_sy","ar_tn","ar_ae","ar_ye","eu","be","bg","ca","zh_hk","zh_cn","zh_sg","zh_tw","hr","cs","da","nl_be","nl","en","en_au","en_bz","en_ca","en_ie","en_jm","en_nz","en_za","en_tt","en_gb","en_us","et","fo","fa","fi","fr_be","fr_ca","fr_lu","fr","fr_ch","gd","de_at","de_li","de_lu","de","de_ch","el","he","hi","hu","is","id","ga","it","it_ch","ja","ko","ku","lv","lt","mk","ml","ms","mt","no","nb","nn","pl","pt_br","pt","pa","rm","ro","ro_md","ru","ru_md","sr","sk","sl","sb","es_ar","es_bo","es_cl","es_co","es_cr","es_do","es_ec","es_sv","es_gt","es_hn","es_mx","es","sv","sv_fi","th","tr","uk","ur","vi","cy","ji","zu"]).openapi({description:"Enum for locale values",example:"en"}),Xs=d.z.union([d.z.string(),d.z.number(),d.z.null()]).optional().transform(a=>{if(a==null||a==="")return null;if(typeof a=="number")return a;const t=Number(a);return isNaN(t)?a:t}).pipe(d.z.number().nonnegative({message:"This field must be a positive number"}).nullable().refine(a=>a===null||a>=0,{message:"Price must be positive"})),ut=d.z.coerce.number().min(.1,"This field must be positive").refine(a=>/^\d+(\.\d{1,2})?$/.test(a.toString()),{message:"This field can have a maximum of two decimal points"}),Yo=d.z.union([d.z.string(),d.z.number(),d.z.null()]).optional().transform(a=>{if(a==null||a==="")return null;if(typeof a=="number")return a;const t=Number(a);return Number.isNaN(t)?a:t}).pipe(d.z.number().int({message:"This field must be a whole number"}).nonnegative({message:"This field must be zero or greater"}).nullable()),el=d.z.object({type:d.z.literal("blob.generate-client-token"),payload:d.z.object({pathname:d.z.string(),callbackUrl:d.z.string(),multipart:d.z.boolean(),clientPayload:d.z.string().nullable()})}),al=d.z.object({type:d.z.literal("blob.upload-completed"),payload:d.z.object({blob:d.z.any(),tokenPayload:d.z.string().nullable().optional()})});d.z.discriminatedUnion("type",[el,al]),d.z.discriminatedUnion("type",[d.z.object({type:d.z.literal("blob.generate-client-token"),clientToken:d.z.string()}),d.z.object({type:d.z.literal("blob.upload-completed"),response:d.z.literal("ok")})]),d.z.object({mimeType:d.z.string().min(1,"MIME type is required").openapi({example:"image/png",description:"MIME type of the file"}),size:d.z.number().min(1,"Size is required").openapi({example:1024,description:"Size of the file in bytes"}),filename:d.z.string().min(1,"Filename is required").openapi({example:"example.png",description:"Name of the file"}),organizationId:d.z.string().optional().openapi({example:"clm1234567890abcdef",description:"ID of the organization"})});const ra=d.z.object({id:d.z.string().min(1,"ID is required").openapi({example:"clf9876543210abcdef",description:"ID of the file"}),url:d.z.string().min(1,"Path is required").openapi({example:"/path/to/file",description:"Path of the file"}),mimeType:d.z.string().min(1,"MIME type is required").openapi({example:"image/png",description:"MIME type of the file"}),size:d.z.number().min(1,"Size is required").openapi({example:1024,description:"Size of the file in bytes"}),filename:d.z.string().min(1,"Filename is required").openapi({example:"example.png",description:"Name of the file"})}).openapi("UploadedFile"),zt=d.z.object({id:d.z.string().openapi({example:"clf9876543210abcdef",description:"ID of the product category"}),slug:d.z.string().openapi({example:"electronics",description:"Slug of the product category"}),image:ra.nullable().optional().openapi({description:"Image of the product category"}),createdAt:d.z.date(),publishedAt:d.z.date().nullable().optional().openapi({description:"Timestamp when the product category was published"}),translations:d.z.array(d.z.object({locale:d.z.string().min(1,"Locale is required").openapi({example:"en-US",description:"Locale code for the translation"}),title:d.z.string().default("").openapi({example:"Electronics",description:"Name of the product category in the specified locale"}),description:d.z.string().max(6e3,"Maximum character limit is 6000").nullable().default("").optional().openapi({example:"A category for electronic devices.",description:"Description of the product category in the specified locale"})})).openapi({description:"List of translations for the product category"})}).openapi("ProductCategory");zt.omit({translations:!0}).extend({title:d.z.string().default(""),description:d.z.string().default("")}).openapi("LocalizedProductCategory");const tl=zt.pick({slug:!0,image:!0,translations:!0}).extend({defaultLocale:d.z.string().min(1,"Default locale is required").openapi({description:"The default locale for the product category"}),imageId:d.z.string().cuid().optional().openapi({description:"ID of the image for the product category"})}).superRefine(Aa("title")).openapi("CreateProductCategory"),rl=zt.pick({slug:!0,image:!0,translations:!0}).extend({defaultLocale:d.z.string().min(1,"Default locale is required").openapi({description:"The default locale for the product category"}),imageId:d.z.string().cuid().optional().nullable().openapi({description:"ID of the image for the product category"})}).partial().superRefine(Aa("title")).openapi("UpdateProductCategory"),Ys=d.z.object({id:d.z.string().cuid().optional(),title:d.z.string().min(1,"This field is required").openapi({example:"Large",description:"Title of the modifier"}),sku:d.z.coerce.string().optional().openapi({example:"csd9876543210abcdef",description:"Stock Keeping Unit identifier"}),price:d.z.coerce.number().optional().default(0).openapi({example:2.5,description:"Price of the modifier"})}).openapi("Modifier"),ei=d.z.object({id:d.z.string().cuid(),selectMin:d.z.coerce.number().min(0).openapi({example:1,description:"Minimum number of modifiers that can be selected"}),selectMax:d.z.coerce.number().min(0).openapi({example:1,description:"Maximum number of modifiers that can be selected"}),defaultLocale:We.optional(),modifiers:d.z.array(Ys).optional().openapi({}),translations:d.z.array(d.z.object({locale:We,title:d.z.string().optional().openapi({example:"Size",description:"Title of the modifier group"})}))}).openapi("ModifierGroup"),sl=ei.extend({title:d.z.string().default("").nullable()}).omit({translations:!0}).openapi("LocalizedModifierGroup"),ai=d.z.object({selectMin:d.z.coerce.number().min(0).openapi({example:1,description:"Minimum number of modifiers that can be selected"}),selectMax:d.z.coerce.number().min(0).openapi({example:1,description:"Maximum number of modifiers that can be selected"}),defaultLocale:We.optional(),modifiers:d.z.array(Ys).optional().openapi({}),translations:d.z.array(d.z.object({locale:We,title:d.z.string().optional().openapi({example:"Size",description:"Title of the modifier group"})}))}).refine(a=>a.selectMax>=a.selectMin,{message:"Maximum selections must be greater than or equal to minimum selections",path:["selectMax"]}).refine(a=>{var r;const t=((r=a.modifiers)==null?void 0:r.length)||0;return a.selectMax<=t},{message:"Maximum selections cannot exceed the total number of modifiers",path:["selectMax"]}).superRefine(Aa("title")).openapi("CreateOrUpdateModifierGroup"),ti=d.z.object({id:d.z.string().cuid().openapi({example:"clf9876543210abcdef",description:"ID of the product"}),slug:d.z.string().optional().openapi({example:"premium-watch",description:"Unique slug for the product"}),sku:d.z.string().optional().openapi({example:"PRM-WATCH-01",description:"Stock Keeping Unit identifier"}),availableQuantity:Yo.openapi({example:12,description:"Available stock quantity. Null means unlimited inventory."}),basePrice:ut,discountedBasePrice:Xs,currency:d.z.string().openapi({example:"USD",description:"Currency code for pricing"}),images:d.z.array(ra).optional().openapi({description:"List of product images"}),modifierGroups:d.z.array(ei).optional().openapi({description:"List of product modifier groups"}),categories:d.z.array(zt).openapi({example:["cju0z9k4z0000l1qg5z1z1z"],description:"IDs of associated product categories"}),manufacturerId:d.z.string().cuid().nullable().optional().openapi({description:"ID of associated manufacturer"}),createdAt:d.z.date(),publishedAt:d.z.date().nullable().optional(),translations:d.z.array(d.z.object({locale:We,title:d.z.coerce.string().optional().openapi({example:"Premium Watch",description:"Product name in specified locale"}),description:d.z.string().nullable().optional().openapi({example:"High-quality premium watch",description:"Product description in specified locale"})})).optional(),metadata:d.z.record(d.z.string().min(1,"Key cannot be empty").max(50,"Key too long").regex(/^[a-zA-Z][a-zA-Z0-9_-]*$/,"Key must start with letter and contain only letters, numbers, underscore, or dash"),d.z.string().min(1,"Value cannot be empty").max(200,"Value too long")).optional().nullable()}).openapi("Product"),il=ti.extend({title:d.z.string().default(""),description:d.z.string().nullable().default(""),modifierGroups:d.z.array(sl),categories:d.z.array(d.z.object({id:d.z.string().cuid().openapi({example:"cju0z9k4z0000l1qg5z1z1z",description:"ID of the product category"})})).default([])}).omit({translations:!0}).openapi("LocalizedProduct"),ri=ti.pick({slug:!0,sku:!0,availableQuantity:!0,basePrice:!0,discountedBasePrice:!0,currency:!0,images:!0,manufacturerId:!0,translations:!0,metadata:!0}).extend({defaultLocale:d.z.string().min(1,"Default locale is required").openapi({example:"en-US",description:"Default translation locale"}),modifierGroups:d.z.array(ai).optional().openapi({description:"List of product modifier groups"}),categories:d.z.array(d.z.string()).optional().openapi({example:["cju0z9k4z0000l1qg5z1z1z"],description:"IDs of associated product categories"})}),nl=ri.superRefine((a,t)=>(a.discountedBasePrice!==null&&a.discountedBasePrice!==void 0&&a.discountedBasePrice>a.basePrice&&t.addIssue({code:d.z.ZodIssueCode.custom,path:["discountedBasePrice"],message:"Discounted price cannot exceed base price"}),Aa("title")(a,t))).openapi("CreateProduct"),ol=ri.partial().superRefine((a,t)=>(a.discountedBasePrice!==null&&a.discountedBasePrice!==void 0&&a.basePrice&&a.discountedBasePrice>a.basePrice&&t.addIssue({code:d.z.ZodIssueCode.custom,path:["discountedBasePrice"],message:"Discounted price cannot exceed base price"}),Aa("title")(a,t))).openapi("UpdateProduct"),ll=d.z.record(d.z.string().openapi({example:"clf9876543210abcdef",description:"ID of the product in the cart"}),il),It=d.z.object({productId:d.z.string().cuid().openapi({example:"clf9876543210abcdef",description:"ID of the product in the cart"}),quantity:d.z.number().default(1).optional().openapi({example:2,description:"Quantity of this item in the cart"}),modifierGroups:d.z.array(d.z.object({id:d.z.string().cuid().openapi({example:"clg1234567890abcdef",description:"ID of the modifier group"}),modifiers:d.z.array(d.z.object({id:d.z.string().cuid().openapi({example:"clh9876543210abcdef",description:"ID of the selected modifier"}),quantity:d.z.number().default(1).openapi({example:1,description:"Quantity of this modifier"})}))}))}).openapi("CartItem"),dl=d.z.object({items:d.z.array(It),shippingMethodId:d.z.string().cuid().optional()}),cl=d.z.enum(["invalid_product","out_of_stock","insufficient_stock"]).openapi("CartAdjustmentReason"),ml=d.z.object({productId:d.z.string().cuid().openapi({example:"clf9876543210abcdef",description:"ID of the affected product"}),modifierGroups:It.shape.modifierGroups.optional(),reason:cl,requestedQuantity:d.z.number().int().min(0).openapi({example:3,description:"Quantity requested by the customer"}),resolvedQuantity:d.z.number().int().min(0).openapi({example:1,description:"Quantity accepted after stock normalization"})}).openapi("CartAdjustment"),ul=d.z.object({invalidProductIds:d.z.array(d.z.string()),normalizedItems:d.z.array(It),adjustments:d.z.array(ml),products:ll,shipping:d.z.number().optional(),subtotal:d.z.number(),total:d.z.number()});ul.extend({message:d.z.string()}).openapi("CartConflict"),d.z.object({status:d.z.number().openapi({example:404,description:"The HTTP status code"}),message:d.z.string().openapi({example:"Not found",description:"The error message"})}),d.z.object({"accept-language":d.z.string().optional().openapi({example:"en-US",description:"Accept-Language header",param:{in:"header",name:"accept-language"}}),cookie:d.z.string().optional().openapi({example:"session=1234567890",description:"Cookie header",param:{in:"header",name:"cookie"}})}).openapi("Headers");const pl=d.z.string().min(1).openapi({example:"stripe",description:"Integration type key"}),or=d.z.enum(["card","blik"]).openapi({example:"card",description:"Stripe payment method"});d.z.object({paymentMethods:d.z.array(or).max(2).optional(),secretKey:d.z.string().trim().min(1).optional(),webhookSecret:d.z.string().trim().min(1).optional()}).strict(),d.z.object({apiKey:d.z.string().trim().min(1).optional(),fromEmail:d.z.string().trim().email().optional()}).strict();const Et=d.z.object({paymentMethods:d.z.array(or).max(2).openapi({example:["card","blik"],description:"Enabled Stripe payment methods for the organization"}),hasSecretKey:d.z.boolean().openapi({example:!0,description:"Whether the Stripe API key has been configured"}),hasWebhookSecret:d.z.boolean().openapi({example:!0,description:"Whether the Stripe webhook signing secret has been configured"})}).strict().openapi("StripeIntegrationConfig"),gl=d.z.object({paymentMethods:d.z.array(or).max(2).openapi({example:["card","blik"],description:"Enabled Stripe payment methods for the organization"}),secretKey:d.z.string().trim().min(1).optional().openapi({example:"sk_live_123456789",description:"Stripe secret API key for the organization"}),webhookSecret:d.z.string().trim().min(1).optional().openapi({example:"whsec_123456789",description:"Stripe webhook signing secret for the organization"})}).strict().openapi("UpsertStripeIntegrationConfig"),Dt=d.z.object({hasApiKey:d.z.boolean().openapi({example:!0,description:"Whether the Resend API key has been configured"}),fromEmail:d.z.string().trim().email().optional().openapi({example:"orders@example.com",description:"Verified sender email used for transactional messages"})}).strict().openapi("ResendIntegrationConfig"),hl=d.z.object({apiKey:d.z.string().trim().min(1).optional().openapi({example:"re_123456789",description:"Resend API key for the organization"}),fromEmail:d.z.string().trim().email().optional().openapi({example:"orders@example.com",description:"Verified sender email used for transactional messages"})}).strict().openapi("UpsertResendIntegrationConfig"),xl=d.z.record(d.z.string(),d.z.unknown()).openapi("IntegrationConfig");d.z.object({organizationId:d.z.string().openapi({example:"clm1234567890abcdef",description:"Organization ID"}),type:pl,config:xl.openapi({description:"Stored integration configuration JSON"}),createdAt:d.z.date().openapi({description:"Timestamp when the integration was created"}),updatedAt:d.z.date().openapi({description:"Timestamp when the integration was last updated"})}).openapi("Integration"),d.z.object({config:d.z.unknown().openapi({example:{paymentMethods:["card","blik"],secretKey:"sk_live_123456789",webhookSecret:"whsec_123456789"},description:"Integration configuration payload. Validation depends on the integration type."})}).openapi("UpsertIntegration");const fl=d.z.object({id:d.z.string().openapi({example:"clm1234567890abcdef",description:"User's ID"}),email:d.z.string().openapi({example:"user@example.com",description:"User's email address",format:"email"}),firstname:d.z.string().openapi({example:"John",description:"User's first name"}),lastname:d.z.string().openapi({example:"Doe",description:"User's last name"}),image:d.z.string().nullable().optional().openapi({example:"https://example.com/image.jpg",description:"User's profile image"}),name:d.z.string().nullable().optional().openapi({description:"User's full name (optional)"})}).openapi("User"),Xr=d.z.object({page:d.z.coerce.number().optional().default(1).openapi({example:1,description:"Page number"}),limit:d.z.coerce.number().optional().default(10).openapi({example:50,description:"Number of items per page"}),search:d.z.string().optional().openapi({example:"Apple",description:"Search query"}),published:d.z.coerce.boolean().optional().openapi({example:!0,description:"Whether to filter by published items"}),locale:We.optional()});d.z.object({isFirstPage:d.z.boolean().openapi({example:!0,description:"Whether the current page is the first page"}),isLastPage:d.z.boolean().openapi({example:!1,description:"Whether the current page is the last page"}),currentPage:d.z.number().openapi({example:1,description:"The current page number"}),previousPage:d.z.number().nullable().openapi({example:0,description:"The previous page number"}),nextPage:d.z.number().nullable().openapi({example:2,description:"The next page number"}),pageCount:d.z.number().openapi({example:5,description:"The total number of pages"}),totalCount:d.z.number().openapi({example:50,description:"The total number of items"})}).openapi("PaginationMeta");const Ca=d.z.object({id:d.z.string().cuid().openapi({example:"clf9876543210abcdef",description:"The unique identifier of the address"}),firstname:d.z.string().optional().nullable().openapi({example:"John",description:"The first name of the recipient"}),lastname:d.z.string().optional().nullable().openapi({example:"Doe",description:"The last name of the recipient"}),phone:d.z.string().optional().nullable().openapi({example:"+1234567890",description:"Phone number of the recipient"}),addressLineOne:d.z.string().openapi({example:"123 Main Street",description:"The first line of the address"}),doorNumber:d.z.string().nullable().optional().openapi({description:"The door number of the address"}),addressLineTwo:d.z.string().nullable().optional().openapi({example:"Suite 100",description:"The second line of the address"}),zipCode:d.z.string().optional().openapi({example:"12345",description:"The postal code of the address"}),city:d.z.string().openapi({example:"New York",description:"The city of the address"}),country:d.z.string().openapi({example:"USA",description:"The country of the address"}),placeId:d.z.string().openapi({example:"ChIJN1t_tKlj4AR4GeTYWZ7frY",description:"The Google Place ID for the address"}),deliveryInstructions:d.z.string().nullable().optional().openapi({example:"Leave at the door",description:"Delivery instructions for the address"})}).openapi("Address"),Rt=Ca.pick({addressLineOne:!0,doorNumber:!0,addressLineTwo:!0,zipCode:!0,city:!0,country:!0,placeId:!0}).openapi("CreateAddress"),si=Rt.partial().openapi("UpdateAddress"),yl=Ca.extend({firstname:d.z.string().min(2,"First Name must be at least 2 characters").openapi({example:"John",description:"The first name of the recipient"}),lastname:d.z.string().min(1,"Last Name must be at least 2 characters").openapi({example:"Doe",description:"The last name of the recipient"}),phone:d.z.string().min(4).openapi({example:"+1234567890",description:"Phone number of the recepient"})}),ii=yl.pick({firstname:!0,lastname:!0,phone:!0,addressLineOne:!0,addressLineTwo:!0,doorNumber:!0,zipCode:!0,city:!0,country:!0,placeId:!0,deliveryInstructions:!0});ii.partial().extend({placeId:d.z.string().min(1,"This field is required").openapi({example:"ChIJN1t_tKlj4AR4GeTYWZ7frY",description:"The Google Place ID for the address"})}).openapi("UpdateShippingAddress");const lr=d.z.enum(["card","blik","cash_on_delivery","paypal"]).openapi({description:"The payment method",example:"card"}),dr=d.z.enum(["stripe","revolut","payu","not_applicable"]).openapi({description:"The payment method",example:"card"}),bl=d.z.enum(["pending","succeeded","refunded","failed","canceled"]).openapi({description:"The payment status",example:"pending"});d.z.object({id:d.z.string().min(1),provider:dr,method:lr,description:d.z.string().min(1)}).openapi({description:"The payment method",example:{provider:"stripe",type:"card"}});const jl=d.z.object({id:d.z.string().cuid().min(1),method:lr,provider:dr,status:bl,shipping:d.z.number().min(0).default(0),subtotal:d.z.number().min(0),total:d.z.number().min(0),discount:d.z.number().min(0).default(0),currency:Ct}),Yr=d.z.object({id:d.z.string().optional().openapi({example:"clf9876543210abcdef",description:"ID of the shipping zone"}),title:d.z.string().min(1,"Title is required").openapi({example:"Zone 1",description:"Title of the shipping zone"}),distanceUpto:ut.openapi({example:10,description:"Ending distance for the shipping zone"}),price:ut.openapi({example:5.99,description:"Price for shipping in this zone"}),minimumOrderAmount:Xs.openapi({example:50,description:"Minimum order amount for this shipping zone"}),eta:d.z.string().min(1,"ETA is required").openapi({example:"2-3 days",description:"Estimated time of arrival for this shipping zone"})}).openapi("ShippingZone"),ni=d.z.object({id:d.z.string().openapi({example:"clf9876543210abcdef",description:"ID of the shipping method"}),title:d.z.string().min(1,"Title is required").openapi({example:"Standard Shipping",description:"Title of the shipping method"}),providerName:d.z.string().min(1,"Provider name is required").openapi({example:"FedEx",description:"Name of the shipping provider"}),providerLogo:ra.nullable().optional().openapi({description:"Logo of the shipping provider"}),requireDateOfDelivery:d.z.coerce.boolean().optional().openapi({example:!0,description:"Whether the delivery time should be selected"}),shippingZones:d.z.array(Yr).openapi({description:"List of shipping zones for this shipping method"}),eligibleShippingZone:Yr.optional(),createdAt:d.z.date(),updatedAt:d.z.date()}).openapi("ShippingMethod"),oi=ni.pick({title:!0,providerName:!0,providerLogo:!0,requireDateOfDelivery:!0,shippingZones:!0}).extend({providerLogoId:d.z.string().cuid().optional().openapi({example:"clf9876543210abcdef",description:"ID reference to the provider logo file"})}).openapi("CreateShippingMethod"),vl=oi.partial().openapi("UpdateShippingMethod"),wl=d.z.enum(["draft","pending","accepted","ready-for-dispatch","dispatched","completed","cancelled"]).openapi({description:"Status of the order",example:"accepted"}),kl=d.z.object({translations:d.z.array(d.z.object({locale:We.openapi({description:"Locale of the translation",example:"en-US"}),title:d.z.string().openapi({description:"Title of the ordered product",example:"Premium Watch"}),subtitle:d.z.string().openapi({description:"Additional details about the ordered item, including modifiers",example:"Color: Silver, Size: Large"})})).openapi({description:"Translations for the order item"}),rawData:It,unitPrice:d.z.number().min(0).openapi({description:"Price per unit of the item",example:299.99}),image:ra.nullable().optional(),totalPrice:d.z.number().min(0).openapi({description:"Total price for this item (unitPrice × quantity)",example:599.98}),quantity:d.z.number().min(1).openapi({description:"Number of units ordered",example:2}),productSnapshotId:d.z.string().cuid()}).openapi("OrderItem"),Nl=d.z.object({productId:d.z.string().cuid(),title:d.z.string(),requestedQuantity:d.z.number().int().min(1),availableQuantity:d.z.number().int().min(0)}).openapi("InventoryConflictItem"),Al=d.z.object({id:d.z.string().openapi({description:"Unique identifier for the order",example:"clj1234567890abcdef"}),referenceId:d.z.string().openapi({description:"External reference ID for the order",example:"ORD-12345"}),status:wl.optional(),token:d.z.string().openapi({description:"Security token for order verification",example:"a1b2c3d4e5f6g7h8i9j0"}),expiresAt:d.z.date().openapi({description:"Expiration date for the order",example:"2023-12-31T23:59:59Z"}),items:d.z.array(kl).min(1).openapi({description:"Array of items in the order"}),shippingMethod:ni.nullable().openapi({description:"Shipping method selected for the order"}),acceptedAt:d.z.date().nullable().optional().openapi({description:"Date when the order was accepted",example:"2023-06-15T14:30:00Z"}),dispatchedAt:d.z.date().nullable().optional().openapi({description:"Date when the order was dispatched",example:"2023-06-16T09:15:00Z"}),readyForDispatchAt:d.z.date().nullable().optional().openapi({description:"Date when the order was ready for dispatch",example:"2023-06-16T09:15:00Z"}),createdAt:d.z.date().openapi({description:"Date when the order was created",example:"2023-06-15T14:30:00Z"}),completedAt:d.z.date().nullable().optional().openapi({description:"Date when the order was completed",example:"2023-06-18T11:45:00Z"}),cancelledAt:d.z.date().nullable().optional().openapi({description:"Date when the order was cancelled",example:"2023-06-14T16:20:00Z"}),inventoryDeductedAt:d.z.date().nullable().optional().openapi({description:"Date when the paid order inventory was deducted",example:"2023-06-15T14:30:00Z"}),inventoryConflictAt:d.z.date().nullable().optional().openapi({description:"Date when the paid order was flagged for manual inventory review",example:"2023-06-15T14:30:00Z"}),inventoryConflictItems:d.z.array(Nl).nullable().optional().openapi({description:"List of line items that could not be deducted after payment"}),shippingAddress:Ca.nullable().optional(),fulfilmentMethod:nr.openapi({description:"Method of order fulfilment (pickup or delivery)",example:"delivery"}),currency:Ct.openapi({description:"Currency used for the order",example:"USD"}),payment:jl}).transform(a=>{let t;return a.cancelledAt?t="cancelled":a.completedAt?t="completed":a.dispatchedAt?t="dispatched":a.readyForDispatchAt?t="ready-for-dispatch":a.acceptedAt?t="accepted":t="pending",{...a,status:t}}).openapi("Order");dl.extend({fulfilmentMethod:nr.default("delivery"),payment:d.z.object({provider:dr,method:lr}),checkoutBaseUrl:d.z.string().url()}).refine(a=>a.fulfilmentMethod!=="delivery"||a.shippingMethodId!==void 0,{message:"shippingMethodId is required when fulfilmentMethod is 'delivery'",path:["shippingMethodId"]}).openapi("CreateOrder");const es=d.z.object({monday:d.z.string().nullable().openapi({example:"09:00",description:"Opening time for Monday"}),tuesday:d.z.string().nullable().openapi({example:"09:00",description:"Opening time for Tuesday"}),wednesday:d.z.string().nullable().openapi({example:"09:00",description:"Opening time for Wednesday"}),thursday:d.z.string().nullable().openapi({example:"09:00",description:"Opening time for Thursday"}),friday:d.z.string().nullable().openapi({example:"09:00",description:"Opening time for Friday"}),saturday:d.z.string().nullable().openapi({example:"09:00",description:"Opening time for Saturday"}),sunday:d.z.string().nullable().openapi({example:"09:00",description:"Opening time for Sunday"})}).openapi("TimeSchedule"),li=d.z.object({id:d.z.string().openapi({example:"clm1234567890abcdef",description:"Unique identifier for the organization configuration"}),hostname:d.z.coerce.string().optional().openapi({example:"store.example.com",description:"Hostname associated with the organization"}),countriesShipping:d.z.array(d.z.string()).openapi({example:["US","CA"],description:"List of countries where shipping is available"}),stripeAccountId:d.z.coerce.string().optional().openapi({example:"acct_123456789",description:"Stripe account ID associated with the organization"}),enableHostCheckout:d.z.boolean().openapi({example:!0,description:"Indicates if host checkout is enabled"}),enableHostTracking:d.z.boolean().openapi({example:!0,description:"Indicates if host tracking is enabled"}),isAcceptingOrders:d.z.boolean().openapi({example:!0,description:"Indicates if the organization is currently accepting orders"}),isAcceptingReservations:d.z.boolean().openapi({example:!0,description:"Indicates if the organization is currently accepting reservations"}),isOpen:d.z.boolean().default(!1).openapi({example:!0,description:"Indicates if the organization is currently open"}),defaultLocale:We,supportedLocales:d.z.array(We).openapi({description:"List of supported locales for the organization"}),openingTimes:es.optional(),closingTimes:es.optional(),facebookProfile:d.z.string().nullable().optional().openapi({example:"https://www.facebook.com/example",description:"Facebook profile URL for the organization"}),instagramProfile:d.z.string().nullable().optional().openapi({example:"https://www.instagram.com/example",description:"Instagram profile URL for the organization"}),xProfile:d.z.string().nullable().optional().openapi({example:"https://www.x.com/example",description:"X profile URL for the organization"}),defaultCurrency:Ct.openapi({example:"USD",description:"Default currency for the organization"}),createdAt:d.z.date().openapi({description:"Timestamp when the organization configuration was created"})}).openapi("OrganizationConfiguration"),Cl=li.pick({hostname:!0,countriesShipping:!0,stripeAccountId:!0,enableHostCheckout:!0,enableHostTracking:!0,isAcceptingOrders:!0,isAcceptingReservations:!0,defaultLocale:!0,supportedLocales:!0,defaultCurrency:!0,openingTimes:!0,closingTimes:!0,facebookProfile:!0,instagramProfile:!0,xProfile:!0}).partial().openapi("UpdateOrganizationConfiguration"),Sl=d.z.object({id:d.z.string().openapi({example:"clm1234567890abcdef",description:"The unique identifier of the organization"}),name:d.z.string().openapi({example:"Acme Store",description:"The name of the organization"}),phone:d.z.string().min(1,"Phone number is required").openapi({example:"+48123456890",description:"The phone number of the organization"}),email:d.z.string().email().optional().openapi({example:"john.doe@example.com",description:"The email address of the organization"}),createdAt:d.z.date().openapi({example:"2022-01-01T00:00:00.000Z",description:"The date and time the organization was created"}),legalEntityId:d.z.string().nullable().openapi({example:"clm1234567890abcdef",description:"The unique identifier of the legal entity associated with the organization"}),address:Ca,configuration:li.openapi({description:"The configuration settings for the organization"}),logo:d.z.string().url().optional().nullable().openapi({example:"https://example.com/logo.jpg",description:"The logo of the organization"}),logoFile:ra.optional().nullable().openapi({description:"The logo of the organization"})}).openapi("Organization"),di=Sl.pick({name:!0,phone:!0,email:!0,logoFile:!0}).extend({logoId:d.z.string().optional().nullable().openapi({example:"clm1234567890abcdef",description:"The unique identifier of the thumbnail image associated with the organization"}),address:Rt}).openapi("CreateOrganization"),cr=di.extend({address:si,configuration:Cl}).partial().openapi("UpdateOrganization"),zl=d.z.object({id:d.z.string().openapi({example:"clf9876543210abcdef",description:"ID of the manufacturer"}),name:d.z.string().openapi({example:"Tech Innovators Inc.",description:"Name of the manufacturer"}),logo:ra.nullable().optional().openapi({description:"Logo of the manufacturer"}),createdAt:d.z.date(),translations:d.z.array(d.z.object({locale:d.z.string().min(1,"Locale is required").openapi({example:"en-US",description:"Locale code for the translation"}),about:d.z.string().max(6e3,"Maximum character limit is 6000").nullable().optional().openapi({example:"Tech Innovators Inc. is a technology company.",description:"Description about the manufacturer in the specified locale"})})).optional().openapi({description:"List of translations for the manufacturer"})}).openapi("Manufacturer");zl.omit({translations:!0}).extend({about:d.z.string().nullable().optional().default("")}).openapi("LocalizedManufacturer");const Il=d.z.object({name:d.z.string().min(1,"Name is required").openapi({example:"Apple Inc.",description:"Name of the manufacturer"}),defaultLocale:d.z.string().min(1,"Default locale is required").openapi({example:"en-US",description:"The default locale for the manufacturer"}),logo:ra.nullable().optional().openapi({description:"Logo of the manufacturer"}),translations:d.z.array(d.z.object({locale:d.z.string().min(1,"Locale is required").openapi({example:"en-US",description:"Locale code for the translation"}),about:d.z.string().max(6e3,"Maximum character limit is 6000").nullable().optional().openapi({example:"Apple Inc. is a multinational technology company.",description:"Description about the manufacturer in the specified locale"})})).min(1,"Translations are required").openapi({description:"List of translations for the manufacturer"}),logoId:d.z.string().optional().openapi({example:"clf9876543210abcdef",description:"ID reference to the manufacturer's logo file"})}).superRefine(Aa("about")).openapi("CreateManufacturer"),El=d.z.object({name:d.z.string().min(1,"Name is required").optional().openapi({example:"Apple Inc. Updated",description:"Name of the manufacturer"}),logo:ra.nullable().optional().openapi({description:"Logo of the manufacturer"}),defaultLocale:d.z.string().min(1,"Default locale is required").openapi({description:"The default locale for the manufacturer"}),logoId:d.z.string().nullable().optional().openapi({example:"clf9876543210abcdef",description:"ID reference to the manufacturer's logo file"}),translations:d.z.array(d.z.object({locale:d.z.string().min(1,"Locale is required").openapi({example:"en-US",description:"Locale code for the translation"}),about:d.z.string().max(6e3,"Maximum character limit is 6000").nullable().optional().openapi({example:"Apple Inc. is a multinational technology company.",description:"Description about the manufacturer in the specified locale"})})).optional().openapi({description:"List of translations for the manufacturer"})}).openapi("UpdateManufacturer");d.z.object({id:d.z.string().openapi({example:"clm1234567890abcdef",description:"The unique identifier of the legal entity"}),name:d.z.string().openapi({example:"Acme Corporation",description:"The name of the legal entity"}),taxId:d.z.string().min(2).max(20).openapi({example:"PL1234567890",description:"The TAX ID of the legal entity"}),email:d.z.string().email().nullable().openapi({example:"contact@acme.com",description:"The email of the legal entity",format:"email"}),phone:d.z.string().nullable().openapi({example:"+48123456789",description:"The phone number of the legal entity"}),createdAt:d.z.date().openapi({description:"The date and time when the legal entity was created",format:"date-time"}),address:Ca.required().openapi({description:"The address of the legal entity"})}).openapi("LegalEntity"),d.z.object({name:d.z.string().min(1,"Name is required").openapi({example:"Acme Corporation",description:"The name of the legal entity"}),taxId:d.z.string().min(2).max(20).openapi({example:"PL1234567890",description:"The TAX ID of the legal entity"}),email:d.z.string().email().optional().openapi({example:"contact@acme.com",description:"The email of the legal entity",format:"email"}),phone:d.z.string().optional().openapi({example:"+48123456789",description:"The phone number of the legal entity"}),address:Rt.required().openapi({description:"The address of the legal entity"})}).openapi("CreateLegalEntity"),d.z.object({name:d.z.string().min(1,"Name is required").optional().openapi({example:"Acme Corporation",description:"The name of the legal entity"}),taxId:d.z.string().min(2).max(20).openapi({example:"PL1234567890",description:"The TAX ID of the legal entity"}),email:d.z.string().email().optional().openapi({example:"contact@acme.com",description:"The email of the legal entity",format:"email"}),phone:d.z.string().optional().openapi({example:"+48123456789",description:"The phone number of the legal entity"}),address:si.required().openapi({description:"The address of the legal entity"})}).openapi("UpdateLegalEntity");const Dl=d.z.object({id:d.z.string().openapi({example:"clf9876543210abcdef",description:"ID of the customer"}),firstname:d.z.string().nullable().optional().openapi({example:"John Doe",description:"Name of the customer"}),email:d.z.string().nullable().optional().openapi({example:"john.doe@example.com",description:"Email of the customer"}),phone:d.z.string().nullable().optional().openapi({example:"+1234567890",description:"Phone number of the customer"}),address:Ca.nullable().optional().openapi({description:"Address of the customer"}),createdAt:d.z.date(),updatedAt:d.z.date()}).openapi("Customer"),Rl=Dl.pick({firstname:!0,email:!0,phone:!0}).extend({address:Rt}).openapi("Customer");Rl.partial().openapi("UpdateCustomer");const mr=d.z.object({email:d.z.string().min(1,"Email is required").email("Invalid email").openapi({example:"user@example.com",description:"User's email address"}),password:d.z.string().min(1,"Password is required").min(8,"Password must be more than 8 characters").max(32,"Password must be less than 32 characters").openapi({example:"password123",description:"User's password"}),firstname:d.z.string().min(1,"First name is required").max(32,"First name must be less than 32 characters").openapi({example:"John",description:"User's first name"}),lastname:d.z.string().min(1,"Last name is required").max(32,"Last name must be less than 32 characters").openapi({example:"Doe",description:"User's last name"})}).openapi("SignUp"),ci=mr.pick({email:!0,password:!0}).openapi("SignIn"),Fl=d.z.object({organizationId:d.z.string().cuid().min(1,"organizationId is required").openapi({example:"ckel0e8qw00004n5p5w6fznym",description:"The organization ID"})}).openapi("OrganizationParams");Fl.extend({id:d.z.string().cuid().min(1,"id is required").openapi({example:"ckel0e8qw00004n5p5w6fznym",description:"The organization ID"})}).openapi("OrganizationWithIdParams"),d.z.object({placeId:d.z.string().openapi({example:"ChIJN1t_tKlj4AR4GeTYWZ7frY",description:"The Google Place ID for the address"}),text:d.z.string().openapi({example:"123 Main Street, New York, USA",description:"The description of the place"}),addressLineOne:d.z.string().openapi({example:"123 Main Street",description:"The first line of the address"}),addressLineTwo:d.z.string().optional().openapi({example:"Suite 100",description:"The second line of the address"}),latitude:d.z.number().optional().openapi({example:40.712776,description:"The latitude of the coordinate"}),longitude:d.z.number().optional().openapi({example:-74.005974,description:"The longitude of the coordinate"})}).openapi("Place"),d.z.object({addressLineOne:d.z.string().openapi({example:"123 Main Street",description:"The first line of the address"}),zipCode:d.z.string().optional().openapi({example:"12345",description:"The postal code of the address"}),city:d.z.string().openapi({example:"New York",description:"The city of the address"}),country:d.z.string().openapi({example:"USA",description:"The ISO 3166-1 alpha-2 country code"})}).openapi("PlaceDetails");const Kt=a=>d.z.any().transform(t=>typeof t=="string"?t.trim():"").refine(t=>t.length>0,{message:`${a} is required`}),Ml=d.z.any().transform(a=>a==null||a===""?Number.NaN:Number(a)).refine(a=>Number.isFinite(a)&&a>0,{message:"Number of guests is required"}),Pl=d.z.any().refine(a=>a!=null&&a!=="",{message:"Reservation date is required"}).transform(a=>new Date(a)).refine(a=>!Number.isNaN(a.getTime()),{message:"Reservation date is required"}),mi=d.z.object({id:d.z.string().openapi({description:"Unique identifier for the order",example:"clj1234567890abcdef"}),firstname:d.z.string().openapi({description:"Customer's first name",example:"John"}),lastname:d.z.string().openapi({description:"Customer's last name",example:"Doe"}),guests:ut,phone:d.z.string().openapi({description:"Customer's phone number",example:"+1234567890"}),date:d.z.coerce.date().openapi({description:"Reservation date and time",example:"2023-06-14T16:20:00Z"}),referenceId:d.z.string().openapi({description:"External reference ID for the order",example:"ORD-12345"}),acceptedAt:d.z.date().nullable().optional().openapi({description:"Date when the order was accepted",example:"2023-06-15T14:30:00Z"}),cancelledAt:d.z.date().nullable().optional().openapi({description:"Date when the order was cancelled",example:"2023-06-14T16:20:00Z"}),createdAt:d.z.date().nullable().optional().openapi({description:"Date when the order was created",example:"2023-06-14T16:20:00Z"})}).openapi("Reservation"),ui=mi.pick({firstname:!0,lastname:!0,guests:!0,phone:!0,date:!0}).extend({firstname:Kt("First name").openapi({description:"Customer's first name",example:"John"}),lastname:Kt("Last name").openapi({description:"Customer's last name",example:"Doe"}),guests:Ml.openapi({description:"Number of guests included in the reservation",example:2}),phone:Kt("Phone number").openapi({description:"Customer's phone number",example:"+1234567890"}),date:Pl.openapi({description:"Reservation date and time",example:"2023-06-14T16:20:00Z"})}).openapi("CreateReservation"),Bl=ui.pick({firstname:!0,lastname:!0,guests:!0,date:!0}).openapi("UpdateReservation");Xr.extend({from:d.z.coerce.date().optional().openapi({description:"Filter reservations scheduled from this date and time",example:"2026-03-01T00:00:00.000Z"}),to:d.z.coerce.date().optional().openapi({description:"Filter reservations scheduled up to this date and time",example:"2026-03-31T23:59:59.999Z"})}).openapi("ReservationListQuery"),Xr.pick({page:!0,limit:!0,search:!0}).openapi("AdminCustomerListQuery");const Tl=fl.extend({createdAt:d.z.date().openapi({description:"Date when the customer account was created",example:"2026-03-29T12:00:00.000Z"}),orderCount:d.z.number().int().min(0).openapi({description:"Number of orders placed by the customer in this organization",example:3}),reservationCount:d.z.number().int().min(0).openapi({description:"Number of reservations created by the customer in this organization",example:2})}).openapi("AdminCustomer");d.z.object({customer:Tl,orders:d.z.array(Al),reservations:d.z.array(mi)}).openapi("AdminCustomerDetail");function pa(...a){return Cs.twMerge(As(...a))}const pi=["focus:ring-2","focus:ring-blue-200 dark:focus:ring-blue-700/30","focus:border-blue-500 dark:focus:border-blue-700"],Sa=["outline outline-offset-2 outline-0 focus-visible:outline-2","outline-blue-500 dark:outline-blue-500"],Ql=["ring-2","border-red-500 dark:border-red-700","ring-red-200 dark:ring-red-700/30"],gi=Le.tv({base:["relative inline-flex items-center justify-center whitespace-nowrap rounded-lg border px-3 py-2 text-center text-sm font-medium shadow-2xs transition-all duration-100 ease-in-out cursor-pointer","disabled:pointer-events-none disabled:shadow-none disabled:cursor-not-allowed",Sa],variants:{variant:{primary:["border-transparent","storefront-primary-action"],secondary:["border-gray-200 dark:border-gray-800","text-gray-900 dark:text-gray-50","bg-white dark:bg-gray-950","hover:bg-gray-50 dark:hover:bg-gray-900/60","disabled:text-gray-400","dark:disabled:text-gray-600"],light:["shadow-none","border-transparent","text-gray-900 dark:text-gray-50","bg-gray-200 dark:bg-gray-900","hover:bg-gray-300/70 dark:hover:bg-gray-800/80","disabled:bg-gray-100 disabled:text-gray-400","dark:disabled:bg-gray-800 dark:disabled:text-gray-600"],ghost:["shadow-none","border-transparent","text-gray-900 dark:text-gray-50","bg-transparent hover:bg-gray-100 dark:hover:bg-gray-800/80","disabled:text-gray-400","dark:disabled:text-gray-600"],destructive:["text-white","border-transparent","bg-red-600 dark:bg-red-700","hover:bg-red-700 dark:hover:bg-red-600","disabled:bg-red-300 disabled:text-white","dark:disabled:bg-red-950 dark:disabled:text-red-400"]}},defaultVariants:{variant:"primary"}}),te=x.forwardRef(({asChild:a,isLoading:t=!1,loadingText:r,className:s,disabled:i,variant:n,children:o,...l},c)=>{const m=a?tr.Slot:"button";return e.jsx(m,{ref:c,className:w(gi({variant:n}),s),disabled:i||t,...l,children:t?e.jsxs("span",{className:"pointer-events-none flex shrink-0 items-center justify-center gap-1.5",children:[e.jsx(P.RiLoader2Fill,{className:"size-4 shrink-0 animate-spin","aria-hidden":"true"}),e.jsx("span",{className:"sr-only",children:r||"Loading"}),r||"Loading"]}):o})});te.displayName="Button";const as=[{continent:"America",items:[{value:"US",label:"United States",flag:"🇺🇸"},{value:"CA",label:"Canada",flag:"🇨🇦"},{value:"MX",label:"Mexico",flag:"🇲🇽"},{value:"BR",label:"Brazil",flag:"🇧🇷"},{value:"AR",label:"Argentina",flag:"🇦🇷"},{value:"CO",label:"Colombia",flag:"🇨🇴"},{value:"CL",label:"Chile",flag:"🇨🇱"},{value:"PE",label:"Peru",flag:"🇵🇪"}]},{continent:"Europe",items:[{value:"GB",label:"United Kingdom",flag:"🇬🇧"},{value:"FR",label:"France",flag:"🇫🇷"},{value:"DE",label:"Germany",flag:"🇩🇪"},{value:"PL",label:"Poland",flag:"🇵🇱"},{value:"IT",label:"Italy",flag:"🇮🇹"},{value:"ES",label:"Spain",flag:"🇪🇸"},{value:"NL",label:"Netherlands",flag:"🇳🇱"},{value:"PT",label:"Portugal",flag:"🇵🇹"},{value:"SE",label:"Sweden",flag:"🇸🇪"},{value:"NO",label:"Norway",flag:"🇳🇴"},{value:"DK",label:"Denmark",flag:"🇩🇰"},{value:"FI",label:"Finland",flag:"🇫🇮"},{value:"CH",label:"Switzerland",flag:"🇨🇭"},{value:"IE",label:"Ireland",flag:"🇮🇪"},{value:"BE",label:"Belgium",flag:"🇧🇪"},{value:"AT",label:"Austria",flag:"🇦🇹"},{value:"GR",label:"Greece",flag:"🇬🇷"}]},{continent:"Asia",items:[{value:"CN",label:"China",flag:"🇨🇳"},{value:"JP",label:"Japan",flag:"🇯🇵"},{value:"IN",label:"India",flag:"🇮🇳"},{value:"KR",label:"South Korea",flag:"🇰🇷"},{value:"SG",label:"Singapore",flag:"🇸🇬"},{value:"MY",label:"Malaysia",flag:"🇲🇾"},{value:"ID",label:"Indonesia",flag:"🇮🇩"},{value:"TH",label:"Thailand",flag:"🇹🇭"},{value:"VN",label:"Vietnam",flag:"🇻🇳"},{value:"AE",label:"United Arab Emirates",flag:"🇦🇪"},{value:"SA",label:"Saudi Arabia",flag:"🇸🇦"}]},{continent:"Oceania",items:[{value:"AU",label:"Australia",flag:"🇦🇺"},{value:"NZ",label:"New Zealand",flag:"🇳🇿"},{value:"FJ",label:"Fiji",flag:"🇫🇯"},{value:"PG",label:"Papua New Guinea",flag:"🇵🇬"}]},{continent:"Africa",items:[{value:"ZA",label:"South Africa",flag:"🇿🇦"},{value:"NG",label:"Nigeria",flag:"🇳🇬"},{value:"MA",label:"Morocco",flag:"🇲🇦"},{value:"EG",label:"Egypt",flag:"🇪🇬"},{value:"KE",label:"Kenya",flag:"🇰🇪"},{value:"GH",label:"Ghana",flag:"🇬🇭"},{value:"ET",label:"Ethiopia",flag:"🇪🇹"}]}],Ft=a=>e.jsx(re.Root,{...a});Ft.displayName="Dialog";const hi=re.Trigger;hi.displayName="DialogTrigger";const xi=re.Close;xi.displayName="DialogClose";const fi=re.Portal;fi.displayName="DialogPortal";const yi=x.forwardRef(({className:a,...t},r)=>e.jsx(re.Overlay,{ref:r,className:w("fixed inset-0 z-50 overflow-y-auto","bg-black/70","data-[state=open]:animate-dialogOverlayShow",a),...t}));yi.displayName="DialogOverlay";const Mt=x.forwardRef(({className:a,...t},r)=>e.jsx(fi,{children:e.jsx(yi,{children:e.jsx(re.Content,{ref:r,className:w("fixed left-1/2 top-1/2 z-50 w-[100vw] max-w-lg -translate-x-1/2 -translate-y-1/2 overflow-y-auto rounded-md border p-6 shadow-lg","border-gray-200 dark:border-gray-900","bg-white dark:bg-[#090E1A]","data-[state=open]:animate-dialogContentShow",Sa,a),...t})})}));Mt.displayName="DialogContent";const bi=({className:a,...t})=>e.jsx("div",{className:w("flex flex-col gap-y-1",a),...t});bi.displayName="DialogHeader";const ur=x.forwardRef(({className:a,...t},r)=>e.jsx(re.Title,{ref:r,className:w("text-lg font-semibold","text-gray-900 dark:text-gray-50",a),...t}));ur.displayName="DialogTitle";const ji=x.forwardRef(({className:a,...t},r)=>e.jsx(re.Description,{ref:r,className:w("text-gray-500 dark:text-gray-500",a),...t}));ji.displayName="DialogDescription";const vi=({className:a,...t})=>e.jsx("div",{className:w("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...t});vi.displayName="DialogFooter";const $a=z.forwardRef(({className:a,...t},r)=>e.jsx(G.Command,{ref:r,className:w("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",a),...t}));$a.displayName=G.Command.displayName;const Ol=({children:a,...t})=>e.jsx(Ft,{...t,children:e.jsx(Mt,{className:"overflow-hidden p-0",children:e.jsx($a,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:a})})}),Pt=z.forwardRef(({className:a,...t},r)=>e.jsxs("div",{className:"flex items-center border-b pl-3","cmdk-input-wrapper":"",children:[e.jsx(N.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(G.Command.Input,{ref:r,className:w("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",a),...t})]}));Pt.displayName=G.Command.Input.displayName;const Bt=z.forwardRef(({className:a,...t},r)=>e.jsx(G.Command.List,{ref:r,className:w("max-h-[300px] overflow-y-auto overflow-x-hidden",a),...t}));Bt.displayName=G.Command.List.displayName;const Tt=z.forwardRef((a,t)=>e.jsx(G.Command.Empty,{ref:t,className:"py-6 text-center text-sm",...a}));Tt.displayName=G.Command.Empty.displayName;const Qt=z.forwardRef(({className:a,...t},r)=>e.jsx(G.Command.Group,{ref:r,className:w("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",a),...t}));Qt.displayName=G.Command.Group.displayName;const wi=z.forwardRef(({className:a,...t},r)=>e.jsx(G.Command.Separator,{ref:r,className:w("-mx-1 h-px bg-border",a),...t}));wi.displayName=G.Command.Separator.displayName;const Ot=z.forwardRef(({className:a,...t},r)=>e.jsx(G.Command.Item,{ref:r,className:w("relative flex cursor-default gap-2 select-none items-center rounded-xs px-2 py-1.5 text-sm outline-hidden data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",a),...t}));Ot.displayName=G.Command.Item.displayName;const ki=({className:a,...t})=>e.jsx("span",{className:w("ml-auto text-xs tracking-widest text-muted-foreground",a),...t});ki.displayName="CommandShortcut";const za=a=>e.jsx(ie.Root,{...a});za.displayName="Popover";const Ia=z.forwardRef((a,t)=>e.jsx(ie.Trigger,{ref:t,...a}));Ia.displayName="PopoverTrigger";const Ni=z.forwardRef((a,t)=>e.jsx(ie.Anchor,{ref:t,...a}));Ni.displayName="PopoverAnchor";const Ai=z.forwardRef((a,t)=>e.jsx(ie.Close,{ref:t,...a}));Ai.displayName="PopoverClose";const Ea=z.forwardRef(({className:a,sideOffset:t=10,side:r="bottom",align:s="center",collisionPadding:i,...n},o)=>e.jsx(ie.Portal,{children:e.jsx(ie.Content,{ref:o,sideOffset:t,side:r,align:s,collisionPadding:i,avoidCollisions:!0,className:pa("max-h-[var(--radix-popper-available-height)] min-w-60 overflow-hidden rounded-md border p-2.5 text-sm shadow-md","border-gray-200 dark:border-gray-800","text-gray-900 dark:text-gray-50","bg-white dark:bg-gray-950","will-change-[transform,opacity]","data-[state=closed]:animate-hide","data-[state=open]:data-[side=bottom]:animate-slideDownAndFade data-[state=open]:data-[side=left]:animate-slideLeftAndFade data-[state=open]:data-[side=right]:animate-slideRightAndFade data-[state=open]:data-[side=top]:animate-slideUpAndFade",a),onWheel:l=>{l.stopPropagation(),l.deltaY>0?l.currentTarget.dispatchEvent(new KeyboardEvent("keydown",{key:"ArrowDown"})):l.currentTarget.dispatchEvent(new KeyboardEvent("keydown",{key:"ArrowUp"}))},...n})}));Ea.displayName="PopoverContent";const Ci=({value:a,onChange:t,disabled:r})=>{const s=x.useId(),[i,n]=x.useState(!1),o=as.map(l=>l.items.find(c=>c.value===a)).filter(Boolean)[0];return e.jsx("div",{className:"mt-2",children:e.jsxs(za,{open:r?!1:i,onOpenChange:r?void 0:n,children:[e.jsx(Ia,{asChild:!0,children:e.jsxs(te,{id:s,role:"combobox",disabled:r,"aria-expanded":i,variant:"secondary",className:"w-full justify-between shadow-2xs! bg-background px-3 py-2.5 font-normal outline-offset-0 hover:bg-background focus-visible:border-ring focus-visible:outline-[3px] focus-visible:outline-ring/20 disabled:opacity-50 disabled:cursor-not-allowed",children:[a?e.jsxs("span",{className:"flex min-w-0 items-center gap-2 mr-auto",children:[e.jsx("span",{className:"text-lg leading-none",children:o==null?void 0:o.flag}),e.jsx("span",{className:"truncate",children:o==null?void 0:o.label})]}):e.jsx("span",{className:"text-muted-foreground",children:"Select country"}),e.jsx(N.ChevronDown,{size:16,strokeWidth:2,className:"shrink-0 text-muted-foreground/80","aria-hidden":"true"})]})}),e.jsx(Ea,{className:"w-full min-w-[var(--radix-popper-anchor-width)] border-input -mt-1 z-50",align:"start",children:e.jsxs($a,{className:"p-0",children:[e.jsx(Pt,{className:"w-full border-none",style:{boxShadow:"none"},placeholder:"Search country..."}),e.jsxs(Bt,{children:[e.jsx(Tt,{children:"No country found."}),as.map(l=>e.jsx(x.Fragment,{children:e.jsx(Qt,{heading:l.continent,children:l.items.map(c=>e.jsxs(Ot,{value:c.label,className:"cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-800",onSelect:()=>{t(c.value??""),n(!1)},children:[e.jsx("span",{className:"text-lg leading-none",children:c.flag})," ",c.label,a===c.value&&e.jsx(N.Check,{size:16,strokeWidth:2,className:"ml-auto"})]},c.value))})},l.continent))]})]})})]})})},Ll=Le.tv({base:["relative block w-full rounded-lg border px-2.5 py-2.5 shadow-2xs outline-hidden transition sm:text-sm","border-gray-200 dark:border-gray-800","text-gray-900 dark:text-gray-50","placeholder-gray-400 dark:placeholder-gray-500","bg-white dark:bg-gray-950","disabled:border-gray-300 disabled:bg-gray-100 disabled:text-gray-400","dark:disabled:border-gray-700 dark:disabled:bg-gray-800 dark:disabled:text-gray-500",pi],variants:{hasError:{true:Ql},enableStepper:{false:"[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none"},multiline:{true:"resize-y min-h-[100px]",false:"truncate appearance-none"}}}),De=x.forwardRef(({className:a,inputClassName:t,hasError:r,enableStepper:s=!0,type:i,multiline:n=!1,prefix:o,suffix:l,...c},m)=>{const[u,p]=x.useState(i),g=i==="password"&&!n,h=i==="search"&&!n,f=i==="textarea"?"textarea":"input";return e.jsxs("div",{className:w("relative w-full",a),children:[o&&e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center px-3 text-slate-600 dark:text-gray-600 z-10 text-sm border-r border-gray-200",children:o}),e.jsx(f,{ref:m,type:g?u:i,className:w(Ll({hasError:r,enableStepper:n?!1:s,multiline:n}),{"pl-16":o,"pl-8":!o&&h,"pr-10":l||!l&&g},t),...c}),!o&&h&&e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-2 text-gray-400 dark:text-gray-600",children:e.jsx(P.RiSearchLine,{className:"size-[1.125rem]"})}),l&&e.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2 text-gray-400 dark:text-gray-600",children:l}),!l&&g&&e.jsx("div",{className:"absolute inset-y-0 right-0 flex items-center pr-3",children:e.jsx("button",{type:"button",onClick:()=>p(u==="password"?"text":"password"),className:w(Sa,"text-gray-400 hover:text-gray-500 dark:text-gray-600"),children:u==="password"?e.jsx(P.RiEyeFill,{className:"size-5"}):e.jsx(P.RiEyeOffFill,{className:"size-5"})})})]})});De.displayName="Input";const Si=({...a})=>{const t=x.useId();return e.jsx("div",{className:"mt-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(De,{id:t,type:"email",inputClassName:"peer ps-9",...a}),e.jsx("div",{className:"pointer-events-none absolute inset-y-0 start-0 flex items-center justify-center ps-3 text-muted-foreground/80 peer-disabled:opacity-50",children:e.jsx(N.MailIcon,{size:16})})]})})},zi=a=>{const{client:t}=M(),[r,s]=x.useState(!1),[i,n]=x.useState(0),o=async u=>{const{body:p,status:g}=await t.file.createTemporaryFile({body:{filename:u.name,mimeType:u.type,size:u.size,organizationId:a.organizationId}});if(g!==201)throw new Error("Failed to create temporary file");const h=await Ns.upload(u.name,u,{access:"public",handleUploadUrl:`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/files/token/vercel`,clientPayload:JSON.stringify({fileId:p==null?void 0:p.id}),onUploadProgress(f){n(f.percentage)}});return{id:p.id,filename:u.name,mimeType:u.type,size:u.size,url:h.url}},l=async u=>{var p;if((p=u.target.files)!=null&&p[0]){s(!0);try{const g=await o(u.target.files[0]);if(a.multiple){const h=a.value??[];a.onChange([...h,g])}else a.onChange(g)}catch(g){console.error(g)}finally{s(!1)}}},c=u=>{if(a.multiple){if(!a.value)return a.onChange(void 0);const p=a.value.filter(g=>g.id!==u);a.onChange(p.length?p:void 0)}else a.onChange(void 0)},m=()=>{if(a.value){const u=a.multiple?a.value:[a.value];return e.jsxs("div",{className:"flex",children:[u.map(p=>e.jsx("div",{className:"flex flex-col w-40 h-40 mr-3 transition-all rounded-lg relative animate-fade",children:e.jsxs("div",{className:"relative h-full w-40",children:[e.jsx("button",{className:"absolute w-6 h-6 bg-black flex items-center justify-center rounded-md right-1 top-1",onClick:()=>c(p.id),children:e.jsx(N.XIcon,{className:"w-4 h-4 text-white"})}),e.jsx(Ie,{src:p.url,alt:p.filename,width:160,height:160,className:"w-40 h-40 rounded-md object-cover"})]})},p.id)),a.multiple&&e.jsxs("div",{className:"group flex relative flex-col w-40 h-40 items-center justify-center cursor-pointer border-2 border-gray-200 border-dashed transition-all rounded-lg hover:bg-gray-100 hover:border-gray-300",children:[e.jsx("div",{className:"flex flex-col items-center justify-center",children:r?e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"animate-spin w-4 h-4 fill-current shrink-0 mb-2",viewBox:"0 0 16 16",children:e.jsx("path",{d:"M8 16a7.928 7.928 0 01-3.428-.77l.857-1.807A6.006 6.006 0 0014 8c0-3.309-2.691-6-6-6a6.006 6.006 0 00-5.422 8.572l-1.806.859A7.929 7.929 0 010 8c0-4.411 3.589-8 8-8s8 3.589 8 8-3.589 8-8 8z"})}),e.jsxs("span",{className:"text-sm",children:["Uploading... (",i,"%)"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(N.CloudUpload,{className:"w-12 h-12 text-gray-300 group-hover:text-gray-600 transition-all stroke-1"}),e.jsx("p",{className:"pt-1 text-sm font-medium text-gray-400 group-hover:text-gray-600",children:"Upload an image"})]})}),e.jsx("input",{type:"file",className:"opacity-0 w-full h-full absolute cursor-pointer",onChange:l,accept:"image/png, image/gif, image/jpeg"})]},"upload-placeholder")]})}return e.jsxs("div",{className:"group flex relative flex-col items-center justify-center cursor-pointer w-full h-40 border-2 border-gray-200 border-dashed transition-all rounded-lg hover:bg-gray-100 hover:border-gray-300",children:[e.jsx("div",{className:"flex flex-col items-center justify-center",children:r?e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"animate-spin w-4 h-4 fill-current shrink-0 mb-2",viewBox:"0 0 16 16",children:e.jsx("path",{d:"M8 16a7.928 7.928 0 01-3.428-.77l.857-1.807A6.006 6.006 0 0014 8c0-3.309-2.691-6-6-6a6.006 6.006 0 00-5.422 8.572l-1.806.859A7.929 7.929 0 010 8c0-4.411 3.589-8 8-8s8 3.589 8 8-3.589 8-8 8z"})}),e.jsxs("span",{className:"text-sm",children:["Uploading... (",i,"%)"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(N.CloudUpload,{className:"w-12 h-12 text-gray-300 group-hover:text-gray-600 transition-all stroke-1"}),e.jsx("p",{className:"pt-1 text-sm font-medium text-gray-400 group-hover:text-gray-600",children:"Upload an image"})]})}),e.jsx("input",{type:"file",className:"opacity-0 w-full h-full absolute cursor-pointer",onChange:l,accept:"image/png, image/gif, image/jpeg"})]},"upload-placeholder")};return e.jsx("div",{className:"flex items-center w-full mt-2",children:m()})},Lt=({value:a,onChange:t,placeholder:r="Search for a place"})=>{const{client:s}=M(),i=x.useId(),[n,o]=x.useState(!1),[l,c]=x.useState(""),[m,u]=x.useState(null),p=x.useRef(null),[g]=Ke.useDebounce(l,300);x.useEffect(()=>{a&&(m==null?void 0:m.text)!==a&&c(a)},[a,m]);const{data:h=[],error:f,isLoading:b}=A.useQuery({queryKey:["autocomplete",g],queryFn:async()=>{if(!g||g.length<2)return[];const j=await s.location.getPredictions({query:{query:g}});if(j.status!==200)throw new Error("Failed to fetch predictions");return Array.isArray(j.body)?j.body:(console.warn("API did not return an array:",j.body),[])},enabled:g.length>=2,refetchOnWindowFocus:!1}),y=j=>{u(j),c(j.text);const v={placeId:j.placeId,text:j.text,addressLineOne:j.addressLineOne,addressLineTwo:j.addressLineTwo};t(v),o(!1)};return x.useEffect(()=>{n&&p.current&&p.current.focus()},[n]),e.jsxs("div",{className:"mt-2 relative",children:[e.jsxs(za,{open:n,onOpenChange:o,children:[e.jsx(Ia,{asChild:!0,children:e.jsxs(te,{id:i,role:"combobox","aria-expanded":n,variant:"secondary",className:"w-full shadow-2xs! bg-background px-2! py-1 min-h-[41.6px] font-normal outline-offset-0 hover:bg-background focus-visible:border-ring focus-visible:outline-[3px] focus-visible:outline-ring/20",onClick:()=>o(!n),children:[a?e.jsx("span",{className:"px-1 text-sm truncate mr-auto",children:a}):e.jsx("span",{className:"px-1 text-sm text-gray-400 mr-auto",children:r}),e.jsx(N.ChevronDown,{size:16,strokeWidth:2,className:"shrink-0 text-muted-foreground/80","aria-hidden":"true"})]})}),e.jsxs(Ea,{className:"w-full min-w-[var(--radix-popper-anchor-width)] border-input -mt-1 z-50 p-0",align:"start",children:[e.jsxs("div",{className:"flex items-center border-b px-3 py-2",children:[e.jsx(N.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx("input",{ref:p,placeholder:"Search places...",className:"flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",value:l,onChange:j=>{c(j.target.value),j.target.value.length>=2&&o(!0)}})]}),e.jsxs("div",{className:"max-h-[300px] overflow-y-auto",children:[b&&e.jsxs("div",{className:"py-6 text-center",children:[e.jsx(N.Loader2,{className:"h-4 w-4 animate-spin mx-auto"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"Searching places..."})]}),!b&&l.length<2&&e.jsx("p",{className:"py-6 text-center text-sm text-muted-foreground",children:"Type at least 2 characters to search"}),!b&&l.length>=2&&h.length===0&&e.jsx("p",{className:"py-6 text-center text-sm text-muted-foreground",children:"No places found"}),!b&&l.length>=2&&h.length>0&&e.jsxs("div",{className:"py-1",children:[e.jsxs("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:["Found ",h.length," results"]}),h.map((j,v)=>e.jsxs("div",{className:"relative flex cursor-pointer select-none items-center rounded-xs px-2 py-2 text-sm outline-hidden hover:bg-gray-100 dark:hover:bg-gray-800",onClick:()=>y(j),children:[e.jsxs("div",{className:"flex flex-col grow",children:[e.jsx("span",{children:j.addressLineOne||j.text}),j.addressLineTwo&&e.jsx("span",{className:"text-xs text-muted-foreground",children:j.addressLineTwo})]}),(m==null?void 0:m.placeId)===j.placeId&&e.jsx(N.Check,{size:16,strokeWidth:2,className:"ml-auto"})]},`${j.placeId||"place"}-${v}`))]})]})]})]}),f&&e.jsxs("p",{className:"text-xs text-red-500 mt-1",children:["Error fetching results: ",f.message]})]})},Ii=x.forwardRef(({...a},t)=>e.jsx(De,{...a,inputClassName:"border-l-0 rounded-l-none",ref:t,className:""}));Ii.displayName="PhoneInput";const Jl=({disabled:a,value:t,onChange:r,options:s})=>{const i=n=>{r(n.target.value)};return e.jsxs("div",{className:"relative inline-flex items-center self-stretch rounded-s-lg border border-gray-200 dark:border-gray-800 bg-background py-2 pe-2 ps-3 text-muted-foreground transition-shadow focus-within:z-10 focus-within:border-ring focus-within:outline-hidden focus-within:ring-[3px] focus-within:ring-ring/20 hover:bg-accent hover:text-foreground has-disabled:pointer-events-none has-disabled:opacity-50",children:[e.jsxs("div",{className:"inline-flex items-center gap-1","aria-hidden":"true",children:[e.jsx(Ei,{country:t,countryName:t,"aria-hidden":"true"}),e.jsx("span",{className:"text-muted-foreground/80",children:e.jsx(N.ChevronDown,{size:16,strokeWidth:2,"aria-hidden":"true"})})]}),e.jsxs("select",{disabled:a,value:t,onChange:i,className:"absolute inset-0 text-sm opacity-0","aria-label":"Select country",children:[e.jsx("option",{value:"",children:"Select a country"},"default"),s.filter(n=>n.value).map((n,o)=>e.jsxs("option",{value:n.value,children:[n.label," ",n.value&&`+${Nt.getCountryCallingCode(n.value)}`]},n.value??`empty-${o}`))]})]})},Ei=({country:a,countryName:t})=>{const r=zs[a];return e.jsx("span",{className:"w-5 overflow-hidden rounded-xs",children:r?e.jsx(r,{title:t}):e.jsx(N.Phone,{size:16,"aria-hidden":"true"})})},Di=({value:a,onChange:t,onBlur:r})=>{const s=x.useId();return e.jsx("div",{className:"mt-2",children:e.jsx(Nt.default,{id:s,className:"flex rounded-lg shadow-2xs shadow-black/5",international:!0,flagComponent:Ei,countrySelectComponent:Jl,inputComponent:Ii,placeholder:"Enter phone number",value:a,onChange:i=>t(i??""),onBlur:r})})},Ri=({options:a,value:t,onChange:r,multiple:s=!1,placeholder:i})=>{var u;const n=x.useId(),[o,l]=x.useState(!1),c=p=>{if(s){let g;Array.isArray(t)&&t.includes(p)?g=t.filter(h=>h!==p):g=Array.isArray(t)?[...t,p]:[p],r(g)}else r(p),l(!1)},m=p=>{if(s&&Array.isArray(t)){const g=t.filter(h=>h!==p);r(g)}};return e.jsx("div",{className:"mt-2",children:e.jsxs(za,{open:o,onOpenChange:l,children:[e.jsx(Ia,{asChild:!0,children:e.jsxs(te,{id:n,role:"combobox","aria-expanded":o,variant:"secondary",className:"w-full justify-between shadow-2xs! bg-background px-2! py-1 min-h-[41.6px] font-normal outline-offset-0 hover:bg-background focus-visible:border-ring focus-visible:outline-[3px] focus-visible:outline-ring/20",children:[(t==null?void 0:t.length)>0?e.jsx("div",{className:"flex flex-wrap gap-2",children:Array.isArray(t)?t.map(p=>{const g=a.find(h=>h.value===p);return g?e.jsxs("span",{className:"animate-fadeIn relative inline-flex cursor-default items-center rounded-md border border-border bg-background px-2 py-1 text-xs font-medium text-secondary-foreground transition-all hover:bg-background disabled:cursor-not-allowed disabled:opacity-50",children:[g.label,e.jsx(N.X,{size:12,onClick:h=>{h.preventDefault(),m(p)},className:"cursor-pointer ml-1"})]},p):null}):e.jsx("span",{className:"px-1 text-sm",children:(u=a.find(p=>p.value===t))==null?void 0:u.label})}):e.jsx("span",{className:"px-1 text-sm text-gray-400",children:i||(s?"Select options":"Select an option")}),e.jsx(N.ChevronDown,{size:16,strokeWidth:2,className:"shrink-0 text-muted-foreground/80","aria-hidden":"true"})]})}),e.jsx(Ea,{className:"w-full min-w-[var(--radix-popper-anchor-width)] border-input -mt-1 z-50 p-0",align:"start",children:e.jsxs($a,{className:"p-0",children:[e.jsx(Pt,{className:"w-full border-none pl-0",style:{boxShadow:"none"},placeholder:"Search..."}),e.jsxs(Bt,{children:[e.jsx(Tt,{children:"No options found."}),e.jsx(Qt,{children:a.map(p=>e.jsxs(Ot,{value:p.label,className:"cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-800",onSelect:()=>c(p.value),children:[p.label,(s?t.includes(p.value):t===p.value)&&e.jsx(N.Check,{size:16,strokeWidth:2,className:"ml-auto"})]},p.value))})]})]})})]})})},Vl=Le.tv({slots:{root:["group relative isolate inline-flex shrink-0 cursor-pointer items-center rounded-full p-0.5 shadow-inner outline-hidden ring-1 ring-inset transition-all","bg-gray-200 dark:bg-gray-950","ring-black/5 dark:ring-gray-800","data-[state=checked]:bg-blue-600 dark:data-[state=checked]:bg-blue-600","data-disabled:cursor-default","data-disabled:data-[state=checked]:bg-blue-200","data-disabled:data-[state=checked]:ring-gray-300","dark:data-disabled:data-[state=checked]:ring-gray-900","dark:data-disabled:data-[state=checked]:bg-blue-900","data-disabled:data-[state=unchecked]:ring-gray-300","data-disabled:data-[state=unchecked]:bg-gray-100","dark:data-disabled:data-[state=unchecked]:ring-gray-700","dark:data-disabled:data-[state=unchecked]:bg-gray-800",Sa],thumb:["pointer-events-none relative inline-block transform appearance-none rounded-full border-none shadow-lg outline-hidden transition-all duration-150 ease-in-out focus:border-none focus:outline-hidden focus:outline-transparent","bg-white dark:bg-gray-50","group-data-disabled:shadow-none","group-data-disabled:bg-gray-50 dark:group-data-disabled:bg-gray-500"]},variants:{size:{default:{root:"h-7 w-14",thumb:"h-4 w-4 data-[state=checked]:translate-x-7 data-[state=unchecked]:translate-x-0"},small:{root:"h-4 w-7",thumb:"h-3 w-3 data-[state=checked]:translate-x-3 data-[state=unchecked]:translate-x-0"}}},defaultVariants:{size:"default"}}),pr=x.forwardRef(({className:a,size:t,...r},s)=>{const{root:i,thumb:n}=Vl({size:t});return e.jsx(ct.Root,{ref:s,className:w(i(),a),...r,children:e.jsx(ct.Thumb,{className:w(n())})})});pr.displayName="Switch";const Fi=x.forwardRef(({className:a,type:t,...r},s)=>e.jsx("input",{type:t,className:pa("flex h-10 w-full rounded-md border border-gray-200 bg-white px-3 py-2 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-hidden focus:ring-2 focus:ring-blue-500 focus:border-transparent disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-50 dark:placeholder:text-gray-500",a),ref:s,...r}));Fi.displayName="TextInput";function gr({className:a,...t}){const r=x.useId();return e.jsx(Fi,{id:r,placeholder:"00:00",className:w(a,"mt-2"),ref:Yn.withMask("99:99",{placeholder:"-",showMaskOnHover:!1}),...t})}const Re=z.forwardRef(({className:a,disabled:t,...r},s)=>e.jsx(Is.Root,{ref:s,className:pa("text-sm leading-none font-medium","text-gray-900 dark:text-gray-50",{"text-gray-400 dark:text-gray-600":t},a),"aria-disabled":t,...r}));Re.displayName="Label";const ql=({value:a,onChange:t,disabled:r})=>{const s=()=>{const y=new Date,j=new Date(y);return j.setMinutes(y.getMinutes()+30),j},i=x.useMemo(()=>{const y=[],j=new Date;for(let v=0;v<7;v++){const k=new Date(j);k.setDate(j.getDate()+v),k.setHours(0,0,0,0),y.push(k)}return y},[]),n=y=>{const j=s();if(y.toDateString()!==new Date().toDateString())return!0;if(j.getHours()>=21&&j.getMinutes()>0)return!1;for(let v=11;v<=21;v++){const k=new Date(y);if(k.setHours(v,0,0,0),k>j)return!0}return!1},o=y=>!n(y),l=x.useMemo(()=>i.find(y=>!o(y))||null,[i]),[c,m]=x.useState(a||l),[u,p]=x.useState(a?`${a.getHours()}:${a.getMinutes()===0?"00":a.getMinutes()}`:null),g=x.useMemo(()=>{if(!c)return[];const y=[],j=s(),v=c.toDateString()===new Date().toDateString();for(let k=11;k<=21;k++){const C=new Date(c);C.setHours(k,0,0,0),(!v||C>j)&&y.push(`${k}:00`)}return y},[c]),h=y=>{const j=y.toLocaleDateString("en-US",{weekday:"short"}),v=y.toLocaleDateString("en-US",{month:"short"}),k=y.getDate();return{weekday:j,month:v,day:k}},f=y=>{m(y),p(null)},b=y=>{if(p(y),c){const[j]=y.split(":").map(Number),v=new Date(c);v.setHours(j,0,0,0),t(v)}};return x.useEffect(()=>{!c&&l&&m(l)},[]),e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"col-span-4 mt-4",children:[e.jsx(Re,{htmlFor:"date",children:"Select Date"}),e.jsx("div",{className:"grid grid-cols-7 gap-2 mt-2",children:i.map((y,j)=>{const{weekday:v,month:k,day:C}=h(y),F=o(y);return e.jsx("button",{type:"button",disabled:F,className:`p-2 text-center border rounded-md ${F?"opacity-50 cursor-not-allowed":"cursor-pointer"} ${c&&c.toDateString()===y.toDateString()?"storefront-primary-action":"bg-white hover:bg-gray-100"}`,onClick:()=>!F&&f(y),children:e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("span",{className:"text-xs font-medium",children:v}),e.jsx("span",{className:"text-xl font-black font-red-hat-display",children:C}),e.jsx("span",{className:"text-xs font-medium",children:k})]})},j)})})]}),c&&g.length>0&&e.jsxs("div",{className:"col-span-4 mt-4",children:[e.jsx(Re,{htmlFor:"time",children:"Select Time"}),e.jsx("div",{className:"grid grid-cols-5 gap-2 mt-2",children:g.map((y,j)=>e.jsx("button",{type:"button",className:`p-2 text-sm text-center border rounded-md font-medium cursor-pointer ${u===y?"storefront-primary-action":"bg-white hover:bg-gray-100"}`,onClick:()=>b(y),children:y},j))})]})]})},Mi=({name:a,type:t,placeholder:r,multiple:s,options:i,disabled:n,prefix:o})=>{const{watch:l,register:c,setValue:m}=U.useFormContext(),u=["country","file","location","phone-number","select","switch","week-time"].includes(t);x.useEffect(()=>{u&&c(a)},[u,a,c]);const p=g=>m(a,g,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0});switch(t){case"email":return e.jsx(Si,{...c(a),placeholder:r});case"file":return e.jsx(zi,{value:l(a),multiple:s,onChange:g=>p(g)});case"week-time":return e.jsx(ql,{value:l(a),onChange:g=>p(g)});case"phone-number":return e.jsx(Di,{value:l(a),onChange:g=>p(g)});case"country":return e.jsx(Ci,{value:l(a),onChange:g=>p(g),disabled:n});case"select":{const g=s?l(a)||[]:l(a)||"";if(!i)throw new Error("Options are required for select input");return e.jsx(Ri,{options:i,value:g,onChange:h=>p(h),placeholder:r,multiple:s})}case"switch":return e.jsx(pr,{size:"default",className:"mt-2",value:l(a),onCheckedChange:g=>p(g)});case"location":return e.jsx(Lt,{value:l(a),onChange:g=>p(g.addressLineOne)});case"time":return e.jsx(gr,{value:l(a),...c(a)});default:return e.jsx(De,{...c(a),type:t,rows:t==="textarea"?4:void 0,placeholder:r,className:"mt-2",prefix:o})}},Pi=(a,t)=>!a||typeof a!="object"?void 0:t?t.replace(/\[/g,".").replace(/\]/g,"").split(".").filter(Boolean).reduce((r,s)=>{if(r!=null)return r[s]},a):a,Ne=({type:a="text",name:t,label:r,className:s,locale:i,placeholder:n,multiple:o,options:l,localizable:c,prefix:m,disabled:u})=>{const{errors:p}=U.useFormState(),g=Pi(p,t);return e.jsxs("div",{className:w("w-full",s),children:[typeof r=="string"&&e.jsxs(Re,{htmlFor:t,className:"font-medium flex items-center justify-between",children:[e.jsxs("span",{className:"flex items-center",children:[r,c&&e.jsx(N.LanguagesIcon,{className:"w-4 h-4 ml-1 text-gray-500"})]}),i&&c&&e.jsxs("span",{className:"flex items-center text-xs text-gray-500 ml-1 bg-gray-100 px-1 py-0.5 rounded-sm",children:[St.get(i)," (",i,")"]})]}),e.jsx(Mi,{type:a,name:t,placeholder:n,options:l,multiple:o,prefix:m,disabled:u}),(g==null?void 0:g.message)&&e.jsx("p",{className:"mt-1 text-sm text-red-500",children:g.message})]})},Bi=({isOpen:a,onClose:t,children:r})=>e.jsx(va.Transition,{show:a,as:x.Fragment,children:e.jsx(va.Dialog,{as:"div",className:"fixed inset-0 overflow-hidden",onClose:t,children:e.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[e.jsx(va.TransitionChild,{as:x.Fragment,enter:"ease-in-out duration-500",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in-out duration-500",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:e.jsx("div",{className:"fixed inset-0 bg-black/75 z-20 transition-opacity"})}),e.jsx("div",{className:"fixed h-1/2 top-0 right-0 z-30 max-w-full flex",children:e.jsx(va.TransitionChild,{as:x.Fragment,enter:"transform transition ease-in-out duration-500",enterFrom:"-translate-y-full",enterTo:"translate-y-0",leave:"transform transition ease-in-out duration-500",leaveFrom:"translate-y-0",leaveTo:"-translate-y-full",children:e.jsx(va.DialogPanel,{className:"relative w-screen h-full",children:e.jsx("div",{className:"max-h-screen bg-gray-900 flex flex-col py-6 shadow-xl overflow-y-scroll",children:r})})})})]})})}),Hl=w("hidden h-6 select-none items-center justify-center rounded-md bg-gray-800 px-2 font-mono text-xs text-gray-400 ring-1 ring-inset ring-gray-700 transition sm:flex"),Ti=({open:a=!1,onOpenChange:t,defaultOpen:r=!1,disableAutoFocus:s=!0,children:i})=>e.jsxs(ie.Root,{open:a,onOpenChange:t,defaultOpen:r,children:[e.jsx(ie.Anchor,{className:w("fixed inset-x-0 bottom-8 mx-auto flex w-fit items-center")}),e.jsx(ie.Portal,{children:e.jsx(ie.Content,{side:"top",sideOffset:0,onOpenAutoFocus:n=>{s&&n.preventDefault()},className:w("z-50","data-[state=closed]:animate-hide","data-[side=top]:animate-slideUpAndFade"),children:i})})]});Ti.displayName="CommandBar";const Qi=z.forwardRef(({className:a,...t},r)=>e.jsx("div",{ref:r,className:w("px-3 py-2.5 text-sm tabular-nums text-gray-300",a),...t}));Qi.displayName="CommandBar.Value";const Oi=z.forwardRef(({className:a,...t},r)=>e.jsx("div",{ref:r,className:w("relative flex items-center rounded-lg bg-gray-900 px-1 shadow-lg shadow-black/30 dark:ring-1 dark:ring-white/10",a),...t}));Oi.displayName="CommandBarBar";const Li=z.forwardRef(({className:a,...t},r)=>e.jsx("div",{ref:r,className:w("h-4 w-px bg-gray-700",a),...t}));Li.displayName="CommandBar.Seperator";const Ji=z.forwardRef(({className:a,type:t="button",label:r,action:s,shortcut:i,disabled:n,...o},l)=>(z.useEffect(()=>{const c=m=>{m.key===i.shortcut&&(m.preventDefault(),m.stopPropagation(),s())};return n||document.addEventListener("keydown",c),()=>{document.removeEventListener("keydown",c)}},[s,i,n]),e.jsx("span",{className:w("flex items-center gap-x-2 rounded-lg bg-gray-900 p-1 text-base font-medium text-gray-50 outline-hidden transition focus:z-10 sm:text-sm","sm:last-of-type:-mr-1",a),children:e.jsxs("button",{ref:l,type:t,onClick:s,disabled:n,className:w("flex items-center gap-x-2 rounded-md px-1 py-1 hover:bg-gray-800","focus-visible:bg-gray-800 focus-visible:hover:bg-gray-800","disabled:text-gray-500",Sa),...o,children:[e.jsx("span",{children:r}),e.jsx("span",{className:Hl,children:i.label?i.label.toUpperCase():i.shortcut.toUpperCase()})]})})));Ji.displayName="CommandBar.Command";const pt=z.forwardRef(({className:a,...t},r)=>e.jsx(rr.Root,{ref:r,className:pa("grid gap-2",a),...t}));pt.displayName="RadioCardGroup";const gt=z.forwardRef(({className:a,...t},r)=>e.jsx("div",{className:pa("relative flex size-4 shrink-0 appearance-none items-center justify-center rounded-full border shadow-2xs outline-hidden","border-gray-300 dark:border-gray-800","bg-white dark:bg-gray-950","group-data-[state=checked]:border-0 group-data-[state=checked]:border-transparent group-data-[state=checked]:bg-blue-600","group-data-disabled:border","group-data-disabled:border-gray-300 group-data-disabled:bg-gray-100 group-data-disabled:text-gray-400","dark:group-data-disabled:border-gray-700 dark:group-data-disabled:bg-gray-800",Sa,a),children:e.jsx(rr.Indicator,{ref:r,className:"flex items-center justify-center",...t,children:e.jsx("div",{className:pa("size size-1.5 shrink-0 rounded-full","bg-white","group-data-disabled:bg-gray-400 dark:group-data-disabled:bg-gray-500")})})}));gt.displayName="RadioCardGroupIndicator";const ht=z.forwardRef(({className:a,children:t,...r},s)=>e.jsx(rr.Item,{ref:s,className:pa("group relative w-full rounded-lg border p-4 text-left shadow-2xs transition-all focus:outline-hidden","bg-white dark:bg-gray-950","border-gray-200 dark:border-gray-800","data-[state=checked]:border-blue-600 dark:data-[state=checked]:border-blue-600",pi,a),...r,children:t}));ht.displayName="RadioCardItem";const Vi=Le.tv({base:w("inline-flex items-center gap-x-1 whitespace-nowrap rounded-sm px-1.5 py-0.5 text-xs font-semibold ring-1"),variants:{variant:{default:["bg-blue-50 text-blue-800 ring-blue-500/30","dark:bg-blue-400/10 dark:text-blue-400 dark:ring-blue-400/30"],neutral:["bg-gray-50 text-gray-700 ring-gray-500/30","dark:bg-gray-400/10 dark:text-gray-300 dark:ring-gray-400/20"],success:["bg-emerald-50 text-emerald-800 ring-emerald-600/30","dark:bg-emerald-400/10 dark:text-emerald-400 dark:ring-emerald-400/20"],error:["bg-red-50 text-red-800 ring-red-600/20","dark:bg-red-400/10 dark:text-red-400 dark:ring-red-400/20"],warning:["bg-yellow-50 text-yellow-800 ring-yellow-600/30","dark:bg-yellow-400/10 dark:text-yellow-500 dark:ring-yellow-400/20"]}},defaultVariants:{variant:"default"}}),hr=x.forwardRef(({className:a,variant:t,...r},s)=>e.jsx("span",{ref:s,className:w(Vi({variant:t}),a),...r}));hr.displayName="Badge";const Na=x.forwardRef(({className:a,children:t,...r},s)=>e.jsx("div",{ref:s,className:w("mx-auto my-6 flex w-full items-center justify-between gap-3 text-sm col-span-full","text-gray-500 dark:text-gray-500",a),...r,children:t?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:w("h-[1px] w-full","bg-gray-200 dark:bg-gray-800")}),e.jsx("div",{className:"whitespace-nowrap text-inherit",children:t}),e.jsx("div",{className:w("h-[1px] w-full","bg-gray-200 dark:bg-gray-800")})]}):e.jsx("div",{className:w("h-[0.5px] w-full","bg-gray-200 dark:bg-gray-800")})}));Na.displayName="Divider";const Ul=({initialData:a,shippingAndPaymentPageUrl:t})=>{const{itemCount:r}=At(),s=E.useRouter(),{client:i}=M(),n=U.useForm({resolver:fe.zodResolver(ii),reValidateMode:"onChange",defaultValues:a?{firstname:a.firstname,lastname:a.lastname,phone:a.phone,addressLineOne:a.addressLineOne,placeId:a.placeId,doorNumber:a.doorNumber,zipCode:a.zipCode,city:a.city,country:a.country,deliveryInstructions:a.deliveryInstructions}:void 0}),o=n.watch("placeId"),l=n.watch("addressLineOne");x.useEffect(()=>{(async()=>{if(o){const{status:p,body:g}=await i.location.getPlaceDetails({params:{placeId:o}});if(p!==200)throw new Error("Failed to fetch place details");n.setValue("zipCode",g.zipCode,{shouldValidate:!0,shouldDirty:!0}),n.setValue("city",g.city,{shouldValidate:!0,shouldDirty:!0}),n.setValue("country",g.country,{shouldValidate:!0,shouldDirty:!0})}})()},[n,o]);const c=A.useMutation({mutationFn:async p=>{const{status:g,body:h}=await i.shipping.createShippingAddress({body:p});if(g!==201)throw new Error("Failed to create shipping address");return h},onSuccess:()=>{s.push(t)}}),m=A.useMutation({mutationFn:async p=>{const{status:g,body:h}=await i.shipping.updateShippingAddress({body:p});if(g!==200)throw new Error("Failed to update shipping address");return h},onSuccess:()=>s.push(t)}),u=p=>{(a?m:c).mutate(p)};return e.jsx("div",{className:"flex flex-col gap-4",children:e.jsx(U.FormProvider,{...n,children:e.jsxs("form",{onSubmit:n.handleSubmit(u),children:[e.jsxs("div",{className:"grid grid-cols-4 gap-x-4 gap-y-4 mt-3",children:[e.jsx(Ne,{name:"firstname",label:"First Name",type:"text",className:"col-span-2",placeholder:"e.g. John"}),e.jsx(Ne,{name:"lastname",label:"Last Name",type:"text",className:"col-span-2",placeholder:"e.g. Doe"}),e.jsx(Ne,{name:"phone",label:"Phone",type:"phone-number",className:"col-span-4",placeholder:"e.g. +48 123 456 789"}),e.jsxs("div",{className:"col-span-4 md:col-span-3 text-sm text-gray-500",children:[e.jsx(Re,{htmlFor:"address.addressLineOne",className:"font-medium flex items-center justify-between",children:"Street Address"}),e.jsx(Lt,{onChange:p=>{n.setValue("addressLineOne",p.addressLineOne,{shouldValidate:!0,shouldDirty:!0}),n.setValue("placeId",p.placeId,{shouldValidate:!0,shouldDirty:!0})},value:l}),n.formState.errors.addressLineOne&&e.jsx("p",{className:"mt-1 text-sm text-red-500",children:String(n.formState.errors.addressLineOne.message??"")})]}),e.jsx(Ne,{name:"doorNumber",label:"Door Number",type:"text",className:"md:col-span-1 col-span-2",placeholder:"e.g. 123"}),e.jsx(Ne,{name:"zipCode",label:"Postal Code",type:"text",className:"col-span-2",placeholder:"e.g. 12345"}),e.jsx(Ne,{name:"city",label:"City",type:"text",className:"col-span-2",placeholder:"e.g. Kraków"}),e.jsx(Ne,{name:"country",label:"Country",type:"country",className:"col-span-2 md:col-span-4",disabled:!0}),e.jsx(Ne,{name:"deliveryInstructions",label:"Notes / Instructions",type:"textarea",className:"col-span-4",placeholder:"e.g. 4th floor, code 12345"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-2 w-full mt-8",children:[e.jsx(te,{variant:"secondary",className:"shadow-none",type:"button",onClick:()=>s.push("/"),children:"Back"}),e.jsx(te,{type:"submit",className:"shadow-none",isLoading:c.isPending||m.isPending,disabled:r===0,loadingText:"Saving...",children:"Save & Continue"})]})]})})})},Zl=()=>e.jsxs("div",{className:"animate-pulse space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[e.jsx("div",{className:"h-[40px] bg-gray-100 rounded-sm col-span-2"}),e.jsx("div",{className:"h-[40px] bg-gray-100 rounded-sm col-span-2"})]}),e.jsx("div",{className:"h-[70px] bg-gray-100 rounded-sm"}),e.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[e.jsx("div",{className:"h-[40px] bg-gray-100 rounded-sm col-span-3"}),e.jsx("div",{className:"h-[40px] bg-gray-100 rounded-sm col-span-1"})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[e.jsx("div",{className:"h-[40px] bg-gray-100 rounded-sm col-span-2"}),e.jsx("div",{className:"h-[40px] bg-gray-100 rounded-sm col-span-2"})]}),e.jsx("div",{className:"h-[40px] bg-gray-100 rounded-sm"}),e.jsx("div",{className:"h-[100px] bg-gray-100 rounded-sm"}),e.jsx("div",{className:"h-[40px] bg-gray-100 rounded-sm mt-8"})]}),Yt=({shippingAndPaymentPageUrl:a="/checkout/shipping-and-payment"})=>{const t=E.useRouter(),{client:r}=M(),{data:s,isLoading:i,error:n}=A.useQuery({queryKey:["shippingAddress"],queryFn:async()=>{const{status:l,body:c}=await r.shipping.getShippingAddress();if(l!==200)throw new Error("Failed to fetch shipping address");return c}}),o=()=>{t.push(a)};return i?e.jsx(Zl,{}):n?e.jsxs("div",{className:"p-4 rounded-lg bg-red-50 text-red-700",children:[e.jsx("p",{className:"font-semibold",children:"Failed to load shipping address"}),e.jsx("p",{className:"text-xs",children:"Please try refreshing the page or contact support if the issue persists."})]}):e.jsxs("div",{className:"flex flex-col gap-4 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col gap-y-1",children:[e.jsx("h1",{className:"text-[32px] font-red-hat-display font-black dark:text-blue-500",children:"Shipping Details"}),e.jsx("p",{className:"text-gray-500",children:"Please fill in the your shipping details to continue."})]}),e.jsx(Ul,{initialData:s??null,onSuccess:o,shippingAndPaymentPageUrl:a},s==null?void 0:s.id)]})},$l=()=>e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"animate-pulse space-y-4",children:e.jsx("div",{className:"space-y-2",children:[1,2,3].map(a=>e.jsxs("div",{className:"flex items-center gap-3 p-4 border rounded-lg",children:[e.jsx("div",{className:"h-4 w-4 bg-gray-100 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-5 w-32 bg-gray-100 rounded-sm"}),e.jsx("div",{className:"h-4 w-24 bg-gray-100 rounded-sm"})]})]},a))})}),e.jsx("div",{className:"animate-pulse space-y-4 mt-8",children:e.jsx("div",{className:"space-y-2",children:[1,2].map(a=>e.jsxs("div",{className:"flex items-center gap-3 p-4 border rounded-lg",children:[e.jsx("div",{className:"h-4 w-4 bg-gray-100 rounded-full"}),e.jsx("div",{className:"h-5 w-24 bg-gray-100 rounded-sm"})]},a))})}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-2 w-full mt-4",children:[e.jsx("div",{className:"h-10 bg-gray-100 rounded-sm"}),e.jsx("div",{className:"h-10 bg-gray-100 rounded-sm"})]})]}),_l=({shippingMethods:a,paymentMethods:t,customerDetailsPageUrl:r})=>{const s=E.useRouter(),{client:i,baseUrl:n}=M(),{organizationId:o}=ke(),{items:l,shippingMethod:c,paymentMethod:m,setPaymentMethod:u,setShippingMethod:p,replaceItems:g}=At(),h=A.useMutation({mutationFn:async()=>{if(!c)throw new Error("Please select a shipping method");if(!m)throw new Error("Please select a payment method");const{body:b,status:y}=await i.order.createOrder({params:{organizationId:o},body:{items:l,shippingMethodId:c==null?void 0:c.id,fulfilmentMethod:"delivery",payment:{provider:m.provider,method:m.method},checkoutBaseUrl:n}});if(y===409){const j=b;throw j.normalizedItems&&g(j.normalizedItems),new Error(j.message??"Some items changed availability before payment started.")}if(y!==201)throw new Error((b==null?void 0:b.message)??"Failed to create order");return b.redirectUrl&&(window.location.href=b.redirectUrl),b}}),f=()=>{h.mutate()};return x.useEffect(()=>{a.length===1&&p(a[0])},[p,a]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("h2",{className:"text-[32px] font-red-hat-display font-black",children:"Shipping Method"}),e.jsx("p",{className:"text-gray-500",children:"Select a shipping method"})]}),e.jsx(pt,{className:"flex flex-col gap-2",value:c==null?void 0:c.id,children:a.map(b=>e.jsx(ht,{value:b.id,disabled:!b.eligibleShippingZone,onClick:()=>p(b),children:e.jsxs("div",{className:w("flex items-center gap-3",{"opacity-60 cursor-not-allowed":!b.eligibleShippingZone}),children:[e.jsx(gt,{}),e.jsx("div",{children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center",children:[e.jsxs("span",{className:"leading-5 font-red-hat-display font-black mr-2",children:[b.title," (",b.providerName,")"]}),!b.eligibleShippingZone&&e.jsx(hr,{variant:"error",children:"Not Available"})]}),b.eligibleShippingZone&&e.jsxs("p",{className:"text-xs font-medium text-gray-500 mt-0.5",children:["Shipping Fee: ",b.eligibleShippingZone.price," zł ",e.jsx("br",{}),"ETA: ",b.eligibleShippingZone.eta]}),!b.eligibleShippingZone&&e.jsxs("p",{className:"mt-0.5 text-xs text-gray-500",children:["Sorry, this address is too far for delivery ",e.jsx("br",{})," from our store."]})]})})]})},b.id))}),e.jsxs("div",{className:"flex flex-col gap-1 mt-3",children:[e.jsx("h2",{className:"text-[32px] font-red-hat-display font-black",children:"Payment Method"}),e.jsx("p",{className:"text-gray-500",children:"Select a payment method"})]}),e.jsx(pt,{className:"flex flex-col gap-3",value:m==null?void 0:m.id,children:t.map(b=>e.jsx(ht,{value:b.id,onClick:()=>u(b),children:e.jsxs("div",{className:w("flex items-center gap-3"),children:[e.jsx(gt,{}),e.jsxs("div",{children:[e.jsx("p",{className:"font-red-hat-display font-black mr-2 capitalize",children:b.method}),e.jsxs("p",{className:"text-xs font-medium text-gray-500 capitalize",children:[b.provider," • ",b.description]})]})]})},b.id))}),h.error&&e.jsx("div",{className:"p-4 mt-2 rounded-lg bg-red-50 text-red-700",children:e.jsx("p",{className:"text-sm",children:h.error.message})}),e.jsx("div",{children:e.jsxs("p",{className:"text-sm text-gray-500 mt-2 block",children:["By confirming this order you agree to our"," ",e.jsx(B,{href:"/terms-and-conditions",className:"storefront-primary-text storefront-primary-text-hover mr-1",children:"Terms & Conditions"}),"and"," ",e.jsx(B,{href:"/privacy-policy",className:"storefront-primary-text storefront-primary-text-hover mr-1",children:"Privacy Policy"})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-2 w-full mt-3",children:[e.jsx(te,{variant:"secondary",className:"shadow-none",onClick:()=>s.push(r),children:"Back"}),e.jsx(te,{className:"shadow-none",onClick:f,isLoading:h.isPending,children:"Pay & Confirm"})]})]})},qi=({customerDetailsPageUrl:a="/checkout/customer-details"})=>{const{client:t}=M(),{organizationId:r}=ke(),s=E.useRouter(),i=A.useQuery({queryKey:["shippingAddress"],queryFn:async()=>{const{status:c,body:m}=await t.shipping.getShippingAddress();if(c!==200)throw new Error("Failed to fetch shipping address");return m||s.push(a),m}}),n=A.useQuery({queryKey:["shipping-and-payment-eligibility"],queryFn:async()=>{const{body:c,status:m}=await t.shippingMethod.accessEligibility({params:{organizationId:r}});if(m!==200)throw new Error("Failed to fetch shipping methods");return c}}),o=A.useQuery({queryKey:["payment-methods"],queryFn:async()=>{const{body:c,status:m}=await t.payment.getAvailablePaymentMethods({params:{organizationId:r}});if(m!==200)throw new Error((c==null?void 0:c.message)??"Failed to fetch payment methods");if(!(c!=null&&c.length))throw new Error("No payment methods are configured for this organization");return c}}),l=n.error||i.error||o.error;if(l){const c=l instanceof Error?l.message:"Please try refreshing the page or contact support if the issue persists.";return e.jsxs("div",{className:"p-4 rounded-lg bg-red-50 text-red-700",children:[e.jsx("p",{className:"font-semibold",children:"Unable to load checkout options"}),e.jsx("p",{className:"text-xs",children:c})]})}return n.isLoading||i.isLoading||o.isLoading?e.jsx($l,{}):e.jsx("div",{className:"flex flex-col gap-3 animate-fade-in",children:e.jsx(_l,{shippingMethods:n.data??[],paymentMethods:o.data??[],customerDetailsPageUrl:a})})},Wl=a=>ks.createAuthClient({baseURL:a,plugins:[dt.inferAdditionalFields(),dt.organizationClient()]}),Hi=x.createContext(void 0),Kl=({children:a,baseURL:t})=>{const r=x.useMemo(()=>Wl(t),[t]);return e.jsx(Hi.Provider,{value:r,children:a})},Je=()=>{const a=x.useContext(Hi);if(a===void 0)throw new Error("useAuth must be used within a AuthProvider");return a},Gl=()=>e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"animate-pulse",children:[1,2].map(a=>e.jsxs("div",{className:"flex items-center w-full mb-5 sm:mb-7",children:[e.jsx("div",{className:"w-14 sm:w-32 h-10 sm:h-24 overflow-hidden rounded-lg bg-white/10"}),e.jsxs("div",{className:"pl-3 md:pl-5 flex-1",children:[e.jsx("div",{className:"h-4 bg-white/10 rounded-sm w-3/4 mb-2"}),e.jsx("div",{className:"h-3 bg-white/10 rounded-sm w-1/2 mb-2"}),e.jsx("div",{className:"text-white text-xs opacity-50 whitespace-nowrap sm:block hidden",children:e.jsx("div",{className:"h-3 bg-white/10 rounded-sm w-24 mb-2"})}),e.jsx("div",{className:"text-white text-sm font-semibold whitespace-nowrap mt-2 sm:block hidden",children:e.jsx("div",{className:"h-4 bg-white/10 rounded-sm w-16"})})]}),e.jsxs("div",{className:"ml-auto pl-4 text-right sm:hidden",children:[e.jsx("div",{className:"h-4 bg-white/10 rounded-sm w-16 mb-2"}),e.jsx("div",{className:"h-3 bg-white/10 rounded-sm w-20"})]})]},a))}),e.jsx("hr",{className:" md:flex opacity-10 my-4 sm:my-4"}),e.jsxs("div",{className:"mt-3 flex items-center",children:[e.jsx("div",{className:"h-4 w-20 bg-white/10 rounded-sm animate-pulse"}),e.jsx("div",{className:"h-4 w-16 bg-white/10 rounded-sm animate-pulse ml-auto"})]}),e.jsxs("div",{className:"mt-3 flex items-center",children:[e.jsx("div",{className:"h-4 w-20 bg-white/10 rounded-sm animate-pulse"}),e.jsx("div",{className:"h-4 w-16 bg-white/10 rounded-sm animate-pulse ml-auto"})]}),e.jsx("hr",{className:" md:flex opacity-10 my-4 sm:my-4"}),e.jsxs("div",{className:"mt-4 flex justify-between",children:[e.jsx("div",{className:"h-5 w-16 bg-white/10 rounded-sm animate-pulse"}),e.jsx("div",{className:"h-5 w-24 bg-white/10 rounded-sm animate-pulse"})]})]}),xr=({loading:a=!1,items:t,total:r,subtotal:s,shipping:i,discount:n,currency:o})=>a?e.jsx(Gl,{}):t.length===0?e.jsx("div",{className:"px-7 pt-10 pb-0 md:pt-0 md:px-0",children:e.jsx("div",{className:"my-3 sm:my-6 sm:pb-1",children:e.jsxs("div",{className:"text-center py-6",children:[e.jsx("p",{className:"text-white font-red-hat-display text-xl font-black mb-4",children:"Your shopping cart is empty. Add some products to get started."}),e.jsx(B,{href:"/",className:"text-white hover:text-white/80 underline text-sm",children:"View products"})]})})}):e.jsxs("div",{className:"px-7 pt-10 pb-0 md:pt-0 md:px-0",children:[e.jsx("div",{className:"my-3 sm:my-6 sm:pb-1",children:t.map(({title:l,subtitle:c,image:m,price:u,unitPrice:p,quantity:g},h)=>e.jsx("div",{children:e.jsxs("div",{className:"flex items-center w-full mb-5 sm:mb-7",children:[e.jsx("div",{className:"w-14 sm:min-w-32 h-10 sm:h-24 overflow-hidden rounded-lg",children:m!=null&&m.url?e.jsx(Ie,{width:100,height:100,src:m.url,alt:"",className:"w-full h-full object-cover"}):e.jsx("div",{className:"bg-slate-100 w-full h-full flex items-center justify-center",children:e.jsx("span",{className:"text-slate-400 text-xs",children:"No image"})})}),e.jsxs("div",{className:"pl-3 md:pl-5",children:[e.jsx("div",{className:"flex font-red-hat-display h4 text-white text-sm items-center",children:l}),c&&c.map((f,b)=>e.jsx("div",{className:"text-white text-xs opacity-50",children:f},b)),e.jsxs("div",{className:"text-white text-xs opacity-50 whitespace-nowrap sm:block hidden",children:["Price: ",p," | Quantity: x ",g]}),e.jsx("div",{className:"font-red-hat-display h4 text-white text-sm whitespace-nowrap mt-2 sm:block hidden",children:u})]}),e.jsxs("div",{className:"ml-auto pl-4 text-right sm:hidden",children:[e.jsx("div",{className:"font-red-hat-display h4 text-white text-sm whitespace-nowrap",children:u}),e.jsxs("div",{className:"text-white text-xs opacity-50 whitespace-nowrap",children:["Quantity: ",g]})]})]})},h))}),e.jsx("hr",{className:" md:flex opacity-10 my-4 sm:my-4"}),typeof i=="number"&&e.jsxs("div",{className:"mt-3 flex items-center",children:[e.jsx("h2",{className:"text-xs xl:text-sm text-white opacity-40 font-red-hat-display",children:"Shipping"}),e.jsx("h3",{className:"text-xs xl:text-sm text-white opacity-40 ml-auto font-red-hat-display",children:we(i,o)})]}),e.jsxs("div",{className:"mt-3 flex items-center",children:[e.jsx("h2",{className:"text-xs xl:text-sm text-white opacity-40 font-red-hat-display",children:"Subtotal"}),e.jsx("h3",{className:"text-xs xl:text-sm text-white opacity-40 ml-auto font-red-hat-display",children:we(s,o)})]}),n?e.jsxs("div",{className:"mt-3 flex items-center",children:[e.jsx("h2",{className:"text-xs xl:text-sm text-white opacity-40",children:"Discount"}),e.jsxs("h3",{className:"text-xs xl:text-sm text-white opacity-40 ml-auto",children:["- ",we(s,o)]})]}):null,e.jsx("hr",{className:" md:flex opacity-10 my-4 sm:my-4"}),e.jsxs("div",{className:"mt-4 flex justify-between",children:[e.jsx("h2",{className:"text-sm xl:text-lg text-white font-black font-red-hat-display",children:"Total"}),e.jsx("h3",{className:"xl:text-lg text-white font-black font-red-hat-display",children:we(r,o)})]})]}),Xl=()=>e.jsxs("header",{className:"fixed flex justify-between px-2 md:px-6 py-4 md:py-12 z-50 bg-gray-900 md:bg-transparent w-full",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("span",{children:e.jsx(N.ChevronLeft,{className:"w-5 h-5 text-white"})}),e.jsx("div",{className:"ml-1.5 w-7 xl:w-8 h-7 xl:h-8 bg-gray-300 animate-pulse rounded-full"}),e.jsx("div",{className:"ml-2 bg-gray-300 animate-pulse h-5 xl:h-6 w-24 xl:w-28 rounded"})]}),e.jsxs("div",{className:"flex items-center",children:[e.jsxs("div",{className:"mr-6 flex items-center",children:[e.jsx("div",{className:"w-8 h-8 bg-gray-300 animate-pulse rounded-full mr-2"}),e.jsx("div",{className:"bg-gray-300 animate-pulse h-4 w-16 rounded"})]}),e.jsxs("div",{className:"flex md:hidden items-center",children:[e.jsx("div",{className:"bg-gray-300 animate-pulse h-3 w-12 rounded mr-1.5"}),e.jsx(N.ShoppingBasketIcon,{className:"w-5 h-5 text-gray-300"})]})]})]}),Yl=()=>{const a=E.useRouter(),{useSession:t,signOut:r}=Je(),{data:s}=t(),i=()=>{var l;if(!((l=s==null?void 0:s.user)!=null&&l.name))return"";const o=s.user.name.split(" ");return o.length===1?o[0].charAt(0):`${o[0].charAt(0)}${o[o.length-1].charAt(0)}`},n=async()=>{await r(),a.push("/account/sign-in")};return e.jsx("div",{className:"hidden md:block",children:e.jsxs(za,{children:[e.jsx(Ia,{className:"flex items-center focus:outline-hidden group",children:s!=null&&s.user?e.jsx("div",{className:"w-8 h-8 rounded-full overflow-hidden flex items-center justify-center bg-blue-500 text-white relative transition-transform duration-200 group-hover:scale-110 group-hover:ring-2 group-hover:ring-white/50 group-hover:ring-offset-1 group-hover:cursor-pointer",children:s.user.image?e.jsx("img",{src:s.user.image,alt:s.user.name||"User",className:"w-full h-full object-cover"}):e.jsx("span",{className:"font-medium text-sm",children:i()})}):e.jsxs("div",{className:"flex items-center text-white group-hover:text-blue-300 transition-colors duration-200",children:[e.jsx(N.UserIcon,{className:"w-5 h-5 mr-1 group-hover:scale-110 transition-transform duration-200"}),e.jsx("span",{children:"Guest"})]})}),e.jsx(Ea,{className:"w-52 min-w-52 p-0 py-1 data-[state=open]:animate-slideDownAndFade z-50",align:"end",sideOffset:5,forceMount:!0,children:s!=null&&s.user?e.jsxs(e.Fragment,{children:[e.jsxs(B,{href:"/account",className:"flex items-center gap-2 px-4 py-2 text-sm font-medium text-gray-700 transition hover:bg-gray-100",children:[e.jsx(N.LayoutDashboardIcon,{className:"h-4 w-4"}),"My account"]}),e.jsxs(B,{href:"/account/orders",className:"flex items-center gap-2 px-4 py-2 text-sm font-medium text-gray-700 transition hover:bg-gray-100",children:[e.jsx(N.ShoppingBagIcon,{className:"h-4 w-4"}),"Orders"]}),e.jsxs(B,{href:"/account/reservations",className:"flex items-center gap-2 px-4 py-2 text-sm font-medium text-gray-700 transition hover:bg-gray-100",children:[e.jsx(N.CalendarDaysIcon,{className:"h-4 w-4"}),"Reservations"]}),e.jsxs("button",{onClick:n,className:"flex w-full items-center gap-2 px-4 py-2 text-sm font-medium text-gray-700 transition hover:bg-gray-100",children:[e.jsx(N.LogOutIcon,{className:"h-4 w-4"}),"Logout"]})]}):e.jsxs(B,{href:"/account/sign-in",className:"flex items-center gap-2 px-4 py-2 text-sm font-medium text-gray-700 transition hover:bg-gray-100",children:[e.jsx(N.UserIcon,{className:"h-4 w-4"}),"Sign in"]})})]})})},_a=({summary:a})=>{const{organization:t,loading:r}=ke(),[s,i]=x.useState(!1);if(r)return e.jsx(Xl,{});const n=(t==null?void 0:t.name)??"",o=t==null?void 0:t.logoFile,l=(t==null?void 0:t.configuration.defaultCurrency)??"USD";return e.jsxs(e.Fragment,{children:[e.jsxs("header",{className:"fixed flex justify-between px-2 md:px-6 py-4 md:py-12 z-50 bg-gray-900 md:bg-transparent w-full",children:[e.jsxs(B,{href:"/",className:"flex items-center",children:[e.jsx("span",{children:e.jsx(N.ChevronLeft,{className:"w-5 h-5 text-white"})}),o?e.jsx("span",{className:"ml-1.5 w-7 xl:w-8 h-7 xl:h-8 overflow-hidden rounded-full",children:e.jsx(Ie,{src:o.url,alt:n,className:"w-full h-full",width:32,height:32})}):e.jsx("div",{className:"flex items-center justify-center w-8 h-8 bg-blue-500 rounded-full text-white text-sm uppercase font-semibold",children:e.jsx("span",{children:n.slice(0,2)})}),n?e.jsx("span",{className:"xl:text-lg font-black text-white ml-2 font-red-hat-display",children:n}):null]}),e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"mr-6",children:e.jsx(Yl,{})}),a&&e.jsx("div",{className:"flex md:hidden",children:s?e.jsx("button",{className:"flex items-center text-white mr-2 animate-fade",onClick:()=>i(!1),children:e.jsx(N.XIcon,{className:"w-5 h-5"})},1):e.jsxs("button",{className:"flex items-center text-white mr-2 animate-fade",onClick:()=>i(!0),children:[e.jsx("span",{className:"text-xs text-white font-semibold mr-1.5",children:we(a.total,l)}),e.jsx(N.ShoppingBasketIcon,{className:"w-5 h-5"})]},2)})]})]}),a&&e.jsx(Bi,{isOpen:s,onClose:()=>i(!1),children:e.jsx(xr,{total:a.total,items:a.items,shipping:a.shipping,subtotal:a.subtotal,currency:l})})]})},Ui=({children:a,description:t,title:r})=>{const s=r||t;return e.jsxs(e.Fragment,{children:[e.jsx(_a,{}),e.jsx("div",{children:e.jsxs("div",{className:"flex flex-col md:flex-row h-screen w-screen relative",children:[e.jsx("div",{className:"hidden md:flex items-center justify-end w-full md:w-1/2 h-full px-16 xl:px-24 relative",children:e.jsx("div",{className:"absolute inset-0 z-0",children:e.jsx(Ie,{src:"/images/15750.jpg",alt:"Authentication background",fill:!0,className:"object-cover brightness-50",priority:!0})})}),e.jsx("div",{className:"flex flex-col items-start 2xl:items-start w-full md:w-1/2 h-full px-6 sm:px-12 xl:px-24 py-8 md:overflow-y-auto relative",children:e.jsxs("div",{className:"py-10 xl:py-24 md:my-auto animate-fade w-full md:max-w-[432px]",children:[s&&e.jsxs("div",{className:"mb-4 flex flex-col gap-y-1",children:[r&&e.jsx("h1",{className:"text-[32px] font-red-hat-display font-black",children:r}),t&&e.jsx("p",{className:"text-gray-500",children:t})]}),a]})})]})})]})},ts=({children:a})=>{const{useSession:t}=Je(),r=E.useRouter(),{data:s,isPending:i}=t();return x.useEffect(()=>{if(!i&&s)return r.push("/checkout/customer-details")},[s,i,r]),i?e.jsx("div",{className:"flex flex-col items-center justify-center h-screen w-screen bg-gray-900",children:e.jsx("div",{className:"mb-4",children:e.jsx("div",{className:"storefront-primary-border animate-spin rounded-full h-18 w-18 border-b-2"})})}):e.jsx(Ui,{children:a})},ca=({children:a})=>{const{useSession:t}=Je(),r=E.useRouter(),{data:s,isPending:i}=t();return x.useEffect(()=>{if(!i&&!s)return r.push("/account/sign-in")},[s,i,r]),i?e.jsx("div",{className:"flex flex-col items-center justify-center h-screen w-screen bg-gray-900",children:e.jsx("div",{className:"mb-4"})}):a},ed={danger:"border-red-200 bg-red-50 text-red-700",info:"border-sky-200 bg-sky-50 text-sky-700",neutral:"border-stone-200 bg-stone-100 text-stone-700",success:"border-emerald-200 bg-emerald-50 text-emerald-700",warning:"border-amber-200 bg-amber-50 text-amber-700"},aa=(a,t="Not available",r="MMM d, yyyy")=>{if(!a)return t;const s=new Date(a);return I.isValid(s)?I.format(s,r):t},Zi=a=>{switch(a){case"accepted":return"Accepted";case"ready-for-dispatch":return"Preparing";case"dispatched":return"On the way";case"completed":return"Completed";case"cancelled":return"Cancelled";default:return"Pending"}},$i=a=>{switch(a){case"accepted":case"ready-for-dispatch":return"info";case"dispatched":case"completed":return"success";case"cancelled":return"danger";default:return"warning"}},_i=a=>a.cancelledAt?"Cancelled":a.acceptedAt?"Confirmed":"Pending",Wi=a=>a.cancelledAt?"danger":a.acceptedAt?"success":"warning",ad=a=>{if(!a)return"A";const t=a.split(" ").filter(Boolean);return t.length===0?"A":t.length===1?t[0].slice(0,1).toUpperCase():`${t[0].slice(0,1)}${t[t.length-1].slice(0,1)}`.toUpperCase()},Jt=({actions:a,children:t,description:r,eyebrow:s,title:i})=>e.jsxs(e.Fragment,{children:[e.jsx(_a,{}),e.jsx("main",{className:"min-h-screen bg-[linear-gradient(180deg,#0f172a_0px,#0f172a_180px,#f5f1e8_180px,#faf7f2_100%)] pb-16 pt-28 sm:pt-32",children:e.jsx("div",{className:"mx-auto max-w-6xl px-4 sm:px-6 lg:px-8",children:e.jsxs("div",{className:"overflow-hidden rounded-[32px] border border-stone-200 bg-white shadow-[0_24px_80px_rgba(15,23,42,0.12)]",children:[e.jsx("div",{className:"border-b border-stone-200 bg-[radial-gradient(circle_at_top_left,rgba(20,184,166,0.16),transparent_34%),linear-gradient(135deg,#fff7ed_0%,#ffffff_45%,#f8fafc_100%)] px-6 py-8 sm:px-8 lg:px-10",children:e.jsxs("div",{className:"flex flex-col gap-6 lg:flex-row lg:items-end lg:justify-between",children:[e.jsxs("div",{className:"max-w-2xl",children:[s?e.jsx("p",{className:"mb-3 text-xs font-semibold uppercase tracking-[0.28em] text-stone-500",children:s}):null,e.jsx("h1",{className:"font-red-hat-display text-3xl font-black text-stone-950 sm:text-[40px] sm:leading-tight",children:i}),r?e.jsx("p",{className:"mt-3 max-w-xl text-sm leading-6 text-stone-600 sm:text-base",children:r}):null]}),a?e.jsx("div",{className:"flex flex-wrap gap-3 lg:justify-end",children:a}):null]})}),e.jsx("div",{className:"px-6 py-6 sm:px-8 sm:py-8 lg:px-10",children:t})]})})})]}),wa=({action:a,children:t,className:r,description:s,title:i})=>e.jsxs("section",{className:w("rounded-[28px] border border-stone-200 bg-stone-50/80 p-5 sm:p-6",r),children:[e.jsxs("div",{className:"mb-5 flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-red-hat-display text-xl font-black text-stone-950",children:i}),s?e.jsx("p",{className:"mt-1 text-sm leading-6 text-stone-600",children:s}):null]}),a]}),t]}),xt=({children:a,className:t,tone:r="neutral"})=>e.jsx("span",{className:w("inline-flex items-center rounded-full border px-3 py-1 text-xs font-semibold uppercase tracking-wide",ed[r],t),children:a}),ta=({actionHref:a,actionLabel:t,description:r,icon:s,title:i})=>e.jsxs("div",{className:"rounded-[24px] border border-dashed border-stone-300 bg-white px-6 py-10 text-center",children:[e.jsx("div",{className:"mx-auto flex h-14 w-14 items-center justify-center rounded-2xl bg-stone-100 text-stone-700",children:e.jsx(s,{className:"h-6 w-6"})}),e.jsx("h3",{className:"mt-4 font-red-hat-display text-xl font-black text-stone-950",children:i}),e.jsx("p",{className:"mx-auto mt-2 max-w-md text-sm leading-6 text-stone-600",children:r}),a&&t?e.jsx("div",{className:"mt-5",children:e.jsx(te,{asChild:!0,children:e.jsx(B,{href:a,children:t})})}):null]}),fr=({description:a="Loading your latest activity.",title:t})=>e.jsxs(Jt,{eyebrow:"My account",title:t,description:a,children:[e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-4",children:Array.from({length:4}).map((r,s)=>e.jsx("div",{className:"h-36 animate-pulse rounded-[24px] border border-stone-200 bg-stone-100"},s))}),e.jsxs("div",{className:"mt-6 grid gap-6 lg:grid-cols-2",children:[e.jsx("div",{className:"h-80 animate-pulse rounded-[28px] border border-stone-200 bg-stone-100"}),e.jsx("div",{className:"h-80 animate-pulse rounded-[28px] border border-stone-200 bg-stone-100"})]})]}),ft=({href:a,label:t})=>e.jsxs(B,{href:a,className:"inline-flex items-center gap-1 text-sm font-semibold text-stone-700 transition hover:text-stone-950",children:[t,e.jsx(N.ArrowRightIcon,{className:"h-4 w-4"})]}),td=a=>{const t=a.items.map(r=>{var s;return(s=r.translations[0])==null?void 0:s.title}).filter(Boolean);return t.length===0?"Order placed":t.length===1?t[0]:`${t[0]} +${t.length-1} more`},rs=({description:a,href:t,icon:r,title:s})=>e.jsxs(B,{href:t,className:"storefront-primary-border-hover group rounded-[24px] border border-stone-200 bg-white p-5 transition duration-200 hover:-translate-y-0.5 hover:shadow-lg",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.22em] text-stone-500",children:"Quick access"}),e.jsxs("div",{className:"mt-3 flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-red-hat-display text-xl font-black text-stone-950",children:s}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-stone-600",children:a})]}),e.jsx("span",{className:"storefront-primary-group-accent inline-flex h-11 w-11 shrink-0 items-center justify-center rounded-2xl bg-stone-100 text-stone-700 transition",children:e.jsx(r,{className:"h-5 w-5"})})]})]}),rd=()=>{var p,g,h;const{client:a}=M(),{useSession:t}=Je(),{organization:r,organizationId:s}=ke(),{data:i}=t(),n=A.useQuery({queryKey:["account","orders",s],enabled:!!s&&!!(i!=null&&i.user),queryFn:async()=>{const{body:f,status:b}=await a.order.getMyOrders({params:{organizationId:s},query:{limit:4,page:1}});if(b!==200)throw new Error("Failed to fetch your orders");return f}}),o=A.useQuery({queryKey:["account","reservations",s],enabled:!!s&&!!(i!=null&&i.user),queryFn:async()=>{const{body:f,status:b}=await a.reservation.getMyReservations({params:{organizationId:s},query:{limit:4,page:1}});if(b!==200)throw new Error("Failed to fetch your reservations");return f}});if(!(i!=null&&i.user))return null;if(n.isLoading||o.isLoading)return e.jsx(fr,{title:"Your account"});const l=((p=n.data)==null?void 0:p.list)??[],c=((g=o.data)==null?void 0:g.list)??[],m=[...c].filter(f=>!f.cancelledAt&&!!f.date&&new Date(f.date).getTime()>Date.now()).sort((f,b)=>new Date(f.date??0).getTime()-new Date(b.date??0).getTime())[0],u=i.user.firstname??((h=i.user.name)==null?void 0:h.split(" ").filter(Boolean)[0])??"there";return e.jsxs(Jt,{eyebrow:"My account",title:`Welcome back, ${u}`,description:"Track recent orders, revisit reservation history, and jump straight into the parts of your account you use most.",actions:e.jsxs(e.Fragment,{children:[e.jsx(te,{asChild:!0,variant:"secondary",children:e.jsx(B,{href:"/account/orders",children:"View orders"})}),e.jsx(te,{asChild:!0,children:e.jsx(B,{href:"/account/reservations",children:"Reservation history"})})]}),children:[e.jsxs("div",{className:"grid gap-6 lg:grid-cols-[1.25fr_0.95fr]",children:[e.jsx(wa,{title:"Recent orders",description:"A quick look at what you ordered most recently.",action:e.jsx(ft,{href:"/account/orders",label:"See all"}),children:n.isError?e.jsx(ta,{icon:N.ShoppingBagIcon,title:"Orders unavailable",description:"We couldn't load your recent orders just now. Please refresh and try again."}):l.length===0?e.jsx(ta,{icon:N.ShoppingBagIcon,title:"Your order history will appear here",description:"Once you place an order, you'll be able to track its progress and reopen the details from this account page.",actionHref:"/",actionLabel:"Browse the menu"}):e.jsx("div",{className:"space-y-4",children:l.map(f=>e.jsx(B,{href:`/account/orders/${f.id}`,className:"storefront-primary-border-hover group block rounded-[24px] border border-stone-200 bg-white p-5 transition duration-200 hover:-translate-y-0.5 hover:shadow-lg",children:e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"font-red-hat-display text-lg font-black text-stone-950",children:td(f)}),e.jsx(xt,{tone:$i(f.status),children:Zi(f.status)})]}),e.jsxs("p",{className:"mt-2 text-sm leading-6 text-stone-600",children:["Ref ",f.referenceId," • ",f.items.length," item",f.items.length===1?"":"s"," •"," ",f.fulfilmentMethod==="delivery"?"Delivery":"Pickup"]})]}),e.jsxs("div",{className:"text-left sm:text-right",children:[e.jsx("p",{className:"text-lg font-black text-stone-950",children:we(f.payment.total,f.currency)}),e.jsx("p",{className:"mt-1 text-sm text-stone-500",children:aa(f.createdAt,"Recently")})]})]})},f.id))})}),e.jsxs("div",{className:"grid gap-6",children:[e.jsx(wa,{title:"Jump into your history",description:"The two most useful places for signed-in guests.",children:e.jsxs("div",{className:"grid gap-4",children:[e.jsx(rs,{href:"/account/orders",icon:N.ShoppingBagIcon,title:"Orders list",description:"Review every purchase, total paid, fulfilment method, and live order status."}),e.jsx(rs,{href:"/account/reservations",icon:N.CalendarDaysIcon,title:"Reservation history",description:"See confirmed, pending, and cancelled bookings in one place."})]})}),e.jsx(wa,{title:"Profile snapshot",description:"A quick summary of the details tied to this account.",children:e.jsxs("div",{className:"rounded-[24px] border border-stone-200 bg-white p-5",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"flex h-14 w-14 items-center justify-center rounded-2xl bg-stone-900 text-lg font-black text-white",children:ad(i.user.name)}),e.jsxs("div",{children:[e.jsx("p",{className:"font-red-hat-display text-lg font-black text-stone-950",children:i.user.name}),e.jsx("p",{className:"text-sm text-stone-500",children:i.user.email})]})]}),e.jsxs("div",{className:"mt-5 grid gap-3 rounded-[20px] bg-stone-50 p-4 text-sm text-stone-600",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx(N.UserIcon,{className:"h-4 w-4"}),"First name"]}),e.jsx("span",{className:"font-semibold text-stone-900",children:i.user.firstname})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx(N.UserIcon,{className:"h-4 w-4"}),"Last name"]}),e.jsx("span",{className:"font-semibold text-stone-900",children:i.user.lastname})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx(N.CalendarDaysIcon,{className:"h-4 w-4"}),"Upcoming reservation"]}),e.jsx("span",{className:"font-semibold text-stone-900",children:m?aa(m.date,"Not scheduled","MMM d, yyyy"):"Nothing booked"})]})]}),e.jsx("div",{className:"mt-5",children:e.jsx(te,{asChild:!0,variant:"secondary",children:e.jsx(B,{href:"/account/reservations/book",children:"Book a table"})})})]})})]})]}),e.jsx("div",{className:"mt-6",children:e.jsx(wa,{title:"Reservation activity",description:"Your most recent table bookings and their current status.",action:e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx(te,{asChild:!0,variant:"secondary",children:e.jsx(B,{href:"/account/reservations/book",children:"Book a table"})}),e.jsx(ft,{href:"/account/reservations",label:"Open history"})]}),children:o.isError?e.jsx(ta,{icon:N.CalendarDaysIcon,title:"Reservations unavailable",description:"We couldn't load your reservation history just now. Please refresh and try again."}):c.length===0?e.jsx(ta,{icon:N.CalendarDaysIcon,title:"No reservations yet",description:"When you reserve a table, the details and status updates will show up here.",actionHref:"/account/reservations/book",actionLabel:"Book a table"}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:c.map(f=>e.jsx(B,{href:`/account/reservations/${f.id}`,className:"storefront-primary-border-hover group rounded-[24px] border border-stone-200 bg-white p-5 transition duration-200 hover:-translate-y-0.5 hover:shadow-lg",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"font-red-hat-display text-lg font-black text-stone-950",children:aa(f.date,"Date pending","MMM d, yyyy")}),e.jsx(xt,{tone:Wi(f),children:_i(f)})]}),e.jsxs("p",{className:"mt-2 text-sm leading-6 text-stone-600",children:["Ref ",f.referenceId," • ",f.guests," ","guest",f.guests===1?"":"s"]})]}),e.jsx("p",{className:"text-sm font-medium text-stone-500",children:aa(f.date,"Awaiting confirmation","h:mm a")})]})},f.id))})})})]})},Ki=()=>e.jsx(ca,{children:e.jsx(rd,{})}),Gi=()=>e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex flex-col md:flex-row h-screen w-screen relative",children:[e.jsx("div",{className:"hidden md:flex items-center justify-end w-full md:w-1/2 h-full px-16 xl:px-24 bg-gray-900 md:overflow-y-auto",children:e.jsx("div",{className:"w-96 animate-fade",children:e.jsx("div",{className:"pl-6",children:e.jsxs("div",{className:"px-7 pt-10 pb-0 md:pt-0 md:px-0",children:[[1,2].map(a=>e.jsxs("div",{className:"flex items-center w-full mb-5 sm:mb-7",children:[e.jsx("div",{className:"w-14 sm:w-32 h-10 sm:h-24 overflow-hidden rounded-lg bg-gray-700 animate-pulse"}),e.jsxs("div",{className:"pl-3 md:pl-5 w-full",children:[e.jsx("div",{className:"h-4 bg-gray-700 rounded-sm w-3/4 mb-2 animate-pulse"}),e.jsx("div",{className:"h-3 bg-gray-700 rounded-sm w-1/2 mb-2 animate-pulse"}),e.jsx("div",{className:"h-3 bg-gray-700 rounded-sm w-1/4 animate-pulse"})]})]},a)),e.jsx("hr",{className:"opacity-10 my-4 sm:my-4"}),e.jsxs("div",{className:"mt-3 flex items-center",children:[e.jsx("div",{className:"h-3 bg-gray-700 rounded-sm w-20 animate-pulse"}),e.jsx("div",{className:"h-3 bg-gray-700 rounded-sm w-16 ml-auto animate-pulse"})]}),e.jsxs("div",{className:"mt-3 flex items-center",children:[e.jsx("div",{className:"h-3 bg-gray-700 rounded-sm w-16 animate-pulse"}),e.jsx("div",{className:"h-3 bg-gray-700 rounded-sm w-16 ml-auto animate-pulse"})]}),e.jsx("hr",{className:"opacity-10 my-4 sm:my-4"}),e.jsxs("div",{className:"mt-4 flex justify-between",children:[e.jsx("div",{className:"h-5 bg-gray-700 rounded-sm w-16 animate-pulse"}),e.jsx("div",{className:"h-5 bg-gray-700 rounded-sm w-20 animate-pulse"})]})]})})})}),e.jsx("div",{className:"flex flex-col items-start 2xl:items-start w-full md:w-1/2 h-full px-6 sm:px-12 xl:px-24 py-8 md:overflow-y-auto relative",children:e.jsxs("div",{className:"md:my-auto animate-fade w-full md:max-w-[432px]",children:[e.jsx("div",{className:"h-8 bg-gray-200 rounded-sm w-64 mb-4 animate-pulse"}),e.jsxs("div",{className:"mb-8",children:[e.jsx("div",{className:"h-4 bg-gray-200 rounded-sm w-48 mb-2 animate-pulse"}),e.jsx("div",{className:"h-4 bg-gray-200 rounded-sm w-40 animate-pulse"})]}),e.jsx("div",{className:"mt-8 space-y-4",children:e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-4 top-0 h-full w-0.5 bg-gray-200"}),[1,2,3,4,5].map(a=>e.jsxs("div",{className:"ml-9 mb-8 relative",children:[e.jsx("div",{className:"absolute -left-9 mt-1.5",children:e.jsx("div",{className:"h-8 w-8 rounded-full bg-gray-200 animate-pulse"})}),e.jsx("div",{className:"h-5 bg-gray-200 rounded-sm w-40 mb-2 animate-pulse"}),e.jsx("div",{className:"h-3 bg-gray-200 rounded-sm w-64 mb-2 animate-pulse"}),e.jsx("div",{className:"h-3 bg-gray-200 rounded-sm w-24 animate-pulse"})]},a))]})})]})})]})}),sd=({className:a})=>e.jsx("svg",{className:a,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 13l4 4L19 7"})}),id=({className:a})=>e.jsx("svg",{className:a,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})}),nd=({className:a})=>e.jsxs("svg",{"aria-hidden":"true",className:a,viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",fill:"currentColor"}),e.jsx("path",{d:"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",fill:"currentFill"})]}),Xi=({title:a,description:t,active:r,date:s,cancelled:i=!1,showConfetti:n=!1})=>{const o=m=>{if(!m)return null;const u=new Date(m);return I.isValid(u)?I.format(u,"MMM d, yyyy - h:mm a"):null},l=!!s,c=r&&!s;return e.jsxs("div",{className:"relative flex items-start gap-4 pb-8",children:[e.jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-full shrink-0",children:e.jsxs("div",{className:w("w-8 h-8 rounded-full flex items-center justify-center",{"bg-green-100 border-green-500 border-[3px]":l&&!n,"bg-violet-100 border-violet-500 border-[3px]":l&&n,"bg-white":!s,"border-gray-200 border-[3px]":!s&&!r,"bg-red-100 border-red-500 border-[3px]":i}),children:[s&&!n&&!i&&e.jsx(sd,{className:"w-4 h-4 text-green-500"}),l&&n&&e.jsx(N.PartyPopperIcon,{className:"w-4 h-4 text-violet-500"}),i&&e.jsx(id,{className:"w-4 h-4 text-red-500"}),c&&e.jsx(nd,{className:"text-gray-200 animate-spin dark:text-gray-600 fill-blue-600 w-full"})]})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:w("font-black font-red-hat-display",{"text-red-500":i,"text-gray-900":l,"text-gray-500":!i&&!l}),children:a}),e.jsx("p",{className:w("text-sm font-medium",{"text-red-500":i,"text-gray-600":l,"text-gray-400":!i&&!l}),children:t}),o(s)&&e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:o(s)})]})]})},od=({orderId:a})=>{const{client:t}=M(),{clearCart:r}=Ha(),{organization:s,organizationId:i}=ke(),n=E.useSearchParams(),o=E.useRouter(),l=E.usePathname(),{t:c}=Ua(),m=s==null?void 0:s.configuration.defaultCurrency;x.useEffect(()=>{if((n==null?void 0:n.get("clearCart"))==="true"&&l){r();const y=new URLSearchParams(Array.from(n.entries()));y.delete("clearCart");const j=y.toString()?`${l}?${y.toString()}`:l;o.replace(j)}},[r,n,o,l]);const{data:u,isLoading:p,error:g}=A.useQuery({queryKey:["order",a],refetchInterval:({state:y})=>{var j,v;return((j=y.data)==null?void 0:j.status)!=="completed"&&((v=y.data)==null?void 0:v.status)!=="cancelled"?30*1e3:!1},queryFn:async()=>{const{status:y,body:j}=await t.order.getOrder({params:{id:a,organizationId:i}});if(y!==200)throw new Error("Failed to fetch shipping address");return j}}),h=x.useMemo(()=>u?u==null?void 0:u.items.map(y=>({title:y.translations[0].title,subtitle:[y.translations[0].subtitle],price:we(y.unitPrice,m??"USD"),unitPrice:we(y.unitPrice,m??"USD"),quantity:y.quantity,image:y.image})):[],[u,m]);if(!u||p)return e.jsx(Gi,{});const{status:f}=u,b=[{title:c("orderTracking.orderPlaced"),description:c("orderTracking.orderPlacedDesc"),date:new Date(u.expiresAt),active:!1},{title:c("orderTracking.orderAccepted"),description:c("orderTracking.orderAcceptedDesc"),date:u.acceptedAt,active:!u.acceptedAt},{title:c("orderTracking.readyForDispatch"),description:c("orderTracking.readyForDispatchDesc"),date:u.readyForDispatchAt,active:f==="accepted"},{title:c("orderTracking.orderDispatched"),description:c("orderTracking.orderDispatchedDesc"),date:u.dispatchedAt,active:f==="ready-for-dispatch"},{title:c("orderTracking.orderDelivered"),description:c("orderTracking.orderDeliveredDesc"),date:u.completedAt,active:f==="dispatched",showConfetti:!0}];return u.status==="cancelled"&&b.push({title:c("orderTracking.orderCancelled"),description:c("orderTracking.orderCancelledDesc"),date:u.cancelledAt,active:!!u.cancelledAt,cancelled:!0}),e.jsxs(e.Fragment,{children:[e.jsx(_a,{summary:{total:u.payment.total,subtotal:u.payment.subtotal,shipping:u.payment.shipping,items:h}}),e.jsx("div",{children:e.jsxs("div",{className:"flex flex-col md:flex-row h-screen w-screen relative",children:[e.jsx("div",{className:"hidden md:flex items-center justify-end w-full md:w-1/2 h-full px-16 xl:px-24 bg-gray-900 md:overflow-y-auto",children:e.jsx("div",{className:"w-96 animate-fade",children:e.jsxs("div",{className:"pl-6",children:[e.jsx(xr,{items:h,total:u.payment.total,subtotal:u.payment.subtotal,shipping:u.payment.shipping,currency:m??"USD"}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 text-center mt-14 w-full",children:[c("orderTracking.poweredBy")," ",e.jsx("a",{href:"https://shophost.io",className:"text-blue-500 hover:text-blue-600 dark:text-blue-500 dark:hover:text-blue-400",children:"shophost.io"})]})]})})}),e.jsx("div",{className:"flex flex-col items-start 2xl:items-start w-full md:w-1/2 h-full px-6 sm:px-12 xl:px-24 py-8 md:overflow-y-auto relative",children:e.jsxs("div",{className:"md:my-auto animate-fade w-full md:max-w-[432px] pt-14 sm:pt-0",children:[e.jsx("h1",{className:"h3 mb-1 font-red-hat-display",children:c("checkout.yourOrder")}),e.jsxs("div",{className:"mb-8",children:[e.jsxs("p",{className:"text-sm font-medium text-gray-500",children:[c("orderTracking.reference"),": ",u.referenceId]}),e.jsxs("p",{className:"text-sm font-medium text-gray-500",children:[c("orderTracking.status"),":"," ",e.jsx("span",{className:`capitalize font-semibold ${u.status==="cancelled"?"text-red-600":"text-green-600"}`,children:u.status})]})]}),e.jsx("div",{className:"mt-8 space-y-4",children:e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-4 top-0 w-0.5 bg-gray-200",style:{height:`calc(100% - ${b.length>1?"4rem":"0rem"})`}}),b.map((y,j)=>e.jsx(Xi,{...y},j))]})})]})})]})})]})},ld=a=>{const t=a.items.map(r=>{var s;return(s=r.translations[0])==null?void 0:s.title}).filter(Boolean);return t.length===0?"Order placed":t.length===1?t[0]:`${t[0]} +${t.length-1} more`},dd=()=>{var o;const{client:a}=M(),{useSession:t}=Je(),{organizationId:r}=ke(),{data:s}=t(),i=A.useQuery({queryKey:["account","orders","history",r],enabled:!!r&&!!(s!=null&&s.user),queryFn:async()=>{const{body:l,status:c}=await a.order.getMyOrders({params:{organizationId:r},query:{limit:20,page:1}});if(c!==200)throw new Error("Failed to fetch your orders");return l}});if(!(s!=null&&s.user))return null;if(i.isLoading)return e.jsx(fr,{title:"Your orders",description:"Loading your order history."});const n=((o=i.data)==null?void 0:o.list)??[];return e.jsx(Jt,{eyebrow:"My account",title:"Your orders",description:"Everything you've ordered lives here, including totals, fulfilment details, and live status updates.",actions:e.jsxs(e.Fragment,{children:[e.jsx(te,{asChild:!0,variant:"secondary",children:e.jsx(B,{href:"/account",children:"Back to account"})}),e.jsx(te,{asChild:!0,children:e.jsx(B,{href:"/account/reservations",children:"Reservation history"})})]}),children:e.jsx("div",{children:e.jsx(wa,{title:"Order history",description:"Open any order to review the full tracker and line items.",action:e.jsx(ft,{href:"/account",label:"Back to dashboard"}),children:i.isError?e.jsx(ta,{icon:N.ShoppingBagIcon,title:"We couldn't load your orders",description:"Please refresh the page and try again. Your order tracker will be back as soon as the connection recovers."}):n.length===0?e.jsx(ta,{icon:N.ShoppingBagIcon,title:"No orders yet",description:"Once you buy something, this page becomes your personal record of what you ordered and how each order progressed.",actionHref:"/",actionLabel:"Start shopping"}):e.jsx("div",{className:"space-y-4",children:n.map(l=>e.jsx(B,{href:`/account/orders/${l.id}`,className:"storefront-primary-border-hover group block rounded-[24px] border border-stone-200 bg-white p-5 transition duration-200 hover:-translate-y-0.5 hover:shadow-lg",children:e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"font-red-hat-display text-lg font-black text-stone-950",children:ld(l)}),e.jsx(xt,{tone:$i(l.status),children:Zi(l.status)})]}),e.jsxs("p",{className:"mt-2 text-sm leading-6 text-stone-600",children:["Ref ",l.referenceId," • ",l.items.length," item",l.items.length===1?"":"s"," •"," ",l.fulfilmentMethod==="delivery"?"Delivery":"Pickup"]}),e.jsx("div",{className:"mt-4 flex flex-wrap gap-2",children:l.items.slice(0,3).map((c,m)=>{var u;return e.jsx("span",{className:"rounded-full border border-stone-200 bg-stone-50 px-3 py-1 text-xs font-medium text-stone-600",children:((u=c.translations[0])==null?void 0:u.title)??"Item"},`${l.id}-${m}`)})})]}),e.jsxs("div",{className:"shrink-0 text-left lg:text-right",children:[e.jsx("p",{className:"text-lg font-black text-stone-950",children:we(l.payment.total,l.currency)}),e.jsx("p",{className:"mt-1 text-sm text-stone-500",children:aa(l.createdAt,"Recently")}),e.jsx("p",{className:"mt-3 text-sm font-semibold text-stone-700 transition group-hover:text-stone-950",children:"View details"})]})]})},l.id))})})})})},cd=(a,t,r)=>{if(t.length===0)return;let s=a;for(let i=0;i<t.length;i+=1){const n=String(t[i]);if(i===t.length-1){s[n]=r;return}s[n]??(s[n]={}),s=s[n]}},md=a=>async t=>{const r=await a.safeParseAsync(t);if(r.success)return{values:r.data,errors:{}};const s={};for(const i of r.error.issues)cd(s,i.path.filter(n=>typeof n=="string"||typeof n=="number"),{type:i.code,message:i.message});return{values:{},errors:s}},ud=({initialData:a})=>{var u;const{client:t}=M(),{organizationId:r,organization:s}=ke(),{t:i}=Ua(),n=E.useRouter(),o=(u=s==null?void 0:s.configuration)==null?void 0:u.isAcceptingReservations,l=[s==null?void 0:s.phone,s==null?void 0:s.email].filter(p=>!!p),c=U.useForm({resolver:md(ui),reValidateMode:"onChange",defaultValues:{firstname:a.firstname,lastname:a.lastname}}),m=A.useMutation({mutationFn:async p=>{const{status:g,body:h}=await t.reservation.createReservation({body:p,params:{organizationId:r}});if(g!==201)throw new Error("Failed to create shipping address");return h},onSuccess:p=>{n.push(`/account/reservations/${p.id}`)}});return e.jsxs("div",{className:"flex flex-col gap-4",children:[s&&o===!1&&e.jsxs("div",{className:"rounded-[28px] border border-amber-200 bg-amber-50 px-5 py-4 text-amber-950",children:[e.jsx("h2",{className:"font-red-hat-display text-lg font-black",children:i("reservation.bookingDisabled")}),e.jsx("p",{className:"mt-2 text-sm leading-6",children:i("reservation.bookingDisabledDesc")}),l.length>0&&e.jsx("div",{className:"mt-3 text-sm font-medium",children:l.map(p=>e.jsx("div",{children:p},p))})]}),o===!1?e.jsx(te,{variant:"secondary",className:"shadow-none",type:"button",onClick:()=>n.push("/"),children:"Back"}):e.jsx(U.FormProvider,{...c,children:e.jsxs("form",{onSubmit:c.handleSubmit(p=>m.mutate(p)),children:[e.jsxs("div",{className:"grid grid-cols-4 gap-x-4 gap-y-4 mt-3",children:[e.jsx(Ne,{name:"firstname",label:"First Name",type:"text",className:"col-span-2",placeholder:"e.g. John"}),e.jsx(Ne,{name:"lastname",label:"Last Name",type:"text",className:"col-span-2",placeholder:"e.g. Doe"}),e.jsx(Ne,{name:"phone",label:"Phone",type:"phone-number",className:"col-span-4",placeholder:"e.g. +48 123 456 789"}),e.jsx(Ne,{name:"guests",label:"Number of Guests",type:"number",className:"col-span-4",placeholder:"e.g. 2"}),e.jsx(Ne,{name:"date",type:"week-time",className:"col-span-4 -mt-4"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-2 w-full mt-8",children:[e.jsx(te,{variant:"secondary",className:"shadow-none",type:"button",onClick:()=>n.push("/"),children:"Back"}),e.jsx(te,{type:"submit",className:"shadow-none",isLoading:m.isPending,loadingText:"Saving...",children:"Send Request"})]})]})})]})},pd=()=>{const{useSession:a}=Je(),{organization:t}=ke(),{data:r}=a(),s=t!=null&&t.name?`Enter your details to book a table at ${t.name}`:"Enter your details to book a table";return r!=null&&r.user?e.jsx(Ui,{title:"Book a table",description:s,children:e.jsx(ud,{initialData:{firstname:r.user.firstname,lastname:r.user.lastname}})}):null},ss=(a,t)=>{if(!a)return t("reservation.notSpecified");const r=new Date(a);return I.isValid(r)?I.format(r,"MMM d, yyyy - h:mm a"):t("reservation.invalidDate")},gd=({reservationId:a})=>{const{client:t}=M(),{organizationId:r}=ke(),{t:s}=Ua(),{data:i,isLoading:n}=A.useQuery({queryKey:["reservation",a],queryFn:async()=>{const{status:c,body:m}=await t.reservation.getReservation({params:{reservationId:a,organizationId:r}});if(c!==200)throw new Error("Failed to fetch reservation");return m},refetchInterval:({state:c})=>{var m,u;return!((m=c.data)!=null&&m.acceptedAt)&&!((u=c.data)!=null&&u.cancelledAt)?30*1e3:!1}});if(!i||n)return e.jsx(Gi,{});const o=[{title:s("reservation.requestSent"),description:s("reservation.requestSentDesc"),date:i.createdAt||new Date,active:!1},{title:s("reservation.confirmed"),description:s("reservation.confirmedDesc"),date:i.acceptedAt,active:!i.acceptedAt,showConfetti:!!i.acceptedAt}];i.cancelledAt&&o.push({title:s("reservation.cancelled"),description:s("reservation.cancelledDesc"),date:i.cancelledAt,active:!1,cancelled:!0});const l=()=>i.cancelledAt?s("reservation.cancelledStatus"):i.acceptedAt?s("reservation.confirmedStatus"):s("reservation.pendingStatus");return e.jsxs(e.Fragment,{children:[e.jsx(_a,{}),e.jsxs("div",{className:"flex flex-col md:flex-row h-screen w-screen relative",children:[e.jsx("div",{className:"hidden md:flex items-center justify-end w-full md:w-1/2 h-full px-16 xl:px-24 bg-gray-900 md:overflow-y-auto",children:e.jsx("div",{className:"w-96 animate-fade",children:e.jsxs("div",{className:"pl-6",children:[e.jsxs("div",{className:"px-7 pt-10 pb-0 md:pt-0 md:px-0",children:[e.jsx("div",{className:"my-3 sm:my-6 sm:pb-1",children:e.jsxs("div",{className:"flex flex-col w-full mb-5 sm:mb-3",children:[e.jsx("h2",{className:"text-xl font-bold text-white mb-2",children:s("reservation.reservationDetails")}),e.jsxs("p",{className:"text-white font-medium text-sm mb-1",children:[e.jsxs("span",{className:"opacity-70 font-semibold",children:[s("reservation.name"),":"]})," ",i.firstname," ",i.lastname]}),e.jsxs("p",{className:"text-white font-medium text-sm mb-1",children:[e.jsxs("span",{className:"opacity-70 font-semibold",children:[s("reservation.phone"),":"]})," ",i.phone]}),e.jsxs("p",{className:"text-white font-medium text-sm mb-1",children:[e.jsxs("span",{className:"opacity-70 font-semibold",children:[s("reservation.guests"),":"]})," ",i.guests]}),e.jsxs("p",{className:"text-white font-medium text-sm mb-1",children:[e.jsxs("span",{className:"opacity-70 font-semibold",children:[s("reservation.date"),":"]})," ",ss(i.date,s)]})]})}),e.jsx("hr",{className:"opacity-10 my-4 sm:my-4"}),e.jsx("div",{className:"mt-4",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("h2",{className:"text-sm xl:text-lg text-white font-black font-red-hat-display",children:s("common.makeReservation")}),e.jsx("span",{className:`ml-auto py-1 px-3 rounded-full text-sm font-semibold ${i.cancelledAt?"bg-red-100 text-red-800":i.acceptedAt?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"}`,children:l()})]})})]}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 text-center mt-14 w-full",children:[s("reservation.poweredBy")," ",e.jsx("a",{href:"https://shophost.io",className:"text-blue-500 hover:text-blue-600 dark:text-blue-500 dark:hover:text-blue-400",children:"shophost.io"})]})]})})}),e.jsx("div",{className:"flex flex-col items-start 2xl:items-start w-full md:w-1/2 h-full px-6 sm:px-12 xl:px-24 py-8 md:overflow-y-auto relative animate-fade-in",children:e.jsxs("div",{className:"md:my-auto animate-fade w-full md:max-w-[432px] pt-14 sm:pt-0",children:[e.jsx("h1",{className:"h3 mb-1 font-red-hat-display",children:s("common.makeReservation")}),e.jsxs("div",{className:"mb-8",children:[e.jsxs("p",{className:"text-sm font-medium text-gray-500",children:[s("reservation.reference"),": ",i.referenceId]}),e.jsxs("p",{className:"text-sm font-medium text-gray-500",children:[s("reservation.status"),":"," ",e.jsx("span",{className:`capitalize font-semibold ${i.cancelledAt?"text-red-600":i.acceptedAt?"text-green-600":"text-yellow-600"}`,children:l()})]}),e.jsxs("div",{className:"mt-10 border-b pb-6 md:hidden",children:[e.jsx("div",{className:"flex items-center",children:e.jsx("h2",{className:"text-lg font-black font-red-hat-display text-gray-900",children:s("reservation.reservationDetails")})}),e.jsxs("p",{className:"text-sm font-medium text-gray-600 mb-1",children:[e.jsxs("span",{className:"font-semibold",children:[s("reservation.name"),":"]})," ",i.firstname," ",i.lastname]}),e.jsxs("p",{className:"text-sm font-medium text-gray-600 mb-1",children:[e.jsxs("span",{className:"font-semibold",children:[s("reservation.phone"),":"]})," ",i.phone]}),e.jsxs("p",{className:"text-sm text-gray-600 mb-1",children:[e.jsxs("span",{className:"font-semibold",children:[s("reservation.guests"),":"]})," ",i.guests]}),e.jsxs("p",{className:"text-sm font-medium text-gray-600 mb-1",children:[e.jsxs("span",{className:"font-semibold",children:[s("reservation.date"),":"]})," ",ss(i.date,s)]})]})]}),e.jsx("div",{className:"mt-8 space-y-4",children:e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-4 top-0 w-0.5 bg-gray-200",style:{height:`calc(100% - ${o.length>1?"4rem":"0rem"})`}}),o.map((c,m)=>e.jsx(Xi,{...c},m))]})})]})})]})]})},hd=()=>{var o;const{client:a}=M(),{useSession:t}=Je(),{organizationId:r}=ke(),{data:s}=t(),i=A.useQuery({queryKey:["account","reservations","history",r],enabled:!!r&&!!(s!=null&&s.user),queryFn:async()=>{const{body:l,status:c}=await a.reservation.getMyReservations({params:{organizationId:r},query:{limit:20,page:1}});if(c!==200)throw new Error("Failed to fetch your reservations");return l}});if(!(s!=null&&s.user))return null;if(i.isLoading)return e.jsx(fr,{title:"Reservation history",description:"Loading your reservations."});const n=((o=i.data)==null?void 0:o.list)??[];return e.jsx(Jt,{eyebrow:"My account",title:"Reservation history",description:"Keep track of upcoming tables, past visits, and every booking status change in one place.",actions:e.jsxs(e.Fragment,{children:[e.jsx(te,{asChild:!0,variant:"secondary",children:e.jsx(B,{href:"/account",children:"Back to account"})}),e.jsx(te,{asChild:!0,children:e.jsx(B,{href:"/account/reservations/book",children:"Book a table"})})]}),children:e.jsx("div",{children:e.jsx(wa,{title:"Your bookings",description:"Open any reservation to review the confirmation timeline and details.",action:e.jsx(ft,{href:"/account",label:"Back to dashboard"}),children:i.isError?e.jsx(ta,{icon:N.CalendarDaysIcon,title:"We couldn't load your reservations",description:"Please refresh the page and try again. Your booking history will return as soon as the connection is restored."}):n.length===0?e.jsx(ta,{icon:N.CalendarDaysIcon,title:"No reservations yet",description:"Once you book a table, this page will keep the full history of confirmed, pending, and cancelled reservations.",actionHref:"/account/reservations/book",actionLabel:"Book a table"}):e.jsx("div",{className:"space-y-4",children:n.map(l=>e.jsx(B,{href:`/account/reservations/${l.id}`,className:"storefront-primary-border-hover group block rounded-[24px] border border-stone-200 bg-white p-5 transition duration-200 hover:-translate-y-0.5 hover:shadow-lg",children:e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"font-red-hat-display text-lg font-black text-stone-950",children:aa(l.date,"Date pending","EEEE, MMM d")}),e.jsx(xt,{tone:Wi(l),children:_i(l)})]}),e.jsxs("p",{className:"mt-2 text-sm leading-6 text-stone-600",children:["Ref ",l.referenceId," • ",l.guests," ","guest",l.guests===1?"":"s"]}),e.jsxs("div",{className:"mt-4 inline-flex rounded-full border border-stone-200 bg-stone-50 px-3 py-1 text-xs font-medium text-stone-600",children:["Reserved under ",l.firstname," ",l.lastname]})]}),e.jsxs("div",{className:"shrink-0 text-left lg:text-right",children:[e.jsx("p",{className:"text-lg font-black text-stone-950",children:aa(l.date,"Awaiting time","h:mm a")}),e.jsxs("p",{className:"mt-1 text-sm text-stone-500",children:["Created"," ",aa(l.createdAt,"Recently")]}),e.jsx("p",{className:"mt-3 text-sm font-semibold text-stone-700 transition group-hover:text-stone-950",children:"View details"})]})]})},l.id))})})})})},xd=()=>{const a=E.useSearchParams(),{signIn:t}=Je(),{baseUrl:r}=M(),s=(a==null?void 0:a.get("redirect"))??"/checkout/customer-details",{register:i,handleSubmit:n,formState:{errors:o,isSubmitting:l}}=U.useForm({resolver:fe.zodResolver(ci),shouldFocusError:!0}),c=async u=>{await t.email({email:u.email,password:u.password,callbackURL:`${r}${s}`})},m=async u=>{u.preventDefault(),await t.social({provider:"google",callbackURL:`${r}${s}`})};return e.jsxs("div",{className:"flex w-full flex-col items-start sm:max-w-sm",children:[e.jsxs("div",{className:"mt-6 flex flex-col",children:[e.jsx("h1",{className:"h4 font-black font-red-hat-display",children:"Log in"}),e.jsxs("p",{className:"mt-1 text-sm text-gray-700 dark:text-gray-300",children:["Login or create an account to continue. Don’t have an account?"," ",e.jsx(B,{className:"storefront-primary-text storefront-primary-text-hover",href:`/account/sign-up?redirect=${s}`,children:"Sign up"})]})]}),e.jsxs("div",{className:"mt-10 w-full",children:[e.jsx("div",{className:"gap-2 sm:flex sm:flex-row sm:items-center",children:e.jsxs(te,{variant:"secondary",type:"button",className:"mt-2 w-full sm:mt-0 shadow-none inline-flex items-center gap-2",onClick:m,children:[e.jsx(P.RiGoogleFill,{className:"size-4","aria-hidden":"true"}),"Login with Google"]})}),e.jsx(Na,{className:"my-6",children:"or"}),e.jsxs("form",{onSubmit:n(c),className:"flex w-full flex-col gap-y-6",children:[e.jsxs("div",{className:"flex flex-col gap-y-4",children:[e.jsxs("div",{className:"flex flex-col space-y-2",children:[e.jsx(Re,{htmlFor:"email-form-item",className:"font-medium",children:"Email"}),e.jsx(De,{type:"email",autoComplete:"email",id:"email-form-item",placeholder:"emily.ross@acme.ch",...i("email")}),o.email&&e.jsx("span",{className:"text-sm text-red-500",children:o.email.message})]}),e.jsxs("div",{className:"flex flex-col space-y-2",children:[e.jsx(Re,{htmlFor:"password-form-item",className:"font-medium",children:"Password"}),e.jsx(De,{type:"password",autoComplete:"current-password",id:"password-form-item",placeholder:"Password",...i("password")}),o.password&&e.jsx("span",{className:"text-sm text-red-500",children:o.password.message})]})]}),e.jsx(te,{type:"submit",className:"shadow-none",isLoading:l,children:l?"Submitting...":"Continue"})]})]}),e.jsx(Na,{}),e.jsxs("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:["Forgot your password?"," ",e.jsx("a",{className:"storefront-primary-text storefront-primary-text-hover",href:"#",children:"Reset password"})]})]})},fd=()=>e.jsx(xd,{}),yd=()=>{const a=E.useSearchParams(),{signUp:t,signIn:r}=Je(),{baseUrl:s}=M(),i=(a==null?void 0:a.get("redirect"))??"/checkout/customer-details",{register:n,handleSubmit:o,formState:{errors:l}}=U.useForm({resolver:fe.zodResolver(mr),shouldFocusError:!0}),{isPending:c,isError:m,mutate:u}=A.useMutation({onMutate:async g=>t.email({email:g.email,password:g.password,name:`${g.firstname} ${g.lastname}`,firstname:g.firstname,lastname:g.lastname,callbackURL:`${s}${i}`})}),p=async g=>(g.preventDefault(),r.social({provider:"google",callbackURL:`${s}${i}`}));return e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex w-full flex-col items-start md:max-w-sm",children:[e.jsxs("div",{className:"mt-6 flex flex-col",children:[e.jsx("h1",{className:"h4 font-black font-red-hat-display",children:"Create an account"}),e.jsxs("p",{className:"mt-1 text-sm text-gray-700 dark:text-gray-300",children:["Already have an account?"," ",e.jsx(B,{className:"storefront-primary-text storefront-primary-text-hover",href:"/account/sign-in",children:"Sign in"})]})]}),e.jsxs("div",{className:"mt-10 w-full",children:[e.jsx("div",{className:"gap-2 sm:flex sm:flex-row sm:items-center",children:e.jsxs(te,{variant:"secondary",type:"button",className:"mt-2 w-full sm:mt-0 inline-flex items-center gap-2 shadow-none",onClick:p,children:[e.jsx(P.RiGoogleFill,{className:"size-4","aria-hidden":"true"}),"Signin with Google"]})}),e.jsx(Na,{className:"my-6",children:"or"}),e.jsxs("form",{onSubmit:o(g=>u(g)),className:"flex w-full flex-col gap-y-6",children:[e.jsxs("div",{className:"flex flex-col gap-y-4",children:[e.jsxs("div",{className:"flex flex-col space-y-2",children:[e.jsx(Re,{htmlFor:"email-form-item",className:"font-medium",children:"First Name"}),e.jsx(De,{type:"text",id:"email-form-item",placeholder:"Emily",...n("firstname")}),l.firstname&&e.jsx("span",{className:"text-sm text-red-500",children:l.firstname.message})]}),e.jsxs("div",{className:"flex flex-col space-y-2",children:[e.jsx(Re,{htmlFor:"email-form-item",className:"font-medium",children:"Last Name"}),e.jsx(De,{type:"text",id:"email-form-item",placeholder:"Emily",...n("lastname")}),l.lastname&&e.jsx("span",{className:"text-sm text-red-500",children:l.lastname.message})]}),e.jsxs("div",{className:"flex flex-col space-y-2",children:[e.jsx(Re,{htmlFor:"email-form-item",className:"font-medium",children:"Email"}),e.jsx(De,{type:"email",autoComplete:"email",id:"email-form-item",placeholder:"emily.ross@acme.ch",...n("email")}),l.email&&e.jsx("span",{className:"text-sm text-red-500",children:l.email.message})]}),e.jsxs("div",{className:"flex flex-col space-y-2",children:[e.jsx(Re,{htmlFor:"password-form-item",className:"font-medium",children:"Password"}),e.jsx(De,{type:"password",autoComplete:"current-password",id:"password-form-item",placeholder:"Password",...n("password")}),l.password&&e.jsx("span",{className:"text-sm text-red-500",children:l.password.message})]})]}),m&&e.jsx("span",{className:"text-sm text-red-500",children:"An error occurred, please try again."}),e.jsx(te,{type:"submit",isLoading:c,children:c?"Submitting...":"Continue"})]})]}),e.jsx(Na,{}),e.jsxs("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:["Forgot your password?"," ",e.jsx("a",{className:"storefront-primary-text storefront-primary-text-hover",href:"#",children:"Reset password"})]})]})})},bd=()=>e.jsx(yd,{}),jd=()=>{const{segments:a}=E.useParams(),[t,...r]=a??[];if(!t)return e.jsx(ca,{children:e.jsx(Ki,{})});switch(t){case"sign-in":return r.length!==0?E.notFound():e.jsx(ts,{children:e.jsx(fd,{})});case"sign-up":return r.length!==0?E.notFound():e.jsx(ts,{children:e.jsx(bd,{})});case"orders":return r.length>1?E.notFound():r.length===0?e.jsx(ca,{children:e.jsx(dd,{})}):e.jsx(ca,{children:e.jsx(od,{orderId:r[0]})});case"reservations":return r.length>1?E.notFound():r.length===0?e.jsx(ca,{children:e.jsx(hd,{})}):r[0]==="book"?e.jsx(ca,{children:e.jsx(pd,{})}):e.jsx(ca,{children:e.jsx(gd,{reservationId:r[0]})});default:return E.notFound()}},vd=a=>{if(a[0]==="reservation"&&a.length===1)return e.jsx(Yt,{});if(a.length!==1)return E.notFound();switch(a[0]){case"customer-details":return e.jsx(Yt,{});case"shipping-and-payment":return e.jsx(qi,{});default:return E.notFound()}},wd=()=>{const a=E.useParams(),{useSession:t}=Je(),r=E.useRouter(),{data:s,isPending:i}=t(),{loading:n,formattedCartItems:o,total:l,subtotal:c,shipping:m}=At(),{organization:u,loading:p}=ke(),g=(a==null?void 0:a.segments)||[];if(x.useEffect(()=>{!i&&!s&&r.push("/account/sign-in?redirect=/checkout/customer-details")},[s,i,r]),p||n||i)return e.jsx("div",{className:"flex flex-col items-center justify-center h-screen w-screen bg-gray-900",children:e.jsx("div",{className:"mb-4",children:e.jsx("div",{className:"storefront-primary-border animate-spin rounded-full h-18 w-18 border-b-2"})})});if(!u)return e.jsx("div",{className:"flex flex-col items-center justify-center h-screen w-screen bg-gray-900",children:e.jsx("h1",{className:"text-2xl font-bold",children:"Organization not found"})});if(!u.configuration.isAcceptingOrders||!u.configuration.isOpen){const h=[u.phone,u.email].filter(f=>!!f);return e.jsx("div",{className:"flex flex-col items-center justify-center h-screen w-screen bg-gray-900 text-center animate-fade-in",children:u.configuration.isOpen?e.jsxs("div",{className:"relative z-10 max-w-[800px] px-10",children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-black font-red-hat-display text-white",children:"Unfortunately, We're currently not accepting online orders."}),e.jsxs("p",{className:"text-gray-100 font-medium mt-3 text-lg mt-",children:["Please contact us directly for any inquiries.",h.map(f=>e.jsxs(x.Fragment,{children:[e.jsx("br",{}),f]},f))]}),e.jsx(B,{className:"storefront-primary-action btn-sm mt-6 rounded-lg shrink-0",href:"/",children:"Back to Homepage"})]}):e.jsxs("div",{className:"relative z-10",children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-black font-red-hat-display text-white",children:"Sorry, we're currently closed"}),e.jsxs("p",{className:"text-gray-100 font-medium mt-3 text-lg mt-",children:["Please contact us directly for any inquiries.",h.map(f=>e.jsxs(x.Fragment,{children:[e.jsx("br",{}),f]},f))]}),e.jsx(B,{className:"storefront-primary-action btn-sm mt-6 rounded-lg shrink-0",href:"/",children:"Back to Homepage"})]})})}return e.jsxs(e.Fragment,{children:[e.jsx(_a,{summary:{total:l,subtotal:c,shipping:m,items:o}}),e.jsx("div",{children:e.jsxs("div",{className:"flex flex-col md:flex-row h-screen w-screen relative",children:[e.jsx("div",{className:"hidden md:flex items-center justify-end w-full md:w-1/2 h-full px-16 xl:px-24 bg-gray-900 md:overflow-y-auto",children:e.jsxs("div",{className:"w-96 animate-fade",children:[e.jsx("div",{className:"pl-6",children:e.jsx(xr,{items:o,total:l,subtotal:c,shipping:m,currency:u.configuration.defaultCurrency||"USD"})}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 text-center mt-14 w-full",children:["Powered by"," ",e.jsx("a",{href:"https://shophost.io",className:"storefront-primary-text storefront-primary-text-hover",children:"shophost.io"})]})]})}),e.jsx("div",{className:"flex flex-col items-start 2xl:items-start w-full md:w-1/2 h-full px-6 sm:px-12 xl:px-24 py-8 md:overflow-y-auto relative",children:e.jsx("div",{className:"py-10 xl:py-24 md:my-auto animate-fade w-full md:max-w-[432px]",children:vd(g)})})]})})]})},Yi=({children:a})=>{const{isOpen:t,onClose:r,product:s,modifierGroups:i,hasModifiers:n,productName:o,quantity:l,handleIncrement:c,handleDecrement:m,handleQuantityInput:u,isIncrementDisabled:p,isSubmitting:g,isOutOfStock:h,maxQuantity:f,stockMessage:b,handleAddToCart:y,validationError:j}=Za();if(!s)return null;const v=l<=1;return a({modifierGroups:i,hasModifiers:n,product:s,isOpen:t,onClose:r,productName:o,quantity:l,onIncrement:c,onDecrement:m,onQuantityInput:u,isDecrementDisabled:v,isIncrementDisabled:p,isSubmitting:g,isOutOfStock:h,maxQuantity:f,stockMessage:b,onAddToCart:y,validationError:j})},en=({children:a,group:t,renderOptions:r})=>{const{getModifierGroupName:s}=Za(),i=s(t),n=t.selectMin>0;let o=null;return t.selectMin>0&&t.selectMax>0&&(o=t.selectMin===t.selectMax?`${t.selectMin} option`:`${t.selectMin}-${t.selectMax}`),a({group:t,groupName:i,isRequired:n,selectionRequirements:o,renderOptions:r})},an=({children:a,modifier:t,groupId:r})=>{var f;const{isModifierSelected:s,isMultiSelect:i,toggleModifier:n,selectModifier:o,formatModifierPrice:l,product:c,locale:m}=Za(),u=s(r,t.id),p=(f=c==null?void 0:c.modifierGroups)==null?void 0:f.find(b=>b.id===r),g=p?i(p):!1,h=l(t,(c==null?void 0:c.currency)??"USD");return a({modifier:t,isSelected:u,onSelect:()=>{g?n(r,t.id):o(r,t.id)},isMultiSelect:g,formattedPrice:h})},kd=e.jsx("div",{className:"p-4 text-center text-gray-500",children:"This product has no modifiers."}),Nd=({addToCartLabel:a="Add to Cart",emptyState:t=kd,panelClassName:r,renderFooter:s,renderGroup:i,renderHeader:n,renderOption:o})=>{const{t:l}=Ua();return e.jsx(Yi,{children:({isOpen:c,onClose:m,product:u,modifierGroups:p,quantity:g,onIncrement:h,onDecrement:f,isDecrementDisabled:b,isIncrementDisabled:y,isSubmitting:j,isOutOfStock:v,maxQuantity:k,onAddToCart:C,onQuantityInput:F,stockMessage:T,validationError:O})=>e.jsx(Ft,{open:c,onOpenChange:R=>{R||m()},children:e.jsxs(Mt,{className:w("w-[calc(100vw)] max-w-[calc(100vw)] sm:max-w-md max-h-[75vh] sm:max-h-[90vh] overflow-x-hidden overflow-y-auto p-0 h-min","top-auto left-1/2 right-auto bottom-0 -translate-x-1/2 translate-y-0 rounded-t-xl rounded-b-none border-none","sm:top-1/2 sm:left-1/2 sm:right-auto sm:bottom-auto sm:-translate-x-1/2 sm:-translate-y-1/2 sm:rounded-xl sm:border",r),children:[n?n({onClose:m,product:u}):e.jsxs("div",{className:"flex justify-between items-start pb-3",children:[e.jsx("div",{className:"absolute left-1/2 -translate-x-1/2 top-2 w-12 h-1.5 bg-gray-300 rounded-full sm:hidden"}),e.jsxs("div",{children:[e.jsx(ur,{className:"text-2xl font-black font-red-hat-display",children:u.title}),e.jsx("p",{className:"text-sm text-gray-500",children:u.description})]}),e.jsx("button",{type:"button",onClick:m,className:"cursor-pointer text-gray-500 hover:text-gray-700 text-2xl leading-none","aria-label":"Close modal",children:"×"})]}),p.length>0?e.jsxs("div",{children:[p.map(R=>e.jsx(en,{group:R,renderOptions:()=>R.modifiers.map(S=>e.jsx(an,{modifier:S,groupId:R.id,children:Q=>o?o(Q):e.jsxs("div",{className:w("mb-1.5 flex cursor-pointer items-center rounded-lg border px-3 py-2 text-sm font-medium text-gray-600 dark:text-gray-400",Q.isSelected?"border-blue-500 bg-blue-50":"border-gray-200"),onClick:Q.onSelect,children:[e.jsx("input",{type:Q.isMultiSelect?"checkbox":"radio",checked:Q.isSelected,className:"mr-2",onChange:W=>W.preventDefault()}),e.jsxs("span",{children:[Q.modifier.title,Q.formattedPrice]})]})},S.id)),children:S=>i?i(S):e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"font-medium mb-2",children:[e.jsxs("div",{className:"flex items-center font-black font-red-hat-display text-lg",children:[S.groupName,S.isRequired&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),S.selectionRequirements&&e.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Select ",S.selectionRequirements]})]}),e.jsx("div",{children:S.renderOptions()})]})},R.id)),(O||T)&&e.jsx("div",{className:"mb-2 text-sm text-red-500",children:O||T})]}):t,s?s({isDecrementDisabled:b,isIncrementDisabled:y,isSubmitting:j,isOutOfStock:v,maxQuantity:k,onAddToCart:C,onDecrement:f,onIncrement:h,onQuantityInput:F,quantity:g,stockMessage:T,validationError:O}):e.jsxs("div",{className:"flex items-center mt-8 border-t pt-4",children:[e.jsx("div",{children:e.jsxs("div",{className:"flex items-center justify-center gap-2.5",children:[e.jsx("button",{type:"button",onClick:f,className:w("flex h-9 min-w-9 items-center justify-center rounded-lg border text-base",b||j?"cursor-not-allowed opacity-50":"cursor-pointer"),"aria-label":"Decrease quantity",disabled:b||j,children:"-"}),e.jsx(De,{min:1,max:v?1:k??void 0,step:1,value:g,onChange:R=>F(R.target.value),disabled:j,inputClassName:"h-9 px-2 text-center",className:"max-w-10 min-w-10","aria-label":"Quantity"}),e.jsx("button",{type:"button",onClick:h,className:w("flex h-9 min-w-9 items-center justify-center rounded-lg border text-base",y||j?"cursor-not-allowed opacity-50":"cursor-pointer"),"aria-label":"Increase quantity",disabled:y||j,children:"+"})]})}),e.jsx("div",{className:"pl-4 sm:pl-5 w-full",children:e.jsx("button",{type:"button",onClick:C,className:"storefront-primary-action btn text-sm rounded-lg w-full",disabled:v||j,children:j?e.jsxs("span",{className:"inline-flex items-center justify-center gap-2",children:[e.jsx(P.RiLoader2Fill,{className:"size-4 animate-spin","aria-hidden":"true"}),l("common.loading")]}):v?"Out of stock":a})})]})]})})})},Ad=({children:a,minQuantity:t=1})=>{const{quantity:r,handleIncrement:s,handleDecrement:i,handleQuantityInput:n,isIncrementDisabled:o}=Za(),l=r<=t;return a({quantity:r,onIncrement:s,onDecrement:i,onQuantityInput:n,isDecrementDisabled:l,isIncrementDisabled:o})},Cd=({children:a,locale:t="en"})=>e.jsx(_s,{locale:t,children:a}),Sd=(a,t=[])=>{const[r,s]=x.useState(null),[i,n]=x.useState(!0),[o,l]=x.useState(null),c=JSON.stringify(t.map(m=>m.id));return x.useEffect(()=>{(async()=>{n(!0);try{const m=t.find(u=>u.id===a);if(m)s(m);else throw new Error(`Product with ID ${a} not found`)}catch(m){l(m instanceof Error?m:new Error("Failed to fetch product"))}finally{n(!1)}})()},[a,c]),{product:r,loading:i,error:o}},zd=(a,t=[])=>{const[r,s]=x.useState({}),[i,n]=x.useState(!0),[o,l]=x.useState(null),c=JSON.stringify(a.sort());return x.useEffect(()=>{const m=async()=>{n(!0);try{const u=t.filter(g=>a.includes(g.id)).reduce((g,h)=>(g[h.id]=h,g),{});s(u);const p=a.filter(g=>!u[g]);p.length>0&&console.warn(`Products with IDs ${p.join(", ")} not found`)}catch(u){l(u instanceof Error?u:new Error("Failed to fetch products"))}finally{n(!1)}};a.length>0?m():(s({}),n(!1))},[c,t]),{products:r,getProduct:m=>r[m]||null,loading:i,error:o}},Id=[{id:"product-1",slug:"classic-burger",sku:"BURGER-001",basePrice:12.99,discountedBasePrice:null,currency:"USD",images:[{id:"img-1",url:"https://images.unsplash.com/photo-1568901346375-23c9450c58cd?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1000&q=80",mimeType:"image/jpeg",size:65783,filename:"classic-burger.jpeg"}],modifierGroups:[],categories:[{id:"cat-1",slug:"burgers",createdAt:"2023-01-01T00:00:00.000Z",translations:[{locale:"en",title:"Burgers",description:""},{locale:"pl",title:"Burgery",description:""}]}],manufacturerId:null,createdAt:"2023-01-01T00:00:00.000Z",publishedAt:"2023-01-01T00:00:00.000Z",translations:[{locale:"en",title:"Classic Burger",description:"A juicy beef patty with lettuce, tomato, onion, and our special sauce on a toasted bun."},{locale:"pl",title:"Klasyczny Burger",description:"Soczysta wołowina z sałatą, pomidorem, cebulą i naszym specjalnym sosem na opiekanej bułce."}]},{id:"product-2",slug:"custom-pizza",sku:"PIZZA-001",basePrice:14.99,discountedBasePrice:null,currency:"USD",images:[{id:"img-2",url:"https://images.unsplash.com/photo-1513104890138-7c749659a591?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1000&q=80",mimeType:"image/jpeg",size:75783,filename:"custom-pizza.jpeg"}],modifierGroups:[{id:"mod-group-1",selectMin:1,selectMax:1,modifiers:[{id:"mod-1-1",title:"Thin Crust",sku:null,price:0},{id:"mod-1-2",title:"Regular Crust",sku:null,price:0},{id:"mod-1-3",title:"Thick Crust",sku:null,price:2}],translations:[{locale:"en",title:"Crust Type"},{locale:"pl",title:"Rodzaj Ciasta"}]},{id:"mod-group-2",selectMin:1,selectMax:1,modifiers:[{id:"mod-2-1",title:"Tomato Sauce",sku:null,price:0},{id:"mod-2-2",title:"White Sauce",sku:null,price:0},{id:"mod-2-3",title:"BBQ Sauce",sku:null,price:0}],translations:[{locale:"en",title:"Sauce"},{locale:"pl",title:"Sos"}]}],categories:[{id:"cat-2",slug:"pizza",createdAt:"2023-01-01T00:00:00.000Z",translations:[{locale:"en",title:"Pizza",description:""},{locale:"pl",title:"Pizza",description:""}]}],manufacturerId:null,createdAt:"2023-01-01T00:00:00.000Z",publishedAt:"2023-01-01T00:00:00.000Z",translations:[{locale:"en",title:"Custom Pizza",description:"Build your own pizza with your choice of crust and sauce. Comes with cheese and tomatoes."},{locale:"pl",title:"Pizza Własna",description:"Zbuduj własną pizzę z wybranym rodzajem ciasta i sosu. Zawiera ser i pomidory."}]},{id:"product-3",slug:"build-your-salad",sku:"SALAD-001",basePrice:9.99,discountedBasePrice:null,currency:"USD",images:[{id:"img-3",url:"https://images.unsplash.com/photo-1512621776951-a57141f2eefd?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1000&q=80",mimeType:"image/jpeg",size:55783,filename:"build-your-salad.jpeg"}],modifierGroups:[{id:"mod-group-3",selectMin:0,selectMax:5,modifiers:[{id:"mod-3-1",title:"Grilled Chicken",sku:null,price:2.5},{id:"mod-3-2",title:"Bacon",sku:null,price:1.5},{id:"mod-3-3",title:"Avocado",sku:null,price:2},{id:"mod-3-4",title:"Feta Cheese",sku:null,price:1},{id:"mod-3-5",title:"Boiled Egg",sku:null,price:1}],translations:[{locale:"en",title:"Toppings"},{locale:"pl",title:"Dodatki"}]},{id:"mod-group-4",selectMin:0,selectMax:1,modifiers:[{id:"mod-4-1",title:"Ranch",sku:null,price:0},{id:"mod-4-2",title:"Balsamic Vinaigrette",sku:null,price:0},{id:"mod-4-3",title:"Caesar",sku:null,price:0},{id:"mod-4-4",title:"Olive Oil & Lemon",sku:null,price:0}],translations:[{locale:"en",title:"Dressing"},{locale:"pl",title:"Dressing"}]}],categories:[{id:"cat-3",slug:"salads",createdAt:"2023-01-01T00:00:00.000Z",translations:[{locale:"en",title:"Salads",description:""},{locale:"pl",title:"Sałatki",description:""}]}],manufacturerId:null,createdAt:"2023-01-01T00:00:00.000Z",publishedAt:"2023-01-01T00:00:00.000Z",translations:[{locale:"en",title:"Build Your Salad",description:"Fresh mixed greens with cherry tomatoes, cucumber, and red onion. Add your favorite toppings and dressing."},{locale:"pl",title:"Skomponuj Swoją Sałatkę",description:"Świeże mieszane sałaty z pomidorkami koktajlowymi, ogórkiem i czerwoną cebulą. Dodaj ulubione dodatki i dressing."}]}],Ed=new A.QueryClient({defaultOptions:{queries:{retry:!1,refetchInterval:!1,refetchOnWindowFocus:!1}}}),yt="#ffffff",is="#0f172a",tn=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/,Dd=/^(?:rgb|rgba|hsl|hsla|oklch|oklab|var)\([^;{}]+\)$/i,Rd=/^(?:bg-)?([a-z]+(?:-[a-z]+)*)-(\d{2,3})$/,er=co,Fd=er.teal,ns=Fd[500],Md=a=>{const t=a.trim();if(t.length===4||t.length===5){const[r,...s]=t;return`${r}${s.map(i=>`${i}${i}`).join("")}`}return t},Gt=a=>{const t=a/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4},os=a=>{const t=Md(a).slice(1,7),r=Number.parseInt(t.slice(0,2),16),s=Number.parseInt(t.slice(2,4),16),i=Number.parseInt(t.slice(4,6),16);return .2126*Gt(r)+.7152*Gt(s)+.0722*Gt(i)},ls=(a,t)=>{const r=os(a),s=os(t),i=Math.max(r,s),n=Math.min(r,s);return(i+.05)/(n+.05)},ds=a=>{if(tn.test(a)){const r=ls(a,"#ffffff"),s=ls(a,"#000000");return r>=s?yt:is}const t=a.match(/^oklch\(([\d.]+)%/i);return t&&Number.parseFloat(t[1])>=78?is:yt},Pd=a=>{const t=a.match(Rd);if(t){const[,i,n]=t,o=er[i];if(o&&typeof o!="string")return o[n]}const r=a.replace(/^bg-/,""),s=er[r];if(typeof s=="string")return s},Bd=a=>{const t=a==null?void 0:a.trim();if(!t)return{color:ns,foreground:yt};const r=Pd(t);return r?{color:r,foreground:ds(r)}:tn.test(t)||Dd.test(t)?{color:t,foreground:ds(t)}:{color:ns,foreground:yt}},Td=a=>{const{color:t,foreground:r}=Bd(a==null?void 0:a.primaryColor);return`:root{--storefront-primary:${t};--storefront-primary-foreground:${r};}`},Qd=({appearance:a,children:t})=>{const r=a!=null&&a.primaryColor?Td(a):null;return e.jsxs(e.Fragment,{children:[r?e.jsx("style",{"data-shophost-storefront-appearance":!0,suppressHydrationWarning:!0,children:r}):null,t]})},Od=({appearance:a,baseUrl:t,children:r,initialOrganization:s,locale:i="en",modifiersModal:n,organizationId:o})=>e.jsx(Qd,{appearance:a,children:e.jsx(Bo,{locale:i,children:e.jsx(Kl,{baseURL:t,children:e.jsx(sr,{baseUrl:t,children:e.jsx(A.QueryClientProvider,{client:Ed,children:e.jsx(Io,{initialOrganization:s,organizationId:o,children:e.jsx(qs,{locale:i,organizationId:o,children:e.jsxs(_s,{locale:i,children:[r,n]})})})})})})})});function $(...a){return Cs.twMerge(As(...a))}const Da=["focus:ring-2","focus:ring-blue-200 dark:focus:ring-blue-700/30","focus:border-blue-500 dark:focus:border-blue-700"],Ae=["outline outline-offset-2 outline-0 focus-visible:outline-2","outline-blue-500 dark:outline-blue-500"],Vt=["ring-2","border-red-500 dark:border-red-700","ring-red-200 dark:ring-red-700/30"],Ld=(a,t=0)=>Intl.NumberFormat("us",{minimumFractionDigits:t,maximumFractionDigits:t}).format(Number(a)).toString(),xe={currency:(a,t="USD")=>new Intl.NumberFormat("en-US",{style:"currency",currency:t}).format(a),unit:a=>`${Ld(a)}`},Jd=Le.tv({base:["relative inline-flex items-center justify-center whitespace-nowrap rounded-lg border px-3 py-2 text-center text-sm font-medium shadow-xs transition-all duration-100 ease-in-out","disabled:pointer-events-none disabled:shadow-none",Ae],variants:{variant:{primary:["border-transparent","text-white dark:text-white","bg-blue-600 dark:bg-blue-500","shadow-[0_16px_8px_rgba(31,31,31,0.01),0_12px_6px_rgba(31,31,31,0.04),0_4px_4px_rgba(31,31,31,0.07),0_1.5px_3px_rgba(31,31,31,0.08),0_0_0_1px_#2563eb,inset_0_1px_2px_hsla(0,0%,100%,0.12)] dark:outline-0 outline outline-2 outline-transparent outline-offset-2","hover:bg-blue-500 dark:hover:bg-blue-600","disabled:bg-blue-100 disabled:text-gray-400","dark:disabled:bg-blue-800 dark:disabled:text-blue-400"],secondary:["border-gray-200 dark:border-gray-800","text-gray-900 dark:text-gray-50","bg-white dark:bg-gray-950","shadow-[0_1px_1px_0.5px_rgba(51,51,51,.04),0_3px_3px_-1.5px_rgba(51,51,51,.02),0_6px_6px_-3px_rgba(51,51,51,.04),0_12px_12px_-6px_rgba(51,51,51,.04),0_24px_24px_-12px_rgba(51,51,51,.04),0_48px_48px_-24px_rgba(51,51,51,.04),0_0_0_1px_rgba(51,51,51,.1),inset_0_-1px_1px_-0.5px_rgba(51,51,51,.06)] outline outline-2 dark:outline-0 outline-transparent outline-offset-2","hover:bg-gray-50 dark:hover:bg-gray-900/60","disabled:text-gray-400","dark:disabled:text-gray-600"],light:["shadow-none","border-transparent","text-gray-900 dark:text-gray-50","bg-gray-200 dark:bg-gray-900","hover:bg-gray-300/70 dark:hover:bg-gray-800/80","disabled:bg-gray-100 disabled:text-gray-400","dark:disabled:bg-gray-800 dark:disabled:text-gray-600"],ghost:["shadow-none","border-transparent","text-gray-900 dark:text-gray-50","bg-transparent hover:bg-gray-100 dark:hover:bg-gray-800/80","disabled:text-gray-400","dark:disabled:text-gray-600"],destructive:["text-white","border-transparent","bg-red-600 dark:bg-red-700","hover:bg-red-700 dark:hover:bg-red-600","disabled:bg-red-300 disabled:text-white","dark:disabled:bg-red-950 dark:disabled:text-red-400"]}},defaultVariants:{variant:"primary"}}),D=x.forwardRef(({asChild:a,isLoading:t=!1,loadingText:r,className:s,disabled:i,variant:n,children:o,...l},c)=>{const m=a?tr.Slot:"button";return e.jsx(m,{ref:c,className:w(Jd({variant:n}),s),disabled:i||t,...l,children:t?e.jsxs("span",{className:"pointer-events-none flex shrink-0 items-center justify-center gap-1.5",children:[e.jsx(P.RiLoader2Fill,{className:"size-4 shrink-0 animate-spin","aria-hidden":"true"}),e.jsx("span",{className:"sr-only",children:r||"Loading"}),r||"Loading"]}):o})});D.displayName="Button";function yr({onReset:a}){return e.jsx("div",{className:"shophost-admin flex h-screen flex-col items-center justify-center gap-4",children:e.jsx("div",{className:"py-8 px-4 mx-auto max-w-(--breakpoint-xl) pb-64 lg:px-6",children:e.jsxs("div",{className:"mx-auto max-w-(--breakpoint-sm) text-center",children:[e.jsx("h1",{className:"mb-4 text-7xl tracking-tight font-extrabold lg:text-9xl text-red-500 dark:text-primary-500",children:"500"}),e.jsx("p",{className:"mb-3 font-red-hat-display text-3xl tracking-tight font-bold text-gray-800 md:text-4xl dark:text-white",children:"Something went wrong"}),e.jsxs("p",{className:"mb-4 text-lg text-gray-500 dark:text-gray-400",children:["We are sorry, but there was an unexpected error. ",e.jsx("br",{}),"Please try reloading the page."]}),a&&e.jsx(D,{className:"mt-3",onClick:a,children:"Reload Page"})]})})})}const qt=x.createContext({});function Vd({children:a,organizationId:t,id:r}){return e.jsx(qt.Provider,{value:{organizationId:t,id:r},children:a})}function qd(){return x.useContext(qt)}function H(){const{organizationId:a}=x.useContext(qt);if(!a)throw new Error("useOrgId called outside an org-scoped route");return a}function ga(){const{id:a}=x.useContext(qt);if(!a)throw new Error("useRouteId called outside a detail route");return a}const Hd=x.createContext(void 0),Ud=({children:a,initialState:t=!1})=>{const[r,s]=x.useState(t);return e.jsx(Hd.Provider,{value:{flyoutOpen:r,setFlyoutOpen:s},children:a})},pe=({className:a,...t})=>e.jsxs("svg",{"aria-hidden":"true",className:w("text-gray-200 animate-spin dark:text-gray-600 fill-blue-600",a),viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:[e.jsx("path",{d:"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",fill:"currentColor"}),e.jsx("path",{d:"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",fill:"currentFill"})]}),rn=x.createContext(null),cs=({children:a})=>{var c,m,u,p,g;const{client:t}=M(),{organizationId:r}=qd(),s=A.useQuery({queryKey:["organizations"],queryFn:async()=>{const{body:h,status:f}=await t.organization.getOrganizations();if(f!==200)throw f!==401&&J.error("Failed to update organizations list. Please refresh the page or try again later."),new Error("Failed to fetch organizations");return h},retry:!1}),i=A.useQuery({queryKey:["organization",r],queryFn:async()=>{const{body:h,status:f}=await t.organization.getOrganization({params:{organizationId:r}});if(f!==200)throw f!==401&&J.error("Failed to fetch organization. Please try refreshing the page or try again later."),new Error("Failed to fetch organizations");return h},enabled:!!r}),n=((c=i.data)==null?void 0:c.configuration.defaultLocale)??"en",o=((m=i.data)==null?void 0:m.configuration.defaultCurrency)??"USD",l=((p=(u=i.data)==null?void 0:u.configuration.supportedLocales)==null?void 0:p.sort(h=>h===n?-1:1))||["en"];return e.jsx(rn.Provider,{value:{defaultLocale:n,defaultCurrency:o,supportedLocales:l,organizations:{loading:s.isLoading,data:((g=s.data)==null?void 0:g.list)??[],error:s.isError},organization:{loading:i.isLoading,data:i.data??null,error:i.isError}},children:i.isLoading||s.isLoading?e.jsx("div",{className:"flex justify-center items-center h-screen mt-5",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(pe,{className:"w-12 h-12"}),e.jsx("p",{className:"text-gray-500 text-sm mt-3",children:"Loading data..."})]})}):a})},je=()=>{const a=x.useContext(rn);if(!a)throw new Error("useOrganization must be used within a OrganizationProvider");return a},Zd="redirect";function $d(a){return a.startsWith("/")&&!a.startsWith("//")}function _d(a,t){return a===t||a.startsWith(`${t}/`)}function Ht(a,t){return!a||!$d(a)||!_d(a,t.home)||a===t.signIn||a===t.signUp?t.home:a}function br(a,t){const r=new URLSearchParams({[Zd]:t});return`${a}?${r.toString()}`}function sn(a,t,r){const s=Ht(t,r);return new URL(s,a).toString()}const Z=x.forwardRef(({className:a,children:t,...r},s)=>e.jsx("div",{ref:s,className:w("mx-auto my-6 flex w-full items-center justify-between gap-3 text-sm col-span-full","text-gray-500 dark:text-gray-500",a),...r,children:t?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:w("h-[1px] w-full","bg-gray-200 dark:bg-gray-800")}),e.jsx("div",{className:"whitespace-nowrap text-inherit",children:t}),e.jsx("div",{className:w("h-[1px] w-full","bg-gray-200 dark:bg-gray-800")})]}):e.jsx("div",{className:w("h-[0.5px] w-full","bg-gray-200 dark:bg-gray-800")})}));Z.displayName="Divider";const Wd=Le.tv({base:["relative block w-full rounded-lg border px-2.5 py-2.5 shadow-xs outline-hidden transition sm:text-sm","border-gray-200 dark:border-gray-800","text-gray-900 dark:text-gray-50","placeholder-gray-400 dark:placeholder-gray-500","bg-white dark:bg-gray-950","disabled:border-gray-300 disabled:bg-gray-100 disabled:text-gray-400","dark:disabled:border-gray-700 dark:disabled:bg-gray-800 dark:disabled:text-gray-500",Da],variants:{hasError:{true:Vt},enableStepper:{false:"[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none"},multiline:{true:"resize-y min-h-[100px]",false:"truncate appearance-none"}}}),ne=x.forwardRef(({className:a,inputClassName:t,hasError:r,enableStepper:s=!0,type:i,multiline:n=!1,prefix:o,suffix:l,copyValue:c,copySuccessMessage:m="Copied to clipboard.",copyErrorMessage:u="Failed to copy to clipboard. Please try again.",...p},g)=>{const[h,f]=x.useState(i),[b,y]=x.useState(!1),j=i==="password"&&!n,v=i==="search"&&!n,k=!!c,C=i==="textarea"?"textarea":"input",F=async()=>{if(c)try{y(!0),await navigator.clipboard.writeText(c),J.success(m)}catch{J.error(u)}finally{y(!1)}};return e.jsxs("div",{className:w("relative w-full",a),children:[o&&e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center px-3 text-slate-600 dark:text-gray-600 z-10 text-sm border-r border-gray-200",children:o}),e.jsx(C,{ref:g,type:j?h:i,className:w(Wd({hasError:r,enableStepper:n?!1:s,multiline:n}),{"pl-16":o,"pl-8":!o&&v,"pr-24":k,"pr-10":!k&&(l||!l&&j)},t),...p}),!o&&v&&e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-2 text-gray-400 dark:text-gray-600",children:e.jsx(P.RiSearchLine,{className:"size-[1.125rem]"})}),k&&e.jsx("div",{className:"absolute inset-y-0 right-0 flex items-center pr-1.5",children:e.jsxs(D,{type:"button",variant:"ghost",onClick:F,isLoading:b,loadingText:"Copying...",className:"h-8 cursor-pointer px-2 text-xs hover:text-gray-600 dark:hover:bg-gray-800",children:[e.jsx(N.CopyIcon,{className:"size-4","aria-hidden":"true"}),e.jsx("span",{className:"sr-only",children:"Copy value"})]})}),!k&&l&&e.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2 text-gray-400 dark:text-gray-600",children:l}),!k&&!l&&j&&e.jsx("div",{className:"absolute inset-y-0 right-0 flex items-center pr-3",children:e.jsx("button",{type:"button",onClick:()=>f(h==="password"?"text":"password"),className:w(Ae,"text-gray-400 hover:text-gray-500 dark:text-gray-600"),children:h==="password"?e.jsx(P.RiEyeFill,{className:"size-5"}):e.jsx(P.RiEyeOffFill,{className:"size-5"})})})]})});ne.displayName="Input";const le=z.forwardRef(({className:a,disabled:t,...r},s)=>e.jsx(Is.Root,{ref:s,className:$("text-sm leading-none","text-gray-900 dark:text-gray-50",{"text-gray-400 dark:text-gray-600":t},a),"aria-disabled":t,...r}));le.displayName="Label";const Kd=()=>{const a=E.useRouter(),t=E.useSearchParams(),r=qa(),s=_(),i=r.signIn,n=Ht(t==null?void 0:t.get("redirect"),s),{register:o,handleSubmit:l,formState:{errors:c,isSubmitting:m}}=U.useForm({resolver:fe.zodResolver(ci),shouldFocusError:!0}),u=()=>a.push(n),p=async h=>{await i.email({email:h.email,password:h.password,fetchOptions:{onSuccess:u}})},g=async()=>{await i.social({provider:"google",callbackURL:sn(window.location.origin,n,s)})};return e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex w-full flex-col items-start sm:max-w-sm",children:[e.jsx("div",{className:"relative flex items-center justify-center rounded-lg bg-white p-3 shadow-lg ring-1 ring-black/5",children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:481,zoomAndPan:"magnify",viewBox:"0 0 360.75 362.250002",height:483,preserveAspectRatio:"xMidYMid meet",className:"size-8 text-blue-500 dark:text-blue-500",children:[e.jsxs("defs",{children:[e.jsx("filter",{x:"0%",y:"0%",width:"100%",height:"100%",id:"2330832e18",children:e.jsx("feColorMatrix",{values:"0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0",colorInterpolationFilters:"sRGB"})}),e.jsx("clipPath",{id:"5855bcb1c8",children:e.jsx("path",{d:"M 49 49.945312 L 357 49.945312 L 357 361.257812 L 49 361.257812 Z M 49 49.945312 ",clipRule:"nonzero"})}),e.jsx("clipPath",{id:"2af377de26",children:e.jsx("path",{d:"M 226.65625 348.957031 L 345.746094 229.867188 C 359.820312 215.792969 359.820312 193.058594 345.746094 178.984375 L 228.101562 61.339844 C 220.160156 53.398438 209.515625 49.070312 198.328125 49.070312 L 50.730469 49.070312 L 180.644531 178.984375 C 194.71875 193.058594 194.71875 215.792969 180.644531 229.867188 L 49.285156 361.226562 L 196.882812 361.226562 C 208.070312 361.226562 218.71875 356.714844 226.65625 348.957031 Z M 226.65625 348.957031 ",clipRule:"nonzero"})}),e.jsx("image",{x:0,y:0,width:313,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAATkAAAE5CAYAAADr4VfxAAAABmJLR0QA/wD/AP+gvaeTAAAEKklEQVR4nO3UMQqAMBQFQeP9D51aUYSAIssM/CbwSLdj+4dxcXfvT7eys7Gx+Xbz5l8H+/kBoETkgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSJsw7gNx2VB9PQAAAABJRU5ErkJggg==",id:"dfad2cd726",height:313,preserveAspectRatio:"xMidYMid meet"}),e.jsx("mask",{id:"161eaca8d9",children:e.jsx("g",{filter:"url(#2330832e18)",children:e.jsx("g",{children:e.jsx("image",{x:0,y:0,width:313,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAATkAAAE5CAYAAADr4VfxAAAABmJLR0QA/wD/AP+gvaeTAAAEKklEQVR4nO3UMQqAMBQFQeP9D51aUYSAIssM/CbwSLdj+4dxcXfvT7eys7Gx+Xbz5l8H+/kBoETkgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSJsw7gNx2VB9PQAAAABJRU5ErkJggg==",height:313,preserveAspectRatio:"xMidYMid meet"})})})}),e.jsx("clipPath",{id:"5d3dc395e3",children:e.jsx("rect",{x:0,width:313,y:0,height:313})}),e.jsx("pattern",{id:"2569dd48be",patternUnits:"userSpaceOnUse",width:313,patternTransform:"matrix(0.997934, 0, 0, -0.997934, 48.148759, 361.331903)",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 313 313",height:313,x:0,y:0,children:e.jsx("g",{children:e.jsx("g",{clipPath:"url(#5d3dc395e3)",children:e.jsx("g",{mask:"url(#161eaca8d9)",children:e.jsx("rect",{x:"-127.777762",width:"520.555524",fill:"#8c52ff",height:"522.72",y:"-80.78",fillOpacity:1})})})})}),e.jsx("clipPath",{id:"2302aeb2c7",children:e.jsx("path",{d:"M 0.246094 0.90625 L 308 0.90625 L 308 312.21875 L 0.246094 312.21875 Z M 0.246094 0.90625 ",clipRule:"nonzero"})}),e.jsx("clipPath",{id:"d6b3633872",children:e.jsx("path",{d:"M 177.617188 299.917969 L 296.707031 180.828125 C 310.78125 166.753906 310.78125 144.019531 296.707031 129.945312 L 179.0625 12.300781 C 171.121094 4.363281 160.476562 0.03125 149.289062 0.03125 L 1.691406 0.03125 L 131.605469 129.945312 C 145.679688 144.019531 145.679688 166.753906 131.605469 180.828125 L 0.246094 312.1875 L 147.84375 312.1875 C 159.03125 312.1875 169.679688 307.675781 177.617188 299.917969 Z M 177.617188 299.917969 ",clipRule:"nonzero"})}),e.jsx("image",{x:0,y:0,width:312,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAATgAAAE5CAYAAAAEIzzPAAAABmJLR0QA/wD/AP+gvaeTAAAEKElEQVR4nO3UMQ6AIAAEQfH/j7bGQhqVZDOT0EAudDuO/cbDWb3bvLf76x8bmy83k/N+AVAhcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2RdVgkDcV9ZT24AAAAASUVORK5CYII=",id:"f9fee20a49",height:313,preserveAspectRatio:"xMidYMid meet"}),e.jsx("mask",{id:"8bb974956b",children:e.jsx("g",{filter:"url(#2330832e18)",children:e.jsx("g",{children:e.jsx("image",{x:0,y:0,width:312,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAATgAAAE5CAYAAAAEIzzPAAAABmJLR0QA/wD/AP+gvaeTAAAEKElEQVR4nO3UMQ6AIAAEQfH/j7bGQhqVZDOT0EAudDuO/cbDWb3bvLf76x8bmy83k/N+AVAhcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2RdVgkDcV9ZT24AAAAASUVORK5CYII=",height:313,preserveAspectRatio:"xMidYMid meet"})})})}),e.jsx("clipPath",{id:"4f6b6cd058",children:e.jsx("rect",{x:0,width:312,y:0,height:313})}),e.jsx("pattern",{id:"80e461df2c",patternUnits:"userSpaceOnUse",width:312,patternTransform:"matrix(0.997934, 0, 0, -0.997934, 0.247933, 312.433143)",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 312 313",height:313,x:0,y:0,children:e.jsx("g",{children:e.jsx("g",{clipPath:"url(#4f6b6cd058)",children:e.jsx("g",{mask:"url(#8bb974956b)",children:e.jsx("rect",{x:"-79.777762",width:"520.555524",fill:"#8c52ff",height:"522.72",y:"-129.78",fillOpacity:1})})})})})]}),e.jsx("g",{clipPath:"url(#5855bcb1c8)",children:e.jsx("g",{clipPath:"url(#2af377de26)",children:e.jsx("path",{fill:"url(#2569dd48be)",d:"M 359.820312 361.226562 L 49.289062 361.226562 L 49.289062 49.945312 L 359.820312 49.945312 Z M 359.820312 361.226562 ",fillRule:"nonzero"})})}),e.jsx("g",{clipPath:"url(#2302aeb2c7)",children:e.jsx("g",{clipPath:"url(#d6b3633872)",children:e.jsx("path",{fill:"url(#80e461df2c)",d:"M 310.78125 312.1875 L 0.25 312.1875 L 0.25 0.90625 L 310.78125 0.90625 Z M 310.78125 312.1875 ",fillRule:"nonzero"})})})]})}),e.jsxs("div",{className:"mt-6 flex flex-col",children:[e.jsx("h1",{className:"text-lg font-semibold text-gray-900 dark:text-gray-50",children:"Log in to Shophost"}),e.jsxs("p",{className:"mt-1 text-sm text-gray-700 dark:text-gray-300",children:["Don’t have an account?"," ",e.jsx(B,{className:"text-blue-500 hover:text-blue-600 dark:text-blue-500 dark:hover:text-blue-400",href:br(s.signUp,n),children:"Sign up"})]})]}),e.jsxs("div",{className:"mt-10 w-full",children:[e.jsx("div",{className:"gap-2 sm:flex sm:flex-row sm:items-center",children:e.jsxs(D,{variant:"secondary",type:"button",className:"mt-2 w-full sm:mt-0 shadow-none inline-flex items-center gap-2",onClick:g,children:[e.jsx(P.RiGoogleFill,{className:"size-4","aria-hidden":"true"}),"Login with Google"]})}),e.jsx(Z,{className:"my-6",children:"or"}),e.jsxs("form",{onSubmit:l(p),className:"flex w-full flex-col gap-y-6",children:[e.jsxs("div",{className:"flex flex-col gap-y-4",children:[e.jsxs("div",{className:"flex flex-col space-y-2",children:[e.jsx(le,{htmlFor:"email-form-item",className:"font-medium",children:"Email"}),e.jsx(ne,{type:"email",autoComplete:"email",id:"email-form-item",placeholder:"emily.ross@acme.ch",...o("email")}),c.email&&e.jsx("span",{className:"text-sm text-red-500",children:c.email.message})]}),e.jsxs("div",{className:"flex flex-col space-y-2",children:[e.jsx(le,{htmlFor:"password-form-item",className:"font-medium",children:"Password"}),e.jsx(ne,{type:"password",autoComplete:"current-password",id:"password-form-item",placeholder:"Password",...o("password")}),c.password&&e.jsx("span",{className:"text-sm text-red-500",children:c.password.message})]})]}),e.jsx(D,{type:"submit",isLoading:m,children:m?"Submitting...":"Continue"})]})]}),e.jsx(Z,{}),e.jsxs("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:["Forgot your password?"," ",e.jsx("a",{className:"text-blue-500 hover:text-blue-600 dark:text-blue-500 dark:hover:text-blue-400",href:"#",children:"Reset password"})]})]})})};function nn({children:a}){const{appearance:t}=Fs(),r=t==null?void 0:t.loginImage;return e.jsxs("div",{className:"flex w-full min-h-screen",children:[r&&e.jsx("div",{className:"hidden lg:block relative w-1/2 overflow-hidden",children:e.jsx(Ie,{src:r,alt:"Login Visual",width:4e3,height:2250,className:"w-full h-full object-cover min-h-screen"})}),e.jsx("div",{className:`w-full ${r?"lg:w-1/2":""} flex items-center justify-center p-8`,children:e.jsx("div",{className:"w-full max-w-md space-y-8",children:a})})]})}function Gd(){return e.jsx(nn,{children:e.jsx(Kd,{})})}const Xd=()=>{const a=E.useRouter(),t=E.useSearchParams(),r=qa(),s=_(),{signIn:i,signUp:n}=r,o=Ht(t==null?void 0:t.get("redirect"),s),{register:l,handleSubmit:c,formState:{errors:m}}=U.useForm({resolver:fe.zodResolver(mr),shouldFocusError:!0}),u=()=>a.push(o),{isPending:p,isError:g,mutate:h}=A.useMutation({onMutate:async b=>n.email({email:b.email,password:b.password,name:`${b.firstname} ${b.lastname}`,firstname:b.firstname,lastname:b.lastname,fetchOptions:{onSuccess:u}})}),f=async()=>i.social({provider:"google",callbackURL:sn(window.location.origin,o,s)});return e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex w-full flex-col items-start sm:max-w-sm",children:[e.jsx("div",{className:"relative flex items-center justify-center rounded-lg bg-white p-3 shadow-lg ring-1 ring-black/5",children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:481,zoomAndPan:"magnify",viewBox:"0 0 360.75 362.250002",height:483,preserveAspectRatio:"xMidYMid meet",className:"size-8 text-blue-500 dark:text-blue-500",children:[e.jsxs("defs",{children:[e.jsx("filter",{x:"0%",y:"0%",width:"100%",height:"100%",id:"2330832e18",children:e.jsx("feColorMatrix",{values:"0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0",colorInterpolationFilters:"sRGB"})}),e.jsx("clipPath",{id:"5855bcb1c8",children:e.jsx("path",{d:"M 49 49.945312 L 357 49.945312 L 357 361.257812 L 49 361.257812 Z M 49 49.945312 ",clipRule:"nonzero"})}),e.jsx("clipPath",{id:"2af377de26",children:e.jsx("path",{d:"M 226.65625 348.957031 L 345.746094 229.867188 C 359.820312 215.792969 359.820312 193.058594 345.746094 178.984375 L 228.101562 61.339844 C 220.160156 53.398438 209.515625 49.070312 198.328125 49.070312 L 50.730469 49.070312 L 180.644531 178.984375 C 194.71875 193.058594 194.71875 215.792969 180.644531 229.867188 L 49.285156 361.226562 L 196.882812 361.226562 C 208.070312 361.226562 218.71875 356.714844 226.65625 348.957031 Z M 226.65625 348.957031 ",clipRule:"nonzero"})}),e.jsx("image",{x:0,y:0,width:313,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAATkAAAE5CAYAAADr4VfxAAAABmJLR0QA/wD/AP+gvaeTAAAEKklEQVR4nO3UMQqAMBQFQeP9D51aUYSAIssM/CbwSLdj+4dxcXfvT7eys7Gx+Xbz5l8H+/kBoETkgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSJsw7gNx2VB9PQAAAABJRU5ErkJggg==",id:"dfad2cd726",height:313,preserveAspectRatio:"xMidYMid meet"}),e.jsx("mask",{id:"161eaca8d9",children:e.jsx("g",{filter:"url(#2330832e18)",children:e.jsx("g",{children:e.jsx("image",{x:0,y:0,width:313,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAATkAAAE5CAYAAADr4VfxAAAABmJLR0QA/wD/AP+gvaeTAAAEKklEQVR4nO3UMQqAMBQFQeP9D51aUYSAIssM/CbwSLdj+4dxcXfvT7eys7Gx+Xbz5l8H+/kBoETkgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSBM5IE3kgDSRA9JEDkgTOSBN5IA0kQPSRA5IEzkgTeSANJED0kQOSJsw7gNx2VB9PQAAAABJRU5ErkJggg==",height:313,preserveAspectRatio:"xMidYMid meet"})})})}),e.jsx("clipPath",{id:"5d3dc395e3",children:e.jsx("rect",{x:0,width:313,y:0,height:313})}),e.jsx("pattern",{id:"2569dd48be",patternUnits:"userSpaceOnUse",width:313,patternTransform:"matrix(0.997934, 0, 0, -0.997934, 48.148759, 361.331903)",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 313 313",height:313,x:0,y:0,children:e.jsx("g",{children:e.jsx("g",{clipPath:"url(#5d3dc395e3)",children:e.jsx("g",{mask:"url(#161eaca8d9)",children:e.jsx("rect",{x:"-127.777762",width:"520.555524",fill:"#8c52ff",height:"522.72",y:"-80.78",fillOpacity:1})})})})}),e.jsx("clipPath",{id:"2302aeb2c7",children:e.jsx("path",{d:"M 0.246094 0.90625 L 308 0.90625 L 308 312.21875 L 0.246094 312.21875 Z M 0.246094 0.90625 ",clipRule:"nonzero"})}),e.jsx("clipPath",{id:"d6b3633872",children:e.jsx("path",{d:"M 177.617188 299.917969 L 296.707031 180.828125 C 310.78125 166.753906 310.78125 144.019531 296.707031 129.945312 L 179.0625 12.300781 C 171.121094 4.363281 160.476562 0.03125 149.289062 0.03125 L 1.691406 0.03125 L 131.605469 129.945312 C 145.679688 144.019531 145.679688 166.753906 131.605469 180.828125 L 0.246094 312.1875 L 147.84375 312.1875 C 159.03125 312.1875 169.679688 307.675781 177.617188 299.917969 Z M 177.617188 299.917969 ",clipRule:"nonzero"})}),e.jsx("image",{x:0,y:0,width:312,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAATgAAAE5CAYAAAAEIzzPAAAABmJLR0QA/wD/AP+gvaeTAAAEKElEQVR4nO3UMQ6AIAAEQfH/j7bGQhqVZDOT0EAudDuO/cbDWb3bvLf76x8bmy83k/N+AVAhcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2RdVgkDcV9ZT24AAAAASUVORK5CYII=",id:"f9fee20a49",height:313,preserveAspectRatio:"xMidYMid meet"}),e.jsx("mask",{id:"8bb974956b",children:e.jsx("g",{filter:"url(#2330832e18)",children:e.jsx("g",{children:e.jsx("image",{x:0,y:0,width:312,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAATgAAAE5CAYAAAAEIzzPAAAABmJLR0QA/wD/AP+gvaeTAAAEKElEQVR4nO3UMQ6AIAAEQfH/j7bGQhqVZDOT0EAudDuO/cbDWb3bvLf76x8bmy83k/N+AVAhcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2QJHJAlcECWwAFZAgdkCRyQJXBAlsABWQIHZAkckCVwQJbAAVkCB2RdVgkDcV9ZT24AAAAASUVORK5CYII=",height:313,preserveAspectRatio:"xMidYMid meet"})})})}),e.jsx("clipPath",{id:"4f6b6cd058",children:e.jsx("rect",{x:0,width:312,y:0,height:313})}),e.jsx("pattern",{id:"80e461df2c",patternUnits:"userSpaceOnUse",width:312,patternTransform:"matrix(0.997934, 0, 0, -0.997934, 0.247933, 312.433143)",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 312 313",height:313,x:0,y:0,children:e.jsx("g",{children:e.jsx("g",{clipPath:"url(#4f6b6cd058)",children:e.jsx("g",{mask:"url(#8bb974956b)",children:e.jsx("rect",{x:"-79.777762",width:"520.555524",fill:"#8c52ff",height:"522.72",y:"-129.78",fillOpacity:1})})})})})]}),e.jsx("g",{clipPath:"url(#5855bcb1c8)",children:e.jsx("g",{clipPath:"url(#2af377de26)",children:e.jsx("path",{fill:"url(#2569dd48be)",d:"M 359.820312 361.226562 L 49.289062 361.226562 L 49.289062 49.945312 L 359.820312 49.945312 Z M 359.820312 361.226562 ",fillRule:"nonzero"})})}),e.jsx("g",{clipPath:"url(#2302aeb2c7)",children:e.jsx("g",{clipPath:"url(#d6b3633872)",children:e.jsx("path",{fill:"url(#80e461df2c)",d:"M 310.78125 312.1875 L 0.25 312.1875 L 0.25 0.90625 L 310.78125 0.90625 Z M 310.78125 312.1875 ",fillRule:"nonzero"})})})]})}),e.jsxs("div",{className:"mt-6 flex flex-col",children:[e.jsx("h1",{className:"text-lg font-semibold text-gray-900 dark:text-gray-50",children:"Log in to Shophost"}),e.jsxs("p",{className:"mt-1 text-sm text-gray-700 dark:text-gray-300",children:["Already have an account?"," ",e.jsx(B,{className:"text-blue-500 hover:text-blue-600 dark:text-blue-500 dark:hover:text-blue-400",href:br(s.signIn,o),children:"Sign in"})]})]}),e.jsxs("div",{className:"mt-10 w-full",children:[e.jsx("div",{className:"gap-2 sm:flex sm:flex-row sm:items-center",children:e.jsx(D,{asChild:!0,variant:"secondary",className:"mt-2 w-full sm:mt-0",children:e.jsxs("button",{className:"inline-flex items-center gap-2",onClick:f,children:[e.jsx(P.RiGoogleFill,{className:"size-4","aria-hidden":"true"}),"Signin with Google"]})})}),e.jsx(Z,{className:"my-6",children:"or"}),e.jsxs("form",{onSubmit:c(b=>h(b)),className:"flex w-full flex-col gap-y-6",children:[e.jsxs("div",{className:"flex flex-col gap-y-4",children:[e.jsxs("div",{className:"flex flex-col space-y-2",children:[e.jsx(le,{htmlFor:"email-form-item",className:"font-medium",children:"First Name"}),e.jsx(ne,{type:"text",id:"email-form-item",placeholder:"Emily",...l("firstname")}),m.firstname&&e.jsx("span",{className:"text-sm text-red-500",children:m.firstname.message})]}),e.jsxs("div",{className:"flex flex-col space-y-2",children:[e.jsx(le,{htmlFor:"email-form-item",className:"font-medium",children:"Last Name"}),e.jsx(ne,{type:"text",id:"email-form-item",placeholder:"Emily",...l("lastname")}),m.lastname&&e.jsx("span",{className:"text-sm text-red-500",children:m.lastname.message})]}),e.jsxs("div",{className:"flex flex-col space-y-2",children:[e.jsx(le,{htmlFor:"email-form-item",className:"font-medium",children:"Email"}),e.jsx(ne,{type:"email",autoComplete:"email",id:"email-form-item",placeholder:"emily.ross@acme.ch",...l("email")}),m.email&&e.jsx("span",{className:"text-sm text-red-500",children:m.email.message})]}),e.jsxs("div",{className:"flex flex-col space-y-2",children:[e.jsx(le,{htmlFor:"password-form-item",className:"font-medium",children:"Password"}),e.jsx(ne,{type:"password",autoComplete:"current-password",id:"password-form-item",placeholder:"Password",...l("password")}),m.password&&e.jsx("span",{className:"text-sm text-red-500",children:m.password.message})]})]}),g&&e.jsx("span",{className:"text-sm text-red-500",children:"An error occurred, please try again."}),e.jsx(D,{type:"submit",isLoading:p,children:p?"Submitting...":"Continue"})]})]}),e.jsx(Z,{}),e.jsxs("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:["Forgot your password?"," ",e.jsx("a",{className:"text-blue-500 hover:text-blue-600 dark:text-blue-500 dark:hover:text-blue-400",href:"#",children:"Reset password"})]})]})})};function Yd(){return e.jsx(nn,{children:e.jsx(Xd,{})})}const ec=Le.tv({base:w("inline-flex items-center gap-x-1 whitespace-nowrap rounded px-1.5 py-0.5 text-xs font-semibold ring-1"),variants:{variant:{default:["bg-blue-50 text-blue-800 ring-blue-500/30","dark:bg-blue-400/10 dark:text-blue-400 dark:ring-blue-400/30"],neutral:["bg-gray-50 text-gray-700 ring-gray-500/30","dark:bg-gray-400/10 dark:text-gray-300 dark:ring-gray-400/20"],success:["bg-emerald-50 text-emerald-800 ring-emerald-600/30","dark:bg-emerald-400/10 dark:text-emerald-400 dark:ring-emerald-400/20"],error:["bg-red-50 text-red-800 ring-red-600/20","dark:bg-red-400/10 dark:text-red-400 dark:ring-red-400/20"],warning:["bg-yellow-50 text-yellow-800 ring-yellow-600/30","dark:bg-yellow-400/10 dark:text-yellow-500 dark:ring-yellow-400/20"]}},defaultVariants:{variant:"default"}}),de=x.forwardRef(({className:a,variant:t,...r},s)=>e.jsx("span",{ref:s,className:w(ec({variant:t}),a),...r}));de.displayName="Badge";const Be=x.forwardRef(({className:a,asChild:t,...r},s)=>{const i=t?tr.Slot:"div";return e.jsx(i,{ref:s,className:w("relative w-full rounded-xl border p-6 text-left shadow-xs","bg-white dark:bg-[#090E1A]","border-gray-200 dark:border-gray-900",a),...r})});Be.displayName="Card";const Ra=a=>e.jsx(re.Root,{...a});Ra.displayName="Dialog";const on=re.Trigger;on.displayName="DialogTrigger";const jr=re.Close;jr.displayName="DialogClose";const ln=re.Portal;ln.displayName="DialogPortal";const dn=x.forwardRef(({className:a,...t},r)=>e.jsx(re.Overlay,{ref:r,className:w("fixed inset-0 z-50 overflow-y-auto","bg-black/70","data-[state=open]:animate-dialogOverlayShow",a),...t}));dn.displayName="DialogOverlay";const Fa=x.forwardRef(({className:a,...t},r)=>e.jsx(ln,{children:e.jsx(dn,{children:e.jsx(re.Content,{ref:r,className:w("fixed left-1/2 top-1/2 z-50 w-[95vw] max-w-lg -translate-x-1/2 -translate-y-1/2 overflow-y-auto rounded-md border p-6 shadow-lg","border-gray-200 dark:border-gray-900","bg-white dark:bg-[#090E1A]","data-[state=open]:animate-dialogContentShow",Ae,a),...t})})}));Fa.displayName="DialogContent";const Ma=({className:a,...t})=>e.jsx("div",{className:w("flex flex-col gap-y-1",a),...t});Ma.displayName="DialogHeader";const Pa=x.forwardRef(({className:a,...t},r)=>e.jsx(re.Title,{ref:r,className:w("text-lg font-bold font-red-hat-display","text-gray-900 dark:text-gray-50",a),...t}));Pa.displayName="DialogTitle";const Ut=x.forwardRef(({className:a,...t},r)=>e.jsx(re.Description,{ref:r,className:w("text-gray-500 dark:text-gray-500",a),...t}));Ut.displayName="DialogDescription";const vr=({className:a,...t})=>e.jsx("div",{className:w("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...t});vr.displayName="DialogFooter";const ac=a=>t=>new Intl.NumberFormat("en-US",{style:"currency",currency:a.currency||"PLN"}).format(t),ms={draft:{variant:"neutral",label:"Draft"},pending:{variant:"warning",label:"Pending"},accepted:{variant:"default",label:"Accepted"},"ready-for-dispatch":{variant:"default",label:"Ready for Dispatch"},dispatched:{variant:"default",label:"Dispatched"},completed:{variant:"success",label:"Completed"},cancelled:{variant:"error",label:"Cancelled"}},us={pending:{variant:"warning",label:"Pending"},succeeded:{variant:"success",label:"Paid"},refunded:{variant:"neutral",label:"Refunded"},failed:{variant:"error",label:"Failed"},canceled:{variant:"error",label:"Canceled"}},tc={card:"Card",blik:"BLIK",cash_on_delivery:"Cash on Delivery",paypal:"PayPal"},Ka=({icon:a,title:t})=>e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("span",{className:"text-gray-400 dark:text-gray-500",children:a}),e.jsx("h3",{className:"text-sm font-bold text-gray-500 dark:text-gray-400 tracking-wide font-red-hat-display",children:t})]}),ps=({label:a,children:t})=>e.jsxs("div",{className:"flex justify-between items-center py-1.5",children:[e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:a}),e.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:t})]}),cn=({open:a,onOpenChange:t,order:r})=>{var c,m,u,p,g,h,f,b,y,j;if(!r)return null;const s=ac(r),i=ms[r.status||"pending"]??ms.pending,n=us[((c=r.payment)==null?void 0:c.status)||"pending"]??us.pending,o=[{label:"Created",date:r.createdAt},{label:"Accepted",date:r.acceptedAt},{label:"Ready for Dispatch",date:r.readyForDispatchAt},{label:"Dispatched",date:r.dispatchedAt},{label:"Completed",date:r.completedAt},...r.status==="cancelled"||r.cancelledAt?[{label:"Cancelled",date:r.cancelledAt}]:[]],l=r.shippingAddress;return e.jsx(Ra,{open:a,onOpenChange:t,children:e.jsxs(Fa,{className:"sm:max-w-2xl overflow-y-auto max-h-[90vh] !p-0",children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white dark:bg-[#090E1A] border-b border-gray-200 dark:border-gray-800 px-5 pt-5 pb-3",children:e.jsx(Ma,{children:e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs(Pa,{className:"text-lg",children:["Order #",r.referenceId]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{variant:i.variant,children:i.label}),e.jsx(de,{variant:n.variant,children:n.label}),r.fulfilmentMethod==="pickup"&&e.jsx(de,{variant:"neutral",children:"Pickup"})]})]}),e.jsx(jr,{className:"rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 p-1.5 -mt-1 -mr-1.5 transition-colors",children:e.jsx(N.X,{className:"h-4 w-4"})})]})})}),e.jsxs("div",{className:"px-5 pb-5 space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-5 pt-4",children:[e.jsxs("div",{children:[e.jsx(Ka,{icon:e.jsx(N.CreditCard,{className:"h-4 w-4"}),title:"Payment"}),e.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800 p-3 space-y-0.5",children:[e.jsx(ps,{label:"Method",children:tc[((m=r.payment)==null?void 0:m.method)||""]||((u=r.payment)==null?void 0:u.method)||"N/A"}),e.jsx(ps,{label:"Provider",children:e.jsx("span",{className:"capitalize",children:((p=r.payment)==null?void 0:p.provider)==="not_applicable"?"N/A":((g=r.payment)==null?void 0:g.provider)||"N/A"})})]})]}),e.jsxs("div",{children:[e.jsx(Ka,{icon:r.fulfilmentMethod==="pickup"?e.jsx(N.MapPin,{className:"h-4 w-4"}):e.jsx(N.Truck,{className:"h-4 w-4"}),title:r.fulfilmentMethod==="pickup"?"Pickup":"Shipping"}),e.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800 p-3",children:[l?e.jsxs("div",{className:"text-sm space-y-0.5",children:[e.jsxs("p",{className:"font-medium text-gray-900 dark:text-gray-100",children:[l.firstname," ",l.lastname]}),e.jsxs("p",{className:"text-gray-500 dark:text-gray-400",children:[l.addressLineOne,l.doorNumber?` / ${l.doorNumber}`:""]}),e.jsxs("p",{className:"text-gray-500 dark:text-gray-400",children:[l.zipCode,", ",l.city]}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:l.country}),l.phone&&e.jsx("p",{className:"text-gray-500 dark:text-gray-400 pt-1",children:l.phone})]}):e.jsx("p",{className:"text-sm text-gray-400",children:"No address provided"}),r.fulfilmentMethod==="delivery"&&((h=r.shippingMethod)==null?void 0:h.title)&&e.jsx("div",{className:"mt-2 pt-2 border-t border-gray-100 dark:border-gray-800",children:e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:["via"," ",e.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:r.shippingMethod.title})]})})]})]})]}),r.inventoryConflictAt&&r.inventoryConflictItems&&r.inventoryConflictItems.length>0&&e.jsx("div",{className:"rounded-lg border border-yellow-200 bg-yellow-50 p-4 dark:border-yellow-900/50 dark:bg-yellow-950/20",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(N.AlertTriangle,{className:"h-5 w-5 text-yellow-600 dark:text-yellow-400 shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-yellow-900 dark:text-yellow-200",children:"Manual inventory review required"}),e.jsx("ul",{className:"mt-1.5 space-y-0.5 text-sm text-yellow-800 dark:text-yellow-300",children:r.inventoryConflictItems.map(v=>e.jsxs("li",{children:[v.title,": requested ",v.requestedQuantity,", available ",v.availableQuantity]},v.productId))})]})]})}),e.jsxs("div",{children:[e.jsx(Ka,{icon:e.jsx(N.Package,{className:"h-4 w-4"}),title:"Items"}),e.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800 overflow-hidden",children:[e.jsx("div",{className:"divide-y divide-gray-100 dark:divide-gray-800",children:r.items.map((v,k)=>{const C=v.translations.find(F=>F.locale==="en")||v.translations[0];return e.jsxs("div",{className:"flex items-center gap-3 p-3",children:[v.image&&e.jsx("div",{className:"h-12 w-12 rounded-md overflow-hidden shrink-0 bg-gray-100 dark:bg-gray-800",children:e.jsx("img",{src:v.image.url,alt:(C==null?void 0:C.title)||"Product",className:"h-full w-full object-cover"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 truncate",children:(C==null?void 0:C.title)||"Product"}),(C==null?void 0:C.subtitle)&&e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:C.subtitle})]}),e.jsxs("div",{className:"text-right shrink-0",children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:s(v.totalPrice)}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:[v.quantity," × ",s(v.unitPrice)]})]})]},k)})}),e.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-800 bg-gray-50 dark:bg-gray-900/50 px-3 py-3 space-y-1.5",children:[e.jsxs("div",{className:"flex justify-between text-sm text-gray-500 dark:text-gray-400",children:[e.jsx("span",{children:"Subtotal"}),e.jsx("span",{children:s(Number((f=r.payment)==null?void 0:f.subtotal)||0)})]}),((b=r.payment)==null?void 0:b.shipping)!=null&&r.payment.shipping>0&&e.jsxs("div",{className:"flex justify-between text-sm text-gray-500 dark:text-gray-400",children:[e.jsx("span",{children:"Shipping"}),e.jsx("span",{children:s(r.payment.shipping)})]}),((y=r.payment)==null?void 0:y.discount)!=null&&r.payment.discount>0&&e.jsxs("div",{className:"flex justify-between text-sm text-green-600 dark:text-green-400",children:[e.jsx("span",{children:"Discount"}),e.jsxs("span",{children:["-",s(r.payment.discount)]})]}),e.jsxs("div",{className:"flex justify-between text-sm font-semibold text-gray-900 dark:text-gray-100 pt-1.5 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("span",{children:"Total"}),e.jsx("span",{children:s(Number((j=r.payment)==null?void 0:j.total)||0)})]})]})]})]}),e.jsxs("div",{children:[e.jsx(Ka,{icon:e.jsx(N.Calendar,{className:"h-4 w-4"}),title:"Timeline"}),e.jsx("div",{className:"relative",children:o.map((v,k)=>{const C=!!v.date,F=v.label==="Cancelled",T=k===o.length-1;return e.jsxs("div",{className:"relative flex items-start gap-3 pb-4 last:pb-0",children:[!T&&e.jsx("div",{className:`absolute left-[5px] top-3 bottom-0 w-0.5 ${C?"bg-emerald-500":"bg-gray-200 dark:bg-gray-800"}`}),e.jsx("div",{className:`relative z-10 mt-0.5 h-3 w-3 rounded-full border-2 shrink-0 ${F&&C?"border-red-500 bg-red-500":C?"border-emerald-500 bg-emerald-500":"border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-950"}`}),e.jsxs("div",{className:"flex-1 -mt-0.5",children:[e.jsx("p",{className:`text-sm leading-tight ${C?"font-medium text-gray-900 dark:text-gray-100":"text-gray-400 dark:text-gray-600"}`,children:v.label}),C&&v.date&&e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:I.format(new Date(v.date),"dd MMM yyyy, HH:mm")})]})]},v.label)})})]})]})]})})},mn=({organizationId:a,id:t,acceptedAt:r,cancelledAt:s,refetch:i,className:n,compact:o=!1})=>{var j;const{client:l}=M(),c=A.useMutation({mutationFn:async({operation:v})=>{if((await l.reservation.updateReservationStatus({params:{organizationId:a,reservationId:t,operation:v},body:{}})).status!==200)throw new Error("Failed to update reservation status");return i()}}),m=()=>{c.mutate({operation:"accept"})},u=()=>{c.mutate({operation:"cancel"})},p=c.isPending,g=(j=c.variables)==null?void 0:j.operation,h=p&&g==="cancel",f=p&&g==="accept",b=!r&&!s,y=!s;return e.jsxs("div",{className:$("flex items-center gap-2 min-w-28 min-h-[45px]",o?"min-h-0 min-w-0":"",n),children:[y&&e.jsxs("button",{onClick:u,disabled:p,className:$("relative inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-md border px-2 py-1 text-center text-sm font-medium shadow-xs transition-all duration-100 ease-in-out disabled:pointer-events-none disabled:shadow-none outline outline-offset-2 outline-0 focus-visible:outline-2 outline-blue-500 dark:outline-blue-500 border-gray-300 dark:border-gray-800 text-gray-900 dark:text-gray-50 bg-white dark:bg-gray-950 hover:bg-gray-50 dark:hover:bg-gray-900/60 disabled:text-gray-400 dark:disabled:text-gray-600",o?"my-0":"my-2"),children:[h?"Loading...":"Cancel",e.jsx(N.X,{className:"w-4 h-4 text-red-600 dark:text-red-500"})]}),b&&e.jsxs("button",{onClick:m,disabled:p,className:$("relative inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-md border px-2 py-1 text-center text-sm font-medium shadow-xs transition-all duration-100 ease-in-out disabled:pointer-events-none disabled:shadow-none outline outline-offset-2 outline-0 focus-visible:outline-2 outline-blue-500 dark:outline-blue-500 border-gray-300 dark:border-gray-800 text-gray-900 dark:text-gray-50 bg-white dark:bg-gray-950 hover:bg-gray-50 dark:hover:bg-gray-900/60 disabled:text-gray-400 dark:disabled:text-gray-600",o?"my-0":"my-2"),children:[f?"Loading...":"Accept",e.jsx(N.CheckCircle,{className:"w-4 h-4 text-emerald-600 dark:text-emerald-500"})]})]})},gs=a=>a?I.format(new Date(a),"yyyy-MM-dd'T'HH:mm"):"";function rc({organizationId:a,reservation:t,onCancel:r,onSuccess:s}){var c,m,u,p;const{client:i}=M(),n=U.useForm({resolver:fe.zodResolver(Bl),defaultValues:{firstname:t.firstname,lastname:t.lastname,guests:t.guests,date:gs(t.date)}});x.useEffect(()=>{n.reset({firstname:t.firstname,lastname:t.lastname,guests:t.guests,date:gs(t.date)})},[n,t]);const o=A.useMutation({mutationFn:async g=>{const{status:h,body:f}=await i.reservation.updateReservation({params:{organizationId:a,reservationId:t.id},body:g});if(h!==200)throw new Error("Failed to update reservation");return f},onSuccess:async g=>{J.success("Reservation updated successfully"),await oe.invalidateQueries({queryKey:["reservations"]}),await oe.invalidateQueries({queryKey:["reservations-calendar"]}),s(g)},onError:g=>{J.error(g instanceof Error?g.message:"Failed to update reservation")}}),l=n.handleSubmit(g=>{o.mutate({...g,date:new Date(g.date)})});return e.jsx(U.FormProvider,{...n,children:e.jsxs("form",{onSubmit:l,className:"px-5 py-5",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(le,{htmlFor:"reservation-firstname",className:"font-medium",children:"First name"}),e.jsx(ne,{id:"reservation-firstname",...n.register("firstname"),className:"mt-2",placeholder:"e.g. John"}),(c=n.formState.errors.firstname)!=null&&c.message?e.jsx("p",{className:"mt-1 text-sm text-red-500",children:n.formState.errors.firstname.message}):null]}),e.jsxs("div",{children:[e.jsx(le,{htmlFor:"reservation-lastname",className:"font-medium",children:"Last name"}),e.jsx(ne,{id:"reservation-lastname",...n.register("lastname"),className:"mt-2",placeholder:"e.g. Doe"}),(m=n.formState.errors.lastname)!=null&&m.message?e.jsx("p",{className:"mt-1 text-sm text-red-500",children:n.formState.errors.lastname.message}):null]}),e.jsxs("div",{children:[e.jsx(le,{htmlFor:"reservation-guests",className:"font-medium",children:"Number of guests"}),e.jsx(ne,{id:"reservation-guests",...n.register("guests",{valueAsNumber:!0}),className:"mt-2",min:1,placeholder:"e.g. 2",type:"number"}),(u=n.formState.errors.guests)!=null&&u.message?e.jsx("p",{className:"mt-1 text-sm text-red-500",children:n.formState.errors.guests.message}):null]}),e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx(le,{htmlFor:"reservation-date",className:"font-medium",children:"Reservation date and time"}),e.jsx(ne,{id:"reservation-date",...n.register("date"),className:"mt-2",step:60,type:"datetime-local"}),(p=n.formState.errors.date)!=null&&p.message?e.jsx("p",{className:"mt-1 text-sm text-red-500",children:n.formState.errors.date.message}):null]})]}),e.jsxs("div",{className:"mt-6 flex flex-col-reverse gap-2 border-t border-gray-200 pt-4 dark:border-gray-800 sm:flex-row sm:justify-end",children:[e.jsx(D,{type:"button",variant:"secondary",onClick:r,children:"Cancel"}),e.jsx(D,{type:"submit",isLoading:o.isPending,loadingText:"Saving...",children:"Save changes"})]})]})})}const Xt=({icon:a,title:t})=>e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("span",{className:"text-gray-400 dark:text-gray-500",children:a}),e.jsx("h3",{className:"text-sm font-bold text-gray-500 dark:text-gray-400 tracking-wide font-red-hat-display",children:t})]}),Ga=({label:a,children:t})=>e.jsxs("div",{className:"flex justify-between items-center py-1.5",children:[e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:a}),e.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:t})]}),sc=a=>a.cancelledAt?{variant:"error",label:"Cancelled"}:a.acceptedAt?{variant:"success",label:"Accepted"}:{variant:"warning",label:"Pending"},wr=({open:a,onOpenChange:t,organizationId:r,reservation:s,refetch:i})=>{const[n,o]=x.useState(s),[l,c]=x.useState(!1);x.useEffect(()=>{o(s),c(!1)},[s]);const m=sc(n),u=!n.cancelledAt,p=[{label:"Created",date:n.createdAt},{label:"Accepted",date:n.acceptedAt},...n.cancelledAt?[{label:"Cancelled",date:n.cancelledAt}]:[]];return e.jsx(Ra,{open:a,onOpenChange:t,children:e.jsxs(Fa,{className:"sm:max-w-lg overflow-y-auto max-h-[90vh] !p-0",children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white dark:bg-[#090E1A] border-b border-gray-200 dark:border-gray-800 px-5 pt-5 pb-3",children:e.jsx(Ma,{children:e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs(Pa,{className:"text-lg",children:["Reservation #",n.referenceId]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(de,{variant:m.variant,children:m.label})})]}),e.jsx(jr,{className:"rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 p-1.5 -mt-1 -mr-1.5 transition-colors",children:e.jsx(N.X,{className:"h-4 w-4"})})]})})}),l&&r?e.jsx(rc,{organizationId:r,onCancel:()=>c(!1),onSuccess:async g=>{o(g),c(!1),await(i==null?void 0:i())},reservation:n}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-5 pb-5 space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-5 pt-4",children:[e.jsxs("div",{children:[e.jsx(Xt,{icon:e.jsx(N.User,{className:"h-4 w-4"}),title:"Guest"}),e.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800 p-3 space-y-0.5",children:[e.jsxs(Ga,{label:"Name",children:[n.firstname," ",n.lastname]}),e.jsx(Ga,{label:"Phone",children:n.phone||"N/A"})]})]}),e.jsxs("div",{children:[e.jsx(Xt,{icon:e.jsx(N.Users,{className:"h-4 w-4"}),title:"Details"}),e.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800 p-3 space-y-0.5",children:[e.jsx(Ga,{label:"Guests",children:n.guests}),e.jsx(Ga,{label:"Date",children:n.date?I.format(new Date(n.date),"dd MMM yyyy, HH:mm"):"N/A"})]})]})]}),e.jsxs("div",{children:[e.jsx(Xt,{icon:e.jsx(N.Calendar,{className:"h-4 w-4"}),title:"Timeline"}),e.jsx("div",{className:"relative",children:p.map((g,h)=>{const f=!!g.date,b=g.label==="Cancelled",y=h===p.length-1;return e.jsxs("div",{className:"relative flex items-start gap-3 pb-4 last:pb-0",children:[!y&&e.jsx("div",{className:`absolute left-[5px] top-3 bottom-0 w-0.5 ${f?"bg-emerald-500":"bg-gray-200 dark:bg-gray-800"}`}),e.jsx("div",{className:`relative z-10 mt-0.5 h-3 w-3 rounded-full border-2 shrink-0 ${b&&f?"border-red-500 bg-red-500":f?"border-emerald-500 bg-emerald-500":"border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-950"}`}),e.jsxs("div",{className:"flex-1 -mt-0.5",children:[e.jsx("p",{className:`text-sm leading-tight ${f?"font-medium text-gray-900 dark:text-gray-100":"text-gray-400 dark:text-gray-600"}`,children:g.label}),f&&g.date&&e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:I.format(new Date(g.date),"dd MMM yyyy, HH:mm")})]})]},g.label)})})]})]}),r&&i?e.jsxs(vr,{className:"border-t border-gray-200 px-5 py-4 dark:border-gray-800 sm:items-center sm:justify-between sm:space-x-0",children:[e.jsx("div",{}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[u?e.jsxs(D,{className:"!h-8 !rounded-md !px-2 !py-1 shadow-xs",type:"button",variant:"secondary",onClick:()=>c(!0),children:[e.jsx(N.PencilIcon,{className:"mr-2 h-4 w-4"})," Edit reservation"]}):null,e.jsx(mn,{acceptedAt:n.acceptedAt,cancelledAt:n.cancelledAt,className:"justify-end",compact:!0,id:n.id,organizationId:r,refetch:i})]})]}):null]})]})})},un=a=>{var t;return`${a.firstname} ${a.lastname}`.trim()||((t=a.name)==null?void 0:t.trim())||a.email},ic=a=>{const t=un(a),r=t.split(" ").filter(Boolean);return r.length>=2?`${r[0][0]}${r[1][0]}`.toUpperCase():t.substring(0,2).toUpperCase()},hs=a=>a?I.format(new Date(a),"dd MMM yyyy, HH:mm"):"N/A",nc=a=>{switch(a){case"completed":return{label:"Completed",variant:"success"};case"cancelled":return{label:"Cancelled",variant:"error"};case"pending":return{label:"Pending",variant:"warning"};case"draft":return{label:"Draft",variant:"neutral"};case"accepted":return{label:"Accepted",variant:"default"};case"ready-for-dispatch":return{label:"Ready for Dispatch",variant:"default"};case"dispatched":return{label:"Dispatched",variant:"default"};default:return{label:"Unknown",variant:"neutral"}}},oc=a=>a.cancelledAt?{label:"Cancelled",variant:"error"}:a.acceptedAt?{label:"Accepted",variant:"success"}:{label:"Pending",variant:"warning"};function lc(){const{client:a}=M(),t=H(),r=ga(),s=_(),{defaultCurrency:i,defaultLocale:n}=je(),[o,l]=x.useState(null),[c,m]=x.useState(null),u=A.useQuery({queryKey:["customer",t,r],queryFn:async()=>{const{body:f,status:b}=await a.customer.getCustomer({params:{organizationId:t,id:r}});if(b!==200)throw new Error("Failed to fetch customer");return f}});if(x.useEffect(()=>{if(!u.data||!c)return;const f=u.data.reservations.find(b=>b.id===c.id)??null;f&&m(f)},[u.data,c]),u.isLoading)return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"size-12 animate-pulse rounded-full bg-gray-200 dark:bg-gray-800"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-5 w-40 animate-pulse rounded bg-gray-200 dark:bg-gray-800"}),e.jsx("div",{className:"h-4 w-56 animate-pulse rounded bg-gray-200 dark:bg-gray-800"})]})]}),e.jsx("div",{className:"grid gap-6 xl:grid-cols-2",children:Array.from({length:2}).map((f,b)=>e.jsxs(Be,{className:"animate-pulse p-0",children:[e.jsx("div",{className:"border-b border-gray-200 px-5 py-4 dark:border-gray-800",children:e.jsx("div",{className:"h-5 w-24 rounded bg-gray-200 dark:bg-gray-800"})}),e.jsxs("div",{className:"space-y-4 p-5",children:[e.jsx("div",{className:"h-4 w-full rounded bg-gray-200 dark:bg-gray-800"}),e.jsx("div",{className:"h-4 w-3/4 rounded bg-gray-200 dark:bg-gray-800"})]})]},b))})]});if(u.isError||!u.data)return e.jsxs(Be,{className:"border-red-200 p-6 dark:border-red-950",children:[e.jsx("h1",{className:"text-xl font-semibold text-gray-900 dark:text-gray-50",children:"Customer Details"}),e.jsx("p",{className:"mt-3 text-sm text-gray-500 dark:text-gray-400",children:"We couldn't load this customer right now. Please refresh and try again."})]});const p=u.data.customer,g=un(p),h=(f,b)=>new Intl.NumberFormat(n,{style:"currency",currency:b||i}).format(f);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("span",{className:"flex size-12 shrink-0 items-center justify-center rounded-full bg-gray-100 text-sm font-semibold text-gray-600 dark:bg-gray-800 dark:text-gray-300",children:ic(p)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-xl font-semibold text-gray-900 dark:text-gray-50",children:g}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-4 gap-y-1 text-sm text-gray-500 dark:text-gray-400",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(N.MailIcon,{className:"size-3.5","aria-hidden":"true"}),p.email]}),e.jsxs("span",{children:["Customer since"," ",I.format(new Date(p.createdAt),"dd MMM yyyy")]})]})]})]}),e.jsx(D,{asChild:!0,variant:"secondary",className:"w-full sm:w-auto",children:e.jsxs(B,{href:s.customers(t),children:[e.jsx(N.ArrowLeftIcon,{className:"mr-2 size-4","aria-hidden":"true"}),"Back to customers"]})})]}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[e.jsxs(de,{variant:"default",children:[p.orderCount," orders"]}),e.jsxs(de,{variant:"neutral",children:[p.reservationCount," reservations"]})]}),e.jsxs("div",{className:"mt-6 grid gap-6 xl:grid-cols-2",children:[e.jsxs(Be,{className:"overflow-hidden p-0",children:[e.jsxs("div",{className:"flex items-center gap-3 border-b border-gray-200 pb-3.5 dark:border-gray-800",children:[e.jsx(N.LogsIcon,{className:"size-4 text-gray-400 dark:text-gray-500","aria-hidden":"true"}),e.jsx("h2",{className:"font-semibold text-gray-900 dark:text-gray-50",children:"Orders"}),e.jsxs("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:["(",u.data.orders.length,")"]})]}),u.data.orders.length===0?e.jsx("div",{className:"px-5 py-8 text-center text-sm text-gray-500 dark:text-gray-400",children:"No orders yet."}):e.jsx("div",{className:"divide-y divide-gray-200 dark:divide-gray-800",children:u.data.orders.map(f=>{var y;const b=nc(f.status);return e.jsx("button",{type:"button",onClick:()=>l(f),className:"w-full px-5 py-3.5 text-left transition hover:bg-gray-50 dark:hover:bg-gray-900/70",children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-50",children:["Order #",f.referenceId]}),e.jsxs("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:[hs(f.createdAt),f.fulfilmentMethod==="pickup"?" · Pickup":f.shippingAddress?` · ${f.shippingAddress.city}, ${f.shippingAddress.country}`:" · Delivery"]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-3",children:[e.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-gray-50",children:h(Number(((y=f.payment)==null?void 0:y.total)??0),f.currency)}),e.jsx(de,{variant:b.variant,children:b.label})]})]})},f.id)})})]}),e.jsxs(Be,{className:"overflow-hidden p-0",children:[e.jsxs("div",{className:"flex items-center gap-3 border-b border-gray-200 pb-3.5 dark:border-gray-800",children:[e.jsx(N.CalendarCheckIcon,{className:"size-4 text-gray-400 dark:text-gray-500","aria-hidden":"true"}),e.jsx("h2",{className:"font-semibold text-gray-900 dark:text-gray-50",children:"Reservations"}),e.jsxs("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:["(",u.data.reservations.length,")"]})]}),u.data.reservations.length===0?e.jsx("div",{className:"px-5 py-8 text-center text-sm text-gray-500 dark:text-gray-400",children:"No reservations yet."}):e.jsx("div",{className:"divide-y divide-gray-200 dark:divide-gray-800",children:u.data.reservations.map(f=>{const b=oc(f);return e.jsx("button",{type:"button",onClick:()=>m(f),className:"w-full px-5 py-3.5 text-left transition hover:bg-gray-50 dark:hover:bg-gray-900/70",children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-50",children:["Reservation #",f.referenceId]}),e.jsxs("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:[hs(f.date)," · ",f.guests," ",f.guests===1?"guest":"guests"]})]}),e.jsx(de,{variant:b.variant,children:b.label})]})},f.id)})})]})]}),e.jsx(cn,{open:!!o,onOpenChange:f=>{f||l(null)},order:o}),c?e.jsx(wr,{open:!!c,onOpenChange:f=>{f||m(null)},organizationId:t,reservation:c,refetch:u.refetch}):null]})}function dc(){return e.jsx(lc,{})}const cc=x.forwardRef(({className:a,children:t,...r},s)=>e.jsx("div",{ref:s,children:e.jsx("div",{className:$("w-full overflow-auto whitespace-nowrap",a),...r,children:t})}));cc.displayName="TableRoot";const kr=x.forwardRef(({className:a,...t},r)=>e.jsx("table",{ref:r,className:$("w-full caption-bottom border-b","border-gray-200 dark:border-gray-800",a),...t}));kr.displayName="Table";const Nr=x.forwardRef(({className:a,...t},r)=>e.jsx("thead",{ref:r,className:$(a),...t}));Nr.displayName="TableHead";const ma=x.forwardRef(({className:a,...t},r)=>e.jsx("th",{ref:r,className:$("border-b px-4 py-3.5 text-left text-sm font-semibold","text-gray-900 dark:text-gray-50","border-gray-200 dark:border-gray-800",a),...t}));ma.displayName="TableHeaderCell";const Ar=x.forwardRef(({className:a,...t},r)=>e.jsx("tbody",{ref:r,className:$("divide-y","divide-gray-200 dark:divide-gray-800",a),...t}));Ar.displayName="TableBody";const ua=x.forwardRef(({className:a,...t},r)=>e.jsx("tr",{ref:r,className:$("[&_td:last-child]:pr-4 [&_th:last-child]:pr-4","[&_td:first-child]:pl-4 [&_th:first-child]:pl-4",a),...t}));ua.displayName="TableRow";const $e=x.forwardRef(({className:a,...t},r)=>e.jsx("td",{ref:r,className:$("p-4 text-sm","text-gray-600 dark:text-gray-400",a),...t}));$e.displayName="TableCell";const mc=x.forwardRef(({className:a,...t},r)=>e.jsx("tfoot",{ref:r,className:$("border-t text-left font-medium","text-gray-900 dark:text-gray-50","border-gray-200 dark:border-gray-800",a),...t}));mc.displayName="TableFoot";const uc=x.forwardRef(({className:a,...t},r)=>e.jsx("caption",{ref:r,className:$("mt-3 px-3 text-center text-sm","text-gray-500 dark:text-gray-500",a),...t}));uc.displayName="TableCaption";const pc=w("hidden h-6 select-none items-center justify-center rounded-md bg-gray-800 px-2 font-mono text-xs text-gray-400 ring-1 ring-inset ring-gray-700 transition sm:flex"),pn=({open:a=!1,onOpenChange:t,defaultOpen:r=!1,disableAutoFocus:s=!0,children:i})=>e.jsxs(ie.Root,{open:a,onOpenChange:t,defaultOpen:r,children:[e.jsx(ie.Anchor,{className:w("fixed inset-x-0 bottom-8 mx-auto flex w-fit items-center")}),e.jsx(ie.Portal,{children:e.jsx(ie.Content,{side:"top",sideOffset:0,onOpenAutoFocus:n=>{s&&n.preventDefault()},className:w("z-50","data-[state=closed]:animate-hide","data-[side=top]:animate-slideUpAndFade"),children:i})})]});pn.displayName="CommandBar";const gn=z.forwardRef(({className:a,...t},r)=>e.jsx("div",{ref:r,className:w("px-3 py-2.5 text-sm tabular-nums text-gray-300",a),...t}));gn.displayName="CommandBar.Value";const hn=z.forwardRef(({className:a,...t},r)=>e.jsx("div",{ref:r,className:w("relative flex items-center rounded-lg bg-gray-900 px-1 shadow-lg shadow-black/30 dark:ring-1 dark:ring-white/10",a),...t}));hn.displayName="CommandBarBar";const nt=z.forwardRef(({className:a,...t},r)=>e.jsx("div",{ref:r,className:w("h-4 w-px bg-gray-700",a),...t}));nt.displayName="CommandBar.Seperator";const ot=z.forwardRef(({className:a,type:t="button",label:r,action:s,shortcut:i,disabled:n,...o},l)=>(z.useEffect(()=>{const c=m=>{m.key===i.shortcut&&(m.preventDefault(),m.stopPropagation(),s())};return n||document.addEventListener("keydown",c),()=>{document.removeEventListener("keydown",c)}},[s,i,n]),e.jsx("span",{className:w("flex items-center gap-x-2 rounded-lg bg-gray-900 p-1 text-base font-medium text-gray-50 outline-hidden transition focus:z-10 sm:text-sm","sm:last-of-type:-mr-1",a),children:e.jsxs("button",{ref:l,type:t,onClick:s,disabled:n,className:w("flex items-center gap-x-2 rounded-md px-1 py-1 hover:bg-gray-800","focus-visible:bg-gray-800 focus-visible:hover:bg-gray-800","disabled:text-gray-500",Ae),...o,children:[e.jsx("span",{children:r}),e.jsx("span",{className:pc,children:i.label?i.label.toUpperCase():i.shortcut.toUpperCase()})]})})));ot.displayName="CommandBar.Command";function gc({table:a,rowSelection:t}){const r=Object.keys(t).length>0;return e.jsx(pn,{open:r,children:e.jsxs(hn,{children:[e.jsxs(gn,{children:[Object.keys(t).length," selected"]}),e.jsx(nt,{}),e.jsx(ot,{label:"Edit",action:()=>{console.log("Edit")},shortcut:{shortcut:"e"}}),e.jsx(nt,{}),e.jsx(ot,{label:"Delete",action:()=>{console.log("Delete")},shortcut:{shortcut:"d"}}),e.jsx(nt,{}),e.jsx(ot,{label:"Reset",action:()=>{a.resetRowSelection()},shortcut:{shortcut:"Escape",label:"esc"}})]})})}function hc({meta:a,table:t}){const r=E.useSearchParams(),s=E.useRouter(),i=E.usePathname(),n=Number((r==null?void 0:r.get("page"))||"1"),o=(g,h)=>{const f=new URLSearchParams(r==null?void 0:r.toString());return f.set(g,h),f.toString()},l=g=>{s.push(`${i}?${o("page",g.toString())}`)},c=[{icon:P.RiArrowLeftDoubleLine,onClick:()=>l(1),disabled:!(a!=null&&a.previousPage),srText:"First page",mobileView:"hidden sm:block"},{icon:P.RiArrowLeftSLine,onClick:()=>l(n-1),disabled:!(a!=null&&a.previousPage),srText:"Previous page",mobileView:""},{icon:P.RiArrowRightSLine,onClick:()=>l(n+1),disabled:!(a!=null&&a.nextPage),srText:"Next page",mobileView:""},{icon:P.RiArrowRightDoubleLine,onClick:()=>l(a.pageCount),disabled:!(a!=null&&a.nextPage),srText:"Last page",mobileView:"hidden sm:block"}],m=t.getFilteredRowModel().rows.length,u=t.getState().pagination.pageIndex*15+1,p=Math.min(m,u+15-1);return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"text-sm tabular-nums text-gray-500",children:[t.getFilteredSelectedRowModel().rows.length," of ",m," row(s) selected."]}),e.jsxs("div",{className:"flex items-center gap-x-6 lg:gap-x-8",children:[e.jsxs("p",{className:"hidden text-sm tabular-nums text-gray-500 sm:block",children:["Showing"," ",e.jsxs("span",{className:"font-medium text-gray-900 dark:text-gray-50",children:[u,"-",p]})," ","of"," ",e.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-50",children:m})]}),e.jsx("div",{className:"flex items-center gap-x-1.5",children:c.map((g,h)=>e.jsxs(D,{variant:"secondary",className:w(g.mobileView,"p-1.5"),onClick:()=>{g.onClick(),t.resetRowSelection()},disabled:g.disabled,children:[e.jsx("span",{className:"sr-only",children:g.srText}),e.jsx(g.icon,{className:"size-4 shrink-0","aria-hidden":"true"})]},h))})]})]})}function ha({meta:a,columns:t,error:r,data:s,loading:i,className:n,refetch:o}){var g,h;const l=H(),c=_(),[m,u]=z.useState({}),p=Se.useReactTable({data:s,columns:t,state:{rowSelection:m},enableRowSelection:!0,getFilteredRowModel:Se.getFilteredRowModel(),onRowSelectionChange:u,getCoreRowModel:Se.getCoreRowModel(),getSortedRowModel:Se.getSortedRowModel(),manualPagination:!0,meta:{...a,organizationId:l,refetch:o,routes:c}});return e.jsx(e.Fragment,{children:e.jsxs("div",{className:w("space-y-6 relative",n),children:[e.jsxs("div",{className:"relative overflow-hidden overflow-x-auto",children:[i&&!s?e.jsx("div",{className:"flex items-center justify-center h-48",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(pe,{className:"w-10 h-10"}),e.jsx("p",{className:"text-gray-500 text-xs mt-1",children:"Loading..."})]})}):e.jsxs(e.Fragment,{children:[e.jsxs(kr,{children:[e.jsx(Nr,{children:p.getHeaderGroups().map(f=>e.jsx(ua,{className:"border-y border-gray-200 dark:border-gray-800 back",children:f.headers.map(b=>{var y;return e.jsx(ma,{className:w("whitespace-nowrap py-1 text-sm sm:text-xs",(y=b.column.columnDef.meta)==null?void 0:y.className),children:Se.flexRender(b.column.columnDef.header,b.getContext())},b.id)})},f.id))}),e.jsxs(Ar,{children:[r&&e.jsx(ua,{children:e.jsx($e,{colSpan:t.length,className:"h-24 text-center text-red-500",children:"An error occurred while fetching data. Please refresh the site and try again."})}),((g=p.getRowModel().rows)==null?void 0:g.length)>0&&p.getRowModel().rows.map(f=>e.jsx(ua,{className:"group select-none hover:bg-gray-50 dark:hover:bg-gray-900",children:f.getVisibleCells().map((b,y)=>{var j;return e.jsxs($e,{className:w(f.getIsSelected()?"bg-gray-50 dark:bg-gray-900":"","relative whitespace-nowrap py-1 text-gray-600 first:w-10 dark:text-gray-400",(j=b.column.columnDef.meta)==null?void 0:j.className),children:[y===0&&f.getIsSelected()&&e.jsx("div",{className:"absolute inset-y-0 left-0 w-0.5 bg-blue-600 dark:bg-blue-500"}),Se.flexRender(b.column.columnDef.cell,b.getContext())]},b.id)})},f.id)),((h=p.getRowModel().rows)==null?void 0:h.length)===0&&!i&&e.jsx(ua,{children:e.jsx($e,{colSpan:t.length,className:"h-24 text-center",children:"No results."})})]})]}),i&&s&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-white bg-opacity-75 dark:bg-gray-900 dark:bg-opacity-75",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(pe,{className:"w-10 h-10"}),e.jsx("p",{className:"text-gray-500 text-xs mt-1",children:"Loading..."})]})})]}),e.jsx(gc,{table:p,rowSelection:m})]}),a&&e.jsx(hc,{meta:a,table:p})]})})}const xc=Le.tv({base:["relative block w-full appearance-none rounded-md border px-2.5 py-1.5 outline-hidden transition sm:text-sm","border-transparent dark:border-gray-800","text-gray-900 dark:text-gray-50","placeholder-gray-400 dark:placeholder-gray-500","bg-gray-100 dark:bg-gray-950","disabled:border-gray-300 disabled:bg-gray-100 disabled:text-gray-400","dark:disabled:border-gray-700 dark:disabled:bg-gray-800 dark:disabled:text-gray-500",Da,"[&::--webkit-search-cancel-button]:hidden [&::-webkit-search-cancel-button]:hidden [&::-webkit-search-decoration]:hidden"],variants:{hasError:{true:Vt},enableStepper:{true:"[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none"}}}),xa=z.forwardRef(({className:a,inputClassName:t,hasError:r,enableStepper:s,type:i="search",...n},o)=>e.jsxs("div",{className:w("relative w-full",a),children:[e.jsx("input",{ref:o,type:i,className:w(xc({hasError:r,enableStepper:s}),"pl-8",t),...n}),e.jsx("div",{className:w("pointer-events-none absolute bottom-0 left-2 flex h-full items-center justify-center","text-gray-400 dark:text-gray-600"),children:e.jsx(P.RiSearchLine,{className:"size-[1.125rem] shrink-0","aria-hidden":"true"})})]}));xa.displayName="Searchbar";function V({column:a,title:t,className:r}){return a.getCanSort()?e.jsxs("div",{onClick:a.getToggleSortingHandler(),className:w(a.columnDef.enableSorting===!0?"-mx-2 inline-flex cursor-pointer select-none items-center gap-2 rounded-md px-2 py-1 hover:bg-gray-50 dark:hover:bg-gray-900":""),children:[e.jsx("span",{children:t}),a.getCanSort()?e.jsxs("div",{className:"-space-y-2",children:[e.jsx(P.RiArrowUpSLine,{className:w("size-3.5 text-gray-900 dark:text-gray-50",a.getIsSorted()==="desc"?"opacity-30":""),"aria-hidden":"true"}),e.jsx(P.RiArrowDownSLine,{className:w("size-3.5 text-gray-900 dark:text-gray-50",a.getIsSorted()==="asc"?"opacity-30":""),"aria-hidden":"true"})]}):null]}):e.jsx("div",{className:w(r),children:t})}const Ba=Se.createColumnHelper(),xn=a=>{var t;return`${a.firstname} ${a.lastname}`.trim()||((t=a.name)==null?void 0:t.trim())||a.email},fc=a=>{const t=xn(a),r=t.split(" ").filter(Boolean);return r.length>=2?`${r[0][0]}${r[1][0]}`.toUpperCase():t.substring(0,2).toUpperCase()},yc=({customer:a})=>{const t=H(),r=_();return e.jsxs(B,{href:r.customerDetail(t,a.id),className:"flex items-center gap-x-4 truncate py-2 transition hover:opacity-90",children:[e.jsx("span",{className:"hidden size-9 shrink-0 items-center justify-center rounded-full border border-gray-300 bg-white text-xs text-gray-700 sm:flex dark:border-gray-800 dark:bg-gray-950 dark:text-gray-300","aria-hidden":"true",children:fc(a)}),e.jsxs("div",{className:"truncate",children:[e.jsx("p",{className:"truncate text-sm font-medium text-gray-900 dark:text-gray-50",children:xn(a)}),e.jsx("p",{className:"truncate text-xs text-gray-500",children:a.email})]})]})},bc=({customer:a})=>{const t=H(),r=_();return e.jsx(B,{href:r.customerDetail(t,a.id),className:"text-sm font-medium text-indigo-600 hover:text-indigo-500 dark:text-indigo-400 dark:hover:text-indigo-300",children:"View"})},jc=[Ba.display({id:"name",meta:{className:"text-left",displayName:"Customer"},header:({column:a})=>e.jsx(V,{column:a,title:"Customer"}),cell:({row:a})=>e.jsx(yc,{customer:a.original})}),Ba.accessor("orderCount",{enableSorting:!0,meta:{className:"text-left",displayName:"Orders"},header:({column:a})=>e.jsx(V,{column:a,title:"Orders"}),cell:({row:a})=>e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:a.original.orderCount})}),Ba.accessor("reservationCount",{enableSorting:!0,meta:{className:"text-left",displayName:"Reservations"},header:({column:a})=>e.jsx(V,{column:a,title:"Reservations"}),cell:({row:a})=>e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:a.original.reservationCount})}),Ba.accessor("createdAt",{enableSorting:!0,meta:{className:"text-left",displayName:"Customer Since"},header:({column:a})=>e.jsx(V,{column:a,title:"Customer Since"}),cell:({row:a})=>e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:a.original.createdAt?I.format(new Date(a.original.createdAt),"dd MMM yyyy"):"N/A"})}),Ba.display({id:"actions",enableSorting:!1,enableHiding:!1,meta:{className:"text-right",displayName:""},header:()=>null,cell:({row:a})=>e.jsx(bc,{customer:a.original})})];function vc(){var g,h;const{client:a}=M(),t=H(),r=E.usePathname(),s=E.useRouter(),i=E.useSearchParams(),[n,o]=x.useState(""),[l]=Ke.useDebounce(n,300),c=Number((i==null?void 0:i.get("page"))||"1"),m=(f,b)=>{const y=new URLSearchParams(i==null?void 0:i.toString());return y.set(f,b),y.toString()},u=()=>{c!==1&&s.replace(`${r}?${m("page","1")}`)},p=A.useQuery({queryKey:["customers",t,c,l],queryFn:async()=>{const{body:f,status:b}=await a.customer.getCustomers({params:{organizationId:t},query:{page:c,limit:10,search:l}});if(b!==200)throw new Error("Failed to fetch customers");return f},placeholderData:A.keepPreviousData});return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap items-center justify-between gap-2 sm:gap-x-6",children:e.jsx("div",{className:"flex w-full flex-col gap-2 sm:w-fit sm:flex-row sm:items-center",children:e.jsx(xa,{type:"search",placeholder:"Search by name or email...",value:n,onChange:f=>{o(f.target.value),u()},className:"w-full sm:max-w-[280px] sm:[&>input]:h-[40px]"})})}),e.jsx(ha,{error:p.isError,loading:p.isLoading||p.isRefetching,meta:(g=p.data)!=null&&g.meta?{...p.data.meta,currentPage:c}:void 0,data:((h=p.data)==null?void 0:h.list)||[],columns:jc,className:"mt-8",refetch:p.refetch})]})}function wc(){return e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-xl font-semibold text-gray-900 sm:text-2xl dark:text-gray-50",children:"Customers"}),e.jsx("div",{className:"mt-4 sm:mt-6 lg:mt-6",children:e.jsx(vc,{})})]})}const La=z.forwardRef(({onClick:a,icon:t,disabled:r,...s},i)=>{const n=t;return e.jsx("button",{ref:i,type:"button",disabled:r,className:w("flex size-8 shrink-0 select-none items-center justify-center rounded border p-1 outline-hidden transition sm:size-[30px]","text-gray-600 hover:text-gray-800","dark:text-gray-400 dark:hover:text-gray-200","border-gray-300 dark:border-gray-800","hover:bg-gray-50 active:bg-gray-100","dark:hover:bg-gray-900 dark:active:bg-gray-800","disabled:pointer-events-none","disabled:border-gray-200 dark:disabled:border-gray-800","disabled:text-gray-400 dark:disabled:text-gray-600",Ae),onClick:a,...s,children:e.jsx(n,{className:"size-full shrink-0"})})});La.displayName="NavigationButton";function xs({displayMonth:a,displayIndex:t,enableYearNavigation:r,disableNavigation:s,numberOfMonths:i,startMonth:n,endMonth:o}){const l=Oa.useNavigation(),c=a,m=t??0,u=m<=0,p=m===i-1,g=i>1&&(u||!p),h=i>1&&(p||!u),f=l.previousMonth,b=l.nextMonth,y=l.goToMonth,j=!n||I.addYears(c,-1).getTime()>=n.getTime(),v=!o||I.addYears(c,1).getTime()<=o.getTime(),k=()=>{!f||!j||y(I.addYears(c,-1))},C=()=>{!b||!v||y(I.addYears(c,1))};return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[r&&!h&&e.jsx(La,{disabled:s||!f||!j,"aria-label":"Go to previous year",onClick:k,icon:P.RiArrowLeftDoubleLine}),!h&&e.jsx(La,{disabled:s||!f,"aria-label":"Go to previous month",onClick:()=>f&&y(f),icon:P.RiArrowLeftSLine})]}),e.jsx("div",{role:"presentation","aria-live":"polite",className:"text-sm font-medium capitalize tabular-nums text-gray-900 dark:text-gray-50",children:I.format(c,"LLLL yyy")}),e.jsxs("div",{className:"flex items-center gap-1",children:[!g&&e.jsx(La,{disabled:s||!b,"aria-label":"Go to next month",onClick:()=>b&&y(b),icon:P.RiArrowRightSLine}),r&&!g&&e.jsx(La,{disabled:s||!b||!v,"aria-label":"Go to next year",onClick:C,icon:P.RiArrowRightDoubleLine})]})]})}const fn=a=>{const t=a.enableYearNavigation??!1,r=a.weekStartsOn??1,s=a.numberOfMonths??1,i=a.disableNavigation,n=a.fromMonth??(a.fromYear?new Date(a.fromYear,0,1):void 0),o=a.toMonth??(a.toYear?new Date(a.toYear,11,1):void 0),l={months:"flex space-y-0",month:"space-y-4 p-3",caption:"p-4",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"w-9 font-medium text-sm sm:text-xs text-center text-gray-400 dark:text-gray-600 pb-2",row:"mt-0.5 flex w-full",cell:w("relative p-0 text-center focus-within:relative","text-gray-900 dark:text-gray-50"),day:w("size-9 rounded text-sm text-gray-900 focus:z-10 dark:text-gray-50","hover:bg-gray-200 dark:hover:bg-gray-700",Ae),day_today:"font-semibold",day_selected:w("rounded","bg-blue-600 text-gray-50","dark:bg-blue-500 dark:text-gray-50"),day_disabled:"text-gray-300! dark:text-gray-700! line-through hover:bg-transparent",day_outside:"text-gray-400 dark:text-gray-600",day_range_middle:w("rounded-none!","bg-gray-100! text-gray-900!","dark:bg-gray-900! dark:text-gray-50!"),day_range_start:"rounded-r-none rounded-l!",day_range_end:"rounded-l-none rounded-r!",...a.classNames},c={...a.components,Caption:({displayMonth:k,displayIndex:C})=>e.jsx(xs,{displayMonth:k,displayIndex:C,enableYearNavigation:t,disableNavigation:i,numberOfMonths:s,startMonth:n,endMonth:o}),Chevron:()=>e.jsx("span",{}),Nav:()=>e.jsx("span",{}),MonthCaption:({calendarMonth:k,displayIndex:C})=>e.jsx(xs,{displayMonth:k.date,displayIndex:C,enableYearNavigation:t,disableNavigation:i,numberOfMonths:s,startMonth:n,endMonth:o})},m={weekStartsOn:r,numberOfMonths:s,disableNavigation:i,showOutsideDays:s===1,className:w(a.className),classNames:l,components:c};if(a.mode==="range"){const{enableYearNavigation:k,className:C,classNames:F,components:T,weekStartsOn:O,numberOfMonths:R,...S}=a,Q={...S,...m,mode:"range"};return e.jsx(Oa.DayPicker,{...Q})}if(a.mode==="multiple"){const{enableYearNavigation:k,className:C,classNames:F,components:T,weekStartsOn:O,numberOfMonths:R,...S}=a,Q={...S,...m,mode:"multiple"};return e.jsx(Oa.DayPicker,{...Q})}if(a.mode==="default"){const{enableYearNavigation:k,className:C,classNames:F,components:T,weekStartsOn:O,numberOfMonths:R,...S}=a,Q={...S,...m,mode:"default"};return e.jsx(Oa.DayPicker,{...Q})}const{enableYearNavigation:u,className:p,classNames:g,components:h,mode:f,weekStartsOn:b,numberOfMonths:y,...j}=a,v={...j,...m,mode:"single"};return e.jsx(Oa.DayPicker,{...v})};fn.displayName="Calendar";const kc=()=>{const a=typeof window<"u"?window.navigator.language:"en-US",t=new Intl.DateTimeFormat(a,{hour:"numeric"}).format();return Number.isInteger(Number(t))},Nc=({segment:a,state:t})=>{const r=z.useRef(null),{segmentProps:s}=Ss.useDateSegment(a,t,r),i=a.type==="literal"&&a.text===":",n=a.type==="literal"&&a.text===" ",o=i||n;return e.jsxs("div",{...s,ref:r,className:$("relative block w-full appearance-none rounded-md border px-2.5 py-1.5 text-left uppercase tabular-nums shadow-xs outline-hidden transition sm:text-sm","border-gray-300 dark:border-gray-800","text-gray-900 dark:text-gray-50","bg-white dark:bg-gray-950",Da,"invalid:border-red-500 invalid:ring-2 invalid:ring-red-200 group-aria-invalid/time-input:border-red-500 group-aria-invalid/time-input:ring-2 group-aria-invalid/time-input:ring-red-200 dark:group-aria-invalid/time-input:ring-red-400/20",{"w-fit! border-none bg-transparent px-0 text-gray-400 shadow-none":o,hidden:n,"border-gray-300 bg-gray-100 text-gray-400 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-500":t.isDisabled,"bg-transparent! text-gray-400!":!a.isEditable}),children:[e.jsx("span",{"aria-hidden":"true",className:$("pointer-events-none block w-full text-left text-gray-700 sm:text-sm",{hidden:!a.isPlaceholder,"h-0":!a.isPlaceholder}),children:a.placeholder}),a.isPlaceholder?" ":a.text]})},ar=z.forwardRef(({hourCycle:a,...t},r)=>{const s=z.useRef(null);z.useImperativeHandle(r,()=>s==null?void 0:s.current);const i=window!==void 0?window.navigator.language:"en-US",n=so.useTimeFieldState({hourCycle:a,locale:i,shouldForceLeadingZeros:!0,autoFocus:!0,...t}),{fieldProps:o}=Ss.useTimeField({...t,hourCycle:a,shouldForceLeadingZeros:!0},n,s);return e.jsx("div",{...o,ref:s,className:"group/time-input inline-flex w-full gap-x-2",children:n.segments.map((l,c)=>e.jsx(Nc,{segment:l,state:n},c))})});ar.displayName="TimeInput";const Ac=Le.tv({base:["peer flex w-full cursor-pointer appearance-none items-center gap-x-2 truncate rounded-md border px-3 py-2 shadow-xs outline-hidden transition-all sm:text-sm","bg-white dark:bg-gray-950","border-gray-300 dark:border-gray-800","text-gray-900 dark:text-gray-50","placeholder-gray-400 dark:placeholder-gray-500","hover:bg-gray-50 dark:hover:bg-gray-950/50","disabled:pointer-events-none","disabled:bg-gray-100 disabled:text-gray-400","dark:disabled:border-gray-800 dark:disabled:bg-gray-800 dark:disabled:text-gray-500",Da],variants:{hasError:{true:Vt}}}),yn=z.forwardRef(({className:a,children:t,placeholder:r,hasError:s,...i},n)=>e.jsx(ie.Trigger,{asChild:!0,children:e.jsxs("button",{ref:n,className:$(Ac({hasError:s}),a),...i,children:[e.jsx(P.RiCalendar2Fill,{className:"size-5 shrink-0 text-gray-400 dark:text-gray-600"}),e.jsx("span",{className:"flex-1 overflow-hidden text-ellipsis whitespace-nowrap text-left text-gray-900 dark:text-gray-50",children:t||(r?e.jsx("span",{className:"text-gray-400 dark:text-gray-600",children:r}):null)})]})}));yn.displayName="DatePicker.Trigger";const bn=z.forwardRef(({align:a,className:t,children:r,...s},i)=>e.jsx(ie.Portal,{children:e.jsx(ie.Content,{ref:i,sideOffset:10,side:"bottom",align:a,avoidCollisions:!0,onOpenAutoFocus:n=>n.preventDefault(),className:$("relative z-50 w-fit rounded-md border text-sm shadow-xl shadow-black/[2.5%]","min-w-[calc(var(--radix-select-trigger-width)-2px)] max-w-[95vw]","border-gray-200 dark:border-gray-800","bg-white dark:bg-gray-950","will-change-[transform,opacity]","data-[state=closed]:animate-hide","data-[state=open]:data-[side=bottom]:animate-slideDownAndFade data-[state=open]:data-[side=left]:animate-slideLeftAndFade data-[state=open]:data-[side=right]:animate-slideRightAndFade data-[state=open]:data-[side=top]:animate-slideUpAndFade",t),...s,children:r})}));bn.displayName="DatePicker.CalendarPopover";const jn=({presets:a,onSelect:t,currentValue:r})=>{const s=m=>"dateRange"in m,i=m=>"date"in m,n=m=>{s(m)?t(m.dateRange):i(m)&&t(m.date)},o=(m,u)=>m.getDate()===u.getDate()&&m.getMonth()===u.getMonth()&&m.getFullYear()===u.getFullYear(),l=(m,u)=>{const p=m.from,g=u.from;let h=!1;p&&g&&o(p,g)&&(h=!0);const f=m.to,b=u.to;let y=!1;return f&&b&&o(f,b)&&(y=!0),h&&y},c=m=>{if(s(m)){const u=r;return u&&l(u,m.dateRange)}else if(i(m)){const u=r;return u&&o(u,m.date)}return!1};return e.jsx("ul",{className:"flex items-start gap-x-2 sm:flex-col",children:a.map((m,u)=>e.jsx("li",{className:"sm:w-full sm:py-px",children:e.jsx("button",{title:m.label,className:$("relative w-full overflow-hidden text-ellipsis whitespace-nowrap rounded border px-2.5 py-1.5 text-left text-base shadow-xs outline-hidden transition-all sm:border-none sm:py-2 sm:text-sm sm:shadow-none","text-gray-700 dark:text-gray-300","border-gray-200 dark:border-gray-800",Ae,"focus-visible:bg-gray-100 dark:focus-visible:bg-gray-900","hover:bg-gray-100 dark:hover:bg-gray-900",{"bg-gray-100 dark:bg-gray-900":c(m)}),onClick:()=>n(m),"aria-label":`Select ${m.label}`,children:e.jsx("span",{children:m.label})})},u))})};jn.displayName="DatePicker.PresetContainer";const fs=(a,t,r)=>{const s=!kc();let i;return r?i=s?I.format(a,"dd MMM, yyyy h:mm a",{locale:t}):I.format(a,"dd MMM, yyyy HH:mm",{locale:t}):i=I.format(a,"dd MMM, yyyy",{locale:t}),i},Cc=({defaultValue:a,value:t,onChange:r,presets:s,disabled:i,disableNavigation:n,disabledDays:o,enableYearNavigation:l=!1,locale:c=io.enUS,showTimePicker:m,placeholder:u="Select date range",hasError:p,translations:g,align:h="center",className:f,...b})=>{const[y,j]=z.useState(!1),[v,k]=z.useState(t??a??void 0),[C,F]=z.useState(v==null?void 0:v.from),[T,O]=z.useState(t!=null&&t.from?new he.Time(t.from.getHours(),t.from.getMinutes()):a!=null&&a.from?new he.Time(a.from.getHours(),a.from.getMinutes()):new he.Time(0,0)),[R,S]=z.useState(t!=null&&t.to?new he.Time(t.to.getHours(),t.to.getMinutes()):a!=null&&a.to?new he.Time(a.to.getHours(),a.to.getMinutes()):new he.Time(0,0)),Q=z.useMemo(()=>v,[y]);z.useEffect(()=>{k(t??a??void 0)},[t,a]),z.useEffect(()=>{v&&F(v.from)},[v]),z.useEffect(()=>{y||F(v==null?void 0:v.from)},[y]);const W=X=>{const Y=X;m&&(Y!=null&&Y.from&&!T&&O(new he.Time(0,0)),Y!=null&&Y.to&&!R&&S(new he.Time(0,0)),Y!=null&&Y.from&&T&&(Y.from.setHours(T.hour),Y.from.setMinutes(T.minute)),Y!=null&&Y.to&&R&&(Y.to.setHours(R.hour),Y.to.setMinutes(R.minute))),k(Y)},ye=()=>{k(Q),O(Q!=null&&Q.from?new he.Time(Q.from.getHours(),Q.from.getMinutes()):new he.Time(0,0)),S(Q!=null&&Q.to?new he.Time(Q.to.getHours(),Q.to.getMinutes()):new he.Time(0,0)),j(!1)},Ve=X=>{X||ye(),j(X)},ue=(X,Y)=>{switch(Y){case"start":O(X);break;case"end":S(X);break}if(v){if(Y==="start"){if(!v.from)return;const ce=new Date(v.from.getTime());X?(ce.setHours(X.hour),ce.setMinutes(X.minute)):(ce.setHours(0),ce.setMinutes(0)),k({...v,from:ce})}if(Y==="end"){if(!v.to)return;const ce=new Date(v.to.getTime());X?(ce.setHours(X.hour),ce.setMinutes(X.minute)):(ce.setHours(0),ce.setMinutes(0)),k({...v,to:ce})}}};z.useEffect(()=>{k(t??a??void 0),O(t!=null&&t.from?new he.Time(t.from.getHours(),t.from.getMinutes()):a!=null&&a.from?new he.Time(a.from.getHours(),a.from.getMinutes()):new he.Time(0,0)),S(t!=null&&t.to?new he.Time(t.to.getHours(),t.to.getMinutes()):a!=null&&a.to?new he.Time(a.to.getHours(),a.to.getMinutes()):new he.Time(0,0))},[t,a]);const oa=z.useMemo(()=>v?`${v.from?fs(v.from,c,m):""} - ${v.to?fs(v.to,c,m):""}`:null,[v,c,m]),Ce=()=>{j(!1),r==null||r(v)};return e.jsxs(ie.Root,{"tremor-id":"tremor-raw",open:y,onOpenChange:Ve,children:[e.jsx(yn,{placeholder:u,disabled:i,className:f,hasError:p,"aria-required":b.required||b["aria-required"],"aria-invalid":b["aria-invalid"],"aria-label":b["aria-label"],"aria-labelledby":b["aria-labelledby"],children:oa}),e.jsx(bn,{align:h,children:e.jsx("div",{className:"flex",children:e.jsxs("div",{className:"flex flex-col overflow-x-auto sm:flex-row sm:items-start",children:[s&&s.length>0&&e.jsx("div",{className:$("relative flex h-16 w-full items-center sm:h-full sm:w-40","border-b border-gray-200 sm:border-b-0 sm:border-r dark:border-gray-800","overflow-auto"),children:e.jsx("div",{className:"absolute px-3 sm:inset-0 sm:left-0 sm:p-2",children:e.jsx(jn,{currentValue:v,presets:s,onSelect:W})})}),e.jsxs("div",{className:"overflow-x-auto",children:[e.jsx(fn,{mode:"range",selected:v,onSelect:W,month:C,onMonthChange:F,numberOfMonths:2,disabled:o,disableNavigation:n,enableYearNavigation:l,locale:c,initialFocus:!0,classNames:{months:"flex flex-row divide-x divide-gray-200 dark:divide-gray-800 overflow-x-auto"},...b}),m&&e.jsxs("div",{className:"flex items-center justify-evenly gap-x-3 border-t border-gray-200 p-3 dark:border-gray-800",children:[e.jsxs("div",{className:"flex flex-1 items-center gap-x-2",children:[e.jsxs("span",{className:"dark:text-gray-30 text-gray-700",children:[(g==null?void 0:g.start)??"Start",":"]}),e.jsx(ar,{value:T,onChange:X=>ue(X,"start"),"aria-label":"Start date time",isDisabled:!(v!=null&&v.from),isRequired:b.required})]}),e.jsx(P.RiSubtractFill,{className:"size-4 shrink-0 text-gray-400"}),e.jsxs("div",{className:"flex flex-1 items-center gap-x-2",children:[e.jsxs("span",{className:"dark:text-gray-30 text-gray-700",children:[(g==null?void 0:g.end)??"End",":"]}),e.jsx(ar,{value:R,onChange:X=>ue(X,"end"),"aria-label":"End date time",isDisabled:!(v!=null&&v.to),isRequired:b.required})]})]}),e.jsxs("div",{className:"border-t border-gray-200 p-3 sm:flex sm:items-center sm:justify-between dark:border-gray-800",children:[e.jsxs("p",{className:"tabular-nums text-gray-900 dark:text-gray-50",children:[e.jsxs("span",{className:"text-gray-700 dark:text-gray-300",children:[(g==null?void 0:g.range)??"Range",":"]})," ",e.jsx("span",{className:"font-medium",children:oa})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-x-2 sm:mt-0",children:[e.jsx(D,{variant:"secondary",className:"h-8 w-full sm:w-fit",type:"button",onClick:ye,children:(g==null?void 0:g.cancel)??"Cancel"}),e.jsx(D,{variant:"primary",className:"h-8 w-full sm:w-fit",type:"button",onClick:Ce,children:(g==null?void 0:g.apply)??"Apply"})]})]})]})]})})})]})},Sc=(a,t)=>{const{toYear:r,fromYear:s,fromMonth:i,toMonth:n,fromDay:o,toDay:l}=t;if(a&&a.length>0){const c=s,m=r;a.forEach(u=>{var p,g,h,f,b,y;if("date"in u){const j=u.date.getFullYear();if(s&&j<s)throw new Error(`Preset ${u.label} is before fromYear ${c}.`);if(r&&j>r)throw new Error(`Preset ${u.label} is after toYear ${m}.`);if(i&&u.date.getMonth()<i.getMonth())throw new Error(`Preset ${u.label} is before fromMonth ${i}.`);if(n&&u.date.getMonth()>n.getMonth())throw new Error(`Preset ${u.label} is after toMonth ${n}.`);if(o&&u.date.getDate()<o.getDate())throw new Error(`Preset ${u.label} is before fromDay ${o}.`);if(l&&u.date.getDate()>l.getDate())throw new Error(`Preset ${u.label} is after toDay ${I.format(l,"MMM dd, yyyy")}.`)}if("dateRange"in u){const j=(p=u.dateRange.from)==null?void 0:p.getFullYear(),v=(g=u.dateRange.to)==null?void 0:g.getFullYear();if(j&&s&&j<s)throw new Error(`Preset ${u.label}'s 'from' is before fromYear ${c}.`);if(v&&r&&v>r)throw new Error(`Preset ${u.label}'s 'to' is after toYear ${m}.`);if(i){const k=(h=u.dateRange.from)==null?void 0:h.getMonth();if(k&&k<i.getMonth())throw new Error(`Preset ${u.label}'s 'from' is before fromMonth ${I.format(i,"MMM, yyyy")}.`)}if(n){const k=(f=u.dateRange.to)==null?void 0:f.getMonth();if(k&&k>n.getMonth())throw new Error(`Preset ${u.label}'s 'to' is after toMonth ${I.format(n,"MMM, yyyy")}.`)}if(o){const k=(b=u.dateRange.from)==null?void 0:b.getDate();if(k&&k<o.getDate())throw new Error(`Preset ${u.dateRange.from}'s 'from' is before fromDay ${I.format(o,"MMM dd, yyyy")}.`)}if(l){const k=(y=u.dateRange.to)==null?void 0:y.getDate();if(k&&k>l.getDate())throw new Error(`Preset ${u.label}'s 'to' is after toDay ${I.format(l,"MMM dd, yyyy")}.`)}}})}},vn=({presets:a,...t})=>(a&&Sc(a,t),e.jsx(Cc,{presets:a,...t}));vn.displayName="DateRangePicker";const zc=new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:1}),Ic={bank_transfer:"Bank transfer",blik:"BLIK",card:"Card",cash_on_delivery:"Cash on delivery",paypal:"PayPal"},Ec={delivery:"Delivery",pickup:"Pickup"},Xa=["#0f766e","#fb923c"],Ya=a=>typeof a=="number"?a:typeof a=="string"?Number(a):Array.isArray(a)&&a.length>0?Number(a[0]):0;function Dc(){const{client:a}=M(),t=H(),r=x.useMemo(()=>new Date,[]),[s,i]=x.useState({from:I.subDays(r,29),to:r}),n=x.useMemo(()=>{const y=(s==null?void 0:s.from)??I.subDays(r,29),j=(s==null?void 0:s.to)??(s==null?void 0:s.from)??r;return{from:I.startOfDay(y),to:I.endOfDay(j)}},[s,r]),{data:o,error:l,isError:c,isLoading:m,isRefetching:u,refetch:p}=A.useQuery({queryKey:["dashboard-overview",t,n.from.toISOString(),n.to.toISOString()],queryFn:async()=>{const{body:y,status:j}=await a.analytics.getOverview({params:{organizationId:t},query:{from:n.from.toISOString(),to:n.to.toISOString()}});if(j!==200||!y)throw new Error("Failed to fetch dashboard overview");return y},placeholderData:A.keepPreviousData}),g=(o==null?void 0:o.summary.currency)??"USD",h=((o==null?void 0:o.paymentMethods)??[]).map(y=>({...y,label:Ic[y.method]??y.method})),f=((o==null?void 0:o.fulfilmentMethods)??[]).map(y=>({...y,label:Ec[y.method]??y.method})),b=f.reduce((y,j)=>y+j.count,0);return e.jsxs("section",{"aria-labelledby":"dashboard-overview",children:[e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-end lg:justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold text-gray-900 sm:text-2xl dark:text-gray-50",children:"Overview"}),e.jsx("p",{className:"mt-1 text-sm text-gray-600 dark:text-gray-400",children:"Live store performance across orders, reservations, and payment behaviour."})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[u?e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Updating…"}):null,e.jsx(vn,{value:s,onChange:i,className:"w-full sm:w-fit",toDate:r,align:"end"})]})]}),c&&!o?e.jsx(Be,{className:"mt-8 border-red-200 dark:border-red-950",children:e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-50",children:"Dashboard data unavailable"}),e.jsx("p",{className:"mt-1 text-sm text-gray-600 dark:text-gray-400",children:l instanceof Error?l.message:"We could not load the dashboard metrics for this range."})]}),e.jsxs(D,{onClick:()=>p(),className:"gap-2",children:[e.jsx(P.RiRefreshLine,{className:"size-4","aria-hidden":"true"}),"Retry"]})]})}):null,e.jsx("div",{className:"mt-8 grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-4",children:m&&!o?Array.from({length:4}).map((y,j)=>e.jsx(Ta,{className:"h-[148px]"},j)):o?e.jsxs(e.Fragment,{children:[e.jsx(et,{icon:P.RiMoneyDollarCircleLine,title:"Paid sales",value:xe.currency(o.summary.totalSales,g),description:"Successful payments in the selected range"}),e.jsx(et,{icon:P.RiShoppingBag3Line,title:"Paid orders",value:xe.unit(o.summary.paidOrders),description:`Average order value ${xe.currency(o.summary.averageOrderValue,g)}`}),e.jsx(et,{icon:P.RiCalendarCheckLine,title:"Reservations",value:xe.unit(o.summary.reservations),description:"Scheduled reservations in the selected range"}),e.jsx(et,{icon:P.RiGroupLine,title:"Reserved guests",value:xe.unit(o.summary.guests),description:"Total covers booked from reservations"})]}):null}),e.jsx("div",{className:"mt-4 grid grid-cols-1 gap-4 xl:grid-cols-2",children:m&&!o?e.jsxs(e.Fragment,{children:[e.jsx(Ta,{className:"h-[360px]"}),e.jsx(Ta,{className:"h-[360px]"})]}):o?e.jsxs(e.Fragment,{children:[e.jsx(at,{title:"Paid sales by day",value:xe.currency(o.summary.totalSales,g),description:"Gross paid revenue recognised on each order day.",children:e.jsx(ae.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ae.AreaChart,{data:o.salesByDay,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"salesGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"#0f766e",stopOpacity:.28}),e.jsx("stop",{offset:"95%",stopColor:"#0f766e",stopOpacity:.02})]})}),e.jsx(ae.CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb",vertical:!1}),e.jsx(ae.XAxis,{dataKey:"label",axisLine:!1,tickLine:!1,tick:{fill:"#6b7280",fontSize:12}}),e.jsx(ae.YAxis,{axisLine:!1,tickLine:!1,width:48,tickFormatter:y=>zc.format(y),tick:{fill:"#6b7280",fontSize:12}}),e.jsx(ae.Tooltip,{formatter:(y,j)=>{const v=Ya(y);return[String(j)==="totalSales"?xe.currency(v,g):xe.unit(v),String(j)==="totalSales"?"Sales":"Paid orders"]},contentStyle:tt,labelStyle:rt}),e.jsx(ae.Area,{type:"monotone",dataKey:"totalSales",stroke:"#0f766e",strokeWidth:2.5,fill:"url(#salesGradient)",name:"totalSales"})]})})}),e.jsx(at,{title:"Reservations per day",value:xe.unit(o.summary.reservations),description:"Bookings are grouped by reservation date, not submission time.",children:e.jsx(ae.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ae.BarChart,{data:o.reservationsByDay,children:[e.jsx(ae.CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb",vertical:!1}),e.jsx(ae.XAxis,{dataKey:"label",axisLine:!1,tickLine:!1,tick:{fill:"#6b7280",fontSize:12}}),e.jsx(ae.YAxis,{allowDecimals:!1,axisLine:!1,tickLine:!1,width:36,tick:{fill:"#6b7280",fontSize:12}}),e.jsx(ae.Tooltip,{formatter:(y,j)=>[xe.unit(Ya(y)),String(j)==="guests"?"Guests":"Reservations"],contentStyle:tt,labelStyle:rt}),e.jsx(ae.Bar,{dataKey:"reservations",name:"reservations",fill:"#fb923c",radius:[8,8,0,0]})]})})})]}):null}),e.jsx("div",{className:"mt-4 grid grid-cols-1 gap-4 xl:grid-cols-2",children:m&&!o?e.jsxs(e.Fragment,{children:[e.jsx(Ta,{className:"h-[320px]"}),e.jsx(Ta,{className:"h-[320px]"})]}):o?e.jsxs(e.Fragment,{children:[e.jsx(at,{title:"Payment methods",value:xe.unit(h.reduce((y,j)=>y+j.count,0)),description:"Successful orders grouped by how guests paid.",children:h.length>0?e.jsx(ae.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ae.BarChart,{data:h,layout:"vertical",margin:{left:12,right:12},children:[e.jsx(ae.CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb",horizontal:!1}),e.jsx(ae.XAxis,{type:"number",allowDecimals:!1,axisLine:!1,tickLine:!1,tick:{fill:"#6b7280",fontSize:12}}),e.jsx(ae.YAxis,{dataKey:"label",type:"category",axisLine:!1,tickLine:!1,width:110,tick:{fill:"#374151",fontSize:12}}),e.jsx(ae.Tooltip,{formatter:(y,j,v)=>{const k=Ya(y),C=v&&typeof v=="object"&&"payload"in v?v.payload:{totalSales:0};return String(j)==="count"?[xe.unit(k),"Orders"]:[xe.currency(C.totalSales,g),"Sales"]},contentStyle:tt,labelStyle:rt}),e.jsx(ae.Bar,{dataKey:"count",name:"count",fill:"#2563eb",radius:[0,8,8,0]})]})}):e.jsx(ys,{message:"No paid orders in the selected range."})}),e.jsx(at,{title:"Fulfilment mix",value:xe.unit(b),description:"Non-cancelled orders split by delivery and pickup.",children:b>0?e.jsxs("div",{className:"grid h-full grid-cols-1 gap-4 md:grid-cols-[1.2fr_0.8fr]",children:[e.jsx(ae.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(ae.PieChart,{children:[e.jsx(ae.Pie,{data:f,dataKey:"count",nameKey:"label",innerRadius:68,outerRadius:100,paddingAngle:4,children:f.map((y,j)=>e.jsx(ae.Cell,{fill:Xa[j%Xa.length]},y.method))}),e.jsx(ae.Tooltip,{formatter:(y,j,v)=>{const k=Ya(y),C=v&&typeof v=="object"&&"payload"in v?v.payload:{label:"Orders"};return[`${xe.unit(k)} orders`,C.label]},contentStyle:tt,labelStyle:rt})]})}),e.jsx("div",{className:"flex flex-col justify-center gap-3",children:f.map((y,j)=>e.jsxs("div",{className:"rounded-lg border border-gray-200 p-4 dark:border-gray-800",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"size-2.5 rounded-full",style:{backgroundColor:Xa[j%Xa.length]}}),e.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-gray-50",children:y.label})]}),e.jsxs("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:[Math.round(y.count/b*100),"%"]})]}),e.jsx("div",{className:"mt-2 text-lg font-semibold text-gray-900 dark:text-gray-50",children:xe.unit(y.count)}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:xe.currency(y.totalSales,g)})]},y.method))})]}):e.jsx(ys,{message:"No orders in the selected range."})})]}):null})]})}function et({description:a,icon:t,title:r,value:s}){return e.jsx(Be,{className:"overflow-hidden",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-600 dark:text-gray-400",children:r}),e.jsx("p",{className:"mt-3 text-3xl font-bold tracking-tight text-gray-900 dark:text-gray-50 font-red-hat-display",children:s}),e.jsx("p",{className:"mt-2 max-w-xs text-sm text-gray-500 dark:text-gray-400",children:a})]}),e.jsx("div",{className:"rounded-full bg-gray-100 p-3 text-gray-700 dark:bg-gray-900 dark:text-gray-200",children:e.jsx(t,{className:"size-5","aria-hidden":"true"})})]})})}function at({children:a,description:t,title:r,value:s}){return e.jsxs(Be,{className:"flex min-h-[320px] flex-col",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-50",children:r}),e.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:t})]}),e.jsx("div",{className:"text-right",children:e.jsx("p",{className:"text-2xl font-bold tracking-tight text-gray-900 dark:text-gray-50 font-red-hat-display",children:s})})]}),e.jsx("div",{className:"mt-6 min-h-[220px] flex-1",children:a})]})}function Ta({className:a}){return e.jsx(Be,{className:$("animate-pulse",a),children:e.jsx("div",{className:"h-full rounded-xl bg-gray-100 dark:bg-gray-900"})})}function ys({message:a}){return e.jsx("div",{className:"flex h-full items-center justify-center rounded-xl border border-dashed border-gray-200 bg-gray-50 text-sm text-gray-500 dark:border-gray-800 dark:bg-gray-950 dark:text-gray-400",children:a})}const tt={border:"1px solid #e5e7eb",borderRadius:"12px",boxShadow:"0 10px 30px rgba(15, 23, 42, 0.08)",backgroundColor:"#ffffff"},rt={color:"#111827",fontWeight:600},wn=(a,t,r)=>{if(a==null)return r;const s=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split(".").filter(Boolean);let i=a;for(let n=0;n<s.length;n++){const o=s[n];if(i==null||!(o in i))return r;i=i[o]}return i===void 0?r:i},bs=[{continent:"America",items:[{value:"US",label:"United States",flag:"🇺🇸"},{value:"CA",label:"Canada",flag:"🇨🇦"},{value:"MX",label:"Mexico",flag:"🇲🇽"},{value:"BR",label:"Brazil",flag:"🇧🇷"},{value:"AR",label:"Argentina",flag:"🇦🇷"},{value:"CO",label:"Colombia",flag:"🇨🇴"},{value:"CL",label:"Chile",flag:"🇨🇱"},{value:"PE",label:"Peru",flag:"🇵🇪"}]},{continent:"Europe",items:[{value:"GB",label:"United Kingdom",flag:"🇬🇧"},{value:"FR",label:"France",flag:"🇫🇷"},{value:"DE",label:"Germany",flag:"🇩🇪"},{value:"PL",label:"Poland",flag:"🇵🇱"},{value:"IT",label:"Italy",flag:"🇮🇹"},{value:"ES",label:"Spain",flag:"🇪🇸"},{value:"NL",label:"Netherlands",flag:"🇳🇱"},{value:"PT",label:"Portugal",flag:"🇵🇹"},{value:"SE",label:"Sweden",flag:"🇸🇪"},{value:"NO",label:"Norway",flag:"🇳🇴"},{value:"DK",label:"Denmark",flag:"🇩🇰"},{value:"FI",label:"Finland",flag:"🇫🇮"},{value:"CH",label:"Switzerland",flag:"🇨🇭"},{value:"IE",label:"Ireland",flag:"🇮🇪"},{value:"BE",label:"Belgium",flag:"🇧🇪"},{value:"AT",label:"Austria",flag:"🇦🇹"},{value:"GR",label:"Greece",flag:"🇬🇷"}]},{continent:"Asia",items:[{value:"CN",label:"China",flag:"🇨🇳"},{value:"JP",label:"Japan",flag:"🇯🇵"},{value:"IN",label:"India",flag:"🇮🇳"},{value:"KR",label:"South Korea",flag:"🇰🇷"},{value:"SG",label:"Singapore",flag:"🇸🇬"},{value:"MY",label:"Malaysia",flag:"🇲🇾"},{value:"ID",label:"Indonesia",flag:"🇮🇩"},{value:"TH",label:"Thailand",flag:"🇹🇭"},{value:"VN",label:"Vietnam",flag:"🇻🇳"},{value:"AE",label:"United Arab Emirates",flag:"🇦🇪"},{value:"SA",label:"Saudi Arabia",flag:"🇸🇦"}]},{continent:"Oceania",items:[{value:"AU",label:"Australia",flag:"🇦🇺"},{value:"NZ",label:"New Zealand",flag:"🇳🇿"},{value:"FJ",label:"Fiji",flag:"🇫🇯"},{value:"PG",label:"Papua New Guinea",flag:"🇵🇬"}]},{continent:"Africa",items:[{value:"ZA",label:"South Africa",flag:"🇿🇦"},{value:"NG",label:"Nigeria",flag:"🇳🇬"},{value:"MA",label:"Morocco",flag:"🇲🇦"},{value:"EG",label:"Egypt",flag:"🇪🇬"},{value:"KE",label:"Kenya",flag:"🇰🇪"},{value:"GH",label:"Ghana",flag:"🇬🇭"},{value:"ET",label:"Ethiopia",flag:"🇪🇹"}]}],Cr=z.forwardRef(({className:a,...t},r)=>e.jsx(G.Command,{ref:r,className:w("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",a),...t}));Cr.displayName=G.Command.displayName;const Sr=z.forwardRef(({className:a,...t},r)=>e.jsxs("div",{className:"flex items-center border-b pl-3","cmdk-input-wrapper":"",children:[e.jsx(N.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(G.Command.Input,{ref:r,className:w("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",a),...t})]}));Sr.displayName=G.Command.Input.displayName;const zr=z.forwardRef(({className:a,...t},r)=>e.jsx(G.Command.List,{ref:r,className:w("max-h-[300px] overflow-y-auto overflow-x-hidden",a),...t}));zr.displayName=G.Command.List.displayName;const Ir=z.forwardRef((a,t)=>e.jsx(G.Command.Empty,{ref:t,className:"py-6 text-center text-sm",...a}));Ir.displayName=G.Command.Empty.displayName;const Er=z.forwardRef(({className:a,...t},r)=>e.jsx(G.Command.Group,{ref:r,className:w("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",a),...t}));Er.displayName=G.Command.Group.displayName;const Rc=z.forwardRef(({className:a,...t},r)=>e.jsx(G.Command.Separator,{ref:r,className:w("-mx-1 h-px bg-border",a),...t}));Rc.displayName=G.Command.Separator.displayName;const Dr=z.forwardRef(({className:a,...t},r)=>e.jsx(G.Command.Item,{ref:r,className:w("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-hidden data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",a),...t}));Dr.displayName=G.Command.Item.displayName;const Rr=a=>e.jsx(ie.Root,{...a});Rr.displayName="Popover";const Fr=z.forwardRef((a,t)=>e.jsx(ie.Trigger,{ref:t,...a}));Fr.displayName="PopoverTrigger";const Fc=z.forwardRef((a,t)=>e.jsx(ie.Anchor,{ref:t,...a}));Fc.displayName="PopoverAnchor";const Mc=z.forwardRef((a,t)=>e.jsx(ie.Close,{ref:t,...a}));Mc.displayName="PopoverClose";const Mr=z.forwardRef(({className:a,sideOffset:t=10,side:r="bottom",align:s="center",collisionPadding:i,...n},o)=>e.jsx(ie.Portal,{children:e.jsx(ie.Content,{ref:o,sideOffset:t,side:r,align:s,collisionPadding:i,avoidCollisions:!0,className:$("max-h-[var(--radix-popper-available-height)] min-w-60 overflow-hidden rounded-md border p-2.5 text-sm shadow-md","border-gray-200 dark:border-gray-800","text-gray-900 dark:text-gray-50","bg-white dark:bg-gray-950","will-change-[transform,opacity]","data-[state=closed]:animate-hide","data-[state=open]:data-[side=bottom]:animate-slideDownAndFade data-[state=open]:data-[side=left]:animate-slideLeftAndFade data-[state=open]:data-[side=right]:animate-slideRightAndFade data-[state=open]:data-[side=top]:animate-slideUpAndFade",a),onWheel:l=>{l.stopPropagation(),l.deltaY>0?l.currentTarget.dispatchEvent(new KeyboardEvent("keydown",{key:"ArrowDown"})):l.currentTarget.dispatchEvent(new KeyboardEvent("keydown",{key:"ArrowUp"}))},...n})}));Mr.displayName="PopoverContent";const Pc=({value:a,onChange:t})=>{const r=x.useId(),[s,i]=x.useState(!1),n=bs.map(o=>o.items.find(l=>l.value===a)).filter(Boolean)[0];return e.jsx("div",{className:"mt-2",children:e.jsxs(Rr,{open:s,onOpenChange:i,children:[e.jsx(Fr,{asChild:!0,children:e.jsxs(D,{id:r,role:"combobox","aria-expanded":s,variant:"secondary",className:"w-full justify-between shadow-xs! bg-background px-3 py-2.5 font-normal outline-offset-0 hover:bg-background focus-visible:border-ring focus-visible:outline-[3px] focus-visible:outline-ring/20",children:[a?e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"text-lg leading-none",children:n==null?void 0:n.flag}),e.jsx("span",{className:"truncate",children:n==null?void 0:n.label})]}):e.jsx("span",{className:"text-muted-foreground",children:"Select country"}),e.jsx(N.ChevronDown,{size:16,strokeWidth:2,className:"shrink-0 text-muted-foreground/80","aria-hidden":"true"})]})}),e.jsx(Mr,{className:"w-full min-w-[var(--radix-popper-anchor-width)] border-input -mt-1 z-50",align:"start",children:e.jsxs(Cr,{className:"p-0",children:[e.jsx(Sr,{className:"w-full border-none",style:{boxShadow:"none"},placeholder:"Search country..."}),e.jsxs(zr,{children:[e.jsx(Ir,{children:"No country found."}),bs.map(o=>e.jsx(x.Fragment,{children:e.jsx(Er,{heading:o.continent,children:o.items.map(l=>e.jsxs(Dr,{value:l.label,className:"cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-800",onSelect:()=>{t(l.value??""),i(!1)},children:[e.jsx("span",{className:"text-lg leading-none",children:l.flag})," ",l.label,a===l.value&&e.jsx(N.Check,{size:16,strokeWidth:2,className:"ml-auto"})]},l.value))})},o.continent))]})]})})]})})},Bc=({...a})=>{const t=x.useId();return e.jsx("div",{className:"mt-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(ne,{id:t,type:"email",inputClassName:"peer ps-9",...a}),e.jsx("div",{className:"pointer-events-none absolute inset-y-0 start-0 flex items-center justify-center ps-3 text-muted-foreground/80 peer-disabled:opacity-50",children:e.jsx(N.AtSign,{size:16,strokeWidth:2,"aria-hidden":"true"})})]})})},Tc=a=>{const{client:t}=M(),[r,s]=x.useState(!1),[i,n]=x.useState(0),o=async u=>{const{body:p,status:g}=await t.file.createTemporaryFile({body:{filename:u.name,mimeType:u.type,size:u.size,organizationId:a.organizationId}});if(g!==201)throw new Error("Failed to create temporary file");const h=await Ns.upload(u.name,u,{access:"public",handleUploadUrl:`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/files/token/vercel`,clientPayload:JSON.stringify({fileId:p==null?void 0:p.id}),onUploadProgress(f){n(f.percentage)}});return{id:p.id,filename:u.name,mimeType:u.type,size:u.size,url:h.url}},l=async u=>{var p;if((p=u.target.files)!=null&&p[0]){s(!0);try{const g=await o(u.target.files[0]);if(a.multiple){const h=a.value??[];a.onChange([...h,g])}else a.onChange(g)}catch(g){console.error(g)}finally{s(!1)}}},c=u=>{if(a.multiple){if(!a.value)return a.onChange(void 0);const p=a.value.filter(g=>g.id!==u);a.onChange(p.length?p:void 0)}else a.onChange(void 0)},m=()=>{if(a.value){const u=a.multiple?a.value:[a.value];return e.jsxs("div",{className:"flex",children:[u.map(p=>e.jsx("div",{className:"flex flex-col w-40 h-40 mr-3 transition-all rounded-lg relative animate-fade",children:e.jsxs("div",{className:"relative h-full w-40",children:[e.jsx("button",{className:"absolute w-6 h-6 bg-black flex items-center justify-center rounded-md right-1 top-1",onClick:()=>c(p.id),children:e.jsx(N.XIcon,{className:"w-4 h-4 text-white"})}),e.jsx(Ie,{src:p.url,alt:p.filename,width:160,height:160,className:"w-40 h-40 rounded-md object-cover"})]})},p.id)),a.multiple&&e.jsxs("div",{className:"group flex relative flex-col w-40 h-40 items-center justify-center cursor-pointer border-2 border-gray-200 border-dashed transition-all rounded-lg hover:bg-gray-100 hover:border-gray-300",children:[e.jsx("div",{className:"flex flex-col items-center justify-center",children:r?e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"animate-spin w-4 h-4 fill-current shrink-0 mb-2",viewBox:"0 0 16 16",children:e.jsx("path",{d:"M8 16a7.928 7.928 0 01-3.428-.77l.857-1.807A6.006 6.006 0 0014 8c0-3.309-2.691-6-6-6a6.006 6.006 0 00-5.422 8.572l-1.806.859A7.929 7.929 0 010 8c0-4.411 3.589-8 8-8s8 3.589 8 8-3.589 8-8 8z"})}),e.jsxs("span",{className:"text-sm",children:["Uploading... (",i,"%)"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(N.CloudUpload,{className:"w-12 h-12 text-gray-300 group-hover:text-gray-600 transition-all stroke-1"}),e.jsx("p",{className:"pt-1 text-sm font-medium text-gray-400 group-hover:text-gray-600",children:"Upload an image"})]})}),e.jsx("input",{type:"file",className:"opacity-0 w-full h-full absolute cursor-pointer",onChange:l,accept:"image/png, image/gif, image/jpeg"})]},"upload-placeholder")]})}return e.jsxs("div",{className:"group flex relative flex-col items-center justify-center cursor-pointer w-full h-40 border-2 border-gray-200 border-dashed transition-all rounded-lg hover:bg-gray-100 hover:border-gray-300",children:[e.jsx("div",{className:"flex flex-col items-center justify-center",children:r?e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"animate-spin w-4 h-4 fill-current shrink-0 mb-2",viewBox:"0 0 16 16",children:e.jsx("path",{d:"M8 16a7.928 7.928 0 01-3.428-.77l.857-1.807A6.006 6.006 0 0014 8c0-3.309-2.691-6-6-6a6.006 6.006 0 00-5.422 8.572l-1.806.859A7.929 7.929 0 010 8c0-4.411 3.589-8 8-8s8 3.589 8 8-3.589 8-8 8z"})}),e.jsxs("span",{className:"text-sm",children:["Uploading... (",i,"%)"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(N.CloudUpload,{className:"w-12 h-12 text-gray-300 group-hover:text-gray-600 transition-all stroke-1"}),e.jsx("p",{className:"pt-1 text-sm font-medium text-gray-400 group-hover:text-gray-600",children:"Upload an image"})]})}),e.jsx("input",{type:"file",className:"opacity-0 w-full h-full absolute cursor-pointer",onChange:l,accept:"image/png, image/gif, image/jpeg"})]},"upload-placeholder")};return e.jsx("div",{className:"flex items-center w-full mt-2",children:m()})},kn=x.forwardRef(({...a},t)=>e.jsx(ne,{...a,inputClassName:"border-l-0 rounded-l-none",ref:t,className:""}));kn.displayName="PhoneInput";const Qc=({disabled:a,value:t,onChange:r,options:s})=>{const i=n=>{r(n.target.value)};return e.jsxs("div",{className:"relative inline-flex items-center self-stretch rounded-s-lg border border-gray-200 dark:border-gray-800 bg-background py-2 pe-2 ps-3 text-muted-foreground transition-shadow focus-within:z-10 focus-within:border-ring focus-within:outline-hidden focus-within:ring-[3px] focus-within:ring-ring/20 hover:bg-accent hover:text-foreground has-disabled:pointer-events-none has-disabled:opacity-50",children:[e.jsxs("div",{className:"inline-flex items-center gap-1","aria-hidden":"true",children:[e.jsx(Nn,{country:t,countryName:t,"aria-hidden":"true"}),e.jsx("span",{className:"text-muted-foreground/80",children:e.jsx(N.ChevronDown,{size:16,strokeWidth:2,"aria-hidden":"true"})})]}),e.jsxs("select",{disabled:a,value:t,onChange:i,className:"absolute inset-0 text-sm opacity-0","aria-label":"Select country",children:[e.jsx("option",{value:"",children:"Select a country"},"default"),s.filter(n=>n.value).map((n,o)=>e.jsxs("option",{value:n.value,children:[n.label," ",n.value&&`+${Nt.getCountryCallingCode(n.value)}`]},n.value??`empty-${o}`))]})]})},Nn=({country:a,countryName:t})=>{const r=zs[a];return e.jsx("span",{className:"w-5 overflow-hidden rounded-sm",children:r?e.jsx(r,{title:t}):e.jsx(N.Phone,{size:16,"aria-hidden":"true"})})},Oc=({value:a,onChange:t,onBlur:r})=>{const s=x.useId();return e.jsx("div",{className:"mt-2",children:e.jsx(Nt.default,{id:s,className:"flex rounded-lg shadow-xs shadow-black/5",international:!0,flagComponent:Nn,countrySelectComponent:Qc,inputComponent:kn,placeholder:"Enter phone number",value:a,onChange:i=>t(i??""),onBlur:r})})},Lc=({options:a,value:t,onChange:r,multiple:s=!1,placeholder:i})=>{var u;const n=x.useId(),[o,l]=x.useState(!1),c=p=>{if(s){let g;Array.isArray(t)&&t.includes(p)?g=t.filter(h=>h!==p):g=Array.isArray(t)?[...t,p]:[p],r(g)}else r(p),l(!1)},m=p=>{if(s&&Array.isArray(t)){const g=t.filter(h=>h!==p);r(g)}};return e.jsx("div",{className:"mt-2",children:e.jsxs(Rr,{open:o,onOpenChange:l,children:[e.jsx(Fr,{asChild:!0,children:e.jsxs(D,{id:n,role:"combobox","aria-expanded":o,variant:"secondary",className:"w-full justify-between shadow-xs! bg-background px-2! py-1 min-h-[41.6px] font-normal outline-offset-0 hover:bg-background focus-visible:border-ring focus-visible:outline-[3px] focus-visible:outline-ring/20",children:[(t==null?void 0:t.length)>0?e.jsx("div",{className:"flex flex-wrap gap-2",children:Array.isArray(t)?t.map(p=>{const g=a.find(h=>h.value===p);return g?e.jsxs("span",{className:"animate-fadeIn relative inline-flex cursor-default items-center rounded-md border border-border bg-background px-2 py-1 text-xs font-medium text-secondary-foreground transition-all hover:bg-background disabled:cursor-not-allowed disabled:opacity-50",children:[g.label,e.jsx(N.X,{size:12,onClick:h=>{h.preventDefault(),m(p)},className:"cursor-pointer ml-1"})]},p):null}):e.jsx("span",{className:"px-1 text-sm",children:(u=a.find(p=>p.value===t))==null?void 0:u.label})}):e.jsx("span",{className:"px-1 text-sm text-gray-400",children:i||(s?"Select options":"Select an option")}),e.jsx(N.ChevronDown,{size:16,strokeWidth:2,className:"shrink-0 text-muted-foreground/80","aria-hidden":"true"})]})}),e.jsx(Mr,{className:"w-full min-w-[var(--radix-popper-anchor-width)] border-input -mt-1 z-50 p-0",align:"start",children:e.jsxs(Cr,{className:"p-0",children:[e.jsx(Sr,{className:"w-full border-none pl-0",style:{boxShadow:"none"},placeholder:"Search..."}),e.jsxs(zr,{children:[e.jsx(Ir,{children:"No options found."}),e.jsx(Er,{children:a.map(p=>e.jsxs(Dr,{value:p.label,className:"cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-800",onSelect:()=>c(p.value),children:[p.label,(s?t.includes(p.value):t===p.value)&&e.jsx(N.Check,{size:16,strokeWidth:2,className:"ml-auto"})]},p.value))})]})]})})]})})},Jc=Le.tv({slots:{root:["group relative isolate inline-flex shrink-0 cursor-pointer items-center rounded-full p-0.5 shadow-inner outline-hidden ring-1 ring-inset transition-all","bg-gray-200 dark:bg-gray-950","ring-black/5 dark:ring-gray-800","data-[state=checked]:bg-blue-600 dark:data-[state=checked]:bg-blue-600","data-disabled:cursor-default","data-disabled:data-[state=checked]:bg-blue-200","data-disabled:data-[state=checked]:ring-gray-300","dark:data-disabled:data-[state=checked]:ring-gray-900","dark:data-disabled:data-[state=checked]:bg-blue-900","data-disabled:data-[state=unchecked]:ring-gray-300","data-disabled:data-[state=unchecked]:bg-gray-100","dark:data-disabled:data-[state=unchecked]:ring-gray-700","dark:data-disabled:data-[state=unchecked]:bg-gray-800",Ae],thumb:["pointer-events-none relative inline-block transform appearance-none rounded-full border-none shadow-lg outline-hidden transition-all duration-150 ease-in-out focus:border-none focus:outline-hidden focus:outline-transparent","bg-white dark:bg-gray-50","group-data-disabled:shadow-none","group-data-disabled:bg-gray-50 dark:group-data-disabled:bg-gray-500"]},variants:{size:{default:{root:"h-7 w-14",thumb:"h-4 w-4 data-[state=checked]:translate-x-7 data-[state=unchecked]:translate-x-0"},small:{root:"h-4 w-7",thumb:"h-3 w-3 data-[state=checked]:translate-x-3 data-[state=unchecked]:translate-x-0"}}},defaultVariants:{size:"default"}}),An=x.forwardRef(({className:a,size:t,...r},s)=>{const{root:i,thumb:n}=Jc({size:t});return e.jsx(ct.Root,{ref:s,className:w(i(),a),...r,children:e.jsx(ct.Thumb,{className:w(n())})})});An.displayName="Switch";const Vc=({name:a,type:t,placeholder:r,multiple:s,options:i,prefix:n})=>{const{watch:o,register:l,setFocus:c,setValue:m}=U.useFormContext();switch(t){case"email":return e.jsx(Bc,{...l(a),placeholder:r});case"file":return e.jsx(Tc,{value:o(a),multiple:s,onChange:u=>m(a,u)});case"phone-number":return e.jsx(Oc,{value:o("phone"),onChange:u=>m("phone",u),onBlur:()=>c("phone")});case"country":return e.jsx(Pc,{value:o(a),onChange:u=>m(a,u)});case"select":{const u=s?o(a)||[]:o(a)||"";if(!i)throw new Error("Options are required for select input");return e.jsx(Lc,{options:i,value:u,onChange:p=>m(a,p),placeholder:r,multiple:s})}case"switch":return e.jsx(An,{size:"default",className:"mr-2",checked:o(a),onCheckedChange:u=>m(a,u)});case"time":return e.jsx(gr,{value:o(a),onChange:u=>m(a,u.target.value),className:"mt-2"});default:return e.jsx(ne,{...l(a),type:t,rows:t==="textarea"?4:void 0,placeholder:r,className:"mt-2",prefix:n})}},qc=(a,t)=>!a||typeof a!="object"?void 0:t?t.replace(/\[/g,".").replace(/\]/g,"").split(".").filter(Boolean).reduce((r,s)=>{if(r!=null)return r[s]},a):a,Pe=({type:a="text",name:t,label:r,className:s,locale:i,placeholder:n,multiple:o,options:l,localizable:c,prefix:m})=>{const{errors:u}=U.useFormState(),p=qc(u,t);return e.jsxs("div",{className:w("w-full",{"flex items-center flex-row-reverse justify-end":a==="switch"},s),children:[typeof r=="string"&&e.jsxs(le,{htmlFor:t,className:"font-medium flex items-center justify-between",children:[e.jsxs("span",{className:"flex items-center",children:[r,c&&e.jsx(N.LanguagesIcon,{className:"w-4 h-4 ml-1 text-gray-500"})]}),i&&c&&e.jsxs("span",{className:"flex items-center text-xs text-gray-500 ml-1 bg-gray-100 px-1 py-0.5 rounded",children:[St.get(i)," (",i,")"]})]}),e.jsx(Vc,{type:a,name:t,placeholder:n,options:l,multiple:o,prefix:m}),(p==null?void 0:p.message)&&e.jsx("p",{className:"mt-1 text-sm text-red-500",children:p.message})]})},Hc=({form:a,config:t,columns:r=2})=>{var c;const{errors:s}=U.useFormState(),i=wn(s,t.name),{fields:n,append:o,remove:l}=U.useFieldArray({control:a.control,name:t.name});return(c=t.fields)!=null&&c.length?e.jsx(e.Fragment,{children:e.jsxs("div",{className:"w-full col-span-full",children:[t.label&&e.jsx("h4",{className:"text-2xl flex items-center justify-between font-semibold",children:t.label}),t.description&&e.jsx("p",{className:"text-sm text-gray-500",children:t.description}),n.map((m,u)=>{var p;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:w("grid gap-5 w-full border-l-[8px] border-blue-500 pl-5 py-3 mt-6",{"grid-cols-1":r===1,"grid-cols-2":r===2,"grid-cols-3":r===3,"grid-cols-4":r===4}),children:(p=t.fields)==null?void 0:p.map(({name:g,label:h,type:f,colspan:b,localizable:y,multiple:j,options:v,placeholder:k,prefix:C})=>e.jsx(Pe,{name:`${t.name}[${u}].${g}`,label:h,type:f??"text",localizable:y,className:w({"col-span-1":b===1,"col-span-2":b===2,"col-span-3":b===3,"col-span-4":b===4}),placeholder:k,multiple:j,options:v,prefix:C},t.name+g))},m.id),u<n.length-1&&e.jsx(Z,{})]})}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsxs("button",{type:"button",className:"relative my-2 inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-md border px-2 py-1 text-center text-sm font-medium shadow-xs transition-all duration-100 ease-in-out disabled:pointer-events-none disabled:shadow-none outline outline-offset-2 outline-0 focus-visible:outline-2 outline-blue-500 dark:outline-blue-500 border-gray-300 dark:border-gray-800 text-gray-900 dark:text-gray-50 bg-white dark:bg-gray-950 hover:bg-gray-50 dark:hover:bg-gray-900/60 disabled:text-gray-400 dark:disabled:text-gray-600",onClick:()=>o({}),children:[e.jsx(N.PlusCircleIcon,{className:"w-4 h-4 text-blue-500"}),"Add New"]}),n.length>1&&e.jsxs("button",{type:"button",className:"relative my-2 inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-md border px-2 py-1 text-center text-sm font-medium shadow-xs transition-all duration-100 ease-in-out disabled:pointer-events-none disabled:shadow-none outline outline-offset-2 outline-0 focus-visible:outline-2 outline-blue-500 dark:outline-blue-500 border-gray-300 dark:border-gray-800 text-gray-900 dark:text-gray-50 bg-white dark:bg-gray-950 hover:bg-gray-50 dark:hover:bg-gray-900/60 disabled:text-gray-400 dark:disabled:text-gray-600",onClick:()=>l(n.length-1),children:[e.jsx(N.XCircleIcon,{className:"w-4 h-4 text-red-500"}),"Remove"]})]}),(i==null?void 0:i.message)&&e.jsx("p",{className:"mt-1 text-sm text-red-500",children:i.message})]})}):null},Uc=({config:a,columns:t=2})=>{var i;const{errors:r}=U.useFormState(),s=wn(r,a.name);return(i=a.fields)!=null&&i.length?e.jsxs("div",{className:"w-full col-span-full",children:[a.label&&e.jsx("h4",{className:"text-2xl font-semibold mb-2",children:a.label}),a.description&&e.jsx("p",{className:"text-sm text-gray-500 mb-3",children:a.description}),e.jsx("div",{className:w("grid gap-5",{"grid-cols-1":t===1,"grid-cols-2":t===2,"grid-cols-3":t===3,"grid-cols-4":t===4}),children:a.fields.map(({name:n,label:o,type:l,colspan:c,localizable:m,multiple:u,options:p,placeholder:g,prefix:h})=>e.jsx(Pe,{name:`${a.name}.${n}`,label:o,type:l??"text",localizable:m,className:w({"col-span-1":c===1,"col-span-2":c===2,"col-span-3":c===3,"col-span-4":c===4}),placeholder:g,multiple:u,options:p,prefix:h},`${a.name}.${n}`))}),(s==null?void 0:s.message)&&e.jsx("p",{className:"mt-1 text-sm text-red-500",children:s.message})]}):null};function Zc(a,t){const{asChild:r,children:s}=a;if(!r)return typeof t=="function"?t(s):t;const i=x.Children.only(s);return x.cloneElement(i,{children:typeof t=="function"?t(i.props.children):t})}const Pr=x.forwardRef(({className:a,children:t,...r},s)=>e.jsx(mt.Root,{ref:s,...r,asChild:!1,children:e.jsx(mt.List,{className:w("flex items-center justify-start whitespace-nowrap border-b [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","border-gray-200 dark:border-gray-800",a),children:t})}));Pr.displayName="TabNavigation";const Br=x.forwardRef(({asChild:a,disabled:t,className:r,children:s,...i},n)=>e.jsx(mt.Item,{className:"flex","aria-disabled":t,children:e.jsx(mt.Link,{"aria-disabled":t,className:w("group relative flex shrink-0 select-none items-center justify-center",t?"pointer-events-none":""),ref:n,onSelect:()=>{},asChild:a,...i,children:Zc({asChild:a,children:s},o=>e.jsx("span",{className:w("-mb-px flex items-center justify-center whitespace-nowrap border-b-2 border-transparent px-3 pb-2 text-sm font-medium transition-all","text-gray-500 dark:text-gray-500","group-hover:text-gray-700 dark:group-hover:text-gray-400","group-hover:border-gray-300 dark:group-hover:border-gray-400","group-data-active:border-blue-600 group-data-active:text-blue-600","dark:group-data-active:border-blue-500 dark:group-data-active:text-blue-500",t?"pointer-events-none text-gray-300 dark:text-gray-700":"",Ae,r),children:o}))})}));Br.displayName="TabNavigationLink";const Te=({form:a,okText:t,config:r,loading:s,onCancel:i,cancelText:n,columns:o=2,onSubmit:l})=>{const c=a.watch("translations"),{organization:m,defaultLocale:u,supportedLocales:p}=je(),[g,h]=x.useState(),f=x.useMemo(()=>r.some(y=>y.localizable),[r]);x.useEffect(()=>{m.data&&h(u)},[m.data,u,a,p,c]),x.useEffect(()=>{a.formState.errors.translations&&h(u)},[u,a.formState.errors.translations]);const b=e.jsxs("div",{className:$("grid gap-5 w-full",{"grid-cols-1":o===1,"grid-cols-2":o===2,"grid-cols-3":o===3,"grid-cols-4":o===4}),children:[f&&e.jsx("div",{className:"col-span-full",children:e.jsx(Pr,{className:"col-span-full mb-3",children:p.map(y=>{const j=y===u;return e.jsx(Br,{active:y===g,onClick:()=>h(y),className:"cursor-pointer",children:e.jsxs(e.Fragment,{children:[St.get(y)," ",j&&"(Default)"]})},y)})})}),r.map(y=>{const{name:j,label:v,type:k,colspan:C,localizable:F,multiple:T,options:O,placeholder:R,prefix:S}=y,Q=!F||!g?j:`translations[${p==null?void 0:p.indexOf(g)}].${j}`;return k==="object"?e.jsx(Uc,{config:y},j):k==="array"?e.jsx(Hc,{form:a,config:y},j):e.jsx(Pe,{name:Q,label:v,type:k??"text",localizable:F,className:$({"col-span-1":C===1,"col-span-2":C===2,"col-span-3":C===3,"col-span-4":C===4}),placeholder:R,multiple:T,options:O,locale:g,prefix:S},Q)}),l&&e.jsxs("div",{className:"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2 mt-6 col-span-full border-t pt-7",children:[i&&e.jsx(D,{type:"button",className:"w-full sm:w-fit",variant:"secondary",onClick:i,children:n??"Cancel"}),e.jsx(D,{type:"submit",className:"w-full sm:w-fit",isLoading:s,loadingText:"Saving...",children:t??"Save Data"})]})]});return l?e.jsx(U.FormProvider,{...a,children:e.jsx("form",{onSubmit:a.handleSubmit(y=>l(y)),children:b})}):e.jsx("div",{className:"w-full",children:b})},$c=[{name:"name",label:"Manufacturer Name",type:"text",placeholder:"Acme Inc.",colspan:2},{name:"about",label:"About",type:"textarea",placeholder:"Lorem ipsum dolor sit amet, consectetur adipiscing elit.",colspan:2,localizable:!0},{name:"logo",label:"Logo",type:"file"}],Cn=({initialData:a})=>{const{client:t}=M(),r=E.useRouter(),s=_(),i=H(),{defaultLocale:n,supportedLocales:o}=je(),l=a?El:Il,c=U.useForm({resolver:fe.zodResolver(l),defaultValues:a?{defaultLocale:n,name:a.name,logo:a.logo,translations:a.translations}:{defaultLocale:n,translations:o.map(h=>({locale:h}))}}),m=A.useMutation({mutationFn:async h=>{var y;const f={name:h.name,defaultLocale:h.defaultLocale,translations:h.translations,logoId:(y=h.logo)==null?void 0:y.id},{status:b}=await t.manufacturer.createManufacturer({params:{organizationId:i},body:f});if(b!==201)throw J.error("Failed to create manufacturer. Please try again later."),new Error("Failed to create manufacturer")}}),u=A.useMutation({mutationFn:async h=>{var y;const f={name:h.name,defaultLocale:h.defaultLocale,translations:h.translations,logoId:((y=h.logo)==null?void 0:y.id)||null},{status:b}=await t.manufacturer.updateManufacturer({params:{organizationId:i,id:a.id},body:f});if(b!==200)throw J.error("Failed to update manufacturer. Please try again later."),new Error("Failed to update manufacturer")}}),p=async()=>{J.success("Manufacturer saved successfully"),r.push(s.manufacturers(i)),await oe.invalidateQueries({queryKey:["manufacturers"]})},g=h=>{a?u.mutate(h,{onSuccess:p}):m.mutate(h,{onSuccess:p})};return e.jsx(Te,{form:c,config:$c,onSubmit:g,loading:m.isPending||u.isPending,cancelText:"Go back",okText:a?"Update Manufacturer":"Create Manufacturer"})};function _c(){return e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-gray-900 sm:text-xl dark:text-gray-50",children:"Create Manufacturer"}),e.jsx(Z,{}),e.jsx("div",{className:"pt-6",children:e.jsx("div",{className:"space-y-10",children:e.jsx("section",{"aria-labelledby":"manufacturer-info",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"manufacturer-info",className:"scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Manufacturer Information"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Enter the information about the manufacturer."})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsx(Cn,{})})]})})})})]})}function Wc(){const a=H(),t=ga(),{client:r}=M(),{isLoading:s,data:i}=A.useQuery({queryKey:["manufacturers",a,t],queryFn:async()=>{const{status:n,body:o}=await r.manufacturer.getManufacturer({params:{id:t,organizationId:a}});if(n!==200)throw J.error("Failed to fetch manufacturer. Please refresh or try again later."),new Error("Failed to fetch manufacturer");return o},throwOnError:!0,placeholderData:A.keepPreviousData});return e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-gray-900 sm:text-xl dark:text-gray-50",children:"Edit Manufacturer"}),e.jsx(Z,{}),e.jsx("div",{className:"pt-6",children:e.jsx("div",{className:"space-y-10",children:e.jsx("section",{"aria-labelledby":"manufacturer-info",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"manufacturer-info",className:"scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Manufacturer Information"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Enter the information about the manufacturer."})]}),e.jsx("div",{className:"md:col-span-2",children:s||!i?e.jsx("div",{className:"flex justify-center items-center h-screen mt-5",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(pe,{className:"w-12 h-12"}),e.jsx("p",{className:"text-gray-500 text-sm mt-3",children:"Loading data..."})]})}):e.jsx(Cn,{initialData:i})})]})})})})]})}const Oe=x.forwardRef(({className:a,checked:t,...r},s)=>e.jsx(_r.Root,{ref:s,...r,checked:t,className:w("relative inline-flex size-4 shrink-0 appearance-none items-center justify-center rounded shadow-xs outline-hidden ring-1 ring-inset transition duration-100 enabled:cursor-pointer","text-white dark:text-gray-50","bg-white dark:bg-gray-950","ring-gray-300 dark:ring-gray-800","data-disabled:bg-gray-100 data-disabled:text-gray-400 data-disabled:ring-gray-300","dark:data-disabled:bg-gray-800 dark:data-disabled:text-gray-500 dark:data-disabled:ring-gray-700","enabled:data-[state=checked]:bg-blue-600 enabled:data-[state=checked]:ring-0 enabled:data-[state=checked]:ring-transparent","enabled:data-[state=indeterminate]:bg-blue-600 enabled:data-[state=indeterminate]:ring-0 enabled:data-[state=indeterminate]:ring-transparent",Ae,a),children:e.jsx(_r.Indicator,{asChild:!0,className:"flex size-full items-center justify-center",children:t==="indeterminate"?e.jsx("svg",{"aria-hidden":"true",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("line",{stroke:"currentColor",strokeLinecap:"round",strokeWidth:"2",x1:"4",x2:"12",y1:"8",y2:"8"})}):e.jsx("svg",{"aria-hidden":"true",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M11.2 5.59998L6.79999 9.99998L4.79999 7.99998",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})})})}));Oe.displayName="Checkbox";const sa=be.Root;sa.displayName="DropdownMenu";const ia=be.Trigger;ia.displayName="DropdownMenuTrigger";const Va=be.Group;Va.displayName="DropdownMenuGroup";const Sn=be.Sub;Sn.displayName="DropdownMenuSubMenu";const zn=be.RadioGroup;zn.displayName="DropdownMenuRadioGroup";const In=z.forwardRef(({className:a,children:t,...r},s)=>e.jsxs(be.SubTrigger,{ref:s,className:w("relative flex cursor-default select-none items-center rounded py-1.5 pl-2 pr-1 outline-hidden transition-colors data-[state=checked]:font-semibold sm:text-sm","text-gray-900 dark:text-gray-50","data-disabled:pointer-events-none data-disabled:text-gray-400 data-disabled:hover:bg-none dark:data-disabled:text-gray-600","focus-visible:bg-gray-100 data-[state=open]:bg-gray-100 dark:focus-visible:bg-gray-900 dark:data-[state=open]:bg-gray-900","hover:bg-gray-100 dark:hover:bg-gray-900",a),...r,children:[t,e.jsx(P.RiArrowRightSLine,{className:"ml-auto size-4 shrink-0 text-gray-500","aria-hidden":"true"})]}));In.displayName="DropdownMenuSubMenuTrigger";const En=z.forwardRef(({className:a,collisionPadding:t=8,...r},s)=>e.jsx(be.Portal,{children:e.jsx(be.SubContent,{ref:s,collisionPadding:t,className:w("relative z-50 overflow-hidden rounded-md border p-1 shadow-xl shadow-black/[2.5%]","min-w-32","max-h-[var(--radix-popper-available-height)]","bg-white dark:bg-gray-950","text-gray-900 dark:text-gray-50","border-gray-200 dark:border-gray-800","will-change-[transform,opacity]","data-[state=closed]:animate-hide","data-[side=bottom]:animate-slideDownAndFade data-[side=left]:animate-slideLeftAndFade data-[side=right]:animate-slideRightAndFade data-[side=top]:animate-slideUpAndFade",a),...r})}));En.displayName="DropdownMenuSubMenuContent";const na=z.forwardRef(({className:a,sideOffset:t=8,collisionPadding:r=8,align:s="center",loop:i=!0,...n},o)=>e.jsx(be.Portal,{children:e.jsx(be.Content,{ref:o,className:w("relative z-50 overflow-hidden rounded-md border p-1 shadow-xl shadow-black/[2.5%]","min-w-[calc(var(--radix-dropdown-menu-trigger-width))]","max-h-[var(--radix-popper-available-height)]","bg-white dark:bg-gray-950","text-gray-900 dark:text-gray-50","border-gray-200 dark:border-gray-800","will-change-[transform,opacity]","data-[state=closed]:animate-hide","data-[side=bottom]:animate-slideDownAndFade data-[side=left]:animate-slideLeftAndFade data-[side=right]:animate-slideRightAndFade data-[side=top]:animate-slideUpAndFade",a),sideOffset:t,align:s,collisionPadding:r,loop:i,...n})}));na.displayName="DropdownMenuContent";const ze=z.forwardRef(({className:a,shortcut:t,hint:r,children:s,...i},n)=>e.jsxs(be.Item,{ref:n,className:w("group/DropdownMenuItem relative flex cursor-pointer select-none items-center rounded py-1.5 pl-2 pr-1 outline-hidden transition-colors data-[state=checked]:font-semibold sm:text-sm","text-gray-900 dark:text-gray-50","data-disabled:pointer-events-none data-disabled:text-gray-400 data-disabled:hover:bg-none dark:data-disabled:text-gray-600","focus-visible:bg-gray-100 dark:focus-visible:bg-gray-900","hover:bg-gray-100 dark:hover:bg-gray-900",a),...i,children:[s,r&&e.jsx("span",{className:w("ml-auto pl-2 text-sm text-gray-400 dark:text-gray-600"),children:r}),t&&e.jsx("span",{className:w("ml-auto pl-2 text-sm text-gray-400 dark:text-gray-600"),children:t})]}));ze.displayName="DropdownMenuItem";const Kc=z.forwardRef(({className:a,hint:t,shortcut:r,children:s,checked:i,...n},o)=>e.jsxs(be.CheckboxItem,{ref:o,className:w("relative flex cursor-pointer select-none items-center gap-x-2 rounded py-1.5 pl-8 pr-1 outline-hidden transition-colors data-[state=checked]:font-semibold sm:text-sm","text-gray-900 dark:text-gray-50","data-disabled:pointer-events-none data-disabled:text-gray-400 data-disabled:hover:bg-none dark:data-disabled:text-gray-600","focus-visible:bg-gray-100 dark:focus-visible:bg-gray-900","hover:bg-gray-100 dark:hover:bg-gray-900",a),checked:i,...n,children:[e.jsx("span",{className:"absolute left-2 flex size-4 items-center justify-center",children:e.jsx(be.ItemIndicator,{children:e.jsx(P.RiCheckLine,{"aria-hidden":"true",className:"size-full shrink-0 text-gray-800 dark:text-gray-200"})})}),s,t&&e.jsx("span",{className:w("ml-auto text-sm font-normal text-gray-400 dark:text-gray-600"),children:t}),r&&e.jsx("span",{className:w("ml-auto text-sm font-normal tracking-widest text-gray-400 dark:border-gray-800 dark:text-gray-600"),children:r})]}));Kc.displayName="DropdownMenuCheckboxItem";const lt=z.forwardRef(({className:a,hint:t,shortcut:r,children:s,iconType:i="radio",...n},o)=>e.jsxs(be.RadioItem,{ref:o,className:w("group/DropdownMenuRadioItem relative flex cursor-pointer select-none items-center gap-x-2 rounded py-1.5 pl-8 pr-1 outline-hidden transition-colors data-[state=checked]:font-semibold sm:text-sm","text-gray-900 dark:text-gray-50","data-disabled:pointer-events-none data-disabled:text-gray-400 data-disabled:hover:bg-none dark:data-disabled:text-gray-600","focus-visible:bg-gray-100 dark:focus-visible:bg-gray-900","hover:bg-gray-100 dark:hover:bg-gray-900",a),...n,children:[i==="radio"?e.jsxs("span",{className:"absolute left-2 flex size-4 items-center justify-center",children:[e.jsx(P.RiRadioButtonFill,{"aria-hidden":"true",className:"size-full shrink-0 text-blue-500 group-data-[state=checked]/DropdownMenuRadioItem:flex group-data-[state=unchecked]/DropdownMenuRadioItem:hidden dark:text-blue-500"}),e.jsx(P.RiCheckboxBlankCircleLine,{"aria-hidden":"true",className:"size-full shrink-0 text-gray-300 group-data-[state=unchecked]/DropdownMenuRadioItem:flex group-data-[state=checked]/DropdownMenuRadioItem:hidden dark:text-gray-700"})]}):i==="check"?e.jsx("span",{className:"absolute left-2 flex size-4 items-center justify-center",children:e.jsx(P.RiCheckLine,{"aria-hidden":"true",className:"size-full shrink-0 text-gray-800 group-data-[state=checked]/DropdownMenuRadioItem:flex group-data-[state=unchecked]/DropdownMenuRadioItem:hidden dark:text-gray-200"})}):null,s,t&&e.jsx("span",{className:w("ml-auto text-sm font-normal text-gray-400 dark:text-gray-600"),children:t}),r&&e.jsx("span",{className:w("ml-auto text-sm font-normal tracking-widest text-gray-400 dark:border-gray-800 dark:text-gray-600"),children:r})]}));lt.displayName="DropdownMenuRadioItem";const Zt=z.forwardRef(({className:a,...t},r)=>e.jsx(be.Label,{ref:r,className:w("px-2 py-2 text-xs font-medium tracking-wide","text-gray-500 dark:text-gray-500",a),...t}));Zt.displayName="DropdownMenuLabel";const Gc=z.forwardRef(({className:a,...t},r)=>e.jsx(be.Separator,{ref:r,className:w("-mx-1 my-1 h-px border-t border-gray-200 dark:border-gray-800",a),...t}));Gc.displayName="DropdownMenuSeparator";const Qa=Se.createColumnHelper(),Xc=[Qa.display({id:"select",header:({table:a})=>e.jsx(Oe,{checked:a.getIsAllPageRowsSelected()?!0:a.getIsSomeRowsSelected()?"indeterminate":!1,onCheckedChange:()=>a.toggleAllPageRowsSelected(),className:"translate-y-0.5","aria-label":"Select all"}),cell:({row:a})=>e.jsx(Oe,{checked:a.getIsSelected(),onCheckedChange:()=>a.toggleSelected(),className:"translate-y-0.5","aria-label":"Select row"}),enableSorting:!1,enableHiding:!1,meta:{displayName:"Select"}}),Qa.accessor("name",{header:({column:a})=>e.jsx(V,{column:a,title:"Name"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"Name"},cell:({row:a,table:t})=>{var i,n,o;const r=(i=t.options.meta)==null?void 0:i.organizationId,s=a.original.id;return e.jsx(B,{href:((o=(n=t.options.meta)==null?void 0:n.routes)==null?void 0:o.manufacturerEdit(r,s))??`/admin/${r}/manufacturers/${s}`,className:"text-blue-500 hover:underline",children:a.getValue("name")||"-"})}}),Qa.accessor("translations",{header:({column:a})=>e.jsx(V,{column:a,title:"About"}),enableSorting:!1,meta:{className:"text-left",displayName:"About"},cell:({row:a})=>{var t;return((t=a.getValue("translations").find(r=>r.about))==null?void 0:t.about)||"-"}}),Qa.accessor("createdAt",{header:({column:a})=>e.jsx(V,{column:a,title:"Created At"}),enableSorting:!1,meta:{className:"text-left",displayName:"Created At"},cell:({row:a})=>{const t=a.getValue("createdAt");return new Date(t).toLocaleDateString()}}),Qa.display({id:"edit",header:"Edit",enableSorting:!1,enableHiding:!1,meta:{className:"text-right",displayName:"Edit"},cell:({row:a,table:t})=>{var i,n,o;const r=(i=t.options.meta)==null?void 0:i.organizationId,s=a.original.id;return e.jsxs(sa,{children:[e.jsx(ia,{asChild:!0,children:e.jsx(D,{variant:"ghost",className:"group aspect-square px-1.5 py-0! h-8! hover:border hover:border-gray-300 data-[state=open]:border-gray-300 data-[state=open]:bg-gray-50 dark:hover:border-gray-700 dark:data-[state=open]:border-gray-700 dark:data-[state=open]:bg-gray-900",children:e.jsx(P.RiMoreFill,{className:"size-4 shrink-0 text-gray-500 group-hover:text-gray-700 group-data-[state=open]:text-gray-700 dark:group-hover:text-gray-300 dark:group-data-[state=open]:text-gray-300","aria-hidden":"true"})})}),e.jsxs(na,{align:"end",className:"min-w-40",children:[e.jsx(ze,{children:e.jsx(B,{href:((o=(n=t.options.meta)==null?void 0:n.routes)==null?void 0:o.manufacturerEdit(r,s))??`/admin/${r}/manufacturers/${s}`,className:"block",children:"Edit"})}),e.jsx(ze,{className:"text-red-600 dark:text-red-500",children:"Delete"})]})]})}})],Yc=()=>{const{client:a}=M(),t=_(),r=H(),s=E.useSearchParams(),[i,n]=x.useState(""),[o]=Ke.useDebounce(i,300),l=Number((s==null?void 0:s.get("page"))||"1"),{isLoading:c,isRefetching:m,isError:u,data:p}=A.useQuery({queryKey:["manufacturers",r,l,o],queryFn:async()=>{const{body:g,status:h}=await a.manufacturer.getManufacturers({params:{organizationId:r},query:{page:l,limit:10,search:o}});if(h!==200)throw new Error("Failed to fetch organizations");return g},placeholderData:A.keepPreviousData});return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 sm:gap-x-6",children:[e.jsx("div",{className:"flex w-full flex-col gap-2 sm:w-fit sm:flex-row sm:items-center",children:e.jsx(xa,{type:"search",placeholder:"Search by manufaturer...",value:i,onChange:g=>n(g.target.value),className:"w-full sm:max-w-[250px] sm:[&>input]:h-[40px]"})}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(D,{asChild:!0,className:"hidden gap-x-2 px-2 py-1.5 text-sm sm:text-xs lg:flex",children:e.jsxs(B,{href:t.manufacturerCreate(r),children:["Create Manufacturer",e.jsx(N.PlusIcon,{className:"size-4 shrink-0","aria-hidden":"true"})]})})})]}),e.jsx(ha,{error:u,loading:c||m,meta:p!=null&&p.meta?{...p==null?void 0:p.meta,currentPage:l}:void 0,data:(p==null?void 0:p.list)||[],columns:Xc,className:"mt-8"})]})};function em(){return e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-xl font-semibold text-gray-900 sm:text-2xl dark:text-gray-50",children:"Manufacturers"}),e.jsx("div",{className:"mt-4 sm:mt-6 lg:mt-6",children:e.jsx(Yc,{})})]})}const am=({organizationId:a,id:t,status:r,refetch:s})=>{var f;const{client:i}=M(),n=A.useMutation({mutationFn:async({operation:b})=>{if((await i.order.updateStatus({params:{id:t,organizationId:a,operation:b}})).status!==200)throw new Error("Failed to update order status");return s()}}),o=(()=>{switch(r){case"pending":return"Accept";case"accepted":return"Ready";case"ready-for-dispatch":return"Dispatch";case"dispatched":return"Complete";case"completed":return"Completed";case"cancelled":return"Cancelled";default:return"Unknown"}})(),l=()=>{const b=(()=>{switch(r){case"pending":return"accepted";case"accepted":return"ready-for-dispatch";case"ready-for-dispatch":return"dispatched";case"dispatched":return"completed";default:return null}})();b&&n.mutate({operation:b})},c=()=>{n.mutate({operation:"cancelled"})},m=n.isPending,u=(f=n.variables)==null?void 0:f.operation,p=m&&u==="cancelled",g=m&&u!=="cancelled",h=r!=="completed"&&r!=="cancelled";return e.jsxs("div",{className:"flex items-center gap-2 min-w-28",children:[e.jsxs("button",{onClick:c,disabled:m||r==="cancelled"||r==="completed",className:"relative my-2 inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-md border px-2 py-1 text-center text-sm font-medium shadow-xs transition-all duration-100 ease-in-out disabled:pointer-events-none disabled:shadow-none outline outline-offset-2 outline-0 focus-visible:outline-2 outline-blue-500 dark:outline-blue-500 border-gray-300 dark:border-gray-800 text-gray-900 dark:text-gray-50 bg-white dark:bg-gray-950 hover:bg-gray-50 dark:hover:bg-gray-900/60 disabled:text-gray-400 dark:disabled:text-gray-600","tremor-id":"tremor-raw",children:[p?"Loading...":"Cancel",e.jsx(N.X,{className:"w-4 h-4 text-red-600 dark:text-red-500"})]}),h&&e.jsxs("button",{onClick:l,disabled:m,className:"relative my-2 inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-md border px-2 py-1 text-center text-sm font-medium shadow-xs transition-all duration-100 ease-in-out disabled:pointer-events-none disabled:shadow-none outline outline-offset-2 outline-0 focus-visible:outline-2 outline-blue-500 dark:outline-blue-500 border-gray-300 dark:border-gray-800 text-gray-900 dark:text-gray-50 bg-white dark:bg-gray-950 hover:bg-gray-50 dark:hover:bg-gray-900/60 disabled:text-gray-400 dark:disabled:text-gray-600","tremor-id":"tremor-raw",children:[g?"Loading...":o,e.jsx(N.CheckCircle,{className:"w-4 h-4 text-emerald-600 dark:text-emerald-500"})]})]})},tm=({order:a})=>{const[t,r]=x.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>r(!0),className:"text-blue-500 hover:underline",children:a.referenceId}),e.jsx(cn,{open:t,onOpenChange:r,order:a})]})},rm=({order:a,table:t})=>{const r=t.options.meta,s=(r==null?void 0:r.organizationId)||"",i=typeof(r==null?void 0:r.refetch)=="function"?r.refetch:()=>{};return e.jsx(am,{organizationId:s,id:a.id,status:a.status,refetch:i})},Xe=Se.createColumnHelper(),sm=a=>{var t;return a.inventoryConflictAt?e.jsx(de,{variant:"warning",children:"Manual review"}):((t=a.payment)==null?void 0:t.status)==="succeeded"&&a.inventoryDeductedAt?e.jsx(de,{variant:"success",children:"Deducted"}):e.jsx(de,{variant:"neutral",children:"Pending"})},im=[Xe.accessor("referenceId",{header:({column:a})=>e.jsx(V,{column:a,title:"Reference ID"}),cell:({row:a})=>e.jsx(tm,{order:a.original}),meta:{className:"text-left",displayName:"Reference ID"},enableSorting:!1,enableHiding:!1}),Xe.display({id:"customer",meta:{className:"text-left",displayName:"ID"},header:({column:a})=>e.jsx(V,{column:a,title:"Customer"}),cell:({row:a})=>{var s,i;const t=((s=a.original.shippingAddress)==null?void 0:s.firstname)||"",r=((i=a.original.shippingAddress)==null?void 0:i.lastname)||"";return e.jsx("div",{children:`${t} ${r}`.trim()||"N/A"})}}),Xe.accessor("payment.total",{meta:{className:"text-left",displayName:"ID"},enableSorting:!0,enableHiding:!1,header:({column:a})=>e.jsx(V,{column:a,title:"Total"}),cell:({row:a})=>{const t=parseFloat(a.original.payment.total.toString()),r=new Intl.NumberFormat("en-US",{style:"currency",currency:a.original.currency||"PLN"}).format(t);return e.jsx("div",{className:"font-medium",children:r})}}),Xe.accessor("createdAt",{meta:{className:"text-left",displayName:"ID"},enableSorting:!0,enableHiding:!1,header:({column:a})=>e.jsx(V,{column:a,title:"Date & Time"}),cell:({row:a})=>{const t=a.getValue("createdAt");return t?I.format(new Date(t),"dd.MM.yyyy HH:mm"):"N/A"}}),Xe.display({id:"paymentMethod",header:({column:a})=>e.jsx(V,{column:a,title:"Payment Method"}),cell:({row:a})=>{var r;const t=(r=a.original.payment)==null?void 0:r.method;return e.jsx("div",{children:t||"N/A"})}}),Xe.display({id:"address",meta:{className:"text-left",displayName:"ID"},header:({column:a})=>e.jsx(V,{column:a,title:"Address"}),cell:({row:a})=>{var n,o,l,c;const t=((n=a.original.shippingAddress)==null?void 0:n.addressLineOne)||"",r=((o=a.original.shippingAddress)==null?void 0:o.city)||"",s=((l=a.original.shippingAddress)==null?void 0:l.doorNumber)||"",i=((c=a.original.shippingAddress)==null?void 0:c.zipCode)||"";return e.jsxs("div",{children:[e.jsxs("div",{children:[t," ",s?` / ${s}`:""]}),e.jsxs("div",{children:[i?`${i}, `:"",r]})]})}}),Xe.display({id:"inventory",meta:{className:"text-left",displayName:"Inventory"},header:({column:a})=>e.jsx(V,{column:a,title:"Inventory"}),cell:({row:a})=>sm(a.original)}),Xe.display({id:"status",header:({column:a})=>e.jsx(V,{column:a,title:"Actions"}),cell:({row:a,table:t})=>e.jsx(rm,{order:a.original,table:t})})],nm=()=>{const{client:a}=M(),t=H(),r=E.useSearchParams(),[s,i]=x.useState(""),[n]=Ke.useDebounce(s,300),o=Number((r==null?void 0:r.get("page"))||"1"),{isLoading:l,isRefetching:c,isError:m,data:u,refetch:p}=A.useQuery({queryKey:["orders",t,o,n],queryFn:async()=>{const{body:g,status:h}=await a.order.getOrders({params:{organizationId:t},query:{page:o,limit:10,search:n}});if(h!==200)throw new Error("Failed to fetch orders");return g},placeholderData:A.keepPreviousData});return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap items-center justify-between gap-2 sm:gap-x-6",children:e.jsx("div",{className:"flex w-full flex-col gap-2 sm:w-fit sm:flex-row sm:items-center",children:e.jsx(xa,{type:"search",placeholder:"Search by order reference...",value:s,onChange:g=>i(g.target.value),className:"w-full sm:max-w-[250px] sm:[&>input]:h-[40px]"})})}),e.jsx(ha,{error:m,loading:l||c,meta:u!=null&&u.meta?{...u==null?void 0:u.meta,currentPage:o}:void 0,data:(u==null?void 0:u.list)||[],columns:im,className:"mt-8",refetch:p})]})};function om(){return e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-xl font-semibold text-gray-900 sm:text-2xl dark:text-gray-50",children:"Orders List"}),e.jsx("div",{className:"mt-4 sm:mt-6 lg:mt-6",children:e.jsx(nm,{})})]})}const Dn=({onClose:a,initialData:t})=>{var m;const{client:r}=M(),s=U.useForm({resolver:fe.zodResolver(t?cr:di),defaultValues:{...t}}),i=s.watch("address.placeId"),n=s.watch("address.addressLineOne");x.useEffect(()=>{(async()=>{if(i){const{status:u,body:p}=await r.location.getPlaceDetails({params:{placeId:i}});if(u!==200)throw new Error("Failed to fetch place details");s.setValue("address.zipCode",p.zipCode,{shouldValidate:!0}),s.setValue("address.city",p.city,{shouldValidate:!0}),s.setValue("address.country",p.country,{shouldValidate:!0})}})()},[s,i]);const o=A.useMutation({mutationFn:async u=>{const{logoFile:p,...g}=u;return await r.organization.createOrganization({body:{...g,logoId:p==null?void 0:p.id}})},onSuccess:async()=>{await oe.invalidateQueries({queryKey:["organizations"]}),a&&a()}}),l=A.useMutation({mutationFn:async u=>{if(!t)throw new Error("Cannot update organization without initial data");const{logoFile:p,...g}=u;return await r.organization.updateOrganization({params:{organizationId:t.id},body:{...g,logoId:p==null?void 0:p.id}})},onSuccess:async()=>{await oe.invalidateQueries({queryKey:["organizations"]}),a&&a()}}),c=u=>{t?l.mutate(u):o.mutate(u)};return e.jsx("div",{className:"mt-6",children:e.jsx(U.FormProvider,{...s,children:e.jsxs("form",{onSubmit:s.handleSubmit(u=>c(u)),className:"grid gap-5 grid-cols-4",children:[t&&e.jsxs("div",{className:"col-span-2",children:[e.jsx(le,{htmlFor:"organization-id",className:"font-medium flex items-center justify-between",children:"Organization ID"}),e.jsx("div",{className:"relative mt-2",children:e.jsx(ne,{id:"organization-id",value:t.id,disabled:!0,readOnly:!0,className:"w-full",copyValue:t.id,copySuccessMessage:"Organization ID copied to clipboard.",copyErrorMessage:"Failed to copy organization ID. Please try again."})})]}),e.jsx(Pe,{name:"name",label:"Organization Name",placeholder:"Acme Inc.",className:"col-span-2"}),e.jsx(Pe,{name:"email",type:"email",label:"Support Email",placeholder:"john.doe@example.com",className:"col-span-2"}),e.jsx(Pe,{name:"phone",type:"phone-number",label:"Phone Number",placeholder:"Enter phone number",className:"col-span-2"}),e.jsxs("div",{className:"col-span-4 text-sm text-gray-500",children:[e.jsx(le,{htmlFor:"address.addressLineOne",className:"font-medium flex items-center justify-between",children:"Street / Address Line 1"}),e.jsx(Lt,{onChange:u=>{s.setValue("address.addressLineOne",u.addressLineOne,{shouldValidate:!0}),s.setValue("address.placeId",u.placeId,{shouldValidate:!0})},value:n??""}),((m=s.formState.errors.address)==null?void 0:m.addressLineOne)&&e.jsx("p",{className:"mt-1 text-sm text-red-500",children:s.formState.errors.address.addressLineOne.message})]}),e.jsx(Pe,{name:"address.addressLineTwo",label:"Door / Address Line 2",placeholder:"Apt 123",className:"col-span-2"}),e.jsx(Pe,{name:"address.zipCode",label:"Postal Code",placeholder:"12345",className:"col-span-2"}),e.jsx(Pe,{name:"address.city",label:"City",placeholder:"New York",className:"col-span-2"}),e.jsx(Pe,{name:"address.country",label:"Country",placeholder:"United States",className:"col-span-2",type:"country"}),e.jsx(Pe,{name:"logoFile",label:"Logo",type:"file",className:"col-span-2"}),e.jsxs("div",{className:"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2 mt-5 col-span-full border-t pt-7",children:[a&&e.jsx(D,{type:"button",className:"w-full sm:w-fit",variant:"secondary",onClick:a,children:"Cancel"}),e.jsx(D,{type:"submit",className:"w-full sm:w-fit",isLoading:o.isPending||l.isPending,loadingText:"Saving...",children:t?"Update Data":"Create Organization"})]})]})})})},lm=({invitation:a})=>{var s;const{client:t}=M(),r=A.useMutation({mutationFn:async()=>{const{status:i}=await t.access.acceptInvitation({params:{invitationId:a.id}});if(i!==200)throw new Error("Failed to accept invitation")},onSuccess:async()=>{J.success(`Joined ${a.organization.name}`),await oe.invalidateQueries({queryKey:["organizations"]}),await oe.invalidateQueries({queryKey:["user-invitations"]})},onError:i=>{J.error((i==null?void 0:i.message)||"Failed to accept invitation")}});return e.jsxs("div",{className:"relative flex items-center rounded-md border border-dashed border-emerald-300 bg-emerald-50/50 px-4 py-3 shadow-xs dark:border-emerald-700 dark:bg-emerald-950/20",children:[e.jsx("span",{className:"absolute inset-x-0 top-1/2 h-10 w-1 -translate-y-1/2 rounded-r-md bg-emerald-500 dark:bg-emerald-500","aria-hidden":"true"}),e.jsx("div",{className:"rounded-full ml-2",children:e.jsxs("div",{className:"rounded-full h-14 w-14 bg-emerald-500 text-white text-xl flex items-center justify-center",children:[a.organization.name.charAt(0).toUpperCase(),(s=a.organization.name.charAt(1))==null?void 0:s.toUpperCase()]})}),e.jsxs("div",{className:"border-l border-emerald-200 dark:border-emerald-800 ml-6 pl-6 flex justify-between items-center w-full",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-lg font-semibold text-gray-900 dark:text-gray-50",children:a.organization.name}),e.jsx("span",{className:"inline-flex items-center rounded-md bg-emerald-100 px-2 py-0.5 text-xs font-medium text-emerald-700 dark:bg-emerald-900 dark:text-emerald-300",children:"Invited"})]}),e.jsx("p",{className:"flex items-center gap-2",children:e.jsxs("span",{className:"text-sm text-gray-500 dark:text-gray-500",children:["You have been invited as"," ",e.jsx("span",{className:"font-medium",children:a.role??"member"})]})})]}),e.jsx("div",{children:e.jsx("button",{onClick:()=>r.mutate(),disabled:r.isPending,className:"block rounded-full text-emerald-500 p-2 hover:bg-emerald-500 hover:text-white hover:translate-y-[-2px] hover:shadow-lg transition mr-2 border border-emerald-200 dark:border-emerald-700/60 hover:border-emerald-500 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:translate-y-0 disabled:hover:shadow-none",children:e.jsx(N.CheckIcon,{className:"w-5 h-5"})})})]})]})},dm=()=>{const[a,t]=x.useState(!1),r=_(),{client:s}=M(),{organizations:i}=je(),{data:n}=A.useQuery({queryKey:["user-invitations"],queryFn:async()=>{const{body:l,status:c}=await s.access.getUserInvitations();return c!==200?[]:l}}),o=()=>t(!1);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"max-w-4xl mx-auto py-8 px-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold text-gray-900 dark:text-gray-50",children:"Organizations"}),e.jsx("p",{className:"text-gray-500 sm:text-sm/6 dark:text-gray-500",children:"Select a organization to get started."})]}),e.jsx("div",{className:"w-min h-min",children:e.jsxs(D,{onClick:()=>t(!0),variant:"primary",children:[e.jsx(N.PlusIcon,{className:"w-4 h-4 mr-1"})," Add New"]})})]}),i.loading?e.jsx("div",{className:"flex justify-center items-center h-32 mt-5",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsxs("svg",{"aria-hidden":"true",className:"w-8 h-8 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600",viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",fill:"currentColor"}),e.jsx("path",{d:"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",fill:"currentFill"})]}),e.jsx("p",{className:"text-gray-500 text-sm mt-2",children:"Loading organizations..."})]})}):e.jsxs("div",{className:"grid grid-cols-1 gap-y-3 gap-x-4 animate-fade-in mt-5",children:[n==null?void 0:n.map(l=>e.jsx(lm,{invitation:l},l.id)),i.data.map(l=>{var c,m;return e.jsxs("div",{className:"relative flex items-center rounded-md border border-gray-200 bg-white px-4 py-3 shadow-xs dark:border-gray-800 dark:bg-gray-900",children:[e.jsx("span",{className:"absolute inset-x-0 top-1/2 h-10 w-1 -translate-y-1/2 rounded-r-md bg-blue-500 dark:bg-blue-500","aria-hidden":"true"}),l.logoFile?e.jsx(Ie,{src:l.logoFile.url,alt:l.name,width:100,height:100,className:"rounded-lg ml-2 h-16 w-16 object-cover"}):e.jsx("div",{className:"rounded-full ml-2",children:e.jsxs("div",{className:"rounded-full h-14 w-14 bg-blue-500 text-white text-xl flex items-center justify-center",children:[l.name.charAt(0).toUpperCase(),l.name.charAt(1).toUpperCase()]})}),e.jsxs("div",{className:"border-l ml-6 pl-6 flex justify-between items-center w-full",children:[e.jsxs("div",{children:[e.jsx("p",{className:"flex items-center justify-between gap-2",children:e.jsx("span",{className:"text-lg font-semibold text-gray-900 dark:text-gray-50",children:l.name})}),e.jsx("p",{className:"flex items-center justify-between gap-2",children:e.jsxs("span",{className:"text-sm text-gray-500 dark:text-gray-500",children:[(c=l.address)==null?void 0:c.addressLineOne,","," ",(m=l.address)==null?void 0:m.city]})})]}),e.jsx("div",{children:e.jsx(B,{className:"block rounded-full text-blue-500 p-2 hover:bg-blue-500 hover:text-white hover:translate-y-[-2px] hover:shadow-lg transition mr-2 border border-gray-200 dark:border-gray-700/60 hover:border-blue-500",href:r.dashboard(l.id),children:e.jsx(N.ArrowRight,{className:"w-5 h-5"})})})]})]},l.id)})]})]}),e.jsxs(Ra,{onOpenChange:o,open:a,children:[e.jsx(on,{className:"w-full text-left"}),e.jsxs(Fa,{className:"sm:max-w-xl",children:[e.jsxs(Ma,{children:[e.jsx(Pa,{children:"Create a Organization"}),e.jsx(Ut,{className:"mt-1 text-sm leading-6",children:"Fill in the details below to create a new organization"})]}),e.jsx(Dn,{onClose:o})]})]})]})};function cm(){const{appearance:a}=Fs(),t=a==null?void 0:a.organizationImage;return e.jsxs("div",{className:"flex w-full min-h-screen",children:[t&&e.jsx("div",{className:"hidden lg:block relative w-1/2 overflow-hidden",children:e.jsx(Ie,{src:t,alt:"Organization Visual",width:4e3,height:2250,className:"w-full h-full object-cover min-h-screen"})}),e.jsx("div",{className:`w-full ${t?"lg:w-1/2":""} flex items-center justify-center p-8`,children:e.jsx("div",{className:"w-full max-w-md space-y-8",children:e.jsx(dm,{})})})]})}const bt=me.Root;bt.displayName="Select";const mm=me.Group;mm.displayName="SelectGroup";const jt=me.Value;jt.displayName="SelectValue";const um=[w("group/trigger flex w-full select-none items-center justify-between gap-2 truncate rounded-md border px-3 py-2 shadow-xs outline-hidden transition sm:text-sm","border-gray-300 dark:border-gray-800","text-gray-900 dark:text-gray-50","data-placeholder:text-gray-500 dark:data-placeholder:text-gray-500","bg-white dark:bg-gray-950","hover:bg-gray-50 dark:hover:bg-gray-950/50","data-disabled:bg-gray-100 data-disabled:text-gray-400","dark:data-disabled:border-gray-700 dark:data-disabled:bg-gray-800 dark:data-disabled:text-gray-500",Da)],vt=x.forwardRef(({className:a,hasError:t,children:r,...s},i)=>e.jsxs(me.Trigger,{ref:i,className:w(um,t?Vt:"",a),...s,children:[e.jsx("span",{className:"truncate",children:r}),e.jsx(me.Icon,{asChild:!0,children:e.jsx(P.RiArrowDownSLine,{className:w("-mr-1 size-5 shrink-0","text-gray-400 dark:text-gray-600","group-data-disabled/trigger:text-gray-300 dark:group-data-disabled/trigger:text-gray-600")})})]}));vt.displayName="SelectTrigger";const Rn=x.forwardRef(({className:a,...t},r)=>e.jsx(me.ScrollUpButton,{ref:r,className:w("flex cursor-default items-center justify-center py-1",a),...t,children:e.jsx(P.RiArrowUpSLine,{className:"size-3 shrink-0","aria-hidden":"true"})}));Rn.displayName=me.ScrollUpButton.displayName;const Fn=x.forwardRef(({className:a,...t},r)=>e.jsx(me.ScrollDownButton,{ref:r,className:w("flex cursor-default items-center justify-center py-1",a),...t,children:e.jsx(P.RiArrowDownSLine,{className:"size-3 shrink-0","aria-hidden":"true"})}));Fn.displayName=me.ScrollDownButton.displayName;const wt=x.forwardRef(({className:a,position:t="popper",children:r,sideOffset:s=8,collisionPadding:i=10,...n},o)=>e.jsx(me.Portal,{children:e.jsxs(me.Content,{ref:o,className:w("relative z-50 overflow-hidden rounded-md border shadow-xl shadow-black/[2.5%]","min-w-[calc(var(--radix-select-trigger-width)-2px)] max-w-[95vw]","max-h-(--radix-select-content-available-height)","bg-white dark:bg-gray-950","text-gray-900 dark:text-gray-50","border-gray-200 dark:border-gray-800","will-change-[transform,opacity]","data-[state=closed]:animate-hide","data-[side=bottom]:animate-slideDownAndFade data-[side=left]:animate-slideLeftAndFade data-[side=right]:animate-slideRightAndFade data-[side=top]:animate-slideUpAndFade",a),sideOffset:s,position:t,collisionPadding:i,...n,children:[e.jsx(Rn,{}),e.jsx(me.Viewport,{className:w("p-1",t==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[calc(var(--radix-select-trigger-width))]"),children:r}),e.jsx(Fn,{})]})}));wt.displayName="SelectContent";const pm=x.forwardRef(({className:a,...t},r)=>e.jsx(me.Label,{ref:r,className:w("px-3 py-2 text-xs font-medium tracking-wide","text-gray-500 dark:text-gray-500",a),...t}));pm.displayName="SelectGroupLabel";const _e=x.forwardRef(({className:a,children:t,...r},s)=>e.jsxs(me.Item,{ref:s,className:w("grid cursor-pointer grid-cols-[1fr_20px] gap-x-2 rounded px-3 py-2 outline-hidden transition-colors data-[state=checked]:font-semibold sm:text-sm","text-gray-900 dark:text-gray-50","data-disabled:pointer-events-none data-disabled:text-gray-400 data-disabled:hover:bg-none dark:data-disabled:text-gray-600","focus-visible:bg-gray-100 dark:focus-visible:bg-gray-900","hover:bg-gray-100 dark:hover:bg-gray-900",a),...r,children:[e.jsx(me.ItemText,{className:"flex-1 truncate",children:t}),e.jsx(me.ItemIndicator,{children:e.jsx(P.RiCheckLine,{className:"size-5 shrink-0 text-gray-800 dark:text-gray-200","aria-hidden":"true"})})]}));_e.displayName="SelectItem";const gm=x.forwardRef(({className:a,children:t,period:r,...s},i)=>e.jsxs(me.Item,{ref:i,className:w("relative flex cursor-pointer items-center rounded py-2 pl-8 pr-3 outline-hidden transition-colors data-[state=checked]:font-semibold sm:text-sm","text-gray-900 dark:text-gray-50","data-disabled:pointer-events-none data-disabled:text-gray-400 data-disabled:hover:bg-none dark:data-disabled:text-gray-600","focus-visible:bg-gray-100 dark:focus-visible:bg-gray-900","hover:bg-gray-100 dark:hover:bg-gray-900",a),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(me.ItemIndicator,{children:e.jsx(P.RiCheckLine,{className:"size-5 shrink-0 text-gray-800 dark:text-gray-200","aria-hidden":"true"})})}),e.jsxs("div",{className:"flex w-full items-center",children:[e.jsx("span",{className:"w-40 sm:w-32",children:e.jsx(me.ItemText,{children:t})}),e.jsx("span",{children:(r==null?void 0:r.from)&&(r==null?void 0:r.to)&&e.jsxs("span",{className:"whitespace-nowrap font-normal text-gray-400",children:[I.format(r.from,"MMM d, yyyy")," –"," ",I.format(r.to,"MMM d, yyyy")]})})]})]}));gm.displayName="SelectItemPeriod";const hm=x.forwardRef(({className:a,...t},r)=>e.jsx(me.Separator,{ref:r,className:w("-mx-1 my-1 h-px","bg-gray-300 dark:bg-gray-700",a),...t}));hm.displayName="SelectSeparator";const ba=Se.createColumnHelper(),xm=({row:a,table:t})=>{var m,u;const{client:r}=M(),s=a.original.id,i=a.getValue("publishedAt"),n=(m=t.options.meta)==null?void 0:m.organizationId,o=(u=t.options.meta)==null?void 0:u.refetch,l=A.useMutation({mutationFn:async()=>{if((await r.productCategory.updateStatus({params:{id:s,organizationId:n,operation:i?"unpublish":"publish"}})).status!==200)throw new Error("Failed to update product category status");o&&await o()}}),c=()=>{l.mutate()};return l.isPending?e.jsx("div",{className:"min-w-28",children:e.jsxs("button",{className:"relative my-2 inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-md border px-2 py-1 text-center text-sm font-medium shadow-xs transition-all duration-100 ease-in-out disabled:pointer-events-none disabled:shadow-none outline outline-offset-2 outline-0 focus-visible:outline-2 outline-blue-500 dark:outline-blue-500 border-gray-300 dark:border-gray-800 text-gray-900 dark:text-gray-50 bg-white dark:bg-gray-950 hover:bg-gray-50 dark:hover:bg-gray-900/60 disabled:text-gray-400 dark:disabled:text-gray-600","tremor-id":"tremor-raw",disabled:!0,children:[e.jsx(pe,{className:"w-4 h-4"})," Saving..."]})}):e.jsx("div",{className:"min-w-28",children:e.jsxs("button",{onClick:c,className:"relative my-2 inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-md border px-2 py-1 text-center text-sm font-medium shadow-xs transition-all duration-100 ease-in-out disabled:pointer-events-none disabled:shadow-none outline outline-offset-2 outline-0 focus-visible:outline-2 outline-blue-500 dark:outline-blue-500 border-gray-300 dark:border-gray-800 text-gray-900 dark:text-gray-50 bg-white dark:bg-gray-950 hover:bg-gray-50 dark:hover:bg-gray-900/60 disabled:text-gray-400 dark:disabled:text-gray-600","tremor-id":"tremor-raw",children:[i?e.jsx(N.CheckCircle,{className:"w-4 h-4 text-emerald-600 dark:text-emerald-500"}):e.jsx(N.EyeOffIcon,{className:"w-4 h-4 text-red-600 dark:text-red-500"}),i?"Published":"Draft"]})})},fm=({row:a,table:t})=>{var c,m,u,p;const{client:r}=M(),s=a.original.id,i=(c=t.options.meta)==null?void 0:c.organizationId,n=(m=t.options.meta)==null?void 0:m.refetch,o=A.useMutation({mutationFn:async()=>{if((await r.productCategory.deleteProductCategory({params:{id:s,organizationId:i}})).status!==204)throw new Error("Failed to delete product category");n&&await n()}}),l=()=>{window.confirm("Are you sure you want to delete this product category? This action cannot be undone.")&&o.mutate()};return e.jsxs(sa,{children:[e.jsx(ia,{asChild:!0,children:e.jsx(D,{variant:"ghost",className:"group aspect-square px-1.5 py-0! h-8! hover:border hover:border-gray-300 data-[state=open]:border-gray-300 data-[state=open]:bg-gray-50 dark:hover:border-gray-700 dark:data-[state=open]:border-gray-700 dark:data-[state=open]:bg-gray-900",disabled:o.isPending,children:o.isPending?e.jsx(pe,{className:"size-4 shrink-0"}):e.jsx(P.RiMoreFill,{className:"size-4 shrink-0 text-gray-500 group-hover:text-gray-700 group-data-[state=open]:text-gray-700 dark:group-hover:text-gray-300 dark:group-data-[state=open]:text-gray-300","aria-hidden":"true"})})}),e.jsxs(na,{align:"end",className:"min-w-40",children:[e.jsx(ze,{children:e.jsxs(B,{href:((p=(u=t.options.meta)==null?void 0:u.routes)==null?void 0:p.productCategoryEdit(i,s))??`/admin/${i}/product-categories/${s}`,className:"block flex items-center gap-2",children:[e.jsx(N.PencilIcon,{className:"w-4 h-4"}),"Edit"]})}),e.jsx(ze,{className:"text-red-600 dark:text-red-500 cursor-pointer",onClick:l,disabled:o.isPending,children:e.jsxs("div",{className:"flex items-center gap-2",children:[o.isPending?e.jsx(pe,{className:"w-4 h-4"}):e.jsx(N.Trash2,{className:"w-4 h-4"}),o.isPending?"Deleting...":"Delete"]})})]})]})},ym=[ba.display({id:"select",header:({table:a})=>e.jsx(Oe,{checked:a.getIsAllPageRowsSelected()?!0:a.getIsSomeRowsSelected()?"indeterminate":!1,onCheckedChange:()=>a.toggleAllPageRowsSelected(),className:"translate-y-0.5","aria-label":"Select all"}),cell:({row:a})=>e.jsx(Oe,{checked:a.getIsSelected(),onCheckedChange:()=>a.toggleSelected(),className:"translate-y-0.5","aria-label":"Select row"}),enableSorting:!1,enableHiding:!1,meta:{displayName:"Select"}}),ba.accessor("title",{header:({column:a})=>e.jsx(V,{column:a,title:"Title"}),enableSorting:!1,meta:{className:"text-left",displayName:"Title"},cell:({row:a,table:t})=>{var i,n,o;const r=(i=t.options.meta)==null?void 0:i.organizationId,s=a.original.id;return e.jsx(B,{href:((o=(n=t.options.meta)==null?void 0:n.routes)==null?void 0:o.productCategoryEdit(r,s))??`/admin/${r}/product-categories/${s}`,className:"text-blue-500 hover:underline",children:a.getValue("title")||"-"})}}),ba.accessor("slug",{header:({column:a})=>e.jsx(V,{column:a,title:"Slug"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"Slug"}}),ba.accessor("publishedAt",{header:({column:a})=>e.jsx(V,{column:a,title:"Status"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"Status"},cell:({row:a,table:t})=>e.jsx(xm,{row:a,table:t})}),ba.accessor("createdAt",{header:({column:a})=>e.jsx(V,{column:a,title:"Created At"}),enableSorting:!1,meta:{className:"text-left",displayName:"Created At"},cell:({row:a})=>{const t=a.getValue("createdAt");return new Date(t).toLocaleDateString()}}),ba.display({id:"edit",header:"Edit",enableSorting:!1,enableHiding:!1,meta:{className:"text-right",displayName:"Edit"},cell:({row:a,table:t})=>e.jsx(fm,{row:a,table:t})})],bm=()=>{const{client:a}=M(),t=_(),{defaultLocale:r}=je(),s=H(),i=E.usePathname(),n=E.useRouter(),o=E.useSearchParams(),[l,c]=x.useState(""),[m,u]=x.useState("all"),p=Number((o==null?void 0:o.get("page"))||"1"),[g]=Ke.useDebounce(l,300),h=m==="all"?void 0:m,f=(F,T)=>{const O=new URLSearchParams(o==null?void 0:o.toString());return O.set(F,T),O.toString()},b=()=>{p!==1&&n.replace(`${i}?${f("page","1")}`)},{isLoading:y,isRefetching:j,isError:v,data:k,refetch:C}=A.useQuery({queryKey:["productCategories",s,p,g,h,r],queryFn:async()=>{const{body:F,status:T}=await a.productCategory.getProductCategories({params:{organizationId:s},query:{page:p,limit:10,search:g,locale:r,publishedStatus:h}});if(T!==200)throw new Error("Failed to fetch product categories");return F},placeholderData:A.keepPreviousData});return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 sm:gap-x-6",children:[e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:w-fit sm:flex-row sm:items-center",children:[e.jsx(xa,{type:"search",placeholder:"Search by product category...",value:l,onChange:F=>{c(F.target.value),b()},className:"w-full sm:max-w-[250px] sm:[&>input]:h-[40px]"}),e.jsxs(bt,{value:m,onValueChange:F=>{u(F),b()},children:[e.jsx(vt,{className:"w-full sm:w-[190px]",children:e.jsx(jt,{placeholder:"All statuses"})}),e.jsxs(wt,{children:[e.jsx(_e,{value:"all",children:"All statuses"}),e.jsx(_e,{value:"published",children:"Published"}),e.jsx(_e,{value:"unpublished",children:"Unpublished"})]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(D,{asChild:!0,className:"hidden gap-x-2 px-2 py-1.5 text-sm sm:text-xs lg:flex",children:e.jsxs(B,{href:t.productCategoryCreate(s),children:["Create Product Category",e.jsx(N.PlusIcon,{className:"size-4 shrink-0","aria-hidden":"true"})]})})})]}),e.jsx(ha,{error:v,loading:y||j,meta:k==null?void 0:k.meta,data:(k==null?void 0:k.list)||[],columns:ym,className:"mt-8",refetch:C})]})};function jm(){return e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-xl font-semibold text-gray-900 sm:text-2xl dark:text-gray-50",children:"Product Categories"}),e.jsx("div",{className:"mt-4 sm:mt-6 lg:mt-6",children:e.jsx(bm,{})})]})}const vm=[{name:"slug",label:"Slug",type:"text",placeholder:"electronics",colspan:2},{name:"title",label:"Title",type:"text",placeholder:"Electronics",colspan:2,localizable:!0},{name:"description",label:"Description",type:"textarea",placeholder:"All electronic devices and accessories.",colspan:2,localizable:!0},{name:"image",label:"Image",type:"file"}],Mn=({initialData:a})=>{const{client:t}=M(),r=E.useRouter(),s=_(),i=H(),{defaultLocale:n,supportedLocales:o}=je(),l=a?rl:tl,c=U.useForm({resolver:fe.zodResolver(l),defaultValues:a?{defaultLocale:n,slug:a.slug,image:a.image,translations:a.translations}:{defaultLocale:n,translations:o.map(h=>({locale:h}))}}),m=A.useMutation({mutationFn:async h=>{var y;const f={slug:h.slug,defaultLocale:h.defaultLocale,translations:h.translations,imageId:(y=h.image)==null?void 0:y.id},{status:b}=await t.productCategory.createProductCategory({params:{organizationId:i},body:f});if(b!==201)throw J.error("Failed to create product category. Please try again later."),new Error("Failed to create product category")}}),u=A.useMutation({mutationFn:async h=>{var y;const f={slug:h.slug,defaultLocale:h.defaultLocale,translations:h.translations,imageId:((y=h.image)==null?void 0:y.id)||null},{status:b}=await t.productCategory.updateProductCategory({params:{organizationId:i,id:a.id},body:f});if(b!==200)throw J.error("Failed to update product category. Please try again later."),new Error("Failed to update product category")}}),p=async()=>{J.success("Product category saved successfully"),r.push(s.productCategories(i)),await oe.invalidateQueries({queryKey:["productCategories"]})},g=h=>{a?u.mutate(h,{onSuccess:p}):m.mutate(h,{onSuccess:p})};return e.jsx(Te,{form:c,config:vm,onSubmit:g,loading:m.isPending||u.isPending,cancelText:"Go back",okText:a?"Update Product Category":"Create Product Category"})};function wm(){return e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-gray-900 sm:text-xl dark:text-gray-50",children:"Create Product Category"}),e.jsx(Z,{}),e.jsx("div",{className:"pt-6",children:e.jsx("div",{className:"space-y-10",children:e.jsx("section",{"aria-labelledby":"product-category-info",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"product-category-info",className:"scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Product Category Information"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Enter the information about the product category."})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsx(Mn,{})})]})})})})]})}function km(){const a=H(),t=ga(),{client:r}=M(),{isLoading:s,data:i}=A.useQuery({queryKey:["productCategories",a,t],queryFn:async()=>{const{status:n,body:o}=await r.productCategory.getProductCategory({params:{id:t,organizationId:a}});if(n!==200)throw J.error("Failed to fetch product category. Please refresh or try again later."),new Error("Failed to fetch product category");return o},throwOnError:!0,placeholderData:A.keepPreviousData});return e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-gray-900 sm:text-xl dark:text-gray-50",children:"Edit Product Category"}),e.jsx(Z,{}),e.jsx("div",{className:"pt-6",children:e.jsx("div",{className:"space-y-10",children:e.jsx("section",{"aria-labelledby":"product-category-info",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"product-category-info",className:"scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Product Category Information"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Enter the information about the product category."})]}),e.jsx("div",{className:"md:col-span-2",children:s||!i?e.jsx("div",{className:"flex justify-center items-center h-[500px] mt-5",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(pe,{className:"w-12 h-12"}),e.jsx("p",{className:"text-gray-500 text-sm mt-3",children:"Loading data..."})]})}):e.jsx(Mn,{initialData:i})})]})})})})]})}const Nm=({form:a})=>{const{client:t}=M(),r=H(),{data:s}=A.useQuery({queryKey:["product-categories",r],queryFn:async()=>{const o=await t.productCategory.getProductCategories({params:{organizationId:r},query:{limit:100}});if(o.status!==200)throw new Error("Failed to fetch product categories");return o.body.list.map(l=>({label:l.translations[0].title||"",value:l.id}))},throwOnError:!0}),{data:i}=A.useQuery({queryKey:["manufacturers",r],queryFn:async()=>{const o=await t.manufacturer.getManufacturers({params:{organizationId:r},query:{limit:100}});if(o.status!==200)throw new Error("Failed to fetch product categories");return o.body.list.map(l=>({label:l.name,value:l.id}))},throwOnError:!0}),n=[{name:"title",label:"Title",type:"text",placeholder:"Enter product name",colspan:2,localizable:!0},{name:"description",label:"Description",type:"textarea",placeholder:"Enter product description",colspan:2,localizable:!0},{name:"slug",label:"Slug",type:"text",placeholder:"Enter a URL-friendly slug"},{name:"sku",label:"SKU (Stock Keeping Unit)",type:"text",placeholder:"Enter SKU"},{name:"categories",label:"Categories",type:"select",options:s||[],multiple:!0},{name:"manufacturerId",label:"Manufacturer",type:"select",options:i||[]},{name:"images",label:"Images",type:"file",multiple:!0,colspan:2}];return e.jsx("section",{"aria-labelledby":"product-information",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"product-information",className:"text-lg scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Basic Information"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Enter the basic information of your product, including the name, description, base price, and other essential details."})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsx(Te,{form:a,config:n})})]})})},Am=({form:a})=>{const[t,r]=x.useState([]);x.useEffect(()=>{const l=a.getValues("metadata")||{},c=Object.entries(l);c.length>0&&r(c.map(([m,u],p)=>({id:`metadata-${p}-${Date.now()}`,key:m,value:u})))},[a]);const s=x.useCallback(l=>{const c={};l.forEach(m=>{m.key&&m.value&&(c[m.key]=m.value)}),a.setValue("metadata",Object.keys(c).length>0?c:void 0)},[a]),i=()=>{const l={id:`metadata-${Date.now()}`,key:"",value:""},c=[...t,l];r(c)},n=l=>{const c=t.filter((m,u)=>u!==l);r(c),s(c)},o=(l,c,m)=>{const u=[...t];u[l][c]=m,r(u),s(u)};return e.jsx("section",{"aria-labelledby":"product-metadata",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"product-metadata",className:"text-lg scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Metadata"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Add custom key-value pairs to store additional information about your product. Keys must start with a letter and contain only letters, numbers, underscores, or dashes."})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsxs("div",{className:"space-y-4",children:[t.map((l,c)=>e.jsxs("div",{className:"flex gap-4 items-start",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(le,{htmlFor:`metadata-key-${c}`,className:"font-medium",children:"Key"}),e.jsx(ne,{id:`metadata-key-${c}`,type:"text",value:l.key,onChange:m=>o(c,"key",m.target.value),placeholder:"e.g., color, size, weight",className:"mt-2"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx(le,{htmlFor:`metadata-value-${c}`,className:"font-medium",children:"Value"}),e.jsx(ne,{id:`metadata-value-${c}`,type:"text",value:l.value,onChange:m=>o(c,"value",m.target.value),placeholder:"e.g., red, large, 2.5kg",className:"mt-2"})]}),e.jsx(D,{type:"button",variant:"destructive",className:"mt-8 min-w-[42px] h-[42px] p-0",onClick:()=>n(c),children:e.jsx(N.TrashIcon,{className:"w-4 h-4"})})]},l.id)),t.length===0&&e.jsx("p",{className:"text-sm text-gray-500 italic",children:"No metadata added yet. Click the button below to add key-value pairs."}),e.jsxs(D,{type:"button",variant:"secondary",onClick:i,className:"w-full shadow-none mt-2",children:[e.jsx(N.PlusIcon,{className:"w-4 h-4 mr-2"}),"Add Row"]})]})})]})})},Cm=({open:a,onClose:t,initialData:r,onSubmit:s})=>{const{defaultLocale:i,supportedLocales:n}=je(),o=U.useForm({resolver:fe.zodResolver(ai),defaultValues:r?{...r,defaultLocale:i}:{defaultLocale:i,translations:n.map(p=>({locale:p,title:""})),modifiers:[{title:"",price:0}]}}),{fields:l,append:c,remove:m}=U.useFieldArray({control:o.control,name:"modifiers"}),u=p=>{s(p),t(),o.reset({defaultLocale:i,translations:n.map(g=>({locale:g,title:""})),modifiers:[{title:"",price:0}]})};return e.jsx(Ra,{open:a,onOpenChange:t,children:e.jsxs(Fa,{className:"max-w-[710px]",children:[e.jsxs(Ma,{children:[e.jsx(Pa,{children:"New Modifier Group"}),e.jsx(Ut,{className:"text-sm mb-5",children:"Modifiers allow you to create different variants of the same product. Create or choose existing modifiers for your product."})]}),e.jsxs(U.FormProvider,{...o,children:[e.jsx(Te,{form:o,config:[{name:"title",label:"Group Title",type:"text",placeholder:'For example: "Spice Level" or "Select toppings".',colspan:2,localizable:!0},{name:"selectMin",label:"Select Min",type:"number",placeholder:"Minimum selections",colspan:1},{name:"selectMax",label:"Select Max",type:"number",placeholder:"Maximum selections",colspan:1}]}),e.jsx("h3",{className:"text-lg font-semibold mt-6",children:"Modifier Options"}),e.jsx("p",{className:"text-sm text-gray-500 mb-6 mt-1",children:"Add options to this modifier group. Modifier options are the different variants of the product. The price adds to the base price of the product. Leave the price as 0 if it's free."}),l.map((p,g)=>e.jsxs("div",{className:"mb-4 flex",children:[e.jsx(Te,{form:o,columns:2,config:[{name:`modifiers.${g}.title`,label:"Title",type:"text",placeholder:'eg: "Mild" or "Pepperoni"',colspan:1},{name:`modifiers.${g}.price`,label:"Price",type:"number",placeholder:"Price for this modifier",colspan:1,prefix:"USD"}]}),l.length>1&&e.jsx(D,{type:"button",variant:"destructive",className:"mt-auto ml-4 min-w-[42px] h-[42px] p-0! shadow-none!",onClick:()=>m(g),children:e.jsx(N.XIcon,{className:"w-4 h-4"})})]},p.id)),e.jsx(D,{type:"button",variant:"secondary",className:"mb-4 mt-4 ml-auto w-full shadow-none",onClick:()=>c({title:"",price:0}),children:"Add Another Option"}),e.jsx(Z,{className:"mt-8 mb-6"}),e.jsxs("div",{className:"flex justify-end space-x-3 mt-6 col-span-full",children:[e.jsx(D,{type:"button",className:"w-full sm:w-fit",variant:"secondary",onClick:t,children:"Cancel"}),e.jsx(D,{type:"button",className:"w-full sm:w-fit",onClick:o.handleSubmit(u),children:r?"Save Modifier Group":"Create Modifier Group"})]})]})]})})},Sm=({form:a})=>{const{control:t}=a,{defaultLocale:r}=je(),{fields:s,append:i,remove:n,update:o}=U.useFieldArray({control:t,name:"modifierGroups"}),[l,c]=x.useState(!1),[m,u]=x.useState(null),p=y=>({...y,defaultLocale:y.defaultLocale??r,modifiers:y.modifiers??[]}),g=y=>{y.preventDefault(),u(null),c(!0)},h=y=>{u(y),c(!0)},f=y=>{if(m===null){i(p(y)),c(!1);return}o(m,p(y)),c(!1)},b=()=>{i({defaultLocale:r,selectMin:1,selectMax:1,modifiers:[{title:"Łagodny (Mild)",sku:"null",price:0},{title:"Średni (Medium)",sku:"null",price:0},{title:"Ostry (Spicy)",sku:"null",price:0}],translations:[{locale:"en",title:"Spice Level"},{locale:"pl",title:"Ostrość"}]})};return e.jsxs("section",{"aria-labelledby":"product-modifiers",className:"min-h-[200px]",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"product-modifiers",className:"text-lg scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Product Modifiers (Optional)"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Modifiers allow you to create different variants of the same product. Create or choose existing modifiers for your product."})]}),e.jsx("div",{className:"md:col-span-2",children:s.length===0?e.jsxs("div",{className:"text-center flex-col justify-center items-center",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"No Modifier Groups"}),e.jsx("p",{className:"text-gray-500 max-w-[500px] mx-auto mt-1",children:"If your product has different options or variants, you can add modifier groups to manage them."}),e.jsxs("div",{className:"flex space-x-3 mx-auto w-min mt-6",children:[e.jsxs(D,{type:"button",variant:"secondary",className:"shadow-none",onClick:b,children:[e.jsx(N.BookCopyIcon,{className:"w-4 h-4 mr-2"})," Add From Template"]}),e.jsxs(D,{type:"button",variant:"secondary",className:"shadow-none",onClick:g,children:[e.jsx(N.PlusIcon,{className:"w-4 h-4 mr-2"})," Create Modifier Group"]})]})]}):e.jsxs("div",{className:"space-y-10",children:[e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsxs(D,{type:"button",variant:"secondary",className:"shadow-none",onClick:b,children:[e.jsx(N.BookCopyIcon,{className:"w-4 h-4 mr-2"})," Add From Template"]}),e.jsxs(D,{type:"button",variant:"secondary",className:"shadow-none",onClick:g,children:[e.jsx(N.PlusIcon,{className:"w-4 h-4 mr-2"})," Create Modifier Group"]})]}),e.jsx("div",{className:"space-y-4",children:s.map((y,j)=>{var v;return e.jsxs("div",{className:"p-4 border rounded-md",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-lg font-semibold",children:y.translations[0].title||"Unnamed Group"}),e.jsxs("div",{children:[e.jsx("button",{type:"button",onClick:()=>h(j),className:"text-blue-500 font-medium hover:underline text-sm mr-4",children:"Edit"}),e.jsx("button",{type:"button",onClick:()=>n(j),className:"text-red-500 font-medium hover:underline text-sm p-0!",children:"Remove"})]})]}),e.jsxs("p",{className:"text-sm text-gray-500 mt-3",children:["Min: ",y.selectMin," | Max: ",y.selectMax]}),e.jsxs("p",{className:"text-sm text-gray-500 mt-1",children:["Available Options:"," ",(v=y.modifiers)==null?void 0:v.map(k=>k==null?void 0:k.title).join(",")]})]},y.id)})})]})})]}),e.jsx(Cm,{open:l,initialData:m===null?null:s[m],onSubmit:f,onClose:()=>{c(!1),u(null)}},m)]})},zm=({form:a,loading:t})=>{const{defaultCurrency:r}=je(),s=[{name:"basePrice",label:"Base Price",type:"number",placeholder:"Enter base price",prefix:r},{name:"discountedBasePrice",label:"Discounted Price",type:"number",placeholder:"Enter discounted price",prefix:r},{name:"availableQuantity",label:"Available Quantity",type:"number",placeholder:"Leave blank for unlimited stock"}];return e.jsx("section",{"aria-labelledby":"product-information",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"product-information",className:"text-lg scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Pricing"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Enter the pricing details of your product, including the base price and discounted price."})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx(Te,{form:a,config:s,loading:t}),e.jsx("p",{className:"mt-3 text-xs text-gray-500",children:"Leave available quantity blank to keep inventory unlimited."})]})]})})},Pn=({initialData:a})=>{var b,y;const{client:t}=M(),r=E.useRouter(),s=_(),i=H(),{defaultCurrency:n,defaultLocale:o,supportedLocales:l}=je(),c=a==null?void 0:a.id,m=a?ol:nl,u=U.useForm({resolver:fe.zodResolver(m),defaultValues:a?{...a,defaultLocale:o,categories:(b=a.categories)==null?void 0:b.map(j=>j.id),translations:a.translations,images:a.images,metadata:a.metadata,modifierGroups:(y=a.modifierGroups)==null?void 0:y.map(j=>({...j,defaultLocale:o,translations:j.translations,modifiers:j.modifiers}))}:{defaultLocale:o,translations:l.map(j=>({locale:j})),currency:n}}),p=A.useMutation({mutationFn:async j=>{const{status:v}=await t.product.createProduct({params:{organizationId:i},body:j});if(v!==201)throw new Error("Failed to create product")}}),g=A.useMutation({mutationFn:async j=>{const{status:v}=await t.product.updateProduct({params:{organizationId:i,id:c},body:j});if(v!==200)throw new Error("Failed to update product")}}),h=async()=>{J.success("Product saved successfully"),r.push(s.products(i)),await oe.invalidateQueries({queryKey:["products"]}),c&&await oe.invalidateQueries({queryKey:["product",i,c]})},f=j=>{a?g.mutate(j,{onSuccess:h}):p.mutate(j,{onSuccess:h})};return e.jsx(U.FormProvider,{...u,children:e.jsxs("form",{onSubmit:u.handleSubmit(j=>f(j)),className:"space-y-14",children:[e.jsx(Nm,{form:u}),e.jsx(Z,{}),e.jsx(zm,{form:u}),e.jsx(Z,{}),e.jsx(Sm,{form:u}),e.jsx(Z,{}),e.jsx(Am,{form:u}),e.jsx(Z,{}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsxs(D,{type:"button",variant:"secondary",onClick:()=>r.push(s.products(i)),children:[e.jsx(N.ChevronLeft,{className:"w-4 h-4 mr-2"})," Cancel"]}),e.jsxs(D,{type:"submit",isLoading:p.isPending||g.isPending,loadingText:"Saving...",children:[e.jsx(N.CheckIcon,{className:"w-4 h-4 mr-2"})," ",a?"Save Product":"Create Product"]})]})]})})};function Im(){return e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-gray-900 sm:text-xl dark:text-gray-50",children:"Create Product"}),e.jsx(Z,{}),e.jsx("div",{className:"pt-6",children:e.jsx("div",{className:"space-y-10",children:e.jsx(Pn,{})})})]})}function Em(){const a=H(),t=ga(),{client:r}=M(),{data:s,isLoading:i}=A.useQuery({queryKey:["product",a,t],queryFn:async()=>{const{status:n,body:o}=await r.product.getProduct({params:{organizationId:a,id:t}});if(n!==200)throw J.error("Failed to load product"),new Error("Failed to fetch product");return o}});return e.jsxs("div",{className:"space-y-6",children:[e.jsx("h1",{className:"text-xl font-semibold text-gray-900 sm:text-2xl dark:text-gray-50",children:"Edit Product"}),e.jsx(Z,{}),i?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(pe,{className:"w-8 h-8"})}):e.jsx("div",{className:"pt-6",children:e.jsx(Pn,{initialData:s})})]})}const Ue=Se.createColumnHelper(),Bn=a=>{if(a==null||a==="")return null;const t=typeof a=="string"?Number.parseInt(a,10):a;return Number.isFinite(t)?t:null},Dm=({row:a,table:t})=>{var m;const{client:r}=M(),s=a.original.id,i=a.getValue("publishedAt"),n=(m=t.options.meta)==null?void 0:m.organizationId,o=t.options.meta.refetch,l=A.useMutation({mutationFn:async()=>{if((await r.product.updateStatus({params:{id:s,organizationId:n,operation:i?"unpublish":"publish"}})).status!==200)throw new Error("Failed to update product status");await o()}}),c=()=>{l.mutate()};return l.isPending?e.jsx("div",{className:"min-w-28",children:e.jsxs("button",{className:"relative my-2 inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-md border px-2 py-1 text-center text-sm font-medium shadow-xs transition-all duration-100 ease-in-out disabled:pointer-events-none disabled:shadow-none outline outline-offset-2 outline-0 focus-visible:outline-2 outline-blue-500 dark:outline-blue-500 border-gray-300 dark:border-gray-800 text-gray-900 dark:text-gray-50 bg-white dark:bg-gray-950 hover:bg-gray-50 dark:hover:bg-gray-900/60 disabled:text-gray-400 dark:disabled:text-gray-600","tremor-id":"tremor-raw",disabled:!0,children:[e.jsx(pe,{className:"w-4 h-4"})," Saving..."]})}):e.jsx("div",{className:"min-w-28",children:e.jsxs("button",{onClick:c,className:"relative my-2 inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-md border px-2 py-1 text-center text-sm font-medium shadow-xs transition-all duration-100 ease-in-out disabled:pointer-events-none disabled:shadow-none outline outline-offset-2 outline-0 focus-visible:outline-2 outline-blue-500 dark:outline-blue-500 border-gray-300 dark:border-gray-800 text-gray-900 dark:text-gray-50 bg-white dark:bg-gray-950 hover:bg-gray-50 dark:hover:bg-gray-900/60 disabled:text-gray-400 dark:disabled:text-gray-600","tremor-id":"tremor-raw",children:[i?e.jsx(N.CheckCircle,{className:"w-4 h-4 text-emerald-600 dark:text-emerald-500"}):e.jsx(N.EyeOffIcon,{className:"w-4 h-4 text-red-600 dark:text-red-500"}),i?"Published":"Draft"]})})},Rm=({row:a,table:t})=>{var y,j,v;const{client:r}=M(),s=a.original.id,i=Bn(a.original.availableQuantity),n=(y=t.options.meta)==null?void 0:y.organizationId,o=t.options.meta.refetch,[l,c]=x.useState(!1),[m,u]=x.useState(!1),[p,g]=x.useState(i==null?"":String(i));x.useEffect(()=>{m&&g(i==null?"":String(i))},[i,m]);const h=A.useMutation({mutationFn:async()=>{if((await r.product.deleteProduct({params:{id:s,organizationId:n}})).status!==204)throw new Error("Failed to delete product");await o()}}),f=A.useMutation({mutationFn:async()=>{const k=p.trim()===""?null:Number.parseInt(p,10);if(k!==null&&(!Number.isInteger(k)||k<0))throw new Error("Stock quantity must be a whole number greater than or equal to 0.");if((await r.product.updateProduct({params:{id:s,organizationId:n},body:{availableQuantity:k}})).status!==200)throw new Error("Failed to update product stock");await o(),u(!1)}}),b=()=>{window.confirm("Are you sure you want to delete this product? This action cannot be undone.")&&h.mutate()};return e.jsxs(e.Fragment,{children:[e.jsxs(sa,{open:l,onOpenChange:c,children:[e.jsx(ia,{asChild:!0,children:e.jsx(D,{variant:"ghost",className:"group aspect-square px-1.5 py-0! h-8! hover:border hover:border-gray-300 data-[state=open]:border-gray-300 data-[state=open]:bg-gray-50 dark:hover:border-gray-700 dark:data-[state=open]:border-gray-700 dark:data-[state=open]:bg-gray-900",disabled:h.isPending||f.isPending,children:h.isPending||f.isPending?e.jsx(pe,{className:"size-4 shrink-0"}):e.jsx(P.RiMoreFill,{className:"size-4 shrink-0 text-gray-500 group-hover:text-gray-700 group-data-[state=open]:text-gray-700 dark:group-hover:text-gray-300 dark:group-data-[state=open]:text-gray-300","aria-hidden":"true"})})}),e.jsxs(na,{align:"end",className:"min-w-40",children:[e.jsx(ze,{children:e.jsxs(B,{href:((v=(j=t.options.meta)==null?void 0:j.routes)==null?void 0:v.productEdit(n,s))??`/admin/${n}/products/${s}`,className:"block flex items-center gap-2",children:[e.jsx(N.PencilIcon,{className:"w-4 h-4"}),"Edit"]})}),e.jsx(ze,{className:"cursor-pointer",onSelect:()=>{c(!1),u(!0)},children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N.PackageIcon,{className:"w-4 h-4"}),"Update Stock"]})}),e.jsx(ze,{className:"text-red-600 dark:text-red-500 cursor-pointer",onClick:b,disabled:h.isPending,children:e.jsxs("div",{className:"flex items-center gap-2",children:[h.isPending?e.jsx(pe,{className:"w-4 h-4"}):e.jsx(N.Trash2,{className:"w-4 h-4"}),h.isPending?"Deleting...":"Delete"]})})]})]}),e.jsx(Ra,{open:m,onOpenChange:u,children:e.jsxs(Fa,{children:[e.jsxs(Ma,{children:[e.jsx(Pa,{children:"Update Stock"}),e.jsx(Ut,{children:"Leave this blank to keep the product inventory unlimited."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(le,{htmlFor:`stock-${s}`,children:"Available quantity"}),e.jsx(ne,{id:`stock-${s}`,type:"number",min:0,step:1,value:p,onChange:k=>g(k.target.value),placeholder:"Unlimited stock"})]}),e.jsxs(vr,{className:"mt-6",children:[e.jsx(D,{type:"button",variant:"secondary",onClick:()=>u(!1),children:"Cancel"}),e.jsx(D,{type:"button",onClick:()=>f.mutate(),isLoading:f.isPending,loadingText:"Saving...",children:"Save Stock"})]})]})})]})},js=({amount:a,fallbackCurrency:t})=>{var n;const{defaultLocale:r,organization:s}=je(),i=((n=s.data)==null?void 0:n.configuration.defaultCurrency)??t??"USD";return a==null?"-":we(a,i,r)},Fm=[Ue.display({id:"select",header:({table:a})=>e.jsx(Oe,{checked:a.getIsAllPageRowsSelected()?!0:a.getIsSomeRowsSelected()?"indeterminate":!1,onCheckedChange:()=>a.toggleAllPageRowsSelected(),className:"translate-y-0.5","aria-label":"Select all"}),cell:({row:a})=>e.jsx(Oe,{checked:a.getIsSelected(),onCheckedChange:()=>a.toggleSelected(),className:"translate-y-0.5","aria-label":"Select row"}),enableSorting:!1,enableHiding:!1,meta:{displayName:"Select"}}),Ue.accessor("title",{header:({column:a})=>e.jsx(V,{column:a,title:"Title"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"Title"},cell:({row:a,table:t})=>{var i,n,o;const r=(i=t.options.meta)==null?void 0:i.organizationId,s=a.original.id;return e.jsx(B,{href:((o=(n=t.options.meta)==null?void 0:n.routes)==null?void 0:o.productEdit(r,s))??`/admin/${r}/products/${s}`,className:"text-blue-500 hover:underline",children:a.getValue("title")||"-"})}}),Ue.accessor("sku",{header:({column:a})=>e.jsx(V,{column:a,title:"SKU"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"SKU"},cell:({row:a})=>a.getValue("sku")||"-"}),Ue.accessor("availableQuantity",{header:({column:a})=>e.jsx(V,{column:a,title:"Stock"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"Stock"},cell:({row:a})=>{const t=Bn(a.original.availableQuantity);return t===null?e.jsx(de,{variant:"neutral",children:"Unlimited"}):t===0?e.jsx(de,{variant:"warning",children:"Out of stock"}):e.jsx("span",{children:t})}}),Ue.accessor("basePrice",{header:({column:a})=>e.jsx(V,{column:a,title:"Base Price"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"Base Price"},cell:({row:a})=>{const t=a.getValue("basePrice");return e.jsx(js,{amount:t,fallbackCurrency:a.original.currency})}}),Ue.accessor("discountedBasePrice",{header:({column:a})=>e.jsx(V,{column:a,title:"Discounted Price"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"Discounted Price"},cell:({row:a})=>{const t=a.getValue("discountedBasePrice");return e.jsx(js,{amount:t,fallbackCurrency:a.original.currency})}}),Ue.accessor("publishedAt",{header:({column:a})=>e.jsx(V,{column:a,title:"Status"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"Slug"},cell:({row:a,table:t})=>e.jsx(Dm,{row:a,table:t})}),Ue.accessor("createdAt",{header:({column:a})=>e.jsx(V,{column:a,title:"Created At"}),enableSorting:!1,meta:{className:"text-left",displayName:"Created At"},cell:({row:a})=>{const t=a.getValue("createdAt");return new Date(t).toLocaleDateString()}}),Ue.display({id:"edit",header:"Edit",enableSorting:!1,enableHiding:!1,meta:{className:"text-right",displayName:"Edit"},cell:({row:a,table:t})=>e.jsx(Rm,{row:a,table:t})})],Mm=()=>{const{client:a}=M(),t=_(),{defaultLocale:r}=je(),s=H(),i=E.usePathname(),n=E.useRouter(),o=E.useSearchParams(),[l,c]=x.useState(""),[m,u]=x.useState("all"),[p,g]=x.useState("all"),[h]=Ke.useDebounce(l,300),f=Number((o==null?void 0:o.get("page"))||"1"),b=m==="all"?void 0:m,y=p==="all"?void 0:p,j=(S,Q)=>{const W=new URLSearchParams(o==null?void 0:o.toString());return W.set(S,Q),W.toString()},v=()=>{f!==1&&n.replace(`${i}?${j("page","1")}`)},{data:k=[]}=A.useQuery({queryKey:["productCategoriesFilter",s,r],queryFn:async()=>{const{body:S,status:Q}=await a.productCategory.getProductCategories({params:{organizationId:s},query:{limit:100,locale:r}});if(Q!==200)throw new Error("Failed to fetch product categories");return S.list.map(W=>({label:W.title||"Untitled category",value:W.id}))},placeholderData:[]}),{isLoading:C,isRefetching:F,isError:T,data:O,refetch:R}=A.useQuery({queryKey:["products",s,f,h,b,y,r],queryFn:async()=>{const{body:S,status:Q}=await a.product.getProducts({params:{organizationId:s},query:{page:f,limit:10,search:h,locale:r,categoryId:b,publishedStatus:y}});if(Q!==200)throw new Error("Failed to fetch products");return S},placeholderData:A.keepPreviousData});return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 sm:gap-x-6",children:[e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:w-fit sm:flex-row sm:items-center",children:[e.jsx(xa,{type:"search",placeholder:"Search products...",value:l,onChange:S=>{c(S.target.value),v()},className:"w-full sm:max-w-[250px] sm:[&>input]:h-[40px]"}),e.jsxs(bt,{value:m,onValueChange:S=>{u(S),v()},children:[e.jsx(vt,{className:"w-full sm:w-[220px]",children:e.jsx(jt,{placeholder:"All categories"})}),e.jsxs(wt,{children:[e.jsx(_e,{value:"all",children:"All categories"}),k.map(S=>e.jsx(_e,{value:S.value,children:S.label},S.value))]})]}),e.jsxs(bt,{value:p,onValueChange:S=>{g(S),v()},children:[e.jsx(vt,{className:"w-full sm:w-[190px]",children:e.jsx(jt,{placeholder:"All statuses"})}),e.jsxs(wt,{children:[e.jsx(_e,{value:"all",children:"All statuses"}),e.jsx(_e,{value:"published",children:"Published"}),e.jsx(_e,{value:"unpublished",children:"Unpublished"})]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(D,{asChild:!0,className:"hidden gap-x-2 px-2 py-1.5 text-sm sm:text-xs lg:flex",children:e.jsxs(B,{href:t.productCreate(s),children:["Create Product",e.jsx(N.PlusIcon,{className:"size-4 shrink-0","aria-hidden":"true"})]})})})]}),e.jsx(ha,{error:T,loading:C||F,meta:O!=null&&O.meta?{...O==null?void 0:O.meta,currentPage:f}:void 0,data:(O==null?void 0:O.list)||[],columns:Fm,className:"mt-8",refetch:R})]})};function Pm(){return e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-xl font-semibold text-gray-900 sm:text-2xl dark:text-gray-50",children:"Products"}),e.jsx("div",{className:"mt-4 sm:mt-6 lg:mt-6",children:e.jsx(Mm,{})})]})}const Tn=a=>a.options.meta??{},Bm=({organizationId:a,refetch:t,reservation:r})=>{const[s,i]=x.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>i(!0),className:"text-blue-500 hover:underline",children:String(r.id).slice(-5)}),e.jsx(wr,{open:s,onOpenChange:i,organizationId:a,reservation:r,refetch:t})]})},Tm=({reservation:a,table:t})=>{const r=Tn(t),s=(r==null?void 0:r.organizationId)||"",i=typeof(r==null?void 0:r.refetch)=="function"?r.refetch:()=>{};return e.jsx(mn,{organizationId:s,id:a.id,acceptedAt:a.acceptedAt,cancelledAt:a.cancelledAt,refetch:i})},Ze=Se.createColumnHelper(),Qm=[Ze.accessor("id",{header:({column:a})=>e.jsx(V,{column:a,title:"ID"}),meta:{className:"text-left",displayName:"ID"},cell:({row:a,table:t})=>{const r=Tn(t),s=(r==null?void 0:r.organizationId)||"",i=typeof(r==null?void 0:r.refetch)=="function"?r.refetch:()=>{};return e.jsx(Bm,{organizationId:s,refetch:i,reservation:a.original})},enableSorting:!0,enableHiding:!1}),Ze.accessor("referenceId",{header:({column:a})=>e.jsx(V,{column:a,title:"Reference ID"}),cell:({row:a})=>e.jsx("div",{className:"w-[100px]",children:a.getValue("referenceId")}),meta:{className:"text-left",displayName:"Reference ID"},enableSorting:!1,enableHiding:!1}),Ze.display({id:"customer",meta:{className:"text-left",displayName:"Customer"},header:({column:a})=>e.jsx(V,{column:a,title:"Customer"}),cell:({row:a})=>{const t=a.original.firstname||"",r=a.original.lastname||"";return e.jsx("div",{children:`${t} ${r}`.trim()||"N/A"})}}),Ze.accessor("guests",{meta:{className:"text-left",displayName:"Guests"},enableSorting:!0,enableHiding:!1,header:({column:a})=>e.jsx(V,{column:a,title:"Guests"}),cell:({row:a})=>e.jsx("div",{className:"font-medium",children:a.original.guests})}),Ze.accessor("phone",{meta:{className:"text-left",displayName:"Phone"},enableSorting:!1,enableHiding:!1,header:({column:a})=>e.jsx(V,{column:a,title:"Phone"}),cell:({row:a})=>e.jsx("div",{children:a.original.phone||"N/A"})}),Ze.accessor("date",{meta:{className:"text-left",displayName:"Reservation Date"},enableSorting:!0,enableHiding:!1,header:({column:a})=>e.jsx(V,{column:a,title:"Reservation Date"}),cell:({row:a})=>{const t=a.getValue("date");return t?I.format(new Date(t),"dd.MM.yyyy HH:mm"):"N/A"}}),Ze.accessor("createdAt",{meta:{className:"text-left",displayName:"Created At"},enableSorting:!0,enableHiding:!1,header:({column:a})=>e.jsx(V,{column:a,title:"Created At"}),cell:({row:a})=>{const t=a.getValue("createdAt");return t?I.format(new Date(t),"dd.MM.yyyy HH:mm"):"N/A"}}),Ze.display({id:"status",meta:{className:"text-left",displayName:"Status"},header:({column:a})=>e.jsx(V,{column:a,title:"Status"}),cell:({row:a})=>{const t=a.original.acceptedAt;return a.original.cancelledAt?e.jsx("div",{className:"text-red-600 font-medium",children:"Cancelled"}):t?e.jsx("div",{className:"text-green-600 font-medium",children:"Accepted"}):e.jsx("div",{className:"text-yellow-600 font-medium",children:"Pending"})}}),Ze.display({id:"actions",header:({column:a})=>e.jsx(V,{column:a,title:"Actions"}),cell:({row:a,table:t})=>e.jsx(Tm,{reservation:a.original,table:t})})];function Qn({options:a,value:t,onValueChange:r,className:s}){return e.jsx("div",{className:$("inline-flex items-center rounded-lg bg-gray-100 p-0.5 dark:bg-gray-900 w-min",s),children:a.map(i=>{const n=i.value===t;return e.jsx("button",{type:"button",onClick:()=>r(i.value),className:$("rounded-md px-2.5 py-1 text-xs font-medium transition-all duration-150",n?"bg-white text-gray-900 shadow-sm dark:bg-gray-800 dark:text-gray-50":"text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200"),children:i.label},i.value)})})}const st=1,Om=[{label:"Month",value:"month"},{label:"Week",value:"week"},{label:"Day",value:"day"}],Tr=a=>a.cancelledAt?"cancelled":a.acceptedAt?"accepted":"pending",Qr=a=>a==="accepted"?{badgeVariant:"success",dotClassName:"bg-emerald-500",label:"Accepted"}:a==="cancelled"?{badgeVariant:"error",dotClassName:"bg-red-500",label:"Cancelled"}:{badgeVariant:"warning",dotClassName:"bg-yellow-500",label:"Pending"},it=a=>I.format(a,"yyyy-MM-dd"),ka=a=>{if(!a.date)return null;const t=new Date(a.date);return Number.isNaN(t.getTime())?null:t},kt=(a,t)=>t==="day"?{from:I.startOfDay(a),to:I.endOfDay(a)}:t==="week"?{from:I.startOfWeek(a,{weekStartsOn:st}),to:I.endOfWeek(a,{weekStartsOn:st})}:{from:I.startOfWeek(I.startOfMonth(a),{weekStartsOn:st}),to:I.endOfWeek(I.endOfMonth(a),{weekStartsOn:st})},vs=(a,t,r)=>t==="day"?I.addDays(a,r):t==="week"?I.addWeeks(a,r):I.addMonths(a,r),Lm=(a,t)=>{if(t==="day")return I.format(a,"EEEE, d MMMM yyyy");if(t==="week"){const{from:r,to:s}=kt(a,t);return`${I.format(r,"d MMM")} - ${I.format(s,"d MMM yyyy")}`}return I.format(a,"MMMM yyyy")},Jm=({onOpen:a,reservation:t})=>{const r=ka(t),s=Tr(t),i=Qr(s);return r?e.jsxs("button",{type:"button",onClick:()=>a(t.id),className:"flex w-full items-center gap-1.5 rounded-md px-1.5 py-1 text-left text-[11px] leading-tight transition hover:bg-gray-100 dark:hover:bg-gray-800",children:[e.jsx("span",{className:$("size-1.5 shrink-0 rounded-full",i.dotClassName)}),e.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-100",children:I.format(r,"HH:mm")}),e.jsxs("span",{className:"truncate text-gray-500 dark:text-gray-400",children:[t.firstname," ",t.lastname]})]}):null},Vm=({onOpen:a,reservation:t})=>{const r=ka(t),s=Tr(t),i=Qr(s),n=t.guests===1?"guest":"guests";return r?e.jsxs("button",{type:"button",onClick:()=>a(t.id),className:"w-full rounded-lg border border-gray-200 bg-white p-3 text-left transition hover:border-gray-300 dark:border-gray-800 dark:bg-gray-950 dark:hover:border-gray-700",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:I.format(r,"HH:mm")}),e.jsxs("p",{className:"mt-0.5 text-sm font-medium text-gray-900 dark:text-gray-50",children:[t.firstname," ",t.lastname]})]}),e.jsx(de,{variant:i.badgeVariant,children:i.label})]}),e.jsxs("p",{className:"mt-1.5 text-xs text-gray-500 dark:text-gray-400",children:[t.guests," ",n," · Ref ",t.referenceId]})]}):null};function qm({currentDate:a,error:t,loading:r,onCurrentDateChange:s,onRetry:i,onViewChange:n,organizationId:o,reservations:l,refetch:c,view:m}){const[u,p]=x.useState(null),g=new Date,h=[...l].map(k=>({reservation:k,scheduledAt:ka(k)})).filter(k=>k.scheduledAt!==null).sort((k,C)=>k.scheduledAt.getTime()-C.scheduledAt.getTime()).map(k=>k.reservation),f=new Map;for(const k of h){const C=ka(k);if(!C)continue;const F=it(C),T=f.get(F)??[];T.push(k),f.set(F,T)}const b=h.find(k=>k.id===u)??null,y=()=>{var O;const{from:k,to:C}=kt(a,"month"),F=I.eachDayOfInterval({start:k,end:C}),T=[];for(let R=0;R<F.length;R+=7)T.push(F.slice(R,R+7));return e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("div",{className:"min-w-[700px]",children:[e.jsx("div",{className:"grid grid-cols-7 border-b border-gray-200 dark:border-gray-800",children:(O=T[0])==null?void 0:O.map(R=>e.jsx("div",{className:"px-2 py-2 text-center text-xs font-medium text-gray-500 dark:text-gray-400",children:I.format(R,"EEE")},R.toISOString()))}),e.jsx("div",{className:"grid grid-cols-7",children:T.flatMap(R=>R.map(S=>{const Q=f.get(it(S))??[],W=Math.max(Q.length-3,0);return e.jsxs("div",{className:$("min-h-[130px] border-b border-r border-gray-200 p-1.5 dark:border-gray-800",!I.isSameMonth(S,a)&&"bg-gray-50/50 dark:bg-gray-900/30"),children:[e.jsx("button",{type:"button",onClick:()=>{s(S),n("day")},className:$("mb-1 inline-flex size-7 items-center justify-center rounded-full text-xs font-medium transition-colors",I.isToday(S)?"bg-blue-600 text-white dark:bg-blue-500":I.isSameMonth(S,a)?"text-gray-900 hover:bg-gray-100 dark:text-gray-100 dark:hover:bg-gray-800":"text-gray-400 hover:bg-gray-100 dark:text-gray-500 dark:hover:bg-gray-800"),children:I.format(S,"d")}),e.jsxs("div",{className:"space-y-0.5",children:[Q.slice(0,3).map(ye=>e.jsx(Jm,{onOpen:p,reservation:ye},ye.id)),W>0?e.jsxs("button",{type:"button",onClick:()=>{s(S),n("day")},className:"w-full px-1.5 py-0.5 text-left text-[11px] font-medium text-gray-400 hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300",children:["+",W," more"]}):null]})]},S.toISOString())}))})]})})},j=()=>{const{from:k,to:C}=kt(a,"week"),F=I.eachDayOfInterval({start:k,end:C});return e.jsx("div",{className:"overflow-x-auto",children:e.jsx("div",{className:"grid min-w-[900px] auto-rows-fr grid-cols-7 gap-px overflow-hidden rounded-lg border border-gray-200 bg-gray-200 dark:border-gray-800 dark:bg-gray-800 min-h-[800px]",children:F.map(T=>{const O=f.get(it(T))??[];return e.jsxs("div",{className:$("flex min-h-[400px] flex-col bg-white p-3 dark:bg-gray-950",I.isToday(T)&&"bg-blue-50/30 dark:bg-blue-950/10"),children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:I.format(T,"EEE")}),e.jsx("p",{className:$("text-lg font-semibold",I.isToday(T)?"text-blue-600 dark:text-blue-400":"text-gray-900 dark:text-gray-50"),children:I.format(T,"d")})]}),e.jsx("div",{className:"flex-1 space-y-2",children:O.length===0?e.jsx("p",{className:"py-4 text-center text-xs text-gray-400 dark:text-gray-500",children:"No reservations"}):O.map(R=>{const S=ka(R),Q=Tr(R),W=Qr(Q),ye=R.guests===1?"guest":"guests";return S?e.jsxs("button",{type:"button",onClick:()=>p(R.id),className:"w-full rounded-md bg-gray-50 p-2 text-left transition hover:bg-gray-100 dark:bg-gray-900 dark:hover:bg-gray-800",children:[e.jsxs("div",{className:"flex items-start justify-between gap-1",children:[e.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:I.format(S,"HH:mm")}),e.jsx("span",{className:$("size-2 shrink-0 rounded-full mt-1",W.dotClassName)})]}),e.jsxs("p",{className:"mt-0.5 text-sm font-medium text-gray-900 dark:text-gray-50",children:[R.firstname," ",R.lastname]}),e.jsxs("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:[R.guests," ",ye]})]},R.id):null})})]},T.toISOString())})})})},v=()=>{const k=f.get(it(a))??h;return e.jsx("div",{className:"space-y-2",children:k.length===0?e.jsxs("div",{className:"rounded-lg border border-dashed border-gray-200 px-4 py-10 text-center dark:border-gray-800",children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-50",children:"No reservations scheduled"}),e.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:"Try another day or switch to the weekly or monthly view."})]}):k.map(C=>{const F=ka(C);return F?e.jsxs("div",{className:"flex gap-3 rounded-lg border border-gray-200 bg-white p-3 dark:border-gray-800 dark:bg-gray-950",children:[e.jsx("div",{className:"flex w-16 shrink-0 flex-col items-center justify-center rounded-md bg-gray-50 py-2 dark:bg-gray-900",children:e.jsx("p",{className:"text-lg font-semibold text-gray-900 dark:text-gray-50",children:I.format(F,"HH:mm")})}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(Vm,{onOpen:p,reservation:C})})]},C.id):null})})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-6 border-t pt-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{type:"button",className:"inline-flex size-7 items-center justify-center rounded-md text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-50",onClick:()=>s(vs(a,m,-1)),children:e.jsx(N.ChevronLeft,{className:"size-4","aria-hidden":"true"})}),e.jsx("button",{type:"button",className:"inline-flex size-7 items-center justify-center rounded-md text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-50",onClick:()=>s(vs(a,m,1)),children:e.jsx(N.ChevronRight,{className:"size-4","aria-hidden":"true"})})]}),e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-50",children:Lm(a,m)}),e.jsxs("div",{className:"flex items-center gap-2 sm:ml-auto",children:[e.jsx("button",{type:"button",className:"inline-flex h-7 items-center justify-center rounded-md border border-gray-200 px-2.5 text-xs font-medium text-gray-700 transition-colors hover:bg-gray-50 dark:border-gray-800 dark:text-gray-300 dark:hover:bg-gray-800",onClick:()=>s(g),children:"Today"}),e.jsx(Qn,{options:Om,value:m,onValueChange:n})]})]}),e.jsx("div",{className:"mt-4",children:t&&!r?e.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50/60 p-4 dark:border-red-950 dark:bg-red-950/20",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-gray-50",children:"Failed to load reservations"}),e.jsx("p",{className:"mt-0.5 text-sm text-gray-500 dark:text-gray-400",children:"Could not load reservations for this range."})]}),e.jsxs("button",{type:"button",onClick:()=>i(),className:"inline-flex items-center gap-2 rounded-lg border border-gray-200 bg-white px-3 py-2 text-sm font-medium text-gray-900 shadow-xs transition hover:bg-gray-50 dark:border-gray-800 dark:bg-gray-950 dark:text-gray-50 dark:hover:bg-gray-900",children:[e.jsx(P.RiRefreshLine,{className:"size-4","aria-hidden":"true"}),"Retry"]})]})}):r&&l.length===0?e.jsx("div",{className:"flex min-h-[300px] items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(pe,{className:"size-8"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Loading reservations..."})]})}):h.length===0?e.jsxs("div",{className:"rounded-lg border border-dashed border-gray-200 px-4 py-10 text-center dark:border-gray-800",children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-50",children:"No reservations found"}),e.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:"No bookings in this range. Try another date."})]}):m==="month"?y():m==="week"?j():v()})]}),b?e.jsx(wr,{open:!0,onOpenChange:k=>{k||p(null)},organizationId:o,reservation:b,refetch:c}):null]})}const Hm=100,Um=[{label:"Calendar",value:"calendar"},{label:"List",value:"list"}],Zm=()=>{var C,F;const{client:a}=M(),t=H(),r=E.usePathname(),s=E.useRouter(),i=E.useSearchParams(),[n,o]=x.useState(""),[l,c]=x.useState("calendar"),[m,u]=x.useState("week"),[p,g]=x.useState(()=>new Date),[h]=Ke.useDebounce(n,300),f=Number((i==null?void 0:i.get("page"))||"1"),b=kt(p,m),y=(T,O)=>{const R=new URLSearchParams(i==null?void 0:i.toString());return R.set(T,O),R.toString()},j=()=>{f!==1&&s.replace(`${r}?${y("page","1")}`)},v=A.useQuery({queryKey:["reservations",t,f,h],queryFn:async()=>{const{body:T,status:O}=await a.reservation.getReservations({params:{organizationId:t},query:{page:f,limit:10,search:h}});if(O!==200)throw new Error("Failed to fetch reservations");return T},enabled:l==="list",placeholderData:A.keepPreviousData}),k=A.useQuery({queryKey:["reservations-calendar",t,h,m,b.from.toISOString(),b.to.toISOString()],queryFn:async()=>{const T=async S=>{const{body:Q,status:W}=await a.reservation.getReservations({params:{organizationId:t},query:{page:S,limit:Hm,search:h,from:b.from.toISOString(),to:b.to.toISOString()}});if(W!==200)throw new Error("Failed to fetch reservations");return Q},O=await T(1);if(O.meta.pageCount<=1)return O.list;const R=await Promise.all(Array.from({length:O.meta.pageCount-1},(S,Q)=>T(Q+2)));return[O,...R].flatMap(S=>S.list)},enabled:l==="calendar",placeholderData:A.keepPreviousData});return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-end lg:justify-between",children:[e.jsx("div",{className:"flex w-full flex-col gap-3 sm:flex-row sm:items-center",children:e.jsx(xa,{type:"search",placeholder:"Search by name or reference...",value:n,onChange:T=>{o(T.target.value),j()},className:"w-full sm:max-w-[320px] sm:[&>input]:h-[40px]"})}),e.jsx(Qn,{options:Um,value:l,onValueChange:c})]}),l==="calendar"?e.jsx(qm,{currentDate:p,error:k.isError,loading:k.isLoading||k.isRefetching,onCurrentDateChange:g,onRetry:k.refetch,onViewChange:u,organizationId:t,reservations:k.data||[],refetch:k.refetch,view:m}):e.jsx(ha,{error:v.isError,loading:v.isLoading||v.isRefetching,meta:(C=v.data)!=null&&C.meta?{...v.data.meta,currentPage:f}:void 0,data:((F=v.data)==null?void 0:F.list)||[],columns:Qm,className:"mt-8",refetch:v.refetch})]})};function $m(){return e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"text-xl font-semibold text-gray-900 sm:text-2xl dark:text-gray-50",children:"Reservations List"}),e.jsx("div",{className:"mt-4 sm:mt-6 lg:mt-6",children:e.jsx(Zm,{})})]})}const _m=[{label:"Owner",value:"owner"},{label:"Admin",value:"admin"},{label:"Member",value:"member"}],On=({initialData:a})=>{const{client:t}=M(),r=E.useRouter(),s=_(),i=H(),n=!!a,o=n?Xo:Go,l=U.useForm({resolver:fe.zodResolver(o),defaultValues:n?{role:a.role}:{email:"",role:"member"}}),c=A.useMutation({mutationFn:async g=>{const{status:h}=await t.access.createInvitation({params:{organizationId:i},body:g});if(h!==201)throw new Error("Failed to create invitation")}}),m=A.useMutation({mutationFn:async g=>{const{status:h}=await t.access.updateMemberRole({params:{organizationId:i,memberId:a.id},body:g});if(h!==200)throw new Error("Failed to update member role")}}),u=async()=>{J.success(n?"Member role updated successfully":"Invitation sent successfully"),r.push(s.settingsAccess(i)),await oe.invalidateQueries({queryKey:["access-members"]}),await oe.invalidateQueries({queryKey:["access-invitations"]})},p=g=>{n?m.mutate({role:g.role},{onSuccess:u}):c.mutate(g,{onSuccess:u})};return e.jsx(U.FormProvider,{...l,children:e.jsxs("form",{onSubmit:l.handleSubmit(g=>p(g)),className:"space-y-14",children:[e.jsx("section",{"aria-labelledby":"access-information",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"access-information",className:"text-lg scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:n?"Edit Member Role":"Invite User"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:n?`Update the role for ${a.user.firstname} ${a.user.lastname}`:"Send an invitation to a new team member"})]}),e.jsxs("div",{className:"md:col-span-2",children:[n&&e.jsxs("div",{className:"mb-5",children:[e.jsx(le,{htmlFor:"member-email",className:"font-medium",children:"Email"}),e.jsx(ne,{id:"member-email",value:a.user.email,disabled:!0,readOnly:!0,className:"w-full mt-2"})]}),e.jsx(Te,{form:l,config:[...n?[]:[{name:"email",label:"Email",type:"email",placeholder:"user@example.com",colspan:2}],{name:"role",label:"Role",type:"select",options:_m,colspan:2}]})]})]})}),e.jsx(Z,{}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsxs(D,{type:"button",variant:"secondary",onClick:()=>r.push(s.settingsAccess(i)),children:[e.jsx(N.ChevronLeft,{className:"w-4 h-4 mr-2"})," Cancel"]}),e.jsxs(D,{type:"submit",isLoading:c.isPending||m.isPending,loadingText:"Saving...",children:[e.jsx(N.CheckIcon,{className:"w-4 h-4 mr-2"})," ",n?"Save Role":"Send Invitation"]})]})]})})};function Wm(){return e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-gray-900 sm:text-xl dark:text-gray-50",children:"Invite User"}),e.jsx(Z,{}),e.jsx("div",{className:"pt-6",children:e.jsx("div",{className:"space-y-10",children:e.jsx(On,{})})})]})}const Km=()=>{var u;const{client:a}=M(),t=H(),r=_(),s=E.useSearchParams(),[i]=x.useState(""),[n]=Ke.useDebounce(i,300),o=Number((s==null?void 0:s.get("page"))||"1"),l=A.useMutation({mutationFn:async p=>{const{status:g}=await a.access.deleteMember({params:{organizationId:t,memberId:p}});if(g!==204)throw new Error("Failed to remove member")},onSuccess:async()=>{J.success("Member removed successfully"),await oe.invalidateQueries({queryKey:["access-members"]})},onError:p=>{J.error((p==null?void 0:p.message)||"Failed to remove member")}}),{isLoading:c,data:m}=A.useQuery({queryKey:["access-members",t,o,n],queryFn:async()=>{const{body:p,status:g}=await a.access.getMembers({params:{organizationId:t},query:{page:o,limit:10,search:n}});if(g!==200)throw new Error("Failed to fetch members");return p},placeholderData:A.keepPreviousData});return c?e.jsx("div",{className:"flex items-center justify-center h-24 mt-4",children:e.jsx(pe,{className:"w-6 h-6"})}):(u=m==null?void 0:m.list)!=null&&u.length?e.jsx("ul",{className:"mt-4 divide-y divide-gray-200 dark:divide-gray-800",children:m.list.map(p=>{const g=p.user.firstname.charAt(0).toUpperCase()+p.user.lastname.charAt(0).toUpperCase();return e.jsxs("li",{className:"flex items-center justify-between gap-x-6 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-x-4 truncate",children:[e.jsx("span",{className:"hidden size-9 shrink-0 items-center justify-center rounded-full border border-gray-300 bg-white text-xs text-gray-700 sm:flex dark:border-gray-800 dark:bg-gray-950 dark:text-gray-300","aria-hidden":"true",children:g}),e.jsxs("div",{className:"truncate",children:[e.jsxs("p",{className:"truncate text-sm font-medium text-gray-900 dark:text-gray-50",children:[p.user.firstname," ",p.user.lastname]}),e.jsx("p",{className:"truncate text-xs text-gray-500",children:p.user.email})]})]}),e.jsxs("div",{className:"flex items-center gap-x-4",children:[e.jsx("span",{className:"inline-flex items-center rounded-md bg-gray-100 px-2 py-0.5 text-xs font-medium text-gray-600 dark:bg-gray-800 dark:text-gray-400",children:p.role.charAt(0).toUpperCase()+p.role.slice(1)}),e.jsx(B,{href:r.settingsAccessMemberEdit(t,p.id),className:"text-sm font-medium text-indigo-600 hover:text-indigo-500 dark:text-indigo-400 dark:hover:text-indigo-300",children:"Edit"}),e.jsx("button",{onClick:()=>l.mutate(p.id),disabled:l.isPending,className:"text-sm font-medium text-red-600 hover:text-red-500 dark:text-red-400 dark:hover:text-red-300 disabled:opacity-50",children:"Delete"})]})]},p.id)})}):e.jsx("p",{className:"text-sm text-gray-500 py-4 mt-4",children:"No members found."})},Gm=()=>{const{client:a}=M(),t=H(),{isLoading:r,data:s}=A.useQuery({queryKey:["access-invitations",t],queryFn:async()=>{const{body:n,status:o}=await a.access.getInvitations({params:{organizationId:t}});if(o!==200)throw new Error("Failed to fetch invitations");return n}}),i=A.useMutation({mutationFn:async n=>{const{status:o}=await a.access.deleteInvitation({params:{organizationId:t,invitationId:n}});if(o!==204)throw new Error("Failed to revoke invitation")},onSuccess:async()=>{J.success("Invitation revoked"),await oe.invalidateQueries({queryKey:["access-invitations",t]})},onError:n=>{J.error((n==null?void 0:n.message)||"Failed to revoke invitation")}});return r?e.jsx("div",{className:"flex items-center justify-center h-24",children:e.jsx(pe,{className:"w-6 h-6"})}):!s||s.length===0?e.jsx("p",{className:"text-sm text-gray-500 py-4",children:"No pending invitations."}):e.jsx("div",{className:"relative overflow-hidden overflow-x-auto",children:e.jsxs(kr,{children:[e.jsx(Nr,{children:e.jsxs(ua,{className:"border-y border-gray-200 dark:border-gray-800",children:[e.jsx(ma,{className:"whitespace-nowrap py-1 text-sm sm:text-xs",children:"Email"}),e.jsx(ma,{className:"whitespace-nowrap py-1 text-sm sm:text-xs",children:"Role"}),e.jsx(ma,{className:"whitespace-nowrap py-1 text-sm sm:text-xs",children:"Status"}),e.jsx(ma,{className:"whitespace-nowrap py-1 text-sm sm:text-xs",children:"Expires"}),e.jsx(ma,{className:"whitespace-nowrap py-1 text-sm sm:text-xs text-right",children:"Actions"})]})}),e.jsx(Ar,{children:s.map(n=>e.jsxs(ua,{className:"group select-none hover:bg-gray-50 dark:hover:bg-gray-900",children:[e.jsx($e,{className:"whitespace-nowrap py-1 text-gray-600 dark:text-gray-400",children:n.email}),e.jsx($e,{className:"whitespace-nowrap py-1 text-gray-600 dark:text-gray-400",children:e.jsx("span",{className:"inline-flex items-center rounded-md bg-gray-100 px-2 py-0.5 text-xs font-medium text-gray-600 dark:bg-gray-800 dark:text-gray-400",children:n.role?n.role.charAt(0).toUpperCase()+n.role.slice(1):"-"})}),e.jsx($e,{className:"whitespace-nowrap py-1 text-gray-600 dark:text-gray-400",children:e.jsx("span",{className:"inline-flex items-center rounded-md bg-yellow-50 px-2 py-0.5 text-xs font-medium text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400",children:n.status.charAt(0).toUpperCase()+n.status.slice(1)})}),e.jsx($e,{className:"whitespace-nowrap py-1 text-gray-600 dark:text-gray-400",children:new Date(n.expiresAt).toLocaleDateString()}),e.jsx($e,{className:"whitespace-nowrap py-1 text-right",children:e.jsx("button",{onClick:()=>i.mutate(n.id),disabled:i.isPending,className:"inline-flex items-center rounded-md p-1 text-gray-400 hover:text-red-600 hover:bg-red-50 dark:hover:text-red-400 dark:hover:bg-red-900/20 transition disabled:opacity-50",children:e.jsx(N.Trash2,{className:"w-4 h-4"})})})]},n.id))})]})})};function Xm(){const a=H(),t=_();return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"sm:flex sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Members"}),e.jsx("p",{className:"text-sm leading-6 text-gray-500",children:"Manage team members and their roles within your organization."})]}),e.jsx(D,{asChild:!0,className:"hidden gap-x-2 px-2 py-1.5 text-sm sm:text-xs lg:flex",children:e.jsxs(B,{href:t.settingsAccessInvite(a),children:["Invite User",e.jsx(N.PlusIcon,{className:"size-4 shrink-0","aria-hidden":"true"})]})})]}),e.jsx(Km,{}),e.jsxs("div",{className:"mt-12",children:[e.jsx("h3",{className:"scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Pending Invitations"}),e.jsx("p",{className:"text-sm leading-6 text-gray-500",children:"Invitations that have been sent but not yet accepted."}),e.jsx("div",{className:"mt-4",children:e.jsx(Gm,{})})]})]})}function Ym(){const a=H(),t=ga(),{client:r}=M(),{isLoading:s,data:i}=A.useQuery({queryKey:["access-members",a,t],queryFn:async()=>{const{status:n,body:o}=await r.access.getMember({params:{organizationId:a,memberId:t}});if(n!==200)throw J.error("Failed to fetch member. Please refresh or try again later."),new Error("Failed to fetch member");return o},throwOnError:!0,placeholderData:A.keepPreviousData});return e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-gray-900 sm:text-xl dark:text-gray-50",children:"Edit Member"}),e.jsx(Z,{}),e.jsx("div",{className:"pt-6",children:e.jsx("div",{className:"space-y-10",children:s||!i?e.jsx("div",{className:"flex justify-center items-center h-screen mt-5",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(pe,{className:"w-12 h-12"}),e.jsx("p",{className:"text-gray-500 text-sm mt-3",children:"Loading data..."})]})}):e.jsx(On,{initialData:i})})})]})}const Ln=[{type:"stripe",name:"Stripe",description:"Payments and webhook delivery",configurable:!0},{type:"resend",name:"Resend",description:"Transactional email delivery for orders and reservations",configurable:!0},{type:"wolt",name:"Wolt",description:"Marketplace and delivery sync",configurable:!1},{type:"payu",name:"PayU",description:"Alternative payments provider",configurable:!1}];function Or(a){return Ln.find(t=>t.type===a)}function Ja(a){var t;return((t=Or(a))==null?void 0:t.name)??a.split(/[-_]/).filter(Boolean).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}const eu=a=>{if(!a)return{label:"Available",variant:"warning"};if(a.type==="stripe"){const t=Et.safeParse(a.config);if(t.success)return t.data.hasSecretKey&&t.data.hasWebhookSecret?{label:"Configured",variant:"success"}:{label:"Needs setup",variant:"warning"}}if(a.type==="resend"){const t=Dt.safeParse(a.config);if(t.success)return t.data.hasApiKey&&t.data.fromEmail?{label:"Configured",variant:"success"}:{label:"Needs setup",variant:"warning"}}return{label:"Configured",variant:"success"}};function au(){const a=H(),t=_(),{client:r}=M(),s=A.useQuery({queryKey:["organization-integrations",a],queryFn:async()=>{const{body:i,status:n}=await r.integration.getIntegrations({params:{organizationId:a}});if(n!==200)throw new Error("Failed to load integrations");return i}});return e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-gray-900 sm:text-xl dark:text-gray-50",children:"Add Integration"}),e.jsx(Z,{}),e.jsx("div",{className:"pt-6",children:s.isLoading?e.jsx("div",{className:"flex h-32 items-center justify-center",children:e.jsx(pe,{className:"h-6 w-6"})}):s.isError?e.jsx("p",{className:"text-sm text-red-500",children:"Failed to load integration catalog."}):e.jsx("div",{className:"grid gap-5 md:grid-cols-2 xl:grid-cols-3",children:Ln.map(i=>{var l;const n=((l=s.data)==null?void 0:l.find(c=>c.type===i.type))??null,o=eu(n);return e.jsxs(Be,{className:"flex flex-col justify-between",children:[e.jsx("div",{children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-50",children:i.name}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:i.description})]}),e.jsx(de,{variant:i.configurable?o.variant:"neutral",children:i.configurable?o.label:"Coming soon"})]})}),e.jsx("div",{className:"mt-6",children:i.configurable?e.jsx(D,{asChild:!0,className:"w-full justify-center gap-2",children:e.jsxs(B,{href:t.settingsIntegration(a,i.type),children:[n?"Edit Integration":"Select",e.jsx(N.ArrowRightIcon,{className:"h-4 w-4"})]})}):e.jsx(D,{type:"button",variant:"secondary",className:"w-full justify-center",disabled:!0,children:"Not available yet"})})]},i.type)})})})]})}const tu=Ye.z.object({apiKey:Ye.z.string(),fromEmail:Ye.z.string().trim().email("Enter a valid sender email.")}),ru=a=>{const t=Dt.safeParse(a==null?void 0:a.config);return t.success?t.data:void 0};function su(){var g;const{client:a}=M(),t=H(),r=E.useRouter(),s=_(),i=U.useForm({resolver:fe.zodResolver(tu),defaultValues:{apiKey:"",fromEmail:""}}),n=((g=A.useQuery({queryKey:["organization-integrations",t],queryFn:async()=>{const{body:h,status:f}=await a.integration.getIntegrations({params:{organizationId:t}});if(f!==200)throw new Error("Failed to load integrations.");return h}}).data)==null?void 0:g.find(h=>h.type==="resend"))??null,o=ru(n),l=n?s.settingsIntegrations(t):s.settingsIntegrationsCreate(t),c=(n==null?void 0:n.updatedAt)??"new";x.useEffect(()=>{i.reset({apiKey:"",fromEmail:(o==null?void 0:o.fromEmail)??""})},[i,c]);const m=A.useMutation({mutationFn:async({apiKey:h,fromEmail:f})=>{var k;const b=h.trim(),y=f.trim(),j=hl.safeParse({apiKey:b||void 0,fromEmail:y||void 0});if(!j.success)throw new Error(((k=j.error.issues[0])==null?void 0:k.message)??"Invalid Resend configuration.");const{status:v}=await a.integration.upsertIntegration({params:{organizationId:t,type:"resend"},body:{config:j.data}});if(v!==200)throw new Error("Failed to update Resend integration.");await oe.invalidateQueries({queryKey:["organization-integrations",t]})},onSuccess:()=>{J.success("Resend integration updated."),r.push(s.settingsIntegrations(t))},onError:h=>{J.error(h.message||"Failed to update Resend integration.")}}),u=A.useMutation({mutationFn:async()=>{const{status:h}=await a.integration.deleteIntegration({params:{organizationId:t,type:"resend"}});if(h!==204)throw new Error("Failed to remove Resend integration.");await oe.invalidateQueries({queryKey:["organization-integrations",t]})},onSuccess:()=>{J.success("Resend integration removed."),r.push(s.settingsIntegrations(t))},onError:h=>{J.error(h.message||"Failed to remove Resend integration.")}}),p=h=>{if(i.clearErrors("apiKey"),!(o!=null&&o.hasApiKey)&&!h.apiKey.trim()){i.setError("apiKey",{type:"manual",message:"Resend API key is required."});return}m.mutate(h)};return e.jsxs("form",{onSubmit:i.handleSubmit(p),className:"space-y-14",children:[e.jsx("section",{"aria-labelledby":"resend-sender",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"resend-sender",className:"scroll-mt-10 text-lg font-semibold text-gray-900 dark:text-gray-50",children:"Sender Identity"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Use a verified sender address from your Resend account for order and reservation emails."})]}),e.jsx("div",{className:"space-y-5 md:col-span-2",children:e.jsxs("div",{children:[e.jsx(le,{htmlFor:"resend-from-email",children:"Sender Email"}),e.jsx(ne,{id:"resend-from-email",type:"email",className:"mt-2",placeholder:"orders@example.com",hasError:!!i.formState.errors.fromEmail,...i.register("fromEmail")}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-gray-500",children:"This address must be verified in Resend. The organization name is used automatically as the display name."}),i.formState.errors.fromEmail&&e.jsx("p",{className:"mt-2 text-sm text-red-500",children:i.formState.errors.fromEmail.message})]})})]})}),e.jsx(Z,{}),e.jsx("section",{"aria-labelledby":"resend-api-access",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"resend-api-access",className:"scroll-mt-10 text-lg font-semibold text-gray-900 dark:text-gray-50",children:"API Access"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Save the Resend API key used to deliver transactional emails for this organization."})]}),e.jsx("div",{className:"space-y-5 md:col-span-2",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(le,{htmlFor:"resend-api-key",children:"API Key"}),o!=null&&o.hasApiKey?e.jsx(de,{variant:"success",children:"Configured"}):e.jsx(de,{variant:"warning",children:"Required"})]}),e.jsx(ne,{id:"resend-api-key",type:"password",className:"mt-2",placeholder:o!=null&&o.hasApiKey?"Leave blank to keep the saved API key":"re_...",hasError:!!i.formState.errors.apiKey,...i.register("apiKey")}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-gray-500",children:"Saved API keys are never returned to the browser. Leave this blank to keep the currently stored key."}),i.formState.errors.apiKey&&e.jsx("p",{className:"mt-2 text-sm text-red-500",children:i.formState.errors.apiKey.message})]})})]})}),e.jsx(Z,{}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsxs(D,{type:"button",variant:"secondary",onClick:()=>r.push(l),children:[e.jsx(N.ChevronLeft,{className:"mr-2 h-4 w-4"})," Cancel"]}),n&&e.jsxs(D,{type:"button",variant:"secondary",className:"text-red-600 dark:text-red-400",onClick:()=>u.mutate(),isLoading:u.isPending,loadingText:"Removing...",children:[e.jsx(N.Trash2Icon,{className:"mr-2 h-4 w-4"})," Remove"]}),e.jsxs(D,{type:"submit",isLoading:m.isPending,loadingText:"Saving...",children:[e.jsx(N.CheckIcon,{className:"mr-2 h-4 w-4"})," Save Integration"]})]})]})}const iu=Ye.z.object({paymentMethods:Ye.z.array(Ye.z.enum(["card","blik"])),secretKey:Ye.z.string(),webhookSecret:Ye.z.string()}),nu=[{value:"card",label:"Card",description:"Visa, Mastercard, American Express and other card payments."},{value:"blik",label:"BLIK",description:"Popular one-time code payments in Poland."}],ou=a=>{const t=Et.safeParse(a==null?void 0:a.config);return t.success?t.data:void 0};function lu(){var y;const{client:a,baseUrl:t}=M(),r=H(),s=E.useRouter(),i=_(),n=`${t.replace(/\/$/,"")}/api/webhook/payment/stripe/${r}`,o=U.useForm({resolver:fe.zodResolver(iu),defaultValues:{paymentMethods:["card"],secretKey:"",webhookSecret:""}}),l=((y=A.useQuery({queryKey:["organization-integrations",r],queryFn:async()=>{const{body:j,status:v}=await a.integration.getIntegrations({params:{organizationId:r}});if(v!==200)throw new Error("Failed to load integrations.");return j}}).data)==null?void 0:y.find(j=>j.type==="stripe"))??null,c=ou(l),m=l?i.settingsIntegrations(r):i.settingsIntegrationsCreate(r),u=(l==null?void 0:l.updatedAt)??"new";x.useEffect(()=>{o.reset({paymentMethods:(c==null?void 0:c.paymentMethods)??["card"],secretKey:"",webhookSecret:""})},[o,u]);const p=A.useMutation({mutationFn:async({paymentMethods:j,secretKey:v,webhookSecret:k})=>{var R;const C=v.trim(),F=k.trim(),T=gl.safeParse({paymentMethods:j,secretKey:C||void 0,webhookSecret:F||void 0});if(!T.success)throw new Error(((R=T.error.issues[0])==null?void 0:R.message)??"Invalid Stripe configuration.");const{status:O}=await a.integration.upsertIntegration({params:{organizationId:r,type:"stripe"},body:{config:T.data}});if(O!==200)throw new Error("Failed to update Stripe integration.");await oe.invalidateQueries({queryKey:["organization-integrations",r]})},onSuccess:()=>{J.success("Stripe integration updated."),s.push(i.settingsIntegrations(r))},onError:j=>{J.error(j.message||"Failed to update Stripe integration.")}}),g=A.useMutation({mutationFn:async()=>{const{status:j}=await a.integration.deleteIntegration({params:{organizationId:r,type:"stripe"}});if(j!==204)throw new Error("Failed to remove Stripe integration.");await oe.invalidateQueries({queryKey:["organization-integrations",r]})},onSuccess:()=>{J.success("Stripe integration removed."),s.push(i.settingsIntegrations(r))},onError:j=>{J.error(j.message||"Failed to remove Stripe integration.")}}),h=o.watch("paymentMethods"),f=(j,v)=>{const k=o.getValues("paymentMethods"),C=v?Array.from(new Set([...k,j])):k.filter(F=>F!==j);o.setValue("paymentMethods",C,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0})},b=j=>{o.clearErrors(["secretKey","webhookSecret"]);let v=!1;!(c!=null&&c.hasSecretKey)&&!j.secretKey.trim()&&(o.setError("secretKey",{type:"manual",message:"Stripe API key is required."}),v=!0),!(c!=null&&c.hasWebhookSecret)&&!j.webhookSecret.trim()&&(o.setError("webhookSecret",{type:"manual",message:"Stripe webhook secret is required."}),v=!0),!v&&p.mutate(j)};return e.jsxs("form",{onSubmit:o.handleSubmit(b),className:"space-y-14",children:[e.jsx("section",{"aria-labelledby":"stripe-payment-methods",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"stripe-payment-methods",className:"scroll-mt-10 text-lg font-semibold text-gray-900 dark:text-gray-50",children:"Payment Methods"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Choose which Stripe payment methods should be available at checkout."})]}),e.jsx("div",{className:"space-y-4 md:col-span-2",children:nu.map(j=>e.jsxs("label",{className:"flex items-start gap-3 rounded-lg border border-gray-200 p-4 dark:border-gray-800",children:[e.jsx(Oe,{checked:h.includes(j.value),onCheckedChange:v=>f(j.value,v),className:"mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-50",children:j.label}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:j.description})]})]},j.value))})]})}),e.jsx(Z,{}),e.jsx("section",{"aria-labelledby":"stripe-api-access",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"stripe-api-access",className:"scroll-mt-10 text-lg font-semibold text-gray-900 dark:text-gray-50",children:"API Access"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Save the Stripe secret API key used to create checkout sessions."})]}),e.jsx("div",{className:"space-y-5 md:col-span-2",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(le,{htmlFor:"stripe-secret-key",children:"Secret API Key"}),c!=null&&c.hasSecretKey?e.jsx(de,{variant:"success",children:"Configured"}):e.jsx(de,{variant:"warning",children:"Required"})]}),e.jsx(ne,{id:"stripe-secret-key",type:"password",className:"mt-2",placeholder:c!=null&&c.hasSecretKey?"Leave blank to keep the saved API key":"sk_live_...",hasError:!!o.formState.errors.secretKey,...o.register("secretKey")}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-gray-500",children:"Saved API keys are never returned to the browser. Leave this blank to keep the currently stored key."}),o.formState.errors.secretKey&&e.jsx("p",{className:"mt-2 text-sm text-red-500",children:o.formState.errors.secretKey.message})]})})]})}),e.jsx(Z,{}),e.jsx("section",{"aria-labelledby":"stripe-webhooks",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"stripe-webhooks",className:"scroll-mt-10 text-lg font-semibold text-gray-900 dark:text-gray-50",children:"Stripe Webhooks"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Copy the endpoint into Stripe, then paste the webhook secret here to save it as the Stripe integration config."})]}),e.jsxs("div",{className:"space-y-5 md:col-span-2",children:[e.jsxs("div",{children:[e.jsx(le,{htmlFor:"stripe-webhook-endpoint",children:"Webhook Endpoint"}),e.jsx(ne,{id:"stripe-webhook-endpoint",value:n,disabled:!0,readOnly:!0,className:"mt-2",copyValue:n,copySuccessMessage:"Stripe webhook endpoint copied to clipboard.",copyErrorMessage:"Failed to copy Stripe webhook endpoint. Please try again."})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(le,{htmlFor:"stripe-webhook-secret",children:"Webhook Secret"}),c!=null&&c.hasWebhookSecret?e.jsx(de,{variant:"success",children:"Configured"}):e.jsx(de,{variant:"warning",children:"Required"})]}),e.jsx(ne,{id:"stripe-webhook-secret",type:"password",className:"mt-2",placeholder:c!=null&&c.hasWebhookSecret?"Leave blank to keep the saved webhook secret":"whsec_...",hasError:!!o.formState.errors.webhookSecret,...o.register("webhookSecret")}),e.jsxs("p",{className:"mt-2 text-sm leading-6 text-gray-500",children:["Stripe config is validated server-side for the"," ",e.jsx("code",{children:"stripe"})," integration type before it is saved. Saved secrets are never returned in API responses."]}),o.formState.errors.webhookSecret&&e.jsx("p",{className:"mt-2 text-sm text-red-500",children:o.formState.errors.webhookSecret.message})]})]})]})}),e.jsx(Z,{}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsxs(D,{type:"button",variant:"secondary",onClick:()=>s.push(m),children:[e.jsx(N.ChevronLeft,{className:"mr-2 h-4 w-4"})," Cancel"]}),l&&e.jsxs(D,{type:"button",variant:"secondary",className:"text-red-600 dark:text-red-400",onClick:()=>g.mutate(),isLoading:g.isPending,loadingText:"Removing...",children:[e.jsx(N.Trash2Icon,{className:"mr-2 h-4 w-4"})," Remove"]}),e.jsxs(D,{type:"submit",isLoading:p.isPending,loadingText:"Saving...",children:[e.jsx(N.CheckIcon,{className:"mr-2 h-4 w-4"})," Save Integration"]})]})]})}function du(){const a=ga(),t=H(),r=_(),s=E.useRouter(),i=Or(a);return a==="stripe"?e.jsxs("div",{children:[e.jsxs("h1",{className:"text-lg font-semibold text-gray-900 sm:text-xl dark:text-gray-50",children:[Ja(a)," Integration"]}),e.jsx(Z,{}),e.jsx("div",{className:"pt-6",children:e.jsx(lu,{})})]}):a==="resend"?e.jsxs("div",{children:[e.jsxs("h1",{className:"text-lg font-semibold text-gray-900 sm:text-xl dark:text-gray-50",children:[Ja(a)," Integration"]}),e.jsx(Z,{}),e.jsx("div",{className:"pt-6",children:e.jsx(su,{})})]}):e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-gray-900 sm:text-xl dark:text-gray-50",children:(i==null?void 0:i.name)??Ja(a)}),e.jsx(Z,{}),e.jsxs("div",{className:"pt-6",children:[e.jsx("p",{className:"text-sm leading-6 text-gray-500",children:"This integration does not have a configuration form yet."}),e.jsx("div",{className:"mt-6",children:e.jsx(D,{type:"button",variant:"secondary",onClick:()=>s.push(r.settingsIntegrationsCreate(t)),children:"Back to Integration Catalog"})})]})]})}const cu=a=>{if(a.type==="stripe"){const t=Et.safeParse(a.config);return t.success?!t.data.hasSecretKey||!t.data.hasWebhookSecret?"Stripe setup needs attention":t.data.paymentMethods.length===0?"Stripe is connected with no payment methods enabled":`Enabled methods: ${t.data.paymentMethods.map(r=>r==="blik"?"BLIK":"Card").join(", ")}`:"Stripe configuration saved"}if(a.type==="resend"){const t=Dt.safeParse(a.config);return t.success?t.data.hasApiKey?t.data.fromEmail?`Sender: ${t.data.fromEmail}`:"Resend sender email is missing":"Resend setup needs attention":"Resend configuration saved"}return"Configuration saved"},mu=a=>{if(a.type==="stripe"){const t=Et.safeParse(a.config);if(t.success)return t.data.hasSecretKey&&t.data.hasWebhookSecret?{label:"Configured",variant:"success"}:{label:"Needs setup",variant:"warning"}}if(a.type==="resend"){const t=Dt.safeParse(a.config);if(t.success)return t.data.hasApiKey&&t.data.fromEmail?{label:"Configured",variant:"success"}:{label:"Needs setup",variant:"warning"}}return{label:"Configured",variant:"success"}};function uu(){var n;const{client:a}=M(),t=H(),r=_(),s=A.useQuery({queryKey:["organization-integrations",t],queryFn:async()=>{const{body:o,status:l}=await a.integration.getIntegrations({params:{organizationId:t}});if(l!==200)throw new Error("Failed to fetch integrations");return o}}),i=A.useMutation({mutationFn:async o=>{const{status:l}=await a.integration.deleteIntegration({params:{organizationId:t,type:o}});if(l!==204)throw new Error("Failed to delete integration")},onSuccess:async()=>{J.success("Integration removed successfully"),await oe.invalidateQueries({queryKey:["organization-integrations",t]})},onError:o=>{J.error(o.message||"Failed to delete integration")}});return s.isLoading?e.jsx("div",{className:"mt-4 flex h-24 items-center justify-center",children:e.jsx(pe,{className:"h-6 w-6"})}):s.isError?e.jsx("p",{className:"mt-4 py-4 text-sm text-red-500",children:"Failed to load integrations."}):(n=s.data)!=null&&n.length?e.jsx("ul",{className:"mt-4 divide-y divide-gray-200 dark:divide-gray-800",children:s.data.map(o=>{const l=Or(o.type),c=Ja(o.type),m=mu(o);return e.jsxs("li",{className:"flex items-center justify-between gap-x-6 py-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-x-3",children:[e.jsx("p",{className:"truncate text-sm font-medium text-gray-900 dark:text-gray-50",children:c}),e.jsx(de,{variant:m.variant,children:m.label})]}),e.jsx("p",{className:"mt-1 truncate text-xs text-gray-500",children:cu(o)}),(l==null?void 0:l.description)&&e.jsx("p",{className:"mt-1 truncate text-xs text-gray-500",children:l.description}),e.jsxs("p",{className:"mt-1 truncate text-xs text-gray-500",children:["Updated ",new Date(o.updatedAt).toLocaleString()]})]}),e.jsxs("div",{className:"flex items-center gap-x-4",children:[e.jsx(B,{href:r.settingsIntegration(t,o.type),className:"text-sm font-medium text-indigo-600 hover:text-indigo-500 dark:text-indigo-400 dark:hover:text-indigo-300",children:"Edit"}),e.jsx("button",{type:"button",onClick:()=>i.mutate(o.type),disabled:i.isPending,className:"text-sm font-medium text-red-600 hover:text-red-500 disabled:opacity-50 dark:text-red-400 dark:hover:text-red-300",children:"Delete"})]})]},`${o.organizationId}:${o.type}`)})}):e.jsx("p",{className:"mt-4 py-4 text-sm text-gray-500",children:"No integrations configured yet."})}function pu(){const a=H(),t=_();return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"sm:flex sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Integrations"}),e.jsx("p",{className:"text-sm leading-6 text-gray-500",children:"Manage the integrations currently connected to your organization."})]}),e.jsx(D,{asChild:!0,className:"hidden gap-x-2 px-2 py-1.5 text-sm sm:text-xs lg:flex",children:e.jsxs(B,{href:t.settingsIntegrationsCreate(a),children:["Add Integration",e.jsx(N.PlusIcon,{className:"size-4 shrink-0","aria-hidden":"true"})]})})]}),e.jsx(uu,{})]})}const gu=[{name:"configuration.openingTimes.monday",label:"Monday",type:"time"},{name:"configuration.closingTimes.monday",label:"",type:"time"},{name:"configuration.openingTimes.tuesday",label:"Tuesday",type:"time"},{name:"configuration.closingTimes.tuesday",label:"",type:"time"},{name:"configuration.openingTimes.wednesday",label:"Wednesday",type:"time"},{name:"configuration.closingTimes.wednesday",label:"",type:"time"},{name:"configuration.openingTimes.thursday",label:"Thursday",type:"time"},{name:"configuration.closingTimes.thursday",label:"",type:"time"},{name:"configuration.openingTimes.friday",label:"Friday",type:"time"},{name:"configuration.closingTimes.friday",label:"",type:"time"},{name:"configuration.openingTimes.saturday",label:"Saturday",type:"time"},{name:"configuration.closingTimes.saturday",label:"",type:"time"},{name:"configuration.openingTimes.sunday",label:"Sunday",type:"time"},{name:"configuration.closingTimes.sunday",label:"",type:"time"},{name:"configuration.isAcceptingOrders",label:"Accepting Orders",type:"switch"},{name:"configuration.isAcceptingReservations",label:"Accepting Reservations",type:"switch"}],hu=({onClose:a,initialData:t})=>{var o,l,c,m,u,p,g;const{client:r}=M(),s=U.useForm({resolver:fe.zodResolver(cr),defaultValues:{configuration:{defaultLocale:(o=t==null?void 0:t.configuration)==null?void 0:o.defaultLocale,supportedLocales:(l=t==null?void 0:t.configuration)==null?void 0:l.supportedLocales,defaultCurrency:(c=t==null?void 0:t.configuration)==null?void 0:c.defaultCurrency,openingTimes:(m=t==null?void 0:t.configuration)==null?void 0:m.openingTimes,closingTimes:(u=t==null?void 0:t.configuration)==null?void 0:u.closingTimes,isAcceptingOrders:(p=t==null?void 0:t.configuration)==null?void 0:p.isAcceptingOrders,isAcceptingReservations:(g=t==null?void 0:t.configuration)==null?void 0:g.isAcceptingReservations}}}),{isPending:i,mutate:n}=A.useMutation({mutationFn:async({configuration:h})=>{const{status:f}=await r.organization.updateOrganization({params:{organizationId:t==null?void 0:t.id},body:{configuration:h}});if(f!==200)throw J.error("Failed to update organization. Please try again later."),new Error("Failed to update organization");return await oe.invalidateQueries({queryKey:["organizations"]}),a&&a()}});return e.jsx(Te,{form:s,config:gu,onSubmit:h=>n(h),onCancel:a,loading:i,cancelText:"Go back",okText:"Save Schedule"})};function xu(){const{organization:a}=je();return a.data?e.jsx("div",{className:"space-y-10",children:e.jsx("section",{"aria-labelledby":"opening-times",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"opening-times",className:"scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Opening and Closing Times"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Set the opening and closing times for your organization"})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsx(hu,{initialData:a.data})})]})})}):e.jsx("div",{children:"Loading..."})}const Jn=({initialData:a})=>{var p;const{client:t}=M(),r=E.useRouter(),s=_(),i=H(),n=a?vl:oi,o=U.useForm({resolver:fe.zodResolver(n),defaultValues:a?{title:a.title,providerName:a.providerName,providerLogoId:(p=a.providerLogo)==null?void 0:p.id,requireDateOfDelivery:a.requireDateOfDelivery,shippingZones:a.shippingZones}:{shippingZones:[{}]}}),l=A.useMutation({mutationFn:async g=>{const{status:h}=await t.shippingMethod.createShippingMethod({params:{organizationId:i},body:g});if(h!==201)throw J.error("Failed to create shipping method. Please try again later."),new Error("Failed to create shipping method")}}),c=A.useMutation({mutationFn:async g=>{const{status:h}=await t.shippingMethod.updateShippingMethod({params:{organizationId:i,id:a.id},body:g});if(h!==200)throw J.error("Failed to update shipping method. Please try again later."),new Error("Failed to update shipping method")}}),m=async()=>{J.success("Shipping method saved successfully"),r.push(s.settingsShippingMethods(i)),await oe.invalidateQueries({queryKey:["shipping-and-payment"]})},u=g=>{a?c.mutate(g,{onSuccess:m}):l.mutate(g,{onSuccess:m})};return e.jsx(U.FormProvider,{...o,children:e.jsxs("form",{onSubmit:o.handleSubmit(g=>u(g)),className:"space-y-14",children:[e.jsx("section",{"aria-labelledby":"Basic Information",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"product-information",className:"text-lg scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Basic Information"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Enter the information about your shipping method including title, shipping provider's name and logo"})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsx(Te,{form:o,config:[{name:"title",label:"Title",type:"text",placeholder:"Standard Shipping",colspan:2},{name:"providerName",label:"Provider Name",type:"text",placeholder:"FedEx",colspan:2},{name:"providerLogoId",label:"Provider Logo",type:"file"},{name:"requireDateOfDelivery",label:"Require Date of Delivery?",type:"switch",colspan:2}]})})]})}),e.jsx(Z,{}),e.jsx("section",{"aria-labelledby":"product-information",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"product-information",className:"text-lg scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Shipping Zones"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Set pricing and minimum order based on delivery zones"})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsx(Te,{form:o,config:[{name:"shippingZones",type:"array",fields:[{name:"title",label:"Title",type:"text",placeholder:"Zone 1"},{name:"distanceUpto",label:"Distance To (km)",type:"number",placeholder:"10"},{name:"price",label:"Shipping Price",type:"number",placeholder:"5.99",prefix:"USD"},{name:"minimumOrderAmount",label:"Minimum Order Amount",type:"number",placeholder:"50",prefix:"USD"},{name:"eta",label:"Estimated Time of Arrival",type:"text",placeholder:"2-3 days"}]}]})})]})}),e.jsx(Z,{}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsxs(D,{type:"button",variant:"secondary",onClick:()=>r.push(s.settingsShippingMethods(i)),children:[e.jsx(N.ChevronLeft,{className:"w-4 h-4 mr-2"})," Cancel"]}),e.jsxs(D,{type:"submit",isLoading:l.isPending||c.isPending,loadingText:"Saving...",children:[e.jsx(N.CheckIcon,{className:"w-4 h-4 mr-2"})," ",a?"Save Product":"Create Shipping Method"]})]})]})})};function fu(){return e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-gray-900 sm:text-xl dark:text-gray-50",children:"Create Shipping Method"}),e.jsx(Z,{}),e.jsx("div",{className:"pt-6",children:e.jsx("div",{className:"space-y-10",children:e.jsx(Jn,{})})})]})}function yu(){const a=H(),t=ga(),{client:r}=M(),{isLoading:s,data:i}=A.useQuery({queryKey:["shipping-and-payment",a,t],queryFn:async()=>{const{status:n,body:o}=await r.shippingMethod.getShippingMethod({params:{id:t,organizationId:a}});if(n!==200)throw J.error("Failed to fetch shipping method. Please refresh or try again later."),new Error("Failed to fetch shipping method");return o},throwOnError:!0,placeholderData:A.keepPreviousData});return e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-gray-900 sm:text-xl dark:text-gray-50",children:"Edit Shipping Method"}),e.jsx(Z,{}),e.jsx("div",{className:"pt-6",children:e.jsx("div",{className:"space-y-10",children:s||!i?e.jsx("div",{className:"flex justify-center items-center h-screen mt-5",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(pe,{className:"w-12 h-12"}),e.jsx("p",{className:"text-gray-500 text-sm mt-3",children:"Loading data..."})]})}):e.jsx(Jn,{initialData:i})})})]})}const ja=Se.createColumnHelper(),bu=[ja.display({id:"select",header:({table:a})=>e.jsx(Oe,{checked:a.getIsAllPageRowsSelected()?!0:a.getIsSomeRowsSelected()?"indeterminate":!1,onCheckedChange:()=>a.toggleAllPageRowsSelected(),className:"translate-y-0.5","aria-label":"Select all"}),cell:({row:a})=>e.jsx(Oe,{checked:a.getIsSelected(),onCheckedChange:()=>a.toggleSelected(),className:"translate-y-0.5","aria-label":"Select row"}),enableSorting:!1,enableHiding:!1,meta:{displayName:"Select"}}),ja.accessor("id",{header:({column:a})=>e.jsx(V,{column:a,title:"Id"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"ID"},cell:({row:a,table:t})=>{var s,i,n;const r=(s=t.options.meta)==null?void 0:s.organizationId;return e.jsx(B,{href:((n=(i=t.options.meta)==null?void 0:i.routes)==null?void 0:n.settingsShippingMethodEdit(r,a.getValue("id")))??`/admin/${r}/settings/shipping-methods/${a.getValue("id")}`,className:"text-blue-500",children:a.getValue("id")})}}),ja.accessor("title",{header:({column:a})=>e.jsx(V,{column:a,title:"Title"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"Title"}}),ja.accessor("providerName",{header:({column:a})=>e.jsx(V,{column:a,title:"Provider Name"}),enableSorting:!0,meta:{className:"text-left",displayName:"Provider Name"}}),ja.accessor("shippingZones",{header:({column:a})=>e.jsx(V,{column:a,title:"Shipping Zones"}),enableSorting:!1,meta:{className:"text-left",displayName:"Shipping Zones"},cell:({row:a})=>a.getValue("shippingZones").map(t=>t.title).join(", ")||"-"}),ja.display({id:"edit",header:"Edit",enableSorting:!1,enableHiding:!1,meta:{className:"text-right",displayName:"Edit"},cell:({row:a,table:t})=>{var s,i,n;const r=(s=t.options.meta)==null?void 0:s.organizationId;return e.jsxs(sa,{children:[e.jsx(ia,{asChild:!0,children:e.jsx(D,{variant:"ghost",className:"group aspect-square px-1.5 py-0! h-8! hover:border hover:border-gray-300 data-[state=open]:border-gray-300 data-[state=open]:bg-gray-50 dark:hover:border-gray-700 dark:data-[state=open]:border-gray-700 dark:data-[state=open]:bg-gray-900",children:e.jsx(P.RiMoreFill,{className:"size-4 shrink-0 text-gray-500 group-hover:text-gray-700 group-data-[state=open]:text-gray-700 dark:group-hover:text-gray-300 dark:group-data-[state=open]:text-gray-300","aria-hidden":"true"})})}),e.jsxs(na,{align:"end",className:"min-w-40",children:[e.jsx(ze,{children:e.jsx(B,{href:((n=(i=t.options.meta)==null?void 0:i.routes)==null?void 0:n.settingsShippingMethodEdit(r,a.getValue("id")))??`/admin/${r}/settings/shipping-methods/${a.getValue("id")}`,className:"block",children:"Edit"})}),e.jsx(ze,{className:"text-red-600 dark:text-red-500",children:"Delete"})]})]})}})],ju=()=>{const{client:a}=M(),t=H(),r=E.useSearchParams(),[s]=x.useState(""),[i]=Ke.useDebounce(s,300),n=Number((r==null?void 0:r.get("page"))||"1"),{isLoading:o,isRefetching:l,isError:c,data:m}=A.useQuery({queryKey:["shipping-and-payment",t,n,i],queryFn:async()=>{const{body:u,status:p}=await a.shippingMethod.getShippingMethods({params:{organizationId:t},query:{page:n,limit:10,search:i}});if(p!==200)throw new Error("Failed to fetch shipping methods");return u},placeholderData:A.keepPreviousData});return e.jsx("div",{children:e.jsx(ha,{error:c,loading:o||l,meta:m!=null&&m.meta?{...m==null?void 0:m.meta,currentPage:n}:void 0,data:(m==null?void 0:m.list)||[],columns:bu,className:"mt-8"})})};function vu(){const a=H(),t=_();return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"sm:flex sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{id:"existing-users",className:"scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Shipping Methods"}),e.jsx("p",{className:"text-sm leading-6 text-gray-500",children:"Set up delivery zones, pricing based on distance, and manage shipping methods and providers for your organization."})]}),e.jsx(D,{asChild:!0,className:"hidden gap-x-2 px-2 py-1.5 text-sm sm:text-xs lg:flex",children:e.jsxs(B,{href:t.settingsShippingMethodCreate(a),children:["Create Shipping Method",e.jsx(N.PlusIcon,{className:"size-4 shrink-0","aria-hidden":"true"})]})})]}),e.jsx(ju,{})]})}function Me({children:a}){const t=E.usePathname(),r=H(),s=_(),i=[{name:"General",href:s.settings(r)},{name:"Integrations",href:s.settingsIntegrations(r)},{name:"Shipping Methods",href:s.settingsShippingMethods(r)},{name:"Opening Times",href:s.settingsOpeningTimes(r)},{name:"Access",href:s.settingsAccess(r)},{name:"API Keys",href:`${s.settings(r)}/api-keys`}];return t!=null&&t.match(/\/settings\/shipping-methods\/[^/]+$/)||t!=null&&t.match(/\/settings\/access\/[^/]+$/)||t!=null&&t.match(/\/settings\/integrations\/[^/]+$/)?e.jsx("div",{children:a}):e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-gray-900 sm:text-2xl dark:text-gray-50",children:"Settings"}),e.jsx(Pr,{className:"mt-4 sm:mt-6 lg:mt-6",children:i.map(n=>e.jsx(Br,{asChild:!0,active:t===n.href,children:e.jsx(B,{href:n.href,children:n.name})},n.name))}),e.jsx("div",{className:"pt-6",children:a})]})}const wu=[{name:"configuration.defaultLocale",label:"Default Locale",type:"select",placeholder:"",options:Gr},{name:"configuration.supportedLocales",label:"Supported Locales",type:"select",placeholder:"Select locales",multiple:!0,options:Gr},{name:"configuration.defaultCurrency",label:"Currency",type:"select",placeholder:"Acme Inc.",options:qo}],ku=({onClose:a,initialData:t})=>{var o,l,c;const{client:r}=M(),s=U.useForm({resolver:fe.zodResolver(cr),defaultValues:{configuration:{defaultLocale:(o=t==null?void 0:t.configuration)==null?void 0:o.defaultLocale,supportedLocales:(l=t==null?void 0:t.configuration)==null?void 0:l.supportedLocales,defaultCurrency:(c=t==null?void 0:t.configuration)==null?void 0:c.defaultCurrency}}}),{isPending:i,mutate:n}=A.useMutation({mutationFn:async({configuration:m})=>{const{status:u}=await r.organization.updateOrganization({params:{organizationId:t==null?void 0:t.id},body:{configuration:m}});if(u!==200)throw J.error("Failed to update organization. Please try again later."),new Error("Failed to update organization");return await oe.invalidateQueries({queryKey:["organizations"]}),a&&a()}});return e.jsx(Te,{form:s,config:wu,onSubmit:m=>n(m),onCancel:a,loading:i,cancelText:"Go back",okText:"Save Settings"})};function Nu(){const{organization:a}=je(),{client:t}=M(),r=H(),s=E.useRouter(),i=_(),n=A.useMutation({mutationFn:async()=>{const{status:o}=await t.access.leaveOrganization({params:{organizationId:r}});if(o!==204)throw new Error("Failed to leave organization")},onSuccess:async()=>{J.success("You have left the organization"),await oe.invalidateQueries({queryKey:["organizations"]}),s.push(i.organizations)},onError:o=>{J.error((o==null?void 0:o.message)||"Failed to leave organization")}});return a.data?e.jsxs("div",{className:"space-y-10",children:[e.jsx("section",{"aria-labelledby":"org-information",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"org-information",className:"scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Organization Information"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Manage your organization information."})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsx(Dn,{initialData:a.data})})]})}),e.jsx(Z,{}),e.jsx("section",{"aria-labelledby":"locale-settings",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"locale-settings",className:"scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Currency and Locale"}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:"Set the currency and languages you support"})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsx(ku,{initialData:a.data})})]})}),e.jsx(Z,{}),e.jsx("section",{"aria-labelledby":"danger-zone",children:e.jsxs("div",{className:"grid grid-cols-1 gap-x-14 gap-y-8 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"danger-zone",className:"scroll-mt-10 font-semibold text-gray-900 dark:text-gray-50",children:"Danger zone"}),e.jsxs("p",{className:"mt-1 text-sm leading-6 text-gray-500",children:["Manage general workspace. Contact system admin for more information."," ",e.jsxs("a",{href:"#",className:"inline-flex items-center gap-1 text-indigo-600 hover:underline hover:underline-offset-4 dark:text-indigo-400",children:["Learn more",e.jsx(N.ExternalLinkIcon,{className:"size-4 shrink-0","aria-hidden":"true"})]})]})]}),e.jsx("div",{className:"space-y-6 md:col-span-2",children:e.jsx(Be,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-10",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-gray-50",children:"Leave workspace"}),e.jsx("p",{className:"mt-2 text-sm leading-6 text-gray-500",children:"Revoke your access to this team. Other people you have added to the workspace will remain."})]}),e.jsx(D,{variant:"secondary",className:"text-red-600 dark:text-red-500",onClick:()=>n.mutate(),isLoading:n.isPending,loadingText:"Leaving...",children:"Leave"})]})})})]})})]}):e.jsx("div",{children:"Loading..."})}function se(a,t){return{label:"Home",href:t.dashboard(a)}}function Au(a,t){switch(a.type){case"home":case"sign-in":case"sign-up":case"organizations":case"not-found":return[];case"dashboard":return[{label:"Home"}];case"orders":return[se(a.orgId,t),{label:"Orders"}];case"reservations":return[se(a.orgId,t),{label:"Reservations"}];case"customers":return[se(a.orgId,t),{label:"Customers"}];case"customer-detail":return[se(a.orgId,t),{label:"Customers",href:t.customers(a.orgId)},{label:"Customer Details"}];case"products-list":return[se(a.orgId,t),{label:"Products"}];case"product-create":return[se(a.orgId,t),{label:"Products",href:t.products(a.orgId)},{label:"Create Product"}];case"product-edit":return[se(a.orgId,t),{label:"Products",href:t.products(a.orgId)},{label:"Edit Product"}];case"product-categories-list":return[se(a.orgId,t),{label:"Product Categories"}];case"product-category-create":return[se(a.orgId,t),{label:"Product Categories",href:t.productCategories(a.orgId)},{label:"Create Product Category"}];case"product-category-edit":return[se(a.orgId,t),{label:"Product Categories",href:t.productCategories(a.orgId)},{label:"Edit Product Category"}];case"manufacturers-list":return[se(a.orgId,t),{label:"Manufacturers"}];case"manufacturer-create":return[se(a.orgId,t),{label:"Manufacturers",href:t.manufacturers(a.orgId)},{label:"Create Manufacturer"}];case"manufacturer-edit":return[se(a.orgId,t),{label:"Manufacturers",href:t.manufacturers(a.orgId)},{label:"Edit Manufacturer"}];case"settings":return[se(a.orgId,t),{label:"Settings"}];case"settings-opening-times":return[se(a.orgId,t),{label:"Settings",href:t.settings(a.orgId)},{label:"Opening Times"}];case"settings-integrations":return[se(a.orgId,t),{label:"Settings",href:t.settings(a.orgId)},{label:"Integrations"}];case"settings-integrations-create":return[se(a.orgId,t),{label:"Settings",href:t.settings(a.orgId)},{label:"Integrations",href:t.settingsIntegrations(a.orgId)},{label:"Add Integration"}];case"settings-integration":return[se(a.orgId,t),{label:"Settings",href:t.settings(a.orgId)},{label:"Integrations",href:t.settingsIntegrations(a.orgId)},{label:Ja(a.id)}];case"shipping-methods-list":return[se(a.orgId,t),{label:"Settings",href:t.settings(a.orgId)},{label:"Shipping Methods"}];case"shipping-method-create":return[se(a.orgId,t),{label:"Settings",href:t.settings(a.orgId)},{label:"Shipping Methods",href:t.settingsShippingMethods(a.orgId)},{label:"Create Shipping Method"}];case"shipping-method-edit":return[se(a.orgId,t),{label:"Settings",href:t.settings(a.orgId)},{label:"Shipping Methods",href:t.settingsShippingMethods(a.orgId)},{label:"Edit Shipping Method"}];case"access-list":return[se(a.orgId,t),{label:"Settings",href:t.settings(a.orgId)},{label:"Access"}];case"access-invite":return[se(a.orgId,t),{label:"Settings",href:t.settings(a.orgId)},{label:"Access",href:t.settingsAccess(a.orgId)},{label:"Invite User"}];case"access-member-edit":return[se(a.orgId,t),{label:"Settings",href:t.settings(a.orgId)},{label:"Access",href:t.settingsAccess(a.orgId)},{label:"Edit Member"}]}}function Cu({view:a}){const t=_(),r=Au(a,t);return r.length===0?null:e.jsx("nav",{"aria-label":"Breadcrumb",className:"mb-4 overflow-x-auto pb-1",children:e.jsx("ol",{className:"flex min-w-max items-center text-sm text-gray-500 dark:text-gray-400",children:r.map((s,i)=>{const n=i===r.length-1;return e.jsxs("li",{className:"flex items-center",children:[i>0?e.jsx(N.ChevronRightIcon,{className:"mx-1 size-3.5 shrink-0 text-gray-400 dark:text-gray-500","aria-hidden":"true"}):null,s.href&&!n?e.jsx(B,{href:s.href,className:"whitespace-nowrap rounded-sm transition hover:text-gray-900 dark:hover:text-gray-200",children:s.label}):e.jsx("span",{"aria-current":n?"page":void 0,className:n?"whitespace-nowrap font-medium text-gray-900 dark:text-gray-50":"whitespace-nowrap",children:s.label})]},`${s.label}-${i}`)})})})}const Su=()=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:451,zoomAndPan:"magnify",viewBox:"0 0 338.25 101.249998",height:135,preserveAspectRatio:"xMidYMid meet",className:"h-auto w-3/4 mr-5 text-[#15203a] dark:text-white",children:[e.jsxs("defs",{children:[e.jsx("filter",{x:"0%",y:"0%",width:"100%",height:"100%",id:"e96f145012",children:e.jsx("feColorMatrix",{values:"0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0",colorInterpolationFilters:"sRGB"})}),e.jsx("g",{}),e.jsx("clipPath",{id:"2854c0f5ba",children:e.jsx("path",{d:"M 280.070312 29.789062 L 335.910156 29.789062 L 335.910156 85.628906 L 280.070312 85.628906 Z M 280.070312 29.789062 ",clipRule:"nonzero"})}),e.jsx("clipPath",{id:"a2b4eafd05",children:e.jsx("path",{d:"M 312.023438 83.421875 L 333.382812 62.0625 C 335.910156 59.535156 335.910156 55.460938 333.382812 52.933594 L 312.285156 31.835938 C 310.859375 30.410156 308.949219 29.632812 306.941406 29.632812 L 280.46875 29.632812 L 303.773438 52.933594 C 306.296875 55.460938 306.296875 59.535156 303.773438 62.0625 L 280.210938 85.621094 L 306.683594 85.621094 C 308.691406 85.621094 310.601562 84.8125 312.023438 83.421875 Z M 312.023438 83.421875 ",clipRule:"nonzero"})}),e.jsx("image",{x:0,y:0,width:57,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADkAAAA5CAYAAACMGIOFAAAABmJLR0QA/wD/AP+gvaeTAAAAdElEQVRoge3PMQqEQBAAwXVB//9kEwMD9eAwKrthYGBgoJZx3xxjrMdsp/1qft3f+PHvfc4HJFNIpZBKIZVCKoVUCqkUUimkUkilkEohlUIqhVQKqRRSKaRSSKWQSiGVQiqFVAqpFFIppFJIpZBKIZU+gdwB24gBccg7AIAAAAAASUVORK5CYII=",id:"c594f9d06d",height:57,preserveAspectRatio:"xMidYMid meet"}),e.jsx("mask",{id:"1f1a4971c6",children:e.jsx("g",{filter:"url(#e96f145012)",children:e.jsx("g",{children:e.jsx("image",{x:0,y:0,width:57,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADkAAAA5CAYAAACMGIOFAAAABmJLR0QA/wD/AP+gvaeTAAAAdElEQVRoge3PMQqEQBAAwXVB//9kEwMD9eAwKrthYGBgoJZx3xxjrMdsp/1qft3f+PHvfc4HJFNIpZBKIZVCKoVUCqkUUimkUkilkEohlUIqhVQKqRRSKaRSSKWQSiGVQiqFVAqpFFIppFJIpZBKIZU+gdwB24gBccg7AIAAAAAASUVORK5CYII=",height:57,preserveAspectRatio:"xMidYMid meet"})})})}),e.jsx("clipPath",{id:"d584d4a10b",children:e.jsx("rect",{x:0,width:57,y:0,height:57})}),e.jsx("pattern",{id:"ca59399d09",patternUnits:"userSpaceOnUse",width:57,patternTransform:"matrix(0.992647, 0, 0, -0.992647, 279.805145, 86.320587)",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 57 57",height:57,x:0,y:0,children:e.jsx("g",{children:e.jsx("g",{clipPath:"url(#d584d4a10b)",children:e.jsx("g",{mask:"url(#1f1a4971c6)",children:e.jsx("rect",{x:"-356.844005",width:"490.68801",fill:"#8c52ff",height:"146.88",y:"-37.48",fillOpacity:1})})})})}),e.jsx("clipPath",{id:"058149a1c1",children:e.jsx("path",{d:"M 271.277344 20.996094 L 327 20.996094 L 327 76.832031 L 271.277344 76.832031 Z M 271.277344 20.996094 ",clipRule:"nonzero"})}),e.jsx("clipPath",{id:"3a8b0dae6b",children:e.jsx("path",{d:"M 303.230469 74.625 L 324.589844 53.265625 C 327.113281 50.742188 327.113281 46.664062 324.589844 44.140625 L 303.488281 23.039062 C 302.0625 21.613281 300.15625 20.839844 298.148438 20.839844 L 271.675781 20.839844 L 294.976562 44.140625 C 297.5 46.664062 297.5 50.742188 294.976562 53.265625 L 271.414062 76.824219 L 297.890625 76.824219 C 299.894531 76.824219 301.804688 76.015625 303.230469 74.625 Z M 303.230469 74.625 ",clipRule:"nonzero"})}),e.jsx("image",{x:0,y:0,width:57,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADkAAAA5CAYAAACMGIOFAAAABmJLR0QA/wD/AP+gvaeTAAAAbklEQVRoge3PwQmAAAwEwaho/yVbgfrQ17gLeR0EZpnrlpk5Zma/ubf7Fz+e9m29QTKFVAqpFFIppFJIpZBKIZVCKoVUCqkUUimkUkilkEohlUIqhVQKqRRSKaRSSKWQSiGVQiqFVAqpFFLpF8gT2vQBcSod/NEAAAAASUVORK5CYII=",id:"85d98eb3ed",height:57,preserveAspectRatio:"xMidYMid meet"}),e.jsx("mask",{id:"712d9ec0cc",children:e.jsx("g",{filter:"url(#e96f145012)",children:e.jsx("g",{children:e.jsx("image",{x:0,y:0,width:57,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADkAAAA5CAYAAACMGIOFAAAABmJLR0QA/wD/AP+gvaeTAAAAbklEQVRoge3PwQmAAAwEwaho/yVbgfrQ17gLeR0EZpnrlpk5Zma/ubf7Fz+e9m29QTKFVAqpFFIppFJIpZBKIZVCKoVUCqkUUimkUkilkEohlUIqhVQKqRRSKaRSSKWQSiGVQiqFVAqpFFLpF8gT2vQBcSod/NEAAAAASUVORK5CYII=",height:57,preserveAspectRatio:"xMidYMid meet"})})})}),e.jsx("clipPath",{id:"66291c0f48",children:e.jsx("rect",{x:0,width:57,y:0,height:57})}),e.jsx("pattern",{id:"82194e6edc",patternUnits:"userSpaceOnUse",width:57,patternTransform:"matrix(0.992647, 0, 0, -0.992647, 270.871322, 77.386763)",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 57 57",height:57,x:0,y:0,children:e.jsx("g",{children:e.jsx("g",{clipPath:"url(#66291c0f48)",children:e.jsx("g",{mask:"url(#712d9ec0cc)",children:e.jsx("rect",{x:"-347.844005",width:"490.68801",fill:"#8c52ff",height:"146.88",y:"-46.48",fillOpacity:1})})})})})]}),e.jsx("g",{fill:"currentColor",fillOpacity:1,children:e.jsx("g",{transform:"translate(19.705917, 70.793676)",children:e.jsx("g",{children:e.jsx("path",{d:"M 16.359375 0.0625 C 13.921875 0.0625 11.773438 -0.289062 9.921875 -1 C 8.441406 -1.59375 6.925781 -2.570312 5.375 -3.9375 C 3.601562 -5.5625 2.476562 -7.578125 2 -9.984375 C 1.8125 -10.753906 1.71875 -11.53125 1.71875 -12.3125 C 1.675781 -12.570312 1.675781 -12.832031 1.71875 -13.09375 L 1.71875 -13.46875 L 9.3125 -13.359375 L 9.3125 -13.421875 C 9.3125 -12.054688 9.609375 -10.925781 10.203125 -10.03125 C 11.304688 -8.375 13.359375 -7.546875 16.359375 -7.546875 C 21.160156 -7.546875 23.5625 -8.671875 23.5625 -10.921875 C 23.5625 -13.109375 21.085938 -14.476562 16.140625 -15.03125 C 13.285156 -15.363281 10.84375 -15.953125 8.8125 -16.796875 C 6.925781 -17.578125 5.394531 -18.613281 4.21875 -19.90625 C 2.550781 -21.757812 1.71875 -23.90625 1.71875 -26.34375 C 1.71875 -27.851562 1.992188 -29.273438 2.546875 -30.609375 C 2.953125 -31.609375 3.507812 -32.515625 4.21875 -33.328125 C 6.800781 -36.242188 10.90625 -37.703125 16.53125 -37.703125 C 19.894531 -37.703125 22.738281 -37.039062 25.0625 -35.71875 C 26.832031 -34.71875 28.273438 -33.382812 29.390625 -31.71875 C 30.203125 -30.457031 30.773438 -29.015625 31.109375 -27.390625 C 31.222656 -26.835938 31.296875 -26.285156 31.328125 -25.734375 C 31.367188 -25.546875 31.390625 -25.359375 31.390625 -25.171875 L 31.390625 -24.84375 L 23.796875 -24.84375 L 23.796875 -24.78125 C 23.828125 -25.894531 23.546875 -26.835938 22.953125 -27.609375 C 21.773438 -29.273438 19.632812 -30.109375 16.53125 -30.109375 C 14.644531 -30.109375 13.085938 -29.867188 11.859375 -29.390625 C 10.347656 -28.796875 9.59375 -27.945312 9.59375 -26.84375 C 9.59375 -24.550781 12.050781 -23.125 16.96875 -22.5625 C 22.507812 -21.9375 26.503906 -20.21875 28.953125 -17.40625 C 30.578125 -15.488281 31.390625 -13.328125 31.390625 -10.921875 L 31.390625 -10.421875 C 31.390625 -10.203125 31.367188 -9.984375 31.328125 -9.765625 C 31.296875 -9.171875 31.222656 -8.613281 31.109375 -8.09375 C 30.734375 -6.613281 30.03125 -5.300781 29 -4.15625 C 27.78125 -2.789062 26.132812 -1.738281 24.0625 -1 C 22 -0.289062 19.429688 0.0625 16.359375 0.0625 Z M 16.359375 0.0625 "})})})}),e.jsx("g",{fill:"currentColor",fillOpacity:1,children:e.jsx("g",{transform:"translate(52.748732, 70.793676)",children:e.jsx("g",{children:e.jsx("path",{d:"M 30.78125 0 L 23.5625 0 L 23.5625 -14.078125 L 23.515625 -14.078125 L 23.515625 -14.25 C 23.515625 -16.175781 22.828125 -17.820312 21.453125 -19.1875 C 20.085938 -20.550781 18.425781 -21.234375 16.46875 -21.234375 C 14.550781 -21.234375 12.890625 -20.53125 11.484375 -19.125 C 10.078125 -17.726562 9.410156 -16.066406 9.484375 -14.140625 L 9.484375 -14.078125 L 9.421875 -14.078125 L 9.421875 0 L 1.65625 0 L 1.65625 -36.046875 L 9.421875 -36.046875 L 9.421875 -24.953125 C 11.160156 -27.023438 13.492188 -28.191406 16.421875 -28.453125 C 20.484375 -28.785156 23.84375 -27.726562 26.5 -25.28125 C 29.351562 -22.65625 30.78125 -18.976562 30.78125 -14.25 Z M 30.78125 0 "})})})}),e.jsx("g",{fill:"currentColor",fillOpacity:1,children:e.jsx("g",{transform:"translate(85.181699, 70.793676)",children:e.jsx("g",{children:e.jsx("path",{d:"M 14.8125 -28.5625 C 18.757812 -28.59375 22.117188 -27.222656 24.890625 -24.453125 C 27.703125 -21.640625 29.109375 -18.273438 29.109375 -14.359375 C 29.148438 -10.398438 27.785156 -7.035156 25.015625 -4.265625 C 22.234375 -1.460938 18.882812 -0.0390625 14.96875 0 C 11.007812 0.0390625 7.628906 -1.328125 4.828125 -4.109375 C 2.015625 -6.878906 0.609375 -10.242188 0.609375 -14.203125 C 0.566406 -18.148438 1.9375 -21.507812 4.71875 -24.28125 C 7.488281 -27.09375 10.851562 -28.519531 14.8125 -28.5625 Z M 19.859375 -9.3125 C 21.222656 -10.6875 21.90625 -12.351562 21.90625 -14.3125 C 21.90625 -16.226562 21.203125 -17.890625 19.796875 -19.296875 C 18.390625 -20.628906 16.726562 -21.296875 14.8125 -21.296875 C 12.882812 -21.296875 11.238281 -20.613281 9.875 -19.25 C 8.5 -17.800781 7.8125 -16.132812 7.8125 -14.25 C 7.8125 -12.332031 8.515625 -10.671875 9.921875 -9.265625 C 11.296875 -7.890625 12.960938 -7.203125 14.921875 -7.203125 C 16.910156 -7.273438 18.554688 -7.976562 19.859375 -9.3125 Z M 19.859375 -9.3125 "})})})}),e.jsx("g",{fill:"currentColor",fillOpacity:1,children:e.jsx("g",{transform:"translate(114.89805, 70.793676)",children:e.jsx("g",{children:e.jsx("path",{d:"M 16.53125 -28.5625 C 20.445312 -28.59375 23.8125 -27.222656 26.625 -24.453125 C 29.425781 -21.679688 30.847656 -18.316406 30.890625 -14.359375 C 30.921875 -10.441406 29.550781 -7.078125 26.78125 -4.265625 C 24.007812 -1.460938 20.644531 -0.0390625 16.6875 0 C 13.46875 0 11.046875 -1.015625 9.421875 -3.046875 L 9.421875 10.640625 L 1.65625 10.640625 L 1.65625 -28.5 L 9.421875 -28.5 L 9.421875 -25.515625 C 10.941406 -27.472656 13.3125 -28.488281 16.53125 -28.5625 Z M 21.625 -9.3125 C 23.03125 -10.71875 23.695312 -12.382812 23.625 -14.3125 C 23.625 -16.269531 22.941406 -17.929688 21.578125 -19.296875 C 20.171875 -20.628906 18.503906 -21.296875 16.578125 -21.296875 C 14.617188 -21.296875 12.957031 -20.613281 11.59375 -19.25 C 10.21875 -17.800781 9.53125 -16.132812 9.53125 -14.25 C 9.613281 -12.25 10.316406 -10.585938 11.640625 -9.265625 C 13.015625 -7.890625 14.679688 -7.203125 16.640625 -7.203125 C 18.628906 -7.273438 20.289062 -7.976562 21.625 -9.3125 Z M 21.625 -9.3125 "})})})}),e.jsx("g",{fill:"currentColor",fillOpacity:1,children:e.jsx("g",{transform:"translate(146.665722, 70.793676)",children:e.jsx("g",{children:e.jsx("path",{d:"M 30.78125 0 L 23.5625 0 L 23.5625 -14.078125 L 23.515625 -14.078125 L 23.515625 -14.25 C 23.515625 -16.175781 22.828125 -17.820312 21.453125 -19.1875 C 20.085938 -20.550781 18.425781 -21.234375 16.46875 -21.234375 C 14.550781 -21.234375 12.890625 -20.53125 11.484375 -19.125 C 10.078125 -17.726562 9.410156 -16.066406 9.484375 -14.140625 L 9.484375 -14.078125 L 9.421875 -14.078125 L 9.421875 0 L 1.65625 0 L 1.65625 -36.046875 L 9.421875 -36.046875 L 9.421875 -24.953125 C 11.160156 -27.023438 13.492188 -28.191406 16.421875 -28.453125 C 20.484375 -28.785156 23.84375 -27.726562 26.5 -25.28125 C 29.351562 -22.65625 30.78125 -18.976562 30.78125 -14.25 Z M 30.78125 0 "})})})}),e.jsx("g",{fill:"currentColor",fillOpacity:1,children:e.jsx("g",{transform:"translate(179.09869, 70.793676)",children:e.jsx("g",{children:e.jsx("path",{d:"M 14.8125 -28.5625 C 18.757812 -28.59375 22.117188 -27.222656 24.890625 -24.453125 C 27.703125 -21.640625 29.109375 -18.273438 29.109375 -14.359375 C 29.148438 -10.398438 27.785156 -7.035156 25.015625 -4.265625 C 22.234375 -1.460938 18.882812 -0.0390625 14.96875 0 C 11.007812 0.0390625 7.628906 -1.328125 4.828125 -4.109375 C 2.015625 -6.878906 0.609375 -10.242188 0.609375 -14.203125 C 0.566406 -18.148438 1.9375 -21.507812 4.71875 -24.28125 C 7.488281 -27.09375 10.851562 -28.519531 14.8125 -28.5625 Z M 19.859375 -9.3125 C 21.222656 -10.6875 21.90625 -12.351562 21.90625 -14.3125 C 21.90625 -16.226562 21.203125 -17.890625 19.796875 -19.296875 C 18.390625 -20.628906 16.726562 -21.296875 14.8125 -21.296875 C 12.882812 -21.296875 11.238281 -20.613281 9.875 -19.25 C 8.5 -17.800781 7.8125 -16.132812 7.8125 -14.25 C 7.8125 -12.332031 8.515625 -10.671875 9.921875 -9.265625 C 11.296875 -7.890625 12.960938 -7.203125 14.921875 -7.203125 C 16.910156 -7.273438 18.554688 -7.976562 19.859375 -9.3125 Z M 19.859375 -9.3125 "})})})}),e.jsx("g",{fill:"currentColor",fillOpacity:1,children:e.jsx("g",{transform:"translate(208.81504, 70.793676)",children:e.jsx("g",{children:e.jsx("path",{d:"M 13.203125 0 C 11.273438 0 9.59375 -0.296875 8.15625 -0.890625 C 7.007812 -1.296875 5.828125 -2.050781 4.609375 -3.15625 C 2.492188 -5.113281 1.53125 -7.59375 1.71875 -10.59375 L 1.71875 -11.203125 L 7.9375 -11.09375 L 8.421875 -11.09375 L 8.421875 -10.640625 C 8.460938 -9.722656 8.664062 -8.96875 9.03125 -8.375 C 9.664062 -7.300781 11.054688 -6.765625 13.203125 -6.765625 C 14.972656 -6.765625 16.25 -6.96875 17.03125 -7.375 C 17.4375 -7.5625 17.710938 -7.800781 17.859375 -8.09375 C 17.929688 -8.207031 17.96875 -8.316406 17.96875 -8.421875 L 18.015625 -8.703125 C 18.015625 -9.484375 17.40625 -10.113281 16.1875 -10.59375 C 15.707031 -10.78125 15.15625 -10.925781 14.53125 -11.03125 C 14.050781 -11.144531 13.515625 -11.238281 12.921875 -11.3125 C 10.703125 -11.53125 8.851562 -11.972656 7.375 -12.640625 C 5.894531 -13.234375 4.675781 -14.046875 3.71875 -15.078125 C 2.382812 -16.597656 1.71875 -18.335938 1.71875 -20.296875 C 1.71875 -21.515625 1.941406 -22.640625 2.390625 -23.671875 C 2.722656 -24.484375 3.164062 -25.207031 3.71875 -25.84375 C 5.707031 -28.132812 8.90625 -29.28125 13.3125 -29.28125 C 15.9375 -29.28125 18.15625 -28.757812 19.96875 -27.71875 C 21.375 -26.945312 22.5 -25.894531 23.34375 -24.5625 C 24.007812 -23.5625 24.472656 -22.398438 24.734375 -21.078125 C 24.804688 -20.628906 24.859375 -20.203125 24.890625 -19.796875 L 24.890625 -18.625 L 18.1875 -18.625 L 18.1875 -19.46875 C 18.15625 -19.613281 18.140625 -19.757812 18.140625 -19.90625 C 18.023438 -20.3125 17.875 -20.644531 17.6875 -20.90625 C 16.875 -22.007812 15.414062 -22.5625 13.3125 -22.5625 C 10.207031 -22.5625 8.65625 -21.914062 8.65625 -20.625 C 8.65625 -19.957031 9.023438 -19.421875 9.765625 -19.015625 C 10.535156 -18.535156 11.847656 -18.1875 13.703125 -17.96875 C 17.953125 -17.519531 21.035156 -16.171875 22.953125 -13.921875 C 24.242188 -12.398438 24.890625 -10.660156 24.890625 -8.703125 L 24.890625 -8.3125 L 24.84375 -7.8125 C 24.84375 -7.332031 24.785156 -6.890625 24.671875 -6.484375 C 24.378906 -5.304688 23.828125 -4.253906 23.015625 -3.328125 C 22.085938 -2.210938 20.789062 -1.378906 19.125 -0.828125 C 17.46875 -0.273438 15.492188 0 13.203125 0 Z M 13.203125 0 "})})})}),e.jsx("g",{fill:"currentColor",fillOpacity:1,children:e.jsx("g",{transform:"translate(235.371259, 70.793676)",children:e.jsx("g",{children:e.jsx("path",{d:"M 22.234375 -28.5625 L 22.234375 -20.796875 L 15.859375 -20.796875 L 15.859375 0 L 8.09375 0 L 8.09375 -20.796875 L 1.65625 -20.796875 L 1.65625 -28.5625 L 8.09375 -28.5625 L 8.09375 -38.546875 L 15.859375 -38.546875 L 15.859375 -28.5625 Z M 22.234375 -28.5625 "})})})}),e.jsx("g",{fill:"currentColor",fillOpacity:1,children:e.jsx("g",{transform:"translate(259.266309, 70.793676)",children:e.jsx("g",{children:e.jsx("path",{d:"M 9.421875 0 L 1.65625 0 L 1.65625 -7.765625 L 9.421875 -7.765625 Z M 9.421875 0 "})})})}),e.jsx("g",{clipPath:"url(#2854c0f5ba)",children:e.jsx("g",{clipPath:"url(#a2b4eafd05)",children:e.jsx("path",{fill:"url(#ca59399d09)",d:"M 335.910156 85.621094 L 280.214844 85.621094 L 280.214844 29.789062 L 335.910156 29.789062 Z M 335.910156 85.621094 ",fillRule:"nonzero"})})}),e.jsx("g",{clipPath:"url(#058149a1c1)",children:e.jsx("g",{clipPath:"url(#3a8b0dae6b)",children:e.jsx("path",{fill:"url(#82194e6edc)",d:"M 327.113281 76.824219 L 271.417969 76.824219 L 271.417969 20.992188 L 327.113281 20.992188 Z M 327.113281 76.824219 ",fillRule:"nonzero"})})})]}),Vn=a=>e.jsx(re.Root,{...a});Vn.displayName="Drawer";const qn=z.forwardRef(({className:a,...t},r)=>e.jsx(re.Trigger,{ref:r,className:w(a),...t}));qn.displayName="Drawer.Trigger";const Hn=z.forwardRef(({className:a,...t},r)=>e.jsx(re.Close,{ref:r,className:w(a),...t}));Hn.displayName="Drawer.Close";const Un=re.Portal;Un.displayName="DrawerPortal";const Zn=z.forwardRef(({className:a,...t},r)=>e.jsx(re.Overlay,{ref:r,className:w("fixed inset-0 z-50 overflow-y-auto","bg-black/30","data-[state=closed]:animate-hide data-[state=open]:animate-dialogOverlayShow",a),...t,style:{animationDuration:"400ms",animationFillMode:"backwards"}}));Zn.displayName="DrawerOverlay";const $n=z.forwardRef(({className:a,...t},r)=>e.jsx(Un,{children:e.jsx(Zn,{children:e.jsx(re.Content,{ref:r,className:w("fixed inset-y-2 mx-auto flex w-[95vw] flex-1 flex-col overflow-y-auto rounded-md border p-4 shadow-lg focus:outline-hidden max-sm:inset-x-2 sm:inset-y-2 sm:right-2 sm:max-w-lg sm:p-6","border-gray-200 dark:border-gray-900","bg-white dark:bg-[#090E1A]","data-[state=closed]:animate-drawerSlideRightAndFade data-[state=open]:animate-drawerSlideLeftAndFade",Ae,a),...t})})}));$n.displayName="DrawerContent";const _n=z.forwardRef(({children:a,className:t,...r},s)=>e.jsxs("div",{ref:s,className:"flex items-start justify-between gap-x-4 border-b border-gray-200 pb-4 dark:border-gray-900",...r,children:[e.jsx("div",{className:w("mt-1 flex flex-col gap-y-1",t),children:a}),e.jsx(re.Close,{asChild:!0,children:e.jsx(D,{variant:"ghost",className:"aspect-square p-1 hover:bg-gray-100 dark:hover:bg-gray-400/10",children:e.jsx(P.RiCloseLine,{className:"size-6","aria-hidden":"true"})})})]}));_n.displayName="Drawer.Header";const Wn=z.forwardRef(({className:a,...t},r)=>e.jsx(re.Title,{ref:r,className:w("text-base font-semibold","text-gray-900 dark:text-gray-50",a),...t}));Wn.displayName="DrawerTitle";const Kn=z.forwardRef(({className:a,...t},r)=>e.jsx("div",{ref:r,className:w("flex-1 py-4",a),...t}));Kn.displayName="Drawer.Body";const zu=z.forwardRef(({className:a,...t},r)=>e.jsx(re.Description,{ref:r,className:w("text-gray-500 dark:text-gray-500",a),...t}));zu.displayName="DrawerDescription";function Iu(){const a=E.usePathname(),t=H(),r=_();if(!t)return null;const s=[{name:"Dashboard",href:r.dashboard(t),icon:N.HomeIcon},{name:"Live Orders",href:r.liveOrders(t),icon:N.RadioIcon},{name:"Orders",href:r.orders(t),icon:N.LogsIcon},{name:"Reservations",href:r.reservations(t),icon:N.CalendarCheckIcon},{name:"Customers",href:r.customers(t),icon:N.UserCircleIcon},{name:"Products",href:r.products(t),icon:N.PackageIcon},{name:"Categories",href:r.productCategories(t),icon:N.BoxesIcon},{name:"Manufacturers",href:r.manufacturers(t),icon:N.FactoryIcon},{name:"Settings",href:r.settings(t),icon:P.RiSettings5Line}];return e.jsxs(Vn,{children:[e.jsx(qn,{asChild:!0,children:e.jsx(D,{variant:"ghost","aria-label":"open sidebar",className:"group flex items-center rounded-md p-2 text-sm font-medium hover:bg-gray-100 data-[state=open]:bg-gray-100 data-[state=open]:bg-gray-400/10 dark:hover:bg-gray-400/10",children:e.jsx(P.RiMenuLine,{className:"size-6 shrink-0 sm:size-5","aria-hidden":"true"})})}),e.jsxs($n,{className:"sm:max-w-lg",children:[e.jsx(_n,{children:e.jsx(Wn,{children:"Navigation"})}),e.jsx(Kn,{children:e.jsx("nav",{"aria-label":"mobile navigation links",className:"flex flex-1 flex-col space-y-10",children:e.jsx("ul",{role:"list",className:"space-y-1.5",children:s.map(i=>e.jsx("li",{children:e.jsx(Hn,{asChild:!0,children:e.jsxs(B,{href:i.href,className:$(a===i.href||a!=null&&a.startsWith(i.href)?"text-blue-600 dark:text-blue-400":"text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-50","flex items-center gap-x-2.5 rounded-md px-2 py-1.5 text-base font-medium transition hover:bg-gray-100 sm:text-sm dark:hover:bg-gray-900",Ae),children:[e.jsx(i.icon,{className:"size-5 shrink-0","aria-hidden":"true"}),i.name]})})},i.name))})})})]})]})}const Eu=()=>{var l;const[a,t]=x.useState(!1),r=x.useRef(null),{organizations:s,organization:i}=je(),n=E.useRouter(),o=_();return e.jsx(e.Fragment,{children:e.jsxs(sa,{open:a,onOpenChange:t,modal:!1,children:[e.jsx(ia,{asChild:!0,children:i.data&&e.jsxs("button",{className:w("flex w-full items-center gap-x-2.5 rounded-md border border-gray-300 bg-white p-2 text-sm shadow-xs transition-all hover:bg-gray-50 dark:border-gray-800 dark:bg-gray-950 dark:hover:bg-gray-900",Da),children:[i.data.logoFile?e.jsx(Ie,{src:i.data.logoFile.url,alt:i.data.name,width:40,height:40,className:"flex aspect-square size-8 items-center justify-center rounded"}):e.jsxs("span",{className:"flex aspect-square size-8 items-center justify-center rounded bg-blue-600 p-2 text-xs font-medium text-white dark:bg-blue-500 uppercase","aria-hidden":"true",children:[i.data.name[0],i.data.name[1]]}),e.jsxs("div",{className:"flex w-full items-center justify-between gap-x-4 truncate",children:[e.jsxs("div",{className:"truncate text-left",children:[e.jsx("p",{className:"truncate whitespace-nowrap text-sm font-medium text-gray-900 dark:text-gray-50",children:i.data.name}),e.jsx("p",{className:"whitespace-nowrap text-left text-xs text-gray-700 dark:text-gray-300",children:(l=i.data.address)==null?void 0:l.addressLineOne})]}),e.jsx(P.RiExpandUpDownLine,{className:"size-5 shrink-0 text-gray-500","aria-hidden":"true"})]})]})}),e.jsx(na,{hidden:!1,onCloseAutoFocus:c=>{r.current&&(r.current.focus(),r.current=null,c.preventDefault())},children:e.jsxs(Va,{children:[e.jsxs(Zt,{children:["Workspaces (",s.data.length,")"]}),s.data.map(c=>{var m;return e.jsx(ze,{onClick:()=>n.push(o.dashboard(c.id)),children:e.jsxs("div",{className:"flex w-full items-center gap-x-2.5",children:[c.logoFile?e.jsx(Ie,{src:c.logoFile.url,alt:c.name,width:40,height:40,className:"flex aspect-square size-8 items-center justify-center rounded"}):e.jsxs("span",{className:"flex aspect-square size-8 items-center justify-center rounded bg-blue-600 p-2 text-xs font-medium text-white dark:bg-blue-500 uppercase","aria-hidden":"true",children:[c.name[0],c.name[1]]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-50",children:c.name}),e.jsx("p",{className:"text-xs text-gray-700 dark:text-gray-400",children:(m=c.address)==null?void 0:m.addressLineOne})]})]})},c.id)})]})})]})})},Du=()=>{const[a,t]=x.useState(!1),r=x.useRef(null),{organizations:s,organization:i}=je(),n=E.useRouter(),o=_();return e.jsxs(sa,{open:a,onOpenChange:t,modal:!1,children:[e.jsx(ia,{asChild:!0,children:i.data&&e.jsxs("button",{className:"flex items-center gap-x-1.5 rounded-md p-2 hover:bg-gray-100 focus:outline-hidden dark:hover:bg-gray-900",children:[i.data.logoFile?e.jsx(Ie,{src:i.data.logoFile.url,alt:i.data.name,width:28,height:28,className:"flex aspect-square size-7 items-center justify-center rounded"}):e.jsxs("span",{className:"flex aspect-square size-7 items-center justify-center rounded bg-blue-600 p-2 text-xs font-medium text-white dark:bg-blue-500 uppercase","aria-hidden":"true",children:[i.data.name[0],i.data.name[1]]}),e.jsx(P.RiArrowRightSLine,{className:"size-4 shrink-0 text-gray-500","aria-hidden":"true"}),e.jsxs("div",{className:"flex w-full items-center justify-between gap-x-3 truncate",children:[e.jsx("p",{className:"truncate whitespace-nowrap text-sm font-medium text-gray-900 dark:text-gray-50",children:i.data.name}),e.jsx(P.RiExpandUpDownLine,{className:"size-4 shrink-0 text-gray-500","aria-hidden":"true"})]})]})}),e.jsx(na,{className:"min-w-72!",onCloseAutoFocus:l=>{r.current&&(r.current.focus(),r.current=null,l.preventDefault())},children:e.jsxs(Va,{children:[e.jsxs(Zt,{children:["Workspaces (",s.data.length,")"]}),s.data.map(l=>{var c;return e.jsx(ze,{onClick:()=>n.push(o.dashboard(l.id)),children:e.jsxs("div",{className:"flex w-full items-center gap-x-2.5",children:[l.logoFile?e.jsx(Ie,{src:l.logoFile.url,alt:l.name,width:28,height:28,className:"flex aspect-square size-7 items-center justify-center rounded"}):e.jsxs("span",{className:"flex aspect-square size-7 items-center justify-center rounded bg-blue-600 p-2 text-xs font-medium text-white dark:bg-blue-500 uppercase","aria-hidden":"true",children:[l.name[0],l.name[1]]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-50",children:l.name}),e.jsx("p",{className:"text-xs text-gray-700 dark:text-gray-400",children:(c=l.address)==null?void 0:c.addressLineOne})]})]})},l.id)})]})})]})};function Gn({children:a,align:t="start"}){var p,g;const r=E.useRouter(),[s,i]=z.useState(!1),{theme:n,setTheme:o}=ws.useTheme(),l=qa(),c=_(),m=l.useSession();z.useEffect(()=>{i(!0)},[]);const u=()=>l.signOut({fetchOptions:{onSuccess:()=>r.push(c.signIn)}});return s?e.jsx(e.Fragment,{children:e.jsxs(sa,{children:[e.jsx(ia,{asChild:!0,children:a}),e.jsxs(na,{align:t,children:[e.jsx(Zt,{children:(g=(p=m.data)==null?void 0:p.user)==null?void 0:g.email}),e.jsx(Va,{children:e.jsxs(Sn,{children:[e.jsx(In,{children:"Theme"}),e.jsx(En,{children:e.jsxs(zn,{value:n,onValueChange:h=>{o(h)},children:[e.jsxs(lt,{"aria-label":"Switch to Light Mode",value:"light",iconType:"check",children:[e.jsx(P.RiSunLine,{className:"size-4 shrink-0","aria-hidden":"true"}),"Light"]}),e.jsxs(lt,{"aria-label":"Switch to Dark Mode",value:"dark",iconType:"check",children:[e.jsx(P.RiMoonLine,{className:"size-4 shrink-0","aria-hidden":"true"}),"Dark"]}),e.jsxs(lt,{"aria-label":"Switch to System Mode",value:"system",iconType:"check",children:[e.jsx(P.RiComputerLine,{className:"size-4 shrink-0","aria-hidden":"true"}),"System"]})]})}),e.jsx(Va,{children:e.jsx(ze,{onClick:u,className:"text-red-500",children:"Sign out"})})]})})]})]})}):null}const Ru=()=>{var s;const a=qa().useSession(),{firstname:t,lastname:r}=((s=a.data)==null?void 0:s.user)||{};return e.jsx(Gn,{children:e.jsxs(D,{"aria-label":"User settings",variant:"ghost",className:$(Ae,"group flex w-full items-center justify-between rounded-md p-2 text-sm font-medium text-gray-900 hover:bg-gray-100 data-[state=open]:bg-gray-100 data-[state=open]:bg-gray-400/10 dark:hover:bg-gray-400/10"),children:[e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-full border border-gray-300 bg-white text-xs text-gray-700 dark:border-gray-800 dark:bg-gray-950 dark:text-gray-300","aria-hidden":"true",children:[t==null?void 0:t.charAt(0),r==null?void 0:r.charAt(0)]}),e.jsxs("span",{children:[t," ",r]})]}),e.jsx(P.RiMore2Fill,{className:"size-4 shrink-0 text-gray-500 group-hover:text-gray-700 dark:group-hover:text-gray-400","aria-hidden":"true"})]})})},Fu=()=>e.jsx(Gn,{align:"end",children:e.jsx(D,{"aria-label":"User settings",variant:"ghost",className:$("group flex items-center rounded-md p-1 text-sm font-medium text-gray-900 hover:bg-gray-100 data-[state=open]:bg-gray-100 data-[state=open]:bg-gray-400/10 dark:hover:bg-gray-400/10"),children:e.jsx("span",{className:"flex size-7 shrink-0 items-center justify-center rounded-full border border-gray-300 bg-white text-xs text-gray-700 dark:border-gray-800 dark:bg-gray-950 dark:text-gray-300","aria-hidden":"true",children:"ES"})})});function Mu(){const a=E.usePathname(),t=H(),r=_(),s=[{name:"Home",href:r.dashboard(t),icon:N.HomeIcon},{name:"Live Orders",href:r.liveOrders(t),icon:N.RadioIcon},{name:"Orders List",href:r.orders(t),icon:N.LogsIcon},{name:"Reservations",href:r.reservations(t),icon:N.CalendarCheckIcon},{name:"Products",href:r.products(t),icon:N.PackageIcon},{name:"Product Categories",href:r.productCategories(t),icon:N.BoxesIcon},{name:"Manufacturers",href:r.manufacturers(t),icon:N.FactoryIcon},{name:"Customers",href:r.customers(t),icon:N.UserCircleIcon},{name:"Settings",href:r.settings(t),icon:P.RiSettings5Line}],i=n=>a===n||(a==null?void 0:a.startsWith(n));return e.jsxs(e.Fragment,{children:[e.jsx("nav",{className:"hidden lg:fixed lg:inset-y-0 lg:z-50 lg:flex lg:w-72 lg:flex-col",children:e.jsxs("aside",{className:"flex grow flex-col gap-y-6 overflow-y-auto border-r border-gray-200 bg-slate-50 p-4 dark:border-gray-800 dark:bg-gray-950",children:[e.jsx(B,{href:r.home,className:"-ml-2",children:e.jsx(Su,{})}),e.jsx("hr",{className:"block border-t border-gray-200 dark:border-gray-800 -mt-3 mb-1"}),e.jsx(Eu,{}),e.jsx("nav",{"aria-label":"core navigation links",className:"flex flex-1 flex-col space-y-10",children:e.jsx("ul",{role:"list",className:"space-y-0.5",children:s.map(n=>e.jsx("li",{children:e.jsxs(B,{href:n.href,className:w(i(n.href)?"text-blue-600 dark:text-blue-400":"text-gray-700 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-50","flex items-center gap-x-2.5 rounded-md px-2 py-1.5 text-sm font-medium transition hover:bg-gray-100 dark:hover:bg-gray-900",Ae),children:[e.jsx(n.icon,{className:"size-4 shrink-0","aria-hidden":"true"}),n.name]})},n.name))})}),e.jsx("div",{className:"mt-auto",children:e.jsx(Ru,{})})]})}),e.jsxs("div",{className:"sticky top-0 z-40 flex h-16 shrink-0 items-center justify-between border-b border-gray-200 bg-white px-2 shadow-xs sm:gap-x-6 sm:px-4 lg:hidden dark:border-gray-800 dark:bg-gray-950",children:[e.jsx(Du,{}),e.jsxs("div",{className:"flex items-center gap-1 sm:gap-2",children:[e.jsx(Fu,{}),e.jsx(Iu,{})]})]})]})}function Pu({children:a,view:t}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bg-slate-50 dark:hidden w-1/2 absolute top-0 left-0 h-screen"}),e.jsxs("div",{className:"mx-auto max-w-(--breakpoint-2xl)",children:[e.jsx(Mu,{}),e.jsx("main",{className:"lg:pl-72 bg-white dark:bg-gray-950 z-10 relative min-h-screen",children:e.jsx("div",{className:"relative",children:e.jsxs("div",{className:"p-4 sm:px-6 sm:pb-10 sm:pt-10 lg:px-10 lg:pt-[34px]",children:[e.jsx(Cu,{view:t}),a]})})})]})]})}function Bu(a){if(a.length===0)return{type:"home"};const[t,r,s,i,n]=a;if(t==="auth")return r==="sign-in"?{type:"sign-in"}:r==="sign-up"?{type:"sign-up"}:{type:"not-found"};if(t==="organizations")return{type:"organizations"};const o=t;return r?r==="dashboard"?{type:"dashboard",orgId:o}:r==="orders"?{type:"orders",orgId:o}:r==="reservations"?{type:"reservations",orgId:o}:r==="customers"?s?{type:"customer-detail",orgId:o,id:s}:{type:"customers",orgId:o}:r==="products"?s?s==="create"?{type:"product-create",orgId:o}:{type:"product-edit",orgId:o,id:s}:{type:"products-list",orgId:o}:r==="product-categories"?s?s==="create"?{type:"product-category-create",orgId:o}:{type:"product-category-edit",orgId:o,id:s}:{type:"product-categories-list",orgId:o}:r==="manufacturers"?s?s==="create"?{type:"manufacturer-create",orgId:o}:{type:"manufacturer-edit",orgId:o,id:s}:{type:"manufacturers-list",orgId:o}:r==="settings"?s?s==="integrations"?i?i==="create"?{type:"settings-integrations-create",orgId:o}:{type:"settings-integration",orgId:o,id:i}:{type:"settings-integrations",orgId:o}:s==="opening-times"?{type:"settings-opening-times",orgId:o}:s==="shipping-methods"?i?i==="create"?{type:"shipping-method-create",orgId:o}:{type:"shipping-method-edit",orgId:o,id:i}:{type:"shipping-methods-list",orgId:o}:s==="access"?i?i==="invite"?{type:"access-invite",orgId:o}:{type:"access-member-edit",orgId:o,id:i}:{type:"access-list",orgId:o}:{type:"settings",orgId:o}:{type:"settings",orgId:o}:{type:"not-found"}:{type:"not-found"}}function Tu({segments:a}){const t=qa(),r=_(),s=E.useRouter(),i=E.usePathname(),n=E.useSearchParams(),{data:o,isPending:l}=t.useSession(),c=Bu(a),m=c.type==="sign-in"||c.type==="sign-up",u=c.type==="home"||c.type==="organizations",p=n==null?void 0:n.get("redirect"),g=n==null?void 0:n.toString(),h=i?`${i}${g?`?${g}`:""}`:r.home,f=m?Ht(p,r):h;if(x.useEffect(()=>{if(!l){if(!o&&!m){s.replace(br(r.signIn,f));return}o&&m&&s.replace(f)}},[o,l,m,s,r.signIn,f]),l)return e.jsx("div",{className:"flex justify-center items-center h-screen",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600"})});if(m){if(c.type==="sign-in")return e.jsx(Gd,{});if(c.type==="sign-up")return e.jsx(Yd,{})}if(!o)return null;if(u)return e.jsx(cs,{children:e.jsx(cm,{})});if(c.type==="not-found")return e.jsx(yr,{});const b="orgId"in c?c.orgId:void 0,y="id"in c?c.id:void 0;return e.jsx(Vd,{organizationId:b,id:y,children:e.jsx(cs,{children:e.jsx(Ud,{children:e.jsx(Pu,{view:c,children:Qu(c)})})})})}function Qu(a){switch(a.type){case"dashboard":return e.jsx(Dc,{});case"orders":return e.jsx(om,{});case"reservations":return e.jsx($m,{});case"customers":return e.jsx(wc,{});case"customer-detail":return e.jsx(dc,{});case"products-list":return e.jsx(Pm,{});case"product-create":return e.jsx(Im,{});case"product-edit":return e.jsx(Em,{});case"product-categories-list":return e.jsx(jm,{});case"product-category-create":return e.jsx(wm,{});case"product-category-edit":return e.jsx(km,{});case"manufacturers-list":return e.jsx(em,{});case"manufacturer-create":return e.jsx(_c,{});case"manufacturer-edit":return e.jsx(Wc,{});case"settings":return e.jsx(Me,{children:e.jsx(Nu,{})});case"settings-opening-times":return e.jsx(Me,{children:e.jsx(xu,{})});case"settings-integrations":return e.jsx(Me,{children:e.jsx(pu,{})});case"settings-integrations-create":return e.jsx(Me,{children:e.jsx(au,{})});case"settings-integration":return e.jsx(Me,{children:e.jsx(du,{})});case"shipping-methods-list":return e.jsx(Me,{children:e.jsx(vu,{})});case"shipping-method-create":return e.jsx(Me,{children:e.jsx(fu,{})});case"shipping-method-edit":return e.jsx(Me,{children:e.jsx(yu,{})});case"access-list":return e.jsx(Me,{children:e.jsx(Xm,{})});case"access-invite":return e.jsx(Me,{children:e.jsx(Wm,{})});case"access-member-edit":return e.jsx(Me,{children:e.jsx(Ym,{})});default:return e.jsx(yr,{})}}exports.APIProvider=sr,exports.AccountHomePage=Ki,exports.AccountPages=jd,exports.AdminProvider=yo,exports.AdminRouter=Tu,exports.Badge=hr,exports.Button=te,exports.CartDrawer=Vo,exports.CartDrawerItem=Ks,exports.CartItems=Ws,exports.CartPanel=Gs,exports.CartProvider=qs,exports.CheckoutPages=wd,exports.Command=$a,exports.CommandBar=Ti,exports.CommandBarBar=Oi,exports.CommandBarCommand=Ji,exports.CommandBarSeperator=Li,exports.CommandBarValue=Qi,exports.CommandDialog=Ol,exports.CommandEmpty=Tt,exports.CommandGroup=Qt,exports.CommandInput=Pt,exports.CommandItem=Ot,exports.CommandList=Bt,exports.CommandSeparator=wi,exports.CommandShortcut=ki,exports.CountryInput=Ci,exports.CustomerDetailsPage=Yt,exports.Dialog=Ft,exports.DialogClose=xi,exports.DialogContent=Mt,exports.DialogDescription=ji,exports.DialogFooter=vi,exports.DialogHeader=bi,exports.DialogTitle=ur,exports.DialogTrigger=hi,exports.Divider=Na,exports.EmailInput=Si,exports.ErrorView=yr,exports.ImageUploadInput=zi,exports.Input=Mi,exports.InputGroup=Ne,exports.Label=Re,exports.LocationInput=Lt,exports.ModifierContainer=Yi,exports.ModifiersDialog=Nd,exports.ModifiersGroup=en,exports.ModifiersModal=Cd,exports.ModifiersOption=an,exports.PhoneNumberInput=Di,exports.Popover=za,exports.PopoverAnchor=Ni,exports.PopoverClose=Ai,exports.PopoverContent=Ea,exports.PopoverTrigger=Ia,exports.QuantityControl=Ad,exports.RadioCardGroup=pt,exports.RadioCardGroupIndicator=gt,exports.RadioCardItem=ht,exports.SelectInput=Ri,exports.ShippingAndPaymentPage=qi,exports.ShophostProvider=Od,exports.SliderOver=Bi,exports.Switch=pr,exports.TextInput=De,exports.TimeInput=gr,exports.badgeVariants=Vi,exports.buttonVariants=gi,exports.calculateCartTotal=Qs,exports.createAdminAuthClient=Ps,exports.createRoutes=Ts,exports.findCartItem=Os,exports.formatPrice=we,exports.getAdminAuthClient=Bs,exports.getFieldError=Pi,exports.getFormattedModifiers=jo,exports.mockProducts=Id,exports.productRequiresModifiers=wo,exports.useAPI=M,exports.useCart=At,exports.useCartContext=Ha,exports.useLocalization=Hs,exports.useModifierSelection=Us,exports.useModifiers=Za,exports.useMultipleProductDetails=zd,exports.useOrganization=ke,exports.useProductDetails=Sd;
|