efficient-storefront-blocks 0.81.0 → 0.83.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 +22 -0
- package/README.md +1 -1
- package/dist/chunks/EditorPreviewCheckout-RI5SBSCE.js +4 -0
- package/dist/chunks/{SiteEditorProvider-PXXYEDUI.js → SiteEditorProvider-OQXY7YGK.js} +1 -1
- package/dist/chunks/{chunk-EEBM2KUO.js → chunk-AUYTGAOU.js} +1 -1
- package/dist/chunks/chunk-LMOEQBT7.js +340 -0
- package/dist/chunks/{chunk-K3VUREAB.js → chunk-QOM2OL54.js} +1 -1
- package/dist/chunks/{fitment-data-WHDQR3A2.js → fitment-data-64LXUHOU.js} +1 -1
- package/dist/contract.js +22 -2
- package/dist/editor/components/CategoryProductFields.d.ts +4 -1
- package/dist/editor/components/CategoryProductFields.js +1 -1
- package/dist/editor/components/EditReviewsLink.d.ts +4 -0
- package/dist/editor/components/EditReviewsLink.js +1 -0
- package/dist/editor/components/GalleryShowcaseSource.js +1 -1
- package/dist/editor/components/ProductHeroSource.js +1 -1
- package/dist/editor/components/ProductPicker.js +1 -1
- package/dist/editor/components/ReviewsProductSource.d.ts +26 -0
- package/dist/editor/components/ReviewsProductSource.js +1 -0
- package/dist/editor/components/SpecTableSource.js +1 -1
- package/dist/editor/lib/document/blocks/commerce/index.d.ts +1 -1
- package/dist/editor/lib/document/blocks/service/FooterMenu/fields.js +1 -1
- package/dist/editor/lib/document/blocks/service/MenuLinkBlock/fields.d.ts +2 -0
- package/dist/editor/lib/document/blocks/service/MenuLinkBlock/fields.js +1 -0
- package/dist/editor/lib/document/blocks/service/ReviewForm/fields.js +1 -1
- package/dist/editor/lib/document/blocks/service/Reviews/fields.js +1 -1
- package/dist/editor/lib/document/blocks/service/index.d.ts +1 -1
- package/dist/editor/lib/document/blocks/service/index.js +1 -1
- package/dist/editor/lib/document/box-header.d.ts +1 -0
- package/dist/editor/lib/document/box-header.js +1 -1
- package/dist/editor/lib/document/config.js +1 -1
- package/dist/editor/lib/storefront-editor-words.d.ts +9 -2
- package/dist/editor/lib/storefront-editor-words.js +1 -1
- package/dist/index.js +37 -29
- package/dist/render/app/globals.css +67 -9
- package/dist/render/built-with.json +1 -1
- package/dist/render/components/ChatContext.js +1 -1
- package/dist/render/components/FooterMenu.d.ts +9 -9
- package/dist/render/components/FooterMenu.js +1 -1
- package/dist/render/components/MenuLinkBlock.d.ts +7 -0
- package/dist/render/components/MenuLinkBlock.js +1 -0
- package/dist/render/components/ProductCard.js +1 -1
- package/dist/render/components/checkout/CheckoutPageClient.d.ts +2 -1
- package/dist/render/components/checkout/CheckoutPageClient.js +1 -1
- package/dist/render/components/checkout/checkout-state.d.ts +1 -0
- package/dist/render/components/checkout/checkout-state.js +3 -3
- package/dist/render/components/wheels-plp/PlpCard.js +1 -1
- package/dist/render/lib/catalog/relationships.js +1 -1
- package/dist/render/lib/checkout/pay-first.d.ts +19 -0
- package/dist/render/lib/checkout/pay-first.js +1 -1
- package/dist/render/lib/content/menu-card-seed.d.ts +6 -0
- package/dist/render/lib/content/menu-card-seed.js +1 -0
- package/dist/render/lib/document/blocks/service/FooterMenu/meta.d.ts +6 -0
- package/dist/render/lib/document/blocks/service/FooterMenu/meta.js +1 -1
- package/dist/render/lib/document/blocks/service/FooterMenu/render.js +1 -1
- package/dist/render/lib/document/blocks/service/MenuLinkBlock/meta.d.ts +2 -0
- package/dist/render/lib/document/blocks/service/MenuLinkBlock/meta.js +1 -0
- package/dist/render/lib/document/blocks/service/MenuLinkBlock/render.d.ts +2 -0
- package/dist/render/lib/document/blocks/service/MenuLinkBlock/render.js +1 -0
- package/dist/render/lib/document/blocks/service/metas.d.ts +1 -0
- package/dist/render/lib/document/blocks/service/metas.js +1 -1
- package/dist/render/lib/document/blocks/service/renders.d.ts +1 -0
- package/dist/render/lib/document/blocks/service/renders.js +1 -1
- package/dist/render/lib/document/blocks/text-part-shapes.json +0 -14
- package/dist/render/lib/document/card-templates.js +1 -1
- package/dist/render/lib/document/footer-page-blocks.js +1 -1
- package/dist/render/lib/document/lazy-draws.js +1 -1
- package/dist/render/lib/menu-link.d.ts +8 -0
- package/dist/render/lib/sections/reviews.d.ts +7 -0
- package/dist/render/lib/sections/reviews.js +1 -1
- package/dist/words.d.ts +30 -8
- package/dist/words.js +4 -4
- package/package.json +4 -4
- package/dist/chunks/EditorPreviewCheckout-OIN6G67Y.js +0 -4
- package/dist/chunks/chunk-SXRBNRRO.js +0 -320
- package/dist/editor/lib/document/blocks/service/placeholders.d.ts +0 -1
- package/dist/editor/lib/document/blocks/service/placeholders.js +0 -1
- /package/dist/chunks/{chunk-5O3W5AUB.js → chunk-CRXKVHUQ.js} +0 -0
- /package/dist/chunks/{chunk-PBQWSV3B.js → chunk-DX6JADLE.js} +0 -0
- /package/dist/chunks/{chunk-SXRBNRRO.js.LEGAL.txt → chunk-LMOEQBT7.js.LEGAL.txt} +0 -0
|
@@ -1492,7 +1492,8 @@ body:has([data-page-width="full"]) footer {
|
|
|
1492
1492
|
/* Stick to top — the pin any section or card can be given (efficient-web-builder
|
|
1493
1493
|
lib/content/section-sticky.ts, card [ADD] Every Section Can Stick To The Top).
|
|
1494
1494
|
The pass wraps a node that sticks in `.sf-section-stick` and publishes the
|
|
1495
|
-
distance below the header as `--sf-stick-distance` (and `-
|
|
1495
|
+
distance below the header as `--sf-stick-distance` (and `-tablet`,
|
|
1496
|
+
`-phone`); nothing
|
|
1496
1497
|
is emitted for a node that does not stick, so these rules match nothing on
|
|
1497
1498
|
a page that never used it.
|
|
1498
1499
|
|
|
@@ -1529,6 +1530,25 @@ body:has([data-page-width="full"]) footer {
|
|
|
1529
1530
|
position: relative;
|
|
1530
1531
|
z-index: 2;
|
|
1531
1532
|
}
|
|
1533
|
+
/* The tablet's own answer (three-views plan 2026-11-02, PR 5c): the Tablet
|
|
1534
|
+
view's widths, efficient-easel's VIEW_TABLET_MIN (720) up to, not including,
|
|
1535
|
+
VIEW_DESKTOP_MIN (1100), the builder's lib/content/view-values `TABLET_MEDIA`.
|
|
1536
|
+
The builder adds `-tablet-on` / `-tablet-off` and `--sf-stick-distance-tablet`
|
|
1537
|
+
only when the tablet draws a value of its own, so a node without one matches
|
|
1538
|
+
nothing here. scripts/test-tablet-section-css.ts. */
|
|
1539
|
+
@media (min-width: 720px) and (max-width: 1099.98px) {
|
|
1540
|
+
.sf-section-stick.sf-section-stick-tablet-on {
|
|
1541
|
+
position: sticky;
|
|
1542
|
+
top: calc(var(--sf-header-h, 88px) + var(--sf-stick-distance-tablet, 0px));
|
|
1543
|
+
}
|
|
1544
|
+
.sf-section-stick.sf-section-stick-tablet-off {
|
|
1545
|
+
position: static;
|
|
1546
|
+
}
|
|
1547
|
+
:root[data-header-sticky="none"] .sf-section-stick.sf-section-stick-tablet-on,
|
|
1548
|
+
:root[data-header-sticky="on_scroll_up"] .sf-section-stick.sf-section-stick-tablet-on {
|
|
1549
|
+
top: var(--sf-stick-distance-tablet, 0px);
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1532
1552
|
/* The phone's own answer (below 720px, VIEW_TABLET_MIN, written as in the
|
|
1533
1553
|
phone padding block below). */
|
|
1534
1554
|
@media not all and (min-width: 720px) {
|
|
@@ -2486,7 +2506,8 @@ em.text-accent {
|
|
|
2486
2506
|
· the hero (HeroSingle's section, the slideshow's viewport) is a column
|
|
2487
2507
|
at least as tall as the height that applies at this width: the set
|
|
2488
2508
|
phone height (`--sf-hero-h-m`, which the builder writes on the
|
|
2489
|
-
element), from 720px the
|
|
2509
|
+
element), from 720px the tablet height if one is set (`--sf-hero-h-t`),
|
|
2510
|
+
else the set desktop height (`--sf-hero-h-d`; 720 is
|
|
2490
2511
|
the height control's own line and picks WHICH height, nothing else —
|
|
2491
2512
|
the rule just below this block), or, with no set height,
|
|
2492
2513
|
`max(100vh, 680px)`: the pixels `h-screen min-h-[680px]` drew;
|
|
@@ -2532,14 +2553,15 @@ em.text-accent {
|
|
|
2532
2553
|
width: 100%;
|
|
2533
2554
|
}
|
|
2534
2555
|
}
|
|
2535
|
-
/* …and WHICH height is the minimum between 720 and 800: the
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2556
|
+
/* …and WHICH height is the minimum between 720 and 800: the Tablet view's own
|
|
2557
|
+
(`--sf-hero-h-t`, the builder writes it only when a tablet height is stored),
|
|
2558
|
+
else the desktop one, as the builder's own `view-tablet:h-[var(--sf-hero-h-d)]`
|
|
2559
|
+
says (VIEW_TABLET_MIN, the line the Height control switches on). Only the
|
|
2560
|
+
height is chosen here; the layout above is on the hero's one line, 800. */
|
|
2539
2561
|
@media (min-width: 720px) and (max-width: 800px) {
|
|
2540
2562
|
section:not([data-slide-name]):has(> .sf-hero-group-layer),
|
|
2541
2563
|
div:has(> .hero-track) {
|
|
2542
|
-
min-height: var(--sf-hero-h-d, max(100vh, 680px));
|
|
2564
|
+
min-height: var(--sf-hero-h-t, var(--sf-hero-h-d, max(100vh, 680px)));
|
|
2543
2565
|
}
|
|
2544
2566
|
}
|
|
2545
2567
|
|
|
@@ -3016,8 +3038,9 @@ em.text-accent {
|
|
|
3016
3038
|
section that has a border inherits the section's properties for whatever it
|
|
3017
3039
|
did not set itself: the Box follows the tier above, as Corners does.
|
|
3018
3040
|
|
|
3019
|
-
On a
|
|
3020
|
-
fallback, so an unset phone value
|
|
3041
|
+
On a tablet the `-tablet` properties come first, and on a phone the `-phone`
|
|
3042
|
+
ones; the desktop ones are the fallback, so an unset tablet or phone value
|
|
3043
|
+
follows the desktop (the tablet rule: scripts/test-tablet-section-css.ts). The boundary is the
|
|
3021
3044
|
phone padding's below (`not all and (min-width: 720px)`, lib/content/
|
|
3022
3045
|
view-tiers' VIEW_TABLET_MIN). scripts/test-section-border-css.ts.
|
|
3023
3046
|
|
|
@@ -3031,6 +3054,19 @@ em.text-accent {
|
|
|
3031
3054
|
border-color: var(--sf-border-color, var(--site-line));
|
|
3032
3055
|
border-width: var(--sf-border-top-width, 0) var(--sf-border-right-width, 0) var(--sf-border-bottom-width, 0) var(--sf-border-left-width, 0);
|
|
3033
3056
|
}
|
|
3057
|
+
/* The tablet's own Border (three-views plan 2026-11-02, PR 5c), in the Tablet
|
|
3058
|
+
view's widths (720 up to, not including, 1100; the builder's `TABLET_MEDIA`).
|
|
3059
|
+
The `-tablet` properties come first and the desktop ones are the fallback, one
|
|
3060
|
+
property at a time, so a node with no tablet value draws as before.
|
|
3061
|
+
scripts/test-tablet-section-css.ts. */
|
|
3062
|
+
@media (min-width: 720px) and (max-width: 1099.98px) {
|
|
3063
|
+
.sf-section-border > *,
|
|
3064
|
+
.sf-section-border-self {
|
|
3065
|
+
border-style: var(--sf-border-style-tablet, var(--sf-border-style, solid));
|
|
3066
|
+
border-color: var(--sf-border-color-tablet, var(--sf-border-color, var(--site-line)));
|
|
3067
|
+
border-width: var(--sf-border-top-width-tablet, var(--sf-border-top-width, 0)) var(--sf-border-right-width-tablet, var(--sf-border-right-width, 0)) var(--sf-border-bottom-width-tablet, var(--sf-border-bottom-width, 0)) var(--sf-border-left-width-tablet, var(--sf-border-left-width, 0));
|
|
3068
|
+
}
|
|
3069
|
+
}
|
|
3034
3070
|
@media not all and (min-width: 720px) {
|
|
3035
3071
|
.sf-section-border > *,
|
|
3036
3072
|
.sf-section-border-self {
|
|
@@ -3127,6 +3163,13 @@ em.text-accent {
|
|
|
3127
3163
|
.sf-pad-right-tablet {
|
|
3128
3164
|
padding-right: var(--sf-pad-r-tablet) !important;
|
|
3129
3165
|
}
|
|
3166
|
+
/* A picture's TABLET focus: the same split as `.sf-focus-phone`. The desktop
|
|
3167
|
+
point is the picture's INLINE `object-position`, and the builder's
|
|
3168
|
+
lib/content/phone-focus adds this class and its variable only when a tablet
|
|
3169
|
+
point is set, so a picture without one draws the bytes it drew. */
|
|
3170
|
+
.sf-focus-tablet {
|
|
3171
|
+
object-position: var(--sf-focus-tablet) !important;
|
|
3172
|
+
}
|
|
3130
3173
|
}
|
|
3131
3174
|
|
|
3132
3175
|
/* ── A section's phone padding ────────────────────────────────────────────────
|
|
@@ -3207,6 +3250,21 @@ em.text-accent {
|
|
|
3207
3250
|
padding-right: 0;
|
|
3208
3251
|
}
|
|
3209
3252
|
|
|
3253
|
+
/* The tablet's own Height (three-views plan 2026-11-02, PR 5c): the same pair
|
|
3254
|
+
as the phone's (next block), in the Tablet view's widths (720 up to, not including,
|
|
3255
|
+
1100; the builder's `TABLET_MEDIA`). The builder adds the class only when the
|
|
3256
|
+
tablet draws a height of its own. scripts/test-tablet-section-css.ts. */
|
|
3257
|
+
@media (min-width: 720px) and (max-width: 1099.98px) {
|
|
3258
|
+
.sf-section-minh-tablet {
|
|
3259
|
+
display: grid !important;
|
|
3260
|
+
min-height: var(--sf-section-minh-t) !important;
|
|
3261
|
+
}
|
|
3262
|
+
@supports (min-height: 1svh) {
|
|
3263
|
+
.sf-section-minh-tablet {
|
|
3264
|
+
min-height: var(--sf-section-minh-ts, var(--sf-section-minh-t)) !important;
|
|
3265
|
+
}
|
|
3266
|
+
}
|
|
3267
|
+
}
|
|
3210
3268
|
/* ── A section's height on a phone ────────────────────────────────────────────
|
|
3211
3269
|
The phone half of the Height group. Lewis chose 甲 on 2026-09-08: the phone
|
|
3212
3270
|
overrides the group AS ONE UNIT, so a section either follows the desktop
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as $}from"react/jsx-runtime";import{createContext as q,useCallback as f,useContext as z,useEffect as p,useMemo as B,useRef as x,useState as c}from"react";import{auth as D}from"../lib/auth.js";import{api as F}from"../lib/api/index.js";import{chatSocketUrl as G}from"../lib/chat-socket.js";import{safeLocalStorage as I}from"efficient-web-builder/format/lib/safe-storage";import{getChatThread as Q,postChatMessage as X,startChat as Z}from"../lib/api/chat.js";const ee="sf:aid",A="sf:chat",U=q(null);function te(){const u=I.getItem(A);if(!u)return null;try{return JSON.parse(u)}catch{return null}}function ie({children:u,preview:t=!1}){const[m,y]=c(!1),[e,O]=c(null),[b,g]=c([]),[E,T]=c(!1),[v,P]=c(null),[M,C]=c(0),[N,R]=c(!1),[J,H]=c(!1),S=x(m);S.current=m;const h=x(null),_=x(e);_.current=e,p(()=>{t||O(te())},[t]);const i=f(async r=>{try{const o=await Q(r.id,r.token);g(o.messages)}catch{}},[]),l=f(()=>(t||h.current||(h.current=F.restoreSession().then(()=>{R(!0),_.current&&i(_.current)},()=>R(!1))),h.current),[t,i]);p(()=>{t||e&&i(e)},[t,e,i]),p(()=>{if(t||!e)return;const r=D.getAccess()??e.token;let o=!1,s=null,n,a=3e3;const d=()=>{o||(s=new WebSocket(G(e.id,r)),s.onmessage=V=>{try{const k=JSON.parse(V.data);k.type==="chat_event"&&k.event==="message"&&(i(e),!S.current&&k.payload?.sender_role==="employee"&&C(W=>W+1))}catch{}},s.onclose=()=>{o||(n=setTimeout(d,a),a=Math.min(a*2,3e4))},s.onerror=()=>s?.close())};return d(),()=>{o=!0,n&&clearTimeout(n),s?.close()}},[t,e,i]);const K=f(()=>{y(!0),C(0),l()},[l]),Y=f(()=>y(!1),[]),j=f(()=>{S.current||l(),y(r=>(r||C(0),!r))},[l]),w=f(async(r,o)=>{const s=r.trim();if(s){if(t){g(n=>[...n,{id:`preview-${n.length}`,sender_role:"customer",sender_name:o?.name||"You",body:s,image_url:null,created_at:""}]),H(!0);return}T(!0),P(null),await l();try{if(e){const n=await X(e.id,e.token,s);g(a=>[...a,n])}else{const n=I.getItem(ee)||"",a=await Z({body:s,guestName:o?.name,guestEmail:o?.email,guestKey:n}),d={id:a.id,token:a.guest_token};I.setItem(A,JSON.stringify(d)),O(d),g(a.messages)}}catch{P("Could not send your message. Please try again shortly.")}finally{T(!1)}}},[e,t,l]),L=B(()=>({isOpen:m,open:K,close:Y,toggle:j,messages:b,sending:E,error:v,unread:M,hasConversation:t?J:!!e,isSignedIn:N,send:w}),[m,K,Y,j,b,E,v,M,e,N,w,t,J]);return $(U.Provider,{value:L,children:u})}function le(){const u=z(U);if(!u)throw new Error("useChat must be used within <ChatProvider>");return u}export{ie as ChatProvider,le as useChat};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
url: string;
|
|
4
|
-
dropdown_items?: {
|
|
5
|
-
label: string;
|
|
6
|
-
url: string;
|
|
7
|
-
}[];
|
|
8
|
-
}
|
|
1
|
+
import type { SlotComponent } from "efficient-easel/blocks";
|
|
2
|
+
import type { FooterMenuItem } from "../lib/menu-link.js";
|
|
9
3
|
export interface FooterMenuValue {
|
|
10
4
|
id?: string;
|
|
11
5
|
handle?: string;
|
|
12
6
|
name?: string;
|
|
13
7
|
items?: FooterMenuItem[];
|
|
14
8
|
}
|
|
9
|
+
export interface MenuOwner {
|
|
10
|
+
id: string;
|
|
11
|
+
type: string;
|
|
12
|
+
template?: SlotComponent;
|
|
13
|
+
}
|
|
15
14
|
export interface FooterMenuProps {
|
|
15
|
+
owner: MenuOwner;
|
|
16
16
|
menu?: FooterMenuValue | null;
|
|
17
17
|
heading?: string;
|
|
18
18
|
accordionMobile?: boolean;
|
|
@@ -22,4 +22,4 @@ export interface FooterMenuProps {
|
|
|
22
22
|
linkAlign?: unknown;
|
|
23
23
|
linkRange?: unknown;
|
|
24
24
|
}
|
|
25
|
-
export default function FooterMenu({ menu, heading, accordionMobile, showDividers, editing, layout, linkAlign, linkRange, }: FooterMenuProps): import("react").JSX.Element;
|
|
25
|
+
export default function FooterMenu({ owner, menu, heading, accordionMobile, showDividers, editing, layout, linkAlign, linkRange, }: FooterMenuProps): import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as
|
|
1
|
+
"use client";import{jsx as e,Fragment as D,jsxs as r}from"react/jsx-runtime";import{useCallback as H,useEffect as U,useRef as F,useState as O}from"react";import j from"next/link";import{REPEAT_ATTRIBUTE as $,REPEAT_INDEX_ATTRIBUTE as B}from"efficient-easel/draw";import W from"./CountrySelect.js";import{MenuPlaceContext as z}from"./MenuLinkBlock.js";import G from"./ThemeToggle.js";import{CardRowContext as Y,CardTemplateRows as q}from"efficient-web-builder/render/components/CardRowContext";import{renderChrome as _}from"efficient-web-builder/render/components/goldPhrases";import{UTIL_WORDS as X}from"./HeaderTools.js";import{usePhoneMenuTools as J}from"efficient-web-builder/render/components/PhoneMenuTools";import{useSearch as K}from"./SearchContext.js";import{useModalDismiss as Q}from"./useModalDismiss.js";import V from"efficient-easel/screen/components/UiIcon";import{usePreviewMenus as Z}from"./PreviewMenusContext.js";import{FOOTER_MENU_PLACEHOLDER_COUNT as ee,FOOTER_MENU_PLACEHOLDER_HEADING as ne,FOOTER_MENU_PLACEHOLDER_HINT as le}from"../lib/content/menu-placeholder.js";import{say as w}from"efficient-web-builder/format/lib/editor-words";import{UNDER_HEADER_SHEET_CLASS as te}from"../lib/content/header-bar.js";import{isMenuOrphaned as re}from"../lib/menu-source.js";import{legacyBlockAlignOf as ae}from"../lib/content/legacy-block-align.js";import{menuLinkInRange as oe,resolveMenuLinkRange as ie}from"../lib/content/menu-row.js";const se="flex list-none flex-col gap-3 text-[13px]",C="mb-4 font-mono text-[13px] uppercase tracking-[0.2em] text-fg-dim",k="text-[12px] italic text-fg-dim/70",S=(n,l)=>n&&l>0?"border-t border-line pt-3":"",I=n=>({label:n.label??"",href:n.url??""}),ce=Array.from({length:ee},()=>({label:"",href:""}));function L({owner:n,items:l,place:s,wrap:a}){const g=l?l.map(I):ce;return e(z.Provider,{value:l?s:{...s,placeholder:!0},children:e(q,{ownerId:n.id,ownerType:n.type,Template:n.template,rows:g,items:l??void 0,fallback:null,wrapCopy:a,children:c=>c})})}const M=n=>(n.template?.blockCount??0)>0,P="This menu draws no links: its card template is empty. Undo the delete, or delete this Menu and add it again.";function me({owner:n,items:l,label:s,editing:a,linkAlign:g,linkRange:c}){const E=ae(g),p=ie(c),y=!!p&&l!==null&&p.to!==void 0&&p.to<l.length,[f,v]=O(!1),h=F(null),t=J(),{open:m}=K(),R=s||"Menu",N=H(()=>v(!1),[]);Q({active:f,onDismiss:N,scopeRef:h});const T=e(L,{owner:n,items:l,place:{place:"row"},wrap:(d,u)=>{const b=l!==null&&p&&!oe(p,u.index+1)?{"data-menu-out":""}:null;return e("li",{className:"",...b,children:d})}}),o=(d,u,b)=>a?{[$]:`${d}:${b<0?"panel":"dropdown"}`,[B]:`${b+1}.${u.index}`}:null,x=e(L,{owner:n,items:l,place:{place:"panel",onNavigate:N},wrap:(d,u)=>r(D,{children:[e("li",{className:"flex min-h-14 items-center border-b border-line",...o(n.id,u,-1),children:d}),l===null?null:(u.item?.dropdown_items??[]).map((b,A)=>e(Y.Provider,{value:{...u,row:I(b),item:b},children:e("li",{className:"flex min-h-12 items-center border-b border-line pl-5 text-[14px]",...o(n.id,u,A),children:d})},A))]})}),i=t&&(t.search||t.region||t.account||t.theme)?t:null;return!a&&l!==null&&!M(n)&&!i?null:r("nav",{ref:h,"aria-label":R,"data-menu-row":"",...E?{"data-menu-align":E}:null,...y?{"data-menu-part":"lead"}:null,className:"min-w-0",children:[e("ul",{className:"m-0 hidden list-none flex-wrap items-center gap-x-8 gap-y-2 p-0 font-mono text-[13px] uppercase tracking-[0.18em] view-tablet:flex",children:T}),e("button",{type:"button",className:"flex h-11 w-11 items-center justify-center view-tablet:hidden","aria-expanded":f,"aria-label":f?"Close the menu":"Open the menu",onClick:()=>v(d=>!d),children:e("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":"true",children:f?e("path",{d:"M6 6l12 12M18 6L6 18"}):e("path",{d:"M4 7h16M4 12h16M4 17h16"})})}),f?r("div",{role:"dialog","aria-label":R,className:`${te} z-[60] flex flex-col overflow-y-auto bg-bg text-fg view-tablet:hidden`,children:[e("ul",{className:"m-0 flex list-none flex-col px-5 py-3 font-mono text-[16px] uppercase tracking-[0.18em]",children:x}),i?r("div",{className:"mt-auto flex flex-col gap-4 border-t border-line bg-surface p-5",children:[i.search?r("button",{type:"button",className:"flex h-12 items-center gap-3 border border-line bg-bg px-4 text-left text-[15px]",onClick:a?void 0:()=>{N(),m()},children:[e(V,{name:"search",size:18,strokeWidth:1.6,rounded:!0}),X.search]}):null,i.account?r("div",{className:"flex items-center justify-between",children:[e("span",{className:"mono-eyebrow text-fg-dim",children:"Account"}),e(j,{href:"/account",onClick:N,className:"mono-eyebrow underline",children:"Your account"})]}):null,i.region?r("div",{className:"flex items-center justify-between",children:[e("span",{className:"mono-eyebrow text-fg-dim",children:"Region"}),e(W,{})]}):null,i.theme?r("div",{className:"flex items-center justify-between",children:[e("span",{className:"mono-eyebrow text-fg-dim",children:"Theme"}),e(G,{})]}):null]}):null]}):null]})}function de({owner:n,menu:l,heading:s,accordionMobile:a=!1,showDividers:g=!1,editing:c=!1,layout:E="column",linkAlign:p,linkRange:y}){const{live:f,ready:v}=Z(),h=re({id:l?.id,handle:l?.handle,editing:c,ready:v,live:f}),t=h?[]:l?.items??[],m=s||l?.name||"",[R,N]=O(!1);if(U(()=>{if(!a)return;const o=window.matchMedia("(max-width: 800px)"),x=()=>N(o.matches);return x(),o.addEventListener("change",x),()=>o.removeEventListener("change",x)},[a]),E==="row"&&c&&!h&&t.length>0&&!M(n))return e("p",{className:k,children:w(P)});if(E==="row")return e(me,{owner:n,items:h?null:t,label:m,editing:c,linkAlign:p,linkRange:y});const T=o=>e("ul",{className:se,children:e(L,{owner:n,items:o,place:{place:"column"},wrap:(x,i)=>e("li",{className:o?S(g,i.index):`text-fg ${S(g,i.index)}`,children:x})})});return h?r("div",{className:"min-w-0",children:[e("h4",{className:C,children:s?_(s):w(ne)}),T(null),e("p",{className:`mt-3 ${k}`,children:w(le)})]}):t.length===0||!M(n)?r("div",{className:"min-w-0",children:[m?e("h4",{className:C,children:_(m)}):null,c?e("p",{className:k,children:t.length===0?w("This menu has no links yet — add them in {place}.",{place:w("Storefront → Menus")}):w(P)}):null]}):a&&R?r("details",{className:"min-w-0 border-b border-line",children:[r("summary",{className:"flex cursor-pointer list-none items-center justify-between py-3 font-mono text-[13px] uppercase tracking-[0.2em] text-fg-dim",children:[_(m),e("span",{"aria-hidden":!0,children:"+"})]}),e("div",{className:"pb-3",children:T(t)})]}):r("div",{className:"min-w-0",children:[m?e("h4",{className:C,children:_(m)}):null,T(t)]})}export{de as default};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface MenuPlace {
|
|
2
|
+
place: "column" | "row" | "panel";
|
|
3
|
+
placeholder?: boolean;
|
|
4
|
+
onNavigate?: () => void;
|
|
5
|
+
}
|
|
6
|
+
export declare const MenuPlaceContext: import("react").Context<MenuPlace | null>;
|
|
7
|
+
export default function MenuLinkBlock(): import("react").JSX.Element | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{jsx as l}from"react/jsx-runtime";import{createContext as s,useContext as u}from"react";import p from"next/link";import f from"./HeaderNavItem.js";import m from"./MenuPlaceholderLabel.js";import{useCardRow as b}from"efficient-web-builder/render/components/CardRowContext";import{renderGold as o}from"efficient-web-builder/render/components/goldPhrases";import{isLabelOnlyMenuUrl as h}from"../lib/menu-link.js";const d=s(null),x=e=>/^https?:\/\//i.test(e),c="opacity-80 transition-opacity hover:opacity-100";function i({item:e,label:n,link:r,onNavigate:t}){return h(e.url)?l("span",{className:n,children:o(e.label)}):x(e.url)?l("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:r,onClick:t,children:o(e.label)}):l(p,{href:e.url,className:r,onClick:t,children:o(e.label)})}function k(){const e=b(),n=u(d);if(!e||!n)return null;if(n.placeholder)return l(m,{});const r={label:e.row.label??"",url:e.row.href??""};if(n.place==="column")return l(i,{item:r,label:"text-fg",link:"text-fg transition-colors hover:text-accent"});if(n.place==="panel")return l(i,{item:r,label:"",link:` ${c}`,onNavigate:n.onNavigate});const t=e.item?.dropdown_items??[];return t.length?l(f,{item:{href:r.url,label:o(r.label),plainLabel:r.label,dropdownItems:t.map(a=>({href:a.url,label:o(a.label),plainLabel:a.label}))}}):l(i,{item:r,label:"",link:` ${c}`})}export{d as MenuPlaceContext,k as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,Fragment as W,jsxs as R}from"react/jsx-runtime";import U from"next/image";import{useState as X}from"react";import{setSecondSrc as q}from"../lib/wheels/set-mode.js";import{CARD_INDEX_BADGE_CLASS as G,CARD_INDEX_CLASS as M}from"efficient-web-builder/format/lib/sections/product-card-style";import{coverSrcForWheel as O,resolvePaintedSrc as
|
|
1
|
+
"use client";import{jsx as e,Fragment as W,jsxs as R}from"react/jsx-runtime";import U from"next/image";import{useState as X}from"react";import{setSecondSrc as q}from"../lib/wheels/set-mode.js";import{CARD_INDEX_BADGE_CLASS as G,CARD_INDEX_CLASS as M}from"efficient-web-builder/format/lib/sections/product-card-style";import{coverSrcForWheel as O,resolvePaintedSrc as T}from"../lib/wheels/cover-rendering.js";import{wheelCardEyebrow as H,withSetChip as J}from"./ProductCardEyebrow.js";import{withRMark as K}from"efficient-web-builder/render/components/RMark";import Q from"./WheelPlaceholder.js";import{useProductCardChrome as V}from"./ProductCardChrome.js";import Y,{CardBuyDialog as Z}from"./card-pieces/CardBuyButton.js";import ee from"./card-pieces/CardFinishSwatches.js";import re from"./card-pieces/CardPrice.js";import oe from"./card-pieces/CardProductBadge.js";import{useWheelCardState as se,WheelCardStateProvider as ae}from"./card-pieces/ProductCardState.js";import{CardSpecFacts as te}from"./card-pieces/CardSpecs.js";import ie from"./WheelCardFrame.js";import{cardTurnFor as ne}from"efficient-web-builder/format/lib/animation/hover";import{cardSpinOf as de}from"./card-spin.js";function ce({wheel:i,variant:a="compact",defaultFinish:r}){return e(ae,{wheel:i,defaultFinish:r,children:e(le,{variant:a})})}function le({variant:i}){const a=i==="catalog",{wheel:r,sel:s,isSet:n}=se(),{imageBackgroundFill:b,hover:y,coverIndex:B,indexBadge:h,outline:F,showBadge:k,fieldUsage:f,reserveEyebrow:x,showCardPrice:E,showCardFinishes:P,showCardSizes:_,showCardBuy:u,showCardPage:p,imageSizes:$}=V(),d=a&&(u||p),v=O(r,B,s.finish?.name,s.shownSrc),A="h-full w-full",c=de(ne(y,r.spokes)),[w,D]=X(()=>new Set),I=o=>D(t=>t.has(o)?t:new Set(t).add(o)),l=T({overrideSrc:v,hookSrc:s.shownSrc,failed:w}),g=(o,t)=>e(U,{src:o,alt:t,width:1e3,height:1e3,sizes:$,className:`block object-contain ${c.className} ${A}`,style:c.style,draggable:!1,onError:()=>I(o)},o),S=s.finish?`${r.name} — ${s.finish.name}`:r.name,L=l?g(l,S):e(Q,{imageLabel:r.name,spin:c}),m=n?q(r.finishes?.find(o=>o.name===s.finish?.name),l):null,j=m&&!w.has(m)?g(m,`${S} — right`):void 0,C=H({kindLabel:null,brand:null,process:r.process?K(r.process):null},f),z=n&&!a?J(C):C,N=h!=="off"?e("span",{"aria-hidden":!0,className:`${M} ${G}`}):null;return R(W,{children:[e(ie,{variant:i,wide:n&&a,href:`/wheels/${r.slug}`,outline:F,imageBackgroundFill:b,probes:s.probes,reserveEyebrow:x,indexBadge:N,badges:e(oe,{show:k,numbered:h!=="off",axleSets:!0}),image:L,imageSecond:j,eyebrow:z,spec:e(te,{sizes:_,fieldUsage:f}),price:e(re,{show:E,quoteSets:!0}),swatches:e(ee,{show:P}),identityLink:d,wholeCardLink:!0,buy:e(Y,{buy:d&&u,page:d&&p})}),e(Z,{})]})}export{ce as default};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type PayFirstResult } from "../../lib/checkout/pay-first.js";
|
|
2
2
|
import { type CheckoutProps } from "./checkout-state.js";
|
|
3
3
|
export default function CheckoutPageClient(props: CheckoutProps): import("react").JSX.Element;
|
|
4
|
-
export declare function PayFirstResultView({ result }: {
|
|
4
|
+
export declare function PayFirstResultView({ result, lostChangeNote }: {
|
|
5
5
|
result: PayFirstResult;
|
|
6
|
+
lostChangeNote?: string | null;
|
|
6
7
|
}): import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as r,Fragment as x}from"react/jsx-runtime";import S from"next/link";import{useEffect as D,useMemo as Y,useRef as j,useState as v}from"react";import{stripeAppearance as Q}from"../../lib/checkout/stripe-appearance.js";import{Elements as V,PaymentElement as Z,useElements as J,useStripe as X}from"@stripe/react-stripe-js";import{loadStripe as ee}from"@stripe/stripe-js";import{useCurrency as R}from"../CurrencyContext.js";import{Notice as I}from"../Notice.js";import{resolveCopyright as te}from"../../lib/content/site.js";import{ApiError as O,products as T}from"../../lib/api/index.js";import re from"efficient-web-builder/render/components/Logo";import{NOT_CHECKED as _,orderReference as ne}from"../../lib/checkout/pay-first.js";import{CheckoutStateProvider as ae,useCheckout as ie}from"./checkout-state.js";import{CheckoutContact as oe,CheckoutOrderSummary as se,CheckoutPayment as ce,CheckoutShippingAddress as le,CheckoutShippingMethod as de}from"./checkout-parts.js";function me(t){return e(ae,{...t,children:e(fe,{})})}function pe({order:t,paid:n}){const{formatMoney:p}=R();if(!t.grandTotal||!t.currency)return null;const u=i=>p(Number(i),t.currency),h=Number(t.freightCharge??0),c=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(x,{children:[r("dt",{className:"text-fg-dim",children:["Delivery",t.shippingMethod?` · ${t.shippingMethod}`:""]}),e("dd",{className:"text-right font-mono",children:u(t.freightCharge??"0")})]}),c>0&&r(x,{children:[r("dt",{className:"text-fg-dim",children:["Discount",t.couponCode?` · ${t.couponCode}`:""]}),r("dd",{className:"text-right font-mono",children:["−",u(t.discountAmount??"0")]})]}),e("dt",{className:"text-fg",children:n?"Total paid":"Order total"}),e("dd",{className:"text-right font-mono text-fg",children:u(t.grandTotal)})]})}function ue({result:t}){const n=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 ",n,". Your payment is refunded to your card."]}):t.kind==="expired"?r(x,{children:["The hold on checkout ",n," ran out before your payment arrived. Your payment is refunded to your card."]}):t.kind==="processing"?r(x,{children:["Your payment for checkout ",n," is being processed. When it goes through, we will email your order confirmation."]}):r(x,{children:["Thank you — your payment for checkout ",n," has gone through. We will email you the order number shortly."]})}),e(S,{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 fe(){const{site:t,logo:n,items:p,placing:u,email:h,me:c,addressSaveNote:i,idemKey:f,confirmation:o,setConfirmation:m,payment:d,paypalStep:k,squareStep:g,pendingConf:s,paid:y,setPaid:b,payNote:N,afterpayConfirming:E,gocardlessConfirming:l,zipConfirming:a,klarnaConfirming:w,cardConfirming:P,checkoutResult:q,confirmCardPayment:L,cardStillProcessing:z,renewCardPayment:F,holdRenewed:H,leaveCardPayment:G,checkoutRootRef:U,setCheckoutHeaderEl:W}=ie();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(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(S,{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(pe,{order:o,paid:y}),N&&e("p",{className:"text-sm text-fg-dim",children:N}),i&&e("p",{className:"text-sm text-fg-dim",children:i}),!c&&r("p",{className:"text-sm text-fg-dim",children:["You can also"," ",e(S,{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(S,{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"})]}):q?e(ue,{result:q}):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:"Placing your order — one moment."})]}):E?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."})]}):l?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."})]}):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 Zip — 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:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Klarna — one moment."})]}):d&&s?e(xe,{payment:d,checkout:s,holdRenewed:H,onPaid:L,onProcessing:z,onRenew:F,onBack:G}):k&&s?e(be,{confirmation:s,clientId:t.paypalClientId??"",idemKey:f,onPaid:()=>{b(!0),m(s)},onSkip:()=>m(s)}):g&&s?e(ke,{confirmation:s,applicationId:t.squareApplicationId??"",locationId:t.squareLocationId??"",environment:t.squareEnvironment??"production",idemKey:f,onPaid:()=>{b(!0),m(s)},onSkip:()=>m(s)}):r("div",{ref:U,className:"bg-bg text-fg",children:[r("header",{ref:W,className:"sticky top-0 z-30 grid grid-cols-[1fr_auto_1fr] items-center gap-8 border-b border-line px-[var(--sf-site-gutter,40px)] py-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(S,{href:"/",className:"inline-flex items-center gap-3 font-mono text-[13px] uppercase tracking-[0.26em] text-fg-dim transition-colors hover:text-accent",children:["←",e("span",{className:"max-[640px]:hidden",children:"Back to shop"})]}),e(S,{href:"/","aria-label":`${t.name} home`,className:"inline-flex items-center justify-center",children:e(re,{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,siteName:t.name})}),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(C=>r("span",{className:["relative flex items-center gap-2 transition-colors",C.state==="pending"?"text-fg-dim":"text-fg",C.state==="active"?"font-bold after:absolute after:inset-x-0 after:-bottom-1 after:h-[2px] after:bg-accent":""].join(" "),children:[e("span",{className:C.state==="done"?"text-accent font-bold":"",children:C.n}),e("span",{children:C.label})]},C.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:[e(oe,{}),e(le,{}),e(de,{}),e(ce,{})]}),e(se,{})]}),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:te({legalName:t.legalName,foundedYear:t.foundedYear,siteName:t.name})})})]})}function xe({payment:t,checkout:n,holdRenewed:p,onPaid:u,onProcessing:h,onRenew:c,onBack:i}){const{formatMoney:f}=R(),o=e("span",{className:"text-fg",children:f(Number(t.amount),t.currency)}),m=Y(()=>ee(t.publishableKey),[t.publishableKey]),d=Y(()=>Q(),[]);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:ne(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 ",o," by card to confirm it now."]}):p?r(x,{children:["Your hold ran out, so your items are held again",n.expiresAt?` until ${B(n.expiresAt)}`:"",". Enter your card again, then pay ",o,"."]}):r(x,{children:["Your items are held",n.expiresAt?` until ${B(n.expiresAt)}`:"",". Pay ",o," by card to place your order."]})}),e(V,{stripe:m,options:{clientSecret:t.clientSecret,appearance:d},children:e(he,{payment:t,checkout:n,onPaid:u,onProcessing:h,onRenew:c,onBack:i})},t.clientSecret)]})]})})}function B(t){return new Date(t).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}const ge=5;function he({payment:t,checkout:n,onPaid:p,onProcessing:u,onRenew:h,onBack:c}){const{formatMoney:i}=R(),f=X(),o=J(),[m,d]=v(!1),[k,g]=v(null),s=j(!1);async function y(){try{return(await f.retrievePaymentIntent(t.clientSecret)).paymentIntent?.status}catch{return}}async function b(l){let a=l;for(let w=0;a==="processing"&&w<ge;w+=1)await new Promise(P=>setTimeout(P,1e3)),a=await y()??a;if(a==="succeeded"){p();return}if(a==="processing"){u();return}g("Payment did not complete. Please try again."),d(!1)}async function N(){if(!f||!o||m)return;d(!0),g(null),s.current=!0;const l=await f.confirmPayment({elements:o,redirect:"if_required"}).catch(()=>null);if(!l){const a=await y();if(a==="succeeded"||a==="processing"){await b(a);return}g(a===void 0?_:"Payment failed. Please try again."),d(!1);return}if(l.error){if(!n.orderNumber&&l.error.code==="payment_intent_unexpected_state"){const a=await y();if(a==="succeeded"||a==="processing"){await b(a);return}if(a===void 0){g(_),d(!1);return}await h(a==="canceled"),d(!1);return}g(l.error.message??"Payment failed. Please try again."),d(!1);return}await b(l.paymentIntent?.status)}async function E(){if(m)return;if(!s.current){c();return}d(!0),g(null);const l=await y();if(l==="succeeded"||l==="processing"){await b(l);return}if(d(!1),l===void 0){g(_);return}c()}return r("div",{className:"flex flex-col gap-4",children:[e(Z,{}),k&&e(I,{role:"alert",children:k}),e("button",{type:"button",onClick:N,disabled:!f||!o||m,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",!f||!o||m?"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:m?r(x,{children:["Processing… ",e("span",{children:"·"})]}):r(x,{children:["Pay ",i(Number(t.amount),t.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})}),!n.orderNumber&&!m&&r("button",{type:"button",onClick:E,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 M="paypal-sdk-js";let A=null;function ye(t,n){const p=`${t}|${n}`;if(A?.key===p)return A.promise;const u=new Promise((h,c)=>{document.getElementById(M)?.remove();const i=document.createElement("script");i.id=M;const f=new URLSearchParams({"client-id":t,currency:n,intent:"capture"});i.src=`https://www.paypal.com/sdk/js?${f}`,i.onload=()=>{const o=window.paypal;o?h(o):c(new Error("PayPal SDK loaded without its namespace"))},i.onerror=()=>c(new Error("PayPal SDK failed to load")),document.head.appendChild(i)});return A={key:p,promise:u},u}function be({confirmation:t,clientId:n,idemKey:p,onPaid:u,onSkip:h}){const{formatMoney:c}=R(),i=j(null),[f,o]=v(!1),[m,d]=v(null),k=j(u);return k.current=u,D(()=>{let g=!1,s=null;return ye(n,t.currency).then(y=>{if(!(g||!i.current))return s=y.Buttons({style:{layout:"vertical",color:"gold",shape:"rect",label:"paypal"},createOrder:async()=>(await T.createPaypalOrder({idempotencyKey:p})).paypalOrderId,onApprove:async b=>{try{if((await T.capturePaypalOrder({idempotencyKey:p,paypalOrderId:b.orderID})).status==="paid"){k.current();return}d("PayPal did not complete the payment. Please try again.")}catch(N){d(N instanceof O?N.message:"PayPal payment failed. Please try again.")}},onError:()=>{d("PayPal could not process the payment. Please try again.")}}),s.render(i.current).then(()=>{g||o(!0)})}).catch(()=>{g||d("PayPal could not be loaded. You can pay later — your order stands either way.")}),()=>{g=!0,s?.close?.()}},[n,t.currency,p]),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:c(Number(t.grandTotal),t.currency)})," ","with PayPal to confirm it now."]}),!f&&!m&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading PayPal…"}),e("div",{ref:i}),m&&e(I,{role:"alert",children:m}),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 K=null;function Ne(t){const n=t==="sandbox"?"sandbox":"production";if(K?.key===n)return K.promise;const p=new Promise((u,h)=>{document.getElementById($)?.remove();const c=document.createElement("script");c.id=$,c.src=n==="sandbox"?"https://sandbox.web.squarecdn.com/v1/square.js":"https://web.squarecdn.com/v1/square.js",c.onload=()=>{const i=window.Square;i?u(i):h(new Error("Square SDK loaded without its namespace"))},c.onerror=()=>h(new Error("Square SDK failed to load")),document.head.appendChild(c)});return K={key:n,promise:p},p}function ke({confirmation:t,applicationId:n,locationId:p,environment:u,idemKey:h,onPaid:c,onSkip:i}){const{formatMoney:f}=R(),o=j(null),m=j(null),d=j(null),[k,g]=v(!1),[s,y]=v(!1),[b,N]=v(null);D(()=>{let l=!1,a=null;return Ne(u).then(async w=>{if(l||!o.current)return;const P=w.payments(n,p);d.current=P,a=await P.card(),await a.attach(o.current),m.current=a,l||g(!0)}).catch(()=>{l||N("Square could not be loaded. You can pay later — your order stands either way.")}),()=>{l=!0,a?.destroy?.()}},[n,p,u]);async function E(){const l=m.current;if(!(!l||s)){y(!0),N(null);try{const a=await l.tokenize();if(a.status!=="OK"||!a.token){N(a.errors?.[0]?.message??"Please check the card details and try again."),y(!1);return}let w;try{w=(await d.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"){c();return}N("Square did not complete the payment. Please try again.")}catch(a){N(a instanceof O?a.message:"Square payment failed. Please try again.")}y(!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:f(Number(t.grandTotal),t.currency)})," ","by card to confirm it now."]}),!k&&!b&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading card form…"}),e("div",{ref:o}),b&&e(I,{role:"alert",children:b}),e("button",{type:"button",onClick:E,disabled:!k||s,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",!k||s?"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:s?r(x,{children:["Processing… ",e("span",{children:"·"})]}):r(x,{children:["Pay ",f(Number(t.grandTotal),t.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})}),e("button",{type:"button",onClick:i,disabled:s,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{ue as PayFirstResultView,me as default};
|
|
1
|
+
"use client";import{jsx as e,jsxs as r,Fragment as x}from"react/jsx-runtime";import j from"next/link";import{useEffect as Y,useMemo as O,useRef as E,useState as v}from"react";import{stripeAppearance as V}from"../../lib/checkout/stripe-appearance.js";import{Elements as Z,PaymentElement as J,useElements as X,useStripe as ee}from"@stripe/react-stripe-js";import{loadStripe as te}from"@stripe/stripe-js";import{useCurrency as R}from"../CurrencyContext.js";import{Notice as q}from"../Notice.js";import{resolveCopyright as re}from"../../lib/content/site.js";import{ApiError as B,products as I}from"../../lib/api/index.js";import ne from"efficient-web-builder/render/components/Logo";import{NOT_CHECKED as T,orderReference as ae}from"../../lib/checkout/pay-first.js";import{CheckoutStateProvider as ie,useCheckout as oe}from"./checkout-state.js";import{CheckoutContact as ce,CheckoutOrderSummary as se,CheckoutPayment as le,CheckoutShippingAddress as de,CheckoutShippingMethod as me}from"./checkout-parts.js";function pe(t){return e(ie,{...t,children:e(xe,{})})}function ue({order:t,paid:n}){const{formatMoney:i}=R();if(!t.grandTotal||!t.currency)return null;const u=o=>i(Number(o),t.currency),h=Number(t.freightCharge??0),s=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(x,{children:[r("dt",{className:"text-fg-dim",children:["Delivery",t.shippingMethod?` · ${t.shippingMethod}`:""]}),e("dd",{className:"text-right font-mono",children:u(t.freightCharge??"0")})]}),s>0&&r(x,{children:[r("dt",{className:"text-fg-dim",children:["Discount",t.couponCode?` · ${t.couponCode}`:""]}),r("dd",{className:"text-right font-mono",children:["−",u(t.discountAmount??"0")]})]}),e("dt",{className:"text-fg",children:n?"Total paid":"Order total"}),e("dd",{className:"text-right font-mono text-fg",children:u(t.grandTotal)})]})}function fe({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(j,{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 xe(){const{site:t,logo:n,items:i,placing:u,email:h,me:s,addressSaveNote:o,lostChangeNote:f,idemKey:p,confirmation:d,setConfirmation:c,payment:k,paypalStep:g,squareStep:b,pendingConf:m,paid:y,setPaid:N,payNote:C,afterpayConfirming:l,gocardlessConfirming:a,zipConfirming:w,klarnaConfirming:P,cardConfirming:K,checkoutResult:D,confirmCardPayment:z,cardStillProcessing:F,renewCardPayment:H,holdRenewed:G,leaveCardPayment:U,checkoutRootRef:W,setCheckoutHeaderEl:Q}=oe();return 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:y?"Payment received":"Order received"}),r("p",{className:"text-fg-dim",children:[y?r(x,{children:["Thank you — your payment for order"," ",e("span",{className:"font-mono text-fg",children:d.orderNumber})," has gone through."," "]}):r(x,{children:["Thank you — your order ",e("span",{className:"font-mono text-fg",children:d.orderNumber})," is being reviewed by our team."," "]}),s?r(x,{children:["Track it under"," ",e(j,{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(ue,{order:d,paid:y}),f&&e("p",{className:"text-sm text-fg-dim",children:f}),C&&e("p",{className:"text-sm text-fg-dim",children:C}),o&&e("p",{className:"text-sm text-fg-dim",children:o}),!s&&r("p",{className:"text-sm text-fg-dim",children:["You can also"," ",e(j,{href:`/track?order=${encodeURIComponent(d.orderNumber)}`,className:"text-accent underline",children:"track this order"})," ","anytime with just your order number and email — no password needed."]}),e(j,{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(fe,{result:D,lostChangeNote:f}):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:"Placing your order — one moment."})]}):l?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."})]}):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:"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."})]}):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:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Zip — 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 Klarna — one moment."})]}):k&&m?e(ge,{payment:k,checkout:m,holdRenewed:G,onPaid:z,onProcessing:F,onRenew:H,onBack:U}):g&&m?e(Ne,{confirmation:m,clientId:t.paypalClientId??"",idemKey:p,onPaid:()=>{N(!0),c(m)},onSkip:()=>c(m)}):b&&m?e(we,{confirmation:m,applicationId:t.squareApplicationId??"",locationId:t.squareLocationId??"",environment:t.squareEnvironment??"production",idemKey:p,onPaid:()=>{N(!0),c(m)},onSkip:()=>c(m)}):r("div",{ref:W,className:"bg-bg text-fg",children:[r("header",{ref:Q,className:"sticky top-0 z-30 grid grid-cols-[1fr_auto_1fr] items-center gap-8 border-b border-line px-[var(--sf-site-gutter,40px)] py-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(j,{href:"/",className:"inline-flex items-center gap-3 font-mono text-[13px] uppercase tracking-[0.26em] text-fg-dim transition-colors hover:text-accent",children:["←",e("span",{className:"max-[640px]:hidden",children:"Back to shop"})]}),e(j,{href:"/","aria-label":`${t.name} home`,className:"inline-flex items-center justify-center",children:e(ne,{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,siteName:t.name})}),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:[e(ce,{}),e(de,{}),e(me,{}),e(le,{})]}),e(se,{})]}),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:re({legalName:t.legalName,foundedYear:t.foundedYear,siteName:t.name})})})]})}function ge({payment:t,checkout:n,holdRenewed:i,onPaid:u,onProcessing:h,onRenew:s,onBack:o}){const{formatMoney:f}=R(),p=e("span",{className:"text-fg",children:f(Number(t.amount),t.currency)}),d=O(()=>te(t.publishableKey),[t.publishableKey]),c=O(()=>V(),[]);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:ae(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 ",p," by card to confirm it now."]}):i?r(x,{children:["Your hold ran out, so your items are held again",n.expiresAt?` until ${M(n.expiresAt)}`:"",". Enter your card again, then pay ",p,"."]}):r(x,{children:["Your items are held",n.expiresAt?` until ${M(n.expiresAt)}`:"",". Pay ",p," by card to place your order."]})}),e(Z,{stripe:d,options:{clientSecret:t.clientSecret,appearance:c},children:e(ye,{payment:t,checkout:n,onPaid:u,onProcessing:h,onRenew:s,onBack:o})},t.clientSecret)]})]})})}function M(t){return new Date(t).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}const he=5;function ye({payment:t,checkout:n,onPaid:i,onProcessing:u,onRenew:h,onBack:s}){const{formatMoney:o}=R(),f=ee(),p=X(),[d,c]=v(!1),[k,g]=v(null),b=E(!1);async function m(){try{return(await f.retrievePaymentIntent(t.clientSecret)).paymentIntent?.status}catch{return}}async function y(l){let a=l;for(let w=0;a==="processing"&&w<he;w+=1)await new Promise(P=>setTimeout(P,1e3)),a=await m()??a;if(a==="succeeded"){i();return}if(a==="processing"){u();return}g("Payment did not complete. Please try again."),c(!1)}async function N(){if(!f||!p||d)return;c(!0),g(null),b.current=!0;const l=await f.confirmPayment({elements:p,redirect:"if_required"}).catch(()=>null);if(!l){const a=await m();if(a==="succeeded"||a==="processing"){await y(a);return}g(a===void 0?T:"Payment failed. Please try again."),c(!1);return}if(l.error){if(!n.orderNumber&&l.error.code==="payment_intent_unexpected_state"){const a=await m();if(a==="succeeded"||a==="processing"){await y(a);return}if(a===void 0){g(T),c(!1);return}await h(a==="canceled"),c(!1);return}g(l.error.message??"Payment failed. Please try again."),c(!1);return}await y(l.paymentIntent?.status)}async function C(){if(d)return;if(!b.current){s();return}c(!0),g(null);const l=await m();if(l==="succeeded"||l==="processing"){await y(l);return}if(c(!1),l===void 0){g(T);return}s()}return r("div",{className:"flex flex-col gap-4",children:[e(J,{}),k&&e(q,{role:"alert",children:k}),e("button",{type:"button",onClick:N,disabled:!f||!p||d,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",!f||!p||d?"cursor-not-allowed border-line bg-surface text-fg-dim":"border-btn bg-btn text-btn-ink hover:border-fg hover:bg-fg"].join(" "),children:d?r(x,{children:["Processing… ",e("span",{children:"·"})]}):r(x,{children:["Pay ",o(Number(t.amount),t.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})}),!n.orderNumber&&!d&&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 $="paypal-sdk-js";let _=null;function be(t,n){const i=`${t}|${n}`;if(_?.key===i)return _.promise;const u=new Promise((h,s)=>{document.getElementById($)?.remove();const o=document.createElement("script");o.id=$;const f=new URLSearchParams({"client-id":t,currency:n,intent:"capture"});o.src=`https://www.paypal.com/sdk/js?${f}`,o.onload=()=>{const p=window.paypal;p?h(p):s(new Error("PayPal SDK loaded without its namespace"))},o.onerror=()=>s(new Error("PayPal SDK failed to load")),document.head.appendChild(o)});return _={key:i,promise:u},u}function Ne({confirmation:t,clientId:n,idemKey:i,onPaid:u,onSkip:h}){const{formatMoney:s}=R(),o=E(null),[f,p]=v(!1),[d,c]=v(null),k=E(u);return k.current=u,Y(()=>{let g=!1,b=null;return be(n,t.currency).then(m=>{if(!(g||!o.current))return b=m.Buttons({style:{layout:"vertical",color:"gold",shape:"rect",label:"paypal"},createOrder:async()=>(await I.createPaypalOrder({idempotencyKey:i})).paypalOrderId,onApprove:async y=>{try{if((await I.capturePaypalOrder({idempotencyKey:i,paypalOrderId:y.orderID})).status==="paid"){k.current();return}c("PayPal did not complete the payment. Please try again.")}catch(N){c(N instanceof B?N.message:"PayPal payment failed. Please try again.")}},onError:()=>{c("PayPal could not process the payment. Please try again.")}}),b.render(o.current).then(()=>{g||p(!0)})}).catch(()=>{g||c("PayPal could not be loaded. You can pay later — your order stands either way.")}),()=>{g=!0,b?.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:s(Number(t.grandTotal),t.currency)})," ","with PayPal to confirm it now."]}),!f&&!d&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading PayPal…"}),e("div",{ref:o}),d&&e(q,{role:"alert",children:d}),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 L="square-web-sdk";let A=null;function ke(t){const n=t==="sandbox"?"sandbox":"production";if(A?.key===n)return A.promise;const i=new Promise((u,h)=>{document.getElementById(L)?.remove();const s=document.createElement("script");s.id=L,s.src=n==="sandbox"?"https://sandbox.web.squarecdn.com/v1/square.js":"https://web.squarecdn.com/v1/square.js",s.onload=()=>{const o=window.Square;o?u(o):h(new Error("Square SDK loaded without its namespace"))},s.onerror=()=>h(new Error("Square SDK failed to load")),document.head.appendChild(s)});return A={key:n,promise:i},i}function we({confirmation:t,applicationId:n,locationId:i,environment:u,idemKey:h,onPaid:s,onSkip:o}){const{formatMoney:f}=R(),p=E(null),d=E(null),c=E(null),[k,g]=v(!1),[b,m]=v(!1),[y,N]=v(null);Y(()=>{let l=!1,a=null;return ke(u).then(async w=>{if(l||!p.current)return;const P=w.payments(n,i);c.current=P,a=await P.card(),await a.attach(p.current),d.current=a,l||g(!0)}).catch(()=>{l||N("Square could not be loaded. You can pay later — your order stands either way.")}),()=>{l=!0,a?.destroy?.()}},[n,i,u]);async function C(){const l=d.current;if(!(!l||b)){m(!0),N(null);try{const a=await l.tokenize();if(a.status!=="OK"||!a.token){N(a.errors?.[0]?.message??"Please check the card details and try again."),m(!1);return}let w;try{w=(await c.current?.verifyBuyer?.(a.token,{amount:String(t.grandTotal),currencyCode:t.currency,intent:"CHARGE"}))?.token}catch{}if((await I.chargeSquare({idempotencyKey:h,sourceId:a.token,...w?{verificationToken:w}:{}})).status==="paid"){s();return}N("Square did not complete the payment. Please try again.")}catch(a){N(a instanceof B?a.message:"Square payment failed. Please try again.")}m(!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:f(Number(t.grandTotal),t.currency)})," ","by card to confirm it now."]}),!k&&!y&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading card form…"}),e("div",{ref:p}),y&&e(q,{role:"alert",children:y}),e("button",{type:"button",onClick:C,disabled:!k||b,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",!k||b?"cursor-not-allowed border-line bg-surface text-fg-dim":"border-btn bg-btn text-btn-ink hover:border-fg hover:bg-fg"].join(" "),children:b?r(x,{children:["Processing… ",e("span",{children:"·"})]}):r(x,{children:["Pay ",f(Number(t.grandTotal),t.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})}),e("button",{type:"button",onClick:o,disabled:b,className:"self-center font-mono text-[11px] uppercase tracking-[0.24em] text-fg-dim underline-offset-4 transition-colors hover:text-accent hover:underline",children:"Pay later — our team will be in touch"})]})]})})}export{fe as PayFirstResultView,pe as default};
|
|
@@ -129,6 +129,7 @@ declare function useCheckoutState({ site, logo, preview }: CheckoutProps): {
|
|
|
129
129
|
saveLabel: string;
|
|
130
130
|
setSaveLabel: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
131
131
|
addressSaveNote: string | null;
|
|
132
|
+
lostChangeNote: string | null;
|
|
132
133
|
idemKey: string;
|
|
133
134
|
confirmation: LandingOrder | null;
|
|
134
135
|
setConfirmation: import("react").Dispatch<import("react").SetStateAction<LandingOrder | null>>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
2
|
-
`);return
|
|
3
|
-
${Ae.trim()}`:te,E=JSON.stringify([D,O,J,G,fe,$,v,T,u,i.map(e=>[e.id,e.qty]),Q,It(M),h,A.currency,le?.id??null]),ye=f(null),P=f(!1),H=f(null),he=f(!1),we=f(E);we.current=E;const yt=f(ee);yt.current=ee;const ht=()=>P.current&&we.current!==ye.current,_=f(null);m(()=>{yt.current||(E!==_.current&&(_.current=null),!(!P.current||!g||g.orderNumber)&&(E===ye.current||E===_.current||ge(g)))},[E,g]);async function ge(e){if(!he.current){he.current=!0,b(!0);try{const t=H.current?await $n(H.current):"none";if(t==="succeeded"||t==="processing"){P.current=!1,K(null),t==="succeeded"?await I(void 0,e):bt(e);return}if(t===void 0||!Mn.has(t)){_.current=we.current,K(e),w(t==="requires_action"?Rn:Fe);return}const n=await Et(Y);if(n==="committed"){P.current=!1,K(null),await I(void 0,e);return}if(n!=="released"){_.current=we.current,K(e),w(Fe);return}P.current=!1,H.current=null,_.current=null,w(null),K(null),Ie(Ce())}finally{he.current=!1,b(!1)}}}async function pn(){if(d||ee||he.current)return;if(g){if(P.current&&!g.orderNumber&&E!==ye.current){await ge(g);return}b(!0),w(null),await Me();const r=g.orderNumber?h:"card";r!==h&&be(r),await Nt(g,r,!g.orderNumber);return}if(i.length===0||A.repricing||!h||!z.some(r=>r.key===h))return;const e=i.filter(vt).flatMap(r=>vn(r.components,r.qty));if(e.length===0){w("Pick a size on each wheel's product page before checking out.");return}b(!0),w(null);let t,n=Y;try{const r=le?y.createOrderAuthed:y.createOrder,o=Nn(),s={customer:{email:D,name:`${O} ${J}`.trim(),phone:G.trim()||void 0,address:fe,city:$,state:v||void 0,zipCode:T,country:u},items:e,currency:A.currency,idempotencyKey:Y,shippingMethodId:Q??void 0,couponCode:It(M),...o==="denied"?{}:bn(),...o?{adConsent:o}:{},...Ln(h)?{checkoutFlow:Kt}:{}};B.current=()=>r(s),H.current=null,P.current=!1,_.current=null,ye.current=E,pe.current=i,kt(s,r);const l=await(!s.checkoutFlow&&Re.current===s.idempotencyKey?wt(s,r):r(s).then(R=>({answer:R,request:s})).catch(R=>mn(R,s,r)));if(!l)return;t=l.answer,n=l.request.idempotencyKey,t.orderNumber&&(Ct(t),L()),await Me()}catch(r){const o=Fn(r);o?(Mt(o),w(`${o} Your order has not been placed. Place it again to continue without the code.`)):r instanceof _t?w(Fe):w(r instanceof ke?r.message:"Could not place the order. Please try again."),b(!1);return}await Nt(t,h,!1,n)}async function mn(e,t,n){if(Ye(e))return gt(t,n);if(!_n(e))throw e;return Re.current=t.idempotencyKey,wt(t,n)}async function wt(e,t){const n=await Et(e.idempotencyKey);if(n==="released")return gt(e,t);if(n!=="committed")throw new _t;const r=_e.current?.key===e.idempotencyKey?_e.current:null;pe.current=r?.lines??i;const o=r?.send??(()=>t({...e,checkoutFlow:Kt}));B.current=o;const s=await o();return b(!1),await I(s,{...s,orderNumber:""}),await Me(),null}async function gt(e,t){const n={...e,idempotencyKey:Ce()};return Re.current=null,Ie(n.idempotencyKey),B.current=()=>t(n),kt(n,t),{answer:await t(n),request:n}}function kt(e,t){e.checkoutFlow&&(_e.current={key:e.idempotencyKey,send:()=>t(e),lines:i})}function Ct(e){Sn({confirmation:e,lines:pe.current,adsSendTo:a.googleAdsId&&a.googleAdsConversionLabel?`${a.googleAdsId}/${a.googleAdsConversionLabel}`:null}),An({confirmation:e,lines:pe.current})}async function I(e,t=x){if(!t)return;const n=e?async()=>e:B.current;if(t.orderNumber||!n){U(!0),k(t);return}L(),await Yn({checkoutNumber:t.checkoutNumber,resend:n,page:{setConfirming:an,land:k,markPaid:()=>U(!0),track:Ct,unplaced:lt}})}function bt(e=x){if(e){if(e.orderNumber){k(e);return}L(),lt({kind:"processing",checkoutNumber:e.checkoutNumber})}}async function Me(){const e=JSON.stringify([Ee.trim(),O,J,G.trim(),fe,$,v,T,u]);if(!(!le||!Ve||Qe!=="new"||nt.current===e))try{await j.createAddress({label:Ee.trim()||"Home",contact_name:`${O} ${J}`.trim(),phone:G.trim(),address:fe,city:$,zip_code:T,state:v,country:u}),nt.current=e,tt("Address saved to your account.")}catch{tt("We couldn't save the address to your account — you can add it under Account → Addresses.")}}async function Nt(e,t=h,n=!1,r=Y){K(null);try{if(t==="card"&&a.paymentMethods.includes("card")){const o=await y.createPaymentIntent({idempotencyKey:r});if(H.current=o,n&&ht()){await ge(e);return}let s=e;if(n){const l=await B.current?.().catch(()=>null);if(l?.orderNumber){await I(l,e);return}if(s=Pt(e,l)??{...e,expiresAt:null},ht()){await ge(e);return}}F(s),Oe(!1),de(o)}else if(t==="paypal"&&a.paymentMethods.includes("paypal"))F(e),Zt(!0);else if(t==="afterpay"&&a.paymentMethods.includes("afterpay")){const o=window.location.origin,s=await y.createAfterpayCheckout({idempotencyKey:r,confirmUrl:`${o}/checkout?afterpay=confirm`,cancelUrl:`${o}/checkout?afterpay=cancel`}),l={idempotencyKey:r,confirmation:e};C.setItem(Kn,JSON.stringify(l)),window.location.assign(s.redirectCheckoutUrl);return}else if(t==="square"&&a.paymentMethods.includes("square"))F(e),jt(!0);else if(t==="gocardless"&&a.paymentMethods.includes("gocardless")){const o=window.location.origin,s=await y.createGocardlessBillingRequest({idempotencyKey:r,confirmUrl:`${o}/checkout?gocardless=confirm`,cancelUrl:`${o}/checkout?gocardless=cancel`}),l={idempotencyKey:r,confirmation:e};C.setItem(Le,JSON.stringify(l)),window.location.assign(s.authorisationUrl);return}else if(t==="zip"&&a.paymentMethods.includes("zip")){const o=window.location.origin,s=await y.createZipCheckout({idempotencyKey:r,redirectUrl:`${o}/checkout?zip=return`}),l={idempotencyKey:r,confirmation:e};C.setItem(In,JSON.stringify(l)),window.location.assign(s.redirectUrl);return}else if(t==="klarna"&&a.paymentMethods.includes("klarna")){const o=window.location.origin,s=await y.createKlarnaCheckout({idempotencyKey:r,confirmUrl:`${o}/checkout?klarna=confirm`,cancelUrl:`${o}/checkout?klarna=cancel`}),l={idempotencyKey:r,confirmation:e};C.setItem($e,JSON.stringify(l)),window.location.assign(s.redirectUrl);return}else k(e)}catch(o){if((n||t==="card")&&o instanceof ke&&o.status===409){await I(void 0,e);return}St(e,o),b(!1)}}function Pt(e,t){return t&&!t.orderNumber&&t.status==="open"&&t.checkoutNumber===e.checkoutNumber?t:null}function St(e,t){w(Un(e,t)),!e.orderNumber&&Ye(t)?(P.current=!1,Ie(Ce())):K(e)}async function fn(e){if(!x)return;const t=x;try{const n=await y.createPaymentIntent({idempotencyKey:Y}),r=await B.current?.().catch(()=>null);if(r?.orderNumber){await I(r);return}const o=Pt(t,r);F(o??{...t,expiresAt:null}),Oe(e&&o!==null),H.current=n,de(n)}catch(n){if(n instanceof ke&&n.status===409){await I();return}de(null),F(null),St(t,n),b(!1)}}function yn(){x&&(P.current=!0,K(x),de(null),F(null),Oe(!1),b(!1))}return{site:a,logo:p,items:i,totals:A,coupon:M,deliveryOptions:Ue,courierUnavailable:qt,retryCourier:Dt,shippingMethodId:Q,setShippingMethodId:Lt,pickupLocation:Ft,servedCountries:q,formatMoney:Ut,payChoice:h,setPayChoice:be,placing:ee,email:D,setEmail:Ne,firstName:O,setFirstName:Pe,lastName:J,setLastName:Se,address1:te,setAddress1:ne,address2:Ae,setAddress2:re,city:$,setCity:oe,postcode:T,setPostcode:ce,phone:G,setPhone:ae,country:u,setCountry:se,subdivision:v,setSubdivision:ie,subdivisions:W,destination:We,postcodeLabel:zt,subdivisionLabel:Ht,me:le,savedAddresses:Jt,selectedAddressId:Qe,setSelectedAddressId:Ke,saveAddress:Ve,setSaveAddress:et,saveLabel:Ee,setSaveLabel:Gt,addressSaveNote:Wt,idemKey:Y,confirmation:rt,setConfirmation:k,orderError:Xt,payment:ot,paypalStep:ct,squareStep:at,pendingConf:x,paid:Qt,setPaid:U,unpaidOrder:g,payNote:Vt,afterpayConfirming:en,gocardlessConfirming:nn,zipConfirming:rn,klarnaConfirming:cn,cardConfirming:ut,checkoutResult:Te,confirmCardPayment:I,cardStillProcessing:bt,renewCardPayment:fn,holdRenewed:sn,leaveCardPayment:yn,checkoutRootRef:mt,setCheckoutHeaderEl:un,fillFromAddress:ft,checkoutSignOut:ln,payOptions:z,noPaymentMethod:dn,placeOrder:pn}}const Rt=wn(null);function sr({children:a,...p}){const d=Bn(p);return S(Rt.Provider,{value:d,children:a})}function ir(){const a=gn(Rt);if(!a)throw new Error("useCheckout must be used inside CheckoutStateProvider");return a}export{sr as CheckoutStateProvider,cr as NO_PAYMENT_METHOD_NOTE,ar as SHIPPING_RETRY_NOTE,Tt as buildPayOptions,Un as paymentNotStartedMessage,ir as useCheckout};
|
|
1
|
+
"use client";import{jsx as T}from"react/jsx-runtime";import{createContext as Un,useContext as Bn,useEffect as y,useMemo as zt,useRef as f,useState as o}from"react";import{isOrderable as Dt,useCart as Hn}from"../CartContext.js";import{useCurrency as zn}from"../CurrencyContext.js";import{getClickIds as Dn}from"../../lib/click-ids.js";import{adConsentForOrder as qn}from"../../lib/consent/choice.js";import{trackBeginCheckout as Gn,trackPurchase as Jn}from"../../lib/google-tag.js";import{trackMetaPurchase as Wn}from"../../lib/meta-pixel.js";import{ApiError as Te,api as ie,products as C}from"../../lib/api/index.js";import{uuid as ue}from"../../lib/uuid.js";import{orderLinesForSets as Xn}from"../../lib/commerce.js";import{canPersist as Zn,safeSessionStorage as v}from"efficient-web-builder/format/lib/safe-storage";import{AFTERPAY_CONTEXT_KEY as jn,AFTERPAY_RETURN as Qn,GOCARDLESS_CONTEXT_KEY as qe,KLARNA_CONTEXT_KEY as Ge,ZIP_CONTEXT_KEY as Vn,ZIP_RETURN as er,runWalletReturn as qt}from"../../lib/checkout/wallet-return.js";import{matchSubdivision as tr}from"../../lib/checkout/match-subdivision.js";import{checkoutGone as Je,checkoutWaiting as Gt,BANK_WAITING as nr,DROPPABLE_INTENT as rr,NOT_CHECKED as We,LOST_CHANGE as Jt,PAY_FIRST_FLOW as Wt,paysFirst as or,readIntentStatus as cr,releaseHeldCheckout as Xt,CHECKOUT_COMMITTED as ar,goodsShapeOf as sr,refusedForGood as Zt,settlePayFirst as ir}from"../../lib/checkout/pay-first.js";import{couponCodeForOrder as jt,couponRefusedByOrder as ur}from"../../lib/cart/coupon-preview.js";function Qt(a){const m=a.indexOf(`
|
|
2
|
+
`);return m===-1?[a,""]:[a.slice(0,m),a.slice(m+1)]}function Vt(a,{canParkContext:m}={canParkContext:!0}){const p=a.paymentMethods,i=[];return p.includes("card")&&i.push({key:"card",title:"Card",body:null,price:T("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"VISA · MC · AMEX"})}),p.includes("paypal")&&a.paypalClientId&&i.push({key:"paypal",title:"PayPal",body:null,price:T("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAYPAL · CARDS"})}),p.includes("afterpay")&&i.push({key:"afterpay",title:"Afterpay",body:null,price:T("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"4 × INTEREST-FREE"})}),p.includes("square")&&a.squareApplicationId&&a.squareLocationId&&i.push({key:"square",title:"Card (Square)",body:null,price:T("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"VISA · MC · AMEX"})}),p.includes("gocardless")&&m&&i.push({key:"gocardless",title:"Bank Direct Debit",body:null,price:T("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY BY BANK"})}),p.includes("zip")&&i.push({key:"zip",title:"Zip",body:null,price:T("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY IN 4"})}),p.includes("klarna")&&m&&i.push({key:"klarna",title:"Klarna",body:null,price:T("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-accent",children:"PAY LATER"})}),p.includes("bank")&&i.push({key:"bank",title:"Bank transfer",body:null,price:T("span",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Invoiced"})}),i}const xr="This shop does not take payment online yet. Please contact the shop to order.";class Ie extends Error{}function en(a,m){if(!a.orderNumber&&Je(m))return m.message;const p=m instanceof Te?` (${m.message})`:"";return a.orderNumber?`Your order ${a.orderNumber} is saved, but the payment did not start${p}. Try the payment again — your order will not be placed twice.`:`Your items are held under ${a.checkoutNumber}, but the payment did not start${p}. Try the payment again — you will not be charged twice.`}const tn=new Set(["paypal","square","afterpay","gocardless","zip","klarna"]),z=a=>JSON.parse(a),Or="Shipping cannot be calculated right now. Please try again.";function lr({site:a,logo:m,preview:p=!1}){const{items:i,totals:I,coupon:D,refuseCoupon:rn,deliveryOptions:Xe,shippingMethodId:le,setShippingMethodId:on,setQuoteDestination:de,courier:cn,requote:an,identify:Ze,clearCapturedCart:q,replaceItems:je,removeCoupon:Qe}=Hn(),sn=Xe.find(e=>e.id===le)?.pickupLocation??null,{country:Ve,countries:Q,activeCountry:et,formatMoney:un}=zn(),[w,pe]=o(()=>Vt(a)[0]?.key??null),[tt,ln]=o(!0);y(()=>{ln(Zn(v))},[]);const[fe,S]=o(!1),[V,_e]=o(""),[L,Me]=o(""),[ee,Re]=o(""),[me,ye]=o(""),[Le,he]=o(""),[G,we]=o(""),[$,ge]=o(""),[te,ke]=o(""),[l,Ce]=o(()=>Ve||Q[0]?.code||""),[_,be]=o(""),[ne,nt]=o([]),[$e,Fe]=o(null),[Ne,re]=o(null),rt=zt(()=>Q.find(e=>e.code===l)??et,[Q,l,et]),dn=rt?.postalLabel||"Postal Code",pn=ne[0]?.divisionType||"State / Province";y(()=>{if(!l){nt([]),Fe(l);return}Fe(null);let e=!1;return C.listCountrySubdivisions(l).then(t=>{e||(nt(t),Fe(l),be(""))}),()=>{e=!0}},[l]);const ot=me.trim()!==""&&G.trim()!==""&&$.trim()!==""&&$e===l&&(ne.length===0||_!=="")?$.trim():"";y(()=>{de(l?{country:l,subdivision:_,postcode:ot}:null)},[l,_,ot,de]),y(()=>()=>de(null),[de]);const fn=cn?.status==="unavailable",mn=an,[Pe,ct]=o(null),[yn,at]=o([]),[st,Ye]=o("new"),[it,ut]=o(!1),[Ue,hn]=o("Home"),[wn,lt]=o(null),[gn,dt]=o(null),[oe,Se]=o(()=>ue()),pt=f(null),[ft,A]=o(null),[kn,b]=o(null),[mt,Ae]=o(null),[yt,Cn]=o(!1),[ht,bn]=o(!1),[M,J]=o(null),[Nn,W]=o(!1),[N,K]=o(null),[Pn,x]=o(null),[Sn,An]=o(!1),[vn,wt]=o(!1),[Kn,xn]=o(!1),[On,gt]=o(!1),[kt,En]=o(!1),[Tn,Be]=o(!1),[He,Ct]=o(null),F=f(null),ce=f(i),Y=f(null),X=f(null),bt=!!(ft||He&&He.kind!=="processing"||kt||yt||ht||mt&&M?.orderNumber);y(()=>{bt&&(je([]),Qe())},[bt,je,Qe]);const Nt=f(!1);y(()=>{p||Nt.current||!i.some(Dt)||(Nt.current=!0,Gn({lines:i,currency:I.currency,value:I.subtotal-I.discount,coupon:D?.valid?D.code:void 0}))},[i,I,D,p]),y(()=>{Ze(V,L.trim()||void 0)},[V,L,Ze]);const Pt=f(null),[ve,In]=o(null);y(()=>{const e=Pt.current;if(!ve||!e)return;const t=()=>e.style.setProperty("--sf-checkout-header-h",`${ve.offsetHeight}px`);t();const n=new ResizeObserver(t);return n.observe(ve),()=>n.disconnect()},[ve]),y(()=>{const e=n=>({setConfirming:n,land:A,markPaid:()=>W(!0),note:x,fail:b,clearCart:q}),t={search:window.location.search,storage:v,scrubQuery:()=>window.history.replaceState(null,"",window.location.pathname)};qt(Qn,{...t,capture:C.captureAfterpayPayment,page:e(An)}),qt(er,{...t,capture:C.captureZipPayment,page:e(xn)})},[]),y(()=>{const t=new URLSearchParams(window.location.search).get("gocardless");if(t!=="confirm"&&t!=="cancel")return;const n=v.getItem(qe);if(v.removeItem(qe),window.history.replaceState(null,"",window.location.pathname),!n)return;let c;try{c=JSON.parse(n)}catch{return}if(q(),t==="cancel"){x("The direct debit was not set up — our team will follow up on payment."),A(c.confirmation);return}wt(!0),C.completeGocardlessPayment({idempotencyKey:c.idempotencyKey}).then(r=>{r.status==="paid"?W(!0):r.status==="declined"?x("The direct debit was declined — our team will follow up on payment."):x("Your direct debit is set up — the payment is collecting and will clear in a few days.")}).catch(()=>{x("We could not confirm the direct debit — our team will follow up on payment.")}).finally(()=>{A(c.confirmation),wt(!1)})},[]),y(()=>{const e=new URLSearchParams(window.location.search),t=e.get("klarna");if(t!=="confirm"&&t!=="cancel")return;const n=v.getItem(Ge);v.removeItem(Ge);const c=e.get("authorization_token");if(window.history.replaceState(null,"",window.location.pathname),!n)return;let r;try{r=JSON.parse(n)}catch{return}if(q(),t==="cancel"||!c){x("The Klarna payment was not completed — our team will follow up on payment."),A(r.confirmation);return}gt(!0),C.captureKlarnaPayment({idempotencyKey:r.idempotencyKey,authorizationToken:c}).then(u=>{u.status==="paid"?W(!0):u.status==="declined"?x("Klarna declined the payment — our team will follow up on payment."):x("Your Klarna payment is being reviewed — we'll confirm the outcome shortly.")}).catch(()=>{x("We could not confirm the Klarna payment — our team will follow up on payment.")}).finally(()=>{A(r.confirmation),gt(!1)})},[]);function St(e){const[t,n]=Qt(e.address);ye(t),he(n),we(e.city),ge(e.zip_code),e.country&&Ce(e.country),e.phone&&ke(e.phone),re({country:e.country||null,state:e.state??""})}y(()=>{if(Ne){if((Ne.country||l)!==l){re(null);return}$e===l&&(be(tr(l,Ne.state,ne)),re(null))}},[Ne,l,$e,ne]),y(()=>{let e=!1;return(async()=>{try{const[t,n,c]=await Promise.all([ie.me(),ie.myProfile().catch(()=>null),ie.myAddresses().catch(()=>[])]);if(e)return;ct(t);const r=c.filter(d=>d.is_active);at(r),_e(t.email);const u=(n?.contact_name??"").split(/\s+/);Me(t.first_name||u[0]||""),Re(t.last_name||u.slice(1).join(" "));const s=t.phone||n?.phone;s&&ke(s);const g=r.find(d=>d.id===t.default_delivery_location)??r[0];if(g)Ye(g.id),St(g);else if(n){const[d,k]=Qt(n.address??"");ye(d),he(k),we(n.city??""),ge(n.zip_code??""),n.country&&Ce(n.country),re({country:n.country||null,state:n.state??""})}}catch{}})(),()=>{e=!0}},[]);function _n(){ie.logout(),ct(null),at([]),Ye("new"),ut(!1),_e(""),Me(""),Re(""),ye(""),he(""),we(""),ge(""),ke(""),Ce(Ve||Q[0]?.code||""),be(""),re(null)}const Z=zt(()=>Vt(a,{canParkContext:tt}),[a,tt]);y(()=>{Z.some(e=>e.key===w)||pe(Z[0]?.key??null)},[Z,w]);const Mn=Z.length===0,Ke=Le.trim()?`${me}
|
|
3
|
+
${Le.trim()}`:me,Rn=sr({email:V,firstName:L,lastName:ee,phone:te,address:Ke,city:G,subdivision:_,postcode:$,country:l,lines:i.map(e=>[e.id,e.qty]),shippingMethodId:le,couponCode:jt(D),currency:I.currency,shopperId:Pe?.id??null}),h=JSON.stringify([Rn,w]),R=f(null),ze=f(null),xe=f(!1),O=f(!1),j=f(null),Oe=f(!1),P=f(h);P.current=h;const At=f(fe);At.current=fe;const vt=()=>O.current&&P.current!==R.current,U=f(null);y(()=>{At.current||(h!==U.current&&(U.current=null),!(!O.current||!N||N.orderNumber)&&(h===R.current||h===U.current||Ee(N)))},[h,N]);async function Ee(e){if(Oe.current)return null;Oe.current=!0,S(!0);try{const t=j.current?await cr(j.current):"none";if(t==="succeeded"||t==="processing")return O.current=!1,K(null),E("card"),t==="succeeded"?await B(void 0,e):Rt(e),null;if(t===void 0||!rr.has(t))return U.current=P.current,K(e),b(t==="requires_action"?nr:We),null;const n=await Xt(oe);if(n==="committed")return O.current=!1,K(null),E("card"),await B(void 0,e),null;if(n!=="released")return U.current=P.current,K(e),b(We),null;O.current=!1,j.current=null,U.current=null,b(null),K(null);const c=ue();return Se(c),c}finally{Oe.current=!1,S(!1)}}async function Ln(){if(!(p||fe||Oe.current)){if(N){if((O.current?h!==R.current:ae())&&!N.orderNumber){const c=await Ee(N);c&&P.current===h&&await Kt(c);return}S(!0),b(null),xe.current=!1,await De();const t=z(P.current)[1],n=N.orderNumber?t:"card";if(n&&tn.has(n)&&ae()&&z(P.current)[0]!==ze.current){xt(N);return}E(n),n!==w&&pe(n),await Lt(N,n,!N.orderNumber);return}await Kt(oe)}}async function Kt(e){if(i.length===0||I.repricing||!w||!Z.some(s=>s.key===w))return;const t=i.filter(Dt).flatMap(s=>Xn(s.components,s.qty));if(t.length===0){b("Pick a size on each wheel's product page before checking out.");return}S(!0),b(null);let n,c=e,r=w,u=!1;try{const s=Pe?C.createOrderAuthed:C.createOrder,g=qn(),d={customer:{email:V,name:`${L} ${ee}`.trim(),phone:te.trim()||void 0,address:Ke,city:G,state:_||void 0,zipCode:$,country:l},items:t,currency:I.currency,idempotencyKey:e,shippingMethodId:le??void 0,couponCode:jt(D),...g==="denied"?{}:Dn(),...g?{adConsent:g}:{},...or(w)?{checkoutFlow:Wt}:{}};F.current=()=>s(d),dt(null),ze.current=null,xe.current=!1,j.current=null,O.current=!1,U.current=null,R.current=h,ce.current=i;const k=Y.current,Yt=k?.key===d.idempotencyKey&&(k.shape!==h&&(!!d.checkoutFlow||!!k.method||!!k.plainMethod)||!!d.checkoutFlow&&!!k.plainMethod);Yt&&(X.current=d.idempotencyKey);const Ut=It(d,s),Bt=Yt||!d.checkoutFlow&&X.current===d.idempotencyKey,Ht=!Ut&&!Bt&&!d.checkoutFlow&&!!k&&!k.method;Ht&&(k.plainMethod=w,k.plainLines=i,k.plainShape=h);const H=await(Bt?Et(d,s):s(d).then(se=>({answer:se,request:d})).catch(se=>(Ut?Ot(se,d.idempotencyKey):Ht&&Zt(se)&&(k.plainMethod=""),$n(se,d,s))));if(!H)return;n=H.answer,c=H.request.idempotencyKey,r=H.method??r,E(r),u=ae()||r!==z(P.current)[1],H.method&&H.method!==w&&pe(H.method),n.orderNumber&&(_t(n),q()),await De()}catch(s){const g=ur(s);g?(rn(g),b(`${g} Your order has not been placed. Place it again to continue without the code.`)):s instanceof Ie?b(We):b(s instanceof Te?s.message:"Could not place the order. Please try again."),S(!1);return}if(r&&tn.has(r)&&(u||ae())){xt(n);return}await Lt(n,r,!1,c)}function xt(e){ze.current=z(P.current)[0],b(`${en(e,null)} ${Jt}`),K(e),S(!1)}function Ot(e,t){Zt(e)&&!Gt(e)&&Y.current?.key===t&&(Y.current=null)}async function $n(e,t,n){if(Je(e))return Tt(t,n);if(!Gt(e))throw e;return X.current=t.idempotencyKey,Et(t,n,!0)}async function Et(e,t,n=!1){const c=await Xt(e.idempotencyKey);if(c==="released")return P.current===h?Tt(e,t):(Se(ue()),S(!1),null);if(c!=="committed")throw new Ie;const r=Y.current?.key===e.idempotencyKey?Y.current:null;if(ce.current=r?.lines??i,r?.method&&!n){X.current=null,F.current=r.send;const g=await r.send().catch(()=>{throw new Ie});return R.current=r.shape,{answer:g,request:e,method:r.method}}const u=r&&!r.method?r.send:()=>t({...e,checkoutFlow:Wt});F.current=u;const s=await u().catch(()=>null);if(!s&&r?.plainMethod)throw new Ie;return s?.orderNumber&&s.status!==ar?(X.current=null,r?.plainMethod&&(ce.current=r.plainLines),r&&(R.current=r.plainMethod?r.plainShape:r.shape),{answer:s,request:e,method:r?.plainMethod||void 0}):(S(!1),r&&(R.current=r.shape),E("card"),await Mt("",s?async()=>s:()=>Promise.reject(new Error("The order request did not answer."))),await De(),null)}function ae(){const e=R.current;return e!==null&&z(e)[0]!==z(P.current)[0]}function E(e){e!==z(P.current)[1]&&(xe.current=!0),dt(xe.current||ae()?Jt:null)}async function Tt(e,t){const n={...e,idempotencyKey:ue()};X.current=null,Se(n.idempotencyKey),F.current=()=>t(n),It(n,t);try{return{answer:await t(n),request:n}}catch(c){throw Ot(c,n.idempotencyKey),c}}function It(e,t){return Y.current?.key===e.idempotencyKey?!1:(Y.current={key:e.idempotencyKey,send:()=>t(e),lines:i,shape:h,method:e.checkoutFlow?"":w??"",plainMethod:"",plainLines:i,plainShape:h},!0)}function _t(e){Jn({confirmation:e,lines:ce.current,adsSendTo:a.googleAdsId&&a.googleAdsConversionLabel?`${a.googleAdsId}/${a.googleAdsConversionLabel}`:null}),Wn({confirmation:e,lines:ce.current})}async function B(e,t=M){if(!t)return;const n=e?async()=>e:F.current;if(t.orderNumber||!n){W(!0),A(t);return}await Mt(t.checkoutNumber,n)}async function Mt(e,t){q(),await ir({checkoutNumber:e,resend:t,page:{setConfirming:En,land:A,markPaid:()=>W(!0),track:_t,unplaced:Ct}})}function Rt(e=M){if(e){if(e.orderNumber){A(e);return}q(),Ct({kind:"processing",checkoutNumber:e.checkoutNumber})}}async function De(){const e=JSON.stringify([Ue.trim(),L,ee,te.trim(),Ke,G,_,$,l]);if(!(!Pe||!it||st!=="new"||pt.current===e))try{await ie.createAddress({label:Ue.trim()||"Home",contact_name:`${L} ${ee}`.trim(),phone:te.trim(),address:Ke,city:G,zip_code:$,state:_,country:l}),pt.current=e,lt("Address saved to your account.")}catch{lt("We couldn't save the address to your account — you can add it under Account → Addresses.")}}async function Lt(e,t=w,n=!1,c=oe){K(null);try{if(t==="card"&&a.paymentMethods.includes("card")){const r=await C.createPaymentIntent({idempotencyKey:c});if(j.current=r,n&&vt()){await Ee(e);return}let u=e;if(n){const s=await F.current?.().catch(()=>null);if(s?.orderNumber){E("card"),await B(s,e);return}if(u=$t(e,s)??{...e,expiresAt:null},vt()){await Ee(e);return}}E("card"),J(u),Be(!1),Ae(r)}else if(t==="paypal"&&a.paymentMethods.includes("paypal"))J(e),Cn(!0);else if(t==="afterpay"&&a.paymentMethods.includes("afterpay")){const r=window.location.origin,u=await C.createAfterpayCheckout({idempotencyKey:c,confirmUrl:`${r}/checkout?afterpay=confirm`,cancelUrl:`${r}/checkout?afterpay=cancel`}),s={idempotencyKey:c,confirmation:e};v.setItem(jn,JSON.stringify(s)),window.location.assign(u.redirectCheckoutUrl);return}else if(t==="square"&&a.paymentMethods.includes("square"))J(e),bn(!0);else if(t==="gocardless"&&a.paymentMethods.includes("gocardless")){const r=window.location.origin,u=await C.createGocardlessBillingRequest({idempotencyKey:c,confirmUrl:`${r}/checkout?gocardless=confirm`,cancelUrl:`${r}/checkout?gocardless=cancel`}),s={idempotencyKey:c,confirmation:e};v.setItem(qe,JSON.stringify(s)),window.location.assign(u.authorisationUrl);return}else if(t==="zip"&&a.paymentMethods.includes("zip")){const r=window.location.origin,u=await C.createZipCheckout({idempotencyKey:c,redirectUrl:`${r}/checkout?zip=return`}),s={idempotencyKey:c,confirmation:e};v.setItem(Vn,JSON.stringify(s)),window.location.assign(u.redirectUrl);return}else if(t==="klarna"&&a.paymentMethods.includes("klarna")){const r=window.location.origin,u=await C.createKlarnaCheckout({idempotencyKey:c,confirmUrl:`${r}/checkout?klarna=confirm`,cancelUrl:`${r}/checkout?klarna=cancel`}),s={idempotencyKey:c,confirmation:e};v.setItem(Ge,JSON.stringify(s)),window.location.assign(u.redirectUrl);return}else E(t),A(e)}catch(r){if((n||t==="card")&&r instanceof Te&&r.status===409){E(t),await B(void 0,e);return}Ft(e,r),S(!1)}}function $t(e,t){return t&&!t.orderNumber&&t.status==="open"&&t.checkoutNumber===e.checkoutNumber?t:null}function Ft(e,t){b(en(e,t)),!e.orderNumber&&Je(t)?(O.current=!1,Se(ue())):K(e)}async function Fn(e){if(!M)return;const t=M;try{const n=await C.createPaymentIntent({idempotencyKey:oe}),c=await F.current?.().catch(()=>null);if(c?.orderNumber){await B(c);return}const r=$t(t,c);J(r??{...t,expiresAt:null}),Be(e&&r!==null),j.current=n,Ae(n)}catch(n){if(n instanceof Te&&n.status===409){await B();return}Ae(null),J(null),Ft(t,n),S(!1)}}function Yn(){M&&(O.current=!0,K(M),Ae(null),J(null),Be(!1),S(!1))}return{site:a,logo:m,items:i,totals:I,coupon:D,deliveryOptions:Xe,courierUnavailable:fn,retryCourier:mn,shippingMethodId:le,setShippingMethodId:on,pickupLocation:sn,servedCountries:Q,formatMoney:un,payChoice:w,setPayChoice:pe,placing:fe,email:V,setEmail:_e,firstName:L,setFirstName:Me,lastName:ee,setLastName:Re,address1:me,setAddress1:ye,address2:Le,setAddress2:he,city:G,setCity:we,postcode:$,setPostcode:ge,phone:te,setPhone:ke,country:l,setCountry:Ce,subdivision:_,setSubdivision:be,subdivisions:ne,destination:rt,postcodeLabel:dn,subdivisionLabel:pn,me:Pe,savedAddresses:yn,selectedAddressId:st,setSelectedAddressId:Ye,saveAddress:it,setSaveAddress:ut,saveLabel:Ue,setSaveLabel:hn,addressSaveNote:wn,lostChangeNote:gn,idemKey:oe,confirmation:ft,setConfirmation:A,orderError:kn,payment:mt,paypalStep:yt,squareStep:ht,pendingConf:M,paid:Nn,setPaid:W,unpaidOrder:N,payNote:Pn,afterpayConfirming:Sn,gocardlessConfirming:vn,zipConfirming:Kn,klarnaConfirming:On,cardConfirming:kt,checkoutResult:He,confirmCardPayment:B,cardStillProcessing:Rt,renewCardPayment:Fn,holdRenewed:Tn,leaveCardPayment:Yn,checkoutRootRef:Pt,setCheckoutHeaderEl:In,fillFromAddress:St,checkoutSignOut:_n,payOptions:Z,noPaymentMethod:Mn,placeOrder:Ln}}const nn=Un(null);function Er({children:a,...m}){const p=lr(m);return T(nn.Provider,{value:p,children:a})}function Tr(){const a=Bn(nn);if(!a)throw new Error("useCheckout must be used inside CheckoutStateProvider");return a}export{Er as CheckoutStateProvider,xr as NO_PAYMENT_METHOD_NOTE,Or as SHIPPING_RETRY_NOTE,Vt as buildPayOptions,en as paymentNotStartedMessage,Tr as useCheckout};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as r,Fragment as $,jsxs as j}from"react/jsx-runtime";import{CARD_IMAGE_SIZES as z}from"../../lib/sections/card-image-sizes.js";import{LISTING_CARD_SHOW as P}from"../../lib/sections/card-show-defaults.js";import M from"next/image";import{useState as U}from"react";import X from"../BrandPlate.js";import H,{CardBuyDialog as V}from"../card-pieces/CardBuyButton.js";import Z from"../card-pieces/CardFinishSwatches.js";import q from"../card-pieces/CardPrice.js";import J from"../card-pieces/CardProductBadge.js";import{useWheelCardState as K,WheelCardStateProvider as Q}from"../card-pieces/ProductCardState.js";import{wheelCardEyebrow as Y,wheelCardEyebrowShows as ee}from"../ProductCardEyebrow.js";import{withRMark as N}from"efficient-web-builder/render/components/RMark";import re from"../WheelPlaceholder.js";import{cardSpinOf as oe}from"../card-spin.js";import{cardHoverOf as ae,cardTurnFor as se}from"efficient-web-builder/format/lib/animation/hover";import{CardSpecFacts as te}from"../card-pieces/CardSpecs.js";import ne from"../WheelCardFrame.js";import{CARD_IMAGE_BG_OFF as ie}from"efficient-web-builder/format/lib/content/card-image-background";import{itemBrand as le}from"../../lib/catalog/plp-item.js";import{CARD_INDEX_BADGE_CLASS as me,CARD_INDEX_CLASS as de,DEFAULT_CARD_INDEX_FORMAT as ce,DEFAULT_CARD_OUTLINE as he}from"efficient-web-builder/format/lib/sections/product-card-style";import{setSecondSrc as ue}from"../../lib/wheels/set-mode.js";import{PLP_GRID_GAP_VAR as fe}from"../../lib/wheels/plp-grid.js";import{FITMENT_FIELD_SEPARATOR as pe}from"../../lib/wheels/plp-fitment-match.js";import{coverSrcForWheel as we,DEFAULT_COVER_INDEX as Se,resolvePaintedSrc as Ce}from"../../lib/wheels/cover-rendering.js";const ge=[],_e=ae({},"AlloyWheelsListing");function Ee({wheel:n,colours:c,fit:i=null,editing:l=!1,brandPlate:m=!1,kindLabel:h=null,showBrand:s=!0,showProcess:u=!1,coverIndex:f=Se,fieldUsage:p=ge,hover:w=_e,imageBackgroundFill:S=ie,showBadge:C=!0,outline:g=he,indexBadge:_=ce,showCardSizes:E=P.showCardSizes,showCardBuy:A=P.showCardBuy,showCardPage:F=P.showCardPage,showCardPrice:e=!0,showCardFinishes:o=!0,imageSizes:d=z}){return r(Q,{wheel:n,colours:c,editing:l,children:r(Ae,{fit:i,brandPlate:m,kindLabel:h,showBrand:s,showProcess:u,coverIndex:f,fieldUsage:p,hover:w,imageBackgroundFill:S,showBadge:C,outline:g,indexBadge:_,showCardSizes:E,showCardBuy:A,showCardPage:F,showCardPrice:e,showCardFinishes:o,imageSizes:d})})}function Ae({fit:n,brandPlate:c,kindLabel:i,showBrand:l,showProcess:m,coverIndex:h,fieldUsage:s,hover:u,imageBackgroundFill:f,showBadge:p,outline:w,indexBadge:S,showCardSizes:C,showCardBuy:g,showCardPage:_,showCardPrice:E,showCardFinishes:A,imageSizes:F}){const{wheel:e,sel:o,isSet:d}=K(),k=we(e,h,o.finish?.name,o.shownSrc,n?.holes),[y,G]=U(()=>new Set),x=a=>G(t=>t.has(a)?t:new Set(t).add(a)),b=Ce({overrideSrc:k,hookSrc:o.shownSrc,failed:y}),I=le(e),B=oe(se(u,e.spokes)),R=(a,t)=>r(M,{src:a,alt:t,width:800,height:800,sizes:F,className:["block h-full w-full object-contain",B.className].filter(Boolean).join(" "),style:B.style,draggable:!1,onError:()=>x(a)},a),L=o.finish?`${e.name} — ${o.finish.name}`:e.name,O=b?R(b,L):r(re,{imageLabel:e.name,spin:B}),D=d?ue(e.finishes?.find(a=>a.name===o.finish?.name),b):null,W=D&&!y.has(D)?R(D,`${L} — right`):void 0,T=S!=="off"?r("span",{"aria-hidden":!0,className:`${de} ${me}`}):null,v=Y({kindLabel:i,brand:l&&I?N(I):null,process:m&&e.process?N(e.process):null},s);return j($,{children:[r(ne,{href:`/wheels/${e.slug}`,wide:d,setGridGap:`var(${fe})`,identityLink:!0,containerProps:{onPointerEnter:o.arm,onTouchStart:o.arm,onFocusCapture:o.arm},probes:o.probes,outline:w,imageBackgroundFill:f,indexBadge:T,badges:r(J,{show:p,numbered:T!=null,sale:!0}),image:O,imageSecond:W,plate:c?r(X,{brand:I,logo:e.brandLogo}):null,eyebrow:v,wholeCardLink:!0,reserveEyebrow:ee({kind:!!i,brand:l,process:m},s),spec:r(te,{sizes:C,fieldUsage:s,car:n,separator:pe}),price:r(q,{show:E,setTotal:!0,wasFollowsSize:!0}),swatches:r(Z,{show:A,showSingle:!0}),buy:r(H,{buy:g,page:_})}),r(V,{})]})}export{Ee as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CARD_HOVER_KEYS as o}from"efficient-web-builder/format/lib/animation/hover";const
|
|
1
|
+
import{CARD_HOVER_KEYS as o,HOVER_GROUP_KEY as r}from"efficient-web-builder/format/lib/animation/hover";const i={kind:"tyre",tyres:[]},s={kind:"alloy-wheel",wheels:[]},l=[{key:"tyres-that-fit",label:"Tyres that fit this product",from:["alloy-wheel"],to:"tyre",heading:"Compatible *tyres.*",resolve:e=>e.kind==="alloy-wheel"?{kind:"tyre",tyres:e.source.compatibleTyres??[]}:i},{key:"wheels-that-fit",label:"Wheels this product fits",from:["tyre"],to:"alloy-wheel",heading:"Wheels that *fit.*",resolve:(e,t)=>e.kind==="tyre"?{kind:"alloy-wheel",wheels:t}:s},{key:"more-like-this",label:"More like this",from:["alloy-wheel"],to:"alloy-wheel",heading:"Others you might *like.*",resolve:(e,t)=>({kind:"alloy-wheel",wheels:t})}],a="more-like-this",y=l.map(e=>({value:e.key,label:e.label}));function n(e){return l.find(t=>t.key===e)}function c(e){return l.filter(t=>t.from.includes(e))}function d(e,t){return e.from.includes(t)}const p=["coverIndex","imageBackground",r,...Object.values(o),"showBadge"];function f(e){return n(e)?.to==="tyre"}export{p as CARD_ROWS_NOT_ON_A_TYRE,a as DEFAULT_RELATIONSHIP,l as RELATIONSHIPS,y as RELATIONSHIP_OPTIONS,f as answersWithTyres,d as relationshipApplies,n as relationshipByKey,c as relationshipsFor};
|