efficient-storefront-blocks 0.18.2 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,52 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.20.0 — 2026-10-13
4
+
5
+ Peer dependencies are unchanged. The canvas is built with efficient-web-builder 5.0.2.
6
+
7
+ Nothing a host calls changes, and an editor draws what it drew. This release
8
+ is the blocks' half of dynamic pages for a record that is not a product
9
+ (efficient-backend `docs/adr/0049`, "Amended 2026-10-12"), which the storefront
10
+ app's renderer uses.
11
+
12
+ - **A dynamic page's record reaches its blocks through one provider.**
13
+ `lib/puck/current-record` holds the record a dynamic page is drawn for,
14
+ whatever its type: `CurrentRecordProvider`, `useCurrentRecord()` and
15
+ `useCurrentRecordOf(type)`. A record is its type's key, its own key, a title
16
+ and the fields its type declared; nothing of it is in the page's document.
17
+ - **A product is one type of record.** `CurrentProductProvider` mounts that
18
+ provider with the type `product`, and `useCurrentProduct()` reads it back, so
19
+ every product block and every caller is as it was. On a dynamic page of
20
+ another record type a product block is told there is no product, as on an
21
+ ordinary page.
22
+ - **The EFFICIENT client reads the two new public routes.**
23
+ `products.listDynamicPages(recordType?)` lists a site's published dynamic
24
+ pages with the record type each draws, and `products.getRecord(type, key)`
25
+ answers one record or `null` for the backend's one 404.
26
+ - No block reads a record of another type yet, and the editor offers no record
27
+ type to choose: a host declares its record types with efficient-web-builder
28
+ 5.5.0 (`registerRecordTypes`), which this package does not build with yet.
29
+
30
+ ## 0.19.0 — 2026-10-13
31
+
32
+ Peer dependencies are unchanged. The canvas is built with efficient-web-builder 5.0.2.
33
+
34
+ - **A host names the portal its token is for.**
35
+ `createEfficientBackend({ portalAudience: "venue" })` makes every call the
36
+ editor sends carry `X-Portal-Audience: venue` in place of `admin`, so the
37
+ venue portal can host the editor on its own sign-in (efficient-backend
38
+ `docs/adr/0049`, "Amended 2026-10-12": a venue login that holds the website
39
+ right may use the editor's routes). Left out it is `admin`, and nothing
40
+ changes for the admin portal. The audience is the host's, so it is kept for
41
+ the page once named: an editor's last calls after it unmounts (the lock's
42
+ release, a final save) carry it too. `createStorefrontAdmin({ audience })`
43
+ is the same for a Node caller. The README's "A host that is not the admin portal"
44
+ lists what such a host supplies and what in the package still assumes the
45
+ admin portal.
46
+ - **An editor's read has no page-render deadline, whichever portal it is.**
47
+ The five-second deadline of a shopper's read was withheld from the editor's
48
+ calls by their `admin` audience; it is withheld from `venue` the same way.
49
+
3
50
  ## 0.18.2 — 2026-10-12
4
51
 
5
52
  - **The phone header draws its menu button only when the drawer has
package/README.md CHANGED
@@ -132,6 +132,103 @@ const backend: WebsiteBackend = {
132
132
  list your blog; without it neither offers a list.
133
133
  - `backend` is read once, when the editor mounts — re-mount (a `key`) to change it.
134
134
 
135
+ ## A host that is not the admin portal (0.19.0)
136
+
137
+ The editor's calls to EFFICIENT's backend are authorised by the host's own
138
+ token, and each call names the portal that token was minted for
139
+ (`X-Portal-Audience`). The backend refuses a token whose portal is not the one
140
+ named ("Token was issued for a different portal"). Until 0.19.0 every call
141
+ said `admin`. A host that is another portal names its own, once, on the
142
+ backend it passes:
143
+
144
+ ```tsx
145
+ import { WebsiteEditor, createEditorHost, createEfficientBackend } from "efficient-storefront-blocks";
146
+
147
+ const [backend] = useState(() => createEfficientBackend({ portalAudience: "venue" }));
148
+
149
+ <WebsiteEditor host={host} target={target} site={{ slug, origin }} backend={backend} mediaPanel={MediaPanel} />;
150
+ ```
151
+
152
+ - **`portalAudience`** is `"admin"` (the default: leave it out and nothing
153
+ changes) or `"venue"`, the venue portal, where a business edits its own
154
+ website. It is carried by every request the package makes with the host's
155
+ token: the page and its lock, publish, site styles, the header, menus,
156
+ forms, media uploads, section templates. A value the package does not know
157
+ is sent as `admin`.
158
+ - **It is still EFFICIENT's backend.** The editor waits for the token
159
+ (`storefront-editor:auth`) and keeps its own client open, exactly as with no
160
+ `backend` at all.
161
+ - **It is the host's, not one editor's.** A host is one portal, so the
162
+ audience is kept for the page from the moment it is named: every editor
163
+ mounted afterwards carries it, and so do an editor's last calls after it
164
+ unmounts (the lock's release, a final save). Make the backend before the
165
+ first editor mounts. A backend made without `portalAudience` leaves it as it
166
+ is.
167
+ - **What the backend answers is the backend's rule.** For `venue`:
168
+ efficient-backend `docs/adr/0049` ("Amended 2026-10-12"). A venue login
169
+ that holds the website right reaches the routes of a brochure website
170
+ (pages, the lock, publish, the site and its settings, theme, header and
171
+ social links, menus, forms, media, section templates, and the template
172
+ catalogue to read). The shop's routes stay the admin portal's.
173
+
174
+ ### What such a host supplies
175
+
176
+ The editor draws the canvas, the block panels, Site styles and the header
177
+ panel. Everything round it is the host's, as it is the admin portal's
178
+ (`admin-portal/src/pages/storefront/`, `src/components/website/`):
179
+
180
+ | The host supplies | How the editor asks for it |
181
+ |---|---|
182
+ | The token, and a fresh one when it runs out | It sends `storefront-editor:ready`, and `storefront-editor:auth-expired` when a call is refused; answer each with `deliver({ type: "storefront-editor:auth", token, siteId })` |
183
+ | A window to mount it in, and its address | `createEditorHost({ address })`: `search`, `show`, `load`, `reload`; it sends `storefront-editor:navigated` when it moves to another page |
184
+ | A media library | the `mediaPanel` prop (`MediaPanelComponent`: browse, and pick when `pick` is set). Without one, each image field sends `storefront-editor:open-media-picker`; answer with `storefront-editor:media-picked` or `storefront-editor:media-pick-cancelled` |
185
+ | The page list's settings screen, and the new-page flow | `storefront-editor:open-page` (`slug`) and `storefront-editor:new-page`. The new-page flow is where a page is made blank or from the website's template library (`GET /api/storefront/pages/template-library/`, `POST /api/storefront/pages/from-template/`) |
186
+ | Menus | `storefront-editor:open-menus` (`menuId`); tell the editor with `storefront-editor:menus-updated` when one was saved |
187
+ | Forms, and the inbox of what was sent | `storefront-editor:open-form` (`mode: "create"` with a `requestId`, or `"edit"` with a `formId`); answer a create with `storefront-editor:form-saved` or `storefront-editor:form-closed` |
188
+ | The website's settings and its address | nothing asks: a screen of the host's own (`/api/storefront/sites/`, `sites/{id}/address/`). The editor itself saves one site field, the Maps key |
189
+ | The template picker | nothing asks: making a website from a look or from nothing is the host's (`GET /api/storefront/page-templates/`, `POST /api/storefront/sites/` with `template`) |
190
+ | Toasts and the unsaved-changes guard | `storefront-editor:dirty`, `saved`, `published`, `save-failed` |
191
+
192
+ `storefront-editor:open-product`, `open-category`, `open-post` and
193
+ `save-as-template` are sent only from the shop's blocks, the blog source and
194
+ an operator's template editor. A host that offers none of those never
195
+ receives them (`blocks: { sets: [...] }`, above; leave `can` out of the
196
+ `auth` message).
197
+
198
+ ### What still assumes the admin portal
199
+
200
+ Listed so that a host knows what it will meet. None of it is switched by
201
+ `portalAudience`.
202
+
203
+ - **Calls the backend answers only to the admin portal.** With
204
+ `portalAudience: "venue"` the backend refuses these (403): the product
205
+ catalogue and one product's details (`/api/storefront/products/`,
206
+ `wheel-curations/`), categories (`categories/`), the product field answers
207
+ (`field-usage/`), blog posts (`blog-posts/`) and the live-chat settings
208
+ (`chat-settings/`). A refused list reads as an empty one (the catalogue,
209
+ categories, the field answers) or as "Couldn't reach" (the blog source).
210
+ The Live chat panel is still drawn: it loads nothing and its save is
211
+ refused. Offer only the block sets a brochure website needs (`blocks.sets`)
212
+ and the catalogue is never asked for. To stop the editor asking for the chat
213
+ settings or the blog, leave the group out of the backend you pass:
214
+ `const { chat, blog, ...backend } = createEfficientBackend({ portalAudience: "venue" })`
215
+ (it is still EFFICIENT's backend).
216
+ - **Words that name the admin portal's menu.** Hints such as "Create menus in
217
+ Storefront → Menus", "Goes to Storefront → Forms", "Syncing from Storefront
218
+ → Blog" and "Storefront → Categories" (`MenuPicker`, `HeaderSettingsPanel`,
219
+ `FormPicker`, `BlogSource`, `CategorySource`, `lib/content/menu-placeholder`)
220
+ say where those screens are in the admin portal.
221
+ - **`brandId` and `can.canCreatePlatformTemplate`** in the `auth` message are
222
+ the admin portal's and the operator's. Leave both out.
223
+ - **Template targets.** `target: { kind: "template" }` edits a row of the
224
+ template catalogue, which only the admin portal may write.
225
+ - **The Preview link and the shop's own routes** (fitment, geocoding, logo
226
+ analysis) go to `site.origin`, the published website, whatever the host is.
227
+
228
+ Nothing in the package reads `/api/auth/me/`, a permission name or a feature
229
+ flag: what the signed-in person may do is the host's to know, and it says so
230
+ by what it mounts and what it puts in `can`.
231
+
135
232
  ## Which blocks the editor offers (0.7.0)
136
233
 
137
234
  Every block is in one of three **sets**:
