efficient-storefront-blocks 0.118.0 → 0.118.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.
@@ -1 +1 @@
1
- "use client";import{jsx as e,Fragment as v,jsxs as a}from"react/jsx-runtime";import{useId as j}from"react";import V from"next/image";import X from"next/link";import{lineTotal as Z,useCart as J}from"../CartContext.js";import{useCurrency as ee}from"../CurrencyContext.js";import{Notice as _}from"../Notice.js";import{FREE_PRICE as O}from"../../lib/wheels/price-display.js";import te from"../CouponField.js";import{COUPON_DEFERRED_TOTAL as ne}from"../../lib/cart/coupon-preview.js";import{orderReference as ae}from"../../lib/checkout/pay-first.js";import{PRICES_REQUOTED as re}from"../../lib/checkout/checkout-memory.js";import{shippingWords as ie,TAX_PENDING as le}from"../../lib/cart/shipping-status.js";import{DEFAULT_FINISH_COLOR as oe}from"../../lib/wheels/finish-defaults.js";import D from"../ThemedSelect.js";import g from"../WebFormField.js";import se from"../WheelSvg.js";import{NO_PAYMENT_METHOD_NOTE as ce,placedOrderLockNote as de,SHIPPING_RETRY_NOTE as pe,useCheckout as S}from"./checkout-state.js";import{FIELD_INPUT_CLASS as u}from"../../lib/field-input.js";import{FIGURE_UPDATING as P}from"../../lib/wheels/price-display.js";function $e(){const{email:t,setEmail:i,firstName:n,setFirstName:l,lastName:c,setLastName:d,company:f,setCompany:y,me:b,checkoutSignOut:h,orderLocked:x,unpaidOrder:o}=S(),s=j();return a(L,{num:"N° 01",title:"Contact",children:[x&&o&&e(he,{orderNumber:o.orderNumber}),e(g,{label:"Email",htmlFor:s,hint:b?a(v,{children:["Signed in ·"," ",e("button",{type:"button",onClick:h,className:"underline transition-colors enabled:hover:text-accent",children:"Not you? Sign out"})]}):void 0,children:e("input",{id:s,type:"email",value:t,onChange:p=>i(p.target.value),placeholder:"you@example.com",readOnly:b!==null,className:u})}),a(U,{children:[e(g,{label:"First name",children:e("input",{type:"text",value:n,onChange:p=>l(p.target.value),className:u})}),e(g,{label:"Last name",children:e("input",{type:"text",value:c,onChange:p=>d(p.target.value),className:u})})]}),e(g,{label:"Company (optional)",children:e("input",{type:"text",value:f,onChange:p=>y(p.target.value),autoComplete:"organization",className:u})})]})}function De(){const{pickupLocation:t,servedCountries:i,address1:n,setAddress1:l,address2:c,setAddress2:d,city:f,setCity:y,postcode:b,setPostcode:h,phone:x,setPhone:o,country:s,setCountry:p,subdivision:C,setSubdivision:m,subdivisions:w,destination:N,postcodeLabel:q,subdivisionLabel:z,me:A,savedAddresses:B,selectedAddressId:I,setSelectedAddressId:T,saveAddress:R,setSaveAddress:H,saveLabel:G,setSaveLabel:W,fillFromAddress:K,orderLocked:Q}=S(),$=j(),F=j();return a(L,{num:"N° 02",title:t?"Collection":"Shipping address",children:[t?a("div",{className:"grid gap-2 text-[14px] leading-[1.6]",children:[e("span",{className:"font-medium",children:t.name}),[t.address,t.city,t.state,t.zipCode,t.country].filter(Boolean).length>0&&e("span",{className:"opacity-80",children:[t.address,t.city,t.state,t.zipCode,t.country].filter(Boolean).join(", ")}),t.openingHours&&e("span",{className:"opacity-80",children:t.openingHours}),t.readyIn&&e("span",{className:"opacity-80",children:t.readyIn}),t.instructions&&e("span",{className:"opacity-80",children:t.instructions}),e("span",{className:"mt-1 font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"No delivery address needed"})]}):a(v,{children:[A!==null&&B.length>0&&a("div",{className:"grid gap-3",children:[B.map(r=>e(E,{active:I===r.id,onClick:()=>{T(r.id),K(r)},title:r.label,body:r.formatted_address,price:null},r.id)),e(E,{active:I==="new",onClick:()=>T("new"),title:"New address",body:null,price:null})]}),e(g,{label:"Address line 1",children:e("input",{type:"text",value:n,onChange:r=>l(r.target.value),className:u})}),e(g,{label:"Address line 2",children:e("input",{type:"text",value:c,onChange:r=>d(r.target.value),placeholder:"Apartment, unit, garage bay…",className:u})}),a(U,{cols:"three",children:[e(g,{label:"City",children:e("input",{type:"text",value:f,onChange:r=>y(r.target.value),className:u})}),e(g,{label:q,children:e("input",{type:"text",value:b,onChange:r=>h(r.target.value),className:u})}),e(g,{label:"Country",separate:!0,htmlFor:$,children:e(D,{id:$,value:s,onChange:r=>p(r.target.value),className:u+" pr-10",style:Y,children:i.map(r=>e("option",{value:r.code,children:r.name},r.code))})})]}),e(g,{label:z,separate:!0,htmlFor:F,children:w.length>0?a(D,{id:F,value:C,onChange:r=>m(r.target.value),className:u+" pr-10",style:Y,children:[e("option",{value:"",children:"Select…"}),w.map(r=>e("option",{value:r.code||r.name,children:r.name},r.code||r.name))]}):e("input",{id:F,type:"text",value:C,onChange:r=>m(r.target.value),className:u})})]}),e(g,{label:"Phone",children:e("input",{type:"tel",value:x,onChange:r=>o(r.target.value),className:u})}),!t&&A!==null&&I==="new"&&!Q&&a(v,{children:[e(ge,{checked:R,onChange:H,label:"Save this address to my account"}),R&&e(g,{label:"Address label",children:e("input",{type:"text",value:G,onChange:r=>W(r.target.value),placeholder:"Home",className:u})})]})]})}function Me(){const{totals:t,coupon:i,deliveryOptions:n,shippingMethodId:l,setShippingMethodId:c,pickupLocation:d,formatMoney:f,city:y,destination:b,courierUnavailable:h,retryCourier:x}=S();return e(L,{num:"N° 03",title:"Shipping",children:a("div",{className:"grid gap-3",children:[n.map(o=>{const s=o.pickupLocation,p=s?[s.address,s.city,s.state,s.zipCode].filter(Boolean).join(", "):null;return e(E,{active:l===o.id,onClick:()=>c(o.id),title:s?`${o.name} — ${s.name}`:o.name,body:s?[p,s.openingHours,s.readyIn,s.instructions,o.description].filter(Boolean).join(" · "):o.description||null,price:t.freeShipping||o.amount===0?O:f(o.amount,t.currency),tag:o.tag||void 0},o.id)}),h?a("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:[pe," ",e("button",{type:"button",onClick:x,className:"underline transition-colors enabled:hover:text-accent",children:"Try again"})]}):n.length===0&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Shipping is arranged after your order is reviewed."})]})})}function Ye(){const{payChoice:t,setPayChoice:i,payment:n,payOptions:l,noPaymentMethod:c}=S();return a(L,{num:"N° 04",title:"Payment",children:[c&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:ce}),e("div",{className:"grid gap-3",children:l.map(d=>e(E,{active:t===d.key,onClick:()=>i(d.key),title:d.title,body:d.body,price:d.price,tag:d.tag},d.key))}),t==="card"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll enter card details on the secure payment step after placing the order."}):t==="paypal"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll approve the payment with PayPal on the payment step after placing the order."}):t==="afterpay"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll be taken to Afterpay to approve four interest-free payments, then brought straight back."}):t==="square"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll enter card details on the secure payment step after placing the order."}):t==="gocardless"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll set up a bank direct debit with GoCardless, then be brought straight back. Direct debits clear in a few days."}):t==="zip"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll be taken to Zip to approve four instalments, then brought straight back."}):t==="klarna"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll be taken to Klarna to choose how to pay, then brought straight back."}):t==="bank"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Our team emails you the invoice and bank details after review."}):null]})}function Ue(){const{site:t,items:i,totals:n,coupon:l,formatMoney:c,payChoice:d,placing:f,email:y,orderError:b,payment:h,noPaymentMethod:x,unpaidOrder:o,formLocked:s,restoredPrices:p,placeOrder:C}=S(),m=p==="waiting",w=p==="changed";return a("aside",{className:"sticky top-[var(--sf-checkout-header-h,88px)] border border-line max-view-desktop:static",style:{background:"linear-gradient(180deg, color-mix(in oklab, var(--site-surface) 70%, var(--bg)) 0%, var(--bg) 100%)"},children:[a("header",{className:"flex items-center justify-between border-b border-accent bg-accent px-6 py-4 font-mono text-[13px] font-bold uppercase tracking-[0.28em] text-bg",children:[e("span",{children:"Your order"}),e(M,{href:"/wheels",className:"text-bg/80 transition-colors hover:text-bg",children:"Edit ↗"})]}),e("div",{className:"flex flex-col px-6 py-2",children:i.length===0?a("div",{className:"py-8 text-center font-serif text-[16px] italic leading-[1.5] text-fg-dim",children:["Your cart is empty. ",e(M,{href:"/wheels",className:"text-accent underline-offset-4 hover:underline",children:"Browse the catalog →"})]}):i.map(N=>e(fe,{slug:N.slug,name:N.name,qty:N.qty,config:N.config,configSummary:xe(N.config),price:w||m?null:Z(N,n.currency)??0,currency:n.currency},N.id))}),e(ue,{locked:s,className:"border-t border-line px-6 pt-5",children:e(te,{customerEmail:y,disabled:s})}),a("div",{className:"flex flex-col gap-2 border-t border-line mt-5 px-6 pt-5",children:[e(k,{label:"Subtotal",value:m?P:c(w?n.serverSubtotal??0:n.subtotal,n.currency)}),n.discount>0&&l?.valid&&e(k,{label:`Coupon · ${l.code}`,value:a("span",{className:"font-semibold text-green",children:["− ",c(n.discount,n.currency)]})}),l?.deferred&&e(k,{label:`Coupon · ${l.code}`,value:ne}),l?.valid&&l.effects?.gift&&e(k,{label:`Free gift · ${l.effects.gift.partNumber}${l.effects.gift.quantity>1?` ×${l.effects.gift.quantity}`:""}`,value:e("span",{className:"font-semibold text-green",children:O})}),e(k,{label:"Shipping",value:n.shippingStatus==="free"?e("span",{className:"font-semibold text-green",children:O}):ie(n.shippingStatus)??c(n.shipping,n.currency)}),n.tax&&(n.tax.charged?e(k,{label:n.tax.inclusive?`${n.tax.name} included · ${n.tax.rate}%`:n.tax.name,value:c(n.tax.amount,n.currency)}):n.tax.name?e(k,{label:n.tax.name,value:le}):null)]}),a("div",{className:"mt-4 flex items-end justify-between border-y-2 border-accent px-6 py-4",style:{background:"color-mix(in oklab, var(--accent) 10%, var(--bg))"},children:[e("span",{className:"font-display text-[20px] font-bold uppercase tracking-[0.04em] text-fg",children:"Total"}),e("span",{className:"text-right font-display text-[34px] font-bold leading-none tracking-[-0.025em] text-fg",children:n.repricing?P:c(n.grand,n.currency)})]}),a("div",{className:"flex flex-col gap-3 px-6 pt-5 pb-6",children:[w&&e(_,{tone:"quiet",children:re}),b&&e(_,{role:"alert",children:b}),n.hasUnpricedLine&&a(_,{role:"status",children:["One or more items have no price in ",n.currency,". Remove them, or switch region, to continue."]}),e("button",{type:"button",onClick:C,disabled:f||!o&&(x||i.length===0||n.hasUnpricedLine||n.repricing),className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",f||!o&&(i.length===0||x||n.hasUnpricedLine||n.repricing)?"cursor-not-allowed border-line bg-surface text-fg-dim":"border-btn bg-btn text-btn-ink hover:border-fg hover:bg-fg"].join(" "),children:f?a(v,{children:["Building order… ",e("span",{children:"·"})]}):x?a(v,{children:["No online payment ",e("span",{children:"·"})]}):o?a(v,{children:["Try payment again · ",ae(o),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]}):n.repricing?a(v,{children:[P," ",e("span",{children:"·"})]}):a(v,{children:[d==="bank"?"Place order":"Continue to payment"," ·"," ",c(n.grand,n.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})})]})]})}const me=" [&:disabled_:disabled]:cursor-not-allowed! [&:disabled_:disabled]:opacity-70! [&_input[readonly]]:cursor-not-allowed [&_input[readonly]]:opacity-70";function ue({locked:t,className:i="",children:n}){return e("fieldset",{disabled:t,className:"m-0 min-w-0 border-0 p-0 "+i+me,children:n})}function M({href:t,className:i="",children:n,...l}){const{placing:c}=S();return c?e("span",{"aria-disabled":"true","aria-label":l["aria-label"],className:i+" pointer-events-none",children:n}):e(X,{href:t,"aria-label":l["aria-label"],className:i,children:n})}function he({orderNumber:t}){return e(_,{tone:"quiet",role:"status",children:a("span",{className:"flex items-start gap-2",children:[a("svg",{"aria-hidden":!0,viewBox:"0 0 16 16",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"mt-[3px] shrink-0",children:[e("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1"}),e("path",{d:"M5 7V5a3 3 0 0 1 6 0v2"})]}),e("span",{children:de(t)})]})})}const Y={backgroundImage:"linear-gradient(45deg, transparent 50%, var(--accent) 50%), linear-gradient(135deg, var(--accent) 50%, transparent 50%)",backgroundPosition:"calc(100% - 18px) 50%, calc(100% - 12px) 50%",backgroundSize:"6px 6px",backgroundRepeat:"no-repeat"};function L({num:t,title:i,children:n}){return a("section",{className:"mb-6 border border-line bg-bg",children:[a("header",{className:"flex items-center gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t}),e("h2",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:i})]}),e("div",{className:"flex flex-col gap-4 px-6 py-6",children:n})]})}function U({cols:t="two",children:i}){return e("div",{className:["grid gap-3 max-[640px]:grid-cols-1",t==="two"?"grid-cols-2":"grid-cols-[1.2fr_1fr_1fr]"].join(" "),children:i})}function E({active:t,onClick:i,title:n,body:l,price:c,tag:d}){return a("button",{type:"button",onClick:i,"aria-pressed":t,className:["relative grid grid-cols-[auto_1fr_auto] items-center gap-5 border bg-bg px-6 py-5 text-left transition-colors",t?"border-accent outline outline-1 outline-accent -outline-offset-1":"border-line enabled:hover:border-[color-mix(in_oklab,var(--accent)_50%,var(--site-line))]"].join(" "),style:t?{background:"color-mix(in oklab, var(--accent) 14%, var(--bg))"}:void 0,children:[t&&e("span",{"aria-hidden":!0,className:"absolute inset-y-0 left-0 w-[3px] bg-accent"}),e("span",{className:["flex h-[18px] w-[18px] items-center justify-center rounded-full border-2",t?"border-accent":"border-fg-dim"].join(" "),children:t&&e("span",{className:"block h-2.5 w-2.5 rounded-full bg-accent"})}),a("span",{className:"flex min-w-0 flex-col gap-1",children:[a("span",{className:"flex flex-wrap items-baseline gap-3 font-display text-[18px] font-medium tracking-[-0.01em] text-fg",children:[n,d&&e("span",{className:"border px-2 py-0.5 font-mono text-[11px] font-normal uppercase tracking-[0.24em] text-accent",style:{background:"color-mix(in oklab, var(--accent) 14%, transparent)",borderColor:"color-mix(in oklab, var(--accent) 45%, var(--site-line))"},children:d})]}),l&&e("span",{className:"font-mono text-[12px] uppercase tracking-[0.22em] text-fg-dim",children:l})]}),e("span",{className:"whitespace-nowrap font-display text-[18px] font-medium tracking-[-0.01em] text-fg",children:c})]})}function ge({checked:t,onChange:i,label:n,sub:l}){return a("div",{className:"flex items-start gap-3 border-t border-line py-4 first:border-t-0 first:pt-0",children:[e("button",{type:"button",onClick:()=>i(!t),"aria-pressed":t,"aria-label":n,className:["mt-px flex h-5 w-5 flex-shrink-0 items-center justify-center border transition-colors",t?"border-accent":"border-line"].join(" "),style:t?{background:"color-mix(in oklab, var(--accent) 18%, transparent)"}:void 0,children:t&&e("span",{className:"text-[13px] text-accent",children:"✓"})}),a("span",{className:"flex-1 font-display text-[16px] leading-[1.5] text-fg",children:[n,l&&e("small",{className:"mt-1 block font-mono text-[12px] uppercase tracking-[0.18em] text-fg-dim",children:l})]})]})}function fe({slug:t,name:i,qty:n,config:l,configSummary:c,price:d,currency:f}){const{catalog:y}=J(),{formatMoney:b}=ee(),h=y.find(m=>m.slug===t),x=h?.spokes??5,o=h?.mesh??!1,s=l.find(m=>m.gold)?.label,p=h?.finishes.find(m=>m.name===s&&m.src)??h?.finishes.find(m=>m.src),C=h?.finishes[0]?.color??oe;return a("div",{className:"grid grid-cols-[60px_1fr_auto] items-center gap-4 border-b border-line py-4 last:border-b-0",children:[a("div",{className:"relative aspect-square",children:[e("div",{className:"flex h-full w-full items-center justify-center overflow-hidden border border-line bg-surface",children:p?.src?e(V,{src:p.src,alt:`${i.lead}${i.accent} — ${p.name}`,width:120,height:120,sizes:"60px",className:"block h-full w-full object-contain p-2"}):e("div",{className:"block w-[78%]",style:{color:C},children:e(se,{spokes:x,mesh:o,className:"block w-full"})})}),e("span",{className:"absolute -right-1.5 -top-1.5 z-[2] flex h-[18px] w-[18px] items-center justify-center rounded-full bg-accent font-mono text-[11px] font-bold text-bg",children:n})]}),a("div",{className:"flex min-w-0 flex-col gap-0.5",children:[a("span",{className:"font-display text-[17px] font-bold uppercase leading-none tracking-[-0.005em] text-fg",children:[i.lead,e("em",{className:"font-serif font-normal italic text-accent tracking-[-0.005em] normal-case",children:i.accent})]}),e("span",{className:"font-mono text-[12px] uppercase leading-[1.5] tracking-[0.18em] text-fg-dim",children:c})]}),e("span",{className:"text-right font-display text-[17px] font-bold tracking-[-0.005em] text-fg",children:d===null?null:b(d,f)})]})}function k({label:t,value:i}){return a("div",{className:"flex items-center justify-between font-mono text-[13px] font-medium uppercase tracking-[0.18em] text-fg",children:[e("span",{children:t}),e("strong",{className:"font-display text-[16px] font-medium tracking-[-0.005em] normal-case text-fg",children:i})]})}function xe(t){return t.map(i=>i.label).join(" · ")}export{$e as CheckoutContact,Ue as CheckoutOrderSummary,Ye as CheckoutPayment,De as CheckoutShippingAddress,Me as CheckoutShippingMethod,ue as FormLock,M as LeaveLink};
1
+ "use client";import{jsx as e,Fragment as N,jsxs as a}from"react/jsx-runtime";import{useId as O}from"react";import V from"next/image";import X from"next/link";import{lineTotal as Z,useCart as J}from"../CartContext.js";import{useCurrency as ee}from"../CurrencyContext.js";import{Notice as _}from"../Notice.js";import{FREE_PRICE as A}from"../../lib/wheels/price-display.js";import te from"../CouponField.js";import{COUPON_DEFERRED_TOTAL as ne}from"../../lib/cart/coupon-preview.js";import{orderReference as ae}from"../../lib/checkout/pay-first.js";import{PRICES_REQUOTED as re,PRICES_UNCHECKED as ie}from"../../lib/checkout/checkout-memory.js";import{shippingWords as le,TAX_PENDING as oe}from"../../lib/cart/shipping-status.js";import{DEFAULT_FINISH_COLOR as ce}from"../../lib/wheels/finish-defaults.js";import U from"../ThemedSelect.js";import g from"../WebFormField.js";import se from"../WheelSvg.js";import{NO_PAYMENT_METHOD_NOTE as de,placedOrderLockNote as pe,SHIPPING_RETRY_NOTE as me,useCheckout as w}from"./checkout-state.js";import{FIELD_INPUT_CLASS as u}from"../../lib/field-input.js";import{FIGURE_UPDATING as T}from"../../lib/wheels/price-display.js";function $e(){const{email:t,setEmail:i,firstName:n,setFirstName:l,lastName:s,setLastName:d,company:f,setCompany:v,me:b,checkoutSignOut:h,orderLocked:x,unpaidOrder:o}=w(),c=O();return a(L,{num:"N° 01",title:"Contact",children:[x&&o&&e(ge,{orderNumber:o.orderNumber}),e(g,{label:"Email",htmlFor:c,hint:b?a(N,{children:["Signed in ·"," ",e("button",{type:"button",onClick:h,className:"underline transition-colors enabled:hover:text-accent",children:"Not you? Sign out"})]}):void 0,children:e("input",{id:c,type:"email",value:t,onChange:p=>i(p.target.value),placeholder:"you@example.com",readOnly:b!==null,className:u})}),a(z,{children:[e(g,{label:"First name",children:e("input",{type:"text",value:n,onChange:p=>l(p.target.value),className:u})}),e(g,{label:"Last name",children:e("input",{type:"text",value:s,onChange:p=>d(p.target.value),className:u})})]}),e(g,{label:"Company (optional)",children:e("input",{type:"text",value:f,onChange:p=>v(p.target.value),autoComplete:"organization",className:u})})]})}function Me(){const{pickupLocation:t,servedCountries:i,address1:n,setAddress1:l,address2:s,setAddress2:d,city:f,setCity:v,postcode:b,setPostcode:h,phone:x,setPhone:o,country:c,setCountry:p,subdivision:k,setSubdivision:m,subdivisions:E,destination:F,postcodeLabel:S,subdivisionLabel:y,me:B,savedAddresses:R,selectedAddressId:P,setSelectedAddressId:D,saveAddress:$,setSaveAddress:H,saveLabel:G,setSaveLabel:W,fillFromAddress:K,orderLocked:Q}=w(),M=O(),j=O();return a(L,{num:"N° 02",title:t?"Collection":"Shipping address",children:[t?a("div",{className:"grid gap-2 text-[14px] leading-[1.6]",children:[e("span",{className:"font-medium",children:t.name}),[t.address,t.city,t.state,t.zipCode,t.country].filter(Boolean).length>0&&e("span",{className:"opacity-80",children:[t.address,t.city,t.state,t.zipCode,t.country].filter(Boolean).join(", ")}),t.openingHours&&e("span",{className:"opacity-80",children:t.openingHours}),t.readyIn&&e("span",{className:"opacity-80",children:t.readyIn}),t.instructions&&e("span",{className:"opacity-80",children:t.instructions}),e("span",{className:"mt-1 font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"No delivery address needed"})]}):a(N,{children:[B!==null&&R.length>0&&a("div",{className:"grid gap-3",children:[R.map(r=>e(I,{active:P===r.id,onClick:()=>{D(r.id),K(r)},title:r.label,body:r.formatted_address,price:null},r.id)),e(I,{active:P==="new",onClick:()=>D("new"),title:"New address",body:null,price:null})]}),e(g,{label:"Address line 1",children:e("input",{type:"text",value:n,onChange:r=>l(r.target.value),className:u})}),e(g,{label:"Address line 2",children:e("input",{type:"text",value:s,onChange:r=>d(r.target.value),placeholder:"Apartment, unit, garage bay…",className:u})}),a(z,{cols:"three",children:[e(g,{label:"City",children:e("input",{type:"text",value:f,onChange:r=>v(r.target.value),className:u})}),e(g,{label:S,children:e("input",{type:"text",value:b,onChange:r=>h(r.target.value),className:u})}),e(g,{label:"Country",separate:!0,htmlFor:M,children:e(U,{id:M,value:c,onChange:r=>p(r.target.value),className:u+" pr-10",style:q,children:i.map(r=>e("option",{value:r.code,children:r.name},r.code))})})]}),e(g,{label:y,separate:!0,htmlFor:j,children:E.length>0?a(U,{id:j,value:k,onChange:r=>m(r.target.value),className:u+" pr-10",style:q,children:[e("option",{value:"",children:"Select…"}),E.map(r=>e("option",{value:r.code||r.name,children:r.name},r.code||r.name))]}):e("input",{id:j,type:"text",value:k,onChange:r=>m(r.target.value),className:u})})]}),e(g,{label:"Phone",children:e("input",{type:"tel",value:x,onChange:r=>o(r.target.value),className:u})}),!t&&B!==null&&P==="new"&&!Q&&a(N,{children:[e(fe,{checked:$,onChange:H,label:"Save this address to my account"}),$&&e(g,{label:"Address label",children:e("input",{type:"text",value:G,onChange:r=>W(r.target.value),placeholder:"Home",className:u})})]})]})}function Ue(){const{totals:t,coupon:i,deliveryOptions:n,shippingMethodId:l,setShippingMethodId:s,pickupLocation:d,formatMoney:f,city:v,destination:b,courierUnavailable:h,retryCourier:x}=w();return e(L,{num:"N° 03",title:"Shipping",children:a("div",{className:"grid gap-3",children:[n.map(o=>{const c=o.pickupLocation,p=c?[c.address,c.city,c.state,c.zipCode].filter(Boolean).join(", "):null;return e(I,{active:l===o.id,onClick:()=>s(o.id),title:c?`${o.name} — ${c.name}`:o.name,body:c?[p,c.openingHours,c.readyIn,c.instructions,o.description].filter(Boolean).join(" · "):o.description||null,price:t.freeShipping||o.amount===0?A:f(o.amount,t.currency),tag:o.tag||void 0},o.id)}),h?a("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:[me," ",e("button",{type:"button",onClick:x,className:"underline transition-colors enabled:hover:text-accent",children:"Try again"})]}):n.length===0&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Shipping is arranged after your order is reviewed."})]})})}function Ye(){const{payChoice:t,setPayChoice:i,payment:n,payOptions:l,noPaymentMethod:s}=w();return a(L,{num:"N° 04",title:"Payment",children:[s&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:de}),e("div",{className:"grid gap-3",children:l.map(d=>e(I,{active:t===d.key,onClick:()=>i(d.key),title:d.title,body:d.body,price:d.price,tag:d.tag},d.key))}),t==="card"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll enter card details on the secure payment step after placing the order."}):t==="paypal"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll approve the payment with PayPal on the payment step after placing the order."}):t==="afterpay"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll be taken to Afterpay to approve four interest-free payments, then brought straight back."}):t==="square"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll enter card details on the secure payment step after placing the order."}):t==="gocardless"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll set up a bank direct debit with GoCardless, then be brought straight back. Direct debits clear in a few days."}):t==="zip"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll be taken to Zip to approve four instalments, then brought straight back."}):t==="klarna"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You’ll be taken to Klarna to choose how to pay, then brought straight back."}):t==="bank"?e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Our team emails you the invoice and bank details after review."}):null]})}function qe(){const{site:t,items:i,totals:n,coupon:l,formatMoney:s,payChoice:d,placing:f,email:v,orderError:b,payment:h,noPaymentMethod:x,unpaidOrder:o,formLocked:c,restoredPrices:p,quoteFailed:k,retryQuote:m,placeOrder:E}=w(),F=p==="waiting",S=p==="changed";return a("aside",{className:"sticky top-[var(--sf-checkout-header-h,88px)] border border-line max-view-desktop:static",style:{background:"linear-gradient(180deg, color-mix(in oklab, var(--site-surface) 70%, var(--bg)) 0%, var(--bg) 100%)"},children:[a("header",{className:"flex items-center justify-between border-b border-accent bg-accent px-6 py-4 font-mono text-[13px] font-bold uppercase tracking-[0.28em] text-bg",children:[e("span",{children:"Your order"}),e(Y,{href:"/wheels",className:"text-bg/80 transition-colors hover:text-bg",children:"Edit ↗"})]}),e("div",{className:"flex flex-col px-6 py-2",children:i.length===0?a("div",{className:"py-8 text-center font-serif text-[16px] italic leading-[1.5] text-fg-dim",children:["Your cart is empty. ",e(Y,{href:"/wheels",className:"text-accent underline-offset-4 hover:underline",children:"Browse the catalog →"})]}):i.map(y=>e(xe,{slug:y.slug,name:y.name,qty:y.qty,config:y.config,configSummary:be(y.config),price:S||F?null:Z(y,n.currency)??0,currency:n.currency},y.id))}),e(he,{locked:c,className:"border-t border-line px-6 pt-5",children:e(te,{customerEmail:v,disabled:c})}),a("div",{className:"flex flex-col gap-2 border-t border-line mt-5 px-6 pt-5",children:[e(C,{label:"Subtotal",value:F?T:s(S?n.serverSubtotal??0:n.subtotal,n.currency)}),n.discount>0&&l?.valid&&e(C,{label:`Coupon · ${l.code}`,value:a("span",{className:"font-semibold text-green",children:["− ",s(n.discount,n.currency)]})}),l?.deferred&&e(C,{label:`Coupon · ${l.code}`,value:ne}),l?.valid&&l.effects?.gift&&e(C,{label:`Free gift · ${l.effects.gift.partNumber}${l.effects.gift.quantity>1?` ×${l.effects.gift.quantity}`:""}`,value:e("span",{className:"font-semibold text-green",children:A})}),e(C,{label:"Shipping",value:n.shippingStatus==="free"?e("span",{className:"font-semibold text-green",children:A}):le(n.shippingStatus)??s(n.shipping,n.currency)}),n.tax&&(n.tax.charged?e(C,{label:n.tax.inclusive?`${n.tax.name} included · ${n.tax.rate}%`:n.tax.name,value:s(n.tax.amount,n.currency)}):n.tax.name?e(C,{label:n.tax.name,value:oe}):null)]}),a("div",{className:"mt-4 flex items-end justify-between border-y-2 border-accent px-6 py-4",style:{background:"color-mix(in oklab, var(--accent) 10%, var(--bg))"},children:[e("span",{className:"font-display text-[20px] font-bold uppercase tracking-[0.04em] text-fg",children:"Total"}),e("span",{className:"text-right font-display text-[34px] font-bold leading-none tracking-[-0.025em] text-fg",children:n.repricing?T:s(n.grand,n.currency)})]}),a("div",{className:"flex flex-col gap-3 px-6 pt-5 pb-6",children:[S&&e(_,{tone:"quiet",children:re}),k&&a(_,{role:"alert",children:[ie," ",e("button",{type:"button",onClick:m,className:"underline transition-colors enabled:hover:text-accent",children:"Try again"})]}),b&&e(_,{role:"alert",children:b}),n.hasUnpricedLine&&a(_,{role:"status",children:["One or more items have no price in ",n.currency,". Remove them, or switch region, to continue."]}),e("button",{type:"button",onClick:E,disabled:f||!o&&(x||i.length===0||n.hasUnpricedLine||n.repricing),className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",f||!o&&(i.length===0||x||n.hasUnpricedLine||n.repricing)?"cursor-not-allowed border-line bg-surface text-fg-dim":"border-btn bg-btn text-btn-ink hover:border-fg hover:bg-fg"].join(" "),children:f?a(N,{children:["Building order… ",e("span",{children:"·"})]}):x?a(N,{children:["No online payment ",e("span",{children:"·"})]}):o?a(N,{children:["Try payment again · ",ae(o),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]}):k?a(N,{children:["Total not confirmed ",e("span",{children:"·"})]}):n.repricing?a(N,{children:[T," ",e("span",{children:"·"})]}):a(N,{children:[d==="bank"?"Place order":"Continue to payment"," ·"," ",s(n.grand,n.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})})]})]})}const ue=" [&:disabled_:disabled]:cursor-not-allowed! [&:disabled_:disabled]:opacity-70! [&_input[readonly]]:cursor-not-allowed [&_input[readonly]]:opacity-70";function he({locked:t,className:i="",children:n}){return e("fieldset",{disabled:t,className:"m-0 min-w-0 border-0 p-0 "+i+ue,children:n})}function Y({href:t,className:i="",children:n,...l}){const{placing:s}=w();return s?e("span",{"aria-disabled":"true","aria-label":l["aria-label"],className:i+" pointer-events-none",children:n}):e(X,{href:t,"aria-label":l["aria-label"],className:i,children:n})}function ge({orderNumber:t}){return e(_,{tone:"quiet",role:"status",children:a("span",{className:"flex items-start gap-2",children:[a("svg",{"aria-hidden":!0,viewBox:"0 0 16 16",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"mt-[3px] shrink-0",children:[e("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1"}),e("path",{d:"M5 7V5a3 3 0 0 1 6 0v2"})]}),e("span",{children:pe(t)})]})})}const q={backgroundImage:"linear-gradient(45deg, transparent 50%, var(--accent) 50%), linear-gradient(135deg, var(--accent) 50%, transparent 50%)",backgroundPosition:"calc(100% - 18px) 50%, calc(100% - 12px) 50%",backgroundSize:"6px 6px",backgroundRepeat:"no-repeat"};function L({num:t,title:i,children:n}){return a("section",{className:"mb-6 border border-line bg-bg",children:[a("header",{className:"flex items-center gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t}),e("h2",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:i})]}),e("div",{className:"flex flex-col gap-4 px-6 py-6",children:n})]})}function z({cols:t="two",children:i}){return e("div",{className:["grid gap-3 max-[640px]:grid-cols-1",t==="two"?"grid-cols-2":"grid-cols-[1.2fr_1fr_1fr]"].join(" "),children:i})}function I({active:t,onClick:i,title:n,body:l,price:s,tag:d}){return a("button",{type:"button",onClick:i,"aria-pressed":t,className:["relative grid grid-cols-[auto_1fr_auto] items-center gap-5 border bg-bg px-6 py-5 text-left transition-colors",t?"border-accent outline outline-1 outline-accent -outline-offset-1":"border-line enabled:hover:border-[color-mix(in_oklab,var(--accent)_50%,var(--site-line))]"].join(" "),style:t?{background:"color-mix(in oklab, var(--accent) 14%, var(--bg))"}:void 0,children:[t&&e("span",{"aria-hidden":!0,className:"absolute inset-y-0 left-0 w-[3px] bg-accent"}),e("span",{className:["flex h-[18px] w-[18px] items-center justify-center rounded-full border-2",t?"border-accent":"border-fg-dim"].join(" "),children:t&&e("span",{className:"block h-2.5 w-2.5 rounded-full bg-accent"})}),a("span",{className:"flex min-w-0 flex-col gap-1",children:[a("span",{className:"flex flex-wrap items-baseline gap-3 font-display text-[18px] font-medium tracking-[-0.01em] text-fg",children:[n,d&&e("span",{className:"border px-2 py-0.5 font-mono text-[11px] font-normal uppercase tracking-[0.24em] text-accent",style:{background:"color-mix(in oklab, var(--accent) 14%, transparent)",borderColor:"color-mix(in oklab, var(--accent) 45%, var(--site-line))"},children:d})]}),l&&e("span",{className:"font-mono text-[12px] uppercase tracking-[0.22em] text-fg-dim",children:l})]}),e("span",{className:"whitespace-nowrap font-display text-[18px] font-medium tracking-[-0.01em] text-fg",children:s})]})}function fe({checked:t,onChange:i,label:n,sub:l}){return a("div",{className:"flex items-start gap-3 border-t border-line py-4 first:border-t-0 first:pt-0",children:[e("button",{type:"button",onClick:()=>i(!t),"aria-pressed":t,"aria-label":n,className:["mt-px flex h-5 w-5 flex-shrink-0 items-center justify-center border transition-colors",t?"border-accent":"border-line"].join(" "),style:t?{background:"color-mix(in oklab, var(--accent) 18%, transparent)"}:void 0,children:t&&e("span",{className:"text-[13px] text-accent",children:"✓"})}),a("span",{className:"flex-1 font-display text-[16px] leading-[1.5] text-fg",children:[n,l&&e("small",{className:"mt-1 block font-mono text-[12px] uppercase tracking-[0.18em] text-fg-dim",children:l})]})]})}function xe({slug:t,name:i,qty:n,config:l,configSummary:s,price:d,currency:f}){const{catalog:v}=J(),{formatMoney:b}=ee(),h=v.find(m=>m.slug===t),x=h?.spokes??5,o=h?.mesh??!1,c=l.find(m=>m.gold)?.label,p=h?.finishes.find(m=>m.name===c&&m.src)??h?.finishes.find(m=>m.src),k=h?.finishes[0]?.color??ce;return a("div",{className:"grid grid-cols-[60px_1fr_auto] items-center gap-4 border-b border-line py-4 last:border-b-0",children:[a("div",{className:"relative aspect-square",children:[e("div",{className:"flex h-full w-full items-center justify-center overflow-hidden border border-line bg-surface",children:p?.src?e(V,{src:p.src,alt:`${i.lead}${i.accent} — ${p.name}`,width:120,height:120,sizes:"60px",className:"block h-full w-full object-contain p-2"}):e("div",{className:"block w-[78%]",style:{color:k},children:e(se,{spokes:x,mesh:o,className:"block w-full"})})}),e("span",{className:"absolute -right-1.5 -top-1.5 z-[2] flex h-[18px] w-[18px] items-center justify-center rounded-full bg-accent font-mono text-[11px] font-bold text-bg",children:n})]}),a("div",{className:"flex min-w-0 flex-col gap-0.5",children:[a("span",{className:"font-display text-[17px] font-bold uppercase leading-none tracking-[-0.005em] text-fg",children:[i.lead,e("em",{className:"font-serif font-normal italic text-accent tracking-[-0.005em] normal-case",children:i.accent})]}),e("span",{className:"font-mono text-[12px] uppercase leading-[1.5] tracking-[0.18em] text-fg-dim",children:s})]}),e("span",{className:"text-right font-display text-[17px] font-bold tracking-[-0.005em] text-fg",children:d===null?null:b(d,f)})]})}function C({label:t,value:i}){return a("div",{className:"flex items-center justify-between font-mono text-[13px] font-medium uppercase tracking-[0.18em] text-fg",children:[e("span",{children:t}),e("strong",{className:"font-display text-[16px] font-medium tracking-[-0.005em] normal-case text-fg",children:i})]})}function be(t){return t.map(i=>i.label).join(" · ")}export{$e as CheckoutContact,qe as CheckoutOrderSummary,Ye as CheckoutPayment,Me as CheckoutShippingAddress,Ue as CheckoutShippingMethod,he as FormLock,Y as LeaveLink};
@@ -189,6 +189,8 @@ declare function useCheckoutState({ site, logo, preview }: CheckoutProps): {
189
189
  orderLocked: boolean;
190
190
  formLocked: boolean;
191
191
  restoredPrices: "waiting" | "changed" | "same" | null;
192
+ quoteFailed: boolean;
193
+ retryQuote: () => void;
192
194
  payNote: PayNote | null;
193
195
  afterpayConfirming: boolean;
194
196
  gocardlessConfirming: boolean;
@@ -1,3 +1,3 @@
1
- "use client";import{jsx as R}from"react/jsx-runtime";import{createContext as fr,useContext as mr,useEffect as h,useMemo as an,useRef as y,useState as s}from"react";import{isOrderable as un,useCart as yr}from"../CartContext.js";import{useCurrency as hr}from"../CurrencyContext.js";import{getClickIds as gr}from"../../lib/click-ids.js";import{adConsentForOrder as kr}from"../../lib/consent/choice.js";import{trackBeginCheckout as Cr,trackPurchase as wr}from"../../lib/google-tag.js";import{trackMetaPurchase as Pr}from"../../lib/meta-pixel.js";import{ApiError as Fe,api as me,products as w}from"../../lib/api/index.js";import{uuid as qe}from"../../lib/uuid.js";import{orderLinesForSets as br}from"../../lib/commerce.js";import{canPersist as Nr,safeSessionStorage as st}from"efficient-web-builder/format/lib/safe-storage";import{AFTERPAY_CONTEXT_KEY as Sr,AFTERPAY_RETURN as Ar,GOCARDLESS_CONTEXT_KEY as vr,GOCARDLESS_RETURN as Or,KLARNA_CONTEXT_KEY as Er,KLARNA_RETURN as Rr,ZIP_CONTEXT_KEY as Kr,ZIP_RETURN as Mr,runWalletReturn as $e}from"../../lib/checkout/wallet-return.js";import{matchSubdivision as Lr}from"../../lib/checkout/match-subdivision.js";import{clearCheckoutMemory as Tr,holdsPress as _r,parkCheckoutMemory as xr,parkForm as Ir,parkOrder as Fr,parkRequest as ln,readCheckoutMemory as qr,sameGoods as $r,sendableRequest as Br}from"../../lib/checkout/checkout-memory.js";import{checkoutGone as ct,checkoutWaiting as dn,BANK_WAITING as Ur,DROPPABLE_INTENT as Yr,NOT_CHECKED as at,LOST_CHANGE as it,PAY_FIRST_FLOW as ut,paysFirst as Hr,readIntentStatus as Gr,releaseHeldCheckout as pn,CHECKOUT_COMMITTED as Dr,goodsShapeOf as zr,refusedForGood as fn,settlePayFirst as Wr}from"../../lib/checkout/pay-first.js";import{couponCodeForOrder as mn,couponRefusedByOrder as Jr}from"../../lib/cart/coupon-preview.js";function yn(o){const g=o.indexOf(`
2
- `);return g===-1?[o,""]:[o.slice(0,g),o.slice(g+1)]}function hn(o,{canParkContext:g}={canParkContext:!0}){const f=o.paymentMethods,a=[];return f.includes("card")&&a.push({key:"card",title:"Card",body:null,price:R("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"VISA · MC · AMEX"})}),f.includes("paypal")&&o.paypalClientId&&a.push({key:"paypal",title:"PayPal",body:null,price:R("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAYPAL · CARDS"})}),f.includes("afterpay")&&a.push({key:"afterpay",title:"Afterpay",body:null,price:R("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"4 × INTEREST-FREE"})}),f.includes("square")&&o.squareApplicationId&&o.squareLocationId&&a.push({key:"square",title:"Card (Square)",body:null,price:R("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"VISA · MC · AMEX"})}),f.includes("gocardless")&&g&&a.push({key:"gocardless",title:"Bank Direct Debit",body:null,price:R("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY BY BANK"})}),f.includes("zip")&&a.push({key:"zip",title:"Zip",body:null,price:R("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY IN 4"})}),f.includes("klarna")&&g&&a.push({key:"klarna",title:"Klarna",body:null,price:R("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY LATER"})}),f.includes("bank")&&a.push({key:"bank",title:"Bank transfer",body:null,price:R("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Invoiced"})}),a}const Co="This shop does not take payment online yet. Please contact the shop to order.";class Be extends Error{}function gn(o,g){if(!o.orderNumber&&ct(g))return g.message;const f=g instanceof Fe?` (${g.message})`:"";return o.orderNumber?`Your order ${o.orderNumber} is saved, but the payment did not start${f}. Try the payment again — your order will not be placed twice.`:`Your items are held under ${o.checkoutNumber}, but the payment did not start${f}. Try the payment again — you will not be charged twice.`}const Xr=3e3,Zr=.005,kn=new Set(["paypal","square","afterpay","gocardless","zip","klarna"]);function Cn(){const o=kr();return{...o==="denied"?{}:gr(),...o?{adConsent:o}:{}}}const v=o=>JSON.parse(o),jr={lastPress:null,keptCardKey:null,placedShape:null,placedRequest:null,unpaidOrder:null},Qr={lastPress:o=>o&&{key:o.key,request:ln(o.request),lines:o.lines,goods:v(o.shape)[0],plainPressed:!!o.plainMethod,plainLines:o.plainLines,plainGoods:v(o.plainShape)[0]},keptCardKey:o=>o,placedShape:o=>o===null?null:v(o)[0],placedRequest:o=>o&&ln(o.body),unpaidOrder:o=>o&&Fr(o)};function wn(o,g){const f={};for(const a of Object.keys(o))f[a]=o[a](g[a]);return f}const wo="Shipping cannot be calculated right now. Please try again.";function Po(o){return`Your order is saved, so its contact, address, delivery and discount can't change here. To change any of them, contact the shop and quote ${o}.`}function Vr({site:o,logo:g,preview:f=!1}){const{items:a,totals:P,coupon:K,refuseCoupon:bn,deliveryOptions:lt,shippingMethodId:Q,setShippingMethodId:dt,setQuoteDestination:ye,courier:Nn,requote:Ue,identify:pt,clearCapturedCart:he,replaceItems:Ye,removeCoupon:ft,applyCoupon:Sn}=yr(),An=lt.find(e=>e.id===Q)?.pickupLocation??null,{country:mt,countries:V,activeCountry:yt,formatMoney:vn}=hr(),[C,ge]=s(()=>hn(o)[0]?.key??null),[ht,On]=s(!0);h(()=>{On(Nr(st))},[]);const[M,He]=s(!1),[I,ke]=s(""),[L,Ce]=s(""),[H,we]=s(""),[Pe,Ge]=s(""),[ee,te]=s(""),[be,ne]=s(""),[F,re]=s(""),[T,oe]=s(""),[G,se]=s(""),[m,ce]=s(()=>mt||V[0]?.code||""),[O,Ne]=s(""),[ae,gt]=s([]),[De,ze]=s(null),[Se,D]=s(null),kt=an(()=>V.find(e=>e.code===m)??yt,[V,m,yt]),En=kt?.postalLabel||"Postal Code",Rn=ae[0]?.divisionType||"State / Province";h(()=>{if(!m){gt([]),ze(m);return}ze(null);let e=!1;return w.listCountrySubdivisions(m).then(t=>{e||(gt(t),ze(m),Ne(""))}),()=>{e=!0}},[m]);const Ct=ee.trim()!==""&&F.trim()!==""&&T.trim()!==""&&De===m&&(ae.length===0||O!=="")?T.trim():"";h(()=>{ye(m?{country:m,subdivision:O,postcode:Ct}:null)},[m,O,Ct,ye]),h(()=>()=>ye(null),[ye]);const Kn=Nn?.status==="unavailable",Mn=Ue,[ie,wt]=s(null),[Ln,Pt]=s([]),[We,Ae]=s("new"),[bt,Nt]=s(!1),[Je,Tn]=s("Home"),[_n,St]=s(null),[xn,Xe]=s(null),[q,ve]=s(()=>qe()),At=y(null),[Ze,z]=s(null),[In,N]=s(null),[vt,Oe]=s(null),[Ot,Fn]=s(!1),[Et,qn]=s(!1),[_,W]=s(null),[$n,Ee]=s(!1),[k,S]=s(null),Rt=!!k?.orderNumber,Bn=Rt||M,[Un,Yn]=s(null),[Hn,Gn]=s(!1),[Dn,zn]=s(!1),[Wn,Jn]=s(!1),[Xn,Zn]=s(!1),[Kt,jn]=s(!1),[Qn,je]=s(!1),[ue,Mt]=s(null),i=y({...jr});i.current.unpaidOrder=k;const Qe=y(!1),$=y(a),Lt=!!(Ze||ue&&ue.kind!=="processing"||Kt||Ot||Et||vt&&_?.orderNumber);h(()=>{Lt&&(Ye([]),ft())},[Lt,Ye,ft]);const Tt=y(!1);h(()=>{f||Tt.current||!a.some(un)||(Tt.current=!0,Cr({lines:a,currency:P.currency,value:P.subtotal-P.discount,coupon:K?.valid?K.code:void 0}))},[a,P,K,f]),h(()=>{pt(I,L.trim()||void 0)},[I,L,pt]);const _t=y(null),[Re,Vn]=s(null);h(()=>{const e=_t.current;if(!Re||!e)return;const t=()=>e.style.setProperty("--sf-checkout-header-h",`${Re.offsetHeight}px`);t();const r=new ResizeObserver(t);return r.observe(Re),()=>r.disconnect()},[Re]),h(()=>{const e=r=>({setConfirming:r,land:z,markPaid:()=>Ee(!0),note:(c,n)=>Yn({text:c,warning:n}),fail:N,clearCart:he,lostChange:()=>Xe(it)}),t={search:window.location.search,storage:st,scrubQuery:()=>window.history.replaceState(null,"",window.location.pathname)};$e(Ar,{...t,capture:w.captureAfterpayPayment,page:e(Gn)}),$e(Mr,{...t,capture:w.captureZipPayment,page:e(Jn)}),$e(Or,{...t,capture:w.completeGocardlessPayment,page:e(zn)}),$e(Rr,{...t,capture:w.captureKlarnaPayment,page:e(Zn)})},[]);function xt(e){const[t,r]=yn(e.address);te(t),ne(r),re(e.city),oe(e.zip_code),e.country&&ce(e.country),e.phone&&se(e.phone),D({country:e.country||null,state:e.state??""})}h(()=>{if(Se){if((Se.country||m)!==m){D(null);return}De===m&&(Ne(Lr(m,Se.state,ae)),D(null))}},[Se,m,De,ae]),h(()=>{let e=!1;return(async()=>{try{const[t,r,c]=await Promise.all([me.me(),me.myProfile().catch(()=>null),me.myAddresses().catch(()=>[])]);if(e)return;wt(t);const n=c.filter(p=>p.is_active);Pt(n),ke(t.email);const u=(r?.contact_name??"").split(/\s+/);Ce(t.first_name||u[0]||""),we(t.last_name||u.slice(1).join(" "));const d=t.phone||r?.phone;d&&se(d);const l=n.find(p=>p.id===t.default_delivery_location)??n[0];if(l)Ae(l.id),xt(l);else if(r){const[p,j]=yn(r.address??"");te(p),ne(j),re(r.city??""),oe(r.zip_code??""),r.country&&ce(r.country),D({country:r.country||null,state:r.state??""})}Ie.current&&Ht(Ie.current,!1)}catch{}})(),()=>{e=!0}},[]);function er(){me.logout(),le.current=!0,Ie.current=null,xe.current=null,de(),wt(null),Pt([]),Ae("new"),Nt(!1),ke(""),Ce(""),we(""),Ge(""),te(""),ne(""),re(""),oe(""),se(""),ce(mt||V[0]?.code||""),Ne(""),D(null)}const J=an(()=>hn(o,{canParkContext:ht}),[o,ht]);h(()=>{J.some(e=>e.key===C)||ge(J[0]?.key??null)},[J,C]);const tr=J.length===0,Ke=be.trim()?`${ee}
3
- ${be.trim()}`:ee,nr=zr({email:I,firstName:L,lastName:H,company:Pe.trim(),phone:G,address:Ke,city:F,subdivision:O,postcode:T,country:m,lines:a.map(e=>[e.id,e.qty]),shippingMethodId:Q,couponCode:mn(K),currency:P.currency,shopperId:ie?.id??null}),b=JSON.stringify([nr,C]),Ve=y(null),Me=y(!1),x=y(!1),X=y(null),Le=y(!1),A=y(b);A.current=b;const It=y(M);It.current=M;const Te=y(null);h(()=>{const e=()=>{const t=Te.current;t&&(Te.current=null,S(t),He(!1))};return window.addEventListener("pageshow",e),()=>window.removeEventListener("pageshow",e)},[]);function _e(e,t,r,c){const n={idempotencyKey:t,confirmation:r};Xt()&&(n.lostChange=!0),st.setItem(e,JSON.stringify(n)),window.location.assign(c),Te.current=r}async function Ft(e){He(!0);try{await e()}finally{Te.current||He(!1)}}const qt=y(!1),$t=!!(Ze||ue&&ue.kind!=="processing");h(()=>{$t&&(qt.current=!0,de())},[$t]);const xe=y(null),le=y(!1),et=y(null);function de(){et.current=null,Tr()}const Ie=y(null),[Z,rr]=s(!1);function tt(e){if(qt.current||f||le.current)return;const t={key:e,authed:Qe.current,parkedAt:et.current??=Date.now(),press:wn(Qr,i.current),lines:a.length>0?a:$.current,form:Ir({email:I,firstName:L,lastName:H,company:Pe,address1:ee,address2:be,city:F,postcode:T,phone:G,country:m,subdivision:O,selectedAddressId:We,shippingMethodId:Q,couponCode:K?.valid?K.code:null})};_r(t.press)?xr(t):de()}const Bt=y(C);Bt.current=C;function nt(e){return{...Br(e),...Cn(),...e.payFirst?{checkoutFlow:ut}:{}}}function or(e,t){let r=e.request.payFirst?"":null,c=e.plainPressed?null:"";const n=()=>Bt.current??"";return{key:e.key,send:()=>t(nt(e.request)),request:nt(e.request),lines:e.lines,shape:JSON.stringify([e.goods,null]),get method(){return r??n()},set method(u){r=u},get plainMethod(){return c??n()},set plainMethod(u){c=u},plainLines:e.plainLines,plainShape:JSON.stringify([e.plainGoods,null])}}const[sr,cr]=s(!1),Ut=sr?!P.quoted||P.serverSubtotal===null?"waiting":Math.abs(P.serverSubtotal-P.subtotal)<Zr?"same":"changed":null,rt=!k&&Ut==="waiting",ar=rt?{...P,repricing:!0}:P,Yt=rt&&P.quoteFailed;h(()=>{if(!Yt)return;const e=setInterval(Ue,Xr);return()=>clearInterval(e)},[Yt,Ue]);function Ht(e,t=!0){ke(e.email),Ce(e.firstName),we(e.lastName),Ge(e.company),te(e.address1),ne(e.address2),re(e.city),oe(e.postcode),se(e.phone),e.country&&ce(e.country),D({country:e.country||null,state:e.subdivision}),Ae(e.selectedAddressId),e.shippingMethodId&&dt(e.shippingMethodId),t&&(xe.current=e.couponCode)}h(()=>{let e=f?null:qr();const t=!!(e&&a.length>0);if(e&&t&&!$r(e.lines,a)&&(de(),e=null),e){const r=e.authed?w.createOrderAuthed:w.createOrder;ve(e.key),et.current=e.parkedAt,Qe.current=e.authed;const c={lastPress:n=>n&&or(n,r),keptCardKey:n=>n,placedShape:n=>n===null?null:JSON.stringify([n,null]),placedRequest:n=>{if(!n)return null;const u=nt(n);return{body:u,send:()=>r(u)}},unpaidOrder:n=>n};i.current=wn(c,e.press),e.press.unpaidOrder&&S(e.press.unpaidOrder),e.lines.length>0&&!t&&(Ye(e.lines),$.current=e.lines,cr(!0)),e.form&&(Ie.current=e.form,Ht(e.form))}rr(!0)},[]),h(()=>{!Z||a.length>0||i.current.unpaidOrder||M||(le.current=!0,de())},[Z,a.length]),h(()=>{const e=xe.current;!Z||!e||a.length===0||(xe.current=null,Sn(e,I||void 0))},[Z,a.length]),h(()=>{!Z||M||tt(q)},[Z,M,q,k]);const B=y(null);h(()=>{It.current||(b!==B.current&&(B.current=null),!(!x.current||!k||k.orderNumber)&&(b===i.current.placedShape||b===B.current||Ft(()=>Gt(k))))},[b,k]);async function Gt(e){if(Le.current)return null;Le.current=!0;try{const t=X.current?await Gr(X.current):"none";if(t==="succeeded"||t==="processing")return x.current=!1,S(null),E("card"),t==="succeeded"?await U(void 0,e):en(e),null;if(t===void 0||!Yr.has(t))return B.current=A.current,S(e),N(t==="requires_action"?Ur:at),null;const r=await pn(q);if(r==="committed")return x.current=!1,S(null),E("card"),await U(void 0,e),null;if(r!=="released")return B.current=A.current,S(e),N(at),null;x.current=!1,X.current=null,B.current=null,N(null),S(null);const c=qe();return ve(c),c}finally{Le.current=!1}}async function ir(){f||M||Le.current||await Ft(ur)}async function ur(){if(k){if((x.current?b!==i.current.placedShape:pe())&&!k.orderNumber){const c=await Gt(k);c&&A.current===b&&await Dt(c);return}N(null),Me.current=!1,await ot();const t=v(A.current)[1],r=k.orderNumber?t:"card";if(r&&kn.has(r)&&pe()&&v(A.current)[0]!==Ve.current){zt(k);return}E(r),r!==C&&ge(r),await tn(k,r,!k.orderNumber);return}await Dt(q)}async function Dt(e){if(a.length===0||P.repricing||rt||!C||!J.some(d=>d.key===C))return;const t=a.filter(un).flatMap(d=>br(d.components,d.qty));if(t.length===0){N("Pick a size on each wheel's product page before checking out.");return}N(null);let r,c=e,n=C,u=!1;try{const d=ie?w.createOrderAuthed:w.createOrder,l={customer:{email:I,name:`${L} ${H}`.trim(),phone:G.trim()||void 0,companyName:Pe.trim()||void 0,address:Ke,city:F,state:O||void 0,zipCode:T,country:m},items:t,currency:P.currency,idempotencyKey:e,shippingMethodId:Q??void 0,couponCode:mn(K),...Cn(),...Hr(C)?{checkoutFlow:ut}:{}};i.current.placedRequest={body:l,send:()=>d(l)},Qe.current=!!ie,le.current=!1,Xe(null),Ve.current=null,Me.current=!1,X.current=null,x.current=!1,B.current=null,i.current.placedShape=b,$.current=a;const p=i.current.lastPress,j=p?.key===l.idempotencyKey&&(p.shape!==b&&(!!l.checkoutFlow||!!p.method||!!p.plainMethod)||!!l.checkoutFlow&&!!p.plainMethod);j&&(i.current.keptCardKey=l.idempotencyKey);const on=jt(l,d),sn=j||!l.checkoutFlow&&i.current.keptCardKey===l.idempotencyKey,cn=!on&&!sn&&!l.checkoutFlow&&!!p&&!p.method;cn&&(p.plainMethod=C,p.plainLines=a,p.plainShape=b,tt(l.idempotencyKey));const Y=await(sn?Jt(l,d):d(l).then(fe=>({answer:fe,request:l})).catch(fe=>(on?Wt(fe,l.idempotencyKey):cn&&fn(fe)&&(p.plainMethod=""),lr(fe,l,d))));if(!Y)return;r=Y.answer,c=Y.request.idempotencyKey,n=Y.method??n,E(n),u=pe()||n!==v(A.current)[1],Y.method&&Y.method!==C&&ge(Y.method),r.orderNumber&&(Qt(r),he()),await ot()}catch(d){const l=Jr(d);l?(bn(l),N(`${l} Your order has not been placed. Place it again to continue without the code.`)):d instanceof Be?N(at):N(d instanceof Fe?d.message:"Could not place the order. Please try again.");return}if(n&&kn.has(n)&&(u||pe())){zt(r);return}await tn(r,n,!1,c)}function zt(e){Ve.current=v(A.current)[0],N(`${gn(e,null)} ${it}`),S(e)}function Wt(e,t){fn(e)&&!dn(e)&&i.current.lastPress?.key===t&&(i.current.lastPress=null)}async function lr(e,t,r){if(ct(e))return Zt(t,r);if(!dn(e))throw e;return i.current.keptCardKey=t.idempotencyKey,Jt(t,r,!0)}async function Jt(e,t,r=!1){const c=await pn(e.idempotencyKey);if(c==="released")return Zt(e,t);if(c!=="committed")throw new Be;const n=i.current.lastPress?.key===e.idempotencyKey?i.current.lastPress:null;if($.current=n?.lines??a,n?.method&&!r){i.current.keptCardKey=null,i.current.placedRequest={body:n.request,send:n.send};const j=await n.send().catch(()=>{throw new Be});return i.current.placedShape=n.shape,{answer:j,request:e,method:n.method}}const u={...e,checkoutFlow:ut},d=n&&!n.method?{body:n.request,send:n.send}:{body:u,send:()=>t(u)};i.current.placedRequest=d;const l=d.send,p=await l().catch(()=>null);if(!p&&n?.plainMethod)throw new Be;return p?.orderNumber&&p.status!==Dr?(i.current.keptCardKey=null,n?.plainMethod&&($.current=n.plainLines),n&&(i.current.placedShape=n.plainMethod?n.plainShape:n.shape),{answer:p,request:e,method:n?.plainMethod||void 0}):(n&&(i.current.placedShape=n.shape),E("card"),await Vt("",p?async()=>p:()=>Promise.reject(new Error("The order request did not answer."))),await ot(),null)}function pe(){const e=i.current.placedShape;return e!==null&&v(e)[0]!==v(A.current)[0]}function E(e){e!==v(A.current)[1]&&(Me.current=!0),Xe(Xt()?it:null)}function Xt(){return Me.current||pe()}async function Zt(e,t){const r={...e,idempotencyKey:qe()};i.current.keptCardKey=null,ve(r.idempotencyKey),i.current.placedRequest={body:r,send:()=>t(r)},jt(r,t);try{return{answer:await t(r),request:r}}catch(c){throw Wt(c,r.idempotencyKey),c}}function jt(e,t){return i.current.lastPress?.key===e.idempotencyKey?!1:(i.current.lastPress={key:e.idempotencyKey,send:()=>t(e),request:e,lines:a,shape:b,method:e.checkoutFlow?"":C??"",plainMethod:"",plainLines:a,plainShape:b},le.current=!1,tt(e.idempotencyKey),!0)}function Qt(e){wr({confirmation:e,lines:$.current,adsSendTo:o.googleAdsId&&o.googleAdsConversionLabel?`${o.googleAdsId}/${o.googleAdsConversionLabel}`:null}),Pr({confirmation:e,lines:$.current})}async function U(e,t=_){if(!t)return;const r=e?async()=>e:i.current.placedRequest?.send;if(t.orderNumber||!r){Ee(!0),z(t);return}await Vt(t.checkoutNumber,r)}async function Vt(e,t){he(),await Wr({checkoutNumber:e,resend:t,page:{setConfirming:jn,land:z,markPaid:()=>Ee(!0),track:Qt,unplaced:Mt}})}function en(e=_){if(e){if(e.orderNumber){z(e);return}he(),Mt({kind:"processing",checkoutNumber:e.checkoutNumber})}}async function ot(){const e=JSON.stringify([Je.trim(),L,H,G.trim(),Ke,F,O,T,m]);if(!(!ie||!bt||We!=="new"||At.current===e))try{await me.createAddress({label:Je.trim()||"Home",contact_name:`${L} ${H}`.trim(),phone:G.trim(),address:Ke,city:F,zip_code:T,state:O,country:m}),At.current=e,St("Address saved to your account.")}catch{St("We couldn't save the address to your account — you can add it under Account → Addresses.")}}async function tn(e,t=C,r=!1,c=q){S(null);try{if(t==="card"&&o.paymentMethods.includes("card")){const n=await w.createPaymentIntent({idempotencyKey:c});X.current=n;let u=e;if(r){const d=await i.current.placedRequest?.send().catch(()=>null);if(d?.orderNumber){E("card"),await U(d,e);return}u=nn(e,d)??{...e,expiresAt:null}}E("card"),W(u),je(!1),Oe(n)}else if(t==="paypal"&&o.paymentMethods.includes("paypal"))W(e),Fn(!0);else if(t==="afterpay"&&o.paymentMethods.includes("afterpay")){const n=window.location.origin,u=await w.createAfterpayCheckout({idempotencyKey:c,confirmUrl:`${n}/checkout?afterpay=confirm`,cancelUrl:`${n}/checkout?afterpay=cancel`});_e(Sr,c,e,u.redirectCheckoutUrl);return}else if(t==="square"&&o.paymentMethods.includes("square"))W(e),qn(!0);else if(t==="gocardless"&&o.paymentMethods.includes("gocardless")){const n=window.location.origin,u=await w.createGocardlessBillingRequest({idempotencyKey:c,confirmUrl:`${n}/checkout?gocardless=confirm`,cancelUrl:`${n}/checkout?gocardless=cancel`});_e(vr,c,e,u.authorisationUrl);return}else if(t==="zip"&&o.paymentMethods.includes("zip")){const n=window.location.origin,u=await w.createZipCheckout({idempotencyKey:c,redirectUrl:`${n}/checkout?zip=return`});_e(Kr,c,e,u.redirectUrl);return}else if(t==="klarna"&&o.paymentMethods.includes("klarna")){const n=window.location.origin,u=await w.createKlarnaCheckout({idempotencyKey:c,confirmUrl:`${n}/checkout?klarna=confirm`,cancelUrl:`${n}/checkout?klarna=cancel`});_e(Er,c,e,u.redirectUrl);return}else E(t),z(e)}catch(n){if((r||t==="card")&&n instanceof Fe&&n.status===409){E(t),await U(void 0,e);return}rn(e,n)}}function nn(e,t){return t&&!t.orderNumber&&t.status==="open"&&t.checkoutNumber===e.checkoutNumber?t:null}function rn(e,t){N(gn(e,t)),!e.orderNumber&&ct(t)?(x.current=!1,ve(qe())):S(e)}async function dr(e){if(!_)return;const t=_;try{const r=await w.createPaymentIntent({idempotencyKey:q}),c=await i.current.placedRequest?.send().catch(()=>null);if(c?.orderNumber){await U(c);return}const n=nn(t,c);W(n??{...t,expiresAt:null}),je(e&&n!==null),X.current=r,Oe(r)}catch(r){if(r instanceof Fe&&r.status===409){await U();return}Oe(null),W(null),rn(t,r)}}function pr(){_&&(x.current=!0,S(_),Oe(null),W(null),je(!1))}return{site:o,logo:g,items:a,totals:ar,coupon:K,deliveryOptions:lt,courierUnavailable:Kn,retryCourier:Mn,shippingMethodId:Q,setShippingMethodId:dt,pickupLocation:An,servedCountries:V,formatMoney:vn,payChoice:C,setPayChoice:ge,placing:M,email:I,setEmail:ke,firstName:L,setFirstName:Ce,lastName:H,setLastName:we,company:Pe,setCompany:Ge,address1:ee,setAddress1:te,address2:be,setAddress2:ne,city:F,setCity:re,postcode:T,setPostcode:oe,phone:G,setPhone:se,country:m,setCountry:ce,subdivision:O,setSubdivision:Ne,subdivisions:ae,destination:kt,postcodeLabel:En,subdivisionLabel:Rn,me:ie,savedAddresses:Ln,selectedAddressId:We,setSelectedAddressId:Ae,saveAddress:bt,setSaveAddress:Nt,saveLabel:Je,setSaveLabel:Tn,addressSaveNote:_n,lostChangeNote:xn,idemKey:q,confirmation:Ze,setConfirmation:z,orderError:In,payment:vt,paypalStep:Ot,squareStep:Et,pendingConf:_,paid:$n,setPaid:Ee,unpaidOrder:k,orderLocked:Rt,formLocked:Bn,restoredPrices:Ut,payNote:Un,afterpayConfirming:Hn,gocardlessConfirming:Dn,zipConfirming:Wn,klarnaConfirming:Xn,cardConfirming:Kt,checkoutResult:ue,confirmCardPayment:U,cardStillProcessing:en,renewCardPayment:dr,holdRenewed:Qn,leaveCardPayment:pr,checkoutRootRef:_t,setCheckoutHeaderEl:Vn,fillFromAddress:xt,checkoutSignOut:er,payOptions:J,noPaymentMethod:tr,placeOrder:ir}}const Pn=fr(null);function bo({children:o,...g}){const f=Vr(g);return R(Pn.Provider,{value:f,children:o})}function No(){const o=mr(Pn);if(!o)throw new Error("useCheckout must be used inside CheckoutStateProvider");return o}export{bo as CheckoutStateProvider,Co as NO_PAYMENT_METHOD_NOTE,wo as SHIPPING_RETRY_NOTE,hn as buildPayOptions,gn as paymentNotStartedMessage,Po as placedOrderLockNote,No as useCheckout};
1
+ "use client";import{jsx as R}from"react/jsx-runtime";import{createContext as mr,useContext as yr,useEffect as h,useMemo as an,useRef as y,useState as s}from"react";import{isOrderable as un,useCart as hr}from"../CartContext.js";import{useCurrency as gr}from"../CurrencyContext.js";import{getClickIds as kr}from"../../lib/click-ids.js";import{adConsentForOrder as Cr}from"../../lib/consent/choice.js";import{trackBeginCheckout as wr,trackPurchase as Pr}from"../../lib/google-tag.js";import{trackMetaPurchase as br}from"../../lib/meta-pixel.js";import{ApiError as qe,api as me,products as w}from"../../lib/api/index.js";import{uuid as $e}from"../../lib/uuid.js";import{orderLinesForSets as Nr}from"../../lib/commerce.js";import{canPersist as Sr,safeSessionStorage as ct}from"efficient-web-builder/format/lib/safe-storage";import{AFTERPAY_CONTEXT_KEY as Ar,AFTERPAY_RETURN as vr,GOCARDLESS_CONTEXT_KEY as Or,GOCARDLESS_RETURN as Er,KLARNA_CONTEXT_KEY as Rr,KLARNA_RETURN as Kr,ZIP_CONTEXT_KEY as Mr,ZIP_RETURN as Lr,runWalletReturn as Be}from"../../lib/checkout/wallet-return.js";import{matchSubdivision as Tr}from"../../lib/checkout/match-subdivision.js";import{clearCheckoutMemory as _r,holdsPress as xr,parkCheckoutMemory as Ir,parkForm as Fr,parkOrder as qr,parkRequest as ln,readCheckoutMemory as $r,sameGoods as Br,sendableRequest as Ur}from"../../lib/checkout/checkout-memory.js";import{checkoutGone as at,checkoutWaiting as dn,BANK_WAITING as Yr,DROPPABLE_INTENT as Hr,NOT_CHECKED as it,LOST_CHANGE as ut,PAY_FIRST_FLOW as lt,paysFirst as Gr,readIntentStatus as Dr,releaseHeldCheckout as pn,CHECKOUT_COMMITTED as zr,goodsShapeOf as Wr,refusedForGood as fn,settlePayFirst as Jr}from"../../lib/checkout/pay-first.js";import{couponCodeForOrder as mn,couponRefusedByOrder as Xr}from"../../lib/cart/coupon-preview.js";function yn(o){const g=o.indexOf(`
2
+ `);return g===-1?[o,""]:[o.slice(0,g),o.slice(g+1)]}function hn(o,{canParkContext:g}={canParkContext:!0}){const f=o.paymentMethods,a=[];return f.includes("card")&&a.push({key:"card",title:"Card",body:null,price:R("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"VISA · MC · AMEX"})}),f.includes("paypal")&&o.paypalClientId&&a.push({key:"paypal",title:"PayPal",body:null,price:R("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAYPAL · CARDS"})}),f.includes("afterpay")&&a.push({key:"afterpay",title:"Afterpay",body:null,price:R("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"4 × INTEREST-FREE"})}),f.includes("square")&&o.squareApplicationId&&o.squareLocationId&&a.push({key:"square",title:"Card (Square)",body:null,price:R("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"VISA · MC · AMEX"})}),f.includes("gocardless")&&g&&a.push({key:"gocardless",title:"Bank Direct Debit",body:null,price:R("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY BY BANK"})}),f.includes("zip")&&a.push({key:"zip",title:"Zip",body:null,price:R("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY IN 4"})}),f.includes("klarna")&&g&&a.push({key:"klarna",title:"Klarna",body:null,price:R("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY LATER"})}),f.includes("bank")&&a.push({key:"bank",title:"Bank transfer",body:null,price:R("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Invoiced"})}),a}const wo="This shop does not take payment online yet. Please contact the shop to order.";class Ue extends Error{}function gn(o,g){if(!o.orderNumber&&at(g))return g.message;const f=g instanceof qe?` (${g.message})`:"";return o.orderNumber?`Your order ${o.orderNumber} is saved, but the payment did not start${f}. Try the payment again — your order will not be placed twice.`:`Your items are held under ${o.checkoutNumber}, but the payment did not start${f}. Try the payment again — you will not be charged twice.`}const Zr=3e3,jr=.005,kn=new Set(["paypal","square","afterpay","gocardless","zip","klarna"]);function Cn(){const o=Cr();return{...o==="denied"?{}:kr(),...o?{adConsent:o}:{}}}const v=o=>JSON.parse(o),Qr={lastPress:null,keptCardKey:null,placedShape:null,placedRequest:null,unpaidOrder:null},Vr={lastPress:o=>o&&{key:o.key,request:ln(o.request),lines:o.lines,goods:v(o.shape)[0],plainPressed:!!o.plainMethod,plainLines:o.plainLines,plainGoods:v(o.plainShape)[0]},keptCardKey:o=>o,placedShape:o=>o===null?null:v(o)[0],placedRequest:o=>o&&ln(o.body),unpaidOrder:o=>o&&qr(o)};function wn(o,g){const f={};for(const a of Object.keys(o))f[a]=o[a](g[a]);return f}const Po="Shipping cannot be calculated right now. Please try again.";function bo(o){return`Your order is saved, so its contact, address, delivery and discount can't change here. To change any of them, contact the shop and quote ${o}.`}function eo({site:o,logo:g,preview:f=!1}){const{items:a,totals:P,coupon:K,refuseCoupon:bn,deliveryOptions:dt,shippingMethodId:Q,setShippingMethodId:pt,setQuoteDestination:ye,courier:Nn,requote:he,identify:ft,clearCapturedCart:ge,replaceItems:Ye,removeCoupon:mt,applyCoupon:Sn}=hr(),An=dt.find(e=>e.id===Q)?.pickupLocation??null,{country:yt,countries:V,activeCountry:ht,formatMoney:vn}=gr(),[C,ke]=s(()=>hn(o)[0]?.key??null),[gt,On]=s(!0);h(()=>{On(Sr(ct))},[]);const[M,He]=s(!1),[I,Ce]=s(""),[L,we]=s(""),[H,Pe]=s(""),[be,Ge]=s(""),[ee,te]=s(""),[Ne,ne]=s(""),[F,re]=s(""),[T,oe]=s(""),[G,se]=s(""),[m,ce]=s(()=>yt||V[0]?.code||""),[O,Se]=s(""),[ae,kt]=s([]),[De,ze]=s(null),[Ae,D]=s(null),Ct=an(()=>V.find(e=>e.code===m)??ht,[V,m,ht]),En=Ct?.postalLabel||"Postal Code",Rn=ae[0]?.divisionType||"State / Province";h(()=>{if(!m){kt([]),ze(m);return}ze(null);let e=!1;return w.listCountrySubdivisions(m).then(t=>{e||(kt(t),ze(m),Se(""))}),()=>{e=!0}},[m]);const wt=ee.trim()!==""&&F.trim()!==""&&T.trim()!==""&&De===m&&(ae.length===0||O!=="")?T.trim():"";h(()=>{ye(m?{country:m,subdivision:O,postcode:wt}:null)},[m,O,wt,ye]),h(()=>()=>ye(null),[ye]);const Kn=Nn?.status==="unavailable",Mn=he,[ie,Pt]=s(null),[Ln,bt]=s([]),[We,ve]=s("new"),[Nt,St]=s(!1),[Je,Tn]=s("Home"),[_n,At]=s(null),[xn,Xe]=s(null),[q,Oe]=s(()=>$e()),vt=y(null),[Ze,z]=s(null),[In,N]=s(null),[Ot,Ee]=s(null),[Et,Fn]=s(!1),[Rt,qn]=s(!1),[_,W]=s(null),[$n,Re]=s(!1),[k,S]=s(null),Kt=!!k?.orderNumber,Bn=Kt||M,[Un,Yn]=s(null),[Hn,Gn]=s(!1),[Dn,zn]=s(!1),[Wn,Jn]=s(!1),[Xn,Zn]=s(!1),[Mt,jn]=s(!1),[Qn,je]=s(!1),[ue,Lt]=s(null),i=y({...Qr});i.current.unpaidOrder=k;const Qe=y(!1),$=y(a),Tt=!!(Ze||ue&&ue.kind!=="processing"||Mt||Et||Rt||Ot&&_?.orderNumber);h(()=>{Tt&&(Ye([]),mt())},[Tt,Ye,mt]);const _t=y(!1);h(()=>{f||_t.current||!a.some(un)||(_t.current=!0,wr({lines:a,currency:P.currency,value:P.subtotal-P.discount,coupon:K?.valid?K.code:void 0}))},[a,P,K,f]),h(()=>{ft(I,L.trim()||void 0)},[I,L,ft]);const xt=y(null),[Ke,Vn]=s(null);h(()=>{const e=xt.current;if(!Ke||!e)return;const t=()=>e.style.setProperty("--sf-checkout-header-h",`${Ke.offsetHeight}px`);t();const r=new ResizeObserver(t);return r.observe(Ke),()=>r.disconnect()},[Ke]),h(()=>{const e=r=>({setConfirming:r,land:z,markPaid:()=>Re(!0),note:(c,n)=>Yn({text:c,warning:n}),fail:N,clearCart:ge,lostChange:()=>Xe(ut)}),t={search:window.location.search,storage:ct,scrubQuery:()=>window.history.replaceState(null,"",window.location.pathname)};Be(vr,{...t,capture:w.captureAfterpayPayment,page:e(Gn)}),Be(Lr,{...t,capture:w.captureZipPayment,page:e(Jn)}),Be(Er,{...t,capture:w.completeGocardlessPayment,page:e(zn)}),Be(Kr,{...t,capture:w.captureKlarnaPayment,page:e(Zn)})},[]);function It(e){const[t,r]=yn(e.address);te(t),ne(r),re(e.city),oe(e.zip_code),e.country&&ce(e.country),e.phone&&se(e.phone),D({country:e.country||null,state:e.state??""})}h(()=>{if(Ae){if((Ae.country||m)!==m){D(null);return}De===m&&(Se(Tr(m,Ae.state,ae)),D(null))}},[Ae,m,De,ae]),h(()=>{let e=!1;return(async()=>{try{const[t,r,c]=await Promise.all([me.me(),me.myProfile().catch(()=>null),me.myAddresses().catch(()=>[])]);if(e)return;Pt(t);const n=c.filter(p=>p.is_active);bt(n),Ce(t.email);const u=(r?.contact_name??"").split(/\s+/);we(t.first_name||u[0]||""),Pe(t.last_name||u.slice(1).join(" "));const d=t.phone||r?.phone;d&&se(d);const l=n.find(p=>p.id===t.default_delivery_location)??n[0];if(l)ve(l.id),It(l);else if(r){const[p,j]=yn(r.address??"");te(p),ne(j),re(r.city??""),oe(r.zip_code??""),r.country&&ce(r.country),D({country:r.country||null,state:r.state??""})}Fe.current&&Ht(Fe.current,!1)}catch{}})(),()=>{e=!0}},[]);function er(){me.logout(),le.current=!0,Fe.current=null,Ie.current=null,de(),Pt(null),bt([]),ve("new"),St(!1),Ce(""),we(""),Pe(""),Ge(""),te(""),ne(""),re(""),oe(""),se(""),ce(yt||V[0]?.code||""),Se(""),D(null)}const J=an(()=>hn(o,{canParkContext:gt}),[o,gt]);h(()=>{J.some(e=>e.key===C)||ke(J[0]?.key??null)},[J,C]);const tr=J.length===0,Me=Ne.trim()?`${ee}
3
+ ${Ne.trim()}`:ee,nr=Wr({email:I,firstName:L,lastName:H,company:be.trim(),phone:G,address:Me,city:F,subdivision:O,postcode:T,country:m,lines:a.map(e=>[e.id,e.qty]),shippingMethodId:Q,couponCode:mn(K),currency:P.currency,shopperId:ie?.id??null}),b=JSON.stringify([nr,C]),Ve=y(null),Le=y(!1),x=y(!1),X=y(null),Te=y(!1),A=y(b);A.current=b;const Ft=y(M);Ft.current=M;const _e=y(null);h(()=>{const e=()=>{const t=_e.current;t&&(_e.current=null,S(t),He(!1))};return window.addEventListener("pageshow",e),()=>window.removeEventListener("pageshow",e)},[]);function xe(e,t,r,c){const n={idempotencyKey:t,confirmation:r};Xt()&&(n.lostChange=!0),ct.setItem(e,JSON.stringify(n)),window.location.assign(c),_e.current=r}async function qt(e){He(!0);try{await e()}finally{_e.current||He(!1)}}const $t=y(!1),Bt=!!(Ze||ue&&ue.kind!=="processing");h(()=>{Bt&&($t.current=!0,de())},[Bt]);const Ie=y(null),le=y(!1),et=y(null);function de(){et.current=null,_r()}const Fe=y(null),[Z,rr]=s(!1);function tt(e){if($t.current||f||le.current)return;const t={key:e,authed:Qe.current,parkedAt:et.current??=Date.now(),press:wn(Vr,i.current),lines:a.length>0?a:$.current,form:Fr({email:I,firstName:L,lastName:H,company:be,address1:ee,address2:Ne,city:F,postcode:T,phone:G,country:m,subdivision:O,selectedAddressId:We,shippingMethodId:Q,couponCode:K?.valid?K.code:null})};xr(t.press)?Ir(t):de()}const Ut=y(C);Ut.current=C;function nt(e){return{...Ur(e),...Cn(),...e.payFirst?{checkoutFlow:lt}:{}}}function or(e,t){let r=e.request.payFirst?"":null,c=e.plainPressed?null:"";const n=()=>Ut.current??"";return{key:e.key,send:()=>t(nt(e.request)),request:nt(e.request),lines:e.lines,shape:JSON.stringify([e.goods,null]),get method(){return r??n()},set method(u){r=u},get plainMethod(){return c??n()},set plainMethod(u){c=u},plainLines:e.plainLines,plainShape:JSON.stringify([e.plainGoods,null])}}const[sr,cr]=s(!1),Yt=sr?!P.quoted||P.serverSubtotal===null?"waiting":Math.abs(P.serverSubtotal-P.subtotal)<jr?"same":"changed":null,rt=!k&&Yt==="waiting",ar=rt?{...P,repricing:!0}:P,ot=rt&&P.quoteFailed;h(()=>{if(!ot)return;const e=setInterval(he,Zr);return()=>clearInterval(e)},[ot,he]);const ir=he;function Ht(e,t=!0){Ce(e.email),we(e.firstName),Pe(e.lastName),Ge(e.company),te(e.address1),ne(e.address2),re(e.city),oe(e.postcode),se(e.phone),e.country&&ce(e.country),D({country:e.country||null,state:e.subdivision}),ve(e.selectedAddressId),e.shippingMethodId&&pt(e.shippingMethodId),t&&(Ie.current=e.couponCode)}h(()=>{let e=f?null:$r();const t=!!(e&&a.length>0);if(e&&t&&!Br(e.lines,a)&&(de(),e=null),e){const r=e.authed?w.createOrderAuthed:w.createOrder;Oe(e.key),et.current=e.parkedAt,Qe.current=e.authed;const c={lastPress:n=>n&&or(n,r),keptCardKey:n=>n,placedShape:n=>n===null?null:JSON.stringify([n,null]),placedRequest:n=>{if(!n)return null;const u=nt(n);return{body:u,send:()=>r(u)}},unpaidOrder:n=>n};i.current=wn(c,e.press),e.press.unpaidOrder&&S(e.press.unpaidOrder),e.lines.length>0&&!t&&(Ye(e.lines),$.current=e.lines,cr(!0)),e.form&&(Fe.current=e.form,Ht(e.form))}rr(!0)},[]),h(()=>{!Z||a.length>0||i.current.unpaidOrder||M||(le.current=!0,de())},[Z,a.length]),h(()=>{const e=Ie.current;!Z||!e||a.length===0||(Ie.current=null,Sn(e,I||void 0))},[Z,a.length]),h(()=>{!Z||M||tt(q)},[Z,M,q,k]);const B=y(null);h(()=>{Ft.current||(b!==B.current&&(B.current=null),!(!x.current||!k||k.orderNumber)&&(b===i.current.placedShape||b===B.current||qt(()=>Gt(k))))},[b,k]);async function Gt(e){if(Te.current)return null;Te.current=!0;try{const t=X.current?await Dr(X.current):"none";if(t==="succeeded"||t==="processing")return x.current=!1,S(null),E("card"),t==="succeeded"?await U(void 0,e):en(e),null;if(t===void 0||!Hr.has(t))return B.current=A.current,S(e),N(t==="requires_action"?Yr:it),null;const r=await pn(q);if(r==="committed")return x.current=!1,S(null),E("card"),await U(void 0,e),null;if(r!=="released")return B.current=A.current,S(e),N(it),null;x.current=!1,X.current=null,B.current=null,N(null),S(null);const c=$e();return Oe(c),c}finally{Te.current=!1}}async function ur(){f||M||Te.current||await qt(lr)}async function lr(){if(k){if((x.current?b!==i.current.placedShape:pe())&&!k.orderNumber){const c=await Gt(k);c&&A.current===b&&await Dt(c);return}N(null),Le.current=!1,await st();const t=v(A.current)[1],r=k.orderNumber?t:"card";if(r&&kn.has(r)&&pe()&&v(A.current)[0]!==Ve.current){zt(k);return}E(r),r!==C&&ke(r),await tn(k,r,!k.orderNumber);return}await Dt(q)}async function Dt(e){if(a.length===0||P.repricing||rt||!C||!J.some(d=>d.key===C))return;const t=a.filter(un).flatMap(d=>Nr(d.components,d.qty));if(t.length===0){N("Pick a size on each wheel's product page before checking out.");return}N(null);let r,c=e,n=C,u=!1;try{const d=ie?w.createOrderAuthed:w.createOrder,l={customer:{email:I,name:`${L} ${H}`.trim(),phone:G.trim()||void 0,companyName:be.trim()||void 0,address:Me,city:F,state:O||void 0,zipCode:T,country:m},items:t,currency:P.currency,idempotencyKey:e,shippingMethodId:Q??void 0,couponCode:mn(K),...Cn(),...Gr(C)?{checkoutFlow:lt}:{}};i.current.placedRequest={body:l,send:()=>d(l)},Qe.current=!!ie,le.current=!1,Xe(null),Ve.current=null,Le.current=!1,X.current=null,x.current=!1,B.current=null,i.current.placedShape=b,$.current=a;const p=i.current.lastPress,j=p?.key===l.idempotencyKey&&(p.shape!==b&&(!!l.checkoutFlow||!!p.method||!!p.plainMethod)||!!l.checkoutFlow&&!!p.plainMethod);j&&(i.current.keptCardKey=l.idempotencyKey);const on=jt(l,d),sn=j||!l.checkoutFlow&&i.current.keptCardKey===l.idempotencyKey,cn=!on&&!sn&&!l.checkoutFlow&&!!p&&!p.method;cn&&(p.plainMethod=C,p.plainLines=a,p.plainShape=b,tt(l.idempotencyKey));const Y=await(sn?Jt(l,d):d(l).then(fe=>({answer:fe,request:l})).catch(fe=>(on?Wt(fe,l.idempotencyKey):cn&&fn(fe)&&(p.plainMethod=""),dr(fe,l,d))));if(!Y)return;r=Y.answer,c=Y.request.idempotencyKey,n=Y.method??n,E(n),u=pe()||n!==v(A.current)[1],Y.method&&Y.method!==C&&ke(Y.method),r.orderNumber&&(Qt(r),ge()),await st()}catch(d){const l=Xr(d);l?(bn(l),N(`${l} Your order has not been placed. Place it again to continue without the code.`)):d instanceof Ue?N(it):N(d instanceof qe?d.message:"Could not place the order. Please try again.");return}if(n&&kn.has(n)&&(u||pe())){zt(r);return}await tn(r,n,!1,c)}function zt(e){Ve.current=v(A.current)[0],N(`${gn(e,null)} ${ut}`),S(e)}function Wt(e,t){fn(e)&&!dn(e)&&i.current.lastPress?.key===t&&(i.current.lastPress=null)}async function dr(e,t,r){if(at(e))return Zt(t,r);if(!dn(e))throw e;return i.current.keptCardKey=t.idempotencyKey,Jt(t,r,!0)}async function Jt(e,t,r=!1){const c=await pn(e.idempotencyKey);if(c==="released")return Zt(e,t);if(c!=="committed")throw new Ue;const n=i.current.lastPress?.key===e.idempotencyKey?i.current.lastPress:null;if($.current=n?.lines??a,n?.method&&!r){i.current.keptCardKey=null,i.current.placedRequest={body:n.request,send:n.send};const j=await n.send().catch(()=>{throw new Ue});return i.current.placedShape=n.shape,{answer:j,request:e,method:n.method}}const u={...e,checkoutFlow:lt},d=n&&!n.method?{body:n.request,send:n.send}:{body:u,send:()=>t(u)};i.current.placedRequest=d;const l=d.send,p=await l().catch(()=>null);if(!p&&n?.plainMethod)throw new Ue;return p?.orderNumber&&p.status!==zr?(i.current.keptCardKey=null,n?.plainMethod&&($.current=n.plainLines),n&&(i.current.placedShape=n.plainMethod?n.plainShape:n.shape),{answer:p,request:e,method:n?.plainMethod||void 0}):(n&&(i.current.placedShape=n.shape),E("card"),await Vt("",p?async()=>p:()=>Promise.reject(new Error("The order request did not answer."))),await st(),null)}function pe(){const e=i.current.placedShape;return e!==null&&v(e)[0]!==v(A.current)[0]}function E(e){e!==v(A.current)[1]&&(Le.current=!0),Xe(Xt()?ut:null)}function Xt(){return Le.current||pe()}async function Zt(e,t){const r={...e,idempotencyKey:$e()};i.current.keptCardKey=null,Oe(r.idempotencyKey),i.current.placedRequest={body:r,send:()=>t(r)},jt(r,t);try{return{answer:await t(r),request:r}}catch(c){throw Wt(c,r.idempotencyKey),c}}function jt(e,t){return i.current.lastPress?.key===e.idempotencyKey?!1:(i.current.lastPress={key:e.idempotencyKey,send:()=>t(e),request:e,lines:a,shape:b,method:e.checkoutFlow?"":C??"",plainMethod:"",plainLines:a,plainShape:b},le.current=!1,tt(e.idempotencyKey),!0)}function Qt(e){Pr({confirmation:e,lines:$.current,adsSendTo:o.googleAdsId&&o.googleAdsConversionLabel?`${o.googleAdsId}/${o.googleAdsConversionLabel}`:null}),br({confirmation:e,lines:$.current})}async function U(e,t=_){if(!t)return;const r=e?async()=>e:i.current.placedRequest?.send;if(t.orderNumber||!r){Re(!0),z(t);return}await Vt(t.checkoutNumber,r)}async function Vt(e,t){ge(),await Jr({checkoutNumber:e,resend:t,page:{setConfirming:jn,land:z,markPaid:()=>Re(!0),track:Qt,unplaced:Lt}})}function en(e=_){if(e){if(e.orderNumber){z(e);return}ge(),Lt({kind:"processing",checkoutNumber:e.checkoutNumber})}}async function st(){const e=JSON.stringify([Je.trim(),L,H,G.trim(),Me,F,O,T,m]);if(!(!ie||!Nt||We!=="new"||vt.current===e))try{await me.createAddress({label:Je.trim()||"Home",contact_name:`${L} ${H}`.trim(),phone:G.trim(),address:Me,city:F,zip_code:T,state:O,country:m}),vt.current=e,At("Address saved to your account.")}catch{At("We couldn't save the address to your account — you can add it under Account → Addresses.")}}async function tn(e,t=C,r=!1,c=q){S(null);try{if(t==="card"&&o.paymentMethods.includes("card")){const n=await w.createPaymentIntent({idempotencyKey:c});X.current=n;let u=e;if(r){const d=await i.current.placedRequest?.send().catch(()=>null);if(d?.orderNumber){E("card"),await U(d,e);return}u=nn(e,d)??{...e,expiresAt:null}}E("card"),W(u),je(!1),Ee(n)}else if(t==="paypal"&&o.paymentMethods.includes("paypal"))W(e),Fn(!0);else if(t==="afterpay"&&o.paymentMethods.includes("afterpay")){const n=window.location.origin,u=await w.createAfterpayCheckout({idempotencyKey:c,confirmUrl:`${n}/checkout?afterpay=confirm`,cancelUrl:`${n}/checkout?afterpay=cancel`});xe(Ar,c,e,u.redirectCheckoutUrl);return}else if(t==="square"&&o.paymentMethods.includes("square"))W(e),qn(!0);else if(t==="gocardless"&&o.paymentMethods.includes("gocardless")){const n=window.location.origin,u=await w.createGocardlessBillingRequest({idempotencyKey:c,confirmUrl:`${n}/checkout?gocardless=confirm`,cancelUrl:`${n}/checkout?gocardless=cancel`});xe(Or,c,e,u.authorisationUrl);return}else if(t==="zip"&&o.paymentMethods.includes("zip")){const n=window.location.origin,u=await w.createZipCheckout({idempotencyKey:c,redirectUrl:`${n}/checkout?zip=return`});xe(Mr,c,e,u.redirectUrl);return}else if(t==="klarna"&&o.paymentMethods.includes("klarna")){const n=window.location.origin,u=await w.createKlarnaCheckout({idempotencyKey:c,confirmUrl:`${n}/checkout?klarna=confirm`,cancelUrl:`${n}/checkout?klarna=cancel`});xe(Rr,c,e,u.redirectUrl);return}else E(t),z(e)}catch(n){if((r||t==="card")&&n instanceof qe&&n.status===409){E(t),await U(void 0,e);return}rn(e,n)}}function nn(e,t){return t&&!t.orderNumber&&t.status==="open"&&t.checkoutNumber===e.checkoutNumber?t:null}function rn(e,t){N(gn(e,t)),!e.orderNumber&&at(t)?(x.current=!1,Oe($e())):S(e)}async function pr(e){if(!_)return;const t=_;try{const r=await w.createPaymentIntent({idempotencyKey:q}),c=await i.current.placedRequest?.send().catch(()=>null);if(c?.orderNumber){await U(c);return}const n=nn(t,c);W(n??{...t,expiresAt:null}),je(e&&n!==null),X.current=r,Ee(r)}catch(r){if(r instanceof qe&&r.status===409){await U();return}Ee(null),W(null),rn(t,r)}}function fr(){_&&(x.current=!0,S(_),Ee(null),W(null),je(!1))}return{site:o,logo:g,items:a,totals:ar,coupon:K,deliveryOptions:dt,courierUnavailable:Kn,retryCourier:Mn,shippingMethodId:Q,setShippingMethodId:pt,pickupLocation:An,servedCountries:V,formatMoney:vn,payChoice:C,setPayChoice:ke,placing:M,email:I,setEmail:Ce,firstName:L,setFirstName:we,lastName:H,setLastName:Pe,company:be,setCompany:Ge,address1:ee,setAddress1:te,address2:Ne,setAddress2:ne,city:F,setCity:re,postcode:T,setPostcode:oe,phone:G,setPhone:se,country:m,setCountry:ce,subdivision:O,setSubdivision:Se,subdivisions:ae,destination:Ct,postcodeLabel:En,subdivisionLabel:Rn,me:ie,savedAddresses:Ln,selectedAddressId:We,setSelectedAddressId:ve,saveAddress:Nt,setSaveAddress:St,saveLabel:Je,setSaveLabel:Tn,addressSaveNote:_n,lostChangeNote:xn,idemKey:q,confirmation:Ze,setConfirmation:z,orderError:In,payment:Ot,paypalStep:Et,squareStep:Rt,pendingConf:_,paid:$n,setPaid:Re,unpaidOrder:k,orderLocked:Kt,formLocked:Bn,restoredPrices:Yt,quoteFailed:ot,retryQuote:ir,payNote:Un,afterpayConfirming:Hn,gocardlessConfirming:Dn,zipConfirming:Wn,klarnaConfirming:Xn,cardConfirming:Mt,checkoutResult:ue,confirmCardPayment:U,cardStillProcessing:en,renewCardPayment:pr,holdRenewed:Qn,leaveCardPayment:fr,checkoutRootRef:xt,setCheckoutHeaderEl:Vn,fillFromAddress:It,checkoutSignOut:er,payOptions:J,noPaymentMethod:tr,placeOrder:ur}}const Pn=mr(null);function No({children:o,...g}){const f=eo(g);return R(Pn.Provider,{value:f,children:o})}function So(){const o=yr(Pn);if(!o)throw new Error("useCheckout must be used inside CheckoutStateProvider");return o}export{No as CheckoutStateProvider,wo as NO_PAYMENT_METHOD_NOTE,Po as SHIPPING_RETRY_NOTE,hn as buildPayOptions,gn as paymentNotStartedMessage,bo as placedOrderLockNote,So as useCheckout};
@@ -2,6 +2,7 @@ import type { CartLine } from "../../components/CartContext.js";
2
2
  import type { OrderConfirmation, OrderRequest } from "../api/index.js";
3
3
  export declare const CHECKOUT_MEMORY_KEY = "checkout-memory-context";
4
4
  export declare const PRICES_REQUOTED = "Prices have changed since this checkout started. The total shows today's prices.";
5
+ export declare const PRICES_UNCHECKED = "We couldn't check today's prices for your basket. Try again in a moment \u2014 you can place the order once the total is confirmed.";
5
6
  export declare const CHECKOUT_MEMORY_LIFE_MS: number;
6
7
  export declare function parkLine(line: CartLine): CartLine;
7
8
  export declare function sameGoods(a: CartLine[], b: CartLine[]): boolean;
@@ -1 +1 @@
1
- import{safeSessionStorage as i}from"efficient-web-builder/format/lib/safe-storage";import{orderLinesForSets as g}from"../commerce.js";const c="checkout-memory-context",P="Prices have changed since this checkout started. The total shows today's prices.",d=3,k=3600*1e3;function N(e){return{id:e.id,slug:e.slug,name:{lead:e.name?.lead,accent:e.name?.accent},process:e.process,positionNo:e.positionNo,config:(e.config??[]).map(t=>({label:t.label,gold:t.gold})),finishName:e.finishName,size:e.size,qty:e.qty,href:e.href,kind:e.kind,sku:e.sku,components:e.components.map(t=>({partNumber:t.partNumber,wheels:t.wheels,prices:{...t.prices},hand:t.hand}))}}const a=e=>e.map(N);function I(e,t){const n=o=>JSON.stringify(o.map(r=>[r.id,r.qty]).sort(([r],[u])=>r<u?-1:r>u?1:0));return n(e)===n(t)}function l(e){const t=e.customer;return{customer:{email:t.email,name:t.name,phone:t.phone,companyName:t.companyName,address:t.address,city:t.city,state:t.state,zipCode:t.zipCode,country:t.country},items:e.items.flatMap(n=>g([{partNumber:n.partNumber,wheels:n.quantity,prices:{}}],1)),currency:e.currency,idempotencyKey:e.idempotencyKey,shippingMethodId:e.shippingMethodId,couponCode:e.couponCode}}function K(e){return{...l(e),payFirst:!!e.checkoutFlow}}function L(e){return l(e)}const A={lastPress:null,keptCardKey:null,placedShape:null,placedRequest:null,unpaidOrder:null};function b(e){const t=n=>typeof n=="string"?n:"";return{email:t(e.email),firstName:t(e.firstName),lastName:t(e.lastName),company:t(e.company),address1:t(e.address1),address2:t(e.address2),city:t(e.city),postcode:t(e.postcode),phone:t(e.phone),country:t(e.country),subdivision:t(e.subdivision),selectedAddressId:t(e.selectedAddressId),shippingMethodId:typeof e.shippingMethodId=="string"?e.shippingMethodId:null,couponCode:typeof e.couponCode=="string"?e.couponCode:null}}function C(e){return{orderNumber:e.orderNumber,checkoutNumber:e.checkoutNumber,expiresAt:e.expiresAt,status:e.status,total:e.total,currency:e.currency,freightCharge:e.freightCharge,discountAmount:e.discountAmount,grandTotal:e.grandTotal,shippingMethod:e.shippingMethod,couponCode:e.couponCode}}function x(e){return e.lastPress!==null||e.unpaidOrder!==null||e.keptCardKey!==null}function M(e){const t=e.parkedAt+k,n=e.press.unpaidOrder,o=n&&!n.orderNumber?n.expiresAt:null,r=o?Date.parse(o):NaN;return Number.isNaN(r)?t:Math.min(t,r)}function _(e){try{const t={...e,lines:a(e.lines),press:f(e.press)};i.setItem(c,JSON.stringify({v:d,...t}))}catch{}}const s=e=>!!e&&typeof e=="object"&&!Array.isArray(e),y=e=>s(e)&&typeof e.idempotencyKey=="string"&&Array.isArray(e.items)&&e.items.every(t=>s(t)&&typeof t.partNumber=="string"&&typeof t.quantity=="number")&&s(e.customer)&&typeof e.payFirst=="boolean",p=e=>s(e)&&typeof e.id=="string"&&typeof e.qty=="number"&&Array.isArray(e.components);function O(e){return s(e)&&typeof e.key=="string"&&y(e.request)&&Array.isArray(e.lines)&&e.lines.every(p)&&Array.isArray(e.plainLines)&&e.plainLines.every(p)?{key:e.key,request:e.request,lines:a(e.lines),goods:typeof e.goods=="string"?e.goods:"",plainPressed:e.plainPressed===!0,plainLines:a(e.plainLines),plainGoods:typeof e.plainGoods=="string"?e.plainGoods:""}:null}const m=e=>typeof e=="string"?e:null,h={lastPress:O,keptCardKey:m,placedShape:m,placedRequest:e=>y(e)?e:null,unpaidOrder:e=>s(e)?C(e):null};function f(e){const t=s(e)?e:{},n={...A};for(const o of Object.keys(h))n[o]=h[o](t[o]);return n}function q(){let e;try{e=i.getItem(c)}catch{return null}if(!e)return null;try{const t=JSON.parse(e);if(t.v!==d||typeof t.key!="string"||!t.key||!Array.isArray(t.lines)||!t.lines.every(p)||typeof t.parkedAt!="number")return null;const n={key:t.key,authed:t.authed===!0,parkedAt:t.parkedAt,press:f(t.press),lines:a(t.lines),form:t.form&&typeof t.form=="object"?b(t.form):null};return Date.now()>=M(n)?(S(),null):x(n.press)?n:null}catch{return null}}function S(){try{i.removeItem(c)}catch{}}export{c as CHECKOUT_MEMORY_KEY,k as CHECKOUT_MEMORY_LIFE_MS,A as NO_PRESS,h as PARKED_PRESS_READERS,P as PRICES_REQUOTED,S as clearCheckoutMemory,x as holdsPress,_ as parkCheckoutMemory,b as parkForm,N as parkLine,C as parkOrder,K as parkRequest,q as readCheckoutMemory,I as sameGoods,L as sendableRequest};
1
+ import{safeSessionStorage as i}from"efficient-web-builder/format/lib/safe-storage";import{orderLinesForSets as g}from"../commerce.js";const c="checkout-memory-context",P="Prices have changed since this checkout started. The total shows today's prices.",I="We couldn't check today's prices for your basket. Try again in a moment — you can place the order once the total is confirmed.",d=3,k=3600*1e3;function N(e){return{id:e.id,slug:e.slug,name:{lead:e.name?.lead,accent:e.name?.accent},process:e.process,positionNo:e.positionNo,config:(e.config??[]).map(t=>({label:t.label,gold:t.gold})),finishName:e.finishName,size:e.size,qty:e.qty,href:e.href,kind:e.kind,sku:e.sku,components:e.components.map(t=>({partNumber:t.partNumber,wheels:t.wheels,prices:{...t.prices},hand:t.hand}))}}const a=e=>e.map(N);function K(e,t){const n=o=>JSON.stringify(o.map(r=>[r.id,r.qty]).sort(([r],[u])=>r<u?-1:r>u?1:0));return n(e)===n(t)}function l(e){const t=e.customer;return{customer:{email:t.email,name:t.name,phone:t.phone,companyName:t.companyName,address:t.address,city:t.city,state:t.state,zipCode:t.zipCode,country:t.country},items:e.items.flatMap(n=>g([{partNumber:n.partNumber,wheels:n.quantity,prices:{}}],1)),currency:e.currency,idempotencyKey:e.idempotencyKey,shippingMethodId:e.shippingMethodId,couponCode:e.couponCode}}function _(e){return{...l(e),payFirst:!!e.checkoutFlow}}function L(e){return l(e)}const b={lastPress:null,keptCardKey:null,placedShape:null,placedRequest:null,unpaidOrder:null};function A(e){const t=n=>typeof n=="string"?n:"";return{email:t(e.email),firstName:t(e.firstName),lastName:t(e.lastName),company:t(e.company),address1:t(e.address1),address2:t(e.address2),city:t(e.city),postcode:t(e.postcode),phone:t(e.phone),country:t(e.country),subdivision:t(e.subdivision),selectedAddressId:t(e.selectedAddressId),shippingMethodId:typeof e.shippingMethodId=="string"?e.shippingMethodId:null,couponCode:typeof e.couponCode=="string"?e.couponCode:null}}function C(e){return{orderNumber:e.orderNumber,checkoutNumber:e.checkoutNumber,expiresAt:e.expiresAt,status:e.status,total:e.total,currency:e.currency,freightCharge:e.freightCharge,discountAmount:e.discountAmount,grandTotal:e.grandTotal,shippingMethod:e.shippingMethod,couponCode:e.couponCode}}function x(e){return e.lastPress!==null||e.unpaidOrder!==null||e.keptCardKey!==null}function E(e){const t=e.parkedAt+k,n=e.press.unpaidOrder,o=n&&!n.orderNumber?n.expiresAt:null,r=o?Date.parse(o):NaN;return Number.isNaN(r)?t:Math.min(t,r)}function q(e){try{const t={...e,lines:a(e.lines),press:f(e.press)};i.setItem(c,JSON.stringify({v:d,...t}))}catch{}}const s=e=>!!e&&typeof e=="object"&&!Array.isArray(e),y=e=>s(e)&&typeof e.idempotencyKey=="string"&&Array.isArray(e.items)&&e.items.every(t=>s(t)&&typeof t.partNumber=="string"&&typeof t.quantity=="number")&&s(e.customer)&&typeof e.payFirst=="boolean",p=e=>s(e)&&typeof e.id=="string"&&typeof e.qty=="number"&&Array.isArray(e.components);function S(e){return s(e)&&typeof e.key=="string"&&y(e.request)&&Array.isArray(e.lines)&&e.lines.every(p)&&Array.isArray(e.plainLines)&&e.plainLines.every(p)?{key:e.key,request:e.request,lines:a(e.lines),goods:typeof e.goods=="string"?e.goods:"",plainPressed:e.plainPressed===!0,plainLines:a(e.plainLines),plainGoods:typeof e.plainGoods=="string"?e.plainGoods:""}:null}const m=e=>typeof e=="string"?e:null,h={lastPress:S,keptCardKey:m,placedShape:m,placedRequest:e=>y(e)?e:null,unpaidOrder:e=>s(e)?C(e):null};function f(e){const t=s(e)?e:{},n={...b};for(const o of Object.keys(h))n[o]=h[o](t[o]);return n}function w(){let e;try{e=i.getItem(c)}catch{return null}if(!e)return null;try{const t=JSON.parse(e);if(t.v!==d||typeof t.key!="string"||!t.key||!Array.isArray(t.lines)||!t.lines.every(p)||typeof t.parkedAt!="number")return null;const n={key:t.key,authed:t.authed===!0,parkedAt:t.parkedAt,press:f(t.press),lines:a(t.lines),form:t.form&&typeof t.form=="object"?A(t.form):null};return Date.now()>=E(n)?(M(),null):x(n.press)?n:null}catch{return null}}function M(){try{i.removeItem(c)}catch{}}export{c as CHECKOUT_MEMORY_KEY,k as CHECKOUT_MEMORY_LIFE_MS,b as NO_PRESS,h as PARKED_PRESS_READERS,P as PRICES_REQUOTED,I as PRICES_UNCHECKED,M as clearCheckoutMemory,x as holdsPress,q as parkCheckoutMemory,A as parkForm,N as parkLine,C as parkOrder,_ as parkRequest,w as readCheckoutMemory,K as sameGoods,L as sendableRequest};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efficient-storefront-blocks",
3
- "version": "0.118.0",
3
+ "version": "0.118.2",
4
4
  "description": "The EFFICIENT storefront's website editor — the website builder assembled with the storefront's own sections — for an app that edits a storefront website inside its own page. Built from the efficient-storefront-blocks repository.",
5
5
  "license": "UNLICENSED",
6
6
  "author": "Efficient Pty Ltd",
@@ -1,4 +0,0 @@
1
- "use client";import{$ as fn,O as Fr,P as _r,Q as Mr,R as Kr,S as Dr,T as fe,V as mt,W as jr,X as Ur,Y as _t,Z as Wr,aa as ne,b as Tr,c as mn,d as qr,da as $r,e as Tt,ea as Yr,ja as Br,ka as ge,la as zr,ma as Gr,ra as Hr,sa as ft,va as gn,xa as ie,y as qt,z as Ft}from"./chunk-H5F6BWNC.js";import{R as ue,X as Ze,ca as Y,o as Lr,p as Ir}from"./chunk-2ULOP225.js";import{Ei as Rr,Gi as Ue,Ki as Or}from"./chunk-53R44PTG.js";import{n as Ar,o as pt,p as Le}from"./chunk-CL5JFHNP.js";import{a as pn,b as fi}from"./chunk-Y6SLVHK3.js";var Zr=pn(($s,Xr)=>{"use strict";var hi="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";Xr.exports=hi});var no=pn((Ys,to)=>{"use strict";var bi=Zr();function Qr(){}function eo(){}eo.resetWarningCache=Qr;to.exports=function(){function e(r,a,s,d,g,f){if(f!==bi){var p=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw p.name="Invariant Violation",p}}e.isRequired=e;function t(){return e}var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:eo,resetWarningCache:Qr};return n.PropTypes=n,n}});var oo=pn((Gs,ro)=>{"use strict";ro.exports=no()();var Bs,zs});import{useEffect as Ra,useMemo as wa,useRef as tt,useState as Ye}from"react";import{formatTime as gi}from"efficient-shell/format";function Vr(e,t){let n=Ir(t);return!n||Number.isNaN(new Date(e).getTime())?"":gi(e,{locale:Lr(),timeZone:n})}import{rootIsDark as yi}from"efficient-shell/format";function Jr(){if(typeof document>"u")return;let e=getComputedStyle(document.documentElement),t=(r,a)=>e.getPropertyValue(r).trim()||a,n=yi({whenUnset:!0});return{theme:n?"night":"stripe",variables:{colorPrimary:t("--accent",n?"#c9a461":"#8a6a2a"),colorBackground:t("--site-surface",n?"#131313":"#ffffff"),colorText:t("--fg",n?"#f5f1e8":"#0a0a0a"),borderRadius:"0px"}}}import{userZone as ws}from"efficient-shell/format";var M=fi(oo(),1);import I from"react";function ao(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function vi(e){if(Array.isArray(e))return e}function uo(e,t,n){return(t=wi(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ki(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,a,s,d,g=[],f=!0,p=!1;try{if(s=(n=n.call(e)).next,t!==0)for(;!(f=(r=s.call(n)).done)&&(g.push(r.value),g.length!==t);f=!0);}catch(v){p=!0,a=v}finally{try{if(!f&&n.return!=null&&(d=n.return(),Object(d)!==d))return}finally{if(p)throw a}}return g}}function xi(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function io(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),n.push.apply(n,r)}return n}function so(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?io(Object(n),!0).forEach(function(r){uo(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):io(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Ci(e,t){if(e==null)return{};var n,r,a=Pi(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(r=0;r<s.length;r++)n=s[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function Pi(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function po(e,t){return vi(e)||ki(e,t)||Si(e,t)||xi()}function Ni(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function wi(e){var t=Ni(e,"string");return typeof t=="symbol"?t:t+""}function yn(e){"@babel/helpers - typeof";return yn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},yn(e)}function Si(e,t){if(e){if(typeof e=="string")return ao(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ao(e,t):void 0}}var X=function(t,n,r){var a=!!r,s=I.useRef(r);I.useEffect(function(){s.current=r},[r]),I.useEffect(function(){if(!a||!t)return function(){};var d=function(){if(s.current)return s.current.apply(s,arguments)};return t.on(n,d),function(){t.off(n,d)}},[a,n,t,s])},hn=function(t){var n=I.useRef(t);return I.useEffect(function(){n.current=t},[t]),n.current},Qe=function(t){return t!==null&&yn(t)==="object"},Ei=function(t){return Qe(t)&&typeof t.then=="function"},Ri=function(t){return Qe(t)&&typeof t.elements=="function"&&typeof t.createToken=="function"&&typeof t.createPaymentMethod=="function"&&typeof t.confirmCardPayment=="function"},co="[object Object]",Oi=function e(t,n){if(t===n)return!0;if(!Qe(t)||!Qe(n))return t===n;var r=Array.isArray(t),a=Array.isArray(n);if(r!==a)return!1;var s=Object.prototype.toString.call(t)===co,d=Object.prototype.toString.call(n)===co;if(s!==d)return!1;if(!s&&!r)return t===n;var g=Object.keys(t),f=Object.keys(n);if(g.length!==f.length)return!1;for(var p={},v=0;v<g.length;v+=1)p[g[v]]=!0;for(var h=0;h<f.length;h+=1)p[f[h]]=!0;var k=Object.keys(p);if(k.length!==g.length)return!1;var b=t,R=n,C=function(j){return e(b[j],R[j])};return k.every(C)},mo=function(t,n,r){return Qe(t)?Object.keys(t).reduce(function(a,s){var d=!Qe(n)||!Oi(t[s],n[s]);return r.includes(s)?(d&&console.warn("Unsupported prop change: options.".concat(s," is not a mutable property.")),a):d?so(so({},a||{}),{},uo({},s,t[s])):a},null):null},fo="Invalid prop `stripe` supplied to `Elements`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.",lo=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:fo;if(t===null||Ri(t))return t;throw new Error(n)},Ai=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:fo;if(Ei(t))return{tag:"async",stripePromise:Promise.resolve(t).then(function(a){return lo(a,n)})};var r=lo(t,n);return r===null?{tag:"empty"}:{tag:"sync",stripe:r}},Li=function(t){!t||!t._registerWrapper||!t.registerAppInfo||(t._registerWrapper({name:"react-stripe-js",version:"6.12.0"}),t.registerAppInfo({name:"react-stripe-js",version:"6.12.0",url:"https://stripe.com/docs/stripe-js/react"}))},Mt=I.createContext(null);Mt.displayName="ElementsContext";var go=function(t,n){if(!t)throw new Error("Could not find Elements context; You need to wrap the part of your app that ".concat(n," in an <Elements> provider."));return t},vn=function(t){var n=t.stripe,r=t.options,a=t.children,s=I.useMemo(function(){return Ai(n)},[n]),d=I.useState(function(){return{stripe:s.tag==="sync"?s.stripe:null,elements:s.tag==="sync"?s.stripe.elements(r):null}}),g=po(d,2),f=g[0],p=g[1];I.useEffect(function(){var k=!0,b=function(C){p(function(E){return E.stripe?E:{stripe:C,elements:C.elements(r)}})};return s.tag==="async"&&!f.stripe?s.stripePromise.then(function(R){R&&k&&b(R)}):s.tag==="sync"&&!f.stripe&&b(s.stripe),function(){k=!1}},[s,f,r]);var v=hn(n);I.useEffect(function(){v!==null&&v!==n&&console.warn("Unsupported prop change on Elements: You cannot change the `stripe` prop after setting it.")},[v,n]);var h=hn(r);return I.useEffect(function(){if(f.elements){var k=mo(r,h,["clientSecret","fonts"]);k&&f.elements.update(k)}},[r,h,f.elements]),I.useEffect(function(){Li(f.stripe)},[f.stripe]),I.createElement(Mt.Provider,{value:f},a)};vn.propTypes={stripe:M.default.any,options:M.default.object};var yo=function(t){var n=I.useContext(Mt);return go(n,t)},ho=function(){var t=yo("calls useElements()"),n=t.elements;return n},Ii=function(t){var n=t.children,r=yo("mounts <ElementsConsumer>");return n(r)};Ii.propTypes={children:M.default.func.isRequired};var Ti=I.createContext(null);Ti.displayName="CheckoutContext";var bo=I.createContext(null);bo.displayName="CheckoutSdkContext";var bn=function(t){var n=I.useContext(bo),r=I.useContext(Mt);if(n){if(r)throw new Error("You cannot wrap the part of your app that ".concat(t," in both a checkout provider and <Elements> provider."));return n}else return go(r,t)},qi=["mode"],Fi=function(t){return t.charAt(0).toUpperCase()+t.slice(1)},K=function(t,n,r){var a="".concat(Fi(t),"Element"),s=function(p){var v=p.id,h=p.className,k=p.options,b=k===void 0?{}:k,R=p.onBlur,C=p.onFocus,E=p.onReady,j=p.onChange,O=p.onEscape,S=p.onClick,B=p.onLoadError,Z=p.onLoaderStart,de=p.onNetworksChange,U=p.onConfirm,se=p.onCancel,Ne=p.onShippingAddressChange,qe=p.onShippingRateChange,ee=p.onSavedPaymentMethodRemove,he=p.onSavedPaymentMethodUpdate,re=p.onAvailablePaymentMethodsChange,te=bn("mounts <".concat(a,">")),H="elements"in te?te.elements:null,y="checkoutSdk"in te?te.checkoutSdk:null,we=I.useState(null),Fe=po(we,2),W=Fe[0],nt=Fe[1],Q=I.useRef(null),be=I.useRef(null);X(W,"blur",R),X(W,"focus",C),X(W,"escape",O),X(W,"click",S),X(W,"loaderror",B),X(W,"loaderstart",Z),X(W,"networkschange",de),X(W,"confirm",U),X(W,"cancel",se),X(W,"shippingaddresschange",Ne),X(W,"shippingratechange",qe),X(W,"savedpaymentmethodremove",ee),X(W,"savedpaymentmethodupdate",he),X(W,"availablepaymentmethodschange",re),X(W,"change",j);var Se;E&&(t==="expressCheckout"?Se=E:Se=function(){E(W)}),X(W,"ready",Se),I.useLayoutEffect(function(){if(Q.current===null&&be.current!==null&&(H||y)){var L=null;if(y){var oe=y,pe=y;switch(t){case"paymentForm":L=pe.createForm(b);break;case"payment":L=oe.createPaymentElement(b);break;case"address":if("mode"in b){var Re=b.mode,ve=Ci(b,qi);if(Re==="shipping")L=oe.createShippingAddressElement(ve);else if(Re==="billing")L=oe.createBillingAddressElement(ve);else throw new Error("Invalid options.mode. mode must be 'billing' or 'shipping'.")}else throw new Error("You must supply options.mode. mode must be 'billing' or 'shipping'.");break;case"expressCheckout":L=oe.createExpressCheckoutElement(b);break;case"currencySelector":L=y.createCurrencySelectorElement();break;case"taxId":L=oe.createTaxIdElement(b);break;case"contactDetails":L=oe.createContactDetailsElement();break;case"linkSignup":if("createLinkSignupElement"in y)L=y.createLinkSignupElement(b);else throw new Error("<LinkSignupElement> requires <CheckoutElementsProvider> and is not supported inside <CheckoutFormProvider>.");break;case"terms":L=oe.createTermsElement(b);break;default:throw new Error("<".concat(a,"> is not supported inside a checkout provider. Use an <Elements> provider instead."))}}else H&&(L=H.create(t,b));Q.current=L,nt(L),L&&L.mount(be.current)}},[H,y,b]);var Ee=hn(b);return I.useEffect(function(){if(Q.current){var L=mo(b,Ee,["paymentRequest"]);L&&"update"in Q.current&&Q.current.update(L)}},[b,Ee]),I.useLayoutEffect(function(){return function(){if(Q.current&&typeof Q.current.destroy=="function")try{Q.current.destroy(),Q.current=null}catch{}}},[]),I.createElement("div",{id:v,className:h,ref:be})},d=function(p){bn("mounts <".concat(a,">"));var v=p.id,h=p.className;return I.createElement("div",{id:v,className:h})},g=n?d:s;return g.propTypes={id:M.default.string,className:M.default.string,onChange:M.default.func,onBlur:M.default.func,onFocus:M.default.func,onReady:M.default.func,onEscape:M.default.func,onClick:M.default.func,onLoadError:M.default.func,onLoaderStart:M.default.func,onNetworksChange:M.default.func,onConfirm:M.default.func,onCancel:M.default.func,onShippingAddressChange:M.default.func,onShippingRateChange:M.default.func,onSavedPaymentMethodRemove:M.default.func,onSavedPaymentMethodUpdate:M.default.func,onAvailablePaymentMethodsChange:M.default.func,options:M.default.object},g.displayName=a,g.__elementType=t,g},D=typeof window>"u",_i=I.createContext(null);_i.displayName="EmbeddedCheckoutProviderContext";var vo=function(){var t=bn("calls useStripe()"),n=t.stripe;return n},Vs=K("auBankAccount",D),Js=K("card",D),Xs=K("cardNumber",D),Zs=K("cardExpiry",D),Qs=K("cardCvc",D),ec=K("currencySelector",D),tc=K("iban",D),ko=K("payment",D),nc=K("expressCheckout",D),rc=K("paymentRequestButton",D),oc=K("linkAuthentication",D),ac=K("linkSignup",D),ic=K("contactDetails",D),sc=K("address",D),cc=K("shippingAddress",D),lc=K("paymentMethodMessaging",D),uc=K("taxId",D),dc=K("issuingCardNumberDisplay",D),pc=K("issuingCardCvcDisplay",D),mc=K("issuingCardExpiryDisplay",D),fc=K("issuingCardPinDisplay",D),gc=K("issuingCardCopyButton",D),yc=K("terms",D);function jt(e){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?jt=function(t){return typeof t}:jt=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},jt(e)}var Po="dahlia",Mi=function(t){return t===3?"v3":t},No="https://js.stripe.com",Ki="".concat(No,"/").concat(Po,"/stripe.js"),Di=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,ji=/^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/,xo="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used",Ui=function(t){return Di.test(t)||ji.test(t)},Wi=function(){for(var t=document.querySelectorAll('script[src^="'.concat(No,'"]')),n=0;n<t.length;n++){var r=t[n];if(Ui(r.src))return r}return null},Co=function(t){var n=t&&!t.advancedFraudSignals?"?advancedFraudSignals=false":"",r=document.createElement("script");r.src="".concat(Ki).concat(n);var a=document.head||document.body;if(!a)throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");return a.appendChild(r),r},$i=function(t,n){!t||!t._registerWrapper||t._registerWrapper({name:"stripe-js",version:"9.17.0",startTime:n})},gt=null,Kt=null,Dt=null,Yi=function(t){return function(n){t(new Error("Failed to load Stripe.js",{cause:n}))}},Bi=function(t,n){return function(){window.Stripe?t(window.Stripe):n(new Error("Stripe.js not available"))}},zi=function(t){return gt!==null?gt:(gt=new Promise(function(n,r){if(typeof window>"u"||typeof document>"u"){n(null);return}if(window.Stripe&&t&&console.warn(xo),window.Stripe){n(window.Stripe);return}try{var a=Wi();if(a&&t)console.warn(xo);else if(!a)a=Co(t);else if(a&&Dt!==null&&Kt!==null){var s;a.removeEventListener("load",Dt),a.removeEventListener("error",Kt),(s=a.parentNode)===null||s===void 0||s.removeChild(a),a=Co(t)}Dt=Bi(n,r),Kt=Yi(r),a.addEventListener("load",Dt),a.addEventListener("error",Kt)}catch(d){r(d);return}}),gt.catch(function(n){return gt=null,Promise.reject(n)}))},Gi=function(t,n,r){if(t===null)return null;var a=n[0];if(typeof a!="string")throw new Error("Expected publishable key to be of type string, got type ".concat(jt(a)," instead."));var s=a.match(/^pk_test/),d=Mi(t.version),g=Po;s&&d!==g&&console.warn("Stripe.js@".concat(d," was loaded on the page, but @stripe/stripe-js@").concat("9.17.0"," expected Stripe.js@").concat(g,". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));var f=t.apply(void 0,n);return $i(f,r),f},yt,wo=!1,So=function(){return yt||(yt=zi(null).catch(function(t){return yt=null,Promise.reject(t)}),yt)};Promise.resolve().then(function(){return So()}).catch(function(e){wo||console.warn(e)});var Ut=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];wo=!0;var a=Date.now();return So().then(function(s){return Gi(s,n,a)})};var Wt=2;function Eo(e){return e==="card"}var Hi="checkout_unavailable",Vi="checkout_waiting",Ro="committed",Ie="We could not check your payment. Please try again.",$t="Your last change was not saved. This is your order as placed.",Oo="Your bank is still waiting for you to approve this payment, so your order stays as it was. Finish the approval, or try again in a few minutes.",Ao=1e4;async function Lo(e,t=Ao){let n,r=new Promise(s=>{n=setTimeout(()=>s(void 0),t)}),a=(async()=>{try{return(await(await Ut(e.publishableKey))?.retrievePaymentIntent(e.clientSecret))?.paymentIntent?.status}catch{return}})();try{return await Promise.race([a,r])}finally{clearTimeout(n)}}var Io=new Set(["none","requires_payment_method","canceled"]);async function kn(e,t=Ao){let n,r=new Promise(a=>{n=setTimeout(()=>a(void 0),t)});try{return await Promise.race([Y.releaseCheckout({idempotencyKey:e}).then(a=>a.status,()=>{}),r])}finally{clearTimeout(n)}}function To(e,t){return e instanceof ue&&typeof e.data=="object"&&e.data!==null&&e.data.code===t}function Yt(e){return To(e,Hi)}function xn(e){return To(e,Vi)}function Cn(e){return e instanceof ue&&e.status>=400&&e.status<500&&e.status!==408}function qo(e){return JSON.stringify([e.email,e.firstName,e.lastName,e.phone,e.address,e.city,e.subdivision,e.postcode,e.country,e.lines,e.shippingMethodId,e.couponCode,e.currency,e.shopperId,e.company])}function Bt(e){return e.orderNumber||e.checkoutNumber}function Ji(e){return e.orderNumber?{kind:"placed",order:e}:{kind:e.status==="released"?"refunded":e.status==="expired"?"expired":"pending",checkoutNumber:e.checkoutNumber}}async function Fo({checkoutNumber:e,resend:t,page:n}){n.setConfirming(!0);let r;try{r=Ji(await t())}catch{r={kind:"pending",checkoutNumber:e}}r.kind==="placed"?(n.markPaid(),n.track(r.order),n.land(r.order)):n.unplaced({...r,checkoutNumber:r.checkoutNumber||e}),n.setConfirming(!1)}import{createContext as ms,useContext as fs,useEffect as G,useMemo as ia,useRef as z,useState as P}from"react";var Xi="sf:gclid",Zi="sf:fbclid",Qi=2160*60*60*1e3;function Ko(){return typeof window<"u"}function _o(e){let t=pt.getItem(e);if(!t)return"";try{let{v:n,t:r}=JSON.parse(t);return!n||typeof r!="number"||Date.now()-r>Qi?"":n}catch{return""}}function Mo(e){if(!Ko())return"";let t=e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1"),n=document.cookie.match(new RegExp(`(?:^|; )${t}=([^;]*)`));return n?decodeURIComponent(n[1]):""}function Do(){if(!Ko())return{};let e=_o(Xi),t=_o(Zi),n=Mo("_fbp"),r=Mo("_fbc");!r&&t&&(r=`fb.1.${Date.now()}.${t}`);let a={};return e&&(a.gclid=e),t&&(a.fbclid=t),n&&(a.fbp=n),r&&(a.fbc=r),a}var jo="sf:meta-purchases",es=20;function Wo(){return typeof window>"u"||window.parent!==window}function ts(...e){try{if(Wo()||typeof window.fbq!="function")return;window.fbq(...e)}catch{}}var Uo=new Set;function ns(e){if(Uo.has(e))return!1;Uo.add(e);try{let t=JSON.parse(pt.getItem(jo)??"[]");if(t.includes(e))return!1;pt.setItem(jo,JSON.stringify([...t,e].slice(-es)))}catch{}return!0}function rs(e){return[...new Set(e.filter(mt).flatMap(t=>t.components.map(n=>n.partNumber)))]}function $o(e){let t=e.confirmation;Wo()||!ns(t.orderNumber)||ts("track","Purchase",{value:Number(t.grandTotal),currency:t.currency,content_type:"product",content_ids:rs(e.lines)},{eventID:t.orderNumber})}var Pn="checkout-afterpay-context",Nn="checkout-gocardless-context",wn="checkout-zip-context",Sn="checkout-klarna-context";function os(e){return e?.lostChange===!0}function as({evidence:e,parked:t}){return e?{action:"capture",evidence:e,parked:t}:t?{action:"settle",parked:t}:{action:"ignore"}}function is(e,t){let n=e.getItem(t);if(e.removeItem(t),!n)return null;try{return JSON.parse(n)}catch{return null}}function ss(e){let t=e.words?.declined??`${e.name} declined the payment \u2014 our team will follow up on payment.`;return{settled:e.words?.settled??`The ${e.name} payment was not completed \u2014 our team will follow up on payment.`,declined:t,collecting:e.words?.collecting??t,unconfirmed:e.words?.unconfirmed??`We could not confirm the ${e.name} payment \u2014 our team will follow up on payment.`}}var Yo={name:"Afterpay",legParam:"afterpay",legValues:["confirm","cancel"],storageKey:Pn,evidenceFrom(e,t){return t==="cancel"||(e.get("status")??"").toUpperCase()==="CANCELLED"?null:e.get("orderToken")},requestFrom:e=>({token:e})},Bo={name:"Zip",legParam:"zip",legValues:["return"],storageKey:wn,evidenceFrom(e){let t=(e.get("result")??"").toLowerCase();return t==="cancelled"||t==="declined"?null:e.get("checkoutId")},requestFrom:e=>({checkoutId:e})},zo={name:"GoCardless",legParam:"gocardless",legValues:["confirm","cancel"],storageKey:Nn,evidenceFrom:(e,t)=>t==="confirm"?t:null,requestFrom:(e,t)=>({idempotencyKey:t?.idempotencyKey??""}),keyedByParked:!0,words:{settled:"The direct debit was not set up \u2014 our team will follow up on payment.",declined:"The direct debit was declined \u2014 our team will follow up on payment.",collecting:"Your direct debit is set up \u2014 the payment is collecting and will clear in a few days.",unconfirmed:"We could not confirm the direct debit \u2014 our team will follow up on payment."}},Go={name:"Klarna",legParam:"klarna",legValues:["confirm","cancel"],storageKey:Sn,evidenceFrom:(e,t)=>t==="confirm"?e.get("authorization_token"):null,requestFrom:(e,t)=>({idempotencyKey:t?.idempotencyKey??"",authorizationToken:e}),keyedByParked:!0,words:{collecting:"Your Klarna payment is being reviewed \u2014 we'll confirm the outcome shortly."}};async function ht(e,t){let n=new URLSearchParams(t.search),r=n.get(e.legParam);if(!r||!e.legValues.includes(r))return;let a=is(t.storage,e.storageKey),s=e.evidenceFrom(n,r);t.scrubQuery();let d=as({evidence:s,parked:a});if(d.action==="ignore"||e.keyedByParked&&!d.parked)return;let g=ss(e);if(t.page.clearCart(),os(d.parked)&&t.page.lostChange(),d.action==="settle"){t.page.note(g.settled,!0),t.page.land(d.parked.confirmation);return}t.page.setConfirming(!0);try{let f=await t.capture(e.requestFrom(d.evidence,d.parked));f.status==="paid"?t.page.markPaid():f.status==="collecting"?t.page.note(g.collecting,!e.words?.collecting):t.page.note(g.declined,!0),t.page.land(d.parked?.confirmation??f)}catch{d.parked?(t.page.note(g.unconfirmed,!0),t.page.land(d.parked.confirmation)):t.page.fail(`We could not confirm your ${e.name} payment. Please contact us before trying again \u2014 your payment may already have been taken.`)}finally{t.page.setConfirming(!1)}}function Ho(e,t,n){let r=(t??"").trim();if(!r)return"";if(n.length===0)return r;let a=r.toUpperCase(),s=`${e.toUpperCase()}-${a}`,d=n.find(g=>g.code&&g.code.toUpperCase()===a)??n.find(g=>g.code&&g.code.toUpperCase()===s)??n.find(g=>g.name.toUpperCase()===a);return d?d.code||d.name:""}var Rn="checkout-memory-context",Xo="Prices have changed since this checkout started. The total shows today's prices.",Zo=3,cs=3600*1e3;function ls(e){return{id:e.id,slug:e.slug,name:{lead:e.name?.lead,accent:e.name?.accent},process:e.process,positionNo:e.positionNo,config:(e.config??[]).map(t=>({label:t.label,gold:t.gold})),finishName:e.finishName,size:e.size,qty:e.qty,href:e.href,kind:e.kind,sku:e.sku,components:e.components.map(t=>({partNumber:t.partNumber,wheels:t.wheels,prices:{...t.prices},hand:t.hand}))}}var zt=e=>e.map(ls);function Qo(e,t){let n=r=>JSON.stringify(r.map(a=>[a.id,a.qty]).sort(([a],[s])=>a<s?-1:a>s?1:0));return n(e)===n(t)}function ea(e){let t=e.customer;return{customer:{email:t.email,name:t.name,phone:t.phone,companyName:t.companyName,address:t.address,city:t.city,state:t.state,zipCode:t.zipCode,country:t.country},items:e.items.flatMap(n=>Tt([{partNumber:n.partNumber,wheels:n.quantity,prices:{}}],1)),currency:e.currency,idempotencyKey:e.idempotencyKey,shippingMethodId:e.shippingMethodId,couponCode:e.couponCode}}function On(e){return{...ea(e),payFirst:!!e.checkoutFlow}}function ta(e){return ea(e)}var us={lastPress:null,keptCardKey:null,placedShape:null,placedRequest:null,unpaidOrder:null};function An(e){let t=n=>typeof n=="string"?n:"";return{email:t(e.email),firstName:t(e.firstName),lastName:t(e.lastName),company:t(e.company),address1:t(e.address1),address2:t(e.address2),city:t(e.city),postcode:t(e.postcode),phone:t(e.phone),country:t(e.country),subdivision:t(e.subdivision),selectedAddressId:t(e.selectedAddressId),shippingMethodId:typeof e.shippingMethodId=="string"?e.shippingMethodId:null,couponCode:typeof e.couponCode=="string"?e.couponCode:null}}function Ln(e){return{orderNumber:e.orderNumber,checkoutNumber:e.checkoutNumber,expiresAt:e.expiresAt,status:e.status,total:e.total,currency:e.currency,freightCharge:e.freightCharge,discountAmount:e.discountAmount,grandTotal:e.grandTotal,shippingMethod:e.shippingMethod,couponCode:e.couponCode}}function In(e){return e.lastPress!==null||e.unpaidOrder!==null||e.keptCardKey!==null}function ds(e){let t=e.parkedAt+cs,n=e.press.unpaidOrder,r=n&&!n.orderNumber?n.expiresAt:null,a=r?Date.parse(r):NaN;return Number.isNaN(a)?t:Math.min(t,a)}function na(e){try{let t={...e,lines:zt(e.lines),press:oa(e.press)};Le.setItem(Rn,JSON.stringify({v:Zo,...t}))}catch{}}var We=e=>!!e&&typeof e=="object"&&!Array.isArray(e),ra=e=>We(e)&&typeof e.idempotencyKey=="string"&&Array.isArray(e.items)&&e.items.every(t=>We(t)&&typeof t.partNumber=="string"&&typeof t.quantity=="number")&&We(e.customer)&&typeof e.payFirst=="boolean",En=e=>We(e)&&typeof e.id=="string"&&typeof e.qty=="number"&&Array.isArray(e.components);function ps(e){return We(e)&&typeof e.key=="string"&&ra(e.request)&&Array.isArray(e.lines)&&e.lines.every(En)&&Array.isArray(e.plainLines)&&e.plainLines.every(En)?{key:e.key,request:e.request,lines:zt(e.lines),goods:typeof e.goods=="string"?e.goods:"",plainPressed:e.plainPressed===!0,plainLines:zt(e.plainLines),plainGoods:typeof e.plainGoods=="string"?e.plainGoods:""}:null}var Vo=e=>typeof e=="string"?e:null,Jo={lastPress:ps,keptCardKey:Vo,placedShape:Vo,placedRequest:e=>ra(e)?e:null,unpaidOrder:e=>We(e)?Ln(e):null};function oa(e){let t=We(e)?e:{},n={...us};for(let r of Object.keys(Jo))n[r]=Jo[r](t[r]);return n}function aa(){let e;try{e=Le.getItem(Rn)}catch{return null}if(!e)return null;try{let t=JSON.parse(e);if(t.v!==Zo||typeof t.key!="string"||!t.key||!Array.isArray(t.lines)||!t.lines.every(En)||typeof t.parkedAt!="number")return null;let n={key:t.key,authed:t.authed===!0,parkedAt:t.parkedAt,press:oa(t.press),lines:zt(t.lines),form:t.form&&typeof t.form=="object"?An(t.form):null};return Date.now()>=ds(n)?(Tn(),null):In(n.press)?n:null}catch{return null}}function Tn(){try{Le.removeItem(Rn)}catch{}}import{jsx as Ce}from"react/jsx-runtime";function sa(e){let t=e.indexOf(`
3
- `);return t===-1?[e,""]:[e.slice(0,t),e.slice(t+1)]}function ca(e,{canParkContext:t}={canParkContext:!0}){let n=e.paymentMethods,r=[];return n.includes("card")&&r.push({key:"card",title:"Card",body:null,price:Ce("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"VISA \xB7 MC \xB7 AMEX"})}),n.includes("paypal")&&e.paypalClientId&&r.push({key:"paypal",title:"PayPal",body:null,price:Ce("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAYPAL \xB7 CARDS"})}),n.includes("afterpay")&&r.push({key:"afterpay",title:"Afterpay",body:null,price:Ce("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"4 \xD7 INTEREST-FREE"})}),n.includes("square")&&e.squareApplicationId&&e.squareLocationId&&r.push({key:"square",title:"Card (Square)",body:null,price:Ce("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"VISA \xB7 MC \xB7 AMEX"})}),n.includes("gocardless")&&t&&r.push({key:"gocardless",title:"Bank Direct Debit",body:null,price:Ce("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY BY BANK"})}),n.includes("zip")&&r.push({key:"zip",title:"Zip",body:null,price:Ce("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY IN 4"})}),n.includes("klarna")&&t&&r.push({key:"klarna",title:"Klarna",body:null,price:Ce("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY LATER"})}),n.includes("bank")&&r.push({key:"bank",title:"Bank transfer",body:null,price:Ce("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Invoiced"})}),r}var ma="This shop does not take payment online yet. Please contact the shop to order.",et=class extends Error{};function la(e,t){if(!e.orderNumber&&Yt(t))return t.message;let n=t instanceof ue?` (${t.message})`:"";return e.orderNumber?`Your order ${e.orderNumber} is saved, but the payment did not start${n}. Try the payment again \u2014 your order will not be placed twice.`:`Your items are held under ${e.checkoutNumber}, but the payment did not start${n}. Try the payment again \u2014 you will not be charged twice.`}var gs=3e3,ys=.005,ua=new Set(["paypal","square","afterpay","gocardless","zip","klarna"]);function da(){let e=Hr();return{...e==="denied"?{}:Do(),...e?{adConsent:e}:{}}}var ye=e=>JSON.parse(e),hs={lastPress:null,keptCardKey:null,placedShape:null,placedRequest:null,unpaidOrder:null},bs={lastPress:e=>e&&{key:e.key,request:On(e.request),lines:e.lines,goods:ye(e.shape)[0],plainPressed:!!e.plainMethod,plainLines:e.plainLines,plainGoods:ye(e.plainShape)[0]},keptCardKey:e=>e,placedShape:e=>e===null?null:ye(e)[0],placedRequest:e=>e&&On(e.body),unpaidOrder:e=>e&&Ln(e)};function pa(e,t){let n={};for(let r of Object.keys(e))n[r]=e[r](t[r]);return n}var fa="Shipping cannot be calculated right now. Please try again.";function ga(e){return`Your order is saved, so its contact, address, delivery and discount can't change here. To change any of them, contact the shop and quote ${e}.`}function vs({site:e,logo:t,preview:n=!1}){let{items:r,totals:a,coupon:s,refuseCoupon:d,deliveryOptions:g,shippingMethodId:f,setShippingMethodId:p,setQuoteDestination:v,courier:h,requote:k,identify:b,clearCapturedCart:R,replaceItems:C,removeCoupon:E,applyCoupon:j}=_t(),O=g.find(o=>o.id===f)?.pickupLocation??null,{country:S,countries:B,activeCountry:Z,formatMoney:de}=fe(),[U,se]=P(()=>ca(e)[0]?.key??null),[Ne,qe]=P(!0);G(()=>{qe(Ar(Le))},[]);let[ee,he]=P(!1),[re,te]=P(""),[H,y]=P(""),[we,Fe]=P(""),[W,nt]=P(""),[Q,be]=P(""),[Se,Ee]=P(""),[L,oe]=P(""),[pe,Re]=P(""),[ve,rt]=P(""),[$,ot]=P(()=>S||B[0]?.code||""),[ke,vt]=P(""),[at,Kn]=P([]),[Xt,Zt]=P(null),[kt,Be]=P(null),Dn=ia(()=>B.find(o=>o.code===$)??Z,[B,$,Z]),Oa=Dn?.postalLabel||"Postal Code",Aa=at[0]?.divisionType||"State / Province";G(()=>{if(!$){Kn([]),Zt($);return}Zt(null);let o=!1;return Y.listCountrySubdivisions($).then(c=>{o||(Kn(c),Zt($),vt(""))}),()=>{o=!0}},[$]);let jn=Q.trim()!==""&&L.trim()!==""&&pe.trim()!==""&&Xt===$&&(at.length===0||ke!=="")?pe.trim():"";G(()=>{v($?{country:$,subdivision:ke,postcode:jn}:null)},[$,ke,jn,v]),G(()=>()=>v(null),[v]);let La=h?.status==="unavailable",Ia=k,[it,Un]=P(null),[Ta,Wn]=P([]),[Qt,xt]=P("new"),[$n,Yn]=P(!1),[en,qa]=P("Home"),[Fa,Bn]=P(null),[_a,tn]=P(null),[_e,Ct]=P(()=>ft()),zn=z(null),[nn,ze]=P(null),[Ma,ce]=P(null),[Gn,Pt]=P(null),[Hn,Ka]=P(!1),[Vn,Da]=P(!1),[Oe,Ge]=P(null),[ja,Nt]=P(!1),[J,le]=P(null),Jn=!!J?.orderNumber,Ua=Jn||ee,[Wa,$a]=P(null),[Ya,Ba]=P(!1),[za,Ga]=P(!1),[Ha,Va]=P(!1),[Ja,Xa]=P(!1),[Xn,Za]=P(!1),[Qa,rn]=P(!1),[st,Zn]=P(null),A=z({...hs});A.current.unpaidOrder=J;let on=z(!1),Me=z(r),Qn=!!(nn||st&&st.kind!=="processing"||Xn||Hn||Vn||Gn&&Oe?.orderNumber);G(()=>{Qn&&(C([]),E())},[Qn,C,E]);let er=z(!1);G(()=>{n||er.current||!r.some(mt)||(er.current=!0,Fr({lines:r,currency:a.currency,value:a.subtotal-a.discount,coupon:s?.valid?s.code:void 0}))},[r,a,s,n]),G(()=>{b(re,H.trim()||void 0)},[re,H,b]);let tr=z(null),[wt,ei]=P(null);G(()=>{let o=tr.current;if(!wt||!o)return;let c=()=>o.style.setProperty("--sf-checkout-header-h",`${wt.offsetHeight}px`);c();let m=new ResizeObserver(c);return m.observe(wt),()=>m.disconnect()},[wt]),G(()=>{let o=m=>({setConfirming:m,land:ze,markPaid:()=>Nt(!0),note:(N,u)=>$a({text:N,warning:u}),fail:ce,clearCart:R,lostChange:()=>tn($t)}),c={search:window.location.search,storage:Le,scrubQuery:()=>window.history.replaceState(null,"",window.location.pathname)};ht(Yo,{...c,capture:Y.captureAfterpayPayment,page:o(Ba)}),ht(Bo,{...c,capture:Y.captureZipPayment,page:o(Va)}),ht(zo,{...c,capture:Y.completeGocardlessPayment,page:o(Ga)}),ht(Go,{...c,capture:Y.captureKlarnaPayment,page:o(Xa)})},[]);function nr(o){let[c,m]=sa(o.address);be(c),Ee(m),oe(o.city),Re(o.zip_code),o.country&&ot(o.country),o.phone&&rt(o.phone),Be({country:o.country||null,state:o.state??""})}G(()=>{if(kt){if((kt.country||$)!==$){Be(null);return}Xt===$&&(vt(Ho($,kt.state,at)),Be(null))}},[kt,$,Xt,at]),G(()=>{let o=!1;return(async()=>{try{let[c,m,N]=await Promise.all([Ze.me(),Ze.myProfile().catch(()=>null),Ze.myAddresses().catch(()=>[])]);if(o)return;Un(c);let u=N.filter(_=>_.is_active);Wn(u),te(c.email);let T=(m?.contact_name??"").split(/\s+/);y(c.first_name||T[0]||""),Fe(c.last_name||T.slice(1).join(" "));let F=c.phone||m?.phone;F&&rt(F);let q=u.find(_=>_.id===c.default_delivery_location)??u[0];if(q)xt(q.id),nr(q);else if(m){let[_,Xe]=sa(m.address??"");be(_),Ee(Xe),oe(m.city??""),Re(m.zip_code??""),m.country&&ot(m.country),Be({country:m.country||null,state:m.state??""})}It.current&&ur(It.current,!1)}catch{}})(),()=>{o=!0}},[]);function ti(){Ze.logout(),ct.current=!0,It.current=null,Lt.current=null,lt(),Un(null),Wn([]),xt("new"),Yn(!1),te(""),y(""),Fe(""),nt(""),be(""),Ee(""),oe(""),Re(""),rt(""),ot(S||B[0]?.code||""),vt(""),Be(null)}let He=ia(()=>ca(e,{canParkContext:Ne}),[e,Ne]);G(()=>{He.some(o=>o.key===U)||se(He[0]?.key??null)},[He,U]);let ni=He.length===0,St=Se.trim()?`${Q}
4
- ${Se.trim()}`:Q,ri=qo({email:re,firstName:H,lastName:we,company:W.trim(),phone:ve,address:St,city:L,subdivision:ke,postcode:pe,country:$,lines:r.map(o=>[o.id,o.qty]),shippingMethodId:f,couponCode:mn(s),currency:a.currency,shopperId:it?.id??null}),ae=JSON.stringify([ri,U]),an=z(null),Et=z(!1),Ae=z(!1),Ve=z(null),Rt=z(!1),me=z(ae);me.current=ae;let rr=z(ee);rr.current=ee;let Ot=z(null);G(()=>{let o=()=>{let c=Ot.current;c&&(Ot.current=null,le(c),he(!1))};return window.addEventListener("pageshow",o),()=>window.removeEventListener("pageshow",o)},[]);function At(o,c,m,N){let u={idempotencyKey:c,confirmation:m};yr()&&(u.lostChange=!0),Le.setItem(o,JSON.stringify(u)),window.location.assign(N),Ot.current=m}async function or(o){he(!0);try{await o()}finally{Ot.current||he(!1)}}let ar=z(!1),ir=!!(nn||st&&st.kind!=="processing");G(()=>{ir&&(ar.current=!0,lt())},[ir]);let Lt=z(null),ct=z(!1),sn=z(null);function lt(){sn.current=null,Tn()}let It=z(null),[Je,oi]=P(!1);function cn(o){if(ar.current||n||ct.current)return;let c={key:o,authed:on.current,parkedAt:sn.current??=Date.now(),press:pa(bs,A.current),lines:r.length>0?r:Me.current,form:An({email:re,firstName:H,lastName:we,company:W,address1:Q,address2:Se,city:L,postcode:pe,phone:ve,country:$,subdivision:ke,selectedAddressId:Qt,shippingMethodId:f,couponCode:s?.valid?s.code:null})};In(c.press)?na(c):lt()}let sr=z(U);sr.current=U;function ln(o){return{...ta(o),...da(),...o.payFirst?{checkoutFlow:Wt}:{}}}function ai(o,c){let m=o.request.payFirst?"":null,N=o.plainPressed?null:"",u=()=>sr.current??"";return{key:o.key,send:()=>c(ln(o.request)),request:ln(o.request),lines:o.lines,shape:JSON.stringify([o.goods,null]),get method(){return m??u()},set method(T){m=T},get plainMethod(){return N??u()},set plainMethod(T){N=T},plainLines:o.plainLines,plainShape:JSON.stringify([o.plainGoods,null])}}let[ii,si]=P(!1),cr=ii?!a.quoted||a.serverSubtotal===null?"waiting":Math.abs(a.serverSubtotal-a.subtotal)<ys?"same":"changed":null,un=!J&&cr==="waiting",ci=un?{...a,repricing:!0}:a,lr=un&&a.quoteFailed;G(()=>{if(!lr)return;let o=setInterval(k,gs);return()=>clearInterval(o)},[lr,k]);function ur(o,c=!0){te(o.email),y(o.firstName),Fe(o.lastName),nt(o.company),be(o.address1),Ee(o.address2),oe(o.city),Re(o.postcode),rt(o.phone),o.country&&ot(o.country),Be({country:o.country||null,state:o.subdivision}),xt(o.selectedAddressId),o.shippingMethodId&&p(o.shippingMethodId),c&&(Lt.current=o.couponCode)}G(()=>{let o=n?null:aa(),c=!!(o&&r.length>0);if(o&&c&&!Qo(o.lines,r)&&(lt(),o=null),o){let m=o.authed?Y.createOrderAuthed:Y.createOrder;Ct(o.key),sn.current=o.parkedAt,on.current=o.authed;let N={lastPress:u=>u&&ai(u,m),keptCardKey:u=>u,placedShape:u=>u===null?null:JSON.stringify([u,null]),placedRequest:u=>{if(!u)return null;let T=ln(u);return{body:T,send:()=>m(T)}},unpaidOrder:u=>u};A.current=pa(N,o.press),o.press.unpaidOrder&&le(o.press.unpaidOrder),o.lines.length>0&&!c&&(C(o.lines),Me.current=o.lines,si(!0)),o.form&&(It.current=o.form,ur(o.form))}oi(!0)},[]),G(()=>{!Je||r.length>0||A.current.unpaidOrder||ee||(ct.current=!0,lt())},[Je,r.length]),G(()=>{let o=Lt.current;!Je||!o||r.length===0||(Lt.current=null,j(o,re||void 0))},[Je,r.length]),G(()=>{!Je||ee||cn(_e)},[Je,ee,_e,J]);let Ke=z(null);G(()=>{rr.current||(ae!==Ke.current&&(Ke.current=null),!(!Ae.current||!J||J.orderNumber)&&(ae===A.current.placedShape||ae===Ke.current||or(()=>dr(J))))},[ae,J]);async function dr(o){if(Rt.current)return null;Rt.current=!0;try{let c=Ve.current?await Lo(Ve.current):"none";if(c==="succeeded"||c==="processing")return Ae.current=!1,le(null),xe("card"),c==="succeeded"?await De(void 0,o):xr(o),null;if(c===void 0||!Io.has(c))return Ke.current=me.current,le(o),ce(c==="requires_action"?Oo:Ie),null;let m=await kn(_e);if(m==="committed")return Ae.current=!1,le(null),xe("card"),await De(void 0,o),null;if(m!=="released")return Ke.current=me.current,le(o),ce(Ie),null;Ae.current=!1,Ve.current=null,Ke.current=null,ce(null),le(null);let N=ft();return Ct(N),N}finally{Rt.current=!1}}async function li(){n||ee||Rt.current||await or(ui)}async function ui(){if(J){if((Ae.current?ae!==A.current.placedShape:ut())&&!J.orderNumber){let N=await dr(J);N&&me.current===ae&&await pr(N);return}ce(null),Et.current=!1,await dn();let c=ye(me.current)[1],m=J.orderNumber?c:"card";if(m&&ua.has(m)&&ut()&&ye(me.current)[0]!==an.current){mr(J);return}xe(m),m!==U&&se(m),await Cr(J,m,!J.orderNumber);return}await pr(_e)}async function pr(o){if(r.length===0||a.repricing||un||!U||!He.some(F=>F.key===U))return;let c=r.filter(mt).flatMap(F=>Tt(F.components,F.qty));if(c.length===0){ce("Pick a size on each wheel's product page before checking out.");return}ce(null);let m,N=o,u=U,T=!1;try{let F=it?Y.createOrderAuthed:Y.createOrder,q={customer:{email:re,name:`${H} ${we}`.trim(),phone:ve.trim()||void 0,companyName:W.trim()||void 0,address:St,city:L,state:ke||void 0,zipCode:pe,country:$},items:c,currency:a.currency,idempotencyKey:o,shippingMethodId:f??void 0,couponCode:mn(s),...da(),...Eo(U)?{checkoutFlow:Wt}:{}};A.current.placedRequest={body:q,send:()=>F(q)},on.current=!!it,ct.current=!1,tn(null),an.current=null,Et.current=!1,Ve.current=null,Ae.current=!1,Ke.current=null,A.current.placedShape=ae,Me.current=r;let _=A.current.lastPress,Xe=_?.key===q.idempotencyKey&&(_.shape!==ae&&(!!q.checkoutFlow||!!_.method||!!_.plainMethod)||!!q.checkoutFlow&&!!_.plainMethod);Xe&&(A.current.keptCardKey=q.idempotencyKey);let wr=br(q,F),Sr=Xe||!q.checkoutFlow&&A.current.keptCardKey===q.idempotencyKey,Er=!wr&&!Sr&&!q.checkoutFlow&&!!_&&!_.method;Er&&(_.plainMethod=U,_.plainLines=r,_.plainShape=ae,cn(q.idempotencyKey));let je=await(Sr?gr(q,F):F(q).then(dt=>({answer:dt,request:q})).catch(dt=>(wr?fr(dt,q.idempotencyKey):Er&&Cn(dt)&&(_.plainMethod=""),di(dt,q,F))));if(!je)return;m=je.answer,N=je.request.idempotencyKey,u=je.method??u,xe(u),T=ut()||u!==ye(me.current)[1],je.method&&je.method!==U&&se(je.method),m.orderNumber&&(vr(m),R()),await dn()}catch(F){let q=qr(F);q?(d(q),ce(`${q} Your order has not been placed. Place it again to continue without the code.`)):F instanceof et?ce(Ie):ce(F instanceof ue?F.message:"Could not place the order. Please try again.");return}if(u&&ua.has(u)&&(T||ut())){mr(m);return}await Cr(m,u,!1,N)}function mr(o){an.current=ye(me.current)[0],ce(`${la(o,null)} ${$t}`),le(o)}function fr(o,c){Cn(o)&&!xn(o)&&A.current.lastPress?.key===c&&(A.current.lastPress=null)}async function di(o,c,m){if(Yt(o))return hr(c,m);if(!xn(o))throw o;return A.current.keptCardKey=c.idempotencyKey,gr(c,m,!0)}async function gr(o,c,m=!1){let N=await kn(o.idempotencyKey);if(N==="released")return hr(o,c);if(N!=="committed")throw new et;let u=A.current.lastPress?.key===o.idempotencyKey?A.current.lastPress:null;if(Me.current=u?.lines??r,u?.method&&!m){A.current.keptCardKey=null,A.current.placedRequest={body:u.request,send:u.send};let Xe=await u.send().catch(()=>{throw new et});return A.current.placedShape=u.shape,{answer:Xe,request:o,method:u.method}}let T={...o,checkoutFlow:Wt},F=u&&!u.method?{body:u.request,send:u.send}:{body:T,send:()=>c(T)};A.current.placedRequest=F;let q=F.send,_=await q().catch(()=>null);if(!_&&u?.plainMethod)throw new et;return _?.orderNumber&&_.status!==Ro?(A.current.keptCardKey=null,u?.plainMethod&&(Me.current=u.plainLines),u&&(A.current.placedShape=u.plainMethod?u.plainShape:u.shape),{answer:_,request:o,method:u?.plainMethod||void 0}):(u&&(A.current.placedShape=u.shape),xe("card"),await kr("",_?async()=>_:()=>Promise.reject(new Error("The order request did not answer."))),await dn(),null)}function ut(){let o=A.current.placedShape;return o!==null&&ye(o)[0]!==ye(me.current)[0]}function xe(o){o!==ye(me.current)[1]&&(Et.current=!0),tn(yr()?$t:null)}function yr(){return Et.current||ut()}async function hr(o,c){let m={...o,idempotencyKey:ft()};A.current.keptCardKey=null,Ct(m.idempotencyKey),A.current.placedRequest={body:m,send:()=>c(m)},br(m,c);try{return{answer:await c(m),request:m}}catch(N){throw fr(N,m.idempotencyKey),N}}function br(o,c){return A.current.lastPress?.key===o.idempotencyKey?!1:(A.current.lastPress={key:o.idempotencyKey,send:()=>c(o),request:o,lines:r,shape:ae,method:o.checkoutFlow?"":U??"",plainMethod:"",plainLines:r,plainShape:ae},ct.current=!1,cn(o.idempotencyKey),!0)}function vr(o){_r({confirmation:o,lines:Me.current,adsSendTo:e.googleAdsId&&e.googleAdsConversionLabel?`${e.googleAdsId}/${e.googleAdsConversionLabel}`:null}),$o({confirmation:o,lines:Me.current})}async function De(o,c=Oe){if(!c)return;let m=o?async()=>o:A.current.placedRequest?.send;if(c.orderNumber||!m){Nt(!0),ze(c);return}await kr(c.checkoutNumber,m)}async function kr(o,c){R(),await Fo({checkoutNumber:o,resend:c,page:{setConfirming:Za,land:ze,markPaid:()=>Nt(!0),track:vr,unplaced:Zn}})}function xr(o=Oe){if(o){if(o.orderNumber){ze(o);return}R(),Zn({kind:"processing",checkoutNumber:o.checkoutNumber})}}async function dn(){let o=JSON.stringify([en.trim(),H,we,ve.trim(),St,L,ke,pe,$]);if(!(!it||!$n||Qt!=="new"||zn.current===o))try{await Ze.createAddress({label:en.trim()||"Home",contact_name:`${H} ${we}`.trim(),phone:ve.trim(),address:St,city:L,zip_code:pe,state:ke,country:$}),zn.current=o,Bn("Address saved to your account.")}catch{Bn("We couldn't save the address to your account \u2014 you can add it under Account \u2192 Addresses.")}}async function Cr(o,c=U,m=!1,N=_e){le(null);try{if(c==="card"&&e.paymentMethods.includes("card")){let u=await Y.createPaymentIntent({idempotencyKey:N});Ve.current=u;let T=o;if(m){let F=await A.current.placedRequest?.send().catch(()=>null);if(F?.orderNumber){xe("card"),await De(F,o);return}T=Pr(o,F)??{...o,expiresAt:null}}xe("card"),Ge(T),rn(!1),Pt(u)}else if(c==="paypal"&&e.paymentMethods.includes("paypal"))Ge(o),Ka(!0);else if(c==="afterpay"&&e.paymentMethods.includes("afterpay")){let u=window.location.origin,T=await Y.createAfterpayCheckout({idempotencyKey:N,confirmUrl:`${u}/checkout?afterpay=confirm`,cancelUrl:`${u}/checkout?afterpay=cancel`});At(Pn,N,o,T.redirectCheckoutUrl);return}else if(c==="square"&&e.paymentMethods.includes("square"))Ge(o),Da(!0);else if(c==="gocardless"&&e.paymentMethods.includes("gocardless")){let u=window.location.origin,T=await Y.createGocardlessBillingRequest({idempotencyKey:N,confirmUrl:`${u}/checkout?gocardless=confirm`,cancelUrl:`${u}/checkout?gocardless=cancel`});At(Nn,N,o,T.authorisationUrl);return}else if(c==="zip"&&e.paymentMethods.includes("zip")){let u=window.location.origin,T=await Y.createZipCheckout({idempotencyKey:N,redirectUrl:`${u}/checkout?zip=return`});At(wn,N,o,T.redirectUrl);return}else if(c==="klarna"&&e.paymentMethods.includes("klarna")){let u=window.location.origin,T=await Y.createKlarnaCheckout({idempotencyKey:N,confirmUrl:`${u}/checkout?klarna=confirm`,cancelUrl:`${u}/checkout?klarna=cancel`});At(Sn,N,o,T.redirectUrl);return}else xe(c),ze(o)}catch(u){if((m||c==="card")&&u instanceof ue&&u.status===409){xe(c),await De(void 0,o);return}Nr(o,u)}}function Pr(o,c){return c&&!c.orderNumber&&c.status==="open"&&c.checkoutNumber===o.checkoutNumber?c:null}function Nr(o,c){ce(la(o,c)),!o.orderNumber&&Yt(c)?(Ae.current=!1,Ct(ft())):le(o)}async function pi(o){if(!Oe)return;let c=Oe;try{let m=await Y.createPaymentIntent({idempotencyKey:_e}),N=await A.current.placedRequest?.send().catch(()=>null);if(N?.orderNumber){await De(N);return}let u=Pr(c,N);Ge(u??{...c,expiresAt:null}),rn(o&&u!==null),Ve.current=m,Pt(m)}catch(m){if(m instanceof ue&&m.status===409){await De();return}Pt(null),Ge(null),Nr(c,m)}}function mi(){Oe&&(Ae.current=!0,le(Oe),Pt(null),Ge(null),rn(!1))}return{site:e,logo:t,items:r,totals:ci,coupon:s,deliveryOptions:g,courierUnavailable:La,retryCourier:Ia,shippingMethodId:f,setShippingMethodId:p,pickupLocation:O,servedCountries:B,formatMoney:de,payChoice:U,setPayChoice:se,placing:ee,email:re,setEmail:te,firstName:H,setFirstName:y,lastName:we,setLastName:Fe,company:W,setCompany:nt,address1:Q,setAddress1:be,address2:Se,setAddress2:Ee,city:L,setCity:oe,postcode:pe,setPostcode:Re,phone:ve,setPhone:rt,country:$,setCountry:ot,subdivision:ke,setSubdivision:vt,subdivisions:at,destination:Dn,postcodeLabel:Oa,subdivisionLabel:Aa,me:it,savedAddresses:Ta,selectedAddressId:Qt,setSelectedAddressId:xt,saveAddress:$n,setSaveAddress:Yn,saveLabel:en,setSaveLabel:qa,addressSaveNote:Fa,lostChangeNote:_a,idemKey:_e,confirmation:nn,setConfirmation:ze,orderError:Ma,payment:Gn,paypalStep:Hn,squareStep:Vn,pendingConf:Oe,paid:ja,setPaid:Nt,unpaidOrder:J,orderLocked:Jn,formLocked:Ua,restoredPrices:cr,payNote:Wa,afterpayConfirming:Ya,gocardlessConfirming:za,zipConfirming:Ha,klarnaConfirming:Ja,cardConfirming:Xn,checkoutResult:st,confirmCardPayment:De,cardStillProcessing:xr,renewCardPayment:pi,holdRenewed:Qa,leaveCardPayment:mi,checkoutRootRef:tr,setCheckoutHeaderEl:ei,fillFromAddress:nr,checkoutSignOut:ti,payOptions:He,noPaymentMethod:ni,placeOrder:li}}var ya=ms(null);function ha({children:e,...t}){let n=vs(t);return Ce(ya.Provider,{value:n,children:e})}function Pe(){let e=fs(ya);if(!e)throw new Error("useCheckout must be used inside CheckoutStateProvider");return e}import{useId as qn}from"react";import{Fragment as Te,jsx as i,jsxs as w}from"react/jsx-runtime";function va(){let{email:e,setEmail:t,firstName:n,setFirstName:r,lastName:a,setLastName:s,company:d,setCompany:g,me:f,checkoutSignOut:p,orderLocked:v,unpaidOrder:h}=Pe(),k=qn();return w(Vt,{num:"N\xB0 01",title:"Contact",children:[v&&h&&i(xs,{orderNumber:h.orderNumber}),i(ie,{label:"Email",htmlFor:k,hint:f?w(Te,{children:["Signed in \xB7"," ",i("button",{type:"button",onClick:p,className:"underline transition-colors enabled:hover:text-accent",children:"Not you? Sign out"})]}):void 0,children:i("input",{id:k,type:"email",value:e,onChange:b=>t(b.target.value),placeholder:"you@example.com",readOnly:f!==null,className:ne})}),w(Na,{children:[i(ie,{label:"First name",children:i("input",{type:"text",value:n,onChange:b=>r(b.target.value),className:ne})}),i(ie,{label:"Last name",children:i("input",{type:"text",value:a,onChange:b=>s(b.target.value),className:ne})})]}),i(ie,{label:"Company (optional)",children:i("input",{type:"text",value:d,onChange:b=>g(b.target.value),autoComplete:"organization",className:ne})})]})}function ka(){let{pickupLocation:e,servedCountries:t,address1:n,setAddress1:r,address2:a,setAddress2:s,city:d,setCity:g,postcode:f,setPostcode:p,phone:v,setPhone:h,country:k,setCountry:b,subdivision:R,setSubdivision:C,subdivisions:E,destination:j,postcodeLabel:O,subdivisionLabel:S,me:B,savedAddresses:Z,selectedAddressId:de,setSelectedAddressId:U,saveAddress:se,setSaveAddress:Ne,saveLabel:qe,setSaveLabel:ee,fillFromAddress:he,orderLocked:re}=Pe(),te=qn(),H=qn();return w(Vt,{num:"N\xB0 02",title:e?"Collection":"Shipping address",children:[e?w("div",{className:"grid gap-2 text-[14px] leading-[1.6]",children:[i("span",{className:"font-medium",children:e.name}),[e.address,e.city,e.state,e.zipCode,e.country].filter(Boolean).length>0&&i("span",{className:"opacity-80",children:[e.address,e.city,e.state,e.zipCode,e.country].filter(Boolean).join(", ")}),e.openingHours&&i("span",{className:"opacity-80",children:e.openingHours}),e.readyIn&&i("span",{className:"opacity-80",children:e.readyIn}),e.instructions&&i("span",{className:"opacity-80",children:e.instructions}),i("span",{className:"mt-1 font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"No delivery address needed"})]}):w(Te,{children:[B!==null&&Z.length>0&&w("div",{className:"grid gap-3",children:[Z.map(y=>i(Gt,{active:de===y.id,onClick:()=>{U(y.id),he(y)},title:y.label,body:y.formatted_address,price:null},y.id)),i(Gt,{active:de==="new",onClick:()=>U("new"),title:"New address",body:null,price:null})]}),i(ie,{label:"Address line 1",children:i("input",{type:"text",value:n,onChange:y=>r(y.target.value),className:ne})}),i(ie,{label:"Address line 2",children:i("input",{type:"text",value:a,onChange:y=>s(y.target.value),placeholder:"Apartment, unit, garage bay\u2026",className:ne})}),w(Na,{cols:"three",children:[i(ie,{label:"City",children:i("input",{type:"text",value:d,onChange:y=>g(y.target.value),className:ne})}),i(ie,{label:O,children:i("input",{type:"text",value:f,onChange:y=>p(y.target.value),className:ne})}),i(ie,{label:"Country",separate:!0,htmlFor:te,children:i(gn,{id:te,value:k,onChange:y=>b(y.target.value),className:ne+" pr-10",style:ba,children:t.map(y=>i("option",{value:y.code,children:y.name},y.code))})})]}),i(ie,{label:S,separate:!0,htmlFor:H,children:E.length>0?w(gn,{id:H,value:R,onChange:y=>C(y.target.value),className:ne+" pr-10",style:ba,children:[i("option",{value:"",children:"Select\u2026"}),E.map(y=>i("option",{value:y.code||y.name,children:y.name},y.code||y.name))]}):i("input",{id:H,type:"text",value:R,onChange:y=>C(y.target.value),className:ne})})]}),i(ie,{label:"Phone",children:i("input",{type:"tel",value:v,onChange:y=>h(y.target.value),className:ne})}),!e&&B!==null&&de==="new"&&!re&&w(Te,{children:[i(Cs,{checked:se,onChange:Ne,label:"Save this address to my account"}),se&&i(ie,{label:"Address label",children:i("input",{type:"text",value:qe,onChange:y=>ee(y.target.value),placeholder:"Home",className:ne})})]})]})}function xa(){let{totals:e,coupon:t,deliveryOptions:n,shippingMethodId:r,setShippingMethodId:a,pickupLocation:s,formatMoney:d,city:g,destination:f,courierUnavailable:p,retryCourier:v}=Pe();return i(Vt,{num:"N\xB0 03",title:"Shipping",children:w("div",{className:"grid gap-3",children:[n.map(h=>{let k=h.pickupLocation,b=k?[k.address,k.city,k.state,k.zipCode].filter(Boolean).join(", "):null;return i(Gt,{active:r===h.id,onClick:()=>a(h.id),title:k?`${h.name} \u2014 ${k.name}`:h.name,body:k?[b,k.openingHours,k.readyIn,k.instructions,h.description].filter(Boolean).join(" \xB7 "):h.description||null,price:e.freeShipping||h.amount===0?qt:d(h.amount,e.currency),tag:h.tag||void 0},h.id)}),p?w("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:[fa," ",i("button",{type:"button",onClick:v,className:"underline transition-colors enabled:hover:text-accent",children:"Try again"})]}):n.length===0&&i("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Shipping is arranged after your order is reviewed."})]})})}function Ca(){let{payChoice:e,setPayChoice:t,payment:n,payOptions:r,noPaymentMethod:a}=Pe();return w(Vt,{num:"N\xB0 04",title:"Payment",children:[a&&i("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:ma}),i("div",{className:"grid gap-3",children:r.map(s=>i(Gt,{active:e===s.key,onClick:()=>t(s.key),title:s.title,body:s.body,price:s.price,tag:s.tag},s.key))}),e==="card"?i("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You\u2019ll enter card details on the secure payment step after placing the order."}):e==="paypal"?i("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You\u2019ll approve the payment with PayPal on the payment step after placing the order."}):e==="afterpay"?i("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You\u2019ll be taken to Afterpay to approve four interest-free payments, then brought straight back."}):e==="square"?i("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You\u2019ll enter card details on the secure payment step after placing the order."}):e==="gocardless"?i("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You\u2019ll set up a bank direct debit with GoCardless, then be brought straight back. Direct debits clear in a few days."}):e==="zip"?i("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You\u2019ll be taken to Zip to approve four instalments, then brought straight back."}):e==="klarna"?i("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"You\u2019ll be taken to Klarna to choose how to pay, then brought straight back."}):e==="bank"?i("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Our team emails you the invoice and bank details after review."}):null]})}function Pa(){let{site:e,items:t,totals:n,coupon:r,formatMoney:a,payChoice:s,placing:d,email:g,orderError:f,payment:p,noPaymentMethod:v,unpaidOrder:h,formLocked:k,restoredPrices:b,placeOrder:R}=Pe(),C=b==="waiting",E=b==="changed";return w("aside",{className:"sticky top-[var(--sf-checkout-header-h,88px)] border border-line max-view-desktop:static",style:{background:"linear-gradient(180deg, color-mix(in oklab, var(--site-surface) 70%, var(--bg)) 0%, var(--bg) 100%)"},children:[w("header",{className:"flex items-center justify-between border-b border-accent bg-accent px-6 py-4 font-mono text-[13px] font-bold uppercase tracking-[0.28em] text-bg",children:[i("span",{children:"Your order"}),i(bt,{href:"/wheels",className:"text-bg/80 transition-colors hover:text-bg",children:"Edit \u2197"})]}),i("div",{className:"flex flex-col px-6 py-2",children:t.length===0?w("div",{className:"py-8 text-center font-serif text-[16px] italic leading-[1.5] text-fg-dim",children:["Your cart is empty. ",i(bt,{href:"/wheels",className:"text-accent underline-offset-4 hover:underline",children:"Browse the catalog \u2192"})]}):t.map(j=>i(Ps,{slug:j.slug,name:j.name,qty:j.qty,config:j.config,configSummary:Ns(j.config),price:E||C?null:jr(j,n.currency)??0,currency:n.currency},j.id))}),i(Ht,{locked:k,className:"border-t border-line px-6 pt-5",children:i(Br,{customerEmail:g,disabled:k})}),w("div",{className:"flex flex-col gap-2 border-t border-line mt-5 px-6 pt-5",children:[i($e,{label:"Subtotal",value:C?Ft:a(E?n.serverSubtotal??0:n.subtotal,n.currency)}),n.discount>0&&r?.valid&&i($e,{label:`Coupon \xB7 ${r.code}`,value:w("span",{className:"font-semibold text-green",children:["\u2212 ",a(n.discount,n.currency)]})}),r?.deferred&&i($e,{label:`Coupon \xB7 ${r.code}`,value:Tr}),r?.valid&&r.effects?.gift&&i($e,{label:`Free gift \xB7 ${r.effects.gift.partNumber}${r.effects.gift.quantity>1?` \xD7${r.effects.gift.quantity}`:""}`,value:i("span",{className:"font-semibold text-green",children:qt})}),i($e,{label:"Shipping",value:n.shippingStatus==="free"?i("span",{className:"font-semibold text-green",children:qt}):Kr(n.shippingStatus)??a(n.shipping,n.currency)}),n.tax&&(n.tax.charged?i($e,{label:n.tax.inclusive?`${n.tax.name} included \xB7 ${n.tax.rate}%`:n.tax.name,value:a(n.tax.amount,n.currency)}):n.tax.name?i($e,{label:n.tax.name,value:Mr}):null)]}),w("div",{className:"mt-4 flex items-end justify-between border-y-2 border-accent px-6 py-4",style:{background:"color-mix(in oklab, var(--accent) 10%, var(--bg))"},children:[i("span",{className:"font-display text-[20px] font-bold uppercase tracking-[0.04em] text-fg",children:"Total"}),i("span",{className:"text-right font-display text-[34px] font-bold leading-none tracking-[-0.025em] text-fg",children:n.repricing?Ft:a(n.grand,n.currency)})]}),w("div",{className:"flex flex-col gap-3 px-6 pt-5 pb-6",children:[E&&i(ge,{tone:"quiet",children:Xo}),f&&i(ge,{role:"alert",children:f}),n.hasUnpricedLine&&w(ge,{role:"status",children:["One or more items have no price in ",n.currency,". Remove them, or switch region, to continue."]}),i("button",{type:"button",onClick:R,disabled:d||!h&&(v||t.length===0||n.hasUnpricedLine||n.repricing),className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",d||!h&&(t.length===0||v||n.hasUnpricedLine||n.repricing)?"cursor-not-allowed border-line bg-surface text-fg-dim":"border-btn bg-btn text-btn-ink hover:border-fg hover:bg-fg"].join(" "),children:d?w(Te,{children:["Building order\u2026 ",i("span",{children:"\xB7"})]}):v?w(Te,{children:["No online payment ",i("span",{children:"\xB7"})]}):h?w(Te,{children:["Try payment again \xB7 ",Bt(h),i("span",{className:"transition-transform group-hover:translate-x-1",children:"\u2192"})]}):n.repricing?w(Te,{children:[Ft," ",i("span",{children:"\xB7"})]}):w(Te,{children:[s==="bank"?"Place order":"Continue to payment"," \xB7"," ",a(n.grand,n.currency),i("span",{className:"transition-transform group-hover:translate-x-1",children:"\u2192"})]})})]})]})}var ks=" [&:disabled_:disabled]:cursor-not-allowed! [&:disabled_:disabled]:opacity-70! [&_input[readonly]]:cursor-not-allowed [&_input[readonly]]:opacity-70";function Ht({locked:e,className:t="",children:n}){return i("fieldset",{disabled:e,className:"m-0 min-w-0 border-0 p-0 "+t+ks,children:n})}function bt({href:e,className:t="",children:n,...r}){let{placing:a}=Pe();return a?i("span",{"aria-disabled":"true","aria-label":r["aria-label"],className:t+" pointer-events-none",children:n}):i(Ue,{href:e,"aria-label":r["aria-label"],className:t,children:n})}function xs({orderNumber:e}){return i(ge,{tone:"quiet",role:"status",children:w("span",{className:"flex items-start gap-2",children:[w("svg",{"aria-hidden":!0,viewBox:"0 0 16 16",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"mt-[3px] shrink-0",children:[i("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1"}),i("path",{d:"M5 7V5a3 3 0 0 1 6 0v2"})]}),i("span",{children:ga(e)})]})})}var ba={backgroundImage:"linear-gradient(45deg, transparent 50%, var(--accent) 50%), linear-gradient(135deg, var(--accent) 50%, transparent 50%)",backgroundPosition:"calc(100% - 18px) 50%, calc(100% - 12px) 50%",backgroundSize:"6px 6px",backgroundRepeat:"no-repeat"};function Vt({num:e,title:t,children:n}){return w("section",{className:"mb-6 border border-line bg-bg",children:[w("header",{className:"flex items-center gap-4 border-b border-line bg-surface px-6 py-4",children:[i("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:e}),i("h2",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:t})]}),i("div",{className:"flex flex-col gap-4 px-6 py-6",children:n})]})}function Na({cols:e="two",children:t}){return i("div",{className:["grid gap-3 max-[640px]:grid-cols-1",e==="two"?"grid-cols-2":"grid-cols-[1.2fr_1fr_1fr]"].join(" "),children:t})}function Gt({active:e,onClick:t,title:n,body:r,price:a,tag:s}){return w("button",{type:"button",onClick:t,"aria-pressed":e,className:["relative grid grid-cols-[auto_1fr_auto] items-center gap-5 border bg-bg px-6 py-5 text-left transition-colors",e?"border-accent outline outline-1 outline-accent -outline-offset-1":"border-line enabled:hover:border-[color-mix(in_oklab,var(--accent)_50%,var(--site-line))]"].join(" "),style:e?{background:"color-mix(in oklab, var(--accent) 14%, var(--bg))"}:void 0,children:[e&&i("span",{"aria-hidden":!0,className:"absolute inset-y-0 left-0 w-[3px] bg-accent"}),i("span",{className:["flex h-[18px] w-[18px] items-center justify-center rounded-full border-2",e?"border-accent":"border-fg-dim"].join(" "),children:e&&i("span",{className:"block h-2.5 w-2.5 rounded-full bg-accent"})}),w("span",{className:"flex min-w-0 flex-col gap-1",children:[w("span",{className:"flex flex-wrap items-baseline gap-3 font-display text-[18px] font-medium tracking-[-0.01em] text-fg",children:[n,s&&i("span",{className:"border px-2 py-0.5 font-mono text-[11px] font-normal uppercase tracking-[0.24em] text-accent",style:{background:"color-mix(in oklab, var(--accent) 14%, transparent)",borderColor:"color-mix(in oklab, var(--accent) 45%, var(--site-line))"},children:s})]}),r&&i("span",{className:"font-mono text-[12px] uppercase tracking-[0.22em] text-fg-dim",children:r})]}),i("span",{className:"whitespace-nowrap font-display text-[18px] font-medium tracking-[-0.01em] text-fg",children:a})]})}function Cs({checked:e,onChange:t,label:n,sub:r}){return w("div",{className:"flex items-start gap-3 border-t border-line py-4 first:border-t-0 first:pt-0",children:[i("button",{type:"button",onClick:()=>t(!e),"aria-pressed":e,"aria-label":n,className:["mt-px flex h-5 w-5 flex-shrink-0 items-center justify-center border transition-colors",e?"border-accent":"border-line"].join(" "),style:e?{background:"color-mix(in oklab, var(--accent) 18%, transparent)"}:void 0,children:e&&i("span",{className:"text-[13px] text-accent",children:"\u2713"})}),w("span",{className:"flex-1 font-display text-[16px] leading-[1.5] text-fg",children:[n,r&&i("small",{className:"mt-1 block font-mono text-[12px] uppercase tracking-[0.18em] text-fg-dim",children:r})]})]})}function Ps({slug:e,name:t,qty:n,config:r,configSummary:a,price:s,currency:d}){let{catalog:g}=_t(),{formatMoney:f}=fe(),p=g.find(C=>C.slug===e),v=p?.spokes??5,h=p?.mesh??!1,k=r.find(C=>C.gold)?.label,b=p?.finishes.find(C=>C.name===k&&C.src)??p?.finishes.find(C=>C.src),R=p?.finishes[0]?.color??Yr;return w("div",{className:"grid grid-cols-[60px_1fr_auto] items-center gap-4 border-b border-line py-4 last:border-b-0",children:[w("div",{className:"relative aspect-square",children:[i("div",{className:"flex h-full w-full items-center justify-center overflow-hidden border border-line bg-surface",children:b?.src?i(Rr,{src:b.src,alt:`${t.lead}${t.accent} \u2014 ${b.name}`,width:120,height:120,sizes:"60px",className:"block h-full w-full object-contain p-2"}):i("div",{className:"block w-[78%]",style:{color:R},children:i($r,{spokes:v,mesh:h,className:"block w-full"})})}),i("span",{className:"absolute -right-1.5 -top-1.5 z-[2] flex h-[18px] w-[18px] items-center justify-center rounded-full bg-accent font-mono text-[11px] font-bold text-bg",children:n})]}),w("div",{className:"flex min-w-0 flex-col gap-0.5",children:[w("span",{className:"font-display text-[17px] font-bold uppercase leading-none tracking-[-0.005em] text-fg",children:[t.lead,i("em",{className:"font-serif font-normal italic text-accent tracking-[-0.005em] normal-case",children:t.accent})]}),i("span",{className:"font-mono text-[12px] uppercase leading-[1.5] tracking-[0.18em] text-fg-dim",children:a})]}),i("span",{className:"text-right font-display text-[17px] font-bold tracking-[-0.005em] text-fg",children:s===null?null:f(s,d)})]})}function $e({label:e,value:t}){return w("div",{className:"flex items-center justify-between font-mono text-[13px] font-medium uppercase tracking-[0.18em] text-fg",children:[i("span",{children:e}),i("strong",{className:"font-display text-[16px] font-medium tracking-[-0.005em] normal-case text-fg",children:t})]})}function Ns(e){return e.map(t=>t.label).join(" \xB7 ")}import{Fragment as V,jsx as l,jsxs as x}from"react/jsx-runtime";function Mn(e){return l(ha,{...e,children:l(Rs,{})})}function Ss({order:e,paid:t}){let{formatMoney:n}=fe();if(!e.grandTotal||!e.currency)return null;let r=d=>n(Number(d),e.currency),a=Number(e.freightCharge??0),s=Number(e.discountAmount??0);return x("dl",{className:"grid w-full max-w-sm grid-cols-[1fr_auto] gap-x-6 gap-y-1 border-y border-line py-3 text-left text-sm",children:[(e.shippingMethod||a>0)&&x(V,{children:[x("dt",{className:"text-fg-dim",children:["Delivery",e.shippingMethod?` \xB7 ${e.shippingMethod}`:""]}),l("dd",{className:"text-right font-mono",children:r(e.freightCharge??"0")})]}),s>0&&x(V,{children:[x("dt",{className:"text-fg-dim",children:["Discount",e.couponCode?` \xB7 ${e.couponCode}`:""]}),x("dd",{className:"text-right font-mono",children:["\u2212",r(e.discountAmount??"0")]})]}),l("dt",{className:"text-fg",children:t?"Total paid":"Order total"}),l("dd",{className:"text-right font-mono text-fg",children:r(e.grandTotal)})]})}function Es({result:e,lostChangeNote:t=null}){let n=l("span",{className:"font-mono text-fg",children:e.checkoutNumber});return x("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[l("h1",{className:"font-display text-3xl",children:e.kind==="refunded"||e.kind==="expired"?"Order not placed":e.kind==="processing"?"Payment processing":"Payment received"}),l("p",{className:"text-fg-dim",children:e.kind==="refunded"?x(V,{children:["An item sold out or an offer ended while you paid for checkout ",n,". Your payment goes back to your card."]}):e.kind==="expired"?x(V,{children:["The hold on checkout ",n," ran out before your payment arrived. Your payment goes back to your card."]}):e.kind==="processing"?x(V,{children:["Your payment for checkout ",n," is being processed. When it goes through, we will email your order confirmation."]}):x(V,{children:["Thank you \u2014 your payment",e.checkoutNumber?x(V,{children:[" for checkout ",n]}):null," has gone through. We will email you the order number shortly."]})}),t&&e.kind!=="refunded"&&e.kind!=="expired"&&l("p",{className:"text-sm text-fg-dim",children:t}),l(Ue,{href:"/wheels",className:"mt-2 border-2 border-line px-6 py-3 font-mono text-[12px] uppercase tracking-[0.24em] hover:border-accent",children:"Continue browsing"})]})}function Rs(){let{site:e,logo:t,items:n,placing:r,formLocked:a,email:s,me:d,addressSaveNote:g,lostChangeNote:f,idemKey:p,confirmation:v,setConfirmation:h,payment:k,paypalStep:b,squareStep:R,pendingConf:C,paid:E,setPaid:j,payNote:O,afterpayConfirming:S,gocardlessConfirming:B,zipConfirming:Z,klarnaConfirming:de,cardConfirming:U,checkoutResult:se,confirmCardPayment:Ne,cardStillProcessing:qe,renewCardPayment:ee,holdRenewed:he,leaveCardPayment:re,checkoutRootRef:te,setCheckoutHeaderEl:H}=Pe();return v?x("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[l("h1",{className:"font-display text-3xl",children:E?"Payment received":"Order received"}),x("p",{className:"text-fg-dim",children:[E?x(V,{children:["Thank you \u2014 your payment for order"," ",l("span",{className:"font-mono text-fg",children:v.orderNumber})," has gone through."," "]}):x(V,{children:["Thank you \u2014 your order ",l("span",{className:"font-mono text-fg",children:v.orderNumber})," is being reviewed by our team."," "]}),d?x(V,{children:["Track it under"," ",l(Ue,{href:"/account/orders",className:"text-accent underline",children:"your orders"}),"."]}):l(V,{children:"We\u2019ve emailed you a link to set a password and track it."})]}),l(Ss,{order:v,paid:E}),f&&l("p",{className:"text-sm text-fg-dim",children:f}),O&&(O.warning?l("div",{className:"w-full max-w-sm text-left",children:l(ge,{tone:"bad",role:"alert",children:O.text})}):l("p",{className:"text-sm text-fg-dim",children:O.text})),g&&l("p",{className:"text-sm text-fg-dim",children:g}),!d&&x("p",{className:"text-sm text-fg-dim",children:["You can also"," ",l(Ue,{href:`/track?order=${encodeURIComponent(v.orderNumber)}`,className:"text-accent underline",children:"track this order"})," ","anytime with just your order number and email \u2014 no password needed."]}),l(Ue,{href:"/wheels",className:"mt-2 border-2 border-line px-6 py-3 font-mono text-[12px] uppercase tracking-[0.24em] hover:border-accent",children:"Continue browsing"})]}):se?l(Es,{result:se,lostChangeNote:f}):U?x("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[l("h1",{className:"font-display text-3xl",children:"Confirming your payment\u2026"}),l("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Placing your order \u2014 one moment."})]}):S?x("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[l("h1",{className:"font-display text-3xl",children:"Confirming your payment\u2026"}),l("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Afterpay \u2014 one moment."})]}):B?x("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[l("h1",{className:"font-display text-3xl",children:"Setting up your direct debit\u2026"}),l("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Confirming with GoCardless \u2014 one moment."})]}):Z?x("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[l("h1",{className:"font-display text-3xl",children:"Confirming your payment\u2026"}),l("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Zip \u2014 one moment."})]}):de?x("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[l("h1",{className:"font-display text-3xl",children:"Confirming your payment\u2026"}),l("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Klarna \u2014 one moment."})]}):k&&C?l(Os,{payment:k,checkout:C,holdRenewed:he,onPaid:Ne,onProcessing:qe,onRenew:ee,onBack:re}):b&&C?l(Ts,{confirmation:C,clientId:e.paypalClientId??"",idemKey:p,onPaid:()=>{j(!0),h(C)},onSkip:()=>h(C)}):R&&C?l(Fs,{confirmation:C,applicationId:e.squareApplicationId??"",locationId:e.squareLocationId??"",environment:e.squareEnvironment??"production",idemKey:p,onPaid:()=>{j(!0),h(C)},onSkip:()=>h(C)}):x("div",{ref:te,className:"bg-bg text-fg",children:[x("header",{ref:H,className:"sticky top-0 z-30 grid grid-cols-[1fr_auto_1fr] items-center gap-8 max-[640px]:grid-cols-[auto_minmax(0,1fr)_auto] max-[640px]:gap-3 border-b border-line px-[var(--sf-site-gutter,40px)] py-6 backdrop-blur-md max-[640px]:px-[min(20px,var(--sf-site-gutter,40px))] max-[640px]:py-4",style:{background:"color-mix(in oklab, var(--bg) 92%, transparent)"},children:[x(bt,{href:"/",className:"inline-flex items-center gap-3 font-mono text-[14px] uppercase tracking-[0.26em] text-fg-dim transition-colors hover:text-accent",children:["\u2190",l("span",{className:"max-[640px]:hidden",children:"Back to shop"})]}),l("div",{className:"flex min-w-0 justify-center max-[640px]:[container-type:inline-size]",children:l(bt,{href:"/","aria-label":`${e.name} home`,className:"inline-flex max-w-full items-center justify-center max-[640px]:overflow-x-clip",children:[!0,!1].map(y=>l(Gr,{hideClass:y?"min-[641px]:hidden":"max-[640px]:hidden",variant:"header",scrolled:!0,src:t?.url??null,reverse:t?.reverse??!1,reversedSrc:t?.reversed??null,inkIsDark:t?.inkIsDark??null,size:t?.size??"medium",sizePx:t?.sizePx??null,sizeUnit:t?.sizeUnit??null,siteName:e.name,fitWordmarkToContainer:y,fitFloorPx:y?zr:void 0},y?"phone":"wide"))})}),e.cardPayments?x("span",{className:"flex items-center justify-end gap-3 font-mono text-[12px] uppercase tracking-[0.26em] text-fg-dim",children:[l("span",{className:"text-green",children:"\u25CF"}),l("span",{className:"max-[640px]:hidden",children:"Encrypted \xB7"})," Stripe"]}):l("span",{})]}),x("section",{className:"mx-auto flex max-w-[var(--sf-site-width,1600px)] flex-wrap items-center justify-between gap-x-8 gap-y-3 border-b border-line bg-surface px-[var(--sf-site-gutter,40px)] py-4 font-mono text-[13px] font-medium uppercase tracking-[0.24em] text-fg max-view-desktop:px-[min(24px,var(--sf-site-gutter,40px))]",children:[l("span",{className:"inline-flex items-center bg-accent px-3 py-1 font-bold text-bg",children:"Checkout"}),l("nav",{"aria-label":"Checkout steps",className:"flex flex-wrap items-center gap-5",children:[{n:"01",label:"Cart",state:"done"},{n:"02",label:"Ship & pay",state:"active"},{n:"03",label:"Confirmed",state:"pending"}].map(y=>x("span",{className:["relative flex items-center gap-2 transition-colors",y.state==="pending"?"text-fg-dim":"text-fg",y.state==="active"?"font-bold after:absolute after:inset-x-0 after:-bottom-1 after:h-[2px] after:bg-accent":""].join(" "),children:[l("span",{className:y.state==="done"?"text-accent font-bold":"",children:y.n}),l("span",{children:y.label})]},y.n))})]}),x("main",{className:"mx-auto grid max-w-[var(--sf-site-width,1600px)] grid-cols-[1fr_420px] items-start gap-16 px-[var(--sf-site-gutter,40px)] pt-10 pb-[100px] max-view-desktop:grid-cols-1 max-view-desktop:gap-10 max-view-desktop:px-[min(24px,var(--sf-site-gutter,40px))] max-view-desktop:pt-8 max-view-desktop:pb-20",children:[x("div",{children:[x(Ht,{locked:a,children:[l(va,{}),l(ka,{}),l(xa,{})]}),l(Ht,{locked:r,children:l(Ca,{})})]}),l(Pa,{})]}),l("footer",{className:"flex flex-wrap items-center justify-between gap-4 border-t border-line px-[var(--sf-site-gutter,40px)] py-6 font-mono text-[12px] uppercase tracking-[0.22em] text-fg-dim max-[640px]:px-[min(20px,var(--sf-site-gutter,40px))]",children:l("span",{children:Wr({legalName:e.legalName,foundedYear:e.foundedYear,siteName:e.name})})})]})}function Os({payment:e,checkout:t,holdRenewed:n,onPaid:r,onProcessing:a,onRenew:s,onBack:d}){let{formatMoney:g}=fe(),f=l("span",{className:"text-fg",children:g(Number(e.amount),e.currency)}),p=wa(()=>Ut(e.publishableKey),[e.publishableKey]),v=wa(()=>Jr(),[]),h=Vr(t.expiresAt??"",ws()??"");return l("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:x("div",{className:"w-full max-w-xl border border-line bg-bg",children:[x("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-4",children:[l("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:Bt(t)}),l("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"Payment"})]}),x("div",{className:"flex flex-col gap-4 px-6 py-6",children:[l("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:t.orderNumber?x(V,{children:["Your order is placed. Pay ",f," by card to confirm it now."]}):n?x(V,{children:["Your hold ran out, so your items are held again",h?` until ${h}`:"",". Enter your card again, then pay ",f,"."]}):x(V,{children:["Your items are held",h?` until ${h}`:"",". Pay ",f," by card to place your order."]})}),l(vn,{stripe:p,options:{clientSecret:e.clientSecret,appearance:v},children:l(Ls,{payment:e,checkout:t,onPaid:r,onProcessing:a,onRenew:s,onBack:d})},e.clientSecret)]})]})})}var As=5;function Ls({payment:e,checkout:t,onPaid:n,onProcessing:r,onRenew:a,onBack:s}){let{formatMoney:d}=fe(),g=vo(),f=ho(),[p,v]=Ye(!1),[h,k]=Ye(null),b=tt(!1);async function R(){try{return(await g.retrievePaymentIntent(e.clientSecret)).paymentIntent?.status}catch{return}}async function C(O){let S=O;for(let B=0;S==="processing"&&B<As;B+=1)await new Promise(Z=>setTimeout(Z,1e3)),S=await R()??S;if(S==="succeeded"){n();return}if(S==="processing"){r();return}k("Payment did not complete. Please try again."),v(!1)}async function E(){if(!g||!f||p)return;v(!0),k(null),b.current=!0;let O=await g.confirmPayment({elements:f,redirect:"if_required"}).catch(()=>null);if(!O){let S=await R();if(S==="succeeded"||S==="processing"){await C(S);return}k(S===void 0?Ie:"Payment failed. Please try again."),v(!1);return}if(O.error){if(!t.orderNumber&&O.error.code==="payment_intent_unexpected_state"){let S=await R();if(S==="succeeded"||S==="processing"){await C(S);return}if(S===void 0){k(Ie),v(!1);return}await a(S==="canceled"),v(!1);return}k(O.error.message??"Payment failed. Please try again."),v(!1);return}await C(O.paymentIntent?.status)}async function j(){if(p)return;if(!b.current){s();return}v(!0),k(null);let O=await R();if(O==="succeeded"||O==="processing"){await C(O);return}if(v(!1),O===void 0){k(Ie);return}s()}return x("div",{className:"flex flex-col gap-4",children:[l(ko,{}),h&&l(ge,{role:"alert",children:h}),l("button",{type:"button",onClick:E,disabled:!g||!f||p,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",!g||!f||p?"cursor-not-allowed border-line bg-surface text-fg-dim":"border-btn bg-btn text-btn-ink hover:border-fg hover:bg-fg"].join(" "),children:p?x(V,{children:["Processing\u2026 ",l("span",{children:"\xB7"})]}):x(V,{children:["Pay ",d(Number(e.amount),e.currency),l("span",{className:"transition-transform group-hover:translate-x-1",children:"\u2192"})]})}),!t.orderNumber&&!p&&x("button",{type:"button",onClick:j,className:"inline-flex items-center gap-3 self-start font-mono text-[12px] uppercase tracking-[0.26em] text-fg-dim transition-colors hover:text-accent",children:["\u2190",l("span",{children:"Back to checkout"})]})]})}var Sa="paypal-sdk-js",Fn=null;function Is(e,t){let n=`${e}|${t}`;if(Fn?.key===n)return Fn.promise;let r=new Promise((a,s)=>{document.getElementById(Sa)?.remove();let d=document.createElement("script");d.id=Sa;let g=new URLSearchParams({"client-id":e,currency:t,intent:"capture"});d.src=`https://www.paypal.com/sdk/js?${g}`,d.onload=()=>{let f=window.paypal;f?a(f):s(new Error("PayPal SDK loaded without its namespace"))},d.onerror=()=>s(new Error("PayPal SDK failed to load")),document.head.appendChild(d)});return Fn={key:n,promise:r},r}function Ts({confirmation:e,clientId:t,idemKey:n,onPaid:r,onSkip:a}){let{formatMoney:s}=fe(),d=tt(null),[g,f]=Ye(!1),[p,v]=Ye(null),h=tt(r);return h.current=r,Ra(()=>{let k=!1,b=null;return Is(t,e.currency).then(R=>{if(!(k||!d.current))return b=R.Buttons({style:{layout:"vertical",color:"gold",shape:"rect",label:"paypal"},createOrder:async()=>(await Y.createPaypalOrder({idempotencyKey:n})).paypalOrderId,onApprove:async C=>{try{if((await Y.capturePaypalOrder({idempotencyKey:n,paypalOrderId:C.orderID})).status==="paid"){h.current();return}v("PayPal did not complete the payment. Please try again.")}catch(E){v(E instanceof ue?E.message:"PayPal payment failed. Please try again.")}},onError:()=>{v("PayPal could not process the payment. Please try again.")}}),b.render(d.current).then(()=>{k||f(!0)})}).catch(()=>{k||v("PayPal could not be loaded. You can pay later \u2014 your order stands either way.")}),()=>{k=!0,b?.close?.()}},[t,e.currency,n]),l("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:x("div",{className:"w-full max-w-xl border border-line bg-bg",children:[x("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-4",children:[l("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:e.orderNumber}),l("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"PayPal"})]}),x("div",{className:"flex flex-col gap-4 px-6 py-6",children:[x("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:["Your order is placed. Pay"," ",l("span",{className:"text-fg",children:s(Number(e.grandTotal),e.currency)})," ","with PayPal to confirm it now."]}),!g&&!p&&l("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading PayPal\u2026"}),l("div",{ref:d}),p&&l(ge,{role:"alert",children:p}),l("button",{type:"button",onClick:a,className:"self-center font-mono text-[11px] uppercase tracking-[0.24em] text-fg-dim underline-offset-4 transition-colors hover:text-accent hover:underline",children:"Pay later \u2014 our team will be in touch"})]})]})})}var Ea="square-web-sdk",_n=null;function qs(e){let t=e==="sandbox"?"sandbox":"production";if(_n?.key===t)return _n.promise;let n=new Promise((r,a)=>{document.getElementById(Ea)?.remove();let s=document.createElement("script");s.id=Ea,s.src=t==="sandbox"?"https://sandbox.web.squarecdn.com/v1/square.js":"https://web.squarecdn.com/v1/square.js",s.onload=()=>{let d=window.Square;d?r(d):a(new Error("Square SDK loaded without its namespace"))},s.onerror=()=>a(new Error("Square SDK failed to load")),document.head.appendChild(s)});return _n={key:t,promise:n},n}function Fs({confirmation:e,applicationId:t,locationId:n,environment:r,idemKey:a,onPaid:s,onSkip:d}){let{formatMoney:g}=fe(),f=tt(null),p=tt(null),v=tt(null),[h,k]=Ye(!1),[b,R]=Ye(!1),[C,E]=Ye(null);Ra(()=>{let O=!1,S=null;return qs(r).then(async B=>{if(O||!f.current)return;let Z=B.payments(t,n);v.current=Z,S=await Z.card(),await S.attach(f.current),p.current=S,O||k(!0)}).catch(()=>{O||E("Square could not be loaded. You can pay later \u2014 your order stands either way.")}),()=>{O=!0,S?.destroy?.()}},[t,n,r]);async function j(){let O=p.current;if(!(!O||b)){R(!0),E(null);try{let S=await O.tokenize();if(S.status!=="OK"||!S.token){E(S.errors?.[0]?.message??"Please check the card details and try again."),R(!1);return}let B;try{B=(await v.current?.verifyBuyer?.(S.token,{amount:String(e.grandTotal),currencyCode:e.currency,intent:"CHARGE"}))?.token}catch{}if((await Y.chargeSquare({idempotencyKey:a,sourceId:S.token,...B?{verificationToken:B}:{}})).status==="paid"){s();return}E("Square did not complete the payment. Please try again.")}catch(S){E(S instanceof ue?S.message:"Square payment failed. Please try again.")}R(!1)}}return l("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:x("div",{className:"w-full max-w-xl border border-line bg-bg",children:[x("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-4",children:[l("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:e.orderNumber}),l("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"Card"})]}),x("div",{className:"flex flex-col gap-4 px-6 py-6",children:[x("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:["Your order is placed. Pay"," ",l("span",{className:"text-fg",children:g(Number(e.grandTotal),e.currency)})," ","by card to confirm it now."]}),!h&&!C&&l("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading card form\u2026"}),l("div",{ref:f}),C&&l(ge,{role:"alert",children:C}),l("button",{type:"button",onClick:j,disabled:!h||b,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",!h||b?"cursor-not-allowed border-line bg-surface text-fg-dim":"border-btn bg-btn text-btn-ink hover:border-fg hover:bg-fg"].join(" "),children:b?x(V,{children:["Processing\u2026 ",l("span",{children:"\xB7"})]}):x(V,{children:["Pay ",g(Number(e.grandTotal),e.currency),l("span",{className:"transition-transform group-hover:translate-x-1",children:"\u2192"})]})}),l("button",{type:"button",onClick:d,disabled:b,className:"self-center font-mono text-[11px] uppercase tracking-[0.24em] text-fg-dim underline-offset-4 transition-colors hover:text-accent hover:underline",children:"Pay later \u2014 our team will be in touch"})]})]})})}import{jsx as Jt}from"react/jsx-runtime";function _s(){let{settings:e,websiteName:t}=Or(),n=t?{...fn,name:t}:fn,r=e?{url:e.logoUrl,reversed:e.logoReversed??null,inkIsDark:e.logoInkIsDark??null,reverse:e.reverseLogo,size:e.logoSize,sizePx:e.logoSizePx,sizeUnit:e.logoSizeUnit??null}:null;return Jt("div",{style:{position:"fixed",inset:0,zIndex:2147482e3,overflowY:"auto",background:"var(--bg)",color:"var(--fg)"},children:Jt(Dr,{children:Jt(Ur,{preview:!0,children:Jt(Mn,{site:n,logo:r,preview:!0})})})})}export{_s as default};