@shophost/react 2.0.47 → 2.0.49

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-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"),Ir=require("next-themes"),h=require("react"),Q=require("react-hot-toast"),Ta=require("better-auth/client/plugins"),Er=require("better-auth/react"),L=require("react-hook-form"),v=require("lucide-react"),Dr=require("@vercel/blob/client"),xe=require("next/image.js"),Te=require("use-debounce"),w=require("classnames"),Wi=require("use-mask-input"),Xe=require("@headlessui/react"),D=require("next/link.js"),z=require("@remixicon/react"),S=require("next/navigation.js"),ce=require("@hookform/resolvers/zod"),T=require("date-fns"),Gi=require("@shophost/client"),d=require("@hono/zod-openapi"),Dt=require("@radix-ui/react-slot"),Se=require("tailwind-variants"),Fr=require("clsx"),Rr=require("tailwind-merge"),Ki=require("@radix-ui/react-label"),_=require("recharts"),se=require("@internationalized/date"),Xi=require("@radix-ui/react-popover"),Pr=require("@react-aria/datepicker"),Yi=require("@react-stately/datepicker"),en=require("date-fns/locale"),fa=require("react-day-picker"),$=require("cmdk"),an=require("@radix-ui/react-dialog"),tn=require("react-phone-number-input"),Mr=require("react-phone-number-input/flags"),rn=require("@radix-ui/react-switch"),sn=require("@radix-ui/react-radio-group"),nn=require("tailwindcss/colors"),on=require("@radix-ui/react-navigation-menu"),fe=require("@tanstack/react-table"),ln=require("@radix-ui/react-checkbox"),dn=require("@radix-ui/react-dropdown-menu"),cn=require("@radix-ui/react-select"),ha=require("zod");function Ae(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 C=Ae(h),Br=Ae(Ki),G=Ae(Xi),W=Ae(an),Xa=Ae(tn),Qa=Ae(rn),Ft=Ae(sn),Oa=Ae(on),lr=Ae(ln),de=Ae(dn),ee=Ae(cn),ae=new A.QueryClient({defaultOptions:{queries:{retry:!1,refetchInterval:!1,refetchOnWindowFocus:!1}}}),Tr=h.createContext(null),Rt=({baseUrl:a,children:t})=>{const r=h.useMemo(()=>Gi.initClient({baseUrl:a,throwOnUnknownStatus:!0,baseHeaders:{},credentials:"include"}),[a]);return e.jsx(Tr.Provider,{value:{client:r,baseUrl:a},children:t})},E=()=>{const a=h.useContext(Tr);if(!a)throw new Error("useAPI must be used within a APIProvider");return a},Qr=h.createContext(null),mn=({client:a,children:t})=>e.jsx(Qr.Provider,{value:a,children:t});function ja(){const a=h.useContext(Qr);if(!a)throw new Error("useAdminAuth must be used within AdminProvider");return a}const Or=h.createContext(null),un=({config:a,children:t})=>e.jsx(Or.Provider,{value:a,children:t});function Lr(){const a=h.useContext(Or);if(!a)throw new Error("useAdminConfig must be used within AdminProvider");return a}const Jr=h.createContext(null),pn=({routes:a,children:t})=>e.jsx(Jr.Provider,{value:a,children:t});function q(){const a=h.useContext(Jr);if(!a)throw new Error("useAdminRoutes must be used within AdminProvider");return a}function Vr(a){return Er.createAuthClient({baseURL:a,plugins:[Ta.inferAdditionalFields(),Ta.organizationClient()]})}const At=new Map;function Hr(a){return At.has(a)||At.set(a,Vr(a)),At.get(a)}function Ur(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 gn({config:a,children:t}){const r=h.useMemo(()=>Hr(a.apiBaseUrl),[a.apiBaseUrl]),s=h.useMemo(()=>Ur(a.basePath),[a.basePath]);return e.jsx(A.QueryClientProvider,{client:ae,children:e.jsxs("div",{className:"shophost-admin",children:[e.jsx(Ir.ThemeProvider,{defaultTheme:"light",attribute:"class",children:e.jsx(Rt,{baseUrl:a.apiBaseUrl,children:e.jsx(mn,{client:r,children:e.jsx(un,{config:a,children:e.jsx(pn,{routes:s,children:t})})})})}),e.jsx(Q.Toaster,{})]})})}const dr="shophost-cart",hn={items:[],isInitialized:!1,modifierModal:null,totalAmount:0,itemCount:0,removedItemsAlert:!1},xn=(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),ue=(a,t="USD",r="en-US")=>new Intl.NumberFormat(r,{style:"currency",currency:t}).format(a),fn=(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 f=n.modifiers.find(y=>y&&y.id===g.id);if(!f)return"";const x=f.title||"",j=g.quantity||1;return j>1?`${x} (${j})`:x}).filter(Boolean).join(", ");return o?`${o}: ${l}`:l}).filter(Boolean).join(" | ")},yn=(a,t,r)=>a.find(s=>Ya(s,{productId:t,modifierGroups:r})),Ya=(a,t)=>{if(a.productId!==t.productId)return!1;const r=t.modifierGroups??[],s=a.modifierGroups??[];return r.length===0?s.length===0:bn(s,r)},bn=(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})},jn=a=>!a.modifierGroups||a.modifierGroups.length===0?!1:a.modifierGroups.some(t=>t.selectMin>0),wn=(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}},We=a=>a.reduce((t,r)=>t+(r.quantity||1),0),kn=(a,t)=>a.findIndex(r=>Ya(r,{productId:t.productId,modifierGroups:t.modifierGroups})),vn=(a,t,r)=>a.map(s=>Ya(s,t)?{...s,quantity:r}:s),Nn=(a,t)=>a.filter(r=>!Ya(r,t)),An=(a,t)=>{const r=kn(a,t);return r===-1?[...a,t]:a.map((s,i)=>i===r?{...s,quantity:(s.quantity||1)+(t.quantity||1)}:s)},Cn=(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}),Zr=(a,t)=>{switch(t.type){case"INITIALIZE_CART":{const r=t.payload;return{...a,items:r,itemCount:We(r)}}case"SET_INITIALIZED":return{...a,isInitialized:t.payload};case"ADD_ITEM":{const r=An(a.items,t.payload);return{...a,items:r,itemCount:We(r)}}case"UPDATE_ITEM_QUANTITY":{const{productId:r,quantity:s,modifierGroups:i}=t.payload;if(s<=0)return Zr(a,{type:"REMOVE_ITEM",payload:{productId:r,modifierGroups:i}});const n=vn(a.items,{productId:r,modifierGroups:i},s);return{...a,items:n,itemCount:We(n)}}case"REMOVE_ITEM":{const r=Nn(a.items,t.payload);return{...a,items:r,itemCount:We(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?Cn(l,c):!1}),o=n.length<i;return{...a,items:n,itemCount:We(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:We(s)}}default:return a}};function qr(a,t,r,s){const i=Number(t.discountedBasePrice??t.basePrice??0),n=ue((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 f;const g=(f=m.modifiers)==null?void 0:f.find(x=>x.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:ue(i,r,s),quantity:a.quantity||1}}const $r=h.createContext(void 0),Sn=({children:a,initialOrganization:t,organizationId:r})=>{const{client:s}=E(),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($r.Provider,{value:{organizationId:r,loading:i.isLoading,organization:i.data,error:i.error},children:a})},pe=()=>{const a=h.useContext($r);if(a===void 0)throw new Error("useOrganization must be used within a OrganizationProvider");return a},Pt=h.createContext(void 0),_r=({children:a,locale:t="en",organizationId:r})=>{const{organization:s}=pe(),i=s==null?void 0:s.configuration.defaultCurrency,{client:n}=E(),[o,l]=h.useState(null),[c,m]=h.useState(null),[{items:u,isInitialized:p,modifierModal:g,totalAmount:f,itemCount:x,removedItemsAlert:j},y]=h.useReducer(Zr,hn),b=g!==null,k=(g==null?void 0:g.product)??null,N=(g==null?void 0:g.quantity)??1,R=g==null?void 0:g.onAdded,O=h.useMemo(()=>[...new Set(u.map(M=>M.productId))],[u]),{data:F,isLoading:U,isRefetching:te}=A.useQuery({queryKey:["cartProducts",O,x,c==null?void 0:c.id],queryFn:async()=>{if(O.length===0)return{products:{},total:0,subtotal:0,invalidProductIds:[]};const M=await n.cart.getCartData({params:{organizationId:r},query:{locale:t},body:{items:u,shippingMethodId:c==null?void 0:c.id}});if(M.status!==200)throw new Error("Failed to fetch product data");return M.body},placeholderData:A.keepPreviousData,enabled:O.length>0});h.useEffect(()=>{var M;F&&((M=F.invalidProductIds)==null?void 0:M.length)>0&&(y({type:"REMOVE_INVALID_PRODUCTS",payload:{invalidProductIds:F.invalidProductIds}}),alert("Some items have been removed from your cart because they are no longer available or their options have changed."))},[F,te,u.length]),h.useEffect(()=>{(()=>{const M=localStorage.getItem(dr);if(M)try{const Z=JSON.parse(M);y({type:"INITIALIZE_CART",payload:Z})}catch(Z){console.error("Failed to parse cart from localStorage:",Z)}y({type:"SET_INITIALIZED",payload:!0})})()},[]),h.useEffect(()=>{p&&localStorage.setItem(dr,JSON.stringify(u))},[u,p]),h.useEffect(()=>{u.length>0&&F&&y({type:"UPDATE_TOTALS",payload:{productsData:F.products}})},[u,F]);const P=h.useCallback(M=>{y({type:"ADD_ITEM",payload:M})},[]),H=h.useCallback((M,Z,Nt)=>{y({type:"UPDATE_ITEM_QUANTITY",payload:{productId:M,quantity:Z,modifierGroups:Nt}})},[]),je=h.useCallback((M,Z)=>{y({type:"REMOVE_ITEM",payload:{productId:M,modifierGroups:Z}})},[]),ua=h.useCallback(()=>{y({type:"CLEAR_CART"})},[]),Ca=h.useCallback(()=>{console.log("Checkout clicked, implement onCheckout handler")},[]),pa=h.useCallback((M,Z)=>{const Nt={product:M,quantity:(Z==null?void 0:Z.quantity)??1,onAdded:Z==null?void 0:Z.onAdded};y({type:"OPEN_MODIFIERS_MODAL",payload:Nt})},[]),ga=h.useCallback(()=>{y({type:"CLOSE_MODIFIERS_MODAL"})},[]),Sa=h.useMemo(()=>F!=null&&F.products?u.map(M=>{const Z=F.products[M.productId];return Z?qr(M,Z,i??"USD",t):null}).filter(M=>M!==null):[],[u,F==null?void 0:F.products,i,t]),re=h.useMemo(()=>({locale:t,organizationId:r,items:u,total:(F==null?void 0:F.total)??0,shipping:F==null?void 0:F.shipping,subtotal:(F==null?void 0:F.subtotal)??0,products:(F==null?void 0:F.products)||{},addItem:P,removeItem:je,updateItemQuantity:H,clearCart:ua,itemCount:x,totalAmount:f,onCheckoutClick:Ca,openModifiersModal:pa,closeModifiersModal:ga,modifierModal:g,isModifiersModalOpen:b,selectedProduct:k,pendingModalQuantity:N,onModalAddToCart:R,isProductsLoading:U,paymentMethod:o,setPaymentMethod:l,shippingMethod:c,setShippingMethod:m,formattedCartItems:Sa}),[t,r,u,P,je,H,ua,x,f,Ca,pa,ga,g,b,k,N,R,F,U,o,l,c,m,Sa]);return e.jsx(Pt.Provider,{value:re,children:a})},et=()=>{const a=h.useContext(Pt),{client:t}=E();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 x;const g=(j=m??[])=>(a.addItem({productId:l,quantity:c,modifierGroups:j}),p==null||p(),{openedModifiers:!1});if(m!=null&&m.length)return g(m);const f=await r(l,u);return(x=f.modifierGroups)!=null&&x.length?(a.openModifiersModal(f,{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}},at=()=>{const a=h.useContext(Pt);if(a===void 0)throw new Error("useCart must be used within a CartProvider");return a},Wr=(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(f=>f.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}},zn=a=>a.map(t=>({groupId:t.id,modifierIds:[]})),cr=(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)},Gr=(a=[])=>{const[t,r]=h.useState([]),[s,i]=h.useState(null);h.useEffect(()=>{r(zn(a)),i(null)},[a]);const n=h.useCallback((p,g)=>{r(f=>cr(f,p,x=>x.includes(g)?x.filter(j=>j!==g):[...x,g])),i(null)},[]),o=h.useCallback((p,g)=>{r(f=>cr(f,p,()=>[g])),i(null)},[]),l=h.useCallback((p,g)=>{const f=t.find(x=>x.groupId===p);return f?f.modifierIds.includes(g):!1},[t]),c=h.useCallback(()=>{const p=wn(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}},Kr=h.createContext(null),Xr=({children:a,locale:t="en"})=>{const{modifierModal:r,closeModifiersModal:s,addItem:i}=at(),n=(r==null?void 0:r.product)??null,o=h.useMemo(()=>(n==null?void 0:n.modifierGroups)??[],[n]),[l,c]=h.useState(1),{toggleModifier:m,selectModifier:u,isModifierSelected:p,validateSelections:g,validationError:f,getCartModifierGroups:x}=Gr(o),{getProductName:j,getModifierGroupName:y}=Wr(t);h.useEffect(()=>{c((r==null?void 0:r.quantity)??1)},[r]);const b=h.useCallback(()=>{c(P=>P+1)},[]),k=h.useCallback(()=>{c(P=>P>1?P-1:1)},[]),N=h.useCallback(()=>{var P;!n||!g()||(i({productId:n.id,quantity:l,modifierGroups:x()}),c(1),s(),(P=r==null?void 0:r.onAdded)==null||P.call(r))},[i,s,x,r,n,l,g]),R=o.length>0,O=h.useMemo(()=>n?"title"in n?n.title??"":j(n,""):"",[j,n]),F=h.useCallback(P=>P.selectMax>1||P.selectMax===0,[]),U=h.useCallback((P,H)=>P.price>0?` (+${ue(P.price,H,t)})`:"",[t]),te={isOpen:r!==null,onClose:s,product:n,productName:O,hasModifiers:R,quantity:l,handleIncrement:b,handleDecrement:k,handleAddToCart:N,validationError:f,modifierGroups:o,isModifierSelected:p,isMultiSelect:F,toggleModifier:m,selectModifier:u,getModifierGroupName:y,formatModifierPrice:U,locale:t};return e.jsx(Kr.Provider,{value:te,children:a})},wa=()=>{const a=h.useContext(Kr);if(!a)throw new Error("useModifiers must be used within a ModifiersProvider");return a},Yr=({className:a,emptyCartComponent:t,renderItem:r,loadingComponent:s})=>{const{organization:i}=pe(),{locale:n,items:o,removeItem:l,updateItemQuantity:c,products:m,isProductsLoading:u}=at();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 f=()=>l(p.productId,p.modifierGroups),x=y=>c(p.productId,y,p.modifierGroups),j=qr(p,g,i.configuration.defaultCurrency,n);return e.jsx(h.Fragment,{children:r({...j,remove:f,updateQuantity:x})},`${p.productId}-${JSON.stringify(p.modifierGroups)}`)})})},es=({title:a,subtitle:t,image:r,price:s,quantity:i,remove:n,updateQuantity:o})=>{const[l,c]=h.useState(String(i));h.useEffect(()=>{c(String(i))},[i]);const m=h.useCallback(()=>{const u=Number.parseInt(l,10);if(Number.isNaN(u)){c(String(i));return}if(u<=0){n();return}o(u)},[l,i,n,o]);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(xe,{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?n():o(Math.max(1,i-1)),"aria-label":"Decrease quantity",children:"-"}),e.jsx("input",{type:"number",min:1,step:1,inputMode:"numeric",value:l,onChange:u=>{const p=u.target.value;(p===""||/^[0-9]+$/.test(p))&&c(p)},onBlur:m,onKeyDown:u=>{u.key==="Enter"&&u.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:()=>o(i+1),"aria-label":"Increase quantity",children:"+"})]})})]})]})})},In=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"})]})}),En=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"})]}),Dn=a=>e.jsx(es,{...a}),as=({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=En,loadingComponent:m=In,renderFooter:u,renderHeader:p,renderItem:g=Dn})=>{const{itemCount:f,total:x,locale:j}=at(),{organization:y}=pe(),b=(y==null?void 0:y.configuration.defaultCurrency)??"USD",k=ue(x,b,j),N={checkoutHref:a,checkoutLabel:t,close:o??(()=>{}),formattedTotal:k,itemCount:f,total:x};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(z.RiCloseLine,{className:"h-5 w-5"})})]}),e.jsx("div",{className:i,children:e.jsx(Yr,{renderItem:R=>g(R),loadingComponent:m,emptyCartComponent:c})}),f>0&&(u?u(N):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:k}),e.jsx(D,{href:a,className:"storefront-primary-action btn text-sm rounded-lg w-full",onClick:o,children:t})]}))]})},Fn=({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,f]=h.useState(null),[x,j]=h.useState(null),y=50,b=R=>{j(null),f(R.targetTouches[0].clientY)},k=R=>{j(R.targetTouches[0].clientY)},N=()=>{!g||!x||(x-g>y&&t(),f(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(Xe.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: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:b,onTouchMove:k,onTouchEnd:N,children:e.jsx(as,{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})})})})]})},Rn=[{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"}],tt=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."}),St=d.z.enum(["delivery","pickup"]),Pn=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 Mn=d.z.object({from:d.z.date(),to:d.z.date()}).openapi("AnalyticsRange"),Bn=d.z.object({currency:tt,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"),Tn=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"),Qn=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"),On=d.z.object({method:Pn,count:d.z.number().int().min(0),totalSales:d.z.number().min(0)}).openapi("PaymentMethodBreakdownItem"),Ln=d.z.object({method:St,count:d.z.number().int().min(0),totalSales:d.z.number().min(0)}).openapi("FulfilmentBreakdownItem");d.z.object({range:Mn,summary:Bn,salesByDay:d.z.array(Tn),reservationsByDay:d.z.array(Qn),paymentMethods:d.z.array(On),fulfilmentMethods:d.z.array(Ln)}).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 Jn=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"),Vn=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 ta=(...a)=>(t,r)=>{const{translations:s,defaultLocale:i}=t,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]})})},rt=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"]]),mr=Array.from(rt.entries()).map(([a,t])=>({value:a,label:t})),Re=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"}),ts=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"})),La=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"}),Hn=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()})}),Un=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",[Hn,Un]),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 Qe=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"),st=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:Qe.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");st.omit({translations:!0}).extend({title:d.z.string().default(""),description:d.z.string().default("")}).openapi("LocalizedProductCategory");const Zn=st.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(ta("title")).openapi("CreateProductCategory"),qn=st.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(ta("title")).openapi("UpdateProductCategory"),rs=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"),ss=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:Re.optional(),modifiers:d.z.array(rs).optional().openapi({}),translations:d.z.array(d.z.object({locale:Re,title:d.z.string().optional().openapi({example:"Size",description:"Title of the modifier group"})}))}).openapi("ModifierGroup"),$n=ss.extend({title:d.z.string().default("").nullable()}).omit({translations:!0}).openapi("LocalizedModifierGroup"),is=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:Re.optional(),modifiers:d.z.array(rs).optional().openapi({}),translations:d.z.array(d.z.object({locale:Re,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(ta("title")).openapi("CreateOrUpdateModifierGroup"),ns=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"}),basePrice:La,discountedBasePrice:ts,currency:d.z.string().openapi({example:"USD",description:"Currency code for pricing"}),images:d.z.array(Qe).optional().openapi({description:"List of product images"}),modifierGroups:d.z.array(ss).optional().openapi({description:"List of product modifier groups"}),categories:d.z.array(st).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:Re,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"),_n=ns.extend({title:d.z.string().default(""),description:d.z.string().nullable().default(""),modifierGroups:d.z.array($n),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"),os=ns.pick({slug:!0,sku:!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(is).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"})}),Wn=os.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"}),ta("title")(a,t))).openapi("CreateProduct"),Gn=os.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"}),ta("title")(a,t))).openapi("UpdateProduct");d.z.record(d.z.string().openapi({example:"clf9876543210abcdef",description:"ID of the product in the cart"}),_n);const ls=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"),Kn=d.z.object({items:d.z.array(ls),shippingMethodId:d.z.string().cuid().optional()});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 Xn=d.z.string().min(1).openapi({example:"stripe",description:"Integration type key"}),Mt=d.z.enum(["card","blik"]).openapi({example:"card",description:"Stripe payment method"});d.z.object({paymentMethods:d.z.array(Mt).max(2).optional(),secretKey:d.z.string().trim().min(1).optional(),webhookSecret:d.z.string().trim().min(1).optional()}).strict();const it=d.z.object({paymentMethods:d.z.array(Mt).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"),Yn=d.z.object({paymentMethods:d.z.array(Mt).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"),eo=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:Xn,config:eo.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"),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:Re.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 ra=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"),nt=ra.pick({addressLineOne:!0,doorNumber:!0,addressLineTwo:!0,zipCode:!0,city:!0,country:!0,placeId:!0}).openapi("CreateAddress"),ds=nt.partial().openapi("UpdateAddress"),ao=ra.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"})}),cs=ao.pick({firstname:!0,lastname:!0,phone:!0,addressLineOne:!0,addressLineTwo:!0,doorNumber:!0,zipCode:!0,city:!0,country:!0,placeId:!0,deliveryInstructions:!0});cs.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 Bt=d.z.enum(["card","blik","cash_on_delivery","paypal"]).openapi({description:"The payment method",example:"card"}),Tt=d.z.enum(["stripe","revolut","payu","not_applicable"]).openapi({description:"The payment method",example:"card"}),to=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:Tt,method:Bt,description:d.z.string().min(1)}).openapi({description:"The payment method",example:{provider:"stripe",type:"card"}});const ro=d.z.object({id:d.z.string().cuid().min(1),method:Bt,provider:Tt,status:to,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:tt}),ur=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:La.openapi({example:10,description:"Ending distance for the shipping zone"}),price:La.openapi({example:5.99,description:"Price for shipping in this zone"}),minimumOrderAmount:ts.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"),ms=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:Qe.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(ur).openapi({description:"List of shipping zones for this shipping method"}),eligibleShippingZone:ur.optional(),createdAt:d.z.date(),updatedAt:d.z.date()}).openapi("ShippingMethod"),us=ms.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"),so=us.partial().openapi("UpdateShippingMethod"),io=d.z.enum(["draft","pending","accepted","ready-for-dispatch","dispatched","completed","cancelled"]).openapi({description:"Status of the order",example:"accepted"}),no=d.z.object({translations:d.z.array(d.z.object({locale:Re.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:ls,unitPrice:d.z.number().min(0).openapi({description:"Price per unit of the item",example:299.99}),image:Qe.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");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:io.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(no).min(1).openapi({description:"Array of items in the order"}),shippingMethod:ms.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"}),shippingAddress:ra.nullable().optional(),fulfilmentMethod:St.openapi({description:"Method of order fulfilment (pickup or delivery)",example:"delivery"}),currency:tt.openapi({description:"Currency used for the order",example:"USD"}),payment:ro}).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"),Kn.extend({fulfilmentMethod:St.default("delivery"),payment:d.z.object({provider:Tt,method:Bt}),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 pr=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"),ps=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"}),isOpen:d.z.boolean().default(!1).openapi({example:!0,description:"Indicates if the organization is currently open"}),defaultLocale:Re,supportedLocales:d.z.array(Re).openapi({description:"List of supported locales for the organization"}),openingTimes:pr.optional(),closingTimes:pr.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:tt.openapi({example:"USD",description:"Default currency for the organization"}),createdAt:d.z.date().openapi({description:"Timestamp when the organization configuration was created"})}).openapi("OrganizationConfiguration"),oo=ps.pick({hostname:!0,countriesShipping:!0,stripeAccountId:!0,enableHostCheckout:!0,enableHostTracking:!0,isAcceptingOrders:!0,defaultLocale:!0,supportedLocales:!0,defaultCurrency:!0,openingTimes:!0,closingTimes:!0,facebookProfile:!0,instagramProfile:!0,xProfile:!0}).partial().openapi("UpdateOrganizationConfiguration"),lo=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:ra,configuration:ps.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:Qe.optional().nullable().openapi({description:"The logo of the organization"})}).openapi("Organization"),gs=lo.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:nt}).openapi("CreateOrganization"),Qt=gs.extend({address:ds,configuration:oo}).partial().openapi("UpdateOrganization"),co=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:Qe.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");co.omit({translations:!0}).extend({about:d.z.string().nullable().optional().default("")}).openapi("LocalizedManufacturer");const mo=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:Qe.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(ta("about")).openapi("CreateManufacturer"),uo=d.z.object({name:d.z.string().min(1,"Name is required").optional().openapi({example:"Apple Inc. Updated",description:"Name of the manufacturer"}),logo:Qe.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:ra.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:nt.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:ds.required().openapi({description:"The address of the legal entity"})}).openapi("UpdateLegalEntity");const po=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:ra.nullable().optional().openapi({description:"Address of the customer"}),createdAt:d.z.date(),updatedAt:d.z.date()}).openapi("Customer"),go=po.pick({firstname:!0,email:!0,phone:!0}).extend({address:nt}).openapi("Customer");go.partial().openapi("UpdateCustomer");const Ot=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"),hs=Ot.pick({email:!0,password:!0}).openapi("SignIn"),ho=d.z.object({organizationId:d.z.string().cuid().min(1,"organizationId is required").openapi({example:"ckel0e8qw00004n5p5w6fznym",description:"The organization ID"})}).openapi("OrganizationParams");ho.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 xo=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:La,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"),fo=xo.pick({firstname:!0,lastname:!0,guests:!0,phone:!0,date:!0}).openapi("CreateReservation");function $e(...a){return Rr.twMerge(Fr(...a))}const xs=["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"],yo=["ring-2","border-red-500 dark:border-red-700","ring-red-200 dark:ring-red-700/30"],fs=Se.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"}}),K=h.forwardRef(({asChild:a,isLoading:t=!1,loadingText:r,className:s,disabled:i,variant:n,children:o,...l},c)=>{const m=a?Dt.Slot:"button";return e.jsx(m,{ref:c,className:w(fs({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(z.RiLoader2Fill,{className:"size-4 shrink-0 animate-spin","aria-hidden":"true"}),e.jsx("span",{className:"sr-only",children:r||"Loading"}),r||"Loading"]}):o})});K.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:"🇪🇹"}]}],ka=a=>e.jsx(W.Root,{...a});ka.displayName="Dialog";const ys=W.Trigger;ys.displayName="DialogTrigger";const bs=W.Close;bs.displayName="DialogClose";const js=W.Portal;js.displayName="DialogPortal";const ws=h.forwardRef(({className:a,...t},r)=>e.jsx(W.Overlay,{ref:r,className:w("fixed inset-0 z-50 overflow-y-auto","bg-black/70","data-[state=open]:animate-dialogOverlayShow",a),...t}));ws.displayName="DialogOverlay";const va=h.forwardRef(({className:a,...t},r)=>e.jsx(js,{children:e.jsx(ws,{children:e.jsx(W.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",sa,a),...t})})}));va.displayName="DialogContent";const Lt=({className:a,...t})=>e.jsx("div",{className:w("flex flex-col gap-y-1",a),...t});Lt.displayName="DialogHeader";const ot=h.forwardRef(({className:a,...t},r)=>e.jsx(W.Title,{ref:r,className:w("text-lg font-semibold","text-gray-900 dark:text-gray-50",a),...t}));ot.displayName="DialogTitle";const ks=h.forwardRef(({className:a,...t},r)=>e.jsx(W.Description,{ref:r,className:w("text-gray-500 dark:text-gray-500",a),...t}));ks.displayName="DialogDescription";const vs=({className:a,...t})=>e.jsx("div",{className:w("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...t});vs.displayName="DialogFooter";const Na=C.forwardRef(({className:a,...t},r)=>e.jsx($.Command,{ref:r,className:w("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",a),...t}));Na.displayName=$.Command.displayName;const bo=({children:a,...t})=>e.jsx(ka,{...t,children:e.jsx(va,{className:"overflow-hidden p-0",children:e.jsx(Na,{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})})}),lt=C.forwardRef(({className:a,...t},r)=>e.jsxs("div",{className:"flex items-center border-b pl-3","cmdk-input-wrapper":"",children:[e.jsx(v.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx($.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})]}));lt.displayName=$.Command.Input.displayName;const dt=C.forwardRef(({className:a,...t},r)=>e.jsx($.Command.List,{ref:r,className:w("max-h-[300px] overflow-y-auto overflow-x-hidden",a),...t}));dt.displayName=$.Command.List.displayName;const ct=C.forwardRef((a,t)=>e.jsx($.Command.Empty,{ref:t,className:"py-6 text-center text-sm",...a}));ct.displayName=$.Command.Empty.displayName;const mt=C.forwardRef(({className:a,...t},r)=>e.jsx($.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}));mt.displayName=$.Command.Group.displayName;const Ns=C.forwardRef(({className:a,...t},r)=>e.jsx($.Command.Separator,{ref:r,className:w("-mx-1 h-px bg-border",a),...t}));Ns.displayName=$.Command.Separator.displayName;const ut=C.forwardRef(({className:a,...t},r)=>e.jsx($.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}));ut.displayName=$.Command.Item.displayName;const As=({className:a,...t})=>e.jsx("span",{className:w("ml-auto text-xs tracking-widest text-muted-foreground",a),...t});As.displayName="CommandShortcut";const ia=a=>e.jsx(G.Root,{...a});ia.displayName="Popover";const na=C.forwardRef((a,t)=>e.jsx(G.Trigger,{ref:t,...a}));na.displayName="PopoverTrigger";const Cs=C.forwardRef((a,t)=>e.jsx(G.Anchor,{ref:t,...a}));Cs.displayName="PopoverAnchor";const Ss=C.forwardRef((a,t)=>e.jsx(G.Close,{ref:t,...a}));Ss.displayName="PopoverClose";const oa=C.forwardRef(({className:a,sideOffset:t=10,side:r="bottom",align:s="center",collisionPadding:i,...n},o)=>e.jsx(G.Portal,{children:e.jsx(G.Content,{ref:o,sideOffset:t,side:r,align:s,collisionPadding:i,avoidCollisions:!0,className:$e("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})}));oa.displayName="PopoverContent";const zs=({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(ia,{open:r?!1:i,onOpenChange:r?void 0:n,children:[e.jsx(na,{asChild:!0,children:e.jsxs(K,{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(v.ChevronDown,{size:16,strokeWidth:2,className:"shrink-0 text-muted-foreground/80","aria-hidden":"true"})]})}),e.jsx(oa,{className:"w-full min-w-[var(--radix-popper-anchor-width)] border-input -mt-1 z-50",align:"start",children:e.jsxs(Na,{className:"p-0",children:[e.jsx(lt,{className:"w-full border-none",style:{boxShadow:"none"},placeholder:"Search country..."}),e.jsxs(dt,{children:[e.jsx(ct,{children:"No country found."}),gr.map(l=>e.jsx(h.Fragment,{children:e.jsx(mt,{heading:l.continent,children:l.items.map(c=>e.jsxs(ut,{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(v.Check,{size:16,strokeWidth:2,className:"ml-auto"})]},c.value))})},l.continent))]})]})})]})})},jo=Se.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",xs],variants:{hasError:{true:yo},enableStepper:{false:"[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none"},multiline:{true:"resize-y min-h-[100px]",false:"truncate appearance-none"}}}),ve=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,f=i==="search"&&!n,x=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(x,{ref:m,type:g?u:i,className:w(jo({hasError:r,enableStepper:n?!1:s,multiline:n}),{"pl-16":o,"pl-8":!o&&f,"pr-10":l||!l&&g},t),...c}),!o&&f&&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(z.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",{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(z.RiEyeFill,{className:"size-5"}):e.jsx(z.RiEyeOffFill,{className:"size-5"})})})]})});ve.displayName="Input";const Is=({...a})=>{const t=h.useId();return e.jsx("div",{className:"mt-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(ve,{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(v.MailIcon,{size:16})})]})})},Es=a=>{const{client:t}=E(),[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 f=await Dr.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(x){n(x.percentage)}});return{id:p.id,filename:u.name,mimeType:u.type,size:u.size,url:f.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 f=a.value??[];a.onChange([...f,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(v.XIcon,{className:"w-4 h-4 text-white"})}),e.jsx(xe,{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(v.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(v.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()})},pt=({value:a,onChange:t,placeholder:r="Search for a place"})=>{const{client:s}=E(),i=h.useId(),[n,o]=h.useState(!1),[l,c]=h.useState(""),[m,u]=h.useState(null),p=h.useRef(null),[g]=Te.useDebounce(l,300);h.useEffect(()=>{a&&(m==null?void 0:m.text)!==a&&c(a)},[a,m]);const{data:f=[],error:x,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}),y=b=>{u(b),c(b.text);const k={placeId:b.placeId,text:b.text,addressLineOne:b.addressLineOne,addressLineTwo:b.addressLineTwo};t(k),o(!1)};return h.useEffect(()=>{n&&p.current&&p.current.focus()},[n]),e.jsxs("div",{className:"mt-2 relative",children:[e.jsxs(ia,{open:n,onOpenChange:o,children:[e.jsx(na,{asChild:!0,children:e.jsxs(K,{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(v.ChevronDown,{size:16,strokeWidth:2,className:"shrink-0 text-muted-foreground/80","aria-hidden":"true"})]})}),e.jsxs(oa,{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(v.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(v.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&&f.length===0&&e.jsx("p",{className:"py-6 text-center text-sm text-muted-foreground",children:"No places found"}),!j&&l.length>=2&&f.length>0&&e.jsxs("div",{className:"py-1",children:[e.jsxs("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:["Found ",f.length," results"]}),f.map((b,k)=>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(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(v.Check,{size:16,strokeWidth:2,className:"ml-auto"})]},`${b.placeId||"place"}-${k}`))]})]})]})]}),x&&e.jsxs("p",{className:"text-xs text-red-500 mt-1",children:["Error fetching results: ",x.message]})]})},Ds=h.forwardRef(({...a},t)=>e.jsx(ve,{...a,inputClassName:"border-l-0 rounded-l-none",ref:t,className:""}));Ds.displayName="PhoneInput";const wo=({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(Fs,{country:t,countryName:t,"aria-hidden":"true"}),e.jsx("span",{className:"text-muted-foreground/80",children:e.jsx(v.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&&`+${Xa.getCountryCallingCode(n.value)}`]},n.value??`empty-${o}`))]})]})},Fs=({country:a,countryName:t})=>{const r=Mr[a];return e.jsx("span",{className:"w-5 overflow-hidden rounded-xs",children:r?e.jsx(r,{title:t}):e.jsx(v.Phone,{size:16,"aria-hidden":"true"})})},Rs=({value:a,onChange:t,onBlur:r})=>{const s=h.useId();return e.jsx("div",{className:"mt-2",children:e.jsx(Xa.default,{id:s,className:"flex rounded-lg shadow-2xs shadow-black/5",international:!0,flagComponent:Fs,countrySelectComponent:wo,inputComponent:Ds,placeholder:"Enter phone number",value:a,onChange:i=>t(i??""),onBlur:r})})},Ps=({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(f=>f!==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(f=>f!==p);r(g)}};return e.jsx("div",{className:"mt-2",children:e.jsxs(ia,{open:o,onOpenChange:l,children:[e.jsx(na,{asChild:!0,children:e.jsxs(K,{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(f=>f.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(v.X,{size:12,onClick:f=>{f.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(v.ChevronDown,{size:16,strokeWidth:2,className:"shrink-0 text-muted-foreground/80","aria-hidden":"true"})]})}),e.jsx(oa,{className:"w-full min-w-[var(--radix-popper-anchor-width)] border-input -mt-1 z-50 p-0",align:"start",children:e.jsxs(Na,{className:"p-0",children:[e.jsx(lt,{className:"w-full border-none pl-0",style:{boxShadow:"none"},placeholder:"Search..."}),e.jsxs(dt,{children:[e.jsx(ct,{children:"No options found."}),e.jsx(mt,{children:a.map(p=>e.jsxs(ut,{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(v.Check,{size:16,strokeWidth:2,className:"ml-auto"})]},p.value))})]})]})})]})})},ko=Se.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"}}),Jt=h.forwardRef(({className:a,size:t,...r},s)=>{const{root:i,thumb:n}=ko({size:t});return e.jsx(Qa.Root,{ref:s,className:w(i(),a),...r,children:e.jsx(Qa.Thumb,{className:w(n())})})});Jt.displayName="Switch";const Ms=h.forwardRef(({className:a,type:t,...r},s)=>e.jsx("input",{type:t,className:$e("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}));Ms.displayName="TextInput";function Vt({className:a,...t}){const r=h.useId();return e.jsx(Ms,{id:r,placeholder:"00:00",className:w(a,"mt-2"),ref:Wi.withMask("99:99",{placeholder:"-",showMaskOnHover:!1}),...t})}const ye=C.forwardRef(({className:a,disabled:t,...r},s)=>e.jsx(Br.Root,{ref:s,className:$e("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}));ye.displayName="Label";const vo=({value:a,onChange:t,disabled:r})=>{const s=()=>{const y=new Date,b=new Date(y);return b.setMinutes(y.getMinutes()+30),b},i=h.useMemo(()=>{const y=[],b=new Date;for(let k=0;k<7;k++){const N=new Date(b);N.setDate(b.getDate()+k),N.setHours(0,0,0,0),y.push(N)}return y},[]),n=y=>{const b=s();if(y.toDateString()!==new Date().toDateString())return!0;if(b.getHours()>=21&&b.getMinutes()>0)return!1;for(let k=11;k<=21;k++){const N=new Date(y);if(N.setHours(k,0,0,0),N>b)return!0}return!1},o=y=>!n(y),l=h.useMemo(()=>i.find(y=>!o(y))||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 y=[],b=s(),k=c.toDateString()===new Date().toDateString();for(let N=11;N<=21;N++){const R=new Date(c);R.setHours(N,0,0,0),(!k||R>b)&&y.push(`${N}:00`)}return y},[c]),f=y=>{const b=y.toLocaleDateString("en-US",{weekday:"short"}),k=y.toLocaleDateString("en-US",{month:"short"}),N=y.getDate();return{weekday:b,month:k,day:N}},x=y=>{m(y),p(null)},j=y=>{if(p(y),c){const[b]=y.split(":").map(Number),k=new Date(c);k.setHours(b,0,0,0),t(k)}};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(ye,{htmlFor:"date",children:"Select Date"}),e.jsx("div",{className:"grid grid-cols-7 gap-2 mt-2",children:i.map((y,b)=>{const{weekday:k,month:N,day:R}=f(y),O=o(y);return e.jsx("button",{type:"button",disabled:O,className:`p-2 text-center border rounded-md ${O?"opacity-50 cursor-not-allowed":"cursor-pointer"} ${c&&c.toDateString()===y.toDateString()?"storefront-primary-action":"bg-white hover:bg-gray-100"}`,onClick:()=>!O&&x(y),children:e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("span",{className:"text-xs font-medium",children:k}),e.jsx("span",{className:"text-xl font-black font-red-hat-display",children:R}),e.jsx("span",{className:"text-xs font-medium",children:N})]})},b)})})]}),c&&g.length>0&&e.jsxs("div",{className:"col-span-4 mt-4",children:[e.jsx(ye,{htmlFor:"time",children:"Select Time"}),e.jsx("div",{className:"grid grid-cols-5 gap-2 mt-2",children:g.map((y,b)=>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:()=>j(y),children:y},b))})]})]})},Bs=({name:a,type:t,placeholder:r,multiple:s,options:i,disabled:n,prefix:o})=>{const{watch:l,register:c,setValue:m}=L.useFormContext(),u=p=>m(a,p,{shouldDirty:!0,shouldTouch:!0});switch(t){case"email":return e.jsx(Is,{...c(a),placeholder:r});case"file":return e.jsx(Es,{value:l(a),multiple:s,onChange:p=>u(p)});case"week-time":return e.jsx(vo,{value:l(a),onChange:p=>u(p)});case"phone-number":return e.jsx(Rs,{value:l(a),onChange:p=>u(p)});case"country":return e.jsx(zs,{value:l(a),onChange:p=>u(p),disabled:n});case"select":{const p=s?l(a)||[]:l(a)||"";if(!i)throw new Error("Options are required for select input");return e.jsx(Ps,{options:i,value:p,onChange:g=>u(g),placeholder:r,multiple:s})}case"switch":return e.jsx(Jt,{size:"default",className:"mt-2",value:l(a),onCheckedChange:p=>u(p)});case"location":return e.jsx(pt,{value:l(a),onChange:p=>u(p.addressLineOne)});case"time":return e.jsx(Vt,{value:l(a),...c(a)});default:return e.jsx(ve,{...c(a),type:t,rows:t==="textarea"?4:void 0,placeholder:r,className:"mt-2",prefix:o})}},Ts=(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,me=({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}=L.useFormState(),g=Ts(p,t);return e.jsxs("div",{className:w("w-full",s),children:[typeof r=="string"&&e.jsxs(ye,{htmlFor:t,className:"font-medium flex items-center justify-between",children:[e.jsxs("span",{className:"flex items-center",children:[r,c&&e.jsx(v.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:[rt.get(i)," (",i,")"]})]}),e.jsx(Bs,{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})]})},Qs=({isOpen:a,onClose:t,children:r})=>e.jsx(Xe.Transition,{show:a,as:h.Fragment,children:e.jsx(Xe.Dialog,{as:"div",className:"fixed inset-0 overflow-hidden",onClose:t,children:e.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[e.jsx(Xe.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(Xe.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(Xe.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})})})})]})})}),No=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"),Os=({open:a=!1,onOpenChange:t,defaultOpen:r=!1,disableAutoFocus:s=!0,children:i})=>e.jsxs(G.Root,{open:a,onOpenChange:t,defaultOpen:r,children:[e.jsx(G.Anchor,{className:w("fixed inset-x-0 bottom-8 mx-auto flex w-fit items-center")}),e.jsx(G.Portal,{children:e.jsx(G.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})})]});Os.displayName="CommandBar";const Ls=C.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}));Ls.displayName="CommandBar.Value";const Js=C.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}));Js.displayName="CommandBarBar";const Vs=C.forwardRef(({className:a,...t},r)=>e.jsx("div",{ref:r,className:w("h-4 w-px bg-gray-700",a),...t}));Vs.displayName="CommandBar.Seperator";const Hs=C.forwardRef(({className:a,type:t="button",label:r,action:s,shortcut:i,disabled:n,...o},l)=>(C.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:No,children:i.label?i.label.toUpperCase():i.shortcut.toUpperCase()})]})})));Hs.displayName="CommandBar.Command";const Ja=C.forwardRef(({className:a,...t},r)=>e.jsx(Ft.Root,{ref:r,className:$e("grid gap-2",a),...t}));Ja.displayName="RadioCardGroup";const Va=C.forwardRef(({className:a,...t},r)=>e.jsx("div",{className:$e("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(Ft.Indicator,{ref:r,className:"flex items-center justify-center",...t,children:e.jsx("div",{className:$e("size size-1.5 shrink-0 rounded-full","bg-white","group-data-disabled:bg-gray-400 dark:group-data-disabled:bg-gray-500")})})}));Va.displayName="RadioCardGroupIndicator";const Ha=C.forwardRef(({className:a,children:t,...r},s)=>e.jsx(Ft.Item,{ref:s,className:$e("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",xs,a),...r,children:t}));Ha.displayName="RadioCardItem";const Us=Se.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"}}),ea=h.forwardRef(({className:a,variant:t,...r},s)=>e.jsx("span",{ref:s,className:w(Us({variant:t}),a),...r}));ea.displayName="Badge";const aa=h.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")})}));aa.displayName="Divider";const Ao=({initialData:a,shippingAndPaymentPageUrl:t})=>{const{itemCount:r}=et(),s=S.useRouter(),{client:i}=E(),n=L.useForm({resolver:ce.zodResolver(cs),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:f}=await i.shipping.createShippingAddress({body:p});if(g!==201)throw new Error("Failed to create shipping address");return f},onSuccess:()=>{s.push(t)}}),m=A.useMutation({mutationFn:async p=>{const{status:g,body:f}=await i.shipping.updateShippingAddress({body:p});if(g!==200)throw new Error("Failed to update shipping address");return f},onSuccess:()=>s.push(t)}),u=p=>{(a?m:c).mutate(p)};return e.jsx("div",{className:"flex flex-col gap-4",children:e.jsx(L.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(me,{name:"firstname",label:"First Name",type:"text",className:"col-span-2",placeholder:"e.g. John"}),e.jsx(me,{name:"lastname",label:"Last Name",type:"text",className:"col-span-2",placeholder:"e.g. Doe"}),e.jsx(me,{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(ye,{htmlFor:"address.addressLineOne",className:"font-medium flex items-center justify-between",children:"Street Address"}),e.jsx(pt,{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(me,{name:"doorNumber",label:"Door Number",type:"text",className:"md:col-span-1 col-span-2",placeholder:"e.g. 123"}),e.jsx(me,{name:"zipCode",label:"Postal Code",type:"text",className:"col-span-2",placeholder:"e.g. 12345"}),e.jsx(me,{name:"city",label:"City",type:"text",className:"col-span-2",placeholder:"e.g. Kraków"}),e.jsx(me,{name:"country",label:"Country",type:"country",className:"col-span-2 md:col-span-4",disabled:!0}),e.jsx(me,{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(K,{variant:"secondary",className:"shadow-none",type:"button",onClick:()=>s.push("/"),children:"Back"}),e.jsx(K,{type:"submit",className:"shadow-none",isLoading:c.isPending||m.isPending,disabled:r===0,loadingText:"Saving...",children:"Save & Continue"})]})]})})})},Co=()=>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"})]}),zt=({shippingAndPaymentPageUrl:a="/checkout/shipping-and-payment"})=>{const t=S.useRouter(),{client:r}=E(),{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(Co,{}):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(Ao,{initialData:s??null,onSuccess:o,shippingAndPaymentPageUrl:a},s==null?void 0:s.id)]})},So=()=>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"})]})]}),zo=({shippingMethods:a,paymentMethods:t,customerDetailsPageUrl:r})=>{const s=S.useRouter(),{client:i,baseUrl:n}=E(),{organizationId:o}=pe(),{items:l,shippingMethod:c,paymentMethod:m,setPaymentMethod:u,setShippingMethod:p}=et(),g=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:x,status:j}=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(j!==201)throw new Error((x==null?void 0:x.message)??"Failed to create order");return x.redirectUrl&&(window.location.href=x.redirectUrl),x}}),f=()=>{g.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(Ja,{className:"flex flex-col gap-2",value:c==null?void 0:c.id,children:a.map(x=>e.jsx(Ha,{value:x.id,disabled:!x.eligibleShippingZone,onClick:()=>p(x),children:e.jsxs("div",{className:w("flex items-center gap-3",{"opacity-60 cursor-not-allowed":!x.eligibleShippingZone}),children:[e.jsx(Va,{}),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:[x.title," (",x.providerName,")"]}),!x.eligibleShippingZone&&e.jsx(ea,{variant:"error",children:"Not Available"})]}),x.eligibleShippingZone&&e.jsxs("p",{className:"text-xs font-medium text-gray-500 mt-0.5",children:["Shipping Fee: ",x.eligibleShippingZone.price," zł ",e.jsx("br",{}),"ETA: ",x.eligibleShippingZone.eta]}),!x.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."]})]})})]})},x.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(Ja,{className:"flex flex-col gap-3",value:m==null?void 0:m.id,children:t.map(x=>e.jsx(Ha,{value:x.id,onClick:()=>u(x),children:e.jsxs("div",{className:w("flex items-center gap-3"),children:[e.jsx(Va,{}),e.jsxs("div",{children:[e.jsx("p",{className:"font-red-hat-display font-black mr-2 capitalize",children:x.method}),e.jsxs("p",{className:"text-xs font-medium text-gray-500 capitalize",children:[x.provider," • ",x.description]})]})]})},x.id))}),g.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:g.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(D,{href:"/terms-and-conditions",className:"storefront-primary-text storefront-primary-text-hover mr-1",children:"Terms & Conditions"}),"and"," ",e.jsx(D,{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(K,{variant:"secondary",className:"shadow-none",onClick:()=>s.push(r),children:"Back"}),e.jsx(K,{className:"shadow-none",onClick:f,isLoading:g.isPending,children:"Pay & Confirm"})]})]})},Zs=({customerDetailsPageUrl:a="/checkout/customer-details"})=>{const{client:t}=E(),{organizationId:r}=pe(),s=S.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(So,{}):e.jsx("div",{className:"flex flex-col gap-3 animate-fade-in",children:e.jsx(zo,{shippingMethods:n.data??[],paymentMethods:o.data??[],customerDetailsPageUrl:a})})},Io=a=>Er.createAuthClient({baseURL:a,plugins:[Ta.inferAdditionalFields(),Ta.organizationClient()]}),qs=h.createContext(void 0),Eo=({children:a,baseURL:t})=>{const r=h.useMemo(()=>Io(t),[t]);return e.jsx(qs.Provider,{value:r,children:a})},ze=()=>{const a=h.useContext(qs);if(a===void 0)throw new Error("useAuth must be used within a AuthProvider");return a},Do=()=>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"})]})]}),Ht=({loading:a=!1,items:t,total:r,subtotal:s,shipping:i,discount:n,currency:o})=>a?e.jsx(Do,{}):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(D,{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},f)=>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(xe,{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((x,j)=>e.jsx("div",{className:"text-white text-xs opacity-50",children:x},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]})]})]})},f))}),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:ue(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:ue(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:["- ",ue(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:ue(r,o)})]})]}),Fo=()=>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(v.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(v.ShoppingBasketIcon,{className:"w-5 h-5 text-gray-300"})]})]})]}),Ro=()=>{const a=S.useRouter(),{useSession:t,signOut:r}=ze(),{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(ia,{children:[e.jsx(na,{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(v.UserIcon,{className:"w-5 h-5 mr-1 group-hover:scale-110 transition-transform duration-200"}),e.jsx("span",{children:"Guest"})]})}),e.jsx(oa,{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(D,{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(v.LayoutDashboardIcon,{className:"h-4 w-4"}),"My account"]}),e.jsxs(D,{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(v.ShoppingBagIcon,{className:"h-4 w-4"}),"Orders"]}),e.jsxs(D,{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(v.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(v.LogOutIcon,{className:"h-4 w-4"}),"Logout"]})]}):e.jsxs(D,{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(v.UserIcon,{className:"h-4 w-4"}),"Sign in"]})})]})})},Aa=({summary:a})=>{const{organization:t,loading:r}=pe(),[s,i]=h.useState(!1);if(r)return e.jsx(Fo,{});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(D,{href:"/",className:"flex items-center",children:[e.jsx("span",{children:e.jsx(v.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(xe,{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(Ro,{})}),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(v.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:ue(a.total,l)}),e.jsx(v.ShoppingBasketIcon,{className:"w-5 h-5"})]},2)})]})]}),a&&e.jsx(Qs,{isOpen:s,onClose:()=>i(!1),children:e.jsx(Ht,{total:a.total,items:a.items,shipping:a.shipping,subtotal:a.subtotal,currency:l})})]})},$s=({children:a,description:t,title:r})=>{const s=r||t;return e.jsxs(e.Fragment,{children:[e.jsx(Aa,{}),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(xe,{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]})})]})})]})},hr=({children:a})=>{const{useSession:t}=ze(),r=S.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($s,{children:a})},He=({children:a})=>{const{useSession:t}=ze(),r=S.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},Po={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"},Me=(a,t="Not available",r="MMM d, yyyy")=>{if(!a)return t;const s=new Date(a);return T.isValid(s)?T.format(s,r):t},_s=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"}},Ws=a=>{switch(a){case"accepted":case"ready-for-dispatch":return"info";case"dispatched":case"completed":return"success";case"cancelled":return"danger";default:return"warning"}},Gs=a=>a.cancelledAt?"Cancelled":a.acceptedAt?"Confirmed":"Pending",Ks=a=>a.cancelledAt?"danger":a.acceptedAt?"success":"warning",Mo=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()},gt=({actions:a,children:t,description:r,eyebrow:s,title:i})=>e.jsxs(e.Fragment,{children:[e.jsx(Aa,{}),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})]})})})]}),Ye=({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]}),Ua=({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",Po[r],t),children:a}),Be=({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(K,{asChild:!0,children:e.jsx(D,{href:a,children:t})})}):null]}),Ut=({description:a="Loading your latest activity.",title:t})=>e.jsxs(gt,{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"})]})]}),Za=({href:a,label:t})=>e.jsxs(D,{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(v.ArrowRightIcon,{className:"h-4 w-4"})]}),Bo=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`},xr=({description:a,href:t,icon:r,title:s})=>e.jsxs(D,{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"})})]})]}),To=()=>{var p,g,f;const{client:a}=E(),{useSession:t}=ze(),{organization:r,organizationId:s}=pe(),{data:i}=t(),n=A.useQuery({queryKey:["account","orders",s],enabled:!!s&&!!(i!=null&&i.user),queryFn:async()=>{const{body:x,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 x}}),o=A.useQuery({queryKey:["account","reservations",s],enabled:!!s&&!!(i!=null&&i.user),queryFn:async()=>{const{body:x,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 x}});if(!(i!=null&&i.user))return null;if(n.isLoading||o.isLoading)return e.jsx(Ut,{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(x=>!x.cancelledAt&&!!x.date&&new Date(x.date).getTime()>Date.now()).sort((x,j)=>new Date(x.date??0).getTime()-new Date(j.date??0).getTime())[0],u=i.user.firstname??((f=i.user.name)==null?void 0:f.split(" ").filter(Boolean)[0])??"there";return e.jsxs(gt,{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(K,{asChild:!0,variant:"secondary",children:e.jsx(D,{href:"/account/orders",children:"View orders"})}),e.jsx(K,{asChild:!0,children:e.jsx(D,{href:"/account/reservations",children:"Reservation history"})})]}),children:[e.jsxs("div",{className:"grid gap-6 lg:grid-cols-[1.25fr_0.95fr]",children:[e.jsx(Ye,{title:"Recent orders",description:"A quick look at what you ordered most recently.",action:e.jsx(Za,{href:"/account/orders",label:"See all"}),children:n.isError?e.jsx(Be,{icon:v.ShoppingBagIcon,title:"Orders unavailable",description:"We couldn't load your recent orders just now. Please refresh and try again."}):l.length===0?e.jsx(Be,{icon:v.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(x=>e.jsx(D,{href:`/account/orders/${x.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:Bo(x)}),e.jsx(Ua,{tone:Ws(x.status),children:_s(x.status)})]}),e.jsxs("p",{className:"mt-2 text-sm leading-6 text-stone-600",children:["Ref ",x.referenceId," • ",x.items.length," item",x.items.length===1?"":"s"," •"," ",x.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:ue(x.payment.total,x.currency)}),e.jsx("p",{className:"mt-1 text-sm text-stone-500",children:Me(x.createdAt,"Recently")})]})]})},x.id))})}),e.jsxs("div",{className:"grid gap-6",children:[e.jsx(Ye,{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(xr,{href:"/account/orders",icon:v.ShoppingBagIcon,title:"Orders list",description:"Review every purchase, total paid, fulfilment method, and live order status."}),e.jsx(xr,{href:"/account/reservations",icon:v.CalendarDaysIcon,title:"Reservation history",description:"See confirmed, pending, and cancelled bookings in one place."})]})}),e.jsx(Ye,{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:Mo(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(v.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(v.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(v.CalendarDaysIcon,{className:"h-4 w-4"}),"Upcoming reservation"]}),e.jsx("span",{className:"font-semibold text-stone-900",children:m?Me(m.date,"Not scheduled","MMM d, yyyy"):"Nothing booked"})]})]}),e.jsx("div",{className:"mt-5",children:e.jsx(K,{asChild:!0,variant:"secondary",children:e.jsx(D,{href:"/account/reservations/book",children:"Book a table"})})})]})})]})]}),e.jsx("div",{className:"mt-6",children:e.jsx(Ye,{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(K,{asChild:!0,variant:"secondary",children:e.jsx(D,{href:"/account/reservations/book",children:"Book a table"})}),e.jsx(Za,{href:"/account/reservations",label:"Open history"})]}),children:o.isError?e.jsx(Be,{icon:v.CalendarDaysIcon,title:"Reservations unavailable",description:"We couldn't load your reservation history just now. Please refresh and try again."}):c.length===0?e.jsx(Be,{icon:v.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(x=>e.jsx(D,{href:`/account/reservations/${x.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:Me(x.date,"Date pending","MMM d, yyyy")}),e.jsx(Ua,{tone:Ks(x),children:Gs(x)})]}),e.jsxs("p",{className:"mt-2 text-sm leading-6 text-stone-600",children:["Ref ",x.referenceId," • ",x.guests," ","guest",x.guests===1?"":"s"]})]}),e.jsx("p",{className:"text-sm font-medium text-stone-500",children:Me(x.date,"Awaiting confirmation","h:mm a")})]})},x.id))})})})]})},Xs=()=>e.jsx(He,{children:e.jsx(To,{})}),Qo={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",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",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."}},Oo={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",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",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."}},fr={en:Qo,pl:Oo},Ys=h.createContext(void 0),Lo=({children:a,locale:t})=>{const r=h.useCallback(i=>{const n=i.split(".");let o=fr[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:fr[t],t:r};return e.jsx(Ys.Provider,{value:s,children:a})},ei=()=>{const a=h.useContext(Ys);if(a===void 0)throw new Error("useTranslation must be used within a TranslationProvider");return a},ai=()=>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))]})})]})})]})}),Jo=({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"})}),Vo=({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"})}),Ho=({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"})]}),ti=({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 T.isValid(u)?T.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(Jo,{className:"w-4 h-4 text-green-500"}),l&&n&&e.jsx(v.PartyPopperIcon,{className:"w-4 h-4 text-violet-500"}),i&&e.jsx(Vo,{className:"w-4 h-4 text-red-500"}),c&&e.jsx(Ho,{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)})]})]})},Uo=({orderId:a})=>{const{client:t}=E(),{organization:r,organizationId:s}=pe(),i=S.useSearchParams(),n=S.useRouter(),o=S.usePathname(),{t:l}=ei(),c=r==null?void 0:r.configuration.defaultCurrency;h.useEffect(()=>{if((i==null?void 0:i.get("clearCart"))==="true"&&o){localStorage.removeItem("shophost-cart");const j=new URLSearchParams(Array.from(i.entries()));j.delete("clearCart");const y=j.toString()?`${o}?${j.toString()}`:o;n.replace(y)}},[i,n,o]);const{data:m,isLoading:u,error:p}=A.useQuery({queryKey:["order",a],refetchInterval:({state:j})=>{var y,b;return((y=j.data)==null?void 0:y.status)!=="completed"&&((b=j.data)==null?void 0:b.status)!=="cancelled"?30*1e3:!1},queryFn:async()=>{const{status:j,body:y}=await t.order.getOrder({params:{id:a,organizationId:s}});if(j!==200)throw new Error("Failed to fetch shipping address");return y}}),g=h.useMemo(()=>m?m==null?void 0:m.items.map(j=>({title:j.translations[0].title,subtitle:[j.translations[0].subtitle],price:ue(j.unitPrice,c??"USD"),unitPrice:ue(j.unitPrice,c??"USD"),quantity:j.quantity,image:j.image})):[],[m,c]);if(!m||u)return e.jsx(ai,{});const{status:f}=m,x=[{title:l("orderTracking.orderPlaced"),description:l("orderTracking.orderPlacedDesc"),date:new Date(m.expiresAt),active:!1},{title:l("orderTracking.orderAccepted"),description:l("orderTracking.orderAcceptedDesc"),date:m.acceptedAt,active:!m.acceptedAt},{title:l("orderTracking.readyForDispatch"),description:l("orderTracking.readyForDispatchDesc"),date:m.readyForDispatchAt,active:f==="accepted"},{title:l("orderTracking.orderDispatched"),description:l("orderTracking.orderDispatchedDesc"),date:m.dispatchedAt,active:f==="ready-for-dispatch"},{title:l("orderTracking.orderDelivered"),description:l("orderTracking.orderDeliveredDesc"),date:m.completedAt,active:f==="dispatched",showConfetti:!0}];return m.status==="cancelled"&&x.push({title:l("orderTracking.orderCancelled"),description:l("orderTracking.orderCancelledDesc"),date:m.cancelledAt,active:!!m.cancelledAt,cancelled:!0}),e.jsxs(e.Fragment,{children:[e.jsx(Aa,{summary:{total:m.payment.total,subtotal:m.payment.subtotal,shipping:m.payment.shipping,items:g}}),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(Ht,{items:g,total:m.payment.total,subtotal:m.payment.subtotal,shipping:m.payment.shipping,currency:c??"USD"}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 text-center mt-14 w-full",children:[l("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:l("checkout.yourOrder")}),e.jsxs("div",{className:"mb-8",children:[e.jsxs("p",{className:"text-sm font-medium text-gray-500",children:[l("orderTracking.reference"),": ",m.referenceId]}),e.jsxs("p",{className:"text-sm font-medium text-gray-500",children:[l("orderTracking.status"),":"," ",e.jsx("span",{className:`capitalize font-semibold ${m.status==="cancelled"?"text-red-600":"text-green-600"}`,children:m.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% - ${x.length>1?"4rem":"0rem"})`}}),x.map((j,y)=>e.jsx(ti,{...j},y))]})})]})})]})})]})},Zo=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`},qo=()=>{var o;const{client:a}=E(),{useSession:t}=ze(),{organizationId:r}=pe(),{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(Ut,{title:"Your orders",description:"Loading your order history."});const n=((o=i.data)==null?void 0:o.list)??[];return e.jsx(gt,{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(K,{asChild:!0,variant:"secondary",children:e.jsx(D,{href:"/account",children:"Back to account"})}),e.jsx(K,{asChild:!0,children:e.jsx(D,{href:"/account/reservations",children:"Reservation history"})})]}),children:e.jsx("div",{children:e.jsx(Ye,{title:"Order history",description:"Open any order to review the full tracker and line items.",action:e.jsx(Za,{href:"/account",label:"Back to dashboard"}),children:i.isError?e.jsx(Be,{icon:v.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(Be,{icon:v.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(D,{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:Zo(l)}),e.jsx(Ua,{tone:Ws(l.status),children:_s(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:ue(l.payment.total,l.currency)}),e.jsx("p",{className:"mt-1 text-sm text-stone-500",children:Me(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))})})})})},$o=({initialData:a})=>{const{client:t}=E(),{organizationId:r}=pe(),s=S.useRouter(),i=L.useForm({resolver:ce.zodResolver(fo),reValidateMode:"onChange",defaultValues:{firstname:a.firstname,lastname:a.lastname}}),n=A.useMutation({mutationFn:async o=>{const{status:l,body:c}=await t.reservation.createReservation({body:o,params:{organizationId:r}});if(l!==201)throw new Error("Failed to create shipping address");return c},onSuccess:o=>{s.push(`/account/reservations/${o.id}`)}});return e.jsx("div",{className:"flex flex-col gap-4",children:e.jsx(L.FormProvider,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(o=>n.mutate(o)),children:[e.jsxs("div",{className:"grid grid-cols-4 gap-x-4 gap-y-4 mt-3",children:[e.jsx(me,{name:"firstname",label:"First Name",type:"text",className:"col-span-2",placeholder:"e.g. John"}),e.jsx(me,{name:"lastname",label:"Last Name",type:"text",className:"col-span-2",placeholder:"e.g. Doe"}),e.jsx(me,{name:"phone",label:"Phone",type:"phone-number",className:"col-span-4",placeholder:"e.g. +48 123 456 789"}),e.jsx(me,{name:"guests",label:"Number of Guests",type:"number",className:"col-span-4",placeholder:"e.g. 2"}),e.jsx(me,{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(K,{variant:"secondary",className:"shadow-none",type:"button",onClick:()=>s.push("/"),children:"Back"}),e.jsx(K,{type:"submit",className:"shadow-none",isLoading:n.isPending,loadingText:"Saving...",children:"Send Request"})]})]})})})},_o=()=>{const{useSession:a}=ze(),{data:t}=a();return t!=null&&t.user?e.jsx($s,{title:"Book a table",description:"Enter your details to book a table at Madras Bistro",children:e.jsx($o,{initialData:{firstname:t.user.firstname,lastname:t.user.lastname}})}):null},yr=(a,t)=>{if(!a)return t("reservation.notSpecified");const r=new Date(a);return T.isValid(r)?T.format(r,"MMM d, yyyy - h:mm a"):t("reservation.invalidDate")},Wo=({reservationId:a})=>{const{client:t}=E(),{organizationId:r}=pe(),{t:s}=ei(),{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(ai,{});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(Aa,{}),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"),":"]})," ",yr(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"),":"]})," ",yr(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(ti,{...c},m))]})})]})})]})]})},Go=()=>{var o;const{client:a}=E(),{useSession:t}=ze(),{organizationId:r}=pe(),{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(Ut,{title:"Reservation history",description:"Loading your reservations."});const n=((o=i.data)==null?void 0:o.list)??[];return e.jsx(gt,{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(K,{asChild:!0,variant:"secondary",children:e.jsx(D,{href:"/account",children:"Back to account"})}),e.jsx(K,{asChild:!0,children:e.jsx(D,{href:"/account/reservations/book",children:"Book a table"})})]}),children:e.jsx("div",{children:e.jsx(Ye,{title:"Your bookings",description:"Open any reservation to review the confirmation timeline and details.",action:e.jsx(Za,{href:"/account",label:"Back to dashboard"}),children:i.isError?e.jsx(Be,{icon:v.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(Be,{icon:v.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(D,{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:Me(l.date,"Date pending","EEEE, MMM d")}),e.jsx(Ua,{tone:Ks(l),children:Gs(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:Me(l.date,"Awaiting time","h:mm a")}),e.jsxs("p",{className:"mt-1 text-sm text-stone-500",children:["Created"," ",Me(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))})})})})},Ko=()=>{const a=S.useSearchParams(),{signIn:t}=ze(),{baseUrl:r}=E(),s=(a==null?void 0:a.get("redirect"))??"/checkout/customer-details",{register:i,handleSubmit:n,formState:{errors:o,isSubmitting:l}}=L.useForm({resolver:ce.zodResolver(hs),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(D,{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(K,{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(z.RiGoogleFill,{className:"size-4","aria-hidden":"true"}),"Login with Google"]})}),e.jsx(aa,{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(ye,{htmlFor:"email-form-item",className:"font-medium",children:"Email"}),e.jsx(ve,{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(ye,{htmlFor:"password-form-item",className:"font-medium",children:"Password"}),e.jsx(ve,{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(K,{type:"submit",className:"shadow-none",isLoading:l,children:l?"Submitting...":"Continue"})]})]}),e.jsx(aa,{}),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"})]})]})},Xo=()=>e.jsx(Ko,{}),Yo=()=>{const a=S.useSearchParams(),{signUp:t,signIn:r}=ze(),{baseUrl:s}=E(),i=(a==null?void 0:a.get("redirect"))??"/checkout/customer-details",{register:n,handleSubmit:o,formState:{errors:l}}=L.useForm({resolver:ce.zodResolver(Ot),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(D,{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(K,{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(z.RiGoogleFill,{className:"size-4","aria-hidden":"true"}),"Signin with Google"]})}),e.jsx(aa,{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(ye,{htmlFor:"email-form-item",className:"font-medium",children:"First Name"}),e.jsx(ve,{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(ye,{htmlFor:"email-form-item",className:"font-medium",children:"Last Name"}),e.jsx(ve,{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(ye,{htmlFor:"email-form-item",className:"font-medium",children:"Email"}),e.jsx(ve,{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(ye,{htmlFor:"password-form-item",className:"font-medium",children:"Password"}),e.jsx(ve,{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(K,{type:"submit",isLoading:c,children:c?"Submitting...":"Continue"})]})]}),e.jsx(aa,{}),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"})]})]})})},el=()=>e.jsx(Yo,{}),al=()=>{const{segments:a}=S.useParams(),[t,...r]=a??[];if(!t)return e.jsx(He,{children:e.jsx(Xs,{})});switch(t){case"sign-in":return r.length!==0?S.notFound():e.jsx(hr,{children:e.jsx(Xo,{})});case"sign-up":return r.length!==0?S.notFound():e.jsx(hr,{children:e.jsx(el,{})});case"orders":return r.length>1?S.notFound():r.length===0?e.jsx(He,{children:e.jsx(qo,{})}):e.jsx(He,{children:e.jsx(Uo,{orderId:r[0]})});case"reservations":return r.length>1?S.notFound():r.length===0?e.jsx(He,{children:e.jsx(Go,{})}):r[0]==="book"?e.jsx(He,{children:e.jsx(_o,{})}):e.jsx(He,{children:e.jsx(Wo,{reservationId:r[0]})});default:return S.notFound()}},tl=a=>{if(a[0]==="reservation"&&a.length===1)return e.jsx(zt,{});if(a.length!==1)return S.notFound();switch(a[0]){case"customer-details":return e.jsx(zt,{});case"shipping-and-payment":return e.jsx(Zs,{});default:return S.notFound()}},rl=()=>{const a=S.useParams(),{useSession:t}=ze(),r=S.useRouter(),{data:s,isPending:i}=t(),{loading:n,formattedCartItems:o,total:l,subtotal:c,shipping:m}=et(),{organization:u,loading:p}=pe(),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 f=[u.phone,u.email].filter(x=>!!x);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.",f.map(x=>e.jsxs(h.Fragment,{children:[e.jsx("br",{}),x]},x))]}),e.jsx(D,{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.",f.map(x=>e.jsxs(h.Fragment,{children:[e.jsx("br",{}),x]},x))]}),e.jsx(D,{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(Aa,{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(Ht,{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:tl(g)})})]})})]})},ri=({children:a})=>{const{isOpen:t,onClose:r,product:s,modifierGroups:i,hasModifiers:n,productName:o,quantity:l,handleIncrement:c,handleDecrement:m,handleAddToCart:u,validationError:p}=wa();if(!s)return null;const g=l<=1;return a({modifierGroups:i,hasModifiers:n,product:s,isOpen:t,onClose:r,productName:o,quantity:l,onIncrement:c,onDecrement:m,isDecrementDisabled:g,onAddToCart:u,validationError:p})},si=({children:a,group:t,renderOptions:r})=>{const{getModifierGroupName:s}=wa(),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})},ii=({children:a,modifier:t,groupId:r})=>{var x;const{isModifierSelected:s,isMultiSelect:i,toggleModifier:n,selectModifier:o,formatModifierPrice:l,product:c,locale:m}=wa(),u=s(r,t.id),p=(x=c==null?void 0:c.modifierGroups)==null?void 0:x.find(j=>j.id===r),g=p?i(p):!1,f=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:f})},sl=e.jsx("div",{className:"p-4 text-center text-gray-500",children:"This product has no modifiers."}),il=({addToCartLabel:a="Add to Cart",emptyState:t=sl,panelClassName:r,renderFooter:s,renderGroup:i,renderHeader:n,renderOption:o})=>e.jsx(ri,{children:({isOpen:l,onClose:c,product:m,modifierGroups:u,quantity:p,onIncrement:g,onDecrement:f,isDecrementDisabled:x,onAddToCart:j,validationError:y})=>e.jsx(ka,{open:l,onOpenChange:b=>{b||c()},children:e.jsxs(va,{className:w("w-full sm:max-w-md max-h-[75vh] sm:max-h-[90vh] overflow-auto p-0","top-auto left-0 right-0 bottom-0 translate-x-0 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:c,product:m}):e.jsxs("div",{className:"flex justify-between items-start p-4",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",{className:"mt-4 sm:mt-0",children:[e.jsx(ot,{className:"text-2xl font-black font-red-hat-display",children:m.title}),e.jsx("p",{className:"text-sm text-gray-500",children:m.description})]}),e.jsx("button",{type:"button",onClick:c,className:"cursor-pointer text-gray-500 hover:text-gray-700 text-2xl leading-none mt-4 sm:mt-0","aria-label":"Close modal",children:"×"})]}),u.length>0?e.jsx("div",{className:"px-4",children:u.map(b=>e.jsx(si,{group:b,renderOptions:()=>b.modifiers.map(k=>e.jsx(ii,{modifier:k,groupId:b.id,children:N=>o?o(N):e.jsxs("div",{className:w("flex items-center py-2.5 px-3 border rounded-lg cursor-pointer text-sm font-medium text-gray-600 dark:text-gray-400 mb-2",N.isSelected?"border-blue-500 bg-blue-50":"border-gray-200"),onClick:N.onSelect,children:[e.jsx("input",{type:N.isMultiSelect?"checkbox":"radio",checked:N.isSelected,className:"mr-2",onChange:R=>R.preventDefault()}),e.jsxs("span",{children:[N.modifier.title,N.formattedPrice]})]})},k.id)),children:k=>i?i(k):e.jsxs("div",{className:"mb-4",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:[k.groupName,k.isRequired&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),k.selectionRequirements&&e.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Select ",k.selectionRequirements]})]}),e.jsx("div",{children:k.renderOptions()})]})},b.id))}):t,s?s({isDecrementDisabled:x,onAddToCart:j,onDecrement:f,onIncrement:g,quantity:p,validationError:y}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"p-4 flex items-center justify-center border-t mt-8",children:[e.jsx("button",{type:"button",onClick:f,className:w("w-8 h-8 flex items-center justify-center border rounded-lg",x?"opacity-50 cursor-not-allowed":"cursor-pointer"),"aria-label":"Decrease quantity",disabled:x,children:"-"}),e.jsx("span",{className:"w-12 text-center",children:p}),e.jsx("button",{type:"button",onClick:g,className:"w-8 h-8 flex items-center justify-center border rounded-lg cursor-pointer","aria-label":"Increase quantity",children:"+"})]}),e.jsxs("div",{className:"p-4 border-t",children:[y&&e.jsx("div",{className:"text-red-500 mb-2",children:y}),e.jsx("button",{type:"button",onClick:j,className:"storefront-primary-action btn text-sm rounded-lg w-full",children:a})]})]})]})})}),nl=({children:a,minQuantity:t=1})=>{const{quantity:r,handleIncrement:s,handleDecrement:i}=wa(),n=r<=t;return a({quantity:r,onIncrement:s,onDecrement:i,isDecrementDisabled:n})},ol=({children:a,locale:t="en"})=>e.jsx(Xr,{locale:t,children:a}),ll=(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}},dl=(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,f)=>(g[f.id]=f,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}},cl=[{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."}]}],ml=new A.QueryClient({defaultOptions:{queries:{retry:!1,refetchInterval:!1,refetchOnWindowFocus:!1}}}),qa="#ffffff",br="#0f172a",ni=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/,ul=/^(?:rgb|rgba|hsl|hsla|oklch|oklab|var)\([^;{}]+\)$/i,pl=/^(?:bg-)?([a-z]+(?:-[a-z]+)*)-(\d{2,3})$/,It=nn,gl=It.teal,jr=gl[500],hl=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},Ct=a=>{const t=a/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4},wr=a=>{const t=hl(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*Ct(r)+.7152*Ct(s)+.0722*Ct(i)},kr=(a,t)=>{const r=wr(a),s=wr(t),i=Math.max(r,s),n=Math.min(r,s);return(i+.05)/(n+.05)},vr=a=>{if(ni.test(a)){const r=kr(a,"#ffffff"),s=kr(a,"#000000");return r>=s?qa:br}const t=a.match(/^oklch\(([\d.]+)%/i);return t&&Number.parseFloat(t[1])>=78?br:qa},xl=a=>{const t=a.match(pl);if(t){const[,i,n]=t,o=It[i];if(o&&typeof o!="string")return o[n]}const r=a.replace(/^bg-/,""),s=It[r];if(typeof s=="string")return s},fl=a=>{const t=a==null?void 0:a.trim();if(!t)return{color:jr,foreground:qa};const r=xl(t);return r?{color:r,foreground:vr(r)}:ni.test(t)||ul.test(t)?{color:t,foreground:vr(t)}:{color:jr,foreground:qa}},yl=a=>{const{color:t,foreground:r}=fl(a==null?void 0:a.primaryColor);return`:root{--storefront-primary:${t};--storefront-primary-foreground:${r};}`},bl=({appearance:a,children:t})=>{const r=a!=null&&a.primaryColor?yl(a):null;return e.jsxs(e.Fragment,{children:[r?e.jsx("style",{"data-shophost-storefront-appearance":!0,suppressHydrationWarning:!0,children:r}):null,t]})},jl=({appearance:a,baseUrl:t,children:r,initialOrganization:s,locale:i="en",modifiersModal:n,organizationId:o})=>e.jsx(bl,{appearance:a,children:e.jsx(Lo,{locale:i,children:e.jsx(Eo,{baseURL:t,children:e.jsx(Rt,{baseUrl:t,children:e.jsx(A.QueryClientProvider,{client:ml,children:e.jsx(Sn,{initialOrganization:s,organizationId:o,children:e.jsx(_r,{locale:i,organizationId:o,children:e.jsxs(Xr,{locale:i,children:[r,n]})})})})})})})});function X(...a){return Rr.twMerge(Fr(...a))}const la=["focus:ring-2","focus:ring-blue-200 dark:focus:ring-blue-700/30","focus:border-blue-500 dark:focus:border-blue-700"],ge=["outline outline-offset-2 outline-0 focus-visible:outline-2","outline-blue-500 dark:outline-blue-500"],ht=["ring-2","border-red-500 dark:border-red-700","ring-red-200 dark:ring-red-700/30"],wl=(a,t=0)=>Intl.NumberFormat("us",{minimumFractionDigits:t,maximumFractionDigits:t}).format(Number(a)).toString(),ne={currency:(a,t="USD")=>new Intl.NumberFormat("en-US",{style:"currency",currency:t}).format(a),unit:a=>`${wl(a)}`},kl=Se.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",ge],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"}}),I=h.forwardRef(({asChild:a,isLoading:t=!1,loadingText:r,className:s,disabled:i,variant:n,children:o,...l},c)=>{const m=a?Dt.Slot:"button";return e.jsx(m,{ref:c,className:w(kl({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(z.RiLoader2Fill,{className:"size-4 shrink-0 animate-spin","aria-hidden":"true"}),e.jsx("span",{className:"sr-only",children:r||"Loading"}),r||"Loading"]}):o})});I.displayName="Button";function Zt({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(I,{className:"mt-3",onClick:a,children:"Reload Page"})]})})})}const xt=h.createContext({});function vl({children:a,organizationId:t,id:r}){return e.jsx(xt.Provider,{value:{organizationId:t,id:r},children:a})}function Nl(){return h.useContext(xt)}function V(){const{organizationId:a}=h.useContext(xt);if(!a)throw new Error("useOrgId called outside an org-scoped route");return a}function da(){const{id:a}=h.useContext(xt);if(!a)throw new Error("useRouteId called outside a detail route");return a}const Al=h.createContext(void 0),Cl=({children:a,initialState:t=!1})=>{const[r,s]=h.useState(t);return e.jsx(Al.Provider,{value:{flyoutOpen:r,setFlyoutOpen:s},children:a})},ie=({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"})]}),oi=h.createContext(null),Nr=({children:a})=>{var c,m,u,p,g;const{client:t}=E(),{organizationId:r}=Nl(),s=A.useQuery({queryKey:["organizations"],queryFn:async()=>{const{body:f,status:x}=await t.organization.getOrganizations();if(x!==200)throw x!==401&&Q.error("Failed to update organizations list. Please refresh the page or try again later."),new Error("Failed to fetch organizations");return f},retry:!1}),i=A.useQuery({queryKey:["organization",r],queryFn:async()=>{const{body:f,status:x}=await t.organization.getOrganization({params:{organizationId:r}});if(x!==200)throw x!==401&&Q.error("Failed to fetch organization. Please try refreshing the page or try again later."),new Error("Failed to fetch organizations");return f},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(f=>f===n?-1:1))||["en"];return e.jsx(oi.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(ie,{className:"w-12 h-12"}),e.jsx("p",{className:"text-gray-500 text-sm mt-3",children:"Loading data..."})]})}):a})},he=()=>{const a=h.useContext(oi);if(!a)throw new Error("useOrganization must be used within a OrganizationProvider");return a},Sl="redirect";function zl(a){return a.startsWith("/")&&!a.startsWith("//")}function Il(a,t){return a===t||a.startsWith(`${t}/`)}function ft(a,t){return!a||!zl(a)||!Il(a,t.home)||a===t.signIn||a===t.signUp?t.home:a}function qt(a,t){const r=new URLSearchParams({[Sl]:t});return`${a}?${r.toString()}`}function li(a,t,r){const s=ft(t,r);return new URL(s,a).toString()}const J=h.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")})}));J.displayName="Divider";const El=Se.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",la],variants:{hasError:{true:ht},enableStepper:{false:"[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none"},multiline:{true:"resize-y min-h-[100px]",false:"truncate appearance-none"}}}),oe=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[f,x]=h.useState(i),[j,y]=h.useState(!1),b=i==="password"&&!n,k=i==="search"&&!n,N=!!c,R=i==="textarea"?"textarea":"input",O=async()=>{if(c)try{y(!0),await navigator.clipboard.writeText(c),Q.success(m)}catch{Q.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(R,{ref:g,type:b?f:i,className:w(El({hasError:r,enableStepper:n?!1:s,multiline:n}),{"pl-16":o,"pl-8":!o&&k,"pr-24":N,"pr-10":!N&&(l||!l&&b)},t),...p}),!o&&k&&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(z.RiSearchLine,{className:"size-[1.125rem]"})}),N&&e.jsx("div",{className:"absolute inset-y-0 right-0 flex items-center pr-1.5",children:e.jsxs(I,{type:"button",variant:"ghost",onClick:O,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(v.CopyIcon,{className:"size-4","aria-hidden":"true"}),e.jsx("span",{className:"sr-only",children:"Copy value"})]})}),!N&&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}),!N&&!l&&b&&e.jsx("div",{className:"absolute inset-y-0 right-0 flex items-center pr-3",children:e.jsx("button",{onClick:()=>x(f==="password"?"text":"password"),className:w(ge,"text-gray-400 hover:text-gray-500 dark:text-gray-600"),children:f==="password"?e.jsx(z.RiEyeFill,{className:"size-5"}):e.jsx(z.RiEyeOffFill,{className:"size-5"})})})]})});oe.displayName="Input";const le=C.forwardRef(({className:a,disabled:t,...r},s)=>e.jsx(Br.Root,{ref:s,className:X("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 Dl=()=>{const a=S.useRouter(),t=S.useSearchParams(),r=ja(),s=q(),i=r.signIn,n=ft(t==null?void 0:t.get("redirect"),s),{register:o,handleSubmit:l,formState:{errors:c,isSubmitting:m}}=L.useForm({resolver:ce.zodResolver(hs),shouldFocusError:!0}),u=()=>a.push(n),p=async f=>{await i.email({email:f.email,password:f.password,fetchOptions:{onSuccess:u}})},g=async()=>{await i.social({provider:"google",callbackURL:li(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(D,{className:"text-blue-500 hover:text-blue-600 dark:text-blue-500 dark:hover:text-blue-400",href:qt(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(I,{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(z.RiGoogleFill,{className:"size-4","aria-hidden":"true"}),"Login with Google"]})}),e.jsx(J,{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(oe,{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(oe,{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(I,{type:"submit",isLoading:m,children:m?"Submitting...":"Continue"})]})]}),e.jsx(J,{}),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 di({children:a}){const{appearance:t}=Lr(),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(xe,{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 Fl(){return e.jsx(di,{children:e.jsx(Dl,{})})}const Rl=()=>{const a=S.useRouter(),t=S.useSearchParams(),r=ja(),s=q(),{signIn:i,signUp:n}=r,o=ft(t==null?void 0:t.get("redirect"),s),{register:l,handleSubmit:c,formState:{errors:m}}=L.useForm({resolver:ce.zodResolver(Ot),shouldFocusError:!0}),u=()=>a.push(o),{isPending:p,isError:g,mutate:f}=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}})}),x=async()=>i.social({provider:"google",callbackURL:li(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(D,{className:"text-blue-500 hover:text-blue-600 dark:text-blue-500 dark:hover:text-blue-400",href:qt(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(I,{asChild:!0,variant:"secondary",className:"mt-2 w-full sm:mt-0",children:e.jsxs("button",{className:"inline-flex items-center gap-2",onClick:x,children:[e.jsx(z.RiGoogleFill,{className:"size-4","aria-hidden":"true"}),"Signin with Google"]})})}),e.jsx(J,{className:"my-6",children:"or"}),e.jsxs("form",{onSubmit:c(j=>f(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(le,{htmlFor:"email-form-item",className:"font-medium",children:"First Name"}),e.jsx(oe,{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(oe,{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(oe,{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(oe,{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(I,{type:"submit",isLoading:p,children:p?"Submitting...":"Continue"})]})]}),e.jsx(J,{}),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 Pl(){return e.jsx(di,{children:e.jsx(Rl,{})})}const _e=h.forwardRef(({className:a,asChild:t,...r},s)=>{const i=t?Dt.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})});_e.displayName="Card";const ya=C.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",ge),onClick:a,...s,children:e.jsx(n,{className:"size-full shrink-0"})})});ya.displayName="NavigationButton";function Ar({displayMonth:a,displayIndex:t,enableYearNavigation:r,disableNavigation:s,numberOfMonths:i,startMonth:n,endMonth:o}){const l=fa.useNavigation(),c=a,m=t??0,u=m<=0,p=m===i-1,g=i>1&&(u||!p),f=i>1&&(p||!u),x=l.previousMonth,j=l.nextMonth,y=l.goToMonth,b=!n||T.addYears(c,-1).getTime()>=n.getTime(),k=!o||T.addYears(c,1).getTime()<=o.getTime(),N=()=>{!x||!b||y(T.addYears(c,-1))},R=()=>{!j||!k||y(T.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&&!f&&e.jsx(ya,{disabled:s||!x||!b,"aria-label":"Go to previous year",onClick:N,icon:z.RiArrowLeftDoubleLine}),!f&&e.jsx(ya,{disabled:s||!x,"aria-label":"Go to previous month",onClick:()=>x&&y(x),icon:z.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:T.format(c,"LLLL yyy")}),e.jsxs("div",{className:"flex items-center gap-1",children:[!g&&e.jsx(ya,{disabled:s||!j,"aria-label":"Go to next month",onClick:()=>j&&y(j),icon:z.RiArrowRightSLine}),r&&!g&&e.jsx(ya,{disabled:s||!j||!k,"aria-label":"Go to next year",onClick:R,icon:z.RiArrowRightDoubleLine})]})]})}const ci=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",ge),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:N,displayIndex:R})=>e.jsx(Ar,{displayMonth:N,displayIndex:R,enableYearNavigation:t,disableNavigation:i,numberOfMonths:s,startMonth:n,endMonth:o}),Chevron:()=>e.jsx("span",{}),Nav:()=>e.jsx("span",{}),MonthCaption:({calendarMonth:N,displayIndex:R})=>e.jsx(Ar,{displayMonth:N.date,displayIndex:R,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:N,className:R,classNames:O,components:F,weekStartsOn:U,numberOfMonths:te,...P}=a,H={...P,...m,mode:"range"};return e.jsx(fa.DayPicker,{...H})}if(a.mode==="multiple"){const{enableYearNavigation:N,className:R,classNames:O,components:F,weekStartsOn:U,numberOfMonths:te,...P}=a,H={...P,...m,mode:"multiple"};return e.jsx(fa.DayPicker,{...H})}if(a.mode==="default"){const{enableYearNavigation:N,className:R,classNames:O,components:F,weekStartsOn:U,numberOfMonths:te,...P}=a,H={...P,...m,mode:"default"};return e.jsx(fa.DayPicker,{...H})}const{enableYearNavigation:u,className:p,classNames:g,components:f,mode:x,weekStartsOn:j,numberOfMonths:y,...b}=a,k={...b,...m,mode:"single"};return e.jsx(fa.DayPicker,{...k})};ci.displayName="Calendar";const Ml=()=>{const a=typeof window<"u"?window.navigator.language:"en-US",t=new Intl.DateTimeFormat(a,{hour:"numeric"}).format();return Number.isInteger(Number(t))},Bl=({segment:a,state:t})=>{const r=C.useRef(null),{segmentProps:s}=Pr.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:X("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",la,"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:X("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]})},Et=C.forwardRef(({hourCycle:a,...t},r)=>{const s=C.useRef(null);C.useImperativeHandle(r,()=>s==null?void 0:s.current);const i=window!==void 0?window.navigator.language:"en-US",n=Yi.useTimeFieldState({hourCycle:a,locale:i,shouldForceLeadingZeros:!0,autoFocus:!0,...t}),{fieldProps:o}=Pr.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(Bl,{segment:l,state:n},c))})});Et.displayName="TimeInput";const Tl=Se.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",la],variants:{hasError:{true:ht}}}),mi=C.forwardRef(({className:a,children:t,placeholder:r,hasError:s,...i},n)=>e.jsx(G.Trigger,{asChild:!0,children:e.jsxs("button",{ref:n,className:X(Tl({hasError:s}),a),...i,children:[e.jsx(z.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)})]})}));mi.displayName="DatePicker.Trigger";const ui=C.forwardRef(({align:a,className:t,children:r,...s},i)=>e.jsx(G.Portal,{children:e.jsx(G.Content,{ref:i,sideOffset:10,side:"bottom",align:a,avoidCollisions:!0,onOpenAutoFocus:n=>n.preventDefault(),className:X("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})}));ui.displayName="DatePicker.CalendarPopover";const pi=({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 f=!1;p&&g&&o(p,g)&&(f=!0);const x=m.to,j=u.to;let y=!1;return x&&j&&o(x,j)&&(y=!0),f&&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:X("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",ge,"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))})};pi.displayName="DatePicker.PresetContainer";const Cr=(a,t,r)=>{const s=!Ml();let i;return r?i=s?T.format(a,"dd MMM, yyyy h:mm a",{locale:t}):T.format(a,"dd MMM, yyyy HH:mm",{locale:t}):i=T.format(a,"dd MMM, yyyy",{locale:t}),i},Ql=({defaultValue:a,value:t,onChange:r,presets:s,disabled:i,disableNavigation:n,disabledDays:o,enableYearNavigation:l=!1,locale:c=en.enUS,showTimePicker:m,placeholder:u="Select date range",hasError:p,translations:g,align:f="center",className:x,...j})=>{const[y,b]=C.useState(!1),[k,N]=C.useState(t??a??void 0),[R,O]=C.useState(k==null?void 0:k.from),[F,U]=C.useState(t!=null&&t.from?new se.Time(t.from.getHours(),t.from.getMinutes()):a!=null&&a.from?new se.Time(a.from.getHours(),a.from.getMinutes()):new se.Time(0,0)),[te,P]=C.useState(t!=null&&t.to?new se.Time(t.to.getHours(),t.to.getMinutes()):a!=null&&a.to?new se.Time(a.to.getHours(),a.to.getMinutes()):new se.Time(0,0)),H=C.useMemo(()=>k,[y]);C.useEffect(()=>{N(t??a??void 0)},[t,a]),C.useEffect(()=>{k&&O(k.from)},[k]),C.useEffect(()=>{y||O(k==null?void 0:k.from)},[y]);const je=re=>{const M=re;m&&(M!=null&&M.from&&!F&&U(new se.Time(0,0)),M!=null&&M.to&&!te&&P(new se.Time(0,0)),M!=null&&M.from&&F&&(M.from.setHours(F.hour),M.from.setMinutes(F.minute)),M!=null&&M.to&&te&&(M.to.setHours(te.hour),M.to.setMinutes(te.minute))),N(M)},ua=()=>{N(H),U(H!=null&&H.from?new se.Time(H.from.getHours(),H.from.getMinutes()):new se.Time(0,0)),P(H!=null&&H.to?new se.Time(H.to.getHours(),H.to.getMinutes()):new se.Time(0,0)),b(!1)},Ca=re=>{re||ua(),b(re)},pa=(re,M)=>{switch(M){case"start":U(re);break;case"end":P(re);break}if(k){if(M==="start"){if(!k.from)return;const Z=new Date(k.from.getTime());re?(Z.setHours(re.hour),Z.setMinutes(re.minute)):(Z.setHours(0),Z.setMinutes(0)),N({...k,from:Z})}if(M==="end"){if(!k.to)return;const Z=new Date(k.to.getTime());re?(Z.setHours(re.hour),Z.setMinutes(re.minute)):(Z.setHours(0),Z.setMinutes(0)),N({...k,to:Z})}}};C.useEffect(()=>{N(t??a??void 0),U(t!=null&&t.from?new se.Time(t.from.getHours(),t.from.getMinutes()):a!=null&&a.from?new se.Time(a.from.getHours(),a.from.getMinutes()):new se.Time(0,0)),P(t!=null&&t.to?new se.Time(t.to.getHours(),t.to.getMinutes()):a!=null&&a.to?new se.Time(a.to.getHours(),a.to.getMinutes()):new se.Time(0,0))},[t,a]);const ga=C.useMemo(()=>k?`${k.from?Cr(k.from,c,m):""} - ${k.to?Cr(k.to,c,m):""}`:null,[k,c,m]),Sa=()=>{b(!1),r==null||r(k)};return e.jsxs(G.Root,{"tremor-id":"tremor-raw",open:y,onOpenChange:Ca,children:[e.jsx(mi,{placeholder:u,disabled:i,className:x,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:ga}),e.jsx(ui,{align:f,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:X("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(pi,{currentValue:k,presets:s,onSelect:je})})}),e.jsxs("div",{className:"overflow-x-auto",children:[e.jsx(ci,{mode:"range",selected:k,onSelect:je,month:R,onMonthChange:O,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(Et,{value:F,onChange:re=>pa(re,"start"),"aria-label":"Start date time",isDisabled:!(k!=null&&k.from),isRequired:j.required})]}),e.jsx(z.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(Et,{value:te,onChange:re=>pa(re,"end"),"aria-label":"End date time",isDisabled:!(k!=null&&k.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:ga})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-x-2 sm:mt-0",children:[e.jsx(I,{variant:"secondary",className:"h-8 w-full sm:w-fit",type:"button",onClick:ua,children:(g==null?void 0:g.cancel)??"Cancel"}),e.jsx(I,{variant:"primary",className:"h-8 w-full sm:w-fit",type:"button",onClick:Sa,children:(g==null?void 0:g.apply)??"Apply"})]})]})]})]})})})]})},Ol=(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,f,x,j,y;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 ${T.format(l,"MMM dd, yyyy")}.`)}if("dateRange"in u){const b=(p=u.dateRange.from)==null?void 0:p.getFullYear(),k=(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(k&&r&&k>r)throw new Error(`Preset ${u.label}'s 'to' is after toYear ${m}.`);if(i){const N=(f=u.dateRange.from)==null?void 0:f.getMonth();if(N&&N<i.getMonth())throw new Error(`Preset ${u.label}'s 'from' is before fromMonth ${T.format(i,"MMM, yyyy")}.`)}if(n){const N=(x=u.dateRange.to)==null?void 0:x.getMonth();if(N&&N>n.getMonth())throw new Error(`Preset ${u.label}'s 'to' is after toMonth ${T.format(n,"MMM, yyyy")}.`)}if(o){const N=(j=u.dateRange.from)==null?void 0:j.getDate();if(N&&N<o.getDate())throw new Error(`Preset ${u.dateRange.from}'s 'from' is before fromDay ${T.format(o,"MMM dd, yyyy")}.`)}if(l){const N=(y=u.dateRange.to)==null?void 0:y.getDate();if(N&&N>l.getDate())throw new Error(`Preset ${u.label}'s 'to' is after toDay ${T.format(l,"MMM dd, yyyy")}.`)}}})}},gi=({presets:a,...t})=>(a&&Ol(a,t),e.jsx(Ql,{presets:a,...t}));gi.displayName="DateRangePicker";const Ll=new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:1}),Jl={bank_transfer:"Bank transfer",blik:"BLIK",card:"Card",cash_on_delivery:"Cash on delivery",paypal:"PayPal"},Vl={delivery:"Delivery",pickup:"Pickup"},za=["#0f766e","#fb923c"],Ia=a=>typeof a=="number"?a:typeof a=="string"?Number(a):Array.isArray(a)&&a.length>0?Number(a[0]):0;function Hl(){const{client:a}=E(),t=V(),r=h.useMemo(()=>new Date,[]),[s,i]=h.useState({from:T.subDays(r,29),to:r}),n=h.useMemo(()=>{const y=(s==null?void 0:s.from)??T.subDays(r,29),b=(s==null?void 0:s.to)??(s==null?void 0:s.from)??r;return{from:T.startOfDay(y),to:T.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:y,status:b}=await a.analytics.getOverview({params:{organizationId:t},query:{from:n.from.toISOString(),to:n.to.toISOString()}});if(b!==200||!y)throw new Error("Failed to fetch dashboard overview");return y},placeholderData:A.keepPreviousData}),g=(o==null?void 0:o.summary.currency)??"USD",f=((o==null?void 0:o.paymentMethods)??[]).map(y=>({...y,label:Jl[y.method]??y.method})),x=((o==null?void 0:o.fulfilmentMethods)??[]).map(y=>({...y,label:Vl[y.method]??y.method})),j=x.reduce((y,b)=>y+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(gi,{value:s,onChange:i,className:"w-full sm:w-fit",toDate:r,align:"end"})]})]}),c&&!o?e.jsx(_e,{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(I,{onClick:()=>p(),className:"gap-2",children:[e.jsx(z.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,b)=>e.jsx(xa,{className:"h-[148px]"},b)):o?e.jsxs(e.Fragment,{children:[e.jsx(Ea,{icon:z.RiMoneyDollarCircleLine,title:"Paid sales",value:ne.currency(o.summary.totalSales,g),description:"Successful payments in the selected range"}),e.jsx(Ea,{icon:z.RiShoppingBag3Line,title:"Paid orders",value:ne.unit(o.summary.paidOrders),description:`Average order value ${ne.currency(o.summary.averageOrderValue,g)}`}),e.jsx(Ea,{icon:z.RiCalendarCheckLine,title:"Reservations",value:ne.unit(o.summary.reservations),description:"Scheduled reservations in the selected range"}),e.jsx(Ea,{icon:z.RiGroupLine,title:"Reserved guests",value:ne.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(xa,{className:"h-[360px]"}),e.jsx(xa,{className:"h-[360px]"})]}):o?e.jsxs(e.Fragment,{children:[e.jsx(Da,{title:"Paid sales by day",value:ne.currency(o.summary.totalSales,g),description:"Gross paid revenue recognised on each order day.",children:e.jsx(_.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(_.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(_.CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb",vertical:!1}),e.jsx(_.XAxis,{dataKey:"label",axisLine:!1,tickLine:!1,tick:{fill:"#6b7280",fontSize:12}}),e.jsx(_.YAxis,{axisLine:!1,tickLine:!1,width:48,tickFormatter:y=>Ll.format(y),tick:{fill:"#6b7280",fontSize:12}}),e.jsx(_.Tooltip,{formatter:(y,b)=>{const k=Ia(y);return[String(b)==="totalSales"?ne.currency(k,g):ne.unit(k),String(b)==="totalSales"?"Sales":"Paid orders"]},contentStyle:Fa,labelStyle:Ra}),e.jsx(_.Area,{type:"monotone",dataKey:"totalSales",stroke:"#0f766e",strokeWidth:2.5,fill:"url(#salesGradient)",name:"totalSales"})]})})}),e.jsx(Da,{title:"Reservations per day",value:ne.unit(o.summary.reservations),description:"Bookings are grouped by reservation date, not submission time.",children:e.jsx(_.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(_.BarChart,{data:o.reservationsByDay,children:[e.jsx(_.CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb",vertical:!1}),e.jsx(_.XAxis,{dataKey:"label",axisLine:!1,tickLine:!1,tick:{fill:"#6b7280",fontSize:12}}),e.jsx(_.YAxis,{allowDecimals:!1,axisLine:!1,tickLine:!1,width:36,tick:{fill:"#6b7280",fontSize:12}}),e.jsx(_.Tooltip,{formatter:(y,b)=>[ne.unit(Ia(y)),String(b)==="guests"?"Guests":"Reservations"],contentStyle:Fa,labelStyle:Ra}),e.jsx(_.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(xa,{className:"h-[320px]"}),e.jsx(xa,{className:"h-[320px]"})]}):o?e.jsxs(e.Fragment,{children:[e.jsx(Da,{title:"Payment methods",value:ne.unit(f.reduce((y,b)=>y+b.count,0)),description:"Successful orders grouped by how guests paid.",children:f.length>0?e.jsx(_.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(_.BarChart,{data:f,layout:"vertical",margin:{left:12,right:12},children:[e.jsx(_.CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb",horizontal:!1}),e.jsx(_.XAxis,{type:"number",allowDecimals:!1,axisLine:!1,tickLine:!1,tick:{fill:"#6b7280",fontSize:12}}),e.jsx(_.YAxis,{dataKey:"label",type:"category",axisLine:!1,tickLine:!1,width:110,tick:{fill:"#374151",fontSize:12}}),e.jsx(_.Tooltip,{formatter:(y,b,k)=>{const N=Ia(y),R=k&&typeof k=="object"&&"payload"in k?k.payload:{totalSales:0};return String(b)==="count"?[ne.unit(N),"Orders"]:[ne.currency(R.totalSales,g),"Sales"]},contentStyle:Fa,labelStyle:Ra}),e.jsx(_.Bar,{dataKey:"count",name:"count",fill:"#2563eb",radius:[0,8,8,0]})]})}):e.jsx(Sr,{message:"No paid orders in the selected range."})}),e.jsx(Da,{title:"Fulfilment mix",value:ne.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(_.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(_.PieChart,{children:[e.jsx(_.Pie,{data:x,dataKey:"count",nameKey:"label",innerRadius:68,outerRadius:100,paddingAngle:4,children:x.map((y,b)=>e.jsx(_.Cell,{fill:za[b%za.length]},y.method))}),e.jsx(_.Tooltip,{formatter:(y,b,k)=>{const N=Ia(y),R=k&&typeof k=="object"&&"payload"in k?k.payload:{label:"Orders"};return[`${ne.unit(N)} orders`,R.label]},contentStyle:Fa,labelStyle:Ra})]})}),e.jsx("div",{className:"flex flex-col justify-center gap-3",children:x.map((y,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:za[b%za.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/j*100),"%"]})]}),e.jsx("div",{className:"mt-2 text-lg font-semibold text-gray-900 dark:text-gray-50",children:ne.unit(y.count)}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:ne.currency(y.totalSales,g)})]},y.method))})]}):e.jsx(Sr,{message:"No orders in the selected range."})})]}):null})]})}function Ea({description:a,icon:t,title:r,value:s}){return e.jsx(_e,{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 Da({children:a,description:t,title:r,value:s}){return e.jsxs(_e,{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 xa({className:a}){return e.jsx(_e,{className:X("animate-pulse",a),children:e.jsx("div",{className:"h-full rounded-xl bg-gray-100 dark:bg-gray-900"})})}function Sr({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 Fa={border:"1px solid #e5e7eb",borderRadius:"12px",boxShadow:"0 10px 30px rgba(15, 23, 42, 0.08)",backgroundColor:"#ffffff"},Ra={color:"#111827",fontWeight:600},hi=(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},zr=[{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:"🇪🇹"}]}],yt=a=>e.jsx(W.Root,{...a});yt.displayName="Dialog";const xi=W.Trigger;xi.displayName="DialogTrigger";const fi=W.Close;fi.displayName="DialogClose";const yi=W.Portal;yi.displayName="DialogPortal";const bi=h.forwardRef(({className:a,...t},r)=>e.jsx(W.Overlay,{ref:r,className:w("fixed inset-0 z-50 overflow-y-auto","bg-black/70","data-[state=open]:animate-dialogOverlayShow",a),...t}));bi.displayName="DialogOverlay";const bt=h.forwardRef(({className:a,...t},r)=>e.jsx(yi,{children:e.jsx(bi,{children:e.jsx(W.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",ge,a),...t})})}));bt.displayName="DialogContent";const jt=({className:a,...t})=>e.jsx("div",{className:w("flex flex-col gap-y-1",a),...t});jt.displayName="DialogHeader";const wt=h.forwardRef(({className:a,...t},r)=>e.jsx(W.Title,{ref:r,className:w("text-lg font-semibold","text-gray-900 dark:text-gray-50",a),...t}));wt.displayName="DialogTitle";const kt=h.forwardRef(({className:a,...t},r)=>e.jsx(W.Description,{ref:r,className:w("text-gray-500 dark:text-gray-500",a),...t}));kt.displayName="DialogDescription";const $t=C.forwardRef(({className:a,...t},r)=>e.jsx($.Command,{ref:r,className:w("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",a),...t}));$t.displayName=$.Command.displayName;const _t=C.forwardRef(({className:a,...t},r)=>e.jsxs("div",{className:"flex items-center border-b pl-3","cmdk-input-wrapper":"",children:[e.jsx(v.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx($.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})]}));_t.displayName=$.Command.Input.displayName;const Wt=C.forwardRef(({className:a,...t},r)=>e.jsx($.Command.List,{ref:r,className:w("max-h-[300px] overflow-y-auto overflow-x-hidden",a),...t}));Wt.displayName=$.Command.List.displayName;const Gt=C.forwardRef((a,t)=>e.jsx($.Command.Empty,{ref:t,className:"py-6 text-center text-sm",...a}));Gt.displayName=$.Command.Empty.displayName;const Kt=C.forwardRef(({className:a,...t},r)=>e.jsx($.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}));Kt.displayName=$.Command.Group.displayName;const Ul=C.forwardRef(({className:a,...t},r)=>e.jsx($.Command.Separator,{ref:r,className:w("-mx-1 h-px bg-border",a),...t}));Ul.displayName=$.Command.Separator.displayName;const Xt=C.forwardRef(({className:a,...t},r)=>e.jsx($.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}));Xt.displayName=$.Command.Item.displayName;const Yt=a=>e.jsx(G.Root,{...a});Yt.displayName="Popover";const er=C.forwardRef((a,t)=>e.jsx(G.Trigger,{ref:t,...a}));er.displayName="PopoverTrigger";const Zl=C.forwardRef((a,t)=>e.jsx(G.Anchor,{ref:t,...a}));Zl.displayName="PopoverAnchor";const ql=C.forwardRef((a,t)=>e.jsx(G.Close,{ref:t,...a}));ql.displayName="PopoverClose";const ar=C.forwardRef(({className:a,sideOffset:t=10,side:r="bottom",align:s="center",collisionPadding:i,...n},o)=>e.jsx(G.Portal,{children:e.jsx(G.Content,{ref:o,sideOffset:t,side:r,align:s,collisionPadding:i,avoidCollisions:!0,className:X("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})}));ar.displayName="PopoverContent";const $l=({value:a,onChange:t})=>{const r=h.useId(),[s,i]=h.useState(!1),n=zr.map(o=>o.items.find(l=>l.value===a)).filter(Boolean)[0];return e.jsx("div",{className:"mt-2",children:e.jsxs(Yt,{open:s,onOpenChange:i,children:[e.jsx(er,{asChild:!0,children:e.jsxs(I,{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(v.ChevronDown,{size:16,strokeWidth:2,className:"shrink-0 text-muted-foreground/80","aria-hidden":"true"})]})}),e.jsx(ar,{className:"w-full min-w-[var(--radix-popper-anchor-width)] border-input -mt-1 z-50",align:"start",children:e.jsxs($t,{className:"p-0",children:[e.jsx(_t,{className:"w-full border-none",style:{boxShadow:"none"},placeholder:"Search country..."}),e.jsxs(Wt,{children:[e.jsx(Gt,{children:"No country found."}),zr.map(o=>e.jsx(h.Fragment,{children:e.jsx(Kt,{heading:o.continent,children:o.items.map(l=>e.jsxs(Xt,{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(v.Check,{size:16,strokeWidth:2,className:"ml-auto"})]},l.value))})},o.continent))]})]})})]})})},_l=({...a})=>{const t=h.useId();return e.jsx("div",{className:"mt-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(oe,{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(v.AtSign,{size:16,strokeWidth:2,"aria-hidden":"true"})})]})})},Wl=a=>{const{client:t}=E(),[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 f=await Dr.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(x){n(x.percentage)}});return{id:p.id,filename:u.name,mimeType:u.type,size:u.size,url:f.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 f=a.value??[];a.onChange([...f,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(v.XIcon,{className:"w-4 h-4 text-white"})}),e.jsx(xe,{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(v.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(v.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()})},ji=h.forwardRef(({...a},t)=>e.jsx(oe,{...a,inputClassName:"border-l-0 rounded-l-none",ref:t,className:""}));ji.displayName="PhoneInput";const Gl=({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(wi,{country:t,countryName:t,"aria-hidden":"true"}),e.jsx("span",{className:"text-muted-foreground/80",children:e.jsx(v.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&&`+${Xa.getCountryCallingCode(n.value)}`]},n.value??`empty-${o}`))]})]})},wi=({country:a,countryName:t})=>{const r=Mr[a];return e.jsx("span",{className:"w-5 overflow-hidden rounded-sm",children:r?e.jsx(r,{title:t}):e.jsx(v.Phone,{size:16,"aria-hidden":"true"})})},Kl=({value:a,onChange:t,onBlur:r})=>{const s=h.useId();return e.jsx("div",{className:"mt-2",children:e.jsx(Xa.default,{id:s,className:"flex rounded-lg shadow-xs shadow-black/5",international:!0,flagComponent:wi,countrySelectComponent:Gl,inputComponent:ji,placeholder:"Enter phone number",value:a,onChange:i=>t(i??""),onBlur:r})})},Xl=({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(f=>f!==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(f=>f!==p);r(g)}};return e.jsx("div",{className:"mt-2",children:e.jsxs(Yt,{open:o,onOpenChange:l,children:[e.jsx(er,{asChild:!0,children:e.jsxs(I,{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(f=>f.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(v.X,{size:12,onClick:f=>{f.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(v.ChevronDown,{size:16,strokeWidth:2,className:"shrink-0 text-muted-foreground/80","aria-hidden":"true"})]})}),e.jsx(ar,{className:"w-full min-w-[var(--radix-popper-anchor-width)] border-input -mt-1 z-50 p-0",align:"start",children:e.jsxs($t,{className:"p-0",children:[e.jsx(_t,{className:"w-full border-none pl-0",style:{boxShadow:"none"},placeholder:"Search..."}),e.jsxs(Wt,{children:[e.jsx(Gt,{children:"No options found."}),e.jsx(Kt,{children:a.map(p=>e.jsxs(Xt,{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(v.Check,{size:16,strokeWidth:2,className:"ml-auto"})]},p.value))})]})]})})]})})},Yl=Se.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",ge],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"}}),ki=h.forwardRef(({className:a,size:t,...r},s)=>{const{root:i,thumb:n}=Yl({size:t});return e.jsx(Qa.Root,{ref:s,className:w(i(),a),...r,children:e.jsx(Qa.Thumb,{className:w(n())})})});ki.displayName="Switch";const ed=({name:a,type:t,placeholder:r,multiple:s,options:i,prefix:n})=>{const{watch:o,register:l,setFocus:c,setValue:m}=L.useFormContext();switch(t){case"email":return e.jsx(_l,{...l(a),placeholder:r});case"file":return e.jsx(Wl,{value:o(a),multiple:s,onChange:u=>m(a,u)});case"phone-number":return e.jsx(Kl,{value:o("phone"),onChange:u=>m("phone",u),onBlur:()=>c("phone")});case"country":return e.jsx($l,{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(Xl,{options:i,value:u,onChange:p=>m(a,p),placeholder:r,multiple:s})}case"switch":return e.jsx(ki,{size:"default",className:"mr-2",checked:o(a),onCheckedChange:u=>m(a,u)});case"time":return e.jsx(Vt,{value:o(a),onChange:u=>m(a,u.target.value),className:"mt-2"});default:return e.jsx(oe,{...l(a),type:t,rows:t==="textarea"?4:void 0,placeholder:r,className:"mt-2",prefix:n})}},ad=(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,ke=({type:a="text",name:t,label:r,className:s,locale:i,placeholder:n,multiple:o,options:l,localizable:c,prefix:m})=>{const{errors:u}=L.useFormState(),p=ad(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(v.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:[rt.get(i)," (",i,")"]})]}),e.jsx(ed,{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})]})},td=({form:a,config:t,columns:r=2})=>{var c;const{errors:s}=L.useFormState(),i=hi(s,t.name),{fields:n,append:o,remove:l}=L.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:f,type:x,colspan:j,localizable:y,multiple:b,options:k,placeholder:N,prefix:R})=>e.jsx(ke,{name:`${t.name}[${u}].${g}`,label:f,type:x??"text",localizable:y,className:w({"col-span-1":j===1,"col-span-2":j===2,"col-span-3":j===3,"col-span-4":j===4}),placeholder:N,multiple:b,options:k,prefix:R},t.name+g))},m.id),u<n.length-1&&e.jsx(J,{})]})}),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(v.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(v.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},rd=({config:a,columns:t=2})=>{var i;const{errors:r}=L.useFormState(),s=hi(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:f})=>e.jsx(ke,{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:f},`${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 sd(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 tr=h.forwardRef(({className:a,children:t,...r},s)=>e.jsx(Oa.Root,{ref:s,...r,asChild:!1,children:e.jsx(Oa.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})}));tr.displayName="TabNavigation";const rr=h.forwardRef(({asChild:a,disabled:t,className:r,children:s,...i},n)=>e.jsx(Oa.Item,{className:"flex","aria-disabled":t,children:e.jsx(Oa.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:sd({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":"",ge,r),children:o}))})}));rr.displayName="TabNavigationLink";const Ne=({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}=he(),[g,f]=h.useState(),x=h.useMemo(()=>r.some(y=>y.localizable),[r]);h.useEffect(()=>{m.data&&f(u)},[m.data,u,a,p,c]),h.useEffect(()=>{a.formState.errors.translations&&f(u)},[u,a.formState.errors.translations]);const j=e.jsxs("div",{className:X("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:[x&&e.jsx("div",{className:"col-span-full",children:e.jsx(tr,{className:"col-span-full mb-3",children:p.map(y=>{const b=y===u;return e.jsx(rr,{active:y===g,onClick:()=>f(y),className:"cursor-pointer",children:e.jsxs(e.Fragment,{children:[rt.get(y)," ",b&&"(Default)"]})},y)})})}),r.map(y=>{const{name:b,label:k,type:N,colspan:R,localizable:O,multiple:F,options:U,placeholder:te,prefix:P}=y,H=!O||!g?b:`translations[${p==null?void 0:p.indexOf(g)}].${b}`;return N==="object"?e.jsx(rd,{config:y},b):N==="array"?e.jsx(td,{form:a,config:y},b):e.jsx(ke,{name:H,label:k,type:N??"text",localizable:O,className:X({"col-span-1":R===1,"col-span-2":R===2,"col-span-3":R===3,"col-span-4":R===4}),placeholder:te,multiple:F,options:U,locale:g,prefix:P},H)}),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(I,{type:"button",className:"w-full sm:w-fit",variant:"secondary",onClick:i,children:n??"Cancel"}),e.jsx(I,{type:"submit",className:"w-full sm:w-fit",isLoading:s,loadingText:"Saving...",children:t??"Save Data"})]})]});return l?e.jsx(L.FormProvider,{...a,children:e.jsx("form",{onSubmit:a.handleSubmit(y=>l(y)),children:j})}):e.jsx("div",{className:"w-full",children:j})},id=[{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"}],vi=({initialData:a})=>{const{client:t}=E(),r=S.useRouter(),s=q(),i=V(),{defaultLocale:n,supportedLocales:o}=he(),l=a?uo:mo,c=L.useForm({resolver:ce.zodResolver(l),defaultValues:a?{defaultLocale:n,name:a.name,logo:a.logo,translations:a.translations}:{defaultLocale:n,translations:o.map(f=>({locale:f}))}}),m=A.useMutation({mutationFn:async f=>{var y;const x={name:f.name,defaultLocale:f.defaultLocale,translations:f.translations,logoId:(y=f.logo)==null?void 0:y.id},{status:j}=await t.manufacturer.createManufacturer({params:{organizationId:i},body:x});if(j!==201)throw Q.error("Failed to create manufacturer. Please try again later."),new Error("Failed to create manufacturer")}}),u=A.useMutation({mutationFn:async f=>{var y;const x={name:f.name,defaultLocale:f.defaultLocale,translations:f.translations,logoId:((y=f.logo)==null?void 0:y.id)||null},{status:j}=await t.manufacturer.updateManufacturer({params:{organizationId:i,id:a.id},body:x});if(j!==200)throw Q.error("Failed to update manufacturer. Please try again later."),new Error("Failed to update manufacturer")}}),p=async()=>{Q.success("Manufacturer saved successfully"),r.push(s.manufacturers(i)),await ae.invalidateQueries({queryKey:["manufacturers"]})},g=f=>{a?u.mutate(f,{onSuccess:p}):m.mutate(f,{onSuccess:p})};return e.jsx(Ne,{form:c,config:id,onSubmit:g,loading:m.isPending||u.isPending,cancelText:"Go back",okText:a?"Update Manufacturer":"Create Manufacturer"})};function nd(){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(J,{}),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(vi,{})})]})})})})]})}function od(){const a=V(),t=da(),{client:r}=E(),{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 Q.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(J,{}),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(ie,{className:"w-12 h-12"}),e.jsx("p",{className:"text-gray-500 text-sm mt-3",children:"Loading data..."})]})}):e.jsx(vi,{initialData:i})})]})})})})]})}const ld=h.forwardRef(({className:a,children:t,...r},s)=>e.jsx("div",{ref:s,children:e.jsx("div",{className:X("w-full overflow-auto whitespace-nowrap",a),...r,children:t})}));ld.displayName="TableRoot";const sr=h.forwardRef(({className:a,...t},r)=>e.jsx("table",{ref:r,className:X("w-full caption-bottom border-b","border-gray-200 dark:border-gray-800",a),...t}));sr.displayName="Table";const ir=h.forwardRef(({className:a,...t},r)=>e.jsx("thead",{ref:r,className:X(a),...t}));ir.displayName="TableHead";const Ue=h.forwardRef(({className:a,...t},r)=>e.jsx("th",{ref:r,className:X("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}));Ue.displayName="TableHeaderCell";const nr=h.forwardRef(({className:a,...t},r)=>e.jsx("tbody",{ref:r,className:X("divide-y","divide-gray-200 dark:divide-gray-800",a),...t}));nr.displayName="TableBody";const Ze=h.forwardRef(({className:a,...t},r)=>e.jsx("tr",{ref:r,className:X("[&_td:last-child]:pr-4 [&_th:last-child]:pr-4","[&_td:first-child]:pl-4 [&_th:first-child]:pl-4",a),...t}));Ze.displayName="TableRow";const De=h.forwardRef(({className:a,...t},r)=>e.jsx("td",{ref:r,className:X("p-4 text-sm","text-gray-600 dark:text-gray-400",a),...t}));De.displayName="TableCell";const dd=h.forwardRef(({className:a,...t},r)=>e.jsx("tfoot",{ref:r,className:X("border-t text-left font-medium","text-gray-900 dark:text-gray-50","border-gray-200 dark:border-gray-800",a),...t}));dd.displayName="TableFoot";const cd=h.forwardRef(({className:a,...t},r)=>e.jsx("caption",{ref:r,className:X("mt-3 px-3 text-center text-sm","text-gray-500 dark:text-gray-500",a),...t}));cd.displayName="TableCaption";const md=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"),Ni=({open:a=!1,onOpenChange:t,defaultOpen:r=!1,disableAutoFocus:s=!0,children:i})=>e.jsxs(G.Root,{open:a,onOpenChange:t,defaultOpen:r,children:[e.jsx(G.Anchor,{className:w("fixed inset-x-0 bottom-8 mx-auto flex w-fit items-center")}),e.jsx(G.Portal,{children:e.jsx(G.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})})]});Ni.displayName="CommandBar";const Ai=C.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}));Ai.displayName="CommandBar.Value";const Ci=C.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}));Ci.displayName="CommandBarBar";const Pa=C.forwardRef(({className:a,...t},r)=>e.jsx("div",{ref:r,className:w("h-4 w-px bg-gray-700",a),...t}));Pa.displayName="CommandBar.Seperator";const Ma=C.forwardRef(({className:a,type:t="button",label:r,action:s,shortcut:i,disabled:n,...o},l)=>(C.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",ge),...o,children:[e.jsx("span",{children:r}),e.jsx("span",{className:md,children:i.label?i.label.toUpperCase():i.shortcut.toUpperCase()})]})})));Ma.displayName="CommandBar.Command";function ud({table:a,rowSelection:t}){const r=Object.keys(t).length>0;return e.jsx(Ni,{open:r,children:e.jsxs(Ci,{children:[e.jsxs(Ai,{children:[Object.keys(t).length," selected"]}),e.jsx(Pa,{}),e.jsx(Ma,{label:"Edit",action:()=>{console.log("Edit")},shortcut:{shortcut:"e"}}),e.jsx(Pa,{}),e.jsx(Ma,{label:"Delete",action:()=>{console.log("Delete")},shortcut:{shortcut:"d"}}),e.jsx(Pa,{}),e.jsx(Ma,{label:"Reset",action:()=>{a.resetRowSelection()},shortcut:{shortcut:"Escape",label:"esc"}})]})})}function pd({meta:a,table:t}){const r=S.useSearchParams(),s=S.useRouter(),i=S.usePathname(),n=Number((r==null?void 0:r.get("page"))||"1"),o=(g,f)=>{const x=new URLSearchParams(r==null?void 0:r.toString());return x.set(g,f),x.toString()},l=g=>{s.push(`${i}?${o("page",g.toString())}`)},c=[{icon:z.RiArrowLeftDoubleLine,onClick:()=>l(1),disabled:!(a!=null&&a.previousPage),srText:"First page",mobileView:"hidden sm:block"},{icon:z.RiArrowLeftSLine,onClick:()=>l(n-1),disabled:!(a!=null&&a.previousPage),srText:"Previous page",mobileView:""},{icon:z.RiArrowRightSLine,onClick:()=>l(n+1),disabled:!(a!=null&&a.nextPage),srText:"Next page",mobileView:""},{icon:z.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,f)=>e.jsxs(I,{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"})]},f))})]})]})}function ca({meta:a,columns:t,error:r,data:s,loading:i,className:n,refetch:o}){var g,f;const l=V(),c=q(),[m,u]=C.useState({}),p=fe.useReactTable({data:s,columns:t,state:{rowSelection:m},enableRowSelection:!0,getFilteredRowModel:fe.getFilteredRowModel(),onRowSelectionChange:u,getCoreRowModel:fe.getCoreRowModel(),getSortedRowModel:fe.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(ie,{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(sr,{children:[e.jsx(ir,{children:p.getHeaderGroups().map(x=>e.jsx(Ze,{className:"border-y border-gray-200 dark:border-gray-800 back",children:x.headers.map(j=>{var y;return e.jsx(Ue,{className:w("whitespace-nowrap py-1 text-sm sm:text-xs",(y=j.column.columnDef.meta)==null?void 0:y.className),children:fe.flexRender(j.column.columnDef.header,j.getContext())},j.id)})},x.id))}),e.jsxs(nr,{children:[r&&e.jsx(Ze,{children:e.jsx(De,{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(x=>e.jsx(Ze,{className:"group select-none hover:bg-gray-50 dark:hover:bg-gray-900",children:x.getVisibleCells().map((j,y)=>{var b;return e.jsxs(De,{className:w(x.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:[y===0&&x.getIsSelected()&&e.jsx("div",{className:"absolute inset-y-0 left-0 w-0.5 bg-blue-600 dark:bg-blue-500"}),fe.flexRender(j.column.columnDef.cell,j.getContext())]},j.id)})},x.id)),((f=p.getRowModel().rows)==null?void 0:f.length)===0&&!i&&e.jsx(Ze,{children:e.jsx(De,{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(ie,{className:"w-10 h-10"}),e.jsx("p",{className:"text-gray-500 text-xs mt-1",children:"Loading..."})]})})]}),e.jsx(ud,{table:p,rowSelection:m})]}),a&&e.jsx(pd,{meta:a,table:p})]})})}const gd=Se.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",la,"[&::--webkit-search-cancel-button]:hidden [&::-webkit-search-cancel-button]:hidden [&::-webkit-search-decoration]:hidden"],variants:{hasError:{true:ht},enableStepper:{true:"[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none"}}}),ma=C.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(gd({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(z.RiSearchLine,{className:"size-[1.125rem] shrink-0","aria-hidden":"true"})})]}));ma.displayName="Searchbar";const Ce=h.forwardRef(({className:a,checked:t,...r},s)=>e.jsx(lr.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",ge,a),children:e.jsx(lr.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"})})})}));Ce.displayName="Checkbox";function B({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(z.RiArrowUpSLine,{className:w("size-3.5 text-gray-900 dark:text-gray-50",a.getIsSorted()==="desc"?"opacity-30":""),"aria-hidden":"true"}),e.jsx(z.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 Oe=de.Root;Oe.displayName="DropdownMenu";const Le=de.Trigger;Le.displayName="DropdownMenuTrigger";const ba=de.Group;ba.displayName="DropdownMenuGroup";const Si=de.Sub;Si.displayName="DropdownMenuSubMenu";const zi=de.RadioGroup;zi.displayName="DropdownMenuRadioGroup";const Ii=C.forwardRef(({className:a,children:t,...r},s)=>e.jsxs(de.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(z.RiArrowRightSLine,{className:"ml-auto size-4 shrink-0 text-gray-500","aria-hidden":"true"})]}));Ii.displayName="DropdownMenuSubMenuTrigger";const Ei=C.forwardRef(({className:a,collisionPadding:t=8,...r},s)=>e.jsx(de.Portal,{children:e.jsx(de.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})}));Ei.displayName="DropdownMenuSubMenuContent";const Je=C.forwardRef(({className:a,sideOffset:t=8,collisionPadding:r=8,align:s="center",loop:i=!0,...n},o)=>e.jsx(de.Portal,{children:e.jsx(de.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})}));Je.displayName="DropdownMenuContent";const be=C.forwardRef(({className:a,shortcut:t,hint:r,children:s,...i},n)=>e.jsxs(de.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})]}));be.displayName="DropdownMenuItem";const hd=C.forwardRef(({className:a,hint:t,shortcut:r,children:s,checked:i,...n},o)=>e.jsxs(de.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(de.ItemIndicator,{children:e.jsx(z.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})]}));hd.displayName="DropdownMenuCheckboxItem";const Ba=C.forwardRef(({className:a,hint:t,shortcut:r,children:s,iconType:i="radio",...n},o)=>e.jsxs(de.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(z.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(z.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(z.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})]}));Ba.displayName="DropdownMenuRadioItem";const vt=C.forwardRef(({className:a,...t},r)=>e.jsx(de.Label,{ref:r,className:w("px-2 py-2 text-xs font-medium tracking-wide","text-gray-500 dark:text-gray-500",a),...t}));vt.displayName="DropdownMenuLabel";const xd=C.forwardRef(({className:a,...t},r)=>e.jsx(de.Separator,{ref:r,className:w("-mx-1 my-1 h-px border-t border-gray-200 dark:border-gray-800",a),...t}));xd.displayName="DropdownMenuSeparator";const Ge=fe.createColumnHelper(),fd=[Ge.display({id:"select",header:({table:a})=>e.jsx(Ce,{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(Ce,{checked:a.getIsSelected(),onCheckedChange:()=>a.toggleSelected(),className:"translate-y-0.5","aria-label":"Select row"}),enableSorting:!1,enableHiding:!1,meta:{displayName:"Select"}}),Ge.accessor("id",{header:({column:a})=>e.jsx(B,{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(D,{href:((n=(i=t.options.meta)==null?void 0:i.routes)==null?void 0:n.manufacturerEdit(r,a.getValue("id")))??`/admin/${r}/manufacturers/${a.getValue("id")}`,className:"text-blue-500",children:a.getValue("id")})}}),Ge.accessor("name",{header:({column:a})=>e.jsx(B,{column:a,title:"Name"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"Owner"}}),Ge.accessor("translations",{header:({column:a})=>e.jsx(B,{column:a,title:"About"}),enableSorting:!1,meta:{className:"text-left",displayName:"Status"},cell:({row:a})=>{var t;return((t=a.getValue("translations").find(r=>r.about))==null?void 0:t.about)||"-"}}),Ge.accessor("createdAt",{header:({column:a})=>e.jsx(B,{column:a,title:"Created At"}),enableSorting:!1,meta:{className:"text-left",displayName:"Status"},cell:({row:a})=>{const t=a.getValue("createdAt");return new Date(t).toLocaleDateString()}}),Ge.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(Oe,{children:[e.jsx(Le,{asChild:!0,children:e.jsx(I,{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(z.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(Je,{align:"end",className:"min-w-40",children:[e.jsx(be,{children:e.jsx(D,{href:((n=(i=t.options.meta)==null?void 0:i.routes)==null?void 0:n.manufacturerEdit(r,a.getValue("id")))??`/admin/${r}/manufacturers/${a.getValue("id")}`,className:"block",children:"Edit"})}),e.jsx(be,{className:"text-red-600 dark:text-red-500",children:"Delete"})]})]})}})],yd=()=>{const{client:a}=E(),t=q(),r=V(),s=S.useSearchParams(),[i,n]=h.useState(""),[o]=Te.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:f}=await a.manufacturer.getManufacturers({params:{organizationId:r},query:{page:l,limit:10,search:o}});if(f!==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(I,{asChild:!0,className:"hidden gap-x-2 px-2 py-1.5 text-sm sm:text-xs lg:flex",children:e.jsxs(D,{href:t.manufacturerCreate(r),children:["Create Manufacturer",e.jsx(v.PlusIcon,{className:"size-4 shrink-0","aria-hidden":"true"})]})})})]}),e.jsx(ca,{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:fd,className:"mt-8"})]})};function bd(){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(yd,{})})]})}const jd=({organizationId:a,id:t,status:r,refetch:s})=>{var x;const{client:i}=E(),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=(x=n.variables)==null?void 0:x.operation,p=m&&u==="cancelled",g=m&&u!=="cancelled",f=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(v.X,{className:"w-4 h-4 text-red-600 dark:text-red-500"})]}),f&&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(v.CheckCircle,{className:"w-4 h-4 text-emerald-600 dark:text-emerald-500"})]})]})},wd=({open:a,onOpenChange:t,order:r})=>{var n,o,l,c,m,u,p;if(!r)return null;const s=g=>new Intl.NumberFormat("en-US",{style:"currency",currency:r.currency||"PLN"}).format(g),i=g=>{switch(g){case"pending":return"yellow";case"accepted":return"blue";case"ready-for-dispatch":return"purple";case"dispatched":return"orange";case"completed":return"green";case"cancelled":return"red";default:return"gray"}};return e.jsx(yt,{open:a,onOpenChange:t,children:e.jsxs(bt,{className:"sm:max-w-3xl overflow-y-auto max-h-[85vh]",children:[e.jsxs(jt,{children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs(wt,{children:["Order Details #",r.referenceId]}),e.jsx(fi,{className:"rounded-full hover:bg-gray-200 p-1 dark:hover:bg-gray-800",children:e.jsx(v.X,{className:"h-5 w-5"})})]}),e.jsx(kt,{children:r.acceptedAt?`Ordered on ${T.format(new Date(r.acceptedAt),"MMMM dd, yyyy")}`:"Order details"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 mt-4",children:[e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 border border-gray-200 dark:border-gray-800",children:[e.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100 mb-3",children:"Order Status"}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Status"}),e.jsx(ea,{color:i(r.status||"pending"),variant:"neutral",children:r.status||"Pending"})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Accepted At"}),e.jsx("span",{children:r.acceptedAt?T.format(new Date(r.acceptedAt),"dd.MM.yyyy HH:mm"):"N/A"})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Ready For Dispatch"}),e.jsx("span",{children:r.readyForDispatchAt?T.format(new Date(r.readyForDispatchAt),"dd.MM.yyyy HH:mm"):"N/A"})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Dispatched At"}),e.jsx("span",{children:r.dispatchedAt?T.format(new Date(r.dispatchedAt),"dd.MM.yyyy HH:mm"):"N/A"})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Completed At"}),e.jsx("span",{children:r.completedAt?T.format(new Date(r.completedAt),"dd.MM.yyyy HH:mm"):"N/A"})]})]})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 border border-gray-200 dark:border-gray-800",children:[e.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100 mb-3",children:"Payment Information"}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Method"}),e.jsx("span",{className:"font-medium",children:((n=r.payment)==null?void 0:n.method)||"N/A"})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Provider"}),e.jsx("span",{children:((o=r.payment)==null?void 0:o.provider)||"N/A"})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Status"}),e.jsx(ea,{color:((l=r.payment)==null?void 0:l.status)==="succeeded"?"green":"yellow",variant:"neutral",children:((c=r.payment)==null?void 0:c.status)||"Pending"})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Total Amount"}),e.jsx("span",{className:"font-bold",children:s(Number((m=r.payment)==null?void 0:m.total)||0)})]})]})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 border border-gray-200 dark:border-gray-800",children:[e.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100 mb-3",children:r.fulfilmentMethod==="pickup"?"Pickup Details":"Shipping Address"}),r.shippingAddress?e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("p",{className:"font-medium",children:[r.shippingAddress.firstname," ",r.shippingAddress.lastname]}),e.jsxs("p",{children:[r.shippingAddress.addressLineOne,r.shippingAddress.doorNumber?`, ${r.shippingAddress.doorNumber}`:""]}),e.jsxs("p",{children:[r.shippingAddress.zipCode,", ",r.shippingAddress.city]}),e.jsx("p",{children:r.shippingAddress.country}),r.shippingAddress.phone&&e.jsxs("p",{className:"mt-2",children:["Phone: ",r.shippingAddress.phone]})]}):e.jsx("p",{className:"text-gray-500",children:"No address information available"})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 border border-gray-200 dark:border-gray-800",children:[e.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100 mb-3",children:"Fulfilment Details"}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Fulfilment Method"}),e.jsx(ea,{color:"blue",variant:"neutral",children:r.fulfilmentMethod||"N/A"})]}),r.fulfilmentMethod==="delivery"&&e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Shipping Method"}),e.jsx("span",{children:((u=r.shippingMethod)==null?void 0:u.title)||"Standard Shipping"})]})]})]})]}),e.jsxs("div",{className:"mt-6 bg-gray-50 dark:bg-gray-900 rounded-lg p-4 border border-gray-200 dark:border-gray-800",children:[e.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100 mb-3",children:"Order Items"}),e.jsx("div",{className:"divide-y divide-gray-200 dark:divide-gray-800",children:r.items.map((g,f)=>{const x=g.translations.find(j=>j.locale==="en")||g.translations[0];return e.jsxs("div",{className:"py-3 flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[g.image&&e.jsx("div",{className:"h-16 w-16 rounded overflow-hidden shrink-0",children:e.jsx("img",{src:g.image.url,alt:(x==null?void 0:x.title)||"Product",className:"h-full w-full object-cover"})}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium",children:(x==null?void 0:x.title)||"Product"}),(x==null?void 0:x.subtitle)&&e.jsx("p",{className:"text-sm text-gray-500",children:x.subtitle}),e.jsxs("p",{className:"text-sm mt-1",children:[s(g.unitPrice)," × ",g.quantity]})]})]}),e.jsx("div",{className:"font-medium",children:s(g.totalPrice)})]},f)})}),e.jsx("div",{className:"mt-4 pt-4 border-t border-gray-200 dark:border-gray-800",children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"font-medium",children:"Total"}),e.jsx("span",{className:"font-bold text-lg",children:s(Number((p=r.payment)==null?void 0:p.total)||0)})]})})]})]})})},kd=({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(wd,{open:t,onOpenChange:r,order:a})]})},vd=({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(jd,{organizationId:s,id:a.id,status:a.status,refetch:i})},Pe=fe.createColumnHelper(),Nd=[Pe.accessor("id",{header:({column:a})=>e.jsx(B,{column:a,title:"ID"}),meta:{className:"text-left",displayName:"ID"},cell:({row:a})=>e.jsx(kd,{order:a.original}),enableSorting:!0,enableHiding:!1}),Pe.accessor("referenceId",{header:({column:a})=>e.jsx(B,{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}),Pe.display({id:"customer",meta:{className:"text-left",displayName:"ID"},header:({column:a})=>e.jsx(B,{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"})}}),Pe.accessor("payment.total",{meta:{className:"text-left",displayName:"ID"},enableSorting:!0,enableHiding:!1,header:({column:a})=>e.jsx(B,{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})}}),Pe.accessor("createdAt",{meta:{className:"text-left",displayName:"ID"},enableSorting:!0,enableHiding:!1,header:({column:a})=>e.jsx(B,{column:a,title:"Date & Time"}),cell:({row:a})=>{const t=a.getValue("createdAt");return t?T.format(new Date(t),"dd.MM.yyyy HH:mm"):"N/A"}}),Pe.display({id:"paymentMethod",header:({column:a})=>e.jsx(B,{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"})}}),Pe.display({id:"address",meta:{className:"text-left",displayName:"ID"},header:({column:a})=>e.jsx(B,{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]})]})}}),Pe.display({id:"status",header:({column:a})=>e.jsx(B,{column:a,title:"Actions"}),cell:({row:a,table:t})=>e.jsx(vd,{order:a.original,table:t})})],Ad=()=>{const{client:a}=E(),t=V(),r=S.useSearchParams(),[s,i]=h.useState(""),[n]=Te.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:f}=await a.order.getOrders({params:{organizationId:t},query:{page:o,limit:10,search:n}});if(f!==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(ca,{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:Nd,className:"mt-8",refetch:p})]})};function Cd(){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(Ad,{})})]})}const Di=({onClose:a,initialData:t})=>{var m;const{client:r}=E(),s=L.useForm({resolver:ce.zodResolver(t?Qt:gs),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 ae.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 ae.invalidateQueries({queryKey:["organizations"]}),a&&a()}}),c=u=>{t?l.mutate(u):o.mutate(u)};return e.jsx("div",{className:"mt-6",children:e.jsx(L.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(oe,{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(ke,{name:"name",label:"Organization Name",placeholder:"Acme Inc.",className:"col-span-2"}),e.jsx(ke,{name:"email",type:"email",label:"Support Email",placeholder:"john.doe@example.com",className:"col-span-2"}),e.jsx(ke,{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(pt,{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(ke,{name:"address.addressLineTwo",label:"Door / Address Line 2",placeholder:"Apt 123",className:"col-span-2"}),e.jsx(ke,{name:"address.zipCode",label:"Postal Code",placeholder:"12345",className:"col-span-2"}),e.jsx(ke,{name:"address.city",label:"City",placeholder:"New York",className:"col-span-2"}),e.jsx(ke,{name:"address.country",label:"Country",placeholder:"United States",className:"col-span-2",type:"country"}),e.jsx(ke,{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(I,{type:"button",className:"w-full sm:w-fit",variant:"secondary",onClick:a,children:"Cancel"}),e.jsx(I,{type:"submit",className:"w-full sm:w-fit",isLoading:o.isPending||l.isPending,loadingText:"Saving...",children:t?"Update Data":"Create Organization"})]})]})})})},Sd=({invitation:a})=>{var s;const{client:t}=E(),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()=>{Q.success(`Joined ${a.organization.name}`),await ae.invalidateQueries({queryKey:["organizations"]}),await ae.invalidateQueries({queryKey:["user-invitations"]})},onError:i=>{Q.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(v.CheckIcon,{className:"w-5 h-5"})})})]})]})},zd=()=>{const[a,t]=h.useState(!1),r=q(),{client:s}=E(),{organizations:i}=he(),{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(I,{onClick:()=>t(!0),variant:"primary",children:[e.jsx(v.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(Sd,{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(xe,{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(D,{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(v.ArrowRight,{className:"w-5 h-5"})})})]})]},l.id)})]})]}),e.jsxs(yt,{onOpenChange:o,open:a,children:[e.jsx(xi,{className:"w-full text-left"}),e.jsxs(bt,{className:"sm:max-w-xl",children:[e.jsxs(jt,{children:[e.jsx(wt,{children:"Create a Organization"}),e.jsx(kt,{className:"mt-1 text-sm leading-6",children:"Fill in the details below to create a new organization"})]}),e.jsx(Di,{onClose:o})]})]})]})};function Id(){const{appearance:a}=Lr(),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(xe,{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(zd,{})})})]})}const $a=ee.Root;$a.displayName="Select";const Ed=ee.Group;Ed.displayName="SelectGroup";const _a=ee.Value;_a.displayName="SelectValue";const Dd=[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",la)],Wa=h.forwardRef(({className:a,hasError:t,children:r,...s},i)=>e.jsxs(ee.Trigger,{ref:i,className:w(Dd,t?ht:"",a),...s,children:[e.jsx("span",{className:"truncate",children:r}),e.jsx(ee.Icon,{asChild:!0,children:e.jsx(z.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")})})]}));Wa.displayName="SelectTrigger";const Fi=h.forwardRef(({className:a,...t},r)=>e.jsx(ee.ScrollUpButton,{ref:r,className:w("flex cursor-default items-center justify-center py-1",a),...t,children:e.jsx(z.RiArrowUpSLine,{className:"size-3 shrink-0","aria-hidden":"true"})}));Fi.displayName=ee.ScrollUpButton.displayName;const Ri=h.forwardRef(({className:a,...t},r)=>e.jsx(ee.ScrollDownButton,{ref:r,className:w("flex cursor-default items-center justify-center py-1",a),...t,children:e.jsx(z.RiArrowDownSLine,{className:"size-3 shrink-0","aria-hidden":"true"})}));Ri.displayName=ee.ScrollDownButton.displayName;const Ga=h.forwardRef(({className:a,position:t="popper",children:r,sideOffset:s=8,collisionPadding:i=10,...n},o)=>e.jsx(ee.Portal,{children:e.jsxs(ee.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(Fi,{}),e.jsx(ee.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(Ri,{})]})}));Ga.displayName="SelectContent";const Fd=h.forwardRef(({className:a,...t},r)=>e.jsx(ee.Label,{ref:r,className:w("px-3 py-2 text-xs font-medium tracking-wide","text-gray-500 dark:text-gray-500",a),...t}));Fd.displayName="SelectGroupLabel";const Fe=h.forwardRef(({className:a,children:t,...r},s)=>e.jsxs(ee.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(ee.ItemText,{className:"flex-1 truncate",children:t}),e.jsx(ee.ItemIndicator,{children:e.jsx(z.RiCheckLine,{className:"size-5 shrink-0 text-gray-800 dark:text-gray-200","aria-hidden":"true"})})]}));Fe.displayName="SelectItem";const Rd=h.forwardRef(({className:a,children:t,period:r,...s},i)=>e.jsxs(ee.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(ee.ItemIndicator,{children:e.jsx(z.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(ee.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:[T.format(r.from,"MMM d, yyyy")," –"," ",T.format(r.to,"MMM d, yyyy")]})})]})]}));Rd.displayName="SelectItemPeriod";const Pd=h.forwardRef(({className:a,...t},r)=>e.jsx(ee.Separator,{ref:r,className:w("-mx-1 my-1 h-px","bg-gray-300 dark:bg-gray-700",a),...t}));Pd.displayName="SelectSeparator";const Ve=fe.createColumnHelper(),Md=({row:a,table:t})=>{var c,m;const{client:r}=E(),s=a.getValue("publishedAt"),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.updateStatus({params:{id:a.getValue("id"),organizationId:i,operation:s?"unpublish":"publish"}})).status!==200)throw new Error("Failed to update product category status");n&&await n()}}),l=()=>{o.mutate()};return o.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(ie,{className:"w-4 h-4"})," Saving..."]})}):e.jsx("div",{className:"min-w-28",children:e.jsxs("button",{onClick:l,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:[s?e.jsx(v.CheckCircle,{className:"w-4 h-4 text-emerald-600 dark:text-emerald-500"}):e.jsx(v.EyeOffIcon,{className:"w-4 h-4 text-red-600 dark:text-red-500"}),s?"Published":"Draft"]})})},Bd=({row:a,table:t})=>{var l,c,m,u;const{client:r}=E(),s=(l=t.options.meta)==null?void 0:l.organizationId,i=(c=t.options.meta)==null?void 0:c.refetch,n=A.useMutation({mutationFn:async()=>{if((await r.productCategory.deleteProductCategory({params:{id:a.getValue("id"),organizationId:s}})).status!==204)throw new Error("Failed to delete product category");i&&await i()}}),o=()=>{window.confirm("Are you sure you want to delete this product category? This action cannot be undone.")&&n.mutate()};return e.jsxs(Oe,{children:[e.jsx(Le,{asChild:!0,children:e.jsx(I,{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:n.isPending,children:n.isPending?e.jsx(ie,{className:"size-4 shrink-0"}):e.jsx(z.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(Je,{align:"end",className:"min-w-40",children:[e.jsx(be,{children:e.jsxs(D,{href:((u=(m=t.options.meta)==null?void 0:m.routes)==null?void 0:u.productCategoryEdit(s,a.getValue("id")))??`/admin/${s}/product-categories/${a.getValue("id")}`,className:"block flex items-center gap-2",children:[e.jsx(v.PencilIcon,{className:"w-4 h-4"}),"Edit"]})}),e.jsx(be,{className:"text-red-600 dark:text-red-500 cursor-pointer",onClick:o,disabled:n.isPending,children:e.jsxs("div",{className:"flex items-center gap-2",children:[n.isPending?e.jsx(ie,{className:"w-4 h-4"}):e.jsx(v.Trash2,{className:"w-4 h-4"}),n.isPending?"Deleting...":"Delete"]})})]})]})},Td=[Ve.display({id:"select",header:({table:a})=>e.jsx(Ce,{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(Ce,{checked:a.getIsSelected(),onCheckedChange:()=>a.toggleSelected(),className:"translate-y-0.5","aria-label":"Select row"}),enableSorting:!1,enableHiding:!1,meta:{displayName:"Select"}}),Ve.accessor("id",{header:({column:a})=>e.jsx(B,{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(D,{href:((n=(i=t.options.meta)==null?void 0:i.routes)==null?void 0:n.productCategoryEdit(r,a.getValue("id")))??`/admin/${r}/product-categories/${a.getValue("id")}`,className:"text-blue-500",children:a.getValue("id")})}}),Ve.accessor("slug",{header:({column:a})=>e.jsx(B,{column:a,title:"Slug"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"Slug"}}),Ve.accessor("title",{header:({column:a})=>e.jsx(B,{column:a,title:"Title"}),enableSorting:!1,meta:{className:"text-left",displayName:"Name"}}),Ve.accessor("publishedAt",{header:({column:a})=>e.jsx(B,{column:a,title:"Status"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"Status"},cell:({row:a,table:t})=>e.jsx(Md,{row:a,table:t})}),Ve.accessor("createdAt",{header:({column:a})=>e.jsx(B,{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()}}),Ve.display({id:"edit",header:"Edit",enableSorting:!1,enableHiding:!1,meta:{className:"text-right",displayName:"Edit"},cell:({row:a,table:t})=>e.jsx(Bd,{row:a,table:t})})],Qd=()=>{const{client:a}=E(),t=q(),{defaultLocale:r}=he(),s=V(),i=S.usePathname(),n=S.useRouter(),o=S.useSearchParams(),[l,c]=h.useState(""),[m,u]=h.useState("all"),p=Number((o==null?void 0:o.get("page"))||"1"),[g]=Te.useDebounce(l,300),f=m==="all"?void 0:m,x=(O,F)=>{const U=new URLSearchParams(o==null?void 0:o.toString());return U.set(O,F),U.toString()},j=()=>{p!==1&&n.replace(`${i}?${x("page","1")}`)},{isLoading:y,isRefetching:b,isError:k,data:N,refetch:R}=A.useQuery({queryKey:["productCategories",s,p,g,f,r],queryFn:async()=>{const{body:O,status:F}=await a.productCategory.getProductCategories({params:{organizationId:s},query:{page:p,limit:10,search:g,locale:r,publishedStatus:f}});if(F!==200)throw new Error("Failed to fetch product categories");return O},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:O=>{c(O.target.value),j()},className:"w-full sm:max-w-[250px] sm:[&>input]:h-[40px]"}),e.jsxs($a,{value:m,onValueChange:O=>{u(O),j()},children:[e.jsx(Wa,{className:"w-full sm:w-[190px]",children:e.jsx(_a,{placeholder:"All statuses"})}),e.jsxs(Ga,{children:[e.jsx(Fe,{value:"all",children:"All statuses"}),e.jsx(Fe,{value:"published",children:"Published"}),e.jsx(Fe,{value:"unpublished",children:"Unpublished"})]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(I,{asChild:!0,className:"hidden gap-x-2 px-2 py-1.5 text-sm sm:text-xs lg:flex",children:e.jsxs(D,{href:t.productCategoryCreate(s),children:["Create Product Category",e.jsx(v.PlusIcon,{className:"size-4 shrink-0","aria-hidden":"true"})]})})})]}),e.jsx(ca,{error:k,loading:y||b,meta:N==null?void 0:N.meta,data:(N==null?void 0:N.list)||[],columns:Td,className:"mt-8",refetch:R})]})};function Od(){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(Qd,{})})]})}const Ld=[{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"}],Pi=({initialData:a})=>{const{client:t}=E(),r=S.useRouter(),s=q(),i=V(),{defaultLocale:n,supportedLocales:o}=he(),l=a?qn:Zn,c=L.useForm({resolver:ce.zodResolver(l),defaultValues:a?{defaultLocale:n,slug:a.slug,image:a.image,translations:a.translations}:{defaultLocale:n,translations:o.map(f=>({locale:f}))}}),m=A.useMutation({mutationFn:async f=>{var y;const x={slug:f.slug,defaultLocale:f.defaultLocale,translations:f.translations,imageId:(y=f.image)==null?void 0:y.id},{status:j}=await t.productCategory.createProductCategory({params:{organizationId:i},body:x});if(j!==201)throw Q.error("Failed to create product category. Please try again later."),new Error("Failed to create product category")}}),u=A.useMutation({mutationFn:async f=>{var y;const x={slug:f.slug,defaultLocale:f.defaultLocale,translations:f.translations,imageId:((y=f.image)==null?void 0:y.id)||null},{status:j}=await t.productCategory.updateProductCategory({params:{organizationId:i,id:a.id},body:x});if(j!==200)throw Q.error("Failed to update product category. Please try again later."),new Error("Failed to update product category")}}),p=async()=>{Q.success("Product category saved successfully"),r.push(s.productCategories(i)),await ae.invalidateQueries({queryKey:["productCategories"]})},g=f=>{a?u.mutate(f,{onSuccess:p}):m.mutate(f,{onSuccess:p})};return e.jsx(Ne,{form:c,config:Ld,onSubmit:g,loading:m.isPending||u.isPending,cancelText:"Go back",okText:a?"Update Product Category":"Create Product Category"})};function Jd(){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(J,{}),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(Pi,{})})]})})})})]})}function Vd(){const a=V(),t=da(),{client:r}=E(),{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 Q.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(J,{}),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(ie,{className:"w-12 h-12"}),e.jsx("p",{className:"text-gray-500 text-sm mt-3",children:"Loading data..."})]})}):e.jsx(Pi,{initialData:i})})]})})})})]})}const Hd=({form:a})=>{const{client:t}=E(),r=V(),{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(Ne,{form:a,config:n})})]})})},Ud=({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(le,{htmlFor:`metadata-key-${c}`,className:"font-medium",children:"Key"}),e.jsx(oe,{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(oe,{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(I,{type:"button",variant:"destructive",className:"mt-8 min-w-[42px] h-[42px] p-0",onClick:()=>n(c),children:e.jsx(v.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(I,{type:"button",variant:"secondary",onClick:i,className:"w-full shadow-none mt-2",children:[e.jsx(v.PlusIcon,{className:"w-4 h-4 mr-2"}),"Add Row"]})]})})]})})},Zd=({open:a,onClose:t,initialData:r,onSubmit:s})=>{const{defaultLocale:i,supportedLocales:n}=he(),o=L.useForm({resolver:ce.zodResolver(is),defaultValues:r?{...r,defaultLocale:i}:{defaultLocale:i,translations:n.map(p=>({locale:p,title:""})),modifiers:[{title:"",price:0}]}}),{fields:l,append:c,remove:m}=L.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(yt,{open:a,onOpenChange:t,children:e.jsxs(bt,{className:"max-w-[710px]",children:[e.jsxs(jt,{children:[e.jsx(wt,{children:"New Modifier Group"}),e.jsx(kt,{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(L.FormProvider,{...o,children:[e.jsx(Ne,{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(Ne,{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(I,{type:"button",variant:"destructive",className:"mt-auto ml-4 min-w-[42px] h-[42px] p-0! shadow-none!",onClick:()=>m(g),children:e.jsx(v.XIcon,{className:"w-4 h-4"})})]},p.id)),e.jsx(I,{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(J,{className:"mt-8 mb-6"}),e.jsxs("div",{className:"flex justify-end space-x-3 mt-6 col-span-full",children:[e.jsx(I,{type:"button",className:"w-full sm:w-fit",variant:"secondary",onClick:t,children:"Cancel"}),e.jsx(I,{type:"button",className:"w-full sm:w-fit",onClick:o.handleSubmit(u),children:r?"Save Modifier Group":"Create Modifier Group"})]})]})]})})},qd=({form:a})=>{const{control:t}=a,{defaultLocale:r}=he(),{fields:s,append:i,remove:n,update:o}=L.useFieldArray({control:t,name:"modifierGroups"}),[l,c]=h.useState(!1),[m,u]=h.useState(null),p=y=>({...y,defaultLocale:y.defaultLocale??r,modifiers:y.modifiers??[]}),g=y=>{y.preventDefault(),u(null),c(!0)},f=y=>{u(y),c(!0)},x=y=>{if(m===null){i(p(y)),c(!1);return}o(m,p(y)),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(I,{type:"button",variant:"secondary",className:"shadow-none",onClick:j,children:[e.jsx(v.BookCopyIcon,{className:"w-4 h-4 mr-2"})," Add From Template"]}),e.jsxs(I,{type:"button",variant:"secondary",className:"shadow-none",onClick:g,children:[e.jsx(v.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(I,{type:"button",variant:"secondary",className:"shadow-none",onClick:j,children:[e.jsx(v.BookCopyIcon,{className:"w-4 h-4 mr-2"})," Add From Template"]}),e.jsxs(I,{type:"button",variant:"secondary",className:"shadow-none",onClick:g,children:[e.jsx(v.PlusIcon,{className:"w-4 h-4 mr-2"})," Create Modifier Group"]})]}),e.jsx("div",{className:"space-y-4",children:s.map((y,b)=>{var k;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:()=>f(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: ",y.selectMin," | Max: ",y.selectMax]}),e.jsxs("p",{className:"text-sm text-gray-500 mt-1",children:["Available Options:"," ",(k=y.modifiers)==null?void 0:k.map(N=>N==null?void 0:N.title).join(",")]})]},y.id)})})]})})]}),e.jsx(Zd,{open:l,initialData:m===null?null:s[m],onSubmit:x,onClose:()=>{c(!1),u(null)}},m)]})},$d=({form:a,loading:t})=>{const{defaultCurrency:r}=he(),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}];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.jsx("div",{className:"md:col-span-2",children:e.jsx(Ne,{form:a,config:s,loading:t})})]})})},Mi=({initialData:a})=>{var j,y;const{client:t}=E(),r=S.useRouter(),s=q(),i=V(),{defaultCurrency:n,defaultLocale:o,supportedLocales:l}=he(),c=a==null?void 0:a.id,m=a?Gn:Wn,u=L.useForm({resolver:ce.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:(y=a.modifierGroups)==null?void 0:y.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:k}=await t.product.createProduct({params:{organizationId:i},body:b});if(k!==201)throw new Error("Failed to create product")}}),g=A.useMutation({mutationFn:async b=>{const{status:k}=await t.product.updateProduct({params:{organizationId:i,id:c},body:b});if(k!==200)throw new Error("Failed to update product")}}),f=async()=>{Q.success("Product saved successfully"),r.push(s.products(i)),await ae.invalidateQueries({queryKey:["products"]}),c&&await ae.invalidateQueries({queryKey:["product",i,c]})},x=b=>{a?g.mutate(b,{onSuccess:f}):p.mutate(b,{onSuccess:f})};return e.jsx(L.FormProvider,{...u,children:e.jsxs("form",{onSubmit:u.handleSubmit(b=>x(b)),className:"space-y-14",children:[e.jsx(Hd,{form:u}),e.jsx(J,{}),e.jsx($d,{form:u}),e.jsx(J,{}),e.jsx(qd,{form:u}),e.jsx(J,{}),e.jsx(Ud,{form:u}),e.jsx(J,{}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsxs(I,{type:"button",variant:"secondary",onClick:()=>r.push(s.products(i)),children:[e.jsx(v.ChevronLeft,{className:"w-4 h-4 mr-2"})," Cancel"]}),e.jsxs(I,{type:"submit",isLoading:p.isPending||g.isPending,loadingText:"Saving...",children:[e.jsx(v.CheckIcon,{className:"w-4 h-4 mr-2"})," ",a?"Save Product":"Create Product"]})]})]})})};function _d(){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(J,{}),e.jsx("div",{className:"pt-6",children:e.jsx("div",{className:"space-y-10",children:e.jsx(Mi,{})})})]})}function Wd(){const a=V(),t=da(),{client:r}=E(),{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 Q.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(J,{}),i?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ie,{className:"w-8 h-8"})}):e.jsx("div",{className:"pt-6",children:e.jsx(Mi,{initialData:s})})]})}const Ie=fe.createColumnHelper(),Gd=({row:a,table:t})=>{var c;const{client:r}=E(),s=a.getValue("publishedAt"),i=(c=t.options.meta)==null?void 0:c.organizationId,n=t.options.meta.refetch,o=A.useMutation({mutationFn:async()=>{if((await r.product.updateStatus({params:{id:a.getValue("id"),organizationId:i,operation:s?"unpublish":"publish"}})).status!==200)throw new Error("Failed to update product status");await n()}}),l=()=>{o.mutate()};return o.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(ie,{className:"w-4 h-4"})," Saving..."]})}):e.jsx("div",{className:"min-w-28",children:e.jsxs("button",{onClick:l,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:[s?e.jsx(v.CheckCircle,{className:"w-4 h-4 text-emerald-600 dark:text-emerald-500"}):e.jsx(v.EyeOffIcon,{className:"w-4 h-4 text-red-600 dark:text-red-500"}),s?"Published":"Draft"]})})},Kd=({row:a,table:t})=>{var l,c,m;const{client:r}=E(),s=(l=t.options.meta)==null?void 0:l.organizationId,i=t.options.meta.refetch,n=A.useMutation({mutationFn:async()=>{if((await r.product.deleteProduct({params:{id:a.getValue("id"),organizationId:s}})).status!==204)throw new Error("Failed to delete product");await i()}}),o=()=>{window.confirm("Are you sure you want to delete this product? This action cannot be undone.")&&n.mutate()};return e.jsxs(Oe,{children:[e.jsx(Le,{asChild:!0,children:e.jsx(I,{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:n.isPending,children:n.isPending?e.jsx(ie,{className:"size-4 shrink-0"}):e.jsx(z.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(Je,{align:"end",className:"min-w-40",children:[e.jsx(be,{children:e.jsxs(D,{href:((m=(c=t.options.meta)==null?void 0:c.routes)==null?void 0:m.productEdit(s,a.getValue("id")))??`/admin/${s}/products/${a.getValue("id")}`,className:"block flex items-center gap-2",children:[e.jsx(v.PencilIcon,{className:"w-4 h-4"}),"Edit"]})}),e.jsx(be,{className:"text-red-600 dark:text-red-500 cursor-pointer",onClick:o,disabled:n.isPending,children:e.jsxs("div",{className:"flex items-center gap-2",children:[n.isPending?e.jsx(ie,{className:"w-4 h-4"}):e.jsx(v.Trash2,{className:"w-4 h-4"}),n.isPending?"Deleting...":"Delete"]})})]})]})},Xd=[Ie.display({id:"select",header:({table:a})=>e.jsx(Ce,{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(Ce,{checked:a.getIsSelected(),onCheckedChange:()=>a.toggleSelected(),className:"translate-y-0.5","aria-label":"Select row"}),enableSorting:!1,enableHiding:!1,meta:{displayName:"Select"}}),Ie.accessor("id",{header:({column:a})=>e.jsx(B,{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(D,{href:((n=(i=t.options.meta)==null?void 0:i.routes)==null?void 0:n.productEdit(r,a.getValue("id")))??`/admin/${r}/products/${a.getValue("id")}`,className:"text-blue-500",children:a.getValue("id")})}}),Ie.accessor("title",{header:({column:a})=>e.jsx(B,{column:a,title:"Title"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"Slug"}}),Ie.accessor("sku",{header:({column:a})=>e.jsx(B,{column:a,title:"SKU"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"SKU"},cell:({row:a})=>a.getValue("sku")||"-"}),Ie.accessor("basePrice",{header:({column:a})=>e.jsx(B,{column:a,title:"Base Price"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"Base Price"},cell:({row:a})=>`$${a.getValue("basePrice").toFixed(2)}`}),Ie.accessor("discountedBasePrice",{header:({column:a})=>e.jsx(B,{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 t?`$${t.toFixed(2)}`:"-"}}),Ie.accessor("publishedAt",{header:({column:a})=>e.jsx(B,{column:a,title:"Status"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"Slug"},cell:({row:a,table:t})=>e.jsx(Gd,{row:a,table:t})}),Ie.accessor("createdAt",{header:({column:a})=>e.jsx(B,{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()}}),Ie.display({id:"edit",header:"Edit",enableSorting:!1,enableHiding:!1,meta:{className:"text-right",displayName:"Edit"},cell:({row:a,table:t})=>e.jsx(Kd,{row:a,table:t})})],Yd=()=>{const{client:a}=E(),t=q(),{defaultLocale:r}=he(),s=V(),i=S.usePathname(),n=S.useRouter(),o=S.useSearchParams(),[l,c]=h.useState(""),[m,u]=h.useState("all"),[p,g]=h.useState("all"),[f]=Te.useDebounce(l,300),x=Number((o==null?void 0:o.get("page"))||"1"),j=m==="all"?void 0:m,y=p==="all"?void 0:p,b=(P,H)=>{const je=new URLSearchParams(o==null?void 0:o.toString());return je.set(P,H),je.toString()},k=()=>{x!==1&&n.replace(`${i}?${b("page","1")}`)},{data:N=[]}=A.useQuery({queryKey:["productCategoriesFilter",s,r],queryFn:async()=>{const{body:P,status:H}=await a.productCategory.getProductCategories({params:{organizationId:s},query:{limit:100,locale:r}});if(H!==200)throw new Error("Failed to fetch product categories");return P.list.map(je=>({label:je.title||"Untitled category",value:je.id}))},placeholderData:[]}),{isLoading:R,isRefetching:O,isError:F,data:U,refetch:te}=A.useQuery({queryKey:["products",s,x,f,j,y,r],queryFn:async()=>{const{body:P,status:H}=await a.product.getProducts({params:{organizationId:s},query:{page:x,limit:10,search:f,locale:r,categoryId:j,publishedStatus:y}});if(H!==200)throw new Error("Failed to fetch products");return P},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:P=>{c(P.target.value),k()},className:"w-full sm:max-w-[250px] sm:[&>input]:h-[40px]"}),e.jsxs($a,{value:m,onValueChange:P=>{u(P),k()},children:[e.jsx(Wa,{className:"w-full sm:w-[220px]",children:e.jsx(_a,{placeholder:"All categories"})}),e.jsxs(Ga,{children:[e.jsx(Fe,{value:"all",children:"All categories"}),N.map(P=>e.jsx(Fe,{value:P.value,children:P.label},P.value))]})]}),e.jsxs($a,{value:p,onValueChange:P=>{g(P),k()},children:[e.jsx(Wa,{className:"w-full sm:w-[190px]",children:e.jsx(_a,{placeholder:"All statuses"})}),e.jsxs(Ga,{children:[e.jsx(Fe,{value:"all",children:"All statuses"}),e.jsx(Fe,{value:"published",children:"Published"}),e.jsx(Fe,{value:"unpublished",children:"Unpublished"})]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(I,{asChild:!0,className:"hidden gap-x-2 px-2 py-1.5 text-sm sm:text-xs lg:flex",children:e.jsxs(D,{href:t.productCreate(s),children:["Create Product",e.jsx(v.PlusIcon,{className:"size-4 shrink-0","aria-hidden":"true"})]})})})]}),e.jsx(ca,{error:F,loading:R||O,meta:U!=null&&U.meta?{...U==null?void 0:U.meta,currentPage:x}:void 0,data:(U==null?void 0:U.list)||[],columns:Xd,className:"mt-8",refetch:te})]})};function ec(){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(Yd,{})})]})}const ac=({organizationId:a,id:t,acceptedAt:r,cancelledAt:s,refetch:i})=>{var j;const{client:n}=E(),o=A.useMutation({mutationFn:async({operation:y})=>{if((await n.reservation.updateReservationStatus({params:{organizationId:a,reservationId:t,operation:y},body:{}})).status!==200)throw new Error("Failed to update reservation status");return i()}}),l=()=>{o.mutate({operation:"accept"})},c=()=>{o.mutate({operation:"cancel"})},m=o.isPending,u=(j=o.variables)==null?void 0:j.operation,p=m&&u==="cancel",g=m&&u==="accept",f=!r&&!s,x=!s;return e.jsxs("div",{className:"flex items-center gap-2 min-w-28 min-h-[45px]",children:[x&&e.jsxs("button",{onClick:c,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",children:[p?"Loading...":"Cancel",e.jsx(v.X,{className:"w-4 h-4 text-red-600 dark:text-red-500"})]}),f&&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",children:[g?"Loading...":"Accept",e.jsx(v.CheckCircle,{className:"w-4 h-4 text-emerald-600 dark:text-emerald-500"})]})]})},tc=({open:a,onOpenChange:t,reservation:r})=>e.jsx(ka,{open:a,onOpenChange:t,children:e.jsxs(va,{className:"sm:max-w-[500px] overflow-y-auto max-h-[85vh]",children:[e.jsx(Lt,{children:e.jsx(ot,{children:"Reservation Details"})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 py-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:"Reference ID"}),e.jsx("p",{className:"text-sm font-medium",children:r.referenceId})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:"Status"}),e.jsx("p",{className:"text-sm font-medium",children:r.cancelledAt?"Cancelled":r.acceptedAt?"Accepted":"Pending"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:"Customer Name"}),e.jsx("p",{className:"text-sm font-medium",children:`${r.firstname} ${r.lastname}`})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:"Phone"}),e.jsx("p",{className:"text-sm font-medium",children:r.phone||"N/A"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:"Number of Guests"}),e.jsx("p",{className:"text-sm font-medium",children:r.guests})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:"Reservation Date"}),e.jsx("p",{className:"text-sm font-medium",children:r.date?T.format(new Date(r.date),"PPpp"):"N/A"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:"Created At"}),e.jsx("p",{className:"text-sm font-medium",children:r.createdAt?T.format(new Date(r.createdAt),"PPpp"):"N/A"})]}),r.acceptedAt&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:"Accepted At"}),e.jsx("p",{className:"text-sm font-medium",children:T.format(new Date(r.acceptedAt),"PPpp")})]}),r.cancelledAt&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:"Cancelled At"}),e.jsx("p",{className:"text-sm font-medium",children:T.format(new Date(r.cancelledAt),"PPpp")})]})]})]})}),rc=({reservation: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(tc,{open:t,onOpenChange:r,reservation:a})]})},sc=({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(ac,{organizationId:s,id:a.id,acceptedAt:a.acceptedAt,cancelledAt:a.cancelledAt,refetch:i})},Ee=fe.createColumnHelper(),ic=[Ee.accessor("id",{header:({column:a})=>e.jsx(B,{column:a,title:"ID"}),meta:{className:"text-left",displayName:"ID"},cell:({row:a})=>e.jsx(rc,{reservation:a.original}),enableSorting:!0,enableHiding:!1}),Ee.accessor("referenceId",{header:({column:a})=>e.jsx(B,{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}),Ee.display({id:"customer",meta:{className:"text-left",displayName:"Customer"},header:({column:a})=>e.jsx(B,{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"})}}),Ee.accessor("guests",{meta:{className:"text-left",displayName:"Guests"},enableSorting:!0,enableHiding:!1,header:({column:a})=>e.jsx(B,{column:a,title:"Guests"}),cell:({row:a})=>e.jsx("div",{className:"font-medium",children:a.original.guests})}),Ee.accessor("phone",{meta:{className:"text-left",displayName:"Phone"},enableSorting:!1,enableHiding:!1,header:({column:a})=>e.jsx(B,{column:a,title:"Phone"}),cell:({row:a})=>e.jsx("div",{children:a.original.phone||"N/A"})}),Ee.accessor("date",{meta:{className:"text-left",displayName:"Reservation Date"},enableSorting:!0,enableHiding:!1,header:({column:a})=>e.jsx(B,{column:a,title:"Reservation Date"}),cell:({row:a})=>{const t=a.getValue("date");return t?T.format(new Date(t),"dd.MM.yyyy HH:mm"):"N/A"}}),Ee.accessor("createdAt",{meta:{className:"text-left",displayName:"Created At"},enableSorting:!0,enableHiding:!1,header:({column:a})=>e.jsx(B,{column:a,title:"Created At"}),cell:({row:a})=>{const t=a.getValue("createdAt");return t?T.format(new Date(t),"dd.MM.yyyy HH:mm"):"N/A"}}),Ee.display({id:"status",meta:{className:"text-left",displayName:"Status"},header:({column:a})=>e.jsx(B,{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"})}}),Ee.display({id:"actions",header:({column:a})=>e.jsx(B,{column:a,title:"Actions"}),cell:({row:a,table:t})=>e.jsx(sc,{reservation:a.original,table:t})})],nc=()=>{const{client:a}=E(),t=V(),r=S.useSearchParams(),[s,i]=h.useState(""),[n]=Te.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:["reservations",t,o,n],queryFn:async()=>{const{body:g,status:f}=await a.reservation.getReservations({params:{organizationId:t},query:{page:o,limit:10,search:n}});if(f!==200)throw new Error("Failed to fetch reservations");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 name or reference...",value:s,onChange:g=>i(g.target.value),className:"w-full sm:max-w-[250px] sm:[&>input]:h-[40px]"})})}),e.jsx(ca,{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:ic,className:"mt-8",refetch:p})]})};function oc(){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(nc,{})})]})}const lc=[{label:"Owner",value:"owner"},{label:"Admin",value:"admin"},{label:"Member",value:"member"}],Bi=({initialData:a})=>{const{client:t}=E(),r=S.useRouter(),s=q(),i=V(),n=!!a,o=n?Vn:Jn,l=L.useForm({resolver:ce.zodResolver(o),defaultValues:n?{role:a.role}:{email:"",role:"member"}}),c=A.useMutation({mutationFn:async g=>{const{status:f}=await t.access.createInvitation({params:{organizationId:i},body:g});if(f!==201)throw new Error("Failed to create invitation")}}),m=A.useMutation({mutationFn:async g=>{const{status:f}=await t.access.updateMemberRole({params:{organizationId:i,memberId:a.id},body:g});if(f!==200)throw new Error("Failed to update member role")}}),u=async()=>{Q.success(n?"Member role updated successfully":"Invitation sent successfully"),r.push(s.settingsAccess(i)),await ae.invalidateQueries({queryKey:["access-members"]}),await ae.invalidateQueries({queryKey:["access-invitations"]})},p=g=>{n?m.mutate({role:g.role},{onSuccess:u}):c.mutate(g,{onSuccess:u})};return e.jsx(L.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(oe,{id:"member-email",value:a.user.email,disabled:!0,readOnly:!0,className:"w-full mt-2"})]}),e.jsx(Ne,{form:l,config:[...n?[]:[{name:"email",label:"Email",type:"email",placeholder:"user@example.com",colspan:2}],{name:"role",label:"Role",type:"select",options:lc,colspan:2}]})]})]})}),e.jsx(J,{}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsxs(I,{type:"button",variant:"secondary",onClick:()=>r.push(s.settingsAccess(i)),children:[e.jsx(v.ChevronLeft,{className:"w-4 h-4 mr-2"})," Cancel"]}),e.jsxs(I,{type:"submit",isLoading:c.isPending||m.isPending,loadingText:"Saving...",children:[e.jsx(v.CheckIcon,{className:"w-4 h-4 mr-2"})," ",n?"Save Role":"Send Invitation"]})]})]})})};function dc(){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(J,{}),e.jsx("div",{className:"pt-6",children:e.jsx("div",{className:"space-y-10",children:e.jsx(Bi,{})})})]})}const cc=()=>{var u;const{client:a}=E(),t=V(),r=q(),s=S.useSearchParams(),[i]=h.useState(""),[n]=Te.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()=>{Q.success("Member removed successfully"),await ae.invalidateQueries({queryKey:["access-members"]})},onError:p=>{Q.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(ie,{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(D,{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."})},mc=()=>{const{client:a}=E(),t=V(),{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()=>{Q.success("Invitation revoked"),await ae.invalidateQueries({queryKey:["access-invitations",t]})},onError:n=>{Q.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(ie,{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(sr,{children:[e.jsx(ir,{children:e.jsxs(Ze,{className:"border-y border-gray-200 dark:border-gray-800",children:[e.jsx(Ue,{className:"whitespace-nowrap py-1 text-sm sm:text-xs",children:"Email"}),e.jsx(Ue,{className:"whitespace-nowrap py-1 text-sm sm:text-xs",children:"Role"}),e.jsx(Ue,{className:"whitespace-nowrap py-1 text-sm sm:text-xs",children:"Status"}),e.jsx(Ue,{className:"whitespace-nowrap py-1 text-sm sm:text-xs",children:"Expires"}),e.jsx(Ue,{className:"whitespace-nowrap py-1 text-sm sm:text-xs text-right",children:"Actions"})]})}),e.jsx(nr,{children:s.map(n=>e.jsxs(Ze,{className:"group select-none hover:bg-gray-50 dark:hover:bg-gray-900",children:[e.jsx(De,{className:"whitespace-nowrap py-1 text-gray-600 dark:text-gray-400",children:n.email}),e.jsx(De,{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(De,{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(De,{className:"whitespace-nowrap py-1 text-gray-600 dark:text-gray-400",children:new Date(n.expiresAt).toLocaleDateString()}),e.jsx(De,{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(v.Trash2,{className:"w-4 h-4"})})})]},n.id))})]})})};function uc(){const a=V(),t=q();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(I,{asChild:!0,className:"hidden gap-x-2 px-2 py-1.5 text-sm sm:text-xs lg:flex",children:e.jsxs(D,{href:t.settingsAccessInvite(a),children:["Invite User",e.jsx(v.PlusIcon,{className:"size-4 shrink-0","aria-hidden":"true"})]})})]}),e.jsx(cc,{}),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(mc,{})})]})]})}function pc(){const a=V(),t=da(),{client:r}=E(),{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 Q.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(J,{}),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(ie,{className:"w-12 h-12"}),e.jsx("p",{className:"text-gray-500 text-sm mt-3",children:"Loading data..."})]})}):e.jsx(Bi,{initialData:i})})})]})}const gc=Se.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"}}),qe=h.forwardRef(({className:a,variant:t,...r},s)=>e.jsx("span",{ref:s,className:w(gc({variant:t}),a),...r}));qe.displayName="Badge";const Ti=[{type:"stripe",name:"Stripe",description:"Payments and webhook delivery",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 Ti.find(t=>t.type===a)}function Ka(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 hc=a=>{if(!a)return{label:"Available",variant:"warning"};if(a.type==="stripe"){const t=it.safeParse(a.config);if(t.success)return t.data.hasSecretKey&&t.data.hasWebhookSecret?{label:"Configured",variant:"success"}:{label:"Needs setup",variant:"warning"}}return{label:"Configured",variant:"success"}};function xc(){const a=V(),t=q(),{client:r}=E(),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(J,{}),e.jsx("div",{className:"pt-6",children:s.isLoading?e.jsx("div",{className:"flex h-32 items-center justify-center",children:e.jsx(ie,{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:Ti.map(i=>{var l;const n=((l=s.data)==null?void 0:l.find(c=>c.type===i.type))??null,o=hc(n);return e.jsxs(_e,{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(qe,{variant:i.configurable?o.variant:"neutral",children:i.configurable?o.label:"Coming soon"})]})}),e.jsx("div",{className:"mt-6",children:i.configurable?e.jsx(I,{asChild:!0,className:"w-full justify-center gap-2",children:e.jsxs(D,{href:t.settingsIntegration(a,i.type),children:[n?"Edit Integration":"Select",e.jsx(v.ArrowRightIcon,{className:"h-4 w-4"})]})}):e.jsx(I,{type:"button",variant:"secondary",className:"w-full justify-center",disabled:!0,children:"Not available yet"})})]},i.type)})})})]})}const fc=ha.z.object({paymentMethods:ha.z.array(ha.z.enum(["card","blik"])),secretKey:ha.z.string(),webhookSecret:ha.z.string()}),yc=[{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."}],bc=a=>{const t=it.safeParse(a==null?void 0:a.config);return t.success?t.data:void 0};function jc(){var y;const{client:a,baseUrl:t}=E(),r=V(),s=S.useRouter(),i=q(),n=`${t.replace(/\/$/,"")}/webhook/payment/stripe/${r}`,o=L.useForm({resolver:ce.zodResolver(fc),defaultValues:{paymentMethods:["card"],secretKey:"",webhookSecret:""}}),l=((y=A.useQuery({queryKey:["organization-integrations",r],queryFn:async()=>{const{body:b,status:k}=await a.integration.getIntegrations({params:{organizationId:r}});if(k!==200)throw new Error("Failed to load integrations.");return b}}).data)==null?void 0:y.find(b=>b.type==="stripe"))??null,c=bc(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:k,webhookSecret:N})=>{var te;const R=k.trim(),O=N.trim(),F=Yn.safeParse({paymentMethods:b,secretKey:R||void 0,webhookSecret:O||void 0});if(!F.success)throw new Error(((te=F.error.issues[0])==null?void 0:te.message)??"Invalid Stripe configuration.");const{status:U}=await a.integration.upsertIntegration({params:{organizationId:r,type:"stripe"},body:{config:F.data}});if(U!==200)throw new Error("Failed to update Stripe integration.");await ae.invalidateQueries({queryKey:["organization-integrations",r]})},onSuccess:()=>{Q.success("Stripe integration updated."),s.push(i.settingsIntegrations(r))},onError:b=>{Q.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 ae.invalidateQueries({queryKey:["organization-integrations",r]})},onSuccess:()=>{Q.success("Stripe integration removed."),s.push(i.settingsIntegrations(r))},onError:b=>{Q.error(b.message||"Failed to remove Stripe integration.")}}),f=o.watch("paymentMethods"),x=(b,k)=>{const N=o.getValues("paymentMethods"),R=k?Array.from(new Set([...N,b])):N.filter(O=>O!==b);o.setValue("paymentMethods",R,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0})},j=b=>{o.clearErrors(["secretKey","webhookSecret"]);let k=!1;!(c!=null&&c.hasSecretKey)&&!b.secretKey.trim()&&(o.setError("secretKey",{type:"manual",message:"Stripe API key is required."}),k=!0),!(c!=null&&c.hasWebhookSecret)&&!b.webhookSecret.trim()&&(o.setError("webhookSecret",{type:"manual",message:"Stripe webhook secret is required."}),k=!0),!k&&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:yc.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(Ce,{checked:f.includes(b.value),onCheckedChange:k=>x(b.value,k),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(J,{}),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(qe,{variant:"success",children:"Configured"}):e.jsx(qe,{variant:"warning",children:"Required"})]}),e.jsx(oe,{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(J,{}),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(oe,{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(qe,{variant:"success",children:"Configured"}):e.jsx(qe,{variant:"warning",children:"Required"})]}),e.jsx(oe,{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(J,{}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsxs(I,{type:"button",variant:"secondary",onClick:()=>s.push(m),children:[e.jsx(v.ChevronLeft,{className:"mr-2 h-4 w-4"})," Cancel"]}),l&&e.jsxs(I,{type:"button",variant:"secondary",className:"text-red-600 dark:text-red-400",onClick:()=>g.mutate(),isLoading:g.isPending,loadingText:"Removing...",children:[e.jsx(v.Trash2Icon,{className:"mr-2 h-4 w-4"})," Remove"]}),e.jsxs(I,{type:"submit",isLoading:p.isPending,loadingText:"Saving...",children:[e.jsx(v.CheckIcon,{className:"mr-2 h-4 w-4"})," Save Integration"]})]})]})}function wc(){const a=da(),t=V(),r=q(),s=S.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:[Ka(a)," Integration"]}),e.jsx(J,{}),e.jsx("div",{className:"pt-6",children:e.jsx(jc,{})})]}):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)??Ka(a)}),e.jsx(J,{}),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(I,{type:"button",variant:"secondary",onClick:()=>s.push(r.settingsIntegrationsCreate(t)),children:"Back to Integration Catalog"})})]})]})}const kc=a=>{if(a.type==="stripe"){const t=it.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"}return"Configuration saved"},vc=a=>{if(a.type==="stripe"){const t=it.safeParse(a.config);if(t.success)return t.data.hasSecretKey&&t.data.hasWebhookSecret?{label:"Configured",variant:"success"}:{label:"Needs setup",variant:"warning"}}return{label:"Configured",variant:"success"}};function Nc(){var n;const{client:a}=E(),t=V(),r=q(),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()=>{Q.success("Integration removed successfully"),await ae.invalidateQueries({queryKey:["organization-integrations",t]})},onError:o=>{Q.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(ie,{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=Ka(o.type),m=vc(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(qe,{variant:m.variant,children:m.label})]}),e.jsx("p",{className:"mt-1 truncate text-xs text-gray-500",children:kc(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(D,{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 Ac(){const a=V(),t=q();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(I,{asChild:!0,className:"hidden gap-x-2 px-2 py-1.5 text-sm sm:text-xs lg:flex",children:e.jsxs(D,{href:t.settingsIntegrationsCreate(a),children:["Add Integration",e.jsx(v.PlusIcon,{className:"size-4 shrink-0","aria-hidden":"true"})]})})]}),e.jsx(Nc,{})]})}const Cc=[{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"}],Sc=({onClose:a,initialData:t})=>{var o,l,c,m,u,p;const{client:r}=E(),s=L.useForm({resolver:ce.zodResolver(Qt),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}}});console.log(s.watch());const{isPending:i,mutate:n}=A.useMutation({mutationFn:async({configuration:g})=>{const{status:f}=await r.organization.updateOrganization({params:{organizationId:t==null?void 0:t.id},body:{configuration:g}});if(f!==200)throw Q.error("Failed to update organization. Please try again later."),new Error("Failed to update organization");return await ae.invalidateQueries({queryKey:["organizations"]}),a&&a()}});return e.jsx(Ne,{form:s,config:Cc,onSubmit:g=>n(g),onCancel:a,loading:i,cancelText:"Go back",okText:"Save Schedule"})};function zc(){const{organization:a}=he();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(Sc,{initialData:a.data})})]})})}):e.jsx("div",{children:"Loading..."})}const Qi=({initialData:a})=>{var p;const{client:t}=E(),r=S.useRouter(),s=q(),i=V(),n=a?so:us,o=L.useForm({resolver:ce.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:f}=await t.shippingMethod.createShippingMethod({params:{organizationId:i},body:g});if(f!==201)throw Q.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:f}=await t.shippingMethod.updateShippingMethod({params:{organizationId:i,id:a.id},body:g});if(f!==200)throw Q.error("Failed to update shipping method. Please try again later."),new Error("Failed to update shipping method")}}),m=async()=>{Q.success("Shipping method saved successfully"),r.push(s.settingsShippingMethods(i)),await ae.invalidateQueries({queryKey:["shipping-and-payment"]})},u=g=>{a?c.mutate(g,{onSuccess:m}):l.mutate(g,{onSuccess:m})};return e.jsx(L.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(Ne,{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(J,{}),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(Ne,{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(J,{}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsxs(I,{type:"button",variant:"secondary",onClick:()=>r.push(s.settingsShippingMethods(i)),children:[e.jsx(v.ChevronLeft,{className:"w-4 h-4 mr-2"})," Cancel"]}),e.jsxs(I,{type:"submit",isLoading:l.isPending||c.isPending,loadingText:"Saving...",children:[e.jsx(v.CheckIcon,{className:"w-4 h-4 mr-2"})," ",a?"Save Product":"Create Shipping Method"]})]})]})})};function Ic(){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(J,{}),e.jsx("div",{className:"pt-6",children:e.jsx("div",{className:"space-y-10",children:e.jsx(Qi,{})})})]})}function Ec(){const a=V(),t=da(),{client:r}=E(),{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 Q.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(J,{}),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(ie,{className:"w-12 h-12"}),e.jsx("p",{className:"text-gray-500 text-sm mt-3",children:"Loading data..."})]})}):e.jsx(Qi,{initialData:i})})})]})}const Ke=fe.createColumnHelper(),Dc=[Ke.display({id:"select",header:({table:a})=>e.jsx(Ce,{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(Ce,{checked:a.getIsSelected(),onCheckedChange:()=>a.toggleSelected(),className:"translate-y-0.5","aria-label":"Select row"}),enableSorting:!1,enableHiding:!1,meta:{displayName:"Select"}}),Ke.accessor("id",{header:({column:a})=>e.jsx(B,{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(D,{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")})}}),Ke.accessor("title",{header:({column:a})=>e.jsx(B,{column:a,title:"Title"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"Title"}}),Ke.accessor("providerName",{header:({column:a})=>e.jsx(B,{column:a,title:"Provider Name"}),enableSorting:!0,meta:{className:"text-left",displayName:"Provider Name"}}),Ke.accessor("shippingZones",{header:({column:a})=>e.jsx(B,{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(", ")||"-"}),Ke.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(Oe,{children:[e.jsx(Le,{asChild:!0,children:e.jsx(I,{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(z.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(Je,{align:"end",className:"min-w-40",children:[e.jsx(be,{children:e.jsx(D,{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(be,{className:"text-red-600 dark:text-red-500",children:"Delete"})]})]})}})],Fc=()=>{const{client:a}=E(),t=V(),r=S.useSearchParams(),[s]=h.useState(""),[i]=Te.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(ca,{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:Dc,className:"mt-8"})})};function Rc(){const a=V(),t=q();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(I,{asChild:!0,className:"hidden gap-x-2 px-2 py-1.5 text-sm sm:text-xs lg:flex",children:e.jsxs(D,{href:t.settingsShippingMethodCreate(a),children:["Create Shipping Method",e.jsx(v.PlusIcon,{className:"size-4 shrink-0","aria-hidden":"true"})]})})]}),e.jsx(Fc,{})]})}function we({children:a}){const t=S.usePathname(),r=V(),s=q(),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(tr,{className:"mt-4 sm:mt-6 lg:mt-6",children:i.map(n=>e.jsx(rr,{asChild:!0,active:t===n.href,children:e.jsx(D,{href:n.href,children:n.name})},n.name))}),e.jsx("div",{className:"pt-6",children:a})]})}const Pc=[{name:"configuration.defaultLocale",label:"Default Locale",type:"select",placeholder:"",options:mr},{name:"configuration.supportedLocales",label:"Supported Locales",type:"select",placeholder:"Select locales",multiple:!0,options:mr},{name:"configuration.defaultCurrency",label:"Currency",type:"select",placeholder:"Acme Inc.",options:Rn}],Mc=({onClose:a,initialData:t})=>{var o,l,c;const{client:r}=E(),s=L.useForm({resolver:ce.zodResolver(Qt),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 Q.error("Failed to update organization. Please try again later."),new Error("Failed to update organization");return await ae.invalidateQueries({queryKey:["organizations"]}),a&&a()}});return e.jsx(Ne,{form:s,config:Pc,onSubmit:m=>n(m),onCancel:a,loading:i,cancelText:"Go back",okText:"Save Settings"})};function Bc(){const{organization:a}=he(),{client:t}=E(),r=V(),s=S.useRouter(),i=q(),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()=>{Q.success("You have left the organization"),await ae.invalidateQueries({queryKey:["organizations"]}),s.push(i.organizations)},onError:o=>{Q.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(Di,{initialData:a.data})})]})}),e.jsx(J,{}),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(Mc,{initialData:a.data})})]})}),e.jsx(J,{}),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(v.ExternalLinkIcon,{className:"size-4 shrink-0","aria-hidden":"true"})]})]})]}),e.jsx("div",{className:"space-y-6 md:col-span-2",children:e.jsx(_e,{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(I,{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 Y(a,t){return{label:"Home",href:t.dashboard(a)}}function Tc(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[Y(a.orgId,t),{label:"Orders"}];case"reservations":return[Y(a.orgId,t),{label:"Reservations"}];case"products-list":return[Y(a.orgId,t),{label:"Products"}];case"product-create":return[Y(a.orgId,t),{label:"Products",href:t.products(a.orgId)},{label:"Create Product"}];case"product-edit":return[Y(a.orgId,t),{label:"Products",href:t.products(a.orgId)},{label:"Edit Product"}];case"product-categories-list":return[Y(a.orgId,t),{label:"Product Categories"}];case"product-category-create":return[Y(a.orgId,t),{label:"Product Categories",href:t.productCategories(a.orgId)},{label:"Create Product Category"}];case"product-category-edit":return[Y(a.orgId,t),{label:"Product Categories",href:t.productCategories(a.orgId)},{label:"Edit Product Category"}];case"manufacturers-list":return[Y(a.orgId,t),{label:"Manufacturers"}];case"manufacturer-create":return[Y(a.orgId,t),{label:"Manufacturers",href:t.manufacturers(a.orgId)},{label:"Create Manufacturer"}];case"manufacturer-edit":return[Y(a.orgId,t),{label:"Manufacturers",href:t.manufacturers(a.orgId)},{label:"Edit Manufacturer"}];case"settings":return[Y(a.orgId,t),{label:"Settings"}];case"settings-opening-times":return[Y(a.orgId,t),{label:"Settings",href:t.settings(a.orgId)},{label:"Opening Times"}];case"settings-integrations":return[Y(a.orgId,t),{label:"Settings",href:t.settings(a.orgId)},{label:"Integrations"}];case"settings-integrations-create":return[Y(a.orgId,t),{label:"Settings",href:t.settings(a.orgId)},{label:"Integrations",href:t.settingsIntegrations(a.orgId)},{label:"Add Integration"}];case"settings-integration":return[Y(a.orgId,t),{label:"Settings",href:t.settings(a.orgId)},{label:"Integrations",href:t.settingsIntegrations(a.orgId)},{label:Ka(a.id)}];case"shipping-methods-list":return[Y(a.orgId,t),{label:"Settings",href:t.settings(a.orgId)},{label:"Shipping Methods"}];case"shipping-method-create":return[Y(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[Y(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[Y(a.orgId,t),{label:"Settings",href:t.settings(a.orgId)},{label:"Access"}];case"access-invite":return[Y(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[Y(a.orgId,t),{label:"Settings",href:t.settings(a.orgId)},{label:"Access",href:t.settingsAccess(a.orgId)},{label:"Edit Member"}]}}function Qc({view:a}){const t=q(),r=Tc(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(v.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(D,{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 Oc=()=>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"})})})]}),Oi=a=>e.jsx(W.Root,{...a});Oi.displayName="Drawer";const Li=C.forwardRef(({className:a,...t},r)=>e.jsx(W.Trigger,{ref:r,className:w(a),...t}));Li.displayName="Drawer.Trigger";const Ji=C.forwardRef(({className:a,...t},r)=>e.jsx(W.Close,{ref:r,className:w(a),...t}));Ji.displayName="Drawer.Close";const Vi=W.Portal;Vi.displayName="DrawerPortal";const Hi=C.forwardRef(({className:a,...t},r)=>e.jsx(W.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"}}));Hi.displayName="DrawerOverlay";const Ui=C.forwardRef(({className:a,...t},r)=>e.jsx(Vi,{children:e.jsx(Hi,{children:e.jsx(W.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",ge,a),...t})})}));Ui.displayName="DrawerContent";const Zi=C.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(W.Close,{asChild:!0,children:e.jsx(I,{variant:"ghost",className:"aspect-square p-1 hover:bg-gray-100 dark:hover:bg-gray-400/10",children:e.jsx(z.RiCloseLine,{className:"size-6","aria-hidden":"true"})})})]}));Zi.displayName="Drawer.Header";const qi=C.forwardRef(({className:a,...t},r)=>e.jsx(W.Title,{ref:r,className:w("text-base font-semibold","text-gray-900 dark:text-gray-50",a),...t}));qi.displayName="DrawerTitle";const $i=C.forwardRef(({className:a,...t},r)=>e.jsx("div",{ref:r,className:w("flex-1 py-4",a),...t}));$i.displayName="Drawer.Body";const Lc=C.forwardRef(({className:a,...t},r)=>e.jsx(W.Description,{ref:r,className:w("text-gray-500 dark:text-gray-500",a),...t}));Lc.displayName="DrawerDescription";function Jc(){const a=S.usePathname(),t=V(),r=q();if(!t)return null;const s=[{name:"Dashboard",href:r.dashboard(t),icon:v.HomeIcon},{name:"Live Orders",href:r.liveOrders(t),icon:v.RadioIcon},{name:"Orders",href:r.orders(t),icon:v.LogsIcon},{name:"Reservations",href:r.reservations(t),icon:v.CalendarCheckIcon},{name:"Products",href:r.products(t),icon:v.PackageIcon},{name:"Categories",href:r.productCategories(t),icon:v.BoxesIcon},{name:"Manufacturers",href:r.manufacturers(t),icon:v.FactoryIcon},{name:"Settings",href:r.settings(t),icon:z.RiSettings5Line}];return e.jsxs(Oi,{children:[e.jsx(Li,{asChild:!0,children:e.jsx(I,{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(z.RiMenuLine,{className:"size-6 shrink-0 sm:size-5","aria-hidden":"true"})})}),e.jsxs(Ui,{className:"sm:max-w-lg",children:[e.jsx(Zi,{children:e.jsx(qi,{children:"Navigation"})}),e.jsx($i,{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(Ji,{asChild:!0,children:e.jsxs(D,{href:i.href,className:X(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",ge),children:[e.jsx(i.icon,{className:"size-5 shrink-0","aria-hidden":"true"}),i.name]})})},i.name))})})})]})]})}const Vc=()=>{var l;const[a,t]=h.useState(!1),r=h.useRef(null),{organizations:s,organization:i}=he(),n=S.useRouter(),o=q();return e.jsx(e.Fragment,{children:e.jsxs(Oe,{open:a,onOpenChange:t,modal:!1,children:[e.jsx(Le,{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",la),children:[i.data.logoFile?e.jsx(xe,{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(z.RiExpandUpDownLine,{className:"size-5 shrink-0 text-gray-500","aria-hidden":"true"})]})]})}),e.jsx(Je,{hidden:!1,onCloseAutoFocus:c=>{r.current&&(r.current.focus(),r.current=null,c.preventDefault())},children:e.jsxs(ba,{children:[e.jsxs(vt,{children:["Workspaces (",s.data.length,")"]}),s.data.map(c=>{var m;return e.jsx(be,{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(xe,{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)})]})})]})})},Hc=()=>{const[a,t]=h.useState(!1),r=h.useRef(null),{organizations:s,organization:i}=he(),n=S.useRouter(),o=q();return e.jsxs(Oe,{open:a,onOpenChange:t,modal:!1,children:[e.jsx(Le,{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(xe,{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(z.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(z.RiExpandUpDownLine,{className:"size-4 shrink-0 text-gray-500","aria-hidden":"true"})]})]})}),e.jsx(Je,{className:"min-w-72!",onCloseAutoFocus:l=>{r.current&&(r.current.focus(),r.current=null,l.preventDefault())},children:e.jsxs(ba,{children:[e.jsxs(vt,{children:["Workspaces (",s.data.length,")"]}),s.data.map(l=>{var c;return e.jsx(be,{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(xe,{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 _i({children:a,align:t="start"}){var p,g;const r=S.useRouter(),[s,i]=C.useState(!1),{theme:n,setTheme:o}=Ir.useTheme(),l=ja(),c=q(),m=l.useSession();C.useEffect(()=>{i(!0)},[]);const u=()=>l.signOut({fetchOptions:{onSuccess:()=>r.push(c.signIn)}});return s?e.jsx(e.Fragment,{children:e.jsxs(Oe,{children:[e.jsx(Le,{asChild:!0,children:a}),e.jsxs(Je,{align:t,children:[e.jsx(vt,{children:(g=(p=m.data)==null?void 0:p.user)==null?void 0:g.email}),e.jsx(ba,{children:e.jsxs(Si,{children:[e.jsx(Ii,{children:"Theme"}),e.jsx(Ei,{children:e.jsxs(zi,{value:n,onValueChange:f=>{o(f)},children:[e.jsxs(Ba,{"aria-label":"Switch to Light Mode",value:"light",iconType:"check",children:[e.jsx(z.RiSunLine,{className:"size-4 shrink-0","aria-hidden":"true"}),"Light"]}),e.jsxs(Ba,{"aria-label":"Switch to Dark Mode",value:"dark",iconType:"check",children:[e.jsx(z.RiMoonLine,{className:"size-4 shrink-0","aria-hidden":"true"}),"Dark"]}),e.jsxs(Ba,{"aria-label":"Switch to System Mode",value:"system",iconType:"check",children:[e.jsx(z.RiComputerLine,{className:"size-4 shrink-0","aria-hidden":"true"}),"System"]})]})}),e.jsx(ba,{children:e.jsx(be,{onClick:u,className:"text-red-500",children:"Sign out"})})]})})]})]})}):null}const Uc=()=>{var s;const a=ja().useSession(),{firstname:t,lastname:r}=((s=a.data)==null?void 0:s.user)||{};return e.jsx(_i,{children:e.jsxs(I,{"aria-label":"User settings",variant:"ghost",className:X(ge,"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(z.RiMore2Fill,{className:"size-4 shrink-0 text-gray-500 group-hover:text-gray-700 dark:group-hover:text-gray-400","aria-hidden":"true"})]})})},Zc=()=>e.jsx(_i,{align:"end",children:e.jsx(I,{"aria-label":"User settings",variant:"ghost",className:X("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 qc(){const a=S.usePathname(),t=V(),r=q(),s=[{name:"Home",href:r.dashboard(t),icon:v.HomeIcon},{name:"Live Orders",href:r.liveOrders(t),icon:v.RadioIcon},{name:"Orders List",href:r.orders(t),icon:v.LogsIcon},{name:"Reservations",href:r.reservations(t),icon:v.CalendarCheckIcon},{name:"Products",href:r.products(t),icon:v.PackageIcon},{name:"Product Categories",href:r.productCategories(t),icon:v.BoxesIcon},{name:"Manufacturers",href:r.manufacturers(t),icon:v.FactoryIcon},{name:"Customers",href:`${r.dashboard(t)}/customers`,icon:v.UserCircleIcon},{name:"Settings",href:r.settings(t),icon:z.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(D,{href:r.home,className:"-ml-2",children:e.jsx(Oc,{})}),e.jsx("hr",{className:"block border-t border-gray-200 dark:border-gray-800 -mt-3 mb-1"}),e.jsx(Vc,{}),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(D,{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",ge),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(Uc,{})})]})}),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(Hc,{}),e.jsxs("div",{className:"flex items-center gap-1 sm:gap-2",children:[e.jsx(Zc,{}),e.jsx(Jc,{})]})]})]})}function $c({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(qc,{}),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(Qc,{view:t}),a]})})})]})]})}function _c(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 Wc({segments:a}){const t=ja(),r=q(),s=S.useRouter(),i=S.usePathname(),n=S.useSearchParams(),{data:o,isPending:l}=t.useSession(),c=_c(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(),f=i?`${i}${g?`?${g}`:""}`:r.home,x=m?ft(p,r):f;if(h.useEffect(()=>{if(!l){if(!o&&!m){s.replace(qt(r.signIn,x));return}o&&m&&s.replace(x)}},[o,l,m,s,r.signIn,x]),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(Fl,{});if(c.type==="sign-up")return e.jsx(Pl,{})}if(!o)return null;if(u)return e.jsx(Nr,{children:e.jsx(Id,{})});if(c.type==="not-found")return e.jsx(Zt,{});const j="orgId"in c?c.orgId:void 0,y="id"in c?c.id:void 0;return e.jsx(vl,{organizationId:j,id:y,children:e.jsx(Nr,{children:e.jsx(Cl,{children:e.jsx($c,{view:c,children:Gc(c)})})})})}function Gc(a){switch(a.type){case"dashboard":return e.jsx(Hl,{});case"orders":return e.jsx(Cd,{});case"reservations":return e.jsx(oc,{});case"products-list":return e.jsx(ec,{});case"product-create":return e.jsx(_d,{});case"product-edit":return e.jsx(Wd,{});case"product-categories-list":return e.jsx(Od,{});case"product-category-create":return e.jsx(Jd,{});case"product-category-edit":return e.jsx(Vd,{});case"manufacturers-list":return e.jsx(bd,{});case"manufacturer-create":return e.jsx(nd,{});case"manufacturer-edit":return e.jsx(od,{});case"settings":return e.jsx(we,{children:e.jsx(Bc,{})});case"settings-opening-times":return e.jsx(we,{children:e.jsx(zc,{})});case"settings-integrations":return e.jsx(we,{children:e.jsx(Ac,{})});case"settings-integrations-create":return e.jsx(we,{children:e.jsx(xc,{})});case"settings-integration":return e.jsx(we,{children:e.jsx(wc,{})});case"shipping-methods-list":return e.jsx(we,{children:e.jsx(Rc,{})});case"shipping-method-create":return e.jsx(we,{children:e.jsx(Ic,{})});case"shipping-method-edit":return e.jsx(we,{children:e.jsx(Ec,{})});case"access-list":return e.jsx(we,{children:e.jsx(uc,{})});case"access-invite":return e.jsx(we,{children:e.jsx(dc,{})});case"access-member-edit":return e.jsx(we,{children:e.jsx(pc,{})});default:return e.jsx(Zt,{})}}exports.APIProvider=Rt,exports.AccountHomePage=Xs,exports.AccountPages=al,exports.AdminProvider=gn,exports.AdminRouter=Wc,exports.Badge=ea,exports.Button=K,exports.CartDrawer=Fn,exports.CartDrawerItem=es,exports.CartItems=Yr,exports.CartPanel=as,exports.CartProvider=_r,exports.CheckoutPages=rl,exports.Command=Na,exports.CommandBar=Os,exports.CommandBarBar=Js,exports.CommandBarCommand=Hs,exports.CommandBarSeperator=Vs,exports.CommandBarValue=Ls,exports.CommandDialog=bo,exports.CommandEmpty=ct,exports.CommandGroup=mt,exports.CommandInput=lt,exports.CommandItem=ut,exports.CommandList=dt,exports.CommandSeparator=Ns,exports.CommandShortcut=As,exports.CountryInput=zs,exports.CustomerDetailsPage=zt,exports.Dialog=ka,exports.DialogClose=bs,exports.DialogContent=va,exports.DialogDescription=ks,exports.DialogFooter=vs,exports.DialogHeader=Lt,exports.DialogTitle=ot,exports.DialogTrigger=ys,exports.Divider=aa,exports.EmailInput=Is,exports.ErrorView=Zt,exports.ImageUploadInput=Es,exports.Input=Bs,exports.InputGroup=me,exports.Label=ye,exports.LocationInput=pt,exports.ModifierContainer=ri,exports.ModifiersDialog=il,exports.ModifiersGroup=si,exports.ModifiersModal=ol,exports.ModifiersOption=ii,exports.PhoneNumberInput=Rs,exports.Popover=ia,exports.PopoverAnchor=Cs,exports.PopoverClose=Ss,exports.PopoverContent=oa,exports.PopoverTrigger=na,exports.QuantityControl=nl,exports.RadioCardGroup=Ja,exports.RadioCardGroupIndicator=Va,exports.RadioCardItem=Ha,exports.SelectInput=Ps,exports.ShippingAndPaymentPage=Zs,exports.ShophostProvider=jl,exports.SliderOver=Qs,exports.Switch=Jt,exports.TextInput=ve,exports.TimeInput=Vt,exports.badgeVariants=Us,exports.buttonVariants=fs,exports.calculateCartTotal=xn,exports.createAdminAuthClient=Vr,exports.createRoutes=Ur,exports.findCartItem=yn,exports.formatPrice=ue,exports.getAdminAuthClient=Hr,exports.getFieldError=Ts,exports.getFormattedModifiers=fn,exports.mockProducts=cl,exports.productRequiresModifiers=jn,exports.useAPI=E,exports.useCart=et,exports.useCartContext=at,exports.useLocalization=Wr,exports.useModifierSelection=Gr,exports.useModifiers=wa,exports.useMultipleProductDetails=dl,exports.useOrganization=pe,exports.useProductDetails=ll;
2
+ "use strict";const e=require("react/jsx-runtime"),A=require("@tanstack/react-query"),Dr=require("next-themes"),h=require("react"),Q=require("react-hot-toast"),Ta=require("better-auth/client/plugins"),Fr=require("better-auth/react"),L=require("react-hook-form"),v=require("lucide-react"),Rr=require("@vercel/blob/client"),xe=require("next/image.js"),Te=require("use-debounce"),w=require("classnames"),Gi=require("use-mask-input"),Xe=require("@headlessui/react"),D=require("next/link.js"),z=require("@remixicon/react"),S=require("next/navigation.js"),ce=require("@hookform/resolvers/zod"),T=require("date-fns"),Ki=require("@shophost/client"),d=require("@hono/zod-openapi"),Ft=require("@radix-ui/react-slot"),Se=require("tailwind-variants"),Pr=require("clsx"),Mr=require("tailwind-merge"),Xi=require("@radix-ui/react-label"),_=require("recharts"),se=require("@internationalized/date"),Yi=require("@radix-ui/react-popover"),Br=require("@react-aria/datepicker"),en=require("@react-stately/datepicker"),an=require("date-fns/locale"),fa=require("react-day-picker"),$=require("cmdk"),tn=require("@radix-ui/react-dialog"),rn=require("react-phone-number-input"),Tr=require("react-phone-number-input/flags"),sn=require("@radix-ui/react-switch"),nn=require("@radix-ui/react-radio-group"),on=require("tailwindcss/colors"),ln=require("@radix-ui/react-navigation-menu"),fe=require("@tanstack/react-table"),dn=require("@radix-ui/react-checkbox"),cn=require("@radix-ui/react-dropdown-menu"),mn=require("@radix-ui/react-select"),ha=require("zod");function Ae(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 C=Ae(h),Qr=Ae(Xi),K=Ae(Yi),G=Ae(tn),Xa=Ae(rn),Qa=Ae(sn),Rt=Ae(nn),Oa=Ae(ln),cr=Ae(dn),de=Ae(cn),ee=Ae(mn),ae=new A.QueryClient({defaultOptions:{queries:{retry:!1,refetchInterval:!1,refetchOnWindowFocus:!1}}}),Or=h.createContext(null),Pt=({baseUrl:a,children:t})=>{const r=h.useMemo(()=>Ki.initClient({baseUrl:a,throwOnUnknownStatus:!0,baseHeaders:{},credentials:"include"}),[a]);return e.jsx(Or.Provider,{value:{client:r,baseUrl:a},children:t})},E=()=>{const a=h.useContext(Or);if(!a)throw new Error("useAPI must be used within a APIProvider");return a},Lr=h.createContext(null),un=({client:a,children:t})=>e.jsx(Lr.Provider,{value:a,children:t});function ja(){const a=h.useContext(Lr);if(!a)throw new Error("useAdminAuth must be used within AdminProvider");return a}const Jr=h.createContext(null),pn=({config:a,children:t})=>e.jsx(Jr.Provider,{value:a,children:t});function Vr(){const a=h.useContext(Jr);if(!a)throw new Error("useAdminConfig must be used within AdminProvider");return a}const Hr=h.createContext(null),gn=({routes:a,children:t})=>e.jsx(Hr.Provider,{value:a,children:t});function Z(){const a=h.useContext(Hr);if(!a)throw new Error("useAdminRoutes must be used within AdminProvider");return a}function qr(a){return Fr.createAuthClient({baseURL:a,plugins:[Ta.inferAdditionalFields(),Ta.organizationClient()]})}const At=new Map;function Ur(a){return At.has(a)||At.set(a,qr(a)),At.get(a)}function Zr(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 hn({config:a,children:t}){const r=h.useMemo(()=>Ur(a.apiBaseUrl),[a.apiBaseUrl]),s=h.useMemo(()=>Zr(a.basePath),[a.basePath]);return e.jsx(A.QueryClientProvider,{client:ae,children:e.jsxs("div",{className:"shophost-admin",children:[e.jsx(Dr.ThemeProvider,{defaultTheme:"light",attribute:"class",children:e.jsx(Pt,{baseUrl:a.apiBaseUrl,children:e.jsx(un,{client:r,children:e.jsx(pn,{config:a,children:e.jsx(gn,{routes:s,children:t})})})})}),e.jsx(Q.Toaster,{})]})})}const mr="shophost-cart",xn={items:[],isInitialized:!1,modifierModal:null,totalAmount:0,itemCount:0,removedItemsAlert:!1},fn=(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),ue=(a,t="USD",r="en-US")=>new Intl.NumberFormat(r,{style:"currency",currency:t}).format(a),yn=(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(y=>y&&y.id===g.id);if(!x)return"";const f=x.title||"",j=g.quantity||1;return j>1?`${f} (${j})`:f}).filter(Boolean).join(", ");return o?`${o}: ${l}`:l}).filter(Boolean).join(" | ")},bn=(a,t,r)=>a.find(s=>Ya(s,{productId:t,modifierGroups:r})),Ya=(a,t)=>{if(a.productId!==t.productId)return!1;const r=t.modifierGroups??[],s=a.modifierGroups??[];return r.length===0?s.length===0:jn(s,r)},jn=(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})},wn=a=>!a.modifierGroups||a.modifierGroups.length===0?!1:a.modifierGroups.some(t=>t.selectMin>0),kn=(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}},We=a=>a.reduce((t,r)=>t+(r.quantity||1),0),vn=(a,t)=>a.findIndex(r=>Ya(r,{productId:t.productId,modifierGroups:t.modifierGroups})),Nn=(a,t,r)=>a.map(s=>Ya(s,t)?{...s,quantity:r}:s),An=(a,t)=>a.filter(r=>!Ya(r,t)),Cn=(a,t)=>{const r=vn(a,t);return r===-1?[...a,t]:a.map((s,i)=>i===r?{...s,quantity:(s.quantity||1)+(t.quantity||1)}:s)},Sn=(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}),$r=(a,t)=>{switch(t.type){case"INITIALIZE_CART":{const r=t.payload;return{...a,items:r,itemCount:We(r)}}case"SET_INITIALIZED":return{...a,isInitialized:t.payload};case"ADD_ITEM":{const r=Cn(a.items,t.payload);return{...a,items:r,itemCount:We(r)}}case"UPDATE_ITEM_QUANTITY":{const{productId:r,quantity:s,modifierGroups:i}=t.payload;if(s<=0)return $r(a,{type:"REMOVE_ITEM",payload:{productId:r,modifierGroups:i}});const n=Nn(a.items,{productId:r,modifierGroups:i},s);return{...a,items:n,itemCount:We(n)}}case"REMOVE_ITEM":{const r=An(a.items,t.payload);return{...a,items:r,itemCount:We(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?Sn(l,c):!1}),o=n.length<i;return{...a,items:n,itemCount:We(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:We(s)}}default:return a}};function _r(a,t,r,s){const i=Number(t.discountedBasePrice??t.basePrice??0),n=ue((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(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:ue(i,r,s),quantity:a.quantity||1}}const Wr=h.createContext(void 0),zn=({children:a,initialOrganization:t,organizationId:r})=>{const{client:s}=E(),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(Wr.Provider,{value:{organizationId:r,loading:i.isLoading,organization:i.data,error:i.error},children:a})},pe=()=>{const a=h.useContext(Wr);if(a===void 0)throw new Error("useOrganization must be used within a OrganizationProvider");return a},Mt=h.createContext(void 0),Gr=({children:a,locale:t="en",organizationId:r})=>{const{organization:s}=pe(),i=s==null?void 0:s.configuration.defaultCurrency,{client:n}=E(),[o,l]=h.useState(null),[c,m]=h.useState(null),[{items:u,isInitialized:p,modifierModal:g,totalAmount:x,itemCount:f,removedItemsAlert:j},y]=h.useReducer($r,xn),b=g!==null,k=(g==null?void 0:g.product)??null,N=(g==null?void 0:g.quantity)??1,R=g==null?void 0:g.onAdded,O=h.useMemo(()=>[...new Set(u.map(M=>M.productId))],[u]),{data:F,isLoading:q,isRefetching:te}=A.useQuery({queryKey:["cartProducts",O,f,c==null?void 0:c.id],queryFn:async()=>{if(O.length===0)return{products:{},total:0,subtotal:0,invalidProductIds:[]};const M=await n.cart.getCartData({params:{organizationId:r},query:{locale:t},body:{items:u,shippingMethodId:c==null?void 0:c.id}});if(M.status!==200)throw new Error("Failed to fetch product data");return M.body},placeholderData:A.keepPreviousData,enabled:O.length>0});h.useEffect(()=>{var M;F&&((M=F.invalidProductIds)==null?void 0:M.length)>0&&(y({type:"REMOVE_INVALID_PRODUCTS",payload:{invalidProductIds:F.invalidProductIds}}),alert("Some items have been removed from your cart because they are no longer available or their options have changed."))},[F,te,u.length]),h.useEffect(()=>{(()=>{const M=localStorage.getItem(mr);if(M)try{const U=JSON.parse(M);y({type:"INITIALIZE_CART",payload:U})}catch(U){console.error("Failed to parse cart from localStorage:",U)}y({type:"SET_INITIALIZED",payload:!0})})()},[]),h.useEffect(()=>{p&&localStorage.setItem(mr,JSON.stringify(u))},[u,p]),h.useEffect(()=>{u.length>0&&F&&y({type:"UPDATE_TOTALS",payload:{productsData:F.products}})},[u,F]);const P=h.useCallback(M=>{y({type:"ADD_ITEM",payload:M})},[]),H=h.useCallback((M,U,Nt)=>{y({type:"UPDATE_ITEM_QUANTITY",payload:{productId:M,quantity:U,modifierGroups:Nt}})},[]),je=h.useCallback((M,U)=>{y({type:"REMOVE_ITEM",payload:{productId:M,modifierGroups:U}})},[]),ua=h.useCallback(()=>{y({type:"CLEAR_CART"})},[]),Ca=h.useCallback(()=>{console.log("Checkout clicked, implement onCheckout handler")},[]),pa=h.useCallback((M,U)=>{const Nt={product:M,quantity:(U==null?void 0:U.quantity)??1,onAdded:U==null?void 0:U.onAdded};y({type:"OPEN_MODIFIERS_MODAL",payload:Nt})},[]),ga=h.useCallback(()=>{y({type:"CLOSE_MODIFIERS_MODAL"})},[]),Sa=h.useMemo(()=>F!=null&&F.products?u.map(M=>{const U=F.products[M.productId];return U?_r(M,U,i??"USD",t):null}).filter(M=>M!==null):[],[u,F==null?void 0:F.products,i,t]),re=h.useMemo(()=>({locale:t,organizationId:r,items:u,total:(F==null?void 0:F.total)??0,shipping:F==null?void 0:F.shipping,subtotal:(F==null?void 0:F.subtotal)??0,products:(F==null?void 0:F.products)||{},addItem:P,removeItem:je,updateItemQuantity:H,clearCart:ua,itemCount:f,totalAmount:x,onCheckoutClick:Ca,openModifiersModal:pa,closeModifiersModal:ga,modifierModal:g,isModifiersModalOpen:b,selectedProduct:k,pendingModalQuantity:N,onModalAddToCart:R,isProductsLoading:q,paymentMethod:o,setPaymentMethod:l,shippingMethod:c,setShippingMethod:m,formattedCartItems:Sa}),[t,r,u,P,je,H,ua,f,x,Ca,pa,ga,g,b,k,N,R,F,q,o,l,c,m,Sa]);return e.jsx(Mt.Provider,{value:re,children:a})},et=()=>{const a=h.useContext(Mt),{client:t}=E();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 f;const g=(j=m??[])=>(a.addItem({productId:l,quantity:c,modifierGroups:j}),p==null||p(),{openedModifiers:!1});if(m!=null&&m.length)return g(m);const x=await r(l,u);return(f=x.modifierGroups)!=null&&f.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}},at=()=>{const a=h.useContext(Mt);if(a===void 0)throw new Error("useCart must be used within a CartProvider");return a},Kr=(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}},In=a=>a.map(t=>({groupId:t.id,modifierIds:[]})),ur=(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)},Xr=(a=[])=>{const[t,r]=h.useState([]),[s,i]=h.useState(null);h.useEffect(()=>{r(In(a)),i(null)},[a]);const n=h.useCallback((p,g)=>{r(x=>ur(x,p,f=>f.includes(g)?f.filter(j=>j!==g):[...f,g])),i(null)},[]),o=h.useCallback((p,g)=>{r(x=>ur(x,p,()=>[g])),i(null)},[]),l=h.useCallback((p,g)=>{const x=t.find(f=>f.groupId===p);return x?x.modifierIds.includes(g):!1},[t]),c=h.useCallback(()=>{const p=kn(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}},Yr=h.createContext(null),es=({children:a,locale:t="en"})=>{const{modifierModal:r,closeModifiersModal:s,addItem:i}=at(),n=(r==null?void 0:r.product)??null,o=h.useMemo(()=>(n==null?void 0:n.modifierGroups)??[],[n]),[l,c]=h.useState(1),{toggleModifier:m,selectModifier:u,isModifierSelected:p,validateSelections:g,validationError:x,getCartModifierGroups:f}=Xr(o),{getProductName:j,getModifierGroupName:y}=Kr(t);h.useEffect(()=>{c((r==null?void 0:r.quantity)??1)},[r]);const b=h.useCallback(()=>{c(P=>P+1)},[]),k=h.useCallback(()=>{c(P=>P>1?P-1:1)},[]),N=h.useCallback(()=>{var P;!n||!g()||(i({productId:n.id,quantity:l,modifierGroups:f()}),c(1),s(),(P=r==null?void 0:r.onAdded)==null||P.call(r))},[i,s,f,r,n,l,g]),R=o.length>0,O=h.useMemo(()=>n?"title"in n?n.title??"":j(n,""):"",[j,n]),F=h.useCallback(P=>P.selectMax>1||P.selectMax===0,[]),q=h.useCallback((P,H)=>P.price>0?` (+${ue(P.price,H,t)})`:"",[t]),te={isOpen:r!==null,onClose:s,product:n,productName:O,hasModifiers:R,quantity:l,handleIncrement:b,handleDecrement:k,handleAddToCart:N,validationError:x,modifierGroups:o,isModifierSelected:p,isMultiSelect:F,toggleModifier:m,selectModifier:u,getModifierGroupName:y,formatModifierPrice:q,locale:t};return e.jsx(Yr.Provider,{value:te,children:a})},wa=()=>{const a=h.useContext(Yr);if(!a)throw new Error("useModifiers must be used within a ModifiersProvider");return a},as=({className:a,emptyCartComponent:t,renderItem:r,loadingComponent:s})=>{const{organization:i}=pe(),{locale:n,items:o,removeItem:l,updateItemQuantity:c,products:m,isProductsLoading:u}=at();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=()=>l(p.productId,p.modifierGroups),f=y=>c(p.productId,y,p.modifierGroups),j=_r(p,g,i.configuration.defaultCurrency,n);return e.jsx(h.Fragment,{children:r({...j,remove:x,updateQuantity:f})},`${p.productId}-${JSON.stringify(p.modifierGroups)}`)})})},ts=({title:a,subtitle:t,image:r,price:s,quantity:i,remove:n,updateQuantity:o})=>{const[l,c]=h.useState(String(i));h.useEffect(()=>{c(String(i))},[i]);const m=h.useCallback(()=>{const u=Number.parseInt(l,10);if(Number.isNaN(u)){c(String(i));return}if(u<=0){n();return}o(u)},[l,i,n,o]);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(xe,{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?n():o(Math.max(1,i-1)),"aria-label":"Decrease quantity",children:"-"}),e.jsx("input",{type:"number",min:1,step:1,inputMode:"numeric",value:l,onChange:u=>{const p=u.target.value;(p===""||/^[0-9]+$/.test(p))&&c(p)},onBlur:m,onKeyDown:u=>{u.key==="Enter"&&u.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:()=>o(i+1),"aria-label":"Increase quantity",children:"+"})]})})]})]})})},En=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"})]})}),Dn=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"})]}),Fn=a=>e.jsx(ts,{...a}),rs=({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=Dn,loadingComponent:m=En,renderFooter:u,renderHeader:p,renderItem:g=Fn})=>{const{itemCount:x,total:f,locale:j}=at(),{organization:y}=pe(),b=(y==null?void 0:y.configuration.defaultCurrency)??"USD",k=ue(f,b,j),N={checkoutHref:a,checkoutLabel:t,close:o??(()=>{}),formattedTotal:k,itemCount:x,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(z.RiCloseLine,{className:"h-5 w-5"})})]}),e.jsx("div",{className:i,children:e.jsx(as,{renderItem:R=>g(R),loadingComponent:m,emptyCartComponent:c})}),x>0&&(u?u(N):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:k}),e.jsx(D,{href:a,className:"storefront-primary-action btn text-sm rounded-lg w-full",onClick:o,children:t})]}))]})},Rn=({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),[f,j]=h.useState(null),y=50,b=R=>{j(null),x(R.targetTouches[0].clientY)},k=R=>{j(R.targetTouches[0].clientY)},N=()=>{!g||!f||(f-g>y&&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(Xe.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: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:b,onTouchMove:k,onTouchEnd:N,children:e.jsx(rs,{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})})})})]})},Pn=[{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"}],tt=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."}),zt=d.z.enum(["delivery","pickup"]),Mn=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 Bn=d.z.object({from:d.z.date(),to:d.z.date()}).openapi("AnalyticsRange"),Tn=d.z.object({currency:tt,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"),Qn=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"),On=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"),Ln=d.z.object({method:Mn,count:d.z.number().int().min(0),totalSales:d.z.number().min(0)}).openapi("PaymentMethodBreakdownItem"),Jn=d.z.object({method:zt,count:d.z.number().int().min(0),totalSales:d.z.number().min(0)}).openapi("FulfilmentBreakdownItem");d.z.object({range:Bn,summary:Tn,salesByDay:d.z.array(Qn),reservationsByDay:d.z.array(On),paymentMethods:d.z.array(Ln),fulfilmentMethods:d.z.array(Jn)}).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 Vn=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"),Hn=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 ta=(...a)=>(t,r)=>{const{translations:s,defaultLocale:i}=t,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]})})},rt=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"]]),pr=Array.from(rt.entries()).map(([a,t])=>({value:a,label:t})),Re=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"}),ss=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"})),La=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"}),qn=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()})}),Un=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",[qn,Un]),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 Qe=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"),st=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:Qe.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");st.omit({translations:!0}).extend({title:d.z.string().default(""),description:d.z.string().default("")}).openapi("LocalizedProductCategory");const Zn=st.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(ta("title")).openapi("CreateProductCategory"),$n=st.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(ta("title")).openapi("UpdateProductCategory"),is=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"),ns=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:Re.optional(),modifiers:d.z.array(is).optional().openapi({}),translations:d.z.array(d.z.object({locale:Re,title:d.z.string().optional().openapi({example:"Size",description:"Title of the modifier group"})}))}).openapi("ModifierGroup"),_n=ns.extend({title:d.z.string().default("").nullable()}).omit({translations:!0}).openapi("LocalizedModifierGroup"),os=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:Re.optional(),modifiers:d.z.array(is).optional().openapi({}),translations:d.z.array(d.z.object({locale:Re,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(ta("title")).openapi("CreateOrUpdateModifierGroup"),ls=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"}),basePrice:La,discountedBasePrice:ss,currency:d.z.string().openapi({example:"USD",description:"Currency code for pricing"}),images:d.z.array(Qe).optional().openapi({description:"List of product images"}),modifierGroups:d.z.array(ns).optional().openapi({description:"List of product modifier groups"}),categories:d.z.array(st).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:Re,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"),Wn=ls.extend({title:d.z.string().default(""),description:d.z.string().nullable().default(""),modifierGroups:d.z.array(_n),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"),ds=ls.pick({slug:!0,sku:!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(os).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"})}),Gn=ds.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"}),ta("title")(a,t))).openapi("CreateProduct"),Kn=ds.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"}),ta("title")(a,t))).openapi("UpdateProduct");d.z.record(d.z.string().openapi({example:"clf9876543210abcdef",description:"ID of the product in the cart"}),Wn);const cs=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"),Xn=d.z.object({items:d.z.array(cs),shippingMethodId:d.z.string().cuid().optional()});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 Yn=d.z.string().min(1).openapi({example:"stripe",description:"Integration type key"}),Bt=d.z.enum(["card","blik"]).openapi({example:"card",description:"Stripe payment method"});d.z.object({paymentMethods:d.z.array(Bt).max(2).optional(),secretKey:d.z.string().trim().min(1).optional(),webhookSecret:d.z.string().trim().min(1).optional()}).strict();const it=d.z.object({paymentMethods:d.z.array(Bt).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"),eo=d.z.object({paymentMethods:d.z.array(Bt).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"),ao=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:Yn,config:ao.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"),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:Re.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 ra=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"),nt=ra.pick({addressLineOne:!0,doorNumber:!0,addressLineTwo:!0,zipCode:!0,city:!0,country:!0,placeId:!0}).openapi("CreateAddress"),ms=nt.partial().openapi("UpdateAddress"),to=ra.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"})}),us=to.pick({firstname:!0,lastname:!0,phone:!0,addressLineOne:!0,addressLineTwo:!0,doorNumber:!0,zipCode:!0,city:!0,country:!0,placeId:!0,deliveryInstructions:!0});us.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 Tt=d.z.enum(["card","blik","cash_on_delivery","paypal"]).openapi({description:"The payment method",example:"card"}),Qt=d.z.enum(["stripe","revolut","payu","not_applicable"]).openapi({description:"The payment method",example:"card"}),ro=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:Qt,method:Tt,description:d.z.string().min(1)}).openapi({description:"The payment method",example:{provider:"stripe",type:"card"}});const so=d.z.object({id:d.z.string().cuid().min(1),method:Tt,provider:Qt,status:ro,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:tt}),gr=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:La.openapi({example:10,description:"Ending distance for the shipping zone"}),price:La.openapi({example:5.99,description:"Price for shipping in this zone"}),minimumOrderAmount:ss.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"),ps=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:Qe.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(gr).openapi({description:"List of shipping zones for this shipping method"}),eligibleShippingZone:gr.optional(),createdAt:d.z.date(),updatedAt:d.z.date()}).openapi("ShippingMethod"),gs=ps.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"),io=gs.partial().openapi("UpdateShippingMethod"),no=d.z.enum(["draft","pending","accepted","ready-for-dispatch","dispatched","completed","cancelled"]).openapi({description:"Status of the order",example:"accepted"}),oo=d.z.object({translations:d.z.array(d.z.object({locale:Re.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:cs,unitPrice:d.z.number().min(0).openapi({description:"Price per unit of the item",example:299.99}),image:Qe.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");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:no.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(oo).min(1).openapi({description:"Array of items in the order"}),shippingMethod:ps.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"}),shippingAddress:ra.nullable().optional(),fulfilmentMethod:zt.openapi({description:"Method of order fulfilment (pickup or delivery)",example:"delivery"}),currency:tt.openapi({description:"Currency used for the order",example:"USD"}),payment:so}).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"),Xn.extend({fulfilmentMethod:zt.default("delivery"),payment:d.z.object({provider:Qt,method:Tt}),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 hr=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"),hs=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:Re,supportedLocales:d.z.array(Re).openapi({description:"List of supported locales for the organization"}),openingTimes:hr.optional(),closingTimes:hr.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:tt.openapi({example:"USD",description:"Default currency for the organization"}),createdAt:d.z.date().openapi({description:"Timestamp when the organization configuration was created"})}).openapi("OrganizationConfiguration"),lo=hs.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"),co=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:ra,configuration:hs.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:Qe.optional().nullable().openapi({description:"The logo of the organization"})}).openapi("Organization"),xs=co.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:nt}).openapi("CreateOrganization"),Ot=xs.extend({address:ms,configuration:lo}).partial().openapi("UpdateOrganization"),mo=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:Qe.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");mo.omit({translations:!0}).extend({about:d.z.string().nullable().optional().default("")}).openapi("LocalizedManufacturer");const uo=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:Qe.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(ta("about")).openapi("CreateManufacturer"),po=d.z.object({name:d.z.string().min(1,"Name is required").optional().openapi({example:"Apple Inc. Updated",description:"Name of the manufacturer"}),logo:Qe.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:ra.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:nt.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:ms.required().openapi({description:"The address of the legal entity"})}).openapi("UpdateLegalEntity");const go=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:ra.nullable().optional().openapi({description:"Address of the customer"}),createdAt:d.z.date(),updatedAt:d.z.date()}).openapi("Customer"),ho=go.pick({firstname:!0,email:!0,phone:!0}).extend({address:nt}).openapi("Customer");ho.partial().openapi("UpdateCustomer");const Lt=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"),fs=Lt.pick({email:!0,password:!0}).openapi("SignIn"),xo=d.z.object({organizationId:d.z.string().cuid().min(1,"organizationId is required").openapi({example:"ckel0e8qw00004n5p5w6fznym",description:"The organization ID"})}).openapi("OrganizationParams");xo.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 Ct=a=>d.z.any().transform(t=>typeof t=="string"?t.trim():"").refine(t=>t.length>0,{message:`${a} is required`}),fo=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"}),yo=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"}),bo=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:La,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"),jo=bo.pick({firstname:!0,lastname:!0,guests:!0,phone:!0,date:!0}).extend({firstname:Ct("First name").openapi({description:"Customer's first name",example:"John"}),lastname:Ct("Last name").openapi({description:"Customer's last name",example:"Doe"}),guests:fo.openapi({description:"Number of guests included in the reservation",example:2}),phone:Ct("Phone number").openapi({description:"Customer's phone number",example:"+1234567890"}),date:yo.openapi({description:"Reservation date and time",example:"2023-06-14T16:20:00Z"})}).openapi("CreateReservation");function $e(...a){return Mr.twMerge(Pr(...a))}const ys=["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"],wo=["ring-2","border-red-500 dark:border-red-700","ring-red-200 dark:ring-red-700/30"],bs=Se.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"}}),W=h.forwardRef(({asChild:a,isLoading:t=!1,loadingText:r,className:s,disabled:i,variant:n,children:o,...l},c)=>{const m=a?Ft.Slot:"button";return e.jsx(m,{ref:c,className:w(bs({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(z.RiLoader2Fill,{className:"size-4 shrink-0 animate-spin","aria-hidden":"true"}),e.jsx("span",{className:"sr-only",children:r||"Loading"}),r||"Loading"]}):o})});W.displayName="Button";const xr=[{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:"🇪🇹"}]}],ka=a=>e.jsx(G.Root,{...a});ka.displayName="Dialog";const js=G.Trigger;js.displayName="DialogTrigger";const ws=G.Close;ws.displayName="DialogClose";const ks=G.Portal;ks.displayName="DialogPortal";const vs=h.forwardRef(({className:a,...t},r)=>e.jsx(G.Overlay,{ref:r,className:w("fixed inset-0 z-50 overflow-y-auto","bg-black/70","data-[state=open]:animate-dialogOverlayShow",a),...t}));vs.displayName="DialogOverlay";const va=h.forwardRef(({className:a,...t},r)=>e.jsx(ks,{children:e.jsx(vs,{children:e.jsx(G.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",sa,a),...t})})}));va.displayName="DialogContent";const Jt=({className:a,...t})=>e.jsx("div",{className:w("flex flex-col gap-y-1",a),...t});Jt.displayName="DialogHeader";const ot=h.forwardRef(({className:a,...t},r)=>e.jsx(G.Title,{ref:r,className:w("text-lg font-semibold","text-gray-900 dark:text-gray-50",a),...t}));ot.displayName="DialogTitle";const Ns=h.forwardRef(({className:a,...t},r)=>e.jsx(G.Description,{ref:r,className:w("text-gray-500 dark:text-gray-500",a),...t}));Ns.displayName="DialogDescription";const As=({className:a,...t})=>e.jsx("div",{className:w("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...t});As.displayName="DialogFooter";const Na=C.forwardRef(({className:a,...t},r)=>e.jsx($.Command,{ref:r,className:w("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",a),...t}));Na.displayName=$.Command.displayName;const ko=({children:a,...t})=>e.jsx(ka,{...t,children:e.jsx(va,{className:"overflow-hidden p-0",children:e.jsx(Na,{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})})}),lt=C.forwardRef(({className:a,...t},r)=>e.jsxs("div",{className:"flex items-center border-b pl-3","cmdk-input-wrapper":"",children:[e.jsx(v.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx($.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})]}));lt.displayName=$.Command.Input.displayName;const dt=C.forwardRef(({className:a,...t},r)=>e.jsx($.Command.List,{ref:r,className:w("max-h-[300px] overflow-y-auto overflow-x-hidden",a),...t}));dt.displayName=$.Command.List.displayName;const ct=C.forwardRef((a,t)=>e.jsx($.Command.Empty,{ref:t,className:"py-6 text-center text-sm",...a}));ct.displayName=$.Command.Empty.displayName;const mt=C.forwardRef(({className:a,...t},r)=>e.jsx($.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}));mt.displayName=$.Command.Group.displayName;const Cs=C.forwardRef(({className:a,...t},r)=>e.jsx($.Command.Separator,{ref:r,className:w("-mx-1 h-px bg-border",a),...t}));Cs.displayName=$.Command.Separator.displayName;const ut=C.forwardRef(({className:a,...t},r)=>e.jsx($.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}));ut.displayName=$.Command.Item.displayName;const Ss=({className:a,...t})=>e.jsx("span",{className:w("ml-auto text-xs tracking-widest text-muted-foreground",a),...t});Ss.displayName="CommandShortcut";const ia=a=>e.jsx(K.Root,{...a});ia.displayName="Popover";const na=C.forwardRef((a,t)=>e.jsx(K.Trigger,{ref:t,...a}));na.displayName="PopoverTrigger";const zs=C.forwardRef((a,t)=>e.jsx(K.Anchor,{ref:t,...a}));zs.displayName="PopoverAnchor";const Is=C.forwardRef((a,t)=>e.jsx(K.Close,{ref:t,...a}));Is.displayName="PopoverClose";const oa=C.forwardRef(({className:a,sideOffset:t=10,side:r="bottom",align:s="center",collisionPadding:i,...n},o)=>e.jsx(K.Portal,{children:e.jsx(K.Content,{ref:o,sideOffset:t,side:r,align:s,collisionPadding:i,avoidCollisions:!0,className:$e("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})}));oa.displayName="PopoverContent";const Es=({value:a,onChange:t,disabled:r})=>{const s=h.useId(),[i,n]=h.useState(!1),o=xr.map(l=>l.items.find(c=>c.value===a)).filter(Boolean)[0];return e.jsx("div",{className:"mt-2",children:e.jsxs(ia,{open:r?!1:i,onOpenChange:r?void 0:n,children:[e.jsx(na,{asChild:!0,children:e.jsxs(W,{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(v.ChevronDown,{size:16,strokeWidth:2,className:"shrink-0 text-muted-foreground/80","aria-hidden":"true"})]})}),e.jsx(oa,{className:"w-full min-w-[var(--radix-popper-anchor-width)] border-input -mt-1 z-50",align:"start",children:e.jsxs(Na,{className:"p-0",children:[e.jsx(lt,{className:"w-full border-none",style:{boxShadow:"none"},placeholder:"Search country..."}),e.jsxs(dt,{children:[e.jsx(ct,{children:"No country found."}),xr.map(l=>e.jsx(h.Fragment,{children:e.jsx(mt,{heading:l.continent,children:l.items.map(c=>e.jsxs(ut,{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(v.Check,{size:16,strokeWidth:2,className:"ml-auto"})]},c.value))})},l.continent))]})]})})]})})},vo=Se.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",ys],variants:{hasError:{true:wo},enableStepper:{false:"[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none"},multiline:{true:"resize-y min-h-[100px]",false:"truncate appearance-none"}}}),ve=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,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(vo({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(z.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",{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(z.RiEyeFill,{className:"size-5"}):e.jsx(z.RiEyeOffFill,{className:"size-5"})})})]})});ve.displayName="Input";const Ds=({...a})=>{const t=h.useId();return e.jsx("div",{className:"mt-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(ve,{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(v.MailIcon,{size:16})})]})})},Fs=a=>{const{client:t}=E(),[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 Rr.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: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(v.XIcon,{className:"w-4 h-4 text-white"})}),e.jsx(xe,{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(v.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(v.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()})},pt=({value:a,onChange:t,placeholder:r="Search for a place"})=>{const{client:s}=E(),i=h.useId(),[n,o]=h.useState(!1),[l,c]=h.useState(""),[m,u]=h.useState(null),p=h.useRef(null),[g]=Te.useDebounce(l,300);h.useEffect(()=>{a&&(m==null?void 0:m.text)!==a&&c(a)},[a,m]);const{data:x=[],error:f,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}),y=b=>{u(b),c(b.text);const k={placeId:b.placeId,text:b.text,addressLineOne:b.addressLineOne,addressLineTwo:b.addressLineTwo};t(k),o(!1)};return h.useEffect(()=>{n&&p.current&&p.current.focus()},[n]),e.jsxs("div",{className:"mt-2 relative",children:[e.jsxs(ia,{open:n,onOpenChange:o,children:[e.jsx(na,{asChild:!0,children:e.jsxs(W,{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(v.ChevronDown,{size:16,strokeWidth:2,className:"shrink-0 text-muted-foreground/80","aria-hidden":"true"})]})}),e.jsxs(oa,{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(v.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(v.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,k)=>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(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(v.Check,{size:16,strokeWidth:2,className:"ml-auto"})]},`${b.placeId||"place"}-${k}`))]})]})]})]}),f&&e.jsxs("p",{className:"text-xs text-red-500 mt-1",children:["Error fetching results: ",f.message]})]})},Rs=h.forwardRef(({...a},t)=>e.jsx(ve,{...a,inputClassName:"border-l-0 rounded-l-none",ref:t,className:""}));Rs.displayName="PhoneInput";const No=({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(Ps,{country:t,countryName:t,"aria-hidden":"true"}),e.jsx("span",{className:"text-muted-foreground/80",children:e.jsx(v.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&&`+${Xa.getCountryCallingCode(n.value)}`]},n.value??`empty-${o}`))]})]})},Ps=({country:a,countryName:t})=>{const r=Tr[a];return e.jsx("span",{className:"w-5 overflow-hidden rounded-xs",children:r?e.jsx(r,{title:t}):e.jsx(v.Phone,{size:16,"aria-hidden":"true"})})},Ms=({value:a,onChange:t,onBlur:r})=>{const s=h.useId();return e.jsx("div",{className:"mt-2",children:e.jsx(Xa.default,{id:s,className:"flex rounded-lg shadow-2xs shadow-black/5",international:!0,flagComponent:Ps,countrySelectComponent:No,inputComponent:Rs,placeholder:"Enter phone number",value:a,onChange:i=>t(i??""),onBlur:r})})},Bs=({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(ia,{open:o,onOpenChange:l,children:[e.jsx(na,{asChild:!0,children:e.jsxs(W,{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(v.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(v.ChevronDown,{size:16,strokeWidth:2,className:"shrink-0 text-muted-foreground/80","aria-hidden":"true"})]})}),e.jsx(oa,{className:"w-full min-w-[var(--radix-popper-anchor-width)] border-input -mt-1 z-50 p-0",align:"start",children:e.jsxs(Na,{className:"p-0",children:[e.jsx(lt,{className:"w-full border-none pl-0",style:{boxShadow:"none"},placeholder:"Search..."}),e.jsxs(dt,{children:[e.jsx(ct,{children:"No options found."}),e.jsx(mt,{children:a.map(p=>e.jsxs(ut,{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(v.Check,{size:16,strokeWidth:2,className:"ml-auto"})]},p.value))})]})]})})]})})},Ao=Se.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"}}),Vt=h.forwardRef(({className:a,size:t,...r},s)=>{const{root:i,thumb:n}=Ao({size:t});return e.jsx(Qa.Root,{ref:s,className:w(i(),a),...r,children:e.jsx(Qa.Thumb,{className:w(n())})})});Vt.displayName="Switch";const Ts=h.forwardRef(({className:a,type:t,...r},s)=>e.jsx("input",{type:t,className:$e("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}));Ts.displayName="TextInput";function Ht({className:a,...t}){const r=h.useId();return e.jsx(Ts,{id:r,placeholder:"00:00",className:w(a,"mt-2"),ref:Gi.withMask("99:99",{placeholder:"-",showMaskOnHover:!1}),...t})}const ye=C.forwardRef(({className:a,disabled:t,...r},s)=>e.jsx(Qr.Root,{ref:s,className:$e("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}));ye.displayName="Label";const Co=({value:a,onChange:t,disabled:r})=>{const s=()=>{const y=new Date,b=new Date(y);return b.setMinutes(y.getMinutes()+30),b},i=h.useMemo(()=>{const y=[],b=new Date;for(let k=0;k<7;k++){const N=new Date(b);N.setDate(b.getDate()+k),N.setHours(0,0,0,0),y.push(N)}return y},[]),n=y=>{const b=s();if(y.toDateString()!==new Date().toDateString())return!0;if(b.getHours()>=21&&b.getMinutes()>0)return!1;for(let k=11;k<=21;k++){const N=new Date(y);if(N.setHours(k,0,0,0),N>b)return!0}return!1},o=y=>!n(y),l=h.useMemo(()=>i.find(y=>!o(y))||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 y=[],b=s(),k=c.toDateString()===new Date().toDateString();for(let N=11;N<=21;N++){const R=new Date(c);R.setHours(N,0,0,0),(!k||R>b)&&y.push(`${N}:00`)}return y},[c]),x=y=>{const b=y.toLocaleDateString("en-US",{weekday:"short"}),k=y.toLocaleDateString("en-US",{month:"short"}),N=y.getDate();return{weekday:b,month:k,day:N}},f=y=>{m(y),p(null)},j=y=>{if(p(y),c){const[b]=y.split(":").map(Number),k=new Date(c);k.setHours(b,0,0,0),t(k)}};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(ye,{htmlFor:"date",children:"Select Date"}),e.jsx("div",{className:"grid grid-cols-7 gap-2 mt-2",children:i.map((y,b)=>{const{weekday:k,month:N,day:R}=x(y),O=o(y);return e.jsx("button",{type:"button",disabled:O,className:`p-2 text-center border rounded-md ${O?"opacity-50 cursor-not-allowed":"cursor-pointer"} ${c&&c.toDateString()===y.toDateString()?"storefront-primary-action":"bg-white hover:bg-gray-100"}`,onClick:()=>!O&&f(y),children:e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("span",{className:"text-xs font-medium",children:k}),e.jsx("span",{className:"text-xl font-black font-red-hat-display",children:R}),e.jsx("span",{className:"text-xs font-medium",children:N})]})},b)})})]}),c&&g.length>0&&e.jsxs("div",{className:"col-span-4 mt-4",children:[e.jsx(ye,{htmlFor:"time",children:"Select Time"}),e.jsx("div",{className:"grid grid-cols-5 gap-2 mt-2",children:g.map((y,b)=>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:()=>j(y),children:y},b))})]})]})},Qs=({name:a,type:t,placeholder:r,multiple:s,options:i,disabled:n,prefix:o})=>{const{watch:l,register:c,setValue:m}=L.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(Ds,{...c(a),placeholder:r});case"file":return e.jsx(Fs,{value:l(a),multiple:s,onChange:g=>p(g)});case"week-time":return e.jsx(Co,{value:l(a),onChange:g=>p(g)});case"phone-number":return e.jsx(Ms,{value:l(a),onChange:g=>p(g)});case"country":return e.jsx(Es,{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(Bs,{options:i,value:g,onChange:x=>p(x),placeholder:r,multiple:s})}case"switch":return e.jsx(Vt,{size:"default",className:"mt-2",value:l(a),onCheckedChange:g=>p(g)});case"location":return e.jsx(pt,{value:l(a),onChange:g=>p(g.addressLineOne)});case"time":return e.jsx(Ht,{value:l(a),...c(a)});default:return e.jsx(ve,{...c(a),type:t,rows:t==="textarea"?4:void 0,placeholder:r,className:"mt-2",prefix:o})}},Os=(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,me=({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}=L.useFormState(),g=Os(p,t);return e.jsxs("div",{className:w("w-full",s),children:[typeof r=="string"&&e.jsxs(ye,{htmlFor:t,className:"font-medium flex items-center justify-between",children:[e.jsxs("span",{className:"flex items-center",children:[r,c&&e.jsx(v.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:[rt.get(i)," (",i,")"]})]}),e.jsx(Qs,{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})]})},Ls=({isOpen:a,onClose:t,children:r})=>e.jsx(Xe.Transition,{show:a,as:h.Fragment,children:e.jsx(Xe.Dialog,{as:"div",className:"fixed inset-0 overflow-hidden",onClose:t,children:e.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[e.jsx(Xe.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(Xe.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(Xe.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})})})})]})})}),So=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"),Js=({open:a=!1,onOpenChange:t,defaultOpen:r=!1,disableAutoFocus:s=!0,children:i})=>e.jsxs(K.Root,{open:a,onOpenChange:t,defaultOpen:r,children:[e.jsx(K.Anchor,{className:w("fixed inset-x-0 bottom-8 mx-auto flex w-fit items-center")}),e.jsx(K.Portal,{children:e.jsx(K.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})})]});Js.displayName="CommandBar";const Vs=C.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}));Vs.displayName="CommandBar.Value";const Hs=C.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}));Hs.displayName="CommandBarBar";const qs=C.forwardRef(({className:a,...t},r)=>e.jsx("div",{ref:r,className:w("h-4 w-px bg-gray-700",a),...t}));qs.displayName="CommandBar.Seperator";const Us=C.forwardRef(({className:a,type:t="button",label:r,action:s,shortcut:i,disabled:n,...o},l)=>(C.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:So,children:i.label?i.label.toUpperCase():i.shortcut.toUpperCase()})]})})));Us.displayName="CommandBar.Command";const Ja=C.forwardRef(({className:a,...t},r)=>e.jsx(Rt.Root,{ref:r,className:$e("grid gap-2",a),...t}));Ja.displayName="RadioCardGroup";const Va=C.forwardRef(({className:a,...t},r)=>e.jsx("div",{className:$e("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(Rt.Indicator,{ref:r,className:"flex items-center justify-center",...t,children:e.jsx("div",{className:$e("size size-1.5 shrink-0 rounded-full","bg-white","group-data-disabled:bg-gray-400 dark:group-data-disabled:bg-gray-500")})})}));Va.displayName="RadioCardGroupIndicator";const Ha=C.forwardRef(({className:a,children:t,...r},s)=>e.jsx(Rt.Item,{ref:s,className:$e("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",ys,a),...r,children:t}));Ha.displayName="RadioCardItem";const Zs=Se.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"}}),ea=h.forwardRef(({className:a,variant:t,...r},s)=>e.jsx("span",{ref:s,className:w(Zs({variant:t}),a),...r}));ea.displayName="Badge";const aa=h.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")})}));aa.displayName="Divider";const zo=({initialData:a,shippingAndPaymentPageUrl:t})=>{const{itemCount:r}=et(),s=S.useRouter(),{client:i}=E(),n=L.useForm({resolver:ce.zodResolver(us),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(L.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(me,{name:"firstname",label:"First Name",type:"text",className:"col-span-2",placeholder:"e.g. John"}),e.jsx(me,{name:"lastname",label:"Last Name",type:"text",className:"col-span-2",placeholder:"e.g. Doe"}),e.jsx(me,{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(ye,{htmlFor:"address.addressLineOne",className:"font-medium flex items-center justify-between",children:"Street Address"}),e.jsx(pt,{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(me,{name:"doorNumber",label:"Door Number",type:"text",className:"md:col-span-1 col-span-2",placeholder:"e.g. 123"}),e.jsx(me,{name:"zipCode",label:"Postal Code",type:"text",className:"col-span-2",placeholder:"e.g. 12345"}),e.jsx(me,{name:"city",label:"City",type:"text",className:"col-span-2",placeholder:"e.g. Kraków"}),e.jsx(me,{name:"country",label:"Country",type:"country",className:"col-span-2 md:col-span-4",disabled:!0}),e.jsx(me,{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(W,{variant:"secondary",className:"shadow-none",type:"button",onClick:()=>s.push("/"),children:"Back"}),e.jsx(W,{type:"submit",className:"shadow-none",isLoading:c.isPending||m.isPending,disabled:r===0,loadingText:"Saving...",children:"Save & Continue"})]})]})})})},Io=()=>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"})]}),It=({shippingAndPaymentPageUrl:a="/checkout/shipping-and-payment"})=>{const t=S.useRouter(),{client:r}=E(),{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(Io,{}):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(zo,{initialData:s??null,onSuccess:o,shippingAndPaymentPageUrl:a},s==null?void 0:s.id)]})},Eo=()=>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"})]})]}),Do=({shippingMethods:a,paymentMethods:t,customerDetailsPageUrl:r})=>{const s=S.useRouter(),{client:i,baseUrl:n}=E(),{organizationId:o}=pe(),{items:l,shippingMethod:c,paymentMethod:m,setPaymentMethod:u,setShippingMethod:p}=et(),g=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:f,status:j}=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(j!==201)throw new Error((f==null?void 0:f.message)??"Failed to create order");return f.redirectUrl&&(window.location.href=f.redirectUrl),f}}),x=()=>{g.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(Ja,{className:"flex flex-col gap-2",value:c==null?void 0:c.id,children:a.map(f=>e.jsx(Ha,{value:f.id,disabled:!f.eligibleShippingZone,onClick:()=>p(f),children:e.jsxs("div",{className:w("flex items-center gap-3",{"opacity-60 cursor-not-allowed":!f.eligibleShippingZone}),children:[e.jsx(Va,{}),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:[f.title," (",f.providerName,")"]}),!f.eligibleShippingZone&&e.jsx(ea,{variant:"error",children:"Not Available"})]}),f.eligibleShippingZone&&e.jsxs("p",{className:"text-xs font-medium text-gray-500 mt-0.5",children:["Shipping Fee: ",f.eligibleShippingZone.price," zł ",e.jsx("br",{}),"ETA: ",f.eligibleShippingZone.eta]}),!f.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."]})]})})]})},f.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(Ja,{className:"flex flex-col gap-3",value:m==null?void 0:m.id,children:t.map(f=>e.jsx(Ha,{value:f.id,onClick:()=>u(f),children:e.jsxs("div",{className:w("flex items-center gap-3"),children:[e.jsx(Va,{}),e.jsxs("div",{children:[e.jsx("p",{className:"font-red-hat-display font-black mr-2 capitalize",children:f.method}),e.jsxs("p",{className:"text-xs font-medium text-gray-500 capitalize",children:[f.provider," • ",f.description]})]})]})},f.id))}),g.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:g.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(D,{href:"/terms-and-conditions",className:"storefront-primary-text storefront-primary-text-hover mr-1",children:"Terms & Conditions"}),"and"," ",e.jsx(D,{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(W,{variant:"secondary",className:"shadow-none",onClick:()=>s.push(r),children:"Back"}),e.jsx(W,{className:"shadow-none",onClick:x,isLoading:g.isPending,children:"Pay & Confirm"})]})]})},$s=({customerDetailsPageUrl:a="/checkout/customer-details"})=>{const{client:t}=E(),{organizationId:r}=pe(),s=S.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(Eo,{}):e.jsx("div",{className:"flex flex-col gap-3 animate-fade-in",children:e.jsx(Do,{shippingMethods:n.data??[],paymentMethods:o.data??[],customerDetailsPageUrl:a})})},Fo=a=>Fr.createAuthClient({baseURL:a,plugins:[Ta.inferAdditionalFields(),Ta.organizationClient()]}),_s=h.createContext(void 0),Ro=({children:a,baseURL:t})=>{const r=h.useMemo(()=>Fo(t),[t]);return e.jsx(_s.Provider,{value:r,children:a})},ze=()=>{const a=h.useContext(_s);if(a===void 0)throw new Error("useAuth must be used within a AuthProvider");return a},Po=()=>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"})]})]}),qt=({loading:a=!1,items:t,total:r,subtotal:s,shipping:i,discount:n,currency:o})=>a?e.jsx(Po,{}):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(D,{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(xe,{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,j)=>e.jsx("div",{className:"text-white text-xs opacity-50",children:f},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:ue(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:ue(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:["- ",ue(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:ue(r,o)})]})]}),Mo=()=>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(v.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(v.ShoppingBasketIcon,{className:"w-5 h-5 text-gray-300"})]})]})]}),Bo=()=>{const a=S.useRouter(),{useSession:t,signOut:r}=ze(),{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(ia,{children:[e.jsx(na,{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(v.UserIcon,{className:"w-5 h-5 mr-1 group-hover:scale-110 transition-transform duration-200"}),e.jsx("span",{children:"Guest"})]})}),e.jsx(oa,{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(D,{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(v.LayoutDashboardIcon,{className:"h-4 w-4"}),"My account"]}),e.jsxs(D,{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(v.ShoppingBagIcon,{className:"h-4 w-4"}),"Orders"]}),e.jsxs(D,{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(v.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(v.LogOutIcon,{className:"h-4 w-4"}),"Logout"]})]}):e.jsxs(D,{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(v.UserIcon,{className:"h-4 w-4"}),"Sign in"]})})]})})},Aa=({summary:a})=>{const{organization:t,loading:r}=pe(),[s,i]=h.useState(!1);if(r)return e.jsx(Mo,{});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(D,{href:"/",className:"flex items-center",children:[e.jsx("span",{children:e.jsx(v.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(xe,{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(Bo,{})}),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(v.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:ue(a.total,l)}),e.jsx(v.ShoppingBasketIcon,{className:"w-5 h-5"})]},2)})]})]}),a&&e.jsx(Ls,{isOpen:s,onClose:()=>i(!1),children:e.jsx(qt,{total:a.total,items:a.items,shipping:a.shipping,subtotal:a.subtotal,currency:l})})]})},Ws=({children:a,description:t,title:r})=>{const s=r||t;return e.jsxs(e.Fragment,{children:[e.jsx(Aa,{}),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(xe,{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]})})]})})]})},fr=({children:a})=>{const{useSession:t}=ze(),r=S.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(Ws,{children:a})},He=({children:a})=>{const{useSession:t}=ze(),r=S.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},To={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"},Me=(a,t="Not available",r="MMM d, yyyy")=>{if(!a)return t;const s=new Date(a);return T.isValid(s)?T.format(s,r):t},Gs=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"}},Ks=a=>{switch(a){case"accepted":case"ready-for-dispatch":return"info";case"dispatched":case"completed":return"success";case"cancelled":return"danger";default:return"warning"}},Xs=a=>a.cancelledAt?"Cancelled":a.acceptedAt?"Confirmed":"Pending",Ys=a=>a.cancelledAt?"danger":a.acceptedAt?"success":"warning",Qo=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()},gt=({actions:a,children:t,description:r,eyebrow:s,title:i})=>e.jsxs(e.Fragment,{children:[e.jsx(Aa,{}),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})]})})})]}),Ye=({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]}),qa=({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",To[r],t),children:a}),Be=({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(W,{asChild:!0,children:e.jsx(D,{href:a,children:t})})}):null]}),Ut=({description:a="Loading your latest activity.",title:t})=>e.jsxs(gt,{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"})]})]}),Ua=({href:a,label:t})=>e.jsxs(D,{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(v.ArrowRightIcon,{className:"h-4 w-4"})]}),Oo=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(D,{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"})})]})]}),Lo=()=>{var p,g,x;const{client:a}=E(),{useSession:t}=ze(),{organization:r,organizationId:s}=pe(),{data:i}=t(),n=A.useQuery({queryKey:["account","orders",s],enabled:!!s&&!!(i!=null&&i.user),queryFn:async()=>{const{body:f,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 f}}),o=A.useQuery({queryKey:["account","reservations",s],enabled:!!s&&!!(i!=null&&i.user),queryFn:async()=>{const{body:f,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 f}});if(!(i!=null&&i.user))return null;if(n.isLoading||o.isLoading)return e.jsx(Ut,{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,j)=>new Date(f.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(gt,{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(W,{asChild:!0,variant:"secondary",children:e.jsx(D,{href:"/account/orders",children:"View orders"})}),e.jsx(W,{asChild:!0,children:e.jsx(D,{href:"/account/reservations",children:"Reservation history"})})]}),children:[e.jsxs("div",{className:"grid gap-6 lg:grid-cols-[1.25fr_0.95fr]",children:[e.jsx(Ye,{title:"Recent orders",description:"A quick look at what you ordered most recently.",action:e.jsx(Ua,{href:"/account/orders",label:"See all"}),children:n.isError?e.jsx(Be,{icon:v.ShoppingBagIcon,title:"Orders unavailable",description:"We couldn't load your recent orders just now. Please refresh and try again."}):l.length===0?e.jsx(Be,{icon:v.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(D,{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:Oo(f)}),e.jsx(qa,{tone:Ks(f.status),children:Gs(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:ue(f.payment.total,f.currency)}),e.jsx("p",{className:"mt-1 text-sm text-stone-500",children:Me(f.createdAt,"Recently")})]})]})},f.id))})}),e.jsxs("div",{className:"grid gap-6",children:[e.jsx(Ye,{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:v.ShoppingBagIcon,title:"Orders list",description:"Review every purchase, total paid, fulfilment method, and live order status."}),e.jsx(yr,{href:"/account/reservations",icon:v.CalendarDaysIcon,title:"Reservation history",description:"See confirmed, pending, and cancelled bookings in one place."})]})}),e.jsx(Ye,{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:Qo(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(v.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(v.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(v.CalendarDaysIcon,{className:"h-4 w-4"}),"Upcoming reservation"]}),e.jsx("span",{className:"font-semibold text-stone-900",children:m?Me(m.date,"Not scheduled","MMM d, yyyy"):"Nothing booked"})]})]}),e.jsx("div",{className:"mt-5",children:e.jsx(W,{asChild:!0,variant:"secondary",children:e.jsx(D,{href:"/account/reservations/book",children:"Book a table"})})})]})})]})]}),e.jsx("div",{className:"mt-6",children:e.jsx(Ye,{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(W,{asChild:!0,variant:"secondary",children:e.jsx(D,{href:"/account/reservations/book",children:"Book a table"})}),e.jsx(Ua,{href:"/account/reservations",label:"Open history"})]}),children:o.isError?e.jsx(Be,{icon:v.CalendarDaysIcon,title:"Reservations unavailable",description:"We couldn't load your reservation history just now. Please refresh and try again."}):c.length===0?e.jsx(Be,{icon:v.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(D,{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:Me(f.date,"Date pending","MMM d, yyyy")}),e.jsx(qa,{tone:Ys(f),children:Xs(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:Me(f.date,"Awaiting confirmation","h:mm a")})]})},f.id))})})})]})},ei=()=>e.jsx(He,{children:e.jsx(Lo,{})}),Jo={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",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."}},Vo={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",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."}},br={en:Jo,pl:Vo},ai=h.createContext(void 0),Ho=({children:a,locale:t})=>{const r=h.useCallback(i=>{const n=i.split(".");let o=br[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:br[t],t:r};return e.jsx(ai.Provider,{value:s,children:a})},Zt=()=>{const a=h.useContext(ai);if(a===void 0)throw new Error("useTranslation must be used within a TranslationProvider");return a},ti=()=>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))]})})]})})]})}),qo=({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"})}),Uo=({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"})}),Zo=({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"})]}),ri=({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 T.isValid(u)?T.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(qo,{className:"w-4 h-4 text-green-500"}),l&&n&&e.jsx(v.PartyPopperIcon,{className:"w-4 h-4 text-violet-500"}),i&&e.jsx(Uo,{className:"w-4 h-4 text-red-500"}),c&&e.jsx(Zo,{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)})]})]})},$o=({orderId:a})=>{const{client:t}=E(),{organization:r,organizationId:s}=pe(),i=S.useSearchParams(),n=S.useRouter(),o=S.usePathname(),{t:l}=Zt(),c=r==null?void 0:r.configuration.defaultCurrency;h.useEffect(()=>{if((i==null?void 0:i.get("clearCart"))==="true"&&o){localStorage.removeItem("shophost-cart");const j=new URLSearchParams(Array.from(i.entries()));j.delete("clearCart");const y=j.toString()?`${o}?${j.toString()}`:o;n.replace(y)}},[i,n,o]);const{data:m,isLoading:u,error:p}=A.useQuery({queryKey:["order",a],refetchInterval:({state:j})=>{var y,b;return((y=j.data)==null?void 0:y.status)!=="completed"&&((b=j.data)==null?void 0:b.status)!=="cancelled"?30*1e3:!1},queryFn:async()=>{const{status:j,body:y}=await t.order.getOrder({params:{id:a,organizationId:s}});if(j!==200)throw new Error("Failed to fetch shipping address");return y}}),g=h.useMemo(()=>m?m==null?void 0:m.items.map(j=>({title:j.translations[0].title,subtitle:[j.translations[0].subtitle],price:ue(j.unitPrice,c??"USD"),unitPrice:ue(j.unitPrice,c??"USD"),quantity:j.quantity,image:j.image})):[],[m,c]);if(!m||u)return e.jsx(ti,{});const{status:x}=m,f=[{title:l("orderTracking.orderPlaced"),description:l("orderTracking.orderPlacedDesc"),date:new Date(m.expiresAt),active:!1},{title:l("orderTracking.orderAccepted"),description:l("orderTracking.orderAcceptedDesc"),date:m.acceptedAt,active:!m.acceptedAt},{title:l("orderTracking.readyForDispatch"),description:l("orderTracking.readyForDispatchDesc"),date:m.readyForDispatchAt,active:x==="accepted"},{title:l("orderTracking.orderDispatched"),description:l("orderTracking.orderDispatchedDesc"),date:m.dispatchedAt,active:x==="ready-for-dispatch"},{title:l("orderTracking.orderDelivered"),description:l("orderTracking.orderDeliveredDesc"),date:m.completedAt,active:x==="dispatched",showConfetti:!0}];return m.status==="cancelled"&&f.push({title:l("orderTracking.orderCancelled"),description:l("orderTracking.orderCancelledDesc"),date:m.cancelledAt,active:!!m.cancelledAt,cancelled:!0}),e.jsxs(e.Fragment,{children:[e.jsx(Aa,{summary:{total:m.payment.total,subtotal:m.payment.subtotal,shipping:m.payment.shipping,items:g}}),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(qt,{items:g,total:m.payment.total,subtotal:m.payment.subtotal,shipping:m.payment.shipping,currency:c??"USD"}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 text-center mt-14 w-full",children:[l("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:l("checkout.yourOrder")}),e.jsxs("div",{className:"mb-8",children:[e.jsxs("p",{className:"text-sm font-medium text-gray-500",children:[l("orderTracking.reference"),": ",m.referenceId]}),e.jsxs("p",{className:"text-sm font-medium text-gray-500",children:[l("orderTracking.status"),":"," ",e.jsx("span",{className:`capitalize font-semibold ${m.status==="cancelled"?"text-red-600":"text-green-600"}`,children:m.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% - ${f.length>1?"4rem":"0rem"})`}}),f.map((j,y)=>e.jsx(ri,{...j},y))]})})]})})]})})]})},_o=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`},Wo=()=>{var o;const{client:a}=E(),{useSession:t}=ze(),{organizationId:r}=pe(),{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(Ut,{title:"Your orders",description:"Loading your order history."});const n=((o=i.data)==null?void 0:o.list)??[];return e.jsx(gt,{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(W,{asChild:!0,variant:"secondary",children:e.jsx(D,{href:"/account",children:"Back to account"})}),e.jsx(W,{asChild:!0,children:e.jsx(D,{href:"/account/reservations",children:"Reservation history"})})]}),children:e.jsx("div",{children:e.jsx(Ye,{title:"Order history",description:"Open any order to review the full tracker and line items.",action:e.jsx(Ua,{href:"/account",label:"Back to dashboard"}),children:i.isError?e.jsx(Be,{icon:v.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(Be,{icon:v.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(D,{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:_o(l)}),e.jsx(qa,{tone:Ks(l.status),children:Gs(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:ue(l.payment.total,l.currency)}),e.jsx("p",{className:"mt-1 text-sm text-stone-500",children:Me(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))})})})})},Go=(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]}},Ko=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)Go(s,i.path.filter(n=>typeof n=="string"||typeof n=="number"),{type:i.code,message:i.message});return{values:{},errors:s}},Xo=({initialData:a})=>{var u;const{client:t}=E(),{organizationId:r,organization:s}=pe(),{t:i}=Zt(),n=S.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=L.useForm({resolver:Ko(jo),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(W,{variant:"secondary",className:"shadow-none",type:"button",onClick:()=>n.push("/"),children:"Back"}):e.jsx(L.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(me,{name:"firstname",label:"First Name",type:"text",className:"col-span-2",placeholder:"e.g. John"}),e.jsx(me,{name:"lastname",label:"Last Name",type:"text",className:"col-span-2",placeholder:"e.g. Doe"}),e.jsx(me,{name:"phone",label:"Phone",type:"phone-number",className:"col-span-4",placeholder:"e.g. +48 123 456 789"}),e.jsx(me,{name:"guests",label:"Number of Guests",type:"number",className:"col-span-4",placeholder:"e.g. 2"}),e.jsx(me,{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(W,{variant:"secondary",className:"shadow-none",type:"button",onClick:()=>n.push("/"),children:"Back"}),e.jsx(W,{type:"submit",className:"shadow-none",isLoading:m.isPending,loadingText:"Saving...",children:"Send Request"})]})]})})]})},Yo=()=>{const{useSession:a}=ze(),{data:t}=a();return t!=null&&t.user?e.jsx(Ws,{title:"Book a table",description:"Enter your details to book a table at Madras Bistro",children:e.jsx(Xo,{initialData:{firstname:t.user.firstname,lastname:t.user.lastname}})}):null},jr=(a,t)=>{if(!a)return t("reservation.notSpecified");const r=new Date(a);return T.isValid(r)?T.format(r,"MMM d, yyyy - h:mm a"):t("reservation.invalidDate")},el=({reservationId:a})=>{const{client:t}=E(),{organizationId:r}=pe(),{t:s}=Zt(),{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(ti,{});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(Aa,{}),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"),":"]})," ",jr(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"),":"]})," ",jr(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(ri,{...c},m))]})})]})})]})]})},al=()=>{var o;const{client:a}=E(),{useSession:t}=ze(),{organizationId:r}=pe(),{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(Ut,{title:"Reservation history",description:"Loading your reservations."});const n=((o=i.data)==null?void 0:o.list)??[];return e.jsx(gt,{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(W,{asChild:!0,variant:"secondary",children:e.jsx(D,{href:"/account",children:"Back to account"})}),e.jsx(W,{asChild:!0,children:e.jsx(D,{href:"/account/reservations/book",children:"Book a table"})})]}),children:e.jsx("div",{children:e.jsx(Ye,{title:"Your bookings",description:"Open any reservation to review the confirmation timeline and details.",action:e.jsx(Ua,{href:"/account",label:"Back to dashboard"}),children:i.isError?e.jsx(Be,{icon:v.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(Be,{icon:v.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(D,{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:Me(l.date,"Date pending","EEEE, MMM d")}),e.jsx(qa,{tone:Ys(l),children:Xs(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:Me(l.date,"Awaiting time","h:mm a")}),e.jsxs("p",{className:"mt-1 text-sm text-stone-500",children:["Created"," ",Me(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))})})})})},tl=()=>{const a=S.useSearchParams(),{signIn:t}=ze(),{baseUrl:r}=E(),s=(a==null?void 0:a.get("redirect"))??"/checkout/customer-details",{register:i,handleSubmit:n,formState:{errors:o,isSubmitting:l}}=L.useForm({resolver:ce.zodResolver(fs),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(D,{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(W,{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(z.RiGoogleFill,{className:"size-4","aria-hidden":"true"}),"Login with Google"]})}),e.jsx(aa,{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(ye,{htmlFor:"email-form-item",className:"font-medium",children:"Email"}),e.jsx(ve,{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(ye,{htmlFor:"password-form-item",className:"font-medium",children:"Password"}),e.jsx(ve,{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(W,{type:"submit",className:"shadow-none",isLoading:l,children:l?"Submitting...":"Continue"})]})]}),e.jsx(aa,{}),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"})]})]})},rl=()=>e.jsx(tl,{}),sl=()=>{const a=S.useSearchParams(),{signUp:t,signIn:r}=ze(),{baseUrl:s}=E(),i=(a==null?void 0:a.get("redirect"))??"/checkout/customer-details",{register:n,handleSubmit:o,formState:{errors:l}}=L.useForm({resolver:ce.zodResolver(Lt),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(D,{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(W,{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(z.RiGoogleFill,{className:"size-4","aria-hidden":"true"}),"Signin with Google"]})}),e.jsx(aa,{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(ye,{htmlFor:"email-form-item",className:"font-medium",children:"First Name"}),e.jsx(ve,{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(ye,{htmlFor:"email-form-item",className:"font-medium",children:"Last Name"}),e.jsx(ve,{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(ye,{htmlFor:"email-form-item",className:"font-medium",children:"Email"}),e.jsx(ve,{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(ye,{htmlFor:"password-form-item",className:"font-medium",children:"Password"}),e.jsx(ve,{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(W,{type:"submit",isLoading:c,children:c?"Submitting...":"Continue"})]})]}),e.jsx(aa,{}),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"})]})]})})},il=()=>e.jsx(sl,{}),nl=()=>{const{segments:a}=S.useParams(),[t,...r]=a??[];if(!t)return e.jsx(He,{children:e.jsx(ei,{})});switch(t){case"sign-in":return r.length!==0?S.notFound():e.jsx(fr,{children:e.jsx(rl,{})});case"sign-up":return r.length!==0?S.notFound():e.jsx(fr,{children:e.jsx(il,{})});case"orders":return r.length>1?S.notFound():r.length===0?e.jsx(He,{children:e.jsx(Wo,{})}):e.jsx(He,{children:e.jsx($o,{orderId:r[0]})});case"reservations":return r.length>1?S.notFound():r.length===0?e.jsx(He,{children:e.jsx(al,{})}):r[0]==="book"?e.jsx(He,{children:e.jsx(Yo,{})}):e.jsx(He,{children:e.jsx(el,{reservationId:r[0]})});default:return S.notFound()}},ol=a=>{if(a[0]==="reservation"&&a.length===1)return e.jsx(It,{});if(a.length!==1)return S.notFound();switch(a[0]){case"customer-details":return e.jsx(It,{});case"shipping-and-payment":return e.jsx($s,{});default:return S.notFound()}},ll=()=>{const a=S.useParams(),{useSession:t}=ze(),r=S.useRouter(),{data:s,isPending:i}=t(),{loading:n,formattedCartItems:o,total:l,subtotal:c,shipping:m}=et(),{organization:u,loading:p}=pe(),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(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.",x.map(f=>e.jsxs(h.Fragment,{children:[e.jsx("br",{}),f]},f))]}),e.jsx(D,{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(f=>e.jsxs(h.Fragment,{children:[e.jsx("br",{}),f]},f))]}),e.jsx(D,{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(Aa,{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(qt,{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:ol(g)})})]})})]})},si=({children:a})=>{const{isOpen:t,onClose:r,product:s,modifierGroups:i,hasModifiers:n,productName:o,quantity:l,handleIncrement:c,handleDecrement:m,handleAddToCart:u,validationError:p}=wa();if(!s)return null;const g=l<=1;return a({modifierGroups:i,hasModifiers:n,product:s,isOpen:t,onClose:r,productName:o,quantity:l,onIncrement:c,onDecrement:m,isDecrementDisabled:g,onAddToCart:u,validationError:p})},ii=({children:a,group:t,renderOptions:r})=>{const{getModifierGroupName:s}=wa(),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})},ni=({children:a,modifier:t,groupId:r})=>{var f;const{isModifierSelected:s,isMultiSelect:i,toggleModifier:n,selectModifier:o,formatModifierPrice:l,product:c,locale:m}=wa(),u=s(r,t.id),p=(f=c==null?void 0:c.modifierGroups)==null?void 0:f.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})},dl=e.jsx("div",{className:"p-4 text-center text-gray-500",children:"This product has no modifiers."}),cl=({addToCartLabel:a="Add to Cart",emptyState:t=dl,panelClassName:r,renderFooter:s,renderGroup:i,renderHeader:n,renderOption:o})=>e.jsx(si,{children:({isOpen:l,onClose:c,product:m,modifierGroups:u,quantity:p,onIncrement:g,onDecrement:x,isDecrementDisabled:f,onAddToCart:j,validationError:y})=>e.jsx(ka,{open:l,onOpenChange:b=>{b||c()},children:e.jsxs(va,{className:w("w-full sm:max-w-md max-h-[75vh] sm:max-h-[90vh] overflow-auto p-0","top-auto left-0 right-0 bottom-0 translate-x-0 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:c,product:m}):e.jsxs("div",{className:"flex justify-between items-start p-4",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",{className:"mt-4 sm:mt-0",children:[e.jsx(ot,{className:"text-2xl font-black font-red-hat-display",children:m.title}),e.jsx("p",{className:"text-sm text-gray-500",children:m.description})]}),e.jsx("button",{type:"button",onClick:c,className:"cursor-pointer text-gray-500 hover:text-gray-700 text-2xl leading-none mt-4 sm:mt-0","aria-label":"Close modal",children:"×"})]}),u.length>0?e.jsx("div",{className:"px-4",children:u.map(b=>e.jsx(ii,{group:b,renderOptions:()=>b.modifiers.map(k=>e.jsx(ni,{modifier:k,groupId:b.id,children:N=>o?o(N):e.jsxs("div",{className:w("flex items-center py-2.5 px-3 border rounded-lg cursor-pointer text-sm font-medium text-gray-600 dark:text-gray-400 mb-2",N.isSelected?"border-blue-500 bg-blue-50":"border-gray-200"),onClick:N.onSelect,children:[e.jsx("input",{type:N.isMultiSelect?"checkbox":"radio",checked:N.isSelected,className:"mr-2",onChange:R=>R.preventDefault()}),e.jsxs("span",{children:[N.modifier.title,N.formattedPrice]})]})},k.id)),children:k=>i?i(k):e.jsxs("div",{className:"mb-4",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:[k.groupName,k.isRequired&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),k.selectionRequirements&&e.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Select ",k.selectionRequirements]})]}),e.jsx("div",{children:k.renderOptions()})]})},b.id))}):t,s?s({isDecrementDisabled:f,onAddToCart:j,onDecrement:x,onIncrement:g,quantity:p,validationError:y}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"p-4 flex items-center justify-center border-t mt-8",children:[e.jsx("button",{type:"button",onClick:x,className:w("w-8 h-8 flex items-center justify-center border rounded-lg",f?"opacity-50 cursor-not-allowed":"cursor-pointer"),"aria-label":"Decrease quantity",disabled:f,children:"-"}),e.jsx("span",{className:"w-12 text-center",children:p}),e.jsx("button",{type:"button",onClick:g,className:"w-8 h-8 flex items-center justify-center border rounded-lg cursor-pointer","aria-label":"Increase quantity",children:"+"})]}),e.jsxs("div",{className:"p-4 border-t",children:[y&&e.jsx("div",{className:"text-red-500 mb-2",children:y}),e.jsx("button",{type:"button",onClick:j,className:"storefront-primary-action btn text-sm rounded-lg w-full",children:a})]})]})]})})}),ml=({children:a,minQuantity:t=1})=>{const{quantity:r,handleIncrement:s,handleDecrement:i}=wa(),n=r<=t;return a({quantity:r,onIncrement:s,onDecrement:i,isDecrementDisabled:n})},ul=({children:a,locale:t="en"})=>e.jsx(es,{locale:t,children:a}),pl=(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}},gl=(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}},hl=[{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."}]}],xl=new A.QueryClient({defaultOptions:{queries:{retry:!1,refetchInterval:!1,refetchOnWindowFocus:!1}}}),Za="#ffffff",wr="#0f172a",oi=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/,fl=/^(?:rgb|rgba|hsl|hsla|oklch|oklab|var)\([^;{}]+\)$/i,yl=/^(?:bg-)?([a-z]+(?:-[a-z]+)*)-(\d{2,3})$/,Et=on,bl=Et.teal,kr=bl[500],jl=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},St=a=>{const t=a/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4},vr=a=>{const t=jl(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*St(r)+.7152*St(s)+.0722*St(i)},Nr=(a,t)=>{const r=vr(a),s=vr(t),i=Math.max(r,s),n=Math.min(r,s);return(i+.05)/(n+.05)},Ar=a=>{if(oi.test(a)){const r=Nr(a,"#ffffff"),s=Nr(a,"#000000");return r>=s?Za:wr}const t=a.match(/^oklch\(([\d.]+)%/i);return t&&Number.parseFloat(t[1])>=78?wr:Za},wl=a=>{const t=a.match(yl);if(t){const[,i,n]=t,o=Et[i];if(o&&typeof o!="string")return o[n]}const r=a.replace(/^bg-/,""),s=Et[r];if(typeof s=="string")return s},kl=a=>{const t=a==null?void 0:a.trim();if(!t)return{color:kr,foreground:Za};const r=wl(t);return r?{color:r,foreground:Ar(r)}:oi.test(t)||fl.test(t)?{color:t,foreground:Ar(t)}:{color:kr,foreground:Za}},vl=a=>{const{color:t,foreground:r}=kl(a==null?void 0:a.primaryColor);return`:root{--storefront-primary:${t};--storefront-primary-foreground:${r};}`},Nl=({appearance:a,children:t})=>{const r=a!=null&&a.primaryColor?vl(a):null;return e.jsxs(e.Fragment,{children:[r?e.jsx("style",{"data-shophost-storefront-appearance":!0,suppressHydrationWarning:!0,children:r}):null,t]})},Al=({appearance:a,baseUrl:t,children:r,initialOrganization:s,locale:i="en",modifiersModal:n,organizationId:o})=>e.jsx(Nl,{appearance:a,children:e.jsx(Ho,{locale:i,children:e.jsx(Ro,{baseURL:t,children:e.jsx(Pt,{baseUrl:t,children:e.jsx(A.QueryClientProvider,{client:xl,children:e.jsx(zn,{initialOrganization:s,organizationId:o,children:e.jsx(Gr,{locale:i,organizationId:o,children:e.jsxs(es,{locale:i,children:[r,n]})})})})})})})});function X(...a){return Mr.twMerge(Pr(...a))}const la=["focus:ring-2","focus:ring-blue-200 dark:focus:ring-blue-700/30","focus:border-blue-500 dark:focus:border-blue-700"],ge=["outline outline-offset-2 outline-0 focus-visible:outline-2","outline-blue-500 dark:outline-blue-500"],ht=["ring-2","border-red-500 dark:border-red-700","ring-red-200 dark:ring-red-700/30"],Cl=(a,t=0)=>Intl.NumberFormat("us",{minimumFractionDigits:t,maximumFractionDigits:t}).format(Number(a)).toString(),ne={currency:(a,t="USD")=>new Intl.NumberFormat("en-US",{style:"currency",currency:t}).format(a),unit:a=>`${Cl(a)}`},Sl=Se.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",ge],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"}}),I=h.forwardRef(({asChild:a,isLoading:t=!1,loadingText:r,className:s,disabled:i,variant:n,children:o,...l},c)=>{const m=a?Ft.Slot:"button";return e.jsx(m,{ref:c,className:w(Sl({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(z.RiLoader2Fill,{className:"size-4 shrink-0 animate-spin","aria-hidden":"true"}),e.jsx("span",{className:"sr-only",children:r||"Loading"}),r||"Loading"]}):o})});I.displayName="Button";function $t({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(I,{className:"mt-3",onClick:a,children:"Reload Page"})]})})})}const xt=h.createContext({});function zl({children:a,organizationId:t,id:r}){return e.jsx(xt.Provider,{value:{organizationId:t,id:r},children:a})}function Il(){return h.useContext(xt)}function V(){const{organizationId:a}=h.useContext(xt);if(!a)throw new Error("useOrgId called outside an org-scoped route");return a}function da(){const{id:a}=h.useContext(xt);if(!a)throw new Error("useRouteId called outside a detail route");return a}const El=h.createContext(void 0),Dl=({children:a,initialState:t=!1})=>{const[r,s]=h.useState(t);return e.jsx(El.Provider,{value:{flyoutOpen:r,setFlyoutOpen:s},children:a})},ie=({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"})]}),li=h.createContext(null),Cr=({children:a})=>{var c,m,u,p,g;const{client:t}=E(),{organizationId:r}=Il(),s=A.useQuery({queryKey:["organizations"],queryFn:async()=>{const{body:x,status:f}=await t.organization.getOrganizations();if(f!==200)throw f!==401&&Q.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:f}=await t.organization.getOrganization({params:{organizationId:r}});if(f!==200)throw f!==401&&Q.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(li.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(ie,{className:"w-12 h-12"}),e.jsx("p",{className:"text-gray-500 text-sm mt-3",children:"Loading data..."})]})}):a})},he=()=>{const a=h.useContext(li);if(!a)throw new Error("useOrganization must be used within a OrganizationProvider");return a},Fl="redirect";function Rl(a){return a.startsWith("/")&&!a.startsWith("//")}function Pl(a,t){return a===t||a.startsWith(`${t}/`)}function ft(a,t){return!a||!Rl(a)||!Pl(a,t.home)||a===t.signIn||a===t.signUp?t.home:a}function _t(a,t){const r=new URLSearchParams({[Fl]:t});return`${a}?${r.toString()}`}function di(a,t,r){const s=ft(t,r);return new URL(s,a).toString()}const J=h.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")})}));J.displayName="Divider";const Ml=Se.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",la],variants:{hasError:{true:ht},enableStepper:{false:"[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none"},multiline:{true:"resize-y min-h-[100px]",false:"truncate appearance-none"}}}),oe=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,f]=h.useState(i),[j,y]=h.useState(!1),b=i==="password"&&!n,k=i==="search"&&!n,N=!!c,R=i==="textarea"?"textarea":"input",O=async()=>{if(c)try{y(!0),await navigator.clipboard.writeText(c),Q.success(m)}catch{Q.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(R,{ref:g,type:b?x:i,className:w(Ml({hasError:r,enableStepper:n?!1:s,multiline:n}),{"pl-16":o,"pl-8":!o&&k,"pr-24":N,"pr-10":!N&&(l||!l&&b)},t),...p}),!o&&k&&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(z.RiSearchLine,{className:"size-[1.125rem]"})}),N&&e.jsx("div",{className:"absolute inset-y-0 right-0 flex items-center pr-1.5",children:e.jsxs(I,{type:"button",variant:"ghost",onClick:O,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(v.CopyIcon,{className:"size-4","aria-hidden":"true"}),e.jsx("span",{className:"sr-only",children:"Copy value"})]})}),!N&&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}),!N&&!l&&b&&e.jsx("div",{className:"absolute inset-y-0 right-0 flex items-center pr-3",children:e.jsx("button",{onClick:()=>f(x==="password"?"text":"password"),className:w(ge,"text-gray-400 hover:text-gray-500 dark:text-gray-600"),children:x==="password"?e.jsx(z.RiEyeFill,{className:"size-5"}):e.jsx(z.RiEyeOffFill,{className:"size-5"})})})]})});oe.displayName="Input";const le=C.forwardRef(({className:a,disabled:t,...r},s)=>e.jsx(Qr.Root,{ref:s,className:X("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 Bl=()=>{const a=S.useRouter(),t=S.useSearchParams(),r=ja(),s=Z(),i=r.signIn,n=ft(t==null?void 0:t.get("redirect"),s),{register:o,handleSubmit:l,formState:{errors:c,isSubmitting:m}}=L.useForm({resolver:ce.zodResolver(fs),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:di(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(D,{className:"text-blue-500 hover:text-blue-600 dark:text-blue-500 dark:hover:text-blue-400",href:_t(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(I,{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(z.RiGoogleFill,{className:"size-4","aria-hidden":"true"}),"Login with Google"]})}),e.jsx(J,{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(oe,{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(oe,{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(I,{type:"submit",isLoading:m,children:m?"Submitting...":"Continue"})]})]}),e.jsx(J,{}),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 ci({children:a}){const{appearance:t}=Vr(),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(xe,{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 Tl(){return e.jsx(ci,{children:e.jsx(Bl,{})})}const Ql=()=>{const a=S.useRouter(),t=S.useSearchParams(),r=ja(),s=Z(),{signIn:i,signUp:n}=r,o=ft(t==null?void 0:t.get("redirect"),s),{register:l,handleSubmit:c,formState:{errors:m}}=L.useForm({resolver:ce.zodResolver(Lt),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}})}),f=async()=>i.social({provider:"google",callbackURL:di(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(D,{className:"text-blue-500 hover:text-blue-600 dark:text-blue-500 dark:hover:text-blue-400",href:_t(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(I,{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(z.RiGoogleFill,{className:"size-4","aria-hidden":"true"}),"Signin with Google"]})})}),e.jsx(J,{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(le,{htmlFor:"email-form-item",className:"font-medium",children:"First Name"}),e.jsx(oe,{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(oe,{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(oe,{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(oe,{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(I,{type:"submit",isLoading:p,children:p?"Submitting...":"Continue"})]})]}),e.jsx(J,{}),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 Ol(){return e.jsx(ci,{children:e.jsx(Ql,{})})}const _e=h.forwardRef(({className:a,asChild:t,...r},s)=>{const i=t?Ft.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})});_e.displayName="Card";const ya=C.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",ge),onClick:a,...s,children:e.jsx(n,{className:"size-full shrink-0"})})});ya.displayName="NavigationButton";function Sr({displayMonth:a,displayIndex:t,enableYearNavigation:r,disableNavigation:s,numberOfMonths:i,startMonth:n,endMonth:o}){const l=fa.useNavigation(),c=a,m=t??0,u=m<=0,p=m===i-1,g=i>1&&(u||!p),x=i>1&&(p||!u),f=l.previousMonth,j=l.nextMonth,y=l.goToMonth,b=!n||T.addYears(c,-1).getTime()>=n.getTime(),k=!o||T.addYears(c,1).getTime()<=o.getTime(),N=()=>{!f||!b||y(T.addYears(c,-1))},R=()=>{!j||!k||y(T.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(ya,{disabled:s||!f||!b,"aria-label":"Go to previous year",onClick:N,icon:z.RiArrowLeftDoubleLine}),!x&&e.jsx(ya,{disabled:s||!f,"aria-label":"Go to previous month",onClick:()=>f&&y(f),icon:z.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:T.format(c,"LLLL yyy")}),e.jsxs("div",{className:"flex items-center gap-1",children:[!g&&e.jsx(ya,{disabled:s||!j,"aria-label":"Go to next month",onClick:()=>j&&y(j),icon:z.RiArrowRightSLine}),r&&!g&&e.jsx(ya,{disabled:s||!j||!k,"aria-label":"Go to next year",onClick:R,icon:z.RiArrowRightDoubleLine})]})]})}const mi=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",ge),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:N,displayIndex:R})=>e.jsx(Sr,{displayMonth:N,displayIndex:R,enableYearNavigation:t,disableNavigation:i,numberOfMonths:s,startMonth:n,endMonth:o}),Chevron:()=>e.jsx("span",{}),Nav:()=>e.jsx("span",{}),MonthCaption:({calendarMonth:N,displayIndex:R})=>e.jsx(Sr,{displayMonth:N.date,displayIndex:R,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:N,className:R,classNames:O,components:F,weekStartsOn:q,numberOfMonths:te,...P}=a,H={...P,...m,mode:"range"};return e.jsx(fa.DayPicker,{...H})}if(a.mode==="multiple"){const{enableYearNavigation:N,className:R,classNames:O,components:F,weekStartsOn:q,numberOfMonths:te,...P}=a,H={...P,...m,mode:"multiple"};return e.jsx(fa.DayPicker,{...H})}if(a.mode==="default"){const{enableYearNavigation:N,className:R,classNames:O,components:F,weekStartsOn:q,numberOfMonths:te,...P}=a,H={...P,...m,mode:"default"};return e.jsx(fa.DayPicker,{...H})}const{enableYearNavigation:u,className:p,classNames:g,components:x,mode:f,weekStartsOn:j,numberOfMonths:y,...b}=a,k={...b,...m,mode:"single"};return e.jsx(fa.DayPicker,{...k})};mi.displayName="Calendar";const Ll=()=>{const a=typeof window<"u"?window.navigator.language:"en-US",t=new Intl.DateTimeFormat(a,{hour:"numeric"}).format();return Number.isInteger(Number(t))},Jl=({segment:a,state:t})=>{const r=C.useRef(null),{segmentProps:s}=Br.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:X("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",la,"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:X("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]})},Dt=C.forwardRef(({hourCycle:a,...t},r)=>{const s=C.useRef(null);C.useImperativeHandle(r,()=>s==null?void 0:s.current);const i=window!==void 0?window.navigator.language:"en-US",n=en.useTimeFieldState({hourCycle:a,locale:i,shouldForceLeadingZeros:!0,autoFocus:!0,...t}),{fieldProps:o}=Br.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(Jl,{segment:l,state:n},c))})});Dt.displayName="TimeInput";const Vl=Se.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",la],variants:{hasError:{true:ht}}}),ui=C.forwardRef(({className:a,children:t,placeholder:r,hasError:s,...i},n)=>e.jsx(K.Trigger,{asChild:!0,children:e.jsxs("button",{ref:n,className:X(Vl({hasError:s}),a),...i,children:[e.jsx(z.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)})]})}));ui.displayName="DatePicker.Trigger";const pi=C.forwardRef(({align:a,className:t,children:r,...s},i)=>e.jsx(K.Portal,{children:e.jsx(K.Content,{ref:i,sideOffset:10,side:"bottom",align:a,avoidCollisions:!0,onOpenAutoFocus:n=>n.preventDefault(),className:X("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})}));pi.displayName="DatePicker.CalendarPopover";const gi=({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 f=m.to,j=u.to;let y=!1;return f&&j&&o(f,j)&&(y=!0),x&&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:X("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",ge,"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))})};gi.displayName="DatePicker.PresetContainer";const zr=(a,t,r)=>{const s=!Ll();let i;return r?i=s?T.format(a,"dd MMM, yyyy h:mm a",{locale:t}):T.format(a,"dd MMM, yyyy HH:mm",{locale:t}):i=T.format(a,"dd MMM, yyyy",{locale:t}),i},Hl=({defaultValue:a,value:t,onChange:r,presets:s,disabled:i,disableNavigation:n,disabledDays:o,enableYearNavigation:l=!1,locale:c=an.enUS,showTimePicker:m,placeholder:u="Select date range",hasError:p,translations:g,align:x="center",className:f,...j})=>{const[y,b]=C.useState(!1),[k,N]=C.useState(t??a??void 0),[R,O]=C.useState(k==null?void 0:k.from),[F,q]=C.useState(t!=null&&t.from?new se.Time(t.from.getHours(),t.from.getMinutes()):a!=null&&a.from?new se.Time(a.from.getHours(),a.from.getMinutes()):new se.Time(0,0)),[te,P]=C.useState(t!=null&&t.to?new se.Time(t.to.getHours(),t.to.getMinutes()):a!=null&&a.to?new se.Time(a.to.getHours(),a.to.getMinutes()):new se.Time(0,0)),H=C.useMemo(()=>k,[y]);C.useEffect(()=>{N(t??a??void 0)},[t,a]),C.useEffect(()=>{k&&O(k.from)},[k]),C.useEffect(()=>{y||O(k==null?void 0:k.from)},[y]);const je=re=>{const M=re;m&&(M!=null&&M.from&&!F&&q(new se.Time(0,0)),M!=null&&M.to&&!te&&P(new se.Time(0,0)),M!=null&&M.from&&F&&(M.from.setHours(F.hour),M.from.setMinutes(F.minute)),M!=null&&M.to&&te&&(M.to.setHours(te.hour),M.to.setMinutes(te.minute))),N(M)},ua=()=>{N(H),q(H!=null&&H.from?new se.Time(H.from.getHours(),H.from.getMinutes()):new se.Time(0,0)),P(H!=null&&H.to?new se.Time(H.to.getHours(),H.to.getMinutes()):new se.Time(0,0)),b(!1)},Ca=re=>{re||ua(),b(re)},pa=(re,M)=>{switch(M){case"start":q(re);break;case"end":P(re);break}if(k){if(M==="start"){if(!k.from)return;const U=new Date(k.from.getTime());re?(U.setHours(re.hour),U.setMinutes(re.minute)):(U.setHours(0),U.setMinutes(0)),N({...k,from:U})}if(M==="end"){if(!k.to)return;const U=new Date(k.to.getTime());re?(U.setHours(re.hour),U.setMinutes(re.minute)):(U.setHours(0),U.setMinutes(0)),N({...k,to:U})}}};C.useEffect(()=>{N(t??a??void 0),q(t!=null&&t.from?new se.Time(t.from.getHours(),t.from.getMinutes()):a!=null&&a.from?new se.Time(a.from.getHours(),a.from.getMinutes()):new se.Time(0,0)),P(t!=null&&t.to?new se.Time(t.to.getHours(),t.to.getMinutes()):a!=null&&a.to?new se.Time(a.to.getHours(),a.to.getMinutes()):new se.Time(0,0))},[t,a]);const ga=C.useMemo(()=>k?`${k.from?zr(k.from,c,m):""} - ${k.to?zr(k.to,c,m):""}`:null,[k,c,m]),Sa=()=>{b(!1),r==null||r(k)};return e.jsxs(K.Root,{"tremor-id":"tremor-raw",open:y,onOpenChange:Ca,children:[e.jsx(ui,{placeholder:u,disabled:i,className:f,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:ga}),e.jsx(pi,{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:X("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(gi,{currentValue:k,presets:s,onSelect:je})})}),e.jsxs("div",{className:"overflow-x-auto",children:[e.jsx(mi,{mode:"range",selected:k,onSelect:je,month:R,onMonthChange:O,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(Dt,{value:F,onChange:re=>pa(re,"start"),"aria-label":"Start date time",isDisabled:!(k!=null&&k.from),isRequired:j.required})]}),e.jsx(z.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(Dt,{value:te,onChange:re=>pa(re,"end"),"aria-label":"End date time",isDisabled:!(k!=null&&k.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:ga})]}),e.jsxs("div",{className:"mt-2 flex items-center gap-x-2 sm:mt-0",children:[e.jsx(I,{variant:"secondary",className:"h-8 w-full sm:w-fit",type:"button",onClick:ua,children:(g==null?void 0:g.cancel)??"Cancel"}),e.jsx(I,{variant:"primary",className:"h-8 w-full sm:w-fit",type:"button",onClick:Sa,children:(g==null?void 0:g.apply)??"Apply"})]})]})]})]})})})]})},ql=(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,f,j,y;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 ${T.format(l,"MMM dd, yyyy")}.`)}if("dateRange"in u){const b=(p=u.dateRange.from)==null?void 0:p.getFullYear(),k=(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(k&&r&&k>r)throw new Error(`Preset ${u.label}'s 'to' is after toYear ${m}.`);if(i){const N=(x=u.dateRange.from)==null?void 0:x.getMonth();if(N&&N<i.getMonth())throw new Error(`Preset ${u.label}'s 'from' is before fromMonth ${T.format(i,"MMM, yyyy")}.`)}if(n){const N=(f=u.dateRange.to)==null?void 0:f.getMonth();if(N&&N>n.getMonth())throw new Error(`Preset ${u.label}'s 'to' is after toMonth ${T.format(n,"MMM, yyyy")}.`)}if(o){const N=(j=u.dateRange.from)==null?void 0:j.getDate();if(N&&N<o.getDate())throw new Error(`Preset ${u.dateRange.from}'s 'from' is before fromDay ${T.format(o,"MMM dd, yyyy")}.`)}if(l){const N=(y=u.dateRange.to)==null?void 0:y.getDate();if(N&&N>l.getDate())throw new Error(`Preset ${u.label}'s 'to' is after toDay ${T.format(l,"MMM dd, yyyy")}.`)}}})}},hi=({presets:a,...t})=>(a&&ql(a,t),e.jsx(Hl,{presets:a,...t}));hi.displayName="DateRangePicker";const Ul=new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:1}),Zl={bank_transfer:"Bank transfer",blik:"BLIK",card:"Card",cash_on_delivery:"Cash on delivery",paypal:"PayPal"},$l={delivery:"Delivery",pickup:"Pickup"},za=["#0f766e","#fb923c"],Ia=a=>typeof a=="number"?a:typeof a=="string"?Number(a):Array.isArray(a)&&a.length>0?Number(a[0]):0;function _l(){const{client:a}=E(),t=V(),r=h.useMemo(()=>new Date,[]),[s,i]=h.useState({from:T.subDays(r,29),to:r}),n=h.useMemo(()=>{const y=(s==null?void 0:s.from)??T.subDays(r,29),b=(s==null?void 0:s.to)??(s==null?void 0:s.from)??r;return{from:T.startOfDay(y),to:T.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:y,status:b}=await a.analytics.getOverview({params:{organizationId:t},query:{from:n.from.toISOString(),to:n.to.toISOString()}});if(b!==200||!y)throw new Error("Failed to fetch dashboard overview");return y},placeholderData:A.keepPreviousData}),g=(o==null?void 0:o.summary.currency)??"USD",x=((o==null?void 0:o.paymentMethods)??[]).map(y=>({...y,label:Zl[y.method]??y.method})),f=((o==null?void 0:o.fulfilmentMethods)??[]).map(y=>({...y,label:$l[y.method]??y.method})),j=f.reduce((y,b)=>y+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(hi,{value:s,onChange:i,className:"w-full sm:w-fit",toDate:r,align:"end"})]})]}),c&&!o?e.jsx(_e,{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(I,{onClick:()=>p(),className:"gap-2",children:[e.jsx(z.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,b)=>e.jsx(xa,{className:"h-[148px]"},b)):o?e.jsxs(e.Fragment,{children:[e.jsx(Ea,{icon:z.RiMoneyDollarCircleLine,title:"Paid sales",value:ne.currency(o.summary.totalSales,g),description:"Successful payments in the selected range"}),e.jsx(Ea,{icon:z.RiShoppingBag3Line,title:"Paid orders",value:ne.unit(o.summary.paidOrders),description:`Average order value ${ne.currency(o.summary.averageOrderValue,g)}`}),e.jsx(Ea,{icon:z.RiCalendarCheckLine,title:"Reservations",value:ne.unit(o.summary.reservations),description:"Scheduled reservations in the selected range"}),e.jsx(Ea,{icon:z.RiGroupLine,title:"Reserved guests",value:ne.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(xa,{className:"h-[360px]"}),e.jsx(xa,{className:"h-[360px]"})]}):o?e.jsxs(e.Fragment,{children:[e.jsx(Da,{title:"Paid sales by day",value:ne.currency(o.summary.totalSales,g),description:"Gross paid revenue recognised on each order day.",children:e.jsx(_.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(_.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(_.CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb",vertical:!1}),e.jsx(_.XAxis,{dataKey:"label",axisLine:!1,tickLine:!1,tick:{fill:"#6b7280",fontSize:12}}),e.jsx(_.YAxis,{axisLine:!1,tickLine:!1,width:48,tickFormatter:y=>Ul.format(y),tick:{fill:"#6b7280",fontSize:12}}),e.jsx(_.Tooltip,{formatter:(y,b)=>{const k=Ia(y);return[String(b)==="totalSales"?ne.currency(k,g):ne.unit(k),String(b)==="totalSales"?"Sales":"Paid orders"]},contentStyle:Fa,labelStyle:Ra}),e.jsx(_.Area,{type:"monotone",dataKey:"totalSales",stroke:"#0f766e",strokeWidth:2.5,fill:"url(#salesGradient)",name:"totalSales"})]})})}),e.jsx(Da,{title:"Reservations per day",value:ne.unit(o.summary.reservations),description:"Bookings are grouped by reservation date, not submission time.",children:e.jsx(_.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(_.BarChart,{data:o.reservationsByDay,children:[e.jsx(_.CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb",vertical:!1}),e.jsx(_.XAxis,{dataKey:"label",axisLine:!1,tickLine:!1,tick:{fill:"#6b7280",fontSize:12}}),e.jsx(_.YAxis,{allowDecimals:!1,axisLine:!1,tickLine:!1,width:36,tick:{fill:"#6b7280",fontSize:12}}),e.jsx(_.Tooltip,{formatter:(y,b)=>[ne.unit(Ia(y)),String(b)==="guests"?"Guests":"Reservations"],contentStyle:Fa,labelStyle:Ra}),e.jsx(_.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(xa,{className:"h-[320px]"}),e.jsx(xa,{className:"h-[320px]"})]}):o?e.jsxs(e.Fragment,{children:[e.jsx(Da,{title:"Payment methods",value:ne.unit(x.reduce((y,b)=>y+b.count,0)),description:"Successful orders grouped by how guests paid.",children:x.length>0?e.jsx(_.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(_.BarChart,{data:x,layout:"vertical",margin:{left:12,right:12},children:[e.jsx(_.CartesianGrid,{strokeDasharray:"3 3",stroke:"#e5e7eb",horizontal:!1}),e.jsx(_.XAxis,{type:"number",allowDecimals:!1,axisLine:!1,tickLine:!1,tick:{fill:"#6b7280",fontSize:12}}),e.jsx(_.YAxis,{dataKey:"label",type:"category",axisLine:!1,tickLine:!1,width:110,tick:{fill:"#374151",fontSize:12}}),e.jsx(_.Tooltip,{formatter:(y,b,k)=>{const N=Ia(y),R=k&&typeof k=="object"&&"payload"in k?k.payload:{totalSales:0};return String(b)==="count"?[ne.unit(N),"Orders"]:[ne.currency(R.totalSales,g),"Sales"]},contentStyle:Fa,labelStyle:Ra}),e.jsx(_.Bar,{dataKey:"count",name:"count",fill:"#2563eb",radius:[0,8,8,0]})]})}):e.jsx(Ir,{message:"No paid orders in the selected range."})}),e.jsx(Da,{title:"Fulfilment mix",value:ne.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(_.ResponsiveContainer,{width:"100%",height:"100%",children:e.jsxs(_.PieChart,{children:[e.jsx(_.Pie,{data:f,dataKey:"count",nameKey:"label",innerRadius:68,outerRadius:100,paddingAngle:4,children:f.map((y,b)=>e.jsx(_.Cell,{fill:za[b%za.length]},y.method))}),e.jsx(_.Tooltip,{formatter:(y,b,k)=>{const N=Ia(y),R=k&&typeof k=="object"&&"payload"in k?k.payload:{label:"Orders"};return[`${ne.unit(N)} orders`,R.label]},contentStyle:Fa,labelStyle:Ra})]})}),e.jsx("div",{className:"flex flex-col justify-center gap-3",children:f.map((y,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:za[b%za.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/j*100),"%"]})]}),e.jsx("div",{className:"mt-2 text-lg font-semibold text-gray-900 dark:text-gray-50",children:ne.unit(y.count)}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:ne.currency(y.totalSales,g)})]},y.method))})]}):e.jsx(Ir,{message:"No orders in the selected range."})})]}):null})]})}function Ea({description:a,icon:t,title:r,value:s}){return e.jsx(_e,{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 Da({children:a,description:t,title:r,value:s}){return e.jsxs(_e,{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 xa({className:a}){return e.jsx(_e,{className:X("animate-pulse",a),children:e.jsx("div",{className:"h-full rounded-xl bg-gray-100 dark:bg-gray-900"})})}function Ir({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 Fa={border:"1px solid #e5e7eb",borderRadius:"12px",boxShadow:"0 10px 30px rgba(15, 23, 42, 0.08)",backgroundColor:"#ffffff"},Ra={color:"#111827",fontWeight:600},xi=(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},Er=[{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:"🇪🇹"}]}],yt=a=>e.jsx(G.Root,{...a});yt.displayName="Dialog";const fi=G.Trigger;fi.displayName="DialogTrigger";const yi=G.Close;yi.displayName="DialogClose";const bi=G.Portal;bi.displayName="DialogPortal";const ji=h.forwardRef(({className:a,...t},r)=>e.jsx(G.Overlay,{ref:r,className:w("fixed inset-0 z-50 overflow-y-auto","bg-black/70","data-[state=open]:animate-dialogOverlayShow",a),...t}));ji.displayName="DialogOverlay";const bt=h.forwardRef(({className:a,...t},r)=>e.jsx(bi,{children:e.jsx(ji,{children:e.jsx(G.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",ge,a),...t})})}));bt.displayName="DialogContent";const jt=({className:a,...t})=>e.jsx("div",{className:w("flex flex-col gap-y-1",a),...t});jt.displayName="DialogHeader";const wt=h.forwardRef(({className:a,...t},r)=>e.jsx(G.Title,{ref:r,className:w("text-lg font-semibold","text-gray-900 dark:text-gray-50",a),...t}));wt.displayName="DialogTitle";const kt=h.forwardRef(({className:a,...t},r)=>e.jsx(G.Description,{ref:r,className:w("text-gray-500 dark:text-gray-500",a),...t}));kt.displayName="DialogDescription";const Wt=C.forwardRef(({className:a,...t},r)=>e.jsx($.Command,{ref:r,className:w("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",a),...t}));Wt.displayName=$.Command.displayName;const Gt=C.forwardRef(({className:a,...t},r)=>e.jsxs("div",{className:"flex items-center border-b pl-3","cmdk-input-wrapper":"",children:[e.jsx(v.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx($.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})]}));Gt.displayName=$.Command.Input.displayName;const Kt=C.forwardRef(({className:a,...t},r)=>e.jsx($.Command.List,{ref:r,className:w("max-h-[300px] overflow-y-auto overflow-x-hidden",a),...t}));Kt.displayName=$.Command.List.displayName;const Xt=C.forwardRef((a,t)=>e.jsx($.Command.Empty,{ref:t,className:"py-6 text-center text-sm",...a}));Xt.displayName=$.Command.Empty.displayName;const Yt=C.forwardRef(({className:a,...t},r)=>e.jsx($.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}));Yt.displayName=$.Command.Group.displayName;const Wl=C.forwardRef(({className:a,...t},r)=>e.jsx($.Command.Separator,{ref:r,className:w("-mx-1 h-px bg-border",a),...t}));Wl.displayName=$.Command.Separator.displayName;const er=C.forwardRef(({className:a,...t},r)=>e.jsx($.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}));er.displayName=$.Command.Item.displayName;const ar=a=>e.jsx(K.Root,{...a});ar.displayName="Popover";const tr=C.forwardRef((a,t)=>e.jsx(K.Trigger,{ref:t,...a}));tr.displayName="PopoverTrigger";const Gl=C.forwardRef((a,t)=>e.jsx(K.Anchor,{ref:t,...a}));Gl.displayName="PopoverAnchor";const Kl=C.forwardRef((a,t)=>e.jsx(K.Close,{ref:t,...a}));Kl.displayName="PopoverClose";const rr=C.forwardRef(({className:a,sideOffset:t=10,side:r="bottom",align:s="center",collisionPadding:i,...n},o)=>e.jsx(K.Portal,{children:e.jsx(K.Content,{ref:o,sideOffset:t,side:r,align:s,collisionPadding:i,avoidCollisions:!0,className:X("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})}));rr.displayName="PopoverContent";const Xl=({value:a,onChange:t})=>{const r=h.useId(),[s,i]=h.useState(!1),n=Er.map(o=>o.items.find(l=>l.value===a)).filter(Boolean)[0];return e.jsx("div",{className:"mt-2",children:e.jsxs(ar,{open:s,onOpenChange:i,children:[e.jsx(tr,{asChild:!0,children:e.jsxs(I,{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(v.ChevronDown,{size:16,strokeWidth:2,className:"shrink-0 text-muted-foreground/80","aria-hidden":"true"})]})}),e.jsx(rr,{className:"w-full min-w-[var(--radix-popper-anchor-width)] border-input -mt-1 z-50",align:"start",children:e.jsxs(Wt,{className:"p-0",children:[e.jsx(Gt,{className:"w-full border-none",style:{boxShadow:"none"},placeholder:"Search country..."}),e.jsxs(Kt,{children:[e.jsx(Xt,{children:"No country found."}),Er.map(o=>e.jsx(h.Fragment,{children:e.jsx(Yt,{heading:o.continent,children:o.items.map(l=>e.jsxs(er,{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(v.Check,{size:16,strokeWidth:2,className:"ml-auto"})]},l.value))})},o.continent))]})]})})]})})},Yl=({...a})=>{const t=h.useId();return e.jsx("div",{className:"mt-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(oe,{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(v.AtSign,{size:16,strokeWidth:2,"aria-hidden":"true"})})]})})},ed=a=>{const{client:t}=E(),[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 Rr.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: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(v.XIcon,{className:"w-4 h-4 text-white"})}),e.jsx(xe,{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(v.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(v.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()})},wi=h.forwardRef(({...a},t)=>e.jsx(oe,{...a,inputClassName:"border-l-0 rounded-l-none",ref:t,className:""}));wi.displayName="PhoneInput";const ad=({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(ki,{country:t,countryName:t,"aria-hidden":"true"}),e.jsx("span",{className:"text-muted-foreground/80",children:e.jsx(v.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&&`+${Xa.getCountryCallingCode(n.value)}`]},n.value??`empty-${o}`))]})]})},ki=({country:a,countryName:t})=>{const r=Tr[a];return e.jsx("span",{className:"w-5 overflow-hidden rounded-sm",children:r?e.jsx(r,{title:t}):e.jsx(v.Phone,{size:16,"aria-hidden":"true"})})},td=({value:a,onChange:t,onBlur:r})=>{const s=h.useId();return e.jsx("div",{className:"mt-2",children:e.jsx(Xa.default,{id:s,className:"flex rounded-lg shadow-xs shadow-black/5",international:!0,flagComponent:ki,countrySelectComponent:ad,inputComponent:wi,placeholder:"Enter phone number",value:a,onChange:i=>t(i??""),onBlur:r})})},rd=({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(ar,{open:o,onOpenChange:l,children:[e.jsx(tr,{asChild:!0,children:e.jsxs(I,{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(v.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(v.ChevronDown,{size:16,strokeWidth:2,className:"shrink-0 text-muted-foreground/80","aria-hidden":"true"})]})}),e.jsx(rr,{className:"w-full min-w-[var(--radix-popper-anchor-width)] border-input -mt-1 z-50 p-0",align:"start",children:e.jsxs(Wt,{className:"p-0",children:[e.jsx(Gt,{className:"w-full border-none pl-0",style:{boxShadow:"none"},placeholder:"Search..."}),e.jsxs(Kt,{children:[e.jsx(Xt,{children:"No options found."}),e.jsx(Yt,{children:a.map(p=>e.jsxs(er,{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(v.Check,{size:16,strokeWidth:2,className:"ml-auto"})]},p.value))})]})]})})]})})},sd=Se.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",ge],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"}}),vi=h.forwardRef(({className:a,size:t,...r},s)=>{const{root:i,thumb:n}=sd({size:t});return e.jsx(Qa.Root,{ref:s,className:w(i(),a),...r,children:e.jsx(Qa.Thumb,{className:w(n())})})});vi.displayName="Switch";const id=({name:a,type:t,placeholder:r,multiple:s,options:i,prefix:n})=>{const{watch:o,register:l,setFocus:c,setValue:m}=L.useFormContext();switch(t){case"email":return e.jsx(Yl,{...l(a),placeholder:r});case"file":return e.jsx(ed,{value:o(a),multiple:s,onChange:u=>m(a,u)});case"phone-number":return e.jsx(td,{value:o("phone"),onChange:u=>m("phone",u),onBlur:()=>c("phone")});case"country":return e.jsx(Xl,{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(rd,{options:i,value:u,onChange:p=>m(a,p),placeholder:r,multiple:s})}case"switch":return e.jsx(vi,{size:"default",className:"mr-2",checked:o(a),onCheckedChange:u=>m(a,u)});case"time":return e.jsx(Ht,{value:o(a),onChange:u=>m(a,u.target.value),className:"mt-2"});default:return e.jsx(oe,{...l(a),type:t,rows:t==="textarea"?4:void 0,placeholder:r,className:"mt-2",prefix:n})}},nd=(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,ke=({type:a="text",name:t,label:r,className:s,locale:i,placeholder:n,multiple:o,options:l,localizable:c,prefix:m})=>{const{errors:u}=L.useFormState(),p=nd(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(v.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:[rt.get(i)," (",i,")"]})]}),e.jsx(id,{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})]})},od=({form:a,config:t,columns:r=2})=>{var c;const{errors:s}=L.useFormState(),i=xi(s,t.name),{fields:n,append:o,remove:l}=L.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:x,type:f,colspan:j,localizable:y,multiple:b,options:k,placeholder:N,prefix:R})=>e.jsx(ke,{name:`${t.name}[${u}].${g}`,label:x,type:f??"text",localizable:y,className:w({"col-span-1":j===1,"col-span-2":j===2,"col-span-3":j===3,"col-span-4":j===4}),placeholder:N,multiple:b,options:k,prefix:R},t.name+g))},m.id),u<n.length-1&&e.jsx(J,{})]})}),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(v.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(v.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},ld=({config:a,columns:t=2})=>{var i;const{errors:r}=L.useFormState(),s=xi(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:x})=>e.jsx(ke,{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: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 dd(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 sr=h.forwardRef(({className:a,children:t,...r},s)=>e.jsx(Oa.Root,{ref:s,...r,asChild:!1,children:e.jsx(Oa.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})}));sr.displayName="TabNavigation";const ir=h.forwardRef(({asChild:a,disabled:t,className:r,children:s,...i},n)=>e.jsx(Oa.Item,{className:"flex","aria-disabled":t,children:e.jsx(Oa.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:dd({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":"",ge,r),children:o}))})}));ir.displayName="TabNavigationLink";const Ne=({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}=he(),[g,x]=h.useState(),f=h.useMemo(()=>r.some(y=>y.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:X("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(sr,{className:"col-span-full mb-3",children:p.map(y=>{const b=y===u;return e.jsx(ir,{active:y===g,onClick:()=>x(y),className:"cursor-pointer",children:e.jsxs(e.Fragment,{children:[rt.get(y)," ",b&&"(Default)"]})},y)})})}),r.map(y=>{const{name:b,label:k,type:N,colspan:R,localizable:O,multiple:F,options:q,placeholder:te,prefix:P}=y,H=!O||!g?b:`translations[${p==null?void 0:p.indexOf(g)}].${b}`;return N==="object"?e.jsx(ld,{config:y},b):N==="array"?e.jsx(od,{form:a,config:y},b):e.jsx(ke,{name:H,label:k,type:N??"text",localizable:O,className:X({"col-span-1":R===1,"col-span-2":R===2,"col-span-3":R===3,"col-span-4":R===4}),placeholder:te,multiple:F,options:q,locale:g,prefix:P},H)}),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(I,{type:"button",className:"w-full sm:w-fit",variant:"secondary",onClick:i,children:n??"Cancel"}),e.jsx(I,{type:"submit",className:"w-full sm:w-fit",isLoading:s,loadingText:"Saving...",children:t??"Save Data"})]})]});return l?e.jsx(L.FormProvider,{...a,children:e.jsx("form",{onSubmit:a.handleSubmit(y=>l(y)),children:j})}):e.jsx("div",{className:"w-full",children:j})},cd=[{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"}],Ni=({initialData:a})=>{const{client:t}=E(),r=S.useRouter(),s=Z(),i=V(),{defaultLocale:n,supportedLocales:o}=he(),l=a?po:uo,c=L.useForm({resolver:ce.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 y;const f={name:x.name,defaultLocale:x.defaultLocale,translations:x.translations,logoId:(y=x.logo)==null?void 0:y.id},{status:j}=await t.manufacturer.createManufacturer({params:{organizationId:i},body:f});if(j!==201)throw Q.error("Failed to create manufacturer. Please try again later."),new Error("Failed to create manufacturer")}}),u=A.useMutation({mutationFn:async x=>{var y;const f={name:x.name,defaultLocale:x.defaultLocale,translations:x.translations,logoId:((y=x.logo)==null?void 0:y.id)||null},{status:j}=await t.manufacturer.updateManufacturer({params:{organizationId:i,id:a.id},body:f});if(j!==200)throw Q.error("Failed to update manufacturer. Please try again later."),new Error("Failed to update manufacturer")}}),p=async()=>{Q.success("Manufacturer saved successfully"),r.push(s.manufacturers(i)),await ae.invalidateQueries({queryKey:["manufacturers"]})},g=x=>{a?u.mutate(x,{onSuccess:p}):m.mutate(x,{onSuccess:p})};return e.jsx(Ne,{form:c,config:cd,onSubmit:g,loading:m.isPending||u.isPending,cancelText:"Go back",okText:a?"Update Manufacturer":"Create Manufacturer"})};function md(){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(J,{}),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(Ni,{})})]})})})})]})}function ud(){const a=V(),t=da(),{client:r}=E(),{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 Q.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(J,{}),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(ie,{className:"w-12 h-12"}),e.jsx("p",{className:"text-gray-500 text-sm mt-3",children:"Loading data..."})]})}):e.jsx(Ni,{initialData:i})})]})})})})]})}const pd=h.forwardRef(({className:a,children:t,...r},s)=>e.jsx("div",{ref:s,children:e.jsx("div",{className:X("w-full overflow-auto whitespace-nowrap",a),...r,children:t})}));pd.displayName="TableRoot";const nr=h.forwardRef(({className:a,...t},r)=>e.jsx("table",{ref:r,className:X("w-full caption-bottom border-b","border-gray-200 dark:border-gray-800",a),...t}));nr.displayName="Table";const or=h.forwardRef(({className:a,...t},r)=>e.jsx("thead",{ref:r,className:X(a),...t}));or.displayName="TableHead";const qe=h.forwardRef(({className:a,...t},r)=>e.jsx("th",{ref:r,className:X("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}));qe.displayName="TableHeaderCell";const lr=h.forwardRef(({className:a,...t},r)=>e.jsx("tbody",{ref:r,className:X("divide-y","divide-gray-200 dark:divide-gray-800",a),...t}));lr.displayName="TableBody";const Ue=h.forwardRef(({className:a,...t},r)=>e.jsx("tr",{ref:r,className:X("[&_td:last-child]:pr-4 [&_th:last-child]:pr-4","[&_td:first-child]:pl-4 [&_th:first-child]:pl-4",a),...t}));Ue.displayName="TableRow";const De=h.forwardRef(({className:a,...t},r)=>e.jsx("td",{ref:r,className:X("p-4 text-sm","text-gray-600 dark:text-gray-400",a),...t}));De.displayName="TableCell";const gd=h.forwardRef(({className:a,...t},r)=>e.jsx("tfoot",{ref:r,className:X("border-t text-left font-medium","text-gray-900 dark:text-gray-50","border-gray-200 dark:border-gray-800",a),...t}));gd.displayName="TableFoot";const hd=h.forwardRef(({className:a,...t},r)=>e.jsx("caption",{ref:r,className:X("mt-3 px-3 text-center text-sm","text-gray-500 dark:text-gray-500",a),...t}));hd.displayName="TableCaption";const xd=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"),Ai=({open:a=!1,onOpenChange:t,defaultOpen:r=!1,disableAutoFocus:s=!0,children:i})=>e.jsxs(K.Root,{open:a,onOpenChange:t,defaultOpen:r,children:[e.jsx(K.Anchor,{className:w("fixed inset-x-0 bottom-8 mx-auto flex w-fit items-center")}),e.jsx(K.Portal,{children:e.jsx(K.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})})]});Ai.displayName="CommandBar";const Ci=C.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}));Ci.displayName="CommandBar.Value";const Si=C.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}));Si.displayName="CommandBarBar";const Pa=C.forwardRef(({className:a,...t},r)=>e.jsx("div",{ref:r,className:w("h-4 w-px bg-gray-700",a),...t}));Pa.displayName="CommandBar.Seperator";const Ma=C.forwardRef(({className:a,type:t="button",label:r,action:s,shortcut:i,disabled:n,...o},l)=>(C.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",ge),...o,children:[e.jsx("span",{children:r}),e.jsx("span",{className:xd,children:i.label?i.label.toUpperCase():i.shortcut.toUpperCase()})]})})));Ma.displayName="CommandBar.Command";function fd({table:a,rowSelection:t}){const r=Object.keys(t).length>0;return e.jsx(Ai,{open:r,children:e.jsxs(Si,{children:[e.jsxs(Ci,{children:[Object.keys(t).length," selected"]}),e.jsx(Pa,{}),e.jsx(Ma,{label:"Edit",action:()=>{console.log("Edit")},shortcut:{shortcut:"e"}}),e.jsx(Pa,{}),e.jsx(Ma,{label:"Delete",action:()=>{console.log("Delete")},shortcut:{shortcut:"d"}}),e.jsx(Pa,{}),e.jsx(Ma,{label:"Reset",action:()=>{a.resetRowSelection()},shortcut:{shortcut:"Escape",label:"esc"}})]})})}function yd({meta:a,table:t}){const r=S.useSearchParams(),s=S.useRouter(),i=S.usePathname(),n=Number((r==null?void 0:r.get("page"))||"1"),o=(g,x)=>{const f=new URLSearchParams(r==null?void 0:r.toString());return f.set(g,x),f.toString()},l=g=>{s.push(`${i}?${o("page",g.toString())}`)},c=[{icon:z.RiArrowLeftDoubleLine,onClick:()=>l(1),disabled:!(a!=null&&a.previousPage),srText:"First page",mobileView:"hidden sm:block"},{icon:z.RiArrowLeftSLine,onClick:()=>l(n-1),disabled:!(a!=null&&a.previousPage),srText:"Previous page",mobileView:""},{icon:z.RiArrowRightSLine,onClick:()=>l(n+1),disabled:!(a!=null&&a.nextPage),srText:"Next page",mobileView:""},{icon:z.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(I,{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"})]},x))})]})]})}function ca({meta:a,columns:t,error:r,data:s,loading:i,className:n,refetch:o}){var g,x;const l=V(),c=Z(),[m,u]=C.useState({}),p=fe.useReactTable({data:s,columns:t,state:{rowSelection:m},enableRowSelection:!0,getFilteredRowModel:fe.getFilteredRowModel(),onRowSelectionChange:u,getCoreRowModel:fe.getCoreRowModel(),getSortedRowModel:fe.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(ie,{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(nr,{children:[e.jsx(or,{children:p.getHeaderGroups().map(f=>e.jsx(Ue,{className:"border-y border-gray-200 dark:border-gray-800 back",children:f.headers.map(j=>{var y;return e.jsx(qe,{className:w("whitespace-nowrap py-1 text-sm sm:text-xs",(y=j.column.columnDef.meta)==null?void 0:y.className),children:fe.flexRender(j.column.columnDef.header,j.getContext())},j.id)})},f.id))}),e.jsxs(lr,{children:[r&&e.jsx(Ue,{children:e.jsx(De,{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(Ue,{className:"group select-none hover:bg-gray-50 dark:hover:bg-gray-900",children:f.getVisibleCells().map((j,y)=>{var b;return e.jsxs(De,{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",(b=j.column.columnDef.meta)==null?void 0:b.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"}),fe.flexRender(j.column.columnDef.cell,j.getContext())]},j.id)})},f.id)),((x=p.getRowModel().rows)==null?void 0:x.length)===0&&!i&&e.jsx(Ue,{children:e.jsx(De,{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(ie,{className:"w-10 h-10"}),e.jsx("p",{className:"text-gray-500 text-xs mt-1",children:"Loading..."})]})})]}),e.jsx(fd,{table:p,rowSelection:m})]}),a&&e.jsx(yd,{meta:a,table:p})]})})}const bd=Se.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",la,"[&::--webkit-search-cancel-button]:hidden [&::-webkit-search-cancel-button]:hidden [&::-webkit-search-decoration]:hidden"],variants:{hasError:{true:ht},enableStepper:{true:"[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none"}}}),ma=C.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(bd({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(z.RiSearchLine,{className:"size-[1.125rem] shrink-0","aria-hidden":"true"})})]}));ma.displayName="Searchbar";const Ce=h.forwardRef(({className:a,checked:t,...r},s)=>e.jsx(cr.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",ge,a),children:e.jsx(cr.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"})})})}));Ce.displayName="Checkbox";function B({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(z.RiArrowUpSLine,{className:w("size-3.5 text-gray-900 dark:text-gray-50",a.getIsSorted()==="desc"?"opacity-30":""),"aria-hidden":"true"}),e.jsx(z.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 Oe=de.Root;Oe.displayName="DropdownMenu";const Le=de.Trigger;Le.displayName="DropdownMenuTrigger";const ba=de.Group;ba.displayName="DropdownMenuGroup";const zi=de.Sub;zi.displayName="DropdownMenuSubMenu";const Ii=de.RadioGroup;Ii.displayName="DropdownMenuRadioGroup";const Ei=C.forwardRef(({className:a,children:t,...r},s)=>e.jsxs(de.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(z.RiArrowRightSLine,{className:"ml-auto size-4 shrink-0 text-gray-500","aria-hidden":"true"})]}));Ei.displayName="DropdownMenuSubMenuTrigger";const Di=C.forwardRef(({className:a,collisionPadding:t=8,...r},s)=>e.jsx(de.Portal,{children:e.jsx(de.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})}));Di.displayName="DropdownMenuSubMenuContent";const Je=C.forwardRef(({className:a,sideOffset:t=8,collisionPadding:r=8,align:s="center",loop:i=!0,...n},o)=>e.jsx(de.Portal,{children:e.jsx(de.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})}));Je.displayName="DropdownMenuContent";const be=C.forwardRef(({className:a,shortcut:t,hint:r,children:s,...i},n)=>e.jsxs(de.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})]}));be.displayName="DropdownMenuItem";const jd=C.forwardRef(({className:a,hint:t,shortcut:r,children:s,checked:i,...n},o)=>e.jsxs(de.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(de.ItemIndicator,{children:e.jsx(z.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})]}));jd.displayName="DropdownMenuCheckboxItem";const Ba=C.forwardRef(({className:a,hint:t,shortcut:r,children:s,iconType:i="radio",...n},o)=>e.jsxs(de.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(z.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(z.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(z.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})]}));Ba.displayName="DropdownMenuRadioItem";const vt=C.forwardRef(({className:a,...t},r)=>e.jsx(de.Label,{ref:r,className:w("px-2 py-2 text-xs font-medium tracking-wide","text-gray-500 dark:text-gray-500",a),...t}));vt.displayName="DropdownMenuLabel";const wd=C.forwardRef(({className:a,...t},r)=>e.jsx(de.Separator,{ref:r,className:w("-mx-1 my-1 h-px border-t border-gray-200 dark:border-gray-800",a),...t}));wd.displayName="DropdownMenuSeparator";const Ge=fe.createColumnHelper(),kd=[Ge.display({id:"select",header:({table:a})=>e.jsx(Ce,{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(Ce,{checked:a.getIsSelected(),onCheckedChange:()=>a.toggleSelected(),className:"translate-y-0.5","aria-label":"Select row"}),enableSorting:!1,enableHiding:!1,meta:{displayName:"Select"}}),Ge.accessor("id",{header:({column:a})=>e.jsx(B,{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(D,{href:((n=(i=t.options.meta)==null?void 0:i.routes)==null?void 0:n.manufacturerEdit(r,a.getValue("id")))??`/admin/${r}/manufacturers/${a.getValue("id")}`,className:"text-blue-500",children:a.getValue("id")})}}),Ge.accessor("name",{header:({column:a})=>e.jsx(B,{column:a,title:"Name"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"Owner"}}),Ge.accessor("translations",{header:({column:a})=>e.jsx(B,{column:a,title:"About"}),enableSorting:!1,meta:{className:"text-left",displayName:"Status"},cell:({row:a})=>{var t;return((t=a.getValue("translations").find(r=>r.about))==null?void 0:t.about)||"-"}}),Ge.accessor("createdAt",{header:({column:a})=>e.jsx(B,{column:a,title:"Created At"}),enableSorting:!1,meta:{className:"text-left",displayName:"Status"},cell:({row:a})=>{const t=a.getValue("createdAt");return new Date(t).toLocaleDateString()}}),Ge.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(Oe,{children:[e.jsx(Le,{asChild:!0,children:e.jsx(I,{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(z.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(Je,{align:"end",className:"min-w-40",children:[e.jsx(be,{children:e.jsx(D,{href:((n=(i=t.options.meta)==null?void 0:i.routes)==null?void 0:n.manufacturerEdit(r,a.getValue("id")))??`/admin/${r}/manufacturers/${a.getValue("id")}`,className:"block",children:"Edit"})}),e.jsx(be,{className:"text-red-600 dark:text-red-500",children:"Delete"})]})]})}})],vd=()=>{const{client:a}=E(),t=Z(),r=V(),s=S.useSearchParams(),[i,n]=h.useState(""),[o]=Te.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(I,{asChild:!0,className:"hidden gap-x-2 px-2 py-1.5 text-sm sm:text-xs lg:flex",children:e.jsxs(D,{href:t.manufacturerCreate(r),children:["Create Manufacturer",e.jsx(v.PlusIcon,{className:"size-4 shrink-0","aria-hidden":"true"})]})})})]}),e.jsx(ca,{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:kd,className:"mt-8"})]})};function Nd(){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(vd,{})})]})}const Ad=({organizationId:a,id:t,status:r,refetch:s})=>{var f;const{client:i}=E(),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=(f=n.variables)==null?void 0:f.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(v.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(v.CheckCircle,{className:"w-4 h-4 text-emerald-600 dark:text-emerald-500"})]})]})},Cd=({open:a,onOpenChange:t,order:r})=>{var n,o,l,c,m,u,p;if(!r)return null;const s=g=>new Intl.NumberFormat("en-US",{style:"currency",currency:r.currency||"PLN"}).format(g),i=g=>{switch(g){case"pending":return"yellow";case"accepted":return"blue";case"ready-for-dispatch":return"purple";case"dispatched":return"orange";case"completed":return"green";case"cancelled":return"red";default:return"gray"}};return e.jsx(yt,{open:a,onOpenChange:t,children:e.jsxs(bt,{className:"sm:max-w-3xl overflow-y-auto max-h-[85vh]",children:[e.jsxs(jt,{children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs(wt,{children:["Order Details #",r.referenceId]}),e.jsx(yi,{className:"rounded-full hover:bg-gray-200 p-1 dark:hover:bg-gray-800",children:e.jsx(v.X,{className:"h-5 w-5"})})]}),e.jsx(kt,{children:r.acceptedAt?`Ordered on ${T.format(new Date(r.acceptedAt),"MMMM dd, yyyy")}`:"Order details"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 mt-4",children:[e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 border border-gray-200 dark:border-gray-800",children:[e.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100 mb-3",children:"Order Status"}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Status"}),e.jsx(ea,{color:i(r.status||"pending"),variant:"neutral",children:r.status||"Pending"})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Accepted At"}),e.jsx("span",{children:r.acceptedAt?T.format(new Date(r.acceptedAt),"dd.MM.yyyy HH:mm"):"N/A"})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Ready For Dispatch"}),e.jsx("span",{children:r.readyForDispatchAt?T.format(new Date(r.readyForDispatchAt),"dd.MM.yyyy HH:mm"):"N/A"})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Dispatched At"}),e.jsx("span",{children:r.dispatchedAt?T.format(new Date(r.dispatchedAt),"dd.MM.yyyy HH:mm"):"N/A"})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Completed At"}),e.jsx("span",{children:r.completedAt?T.format(new Date(r.completedAt),"dd.MM.yyyy HH:mm"):"N/A"})]})]})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 border border-gray-200 dark:border-gray-800",children:[e.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100 mb-3",children:"Payment Information"}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Method"}),e.jsx("span",{className:"font-medium",children:((n=r.payment)==null?void 0:n.method)||"N/A"})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Provider"}),e.jsx("span",{children:((o=r.payment)==null?void 0:o.provider)||"N/A"})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Status"}),e.jsx(ea,{color:((l=r.payment)==null?void 0:l.status)==="succeeded"?"green":"yellow",variant:"neutral",children:((c=r.payment)==null?void 0:c.status)||"Pending"})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Total Amount"}),e.jsx("span",{className:"font-bold",children:s(Number((m=r.payment)==null?void 0:m.total)||0)})]})]})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 border border-gray-200 dark:border-gray-800",children:[e.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100 mb-3",children:r.fulfilmentMethod==="pickup"?"Pickup Details":"Shipping Address"}),r.shippingAddress?e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("p",{className:"font-medium",children:[r.shippingAddress.firstname," ",r.shippingAddress.lastname]}),e.jsxs("p",{children:[r.shippingAddress.addressLineOne,r.shippingAddress.doorNumber?`, ${r.shippingAddress.doorNumber}`:""]}),e.jsxs("p",{children:[r.shippingAddress.zipCode,", ",r.shippingAddress.city]}),e.jsx("p",{children:r.shippingAddress.country}),r.shippingAddress.phone&&e.jsxs("p",{className:"mt-2",children:["Phone: ",r.shippingAddress.phone]})]}):e.jsx("p",{className:"text-gray-500",children:"No address information available"})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 border border-gray-200 dark:border-gray-800",children:[e.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100 mb-3",children:"Fulfilment Details"}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Fulfilment Method"}),e.jsx(ea,{color:"blue",variant:"neutral",children:r.fulfilmentMethod||"N/A"})]}),r.fulfilmentMethod==="delivery"&&e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Shipping Method"}),e.jsx("span",{children:((u=r.shippingMethod)==null?void 0:u.title)||"Standard Shipping"})]})]})]})]}),e.jsxs("div",{className:"mt-6 bg-gray-50 dark:bg-gray-900 rounded-lg p-4 border border-gray-200 dark:border-gray-800",children:[e.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100 mb-3",children:"Order Items"}),e.jsx("div",{className:"divide-y divide-gray-200 dark:divide-gray-800",children:r.items.map((g,x)=>{const f=g.translations.find(j=>j.locale==="en")||g.translations[0];return e.jsxs("div",{className:"py-3 flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[g.image&&e.jsx("div",{className:"h-16 w-16 rounded overflow-hidden shrink-0",children:e.jsx("img",{src:g.image.url,alt:(f==null?void 0:f.title)||"Product",className:"h-full w-full object-cover"})}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium",children:(f==null?void 0:f.title)||"Product"}),(f==null?void 0:f.subtitle)&&e.jsx("p",{className:"text-sm text-gray-500",children:f.subtitle}),e.jsxs("p",{className:"text-sm mt-1",children:[s(g.unitPrice)," × ",g.quantity]})]})]}),e.jsx("div",{className:"font-medium",children:s(g.totalPrice)})]},x)})}),e.jsx("div",{className:"mt-4 pt-4 border-t border-gray-200 dark:border-gray-800",children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"font-medium",children:"Total"}),e.jsx("span",{className:"font-bold text-lg",children:s(Number((p=r.payment)==null?void 0:p.total)||0)})]})})]})]})})},Sd=({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(Cd,{open:t,onOpenChange:r,order:a})]})},zd=({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(Ad,{organizationId:s,id:a.id,status:a.status,refetch:i})},Pe=fe.createColumnHelper(),Id=[Pe.accessor("id",{header:({column:a})=>e.jsx(B,{column:a,title:"ID"}),meta:{className:"text-left",displayName:"ID"},cell:({row:a})=>e.jsx(Sd,{order:a.original}),enableSorting:!0,enableHiding:!1}),Pe.accessor("referenceId",{header:({column:a})=>e.jsx(B,{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}),Pe.display({id:"customer",meta:{className:"text-left",displayName:"ID"},header:({column:a})=>e.jsx(B,{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"})}}),Pe.accessor("payment.total",{meta:{className:"text-left",displayName:"ID"},enableSorting:!0,enableHiding:!1,header:({column:a})=>e.jsx(B,{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})}}),Pe.accessor("createdAt",{meta:{className:"text-left",displayName:"ID"},enableSorting:!0,enableHiding:!1,header:({column:a})=>e.jsx(B,{column:a,title:"Date & Time"}),cell:({row:a})=>{const t=a.getValue("createdAt");return t?T.format(new Date(t),"dd.MM.yyyy HH:mm"):"N/A"}}),Pe.display({id:"paymentMethod",header:({column:a})=>e.jsx(B,{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"})}}),Pe.display({id:"address",meta:{className:"text-left",displayName:"ID"},header:({column:a})=>e.jsx(B,{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]})]})}}),Pe.display({id:"status",header:({column:a})=>e.jsx(B,{column:a,title:"Actions"}),cell:({row:a,table:t})=>e.jsx(zd,{order:a.original,table:t})})],Ed=()=>{const{client:a}=E(),t=V(),r=S.useSearchParams(),[s,i]=h.useState(""),[n]=Te.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(ca,{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:Id,className:"mt-8",refetch:p})]})};function Dd(){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(Ed,{})})]})}const Fi=({onClose:a,initialData:t})=>{var m;const{client:r}=E(),s=L.useForm({resolver:ce.zodResolver(t?Ot:xs),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 ae.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 ae.invalidateQueries({queryKey:["organizations"]}),a&&a()}}),c=u=>{t?l.mutate(u):o.mutate(u)};return e.jsx("div",{className:"mt-6",children:e.jsx(L.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(oe,{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(ke,{name:"name",label:"Organization Name",placeholder:"Acme Inc.",className:"col-span-2"}),e.jsx(ke,{name:"email",type:"email",label:"Support Email",placeholder:"john.doe@example.com",className:"col-span-2"}),e.jsx(ke,{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(pt,{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(ke,{name:"address.addressLineTwo",label:"Door / Address Line 2",placeholder:"Apt 123",className:"col-span-2"}),e.jsx(ke,{name:"address.zipCode",label:"Postal Code",placeholder:"12345",className:"col-span-2"}),e.jsx(ke,{name:"address.city",label:"City",placeholder:"New York",className:"col-span-2"}),e.jsx(ke,{name:"address.country",label:"Country",placeholder:"United States",className:"col-span-2",type:"country"}),e.jsx(ke,{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(I,{type:"button",className:"w-full sm:w-fit",variant:"secondary",onClick:a,children:"Cancel"}),e.jsx(I,{type:"submit",className:"w-full sm:w-fit",isLoading:o.isPending||l.isPending,loadingText:"Saving...",children:t?"Update Data":"Create Organization"})]})]})})})},Fd=({invitation:a})=>{var s;const{client:t}=E(),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()=>{Q.success(`Joined ${a.organization.name}`),await ae.invalidateQueries({queryKey:["organizations"]}),await ae.invalidateQueries({queryKey:["user-invitations"]})},onError:i=>{Q.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(v.CheckIcon,{className:"w-5 h-5"})})})]})]})},Rd=()=>{const[a,t]=h.useState(!1),r=Z(),{client:s}=E(),{organizations:i}=he(),{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(I,{onClick:()=>t(!0),variant:"primary",children:[e.jsx(v.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(Fd,{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(xe,{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(D,{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(v.ArrowRight,{className:"w-5 h-5"})})})]})]},l.id)})]})]}),e.jsxs(yt,{onOpenChange:o,open:a,children:[e.jsx(fi,{className:"w-full text-left"}),e.jsxs(bt,{className:"sm:max-w-xl",children:[e.jsxs(jt,{children:[e.jsx(wt,{children:"Create a Organization"}),e.jsx(kt,{className:"mt-1 text-sm leading-6",children:"Fill in the details below to create a new organization"})]}),e.jsx(Fi,{onClose:o})]})]})]})};function Pd(){const{appearance:a}=Vr(),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(xe,{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(Rd,{})})})]})}const $a=ee.Root;$a.displayName="Select";const Md=ee.Group;Md.displayName="SelectGroup";const _a=ee.Value;_a.displayName="SelectValue";const Bd=[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",la)],Wa=h.forwardRef(({className:a,hasError:t,children:r,...s},i)=>e.jsxs(ee.Trigger,{ref:i,className:w(Bd,t?ht:"",a),...s,children:[e.jsx("span",{className:"truncate",children:r}),e.jsx(ee.Icon,{asChild:!0,children:e.jsx(z.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")})})]}));Wa.displayName="SelectTrigger";const Ri=h.forwardRef(({className:a,...t},r)=>e.jsx(ee.ScrollUpButton,{ref:r,className:w("flex cursor-default items-center justify-center py-1",a),...t,children:e.jsx(z.RiArrowUpSLine,{className:"size-3 shrink-0","aria-hidden":"true"})}));Ri.displayName=ee.ScrollUpButton.displayName;const Pi=h.forwardRef(({className:a,...t},r)=>e.jsx(ee.ScrollDownButton,{ref:r,className:w("flex cursor-default items-center justify-center py-1",a),...t,children:e.jsx(z.RiArrowDownSLine,{className:"size-3 shrink-0","aria-hidden":"true"})}));Pi.displayName=ee.ScrollDownButton.displayName;const Ga=h.forwardRef(({className:a,position:t="popper",children:r,sideOffset:s=8,collisionPadding:i=10,...n},o)=>e.jsx(ee.Portal,{children:e.jsxs(ee.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(Ri,{}),e.jsx(ee.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(Pi,{})]})}));Ga.displayName="SelectContent";const Td=h.forwardRef(({className:a,...t},r)=>e.jsx(ee.Label,{ref:r,className:w("px-3 py-2 text-xs font-medium tracking-wide","text-gray-500 dark:text-gray-500",a),...t}));Td.displayName="SelectGroupLabel";const Fe=h.forwardRef(({className:a,children:t,...r},s)=>e.jsxs(ee.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(ee.ItemText,{className:"flex-1 truncate",children:t}),e.jsx(ee.ItemIndicator,{children:e.jsx(z.RiCheckLine,{className:"size-5 shrink-0 text-gray-800 dark:text-gray-200","aria-hidden":"true"})})]}));Fe.displayName="SelectItem";const Qd=h.forwardRef(({className:a,children:t,period:r,...s},i)=>e.jsxs(ee.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(ee.ItemIndicator,{children:e.jsx(z.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(ee.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:[T.format(r.from,"MMM d, yyyy")," –"," ",T.format(r.to,"MMM d, yyyy")]})})]})]}));Qd.displayName="SelectItemPeriod";const Od=h.forwardRef(({className:a,...t},r)=>e.jsx(ee.Separator,{ref:r,className:w("-mx-1 my-1 h-px","bg-gray-300 dark:bg-gray-700",a),...t}));Od.displayName="SelectSeparator";const Ve=fe.createColumnHelper(),Ld=({row:a,table:t})=>{var c,m;const{client:r}=E(),s=a.getValue("publishedAt"),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.updateStatus({params:{id:a.getValue("id"),organizationId:i,operation:s?"unpublish":"publish"}})).status!==200)throw new Error("Failed to update product category status");n&&await n()}}),l=()=>{o.mutate()};return o.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(ie,{className:"w-4 h-4"})," Saving..."]})}):e.jsx("div",{className:"min-w-28",children:e.jsxs("button",{onClick:l,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:[s?e.jsx(v.CheckCircle,{className:"w-4 h-4 text-emerald-600 dark:text-emerald-500"}):e.jsx(v.EyeOffIcon,{className:"w-4 h-4 text-red-600 dark:text-red-500"}),s?"Published":"Draft"]})})},Jd=({row:a,table:t})=>{var l,c,m,u;const{client:r}=E(),s=(l=t.options.meta)==null?void 0:l.organizationId,i=(c=t.options.meta)==null?void 0:c.refetch,n=A.useMutation({mutationFn:async()=>{if((await r.productCategory.deleteProductCategory({params:{id:a.getValue("id"),organizationId:s}})).status!==204)throw new Error("Failed to delete product category");i&&await i()}}),o=()=>{window.confirm("Are you sure you want to delete this product category? This action cannot be undone.")&&n.mutate()};return e.jsxs(Oe,{children:[e.jsx(Le,{asChild:!0,children:e.jsx(I,{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:n.isPending,children:n.isPending?e.jsx(ie,{className:"size-4 shrink-0"}):e.jsx(z.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(Je,{align:"end",className:"min-w-40",children:[e.jsx(be,{children:e.jsxs(D,{href:((u=(m=t.options.meta)==null?void 0:m.routes)==null?void 0:u.productCategoryEdit(s,a.getValue("id")))??`/admin/${s}/product-categories/${a.getValue("id")}`,className:"block flex items-center gap-2",children:[e.jsx(v.PencilIcon,{className:"w-4 h-4"}),"Edit"]})}),e.jsx(be,{className:"text-red-600 dark:text-red-500 cursor-pointer",onClick:o,disabled:n.isPending,children:e.jsxs("div",{className:"flex items-center gap-2",children:[n.isPending?e.jsx(ie,{className:"w-4 h-4"}):e.jsx(v.Trash2,{className:"w-4 h-4"}),n.isPending?"Deleting...":"Delete"]})})]})]})},Vd=[Ve.display({id:"select",header:({table:a})=>e.jsx(Ce,{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(Ce,{checked:a.getIsSelected(),onCheckedChange:()=>a.toggleSelected(),className:"translate-y-0.5","aria-label":"Select row"}),enableSorting:!1,enableHiding:!1,meta:{displayName:"Select"}}),Ve.accessor("id",{header:({column:a})=>e.jsx(B,{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(D,{href:((n=(i=t.options.meta)==null?void 0:i.routes)==null?void 0:n.productCategoryEdit(r,a.getValue("id")))??`/admin/${r}/product-categories/${a.getValue("id")}`,className:"text-blue-500",children:a.getValue("id")})}}),Ve.accessor("slug",{header:({column:a})=>e.jsx(B,{column:a,title:"Slug"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"Slug"}}),Ve.accessor("title",{header:({column:a})=>e.jsx(B,{column:a,title:"Title"}),enableSorting:!1,meta:{className:"text-left",displayName:"Name"}}),Ve.accessor("publishedAt",{header:({column:a})=>e.jsx(B,{column:a,title:"Status"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"Status"},cell:({row:a,table:t})=>e.jsx(Ld,{row:a,table:t})}),Ve.accessor("createdAt",{header:({column:a})=>e.jsx(B,{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()}}),Ve.display({id:"edit",header:"Edit",enableSorting:!1,enableHiding:!1,meta:{className:"text-right",displayName:"Edit"},cell:({row:a,table:t})=>e.jsx(Jd,{row:a,table:t})})],Hd=()=>{const{client:a}=E(),t=Z(),{defaultLocale:r}=he(),s=V(),i=S.usePathname(),n=S.useRouter(),o=S.useSearchParams(),[l,c]=h.useState(""),[m,u]=h.useState("all"),p=Number((o==null?void 0:o.get("page"))||"1"),[g]=Te.useDebounce(l,300),x=m==="all"?void 0:m,f=(O,F)=>{const q=new URLSearchParams(o==null?void 0:o.toString());return q.set(O,F),q.toString()},j=()=>{p!==1&&n.replace(`${i}?${f("page","1")}`)},{isLoading:y,isRefetching:b,isError:k,data:N,refetch:R}=A.useQuery({queryKey:["productCategories",s,p,g,x,r],queryFn:async()=>{const{body:O,status:F}=await a.productCategory.getProductCategories({params:{organizationId:s},query:{page:p,limit:10,search:g,locale:r,publishedStatus:x}});if(F!==200)throw new Error("Failed to fetch product categories");return O},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:O=>{c(O.target.value),j()},className:"w-full sm:max-w-[250px] sm:[&>input]:h-[40px]"}),e.jsxs($a,{value:m,onValueChange:O=>{u(O),j()},children:[e.jsx(Wa,{className:"w-full sm:w-[190px]",children:e.jsx(_a,{placeholder:"All statuses"})}),e.jsxs(Ga,{children:[e.jsx(Fe,{value:"all",children:"All statuses"}),e.jsx(Fe,{value:"published",children:"Published"}),e.jsx(Fe,{value:"unpublished",children:"Unpublished"})]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(I,{asChild:!0,className:"hidden gap-x-2 px-2 py-1.5 text-sm sm:text-xs lg:flex",children:e.jsxs(D,{href:t.productCategoryCreate(s),children:["Create Product Category",e.jsx(v.PlusIcon,{className:"size-4 shrink-0","aria-hidden":"true"})]})})})]}),e.jsx(ca,{error:k,loading:y||b,meta:N==null?void 0:N.meta,data:(N==null?void 0:N.list)||[],columns:Vd,className:"mt-8",refetch:R})]})};function qd(){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(Hd,{})})]})}const Ud=[{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"}],Mi=({initialData:a})=>{const{client:t}=E(),r=S.useRouter(),s=Z(),i=V(),{defaultLocale:n,supportedLocales:o}=he(),l=a?$n:Zn,c=L.useForm({resolver:ce.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 y;const f={slug:x.slug,defaultLocale:x.defaultLocale,translations:x.translations,imageId:(y=x.image)==null?void 0:y.id},{status:j}=await t.productCategory.createProductCategory({params:{organizationId:i},body:f});if(j!==201)throw Q.error("Failed to create product category. Please try again later."),new Error("Failed to create product category")}}),u=A.useMutation({mutationFn:async x=>{var y;const f={slug:x.slug,defaultLocale:x.defaultLocale,translations:x.translations,imageId:((y=x.image)==null?void 0:y.id)||null},{status:j}=await t.productCategory.updateProductCategory({params:{organizationId:i,id:a.id},body:f});if(j!==200)throw Q.error("Failed to update product category. Please try again later."),new Error("Failed to update product category")}}),p=async()=>{Q.success("Product category saved successfully"),r.push(s.productCategories(i)),await ae.invalidateQueries({queryKey:["productCategories"]})},g=x=>{a?u.mutate(x,{onSuccess:p}):m.mutate(x,{onSuccess:p})};return e.jsx(Ne,{form:c,config:Ud,onSubmit:g,loading:m.isPending||u.isPending,cancelText:"Go back",okText:a?"Update Product Category":"Create Product Category"})};function Zd(){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(J,{}),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(Mi,{})})]})})})})]})}function $d(){const a=V(),t=da(),{client:r}=E(),{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 Q.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(J,{}),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(ie,{className:"w-12 h-12"}),e.jsx("p",{className:"text-gray-500 text-sm mt-3",children:"Loading data..."})]})}):e.jsx(Mi,{initialData:i})})]})})})})]})}const _d=({form:a})=>{const{client:t}=E(),r=V(),{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(Ne,{form:a,config:n})})]})})},Wd=({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(le,{htmlFor:`metadata-key-${c}`,className:"font-medium",children:"Key"}),e.jsx(oe,{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(oe,{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(I,{type:"button",variant:"destructive",className:"mt-8 min-w-[42px] h-[42px] p-0",onClick:()=>n(c),children:e.jsx(v.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(I,{type:"button",variant:"secondary",onClick:i,className:"w-full shadow-none mt-2",children:[e.jsx(v.PlusIcon,{className:"w-4 h-4 mr-2"}),"Add Row"]})]})})]})})},Gd=({open:a,onClose:t,initialData:r,onSubmit:s})=>{const{defaultLocale:i,supportedLocales:n}=he(),o=L.useForm({resolver:ce.zodResolver(os),defaultValues:r?{...r,defaultLocale:i}:{defaultLocale:i,translations:n.map(p=>({locale:p,title:""})),modifiers:[{title:"",price:0}]}}),{fields:l,append:c,remove:m}=L.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(yt,{open:a,onOpenChange:t,children:e.jsxs(bt,{className:"max-w-[710px]",children:[e.jsxs(jt,{children:[e.jsx(wt,{children:"New Modifier Group"}),e.jsx(kt,{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(L.FormProvider,{...o,children:[e.jsx(Ne,{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(Ne,{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(I,{type:"button",variant:"destructive",className:"mt-auto ml-4 min-w-[42px] h-[42px] p-0! shadow-none!",onClick:()=>m(g),children:e.jsx(v.XIcon,{className:"w-4 h-4"})})]},p.id)),e.jsx(I,{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(J,{className:"mt-8 mb-6"}),e.jsxs("div",{className:"flex justify-end space-x-3 mt-6 col-span-full",children:[e.jsx(I,{type:"button",className:"w-full sm:w-fit",variant:"secondary",onClick:t,children:"Cancel"}),e.jsx(I,{type:"button",className:"w-full sm:w-fit",onClick:o.handleSubmit(u),children:r?"Save Modifier Group":"Create Modifier Group"})]})]})]})})},Kd=({form:a})=>{const{control:t}=a,{defaultLocale:r}=he(),{fields:s,append:i,remove:n,update:o}=L.useFieldArray({control:t,name:"modifierGroups"}),[l,c]=h.useState(!1),[m,u]=h.useState(null),p=y=>({...y,defaultLocale:y.defaultLocale??r,modifiers:y.modifiers??[]}),g=y=>{y.preventDefault(),u(null),c(!0)},x=y=>{u(y),c(!0)},f=y=>{if(m===null){i(p(y)),c(!1);return}o(m,p(y)),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(I,{type:"button",variant:"secondary",className:"shadow-none",onClick:j,children:[e.jsx(v.BookCopyIcon,{className:"w-4 h-4 mr-2"})," Add From Template"]}),e.jsxs(I,{type:"button",variant:"secondary",className:"shadow-none",onClick:g,children:[e.jsx(v.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(I,{type:"button",variant:"secondary",className:"shadow-none",onClick:j,children:[e.jsx(v.BookCopyIcon,{className:"w-4 h-4 mr-2"})," Add From Template"]}),e.jsxs(I,{type:"button",variant:"secondary",className:"shadow-none",onClick:g,children:[e.jsx(v.PlusIcon,{className:"w-4 h-4 mr-2"})," Create Modifier Group"]})]}),e.jsx("div",{className:"space-y-4",children:s.map((y,b)=>{var k;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:()=>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: ",y.selectMin," | Max: ",y.selectMax]}),e.jsxs("p",{className:"text-sm text-gray-500 mt-1",children:["Available Options:"," ",(k=y.modifiers)==null?void 0:k.map(N=>N==null?void 0:N.title).join(",")]})]},y.id)})})]})})]}),e.jsx(Gd,{open:l,initialData:m===null?null:s[m],onSubmit:f,onClose:()=>{c(!1),u(null)}},m)]})},Xd=({form:a,loading:t})=>{const{defaultCurrency:r}=he(),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}];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.jsx("div",{className:"md:col-span-2",children:e.jsx(Ne,{form:a,config:s,loading:t})})]})})},Bi=({initialData:a})=>{var j,y;const{client:t}=E(),r=S.useRouter(),s=Z(),i=V(),{defaultCurrency:n,defaultLocale:o,supportedLocales:l}=he(),c=a==null?void 0:a.id,m=a?Kn:Gn,u=L.useForm({resolver:ce.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:(y=a.modifierGroups)==null?void 0:y.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:k}=await t.product.createProduct({params:{organizationId:i},body:b});if(k!==201)throw new Error("Failed to create product")}}),g=A.useMutation({mutationFn:async b=>{const{status:k}=await t.product.updateProduct({params:{organizationId:i,id:c},body:b});if(k!==200)throw new Error("Failed to update product")}}),x=async()=>{Q.success("Product saved successfully"),r.push(s.products(i)),await ae.invalidateQueries({queryKey:["products"]}),c&&await ae.invalidateQueries({queryKey:["product",i,c]})},f=b=>{a?g.mutate(b,{onSuccess:x}):p.mutate(b,{onSuccess:x})};return e.jsx(L.FormProvider,{...u,children:e.jsxs("form",{onSubmit:u.handleSubmit(b=>f(b)),className:"space-y-14",children:[e.jsx(_d,{form:u}),e.jsx(J,{}),e.jsx(Xd,{form:u}),e.jsx(J,{}),e.jsx(Kd,{form:u}),e.jsx(J,{}),e.jsx(Wd,{form:u}),e.jsx(J,{}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsxs(I,{type:"button",variant:"secondary",onClick:()=>r.push(s.products(i)),children:[e.jsx(v.ChevronLeft,{className:"w-4 h-4 mr-2"})," Cancel"]}),e.jsxs(I,{type:"submit",isLoading:p.isPending||g.isPending,loadingText:"Saving...",children:[e.jsx(v.CheckIcon,{className:"w-4 h-4 mr-2"})," ",a?"Save Product":"Create Product"]})]})]})})};function Yd(){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(J,{}),e.jsx("div",{className:"pt-6",children:e.jsx("div",{className:"space-y-10",children:e.jsx(Bi,{})})})]})}function ec(){const a=V(),t=da(),{client:r}=E(),{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 Q.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(J,{}),i?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ie,{className:"w-8 h-8"})}):e.jsx("div",{className:"pt-6",children:e.jsx(Bi,{initialData:s})})]})}const Ie=fe.createColumnHelper(),ac=({row:a,table:t})=>{var c;const{client:r}=E(),s=a.getValue("publishedAt"),i=(c=t.options.meta)==null?void 0:c.organizationId,n=t.options.meta.refetch,o=A.useMutation({mutationFn:async()=>{if((await r.product.updateStatus({params:{id:a.getValue("id"),organizationId:i,operation:s?"unpublish":"publish"}})).status!==200)throw new Error("Failed to update product status");await n()}}),l=()=>{o.mutate()};return o.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(ie,{className:"w-4 h-4"})," Saving..."]})}):e.jsx("div",{className:"min-w-28",children:e.jsxs("button",{onClick:l,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:[s?e.jsx(v.CheckCircle,{className:"w-4 h-4 text-emerald-600 dark:text-emerald-500"}):e.jsx(v.EyeOffIcon,{className:"w-4 h-4 text-red-600 dark:text-red-500"}),s?"Published":"Draft"]})})},tc=({row:a,table:t})=>{var l,c,m;const{client:r}=E(),s=(l=t.options.meta)==null?void 0:l.organizationId,i=t.options.meta.refetch,n=A.useMutation({mutationFn:async()=>{if((await r.product.deleteProduct({params:{id:a.getValue("id"),organizationId:s}})).status!==204)throw new Error("Failed to delete product");await i()}}),o=()=>{window.confirm("Are you sure you want to delete this product? This action cannot be undone.")&&n.mutate()};return e.jsxs(Oe,{children:[e.jsx(Le,{asChild:!0,children:e.jsx(I,{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:n.isPending,children:n.isPending?e.jsx(ie,{className:"size-4 shrink-0"}):e.jsx(z.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(Je,{align:"end",className:"min-w-40",children:[e.jsx(be,{children:e.jsxs(D,{href:((m=(c=t.options.meta)==null?void 0:c.routes)==null?void 0:m.productEdit(s,a.getValue("id")))??`/admin/${s}/products/${a.getValue("id")}`,className:"block flex items-center gap-2",children:[e.jsx(v.PencilIcon,{className:"w-4 h-4"}),"Edit"]})}),e.jsx(be,{className:"text-red-600 dark:text-red-500 cursor-pointer",onClick:o,disabled:n.isPending,children:e.jsxs("div",{className:"flex items-center gap-2",children:[n.isPending?e.jsx(ie,{className:"w-4 h-4"}):e.jsx(v.Trash2,{className:"w-4 h-4"}),n.isPending?"Deleting...":"Delete"]})})]})]})},rc=[Ie.display({id:"select",header:({table:a})=>e.jsx(Ce,{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(Ce,{checked:a.getIsSelected(),onCheckedChange:()=>a.toggleSelected(),className:"translate-y-0.5","aria-label":"Select row"}),enableSorting:!1,enableHiding:!1,meta:{displayName:"Select"}}),Ie.accessor("id",{header:({column:a})=>e.jsx(B,{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(D,{href:((n=(i=t.options.meta)==null?void 0:i.routes)==null?void 0:n.productEdit(r,a.getValue("id")))??`/admin/${r}/products/${a.getValue("id")}`,className:"text-blue-500",children:a.getValue("id")})}}),Ie.accessor("title",{header:({column:a})=>e.jsx(B,{column:a,title:"Title"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"Slug"}}),Ie.accessor("sku",{header:({column:a})=>e.jsx(B,{column:a,title:"SKU"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"SKU"},cell:({row:a})=>a.getValue("sku")||"-"}),Ie.accessor("basePrice",{header:({column:a})=>e.jsx(B,{column:a,title:"Base Price"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"Base Price"},cell:({row:a})=>`$${a.getValue("basePrice").toFixed(2)}`}),Ie.accessor("discountedBasePrice",{header:({column:a})=>e.jsx(B,{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 t?`$${t.toFixed(2)}`:"-"}}),Ie.accessor("publishedAt",{header:({column:a})=>e.jsx(B,{column:a,title:"Status"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"Slug"},cell:({row:a,table:t})=>e.jsx(ac,{row:a,table:t})}),Ie.accessor("createdAt",{header:({column:a})=>e.jsx(B,{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()}}),Ie.display({id:"edit",header:"Edit",enableSorting:!1,enableHiding:!1,meta:{className:"text-right",displayName:"Edit"},cell:({row:a,table:t})=>e.jsx(tc,{row:a,table:t})})],sc=()=>{const{client:a}=E(),t=Z(),{defaultLocale:r}=he(),s=V(),i=S.usePathname(),n=S.useRouter(),o=S.useSearchParams(),[l,c]=h.useState(""),[m,u]=h.useState("all"),[p,g]=h.useState("all"),[x]=Te.useDebounce(l,300),f=Number((o==null?void 0:o.get("page"))||"1"),j=m==="all"?void 0:m,y=p==="all"?void 0:p,b=(P,H)=>{const je=new URLSearchParams(o==null?void 0:o.toString());return je.set(P,H),je.toString()},k=()=>{f!==1&&n.replace(`${i}?${b("page","1")}`)},{data:N=[]}=A.useQuery({queryKey:["productCategoriesFilter",s,r],queryFn:async()=>{const{body:P,status:H}=await a.productCategory.getProductCategories({params:{organizationId:s},query:{limit:100,locale:r}});if(H!==200)throw new Error("Failed to fetch product categories");return P.list.map(je=>({label:je.title||"Untitled category",value:je.id}))},placeholderData:[]}),{isLoading:R,isRefetching:O,isError:F,data:q,refetch:te}=A.useQuery({queryKey:["products",s,f,x,j,y,r],queryFn:async()=>{const{body:P,status:H}=await a.product.getProducts({params:{organizationId:s},query:{page:f,limit:10,search:x,locale:r,categoryId:j,publishedStatus:y}});if(H!==200)throw new Error("Failed to fetch products");return P},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:P=>{c(P.target.value),k()},className:"w-full sm:max-w-[250px] sm:[&>input]:h-[40px]"}),e.jsxs($a,{value:m,onValueChange:P=>{u(P),k()},children:[e.jsx(Wa,{className:"w-full sm:w-[220px]",children:e.jsx(_a,{placeholder:"All categories"})}),e.jsxs(Ga,{children:[e.jsx(Fe,{value:"all",children:"All categories"}),N.map(P=>e.jsx(Fe,{value:P.value,children:P.label},P.value))]})]}),e.jsxs($a,{value:p,onValueChange:P=>{g(P),k()},children:[e.jsx(Wa,{className:"w-full sm:w-[190px]",children:e.jsx(_a,{placeholder:"All statuses"})}),e.jsxs(Ga,{children:[e.jsx(Fe,{value:"all",children:"All statuses"}),e.jsx(Fe,{value:"published",children:"Published"}),e.jsx(Fe,{value:"unpublished",children:"Unpublished"})]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(I,{asChild:!0,className:"hidden gap-x-2 px-2 py-1.5 text-sm sm:text-xs lg:flex",children:e.jsxs(D,{href:t.productCreate(s),children:["Create Product",e.jsx(v.PlusIcon,{className:"size-4 shrink-0","aria-hidden":"true"})]})})})]}),e.jsx(ca,{error:F,loading:R||O,meta:q!=null&&q.meta?{...q==null?void 0:q.meta,currentPage:f}:void 0,data:(q==null?void 0:q.list)||[],columns:rc,className:"mt-8",refetch:te})]})};function ic(){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(sc,{})})]})}const nc=({organizationId:a,id:t,acceptedAt:r,cancelledAt:s,refetch:i})=>{var j;const{client:n}=E(),o=A.useMutation({mutationFn:async({operation:y})=>{if((await n.reservation.updateReservationStatus({params:{organizationId:a,reservationId:t,operation:y},body:{}})).status!==200)throw new Error("Failed to update reservation status");return i()}}),l=()=>{o.mutate({operation:"accept"})},c=()=>{o.mutate({operation:"cancel"})},m=o.isPending,u=(j=o.variables)==null?void 0:j.operation,p=m&&u==="cancel",g=m&&u==="accept",x=!r&&!s,f=!s;return e.jsxs("div",{className:"flex items-center gap-2 min-w-28 min-h-[45px]",children:[f&&e.jsxs("button",{onClick:c,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",children:[p?"Loading...":"Cancel",e.jsx(v.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",children:[g?"Loading...":"Accept",e.jsx(v.CheckCircle,{className:"w-4 h-4 text-emerald-600 dark:text-emerald-500"})]})]})},oc=({open:a,onOpenChange:t,reservation:r})=>e.jsx(ka,{open:a,onOpenChange:t,children:e.jsxs(va,{className:"sm:max-w-[500px] overflow-y-auto max-h-[85vh]",children:[e.jsx(Jt,{children:e.jsx(ot,{children:"Reservation Details"})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 py-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:"Reference ID"}),e.jsx("p",{className:"text-sm font-medium",children:r.referenceId})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:"Status"}),e.jsx("p",{className:"text-sm font-medium",children:r.cancelledAt?"Cancelled":r.acceptedAt?"Accepted":"Pending"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:"Customer Name"}),e.jsx("p",{className:"text-sm font-medium",children:`${r.firstname} ${r.lastname}`})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:"Phone"}),e.jsx("p",{className:"text-sm font-medium",children:r.phone||"N/A"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:"Number of Guests"}),e.jsx("p",{className:"text-sm font-medium",children:r.guests})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:"Reservation Date"}),e.jsx("p",{className:"text-sm font-medium",children:r.date?T.format(new Date(r.date),"PPpp"):"N/A"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:"Created At"}),e.jsx("p",{className:"text-sm font-medium",children:r.createdAt?T.format(new Date(r.createdAt),"PPpp"):"N/A"})]}),r.acceptedAt&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:"Accepted At"}),e.jsx("p",{className:"text-sm font-medium",children:T.format(new Date(r.acceptedAt),"PPpp")})]}),r.cancelledAt&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:"Cancelled At"}),e.jsx("p",{className:"text-sm font-medium",children:T.format(new Date(r.cancelledAt),"PPpp")})]})]})]})}),lc=({reservation: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(oc,{open:t,onOpenChange:r,reservation:a})]})},dc=({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(nc,{organizationId:s,id:a.id,acceptedAt:a.acceptedAt,cancelledAt:a.cancelledAt,refetch:i})},Ee=fe.createColumnHelper(),cc=[Ee.accessor("id",{header:({column:a})=>e.jsx(B,{column:a,title:"ID"}),meta:{className:"text-left",displayName:"ID"},cell:({row:a})=>e.jsx(lc,{reservation:a.original}),enableSorting:!0,enableHiding:!1}),Ee.accessor("referenceId",{header:({column:a})=>e.jsx(B,{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}),Ee.display({id:"customer",meta:{className:"text-left",displayName:"Customer"},header:({column:a})=>e.jsx(B,{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"})}}),Ee.accessor("guests",{meta:{className:"text-left",displayName:"Guests"},enableSorting:!0,enableHiding:!1,header:({column:a})=>e.jsx(B,{column:a,title:"Guests"}),cell:({row:a})=>e.jsx("div",{className:"font-medium",children:a.original.guests})}),Ee.accessor("phone",{meta:{className:"text-left",displayName:"Phone"},enableSorting:!1,enableHiding:!1,header:({column:a})=>e.jsx(B,{column:a,title:"Phone"}),cell:({row:a})=>e.jsx("div",{children:a.original.phone||"N/A"})}),Ee.accessor("date",{meta:{className:"text-left",displayName:"Reservation Date"},enableSorting:!0,enableHiding:!1,header:({column:a})=>e.jsx(B,{column:a,title:"Reservation Date"}),cell:({row:a})=>{const t=a.getValue("date");return t?T.format(new Date(t),"dd.MM.yyyy HH:mm"):"N/A"}}),Ee.accessor("createdAt",{meta:{className:"text-left",displayName:"Created At"},enableSorting:!0,enableHiding:!1,header:({column:a})=>e.jsx(B,{column:a,title:"Created At"}),cell:({row:a})=>{const t=a.getValue("createdAt");return t?T.format(new Date(t),"dd.MM.yyyy HH:mm"):"N/A"}}),Ee.display({id:"status",meta:{className:"text-left",displayName:"Status"},header:({column:a})=>e.jsx(B,{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"})}}),Ee.display({id:"actions",header:({column:a})=>e.jsx(B,{column:a,title:"Actions"}),cell:({row:a,table:t})=>e.jsx(dc,{reservation:a.original,table:t})})],mc=()=>{const{client:a}=E(),t=V(),r=S.useSearchParams(),[s,i]=h.useState(""),[n]=Te.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:["reservations",t,o,n],queryFn:async()=>{const{body:g,status:x}=await a.reservation.getReservations({params:{organizationId:t},query:{page:o,limit:10,search:n}});if(x!==200)throw new Error("Failed to fetch reservations");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 name or reference...",value:s,onChange:g=>i(g.target.value),className:"w-full sm:max-w-[250px] sm:[&>input]:h-[40px]"})})}),e.jsx(ca,{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:cc,className:"mt-8",refetch:p})]})};function uc(){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(mc,{})})]})}const pc=[{label:"Owner",value:"owner"},{label:"Admin",value:"admin"},{label:"Member",value:"member"}],Ti=({initialData:a})=>{const{client:t}=E(),r=S.useRouter(),s=Z(),i=V(),n=!!a,o=n?Hn:Vn,l=L.useForm({resolver:ce.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()=>{Q.success(n?"Member role updated successfully":"Invitation sent successfully"),r.push(s.settingsAccess(i)),await ae.invalidateQueries({queryKey:["access-members"]}),await ae.invalidateQueries({queryKey:["access-invitations"]})},p=g=>{n?m.mutate({role:g.role},{onSuccess:u}):c.mutate(g,{onSuccess:u})};return e.jsx(L.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(oe,{id:"member-email",value:a.user.email,disabled:!0,readOnly:!0,className:"w-full mt-2"})]}),e.jsx(Ne,{form:l,config:[...n?[]:[{name:"email",label:"Email",type:"email",placeholder:"user@example.com",colspan:2}],{name:"role",label:"Role",type:"select",options:pc,colspan:2}]})]})]})}),e.jsx(J,{}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsxs(I,{type:"button",variant:"secondary",onClick:()=>r.push(s.settingsAccess(i)),children:[e.jsx(v.ChevronLeft,{className:"w-4 h-4 mr-2"})," Cancel"]}),e.jsxs(I,{type:"submit",isLoading:c.isPending||m.isPending,loadingText:"Saving...",children:[e.jsx(v.CheckIcon,{className:"w-4 h-4 mr-2"})," ",n?"Save Role":"Send Invitation"]})]})]})})};function gc(){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(J,{}),e.jsx("div",{className:"pt-6",children:e.jsx("div",{className:"space-y-10",children:e.jsx(Ti,{})})})]})}const hc=()=>{var u;const{client:a}=E(),t=V(),r=Z(),s=S.useSearchParams(),[i]=h.useState(""),[n]=Te.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()=>{Q.success("Member removed successfully"),await ae.invalidateQueries({queryKey:["access-members"]})},onError:p=>{Q.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(ie,{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(D,{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."})},xc=()=>{const{client:a}=E(),t=V(),{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()=>{Q.success("Invitation revoked"),await ae.invalidateQueries({queryKey:["access-invitations",t]})},onError:n=>{Q.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(ie,{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(nr,{children:[e.jsx(or,{children:e.jsxs(Ue,{className:"border-y border-gray-200 dark:border-gray-800",children:[e.jsx(qe,{className:"whitespace-nowrap py-1 text-sm sm:text-xs",children:"Email"}),e.jsx(qe,{className:"whitespace-nowrap py-1 text-sm sm:text-xs",children:"Role"}),e.jsx(qe,{className:"whitespace-nowrap py-1 text-sm sm:text-xs",children:"Status"}),e.jsx(qe,{className:"whitespace-nowrap py-1 text-sm sm:text-xs",children:"Expires"}),e.jsx(qe,{className:"whitespace-nowrap py-1 text-sm sm:text-xs text-right",children:"Actions"})]})}),e.jsx(lr,{children:s.map(n=>e.jsxs(Ue,{className:"group select-none hover:bg-gray-50 dark:hover:bg-gray-900",children:[e.jsx(De,{className:"whitespace-nowrap py-1 text-gray-600 dark:text-gray-400",children:n.email}),e.jsx(De,{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(De,{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(De,{className:"whitespace-nowrap py-1 text-gray-600 dark:text-gray-400",children:new Date(n.expiresAt).toLocaleDateString()}),e.jsx(De,{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(v.Trash2,{className:"w-4 h-4"})})})]},n.id))})]})})};function fc(){const a=V(),t=Z();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(I,{asChild:!0,className:"hidden gap-x-2 px-2 py-1.5 text-sm sm:text-xs lg:flex",children:e.jsxs(D,{href:t.settingsAccessInvite(a),children:["Invite User",e.jsx(v.PlusIcon,{className:"size-4 shrink-0","aria-hidden":"true"})]})})]}),e.jsx(hc,{}),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(xc,{})})]})]})}function yc(){const a=V(),t=da(),{client:r}=E(),{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 Q.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(J,{}),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(ie,{className:"w-12 h-12"}),e.jsx("p",{className:"text-gray-500 text-sm mt-3",children:"Loading data..."})]})}):e.jsx(Ti,{initialData:i})})})]})}const bc=Se.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"}}),Ze=h.forwardRef(({className:a,variant:t,...r},s)=>e.jsx("span",{ref:s,className:w(bc({variant:t}),a),...r}));Ze.displayName="Badge";const Qi=[{type:"stripe",name:"Stripe",description:"Payments and webhook delivery",configurable:!0},{type:"wolt",name:"Wolt",description:"Marketplace and delivery sync",configurable:!1},{type:"payu",name:"PayU",description:"Alternative payments provider",configurable:!1}];function dr(a){return Qi.find(t=>t.type===a)}function Ka(a){var t;return((t=dr(a))==null?void 0:t.name)??a.split(/[-_]/).filter(Boolean).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}const jc=a=>{if(!a)return{label:"Available",variant:"warning"};if(a.type==="stripe"){const t=it.safeParse(a.config);if(t.success)return t.data.hasSecretKey&&t.data.hasWebhookSecret?{label:"Configured",variant:"success"}:{label:"Needs setup",variant:"warning"}}return{label:"Configured",variant:"success"}};function wc(){const a=V(),t=Z(),{client:r}=E(),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(J,{}),e.jsx("div",{className:"pt-6",children:s.isLoading?e.jsx("div",{className:"flex h-32 items-center justify-center",children:e.jsx(ie,{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:Qi.map(i=>{var l;const n=((l=s.data)==null?void 0:l.find(c=>c.type===i.type))??null,o=jc(n);return e.jsxs(_e,{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(Ze,{variant:i.configurable?o.variant:"neutral",children:i.configurable?o.label:"Coming soon"})]})}),e.jsx("div",{className:"mt-6",children:i.configurable?e.jsx(I,{asChild:!0,className:"w-full justify-center gap-2",children:e.jsxs(D,{href:t.settingsIntegration(a,i.type),children:[n?"Edit Integration":"Select",e.jsx(v.ArrowRightIcon,{className:"h-4 w-4"})]})}):e.jsx(I,{type:"button",variant:"secondary",className:"w-full justify-center",disabled:!0,children:"Not available yet"})})]},i.type)})})})]})}const kc=ha.z.object({paymentMethods:ha.z.array(ha.z.enum(["card","blik"])),secretKey:ha.z.string(),webhookSecret:ha.z.string()}),vc=[{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."}],Nc=a=>{const t=it.safeParse(a==null?void 0:a.config);return t.success?t.data:void 0};function Ac(){var y;const{client:a,baseUrl:t}=E(),r=V(),s=S.useRouter(),i=Z(),n=`${t.replace(/\/$/,"")}/api/webhook/payment/stripe/${r}`,o=L.useForm({resolver:ce.zodResolver(kc),defaultValues:{paymentMethods:["card"],secretKey:"",webhookSecret:""}}),l=((y=A.useQuery({queryKey:["organization-integrations",r],queryFn:async()=>{const{body:b,status:k}=await a.integration.getIntegrations({params:{organizationId:r}});if(k!==200)throw new Error("Failed to load integrations.");return b}}).data)==null?void 0:y.find(b=>b.type==="stripe"))??null,c=Nc(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:k,webhookSecret:N})=>{var te;const R=k.trim(),O=N.trim(),F=eo.safeParse({paymentMethods:b,secretKey:R||void 0,webhookSecret:O||void 0});if(!F.success)throw new Error(((te=F.error.issues[0])==null?void 0:te.message)??"Invalid Stripe configuration.");const{status:q}=await a.integration.upsertIntegration({params:{organizationId:r,type:"stripe"},body:{config:F.data}});if(q!==200)throw new Error("Failed to update Stripe integration.");await ae.invalidateQueries({queryKey:["organization-integrations",r]})},onSuccess:()=>{Q.success("Stripe integration updated."),s.push(i.settingsIntegrations(r))},onError:b=>{Q.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 ae.invalidateQueries({queryKey:["organization-integrations",r]})},onSuccess:()=>{Q.success("Stripe integration removed."),s.push(i.settingsIntegrations(r))},onError:b=>{Q.error(b.message||"Failed to remove Stripe integration.")}}),x=o.watch("paymentMethods"),f=(b,k)=>{const N=o.getValues("paymentMethods"),R=k?Array.from(new Set([...N,b])):N.filter(O=>O!==b);o.setValue("paymentMethods",R,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0})},j=b=>{o.clearErrors(["secretKey","webhookSecret"]);let k=!1;!(c!=null&&c.hasSecretKey)&&!b.secretKey.trim()&&(o.setError("secretKey",{type:"manual",message:"Stripe API key is required."}),k=!0),!(c!=null&&c.hasWebhookSecret)&&!b.webhookSecret.trim()&&(o.setError("webhookSecret",{type:"manual",message:"Stripe webhook secret is required."}),k=!0),!k&&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:vc.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(Ce,{checked:x.includes(b.value),onCheckedChange:k=>f(b.value,k),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(J,{}),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(Ze,{variant:"success",children:"Configured"}):e.jsx(Ze,{variant:"warning",children:"Required"})]}),e.jsx(oe,{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(J,{}),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(oe,{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(Ze,{variant:"success",children:"Configured"}):e.jsx(Ze,{variant:"warning",children:"Required"})]}),e.jsx(oe,{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(J,{}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsxs(I,{type:"button",variant:"secondary",onClick:()=>s.push(m),children:[e.jsx(v.ChevronLeft,{className:"mr-2 h-4 w-4"})," Cancel"]}),l&&e.jsxs(I,{type:"button",variant:"secondary",className:"text-red-600 dark:text-red-400",onClick:()=>g.mutate(),isLoading:g.isPending,loadingText:"Removing...",children:[e.jsx(v.Trash2Icon,{className:"mr-2 h-4 w-4"})," Remove"]}),e.jsxs(I,{type:"submit",isLoading:p.isPending,loadingText:"Saving...",children:[e.jsx(v.CheckIcon,{className:"mr-2 h-4 w-4"})," Save Integration"]})]})]})}function Cc(){const a=da(),t=V(),r=Z(),s=S.useRouter(),i=dr(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:[Ka(a)," Integration"]}),e.jsx(J,{}),e.jsx("div",{className:"pt-6",children:e.jsx(Ac,{})})]}):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)??Ka(a)}),e.jsx(J,{}),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(I,{type:"button",variant:"secondary",onClick:()=>s.push(r.settingsIntegrationsCreate(t)),children:"Back to Integration Catalog"})})]})]})}const Sc=a=>{if(a.type==="stripe"){const t=it.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"}return"Configuration saved"},zc=a=>{if(a.type==="stripe"){const t=it.safeParse(a.config);if(t.success)return t.data.hasSecretKey&&t.data.hasWebhookSecret?{label:"Configured",variant:"success"}:{label:"Needs setup",variant:"warning"}}return{label:"Configured",variant:"success"}};function Ic(){var n;const{client:a}=E(),t=V(),r=Z(),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()=>{Q.success("Integration removed successfully"),await ae.invalidateQueries({queryKey:["organization-integrations",t]})},onError:o=>{Q.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(ie,{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=dr(o.type),c=Ka(o.type),m=zc(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(Ze,{variant:m.variant,children:m.label})]}),e.jsx("p",{className:"mt-1 truncate text-xs text-gray-500",children:Sc(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(D,{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 Ec(){const a=V(),t=Z();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(I,{asChild:!0,className:"hidden gap-x-2 px-2 py-1.5 text-sm sm:text-xs lg:flex",children:e.jsxs(D,{href:t.settingsIntegrationsCreate(a),children:["Add Integration",e.jsx(v.PlusIcon,{className:"size-4 shrink-0","aria-hidden":"true"})]})})]}),e.jsx(Ic,{})]})}const Dc=[{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"}],Fc=({onClose:a,initialData:t})=>{var o,l,c,m,u,p,g;const{client:r}=E(),s=L.useForm({resolver:ce.zodResolver(Ot),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:f}=await r.organization.updateOrganization({params:{organizationId:t==null?void 0:t.id},body:{configuration:x}});if(f!==200)throw Q.error("Failed to update organization. Please try again later."),new Error("Failed to update organization");return await ae.invalidateQueries({queryKey:["organizations"]}),a&&a()}});return e.jsx(Ne,{form:s,config:Dc,onSubmit:x=>n(x),onCancel:a,loading:i,cancelText:"Go back",okText:"Save Schedule"})};function Rc(){const{organization:a}=he();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(Fc,{initialData:a.data})})]})})}):e.jsx("div",{children:"Loading..."})}const Oi=({initialData:a})=>{var p;const{client:t}=E(),r=S.useRouter(),s=Z(),i=V(),n=a?io:gs,o=L.useForm({resolver:ce.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 Q.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 Q.error("Failed to update shipping method. Please try again later."),new Error("Failed to update shipping method")}}),m=async()=>{Q.success("Shipping method saved successfully"),r.push(s.settingsShippingMethods(i)),await ae.invalidateQueries({queryKey:["shipping-and-payment"]})},u=g=>{a?c.mutate(g,{onSuccess:m}):l.mutate(g,{onSuccess:m})};return e.jsx(L.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(Ne,{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(J,{}),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(Ne,{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(J,{}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsxs(I,{type:"button",variant:"secondary",onClick:()=>r.push(s.settingsShippingMethods(i)),children:[e.jsx(v.ChevronLeft,{className:"w-4 h-4 mr-2"})," Cancel"]}),e.jsxs(I,{type:"submit",isLoading:l.isPending||c.isPending,loadingText:"Saving...",children:[e.jsx(v.CheckIcon,{className:"w-4 h-4 mr-2"})," ",a?"Save Product":"Create Shipping Method"]})]})]})})};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 Shipping Method"}),e.jsx(J,{}),e.jsx("div",{className:"pt-6",children:e.jsx("div",{className:"space-y-10",children:e.jsx(Oi,{})})})]})}function Mc(){const a=V(),t=da(),{client:r}=E(),{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 Q.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(J,{}),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(ie,{className:"w-12 h-12"}),e.jsx("p",{className:"text-gray-500 text-sm mt-3",children:"Loading data..."})]})}):e.jsx(Oi,{initialData:i})})})]})}const Ke=fe.createColumnHelper(),Bc=[Ke.display({id:"select",header:({table:a})=>e.jsx(Ce,{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(Ce,{checked:a.getIsSelected(),onCheckedChange:()=>a.toggleSelected(),className:"translate-y-0.5","aria-label":"Select row"}),enableSorting:!1,enableHiding:!1,meta:{displayName:"Select"}}),Ke.accessor("id",{header:({column:a})=>e.jsx(B,{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(D,{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")})}}),Ke.accessor("title",{header:({column:a})=>e.jsx(B,{column:a,title:"Title"}),enableSorting:!0,enableHiding:!1,meta:{className:"text-left",displayName:"Title"}}),Ke.accessor("providerName",{header:({column:a})=>e.jsx(B,{column:a,title:"Provider Name"}),enableSorting:!0,meta:{className:"text-left",displayName:"Provider Name"}}),Ke.accessor("shippingZones",{header:({column:a})=>e.jsx(B,{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(", ")||"-"}),Ke.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(Oe,{children:[e.jsx(Le,{asChild:!0,children:e.jsx(I,{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(z.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(Je,{align:"end",className:"min-w-40",children:[e.jsx(be,{children:e.jsx(D,{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(be,{className:"text-red-600 dark:text-red-500",children:"Delete"})]})]})}})],Tc=()=>{const{client:a}=E(),t=V(),r=S.useSearchParams(),[s]=h.useState(""),[i]=Te.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(ca,{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:Bc,className:"mt-8"})})};function Qc(){const a=V(),t=Z();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(I,{asChild:!0,className:"hidden gap-x-2 px-2 py-1.5 text-sm sm:text-xs lg:flex",children:e.jsxs(D,{href:t.settingsShippingMethodCreate(a),children:["Create Shipping Method",e.jsx(v.PlusIcon,{className:"size-4 shrink-0","aria-hidden":"true"})]})})]}),e.jsx(Tc,{})]})}function we({children:a}){const t=S.usePathname(),r=V(),s=Z(),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(sr,{className:"mt-4 sm:mt-6 lg:mt-6",children:i.map(n=>e.jsx(ir,{asChild:!0,active:t===n.href,children:e.jsx(D,{href:n.href,children:n.name})},n.name))}),e.jsx("div",{className:"pt-6",children:a})]})}const Oc=[{name:"configuration.defaultLocale",label:"Default Locale",type:"select",placeholder:"",options:pr},{name:"configuration.supportedLocales",label:"Supported Locales",type:"select",placeholder:"Select locales",multiple:!0,options:pr},{name:"configuration.defaultCurrency",label:"Currency",type:"select",placeholder:"Acme Inc.",options:Pn}],Lc=({onClose:a,initialData:t})=>{var o,l,c;const{client:r}=E(),s=L.useForm({resolver:ce.zodResolver(Ot),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 Q.error("Failed to update organization. Please try again later."),new Error("Failed to update organization");return await ae.invalidateQueries({queryKey:["organizations"]}),a&&a()}});return e.jsx(Ne,{form:s,config:Oc,onSubmit:m=>n(m),onCancel:a,loading:i,cancelText:"Go back",okText:"Save Settings"})};function Jc(){const{organization:a}=he(),{client:t}=E(),r=V(),s=S.useRouter(),i=Z(),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()=>{Q.success("You have left the organization"),await ae.invalidateQueries({queryKey:["organizations"]}),s.push(i.organizations)},onError:o=>{Q.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(Fi,{initialData:a.data})})]})}),e.jsx(J,{}),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(Lc,{initialData:a.data})})]})}),e.jsx(J,{}),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(v.ExternalLinkIcon,{className:"size-4 shrink-0","aria-hidden":"true"})]})]})]}),e.jsx("div",{className:"space-y-6 md:col-span-2",children:e.jsx(_e,{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(I,{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 Y(a,t){return{label:"Home",href:t.dashboard(a)}}function Vc(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[Y(a.orgId,t),{label:"Orders"}];case"reservations":return[Y(a.orgId,t),{label:"Reservations"}];case"products-list":return[Y(a.orgId,t),{label:"Products"}];case"product-create":return[Y(a.orgId,t),{label:"Products",href:t.products(a.orgId)},{label:"Create Product"}];case"product-edit":return[Y(a.orgId,t),{label:"Products",href:t.products(a.orgId)},{label:"Edit Product"}];case"product-categories-list":return[Y(a.orgId,t),{label:"Product Categories"}];case"product-category-create":return[Y(a.orgId,t),{label:"Product Categories",href:t.productCategories(a.orgId)},{label:"Create Product Category"}];case"product-category-edit":return[Y(a.orgId,t),{label:"Product Categories",href:t.productCategories(a.orgId)},{label:"Edit Product Category"}];case"manufacturers-list":return[Y(a.orgId,t),{label:"Manufacturers"}];case"manufacturer-create":return[Y(a.orgId,t),{label:"Manufacturers",href:t.manufacturers(a.orgId)},{label:"Create Manufacturer"}];case"manufacturer-edit":return[Y(a.orgId,t),{label:"Manufacturers",href:t.manufacturers(a.orgId)},{label:"Edit Manufacturer"}];case"settings":return[Y(a.orgId,t),{label:"Settings"}];case"settings-opening-times":return[Y(a.orgId,t),{label:"Settings",href:t.settings(a.orgId)},{label:"Opening Times"}];case"settings-integrations":return[Y(a.orgId,t),{label:"Settings",href:t.settings(a.orgId)},{label:"Integrations"}];case"settings-integrations-create":return[Y(a.orgId,t),{label:"Settings",href:t.settings(a.orgId)},{label:"Integrations",href:t.settingsIntegrations(a.orgId)},{label:"Add Integration"}];case"settings-integration":return[Y(a.orgId,t),{label:"Settings",href:t.settings(a.orgId)},{label:"Integrations",href:t.settingsIntegrations(a.orgId)},{label:Ka(a.id)}];case"shipping-methods-list":return[Y(a.orgId,t),{label:"Settings",href:t.settings(a.orgId)},{label:"Shipping Methods"}];case"shipping-method-create":return[Y(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[Y(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[Y(a.orgId,t),{label:"Settings",href:t.settings(a.orgId)},{label:"Access"}];case"access-invite":return[Y(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[Y(a.orgId,t),{label:"Settings",href:t.settings(a.orgId)},{label:"Access",href:t.settingsAccess(a.orgId)},{label:"Edit Member"}]}}function Hc({view:a}){const t=Z(),r=Vc(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(v.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(D,{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 qc=()=>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"})})})]}),Li=a=>e.jsx(G.Root,{...a});Li.displayName="Drawer";const Ji=C.forwardRef(({className:a,...t},r)=>e.jsx(G.Trigger,{ref:r,className:w(a),...t}));Ji.displayName="Drawer.Trigger";const Vi=C.forwardRef(({className:a,...t},r)=>e.jsx(G.Close,{ref:r,className:w(a),...t}));Vi.displayName="Drawer.Close";const Hi=G.Portal;Hi.displayName="DrawerPortal";const qi=C.forwardRef(({className:a,...t},r)=>e.jsx(G.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"}}));qi.displayName="DrawerOverlay";const Ui=C.forwardRef(({className:a,...t},r)=>e.jsx(Hi,{children:e.jsx(qi,{children:e.jsx(G.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",ge,a),...t})})}));Ui.displayName="DrawerContent";const Zi=C.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(G.Close,{asChild:!0,children:e.jsx(I,{variant:"ghost",className:"aspect-square p-1 hover:bg-gray-100 dark:hover:bg-gray-400/10",children:e.jsx(z.RiCloseLine,{className:"size-6","aria-hidden":"true"})})})]}));Zi.displayName="Drawer.Header";const $i=C.forwardRef(({className:a,...t},r)=>e.jsx(G.Title,{ref:r,className:w("text-base font-semibold","text-gray-900 dark:text-gray-50",a),...t}));$i.displayName="DrawerTitle";const _i=C.forwardRef(({className:a,...t},r)=>e.jsx("div",{ref:r,className:w("flex-1 py-4",a),...t}));_i.displayName="Drawer.Body";const Uc=C.forwardRef(({className:a,...t},r)=>e.jsx(G.Description,{ref:r,className:w("text-gray-500 dark:text-gray-500",a),...t}));Uc.displayName="DrawerDescription";function Zc(){const a=S.usePathname(),t=V(),r=Z();if(!t)return null;const s=[{name:"Dashboard",href:r.dashboard(t),icon:v.HomeIcon},{name:"Live Orders",href:r.liveOrders(t),icon:v.RadioIcon},{name:"Orders",href:r.orders(t),icon:v.LogsIcon},{name:"Reservations",href:r.reservations(t),icon:v.CalendarCheckIcon},{name:"Products",href:r.products(t),icon:v.PackageIcon},{name:"Categories",href:r.productCategories(t),icon:v.BoxesIcon},{name:"Manufacturers",href:r.manufacturers(t),icon:v.FactoryIcon},{name:"Settings",href:r.settings(t),icon:z.RiSettings5Line}];return e.jsxs(Li,{children:[e.jsx(Ji,{asChild:!0,children:e.jsx(I,{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(z.RiMenuLine,{className:"size-6 shrink-0 sm:size-5","aria-hidden":"true"})})}),e.jsxs(Ui,{className:"sm:max-w-lg",children:[e.jsx(Zi,{children:e.jsx($i,{children:"Navigation"})}),e.jsx(_i,{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(Vi,{asChild:!0,children:e.jsxs(D,{href:i.href,className:X(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",ge),children:[e.jsx(i.icon,{className:"size-5 shrink-0","aria-hidden":"true"}),i.name]})})},i.name))})})})]})]})}const $c=()=>{var l;const[a,t]=h.useState(!1),r=h.useRef(null),{organizations:s,organization:i}=he(),n=S.useRouter(),o=Z();return e.jsx(e.Fragment,{children:e.jsxs(Oe,{open:a,onOpenChange:t,modal:!1,children:[e.jsx(Le,{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",la),children:[i.data.logoFile?e.jsx(xe,{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(z.RiExpandUpDownLine,{className:"size-5 shrink-0 text-gray-500","aria-hidden":"true"})]})]})}),e.jsx(Je,{hidden:!1,onCloseAutoFocus:c=>{r.current&&(r.current.focus(),r.current=null,c.preventDefault())},children:e.jsxs(ba,{children:[e.jsxs(vt,{children:["Workspaces (",s.data.length,")"]}),s.data.map(c=>{var m;return e.jsx(be,{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(xe,{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)})]})})]})})},_c=()=>{const[a,t]=h.useState(!1),r=h.useRef(null),{organizations:s,organization:i}=he(),n=S.useRouter(),o=Z();return e.jsxs(Oe,{open:a,onOpenChange:t,modal:!1,children:[e.jsx(Le,{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(xe,{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(z.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(z.RiExpandUpDownLine,{className:"size-4 shrink-0 text-gray-500","aria-hidden":"true"})]})]})}),e.jsx(Je,{className:"min-w-72!",onCloseAutoFocus:l=>{r.current&&(r.current.focus(),r.current=null,l.preventDefault())},children:e.jsxs(ba,{children:[e.jsxs(vt,{children:["Workspaces (",s.data.length,")"]}),s.data.map(l=>{var c;return e.jsx(be,{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(xe,{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 Wi({children:a,align:t="start"}){var p,g;const r=S.useRouter(),[s,i]=C.useState(!1),{theme:n,setTheme:o}=Dr.useTheme(),l=ja(),c=Z(),m=l.useSession();C.useEffect(()=>{i(!0)},[]);const u=()=>l.signOut({fetchOptions:{onSuccess:()=>r.push(c.signIn)}});return s?e.jsx(e.Fragment,{children:e.jsxs(Oe,{children:[e.jsx(Le,{asChild:!0,children:a}),e.jsxs(Je,{align:t,children:[e.jsx(vt,{children:(g=(p=m.data)==null?void 0:p.user)==null?void 0:g.email}),e.jsx(ba,{children:e.jsxs(zi,{children:[e.jsx(Ei,{children:"Theme"}),e.jsx(Di,{children:e.jsxs(Ii,{value:n,onValueChange:x=>{o(x)},children:[e.jsxs(Ba,{"aria-label":"Switch to Light Mode",value:"light",iconType:"check",children:[e.jsx(z.RiSunLine,{className:"size-4 shrink-0","aria-hidden":"true"}),"Light"]}),e.jsxs(Ba,{"aria-label":"Switch to Dark Mode",value:"dark",iconType:"check",children:[e.jsx(z.RiMoonLine,{className:"size-4 shrink-0","aria-hidden":"true"}),"Dark"]}),e.jsxs(Ba,{"aria-label":"Switch to System Mode",value:"system",iconType:"check",children:[e.jsx(z.RiComputerLine,{className:"size-4 shrink-0","aria-hidden":"true"}),"System"]})]})}),e.jsx(ba,{children:e.jsx(be,{onClick:u,className:"text-red-500",children:"Sign out"})})]})})]})]})}):null}const Wc=()=>{var s;const a=ja().useSession(),{firstname:t,lastname:r}=((s=a.data)==null?void 0:s.user)||{};return e.jsx(Wi,{children:e.jsxs(I,{"aria-label":"User settings",variant:"ghost",className:X(ge,"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(z.RiMore2Fill,{className:"size-4 shrink-0 text-gray-500 group-hover:text-gray-700 dark:group-hover:text-gray-400","aria-hidden":"true"})]})})},Gc=()=>e.jsx(Wi,{align:"end",children:e.jsx(I,{"aria-label":"User settings",variant:"ghost",className:X("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 Kc(){const a=S.usePathname(),t=V(),r=Z(),s=[{name:"Home",href:r.dashboard(t),icon:v.HomeIcon},{name:"Live Orders",href:r.liveOrders(t),icon:v.RadioIcon},{name:"Orders List",href:r.orders(t),icon:v.LogsIcon},{name:"Reservations",href:r.reservations(t),icon:v.CalendarCheckIcon},{name:"Products",href:r.products(t),icon:v.PackageIcon},{name:"Product Categories",href:r.productCategories(t),icon:v.BoxesIcon},{name:"Manufacturers",href:r.manufacturers(t),icon:v.FactoryIcon},{name:"Customers",href:`${r.dashboard(t)}/customers`,icon:v.UserCircleIcon},{name:"Settings",href:r.settings(t),icon:z.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(D,{href:r.home,className:"-ml-2",children:e.jsx(qc,{})}),e.jsx("hr",{className:"block border-t border-gray-200 dark:border-gray-800 -mt-3 mb-1"}),e.jsx($c,{}),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(D,{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",ge),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(Wc,{})})]})}),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(_c,{}),e.jsxs("div",{className:"flex items-center gap-1 sm:gap-2",children:[e.jsx(Gc,{}),e.jsx(Zc,{})]})]})]})}function Xc({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(Kc,{}),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(Hc,{view:t}),a]})})})]})]})}function Yc(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 em({segments:a}){const t=ja(),r=Z(),s=S.useRouter(),i=S.usePathname(),n=S.useSearchParams(),{data:o,isPending:l}=t.useSession(),c=Yc(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,f=m?ft(p,r):x;if(h.useEffect(()=>{if(!l){if(!o&&!m){s.replace(_t(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(Tl,{});if(c.type==="sign-up")return e.jsx(Ol,{})}if(!o)return null;if(u)return e.jsx(Cr,{children:e.jsx(Pd,{})});if(c.type==="not-found")return e.jsx($t,{});const j="orgId"in c?c.orgId:void 0,y="id"in c?c.id:void 0;return e.jsx(zl,{organizationId:j,id:y,children:e.jsx(Cr,{children:e.jsx(Dl,{children:e.jsx(Xc,{view:c,children:am(c)})})})})}function am(a){switch(a.type){case"dashboard":return e.jsx(_l,{});case"orders":return e.jsx(Dd,{});case"reservations":return e.jsx(uc,{});case"products-list":return e.jsx(ic,{});case"product-create":return e.jsx(Yd,{});case"product-edit":return e.jsx(ec,{});case"product-categories-list":return e.jsx(qd,{});case"product-category-create":return e.jsx(Zd,{});case"product-category-edit":return e.jsx($d,{});case"manufacturers-list":return e.jsx(Nd,{});case"manufacturer-create":return e.jsx(md,{});case"manufacturer-edit":return e.jsx(ud,{});case"settings":return e.jsx(we,{children:e.jsx(Jc,{})});case"settings-opening-times":return e.jsx(we,{children:e.jsx(Rc,{})});case"settings-integrations":return e.jsx(we,{children:e.jsx(Ec,{})});case"settings-integrations-create":return e.jsx(we,{children:e.jsx(wc,{})});case"settings-integration":return e.jsx(we,{children:e.jsx(Cc,{})});case"shipping-methods-list":return e.jsx(we,{children:e.jsx(Qc,{})});case"shipping-method-create":return e.jsx(we,{children:e.jsx(Pc,{})});case"shipping-method-edit":return e.jsx(we,{children:e.jsx(Mc,{})});case"access-list":return e.jsx(we,{children:e.jsx(fc,{})});case"access-invite":return e.jsx(we,{children:e.jsx(gc,{})});case"access-member-edit":return e.jsx(we,{children:e.jsx(yc,{})});default:return e.jsx($t,{})}}exports.APIProvider=Pt,exports.AccountHomePage=ei,exports.AccountPages=nl,exports.AdminProvider=hn,exports.AdminRouter=em,exports.Badge=ea,exports.Button=W,exports.CartDrawer=Rn,exports.CartDrawerItem=ts,exports.CartItems=as,exports.CartPanel=rs,exports.CartProvider=Gr,exports.CheckoutPages=ll,exports.Command=Na,exports.CommandBar=Js,exports.CommandBarBar=Hs,exports.CommandBarCommand=Us,exports.CommandBarSeperator=qs,exports.CommandBarValue=Vs,exports.CommandDialog=ko,exports.CommandEmpty=ct,exports.CommandGroup=mt,exports.CommandInput=lt,exports.CommandItem=ut,exports.CommandList=dt,exports.CommandSeparator=Cs,exports.CommandShortcut=Ss,exports.CountryInput=Es,exports.CustomerDetailsPage=It,exports.Dialog=ka,exports.DialogClose=ws,exports.DialogContent=va,exports.DialogDescription=Ns,exports.DialogFooter=As,exports.DialogHeader=Jt,exports.DialogTitle=ot,exports.DialogTrigger=js,exports.Divider=aa,exports.EmailInput=Ds,exports.ErrorView=$t,exports.ImageUploadInput=Fs,exports.Input=Qs,exports.InputGroup=me,exports.Label=ye,exports.LocationInput=pt,exports.ModifierContainer=si,exports.ModifiersDialog=cl,exports.ModifiersGroup=ii,exports.ModifiersModal=ul,exports.ModifiersOption=ni,exports.PhoneNumberInput=Ms,exports.Popover=ia,exports.PopoverAnchor=zs,exports.PopoverClose=Is,exports.PopoverContent=oa,exports.PopoverTrigger=na,exports.QuantityControl=ml,exports.RadioCardGroup=Ja,exports.RadioCardGroupIndicator=Va,exports.RadioCardItem=Ha,exports.SelectInput=Bs,exports.ShippingAndPaymentPage=$s,exports.ShophostProvider=Al,exports.SliderOver=Ls,exports.Switch=Vt,exports.TextInput=ve,exports.TimeInput=Ht,exports.badgeVariants=Zs,exports.buttonVariants=bs,exports.calculateCartTotal=fn,exports.createAdminAuthClient=qr,exports.createRoutes=Zr,exports.findCartItem=bn,exports.formatPrice=ue,exports.getAdminAuthClient=Ur,exports.getFieldError=Os,exports.getFormattedModifiers=yn,exports.mockProducts=hl,exports.productRequiresModifiers=wn,exports.useAPI=E,exports.useCart=et,exports.useCartContext=at,exports.useLocalization=Kr,exports.useModifierSelection=Xr,exports.useModifiers=wa,exports.useMultipleProductDetails=gl,exports.useOrganization=pe,exports.useProductDetails=pl;