@@ -1,4 +1,4 @@
1
- "use client";import{F as qt,G as _t,H as Ft,I as oe,J as Se,K as Dt,L as Mt,M as Je,N as Ut,P as Xe,V as Wt,Y as Ze,Z as $t,a as Lt,b as Ot,c as Tt,d as jt,da as $,ea as Kt,fa as Yt,ga as Bt}from"./chunk-XBW7A5SW.js";import{i as qe,m as fe,t as T}from"./chunk-UGTQGAHF.js";import{La as It,a as Rt,c as Z}from"./chunk-HYLRHFHP.js";import{s as At,t as Ce,u as z}from"./chunk-TP6VLEFI.js";import{a as Ge,b as ar}from"./chunk-Y6SLVHK3.js";var Ht=Ge((ta,zt)=>{"use strict";var or="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";zt.exports=or});var Xt=Ge((na,Jt)=>{"use strict";var ir=Ht();function Vt(){}function Gt(){}Gt.resetWarningCache=Vt;Jt.exports=function(){function t(a,o,s,l,d,p){if(p!==ir){var u=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 u.name="Invariant Violation",u}}t.isRequired=t;function e(){return t}var n={array:t,bigint:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:e,element:t,elementType:t,instanceOf:e,node:t,objectOf:e,oneOf:e,oneOfType:e,shape:e,exact:e,checkPropTypes:Gt,resetWarningCache:Vt};return n.PropTypes=n,n}});var Qt=Ge((oa,Zt)=>{"use strict";Zt.exports=Xt()();var ra,aa});import{useEffect as Y,useMemo as Ye,useRef as se,useState as g}from"react";var P=ar(Qt(),1);import k from"react";function en(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,a=Array(e);n<e;n++)a[n]=t[n];return a}function sr(t){if(Array.isArray(t))return t}function on(t,e,n){return(e=mr(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function cr(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var a,o,s,l,d=[],p=!0,u=!1;try{if(s=(n=n.call(t)).next,e!==0)for(;!(p=(a=s.call(n)).done)&&(d.push(a.value),d.length!==e);p=!0);}catch(v){u=!0,o=v}finally{try{if(!p&&n.return!=null&&(l=n.return(),Object(l)!==l))return}finally{if(u)throw o}}return d}}function lr(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1
+ "use client";import{F as qt,G as _t,H as Ft,I as oe,J as Se,K as Dt,L as Mt,M as Je,N as Ut,P as Xe,V as Wt,Y as Ze,Z as $t,a as Lt,b as Ot,c as Tt,d as jt,da as $,ea as Kt,fa as Yt,ga as Bt}from"./chunk-3KTQYH72.js";import{i as qe,n as fe,u as T}from"./chunk-K5TEC2IE.js";import{La as It,a as Rt,c as Z}from"./chunk-HYLRHFHP.js";import{r as At,s as Ce,t as z}from"./chunk-EJ2NLQYY.js";import{a as Ge,b as ar}from"./chunk-Y6SLVHK3.js";var Ht=Ge((ta,zt)=>{"use strict";var or="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";zt.exports=or});var Xt=Ge((na,Jt)=>{"use strict";var ir=Ht();function Vt(){}function Gt(){}Gt.resetWarningCache=Vt;Jt.exports=function(){function t(a,o,s,l,d,p){if(p!==ir){var u=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 u.name="Invariant Violation",u}}t.isRequired=t;function e(){return t}var n={array:t,bigint:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:e,element:t,elementType:t,instanceOf:e,node:t,objectOf:e,oneOf:e,oneOfType:e,shape:e,exact:e,checkPropTypes:Gt,resetWarningCache:Vt};return n.PropTypes=n,n}});var Qt=Ge((oa,Zt)=>{"use strict";Zt.exports=Xt()();var ra,aa});import{useEffect as Y,useMemo as Ye,useRef as se,useState as g}from"react";var P=ar(Qt(),1);import k from"react";function en(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,a=Array(e);n<e;n++)a[n]=t[n];return a}function sr(t){if(Array.isArray(t))return t}function on(t,e,n){return(e=mr(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function cr(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var a,o,s,l,d=[],p=!0,u=!1;try{if(s=(n=n.call(t)).next,e!==0)for(;!(p=(a=s.call(n)).done)&&(d.push(a.value),d.length!==e);p=!0);}catch(v){u=!0,o=v}finally{try{if(!p&&n.return!=null&&(l=n.return(),Object(l)!==l))return}finally{if(u)throw o}}return d}}function lr(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function tn(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,a)}return n}function nn(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?tn(Object(n),!0).forEach(function(a){on(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):tn(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function ur(t,e){if(t==null)return{};var n,a,o=pr(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(a=0;a<s.length;a++)n=s[a],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(o[n]=t[n])}return o}function pr(t,e){if(t==null)return{};var n={};for(var a in t)if({}.hasOwnProperty.call(t,a)){if(e.indexOf(a)!==-1)continue;n[a]=t[a]}return n}function sn(t,e){return sr(t)||cr(t,e)||fr(t,e)||lr()}function dr(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,e);if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function mr(t){var e=dr(t,"string");return typeof e=="symbol"?e:e+""}function Qe(t){"@babel/helpers - typeof";return Qe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Qe(t)}function fr(t,e){if(t){if(typeof t=="string")return en(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?en(t,e):void 0}}var j=function(e,n,a){var o=!!a,s=k.useRef(a);k.useEffect(function(){s.current=a},[a]),k.useEffect(function(){if(!o||!e)return function(){};var l=function(){if(s.current)return s.current.apply(s,arguments)};return e.on(n,l),function(){e.off(n,l)}},[o,n,e,s])},et=function(e){var n=k.useRef(e);return k.useEffect(function(){n.current=e},[e]),n.current},ge=function(e){return e!==null&&Qe(e)==="object"},gr=function(e){return ge(e)&&typeof e.then=="function"},yr=function(e){return ge(e)&&typeof e.elements=="function"&&typeof e.createToken=="function"&&typeof e.createPaymentMethod=="function"&&typeof e.confirmCardPayment=="function"},rn="[object Object]",hr=function t(e,n){if(e===n)return!0;if(!ge(e)||!ge(n))return e===n;var a=Array.isArray(e),o=Array.isArray(n);if(a!==o)return!1;var s=Object.prototype.toString.call(e)===rn,l=Object.prototype.toString.call(n)===rn;if(s!==l)return!1;if(!s&&!a)return e===n;var d=Object.keys(e),p=Object.keys(n);if(d.length!==p.length)return!1;for(var u={},v=0;v<d.length;v+=1)u[d[v]]=!0;for(var x=0;x<p.length;x+=1)u[p[x]]=!0;var m=Object.keys(u);if(m.length!==d.length)return!1;var h=e,A=n,C=function(w){return t(h[w],A[w])};return m.every(C)},cn=function(e,n,a){return ge(e)?Object.keys(e).reduce(function(o,s){var l=!ge(n)||!hr(e[s],n[s]);return a.includes(s)?(l&&console.warn("Unsupported prop change: options.".concat(s," is not a mutable property.")),o):l?nn(nn({},o||{}),{},on({},s,e[s])):o},null):null},ln="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.",an=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:ln;if(e===null||yr(e))return e;throw new Error(n)},vr=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:ln;if(gr(e))return{tag:"async",stripePromise:Promise.resolve(e).then(function(o){return an(o,n)})};var a=an(e,n);return a===null?{tag:"empty"}:{tag:"sync",stripe:a}},br=function(e){!e||!e._registerWrapper||!e.registerAppInfo||(e._registerWrapper({name:"react-stripe-js",version:"6.12.0"}),e.registerAppInfo({name:"react-stripe-js",version:"6.12.0",url:"https://stripe.com/docs/stripe-js/react"}))},_e=k.createContext(null);_e.displayName="ElementsContext";var un=function(e,n){if(!e)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 e},nt=function(e){var n=e.stripe,a=e.options,o=e.children,s=k.useMemo(function(){return vr(n)},[n]),l=k.useState(function(){return{stripe:s.tag==="sync"?s.stripe:null,elements:s.tag==="sync"?s.stripe.elements(a):null}}),d=sn(l,2),p=d[0],u=d[1];k.useEffect(function(){var m=!0,h=function(C){u(function(S){return S.stripe?S:{stripe:C,elements:C.elements(a)}})};return s.tag==="async"&&!p.stripe?s.stripePromise.then(function(A){A&&m&&h(A)}):s.tag==="sync"&&!p.stripe&&h(s.stripe),function(){m=!1}},[s,p,a]);var v=et(n);k.useEffect(function(){v!==null&&v!==n&&console.warn("Unsupported prop change on Elements: You cannot change the `stripe` prop after setting it.")},[v,n]);var x=et(a);return k.useEffect(function(){if(p.elements){var m=cn(a,x,["clientSecret","fonts"]);m&&p.elements.update(m)}},[a,x,p.elements]),k.useEffect(function(){br(p.stripe)},[p.stripe]),k.createElement(_e.Provider,{value:p},o)};nt.propTypes={stripe:P.default.any,options:P.default.object};var pn=function(e){var n=k.useContext(_e);return un(n,e)},dn=function(){var e=pn("calls useElements()"),n=e.elements;return n},xr=function(e){var n=e.children,a=pn("mounts <ElementsConsumer>");return n(a)};xr.propTypes={children:P.default.func.isRequired};var kr=k.createContext(null);kr.displayName="CheckoutContext";var mn=k.createContext(null);mn.displayName="CheckoutSdkContext";var tt=function(e){var n=k.useContext(mn),a=k.useContext(_e);if(n){if(a)throw new Error("You cannot wrap the part of your app that ".concat(e," in both a checkout provider and <Elements> provider."));return n}else return un(a,e)},Cr=["mode"],Sr=function(e){return e.charAt(0).toUpperCase()+e.slice(1)},N=function(e,n,a){var o="".concat(Sr(e),"Element"),s=function(u){var v=u.id,x=u.className,m=u.options,h=m===void 0?{}:m,A=u.onBlur,C=u.onFocus,S=u.onReady,w=u.onChange,D=u.onEscape,O=u.onClick,V=u.onLoadError,Q=u.onLoaderStart,Ne=u.onNetworksChange,ce=u.onConfirm,Ee=u.onCancel,ee=u.onShippingAddressChange,Re=u.onShippingRateChange,te=u.onSavedPaymentMethodRemove,Ie=u.onSavedPaymentMethodUpdate,ye=u.onAvailablePaymentMethodsChange,ne=tt("mounts <".concat(o,">")),X="elements"in ne?ne.elements:null,M="checkoutSdk"in ne?ne.checkoutSdk:null,he=k.useState(null),le=sn(he,2),I=le[0],ve=le[1],_=k.useRef(null),re=k.useRef(null);j(I,"blur",A),j(I,"focus",C),j(I,"escape",D),j(I,"click",O),j(I,"loaderror",V),j(I,"loaderstart",Q),j(I,"networkschange",Ne),j(I,"confirm",ce),j(I,"cancel",Ee),j(I,"shippingaddresschange",ee),j(I,"shippingratechange",Re),j(I,"savedpaymentmethodremove",te),j(I,"savedpaymentmethodupdate",Ie),j(I,"availablepaymentmethodschange",ye),j(I,"change",w);var ae;S&&(e==="expressCheckout"?ae=S:ae=function(){S(I)}),j(I,"ready",ae),k.useLayoutEffect(function(){if(_.current===null&&re.current!==null&&(X||M)){var b=null;if(M){var B=M,be=M;switch(e){case"paymentForm":b=be.createForm(h);break;case"payment":b=B.createPaymentElement(h);break;case"address":if("mode"in h){var pe=h.mode,de=ur(h,Cr);if(pe==="shipping")b=B.createShippingAddressElement(de);else if(pe==="billing")b=B.createBillingAddressElement(de);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":b=B.createExpressCheckoutElement(h);break;case"currencySelector":b=M.createCurrencySelectorElement();break;case"taxId":b=B.createTaxIdElement(h);break;case"contactDetails":b=B.createContactDetailsElement();break;case"linkSignup":if("createLinkSignupElement"in M)b=M.createLinkSignupElement(h);else throw new Error("<LinkSignupElement> requires <CheckoutElementsProvider> and is not supported inside <CheckoutFormProvider>.");break;case"terms":b=B.createTermsElement(h);break;default:throw new Error("<".concat(o,"> is not supported inside a checkout provider. Use an <Elements> provider instead."))}}else X&&(b=X.create(e,h));_.current=b,ve(b),b&&b.mount(re.current)}},[X,M,h]);var ue=et(h);return k.useEffect(function(){if(_.current){var b=cn(h,ue,["paymentRequest"]);b&&"update"in _.current&&_.current.update(b)}},[h,ue]),k.useLayoutEffect(function(){return function(){if(_.current&&typeof _.current.destroy=="function")try{_.current.destroy(),_.current=null}catch{}}},[]),k.createElement("div",{id:v,className:x,ref:re})},l=function(u){tt("mounts <".concat(o,">"));var v=u.id,x=u.className;return k.createElement("div",{id:v,className:x})},d=n?l:s;return d.propTypes={id:P.default.string,className:P.default.string,onChange:P.default.func,onBlur:P.default.func,onFocus:P.default.func,onReady:P.default.func,onEscape:P.default.func,onClick:P.default.func,onLoadError:P.default.func,onLoaderStart:P.default.func,onNetworksChange:P.default.func,onConfirm:P.default.func,onCancel:P.default.func,onShippingAddressChange:P.default.func,onShippingRateChange:P.default.func,onSavedPaymentMethodRemove:P.default.func,onSavedPaymentMethodUpdate:P.default.func,onAvailablePaymentMethodsChange:P.default.func,options:P.default.object},d.displayName=o,d.__elementType=e,d},E=typeof window>"u",wr=k.createContext(null);wr.displayName="EmbeddedCheckoutProviderContext";var fn=function(){var e=tt("calls useStripe()"),n=e.stripe;return n},sa=N("auBankAccount",E),ca=N("card",E),la=N("cardNumber",E),ua=N("cardExpiry",E),pa=N("cardCvc",E),da=N("currencySelector",E),ma=N("iban",E),gn=N("payment",E),fa=N("expressCheckout",E),ga=N("paymentRequestButton",E),ya=N("linkAuthentication",E),ha=N("linkSignup",E),va=N("contactDetails",E),ba=N("address",E),xa=N("shippingAddress",E),ka=N("paymentMethodMessaging",E),Ca=N("taxId",E),Sa=N("issuingCardNumberDisplay",E),wa=N("issuingCardCvcDisplay",E),Pa=N("issuingCardExpiryDisplay",E),Na=N("issuingCardPinDisplay",E),Ea=N("issuingCardCopyButton",E),Ra=N("terms",E);function Me(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Me=function(e){return typeof e}:Me=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Me(t)}var vn="dahlia",Pr=function(e){return e===3?"v3":e},bn="https://js.stripe.com",Nr="".concat(bn,"/").concat(vn,"/stripe.js"),Er=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,Rr=/^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/,yn="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used",Ir=function(e){return Er.test(e)||Rr.test(e)},Ar=function(){for(var e=document.querySelectorAll('script[src^="'.concat(bn,'"]')),n=0;n<e.length;n++){var a=e[n];if(Ir(a.src))return a}return null},hn=function(e){var n=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",a=document.createElement("script");a.src="".concat(Nr).concat(n);var o=document.head||document.body;if(!o)throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");return o.appendChild(a),a},Lr=function(e,n){!e||!e._registerWrapper||e._registerWrapper({name:"stripe-js",version:"9.17.0",startTime:n})},we=null,Fe=null,De=null,Or=function(e){return function(n){e(new Error("Failed to load Stripe.js",{cause:n}))}},Tr=function(e,n){return function(){window.Stripe?e(window.Stripe):n(new Error("Stripe.js not available"))}},jr=function(e){return we!==null?we:(we=new Promise(function(n,a){if(typeof window>"u"||typeof document>"u"){n(null);return}if(window.Stripe&&e&&console.warn(yn),window.Stripe){n(window.Stripe);return}try{var o=Ar();if(o&&e)console.warn(yn);else if(!o)o=hn(e);else if(o&&De!==null&&Fe!==null){var s;o.removeEventListener("load",De),o.removeEventListener("error",Fe),(s=o.parentNode)===null||s===void 0||s.removeChild(o),o=hn(e)}De=Tr(n,a),Fe=Or(a),o.addEventListener("load",De),o.addEventListener("error",Fe)}catch(l){a(l);return}}),we.catch(function(n){return we=null,Promise.reject(n)}))},qr=function(e,n,a){if(e===null)return null;var o=n[0];if(typeof o!="string")throw new Error("Expected publishable key to be of type string, got type ".concat(Me(o)," instead."));var s=o.match(/^pk_test/),l=Pr(e.version),d=vn;s&&l!==d&&console.warn("Stripe.js@".concat(l," was loaded on the page, but @stripe/stripe-js@").concat("9.17.0"," expected Stripe.js@").concat(d,". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));var p=e.apply(void 0,n);return Lr(p,a),p},Pe,xn=!1,kn=function(){return Pe||(Pe=jr(null).catch(function(e){return Pe=null,Promise.reject(e)}),Pe)};Promise.resolve().then(function(){return kn()}).catch(function(t){xn||console.warn(t)});var Cn=function(){for(var e=arguments.length,n=new Array(e),a=0;a<e;a++)n[a]=arguments[a];xn=!0;var o=Date.now();return kn().then(function(s){return qr(s,n,o)})};var _r="sf:gclid",Fr="sf:fbclid",Dr=2160*60*60*1e3;function Pn(){return typeof window<"u"}function Sn(t){let e=Ce.getItem(t);if(!e)return"";try{let{v:n,t:a}=JSON.parse(e);return!n||typeof a!="number"||Date.now()-a>Dr?"":n}catch{return""}}function wn(t){if(!Pn())return"";let e=t.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1"),n=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return n?decodeURIComponent(n[1]):""}function Nn(){if(!Pn())return{};let t=Sn(_r),e=Sn(Fr),n=wn("_fbp"),a=wn("_fbc");!a&&e&&(a=`fb.1.${Date.now()}.${e}`);let o={};return t&&(o.gclid=t),e&&(o.fbclid=e),n&&(o.fbp=n),a&&(o.fbc=a),o}var En="sf:meta-purchases",Mr=20;function In(){return typeof window>"u"||window.parent!==window}function Ur(...t){try{if(In()||typeof window.fbq!="function")return;window.fbq(...t)}catch{}}var Rn=new Set;function Wr(t){if(Rn.has(t))return!1;Rn.add(t);try{let e=JSON.parse(Ce.getItem(En)??"[]");if(e.includes(t))return!1;Ce.setItem(En,JSON.stringify([...e,t].slice(-Mr)))}catch{}return!0}function $r(t){return[...new Set(t.filter(Se).flatMap(e=>e.components.map(n=>n.partNumber)))]}function An(t){let e=t.confirmation;In()||!Wr(e.orderNumber)||Ur("track","Purchase",{value:Number(e.grandTotal),currency:e.currency,content_type:"product",content_ids:$r(t.lines)},{eventID:e.orderNumber})}var rt="checkout-afterpay-context",Ue="checkout-gocardless-context",at="checkout-zip-context",We="checkout-klarna-context";function Kr({evidence:t,parked:e}){return t?{action:"capture",evidence:t,parked:e}:e?{action:"settle",parked:e}:{action:"ignore"}}function Yr(t,e){let n=t.getItem(e);if(t.removeItem(e),!n)return null;try{return JSON.parse(n)}catch{return null}}var Ln={name:"Afterpay",legParam:"afterpay",legValues:["confirm","cancel"],storageKey:rt,evidenceFrom(t,e){return e==="cancel"||(t.get("status")??"").toUpperCase()==="CANCELLED"?null:t.get("orderToken")},requestFrom:t=>({token:t})},On={name:"Zip",legParam:"zip",legValues:["return"],storageKey:at,evidenceFrom(t){let e=(t.get("result")??"").toLowerCase();return e==="cancelled"||e==="declined"?null:t.get("checkoutId")},requestFrom:t=>({checkoutId:t})};async function ot(t,e){let n=new URLSearchParams(e.search),a=n.get(t.legParam);if(!a||!t.legValues.includes(a))return;let o=Yr(e.storage,t.storageKey),s=t.evidenceFrom(n,a);e.scrubQuery();let l=Kr({evidence:s,parked:o});if(l.action!=="ignore"){if(e.page.clearCart(),l.action==="settle"){e.page.note(`The ${t.name} payment was not completed \u2014 our team will follow up on payment.`),e.page.land(l.parked.confirmation);return}e.page.setConfirming(!0);try{let d=await e.capture(t.requestFrom(l.evidence));d.status==="paid"?e.page.markPaid():e.page.note(`${t.name} declined the payment \u2014 our team will follow up on payment.`),e.page.land(l.parked?.confirmation??d)}catch{l.parked?(e.page.note(`We could not confirm the ${t.name} payment \u2014 our team will follow up on payment.`),e.page.land(l.parked.confirmation)):e.page.fail(`We could not confirm your ${t.name} payment. Please contact us before trying again \u2014 your payment may already have been taken.`)}finally{e.page.setConfirming(!1)}}}import{Fragment as q,jsx as r,jsxs as c}from"react/jsx-runtime";function Tn(t){let e=t.indexOf(`
3
3
  `);return e===-1?[t,""]:[t.slice(0,e),t.slice(e+1)]}function jn(t,{canParkContext:e}={canParkContext:!0}){let n=t.paymentMethods,a=[];return n.includes("card")&&a.push({key:"card",title:"Card",body:null,price:r("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"VISA \xB7 MC \xB7 AMEX"})}),n.includes("paypal")&&t.paypalClientId&&a.push({key:"paypal",title:"PayPal",body:null,price:r("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAYPAL \xB7 CARDS"})}),n.includes("afterpay")&&a.push({key:"afterpay",title:"Afterpay",body:null,price:r("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"4 \xD7 INTEREST-FREE"})}),n.includes("square")&&t.squareApplicationId&&t.squareLocationId&&a.push({key:"square",title:"Card (Square)",body:null,price:r("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"VISA \xB7 MC \xB7 AMEX"})}),n.includes("gocardless")&&e&&a.push({key:"gocardless",title:"Bank Direct Debit",body:null,price:r("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY BY BANK"})}),n.includes("zip")&&a.push({key:"zip",title:"Zip",body:null,price:r("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY IN 4"})}),n.includes("klarna")&&e&&a.push({key:"klarna",title:"Klarna",body:null,price:r("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY LATER"})}),a.push({key:"bank",title:"Bank transfer",body:null,price:r("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Invoiced"})}),a}function ct({site:t,logo:e,preview:n=!1}){let{items:a,totals:o,coupon:s,refuseCoupon:l,deliveryOptions:d,shippingMethodId:p,setShippingMethodId:u,identify:v,clearCapturedCart:x}=Je(),m=d.find(i=>i.id===p)?.pickupLocation??null,{country:h,countries:A,activeCountry:C,formatMoney:S}=oe(),[w,D]=g(()=>jn(t)[0].key),[O,V]=g(!0);Y(()=>{V(At(z))},[]);let[Q,Ne]=g(!0),[ce,Ee]=g(!1),[ee,Re]=g(""),[te,Ie]=g(""),[ye,ne]=g(""),[X,M]=g(""),[he,le]=g(""),[I,ve]=g(""),[_,re]=g(""),[ae,ue]=g(""),[b,B]=g(()=>h||A[0]?.code||""),[be,pe]=g(""),[de,lt]=g([]),Un=Ye(()=>A.find(i=>i.code===b)??C,[A,b,C])?.postalLabel||"Postal Code",Wn=de[0]?.divisionType||"State / Province";Y(()=>{if(!b){lt([]);return}let i=!1;return T.listCountrySubdivisions(b).then(f=>{i||(lt(f),pe(""))}),()=>{i=!0}},[b]);let[G,ut]=g(null),[pt,dt]=g([]),[Ae,Le]=g("new"),[ze,mt]=g(!1),[ft,$n]=g("Home"),[gt,yt]=g(null),[U]=g(()=>Bt()),[Oe,W]=g(null),[ht,xe]=g(null),[vt,Kn]=g(null),[Yn,Bn]=g(!1),[zn,Hn]=g(!1),[H,He]=g(null),[bt,me]=g(!1),[xt,J]=g(null),[Vn,Gn]=g(!1),[Jn,kt]=g(!1),[Xn,Zn]=g(!1),[Qn,Ct]=g(!1),St=se(!1);Y(()=>{n||St.current||!a.some(Se)||(St.current=!0,qt({lines:a,currency:o.currency,value:o.subtotal-o.discount,coupon:s?.valid?s.code:void 0}))},[a,o,s,n]),Y(()=>{v(ee,te.trim()||void 0)},[ee,te,v]);let wt=se(null),[Te,er]=g(null);Y(()=>{let i=wt.current;if(!Te||!i)return;let f=()=>i.style.setProperty("--sf-checkout-header-h",`${Te.offsetHeight}px`);f();let y=new ResizeObserver(f);return y.observe(Te),()=>y.disconnect()},[Te]),Y(()=>{let i=y=>({setConfirming:y,land:W,markPaid:()=>me(!0),note:J,fail:xe,clearCart:x}),f={search:window.location.search,storage:z,scrubQuery:()=>window.history.replaceState(null,"",window.location.pathname)};ot(Ln,{...f,capture:T.captureAfterpayPayment,page:i(Gn)}),ot(On,{...f,capture:T.captureZipPayment,page:i(Zn)})},[]),Y(()=>{let f=new URLSearchParams(window.location.search).get("gocardless");if(f!=="confirm"&&f!=="cancel")return;let y=z.getItem(Ue);if(z.removeItem(Ue),window.history.replaceState(null,"",window.location.pathname),!y)return;let R;try{R=JSON.parse(y)}catch{return}if(x(),f==="cancel"){J("The direct debit was not set up \u2014 our team will follow up on payment."),W(R.confirmation);return}kt(!0),T.completeGocardlessPayment({idempotencyKey:R.idempotencyKey}).then(L=>{L.status==="paid"?me(!0):L.status==="declined"?J("The direct debit was declined \u2014 our team will follow up on payment."):J("Your direct debit is set up \u2014 the payment is collecting and will clear in a few days.")}).catch(()=>{J("We could not confirm the direct debit \u2014 our team will follow up on payment.")}).finally(()=>{W(R.confirmation),kt(!1)})},[]),Y(()=>{let i=new URLSearchParams(window.location.search),f=i.get("klarna");if(f!=="confirm"&&f!=="cancel")return;let y=z.getItem(We);z.removeItem(We);let R=i.get("authorization_token");if(window.history.replaceState(null,"",window.location.pathname),!y)return;let L;try{L=JSON.parse(y)}catch{return}if(x(),f==="cancel"||!R){J("The Klarna payment was not completed \u2014 our team will follow up on payment."),W(L.confirmation);return}Ct(!0),T.captureKlarnaPayment({idempotencyKey:L.idempotencyKey,authorizationToken:R}).then(F=>{F.status==="paid"?me(!0):F.status==="declined"?J("Klarna declined the payment \u2014 our team will follow up on payment."):J("Your Klarna payment is being reviewed \u2014 we'll confirm the outcome shortly.")}).catch(()=>{J("We could not confirm the Klarna payment \u2014 our team will follow up on payment.")}).finally(()=>{W(L.confirmation),Ct(!1)})},[]);function Pt(i){let[f,y]=Tn(i.address);M(f),le(y),ve(i.city),re(i.zip_code),i.country&&B(i.country),i.phone&&ue(i.phone)}Y(()=>{let i=!1;return(async()=>{try{let[f,y,R]=await Promise.all([fe.me(),fe.myProfile().catch(()=>null),fe.myAddresses().catch(()=>[])]);if(i)return;ut(f);let L=R.filter(ke=>ke.is_active);dt(L),Re(f.email);let F=(y?.contact_name??"").split(/\s+/);Ie(f.first_name||F[0]||""),ne(f.last_name||F.slice(1).join(" "));let Et=f.phone||y?.phone;Et&&ue(Et);let Ve=L.find(ke=>ke.id===f.default_delivery_location)??L[0];if(Ve)Le(Ve.id),Pt(Ve);else if(y){let[ke,rr]=Tn(y.address??"");M(ke),le(rr),ve(y.city??""),re(y.zip_code??""),y.country&&B(y.country)}}catch{}})(),()=>{i=!0}},[]);function tr(){fe.logout(),ut(null),dt([]),Le("new"),mt(!1)}let je=Ye(()=>jn(t,{canParkContext:O}),[t,O]);Y(()=>{je.some(i=>i.key===w)||D(je[0].key)},[je,w]);let Nt=he.trim()?`${X}
4
4
  ${he.trim()}`:X;async function nr(){if(n||ce||a.length===0||o.repricing)return;let i=a.filter(Se).flatMap(f=>jt(f.components,f.qty));if(i.length===0){xe("Pick a size on each wheel's product page before checking out.");return}Ee(!0),xe(null);try{let y=await(G?T.createOrderAuthed:T.createOrder)({customer:{email:ee,name:`${te} ${ye}`.trim(),phone:ae.trim()||void 0,address:Nt,city:I,state:be||void 0,zipCode:_,country:b},items:i,currency:o.currency,idempotencyKey:U,shippingMethodId:p??void 0,couponCode:Ot(s),...Nn()});if(_t({confirmation:y,lines:a,adsSendTo:t.googleAdsId&&t.googleAdsConversionLabel?`${t.googleAdsId}/${t.googleAdsConversionLabel}`:null}),An({confirmation:y,lines:a}),x(),G&&ze&&Ae==="new")try{await fe.createAddress({label:ft.trim()||"Home",contact_name:`${te} ${ye}`.trim(),phone:ae.trim(),address:Nt,city:I,zip_code:_,country:b}),yt("Address saved to your account.")}catch{yt("We couldn't save the address to your account \u2014 you can add it under Account \u2192 Addresses.")}if(w==="card"&&t.paymentMethods.includes("card")){let R=await T.createPaymentIntent({idempotencyKey:U});He(y),Kn(R)}else if(w==="paypal"&&t.paymentMethods.includes("paypal"))He(y),Bn(!0);else if(w==="afterpay"&&t.paymentMethods.includes("afterpay")){let R=window.location.origin,L=await T.createAfterpayCheckout({idempotencyKey:U,confirmUrl:`${R}/checkout?afterpay=confirm`,cancelUrl:`${R}/checkout?afterpay=cancel`}),F={idempotencyKey:U,confirmation:y};z.setItem(rt,JSON.stringify(F)),window.location.assign(L.redirectCheckoutUrl);return}else if(w==="square"&&t.paymentMethods.includes("square"))He(y),Hn(!0);else if(w==="gocardless"&&t.paymentMethods.includes("gocardless")){let R=window.location.origin,L=await T.createGocardlessBillingRequest({idempotencyKey:U,confirmUrl:`${R}/checkout?gocardless=confirm`,cancelUrl:`${R}/checkout?gocardless=cancel`}),F={idempotencyKey:U,confirmation:y};z.setItem(Ue,JSON.stringify(F)),window.location.assign(L.authorisationUrl);return}else if(w==="zip"&&t.paymentMethods.includes("zip")){let R=window.location.origin,L=await T.createZipCheckout({idempotencyKey:U,redirectUrl:`${R}/checkout?zip=return`}),F={idempotencyKey:U,confirmation:y};z.setItem(at,JSON.stringify(F)),window.location.assign(L.redirectUrl);return}else if(w==="klarna"&&t.paymentMethods.includes("klarna")){let R=window.location.origin,L=await T.createKlarnaCheckout({idempotencyKey:U,confirmUrl:`${R}/checkout?klarna=confirm`,cancelUrl:`${R}/checkout?klarna=cancel`}),F={idempotencyKey:U,confirmation:y};z.setItem(We,JSON.stringify(F)),window.location.assign(L.redirectUrl);return}else W(y)}catch(f){let y=Tt(f);y?(l(y),xe(`${y} Your order has not been placed. Place it again to continue without the code.`)):xe(f instanceof qe?f.message:"Could not place the order. Please try again."),Ee(!1)}}return Oe?c("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[r("h1",{className:"font-display text-3xl",children:bt?"Payment received":"Order received"}),c("p",{className:"text-fg-dim",children:[bt?c(q,{children:["Thank you \u2014 your payment for order"," ",r("span",{className:"font-mono text-fg",children:Oe.orderNumber})," has gone through."," "]}):c(q,{children:["Thank you \u2014 your order ",r("span",{className:"font-mono text-fg",children:Oe.orderNumber})," is being reviewed by our team."," "]}),G?c(q,{children:["Track it under"," ",r(Z,{href:"/account/orders",className:"text-accent underline",children:"your orders"}),"."]}):r(q,{children:"We\u2019ve emailed you a link to set a password and track it."})]}),xt&&r("p",{className:"text-sm text-fg-dim",children:xt}),gt&&r("p",{className:"text-sm text-fg-dim",children:gt}),!G&&c("p",{className:"text-sm text-fg-dim",children:["You can also"," ",r(Z,{href:`/track?order=${encodeURIComponent(Oe.orderNumber)}`,className:"text-accent underline",children:"track this order"})," ","anytime with just your order number and email \u2014 no password needed."]}),r(Z,{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"})]}):Vn?c("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[r("h1",{className:"font-display text-3xl",children:"Confirming your payment\u2026"}),r("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Afterpay \u2014 one moment."})]}):Jn?c("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[r("h1",{className:"font-display text-3xl",children:"Setting up your direct debit\u2026"}),r("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Confirming with GoCardless \u2014 one moment."})]}):Xn?c("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[r("h1",{className:"font-display text-3xl",children:"Confirming your payment\u2026"}),r("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Zip \u2014 one moment."})]}):Qn?c("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[r("h1",{className:"font-display text-3xl",children:"Confirming your payment\u2026"}),r("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Klarna \u2014 one moment."})]}):vt?r(Br,{payment:vt,onPaid:()=>{me(!0),W(H)},onSkip:()=>W(H)}):Yn&&H?r(Vr,{confirmation:H,clientId:t.paypalClientId??"",idemKey:U,onPaid:()=>{me(!0),W(H)},onSkip:()=>W(H)}):zn&&H?r(Jr,{confirmation:H,applicationId:t.squareApplicationId??"",locationId:t.squareLocationId??"",environment:t.squareEnvironment??"production",idemKey:U,onPaid:()=>{me(!0),W(H)},onSkip:()=>W(H)}):c("div",{ref:wt,className:"bg-bg text-fg",children:[c("header",{ref:er,className:"sticky top-0 z-30 grid grid-cols-[1fr_auto_1fr] items-center gap-8 border-b border-line px-[var(--sf-site-gutter,40px)] py-[22px] 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:[c(Z,{href:"/",className:"inline-flex items-center gap-2.5 font-mono text-[13px] uppercase tracking-[0.26em] text-fg-dim transition-colors hover:text-accent",children:["\u2190",r("span",{className:"max-[640px]:hidden",children:"Back to shop"})]}),r(Z,{href:"/","aria-label":`${t.name} home`,className:"inline-flex items-center justify-center",children:r(Wt,{variant:"header",scrolled:!0,src:e?.url??null,reverse:e?.reverse??!1,reversedSrc:e?.reversed??null,inkIsDark:e?.inkIsDark??null,size:e?.size??"medium",sizePx:e?.sizePx??null,siteName:t.name})}),t.cardPayments?c("span",{className:"flex items-center justify-end gap-2.5 font-mono text-[12px] uppercase tracking-[0.26em] text-fg-dim",children:[r("span",{className:"text-green",children:"\u25CF"}),r("span",{className:"max-[640px]:hidden",children:"Encrypted \xB7"})," Stripe"]}):r("span",{})]}),c("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-[1100px]:px-[min(24px,var(--sf-site-gutter,40px))]",children:[r("span",{className:"inline-flex items-center bg-accent px-2.5 py-1 font-bold text-bg",children:"Checkout"}),r("nav",{"aria-label":"Checkout steps",className:"flex flex-wrap items-center gap-5",children:[{n:"01",label:"Cart",state:"done"},{n:"02",label:"Ship & pay",state:"active"},{n:"03",label:"Review",state:"pending"},{n:"04",label:"Confirmed",state:"pending"}].map(i=>c("span",{className:["relative flex items-center gap-2 transition-colors",i.state==="pending"?"text-fg-dim":"text-fg",i.state==="active"?"font-bold after:absolute after:inset-x-0 after:-bottom-1 after:h-[2px] after:bg-accent":""].join(" "),children:[r("span",{className:i.state==="done"?"text-accent font-bold":"",children:i.n}),r("span",{children:i.label})]},i.n))})]}),c("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-9 pb-[100px] max-[1100px]:grid-cols-1 max-[1100px]:gap-10 max-[1100px]:px-[min(24px,var(--sf-site-gutter,40px))] max-[1100px]:pt-8 max-[1100px]:pb-20",children:[c("div",{children:[c($e,{num:"N\xB0 01",title:"Contact",children:[r($,{label:"Email",hint:G?c(q,{children:["Signed in \xB7"," ",r("button",{type:"button",onClick:tr,className:"underline transition-colors hover:text-accent",children:"Not you? Sign out"})]}):void 0,children:r("input",{type:"email",value:ee,onChange:i=>Re(i.target.value),placeholder:"you@example.com",readOnly:G!==null,className:K+(G?" opacity-70":"")})}),c(_n,{children:[r($,{label:"First name",children:r("input",{type:"text",value:te,onChange:i=>Ie(i.target.value),className:K})}),r($,{label:"Last name",children:r("input",{type:"text",value:ye,onChange:i=>ne(i.target.value),className:K})})]})]}),c($e,{num:"N\xB0 02",title:m?"Collection":"Shipping address",children:[m?c("div",{className:"grid gap-1.5 text-[14px] leading-[1.6]",children:[r("span",{className:"font-medium",children:m.name}),[m.address,m.city,m.state,m.zipCode,m.country].filter(Boolean).length>0&&r("span",{className:"opacity-80",children:[m.address,m.city,m.state,m.zipCode,m.country].filter(Boolean).join(", ")}),m.openingHours&&r("span",{className:"opacity-80",children:m.openingHours}),m.instructions&&r("span",{className:"opacity-80",children:m.instructions}),r("span",{className:"mt-1 font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"No delivery address needed"})]}):c(q,{children:[G!==null&&pt.length>0&&c("div",{className:"grid gap-2.5",children:[pt.map(i=>r(Ke,{active:Ae===i.id,onClick:()=>{Le(i.id),Pt(i)},title:i.label,body:i.formatted_address,price:null},i.id)),r(Ke,{active:Ae==="new",onClick:()=>Le("new"),title:"New address",body:null,price:null})]}),r($,{label:"Address line 1",children:r("input",{type:"text",value:X,onChange:i=>M(i.target.value),className:K})}),r($,{label:"Address line 2",children:r("input",{type:"text",value:he,onChange:i=>le(i.target.value),placeholder:"Apartment, unit, garage bay\u2026",className:K})}),c(_n,{cols:"three",children:[r($,{label:"City",children:r("input",{type:"text",value:I,onChange:i=>ve(i.target.value),className:K})}),r($,{label:Un,children:r("input",{type:"text",value:_,onChange:i=>re(i.target.value),className:K})}),r($,{label:"Country",separate:!0,children:r(Ze,{value:b,onChange:i=>B(i.target.value),className:K+" pr-10",style:qn,children:A.map(i=>r("option",{value:i.code,children:i.name},i.code))})})]}),r($,{label:Wn,separate:!0,children:de.length>0?c(Ze,{value:be,onChange:i=>pe(i.target.value),className:K+" pr-10",style:qn,children:[r("option",{value:"",children:"Select\u2026"}),de.map(i=>r("option",{value:i.code||i.name,children:i.name},i.code||i.name))]}):r("input",{type:"text",value:be,onChange:i=>pe(i.target.value),className:K})})]}),r($,{label:"Phone",children:r("input",{type:"tel",value:ae,onChange:i=>ue(i.target.value),placeholder:"+44 7700 900000",className:K})}),!m&&G!==null&&Ae==="new"&&c(q,{children:[r(Mn,{checked:ze,onChange:mt,label:"Save this address to my account"}),ze&&r($,{label:"Address label",children:r("input",{type:"text",value:ft,onChange:i=>$n(i.target.value),placeholder:"Home",className:K})})]}),!m&&r(Mn,{checked:Q,onChange:Ne,label:"Billing address is the same as shipping"})]}),r($e,{num:"N\xB0 03",title:"Shipping",children:c("div",{className:"grid gap-2.5",children:[d.map(i=>{let f=i.pickupLocation,y=f?[f.address,f.city,f.state,f.zipCode].filter(Boolean).join(", "):null;return r(Ke,{active:p===i.id,onClick:()=>u(i.id),title:f?`${i.name} \u2014 ${f.name}`:i.name,body:f?[y,f.openingHours,f.instructions,i.description].filter(Boolean).join(" \xB7 "):i.description||null,price:o.freeShipping||i.amount===0?"Free":S(i.amount,o.currency),tag:i.tag||void 0},i.id)}),d.length===0&&r("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Shipping is arranged after your order is reviewed."})]})}),c($e,{num:"N\xB0 04",title:"Payment",children:[r("div",{className:"grid gap-2.5",children:je.map(i=>r(Ke,{active:w===i.key,onClick:()=>D(i.key),title:i.title,body:i.body,price:i.price,tag:i.tag},i.key))}),w==="card"?r("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."}):w==="paypal"?r("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."}):w==="afterpay"?r("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."}):w==="square"?r("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."}):w==="gocardless"?r("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."}):w==="zip"?r("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."}):w==="klarna"?r("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."}):r("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."})]})]}),c("aside",{className:"sticky top-[var(--sf-checkout-header-h,88px)] border border-line max-[1100px]:static",style:{background:"linear-gradient(180deg, color-mix(in oklab, var(--site-surface) 70%, var(--bg)) 0%, var(--bg) 100%)"},children:[c("header",{className:"flex items-center justify-between border-b border-accent bg-accent px-6 py-3.5 font-mono text-[13px] font-bold uppercase tracking-[0.28em] text-bg",children:[r("span",{children:"Your order"}),r(Z,{href:"/wheels",className:"text-bg/80 transition-colors hover:text-bg",children:"Edit \u2197"})]}),r("div",{className:"flex flex-col px-6 py-2",children:a.length===0?c("div",{className:"py-8 text-center font-serif text-[16px] italic leading-[1.5] text-fg-dim",children:["Your cart is empty. ",r(Z,{href:"/wheels",className:"text-accent underline-offset-4 hover:underline",children:"Browse the catalog \u2192"})]}):a.map(i=>r(Xr,{slug:i.slug,name:i.name,qty:i.qty,config:i.config,configSummary:Zr(i.config),price:Dt(i,o.currency)??0,currency:o.currency},i.id))}),r("div",{className:"border-t border-line px-6 pt-5",children:r(Yt,{customerEmail:ee})}),c("div",{className:"flex flex-col gap-2 border-t border-line mt-5 px-6 pt-5",children:[r(ie,{label:"Subtotal",value:S(o.subtotal,o.currency)}),o.discount>0&&s?.valid&&r(ie,{label:`Coupon \xB7 ${s.code}`,value:c("span",{className:"font-semibold text-green",children:["\u2212 ",S(o.discount,o.currency)]})}),s?.deferred&&r(ie,{label:`Coupon \xB7 ${s.code}`,value:Lt}),s?.valid&&s.effects?.gift&&r(ie,{label:`Free gift \xB7 ${s.effects.gift.partNumber}${s.effects.gift.quantity>1?` \xD7${s.effects.gift.quantity}`:""}`,value:r("span",{className:"font-semibold text-green",children:"Free"})}),r(ie,{label:"Shipping",value:o.freeShipping||o.shipping===0?r("span",{className:"font-semibold text-green",children:"Free"}):S(o.shipping,o.currency)}),o.tax&&(o.tax.charged?r(ie,{label:o.tax.inclusive?`${o.tax.name} included \xB7 ${o.tax.rate}%`:o.tax.name,value:S(o.tax.amount,o.currency)}):o.tax.name?r(ie,{label:o.tax.name,value:"Calculated at checkout"}):null)]}),c("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:[r("span",{className:"font-display text-[20px] font-bold uppercase tracking-[0.04em] text-fg",children:"Total"}),r("span",{className:"text-right font-display text-[34px] font-bold leading-none tracking-[-0.025em] text-fg",children:o.repricing?"\u2026":S(o.grand,o.currency)})]}),c("div",{className:"flex flex-col gap-2.5 px-6 pt-[18px] pb-6",children:[ht&&r("p",{className:"border border-red-300 bg-red-50 px-3 py-2 text-[13px] text-red-700",children:ht}),o.hasUnpricedLine&&c("p",{className:"border border-amber-300 bg-amber-50 px-3 py-2 text-[13px] text-amber-800",children:["One or more items have no price in ",o.currency,". Remove them, or switch region, to continue."]}),r("button",{type:"button",onClick:nr,disabled:ce||a.length===0||o.hasUnpricedLine||o.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",a.length===0||ce||o.hasUnpricedLine||o.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:ce?c(q,{children:["Building order\u2026 ",r("span",{children:"\xB7"})]}):o.repricing?c(q,{children:["Updating total\u2026 ",r("span",{children:"\xB7"})]}):c(q,{children:[w==="bank"?"Place order":"Continue to payment"," \xB7"," ",S(o.grand,o.currency),r("span",{className:"transition-transform group-hover:translate-x-1",children:"\u2192"})]})})]})]})]}),r("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:r("span",{children:Ut({legalName:t.legalName,foundedYear:t.foundedYear,siteName:t.name})})})]})}var K="w-full border-2 border-line bg-bg px-4 py-3.5 font-display text-[17px] tracking-[-0.005em] text-fg outline-none transition-colors placeholder:text-fg-dim hover:border-fg-dim focus:border-accent",qn={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 $e({num:t,title:e,children:n}){return c("section",{className:"mb-6 border border-line bg-bg",children:[c("header",{className:"flex items-center gap-4 border-b border-line bg-surface px-6 py-3.5",children:[r("span",{className:"inline-flex items-center justify-center bg-accent px-2.5 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t}),r("h2",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:e})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:n})]})}function _n({cols:t="two",children:e}){return r("div",{className:["grid gap-3 max-[640px]:grid-cols-1",t==="two"?"grid-cols-2":"grid-cols-[1.2fr_1fr_1fr]"].join(" "),children:e})}function Ke({active:t,onClick:e,title:n,body:a,price:o,tag:s}){return c("button",{type:"button",onClick:e,"aria-pressed":t,className:["relative grid grid-cols-[auto_1fr_auto] items-center gap-[18px] border bg-bg px-[22px] py-[18px] text-left transition-colors",t?"border-accent outline outline-1 outline-accent -outline-offset-1":"border-line hover:border-[color-mix(in_oklab,var(--accent)_50%,var(--site-line))]"].join(" "),style:t?{background:"color-mix(in oklab, var(--accent) 14%, var(--bg))"}:void 0,children:[t&&r("span",{"aria-hidden":!0,className:"absolute inset-y-0 left-0 w-[3px] bg-accent"}),r("span",{className:["flex h-[18px] w-[18px] items-center justify-center rounded-full border-2",t?"border-accent":"border-fg-dim"].join(" "),children:t&&r("span",{className:"block h-2.5 w-2.5 rounded-full bg-accent"})}),c("span",{className:"flex min-w-0 flex-col gap-1",children:[c("span",{className:"flex flex-wrap items-baseline gap-2.5 font-display text-[18px] font-medium tracking-[-0.01em] text-fg",children:[n,s&&r("span",{className:"border px-1.5 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})]}),a&&r("span",{className:"font-mono text-[12px] uppercase tracking-[0.22em] text-fg-dim",children:a})]}),r("span",{className:"whitespace-nowrap font-display text-[18px] font-medium tracking-[-0.01em] text-fg",children:o})]})}function Br({payment:t,onPaid:e,onSkip:n}){let{formatMoney:a}=oe(),o=Ye(()=>Cn(t.publishableKey),[t.publishableKey]),s=Ye(()=>{if(typeof document>"u")return;let l=getComputedStyle(document.documentElement),d=(u,v)=>l.getPropertyValue(u).trim()||v,p=document.documentElement.getAttribute("data-theme")!=="light";return{theme:p?"night":"stripe",variables:{colorPrimary:d("--accent",p?"#c9a461":"#8a6a2a"),colorBackground:d("--site-surface",p?"#131313":"#ffffff"),colorText:d("--fg",p?"#f5f1e8":"#0a0a0a"),borderRadius:"0px"}}},[]);return r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:c("div",{className:"w-full max-w-xl border border-line bg-bg",children:[c("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-3.5",children:[r("span",{className:"inline-flex items-center justify-center bg-accent px-2.5 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t.orderNumber}),r("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"Payment"})]}),c("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:["Your order is placed. Pay"," ",r("span",{className:"text-fg",children:a(Number(t.amount),t.currency)})," ","by card to confirm it now."]}),r(nt,{stripe:o,options:{clientSecret:t.clientSecret,appearance:s},children:r(zr,{payment:t,onPaid:e,onSkip:n})})]})]})})}function zr({payment:t,onPaid:e,onSkip:n}){let{formatMoney:a}=oe(),o=fn(),s=dn(),[l,d]=g(!1),[p,u]=g(null);async function v(){if(!o||!s||l)return;d(!0),u(null);let x=await o.confirmPayment({elements:s,redirect:"if_required"});if(x.error){u(x.error.message??"Payment failed. Please try again."),d(!1);return}let m=x.paymentIntent?.status;if(m==="succeeded"||m==="processing"){e();return}u("Payment did not complete. Please try again."),d(!1)}return c("div",{className:"flex flex-col gap-4",children:[r(gn,{}),p&&r("p",{className:"border border-red-300 bg-red-50 px-3 py-2 text-[13px] text-red-700",children:p}),r("button",{type:"button",onClick:v,disabled:!o||!s||l,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",!o||!s||l?"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:l?c(q,{children:["Processing\u2026 ",r("span",{children:"\xB7"})]}):c(q,{children:["Pay ",a(Number(t.amount),t.currency),r("span",{className:"transition-transform group-hover:translate-x-1",children:"\u2192"})]})}),r("button",{type:"button",onClick:n,disabled:l,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 Fn="paypal-sdk-js",it=null;function Hr(t,e){let n=`${t}|${e}`;if(it?.key===n)return it.promise;let a=new Promise((o,s)=>{document.getElementById(Fn)?.remove();let l=document.createElement("script");l.id=Fn;let d=new URLSearchParams({"client-id":t,currency:e,intent:"capture"});l.src=`https://www.paypal.com/sdk/js?${d}`,l.onload=()=>{let p=window.paypal;p?o(p):s(new Error("PayPal SDK loaded without its namespace"))},l.onerror=()=>s(new Error("PayPal SDK failed to load")),document.head.appendChild(l)});return it={key:n,promise:a},a}function Vr({confirmation:t,clientId:e,idemKey:n,onPaid:a,onSkip:o}){let{formatMoney:s}=oe(),l=se(null),[d,p]=g(!1),[u,v]=g(null),x=se(a);return x.current=a,Y(()=>{let m=!1,h=null;return Hr(e,t.currency).then(A=>{if(!(m||!l.current))return h=A.Buttons({style:{layout:"vertical",color:"gold",shape:"rect",label:"paypal"},createOrder:async()=>(await T.createPaypalOrder({idempotencyKey:n})).paypalOrderId,onApprove:async C=>{try{if((await T.capturePaypalOrder({idempotencyKey:n,paypalOrderId:C.orderID})).status==="paid"){x.current();return}v("PayPal did not complete the payment. Please try again.")}catch(S){v(S instanceof qe?S.message:"PayPal payment failed. Please try again.")}},onError:()=>{v("PayPal could not process the payment. Please try again.")}}),h.render(l.current).then(()=>{m||p(!0)})}).catch(()=>{m||v("PayPal could not be loaded. You can pay later \u2014 your order stands either way.")}),()=>{m=!0,h?.close?.()}},[e,t.currency,n]),r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:c("div",{className:"w-full max-w-xl border border-line bg-bg",children:[c("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-3.5",children:[r("span",{className:"inline-flex items-center justify-center bg-accent px-2.5 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t.orderNumber}),r("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"PayPal"})]}),c("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:["Your order is placed. Pay"," ",r("span",{className:"text-fg",children:s(Number(t.grandTotal),t.currency)})," ","with PayPal to confirm it now."]}),!d&&!u&&r("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading PayPal\u2026"}),r("div",{ref:l}),u&&r("p",{className:"border border-red-300 bg-red-50 px-3 py-2 text-[13px] text-red-700",children:u}),r("button",{type:"button",onClick:o,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 Dn="square-web-sdk",st=null;function Gr(t){let e=t==="sandbox"?"sandbox":"production";if(st?.key===e)return st.promise;let n=new Promise((a,o)=>{document.getElementById(Dn)?.remove();let s=document.createElement("script");s.id=Dn,s.src=e==="sandbox"?"https://sandbox.web.squarecdn.com/v1/square.js":"https://web.squarecdn.com/v1/square.js",s.onload=()=>{let l=window.Square;l?a(l):o(new Error("Square SDK loaded without its namespace"))},s.onerror=()=>o(new Error("Square SDK failed to load")),document.head.appendChild(s)});return st={key:e,promise:n},n}function Jr({confirmation:t,applicationId:e,locationId:n,environment:a,idemKey:o,onPaid:s,onSkip:l}){let{formatMoney:d}=oe(),p=se(null),u=se(null),v=se(null),[x,m]=g(!1),[h,A]=g(!1),[C,S]=g(null);Y(()=>{let D=!1,O=null;return Gr(a).then(async V=>{if(D||!p.current)return;let Q=V.payments(e,n);v.current=Q,O=await Q.card(),await O.attach(p.current),u.current=O,D||m(!0)}).catch(()=>{D||S("Square could not be loaded. You can pay later \u2014 your order stands either way.")}),()=>{D=!0,O?.destroy?.()}},[e,n,a]);async function w(){let D=u.current;if(!(!D||h)){A(!0),S(null);try{let O=await D.tokenize();if(O.status!=="OK"||!O.token){S(O.errors?.[0]?.message??"Please check the card details and try again."),A(!1);return}let V;try{V=(await v.current?.verifyBuyer?.(O.token,{amount:String(t.grandTotal),currencyCode:t.currency,intent:"CHARGE"}))?.token}catch{}if((await T.chargeSquare({idempotencyKey:o,sourceId:O.token,...V?{verificationToken:V}:{}})).status==="paid"){s();return}S("Square did not complete the payment. Please try again.")}catch(O){S(O instanceof qe?O.message:"Square payment failed. Please try again.")}A(!1)}}return r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:c("div",{className:"w-full max-w-xl border border-line bg-bg",children:[c("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-3.5",children:[r("span",{className:"inline-flex items-center justify-center bg-accent px-2.5 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t.orderNumber}),r("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"Card"})]}),c("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:["Your order is placed. Pay"," ",r("span",{className:"text-fg",children:d(Number(t.grandTotal),t.currency)})," ","by card to confirm it now."]}),!x&&!C&&r("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading card form\u2026"}),r("div",{ref:p}),C&&r("p",{className:"border border-red-300 bg-red-50 px-3 py-2 text-[13px] text-red-700",children:C}),r("button",{type:"button",onClick:w,disabled:!x||h,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",!x||h?"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:h?c(q,{children:["Processing\u2026 ",r("span",{children:"\xB7"})]}):c(q,{children:["Pay ",d(Number(t.grandTotal),t.currency),r("span",{className:"transition-transform group-hover:translate-x-1",children:"\u2192"})]})}),r("button",{type:"button",onClick:l,disabled:h,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"})]})]})})}function Mn({checked:t,onChange:e,label:n,sub:a}){return c("div",{className:"flex items-start gap-3 border-t border-line py-3.5 first:border-t-0 first:pt-0",children:[r("button",{type:"button",onClick:()=>e(!t),"aria-pressed":t,"aria-label":n,className:["mt-px flex h-5 w-5 flex-shrink-0 items-center justify-center border transition-colors",t?"border-accent":"border-line"].join(" "),style:t?{background:"color-mix(in oklab, var(--accent) 18%, transparent)"}:void 0,children:t&&r("span",{className:"text-[13px] text-accent",children:"\u2713"})}),c("span",{className:"flex-1 font-display text-[16px] leading-[1.5] text-fg",children:[n,a&&r("small",{className:"mt-1 block font-mono text-[12px] uppercase tracking-[0.18em] text-fg-dim",children:a})]})]})}function Xr({slug:t,name:e,qty:n,config:a,configSummary:o,price:s,currency:l}){let{catalog:d}=Je(),{formatMoney:p}=oe(),u=d.find(C=>C.slug===t),v=u?.spokes??5,x=u?.mesh??!1,m=a.find(C=>C.gold)?.label,h=u?.finishes.find(C=>C.name===m&&C.src)??u?.finishes.find(C=>C.src),A=u?.finishes[0]?.color??$t;return c("div",{className:"grid grid-cols-[60px_1fr_auto] items-center gap-3.5 border-b border-line py-4 last:border-b-0",children:[c("div",{className:"relative flex aspect-square items-center justify-center overflow-hidden border border-line bg-surface",children:[r("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}),h?.src?r(Rt,{src:h.src,alt:`${e.lead}${e.accent} \u2014 ${h.name}`,width:120,height:120,sizes:"60px",className:"relative block h-full w-full object-contain p-1.5"}):r("div",{className:"block w-[78%]",style:{color:A},children:r(Kt,{spokes:v,mesh:x,className:"block w-full"})})]}),c("div",{className:"flex min-w-0 flex-col gap-0.5",children:[c("span",{className:"font-display text-[17px] font-bold uppercase leading-none tracking-[-0.005em] text-fg",children:[e.lead,r("em",{className:"font-serif font-normal italic text-accent tracking-[-0.005em] normal-case",children:e.accent})]}),r("span",{className:"font-mono text-[12px] uppercase leading-[1.5] tracking-[0.18em] text-fg-dim",children:o})]}),r("span",{className:"text-right font-display text-[17px] font-bold tracking-[-0.005em] text-fg",children:p(s,l)})]})}function ie({label:t,value:e}){return c("div",{className:"flex items-center justify-between font-mono text-[13px] font-medium uppercase tracking-[0.18em] text-fg",children:[r("span",{children:t}),r("strong",{className:"font-display text-[16px] font-medium tracking-[-0.005em] normal-case text-fg",children:e})]})}function Zr(t){return t.map(e=>e.label).join(" \xB7 ")}import{jsx as Be}from"react/jsx-runtime";function Qr(){let{settings:t,websiteName:e}=It(),n=e?{...Xe,name:e}:Xe,a=t?{url:t.logoUrl,reversed:t.logoReversed??null,inkIsDark:t.logoInkIsDark??null,reverse:t.reverseLogo,size:t.logoSize,sizePx:t.logoSizePx}:null;return Be("div",{style:{position:"fixed",inset:0,zIndex:2147482e3,overflowY:"auto",background:"var(--bg)",color:"var(--fg)"},children:Be(Ft,{children:Be(Mt,{preview:!0,children:Be(ct,{site:n,logo:a,preview:!0})})})})}export{Qr as default};
@@ -1 +1 @@
1
- "use client";import{_ as m,l as g}from"./chunk-MIXL2LLM.js";import{Jd as u,ag as f}from"./chunk-BVXI5N6D.js";import"./chunk-XBW7A5SW.js";import"./chunk-UGTQGAHF.js";import{Ga as s,La as a,Ma as d,Qa as c}from"./chunk-HYLRHFHP.js";import"./chunk-TP6VLEFI.js";import"./chunk-Y6SLVHK3.js";import{Render as I}from"efficient-easel/render";import{jsx as p}from"react/jsx-runtime";function i({footerBlock:r,rootProps:e,headerSettings:o,siteName:t,legalName:l,foundedYear:n,socialLinks:h}){let v=g({root:{props:{...e??{},kind:u}},content:[r],zones:{}});return p(s.Provider,{value:{logoUrl:o?.logoUrl??null,logoReversed:o?.logoReversed??null,logoInkIsDark:o?.logoInkIsDark??null,siteName:t,legalName:l??null,foundedYear:n??null,socialLinks:h??c},children:p(I,{config:m,data:v})})}import{jsx as k}from"react/jsx-runtime";function P(){let{footerBlock:r,editFooter:e}=f(),{settings:o,websiteName:t}=a();if(!r)return null;let l=o?{logoUrl:o.logoUrl,logoReversed:o.logoReversed??null,logoInkIsDark:o.logoInkIsDark??null}:null;return k("div",{className:"sf-preview-footer-pick",onClick:e?n=>{n.stopPropagation(),e()}:void 0,style:e?{cursor:"pointer"}:void 0,title:e?"Edit the site footer \u2192":void 0,children:k(i,{footerBlock:r,headerSettings:l,siteName:t?.trim()||d})})}export{P as default};
1
+ "use client";import{_ as m,l as g}from"./chunk-YBLUQOUU.js";import{Jd as u,ag as f}from"./chunk-HURDX4EH.js";import"./chunk-3KTQYH72.js";import"./chunk-K5TEC2IE.js";import{Ga as s,La as a,Ma as d,Qa as c}from"./chunk-HYLRHFHP.js";import"./chunk-EJ2NLQYY.js";import"./chunk-Y6SLVHK3.js";import{Render as I}from"efficient-easel/render";import{jsx as p}from"react/jsx-runtime";function i({footerBlock:r,rootProps:e,headerSettings:o,siteName:t,legalName:l,foundedYear:n,socialLinks:h}){let v=g({root:{props:{...e??{},kind:u}},content:[r],zones:{}});return p(s.Provider,{value:{logoUrl:o?.logoUrl??null,logoReversed:o?.logoReversed??null,logoInkIsDark:o?.logoInkIsDark??null,siteName:t,legalName:l??null,foundedYear:n??null,socialLinks:h??c},children:p(I,{config:m,data:v})})}import{jsx as k}from"react/jsx-runtime";function P(){let{footerBlock:r,editFooter:e}=f(),{settings:o,websiteName:t}=a();if(!r)return null;let l=o?{logoUrl:o.logoUrl,logoReversed:o.logoReversed??null,logoInkIsDark:o.logoInkIsDark??null}:null;return k("div",{className:"sf-preview-footer-pick",onClick:e?n=>{n.stopPropagation(),e()}:void 0,style:e?{cursor:"pointer"}:void 0,title:e?"Edit the site footer \u2192":void 0,children:k(i,{footerBlock:r,headerSettings:l,siteName:t?.trim()||d})})}export{P as default};
@@ -0,0 +1 @@
1
+ "use client";import{l as t}from"./chunk-6EH27IKS.js";import"./chunk-HURDX4EH.js";import"./chunk-HYLRHFHP.js";import"./chunk-EJ2NLQYY.js";import"./chunk-Y6SLVHK3.js";import{jsx as e}from"react/jsx-runtime";import{default as r}from"efficient-easel/screen/components/ScreenStoreProvider";function p(o){return e(r,{...o,parts:t})}export{p as default};
@@ -1 +1 @@
1
- import{f as nt,i as fe,p as rt,r as ot,t as q}from"./chunk-UGTQGAHF.js";import{Ma as me,Na as Ze,Qa as Ae,Ra as et}from"./chunk-HYLRHFHP.js";import{e as Je,r as tt,t as re}from"./chunk-TP6VLEFI.js";import{createContext as Qt,useContext as Xt,useEffect as Jt,useMemo as ge,useState as st}from"react";function it(e,t){return e.map(n=>({partNumber:n.partNumber,quantity:n.wheels*t}))}function oe(e,t){if(e.length===0)return null;let n=0;for(let r of e){let o=r.prices?.[t];if(typeof o!="number"||!Number.isFinite(o)||o<=0)return null;n+=o*r.wheels}return n}var Me=4,ir=1,ar={unit:"set",spares:0,spareSide:"left"};function at(e){return e.unit==="single"?1:Me+e.spares}function sr(e,t){return[{partNumber:e.partNumber,wheels:at(t),prices:e.prices}]}function lr(e,t){let n=at(t)-Me;if(n<=0||e.length===0)return e;let r=Yt(e),o=r?r[t.spareSide]:0;return e.map((i,a)=>a===o?{...i,wheels:i.wheels+n}:i)}function Yt(e){let t,n;for(let r=0;r<e.length;r+=1){let o=e[r].hand;if(o!=="left"&&o!=="right")continue;if((o==="left"?t:n)!==void 0)return null;o==="left"?t=r:n=r}return t!==void 0&&n!==void 0?{left:t,right:n}:null}function jt(e,t){return t.spares>0?`${e} + spare`:e}function ur(e){return e.unit==="single"?"Single":jt(`Set of ${Me}`,e)}var cr="data-add-to-basket",De=9,Oe="en";function pe(e,t,n=0){return new Intl.NumberFormat(Oe,{style:"currency",currency:t,minimumFractionDigits:0,maximumFractionDigits:n}).format(e)}import{jsx as tn}from"react/jsx-runtime";var lt="storefront-country",ut=Qt(null);function Zt(e){return ct(e,"catalogue")}function en(e){return ct(e,"money")}function ct(e,t){let n=new Map(e.map(o=>[o.code,o.decimalPlaces])),r=new Map;return(o,i)=>{if(!i)return"";let a=r.get(i);if(!a){let u=n.get(i)??0;a=new Intl.NumberFormat(Oe,{style:"currency",currency:i,minimumFractionDigits:t==="money"?u:0,maximumFractionDigits:u}),r.set(i,a)}return a.format(o)}}function gr({children:e,currencies:t,countries:n,defaultCurrency:r,defaultCountry:o}){let i=ge(()=>t??[],[t]),a=ge(()=>n??[],[n]),u=ge(()=>r||i.find(C=>C.isDefault)?.code||i[0]?.code||"",[r,i]),c=ge(()=>o||a.find(C=>C.isDefault)?.code||a[0]?.code||"",[o,a]),[l,d]=st(c),[f,P]=st(!1);Jt(()=>{let C=re.getItem(lt);C&&a.some(I=>I.code===C)&&d(C),P(!0)},[a]);function L(C){d(C),re.setItem(lt,C)}let h=ge(()=>{let C=a.find(w=>w.code===l)??null,I=C?.currency,T=I&&i.some(w=>w.code===I)?I:u,M=Zt(i),x=en(i);return{country:l,currency:T,setCountry:L,currencies:i,countries:a,activeCountry:C,formatPrice:(w,S)=>M(w,S??T),formatMoney:(w,S)=>x(w,S??T),ready:f}},[l,i,a,u,f]);return tn(ut.Provider,{value:h,children:e})}function dt(){let e=Xt(ut);if(!e)throw new Error("useCurrency must be used within a CurrencyProvider");return e}import{createContext as pn,useCallback as k,useContext as gn,useEffect as Y,useMemo as St,useRef as ie,useState as R}from"react";function ft(e,t){return e.valid?!1:e.reason==="firstOrderOnly"?!0:e.reason==="notEligible"&&!t}var pt="We'll confirm this discount when you place your order.",Cr="Confirmed at checkout";function xr(e){return e&&(e.valid||e.deferred)?e.code:void 0}var mt="coupon_code: ";function Sr(e){return!(e instanceof fe)||e.status!==400||!e.message.startsWith(mt)?null:e.message.slice(mt.length)}function gt(e,t){return e.map(n=>({qty:n.qty,slug:n.slug,name:`${n.name.lead}${n.name.accent}`.trim(),finish:n.finishName,size:n.size,kind:n.kind,sku:n.sku,pack:n.pack,priceLabel:t(n)}))}var Pe="Price on request",rn="Request a quote";function Fe(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Ue(e,t){let n=e?.[t];return Fe(n)?n:null}function Ir(e,t,n,r){let o=Ue(e,n),i=Ue(t,n);return o===null&&i===null?0:o===null?1:i===null?-1:r==="asc"?o-i:i-o}function wr(e,t,n,r){if(n==null&&r==null)return!0;let o=Ue(e,t);return!(o===null||n!=null&&o<n||r!=null&&o>r)}var on={priced:!1,unit:null,was:null,onSale:!1,setTotal:null};function an(e,t,n){if(!Fe(e))return on;let r=Fe(t)&&t>e?t:null;return{priced:!0,unit:e,was:r,onSale:r!==null,setTotal:n!=null?e*n:null}}function Lr(e,t,n=""){return!e.priced||e.unit==null?Pe:`${n}${pe(e.unit,t)}`}function Nr(e,t){return e.was==null?null:pe(e.was,t)}function sn(e,t,n=1){let r=oe(e,t);if(r===null)return{priced:!1,unit:null,isFrom:!1,setTotal:null};let o=e.reduce((a,u)=>a+u.wheels,0),i=Math.min(...e.map(a=>a.prices[t]));return{priced:!0,unit:i,isFrom:i*o!==r,setTotal:r*n}}var ln={priced:!1,unit:null,isFrom:!1,was:null,onSale:!1,setTotal:null};function Tr(e,t,n,r=1){let o=an(e.prices[n],e.msrpPrices?.[n],4),i=o.setTotal==null?null:o.setTotal*r;if(!t)return{priced:o.priced,unit:o.unit,isFrom:!0,was:o.was,onSale:o.onSale,setTotal:null,fromSetTotal:i};let a=sn(t.components,n,r);return a.priced?{priced:!0,unit:a.unit,isFrom:a.isFrom,was:null,onSale:!1,setTotal:a.setTotal,fromSetTotal:i}:{...ln,fromSetTotal:i}}function un(e,t){return!e.priced||e.unit==null?Pe:`${e.isFrom?"from ":""}${pe(e.unit,t)}`}function _r(e,t){return e.was==null?null:pe(e.was,t)}function kr(e,t){return!e.priced||e.unit==null?rn:un(e,t)}var cn=/^[^@\s]+@[^@\s]+\.[^@\s]+$/;function yt(e){return cn.test(e.trim())}var bt="sf:ga-purchases",dn=20;function Ct(){return typeof window>"u"||window.parent!==window}function ye(...e){try{if(Ct()||typeof window.gtag!="function")return;window.gtag(...e)}catch{}}function mn(e,t){let n=e.config.find(r=>r.gold)?.label;return{item_id:`${e.slug}|${e.finishName}|${e.size}`,item_name:`${e.name.lead}${e.name.accent}`.trim(),...n?{item_variant:n}:{},price:oe(e.components,t)??0,quantity:e.qty}}function $e(e,t){return e.filter(Ie).map(n=>mn(n,t))}function Fr(e){ye("event","view_item",{currency:e.currency,value:e.pricePerSet,items:[{item_id:e.itemId,item_name:e.itemName,...e.variant?{item_variant:e.variant}:{},price:e.pricePerSet,quantity:1}]})}function xt(e,t){let n=$e([e],t);n.length!==0&&ye("event","add_to_cart",{currency:t,value:n[0].price*n[0].quantity,items:n})}function Ur(e){let t=$e(e.lines,e.currency);t.length!==0&&ye("event","begin_checkout",{currency:e.currency,value:e.value,...e.coupon?{coupon:e.coupon}:{},items:t})}var ht=new Set;function fn(e){if(ht.has(e))return!1;ht.add(e);try{let t=JSON.parse(re.getItem(bt)??"[]");if(t.includes(e))return!1;re.setItem(bt,JSON.stringify([...t,e].slice(-dn)))}catch{}return!0}function $r(e){let t=e.confirmation;if(Ct()||!fn(t.orderNumber))return;let n=t.currency,r=Number(t.grandTotal);ye("event","purchase",{transaction_id:t.orderNumber,currency:n,value:r,shipping:Number(t.freightCharge),...t.couponCode?{coupon:t.couponCode}:{},items:$e(e.lines,n)}),e.adsSendTo&&ye("event","conversion",{send_to:e.adsSendTo,transaction_id:t.orderNumber,currency:n,value:r})}import{jsx as Cn}from"react/jsx-runtime";var yn=400,bn=400,hn=1500;function Ie(e){return(e.components?.length??0)>0}function vt(e,t){return{code:e,valid:t.valid,deferred:ft(t,t.askedAsShopper),message:t.message||void 0,effects:t.effects??void 0}}function Pt(e,t){return oe(e.components,t)}function qe(e,t){let n=Pt(e,t);return n===null?null:n*e.qty}function Et(e){return e!=="tyre"}var It=pn(null);function Qr({children:e,preview:t=!1}){let{currency:n,country:r,formatMoney:o}=dt(),[i,a]=R(t),[u,c]=R([]),[l,d]=R([]),[f,P]=R([]),[L,h]=R(!1),[C,I]=R(!1),[T,M]=R(!1),[x,w]=R(!1),[S,K]=R(null),[W,Q]=R(void 0),b=ie(r),v=ie("");b.current=b.current||r;let[m,H]=R(null),[X,z]=R(!1),[A,J]=R(null),Z=ie(void 0),D=k(()=>a(!0),[]),xe=k(()=>a(!1),[]),O=k(()=>a(s=>!s),[]);Y(()=>{t||typeof window>"u"||new URLSearchParams(window.location.search).get("cart")==="open"&&D()},[D,t]);let Se=k(s=>{w(!0),Et(s)&&M(!0)},[]),ee=T||u.some(s=>Et(s.kind)),se=x||u.length>0;Y(()=>{if(t||!ee||L)return;let s=!0;return q.listWheels().then(p=>{s&&(d(p),h(!0))}),()=>{s=!1}},[t,ee,L]),Y(()=>{if(t||!se||C)return;let s=!0;return q.listBundles().then(p=>{s&&(P(p),I(!0))}),()=>{s=!1}},[t,se,C]);let U=S?.deliveryOptions??[];Y(()=>{U.length!==0&&J(s=>s&&U.some(p=>p.id===s)?s:U[0]?.id??null)},[S]);let V=k(()=>u.filter(Ie).flatMap(s=>it(s.components,s.qty)),[u]),le=k(async(s,p)=>{let y=s.trim().toUpperCase();if(!y)return;let g=V();if(g.length===0){H({code:y,valid:!1,message:"Add a wheel to the cart first."});return}z(!0),Z.current=p;try{let N=await q.validateCoupon({code:y,items:g,currency:n,shippingMethodId:A??void 0,customerEmail:p});H(vt(y,N))}catch{H({code:y,valid:!1,message:"Could not check that code. Please try again."})}finally{z(!1)}},[V,n,A]),te=k(()=>{H(null),Z.current=void 0},[]),ve=k(s=>{if(!m)return;let{code:p}=m;H(y=>y&&y.code===p?{code:p,valid:!1,refused:!0,message:s}:y)},[m]);Y(()=>{if(!m||m.refused)return;let s=m.code,p=g=>g!==null&&g.code===s&&!g.refused,y=setTimeout(async()=>{let g=V();if(g.length===0){H(N=>p(N)?{code:s,valid:!1,message:"Add a wheel to the cart first."}:N);return}z(!0);try{let N=await q.validateCoupon({code:s,items:g,currency:n,shippingMethodId:A??void 0,customerEmail:Z.current});H(de=>p(de)?vt(s,N):de)}catch{}finally{z(!1)}},yn);return()=>clearTimeout(y)},[u,n,A]);let ue=m&&!m.refused?m.code:void 0;Y(()=>{if(t)return;let s=!0,p=setTimeout(async()=>{let y=V();if(y.length===0){K(null),Q(void 0);return}try{let g=await q.quoteCart({items:y,currency:n,shippingMethodId:A??void 0,couponCode:ue,customerEmail:Z.current||void 0,country:b.current||void 0,subdivision:v.current||void 0});if(!s)return;K(g)}catch{if(!s)return}Q(ue)},bn);return()=>{s=!1,clearTimeout(p)}},[u,n,A,ue,r]);let E=k(s=>{c(p=>{let y=p.findIndex(g=>g.id===s.id);return y===-1?[...p,s]:p.map((g,N)=>N===y?{...g,qty:Math.min(De,g.qty+s.qty)}:g)}),xt(s,n)},[n]),F=k(s=>{c(p=>p.filter(y=>y.id!==s))},[]),G=k((s,p)=>{let y=Math.max(1,Math.min(De,p));c(g=>g.map(N=>N.id===s?{...N,qty:y}:N))},[]),ze=k(s=>{c(s)},[]),[ce,Kt]=R(null),Ve=ie(null);Ve.current=ce;let $=ie(null),ke=ie(""),Ge=k((s,p)=>{let y=s.trim().toLowerCase();yt(y)&&Kt(g=>g&&g.email===y&&g.firstName===(p??"")?g:{email:y,firstName:p??""})},[]);Y(()=>{if(t||!ce)return;let s=gt(u.filter(Ie),g=>qe(g,n)===null?Pe:o(qe(g,n),n)),p={email:ce.email,firstName:ce.firstName,currency:n,items:s},y=JSON.stringify(p);if(y!==ke.current)return $.current&&clearTimeout($.current),$.current=setTimeout(()=>{$.current=null,ke.current=y,q.captureCart(p).catch(g=>{})},hn),()=>{$.current&&(clearTimeout($.current),$.current=null)}},[u,ce,n,t]);let Ye=k(()=>{$.current&&(clearTimeout($.current),$.current=null);let s=Ve.current;s&&(ke.current="",q.captureCart({email:s.email,firstName:s.firstName,currency:n,items:[]}).catch(p=>{}))},[n]),je=St(()=>{let s=u.reduce((_,ne)=>{let Ee=qe(ne,n);return Ee===null?_:_+Ee},0),p=u.some(_=>Pt(_,n)===null),y=u.reduce((_,ne)=>_+ne.qty,0),g=m?.valid?m.effects:void 0,N=g?Math.min(s,Number(g.discountAmount)):0,de=S?.bundleDiscount??0,Wt=S?.appliedBundles??[],Qe=!!g?.freeShipping,Bt=U.find(_=>_.id===A),Xe=Qe?0:S?.shipping??Bt?.amount??0,Re={};for(let _ of g?.freeUnits??[])Re[_.partNumber]=(Re[_.partNumber]??0)+_.quantity;let zt=S?.tax??null,Vt=S?S.grandTotal:s-N-de+Xe;return{sets:y,units:u.reduce((_,ne)=>_+(ne.components??[]).reduce((Ee,Gt)=>Ee+Gt.wheels*ne.qty,0),0),subtotal:s,hasUnpricedLine:p,discount:N,bundleDiscount:de,appliedBundles:Wt,shipping:Xe,freeShipping:Qe,freeUnitsByPartNumber:Re,tax:zt,grand:Vt,repricing:!!m?.refused&&S!==null&&W===m?.code,currency:n}},[u,n,m,U,A,S,W]),Ht=St(()=>({isOpen:i,preview:t,open:D,close:xe,toggle:O,items:u,catalog:l,bundles:f,warmCatalog:Se,add:E,remove:F,setQty:G,replaceItems:ze,identify:Ge,clearCapturedCart:Ye,coupon:m,applyCoupon:le,removeCoupon:te,refuseCoupon:ve,couponBusy:X,deliveryOptions:U,shippingMethodId:A,setShippingMethodId:J,totals:je}),[i,t,D,xe,O,u,l,f,Se,E,F,G,ze,Ge,Ye,m,le,te,ve,X,U,A,je]);return Cn(It.Provider,{value:Ht,children:e})}function wt(){let e=gn(It);if(!e)throw new Error("useCart() must be called inside <CartProvider>. Mount the provider in app/layout.tsx.");return e}import{cache as _n}from"react";function Lt(e,t,n,r){for(;e.size>=t;){let o,i;for(let[u,c]of e){if(c.expiresAt<=r){o=u;break}i===void 0&&n(u)&&(i=u)}let a=o??i??e.keys().next().value;if(a===void 0)return;e.delete(a)}}var xn=6e4,Sn=5e3,vn=500,we=new Map;async function En(e){let{host:t,matchesRequestHost:n}=await rt();if(!t)return"";let r=await ot();return r?`${e}|slug:${encodeURIComponent(t)}/${encodeURIComponent(r)}`:n?`${e}|host:${t}`:`${e}|xhost:${t}`}var Pn=e=>e.includes("|slug:")||e.includes("|xhost:");async function Nt(e,t){let n=await En(e);if(!n)return t();let r=Date.now(),o=we.get(n);if(o&&o.expiresAt>r)return o.load;let i=await t(),a=i.outcome.state==="failed",u=a?Sn:xn,c=we.get(n)?.lastGood,l=i.outcome.state==="ok"?i:a?c:void 0,d=a&&l?l:i;return Lt(we,vn,Pn,r),we.set(n,{load:d,expiresAt:r+u,lastGood:l}),d}var In=404;function wn(e){if(e instanceof fe&&e.status===In)return{state:"absent"};let t=e instanceof fe?e.status:-1,n=e instanceof Error?e.message:String(e);return{state:"failed",status:t,detail:n}}var Ln="[storefront:chrome-load-failed]";function Nn(e,t){console.error(`${Ln} ${e} status=${t.status} \u2014 serving fallback chrome`,t.detail)}async function Tt(e,t,n,r){try{let o=await t();return r?.(o)?{value:o,outcome:{state:"absent"}}:{value:o,outcome:{state:"ok"}}}catch(o){let i=wn(o);return i.state==="failed"&&Nn(e,i),{value:n,outcome:i}}}function Tn(e){return e==="production"?"silent":"banner"}var oo=Tn("production");function kn(e,t){return e?.trim()||t}function fo({legalName:e,foundedYear:t,siteName:n},r=new Date().getFullYear()){let o=kn(e,n);return`\xA9 ${t&&t<r?`${t}\u2013${r}`:`${r}`} ${o}`}var Rn={name:me,legalName:null,foundedYear:null,faviconUrl:null,currencies:[],defaultCurrency:null,countries:[],defaultCountry:null,commerceEnabled:!0,cardPayments:!1,paymentMethods:[],paypalClientId:null,paypalEnvironment:null,squareApplicationId:null,squareLocationId:null,squareEnvironment:null,ga4MeasurementId:null,googleAdsId:null,googleAdsConversionLabel:null,metaPixelId:null,mapsApiKey:null,mapsMapId:null,socialLinks:Ae},po=_n(async()=>Nt("site",()=>Tt("site",async()=>{let e=await q.getSite();return{name:Ze(e.name),legalName:e.legalName?.trim()||null,foundedYear:e.foundedYear??null,faviconUrl:e.faviconUrl??null,currencies:e.currencies??[],defaultCurrency:e.defaultCurrency??null,countries:e.countries??[],defaultCountry:e.defaultCountry??null,commerceEnabled:e.commerceEnabled??!0,cardPayments:e.cardPayments??!1,paymentMethods:e.paymentMethods??(e.cardPayments?["card"]:[]),paypalClientId:e.paypalClientId??null,paypalEnvironment:e.paypalEnvironment??null,squareApplicationId:e.squareApplicationId??null,squareLocationId:e.squareLocationId??null,squareEnvironment:e.squareEnvironment??null,ga4MeasurementId:e.ga4MeasurementId??null,googleAdsId:e.googleAdsId??null,googleAdsConversionLabel:(e.googleAdsId?e.googleAdsConversionLabel:null)??null,metaPixelId:e.metaPixelId??null,mapsApiKey:e.mapsApiKey??null,mapsMapId:e.mapsMapId??null,socialLinks:et(e.socialLinks)}},Rn)));var go={name:me,legalName:null,foundedYear:null,faviconUrl:null,currencies:[{code:"USD",symbol:"$",decimalPlaces:2,isDefault:!0}],defaultCurrency:"USD",countries:[{code:"US",name:"United States",currency:"USD",url:"",isDefault:!0,chargeTax:!1,taxDisplay:"none",taxName:"",taxRate:null,postalLabel:"Zip Code"}],defaultCountry:"US",commerceEnabled:!0,cardPayments:!0,paymentMethods:["card"],paypalClientId:null,paypalEnvironment:null,squareApplicationId:null,squareLocationId:null,squareEnvironment:null,ga4MeasurementId:null,googleAdsId:null,googleAdsConversionLabel:null,metaPixelId:null,mapsApiKey:null,mapsMapId:null,socialLinks:Ae};import{jsx as kt,jsxs as Rt}from"react/jsx-runtime";import{useEffect as Le,useRef as At,useState as Ne}from"react";var be=new Map,An=64;async function Mn(e){if(!Je())return null;try{let t=await fetch(`${tt()}/logo-analysis.json?url=${encodeURIComponent(e)}`);if(!t.ok)return null;let n=await t.json();if(!n||typeof n!="object")return null;let{reversed:r,inkIsDark:o}=n;return typeof r!="string"?null:{reversed:r,inkIsDark:typeof o=="boolean"?o:null}}catch{return null}}function _t(e){let t=be.get(e);if(t)return t;let n=Mn(e);if(be.set(e,n),be.size>An){let r=be.keys().next();r.done||be.delete(r.value)}return n}var Dn={small:54,medium:66,large:84},On=44,Fn=202/22,Io=16,wo=140,Un=.88,Lo=16,$n="invert(1)";function No({variant:e="header",scrolled:t=!0,src:n,reverse:r=!1,onLightSurface:o,reversedSrc:i,inkIsDark:a,size:u="medium",sizePx:c,wordmark:l,siteName:d=me,fitToContainer:f=!1,fitWordmarkToContainer:P=!1,fitFloorPx:L}){let h=l&&l.trim()?l.trim():d,[C,I]=Ne(!1),T=At(null),M=E=>{T.current=E};Le(()=>{let E=T.current?.ownerDocument??document,F=()=>{I(E.documentElement.getAttribute("data-theme")==="light")};F();let G=new MutationObserver(F);return G.observe(E.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>G.disconnect()},[]);let x=n&&n.trim()?n.trim():null,w=!!x&&nt(x),S=o??(C&&t),K=r&&w&&x&&i!=null?{reversed:i,inkIsDark:a??null}:null,W=K!==null,[Q,b]=Ne(null);Le(()=>{if(!r||!x||!w||W){b(null);return}let E=!1;return b(null),_t(x).then(F=>{E||b(F)}),()=>{E=!0}},[r,x,w,W]);let v=K??Q,m=!!v&&v.inkIsDark!==null&&(S?!v.inkIsDark:v.inkIsDark),H=r&&!!x&&!w&&!S,X=m&&v?v.reversed:x,z=X?[X]:[],[A,J]=Ne(0);Le(()=>{J(0)},[x,m]);let Z=e==="footer"?On:Dn[u],D=c&&c>0?c:Z,xe=Math.round(D*Fn),O=A<z.length?z[A]:null,[Se,ee]=Ne(X),se=O!==null&&O===Se,U=At(null);Le(()=>{let E=U.current;if(!E||!E.complete)return;if(E.naturalWidth>0||E.naturalHeight>0){ee(O);return}let F=!1;return E.decode().then(()=>!F&&ee(O),()=>!F&&J(G=>G+1)),()=>{F=!0}},[O]);let V=f||P,le=`calc(100cqi / ${((h.length+1)*Un).toFixed(2)})`,te=V&&L&&L>0?Math.min(L,D):null,ve=V?te===null?`min(${D}px, ${le})`:`clamp(${te}px, ${le}, ${D}px)`:`${D}px`,ue=Rt("span",{className:`font-display font-bold tracking-[0.18em] ${te===null?"whitespace-nowrap":"whitespace-normal"}`,style:{fontSize:ve,lineHeight:1},"aria-label":h,children:[h,kt("span",{className:"text-accent",children:"."})]});return Rt("span",{ref:M,className:"inline-flex items-center",children:[!se&&ue,O&&kt("img",{ref:U,src:O,alt:h,width:xe,height:D,className:"shrink-0 object-contain",style:{...se?{height:`${D}px`,width:"auto",...f?{maxWidth:"100cqi"}:{}}:{display:"none"},...H?{filter:$n}:{}},onLoad:()=>ee(O),onError:()=>J(E=>E+1)},O)]})}import{Children as Kn,isValidElement as Hn,useEffect as Dt,useId as Wn,useLayoutEffect as Bn,useRef as j,useState as Ot}from"react";var Te=(e,t)=>!!e[t]&&!e[t].disabled;function Ke(e,t,n){let r=e.length;for(let o=1;o<=r;o++){let i=((t+n*o)%r+r)%r;if(Te(e,i))return i}return t}function He(e,t){return Ke(e,t===1?-1:e.length,t)}function We(e,t){return Te(e,t)?t:Math.max(He(e,1),0)}function Mt(e,t,n){let{open:r,focus:o}=e,i=a=>({...e,...a});if(t.length===1&&/\S/.test(t)){let a=e.typed+t.toLowerCase(),u=n.findIndex((c,l)=>Te(n,l)&&c.label.toLowerCase().startsWith(a));return{state:i({open:!0,typed:a,focus:u>=0?u:o}),handled:!0}}if(!r)return t==="ArrowDown"||t==="ArrowUp"||t==="Enter"||t===" "?{state:i({open:!0,typed:""}),handled:!0}:{state:e,handled:!1};switch(t){case"ArrowDown":return{state:i({focus:Ke(n,o,1)}),handled:!0};case"ArrowUp":return{state:i({focus:Ke(n,o,-1)}),handled:!0};case"Home":return{state:i({focus:He(n,1)}),handled:!0};case"End":return{state:i({focus:He(n,-1)}),handled:!0};case"Enter":case" ":return Te(n,o)?{state:i({open:!1,typed:""}),commit:o,refocus:!0,handled:!0}:{state:e,handled:!0};case"Escape":return{state:i({open:!1,typed:""}),refocus:!0,handled:!0};case"Tab":return{state:i({open:!1,typed:""}),handled:!1};default:return{state:e,handled:!1}}}import{Fragment as jn,jsx as B,jsxs as Ft}from"react/jsx-runtime";function zn({items:e,value:t,onPick:n,open:r,onOpen:o,onClose:i}){let[a,u]=Ot(!1),c=r!==void 0,l=c?r:a,[d,f]=Ot(0),P=j({text:"",timer:0}),L=j(null),h=j(null),C=j(null),I=Wn(),T=j(null),M=e.findIndex(b=>b.value===t),x=b=>{b!==l&&(c||u(b),b?o?.():i?.())},w=b=>{let v=e[b];!v||v.disabled||(n(v.value),x(!1),h.current?.focus())},S=b=>{let v={open:l,focus:l?d:We(e,M),typed:P.current.text},m=Mt(v,b,e);return!m.handled&&m.state.open===l?!1:(m.state.typed!==v.typed&&(P.current.text=m.state.typed,window.clearTimeout(P.current.timer),P.current.timer=window.setTimeout(()=>{P.current.text=""},500)),f(m.state.focus),m.commit!==void 0?w(m.commit):x(m.state.open),m.refocus&&h.current?.focus(),m.handled)},K=j(S);K.current=S;let W=j(()=>x(!1));W.current=()=>x(!1);let Q=b=>{l||(T.current=b.nativeEvent,K.current(b.key)&&b.preventDefault())};return Dt(()=>{if(!l)return;let b=m=>{L.current?.contains(m.target)||W.current()},v=m=>{m!==T.current&&K.current(m.key)&&m.preventDefault()};return document.addEventListener("mousedown",b),document.addEventListener("keydown",v),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",v)}},[l]),Dt(()=>{l&&(P.current.text||f(We(e,M)))},[l]),Bn(()=>{if(!l||!C.current)return;C.current.children.item(d)?.scrollIntoView({block:"nearest"})},[d,l]),{open:l,toggle:()=>x(!l),close:()=>x(!1),focusIdx:d,setFocusIdx:f,pick:b=>w(e.findIndex(v=>v.value===b)),wrapRef:L,triggerRef:h,listRef:C,listId:I,onTriggerKeyDown:Q,activeId:l?`${I}-${d}`:void 0}}var Vn={select:{list:"absolute left-0 top-full z-50 mt-1 max-h-[280px] w-max min-w-full overflow-y-auto border-2 border-accent bg-bg shadow-xl",item:(e,t,n)=>["px-3 py-2.5 font-mono text-[13px] font-semibold uppercase tracking-[0.1em] transition-colors whitespace-nowrap",n?"cursor-not-allowed opacity-40":"cursor-pointer",e&&!n?"bg-accent text-bg":"bg-bg text-fg"].join(" ")},cell:{list:"absolute left-0 top-full z-50 mt-1 max-h-[320px] w-max min-w-full overflow-y-auto border-2 border-accent bg-bg shadow-xl",item:e=>["cursor-pointer whitespace-nowrap px-6 py-3 font-mono text-[length:var(--size-label,13px)] font-semibold uppercase tracking-[0.1em] transition-colors",e?"bg-accent text-bg":"bg-bg text-fg"].join(" "),pickerMarker:!0},hairline:{list:"absolute left-0 top-full z-50 max-h-[320px] w-full overflow-y-auto border border-line bg-bg shadow-[0_6px_20px_rgba(0,0,0,0.10)]",item:(e,t)=>["flex cursor-pointer items-center justify-between gap-4 border-b border-line px-4 py-3 text-left text-[length:var(--size-body,14px)] transition-colors last:border-b-0",t?"border-fg font-medium text-fg":e?"border-fg text-fg":"text-fg-dim"].join(" "),pickerMarker:!0},region:{list:"absolute right-0 top-full z-[200] mt-2 flex min-w-[240px] flex-col border border-line bg-surface text-fg",item:(e,t,n,r)=>["flex w-full cursor-pointer items-center gap-3 px-3.5 py-3 text-left transition-colors","font-mono text-[13px] uppercase tracking-[0.18em]",e?"bg-surface-2 text-fg":"",r?"":"border-b border-line",t?"text-accent":""].join(" "),itemStyle:e=>e?void 0:{color:"color-mix(in oklab, currentColor 80%, transparent)"}}};function Gn({id:e,tone:t,items:n,value:r,focusIdx:o,onFocus:i,onPick:a,listRef:u,ariaLabel:c}){let l=Vn[t];return B("ul",{ref:u,id:e,role:"listbox","aria-label":c,...l.pickerMarker?{"data-picker-menu":""}:{},className:l.list,children:n.map((d,f)=>{let P=d.value===r;return B("li",{id:`${e}-${f}`,role:"option","aria-selected":P,"aria-disabled":d.disabled||void 0,onMouseEnter:()=>!d.disabled&&i(f),onMouseDown:L=>{L.preventDefault(),d.disabled||a(d.value)},className:l.item(f===o,P&&d.value!=="",!!d.disabled,f===n.length-1),style:l.itemStyle?.(P),children:d.meta===void 0?d.label:Ft(jn,{children:[B("span",{className:"flex-1 whitespace-nowrap",children:d.label}),B("span",{className:"ml-auto text-[12px] opacity-50",children:d.meta})]})},`${d.value}_${f}`)})})}function Yn({value:e,onChange:t,disabled:n,children:r,className:o,style:i,name:a,id:u,"aria-label":c}){let l=Kn.toArray(r).flatMap(h=>{if(!Hn(h))return[];if(h.type!=="option")return[];let I=h.props,T=I.value!==void 0?String(I.value):"",M=I.children,x=typeof M=="string"||typeof M=="number"?String(M):T;return[{value:T,label:x,disabled:!!I.disabled}]}),d=e??"",f=zn({items:l,value:d,onPick:h=>t?.({target:{value:h}})}),L=l.find(h=>h.value===d)?.label??l[0]?.label??"";return Ft("div",{ref:f.wrapRef,className:"relative",children:[a&&B("input",{type:"hidden",name:a,value:d}),B("button",{ref:h=>{f.triggerRef.current=h},type:"button",disabled:n,"aria-haspopup":"listbox","aria-expanded":f.open,"aria-controls":f.open?f.listId:void 0,"aria-activedescendant":f.activeId,"aria-label":c,id:u,onClick:()=>!n&&f.toggle(),onKeyDown:h=>!n&&f.onTriggerKeyDown(h),className:`block w-full ${o??""}`,style:i,children:B("span",{className:"block w-full truncate text-left",children:L})}),f.open&&B(Gn,{id:f.listId,tone:"select",items:l,value:d,focusIdx:f.focusIdx,onFocus:f.setFocusIdx,onPick:f.pick,listRef:f.listRef})]})}var Fo="#c9a461",Ut=[{f:"black",label:"Black",hex:"#171717"},{f:"silver",label:"Silver",hex:"#cccccc"},{f:"bronze",label:"Bronze",hex:"#8a6438"},{f:"graphite",label:"Graphite",hex:"#3a3c3f"},{f:"red",label:"Candy Red",hex:"#7a0f14"}],Uo={name:"",color:"var(--fg)",family:"silver",src:""};function Qn(e,t){let n=r=>{let o=Ut.findIndex(i=>i.f===r);return o===-1?Ut.length:o};return n(e)-n(t)||e.localeCompare(t)}function $o(e){let t=new Set;for(let n of e)for(let r of n.finishes??[])r?.family&&t.add(r.family);return[...t].sort(Qn)}import{jsx as he,jsxs as _e}from"react/jsx-runtime";var Xn="font-mono text-[length:var(--size-label,12px)]",Jn="font-semibold uppercase tracking-[0.22em] text-fg";function $t(e){return`${e??Xn} ${Jn}`}function qt(){return he("span",{className:"text-accent",children:" *"})}function Zn({children:e,required:t,labelFace:n}){return _e("span",{className:$t(n),children:[e,t?he(qt,{}):null]})}function er({label:e,required:t,hint:n,separate:r,htmlFor:o,labelFace:i,className:a,children:u}){let c=a?`flex flex-col gap-2 ${a}`:"flex flex-col gap-2",l=n?he("span",{className:"font-mono text-[11px] uppercase tracking-[0.22em] text-fg-dim",children:n}):null;return r||n?_e("div",{className:c,children:[_e("label",{htmlFor:o,className:$t(i),children:[e,t?he(qt,{}):null]}),u,l]}):_e("label",{htmlFor:o,className:c,children:[he(Zn,{required:t,labelFace:i,children:e}),u]})}import{jsx as Ce,jsxs as nr}from"react/jsx-runtime";function tr({spokes:e,mesh:t=!1,className:n}){let a=c=>Math.round(c*1e3)/1e3,u=[];for(let c=0;c<e;c++){let l=c/e*Math.PI*2-Math.PI/2;if(u.push({x1:a(100+Math.cos(l)*22),y1:a(100+Math.sin(l)*22),x2:a(100+Math.cos(l)*86),y2:a(100+Math.sin(l)*86),main:!0}),t){let d=l+Math.PI/e;u.push({x1:a(100+Math.cos(d)*22*1.4),y1:a(100+Math.sin(d)*22*1.4),x2:a(100+Math.cos(d)*78),y2:a(100+Math.sin(d)*78),main:!1})}}return nr("svg",{viewBox:"0 0 200 200",fill:"none",stroke:"currentColor",className:n??"block h-[70%] w-[70%] transition-transform duration-700 [transition-timing-function:cubic-bezier(.2,.6,.2,1)]",children:[Ce("circle",{cx:100,cy:100,r:92,strokeWidth:2}),Ce("circle",{cx:100,cy:100,r:84,strokeWidth:1,opacity:.4}),Ce("circle",{cx:100,cy:100,r:22,strokeWidth:2}),Ce("circle",{cx:100,cy:100,r:6,fill:"currentColor"}),u.map((c,l)=>Ce("line",{x1:c.x1,y1:c.y1,x2:c.x2,y2:c.y2,stroke:"currentColor",strokeWidth:c.main?6:3,strokeLinecap:"round",opacity:c.main?1:.5},l))]})}import{useState as rr}from"react";import{jsx as ae,jsxs as Be}from"react/jsx-runtime";function or({customerEmail:e}){let{coupon:t,applyCoupon:n,removeCoupon:r,couponBusy:o}=wt(),[i,a]=rr("");async function u(){o||!i.trim()||(await n(i,e),a(""))}return Be("div",{className:"flex flex-col gap-2",children:[t===null?Be("div",{className:"flex border border-line",children:[ae("input",{type:"text",value:i,onChange:c=>a(c.target.value),onKeyDown:c=>{c.key==="Enter"&&(c.preventDefault(),u())},placeholder:"Coupon code","aria-label":"Coupon code",className:"flex-1 bg-transparent px-3.5 py-3.5 font-mono text-[11px] uppercase tracking-[0.18em] text-fg outline-none placeholder:text-fg-dim"}),ae("button",{type:"button",onClick:()=>{u()},disabled:o,className:"border-l border-line px-4 font-mono text-[10px] uppercase tracking-[0.26em] text-btn transition-colors hover:bg-btn hover:text-btn-ink disabled:cursor-wait disabled:opacity-60",children:o?"\u2026":"Apply"})]}):Be("div",{className:["flex items-center justify-between gap-3 border px-3.5 py-3",t.valid?"border-accent":"border-line"].join(" "),style:t.valid?{background:"color-mix(in oklab, var(--accent) 8%, transparent)"}:void 0,children:[ae("span",{className:["font-mono text-[11px] uppercase tracking-[0.22em]",t.valid?"text-accent":t.deferred?"text-fg":"text-fg-dim line-through"].join(" "),children:t.code}),ae("button",{type:"button",onClick:r,"aria-label":`Remove coupon ${t.code}`,className:"font-mono text-[12px] text-fg-dim transition-colors hover:text-fg",children:"\u2715"})]}),t?.deferred?ae("p",{className:"font-mono text-[10px] uppercase tracking-[0.18em] text-fg-dim",children:pt}):t&&!t.valid&&t.message&&ae("p",{className:"font-mono text-[10px] uppercase tracking-[0.18em] text-alert",children:t.message})]})}function Qo(){let e=typeof crypto<"u"?crypto:void 0;if(typeof e?.randomUUID=="function")return e.randomUUID();let t=new Uint8Array(16);if(typeof e?.getRandomValues=="function")e.getRandomValues(t);else for(let r=0;r<t.length;r++)t[r]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=Array.from(t,r=>r.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}export{Cr as a,xr as b,Sr as c,it as d,Me as e,ir as f,ar as g,sr as h,lr as i,Yt as j,jt as k,ur as l,cr as m,De as n,Oe as o,pe as p,Pe as q,rn as r,Ue as s,Ir as t,wr as u,an as v,Lr as w,Nr as x,sn as y,Tr as z,un as A,_r as B,kr as C,yt as D,Fr as E,Ur as F,$r as G,gr as H,dt as I,Ie as J,qe as K,Qr as L,wt as M,fo as N,Rn as O,go as P,Dn as Q,On as R,Io as S,wo as T,Lo as U,No as V,zn as W,Gn as X,Yn as Y,Fo as Z,Ut as _,Uo as $,Qn as aa,$o as ba,Zn as ca,er as da,tr as ea,or as fa,Qo as ga};
1
+ import{f as nt,i as fe,q as rt,s as ot,u as q}from"./chunk-K5TEC2IE.js";import{Ma as me,Na as Ze,Qa as Ae,Ra as et}from"./chunk-HYLRHFHP.js";import{e as Je,q as tt,s as re}from"./chunk-EJ2NLQYY.js";import{createContext as Qt,useContext as Xt,useEffect as Jt,useMemo as ge,useState as st}from"react";function it(e,t){return e.map(n=>({partNumber:n.partNumber,quantity:n.wheels*t}))}function oe(e,t){if(e.length===0)return null;let n=0;for(let r of e){let o=r.prices?.[t];if(typeof o!="number"||!Number.isFinite(o)||o<=0)return null;n+=o*r.wheels}return n}var Me=4,ir=1,ar={unit:"set",spares:0,spareSide:"left"};function at(e){return e.unit==="single"?1:Me+e.spares}function sr(e,t){return[{partNumber:e.partNumber,wheels:at(t),prices:e.prices}]}function lr(e,t){let n=at(t)-Me;if(n<=0||e.length===0)return e;let r=Yt(e),o=r?r[t.spareSide]:0;return e.map((i,a)=>a===o?{...i,wheels:i.wheels+n}:i)}function Yt(e){let t,n;for(let r=0;r<e.length;r+=1){let o=e[r].hand;if(o!=="left"&&o!=="right")continue;if((o==="left"?t:n)!==void 0)return null;o==="left"?t=r:n=r}return t!==void 0&&n!==void 0?{left:t,right:n}:null}function jt(e,t){return t.spares>0?`${e} + spare`:e}function ur(e){return e.unit==="single"?"Single":jt(`Set of ${Me}`,e)}var cr="data-add-to-basket",De=9,Oe="en";function pe(e,t,n=0){return new Intl.NumberFormat(Oe,{style:"currency",currency:t,minimumFractionDigits:0,maximumFractionDigits:n}).format(e)}import{jsx as tn}from"react/jsx-runtime";var lt="storefront-country",ut=Qt(null);function Zt(e){return ct(e,"catalogue")}function en(e){return ct(e,"money")}function ct(e,t){let n=new Map(e.map(o=>[o.code,o.decimalPlaces])),r=new Map;return(o,i)=>{if(!i)return"";let a=r.get(i);if(!a){let u=n.get(i)??0;a=new Intl.NumberFormat(Oe,{style:"currency",currency:i,minimumFractionDigits:t==="money"?u:0,maximumFractionDigits:u}),r.set(i,a)}return a.format(o)}}function gr({children:e,currencies:t,countries:n,defaultCurrency:r,defaultCountry:o}){let i=ge(()=>t??[],[t]),a=ge(()=>n??[],[n]),u=ge(()=>r||i.find(C=>C.isDefault)?.code||i[0]?.code||"",[r,i]),c=ge(()=>o||a.find(C=>C.isDefault)?.code||a[0]?.code||"",[o,a]),[l,d]=st(c),[f,P]=st(!1);Jt(()=>{let C=re.getItem(lt);C&&a.some(I=>I.code===C)&&d(C),P(!0)},[a]);function L(C){d(C),re.setItem(lt,C)}let h=ge(()=>{let C=a.find(w=>w.code===l)??null,I=C?.currency,T=I&&i.some(w=>w.code===I)?I:u,M=Zt(i),x=en(i);return{country:l,currency:T,setCountry:L,currencies:i,countries:a,activeCountry:C,formatPrice:(w,S)=>M(w,S??T),formatMoney:(w,S)=>x(w,S??T),ready:f}},[l,i,a,u,f]);return tn(ut.Provider,{value:h,children:e})}function dt(){let e=Xt(ut);if(!e)throw new Error("useCurrency must be used within a CurrencyProvider");return e}import{createContext as pn,useCallback as k,useContext as gn,useEffect as Y,useMemo as St,useRef as ie,useState as R}from"react";function ft(e,t){return e.valid?!1:e.reason==="firstOrderOnly"?!0:e.reason==="notEligible"&&!t}var pt="We'll confirm this discount when you place your order.",Cr="Confirmed at checkout";function xr(e){return e&&(e.valid||e.deferred)?e.code:void 0}var mt="coupon_code: ";function Sr(e){return!(e instanceof fe)||e.status!==400||!e.message.startsWith(mt)?null:e.message.slice(mt.length)}function gt(e,t){return e.map(n=>({qty:n.qty,slug:n.slug,name:`${n.name.lead}${n.name.accent}`.trim(),finish:n.finishName,size:n.size,kind:n.kind,sku:n.sku,pack:n.pack,priceLabel:t(n)}))}var Pe="Price on request",rn="Request a quote";function Fe(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Ue(e,t){let n=e?.[t];return Fe(n)?n:null}function Ir(e,t,n,r){let o=Ue(e,n),i=Ue(t,n);return o===null&&i===null?0:o===null?1:i===null?-1:r==="asc"?o-i:i-o}function wr(e,t,n,r){if(n==null&&r==null)return!0;let o=Ue(e,t);return!(o===null||n!=null&&o<n||r!=null&&o>r)}var on={priced:!1,unit:null,was:null,onSale:!1,setTotal:null};function an(e,t,n){if(!Fe(e))return on;let r=Fe(t)&&t>e?t:null;return{priced:!0,unit:e,was:r,onSale:r!==null,setTotal:n!=null?e*n:null}}function Lr(e,t,n=""){return!e.priced||e.unit==null?Pe:`${n}${pe(e.unit,t)}`}function Nr(e,t){return e.was==null?null:pe(e.was,t)}function sn(e,t,n=1){let r=oe(e,t);if(r===null)return{priced:!1,unit:null,isFrom:!1,setTotal:null};let o=e.reduce((a,u)=>a+u.wheels,0),i=Math.min(...e.map(a=>a.prices[t]));return{priced:!0,unit:i,isFrom:i*o!==r,setTotal:r*n}}var ln={priced:!1,unit:null,isFrom:!1,was:null,onSale:!1,setTotal:null};function Tr(e,t,n,r=1){let o=an(e.prices[n],e.msrpPrices?.[n],4),i=o.setTotal==null?null:o.setTotal*r;if(!t)return{priced:o.priced,unit:o.unit,isFrom:!0,was:o.was,onSale:o.onSale,setTotal:null,fromSetTotal:i};let a=sn(t.components,n,r);return a.priced?{priced:!0,unit:a.unit,isFrom:a.isFrom,was:null,onSale:!1,setTotal:a.setTotal,fromSetTotal:i}:{...ln,fromSetTotal:i}}function un(e,t){return!e.priced||e.unit==null?Pe:`${e.isFrom?"from ":""}${pe(e.unit,t)}`}function _r(e,t){return e.was==null?null:pe(e.was,t)}function kr(e,t){return!e.priced||e.unit==null?rn:un(e,t)}var cn=/^[^@\s]+@[^@\s]+\.[^@\s]+$/;function yt(e){return cn.test(e.trim())}var bt="sf:ga-purchases",dn=20;function Ct(){return typeof window>"u"||window.parent!==window}function ye(...e){try{if(Ct()||typeof window.gtag!="function")return;window.gtag(...e)}catch{}}function mn(e,t){let n=e.config.find(r=>r.gold)?.label;return{item_id:`${e.slug}|${e.finishName}|${e.size}`,item_name:`${e.name.lead}${e.name.accent}`.trim(),...n?{item_variant:n}:{},price:oe(e.components,t)??0,quantity:e.qty}}function $e(e,t){return e.filter(Ie).map(n=>mn(n,t))}function Fr(e){ye("event","view_item",{currency:e.currency,value:e.pricePerSet,items:[{item_id:e.itemId,item_name:e.itemName,...e.variant?{item_variant:e.variant}:{},price:e.pricePerSet,quantity:1}]})}function xt(e,t){let n=$e([e],t);n.length!==0&&ye("event","add_to_cart",{currency:t,value:n[0].price*n[0].quantity,items:n})}function Ur(e){let t=$e(e.lines,e.currency);t.length!==0&&ye("event","begin_checkout",{currency:e.currency,value:e.value,...e.coupon?{coupon:e.coupon}:{},items:t})}var ht=new Set;function fn(e){if(ht.has(e))return!1;ht.add(e);try{let t=JSON.parse(re.getItem(bt)??"[]");if(t.includes(e))return!1;re.setItem(bt,JSON.stringify([...t,e].slice(-dn)))}catch{}return!0}function $r(e){let t=e.confirmation;if(Ct()||!fn(t.orderNumber))return;let n=t.currency,r=Number(t.grandTotal);ye("event","purchase",{transaction_id:t.orderNumber,currency:n,value:r,shipping:Number(t.freightCharge),...t.couponCode?{coupon:t.couponCode}:{},items:$e(e.lines,n)}),e.adsSendTo&&ye("event","conversion",{send_to:e.adsSendTo,transaction_id:t.orderNumber,currency:n,value:r})}import{jsx as Cn}from"react/jsx-runtime";var yn=400,bn=400,hn=1500;function Ie(e){return(e.components?.length??0)>0}function vt(e,t){return{code:e,valid:t.valid,deferred:ft(t,t.askedAsShopper),message:t.message||void 0,effects:t.effects??void 0}}function Pt(e,t){return oe(e.components,t)}function qe(e,t){let n=Pt(e,t);return n===null?null:n*e.qty}function Et(e){return e!=="tyre"}var It=pn(null);function Qr({children:e,preview:t=!1}){let{currency:n,country:r,formatMoney:o}=dt(),[i,a]=R(t),[u,c]=R([]),[l,d]=R([]),[f,P]=R([]),[L,h]=R(!1),[C,I]=R(!1),[T,M]=R(!1),[x,w]=R(!1),[S,K]=R(null),[W,Q]=R(void 0),b=ie(r),v=ie("");b.current=b.current||r;let[m,H]=R(null),[X,z]=R(!1),[A,J]=R(null),Z=ie(void 0),D=k(()=>a(!0),[]),xe=k(()=>a(!1),[]),O=k(()=>a(s=>!s),[]);Y(()=>{t||typeof window>"u"||new URLSearchParams(window.location.search).get("cart")==="open"&&D()},[D,t]);let Se=k(s=>{w(!0),Et(s)&&M(!0)},[]),ee=T||u.some(s=>Et(s.kind)),se=x||u.length>0;Y(()=>{if(t||!ee||L)return;let s=!0;return q.listWheels().then(p=>{s&&(d(p),h(!0))}),()=>{s=!1}},[t,ee,L]),Y(()=>{if(t||!se||C)return;let s=!0;return q.listBundles().then(p=>{s&&(P(p),I(!0))}),()=>{s=!1}},[t,se,C]);let U=S?.deliveryOptions??[];Y(()=>{U.length!==0&&J(s=>s&&U.some(p=>p.id===s)?s:U[0]?.id??null)},[S]);let V=k(()=>u.filter(Ie).flatMap(s=>it(s.components,s.qty)),[u]),le=k(async(s,p)=>{let y=s.trim().toUpperCase();if(!y)return;let g=V();if(g.length===0){H({code:y,valid:!1,message:"Add a wheel to the cart first."});return}z(!0),Z.current=p;try{let N=await q.validateCoupon({code:y,items:g,currency:n,shippingMethodId:A??void 0,customerEmail:p});H(vt(y,N))}catch{H({code:y,valid:!1,message:"Could not check that code. Please try again."})}finally{z(!1)}},[V,n,A]),te=k(()=>{H(null),Z.current=void 0},[]),ve=k(s=>{if(!m)return;let{code:p}=m;H(y=>y&&y.code===p?{code:p,valid:!1,refused:!0,message:s}:y)},[m]);Y(()=>{if(!m||m.refused)return;let s=m.code,p=g=>g!==null&&g.code===s&&!g.refused,y=setTimeout(async()=>{let g=V();if(g.length===0){H(N=>p(N)?{code:s,valid:!1,message:"Add a wheel to the cart first."}:N);return}z(!0);try{let N=await q.validateCoupon({code:s,items:g,currency:n,shippingMethodId:A??void 0,customerEmail:Z.current});H(de=>p(de)?vt(s,N):de)}catch{}finally{z(!1)}},yn);return()=>clearTimeout(y)},[u,n,A]);let ue=m&&!m.refused?m.code:void 0;Y(()=>{if(t)return;let s=!0,p=setTimeout(async()=>{let y=V();if(y.length===0){K(null),Q(void 0);return}try{let g=await q.quoteCart({items:y,currency:n,shippingMethodId:A??void 0,couponCode:ue,customerEmail:Z.current||void 0,country:b.current||void 0,subdivision:v.current||void 0});if(!s)return;K(g)}catch{if(!s)return}Q(ue)},bn);return()=>{s=!1,clearTimeout(p)}},[u,n,A,ue,r]);let E=k(s=>{c(p=>{let y=p.findIndex(g=>g.id===s.id);return y===-1?[...p,s]:p.map((g,N)=>N===y?{...g,qty:Math.min(De,g.qty+s.qty)}:g)}),xt(s,n)},[n]),F=k(s=>{c(p=>p.filter(y=>y.id!==s))},[]),G=k((s,p)=>{let y=Math.max(1,Math.min(De,p));c(g=>g.map(N=>N.id===s?{...N,qty:y}:N))},[]),ze=k(s=>{c(s)},[]),[ce,Kt]=R(null),Ve=ie(null);Ve.current=ce;let $=ie(null),ke=ie(""),Ge=k((s,p)=>{let y=s.trim().toLowerCase();yt(y)&&Kt(g=>g&&g.email===y&&g.firstName===(p??"")?g:{email:y,firstName:p??""})},[]);Y(()=>{if(t||!ce)return;let s=gt(u.filter(Ie),g=>qe(g,n)===null?Pe:o(qe(g,n),n)),p={email:ce.email,firstName:ce.firstName,currency:n,items:s},y=JSON.stringify(p);if(y!==ke.current)return $.current&&clearTimeout($.current),$.current=setTimeout(()=>{$.current=null,ke.current=y,q.captureCart(p).catch(g=>{})},hn),()=>{$.current&&(clearTimeout($.current),$.current=null)}},[u,ce,n,t]);let Ye=k(()=>{$.current&&(clearTimeout($.current),$.current=null);let s=Ve.current;s&&(ke.current="",q.captureCart({email:s.email,firstName:s.firstName,currency:n,items:[]}).catch(p=>{}))},[n]),je=St(()=>{let s=u.reduce((_,ne)=>{let Ee=qe(ne,n);return Ee===null?_:_+Ee},0),p=u.some(_=>Pt(_,n)===null),y=u.reduce((_,ne)=>_+ne.qty,0),g=m?.valid?m.effects:void 0,N=g?Math.min(s,Number(g.discountAmount)):0,de=S?.bundleDiscount??0,Wt=S?.appliedBundles??[],Qe=!!g?.freeShipping,Bt=U.find(_=>_.id===A),Xe=Qe?0:S?.shipping??Bt?.amount??0,Re={};for(let _ of g?.freeUnits??[])Re[_.partNumber]=(Re[_.partNumber]??0)+_.quantity;let zt=S?.tax??null,Vt=S?S.grandTotal:s-N-de+Xe;return{sets:y,units:u.reduce((_,ne)=>_+(ne.components??[]).reduce((Ee,Gt)=>Ee+Gt.wheels*ne.qty,0),0),subtotal:s,hasUnpricedLine:p,discount:N,bundleDiscount:de,appliedBundles:Wt,shipping:Xe,freeShipping:Qe,freeUnitsByPartNumber:Re,tax:zt,grand:Vt,repricing:!!m?.refused&&S!==null&&W===m?.code,currency:n}},[u,n,m,U,A,S,W]),Ht=St(()=>({isOpen:i,preview:t,open:D,close:xe,toggle:O,items:u,catalog:l,bundles:f,warmCatalog:Se,add:E,remove:F,setQty:G,replaceItems:ze,identify:Ge,clearCapturedCart:Ye,coupon:m,applyCoupon:le,removeCoupon:te,refuseCoupon:ve,couponBusy:X,deliveryOptions:U,shippingMethodId:A,setShippingMethodId:J,totals:je}),[i,t,D,xe,O,u,l,f,Se,E,F,G,ze,Ge,Ye,m,le,te,ve,X,U,A,je]);return Cn(It.Provider,{value:Ht,children:e})}function wt(){let e=gn(It);if(!e)throw new Error("useCart() must be called inside <CartProvider>. Mount the provider in app/layout.tsx.");return e}import{cache as _n}from"react";function Lt(e,t,n,r){for(;e.size>=t;){let o,i;for(let[u,c]of e){if(c.expiresAt<=r){o=u;break}i===void 0&&n(u)&&(i=u)}let a=o??i??e.keys().next().value;if(a===void 0)return;e.delete(a)}}var xn=6e4,Sn=5e3,vn=500,we=new Map;async function En(e){let{host:t,matchesRequestHost:n}=await rt();if(!t)return"";let r=await ot();return r?`${e}|slug:${encodeURIComponent(t)}/${encodeURIComponent(r)}`:n?`${e}|host:${t}`:`${e}|xhost:${t}`}var Pn=e=>e.includes("|slug:")||e.includes("|xhost:");async function Nt(e,t){let n=await En(e);if(!n)return t();let r=Date.now(),o=we.get(n);if(o&&o.expiresAt>r)return o.load;let i=await t(),a=i.outcome.state==="failed",u=a?Sn:xn,c=we.get(n)?.lastGood,l=i.outcome.state==="ok"?i:a?c:void 0,d=a&&l?l:i;return Lt(we,vn,Pn,r),we.set(n,{load:d,expiresAt:r+u,lastGood:l}),d}var In=404;function wn(e){if(e instanceof fe&&e.status===In)return{state:"absent"};let t=e instanceof fe?e.status:-1,n=e instanceof Error?e.message:String(e);return{state:"failed",status:t,detail:n}}var Ln="[storefront:chrome-load-failed]";function Nn(e,t){console.error(`${Ln} ${e} status=${t.status} \u2014 serving fallback chrome`,t.detail)}async function Tt(e,t,n,r){try{let o=await t();return r?.(o)?{value:o,outcome:{state:"absent"}}:{value:o,outcome:{state:"ok"}}}catch(o){let i=wn(o);return i.state==="failed"&&Nn(e,i),{value:n,outcome:i}}}function Tn(e){return e==="production"?"silent":"banner"}var oo=Tn("production");function kn(e,t){return e?.trim()||t}function fo({legalName:e,foundedYear:t,siteName:n},r=new Date().getFullYear()){let o=kn(e,n);return`\xA9 ${t&&t<r?`${t}\u2013${r}`:`${r}`} ${o}`}var Rn={name:me,legalName:null,foundedYear:null,faviconUrl:null,currencies:[],defaultCurrency:null,countries:[],defaultCountry:null,commerceEnabled:!0,cardPayments:!1,paymentMethods:[],paypalClientId:null,paypalEnvironment:null,squareApplicationId:null,squareLocationId:null,squareEnvironment:null,ga4MeasurementId:null,googleAdsId:null,googleAdsConversionLabel:null,metaPixelId:null,mapsApiKey:null,mapsMapId:null,socialLinks:Ae},po=_n(async()=>Nt("site",()=>Tt("site",async()=>{let e=await q.getSite();return{name:Ze(e.name),legalName:e.legalName?.trim()||null,foundedYear:e.foundedYear??null,faviconUrl:e.faviconUrl??null,currencies:e.currencies??[],defaultCurrency:e.defaultCurrency??null,countries:e.countries??[],defaultCountry:e.defaultCountry??null,commerceEnabled:e.commerceEnabled??!0,cardPayments:e.cardPayments??!1,paymentMethods:e.paymentMethods??(e.cardPayments?["card"]:[]),paypalClientId:e.paypalClientId??null,paypalEnvironment:e.paypalEnvironment??null,squareApplicationId:e.squareApplicationId??null,squareLocationId:e.squareLocationId??null,squareEnvironment:e.squareEnvironment??null,ga4MeasurementId:e.ga4MeasurementId??null,googleAdsId:e.googleAdsId??null,googleAdsConversionLabel:(e.googleAdsId?e.googleAdsConversionLabel:null)??null,metaPixelId:e.metaPixelId??null,mapsApiKey:e.mapsApiKey??null,mapsMapId:e.mapsMapId??null,socialLinks:et(e.socialLinks)}},Rn)));var go={name:me,legalName:null,foundedYear:null,faviconUrl:null,currencies:[{code:"USD",symbol:"$",decimalPlaces:2,isDefault:!0}],defaultCurrency:"USD",countries:[{code:"US",name:"United States",currency:"USD",url:"",isDefault:!0,chargeTax:!1,taxDisplay:"none",taxName:"",taxRate:null,postalLabel:"Zip Code"}],defaultCountry:"US",commerceEnabled:!0,cardPayments:!0,paymentMethods:["card"],paypalClientId:null,paypalEnvironment:null,squareApplicationId:null,squareLocationId:null,squareEnvironment:null,ga4MeasurementId:null,googleAdsId:null,googleAdsConversionLabel:null,metaPixelId:null,mapsApiKey:null,mapsMapId:null,socialLinks:Ae};import{jsx as kt,jsxs as Rt}from"react/jsx-runtime";import{useEffect as Le,useRef as At,useState as Ne}from"react";var be=new Map,An=64;async function Mn(e){if(!Je())return null;try{let t=await fetch(`${tt()}/logo-analysis.json?url=${encodeURIComponent(e)}`);if(!t.ok)return null;let n=await t.json();if(!n||typeof n!="object")return null;let{reversed:r,inkIsDark:o}=n;return typeof r!="string"?null:{reversed:r,inkIsDark:typeof o=="boolean"?o:null}}catch{return null}}function _t(e){let t=be.get(e);if(t)return t;let n=Mn(e);if(be.set(e,n),be.size>An){let r=be.keys().next();r.done||be.delete(r.value)}return n}var Dn={small:54,medium:66,large:84},On=44,Fn=202/22,Io=16,wo=140,Un=.88,Lo=16,$n="invert(1)";function No({variant:e="header",scrolled:t=!0,src:n,reverse:r=!1,onLightSurface:o,reversedSrc:i,inkIsDark:a,size:u="medium",sizePx:c,wordmark:l,siteName:d=me,fitToContainer:f=!1,fitWordmarkToContainer:P=!1,fitFloorPx:L}){let h=l&&l.trim()?l.trim():d,[C,I]=Ne(!1),T=At(null),M=E=>{T.current=E};Le(()=>{let E=T.current?.ownerDocument??document,F=()=>{I(E.documentElement.getAttribute("data-theme")==="light")};F();let G=new MutationObserver(F);return G.observe(E.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>G.disconnect()},[]);let x=n&&n.trim()?n.trim():null,w=!!x&&nt(x),S=o??(C&&t),K=r&&w&&x&&i!=null?{reversed:i,inkIsDark:a??null}:null,W=K!==null,[Q,b]=Ne(null);Le(()=>{if(!r||!x||!w||W){b(null);return}let E=!1;return b(null),_t(x).then(F=>{E||b(F)}),()=>{E=!0}},[r,x,w,W]);let v=K??Q,m=!!v&&v.inkIsDark!==null&&(S?!v.inkIsDark:v.inkIsDark),H=r&&!!x&&!w&&!S,X=m&&v?v.reversed:x,z=X?[X]:[],[A,J]=Ne(0);Le(()=>{J(0)},[x,m]);let Z=e==="footer"?On:Dn[u],D=c&&c>0?c:Z,xe=Math.round(D*Fn),O=A<z.length?z[A]:null,[Se,ee]=Ne(X),se=O!==null&&O===Se,U=At(null);Le(()=>{let E=U.current;if(!E||!E.complete)return;if(E.naturalWidth>0||E.naturalHeight>0){ee(O);return}let F=!1;return E.decode().then(()=>!F&&ee(O),()=>!F&&J(G=>G+1)),()=>{F=!0}},[O]);let V=f||P,le=`calc(100cqi / ${((h.length+1)*Un).toFixed(2)})`,te=V&&L&&L>0?Math.min(L,D):null,ve=V?te===null?`min(${D}px, ${le})`:`clamp(${te}px, ${le}, ${D}px)`:`${D}px`,ue=Rt("span",{className:`font-display font-bold tracking-[0.18em] ${te===null?"whitespace-nowrap":"whitespace-normal"}`,style:{fontSize:ve,lineHeight:1},"aria-label":h,children:[h,kt("span",{className:"text-accent",children:"."})]});return Rt("span",{ref:M,className:"inline-flex items-center",children:[!se&&ue,O&&kt("img",{ref:U,src:O,alt:h,width:xe,height:D,className:"shrink-0 object-contain",style:{...se?{height:`${D}px`,width:"auto",...f?{maxWidth:"100cqi"}:{}}:{display:"none"},...H?{filter:$n}:{}},onLoad:()=>ee(O),onError:()=>J(E=>E+1)},O)]})}import{Children as Kn,isValidElement as Hn,useEffect as Dt,useId as Wn,useLayoutEffect as Bn,useRef as j,useState as Ot}from"react";var Te=(e,t)=>!!e[t]&&!e[t].disabled;function Ke(e,t,n){let r=e.length;for(let o=1;o<=r;o++){let i=((t+n*o)%r+r)%r;if(Te(e,i))return i}return t}function He(e,t){return Ke(e,t===1?-1:e.length,t)}function We(e,t){return Te(e,t)?t:Math.max(He(e,1),0)}function Mt(e,t,n){let{open:r,focus:o}=e,i=a=>({...e,...a});if(t.length===1&&/\S/.test(t)){let a=e.typed+t.toLowerCase(),u=n.findIndex((c,l)=>Te(n,l)&&c.label.toLowerCase().startsWith(a));return{state:i({open:!0,typed:a,focus:u>=0?u:o}),handled:!0}}if(!r)return t==="ArrowDown"||t==="ArrowUp"||t==="Enter"||t===" "?{state:i({open:!0,typed:""}),handled:!0}:{state:e,handled:!1};switch(t){case"ArrowDown":return{state:i({focus:Ke(n,o,1)}),handled:!0};case"ArrowUp":return{state:i({focus:Ke(n,o,-1)}),handled:!0};case"Home":return{state:i({focus:He(n,1)}),handled:!0};case"End":return{state:i({focus:He(n,-1)}),handled:!0};case"Enter":case" ":return Te(n,o)?{state:i({open:!1,typed:""}),commit:o,refocus:!0,handled:!0}:{state:e,handled:!0};case"Escape":return{state:i({open:!1,typed:""}),refocus:!0,handled:!0};case"Tab":return{state:i({open:!1,typed:""}),handled:!1};default:return{state:e,handled:!1}}}import{Fragment as jn,jsx as B,jsxs as Ft}from"react/jsx-runtime";function zn({items:e,value:t,onPick:n,open:r,onOpen:o,onClose:i}){let[a,u]=Ot(!1),c=r!==void 0,l=c?r:a,[d,f]=Ot(0),P=j({text:"",timer:0}),L=j(null),h=j(null),C=j(null),I=Wn(),T=j(null),M=e.findIndex(b=>b.value===t),x=b=>{b!==l&&(c||u(b),b?o?.():i?.())},w=b=>{let v=e[b];!v||v.disabled||(n(v.value),x(!1),h.current?.focus())},S=b=>{let v={open:l,focus:l?d:We(e,M),typed:P.current.text},m=Mt(v,b,e);return!m.handled&&m.state.open===l?!1:(m.state.typed!==v.typed&&(P.current.text=m.state.typed,window.clearTimeout(P.current.timer),P.current.timer=window.setTimeout(()=>{P.current.text=""},500)),f(m.state.focus),m.commit!==void 0?w(m.commit):x(m.state.open),m.refocus&&h.current?.focus(),m.handled)},K=j(S);K.current=S;let W=j(()=>x(!1));W.current=()=>x(!1);let Q=b=>{l||(T.current=b.nativeEvent,K.current(b.key)&&b.preventDefault())};return Dt(()=>{if(!l)return;let b=m=>{L.current?.contains(m.target)||W.current()},v=m=>{m!==T.current&&K.current(m.key)&&m.preventDefault()};return document.addEventListener("mousedown",b),document.addEventListener("keydown",v),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",v)}},[l]),Dt(()=>{l&&(P.current.text||f(We(e,M)))},[l]),Bn(()=>{if(!l||!C.current)return;C.current.children.item(d)?.scrollIntoView({block:"nearest"})},[d,l]),{open:l,toggle:()=>x(!l),close:()=>x(!1),focusIdx:d,setFocusIdx:f,pick:b=>w(e.findIndex(v=>v.value===b)),wrapRef:L,triggerRef:h,listRef:C,listId:I,onTriggerKeyDown:Q,activeId:l?`${I}-${d}`:void 0}}var Vn={select:{list:"absolute left-0 top-full z-50 mt-1 max-h-[280px] w-max min-w-full overflow-y-auto border-2 border-accent bg-bg shadow-xl",item:(e,t,n)=>["px-3 py-2.5 font-mono text-[13px] font-semibold uppercase tracking-[0.1em] transition-colors whitespace-nowrap",n?"cursor-not-allowed opacity-40":"cursor-pointer",e&&!n?"bg-accent text-bg":"bg-bg text-fg"].join(" ")},cell:{list:"absolute left-0 top-full z-50 mt-1 max-h-[320px] w-max min-w-full overflow-y-auto border-2 border-accent bg-bg shadow-xl",item:e=>["cursor-pointer whitespace-nowrap px-6 py-3 font-mono text-[length:var(--size-label,13px)] font-semibold uppercase tracking-[0.1em] transition-colors",e?"bg-accent text-bg":"bg-bg text-fg"].join(" "),pickerMarker:!0},hairline:{list:"absolute left-0 top-full z-50 max-h-[320px] w-full overflow-y-auto border border-line bg-bg shadow-[0_6px_20px_rgba(0,0,0,0.10)]",item:(e,t)=>["flex cursor-pointer items-center justify-between gap-4 border-b border-line px-4 py-3 text-left text-[length:var(--size-body,14px)] transition-colors last:border-b-0",t?"border-fg font-medium text-fg":e?"border-fg text-fg":"text-fg-dim"].join(" "),pickerMarker:!0},region:{list:"absolute right-0 top-full z-[200] mt-2 flex min-w-[240px] flex-col border border-line bg-surface text-fg",item:(e,t,n,r)=>["flex w-full cursor-pointer items-center gap-3 px-3.5 py-3 text-left transition-colors","font-mono text-[13px] uppercase tracking-[0.18em]",e?"bg-surface-2 text-fg":"",r?"":"border-b border-line",t?"text-accent":""].join(" "),itemStyle:e=>e?void 0:{color:"color-mix(in oklab, currentColor 80%, transparent)"}}};function Gn({id:e,tone:t,items:n,value:r,focusIdx:o,onFocus:i,onPick:a,listRef:u,ariaLabel:c}){let l=Vn[t];return B("ul",{ref:u,id:e,role:"listbox","aria-label":c,...l.pickerMarker?{"data-picker-menu":""}:{},className:l.list,children:n.map((d,f)=>{let P=d.value===r;return B("li",{id:`${e}-${f}`,role:"option","aria-selected":P,"aria-disabled":d.disabled||void 0,onMouseEnter:()=>!d.disabled&&i(f),onMouseDown:L=>{L.preventDefault(),d.disabled||a(d.value)},className:l.item(f===o,P&&d.value!=="",!!d.disabled,f===n.length-1),style:l.itemStyle?.(P),children:d.meta===void 0?d.label:Ft(jn,{children:[B("span",{className:"flex-1 whitespace-nowrap",children:d.label}),B("span",{className:"ml-auto text-[12px] opacity-50",children:d.meta})]})},`${d.value}_${f}`)})})}function Yn({value:e,onChange:t,disabled:n,children:r,className:o,style:i,name:a,id:u,"aria-label":c}){let l=Kn.toArray(r).flatMap(h=>{if(!Hn(h))return[];if(h.type!=="option")return[];let I=h.props,T=I.value!==void 0?String(I.value):"",M=I.children,x=typeof M=="string"||typeof M=="number"?String(M):T;return[{value:T,label:x,disabled:!!I.disabled}]}),d=e??"",f=zn({items:l,value:d,onPick:h=>t?.({target:{value:h}})}),L=l.find(h=>h.value===d)?.label??l[0]?.label??"";return Ft("div",{ref:f.wrapRef,className:"relative",children:[a&&B("input",{type:"hidden",name:a,value:d}),B("button",{ref:h=>{f.triggerRef.current=h},type:"button",disabled:n,"aria-haspopup":"listbox","aria-expanded":f.open,"aria-controls":f.open?f.listId:void 0,"aria-activedescendant":f.activeId,"aria-label":c,id:u,onClick:()=>!n&&f.toggle(),onKeyDown:h=>!n&&f.onTriggerKeyDown(h),className:`block w-full ${o??""}`,style:i,children:B("span",{className:"block w-full truncate text-left",children:L})}),f.open&&B(Gn,{id:f.listId,tone:"select",items:l,value:d,focusIdx:f.focusIdx,onFocus:f.setFocusIdx,onPick:f.pick,listRef:f.listRef})]})}var Fo="#c9a461",Ut=[{f:"black",label:"Black",hex:"#171717"},{f:"silver",label:"Silver",hex:"#cccccc"},{f:"bronze",label:"Bronze",hex:"#8a6438"},{f:"graphite",label:"Graphite",hex:"#3a3c3f"},{f:"red",label:"Candy Red",hex:"#7a0f14"}],Uo={name:"",color:"var(--fg)",family:"silver",src:""};function Qn(e,t){let n=r=>{let o=Ut.findIndex(i=>i.f===r);return o===-1?Ut.length:o};return n(e)-n(t)||e.localeCompare(t)}function $o(e){let t=new Set;for(let n of e)for(let r of n.finishes??[])r?.family&&t.add(r.family);return[...t].sort(Qn)}import{jsx as he,jsxs as _e}from"react/jsx-runtime";var Xn="font-mono text-[length:var(--size-label,12px)]",Jn="font-semibold uppercase tracking-[0.22em] text-fg";function $t(e){return`${e??Xn} ${Jn}`}function qt(){return he("span",{className:"text-accent",children:" *"})}function Zn({children:e,required:t,labelFace:n}){return _e("span",{className:$t(n),children:[e,t?he(qt,{}):null]})}function er({label:e,required:t,hint:n,separate:r,htmlFor:o,labelFace:i,className:a,children:u}){let c=a?`flex flex-col gap-2 ${a}`:"flex flex-col gap-2",l=n?he("span",{className:"font-mono text-[11px] uppercase tracking-[0.22em] text-fg-dim",children:n}):null;return r||n?_e("div",{className:c,children:[_e("label",{htmlFor:o,className:$t(i),children:[e,t?he(qt,{}):null]}),u,l]}):_e("label",{htmlFor:o,className:c,children:[he(Zn,{required:t,labelFace:i,children:e}),u]})}import{jsx as Ce,jsxs as nr}from"react/jsx-runtime";function tr({spokes:e,mesh:t=!1,className:n}){let a=c=>Math.round(c*1e3)/1e3,u=[];for(let c=0;c<e;c++){let l=c/e*Math.PI*2-Math.PI/2;if(u.push({x1:a(100+Math.cos(l)*22),y1:a(100+Math.sin(l)*22),x2:a(100+Math.cos(l)*86),y2:a(100+Math.sin(l)*86),main:!0}),t){let d=l+Math.PI/e;u.push({x1:a(100+Math.cos(d)*22*1.4),y1:a(100+Math.sin(d)*22*1.4),x2:a(100+Math.cos(d)*78),y2:a(100+Math.sin(d)*78),main:!1})}}return nr("svg",{viewBox:"0 0 200 200",fill:"none",stroke:"currentColor",className:n??"block h-[70%] w-[70%] transition-transform duration-700 [transition-timing-function:cubic-bezier(.2,.6,.2,1)]",children:[Ce("circle",{cx:100,cy:100,r:92,strokeWidth:2}),Ce("circle",{cx:100,cy:100,r:84,strokeWidth:1,opacity:.4}),Ce("circle",{cx:100,cy:100,r:22,strokeWidth:2}),Ce("circle",{cx:100,cy:100,r:6,fill:"currentColor"}),u.map((c,l)=>Ce("line",{x1:c.x1,y1:c.y1,x2:c.x2,y2:c.y2,stroke:"currentColor",strokeWidth:c.main?6:3,strokeLinecap:"round",opacity:c.main?1:.5},l))]})}import{useState as rr}from"react";import{jsx as ae,jsxs as Be}from"react/jsx-runtime";function or({customerEmail:e}){let{coupon:t,applyCoupon:n,removeCoupon:r,couponBusy:o}=wt(),[i,a]=rr("");async function u(){o||!i.trim()||(await n(i,e),a(""))}return Be("div",{className:"flex flex-col gap-2",children:[t===null?Be("div",{className:"flex border border-line",children:[ae("input",{type:"text",value:i,onChange:c=>a(c.target.value),onKeyDown:c=>{c.key==="Enter"&&(c.preventDefault(),u())},placeholder:"Coupon code","aria-label":"Coupon code",className:"flex-1 bg-transparent px-3.5 py-3.5 font-mono text-[11px] uppercase tracking-[0.18em] text-fg outline-none placeholder:text-fg-dim"}),ae("button",{type:"button",onClick:()=>{u()},disabled:o,className:"border-l border-line px-4 font-mono text-[10px] uppercase tracking-[0.26em] text-btn transition-colors hover:bg-btn hover:text-btn-ink disabled:cursor-wait disabled:opacity-60",children:o?"\u2026":"Apply"})]}):Be("div",{className:["flex items-center justify-between gap-3 border px-3.5 py-3",t.valid?"border-accent":"border-line"].join(" "),style:t.valid?{background:"color-mix(in oklab, var(--accent) 8%, transparent)"}:void 0,children:[ae("span",{className:["font-mono text-[11px] uppercase tracking-[0.22em]",t.valid?"text-accent":t.deferred?"text-fg":"text-fg-dim line-through"].join(" "),children:t.code}),ae("button",{type:"button",onClick:r,"aria-label":`Remove coupon ${t.code}`,className:"font-mono text-[12px] text-fg-dim transition-colors hover:text-fg",children:"\u2715"})]}),t?.deferred?ae("p",{className:"font-mono text-[10px] uppercase tracking-[0.18em] text-fg-dim",children:pt}):t&&!t.valid&&t.message&&ae("p",{className:"font-mono text-[10px] uppercase tracking-[0.18em] text-alert",children:t.message})]})}function Qo(){let e=typeof crypto<"u"?crypto:void 0;if(typeof e?.randomUUID=="function")return e.randomUUID();let t=new Uint8Array(16);if(typeof e?.getRandomValues=="function")e.getRandomValues(t);else for(let r=0;r<t.length;r++)t[r]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=Array.from(t,r=>r.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}export{Cr as a,xr as b,Sr as c,it as d,Me as e,ir as f,ar as g,sr as h,lr as i,Yt as j,jt as k,ur as l,cr as m,De as n,Oe as o,pe as p,Pe as q,rn as r,Ue as s,Ir as t,wr as u,an as v,Lr as w,Nr as x,sn as y,Tr as z,un as A,_r as B,kr as C,yt as D,Fr as E,Ur as F,$r as G,gr as H,dt as I,Ie as J,qe as K,Qr as L,wt as M,fo as N,Rn as O,go as P,Dn as Q,On as R,Io as S,wo as T,Lo as U,No as V,zn as W,Gn as X,Yn as Y,Fo as Z,Ut as _,Uo as $,Qn as aa,$o as ba,Zn as ca,er as da,tr as ea,or as fa,Qo as ga};