efficient-storefront-blocks 0.134.3 → 0.134.5
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 +9 -0
- package/dist/chunks/{EditorPreviewCheckout-AI5Y24RD.js → EditorPreviewCheckout-PUHW43VL.js} +4 -4
- package/dist/index.js +23 -23
- package/dist/render/components/ProductGallery.js +1 -1
- package/dist/render/components/checkout/CheckoutPageClient.js +1 -1
- package/dist/render/components/checkout/checkout-state.d.ts +2 -0
- package/dist/render/lib/api/types.d.ts +6 -0
- package/dist/render/lib/checkout/wallet-return.d.ts +1 -1
- package/dist/render/lib/commerce.d.ts +4 -0
- package/dist/render/lib/sections/spin-sets.d.ts +8 -0
- package/dist/render/lib/sections/spin-sets.js +1 -1
- package/dist/routine-index.json +1 -1
- package/dist/value-index.json +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as o,Fragment as O,jsxs as u}from"react/jsx-runtime";import{useRef as
|
|
1
|
+
"use client";import{jsx as o,Fragment as O,jsxs as u}from"react/jsx-runtime";import{useRef as F}from"react";import{photoLabel as N}from"./product-hero/hero-view.js";import G from"./product-hero/SpinLayer.js";import{stageControls as $,useHeldStagePhoto as I}from"./product-hero/stage-photo.js";import{DEFAULT_HERO_CLOSE_UPS_FILL as z,DEFAULT_HERO_GALLERY_GAP as R,DEFAULT_HERO_GALLERY_MARKS as V,DEFAULT_HERO_GALLERY_MODE as B,DEFAULT_HERO_GALLERY_SHOW as Y,DEFAULT_HERO_IMAGE_FIT as v,DEFAULT_HERO_PHOTO_GROUND as W,parseHeroGalleryGap as q,parseHeroCloseUpsFill as X,parseHeroGalleryMarks as Z,parseHeroGalleryMode as K,parseHeroGalleryShow as w,parseHeroImageFit as J,parseHeroPhotoGround as Q,resolveHeroImageFit as ee}from"../lib/sections/hero-gallery.js";import{apiSpinFor as te,spinSetFor as ae}from"../lib/sections/spin-sets.js";import{productHasComposedRender as oe}from"../lib/wheels/set-mode.js";import{HideTaker as C}from"efficient-web-builder/render/components/ViewHideRoot";import{swipeEnabled as le,swipeStep as ne}from"efficient-web-builder/format/lib/hero-swipe";function re({product:t,view:e,angleIdx:n,onSelect:c,isLight:l,onLightbox:s,galleryMode:i=B,imageFit:h=v,style:a,takesViewHide:m=!1,spin:p=se,ground:d=W,show:g=Y,marks:y=V,gap:S=R,closeUpsFill:_=z}){const b=ae(p,t.slug,e.metaValue)??te(t.parts,e.metaValue),L=ie(Q(d),l),f=w(g)==="closeUps"||b?ce(e):e,E=Z(y),T=me(e,f,X(_)),r=K(i),x=ee(J(h),oe(t)),H=o(he,{name:t.name,view:f,wellGround:L,angleIdx:n,onSelect:c,onLightbox:s,fit:x,spinSet:b,marks:E,fillsTile:T});return r==="stacked"?o(C,{as:"div",takes:m,"data-hero-gallery":r,"data-hero-fit":x,style:a,children:f.photos.length<2&&!b?H:u(O,{children:[o(pe,{name:t.name,view:f,wellGround:L,onLightbox:s,fit:x,spinSet:b,gap:q(S),fillsTile:T}),o(de,{angleIdx:n,total:U(f),onSelect:c,children:H})]})}):u(C,{as:"div",takes:m,"data-hero-gallery":r,"data-hero-fit":x,className:r==="tiled"?"flex items-start gap-3 max-view-tablet:gap-2":void 0,style:a,children:[o("div",{className:r==="tiled"?"min-w-0 flex-1":void 0,children:H}),r!=="main"&&o(fe,{name:t.name,view:f,angleIdx:n,onSelect:c,isLight:l,tiled:r==="tiled"})]})}function U(t){return t.photos.length>0?t.photos.length:t.thumbFallbackCells}const j="relative flex aspect-square items-center justify-center overflow-hidden",se={},k="sf-photo-ground-studio";function ie(t,e){return t==="studio"?k:e?"bg-bg":""}function ce(t){return t.photos.length===0||t.closeUps.length===0?t:{...t,photos:[t.photos[0],...t.closeUps.map(e=>e.url)],captions:[t.captions[0],...t.closeUps.map(e=>e.title)]}}const A=()=>!1;function me(t,e,n){if(!n||e===t)return A;const c=new Set(t.closeUps.map(l=>l.url));return(l,s)=>s>0&&l!==void 0&&c.has(l)}const M=(t,e,n)=>[t,e.metaValue,n].filter(Boolean).join(" — "),P=(t,e)=>[t,e.metaValue].filter(Boolean).join(" "),D=(t,e)=>`Open ${[t,e.metaValue].filter(Boolean).join(" ")} at full resolution`;function pe({name:t,view:e,wellGround:n,onLightbox:c,fit:l,spinSet:s,gap:i,fillsTile:h=A}){const a=s?o(G,{set:s,name:P(t,e),poster:e.photos[0]}):null,m=i===R;return o("div",{"data-hero-stack":!0,className:m?"flex flex-col gap-2 max-view-tablet:hidden":"flex flex-col max-view-tablet:hidden",style:m?void 0:{gap:`${i}px`},children:e.photos.map((p,d)=>{const g=M(t,e,N(e,d));return o("div",{"data-hero-stack-photo":!0,className:[j,n].join(" "),style:{color:e.tint},children:d===0&&a?a:e.stageImage({photo:p,alt:g,label:D(t,e),onZoom:()=>c(p,g),fit:l,eager:d===0,fillsTile:h(p,d)})},p)})})}function de({angleIdx:t,total:e,onSelect:n,children:c}){const l=F(null),s=F(null),i=le({count:e}),h=a=>({x:a.touches[0].clientX,y:a.touches[0].clientY});return o("div",{"data-hero-phone-stage":!0,className:"view-tablet:hidden",onTouchStart:a=>{l.current=i&&a.touches.length===1?h(a):null,s.current=l.current},onTouchMove:a=>{l.current&&(a.touches.length!==1?l.current=null:s.current=h(a))},onTouchEnd:()=>{const a=l.current,m=s.current;if(l.current=null,s.current=null,!a||!m)return;const p=ne(m.x-a.x,m.y-a.y,t,e);p!==t&&n(p)},children:c})}const ue=6;function he({name:t,view:e,angleIdx:n,onSelect:c,onLightbox:l,fit:s,spinSet:i,wellGround:h,marks:a,fillsTile:m=A}){const p=e.photos[Math.min(n,e.photos.length-1)],d=I(e.photos,p),g=U(e),y=g>=2,S=String(g).padStart(2,"0"),_=Math.min(n,Math.max(e.photos.length-1,0)),b=y||e.captions[_]?N(e,_):"",L=M(t,e,b),f="max-view-tablet:static",E=[`${j} max-view-tablet:col-span-2`,h].join(" ");return u("div",{className:"relative max-view-tablet:grid max-view-tablet:grid-cols-[minmax(0,1fr)_auto] max-view-tablet:items-start max-view-tablet:gap-x-3 max-view-tablet:gap-y-2",style:{color:e.tint},children:[a&&u("div",{className:`absolute left-0 top-0 z-10 flex items-center gap-3 font-mono text-[length:var(--size-label,13px)] font-semibold uppercase tracking-[0.2em] text-fg ${f} max-view-tablet:min-w-0 max-view-tablet:flex-wrap max-view-tablet:gap-x-2 max-view-tablet:gap-y-1`,children:[y&&u(O,{children:[u("span",{className:"text-accent",children:[String(n+1).padStart(2,"0")," / ",S]}),o("span",{className:"text-fg-dim",children:"·"})]}),o("span",{children:t}),e.metaValue&&u(O,{children:[o("span",{className:"text-fg-dim",children:"·"}),o("span",{className:"text-accent",children:e.metaValue})]})]}),a&&y&&o("div",{className:`absolute right-5 top-5 z-10 flex gap-1 ${f}`,children:$(n,g,c).map(r=>o("button",{type:"button","aria-label":r.label,title:r.label,onClick:r.onClick,className:"flex h-7 w-7 items-center justify-center border border-fg-dim/60 text-fg transition-colors hover:border-accent hover:text-accent",children:r.glyph},r.label))}),u("div",{className:E,children:[h!==k&&["top-3 left-3","top-3 right-3","bottom-3 left-3","bottom-3 right-3"].map((r,x)=>o("span",{className:`absolute ${r} h-3 w-3 border border-fg-dim/40`,style:{borderTop:r.includes("top")?"1px solid var(--site-line)":"none",borderBottom:r.includes("bottom")?"1px solid var(--site-line)":"none",borderLeft:r.includes("left")?"1px solid var(--site-line)":"none",borderRight:r.includes("right")?"1px solid var(--site-line)":"none"}},x)),i&&_===0?o(G,{set:i,name:P(t,e),poster:e.photos[0]}):e.stageImage({photo:d,alt:L,label:D(t,e),onZoom:()=>l(d,L),fit:s,fillsTile:m(d,e.photos.indexOf(d??""))})]}),a&&u("div",{className:`absolute bottom-0 left-0 right-0 z-10 flex items-end justify-between gap-3 font-mono text-[length:var(--size-label,12px)] uppercase tracking-[0.18em] text-fg-dim ${f} max-view-tablet:col-span-2 max-view-tablet:flex-wrap`,children:[u("span",{className:"flex min-w-0 flex-col gap-1",children:[e.specCaption&&o("span",{children:e.specCaption}),e.referenceNote&&o("span",{"data-hero-reference-note":!0,children:e.referenceNote}),e.galleryHint&&o("span",{"data-hero-gallery-hint":!0,children:e.galleryHint})]}),o("span",{children:e.originCaption})]})]})}function fe({name:t,view:e,angleIdx:n,onSelect:c,isLight:l,tiled:s=!1}){const i=U(e);return i<2?null:o("div",{className:s?"order-[-1] flex w-16 flex-col gap-2 max-view-tablet:w-12 max-view-tablet:gap-1":"mt-2 grid grid-cols-4 gap-2 max-view-tablet:gap-1",style:!s&&i>4?{gridTemplateColumns:`repeat(${Math.min(i,ue)}, minmax(0, 1fr))`}:void 0,children:Array.from({length:i}).map((h,a)=>{const m=e.photos[a];return u("button",{type:"button",onClick:()=>c(a),"aria-label":`View ${N(e,a)}`,"aria-pressed":a===n,className:["relative flex aspect-square items-center justify-center overflow-hidden transition-colors",l?"bg-bg":"",a===n?"border border-accent":"border border-transparent hover:border-fg-dim"].join(" "),style:{color:e.tint},children:[o("span",{className:"absolute top-1.5 left-2 z-10 font-mono text-[length:var(--size-label,8px)] uppercase tracking-[0.18em] text-fg-dim",children:String(a+1).padStart(2,"0")}),e.thumbImage({photo:m,alt:`${t} — ${N(e,a)}`})]},a)})})}export{re as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,Fragment as f,jsxs as r}from"react/jsx-runtime";import R from"next/link";import{useEffect as D,useMemo as Y,useRef as j,useState as C}from"react";import{holdTime as ee}from"../../lib/checkout/hold-time.js";import{stripeAppearance as te}from"../../lib/checkout/stripe-appearance.js";import{userZone as re,parseOption as ne}from"efficient-shell/format";import{Elements as ae,PaymentElement as ie,useElements as oe,useStripe as ce}from"@stripe/react-stripe-js";import{loadStripe as se}from"@stripe/stripe-js";import{useCurrency as E}from"../CurrencyContext.js";import{Notice as _}from"../Notice.js";import{resolveCopyright as le}from"../../lib/content/site.js";import{ApiError as L,products as I}from"../../lib/api/index.js";import de,{WORDMARK_FIT_FLOOR_PX as me}from"efficient-web-builder/render/components/Logo";import{NOT_CHECKED as T,orderReference as pe}from"../../lib/checkout/pay-first.js";import{CheckoutStateProvider as ue,useCheckout as M}from"./checkout-state.js";import{CheckoutContact as fe,CheckoutOrderSummary as xe,CheckoutPayment as ge,CheckoutShippingAddress as he,CheckoutShippingMethod as ye,FormLock as z,LeaveLink as B}from"./checkout-parts.js";function be(t){return e(ue,{...t,children:e(ke,{children:e(Pe,{})})})}function ke({children:t}){const{capitalised:n}=M();return n?e("div",{"data-checkout-case":"capitalised",className:"contents",children:t}):e(f,{children:t})}function Ne({order:t,paid:n}){const{formatMoney:o}=E();if(!t.grandTotal||!t.currency)return null;const m=s=>o(Number(s),t.currency),y=Number(t.freightCharge??0),p=Number(t.discountAmount??0);return r("dl",{className:"grid w-full max-w-sm grid-cols-[1fr_auto] gap-x-6 gap-y-1 border-y border-line py-3 text-left text-sm",children:[(t.shippingMethod||y>0)&&r(f,{children:[r("dt",{className:"text-fg-dim",children:["Delivery",t.shippingMethod?` · ${t.shippingMethod}`:""]}),e("dd",{className:"text-right font-mono",children:m(t.freightCharge??"0")})]}),p>0&&r(f,{children:[r("dt",{className:"text-fg-dim",children:["Discount",t.couponCode?` · ${t.couponCode}`:""]}),r("dd",{className:"text-right font-mono",children:["−",m(t.discountAmount??"0")]})]}),e("dt",{className:"text-fg",children:n?"Total paid":"Order total"}),e("dd",{className:"text-right font-mono text-fg",children:m(t.grandTotal)})]})}function we({result:t,lostChangeNote:n=null}){const o=e("span",{className:"font-mono text-fg",children:t.checkoutNumber});return r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:t.kind==="refunded"||t.kind==="expired"?"Order not placed":t.kind==="processing"?"Payment processing":"Payment received"}),e("p",{className:"text-fg-dim",children:t.kind==="refunded"?r(f,{children:["An item sold out or an offer ended while you paid for checkout ",o,". Your payment goes back to your card."]}):t.kind==="expired"?r(f,{children:["The hold on checkout ",o," ran out before your payment arrived. Your payment goes back to your card."]}):t.kind==="processing"?r(f,{children:["Your payment for checkout ",o," is being processed. When it goes through, we will email your order confirmation."]}):r(f,{children:["Thank you — your payment",t.checkoutNumber?r(f,{children:[" for checkout ",o]}):null," has gone through. We will email you the order number shortly."]})}),n&&t.kind!=="refunded"&&t.kind!=="expired"&&e("p",{className:"text-sm text-fg-dim",children:n}),e(R,{href:"/wheels",className:"mt-2 border-2 border-line px-6 py-3 font-mono text-[12px] uppercase tracking-[0.24em] hover:border-accent",children:"Continue browsing"})]})}function Pe(){const{site:t,logo:n,items:o,placing:m,formLocked:y,email:p,me:s,addressSaveNote:g,lostChangeNote:d,idemKey:x,confirmation:c,setConfirmation:u,payment:h,paypalStep:k,squareStep:N,pendingConf:l,paid:b,setPaid:S,payNote:i,afterpayConfirming:a,gocardlessConfirming:P,zipConfirming:v,klarnaConfirming:K,worldpayConfirming:U,cardConfirming:W,checkoutResult:A,confirmCardPayment:H,cardStillProcessing:G,renewCardPayment:Q,holdRenewed:V,leaveCardPayment:Z,checkoutRootRef:X,setCheckoutHeaderEl:J}=M();return c?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:b?"Payment received":"Order received"}),r("p",{className:"text-fg-dim",children:[b?r(f,{children:["Thank you — your payment for order"," ",e("span",{className:"font-mono text-fg",children:c.orderNumber})," has gone through."," "]}):r(f,{children:["Thank you — your order ",e("span",{className:"font-mono text-fg",children:c.orderNumber})," is being reviewed by our team."," "]}),s?r(f,{children:["Track it under"," ",e(R,{href:"/account/orders",className:"text-accent underline",children:"your orders"}),"."]}):e(f,{children:"We’ve emailed you a link to set a password and track it."})]}),e(Ne,{order:c,paid:b}),d&&e("p",{className:"text-sm text-fg-dim",children:d}),i&&(i.warning?e("div",{className:"w-full max-w-sm text-left",children:e(_,{tone:"bad",role:"alert",children:i.text})}):e("p",{className:"text-sm text-fg-dim",children:i.text})),g&&e("p",{className:"text-sm text-fg-dim",children:g}),!s&&r("p",{className:"text-sm text-fg-dim",children:["You can also"," ",e(R,{href:`/track?order=${encodeURIComponent(c.orderNumber)}`,className:"text-accent underline",children:"track this order"})," ","anytime with just your order number and email — no password needed."]}),e(R,{href:"/wheels",className:"mt-2 border-2 border-line px-6 py-3 font-mono text-[12px] uppercase tracking-[0.24em] hover:border-accent",children:"Continue browsing"})]}):A?e(we,{result:A,lostChangeNote:d}):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:"Placing your order — one moment."})]}):a?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Afterpay — one moment."})]}):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:"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."})]}):v?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Zip — one moment."})]}):K?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Klarna — one moment."})]}):U?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-xs uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Worldpay — one moment."})]}):h&&l?e(ve,{payment:h,checkout:l,holdRenewed:V,onPaid:H,onProcessing:G,onRenew:Q,onBack:Z}):k&&l?e(Ee,{confirmation:l,clientId:t.paypalClientId??"",idemKey:x,onPaid:()=>{S(!0),u(l)},onSkip:()=>u(l)}):N&&l?e(Ie,{confirmation:l,applicationId:t.squareApplicationId??"",locationId:t.squareLocationId??"",environment:t.squareEnvironment??"production",idemKey:x,onPaid:()=>{S(!0),u(l)},onSkip:()=>u(l)}):r("div",{ref:X,className:"bg-bg text-fg",children:[r("header",{ref:J,className:"sticky top-0 z-30 grid grid-cols-[1fr_auto_1fr] items-center gap-8 max-[640px]:grid-cols-[auto_minmax(0,1fr)_auto] max-[640px]:gap-3 border-b border-line px-[var(--sf-site-gutter,40px)] py-6 backdrop-blur-md max-[640px]:px-[min(20px,var(--sf-site-gutter,40px))] max-[640px]:py-4",style:{background:"color-mix(in oklab, var(--bg) 92%, transparent)"},children:[r(B,{href:"/",className:"inline-flex items-center gap-3 font-mono text-[14px] uppercase tracking-[0.26em] text-fg-dim transition-colors hover:text-accent",children:["←",e("span",{className:"max-[640px]:hidden",children:"Back to shop"})]}),e("div",{className:"flex min-w-0 justify-center max-[640px]:[container-type:inline-size]",children:e(B,{href:"/","aria-label":`${t.name} home`,className:"inline-flex max-w-full items-center justify-center max-[640px]:overflow-x-clip",children:[!0,!1].map(w=>e(de,{hideClass:w?"min-[641px]:hidden":"max-[640px]:hidden",variant:"header",scrolled:!0,src:n?.url??null,reverse:n?.reverse??!1,reversedSrc:n?.reversed??null,inkIsDark:n?.inkIsDark??null,size:n?.size??"medium",sizePx:n?.sizePx??null,sizeUnit:n?.sizeUnit??null,siteName:t.name,fitWordmarkToContainer:w,fitFloorPx:w?me:void 0},w?"phone":"wide"))})}),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 max-[640px]:flex-nowrap max-[640px]:gap-3 max-[640px]:whitespace-nowrap max-[640px]:text-xs max-[640px]:tracking-[0.04em]",children:[{n:"01",label:"Cart",state:"done"},{n:"02",label:"Ship & pay",state:"active"},{n:"03",label:"Confirmed",state:"pending"}].map(w=>r("span",{className:["relative flex items-center gap-2 transition-colors",w.state==="pending"?"text-fg-dim":"text-fg",w.state==="active"?"font-bold after:absolute after:inset-x-0 after:-bottom-1 after:h-[2px] after:bg-accent":""].join(" "),children:[e("span",{className:w.state==="done"?"text-accent font-bold":"",children:w.n}),e("span",{children:w.label})]},w.n))})]}),r("main",{className:"mx-auto grid max-w-[var(--sf-site-width,1600px)] grid-cols-[1fr_420px] items-start gap-16 px-[var(--sf-site-gutter,40px)] pt-10 pb-[100px] max-view-desktop:grid-cols-1 max-view-desktop:gap-10 max-view-desktop:px-[min(24px,var(--sf-site-gutter,40px))] max-view-desktop:pt-8 max-view-desktop:pb-20",children:[r("div",{children:[r(z,{locked:y,children:[e(fe,{}),e(he,{}),e(ye,{})]}),e(z,{locked:m,children:e(ge,{})})]}),e(xe,{})]}),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:le({legalName:t.legalName,foundedYear:t.foundedYear,siteName:t.name})})})]})}function ve({payment:t,checkout:n,holdRenewed:o,onPaid:m,onProcessing:y,onRenew:p,onBack:s}){const{formatMoney:g}=E(),d=e("span",{className:"text-fg",children:g(Number(t.amount),t.currency)}),x=Y(()=>se(t.publishableKey),[t.publishableKey]),c=Y(()=>te(),[]),u=ee(n.expiresAt??"",re()??"");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:pe(n)}),e("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"Payment"})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:[e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:n.orderNumber?r(f,{children:["Your order is placed. Pay ",d," by card to confirm it now."]}):o?r(f,{children:["Your hold ran out, so your items are held again",u?` until ${u}`:"",". Enter your card again, then pay ",d,"."]}):r(f,{children:["Your items are held",u?` until ${u}`:"",". Pay ",d," by card to place your order."]})}),e(ae,{stripe:x,options:{clientSecret:t.clientSecret,appearance:c},children:e(Se,{payment:t,checkout:n,onPaid:m,onProcessing:y,onRenew:p,onBack:s})},t.clientSecret)]})]})})}const Ce=5;function Se({payment:t,checkout:n,onPaid:o,onProcessing:m,onRenew:y,onBack:p}){const{formatMoney:s}=E(),g=ce(),d=oe(),[x,c]=C(!1),[u,h]=C(null),k=j(!1);async function N(){try{return(await g.retrievePaymentIntent(t.clientSecret)).paymentIntent?.status}catch{return}}async function l(i){let a=i;for(let P=0;a==="processing"&&P<Ce;P+=1)await new Promise(v=>setTimeout(v,1e3)),a=await N()??a;if(a==="succeeded"){o();return}if(a==="processing"){m();return}h("Payment did not complete. Please try again."),c(!1)}async function b(){if(!g||!d||x)return;c(!0),h(null),k.current=!0;const i=await g.confirmPayment({elements:d,redirect:"if_required"}).catch(()=>null);if(!i){const a=await N();if(a==="succeeded"||a==="processing"){await l(a);return}h(a===void 0?T:"Payment failed. Please try again."),c(!1);return}if(i.error){if(!n.orderNumber&&i.error.code==="payment_intent_unexpected_state"){const a=await N();if(a==="succeeded"||a==="processing"){await l(a);return}if(a===void 0){h(T),c(!1);return}await y(a==="canceled"),c(!1);return}h(i.error.message??"Payment failed. Please try again."),c(!1);return}await l(i.paymentIntent?.status)}async function S(){if(x)return;if(!k.current){p();return}c(!0),h(null);const i=await N();if(i==="succeeded"||i==="processing"){await l(i);return}if(c(!1),i===void 0){h(T);return}p()}return r("div",{className:"flex flex-col gap-4",children:[e(ie,{}),u&&e(_,{role:"alert",children:u}),e("button",{type:"button",onClick:b,disabled:!g||!d||x,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",!g||!d||x?"cursor-not-allowed border-line bg-surface text-fg-dim":"border-btn bg-btn text-btn-ink hover:border-fg hover:bg-fg"].join(" "),children:x?r(f,{children:["Processing… ",e("span",{children:"·"})]}):r(f,{children:["Pay ",s(Number(t.amount),t.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})}),!n.orderNumber&&!x&&r("button",{type:"button",onClick:S,className:"inline-flex items-center gap-3 self-start font-mono text-[12px] uppercase tracking-[0.26em] text-fg-dim transition-colors hover:text-accent",children:["←",e("span",{children:"Back to checkout"})]})]})}const F="paypal-sdk-js";let q=null;function je(t,n){const o=`${t}|${n}`;if(q?.key===o)return q.promise;const m=new Promise((y,p)=>{document.getElementById(F)?.remove();const s=document.createElement("script");s.id=F;const g=new URLSearchParams({"client-id":t,currency:n,intent:"capture"});s.src=`https://www.paypal.com/sdk/js?${g}`,s.onload=()=>{const d=window.paypal;d?y(d):p(new Error("PayPal SDK loaded without its namespace"))},s.onerror=()=>p(new Error("PayPal SDK failed to load")),document.head.appendChild(s)});return q={key:o,promise:m},m}function Ee({confirmation:t,clientId:n,idemKey:o,onPaid:m,onSkip:y}){const{formatMoney:p}=E(),s=j(null),[g,d]=C(!1),[x,c]=C(null),u=j(m);return u.current=m,D(()=>{let h=!1,k=null;return je(n,t.currency).then(N=>{if(!(h||!s.current))return k=N.Buttons({style:{layout:"vertical",color:"gold",shape:"rect",label:"paypal"},createOrder:async()=>(await I.createPaypalOrder({idempotencyKey:o})).paypalOrderId,onApprove:async l=>{try{if((await I.capturePaypalOrder({idempotencyKey:o,paypalOrderId:l.orderID})).status==="paid"){u.current();return}c("PayPal did not complete the payment. Please try again.")}catch(b){c(b instanceof L?b.message:"PayPal payment failed. Please try again.")}},onError:()=>{c("PayPal could not process the payment. Please try again.")}}),k.render(s.current).then(()=>{h||d(!0)})}).catch(()=>{h||c("PayPal could not be loaded. You can pay later — your order stands either way.")}),()=>{h=!0,k?.close?.()}},[n,t.currency,o]),e("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:r("div",{className:"w-full max-w-xl border border-line bg-bg",children:[r("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t.orderNumber}),e("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"PayPal"})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:[r("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:["Your order is placed. Pay"," ",e("span",{className:"text-fg",children:p(Number(t.grandTotal),t.currency)})," ","with PayPal to confirm it now."]}),!g&&!x&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading PayPal…"}),e("div",{ref:s}),x&&e(_,{role:"alert",children:x}),e("button",{type:"button",onClick:y,className:"self-center font-mono text-[11px] uppercase tracking-[0.24em] text-fg-dim underline-offset-4 transition-colors hover:text-accent hover:underline",children:"Pay later — our team will be in touch"})]})]})})}const $="square-web-sdk";let O=null;const Re=["sandbox","production"];function _e(t){const n=ne(Re,"production",t);if(O?.key===n)return O.promise;const o=new Promise((m,y)=>{document.getElementById($)?.remove();const p=document.createElement("script");p.id=$,p.src=n==="sandbox"?"https://sandbox.web.squarecdn.com/v1/square.js":"https://web.squarecdn.com/v1/square.js",p.onload=()=>{const s=window.Square;s?m(s):y(new Error("Square SDK loaded without its namespace"))},p.onerror=()=>y(new Error("Square SDK failed to load")),document.head.appendChild(p)});return O={key:n,promise:o},o}function Ie({confirmation:t,applicationId:n,locationId:o,environment:m,idemKey:y,onPaid:p,onSkip:s}){const{formatMoney:g}=E(),d=j(null),x=j(null),c=j(null),[u,h]=C(!1),[k,N]=C(!1),[l,b]=C(null);D(()=>{let i=!1,a=null;return _e(m).then(async P=>{if(i||!d.current)return;const v=P.payments(n,o);c.current=v,a=await v.card(),await a.attach(d.current),x.current=a,i||h(!0)}).catch(()=>{i||b("Square could not be loaded. You can pay later — your order stands either way.")}),()=>{i=!0,a?.destroy?.()}},[n,o,m]);async function S(){const i=x.current;if(!(!i||k)){N(!0),b(null);try{const a=await i.tokenize();if(a.status!=="OK"||!a.token){b(a.errors?.[0]?.message??"Please check the card details and try again."),N(!1);return}let P;try{P=(await c.current?.verifyBuyer?.(a.token,{amount:String(t.grandTotal),currencyCode:t.currency,intent:"CHARGE"}))?.token}catch{}if((await I.chargeSquare({idempotencyKey:y,sourceId:a.token,...P?{verificationToken:P}:{}})).status==="paid"){p();return}b("Square did not complete the payment. Please try again.")}catch(a){b(a instanceof L?a.message:"Square payment failed. Please try again.")}N(!1)}}return e("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:r("div",{className:"w-full max-w-xl border border-line bg-bg",children:[r("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t.orderNumber}),e("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"Card"})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:[r("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:["Your order is placed. Pay"," ",e("span",{className:"text-fg",children:g(Number(t.grandTotal),t.currency)})," ","by card to confirm it now."]}),!u&&!l&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading card form…"}),e("div",{ref:d}),l&&e(_,{role:"alert",children:l}),e("button",{type:"button",onClick:S,disabled:!u||k,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",!u||k?"cursor-not-allowed border-line bg-surface text-fg-dim":"border-btn bg-btn text-btn-ink hover:border-fg hover:bg-fg"].join(" "),children:k?r(f,{children:["Processing… ",e("span",{children:"·"})]}):r(f,{children:["Pay ",g(Number(t.grandTotal),t.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})}),e("button",{type:"button",onClick:s,disabled:k,className:"self-center font-mono text-[11px] uppercase tracking-[0.24em] text-fg-dim underline-offset-4 transition-colors hover:text-accent hover:underline",children:"Pay later — our team will be in touch"})]})]})})}export{we as PayFirstResultView,be as default};
|
|
1
|
+
"use client";import{jsx as e,Fragment as u,jsxs as r}from"react/jsx-runtime";import E from"next/link";import{useEffect as D,useMemo as Y,useRef as j,useState as C}from"react";import{holdTime as ee}from"../../lib/checkout/hold-time.js";import{stripeAppearance as te}from"../../lib/checkout/stripe-appearance.js";import{userZone as re,parseOption as ne}from"efficient-shell/format";import{Elements as ae,PaymentElement as ie,useElements as oe,useStripe as ce}from"@stripe/react-stripe-js";import{loadStripe as se}from"@stripe/stripe-js";import{useCurrency as R}from"../CurrencyContext.js";import{Notice as _}from"../Notice.js";import{resolveCopyright as le}from"../../lib/content/site.js";import{ApiError as L,products as I}from"../../lib/api/index.js";import de,{WORDMARK_FIT_FLOOR_PX as me}from"efficient-web-builder/render/components/Logo";import{NOT_CHECKED as T,orderReference as pe}from"../../lib/checkout/pay-first.js";import{CheckoutStateProvider as ue,useCheckout as M}from"./checkout-state.js";import{CheckoutContact as fe,CheckoutOrderSummary as xe,CheckoutPayment as he,CheckoutShippingAddress as ge,CheckoutShippingMethod as ye,FormLock as F,LeaveLink as z}from"./checkout-parts.js";function be(t){return e(ue,{...t,children:e(ke,{children:e(Pe,{})})})}function ke({children:t}){const{capitalised:n}=M();return n?e("div",{"data-checkout-case":"capitalised",className:"contents",children:t}):e(u,{children:t})}function Ne({order:t,paid:n}){const{formatMoney:c}=R();if(!t.grandTotal||!t.currency)return null;const m=s=>c(Number(s),t.currency),y=Number(t.freightCharge??0),p=Number(t.discountAmount??0);return r("dl",{className:"grid w-full max-w-sm grid-cols-[1fr_auto] gap-x-6 gap-y-1 border-y border-line py-3 text-left text-sm",children:[(t.shippingMethod||y>0)&&r(u,{children:[r("dt",{className:"text-fg-dim",children:["Delivery",t.shippingMethod?` · ${t.shippingMethod}`:""]}),e("dd",{className:"text-right font-mono",children:m(t.freightCharge??"0")})]}),p>0&&r(u,{children:[r("dt",{className:"text-fg-dim",children:["Discount",t.couponCode?` · ${t.couponCode}`:""]}),r("dd",{className:"text-right font-mono",children:["−",m(t.discountAmount??"0")]})]}),e("dt",{className:"text-fg",children:n?"Total paid":"Order total"}),e("dd",{className:"text-right font-mono text-fg",children:m(t.grandTotal)})]})}function we({result:t,lostChangeNote:n=null}){const c=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(u,{children:["An item sold out or an offer ended while you paid for checkout ",c,". Your payment goes back to your card."]}):t.kind==="expired"?r(u,{children:["The hold on checkout ",c," ran out before your payment arrived. Your payment goes back to your card."]}):t.kind==="processing"?r(u,{children:["Your payment for checkout ",c," is being processed. When it goes through, we will email your order confirmation."]}):r(u,{children:["Thank you — your payment",t.checkoutNumber?r(u,{children:[" for checkout ",c]}):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(E,{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 Pe(){const{site:t,logo:n,items:c,placing:m,formLocked:y,email:p,me:s,addressSaveNote:h,lostChangeNote:d,idemKey:x,confirmation:i,setConfirmation:f,payment:g,paypalStep:k,squareStep:N,pendingConf:l,paid:b,setPaid:S,payNote:o,afterpayConfirming:a,gocardlessConfirming:P,zipConfirming:v,klarnaConfirming:A,worldpayConfirming:U,cardConfirming:W,checkoutResult:K,confirmCardPayment:H,cardStillProcessing:G,renewCardPayment:Q,holdRenewed:V,leaveCardPayment:Z,checkoutRootRef:X,setCheckoutHeaderEl:J}=M();return i?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:b?"Payment received":"Order received"}),r("p",{className:"text-fg-dim",children:[b?r(u,{children:["Thank you — your payment for order"," ",e("span",{className:"font-mono text-fg",children:i.orderNumber})," has gone through."," "]}):r(u,{children:["Thank you — your order ",e("span",{className:"font-mono text-fg",children:i.orderNumber})," is being reviewed by our team."," "]}),s?r(u,{children:["Track it under"," ",e(E,{href:"/account/orders",className:"text-accent underline",children:"your orders"}),"."]}):i.accountLinkSent?e(u,{children:"We’ve emailed you a link to set a password and track it."}):r(u,{children:["Already have an account?"," ",e(E,{href:"/login?next=%2Faccount%2Forders",className:"text-accent underline",children:"Sign in"})," ","to see it under your orders."]})]}),e(Ne,{order:i,paid:b}),d&&e("p",{className:"text-sm text-fg-dim",children:d}),o&&(o.warning?e("div",{className:"w-full max-w-sm text-left",children:e(_,{tone:"bad",role:"alert",children:o.text})}):e("p",{className:"text-sm text-fg-dim",children:o.text})),h&&e("p",{className:"text-sm text-fg-dim",children:h}),!s&&r("p",{className:"text-sm text-fg-dim",children:["You can also"," ",e(E,{href:`/track?order=${encodeURIComponent(i.orderNumber)}`,className:"text-accent underline",children:"track this order"})," ","anytime with just your order number and email — no password needed."]}),e(E,{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"})]}):K?e(we,{result:K,lostChangeNote:d}):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:"Placing your order — one moment."})]}):a?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Afterpay — one moment."})]}):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:"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."})]}):v?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."})]}):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 Klarna — one moment."})]}):U?r("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg px-6 text-center text-fg",children:[e("h1",{className:"font-display text-3xl",children:"Confirming your payment…"}),e("p",{className:"font-mono text-xs uppercase tracking-[0.2em] text-fg-dim",children:"Checking with Worldpay — one moment."})]}):g&&l?e(ve,{payment:g,checkout:l,holdRenewed:V,onPaid:H,onProcessing:G,onRenew:Q,onBack:Z}):k&&l?e(Ee,{confirmation:l,clientId:t.paypalClientId??"",idemKey:x,onPaid:()=>{S(!0),f(l)},onSkip:()=>f(l)}):N&&l?e(Ie,{confirmation:l,applicationId:t.squareApplicationId??"",locationId:t.squareLocationId??"",environment:t.squareEnvironment??"production",idemKey:x,onPaid:()=>{S(!0),f(l)},onSkip:()=>f(l)}):r("div",{ref:X,className:"bg-bg text-fg",children:[r("header",{ref:J,className:"sticky top-0 z-30 grid grid-cols-[1fr_auto_1fr] items-center gap-8 max-[640px]:grid-cols-[auto_minmax(0,1fr)_auto] max-[640px]:gap-3 border-b border-line px-[var(--sf-site-gutter,40px)] py-6 backdrop-blur-md max-[640px]:px-[min(20px,var(--sf-site-gutter,40px))] max-[640px]:py-4",style:{background:"color-mix(in oklab, var(--bg) 92%, transparent)"},children:[r(z,{href:"/",className:"inline-flex items-center gap-3 font-mono text-[14px] uppercase tracking-[0.26em] text-fg-dim transition-colors hover:text-accent",children:["←",e("span",{className:"max-[640px]:hidden",children:"Back to shop"})]}),e("div",{className:"flex min-w-0 justify-center max-[640px]:[container-type:inline-size]",children:e(z,{href:"/","aria-label":`${t.name} home`,className:"inline-flex max-w-full items-center justify-center max-[640px]:overflow-x-clip",children:[!0,!1].map(w=>e(de,{hideClass:w?"min-[641px]:hidden":"max-[640px]:hidden",variant:"header",scrolled:!0,src:n?.url??null,reverse:n?.reverse??!1,reversedSrc:n?.reversed??null,inkIsDark:n?.inkIsDark??null,size:n?.size??"medium",sizePx:n?.sizePx??null,sizeUnit:n?.sizeUnit??null,siteName:t.name,fitWordmarkToContainer:w,fitFloorPx:w?me:void 0},w?"phone":"wide"))})}),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 max-[640px]:flex-nowrap max-[640px]:gap-3 max-[640px]:whitespace-nowrap max-[640px]:text-xs max-[640px]:tracking-[0.04em]",children:[{n:"01",label:"Cart",state:"done"},{n:"02",label:"Ship & pay",state:"active"},{n:"03",label:"Confirmed",state:"pending"}].map(w=>r("span",{className:["relative flex items-center gap-2 transition-colors",w.state==="pending"?"text-fg-dim":"text-fg",w.state==="active"?"font-bold after:absolute after:inset-x-0 after:-bottom-1 after:h-[2px] after:bg-accent":""].join(" "),children:[e("span",{className:w.state==="done"?"text-accent font-bold":"",children:w.n}),e("span",{children:w.label})]},w.n))})]}),r("main",{className:"mx-auto grid max-w-[var(--sf-site-width,1600px)] grid-cols-[1fr_420px] items-start gap-16 px-[var(--sf-site-gutter,40px)] pt-10 pb-[100px] max-view-desktop:grid-cols-1 max-view-desktop:gap-10 max-view-desktop:px-[min(24px,var(--sf-site-gutter,40px))] max-view-desktop:pt-8 max-view-desktop:pb-20",children:[r("div",{children:[r(F,{locked:y,children:[e(fe,{}),e(ge,{}),e(ye,{})]}),e(F,{locked:m,children:e(he,{})})]}),e(xe,{})]}),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:le({legalName:t.legalName,foundedYear:t.foundedYear,siteName:t.name})})})]})}function ve({payment:t,checkout:n,holdRenewed:c,onPaid:m,onProcessing:y,onRenew:p,onBack:s}){const{formatMoney:h}=R(),d=e("span",{className:"text-fg",children:h(Number(t.amount),t.currency)}),x=Y(()=>se(t.publishableKey),[t.publishableKey]),i=Y(()=>te(),[]),f=ee(n.expiresAt??"",re()??"");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:pe(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(u,{children:["Your order is placed. Pay ",d," by card to confirm it now."]}):c?r(u,{children:["Your hold ran out, so your items are held again",f?` until ${f}`:"",". Enter your card again, then pay ",d,"."]}):r(u,{children:["Your items are held",f?` until ${f}`:"",". Pay ",d," by card to place your order."]})}),e(ae,{stripe:x,options:{clientSecret:t.clientSecret,appearance:i},children:e(Se,{payment:t,checkout:n,onPaid:m,onProcessing:y,onRenew:p,onBack:s})},t.clientSecret)]})]})})}const Ce=5;function Se({payment:t,checkout:n,onPaid:c,onProcessing:m,onRenew:y,onBack:p}){const{formatMoney:s}=R(),h=ce(),d=oe(),[x,i]=C(!1),[f,g]=C(null),k=j(!1);async function N(){try{return(await h.retrievePaymentIntent(t.clientSecret)).paymentIntent?.status}catch{return}}async function l(o){let a=o;for(let P=0;a==="processing"&&P<Ce;P+=1)await new Promise(v=>setTimeout(v,1e3)),a=await N()??a;if(a==="succeeded"){c();return}if(a==="processing"){m();return}g("Payment did not complete. Please try again."),i(!1)}async function b(){if(!h||!d||x)return;i(!0),g(null),k.current=!0;const o=await h.confirmPayment({elements:d,redirect:"if_required"}).catch(()=>null);if(!o){const a=await N();if(a==="succeeded"||a==="processing"){await l(a);return}g(a===void 0?T:"Payment failed. Please try again."),i(!1);return}if(o.error){if(!n.orderNumber&&o.error.code==="payment_intent_unexpected_state"){const a=await N();if(a==="succeeded"||a==="processing"){await l(a);return}if(a===void 0){g(T),i(!1);return}await y(a==="canceled"),i(!1);return}g(o.error.message??"Payment failed. Please try again."),i(!1);return}await l(o.paymentIntent?.status)}async function S(){if(x)return;if(!k.current){p();return}i(!0),g(null);const o=await N();if(o==="succeeded"||o==="processing"){await l(o);return}if(i(!1),o===void 0){g(T);return}p()}return r("div",{className:"flex flex-col gap-4",children:[e(ie,{}),f&&e(_,{role:"alert",children:f}),e("button",{type:"button",onClick:b,disabled:!h||!d||x,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",!h||!d||x?"cursor-not-allowed border-line bg-surface text-fg-dim":"border-btn bg-btn text-btn-ink hover:border-fg hover:bg-fg"].join(" "),children:x?r(u,{children:["Processing… ",e("span",{children:"·"})]}):r(u,{children:["Pay ",s(Number(t.amount),t.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})}),!n.orderNumber&&!x&&r("button",{type:"button",onClick:S,className:"inline-flex items-center gap-3 self-start font-mono text-[12px] uppercase tracking-[0.26em] text-fg-dim transition-colors hover:text-accent",children:["←",e("span",{children:"Back to checkout"})]})]})}const B="paypal-sdk-js";let q=null;function je(t,n){const c=`${t}|${n}`;if(q?.key===c)return q.promise;const m=new Promise((y,p)=>{document.getElementById(B)?.remove();const s=document.createElement("script");s.id=B;const h=new URLSearchParams({"client-id":t,currency:n,intent:"capture"});s.src=`https://www.paypal.com/sdk/js?${h}`,s.onload=()=>{const d=window.paypal;d?y(d):p(new Error("PayPal SDK loaded without its namespace"))},s.onerror=()=>p(new Error("PayPal SDK failed to load")),document.head.appendChild(s)});return q={key:c,promise:m},m}function Ee({confirmation:t,clientId:n,idemKey:c,onPaid:m,onSkip:y}){const{formatMoney:p}=R(),s=j(null),[h,d]=C(!1),[x,i]=C(null),f=j(m);return f.current=m,D(()=>{let g=!1,k=null;return je(n,t.currency).then(N=>{if(!(g||!s.current))return k=N.Buttons({style:{layout:"vertical",color:"gold",shape:"rect",label:"paypal"},createOrder:async()=>(await I.createPaypalOrder({idempotencyKey:c})).paypalOrderId,onApprove:async l=>{try{if((await I.capturePaypalOrder({idempotencyKey:c,paypalOrderId:l.orderID})).status==="paid"){f.current();return}i("PayPal did not complete the payment. Please try again.")}catch(b){i(b instanceof L?b.message:"PayPal payment failed. Please try again.")}},onError:()=>{i("PayPal could not process the payment. Please try again.")}}),k.render(s.current).then(()=>{g||d(!0)})}).catch(()=>{g||i("PayPal could not be loaded. You can pay later — your order stands either way.")}),()=>{g=!0,k?.close?.()}},[n,t.currency,c]),e("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:r("div",{className:"w-full max-w-xl border border-line bg-bg",children:[r("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t.orderNumber}),e("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"PayPal"})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:[r("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:["Your order is placed. Pay"," ",e("span",{className:"text-fg",children:p(Number(t.grandTotal),t.currency)})," ","with PayPal to confirm it now."]}),!h&&!x&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading PayPal…"}),e("div",{ref:s}),x&&e(_,{role:"alert",children:x}),e("button",{type:"button",onClick:y,className:"self-center font-mono text-[11px] uppercase tracking-[0.24em] text-fg-dim underline-offset-4 transition-colors hover:text-accent hover:underline",children:"Pay later — our team will be in touch"})]})]})})}const $="square-web-sdk";let O=null;const Re=["sandbox","production"];function _e(t){const n=ne(Re,"production",t);if(O?.key===n)return O.promise;const c=new Promise((m,y)=>{document.getElementById($)?.remove();const p=document.createElement("script");p.id=$,p.src=n==="sandbox"?"https://sandbox.web.squarecdn.com/v1/square.js":"https://web.squarecdn.com/v1/square.js",p.onload=()=>{const s=window.Square;s?m(s):y(new Error("Square SDK loaded without its namespace"))},p.onerror=()=>y(new Error("Square SDK failed to load")),document.head.appendChild(p)});return O={key:n,promise:c},c}function Ie({confirmation:t,applicationId:n,locationId:c,environment:m,idemKey:y,onPaid:p,onSkip:s}){const{formatMoney:h}=R(),d=j(null),x=j(null),i=j(null),[f,g]=C(!1),[k,N]=C(!1),[l,b]=C(null);D(()=>{let o=!1,a=null;return _e(m).then(async P=>{if(o||!d.current)return;const v=P.payments(n,c);i.current=v,a=await v.card(),await a.attach(d.current),x.current=a,o||g(!0)}).catch(()=>{o||b("Square could not be loaded. You can pay later — your order stands either way.")}),()=>{o=!0,a?.destroy?.()}},[n,c,m]);async function S(){const o=x.current;if(!(!o||k)){N(!0),b(null);try{const a=await o.tokenize();if(a.status!=="OK"||!a.token){b(a.errors?.[0]?.message??"Please check the card details and try again."),N(!1);return}let P;try{P=(await i.current?.verifyBuyer?.(a.token,{amount:String(t.grandTotal),currencyCode:t.currency,intent:"CHARGE"}))?.token}catch{}if((await I.chargeSquare({idempotencyKey:y,sourceId:a.token,...P?{verificationToken:P}:{}})).status==="paid"){p();return}b("Square did not complete the payment. Please try again.")}catch(a){b(a instanceof L?a.message:"Square payment failed. Please try again.")}N(!1)}}return e("div",{className:"flex min-h-screen flex-col items-center justify-center gap-6 bg-bg px-6 py-16 text-fg",children:r("div",{className:"w-full max-w-xl border border-line bg-bg",children:[r("header",{className:"flex items-center justify-between gap-4 border-b border-line bg-surface px-6 py-4",children:[e("span",{className:"inline-flex items-center justify-center bg-accent px-3 py-1 font-mono text-[11px] font-bold uppercase tracking-[0.24em] text-bg",children:t.orderNumber}),e("h1",{className:"font-display text-[26px] font-medium uppercase leading-none tracking-[-0.02em] text-fg",children:"Card"})]}),r("div",{className:"flex flex-col gap-4 px-6 py-6",children:[r("p",{className:"font-mono text-[12px] uppercase tracking-[0.2em] text-fg-dim",children:["Your order is placed. Pay"," ",e("span",{className:"text-fg",children:h(Number(t.grandTotal),t.currency)})," ","by card to confirm it now."]}),!f&&!l&&e("p",{className:"font-mono text-[11px] uppercase tracking-[0.2em] text-fg-dim",children:"Loading card form…"}),e("div",{ref:d}),l&&e(_,{role:"alert",children:l}),e("button",{type:"button",onClick:S,disabled:!f||k,className:["group flex items-center justify-between border px-5 py-5 font-mono text-[14px] font-medium uppercase tracking-[0.3em] transition-all",!f||k?"cursor-not-allowed border-line bg-surface text-fg-dim":"border-btn bg-btn text-btn-ink hover:border-fg hover:bg-fg"].join(" "),children:k?r(u,{children:["Processing… ",e("span",{children:"·"})]}):r(u,{children:["Pay ",h(Number(t.grandTotal),t.currency),e("span",{className:"transition-transform group-hover:translate-x-1",children:"→"})]})}),e("button",{type:"button",onClick:s,disabled:k,className:"self-center font-mono text-[11px] uppercase tracking-[0.24em] text-fg-dim underline-offset-4 transition-colors hover:text-accent hover:underline",children:"Pay later — our team will be in touch"})]})]})})}export{we as PayFirstResultView,be as default};
|
|
@@ -176,6 +176,7 @@ declare function useCheckoutState({ site, logo, signInHref, preview, textCase }:
|
|
|
176
176
|
grandTotal: string;
|
|
177
177
|
shippingMethod?: string | null;
|
|
178
178
|
couponCode?: string | null;
|
|
179
|
+
accountLinkSent?: boolean;
|
|
179
180
|
} | null;
|
|
180
181
|
paid: boolean;
|
|
181
182
|
setPaid: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
@@ -191,6 +192,7 @@ declare function useCheckoutState({ site, logo, signInHref, preview, textCase }:
|
|
|
191
192
|
grandTotal: string;
|
|
192
193
|
shippingMethod?: string | null;
|
|
193
194
|
couponCode?: string | null;
|
|
195
|
+
accountLinkSent?: boolean;
|
|
194
196
|
} | null;
|
|
195
197
|
orderLocked: boolean;
|
|
196
198
|
formLocked: boolean;
|
|
@@ -1356,6 +1356,11 @@ export interface components {
|
|
|
1356
1356
|
hand?: "left" | "right" | null;
|
|
1357
1357
|
axle?: "front" | "rear" | null;
|
|
1358
1358
|
renderKey?: string;
|
|
1359
|
+
spin?: components["schemas"]["ComponentSpin"] | null;
|
|
1360
|
+
};
|
|
1361
|
+
ComponentSpin: {
|
|
1362
|
+
frame_count: number;
|
|
1363
|
+
frames: string[];
|
|
1359
1364
|
};
|
|
1360
1365
|
WheelVariant: {
|
|
1361
1366
|
finishName: string;
|
|
@@ -2046,6 +2051,7 @@ export interface components {
|
|
|
2046
2051
|
grandTotal: string;
|
|
2047
2052
|
shippingMethod?: string | null;
|
|
2048
2053
|
couponCode?: string | null;
|
|
2054
|
+
accountLinkSent?: boolean;
|
|
2049
2055
|
};
|
|
2050
2056
|
OrderLookupRequest: {
|
|
2051
2057
|
orderNumber: string;
|
|
@@ -11,7 +11,7 @@ export interface WalletContext {
|
|
|
11
11
|
lostChange?: true;
|
|
12
12
|
}
|
|
13
13
|
export declare function parkedLostChange(context: WalletContext | null): boolean;
|
|
14
|
-
export type LandingOrder = Pick<OrderConfirmation, "orderNumber"> & Partial<Pick<OrderConfirmation, "currency" | "grandTotal" | "freightCharge" | "discountAmount" | "shippingMethod" | "couponCode">>;
|
|
14
|
+
export type LandingOrder = Pick<OrderConfirmation, "orderNumber"> & Partial<Pick<OrderConfirmation, "currency" | "grandTotal" | "freightCharge" | "discountAmount" | "shippingMethod" | "couponCode" | "accountLinkSent">>;
|
|
15
15
|
export type WalletReturn<C> = {
|
|
16
16
|
action: "ignore";
|
|
17
17
|
} | {
|
|
@@ -6,6 +6,10 @@ export interface SetComponent {
|
|
|
6
6
|
prices: Record<string, number | null>;
|
|
7
7
|
hand?: SpareSide | null;
|
|
8
8
|
axle?: SpareAxle | null;
|
|
9
|
+
spin?: {
|
|
10
|
+
frame_count: number;
|
|
11
|
+
frames: string[];
|
|
12
|
+
} | null;
|
|
9
13
|
}
|
|
10
14
|
export declare function orderLinesForSets(components: SetComponent[], sets: number): {
|
|
11
15
|
partNumber: string;
|
|
@@ -30,6 +30,14 @@ export declare function spinAutoTurnStep(set: SpinSet, position: number, way: 1
|
|
|
30
30
|
};
|
|
31
31
|
export declare function parseSpinSets(v: unknown): SpinSets;
|
|
32
32
|
export declare function spinSetFor(sets: SpinSets, productSlug: string, finishName: string | undefined): SpinSet | null;
|
|
33
|
+
export declare function apiSpinFor(parts: readonly {
|
|
34
|
+
options: Record<string, string>;
|
|
35
|
+
components: readonly {
|
|
36
|
+
spin?: {
|
|
37
|
+
frames: string[];
|
|
38
|
+
} | null;
|
|
39
|
+
}[];
|
|
40
|
+
}[], finishName: string | undefined): SpinSet | null;
|
|
33
41
|
export declare function spinPreference(sets: SpinSets | undefined, productSlug: string): {
|
|
34
42
|
finish: string[];
|
|
35
43
|
} | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolveMedia as
|
|
1
|
+
import{resolveMedia as g}from"efficient-web-builder/render/lib/media";const h=4096,f=360,A=.9,E=!1,F=!1;function U(n){return n===!0}const m=14e3,y=1e-6,j=5e3,M=160;function R(n,t,r,e){const o=n.autoArc??M;if(x(n)&&o<f)return d(n.count,o,t,r,e*n.count/m);const i=x(n)?f:n.arc,s=t+r*e*n.count*f/(m*i);if(x(n))return{position:(s%n.count+n.count)%n.count,way:r};const u=n.count-y;return s>=u?{position:u,way:-1}:s<=0?{position:0,way:1}:{position:s,way:r}}const S=n=>Array.isArray(n)&&n.length>0&&n.every(t=>typeof t=="string"&&t.length>0),p=n=>g(n)??n,a=n=>Number.isInteger(n)&&n>0;function _(n,t){if(!n||typeof n!="object")return null;const{frame:r,cols:e,rows:o,urls:i}=n;return!a(r)||!a(e)||!a(o)||!S(i)||r*e>h||r*o>h||i.length!==Math.ceil(t/(e*o))?null:{frame:r,cols:e,rows:o,urls:i.map(p)}}function T(n){const{frames:t,count:r,startFrame:e,sheets:o}=n,i=S(t)?{count:t.length,frames:t.map(p)}:null;if(o&&typeof o=="object"&&a(r)&&typeof e=="string"&&e){const s=_(o.desktop,r),u=_(o.phone,r);if(s&&u)return{count:r,startFrame:p(e),sheets:{desktop:s,phone:u}}}return i}function b(n){if(!n||typeof n!="object")return null;const{arc:t,start:r}=n,e=T(n);if(!e)return null;if(t!==void 0){if(typeof t!="number"||!(t>0&&t<=f))return null;e.arc=t}const{autoArc:o}=n;return typeof o=="number"&&o>0&&o<=f&&(e.autoArc=o),Number.isInteger(r)&&r>=0&&r<e.count&&(e.start=r),e}function L(n){if(!n||typeof n!="object"||Array.isArray(n))return{};const t={};for(const[r,e]of Object.entries(n)){if(!e||typeof e!="object"||Array.isArray(e))continue;const o={};for(const[i,s]of Object.entries(e)){const u=b(s);u&&(o[i]=u)}Object.keys(o).length>0&&(t[r]=o)}return t}function k(n,t,r){return r?n[t]?.[r]??null:null}function w(n,t){if(!t)return null;for(const r of n)if(r.options.finish===t)for(const e of r.components){const o=e.spin?.frames?.filter(i=>typeof i=="string"&&i.length>0)??[];if(o.length>1)return{count:o.length,frames:o.map(p)}}return null}function D(n,t){const r=Object.keys(n?.[t]??{});return r.length>0?{finish:r}:null}function x(n){return n.arc===void 0||n.arc>=f}function d(n,t,r,e,o){const i=n*t/(2*f),s=(r%n+n)%n,u=s>n/2?s-n:s;let c=u>i?-1:u<-i?1:e,l=u+c*o;return c===1&&u<=i&&l>=i?[l,c]=[i,-1]:c===-1&&u>=-i&&l<=-i&&([l,c]=[-i,1]),{position:(l%n+n)%n,way:c}}function N(n){return x(n)?0:Math.floor(n.count/2)}function O(n){return n.start??N(n)}function I(n,t,r=!0){return r?(Math.floor(n)%t+t)%t:Math.max(0,Math.min(t-1,Math.floor(n)))}function C(n,t,r,e){const o=I(n,t,r),i=n-Math.floor(n),s=r?(o+1)%t:o+1<t?o+1:null;return e||i===0||s===null?{a:o,b:null,mix:0}:{a:o,b:s,mix:i}}function H(n,t,r){return r?n:Math.max(0,Math.min(t-1,n))}function B(n,t,r,e){return r<=0?n:n-t/r*e*A}function G(n,t){const r=n.cols*n.rows,e=t%r;return{url:n.urls[Math.floor(t/r)],col:e%n.cols,row:Math.floor(e/n.cols)}}export{M as DEFAULT_SPIN_AUTO_ARC,E as DEFAULT_SPIN_AUTO_TURN,F as DEFAULT_SPIN_HINT,j as SPIN_RESUME_MS,h as SPIN_SHEET_MAX_SIDE,m as SPIN_TURN_MS,w as apiSpinFor,x as isFullTurn,L as parseSpinSets,U as parseSpinSwitch,R as spinAutoTurnStep,C as spinBlend,G as spinCell,H as spinClampPosition,I as spinFrameIndex,B as spinPositionAfterDrag,D as spinPreference,k as spinSetFor,O as spinStartPosition};
|