efficient-storefront-blocks 0.14.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{f as nt,i as fe,p as rt,r as ot,t as q}from"./chunk-TCRMUJVM.js";import{Ma as me,Na as Ze,Qa as Ae,Ra as et}from"./chunk-MWOOPV76.js";import{e as Je,r as tt,t as re}from"./chunk-F3PA63EP.js";import{createContext as Qt,useContext as Xt,useEffect as Jt,useMemo as ge,useState as st}from"react";function it(e,t){return e.map(n=>({partNumber:n.partNumber,quantity:n.wheels*t}))}function oe(e,t){if(e.length===0)return null;let n=0;for(let r of e){let o=r.prices?.[t];if(typeof o!="number"||!Number.isFinite(o)||o<=0)return null;n+=o*r.wheels}return n}var Me=4,ir=1,ar={unit:"set",spares:0,spareSide:"left"};function at(e){return e.unit==="single"?1:Me+e.spares}function sr(e,t){return[{partNumber:e.partNumber,wheels:at(t),prices:e.prices}]}function lr(e,t){let n=at(t)-Me;if(n<=0||e.length===0)return e;let r=Yt(e),o=r?r[t.spareSide]:0;return e.map((i,a)=>a===o?{...i,wheels:i.wheels+n}:i)}function Yt(e){let t,n;for(let r=0;r<e.length;r+=1){let o=e[r].hand;if(o!=="left"&&o!=="right")continue;if((o==="left"?t:n)!==void 0)return null;o==="left"?t=r:n=r}return t!==void 0&&n!==void 0?{left:t,right:n}:null}function jt(e,t){return t.spares>0?`${e} + spare`:e}function ur(e){return e.unit==="single"?"Single":jt(`Set of ${Me}`,e)}var cr="data-add-to-basket",De=9,Oe="en";function pe(e,t,n=0){return new Intl.NumberFormat(Oe,{style:"currency",currency:t,minimumFractionDigits:0,maximumFractionDigits:n}).format(e)}import{jsx as tn}from"react/jsx-runtime";var lt="storefront-country",ut=Qt(null);function Zt(e){return ct(e,"catalogue")}function en(e){return ct(e,"money")}function ct(e,t){let n=new Map(e.map(o=>[o.code,o.decimalPlaces])),r=new Map;return(o,i)=>{if(!i)return"";let a=r.get(i);if(!a){let u=n.get(i)??0;a=new Intl.NumberFormat(Oe,{style:"currency",currency:i,minimumFractionDigits:t==="money"?u:0,maximumFractionDigits:u}),r.set(i,a)}return a.format(o)}}function gr({children:e,currencies:t,countries:n,defaultCurrency:r,defaultCountry:o}){let i=ge(()=>t??[],[t]),a=ge(()=>n??[],[n]),u=ge(()=>r||i.find(C=>C.isDefault)?.code||i[0]?.code||"",[r,i]),c=ge(()=>o||a.find(C=>C.isDefault)?.code||a[0]?.code||"",[o,a]),[l,d]=st(c),[f,P]=st(!1);Jt(()=>{let C=re.getItem(lt);C&&a.some(I=>I.code===C)&&d(C),P(!0)},[a]);function L(C){d(C),re.setItem(lt,C)}let h=ge(()=>{let C=a.find(w=>w.code===l)??null,I=C?.currency,T=I&&i.some(w=>w.code===I)?I:u,M=Zt(i),x=en(i);return{country:l,currency:T,setCountry:L,currencies:i,countries:a,activeCountry:C,formatPrice:(w,S)=>M(w,S??T),formatMoney:(w,S)=>x(w,S??T),ready:f}},[l,i,a,u,f]);return tn(ut.Provider,{value:h,children:e})}function dt(){let e=Xt(ut);if(!e)throw new Error("useCurrency must be used within a CurrencyProvider");return e}import{createContext as pn,useCallback as k,useContext as gn,useEffect as Y,useMemo as St,useRef as ie,useState as R}from"react";function ft(e,t){return e.valid?!1:e.reason==="firstOrderOnly"?!0:e.reason==="notEligible"&&!t}var pt="We'll confirm this discount when you place your order.",Cr="Confirmed at checkout";function xr(e){return e&&(e.valid||e.deferred)?e.code:void 0}var mt="coupon_code: ";function Sr(e){return!(e instanceof fe)||e.status!==400||!e.message.startsWith(mt)?null:e.message.slice(mt.length)}function gt(e,t){return e.map(n=>({qty:n.qty,slug:n.slug,name:`${n.name.lead}${n.name.accent}`.trim(),finish:n.finishName,size:n.size,kind:n.kind,sku:n.sku,pack:n.pack,priceLabel:t(n)}))}var Pe="Price on request",rn="Request a quote";function Fe(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Ue(e,t){let n=e?.[t];return Fe(n)?n:null}function Ir(e,t,n,r){let o=Ue(e,n),i=Ue(t,n);return o===null&&i===null?0:o===null?1:i===null?-1:r==="asc"?o-i:i-o}function wr(e,t,n,r){if(n==null&&r==null)return!0;let o=Ue(e,t);return!(o===null||n!=null&&o<n||r!=null&&o>r)}var on={priced:!1,unit:null,was:null,onSale:!1,setTotal:null};function an(e,t,n){if(!Fe(e))return on;let r=Fe(t)&&t>e?t:null;return{priced:!0,unit:e,was:r,onSale:r!==null,setTotal:n!=null?e*n:null}}function Lr(e,t,n=""){return!e.priced||e.unit==null?Pe:`${n}${pe(e.unit,t)}`}function Nr(e,t){return e.was==null?null:pe(e.was,t)}function sn(e,t,n=1){let r=oe(e,t);if(r===null)return{priced:!1,unit:null,isFrom:!1,setTotal:null};let o=e.reduce((a,u)=>a+u.wheels,0),i=Math.min(...e.map(a=>a.prices[t]));return{priced:!0,unit:i,isFrom:i*o!==r,setTotal:r*n}}var ln={priced:!1,unit:null,isFrom:!1,was:null,onSale:!1,setTotal:null};function Tr(e,t,n,r=1){let o=an(e.prices[n],e.msrpPrices?.[n],4),i=o.setTotal==null?null:o.setTotal*r;if(!t)return{priced:o.priced,unit:o.unit,isFrom:!0,was:o.was,onSale:o.onSale,setTotal:null,fromSetTotal:i};let a=sn(t.components,n,r);return a.priced?{priced:!0,unit:a.unit,isFrom:a.isFrom,was:null,onSale:!1,setTotal:a.setTotal,fromSetTotal:i}:{...ln,fromSetTotal:i}}function un(e,t){return!e.priced||e.unit==null?Pe:`${e.isFrom?"from ":""}${pe(e.unit,t)}`}function _r(e,t){return e.was==null?null:pe(e.was,t)}function kr(e,t){return!e.priced||e.unit==null?rn:un(e,t)}var cn=/^[^@\s]+@[^@\s]+\.[^@\s]+$/;function yt(e){return cn.test(e.trim())}var bt="sf:ga-purchases",dn=20;function Ct(){return typeof window>"u"||window.parent!==window}function ye(...e){try{if(Ct()||typeof window.gtag!="function")return;window.gtag(...e)}catch{}}function mn(e,t){let n=e.config.find(r=>r.gold)?.label;return{item_id:`${e.slug}|${e.finishName}|${e.size}`,item_name:`${e.name.lead}${e.name.accent}`.trim(),...n?{item_variant:n}:{},price:oe(e.components,t)??0,quantity:e.qty}}function $e(e,t){return e.filter(Ie).map(n=>mn(n,t))}function Fr(e){ye("event","view_item",{currency:e.currency,value:e.pricePerSet,items:[{item_id:e.itemId,item_name:e.itemName,...e.variant?{item_variant:e.variant}:{},price:e.pricePerSet,quantity:1}]})}function xt(e,t){let n=$e([e],t);n.length!==0&&ye("event","add_to_cart",{currency:t,value:n[0].price*n[0].quantity,items:n})}function Ur(e){let t=$e(e.lines,e.currency);t.length!==0&&ye("event","begin_checkout",{currency:e.currency,value:e.value,...e.coupon?{coupon:e.coupon}:{},items:t})}var ht=new Set;function fn(e){if(ht.has(e))return!1;ht.add(e);try{let t=JSON.parse(re.getItem(bt)??"[]");if(t.includes(e))return!1;re.setItem(bt,JSON.stringify([...t,e].slice(-dn)))}catch{}return!0}function $r(e){let t=e.confirmation;if(Ct()||!fn(t.orderNumber))return;let n=t.currency,r=Number(t.grandTotal);ye("event","purchase",{transaction_id:t.orderNumber,currency:n,value:r,shipping:Number(t.freightCharge),...t.couponCode?{coupon:t.couponCode}:{},items:$e(e.lines,n)}),e.adsSendTo&&ye("event","conversion",{send_to:e.adsSendTo,transaction_id:t.orderNumber,currency:n,value:r})}import{jsx as Cn}from"react/jsx-runtime";var yn=400,bn=400,hn=1500;function Ie(e){return(e.components?.length??0)>0}function vt(e,t){return{code:e,valid:t.valid,deferred:ft(t,t.askedAsShopper),message:t.message||void 0,effects:t.effects??void 0}}function Pt(e,t){return oe(e.components,t)}function qe(e,t){let n=Pt(e,t);return n===null?null:n*e.qty}function Et(e){return e!=="tyre"}var It=pn(null);function Qr({children:e,preview:t=!1}){let{currency:n,country:r,formatMoney:o}=dt(),[i,a]=R(t),[u,c]=R([]),[l,d]=R([]),[f,P]=R([]),[L,h]=R(!1),[C,I]=R(!1),[T,M]=R(!1),[x,w]=R(!1),[S,K]=R(null),[W,Q]=R(void 0),b=ie(r),v=ie("");b.current=b.current||r;let[m,H]=R(null),[X,z]=R(!1),[A,J]=R(null),Z=ie(void 0),D=k(()=>a(!0),[]),xe=k(()=>a(!1),[]),O=k(()=>a(s=>!s),[]);Y(()=>{t||typeof window>"u"||new URLSearchParams(window.location.search).get("cart")==="open"&&D()},[D,t]);let Se=k(s=>{w(!0),Et(s)&&M(!0)},[]),ee=T||u.some(s=>Et(s.kind)),se=x||u.length>0;Y(()=>{if(t||!ee||L)return;let s=!0;return q.listWheels().then(p=>{s&&(d(p),h(!0))}),()=>{s=!1}},[t,ee,L]),Y(()=>{if(t||!se||C)return;let s=!0;return q.listBundles().then(p=>{s&&(P(p),I(!0))}),()=>{s=!1}},[t,se,C]);let U=S?.deliveryOptions??[];Y(()=>{U.length!==0&&J(s=>s&&U.some(p=>p.id===s)?s:U[0]?.id??null)},[S]);let V=k(()=>u.filter(Ie).flatMap(s=>it(s.components,s.qty)),[u]),le=k(async(s,p)=>{let y=s.trim().toUpperCase();if(!y)return;let g=V();if(g.length===0){H({code:y,valid:!1,message:"Add a wheel to the cart first."});return}z(!0),Z.current=p;try{let N=await q.validateCoupon({code:y,items:g,currency:n,shippingMethodId:A??void 0,customerEmail:p});H(vt(y,N))}catch{H({code:y,valid:!1,message:"Could not check that code. Please try again."})}finally{z(!1)}},[V,n,A]),te=k(()=>{H(null),Z.current=void 0},[]),ve=k(s=>{if(!m)return;let{code:p}=m;H(y=>y&&y.code===p?{code:p,valid:!1,refused:!0,message:s}:y)},[m]);Y(()=>{if(!m||m.refused)return;let s=m.code,p=g=>g!==null&&g.code===s&&!g.refused,y=setTimeout(async()=>{let g=V();if(g.length===0){H(N=>p(N)?{code:s,valid:!1,message:"Add a wheel to the cart first."}:N);return}z(!0);try{let N=await q.validateCoupon({code:s,items:g,currency:n,shippingMethodId:A??void 0,customerEmail:Z.current});H(de=>p(de)?vt(s,N):de)}catch{}finally{z(!1)}},yn);return()=>clearTimeout(y)},[u,n,A]);let ue=m&&!m.refused?m.code:void 0;Y(()=>{if(t)return;let s=!0,p=setTimeout(async()=>{let y=V();if(y.length===0){K(null),Q(void 0);return}try{let g=await q.quoteCart({items:y,currency:n,shippingMethodId:A??void 0,couponCode:ue,customerEmail:Z.current||void 0,country:b.current||void 0,subdivision:v.current||void 0});if(!s)return;K(g)}catch{if(!s)return}Q(ue)},bn);return()=>{s=!1,clearTimeout(p)}},[u,n,A,ue,r]);let E=k(s=>{c(p=>{let y=p.findIndex(g=>g.id===s.id);return y===-1?[...p,s]:p.map((g,N)=>N===y?{...g,qty:Math.min(De,g.qty+s.qty)}:g)}),xt(s,n)},[n]),F=k(s=>{c(p=>p.filter(y=>y.id!==s))},[]),G=k((s,p)=>{let y=Math.max(1,Math.min(De,p));c(g=>g.map(N=>N.id===s?{...N,qty:y}:N))},[]),ze=k(s=>{c(s)},[]),[ce,Kt]=R(null),Ve=ie(null);Ve.current=ce;let $=ie(null),ke=ie(""),Ge=k((s,p)=>{let y=s.trim().toLowerCase();yt(y)&&Kt(g=>g&&g.email===y&&g.firstName===(p??"")?g:{email:y,firstName:p??""})},[]);Y(()=>{if(t||!ce)return;let s=gt(u.filter(Ie),g=>qe(g,n)===null?Pe:o(qe(g,n),n)),p={email:ce.email,firstName:ce.firstName,currency:n,items:s},y=JSON.stringify(p);if(y!==ke.current)return $.current&&clearTimeout($.current),$.current=setTimeout(()=>{$.current=null,ke.current=y,q.captureCart(p).catch(g=>{})},hn),()=>{$.current&&(clearTimeout($.current),$.current=null)}},[u,ce,n,t]);let Ye=k(()=>{$.current&&(clearTimeout($.current),$.current=null);let s=Ve.current;s&&(ke.current="",q.captureCart({email:s.email,firstName:s.firstName,currency:n,items:[]}).catch(p=>{}))},[n]),je=St(()=>{let s=u.reduce((_,ne)=>{let Ee=qe(ne,n);return Ee===null?_:_+Ee},0),p=u.some(_=>Pt(_,n)===null),y=u.reduce((_,ne)=>_+ne.qty,0),g=m?.valid?m.effects:void 0,N=g?Math.min(s,Number(g.discountAmount)):0,de=S?.bundleDiscount??0,Wt=S?.appliedBundles??[],Qe=!!g?.freeShipping,Bt=U.find(_=>_.id===A),Xe=Qe?0:S?.shipping??Bt?.amount??0,Re={};for(let _ of g?.freeUnits??[])Re[_.partNumber]=(Re[_.partNumber]??0)+_.quantity;let zt=S?.tax??null,Vt=S?S.grandTotal:s-N-de+Xe;return{sets:y,units:u.reduce((_,ne)=>_+(ne.components??[]).reduce((Ee,Gt)=>Ee+Gt.wheels*ne.qty,0),0),subtotal:s,hasUnpricedLine:p,discount:N,bundleDiscount:de,appliedBundles:Wt,shipping:Xe,freeShipping:Qe,freeUnitsByPartNumber:Re,tax:zt,grand:Vt,repricing:!!m?.refused&&S!==null&&W===m?.code,currency:n}},[u,n,m,U,A,S,W]),Ht=St(()=>({isOpen:i,preview:t,open:D,close:xe,toggle:O,items:u,catalog:l,bundles:f,warmCatalog:Se,add:E,remove:F,setQty:G,replaceItems:ze,identify:Ge,clearCapturedCart:Ye,coupon:m,applyCoupon:le,removeCoupon:te,refuseCoupon:ve,couponBusy:X,deliveryOptions:U,shippingMethodId:A,setShippingMethodId:J,totals:je}),[i,t,D,xe,O,u,l,f,Se,E,F,G,ze,Ge,Ye,m,le,te,ve,X,U,A,je]);return Cn(It.Provider,{value:Ht,children:e})}function wt(){let e=gn(It);if(!e)throw new Error("useCart() must be called inside <CartProvider>. Mount the provider in app/layout.tsx.");return e}import{cache as _n}from"react";function Lt(e,t,n,r){for(;e.size>=t;){let o,i;for(let[u,c]of e){if(c.expiresAt<=r){o=u;break}i===void 0&&n(u)&&(i=u)}let a=o??i??e.keys().next().value;if(a===void 0)return;e.delete(a)}}var xn=6e4,Sn=5e3,vn=500,we=new Map;async function En(e){let{host:t,matchesRequestHost:n}=await rt();if(!t)return"";let r=await ot();return r?`${e}|slug:${encodeURIComponent(t)}/${encodeURIComponent(r)}`:n?`${e}|host:${t}`:`${e}|xhost:${t}`}var Pn=e=>e.includes("|slug:")||e.includes("|xhost:");async function Nt(e,t){let n=await En(e);if(!n)return t();let r=Date.now(),o=we.get(n);if(o&&o.expiresAt>r)return o.load;let i=await t(),a=i.outcome.state==="failed",u=a?Sn:xn,c=we.get(n)?.lastGood,l=i.outcome.state==="ok"?i:a?c:void 0,d=a&&l?l:i;return Lt(we,vn,Pn,r),we.set(n,{load:d,expiresAt:r+u,lastGood:l}),d}var In=404;function wn(e){if(e instanceof fe&&e.status===In)return{state:"absent"};let t=e instanceof fe?e.status:-1,n=e instanceof Error?e.message:String(e);return{state:"failed",status:t,detail:n}}var Ln="[storefront:chrome-load-failed]";function Nn(e,t){console.error(`${Ln} ${e} status=${t.status} \u2014 serving fallback chrome`,t.detail)}async function Tt(e,t,n,r){try{let o=await t();return r?.(o)?{value:o,outcome:{state:"absent"}}:{value:o,outcome:{state:"ok"}}}catch(o){let i=wn(o);return i.state==="failed"&&Nn(e,i),{value:n,outcome:i}}}function Tn(e){return e==="production"?"silent":"banner"}var oo=Tn("production");function kn(e,t){return e?.trim()||t}function fo({legalName:e,foundedYear:t,siteName:n},r=new Date().getFullYear()){let o=kn(e,n);return`\xA9 ${t&&t<r?`${t}\u2013${r}`:`${r}`} ${o}`}var Rn={name:me,legalName:null,foundedYear:null,faviconUrl:null,currencies:[],defaultCurrency:null,countries:[],defaultCountry:null,commerceEnabled:!0,cardPayments:!1,paymentMethods:[],paypalClientId:null,paypalEnvironment:null,squareApplicationId:null,squareLocationId:null,squareEnvironment:null,ga4MeasurementId:null,googleAdsId:null,googleAdsConversionLabel:null,metaPixelId:null,mapsApiKey:null,mapsMapId:null,socialLinks:Ae},po=_n(async()=>Nt("site",()=>Tt("site",async()=>{let e=await q.getSite();return{name:Ze(e.name),legalName:e.legalName?.trim()||null,foundedYear:e.foundedYear??null,faviconUrl:e.faviconUrl??null,currencies:e.currencies??[],defaultCurrency:e.defaultCurrency??null,countries:e.countries??[],defaultCountry:e.defaultCountry??null,commerceEnabled:e.commerceEnabled??!0,cardPayments:e.cardPayments??!1,paymentMethods:e.paymentMethods??(e.cardPayments?["card"]:[]),paypalClientId:e.paypalClientId??null,paypalEnvironment:e.paypalEnvironment??null,squareApplicationId:e.squareApplicationId??null,squareLocationId:e.squareLocationId??null,squareEnvironment:e.squareEnvironment??null,ga4MeasurementId:e.ga4MeasurementId??null,googleAdsId:e.googleAdsId??null,googleAdsConversionLabel:(e.googleAdsId?e.googleAdsConversionLabel:null)??null,metaPixelId:e.metaPixelId??null,mapsApiKey:e.mapsApiKey??null,mapsMapId:e.mapsMapId??null,socialLinks:et(e.socialLinks)}},Rn)));var go={name:me,legalName:null,foundedYear:null,faviconUrl:null,currencies:[{code:"USD",symbol:"$",decimalPlaces:2,isDefault:!0}],defaultCurrency:"USD",countries:[{code:"US",name:"United States",currency:"USD",url:"",isDefault:!0,chargeTax:!1,taxDisplay:"none",taxName:"",taxRate:null,postalLabel:"Zip Code"}],defaultCountry:"US",commerceEnabled:!0,cardPayments:!0,paymentMethods:["card"],paypalClientId:null,paypalEnvironment:null,squareApplicationId:null,squareLocationId:null,squareEnvironment:null,ga4MeasurementId:null,googleAdsId:null,googleAdsConversionLabel:null,metaPixelId:null,mapsApiKey:null,mapsMapId:null,socialLinks:Ae};import{jsx as kt,jsxs as Rt}from"react/jsx-runtime";import{useEffect as Le,useRef as At,useState as Ne}from"react";var be=new Map,An=64;async function Mn(e){if(!Je())return null;try{let t=await fetch(`${tt()}/logo-analysis.json?url=${encodeURIComponent(e)}`);if(!t.ok)return null;let n=await t.json();if(!n||typeof n!="object")return null;let{reversed:r,inkIsDark:o}=n;return typeof r!="string"?null:{reversed:r,inkIsDark:typeof o=="boolean"?o:null}}catch{return null}}function _t(e){let t=be.get(e);if(t)return t;let n=Mn(e);if(be.set(e,n),be.size>An){let r=be.keys().next();r.done||be.delete(r.value)}return n}var Dn={small:54,medium:66,large:84},On=44,Fn=202/22,Io=16,wo=140,Un=.88,Lo=16,$n="invert(1)";function No({variant:e="header",scrolled:t=!0,src:n,reverse:r=!1,onLightSurface:o,reversedSrc:i,inkIsDark:a,size:u="medium",sizePx:c,wordmark:l,siteName:d=me,fitToContainer:f=!1,fitWordmarkToContainer:P=!1,fitFloorPx:L}){let h=l&&l.trim()?l.trim():d,[C,I]=Ne(!1),T=At(null),M=E=>{T.current=E};Le(()=>{let E=T.current?.ownerDocument??document,F=()=>{I(E.documentElement.getAttribute("data-theme")==="light")};F();let G=new MutationObserver(F);return G.observe(E.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>G.disconnect()},[]);let x=n&&n.trim()?n.trim():null,w=!!x&&nt(x),S=o??(C&&t),K=r&&w&&x&&i!=null?{reversed:i,inkIsDark:a??null}:null,W=K!==null,[Q,b]=Ne(null);Le(()=>{if(!r||!x||!w||W){b(null);return}let E=!1;return b(null),_t(x).then(F=>{E||b(F)}),()=>{E=!0}},[r,x,w,W]);let v=K??Q,m=!!v&&v.inkIsDark!==null&&(S?!v.inkIsDark:v.inkIsDark),H=r&&!!x&&!w&&!S,X=m&&v?v.reversed:x,z=X?[X]:[],[A,J]=Ne(0);Le(()=>{J(0)},[x,m]);let Z=e==="footer"?On:Dn[u],D=c&&c>0?c:Z,xe=Math.round(D*Fn),O=A<z.length?z[A]:null,[Se,ee]=Ne(X),se=O!==null&&O===Se,U=At(null);Le(()=>{let E=U.current;if(!E||!E.complete)return;if(E.naturalWidth>0||E.naturalHeight>0){ee(O);return}let F=!1;return E.decode().then(()=>!F&&ee(O),()=>!F&&J(G=>G+1)),()=>{F=!0}},[O]);let V=f||P,le=`calc(100cqi / ${((h.length+1)*Un).toFixed(2)})`,te=V&&L&&L>0?Math.min(L,D):null,ve=V?te===null?`min(${D}px, ${le})`:`clamp(${te}px, ${le}, ${D}px)`:`${D}px`,ue=Rt("span",{className:`font-display font-bold tracking-[0.18em] ${te===null?"whitespace-nowrap":"whitespace-normal"}`,style:{fontSize:ve,lineHeight:1},"aria-label":h,children:[h,kt("span",{className:"text-accent",children:"."})]});return Rt("span",{ref:M,className:"inline-flex items-center",children:[!se&&ue,O&&kt("img",{ref:U,src:O,alt:h,width:xe,height:D,className:"shrink-0 object-contain",style:{...se?{height:`${D}px`,width:"auto",...f?{maxWidth:"100cqi"}:{}}:{display:"none"},...H?{filter:$n}:{}},onLoad:()=>ee(O),onError:()=>J(E=>E+1)},O)]})}import{Children as Kn,isValidElement as Hn,useEffect as Dt,useId as Wn,useLayoutEffect as Bn,useRef as j,useState as Ot}from"react";var Te=(e,t)=>!!e[t]&&!e[t].disabled;function Ke(e,t,n){let r=e.length;for(let o=1;o<=r;o++){let i=((t+n*o)%r+r)%r;if(Te(e,i))return i}return t}function He(e,t){return Ke(e,t===1?-1:e.length,t)}function We(e,t){return Te(e,t)?t:Math.max(He(e,1),0)}function Mt(e,t,n){let{open:r,focus:o}=e,i=a=>({...e,...a});if(t.length===1&&/\S/.test(t)){let a=e.typed+t.toLowerCase(),u=n.findIndex((c,l)=>Te(n,l)&&c.label.toLowerCase().startsWith(a));return{state:i({open:!0,typed:a,focus:u>=0?u:o}),handled:!0}}if(!r)return t==="ArrowDown"||t==="ArrowUp"||t==="Enter"||t===" "?{state:i({open:!0,typed:""}),handled:!0}:{state:e,handled:!1};switch(t){case"ArrowDown":return{state:i({focus:Ke(n,o,1)}),handled:!0};case"ArrowUp":return{state:i({focus:Ke(n,o,-1)}),handled:!0};case"Home":return{state:i({focus:He(n,1)}),handled:!0};case"End":return{state:i({focus:He(n,-1)}),handled:!0};case"Enter":case" ":return Te(n,o)?{state:i({open:!1,typed:""}),commit:o,refocus:!0,handled:!0}:{state:e,handled:!0};case"Escape":return{state:i({open:!1,typed:""}),refocus:!0,handled:!0};case"Tab":return{state:i({open:!1,typed:""}),handled:!1};default:return{state:e,handled:!1}}}import{Fragment as jn,jsx as B,jsxs as Ft}from"react/jsx-runtime";function zn({items:e,value:t,onPick:n,open:r,onOpen:o,onClose:i}){let[a,u]=Ot(!1),c=r!==void 0,l=c?r:a,[d,f]=Ot(0),P=j({text:"",timer:0}),L=j(null),h=j(null),C=j(null),I=Wn(),T=j(null),M=e.findIndex(b=>b.value===t),x=b=>{b!==l&&(c||u(b),b?o?.():i?.())},w=b=>{let v=e[b];!v||v.disabled||(n(v.value),x(!1),h.current?.focus())},S=b=>{let v={open:l,focus:l?d:We(e,M),typed:P.current.text},m=Mt(v,b,e);return!m.handled&&m.state.open===l?!1:(m.state.typed!==v.typed&&(P.current.text=m.state.typed,window.clearTimeout(P.current.timer),P.current.timer=window.setTimeout(()=>{P.current.text=""},500)),f(m.state.focus),m.commit!==void 0?w(m.commit):x(m.state.open),m.refocus&&h.current?.focus(),m.handled)},K=j(S);K.current=S;let W=j(()=>x(!1));W.current=()=>x(!1);let Q=b=>{l||(T.current=b.nativeEvent,K.current(b.key)&&b.preventDefault())};return Dt(()=>{if(!l)return;let b=m=>{L.current?.contains(m.target)||W.current()},v=m=>{m!==T.current&&K.current(m.key)&&m.preventDefault()};return document.addEventListener("mousedown",b),document.addEventListener("keydown",v),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",v)}},[l]),Dt(()=>{l&&(P.current.text||f(We(e,M)))},[l]),Bn(()=>{if(!l||!C.current)return;C.current.children.item(d)?.scrollIntoView({block:"nearest"})},[d,l]),{open:l,toggle:()=>x(!l),close:()=>x(!1),focusIdx:d,setFocusIdx:f,pick:b=>w(e.findIndex(v=>v.value===b)),wrapRef:L,triggerRef:h,listRef:C,listId:I,onTriggerKeyDown:Q,activeId:l?`${I}-${d}`:void 0}}var Vn={select:{list:"absolute left-0 top-full z-50 mt-1 max-h-[280px] w-max min-w-full overflow-y-auto border-2 border-accent bg-bg shadow-xl",item:(e,t,n)=>["px-3 py-2.5 font-mono text-[13px] font-semibold uppercase tracking-[0.1em] transition-colors whitespace-nowrap",n?"cursor-not-allowed opacity-40":"cursor-pointer",e&&!n?"bg-accent text-bg":"bg-bg text-fg"].join(" ")},cell:{list:"absolute left-0 top-full z-50 mt-1 max-h-[320px] w-max min-w-full overflow-y-auto border-2 border-accent bg-bg shadow-xl",item:e=>["cursor-pointer whitespace-nowrap px-6 py-3 font-mono text-[length:var(--size-label,13px)] font-semibold uppercase tracking-[0.1em] transition-colors",e?"bg-accent text-bg":"bg-bg text-fg"].join(" "),pickerMarker:!0},hairline:{list:"absolute left-0 top-full z-50 max-h-[320px] w-full overflow-y-auto border border-line bg-bg shadow-[0_6px_20px_rgba(0,0,0,0.10)]",item:(e,t)=>["flex cursor-pointer items-center justify-between gap-4 border-b border-line px-4 py-3 text-left text-[length:var(--size-body,14px)] transition-colors last:border-b-0",t?"border-fg font-medium text-fg":e?"border-fg text-fg":"text-fg-dim"].join(" "),pickerMarker:!0},region:{list:"absolute right-0 top-full z-[200] mt-2 flex min-w-[240px] flex-col border border-line bg-surface text-fg",item:(e,t,n,r)=>["flex w-full cursor-pointer items-center gap-3 px-3.5 py-3 text-left transition-colors","font-mono text-[13px] uppercase tracking-[0.18em]",e?"bg-surface-2 text-fg":"",r?"":"border-b border-line",t?"text-accent":""].join(" "),itemStyle:e=>e?void 0:{color:"color-mix(in oklab, currentColor 80%, transparent)"}}};function Gn({id:e,tone:t,items:n,value:r,focusIdx:o,onFocus:i,onPick:a,listRef:u,ariaLabel:c}){let l=Vn[t];return B("ul",{ref:u,id:e,role:"listbox","aria-label":c,...l.pickerMarker?{"data-picker-menu":""}:{},className:l.list,children:n.map((d,f)=>{let P=d.value===r;return B("li",{id:`${e}-${f}`,role:"option","aria-selected":P,"aria-disabled":d.disabled||void 0,onMouseEnter:()=>!d.disabled&&i(f),onMouseDown:L=>{L.preventDefault(),d.disabled||a(d.value)},className:l.item(f===o,P&&d.value!=="",!!d.disabled,f===n.length-1),style:l.itemStyle?.(P),children:d.meta===void 0?d.label:Ft(jn,{children:[B("span",{className:"flex-1 whitespace-nowrap",children:d.label}),B("span",{className:"ml-auto text-[12px] opacity-50",children:d.meta})]})},`${d.value}_${f}`)})})}function Yn({value:e,onChange:t,disabled:n,children:r,className:o,style:i,name:a,id:u,"aria-label":c}){let l=Kn.toArray(r).flatMap(h=>{if(!Hn(h))return[];if(h.type!=="option")return[];let I=h.props,T=I.value!==void 0?String(I.value):"",M=I.children,x=typeof M=="string"||typeof M=="number"?String(M):T;return[{value:T,label:x,disabled:!!I.disabled}]}),d=e??"",f=zn({items:l,value:d,onPick:h=>t?.({target:{value:h}})}),L=l.find(h=>h.value===d)?.label??l[0]?.label??"";return Ft("div",{ref:f.wrapRef,className:"relative",children:[a&&B("input",{type:"hidden",name:a,value:d}),B("button",{ref:h=>{f.triggerRef.current=h},type:"button",disabled:n,"aria-haspopup":"listbox","aria-expanded":f.open,"aria-controls":f.open?f.listId:void 0,"aria-activedescendant":f.activeId,"aria-label":c,id:u,onClick:()=>!n&&f.toggle(),onKeyDown:h=>!n&&f.onTriggerKeyDown(h),className:`block w-full ${o??""}`,style:i,children:B("span",{className:"block w-full truncate text-left",children:L})}),f.open&&B(Gn,{id:f.listId,tone:"select",items:l,value:d,focusIdx:f.focusIdx,onFocus:f.setFocusIdx,onPick:f.pick,listRef:f.listRef})]})}var Fo="#c9a461",Ut=[{f:"black",label:"Black",hex:"#171717"},{f:"silver",label:"Silver",hex:"#cccccc"},{f:"bronze",label:"Bronze",hex:"#8a6438"},{f:"graphite",label:"Graphite",hex:"#3a3c3f"},{f:"red",label:"Candy Red",hex:"#7a0f14"}],Uo={name:"",color:"var(--fg)",family:"silver",src:""};function Qn(e,t){let n=r=>{let o=Ut.findIndex(i=>i.f===r);return o===-1?Ut.length:o};return n(e)-n(t)||e.localeCompare(t)}function $o(e){let t=new Set;for(let n of e)for(let r of n.finishes??[])r?.family&&t.add(r.family);return[...t].sort(Qn)}import{jsx as he,jsxs as _e}from"react/jsx-runtime";var Xn="font-mono text-[length:var(--size-label,12px)]",Jn="font-semibold uppercase tracking-[0.22em] text-fg";function $t(e){return`${e??Xn} ${Jn}`}function qt(){return he("span",{className:"text-accent",children:" *"})}function Zn({children:e,required:t,labelFace:n}){return _e("span",{className:$t(n),children:[e,t?he(qt,{}):null]})}function er({label:e,required:t,hint:n,separate:r,htmlFor:o,labelFace:i,className:a,children:u}){let c=a?`flex flex-col gap-2 ${a}`:"flex flex-col gap-2",l=n?he("span",{className:"font-mono text-[11px] uppercase tracking-[0.22em] text-fg-dim",children:n}):null;return r||n?_e("div",{className:c,children:[_e("label",{htmlFor:o,className:$t(i),children:[e,t?he(qt,{}):null]}),u,l]}):_e("label",{htmlFor:o,className:c,children:[he(Zn,{required:t,labelFace:i,children:e}),u]})}import{jsx as Ce,jsxs as nr}from"react/jsx-runtime";function tr({spokes:e,mesh:t=!1,className:n}){let a=c=>Math.round(c*1e3)/1e3,u=[];for(let c=0;c<e;c++){let l=c/e*Math.PI*2-Math.PI/2;if(u.push({x1:a(100+Math.cos(l)*22),y1:a(100+Math.sin(l)*22),x2:a(100+Math.cos(l)*86),y2:a(100+Math.sin(l)*86),main:!0}),t){let d=l+Math.PI/e;u.push({x1:a(100+Math.cos(d)*22*1.4),y1:a(100+Math.sin(d)*22*1.4),x2:a(100+Math.cos(d)*78),y2:a(100+Math.sin(d)*78),main:!1})}}return nr("svg",{viewBox:"0 0 200 200",fill:"none",stroke:"currentColor",className:n??"block h-[70%] w-[70%] transition-transform duration-700 [transition-timing-function:cubic-bezier(.2,.6,.2,1)]",children:[Ce("circle",{cx:100,cy:100,r:92,strokeWidth:2}),Ce("circle",{cx:100,cy:100,r:84,strokeWidth:1,opacity:.4}),Ce("circle",{cx:100,cy:100,r:22,strokeWidth:2}),Ce("circle",{cx:100,cy:100,r:6,fill:"currentColor"}),u.map((c,l)=>Ce("line",{x1:c.x1,y1:c.y1,x2:c.x2,y2:c.y2,stroke:"currentColor",strokeWidth:c.main?6:3,strokeLinecap:"round",opacity:c.main?1:.5},l))]})}import{useState as rr}from"react";import{jsx as ae,jsxs as Be}from"react/jsx-runtime";function or({customerEmail:e}){let{coupon:t,applyCoupon:n,removeCoupon:r,couponBusy:o}=wt(),[i,a]=rr("");async function u(){o||!i.trim()||(await n(i,e),a(""))}return Be("div",{className:"flex flex-col gap-2",children:[t===null?Be("div",{className:"flex border border-line",children:[ae("input",{type:"text",value:i,onChange:c=>a(c.target.value),onKeyDown:c=>{c.key==="Enter"&&(c.preventDefault(),u())},placeholder:"Coupon code","aria-label":"Coupon code",className:"flex-1 bg-transparent px-3.5 py-3.5 font-mono text-[11px] uppercase tracking-[0.18em] text-fg outline-none placeholder:text-fg-dim"}),ae("button",{type:"button",onClick:()=>{u()},disabled:o,className:"border-l border-line px-4 font-mono text-[10px] uppercase tracking-[0.26em] text-btn transition-colors hover:bg-btn hover:text-btn-ink disabled:cursor-wait disabled:opacity-60",children:o?"\u2026":"Apply"})]}):Be("div",{className:["flex items-center justify-between gap-3 border px-3.5 py-3",t.valid?"border-accent":"border-line"].join(" "),style:t.valid?{background:"color-mix(in oklab, var(--accent) 8%, transparent)"}:void 0,children:[ae("span",{className:["font-mono text-[11px] uppercase tracking-[0.22em]",t.valid?"text-accent":t.deferred?"text-fg":"text-fg-dim line-through"].join(" "),children:t.code}),ae("button",{type:"button",onClick:r,"aria-label":`Remove coupon ${t.code}`,className:"font-mono text-[12px] text-fg-dim transition-colors hover:text-fg",children:"\u2715"})]}),t?.deferred?ae("p",{className:"font-mono text-[10px] uppercase tracking-[0.18em] text-fg-dim",children:pt}):t&&!t.valid&&t.message&&ae("p",{className:"font-mono text-[10px] uppercase tracking-[0.18em] text-alert",children:t.message})]})}function Qo(){let e=typeof crypto<"u"?crypto:void 0;if(typeof e?.randomUUID=="function")return e.randomUUID();let t=new Uint8Array(16);if(typeof e?.getRandomValues=="function")e.getRandomValues(t);else for(let r=0;r<t.length;r++)t[r]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=Array.from(t,r=>r.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}export{Cr as a,xr as b,Sr as c,it as d,Me as e,ir as f,ar as g,sr as h,lr as i,Yt as j,jt as k,ur as l,cr as m,De as n,Oe as o,pe as p,Pe as q,rn as r,Ue as s,Ir as t,wr as u,an as v,Lr as w,Nr as x,sn as y,Tr as z,un as A,_r as B,kr as C,yt as D,Fr as E,Ur as F,$r as G,gr as H,dt as I,Ie as J,qe as K,Qr as L,wt as M,fo as N,Rn as O,go as P,Dn as Q,On as R,Io as S,wo as T,Lo as U,No as V,zn as W,Gn as X,Yn as Y,Fo as Z,Ut as _,Uo as $,Qn as aa,$o as ba,Zn as ca,er as da,tr as ea,or as fa,Qo as ga};
1
+ import{f as nt,i as fe,p as rt,r as ot,t as q}from"./chunk-JPFTZUGS.js";import{Ma as me,Na as Ze,Qa as Ae,Ra as et}from"./chunk-YOLBILEW.js";import{e as Je,r as tt,t as re}from"./chunk-TY6TWI3F.js";import{createContext as Qt,useContext as Xt,useEffect as Jt,useMemo as ge,useState as st}from"react";function it(e,t){return e.map(n=>({partNumber:n.partNumber,quantity:n.wheels*t}))}function oe(e,t){if(e.length===0)return null;let n=0;for(let r of e){let o=r.prices?.[t];if(typeof o!="number"||!Number.isFinite(o)||o<=0)return null;n+=o*r.wheels}return n}var Me=4,ir=1,ar={unit:"set",spares:0,spareSide:"left"};function at(e){return e.unit==="single"?1:Me+e.spares}function sr(e,t){return[{partNumber:e.partNumber,wheels:at(t),prices:e.prices}]}function lr(e,t){let n=at(t)-Me;if(n<=0||e.length===0)return e;let r=Yt(e),o=r?r[t.spareSide]:0;return e.map((i,a)=>a===o?{...i,wheels:i.wheels+n}:i)}function Yt(e){let t,n;for(let r=0;r<e.length;r+=1){let o=e[r].hand;if(o!=="left"&&o!=="right")continue;if((o==="left"?t:n)!==void 0)return null;o==="left"?t=r:n=r}return t!==void 0&&n!==void 0?{left:t,right:n}:null}function jt(e,t){return t.spares>0?`${e} + spare`:e}function ur(e){return e.unit==="single"?"Single":jt(`Set of ${Me}`,e)}var cr="data-add-to-basket",De=9,Oe="en";function pe(e,t,n=0){return new Intl.NumberFormat(Oe,{style:"currency",currency:t,minimumFractionDigits:0,maximumFractionDigits:n}).format(e)}import{jsx as tn}from"react/jsx-runtime";var lt="storefront-country",ut=Qt(null);function Zt(e){return ct(e,"catalogue")}function en(e){return ct(e,"money")}function ct(e,t){let n=new Map(e.map(o=>[o.code,o.decimalPlaces])),r=new Map;return(o,i)=>{if(!i)return"";let a=r.get(i);if(!a){let u=n.get(i)??0;a=new Intl.NumberFormat(Oe,{style:"currency",currency:i,minimumFractionDigits:t==="money"?u:0,maximumFractionDigits:u}),r.set(i,a)}return a.format(o)}}function gr({children:e,currencies:t,countries:n,defaultCurrency:r,defaultCountry:o}){let i=ge(()=>t??[],[t]),a=ge(()=>n??[],[n]),u=ge(()=>r||i.find(C=>C.isDefault)?.code||i[0]?.code||"",[r,i]),c=ge(()=>o||a.find(C=>C.isDefault)?.code||a[0]?.code||"",[o,a]),[l,d]=st(c),[f,P]=st(!1);Jt(()=>{let C=re.getItem(lt);C&&a.some(I=>I.code===C)&&d(C),P(!0)},[a]);function L(C){d(C),re.setItem(lt,C)}let h=ge(()=>{let C=a.find(w=>w.code===l)??null,I=C?.currency,T=I&&i.some(w=>w.code===I)?I:u,M=Zt(i),x=en(i);return{country:l,currency:T,setCountry:L,currencies:i,countries:a,activeCountry:C,formatPrice:(w,S)=>M(w,S??T),formatMoney:(w,S)=>x(w,S??T),ready:f}},[l,i,a,u,f]);return tn(ut.Provider,{value:h,children:e})}function dt(){let e=Xt(ut);if(!e)throw new Error("useCurrency must be used within a CurrencyProvider");return e}import{createContext as pn,useCallback as k,useContext as gn,useEffect as Y,useMemo as St,useRef as ie,useState as R}from"react";function ft(e,t){return e.valid?!1:e.reason==="firstOrderOnly"?!0:e.reason==="notEligible"&&!t}var pt="We'll confirm this discount when you place your order.",Cr="Confirmed at checkout";function xr(e){return e&&(e.valid||e.deferred)?e.code:void 0}var mt="coupon_code: ";function Sr(e){return!(e instanceof fe)||e.status!==400||!e.message.startsWith(mt)?null:e.message.slice(mt.length)}function gt(e,t){return e.map(n=>({qty:n.qty,slug:n.slug,name:`${n.name.lead}${n.name.accent}`.trim(),finish:n.finishName,size:n.size,kind:n.kind,sku:n.sku,pack:n.pack,priceLabel:t(n)}))}var Pe="Price on request",rn="Request a quote";function Fe(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Ue(e,t){let n=e?.[t];return Fe(n)?n:null}function Ir(e,t,n,r){let o=Ue(e,n),i=Ue(t,n);return o===null&&i===null?0:o===null?1:i===null?-1:r==="asc"?o-i:i-o}function wr(e,t,n,r){if(n==null&&r==null)return!0;let o=Ue(e,t);return!(o===null||n!=null&&o<n||r!=null&&o>r)}var on={priced:!1,unit:null,was:null,onSale:!1,setTotal:null};function an(e,t,n){if(!Fe(e))return on;let r=Fe(t)&&t>e?t:null;return{priced:!0,unit:e,was:r,onSale:r!==null,setTotal:n!=null?e*n:null}}function Lr(e,t,n=""){return!e.priced||e.unit==null?Pe:`${n}${pe(e.unit,t)}`}function Nr(e,t){return e.was==null?null:pe(e.was,t)}function sn(e,t,n=1){let r=oe(e,t);if(r===null)return{priced:!1,unit:null,isFrom:!1,setTotal:null};let o=e.reduce((a,u)=>a+u.wheels,0),i=Math.min(...e.map(a=>a.prices[t]));return{priced:!0,unit:i,isFrom:i*o!==r,setTotal:r*n}}var ln={priced:!1,unit:null,isFrom:!1,was:null,onSale:!1,setTotal:null};function Tr(e,t,n,r=1){let o=an(e.prices[n],e.msrpPrices?.[n],4),i=o.setTotal==null?null:o.setTotal*r;if(!t)return{priced:o.priced,unit:o.unit,isFrom:!0,was:o.was,onSale:o.onSale,setTotal:null,fromSetTotal:i};let a=sn(t.components,n,r);return a.priced?{priced:!0,unit:a.unit,isFrom:a.isFrom,was:null,onSale:!1,setTotal:a.setTotal,fromSetTotal:i}:{...ln,fromSetTotal:i}}function un(e,t){return!e.priced||e.unit==null?Pe:`${e.isFrom?"from ":""}${pe(e.unit,t)}`}function _r(e,t){return e.was==null?null:pe(e.was,t)}function kr(e,t){return!e.priced||e.unit==null?rn:un(e,t)}var cn=/^[^@\s]+@[^@\s]+\.[^@\s]+$/;function yt(e){return cn.test(e.trim())}var bt="sf:ga-purchases",dn=20;function Ct(){return typeof window>"u"||window.parent!==window}function ye(...e){try{if(Ct()||typeof window.gtag!="function")return;window.gtag(...e)}catch{}}function mn(e,t){let n=e.config.find(r=>r.gold)?.label;return{item_id:`${e.slug}|${e.finishName}|${e.size}`,item_name:`${e.name.lead}${e.name.accent}`.trim(),...n?{item_variant:n}:{},price:oe(e.components,t)??0,quantity:e.qty}}function $e(e,t){return e.filter(Ie).map(n=>mn(n,t))}function Fr(e){ye("event","view_item",{currency:e.currency,value:e.pricePerSet,items:[{item_id:e.itemId,item_name:e.itemName,...e.variant?{item_variant:e.variant}:{},price:e.pricePerSet,quantity:1}]})}function xt(e,t){let n=$e([e],t);n.length!==0&&ye("event","add_to_cart",{currency:t,value:n[0].price*n[0].quantity,items:n})}function Ur(e){let t=$e(e.lines,e.currency);t.length!==0&&ye("event","begin_checkout",{currency:e.currency,value:e.value,...e.coupon?{coupon:e.coupon}:{},items:t})}var ht=new Set;function fn(e){if(ht.has(e))return!1;ht.add(e);try{let t=JSON.parse(re.getItem(bt)??"[]");if(t.includes(e))return!1;re.setItem(bt,JSON.stringify([...t,e].slice(-dn)))}catch{}return!0}function $r(e){let t=e.confirmation;if(Ct()||!fn(t.orderNumber))return;let n=t.currency,r=Number(t.grandTotal);ye("event","purchase",{transaction_id:t.orderNumber,currency:n,value:r,shipping:Number(t.freightCharge),...t.couponCode?{coupon:t.couponCode}:{},items:$e(e.lines,n)}),e.adsSendTo&&ye("event","conversion",{send_to:e.adsSendTo,transaction_id:t.orderNumber,currency:n,value:r})}import{jsx as Cn}from"react/jsx-runtime";var yn=400,bn=400,hn=1500;function Ie(e){return(e.components?.length??0)>0}function vt(e,t){return{code:e,valid:t.valid,deferred:ft(t,t.askedAsShopper),message:t.message||void 0,effects:t.effects??void 0}}function Pt(e,t){return oe(e.components,t)}function qe(e,t){let n=Pt(e,t);return n===null?null:n*e.qty}function Et(e){return e!=="tyre"}var It=pn(null);function Qr({children:e,preview:t=!1}){let{currency:n,country:r,formatMoney:o}=dt(),[i,a]=R(t),[u,c]=R([]),[l,d]=R([]),[f,P]=R([]),[L,h]=R(!1),[C,I]=R(!1),[T,M]=R(!1),[x,w]=R(!1),[S,K]=R(null),[W,Q]=R(void 0),b=ie(r),v=ie("");b.current=b.current||r;let[m,H]=R(null),[X,z]=R(!1),[A,J]=R(null),Z=ie(void 0),D=k(()=>a(!0),[]),xe=k(()=>a(!1),[]),O=k(()=>a(s=>!s),[]);Y(()=>{t||typeof window>"u"||new URLSearchParams(window.location.search).get("cart")==="open"&&D()},[D,t]);let Se=k(s=>{w(!0),Et(s)&&M(!0)},[]),ee=T||u.some(s=>Et(s.kind)),se=x||u.length>0;Y(()=>{if(t||!ee||L)return;let s=!0;return q.listWheels().then(p=>{s&&(d(p),h(!0))}),()=>{s=!1}},[t,ee,L]),Y(()=>{if(t||!se||C)return;let s=!0;return q.listBundles().then(p=>{s&&(P(p),I(!0))}),()=>{s=!1}},[t,se,C]);let U=S?.deliveryOptions??[];Y(()=>{U.length!==0&&J(s=>s&&U.some(p=>p.id===s)?s:U[0]?.id??null)},[S]);let V=k(()=>u.filter(Ie).flatMap(s=>it(s.components,s.qty)),[u]),le=k(async(s,p)=>{let y=s.trim().toUpperCase();if(!y)return;let g=V();if(g.length===0){H({code:y,valid:!1,message:"Add a wheel to the cart first."});return}z(!0),Z.current=p;try{let N=await q.validateCoupon({code:y,items:g,currency:n,shippingMethodId:A??void 0,customerEmail:p});H(vt(y,N))}catch{H({code:y,valid:!1,message:"Could not check that code. Please try again."})}finally{z(!1)}},[V,n,A]),te=k(()=>{H(null),Z.current=void 0},[]),ve=k(s=>{if(!m)return;let{code:p}=m;H(y=>y&&y.code===p?{code:p,valid:!1,refused:!0,message:s}:y)},[m]);Y(()=>{if(!m||m.refused)return;let s=m.code,p=g=>g!==null&&g.code===s&&!g.refused,y=setTimeout(async()=>{let g=V();if(g.length===0){H(N=>p(N)?{code:s,valid:!1,message:"Add a wheel to the cart first."}:N);return}z(!0);try{let N=await q.validateCoupon({code:s,items:g,currency:n,shippingMethodId:A??void 0,customerEmail:Z.current});H(de=>p(de)?vt(s,N):de)}catch{}finally{z(!1)}},yn);return()=>clearTimeout(y)},[u,n,A]);let ue=m&&!m.refused?m.code:void 0;Y(()=>{if(t)return;let s=!0,p=setTimeout(async()=>{let y=V();if(y.length===0){K(null),Q(void 0);return}try{let g=await q.quoteCart({items:y,currency:n,shippingMethodId:A??void 0,couponCode:ue,customerEmail:Z.current||void 0,country:b.current||void 0,subdivision:v.current||void 0});if(!s)return;K(g)}catch{if(!s)return}Q(ue)},bn);return()=>{s=!1,clearTimeout(p)}},[u,n,A,ue,r]);let E=k(s=>{c(p=>{let y=p.findIndex(g=>g.id===s.id);return y===-1?[...p,s]:p.map((g,N)=>N===y?{...g,qty:Math.min(De,g.qty+s.qty)}:g)}),xt(s,n)},[n]),F=k(s=>{c(p=>p.filter(y=>y.id!==s))},[]),G=k((s,p)=>{let y=Math.max(1,Math.min(De,p));c(g=>g.map(N=>N.id===s?{...N,qty:y}:N))},[]),ze=k(s=>{c(s)},[]),[ce,Kt]=R(null),Ve=ie(null);Ve.current=ce;let $=ie(null),ke=ie(""),Ge=k((s,p)=>{let y=s.trim().toLowerCase();yt(y)&&Kt(g=>g&&g.email===y&&g.firstName===(p??"")?g:{email:y,firstName:p??""})},[]);Y(()=>{if(t||!ce)return;let s=gt(u.filter(Ie),g=>qe(g,n)===null?Pe:o(qe(g,n),n)),p={email:ce.email,firstName:ce.firstName,currency:n,items:s},y=JSON.stringify(p);if(y!==ke.current)return $.current&&clearTimeout($.current),$.current=setTimeout(()=>{$.current=null,ke.current=y,q.captureCart(p).catch(g=>{})},hn),()=>{$.current&&(clearTimeout($.current),$.current=null)}},[u,ce,n,t]);let Ye=k(()=>{$.current&&(clearTimeout($.current),$.current=null);let s=Ve.current;s&&(ke.current="",q.captureCart({email:s.email,firstName:s.firstName,currency:n,items:[]}).catch(p=>{}))},[n]),je=St(()=>{let s=u.reduce((_,ne)=>{let Ee=qe(ne,n);return Ee===null?_:_+Ee},0),p=u.some(_=>Pt(_,n)===null),y=u.reduce((_,ne)=>_+ne.qty,0),g=m?.valid?m.effects:void 0,N=g?Math.min(s,Number(g.discountAmount)):0,de=S?.bundleDiscount??0,Wt=S?.appliedBundles??[],Qe=!!g?.freeShipping,Bt=U.find(_=>_.id===A),Xe=Qe?0:S?.shipping??Bt?.amount??0,Re={};for(let _ of g?.freeUnits??[])Re[_.partNumber]=(Re[_.partNumber]??0)+_.quantity;let zt=S?.tax??null,Vt=S?S.grandTotal:s-N-de+Xe;return{sets:y,units:u.reduce((_,ne)=>_+(ne.components??[]).reduce((Ee,Gt)=>Ee+Gt.wheels*ne.qty,0),0),subtotal:s,hasUnpricedLine:p,discount:N,bundleDiscount:de,appliedBundles:Wt,shipping:Xe,freeShipping:Qe,freeUnitsByPartNumber:Re,tax:zt,grand:Vt,repricing:!!m?.refused&&S!==null&&W===m?.code,currency:n}},[u,n,m,U,A,S,W]),Ht=St(()=>({isOpen:i,preview:t,open:D,close:xe,toggle:O,items:u,catalog:l,bundles:f,warmCatalog:Se,add:E,remove:F,setQty:G,replaceItems:ze,identify:Ge,clearCapturedCart:Ye,coupon:m,applyCoupon:le,removeCoupon:te,refuseCoupon:ve,couponBusy:X,deliveryOptions:U,shippingMethodId:A,setShippingMethodId:J,totals:je}),[i,t,D,xe,O,u,l,f,Se,E,F,G,ze,Ge,Ye,m,le,te,ve,X,U,A,je]);return Cn(It.Provider,{value:Ht,children:e})}function wt(){let e=gn(It);if(!e)throw new Error("useCart() must be called inside <CartProvider>. Mount the provider in app/layout.tsx.");return e}import{cache as _n}from"react";function Lt(e,t,n,r){for(;e.size>=t;){let o,i;for(let[u,c]of e){if(c.expiresAt<=r){o=u;break}i===void 0&&n(u)&&(i=u)}let a=o??i??e.keys().next().value;if(a===void 0)return;e.delete(a)}}var xn=6e4,Sn=5e3,vn=500,we=new Map;async function En(e){let{host:t,matchesRequestHost:n}=await rt();if(!t)return"";let r=await ot();return r?`${e}|slug:${encodeURIComponent(t)}/${encodeURIComponent(r)}`:n?`${e}|host:${t}`:`${e}|xhost:${t}`}var Pn=e=>e.includes("|slug:")||e.includes("|xhost:");async function Nt(e,t){let n=await En(e);if(!n)return t();let r=Date.now(),o=we.get(n);if(o&&o.expiresAt>r)return o.load;let i=await t(),a=i.outcome.state==="failed",u=a?Sn:xn,c=we.get(n)?.lastGood,l=i.outcome.state==="ok"?i:a?c:void 0,d=a&&l?l:i;return Lt(we,vn,Pn,r),we.set(n,{load:d,expiresAt:r+u,lastGood:l}),d}var In=404;function wn(e){if(e instanceof fe&&e.status===In)return{state:"absent"};let t=e instanceof fe?e.status:-1,n=e instanceof Error?e.message:String(e);return{state:"failed",status:t,detail:n}}var Ln="[storefront:chrome-load-failed]";function Nn(e,t){console.error(`${Ln} ${e} status=${t.status} \u2014 serving fallback chrome`,t.detail)}async function Tt(e,t,n,r){try{let o=await t();return r?.(o)?{value:o,outcome:{state:"absent"}}:{value:o,outcome:{state:"ok"}}}catch(o){let i=wn(o);return i.state==="failed"&&Nn(e,i),{value:n,outcome:i}}}function Tn(e){return e==="production"?"silent":"banner"}var oo=Tn("production");function kn(e,t){return e?.trim()||t}function fo({legalName:e,foundedYear:t,siteName:n},r=new Date().getFullYear()){let o=kn(e,n);return`\xA9 ${t&&t<r?`${t}\u2013${r}`:`${r}`} ${o}`}var Rn={name:me,legalName:null,foundedYear:null,faviconUrl:null,currencies:[],defaultCurrency:null,countries:[],defaultCountry:null,commerceEnabled:!0,cardPayments:!1,paymentMethods:[],paypalClientId:null,paypalEnvironment:null,squareApplicationId:null,squareLocationId:null,squareEnvironment:null,ga4MeasurementId:null,googleAdsId:null,googleAdsConversionLabel:null,metaPixelId:null,mapsApiKey:null,mapsMapId:null,socialLinks:Ae},po=_n(async()=>Nt("site",()=>Tt("site",async()=>{let e=await q.getSite();return{name:Ze(e.name),legalName:e.legalName?.trim()||null,foundedYear:e.foundedYear??null,faviconUrl:e.faviconUrl??null,currencies:e.currencies??[],defaultCurrency:e.defaultCurrency??null,countries:e.countries??[],defaultCountry:e.defaultCountry??null,commerceEnabled:e.commerceEnabled??!0,cardPayments:e.cardPayments??!1,paymentMethods:e.paymentMethods??(e.cardPayments?["card"]:[]),paypalClientId:e.paypalClientId??null,paypalEnvironment:e.paypalEnvironment??null,squareApplicationId:e.squareApplicationId??null,squareLocationId:e.squareLocationId??null,squareEnvironment:e.squareEnvironment??null,ga4MeasurementId:e.ga4MeasurementId??null,googleAdsId:e.googleAdsId??null,googleAdsConversionLabel:(e.googleAdsId?e.googleAdsConversionLabel:null)??null,metaPixelId:e.metaPixelId??null,mapsApiKey:e.mapsApiKey??null,mapsMapId:e.mapsMapId??null,socialLinks:et(e.socialLinks)}},Rn)));var go={name:me,legalName:null,foundedYear:null,faviconUrl:null,currencies:[{code:"USD",symbol:"$",decimalPlaces:2,isDefault:!0}],defaultCurrency:"USD",countries:[{code:"US",name:"United States",currency:"USD",url:"",isDefault:!0,chargeTax:!1,taxDisplay:"none",taxName:"",taxRate:null,postalLabel:"Zip Code"}],defaultCountry:"US",commerceEnabled:!0,cardPayments:!0,paymentMethods:["card"],paypalClientId:null,paypalEnvironment:null,squareApplicationId:null,squareLocationId:null,squareEnvironment:null,ga4MeasurementId:null,googleAdsId:null,googleAdsConversionLabel:null,metaPixelId:null,mapsApiKey:null,mapsMapId:null,socialLinks:Ae};import{jsx as kt,jsxs as Rt}from"react/jsx-runtime";import{useEffect as Le,useRef as At,useState as Ne}from"react";var be=new Map,An=64;async function Mn(e){if(!Je())return null;try{let t=await fetch(`${tt()}/logo-analysis.json?url=${encodeURIComponent(e)}`);if(!t.ok)return null;let n=await t.json();if(!n||typeof n!="object")return null;let{reversed:r,inkIsDark:o}=n;return typeof r!="string"?null:{reversed:r,inkIsDark:typeof o=="boolean"?o:null}}catch{return null}}function _t(e){let t=be.get(e);if(t)return t;let n=Mn(e);if(be.set(e,n),be.size>An){let r=be.keys().next();r.done||be.delete(r.value)}return n}var Dn={small:54,medium:66,large:84},On=44,Fn=202/22,Io=16,wo=140,Un=.88,Lo=16,$n="invert(1)";function No({variant:e="header",scrolled:t=!0,src:n,reverse:r=!1,onLightSurface:o,reversedSrc:i,inkIsDark:a,size:u="medium",sizePx:c,wordmark:l,siteName:d=me,fitToContainer:f=!1,fitWordmarkToContainer:P=!1,fitFloorPx:L}){let h=l&&l.trim()?l.trim():d,[C,I]=Ne(!1),T=At(null),M=E=>{T.current=E};Le(()=>{let E=T.current?.ownerDocument??document,F=()=>{I(E.documentElement.getAttribute("data-theme")==="light")};F();let G=new MutationObserver(F);return G.observe(E.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>G.disconnect()},[]);let x=n&&n.trim()?n.trim():null,w=!!x&&nt(x),S=o??(C&&t),K=r&&w&&x&&i!=null?{reversed:i,inkIsDark:a??null}:null,W=K!==null,[Q,b]=Ne(null);Le(()=>{if(!r||!x||!w||W){b(null);return}let E=!1;return b(null),_t(x).then(F=>{E||b(F)}),()=>{E=!0}},[r,x,w,W]);let v=K??Q,m=!!v&&v.inkIsDark!==null&&(S?!v.inkIsDark:v.inkIsDark),H=r&&!!x&&!w&&!S,X=m&&v?v.reversed:x,z=X?[X]:[],[A,J]=Ne(0);Le(()=>{J(0)},[x,m]);let Z=e==="footer"?On:Dn[u],D=c&&c>0?c:Z,xe=Math.round(D*Fn),O=A<z.length?z[A]:null,[Se,ee]=Ne(X),se=O!==null&&O===Se,U=At(null);Le(()=>{let E=U.current;if(!E||!E.complete)return;if(E.naturalWidth>0||E.naturalHeight>0){ee(O);return}let F=!1;return E.decode().then(()=>!F&&ee(O),()=>!F&&J(G=>G+1)),()=>{F=!0}},[O]);let V=f||P,le=`calc(100cqi / ${((h.length+1)*Un).toFixed(2)})`,te=V&&L&&L>0?Math.min(L,D):null,ve=V?te===null?`min(${D}px, ${le})`:`clamp(${te}px, ${le}, ${D}px)`:`${D}px`,ue=Rt("span",{className:`font-display font-bold tracking-[0.18em] ${te===null?"whitespace-nowrap":"whitespace-normal"}`,style:{fontSize:ve,lineHeight:1},"aria-label":h,children:[h,kt("span",{className:"text-accent",children:"."})]});return Rt("span",{ref:M,className:"inline-flex items-center",children:[!se&&ue,O&&kt("img",{ref:U,src:O,alt:h,width:xe,height:D,className:"shrink-0 object-contain",style:{...se?{height:`${D}px`,width:"auto",...f?{maxWidth:"100cqi"}:{}}:{display:"none"},...H?{filter:$n}:{}},onLoad:()=>ee(O),onError:()=>J(E=>E+1)},O)]})}import{Children as Kn,isValidElement as Hn,useEffect as Dt,useId as Wn,useLayoutEffect as Bn,useRef as j,useState as Ot}from"react";var Te=(e,t)=>!!e[t]&&!e[t].disabled;function Ke(e,t,n){let r=e.length;for(let o=1;o<=r;o++){let i=((t+n*o)%r+r)%r;if(Te(e,i))return i}return t}function He(e,t){return Ke(e,t===1?-1:e.length,t)}function We(e,t){return Te(e,t)?t:Math.max(He(e,1),0)}function Mt(e,t,n){let{open:r,focus:o}=e,i=a=>({...e,...a});if(t.length===1&&/\S/.test(t)){let a=e.typed+t.toLowerCase(),u=n.findIndex((c,l)=>Te(n,l)&&c.label.toLowerCase().startsWith(a));return{state:i({open:!0,typed:a,focus:u>=0?u:o}),handled:!0}}if(!r)return t==="ArrowDown"||t==="ArrowUp"||t==="Enter"||t===" "?{state:i({open:!0,typed:""}),handled:!0}:{state:e,handled:!1};switch(t){case"ArrowDown":return{state:i({focus:Ke(n,o,1)}),handled:!0};case"ArrowUp":return{state:i({focus:Ke(n,o,-1)}),handled:!0};case"Home":return{state:i({focus:He(n,1)}),handled:!0};case"End":return{state:i({focus:He(n,-1)}),handled:!0};case"Enter":case" ":return Te(n,o)?{state:i({open:!1,typed:""}),commit:o,refocus:!0,handled:!0}:{state:e,handled:!0};case"Escape":return{state:i({open:!1,typed:""}),refocus:!0,handled:!0};case"Tab":return{state:i({open:!1,typed:""}),handled:!1};default:return{state:e,handled:!1}}}import{Fragment as jn,jsx as B,jsxs as Ft}from"react/jsx-runtime";function zn({items:e,value:t,onPick:n,open:r,onOpen:o,onClose:i}){let[a,u]=Ot(!1),c=r!==void 0,l=c?r:a,[d,f]=Ot(0),P=j({text:"",timer:0}),L=j(null),h=j(null),C=j(null),I=Wn(),T=j(null),M=e.findIndex(b=>b.value===t),x=b=>{b!==l&&(c||u(b),b?o?.():i?.())},w=b=>{let v=e[b];!v||v.disabled||(n(v.value),x(!1),h.current?.focus())},S=b=>{let v={open:l,focus:l?d:We(e,M),typed:P.current.text},m=Mt(v,b,e);return!m.handled&&m.state.open===l?!1:(m.state.typed!==v.typed&&(P.current.text=m.state.typed,window.clearTimeout(P.current.timer),P.current.timer=window.setTimeout(()=>{P.current.text=""},500)),f(m.state.focus),m.commit!==void 0?w(m.commit):x(m.state.open),m.refocus&&h.current?.focus(),m.handled)},K=j(S);K.current=S;let W=j(()=>x(!1));W.current=()=>x(!1);let Q=b=>{l||(T.current=b.nativeEvent,K.current(b.key)&&b.preventDefault())};return Dt(()=>{if(!l)return;let b=m=>{L.current?.contains(m.target)||W.current()},v=m=>{m!==T.current&&K.current(m.key)&&m.preventDefault()};return document.addEventListener("mousedown",b),document.addEventListener("keydown",v),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",v)}},[l]),Dt(()=>{l&&(P.current.text||f(We(e,M)))},[l]),Bn(()=>{if(!l||!C.current)return;C.current.children.item(d)?.scrollIntoView({block:"nearest"})},[d,l]),{open:l,toggle:()=>x(!l),close:()=>x(!1),focusIdx:d,setFocusIdx:f,pick:b=>w(e.findIndex(v=>v.value===b)),wrapRef:L,triggerRef:h,listRef:C,listId:I,onTriggerKeyDown:Q,activeId:l?`${I}-${d}`:void 0}}var Vn={select:{list:"absolute left-0 top-full z-50 mt-1 max-h-[280px] w-max min-w-full overflow-y-auto border-2 border-accent bg-bg shadow-xl",item:(e,t,n)=>["px-3 py-2.5 font-mono text-[13px] font-semibold uppercase tracking-[0.1em] transition-colors whitespace-nowrap",n?"cursor-not-allowed opacity-40":"cursor-pointer",e&&!n?"bg-accent text-bg":"bg-bg text-fg"].join(" ")},cell:{list:"absolute left-0 top-full z-50 mt-1 max-h-[320px] w-max min-w-full overflow-y-auto border-2 border-accent bg-bg shadow-xl",item:e=>["cursor-pointer whitespace-nowrap px-6 py-3 font-mono text-[length:var(--size-label,13px)] font-semibold uppercase tracking-[0.1em] transition-colors",e?"bg-accent text-bg":"bg-bg text-fg"].join(" "),pickerMarker:!0},hairline:{list:"absolute left-0 top-full z-50 max-h-[320px] w-full overflow-y-auto border border-line bg-bg shadow-[0_6px_20px_rgba(0,0,0,0.10)]",item:(e,t)=>["flex cursor-pointer items-center justify-between gap-4 border-b border-line px-4 py-3 text-left text-[length:var(--size-body,14px)] transition-colors last:border-b-0",t?"border-fg font-medium text-fg":e?"border-fg text-fg":"text-fg-dim"].join(" "),pickerMarker:!0},region:{list:"absolute right-0 top-full z-[200] mt-2 flex min-w-[240px] flex-col border border-line bg-surface text-fg",item:(e,t,n,r)=>["flex w-full cursor-pointer items-center gap-3 px-3.5 py-3 text-left transition-colors","font-mono text-[13px] uppercase tracking-[0.18em]",e?"bg-surface-2 text-fg":"",r?"":"border-b border-line",t?"text-accent":""].join(" "),itemStyle:e=>e?void 0:{color:"color-mix(in oklab, currentColor 80%, transparent)"}}};function Gn({id:e,tone:t,items:n,value:r,focusIdx:o,onFocus:i,onPick:a,listRef:u,ariaLabel:c}){let l=Vn[t];return B("ul",{ref:u,id:e,role:"listbox","aria-label":c,...l.pickerMarker?{"data-picker-menu":""}:{},className:l.list,children:n.map((d,f)=>{let P=d.value===r;return B("li",{id:`${e}-${f}`,role:"option","aria-selected":P,"aria-disabled":d.disabled||void 0,onMouseEnter:()=>!d.disabled&&i(f),onMouseDown:L=>{L.preventDefault(),d.disabled||a(d.value)},className:l.item(f===o,P&&d.value!=="",!!d.disabled,f===n.length-1),style:l.itemStyle?.(P),children:d.meta===void 0?d.label:Ft(jn,{children:[B("span",{className:"flex-1 whitespace-nowrap",children:d.label}),B("span",{className:"ml-auto text-[12px] opacity-50",children:d.meta})]})},`${d.value}_${f}`)})})}function Yn({value:e,onChange:t,disabled:n,children:r,className:o,style:i,name:a,id:u,"aria-label":c}){let l=Kn.toArray(r).flatMap(h=>{if(!Hn(h))return[];if(h.type!=="option")return[];let I=h.props,T=I.value!==void 0?String(I.value):"",M=I.children,x=typeof M=="string"||typeof M=="number"?String(M):T;return[{value:T,label:x,disabled:!!I.disabled}]}),d=e??"",f=zn({items:l,value:d,onPick:h=>t?.({target:{value:h}})}),L=l.find(h=>h.value===d)?.label??l[0]?.label??"";return Ft("div",{ref:f.wrapRef,className:"relative",children:[a&&B("input",{type:"hidden",name:a,value:d}),B("button",{ref:h=>{f.triggerRef.current=h},type:"button",disabled:n,"aria-haspopup":"listbox","aria-expanded":f.open,"aria-controls":f.open?f.listId:void 0,"aria-activedescendant":f.activeId,"aria-label":c,id:u,onClick:()=>!n&&f.toggle(),onKeyDown:h=>!n&&f.onTriggerKeyDown(h),className:`block w-full ${o??""}`,style:i,children:B("span",{className:"block w-full truncate text-left",children:L})}),f.open&&B(Gn,{id:f.listId,tone:"select",items:l,value:d,focusIdx:f.focusIdx,onFocus:f.setFocusIdx,onPick:f.pick,listRef:f.listRef})]})}var Fo="#c9a461",Ut=[{f:"black",label:"Black",hex:"#171717"},{f:"silver",label:"Silver",hex:"#cccccc"},{f:"bronze",label:"Bronze",hex:"#8a6438"},{f:"graphite",label:"Graphite",hex:"#3a3c3f"},{f:"red",label:"Candy Red",hex:"#7a0f14"}],Uo={name:"",color:"var(--fg)",family:"silver",src:""};function Qn(e,t){let n=r=>{let o=Ut.findIndex(i=>i.f===r);return o===-1?Ut.length:o};return n(e)-n(t)||e.localeCompare(t)}function $o(e){let t=new Set;for(let n of e)for(let r of n.finishes??[])r?.family&&t.add(r.family);return[...t].sort(Qn)}import{jsx as he,jsxs as _e}from"react/jsx-runtime";var Xn="font-mono text-[length:var(--size-label,12px)]",Jn="font-semibold uppercase tracking-[0.22em] text-fg";function $t(e){return`${e??Xn} ${Jn}`}function qt(){return he("span",{className:"text-accent",children:" *"})}function Zn({children:e,required:t,labelFace:n}){return _e("span",{className:$t(n),children:[e,t?he(qt,{}):null]})}function er({label:e,required:t,hint:n,separate:r,htmlFor:o,labelFace:i,className:a,children:u}){let c=a?`flex flex-col gap-2 ${a}`:"flex flex-col gap-2",l=n?he("span",{className:"font-mono text-[11px] uppercase tracking-[0.22em] text-fg-dim",children:n}):null;return r||n?_e("div",{className:c,children:[_e("label",{htmlFor:o,className:$t(i),children:[e,t?he(qt,{}):null]}),u,l]}):_e("label",{htmlFor:o,className:c,children:[he(Zn,{required:t,labelFace:i,children:e}),u]})}import{jsx as Ce,jsxs as nr}from"react/jsx-runtime";function tr({spokes:e,mesh:t=!1,className:n}){let a=c=>Math.round(c*1e3)/1e3,u=[];for(let c=0;c<e;c++){let l=c/e*Math.PI*2-Math.PI/2;if(u.push({x1:a(100+Math.cos(l)*22),y1:a(100+Math.sin(l)*22),x2:a(100+Math.cos(l)*86),y2:a(100+Math.sin(l)*86),main:!0}),t){let d=l+Math.PI/e;u.push({x1:a(100+Math.cos(d)*22*1.4),y1:a(100+Math.sin(d)*22*1.4),x2:a(100+Math.cos(d)*78),y2:a(100+Math.sin(d)*78),main:!1})}}return nr("svg",{viewBox:"0 0 200 200",fill:"none",stroke:"currentColor",className:n??"block h-[70%] w-[70%] transition-transform duration-700 [transition-timing-function:cubic-bezier(.2,.6,.2,1)]",children:[Ce("circle",{cx:100,cy:100,r:92,strokeWidth:2}),Ce("circle",{cx:100,cy:100,r:84,strokeWidth:1,opacity:.4}),Ce("circle",{cx:100,cy:100,r:22,strokeWidth:2}),Ce("circle",{cx:100,cy:100,r:6,fill:"currentColor"}),u.map((c,l)=>Ce("line",{x1:c.x1,y1:c.y1,x2:c.x2,y2:c.y2,stroke:"currentColor",strokeWidth:c.main?6:3,strokeLinecap:"round",opacity:c.main?1:.5},l))]})}import{useState as rr}from"react";import{jsx as ae,jsxs as Be}from"react/jsx-runtime";function or({customerEmail:e}){let{coupon:t,applyCoupon:n,removeCoupon:r,couponBusy:o}=wt(),[i,a]=rr("");async function u(){o||!i.trim()||(await n(i,e),a(""))}return Be("div",{className:"flex flex-col gap-2",children:[t===null?Be("div",{className:"flex border border-line",children:[ae("input",{type:"text",value:i,onChange:c=>a(c.target.value),onKeyDown:c=>{c.key==="Enter"&&(c.preventDefault(),u())},placeholder:"Coupon code","aria-label":"Coupon code",className:"flex-1 bg-transparent px-3.5 py-3.5 font-mono text-[11px] uppercase tracking-[0.18em] text-fg outline-none placeholder:text-fg-dim"}),ae("button",{type:"button",onClick:()=>{u()},disabled:o,className:"border-l border-line px-4 font-mono text-[10px] uppercase tracking-[0.26em] text-btn transition-colors hover:bg-btn hover:text-btn-ink disabled:cursor-wait disabled:opacity-60",children:o?"\u2026":"Apply"})]}):Be("div",{className:["flex items-center justify-between gap-3 border px-3.5 py-3",t.valid?"border-accent":"border-line"].join(" "),style:t.valid?{background:"color-mix(in oklab, var(--accent) 8%, transparent)"}:void 0,children:[ae("span",{className:["font-mono text-[11px] uppercase tracking-[0.22em]",t.valid?"text-accent":t.deferred?"text-fg":"text-fg-dim line-through"].join(" "),children:t.code}),ae("button",{type:"button",onClick:r,"aria-label":`Remove coupon ${t.code}`,className:"font-mono text-[12px] text-fg-dim transition-colors hover:text-fg",children:"\u2715"})]}),t?.deferred?ae("p",{className:"font-mono text-[10px] uppercase tracking-[0.18em] text-fg-dim",children:pt}):t&&!t.valid&&t.message&&ae("p",{className:"font-mono text-[10px] uppercase tracking-[0.18em] text-alert",children:t.message})]})}function Qo(){let e=typeof crypto<"u"?crypto:void 0;if(typeof e?.randomUUID=="function")return e.randomUUID();let t=new Uint8Array(16);if(typeof e?.getRandomValues=="function")e.getRandomValues(t);else for(let r=0;r<t.length;r++)t[r]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=Array.from(t,r=>r.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}export{Cr as a,xr as b,Sr as c,it as d,Me as e,ir as f,ar as g,sr as h,lr as i,Yt as j,jt as k,ur as l,cr as m,De as n,Oe as o,pe as p,Pe as q,rn as r,Ue as s,Ir as t,wr as u,an as v,Lr as w,Nr as x,sn as y,Tr as z,un as A,_r as B,kr as C,yt as D,Fr as E,Ur as F,$r as G,gr as H,dt as I,Ie as J,qe as K,Qr as L,wt as M,fo as N,Rn as O,go as P,Dn as Q,On as R,Io as S,wo as T,Lo as U,No as V,zn as W,Gn as X,Yn as Y,Fo as Z,Ut as _,Uo as $,Qn as aa,$o as ba,Zn as ca,er as da,tr as ea,or as fa,Qo as ga};