efficient-storefront-blocks 0.112.0 → 0.113.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 +18 -0
- package/dist/chunks/{EditorPreviewCheckout-NBZP252D.js → EditorPreviewCheckout-QJWDGMO7.js} +4 -4
- package/dist/chunks/chunk-TNITUVMH.js +1 -0
- package/dist/index.js +31 -29
- package/dist/render/components/CartDrawer.js +1 -1
- package/dist/render/components/CartLineThumbnail.d.ts +3 -2
- package/dist/render/components/ConsentProvider.js +1 -1
- package/dist/render/components/DetailRows.d.ts +1 -0
- package/dist/render/components/DetailRows.js +1 -1
- package/dist/render/components/OpeningHours.js +1 -1
- package/dist/render/components/booking/BookingFormState.js +1 -1
- package/dist/render/components/booking/BookingRegions.js +1 -1
- package/dist/render/components/cart/drawer-parts.d.ts +3 -3
- package/dist/render/components/checkout/CheckoutPageClient.js +1 -1
- package/dist/render/components/useTyreCatalog.d.ts +2 -1
- package/dist/render/components/useTyreCatalog.js +3 -1
- package/dist/render/lib/booking/appointment-time.d.ts +2 -2
- package/dist/render/lib/booking/appointment-time.js +1 -1
- package/dist/render/lib/checkout/hold-time.d.ts +1 -0
- package/dist/render/lib/checkout/hold-time.js +1 -0
- package/dist/render/lib/document/current-record.d.ts +1 -0
- package/dist/render/lib/document/current-record.js +1 -1
- package/dist/render/lib/reader-zone.d.ts +1 -0
- package/dist/render/lib/reader-zone.js +1 -0
- package/dist/render/lib/sections/opening-hours.d.ts +1 -1
- package/dist/render/lib/sections/opening-hours.js +1 -1
- package/dist/render/lib/zone.d.ts +2 -0
- package/dist/render/lib/zone.js +1 -0
- package/package.json +1 -1
- package/dist/chunks/chunk-X6YHQFHP.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as r,jsxs as a}from"react/jsx-runtime";import{useEffect as
|
|
1
|
+
"use client";import{jsx as r,jsxs as a}from"react/jsx-runtime";import{useEffect as m,useRef as u}from"react";import{useCart as C}from"./CartContext.js";import{isTyreLine as d}from"../lib/tyres/tyre-purchase.js";import{useTyreCatalog as R}from"./useTyreCatalog.js";import w from"./PopupFrame.js";import{CartActions as T,CartCouponRow as x,CartDrawerHeader as O,CartLines as _,CartStatusRail as v,CartTotals as y,CartTrustMarkers as A,CartUpsell as D}from"./cart/drawer-parts.js";import{CART_DRAWER_DEFAULTS as L,resolveCartDrawerLook as h}from"efficient-web-builder/format/lib/content/cart-drawer";const j=h(void 0);function E({content:e=L,look:t=j}){const{isOpen:l,preview:n,close:i,items:c,setAutoOpen:o}=C(),s=u(null),p=R(c.filter(d).map(f=>f.slug));return m(()=>{o(t.autoOpen)},[t.autoOpen,o]),a(w,{look:t,drawer:{closeRef:s,lockScroll:!n},open:l,onClose:i,label:"Your cart",children:[r(O,{content:e,closeRef:s}),r(v,{content:e}),a("div",{className:"flex-1 overflow-y-auto [scrollbar-color:var(--site-line)_transparent] [scrollbar-width:thin]",children:[r(_,{content:e,tyres:p}),r(D,{}),r(x,{}),r(A,{content:e})]}),r(y,{}),r(T,{})]})}export{E as default};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { CartLine } from "./CartContext.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { TyreThumbnail } from "./useTyreCatalog.js";
|
|
3
|
+
import type { WheelSummary } from "../lib/api/index.js";
|
|
3
4
|
export interface CartLineThumbnailProps {
|
|
4
5
|
line: CartLine;
|
|
5
6
|
catalog: WheelSummary[];
|
|
6
|
-
tyre?:
|
|
7
|
+
tyre?: TyreThumbnail | null;
|
|
7
8
|
}
|
|
8
9
|
export default function CartLineThumbnail({ line, catalog, tyre }: CartLineThumbnailProps): import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as n,jsxs as g}from"react/jsx-runtime";import{useCallback as m,useEffect as
|
|
1
|
+
"use client";import{jsx as n,jsxs as g}from"react/jsx-runtime";import{useCallback as m,useEffect as f,useMemo as h,useState as c}from"react";import{safeLocalStorage as w}from"efficient-web-builder/format/lib/safe-storage";import{bannerWords as N,CONSENT_RULES as O,visitorRegion as P}from"../lib/consent/rules.js";import{readerTimeZone as x}from"../lib/reader-zone.js";import{browserSendsGpc as E,NOT_ASKED as H,readStoredChoice as R,resolveConsent as T,setConsent as _,writeStoredChoice as j}from"../lib/consent/choice.js";import{COUNTRY_STORAGE_KEY as A,useActiveCountry as k}from"./CurrencyContext.js";import{ConsentBannerView as G}from"./ConsentBanner.js";import{ConsentPanelView as V,NoTrackingPanelView as D}from"./ConsentPanel.js";import{ConsentControlsContext as I,ConsentStateContext as K,PENDING as L}from"./ConsentContext.js";function Q({consent:e,children:u}){const[o,p]=c(e.enabled?L:H),[r,C]=c(!e.enabled),[i,t]=c(!1),v=k(),a=m(()=>{const d=P(x(),w.getItem(A));return T({asked:e.enabled,region:d,stored:R(),gpc:E()})},[e.enabled]);f(()=>{p(a()),C(!0)},[a,v]),f(()=>{_(o)},[o]);const l=m(d=>{j(d),p(a()),t(!1)},[a]),s=O[o.region],y=h(()=>({state:o,rule:s,ready:r,openPanel:()=>t(!0)}),[o,s,r]),b=e.enabled&&r&&o.model==="opt-in"&&!o.chosen,S=e.enabled&&r&&o.model==="opt-out"&&!o.chosen&&!o.gpc&&e.noticeOptOut;return n(K.Provider,{value:o,children:g(I.Provider,{value:y,children:[u,(b||S)&&!i&&n(G,{model:o.model,words:N(s,e.brand,e.tags),layout:e.layout,privacyHref:e.privacyHref,onAccept:()=>l({analytics:!0,ads:!0}),onReject:()=>l({analytics:!1,ads:!1}),onChoose:()=>t(!0)}),!e.enabled&&n(D,{open:i,privacyHref:e.privacyHref,onClose:()=>t(!1)}),e.enabled&&r&&n(V,{open:i,rule:s,analytics:o.analytics,ads:o.ads,gpc:o.gpc,privacyHref:e.privacyHref,onSave:l,onClose:()=>t(!1)})]})})}export{Q as ConsentProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as a,jsxs as o}from"react/jsx-runtime";import R from"./SectionBand.js";import j from"efficient-web-builder/render/components/Placeholder";import _ from"efficient-web-builder/render/components/PostDate";import{withRMark as d}from"efficient-web-builder/render/components/RMark";import{renderGold as h}from"efficient-web-builder/render/components/goldPhrases";import{say as p}from"efficient-web-builder/format/lib/editor-words";import{stripMarkup as z}from"efficient-web-builder/format/lib/markup";import{bandPadAttrs as S}from"efficient-web-builder/render/lib/content/section-padding";import{DETAIL_ROWS_ROOM as C,withBandClasses as T}from"../lib/sections/band-padding.js";import{CardTemplateRows as $}from"efficient-web-builder/render/components/CardRowContext";const c={body:"text-[length:var(--size-body,15px)]",labelSmall:"text-[length:var(--size-label,11px)]",label:"text-[length:var(--size-label,12px)]",labelLarge:"text-[length:var(--size-label,13px)]"};function D(t){return{eyebrow:t.eyebrow?.trim()?t.eyebrow:"",title:t.title?.trim()?t.title:"",copy:t.copy?.trim()?t.copy:"",image:t.image?.trim()?t.image:"",tag:t.tag?.trim()?t.tag:""}}function O(t){return t.every(l=>!l.media&&!(l.specs??[]).some(b))}const b=t=>!!((t?.label??"").trim()||(t?.value??"").trim()||(t?.at??"").trim()),B="[&:not(:first-child)]:border-t [&:not(:first-child)]:border-line";function L({rows:t,startLeft:l=!1,layout:v="even",pads:u,editing:y=!1,template:w,nodeId:N}){const i=v==="narrow",g=S(u??{},C),f=(t??[]).filter(e=>(e?.eyebrow??"").trim()||(e?.title??"").trim()||(e?.copy??"").trim()||(e?.tag??"").trim()||(e?.image??"").trim()),r=f.length>0?f:y?[{tag:p("Row {n}",{n:1})},{tag:p("Row {n}",{n:2})},{tag:p("Row {n}",{n:3})}]:[];return r.length===0?null:a(R,{className:T("relative z-[2] border-b border-line bg-bg",g),style:g.style,children:a($,{ownerId:N??"",ownerType:"DetailRows",Template:O(r)?w:void 0,rows:r.map(D),fallback:r.map((e,n)=>{const s=n%2===1!==l;return o("div",{className:["grid items-center py-[60px]",i?"grid-cols-[1fr_460px] gap-[72px]":"grid-cols-2 gap-12","max-view-desktop:grid-cols-1",s?"[direction:rtl] max-view-desktop:[direction:ltr]":"",n>0?"border-t border-line":""].join(" "),children:[o("div",{className:["[direction:ltr] flex flex-col gap-4",i?"max-w-[560px]":"",i&&!s?"ml-auto max-view-desktop:ml-0":""].join(" "),children:[e.eyebrow?.trim()&&a("div",{className:`font-mono ${c.labelLarge} uppercase tracking-[0.2em] text-accent`,children:d(e.eyebrow)}),e.title?.trim()&&a("h2",{className:"font-heading2 text-[length:min(var(--size-headingMedium,clamp(28px,3vw,42px)),var(--sf-heading-max,9999px))] [font-weight:var(--sf-heading-weight,500)] [&_em]:[font-weight:var(--sf-heading-weight-strong,inherit)] leading-[1.1] tracking-[-0.02em]",children:h(e.title,!0)}),e.copy?.trim()&&a("p",{className:`${c.body} leading-[1.6] text-fg-dim`,children:h(e.copy,!1)}),(()=>{const x=(e.specs??[]).filter(b);return x.length===0?null:a("dl",{className:`mt-2 border-t border-line pt-3 font-mono ${c.label} uppercase tracking-[0.1em] leading-[2.1]`,children:x.map((m,k)=>o("div",{className:"flex items-baseline justify-between gap-6",children:[a("dt",{className:"text-fg-dim",children:d(m.label??"")}),a("dd",{className:"text-fg",children:m.at?a(_,{at:m.at}):d(m.value??"")})]},k))})})()]}),o("div",{className:["[direction:ltr] flex flex-col gap-3",i?s?"items-end":"items-start":"",i?"max-view-desktop:items-start":""].join(" "),children:[e.media?a("div",{className:"w-full",children:e.media}):a("div",{className:["relative overflow-hidden max-w-full",i?e.imageShape==="wide"?"w-[460px] aspect-[16/9]":"w-[360px] aspect-square":"aspect-square"].join(" "),children:a(j,{label:e.tag?.trim()||e.title?.trim()||`row-${n+1}`,src:e.image||void 0,alt:z(e.title?.trim()||e.tag?.trim()||""),showBackground:!e.image,objectFit:"contain",sizes:i?"(max-width: 1100px) 100vw, 460px":"(max-width: 1100px) 100vw, 50vw"})}),e.tag?.trim()&&a("span",{className:`font-mono ${c.labelSmall} uppercase tracking-[0.2em] text-fg-dim ${s?"text-left":"text-right"}`,children:d(e.tag)})]})]},n)}),wrapCopy:e=>a("div",{className:B,children:e}),children:e=>e})})}export{L as default,D as detailCardRow,O as templateCanDraw};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as n,jsxs as
|
|
1
|
+
"use client";import{jsx as n,jsxs as t}from"react/jsx-runtime";import{useEffect as h,useState as g}from"react";import x from"efficient-web-builder/render/components/BlockFrame";import{renderHeadline as b}from"efficient-web-builder/render/components/goldPhrases";import{firstReadableZone as k}from"../lib/zone.js";import{OPENING_WORDS as m,badgeLabel as N,momentIn as y,openingStatus as v,weekLines as I}from"../lib/sections/opening-hours.js";const _=3e4;function j({show:i,title:r,row:a,contained:p,now:s}){const[d,c]=g(s??null),o=a?.zone??"",f=!!a?.week,u=!!s||k(o)!=="";if(h(()=>{if(s){c(s);return}if(!f||!u){c(null);return}const e=()=>c(y(o,Date.now()));e();const l=setInterval(e,_);return()=>clearInterval(l)},[s,o,f,u]),!a)return null;if(i==="badge"){if(!a.week||!u)return null;const e=d?v(a.week,d):null;return n(x,{contained:p,className:"py-6",children:n(O,{label:e?N(e):null,open:e?.open??!1})})}return!a.week&&!a.hours.length?null:n(x,{contained:p,className:"py-6",children:t("div",{className:"flex max-w-[560px] flex-col gap-4",children:[r&&n("h2",{className:"font-heading3 text-[length:min(var(--size-headingSmall,28px),var(--sf-heading-max,9999px))] font-medium leading-[1.1] tracking-[-0.02em]",children:b(r,!1)}),a.week?n("ul",{className:"flex flex-col text-[15px]",children:I(a.week).map(e=>{const l=d!==null&&d.day===e.day;return t("li",{"aria-current":l?"date":void 0,className:"flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1 rounded-sm border-b border-line px-3 py-2.5 last:border-b-0",style:l?{background:"color-mix(in oklab, var(--accent) 12%, transparent)"}:void 0,children:[t("span",{className:l?"font-medium":void 0,children:[e.name,l&&n("span",{className:"opacity-70",children:` · ${m.today}`})]}),n("span",{className:e.closed?"tabular-nums opacity-60":"tabular-nums",children:e.closed?m.closed:e.periods})]},e.day)})}):n("div",{className:"flex flex-col gap-1 text-[15px] leading-[1.6]",children:a.hours.map((e,l)=>n("p",{children:e},l))})]})})}function O({label:i,open:r}){return i===null?t("span",{"aria-hidden":!0,className:"invisible inline-flex items-center gap-2 rounded-md px-3 py-1.5 text-[14px]",children:[n("span",{className:"h-2 w-2 rounded-full"}),m.openNow]}):t("span",{className:"inline-flex items-center gap-2 rounded-md px-3 py-1.5 text-[14px] tabular-nums",style:{background:r?"color-mix(in oklab, var(--green) 16%, transparent)":"color-mix(in oklab, var(--fg) 8%, transparent)"},children:[n("span",{"aria-hidden":!0,className:r?"h-2 w-2 shrink-0 rounded-full bg-green":"h-2 w-2 shrink-0 rounded-full bg-current opacity-50"}),i]})}export{_ as OPENING_TICK_MS,j as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as ae}from"react/jsx-runtime";import{createContext as se,useContext as re,useEffect as b,useId as le,useMemo as ce,useState as n}from"react";import{ApiError as F,bookings as h}from"../../lib/api/index.js";import{findFirstBookableDay as ue,isoDate as me}from"../../lib/booking-dates.js";import{startHasPassed as de}from"../../lib/booking/appointment-time.js";import{readerTimeZone as fe}from"../../lib/reader-zone.js";import{uuid as Z}from"../../lib/uuid.js";import{listRows as pe}from"../../lib/api/list-rows.js";const z=se(null);function Ce(){const e=re(z);if(!e)throw new Error("useBookingForm must be used inside <BookingFormProvider>");return e}const T=[{id:"example-1",name:"Example service",durationMinutes:45,price:"80.00",description:"What this appointment includes, in a sentence."},{id:"example-2",name:"Second example",durationMinutes:30,price:"0",description:""}];function ve(e){return{timezone:"UTC",slots:[`${e}T09:00:00.000Z`,`${e}T10:30:00.000Z`,`${e}T13:00:00.000Z`].map(s=>({start:s}))}}const be={bookingNumber:"EXAMPLE-0000",service:"Example service",startAt:"2026-01-01T00:00:00.000Z",timezone:"UTC",customerTimezone:"",manageToken:"example"};function he(e,s){return e&&s?.length===0}function ye(e,s){return!!(!e.editing&&!e.submitting&&e.hasService&&e.selectedStart&&!de(e.selectedStart,s)&&e.name.trim()&&e.email.trim()&&!e.requiresPayment)}function De({editing:e=!1,previewConfirmation:s=!1,children:$}){const L=le(),m=ce(()=>me(new Date),[]),[y,E]=n(),[R,W]=n(""),[a,P]=n(""),[r,k]=n(m),[j,q]=n(m),[d,U]=n(!1),[_,c]=n(null),[K,u]=n(),[S,f]=n(""),[g,O]=n(""),[x,H]=n(""),[A,V]=n(""),[C,X]=n(""),[Y,G]=n(()=>Z()),[J,Q]=n(null),[ee,p]=n(!1),[D,w]=n(!1),[te,v]=n(null),[I,ne]=n("");b(()=>{ne(fe())},[]),b(()=>{let i=!1;return h.listServices().then(t=>{if(i)return;const N=pe(t);E(N),W(t.currency),P(oe=>oe||N[0]?.id||"")}).catch(()=>{i||E([])}),()=>{i=!0}},[]),b(()=>{if(d||!a)return;const i={aborted:!1};return f(""),u(void 0),v(null),c(null),p(!0),ue(a,m,{signal:i}).then(t=>{if(!i.aborted){if(t.outcome==="found"){k(t.date),q(t.date),u(t.availability);return}c(t.outcome==="noneInWindow"?`No times are available in the next ${t.days} days.`:"We couldn't load available times. Please try again.")}}).finally(()=>{i.aborted||p(!1)}),()=>{i.aborted=!0}},[d,a,m]),b(()=>{if(!d||!a||!r)return;let i=!1;return f(""),u(void 0),v(null),c(null),p(!0),h.getAvailability(a,r).then(t=>{i||(u(t),t.slots.length===0&&c("No times are available on this date."))}).catch(()=>{i||c("We couldn't load available times. Please try again.")}).finally(()=>{i||p(!1)}),()=>{i=!0}},[r,d,a]);const l=y?.find(i=>i.id===a),B=l?.depositAmountDue!=null,M=ye({editing:e,submitting:D,hasService:!!l,selectedStart:S,name:g,email:x,requiresPayment:B},Date.now());async function ie(i){if(i.preventDefault(),!(!M||!l)){w(!0),v(null);try{const t=await h.create({serviceId:l.id,start:S,customer:{name:g.trim(),email:x.trim(),phone:A.trim()},notes:C.trim(),idempotencyKey:Y,customerTimezone:I});Q(t),G(Z())}catch(t){v(t instanceof F&&t.status===409?"That time was just booked. Choose another available time.":"Your appointment wasn't submitted. Please check your details and try again."),t instanceof F&&t.status===409&&(f(""),h.getAvailability(l.id,r).then(u).catch(()=>{}))}finally{w(!1)}}}const o=he(e,y);return ae(z.Provider,{value:{fieldPrefix:L,editing:e,services:o?T:y,currency:o?"AUD":R,serviceId:o?T[0].id:a,setServiceId:P,service:o?T[0]:l,requiresPayment:o?!1:B,date:r,earliestDate:j,setDate:k,setDateTouched:U,availability:o?ve(r):K,loadingSlots:o?!1:ee,noSlotsMessage:_,selectedStart:o?`${r}T09:00:00.000Z`:S,setSelectedStart:f,customerTimezone:I,name:g,setName:O,email:x,setEmail:H,phone:A,setPhone:V,notes:C,setNotes:X,confirmation:J??(s?be:null),submitting:D,error:te,canSubmit:o?!1:M,handleSubmit:ie,sample:!!o},children:$})}export{z as BookingFormContext,De as BookingFormProvider,be as SAMPLE_CONFIRMATION,T as SAMPLE_SERVICES,ye as bookingReady,he as showsExample,Ce as useBookingForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as
|
|
1
|
+
"use client";import{jsx as e,jsxs as i}from"react/jsx-runtime";import{SAMPLE_CONFIRMATION as S,useBookingForm as F}from"./BookingFormState.js";import B from"efficient-web-builder/render/components/Btn";import{HideTaker as A}from"efficient-web-builder/render/components/ViewHideRoot";import u from"../WebFormField.js";import{CardTemplateRows as E}from"efficient-web-builder/render/components/CardRowContext";import{InsideSiteColumn as P}from"efficient-web-builder/render/components/SiteGutterFrame";import{groundCell as R}from"../card-ground-cell.js";import{PART_ROW_ATTR as K,encodePartRow as W}from"efficient-web-builder/render/lib/document/text-parts";import{BOOKING_SERVICE_SLOT as _,BOOKING_TIME_SLOT as M}from"../../lib/content/booking-card-seed.js";import{firstReadableZone as v}from"../../lib/zone.js";import{formatAppointment as q,formatAppointmentTime as L,startHasPassed as G}from"../../lib/booking/appointment-time.js";import{formatMoneyInCurrency as U}from"../../lib/commerce.js";import{FREE_PRICE as V}from"../../lib/wheels/price-display.js";const f="w-full border-2 border-line bg-bg px-4 py-4 font-[family-name:var(--bk-value-font,var(--font-display))] text-[length:var(--bk-value-size,17px)] text-fg outline-none transition-colors placeholder:text-fg-dim hover:border-fg-dim focus:border-accent";function Y(r,t){const n=Number(r);if(n===0)return V;try{return U(n,t)}catch{return`${t} ${r}`}}const O={selected:!0};function D(r,t){return({index:n})=>t?{[K]:W(r,n)}:{}}const h="font-[family-name:var(--bk-name-font,var(--font-mono))] text-[length:var(--bk-name-size,12px)]";function I({number:r,children:t}){return i("div",{className:"mb-4 flex items-center gap-3",children:[e("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-full border border-line font-[family-name:var(--bk-step-font,var(--font-mono))] text-[length:var(--bk-step-size,11px)] font-semibold text-fg-dim",children:r}),e("h3",{className:"font-[family-name:var(--bk-step-font,var(--font-mono))] text-[length:var(--bk-step-size,12px)] font-semibold uppercase tracking-[0.2em] text-fg",children:t})]})}function de({eyebrow:r,heading:t,intro:n}){return i("div",{className:"mb-10 max-w-[760px]",children:[(r??"").trim()&&e("p",{className:"mb-4 font-mono text-[12px] font-semibold uppercase tracking-[0.24em] text-accent",children:r}),(t??"").trim()&&e("h2",{className:"font-heading2 text-[length:min(var(--size-headingMedium,44px),var(--sf-heading-max,9999px))] font-medium uppercase leading-[0.98] tracking-[-0.025em] text-fg max-view-wide:text-[length:min(var(--size-headingMedium,32px),var(--sf-heading-max,9999px))]",children:t}),(n??"").trim()&&e("p",{className:"mt-5 max-w-[660px] font-display text-[17px] leading-[1.65] text-fg-dim",children:n})]})}function pe({style:r,owner:t}){const{fieldPrefix:n,services:o,currency:l,serviceId:c,setServiceId:k,requiresPayment:y,date:N,earliestDate:T,setDate:C,setDateTouched:w,availability:m,loadingSlots:d,noSlotsMessage:g,selectedStart:s,setSelectedStart:Z,customerTimezone:j,editing:p}=F();if(!o)return null;const H=Date.now(),x=v(j,m?.timezone??""),z=v(m?.timezone??""),b=z&&z!==x?z:"",$=(m?.slots??[]).map(a=>({start:a.start,time:L(a.start,x),businessTime:b?`${L(a.start,b)} business`:"",passed:!p&&G(a.start,H)}));return i(A,{className:"flex flex-col gap-10",style:r,children:[i("div",{children:[e(I,{number:"01",children:"Choose a service"}),e("div",{className:"grid gap-3 sm:grid-cols-2",children:e(E,{ownerId:t.id,ownerType:t.type,slot:_,Template:t.serviceTemplate,rows:o.map(a=>({name:a.name,meta:`${a.durationMinutes} min · ${Y(a.price,l)}`,description:a.description??""})),states:o.map(a=>a.id===c?O:void 0),actions:p?void 0:o.map(a=>({press:()=>k(a.id),label:a.name})),copyAttrs:D(_,p),fallback:null,wrapCopy:R,children:a=>e(P,{children:a})})}),y&&e("p",{className:"mt-3 font-[family-name:var(--bk-note-font,var(--font-mono))] text-[length:var(--bk-note-size,11px)] uppercase tracking-[0.14em] text-alert",role:"alert",children:"This service requires an upfront payment and cannot be booked through this form yet."})]}),i("div",{children:[e(I,{number:"02",children:"Choose a date and time"}),e(u,{separate:!0,htmlFor:`${n}-date`,label:"Date",required:!0,labelFace:h,children:e("input",{id:`${n}-date`,type:"date",min:T,value:N,onChange:a=>{w(!0),C(a.target.value)},className:f,required:!0})}),e("div",{className:"mt-4 grid grid-cols-2 gap-2 sm:grid-cols-3 min-[1200px]:grid-cols-4",role:"group","aria-label":"Available appointment times",children:d?e("p",{className:"col-span-full py-3 font-[family-name:var(--bk-note-font,var(--font-mono))] text-[length:var(--bk-note-size,11px)] uppercase tracking-[0.18em] text-fg-dim",children:"Loading times…"}):m?.slots.length?e(E,{ownerId:t.id,ownerType:t.type,slot:M,Template:t.timeTemplate,rows:$.map(a=>({time:a.time,businessTime:a.businessTime})),states:$.map(a=>a.start===s&&!a.passed?O:void 0),actions:p?void 0:$.map(a=>({press:()=>Z(a.start),label:a.time,disabled:a.passed})),copyAttrs:D(M,p),fallback:null,wrapCopy:R,children:a=>e(P,{children:a})}):g?e("p",{className:"col-span-full py-3 font-[family-name:var(--bk-note-font,var(--font-mono))] text-[length:var(--bk-note-size,11px)] uppercase tracking-[0.18em] text-fg-dim",role:"status",children:g}):null}),x&&!d&&!!m?.slots.length&&i("p",{className:"mt-3 font-[family-name:var(--bk-note-font,var(--font-mono))] text-[length:var(--bk-note-size,10px)] uppercase tracking-[0.16em] text-fg-dim",children:["Times shown in ",x,b?` · business timezone ${b}`:""]})]})]})}function ue({buttonLabel:r,style:t}){const{fieldPrefix:n,editing:o,name:l,setName:c,email:k,setEmail:y,phone:N,setPhone:T,notes:C,setNotes:w,submitting:m,error:d,canSubmit:g}=F();return i(A,{className:"sf-card border border-line bg-bg p-5 min-[640px]:p-8",style:t,children:[e(I,{number:"03",children:"Your details"}),i("div",{className:"flex flex-col gap-4",children:[e(u,{separate:!0,htmlFor:`${n}-name`,label:"Name",required:!0,labelFace:h,children:e("input",{id:`${n}-name`,type:"text",autoComplete:"name",value:l,onChange:s=>c(s.target.value),className:f,required:!0})}),e(u,{separate:!0,htmlFor:`${n}-email`,label:"Email",required:!0,labelFace:h,children:e("input",{id:`${n}-email`,type:"email",inputMode:"email",autoComplete:"email",value:k,onChange:s=>y(s.target.value),className:f,required:!0})}),e(u,{separate:!0,htmlFor:`${n}-phone`,label:"Phone",labelFace:h,children:e("input",{id:`${n}-phone`,type:"tel",inputMode:"tel",autoComplete:"tel",value:N,onChange:s=>T(s.target.value),className:f})}),e(u,{separate:!0,htmlFor:`${n}-notes`,label:"What would you like to cover?",labelFace:h,children:e("textarea",{id:`${n}-notes`,rows:4,value:C,onChange:s=>w(s.target.value),className:`${f} resize-y`})})]}),d&&e("p",{className:"mt-4 font-[family-name:var(--bk-note-font,var(--font-mono))] text-[length:var(--bk-note-size,11px)] uppercase tracking-[0.16em] text-alert",role:"alert",children:d}),e(B,{type:o?"button":"submit",disabled:!g,arrow:null,className:"mt-6 w-full disabled:cursor-not-allowed disabled:opacity-50",children:m?"Submitting…":(r??"").trim()||"Book appointment"})]})}function fe({successMessage:r}){const{confirmation:t,customerTimezone:n}=F();if(!t)return null;const o=v(t.customerTimezone,n,t.timezone),l=v(t.timezone),c=t!==S&&l&&l!==o?l:"";return i("div",{className:"sf-card max-w-[760px] border border-line bg-bg p-6 min-[640px]:p-10",role:"status",children:[i("p",{className:"font-mono text-[12px] font-semibold uppercase tracking-[0.22em] text-accent",children:["Request received · ",t.bookingNumber]}),e("h3",{className:"mt-4 font-display text-[28px] font-medium uppercase text-fg",children:t.service}),e("p",{className:"mt-2 font-display text-[17px] text-fg-dim",children:q(t.startAt,o)}),c&&i("p",{className:"mt-1 font-mono text-[10px] uppercase tracking-[0.16em] text-fg-dim",children:["Business time: ",q(t.startAt,c)]}),(r??"").trim()&&e("p",{className:"mt-5 max-w-[620px] font-serif text-[18px] italic leading-[1.6] text-fg-dim",children:r}),e(B,{href:`/book/${encodeURIComponent(t.manageToken)}`,newTab:t!==S,variant:"ghost",className:"mt-8",children:"Manage booking"})]})}export{pe as BookingChoose,fe as BookingConfirmed,ue as BookingDetails,de as BookingHead};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RefObject } from "react";
|
|
2
2
|
import { type CartLine } from "../CartContext.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { TyreThumbnail } from "../useTyreCatalog.js";
|
|
4
4
|
import { type CartDrawerContent } from "efficient-web-builder/format/lib/content/cart-drawer";
|
|
5
5
|
export declare function CartDrawerHeader({ content, closeRef, }: {
|
|
6
6
|
content: CartDrawerContent;
|
|
@@ -11,7 +11,7 @@ export declare function CartStatusRail({ content }: {
|
|
|
11
11
|
}): import("react").JSX.Element;
|
|
12
12
|
export declare function CartLines({ content, tyres, }: {
|
|
13
13
|
content: CartDrawerContent;
|
|
14
|
-
tyres: ReadonlyMap<string,
|
|
14
|
+
tyres: ReadonlyMap<string, TyreThumbnail>;
|
|
15
15
|
}): import("react").JSX.Element;
|
|
16
16
|
export declare function CartUpsell(): import("react").JSX.Element;
|
|
17
17
|
export declare function CartCouponRow(): import("react").JSX.Element;
|
|
@@ -22,7 +22,7 @@ export declare function CartTotals(): import("react").JSX.Element;
|
|
|
22
22
|
export declare function CartActions(): import("react").JSX.Element;
|
|
23
23
|
export declare function CartLineRow({ line, tyre, onRemove, onQtyChange, }: {
|
|
24
24
|
line: CartLine;
|
|
25
|
-
tyre?:
|
|
25
|
+
tyre?: TyreThumbnail | null;
|
|
26
26
|
onRemove: () => void;
|
|
27
27
|
onQtyChange: (q: number) => void;
|
|
28
28
|
}): import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as r,Fragment as f}from"react/jsx-runtime";import R from"next/link";import{useEffect as O,useMemo as Y,useRef as j,useState as v}from"react";import{stripeAppearance as J}from"../../lib/checkout/stripe-appearance.js";import{Elements as ee,PaymentElement as te,useElements as re,useStripe as ne}from"@stripe/react-stripe-js";import{loadStripe as ae}from"@stripe/stripe-js";import{useCurrency as E}from"../CurrencyContext.js";import{Notice as _}from"../Notice.js";import{resolveCopyright as ie}from"../../lib/content/site.js";import{ApiError as L,products as T}from"../../lib/api/index.js";import oe,{WORDMARK_FIT_FLOOR_PX as ce}from"efficient-web-builder/render/components/Logo";import{NOT_CHECKED as q,orderReference as se}from"../../lib/checkout/pay-first.js";import{CheckoutStateProvider as le,useCheckout as de}from"./checkout-state.js";import{CheckoutContact as me,CheckoutOrderSummary as pe,CheckoutPayment as ue,CheckoutShippingAddress as fe,CheckoutShippingMethod as xe,FormLock as M,LeaveLink as z}from"./checkout-parts.js";function ge(t){return e(le,{...t,children:e(be,{})})}function he({order:t,paid:n}){const{formatMoney:i}=E();if(!t.grandTotal||!t.currency)return null;const m=c=>i(Number(c),t.currency),h=Number(t.freightCharge??0),p=Number(t.discountAmount??0);return r("dl",{className:"grid w-full max-w-sm grid-cols-[1fr_auto] gap-x-6 gap-y-1 border-y border-line py-3 text-left text-sm",children:[(t.shippingMethod||h>0)&&r(f,{children:[r("dt",{className:"text-fg-dim",children:["Delivery",t.shippingMethod?` · ${t.shippingMethod}`:""]}),e("dd",{className:"text-right font-mono",children:m(t.freightCharge??"0")})]}),p>0&&r(f,{children:[r("dt",{className:"text-fg-dim",children:["Discount",t.couponCode?` · ${t.couponCode}`:""]}),r("dd",{className:"text-right font-mono",children:["−",m(t.discountAmount??"0")]})]}),e("dt",{className:"text-fg",children:n?"Total paid":"Order total"}),e("dd",{className:"text-right font-mono text-fg",children:m(t.grandTotal)})]})}function ye({result:t,lostChangeNote:n=null}){const i=e("span",{className:"font-mono text-fg",children:t.checkoutNumber});return r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:t.kind==="refunded"||t.kind==="expired"?"Order not placed":t.kind==="processing"?"Payment processing":"Payment received"}),e("p",{className:"text-fg-dim",children:t.kind==="refunded"?r(f,{children:["An item sold out or an offer ended while you paid for checkout ",i,". Your payment goes back to your card."]}):t.kind==="expired"?r(f,{children:["The hold on checkout ",i," ran out before your payment arrived. Your payment goes back to your card."]}):t.kind==="processing"?r(f,{children:["Your payment for checkout ",i," is being processed. When it goes through, we will email your order confirmation."]}):r(f,{children:["Thank you — your payment",t.checkoutNumber?r(f,{children:[" for checkout ",i]}):null," has gone through. We will email you the order number shortly."]})}),n&&t.kind!=="refunded"&&t.kind!=="expired"&&e("p",{className:"text-sm text-fg-dim",children:n}),e(R,{href:"/wheels",className:"mt-2 border-2 border-line px-6 py-3 font-mono text-[12px] uppercase tracking-[0.24em] hover:border-accent",children:"Continue browsing"})]})}function be(){const{site:t,logo:n,items:i,placing:m,formLocked:h,email:p,me:c,addressSaveNote:x,lostChangeNote:d,idemKey:u,confirmation:o,setConfirmation:b,payment:g,paypalStep:k,squareStep:N,pendingConf:l,paid:y,setPaid:C,payNote:s,afterpayConfirming:a,gocardlessConfirming:w,zipConfirming:P,klarnaConfirming:K,cardConfirming:U,checkoutResult:D,confirmCardPayment:W,cardStillProcessing:H,renewCardPayment:G,holdRenewed:Q,leaveCardPayment:V,checkoutRootRef:X,setCheckoutHeaderEl:Z}=de();return o?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:y?"Payment received":"Order received"}),r("p",{className:"text-fg-dim",children:[y?r(f,{children:["Thank you — your payment for order"," ",e("span",{className:"font-mono text-fg",children:o.orderNumber})," has gone through."," "]}):r(f,{children:["Thank you — your order ",e("span",{className:"font-mono text-fg",children:o.orderNumber})," is being reviewed by our team."," "]}),c?r(f,{children:["Track it under"," ",e(R,{href:"/account/orders",className:"text-accent underline",children:"your orders"}),"."]}):e(f,{children:"We’ve emailed you a link to set a password and track it."})]}),e(he,{order:o,paid:y}),d&&e("p",{className:"text-sm text-fg-dim",children:d}),s&&e("p",{className:"text-sm text-fg-dim",children:s}),x&&e("p",{className:"text-sm text-fg-dim",children:x}),!c&&r("p",{className:"text-sm text-fg-dim",children:["You can also"," ",e(R,{href:`/track?order=${encodeURIComponent(o.orderNumber)}`,className:"text-accent underline",children:"track this order"})," ","anytime with just your order number and email — no password needed."]}),e(R,{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"})]}):D?e(ye,{result:D,lostChangeNote:d}):U?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Placing your order — one moment."})]}):a?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Afterpay — one moment."})]}):w?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Setting up your direct debit…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Confirming with GoCardless — one moment."})]}):P?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Zip — one moment."})]}):K?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Klarna — one moment."})]}):g&&l?e(ke,{payment:g,checkout:l,holdRenewed:Q,onPaid:W,onProcessing:H,onRenew:G,onBack:V}):k&&l?e(ve,{confirmation:l,clientId:t.paypalClientId??"",idemKey:u,onPaid:()=>{C(!0),b(l)},onSkip:()=>b(l)}):N&&l?e(Se,{confirmation:l,applicationId:t.squareApplicationId??"",locationId:t.squareLocationId??"",environment:t.squareEnvironment??"production",idemKey:u,onPaid:()=>{C(!0),b(l)},onSkip:()=>b(l)}):r("div",{ref:X,className:"bg-bg text-fg",children:[r("header",{ref:Z,className:"sticky top-0 z-30 grid grid-cols-[1fr_auto_1fr] items-center gap-8 max-[640px]:grid-cols-[auto_minmax(0,1fr)_auto] max-[640px]:gap-3 border-b border-line px-[var(--sf-site-gutter,40px)] py-6 backdrop-blur-md max-[640px]:px-[min(20px,var(--sf-site-gutter,40px))] max-[640px]:py-4",style:{background:"color-mix(in oklab, var(--bg) 92%, transparent)"},children:[r(z,{href:"/",className:"inline-flex items-center gap-3 font-mono text-[14px] uppercase tracking-[0.26em] text-fg-dim transition-colors hover:text-accent",children:["←",e("span",{className:"max-[640px]:hidden",children:"Back to shop"})]}),e("div",{className:"flex min-w-0 justify-center max-[640px]:[container-type:inline-size]",children:e(z,{href:"/","aria-label":`${t.name} home`,className:"inline-flex max-w-full items-center justify-center overflow-x-clip",children:e(oe,{variant:"header",scrolled:!0,src:n?.url??null,reverse:n?.reverse??!1,reversedSrc:n?.reversed??null,inkIsDark:n?.inkIsDark??null,size:n?.size??"medium",sizePx:n?.sizePx??null,sizeUnit:n?.sizeUnit??null,siteName:t.name,fitWordmarkToContainer:!0,fitFloorPx:ce})})}),t.cardPayments?r("span",{className:"flex items-center justify-end gap-3 font-mono text-[12px] uppercase tracking-[0.26em] text-fg-dim",children:[e("span",{className:"text-green",children:"●"}),e("span",{className:"max-[640px]:hidden",children:"Encrypted ·"})," Stripe"]}):e("span",{})]}),r("section",{className:"mx-auto flex max-w-[var(--sf-site-width,1600px)] flex-wrap items-center justify-between gap-x-8 gap-y-3 border-b border-line bg-surface px-[var(--sf-site-gutter,40px)] py-4 font-mono text-[13px] font-medium uppercase tracking-[0.24em] text-fg max-view-desktop:px-[min(24px,var(--sf-site-gutter,40px))]",children:[e("span",{className:"inline-flex items-center bg-accent px-3 py-1 font-bold text-bg",children:"Checkout"}),e("nav",{"aria-label":"Checkout steps",className:"flex flex-wrap items-center gap-5",children:[{n:"01",label:"Cart",state:"done"},{n:"02",label:"Ship & pay",state:"active"},{n:"03",label:"Confirmed",state:"pending"}].map(S=>r("span",{className:["relative flex items-center gap-2 transition-colors",S.state==="pending"?"text-fg-dim":"text-fg",S.state==="active"?"font-bold after:absolute after:inset-x-0 after:-bottom-1 after:h-[2px] after:bg-accent":""].join(" "),children:[e("span",{className:S.state==="done"?"text-accent font-bold":"",children:S.n}),e("span",{children:S.label})]},S.n))})]}),r("main",{className:"mx-auto grid max-w-[var(--sf-site-width,1600px)] grid-cols-[1fr_420px] items-start gap-16 px-[var(--sf-site-gutter,40px)] pt-10 pb-[100px] max-view-desktop:grid-cols-1 max-view-desktop:gap-10 max-view-desktop:px-[min(24px,var(--sf-site-gutter,40px))] max-view-desktop:pt-8 max-view-desktop:pb-20",children:[r("div",{children:[r(M,{locked:h,children:[e(me,{}),e(fe,{}),e(xe,{})]}),e(M,{locked:m,children:e(ue,{})})]}),e(pe,{})]}),e("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:e("span",{children:ie({legalName:t.legalName,foundedYear:t.foundedYear,siteName:t.name})})})]})}function ke({payment:t,checkout:n,holdRenewed:i,onPaid:m,onProcessing:h,onRenew:p,onBack:c}){const{formatMoney:x}=E(),d=e("span",{className:"text-fg",children:x(Number(t.amount),t.currency)}),u=Y(()=>ae(t.publishableKey),[t.publishableKey]),o=Y(()=>J(),[]);return e("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:r("div",{className:"w-full max-w-xl border border-line bg-bg",children:[r("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:se(n)}),e("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"Payment"})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:[e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:n.orderNumber?r(f,{children:["Your order is placed. Pay ",d," by card to confirm it now."]}):i?r(f,{children:["Your hold ran out, so your items are held again",n.expiresAt?` until ${B(n.expiresAt)}`:"",". Enter your card again, then pay ",d,"."]}):r(f,{children:["Your items are held",n.expiresAt?` until ${B(n.expiresAt)}`:"",". Pay ",d," by card to place your order."]})}),e(ee,{stripe:u,options:{clientSecret:t.clientSecret,appearance:o},children:e(we,{payment:t,checkout:n,onPaid:m,onProcessing:h,onRenew:p,onBack:c})},t.clientSecret)]})]})})}function B(t){return new Date(t).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}const Ne=5;function we({payment:t,checkout:n,onPaid:i,onProcessing:m,onRenew:h,onBack:p}){const{formatMoney:c}=E(),x=ne(),d=re(),[u,o]=v(!1),[b,g]=v(null),k=j(!1);async function N(){try{return(await x.retrievePaymentIntent(t.clientSecret)).paymentIntent?.status}catch{return}}async function l(s){let a=s;for(let w=0;a==="processing"&&w<Ne;w+=1)await new Promise(P=>setTimeout(P,1e3)),a=await N()??a;if(a==="succeeded"){i();return}if(a==="processing"){m();return}g("Payment did not complete. Please try again."),o(!1)}async function y(){if(!x||!d||u)return;o(!0),g(null),k.current=!0;const s=await x.confirmPayment({elements:d,redirect:"if_required"}).catch(()=>null);if(!s){const a=await N();if(a==="succeeded"||a==="processing"){await l(a);return}g(a===void 0?q:"Payment failed. Please try again."),o(!1);return}if(s.error){if(!n.orderNumber&&s.error.code==="payment_intent_unexpected_state"){const a=await N();if(a==="succeeded"||a==="processing"){await l(a);return}if(a===void 0){g(q),o(!1);return}await h(a==="canceled"),o(!1);return}g(s.error.message??"Payment failed. Please try again."),o(!1);return}await l(s.paymentIntent?.status)}async function C(){if(u)return;if(!k.current){p();return}o(!0),g(null);const s=await N();if(s==="succeeded"||s==="processing"){await l(s);return}if(o(!1),s===void 0){g(q);return}p()}return r("div",{className:"flex flex-col gap-4",children:[e(te,{}),b&&e(_,{role:"alert",children:b}),e("button",{type:"button",onClick:y,disabled:!x||!d||u,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||!d||u?"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:u?r(f,{children:["Processing… ",e("span",{children:"·"})]}):r(f,{children:["Pay ",c(Number(t.amount),t.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})}),!n.orderNumber&&!u&&r("button",{type:"button",onClick:C,className:"inline-flex items-center gap-3 self-start font-mono text-[12px] uppercase tracking-[0.26em] text-fg-dim transition-colors hover:text-accent",children:["←",e("span",{children:"Back to checkout"})]})]})}const F="paypal-sdk-js";let I=null;function Pe(t,n){const i=`${t}|${n}`;if(I?.key===i)return I.promise;const m=new Promise((h,p)=>{document.getElementById(F)?.remove();const c=document.createElement("script");c.id=F;const x=new URLSearchParams({"client-id":t,currency:n,intent:"capture"});c.src=`https://www.paypal.com/sdk/js?${x}`,c.onload=()=>{const d=window.paypal;d?h(d):p(new Error("PayPal SDK loaded without its namespace"))},c.onerror=()=>p(new Error("PayPal SDK failed to load")),document.head.appendChild(c)});return I={key:i,promise:m},m}function ve({confirmation:t,clientId:n,idemKey:i,onPaid:m,onSkip:h}){const{formatMoney:p}=E(),c=j(null),[x,d]=v(!1),[u,o]=v(null),b=j(m);return b.current=m,O(()=>{let g=!1,k=null;return Pe(n,t.currency).then(N=>{if(!(g||!c.current))return k=N.Buttons({style:{layout:"vertical",color:"gold",shape:"rect",label:"paypal"},createOrder:async()=>(await T.createPaypalOrder({idempotencyKey:i})).paypalOrderId,onApprove:async l=>{try{if((await T.capturePaypalOrder({idempotencyKey:i,paypalOrderId:l.orderID})).status==="paid"){b.current();return}o("PayPal did not complete the payment. Please try again.")}catch(y){o(y instanceof L?y.message:"PayPal payment failed. Please try again.")}},onError:()=>{o("PayPal could not process the payment. Please try again.")}}),k.render(c.current).then(()=>{g||d(!0)})}).catch(()=>{g||o("PayPal could not be loaded. You can pay later — your order stands either way.")}),()=>{g=!0,k?.close?.()}},[n,t.currency,i]),e("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:r("div",{className:"w-full max-w-xl border border-line bg-bg",children:[r("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t.orderNumber}),e("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"PayPal"})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:[r("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:["Your order is placed. Pay"," ",e("span",{className:"text-fg",children:p(Number(t.grandTotal),t.currency)})," ","with PayPal to confirm it now."]}),!x&&!u&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading PayPal…"}),e("div",{ref:c}),u&&e(_,{role:"alert",children:u}),e("button",{type:"button",onClick: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 — our team will be in touch"})]})]})})}const $="square-web-sdk";let A=null;function Ce(t){const n=t==="sandbox"?"sandbox":"production";if(A?.key===n)return A.promise;const i=new Promise((m,h)=>{document.getElementById($)?.remove();const p=document.createElement("script");p.id=$,p.src=n==="sandbox"?"https://sandbox.web.squarecdn.com/v1/square.js":"https://web.squarecdn.com/v1/square.js",p.onload=()=>{const c=window.Square;c?m(c):h(new Error("Square SDK loaded without its namespace"))},p.onerror=()=>h(new Error("Square SDK failed to load")),document.head.appendChild(p)});return A={key:n,promise:i},i}function Se({confirmation:t,applicationId:n,locationId:i,environment:m,idemKey:h,onPaid:p,onSkip:c}){const{formatMoney:x}=E(),d=j(null),u=j(null),o=j(null),[b,g]=v(!1),[k,N]=v(!1),[l,y]=v(null);O(()=>{let s=!1,a=null;return Ce(m).then(async w=>{if(s||!d.current)return;const P=w.payments(n,i);o.current=P,a=await P.card(),await a.attach(d.current),u.current=a,s||g(!0)}).catch(()=>{s||y("Square could not be loaded. You can pay later — your order stands either way.")}),()=>{s=!0,a?.destroy?.()}},[n,i,m]);async function C(){const s=u.current;if(!(!s||k)){N(!0),y(null);try{const a=await s.tokenize();if(a.status!=="OK"||!a.token){y(a.errors?.[0]?.message??"Please check the card details and try again."),N(!1);return}let w;try{w=(await o.current?.verifyBuyer?.(a.token,{amount:String(t.grandTotal),currencyCode:t.currency,intent:"CHARGE"}))?.token}catch{}if((await T.chargeSquare({idempotencyKey:h,sourceId:a.token,...w?{verificationToken:w}:{}})).status==="paid"){p();return}y("Square did not complete the payment. Please try again.")}catch(a){y(a instanceof L?a.message:"Square payment failed. Please try again.")}N(!1)}}return e("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:r("div",{className:"w-full max-w-xl border border-line bg-bg",children:[r("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t.orderNumber}),e("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"Card"})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:[r("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:["Your order is placed. Pay"," ",e("span",{className:"text-fg",children:x(Number(t.grandTotal),t.currency)})," ","by card to confirm it now."]}),!b&&!l&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading card form…"}),e("div",{ref:d}),l&&e(_,{role:"alert",children:l}),e("button",{type:"button",onClick:C,disabled:!b||k,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",!b||k?"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:k?r(f,{children:["Processing… ",e("span",{children:"·"})]}):r(f,{children:["Pay ",x(Number(t.grandTotal),t.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})}),e("button",{type:"button",onClick:c,disabled:k,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 — our team will be in touch"})]})]})})}export{ye as PayFirstResultView,ge as default};
|
|
1
|
+
"use client";import{jsx as e,jsxs as r,Fragment as x}from"react/jsx-runtime";import R from"next/link";import{useEffect as D,useMemo as Y,useRef as j,useState as v}from"react";import{holdTime as X}from"../../lib/checkout/hold-time.js";import{stripeAppearance as J}from"../../lib/checkout/stripe-appearance.js";import{readerTimeZone as ee}from"../../lib/reader-zone.js";import{Elements as te,PaymentElement as re,useElements as ne,useStripe as ae}from"@stripe/react-stripe-js";import{loadStripe as ie}from"@stripe/stripe-js";import{useCurrency as E}from"../CurrencyContext.js";import{Notice as _}from"../Notice.js";import{resolveCopyright as oe}from"../../lib/content/site.js";import{ApiError as L,products as T}from"../../lib/api/index.js";import ce,{WORDMARK_FIT_FLOOR_PX as se}from"efficient-web-builder/render/components/Logo";import{NOT_CHECKED as q,orderReference as le}from"../../lib/checkout/pay-first.js";import{CheckoutStateProvider as de,useCheckout as me}from"./checkout-state.js";import{CheckoutContact as pe,CheckoutOrderSummary as ue,CheckoutPayment as fe,CheckoutShippingAddress as xe,CheckoutShippingMethod as ge,FormLock as M,LeaveLink as z}from"./checkout-parts.js";function he(t){return e(de,{...t,children:e(ke,{})})}function ye({order:t,paid:n}){const{formatMoney:i}=E();if(!t.grandTotal||!t.currency)return null;const m=c=>i(Number(c),t.currency),y=Number(t.freightCharge??0),p=Number(t.discountAmount??0);return r("dl",{className:"grid w-full max-w-sm grid-cols-[1fr_auto] gap-x-6 gap-y-1 border-y border-line py-3 text-left text-sm",children:[(t.shippingMethod||y>0)&&r(x,{children:[r("dt",{className:"text-fg-dim",children:["Delivery",t.shippingMethod?` · ${t.shippingMethod}`:""]}),e("dd",{className:"text-right font-mono",children:m(t.freightCharge??"0")})]}),p>0&&r(x,{children:[r("dt",{className:"text-fg-dim",children:["Discount",t.couponCode?` · ${t.couponCode}`:""]}),r("dd",{className:"text-right font-mono",children:["−",m(t.discountAmount??"0")]})]}),e("dt",{className:"text-fg",children:n?"Total paid":"Order total"}),e("dd",{className:"text-right font-mono text-fg",children:m(t.grandTotal)})]})}function be({result:t,lostChangeNote:n=null}){const i=e("span",{className:"font-mono text-fg",children:t.checkoutNumber});return r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:t.kind==="refunded"||t.kind==="expired"?"Order not placed":t.kind==="processing"?"Payment processing":"Payment received"}),e("p",{className:"text-fg-dim",children:t.kind==="refunded"?r(x,{children:["An item sold out or an offer ended while you paid for checkout ",i,". Your payment goes back to your card."]}):t.kind==="expired"?r(x,{children:["The hold on checkout ",i," ran out before your payment arrived. Your payment goes back to your card."]}):t.kind==="processing"?r(x,{children:["Your payment for checkout ",i," is being processed. When it goes through, we will email your order confirmation."]}):r(x,{children:["Thank you — your payment",t.checkoutNumber?r(x,{children:[" for checkout ",i]}):null," has gone through. We will email you the order number shortly."]})}),n&&t.kind!=="refunded"&&t.kind!=="expired"&&e("p",{className:"text-sm text-fg-dim",children:n}),e(R,{href:"/wheels",className:"mt-2 border-2 border-line px-6 py-3 font-mono text-[12px] uppercase tracking-[0.24em] hover:border-accent",children:"Continue browsing"})]})}function ke(){const{site:t,logo:n,items:i,placing:m,formLocked:y,email:p,me:c,addressSaveNote:g,lostChangeNote:d,idemKey:f,confirmation:o,setConfirmation:u,payment:h,paypalStep:k,squareStep:N,pendingConf:l,paid:b,setPaid:C,payNote:s,afterpayConfirming:a,gocardlessConfirming:w,zipConfirming:P,klarnaConfirming:O,cardConfirming:$,checkoutResult:A,confirmCardPayment:U,cardStillProcessing:W,renewCardPayment:H,holdRenewed:G,leaveCardPayment:Z,checkoutRootRef:Q,setCheckoutHeaderEl:V}=me();return o?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:b?"Payment received":"Order received"}),r("p",{className:"text-fg-dim",children:[b?r(x,{children:["Thank you — your payment for order"," ",e("span",{className:"font-mono text-fg",children:o.orderNumber})," has gone through."," "]}):r(x,{children:["Thank you — your order ",e("span",{className:"font-mono text-fg",children:o.orderNumber})," is being reviewed by our team."," "]}),c?r(x,{children:["Track it under"," ",e(R,{href:"/account/orders",className:"text-accent underline",children:"your orders"}),"."]}):e(x,{children:"We’ve emailed you a link to set a password and track it."})]}),e(ye,{order:o,paid:b}),d&&e("p",{className:"text-sm text-fg-dim",children:d}),s&&e("p",{className:"text-sm text-fg-dim",children:s}),g&&e("p",{className:"text-sm text-fg-dim",children:g}),!c&&r("p",{className:"text-sm text-fg-dim",children:["You can also"," ",e(R,{href:`/track?order=${encodeURIComponent(o.orderNumber)}`,className:"text-accent underline",children:"track this order"})," ","anytime with just your order number and email — no password needed."]}),e(R,{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"})]}):A?e(be,{result:A,lostChangeNote:d}):$?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Placing your order — one moment."})]}):a?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Afterpay — one moment."})]}):w?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Setting up your direct debit…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Confirming with GoCardless — one moment."})]}):P?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Zip — one moment."})]}):O?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Klarna — one moment."})]}):h&&l?e(Ne,{payment:h,checkout:l,holdRenewed:G,onPaid:U,onProcessing:W,onRenew:H,onBack:Z}):k&&l?e(Ce,{confirmation:l,clientId:t.paypalClientId??"",idemKey:f,onPaid:()=>{C(!0),u(l)},onSkip:()=>u(l)}):N&&l?e(je,{confirmation:l,applicationId:t.squareApplicationId??"",locationId:t.squareLocationId??"",environment:t.squareEnvironment??"production",idemKey:f,onPaid:()=>{C(!0),u(l)},onSkip:()=>u(l)}):r("div",{ref:Q,className:"bg-bg text-fg",children:[r("header",{ref:V,className:"sticky top-0 z-30 grid grid-cols-[1fr_auto_1fr] items-center gap-8 max-[640px]:grid-cols-[auto_minmax(0,1fr)_auto] max-[640px]:gap-3 border-b border-line px-[var(--sf-site-gutter,40px)] py-6 backdrop-blur-md max-[640px]:px-[min(20px,var(--sf-site-gutter,40px))] max-[640px]:py-4",style:{background:"color-mix(in oklab, var(--bg) 92%, transparent)"},children:[r(z,{href:"/",className:"inline-flex items-center gap-3 font-mono text-[14px] uppercase tracking-[0.26em] text-fg-dim transition-colors hover:text-accent",children:["←",e("span",{className:"max-[640px]:hidden",children:"Back to shop"})]}),e("div",{className:"flex min-w-0 justify-center max-[640px]:[container-type:inline-size]",children:e(z,{href:"/","aria-label":`${t.name} home`,className:"inline-flex max-w-full items-center justify-center overflow-x-clip",children:e(ce,{variant:"header",scrolled:!0,src:n?.url??null,reverse:n?.reverse??!1,reversedSrc:n?.reversed??null,inkIsDark:n?.inkIsDark??null,size:n?.size??"medium",sizePx:n?.sizePx??null,sizeUnit:n?.sizeUnit??null,siteName:t.name,fitWordmarkToContainer:!0,fitFloorPx:se})})}),t.cardPayments?r("span",{className:"flex items-center justify-end gap-3 font-mono text-[12px] uppercase tracking-[0.26em] text-fg-dim",children:[e("span",{className:"text-green",children:"●"}),e("span",{className:"max-[640px]:hidden",children:"Encrypted ·"})," Stripe"]}):e("span",{})]}),r("section",{className:"mx-auto flex max-w-[var(--sf-site-width,1600px)] flex-wrap items-center justify-between gap-x-8 gap-y-3 border-b border-line bg-surface px-[var(--sf-site-gutter,40px)] py-4 font-mono text-[13px] font-medium uppercase tracking-[0.24em] text-fg max-view-desktop:px-[min(24px,var(--sf-site-gutter,40px))]",children:[e("span",{className:"inline-flex items-center bg-accent px-3 py-1 font-bold text-bg",children:"Checkout"}),e("nav",{"aria-label":"Checkout steps",className:"flex flex-wrap items-center gap-5",children:[{n:"01",label:"Cart",state:"done"},{n:"02",label:"Ship & pay",state:"active"},{n:"03",label:"Confirmed",state:"pending"}].map(S=>r("span",{className:["relative flex items-center gap-2 transition-colors",S.state==="pending"?"text-fg-dim":"text-fg",S.state==="active"?"font-bold after:absolute after:inset-x-0 after:-bottom-1 after:h-[2px] after:bg-accent":""].join(" "),children:[e("span",{className:S.state==="done"?"text-accent font-bold":"",children:S.n}),e("span",{children:S.label})]},S.n))})]}),r("main",{className:"mx-auto grid max-w-[var(--sf-site-width,1600px)] grid-cols-[1fr_420px] items-start gap-16 px-[var(--sf-site-gutter,40px)] pt-10 pb-[100px] max-view-desktop:grid-cols-1 max-view-desktop:gap-10 max-view-desktop:px-[min(24px,var(--sf-site-gutter,40px))] max-view-desktop:pt-8 max-view-desktop:pb-20",children:[r("div",{children:[r(M,{locked:y,children:[e(pe,{}),e(xe,{}),e(ge,{})]}),e(M,{locked:m,children:e(fe,{})})]}),e(ue,{})]}),e("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:e("span",{children:oe({legalName:t.legalName,foundedYear:t.foundedYear,siteName:t.name})})})]})}function Ne({payment:t,checkout:n,holdRenewed:i,onPaid:m,onProcessing:y,onRenew:p,onBack:c}){const{formatMoney:g}=E(),d=e("span",{className:"text-fg",children:g(Number(t.amount),t.currency)}),f=Y(()=>ie(t.publishableKey),[t.publishableKey]),o=Y(()=>J(),[]),u=X(n.expiresAt??"",ee());return e("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:r("div",{className:"w-full max-w-xl border border-line bg-bg",children:[r("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:le(n)}),e("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"Payment"})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:[e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:n.orderNumber?r(x,{children:["Your order is placed. Pay ",d," by card to confirm it now."]}):i?r(x,{children:["Your hold ran out, so your items are held again",u?` until ${u}`:"",". Enter your card again, then pay ",d,"."]}):r(x,{children:["Your items are held",u?` until ${u}`:"",". Pay ",d," by card to place your order."]})}),e(te,{stripe:f,options:{clientSecret:t.clientSecret,appearance:o},children:e(Pe,{payment:t,checkout:n,onPaid:m,onProcessing:y,onRenew:p,onBack:c})},t.clientSecret)]})]})})}const we=5;function Pe({payment:t,checkout:n,onPaid:i,onProcessing:m,onRenew:y,onBack:p}){const{formatMoney:c}=E(),g=ae(),d=ne(),[f,o]=v(!1),[u,h]=v(null),k=j(!1);async function N(){try{return(await g.retrievePaymentIntent(t.clientSecret)).paymentIntent?.status}catch{return}}async function l(s){let a=s;for(let w=0;a==="processing"&&w<we;w+=1)await new Promise(P=>setTimeout(P,1e3)),a=await N()??a;if(a==="succeeded"){i();return}if(a==="processing"){m();return}h("Payment did not complete. Please try again."),o(!1)}async function b(){if(!g||!d||f)return;o(!0),h(null),k.current=!0;const s=await g.confirmPayment({elements:d,redirect:"if_required"}).catch(()=>null);if(!s){const a=await N();if(a==="succeeded"||a==="processing"){await l(a);return}h(a===void 0?q:"Payment failed. Please try again."),o(!1);return}if(s.error){if(!n.orderNumber&&s.error.code==="payment_intent_unexpected_state"){const a=await N();if(a==="succeeded"||a==="processing"){await l(a);return}if(a===void 0){h(q),o(!1);return}await y(a==="canceled"),o(!1);return}h(s.error.message??"Payment failed. Please try again."),o(!1);return}await l(s.paymentIntent?.status)}async function C(){if(f)return;if(!k.current){p();return}o(!0),h(null);const s=await N();if(s==="succeeded"||s==="processing"){await l(s);return}if(o(!1),s===void 0){h(q);return}p()}return r("div",{className:"flex flex-col gap-4",children:[e(re,{}),u&&e(_,{role:"alert",children:u}),e("button",{type:"button",onClick:b,disabled:!g||!d||f,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",!g||!d||f?"cursor-not-allowed border-line bg-surface text-fg-dim":"border-btn bg-btn text-btn-ink hover:border-fg hover:bg-fg"].join(" "),children:f?r(x,{children:["Processing… ",e("span",{children:"·"})]}):r(x,{children:["Pay ",c(Number(t.amount),t.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})}),!n.orderNumber&&!f&&r("button",{type:"button",onClick:C,className:"inline-flex items-center gap-3 self-start font-mono text-[12px] uppercase tracking-[0.26em] text-fg-dim transition-colors hover:text-accent",children:["←",e("span",{children:"Back to checkout"})]})]})}const B="paypal-sdk-js";let I=null;function ve(t,n){const i=`${t}|${n}`;if(I?.key===i)return I.promise;const m=new Promise((y,p)=>{document.getElementById(B)?.remove();const c=document.createElement("script");c.id=B;const g=new URLSearchParams({"client-id":t,currency:n,intent:"capture"});c.src=`https://www.paypal.com/sdk/js?${g}`,c.onload=()=>{const d=window.paypal;d?y(d):p(new Error("PayPal SDK loaded without its namespace"))},c.onerror=()=>p(new Error("PayPal SDK failed to load")),document.head.appendChild(c)});return I={key:i,promise:m},m}function Ce({confirmation:t,clientId:n,idemKey:i,onPaid:m,onSkip:y}){const{formatMoney:p}=E(),c=j(null),[g,d]=v(!1),[f,o]=v(null),u=j(m);return u.current=m,D(()=>{let h=!1,k=null;return ve(n,t.currency).then(N=>{if(!(h||!c.current))return k=N.Buttons({style:{layout:"vertical",color:"gold",shape:"rect",label:"paypal"},createOrder:async()=>(await T.createPaypalOrder({idempotencyKey:i})).paypalOrderId,onApprove:async l=>{try{if((await T.capturePaypalOrder({idempotencyKey:i,paypalOrderId:l.orderID})).status==="paid"){u.current();return}o("PayPal did not complete the payment. Please try again.")}catch(b){o(b instanceof L?b.message:"PayPal payment failed. Please try again.")}},onError:()=>{o("PayPal could not process the payment. Please try again.")}}),k.render(c.current).then(()=>{h||d(!0)})}).catch(()=>{h||o("PayPal could not be loaded. You can pay later — your order stands either way.")}),()=>{h=!0,k?.close?.()}},[n,t.currency,i]),e("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:r("div",{className:"w-full max-w-xl border border-line bg-bg",children:[r("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t.orderNumber}),e("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"PayPal"})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:[r("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:["Your order is placed. Pay"," ",e("span",{className:"text-fg",children:p(Number(t.grandTotal),t.currency)})," ","with PayPal to confirm it now."]}),!g&&!f&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading PayPal…"}),e("div",{ref:c}),f&&e(_,{role:"alert",children:f}),e("button",{type:"button",onClick:y,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 — our team will be in touch"})]})]})})}const F="square-web-sdk";let K=null;function Se(t){const n=t==="sandbox"?"sandbox":"production";if(K?.key===n)return K.promise;const i=new Promise((m,y)=>{document.getElementById(F)?.remove();const p=document.createElement("script");p.id=F,p.src=n==="sandbox"?"https://sandbox.web.squarecdn.com/v1/square.js":"https://web.squarecdn.com/v1/square.js",p.onload=()=>{const c=window.Square;c?m(c):y(new Error("Square SDK loaded without its namespace"))},p.onerror=()=>y(new Error("Square SDK failed to load")),document.head.appendChild(p)});return K={key:n,promise:i},i}function je({confirmation:t,applicationId:n,locationId:i,environment:m,idemKey:y,onPaid:p,onSkip:c}){const{formatMoney:g}=E(),d=j(null),f=j(null),o=j(null),[u,h]=v(!1),[k,N]=v(!1),[l,b]=v(null);D(()=>{let s=!1,a=null;return Se(m).then(async w=>{if(s||!d.current)return;const P=w.payments(n,i);o.current=P,a=await P.card(),await a.attach(d.current),f.current=a,s||h(!0)}).catch(()=>{s||b("Square could not be loaded. You can pay later — your order stands either way.")}),()=>{s=!0,a?.destroy?.()}},[n,i,m]);async function C(){const s=f.current;if(!(!s||k)){N(!0),b(null);try{const a=await s.tokenize();if(a.status!=="OK"||!a.token){b(a.errors?.[0]?.message??"Please check the card details and try again."),N(!1);return}let w;try{w=(await o.current?.verifyBuyer?.(a.token,{amount:String(t.grandTotal),currencyCode:t.currency,intent:"CHARGE"}))?.token}catch{}if((await T.chargeSquare({idempotencyKey:y,sourceId:a.token,...w?{verificationToken:w}:{}})).status==="paid"){p();return}b("Square did not complete the payment. Please try again.")}catch(a){b(a instanceof L?a.message:"Square payment failed. Please try again.")}N(!1)}}return e("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:r("div",{className:"w-full max-w-xl border border-line bg-bg",children:[r("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t.orderNumber}),e("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"Card"})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:[r("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:["Your order is placed. Pay"," ",e("span",{className:"text-fg",children:g(Number(t.grandTotal),t.currency)})," ","by card to confirm it now."]}),!u&&!l&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading card form…"}),e("div",{ref:d}),l&&e(_,{role:"alert",children:l}),e("button",{type:"button",onClick:C,disabled:!u||k,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",!u||k?"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:k?r(x,{children:["Processing… ",e("span",{children:"·"})]}):r(x,{children:["Pay ",g(Number(t.grandTotal),t.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})}),e("button",{type:"button",onClick:c,disabled:k,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 — our team will be in touch"})]})]})})}export{be as PayFirstResultView,he as default};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { type TyreSummary } from "../lib/api/index.js";
|
|
2
|
-
export
|
|
2
|
+
export type TyreThumbnail = Pick<TyreSummary, "coverImage" | "tyreTypes">;
|
|
3
|
+
export declare function useTyreCatalog(slugs: readonly string[]): ReadonlyMap<string, TyreThumbnail>;
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
"use client";import{useEffect as
|
|
1
|
+
"use client";import{useEffect as u,useState as f}from"react";import{products as l}from"../lib/api/index.js";const h=new Map,i=new Map;function p(e){const r=e.variants.map(t=>t.specs?.tireType).filter(t=>!!t);return{coverImage:e.coverImage,tyreTypes:[...new Set(r)]}}function m(e){const r=i.get(e);if(r)return r;const t=l.getTyre(e).then(p).catch(n=>{throw i.delete(e),n});return i.set(e,t),t}function d(e){const[r,t]=f(h),n=[...new Set(e)].sort().join(`
|
|
2
|
+
`);return u(()=>{if(!n)return;let s=!0;for(const o of n.split(`
|
|
3
|
+
`))m(o).then(c=>{s&&t(a=>a.get(o)===c?a:new Map(a).set(o,c))}).catch(c=>{s&&console.error("[useTyreCatalog] tyre read failed",o,c)});return()=>{s=!1}},[n]),r}export{d as useTyreCatalog};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare function formatAppointmentTime(value: string,
|
|
2
|
-
export declare function formatAppointment(value: string,
|
|
1
|
+
export declare function formatAppointmentTime(value: string, ...zones: string[]): string;
|
|
2
|
+
export declare function formatAppointment(value: string, ...zones: string[]): string;
|
|
3
3
|
export declare function startHasPassed(start: string, now: number): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{formatTime as m}from"efficient-shell/format";import{firstReadableZone as r,runtimeLocale as a}from"../zone.js";const u={weekday:"long",day:"numeric",month:"long",year:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"};function i(t){const e=new Date(t);return Number.isFinite(e.getTime())?e:null}function f(t,...e){const n=r(...e);return!n||!i(t)?"":m(t,{locale:a(),timeZone:n})}function p(t,...e){const n=r(...e),o=i(t);return!n||!o?"":new Intl.DateTimeFormat(void 0,{...u,timeZone:n}).format(o)}function l(t,e){const n=Date.parse(t);return Number.isFinite(n)&&n<=e}export{p as formatAppointment,f as formatAppointmentTime,l as startHasPassed};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function holdTime(expiresAt: string, zone: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{formatTime as r}from"efficient-shell/format";import{firstReadableZone as t,runtimeLocale as i}from"../zone.js";function f(e,m){const o=t(m);return!o||Number.isNaN(new Date(e).getTime())?"":r(e,{locale:i(),timeZone:o})}export{f as holdTime};
|
|
@@ -15,6 +15,7 @@ export declare function recordPictures(record: CurrentRecord | null | undefined,
|
|
|
15
15
|
export interface RecordFact {
|
|
16
16
|
label: string;
|
|
17
17
|
value: string;
|
|
18
|
+
at?: string;
|
|
18
19
|
}
|
|
19
20
|
export declare function recordFacts(record: CurrentRecord | null | undefined): RecordFact[];
|
|
20
21
|
export declare function editorPageDrawsOtherRecord(params: unknown): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as f}from"react/jsx-runtime";import{createContext as
|
|
1
|
+
"use client";import{jsx as f}from"react/jsx-runtime";import{createContext as h,useContext as p}from"react";import{formatDate as k,fromDateKey as A}from"efficient-shell/format";import{say as o}from"efficient-web-builder/format/lib/editor-words";import{declaredRecordType as C,PRODUCT_RECORD_TYPE as a}from"efficient-web-builder/format/lib/content/record-types";import{CurrentRecordProvider as D,useCurrentRecord as y,useCurrentRecordOf as b}from"efficient-web-builder/render/components/CurrentRecord";function O(e){const t=e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().toLowerCase();return t?t[0].toUpperCase()+t.slice(1):e}const P=/^\d{4}-\d{2}-\d{2}$/;function m(e){return e?e.schema?.length?e.schema.filter(t=>typeof t?.key=="string"&&Object.hasOwn(e.fields,t.key)):Object.entries(e.fields).flatMap(([t,r])=>{const n=Array.isArray(r)?g(r[0])?"rows":"images":typeof r=="string"?P.test(r)?"date":"text":null;return n?[{key:t,label:O(t),kind:n}]:[]}):[]}function M(e,{firstField:t=!1}={}){if(!e)return[];const r=m(e).filter(n=>n.kind==="images");return(t?r.slice(0,1):r).flatMap(n=>{const i=e.fields[n.key];return Array.isArray(i)?i.flatMap(s=>{const c=s?.url;if(typeof c!="string"||!c)return[];const u=s.alt,d=s.video;return[{url:c,alt:typeof u=="string"?u:"",...typeof d=="string"&&d?{video:d}:{}}]}):[]})}const T=/^\d{4}-\d{2}-\d{2}T/,v={locale:"en-GB",style:{day:"numeric",month:"long",year:"numeric"}},x=e=>T.test(e)&&!Number.isNaN(Date.parse(e));function R(e){return A(e)?k(e,v):x(e)?"":e}function g(e){const t=e;return typeof t?.label=="string"&&!!t.label.trim()&&typeof t.value=="string"&&!!t.value.trim()}function j(e){return e?m(e).flatMap(t=>{const r=e.fields[t.key];return t.kind==="rows"?Array.isArray(r)?r.filter(g).map(({label:n,value:i})=>({label:n,value:i})):[]:t.kind!=="text"&&t.kind!=="date"?[]:typeof r!="string"||!r.trim()?[]:t.kind==="date"&&x(r)?[{label:t.label,value:"",at:r}]:[{label:t.label,value:t.kind==="date"?R(r):r}]}):[]}function B(e){const t=e?.appState?.data?.root;return C(t?.props)!==a}const l=h(a);function F({type:e,children:t}){return f(l.Provider,{value:e,children:t})}function U(){return p(l)}function L(e){const t=y(),r=p(l);return t?t.type!==a:e&&r!==a}const W={type:"sample",key:"sample",get title(){return o("Record title")},get fields(){return{first:o("A detail of this record"),second:o("Another detail"),third:o("A third")}},value:void 0,get schema(){return[{key:"first",label:o("First detail"),kind:"text"},{key:"second",label:o("Second detail"),kind:"text"},{key:"third",label:o("Third detail"),kind:"text"}]}},Y=4;function $({record:e,children:t}){return f(D,{record:e,dateWords:R,children:t})}export{$ as CurrentRecordProvider,F as DeclaredRecordTypeProvider,Y as SAMPLE_PICTURE_COUNT,W as SAMPLE_RECORD,B as editorPageDrawsOtherRecord,j as recordFacts,m as recordFieldSpecs,M as recordPictures,y as useCurrentRecord,b as useCurrentRecordOf,U as useDeclaredRecordType,L as useDrawsOtherRecord};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function readerTimeZone(): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getUserTimezone as r}from"efficient-shell/format";import{firstReadableZone as t}from"./zone.js";function i(){const e=t(r()??"");if(e)return e;if(typeof window>"u")return"";try{return Intl.DateTimeFormat().resolvedOptions().timeZone??""}catch{return""}}export{i as readerTimeZone};
|
|
@@ -39,7 +39,7 @@ export declare function parseOpeningWeek(text: string | undefined): OpeningWeek
|
|
|
39
39
|
export declare function readOpeningRow(rows: readonly SourceRow[]): OpeningRow | null;
|
|
40
40
|
export declare function clockLabel(minute: number): string;
|
|
41
41
|
export declare const periodLabel: (period: OpeningPeriod) => string;
|
|
42
|
-
export declare function momentIn(zone: string, instant: number | Date): OpeningMoment;
|
|
42
|
+
export declare function momentIn(zone: string, instant: number | Date): OpeningMoment | null;
|
|
43
43
|
export declare function openingStatus(week: OpeningWeek, now: OpeningMoment): OpeningStatus;
|
|
44
44
|
export declare function badgeLabel(status: OpeningStatus): string;
|
|
45
45
|
export interface WeekLine {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
import{firstReadableZone as y}from"../zone.js";const l={days:["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],shortDays:["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],closed:"Closed",openNow:"Open now",until:"until",opens:"opens",today:"today",am:"am",pm:"pm"},a=1440,h=/^\s*(\d)\s*:\s*(\d{1,4})\s*-\s*(\d{1,4})\s*$/;function x(e){const n=Array.from({length:7},()=>[]);let o=!1;for(const r of(e??"").split(";")){const t=h.exec(r);if(!t)continue;const s=Number(t[1]),c=Number(t[2]),u=Number(t[3]);s>6||c>a-1||u<=c||u>2*a-1||u-c>a||(n[s].push({opens:c,closes:u}),o=!0)}if(!o)return null;for(const r of n)r.sort((t,s)=>t.opens-s.opens);return n}function w(e){const n=e[0];if(!n)return null;const o=x(n.week??"");return{week:o,zone:o?(n.zone??"").trim():"",hours:(n.hours??"").split(/\r?\n/).map(r=>r.trim()).filter(Boolean)}}function p(e){const n=(e%a+a)%a,o=Math.floor(n/60),r=n%60,t=o%12||12,s=o<12?l.am:l.pm;return r?`${t}:${String(r).padStart(2,"0")} ${s}`:`${t} ${s}`}const N=e=>`${p(e.opens)} – ${p(e.closes)}`,$={Mon:0,Tue:1,Wed:2,Thu:3,Fri:4,Sat:5,Sun:6};function S(e){const n=y(e);return n?new Intl.DateTimeFormat("en-US",{weekday:"short",hour:"2-digit",minute:"2-digit",hourCycle:"h23",timeZone:n}):null}function D(e,n){const o=S(e);if(!o)return null;const r=o.formatToParts(n),t=c=>r.find(u=>u.type===c)?.value??"",s=Number(t("hour"))%24;return{day:$[t("weekday")]??0,minute:s*60+Number(t("minute"))}}function g(e,n){const{day:o,minute:r}=n,t=e[o]??[],s=t.find(i=>i.opens<=r&&r<i.closes);if(s)return{open:!0,until:s.closes};const u=(e[(o+6)%7]??[]).find(i=>i.closes>a&&r+a<i.closes);if(u)return{open:!0,until:u.closes};const d=t.find(i=>i.opens>r);if(d)return{open:!1,next:{inDays:0,day:o,opens:d.opens}};for(let i=1;i<=7;i+=1){const f=(o+i)%7,m=e[f]?.[0];if(m)return{open:!1,next:{inDays:i,day:f,opens:m.opens}}}return{open:!1,next:null}}function b(e){const n=l;if(e.open)return`${n.openNow} · ${n.until} ${p(e.until)}`;if(!e.next)return n.closed;const o=e.next.inDays===0?n.today:n.shortDays[e.next.day];return`${n.closed} · ${n.opens} ${o} ${p(e.next.opens)}`}function T(e){return e.map((n,o)=>({day:o,name:l.days[o],periods:n.map(N).join(", "),closed:n.length===0}))}const M="0:600-1560;1:600-1560;2:600-1560;3:600-1560;4:600-1620;5:600-1620;6:600-1500",O={day:0,minute:1200};export{O as OPENING_SAMPLE_MOMENT,M as OPENING_SAMPLE_WEEK,l as OPENING_WORDS,b as badgeLabel,p as clockLabel,D as momentIn,g as openingStatus,x as parseOpeningWeek,N as periodLabel,w as readOpeningRow,T as weekLines};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const n=()=>new Intl.DateTimeFormat().resolvedOptions().locale;function o(...t){for(const e of t)if(e)try{return new Intl.DateTimeFormat("en-US",{timeZone:e}),e}catch{}return""}export{o as firstReadableZone,n as runtimeLocale};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "efficient-storefront-blocks",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.113.0",
|
|
4
4
|
"description": "The EFFICIENT storefront's website editor — the website builder assembled with the storefront's own sections — for an app that edits a storefront website inside its own page. Built from the efficient-storefront-blocks repository.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "Efficient Pty Ltd",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{P as xe,X as _t,Z as Rt,_ as Nt,aa as G,g as wt}from"./chunk-IY3JZXIQ.js";import{Ai as Et,Di as Xe,Ei as Pt,Je as Ct,hi as xt,ji as ze,ki as Ve,mi as St,zi as Ce}from"./chunk-7UBABYIY.js";import{c as vt,o as de}from"./chunk-37WWMI27.js";import{createContext as In,useContext as Ot,useEffect as Ln,useMemo as Se,useState as At}from"react";function It(e,t){return e.map(n=>({partNumber:n.partNumber,quantity:n.wheels*t}))}function fe(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 Ye=4,Vr=1,Xr={unit:"set",spares:0,spareSide:"left"};function Lt(e){return e.unit==="single"?1:Ye+e.spares}function Yr(e,t){return[{partNumber:e.partNumber,wheels:Lt(t),prices:e.prices}]}function Qr(e,t){let n=Lt(t)-Ye;if(n<=0||e.length===0)return e;let r=Rn(e),o=r?r[t.spareSide]:0;return e.map((i,a)=>a===o?{...i,wheels:i.wheels+n}:i)}function Rn(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 Nn(e,t){return t.spares>0?`${e} + spare`:e}function jr(e){return e.unit==="single"?"Single":Nn(`Set of ${Ye}`,e)}var Zr="data-add-to-basket",Qe=9,kn="en",kt=new Map;function Te(e,t,n){let r=`${e}|${t??""}|${n??""}`,o=kt.get(r);return o||(o=new Intl.NumberFormat(kn,{style:"currency",currency:e,...t===void 0?{}:{minimumFractionDigits:t},...n===void 0?{}:{maximumFractionDigits:n}}),kt.set(r,o)),o}function Y(e,t,n=0){return Te(t,0,n).format(e)}function Jr(e,t){return Te(t).format(e)}function eo(e,t){let n=e.savings[t];if(n===void 0)return null;let r=Y(n,t);return e.savingIsFrom?`Save from ${r}`:`Save ${r}`}import{jsx as Mn}from"react/jsx-runtime";var An="storefront-country",Tt=An,je=In(null);function Tn(e){return Mt(e,"catalogue")}function On(e){return Mt(e,"money")}function Mt(e,t){let n=new Map(e.map(r=>[r.code,r.decimalPlaces]));return(r,o)=>{if(!o)return"";let i=n.get(o)??0;return Te(o,t==="money"?i:0,i).format(r)}}function io({children:e,currencies:t,countries:n,defaultCurrency:r,defaultCountry:o}){let i=Se(()=>t??[],[t]),a=Se(()=>n??[],[n]),l=Se(()=>r||i.find(m=>m.isDefault)?.code||i[0]?.code||"",[r,i]),c=Se(()=>o||a.find(m=>m.isDefault)?.code||a[0]?.code||"",[o,a]),[u,g]=At(c),[x,d]=At(!1);Ln(()=>{let m=de.getItem(Tt);m&&a.some(L=>L.code===m)&&g(m),d(!0)},[a]);function P(m){g(m),de.setItem(Tt,m)}let k=Se(()=>{let m=a.find(y=>y.code===u)??null,L=m?.currency,I=L&&i.some(y=>y.code===L)?L:l,A=Tn(i),_=On(i);return{country:u,currency:I,setCountry:P,currencies:i,countries:a,activeCountry:m,formatPrice:(y,U)=>A(y,U??I),formatMoney:(y,U)=>_(y,U??I),ready:x}},[u,i,a,l,x]);return Mn(je.Provider,{value:k,children:e})}function Dt(e){let t=Ot(je);if(!t&&!e?.optional)throw new Error("useCurrency must be used within a CurrencyProvider");return t}function ao(){return Ot(je)?.country??""}import{createContext as Yn,useCallback as E,useContext as Qn,useEffect as z,useMemo as jt,useRef as Q,useState as w}from"react";function Ft(){return"/edit"}function $t(e,t){return e.valid?!1:e.reason==="firstOrderOnly"?!0:e.reason==="notEligible"&&!t}var Ht="We'll confirm this discount when you place your order.",fo="Confirmed at checkout";function po(e){return e&&(e.valid||e.deferred)?e.code:void 0}var Ut="coupon_code: ";function mo(e){return!(e instanceof xe)||e.status!==400||!e.message.startsWith(Ut)?null:e.message.slice(Ut.length)}function Bt(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 Oe="Price on request",Fn="Request a quote",qt="from ",bo="From ",Co="each",Wt="Free",xo="\u2026",So="Updating";function Ze(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Je(e,t){let n=e?.[t];return Ze(n)?n:null}function vo(e,t,n,r){let o=Je(e,n),i=Je(t,n);return o===null&&i===null?0:o===null?1:i===null?-1:r==="asc"?o-i:i-o}function Eo(e,t,n,r){if(n==null&&r==null)return!0;let o=Je(e,t);return!(o===null||n!=null&&o<n||r!=null&&o>r)}var Un={priced:!1,unit:null,was:null,onSale:!1,setTotal:null};function $n(e,t,n){if(!Ze(e))return Un;let r=Ze(t)&&t>e?t:null;return{priced:!0,unit:e,was:r,onSale:r!==null,setTotal:n!=null?e*n:null}}function Po(e,t,n=""){return!e.priced||e.unit==null?Oe:`${n}${Y(e.unit,t)}`}function wo(e,t){return e.was==null?null:Y(e.was,t)}function Hn(e,t,n=1){let r=fe(e,t);if(r===null)return{priced:!1,unit:null,isFrom:!1,setTotal:null};let o=e.reduce((a,l)=>a+l.wheels,0),i=Math.min(...e.map(a=>a.prices[t]));return{priced:!0,unit:i,isFrom:i*o!==r,setTotal:r*n}}var Bn={priced:!1,unit:null,isFrom:!1,was:null,onSale:!1,setTotal:null};function _o(e,t,n,r=1){let o=$n(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=Hn(t.components,n,r);return a.priced?{priced:!0,unit:a.unit,isFrom:a.isFrom,was:null,onSale:!1,setTotal:a.setTotal,fromSetTotal:i}:{...Bn,fromSetTotal:i}}function qn(e,t){return!e.priced||e.unit==null?Oe:`${e.isFrom?qt:""}${Y(e.unit,t)}`}function Ro(e,t){return e.was==null?null:Y(e.was,t)}function No(e,t){return!e.priced||e.unit==null?Fn:qn(e,t)}function ko(e,t){let n=e.savings[t];if(n===void 0||e.components.length===0)return null;let r=0;for(let i of e.components){let a=i.prices?.[t];if(typeof a!="number")return null;r+=a*i.quantity}let o=Y(r-n,t);return{was:Y(r,t),amount:e.savingIsFrom?`${qt}${o}`:o}}var Wn=/^[^@\s]+@[^@\s]+\.[^@\s]+$/;function Gt(e){return Wn.test(e.trim())}var Kt="sf:ga-purchases",Gn=20;function Vt(){return typeof window>"u"||window.parent!==window}function ve(...e){try{if(Vt()||typeof window.gtag!="function")return;window.gtag(...e)}catch{}}function Kn(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:fe(e.components,t)??0,quantity:e.qty}}function et(e,t){return e.filter(Me).map(n=>Kn(n,t))}function Mo(e){ve("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=et([e],t);n.length!==0&&ve("event","add_to_cart",{currency:t,value:n[0].price*n[0].quantity,items:n})}function Do(e){let t=et(e.lines,e.currency);t.length!==0&&ve("event","begin_checkout",{currency:e.currency,value:e.value,...e.coupon?{coupon:e.coupon}:{},items:t})}var zt=new Set;function zn(e){if(zt.has(e))return!1;zt.add(e);try{let t=JSON.parse(de.getItem(Kt)??"[]");if(t.includes(e))return!1;de.setItem(Kt,JSON.stringify([...t,e].slice(-Gn)))}catch{}return!0}function Fo(e){let t=e.confirmation;if(Vt()||!zn(t.orderNumber))return;let n=t.currency,r=Number(t.grandTotal);ve("event","purchase",{transaction_id:t.orderNumber,currency:n,value:r,shipping:Number(t.freightCharge),...t.couponCode?{coupon:t.couponCode}:{},items:et(e.lines,n)}),e.adsSendTo&&ve("event","conversion",{send_to:e.adsSendTo,transaction_id:t.orderNumber,currency:n,value:r})}var Vn="Arranged after review",Yt="Calculated at checkout",Xn=Yt,Ho=Yt;function Qt({quoted:e,optionCount:t,chosenAmount:n,couponWaivesFreight:r}){return e&&t===0?"arranged":r?"free":n===void 0?"pending":n===0?"free":"charged"}function Bo(e){switch(e){case"arranged":return Vn;case"pending":return Xn;case"free":return Wt;case"charged":return null}}import{jsx as er}from"react/jsx-runtime";var jn=400,Zn=400,Jn=1500;function Me(e){return(e.components?.length??0)>0}function Zt(e,t){return{code:e,valid:t.valid,deferred:$t(t,t.askedAsShopper),message:t.message||void 0,effects:t.effects??void 0}}function en(e,t){return fe(e.components,t)}function tt(e,t){let n=en(e,t);return n===null?null:n*e.qty}function Jt(e){return e!=="tyre"}var tn=Yn(null);function ei({children:e,preview:t=!1}){let{currency:n,country:r,formatMoney:o}=Dt(),[i,a]=w(t),[l,c]=w([]),[u,g]=w([]),[x,d]=w([]),[P,k]=w(!1),m=Q(new Set),[L,I]=w([]),[A,_]=w(!1),[y,U]=w(null),[V,J]=w(null),[T,b]=w(null),[R,C]=w(0),ee=E(()=>C(s=>s+1),[]),[pe,me]=w(void 0),[K,qe]=w(null),[v,O]=w(null),[ge,ie]=w(!1),[M,he]=w(null),te=Q(void 0),H=E(()=>a(!0),[]),ae=E(()=>a(!1),[]),X=E(()=>a(s=>!s),[]);z(()=>{t||typeof window>"u"||new URLSearchParams(window.location.search).get("cart")==="open"&&H()},[H,t]);let $=Ft(),Re=Q($);z(()=>{Re.current!==$&&(Re.current=$,t||ae())},[$,t,ae]);let F=E(s=>{qe(p=>p?.country===s?.country&&p?.subdivision===s?.subdivision&&p?.postcode===s?.postcode?p:s)},[]),Ne=E((s,p)=>{_(!0),!(!p||!Jt(s))&&I(f=>f.includes(p)?f:[...f,p])},[]),se=A||l.length>0,le=Q(!0);z(()=>(le.current=!0,()=>{le.current=!1}),[]),z(()=>{if(t)return;let s=[...L,...l.filter(f=>Jt(f.kind)).map(f=>f.slug)],p=[...new Set(s)].filter(f=>f&&!m.current.has(f));if(p.length!==0){for(let f of p)m.current.add(f);G.listWheelsBySlug(p).then(f=>{if(!le.current||f.length===0)return;let h=new Set(f.map(S=>S.slug));g(S=>[...S.filter(re=>!h.has(re.slug)),...f])})}},[t,L,l]),z(()=>{if(t||!se||P)return;let s=!0;return G.listBundles().then(p=>{s&&(d(p),k(!0))}),()=>{s=!1}},[t,se,P]);let B=y?.deliveryOptions??[],ye=y?.courier??null;z(()=>{y&&he(s=>s&&B.some(p=>p.id===s)?s:B[0]?.id??null)},[y]);let ne=E(()=>l.filter(Me).flatMap(s=>It(s.components,s.qty)),[l]),ue=E(async(s,p)=>{let f=s.trim().toUpperCase();if(!f)return;let h=ne();if(h.length===0){O({code:f,valid:!1,message:"Add a wheel to the cart first."});return}ie(!0),te.current=p;try{let S=await G.validateCoupon({code:f,items:h,currency:n,shippingMethodId:M??void 0,customerEmail:p});O(Zt(f,S))}catch{O({code:f,valid:!1,unchecked:!0,message:"Could not check that code. Please try again."})}finally{ie(!1)}},[ne,n,M]),ke=E(()=>{O(null),te.current=void 0},[]),Ie=E(s=>{if(!v)return;let{code:p}=v;O(f=>f&&f.code===p?{code:p,valid:!1,refused:!0,message:s}:f)},[v]);z(()=>{if(!v||v.refused)return;let s=v.code,p=h=>h!==null&&h.code===s&&!h.refused,f=setTimeout(async()=>{let h=ne();if(h.length===0){O(S=>p(S)?{code:s,valid:!1,message:"Add a wheel to the cart first."}:S);return}ie(!0);try{let S=await G.validateCoupon({code:s,items:h,currency:n,shippingMethodId:M??void 0,customerEmail:te.current});O(re=>p(re)?Zt(s,S):re)}catch{}finally{ie(!1)}},jn);return()=>clearTimeout(f)},[l,n,M]);let N=v&&!v.refused?v.code:void 0;z(()=>{if(t)return;let s=!0,p=l,f=setTimeout(async()=>{let h=ne();if(h.length===0){U(null),J(null),me(void 0);return}try{let S=await G.quoteCart({items:h,currency:n,shippingMethodId:M??void 0,couponCode:N,customerEmail:te.current||void 0,country:K?.country||r||void 0,subdivision:K?.country&&K.subdivision||void 0,postcode:K?.country&&K.postcode||void 0});if(!s)return;U(S),J(p),b(null)}catch{if(!s)return;b(p)}me(N)},Zn);return()=>{s=!1,clearTimeout(f)}},[l,n,M,N,r,K,R]);let q=E(s=>{c(p=>{let f=p.findIndex(h=>h.id===s.id);return f===-1?[...p,s]:p.map((h,S)=>S===f?{...h,qty:Math.min(Qe,h.qty+s.qty)}:h)}),Xt(s,n)},[n]),Le=E(s=>{c(p=>p.filter(f=>f.id!==s))},[]),lt=E((s,p)=>{let f=Math.max(1,Math.min(Qe,p));c(h=>h.map(S=>S.id===s?{...S,qty:f}:S))},[]),ut=E(s=>{c(s)},[]),[be,xn]=w(null),ct=Q(null);ct.current=be;let W=Q(null),We=Q(""),dt=E((s,p)=>{let f=s.trim().toLowerCase();Gt(f)&&xn(h=>h&&h.email===f&&h.firstName===(p??"")?h:{email:f,firstName:p??""})},[]);z(()=>{if(t||!be)return;let s=Bt(l.filter(Me),h=>tt(h,n)===null?Oe:o(tt(h,n),n)),p={email:be.email,firstName:be.firstName,currency:n,items:s},f=JSON.stringify(p);if(f!==We.current)return W.current&&clearTimeout(W.current),W.current=setTimeout(()=>{W.current=null,We.current=f,G.captureCart(p).catch(h=>{})},Jn),()=>{W.current&&(clearTimeout(W.current),W.current=null)}},[l,be,n,t]);let ft=E(()=>{W.current&&(clearTimeout(W.current),W.current=null);let s=ct.current;s&&(We.current="",G.captureCart({email:s.email,firstName:s.firstName,currency:n,items:[]}).catch(p=>{}))},[n]),pt=jt(()=>{let s=l.reduce((D,ce)=>{let Ae=tt(ce,n);return Ae===null?D:D+Ae},0),p=l.some(D=>en(D,n)===null),f=l.reduce((D,ce)=>D+ce.qty,0),h=v?.valid?v.effects:void 0,S=h?Math.min(s,Number(h.discountAmount)):0,re=y?.bundleDiscount??0,vn=y?.appliedBundles??[],Ge=!!h?.freeShipping,yt=B.find(D=>D.id===M),bt=Ge?0:y?.shipping??yt?.amount??0,En=Qt({quoted:y!==null,optionCount:B.length,chosenAmount:yt?.amount,couponWaivesFreight:Ge}),Ke={};for(let D of h?.freeUnits??[])Ke[D.partNumber]=(Ke[D.partNumber]??0)+D.quantity;let Pn=y?.tax??null,wn=y?y.grandTotal:s-S-re+bt;return{sets:f,units:l.reduce((D,ce)=>D+(ce.components??[]).reduce((Ae,_n)=>Ae+_n.wheels*ce.qty,0),0),subtotal:s,hasUnpricedLine:p,discount:S,bundleDiscount:re,appliedBundles:vn,shipping:bt,freeShipping:Ge,shippingStatus:En,freeUnitsByPartNumber:Ke,tax:Pn,grand:wn,repricing:!!v?.refused&&y!==null&&pe===v?.code,quoted:y!==null&&V===l,serverSubtotal:y?.subtotal??null,quoteFailed:T===l,currency:n}},[l,n,v,B,M,y,pe,V,T]),mt=Q(!0),gt=E(s=>{mt.current=s},[]),ht=E(s=>{q(s),mt.current&&H()},[q,H]),Sn=jt(()=>({isOpen:i,preview:t,open:H,close:ae,toggle:X,items:l,catalog:u,bundles:x,warmCatalog:Ne,add:q,addAndOpen:ht,setAutoOpen:gt,remove:Le,setQty:lt,replaceItems:ut,identify:dt,clearCapturedCart:ft,coupon:v,applyCoupon:ue,removeCoupon:ke,refuseCoupon:Ie,couponBusy:ge,deliveryOptions:B,setQuoteDestination:F,courier:ye,requote:ee,shippingMethodId:M,setShippingMethodId:he,totals:pt}),[i,t,H,ae,X,l,u,x,Ne,q,ht,gt,Le,lt,ut,dt,ft,v,ue,ke,Ie,ge,B,F,ye,ee,M,pt]);return er(tn.Provider,{value:Sn,children:e})}function nn(){let e=Qn(tn);if(!e)throw new Error("useCart() must be called inside <CartProvider>. Mount the provider in app/layout.tsx.");return e}import{cache as cr}from"react";function rn(e){return/(?:^|\|)(?:slug|xhost):/.test(e)}function on(e,t,n,r){for(;e.size>=t;){let o,i;for(let[l,c]of e){if(c.expiresAt<=r){o=l;break}i===void 0&&n(l)&&(i=l)}let a=o??i??e.keys().next().value;if(a===void 0)return;e.delete(a)}}var tr=6e4,nr=5e3,rr=500,De=new Map;async function or(e){let{host:t,matchesRequestHost:n}=await _t();if(!t)return"";let r=await Rt();return r?`${e}|slug:${encodeURIComponent(t)}/${encodeURIComponent(r)}`:n?`${e}|host:${t}`:`${e}|xhost:${t}`}async function an(e,t){if(await Nt()!==null)return t();let n=await or(e);if(!n)return t();let r=Date.now(),o=De.get(n);if(o&&o.expiresAt>r)return o.load;let i=await t(),a=i.outcome.state==="failed",l=a?nr:tr,c=De.get(n)?.lastGood,u=i.outcome.state==="ok"?i:a?c:void 0,g=a&&u?u:i;return on(De,rr,rn,r),De.set(n,{load:g,expiresAt:r+l,lastGood:u}),g}var ir=404;function ar(e){if(e instanceof xe&&e.status===ir)return{state:"absent"};let t=e instanceof xe?e.status:-1,n=e instanceof Error?e.message:String(e);return{state:"failed",status:t,detail:n}}var sr="[storefront:chrome-load-failed]";function lr(e,t){console.error(`${sr} ${e} status=${t.status} \u2014 serving fallback chrome`,t.detail)}async function sn(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=ar(o);return i.state==="failed"&&lr(e,i),{value:n,outcome:i}}}function ur(e){return e==="production"?"silent":"banner"}var li=ur("production");function dr(e,t){return e?.trim()||t}function hi({legalName:e,foundedYear:t,siteName:n},r=new Date().getFullYear()){let o=dr(e,n);return`\xA9 ${t&&t<r?`${t}\u2013${r}`:`${r}`} ${o}`}var fr={name:Ce,legalName:null,foundedYear:null,faviconUrl:null,currencies:[],defaultCurrency:null,countries:[],defaultCountry:null,commerceEnabled:!0,cardPayments:!1,paymentMethods:[],paypalClientId:null,paypalEnvironment:null,squareApplicationId:null,squareLocationId:null,squareEnvironment:null,ga4MeasurementId:null,googleAdsId:null,googleAdsConversionLabel:null,metaPixelId:null,consentEnabled:!1,consentPrivacyPage:null,consentNoticeOptOut:!1,privacyPage:null,termsPage:null,footerCookieSettings:!0,footerSitemap:!0,socialLinks:Xe},yi=cr(async()=>an("site",()=>sn("site",async()=>{let e=await G.getSite();return{name:Et(e.name),legalName:e.legalName?.trim()||null,foundedYear:e.foundedYear??null,faviconUrl:e.faviconUrl??null,currencies:e.currencies??[],defaultCurrency:e.defaultCurrency??null,countries:e.countries??[],defaultCountry:e.defaultCountry??null,commerceEnabled:e.commerceEnabled??!0,cardPayments:e.cardPayments??!1,paymentMethods:e.paymentMethods??(e.cardPayments?["card"]:[]),paypalClientId:e.paypalClientId??null,paypalEnvironment:e.paypalEnvironment??null,squareApplicationId:e.squareApplicationId??null,squareLocationId:e.squareLocationId??null,squareEnvironment:e.squareEnvironment??null,ga4MeasurementId:e.ga4MeasurementId??null,googleAdsId:e.googleAdsId??null,googleAdsConversionLabel:(e.googleAdsId?e.googleAdsConversionLabel:null)??null,metaPixelId:e.metaPixelId??null,consentEnabled:e.consentEnabled??!1,consentPrivacyPage:e.consentPrivacyPage??null,consentNoticeOptOut:e.consentNoticeOptOut??!1,privacyPage:e.privacyPage??null,termsPage:e.termsPage??null,footerCookieSettings:e.footerCookieSettings??!0,footerSitemap:e.footerSitemap??!0,socialLinks:Pt(e.socialLinks)}},fr)));var bi={name:Ce,legalName:null,foundedYear:null,faviconUrl:null,currencies:[{code:"USD",symbol:"$",decimalPlaces:2,isDefault:!0}],defaultCurrency:"USD",countries:[{code:"US",name:"United States",currency:"USD",url:"",isDefault:!0,chargeTax:!1,taxDisplay:"none",taxName:"",taxRate:null,postalLabel:"Zip Code"}],defaultCountry:"US",commerceEnabled:!0,cardPayments:!0,paymentMethods:["card"],paypalClientId:null,paypalEnvironment:null,squareApplicationId:null,squareLocationId:null,squareEnvironment:null,ga4MeasurementId:null,googleAdsId:null,googleAdsConversionLabel:null,metaPixelId:null,consentEnabled:!1,consentPrivacyPage:null,consentNoticeOptOut:!1,privacyPage:null,termsPage:null,footerCookieSettings:!0,footerSitemap:!0,socialLinks:Xe};import{jsx as pr}from"react/jsx-runtime";function xi({tone:e="bad",role:t,children:n}){return pr("div",{role:t,className:["border bg-surface px-4 py-3 text-[14px] leading-relaxed text-fg",e==="good"?"border-accent":e==="bad"?"border-alert":"border-line"].join(" "),children:n})}import{jsx as Pe,jsxs as nt}from"react/jsx-runtime";import{useEffect as Fe,useId as yr,useRef as un,useState as Ue}from"react";import{useRootIsDark as br}from"efficient-shell/theme";import{efficientClientOpen as mr}from"efficient-easel/screen/lib/session";var Ee=new Map,gr=64;async function hr(e){if(!mr())return null;try{let t=await fetch(`${vt()}/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 ln(e){let t=Ee.get(e);if(t)return t;let n=hr(e);if(Ee.set(e,n),Ee.size>gr){let r=Ee.keys().next();r.done||Ee.delete(r.value)}return n}var Cr=202/22,xr=.88,$i=16,Sr="invert(1)";function Hi({variant:e="header",scrolled:t=!0,src:n,reverse:r=!1,color:o=null,onLightSurface:i,reversedSrc:a,inkIsDark:l,size:c="medium",sizePx:u,sizeUnit:g,wordmark:x,siteName:d=Ce,fitToContainer:P=!1,fitWordmarkToContainer:k=!1,fitFloorPx:m,hideClass:L,hideAttrs:I}){let A=x&&x.trim()?x.trim():d,[_,y]=Ue(null),U=un(null),V=N=>{U.current=N};Fe(()=>{y(U.current?.ownerDocument??null)},[]);let J=!br({doc:_,whenUnset:!0}),T=n&&n.trim()?n.trim():null,b=!!T&&wt(T),R=i??(J&&t),C=o&&o.trim()?o.trim():null,ee=r&&!C,pe=`logo-color-${yr().replace(/[^A-Za-z0-9_-]/g,"")}`,me=ee&&b&&T&&a!=null?{reversed:a,inkIsDark:l??null}:null,K=me!==null,[qe,v]=Ue(null);Fe(()=>{if(!ee||!T||!b||K){v(null);return}let N=!1;return v(null),ln(T).then(q=>{N||v(q)}),()=>{N=!0}},[ee,T,b,K]);let O=me??qe,ge=!!O&&O.inkIsDark!==null&&(R?!O.inkIsDark:O.inkIsDark),ie=ee&&!!T&&!b&&!R,M=ge&&O?O.reversed:T,he=M?[M]:[],[te,H]=Ue(0);Fe(()=>{H(0)},[T,ge]);let ae=e==="footer"?Ve:ze[c],X=u&&u>0?u:ae,$=(u&&u>0?Ct(u,g,"size",St):null)??`${X}px`,Re=Math.round(X*Cr),F=te<he.length?he[te]:null,[Ne,se]=Ue(M),le=F!==null&&F===Ne,B=un(null);Fe(()=>{let N=B.current;if(!N||!N.complete)return;if(N.naturalWidth>0||N.naturalHeight>0){se(F);return}let q=!1;return N.decode().then(()=>!q&&se(F),()=>!q&&H(Le=>Le+1)),()=>{q=!0}},[F]);let ye=P||k,ne=`calc(100cqi / ${((A.length+1)*xr).toFixed(2)})`,ue=ye&&m&&m>0?$===`${X}px`?`${Math.min(m,X)}px`:`min(${m}px, ${$})`:null,ke=ye?ue===null?`min(${$}, ${ne})`:`clamp(${ue}, ${ne}, ${$})`:$,Ie=nt("span",{className:`font-display font-bold tracking-[0.18em] ${ue===null?"whitespace-nowrap":"whitespace-normal"}`,style:{fontSize:ke,lineHeight:1,...C?{color:C}:{}},"aria-label":A,children:[A,Pe("span",{className:"text-accent",style:C?{color:C}:void 0,children:"."})]});return nt("span",{ref:V,className:xt("inline-flex items-center",L??""),...I,children:[!le&&Ie,C&&F&&Pe("svg",{"aria-hidden":"true",focusable:"false",width:"0",height:"0",style:{position:"absolute"},children:nt("filter",{id:pe,colorInterpolationFilters:"sRGB",children:[Pe("feFlood",{style:{floodColor:C}}),Pe("feComposite",{in2:"SourceAlpha",operator:"in"})]})}),F&&Pe("img",{ref:B,src:F,alt:A,width:Re,height:X,className:"shrink-0 object-contain",style:{...le?{height:$,width:"auto",...P?{maxWidth:"100cqi"}:{}}:{display:"none"},...ie?{filter:Sr}:{},...C?{filter:`url(#${pe})`}:{}},onLoad:()=>se(F),onError:()=>H(N=>N+1)},F)]})}var qi="w-full border-2 border-line bg-bg px-4 py-4 font-display text-[17px] tracking-[-0.005em] text-fg outline-none transition-colors placeholder:text-fg-dim hover:border-fg-dim focus:border-accent",cn="w-0 min-w-0 flex-1",Wi="w-0 min-w-[7rem] flex-1";import{jsx as we,jsxs as Er}from"react/jsx-runtime";function vr({spokes:e,mesh:t=!1,className:n}){let a=c=>Math.round(c*1e3)/1e3,l=[];for(let c=0;c<e;c++){let u=c/e*Math.PI*2-Math.PI/2;if(l.push({x1:a(100+Math.cos(u)*22),y1:a(100+Math.sin(u)*22),x2:a(100+Math.cos(u)*86),y2:a(100+Math.sin(u)*86),main:!0}),t){let g=u+Math.PI/e;l.push({x1:a(100+Math.cos(g)*22*1.4),y1:a(100+Math.sin(g)*22*1.4),x2:a(100+Math.cos(g)*78),y2:a(100+Math.sin(g)*78),main:!1})}}return Er("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:[we("circle",{cx:100,cy:100,r:92,strokeWidth:2}),we("circle",{cx:100,cy:100,r:84,strokeWidth:1,opacity:.4}),we("circle",{cx:100,cy:100,r:22,strokeWidth:2}),we("circle",{cx:100,cy:100,r:6,fill:"currentColor"}),l.map((c,u)=>we("line",{x1:c.x1,y1:c.y1,x2:c.x2,y2:c.y2,stroke:"currentColor",strokeWidth:c.main?6:3,strokeLinecap:"round",opacity:c.main?1:.5},u))]})}var Vi="#c9a461",dn=[{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"}],Xi={name:"",color:"var(--fg)",family:"silver",src:""};function Pr(e,t){let n=r=>{let o=dn.findIndex(i=>i.f===r);return o===-1?dn.length:o};return n(e)-n(t)||e.localeCompare(t)}function Yi(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(Pr)}import{useState as wr}from"react";import{jsx as oe,jsxs as rt}from"react/jsx-runtime";function _r({customerEmail:e,disabled:t=!1}){let{coupon:n,applyCoupon:r,removeCoupon:o,couponBusy:i}=nn(),[a,l]=wr("");async function c(){t||i||!a.trim()||(await r(a,e),l(""))}return rt("div",{className:"flex flex-col gap-2",children:[n===null?rt("div",{className:"flex border border-line",children:[oe("input",{type:"text",value:a,onChange:u=>l(u.target.value),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),c())},placeholder:"Coupon code","aria-label":"Coupon code",disabled:t,className:`${cn} bg-transparent px-4 py-4 font-mono text-[11px] uppercase tracking-[0.18em] text-fg outline-none placeholder:text-fg-dim`}),oe("button",{type:"button",onClick:()=>{c()},disabled:i||t,className:"border-l border-line px-4 font-mono text-[10px] uppercase tracking-[0.26em] text-btn transition-colors hover:bg-btn hover:text-btn-ink disabled:cursor-wait disabled:opacity-60",children:i?"\u2026":"Apply"})]}):rt("div",{className:["flex items-center justify-between gap-3 border px-4 py-3",n.valid?"border-accent":"border-line"].join(" "),style:n.valid?{background:"color-mix(in oklab, var(--accent) 8%, transparent)"}:void 0,children:[oe("span",{className:["font-mono text-[11px] uppercase tracking-[0.22em]",n.valid?"text-accent":n.deferred||n.unchecked?"text-fg":"text-fg-dim line-through"].join(" "),children:n.code}),n.unchecked&&oe("button",{type:"button",onClick:()=>{r(n.code,e)},disabled:i||t,className:"ml-auto font-mono text-[10px] uppercase tracking-[0.26em] text-btn transition-colors hover:text-fg disabled:cursor-wait disabled:opacity-60",children:i?"\u2026":"Try again"}),!t&&oe("button",{type:"button",onClick:o,"aria-label":`Remove coupon ${n.code}`,className:"font-mono text-[12px] text-fg-dim transition-colors hover:text-fg",children:"\u2715"})]}),n?.deferred?oe("p",{className:"font-mono text-[10px] uppercase tracking-[0.18em] text-fg-dim",children:Ht}):n&&!n.valid&&n.message&&oe("p",{className:"font-mono text-[10px] uppercase tracking-[0.18em] text-alert",children:n.message})]})}var ot="Ads on. Shopper can opt out.",$e="Ads and analytics off until Accept",Rr={us:{region:"us",name:"United States",model:"opt-out",law:"California CCPA / CPRA, other state laws",beforeChoice:ot,footerLink:"Do Not Sell or Share My Personal Information",panelEyebrow:"Do not sell or share",adsRowName:"Sale or sharing for ads"},ca:{region:"ca",name:"Canada",model:"opt-in",law:"PIPEDA, Quebec Law 25",beforeChoice:$e,footerLink:"Privacy choices",panelEyebrow:"Privacy choices",adsRowName:"Advertising"},au:{region:"au",name:"Australia",model:"opt-out",law:"Privacy Act 1988 (APPs)",beforeChoice:ot,footerLink:"Privacy choices",panelEyebrow:"Privacy choices",adsRowName:"Advertising"},nz:{region:"nz",name:"New Zealand",model:"opt-out",law:"Privacy Act 2020",beforeChoice:ot,footerLink:"Privacy choices",panelEyebrow:"Privacy choices",adsRowName:"Advertising"},uk:{region:"uk",name:"United Kingdom",model:"opt-in",law:"PECR, UK GDPR",beforeChoice:$e,footerLink:"Cookie settings",panelEyebrow:"Cookie settings",adsRowName:"Advertising"},eu:{region:"eu",name:"European Union",model:"opt-in",law:"ePrivacy Directive, GDPR",beforeChoice:$e,footerLink:"Cookie settings",panelEyebrow:"Cookie settings",adsRowName:"Advertising"},other:{region:"other",name:"All other countries",model:"opt-in",law:"Safe default",beforeChoice:$e,footerLink:"Cookie settings",panelEyebrow:"Cookie settings",adsRowName:"Advertising"}};function Nr(e){let t=[...e.googleAds?["Google"]:[],...e.meta?["Facebook","Instagram"]:[]];return t.length<=1?t.join(""):`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function ra(e,t,n){let r=Nr(n),o=r?`We use cookies to count visits and to show you ${t} ads on ${r}.`:"We use cookies to count visits.";return e.model==="opt-in"?{heading:r?"Cookies and ads":"Cookies",before:`${o} Nothing loads until you choose. You can change this at any time with `,link:e.footerLink,after:" at the bottom of every page."}:{heading:r?"Cookies and ads":"Cookies",before:`${o} You can say no at any time: choose Privacy choices, or use `,link:e.footerLink,after:" at the bottom of every page."}}var oa={accept:"Accept all",reject:"Reject all",choose:"Choose",save:"Save",ok:"OK",privacyChoices:"Privacy choices",privacyPolicy:"Privacy Policy",alwaysOn:"Always on",close:"Close",cookieSettings:"Cookie settings"};var kr={asked:!1,region:"other",model:"opt-in",analytics:!0,ads:!0,chosen:!0,gpc:!1};var Ir=kr;function la(e=Ir){if(e.asked)return e.ads?"granted":"denied"}function ca(){let e=typeof crypto<"u"?crypto:void 0;if(typeof e?.randomUUID=="function")return e.randomUUID();let t=new Uint8Array(16);if(typeof e?.getRandomValues=="function")e.getRandomValues(t);else for(let r=0;r<t.length;r++)t[r]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=Array.from(t,r=>r.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}import{Children as Ar,isValidElement as Tr,useEffect as pn,useId as Or,useLayoutEffect as hn,useRef as j,useState as mn}from"react";var He=(e,t)=>!!e[t]&&!e[t].disabled;function it(e,t,n){let r=e.length;for(let o=1;o<=r;o++){let i=((t+n*o)%r+r)%r;if(He(e,i))return i}return t}function at(e,t){return it(e,t===1?-1:e.length,t)}function st(e,t){return He(e,t)?t:Math.max(at(e,1),0)}function fn(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(),l=n.findIndex((c,u)=>He(n,u)&&c.label.toLowerCase().startsWith(a));return{state:i({open:!0,typed:a,focus:l>=0?l: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:it(n,o,1)}),handled:!0};case"ArrowUp":return{state:i({focus:it(n,o,-1)}),handled:!0};case"Home":return{state:i({focus:at(n,1)}),handled:!0};case"End":return{state:i({focus:at(n,-1)}),handled:!0};case"Enter":case" ":return He(n,o)?{state:i({open:!1,typed:""}),commit:o,refocus:!0,handled:!0}:{state:e,handled:!0};case"Escape":return{state:i({open:!1,typed:""}),refocus:!0,handled:!0};case"Tab":return{state:i({open:!1,typed:""}),handled:!1};default:return{state:e,handled:!1}}}import{placeMenu as Mr}from"efficient-shell/ui";import{Fragment as qr,jsx as Z,jsxs as yn}from"react/jsx-runtime";var gn={body:"text-[length:var(--size-body,14px)]",label:"text-[length:var(--size-label,13px)]"};function Dr({items:e,value:t,onPick:n,open:r,onOpen:o,onClose:i}){let[a,l]=mn(!1),c=r!==void 0,u=c?r:a,[g,x]=mn(0),d=j({text:"",timer:0}),P=j(null),k=j(null),m=j(null),L=Or(),I=j(null),A=e.findIndex(b=>b.value===t),_=b=>{b!==u&&(c||l(b),b?o?.():i?.())},y=b=>{let R=e[b];!R||R.disabled||(n(R.value),_(!1),k.current?.focus())},U=b=>{let R={open:u,focus:u?g:st(e,A),typed:d.current.text},C=fn(R,b,e);return!C.handled&&C.state.open===u?!1:(C.state.typed!==R.typed&&(d.current.text=C.state.typed,window.clearTimeout(d.current.timer),d.current.timer=window.setTimeout(()=>{d.current.text=""},500)),x(C.state.focus),C.commit!==void 0?y(C.commit):_(C.state.open),C.refocus&&k.current?.focus(),C.handled)},V=j(U);V.current=U;let J=j(()=>_(!1));J.current=()=>_(!1);let T=b=>{u||(I.current=b.nativeEvent,V.current(b.key)&&b.preventDefault())};return pn(()=>{if(!u)return;let b=C=>{P.current?.contains(C.target)||J.current()},R=C=>{C!==I.current&&V.current(C.key)&&C.preventDefault()};return document.addEventListener("mousedown",b),document.addEventListener("keydown",R),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",R)}},[u]),pn(()=>{u&&(d.current.text||x(st(e,A)))},[u]),hn(()=>{if(!u||!m.current)return;m.current.children.item(g)?.scrollIntoView({block:"nearest"})},[g,u]),{open:u,toggle:()=>_(!u),close:()=>_(!1),focusIdx:g,setFocusIdx:x,pick:b=>y(e.findIndex(R=>R.value===b)),wrapRef:P,triggerRef:k,listRef:m,listId:L,onTriggerKeyDown:T,activeId:u?`${L}-${g}`:void 0}}var Fr={select:{list:"absolute left-0 top-full z-50 mt-1 max-h-[280px] w-max min-w-full overflow-y-auto border-2 border-accent bg-bg shadow-xl",item:(e,t,n)=>["px-3 py-3 font-mono text-[13px] font-semibold uppercase tracking-[0.1em] transition-colors whitespace-nowrap",n?"cursor-not-allowed opacity-40":"cursor-pointer",e&&!n?"bg-accent text-bg":"bg-bg text-fg"].join(" ")},cell:{list:"absolute left-0 top-full z-50 mt-1 max-h-[320px] w-max min-w-full overflow-y-auto border-2 border-accent bg-bg shadow-xl",item:e=>[`cursor-pointer whitespace-nowrap px-6 py-3 font-mono ${gn.label} font-semibold uppercase tracking-[0.1em] transition-colors`,e?"bg-accent text-bg":"bg-bg text-fg"].join(" "),pickerMarker:!0},hairline:{list:"absolute left-0 top-full z-50 max-h-[320px] w-full overflow-y-auto border border-line bg-bg shadow-[0_6px_20px_rgba(0,0,0,0.10)]",item:(e,t)=>[`flex cursor-pointer items-center justify-between gap-4 border-b border-line px-4 py-3 text-left ${gn.body} transition-colors last:border-b-0`,t?"border-fg font-medium text-fg":e?"border-fg text-fg":"text-fg-dim"].join(" "),pickerMarker:!0},region:{list:"absolute right-0 top-full z-[200] mt-2 flex min-w-[240px] flex-col border border-line bg-surface text-fg",item:(e,t,n,r)=>["flex w-full cursor-pointer items-center gap-3 px-4 py-3 text-left transition-colors","font-mono text-[13px] uppercase tracking-[0.18em]",e?"bg-surface-2 text-fg":"",r?"":"border-b border-line",t?"text-accent":""].join(" "),itemStyle:e=>e?void 0:{color:"color-mix(in oklab, currentColor 80%, transparent)"}}};function Ur(e,t){hn(()=>{let n=e.current,r=n?.ownerDocument.defaultView;if(!n||!r)return;let o=()=>{let i=n.style;i.top=i.bottom=i.marginTop=i.marginBottom=i.maxHeight=i.overflowY=i.translate="";let a=n.offsetParent??n.parentElement;if(!a)return;let l=a.getBoundingClientRect(),c=n.getBoundingClientRect(),u=Math.abs(c.right-l.right)<Math.abs(c.left-l.left)?"end":"start",g=Mr({trigger:{left:l.left,right:l.right,top:l.top,bottom:l.bottom},menu:{width:c.width,height:c.height},bounds:{left:0,top:0,right:r.innerWidth,bottom:r.innerHeight},align:u,side:"bottom"});if(g.side==="top"){i.top="auto",i.bottom="100%",i.marginTop="0px";let d=g.top+Math.min(c.height,g.maxHeight);i.marginBottom=`${Math.max(0,l.top-d)}px`}g.maxHeight<c.height&&(i.maxHeight=`${g.maxHeight}px`,i.overflowY="auto");let x=g.left-c.left;x&&(i.translate=`${x}px`)};return o(),r.addEventListener("resize",o),r.addEventListener("scroll",o,!0),()=>{r.removeEventListener("resize",o),r.removeEventListener("scroll",o,!0)}},[e,t])}function $r(e){return e.split(" ").map(t=>t==="left-0"?"right-0":t).join(" ")}function Hr({id:e,tone:t,items:n,value:r,focusIdx:o,onFocus:i,onPick:a,listRef:l,ariaLabel:c,align:u="start"}){let g=Fr[t],x=j(null);return Ur(x,n.length),Z("ul",{ref:d=>{x.current=d,l&&(l.current=d)},id:e,role:"listbox","aria-label":c,...g.pickerMarker?{"data-picker-menu":""}:{},className:u==="end"?$r(g.list):g.list,children:n.map((d,P)=>{let k=d.value===r;return Z("li",{id:`${e}-${P}`,role:"option","aria-selected":k,"aria-disabled":d.disabled||void 0,onMouseEnter:()=>!d.disabled&&i(P),onMouseDown:m=>{m.preventDefault(),d.disabled||a(d.value)},className:g.item(P===o,k&&d.value!=="",!!d.disabled,P===n.length-1),style:g.itemStyle?.(k),children:d.meta===void 0?d.label:yn(qr,{children:[d.lead,Z("span",{className:"flex-1 whitespace-nowrap",children:d.label}),Z("span",{className:"ml-auto text-[12px] opacity-50",children:d.meta})]})},`${d.value}_${P}`)})})}function Br({value:e,onChange:t,disabled:n,children:r,className:o,style:i,name:a,id:l,"aria-label":c,align:u}){let g=Ar.toArray(r).flatMap(m=>{if(!Tr(m))return[];if(m.type!=="option")return[];let I=m.props,A=I.value!==void 0?String(I.value):"",_=I.children,y=typeof _=="string"||typeof _=="number"?String(_):A;return[{value:A,label:y,disabled:!!I.disabled}]}),x=e??"",d=Dr({items:g,value:x,onPick:m=>t?.({target:{value:m}})}),k=g.find(m=>m.value===x)?.label??g[0]?.label??"";return yn("div",{ref:d.wrapRef,className:"relative",children:[a&&Z("input",{type:"hidden",name:a,value:x}),Z("button",{ref:m=>{d.triggerRef.current=m},type:"button",disabled:n,"aria-haspopup":"listbox","aria-expanded":d.open,"aria-controls":d.open?d.listId:void 0,"aria-activedescendant":d.activeId,"aria-label":c,id:l,onClick:()=>!n&&d.toggle(),onKeyDown:m=>!n&&d.onTriggerKeyDown(m),className:`block w-full ${o??""}`,style:i,children:Z("span",{className:"block w-full truncate text-left",children:k})}),d.open&&Z(Hr,{id:d.listId,tone:"select",items:g,value:x,focusIdx:d.focusIdx,onFocus:d.setFocusIdx,onPick:d.pick,listRef:d.listRef,align:u})]})}import{jsx as _e,jsxs as Be}from"react/jsx-runtime";var Wr="font-mono text-[length:var(--size-label,12px)]",Gr="font-semibold uppercase tracking-[0.22em] text-fg";function bn(e){return`${e??Wr} ${Gr}`}function Cn(){return _e("span",{className:"text-accent",children:" *"})}function Kr({children:e,required:t,labelFace:n}){return Be("span",{className:bn(n),children:[e,t?_e(Cn,{}):null]})}function zr({label:e,required:t,hint:n,separate:r,htmlFor:o,labelFace:i,className:a,children:l}){let c=a?`flex flex-col gap-2 ${a}`:"flex flex-col gap-2",u=n?_e("span",{className:"font-mono text-[11px] uppercase tracking-[0.22em] text-fg-dim",children:n}):null;return r||n?Be("div",{className:c,children:[Be("label",{htmlFor:o,className:bn(i),children:[e,t?_e(Cn,{}):null]}),l,u]}):Be("label",{htmlFor:o,className:c,children:[_e(Kr,{required:t,labelFace:i,children:e}),l]})}export{Ft as a,fo as b,po as c,mo as d,It as e,Ye as f,Vr as g,Xr as h,Yr as i,Qr as j,Rn as k,Nn as l,jr as m,Zr as n,Qe as o,Te as p,Y as q,Jr as r,eo as s,Oe as t,Fn as u,qt as v,bo as w,Co as x,Wt as y,xo as z,So as A,Je as B,vo as C,Eo as D,$n as E,Po as F,wo as G,Hn as H,_o as I,qn as J,Ro as K,No as L,ko as M,Gt as N,Mo as O,Do as P,Fo as Q,Ho as R,Bo as S,io as T,Dt as U,ao as V,Me as W,tt as X,ei as Y,nn as Z,hi as _,fr as $,bi as aa,qi as ba,cn as ca,Wi as da,vr as ea,Vi as fa,dn as ga,Xi as ha,Pr as ia,Yi as ja,_r as ka,xi as la,$i as ma,Hi as na,Rr as oa,ra as pa,oa as qa,kr as ra,la as sa,ca as ta,Dr as ua,Hr as va,Br as wa,Kr as xa,zr as ya};
|