1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,792450,e=>{"use strict";e.s(["SPIN_ENABLED",0,!1])},725990,e=>{"use strict";let t=(0,e.i(768834).create)(e=>({isOpen:!1,autoOpened:!1,onOpen:t=>e({isOpen:!0,autoOpened:t?.auto??!1}),onClose:()=>e({isOpen:!1})}));e.s(["useSpinDrawer",0,t])},96923,e=>{"use strict";var t=e.i(843476),r=e.i(912598);e.i(247167);var n=function(){return null},a=e.i(837012),s=e.i(271645),i=e.i(857259),o=e.i(924672);let l=({children:e})=>{let{session:r,isLoading:n}=(0,i.useSession)();return(0,s.useEffect)(()=>{n||(0,o.setSessionTenant)(r?.corporateId?"corporate":"public")},[n,r?.corporateId]),(0,s.useEffect)(()=>()=>(0,o.setSessionTenant)(null),[]),(0,t.jsx)(t.Fragment,{children:e})};var c=e.i(123287),c=c,d=e.i(879664),d=d,u=e.i(717521),u=u;let m=(0,e.i(475254).default)("octagon-x",[["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);var p=e.i(582458),p=p,f=e.i(846696),h=e.i(689554);let x=({...e})=>{let{theme:r}=(0,h.useAppTheme)();return(0,t.jsx)(f.Toaster,{theme:"dailyneedplus"===r?"dark":"light",className:"toaster group",icons:{success:(0,t.jsx)(c.default,{className:"size-4"}),info:(0,t.jsx)(d.default,{className:"size-4"}),warning:(0,t.jsx)(p.default,{className:"size-4"}),error:(0,t.jsx)(m,{className:"size-4"}),loading:(0,t.jsx)(u.default,{className:"size-4 animate-spin"})},style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius)"},...e})};var g=e.i(618566),y=e.i(625859);function b(){let e=(0,y.usePlusMembershipState)(),{theme:t,setAppTheme:r}=(0,h.useAppTheme)(),n=(0,g.useRouter)(),a=(0,s.useRef)(null);return(0,s.useEffect)(()=>{if("unknown"===e)return;let s="active"===e?"dailyneedplus":"dailyneed";if(t===s){a.current=null;return}r(s),a.current!==s&&(a.current=s,n.refresh())},[e,t,r,n]),null}var v=e.i(748238),w=e.i(944396);function j({serverTier:e}){let t=(0,w.useMemberPriceTier)(),n=(0,r.useQueryClient)(),a=(0,s.useRef)(e);return(0,s.useEffect)(()=>{t!==a.current&&(a.current=t,n.invalidateQueries({queryKey:v.queryKeys.products.all}))},[t,n]),null}var N=e.i(104943),k=e.i(924540),C=e.i(150361);let S=0;function P(e=1){S=e}function A(){(0,k.c)("[nuqs] Aborting queues"),C.t.abortAll(),C.n.abort().forEach(e=>C.t.queuedQuerySync.emit(e))}function I(){P(0),A()}function E(){!function(e=A){(S=Math.max(0,S-1))>0||e()}(()=>{queueMicrotask(A)})}function _(){return(0,s.useEffect)(()=>(!function(){var e;if(e="next/app","u"<typeof history||(history.nuqs?.version&&"2.8.8"!==history.nuqs.version?(console.error((0,k.s)(409),history.nuqs.version,"2.8.8",e),!0):!!history.nuqs?.adapters?.includes(e)))return;let t=history.replaceState,r=history.pushState;history.replaceState=function(e,r,n){return E(),t.call(history,e,r,n)},history.pushState=function(e,t,n){return E(),r.call(history,e,t,n)},history.nuqs=history.nuqs??{version:"2.8.8",adapters:[]},history.nuqs.adapters.push("next/app")}(),window.addEventListener("popstate",I),()=>window.removeEventListener("popstate",I)),[]),null}let M=(0,k.n)(function(){let e=(0,g.useRouter)(),[t,r]=(0,s.useOptimistic)((0,g.useSearchParams)());return{searchParams:t,updateUrl:(0,s.useCallback)((t,n)=>{(0,s.startTransition)(()=>{n.shallow||r(t);let a=function(e){let{origin:t,pathname:r,hash:n}=location;return t+r+(0,k.o)(e)+n}(t);(0,k.c)("[nuqs next/app] Updating url: %s",a);let s="push"===n.history?history.pushState:history.replaceState;P(3),s.call(history,null,"",a),n.scroll&&window.scrollTo(0,0),n.shallow||e.replace(a,{scroll:!1})})},[]),rateLimitFactor:3,autoResetQueueOnUpdate:!0}});function O({children:e,...t}){return(0,s.createElement)(M,{...t,children:[(0,s.createElement)(s.Suspense,{key:"nuqs-adapter-suspense-navspy",children:(0,s.createElement)(_)}),e]})}function T(){return(0,s.useEffect)(()=>{let t=window.location.hash;(t.includes("code=")||t.includes("error="))&&e.A(684025).then(({completeMsalRedirect:e})=>e())},[]),null}var L=e.i(833747),B=e.i(794764),D=e.i(572041),R=e.i(646176),U=e.i(263474),z=e.i(732445);function W(e){return e.map(e=>`${e.code}:${e.result.discount??0}:${e.result.shippingDiscount??0}`).sort().join("|")}
1var G=e.i(792450),F=e.i(725990),$=e.i(827012);let V=["/login","/register","/checkout","/admin","/blog"],q="dn:seen:spin-teaser";function K(){let e=(0,g.usePathname)(),{isAuthenticated:t,isLoading:r}=(0,i.useSession)(),n=(0,F.useSpinDrawer)(e=>e.onOpen),a=(0,s.useRef)(!1),o=(0,s.useRef)(!1),l=!V.some(t=>e?.startsWith(t)),c=(0,$.useSpinEligibilityQuery)(G.SPIN_ENABLED&&l&&t&&!r);return(0,s.useEffect)(()=>{if(!G.SPIN_ENABLED||!l||r)return;if(!t){if(a.current||function(){try{return"1"===sessionStorage.getItem(q)}catch{return!0}}())return;let e=setTimeout(()=>{if(!a.current){a.current=!0;try{sessionStorage.setItem(q,"1")}catch{}n({auto:!0})}},2500);return()=>clearTimeout(e)}if(o.current)return;let e=c.data;e&&(o.current=!0,(e.eligible||e.pendingWins.length>0)&&n({auto:!0}))},[l,t,r,c.data,n]),null}let Q=(0,e.i(768834).create)(e=>({isOpen:!1,onOpen:()=>e({isOpen:!0}),onClose:()=>e({isOpen:!1})}));var Y=e.i(266027),H=e.i(427670);let X=["utm_source","utm_medium","utm_campaign","utm_content"];function J(e){return X.filter(t=>e[t]).map(t=>`${t}=${e[t].toLowerCase()}`).join("&")}let Z=null;function ee(){return Z||(Z=function(e){let t={};if(!e)return t;for(let r of X){let n=e.get(r)?.trim();n&&(t[r]=n)}return t}(new URLSearchParams(window.location.search)))}let et=(e,t={})=>{let r=J(t);return(0,Y.useQuery)({queryKey:["promo-banner",r],queryFn:()=>((e={})=>H.httpClient.get("customers/me/promotions/banner",{service:"promo",params:e}))(t),enabled:e,staleTime:3e5,retry:!1})},er=["/login","/register","/checkout","/admin","/blog"],en="dn:seen:promo-banner:",ea="dn:seen:promo-banner:any";function es(){let e=(0,g.usePathname)(),t=Q(e=>e.onOpen),r=(0,s.useRef)(null),n=ee(),a=J(n),i=!er.some(t=>e?.startsWith(t)),{data:o}=et(i,n),l=o?.banner??null;return(0,s.useEffect)(()=>{if(!i||!l)return;let e=`${l.id}:${a}`;if(r.current===e||!l.isCampaignMatch&&(function(e){try{return"1"===sessionStorage.getItem(en+e)}catch{return!0}}(l.promotionId)||function(){try{return"1"===sessionStorage.getItem(ea)}catch{return!0}}()))return;let n=setTimeout(()=>{if(r.current!==e){r.current=e;try{sessionStorage.setItem(ea,"1")}catch{}l.isCampaignMatch||function(e){try{sessionStorage.setItem(en+e,"1")}catch{}}(l.promotionId),t()}},2500);return()=>clearTimeout(n)},[i,l,a,t]),null}var ei=e.i(522016),eo=e.i(37727);e.i(972694);var el=e.i(315328),ec=e.i(272224),ed=e.i(167881),eu=e.i(718817);function em({text:e,href:r,onNavigate:n}){let a="bg-brand-accent text-brand-accent-foreground h-12 w-full rounded-full text-sm font-bold shadow-lg hover:opacity-90",s=function(e){if(e.startsWith("/"))return e;try{let t=new URL(e);if(t.origin!==window.location.origin)return null;return`${t.pathname}${t.search}${t.hash}`}catch{return null}}(r);return s?(0,t.jsx)(ed.Button,{asChild:!0,className:a,onClick:n,children:(0,t.jsx)(ei.default,{href:s,children:e})}):(0,t.jsx)(ed.Button,{asChild:!0,className:a,onClick:n,children:(0,t.jsx)("a",{href:r,rel:"noopener noreferrer",children:e})})}function ep(){let e=Q(e=>e.isOpen),r=Q(e=>e.onClose),{track:n}=(0,ec.useAnalytics)(),{data:a}=et(e,ee()),i=a?.banner??null,o=i?.promotionId??null,l=i?.title??i?.altText??"",c=i?.isCampaignMatch??!1;if((0,s.useEffect)(()=>{if(!e||!o)return;let t=()=>n({event:"view_promotion",ecommerce:{promotion_id:o,promotion_name:l,creative_slot:"promo_popup"}});c?t():(0,el.fireOncePerSession)(`view_promotion:promo_popup:${o}`,t)},[e,o,l,c,n]),!i)return null;let d=i.mediaUrlMobile??i.mediaUrlDesktop,u=i.mediaUrlDesktop??i.mediaUrlMobile;if(!d||!u)return null;let m=!!(i.ctaText&&i.ctaUrl),p=!!(i.title||i.description);return(0,t.jsx)(eu.ResponsiveDialog,{open:e,onOpenChange:e=>{e||r()},children:(0,t.jsxs)(eu.ResponsiveDialogContent,{className:"overflow-hidden border-0 p-0 shadow-2xl sm:max-w-[440px] sm:rounded-3xl [&>[data-slot=dialog-close]]:hidden",children:[(0,t.jsx)(eu.ResponsiveDialogTitle,{className:"sr-only",children:i.title??i.altText}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsxs)("picture",{children:[(0,t.jsx)("source",{media:"(min-width: 768px)",srcSet:u}),(0,t.jsx)("img",{src:d,alt:i.altText,className:"block h-auto w-full"})]}),(0,t.jsx)(eu.ResponsiveDialogClose,{"aria-label":"Close",className:"absolute top-3 right-3 flex h-9 w-9 items-center justify-center rounded-full bg-white text-neutral-900 shadow-md ring-1 ring-black/5 transition hover:bg-neutral-100 focus-visible:ring-2 focus-visible:ring-neutral-900 focus-visible:outline-none",children:(0,t.jsx)(eo.X,{className:"h-4.5 w-4.5",strokeWidth:2.5})})]}),(p||m)&&(0,t.jsxs)("div",{className:"flex flex-col gap-2 px-4 pt-3 pb-4",children:[i.title&&(0,t.jsx)("h2",{className:"text-foreground text-base leading-snug font-bold tracking-tight",children:i.title}),i.description&&(0,t.jsx)("p",{className:"text-muted-foreground text-sm leading-relaxed",children:i.description}),m&&(0,t.jsx)(em,{text:i.ctaText,href:i.ctaUrl,onNavigate:()=>{n({event:"select_promotion",ecommerce:{promotion_id:i.promotionId,promotion_name:l,creative_slot:"promo_popup"}}),r()}})]})]})})}var ef=e.i(44194),eh=e.i(593761),ex=e.i(318031),eg=e.i(786850),ey=e.i(57146),eb=e.i(486392);function ev(){return(0,s.useEffect)(()=>{(0,eb.installFlushHooks)();let e=e=>{(0,eb.reportClientError)({source:"window-error",level:"error",name:e.error?.name,message:e.message,stack:e.error?.stack,filename:e.filename,lineno:e.lineno,colno:e.colno})},t=e=>{let t=function(e){if(e instanceof Error)return{name:e.name,message:e.message,stack:e.stack};if("string"==typeof e)return{message:e};try{return{message:JSON.stringify(e)}}catch{return{message:String(e)}}}(e.reason);(0,eb.reportClientError)({source:"unhandled-rejection",level:"error",name:t.name??"UnhandledRejection",message:t.message,stack:t.stack})};return window.addEventListener("error",e),window.addEventListener("unhandledrejection",t),()=>{window.removeEventListener("error",e),window.removeEventListener("unhandledrejection",t)}},[]),null}function ew(){return(0,s.useEffect)(()=>
1{if(!ex.env.NEXT_PUBLIC_ENABLE_ANALYTICS)return;(0,ef.captureUtmParams)(),(0,eh.captureFbcOnArrival)(),ee();let e=setTimeout(()=>(0,ef.cleanUtmFromUrl)(),0);return()=>clearTimeout(e)},[]),null}function ej(){return!function(){let e=(0,g.usePathname)(),t=(0,r.useQueryClient)(),{isAuthenticated:n}=(0,i.useSession)(),{cart:a,cartItems:o,isLoading:l,isFetching:c}=(0,L.useCartLogic)(),d=(0,D.useCheckoutStore)(e=>e.appliedCouponCode),u=(0,D.useCheckoutStore)(e=>e.autoAppliedCoupons),m=(0,D.useCheckoutStore)(e=>e.setAutoAppliedCoupons),p=(0,D.useCheckoutStore)(e=>e.setAppliedCouponCode),f=(0,D.useCheckoutStore)(e=>e.setAppliedCouponResult),h=(0,D.useCheckoutStore)(e=>e.deliveryMethod),x=(0,D.useCheckoutStore)(e=>e.shippingCharges),y=(0,D.useCheckoutStore)(e=>e.outOfStockItems),b=(0,D.useCheckoutStore)(e=>e.isCheckoutDrawerOpen),v=(0,D.useCheckoutStore)(e=>e.setPendingCelebration),w=(0,D.useCheckoutStore)(e=>e.setIsAutoApplyingCoupons),j=(0,D.useCheckoutStore)(e=>e.dismissedAutoCoupons),N="/checkout"===e||b,{data:k=[]}=(0,U.useAutoApplyCouponsQuery)(),C=(0,s.useMemo)(()=>{let e=a?.estimatedTotals;return e?.coupons??[]},[a]);(0,s.useEffect)(()=>{if(l||!a)return;let e=C.filter(e=>"manual"===e.source),t=new Set(j.map(e=>e.trim().toUpperCase())),r=C.filter(e=>"auto"===e.source&&!t.has(e.code.trim().toUpperCase())),n=e.map(e=>e.code).join(",")||null,s=e[e.length-1]?.result??null;n!==d&&p(n),f(s);let i=r.map(e=>({code:e.code,label:e.result.couponDetails?.description||e.code,result:e.result}));W(i)!==W(u)&&m(i)},[C,l,a,d,u,j,p,f,m]);let S=(0,s.useMemo)(()=>{let e=new Set(y.map(e=>e.variantId).filter(e=>!!e)),t=new Set(y.map(e=>e.sku));return o.filter(r=>!(r.variantId&&e.has(r.variantId))&&!t.has(r.sku))},[o,y]),P=(0,s.useRef)(""),A=(0,s.useRef)(!1);(0,s.useLayoutEffect)(()=>{N&&!A.current&&(A.current=!0,P.current="",w(!0)),N||(A.current=!1,w(!1))},[N,w]),(0,s.useEffect)(()=>{n&&t.invalidateQueries({queryKey:["auto-apply-coupons"]})},[n,t]);let I=(0,s.useRef)(null),E=(0,s.useRef)(0),_=(0,s.useRef)(new Set);(0,s.useEffect)(()=>{if(!N){I.current&&(clearTimeout(I.current),I.current=null),P.current="",w(!1);return}if(l||c||!a||0===S.length)return;if((0,L.hasPendingCartSync)()){I.current&&(clearTimeout(I.current),I.current=null),P.current="",w(!0);return}let e=(d??"").split(",").map(e=>e.trim()).filter(Boolean),r=new Set(j.map(e=>e.trim().toUpperCase())),n=(0,z.filterApplicableCoupons)(k).filter(e=>!r.has(e.code.trim().toUpperCase())).map(e=>e.code),s=Array.from(new Set([...e,...n])),i=S.map(e=>{let t=e.metadata??null;return[e.variantId||e.sku,e.quantityPieces,e.unitPriceSnapshotAmount,t?.cartonPrice??"",t?.piecePrice??""].join(":")}).sort().join("|"),o=[s.slice().sort().join(","),h,x,i].join("::");if(P.current===o)return;if(P.current=o,0===s.length){u.length>0&&m([]),d&&(p(null),f(null)),w(!1);return}let g=async()=>{let e=++E.current;try{let r=await R.couponsApi.applyCoupons({codes:n,excludeCodes:j,source:"auto",replace:"auto"});if(e!==E.current)return;if(r.estimatedTotals){if(await t.cancelQueries({queryKey:B.cartKeys.all}),e!==E.current)return;t.setQueriesData({queryKey:B.cartKeys.all},e=>e?{...e,estimatedTotals:r.estimatedTotals}:e),t.invalidateQueries({queryKey:B.cartKeys.all})}let a=r.results.filter(e=>("applied"===e.status||"already_applied"===e.status)&&!!e.appliedCouponResult).map(e=>({code:e.code,label:k.find(t=>t.code===e.code)?.description||e.appliedCouponResult.couponDetails?.description||e.code,result:e.appliedCouponResult}));m(a);let s=new Set(a.map(e=>e.code));for(let e of Array.from(_.current))s.has(e)||_.current.delete(e);let i=a.filter(e=>!_.current.has(e.code));if(i.length>0){for(let e of i)_.current.add(e.code);let e=(r.celebrationOrder??[]).map(e=>i.find(t=>t.code===e)).find(Boolean)??i[0];v(e)}}catch(t){console.error("[AutoApply] bulk apply failed:",t),e===E.current&&(P.current="")}finally{e===E.current&&w(!1)}};w(!0),I.current&&clearTimeout(I.current),I.current=setTimeout(()=>{I.current=null,g()},350)},[N,l,c,a,S,k,d,h,x,u,j,t,w,p,f,m,v])}(),null}function eN({children:e,initialTheme:i,initialMemberPriceTier:o}
1){let c=(0,a.getQueryClient)(),[d,u]=(0,s.useState)(i);(0,s.useEffect)(()=>{u(i)},[i]),(0,s.useEffect)(()=>{try{localStorage.setItem("theme",d)}catch{}},[d]);let m=(0,s.useMemo)(()=>({theme:d,setAppTheme:u}),[d]);return(0,t.jsxs)(r.QueryClientProvider,{client:c,children:[(0,t.jsx)(ev,{}),(0,t.jsxs)(h.AppThemeProvider,{value:m,children:[(0,t.jsx)(x,{position:"top-center",duration:1500}),(0,t.jsx)(h.ThemeProvider,{forcedTheme:d,defaultTheme:d,attribute:"class",enableSystem:!1,themes:["light","kelloggs","indomie","dailyneed","celebr8lyfe","dailyneedplus"],children:(0,t.jsxs)(O,{children:[(0,t.jsx)(T,{}),(0,t.jsx)(l,{children:(0,t.jsxs)(eg.AnalyticsIdentityProvider,{children:[(0,t.jsx)(ew,{}),(0,t.jsx)(ey.PendingLoginTracker,{}),(0,t.jsx)(ej,{}),(0,t.jsx)(K,{}),(0,t.jsxs)(s.Suspense,{fallback:null,children:[(0,t.jsx)(es,{}),(0,t.jsx)(ep,{})]}),(0,t.jsx)(b,{}),(0,t.jsxs)(N.ServerMemberPriceTierProvider,{tier:o,children:[(0,t.jsx)(j,{serverTier:o}),e]})]})})]})})]}),(0,t.jsx)(n,{})]})}e.s(["default",()=>eN],96923)},716915,(e,t,r)=>{!function(n,a){if("function"==typeof define&&define.amd){let n;void 0!==(n=a(e.r,r,t))&&e.v(n)}else t.exports=a()}(e.e,function(){var e,t,r,n={};n.version="0.2.0";var a=n.settings={minimum:.08,easing:"ease",positionUsing:"",speed:200,trickle:!0,trickleRate:.02,trickleSpeed:800,showSpinner:!0,barSelector:'[role="bar"]',spinnerSelector:'[role="spinner"]',parent:"body",template:'<div class="bar" role="bar"><div class="peg"></div></div><div class="spinner" role="spinner"><div class="spinner-icon"></div></div>'};function s(e,t,r){return e<t?t:e>r?r:e}n.configure=function(e){var t,r;for(t in e)void 0!==(r=e[t])&&e.hasOwnProperty(t)&&(a[t]=r);return this},n.status=null,n.set=function(e){var t=n.isStarted();n.status=1===(e=s(e,a.minimum,1))?null:e;var r=n.render(!t),l=r.querySelector(a.barSelector),c=a.speed,d=a.easing;return r.offsetWidth,i(function(t){var s,i,u,m;""===a.positionUsing&&(a.positionUsing=n.getPositioningCSS()),o(l,(s=e,i=c,u=d,(m="translate3d"===a.positionUsing?{transform:"translate3d("+(-1+s)*100+"%,0,0)"}:"translate"===a.positionUsing?{transform:"translate("+(-1+s)*100+"%,0)"}:{"margin-left":(-1+s)*100+"%"}).transition="all "+i+"ms "+u,m)),1===e?(o(r,{transition:"none",opacity:1}),r.offsetWidth,setTimeout(function(){o(r,{transition:"all "+c+"ms linear",opacity:0}),setTimeout(function(){n.remove(),t()},c)},c)):setTimeout(t,c)}),this},n.isStarted=function(){return"number"==typeof n.status},n.start=function(){n.status||n.set(0);var e=function(){setTimeout(function(){n.status&&(n.trickle(),e())},a.trickleSpeed)};return a.trickle&&e(),this},n.done=function(e){return e||n.status?n.inc(.3+.5*Math.random()).set(1):this},n.inc=function(e){var t=n.status;return t?("number"!=typeof e&&(e=(1-t)*s(Math.random()*t,.1,.95)),t=s(t+e,0,.994),n.set(t)):n.start()},n.trickle=function(){return n.inc(Math.random()*a.trickleRate)},e=0,t=0,n.promise=function(r){return r&&"resolved"!==r.state()&&(0===t&&n.start(),e++,t++,r.always(function(){0==--t?(e=0,n.done()):n.set((e-t)/e)})),this},n.render=function(e){if(n.isRendered())return document.getElementById("nprogress");c(document.documentElement,"nprogress-busy");var t=document.createElement("div");t.id="nprogress",t.innerHTML=a.template;var r,s=t.querySelector(a.barSelector),i=e?"-100":(-1+(n.status||0))*100,l=document.querySelector(a.parent);return o(s,{transition:"all 0 linear",transform:"translate3d("+i+"%,0,0)"}),!a.showSpinner&&(r=t.querySelector(a.spinnerSelector))&&m(r),l!=document.body&&c(l,"nprogress-custom-parent"),l.appendChild(t),t},n.remove=function(){d(document.documentElement,"nprogress-busy"),d(document.querySelector(a.parent),"nprogress-custom-parent");var e=document.getElementById("nprogress");e&&m(e)},n.isRendered=function(){return!!document.getElementById("nprogress")},n.getPositioningCSS=function(){var e=document.body.style,t="WebkitTransform"in e?"Webkit":"MozTransform"in e?"Moz":"msTransform"in e?"ms":"OTransform"in e?"O":"";return t+"Perspective"in e?"translate3d":t+"Transform"in e?"translate":"margin"};var i=(r=[],function(e){r.push(e),1==r.length&&function e(){var t=r.shift();t&&t(e)}()}),o=function(){var e=["Webkit","O","Moz","ms"],t={};function r(r,n,a){var s;n=t[s=(s=n).replace(/^-ms-/,"ms-").replace(/-([\da-z])/gi,function(e,t){return t.toUpperCase()})]||(t[s]=function(t){var r=document.body.style;if(t in r)return t;for(var n,a=e.length,s=t.charAt(0).toUpperCase()+t.slice(1);a--;)if((n=e[a]+s)in r)return n;return t}(s)),r.style[n]=a}return function(e,t){var n,a,s=arguments;if(2==s.length)for(n in t)void 0!==(a=t[n])&&t.hasOwnProperty(n)&&r(e,n,a);else r(e,s[1],s[2])}}();function l(e,t){return("string"==typeof e?e:u(e)).indexOf(" "+t+" ")>=0}function c(e,t){var r=u(e),n=r+t;l(r,t)||(e.className=n.substring(1))}function d(e,t){var r,n=u(e);l(e,t)&&(e.className=(r=n.replace(" "+t+" "," ")).substring(1,r.length-1))}function u(e){return(" "+(e.className||"")+" ").replace(/\s+/gi," ")}function m(e){e&&e.parentNode&&e.parentNode.removeChild(e)}return n})},818421,(e,t,r)=>{var n=Object.create,a=Object.defineProperty,s=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,o=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty,c=(e,t)=>a(e,"name",{value:t,configurable:!0}),d=(e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let o of i(t))l.call(e,o)||o===r||a(e,o,{get:()=>t[o],enumerable:!(n=s(t,o))||n.enumerable});return e},u=(e,t,r)=>(r=null!=e?n(o(e)):{}
1,d(!t&&e&&e.__esModule?r:a(r,"default",{value:e,enumerable:!0}),e)),m={},p={default:()=>w,useTopLoader:()=>b};for(var f in p)a(m,f,{get:p[f],enumerable:!0});t.exports=d(a({},"__esModule",{value:!0}),m);var h=u(e.r(745009)),x=u(e.r(271645)),g=u(e.r(716915)),y=u(e.r(716915)),b=c(()=>({start:()=>y.start(),done:e=>y.done(e),remove:()=>y.remove(),setProgress:e=>y.set(e),inc:e=>y.inc(e),trickle:()=>y.trickle(),isStarted:()=>y.isStarted(),isRendered:()=>y.isRendered(),getPositioningCSS:()=>y.getPositioningCSS()}),"useTopLoader"),v=c(({color:e,height:t,showSpinner:r,crawl:n,crawlSpeed:a,initialPosition:s,easing:i,speed:o,shadow:l,template:d,zIndex:u=1600,showAtBottom:m=!1,showForHashAnchor:p=!0,nonce:f})=>{let h=null!=e?e:"#29d",y=l||void 0===l?l?`box-shadow:${l}`:`box-shadow:0 0 10px ${h},0 0 5px ${h}`:"",b=x.createElement("style",{nonce:f},`#nprogress{pointer-events:none}#nprogress .bar{background:${h};position:fixed;z-index:${u};${m?"bottom: 0;":"top: 0;"}left:0;width:100%;height:${null!=t?t:3}px}#nprogress .peg{display:block;position:absolute;right:0;width:100px;height:100%;${y};opacity:1;-webkit-transform:rotate(3deg) translate(0px,-4px);-ms-transform:rotate(3deg) translate(0px,-4px);transform:rotate(3deg) translate(0px,-4px)}#nprogress .spinner{display:block;position:fixed;z-index:${u};${m?"bottom: 15px;":"top: 15px;"}right:15px}#nprogress .spinner-icon{width:18px;height:18px;box-sizing:border-box;border:2px solid transparent;border-top-color:${h};border-left-color:${h};border-radius:50%;-webkit-animation:nprogress-spinner 400ms linear infinite;animation:nprogress-spinner 400ms linear infinite}.nprogress-custom-parent{overflow:hidden;position:relative}.nprogress-custom-parent #nprogress .bar,.nprogress-custom-parent #nprogress .spinner{position:absolute}@-webkit-keyframes nprogress-spinner{0%{-webkit-transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg)}}@keyframes nprogress-spinner{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}`),v=c(e=>new URL(e,window.location.href).href,"toAbsoluteURL"),w=c((e,t)=>{let r=new URL(v(e)),n=new URL(v(t));return r.href.split("#")[0]===n.href.split("#")[0]},"isHashAnchor"),j=c((e,t)=>{let r=new URL(v(e)),n=new URL(v(t));return r.hostname.replace(/^www\./,"")===n.hostname.replace(/^www\./,"")},"isSameHostName");return x.useEffect(()=>{let e,t;function l(e,t){let r=new URL(e),n=new URL(t);if(r.hostname===n.hostname&&r.pathname===n.pathname&&r.search===n.search){let e=r.hash,t=n.hash;return e!==t&&r.href.replace(e,"")===n.href.replace(t,"")}return!1}g.configure({showSpinner:null==r||r,trickle:null==n||n,trickleSpeed:null!=a?a:200,minimum:null!=s?s:.08,easing:null!=i?i:"ease",speed:null!=o?o:200,template:null!=d?d:'<div class="bar" role="bar"><div class="peg"></div></div><div class="spinner" role="spinner"><div class="spinner-icon"></div></div>'}),c(l,"isAnchorOfCurrentUrl");var u,m,f=document.querySelectorAll("html");let h=c(()=>f.forEach(e=>e.classList.remove("nprogress-busy")),"removeNProgressClass");function x(e){for(;e&&"a"!==e.tagName.toLowerCase();)e=e.parentElement;return e}function y(e){try{let t=e.target,r=x(t),n=null==r?void 0:r.href;if(n){let t=window.location.href,a=""!==r.target,s=["tel:","mailto:","sms:","blob:","download:"].some(e=>n.startsWith(e));if(!j(window.location.href,r.href))return;let i=l(t,n)||w(window.location.href,r.href);if(!p&&i)return;n===t||a||s||i||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||!v(r.href).startsWith("http")?(g.start(),g.done(),h()):g.start()}}catch(e){g.start(),g.done()}}function b(){g.done(),h()}function N(){g.done()}return c(x,"findClosestAnchor"),c(y,"handleClick"),e=(u=window.history).pushState,u.pushState=(...t)=>(g.done(),h(),e.apply(u,t)),t=(m=window.history).replaceState,m.replaceState=(...e)=>(g.done(),h(),t.apply(m,e)),c(b,"handlePageHide"),c(N,"handleBackAndForth"),window.addEventListener("popstate",N),document.addEventListener("click",y),window.addEventListener("pagehide",b),()=>{document.removeEventListener("click",y),window.removeEventListener("pagehide",b),window.removeEventListener("popstate",N)}},[]),b},"NextTopLoader"),w=v;v.propTypes={color:h.string,height:h.number,showSpinner:h.bool,crawl:h.bool,crawlSpeed:h.number,initialPosition:h.number,easing:h.string,
1speed:h.number,template:h.string,shadow:h.oneOfType([h.string,h.bool]),zIndex:h.number,showAtBottom:h.bool}},826119,e=>{"use strict";var t=e.i(843476),r=e.i(271645),n=e.i(653145),a=e.i(994814),s=e.i(681307),i=e.i(846696),o=e.i(423892),l=e.i(871689),c=e.i(643531),d=e.i(595468),u=e.i(531278),m=e.i(743687),p=e.i(167881),f=e.i(10708),h=e.i(307145),x=e.i(871443),g=e.i(722410),y=e.i(429552),b=e.i(834986),v=e.i(150746),w=e.i(552289),j=e.i(217103),N=e.i(864550),k=e.i(197345),C=e.i(794764),S=e.i(572041),P=e.i(907120),A=e.i(837012),I=e.i(748238);e.i(972694);var E=e.i(57146),_=e.i(272224),M=e.i(647163);let O="checkout_otp",T=s.z.object({phoneNumber:s.z.string().min(1,"Phone number is required").regex(/^\+?[1-9]\d{1,14}$/,"Invalid phone number format")}),L={verify:0,finishing:1,"address-map":1,"address-form":1},B=["Verify phone","Delivery address"],D={verify:{title:"Sign in to checkout",description:""},finishing:{title:"Signing you in",description:"Moving your cart to your accountâ¦"},"address-map":{title:"Where should we deliver?",description:"Search or drop the pin on the map."},"address-form":{title:"Confirm your address",description:"We'll deliver here."}};function R({onExit:e,exitLabel:s="Back to cart",onMapActiveChange:R,onContinueShopping:U}){let z=(0,P.useCheckoutAuthGateStore)(e=>e.isOpen),W=(0,P.useCheckoutAuthGateStore)(e=>e.close),[G,F]=(0,r.useState)("verify"),[$,V]=(0,r.useState)(""),[q,K]=(0,r.useState)(""),[Q,Y]=(0,r.useState)(null),[H,X]=(0,r.useState)(0),[J,Z]=(0,r.useState)(null),[ee,et]=(0,r.useState)(null),er=(0,y.useSendPasswordlessOtpMutation)(),en=(0,y.useVerifyPasswordlessOtpMutation)(),ea=(0,y.useCompletePasswordlessRegistrationMutation)(),{mutateAsync:es}=(0,C.useMergeCartMutation)(),ei=(0,S.useCheckoutStore)(e=>e.setDeliveryAddress),{track:eo}=(0,_.useAnalytics)(),el=(0,n.useForm)({resolver:(0,a.zodResolver)(T),defaultValues:{phoneNumber:""}}),ec=$.length>0,ed=er.isPending||en.isPending||ea.isPending;(0,r.useEffect)(()=>{if(H<=0)return;let e=setTimeout(()=>X(e=>e-1),1e3);return()=>clearTimeout(e)},[H]),(0,r.useEffect)(()=>{R?.("address-map"===G)},[G,R]),(0,r.useEffect)(()=>()=>R?.(!1),[R]);let eu=e=>{let{onComplete:t}=P.useCheckoutAuthGateStore.getState();W(),e&&i.toast.success(e),t?.()},em=async e=>{try{await er.mutateAsync({identifier:e}),V(e),K(""),Y(null),X(30)}catch(e){i.toast.error(e instanceof Error?e.message:"Failed to send code")}},ep=async e=>{let t=(0,A.getQueryClient)();try{await es()}catch(e){console.error("Cart merge failed",e)}e?eo({event:"sign_up",method:O}):(0,E.queuePendingLoginEvent)({method:O,account_type:"customer"}),await t.invalidateQueries({queryKey:I.queryKeys.session.all}),t.invalidateQueries({queryKey:I.queryKeys.profile.all})},ef=async()=>{F("finishing"),await ep(!1);let e=[];try{e=await (0,A.getQueryClient)().fetchQuery({queryKey:I.queryKeys.addresses.list(),queryFn:()=>j.addressApi.getAddresses(),staleTime:0})}catch(e){console.error("Could not load saved addresses",e)}if(e.length>0){let t=S.useCheckoutStore.getState().deliveryAddressId;e.some(e=>e.id===t)||ei((e.find(e=>e.isDefault)??e[0]).id),eu("You're signed in. Using your saved address.");return}F("address-map")},eh=async e=>{let t;if(!Q)return;let r=(t=e.fullName.trim().split(/\s+/).filter(Boolean)).length<2?null:{firstName:t[0],lastName:t.slice(1).join(" ")};if(!r)return void i.toast.error("Please enter your first and last name in Full Name.");let{firstName:n,lastName:a}=r;try{let t=await ea.mutateAsync({registrationToken:Q,firstName:n,lastName:a,address:e});if(!("user"in t))throw Error("Registration failed");F("finishing"),await ep(!0);let r=t.address?.id;if(!r)try{r=(await j.addressApi.createAddress(e)).id}catch(e){console.error("Could not save the delivery address",e)}r&&ei(r),eu("Account created. Welcome to DailyNeed!")}catch(e){i.toast.error(e instanceof Error?e.message:"Could not create your account. Please try again.")}},ex=async e=>{if(6===e.length&&ec)try{let t=await en.mutateAsync({identifier:$,code:e});if((0,b.passwordlessNeedsRegistration)(t)){Y(t.registrationToken),F("address-map");return}if(!(0,v.isLoginSuccess)(t))throw Error("This account needs extra verification. Please sign in from the login page.");await ef()}catch(e){K(""),i.toast.error(e instanceof Error?e.message:"Invalid code. Please try again.")}},eg=async()=>{await el.trigger("phoneNumber")&&await em(el.getValues("phoneNumber"))},ey=async()=>{Q?F("address-map"):await ex(q)},eb=(0,r.useCallback)(e=>K(e),[]);(0,w.useWebOTP)(eb,z&&"verify"===G&&ec&&!Q);let ev="verify"===G?e:"address-form"===G?()=>F("address-map"):"address-map"===G?Q?()=>F("verify"):e:null,ew=D[G],ej=L[G],eN="address-map"===G||"address-form"===G,{errors:ek}=el.formState;return(0,t.jsxs)("div",{className:"bg-primary flex h-full min-h-0 w-full flex-col overflow-hidden",children:[(0,t.jsxs)("div",{className:(0,M.cn)("relative overflow-hidden",eN?"shrink-0 pb-20":"h-[35%] min-h-40 shrink-0"),children:[(0,t.jsx)(g.HeaderSurface,{}),(0,t.jsxs)("div",{className:"text-primary-foreground relative z-10 flex items-start justify-between px-5 pt-7",children:[ev?(0,t.jsxs)("button",{type:"button",onClick:ev,"aria-label":"verify"===G?s:"Back",className:"flex items-center gap-2 text-sm font-medium transition-opacity hover:opacity-80",children:[(0,t.jsx)(l.ArrowLeft,{className:"h-5 w-5"}),"Back"]}):(0,t.jsx)("span",{}),(0,t.jsx)("button",{type:"button",onClick:U??e,className:"text-sm font-medium transition-opacity hover:opacity-80",children:"Continue Shopping"})]})]}),(0,t.jsxs)("div",{className:(0,M.cn)("bg-card relative z-10 -mt-10 flex min-h-0 flex-1 flex-col overflow-hidden rounded-t-[40px]"),children:[(0,t.jsxs)("div",{className:"shrink-0 border-b px-5 pt-6 pb-4",children:[(0,t.jsx)(m.DrawerTitle,{className:"text-center text-lg font-bold",children:ew.title}),(0,t.jsx)(m.DrawerDescription,{className:(0,M.cn)("text-muted-foreground text-center text-sm",!ew.description&&"sr-only"),children:ew.description||"Verify your phone number to check out."}),(0,t.jsxs)("div",{className:"relative mx-auto mt-5 w-full max-w-sm",children:[(0,t.jsx)("div",{"aria-hidden":!0,
1className:"bg-muted absolute top-4 right-1/4 left-1/4 h-1 -translate-y-1/2 overflow-hidden rounded-full",children:(0,t.jsx)("div",{className:"bg-brand-accent h-full rounded-full transition-[width] duration-500",style:{width:`${ej/(B.length-1)*100}%`}})}),(0,t.jsx)("ol",{className:"relative grid",style:{gridTemplateColumns:`repeat(${B.length}, minmax(0, 1fr))`},"aria-label":"Checkout progress",children:B.map((e,r)=>{let n=r<ej,a=r===ej;return(0,t.jsxs)("li",{className:"flex flex-col items-center gap-2","aria-current":a?"step":void 0,children:[(0,t.jsx)("span",{className:(0,M.cn)("flex size-8 items-center justify-center rounded-full text-sm font-bold transition-all",n&&"bg-brand-accent text-brand-accent-foreground",a&&"bg-brand-accent text-brand-accent-foreground ring-brand-accent/20 ring-4",!n&&!a&&"bg-card text-muted-foreground border-2 border-muted"),children:n?(0,t.jsx)(c.Check,{className:"h-4 w-4"}):r+1}),(0,t.jsx)("span",{className:(0,M.cn)("text-xs font-semibold whitespace-nowrap",a?"text-foreground":"text-muted-foreground"),children:e})]},e)})})]})]}),(0,t.jsx)("div",{className:(0,M.cn)("min-h-0 flex-1 overflow-y-auto",eN?"p-3":"px-5 py-5"),children:(0,t.jsxs)("div",{className:"w-full",children:["verify"===G&&(0,t.jsxs)("form",{id:"checkout-auth-verify-form",onSubmit:e=>{e.preventDefault(),ed||(ec?ey():eg())},className:"space-y-5",children:[(0,t.jsxs)("div",{className:"space-y-1.5","data-scroll-highlight":!0,children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)(f.Label,{htmlFor:"checkout-auth-phone",children:"Phone number"}),ec&&!Q&&(0,t.jsx)("button",{type:"button",onClick:()=>{V(""),K(""),Y(null),X(0)},disabled:ed,className:"text-primary text-xs font-semibold hover:underline disabled:opacity-50",children:"Change number"})]}),(0,t.jsxs)("div",{className:"flex items-start gap-2",children:[(0,t.jsx)(n.Controller,{control:el.control,name:"phoneNumber",render:({field:e})=>(0,t.jsx)(h.PhoneInput,{id:"checkout-auth-phone",value:e.value,onChange:e.onChange,defaultCountry:"NG",placeholder:"Enter phone number",autoFocus:!0,disabled:ec||ed,className:"min-w-0 flex-1 [&_input]:border-border [&_input]:bg-surface-subtle [&_input]:h-11"})}),Q?(0,t.jsxs)("span",{className:"text-success flex h-11 shrink-0 items-center gap-1 px-1 text-sm font-semibold",children:[(0,t.jsx)(d.CheckCircle2,{className:"h-4 w-4"}),"Verified"]}):(0,t.jsx)(p.Button,{type:"button",variant:ec?"outline":"default",className:"h-11 w-26 shrink-0 rounded-lg font-semibold",onClick:ec?()=>em($):eg,disabled:ed||ec&&H>0,children:er.isPending?(0,t.jsx)(u.Loader2,{className:"h-4 w-4 animate-spin"}):ec?H>0?`Resend ${H}s`:"Resend":"Get OTP"})]}),ek.phoneNumber&&(0,t.jsx)("p",{className:"text-destructive text-sm",children:ek.phoneNumber.message})]}),ec&&!Q&&(0,t.jsxs)("div",{className:"space-y-2","data-scroll-highlight":!0,children:[(0,t.jsxs)("div",{className:"flex items-baseline justify-between gap-2",children:[(0,t.jsx)(f.Label,{children:"Enter OTP"}),(0,t.jsxs)("span",{className:"text-muted-foreground truncate text-xs",children:["Sent to ",$]})]}),(0,t.jsx)(x.InputOTP,{maxLength:6,pattern:o.REGEXP_ONLY_DIGITS,value:q,onChange:K,autoComplete:"one-time-code",inputMode:"numeric",disabled:ed,autoFocus:!0,containerClassName:"justify-center",children:(0,t.jsx)(x.InputOTPGroup,{className:"gap-2",children:[0,1,2,3,4,5].map(e=>(0,t.jsx)(x.InputOTPSlot,{index:e,className:"size-11 rounded-lg border text-lg font-semibold first:rounded-l-lg last:rounded-r-lg sm:size-12"},e))})})]})]}),"finishing"===G&&(0,t.jsx)("div",{className:"flex justify-center py-10",children:(0,t.jsx)(u.Loader2,{className:"text-primary h-8 w-8 animate-spin"})}),"address-map"===G&&(0,t.jsx)(k.AddressMapStep,{onNext:(e,t)=>{Z(e),et(t??null),F("address-form")},onBack:ev??e,hideHeader:!0}),"address-form"===G&&(0,t.jsx)(N.AddressFormStep,{coords:J??void 0,initialDetails:ee?{...ee,phone:ee.phone??$}:{phone:$},onSuccess:e=>{ei(e),eu()},asGuestSubmit:Q?eh:void 0,isSubmitting:ea.isPending})]})}),"verify"===G&&(0,t.jsx)("div",{className:"bg-card shrink-0 border-t px-4 py-3",children:(0,t.jsxs)(p.Button,{type:"button",variant:"success",size:"lg",className:"w-full rounded-full font-semibold",disabled:ed||!ec||!Q&&6!==q.length,onClick:ey,children:[(en.isPending||ea.isPending)&&(0,t.jsx)(u.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Continue"]})})]})]})}function U(){let e=(0,P.useCheckoutAuthGateStore)(P.selectShowsInSheet),n=(0,P.useCheckoutAuthGateStore)(e=>e.close),[a,s]=(0,r.useState)(!1);return(0,t.jsx)(m.Drawer,{open:e,dismissible:!a,onOpenChange:e=>{e||n()},children:(0,t.jsx)(m.DrawerContent,{className:"flex h-[90vh] max-h-[90vh] flex-col overflow-hidden md:h-screen",children:e&&(0,t.jsx)(R,{onExit:n,exitLabel:"Close",onMapActiveChange:s})})})}e.s(["CheckoutAuthFlow",()=>R,"CheckoutAuthSheet",()=>U])},751403,e=>{"use strict";var t=e.i(843476),r=e.i(271645),n=e.i(618566),a=e.i(201928),s=e.i(531278),i=e.i(39312),o=e.i(878894),l=e.i(299023),
1c=e.i(107233),d=e.i(664659),u=e.i(846696),m=e.i(167881),p=e.i(743687),f=e.i(846932),h=e.i(88653),x=e.i(833747),g=e.i(30672),y=e.i(857259),b=e.i(185562),v=e.i(192223),w=e.i(147625),j=e.i(647163),N=e.i(325015),k=e.i(463059);let C=[{top:5,left:-6,rotate:-10},{top:-6,left:5,rotate:12},{top:7,left:8,rotate:7},{top:-3,left:-3,rotate:-5}];function S({cartItemCount:e,compact:n=!1,previewImages:s,isDesktop:i=!1}){return e<=0?null:(0,t.jsx)(p.DrawerTrigger,{asChild:!0,children:(0,t.jsxs)("button",{type:"button",className:"cart-offer-trigger-surface cart-trigger-surface flex h-[52px] w-[110px] shrink-0 cursor-pointer items-center justify-center rounded-[10px] border px-4 transition-all active:scale-[0.98] md:w-[120px] md:rounded-[12px]",children:[(0,t.jsx)("div",{className:(0,j.cn)("relative container flex h-full w-full items-center justify-center md:w-auto md:gap-1.5",n&&"md:h-8 md:w-8 md:shrink-0"),children:s.length>0?s.map((e,n)=>{var a;return(0,t.jsxs)(r.Fragment,{children:[(0,t.jsx)("div",{className:"cart-offer-preview-image absolute hidden h-5 w-5 shrink-0 overflow-hidden rounded-sm border md:block",style:function(e){let{top:t,left:r,rotate:n}=C[e%C.length];return{top:`${t}px`,left:`${r}px`,transform:`rotate(${n}deg)`,zIndex:e}}(n),children:(0,t.jsx)("img",{src:e,alt:"",className:"absolute inset-0 h-full w-full object-contain p-0.5"})}),(0,t.jsx)("div",{className:"cart-offer-preview-image absolute block h-5 w-5 shrink-0 overflow-hidden rounded-sm border md:hidden",style:(a=s.length,i?{left:`${-(10*n)}px`}:{left:`${10*n}px`,zIndex:n,transform:1===a?"rotate(0deg)":2===a?`rotate(${0===n?-6:6}deg)`:`rotate(${(n-1)*10}deg)`}),children:(0,t.jsx)("img",{src:e,alt:"",className:"absolute inset-0 h-full w-full object-contain p-0.5"})})]},`${e}-${n}`)}):(0,t.jsx)("div",{className:"cart-offer-trigger-empty-icon-bg flex h-8 w-8 items-center justify-center rounded-lg",children:(0,t.jsx)(a.ShoppingCart,{size:18,className:"cart-offer-icon-muted"})})}),(0,t.jsxs)("div",{className:(0,j.cn)("flex items-center justify-center gap-3",n&&"md:gap-1"),children:[(0,t.jsxs)("div",{className:(0,j.cn)("flex flex-col items-start justify-center md:flex-row md:items-center md:gap-3",n&&"md:flex-col md:items-center md:gap-0.5"),children:[(0,t.jsx)(a.ShoppingCart,{size:n?19:16,className:"cart-offer-text-primary",strokeWidth:2.5}),(0,t.jsxs)("span",{className:"cart-offer-text-secondary text-[9px] font-medium whitespace-nowrap",children:[e," ",1===e?"Item":"Items"]})]}),(0,t.jsx)(k.ChevronRight,{className:(0,j.cn)("cart-offer-icon-strong hidden h-5 w-5 stroke-[2.5] md:block",n&&"md:hidden")})]})]})})}let P=new Set(["/login","/register","/terms","/privacy","/about","/account-deletion","/cookie-policy","/blog","/blog/"]);function A({className:e,cartItemCount:r=0,showCartButton:a=!1}){let s=(0,n.usePathname)(),{cartItems:i}=(0,x.useCartLogic)(),o=(0,N.useMediaQuery)("(min-width: 768px)");if(P.has(s)||s.startsWith("/blog")||!a)return null;let l=i.slice(0,o?3:2).map(e=>e.imageUrl).filter(Boolean);return(0,t.jsx)("div",{className:(0,j.cn)("mx-auto flex w-full items-end justify-end gap-1 overflow-visible",e),children:(0,t.jsx)(S,{cartItemCount:r,compact:!0,previewImages:l,isDesktop:o})})}var I=e.i(352167),E=e.i(572041),_=e.i(907120),M=e.i(826119),O=e.i(924672),T=e.i(17928);e.i(972694);var L=e.i(533187),B=e.i(272224),D=e.i(172138),R=e.i(794764),U=e.i(837012),z=e.i(890538),W=e.i(81751),G=e.i(266126),F=e.i(811673),$=e.i(57403);function V(e){return"string"==typeof e&&e.startsWith("signature:")}function q(e){return!!e.metadata?.signatureBundle}function K({basketId:e,quantity:r,disabled:n}){let{quantity:a,isPending:s,handleIncrement:i,handleDecrement:o}=(0,G.useBasketCartLogic)(e),d=a||r,u=n||s;return(0,t.jsxs)("div",{className:"flex h-[26px] min-w-[66px] items-center justify-between rounded-full add-control cart-stepper border px-1 sm:h-[36px] sm:min-w-[98px] sm:border-2 sm:px-2",onClick:e=>e.stopPropagation(),children:[(0,t.jsx)(m.Button,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 text-brand-accent hover:bg-transparent hover:text-brand-accent sm:h-6 sm:w-6",onClick:e=>{e.stopPropagation(),o(e)},disabled:u||d<=0,children:(0,t.jsx)(l.Minus,{className:"h-2.5 w-2.5 sm:h-3 sm:w-3"})}),(0,t.jsx)("span",{className:"min-w-4 text-center text-[12px] font-semibold text-foreground tabular-nums sm:min-w-5 sm:text-[15px]",children:d}),(0,t.jsx)(m.Button,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 text-brand-accent hover:bg-transparent hover:text-brand-accent sm:h-6 sm:w-6",onClick:e=>{e.stopPropagation(),i(e)},disabled:u,children:(0,t.jsx)(c.Plus,{className:"h-2.5 w-2.5 sm:h-3 sm:w-3"})})]})}function Q(){let e=(0,n.useRouter)(),k=(0,n.usePathname)(),{isAuthenticated:C}=(0,y.useSession)(),S=(0,_.useCheckoutAuthGate)(),{cart:P,cartItems:G,cartTotal:Q,cartItemCount:Y,isUpdating:H,isRemoving:X,isAdding:J,handleUpdateQty:Z,handleRemove:ee,handleRemoveBundle:et,cartEligibleTotal:er,cartOriginalSubtotal:en,cartSubtotal:ea,cartTotals:es,handleAddSignatureBundle:ei}=(0,x.useCartLogic)(),eo=(0,U.getQueryClient)(),el=r.useMemo(()=>{let e=new Map;
1for(let t of P?.bundleGroups??[])e.set(t.id,t.name??"Custom Bundle");return e},[P?.bundleGroups]),ec=r.useMemo(()=>{let e=new Map;for(let t of P?.bundleGroups??[])e.set(t.id,{basketId:t.basketId??t.id,name:t.name??"Custom Bundle"});return e},[P?.bundleGroups]),ed=r.useMemo(()=>{let e=new Map;for(let t of P?.bundleGroups??[])e.set(t.id,t.appliedOffer??null);return e},[P?.bundleGroups]),eu=r.useMemo(()=>{let e=new Set;for(let t of G){if(t?.lineType==="free_gift"||t?.metadata?.isFreeGift||t?.isFreeGift||t?.bundleId)continue;let r=t?.metadata?.productType;if("predefined_combo"===r||"bundle"===r)continue;let n=String(t?.variantId??"").trim(),a=String(t?.sku??"").trim(),s=n&&"00000000-0000-0000-0000-000000000000"!==n?`variant:${n}`:a?`sku:${a}`:"";s&&e.add(s)}return e.size},[G]),em=H||X||J,[ep,ef]=r.useState(!1);r.useEffect(()=>{ef(!0)},[]);let[eh,ex]=r.useState(!1),[eg,ey]=r.useState(!1),[eb,ev]=r.useState(""),[ew,ej]=r.useState(null),[eN,ek]=r.useState(!1),eC=(0,N.useMediaQuery)("(min-width: 768px)"),{setCheckoutDrawerOpen:eS,outOfStockItems:eP,setOutOfStockItems:eA}=(0,E.useCheckoutStore)(),{track:eI}=(0,B.useAnalytics)(),{isOpen:eE,setOpen:e_}=(0,g.useCartDrawer)();(0,F.useCartStockValidation)(G,{enabled:eE});let eM=(0,_.useCheckoutAuthGateStore)(_.selectShowsInCartDrawer),eO=(0,_.useCheckoutAuthGateStore)(e=>e.close),eT=(0,_.useCheckoutAuthGateStore)(e=>e.setCartDrawerAvailable),[eL,eB]=r.useState(!1),eD=r.useRef(!1);r.useEffect(()=>{if(!eE){eD.current=!1;return}if(eD.current||0===G.length)return;eD.current=!0;let e=P?.currency??"NGN",t=G.map(t=>(0,L.cartLineToProductLine)(t,e));eI({event:"view_cart",ecommerce:{currency:e,value:Q,items:(0,L.toGa4Items)(t)}})},[eE,G,Q,P?.currency,eI]);let eR=r.useMemo(()=>new Map(eP.map(e=>[e.sku,{available:e.available,requested:e.requested}])),[eP]),eU=r.useCallback(e=>{let t=eR.get(e.sku);return!!t&&e.quantityPieces>t.available},[eR]),ez=r.useMemo(()=>G.filter(e=>!eU(e)),[G,eU]),eW=r.useMemo(()=>G.filter(e=>eU(e)),[G,eU]),eG=r.useMemo(()=>eW.map(e=>e.id).sort((e,t)=>e.localeCompare(t)).join(","),[eW]),eF=r.useCallback(e=>e.bundleId??null,[]),e$=r.useMemo(()=>{let e=new Map,t=[],r=new Set;for(let n of ez){let a=eF(n);if(!a){t.push({kind:"item",item:n});continue}let s=ec.get(a),i=s?.basketId??a,o=V(i)||q(n),l=e.get(i);l||(l={id:i,name:s?.name??el.get(a)??"Custom Bundle",items:[],bundleIds:[],instanceCount:0,isSignatureBundle:o},e.set(i,l)),l.items.push(n),l.bundleIds.includes(a)||(l.bundleIds.push(a),l.instanceCount+=1),r.has(i)||(r.add(i),t.push({kind:"bundle",id:i}))}return{rows:t,groups:e}},[eF,el,ec,ez]),eV=r.useMemo(()=>{let e=new Map,t=[],r=new Set;for(let n of eW){let a=eF(n);if(!a){t.push({kind:"item",item:n});continue}let s=ec.get(a),i=s?.basketId??a,o=e.get(a);o||(o={id:a,name:el.get(a)??"Custom Bundle",items:[],isSignatureBundle:V(i)||q(n)},e.set(a,o)),o.items.push(n),r.has(a)||(r.add(a),t.push({kind:"bundle",id:a}))}return{rows:t,groups:e}},[eF,el,eW]);r.useEffect(()=>{eE&&eW.length>0&&eG!==eb&&(ey(!0),ev(eG))},[eE,eW.length,eG,eb]),r.useEffect(()=>{if(0===eP.length)return;let e=eP.filter(e=>{let t=G.find(t=>t.sku===e.sku);return!!t&&t.quantityPieces>e.available});e.length!==eP.length&&eA(e)},[G,eP,eA]),P?.metadata;let eq=async t=>{if(t?.stopPropagation(),(0,j.vibrate)("success"),0!==G.length){if((0,T.minCartShortfall)(ea)>0)return void u.toast.error((0,T.minCartMessage)(ea));if(!C&&"corporate"===(0,O.detectTenant)(window.location.hostname))return void S(()=>{e_(!1),eC?eS(!0):e.push("/checkout")},"cart-drawer");if(eC){e_(!1),eS(!0);return}Y>0&&C&&(ex(!0),await new Promise(e=>setTimeout(e,1e3)),ex(!1)),e_(!1),e.push("/checkout")}},eK=r.useCallback(async(e,t)=>{let r=eR.get(e.sku);if(r&&t>r.available)return void ej({available:Math.max(0,r.available)});if(t>e.quantityPieces&&e.variantId)try{await D.checkoutApi.checkStock({skus:(0,$.expandStockCheckSkus)([{...e,quantityPieces:t}])})}catch(r){let t="object"==typeof r&&null!==r&&"data"in r&&r.data&&"object"==typeof r.data&&"outOfStockItems"in r.data&&Array.isArray(r.data?.outOfStockItems)&&r.data?.outOfStockItems||[];if(t.length>0){eA(t.map(e=>({variantId:e.variantId,sku:e.sku,productName:e.productName||e.sku,requested:e.requested,available:e.available})));let r=t.find(t=>t.sku===e.sku);ej({available:Math.max(0,r?.available??t[0].available)})}else u.toast.error("Unable to increase quantity due to stock limits.");return}Z(e.id,t)},[eR,Z,eA]),eQ=["/checkout","/orders","/login","/register"].some(e=>k?.includes(e))||["/profile","/faq","/help-center","/about","/cookie-policy","/terms","/privacy","/approval-pending"].some(e=>k?.startsWith(e));return(r.useEffect(()=>{if(!eQ)return eT(!0),()=>eT(!1)},[eQ,eT]),eQ)?null:(0,t.jsxs)(p.Drawer,{open:eE,dismissible:!eL,onOpenChange:e=>{e_(e),!e&&eM&&eO()},children:[(0,t.jsx)(h.AnimatePresence,{children:ep&&Y>0&&(0,t.jsx)(f.motion.div,{initial:{scale:.3,opacity:0}
1,animate:{scale:1,opacity:1},exit:{scale:.3,opacity:0},transition:{type:"spring",damping:20,stiffness:150},className:"fixed inset-x-0 bottom-20 z-50 px-3 md:inset-x-auto md:right-4 md:bottom-4 md:w-[250px]",children:(0,t.jsx)(A,{cartItemCount:Y,showCartButton:!0})})}),(0,t.jsx)(p.DrawerContent,{className:"flex h-[90vh] max-h-[90vh] flex-col md:h-screen",children:eM?(0,t.jsx)(f.motion.div,{initial:{opacity:0,x:24},animate:{opacity:1,x:0},transition:{type:"spring",damping:24,stiffness:200},className:"flex h-full min-h-0 w-full flex-col",children:(0,t.jsx)(M.CheckoutAuthFlow,{onExit:eO,onMapActiveChange:eB,onContinueShopping:()=>{eO(),e_(!1)}})},"checkout-auth"):(0,t.jsxs)(f.motion.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{type:"spring",damping:22,stiffness:160},className:"flex h-full w-full flex-col",children:[(0,t.jsxs)(p.DrawerHeader,{className:"flex shrink-0 flex-row items-center justify-between border-b px-4 py-5",children:[(0,t.jsxs)(p.DrawerTitle,{className:"flex items-center gap-3 text-xl font-bold",children:[(0,t.jsx)(a.ShoppingCart,{className:"text-brand-accent h-7 w-7"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-brand-accent text-sm font-semibold",children:"Cart"}),(0,t.jsxs)("p",{className:"text-muted-foreground text-xs",children:[Y," item",1!==Y?"s":""]})]})]}),eu>=2&&C&&(0,t.jsxs)(m.Button,{variant:"outline",size:"sm",className:"add-control hover:bg-brand-accent/5 h-8 gap-1.5 rounded-full text-[10px] font-bold md:text-xs",onClick:()=>ek(!0),children:[(0,t.jsx)(i.Zap,{className:"h-3 w-3 fill-current"}),"Save as Combo"]})]}),(0,t.jsx)(W.SaveAsComboDialog,{isOpen:eN,onOpenChange:ek,fromCart:!0,items:G.map(e=>({sku:e.sku,variantId:e.variantId||"00000000-0000-0000-0000-000000000000",productId:e.productId||"00000000-0000-0000-0000-000000000000",quantity:e.metadata?.sellableUnit==="carton"?Math.ceil(e.quantityPieces/(e.piecesPerCarton||1)):e.quantityPieces,piecePerCarton:e.piecesPerCarton||1,uom:e.metadata?.sellableUnit||"piece",category:e.category,metadata:{uiLockedUnit:e.metadata?.uiLockedUnit??!1,taxRate:e.metadata?.taxRate,productName:e.productName??e.name??"",variantName:e.productName??e.name??"",brand:e.brand??"",imageUrl:e.imageUrl??"",isFreeGift:!!(e.isFreeGift??e.metadata?.isFreeGift),productType:e.metadata?.productType??null,pricing:{pricePerCarton:Number(e.metadata?.cartonPrice??e.unitPriceSnapshotAmount??0),pricePerPack:Number(e.metadata?.piecePrice??e.unitPriceSnapshotAmount??0),currency:"NGN"}}}))}),(0,t.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto border-none",children:[(0,t.jsx)("div",{className:"px-1 py-2 sm:px-1.5 sm:py-3",children:G.length>0?(0,t.jsxs)("div",{className:"space-y-1 rounded-lg sm:space-y-1.5",children:[e$.rows.map(e=>{if("item"===e.kind){let r=e.item;return(0,t.jsx)(b.CartItem,{item:r,onUpdateQty:(e,t)=>eK(r,t),onRemove:e=>ee(e),isPending:em},r.id)}let r=e$.groups.get(e.id);if(!r)return null;let n=r.bundleIds.map(e=>{let t=r.items.filter(t=>t.bundleId===e).map(e=>({...e,metadata:e.metadata?{...e.metadata,discount:void 0}:e.metadata})),{subtotal:n}=(0,j.computeItemsSubtotal)(t),a=ed.get(e),s=t.some(e=>{let t=e.metadata;return!!(t?.isFreeGift||t?.isGift)}),i=n;if(a){let e=(0,j.isFreeGiftBundleOffer)(a,s)||"buy_x_get_y"===String(a.promoKind??"").toLowerCase()||"free_gift"===String(a.discountType??"").toLowerCase();!e&&"number"==typeof a.finalValue&&"number"==typeof a.comboTotal&&1>Math.abs(a.comboTotal-n)?i=a.finalValue:e||"number"!=typeof a.discountAmount?e||"percentage"!==a.discountType||"number"!=typeof a.discountValue||(i=n*(1-a.discountValue/100)):i=Math.max(0,n-a.discountAmount)}return{originalSubtotal:n,subtotal:i}}),a=n.reduce((e,t)=>e+t.originalSubtotal,0),s=n.reduce((e,t)=>e+t.subtotal,0),i=r.isSignatureBundle?r.items.find(e=>e.metadata?.signatureBundleParentPrice!=null)?.metadata??{}:null,o=Number(i?.signatureBundleParentPrice),u=Number(i?.signatureBundleParentStrikePrice),p=r.isSignatureBundle&&Number.isFinite(o)&&o>0,f=p?o*r.instanceCount:s,h=p&&Number.isFinite(u)&&u>o?u*r.instanceCount:a,x=function(e){let t=new Set;for(let r of e)t.add(String(r.variantId||r.sku||r.id));return t.size}(r.items),g=async e=>{e.stopPropagation();let t=r.bundleIds[0],n=r.items.filter(e=>e.bundleId===t);n.length&&(await ei({basketId:r.id,name:r.name||"Bundle",items:n.map(e=>{var t;let r=e.metadata??{};return{sku:e.sku,category:e.category||r.category||"Bundle",baseUnit:e.baseUnit,packagingUnit:"bag"===(t=e.packagingUnit??r.packagingUnit)||"box"===t||"crate"===t?t:"carton",variantId:e.variantId,productName:e.productName,variantName:e.variantName,brand:e.brand,imageUrl:e.imageUrl,imageAlt:e.imageAlt,quantityPieces:e.quantityPieces,unitPriceSnapshotAmount:e.unitPriceSnapshotAmount,priceSnapshotCurrency:e.priceSnapshotCurrency,minOrderQuantityPieces:e.minOrderQuantityPieces,piecesPerCarton:e.piecesPerCarton||1,metadata:r}})}
1),await eo.invalidateQueries({queryKey:R.cartKeys.all}))},y=async e=>{e.stopPropagation();let t=r.bundleIds[r.bundleIds.length-1];t&&await et(t)};return(0,t.jsx)(z.Accordion,{type:"single",collapsible:!0,className:"cart-row bg-card",children:(0,t.jsxs)(z.AccordionItem,{value:r.id,className:"border-0",children:[(0,t.jsx)("div",{className:"relative",children:(0,t.jsx)(z.AccordionTrigger,{className:"group grid grid-cols-[44px_minmax(0,1fr)_auto] items-center gap-2 px-1.5 py-1.5 hover:no-underline focus:ring-0 focus:outline-none sm:grid-cols-[48px_minmax(0,1fr)_auto] sm:gap-3 sm:px-3 sm:py-2 [&>svg]:hidden",children:(0,t.jsxs)("div",{className:"contents",children:[(0,t.jsx)(w.ComboImageStack,{images:r.items.map(e=>e.imageUrl).filter(Boolean),className:"h-[44px] w-[44px] shrink-0 sm:h-[48px] sm:w-[48px]",label:r.isSignatureBundle?"COMBO":"MY COMBO"}),(0,t.jsxs)("div",{className:"min-w-0 text-left",children:[(0,t.jsx)("span",{className:"text-[11px] leading-tight font-medium text-foreground sm:text-[13px]",children:r.name||"Bundle"}),(0,t.jsxs)("span",{className:"mt-0.5 flex items-center gap-1 text-[9px] font-medium text-muted-foreground sm:text-[11px]",children:[x," ","item",1!==x?"s":"",(0,t.jsx)(d.ChevronDown,{className:"h-3.5 w-3.5 shrink-0 transition-transform duration-200 group-data-[state=open]:rotate-180"})]}),(0,t.jsxs)("div",{className:"mt-0.5 flex flex-wrap items-baseline gap-1.5 sm:mt-1 sm:gap-2",children:[(0,t.jsx)("span",{className:"text-[12px] leading-tight font-semibold text-foreground sm:text-[16px]",children:(0,j.formatMoney)(f)}),h>f+1&&(0,t.jsx)("span",{className:"text-[10px] leading-tight font-medium text-muted-foreground line-through sm:text-[12px]",children:(0,j.formatMoney)(h)})]})]}),(0,t.jsx)("div",{className:"flex items-center justify-end gap-1",children:r.isSignatureBundle?(0,t.jsxs)("div",{className:"flex h-[26px] min-w-[66px] items-center justify-between rounded-full add-control cart-stepper border px-1 sm:h-[36px] sm:min-w-[98px] sm:border-2 sm:px-2",onClick:e=>e.stopPropagation(),children:[(0,t.jsx)(m.Button,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 text-brand-accent hover:bg-transparent hover:text-brand-accent sm:h-6 sm:w-6",onClick:y,disabled:em||r.instanceCount<=0,children:(0,t.jsx)(l.Minus,{className:"h-2.5 w-2.5 sm:h-3 sm:w-3"})}),(0,t.jsx)("span",{className:"min-w-4 text-center text-[12px] font-semibold tabular-nums text-foreground sm:min-w-5 sm:text-[15px]",children:r.instanceCount}),(0,t.jsx)(m.Button,{type:"button",variant:"ghost",size:"icon",className:"h-5 w-5 text-brand-accent hover:bg-transparent hover:text-brand-accent sm:h-6 sm:w-6",onClick:g,disabled:em,children:(0,t.jsx)(c.Plus,{className:"h-2.5 w-2.5 sm:h-3 sm:w-3"})})]}):(0,t.jsx)(K,{basketId:r.id,quantity:r.instanceCount,disabled:em})})]})})}),(0,t.jsx)(z.AccordionContent,{className:"pb-0",children:(0,t.jsx)("div",{className:"space-y-1.5",children:(function(e){let t=new Map,r=new Map,n=[];for(let a of e){let e=a.metadata;if(e?.isFreeGift||e?.isGift){let t=String(e?.originalVariantId||a.sku||a.variantId||a.id).trim().toLowerCase();if(!r.has(t)){let s={...a,quantityPieces:Math.max(1,a.quantityPieces||1),metadata:e?{...e}:e,__mergedSourceCount:1};r.set(t,s),n.push(s)}continue}let s=[a.variantId||a.sku].join("::"),i=t.get(s);if(!i){let r={...a,metadata:e?{...e}:e,__mergedSourceCount:1};t.set(s,r),n.push(r);continue}i.quantityPieces+=a.quantityPieces,i.__mergedSourceCount+=1}return n})(r.items).map(e=>(0,t.jsx)(b.CartItem,{item:e,onUpdateQty:(t,r)=>eK(e,r),onRemove:e=>ee(e),isPending:em,readonly:!0,ignoreItemDiscount:!0,hideQuantityControls:!0},e.id))})})]})},`bundle-${r.id}`)}),eW.length>0&&(0,t.jsxs)("div",{className:"mt-3 rounded-xl border border-danger-soft-border bg-danger-soft p-3",children:[(0,t.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,t.jsx)("p",{className:"text-[13px] font-bold text-danger",children:"Out of Stocks Items"}),(0,t.jsxs)("p",{className:"text-[12px] font-medium text-muted-foreground",children:[eW.length," ","items"]})]}),(0,t.jsx)("div",{className:"bg space-y-1.5",children:eV.rows.map(e=>{if("item"===e.kind){let r=e.item;return(0,t.jsx)(b.CartItem,{item:r,onUpdateQty:(e,t)=>eK(r,t),onRemove:e=>ee(e),isPending:em,readonly:!1,isOutOfStock:!0},r.id)}let r=eV.groups.get(e.id);if(!r)return null;let n=r.items.map(e=>({...e,metadata:e.metadata?{...e.metadata,discount:void 0}:e.metadata})),{subtotal:a}=(0,j.computeItemsSubtotal)(n),s=ed.get(r.id),i=r.items.some(e=>{let t=e.metadata;return!!(t?.isFreeGift||t?.isGift)}),o=a;if(s){let e=(0,j.isFreeGiftBundleOffer)(s,i)||"buy_x_get_y"===String(s.promoKind??"").toLowerCase()||"free_gift"===String(s.discountType??"").toLowerCase();!e&&"number"==typeof s.finalValue&&"number"==typeof s.comboTotal&&1>Math.abs(s.comboTotal-a)?o=s.finalValue:e||"number"!=typeof s.discountAmount?e||"percentage"!==s.discountType||"number"!=typeof s.discountValue||(o=a*(1-s.discountValue/100)):o=Math.max(0,a-s.discountAmount)}let l=o;return(0,t.jsx)(z.Accordion,{type:"single",collapsible:!0,className:"cart-row bg-card",children:(0,t.jsxs)(z.AccordionItem,{value:r.
1id,className:"border-none outline-none",children:[(0,t.jsx)("div",{className:"relative",children:(0,t.jsx)(z.AccordionTrigger,{className:"grid grid-cols-[44px_minmax(0,1fr)_auto] items-center gap-2 px-1.5 py-1.5 hover:no-underline focus:ring-0 focus:outline-none sm:grid-cols-[48px_minmax(0,1fr)_auto] sm:gap-3 sm:px-3 sm:py-2 [&>svg]:ml-0 [&>svg]:h-4 [&>svg]:w-4 [&>svg]:text-danger",children:(0,t.jsxs)("div",{className:"contents",children:[(0,t.jsx)(w.ComboImageStack,{images:r.items.map(e=>e.imageUrl).filter(Boolean),className:"h-[44px] w-[44px] shrink-0 grayscale sm:h-[48px] sm:w-[48px]",label:r.isSignatureBundle?"COMBO":"MY COMBO"}),(0,t.jsxs)("div",{className:"min-w-0 text-left",children:[(0,t.jsx)("span",{className:"line-clamp-1 text-[11px] leading-tight font-medium text-danger sm:line-clamp-2 sm:text-[13px]",children:r.name||"Bundle"}),(0,t.jsxs)("span",{className:"mt-0.5 block text-[9px] font-medium text-muted-foreground sm:text-[11px]",children:[r.items.length," ","item",1!==r.items.length?"s":""]}),(0,t.jsxs)("div",{className:"mt-0.5 flex flex-wrap items-baseline gap-1.5 sm:mt-1 sm:gap-2",children:[(0,t.jsx)("span",{className:"text-[12px] leading-tight font-semibold text-danger sm:text-[16px]",children:(0,j.formatMoney)(l)}),a>l+1&&(0,t.jsx)("span",{className:"text-[10px] leading-tight font-medium text-muted-foreground line-through sm:text-[12px]",children:(0,j.formatMoney)(a)})]})]})]})})}),(0,t.jsx)(z.AccordionContent,{className:"pb-0",children:(0,t.jsx)("div",{className:"space-y-1.5",children:r.items.map(e=>(0,t.jsx)(b.CartItem,{item:e,onUpdateQty:(t,r)=>eK(e,r),onRemove:e=>ee(e),isPending:em,readonly:!0,isOutOfStock:!0,ignoreItemDiscount:!0,hideQuantityControls:!0},e.id))})})]})},`bundle-${r.id}`)})})]})]}):(0,t.jsxs)("div",{className:"text-muted-foreground flex h-48 flex-col items-center justify-center space-y-4 text-center",children:[(0,t.jsx)(a.ShoppingCart,{className:"h-16 w-16 opacity-20"}),(0,t.jsx)("p",{children:"Your cart is empty"})]})}),G.length>0&&(0,t.jsx)("div",{className:"relative mt-3 bg-card pt-6",children:(0,t.jsx)(I.CustomersAlsoBought,{isCart:!0})})]}),(0,t.jsxs)(p.DrawerFooter,{className:"shrink-0 border-t bg-card px-4 py-3",children:[Y>0&&(0,T.minCartShortfall)(ea)>0&&(0,t.jsxs)("div",{className:"mb-3 space-y-1.5",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between text-xs",children:[(0,t.jsxs)("span",{className:"font-semibold",children:["Add ",(0,j.formatMoney)((0,T.minCartShortfall)(ea))," to checkout"]}),(0,t.jsxs)("span",{className:"text-muted-foreground",children:[(0,j.formatMoney)(ea)," /"," ",(0,j.formatMoney)(T.MIN_CART_VALUE)]})]}),(0,t.jsx)("div",{role:"progressbar","aria-valuemin":0,"aria-valuemax":T.MIN_CART_VALUE,"aria-valuenow":Math.round(ea),"aria-label":"Progress to minimum order value",className:"bg-muted h-2 overflow-hidden rounded-full",children:(0,t.jsx)(f.motion.div,{className:"h-full rounded-full bg-(image:--success-gradient)",initial:!1,animate:{width:`${Math.min(100,ea/T.MIN_CART_VALUE*100)}%`},transition:{type:"spring",damping:25,stiffness:180}})})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex flex-col",children:[en>(ea??0)+1&&(0,t.jsx)("span",{className:"text-muted-foreground text-xs line-through",children:(0,j.formatMoney)(en)}),(0,t.jsx)("span",{className:"text-xl font-bold",children:(0,j.formatMoney)(ea)})]}),(0,t.jsx)(m.Button,{variant:"success",size:"lg",className:(0,j.cn)("rounded-full px-8 font-semibold shadow-lg",(0,T.minCartShortfall)(ea)>0&&"opacity-50"),"aria-disabled":(0,T.minCartShortfall)(ea)>0,onClick:()=>eq(),disabled:0===Y||eh,children:eh?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(s.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Preparing..."]}):"Checkout"})]})]})]},"cart")}),(0,t.jsx)(p.Drawer,{open:eg,onOpenChange:ey,children:(0,t.jsx)(p.DrawerContent,{className:"mx-auto max-w-md rounded-t-3xl px-4 pb-4",children:(0,t.jsxs)("div",{className:"space-y-4 pt-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-center gap-2 text-center text-danger",children:[(0,t.jsx)(o.AlertTriangle,{className:"h-5 w-5"}),(0,t.jsx)("h3",{className:"text-2xl font-semibold",children:"Some items out of stock in your cart"})]}),(0,t.jsx)("div",{className:"flex justify-center gap-3",children:eW.slice(0,4).map(e=>(0,t.jsx)("div",{className:"relative h-16 w-16 overflow-hidden rounded-xl border border-danger-soft-border bg-card",children:(0,t.jsx)(v.SafeImage,{src:e.imageUrl,alt:e.imageAlt??e.productName??e.sku,fill:!0,className:"object-contain p-1"})},e.id))}),(0,t.jsx)("p",{className:"text-center text-lg font-medium text-foreground",children:"Some items in your cart are now out of stock. Please review your cart to continue."}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,t.jsx)(m.Button,{variant:"outline",className:"h-11 rounded-full text-base font-semibold",onClick:()=>ey(!1),children:"Go to Cart"}),(0,t.jsx)(m.Button,{variant:"destructive",className:"h-11 rounded-full text-base font-semibold",onClick:async()=>{ey(!1),await eq()},children:"Continue"})]}),(0,t.jsx)("p",{className:"text-center text-xs text-muted-foreground",children:"By continuing, you'll proceed with available items only"})]})})}),(0,t.jsx)(p.Drawer,{open:!!ew,onOpenChange:e=>{e||ej(null)},children:(0,t.jsx)(p.DrawerContent,{className:"mx-auto max-w-md rounded-t-3xl px-4 pb-5",children:(0,t.jsxs)("div",{className:"space-y-4 pt-4 text-center",children:[(0,t.jsx)("h3",{className:"text-lg font-bold text-danger",children:"Limited stock available"}),(0,t.jsxs)("p",{className:"text-base font-medium text-foreground",children:["Only ",ew?.available??0," item",(ew?.available??0)===1?"":"s"," ","available. You can't add more to your cart"]}),(0,t.jsx)(m.Button,{variant:"destructive",className:"h-11 w-full rounded-full text-base font-semibold",onClick:()=>ej(null),children:"Got it"})]})})})]})}e.s(["CartDrawer",()=>Q],751403)},667585,(e,t,r)=>{"use strict";
1Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"BailoutToCSR",{enumerable:!0,get:function(){return a}});let n=e.r(132061);function a({reason:e,children:t}){if("u"<typeof window)throw Object.defineProperty(new n.BailoutToCSRError(e),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0});return t}},309885,(e,t,r)=>{"use strict";function n(e){return e.split("/").map(e=>encodeURIComponent(e)).join("/")}Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"encodeURIPath",{enumerable:!0,get:function(){return n}})},652157,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"PreloadChunks",{enumerable:!0,get:function(){return l}});let n=e.r(843476),a=e.r(174080),s=e.r(563599),i=e.r(309885),o=e.r(543369);function l({moduleIds:e}){if("u">typeof window)return null;let t=s.workAsyncStorage.getStore();if(void 0===t)return null;let r=[];if(t.reactLoadableManifest&&e){let n=t.reactLoadableManifest;for(let t of e){if(!n[t])continue;let e=n[t].files;r.push(...e)}}if(0===r.length)return null;let l=(0,o.getDeploymentIdQueryOrEmptyString)();return(0,n.jsx)(n.Fragment,{children:r.map(e=>{let r=`${t.assetPrefix}/_next/${(0,i.encodeURIPath)(e)}${l}`;return e.endsWith(".css")?(0,n.jsx)("link",{precedence:"dynamic",href:r,rel:"stylesheet",as:"style",nonce:t.nonce},e):((0,a.preload)(r,{as:"script",fetchPriority:"low",nonce:t.nonce}),null)})})}},869093,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"default",{enumerable:!0,get:function(){return c}});let n=e.r(843476),a=e.r(271645),s=e.r(667585),i=e.r(652157);function o(e){return{default:e&&"default"in e?e.default:e}}let l={loader:()=>Promise.resolve(o(()=>null)),loading:null,ssr:!0},c=function(e){let t={...l,...e},r=(0,a.lazy)(()=>t.loader().then(o)),c=t.loading;function d(e){let o=c?(0,n.jsx)(c,{isLoading:!0,pastDelay:!0,error:null}):null,l=!t.ssr||!!t.loading,d=l?a.Suspense:a.Fragment,u=t.ssr?(0,n.jsxs)(n.Fragment,{children:["u"<typeof window?(0,n.jsx)(i.PreloadChunks,{moduleIds:t.modules}):null,(0,n.jsx)(r,{...e})]}):(0,n.jsx)(s.BailoutToCSR,{reason:"next/dynamic",children:(0,n.jsx)(r,{...e})});return(0,n.jsx)(d,{...l?{fallback:o}:{},children:u})}return d.displayName="LoadableComponent",d}},770703,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"default",{enumerable:!0,get:function(){return a}});let n=e.r(555682)._(e.r(869093));function a(e,t){let r={};"function"==typeof e&&(r.loader=e);let a={...r,...t};return(0,n.default)({...a,modules:a.loadableGenerated?.modules})}("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)},350024,e=>{"use strict";var t=e.i(843476),r=e.i(964118),n=e.i(657688),a=e.i(753815),s=e.i(743687),i=e.i(863005),o=e.i(618566),l=e.i(770703),c=e.i(531278);let d=(0,l.default)(()=>e.A(127844),{loadableGenerated:{modules:[186162]},ssr:!1,loading:()=>(0,t.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,t.jsx)(c.Loader2,{className:"text-primary h-6 w-6 animate-spin"})})});function u(){let{isOpen:e,onClose:l,view:c}=(0,r.useAuthDrawer)(),u=(0,o.usePathname)();return"/login"===u||"/register"===u?null:(0,t.jsx)(s.Drawer,{open:e,onOpenChange:e=>{e||l()},children:(0,t.jsxs)(s.DrawerContent,{className:"max-h-[90vh] p-0 flex flex-col border-t-0 data-[vaul-drawer-direction=bottom]:border-t-0 rounded-t-[24px] data-[vaul-drawer-direction=bottom]:rounded-t-[24px]",children:[e&&"login"===c&&(0,t.jsx)(i.LoginSessionCleanup,{}),(0,t.jsxs)("div",{className:"w-full overflow-y-auto flex-1",children:[(0,t.jsxs)("div",{className:"relative w-full h-[360px] sm:h-[480px] shrink-0 overflow-hidden text-white",children:[(0,t.jsx)(n.default,{src:"/auth-banner.png",alt:"Authentication Banner",fill:!0,priority:!0,className:"object-cover object-[center_80%]"}),(0,t.jsx)("div",{className:"absolute inset-0 bg-gradient-to-b from-black/35 via-trans
1parent to-black/45"}),(0,t.jsx)("button",{onClick:l,className:"absolute top-4 right-4 z-20 rounded-full border border-white/20 bg-white/10 px-4 py-1.5 text-xs font-semibold text-white backdrop-blur-md transition-all hover:bg-white/25 hover:border-white/40 active:scale-95",children:"Skip"}),(0,t.jsxs)("div",{className:"absolute top-[12%] sm:top-[18%] left-0 right-0 z-10 flex flex-col items-center text-center px-6",children:[(0,t.jsx)("div",{className:"relative mb-2 h-14 w-32 sm:h-20 sm:w-44",children:(0,t.jsx)(n.default,{src:"/daily-need-logo.webp",alt:"DailyNeed Logo",fill:!0,priority:!0,className:"object-contain"})}),(0,t.jsx)("p",{className:"text-[9px] font-bold tracking-widest text-white/90 uppercase drop-shadow-md sm:text-xs",children:"EVERY HOME DESERVES THE BEST"})]})]}),(0,t.jsxs)("div",{className:"relative z-10 -mt-6 rounded-t-[24px] bg-card px-5 pb-5 pt-5 mx-auto w-full max-w-md",children:["login"!==c&&(0,t.jsxs)(s.DrawerHeader,{className:"px-0 pt-0",children:[(0,t.jsx)(s.DrawerTitle,{children:{login:"","register-b2b":""}[c]}),(0,t.jsx)(s.DrawerDescription,{children:{login:"","register-b2b":""}[c]})]}),(0,t.jsx)("div",{children:e&&(0,t.jsx)(d,{view:c})}),(0,t.jsx)(a.TrustBadges,{})]})]})]})})}e.s(["AuthDrawer",()=>u])},603811,e=>{"use strict";var t=e.i(843476),r=e.i(271645),n=e.i(846932),a=e.i(88653),s=e.i(769345),i=e.i(643531),o=e.i(503116),l=e.i(730699),c=e.i(846696),d=e.i(651698),u=e.i(718817),m=e.i(964118),p=e.i(857259),f=e.i(647163),h=e.i(725990),x=e.i(827012);class g{constructor(e){this.stop=()=>this.runAll("stop"),this.animations=e.filter(Boolean)}get finished(){return Promise.all(this.animations.map(e=>e.finished))}getAll(e){return this.animations[0][e]}setAll(e,t){for(let r=0;r<this.animations.length;r++)this.animations[r][e]=t}attachTimeline(e){let t=this.animations.map(t=>t.attachTimeline(e));return()=>{t.forEach((e,t)=>{e&&e(),this.animations[t].stop()})}}get time(){return this.getAll("time")}set time(e){this.setAll("time",e)}get speed(){return this.getAll("speed")}set speed(e){this.setAll("speed",e)}get state(){return this.getAll("state")}get startTime(){return this.getAll("startTime")}get duration(){return y(this.animations,"duration")}get iterationDuration(){return y(this.animations,"iterationDuration")}runAll(e){this.animations.forEach(t=>t[e]())}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}function y(e,t){let r=0;for(let n=0;n<e.length;n++){let a=e[n][t];null!==a&&a>r&&(r=a)}return r}class b extends g{then(e,t){return this.finished.finally(e).then(()=>{})}}var v=e.i(133887),w=e.i(486427),j=e.i(373431),N=e.i(83411),k=e.i(515923),C=e.i(997307),S=e.i(721748),P=e.i(215932),A=e.i(783920),I=e.i(763074),E=e.i(965566),_=e.i(893544);function M(e,t){var r;let n;return(0,_.isEasingArray)(e)?e[r=e.length,((t-0)%(n=r-0)+n)%n+0]:e}var O=e.i(749652);function T(e){return"object"==typeof e&&!Array.isArray(e)}function L(e,t,r,n){return null==e?[]:"string"==typeof e&&T(t)?(0,O.resolveElements)(e,r,n):e instanceof NodeList?Array.from(e):Array.isArray(e)?e.filter(e=>null!=e):[e]}function B(e,t,r,n){return"number"==typeof t?t:t.startsWith("-")||t.startsWith("+")?Math.max(0,e+parseFloat(t)):"<"===t?r:t.startsWith("<")?Math.max(0,r+parseFloat(t.slice(1))):n.get(t)??e}var D=e.i(100706);function R(e,t){return e.at!==t.at?e.at-t.at:null===e.value?1:null===t.value?-1:0}function U(e,t){return t.has(e)||t.set(e,{}),t.get(e)}function z(e,t){return t[e]||(t[e]=[]),t[e]}let W=e=>"number"==typeof e,G=e=>e.every(W);var F=e.i(768705),$=e.i(472094),V=e.i(372323),q=e.i(889026),K=e.i(836331),Q=e.i(275737),Y=e.i(386783),H=e.i(130162),X=e.i(617218);class J extends X.VisualElement{constructor(){super(...arguments),this.type="object"}readValueFromInstance(e,t){if(t in e){let r=e[t];if("string"==typeof r||"number"==typeof r)return r}}getBaseTargetFromProps(){}removeValueFromRenderState(e,t){delete t.output[e]}measureInstanceViewportBox(){return(0,H.createBox)()}build(e,t){Object.assign(e.output,t)}renderInstance(e,{output:t}){Object.assign(e,t)}sortInstanceNodePosition(){return 0}}function Z(e){let t={presenceContext:null,props:{}
1,visualState:{renderState:{transform:{},transformOrigin:{},style:{},vars:{},attrs:{}},latestValues:{}}},r=(0,q.isSVGElement)(e)&&!(0,K.isSVGSVGElement)(e)?new Q.SVGVisualElement(t):new Y.HTMLVisualElement(t);r.mount(e),$.visualElementStore.set(e,r)}function ee(e){let t=new J({presenceContext:null,props:{},visualState:{renderState:{output:{}},latestValues:{}}});t.mount(e),$.visualElementStore.set(e,t)}function et(e,t,r,n){let a=[];if((0,N.isMotionValue)(e)||"number"==typeof e||"string"==typeof e&&!T(t))a.push((0,F.animateSingleValue)(e,T(t)&&t.default||t,r&&r.default||r));else{if(null==e)return a;let s=L(e,t,n),i=s.length;(0,E.invariant)(!!i,"No valid elements provided.","no-valid-elements");for(let e=0;e<i;e++){let n=s[e],o=n instanceof Element?Z:ee;$.visualElementStore.has(n)||o(n);let l=$.visualElementStore.get(n),c={...r};"delay"in c&&"function"==typeof c.delay&&(c.delay=c.delay(e,i)),a.push(...(0,V.animateTarget)(l,{...t,transition:c},{}))}}return a}let er=function(e={}){let{scope:t,reduceMotion:r}=e;return function(e,n,a){var s;let i,o=[];if(Array.isArray(e)&&e.some(Array.isArray)){let a;s=void 0!==r?{reduceMotion:r,...n}:n,a=[],(function(e,{defaultTransition:t={},...r}={},n,a){let s=t.duration||.3,i=new Map,o=new Map,l={},c=new Map,d=0,u=0,m=0;for(let r=0;r<e.length;r++){let i=e[r];if("string"==typeof i){c.set(i,u);continue}if(!Array.isArray(i)){c.set(i.name,B(u,i.at,d,c));continue}let[h,x,g={}]=i;void 0!==g.at&&(u=B(u,g.at,d,c));let y=0,b=(e,r,n,i=0,o=0)=>{var l;let c=Array.isArray(l=e)?l:[l],{delay:d=0,times:p=(0,k.defaultOffset)(c),type:f=t.type||"ke
1yframes",repeat:h,repeatType:x,repeatDelay:g=0,...b}=r,{ease:w=t.ease||"easeOut",duration:j}=r,N="function"==typeof d?d(i,o):d,A=c.length,_=(0,C.isGenerator)(f)?f:a?.[f||"keyframes"];if(A<=2&&_){let e=100;2===A&&G(c)&&(e=Math.abs(c[1]-c[0]));let r={...t,...b};void 0!==j&&(r.duration=(0,I.secondsToMilliseconds)(j));let n=(0,S.createGeneratorEasing)(r,e,_);w=n.ease,j=n.duration}j??(j=s);let O=u+N;1===p.length&&0===p[0]&&(p[1]=1);let T=p.length-c.length;if(T>0&&(0,P.fillOffset)(p,T),1===c.length&&c.unshift(null),h){(0,E.invariant)(h<20,"Repeat count too high, must be less than 20","repeat-count-high");j*=h+1;let e=[...c],t=[...p],r=[...w=Array.isArray(w)?[...w]:[w]];for(let n=0;n<h;n++){c.push(...e);for(let a=0;a<e.length;a++)p.push(t[a]+(n+1)),w.push(0===a?"linear":M(r,a-1))}for(let e=0;e<p.length;e++)p[e]=p[e]/(h+1)}let L=O+j;!function(e,t,r,n,a,s){for(let t=0;t<e.length;t++){let r=e[t];r.at>a&&r.at<s&&((0,v.removeItem)(e,r),t--)}for(let i=0;i<t.length;i++)e.push({value:t[i],at:(0,D.mixNumber)(a,s,n[i]),easing:M(r,i)})}(n,c,w,p,O,L),y=Math.max(N+j,y),m=Math.max(L,m)};if((0,N.isMotionValue)(h))b(x,g,z("default",U(h,o)));else{let e=L(h,x,n,l),t=e.length;for(let r=0;r<t;r++){let n=U(e[r],o);for(let e in x){var p,f;b(x[e],(p=g,f=e,p&&p[f]?{...p,...p[f]}:{...p}),z(e,n),r,t)}}}d=u,u+=y}return o.forEach((e,n)=>{for(let a in e){let s=e[a];s.sort(R);let o=[],l=[],c=[];for(let e=0;e<s.length;e++){let{at:t,value:r,easing:n}=s[e];o.push(r),l.push((0,A.progress)(0,m,t)),c.push(n||"easeOut")}0!==l[0]&&(l.unshift(0),o.unshift(o[0]),c.unshift("easeInOut")),1!==l[l.length-1]&&(l.push(1),o.push(null)),i.has(n)||i.set(n,{keyframes:{},transition:{}});let d=i.get(n);d.keyframes[a]=o;let{type:u,...p}=t;d.transition[a]={...p,duration:m,ease:c,times:l,...r}}}),i})(e.map(e=>{if(Array.isArray(e)&&"function"==typeof e[0]){let t=e[0],r=(0,w.motionValue)(0);return(r.on("change",t),1===e.length)?[r,[0,1]]:2===e.length?[r,[0,1],e[1]]:[r,e[1],e[2]]}return e}),s,t,{spring:j.spring}).forEach(({keyframes:e,transition:t},r)=>{a.push(...et(r,e,t))}),o=a}else{let{onComplete:s,...l}=a||{};"function"==typeof s&&(i=s),o=et(e,n,void 0!==r?{reduceMotion:r,...l}:l,t)}let l=new b(o);return i&&l.finished.then(i),t&&(t.animations.push(l),l.finished.then(()=>{(0,v.removeItem)(t.animations,l)})),l}}();var en=e.i(737806),ea=e.i(947414),es=e.i(98107);let ei=["free_delivery","better_luck","curated_box","membership_pass","surprise_gift"];function eo(e){let t=e=>{let t=ei.indexOf(e);return -1===t?ei.length:t};return[...e].sort((e,r)=>t(e.key)-t(r.key))}let el={free_delivery:"#7A2CF0",surprise_gift:"#EC2E9C",membership_pass:"#F79A1E",curated_box:"#2563EB",better_luck:"#1C6B43"};function ec(e,t){let r=parseInt(e.replace("#",""),16),n=t<0?0:255,a=Math.abs(t),s=e=>Math.round((n-e)*a)+e;return`#${(0x1000000+(s(r>>16&255)<<16)+(s(r>>8&255)<<8)+s(255&r)).toString(16).slice(1)}`}function ed(e,t,r,n){let a=(n-90)*Math.PI/180;return{x:e+r*Math.cos(a),y:t+r*Math.sin(a)}}function eu(e,t){let r=ed(200,200,200,t),n=ed(200,200,200,e),a=t-e<=180?0:1;return`M 200 200 L ${r.x} ${r.y} A 200 200 0 ${a} 0 ${n.x} ${n.y} Z`}function em({prizes:e,spinning:a,landTarget:s,onLanded:i}){let o=Math.max(e.length,1),l=360/o,c=function(e){let t=(0,ea.useConstant)(()=>(0,w.motionValue)(e)),{isStatic:n}=(0,r.useContext)(en.MotionConfigContext);if(n){let[,n]=(0,r.useState)(e);(0,r.useEffect)(()=>t.on("change",n),[])}return t}(-l/2),d=(0,r.useRef)(0),u=(0,r.useRef)(null),m=(0,r.useRef)(null),p=(0,r.useRef)(i),[f,h]=(0,r.useState)(null);return(0,r.useEffect)(()=>{p.current=i}),(0,r.useEffect)(()=>{if(a)return h(null),d.current=Date.now(),u.current=er(c,c.get()+16500,{duration:30,ease:"linear"}),()=>u.current?.stop()},[a,c]),(0,r.useEffect)(()=>{if(!s||s.nonce===m.current)return;m.current=s.nonce;let e=setTimeout(()=>{var e,t;let r,n;u.current?.stop();let a=(e=s.index,t=c.get(),n=((360-(e*(r=360/o)+r/2)%360)%360-(t%360+360)%360+360)%360,t+n+1800);er(c,a,{duration:5,ease:[.16,.84,.28,1],onComplete:()=>{h(s.index),p.current()}})},Math.max(0,1400-(Date.now()-d.current)));return()=>clearTimeout(e)},[s,o,c]),(0,t.jsxs)("div",{className:"relative mx-auto aspect-square w-[82vw] max-w-[400px] md:w-full md:max-w-64",children:[(0,t.jsx)("div",{className:"pointer-events-none absolute -inset-x-[70%] -top-[8%] -bottom-[16%] -z-10 overflow-hidden",children:(0,t.jsx)(n.motion.img,{src:"/spin/bg-glow-spiral.png",alt:"","aria-hidden":!0,
1className:"absolute left-1/2 top-1/2 w-[135%] max-w-none -translate-x-1/2 -translate-y-1/2 opacity-80 filter-[hue-rotate(210deg)_saturate(0.9)]",animate:{rotate:360},transition:{duration:90,repeat:1/0,ease:"linear"}})}),(0,t.jsx)("img",{src:"/spin/spinner-polygon.png",alt:"","aria-hidden":!0,className:"absolute left-1/2 -top-2 z-30 w-8 -translate-x-1/2 drop-shadow-[0_3px_4px_rgba(0,0,0,0.4)]"}),(0,t.jsx)("div",{className:"absolute inset-0 rounded-full",style:{background:"linear-gradient(160deg, #C9B0F7 0%, #9E70EA 45%, #7A46CE 100%)",padding:"5.5%",boxShadow:"0 0 0 1px rgba(255,255,255,0.18), 0 16px 46px -12px rgba(160,110,235,0.6), inset 0 2px 6px rgba(255,255,255,0.4), inset 0 -6px 14px rgba(0,0,0,0.28)"},children:(0,t.jsxs)("div",{className:"relative h-full w-full overflow-hidden rounded-full",children:[(0,t.jsxs)(n.motion.svg,{viewBox:"0 0 400 400",style:{rotate:c},className:"absolute inset-0 h-full w-full drop-shadow-[0_10px_30px_rgba(0,0,0,0.35)]",children:[(0,t.jsxs)("defs",{children:[e.map(e=>{let r=el[e.key]??"#7A2CF0";return(0,t.jsxs)("radialGradient",{id:`slice-${e.key}`,gradientUnits:"userSpaceOnUse",cx:200,cy:200,r:200,children:[(0,t.jsx)("stop",{offset:"0%",stopColor:ec(r,.32)}),(0,t.jsx)("stop",{offset:"60%",stopColor:r}),(0,t.jsx)("stop",{offset:"100%",stopColor:ec(r,-.26)})]},`grad-${e.key}`)}),(0,t.jsx)("filter",{id:"spin-gold-glow",x:"-40%",y:"-40%",width:"180%",height:"180%",children:(0,t.jsx)("feDropShadow",{dx:"0",dy:"0",stdDeviation:"6",floodColor:"#FFCE54",floodOpacity:"0.95"})})]}),e.map((e,r)=>(0,t.jsx)("path",{d:eu(r*l,(r+1)*l),fill:`url(#slice-${e.key})`,stroke:"#ffffff",strokeWidth:2},e.key)),null!=f&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("path",{d:eu(f*l,(f+1)*l),fill:"#FFD873",opacity:.16}),(0,t.jsx)("path",{d:eu(f*l,(f+1)*l),fill:"none",stroke:"#FFDD88",strokeWidth:5,filter:"url(#spin-gold-glow)"})]}),e.map((e,r)=>{let n=function(e){let t=e.toUpperCase().trim().split(/\s+/),r=[],n="";for(let e of t)n?(n+" "+e).length<=12?n+=" "+e:(r.push(n),n=e):n=e;return n&&r.push(n),r}(e.label);return(0,t.jsxs)("g",{transform:`rotate(${r*l+l/2} 200 200)`,children:[(0,t.jsx)("text",{x:200,y:36,textAnchor:"middle",fill:"#ffffff",fontSize:"16",fontWeight:"800",letterSpacing:"0.5",style:{textShadow:"0 1px 3px rgba(0,0,0,0.5)"},children:n.map((e,r)=>(0,t.jsx)("tspan",{x:200,dy:21*(0!==r),children:e},r))}),(0,t.jsx)("image",{href:(0,es.prizeIconUrl)(e.key),x:168,y:84,width:64,height:64,preserveAspectRatio:"xMidYMid meet",transform:`rotate(${-r*l} 200 116)`})]},`${e.key}-content`)})]}),(0,t.jsx)("div",{className:"absolute left-1/2 top-1/2 flex h-[22%] w-[22%] -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full border-[3px] border-white",style:{background:"radial-gradient(circle at 50% 32%, #8B5CF6, #4C1D95)",boxShadow:"0 6px 16px rgba(0,0,0,0.5), inset 0 2px 4px rgba(255,255,255,0.3)"},children:(0,t.jsx)("img",{src:"https://imagedelivery.net/MMFlmRtiPspPb6QkV5Pqhw/19f6fd43-7e65-4930-5ecd-9033e0ec2d00/public",alt:"Dailyneed",className:"h-[74%] w-[74%] object-contain"})})]})}),Array.from({length:24}).map((e,r)=>{let n=ed(50,50,47,r/24*360);return(0,t.jsx)("span",{className:"absolute h-[2.4%] w-[2.4%] -translate-x-1/2 -translate-y-1/2 rounded-full",style:{left:`${n.x}%`,top:`${n.y}%`,background:"radial-gradient(circle at 42% 38%, #FFF1C6, #F3C55A 65%)",boxShadow:"0 0 9px 3px rgba(245,197,90,0.55)"}},r)})]})}var ep=e.i(473665);let ef=e=>(0,es.prizeIconUrl)(e);function eh(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleString(void 0,{day:"numeric",month:"short",hour:"numeric",minute:"2-digit"})}function ex(){let e=(0,h.useSpinDrawer)(e=>e.isOpen),n=(0,h.useSpinDrawer)(e=>e.onClose),{isAuthenticated:s}=(0,p.useSession)(),i=(0,m.useAuthDrawer)(e=>e.onOpen),o=(0,x.useSpinEligibilityQuery)(e&&s),l=(0,x.useSpinMutation)(),d=(0,x.useChooseRewardMutation)(),[g,y]=(0,r.useState)("loading"),[b,v]=(0,r.useState)(!1),[w,j]=(0,r.useState)(null),[N,k]=(0,r.useState)(0),[C,S]=(0,r.useState)([]),[P,A]=(0,r.useState)(null),[I,E]=(0,r.useState)(null),_=(0,r.useRef)(!1),M=(0,r.useRef)(null),O=(0,r.useRef)(0),T=o.data,L=eo(T?.prizes??[]),B="claimed"===g||!!T?.confirmedReward;(0,r.useEffect)(()=>{e||(_.current=!1,M.current=null,y("loading"),v(!1),j(null),S([]),A(null),E(null))},[e]),(0,r.useEffect)(()=>{!e||(s?o.isLoading||!T?y("loading"):_.current||(_.current=!0,T.confirmedReward?(E({label:T.confirmedReward.label,prizeKey:T.confirmedReward.prizeKey,color:T.confirmedReward.color,description:T.confirmedReward.description,minCartValue:T.confirmedReward.minCartValue,endsAt:T.confirmedReward.endsAt}),y("claimed")):T.pendingWins.length>=1&&0===T.attemptsRemaining||T.pendingWins.length>
1=2?y("choosing"):T.eligible||T.pendingWins.length>=1?(k(T.attemptsRemaining),y("wheel")):y("not-eligible")):y("teaser"))},[e,s,o.isLoading,T]);let D=async()=>{let{data:e}=await o.refetch();y((e?.pendingWins??[]).length>=1?"choosing":"better-luck")},R=async()=>{if(!b&&!(N<=0)){A(null),v(!0);try{let e=await l.mutateAsync();M.current=e;let t=L.findIndex(t=>t.key===e.prizeKey);O.current+=1,j({index:t>=0?t:0,nonce:O.current})}catch{v(!1),c.toast.error("Could not spin right now. Please try again.")}}},U=async e=>{let t=(T?.pendingWins??[]).find(t=>t.spinEventId===e);try{let r=await d.mutateAsync(e);E({label:t?.label,prizeKey:t?.prizeKey,color:r.confirmedReward?.color??null,description:r.confirmedReward?.description??null,minCartValue:t?.minCartValue??null,endsAt:r.confirmedReward?.endsAt??null}),y("claimed")}catch{c.toast.error("Could not claim your reward. Please try again.")}},z="choosing"===g||"claimed"===g,W="wheel"===g;return(0,t.jsx)(u.ResponsiveDialog,{open:e,onOpenChange:e=>!e&&n(),children:(0,t.jsxs)(u.ResponsiveDialogContent,{className:(0,f.cn)("max-w-md overflow-hidden border-0 p-0 shadow-none md:max-w-lg [&>button]:hidden data-[vaul-drawer-direction=bottom]:mt-0 data-[vaul-drawer-direction=bottom]:max-w-none data-[vaul-drawer-direction=bottom]:max-h-[95vh] data-[vaul-drawer-direction=bottom]:rounded-t-3xl",W?"md:h-[95vh]":"md:max-h-[95vh]"),children:[(0,t.jsx)(u.ResponsiveDialogTitle,{className:"sr-only",children:"Spin & Win"}),(0,t.jsxs)("div",{className:(0,f.cn)("relative rounded-t-3xl text-foreground md:rounded-3xl",W&&"md:h-full"),style:{background:"linear-gradient(180deg, #E7D6FB 0%, #F1E6FD 45%, #FBF7FE 100%)"},children:["loading"!==g&&(0,t.jsxs)("button",{type:"button",onClick:n,disabled:b,className:"absolute flex items-center gap-2 top-3 right-3 z-40 rounded-full bg-white/70 px-3 py-1.5 text-xs font-semibold text-foreground shadow-sm backdrop-blur transition-colors hover:bg-card disabled:opacity-40 md:hidden",children:["Skip ",(0,t.jsx)(ep.MdOutlineKeyboardDoubleArrowRight,{})]}),(0,t.jsxs)("div",{className:(0,f.cn)("no-scrollbar max-h-[95vh] overflow-x-hidden overflow-y-auto md:max-h-[95vh]",W&&"md:h-full"),children:["loading"===g&&(0,t.jsx)("div",{className:"flex items-center justify-center py-32",children:(0,t.jsx)("div",{className:"h-9 w-9 animate-spin rounded-full border-2 border-brand-soft-border border-t-purple-600"})}),"teaser"===g&&(0,t.jsx)(eN,{onLogin:()=>{n(),i("login")},onSkip:n}),"not-eligible"===g&&(0,t.jsxs)("div",{className:"px-6 pt-3 pb-14 text-center",children:[(0,t.jsx)(eg,{line1:"SPIN TO",line2:"REDEEM REWARDS"}),(0,t.jsx)("p",{className:"mx-auto mt-6 max-w-xs text-sm text-muted-foreground",children:T?.reason==="ALREADY_ORDERED"?"Spin & Win is exclusive to your very first order.":T?.reason==="CORPORATE_INELIGIBLE"?"Spin & Win is available on personal accounts only.":"You have used all your spins. Thanks for playing!"}),(0,t.jsx)("div",{className:"mt-8 px-2",children:(0,t.jsx)(ek,{onClick:n,children:"Close"})})]}),("wheel"===g||z||"better-luck"===g)&&(0,t.jsxs)("div",{className:"isolate px-5 pt-5 pb-6 md:pt-4 md:pb-9",children:[(0,t.jsx)(eg,{line1:z?"CHOOSE":"SPIN TO",line2:z?"YOUR REWARDS":"REDEEM REWARDS",subtitle:z?void 0:"Two spins. Two chances. You can choose your favorite reward at the end!"}),(0,t.jsx)(ey,{}),(0,t.jsx)(eb,{spins:T?.spins??[],spinLog:C,finalClaimed:B,prizes:L}),"wheel"===g&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"mt-5 md:mt-9",children:(0,t.jsx)(em,{prizes:L,spinning:b,landTarget:w,onLanded:()=>{v(!1);let e=M.current;if(M.current=null,!e)return;k(e.attemptsRemaining),S(t=>[...t.filter(t=>t.attemptNo!==e.attemptNo),{attemptNo:e.attemptNo,prizeKey:e.prizeKey,isWin:e.isWin}]),o.refetch();let t=L.find(t=>t.key===e.prizeKey)?.minCartValue??null;setTimeout(()=>{A({prizeKey:e.prizeKey,label:e.prizeLabel,color:e.color??"#7C3AED",description:e.description??"",isWin:e.isWin,minCartValue:t})},550)}})}),(0,t.jsx)("div",{className:"mt-6 px-1 md:mt-8",children:(0,t.jsx)(ek,{onClick:R,disabled:b||N<=0,children:b?"Spinningâ¦":"Spin the wheel"})}),(0,t.jsx)("button",{type:"button",onClick:n,disabled:b,className:"mx-auto mt-3 hidden text-sm font-semibold text-primary hover:underline disabled:opacity-40 md:block",children:"Skip for now"})]}),(z||"better-luck"===g)&&(0,t.jsx)("div",{className:"mt-5",children:"better-luck"===g?(0,t.jsxs)("div",{className:"rounded-3xl bg-card p-6 text-center shadow-sm",children:[(0,t.jsx)("p",{className:"text-base font-bold",children:"Better luck next time"}),(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"No win this round â thanks for playing!"}),(0,t.jsx)("div",{className:"mt-5",children:(0,t.jsx)(ek,{onClick:n,children:"Close"})})]}):(0,t.jsx)(ew,{wins:T?.pendingWins??[],loading:d.isPending,onRedeem:U,prizes:L})})]})]}),(0,t.jsxs)(a.AnimatePresence,{children:[P&&(0,t.jsx)(ej,{prizeKey:P.prizeKey,color:P.color,title:P.isWin?P.label:"Better luck next time",message:P.isWin?P.description:"Not a winner this time â thanks for playing!",minCartValue:P.isWin?P.minCartValue:null,placeholder:P.isWin&&"membership_pass"===P.prizeKey,showConfetti:P.isWin,onDismiss:()=>{A(null),N<=0&&D()},autoDismissMs:2600},"spin-reward"),"claimed"===g&&(0,t.jsx)(ej,{prizeKey:I?.prizeKey??void 0,color:I?.color??void 0,title:I?.label??"Reward",message:I?.description??"",minCartValue:I?.minCartValue??null,placeholder:"membership_pass"===I?.prizeKey,val
1idUntil:I?.endsAt??null,showConfetti:!0,buttonLabel:"Continue Shopping",onDismiss:n},"final-claim")]})]})]})})}function eg({line1:e,line2:r,subtitle:n}){return(0,t.jsxs)("div",{className:"text-center z-10",children:[(0,t.jsx)("h2",{className:"mt-1 text-[20px] leading-none font-black tracking-tight text-foreground md:text-[24px]",children:e}),(0,t.jsx)("h2",{className:"mt-1 bg-clip-text text-[20px] leading-tight font-black tracking-tight text-transparent md:text-[24px]",style:{backgroundImage:"linear-gradient(90deg, #7C3AED 0%, #EC4899 55%, #F59E0B 100%)"},children:r}),n&&(0,t.jsx)("p",{className:"mx-auto mt-1 max-w-[18rem] text-[10px] leading-relaxed text-muted-foreground md:mt-1.5 md:max-w-[20rem] md:text-[11px]",children:n})]})}function ey(){return(0,t.jsx)("div",{className:"mt-1.5 flex justify-center md:mt-2",children:(0,t.jsxs)("div",{className:"inline-flex items-center gap-1.5 rounded-full bg-card px-3 py-1 text-[10px] font-medium text-foreground shadow-sm md:text-[11px]",children:[(0,t.jsx)(o.Clock,{className:"h-3 w-3 text-primary"}),"Limited-time first-order reward"]})})}function eb({spins:e,spinLog:r,finalClaimed:a,prizes:s}){let i=new Map;for(let t of e)i.set(t.attemptNo,{isWin:t.isWin,key:t.isWin?t.prizeKey??"better_luck":"better_luck"});for(let e of r)i.set(e.attemptNo,{isWin:e.isWin,key:e.isWin?e.prizeKey:"better_luck"});let o=[1,2].map(e=>{let t=i.get(e);return t?{n:e,label:`SPIN ${e}`,done:!0,isWin:t.isWin,key:t.key}:{n:e,label:`SPIN ${e}`,done:!1,isWin:!1,key:void 0}}),c=o.filter(e=>e.done).length;return(0,t.jsx)("div",{className:"mt-3 rounded-2xl bg-card p-3 shadow-sm md:mt-3 md:p-4",children:(0,t.jsxs)("div",{className:"relative flex items-start justify-between",children:[(0,t.jsx)("div",{className:"absolute top-3.5 right-[16%] left-[16%] h-[3px] rounded-full bg-brand-soft"}),(0,t.jsx)("div",{className:"absolute top-3.5 left-[16%] h-[3px] rounded-full bg-primary transition-all",style:{width:a?"68%":c>=2?"34%":"0%"}}),o.map(e=>(0,t.jsxs)("div",{className:"relative z-10 flex w-1/3 flex-col items-center",children:[(0,t.jsx)(ev,{done:e.done,isWin:e.isWin,prizeKey:e.key,color:s.find(t=>t.key===e.key)?.color}),(0,t.jsx)("span",{className:"mt-1.5 text-[11px] font-bold text-foreground",children:e.label}),(0,t.jsx)("span",{className:(0,f.cn)("text-[10px] font-semibold",e.done&&e.isWin?"text-success":"text-muted-foreground"),children:e.done?e.isWin?"Reward Unlocked":"Better Luck":"Reward"})]},e.n)),(0,t.jsxs)("div",{className:"relative z-10 flex w-1/3 flex-col items-center",children:[(0,t.jsx)(n.motion.span,{initial:!!a&&{scale:.3,opacity:0,rotate:-25},animate:{scale:1,opacity:1,rotate:0},transition:{type:"spring",stiffness:380,damping:16},className:(0,f.cn)("flex h-7 w-7 items-center justify-center rounded-full",a?"bg-primary":"bg-brand-soft"),children:(0,t.jsx)(l.Gift,{className:(0,f.cn)("h-3.5 w-3.5",a?"text-primary-foreground":"text-muted-foreground")})},a?"claimed":"pending"),(0,t.jsx)("span",{className:"mt-1.5 text-[11px] font-bold text-foreground",children:"FINAL REWARD"}),(0,t.jsx)("span",{className:(0,f.cn)("text-[10px] font-semibold",a?"text-primary":"text-muted-foreground"),children:a?"Redeemed":"Redeem"})]})]})})}function ev({done:e,isWin:r,prizeKey:s,color:i}){return(0,t.jsx)(a.AnimatePresence,{mode:"wait",initial:!1,children:e&&s?(0,t.jsx)(n.motion.span,{initial:{scale:.3,opacity:0,rotate:-25},animate:{scale:1,opacity:1,rotate:0},transition:{type:"spring",stiffness:380,damping:16},className:"relative flex h-7 w-7 items-center justify-center",children:(0,t.jsx)(n.motion.span,{initial:{boxShadow:"0 0 0 0 rgba(255,206,84,0)"},animate:{boxShadow:["0 0 0 0 rgba(255,206,84,0.6)","0 0 0 6px rgba(255,206,84,0)"]},transition:{duration:.7,delay:.1},className:"flex h-7 w-7 items-center justify-center overflow-hidden rounded-full",style:{background:i||"#7C3AED"},children:(0,t.jsx)("img",{src:ef(s),alt:"",className:"h-[85%] w-[85%] object-contain"})})},"done"):(0,t.jsx)(n.motion.span,{initial:{scale:.6,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.6,opacity:0},transition:{duration:.2},className:"flex h-7 w-7 items-center justify-center rounded-full bg-brand-soft text-[11px] font-bold text-muted-foreground",children:"?"},"pending")})}function ew({wins:e,loading:a,onRedeem:s,prizes:o}){let[l,c]=(0,r.useState)(e[0]?.spinEventId??null);return(0,t.jsxs)("div",{className:"rounded-3xl bg-card p-4 shadow-sm",children:[(0,t.jsx)("p",{className:"text-center text-base font-bold text-foreground",children:"Select One Reward To Claim"}),(0,t.jsx)("div",{className:"mt-4 flex flex-col gap-3",children:e.map(e=>{let r=l===e.spinEventId;return(0,t.jsxs)(n.motion.button,{type:"button",onClick:()=>c(e.spinEventId),whileTap:{scale:.98}
1,className:(0,f.cn)("relative flex items-center gap-4 rounded-2xl border-2 p-3 text-left transition-colors",r?"border-primary bg-brand-soft":"border-border hover:border-brand-soft-border"),children:[(0,t.jsx)("span",{className:"flex h-14 w-14 shrink-0 items-center justify-center overflow-hidden rounded-xl",style:{background:o.find(t=>t.key===e.prizeKey)?.color||"#7C3AED"},children:(0,t.jsx)("img",{src:ef(e.prizeKey),alt:"",className:"h-[82%] w-[82%] object-contain"})}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("p",{className:"truncate text-sm font-extrabold text-foreground uppercase",children:e.label}),(0,t.jsx)("p",{className:"truncate text-xs text-muted-foreground",children:o.find(t=>t.key===e.prizeKey)?.description||"Your Spin & Win reward"}),e.minCartValue?(0,t.jsxs)("p",{className:"mt-0.5 text-[11px] font-semibold text-primary",children:["Min. cart â¦",e.minCartValue.toLocaleString()]}):null]}),r&&(0,t.jsx)("span",{className:"absolute top-0 right-0 flex h-7 w-7 items-center justify-center rounded-tr-2xl rounded-bl-2xl bg-primary",children:(0,t.jsx)(i.Check,{className:"h-4 w-4 text-primary-foreground",strokeWidth:3})})]},e.spinEventId)})}),(0,t.jsx)("div",{className:"mt-5",children:(0,t.jsx)(ek,{disabled:!l||a,onClick:()=>l&&s(l),children:a?"Redeemingâ¦":"Redeem Now"})})]})}function ej({prizeKey:e,color:a,title:i,message:o,showConfetti:l,buttonLabel:c,onDismiss:u,autoDismissMs:m,minCartValue:p,placeholder:f,validUntil:h}){(0,r.useEffect)(()=>{if(!m)return;let e=setTimeout(u,m);return()=>clearTimeout(e)},[m]);let x=a||"#7C3AED";return(0,t.jsx)(n.motion.div,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},className:"absolute inset-0 z-50 flex items-center justify-center bg-black/45 px-6",onClick:m?u:void 0,children:(0,t.jsxs)(n.motion.div,{initial:{scale:.85,y:20,opacity:0},animate:{scale:1,y:0,opacity:1},exit:{scale:.9,opacity:0},transition:{type:"spring",stiffness:260,damping:22},onClick:e=>e.stopPropagation(),className:"relative w-full max-w-[320px] overflow-hidden rounded-[28px] text-center shadow-2xl",style:{background:`linear-gradient(180deg, color-mix(in oklch, ${x} 60%, white) 0%, color-mix(in oklch, ${x} 22%, white) 22%, #ffffff 55%)`},children:[(0,t.jsx)("img",{src:"/spin/bg-glow-spiral.png",alt:"","aria-hidden":!0,className:"pointer-events-none absolute top-2 left-1/2 z-0 w-40 -translate-x-1/2 opacity-40"}),l&&(0,t.jsx)("div",{className:"pointer-events-none absolute inset-0 z-10",children:(0,t.jsx)(s.default,{animationData:d.default,loop:!1,className:"h-full w-full"})}),(0,t.jsxs)("div",{className:"relative z-20 flex flex-col items-center px-6 pt-8 pb-7",children:[(0,t.jsx)("span",{className:"flex h-20 w-20 items-center justify-center overflow-hidden rounded-full ring-4 ring-card",style:{background:x},children:(0,t.jsx)("img",{src:ef(e),alt:"",className:"h-[80%] w-[80%] object-contain"})}),(0,t.jsx)("h3",{className:"mt-4 text-xl font-extrabold text-primary",children:i}),(0,t.jsx)("p",{className:"mt-2 text-sm leading-relaxed text-foreground",children:o}),f?(0,t.jsx)("button",{type:"button",disabled:!0,className:"mt-3 w-full cursor-not-allowed rounded-full border border-brand-soft-border bg-brand-soft py-2.5 text-sm font-bold text-muted-foreground",children:"Activate"}):(0,t.jsxs)(t.Fragment,{children:[p?(0,t.jsxs)("p",{className:"mt-2 text-xs font-semibold text-primary",children:["Valid on orders over â¦",p.toLocaleString()]}):null,eh(h)?(0,t.jsxs)("p",{className:"mt-1 text-xs text-muted-foreground",children:["Valid until ",eh(h)]}):null]}),c&&(0,t.jsx)("div",{className:"mt-3 w-full",children:(0,t.jsx)(ek,{onClick:u,children:c})})]})]})})}function eN({onLogin:e,onSkip:r}){let n=eo([{key:"free_delivery",label:"Free Delivery",color:"",description:"",imageUrl:null,sortOrder:1,minCartValue:null},{key:"surprise_gift",label:"Surprise Gift",color:"",description:"",imageUrl:null,sortOrder:2,minCartValue:null},{key:"curated_box",label:"Curated Gift Box",color:"",description:"",imageUrl:null,sortOrder:3,minCartValue:null},{key:"membership_pass",label:"Membership Pass",color:"",description:"",imageUrl:null,sortOrder:4,minCartValue:null},{key:"better_luck",label:"Better Luck Next Time",color:"",description:"",imageUrl:null,sortOrder:5,minCartValue:null}]);return(0,t.jsxs)("div",{className:"px-5 pt-4 pb-8 md:pt-6 md:pb-9",children:[(0,t.jsx)(eg,{line1:"SPIN TO",line2:"REDEEM REWARDS",subtitle:"Sign in to spin the wheel and unlock an exclusive welcome reward on your first order."}),(0,t.jsx)("div",{className:"pointer-events-none mt-8 opacity-95 md:mt-12",children:(0,t.jsx)(em,{prizes:n,spinning:!1,landTarget:null,onLanded:()=>{}})}),(0,t.jsx)("div",{className:"mt-6 px-1 md:mt-9",children:(0,t.jsx)(ek,{onClick:e,children:"Login to spin"})}),(0,t.jsx)("button",{type:"button",onClick:r,className:"mx-auto mt-3 hidden text-sm font-semibold text-primary hover:underline md:block",children:"Skip for now"})]})}function ek({children:e,onClick:r,disabled:a}){return(0,t.jsxs)(n.motion.button,{type:"button",onClick:r,disabled:a,whileHover:a?void 0:{scale:1.02},whileTap:a?void 0:{scale:.96},transition:{type:"spring",stiffness:400,damping:22},style:{backgroundImage:"var(--success-gradient)"},className:"block group relative mx-auto overflow-hidden rounded-full md:py-4 py-2 w-[80%] text-base font-bold text-white shadow-[10px_16px_34px_-6px_rgba(52,199,89,0.85),0_6px_16px_-8px_rgba(47,162,59,0.6)] ring-1 ring-white/40 hover:brightness-105 disabled:opacity-60",children:[(0,t.jsx)("span",{className:"relative z-10",children:e}),!a&&(0,t.jsx)("span",{"aria-hidden":!0,className:"absolute inset-0 -translate-x-full bg-[linear-gradient(120deg,transparent_35%,rgba(255,255,255,0.45)_50%,transparent_65%)] transition-transform duration-700 group-hover:translate-x-full"})]})}e.s(["SpinDrawer",()=>ex],603811)},556408,e=>{"use strict";var t=e.i(843476),r=e.i(618566),n=e.i(857259),a=e.i(792450),s=e.i(725990
1),i=e.i(827012);let o=["/login","/register","/checkout","/admin"];function l(){let e=(0,r.usePathname)(),{isAuthenticated:l}=(0,n.useSession)(),c=(0,s.useSpinDrawer)(e=>e.onOpen),d=(0,s.useSpinDrawer)(e=>e.isOpen),u=o.some(t=>e?.startsWith(t)),{data:m}=(0,i.useSpinEligibilityQuery)(a.SPIN_ENABLED&&l&&!u);return a.SPIN_ENABLED&&l&&!u&&!d&&m&&(m.eligible||m.pendingWins.length>0)?(0,t.jsx)("button",{type:"button",onClick:()=>c(),"aria-label":"Open Spin & Win",className:"fixed bottom-28 left-0 z-40 h-24 w-24 -translate-x-1/2 overflow-hidden rounded-full shadow-[0_10px_30px_-8px_oklch(0.4_0.2_290/0.7)] transition-transform hover:scale-105 active:scale-95 md:bottom-10 md:h-28 md:w-28",children:(0,t.jsx)("video",{src:"/spin/spin-win-trigger-320.mp4",autoPlay:!0,muted:!0,loop:!0,playsInline:!0,"aria-hidden":!0,className:"pointer-events-none h-full w-full object-cover"})}):null}e.s(["SpinLauncher",()=>l])},73966,e=>{"use strict";let t=(0,e.i(768834).create)(e=>({isOpen:!1,onOpen:()=>e({isOpen:!0}),onClose:()=>e({isOpen:!1})}));e.s(["useBirthdayGift",0,t])},539613,e=>{"use strict";var t=e.i(843476),r=e.i(271645),n=e.i(657688),a=e.i(846696),s=e.i(718817),i=e.i(220318),o=e.i(192223),l=e.i(857259),c=e.i(647163),d=e.i(73966),u=e.i(19703),m=e.i(20428),p=e.i(907026);function f(){let e=(0,d.useBirthdayGift)(e=>e.isOpen),f=(0,d.useBirthdayGift)(e=>e.onClose),{user:h}=(0,l.useSession)(),{data:x}=(0,i.useBirthdayStatusQuery)(e),g=(0,i.useClaimBirthdayGiftMutation)(),[y,b]=(0,r.useState)(!1);if((0,r.useEffect)(()=>{e||b(!1)},[e]),!e)return null;let v=x?.giftLabel??"Your birthday gift";if(y)return(0,t.jsx)(m.BirthdaySuccessModal,{title:"Your Birthday Gift Is",highlight:"Claimed",message:`${v} is reserved for you. Enjoy your special day!`,onDismiss:f});let w=x?.giftItems??[],j=h?.name?.trim().split(/\s+/)[0];return(0,t.jsx)(u.BirthdayModalShell,{onDismiss:f,className:"border-primary",heroClassName:"px-4 pt-5 pb-0",spiralClassName:"top-[68%] w-[175%]",hero:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(s.ResponsiveDialogTitle,{className:"text-[28px] leading-tight font-extrabold",children:["Happy Birthday",j&&(0,t.jsx)("span",{className:"bg-dnp-gold-text block bg-clip-text text-transparent",children:j.toUpperCase()})]}),(0,t.jsx)(n.default,{src:"/dailyneed-plus/birthday-cake.png",alt:"","aria-hidden":!0,width:680,height:360,className:"-mt-8 h-auto w-[calc(100%+2.5rem)] max-w-none"})]}),children:(0,t.jsxs)("div",{className:"flex flex-col gap-3 md:gap-5 pt-5",children:[(0,t.jsx)("h3",{className:"text-foreground text-center text-lg font-semibold",children:"Collect your Birthday gift"}),0===w.length?(0,t.jsx)("div",{className:"bg-card/60 h-32 animate-pulse rounded-lg"}):(0,t.jsx)("div",{className:1===w.length?"flex justify-center":"grid grid-cols-3 gap-1.5",children:w.map(e=>(0,t.jsxs)("div",{className:(0,c.cn)("relative flex h-full flex-col overflow-hidden rounded-md border-2 border-white/10",1===w.length&&"w-32"),children:[(0,t.jsx)("div",{className:"relative h-28 w-full shrink-0 bg-white",children:(0,t.jsx)(o.SafeImage,{fill:!0,src:e.imageUrl,alt:e.title,className:"object-contain p-2 mix-blend-multiply",sizes:"120px"})}),(0,t.jsx)("p",{className:"flex flex-1 items-center justify-center bg-[linear-gradient(180deg,#7c3aed_0%,#4c1d95_100%)] px-1 py-1.5 text-center text-[11px] leading-tight font-medium text-white",children:e.packLabel})]},e.sku))}),(0,t.jsx)(p.ShimmerButton,{type:"button",onClick:()=>{g.mutate(void 0,{onSuccess:()=>b(!0),onError:()=>a.toast.error("Could not claim your birthday gift. Please try again.")})},disabled:0===w.length||g.isPending,className:"mx-auto w-[86%] text-base disabled:bg-white/10 disabled:bg-none disabled:text-white/35 disabled:opacity-100",children:g.isPending?"Redeemingâ¦":"Redeem Now"}),(0,t.jsx)("button",{type:"button",onClick:f,disabled:g.isPending,className:"text-foreground mx-auto text-sm font-bold hover:underline disabled:opacity-40",children:"Maybe Later"})]})})}e.s(["BirthdayGiftModal",()=>f])},193767,e=>{"use strict";var t=e.i(843476),r=e.i(657688),n=e.i(618566),a=e.i(846932),s=e.i(220318),i=e.i(857259),o=e.i(73966);let l=["/login","/register","/checkout","/admin"];function c(){let e=(0,n.usePathname)(),{isAuthenticated:c}=(0,i.useSession)(),d=(0,o.useBirthdayGift)(e=>e.onOpen),u=(0,o.useBirthdayGift)(e=>e.isOpen),m=l.some(t=>e?.startsWith(t)),{data:p}=(0,s.useBirthdayStatusQuery)(c&&!m);return c&&!m&&!u&&p&&p.inClaimWindow&&!p.giftClaimed&&p.giftItems.length?(0,t.jsxs)(a.motion.button,{type:"button",onClick:d,"aria-label":"Open your birthday gift",whileTap:{scale:.94},className:"fixed right-4 bottom-36 z-40 flex h-16 w-16 items-center justify-center rounded-full bg-[linear-gradient(262.97deg,rgba(249,192,66,0.6)_6.98%,rgba(253,230,169,0.6)_43.95%,rgba(249,192,66,0.6)_90.55%)] p-px shadow-[0_10px_30px_-8px_#f9c042b3] md:bottom-20 md:h-20 md:w-20",children:[(0,t.jsx)(a.motion.span,{"aria-hidden":!0,
1className:"pointer-events-none absolute -inset-2 rounded-full bg-[radial-gradient(circle,rgba(249,192,66,0.72)_0%,rgba(249,192,66,0)_62%)] blur-sm",animate:{opacity:[.35,1,.35],scale:[.94,1.08,.94]},transition:{duration:2,repeat:1/0,ease:"easeInOut"}}),(0,t.jsxs)("span",{className:"relative flex h-full w-full items-center justify-center overflow-hidden rounded-full bg-[radial-gradient(circle_at_32%_22%,rgba(249,192,66,0.42)_0%,rgba(124,58,237,0.55)_45%,rgba(26,0,64,0.98)_100%)]",children:[(0,t.jsx)(a.motion.img,{src:"/spin/bg-glow-spiral.png",alt:"","aria-hidden":!0,className:"pointer-events-none absolute h-[170%] w-[170%] opacity-40 mix-blend-screen",animate:{rotate:360},transition:{duration:18,repeat:1/0,ease:"linear"}}),(0,t.jsx)(r.default,{src:"/dailyneed-plus/gift-full.png",alt:"","aria-hidden":!0,width:320,height:320,className:"relative h-[72%] w-[72%] object-contain drop-shadow-[0_2px_6px_rgba(0,0,0,0.45)]"})]})]}):null}e.s(["BirthdayGiftLauncher",()=>c])},813889,e=>{"use strict";var t=e.i(271645),r=e.i(618566),n=e.i(220318),a=e.i(857259),s=e.i(725990),i=e.i(73966);let o=["/login","/register","/checkout","/admin"],l="dn:bday-popup-shown";function c(){let e=(0,r.usePathname)(),{isAuthenticated:c,isLoading:d}=(0,a.useSession)(),u=(0,i.useBirthdayGift)(e=>e.onOpen),m=(0,t.useRef)(!1),p=!o.some(t=>e?.startsWith(t)),{data:f}=(0,n.useBirthdayStatusQuery)(p&&c&&!d);return(0,t.useEffect)(()=>{if(!(!p||d||!c||m.current||function(){try{return"1"===sessionStorage.getItem(l)}catch{return!0}}())&&f&&!s.useSpinDrawer.getState().isOpen&&f.inClaimWindow&&!f.giftClaimed&&0!==f.giftItems.length){m.current=!0;try{sessionStorage.setItem(l,"1")}catch{}u()}},[p,c,d,f,u]),null}e.s(["BirthdayGiftAutoOpenBridge",()=>c])},320078,e=>{"use strict";var t=e.i(843476),r=e.i(271645),n=e.i(627198),a=e.i(272185);function s(){let[e,s]=(0,r.useState)(!1),i=(0,r.useCallback)(()=>{(0,a.hasQueuedCorporateCouponPopup)()&&s(!0)},[]),o=(0,r.useCallback)(()=>{s(!1),(0,a.clearQueuedCorporateCouponPopup)()},[]);return((0,r.useEffect)(()=>{i();let e=()=>i(),t=e=>{(e.key===a.CORPORATE_COUPON_POPUP_KEY||e.key===a.CORPORATE_COUPON_POPUP_FALLBACK_KEY)&&i()};return window.addEventListener(a.CORPORATE_COUPON_POPUP_EVENT,e),window.addEventListener("storage",t),()=>{window.removeEventListener(a.CORPORATE_COUPON_POPUP_EVENT,e),window.removeEventListener("storage",t)}},[i]),e)?(0,t.jsx)("div",{className:"fixed inset-0 z-[200] flex items-center justify-center bg-black/50",onClick:o,children:(0,t.jsx)("div",{onClick:e=>e.stopPropagation(),children:(0,t.jsx)(n.CorporateDiscountModal,{onClose:o})})}):null}e.s(["CorporateCouponPopup",()=>s])},585216,e=>{"use strict";var t=e.i(843476),r=e.i(167881),n=e.i(743687),a=e.i(502041),s=e.i(37727),i=e.i(846696),o=e.i(192223);function l(){let{isOpen:e,onClose:l,onSuccess:c,product:d}=(0,a.useAgeVerificationDrawer)();return(0,t.jsx)(n.Drawer,{open:e,onOpenChange:l,children:(0,t.jsxs)(n.DrawerContent,{className:"px-2 pb-4 md:!mx-auto md:!w-full md:!max-w-md md:!rounded-t-2xl",children:[(0,t.jsxs)(n.DrawerHeader,{className:"relative flex items-start text-left",children:[d?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex gap-4",children:[(0,t.jsx)("div",{className:"bg-product-media relative h-14 w-14 flex-shrink-0 overflow-hidden rounded-md border",children:(0,t.jsx)(o.SafeImage,{src:d.imageUrl,alt:d.title,fill:!0,className:"object-contain p-1 mix-blend-multiply",sizes:"56px"})}),(0,t.jsxs)("div",{className:"flex flex-col justify-center text-left",children:[(0,t.jsx)("h3",{className:"text-foreground text-md leading-tight font-semibold",children:d.title}),d.netWeight&&(0,t.jsx)("p",{className:"text-muted-foreground mt-0.5 text-sm",children:d.netWeight})]})]}),(0,t.jsx)(n.DrawerTitle,{className:"text-destructive mx-auto text-lg font-bold",children:"Age Verification Required"})]}):(0,t.jsx)(n.DrawerTitle,{className:"text-destructive mt-12 mb-2 text-xl font-bold",children:"Age Verification Required"}),(0,t.jsx)(r.Button,{variant:"ghost",size:"icon",onClick:l,className:"absolute top-0 right-0",children:(0,t.jsx)(s.X,{className:"h-5 w-5"})})]}),(0,t.jsxs)("div",{className:"text-muted-foreground space-y-4 px-2 text-center text-sm",children:[(0,t.jsxs)("p",{children:["This product contains alcohol.",(0,t.jsx)("br",{}),"You must be 18 years or older to purchase alcohol products."]}),(0,t.jsx)("p",{children:"Please confirm your age to continue."})]}),(0,t.jsxs)(n.DrawerFooter,{className:"grid w-full grid-cols-2 gap-2 px-0 pb-6",children:[(0,t.jsx)(r.Button,{variant:"outline",className:"border-border text-foreground hover:bg-muted/50 rounded-full text-xs",onClick:()=>
1{localStorage.setItem("ageVerified","false"),l(),i.toast.error("You must be 18 or older to purchase this item.")},children:"I am Under 18"}),(0,t.jsx)(r.Button,{variant:"outline",className:"border-border text-foreground hover:bg-muted/50 rounded-full text-xs",onClick:()=>{localStorage.setItem("ageVerified","true"),l(),c&&c()},children:"I am 18+"})]})]})})}e.s(["AgeVerificationDrawer",()=>l])},220073,e=>{"use strict";var t=e.i(843476),r=e.i(271645),n=e.i(299023),a=e.i(107233),s=e.i(37727),i=e.i(167881),o=e.i(743687),l=e.i(192223),c=e.i(744871),d=e.i(833747),u=e.i(846696),m=e.i(647163),p=e.i(924672),f=e.i(880470);e.i(972694);var h=e.i(533187),x=e.i(272224),g=e.i(102635),y=e.i(625801),b=e.i(846932),v=e.i(88653),w=e.i(441043),j=e.i(450217),N=e.i(698635),k=e.i(794764),C=e.i(912598);function S(){let{isOpen:e,onClose:S,product:P}=(0,c.useVariantSelectionDrawer)(),A=(0,C.useQueryClient)(),{handleAddItem:I,handleUpdateQty:E,handleRemove:_,cartItems:M,getQuantityStep:O,handleAddSignatureBundle:T}=(0,d.useCartLogic)(),{track:L}=(0,x.useAnalytics)(),[B,D]=(0,r.useState)("piece"),R=(0,r.useRef)(null),U=(0,r.useRef)(!1),z=(0,r.useCallback)(()=>{R.current&&clearTimeout(R.current),R.current=setTimeout(()=>{S()},3e3)},[S]),W=(0,r.useCallback)(()=>{U.current&&z()},[z]),G=(0,r.useRef)(null),[F,$]=(0,r.useState)(0);(0,r.useEffect)(()=>{e||(R.current&&(clearTimeout(R.current),R.current=null),U.current=!1,G.current=null,$(0))},[e]),(0,r.useEffect)(()=>{G.current=null,$(0)},[B]);let V=(0,p.getBrandFromTenant)((0,f.useClientTenant)());(0,r.useEffect)(()=>{if(!e||!P)return;let t=Number(P.variants?.[0]?.minimumOrderQuantity)||1,r="carton"===P.minimumOrderUnit&&t<1,n=1===X||("carton"!==P.minimumOrderUnit||r)&&(P.displayPiecePrice??0)>0;setTimeout(()=>D(n?"piece":"carton"),0)},[e,P]);let q=(0,r.useRef)(new Set);(0,r.useEffect)(()=>{if(!e)return;let t=c.useVariantSelectionDrawer.getState().product;if(!t)return;let r=t.variants?.[0];if(!r)return;let n=`${t.id}:${r.id}`;if(q.current.has(n))return;if(q.current.size>=200){let e=q.current.values().next().value;void 0!==e&&q.current.delete(e)}q.current.add(n);let{amount:a,currency:s}=(0,g.resolveVariantPrice)(t,r),i=(0,h.productToProductLine)({id:r.id,sku:r.sku,name:t.title,brand:"string"==typeof t.brand?t.brand:t.brand?.name??void 0,category:t.category??void 0,variantName:r.name??void 0,price:a,currency:s});L({event:"view_item",ecommerce:{currency:s,value:a,items:(0,h.toGa4Items)([i])}})},[e,P?.id,L]);let K=(0,r.useMemo)(()=>{if(P?.variants)return P.variants.find(e=>"carton"!==e.minimumOrderUnit)},[P]),Q=(0,r.useMemo)(()=>{if(P?.variants)return P.variants.find(e=>"carton"===e.minimumOrderUnit)},[P]),Y=P?.variants?.[0],H=Q||(P?.minimumOrderUnit==="carton"?Y:void 0),X=P?.packsPerCarton||1,J=Y||K||Q,Z=K?.unreservedQuantity??J?.unreservedQuantity??0,ee=J?.unreservedQuantity??0,et=(P?.displayCartonPrice??0)>0&&X>1,er=P?.type==="predefined_combo",{data:en}=(0,w.useBundleBySlugQuery)(er&&P?.slug||""),ea=(0,r.useCallback)(()=>{if(!P)return;let e=("piece"===B?K:H)||P.variants[0],t=e?.priceCurrency??"NGN",r="carton"===B?e?.priceAmountPerCarton??P.displayCartonPrice??0:e?.priceAmountPerPack??P.displayPiecePrice??0;L({event:"generate_lead",currency:t,value:r>0?r:void 0}),u.toast.info("Out of stock. We will notify you when available.")},[P,K,H,B,L]),es=async()=>{if(!P)return;let e=("piece"===B?K:H)||P.variants[0];if(!e)return;let t=e.unreservedQuantity??0;if(t<=0)return void ea();try{let r="carton"===B,n=P.packsPerCarton||1,a=Number(e.minimumOrderQuantity)||1,s=r?Math.round(("carton"===e.minimumOrderUnit?Math.max(1,a):1)*n):a<1&&"carton"===P.minimumOrderUnit?Math.round(a*n):Math.max(1,Math.round(a)),i=P.displayCartonPrice,o=P.displayPiecePrice;if(eh+s>t)return void u.toast.error(`Limited stock available. Only ${Math.floor(t)} item${1===Math.floor(t)?"":"s"} left.`);let l=Math.round(o||(i?i/n:0));await I({baseUnit:e.baseUnit,category:P.category,packagingUnit:e.packagingUnit,unreservedQuantity:t,sku:e.sku,variantId:e.id,productName:P.title,variantName:e.name,brand:P.brand,quantityPieces:s,imageUrl:(e.media||[])[0]?.url||(P.media||[])[0]?.url||P.defaultImageUrl||"",imageAlt:e.name||e.sku,unitPriceSnapshotAmount:o||l,priceSnapshotCurrency:e.priceCurrency||"NGN",minOrderQuantityPieces:s,piecesPerCarton:n>
11?n:1,metadata:{sellableUnit:r?"carton":"piece",piecePrice:Number(o||l),cartonPrice:Number(i||(o||l)*n),discount:e.discount||void 0,taxRate:e.taxRate,baseUnit:e.baseUnit,packagingUnit:e.packagingUnit,category:P.category||void 0,productType:P.type||null}}),U.current=!0,z()}catch(e){console.error("Failed to add to cart",e)}},ei=("piece"===B?K:H)||P?.variants?.[0],eo=en??P,el=eo?.variants?.find(e=>e.id===ei?.id||e.sku===ei?.sku)??ei,ec=(0,j.useSignatureBundleStock)({product:eo,bundleProduct:eo,selectedVariant:el}),ed=er&&ec.isSignatureBundle,eu=ed&&!!ec.isLoading,em=(0,N.useSignatureBundleCartControls)(ed?P?.id:null),ep=ed?!eu&&ec.hasOutOfStockBundleItems:Z<=0,ef=ed?!eu&&ec.hasOutOfStockBundleItems:!et||ee<=0||ee<X,eh=(0,r.useMemo)(()=>M.filter(e=>!e.bundleId&&e.variantId===ei?.id).reduce((e,t)=>e+t.quantityPieces,0),[M,ei?.id]);if(!P)return null;let{title:ex,displayPiecePrice:eg,displayCartonPrice:ey}=P,eb=P?.variants?.[0]?.priceCurrency||"NGN",ev=ei?.unreservedQuantity??0,ew=Math.max(0,ev-eh),ej="carton"===B&&X>1?X:1,eN=ed?!eu&&ec.hasOutOfStockBundleItems:ew<ej,ek=M.find(e=>!e.bundleId&&e.variantId===ei?.id&&(e.metadata?.sellableUnit??"piece")===("carton"===B?"carton":"piece"))??null,eC=ek?.quantityPieces??0,eS="carton"===B&&X>1?X:1,eP=ek&&G.current?.itemId===ek.id?G.current.qty:eC,eA=ek?F||("carton"===B&&X>1?Math.floor(eP/X):eP):0,eI=ei?.discount,eE=Number(ei?.minimumOrderQuantity)||1,e_="carton"===B,eM=Number(P?.variants?.[0]?.minimumOrderQuantity)||1,eO=P?.minimumOrderUnit==="carton"&&eM<1,eT=Number(K?.minimumOrderQuantity)||1,eL=eO&&"piece"===B?((P?.displayCartonPrice??0)||0)*eM:"piece"===B&&eT>1?((P?.displayPiecePrice??0)||0)*eT:("piece"===B?eg:ey)||0,eB=(0,m.calculateBundlePricing)({quantity:eE,unitPrice:eL,moq:eE,discount:eI?{...eI,value:e_&&"fixed"===eI.type?eI.value*X:eI.value}:null}),eD=eE>0?eB.finalTotal/eE:eL,eR=ei?.campaignPricing,eU="carton"===B,ez=(0,y.selectCampaignPricing)(eR,eU?"carton":"pack","cbp"),eW=ez.displayPrice,eG=ez.basePrice,eF=null!=eW,e$=(0,y.getCampaignPricingMetrics)(eR,eU?"carton":"pack","cbp",eb),eV=!!eI&&eD<eL,eq=null!=eW&&eW>eD?eW:null!=eG&&eG>eD?eG:null,eK=null!=eq?eq-eD:0,eQ=(0,m.formatMoney)(Math.round(eD),eb),eY=(0,m.formatMoney)(eL,eb),eH=K||Q||P?.variants?.[0],eX=eH?.netWeight||eH?.combinations?.find(e=>e?.value?.attribute?.name?.toLowerCase()==="net qty")?.value?.value,eJ=1===X||(P?.minimumOrderUnit!=="carton"||eO)&&(P?.displayPiecePrice??0)>0,eZ=(0,m.shortBaseUnit)(P?.variants?.[0]?.baseUnit||"piece"),e0=Number(ei?.safetyStock)||0,e1=ew>0&&e0>0&&ew<e0?Math.floor(ew):null,e2=ed?em.quantity:eA,e4=async()=>{if(!P||!ei)return;let e=ec.bundleDisplayItemsWithStock,t=e.some(e=>!e.productId||!e.variantId);if(ec.hasOutOfStockBundleItems)return void u.toast.error("Bundle is out of stock");if(t||0===e.length)return void u.toast.error("Unable to add this bundle right now. Please try again.");try{await T({basketId:P.id,name:P.title,items:e.map((e,t)=>{let r=Math.max(1,Math.floor(e.quantity||1)),n=e.uom.toLowerCase().includes("carton")?"carton":"piece",a="carton"===n?Math.max(1,Math.round((e.requiredBaseUnits??r)/r)):1,s="carton"===n?r*a:r,i=e.pricing?.pricePerPack??0,o=e.pricing?.pricePerCarton??i*a;return{sku:e.sku,variantId:e.variantId,quantityPieces:s,minOrderQuantityPieces:s,piecesPerCarton:a,unitPriceSnapshotAmount:e.isFreeSample?0:i,priceSnapshotCurrency:e.pricing?.currency||"NGN",category:P.category||"Bundle",packagingUnit:ei.packagingUnit,baseUnit:ei.baseUnit,productName:e.productName,variantName:e.variantName,brand:e.brand,imageUrl:e.imageUrl,imageAlt:e.variantName||e.productName||e.sku,metadata:{sellableUnit:n,piecePrice:i,cartonPrice:o,taxRate:Number(e.taxRate??ei.taxRate??0),baseUnit:ei.baseUnit,packagingUnit:ei.packagingUnit,category:P.category||"Bundle",productName:e.productName||void 0,variantName:e.variantName||void 0,brand:e.brand||void 0,imageUrl:e.imageUrl||void 0,isFreeGift:!!e.isFreeSample,signatureBundle:!0,signatureBundleParentSku:ei.sku,signatureBundleParentVariantId:ei.id,signatureBundleParentPrice:Math.round(eD),signatureBundleParentStrikePrice:eq??void 0,signatureBundleParentSavedAmount:eK>0?eK:void 0,signatureBundleDisplayOrder:t,pricing:e.pricing?{pricePerCarton:e.pricing.pricePerCarton??void 0,pricePerPack:e.pricing.pricePerPack,currency:e.pricing.currency}:void 0}}})}
1),await A.invalidateQueries({queryKey:k.cartKeys.all}),u.toast.success("Bundle added to cart"),U.current=!0,z()}catch(e){console.error("Failed to add signature bundle",e),u.toast.error("Unable to add this bundle right now. Please try again.")}};return(0,t.jsx)(o.Drawer,{open:e,onOpenChange:S,children:(0,t.jsxs)(o.DrawerContent,{className:"px-4 pb-4 md:!mx-auto md:!w-full md:!rounded-t-2xl",children:[(0,t.jsxs)(o.DrawerHeader,{className:"relative flex items-start pr-8 pl-0 text-left",children:[(0,t.jsxs)("div",{className:"flex gap-4",children:[(0,t.jsx)("div",{className:"bg-product-media variant-thumb relative h-14 w-14 flex-shrink-0 overflow-hidden rounded-md border",children:(0,t.jsx)(l.SafeImage,{src:P.media?.[0]?.url||P.defaultImageUrl||"",alt:ex,fill:!0,className:"object-contain p-1 [mix-blend-mode:var(--product-media-blend)]",sizes:"56px"})}),(0,t.jsxs)("div",{className:"flex flex-col justify-center text-left",children:[(0,t.jsx)("h3",{className:"text-foreground text-md leading-tight font-semibold",children:P.title}),eX&&(0,t.jsx)("p",{className:"text-muted-foreground mt-0.5 text-sm",children:eX})]})]}),(0,t.jsx)(i.Button,{variant:"ghost",size:"icon",onClick:S,className:"text-muted-foreground absolute top-0 right-0 h-8 w-8",children:(0,t.jsx)(s.X,{className:"h-5 w-5"})})]}),(0,t.jsxs)("div",{className:"variant-options-section mt-4",children:[(0,t.jsx)("p",{className:"text-muted-foreground mb-3 text-sm",children:"Select Variant"}),(0,t.jsxs)("div",{className:"no-scrollbar flex gap-3 overflow-x-auto pb-2",children:[eJ&&(0,t.jsxs)("button",{disabled:ep,onClick:()=>{D("piece"),W()},className:(0,m.cn)("flex flex-col items-center gap-2",ep&&"cursor-not-allowed opacity-60","piece"===B?"":"opacity-80"),children:[(0,t.jsxs)("div",{className:(0,m.cn)("bg-product-media variant-tile relative flex h-24 w-24 items-center justify-center rounded-xl border p-2 transition-all","piece"===B?"variant-tile-selected border-brand-accent shadow-sm":ep?"border-danger-soft-border":"border-border hover:border-border/80"),children:[(0,t.jsx)(l.SafeImage,{src:K?.media?.[0]?.url||P.media?.[0]?.url||P.defaultImageUrl||"",alt:"Piece",fill:!0,className:"object-contain p-2 mix-blend-multiply",sizes:"96px"}),ep&&(0,t.jsx)("span",{className:"plate-chip absolute top-1/2 left-1/2 z-10 -translate-x-1/2 -translate-y-1/2 rounded px-2 py-1 text-[10px] font-semibold whitespace-nowrap",children:"Out of Stock"})]}),(0,t.jsx)("span",{className:(0,m.cn)("variant-tile-label text-xs font-semibold","piece"===B?"variant-tile-label-selected text-brand-accent":ep?"text-danger":"text-muted-foreground"),children:eO?`${eM} Carton`:`${eT} ${eZ}`}),"piece"===B&&null!==e1&&(0,t.jsxs)("span",{className:"border-danger-soft-border bg-danger-soft text-danger w-fit rounded-sm border px-2 py-0.5 text-[10px] font-medium",children:[e1," ",eZ," left"]})]}),et&&(0,t.jsxs)("button",{disabled:ef,onClick:()=>{D("carton"),W()},className:(0,m.cn)("flex flex-col items-center gap-2",ef&&"cursor-not-allowed opacity-60 grayscale","carton"===B?"":"opacity-80"),children:[(0,t.jsxs)("div",{className:(0,m.cn)("bg-product-media variant-tile relative flex h-24 w-24 items-center justify-center rounded-xl border p-2 transition-all","carton"===B?"variant-tile-selected border-brand-accent shadow-sm":ef?"border-border":"border-border hover:border-border/80"),children:[(0,t.jsx)(l.SafeImage,{src:P.cartonImage||("secondary"===V?"/celebr8_carton.avif":"/daily-need-carton.webp"),alt:"Carton",fill:!0,className:"object-contain p-2 mix-blend-multiply",sizes:"96px"}),ef&&(0,t.jsx)("span",{className:"plate-chip absolute top-1/2 left-1/2 z-10 -translate-x-1/2 -translate-y-1/2 rounded px-2 py-1 text-[10px] font-semibold whitespace-nowrap",children:"Out of Stock"})]}),(0,t.jsx)("span",{className:(0,m.cn)("variant-tile-label text-xs font-semibold","carton"===B?"variant-tile-label-selected text-brand-accent":"text-muted-foreground"),children:P.packsPerCarton?`Carton of ${P.packsPerCarton} ${eZ}`:"Carton"}),"carton"===B&&null!==e1&&(0,t.jsxs)("span",{className:"border-danger-soft-border bg-danger-soft text-danger w-fit roun
1ded-sm border px-2 py-0.5 text-[10px] font-medium",children:[e1," ",eZ," left"]})]})]})]}),eN&&0===e2&&(0,t.jsx)("div",{className:"mt-3 flex items-center justify-between gap-3 rounded-xl border border-danger-soft-border bg-danger-soft px-4 py-3",children:(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)("span",{className:"text-sm font-semibold text-danger",children:ed?"Combo is out of stock":"Current selection is out of stock"}),(0,t.jsx)("span",{className:"text-xs font-medium text-danger/80",children:ed?"One or more items in this combo are unavailable":"Please try changing the selection"}),ed&&ec.outOfStockBundleItems.length>0&&(0,t.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:ec.outOfStockBundleItems.map(e=>(0,t.jsx)("span",{className:"rounded-full bg-card px-2 py-1 text-[11px] font-bold text-danger ring-1 ring-danger-soft-border",children:e.productName||e.variantName||e.sku},e.id))})]})}),(0,t.jsxs)("div",{className:"mt-8 flex items-center justify-between",children:[(0,t.jsx)("div",{className:"flex flex-col",children:eF&&eR?(0,t.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-foreground text-2xl font-bold",children:eQ}),(0,t.jsx)("span",{className:"text-muted-foreground text-sm line-through",children:(0,m.formatMoney)(eW,eb)})]}),e$.visible&&e$.formattedDiscount&&(0,t.jsxs)("div",{className:"flex items-center gap-2 w-fit mt-2 bg-success-soft border border-success rounded-full",children:[(0,t.jsx)("span",{className:"text-[10px] font-medium text-success pl-2",children:e$.formattedSavings}),(0,t.jsx)("span",{className:"relative flex w-fit items-center gap-1 rounded-lg bg-success px-2 py-0.5 text-[10px] font-bold text-white",children:e$.formattedDiscount})]})]}):eV?(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-foreground text-2xl font-bold",children:eQ}),(0,t.jsx)("span",{className:"text-muted-foreground text-sm line-through",children:eY})]}):(0,t.jsx)("span",{className:"text-foreground text-2xl font-bold",children:eQ})}),(0,t.jsx)(v.AnimatePresence,{mode:"wait",children:eu?(0,t.jsx)("div",{className:"flex-shrink-0",children:(0,t.jsx)(i.Button,{disabled:!0,className:"shadow-brand-accent/20 bg-brand-accent h-10 w-28 rounded-full text-sm font-bold shadow-md md:w-32 opacity-80",children:(0,t.jsxs)("span",{className:"flex items-center justify-center gap-2",children:[(0,t.jsx)("span",{className:"h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent"}),"Loading..."]})})}):e2>0?(0,t.jsxs)(b.motion.div,{layout:!0,initial:{scale:.8,opacity:0}
1,animate:{scale:1,opacity:1},exit:{scale:.8,opacity:0},className:"bg-brand-accent shadow-brand-accent/20 text-primary-foreground flex h-10 w-28 items-center justify-between rounded-full px-1 shadow-md md:w-32",children:[(0,t.jsx)(b.motion.div,{whileTap:{scale:.8},children:(0,t.jsx)(i.Button,{variant:"ghost",size:"icon",className:"hover:bg-primary-foreground/20 text-primary-foreground h-8 w-8 rounded-full",onClick:()=>{(()=>{if(ed){em.decrement(),z();return}if(!ek)return;let e=eP-eS;e<=0?(G.current=null,$(0),_(ek.id)):(G.current={itemId:ek.id,qty:e},$(Math.round(e/Math.max(1,eS))),E(ek.id,e)),z()})(),(0,m.vibrate)("nudge")},children:(0,t.jsx)(n.Minus,{className:"h-4 w-4"})})}),(0,t.jsx)(b.motion.span,{initial:{scale:.6,y:6,opacity:0},animate:{scale:1,y:0,opacity:1},transition:{type:"spring",stiffness:260},className:"text-primary-foreground w-8 text-center text-sm font-bold tabular-nums",children:e2},e2),(0,t.jsx)(b.motion.div,{whileTap:{scale:.8},children:(0,t.jsx)(i.Button,{variant:"ghost",size:"icon",className:"hover:bg-primary-foreground/20 text-primary-foreground h-8 w-8 rounded-full",onClick:()=>{(()=>{if(ed)return e4();if(!ek)return;let e=eh+eS;e>ev?u.toast.error(`Limited stock available. Only ${Math.floor(ev)} item${1===Math.floor(ev)?"":"s"} left.`):(G.current={itemId:ek.id,qty:e},$("carton"===B&&X>1?Math.floor(e/X):e),E(ek.id,e),z())})(),(0,m.vibrate)("nudge")},children:(0,t.jsx)(a.Plus,{className:"h-4 w-4"})})})]},"qty"):(0,t.jsx)(b.motion.div,{initial:{scale:.8,opacity:0}
1,animate:{scale:1,opacity:1},exit:{scale:.8,opacity:0},children:(0,t.jsx)(b.motion.div,{whileTap:{scale:.92},children:(0,t.jsx)(i.Button,{onClick:()=>{eN?ea():(ed?e4():es(),(0,m.vibrate)("success"))},className:(0,m.cn)(eN?"h-10 rounded-full border border-danger-soft-border bg-card/95 px-6 text-sm font-bold text-danger shadow-sm hover:bg-danger-soft":"bg-brand-accent shadow-brand-accent/20 h-10 w-28 rounded-full text-sm font-bold shadow-md md:w-32"),children:(0,t.jsx)(b.motion.span,{whileTap:{scale:.9},children:eN?"Notify":"Add to Cart"})})})},"add")})]})]})})}e.s(["VariantSelectionDrawer",()=>S])},144597,e=>{"use strict";var t=e.i(843476),r=e.i(522016),n=e.i(271645),a=e.i(618566),s=e.i(647163),i=e.i(657688),o=e.i(201928),l=e.i(488844),c=e.i(531278),d=e.i(872637),u=e.i(833747),m=e.i(30672),p=e.i(494339),f=e.i(857259),h=e.i(907120);function x(){let e=(0,a.usePathname)(),c=(0,a.useRouter)(),{cartItemCount:x}=(0,u.useCartLogic)(),y=(0,p.useIsPlusMember)(),[b,v]=(0,n.useState)(!1),{isAuthenticated:w}=(0,f.useSession)(),j=(0,h.useCheckoutAuthGate)(),{direction:N,isAtTop:k}=(({threshold:e=10,topOffset:t=24}={})=>{let[r,a]=(0,n.useState)("up"),[s,i]=(0,n.useState)(!0),o=(0,n.useRef)(0),l=(0,n.useRef)(null);return(0,n.useEffect)(()=>{o.current=window.scrollY;let r=()=>{l.current=null;let r=window.scrollY;i(r<=t);let n=r-o.current;Math.abs(n)<e||(a(n>0&&r>t?"down":"up"),o.current=r)},n=()=>{null===l.current&&(l.current=requestAnimationFrame(r))};return window.addEventListener("scroll",n,{passive:!0}),n(),()=>{window.removeEventListener("scroll",n),null!==l.current&&cancelAnimationFrame(l.current)}},[e,t]),{direction:r,isAtTop:s}})();if("/login"===e||"/register"===e||e?.startsWith("/checkout")&&x>0)return null;let C=[{label:"Shop",href:"/",icon:d.PiShoppingBag,activeIcon:d.PiShoppingBagBold,isActive:"/"===e||e?.startsWith("/products")||e?.startsWith("/combos")},{label:"Cart",href:"/checkout",icon:o.ShoppingCart,isActive:"/checkout"===e,badge:x,isLoading:b,onClick:async e=>{if(e.preventDefault(),!w&&x>0)return void j(()=>{m.useCartDrawer.getState().setOpen(!1),c.push("/checkout")},"cart-drawer");if(!b){if(x<1)return void c.push("/checkout");v(!0),await new Promise(e=>setTimeout(e,1e3)),c.push("/checkout"),v(!1)}}},{label:"Orders",href:"/my-orders",icon:l.Package,isActive:e?.startsWith("/my-orders")||"/orders"===e}];return(0,t.jsx)("nav",{className:(0,s.cn)("pb-safe fixed right-0 bottom-0 left-0 z-50 border-t shadow-[0_-2px_10px_rgba(0,0,0,0.05)] transition-transform duration-300 ease-out md:hidden",y?"bg-brand-footer-desktop":"bg-background","down"!==N||k?"translate-y-0":"translate-y-full"),children:(0,t.jsxs)("div",{className:"flex h-16 items-stretch",children:[C.map(e=>(0,t.jsx)("div",{className:"flex-1",children:(0,t.jsx)(g,{item:e})},e.label)),(0,t.jsx)(r.default,{href:"/dailyneed-plus",className:"relative block h-full w-24 shrink-0 overflow-hidden rounded-t-2xl",children:(0,t.jsx)(i.default,{src:"/dailyneed-plus/footer-dailyneedplus-badge.png",alt:"DailyNeed Plus",fill:!0,sizes:"96px",className:"object-contain px-1.5 pb-1"})})]})})}function g({item:e}){let n=e.isActive&&e.activeIcon?e.activeIcon:e.icon,a=(0,t.jsxs)("div",{className:(0,s.cn)("relative flex h-full w-full flex-col items-center justify-center gap-1 transition-all",e.isActive?"text-primary":"text-muted-foreground hover:text-primary"),children:[e.isActive&&(0,t.jsx)("span",{className:"absolute top-0 h-1 w-14 rounded-b-full bg-primary"}),(0,t.jsxs)("div",{className:"relative",children:[e.isActive&&(0,t.jsx)("span",{"aria-hidden":!0,className:"bg-primary/25 pointer-events-none absolute top-1/2 left-1/2 h-10 w-10 -translate-x-1/2 -translate-y-1/2 rounded-full blur-md"}),e.isLoading?(0,t.jsx)(c.Loader2,{className:(0,s.cn)("relative h-5 w-5 animate-spin",e.isActive?"text-primary":"text-muted-foreground")}):(0,t.jsx)(n,{className:(0,s.cn)("relative h-5 w-5",e.isActive&&"stroke-primary [stroke-width:2.5]")}),!e.isLoading&&void 0!==e.badge&&e.badge>0&&(0,t.jsx)("span",{className:"bg-destructive ring-background absolute -top-1.5 -right-1.5 flex h-4 w-4 items-center justify-center rounded-full text-[9px] font-bold text-white ring-1",children:e.badge})]}),(0,t.jsx)("span",{className:(0,s.cn)("text-[10px]",e.isActive?"font-bold":"font-medium"),children:e.label})]});return e.onClick?(0,t.jsx)("button",{disabled:e.isLoading,onClick:e.onClick,className:"h-full w-full",children:a}):(0,t.jsx)(r.default,{href:e.href,className:"h-full w-full",children:a})}
1e.s(["BrandBottomNav",()=>x],144597)},524259,e=>{"use strict";var t=e.i(843476),r=e.i(271645),n=e.i(167881),a=e.i(743687),s=e.i(522016);e.i(972694);var i=e.i(345367);function o(){let[e,o]=(0,r.useState)(!1),[l,c]=(0,r.useState)(!1);return((0,r.useEffect)(()=>{c(!0),(0,i.getStoredCookieConsent)()||setTimeout(()=>o(!0),0)},[]),l)?(0,t.jsx)(a.Drawer,{open:e,onOpenChange:o,children:(0,t.jsxs)(a.DrawerContent,{className:"md:!mx-auto md:!w-full md:!max-w-md md:!rounded-t-2xl",children:[(0,t.jsx)(a.DrawerHeader,{className:"border-border border-b text-center",children:(0,t.jsx)(a.DrawerTitle,{className:"text-foreground text-lg font-bold",children:"We Value Your Privacy ðª"})}),(0,t.jsx)("div",{className:"text-muted-foreground px-6 pt-4 text-center text-sm font-medium",children:'We use cookies to enhance your browsing experience, personalize content, and analyze traffic. Analytics and marketing cookies are on by default â choose "Reject All" to turn them off, or "Accept All" to keep them on.'}),(0,t.jsxs)(a.DrawerFooter,{className:"grid w-full grid-cols-2 gap-3 pb-2",children:[(0,t.jsx)(n.Button,{variant:"outline",className:"border-border text-foreground hover:bg-muted/50 rounded-full",onClick:()=>{(0,i.setStoredCookieConsent)("rejected"),o(!1)},children:"Reject All"}),(0,t.jsx)(n.Button,{className:"bg-brand-accent text-brand-accent-foreground rounded-full hover:brightness-90",onClick:()=>{(0,i.setStoredCookieConsent)("accepted"),o(!1)},children:"Accept All"})]}),(0,t.jsx)("div",{className:"pb-6 text-center",children:(0,t.jsx)(s.default,{href:"/cookie-policy",className:"text-brand-accent text-xs hover:underline",children:"View our Cookie Policy"})})]})}):null}e.s(["CookieDrawer",()=>o])},728406,e=>{"use strict";var t=e.i(843476),r=e.i(271645),n=e.i(618566),a=e.i(723911),s=e.i(464316),i=e.i(924672),o=e.i(880470),l=e.i(857259),c=e.i(889982),d=e.i(427670);let u=["/login","/register"];function m({children:e}){let r=(0,n.usePathname)(),{isLoading:a,isDistributor:i,isApproved:o}=(0,l.useSession)();return u.includes(r)||a||!i||o?(0,t.jsx)(t.Fragment,{children:e}):(0,t.jsx)(s.default,{})}function p({children:e}){let s=(0,n.useRouter)(),m=(0,n.usePathname)(),[p,f]=(0,r.useState)(null),h=(0,o.useClientTenant)(),{session:x,isLoading:g,isAuthenticated:y}=(0,l.useSession)(),b=x?.corporateId??null;return((0,r.useEffect)(()=>{!async function(){if(g)return;let e=(0,i.detectTenant)(window.location.hostname),t=a.tokenStorage.getAccessToken();if("corporate"!==e){let e=(0,c.getAppUserContext)();e.flags?.isCorporateUser&&(0,c.setAppUserContext)({corporate:void 0,flags:{isCorporateUser:!1}}),f(!0);return}let r=u.some(e=>m.startsWith(e)),n=y||!!t;if(!n&&!r)return s.replace(`/login?returnUrl=${m}`);if(!n)return f(!0);let o=t?function(e){try{return JSON.parse(atob(e.split(".")[1]))}catch{return null}}(t):null,l=b??o?.corporateId??null;if(null==l&&o?.tenant!=="corporate"){f(!0),s.replace("/");return}let p=(0,c.getAppUserContext)();l&&(0,c.setAppUserContext)(e=>({...e,corporate:e.corporate?.id===l?e.corporate:{id:l,slug:"",name:""},flags:{...e.flags,isCorporateUser:!0}}));let h=!p.corporate?.slug||p.corporate.id!==l;if(l&&h)try{let e=await d.httpClient.get(`/corporates/corporatesById/${l}`,{service:"pim"});(0,c.setAppUserContext)(t=>({...t,corporate:{slug:e.slug,name:e.name,id:e.id,minimumDeliveryAmount:e.minimumDeliveryAmount??void 0,address:e.address?{addressLine1:e.address.addressLine1,addressLine2:e.address.addressLine2,city:e.address.city,state:e.address.state,postalCode:e.address.postalCode,country:e.address.country,phone:e.address.phone,latitude:e.address.latitude,longitude:e.address.longitude}:void 0},flags:{...t.flags,isCorporateUser:!0}}))}catch(e){console.error("Failed to hydrate corporate context",e)}f(!0)}()},[m,s,g,y,b]),null===p&&"corporate"===h)?null:(0,t.jsx)(t.Fragment,{children:e})}e.s(["AuthGuard",()=>m,"CorporateGuard",()=>p])},181022,e=>{"use strict";var t=e.i(843476),r=e.i(167881),n=e.i(743687),a=e.i(696499),s=e.i(60166),i=e.i(412585),o=e.i(833747),l=e.i(794764),c=e.i(857259),d=e.i(698676),u=e.i(907120),m=e.i(417127),p=e.i(798481),f=e.i(761617),h=e.i(638141),x=e.i(647163),g=e.i(954616),y=e.i(423609),b=e.i(531278),v=e.i(871689),w=e.i(6
157688),j=e.i(618566),N=e.i(271645),k=e.i(846696),C=e.i(216277),S=e.i(427670),P=e.i(172138),A=e.i(572041);e.i(247167);var I=e.i(37727),E=e.i(441043);let _={src:e.i(512788).default,width:110,height:110,blurWidth:0,blurHeight:0};var M=e.i(769345),O=e.i(651698);e.i(972694);var T=e.i(748213),L=e.i(315328),B=e.i(155769);function D({orderId:e,onClose:r,orderItems:n=[],subtotal:a=0,discount:s=0,shipping:i=0,total:o=0,paymentAdjustments:l=[],purchasePayload:c=null}){(0,j.useRouter)();let[d,u]=(0,N.useState)(10);(0,N.useEffect)(()=>{(0,x.vibrate)("buzz")},[]),(0,N.useEffect)(()=>{if(!e)return;let t=c??(0,L.loadPurchaseCapture)();t&&(0,L.firePurchaseOnce)(e,()=>{let r=(0,T.buildPurchaseSnapshot)({orderId:e,items:t.items,value:t.value,currency:t.currency,identity:t.identity,matching:t.matching,tenant:t.tenant});r&&(0,B.dlPush)(r),(0,L.clearPurchaseCapture)()})},[e,c]),(0,N.useEffect)(()=>{let e=setInterval(()=>{u(t=>t<=1?(clearInterval(e),r(),0):t-1)},1e3);return()=>clearInterval(e)},[r]);let{data:m}=(0,E.useProductListQuery)({page:1,limit:4}),p=e=>new Intl.NumberFormat("en-NG",{style:"currency",currency:"NGN",minimumFractionDigits:0}).format(e),f={maskImage:` 2 radial-gradient(circle 20px at 0% 50%, transparent 98%, black 100%), 3 radial-gradient(circle 20px at 100% 50%, transparent 98%, black 100%) 4 `,WebkitMaskImage:` 5 radial-gradient(circle 15px at 0% 50%, transparent 98%, black 100%), 6 radial-gradient(circle 15px at 100% 50%, transparent 98%, black 100%) 7 `,maskComposite:"intersect",WebkitMaskComposite:"source-in",maskRepeat:"no-repeat",WebkitMaskRepeat:"no-repeat"};return(0,t.jsxs)("div",{className:"flex min-h-full flex-col items-center overflow-y-auto bg-success-soft px-4 py-6 pb-20",onClick:r,children:[(0,t.jsx)("div",{className:"mb-2 flex w-full justify-start",children:(0,t.jsx)("button",{onClick:r,className:"rounded-full p-2 hover:bg-black/5","aria-label":`Close in ${d} seconds`,children:(0,t.jsx)(I.X,{className:"h-5 w-5 text-muted-foreground",strokeWidth:1.5})})}),(0,t.jsxs)("div",{className:"drop-shadow-[0_10px_5px_rgba(0,0,0,0.1)] filter",onClick:e=>e.stopPropagation(),children:[(0,t.jsxs)("div",{className:"flex w-full max-w-sm flex-col items-center bg-card p-10 pb-4 shadow-xl",children:[(0,t.jsx)("div",{className:"absolute max-w-sm",children:(0,t.jsx)(M.default,{animationData:O.default,loop:!0})}),(0,t.jsx)(w.default,{src:_,alt:"order success",width:140,height:140}),(0,t.jsx)("h3",{className:"mt-3 text-xl font-bold text-foreground",children:"Thank You"}),(0,t.jsx)("h2",{className:"text-base font-bold text-success",children:"Your Order Placed Successfully!!!"})]}),(0,t.jsx)("div",{style:f,className:"flex h-12 w-full items-center justify-between bg-card px-10",children:(0,t.jsx)("div",{className:"w-full border-b-2 border-dashed border-border"})}),(0,t.jsxs)("div",{className:"mb-10 w-full max-w-sm shadow-xl",style:{WebkitMaskImage:"radial-gradient(circle 20px at center 100%, transparent 98%, black 100%)",maskImage:"radial-gradient(circle 24px at center 100%, transparent 98%, black 100%)",WebkitMaskSize:"40px 100%",maskSize:"60px 100%",WebkitMaskRepeat:"repeat-x",maskRepeat:"repeat-x"},children:[(0,t.jsxs)("div",{className:"bg-card px-5 pt-5 pb-0 shadow-md",children:[(0,t.jsxs)("div",{className:"pb-4 text-center",children:[(0,t.jsx)("p",{className:"text-[11px] font-medium tracking-widest text-muted-foreground uppercase",children:"Order Details"}),(0,t.jsxs)("p",{className:"mt-1 text-base font-bold text-foreground",children:["#",e]})]}),(0,t.jsx)("div",{className:"divide-y divide-gray-100",children:n.map(e=>{let r=e.metadata,n=e.piecesPerCarton??1,a=r?.sellableUnit==="carton",s=a?Math.floor(e.quantityPieces/n):0,i=a?e.quantityPieces%n:e.quantityPieces,o=function(e){let{quantityPieces:t,piecesPerCarton:r,unitPriceSnapshotAmount:n,cartonPrice:a,piecePrice
7:s,isSignatureBundleLine:i}=e,o=r??1,l=s??n??0;return function({piecesPerCarton:e,cartonPrice:t,sellableUnit:r,isSignatureBundleLine:n}){return!!t&&!((e??1)<=1)&&(!n||"carton"===r)}(e)?Math.floor(t/o)*(a??0)+t%o*l:i?l*t:(n||0)*t}({quantityPieces:e.quantityPieces,piecesPerCarton:n,unitPriceSnapshotAmount:e.unitPriceSnapshotAmount,cartonPrice:r?.cartonPrice,piecePrice:r?.piecePrice,sellableUnit:r?.sellableUnit,isSignatureBundleLine:r?.signatureBundle}),l=a?[s>0?`${s} carton${s>1?"s":""}`:"",i>0?`${i} pc${i>1?"s":""}`:""].filter(Boolean).join(" + "):`${e.quantityPieces} x ${e.packagingUnit??"pc"}`;return(0,t.jsxs)("div",{className:"flex items-center gap-3 py-3",children:[e.imageUrl?(0,t.jsx)("img",{src:e.imageUrl,alt:e.imageAlt??e.productName??"",className:"h-10 w-10 shrink-0 rounded-lg border border-border bg-product-media object-contain"}):(0,t.jsx)("div",{className:"h-10 w-10 shrink-0 rounded-lg bg-muted"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("p",{className:"line-clamp-2 text-xs leading-tight font-semibold text-foreground",children:e.productName}),e.variantName&&(0,t.jsx)("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:e.variantName}),(0,t.jsx)("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:l})]}),(0,t.jsx)("p",{className:"shrink-0 text-xs font-bold text-foreground",children:p(o)})]},e.id)})})]}),(0,t.jsx)("div",{className:"bg-card px-5 pt-3 pb-7",children:(0,t.jsxs)("div",{className:"space-y-2 pb-5",children:[(0,t.jsxs)("div",{className:"flex justify-between text-xs text-muted-foreground",children:[(0,t.jsx)("span",{children:"Sub Total"}),(0,t.jsx)("span",{className:"font-medium text-muted-foreground",children:p(a)})]}),s>0&&(0,t.jsxs)("div",{className:"flex justify-between border-t border-border py-2 text-xs text-muted-foreground",children:[(0,t.jsx)("span",{children:"Discount"}),(0,t.jsx)("span",{className:"font-medium line-through",children:p(s)})]}),l.length>0&&l.map(e=>(0,t.jsxs)("div",{className:"flex justify-between border-t border-border py-2 text-xs text-muted-foreground",children:[(0,t.jsx)("span",{children:e.label}),(0,t.jsxs)("span",{className:"font-medium",children:["-",p(e.amount)]})]},e.label)),i>0&&(0,t.jsxs)("div",{className:"flex justify-between text-xs text-muted-foreground",children:[(0,t.jsx)("span",{children:"Shipping"}),(0,t.jsx)("span",{className:"font-medium text-muted-foreground",children:p(i)})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between border-t border-border text-sm font-bold text-foreground",children:[(0,t.jsx)("span",{children:"Total"}),(0,t.jsx)("span",{className:"text-muted-foreground text-lg",children:p(o)})]})]})})]})]})]})}var R=e.i(309968);function U({pointsAwarded:e,onDismiss:r}){return(0,N.useEffect)(()=>{(0,x.vibrate)("buzz")},[]),(0,t.jsx)("div",{className:"fixed inset-0 z-[60] flex items-start justify-center bg-black/50 px-4 pt-24",role:"dialog","aria-modal":"true",onClick:r,children:(0,t.jsx)("div",{className:"relative",onClick:e=>e.stopPropagation(),children:(0,t.jsxs)("div",{className:"relative flex h-[420px] w-[430px] max-w-[100vw] items-center justify-center",children:[(0,t.jsx)(w.default,{src:"/earned-points-bg.svg",alt:"Reward background",fill:!0,priority:!0,className:"points-rays pointer-events-none scale-[1.22] object-contain opacity-95 select-none"}),(0,t.jsxs)("div",{className:"relative z-10 min-h-[180px] w-[250px] overflow-visible rounded-[28px] bg-card shadow-[0_18px_40px_rgba(0,0,0,0.18)]",children:[(0,t.jsx)("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 rounded-[28px] bg-warning-soft"}),(0,t.jsx)("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-[78px] rounded-t-[28px]",style:{background:"linear-gradient(180deg, rgba(255,196,72,0.24) 0%, rgba(255,196,72,0.08) 45%, transparent 100%)"}}),(0,t.jsxs)("div",{className:"relative flex flex-col items-center px-5 pt-12 pb-5 text-center",children:[(0,t.jsx)("p",{className:"mt-4 text-[10px] font-semibold text-foreground",children:"You've earned ð"}),(0,t.jsxs)("div",{className:"mt-4 flex items-center justify-center gap-2 leading-none",children:[(0,t.jsx)("div",{className:"flex items-center justify-center",children:(0,t.jsx)(R.LoyaltyIcon,{type:"points",size:84,className:"block shrink-0"})}),(0,t.jsx)("div",{className:"flex items-center justify-center",children:(0,t.jsx)("span",{className:"relative text-center text-[42px] leading-none font-extrabold tracking-tight text-foreground",children:e.toLocaleStr
7ing()})})]}),(0,t.jsx)("p",{className:"mt-4 text-[12px] font-medium text-foreground",children:"Points on this order."})]})]})]})})})}var z=e.i(433382),W=e.i(174886),G=e.i(269638),F=e.i(373884),$=e.i(63209);let V=({session:e,onVerifyPayment:n})=>{let a=(0,j.useRouter)(),[s,i]=(0,N.useState)(!1),o=async()=>{i(!0);try{await n()}finally{i(!1)}},l="received"===e.payment_status||"success"===e.status,c="rejected"===e.payment_status,d="expired"===e.session_status,u="received_after_expiry"===e.payment_status;return l?(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center p-8 space-y-4 text-center",children:[(0,t.jsx)("div",{className:"rounded-full bg-success-soft p-3 text-success",children:(0,t.jsx)(G.CheckCircle,{className:"h-12 w-12"})}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("h3",{className:"text-xl font-bold text-success",children:"Payment Successful!"}),(0,t.jsxs)("p",{className:"text-muted-foreground",children:["Amount: ",(0,x.formatMoney)((e.amount||0)/100)]}),e.reference&&(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Ref: ",e.reference]})]}),(0,t.jsx)(r.Button,{onClick:()=>a.push("/profile/orders"),variant:"success",className:"w-full mt-4",children:"View Orders"})]}):c?(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center p-8 space-y-4 text-center",children:[(0,t.jsx)("div",{className:"rounded-full bg-danger-soft p-3 text-danger",children:(0,t.jsx)($.AlertCircle,{className:"h-12 w-12"})}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("h3",{className:"text-xl font-bold text-danger",children:"Payment Rejected"}),(0,t.jsx)("p",{className:"font-medium",children:"Wrong Amount Received"}),e.paid_amount&&(0,t.jsxs)("p",{className:"text-sm text-muted-foreground",children:["You paid: ",(0,x.formatMoney)(e.paid_amount/100)]}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground mt-2 px-4",children:e.rejection_reason||"Reversal has been processed."})]}),(0,t.jsx)(r.Button,{onClick:o,variant:"outline",className:"w-full mt-4",disabled:s,children:s?(0,t.jsx)(b.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}):"Refresh Status"})]}):d||u?(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center p-8 space-y-4 text-center",children:[(0,t.jsx)("div",{className:"rounded-full bg-warning-soft p-3 text-warning",children:(0,t.jsx)(F.XCircle,{className:"h-12 w-12"})}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("h3",{className:"text-xl font-bold text-warning",children:"Session Expired"}),u?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"font-medium",children:"Payment received after expiry."}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Reversal processed."})]}):(0,t.jsx)("p",{className:"text-muted-foreground",children:"No payment received in time."})]}),(0,t.jsx)(r.Button,{onClick:()=>a.push("/checkout"),variant:"outline",className:"w-full mt-4",children:"Try Again"})]}):(0,t.jsxs)("div",{className:"container mx-auto p-4 max-w-md",children:[(0,t.jsxs)("div",{className:"text-center mb-6 space-y-2",children:[(0,t.jsx)("h3",{className:"font-semibold text-md text-foreground/90",children:"Transfer the amount to the bank account below"}),(0,t.jsxs)("div",{className:"flex items-center justify-center gap-2 text-3xl font-bold text-success",children:[(0,t.jsx)("span",{children:"ð¸"}),(0,t.jsx)("span",{children:(0,x.formatMoney)((e.amount||0)/100)})]})]}),(0,t.jsxs)("div",{className:"bg-success-soft/50 border border-success rounded-xl p-4 space-y-4 shadow-sm",children:[(0,t.jsx)(q,{label:"Account Name",value:e.account_name}),(0,t.jsx)(q,{label:"Account Number",value:e.account_number,large:!0}),(0,t.jsx)(q,{label:"Bank",value:e.bank})]}),(0,t.jsxs)("div",{className:"mt-8 mb-6 text-center space-y-4",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Your session will close if the timer ends."}),(0,t.jsx)(K,{expiresAt:e.expires??e.expiresAt})]}),(0,t.jsxs)("div",{className:"text-center mb-4",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:"Click after completing the bank transfer."}),(0,t.jsx)(r.Button,{className:"w-full text-lg py-6 rounded-full font-bold shadow-lg",variant:"success",onClick:o,disabled:s,children:s?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(b.Loader2,{className:"mr-2 h-5 w-5 animate-spin"}),"Checking..."]}):"Check Status"})]}),(0,t.jsx)("p",{className:"text-xs text-center text-warning mt-4 px-8",children:"Do not close this page until your payment is completed."})]})};function q({label:e,value:r,large:n}){return(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground
7/80 text-sm",children:[(0,t.jsx)(y.Landmark,{className:"w-3 h-3"}),(0,t.jsx)("span",{children:e})]}),(0,t.jsx)("div",{className:"relative group",children:(0,t.jsxs)("div",{onClick:()=>{r&&(navigator.clipboard.writeText(r),k.toast.success("Copied to clipboard"))},className:(0,x.cn)("w-full bg-card border border-success-soft-border rounded-lg px-4 py-3 flex items-center justify-between cursor-pointer hover:border-success-soft-border transition-colors shadow-sm",n?"text-xl font-bold tracking-wide":"text-base font-semibold"),children:[(0,t.jsx)("span",{className:"truncate pr-8 text-foreground/90",children:r||"N/A"}),(0,t.jsx)(W.Copy,{className:"h-4 w-4 text-muted-foreground/50 group-hover:text-foreground transition-colors absolute right-4"})]})})]})}function K({expiresAt:e}){let[r,n]=(0,N.useState)("--:--"),[a,s]=(0,N.useState)(100);return(0,N.useEffect)(()=>{if(!e)return;let t=setInterval(()=>{let r=new Date().getTime(),a=new Date(e).getTime()-r;if(a<0){clearInterval(t),n("EXPIRED"),s(0);return}let i=Math.floor(a%36e5/6e4),o=Math.floor(a%6e4/1e3);n(`${i}:${o<10?"0"+o:o}`)},1e3);return()=>clearInterval(t)},[e]),(0,t.jsxs)("div",{className:"relative w-32 h-32 mx-auto flex items-center justify-center",children:[(0,t.jsx)("div",{className:"absolute inset-0 rounded-full border-4 border-muted/20"}),(0,t.jsxs)("div",{className:"absolute inset-0 flex items-center justify-center flex-col",children:[(0,t.jsx)("span",{className:"text-2xl font-bold font-mono text-foreground",children:r}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground uppercase",children:"Min Sec"})]})]})}var Q=e.i(533187),Y=e.i(593761),H=e.i(345367),X=e.i(272224),J=e.i(988635),Z=e.i(814710),ee=e.i(318031),et=e.i(57403);function er(){let I=(0,j.usePathname)(),{isCheckoutDrawerOpen:E,setCheckoutDrawerOpen:_,isPaymentDrawerOpen:M,setPaymentDrawerOpen:O,paymentDrawerStep:T,setPaymentDrawerStep:B,paymentStatus:R,setPaymentStatus:W,paymentSession:G,setPaymentSession:F,selectedGateway:$,setSelectedGateway:q,paymentMethod:K,setPaymentMethod:er,deliveryAddressId:es,billingAddressId:ei,deliveryMethod:eo,shippingCharges:el,setShippingCharges:ec,deliveryInstructions:ed,specialDeliveryInstruction:eu,orderSnapshot:em,setOrderSnapshot:ep,successOrderId:ef,setSuccessOrderId:eh,appliedCouponResult:ex,autoAppliedCoupons:eg,resetCoupons:ey,outOfStockItems:eb,setOutOfStockItems:ev,cartWeightInGrams:ew,distanceFromWarehouseInKm:ej}=(0,A.useCheckoutStore)(),eN=(0,A.useCheckoutStore)(e=>e.walletAmountToUse),ek=(0,A.useCheckoutStore)(e=>e.setWalletAmountToUse),eC=(0,A.useCheckoutStore)(e=>e.pointsToUse),eS=(0,A.useCheckoutStore)(e=>e.setPointsToUse),eP=I?.startsWith("/checkout")||E,eA=N.useMemo(()=>new Set(eb.map(e=>e.variantId).filter(e=>!!e)),[eb]),eI=N.useMemo(()=>new Set(eb.map(e=>e.sku)),[eb]),[eE,e_]=N.useState(!1),[eM,eO]=N.useState(null),eT=N.useRef(null),eL=N.useRef(null),[eB,eD]=N.useState(!1),{data:eR}=(0,p.useProfileQuery)();N.useEffect(()=>{e_(!0)},[]);let{cart:eU,cartTotal:ez,cartItems:eW,refreshCart:eG,clearLocalCart:eF,isLoading:e$,isFetching:eV}=(0,o.useCartLogic)(),eq=N.useMemo(()=>eW.filter(e=>!(e.variantId&&eA.has(e.variantId))&&!eI.has(e.sku)),[eW,eA,eI]),eK=N.useMemo(()=>(0,x.computeItemsSubtotal)(eq).subtotal,[eq]),{checkoutEffectiveTotal:eQ,comboDiscountTotal:eY}=N.useMemo(()=>{let e=new Map;for(let t of eU?.bundleGroups??[])e.set(t.id,t.appliedOffer??null);let t=eq.filter(e=>!e.bundleId),r=eq.filter(e=>e.bundleId),n=(0,x.computeItemsSubtotal)(t),a=new Map;for(let e of r){let t=e.bundleId,r=a.get(t)??[];r.push(e),a.set(t,r)}let s=0,i=0;for(let[t,r]of a){let n=r.map(e=>({...e,metadata:e.metadata?{...e.metadata,discount:void 0}:e.metadata})),{subtotal:a}=(0,x.computeItemsSubtotal)(n);s+=a;let o=e.get(t),l=a;o&&("number"==typeof o.finalValue&&"number"==typeof o.comboTotal&&1>Math.abs(o.comboTotal-a)?l=o.finalValue:"number"==typeof o.discountAmount?l=Math.max(0,a-o.discountAmount):"percentage"===o.discountType&&"number"==typeof o.discountValue&&(l=a*(1-o.discountValue/100))),i+=l}return{checkoutEffectiveTotal:n.subtotal+i,comboDiscountTotal:Math.max(0,s-i)}},[eU?.bundleGroups,eq]),eH=N.useMemo(()=>{let e=new Map;
7if((eU?.estimatedTotals?.coupons??[]).forEach(t=>{t.code&&e.set(t.code.toUpperCase(),(t.discount||0)+(t.shippingDiscount||0))}),ex?.couponDetails?.code){let t=ex.couponDetails.code.toUpperCase();e.has(t)||e.set(t,(ex.discount||0)+(ex.shippingDiscount||0))}(eg??[]).forEach(t=>{if(!t.code)return;let r=t.code.toUpperCase();e.has(r)||e.set(r,(t.result?.discount||0)+(t.result?.shippingDiscount||0))});let t=0;e.forEach(e=>{t+=e});let r="pickup"===eo?0:Math.min(el,Number(eU?.estimatedTotals?.headline?.memberShippingWaiver??0));return Math.max(0,eQ+el-t-r)},[eQ,el,eo,ex,eg,eU?.estimatedTotals]),{user:eX,isAuthenticated:eJ,isCorporate:eZ}=(0,c.useSession)(),e0=(0,u.useCheckoutAuthGate)(),{mutateAsync:e1}=(0,l.useMergeCartMutation)(),{mutateAsync:e2}=(0,a.useCreateAddressMutation)(),e4=(0,A.useCheckoutStore)(e=>e.guestDetails),e6=(0,A.useCheckoutStore)(e=>e.setDeliveryAddress),[e5,e8]=N.useState(!1),[e3,e7]=N.useState(!1),e9=N.useRef(!1),{track:te,identity:tt,matching:tr,tenant:tn}=(0,X.useAnalytics)(),ta=N.useRef(null),ts=N.useRef(!1);N.useEffect(()=>{eZ&&(ts.current=!0)},[eZ]);let ti=eZ||ts.current,to=(0,j.useRouter)(),tl=(0,j.useSearchParams)(),tc=tl.get("reference");N.useEffect(()=>{"verifying"!==R||tc||W("idle")},[]),N.useEffect(()=>{if(!E||I?.startsWith("/checkout")||0===eq.length||tt.logged_in&&!tr.external_id)return;let e=eU?.currency??"NGN",t=eq.map(t=>(0,Q.cartLineToProductLine)(t,e));(0,L.fireBeginCheckoutOnce)((0,Q.beginCheckoutFingerprint)(t,e),()=>{te({event:"begin_checkout",ecommerce:{currency:e,value:(0,Q.lineValue)(t),items:(0,Q.toGa4Items)(t)}})})},[E,I,eq,eU?.currency,tt.logged_in,tr.external_id,te]);let td=N.useRef(null);N.useEffect(()=>{if(!E||0===eq.length)return;let e="pickup"===eo?"pickup":es?"home_delivery":"";if(!e||td.current===e)return;td.current=e;let t=eU?.currency??"NGN";te({event:"add_shipping_info",ecommerce:{currency:t,value:eH,shipping_tier:e,items:(0,Q.toGa4Items)(eq.map(e=>(0,Q.cartLineToProductLine)(e,t)))}})},[E,eo,es,te]),N.useEffect(()=>{E||(td.current=null)},[E]),N.useEffect(()=>{0===eW.length&&el>0&&ec(0)},[eW.length,el,ec]);let{data:tu}=(0,a.useAddressesQuery)({enabled:!!eP}),{data:tm=[]}=(0,s.useCorporateAddressesQuery)(!!eP&&"pickup"===eo),[tp,tf]=N.useState(null),[th,tx]=N.useState(null),[tg,ty]=N.useState(!1),{data:tb}=(0,h.usePointsConfigQuery)(),tv=tb?parseFloat(tb.burnRatePerPoint.toString()):1,{data:tw}=(0,f.useWalletQuery)(eP&&ee.env.NEXT_PUBLIC_ENABLE_WALLET),{data:tj}=(0,h.usePointsQuery)(eP),tN=ee.env.NEXT_PUBLIC_ENABLE_WALLET&&tw?.wallet?.balance?parseFloat(tw.wallet.balance):0,tk=tj?.account?.pointsBalance??tj?.pointsBalance??0,tC=Math.min(Math.max(0,Number.isFinite(eN)?eN:0),Math.max(0,tN),eH),tS=Math.max(0,eH-tC),tP=tv>0?Math.floor(tS/tv):tS,tA=Math.min(Math.max(0,Math.floor(Number.isFinite(eC)?eC:0)),Math.max(0,tk),Math.max(0,tP)),tI=(0,Z.pointsToNgn)(tA,tv),tE=Math.max(0,eH-tC-tI),t_=!!eU?.estimatedTotals,tM=e$||eV||!t_;N.useEffect(()=>{I?.startsWith("/checkout")||eN!==tC&&ek(tC)},[eN,tC,ek,I]),N.useEffect(()=>{I?.startsWith("/checkout")||eC!==tA&&eS(tA)},[eC,tA,eS,I]);let tO="https://sdk.monnify.com/plugin/monnify.js";N.useEffect(()=>{if(!ee.env.NEXT_PUBLIC_ENABLE_MONNIFY||"monnify"!==$||"u"<typeof document)return;if(document.querySelector(`script[src="${tO}"]`))return void console.log("[Monnify] Script already in DOM, skipping inject");console.log("[Monnify] Injecting script",tO);let e=document.createElement("script");e.src=tO,e.async=!0,e.onload=()=>console.log("[Monnify] Script onload fired"),e.onerror=e=>console.error("[Monnify] Script onerror",e),document.head.appendChild(e)},[$]);let tT=I?.startsWith("/membership/")??!1;N.useEffect(()=>{if(tT)return;let{orderSnapshot:e,successOrderId:t,successAt:r,clearSuccessState:n}=A.useCheckoutStore.getState();if(!t)return;let a=!!e?.expiresAt&&Date.now()>e.expiresAt,s=!r||Date.now()-r>A.CHECKOUT_SUCCESS_TTL_MS;!e||a||s?n():(tf({orderId:t,omsPayload:null}),W("success"),O(!0))},[]);let tL=tl.get("sessionId"),tB=tl.get("provider"),tD=N.useCallback(async(e,t)=>{O(!0),W("verifying");try{let r=await fetch("/api/payments/verify-reference",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reference:e,...t?.provider&&{provider:t.provider},...t?.sessionId&&{sessionId:t.sessionId}})}),n=await r.json(),a=n.data?.order;if(a?.channel==="membership"||a?.metadata?.purchaseType==="membership"){O(!1),W("idle");return}if(r.ok&&n.data?.status==="payment_completed"){let e=n.data?.order?.metadata,t=e?.oms_payload??e?.omsPayload,r=t?.order_id||e?.orderId||n.data?.metadata?.orderId||n.data?.order?.id;r&&(tf({orderId:r,omsPayload:null}),eh(r));let a=(0,J.coerceMoney)(t?.pricing?.grand_total),s="string"==typeof t?.pricing?.currency?t.pricing.currency:void 0;if(null!=a&&a>0){let e=(0,J.roundMetaValue)(a),t=(s??eU?.currency??"NGN").trim().toUpperCase();
7(0,L.patchPurchaseCapturePricing)(e,t),ta.current&&(ta.current={...ta.current,value:e,currency:t})}W("success"),eO(null),k.toast.success("Payment Successful!");let i=new URLSearchParams(tl.toString());i.delete("reference"),i.delete("sessionId"),i.delete("provider"),to.replace(`${window.location.pathname}?${i.toString()}`),await eF(),ey(),eG&&eG()}else W("failed"),te({event:"payment_failed",reason:"verification_failed",amount:ez,currency:eU?.currency??"NGN",payment_gateway:t?.provider??"unknown"}),k.toast.error("Payment verification failed")}catch(e){console.error(e),W("failed"),te({event:"payment_failed",reason:"verification_error",amount:ez,currency:eU?.currency??"NGN"}),k.toast.error("Error verifying payment")}},[tl,to,eG,eF,eh,ey,O,W,eX?.id,te]),tR=N.useCallback(async e=>{if(e)try{await fetch(`/api/payments/abandon/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:"user_cancelled_payment",at:new Date().toISOString()})})}catch(e){console.error("Failed to mark checkout as abandoned",e)}},[]),tU=N.useCallback(e=>{if(!e||eT.current===e)return;eT.current=e;let t=`/api/payments/abandon/${e}`;try{if("u">typeof navigator&&navigator.sendBeacon){let e=new Blob([JSON.stringify({reason:"page_exit_or_refresh",at:new Date().toISOString()})],{type:"application/json"});navigator.sendBeacon(t,e);return}}catch{}fetch(t,{method:"POST",keepalive:!0,headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:"page_exit_or_refresh",at:new Date().toISOString()})})},[]);N.useEffect(()=>{if(!eM||["success","failed","cancelled","verifying"].includes(R))return;let e=()=>{tU(eM)};return window.addEventListener("beforeunload",e),()=>{window.removeEventListener("beforeunload",e)}},[eM,R,tU]),N.useEffect(()=>{if(!tc||tT)return;let e=`anl_verify_reference_${tc}`;"1"!==sessionStorage.getItem(e)&&(sessionStorage.setItem(e,"1"),tD(tc,{...tL&&{sessionId:tL},...tB&&{provider:tB}}))},[tc,tL,tB,tD,tT]);let tz=async(t,r)=>{if(eO(r??null),"paystack"===t.provider)t.providerResponse.access_code?new(await e.A(417986)).default().resumeTransaction(t.providerResponse.access_code,{onSuccess:async e=>{let r="object"==typeof e&&null!==e&&"reference"in e&&"string"==typeof e.reference?e.reference:t.paymentSession;eO(null),W("verifying"),window.location.href=`/checkout?reference=${r}`},onCancel:()=>{tR(r),eO(null),W("cancelled")},onError:e=>{console.error("Paystack Error:",e),W("verifying"),tD(t.paymentSession)}}):t.url&&(eO(null),W("verifying"),window.location.href=t.url);else if("monnify"===t.provider){console.log("[Monnify] Payment success branch: provider=monnify");let e=t.providerResponse,n=(t.cent??0)/100,a=(eR?.name??eX?.name??"").trim(),s=(eX?.email??"").trim(),i=window.location.origin,o=i.startsWith("https://")?`${i}/checkout`:void 0;console.log("[Monnify] Config",{amountNaira:n,reference:e.reference,redirectUrl:o,customerEmail:s?s.slice(0,3)+"ââ¬Â¦":"(empty)",hasApiKey:!!e.apiKey,hasContractCode:!!e.contractCode});let l={amount:n,currency:"NGN",reference:e.reference,customerFullName:a,customerEmail:s,apiKey:e.apiKey,contractCode:e.contractCode,paymentMethods:["ACCOUNT_TRANSFER"],paymentDescription:"Order payment",...o&&{redirectUrl:o},metadata:{checkoutSessionId:r,name:a},onLoadStart:()=>{},onLoadComplete:()=>{},onComplete:t=>{let n=t.transactionReference??t.paymentReference??e.reference;eO(null),W("verifying"),window.location.href=`/checkout?reference=${encodeURIComponent(n)}&sessionId=${encodeURIComponent(r)}&provider=monnify`},onClose:e=>{e?.paymentStatus==="USER_CANCELLED"?(tR(r),eO(null),W("cancelled")):W("idle")}},c=()=>{let e=window,t=e&&e.MonnifySDK,r=t?.initialize??t?.initializePayment;if(!t)return!1;if(!r)return console.warn("[Monnify] window.MonnifySDK exists but no initialize or initializePayment",Object.keys(t)),!1;let n=t.initialize?"initialize":"initializePayment";return console.log("[Monnify] SDK ready, method=",n),requestAnimationFrame(()=>{try{console.log("[Monnify] Calling",n,"with config"),r.call(t,l),console.log("[Monnify] Init call completed (no throw)")}catch(e){console.error("[Monnify] Init threw",e)}}),!0},d="u">typeof document&&document.querySelector(`script[src="${tO}"]`);
7if(console.log("[Monnify] Script in DOM?",!!d,"window.MonnifySDK?",typeof window.MonnifySDK),"u">typeof document&&!d){console.log("[Monnify] Injecting script (fallback)");let e=document.createElement("script");e.src=tO,e.async=!0,document.head.appendChild(e)}if(c())return void console.log("[Monnify] Init succeeded on first try");let u=0;console.log("[Monnify] Polling for window.MonnifySDK, maxAttempts=",50);let m=setInterval(()=>{if((1===(u+=1)||u%10==0||u>=50)&&console.log("[Monnify] Poll attempt",u,"MonnifySDK?",typeof window.MonnifySDK),c()){clearInterval(m),console.log("[Monnify] Init succeeded on attempt",u);return}u>=50&&(clearInterval(m),console.error("[Monnify] Gave up after",50,"attempts. window.MonnifySDK =",window.MonnifySDK),k.toast.error("Payment could not load. Please refresh and try again."))},200)}else"internal"===t.provider?(eO(null),t.orderId&&eh(t.orderId),W("success"),ty(!0),setTimeout(()=>{ty(!1),W("success"),ey(),eF()},3500)):"traction"===t.provider||"omnipay"===t.provider?(F(t.providerResponse),B("summary"),O(!0)):"cod"===t.method&&(eO(null),t.orderId&&eh(t.orderId),W("success"),ey(),eF())},{mutate:tW,isPending:tG}=(0,g.useMutation)({mutationFn:e=>P.checkoutApi.checkout(e),onSuccess:async e=>{eL.current=null,await tz(e.payment,e.checkoutSessionId)},onError:e=>{if(eL.current=null,console.error(e),e instanceof S.ApiError&&409===e.status&&e.data&&"object"==typeof e.data&&"outOfStockItems"in e.data&&Array.isArray(e.data.outOfStockItems)){ev((e.data.outOfStockItems||[]).map(e=>({variantId:e.variantId,sku:e.sku,productName:e.productName||e.sku,requested:e.requested,available:e.available}))),O(!1),_(!1),te({event:"payment_failed",reason:"out_of_stock",amount:ez,currency:eU?.currency??"NGN"}),k.toast.error("Some items are out of stock");return}let t=e instanceof S.ApiError&&e.data&&"object"==typeof e.data&&"detail"in e.data?String(e.data.detail):e instanceof S.ApiError&&e.data&&"object"==typeof e.data&&"error"in e.data?String(e.data.error):e instanceof Error?e.message:"Checkout failed. Please try again.";te({event:"payment_failed",reason:"checkout_mutation_error",amount:ez,currency:eU?.currency??"NGN"}),k.toast.error(t)}}),tF=async()=>{if(!eB&&!tG){eD(!0);try{if((0,x.vibrate)("success"),0===eq.length)return void k.toast.error("Your cart is empty");if(eb.length>0&&k.toast.info("Some items are out of stock and will not be included in this order."),"pickup"===eo){if(!es){k.toast.error("Please select a pickup store"),(0,C.scrollAndHighlight)("address");return}}else{if(!es){k.toast.error("Please select a delivery address"),(0,C.scrollAndHighlight)("address");return}let e=tu?.find(e=>e.id===es);if(!e){k.toast.error("Invalid shipping address"),(0,C.scrollAndHighlight)("address");return}if(e.country&&"nigeria"!==e.country.toLowerCase())return void k.toast.error("Sorry, we only deliver within Nigeria. Please select a Nigerian address.")}if(!eX?.email&&!eX?.mobilephone)return void k.toast.error("Please sign in to complete your order");if("pickup"===eo&&!(0,i.corporateVerifiedNumber)(eR))return void k.toast.error("Please verify your mobile number for pickup");let e=(0,et.expandStockCheckSkus)(eq);if(e.length>0)try{await P.checkoutApi.checkStock({skus:e})}catch(t){let e=t instanceof S.ApiError&&t.data&&"object"==typeof t.data&&"outOfStockItems"in t.data&&Array.isArray(t.data.outOfStockItems)?t.data.outOfStockItems:[];e.length>0?(ev(e.map(e=>({variantId:e.variantId,sku:e.sku,productName:e.productName||e.sku,requested:e.requested,available:e.available}))),k.toast.error("Some items are out of stock. Please update your cart before paying.")):k.toast.error("Unable to validate stock right now. Please try again.");return}B("payment-selection"),O(!0)}finally{eD(!1)}}},t$=e4.addressLine1.trim().length>0&&e4.city.trim().length>0&&e4.state.trim().length>0&&"nigeria"===e4.country.trim().toLowerCase()&&null!=e4.latitude&&null!=e4.longitude,tV=async()=>{if(!t$)return!1;try{let e=await e2({fullName:e4.fullName,email:e4.email,phone:e4.phone,addressLine1:e4.addressLine1,addressLine2:e4.addressLine2||void 0,city:e4.city,state:e4.state,postalCode:e4.postalCode||"000000",country:"Nigeria",latitude:e4.latitude??void 0,longitude:e4.longitude??void 0,isDefault:!1});return e6(e.id),e9.current=!1,k.toast.success("Address saved to your account"),!0}catch(e){return e9.current=!0,k.toast.error(e instanceof Error?`Could not save address â ${e.message}`:"Could not save address. Tap address to retry."),!1}},tq=async e=>
7{e7(!1),(0,m.clearGuestAuthPopupState)(),e.address?.id&&(e6(e.address.id),e9.current=!1);try{await e1()}catch(e){console.error("Cart merge failed",e)}(e.address?.id||await tV())&&await tF()},tK=async()=>{if(eB||tG)return;eD(!0);let e=(0,H.hasTrackingConsent)();{let e=eU?.currency??"NGN",t={identity:tt,matching:tr??{},tenant:tn,items:(0,Q.toGa4Items)(eW.map(t=>(0,Q.cartLineToProductLine)(t,e))),value:tE,currency:e};ta.current=t,(0,L.storePurchaseCapture)(t)}try{if((0,x.vibrate)("success"),tE>0&&!$){k.toast.error("Please select a payment gateway"),(0,C.scrollAndHighlight)("payment-gateway");return}let t=tE>0?$??"paystack":"paystack";if(!eJ)return void e0();let r=tu?.find(e=>e.id===es),n="pickup"===eo&&es?tm.find(e=>e.id===es):void 0,a=n?{id:n.id,fullName:eX?.name||"",addressLine1:n.addressLine1,addressLine2:n.addressLine2||void 0,city:n.city,state:n.state,postalCode:n.postalCode,country:n.country,phone:n.phone,isDefault:!1,addressCode:void 0,email:eX?.email||""}:void 0,s="pickup"===eo?a:r;if(!s)return void k.toast.error("Unable to find your shipping address. Please select one again.");if(s.country?.toLowerCase()!=="nigeria")return void k.toast.error("Sorry, we only deliver within Nigeria. Please select a Nigerian address.");let o=ei?tu?.find(e=>e.id===ei):s,l=(s.fullName||eX?.name||"").trim(),c=(s.email||eX?.email||"").trim(),d=("pickup"===eo?(0,i.corporateVerifiedNumber)(eR):null)??(s.phone||eX?.mobilephone||""),u=(0,et.expandStockCheckSkus)(eq);if(u.length>0)try{await P.checkoutApi.checkStock({skus:u})}catch(t){let e=t instanceof S.ApiError&&t.data&&"object"==typeof t.data&&"outOfStockItems"in t.data&&Array.isArray(t.data.outOfStockItems)?t.data.outOfStockItems:[];e.length>0?(ev(e.map(e=>({variantId:e.variantId,sku:e.sku,productName:e.productName||e.sku,requested:e.requested,available:e.available}))),k.toast.error("Some items are out of stock. Please update your cart before paying.")):k.toast.error("Unable to validate stock right now. Please try again.");return}let m=(0,et.expandReservationItems)(eq.filter(e=>!!e.variantId)),p=m.length>0?crypto.randomUUID():void 0;if(m.length>0&&p)try{await P.checkoutApi.reserveStocks(m,p),eL.current={items:m,reservationId:p}}catch(e){console.error("Failed to reserve stock before checkout",e),k.toast.error("Unable to reserve stock right now. Please try again.");return}let f=Math.max(0,eK+el-eH);ep({items:eq,subtotal:eK,discount:f,shipping:el,total:tE,paymentAdjustments:[...tC>0?[{label:"Wallet",amount:tC}]:[],...tI>0?[{label:"Points",amount:tI}]:[]],expiresAt:Date.now()+18e5});{let e=eU?.currency??"NGN";te({event:"add_payment_info",ecommerce:{currency:e,value:tE,payment_type:tE>0?t:"internal",items:(0,Q.toGa4Items)(eq.map(t=>(0,Q.cartLineToProductLine)(t,e)))}})}let h=await (0,Y.collectTracking)(),g={type:"pickup"===eo?"pick-up":"delivery",reservationId:p,shippingAddress:{...es&&{id:es},fullName:l,line1:s.addressLine1,line2:s.addressLine2||void 0,city:s.city,state:s.state||"",postalCode:s.postalCode,country:s.country,phone:d,email:c,addressCode:s.addressCode??null},billingAddress:o?{fullName:l,line1:o.addressLine1,line2:o.addressLine2||void 0,city:o.city,state:o.state||"",postalCode:o.postalCode,country:o.country,phone:d,email:c,addressCode:o.addressCode??null}:void 0,pickupStoreAddress:n?{fullName:l,line1:n.addressLine1,line2:n.addressLine2||void 0,city:n.city,state:n.state||"",postalCode:n.postalCode,country:n.country,phone:d,email:c,addressCode:null}:void 0,useShippingAsBilling:!ei||ei===es,paymentMethod:"online",paymentGateway:t,walletAmount:tC,pointsToUse:tA,selectedStoreId:"pickup"===eo&&es?es:void 0,contact:{name:l,phone:d,email:c},tracking:{utmParams:{utm_source:h.utm?.source,utm_medium:h.utm?.medium,utm_campaign:h.utm?.campaign,utm_term:h.utm?.term,utm_content:h.utm?.content,mid:h.utm?.mid},gaClientId:h.gaClientId??null,gaSessionId:h.gaSessionId??null,fbp:h.fbp??null,fbc:h.fbc??null,pageUrl:h.pageUrl??null,userAgent:h.userAgent??null,referrer:h.referrer??null,language:h.language??null,screen:h.screen??null,userId:eX?.id??null,consent:{analytics:e,ad:e,adUserData:e,adPersonalization:e},clickIds:{gclid:h.clickIds?.gclid??null,wbraid:h.clickIds?.wbraid??null,gbraid:h.clickIds?.gbraid??null,fbclid:h.clickIds?.fbclid??null,ttclid:h.clickIds?.ttclid??null,msclkid:h.clickIds?.msclkid??null,twclid:h.clickIds?.twclid??null,liFatId:h.clickIds?.li_fat_id??null},cartWeightInGrams:ew||0,distanceFromWarehouseInKm:ej||0},deliveryInstructions:ed||null,specialDeliveryInstruction:eu||null};tW(g)}finally{eD(!1)}},tQ=ef||tp?.orderId||"";N.useEffect(()=>{if(!ee.env.NEXT_PUBLIC_ENABLE_POINTS||ti||"success"!==R||!tQ)return;let e=!1;return(async()=>{for(let t of[0,800,1600,2400]){if(e)return;t>0&&await new Promise(e=>setTimeout(e,t));try{let t=await z.pointsApi.getEarnedForOrder(tQ);if(!e&&t?.pointsAwarded&&t.pointsAwarded>0)return void tx({pointsAwarded:t.pointsAwarded,tier:t.tier||"none"})}catch{}}})(),()=>{e=!0}},[R,tQ,ti]);let tY=()=>{ta.current=null;let e=eU?.metadata??null,t=(()=>
7{if(e?.sourceBrandSlug!=="shopify")return null;let t=e?.returnUrl;if("string"!=typeof t||0===t.length)return null;try{let e=new URL(t);if("http:"!==e.protocol&&"https:"!==e.protocol)return null;return e.toString()}catch{return null}})();if(W("idle"),O(!1),ep(null),eh(null),tx(null),window.ReactNativeWebView)return void window.ReactNativeWebView.postMessage(JSON.stringify({type:"CHECKOUT_SUCCESS"}));if(t){window.location.href=t;return}to.replace("/")},tH="success"===R;return(0,t.jsxs)(n.Drawer,{open:M||tH,onOpenChange:e=>{tH||O(e)},children:[(0,t.jsx)(n.DrawerContent,{className:(0,x.cn)("md:mx-auto md:max-w-[500px]",tH&&"h-[95dvh]"),children:(0,t.jsxs)("div",{className:"flex h-full flex-col overflow-hidden",children:[!tH&&(0,t.jsx)("div",{className:"shrink-0 border-b bg-card p-4",children:(0,t.jsxs)(n.DrawerTitle,{className:"flex items-center gap-2",children:[("payment-selection"!==T||null!==G||"failed"===R||"cancelled"===R)&&(0,t.jsx)(r.Button,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full p-0 text-muted-foreground hover:bg-surface-subtle shrink-0",onClick:()=>{G?(F(null),W("idle")):("failed"===R||"cancelled"===R)&&W("idle"),B("payment-selection")},children:(0,t.jsx)(v.ArrowLeft,{className:"h-5 w-5"})}),(0,t.jsx)(y.Landmark,{className:"text-primary h-5 w-5 shrink-0"}),(0,t.jsx)("span",{className:"text-lg font-bold",children:G?"Payment Instructions":"payment-selection"===T?"Payment Method":"Payment Details"})]})}),(0,t.jsx)("div",{className:"min-h-0 flex-1",children:(()=>{if(tg)return(0,t.jsxs)("div",{className:"flex h-[400px] flex-col items-center justify-center space-y-3 md:space-y-6 p-8",children:[(0,t.jsxs)("div",{className:"bg-primary/10 relative flex h-20 w-20 items-center justify-center rounded-full",children:[(0,t.jsx)("div",{className:"bg-primary/20 absolute inset-0 animate-ping rounded-full"}),(0,t.jsx)(y.Landmark,{className:"text-primary h-10 w-10 animate-pulse"})]}),(0,t.jsxs)("div",{className:"space-y-2 text-center",children:[(0,t.jsx)("h3",{className:"animate-pulse text-xl font-bold",children:"Confirming Payment Mix..."}),(0,t.jsx)("p",{className:"text-muted-foreground",children:"Applying your wallet, points, and payment confirmation securely."})]})]});if("success"===R)return(0,t.jsxs)("div",{className:"relative h-full overflow-y-auto",children:[(0,t.jsx)(D,{orderId:tQ,onClose:tY,orderItems:em?.items,subtotal:em?.subtotal,discount:em?.discount,shipping:em?.shipping,total:em?.total,paymentAdjustments:em?.paymentAdjustments,purchasePayload:ta.current}),ee.env.NEXT_PUBLIC_ENABLE_POINTS&&!ti&&th&&(0,t.jsx)(U,{pointsAwarded:th.pointsAwarded,tier:th.tier,onDismiss:()=>tx(null)})]});if("cancelled"===R)return(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center space-y-4 p-8 text-center",children:[(0,t.jsx)("div",{className:"rounded-full bg-warning-soft p-3 text-warning",children:(0,t.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,t.jsx)("path",{d:"m15 9-6 6"}),(0,t.jsx)("path",{d:"m9 9 6 6"})]})}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("h3",{className:"text-xl font-bold text-warning",children:"Payment Cancelled"}),(0,t.jsx)("p",{className:"text-muted-foreground",children:"You cancelled the transaction."})]}),(0,t.jsx)(r.Button,{onClick:()=>{eO(null),W("idle")},variant:"outline",className:"mt-4 w-full max-w-xs",children:"Try Again"})]});if("failed"===R)return(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center space-y-4 p-8 text-center",children:[(0,t.jsx)("div",{className:"rounded-full bg-danger-soft p-3 text-danger",children:(0,t.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,t.jsx)("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),(0,t.jsx)("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]})}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("h3",{className:"text-xl font-bold text-danger",children:"Payment Failed"}),(0,t.jsx)("p",{className:"text-muted-foreground",children:"Something went wrong with the payment."})]}),(0,t.jsx)(r.Button,{onClick:()=>{eO(null),W("idle")},variant:"destructive",className:"mt-4 w-full max-w-xs",children:"Try Again"})]});if("payment-selection"===T){let e;return(0,t.jsx)("div",{className:"bg-light-success md:bg-background flex h-full flex-col pt-2 md:pt-0",children:(0,t.jsxs)("div",{className:"mx-auto flex h-full w-full max-w-sm flex-col md:max-w-none",children:[(0,t.jsx)("div",{className:"flex-1 space-y-3 md:space-y-6 overflow-y-auto p-4",children:tM?(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center gap-3 rounded-2xl border border-border bg-surface-subtle p-8 text-center",children:[(0,t.jsx)(b.Loader2,{className:"text-primary h-6 w-6 animate-spin"}),(0,t.jsx)("p",{className:"text-sm font-medium text-muted-foreground",children:"Preparing your billâ¦"})]}):tE>0?(0,t.jsx)("div",{className:"space-y-4","data-scroll-target":"payment-gateway",children:(0,t.jsx)(t.Fragment,{children:0===(e=[{provider:"paystack",status:"active"},...ee.env.NEXT_PUBLIC_ENABLE_MONNIFY?[{provider:"monnify",status:"active"}]:[]].filter(e=>"active"===e.status)).length?(0,t.jsx)("p",{className:"text-muted-foreground text-center",children:"No payment methods available."}):e.map(e=>{let r="";switch(e?.provider?.toLowerCase()){case"paystack":r="/payment-gateways/paystack-logo.png";break;case"omnipay":r="/payment-gateways/omnipay-logo.png";break;case"monnify":r="/payment-gateways/moniepoint-logo.jpeg"}return(0,t.jsxs)("div",{className:(0,x.cn)("flex cursor-pointer items-center justify-between rounded-lg border border-transparent px-2 py-3 transition-all",$===e.provider?"bg-primary/5 border-primary/20":"hover:bg-muted/50"),onClick:()=>q(e.provider),children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[r?(0,t.jsx)("div",{className:"relative h-6 w-10 overflow-hidden rounded-sm bg-product-media/50",children:(0,t.jsx)(w.default,{src:r,alt:e.provider,f
7ill:!0,className:"object-contain"})}):(0,t.jsx)("div",{className:"bg-muted h-6 w-10 rounded-sm"}),(0,t.jsx)("span",{className:"text-base font-medium capitalize",children:"paystack"===e.provider?"Paystack":"omnipay"===e.provider?"Omnipay":"monnify"===e.provider?"Monnify":e.provider})]}),(0,t.jsx)(ea,{checked:$===e.provider})]},e.provider)})})}):(0,t.jsx)("div",{className:"rounded-2xl border border-success-soft-border bg-success-soft p-4 text-sm text-success",children:"Your wallet and points cover this order. No bank payment is needed."})}),(0,t.jsx)("div",{className:"flex justify-center p-4",children:(0,t.jsxs)(r.Button,{onClick:tK,disabled:tM||tE>0&&!$||tG||eB,variant:"success",className:"text-md min-w-[100px] rounded-full px-8! py-6! font-semibold shadow-lg",children:[(tM||tG||eB)&&(0,t.jsx)(b.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),tM?"Calculatingâ¦":`${tE>0?"Proceed to Pay":"Complete Order"} | ${(0,x.formatMoney)(tE)}`]})})]})})}return"verifying"===R?(0,t.jsxs)("div",{className:"flex h-[300px] flex-col items-center justify-center space-y-4 p-8 text-center",children:[(0,t.jsx)(b.Loader2,{className:"text-primary h-12 w-12 animate-spin"}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("h3",{className:"text-xl font-bold",children:"Verifying Payment"}),(0,t.jsx)("p",{className:"text-muted-foreground",children:"Please wait while we confirm your transaction..."})]})]}):G?(0,t.jsx)("div",{className:"max-h-[80vh] overflow-y-auto md:max-h-full",children:(0,t.jsx)(V,{session:G,onVerifyPayment:async()=>{try{W("verifying");let e=await P.checkoutApi.verifyPayment(G.payment_session);if(e.paid){let t=e.orderId??G.payment_session;F(null),ey(),eF(),eh(t),W("success")}else k.toast.error("Payment not received yet. Please try again."),W("idle")}catch(e){console.error(e),k.toast.error("Verification failed"),W("idle")}}})}):(0,t.jsx)(en,{method:K,total:tE,showAll:!0,onSubmit:tF,isPending:tG})})()})]})}),(0,t.jsx)(d.AddressPickerSheet,{open:e5,onOpenChange:e8,onSaved:()=>{eJ&&e9.current&&tV()}}),(0,t.jsx)(m.GuestAuthPopupSheet,{open:e3,onOpenChange:e7,onAuthenticated:tq})]})}function en({method:e,total:n,showAll:a,onSubmit:s,isPending:i}){return(0,t.jsx)("div",{className:"bg-light-success pt-2 pb-4",children:(0,t.jsx)("div",{className:"mx-auto w-full max-w-sm",children:(0,t.jsx)("div",{className:"flex justify-center p-4",children:(0,t.jsxs)(r.Button,{onClick:e=>{e.stopPropagation(),s&&s()},disabled:i||n<=0,variant:"success",className:"text-md min-w-[200px] rounded-full px-4! py-6! font-semibold",children:["Proceed to Pay amount | ",(0,x.formatMoney)(n)]})})})})}function ea({checked:e}){return(0,t.jsx)("div",{className:(0,x.cn)("flex h-5 w-5 items-center justify-center rounded-full border-2",e?"border-primary":"border-muted-foreground"),children:e&&(0,t.jsx)("div",{className:"bg-primary h-3 w-3 rounded-full"})})}e.s(["CheckoutDrawer",()=>er],181022)},770252,e=>{"use strict";var t=e.i(843476),r=e.i(326999),n=e.i(995926),a=e.i(647163);function s({...e}){return(0,t.jsx)(r.Root,{"data-slot":"sheet",...e})}function i({...e}){return(0,t.jsx)(r.Portal,{"data-slot":"sheet-portal",...e})}function o({className:e,...n}){return(0,t.jsx)(r.Overlay,{"data-slot":"sheet-overlay",className:(0,a.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...n})}function l({className:e,children:s,side:l="right",...c}){return(0,t.jsxs)(i,{children:[(0,t.jsx)(o,{}),(0,t.jsxs)(r.Content,{"data-slot":"sheet-content",className:(0,a.cn)("bg-overlay-surface data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500","right"===l&&"data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm","left"===l&&"data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm","top"===l&&"data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b","bottom"===l&&"data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",e),...c,children:[s,(0,t.jsxs)(r.Close,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none",children:[(0,t.jsx)(n.XIcon,{className:"size-4"}),(0,t.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function c({className:e,...r}){return(0,t.jsx)("div",{"data-slot":"sheet-header",className:(0,a.cn)("flex flex-col gap-1.5 p-4",e),...r})}function d({className:e,...n}){return(0,t.jsx)(r.Title,{"data-slot":"sheet-title",className:(0,a.cn)("text-foreground font-semibold",e),...n})}var u=e.i(518141),m=e.i(572041),p=e.i(871689),f=e.i(201928),h=e.i(167881),x=e.i(614062),g=e.i(30672);function y(){let{isCheckoutDrawerOpen:e,setCheckoutDrawerOpen:r}=(0,m.useCheckoutStore)(),{setOpen:n}=(0,g.useCartDrawer)(),a=(0,x.useIsMobileWebView)(),i=e=>{!e&&a&&window.ReactNativeWebView&&window.ReactNativeWebView.postMessage(JSON.stringify({type:"GO_BACK"})),r(e),e||n(!0)};return(0,t.jsx)(s,{open:e,onOpenChange:i,children:(0,t.jsxs)(l,{side:"right",className:"w-full h-full p-0 sm:max-w-md md:max-w-lg lg:max-w-xl border-l-0 flex flex-col h-full overflow-hidden",children:[(0,t.jsxs)(c,{className:"sticky top-0 z-50 flex flex-row items-center gap-2 border-b bg-card px-4 py-4 shrink-0",children:[(0,t.jsx)(h.Button,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full p-0 text-muted-foreground hover:bg-surface-subtle shrink-0",onClick:()=>i(!1),children:(0,t.jsx)(p.ArrowLeft,{className:"h-5 w-5"})}),(0,t.jsxs)(d,{className:"flex items-center gap-3 text-xl font-bold",children:[(0,t.jsx)(f.ShoppingCart,{className:"text-brand-accent h-7 w-7"}),(0,t.jsx)("div",{children:(0,t.jsx)("p",{className:"text-brand-accent text-sm font-semibold",children:"Checkout"})})]})]}),(0,t.jsx)(u.CheckoutView,{className:"flex-1 overflow-hidden"})]})})}e.s(["CheckoutPageDrawer",()=>y],770252)},979721,e=>{"use strict";
7var t=e.i(843476),r=e.i(271645),n=e.i(657688),a=e.i(174886),s=e.i(37727),i=e.i(618566),o=e.i(630374),l=e.i(263474);function c(){let e=(0,i.useSearchParams)(),c=e.get("coupon"),d=e.get("auto"),[u,m]=(0,r.useState)(!1),[p,f]=(0,r.useState)(!1),{data:h=[],isLoading:x}=(0,l.useCouponsQuery)(),{data:g=[],isLoading:y}=(0,l.useAutoApplyCouponsQuery)(),b=(0,r.useMemo)(()=>[...h,...g],[h,g]);(0,r.useEffect)(()=>{m(!1)},[c]);let v=(0,r.useMemo)(()=>c&&"true"===d&&0!==b.length?b.find(e=>e.code?.toLowerCase()===c.toLowerCase()):null,[c,d,b]),w=async()=>{v?.code&&(await navigator.clipboard.writeText(v.code),f(!0),setTimeout(()=>f(!1),2e3))},j=!!v&&!u&&!x&&!y;return j?(0,t.jsx)(o.Dialog,{open:j,onOpenChange:e=>!e&&m(!0),children:(0,t.jsx)(o.DialogContent,{className:"bg-transparent border-none p-0 shadow-none sm:max-w-none max-w-none w-fit outline-none",children:(0,t.jsxs)("div",{className:"ticket-cutout relative flex w-[85vw] max-w-[320px] flex-col items-center overflow-hidden rounded-2xl bg-gradient-to-b from-[#7C3AED] to-[#5B21B6] px-6 pt-10 pb-6 font-sans shadow-2xl",children:[(0,t.jsx)("div",{className:"absolute inset-0 opacity-20 pointer-events-none",style:{background:"repeating-conic-gradient(from 0deg, rgba(255,255,255,0.4) 0deg 15deg, transparent 15deg 30deg)"}}),(0,t.jsx)("button",{onClick:()=>m(!0),className:"absolute top-4 right-4 text-white/70 hover:text-white transition-colors z-20",children:(0,t.jsx)(s.X,{size:20})}),(0,t.jsx)("div",{className:"absolute -top-6 bg-card rounded-full p-4 shadow-lg border-4 border-primary",children:(0,t.jsx)("div",{className:"relative w-10 h-10",children:(0,t.jsx)(n.default,{src:"/logo-purple.svg",fill:!0,alt:"Logo",className:"object-contain"})})}),(0,t.jsxs)("div",{className:"relative z-10 text-center mt-4 mb-4",children:[(0,t.jsx)("h2",{className:"text-2xl font-black uppercase text-white tracking-tight leading-tight",children:v.name||"Special Benefit"}),(0,t.jsx)("div",{className:"h-1 w-12 bg-warning mx-auto mt-2 rounded-full"})]}),(0,t.jsx)("div",{className:"relative z-10 mb-6 w-full rounded-xl bg-white/10 border border-white/20 px-4 py-4 backdrop-blur-sm",children:(0,t.jsx)("p",{className:"text-sm font-medium text-white/90 text-center leading-relaxed",children:v.description||"Enjoy exclusive benefits on your purchase today!"})}),(0,t.jsx)("div",{className:"relative z-10 w-full mb-6",children:(0,t.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-[0.2em] text-white/60",children:"Copy Coupon Code"}),(0,t.jsxs)("div",{className:"flex w-full items-center justify-between rounded-xl border-2 border-dashed border-white/30 bg-white/5 py-3 px-4",children:[(0,t.jsx)("span",{className:"text-xl font-bold text-warning tracking-wider",children:v.code}),(0,t.jsx)("button",{onClick:w,className:"text-warning hover:scale-110 transition-transform",children:(0,t.jsx)(a.Copy,{size:20})})]}),p&&(0,t.jsx)("span",{className:"text-xs font-bold text-success animate-pulse mt-1",children:"Copied!"})]})}),(0,t.jsx)("button",{onClick:()=>m(!0),className:"relative z-10 w-full py-4 rounded-xl bg-warning hover:bg-warning text-primary font-extrabold text-lg shadow-xl transition-all active:scale-95 uppercase tracking-wide",children:"Shop Now"})]})})}):null}e.s(["PromotionPopup",()=>c])},392126,e=>{"use strict";var t=e.i(271645);let r={init(e){!function(e){try{var t,r,n,a,s;t=window,r=document,n="clarity",r.getElementById("clarity-script")||(t[n]=t[n]||function(){(t[n].q=t[n].q||[]).push(arguments)},(a=r.createElement("script")).async=1,a.src="https://www.clarity.ms/tag/"+e+"?ref=npm",a.id="clarity-script",(s=r.getElementsByTagName("script")[0]).parentNode.insertBefore(a,s))}catch(e){return}}(e,"clarity-script")},setTag(e,t){window.clarity("set",e,t)},identify(e,t,r,n){window.clarity("identify",e,t,r,n)},consent(e=!0){window.clarity("consent",e)},consentV2(e={ad_Storage:"granted",analytics_Storage:"granted"}){window.clarity("consentv2",e)},upgrade(e){window.clarity("upgrade",e)},event(e){window.clarity("event",e)}};var n=e.i(857259);e.i(972694);var a=e.i(345367);function s({projectId:e}){let{user:s}
7=(0,n.useSession)(),i=(0,t.useRef)(null),o=(0,t.useRef)(!1),[l,c]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{let e=()=>c((0,a.hasTrackingConsent)());return e(),window.addEventListener(a.COOKIE_CONSENT_CHANGE_EVENT,e),()=>window.removeEventListener(a.COOKIE_CONSENT_CHANGE_EVENT,e)},[]),(0,t.useEffect)(()=>{if(!l){o.current&&r.consentV2({ad_Storage:"denied",analytics_Storage:"denied"});return}o.current||(r.init(e),o.current=!0),r.consentV2({ad_Storage:"granted",analytics_Storage:"granted"})},[l,e]),(0,t.useEffect)(()=>{o.current&&l&&(r.setTag("userType",s?s.corporateId?"Corporate":"External Customer":"Guest"),s?.id&&i.current!==s.id&&(r.identify(s.id,void 0,void 0,s.name),s.role&&r.setTag("role",s.role),s.corporateId&&r.setTag("corporateId",s.corporateId),i.current=s.id))},[l,s?.id,s?.name,s?.role,s?.corporateId,s]),null}e.s(["ClarityInit",()=>s],392126)},228559,e=>{"use strict";var t=e.i(247167),r=e.i(271645);let n="color:#0a0",a="color:#c00;font-weight:bold";function s({gtmId:e,gtmAuth:s,gtmPreview:i,ga4MeasurementId:o,metaPixelId:l,clarityProjectId:c,analyticsEnabled:d}){return(0,r.useEffect)(()=>{if("true"!==t.default.env.NEXT_PUBLIC_ANALYTICS_DEBUG)return;let r=(e,t)=>{t?console.log(`%câ ${e}:%c ${t}`,n,"color:#888"):console.log(`%câ ${e}: MISSING`,a)},u=(e,t)=>{console.log(t?`%câ ${e}: set`:`%câ ${e}: MISSING`,t?n:a)},m=window.setTimeout(()=>{let t,{dataLayerReady:m,gtmContainerLoaded:p}={dataLayerReady:Array.isArray((t=window).dataLayer),gtmContainerLoaded:void 0!==e&&!!t.google_tag_manager?.[e]};console.groupCollapsed("%c[Analytics Init]","color:#0a0;font-weight:bold;font-size:12px",d?"â enabled":"â DISABLED (kill switch)"),r("NEXT_PUBLIC_GTM_ID",e),u("NEXT_PUBLIC_GTM_AUTH",s),u("NEXT_PUBLIC_GTM_PREVIEW",i),r("NEXT_PUBLIC_GA4_MEASUREMENT_ID",o),r("NEXT_PUBLIC_META_PIXEL_ID",l),r("NEXT_PUBLIC_CLARITY_PROJECT_ID",c),m?console.log("%câ window.dataLayer initialised",n):console.log("%câ window.dataLayer NOT initialised",a),p?console.log(`%câ GTM container ${e} loaded (gtm.js executed)`,n):console.log(`%câ GTM container ${e??"(no id)"} NOT loaded â Tag Assistant will not see tags. Check ad-blockers / consent / network.`,a),console.groupEnd()},2e3);return()=>window.clearTimeout(m)},[e,s,i,o,l,c,d]),null}e.s(["AnalyticsInitLogger",()=>s])}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.