efficient-storefront-blocks 0.133.1 → 0.133.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/chunks/{CustomHtmlCodeWindow-MZOYDJ5V.js → CustomHtmlCodeWindow-ZPYYAXIT.js} +1 -1
- package/dist/chunks/EditorPreviewCheckout-BYCGH5HR.js +4 -0
- package/dist/chunks/{SiteEditorProvider-NPIAZYL2.js → SiteEditorProvider-WZHTXNWZ.js} +1 -1
- package/dist/chunks/{chunk-6YESFEQM.js → chunk-I4IY2GTB.js} +5 -5
- package/dist/chunks/chunk-JBFEQFNX.js +1 -0
- package/dist/chunks/{chunk-HENI3WLW.js → chunk-MJ4NDWP7.js} +1 -1
- package/dist/chunks/chunk-RG2VEZZ7.js +9 -0
- package/dist/chunks/{chunk-DI3WYPQW.js → chunk-UQDOJWLM.js} +1 -1
- package/dist/editor/components/EditorPreviewCheckout.js +1 -1
- package/dist/index.js +26 -26
- package/dist/render/app/globals.css +6 -2
- package/dist/render/components/checkout/CheckoutPageClient.js +1 -1
- package/dist/render/components/checkout/checkout-parts.js +1 -1
- package/dist/render/components/checkout/checkout-state.d.ts +3 -1
- package/dist/render/components/checkout/checkout-state.js +3 -3
- package/dist/routine-index.json +1 -1
- package/dist/value-index.json +1 -1
- package/package.json +1 -1
- package/dist/chunks/EditorPreviewCheckout-ZZWN45X3.js +0 -4
- package/dist/chunks/chunk-GXZNWNY6.js +0 -1
- package/dist/chunks/chunk-Q77RRHES.js +0 -9
- /package/dist/chunks/{chunk-HENI3WLW.js.LEGAL.txt → chunk-MJ4NDWP7.js.LEGAL.txt} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{S as X,X as qt,_ as Gt,aa as Kt,ba as Vt,da as U,g as zt}from"./chunk-NQZ3O6A3.js";import{O as $t,aa as ot,ba as it,da as Ut,ka as st,la as Ht}from"./chunk-DI3WYPQW.js";import{j as q}from"./chunk-LN6M3FAM.js";import{ri as Pe,si as Bt,vf as Mt}from"./chunk-6YESFEQM.js";import{c as Wt}from"./chunk-454ZVMST.js";import{createContext as lr,useContext as nn,useEffect as ur,useMemo as Ee,useState as en}from"react";function Qt(e,t){return e.map(n=>({partNumber:n.partNumber,quantity:n.wheels*t}))}function he(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 at=4,Bo=1;function or(e){return e.spareAxle??"front"}var Ho={unit:"set",spares:0,spareSide:"left"};function Xt(e){return e.unit==="single"?1:at+e.spares}function jt(e,t){return[{partNumber:e.partNumber,wheels:Xt(t),prices:e.prices}]}function Zt(e,t){let n=Xt(t)-at;if(n<=0||e.length===0)return e;let r=ir(e),o=r?null:sr(e),i=r?r[t.spareSide]:o?o[t.spareSide][or(t)]:0;return e.map((s,a)=>a===i?{...s,wheels:s.wheels+n}:s)}function ir(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 sr(e){let t={};for(let s=0;s<e.length;s+=1){let{hand:a,axle:c}=e[s];if(a!=="left"&&a!=="right"||c!=="front"&&c!=="rear")return null;let u=`${a}-${c}`;if(t[u]!==void 0)return null;t[u]=s}let{"left-front":n,"left-rear":r,"right-front":o,"right-rear":i}=t;return n!==void 0&&r!==void 0&&o!==void 0&&i!==void 0?{left:{front:n,rear:r},right:{front:o,rear:i}}:null}function lt(e){let t=typeof e.spares=="number"?e.spares:e.spare?1:0;return{unit:e.unit,spares:t,spareSide:e.spareSide??"left",...e.spareAxle?{spareAxle:e.spareAxle}:{}}}function ut(e,t){return t.spares>0?`${e} + spare`:e}function Jt(e){return e.unit==="single"?"Single":ut(`Set of ${at}`,e)}var zo="data-add-to-basket",ct=9,ar="en",Yt=new Map;function He(e,t,n){let r=`${e}|${t??""}|${n??""}`,o=Yt.get(r);return o||(o=new Intl.NumberFormat(ar,{style:"currency",currency:e,...t===void 0?{}:{minimumFractionDigits:t},...n===void 0?{}:{maximumFractionDigits:n}}),Yt.set(r,o)),o}function te(e,t,n=0){return He(t,0,n).format(e)}function qo(e,t){return He(t).format(e)}function Go(e,t){let n=e.savings[t];if(n===void 0)return null;let r=te(n,t);return e.savingIsFrom?`Save from ${r}`:`Save ${r}`}import{jsx as pr}from"react/jsx-runtime";var cr="storefront-country",tn=cr,dt=lr(null);function dr(e){return rn(e,"catalogue")}function fr(e){return rn(e,"money")}function rn(e,t){let n=new Map(e.map(r=>[r.code,r.decimalPlaces]));return(r,o)=>{if(!o)return"";let i=n.get(o)??0;return He(o,t==="money"?i:0,i).format(r)}}function Xo({children:e,currencies:t,countries:n,defaultCurrency:r,defaultCountry:o}){let i=Ee(()=>t??[],[t]),s=Ee(()=>n??[],[n]),a=Ee(()=>r||i.find(g=>g.isDefault)?.code||i[0]?.code||"",[r,i]),c=Ee(()=>o||s.find(g=>g.isDefault)?.code||s[0]?.code||"",[o,s]),[u,m]=en(c),[C,p]=en(!1);ur(()=>{let g=q.getItem(tn);g&&s.some(N=>N.code===g)&&m(g),p(!0)},[s]);function R(g){m(g),q.setItem(tn,g)}let A=Ee(()=>{let g=s.find(b=>b.code===u)??null,N=g?.currency,L=N&&i.some(b=>b.code===N)?N:a,F=dr(i),v=fr(i);return{country:u,currency:L,setCountry:R,currencies:i,countries:s,activeCountry:g,formatPrice:(b,D)=>F(b,D??L),formatMoney:(b,D)=>v(b,D??L),ready:C}},[u,i,s,a,C]);return pr(dt.Provider,{value:A,children:e})}function on(e){let t=nn(dt);if(!t&&!e?.optional)throw new Error("useCurrency must be used within a CurrencyProvider");return t}function jo(){return nn(dt)?.country??""}import{createContext as Br,useCallback as w,useContext as Hr,useEffect as W,useMemo as wn,useRef as j,useState as P}from"react";function sn(){return"/edit"}function ln(e,t){return e.valid?!1:e.reason==="firstOrderOnly"?!0:e.reason==="notEligible"&&!t}var un="We'll confirm this discount when you place your order.",ni="Confirmed at checkout";function ri(e){return e&&(e.valid||e.deferred)?e.code:void 0}var an="coupon_code: ";function oi(e){return!(e instanceof X)||e.status!==400||!e.message.startsWith(an)?null:e.message.slice(an.length)}function ft(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 mr=["width","profile","rim"],ai={width:"Width",profile:"Profile",rim:"Rim"},gr=/^\s*(\d{2,3})\s*\/\s*(\d{2,3})\s*[A-Za-z]*\s*(\d{2}(?:\.\d+)?)\s*$/,yr={width:[100,500],profile:[20,100],rim:[10,30]};function pt(e){let t=gr.exec(e??"");if(!t)return null;let n={width:Number(t[1]),profile:Number(t[2]),rim:Number(t[3])};return mr.every(o=>{let[i,s]=yr[o];return n[o]>=i&&n[o]<=s})?n:null}function be(e){if(e.width==null)return"";if(e.profile==null)return String(e.width);let t=`${e.width}/${e.profile}`;return e.rim==null?t:`${t} R${e.rim}`}function li(e){return[be({width:e.width}),be({width:e.width,profile:e.profile}),be(e)]}function fi(e){if(!e||e.year===null)return null;let{make:t,model:n,year:r,modification:o}=e;return!t||!n||!o?null:{make:t,model:n,year:r,modification:o}}function br(e,t){let n=new URLSearchParams({make:t.make,model:t.model,year:String(t.year),modification:t.modification});return`/api/v1/tyres/${encodeURIComponent(e)}/fitment?${n.toString()}`}function ke(e,t=""){return{vehicle:{...e,region:t},status:"unknown",oemSizes:[],variants:[]}}function Cr(e,t){if(typeof t!="object"||t===null)return ke(e);let n=t,r=typeof n.vehicle=="object"&&n.vehicle!==null?n.vehicle:{},o=typeof r.region=="string"?r.region:"",i=n.status;if(i!=="fits"&&i!=="doesNotFit")return ke(e,o);let s=Array.isArray(n.variants)?n.variants.filter(a=>typeof a=="object"&&a!==null&&typeof a.sku=="string"&&typeof a.fits=="boolean"):[];return s.length===0?ke(e,o):{vehicle:{make:typeof r.make=="string"?r.make:e.make,model:typeof r.model=="string"?r.model:e.model,year:typeof r.year=="number"?r.year:e.year,modification:typeof r.modification=="string"?r.modification:e.modification,region:o},status:i,oemSizes:Array.isArray(n.oemSizes)?n.oemSizes.filter(a=>typeof a=="string"):[],variants:s.map(a=>({sku:a.sku,size:typeof a.size=="string"?a.size:"",fits:a.fits}))}}async function pi(e,t){try{let n=await qt(br(e,t),{baseUrl:""});return Cr(t,n)}catch(n){return n instanceof X&&n.status>=400&&n.status<500?ke(t):{...ke(t),failed:!0}}}function mi(e){if(!e)return[];let t=[];for(let n of[...e.frontTyres,...e.rearTyres]){let r=pt(n);if(!r)continue;let o=be(r);t.includes(o)||t.push(o)}return t}function gi(e,t){if(t.length===0)return null;for(let n of e){let r=pt(n);if(!r)continue;let o=be(r);if(t.includes(o))return o}return null}function xr(e,t){if(!e||e.status==="unknown")return"unknown";let n=e.variants.find(r=>r.sku===t);return n?n.fits?"fits":"doesNotFit":"unknown"}var Sr="/tyres";function cn(e){return e?`${Sr}/${e}`:null}function ze(e){let t=e.lastIndexOf(" ");return t===-1?{lead:"",accent:e}:{lead:e.slice(0,t+1),accent:e.slice(t+1)}}function vr(e,t){return jt({partNumber:e.sku,prices:e.prices},t)}var Pr="Tyre";function dn(e,t,n,r){return{id:`${e.slug}|${t.sku}|${n.unit}|${n.spares>0?"spare":"no-spare"}`,slug:e.slug,name:ze(e.name),process:e.brand||Pr,positionNo:"01",config:[{label:t.size},{label:Jt(n)}],finishName:"",size:t.size,components:vr(t,n),qty:r,href:cn(e.slug)??void 0,kind:"tyre",sku:t.sku,pack:n}}function Pi(e){return e.kind==="tyre"}function Ei(e,t){let n=e.prices?.[t];return typeof n!="number"||!Number.isFinite(n)||n<=0?!1:e.inStock}var Er="dually";function gt(e){let t=e.components.reduce((o,i)=>o+i.wheels,0)||4,n=e.kind,r=[n==="staggered"?"Staggered":n===Er?"Dually":""].filter(Boolean);return r.length?`${r.join(" ")} set of ${t}`:`Set of ${t}`}function kr(e,t){return[...new Set(e.filter(n=>!t||n.finishName===t).map(n=>n.size))]}function fn(e,t,n){if(!(!t||!n))return e.find(r=>r.finishName===t&&r.size===n)}function wr(e){return e!=null&&e.inStock===!1}function Ri(e,t){return t?e.filter(n=>n.finishName===t&&wr(n)):[]}function Ti(e,t,n){return t.findIndex((r,o)=>n[o]!==!1&&kr(e,r).length>0)}function Ai(e){let t=new Set((e.sizePairs??[]).map(o=>`${o.diameter}x${o.width}`)),n=e.spec?.pcds??[],r=e.spec?.etRange??[];return t.size===1&&n.length<=1&&(r.length===0||r[0]===r[r.length-1])}var mn="alloy-wheel",Rr="tyre";function qe(e){return e.name||e.slug||"An item from your cart"}async function gn(e,t){let n=[],r=new Map;for(let s of e){if(!s.slug){n.push(qe(s));continue}let a=s.kind??mn,c=`${a}\0${s.slug}`,u=r.get(c);u?u.snaps.push(s):r.set(c,{kind:a,slug:s.slug,snaps:[s]})}let o=await Promise.all([...r.values()].map(s=>Tr(s,t))),i=[];for(let s of o)for(let a of s)a.ok?i.push(a.line):n.push(a.name);return{lines:i,dropped:n}}function pn(e){if(e instanceof X&&e.status===404)return null;throw e}async function Tr(e,t){let n=e.snaps.map(r=>({ok:!1,name:qe(r)}));if(e.kind===mn){let r=await t.getWheel(e.slug).catch(pn);return r?e.snaps.map(o=>Ar(e.slug,r,o)):n}if(e.kind===Rr){let r=await t.getTyre(e.slug).catch(pn);return r?e.snaps.map(o=>Lr(r,o)):n}return n}function Ar(e,t,n){let r=fn(t.variants,n.finish,n.size);if(!r)return{ok:!1,name:qe(n)};let o=n.pack?lt(n.pack):void 0,i=(o?.spares??0)>0;return{ok:!0,line:{id:`${e}|${r.finishName}|${r.size}${i?"|spare":""}|restored`,slug:e,name:ze(t.name),process:t.process,positionNo:"01",config:[{label:r.size},{label:r.finishName,gold:!0},{label:o?ut(gt(r),o):gt(r)}],finishName:r.finishName,size:r.size,components:o&&i?Zt(r.components,o):r.components,qty:n.qty,...i?{pack:o}:{}}}}function Lr(e,t){let n={ok:!1,name:qe(t)};if(!t.pack||!t.sku)return n;let r=lt(t.pack),o=e.variants.find(i=>i.sku===t.sku);return o?{ok:!0,line:dn(e,o,r,t.qty)}:n}var Ge="Price on request",$i="Request a quote",yn="from ",Ui="From ",Wi="each",hn="Free",Bi="Updating";function yt(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function ht(e,t){let n=e?.[t];return yt(n)?n:null}function Hi(e,t,n,r){let o=ht(e,n),i=ht(t,n);return o===null&&i===null?0:o===null?1:i===null?-1:r==="asc"?o-i:i-o}function zi(e,t,n,r){if(n==null&&r==null)return!0;let o=ht(e,t);return!(o===null||n!=null&&o<n||r!=null&&o>r)}var Nr={priced:!1,unit:null,was:null,onSale:!1,setTotal:null};function _r(e,t,n){if(!yt(e))return Nr;let r=yt(t)&&t>e?t:null;return{priced:!0,unit:e,was:r,onSale:r!==null,setTotal:n!=null?e*n:null}}function qi(e,t,n=""){return!e.priced||e.unit==null?Ge:`${n}${te(e.unit,t)}`}function Gi(e,t){return e.was==null?null:te(e.was,t)}function Ir(e,t,n=1){let r=he(e,t);if(r===null)return{priced:!1,unit:null,isFrom:!1,setTotal:null};let o=e.reduce((s,a)=>s+a.wheels,0),i=Math.min(...e.map(s=>s.prices[t]));return{priced:!0,unit:i,isFrom:i*o!==r,setTotal:r*n}}var Or={priced:!1,unit:null,isFrom:!1,was:null,onSale:!1,setTotal:null};function Ki(e,t,n,r=1){let o=_r(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 s=Ir(t.components,n,r);return s.priced?{priced:!0,unit:s.unit,isFrom:s.isFrom,was:null,onSale:!1,setTotal:s.setTotal,fromSetTotal:i}:{...Or,fromSetTotal:i}}function Vi(e,t){return!e.priced||e.unit==null?Ge:`${e.isFrom?yn:""}${te(e.unit,t)}`}function Yi(e,t){return e.was==null?null:te(e.was,t)}function Qi(e,t){let n=e.savings[t];if(n===void 0||e.components.length===0)return null;let r=0;for(let i of e.components){let s=i.prices?.[t];if(typeof s!="number")return null;r+=s*i.quantity}let o=te(r-n,t);return{was:te(r,t),amount:e.savingIsFrom?`${yn}${o}`:o}}var Fr=/^[^@\s]+@[^@\s]+\.[^@\s]+$/;function bn(e){return Fr.test(e.trim())}var Cn="sf:ga-purchases",Dr=20;function Sn(){return typeof window>"u"||window.parent!==window}function we(...e){try{if(Sn()||typeof window.gtag!="function")return;window.gtag(...e)}catch{}}function Mr(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:he(e.components,t)??0,quantity:e.qty}}function bt(e,t){return e.filter(Re).map(n=>Mr(n,t))}function ts(e){we("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 vn(e,t){let n=bt([e],t);n.length!==0&&we("event","add_to_cart",{currency:t,value:n[0].price*n[0].quantity,items:n})}function ns(e){let t=bt(e.lines,e.currency);t.length!==0&&we("event","begin_checkout",{currency:e.currency,value:e.value,...e.coupon?{coupon:e.coupon}:{},items:t})}var xn=new Set;function $r(e){if(xn.has(e))return!1;xn.add(e);try{let t=JSON.parse(q.getItem(Cn)??"[]");if(t.includes(e))return!1;q.setItem(Cn,JSON.stringify([...t,e].slice(-Dr)))}catch{}return!0}function rs(e){let t=e.confirmation;if(Sn()||!$r(t.orderNumber))return;let n=t.currency,r=Number(t.grandTotal);we("event","purchase",{transaction_id:t.orderNumber,currency:n,value:r,shipping:Number(t.freightCharge),...t.couponCode?{coupon:t.couponCode}:{},items:bt(e.lines,n)}),e.adsSendTo&&we("event","conversion",{send_to:e.adsSendTo,transaction_id:t.orderNumber,currency:n,value:r})}var Ur="Arranged after review",Pn="Calculated at checkout",Wr=Pn,ss=Pn;function En({quoted:e,optionCount:t,chosenAmount:n,couponWaivesFreight:r}){return e&&t===0?"arranged":r?"free":n===void 0?"pending":n===0?"free":"charged"}function kn(e,t){return e*(100-t)/100}function as({discount:e,deliverySaving:t},n){return[e>0?`\u2212 ${n(e)}`:null,t>0?`${n(t)} off delivery`:null].filter(Boolean).join(" \xB7 ")}function ls(e){switch(e){case"arranged":return Ur;case"pending":return Wr;case"free":return hn;case"charged":return null}}import{jsx as Kr}from"react/jsx-runtime";var zr=400,qr=400,Gr=1500,Ct="storefront-cart";function Re(e){return(e.components?.length??0)>0}function Rn(e,t){return{code:e,valid:t.valid,deferred:ln(t,t.askedAsShopper),message:t.message||void 0,effects:t.effects??void 0}}function An(e,t){return he(e.components,t)}function xt(e,t){let n=An(e,t);return n===null?null:n*e.qty}function Tn(e){return e!=="tyre"}var Ln=Br(null);function Ps({children:e,preview:t=!1}){let{currency:n,country:r,formatMoney:o}=on(),[i,s]=P(t),[a,c]=P([]),[u,m]=P([]),[C,p]=P([]),[R,A]=P(!1),g=j(new Set),[N,L]=P([]),[F,v]=P(!1),[b,D]=P(null),[G,oe]=P(null),[fe,h]=P(null),[E,x]=P(0),M=w(()=>x(l=>l+1),[]),[Z,Ce]=P(void 0),[K,_e]=P(null),[k,$]=P(null),[V,ie]=P(!1),[O,pe]=P(null),se=j(void 0),Y=w(()=>s(!0),[]),J=w(()=>s(!1),[]),Ie=w(()=>s(l=>!l),[]);W(()=>{t||typeof window>"u"||new URLSearchParams(window.location.search).get("cart")==="open"&&Y()},[Y,t]);let B=sn(),Q=j(B);W(()=>{Q.current!==B&&(Q.current=B,t||J())},[B,t,J]);let Oe=w(l=>{_e(f=>f?.country===l?.country&&f?.subdivision===l?.subdivision&&f?.postcode===l?.postcode?f:l)},[]),I=w((l,f)=>{v(!0),!(!f||!Tn(l))&&L(d=>d.includes(f)?d:[...d,f])},[]),Fe=F||a.length>0,ae=j(!0);W(()=>(ae.current=!0,()=>{ae.current=!1}),[]),W(()=>{if(t)return;let l=[...N,...a.filter(d=>Tn(d.kind)).map(d=>d.slug)],f=[...new Set(l)].filter(d=>d&&!g.current.has(d));if(f.length!==0){for(let d of f)g.current.add(d);U.listWheelsBySlug(f).then(d=>{if(!ae.current||d.length===0)return;let y=new Set(d.map(S=>S.slug));m(S=>[...S.filter(ce=>!y.has(ce.slug)),...d])})}},[t,N,a]),W(()=>{if(t||!Fe||R)return;let l=!0;return U.listBundles().then(f=>{l&&(p(f),A(!0))}),()=>{l=!1}},[t,Fe,R]);let H=b?.deliveryOptions??[],xe=b?.courier??null;W(()=>{b&&pe(l=>l&&H.some(f=>f.id===l)?l:H[0]?.id??null)},[b]);let le=w(()=>a.filter(Re).flatMap(l=>Qt(l.components,l.qty)),[a]),Se=w(async(l,f)=>{let d=l.trim().toUpperCase();if(!d)return;let y=le();if(y.length===0){$({code:d,valid:!1,message:"Add a wheel to the cart first."});return}ie(!0),se.current=f;try{let S=await U.validateCoupon({code:d,items:y,currency:n,shippingMethodId:O??void 0,customerEmail:f});$(Rn(d,S))}catch{$({code:d,valid:!1,unchecked:!0,message:"Could not check that code. Please try again."})}finally{ie(!1)}},[le,n,O]),me=w(()=>{$(null),se.current=void 0},[]),De=w(l=>{if(!k)return;let{code:f}=k;$(d=>d&&d.code===f?{code:f,valid:!1,refused:!0,message:l}:d)},[k]);W(()=>{if(!k||k.refused)return;let l=k.code,f=y=>y!==null&&y.code===l&&!y.refused,d=setTimeout(async()=>{let y=le();if(y.length===0){$(S=>f(S)?{code:l,valid:!1,message:"Add a wheel to the cart first."}:S);return}ie(!0);try{let S=await U.validateCoupon({code:l,items:y,currency:n,shippingMethodId:O??void 0,customerEmail:se.current});$(ce=>f(ce)?Rn(l,S):ce)}catch{}finally{ie(!1)}},zr);return()=>clearTimeout(d)},[a,n,O]);let ue=k&&!k.refused?k.code:void 0;W(()=>{if(t)return;let l=!0,f=a,d=setTimeout(async()=>{let y=le();if(y.length===0){D(null),oe(null),Ce(void 0);return}try{let S=await U.quoteCart({items:y,currency:n,shippingMethodId:O??void 0,couponCode:ue,customerEmail:se.current||void 0,country:K?.country||r||void 0,subdivision:K?.country&&K.subdivision||void 0,postcode:K?.country&&K.postcode||void 0});if(!l)return;D(S),oe(f),h(null)}catch{if(!l)return;h(f)}Ce(ue)},qr);return()=>{l=!1,clearTimeout(d)}},[a,n,O,ue,r,K,E]);let T=w(l=>{c(f=>{let d=f.findIndex(y=>y.id===l.id);return d===-1?[...f,l]:f.map((y,S)=>S===d?{...y,qty:Math.min(ct,y.qty+l.qty)}:y)}),vn(l,n)},[n]),ee=w(l=>{c(f=>f.filter(d=>d.id!==l))},[]),Me=w((l,f)=>{let d=Math.max(1,Math.min(ct,f));c(y=>y.map(S=>S.id===l?{...S,qty:d}:S))},[]),$e=w(l=>{c(l)},[]),[Rt,Ze]=P(!1),[Tt,Qn]=P([]),At=j(a);At.current=a,W(()=>{if(t)return;let l=[];try{let d=JSON.parse(q.getItem(Ct)??"[]");Array.isArray(d)&&(l=d)}catch{}if(l.length===0){Ze(!0);return}let f=!0;return gn(l,U).then(({lines:d,dropped:y})=>{f&&(At.current.length===0&&($e(d),Qn(y)),Ze(!0))},d=>{f&&Ze(!0)}),()=>{f=!1}},[t,$e]),W(()=>{if(t||!Rt)return;let l=a.filter(Re);if(l.length===0){q.removeItem(Ct);return}q.setItem(Ct,JSON.stringify(ft(l,()=>"")))},[a,t,Rt]);let[ve,Xn]=P(null),Lt=j(null);Lt.current=ve;let z=j(null),Je=j(""),Nt=w((l,f)=>{let d=l.trim().toLowerCase();bn(d)&&Xn(y=>y&&y.email===d&&y.firstName===(f??"")?y:{email:d,firstName:f??""})},[]);W(()=>{if(t||!ve)return;let l=ft(a.filter(Re),y=>xt(y,n)===null?Ge:o(xt(y,n),n)),f={email:ve.email,firstName:ve.firstName,currency:n,items:l},d=JSON.stringify(f);if(d!==Je.current)return z.current&&clearTimeout(z.current),z.current=setTimeout(()=>{z.current=null,Je.current=d,U.captureCart(f).catch(y=>{})},Gr),()=>{z.current&&(clearTimeout(z.current),z.current=null)}},[a,ve,n,t]);let _t=w(()=>{z.current&&(clearTimeout(z.current),z.current=null);let l=Lt.current;l&&(Je.current="",U.captureCart({email:l.email,firstName:l.firstName,currency:n,items:[]}).catch(f=>{}))},[n]),It=wn(()=>{let l=a.reduce((_,ye)=>{let Be=xt(ye,n);return Be===null?_:_+Be},0),f=a.some(_=>An(_,n)===null),d=a.reduce((_,ye)=>_+ye.qty,0),y=k?.valid?k.effects:void 0,S=y?Math.min(l,Number(y.discountAmount)):0,ce=b?.bundleDiscount??0,Zn=b?.appliedBundles??[],Ue=!!y?.freeShipping,ge=H.find(_=>_.id===O),et=Number(y?.deliveryDiscountPercent??0),We=!Ue&&et>0&&et<100?et:0,tt=We>0&&ge?kn(ge.amount,We):void 0,nt=Ue?0:tt!==void 0&&Z!==ue?tt:b?.shipping??tt??ge?.amount??0,Jn=We>0&&ge?Math.max(0,ge.amount-nt):0,er=En({quoted:b!==null,optionCount:H.length,chosenAmount:ge?.amount,couponWaivesFreight:Ue}),rt={};for(let _ of y?.freeUnits??[])rt[_.partNumber]=(rt[_.partNumber]??0)+_.quantity;let tr=b?.tax??null,nr=b?b.grandTotal:l-S-ce+nt;return{sets:d,units:a.reduce((_,ye)=>_+(ye.components??[]).reduce((Be,rr)=>Be+rr.wheels*ye.qty,0),0),subtotal:l,hasUnpricedLine:f,discount:S,bundleDiscount:ce,appliedBundles:Zn,shipping:nt,freeShipping:Ue,deliveryDiscountPercent:We,deliverySaving:Jn,shippingStatus:er,freeUnitsByPartNumber:rt,tax:tr,grand:nr,repricing:!!k?.refused&&b!==null&&Z===k?.code,quoted:b!==null&&G===a,serverSubtotal:b?.subtotal??null,quoteFailed:fe===a,currency:n}},[a,n,k,ue,H,O,b,Z,G,fe]),Ot=j(!0),Ft=w(l=>{Ot.current=l},[]),Dt=w(l=>{T(l),Ot.current&&Y()},[T,Y]),jn=wn(()=>({isOpen:i,preview:t,open:Y,close:J,toggle:Ie,items:a,catalog:u,bundles:C,warmCatalog:I,add:T,addAndOpen:Dt,setAutoOpen:Ft,remove:ee,setQty:Me,replaceItems:$e,restoreDropped:Tt,identify:Nt,clearCapturedCart:_t,coupon:k,applyCoupon:Se,removeCoupon:me,refuseCoupon:De,couponBusy:V,deliveryOptions:H,setQuoteDestination:Oe,courier:xe,requote:M,shippingMethodId:O,setShippingMethodId:pe,totals:It}),[i,t,Y,J,Ie,a,u,C,I,T,Dt,Ft,ee,Me,$e,Tt,Nt,_t,k,Se,me,De,V,H,Oe,xe,M,O,It]);return Kr(Ln.Provider,{value:jn,children:e})}function Nn(){let e=Hr(Ln);if(!e)throw new Error("useCart() must be called inside <CartProvider>. Mount the provider in app/layout.tsx.");return e}import{cache as no}from"react";function _n(e){return/(?:^|\|)(?:slug|xhost):/.test(e)}function In(e,t,n,r){for(;e.size>=t;){let o,i;for(let[a,c]of e){if(c.expiresAt<=r){o=a;break}i===void 0&&n(a)&&(i=a)}let s=o??i??e.keys().next().value;if(s===void 0)return;e.delete(s)}}var Vr=6e4,Yr=5e3,Qr=500,Ke=new Map;async function Xr(e){let{host:t,matchesRequestHost:n}=await Gt();if(!t)return"";let r=await Kt();return r?`${e}|slug:${encodeURIComponent(t)}/${encodeURIComponent(r)}`:n?`${e}|host:${t}`:`${e}|xhost:${t}`}async function On(e,t){if(await Vt()!==null)return t();let n=await Xr(e);if(!n)return t();let r=Date.now(),o=Ke.get(n);if(o&&o.expiresAt>r)return o.load;let i=await t(),s=i.outcome.state==="failed",a=s?Yr:Vr,c=Ke.get(n)?.lastGood,u=i.outcome.state==="ok"?i:s?c:void 0,m=s&&u?u:i;return In(Ke,Qr,_n,r),Ke.set(n,{load:m,expiresAt:r+a,lastGood:u}),m}var jr=404;function Zr(e){if(e instanceof X&&e.status===jr)return{state:"absent"};let t=e instanceof X?e.status:-1,n=e instanceof Error?e.message:String(e);return{state:"failed",status:t,detail:n}}var Jr="[storefront:chrome-load-failed]";function eo(e,t){console.error(`${Jr} ${e} status=${t.status} \u2014 serving fallback chrome`,t.detail)}async function Fn(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=Zr(o);return i.state==="failed"&&eo(e,i),{value:n,outcome:i}}}function to(e){return e==="production"?"silent":"banner"}var Ns=to("production");function ro(e,t){return e?.trim()||t}function Us({legalName:e,foundedYear:t,siteName:n},r=new Date().getFullYear()){let o=ro(e,n);return`\xA9 ${t&&t<r?`${t}\u2013${r}`:`${r}`} ${o}`}var oo={name:Pe,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,consentEnabled:!1,consentPrivacyPage:null,consentNoticeOptOut:!1,privacyPage:null,termsPage:null,footerCookieSettings:!0,footerSitemap:!0,socialLinks:st},Ws=no(async()=>On("site",()=>Fn("site",async()=>{let e=await U.getSite();return{name:Bt(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,consentEnabled:e.consentEnabled??!1,consentPrivacyPage:e.consentPrivacyPage??null,consentNoticeOptOut:e.consentNoticeOptOut??!1,privacyPage:e.privacyPage??null,termsPage:e.termsPage??null,footerCookieSettings:e.footerCookieSettings??!0,footerSitemap:e.footerSitemap??!0,socialLinks:Ht(e.socialLinks)}},oo)));var Bs={name:Pe,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,consentEnabled:!1,consentPrivacyPage:null,consentNoticeOptOut:!1,privacyPage:null,termsPage:null,footerCookieSettings:!0,footerSitemap:!0,socialLinks:st};import{jsx as io}from"react/jsx-runtime";function zs({tone:e="bad",role:t,children:n}){return io("div",{role:t,className:["border bg-surface px-4 py-3 text-[14px] leading-relaxed text-fg",e==="good"?"border-accent":e==="bad"?"border-alert":"border-line"].join(" "),children:n})}import{jsx as Ae,jsxs as St}from"react/jsx-runtime";import{useEffect as Ve,useId as uo,useRef as Mn,useState as Ye}from"react";import{useRootIsDark as co}from"efficient-shell/theme";import{efficientClientOpen as so}from"efficient-easel/screen/lib/session";var Te=new Map,ao=64;async function lo(e){if(!so())return null;try{let t=await fetch(`${Wt()}/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 Dn(e){let t=Te.get(e);if(t)return t;let n=lo(e);if(Te.set(e,n),Te.size>ao){let r=Te.keys().next();r.done||Te.delete(r.value)}return n}var fo=202/22,po=.88,la=16,mo="invert(1)";function ua({variant:e="header",scrolled:t=!0,src:n,reverse:r=!1,color:o=null,onLightSurface:i,reversedSrc:s,inkIsDark:a,size:c="medium",sizePx:u,sizeUnit:m,wordmark:C,siteName:p=Pe,fitToContainer:R=!1,fitWordmarkToContainer:A=!1,fitFloorPx:g,hideClass:N,hideAttrs:L,part:F}){let v=C&&C.trim()?C.trim():p,[b,D]=Ye(null),G=Mn(null),oe=T=>{G.current=T};Ve(()=>{D(G.current?.ownerDocument??null)},[]);let fe=!co({doc:b,whenUnset:!0}),h=n&&n.trim()?n.trim():null,E=!!h&&zt(h),x=i??(fe&&t),M=o&&o.trim()?o.trim():null,Z=r&&!M,Ce=`logo-color-${uo().replace(/[^A-Za-z0-9_-]/g,"")}`,K=Z&&E&&h&&s!=null?{reversed:s,inkIsDark:a??null}:null,_e=K!==null,[k,$]=Ye(null);Ve(()=>{if(!Z||!h||!E||_e){$(null);return}let T=!1;return $(null),Dn(h).then(ee=>{T||$(ee)}),()=>{T=!0}},[Z,h,E,_e]);let V=K??k,ie=!!V&&V.inkIsDark!==null&&(x?!V.inkIsDark:V.inkIsDark),O=Z&&!!h&&!E&&!x,pe=ie&&V?V.reversed:h,se=pe?[pe]:[],[Y,J]=Ye(0);Ve(()=>{J(0)},[h,ie]);let Ie=e==="footer"?it:ot[c],B=u&&u>0?u:Ie,Q=(u&&u>0?Mt(u,m,"size",Ut):null)??`${B}px`,Oe=Math.round(B*fo),I=Y<se.length?se[Y]:null,[Fe,ae]=Ye(pe),H=I!==null&&I===Fe,xe=Mn(null);Ve(()=>{let T=xe.current;if(!T||!T.complete)return;if(T.naturalWidth>0||T.naturalHeight>0){ae(I);return}let ee=!1;return T.decode().then(()=>!ee&&ae(I),()=>!ee&&J(Me=>Me+1)),()=>{ee=!0}},[I]);let le=R||A,Se=`calc(100cqi / ${((v.length+1)*po).toFixed(2)})`,me=le&&g&&g>0?Q===`${B}px`?`${Math.min(g,B)}px`:`min(${g}px, ${Q})`:null,De=le?me===null?`min(${Q}, ${Se})`:`clamp(${me}, ${Se}, ${Q})`:Q,ue=St("span",{className:`font-display font-bold tracking-[0.18em] ${me===null?"whitespace-nowrap":"whitespace-normal"}`,style:{fontSize:De,lineHeight:1,...M?{color:M}:{}},"aria-label":v,children:[v,Ae("span",{className:"text-accent",style:M?{color:M}:void 0,children:"."})]});return St("span",{ref:oe,className:$t("inline-flex items-center",N??""),...L,...F,children:[!H&&ue,M&&I&&Ae("svg",{"aria-hidden":"true",focusable:"false",width:"0",height:"0",style:{position:"absolute"},children:St("filter",{id:Ce,colorInterpolationFilters:"sRGB",children:[Ae("feFlood",{style:{floodColor:M}}),Ae("feComposite",{in2:"SourceAlpha",operator:"in"})]})}),I&&Ae("img",{ref:xe,src:I,alt:v,width:Oe,height:B,className:"shrink-0 object-contain",style:{...H?{height:Q,width:"auto",...R?{maxWidth:"100cqi"}:{}}:{display:"none"},...O?{filter:mo}:{},...M?{filter:`url(#${Ce})`}:{}},onLoad:()=>ae(I),onError:()=>J(T=>T+1)},I)]})}var da="w-full border-2 border-line bg-bg px-4 py-4 font-display text-[17px] tracking-[-0.005em] text-fg outline-none transition-colors placeholder:text-fg-dim hover:border-fg-dim focus:border-accent",$n="w-0 min-w-0 flex-1",fa="w-0 min-w-[7rem] flex-1";import{jsx as Le,jsxs as yo}from"react/jsx-runtime";function go({spokes:e,mesh:t=!1,className:n}){let s=c=>Math.round(c*1e3)/1e3,a=[];for(let c=0;c<e;c++){let u=c/e*Math.PI*2-Math.PI/2;if(a.push({x1:s(100+Math.cos(u)*22),y1:s(100+Math.sin(u)*22),x2:s(100+Math.cos(u)*86),y2:s(100+Math.sin(u)*86),main:!0}),t){let m=u+Math.PI/e;a.push({x1:s(100+Math.cos(m)*22*1.4),y1:s(100+Math.sin(m)*22*1.4),x2:s(100+Math.cos(m)*78),y2:s(100+Math.sin(m)*78),main:!1})}}return yo("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:[Le("circle",{cx:100,cy:100,r:92,strokeWidth:2}),Le("circle",{cx:100,cy:100,r:84,strokeWidth:1,opacity:.4}),Le("circle",{cx:100,cy:100,r:22,strokeWidth:2}),Le("circle",{cx:100,cy:100,r:6,fill:"currentColor"}),a.map((c,u)=>Le("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},u))]})}var ya="#c9a461",Un=[{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"}],ha={name:"",color:"var(--fg)",family:"silver",src:""};function ho(e,t){let n=r=>{let o=Un.findIndex(i=>i.f===r);return o===-1?Un.length:o};return n(e)-n(t)||e.localeCompare(t)}function ba(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(ho)}import{useEffect as bo,useRef as Wn,useState as Co}from"react";import{jsx as de,jsxs as vt}from"react/jsx-runtime";function xo({customerEmail:e,disabled:t=!1}){let{coupon:n,applyCoupon:r,removeCoupon:o,couponBusy:i}=Nn(),[s,a]=Co(""),c=Wn(!1),u=Wn(null);bo(()=>{!c.current||n===null||(c.current=!1,u.current?.focus())},[n]);async function m(){t||i||!s.trim()||(c.current=!0,await r(s,e),a(""))}return vt("div",{className:"flex flex-col gap-2",children:[n===null?vt("div",{className:"flex border border-line",children:[de("input",{type:"text",value:s,onChange:C=>a(C.target.value),onKeyDown:C=>{C.key==="Enter"&&(C.preventDefault(),m())},placeholder:"Coupon code","aria-label":"Coupon code",disabled:t,className:`${$n} bg-transparent px-4 py-4 font-mono text-[11px] uppercase tracking-[0.18em] text-fg outline-none placeholder:text-fg-dim`}),de("button",{type:"button",onClick:()=>{m()},disabled:i||t,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:i?"\u2026":"Apply"})]}):vt("div",{className:["flex items-center justify-between gap-3 border px-4 py-3",n.valid?"border-accent":"border-line"].join(" "),style:n.valid?{background:"color-mix(in oklab, var(--accent) 8%, transparent)"}:void 0,children:[de("span",{className:["font-mono text-[11px] uppercase tracking-[0.22em]",n.valid?"text-accent":n.deferred||n.unchecked?"text-fg":"text-fg-dim line-through"].join(" "),children:n.code}),n.unchecked&&de("button",{type:"button",onClick:()=>{r(n.code,e)},disabled:i||t,className:"ml-auto font-mono text-[10px] uppercase tracking-[0.26em] text-btn transition-colors hover:text-fg disabled:cursor-wait disabled:opacity-60",children:i?"\u2026":"Try again"}),!t&&de("button",{ref:u,type:"button",onClick:o,"aria-label":`Remove coupon ${n.code}`,className:"font-mono text-[12px] text-fg-dim transition-colors hover:text-fg",children:"\u2715"})]}),n?.deferred?de("p",{className:"font-mono text-[10px] uppercase tracking-[0.18em] text-fg-dim",children:un}):n&&!n.valid&&n.message&&de("p",{role:"alert",className:"font-mono text-[10px] uppercase tracking-[0.18em] text-alert",children:n.message})]})}var Pt="Ads on. Shopper can opt out.",Qe="Ads and analytics off until Accept",So={us:{region:"us",name:"United States",model:"opt-out",law:"California CCPA / CPRA, other state laws",beforeChoice:Pt,footerLink:"Do Not Sell or Share My Personal Information",panelEyebrow:"Do not sell or share",adsRowName:"Sale or sharing for ads"},ca:{region:"ca",name:"Canada",model:"opt-in",law:"PIPEDA, Quebec Law 25",beforeChoice:Qe,footerLink:"Privacy choices",panelEyebrow:"Privacy choices",adsRowName:"Advertising"},au:{region:"au",name:"Australia",model:"opt-out",law:"Privacy Act 1988 (APPs)",beforeChoice:Pt,footerLink:"Privacy choices",panelEyebrow:"Privacy choices",adsRowName:"Advertising"},nz:{region:"nz",name:"New Zealand",model:"opt-out",law:"Privacy Act 2020",beforeChoice:Pt,footerLink:"Privacy choices",panelEyebrow:"Privacy choices",adsRowName:"Advertising"},uk:{region:"uk",name:"United Kingdom",model:"opt-in",law:"PECR, UK GDPR",beforeChoice:Qe,footerLink:"Cookie settings",panelEyebrow:"Cookie settings",adsRowName:"Advertising"},eu:{region:"eu",name:"European Union",model:"opt-in",law:"ePrivacy Directive, GDPR",beforeChoice:Qe,footerLink:"Cookie settings",panelEyebrow:"Cookie settings",adsRowName:"Advertising"},other:{region:"other",name:"All other countries",model:"opt-in",law:"Safe default",beforeChoice:Qe,footerLink:"Cookie settings",panelEyebrow:"Cookie settings",adsRowName:"Advertising"}};function vo(e){let t=[...e.googleAds?["Google"]:[],...e.meta?["Facebook","Instagram"]:[]];return t.length<=1?t.join(""):`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function wa(e,t,n){let r=vo(n),o=r?`We use cookies to count visits and to show you ${t} ads on ${r}.`:"We use cookies to count visits.";return e.model==="opt-in"?{heading:r?"Cookies and ads":"Cookies",before:`${o} Nothing loads until you choose. You can change this at any time with `,link:e.footerLink,after:" at the bottom of every page."}:{heading:r?"Cookies and ads":"Cookies",before:`${o} You can say no at any time: choose Privacy choices, or use `,link:e.footerLink,after:" at the bottom of every page."}}var Ra={accept:"Accept all",reject:"Reject all",choose:"Choose",save:"Save",ok:"OK",privacyChoices:"Privacy choices",privacyPolicy:"Privacy Policy",alwaysOn:"Always on",close:"Close",cookieSettings:"Cookie settings"};var Po={asked:!1,region:"other",model:"opt-in",analytics:!0,ads:!0,chosen:!0,gpc:!1};var Eo=Po;function Na(e=Eo){if(e.asked)return e.ads?"granted":"denied"}function Ia(){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)}`}import{Children as wo,isValidElement as Ro,useEffect as Hn,useId as To,useLayoutEffect as Gn,useRef as ne,useState as zn}from"react";var Xe=(e,t)=>!!e[t]&&!e[t].disabled;function Et(e,t,n){let r=e.length;for(let o=1;o<=r;o++){let i=((t+n*o)%r+r)%r;if(Xe(e,i))return i}return t}function kt(e,t){return Et(e,t===1?-1:e.length,t)}function wt(e,t){return Xe(e,t)?t:Math.max(kt(e,1),0)}function Bn(e,t,n){let{open:r,focus:o}=e,i=s=>({...e,...s});if(t.length===1&&/\S/.test(t)){let s=e.typed+t.toLowerCase(),a=n.findIndex((c,u)=>Xe(n,u)&&c.label.toLowerCase().startsWith(s));return{state:i({open:!0,typed:s,focus:a>=0?a: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:Et(n,o,1)}),handled:!0};case"ArrowUp":return{state:i({focus:Et(n,o,-1)}),handled:!0};case"Home":return{state:i({focus:kt(n,1)}),handled:!0};case"End":return{state:i({focus:kt(n,-1)}),handled:!0};case"Enter":case" ":return Xe(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{placeMenu as Ao}from"efficient-shell/ui";import{Fragment as Do,jsx as re,jsxs as Kn}from"react/jsx-runtime";var qn={body:"text-[length:var(--size-body,14px)]",label:"text-[length:var(--size-label,13px)]"};function Lo({items:e,value:t,onPick:n,open:r,onOpen:o,onClose:i}){let[s,a]=zn(!1),c=r!==void 0,u=c?r:s,[m,C]=zn(0),p=ne({text:"",timer:0}),R=ne(null),A=ne(null),g=ne(null),N=To(),L=ne(null),F=e.findIndex(h=>h.value===t),v=h=>{h!==u&&(c||a(h),h?o?.():i?.())},b=h=>{let E=e[h];!E||E.disabled||(n(E.value),v(!1),A.current?.focus())},D=h=>{let E={open:u,focus:u?m:wt(e,F),typed:p.current.text},x=Bn(E,h,e);return!x.handled&&x.state.open===u?!1:(x.state.typed!==E.typed&&(p.current.text=x.state.typed,window.clearTimeout(p.current.timer),p.current.timer=window.setTimeout(()=>{p.current.text=""},500)),C(x.state.focus),x.commit!==void 0?b(x.commit):v(x.state.open),x.refocus&&A.current?.focus(),x.handled)},G=ne(D);G.current=D;let oe=ne(()=>v(!1));oe.current=()=>v(!1);let fe=h=>{u||(L.current=h.nativeEvent,G.current(h.key)&&h.preventDefault())};return Hn(()=>{if(!u)return;let h=x=>{R.current?.contains(x.target)||oe.current()},E=x=>{x!==L.current&&G.current(x.key)&&x.preventDefault()};return document.addEventListener("mousedown",h),document.addEventListener("keydown",E),()=>{document.removeEventListener("mousedown",h),document.removeEventListener("keydown",E)}},[u]),Hn(()=>{u&&(p.current.text||C(wt(e,F)))},[u]),Gn(()=>{if(!u||!g.current)return;g.current.children.item(m)?.scrollIntoView({block:"nearest"})},[m,u]),{open:u,toggle:()=>v(!u),close:()=>v(!1),focusIdx:m,setFocusIdx:C,pick:h=>b(e.findIndex(E=>E.value===h)),wrapRef:R,triggerRef:A,listRef:g,listId:N,onTriggerKeyDown:fe,activeId:u?`${N}-${m}`:void 0}}var No={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-3 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 ${qn.label} 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 ${qn.body} 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-4 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 _o(e,t){Gn(()=>{let n=e.current,r=n?.ownerDocument.defaultView;if(!n||!r)return;let o=()=>{let i=n.style;i.top=i.bottom=i.marginTop=i.marginBottom=i.maxHeight=i.overflowY=i.translate="";let s=n.offsetParent??n.parentElement;if(!s)return;let a=s.getBoundingClientRect(),c=n.getBoundingClientRect(),u=Math.abs(c.right-a.right)<Math.abs(c.left-a.left)?"end":"start",m=Ao({trigger:{left:a.left,right:a.right,top:a.top,bottom:a.bottom},menu:{width:c.width,height:c.height},bounds:{left:0,top:0,right:r.innerWidth,bottom:r.innerHeight},align:u,side:"bottom"});if(m.side==="top"){i.top="auto",i.bottom="100%",i.marginTop="0px";let p=m.top+Math.min(c.height,m.maxHeight);i.marginBottom=`${Math.max(0,a.top-p)}px`}m.maxHeight<c.height&&(i.maxHeight=`${m.maxHeight}px`,i.overflowY="auto");let C=m.left-c.left;C&&(i.translate=`${C}px`)};return o(),r.addEventListener("resize",o),r.addEventListener("scroll",o,!0),()=>{r.removeEventListener("resize",o),r.removeEventListener("scroll",o,!0)}},[e,t])}function Io(e){return e.split(" ").map(t=>t==="left-0"?"right-0":t).join(" ")}function Oo({id:e,tone:t,items:n,value:r,focusIdx:o,onFocus:i,onPick:s,listRef:a,ariaLabel:c,align:u="start"}){let m=No[t],C=ne(null);return _o(C,n.length),re("ul",{ref:p=>{C.current=p,a&&(a.current=p)},id:e,role:"listbox","aria-label":c,...m.pickerMarker?{"data-picker-menu":""}:{},className:u==="end"?Io(m.list):m.list,children:n.map((p,R)=>{let A=p.value===r;return re("li",{id:`${e}-${R}`,role:"option","aria-selected":A,"aria-disabled":p.disabled||void 0,onMouseEnter:()=>!p.disabled&&i(R),onMouseDown:g=>{g.preventDefault(),p.disabled||s(p.value)},className:m.item(R===o,A&&p.value!=="",!!p.disabled,R===n.length-1),style:m.itemStyle?.(A),children:p.meta===void 0?p.label:Kn(Do,{children:[p.lead,re("span",{className:"flex-1 whitespace-nowrap",children:p.label}),re("span",{className:"ml-auto text-[12px] opacity-50",children:p.meta})]})},`${p.value}_${R}`)})})}function Fo({value:e,onChange:t,disabled:n,children:r,className:o,style:i,name:s,id:a,"aria-label":c,align:u}){let m=wo.toArray(r).flatMap(g=>{if(!Ro(g))return[];if(g.type!=="option")return[];let L=g.props,F=L.value!==void 0?String(L.value):"",v=L.children,b=typeof v=="string"||typeof v=="number"?String(v):F;return[{value:F,label:b,disabled:!!L.disabled}]}),C=e??"",p=Lo({items:m,value:C,onPick:g=>t?.({target:{value:g}})}),A=m.find(g=>g.value===C)?.label??m[0]?.label??"";return Kn("div",{ref:p.wrapRef,className:"relative",children:[s&&re("input",{type:"hidden",name:s,value:C}),re("button",{ref:g=>{p.triggerRef.current=g},type:"button",disabled:n,"aria-haspopup":"listbox","aria-expanded":p.open,"aria-controls":p.open?p.listId:void 0,"aria-activedescendant":p.activeId,"aria-label":c,id:a,onClick:()=>!n&&p.toggle(),onKeyDown:g=>!n&&p.onTriggerKeyDown(g),className:`block w-full ${o??""}`,style:i,children:re("span",{className:"block w-full truncate text-left",children:A})}),p.open&&re(Oo,{id:p.listId,tone:"select",items:m,value:C,focusIdx:p.focusIdx,onFocus:p.setFocusIdx,onPick:p.pick,listRef:p.listRef,align:u})]})}import{jsx as Ne,jsxs as je}from"react/jsx-runtime";var Mo="font-mono text-[length:var(--size-label,12px)]",$o="font-semibold uppercase tracking-[0.22em] text-fg";function Vn(e){return`${e??Mo} ${$o}`}function Yn(){return Ne("span",{className:"text-accent",children:" *"})}function Uo({children:e,required:t,labelFace:n}){return je("span",{className:Vn(n),children:[e,t?Ne(Yn,{}):null]})}function Wo({label:e,required:t,hint:n,separate:r,htmlFor:o,labelFace:i,className:s,children:a}){let c=s?`flex flex-col gap-2 ${s}`:"flex flex-col gap-2",u=n?Ne("span",{className:"font-mono text-[11px] uppercase tracking-[0.22em] text-fg-dim",children:n}):null;return r||n?je("div",{className:c,children:[je("label",{htmlFor:o,className:Vn(i),children:[e,t?Ne(Yn,{}):null]}),a,u]}):je("label",{htmlFor:o,className:c,children:[Ne(Uo,{required:t,labelFace:i,children:e}),a]})}export{sn as a,ni as b,ri as c,oi as d,Qt as e,at as f,Bo as g,or as h,Ho as i,Zt as j,ir as k,sr as l,ut as m,Jt as n,zo as o,ct as p,He as q,te as r,qo as s,Go as t,mr as u,ai as v,pt as w,be as x,li as y,fi as z,ke as A,pi as B,mi as C,gi as D,xr as E,cn as F,ze as G,vr as H,dn as I,Pi as J,Ei as K,gt as L,fn as M,wr as N,Ri as O,Ti as P,Ai as Q,Ge as R,$i as S,yn as T,Ui as U,Wi as V,hn as W,Bi as X,ht as Y,Hi as Z,zi as _,_r as $,qi as aa,Gi as ba,Ir as ca,Ki as da,Vi as ea,Yi as fa,Qi as ga,bn as ha,ts as ia,ns as ja,rs as ka,ss as la,kn as ma,as as na,ls as oa,Xo as pa,on as qa,jo as ra,Re as sa,xt as ta,Ps as ua,Nn as va,Us as wa,oo as xa,Bs as ya,da as za,$n as Aa,fa as Ba,go as Ca,ya as Da,Un as Ea,ha as Fa,ho as Ga,ba as Ha,xo as Ia,zs as Ja,la as Ka,ua as La,So as Ma,wa as Na,Ra as Oa,Po as Pa,Na as Qa,Ia as Ra,Lo as Sa,Oo as Ta,Fo as Ua,Uo as Va,Wo as Wa};
|