efficient-storefront-blocks 0.134.2 → 0.134.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/chunks/{EditorPreviewCheckout-NAWXDKVA.js → EditorPreviewCheckout-PUHW43VL.js} +4 -4
- package/dist/chunks/{chunk-6RKYPO5H.js → chunk-JHEIFPET.js} +1 -1
- package/dist/chunks/{chunk-V7SYE7AE.js → chunk-VJSXEYRL.js} +1 -1
- package/dist/chunks/{fitment-data-RJ6DAYHD.js → fitment-data-OO37TN7S.js} +1 -1
- package/dist/index.js +2 -2
- package/dist/render/components/checkout/CheckoutPageClient.js +1 -1
- package/dist/render/components/checkout/checkout-state.d.ts +2 -0
- package/dist/render/lib/api/index.js +1 -1
- package/dist/render/lib/api/types.d.ts +1 -0
- package/dist/render/lib/checkout/wallet-return.d.ts +1 -1
- package/dist/routine-index.json +1 -1
- package/dist/value-index.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.134.4 — 2026-11-29 — Order received promises a set-password email only when one was sent
|
|
4
|
+
|
|
5
|
+
- The "Order received" screen says "We've emailed you a link to set a password and track it" only when the placed order says it sent that link (`accountLinkSent`). A returning guest, or a pay-first checkout whose payment has not made the order yet, reads "Already have an account? Sign in to see it under your orders." with a sign-in link that returns to their orders.
|
|
6
|
+
- `OrderConfirmation` gains the optional `accountLinkSent` the backend already sends.
|
|
7
|
+
|
|
8
|
+
## 0.134.3 — 2026-11-29 — Product and page reads send their slug as one encoded path segment
|
|
9
|
+
|
|
10
|
+
**For hosts:** no peer change. The storefront re-vendors `src/` with
|
|
11
|
+
`node scripts/sync-storefront-blocks.mjs`, then runs `just check`.
|
|
12
|
+
|
|
13
|
+
- **A crafted product or page address can no longer steer the backend read**
|
|
14
|
+
(SG#03631): `getWheel`, `getTyre`, `getBundle`, `getPage` and `getBlogPost`
|
|
15
|
+
now encode the slug, as `getRecord` and `getForm` already did. A slug holding
|
|
16
|
+
`?site=…`, `../` or `%2e%2e/` stays one segment under its own route instead
|
|
17
|
+
of naming another website or another backend path. A slug of letters, digits
|
|
18
|
+
and dashes requests the same URL as before.
|
|
19
|
+
|
|
3
20
|
## 0.134.2 — 2026-11-28 — The 360 view no longer flashes, and its turn hint stays while no one drags
|
|
4
21
|
|
|
5
22
|
**For hosts:** no peer change. The storefront re-vendors `src/` with
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use client";import{$a as ne,Aa as bn,Ia as Vr,W as Mt,X as Kt,b as Mr,c as hn,cb as Jr,d as Kr,db as Xr,e as Ft,ib as Zr,jb as pe,kb as Qr,la as Dr,lb as ea,ma as Ur,na as jr,oa as Wr,pa as Yr,qa as $r,qb as ta,ra as Br,rb as xt,sa as be,ua as vt,ub as vn,va as Hr,wa as zr,wb as ae,xa as Dt,ya as Gr}from"./chunk-
|
|
2
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ma(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function fa(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?ma(Object(n),!0).forEach(function(r){ha(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ma(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Fi(e,t){if(e==null)return{};var n,r,i=Mi(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)&&(i[n]=e[n])}return i}function Mi(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 ba(e,t){return Ti(e)||qi(e,t)||Ui(e,t)||_i()}function Ki(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 Di(e){var t=Ki(e,"string");return typeof t=="symbol"?t:t+""}function xn(e){"@babel/helpers - typeof";return xn=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},xn(e)}function Ui(e,t){if(e){if(typeof e=="string")return pa(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)?pa(e,t):void 0}}var Z=function(t,n,r){var i=!!r,s=T.useRef(r);T.useEffect(function(){s.current=r},[r]),T.useEffect(function(){if(!i||!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)}},[i,n,t,s])},kn=function(t){var n=T.useRef(t);return T.useEffect(function(){n.current=t},[t]),n.current},nt=function(t){return t!==null&&xn(t)==="object"},ji=function(t){return nt(t)&&typeof t.then=="function"},Wi=function(t){return nt(t)&&typeof t.elements=="function"&&typeof t.createToken=="function"&&typeof t.createPaymentMethod=="function"&&typeof t.confirmCardPayment=="function"},ya="[object Object]",Yi=function e(t,n){if(t===n)return!0;if(!nt(t)||!nt(n))return t===n;var r=Array.isArray(t),i=Array.isArray(n);if(r!==i)return!1;var s=Object.prototype.toString.call(t)===ya,d=Object.prototype.toString.call(n)===ya;if(s!==d)return!1;if(!s&&!r)return t===n;var p=Object.keys(t),m=Object.keys(n);if(p.length!==m.length)return!1;for(var f={},b=0;b<p.length;b+=1)f[p[b]]=!0;for(var g=0;g<m.length;g+=1)f[m[g]]=!0;var h=Object.keys(f);if(h.length!==p.length)return!1;var v=t,E=n,C=function(z){return e(v[z],E[z])};return h.every(C)},va=function(t,n,r){return nt(t)?Object.keys(t).reduce(function(i,s){var d=!nt(n)||!Yi(t[s],n[s]);return r.includes(s)?(d&&console.warn("Unsupported prop change: options.".concat(s," is not a mutable property.")),i):d?fa(fa({},i||{}),{},ha({},s,t[s])):i},null):null},xa="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.",ga=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:xa;if(t===null||Wi(t))return t;throw new Error(n)},$i=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:xa;if(ji(t))return{tag:"async",stripePromise:Promise.resolve(t).then(function(i){return ga(i,n)})};var r=ga(t,n);return r===null?{tag:"empty"}:{tag:"sync",stripe:r}},Bi=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"}))},Ut=T.createContext(null);Ut.displayName="ElementsContext";var ka=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},Pn=function(t){var n=t.stripe,r=t.options,i=t.children,s=T.useMemo(function(){return $i(n)},[n]),d=T.useState(function(){return{stripe:s.tag==="sync"?s.stripe:null,elements:s.tag==="sync"?s.stripe.elements(r):null}}),p=ba(d,2),m=p[0],f=p[1];T.useEffect(function(){var h=!0,v=function(C){f(function(O){return O.stripe?O:{stripe:C,elements:C.elements(r)}})};return s.tag==="async"&&!m.stripe?s.stripePromise.then(function(E){E&&h&&v(E)}):s.tag==="sync"&&!m.stripe&&v(s.stripe),function(){h=!1}},[s,m,r]);var b=kn(n);T.useEffect(function(){b!==null&&b!==n&&console.warn("Unsupported prop change on Elements: You cannot change the `stripe` prop after setting it.")},[b,n]);var g=kn(r);return T.useEffect(function(){if(m.elements){var h=va(r,g,["clientSecret","fonts"]);h&&m.elements.update(h)}},[r,g,m.elements]),T.useEffect(function(){Bi(m.stripe)},[m.stripe]),T.createElement(Ut.Provider,{value:m},i)};Pn.propTypes={stripe:D.default.any,options:D.default.object};var Ca=function(t){var n=T.useContext(Ut);return ka(n,t)},Pa=function(){var t=Ca("calls useElements()"),n=t.elements;return n},Hi=function(t){var n=t.children,r=Ca("mounts <ElementsConsumer>");return n(r)};Hi.propTypes={children:D.default.func.isRequired};var zi=T.createContext(null);zi.displayName="CheckoutContext";var Na=T.createContext(null);Na.displayName="CheckoutSdkContext";var Cn=function(t){var n=T.useContext(Na),r=T.useContext(Ut);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 ka(r,t)},Gi=["mode"],Vi=function(t){return t.charAt(0).toUpperCase()+t.slice(1)},U=function(t,n,r){var i="".concat(Vi(t),"Element"),s=function(f){var b=f.id,g=f.className,h=f.options,v=h===void 0?{}:h,E=f.onBlur,C=f.onFocus,O=f.onReady,z=f.onChange,R=f.onEscape,w=f.onClick,I=f.onLoadError,Q=f.onLoaderStart,ce=f.onNetworksChange,oe=f.onConfirm,ke=f.onCancel,Ne=f.onShippingAddressChange,$=f.onShippingRateChange,ye=f.onSavedPaymentMethodRemove,we=f.onSavedPaymentMethodUpdate,_e=f.onAvailablePaymentMethodsChange,V=Cn("mounts <".concat(i,">")),ee="elements"in V?V.elements:null,x="checkoutSdk"in V?V.checkoutSdk:null,J=T.useState(null),le=ba(J,2),W=le[0],Se=le[1],te=T.useRef(null),Ee=T.useRef(null);Z(W,"blur",E),Z(W,"focus",C),Z(W,"escape",R),Z(W,"click",w),Z(W,"loaderror",I),Z(W,"loaderstart",Q),Z(W,"networkschange",ce),Z(W,"confirm",oe),Z(W,"cancel",ke),Z(W,"shippingaddresschange",Ne),Z(W,"shippingratechange",$),Z(W,"savedpaymentmethodremove",ye),Z(W,"savedpaymentmethodupdate",we),Z(W,"availablepaymentmethodschange",_e),Z(W,"change",z);var Fe;O&&(t==="expressCheckout"?Fe=O:Fe=function(){O(W)}),Z(W,"ready",Fe),T.useLayoutEffect(function(){if(te.current===null&&Ee.current!==null&&(ee||x)){var q=null;if(x){var ie=x,Me=x;switch(t){case"paymentForm":q=Me.createForm(v);break;case"payment":q=ie.createPaymentElement(v);break;case"address":if("mode"in v){var ge=v.mode,Oe=Fi(v,Gi);if(ge==="shipping")q=ie.createShippingAddressElement(Oe);else if(ge==="billing")q=ie.createBillingAddressElement(Oe);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":q=ie.createExpressCheckoutElement(v);break;case"currencySelector":q=x.createCurrencySelectorElement();break;case"taxId":q=ie.createTaxIdElement(v);break;case"contactDetails":q=ie.createContactDetailsElement();break;case"linkSignup":if("createLinkSignupElement"in x)q=x.createLinkSignupElement(v);else throw new Error("<LinkSignupElement> requires <CheckoutElementsProvider> and is not supported inside <CheckoutFormProvider>.");break;case"terms":q=ie.createTermsElement(v);break;default:throw new Error("<".concat(i,"> is not supported inside a checkout provider. Use an <Elements> provider instead."))}}else ee&&(q=ee.create(t,v));te.current=q,Se(q),q&&q.mount(Ee.current)}},[ee,x,v]);var Re=kn(v);return T.useEffect(function(){if(te.current){var q=va(v,Re,["paymentRequest"]);q&&"update"in te.current&&te.current.update(q)}},[v,Re]),T.useLayoutEffect(function(){return function(){if(te.current&&typeof te.current.destroy=="function")try{te.current.destroy(),te.current=null}catch{}}},[]),T.createElement("div",{id:b,className:g,ref:Ee})},d=function(f){Cn("mounts <".concat(i,">"));var b=f.id,g=f.className;return T.createElement("div",{id:b,className:g})},p=n?d:s;return p.propTypes={id:D.default.string,className:D.default.string,onChange:D.default.func,onBlur:D.default.func,onFocus:D.default.func,onReady:D.default.func,onEscape:D.default.func,onClick:D.default.func,onLoadError:D.default.func,onLoaderStart:D.default.func,onNetworksChange:D.default.func,onConfirm:D.default.func,onCancel:D.default.func,onShippingAddressChange:D.default.func,onShippingRateChange:D.default.func,onSavedPaymentMethodRemove:D.default.func,onSavedPaymentMethodUpdate:D.default.func,onAvailablePaymentMethodsChange:D.default.func,options:D.default.object},p.displayName=i,p.__elementType=t,p},j=typeof window>"u",Ji=T.createContext(null);Ji.displayName="EmbeddedCheckoutProviderContext";var wa=function(){var t=Cn("calls useStripe()"),n=t.stripe;return n},mc=U("auBankAccount",j),fc=U("card",j),yc=U("cardNumber",j),gc=U("cardExpiry",j),hc=U("cardCvc",j),bc=U("currencySelector",j),vc=U("iban",j),Sa=U("payment",j),xc=U("expressCheckout",j),kc=U("paymentRequestButton",j),Cc=U("linkAuthentication",j),Pc=U("linkSignup",j),Nc=U("contactDetails",j),wc=U("address",j),Sc=U("shippingAddress",j),Ec=U("paymentMethodMessaging",j),Rc=U("taxId",j),Oc=U("issuingCardNumberDisplay",j),Ac=U("issuingCardCvcDisplay",j),Lc=U("issuingCardExpiryDisplay",j),Ic=U("issuingCardPinDisplay",j),Tc=U("issuingCardCopyButton",j),qc=U("terms",j);function Yt(e){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Yt=function(t){return typeof t}:Yt=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Yt(e)}var Oa="dahlia",Xi=function(t){return t===3?"v3":t},Aa="https://js.stripe.com",Zi="".concat(Aa,"/").concat(Oa,"/stripe.js"),Qi=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,es=/^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/,Ea="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used",ts=function(t){return Qi.test(t)||es.test(t)},ns=function(){for(var t=document.querySelectorAll('script[src^="'.concat(Aa,'"]')),n=0;n<t.length;n++){var r=t[n];if(ts(r.src))return r}return null},Ra=function(t){var n=t&&!t.advancedFraudSignals?"?advancedFraudSignals=false":"",r=document.createElement("script");r.src="".concat(Zi).concat(n);var i=document.head||document.body;if(!i)throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");return i.appendChild(r),r},rs=function(t,n){!t||!t._registerWrapper||t._registerWrapper({name:"stripe-js",version:"9.17.0",startTime:n})},kt=null,jt=null,Wt=null,as=function(t){return function(n){t(new Error("Failed to load Stripe.js",{cause:n}))}},os=function(t,n){return function(){window.Stripe?t(window.Stripe):n(new Error("Stripe.js not available"))}},is=function(t){return kt!==null?kt:(kt=new Promise(function(n,r){if(typeof window>"u"||typeof document>"u"){n(null);return}if(window.Stripe&&t&&console.warn(Ea),window.Stripe){n(window.Stripe);return}try{var i=ns();if(i&&t)console.warn(Ea);else if(!i)i=Ra(t);else if(i&&Wt!==null&&jt!==null){var s;i.removeEventListener("load",Wt),i.removeEventListener("error",jt),(s=i.parentNode)===null||s===void 0||s.removeChild(i),i=Ra(t)}Wt=os(n,r),jt=as(r),i.addEventListener("load",Wt),i.addEventListener("error",jt)}catch(d){r(d);return}}),kt.catch(function(n){return kt=null,Promise.reject(n)}))},ss=function(t,n,r){if(t===null)return null;var i=n[0];if(typeof i!="string")throw new Error("Expected publishable key to be of type string, got type ".concat(Yt(i)," instead."));var s=i.match(/^pk_test/),d=Xi(t.version),p=Oa;s&&d!==p&&console.warn("Stripe.js@".concat(d," was loaded on the page, but @stripe/stripe-js@").concat("9.17.0"," expected Stripe.js@").concat(p,". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));var m=t.apply(void 0,n);return rs(m,r),m},Ct,La=!1,Ia=function(){return Ct||(Ct=is(null).catch(function(t){return Ct=null,Promise.reject(t)}),Ct)};Promise.resolve().then(function(){return Ia()}).catch(function(e){La||console.warn(e)});var $t=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];La=!0;var i=Date.now();return Ia().then(function(s){return ss(s,n,i)})};var Bt=2;function Ta(e){return e==="card"}var cs="checkout_unavailable",ls="checkout_waiting",qa="committed",qe="We could not check your payment. Please try again.",Ht="Your last change was not saved. This is your order as placed.",_a="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.",Fa=1e4;async function Ma(e,t=Fa){let n,r=new Promise(s=>{n=setTimeout(()=>s(void 0),t)}),i=(async()=>{try{return(await(await $t(e.publishableKey))?.retrievePaymentIntent(e.clientSecret))?.paymentIntent?.status}catch{return}})();try{return await Promise.race([i,r])}finally{clearTimeout(n)}}var Ka=new Set(["none","requires_payment_method","canceled"]);async function Nn(e,t=Fa){let n,r=new Promise(i=>{n=setTimeout(()=>i(void 0),t)});try{return await Promise.race([K.releaseCheckout({idempotencyKey:e}).then(i=>i.status,()=>{}),r])}finally{clearTimeout(n)}}function Da(e,t){return e instanceof de&&typeof e.data=="object"&&e.data!==null&&e.data.code===t}function zt(e){return Da(e,cs)}function wn(e){return Da(e,ls)}function Sn(e){return e instanceof de&&e.status>=400&&e.status<500&&e.status!==408}function Ua(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 Gt(e){return e.orderNumber||e.checkoutNumber}function us(e){return e.orderNumber?{kind:"placed",order:e}:{kind:e.status==="released"?"refunded":e.status==="expired"?"expired":"pending",checkoutNumber:e.checkoutNumber}}async function ja({checkoutNumber:e,resend:t,page:n}){n.setConfirming(!0);let r;try{r=us(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 Es,useContext as Rs,useEffect as H,useMemo as yo,useRef as B,useState as N}from"react";var ds="sf:gclid",ps="sf:fbclid",ms=2160*60*60*1e3;function $a(){return typeof window<"u"}function Wa(e){let t=bt.getItem(e);if(!t)return"";try{let{v:n,t:r}=JSON.parse(t);return!n||typeof r!="number"||Date.now()-r>ms?"":n}catch{return""}}function Ya(e){if(!$a())return"";let t=e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1"),n=document.cookie.match(new RegExp(`(?:^|; )${t}=([^;]*)`));return n?decodeURIComponent(n[1]):""}function Ba(){if(!$a())return{};let e=Wa(ds),t=Wa(ps),n=Ya("_fbp"),r=Ya("_fbc");!r&&t&&(r=`fb.1.${Date.now()}.${t}`);let i={};return e&&(i.gclid=e),t&&(i.fbclid=t),n&&(i.fbp=n),r&&(i.fbc=r),i}var Ha="sf:meta-purchases",fs=20;function Ga(){return typeof window>"u"||window.parent!==window}function ys(...e){try{if(Ga()||typeof window.fbq!="function")return;window.fbq(...e)}catch{}}var za=new Set;function gs(e){if(za.has(e))return!1;za.add(e);try{let t=JSON.parse(bt.getItem(Ha)??"[]");if(t.includes(e))return!1;bt.setItem(Ha,JSON.stringify([...t,e].slice(-fs)))}catch{}return!0}function hs(e){return[...new Set(e.filter(vt).flatMap(t=>t.components.map(n=>n.partNumber)))]}function Va(e){let t=e.confirmation;Ga()||!gs(t.orderNumber)||ys("track","Purchase",{value:Number(t.grandTotal),currency:t.currency,content_type:"product",content_ids:hs(e.lines)},{eventID:t.orderNumber})}var En="checkout-afterpay-context",Rn="checkout-gocardless-context",On="checkout-zip-context",An="checkout-klarna-context",Ln="checkout-worldpay-context";function bs(e){return e?.lostChange===!0}function vs({evidence:e,parked:t}){return e?{action:"capture",evidence:e,parked:t}:t?{action:"settle",parked:t}:{action:"ignore"}}function xs(e,t){let n=e.getItem(t);if(e.removeItem(t),!n)return null;try{return JSON.parse(n)}catch{return null}}function ks(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 Ja={name:"Afterpay",legParam:"afterpay",legValues:["confirm","cancel"],storageKey:En,evidenceFrom(e,t){return t==="cancel"||(e.get("status")??"").toUpperCase()==="CANCELLED"?null:e.get("orderToken")},requestFrom:e=>({token:e})},Xa={name:"Zip",legParam:"zip",legValues:["return"],storageKey:On,evidenceFrom(e){let t=(e.get("result")??"").toLowerCase();return t==="cancelled"||t==="declined"?null:e.get("checkoutId")},requestFrom:e=>({checkoutId:e})},Za={name:"Worldpay",legParam:"worldpay",legValues:["return","cancel"],storageKey:Ln,evidenceFrom:(e,t)=>t==="cancel"?null:e.get("worldpayRef"),requestFrom:e=>({transactionReference:e}),words:{declined:"Worldpay did not take the payment \u2014 our team will follow up on payment.",collecting:"We're confirming your payment with Worldpay \u2014 we'll email you once it's through."}},Qa={name:"GoCardless",legParam:"gocardless",legValues:["confirm","cancel"],storageKey:Rn,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."}},eo={name:"Klarna",legParam:"klarna",legValues:["confirm","cancel"],storageKey:An,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 rt(e,t){let n=new URLSearchParams(t.search),r=n.get(e.legParam);if(!r||!e.legValues.includes(r))return;let i=xs(t.storage,e.storageKey),s=e.evidenceFrom(n,r);t.scrubQuery();let d=vs({evidence:s,parked:i});if(d.action==="ignore"||e.keyedByParked&&!d.parked)return;let p=ks(e);if(t.page.clearCart(),bs(d.parked)&&t.page.lostChange(),d.action==="settle"){t.page.note(p.settled,!0),t.page.land(d.parked.confirmation);return}t.page.setConfirming(!0);try{let m=await t.capture(e.requestFrom(d.evidence,d.parked));m.status==="paid"?t.page.markPaid():m.status==="collecting"?t.page.note(p.collecting,!e.words?.collecting):t.page.note(p.declined,!0),t.page.land(d.parked?.confirmation??m)}catch{d.parked?(t.page.note(p.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 to(e,t,n){let r=(t??"").trim();if(!r)return"";if(n.length===0)return r;let i=r.toUpperCase(),s=`${e.toUpperCase()}-${i}`,d=n.find(p=>p.code&&p.code.toUpperCase()===i)??n.find(p=>p.code&&p.code.toUpperCase()===s)??n.find(p=>p.name.toUpperCase()===i);return d?d.code||d.name:""}var Tn="checkout-memory-context",ao="Prices have changed since this checkout started. The total shows today's prices.",oo="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.",io=3,Cs=3600*1e3;function Ps(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 Vt=e=>e.map(Ps);function so(e,t){let n=r=>JSON.stringify(r.map(i=>[i.id,i.qty]).sort(([i],[s])=>i<s?-1:i>s?1:0));return n(e)===n(t)}function co(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=>Ft([{partNumber:n.partNumber,wheels:n.quantity,prices:{}}],1)),currency:e.currency,idempotencyKey:e.idempotencyKey,shippingMethodId:e.shippingMethodId,couponCode:e.couponCode}}function qn(e){return{...co(e),payFirst:!!e.checkoutFlow}}function lo(e){return co(e)}var Ns={lastPress:null,keptCardKey:null,placedShape:null,placedRequest:null,unpaidOrder:null};function _n(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 Fn(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 Mn(e){return e.lastPress!==null||e.unpaidOrder!==null||e.keptCardKey!==null}function ws(e){let t=e.parkedAt+Cs,n=e.press.unpaidOrder,r=n&&!n.orderNumber?n.expiresAt:null,i=r?Date.parse(r):NaN;return Number.isNaN(i)?t:Math.min(t,i)}function uo(e){try{let t={...e,lines:Vt(e.lines),press:mo(e.press)};Te.setItem(Tn,JSON.stringify({v:io,...t}))}catch{}}var $e=e=>!!e&&typeof e=="object"&&!Array.isArray(e),po=e=>$e(e)&&typeof e.idempotencyKey=="string"&&Array.isArray(e.items)&&e.items.every(t=>$e(t)&&typeof t.partNumber=="string"&&typeof t.quantity=="number")&&$e(e.customer)&&typeof e.payFirst=="boolean",In=e=>$e(e)&&typeof e.id=="string"&&typeof e.qty=="number"&&Array.isArray(e.components);function Ss(e){return $e(e)&&typeof e.key=="string"&&po(e.request)&&Array.isArray(e.lines)&&e.lines.every(In)&&Array.isArray(e.plainLines)&&e.plainLines.every(In)?{key:e.key,request:e.request,lines:Vt(e.lines),goods:typeof e.goods=="string"?e.goods:"",plainPressed:e.plainPressed===!0,plainLines:Vt(e.plainLines),plainGoods:typeof e.plainGoods=="string"?e.plainGoods:""}:null}var no=e=>typeof e=="string"?e:null,ro={lastPress:Ss,keptCardKey:no,placedShape:no,placedRequest:e=>po(e)?e:null,unpaidOrder:e=>$e(e)?Fn(e):null};function mo(e){let t=$e(e)?e:{},n={...Ns};for(let r of Object.keys(ro))n[r]=ro[r](t[r]);return n}function fo(){let e;try{e=Te.getItem(Tn)}catch{return null}if(!e)return null;try{let t=JSON.parse(e);if(t.v!==io||typeof t.key!="string"||!t.key||!Array.isArray(t.lines)||!t.lines.every(In)||typeof t.parkedAt!="number")return null;let n={key:t.key,authed:t.authed===!0,parkedAt:t.parkedAt,press:mo(t.press),lines:Vt(t.lines),form:t.form&&typeof t.form=="object"?_n(t.form):null};return Date.now()>=ws(n)?(Kn(),null):Mn(n.press)?n:null}catch{return null}}function Kn(){try{Te.removeItem(Tn)}catch{}}import{jsx as ve}from"react/jsx-runtime";function go(e){let t=e.indexOf(`
|
|
3
|
-
`);return t===-1?[e,""]:[e.slice(0,t),e.slice(t+1)]}function ho(e,{canParkContext:t}={canParkContext:!0}){let n=e.paymentMethods,r=[];return n.includes("card")&&r.push({key:"card",title:"Card",body:null,price:ve("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:ve("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:ve("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:ve("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:ve("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:ve("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:ve("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY LATER"})}),n.includes("worldpay")&&r.push({key:"worldpay",title:"Visa / Mastercard / American Express",body:null,price:ve("span",{className:"font-mono text-xs uppercase tracking-[0.2em] text-accent",children:"VIA WORLDPAY"})}),n.includes("bank")&&r.push({key:"bank",title:"Bank transfer",body:null,price:ve("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Invoiced"})}),r}var Co="This shop does not take payment online yet. Please contact the shop to order.",at=class extends Error{};function bo(e,t){if(!e.orderNumber&&zt(t))return t.message;let n=t instanceof de?` (${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 Os=3e3,As=.005,vo=new Set(["paypal","square","afterpay","gocardless","zip","klarna","worldpay"]);function xo(){let e=ta();return{...e==="denied"?{}:Ba(),...e?{adConsent:e}:{}}}var xe=e=>JSON.parse(e),Ls={lastPress:null,keptCardKey:null,placedShape:null,placedRequest:null,unpaidOrder:null},Is={lastPress:e=>e&&{key:e.key,request:qn(e.request),lines:e.lines,goods:xe(e.shape)[0],plainPressed:!!e.plainMethod,plainLines:e.plainLines,plainGoods:xe(e.plainShape)[0]},keptCardKey:e=>e,placedShape:e=>e===null?null:xe(e)[0],placedRequest:e=>e&&qn(e.body),unpaidOrder:e=>e&&Fn(e)};function ko(e,t){let n={};for(let r of Object.keys(e))n[r]=e[r](t[r]);return n}var Po="Shipping cannot be calculated right now. Please try again.";function No(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 Ts({site:e,logo:t,signInHref:n=null,preview:r=!1,textCase:i}){let{items:s,basketRead:d,totals:p,coupon:m,refuseCoupon:f,deliveryOptions:
|
|
4
|
-
${ie.trim()}`:Re,gi=Ua({email:x,firstName:le,lastName:Se,company:Ee.trim(),phone:ze,address:At,city:ge,subdivision:Ce,postcode:Ae,country:Y,lines:s.map(a=>[a.id,a.qty]),shippingMethodId:g,couponCode:hn(m),currency:p.currency,shopperId:dt?.id??null}),re=JSON.stringify([gi,$]),ln=B(null),Lt=B(!1),Ie=B(!1),Ze=B(null),It=B(!1),he=B(re);he.current=re;let cr=B(V);cr.current=V;let Tt=B(null);H(()=>{let a=()=>{let c=Tt.current;c&&(Tt.current=null,ue(c),ee(!1))};return window.addEventListener("pageshow",a),()=>window.removeEventListener("pageshow",a)},[]);function mt(a,c,y,S){let u={idempotencyKey:c,confirmation:y};xr()&&(u.lostChange=!0),Te.setItem(a,JSON.stringify(u)),window.location.assign(S),Tt.current=y}async function lr(a){ee(!0);try{await a()}finally{Tt.current||ee(!1)}}let ur=B(!1),dr=!!(on||pt&&pt.kind!=="processing");H(()=>{dr&&(ur.current=!0,yt())},[dr]);let qt=B(null),ft=B(!1),un=B(null);function yt(){un.current=null,Kn()}let _t=B(null),[Qe,hi]=N(!1);function dn(a){if(ur.current||r||ft.current)return;let c={key:a,authed:cn.current,parkedAt:un.current??=Date.now(),press:ko(Is,A.current),lines:s.length>0?s:De.current,form:_n({email:x,firstName:le,lastName:Se,company:Ee,address1:Re,address2:ie,city:ge,postcode:Ae,phone:ze,country:Y,subdivision:Ce,selectedAddressId:nn,shippingMethodId:g,couponCode:m?.valid?m.code:null})};Mn(c.press)?uo(c):yt()}let pr=B($);pr.current=$;function pn(a){return{...lo(a),...xo(),...a.payFirst?{checkoutFlow:Bt}:{}}}function bi(a,c){let y=a.request.payFirst?"":null,S=a.plainPressed?null:"",u=()=>pr.current??"";return{key:a.key,send:()=>c(pn(a.request)),request:pn(a.request),lines:a.lines,shape:JSON.stringify([a.goods,null]),get method(){return y??u()},set method(L){y=L},get plainMethod(){return S??u()},set plainMethod(L){S=L},plainLines:a.plainLines,plainShape:JSON.stringify([a.plainGoods,null])}}let[vi,xi]=N(!1),mr=vi?!p.quoted||p.serverSubtotal===null?"waiting":Math.abs(p.serverSubtotal-p.subtotal)<As?"same":"changed":null,mn=!X&&mr==="waiting",ki=mn?{...p,repricing:!0}:p,fn=mn&&p.quoteFailed;H(()=>{if(!fn)return;let a=setInterval(C,Os);return()=>clearInterval(a)},[fn,C]);let Ci=C;function fr(a,c=!0){J(a.email),W(a.firstName),te(a.lastName),Fe(a.company),q(a.address1),Me(a.address2),Oe(a.city),st(a.postcode),ct(a.phone),a.country&<(a.country),Ge({country:a.country||null,state:a.subdivision}),wt(a.selectedAddressId),a.shippingMethodId&&h(a.shippingMethodId),c&&(qt.current=a.couponCode)}H(()=>{let a=r?null:fo(),c=!!(a&&s.length>0);if(a&&c&&!so(a.lines,s)&&(yt(),a=null),a){let y=a.authed?K.createOrderAuthed:K.createOrder;St(a.key),un.current=a.parkedAt,cn.current=a.authed;let S={lastPress:u=>u&&bi(u,y),keptCardKey:u=>u,placedShape:u=>u===null?null:JSON.stringify([u,null]),placedRequest:u=>{if(!u)return null;let L=pn(u);return{body:L,send:()=>y(L)}},unpaidOrder:u=>u};A.current=ko(S,a.press),a.press.unpaidOrder&&ue(a.press.unpaidOrder),a.lines.length>0&&!c&&(R(a.lines),De.current=a.lines,xi(!0)),a.form&&(_t.current=a.form,fr(a.form))}hi(!0)},[]),H(()=>{!Qe||s.length>0||A.current.unpaidOrder||V||(ft.current=!0,yt())},[Qe,s.length]),H(()=>{let a=qt.current;!Qe||!a||s.length===0||(qt.current=null,I(a,x||void 0))},[Qe,s.length]),H(()=>{!Qe||V||dn(Ke)},[Qe,V,Ke,X]);let Ue=B(null);H(()=>{cr.current||(re!==Ue.current&&(Ue.current=null),!(!Ie.current||!X||X.orderNumber)&&(re===A.current.placedShape||re===Ue.current||lr(()=>yr(X))))},[re,X]);async function yr(a){if(It.current)return null;It.current=!0;try{let c=Ze.current?await Ma(Ze.current):"none";if(c==="succeeded"||c==="processing")return Ie.current=!1,ue(null),Pe("card"),c==="succeeded"?await je(void 0,a):wr(a),null;if(c===void 0||!Ka.has(c))return Ue.current=he.current,ue(a),se(c==="requires_action"?_a:qe),null;let y=await Nn(Ke);if(y==="committed")return Ie.current=!1,ue(null),Pe("card"),await je(void 0,a),null;if(y!=="released")return Ue.current=he.current,ue(a),se(qe),null;Ie.current=!1,Ze.current=null,Ue.current=null,se(null),ue(null);let S=xt();return St(S),S}finally{It.current=!1}}async function Pi(){r||V||It.current||await lr(Ni)}async function Ni(){if(X){if((Ie.current?re!==A.current.placedShape:gt())&&!X.orderNumber){let S=await yr(X);S&&he.current===re&&await gr(S);return}se(null),Lt.current=!1,await yn();let c=xe(he.current)[1],y=X.orderNumber?c:"card";if(y&&vo.has(y)&>()&&xe(he.current)[0]!==ln.current){hr(X);return}Pe(y),y!==$&&ye(y),await Sr(X,y,!X.orderNumber);return}await gr(Ke)}async function gr(a){if(s.length===0||p.repricing||mn||!$||!Xe.some(F=>F.key===$))return;let c=s.filter(vt).flatMap(F=>Ft(F.components,F.qty));if(c.length===0){se("Pick a size on each wheel's product page before checking out.");return}se(null);let y,S=a,u=$,L=!1;try{let F=dt?K.createOrderAuthed:K.createOrder,_={customer:{email:x,name:`${le} ${Se}`.trim(),phone:ze.trim()||void 0,companyName:Ee.trim()||void 0,address:At,city:ge,state:Ce||void 0,zipCode:Ae,country:Y},items:c,currency:p.currency,idempotencyKey:a,shippingMethodId:g??void 0,couponCode:hn(m),...xo(),...Ta($)?{checkoutFlow:Bt}:{}};A.current.placedRequest={body:_,send:()=>F(_)},cn.current=!!dt,ft.current=!1,an(null),ln.current=null,Lt.current=!1,Ze.current=null,Ie.current=!1,Ue.current=null,A.current.placedShape=re,De.current=s;let M=A.current.lastPress,et=M?.key===_.idempotencyKey&&(M.shape!==re&&(!!_.checkoutFlow||!!M.method||!!M.plainMethod)||!!_.checkoutFlow&&!!M.plainMethod);et&&(A.current.keptCardKey=_.idempotencyKey);let Or=Cr(_,F),Ar=et||!_.checkoutFlow&&A.current.keptCardKey===_.idempotencyKey,Lr=!Or&&!Ar&&!_.checkoutFlow&&!!M&&!M.method;Lr&&(M.plainMethod=$,M.plainLines=s,M.plainShape=re,dn(_.idempotencyKey));let We=await(Ar?vr(_,F):F(_).then(ht=>({answer:ht,request:_})).catch(ht=>(Or?br(ht,_.idempotencyKey):Lr&&Sn(ht)&&(M.plainMethod=""),wi(ht,_,F))));if(!We)return;y=We.answer,S=We.request.idempotencyKey,u=We.method??u,Pe(u),L=gt()||u!==xe(he.current)[1],We.method&&We.method!==$&&ye(We.method),y.orderNumber&&(Pr(y),z()),await yn()}catch(F){let _=Kr(F);_?(f(_),se(`${_} Your order has not been placed. Place it again to continue without the code.`)):F instanceof at?se(qe):se(F instanceof de?F.message:"Could not place the order. Please try again.");return}if(u&&vo.has(u)&&(L||gt())){hr(y);return}await Sr(y,u,!1,S)}function hr(a){ln.current=xe(he.current)[0],se(`${bo(a,null)} ${Ht}`),ue(a)}function br(a,c){Sn(a)&&!wn(a)&&A.current.lastPress?.key===c&&(A.current.lastPress=null)}async function wi(a,c,y){if(zt(a))return kr(c,y);if(!wn(a))throw a;return A.current.keptCardKey=c.idempotencyKey,vr(c,y,!0)}async function vr(a,c,y=!1){let S=await Nn(a.idempotencyKey);if(S==="released")return kr(a,c);if(S!=="committed")throw new at;let u=A.current.lastPress?.key===a.idempotencyKey?A.current.lastPress:null;if(De.current=u?.lines??s,u?.method&&!y){A.current.keptCardKey=null,A.current.placedRequest={body:u.request,send:u.send};let et=await u.send().catch(()=>{throw new at});return A.current.placedShape=u.shape,{answer:et,request:a,method:u.method}}let L={...a,checkoutFlow:Bt},F=u&&!u.method?{body:u.request,send:u.send}:{body:L,send:()=>c(L)};A.current.placedRequest=F;let _=F.send,M=await _().catch(()=>null);if(!M&&u?.plainMethod)throw new at;return M?.orderNumber&&M.status!==qa?(A.current.keptCardKey=null,u?.plainMethod&&(De.current=u.plainLines),u&&(A.current.placedShape=u.plainMethod?u.plainShape:u.shape),{answer:M,request:a,method:u?.plainMethod||void 0}):(u&&(A.current.placedShape=u.shape),Pe("card"),await Nr("",M?async()=>M:()=>Promise.reject(new Error("The order request did not answer."))),await yn(),null)}function gt(){let a=A.current.placedShape;return a!==null&&xe(a)[0]!==xe(he.current)[0]}function Pe(a){a!==xe(he.current)[1]&&(Lt.current=!0),an(xr()?Ht:null)}function xr(){return Lt.current||gt()}async function kr(a,c){let y={...a,idempotencyKey:xt()};A.current.keptCardKey=null,St(y.idempotencyKey),A.current.placedRequest={body:y,send:()=>c(y)},Cr(y,c);try{return{answer:await c(y),request:y}}catch(S){throw br(S,y.idempotencyKey),S}}function Cr(a,c){return A.current.lastPress?.key===a.idempotencyKey?!1:(A.current.lastPress={key:a.idempotencyKey,send:()=>c(a),request:a,lines:s,shape:re,method:a.checkoutFlow?"":$??"",plainMethod:"",plainLines:s,plainShape:re},ft.current=!1,dn(a.idempotencyKey),!0)}function Pr(a){Ur({confirmation:a,lines:De.current,adsSendTo:e.googleAdsId&&e.googleAdsConversionLabel?`${e.googleAdsId}/${e.googleAdsConversionLabel}`:null}),Va({confirmation:a,lines:De.current})}async function je(a,c=Le){if(!c)return;let y=a?async()=>a:A.current.placedRequest?.send;if(c.orderNumber||!y){Rt(!0),Ve(c);return}await Nr(c.checkoutNumber,y)}async function Nr(a,c){z(),await ja({checkoutNumber:a,resend:c,page:{setConfirming:di,land:Ve,markPaid:()=>Rt(!0),track:Pr,unplaced:rr}})}function wr(a=Le){if(a){if(a.orderNumber){Ve(a);return}z(),rr({kind:"processing",checkoutNumber:a.checkoutNumber})}}async function yn(){let a=JSON.stringify([rn.trim(),le,Se,ze.trim(),At,ge,Ce,Ae,Y]);if(!(!dt||!Gn||nn!=="new"||Xn.current===a))try{await tt.createAddress({label:rn.trim()||"Home",contact_name:`${le} ${Se}`.trim(),phone:ze.trim(),address:At,city:ge,zip_code:Ae,state:Ce,country:Y}),Xn.current=a,Jn("Address saved to your account.")}catch{Jn("We couldn't save the address to your account \u2014 you can add it under Account \u2192 Addresses.")}}async function Sr(a,c=$,y=!1,S=Ke){ue(null);try{if(c==="card"&&e.paymentMethods.includes("card")){let u=await K.createPaymentIntent({idempotencyKey:S});Ze.current=u;let L=a;if(y){let F=await A.current.placedRequest?.send().catch(()=>null);if(F?.orderNumber){Pe("card"),await je(F,a);return}L=Er(a,F)??{...a,expiresAt:null}}Pe("card"),Je(L),sn(!1),Et(u)}else if(c==="paypal"&&e.paymentMethods.includes("paypal"))Je(a),Vo(!0);else if(c==="afterpay"&&e.paymentMethods.includes("afterpay")){let u=window.location.origin,L=await K.createAfterpayCheckout({idempotencyKey:S,confirmUrl:`${u}/checkout?afterpay=confirm`,cancelUrl:`${u}/checkout?afterpay=cancel`});mt(En,S,a,L.redirectCheckoutUrl);return}else if(c==="square"&&e.paymentMethods.includes("square"))Je(a),Jo(!0);else if(c==="gocardless"&&e.paymentMethods.includes("gocardless")){let u=window.location.origin,L=await K.createGocardlessBillingRequest({idempotencyKey:S,confirmUrl:`${u}/checkout?gocardless=confirm`,cancelUrl:`${u}/checkout?gocardless=cancel`});mt(Rn,S,a,L.authorisationUrl);return}else if(c==="zip"&&e.paymentMethods.includes("zip")){let u=window.location.origin,L=await K.createZipCheckout({idempotencyKey:S,redirectUrl:`${u}/checkout?zip=return`});mt(On,S,a,L.redirectUrl);return}else if(c==="klarna"&&e.paymentMethods.includes("klarna")){let u=window.location.origin,L=await K.createKlarnaCheckout({idempotencyKey:S,confirmUrl:`${u}/checkout?klarna=confirm`,cancelUrl:`${u}/checkout?klarna=cancel`});mt(An,S,a,L.redirectUrl);return}else if(c==="worldpay"&&e.paymentMethods.includes("worldpay")){let u=window.location.origin,L=await K.createWorldpayCheckout({idempotencyKey:S,successUrl:`${u}/checkout?worldpay=return`,cancelUrl:`${u}/checkout?worldpay=cancel`});mt(Ln,S,a,L.redirectUrl);return}else Pe(c),Ve(a)}catch(u){if((y||c==="card")&&u instanceof de&&u.status===409){Pe(c),await je(void 0,a);return}Rr(a,u)}}function Er(a,c){return c&&!c.orderNumber&&c.status==="open"&&c.checkoutNumber===a.checkoutNumber?c:null}function Rr(a,c){se(bo(a,c)),!a.orderNumber&&zt(c)?(Ie.current=!1,St(xt())):ue(a)}async function Si(a){if(!Le)return;let c=Le;try{let y=await K.createPaymentIntent({idempotencyKey:Ke}),S=await A.current.placedRequest?.send().catch(()=>null);if(S?.orderNumber){await je(S);return}let u=Er(c,S);Je(u??{...c,expiresAt:null}),sn(a&&u!==null),Ze.current=y,Et(y)}catch(y){if(y instanceof de&&y.status===409){await je();return}Et(null),Je(null),Rr(c,y)}}function Ei(){Le&&(Ie.current=!0,ue(Le),Et(null),Je(null),sn(!1))}return{site:e,logo:t,signInHref:n,capitalised:Vr(i)==="capitalised",items:s,totals:ki,coupon:m,deliveryOptions:b,courierUnavailable:Wo,retryCourier:Yo,shippingMethodId:g,setShippingMethodId:h,pickupLocation:Q,servedCountries:oe,formatMoney:Ne,payChoice:$,setPayChoice:ye,placing:V,email:x,setEmail:J,firstName:le,setFirstName:W,lastName:Se,setLastName:te,company:Ee,setCompany:Fe,address1:Re,setAddress1:q,address2:ie,setAddress2:Me,city:ge,setCity:Oe,postcode:Ae,setPostcode:st,phone:ze,setPhone:ct,country:Y,setCountry:lt,subdivision:Ce,setSubdivision:Pt,subdivisions:ut,destination:$n,postcodeLabel:Uo,subdivisionLabel:jo,me:dt,savedAddresses:$o,selectedAddressId:nn,setSelectedAddressId:wt,saveAddress:Gn,setSaveAddress:Vn,saveLabel:rn,setSaveLabel:Bo,addressSaveNote:Ho,lostChangeNote:zo,idemKey:Ke,confirmation:on,setConfirmation:Ve,orderError:Go,payment:Zn,paypalStep:Qn,squareStep:er,pendingConf:Le,paid:Xo,setPaid:Rt,unpaidOrder:X,orderLocked:tr,formLocked:Zo,restoredPrices:mr,basketRead:d,quoteFailed:fn,retryQuote:Ci,payNote:Qo,afterpayConfirming:ti,gocardlessConfirming:ri,zipConfirming:oi,klarnaConfirming:si,worldpayConfirming:li,cardConfirming:nr,checkoutResult:pt,confirmCardPayment:je,cardStillProcessing:wr,renewCardPayment:Si,holdRenewed:pi,leaveCardPayment:Ei,checkoutRootRef:ir,setCheckoutHeaderEl:mi,fillFromAddress:sr,checkoutSignOut:fi,payOptions:Xe,noPaymentMethod:yi,placeOrder:Pi}}var wo=Es(null);function So({children:e,...t}){let n=Ts(t);return ve(wo.Provider,{value:n,children:e})}function me(){let e=Rs(wo);if(!e)throw new Error("useCheckout must be used inside CheckoutStateProvider");return e}import{useId as Dn}from"react";import{Fragment as fe,jsx as o,jsxs as P}from"react/jsx-runtime";var qs="Loading your order",Eo=["py-8","text-center","font-serif","text-[16px]","italic","leading-[1.5]","text-fg-dim"].join(" ");function Ao(){let{email:e,setEmail:t,firstName:n,setFirstName:r,lastName:i,setLastName:s,company:d,setCompany:p,me:m,signInHref:f,checkoutSignOut:b,orderLocked:g,unpaidOrder:h}=me(),v=Dn();return P(Zt,{num:1,title:"Contact",children:[g&&h&&o(Fs,{orderNumber:h.orderNumber}),o(ae,{label:"Email",htmlFor:v,hint:m?P(fe,{children:["Signed in \xB7"," ",o("button",{type:"button",onClick:b,className:"underline transition-colors enabled:hover:text-accent",children:"Not you? Sign out"})]}):f?P(fe,{children:["Have an account?"," ",o(ot,{href:f,className:"underline transition-colors hover:text-accent",children:"Sign in"})]}):void 0,children:o("input",{id:v,type:"email",value:e,onChange:E=>t(E.target.value),placeholder:"you@example.com",readOnly:m!==null,className:ne})}),P(_o,{children:[o(ae,{label:"First name",children:o("input",{type:"text",value:n,onChange:E=>r(E.target.value),className:ne})}),o(ae,{label:"Last name",children:o("input",{type:"text",value:i,onChange:E=>s(E.target.value),className:ne})})]}),o(ae,{label:"Company (optional)",children:o("input",{type:"text",value:d,onChange:E=>p(E.target.value),autoComplete:"organization",className:ne})})]})}function Lo(){let{pickupLocation:e,servedCountries:t,address1:n,setAddress1:r,address2:i,setAddress2:s,city:d,setCity:p,postcode:m,setPostcode:f,phone:b,setPhone:g,country:h,setCountry:v,subdivision:E,setSubdivision:C,subdivisions:O,destination:z,postcodeLabel:R,subdivisionLabel:w,me:I,savedAddresses:Q,selectedAddressId:ce,setSelectedAddressId:oe,saveAddress:ke,setSaveAddress:Ne,saveLabel:$,setSaveLabel:ye,fillFromAddress:we,orderLocked:_e}=me(),V=Dn(),ee=Dn();return P(Zt,{num:2,title:e?"Collection":"Shipping address",children:[e?P("div",{className:"grid gap-2 text-[14px] leading-[1.6]",children:[o("span",{className:"font-medium",children:e.name}),[e.address,e.city,e.state,e.zipCode,e.country].filter(Boolean).length>0&&o("span",{className:"opacity-80",children:[e.address,e.city,e.state,e.zipCode,e.country].filter(Boolean).join(", ")}),e.openingHours&&o("span",{className:"opacity-80",children:e.openingHours}),e.readyIn&&o("span",{className:"opacity-80",children:e.readyIn}),e.instructions&&o("span",{className:"opacity-80",children:e.instructions}),o("span",{className:"mt-1 font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"No delivery address needed"})]}):P(fe,{children:[I!==null&&Q.length>0&&P("div",{className:"grid gap-3",children:[Q.map(x=>o(Jt,{active:ce===x.id,onClick:()=>{oe(x.id),we(x)},title:x.label,body:x.formatted_address,price:null},x.id)),o(Jt,{active:ce==="new",onClick:()=>oe("new"),title:"New address",body:null,price:null})]}),o(ae,{label:"Address line 1",children:o("input",{type:"text",value:n,onChange:x=>r(x.target.value),className:ne})}),o(ae,{label:"Address line 2",children:o("input",{type:"text",value:i,onChange:x=>s(x.target.value),placeholder:"Apartment, unit, garage bay\u2026",className:ne})}),P(_o,{cols:"three",children:[o(ae,{label:"City",children:o("input",{type:"text",value:d,onChange:x=>p(x.target.value),className:ne})}),o(ae,{label:R,children:o("input",{type:"text",value:m,onChange:x=>f(x.target.value),className:ne})}),o(ae,{label:"Country",separate:!0,htmlFor:V,children:o(vn,{id:V,value:h,onChange:x=>v(x.target.value),className:ne+" pr-10",style:Ro,children:t.map(x=>o("option",{value:x.code,children:x.name},x.code))})})]}),o(ae,{label:w,separate:!0,htmlFor:ee,children:O.length>0?P(vn,{id:ee,value:E,onChange:x=>C(x.target.value),className:ne+" pr-10",style:Ro,children:[o("option",{value:"",children:"Select\u2026"}),O.map(x=>o("option",{value:x.code||x.name,children:x.name},x.code||x.name))]}):o("input",{id:ee,type:"text",value:E,onChange:x=>C(x.target.value),className:ne})})]}),o(ae,{label:"Phone",children:o("input",{type:"tel",value:b,onChange:x=>g(x.target.value),className:ne})}),!e&&I!==null&&ce==="new"&&!_e&&P(fe,{children:[o(Ms,{checked:ke,onChange:Ne,label:"Save this address to my account"}),ke&&o(ae,{label:"Address label",children:o("input",{type:"text",value:$,onChange:x=>ye(x.target.value),placeholder:"Home",className:ne})})]})]})}function Io(){let{totals:e,coupon:t,deliveryOptions:n,shippingMethodId:r,setShippingMethodId:i,pickupLocation:s,formatMoney:d,city:p,destination:m,courierUnavailable:f,retryCourier:b}=me();return o(Zt,{num:3,title:"Shipping",children:P("div",{className:"grid gap-3",children:[n.map(g=>{let h=g.pickupLocation,v=h?[h.address,h.city,h.state,h.zipCode].filter(Boolean).join(", "):null;return o(Jt,{active:r===g.id,onClick:()=>i(g.id),title:h?`${g.name} \u2014 ${h.name}`:g.name,body:h?[v,h.openingHours,h.readyIn,h.instructions,g.description].filter(Boolean).join(" \xB7 "):g.description||null,price:e.freeShipping||g.amount===0?Mt:e.deliveryDiscountPercent>0?P(fe,{children:[o("s",{className:"text-fg-dim",children:d(g.amount,e.currency)})," ",d(Wr(g.amount,e.deliveryDiscountPercent),e.currency)]}):d(g.amount,e.currency),tag:g.tag||void 0},g.id)}),f?P("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:[Po," ",o("button",{type:"button",onClick:b,className:"underline transition-colors enabled:hover:text-accent",children:"Try again"})]}):n.length===0&&o("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Shipping is arranged after your order is reviewed."})]})})}function To(){let{payChoice:e,setPayChoice:t,payment:n,payOptions:r,noPaymentMethod:i}=me();return P(Zt,{num:4,title:"Payment",children:[i&&o("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:Co}),o("div",{className:"grid gap-3",children:r.map(s=>o(Jt,{active:e===s.key,onClick:()=>t(s.key),title:s.title,body:s.body,price:s.price,tag:s.tag},s.key))}),e==="card"?o("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"?o("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"?o("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"?o("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"?o("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"?o("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"?o("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==="worldpay"?o("p",{className:"font-mono text-xs uppercase tracking-[0.2em] text-fg-dim",children:"You\u2019ll enter your card on Worldpay\u2019s secure page, then be brought straight back."}):e==="bank"?o("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 qo(){let{site:e,items:t,totals:n,coupon:r,formatMoney:i,payChoice:s,placing:d,email:p,orderError:m,payment:f,noPaymentMethod:b,unpaidOrder:g,formLocked:h,restoredPrices:v,basketRead:E,quoteFailed:C,retryQuote:O,placeOrder:z}=me(),R=v==="waiting"||!E,w=v==="changed";return P("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:[P("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:[o("span",{children:"Your order"}),o(ot,{href:"/wheels",className:"text-bg/80 transition-colors hover:text-bg",children:"Edit \u2197"})]}),o("div",{className:"flex flex-col px-6 py-2",children:E?t.length===0?P("div",{className:Eo,children:["Your cart is empty. ",o(ot,{href:"/wheels",className:"text-accent underline-offset-4 hover:underline",children:"Browse the catalog \u2192"})]}):t.map(I=>o(Ks,{slug:I.slug,name:I.name,qty:I.qty,config:I.config,configSummary:Ds(I.config),price:w||R?null:Hr(I,n.currency)??0,currency:n.currency},I.id)):o("div",{role:"status",className:Eo,children:qs})}),o(Xt,{locked:h,className:"border-t border-line px-6 pt-5",children:o(Zr,{customerEmail:p,disabled:h})}),P("div",{className:"flex flex-col gap-2 border-t border-line mt-5 px-6 pt-5",children:[o(Be,{label:"Subtotal",value:R?Kt:i(w?n.serverSubtotal??0:n.subtotal,n.currency)}),(n.discount>0||n.deliverySaving>0)&&r?.valid&&o(Be,{label:`Coupon \xB7 ${r.code}`,value:o("span",{className:"font-semibold text-green",children:Yr(n,I=>i(I,n.currency))})}),r?.deferred&&o(Be,{label:`Coupon \xB7 ${r.code}`,value:Mr}),r?.valid&&r.effects?.gift&&o(Be,{label:`Free gift \xB7 ${r.effects.gift.partNumber}${r.effects.gift.quantity>1?` \xD7${r.effects.gift.quantity}`:""}`,value:o("span",{className:"font-semibold text-green",children:Mt})}),o(Be,{label:"Shipping",value:n.shippingStatus==="free"?o("span",{className:"font-semibold text-green",children:Mt}):$r(n.shippingStatus)??i(n.shipping,n.currency)}),n.tax&&(n.tax.charged?o(Be,{label:n.tax.inclusive?`${n.tax.name} included \xB7 ${n.tax.rate}%`:n.tax.name,value:i(n.tax.amount,n.currency)}):n.tax.name?o(Be,{label:n.tax.name,value:jr}):null)]}),P("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:[o("span",{className:"font-display text-[20px] font-bold uppercase tracking-[0.04em] text-fg",children:"Total"}),o("span",{className:"text-right font-display text-[34px] font-bold leading-none tracking-[-0.025em] text-fg",children:n.repricing||!E?Kt:i(n.grand,n.currency)})]}),P("div",{className:"flex flex-col gap-3 px-6 pt-5 pb-6",children:[w&&o(pe,{tone:"quiet",children:ao}),C&&P(pe,{role:"alert",children:[oo," ",o("button",{type:"button",onClick:O,className:"underline transition-colors enabled:hover:text-accent",children:"Try again"})]}),m&&o(pe,{role:"alert",children:m}),n.hasUnpricedLine&&P(pe,{role:"status",children:["One or more items have no price in ",n.currency,". Remove them, or switch region, to continue."]}),o("button",{type:"button",onClick:z,disabled:d||!g&&(b||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 max-[640px]:gap-3 max-[640px]:whitespace-nowrap max-[640px]:px-4 max-[640px]:text-xs max-[640px]:tracking-normal",d||!g&&(t.length===0||b||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?P(fe,{children:["Building order\u2026 ",o("span",{children:"\xB7"})]}):b?P(fe,{children:["No online payment ",o("span",{children:"\xB7"})]}):g?P(fe,{children:[P("span",{children:["Try payment again",P(Oo,{children:[" \xB7 ",Gt(g)]})]}),o("span",{className:"transition-transform group-hover:translate-x-1",children:"\u2192"})]}):C?P(fe,{children:["Total not confirmed ",o("span",{children:"\xB7"})]}):n.repricing||!E?P(fe,{children:[Kt," ",o("span",{children:"\xB7"})]}):P(fe,{children:[P("span",{children:[s==="bank"?"Place order":"Continue to payment",P(Oo,{children:[" \xB7 ",i(n.grand,n.currency)]})]}),P("span",{className:"flex items-center gap-3",children:[o("span",{"aria-hidden":"true",className:"max-[359px]:hidden min-[641px]:hidden",children:i(n.grand,n.currency)}),o("span",{className:"transition-transform group-hover:translate-x-1",children:"\u2192"})]})]})})]})]})}var _s=" [&:disabled_:disabled]:cursor-not-allowed! [&:disabled_:disabled]:opacity-70! [&_input[readonly]]:cursor-not-allowed [&_input[readonly]]:opacity-70";function Xt({locked:e,className:t="",children:n}){return o("fieldset",{disabled:e,className:"m-0 min-w-0 border-0 p-0 "+t+_s,children:n})}function ot({href:e,className:t="",children:n,...r}){let{placing:i}=me();return i?o("span",{"aria-disabled":"true","aria-label":r["aria-label"],className:t+" pointer-events-none",children:n}):o(Ye,{href:e,"aria-label":r["aria-label"],className:t,children:n})}function Fs({orderNumber:e}){return o(pe,{tone:"quiet",role:"status",children:P("span",{className:"flex items-start gap-2",children:[P("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:[o("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1"}),o("path",{d:"M5 7V5a3 3 0 0 1 6 0v2"})]}),o("span",{children:No(e)})]})})}var Ro={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 Zt({num:e,title:t,children:n}){let{capitalised:r}=me();return P("section",{className:"mb-6 border border-line bg-bg",children:[P("header",{className:"flex items-center gap-4 border-b border-line bg-surface px-6 py-4",children:[o("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:r?String(e):`N\xB0 ${String(e).padStart(2,"0")}`}),o("h2",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:t})]}),o("div",{className:"flex flex-col gap-4 px-6 py-6",children:n})]})}function _o({cols:e="two",children:t}){return o("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 Jt({active:e,onClick:t,title:n,body:r,price:i,tag:s}){return P("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&&o("span",{"aria-hidden":!0,className:"absolute inset-y-0 left-0 w-[3px] bg-accent"}),o("span",{className:["flex h-[18px] w-[18px] items-center justify-center rounded-full border-2",e?"border-accent":"border-fg-dim"].join(" "),children:e&&o("span",{className:"block h-2.5 w-2.5 rounded-full bg-accent"})}),P("span",{className:"flex min-w-0 flex-col gap-1",children:[P("span",{className:"flex flex-wrap items-baseline gap-3 font-display text-[18px] font-medium tracking-[-0.01em] text-fg",children:[n,s&&o("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&&o("span",{className:"font-mono text-[12px] uppercase tracking-[0.22em] text-fg-dim",children:r})]}),o("span",{className:"whitespace-nowrap font-display text-[18px] font-medium tracking-[-0.01em] text-fg",children:i})]})}function Ms({checked:e,onChange:t,label:n,sub:r}){return P("div",{className:"flex items-start gap-3 border-t border-line py-4 first:border-t-0 first:pt-0",children:[o("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&&o("span",{className:"text-[13px] text-accent",children:"\u2713"})}),P("span",{className:"flex-1 font-display text-[16px] leading-[1.5] text-fg",children:[n,r&&o("small",{className:"mt-1 block font-mono text-[12px] uppercase tracking-[0.18em] text-fg-dim",children:r})]})]})}function Ks({slug:e,name:t,qty:n,config:r,configSummary:i,price:s,currency:d}){let{catalog:p}=Dt(),{formatMoney:m}=be(),f=p.find(C=>C.slug===e),b=f?.spokes??5,g=f?.mesh??!1,h=r.find(C=>C.gold)?.label,v=f?.finishes.find(C=>C.name===h&&C.src)??f?.finishes.find(C=>C.src),E=f?.finishes[0]?.color??Xr;return P("div",{className:"grid grid-cols-[60px_1fr_auto] items-center gap-4 border-b border-line py-4 last:border-b-0",children:[P("div",{className:"relative aspect-square",children:[o("div",{className:"flex h-full w-full items-center justify-center overflow-hidden border border-line bg-surface",children:v?.src?o(Ir,{src:v.src,alt:`${t.lead}${t.accent} \u2014 ${v.name}`,width:120,height:120,sizes:"60px",className:"block h-full w-full object-contain p-2"}):o("div",{className:"block w-[78%]",style:{color:E},children:o(Jr,{spokes:b,mesh:g,className:"block w-full"})})}),o("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})]}),P("div",{className:"flex min-w-0 flex-col gap-0.5",children:[P("span",{className:"font-display text-[17px] font-bold uppercase leading-none tracking-[-0.005em] text-fg",children:[t.lead,o("em",{className:"font-serif font-normal italic text-accent tracking-[-0.005em] normal-case",children:t.accent})]}),o("span",{className:"font-mono text-[12px] uppercase leading-[1.5] tracking-[0.18em] text-fg-dim",children:i})]}),o("span",{className:"text-right font-display text-[17px] font-bold tracking-[-0.005em] text-fg",children:s===null?null:m(s,d)})]})}function Oo({children:e}){return o("span",{className:"max-[640px]:sr-only",children:e})}function Be({label:e,value:t}){return P("div",{className:"flex items-center justify-between font-mono text-[13px] font-medium uppercase tracking-[0.18em] text-fg",children:[o("span",{children:e}),o("strong",{className:"font-display text-[16px] font-medium tracking-[-0.005em] normal-case text-fg",children:t})]})}function Ds(e){return e.map(t=>t.label).join(" \xB7 ")}import{Fragment as G,jsx as l,jsxs as k}from"react/jsx-runtime";function Wn(e){return l(So,{...e,children:l(Ws,{children:l(Bs,{})})})}function Ws({children:e}){let{capitalised:t}=me();return t?l("div",{"data-checkout-case":"capitalised",className:"contents",children:e}):l(G,{children:e})}function Ys({order:e,paid:t}){let{formatMoney:n}=be();if(!e.grandTotal||!e.currency)return null;let r=d=>n(Number(d),e.currency),i=Number(e.freightCharge??0),s=Number(e.discountAmount??0);return k("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||i>0)&&k(G,{children:[k("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&&k(G,{children:[k("dt",{className:"text-fg-dim",children:["Discount",e.couponCode?` \xB7 ${e.couponCode}`:""]}),k("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 $s({result:e,lostChangeNote:t=null}){let n=l("span",{className:"font-mono text-fg",children:e.checkoutNumber});return k("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"?k(G,{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"?k(G,{children:["The hold on checkout ",n," ran out before your payment arrived. Your payment goes back to your card."]}):e.kind==="processing"?k(G,{children:["Your payment for checkout ",n," is being processed. When it goes through, we will email your order confirmation."]}):k(G,{children:["Thank you \u2014 your payment",e.checkoutNumber?k(G,{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(Ye,{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 Bs(){let{site:e,logo:t,items:n,placing:r,formLocked:i,email:s,me:d,addressSaveNote:p,lostChangeNote:m,idemKey:f,confirmation:b,setConfirmation:g,payment:h,paypalStep:v,squareStep:E,pendingConf:C,paid:O,setPaid:z,payNote:R,afterpayConfirming:w,gocardlessConfirming:I,zipConfirming:Q,klarnaConfirming:ce,worldpayConfirming:oe,cardConfirming:ke,checkoutResult:Ne,confirmCardPayment:$,cardStillProcessing:ye,renewCardPayment:we,holdRenewed:_e,leaveCardPayment:V,checkoutRootRef:ee,setCheckoutHeaderEl:x}=me();return b?k("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:O?"Payment received":"Order received"}),k("p",{className:"text-fg-dim",children:[O?k(G,{children:["Thank you \u2014 your payment for order"," ",l("span",{className:"font-mono text-fg",children:b.orderNumber})," has gone through."," "]}):k(G,{children:["Thank you \u2014 your order ",l("span",{className:"font-mono text-fg",children:b.orderNumber})," is being reviewed by our team."," "]}),d?k(G,{children:["Track it under"," ",l(Ye,{href:"/account/orders",className:"text-accent underline",children:"your orders"}),"."]}):l(G,{children:"We\u2019ve emailed you a link to set a password and track it."})]}),l(Ys,{order:b,paid:O}),m&&l("p",{className:"text-sm text-fg-dim",children:m}),R&&(R.warning?l("div",{className:"w-full max-w-sm text-left",children:l(pe,{tone:"bad",role:"alert",children:R.text})}):l("p",{className:"text-sm text-fg-dim",children:R.text})),p&&l("p",{className:"text-sm text-fg-dim",children:p}),!d&&k("p",{className:"text-sm text-fg-dim",children:["You can also"," ",l(Ye,{href:`/track?order=${encodeURIComponent(b.orderNumber)}`,className:"text-accent underline",children:"track this order"})," ","anytime with just your order number and email \u2014 no password needed."]}),l(Ye,{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"})]}):Ne?l($s,{result:Ne,lostChangeNote:m}):ke?k("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."})]}):w?k("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."})]}):I?k("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."})]}):Q?k("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."})]}):ce?k("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."})]}):oe?k("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-xs uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Worldpay \u2014 one moment."})]}):h&&C?l(Hs,{payment:h,checkout:C,holdRenewed:_e,onPaid:$,onProcessing:ye,onRenew:we,onBack:V}):v&&C?l(Js,{confirmation:C,clientId:e.paypalClientId??"",idemKey:f,onPaid:()=>{z(!0),g(C)},onSkip:()=>g(C)}):E&&C?l(Qs,{confirmation:C,applicationId:e.squareApplicationId??"",locationId:e.squareLocationId??"",environment:e.squareEnvironment??"production",idemKey:f,onPaid:()=>{z(!0),g(C)},onSkip:()=>g(C)}):k("div",{ref:ee,className:"bg-bg text-fg",children:[k("header",{ref:x,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:[k(ot,{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(ot,{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(J=>l(ea,{hideClass:J?"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:J,fitFloorPx:J?Qr:void 0},J?"phone":"wide"))})}),e.cardPayments?k("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",{})]}),k("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 max-[640px]:flex-nowrap max-[640px]:gap-3 max-[640px]:whitespace-nowrap max-[640px]:text-xs max-[640px]:tracking-[0.04em]",children:[{n:"01",label:"Cart",state:"done"},{n:"02",label:"Ship & pay",state:"active"},{n:"03",label:"Confirmed",state:"pending"}].map(J=>k("span",{className:["relative flex items-center gap-2 transition-colors",J.state==="pending"?"text-fg-dim":"text-fg",J.state==="active"?"font-bold after:absolute after:inset-x-0 after:-bottom-1 after:h-[2px] after:bg-accent":""].join(" "),children:[l("span",{className:J.state==="done"?"text-accent font-bold":"",children:J.n}),l("span",{children:J.label})]},J.n))})]}),k("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:[k("div",{children:[k(Xt,{locked:i,children:[l(Ao,{}),l(Lo,{}),l(Io,{})]}),l(Xt,{locked:r,children:l(To,{})})]}),l(qo,{})]}),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:Gr({legalName:e.legalName,foundedYear:e.foundedYear,siteName:e.name})})})]})}function Hs({payment:e,checkout:t,holdRenewed:n,onPaid:r,onProcessing:i,onRenew:s,onBack:d}){let{formatMoney:p}=be(),m=l("span",{className:"text-fg",children:p(Number(e.amount),e.currency)}),f=Fo(()=>$t(e.publishableKey),[e.publishableKey]),b=Fo(()=>ra(),[]),g=na(t.expiresAt??"",Us()??"");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:k("div",{className:"w-full max-w-xl border border-line bg-bg",children:[k("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:Gt(t)}),l("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"Payment"})]}),k("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?k(G,{children:["Your order is placed. Pay ",m," by card to confirm it now."]}):n?k(G,{children:["Your hold ran out, so your items are held again",g?` until ${g}`:"",". Enter your card again, then pay ",m,"."]}):k(G,{children:["Your items are held",g?` until ${g}`:"",". Pay ",m," by card to place your order."]})}),l(Pn,{stripe:f,options:{clientSecret:e.clientSecret,appearance:b},children:l(Gs,{payment:e,checkout:t,onPaid:r,onProcessing:i,onRenew:s,onBack:d})},e.clientSecret)]})]})})}var zs=5;function Gs({payment:e,checkout:t,onPaid:n,onProcessing:r,onRenew:i,onBack:s}){let{formatMoney:d}=be(),p=wa(),m=Pa(),[f,b]=He(!1),[g,h]=He(null),v=it(!1);async function E(){try{return(await p.retrievePaymentIntent(e.clientSecret)).paymentIntent?.status}catch{return}}async function C(R){let w=R;for(let I=0;w==="processing"&&I<zs;I+=1)await new Promise(Q=>setTimeout(Q,1e3)),w=await E()??w;if(w==="succeeded"){n();return}if(w==="processing"){r();return}h("Payment did not complete. Please try again."),b(!1)}async function O(){if(!p||!m||f)return;b(!0),h(null),v.current=!0;let R=await p.confirmPayment({elements:m,redirect:"if_required"}).catch(()=>null);if(!R){let w=await E();if(w==="succeeded"||w==="processing"){await C(w);return}h(w===void 0?qe:"Payment failed. Please try again."),b(!1);return}if(R.error){if(!t.orderNumber&&R.error.code==="payment_intent_unexpected_state"){let w=await E();if(w==="succeeded"||w==="processing"){await C(w);return}if(w===void 0){h(qe),b(!1);return}await i(w==="canceled"),b(!1);return}h(R.error.message??"Payment failed. Please try again."),b(!1);return}await C(R.paymentIntent?.status)}async function z(){if(f)return;if(!v.current){s();return}b(!0),h(null);let R=await E();if(R==="succeeded"||R==="processing"){await C(R);return}if(b(!1),R===void 0){h(qe);return}s()}return k("div",{className:"flex flex-col gap-4",children:[l(Sa,{}),g&&l(pe,{role:"alert",children:g}),l("button",{type:"button",onClick:O,disabled:!p||!m||f,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",!p||!m||f?"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?k(G,{children:["Processing\u2026 ",l("span",{children:"\xB7"})]}):k(G,{children:["Pay ",d(Number(e.amount),e.currency),l("span",{className:"transition-transform group-hover:translate-x-1",children:"\u2192"})]})}),!t.orderNumber&&!f&&k("button",{type:"button",onClick:z,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 Mo="paypal-sdk-js",Un=null;function Vs(e,t){let n=`${e}|${t}`;if(Un?.key===n)return Un.promise;let r=new Promise((i,s)=>{document.getElementById(Mo)?.remove();let d=document.createElement("script");d.id=Mo;let p=new URLSearchParams({"client-id":e,currency:t,intent:"capture"});d.src=`https://www.paypal.com/sdk/js?${p}`,d.onload=()=>{let m=window.paypal;m?i(m):s(new Error("PayPal SDK loaded without its namespace"))},d.onerror=()=>s(new Error("PayPal SDK failed to load")),document.head.appendChild(d)});return Un={key:n,promise:r},r}function Js({confirmation:e,clientId:t,idemKey:n,onPaid:r,onSkip:i}){let{formatMoney:s}=be(),d=it(null),[p,m]=He(!1),[f,b]=He(null),g=it(r);return g.current=r,Do(()=>{let h=!1,v=null;return Vs(t,e.currency).then(E=>{if(!(h||!d.current))return v=E.Buttons({style:{layout:"vertical",color:"gold",shape:"rect",label:"paypal"},createOrder:async()=>(await K.createPaypalOrder({idempotencyKey:n})).paypalOrderId,onApprove:async C=>{try{if((await K.capturePaypalOrder({idempotencyKey:n,paypalOrderId:C.orderID})).status==="paid"){g.current();return}b("PayPal did not complete the payment. Please try again.")}catch(O){b(O instanceof de?O.message:"PayPal payment failed. Please try again.")}},onError:()=>{b("PayPal could not process the payment. Please try again.")}}),v.render(d.current).then(()=>{h||m(!0)})}).catch(()=>{h||b("PayPal could not be loaded. You can pay later \u2014 your order stands either way.")}),()=>{h=!0,v?.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:k("div",{className:"w-full max-w-xl border border-line bg-bg",children:[k("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"})]}),k("div",{className:"flex flex-col gap-4 px-6 py-6",children:[k("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."]}),!p&&!f&&l("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading PayPal\u2026"}),l("div",{ref:d}),f&&l(pe,{role:"alert",children:f}),l("button",{type:"button",onClick:i,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 Ko="square-web-sdk",jn=null,Xs=["sandbox","production"];function Zs(e){let t=js(Xs,"production",e);if(jn?.key===t)return jn.promise;let n=new Promise((r,i)=>{document.getElementById(Ko)?.remove();let s=document.createElement("script");s.id=Ko,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):i(new Error("Square SDK loaded without its namespace"))},s.onerror=()=>i(new Error("Square SDK failed to load")),document.head.appendChild(s)});return jn={key:t,promise:n},n}function Qs({confirmation:e,applicationId:t,locationId:n,environment:r,idemKey:i,onPaid:s,onSkip:d}){let{formatMoney:p}=be(),m=it(null),f=it(null),b=it(null),[g,h]=He(!1),[v,E]=He(!1),[C,O]=He(null);Do(()=>{let R=!1,w=null;return Zs(r).then(async I=>{if(R||!m.current)return;let Q=I.payments(t,n);b.current=Q,w=await Q.card(),await w.attach(m.current),f.current=w,R||h(!0)}).catch(()=>{R||O("Square could not be loaded. You can pay later \u2014 your order stands either way.")}),()=>{R=!0,w?.destroy?.()}},[t,n,r]);async function z(){let R=f.current;if(!(!R||v)){E(!0),O(null);try{let w=await R.tokenize();if(w.status!=="OK"||!w.token){O(w.errors?.[0]?.message??"Please check the card details and try again."),E(!1);return}let I;try{I=(await b.current?.verifyBuyer?.(w.token,{amount:String(e.grandTotal),currencyCode:e.currency,intent:"CHARGE"}))?.token}catch{}if((await K.chargeSquare({idempotencyKey:i,sourceId:w.token,...I?{verificationToken:I}:{}})).status==="paid"){s();return}O("Square did not complete the payment. Please try again.")}catch(w){O(w instanceof de?w.message:"Square payment failed. Please try again.")}E(!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:k("div",{className:"w-full max-w-xl border border-line bg-bg",children:[k("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"})]}),k("div",{className:"flex flex-col gap-4 px-6 py-6",children:[k("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:p(Number(e.grandTotal),e.currency)})," ","by card to confirm it now."]}),!g&&!C&&l("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading card form\u2026"}),l("div",{ref:m}),C&&l(pe,{role:"alert",children:C}),l("button",{type:"button",onClick:z,disabled:!g||v,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||v?"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:v?k(G,{children:["Processing\u2026 ",l("span",{children:"\xB7"})]}):k(G,{children:["Pay ",p(Number(e.grandTotal),e.currency),l("span",{className:"transition-transform group-hover:translate-x-1",children:"\u2192"})]})}),l("button",{type:"button",onClick:d,disabled:v,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 Qt}from"react/jsx-runtime";function ec(){let{settings:e,websiteName:t}=Tr(),n=t?{...bn,name:t}:bn,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 Qt("div",{style:{position:"fixed",inset:0,zIndex:2147482e3,overflowY:"auto",background:"var(--bg)",color:"var(--fg)"},children:Qt(Br,{children:Qt(zr,{preview:!0,children:Qt(Wn,{site:n,logo:r,textCase:e?.navTextCase,preview:!0})})})})}export{ec as default};
|
|
1
|
+
"use client";import{$a as ne,Aa as bn,Ia as Vr,W as Mt,X as Kt,b as Mr,c as hn,cb as Jr,d as Kr,db as Xr,e as Ft,ib as Zr,jb as pe,kb as Qr,la as Dr,lb as ea,ma as Ur,na as jr,oa as Wr,pa as Yr,qa as $r,qb as ta,ra as Br,rb as xt,sa as be,ua as vt,ub as vn,va as Hr,wa as zr,wb as ae,xa as Dt,ya as Gr}from"./chunk-VJSXEYRL.js";import{S as de,Y as tt,da as K,o as _r,p as Fr}from"./chunk-JHEIFPET.js";import{fa as Ir,ha as Te}from"./chunk-UYU65XIT.js";import{i as qr,j as bt,k as qe}from"./chunk-YMJRKOEC.js";import{Ci as Tr}from"./chunk-GZKBN53C.js";import"./chunk-XPDSLIZ3.js";import"./chunk-DSTQVJ5G.js";import{a as gn,b as Ri}from"./chunk-Y6SLVHK3.js";var oa=gn((sc,aa)=>{"use strict";var Li="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";aa.exports=Li});var la=gn((cc,ca)=>{"use strict";var Ii=oa();function ia(){}function sa(){}sa.resetWarningCache=ia;ca.exports=function(){function e(r,i,s,d,p,m){if(m!==Ii){var f=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 f.name="Invariant Violation",f}}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:sa,resetWarningCache:ia};return n.PropTypes=n,n}});var da=gn((dc,ua)=>{"use strict";ua.exports=la()();var lc,uc});import{useEffect as Do,useMemo as Fo,useRef as it,useState as He}from"react";import{formatTime as Oi}from"efficient-shell/format";function na(e,t){let n=Fr(t);return!n||Number.isNaN(new Date(e).getTime())?"":Oi(e,{locale:_r(),timeZone:n})}import{rootIsDark as Ai}from"efficient-shell/format";function ra(){if(typeof document>"u")return;let e=getComputedStyle(document.documentElement),t=(r,i)=>e.getPropertyValue(r).trim()||i,n=Ai({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 Us,parseOption as js}from"efficient-shell/format";var D=Ri(da(),1);import T from"react";function pa(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 Ti(e){if(Array.isArray(e))return e}function ha(e,t,n){return(t=Di(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function qi(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,s,d,p=[],m=!0,f=!1;try{if(s=(n=n.call(e)).next,t!==0)for(;!(m=(r=s.call(n)).done)&&(p.push(r.value),p.length!==t);m=!0);}catch(h){f=!0,i=h}finally{try{if(!m&&n.return!=null&&(d=n.return(),Object(d)!==d))return}finally{if(f)throw i}}return p}}function _i(){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 ma(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function fa(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?ma(Object(n),!0).forEach(function(r){ha(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ma(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Fi(e,t){if(e==null)return{};var n,r,i=Mi(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)&&(i[n]=e[n])}return i}function Mi(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 ba(e,t){return Ti(e)||qi(e,t)||Ui(e,t)||_i()}function Ki(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 Di(e){var t=Ki(e,"string");return typeof t=="symbol"?t:t+""}function xn(e){"@babel/helpers - typeof";return xn=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},xn(e)}function Ui(e,t){if(e){if(typeof e=="string")return pa(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)?pa(e,t):void 0}}var Z=function(t,n,r){var i=!!r,s=T.useRef(r);T.useEffect(function(){s.current=r},[r]),T.useEffect(function(){if(!i||!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)}},[i,n,t,s])},kn=function(t){var n=T.useRef(t);return T.useEffect(function(){n.current=t},[t]),n.current},nt=function(t){return t!==null&&xn(t)==="object"},ji=function(t){return nt(t)&&typeof t.then=="function"},Wi=function(t){return nt(t)&&typeof t.elements=="function"&&typeof t.createToken=="function"&&typeof t.createPaymentMethod=="function"&&typeof t.confirmCardPayment=="function"},ya="[object Object]",Yi=function e(t,n){if(t===n)return!0;if(!nt(t)||!nt(n))return t===n;var r=Array.isArray(t),i=Array.isArray(n);if(r!==i)return!1;var s=Object.prototype.toString.call(t)===ya,d=Object.prototype.toString.call(n)===ya;if(s!==d)return!1;if(!s&&!r)return t===n;var p=Object.keys(t),m=Object.keys(n);if(p.length!==m.length)return!1;for(var f={},h=0;h<p.length;h+=1)f[p[h]]=!0;for(var g=0;g<m.length;g+=1)f[m[g]]=!0;var b=Object.keys(f);if(b.length!==p.length)return!1;var x=t,E=n,C=function(G){return e(x[G],E[G])};return b.every(C)},va=function(t,n,r){return nt(t)?Object.keys(t).reduce(function(i,s){var d=!nt(n)||!Yi(t[s],n[s]);return r.includes(s)?(d&&console.warn("Unsupported prop change: options.".concat(s," is not a mutable property.")),i):d?fa(fa({},i||{}),{},ha({},s,t[s])):i},null):null},xa="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.",ga=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:xa;if(t===null||Wi(t))return t;throw new Error(n)},$i=function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:xa;if(ji(t))return{tag:"async",stripePromise:Promise.resolve(t).then(function(i){return ga(i,n)})};var r=ga(t,n);return r===null?{tag:"empty"}:{tag:"sync",stripe:r}},Bi=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"}))},Ut=T.createContext(null);Ut.displayName="ElementsContext";var ka=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},Pn=function(t){var n=t.stripe,r=t.options,i=t.children,s=T.useMemo(function(){return $i(n)},[n]),d=T.useState(function(){return{stripe:s.tag==="sync"?s.stripe:null,elements:s.tag==="sync"?s.stripe.elements(r):null}}),p=ba(d,2),m=p[0],f=p[1];T.useEffect(function(){var b=!0,x=function(C){f(function(O){return O.stripe?O:{stripe:C,elements:C.elements(r)}})};return s.tag==="async"&&!m.stripe?s.stripePromise.then(function(E){E&&b&&x(E)}):s.tag==="sync"&&!m.stripe&&x(s.stripe),function(){b=!1}},[s,m,r]);var h=kn(n);T.useEffect(function(){h!==null&&h!==n&&console.warn("Unsupported prop change on Elements: You cannot change the `stripe` prop after setting it.")},[h,n]);var g=kn(r);return T.useEffect(function(){if(m.elements){var b=va(r,g,["clientSecret","fonts"]);b&&m.elements.update(b)}},[r,g,m.elements]),T.useEffect(function(){Bi(m.stripe)},[m.stripe]),T.createElement(Ut.Provider,{value:m},i)};Pn.propTypes={stripe:D.default.any,options:D.default.object};var Ca=function(t){var n=T.useContext(Ut);return ka(n,t)},Pa=function(){var t=Ca("calls useElements()"),n=t.elements;return n},Hi=function(t){var n=t.children,r=Ca("mounts <ElementsConsumer>");return n(r)};Hi.propTypes={children:D.default.func.isRequired};var zi=T.createContext(null);zi.displayName="CheckoutContext";var Na=T.createContext(null);Na.displayName="CheckoutSdkContext";var Cn=function(t){var n=T.useContext(Na),r=T.useContext(Ut);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 ka(r,t)},Gi=["mode"],Vi=function(t){return t.charAt(0).toUpperCase()+t.slice(1)},U=function(t,n,r){var i="".concat(Vi(t),"Element"),s=function(f){var h=f.id,g=f.className,b=f.options,x=b===void 0?{}:b,E=f.onBlur,C=f.onFocus,O=f.onReady,G=f.onChange,R=f.onEscape,w=f.onClick,I=f.onLoadError,Q=f.onLoaderStart,ce=f.onNetworksChange,oe=f.onConfirm,ke=f.onCancel,Ne=f.onShippingAddressChange,$=f.onShippingRateChange,ye=f.onSavedPaymentMethodRemove,we=f.onSavedPaymentMethodUpdate,Fe=f.onAvailablePaymentMethodsChange,V=Cn("mounts <".concat(i,">")),ee="elements"in V?V.elements:null,k="checkoutSdk"in V?V.checkoutSdk:null,J=T.useState(null),le=ba(J,2),W=le[0],Se=le[1],te=T.useRef(null),Ee=T.useRef(null);Z(W,"blur",E),Z(W,"focus",C),Z(W,"escape",R),Z(W,"click",w),Z(W,"loaderror",I),Z(W,"loaderstart",Q),Z(W,"networkschange",ce),Z(W,"confirm",oe),Z(W,"cancel",ke),Z(W,"shippingaddresschange",Ne),Z(W,"shippingratechange",$),Z(W,"savedpaymentmethodremove",ye),Z(W,"savedpaymentmethodupdate",we),Z(W,"availablepaymentmethodschange",Fe),Z(W,"change",G);var Me;O&&(t==="expressCheckout"?Me=O:Me=function(){O(W)}),Z(W,"ready",Me),T.useLayoutEffect(function(){if(te.current===null&&Ee.current!==null&&(ee||k)){var q=null;if(k){var ie=k,Ke=k;switch(t){case"paymentForm":q=Ke.createForm(x);break;case"payment":q=ie.createPaymentElement(x);break;case"address":if("mode"in x){var ge=x.mode,Oe=Fi(x,Gi);if(ge==="shipping")q=ie.createShippingAddressElement(Oe);else if(ge==="billing")q=ie.createBillingAddressElement(Oe);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":q=ie.createExpressCheckoutElement(x);break;case"currencySelector":q=k.createCurrencySelectorElement();break;case"taxId":q=ie.createTaxIdElement(x);break;case"contactDetails":q=ie.createContactDetailsElement();break;case"linkSignup":if("createLinkSignupElement"in k)q=k.createLinkSignupElement(x);else throw new Error("<LinkSignupElement> requires <CheckoutElementsProvider> and is not supported inside <CheckoutFormProvider>.");break;case"terms":q=ie.createTermsElement(x);break;default:throw new Error("<".concat(i,"> is not supported inside a checkout provider. Use an <Elements> provider instead."))}}else ee&&(q=ee.create(t,x));te.current=q,Se(q),q&&q.mount(Ee.current)}},[ee,k,x]);var Re=kn(x);return T.useEffect(function(){if(te.current){var q=va(x,Re,["paymentRequest"]);q&&"update"in te.current&&te.current.update(q)}},[x,Re]),T.useLayoutEffect(function(){return function(){if(te.current&&typeof te.current.destroy=="function")try{te.current.destroy(),te.current=null}catch{}}},[]),T.createElement("div",{id:h,className:g,ref:Ee})},d=function(f){Cn("mounts <".concat(i,">"));var h=f.id,g=f.className;return T.createElement("div",{id:h,className:g})},p=n?d:s;return p.propTypes={id:D.default.string,className:D.default.string,onChange:D.default.func,onBlur:D.default.func,onFocus:D.default.func,onReady:D.default.func,onEscape:D.default.func,onClick:D.default.func,onLoadError:D.default.func,onLoaderStart:D.default.func,onNetworksChange:D.default.func,onConfirm:D.default.func,onCancel:D.default.func,onShippingAddressChange:D.default.func,onShippingRateChange:D.default.func,onSavedPaymentMethodRemove:D.default.func,onSavedPaymentMethodUpdate:D.default.func,onAvailablePaymentMethodsChange:D.default.func,options:D.default.object},p.displayName=i,p.__elementType=t,p},j=typeof window>"u",Ji=T.createContext(null);Ji.displayName="EmbeddedCheckoutProviderContext";var wa=function(){var t=Cn("calls useStripe()"),n=t.stripe;return n},mc=U("auBankAccount",j),fc=U("card",j),yc=U("cardNumber",j),gc=U("cardExpiry",j),hc=U("cardCvc",j),bc=U("currencySelector",j),vc=U("iban",j),Sa=U("payment",j),xc=U("expressCheckout",j),kc=U("paymentRequestButton",j),Cc=U("linkAuthentication",j),Pc=U("linkSignup",j),Nc=U("contactDetails",j),wc=U("address",j),Sc=U("shippingAddress",j),Ec=U("paymentMethodMessaging",j),Rc=U("taxId",j),Oc=U("issuingCardNumberDisplay",j),Ac=U("issuingCardCvcDisplay",j),Lc=U("issuingCardExpiryDisplay",j),Ic=U("issuingCardPinDisplay",j),Tc=U("issuingCardCopyButton",j),qc=U("terms",j);function Yt(e){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Yt=function(t){return typeof t}:Yt=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Yt(e)}var Oa="dahlia",Xi=function(t){return t===3?"v3":t},Aa="https://js.stripe.com",Zi="".concat(Aa,"/").concat(Oa,"/stripe.js"),Qi=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,es=/^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/,Ea="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used",ts=function(t){return Qi.test(t)||es.test(t)},ns=function(){for(var t=document.querySelectorAll('script[src^="'.concat(Aa,'"]')),n=0;n<t.length;n++){var r=t[n];if(ts(r.src))return r}return null},Ra=function(t){var n=t&&!t.advancedFraudSignals?"?advancedFraudSignals=false":"",r=document.createElement("script");r.src="".concat(Zi).concat(n);var i=document.head||document.body;if(!i)throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");return i.appendChild(r),r},rs=function(t,n){!t||!t._registerWrapper||t._registerWrapper({name:"stripe-js",version:"9.17.0",startTime:n})},kt=null,jt=null,Wt=null,as=function(t){return function(n){t(new Error("Failed to load Stripe.js",{cause:n}))}},os=function(t,n){return function(){window.Stripe?t(window.Stripe):n(new Error("Stripe.js not available"))}},is=function(t){return kt!==null?kt:(kt=new Promise(function(n,r){if(typeof window>"u"||typeof document>"u"){n(null);return}if(window.Stripe&&t&&console.warn(Ea),window.Stripe){n(window.Stripe);return}try{var i=ns();if(i&&t)console.warn(Ea);else if(!i)i=Ra(t);else if(i&&Wt!==null&&jt!==null){var s;i.removeEventListener("load",Wt),i.removeEventListener("error",jt),(s=i.parentNode)===null||s===void 0||s.removeChild(i),i=Ra(t)}Wt=os(n,r),jt=as(r),i.addEventListener("load",Wt),i.addEventListener("error",jt)}catch(d){r(d);return}}),kt.catch(function(n){return kt=null,Promise.reject(n)}))},ss=function(t,n,r){if(t===null)return null;var i=n[0];if(typeof i!="string")throw new Error("Expected publishable key to be of type string, got type ".concat(Yt(i)," instead."));var s=i.match(/^pk_test/),d=Xi(t.version),p=Oa;s&&d!==p&&console.warn("Stripe.js@".concat(d," was loaded on the page, but @stripe/stripe-js@").concat("9.17.0"," expected Stripe.js@").concat(p,". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));var m=t.apply(void 0,n);return rs(m,r),m},Ct,La=!1,Ia=function(){return Ct||(Ct=is(null).catch(function(t){return Ct=null,Promise.reject(t)}),Ct)};Promise.resolve().then(function(){return Ia()}).catch(function(e){La||console.warn(e)});var $t=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];La=!0;var i=Date.now();return Ia().then(function(s){return ss(s,n,i)})};var Bt=2;function Ta(e){return e==="card"}var cs="checkout_unavailable",ls="checkout_waiting",qa="committed",_e="We could not check your payment. Please try again.",Ht="Your last change was not saved. This is your order as placed.",_a="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.",Fa=1e4;async function Ma(e,t=Fa){let n,r=new Promise(s=>{n=setTimeout(()=>s(void 0),t)}),i=(async()=>{try{return(await(await $t(e.publishableKey))?.retrievePaymentIntent(e.clientSecret))?.paymentIntent?.status}catch{return}})();try{return await Promise.race([i,r])}finally{clearTimeout(n)}}var Ka=new Set(["none","requires_payment_method","canceled"]);async function Nn(e,t=Fa){let n,r=new Promise(i=>{n=setTimeout(()=>i(void 0),t)});try{return await Promise.race([K.releaseCheckout({idempotencyKey:e}).then(i=>i.status,()=>{}),r])}finally{clearTimeout(n)}}function Da(e,t){return e instanceof de&&typeof e.data=="object"&&e.data!==null&&e.data.code===t}function zt(e){return Da(e,cs)}function wn(e){return Da(e,ls)}function Sn(e){return e instanceof de&&e.status>=400&&e.status<500&&e.status!==408}function Ua(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 Gt(e){return e.orderNumber||e.checkoutNumber}function us(e){return e.orderNumber?{kind:"placed",order:e}:{kind:e.status==="released"?"refunded":e.status==="expired"?"expired":"pending",checkoutNumber:e.checkoutNumber}}async function ja({checkoutNumber:e,resend:t,page:n}){n.setConfirming(!0);let r;try{r=us(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 Es,useContext as Rs,useEffect as H,useMemo as yo,useRef as B,useState as N}from"react";var ds="sf:gclid",ps="sf:fbclid",ms=2160*60*60*1e3;function $a(){return typeof window<"u"}function Wa(e){let t=bt.getItem(e);if(!t)return"";try{let{v:n,t:r}=JSON.parse(t);return!n||typeof r!="number"||Date.now()-r>ms?"":n}catch{return""}}function Ya(e){if(!$a())return"";let t=e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1"),n=document.cookie.match(new RegExp(`(?:^|; )${t}=([^;]*)`));return n?decodeURIComponent(n[1]):""}function Ba(){if(!$a())return{};let e=Wa(ds),t=Wa(ps),n=Ya("_fbp"),r=Ya("_fbc");!r&&t&&(r=`fb.1.${Date.now()}.${t}`);let i={};return e&&(i.gclid=e),t&&(i.fbclid=t),n&&(i.fbp=n),r&&(i.fbc=r),i}var Ha="sf:meta-purchases",fs=20;function Ga(){return typeof window>"u"||window.parent!==window}function ys(...e){try{if(Ga()||typeof window.fbq!="function")return;window.fbq(...e)}catch{}}var za=new Set;function gs(e){if(za.has(e))return!1;za.add(e);try{let t=JSON.parse(bt.getItem(Ha)??"[]");if(t.includes(e))return!1;bt.setItem(Ha,JSON.stringify([...t,e].slice(-fs)))}catch{}return!0}function hs(e){return[...new Set(e.filter(vt).flatMap(t=>t.components.map(n=>n.partNumber)))]}function Va(e){let t=e.confirmation;Ga()||!gs(t.orderNumber)||ys("track","Purchase",{value:Number(t.grandTotal),currency:t.currency,content_type:"product",content_ids:hs(e.lines)},{eventID:t.orderNumber})}var En="checkout-afterpay-context",Rn="checkout-gocardless-context",On="checkout-zip-context",An="checkout-klarna-context",Ln="checkout-worldpay-context";function bs(e){return e?.lostChange===!0}function vs({evidence:e,parked:t}){return e?{action:"capture",evidence:e,parked:t}:t?{action:"settle",parked:t}:{action:"ignore"}}function xs(e,t){let n=e.getItem(t);if(e.removeItem(t),!n)return null;try{return JSON.parse(n)}catch{return null}}function ks(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 Ja={name:"Afterpay",legParam:"afterpay",legValues:["confirm","cancel"],storageKey:En,evidenceFrom(e,t){return t==="cancel"||(e.get("status")??"").toUpperCase()==="CANCELLED"?null:e.get("orderToken")},requestFrom:e=>({token:e})},Xa={name:"Zip",legParam:"zip",legValues:["return"],storageKey:On,evidenceFrom(e){let t=(e.get("result")??"").toLowerCase();return t==="cancelled"||t==="declined"?null:e.get("checkoutId")},requestFrom:e=>({checkoutId:e})},Za={name:"Worldpay",legParam:"worldpay",legValues:["return","cancel"],storageKey:Ln,evidenceFrom:(e,t)=>t==="cancel"?null:e.get("worldpayRef"),requestFrom:e=>({transactionReference:e}),words:{declined:"Worldpay did not take the payment \u2014 our team will follow up on payment.",collecting:"We're confirming your payment with Worldpay \u2014 we'll email you once it's through."}},Qa={name:"GoCardless",legParam:"gocardless",legValues:["confirm","cancel"],storageKey:Rn,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."}},eo={name:"Klarna",legParam:"klarna",legValues:["confirm","cancel"],storageKey:An,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 rt(e,t){let n=new URLSearchParams(t.search),r=n.get(e.legParam);if(!r||!e.legValues.includes(r))return;let i=xs(t.storage,e.storageKey),s=e.evidenceFrom(n,r);t.scrubQuery();let d=vs({evidence:s,parked:i});if(d.action==="ignore"||e.keyedByParked&&!d.parked)return;let p=ks(e);if(t.page.clearCart(),bs(d.parked)&&t.page.lostChange(),d.action==="settle"){t.page.note(p.settled,!0),t.page.land(d.parked.confirmation);return}t.page.setConfirming(!0);try{let m=await t.capture(e.requestFrom(d.evidence,d.parked));m.status==="paid"?t.page.markPaid():m.status==="collecting"?t.page.note(p.collecting,!e.words?.collecting):t.page.note(p.declined,!0),t.page.land(d.parked?.confirmation??m)}catch{d.parked?(t.page.note(p.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 to(e,t,n){let r=(t??"").trim();if(!r)return"";if(n.length===0)return r;let i=r.toUpperCase(),s=`${e.toUpperCase()}-${i}`,d=n.find(p=>p.code&&p.code.toUpperCase()===i)??n.find(p=>p.code&&p.code.toUpperCase()===s)??n.find(p=>p.name.toUpperCase()===i);return d?d.code||d.name:""}var Tn="checkout-memory-context",ao="Prices have changed since this checkout started. The total shows today's prices.",oo="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.",io=3,Cs=3600*1e3;function Ps(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 Vt=e=>e.map(Ps);function so(e,t){let n=r=>JSON.stringify(r.map(i=>[i.id,i.qty]).sort(([i],[s])=>i<s?-1:i>s?1:0));return n(e)===n(t)}function co(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=>Ft([{partNumber:n.partNumber,wheels:n.quantity,prices:{}}],1)),currency:e.currency,idempotencyKey:e.idempotencyKey,shippingMethodId:e.shippingMethodId,couponCode:e.couponCode}}function qn(e){return{...co(e),payFirst:!!e.checkoutFlow}}function lo(e){return co(e)}var Ns={lastPress:null,keptCardKey:null,placedShape:null,placedRequest:null,unpaidOrder:null};function _n(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 Fn(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 Mn(e){return e.lastPress!==null||e.unpaidOrder!==null||e.keptCardKey!==null}function ws(e){let t=e.parkedAt+Cs,n=e.press.unpaidOrder,r=n&&!n.orderNumber?n.expiresAt:null,i=r?Date.parse(r):NaN;return Number.isNaN(i)?t:Math.min(t,i)}function uo(e){try{let t={...e,lines:Vt(e.lines),press:mo(e.press)};qe.setItem(Tn,JSON.stringify({v:io,...t}))}catch{}}var $e=e=>!!e&&typeof e=="object"&&!Array.isArray(e),po=e=>$e(e)&&typeof e.idempotencyKey=="string"&&Array.isArray(e.items)&&e.items.every(t=>$e(t)&&typeof t.partNumber=="string"&&typeof t.quantity=="number")&&$e(e.customer)&&typeof e.payFirst=="boolean",In=e=>$e(e)&&typeof e.id=="string"&&typeof e.qty=="number"&&Array.isArray(e.components);function Ss(e){return $e(e)&&typeof e.key=="string"&&po(e.request)&&Array.isArray(e.lines)&&e.lines.every(In)&&Array.isArray(e.plainLines)&&e.plainLines.every(In)?{key:e.key,request:e.request,lines:Vt(e.lines),goods:typeof e.goods=="string"?e.goods:"",plainPressed:e.plainPressed===!0,plainLines:Vt(e.plainLines),plainGoods:typeof e.plainGoods=="string"?e.plainGoods:""}:null}var no=e=>typeof e=="string"?e:null,ro={lastPress:Ss,keptCardKey:no,placedShape:no,placedRequest:e=>po(e)?e:null,unpaidOrder:e=>$e(e)?Fn(e):null};function mo(e){let t=$e(e)?e:{},n={...Ns};for(let r of Object.keys(ro))n[r]=ro[r](t[r]);return n}function fo(){let e;try{e=qe.getItem(Tn)}catch{return null}if(!e)return null;try{let t=JSON.parse(e);if(t.v!==io||typeof t.key!="string"||!t.key||!Array.isArray(t.lines)||!t.lines.every(In)||typeof t.parkedAt!="number")return null;let n={key:t.key,authed:t.authed===!0,parkedAt:t.parkedAt,press:mo(t.press),lines:Vt(t.lines),form:t.form&&typeof t.form=="object"?_n(t.form):null};return Date.now()>=ws(n)?(Kn(),null):Mn(n.press)?n:null}catch{return null}}function Kn(){try{qe.removeItem(Tn)}catch{}}import{jsx as ve}from"react/jsx-runtime";function go(e){let t=e.indexOf(`
|
|
3
|
+
`);return t===-1?[e,""]:[e.slice(0,t),e.slice(t+1)]}function ho(e,{canParkContext:t}={canParkContext:!0}){let n=e.paymentMethods,r=[];return n.includes("card")&&r.push({key:"card",title:"Card",body:null,price:ve("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:ve("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:ve("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:ve("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:ve("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:ve("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:ve("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY LATER"})}),n.includes("worldpay")&&r.push({key:"worldpay",title:"Visa / Mastercard / American Express",body:null,price:ve("span",{className:"font-mono text-xs uppercase tracking-[0.2em] text-accent",children:"VIA WORLDPAY"})}),n.includes("bank")&&r.push({key:"bank",title:"Bank transfer",body:null,price:ve("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Invoiced"})}),r}var Co="This shop does not take payment online yet. Please contact the shop to order.",at=class extends Error{};function bo(e,t){if(!e.orderNumber&&zt(t))return t.message;let n=t instanceof de?` (${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 Os=3e3,As=.005,vo=new Set(["paypal","square","afterpay","gocardless","zip","klarna","worldpay"]);function xo(){let e=ta();return{...e==="denied"?{}:Ba(),...e?{adConsent:e}:{}}}var xe=e=>JSON.parse(e),Ls={lastPress:null,keptCardKey:null,placedShape:null,placedRequest:null,unpaidOrder:null},Is={lastPress:e=>e&&{key:e.key,request:qn(e.request),lines:e.lines,goods:xe(e.shape)[0],plainPressed:!!e.plainMethod,plainLines:e.plainLines,plainGoods:xe(e.plainShape)[0]},keptCardKey:e=>e,placedShape:e=>e===null?null:xe(e)[0],placedRequest:e=>e&&qn(e.body),unpaidOrder:e=>e&&Fn(e)};function ko(e,t){let n={};for(let r of Object.keys(e))n[r]=e[r](t[r]);return n}var Po="Shipping cannot be calculated right now. Please try again.";function No(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 Ts({site:e,logo:t,signInHref:n=null,preview:r=!1,textCase:i}){let{items:s,basketRead:d,totals:p,coupon:m,refuseCoupon:f,deliveryOptions:h,shippingMethodId:g,setShippingMethodId:b,setQuoteDestination:x,courier:E,requote:C,identify:O,clearCapturedCart:G,replaceItems:R,removeCoupon:w,applyCoupon:I}=Dt(),Q=h.find(a=>a.id===g)?.pickupLocation??null,{country:ce,countries:oe,activeCountry:ke,formatMoney:Ne}=be(),[$,ye]=N(()=>ho(e)[0]?.key??null),[we,Fe]=N(!0);H(()=>{Fe(qr(qe))},[]);let[V,ee]=N(!1),[k,J]=N(""),[le,W]=N(""),[Se,te]=N(""),[Ee,Me]=N(""),[Re,q]=N(""),[ie,Ke]=N(""),[ge,Oe]=N(""),[Ae,st]=N(""),[ze,ct]=N(""),[Y,lt]=N(()=>ce||oe[0]?.code||""),[Ce,Pt]=N(""),[ut,Yn]=N([]),[en,tn]=N(null),[Nt,Ge]=N(null),$n=yo(()=>oe.find(a=>a.code===Y)??ke,[oe,Y,ke]),Uo=$n?.postalLabel||"Postal Code",jo=ut[0]?.divisionType||"State / Province";H(()=>{if(!Y){Yn([]),tn(Y);return}tn(null);let a=!1;return K.listCountrySubdivisions(Y).then(l=>{a||(Yn(l),tn(Y),Pt(""))}),()=>{a=!0}},[Y]);let Bn=Re.trim()!==""&&ge.trim()!==""&&Ae.trim()!==""&&en===Y&&(ut.length===0||Ce!=="")?Ae.trim():"";H(()=>{x(Y?{country:Y,subdivision:Ce,postcode:Bn}:null)},[Y,Ce,Bn,x]),H(()=>()=>x(null),[x]);let Wo=E?.status==="unavailable",Yo=C,[dt,Hn]=N(null),[$o,zn]=N([]),[nn,wt]=N("new"),[Gn,Vn]=N(!1),[rn,Bo]=N("Home"),[Ho,Jn]=N(null),[zo,an]=N(null),[De,St]=N(()=>xt()),Xn=B(null),[on,Ve]=N(null),[Go,se]=N(null),[Zn,Et]=N(null),[Qn,Vo]=N(!1),[er,Jo]=N(!1),[Le,Je]=N(null),[Xo,Rt]=N(!1),[X,ue]=N(null),tr=!!X?.orderNumber,Zo=tr||V,[Qo,ei]=N(null),[ti,ni]=N(!1),[ri,ai]=N(!1),[oi,ii]=N(!1),[si,ci]=N(!1),[li,ui]=N(!1),[nr,di]=N(!1),[pi,sn]=N(!1),[pt,rr]=N(null),A=B({...Ls});A.current.unpaidOrder=X;let cn=B(!1),Ue=B(s),ar=!!(on||pt&&pt.kind!=="processing"||nr||Qn||er||Zn&&Le?.orderNumber);H(()=>{ar&&(R([]),w())},[ar,R,w]);let or=B(!1);H(()=>{r||or.current||!s.some(vt)||(or.current=!0,Dr({lines:s,currency:p.currency,value:p.subtotal-p.discount,coupon:m?.valid?m.code:void 0}))},[s,p,m,r]),H(()=>{O(k,le.trim()||void 0)},[k,le,O]);let ir=B(null),[Ot,mi]=N(null);H(()=>{let a=ir.current;if(!Ot||!a)return;let l=()=>a.style.setProperty("--sf-checkout-header-h",`${Ot.offsetHeight}px`);l();let y=new ResizeObserver(l);return y.observe(Ot),()=>y.disconnect()},[Ot]),H(()=>{let a=y=>({setConfirming:y,land:Ve,markPaid:()=>Rt(!0),note:(S,u)=>ei({text:S,warning:u}),fail:se,clearCart:G,lostChange:()=>an(Ht)}),l={search:window.location.search,storage:qe,scrubQuery:()=>window.history.replaceState(null,"",window.location.pathname)};rt(Ja,{...l,capture:K.captureAfterpayPayment,page:a(ni)}),rt(Xa,{...l,capture:K.captureZipPayment,page:a(ii)}),rt(Qa,{...l,capture:K.completeGocardlessPayment,page:a(ai)}),rt(eo,{...l,capture:K.captureKlarnaPayment,page:a(ci)}),rt(Za,{...l,capture:K.confirmWorldpayPayment,page:a(ui)})},[]);function sr(a){let[l,y]=go(a.address);q(l),Ke(y),Oe(a.city),st(a.zip_code),a.country&<(a.country),a.phone&&ct(a.phone),Ge({country:a.country||null,state:a.state??""})}H(()=>{if(Nt){if((Nt.country||Y)!==Y){Ge(null);return}en===Y&&(Pt(to(Y,Nt.state,ut)),Ge(null))}},[Nt,Y,en,ut]),H(()=>{let a=!1;return(async()=>{try{let[l,y,S]=await Promise.all([tt.me(),tt.myProfile().catch(()=>null),tt.myAddresses().catch(()=>[])]);if(a)return;Hn(l);let u=S.filter(M=>M.is_active);zn(u),J(l.email);let L=(y?.contact_name??"").split(/\s+/);W(l.first_name||L[0]||""),te(l.last_name||L.slice(1).join(" "));let F=l.phone||y?.phone;F&&ct(F);let _=u.find(M=>M.id===l.default_delivery_location)??u[0];if(_)wt(_.id),sr(_);else if(y){let[M,et]=go(y.address??"");q(M),Ke(et),Oe(y.city??""),st(y.zip_code??""),y.country&<(y.country),Ge({country:y.country||null,state:y.state??""})}_t.current&&fr(_t.current,!1)}catch{}})(),()=>{a=!0}},[]);function fi(){tt.logout(),ft.current=!0,_t.current=null,qt.current=null,yt(),Hn(null),zn([]),wt("new"),Vn(!1),J(""),W(""),te(""),Me(""),q(""),Ke(""),Oe(""),st(""),ct(""),lt(ce||oe[0]?.code||""),Pt(""),Ge(null)}let Xe=yo(()=>ho(e,{canParkContext:we}),[e,we]);H(()=>{Xe.some(a=>a.key===$)||ye(Xe[0]?.key??null)},[Xe,$]);let yi=Xe.length===0,At=ie.trim()?`${Re}
|
|
4
|
+
${ie.trim()}`:Re,gi=Ua({email:k,firstName:le,lastName:Se,company:Ee.trim(),phone:ze,address:At,city:ge,subdivision:Ce,postcode:Ae,country:Y,lines:s.map(a=>[a.id,a.qty]),shippingMethodId:g,couponCode:hn(m),currency:p.currency,shopperId:dt?.id??null}),re=JSON.stringify([gi,$]),ln=B(null),Lt=B(!1),Ie=B(!1),Ze=B(null),It=B(!1),he=B(re);he.current=re;let cr=B(V);cr.current=V;let Tt=B(null);H(()=>{let a=()=>{let l=Tt.current;l&&(Tt.current=null,ue(l),ee(!1))};return window.addEventListener("pageshow",a),()=>window.removeEventListener("pageshow",a)},[]);function mt(a,l,y,S){let u={idempotencyKey:l,confirmation:y};xr()&&(u.lostChange=!0),qe.setItem(a,JSON.stringify(u)),window.location.assign(S),Tt.current=y}async function lr(a){ee(!0);try{await a()}finally{Tt.current||ee(!1)}}let ur=B(!1),dr=!!(on||pt&&pt.kind!=="processing");H(()=>{dr&&(ur.current=!0,yt())},[dr]);let qt=B(null),ft=B(!1),un=B(null);function yt(){un.current=null,Kn()}let _t=B(null),[Qe,hi]=N(!1);function dn(a){if(ur.current||r||ft.current)return;let l={key:a,authed:cn.current,parkedAt:un.current??=Date.now(),press:ko(Is,A.current),lines:s.length>0?s:Ue.current,form:_n({email:k,firstName:le,lastName:Se,company:Ee,address1:Re,address2:ie,city:ge,postcode:Ae,phone:ze,country:Y,subdivision:Ce,selectedAddressId:nn,shippingMethodId:g,couponCode:m?.valid?m.code:null})};Mn(l.press)?uo(l):yt()}let pr=B($);pr.current=$;function pn(a){return{...lo(a),...xo(),...a.payFirst?{checkoutFlow:Bt}:{}}}function bi(a,l){let y=a.request.payFirst?"":null,S=a.plainPressed?null:"",u=()=>pr.current??"";return{key:a.key,send:()=>l(pn(a.request)),request:pn(a.request),lines:a.lines,shape:JSON.stringify([a.goods,null]),get method(){return y??u()},set method(L){y=L},get plainMethod(){return S??u()},set plainMethod(L){S=L},plainLines:a.plainLines,plainShape:JSON.stringify([a.plainGoods,null])}}let[vi,xi]=N(!1),mr=vi?!p.quoted||p.serverSubtotal===null?"waiting":Math.abs(p.serverSubtotal-p.subtotal)<As?"same":"changed":null,mn=!X&&mr==="waiting",ki=mn?{...p,repricing:!0}:p,fn=mn&&p.quoteFailed;H(()=>{if(!fn)return;let a=setInterval(C,Os);return()=>clearInterval(a)},[fn,C]);let Ci=C;function fr(a,l=!0){J(a.email),W(a.firstName),te(a.lastName),Me(a.company),q(a.address1),Ke(a.address2),Oe(a.city),st(a.postcode),ct(a.phone),a.country&<(a.country),Ge({country:a.country||null,state:a.subdivision}),wt(a.selectedAddressId),a.shippingMethodId&&b(a.shippingMethodId),l&&(qt.current=a.couponCode)}H(()=>{let a=r?null:fo(),l=!!(a&&s.length>0);if(a&&l&&!so(a.lines,s)&&(yt(),a=null),a){let y=a.authed?K.createOrderAuthed:K.createOrder;St(a.key),un.current=a.parkedAt,cn.current=a.authed;let S={lastPress:u=>u&&bi(u,y),keptCardKey:u=>u,placedShape:u=>u===null?null:JSON.stringify([u,null]),placedRequest:u=>{if(!u)return null;let L=pn(u);return{body:L,send:()=>y(L)}},unpaidOrder:u=>u};A.current=ko(S,a.press),a.press.unpaidOrder&&ue(a.press.unpaidOrder),a.lines.length>0&&!l&&(R(a.lines),Ue.current=a.lines,xi(!0)),a.form&&(_t.current=a.form,fr(a.form))}hi(!0)},[]),H(()=>{!Qe||s.length>0||A.current.unpaidOrder||V||(ft.current=!0,yt())},[Qe,s.length]),H(()=>{let a=qt.current;!Qe||!a||s.length===0||(qt.current=null,I(a,k||void 0))},[Qe,s.length]),H(()=>{!Qe||V||dn(De)},[Qe,V,De,X]);let je=B(null);H(()=>{cr.current||(re!==je.current&&(je.current=null),!(!Ie.current||!X||X.orderNumber)&&(re===A.current.placedShape||re===je.current||lr(()=>yr(X))))},[re,X]);async function yr(a){if(It.current)return null;It.current=!0;try{let l=Ze.current?await Ma(Ze.current):"none";if(l==="succeeded"||l==="processing")return Ie.current=!1,ue(null),Pe("card"),l==="succeeded"?await We(void 0,a):wr(a),null;if(l===void 0||!Ka.has(l))return je.current=he.current,ue(a),se(l==="requires_action"?_a:_e),null;let y=await Nn(De);if(y==="committed")return Ie.current=!1,ue(null),Pe("card"),await We(void 0,a),null;if(y!=="released")return je.current=he.current,ue(a),se(_e),null;Ie.current=!1,Ze.current=null,je.current=null,se(null),ue(null);let S=xt();return St(S),S}finally{It.current=!1}}async function Pi(){r||V||It.current||await lr(Ni)}async function Ni(){if(X){if((Ie.current?re!==A.current.placedShape:gt())&&!X.orderNumber){let S=await yr(X);S&&he.current===re&&await gr(S);return}se(null),Lt.current=!1,await yn();let l=xe(he.current)[1],y=X.orderNumber?l:"card";if(y&&vo.has(y)&>()&&xe(he.current)[0]!==ln.current){hr(X);return}Pe(y),y!==$&&ye(y),await Sr(X,y,!X.orderNumber);return}await gr(De)}async function gr(a){if(s.length===0||p.repricing||mn||!$||!Xe.some(F=>F.key===$))return;let l=s.filter(vt).flatMap(F=>Ft(F.components,F.qty));if(l.length===0){se("Pick a size on each wheel's product page before checking out.");return}se(null);let y,S=a,u=$,L=!1;try{let F=dt?K.createOrderAuthed:K.createOrder,_={customer:{email:k,name:`${le} ${Se}`.trim(),phone:ze.trim()||void 0,companyName:Ee.trim()||void 0,address:At,city:ge,state:Ce||void 0,zipCode:Ae,country:Y},items:l,currency:p.currency,idempotencyKey:a,shippingMethodId:g??void 0,couponCode:hn(m),...xo(),...Ta($)?{checkoutFlow:Bt}:{}};A.current.placedRequest={body:_,send:()=>F(_)},cn.current=!!dt,ft.current=!1,an(null),ln.current=null,Lt.current=!1,Ze.current=null,Ie.current=!1,je.current=null,A.current.placedShape=re,Ue.current=s;let M=A.current.lastPress,et=M?.key===_.idempotencyKey&&(M.shape!==re&&(!!_.checkoutFlow||!!M.method||!!M.plainMethod)||!!_.checkoutFlow&&!!M.plainMethod);et&&(A.current.keptCardKey=_.idempotencyKey);let Or=Cr(_,F),Ar=et||!_.checkoutFlow&&A.current.keptCardKey===_.idempotencyKey,Lr=!Or&&!Ar&&!_.checkoutFlow&&!!M&&!M.method;Lr&&(M.plainMethod=$,M.plainLines=s,M.plainShape=re,dn(_.idempotencyKey));let Ye=await(Ar?vr(_,F):F(_).then(ht=>({answer:ht,request:_})).catch(ht=>(Or?br(ht,_.idempotencyKey):Lr&&Sn(ht)&&(M.plainMethod=""),wi(ht,_,F))));if(!Ye)return;y=Ye.answer,S=Ye.request.idempotencyKey,u=Ye.method??u,Pe(u),L=gt()||u!==xe(he.current)[1],Ye.method&&Ye.method!==$&&ye(Ye.method),y.orderNumber&&(Pr(y),G()),await yn()}catch(F){let _=Kr(F);_?(f(_),se(`${_} Your order has not been placed. Place it again to continue without the code.`)):F instanceof at?se(_e):se(F instanceof de?F.message:"Could not place the order. Please try again.");return}if(u&&vo.has(u)&&(L||gt())){hr(y);return}await Sr(y,u,!1,S)}function hr(a){ln.current=xe(he.current)[0],se(`${bo(a,null)} ${Ht}`),ue(a)}function br(a,l){Sn(a)&&!wn(a)&&A.current.lastPress?.key===l&&(A.current.lastPress=null)}async function wi(a,l,y){if(zt(a))return kr(l,y);if(!wn(a))throw a;return A.current.keptCardKey=l.idempotencyKey,vr(l,y,!0)}async function vr(a,l,y=!1){let S=await Nn(a.idempotencyKey);if(S==="released")return kr(a,l);if(S!=="committed")throw new at;let u=A.current.lastPress?.key===a.idempotencyKey?A.current.lastPress:null;if(Ue.current=u?.lines??s,u?.method&&!y){A.current.keptCardKey=null,A.current.placedRequest={body:u.request,send:u.send};let et=await u.send().catch(()=>{throw new at});return A.current.placedShape=u.shape,{answer:et,request:a,method:u.method}}let L={...a,checkoutFlow:Bt},F=u&&!u.method?{body:u.request,send:u.send}:{body:L,send:()=>l(L)};A.current.placedRequest=F;let _=F.send,M=await _().catch(()=>null);if(!M&&u?.plainMethod)throw new at;return M?.orderNumber&&M.status!==qa?(A.current.keptCardKey=null,u?.plainMethod&&(Ue.current=u.plainLines),u&&(A.current.placedShape=u.plainMethod?u.plainShape:u.shape),{answer:M,request:a,method:u?.plainMethod||void 0}):(u&&(A.current.placedShape=u.shape),Pe("card"),await Nr("",M?async()=>M:()=>Promise.reject(new Error("The order request did not answer."))),await yn(),null)}function gt(){let a=A.current.placedShape;return a!==null&&xe(a)[0]!==xe(he.current)[0]}function Pe(a){a!==xe(he.current)[1]&&(Lt.current=!0),an(xr()?Ht:null)}function xr(){return Lt.current||gt()}async function kr(a,l){let y={...a,idempotencyKey:xt()};A.current.keptCardKey=null,St(y.idempotencyKey),A.current.placedRequest={body:y,send:()=>l(y)},Cr(y,l);try{return{answer:await l(y),request:y}}catch(S){throw br(S,y.idempotencyKey),S}}function Cr(a,l){return A.current.lastPress?.key===a.idempotencyKey?!1:(A.current.lastPress={key:a.idempotencyKey,send:()=>l(a),request:a,lines:s,shape:re,method:a.checkoutFlow?"":$??"",plainMethod:"",plainLines:s,plainShape:re},ft.current=!1,dn(a.idempotencyKey),!0)}function Pr(a){Ur({confirmation:a,lines:Ue.current,adsSendTo:e.googleAdsId&&e.googleAdsConversionLabel?`${e.googleAdsId}/${e.googleAdsConversionLabel}`:null}),Va({confirmation:a,lines:Ue.current})}async function We(a,l=Le){if(!l)return;let y=a?async()=>a:A.current.placedRequest?.send;if(l.orderNumber||!y){Rt(!0),Ve(l);return}await Nr(l.checkoutNumber,y)}async function Nr(a,l){G(),await ja({checkoutNumber:a,resend:l,page:{setConfirming:di,land:Ve,markPaid:()=>Rt(!0),track:Pr,unplaced:rr}})}function wr(a=Le){if(a){if(a.orderNumber){Ve(a);return}G(),rr({kind:"processing",checkoutNumber:a.checkoutNumber})}}async function yn(){let a=JSON.stringify([rn.trim(),le,Se,ze.trim(),At,ge,Ce,Ae,Y]);if(!(!dt||!Gn||nn!=="new"||Xn.current===a))try{await tt.createAddress({label:rn.trim()||"Home",contact_name:`${le} ${Se}`.trim(),phone:ze.trim(),address:At,city:ge,zip_code:Ae,state:Ce,country:Y}),Xn.current=a,Jn("Address saved to your account.")}catch{Jn("We couldn't save the address to your account \u2014 you can add it under Account \u2192 Addresses.")}}async function Sr(a,l=$,y=!1,S=De){ue(null);try{if(l==="card"&&e.paymentMethods.includes("card")){let u=await K.createPaymentIntent({idempotencyKey:S});Ze.current=u;let L=a;if(y){let F=await A.current.placedRequest?.send().catch(()=>null);if(F?.orderNumber){Pe("card"),await We(F,a);return}L=Er(a,F)??{...a,expiresAt:null}}Pe("card"),Je(L),sn(!1),Et(u)}else if(l==="paypal"&&e.paymentMethods.includes("paypal"))Je(a),Vo(!0);else if(l==="afterpay"&&e.paymentMethods.includes("afterpay")){let u=window.location.origin,L=await K.createAfterpayCheckout({idempotencyKey:S,confirmUrl:`${u}/checkout?afterpay=confirm`,cancelUrl:`${u}/checkout?afterpay=cancel`});mt(En,S,a,L.redirectCheckoutUrl);return}else if(l==="square"&&e.paymentMethods.includes("square"))Je(a),Jo(!0);else if(l==="gocardless"&&e.paymentMethods.includes("gocardless")){let u=window.location.origin,L=await K.createGocardlessBillingRequest({idempotencyKey:S,confirmUrl:`${u}/checkout?gocardless=confirm`,cancelUrl:`${u}/checkout?gocardless=cancel`});mt(Rn,S,a,L.authorisationUrl);return}else if(l==="zip"&&e.paymentMethods.includes("zip")){let u=window.location.origin,L=await K.createZipCheckout({idempotencyKey:S,redirectUrl:`${u}/checkout?zip=return`});mt(On,S,a,L.redirectUrl);return}else if(l==="klarna"&&e.paymentMethods.includes("klarna")){let u=window.location.origin,L=await K.createKlarnaCheckout({idempotencyKey:S,confirmUrl:`${u}/checkout?klarna=confirm`,cancelUrl:`${u}/checkout?klarna=cancel`});mt(An,S,a,L.redirectUrl);return}else if(l==="worldpay"&&e.paymentMethods.includes("worldpay")){let u=window.location.origin,L=await K.createWorldpayCheckout({idempotencyKey:S,successUrl:`${u}/checkout?worldpay=return`,cancelUrl:`${u}/checkout?worldpay=cancel`});mt(Ln,S,a,L.redirectUrl);return}else Pe(l),Ve(a)}catch(u){if((y||l==="card")&&u instanceof de&&u.status===409){Pe(l),await We(void 0,a);return}Rr(a,u)}}function Er(a,l){return l&&!l.orderNumber&&l.status==="open"&&l.checkoutNumber===a.checkoutNumber?l:null}function Rr(a,l){se(bo(a,l)),!a.orderNumber&&zt(l)?(Ie.current=!1,St(xt())):ue(a)}async function Si(a){if(!Le)return;let l=Le;try{let y=await K.createPaymentIntent({idempotencyKey:De}),S=await A.current.placedRequest?.send().catch(()=>null);if(S?.orderNumber){await We(S);return}let u=Er(l,S);Je(u??{...l,expiresAt:null}),sn(a&&u!==null),Ze.current=y,Et(y)}catch(y){if(y instanceof de&&y.status===409){await We();return}Et(null),Je(null),Rr(l,y)}}function Ei(){Le&&(Ie.current=!0,ue(Le),Et(null),Je(null),sn(!1))}return{site:e,logo:t,signInHref:n,capitalised:Vr(i)==="capitalised",items:s,totals:ki,coupon:m,deliveryOptions:h,courierUnavailable:Wo,retryCourier:Yo,shippingMethodId:g,setShippingMethodId:b,pickupLocation:Q,servedCountries:oe,formatMoney:Ne,payChoice:$,setPayChoice:ye,placing:V,email:k,setEmail:J,firstName:le,setFirstName:W,lastName:Se,setLastName:te,company:Ee,setCompany:Me,address1:Re,setAddress1:q,address2:ie,setAddress2:Ke,city:ge,setCity:Oe,postcode:Ae,setPostcode:st,phone:ze,setPhone:ct,country:Y,setCountry:lt,subdivision:Ce,setSubdivision:Pt,subdivisions:ut,destination:$n,postcodeLabel:Uo,subdivisionLabel:jo,me:dt,savedAddresses:$o,selectedAddressId:nn,setSelectedAddressId:wt,saveAddress:Gn,setSaveAddress:Vn,saveLabel:rn,setSaveLabel:Bo,addressSaveNote:Ho,lostChangeNote:zo,idemKey:De,confirmation:on,setConfirmation:Ve,orderError:Go,payment:Zn,paypalStep:Qn,squareStep:er,pendingConf:Le,paid:Xo,setPaid:Rt,unpaidOrder:X,orderLocked:tr,formLocked:Zo,restoredPrices:mr,basketRead:d,quoteFailed:fn,retryQuote:Ci,payNote:Qo,afterpayConfirming:ti,gocardlessConfirming:ri,zipConfirming:oi,klarnaConfirming:si,worldpayConfirming:li,cardConfirming:nr,checkoutResult:pt,confirmCardPayment:We,cardStillProcessing:wr,renewCardPayment:Si,holdRenewed:pi,leaveCardPayment:Ei,checkoutRootRef:ir,setCheckoutHeaderEl:mi,fillFromAddress:sr,checkoutSignOut:fi,payOptions:Xe,noPaymentMethod:yi,placeOrder:Pi}}var wo=Es(null);function So({children:e,...t}){let n=Ts(t);return ve(wo.Provider,{value:n,children:e})}function me(){let e=Rs(wo);if(!e)throw new Error("useCheckout must be used inside CheckoutStateProvider");return e}import{useId as Dn}from"react";import{Fragment as fe,jsx as o,jsxs as P}from"react/jsx-runtime";var qs="Loading your order",Eo=["py-8","text-center","font-serif","text-[16px]","italic","leading-[1.5]","text-fg-dim"].join(" ");function Ao(){let{email:e,setEmail:t,firstName:n,setFirstName:r,lastName:i,setLastName:s,company:d,setCompany:p,me:m,signInHref:f,checkoutSignOut:h,orderLocked:g,unpaidOrder:b}=me(),x=Dn();return P(Zt,{num:1,title:"Contact",children:[g&&b&&o(Fs,{orderNumber:b.orderNumber}),o(ae,{label:"Email",htmlFor:x,hint:m?P(fe,{children:["Signed in \xB7"," ",o("button",{type:"button",onClick:h,className:"underline transition-colors enabled:hover:text-accent",children:"Not you? Sign out"})]}):f?P(fe,{children:["Have an account?"," ",o(ot,{href:f,className:"underline transition-colors hover:text-accent",children:"Sign in"})]}):void 0,children:o("input",{id:x,type:"email",value:e,onChange:E=>t(E.target.value),placeholder:"you@example.com",readOnly:m!==null,className:ne})}),P(_o,{children:[o(ae,{label:"First name",children:o("input",{type:"text",value:n,onChange:E=>r(E.target.value),className:ne})}),o(ae,{label:"Last name",children:o("input",{type:"text",value:i,onChange:E=>s(E.target.value),className:ne})})]}),o(ae,{label:"Company (optional)",children:o("input",{type:"text",value:d,onChange:E=>p(E.target.value),autoComplete:"organization",className:ne})})]})}function Lo(){let{pickupLocation:e,servedCountries:t,address1:n,setAddress1:r,address2:i,setAddress2:s,city:d,setCity:p,postcode:m,setPostcode:f,phone:h,setPhone:g,country:b,setCountry:x,subdivision:E,setSubdivision:C,subdivisions:O,destination:G,postcodeLabel:R,subdivisionLabel:w,me:I,savedAddresses:Q,selectedAddressId:ce,setSelectedAddressId:oe,saveAddress:ke,setSaveAddress:Ne,saveLabel:$,setSaveLabel:ye,fillFromAddress:we,orderLocked:Fe}=me(),V=Dn(),ee=Dn();return P(Zt,{num:2,title:e?"Collection":"Shipping address",children:[e?P("div",{className:"grid gap-2 text-[14px] leading-[1.6]",children:[o("span",{className:"font-medium",children:e.name}),[e.address,e.city,e.state,e.zipCode,e.country].filter(Boolean).length>0&&o("span",{className:"opacity-80",children:[e.address,e.city,e.state,e.zipCode,e.country].filter(Boolean).join(", ")}),e.openingHours&&o("span",{className:"opacity-80",children:e.openingHours}),e.readyIn&&o("span",{className:"opacity-80",children:e.readyIn}),e.instructions&&o("span",{className:"opacity-80",children:e.instructions}),o("span",{className:"mt-1 font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"No delivery address needed"})]}):P(fe,{children:[I!==null&&Q.length>0&&P("div",{className:"grid gap-3",children:[Q.map(k=>o(Jt,{active:ce===k.id,onClick:()=>{oe(k.id),we(k)},title:k.label,body:k.formatted_address,price:null},k.id)),o(Jt,{active:ce==="new",onClick:()=>oe("new"),title:"New address",body:null,price:null})]}),o(ae,{label:"Address line 1",children:o("input",{type:"text",value:n,onChange:k=>r(k.target.value),className:ne})}),o(ae,{label:"Address line 2",children:o("input",{type:"text",value:i,onChange:k=>s(k.target.value),placeholder:"Apartment, unit, garage bay\u2026",className:ne})}),P(_o,{cols:"three",children:[o(ae,{label:"City",children:o("input",{type:"text",value:d,onChange:k=>p(k.target.value),className:ne})}),o(ae,{label:R,children:o("input",{type:"text",value:m,onChange:k=>f(k.target.value),className:ne})}),o(ae,{label:"Country",separate:!0,htmlFor:V,children:o(vn,{id:V,value:b,onChange:k=>x(k.target.value),className:ne+" pr-10",style:Ro,children:t.map(k=>o("option",{value:k.code,children:k.name},k.code))})})]}),o(ae,{label:w,separate:!0,htmlFor:ee,children:O.length>0?P(vn,{id:ee,value:E,onChange:k=>C(k.target.value),className:ne+" pr-10",style:Ro,children:[o("option",{value:"",children:"Select\u2026"}),O.map(k=>o("option",{value:k.code||k.name,children:k.name},k.code||k.name))]}):o("input",{id:ee,type:"text",value:E,onChange:k=>C(k.target.value),className:ne})})]}),o(ae,{label:"Phone",children:o("input",{type:"tel",value:h,onChange:k=>g(k.target.value),className:ne})}),!e&&I!==null&&ce==="new"&&!Fe&&P(fe,{children:[o(Ms,{checked:ke,onChange:Ne,label:"Save this address to my account"}),ke&&o(ae,{label:"Address label",children:o("input",{type:"text",value:$,onChange:k=>ye(k.target.value),placeholder:"Home",className:ne})})]})]})}function Io(){let{totals:e,coupon:t,deliveryOptions:n,shippingMethodId:r,setShippingMethodId:i,pickupLocation:s,formatMoney:d,city:p,destination:m,courierUnavailable:f,retryCourier:h}=me();return o(Zt,{num:3,title:"Shipping",children:P("div",{className:"grid gap-3",children:[n.map(g=>{let b=g.pickupLocation,x=b?[b.address,b.city,b.state,b.zipCode].filter(Boolean).join(", "):null;return o(Jt,{active:r===g.id,onClick:()=>i(g.id),title:b?`${g.name} \u2014 ${b.name}`:g.name,body:b?[x,b.openingHours,b.readyIn,b.instructions,g.description].filter(Boolean).join(" \xB7 "):g.description||null,price:e.freeShipping||g.amount===0?Mt:e.deliveryDiscountPercent>0?P(fe,{children:[o("s",{className:"text-fg-dim",children:d(g.amount,e.currency)})," ",d(Wr(g.amount,e.deliveryDiscountPercent),e.currency)]}):d(g.amount,e.currency),tag:g.tag||void 0},g.id)}),f?P("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:[Po," ",o("button",{type:"button",onClick:h,className:"underline transition-colors enabled:hover:text-accent",children:"Try again"})]}):n.length===0&&o("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Shipping is arranged after your order is reviewed."})]})})}function To(){let{payChoice:e,setPayChoice:t,payment:n,payOptions:r,noPaymentMethod:i}=me();return P(Zt,{num:4,title:"Payment",children:[i&&o("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:Co}),o("div",{className:"grid gap-3",children:r.map(s=>o(Jt,{active:e===s.key,onClick:()=>t(s.key),title:s.title,body:s.body,price:s.price,tag:s.tag},s.key))}),e==="card"?o("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"?o("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"?o("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"?o("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"?o("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"?o("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"?o("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==="worldpay"?o("p",{className:"font-mono text-xs uppercase tracking-[0.2em] text-fg-dim",children:"You\u2019ll enter your card on Worldpay\u2019s secure page, then be brought straight back."}):e==="bank"?o("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 qo(){let{site:e,items:t,totals:n,coupon:r,formatMoney:i,payChoice:s,placing:d,email:p,orderError:m,payment:f,noPaymentMethod:h,unpaidOrder:g,formLocked:b,restoredPrices:x,basketRead:E,quoteFailed:C,retryQuote:O,placeOrder:G}=me(),R=x==="waiting"||!E,w=x==="changed";return P("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:[P("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:[o("span",{children:"Your order"}),o(ot,{href:"/wheels",className:"text-bg/80 transition-colors hover:text-bg",children:"Edit \u2197"})]}),o("div",{className:"flex flex-col px-6 py-2",children:E?t.length===0?P("div",{className:Eo,children:["Your cart is empty. ",o(ot,{href:"/wheels",className:"text-accent underline-offset-4 hover:underline",children:"Browse the catalog \u2192"})]}):t.map(I=>o(Ks,{slug:I.slug,name:I.name,qty:I.qty,config:I.config,configSummary:Ds(I.config),price:w||R?null:Hr(I,n.currency)??0,currency:n.currency},I.id)):o("div",{role:"status",className:Eo,children:qs})}),o(Xt,{locked:b,className:"border-t border-line px-6 pt-5",children:o(Zr,{customerEmail:p,disabled:b})}),P("div",{className:"flex flex-col gap-2 border-t border-line mt-5 px-6 pt-5",children:[o(Be,{label:"Subtotal",value:R?Kt:i(w?n.serverSubtotal??0:n.subtotal,n.currency)}),(n.discount>0||n.deliverySaving>0)&&r?.valid&&o(Be,{label:`Coupon \xB7 ${r.code}`,value:o("span",{className:"font-semibold text-green",children:Yr(n,I=>i(I,n.currency))})}),r?.deferred&&o(Be,{label:`Coupon \xB7 ${r.code}`,value:Mr}),r?.valid&&r.effects?.gift&&o(Be,{label:`Free gift \xB7 ${r.effects.gift.partNumber}${r.effects.gift.quantity>1?` \xD7${r.effects.gift.quantity}`:""}`,value:o("span",{className:"font-semibold text-green",children:Mt})}),o(Be,{label:"Shipping",value:n.shippingStatus==="free"?o("span",{className:"font-semibold text-green",children:Mt}):$r(n.shippingStatus)??i(n.shipping,n.currency)}),n.tax&&(n.tax.charged?o(Be,{label:n.tax.inclusive?`${n.tax.name} included \xB7 ${n.tax.rate}%`:n.tax.name,value:i(n.tax.amount,n.currency)}):n.tax.name?o(Be,{label:n.tax.name,value:jr}):null)]}),P("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:[o("span",{className:"font-display text-[20px] font-bold uppercase tracking-[0.04em] text-fg",children:"Total"}),o("span",{className:"text-right font-display text-[34px] font-bold leading-none tracking-[-0.025em] text-fg",children:n.repricing||!E?Kt:i(n.grand,n.currency)})]}),P("div",{className:"flex flex-col gap-3 px-6 pt-5 pb-6",children:[w&&o(pe,{tone:"quiet",children:ao}),C&&P(pe,{role:"alert",children:[oo," ",o("button",{type:"button",onClick:O,className:"underline transition-colors enabled:hover:text-accent",children:"Try again"})]}),m&&o(pe,{role:"alert",children:m}),n.hasUnpricedLine&&P(pe,{role:"status",children:["One or more items have no price in ",n.currency,". Remove them, or switch region, to continue."]}),o("button",{type:"button",onClick:G,disabled:d||!g&&(h||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 max-[640px]:gap-3 max-[640px]:whitespace-nowrap max-[640px]:px-4 max-[640px]:text-xs max-[640px]:tracking-normal",d||!g&&(t.length===0||h||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?P(fe,{children:["Building order\u2026 ",o("span",{children:"\xB7"})]}):h?P(fe,{children:["No online payment ",o("span",{children:"\xB7"})]}):g?P(fe,{children:[P("span",{children:["Try payment again",P(Oo,{children:[" \xB7 ",Gt(g)]})]}),o("span",{className:"transition-transform group-hover:translate-x-1",children:"\u2192"})]}):C?P(fe,{children:["Total not confirmed ",o("span",{children:"\xB7"})]}):n.repricing||!E?P(fe,{children:[Kt," ",o("span",{children:"\xB7"})]}):P(fe,{children:[P("span",{children:[s==="bank"?"Place order":"Continue to payment",P(Oo,{children:[" \xB7 ",i(n.grand,n.currency)]})]}),P("span",{className:"flex items-center gap-3",children:[o("span",{"aria-hidden":"true",className:"max-[359px]:hidden min-[641px]:hidden",children:i(n.grand,n.currency)}),o("span",{className:"transition-transform group-hover:translate-x-1",children:"\u2192"})]})]})})]})]})}var _s=" [&:disabled_:disabled]:cursor-not-allowed! [&:disabled_:disabled]:opacity-70! [&_input[readonly]]:cursor-not-allowed [&_input[readonly]]:opacity-70";function Xt({locked:e,className:t="",children:n}){return o("fieldset",{disabled:e,className:"m-0 min-w-0 border-0 p-0 "+t+_s,children:n})}function ot({href:e,className:t="",children:n,...r}){let{placing:i}=me();return i?o("span",{"aria-disabled":"true","aria-label":r["aria-label"],className:t+" pointer-events-none",children:n}):o(Te,{href:e,"aria-label":r["aria-label"],className:t,children:n})}function Fs({orderNumber:e}){return o(pe,{tone:"quiet",role:"status",children:P("span",{className:"flex items-start gap-2",children:[P("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:[o("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1"}),o("path",{d:"M5 7V5a3 3 0 0 1 6 0v2"})]}),o("span",{children:No(e)})]})})}var Ro={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 Zt({num:e,title:t,children:n}){let{capitalised:r}=me();return P("section",{className:"mb-6 border border-line bg-bg",children:[P("header",{className:"flex items-center gap-4 border-b border-line bg-surface px-6 py-4",children:[o("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:r?String(e):`N\xB0 ${String(e).padStart(2,"0")}`}),o("h2",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:t})]}),o("div",{className:"flex flex-col gap-4 px-6 py-6",children:n})]})}function _o({cols:e="two",children:t}){return o("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 Jt({active:e,onClick:t,title:n,body:r,price:i,tag:s}){return P("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&&o("span",{"aria-hidden":!0,className:"absolute inset-y-0 left-0 w-[3px] bg-accent"}),o("span",{className:["flex h-[18px] w-[18px] items-center justify-center rounded-full border-2",e?"border-accent":"border-fg-dim"].join(" "),children:e&&o("span",{className:"block h-2.5 w-2.5 rounded-full bg-accent"})}),P("span",{className:"flex min-w-0 flex-col gap-1",children:[P("span",{className:"flex flex-wrap items-baseline gap-3 font-display text-[18px] font-medium tracking-[-0.01em] text-fg",children:[n,s&&o("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&&o("span",{className:"font-mono text-[12px] uppercase tracking-[0.22em] text-fg-dim",children:r})]}),o("span",{className:"whitespace-nowrap font-display text-[18px] font-medium tracking-[-0.01em] text-fg",children:i})]})}function Ms({checked:e,onChange:t,label:n,sub:r}){return P("div",{className:"flex items-start gap-3 border-t border-line py-4 first:border-t-0 first:pt-0",children:[o("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&&o("span",{className:"text-[13px] text-accent",children:"\u2713"})}),P("span",{className:"flex-1 font-display text-[16px] leading-[1.5] text-fg",children:[n,r&&o("small",{className:"mt-1 block font-mono text-[12px] uppercase tracking-[0.18em] text-fg-dim",children:r})]})]})}function Ks({slug:e,name:t,qty:n,config:r,configSummary:i,price:s,currency:d}){let{catalog:p}=Dt(),{formatMoney:m}=be(),f=p.find(C=>C.slug===e),h=f?.spokes??5,g=f?.mesh??!1,b=r.find(C=>C.gold)?.label,x=f?.finishes.find(C=>C.name===b&&C.src)??f?.finishes.find(C=>C.src),E=f?.finishes[0]?.color??Xr;return P("div",{className:"grid grid-cols-[60px_1fr_auto] items-center gap-4 border-b border-line py-4 last:border-b-0",children:[P("div",{className:"relative aspect-square",children:[o("div",{className:"flex h-full w-full items-center justify-center overflow-hidden border border-line bg-surface",children:x?.src?o(Ir,{src:x.src,alt:`${t.lead}${t.accent} \u2014 ${x.name}`,width:120,height:120,sizes:"60px",className:"block h-full w-full object-contain p-2"}):o("div",{className:"block w-[78%]",style:{color:E},children:o(Jr,{spokes:h,mesh:g,className:"block w-full"})})}),o("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})]}),P("div",{className:"flex min-w-0 flex-col gap-0.5",children:[P("span",{className:"font-display text-[17px] font-bold uppercase leading-none tracking-[-0.005em] text-fg",children:[t.lead,o("em",{className:"font-serif font-normal italic text-accent tracking-[-0.005em] normal-case",children:t.accent})]}),o("span",{className:"font-mono text-[12px] uppercase leading-[1.5] tracking-[0.18em] text-fg-dim",children:i})]}),o("span",{className:"text-right font-display text-[17px] font-bold tracking-[-0.005em] text-fg",children:s===null?null:m(s,d)})]})}function Oo({children:e}){return o("span",{className:"max-[640px]:sr-only",children:e})}function Be({label:e,value:t}){return P("div",{className:"flex items-center justify-between font-mono text-[13px] font-medium uppercase tracking-[0.18em] text-fg",children:[o("span",{children:e}),o("strong",{className:"font-display text-[16px] font-medium tracking-[-0.005em] normal-case text-fg",children:t})]})}function Ds(e){return e.map(t=>t.label).join(" \xB7 ")}import{Fragment as z,jsx as c,jsxs as v}from"react/jsx-runtime";function Wn(e){return c(So,{...e,children:c(Ws,{children:c(Bs,{})})})}function Ws({children:e}){let{capitalised:t}=me();return t?c("div",{"data-checkout-case":"capitalised",className:"contents",children:e}):c(z,{children:e})}function Ys({order:e,paid:t}){let{formatMoney:n}=be();if(!e.grandTotal||!e.currency)return null;let r=d=>n(Number(d),e.currency),i=Number(e.freightCharge??0),s=Number(e.discountAmount??0);return v("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||i>0)&&v(z,{children:[v("dt",{className:"text-fg-dim",children:["Delivery",e.shippingMethod?` \xB7 ${e.shippingMethod}`:""]}),c("dd",{className:"text-right font-mono",children:r(e.freightCharge??"0")})]}),s>0&&v(z,{children:[v("dt",{className:"text-fg-dim",children:["Discount",e.couponCode?` \xB7 ${e.couponCode}`:""]}),v("dd",{className:"text-right font-mono",children:["\u2212",r(e.discountAmount??"0")]})]}),c("dt",{className:"text-fg",children:t?"Total paid":"Order total"}),c("dd",{className:"text-right font-mono text-fg",children:r(e.grandTotal)})]})}function $s({result:e,lostChangeNote:t=null}){let n=c("span",{className:"font-mono text-fg",children:e.checkoutNumber});return v("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[c("h1",{className:"font-display text-3xl",children:e.kind==="refunded"||e.kind==="expired"?"Order not placed":e.kind==="processing"?"Payment processing":"Payment received"}),c("p",{className:"text-fg-dim",children:e.kind==="refunded"?v(z,{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"?v(z,{children:["The hold on checkout ",n," ran out before your payment arrived. Your payment goes back to your card."]}):e.kind==="processing"?v(z,{children:["Your payment for checkout ",n," is being processed. When it goes through, we will email your order confirmation."]}):v(z,{children:["Thank you \u2014 your payment",e.checkoutNumber?v(z,{children:[" for checkout ",n]}):null," has gone through. We will email you the order number shortly."]})}),t&&e.kind!=="refunded"&&e.kind!=="expired"&&c("p",{className:"text-sm text-fg-dim",children:t}),c(Te,{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 Bs(){let{site:e,logo:t,items:n,placing:r,formLocked:i,email:s,me:d,addressSaveNote:p,lostChangeNote:m,idemKey:f,confirmation:h,setConfirmation:g,payment:b,paypalStep:x,squareStep:E,pendingConf:C,paid:O,setPaid:G,payNote:R,afterpayConfirming:w,gocardlessConfirming:I,zipConfirming:Q,klarnaConfirming:ce,worldpayConfirming:oe,cardConfirming:ke,checkoutResult:Ne,confirmCardPayment:$,cardStillProcessing:ye,renewCardPayment:we,holdRenewed:Fe,leaveCardPayment:V,checkoutRootRef:ee,setCheckoutHeaderEl:k}=me();return h?v("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[c("h1",{className:"font-display text-3xl",children:O?"Payment received":"Order received"}),v("p",{className:"text-fg-dim",children:[O?v(z,{children:["Thank you \u2014 your payment for order"," ",c("span",{className:"font-mono text-fg",children:h.orderNumber})," has gone through."," "]}):v(z,{children:["Thank you \u2014 your order ",c("span",{className:"font-mono text-fg",children:h.orderNumber})," is being reviewed by our team."," "]}),d?v(z,{children:["Track it under"," ",c(Te,{href:"/account/orders",className:"text-accent underline",children:"your orders"}),"."]}):h.accountLinkSent?c(z,{children:"We\u2019ve emailed you a link to set a password and track it."}):v(z,{children:["Already have an account?"," ",c(Te,{href:"/login?next=%2Faccount%2Forders",className:"text-accent underline",children:"Sign in"})," ","to see it under your orders."]})]}),c(Ys,{order:h,paid:O}),m&&c("p",{className:"text-sm text-fg-dim",children:m}),R&&(R.warning?c("div",{className:"w-full max-w-sm text-left",children:c(pe,{tone:"bad",role:"alert",children:R.text})}):c("p",{className:"text-sm text-fg-dim",children:R.text})),p&&c("p",{className:"text-sm text-fg-dim",children:p}),!d&&v("p",{className:"text-sm text-fg-dim",children:["You can also"," ",c(Te,{href:`/track?order=${encodeURIComponent(h.orderNumber)}`,className:"text-accent underline",children:"track this order"})," ","anytime with just your order number and email \u2014 no password needed."]}),c(Te,{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"})]}):Ne?c($s,{result:Ne,lostChangeNote:m}):ke?v("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[c("h1",{className:"font-display text-3xl",children:"Confirming your payment\u2026"}),c("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Placing your order \u2014 one moment."})]}):w?v("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[c("h1",{className:"font-display text-3xl",children:"Confirming your payment\u2026"}),c("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Afterpay \u2014 one moment."})]}):I?v("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[c("h1",{className:"font-display text-3xl",children:"Setting up your direct debit\u2026"}),c("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Confirming with GoCardless \u2014 one moment."})]}):Q?v("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[c("h1",{className:"font-display text-3xl",children:"Confirming your payment\u2026"}),c("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Zip \u2014 one moment."})]}):ce?v("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[c("h1",{className:"font-display text-3xl",children:"Confirming your payment\u2026"}),c("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Klarna \u2014 one moment."})]}):oe?v("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[c("h1",{className:"font-display text-3xl",children:"Confirming your payment\u2026"}),c("p",{className:"font-mono text-xs uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Worldpay \u2014 one moment."})]}):b&&C?c(Hs,{payment:b,checkout:C,holdRenewed:Fe,onPaid:$,onProcessing:ye,onRenew:we,onBack:V}):x&&C?c(Js,{confirmation:C,clientId:e.paypalClientId??"",idemKey:f,onPaid:()=>{G(!0),g(C)},onSkip:()=>g(C)}):E&&C?c(Qs,{confirmation:C,applicationId:e.squareApplicationId??"",locationId:e.squareLocationId??"",environment:e.squareEnvironment??"production",idemKey:f,onPaid:()=>{G(!0),g(C)},onSkip:()=>g(C)}):v("div",{ref:ee,className:"bg-bg text-fg",children:[v("header",{ref:k,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:[v(ot,{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",c("span",{className:"max-[640px]:hidden",children:"Back to shop"})]}),c("div",{className:"flex min-w-0 justify-center max-[640px]:[container-type:inline-size]",children:c(ot,{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(J=>c(ea,{hideClass:J?"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:J,fitFloorPx:J?Qr:void 0},J?"phone":"wide"))})}),e.cardPayments?v("span",{className:"flex items-center justify-end gap-3 font-mono text-[12px] uppercase tracking-[0.26em] text-fg-dim",children:[c("span",{className:"text-green",children:"\u25CF"}),c("span",{className:"max-[640px]:hidden",children:"Encrypted \xB7"})," Stripe"]}):c("span",{})]}),v("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:[c("span",{className:"inline-flex items-center bg-accent px-3 py-1 font-bold text-bg",children:"Checkout"}),c("nav",{"aria-label":"Checkout steps",className:"flex flex-wrap items-center gap-5 max-[640px]:flex-nowrap max-[640px]:gap-3 max-[640px]:whitespace-nowrap max-[640px]:text-xs max-[640px]:tracking-[0.04em]",children:[{n:"01",label:"Cart",state:"done"},{n:"02",label:"Ship & pay",state:"active"},{n:"03",label:"Confirmed",state:"pending"}].map(J=>v("span",{className:["relative flex items-center gap-2 transition-colors",J.state==="pending"?"text-fg-dim":"text-fg",J.state==="active"?"font-bold after:absolute after:inset-x-0 after:-bottom-1 after:h-[2px] after:bg-accent":""].join(" "),children:[c("span",{className:J.state==="done"?"text-accent font-bold":"",children:J.n}),c("span",{children:J.label})]},J.n))})]}),v("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:[v("div",{children:[v(Xt,{locked:i,children:[c(Ao,{}),c(Lo,{}),c(Io,{})]}),c(Xt,{locked:r,children:c(To,{})})]}),c(qo,{})]}),c("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:c("span",{children:Gr({legalName:e.legalName,foundedYear:e.foundedYear,siteName:e.name})})})]})}function Hs({payment:e,checkout:t,holdRenewed:n,onPaid:r,onProcessing:i,onRenew:s,onBack:d}){let{formatMoney:p}=be(),m=c("span",{className:"text-fg",children:p(Number(e.amount),e.currency)}),f=Fo(()=>$t(e.publishableKey),[e.publishableKey]),h=Fo(()=>ra(),[]),g=na(t.expiresAt??"",Us()??"");return c("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:v("div",{className:"w-full max-w-xl border border-line bg-bg",children:[v("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-4",children:[c("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:Gt(t)}),c("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"Payment"})]}),v("div",{className:"flex flex-col gap-4 px-6 py-6",children:[c("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:t.orderNumber?v(z,{children:["Your order is placed. Pay ",m," by card to confirm it now."]}):n?v(z,{children:["Your hold ran out, so your items are held again",g?` until ${g}`:"",". Enter your card again, then pay ",m,"."]}):v(z,{children:["Your items are held",g?` until ${g}`:"",". Pay ",m," by card to place your order."]})}),c(Pn,{stripe:f,options:{clientSecret:e.clientSecret,appearance:h},children:c(Gs,{payment:e,checkout:t,onPaid:r,onProcessing:i,onRenew:s,onBack:d})},e.clientSecret)]})]})})}var zs=5;function Gs({payment:e,checkout:t,onPaid:n,onProcessing:r,onRenew:i,onBack:s}){let{formatMoney:d}=be(),p=wa(),m=Pa(),[f,h]=He(!1),[g,b]=He(null),x=it(!1);async function E(){try{return(await p.retrievePaymentIntent(e.clientSecret)).paymentIntent?.status}catch{return}}async function C(R){let w=R;for(let I=0;w==="processing"&&I<zs;I+=1)await new Promise(Q=>setTimeout(Q,1e3)),w=await E()??w;if(w==="succeeded"){n();return}if(w==="processing"){r();return}b("Payment did not complete. Please try again."),h(!1)}async function O(){if(!p||!m||f)return;h(!0),b(null),x.current=!0;let R=await p.confirmPayment({elements:m,redirect:"if_required"}).catch(()=>null);if(!R){let w=await E();if(w==="succeeded"||w==="processing"){await C(w);return}b(w===void 0?_e:"Payment failed. Please try again."),h(!1);return}if(R.error){if(!t.orderNumber&&R.error.code==="payment_intent_unexpected_state"){let w=await E();if(w==="succeeded"||w==="processing"){await C(w);return}if(w===void 0){b(_e),h(!1);return}await i(w==="canceled"),h(!1);return}b(R.error.message??"Payment failed. Please try again."),h(!1);return}await C(R.paymentIntent?.status)}async function G(){if(f)return;if(!x.current){s();return}h(!0),b(null);let R=await E();if(R==="succeeded"||R==="processing"){await C(R);return}if(h(!1),R===void 0){b(_e);return}s()}return v("div",{className:"flex flex-col gap-4",children:[c(Sa,{}),g&&c(pe,{role:"alert",children:g}),c("button",{type:"button",onClick:O,disabled:!p||!m||f,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",!p||!m||f?"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?v(z,{children:["Processing\u2026 ",c("span",{children:"\xB7"})]}):v(z,{children:["Pay ",d(Number(e.amount),e.currency),c("span",{className:"transition-transform group-hover:translate-x-1",children:"\u2192"})]})}),!t.orderNumber&&!f&&v("button",{type:"button",onClick:G,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",c("span",{children:"Back to checkout"})]})]})}var Mo="paypal-sdk-js",Un=null;function Vs(e,t){let n=`${e}|${t}`;if(Un?.key===n)return Un.promise;let r=new Promise((i,s)=>{document.getElementById(Mo)?.remove();let d=document.createElement("script");d.id=Mo;let p=new URLSearchParams({"client-id":e,currency:t,intent:"capture"});d.src=`https://www.paypal.com/sdk/js?${p}`,d.onload=()=>{let m=window.paypal;m?i(m):s(new Error("PayPal SDK loaded without its namespace"))},d.onerror=()=>s(new Error("PayPal SDK failed to load")),document.head.appendChild(d)});return Un={key:n,promise:r},r}function Js({confirmation:e,clientId:t,idemKey:n,onPaid:r,onSkip:i}){let{formatMoney:s}=be(),d=it(null),[p,m]=He(!1),[f,h]=He(null),g=it(r);return g.current=r,Do(()=>{let b=!1,x=null;return Vs(t,e.currency).then(E=>{if(!(b||!d.current))return x=E.Buttons({style:{layout:"vertical",color:"gold",shape:"rect",label:"paypal"},createOrder:async()=>(await K.createPaypalOrder({idempotencyKey:n})).paypalOrderId,onApprove:async C=>{try{if((await K.capturePaypalOrder({idempotencyKey:n,paypalOrderId:C.orderID})).status==="paid"){g.current();return}h("PayPal did not complete the payment. Please try again.")}catch(O){h(O instanceof de?O.message:"PayPal payment failed. Please try again.")}},onError:()=>{h("PayPal could not process the payment. Please try again.")}}),x.render(d.current).then(()=>{b||m(!0)})}).catch(()=>{b||h("PayPal could not be loaded. You can pay later \u2014 your order stands either way.")}),()=>{b=!0,x?.close?.()}},[t,e.currency,n]),c("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:v("div",{className:"w-full max-w-xl border border-line bg-bg",children:[v("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-4",children:[c("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}),c("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"PayPal"})]}),v("div",{className:"flex flex-col gap-4 px-6 py-6",children:[v("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:["Your order is placed. Pay"," ",c("span",{className:"text-fg",children:s(Number(e.grandTotal),e.currency)})," ","with PayPal to confirm it now."]}),!p&&!f&&c("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading PayPal\u2026"}),c("div",{ref:d}),f&&c(pe,{role:"alert",children:f}),c("button",{type:"button",onClick:i,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 Ko="square-web-sdk",jn=null,Xs=["sandbox","production"];function Zs(e){let t=js(Xs,"production",e);if(jn?.key===t)return jn.promise;let n=new Promise((r,i)=>{document.getElementById(Ko)?.remove();let s=document.createElement("script");s.id=Ko,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):i(new Error("Square SDK loaded without its namespace"))},s.onerror=()=>i(new Error("Square SDK failed to load")),document.head.appendChild(s)});return jn={key:t,promise:n},n}function Qs({confirmation:e,applicationId:t,locationId:n,environment:r,idemKey:i,onPaid:s,onSkip:d}){let{formatMoney:p}=be(),m=it(null),f=it(null),h=it(null),[g,b]=He(!1),[x,E]=He(!1),[C,O]=He(null);Do(()=>{let R=!1,w=null;return Zs(r).then(async I=>{if(R||!m.current)return;let Q=I.payments(t,n);h.current=Q,w=await Q.card(),await w.attach(m.current),f.current=w,R||b(!0)}).catch(()=>{R||O("Square could not be loaded. You can pay later \u2014 your order stands either way.")}),()=>{R=!0,w?.destroy?.()}},[t,n,r]);async function G(){let R=f.current;if(!(!R||x)){E(!0),O(null);try{let w=await R.tokenize();if(w.status!=="OK"||!w.token){O(w.errors?.[0]?.message??"Please check the card details and try again."),E(!1);return}let I;try{I=(await h.current?.verifyBuyer?.(w.token,{amount:String(e.grandTotal),currencyCode:e.currency,intent:"CHARGE"}))?.token}catch{}if((await K.chargeSquare({idempotencyKey:i,sourceId:w.token,...I?{verificationToken:I}:{}})).status==="paid"){s();return}O("Square did not complete the payment. Please try again.")}catch(w){O(w instanceof de?w.message:"Square payment failed. Please try again.")}E(!1)}}return c("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:v("div",{className:"w-full max-w-xl border border-line bg-bg",children:[v("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-4",children:[c("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}),c("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"Card"})]}),v("div",{className:"flex flex-col gap-4 px-6 py-6",children:[v("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:["Your order is placed. Pay"," ",c("span",{className:"text-fg",children:p(Number(e.grandTotal),e.currency)})," ","by card to confirm it now."]}),!g&&!C&&c("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading card form\u2026"}),c("div",{ref:m}),C&&c(pe,{role:"alert",children:C}),c("button",{type:"button",onClick:G,disabled:!g||x,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||x?"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:x?v(z,{children:["Processing\u2026 ",c("span",{children:"\xB7"})]}):v(z,{children:["Pay ",p(Number(e.grandTotal),e.currency),c("span",{className:"transition-transform group-hover:translate-x-1",children:"\u2192"})]})}),c("button",{type:"button",onClick:d,disabled:x,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 Qt}from"react/jsx-runtime";function ec(){let{settings:e,websiteName:t}=Tr(),n=t?{...bn,name:t}:bn,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 Qt("div",{style:{position:"fixed",inset:0,zIndex:2147482e3,overflowY:"auto",background:"var(--bg)",color:"var(--fg)"},children:Qt(Br,{children:Qt(zr,{preview:!0,children:Qt(Wn,{site:n,logo:r,textCase:e?.navTextCase,preview:!0})})})})}export{ec as default};
|