efficient-storefront-blocks 0.119.0 → 0.119.2
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 +27 -0
- package/dist/chunks/{EditorPreviewCheckout-573RVCXC.js → EditorPreviewCheckout-URRXDD74.js} +1 -1
- package/dist/chunks/chunk-P6T6KGL3.js +1 -0
- package/dist/chunks/chunk-R4NVEFBL.js +1 -0
- package/dist/chunks/{fitment-data-HYODY7DX.js → fitment-data-PUHJNPTL.js} +1 -1
- package/dist/index.js +28 -28
- package/dist/render/components/SignUpFind.d.ts +3 -1
- package/dist/render/components/SignUpFind.js +1 -1
- package/dist/render/components/SignUpLink.d.ts +4 -2
- package/dist/render/components/SignUpLink.js +1 -1
- package/dist/render/lib/api/index.js +1 -1
- package/dist/render/lib/sections/sign-up.d.ts +6 -0
- package/dist/render/lib/sections/sign-up.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/chunk-CJ7IEW3F.js +0 -1
- package/dist/chunks/chunk-V7O6FKCB.js +0 -1
|
@@ -16,10 +16,12 @@ interface SignUpFindViewProps {
|
|
|
16
16
|
wrong?: string | null;
|
|
17
17
|
trouble?: SignUpTrouble | null;
|
|
18
18
|
linkGone?: boolean;
|
|
19
|
+
openTrouble?: SignUpTrouble | null;
|
|
19
20
|
busy?: boolean;
|
|
20
21
|
onEmail?: (value: string) => void;
|
|
21
22
|
onSubmit?: (event: FormEvent<HTMLFormElement>) => void;
|
|
22
23
|
onAnother?: () => void;
|
|
24
|
+
onRetry?: () => void;
|
|
23
25
|
}
|
|
24
|
-
export declare function SignUpFindView({ stage, productName, startHref, email, wrong, trouble, linkGone, busy, onEmail, onSubmit, onAnother, }: SignUpFindViewProps): import("react").JSX.Element;
|
|
26
|
+
export declare function SignUpFindView({ stage, productName, startHref, email, wrong, trouble, linkGone, openTrouble, busy, onEmail, onSubmit, onAnother, onRetry, }: SignUpFindViewProps): import("react").JSX.Element;
|
|
25
27
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as
|
|
1
|
+
"use client";import{jsx as e,jsxs as f,Fragment as O}from"react/jsx-runtime";import _ from"next/link";import{usePathname as C}from"next/navigation";import{useEffect as G,useId as L,useState as s}from"react";import{ApiError as j,askForWorkspaces as U,openWorkspaceFind as B}from"../lib/api/index.js";import{BANNER as v,CARD as E,PRIMARY as P,QUIET as N,TITLE as A}from"../lib/sections/sign-up-look.js";import{FIND_WORDS as t,SIGN_UP_WORDS as g,checkWaitingEmail as M,fill as V,findTokenOf as H,readFindOpenTrouble as Q,readFindRefusal as Y}from"../lib/sections/sign-up.js";function q({product:p,productName:y,startHref:h,inert:m=!1}){const n=m?"":H(C()),[b,i]=s(n?"opening":"form"),[r,x]=s(""),[k,u]=s(null),[F,d]=s(null),[o,c]=s(!1),[S,$]=s(null),[D,I]=s(0),[w,T]=s(!1);return G(()=>{if(!n)return;let l=!1;return B(n).then(a=>{l||(a?window.location.assign(a):(c(!0),i("form")))}).catch(a=>{l||($(a instanceof j?Q(a.status):"failed"),i("form"))}),()=>{l=!0}},[n,D]),e(z,{stage:b,productName:y,startHref:h,email:r,wrong:k,trouble:F,linkGone:o,openTrouble:S,busy:w,onEmail:l=>{x(l),u(null),d(null)},onSubmit:async l=>{if(l.preventDefault(),m||w)return;const a=M(r);if(u(a),d(null),!a){T(!0);try{await U(p,r),c(!1),$(null),i("sent")}catch(R){const W=R instanceof j?Y(R.status,R.data):{email:null,trouble:"failed"};u(W.email),d(W.trouble)}finally{T(!1)}}},onAnother:()=>i("form"),onRetry:()=>{$(null),i("opening"),I(l=>l+1)}})}function z({stage:p,productName:y,startHref:h,email:m,wrong:n,trouble:b,linkGone:i=!1,openTrouble:r=null,busy:x=!1,onEmail:k,onSubmit:u,onAnother:F,onRetry:d}){const o=L();if(p==="opening")return e("div",{className:E,role:"status",children:e("p",{className:N,children:t.opening})});if(p==="sent"){const[c,S]=t.sentBody.split("{email}");return f("div",{className:E,children:[e("h2",{className:A,children:t.sentTitle}),f("p",{className:"mt-[10px]",children:[c,e("span",{className:"font-medium",children:m.trim()}),S]}),e("p",{className:`${N} mt-[10px]`,children:t.sentNote}),e("button",{type:"button",onClick:F,className:"mt-[18px] flex h-11 w-full cursor-pointer items-center justify-center rounded-[10px] border border-line font-medium text-fg",children:t.another})]})}return f("form",{noValidate:!0,onSubmit:u,className:E,children:[e("h2",{className:A,children:t.title}),r?f(O,{children:[e("p",{role:"alert",className:`${v} mt-[10px]`,children:r==="unreachable"||r==="tooMany"?g.trouble[r]:t.openFailed}),e("button",{type:"button",onClick:d,className:"mt-3 flex h-11 w-full cursor-pointer items-center justify-center rounded-[10px] border border-line font-medium text-fg",children:t.retry})]}):i?e("p",{role:"alert",className:`${v} mt-[10px]`,children:t.linkGone}):e("p",{className:`${N} mt-1`,children:t.intro}),e("label",{htmlFor:`${o}-email`,className:"mb-1 mt-3 block text-[13px] font-medium",children:g.email}),e("div",{className:`flex h-11 items-center rounded-[10px] border bg-bg px-3 ${n?"border-alert":"border-line focus-within:border-accent"}`,children:e("input",{id:`${o}-email`,name:"email",type:"email",autoComplete:"email",maxLength:254,value:m,"aria-invalid":n?!0:void 0,"aria-describedby":n?`${o}-email-said`:void 0,onChange:c=>k?.(c.target.value),className:"h-full w-full bg-transparent text-[14px] text-fg outline-none focus-visible:outline-none!"})}),n&&e("p",{id:`${o}-email-said`,role:"alert",className:"mt-1 text-[13px] text-alert",children:n}),b&&e("p",{role:"alert",className:v,children:g.trouble[b]}),e("button",{type:"submit",disabled:x,className:P,children:x?g.sending:t.submit}),h&&f("p",{className:`${N} mt-3 text-center`,children:[V(t.newHere,{name:y})," ",e(_,{href:h,className:"text-accent",children:t.create})]})]})}export{z as SignUpFindView,q as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type LinkState } from "../lib/sections/sign-up.js";
|
|
1
|
+
import { type LinkState, type SignUpTrouble } from "../lib/sections/sign-up.js";
|
|
2
2
|
interface SignUpLinkProps {
|
|
3
3
|
token: string;
|
|
4
4
|
productName: string;
|
|
@@ -7,7 +7,9 @@ interface SignUpLinkProps {
|
|
|
7
7
|
findHref: string;
|
|
8
8
|
}
|
|
9
9
|
export default function SignUpLink({ token, productName, suffix, startHref, findHref }: SignUpLinkProps): import("react").JSX.Element;
|
|
10
|
-
export declare function SignUpLinkView({ state, productName, suffix, startHref, findHref, }: Omit<SignUpLinkProps, "token"> & {
|
|
10
|
+
export declare function SignUpLinkView({ state, note, onRetry, productName, suffix, startHref, findHref, }: Omit<SignUpLinkProps, "token"> & {
|
|
11
11
|
state: LinkState | null;
|
|
12
|
+
note?: SignUpTrouble | null;
|
|
13
|
+
onRetry?: () => void;
|
|
12
14
|
}): import("react").JSX.Element;
|
|
13
15
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as s}from"react/jsx-runtime";import
|
|
1
|
+
"use client";import{jsx as e,jsxs as s}from"react/jsx-runtime";import T from"next/link";import{useEffect as E,useState as k}from"react";import{openSignUpLink as K}from"../lib/api/index.js";import{BANNER as w,CARD as t,PRIMARY as S,QUIET as o,TITLE as c}from"../lib/sections/sign-up-look.js";import{LINK_ASKS_AT_MOST as R,LINK_WORDS as l,SIGN_UP_WORDS as m,buildProgress as L,buildSteps as M,fill as N,linkAskAfterMs as W,linkAsksAgain as P}from"../lib/sections/sign-up.js";function C({token:n,productName:g,suffix:f,startHref:u,findHref:p}){const[r,h]=k(null),[x,d]=k(null),[i,a]=k(0),[B,U]=k(0);E(()=>{let b=!1;const $=r!==null;if($&&(!P(r)||i>=R))return;const A=y=>{b||(y.kind==="trouble"&&r?.kind==="building"?d(y.trouble):(h(y),d(null)),a(D=>D+1))},j=window.setTimeout(()=>{K(n).then(A).catch(()=>A({kind:"trouble",trouble:"failed"}))},$?W(i):0);return()=>{b=!0,window.clearTimeout(j)}},[n,i,B]);const I=()=>{h(null),d(null),a(0),U(b=>b+1)},O=r?.kind==="building"&&i>=R;return e(F,{state:r,note:x,onRetry:r?.kind==="trouble"||O?I:void 0,productName:g,suffix:f,startHref:u,findHref:p})}const _=n=>n==="failed"?l.troubleFailed:m.trouble[n],v={done:{sign:"✓",tone:"text-green",spin:!1},running:{sign:"◌",tone:"text-accent",spin:!0},waiting:{sign:"○",tone:"text-fg-dim",spin:!1},stopped:{sign:"!",tone:"text-alert",spin:!1}};function F({state:n,note:g=null,onRetry:f,productName:u,suffix:p,startHref:r,findHref:h}){const x=i=>e(T,{href:r,className:S,children:i}),d=f&&e("button",{type:"button",onClick:f,className:S,children:l.tryAgain});if(n===null)return e("div",{className:t,role:"status",children:e("p",{className:o,children:l.checking})});switch(n.kind){case"building":case"failed":{const i=M(n,u,p);return s("div",{className:t,children:[e("h2",{className:c,children:N(l.settingUp,{company:n.company})}),n.kind==="building"&&e("div",{role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":L(n.status),"aria-label":N(l.settingUp,{company:n.company}),className:"mb-[10px] mt-[14px] h-[6px] rounded-[3px] bg-line",children:e("div",{className:"h-[6px] rounded-[3px] bg-accent transition-[width] duration-500",style:{width:`${L(n.status)}%`}})}),e("ul",{className:n.kind==="failed"?"mt-2":void 0,children:i.map(a=>s("li",{className:"flex items-center gap-[10px] py-[7px]",children:[e("span",{"aria-hidden":!0,className:`inline-block w-5 text-center text-[18px] leading-none ${v[a.at].tone} ${v[a.at].spin?"animate-spin":""}`,children:v[a.at].sign}),e("span",{children:a.words})]},a.words))}),n.kind==="failed"?e("p",{role:"alert",className:w,children:l.failedBody}):e("p",{role:"status",className:`${o} mt-3`,children:l.aboutTen}),n.kind==="building"&&g&&e("p",{className:`${o} mt-2`,children:_(g)}),n.kind==="building"&&d]})}case"ready":return s("div",{className:t,children:[e("span",{"aria-hidden":!0,className:"block text-[28px] leading-none text-green",children:"✓"}),e("h2",{className:`${c} mt-[6px]`,children:l.readyTitle}),e("dl",{className:"mt-[10px]",children:[[l.workspace,n.company],[l.address,`${n.slug}${p}`],[l.plan,N(l.planName,{name:u})]].map(([i,a])=>s("div",{className:"flex border-b border-line py-2",children:[e("dt",{className:`${o} w-24 shrink-0`,children:i}),e("dd",{className:"min-w-0 break-words font-medium",children:a})]},i))}),e("p",{className:"mt-[14px]",children:l.readyNext})]});case"taken":return s("div",{className:t,children:[e("h2",{className:c,children:l.takenTitle}),e("p",{className:"mt-[6px]",children:n.slug?N(l.takenBody,{address:`${n.slug}${p}`}):l.takenBodyBare}),x(l.chooseAnother)]});case"dailyLimit":return s("div",{className:t,children:[e("h2",{className:c,children:l.limitTitle}),e("p",{role:"alert",className:`${w} mt-1`,children:m.trouble.dailyLimit}),e("p",{className:`${o} mt-2`,children:l.limitNext})]});case"closed":return s("div",{className:t,children:[e("h2",{className:c,children:m.closedTitle}),e("p",{className:"mt-1",children:N(m.closedBody,{name:u})}),h&&s("p",{className:`${o} mt-[10px] text-center`,children:[m.haveOne," ",e(T,{href:h,className:"text-accent",children:m.find})]})]});case"trouble":return s("div",{className:t,children:[e("h2",{className:c,children:l.troubleTitle}),e("p",{role:"alert",className:`${w} mt-1`,children:_(n.trouble)}),d]});default:return s("div",{className:t,children:[e("h2",{className:c,children:l.goneTitle}),e("p",{className:"mt-[6px]",children:l.goneBody}),x(l.again)]})}}export{F as SignUpLinkView,C as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PREVIEW_TOKEN_HEADER as dt,SITE_HOST_HEADER as ut,SITE_SLUG_HEADER as lt}from"../site-headers.js";import{PRODUCT_API_BASE as pt,PRODUCT_BACKEND_URL as H}from"./origins.js";import{listRows as m}from"./list-rows.js";import{backendHopHeaders as yt,clientIpFromForwardedFor as ht,FORWARDED_FOR_HEADER as ft,hopCachingOf as gt}from"../forwarded-for.js";import mt from"efficient-web-builder/format/lib/document/media-manifest.json";import{auth as O}from"../auth.js";import{efficientClientOpen as wt}from"efficient-easel/screen/lib/session";import{listableWheelSummaries as U}from"../wheels/listable-wheels.js";import{dropRenderlessFinishes as F}from"../wheels/renderable-finishes.js";const St=process.env.NEXT_PUBLIC_API_URL??"http://localhost:8000";class w extends Error{status;data;constructor(e,n,s){super(n),this.status=e,this.data=s}}const v="Unable to reach the server. This could be a problem with your internet connection, or the server may be undergoing maintenance or an upgrade. Please try again shortly.",Pt=new Set([502,503,504]),k=0,Ot="This editor runs on its host's own backend, which does not serve this request.",bt=5e3,Tt=15e3,At=()=>typeof window>"u"?bt:Tt;function M(t){const e=(t.method??"GET").toUpperCase();if(!(t.body!=null||e!=="GET"&&e!=="HEAD")&&!(t.audience!=null&&t.audience!=="shop")&&typeof AbortSignal?.timeout=="function")return AbortSignal.timeout(At())}const B=t=>t instanceof Error&&t.name==="TimeoutError",q=(t,e)=>Pt.has(t)?v:e,Rt=["admin","venue"];let G="admin";function Ee(t){G=Rt.includes(t)?t:"admin"}function Et(){return G}const _t=/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{1,8})*$/;let W=null;function _e(t){W=t&&_t.test(t)?t:null}function Ut(){return W}function $t(t){if(typeof window>"u"||!t.startsWith("/api/v1/"))return t;const e=Y();return!e||/[?&]site=/.test(t)?t:$(t,`site=${encodeURIComponent(e)}`)}async function i(t,e={}){const{token:n,baseUrl:s,headers:u,audience:l,...y}=e;if(typeof window<"u"&&!wt())throw new w(k,Ot,null);if(typeof window>"u"&&s===void 0)throw new Error(`apiFetch(${JSON.stringify(t)}) ran on the server without an explicit baseUrl. The API_URL default it would inherit is browser-only (the prod image bakes NEXT_PUBLIC_API_URL="" for same-origin use, which a Node fetch cannot resolve). Pass a base explicitly: \`await backendOpts()\` (or baseUrl: PRODUCT_FETCH_BASE) for product reads, or the server-only PRODUCT_BACKEND_URL env for other backend surfaces.`);const a=typeof FormData<"u"&&y.body instanceof FormData;let r;try{r=await fetch(`${s??St}${$t(t)}`,{...y,headers:{...a?{}:{"Content-Type":"application/json"},...n?{Authorization:`Bearer ${n}`}:{},...l===null?{}:{"X-Portal-Audience":l??"shop"},...u},signal:y.signal??M({...y,audience:l})})}catch(h){throw h instanceof TypeError||B(h)?new w(k,v,null):h}let o;try{o=await r.text()}catch(h){throw B(h)?new w(k,v,null):h}let p=null;if(o)try{p=JSON.parse(o)}catch{throw new w(r.status,r.ok?"Expected JSON but received a non-JSON response":q(r.status,r.statusText),o)}if(!r.ok){const h=(p&&typeof p=="object"&&"detail"in p&&typeof p.detail=="string"?p.detail:null)??q(r.status,r.statusText);throw new w(r.status,h,p)}return p}let A=null;async function j(){return A||(A=Ct().finally(()=>{A=null}),A)}async function Ct(){const t=O.takeLegacyRefresh(),e=await vt.refresh(t??void 0);return O.setTokens(e.access),e.access}async function z(){return O.getAccess()??j()}async function g(t,e={}){let n;try{n=await z()}catch{throw O.clear(),new w(401,"Not signed in",null)}try{return await i(t,{...e,token:n})}catch(s){if(!(s instanceof w)||s.status!==401)throw s;try{const u=await j();return await i(t,{...e,token:u})}catch{throw O.clear(),s}}}const Nt=100,K=20;function It(t){if(!t)return null;try{return new URL(t,"http://page.invalid").searchParams.get("page")}catch{return null}}async function V(t,e){const[n,s=""]=t.split("?"),u=[];let l="1";for(let y=0;y<K&&l;y++){const a=new URLSearchParams(s);a.set("page_size",String(Nt)),l!=="1"&&a.set("page",l);const r=await g(`${n}?${a.toString()}`);u.push(...m(r)),l=It(r.next)}return l&&console.warn(`[${e}] stopped at ${K} pages (${u.length} rows); list may be truncated`),u}async function X(t,e={}){if(O.getAccess())try{return{data:await g(t,e),asShopper:!0}}catch(n){if(!(n instanceof w)||n.status!==401)throw n}return{data:await i(t,e),asShopper:!1}}async function Z(){const t=await g("/api/auth/me/");if(t.portal!=="shop")throw O.clear(),new w(403,"This session is not valid for this shop.",null);return t}const vt={login:(t,e)=>i("/api/auth/login/",{method:"POST",body:JSON.stringify({email:t,password:e,portal:"shop"}),credentials:"include"}),refresh:t=>i("/api/auth/refresh/",{method:"POST",body:JSON.stringify(t?{refresh:t,portal:"shop"}:{portal:"shop"}),credentials:"include"}),logout:async()=>{O.clear();try{await i("/api/auth/logout/",{method:"POST",body:JSON.stringify({portal:"shop"}),credentials:"include"})}catch{}},restoreSession:async()=>{const t=await z();return await Z(),t},me:Z,updateMe:t=>g("/api/auth/me/",{method:"PATCH",body:JSON.stringify(t)}),changePassword:(t,e)=>g("/api/auth/me/",{method:"PATCH",body:JSON.stringify({password:e,old_password:t})}),changeEmail:(t,e)=>g("/api/shop-portal/change-email/",{method:"POST",body:JSON.stringify({new_email:t,current_password:e})}),myProfile:()=>g("/api/shop-portal/profile/"),updateMyProfile:t=>g("/api/shop-portal/profile/",{method:"PATCH",body:JSON.stringify(t)}),myAddresses:()=>g("/api/shop-portal/delivery-locations/"),createAddress:t=>g("/api/shop-portal/delivery-locations/",{method:"POST",body:JSON.stringify(t)}),updateAddress:(t,e)=>g(`/api/shop-portal/delivery-locations/${t}/`,{method:"PATCH",body:JSON.stringify(e)}),deleteAddress:t=>g(`/api/shop-portal/delivery-locations/${t}/`,{method:"DELETE"}),passwordResetRequest:t=>i("/api/auth/password-reset/",{method:"POST",body:JSON.stringify({email:t})}),passwordResetConfirm:(t,e,n)=>i("/api/auth/password-reset/confirm/",{method:"POST",body:JSON.stringify({uid:t,token:e,new_password:n})}),brands:()=>g("/api/products/brands/"),myOrders:()=>V("/api/shop-portal/orders/","api.myOrders"),myOrder:t=>g(`/api/shop-portal/orders/${t}/`),cancelOrder:t=>g(`/api/shop-portal/orders/${t}/cancel/`,{method:"POST"}),myReturns:t=>V(`/api/shop-portal/returns/${t?`?order=${encodeURIComponent(t)}`:""}`,"api.myReturns"),createReturn:t=>g("/api/shop-portal/returns/",{method:"POST",body:JSON.stringify(t)}),withdrawReturn:t=>g(`/api/shop-portal/returns/${t}/cancel/`,{method:"POST"}),uploadReturnPhoto:(t,e)=>{const n=new FormData;return n.append("claim_item",t),n.append("file",e),n.append("media_type",e.type.startsWith("video/")?"video":"image"),g("/api/shop-portal/return-media/",{method:"POST",body:n})}};import{media as kt,absolutizeApiUrl as L}from"efficient-web-builder/render/lib/media";import{analyzeLogoSvg as Lt,isSvgUrl as Jt}from"efficient-web-builder/format/lib/logo/reverse-svg";import{getEditorSiteId as xt}from"efficient-web-builder/render/lib/editor-site";import{shopRouteBase as Dt,webRuntimeSiteSlug as Y}from"efficient-web-builder/format/lib/web-runtime";import{readDealerList as Ht}from"../sections/dealer-finder.js";import{SIGN_UP_PATH as Ft,SIGN_UP_VERIFY_PATH as Mt,SIGN_UP_WAITING_PATH as Bt,WORKSPACE_FINDS_PATH as qt,WORKSPACE_FIND_OPEN_PATH as Gt,signInUrlOf as Wt,readLinkAnswer as Q,readSignUpAvailability as jt,readSignUpSent as zt,signUpAvailabilityPath as Kt}from"../sections/sign-up.js";function S(t){if(typeof t=="string")return t.startsWith("/media/")?kt(t):t;if(Array.isArray(t))return t.map(S);if(t&&typeof t=="object"){const e={};for(const[n,s]of Object.entries(t))e[n]=n==="captions"&&s&&typeof s=="object"&&!Array.isArray(s)?Object.fromEntries(Object.entries(s).map(([u,l])=>[S(u),l])):S(s);return e}return t}import{PRODUCT_API_BASE as Ke}from"./origins.js";const tt=typeof window>"u"&&H!=="",Vt=tt?H:pt,Xt=Dt,b=()=>({baseUrl:Xt(),audience:null});function c(t,e){const n=e?`?process=${encodeURIComponent(e)}`:"";return`/api/v1${t}${n}`}const et=100,at=50;function J(t,e,n){const s=new URLSearchParams;for(const[u,l]of Object.entries(e))l!=null&&l!==""&&s.set(u,String(l));return s.set("pageSize",String(et)),n&&s.set("cursor",n),`/api/v1${t}?${s.toString()}`}function Zt(t,e){return J("/wheels",{process:t},e)}const rt=et;function Yt(t,e){return J("/wheels",{slug:t.join(",")},e)}function Qt(t,e,n){return J("/products",{kind:t.join(","),make:e?.make,model:e?.model,year:e?.year,modification:e?.modification},n)}function te(t){if(!t)return null;try{return new URL(t,"http://cursor.invalid").searchParams.get("cursor")}catch{return null}}async function x(t,e,n=()=>!1,s=()=>!1){const u=[];let l=null;try{for(let y=0;y<at;y++){const a=await i(await e(l),await d());if(u.push(...m(a)),l=te(a.next),!l)break;if(s(u))return u}l&&console.warn(`[${t}] stopped at ${at} pages (${u.length} rows); catalog may be truncated`)}catch(y){if(n(y))throw y;console.warn(`[${t}] product API unavailable, returning []`,y)}return u}const nt=t=>t instanceof w&&t.status===400;function st(t){return t.flatMap(e=>e.kind==="alloy-wheel"?U([e]):[e])}async function ot(){return(await ee()).host}async function ee(){try{const{headers:t}=await import("next/headers"),e=await t(),n=l=>l?.split(",")[0]?.split(":")[0]?.trim().toLowerCase()||null,s=n(e.get(ut)??e.get("x-forwarded-host")??e.get("host")),u=n(e.get("host"));return{host:s,matchesRequestHost:s!==null&&s===u}}catch{return{host:null,matchesRequestHost:!1}}}async function ae(){try{const{headers:t}=await import("next/headers");return ht((await t()).get(ft))}catch{return null}}async function re(){try{const{headers:t}=await import("next/headers");return(await t()).get(lt)||null}catch{return null}}async function ne(){const t=await re();if(t)return`site=${encodeURIComponent(t)}`;const e=await ot();return e?`host=${encodeURIComponent(e)}`:""}async function f(t){if(typeof window<"u"){const e=Y();return e?$(t,`site=${encodeURIComponent(e)}`):t}return $(t,await ne())}function $(t,e){return e?`${t}${t.includes("?")?"&":"?"}${e}`:t}const se="preview";async function oe(){if(typeof window<"u")return null;try{const{headers:t}=await import("next/headers");return(await t()).get(dt)}catch{return null}}async function ie(){try{const{headers:t}=await import("next/headers");return(await t()).get("user-agent")}catch{return null}}async function D(t,e){const n=await oe();if(n===null)return[await f(t),await d(e)];const s=$(await f(t),`${se}=${encodeURIComponent(n)}`),{next:u,cache:l,...y}=e??{},a=await d({...y,cache:"no-store"}),r=await ie();return r&&(a.headers={...a.headers,"user-agent":r}),[s,a]}async function ce(t){if(!tt)return;const[e,n]=await Promise.all([ot(),ae()]),s=yt(e,n,t);return Object.keys(s).length>0?s:void 0}async function d(t){const e=await ce(gt(t)),n={baseUrl:Vt,...t};return e&&(n.headers={...e,...t?.headers}),n}const R=typeof window>"u";function E(t,e){const n=new URLSearchParams;for(const[u,l]of Object.entries(e))l!==void 0&&l!==""&&n.set(u,String(l));const s=n.toString();return`/api/v1/fitment${t}${s?`?${s}`:""}`}const ke={listMakes:async t=>{if(R){const{fitmentData:n}=await import("./fitment-data.js");return n.makes(t)}const e=await i(E("/makes",{region:t}),b());return m(e)},listModels:async(t,e)=>{if(R){const{fitmentData:s}=await import("./fitment-data.js");return s.models(t,e)}const n=await i(E("/models",{make:t,region:e}),b());return m(n)},listYears:async(t,e,n)=>{if(R){const{fitmentData:u}=await import("./fitment-data.js");return u.years(t,e,n)}const s=await i(E("/years",{make:t,model:e,region:n}),b());return m(s)},listModifications:async(t,e,n,s)=>{if(R){const{fitmentData:l}=await import("./fitment-data.js");return l.modifications(t,e,n,s)}const u=await i(E("/modifications",{make:t,model:e,year:n,region:s}),b());return m(u)},getStockFitment:async(t,e,n,s,u)=>{if(R){const{fitmentData:l}=await import("./fitment-data.js");return l.stockFitment(t,e,n,s,u)}return i(E("/stock-fitment",{make:t,model:e,year:n,modification:s,region:u}),b())}},Le={listWheels:async(t,e={})=>{const n=await x("products.listWheels",async s=>await f(Zt(t,s)),e.throwOnFailure?()=>!0:void 0,e.maxRows===void 0?void 0:s=>U([...s]).length>=e.maxRows);return U(S(n))},listWheelsBySlug:async(t,e={})=>{const n=[...new Set(t.map(a=>a.trim()).filter(Boolean))];if(n.length===0)return[];const s=[];for(let a=0;a<n.length;a+=rt)s.push(n.slice(a,a+rt));const u=await Promise.all(s.map(a=>x("products.listWheelsBySlug",async r=>await f(Yt(a,r)),e.throwOnFailure?()=>!0:nt))),l=new Set(n),y=u.flat().filter(a=>l.has(a.slug));return U(S(y))},listCatalog:async(t,e,n={})=>{if(t.length===0)throw new Error("products.listCatalog() needs at least one kind. An empty list would omit `kind`, which the contract reads as `alloy-wheel` — so the call would silently return the wheel catalog instead of nothing.");const s=await x("products.listCatalog",async u=>await f(Qt(t,e,u)),n.throwOnFailure?()=>!0:nt,n.maxRows===void 0?void 0:u=>st([...u]).length>=n.maxRows);return st(S(s))},getWheel:async t=>F(S(await i(await f(c(`/wheels/${t}`)),await d()))),getTyre:async t=>S(await i(await f(c(`/tyres/${t}`)),await d())),listBundles:async(t={})=>{try{return await i(await f(c("/bundles")),await d())}catch(e){if(t.throwOnFailure)throw e;return[]}},getBundle:async t=>i(await f(c(`/bundles/${t}`)),await d()),listGalleryBuilds:async(t={})=>{const{process:e=null,wheelSlug:n=null}=t;if(typeof window>"u"){const{listGalleryBuilds:s}=await import("./gallery-builds-data.js");return S(s(e,n))}try{const s=new URLSearchParams;e&&s.set("process",e),n&&s.set("wheelSlug",n);const u=s.toString(),l=await i(`/api/v1/gallery-builds${u?`?${u}`:""}`,b());return S(m(l))}catch(s){return console.warn("[products.listGalleryBuilds] product API unavailable, returning []",s),[]}},getSite:async()=>i(await f(c("/site")),await d()),getSiteBySlug:async t=>i(`${c("/site")}?${new URLSearchParams({site:t})}`,typeof window>"u"?await d():void 0),listPages:async()=>S(await i(await f(c("/pages")),await d())),listPopups:async()=>i(await f(c("/popups")),await d()),listProductTemplates:async()=>{try{return await i(await f(c("/product-templates")),await d())}catch(t){return console.warn("[products.listProductTemplates] unavailable, returning []",t),[]}},listDynamicPages:async t=>{const e=t?`?recordType=${encodeURIComponent(t)}`:"";try{return await i(await f(`${c("/dynamic-pages")}${e}`),await d())}catch(n){if(n instanceof w&&n.status===404)return[];throw n}},getRecord:async(t,e)=>{try{return await i(await f(c(`/records/${encodeURIComponent(t)}/${encodeURIComponent(e)}`)),await d())}catch(n){if(n instanceof w&&n.status===404)return null;throw n}},listRecordKeys:async t=>{try{const e=await i(await f(c(`/records/${encodeURIComponent(t)}`)),await d({cache:"no-store"}));return Array.isArray(e?.keys)?e.keys.filter(n=>typeof n=="string"&&n!==""):[]}catch(e){if(e instanceof w&&e.status===404)return[];throw e}},listProductTypeChoices:async()=>{try{return await i(await f(c("/product-type-choices")),await d())}catch(t){return console.warn("[products.listProductTypeChoices] unavailable, returning []",t),[]}},listFieldUsage:async()=>{try{return await i(await f(c("/field-usage")),await d())}catch(t){return console.warn("[products.listFieldUsage] unavailable, returning []",t),[]}},getPage:async(t,e={})=>{const n=e.record?`?record=${encodeURIComponent(e.record)}`:"",[s,u]=await D(c(`/pages/${t}`)+n,e.revalidate!==void 0?{next:{revalidate:e.revalidate}}:void 0);return S(await i(s,u))},listBlogPosts:async(t={},{throwOnFailure:e=!1}={})=>{const n=t.category?`?category=${encodeURIComponent(t.category)}`:"";try{return(await i(c("/blog-posts")+n,await d())).map(u=>({...u,coverImage:L(u.coverImage)??""}))}catch(s){if(e)throw s;return console.warn("[products.listBlogPosts] blog API unavailable, returning []",s),[]}},getBlogPost:async t=>{const e=await i(c(`/blog-posts/${t}`),await d());return{...e,coverImage:L(e.coverImage)??""}},createOrder:async t=>i(c("/orders"),await d({method:"POST",body:JSON.stringify(t)})),createOrderAuthed:async t=>g(c("/orders"),await d({method:"POST",body:JSON.stringify(t)})),lookupOrder:async t=>i(c("/orders/lookup"),await d({method:"POST",body:JSON.stringify(t)})),createPaymentIntent:async t=>i(c("/payments/intent"),await d({method:"POST",body:JSON.stringify(t)})),releaseCheckout:async t=>i(c("/checkouts/release"),await d({method:"POST",body:JSON.stringify(t)})),createPaypalOrder:async t=>i(c("/payments/paypal/order"),await d({method:"POST",body:JSON.stringify(t)})),capturePaypalOrder:async t=>i(c("/payments/paypal/capture"),await d({method:"POST",body:JSON.stringify(t)})),createAfterpayCheckout:async t=>i(c("/payments/afterpay/checkout"),await d({method:"POST",body:JSON.stringify(t)})),captureAfterpayPayment:async t=>i(c("/payments/afterpay/capture"),await d({method:"POST",body:JSON.stringify(t)})),chargeSquare:async t=>i(c("/payments/square/charge"),await d({method:"POST",body:JSON.stringify(t)})),createGocardlessBillingRequest:async t=>i(c("/payments/gocardless/billing-request"),await d({method:"POST",body:JSON.stringify(t)})),completeGocardlessPayment:async t=>i(c("/payments/gocardless/complete"),await d({method:"POST",body:JSON.stringify(t)})),createZipCheckout:async t=>i(c("/payments/zip/checkout"),await d({method:"POST",body:JSON.stringify(t)})),captureZipPayment:async t=>i(c("/payments/zip/capture"),await d({method:"POST",body:JSON.stringify(t)})),createKlarnaCheckout:async t=>i(c("/payments/klarna/checkout"),await d({method:"POST",body:JSON.stringify(t)})),captureKlarnaPayment:async t=>i(c("/payments/klarna/capture"),await d({method:"POST",body:JSON.stringify(t)})),createStockAlert:async t=>i(c("/stock-alerts"),await d({method:"POST",body:JSON.stringify(t)})),createPreOrderIntent:async t=>i(c("/pre-order-intents"),await d({method:"POST",body:JSON.stringify(t)})),createNewsletterSubscription:async t=>i(c("/newsletter-subscriptions"),await d({method:"POST",body:JSON.stringify(t)})),unsubscribeNewsletter:async t=>i(c("/newsletter-unsubscribe"),await d({method:"POST",body:JSON.stringify(t)})),captureCart:async t=>i(c("/carts"),await d({method:"POST",body:JSON.stringify(t)})),restoreCart:async t=>i(c("/carts/restore"),await d({method:"POST",body:JSON.stringify(t)})),unsubscribeCartReminders:async t=>i(c("/carts/unsubscribe"),await d({method:"POST",body:JSON.stringify(t)})),listReviews:async(t={})=>{const e=new URLSearchParams;t.limit&&e.set("limit",String(t.limit)),t.designCode&&e.set("designCode",t.designCode);const n=c("/reviews"),s=e.toString();try{return await i(await f(s?`${n}?${s}`:n),await d())}catch(u){return console.warn("[products.listReviews] product API unavailable, returning []",u),[]}},submitReview:async t=>i(c("/reviews"),await d({method:"POST",body:JSON.stringify(t)})),getForm:async t=>i(c(`/forms/${encodeURIComponent(t)}`),await d()),submitForm:async(t,e)=>i(c(`/forms/${encodeURIComponent(t)}/submissions`),await d({method:"POST",body:JSON.stringify(e)})),listShippingMethods:async()=>{try{return await i(c("/shipping-methods"),await d())}catch(t){return console.warn("[products.listShippingMethods] product API unavailable, returning []",t),[]}},listCountrySubdivisions:async t=>{try{return await i(c(`/countries/${encodeURIComponent(t)}/subdivisions`),await d())}catch(e){return console.warn("[products.listCountrySubdivisions] unavailable, returning []",e),[]}},quoteCart:async t=>{const e=c("/cart/quote"),n=await d({method:"POST",body:JSON.stringify(t)});return t.couponCode?(await X(e,n)).data:i(e,n)},validateCoupon:async t=>{const{data:e,asShopper:n}=await X(c("/coupons/validate"),await d({method:"POST",body:JSON.stringify(t)}));return{...e,askedAsShopper:n}},getHeaderSettings:async()=>{const t=M({method:"GET"}),e=await i(...await D(c("/header-settings"),{signal:t})),n=L(e.logoUrl);let s=null,u=null;if(n&&Jt(n)){const l=await Lt(n,t);l&&(s=l.reversed,u=l.inkIsDark)}return{...e,logoUrl:n,logoReversed:s,logoInkIsDark:u}},getThemeSettings:async()=>i(...await D(c("/theme-settings"))),getChatSettings:async()=>i(await f(c("/chat-settings")),await d())},Je={listServices:async()=>{try{return await i(c("/bookings/services"),await d())}catch(t){return console.warn("[bookings.listServices] API unavailable, returning []",t),{results:[],currency:"USD"}}},getAvailability:async(t,e)=>i(c(`/bookings/availability?service=${encodeURIComponent(t)}&date=${e}`),await d()),create:async t=>i(c("/bookings"),await d({method:"POST",body:JSON.stringify(t)})),get:async t=>i(c(`/bookings/manage/${encodeURIComponent(t)}`),await d()),cancel:async t=>i(c(`/bookings/manage/${encodeURIComponent(t)}/cancel`),await d({method:"POST"})),createPaymentIntent:async t=>i(c("/bookings/payments/intent"),await d({method:"POST",body:JSON.stringify({manageToken:t})}))};class de extends Error{slug;count;constructor(e,n){super(`Slug "${e}" exists on ${n} websites; a site is required to pick one.`),this.slug=e,this.count=n,this.name="AmbiguousPageSlugError"}}const C=(t,e,n)=>{const s=new URLSearchParams({...e?{site:e}:{},...n?{draft:"1"}:{}}).toString();return`/api/storefront/${t}/${s?`?${s}`:""}`},N=t=>`/api/storefront/sites/${encodeURIComponent(t)}/`,ue=t=>`${N(t)}currencies/`,le="/api/storefront/media/ingest/";class pe extends Error{constructor(){super("This editor is not connected to a website, so an upload has nowhere to go. Open the page from the website the file should belong to, then try again."),this.name="MediaUploadDestinationError"}}function ye(){const t=xt();if(!t)throw new pe;return`${le}?${new URLSearchParams({site:t})}`}const he="X-Puck-Media-Manifest",it=mt.contentHash,I={"X-Media-Manifest":it,[he]:it},xe=ct({});function ct(t){return(e,n={})=>{const s=Ut(),u=t.headers||s?{...s?{"Accept-Language":s}:{},...t.headers,...n.headers}:void 0;return i(e,{...n,...t.baseUrl!==void 0?{baseUrl:t.baseUrl}:{},...u?{headers:u}:{},audience:t.audience??Et()})}}function fe(t={}){const e=ct(t),n=t.siteDrafts===!0,s=a=>C("header-settings",a,n),u=a=>C("theme-settings",a,n),l=a=>C("chat-settings",a,n),y=a=>C("social-settings",a,n);return{findPageBySlug:async(a,r,o)=>{const p=new URLSearchParams({slug:a});o&&p.set("site",o);const h=await e(`/api/storefront/pages/?${p.toString()}`,{token:r}),P=m(h);if(!o&&P.length>1)throw new de(a,P.length);return P[0]??null},getPageById:(a,r)=>e(`/api/storefront/pages/${a}/`,{token:r}),saveLayout:(a,r,o,p,h)=>e(`/api/storefront/pages/${a}/`,{method:"PATCH",body:JSON.stringify({layout:r,expected_updated_at:p,...h?{client_id:h}:{}}),token:o}),duplicatePage:(a,r,o)=>e(`/api/storefront/pages/${a}/duplicate/`,{method:"POST",body:JSON.stringify({title:r.title,slug:r.slug}),token:o}),geocode:(a,r,o)=>e(`/api/storefront/geocode/?${new URLSearchParams(o?{q:a,country:o}:{q:a})}`,{token:r}),listBlockSources:a=>e("/api/storefront/block-sources/",{token:a}),listRecordTypes:a=>e("/api/storefront/record-types/",{token:a}),createPagePreviewLink:(a,r)=>e(`/api/storefront/pages/${a}/preview-link/`,{method:"POST",token:r}),claimPageEditLock:(a,r,o,p=!1)=>e(`/api/storefront/pages/${a}/edit-lock/`,{method:"POST",body:JSON.stringify({client_id:o,takeover:p}),token:r}),releasePageEditLock:(a,r)=>e(`/api/storefront/pages/${a}/edit-lock/`,{method:"DELETE",token:r}),createTemplate:(a,r,o)=>e("/api/storefront/page-templates/",{method:"POST",body:JSON.stringify({name:a,layout:r}),headers:I,token:o}),getTemplate:(a,r)=>e(`/api/storefront/page-templates/${a}/`,{token:r}),saveTemplateLayout:(a,r,o)=>e(`/api/storefront/page-templates/${a}/`,{method:"PATCH",body:JSON.stringify({layout:r}),headers:I,token:o}),listTemplatePages:async(a,r)=>{const o=await e(`/api/storefront/template-pages/?template=${encodeURIComponent(a)}`,{token:r});return m(o)},getPageLibrary:async a=>{const r=await e("/api/storefront/page-templates/?is_page_library=true&is_active=true",{token:a});return m(r)[0]??null},getTemplateLibrary:(a,r)=>e(`/api/storefront/pages/template-library/?site=${encodeURIComponent(a)}`,{token:r}),createPageFromTemplate:(a,r)=>e(`/api/storefront/pages/from-template/${n?"?draft=1":""}`,{method:"POST",body:JSON.stringify(a),token:r}),findTemplatePageBySlug:async(a,r,o)=>{const p=await e(`/api/storefront/template-pages/?template=${encodeURIComponent(a)}&slug=${encodeURIComponent(r)}`,{token:o});return m(p)[0]??null},createTemplatePage:(a,r,o)=>e("/api/storefront/template-pages/",{method:"POST",body:JSON.stringify({template:a,...r}),headers:I,token:o}),saveTemplatePageLayout:(a,r,o)=>e(`/api/storefront/template-pages/${a}/`,{method:"PATCH",body:JSON.stringify({layout:r}),headers:I,token:o}),deleteTemplatePage:(a,r,o)=>e(`/api/storefront/template-pages/${a}/`,{method:"DELETE",token:r,...o?.keepalive?{keepalive:!0}:{}}),listPages:async(a,r)=>{const o=new URLSearchParams({no_page:"true"});r&&o.set("site",r);const p=await e(`/api/storefront/pages/?${o.toString()}`,{token:a});return m(p)},createPage:(a,r,o,p)=>e("/api/storefront/pages/",{method:"POST",body:JSON.stringify({title:a,slug:r,layout:o}),token:p}),deletePage:(a,r)=>e(`/api/storefront/pages/${a}/`,{method:"DELETE",token:r}),getHeaderSettings:(a,r)=>e(s(r),{token:a}),listMenus:async(a,r)=>{const o=new URLSearchParams({no_page:"true"});r&&o.set("site",r);const p=await e(`/api/storefront/menus/?${o}`,{token:a});return m(p)},listBlogPosts:async(a,r={})=>{const o=new URLSearchParams({no_page:"true"});r.visibleOnly&&o.set("is_visible","true"),r.siteId&&o.set("site",r.siteId);const p=await e(`/api/storefront/blog-posts/?${o.toString()}`,{token:a});return m(p)},listFieldUsage:async(a,r)=>{const o=await e(`/api/storefront/field-usage/?site=${encodeURIComponent(r)}`,{token:a});return Array.isArray(o?.entries)?o.entries:[]},listCategories:async(a,r={})=>{const o=new URLSearchParams({no_page:"true"});r.visibleOnly&&o.set("is_visible","true"),r.siteId&&o.set("site",r.siteId);const p=await e(`/api/storefront/categories/?${o.toString()}`,{token:a});return[...m(p)].sort((P,_)=>P.sort_order-_.sort_order||P.name.localeCompare(_.name))},listForms:async(a,r={})=>{const o=new URLSearchParams({no_page:"true"});r.siteId&&o.set("site",r.siteId);const p=await e(`/api/storefront/forms/?${o.toString()}`,{token:a});return[...m(p)].sort((P,_)=>P.title.localeCompare(_.title))},listWheelSummaries:async(a,r={})=>{const o=new URLSearchParams;r.siteId&&o.set("site",r.siteId);const p=o.toString(),h=await e(`/api/storefront/wheel-curations/summaries/${p?`?${p}`:""}`,{token:a});return S(h)},listProducts:async(a,r={})=>{const o=new URLSearchParams;r.kinds?.length&&o.set("kind",r.kinds.join(",")),r.siteId&&o.set("site",r.siteId);const p=o.toString(),h=await e(`/api/storefront/products/${p?`?${p}`:""}`,{token:a});return S(h)},getWheelDetail:async(a,r,o={})=>{const p=new URLSearchParams({slug:r});return o.siteId&&p.set("site",o.siteId),F(S(await e(`/api/storefront/wheel-curations/detail/?${p.toString()}`,{token:a})))},updateHeaderSettings:(a,r,o)=>e(s(o),{method:"PATCH",body:JSON.stringify(a),token:r}),getSite:(a,r)=>e(N(a),{token:r}),listSites:async a=>{const r=await e("/api/storefront/sites/?no_page=true",{token:a});return m(r)},listSiteCurrencies:async(a,r)=>{const o=await e(ue(a),{token:r});return Array.isArray(o)?o:[]},publishSite:(a,r)=>e(`${N(a)}publish/`,{method:"POST",token:r}),getSiteLiveState:(a,r)=>e(`${N(a)}live-state/`,{token:r}),getThemeSettings:(a,r)=>e(u(r),{token:a}),updateThemeSettings:(a,r,o)=>e(u(o),{method:"PATCH",body:JSON.stringify(a),token:r}),getMyPreferences:async a=>(await e("/api/auth/me/",{token:a})).preferences??{},updateMyPreferences:(a,r)=>e("/api/auth/me/",{method:"PATCH",body:JSON.stringify({preferences:a}),token:r}),getChatSettings:(a,r)=>e(l(r),{token:a}),updateChatSettings:(a,r,o)=>e(l(o),{method:"PATCH",body:JSON.stringify(a),token:r}),getSocialSettings:(a,r)=>e(y(r),{token:a}),updateSocialSettings:(a,r,o)=>e(y(o),{method:"PATCH",body:JSON.stringify(a),token:r}),uploadHeaderLogo:(a,r,o)=>{const p=new FormData;return p.append("logo",a),e(s(o),{method:"PATCH",body:p,token:r})},clearHeaderLogo:(a,r)=>e(s(r),{method:"PATCH",body:JSON.stringify({logo:null}),token:a}),setHeaderLogoFromAsset:(a,r,o)=>e(s(o),{method:"PATCH",body:JSON.stringify({logo_asset_id:a}),token:r}),uploadMedia:async(a,r)=>{const o=new FormData;return o.append("file",a),e(ye(),{method:"POST",body:o,token:r})},listMedia:async(a,r)=>{const o=new URLSearchParams({no_page:"true"});r&&o.set("kind",r);const p=await e(`/api/storefront/media-assets/?${o.toString()}`,{token:a});return m(p)}}}const De=fe({siteDrafts:!0});function ge(t){const e=t.trim();return e?`/api/v1/dealers?${new URLSearchParams({near:e}).toString()}`:"/api/v1/dealers"}async function He(t){return Ht(await i(ge(t)))}const T={audience:null,baseUrl:""};async function Fe(t,e){return jt(await i(Kt(t,e),T))}async function Me(t){return zt(await i(Ft,{...T,method:"POST",body:JSON.stringify(t)}))}async function Be(t){try{const e=await i(Mt,{...T,method:"POST",body:JSON.stringify({token:t})});return Q(202,e)}catch(e){if(e instanceof w)return Q(e.status,e.data);throw e}}async function qe(t,e){await i(Bt,{...T,method:"POST",body:JSON.stringify({email:e.trim(),...t?{product:t}:{}})})}async function Ge(t,e){await i(qt,{...T,method:"POST",body:JSON.stringify({email:e.trim(),...t?{product:t}:{}})})}async function We(t){try{return Wt(await i(Gt,{...T,method:"POST",body:JSON.stringify({token:t})}))}catch(e){if(e instanceof w)return"";throw e}}export{St as API_URL,de as AmbiguousPageSlugError,w as ApiError,Tt as BROWSER_READ_TIMEOUT_MS,Ot as EFFICIENT_CLIENT_CLOSED_MESSAGE,pe as MediaUploadDestinationError,se as PREVIEW_PARAM,Ke as PRODUCT_API_BASE,bt as SERVER_READ_TIMEOUT_MS,v as SERVER_UNREACHABLE_MESSAGE,k as STATUS_NETWORK_ERROR,xe as adminFetch,vt as api,i as apiFetch,$ as appendSiteQuery,Ge as askForWorkspaces,Me as askToSignUp,Je as bookings,fe as createStorefrontAdmin,ge as dealersPath,M as defaultRequestDeadline,ye as editorMediaUploadPath,Et as editorPortalAudience,Ut as editorRequestLanguage,He as fetchDealers,Fe as fetchSignUpAvailability,ke as fitment,qe as joinSignUpWaitingList,Be as openSignUpLink,We as openWorkspaceFind,Le as products,At as readDeadlineMs,ae as resolveClientIp,S as resolveMediaUrls,oe as resolvePreviewToken,ot as resolveSiteHost,ee as resolveSiteHostSource,re as resolveSiteSlug,_e as setEditorLanguage,Ee as setEditorPortalAudience,De as storefrontAdmin};
|
|
1
|
+
import{PREVIEW_TOKEN_HEADER as dt,SITE_HOST_HEADER as ut,SITE_SLUG_HEADER as lt}from"../site-headers.js";import{PRODUCT_API_BASE as pt,PRODUCT_BACKEND_URL as H}from"./origins.js";import{listRows as m}from"./list-rows.js";import{backendHopHeaders as yt,clientIpFromForwardedFor as ht,FORWARDED_FOR_HEADER as ft,hopCachingOf as gt}from"../forwarded-for.js";import mt from"efficient-web-builder/format/lib/document/media-manifest.json";import{auth as O}from"../auth.js";import{efficientClientOpen as wt}from"efficient-easel/screen/lib/session";import{listableWheelSummaries as U}from"../wheels/listable-wheels.js";import{dropRenderlessFinishes as F}from"../wheels/renderable-finishes.js";const St=process.env.NEXT_PUBLIC_API_URL??"http://localhost:8000";class w extends Error{status;data;constructor(e,n,s){super(n),this.status=e,this.data=s}}const v="Unable to reach the server. This could be a problem with your internet connection, or the server may be undergoing maintenance or an upgrade. Please try again shortly.",Pt=new Set([502,503,504]),k=0,Ot="This editor runs on its host's own backend, which does not serve this request.",bt=5e3,Tt=15e3,At=()=>typeof window>"u"?bt:Tt;function M(t){const e=(t.method??"GET").toUpperCase();if(!(t.body!=null||e!=="GET"&&e!=="HEAD")&&!(t.audience!=null&&t.audience!=="shop")&&typeof AbortSignal?.timeout=="function")return AbortSignal.timeout(At())}const B=t=>t instanceof Error&&t.name==="TimeoutError",q=(t,e)=>Pt.has(t)?v:e,Rt=["admin","venue"];let G="admin";function _e(t){G=Rt.includes(t)?t:"admin"}function Et(){return G}const _t=/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{1,8})*$/;let W=null;function Ue(t){W=t&&_t.test(t)?t:null}function Ut(){return W}function $t(t){if(typeof window>"u"||!t.startsWith("/api/v1/"))return t;const e=Y();return!e||/[?&]site=/.test(t)?t:$(t,`site=${encodeURIComponent(e)}`)}async function i(t,e={}){const{token:n,baseUrl:s,headers:u,audience:l,...y}=e;if(typeof window<"u"&&!wt())throw new w(k,Ot,null);if(typeof window>"u"&&s===void 0)throw new Error(`apiFetch(${JSON.stringify(t)}) ran on the server without an explicit baseUrl. The API_URL default it would inherit is browser-only (the prod image bakes NEXT_PUBLIC_API_URL="" for same-origin use, which a Node fetch cannot resolve). Pass a base explicitly: \`await backendOpts()\` (or baseUrl: PRODUCT_FETCH_BASE) for product reads, or the server-only PRODUCT_BACKEND_URL env for other backend surfaces.`);const a=typeof FormData<"u"&&y.body instanceof FormData;let r;try{r=await fetch(`${s??St}${$t(t)}`,{...y,headers:{...a?{}:{"Content-Type":"application/json"},...n?{Authorization:`Bearer ${n}`}:{},...l===null?{}:{"X-Portal-Audience":l??"shop"},...u},signal:y.signal??M({...y,audience:l})})}catch(h){throw h instanceof TypeError||B(h)?new w(k,v,null):h}let o;try{o=await r.text()}catch(h){throw B(h)?new w(k,v,null):h}let p=null;if(o)try{p=JSON.parse(o)}catch{throw new w(r.status,r.ok?"Expected JSON but received a non-JSON response":q(r.status,r.statusText),o)}if(!r.ok){const h=(p&&typeof p=="object"&&"detail"in p&&typeof p.detail=="string"?p.detail:null)??q(r.status,r.statusText);throw new w(r.status,h,p)}return p}let A=null;async function j(){return A||(A=Ct().finally(()=>{A=null}),A)}async function Ct(){const t=O.takeLegacyRefresh(),e=await vt.refresh(t??void 0);return O.setTokens(e.access),e.access}async function z(){return O.getAccess()??j()}async function g(t,e={}){let n;try{n=await z()}catch{throw O.clear(),new w(401,"Not signed in",null)}try{return await i(t,{...e,token:n})}catch(s){if(!(s instanceof w)||s.status!==401)throw s;try{const u=await j();return await i(t,{...e,token:u})}catch{throw O.clear(),s}}}const Nt=100,K=20;function It(t){if(!t)return null;try{return new URL(t,"http://page.invalid").searchParams.get("page")}catch{return null}}async function V(t,e){const[n,s=""]=t.split("?"),u=[];let l="1";for(let y=0;y<K&&l;y++){const a=new URLSearchParams(s);a.set("page_size",String(Nt)),l!=="1"&&a.set("page",l);const r=await g(`${n}?${a.toString()}`);u.push(...m(r)),l=It(r.next)}return l&&console.warn(`[${e}] stopped at ${K} pages (${u.length} rows); list may be truncated`),u}async function X(t,e={}){if(O.getAccess())try{return{data:await g(t,e),asShopper:!0}}catch(n){if(!(n instanceof w)||n.status!==401)throw n}return{data:await i(t,e),asShopper:!1}}async function Z(){const t=await g("/api/auth/me/");if(t.portal!=="shop")throw O.clear(),new w(403,"This session is not valid for this shop.",null);return t}const vt={login:(t,e)=>i("/api/auth/login/",{method:"POST",body:JSON.stringify({email:t,password:e,portal:"shop"}),credentials:"include"}),refresh:t=>i("/api/auth/refresh/",{method:"POST",body:JSON.stringify(t?{refresh:t,portal:"shop"}:{portal:"shop"}),credentials:"include"}),logout:async()=>{O.clear();try{await i("/api/auth/logout/",{method:"POST",body:JSON.stringify({portal:"shop"}),credentials:"include"})}catch{}},restoreSession:async()=>{const t=await z();return await Z(),t},me:Z,updateMe:t=>g("/api/auth/me/",{method:"PATCH",body:JSON.stringify(t)}),changePassword:(t,e)=>g("/api/auth/me/",{method:"PATCH",body:JSON.stringify({password:e,old_password:t})}),changeEmail:(t,e)=>g("/api/shop-portal/change-email/",{method:"POST",body:JSON.stringify({new_email:t,current_password:e})}),myProfile:()=>g("/api/shop-portal/profile/"),updateMyProfile:t=>g("/api/shop-portal/profile/",{method:"PATCH",body:JSON.stringify(t)}),myAddresses:()=>g("/api/shop-portal/delivery-locations/"),createAddress:t=>g("/api/shop-portal/delivery-locations/",{method:"POST",body:JSON.stringify(t)}),updateAddress:(t,e)=>g(`/api/shop-portal/delivery-locations/${t}/`,{method:"PATCH",body:JSON.stringify(e)}),deleteAddress:t=>g(`/api/shop-portal/delivery-locations/${t}/`,{method:"DELETE"}),passwordResetRequest:t=>i("/api/auth/password-reset/",{method:"POST",body:JSON.stringify({email:t})}),passwordResetConfirm:(t,e,n)=>i("/api/auth/password-reset/confirm/",{method:"POST",body:JSON.stringify({uid:t,token:e,new_password:n})}),brands:()=>g("/api/products/brands/"),myOrders:()=>V("/api/shop-portal/orders/","api.myOrders"),myOrder:t=>g(`/api/shop-portal/orders/${t}/`),cancelOrder:t=>g(`/api/shop-portal/orders/${t}/cancel/`,{method:"POST"}),myReturns:t=>V(`/api/shop-portal/returns/${t?`?order=${encodeURIComponent(t)}`:""}`,"api.myReturns"),createReturn:t=>g("/api/shop-portal/returns/",{method:"POST",body:JSON.stringify(t)}),withdrawReturn:t=>g(`/api/shop-portal/returns/${t}/cancel/`,{method:"POST"}),uploadReturnPhoto:(t,e)=>{const n=new FormData;return n.append("claim_item",t),n.append("file",e),n.append("media_type",e.type.startsWith("video/")?"video":"image"),g("/api/shop-portal/return-media/",{method:"POST",body:n})}};import{media as kt,absolutizeApiUrl as L}from"efficient-web-builder/render/lib/media";import{analyzeLogoSvg as Lt,isSvgUrl as Jt}from"efficient-web-builder/format/lib/logo/reverse-svg";import{getEditorSiteId as xt}from"efficient-web-builder/render/lib/editor-site";import{shopRouteBase as Dt,webRuntimeSiteSlug as Y}from"efficient-web-builder/format/lib/web-runtime";import{readDealerList as Ht}from"../sections/dealer-finder.js";import{SIGN_UP_PATH as Ft,SIGN_UP_VERIFY_PATH as Mt,SIGN_UP_WAITING_PATH as Bt,WORKSPACE_FINDS_PATH as qt,WORKSPACE_FIND_OPEN_PATH as Gt,signInUrlOf as Wt,readLinkAnswer as Q,readSignUpAvailability as jt,readSignUpSent as zt,signUpAvailabilityPath as Kt}from"../sections/sign-up.js";function S(t){if(typeof t=="string")return t.startsWith("/media/")?kt(t):t;if(Array.isArray(t))return t.map(S);if(t&&typeof t=="object"){const e={};for(const[n,s]of Object.entries(t))e[n]=n==="captions"&&s&&typeof s=="object"&&!Array.isArray(s)?Object.fromEntries(Object.entries(s).map(([u,l])=>[S(u),l])):S(s);return e}return t}import{PRODUCT_API_BASE as Ve}from"./origins.js";const tt=typeof window>"u"&&H!=="",Vt=tt?H:pt,Xt=Dt,b=()=>({baseUrl:Xt(),audience:null});function c(t,e){const n=e?`?process=${encodeURIComponent(e)}`:"";return`/api/v1${t}${n}`}const et=100,at=50;function J(t,e,n){const s=new URLSearchParams;for(const[u,l]of Object.entries(e))l!=null&&l!==""&&s.set(u,String(l));return s.set("pageSize",String(et)),n&&s.set("cursor",n),`/api/v1${t}?${s.toString()}`}function Zt(t,e){return J("/wheels",{process:t},e)}const rt=et;function Yt(t,e){return J("/wheels",{slug:t.join(",")},e)}function Qt(t,e,n){return J("/products",{kind:t.join(","),make:e?.make,model:e?.model,year:e?.year,modification:e?.modification},n)}function te(t){if(!t)return null;try{return new URL(t,"http://cursor.invalid").searchParams.get("cursor")}catch{return null}}async function x(t,e,n=()=>!1,s=()=>!1){const u=[];let l=null;try{for(let y=0;y<at;y++){const a=await i(await e(l),await d());if(u.push(...m(a)),l=te(a.next),!l)break;if(s(u))return u}l&&console.warn(`[${t}] stopped at ${at} pages (${u.length} rows); catalog may be truncated`)}catch(y){if(n(y))throw y;console.warn(`[${t}] product API unavailable, returning []`,y)}return u}const nt=t=>t instanceof w&&t.status===400;function st(t){return t.flatMap(e=>e.kind==="alloy-wheel"?U([e]):[e])}async function ot(){return(await ee()).host}async function ee(){try{const{headers:t}=await import("next/headers"),e=await t(),n=l=>l?.split(",")[0]?.split(":")[0]?.trim().toLowerCase()||null,s=n(e.get(ut)??e.get("x-forwarded-host")??e.get("host")),u=n(e.get("host"));return{host:s,matchesRequestHost:s!==null&&s===u}}catch{return{host:null,matchesRequestHost:!1}}}async function ae(){try{const{headers:t}=await import("next/headers");return ht((await t()).get(ft))}catch{return null}}async function re(){try{const{headers:t}=await import("next/headers");return(await t()).get(lt)||null}catch{return null}}async function ne(){const t=await re();if(t)return`site=${encodeURIComponent(t)}`;const e=await ot();return e?`host=${encodeURIComponent(e)}`:""}async function f(t){if(typeof window<"u"){const e=Y();return e?$(t,`site=${encodeURIComponent(e)}`):t}return $(t,await ne())}function $(t,e){return e?`${t}${t.includes("?")?"&":"?"}${e}`:t}const se="preview";async function oe(){if(typeof window<"u")return null;try{const{headers:t}=await import("next/headers");return(await t()).get(dt)}catch{return null}}async function ie(){try{const{headers:t}=await import("next/headers");return(await t()).get("user-agent")}catch{return null}}async function D(t,e){const n=await oe();if(n===null)return[await f(t),await d(e)];const s=$(await f(t),`${se}=${encodeURIComponent(n)}`),{next:u,cache:l,...y}=e??{},a=await d({...y,cache:"no-store"}),r=await ie();return r&&(a.headers={...a.headers,"user-agent":r}),[s,a]}async function ce(t){if(!tt)return;const[e,n]=await Promise.all([ot(),ae()]),s=yt(e,n,t);return Object.keys(s).length>0?s:void 0}async function d(t){const e=await ce(gt(t)),n={baseUrl:Vt,...t};return e&&(n.headers={...e,...t?.headers}),n}const R=typeof window>"u";function E(t,e){const n=new URLSearchParams;for(const[u,l]of Object.entries(e))l!==void 0&&l!==""&&n.set(u,String(l));const s=n.toString();return`/api/v1/fitment${t}${s?`?${s}`:""}`}const Le={listMakes:async t=>{if(R){const{fitmentData:n}=await import("./fitment-data.js");return n.makes(t)}const e=await i(E("/makes",{region:t}),b());return m(e)},listModels:async(t,e)=>{if(R){const{fitmentData:s}=await import("./fitment-data.js");return s.models(t,e)}const n=await i(E("/models",{make:t,region:e}),b());return m(n)},listYears:async(t,e,n)=>{if(R){const{fitmentData:u}=await import("./fitment-data.js");return u.years(t,e,n)}const s=await i(E("/years",{make:t,model:e,region:n}),b());return m(s)},listModifications:async(t,e,n,s)=>{if(R){const{fitmentData:l}=await import("./fitment-data.js");return l.modifications(t,e,n,s)}const u=await i(E("/modifications",{make:t,model:e,year:n,region:s}),b());return m(u)},getStockFitment:async(t,e,n,s,u)=>{if(R){const{fitmentData:l}=await import("./fitment-data.js");return l.stockFitment(t,e,n,s,u)}return i(E("/stock-fitment",{make:t,model:e,year:n,modification:s,region:u}),b())}},Je={listWheels:async(t,e={})=>{const n=await x("products.listWheels",async s=>await f(Zt(t,s)),e.throwOnFailure?()=>!0:void 0,e.maxRows===void 0?void 0:s=>U([...s]).length>=e.maxRows);return U(S(n))},listWheelsBySlug:async(t,e={})=>{const n=[...new Set(t.map(a=>a.trim()).filter(Boolean))];if(n.length===0)return[];const s=[];for(let a=0;a<n.length;a+=rt)s.push(n.slice(a,a+rt));const u=await Promise.all(s.map(a=>x("products.listWheelsBySlug",async r=>await f(Yt(a,r)),e.throwOnFailure?()=>!0:nt))),l=new Set(n),y=u.flat().filter(a=>l.has(a.slug));return U(S(y))},listCatalog:async(t,e,n={})=>{if(t.length===0)throw new Error("products.listCatalog() needs at least one kind. An empty list would omit `kind`, which the contract reads as `alloy-wheel` — so the call would silently return the wheel catalog instead of nothing.");const s=await x("products.listCatalog",async u=>await f(Qt(t,e,u)),n.throwOnFailure?()=>!0:nt,n.maxRows===void 0?void 0:u=>st([...u]).length>=n.maxRows);return st(S(s))},getWheel:async t=>F(S(await i(await f(c(`/wheels/${t}`)),await d()))),getTyre:async t=>S(await i(await f(c(`/tyres/${t}`)),await d())),listBundles:async(t={})=>{try{return await i(await f(c("/bundles")),await d())}catch(e){if(t.throwOnFailure)throw e;return[]}},getBundle:async t=>i(await f(c(`/bundles/${t}`)),await d()),listGalleryBuilds:async(t={})=>{const{process:e=null,wheelSlug:n=null}=t;if(typeof window>"u"){const{listGalleryBuilds:s}=await import("./gallery-builds-data.js");return S(s(e,n))}try{const s=new URLSearchParams;e&&s.set("process",e),n&&s.set("wheelSlug",n);const u=s.toString(),l=await i(`/api/v1/gallery-builds${u?`?${u}`:""}`,b());return S(m(l))}catch(s){return console.warn("[products.listGalleryBuilds] product API unavailable, returning []",s),[]}},getSite:async()=>i(await f(c("/site")),await d()),getSiteBySlug:async t=>i(`${c("/site")}?${new URLSearchParams({site:t})}`,typeof window>"u"?await d():void 0),listPages:async()=>S(await i(await f(c("/pages")),await d())),listPopups:async()=>i(await f(c("/popups")),await d()),listProductTemplates:async()=>{try{return await i(await f(c("/product-templates")),await d())}catch(t){return console.warn("[products.listProductTemplates] unavailable, returning []",t),[]}},listDynamicPages:async t=>{const e=t?`?recordType=${encodeURIComponent(t)}`:"";try{return await i(await f(`${c("/dynamic-pages")}${e}`),await d())}catch(n){if(n instanceof w&&n.status===404)return[];throw n}},getRecord:async(t,e)=>{try{return await i(await f(c(`/records/${encodeURIComponent(t)}/${encodeURIComponent(e)}`)),await d())}catch(n){if(n instanceof w&&n.status===404)return null;throw n}},listRecordKeys:async t=>{try{const e=await i(await f(c(`/records/${encodeURIComponent(t)}`)),await d({cache:"no-store"}));return Array.isArray(e?.keys)?e.keys.filter(n=>typeof n=="string"&&n!==""):[]}catch(e){if(e instanceof w&&e.status===404)return[];throw e}},listProductTypeChoices:async()=>{try{return await i(await f(c("/product-type-choices")),await d())}catch(t){return console.warn("[products.listProductTypeChoices] unavailable, returning []",t),[]}},listFieldUsage:async()=>{try{return await i(await f(c("/field-usage")),await d())}catch(t){return console.warn("[products.listFieldUsage] unavailable, returning []",t),[]}},getPage:async(t,e={})=>{const n=e.record?`?record=${encodeURIComponent(e.record)}`:"",[s,u]=await D(c(`/pages/${t}`)+n,e.revalidate!==void 0?{next:{revalidate:e.revalidate}}:void 0);return S(await i(s,u))},listBlogPosts:async(t={},{throwOnFailure:e=!1}={})=>{const n=t.category?`?category=${encodeURIComponent(t.category)}`:"";try{return(await i(c("/blog-posts")+n,await d())).map(u=>({...u,coverImage:L(u.coverImage)??""}))}catch(s){if(e)throw s;return console.warn("[products.listBlogPosts] blog API unavailable, returning []",s),[]}},getBlogPost:async t=>{const e=await i(c(`/blog-posts/${t}`),await d());return{...e,coverImage:L(e.coverImage)??""}},createOrder:async t=>i(c("/orders"),await d({method:"POST",body:JSON.stringify(t)})),createOrderAuthed:async t=>g(c("/orders"),await d({method:"POST",body:JSON.stringify(t)})),lookupOrder:async t=>i(c("/orders/lookup"),await d({method:"POST",body:JSON.stringify(t)})),createPaymentIntent:async t=>i(c("/payments/intent"),await d({method:"POST",body:JSON.stringify(t)})),releaseCheckout:async t=>i(c("/checkouts/release"),await d({method:"POST",body:JSON.stringify(t)})),createPaypalOrder:async t=>i(c("/payments/paypal/order"),await d({method:"POST",body:JSON.stringify(t)})),capturePaypalOrder:async t=>i(c("/payments/paypal/capture"),await d({method:"POST",body:JSON.stringify(t)})),createAfterpayCheckout:async t=>i(c("/payments/afterpay/checkout"),await d({method:"POST",body:JSON.stringify(t)})),captureAfterpayPayment:async t=>i(c("/payments/afterpay/capture"),await d({method:"POST",body:JSON.stringify(t)})),chargeSquare:async t=>i(c("/payments/square/charge"),await d({method:"POST",body:JSON.stringify(t)})),createGocardlessBillingRequest:async t=>i(c("/payments/gocardless/billing-request"),await d({method:"POST",body:JSON.stringify(t)})),completeGocardlessPayment:async t=>i(c("/payments/gocardless/complete"),await d({method:"POST",body:JSON.stringify(t)})),createZipCheckout:async t=>i(c("/payments/zip/checkout"),await d({method:"POST",body:JSON.stringify(t)})),captureZipPayment:async t=>i(c("/payments/zip/capture"),await d({method:"POST",body:JSON.stringify(t)})),createKlarnaCheckout:async t=>i(c("/payments/klarna/checkout"),await d({method:"POST",body:JSON.stringify(t)})),captureKlarnaPayment:async t=>i(c("/payments/klarna/capture"),await d({method:"POST",body:JSON.stringify(t)})),createStockAlert:async t=>i(c("/stock-alerts"),await d({method:"POST",body:JSON.stringify(t)})),createPreOrderIntent:async t=>i(c("/pre-order-intents"),await d({method:"POST",body:JSON.stringify(t)})),createNewsletterSubscription:async t=>i(c("/newsletter-subscriptions"),await d({method:"POST",body:JSON.stringify(t)})),unsubscribeNewsletter:async t=>i(c("/newsletter-unsubscribe"),await d({method:"POST",body:JSON.stringify(t)})),captureCart:async t=>i(c("/carts"),await d({method:"POST",body:JSON.stringify(t)})),restoreCart:async t=>i(c("/carts/restore"),await d({method:"POST",body:JSON.stringify(t)})),unsubscribeCartReminders:async t=>i(c("/carts/unsubscribe"),await d({method:"POST",body:JSON.stringify(t)})),listReviews:async(t={})=>{const e=new URLSearchParams;t.limit&&e.set("limit",String(t.limit)),t.designCode&&e.set("designCode",t.designCode);const n=c("/reviews"),s=e.toString();try{return await i(await f(s?`${n}?${s}`:n),await d())}catch(u){return console.warn("[products.listReviews] product API unavailable, returning []",u),[]}},submitReview:async t=>i(c("/reviews"),await d({method:"POST",body:JSON.stringify(t)})),getForm:async t=>i(c(`/forms/${encodeURIComponent(t)}`),await d()),submitForm:async(t,e)=>i(c(`/forms/${encodeURIComponent(t)}/submissions`),await d({method:"POST",body:JSON.stringify(e)})),listShippingMethods:async()=>{try{return await i(c("/shipping-methods"),await d())}catch(t){return console.warn("[products.listShippingMethods] product API unavailable, returning []",t),[]}},listCountrySubdivisions:async t=>{try{return await i(c(`/countries/${encodeURIComponent(t)}/subdivisions`),await d())}catch(e){return console.warn("[products.listCountrySubdivisions] unavailable, returning []",e),[]}},quoteCart:async t=>{const e=c("/cart/quote"),n=await d({method:"POST",body:JSON.stringify(t)});return t.couponCode?(await X(e,n)).data:i(e,n)},validateCoupon:async t=>{const{data:e,asShopper:n}=await X(c("/coupons/validate"),await d({method:"POST",body:JSON.stringify(t)}));return{...e,askedAsShopper:n}},getHeaderSettings:async()=>{const t=M({method:"GET"}),e=await i(...await D(c("/header-settings"),{signal:t})),n=L(e.logoUrl);let s=null,u=null;if(n&&Jt(n)){const l=await Lt(n,t);l&&(s=l.reversed,u=l.inkIsDark)}return{...e,logoUrl:n,logoReversed:s,logoInkIsDark:u}},getThemeSettings:async()=>i(...await D(c("/theme-settings"))),getChatSettings:async()=>i(await f(c("/chat-settings")),await d())},xe={listServices:async()=>{try{return await i(c("/bookings/services"),await d())}catch(t){return console.warn("[bookings.listServices] API unavailable, returning []",t),{results:[],currency:"USD"}}},getAvailability:async(t,e)=>i(c(`/bookings/availability?service=${encodeURIComponent(t)}&date=${e}`),await d()),create:async t=>i(c("/bookings"),await d({method:"POST",body:JSON.stringify(t)})),get:async t=>i(c(`/bookings/manage/${encodeURIComponent(t)}`),await d()),cancel:async t=>i(c(`/bookings/manage/${encodeURIComponent(t)}/cancel`),await d({method:"POST"})),createPaymentIntent:async t=>i(c("/bookings/payments/intent"),await d({method:"POST",body:JSON.stringify({manageToken:t})}))};class de extends Error{slug;count;constructor(e,n){super(`Slug "${e}" exists on ${n} websites; a site is required to pick one.`),this.slug=e,this.count=n,this.name="AmbiguousPageSlugError"}}const C=(t,e,n)=>{const s=new URLSearchParams({...e?{site:e}:{},...n?{draft:"1"}:{}}).toString();return`/api/storefront/${t}/${s?`?${s}`:""}`},N=t=>`/api/storefront/sites/${encodeURIComponent(t)}/`,ue=t=>`${N(t)}currencies/`,le="/api/storefront/media/ingest/";class pe extends Error{constructor(){super("This editor is not connected to a website, so an upload has nowhere to go. Open the page from the website the file should belong to, then try again."),this.name="MediaUploadDestinationError"}}function ye(){const t=xt();if(!t)throw new pe;return`${le}?${new URLSearchParams({site:t})}`}const he="X-Puck-Media-Manifest",it=mt.contentHash,I={"X-Media-Manifest":it,[he]:it},De=ct({});function ct(t){return(e,n={})=>{const s=Ut(),u=t.headers||s?{...s?{"Accept-Language":s}:{},...t.headers,...n.headers}:void 0;return i(e,{...n,...t.baseUrl!==void 0?{baseUrl:t.baseUrl}:{},...u?{headers:u}:{},audience:t.audience??Et()})}}function fe(t={}){const e=ct(t),n=t.siteDrafts===!0,s=a=>C("header-settings",a,n),u=a=>C("theme-settings",a,n),l=a=>C("chat-settings",a,n),y=a=>C("social-settings",a,n);return{findPageBySlug:async(a,r,o)=>{const p=new URLSearchParams({slug:a});o&&p.set("site",o);const h=await e(`/api/storefront/pages/?${p.toString()}`,{token:r}),P=m(h);if(!o&&P.length>1)throw new de(a,P.length);return P[0]??null},getPageById:(a,r)=>e(`/api/storefront/pages/${a}/`,{token:r}),saveLayout:(a,r,o,p,h)=>e(`/api/storefront/pages/${a}/`,{method:"PATCH",body:JSON.stringify({layout:r,expected_updated_at:p,...h?{client_id:h}:{}}),token:o}),duplicatePage:(a,r,o)=>e(`/api/storefront/pages/${a}/duplicate/`,{method:"POST",body:JSON.stringify({title:r.title,slug:r.slug}),token:o}),geocode:(a,r,o)=>e(`/api/storefront/geocode/?${new URLSearchParams(o?{q:a,country:o}:{q:a})}`,{token:r}),listBlockSources:a=>e("/api/storefront/block-sources/",{token:a}),listRecordTypes:a=>e("/api/storefront/record-types/",{token:a}),createPagePreviewLink:(a,r)=>e(`/api/storefront/pages/${a}/preview-link/`,{method:"POST",token:r}),claimPageEditLock:(a,r,o,p=!1)=>e(`/api/storefront/pages/${a}/edit-lock/`,{method:"POST",body:JSON.stringify({client_id:o,takeover:p}),token:r}),releasePageEditLock:(a,r)=>e(`/api/storefront/pages/${a}/edit-lock/`,{method:"DELETE",token:r}),createTemplate:(a,r,o)=>e("/api/storefront/page-templates/",{method:"POST",body:JSON.stringify({name:a,layout:r}),headers:I,token:o}),getTemplate:(a,r)=>e(`/api/storefront/page-templates/${a}/`,{token:r}),saveTemplateLayout:(a,r,o)=>e(`/api/storefront/page-templates/${a}/`,{method:"PATCH",body:JSON.stringify({layout:r}),headers:I,token:o}),listTemplatePages:async(a,r)=>{const o=await e(`/api/storefront/template-pages/?template=${encodeURIComponent(a)}`,{token:r});return m(o)},getPageLibrary:async a=>{const r=await e("/api/storefront/page-templates/?is_page_library=true&is_active=true",{token:a});return m(r)[0]??null},getTemplateLibrary:(a,r)=>e(`/api/storefront/pages/template-library/?site=${encodeURIComponent(a)}`,{token:r}),createPageFromTemplate:(a,r)=>e(`/api/storefront/pages/from-template/${n?"?draft=1":""}`,{method:"POST",body:JSON.stringify(a),token:r}),findTemplatePageBySlug:async(a,r,o)=>{const p=await e(`/api/storefront/template-pages/?template=${encodeURIComponent(a)}&slug=${encodeURIComponent(r)}`,{token:o});return m(p)[0]??null},createTemplatePage:(a,r,o)=>e("/api/storefront/template-pages/",{method:"POST",body:JSON.stringify({template:a,...r}),headers:I,token:o}),saveTemplatePageLayout:(a,r,o)=>e(`/api/storefront/template-pages/${a}/`,{method:"PATCH",body:JSON.stringify({layout:r}),headers:I,token:o}),deleteTemplatePage:(a,r,o)=>e(`/api/storefront/template-pages/${a}/`,{method:"DELETE",token:r,...o?.keepalive?{keepalive:!0}:{}}),listPages:async(a,r)=>{const o=new URLSearchParams({no_page:"true"});r&&o.set("site",r);const p=await e(`/api/storefront/pages/?${o.toString()}`,{token:a});return m(p)},createPage:(a,r,o,p)=>e("/api/storefront/pages/",{method:"POST",body:JSON.stringify({title:a,slug:r,layout:o}),token:p}),deletePage:(a,r)=>e(`/api/storefront/pages/${a}/`,{method:"DELETE",token:r}),getHeaderSettings:(a,r)=>e(s(r),{token:a}),listMenus:async(a,r)=>{const o=new URLSearchParams({no_page:"true"});r&&o.set("site",r);const p=await e(`/api/storefront/menus/?${o}`,{token:a});return m(p)},listBlogPosts:async(a,r={})=>{const o=new URLSearchParams({no_page:"true"});r.visibleOnly&&o.set("is_visible","true"),r.siteId&&o.set("site",r.siteId);const p=await e(`/api/storefront/blog-posts/?${o.toString()}`,{token:a});return m(p)},listFieldUsage:async(a,r)=>{const o=await e(`/api/storefront/field-usage/?site=${encodeURIComponent(r)}`,{token:a});return Array.isArray(o?.entries)?o.entries:[]},listCategories:async(a,r={})=>{const o=new URLSearchParams({no_page:"true"});r.visibleOnly&&o.set("is_visible","true"),r.siteId&&o.set("site",r.siteId);const p=await e(`/api/storefront/categories/?${o.toString()}`,{token:a});return[...m(p)].sort((P,_)=>P.sort_order-_.sort_order||P.name.localeCompare(_.name))},listForms:async(a,r={})=>{const o=new URLSearchParams({no_page:"true"});r.siteId&&o.set("site",r.siteId);const p=await e(`/api/storefront/forms/?${o.toString()}`,{token:a});return[...m(p)].sort((P,_)=>P.title.localeCompare(_.title))},listWheelSummaries:async(a,r={})=>{const o=new URLSearchParams;r.siteId&&o.set("site",r.siteId);const p=o.toString(),h=await e(`/api/storefront/wheel-curations/summaries/${p?`?${p}`:""}`,{token:a});return S(h)},listProducts:async(a,r={})=>{const o=new URLSearchParams;r.kinds?.length&&o.set("kind",r.kinds.join(",")),r.siteId&&o.set("site",r.siteId);const p=o.toString(),h=await e(`/api/storefront/products/${p?`?${p}`:""}`,{token:a});return S(h)},getWheelDetail:async(a,r,o={})=>{const p=new URLSearchParams({slug:r});return o.siteId&&p.set("site",o.siteId),F(S(await e(`/api/storefront/wheel-curations/detail/?${p.toString()}`,{token:a})))},updateHeaderSettings:(a,r,o)=>e(s(o),{method:"PATCH",body:JSON.stringify(a),token:r}),getSite:(a,r)=>e(N(a),{token:r}),listSites:async a=>{const r=await e("/api/storefront/sites/?no_page=true",{token:a});return m(r)},listSiteCurrencies:async(a,r)=>{const o=await e(ue(a),{token:r});return Array.isArray(o)?o:[]},publishSite:(a,r)=>e(`${N(a)}publish/`,{method:"POST",token:r}),getSiteLiveState:(a,r)=>e(`${N(a)}live-state/`,{token:r}),getThemeSettings:(a,r)=>e(u(r),{token:a}),updateThemeSettings:(a,r,o)=>e(u(o),{method:"PATCH",body:JSON.stringify(a),token:r}),getMyPreferences:async a=>(await e("/api/auth/me/",{token:a})).preferences??{},updateMyPreferences:(a,r)=>e("/api/auth/me/",{method:"PATCH",body:JSON.stringify({preferences:a}),token:r}),getChatSettings:(a,r)=>e(l(r),{token:a}),updateChatSettings:(a,r,o)=>e(l(o),{method:"PATCH",body:JSON.stringify(a),token:r}),getSocialSettings:(a,r)=>e(y(r),{token:a}),updateSocialSettings:(a,r,o)=>e(y(o),{method:"PATCH",body:JSON.stringify(a),token:r}),uploadHeaderLogo:(a,r,o)=>{const p=new FormData;return p.append("logo",a),e(s(o),{method:"PATCH",body:p,token:r})},clearHeaderLogo:(a,r)=>e(s(r),{method:"PATCH",body:JSON.stringify({logo:null}),token:a}),setHeaderLogoFromAsset:(a,r,o)=>e(s(o),{method:"PATCH",body:JSON.stringify({logo_asset_id:a}),token:r}),uploadMedia:async(a,r)=>{const o=new FormData;return o.append("file",a),e(ye(),{method:"POST",body:o,token:r})},listMedia:async(a,r)=>{const o=new URLSearchParams({no_page:"true"});r&&o.set("kind",r);const p=await e(`/api/storefront/media-assets/?${o.toString()}`,{token:a});return m(p)}}}const He=fe({siteDrafts:!0});function ge(t){const e=t.trim();return e?`/api/v1/dealers?${new URLSearchParams({near:e}).toString()}`:"/api/v1/dealers"}async function Fe(t){return Ht(await i(ge(t)))}const T={audience:null,baseUrl:""};async function Me(t,e){return jt(await i(Kt(t,e),T))}async function Be(t){return zt(await i(Ft,{...T,method:"POST",body:JSON.stringify(t)}))}async function qe(t){try{const e=await i(Mt,{...T,method:"POST",body:JSON.stringify({token:t})});return Q(202,e)}catch(e){if(e instanceof w)return Q(e.status,e.data);throw e}}async function Ge(t,e){await i(Bt,{...T,method:"POST",body:JSON.stringify({email:e.trim(),...t?{product:t}:{}})})}async function We(t,e){await i(qt,{...T,method:"POST",body:JSON.stringify({email:e.trim(),...t?{product:t}:{}})})}async function je(t){try{return Wt(await i(Gt,{...T,method:"POST",body:JSON.stringify({token:t})}))}catch(e){if(e instanceof w&&me.has(e.status))return"";throw e}}const me=new Set([400,404,410]);export{St as API_URL,de as AmbiguousPageSlugError,w as ApiError,Tt as BROWSER_READ_TIMEOUT_MS,Ot as EFFICIENT_CLIENT_CLOSED_MESSAGE,pe as MediaUploadDestinationError,se as PREVIEW_PARAM,Ve as PRODUCT_API_BASE,bt as SERVER_READ_TIMEOUT_MS,v as SERVER_UNREACHABLE_MESSAGE,k as STATUS_NETWORK_ERROR,De as adminFetch,vt as api,i as apiFetch,$ as appendSiteQuery,We as askForWorkspaces,Be as askToSignUp,xe as bookings,fe as createStorefrontAdmin,ge as dealersPath,M as defaultRequestDeadline,ye as editorMediaUploadPath,Et as editorPortalAudience,Ut as editorRequestLanguage,Fe as fetchDealers,Me as fetchSignUpAvailability,Le as fitment,Ge as joinSignUpWaitingList,qe as openSignUpLink,je as openWorkspaceFind,Je as products,At as readDeadlineMs,ae as resolveClientIp,S as resolveMediaUrls,oe as resolvePreviewToken,ot as resolveSiteHost,ee as resolveSiteHostSource,re as resolveSiteSlug,Ue as setEditorLanguage,_e as setEditorPortalAudience,He as storefrontAdmin};
|
|
@@ -181,6 +181,9 @@ export declare const LINK_WORDS: {
|
|
|
181
181
|
readonly limitTitle: "Not today";
|
|
182
182
|
readonly limitNext: "Your link still works until it runs out. Open it again tomorrow.";
|
|
183
183
|
readonly checking: "Checking your link";
|
|
184
|
+
readonly troubleTitle: "We couldn't check your link";
|
|
185
|
+
readonly troubleFailed: "Something went wrong on our side. Your link still works, so nothing is lost.";
|
|
186
|
+
readonly tryAgain: "Try again";
|
|
184
187
|
};
|
|
185
188
|
export declare const WORKSPACE_FINDS_PATH = "/api/business-sign-ups/workspace-finds/";
|
|
186
189
|
export declare const WORKSPACE_FIND_OPEN_PATH = "/api/business-sign-ups/workspace-finds/openings/";
|
|
@@ -197,7 +200,10 @@ export declare const FIND_WORDS: {
|
|
|
197
200
|
readonly another: "Use another email";
|
|
198
201
|
readonly linkGone: "This link is not right, or it has run out. Ask for your workspaces again.";
|
|
199
202
|
readonly opening: "Opening your workspace";
|
|
203
|
+
readonly openFailed: "We couldn't open your workspace just now. Your link still works — try again.";
|
|
204
|
+
readonly retry: "Try again";
|
|
200
205
|
};
|
|
206
|
+
export declare function readFindOpenTrouble(status: number): SignUpTrouble;
|
|
201
207
|
export declare function readFindRefusal(status: number, data: unknown): {
|
|
202
208
|
email: string | null;
|
|
203
209
|
trouble: SignUpTrouble | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{COUNTRY_CODES as y,CURRENCY_CODES as b}from"./sign-up-catalogue.js";import{formatDateTime as h}from"efficient-shell/format";import{firstReadableZone as k,runtimeLocale as w}from"../zone.js";const L={firstName:"",lastName:"",email:"",company:"",slug:"",country:"",currency:""},_=["slug_malformed","slug_reserved","slug_taken"],d=e=>typeof e=="string"&&_.includes(e),W=400,t={title:"Create your {name} workspace",freeLine:"Free to start. No card needed.",firstName:"First name",lastName:"Last name",email:"Work email",company:"Company name",address:"Workspace address",country:"Country",currency:"Currency",countryHint:"Your shop sells in this currency. The country sets its tax and shipping defaults. Both can be changed later.",checking:"Checking",available:"Available",submit:"Create workspace",sending:"Sending…",agree:"By creating a workspace you agree to the {terms} and {privacy}.",terms:"Terms",privacy:"Privacy Policy",haveOne:"Already have a workspace?",find:"Find my workspace",required:"Fill this in.",companyShort:"Use at least 2 characters.",emailWrong:"Enter an email address, like name@company.com.",notOffered:"That choice is not offered. Pick another.",wrong:"Check this and try again.",slugProblem:{slug_malformed:"Use 3 to 30 lower-case letters, digits or single hyphens, starting with a letter.",slug_reserved:"That address is kept for the platform. Choose another.",slug_taken:"That address is taken. Choose another."},trouble:{closed:"Signing up is closed just now.",dailyLimit:"Too many workspaces signed up today. Try again tomorrow.",unavailable:"Signing up is not available just now. Try again later.",tooMany:"You have asked a few times in a row. Wait a minute, then try again.",unreachable:"We couldn't reach the server. Check your connection and try again.",failed:"Something went wrong and nothing was sent. Try again."},closedTitle:"Signing up is closed just now",closedBody:"New {name} workspaces cannot be made just now.",closedLeave:"Leave your email and we'll tell you when it opens.",tellMe:"Tell me when it opens",waitingDone:"Thanks. We'll email {email} when sign-up opens.",sentTitle:"Check your email",sentBody:"We sent a link to {email}. Open it to set up {company}.",sentUntil:"The link works once, until {when}. Asking again sends a new link, and the old one stops working.",sendAgain:"Send it again",sendingAgain:"Sending…",sentAgain:"A new link is on its way. The old one no longer works.",change:"Change the details"};function p(e,n){return e.replace(/\{(\w+)\}/g,(r,o)=>n[o]??r)}function m(e){return e.trim().toLowerCase().replace(/_/g,"-")}function O(e){return e.normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean).join("-").replace(/^[^a-z]+/,"").slice(0,30).replace(/-+$/,"")}function U(e,n){const r=(e??"").trim().toLowerCase().replace(/^\.+/,"").replace(/\.+$/,"");if(r)return`.${r}`;const o=n.toLowerCase().replace(/\.$/,"").replace(/^www\./,"");return o?`.${o}`:""}const s=e=>typeof e=="string"?e:"";function E(e,n){const r=new URLSearchParams;n&&r.set("slug",n),e&&r.set("product",e);const o=r.toString();return`/api/business-sign-ups/availability/${o?`?${o}`:""}`}const R="/api/business-sign-ups/",D="/api/business-sign-ups/waiting-list/";function F(e,n){const r=n&&typeof n=="object"&&!Array.isArray(n)?n:{};return r.code==="sign_up_open"?{open:!0,email:null,trouble:null}:r.code==="sign_up_waiting_list_unavailable"?{open:!1,email:null,trouble:"unavailable"}:e===400&&"email"in r?{open:!1,email:t.emailWrong,trouble:null}:e===0?{open:!1,email:null,trouble:"unreachable"}:e===429?{open:!1,email:null,trouble:"tooMany"}:{open:!1,email:null,trouble:"failed"}}function j(e){const n=e.trim();return n?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)?null:t.emailWrong:t.required}function $(e){const n=e&&typeof e=="object"?e:{};return{open:n.open===!0,country:s(n.country),currency:s(n.currency),slugAvailable:typeof n.slug_available=="boolean"?n.slug_available:null,slugProblem:d(n.slug_problem)?n.slug_problem:null}}function B(e){return e.slugAvailable?{state:"available"}:e.slugProblem?{state:"problem",problem:e.slugProblem}:{state:"unknown"}}function K(e){const n=e&&typeof e=="object"?e:{};return{slug:s(n.slug),expiresAt:s(n.expires_at)}}function M(e,n,r){return{business_name:e.company.trim(),slug:m(e.slug),first_name:e.firstName.trim(),last_name:e.lastName.trim(),email:e.email.trim(),...n?{product:n}:{},...r&&e.country?{country:e.country}:{},...r&&e.currency?{currency:e.currency}:{}}}function Y(e,n){const r={};e.firstName.trim()||(r.firstName=t.required);const o=e.email.trim();o?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o)||(r.email=t.emailWrong):r.email=t.required;const i=e.company.trim();return i?i.length<2&&(r.company=t.companyShort):r.company=t.required,m(e.slug)?n.state==="problem"&&(r.slug=t.slugProblem[n.problem]):r.slug=t.required,r}const T={business_name:"company",slug:"slug",first_name:"firstName",last_name:"lastName",email:"email",country:"country",currency:"currency"},u={self_sign_up_off:"closed",sign_up_daily_limit:"dailyLimit",sign_up_unavailable:"unavailable",sign_up_plan_missing:"unavailable"};function H(e,n){const r=n&&typeof n=="object"&&!Array.isArray(n)?n:{},o=r.code;if(d(o))return{fields:{slug:t.slugProblem[o]},trouble:null};if(typeof o=="string"&&u[o])return{fields:{},trouble:u[o]};if(e===0)return{fields:{},trouble:"unreachable"};if(e===429)return{fields:{},trouble:"tooMany"};if(e===400){const i={};for(const l of Object.keys(r)){const a=T[l];a&&(i[a]=a==="slug"?t.slugProblem.slug_malformed:a==="email"?t.emailWrong:a==="country"||a==="currency"?t.notOffered:t.wrong)}if(Object.keys(i).length)return{fields:i,trouble:null}}return{fields:{},trouble:"failed"}}function g(e,n){try{const r=new Intl.DisplayNames(n?[n]:void 0,{type:e,fallback:"code"});return o=>r.of(o)??o}catch{return r=>r}}const f=(e,n)=>n&&!e.includes(n)?[...e,n]:[...e],x=(e,n)=>{const r=new Intl.Collator(n);return e.sort((o,i)=>r.compare(o.label,i.label))};function q(e,n){const r=g("region",n);return x(f(y,e).map(o=>({value:o,label:r(o)})),n)}function G(e,n){const r=g("currency",n);return f(b,e).sort().map(o=>{const i=r(o);return{value:o,label:i===o?o:`${o} · ${i}`}})}function z(e,n,r){const o=k(r??"");return!e||Number.isNaN(new Date(e).getTime())||!o?"":h(e,{locale:n||w(),timeZone:o,style:A})}const A={weekday:"long",day:"numeric",month:"long"},S=/^\/sign-up\/verify\/([^/?#]+)\/?$/;function Z(e){const n=S.exec(e??"");if(!n)return"";try{return decodeURIComponent(n[1])}catch{return n[1]}}const V="/api/business-sign-ups/verifications/",N=["pending","provisioning","ready","failed"];function J(e,n){const r=n&&typeof n=="object"&&!Array.isArray(n)?n:{},o=s(r.code),i=s(r.slug);if(e===202||o==="sign_up_already_verified"){const l=s(r.provisioning_status),a=s(r.business_name);return N.includes(l)?l==="ready"?{kind:"ready",company:a,slug:i}:l==="failed"?{kind:"failed",company:a,slug:i}:{kind:"building",company:a,slug:i,status:l}:{kind:"gone"}}return d(o)?{kind:"taken",slug:i}:o==="sign_up_daily_limit"?{kind:"dailyLimit"}:o==="self_sign_up_off"?{kind:"closed"}:o&&u[o]?{kind:"trouble",trouble:u[o]}:e===400&&"token"in r?{kind:"gone"}:e===0?{kind:"trouble",trouble:"unreachable"}:e===429?{kind:"trouble",trouble:"tooMany"}:{kind:"trouble",trouble:"failed"}}function Q(e){return e.kind==="building"||e.kind==="trouble"&&e.trouble!=="failed"}function X(e){return e<5?2e3:e<20?5e3:15e3}const ee=40;function ne(e,n,r){const o=e.kind==="failed"?"stopped":"running";return[{words:c.confirmed,at:"done"},{words:p(c.reserved,{address:`${e.slug}${r}`}),at:"done"},{words:c.building,at:o},...e.kind==="failed"?[]:[{words:p(c.adding,{name:n}),at:"waiting"}]]}const re=e=>e==="pending"?50:75,c={settingUp:"Setting up {company}",confirmed:"Email confirmed",reserved:"Address reserved: {address}",building:"Building your workspace",adding:"Adding {name}",aboutTen:"This takes about 10 seconds. You can close this page: we'll email you when it's ready.",readyTitle:"Your workspace is ready",workspace:"Workspace",address:"Address",plan:"Plan",planName:"{name} Free",readyNext:"We've emailed you a link to set your password. It's the next step.",failedBody:"We couldn't finish building your workspace. We've been told, and we'll email you when it's ready. You don't need to sign up again.",goneTitle:"This link has run out",goneBody:"This link is not right, or it has run out. Sign up again and we'll send a new one.",again:"Sign up again",takenTitle:"That address has gone",takenBody:"{address} was taken before you opened your link. Choose another address and we'll send a new link.",takenBodyBare:"That address was taken before you opened your link. Choose another address and we'll send a new link.",chooseAnother:"Choose another address",limitTitle:"Not today",limitNext:"Your link still works until it runs out. Open it again tomorrow.",checking:"Checking your link"},oe="/api/business-sign-ups/workspace-finds/",ie="/api/business-sign-ups/workspace-finds/openings/",v=/^\/find\/([^/?#]+)\/?$/;function te(e){const n=v.exec(e??"");if(!n)return"";try{return decodeURIComponent(n[1])}catch{return n[1]}}const ae={title:"Find your workspace",intro:"Enter your work email. We'll send you the address of every workspace you belong to.",submit:"Email me my workspaces",newHere:"New to {name}?",create:"Create a workspace",sentTitle:"Check your email",sentBody:"If {email} belongs to a workspace, the links are on their way.",sentNote:"They work for 30 minutes. Nothing arrives if the address isn't in any workspace.",another:"Use another email",linkGone:"This link is not right, or it has run out. Ask for your workspaces again.",opening:"Opening your workspace"};function se(e,n){const r=n&&typeof n=="object"&&!Array.isArray(n)?n:{};return r.code==="workspace_find_unavailable"?{email:null,trouble:"unavailable"}:e===400&&"email"in r?{email:t.emailWrong,trouble:null}:e===0?{email:null,trouble:"unreachable"}:e===429?{email:null,trouble:"tooMany"}:{email:null,trouble:"failed"}}function le(e){const n=e&&typeof e=="object"?s(e.sign_in_url):"";return/^https?:\/\/[^\s]+$/i.test(n)?n:""}export{W as CHECK_AFTER_MS,L as EMPTY_DRAFT,ae as FIND_WORDS,ee as LINK_ASKS_AT_MOST,c as LINK_WORDS,R as SIGN_UP_PATH,V as SIGN_UP_VERIFY_PATH,D as SIGN_UP_WAITING_PATH,t as SIGN_UP_WORDS,_ as SLUG_PROBLEMS,oe as WORKSPACE_FINDS_PATH,ie as WORKSPACE_FIND_OPEN_PATH,U as addressSuffix,re as buildProgress,ne as buildSteps,Y as checkDraft,j as checkWaitingEmail,q as countryChoices,G as currencyChoices,p as fill,te as findTokenOf,d as isSlugProblem,X as linkAskAfterMs,Q as linkAsksAgain,z as linkEnds,Z as linkTokenOf,m as normaliseSlug,se as readFindRefusal,J as readLinkAnswer,$ as readSignUpAvailability,H as readSignUpRefusal,K as readSignUpSent,F as readWaitingRefusal,le as signInUrlOf,E as signUpAvailabilityPath,M as signUpBody,B as slugCheckOf,O as slugFromName};
|
|
1
|
+
import{COUNTRY_CODES as y,CURRENCY_CODES as b}from"./sign-up-catalogue.js";import{formatDateTime as k}from"efficient-shell/format";import{firstReadableZone as h,runtimeLocale as w}from"../zone.js";const I={firstName:"",lastName:"",email:"",company:"",slug:"",country:"",currency:""},_=["slug_malformed","slug_reserved","slug_taken"],d=e=>typeof e=="string"&&_.includes(e),L=400,t={title:"Create your {name} workspace",freeLine:"Free to start. No card needed.",firstName:"First name",lastName:"Last name",email:"Work email",company:"Company name",address:"Workspace address",country:"Country",currency:"Currency",countryHint:"Your shop sells in this currency. The country sets its tax and shipping defaults. Both can be changed later.",checking:"Checking",available:"Available",submit:"Create workspace",sending:"Sending…",agree:"By creating a workspace you agree to the {terms} and {privacy}.",terms:"Terms",privacy:"Privacy Policy",haveOne:"Already have a workspace?",find:"Find my workspace",required:"Fill this in.",companyShort:"Use at least 2 characters.",emailWrong:"Enter an email address, like name@company.com.",notOffered:"That choice is not offered. Pick another.",wrong:"Check this and try again.",slugProblem:{slug_malformed:"Use 3 to 30 lower-case letters, digits or single hyphens, starting with a letter.",slug_reserved:"That address is kept for the platform. Choose another.",slug_taken:"That address is taken. Choose another."},trouble:{closed:"Signing up is closed just now.",dailyLimit:"Too many workspaces signed up today. Try again tomorrow.",unavailable:"Signing up is not available just now. Try again later.",tooMany:"You have asked a few times in a row. Wait a minute, then try again.",unreachable:"We couldn't reach the server. Check your connection and try again.",failed:"Something went wrong and nothing was sent. Try again."},closedTitle:"Signing up is closed just now",closedBody:"New {name} workspaces cannot be made just now.",closedLeave:"Leave your email and we'll tell you when it opens.",tellMe:"Tell me when it opens",waitingDone:"Thanks. We'll email {email} when sign-up opens.",sentTitle:"Check your email",sentBody:"We sent a link to {email}. Open it to set up {company}.",sentUntil:"The link works once, until {when}. Asking again sends a new link, and the old one stops working.",sendAgain:"Send it again",sendingAgain:"Sending…",sentAgain:"A new link is on its way. The old one no longer works.",change:"Change the details"};function p(e,n){return e.replace(/\{(\w+)\}/g,(r,o)=>n[o]??r)}function m(e){return e.trim().toLowerCase().replace(/_/g,"-")}function O(e){return e.normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean).join("-").replace(/^[^a-z]+/,"").slice(0,30).replace(/-+$/,"")}function U(e,n){const r=(e??"").trim().toLowerCase().replace(/^\.+/,"").replace(/\.+$/,"");if(r)return`.${r}`;const o=n.toLowerCase().replace(/\.$/,"").replace(/^www\./,"");return o?`.${o}`:""}const s=e=>typeof e=="string"?e:"";function F(e,n){const r=new URLSearchParams;n&&r.set("slug",n),e&&r.set("product",e);const o=r.toString();return`/api/business-sign-ups/availability/${o?`?${o}`:""}`}const E="/api/business-sign-ups/",R="/api/business-sign-ups/waiting-list/";function D(e,n){const r=n&&typeof n=="object"&&!Array.isArray(n)?n:{};return r.code==="sign_up_open"?{open:!0,email:null,trouble:null}:r.code==="sign_up_waiting_list_unavailable"?{open:!1,email:null,trouble:"unavailable"}:e===400&&"email"in r?{open:!1,email:t.emailWrong,trouble:null}:e===0?{open:!1,email:null,trouble:"unreachable"}:e===429?{open:!1,email:null,trouble:"tooMany"}:{open:!1,email:null,trouble:"failed"}}function j(e){const n=e.trim();return n?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)?null:t.emailWrong:t.required}function $(e){const n=e&&typeof e=="object"?e:{};return{open:n.open===!0,country:s(n.country),currency:s(n.currency),slugAvailable:typeof n.slug_available=="boolean"?n.slug_available:null,slugProblem:d(n.slug_problem)?n.slug_problem:null}}function B(e){return e.slugAvailable?{state:"available"}:e.slugProblem?{state:"problem",problem:e.slugProblem}:{state:"unknown"}}function Y(e){const n=e&&typeof e=="object"?e:{};return{slug:s(n.slug),expiresAt:s(n.expires_at)}}function M(e,n,r){return{business_name:e.company.trim(),slug:m(e.slug),first_name:e.firstName.trim(),last_name:e.lastName.trim(),email:e.email.trim(),...n?{product:n}:{},...r&&e.country?{country:e.country}:{},...r&&e.currency?{currency:e.currency}:{}}}function K(e,n){const r={};e.firstName.trim()||(r.firstName=t.required);const o=e.email.trim();o?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o)||(r.email=t.emailWrong):r.email=t.required;const i=e.company.trim();return i?i.length<2&&(r.company=t.companyShort):r.company=t.required,m(e.slug)?n.state==="problem"&&(r.slug=t.slugProblem[n.problem]):r.slug=t.required,r}const T={business_name:"company",slug:"slug",first_name:"firstName",last_name:"lastName",email:"email",country:"country",currency:"currency"},u={self_sign_up_off:"closed",sign_up_daily_limit:"dailyLimit",sign_up_unavailable:"unavailable",sign_up_plan_missing:"unavailable"};function H(e,n){const r=n&&typeof n=="object"&&!Array.isArray(n)?n:{},o=r.code;if(d(o))return{fields:{slug:t.slugProblem[o]},trouble:null};if(typeof o=="string"&&u[o])return{fields:{},trouble:u[o]};if(e===0)return{fields:{},trouble:"unreachable"};if(e===429)return{fields:{},trouble:"tooMany"};if(e===400){const i={};for(const l of Object.keys(r)){const a=T[l];a&&(i[a]=a==="slug"?t.slugProblem.slug_malformed:a==="email"?t.emailWrong:a==="country"||a==="currency"?t.notOffered:t.wrong)}if(Object.keys(i).length)return{fields:i,trouble:null}}return{fields:{},trouble:"failed"}}function g(e,n){try{const r=new Intl.DisplayNames(n?[n]:void 0,{type:e,fallback:"code"});return o=>r.of(o)??o}catch{return r=>r}}const f=(e,n)=>n&&!e.includes(n)?[...e,n]:[...e],x=(e,n)=>{const r=new Intl.Collator(n);return e.sort((o,i)=>r.compare(o.label,i.label))};function q(e,n){const r=g("region",n);return x(f(y,e).map(o=>({value:o,label:r(o)})),n)}function G(e,n){const r=g("currency",n);return f(b,e).sort().map(o=>{const i=r(o);return{value:o,label:i===o?o:`${o} · ${i}`}})}function z(e,n,r){const o=h(r??"");return!e||Number.isNaN(new Date(e).getTime())||!o?"":k(e,{locale:n||w(),timeZone:o,style:A})}const A={weekday:"long",day:"numeric",month:"long"},S=/^\/sign-up\/verify\/([^/?#]+)\/?$/;function Z(e){const n=S.exec(e??"");if(!n)return"";try{return decodeURIComponent(n[1])}catch{return n[1]}}const V="/api/business-sign-ups/verifications/",N=["pending","provisioning","ready","failed"];function J(e,n){const r=n&&typeof n=="object"&&!Array.isArray(n)?n:{},o=s(r.code),i=s(r.slug);if(e===202||o==="sign_up_already_verified"){const l=s(r.provisioning_status),a=s(r.business_name);return N.includes(l)?l==="ready"?{kind:"ready",company:a,slug:i}:l==="failed"?{kind:"failed",company:a,slug:i}:{kind:"building",company:a,slug:i,status:l}:{kind:"gone"}}return d(o)?{kind:"taken",slug:i}:o==="sign_up_daily_limit"?{kind:"dailyLimit"}:o==="self_sign_up_off"?{kind:"closed"}:o&&u[o]?{kind:"trouble",trouble:u[o]}:e===400&&"token"in r?{kind:"gone"}:e===0?{kind:"trouble",trouble:"unreachable"}:e===429?{kind:"trouble",trouble:"tooMany"}:{kind:"trouble",trouble:"failed"}}function Q(e){return e.kind==="building"||e.kind==="trouble"&&e.trouble!=="failed"}function X(e){return e<5?2e3:e<20?5e3:15e3}const ee=40;function ne(e,n,r){const o=e.kind==="failed"?"stopped":"running";return[{words:c.confirmed,at:"done"},{words:p(c.reserved,{address:`${e.slug}${r}`}),at:"done"},{words:c.building,at:o},...e.kind==="failed"?[]:[{words:p(c.adding,{name:n}),at:"waiting"}]]}const re=e=>e==="pending"?50:75,c={settingUp:"Setting up {company}",confirmed:"Email confirmed",reserved:"Address reserved: {address}",building:"Building your workspace",adding:"Adding {name}",aboutTen:"This takes about 10 seconds. You can close this page: we'll email you when it's ready.",readyTitle:"Your workspace is ready",workspace:"Workspace",address:"Address",plan:"Plan",planName:"{name} Free",readyNext:"We've emailed you a link to set your password. It's the next step.",failedBody:"We couldn't finish building your workspace. We've been told, and we'll email you when it's ready. You don't need to sign up again.",goneTitle:"This link has run out",goneBody:"This link is not right, or it has run out. Sign up again and we'll send a new one.",again:"Sign up again",takenTitle:"That address has gone",takenBody:"{address} was taken before you opened your link. Choose another address and we'll send a new link.",takenBodyBare:"That address was taken before you opened your link. Choose another address and we'll send a new link.",chooseAnother:"Choose another address",limitTitle:"Not today",limitNext:"Your link still works until it runs out. Open it again tomorrow.",checking:"Checking your link",troubleTitle:"We couldn't check your link",troubleFailed:"Something went wrong on our side. Your link still works, so nothing is lost.",tryAgain:"Try again"},oe="/api/business-sign-ups/workspace-finds/",ie="/api/business-sign-ups/workspace-finds/openings/",v=/^\/find\/([^/?#]+)\/?$/;function te(e){const n=v.exec(e??"");if(!n)return"";try{return decodeURIComponent(n[1])}catch{return n[1]}}const ae={title:"Find your workspace",intro:"Enter your work email. We'll send you the address of every workspace you belong to.",submit:"Email me my workspaces",newHere:"New to {name}?",create:"Create a workspace",sentTitle:"Check your email",sentBody:"If {email} belongs to a workspace, the links are on their way.",sentNote:"They work for 30 minutes. Nothing arrives if the address isn't in any workspace.",another:"Use another email",linkGone:"This link is not right, or it has run out. Ask for your workspaces again.",opening:"Opening your workspace",openFailed:"We couldn't open your workspace just now. Your link still works — try again.",retry:"Try again"};function se(e){return e===0?"unreachable":e===429?"tooMany":"failed"}function le(e,n){const r=n&&typeof n=="object"&&!Array.isArray(n)?n:{};return r.code==="workspace_find_unavailable"?{email:null,trouble:"unavailable"}:e===400&&"email"in r?{email:t.emailWrong,trouble:null}:e===0?{email:null,trouble:"unreachable"}:e===429?{email:null,trouble:"tooMany"}:{email:null,trouble:"failed"}}function ue(e){const n=e&&typeof e=="object"?s(e.sign_in_url):"";return/^https?:\/\/[^\s]+$/i.test(n)?n:""}export{L as CHECK_AFTER_MS,I as EMPTY_DRAFT,ae as FIND_WORDS,ee as LINK_ASKS_AT_MOST,c as LINK_WORDS,E as SIGN_UP_PATH,V as SIGN_UP_VERIFY_PATH,R as SIGN_UP_WAITING_PATH,t as SIGN_UP_WORDS,_ as SLUG_PROBLEMS,oe as WORKSPACE_FINDS_PATH,ie as WORKSPACE_FIND_OPEN_PATH,U as addressSuffix,re as buildProgress,ne as buildSteps,K as checkDraft,j as checkWaitingEmail,q as countryChoices,G as currencyChoices,p as fill,te as findTokenOf,d as isSlugProblem,X as linkAskAfterMs,Q as linkAsksAgain,z as linkEnds,Z as linkTokenOf,m as normaliseSlug,se as readFindOpenTrouble,le as readFindRefusal,J as readLinkAnswer,$ as readSignUpAvailability,H as readSignUpRefusal,Y as readSignUpSent,D as readWaitingRefusal,ue as signInUrlOf,F as signUpAvailabilityPath,M as signUpBody,B as slugCheckOf,O as slugFromName};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "efficient-storefront-blocks",
|
|
3
|
-
"version": "0.119.
|
|
3
|
+
"version": "0.119.2",
|
|
4
4
|
"description": "The EFFICIENT storefront's website editor — the website builder assembled with the storefront's own sections — for an app that edits a storefront website inside its own page. Built from the efficient-storefront-blocks repository.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "Efficient Pty Ltd",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as W,c as se,f as oe,h as D,m as ae,o as L}from"./chunk-5VQNKBJK.js";var q="".replace(/\/+$/,"");var K="x-forwarded-for";function le(e){let t=(e??"").split(",").map(n=>n.trim()).filter(Boolean);return t.length>0?t[t.length-1]:null}var mt="x-forwarded-host";function ce(e,t,n){let r={};return e&&(r[mt]=e),t&&n==="uncached"&&(r[K]=t),r}function ue(e){if(e?.cache==="no-store"||e?.cache==="no-cache")return"uncached";if(e?.cache==="force-cache")return"data-cached";let t=e?.next?.revalidate;return typeof t=="number"&&t>0?"data-cached":"uncached"}var de="x-storefront-site",pe="x-storefront-host",me="x-storefront-preview";function h(e){return Array.isArray(e)?e:e?.results??[]}var gt="shop_access_token",ge="shop_refresh_token",J=null;function Z(){L.removeItem(gt),L.removeItem(ge)}var A={getAccess(){return J},takeLegacyRefresh(){let e=L.getItem(ge);return Z(),e},setTokens(e){J=e,Z()},clear(){J=null,Z()}};import{efficientClientOpen as Wt}from"efficient-easel/screen/lib/session";function yt(e){return!!e.src}function C(e){let t=e.finishes.filter(yt);if(t.length===e.finishes.length)return e;let n=e.defaultFinish&&t.some(r=>r.name===e.defaultFinish)?e.defaultFinish:null;return{...e,finishes:t,defaultFinish:n}}function ht(e){return e.listable!==!1}function x(e){return e.map(C).filter(ht)}var Se=["fill","stroke","stop-color","color","flood-color","lighting-color","solid-color"],Pe=new Set(["none","transparent","currentcolor","inherit","initial","unset","context-fill","context-stroke"]),I={black:[0,0,0],white:[255,255,255],gray:[128,128,128],grey:[128,128,128],darkgray:[169,169,169],darkgrey:[169,169,169],dimgray:[105,105,105],dimgrey:[105,105,105],lightgray:[211,211,211],lightgrey:[211,211,211],gainsboro:[220,220,220],silver:[192,192,192],whitesmoke:[245,245,245]},be=12,we=/\burl\(/i,Ae=new RegExp(`(?<![-\\w])(${Se.join("|")})(\\s*=\\s*)(["'])([^"']*)\\3`,"gi"),Re=new RegExp(`((?:^|[;{\\s"'])(?:${Se.join("|")})\\s*:\\s*)([^;}"'<>]+)`,"gi"),ft=/<svg\b([^>]*)>/i,St=/\bfill\s*[=:]/i;function Pt(e){let t=e.replace(Ae,(n,r,o,l,p)=>{let i=ye(p);return i===null?n:`${r}${o}${l}${i}${l}`}).replace(Re,(n,r,o)=>{let l=ye(o);return l===null?n:`${r}${l}`});return t=t.replace(ft,(n,r)=>St.test(r)?n:`<svg fill="#ffffff"${r}>`),t}function ye(e){let t=/!important/i.test(e),n=e.replace(/!important/gi,"").trim().toLowerCase();if(!n||we.test(n)||Pe.has(n))return null;let r=n in I?[...I[n],1]:ke(n);if(!r)return null;let[o,l,p,i]=r;if(Math.max(o,l,p)-Math.min(o,l,p)>be)return null;let s=bt(255-o,255-l,255-p,i);return t?`${s} !important`:s}function bt(e,t,n,r){if(r<1)return`rgba(${e}, ${t}, ${n}, ${r})`;let o=l=>l.toString(16).padStart(2,"0");return`#${o(e)}${o(t)}${o(n)}`}function ke(e){return e.startsWith("#")?wt(e):e.startsWith("rgb")?At(e):e.startsWith("hsl")?kt(e):null}function wt(e){let t=e.slice(1),n=1;if(t.length===3||t.length===4)t.length===4&&(n=parseInt(t[3]+t[3],16)/255),t=t.slice(0,3).split("").map(r=>r+r).join("");else if(t.length===6||t.length===8)t.length===8&&(n=parseInt(t.slice(6,8),16)/255),t=t.slice(0,6);else return null;return/^[0-9a-f]{6}$/.test(t)?[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16),n]:null}function At(e){let t=e.slice(e.indexOf("(")+1,e.lastIndexOf(")")),[n,r]=t.split("/"),o=n.split(/[\s,]+/).filter(Boolean).slice(0,3);if(o.length<3)return null;let l=o.map(i=>i.endsWith("%")?Math.round(parseFloat(i)/100*255):Math.round(parseFloat(i)));if(l.some(i=>Number.isNaN(i)))return null;let p=r?M(r):Rt(n);return[l[0],l[1],l[2],p]}function Rt(e){let t=e.split(/[\s,]+/).filter(Boolean);return t.length>=4?M(t[3]):1}function M(e){let t=e.trim().endsWith("%")?parseFloat(e)/100:parseFloat(e);return Number.isNaN(t)?1:t}function kt(e){let t=e.slice(e.indexOf("(")+1,e.lastIndexOf(")")),[n,r]=t.split("/"),o=n.split(/[\s,]+/).filter(Boolean);if(o.length<3)return null;let l=parseFloat(o[0]),p=parseFloat(o[1])/100,i=parseFloat(o[2])/100;if([l,p,i].some(w=>Number.isNaN(w)))return null;let s=r?M(r):o.length>=4?M(o[3]):1,[a,m,g]=Tt(l,p,i);return[a,m,g,s]}function Tt(e,t,n){let r=(1-Math.abs(2*n-1))*t,o=(e%360+360)%360/60,l=r*(1-Math.abs(o%2-1)),p=0,i=0,s=0;o<1?[p,i,s]=[r,l,0]:o<2?[p,i,s]=[l,r,0]:o<3?[p,i,s]=[0,r,l]:o<4?[p,i,s]=[0,l,r]:o<5?[p,i,s]=[l,0,r]:[p,i,s]=[r,0,l];let a=n-r/2;return[Math.round((p+a)*255),Math.round((i+a)*255),Math.round((s+a)*255)]}var he=512*1024;function Y(e){return/\.svg(\?|$)/i.test(e)}function _t(e){return`data:image/svg+xml,${encodeURIComponent(Pt(e))}`}function Ct(e){let t=e.replace(/!important/gi,"").trim().toLowerCase();if(!t||we.test(t)||Pe.has(t))return null;let n=t in I?[...I[t],1]:ke(t);if(!n)return null;let[r,o,l]=n;return Math.max(r,o,l)-Math.min(r,o,l)>be?null:(.2126*r+.7152*o+.0722*l)/255}function xt(e){let t=[],n=r=>{let o=Ct(r);o!==null&&t.push(o)};for(let r of e.matchAll(Ae))n(r[4]);for(let r of e.matchAll(Re))n(r[2]);return t.length?t.reduce((r,o)=>r+o,0)/t.length<.5:null}var fe=/^(?:\uFEFF|\s+|<\?xml[^>]*\?>|<!--[\s\S]*?-->|<!DOCTYPE\s+svg[^>[]*>)/i;function Ot(e){let t=e;for(let n=fe.exec(t);n&&n[0].length>0;n=fe.exec(t))t=t.slice(n[0].length);return/^<svg[\s>/]/i.test(t)}async function Et(e,t){if(!Y(e))return null;try{let n=await fetch(e,{signal:t,redirect:"manual"});if(!n.ok)return null;let r=Number(n.headers.get("content-length"));if(Number.isFinite(r)&&r>he)return null;let o=await n.text();return o.length>he?null:Ot(o)?o:null}catch{return null}}async function Te(e,t){let n=await Et(e,t);return n===null?null:{reversed:_t(n),inkIsDark:xt(n)}}import{currentEaselSession as Nt,setSessionBridgedSite as vn,setSessionDocumentSite as Fn}from"efficient-easel/screen/lib/session";function _e(){return Nt().siteId()}var Ce={title:"Find a dealer",placeholder:"Postcode or suburb",search:"Search",searching:"Searching\u2026",none:"No dealers to show yet.",notFound:"We couldn't find that place. Check the postcode or suburb and search again.",tryAgain:"We couldn't look up that place just now. Please try again.",website:"Website",map:"Dealers on the map"},k=e=>typeof e=="string"?e:"",V=e=>typeof e=="number"&&Number.isFinite(e)?e:null,Ut=["found","not_found","try_again"];function Dt(e){if(!e||typeof e!="object")return null;let t=e;return typeof t.name!="string"||!t.name?null:{id:k(t.id)||t.name,name:t.name,address:k(t.address),city:k(t.city),state:k(t.state),postcode:k(t.postcode),country:k(t.country),phone:k(t.phone),website:k(t.website),lat:V(t.lat),lng:V(t.lng),distanceKm:V(t.distanceKm)}}function xe(e){if(!e||typeof e!="object")return{near:null,dealers:[]};let t=e,n=typeof t.near=="string"&&Ut.includes(t.near)?t.near:null,r=Array.isArray(t.dealers)?t.dealers:[];return{near:n,dealers:r.map(Dt).filter(o=>o!==null)}}function Gn(e){return e==="not_found"?Ce.notFound:e==="try_again"?Ce.tryAgain:null}function Hn(e){return e===null?null:e<10?`${e.toFixed(1)} km`:`${Math.round(e)} km`}function $n(e){return[e.city,e.state,e.postcode].filter(Boolean).join(" ")}function Wn(e){let t=e.map((a,m)=>({dealer:a,index:m})).filter(({dealer:a})=>a.lat!==null&&a.lng!==null);if(!t.length)return[];let n=t.map(({dealer:a})=>a.lat),r=t.map(({dealer:a})=>a.lng),[o,l]=[Math.min(...n),Math.max(...n)],[p,i]=[Math.min(...r),Math.max(...r)],s=(a,m,g)=>g===m?50:8+(a-m)/(g-m)*84;return t.map(({dealer:a,index:m})=>({id:a.id,index:m,left:s(a.lng,p,i),top:100-s(a.lat,o,l)}))}var Oe=["AD","AE","AF","AG","AI","AL","AM","AO","AQ","AR","AS","AT","AU","AW","AX","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BL","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","CR","CU","CV","CW","CX","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ","FK","FM","FO","FR","GA","GB","GD","GE","GF","GG","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HK","HM","HN","HR","HT","HU","ID","IE","IL","IM","IN","IO","IQ","IR","IS","IT","JE","JM","JO","JP","KE","KG","KH","KI","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","ME","MF","MG","MH","MK","ML","MM","MN","MO","MP","MQ","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PW","PY","QA","RE","RO","RS","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","SS","ST","SV","SX","SY","SZ","TC","TD","TF","TG","TH","TJ","TK","TL","TM","TN","TO","TR","TT","TV","TW","TZ","UA","UG","UM","US","UY","UZ","VA","VC","VE","VG","VI","VN","VU","WF","WS","YE","YT","ZA","ZM","ZW"],Ee=["AED","AFN","ALL","AMD","AOA","ARS","AUD","AWG","AZN","BAM","BBD","BDT","BHD","BIF","BMD","BND","BOB","BOV","BRL","BSD","BTN","BWP","BYN","BZD","CAD","CDF","CHE","CHF","CHW","CLF","CLP","CNY","COP","COU","CRC","CUP","CVE","CZK","DJF","DKK","DOP","DZD","EGP","ERN","ETB","EUR","FJD","FKP","GBP","GEL","GHS","GIP","GMD","GNF","GTQ","GYD","HKD","HNL","HTG","HUF","IDR","ILS","INR","IQD","IRR","ISK","JMD","JOD","JPY","KES","KGS","KHR","KMF","KPW","KRW","KWD","KYD","KZT","LAK","LBP","LKR","LRD","LSL","LYD","MAD","MDL","MGA","MKD","MMK","MNT","MOP","MRU","MUR","MVR","MWK","MXN","MXV","MYR","MZN","NAD","NGN","NIO","NOK","NPR","NZD","OMR","PAB","PEN","PGK","PHP","PKR","PLN","PYG","QAR","RON","RSD","RUB","RWF","SAR","SBD","SCR","SDG","SEK","SGD","SHP","SLE","SOS","SRD","SSP","STN","SVC","SYP","SZL","THB","TJS","TMT","TND","TOP","TRY","TTD","TWD","TZS","UAH","UGX","USD","USN","UYI","UYU","UYW","UZS","VED","VES","VND","VUV","WST","XAF","XCD","XCG","XOF","XPF","YER","ZAR","ZMW","ZWG"],Kn={AD:"EUR",AE:"AED",AF:"AFN",AL:"ALL",AM:"AMD",AO:"AOA",AR:"ARS",AT:"EUR",AU:"AUD",AW:"AWG",AZ:"AZN",BA:"BAM",BB:"BBD",BD:"BDT",BE:"EUR",BH:"BHD",BI:"BIF",BM:"BMD",BN:"BND",BO:"BOB",BR:"BRL",BS:"BSD",BT:"BTN",BW:"BWP",BY:"BYN",BZ:"BZD",CA:"CAD",CD:"CDF",CH:"CHE",CL:"CLF",CN:"CNY",CO:"COP",CR:"CRC",CU:"CUP",CV:"CVE",CY:"EUR",CZ:"CZK",DE:"EUR",DJ:"DJF",DK:"DKK",DO:"DOP",DZ:"DZD",EE:"EUR",EG:"EGP",ER:"ERN",ES:"EUR",ET:"ETB",FI:"EUR",FJ:"FJD",FK:"FKP",FR:"EUR",GB:"GBP",GE:"GEL",GH:"GHS",GI:"GIP",GM:"GMD",GN:"GNF",GR:"EUR",GT:"GTQ",GY:"GYD",HK:"HKD",HN:"HNL",HR:"EUR",HT:"HTG",HU:"HUF",ID:"IDR",IE:"EUR",IL:"ILS",IN:"INR",IQ:"IQD",IR:"IRR",IS:"ISK",IT:"EUR",JM:"JMD",JO:"JOD",JP:"JPY",KE:"KES",KG:"KGS",KH:"KHR",KM:"KMF",KP:"KPW",KR:"KRW",KW:"KWD",KY:"KYD",KZ:"KZT",LA:"LAK",LB:"LBP",LK:"LKR",LR:"LRD",LS:"LSL",LT:"EUR",LU:"EUR",LV:"EUR",LY:"LYD",MA:"MAD",MC:"EUR",MD:"MDL",ME:"EUR",MG:"MGA",MK:"MKD",MM:"MMK",MN:"MNT",MO:"MOP",MR:"MRU",MT:"EUR",MU:"MUR",MV:"MVR",MW:"MWK",MX:"MXN",MY:"MYR",MZ:"MZN",NA:"NAD",NG:"NGN",NI:"NIO",NL:"EUR",NO:"NOK",NP:"NPR",NZ:"NZD",OM:"OMR",PA:"PAB",PE:"PEN",PG:"PGK",PH:"PHP",PK:"PKR",PL:"PLN",PT:"EUR",PY:"PYG",QA:"QAR",RO:"RON",RS:"RSD",RU:"RUB",RW:"RWF",SA:"SAR",SB:"SBD",SC:"SCR",SD:"SDG",SE:"SEK",SG:"SGD",SH:"SHP",SI:"EUR",SK:"EUR",SL:"SLE",SM:"EUR",SO:"SOS",SR:"SRD",SS:"SSP",ST:"STN",SV:"SVC",SY:"SYP",SZ:"SZL",TH:"THB",TJ:"TJS",TM:"TMT",TN:"TND",TO:"TOP",TR:"TRY",TT:"TTD",TW:"TWD",TZ:"TZS",UA:"UAH",UG:"UGX",US:"USD",UY:"UYI",UZ:"UZS",VA:"EUR",VE:"VED",VN:"VND",VU:"VUV",WS:"WST",YE:"YER",ZA:"ZAR",ZM:"ZMW",ZW:"ZWG"};import{formatDateTime as It}from"efficient-shell/format";import{knownZone as Lt}from"efficient-shell/format";var Ne=()=>new Intl.DateTimeFormat().resolvedOptions().locale;function Ue(...e){return e.find(Lt)??""}var Xn={firstName:"",lastName:"",email:"",company:"",slug:"",country:"",currency:""},Mt=["slug_malformed","slug_reserved","slug_taken"],j=e=>typeof e=="string"&&Mt.includes(e),zn=400,P={title:"Create your {name} workspace",freeLine:"Free to start. No card needed.",firstName:"First name",lastName:"Last name",email:"Work email",company:"Company name",address:"Workspace address",country:"Country",currency:"Currency",countryHint:"Your shop sells in this currency. The country sets its tax and shipping defaults. Both can be changed later.",checking:"Checking",available:"Available",submit:"Create workspace",sending:"Sending\u2026",agree:"By creating a workspace you agree to the {terms} and {privacy}.",terms:"Terms",privacy:"Privacy Policy",haveOne:"Already have a workspace?",find:"Find my workspace",required:"Fill this in.",companyShort:"Use at least 2 characters.",emailWrong:"Enter an email address, like name@company.com.",notOffered:"That choice is not offered. Pick another.",wrong:"Check this and try again.",slugProblem:{slug_malformed:"Use 3 to 30 lower-case letters, digits or single hyphens, starting with a letter.",slug_reserved:"That address is kept for the platform. Choose another.",slug_taken:"That address is taken. Choose another."},trouble:{closed:"Signing up is closed just now.",dailyLimit:"Too many workspaces signed up today. Try again tomorrow.",unavailable:"Signing up is not available just now. Try again later.",tooMany:"You have asked a few times in a row. Wait a minute, then try again.",unreachable:"We couldn't reach the server. Check your connection and try again.",failed:"Something went wrong and nothing was sent. Try again."},closedTitle:"Signing up is closed just now",closedBody:"New {name} workspaces cannot be made just now.",closedLeave:"Leave your email and we'll tell you when it opens.",tellMe:"Tell me when it opens",waitingDone:"Thanks. We'll email {email} when sign-up opens.",sentTitle:"Check your email",sentBody:"We sent a link to {email}. Open it to set up {company}.",sentUntil:"The link works once, until {when}. Asking again sends a new link, and the old one stops working.",sendAgain:"Send it again",sendingAgain:"Sending\u2026",sentAgain:"A new link is on its way. The old one no longer works.",change:"Change the details"};function De(e,t){return e.replace(/\{(\w+)\}/g,(n,r)=>t[r]??n)}function Le(e){return e.trim().toLowerCase().replace(/_/g,"-")}function er(e){return e.normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean).join("-").replace(/^[^a-z]+/,"").slice(0,30).replace(/-+$/,"")}function tr(e,t){let n=(e??"").trim().toLowerCase().replace(/^\.+/,"").replace(/\.+$/,"");if(n)return`.${n}`;let r=t.toLowerCase().replace(/\.$/,"").replace(/^www\./,"");return r?`.${r}`:""}var R=e=>typeof e=="string"?e:"";function Ie(e,t){let n=new URLSearchParams;t&&n.set("slug",t),e&&n.set("product",e);let r=n.toString();return`/api/business-sign-ups/availability/${r?`?${r}`:""}`}var Me="/api/business-sign-ups/",ve="/api/business-sign-ups/waiting-list/";function nr(e,t){let n=t&&typeof t=="object"&&!Array.isArray(t)?t:{};return n.code==="sign_up_open"?{open:!0,email:null,trouble:null}:n.code==="sign_up_waiting_list_unavailable"?{open:!1,email:null,trouble:"unavailable"}:e===400&&"email"in n?{open:!1,email:P.emailWrong,trouble:null}:e===0?{open:!1,email:null,trouble:"unreachable"}:e===429?{open:!1,email:null,trouble:"tooMany"}:{open:!1,email:null,trouble:"failed"}}function rr(e){let t=e.trim();return t?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)?null:P.emailWrong:P.required}function Fe(e){let t=e&&typeof e=="object"?e:{};return{open:t.open===!0,country:R(t.country),currency:R(t.currency),slugAvailable:typeof t.slug_available=="boolean"?t.slug_available:null,slugProblem:j(t.slug_problem)?t.slug_problem:null}}function ir(e){return e.slugAvailable?{state:"available"}:e.slugProblem?{state:"problem",problem:e.slugProblem}:{state:"unknown"}}function Be(e){let t=e&&typeof e=="object"?e:{};return{slug:R(t.slug),expiresAt:R(t.expires_at)}}function sr(e,t,n){return{business_name:e.company.trim(),slug:Le(e.slug),first_name:e.firstName.trim(),last_name:e.lastName.trim(),email:e.email.trim(),...t?{product:t}:{},...n&&e.country?{country:e.country}:{},...n&&e.currency?{currency:e.currency}:{}}}function or(e,t){let n={};e.firstName.trim()||(n.firstName=P.required);let r=e.email.trim();r?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r)||(n.email=P.emailWrong):n.email=P.required;let o=e.company.trim();return o?o.length<2&&(n.company=P.companyShort):n.company=P.required,Le(e.slug)?t.state==="problem"&&(n.slug=P.slugProblem[t.problem]):n.slug=P.required,n}var vt={business_name:"company",slug:"slug",first_name:"firstName",last_name:"lastName",email:"email",country:"country",currency:"currency"},F={self_sign_up_off:"closed",sign_up_daily_limit:"dailyLimit",sign_up_unavailable:"unavailable",sign_up_plan_missing:"unavailable"};function ar(e,t){let n=t&&typeof t=="object"&&!Array.isArray(t)?t:{},r=n.code;if(j(r))return{fields:{slug:P.slugProblem[r]},trouble:null};if(typeof r=="string"&&F[r])return{fields:{},trouble:F[r]};if(e===0)return{fields:{},trouble:"unreachable"};if(e===429)return{fields:{},trouble:"tooMany"};if(e===400){let o={};for(let l of Object.keys(n)){let p=vt[l];p&&(o[p]=p==="slug"?P.slugProblem.slug_malformed:p==="email"?P.emailWrong:p==="country"||p==="currency"?P.notOffered:P.wrong)}if(Object.keys(o).length)return{fields:o,trouble:null}}return{fields:{},trouble:"failed"}}function Ge(e,t){try{let n=new Intl.DisplayNames(t?[t]:void 0,{type:e,fallback:"code"});return r=>n.of(r)??r}catch{return n=>n}}var He=(e,t)=>t&&!e.includes(t)?[...e,t]:[...e],Ft=(e,t)=>{let n=new Intl.Collator(t);return e.sort((r,o)=>n.compare(r.label,o.label))};function lr(e,t){let n=Ge("region",t);return Ft(He(Oe,e).map(r=>({value:r,label:n(r)})),t)}function cr(e,t){let n=Ge("currency",t);return He(Ee,e).sort().map(r=>{let o=n(r);return{value:r,label:o===r?r:`${r} \xB7 ${o}`}})}function ur(e,t,n){let r=Ue(n??"");return!e||Number.isNaN(new Date(e).getTime())||!r?"":It(e,{locale:t||Ne(),timeZone:r,style:Bt})}var Bt={weekday:"long",day:"numeric",month:"long"},Gt=/^\/sign-up\/verify\/([^/?#]+)\/?$/;function dr(e){let t=Gt.exec(e??"");if(!t)return"";try{return decodeURIComponent(t[1])}catch{return t[1]}}var $e="/api/business-sign-ups/verifications/",Ht=["pending","provisioning","ready","failed"];function Q(e,t){let n=t&&typeof t=="object"&&!Array.isArray(t)?t:{},r=R(n.code),o=R(n.slug);if(e===202||r==="sign_up_already_verified"){let l=R(n.provisioning_status),p=R(n.business_name);return Ht.includes(l)?l==="ready"?{kind:"ready",company:p,slug:o}:l==="failed"?{kind:"failed",company:p,slug:o}:{kind:"building",company:p,slug:o,status:l}:{kind:"gone"}}return j(r)?{kind:"taken",slug:o}:r==="sign_up_daily_limit"?{kind:"dailyLimit"}:r==="self_sign_up_off"?{kind:"closed"}:r&&F[r]?{kind:"trouble",trouble:F[r]}:e===400&&"token"in n?{kind:"gone"}:e===0?{kind:"trouble",trouble:"unreachable"}:e===429?{kind:"trouble",trouble:"tooMany"}:{kind:"trouble",trouble:"failed"}}function pr(e){return e.kind==="building"||e.kind==="trouble"&&e.trouble!=="failed"}function mr(e){return e<5?2e3:e<20?5e3:15e3}var gr=40;function yr(e,t,n){let r=e.kind==="failed"?"stopped":"running";return[{words:v.confirmed,at:"done"},{words:De(v.reserved,{address:`${e.slug}${n}`}),at:"done"},{words:v.building,at:r},...e.kind==="failed"?[]:[{words:De(v.adding,{name:t}),at:"waiting"}]]}var hr=e=>e==="pending"?50:75,v={settingUp:"Setting up {company}",confirmed:"Email confirmed",reserved:"Address reserved: {address}",building:"Building your workspace",adding:"Adding {name}",aboutTen:"This takes about 10 seconds. You can close this page: we'll email you when it's ready.",readyTitle:"Your workspace is ready",workspace:"Workspace",address:"Address",plan:"Plan",planName:"{name} Free",readyNext:"We've emailed you a link to set your password. It's the next step.",failedBody:"We couldn't finish building your workspace. We've been told, and we'll email you when it's ready. You don't need to sign up again.",goneTitle:"This link has run out",goneBody:"This link is not right, or it has run out. Sign up again and we'll send a new one.",again:"Sign up again",takenTitle:"That address has gone",takenBody:"{address} was taken before you opened your link. Choose another address and we'll send a new link.",takenBodyBare:"That address was taken before you opened your link. Choose another address and we'll send a new link.",chooseAnother:"Choose another address",limitTitle:"Not today",limitNext:"Your link still works until it runs out. Open it again tomorrow.",checking:"Checking your link"},We="/api/business-sign-ups/workspace-finds/",qe="/api/business-sign-ups/workspace-finds/openings/",$t=/^\/find\/([^/?#]+)\/?$/;function fr(e){let t=$t.exec(e??"");if(!t)return"";try{return decodeURIComponent(t[1])}catch{return t[1]}}var Sr={title:"Find your workspace",intro:"Enter your work email. We'll send you the address of every workspace you belong to.",submit:"Email me my workspaces",newHere:"New to {name}?",create:"Create a workspace",sentTitle:"Check your email",sentBody:"If {email} belongs to a workspace, the links are on their way.",sentNote:"They work for 30 minutes. Nothing arrives if the address isn't in any workspace.",another:"Use another email",linkGone:"This link is not right, or it has run out. Ask for your workspaces again.",opening:"Opening your workspace"};function Pr(e,t){let n=t&&typeof t=="object"&&!Array.isArray(t)?t:{};return n.code==="workspace_find_unavailable"?{email:null,trouble:"unavailable"}:e===400&&"email"in n?{email:P.emailWrong,trouble:null}:e===0?{email:null,trouble:"unreachable"}:e===429?{email:null,trouble:"tooMany"}:{email:null,trouble:"failed"}}function Ke(e){let t=e&&typeof e=="object"?R(e.sign_in_url):"";return/^https?:\/\/[^\s]+$/i.test(t)?t:""}var qt="",S=class extends Error{constructor(t,n,r){super(n),this.status=t,this.data=r}},te="Unable to reach the server. This could be a problem with your internet connection, or the server may be undergoing maintenance or an upgrade. Please try again shortly.",Kt=new Set([502,503,504]),X=0,Jt="This editor runs on its host's own backend, which does not serve this request.",Zt=5e3,Yt=15e3,Vt=()=>typeof window>"u"?Zt:Yt;function it(e){let t=(e.method??"GET").toUpperCase();if(!(e.body!=null||t!=="GET"&&t!=="HEAD")&&!(e.audience!=null&&e.audience!=="shop")&&typeof AbortSignal?.timeout=="function")return AbortSignal.timeout(Vt())}var Je=e=>e instanceof Error&&e.name==="TimeoutError",Ze=(e,t)=>Kt.has(e)?te:t,jt=["admin","venue"],st="admin";function Er(e){st=jt.includes(e)?e:"admin"}function Qt(){return st}var Xt=/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{1,8})*$/,ot=null;function Nr(e){ot=e&&Xt.test(e)?e:null}function zt(){return ot}function en(e){if(typeof window>"u"||!e.startsWith("/api/v1/"))return e;let t=W();return!t||/[?&]site=/.test(e)?e:$(e,`site=${encodeURIComponent(t)}`)}async function c(e,t={}){let{token:n,baseUrl:r,headers:o,audience:l,...p}=t;if(typeof window<"u"&&!Wt())throw new S(X,Jt,null);if(typeof window>"u"&&r===void 0)throw new Error(`apiFetch(${JSON.stringify(e)}) ran on the server without an explicit baseUrl. The API_URL default it would inherit is browser-only (the prod image bakes NEXT_PUBLIC_API_URL="" for same-origin use, which a Node fetch cannot resolve). Pass a base explicitly: \`await backendOpts()\` (or baseUrl: PRODUCT_FETCH_BASE) for product reads, or the server-only PRODUCT_BACKEND_URL env for other backend surfaces.`);let i=typeof FormData<"u"&&p.body instanceof FormData,s;try{s=await fetch(`${r??qt}${en(e)}`,{...p,headers:{...i?{}:{"Content-Type":"application/json"},...n?{Authorization:`Bearer ${n}`}:{},...l===null?{}:{"X-Portal-Audience":l??"shop"},...o},signal:p.signal??it({...p,audience:l})})}catch(g){throw g instanceof TypeError||Je(g)?new S(X,te,null):g}let a;try{a=await s.text()}catch(g){throw Je(g)?new S(X,te,null):g}let m=null;if(a)try{m=JSON.parse(a)}catch{throw new S(s.status,s.ok?"Expected JSON but received a non-JSON response":Ze(s.status,s.statusText),a)}if(!s.ok){let g=(m&&typeof m=="object"&&"detail"in m&&typeof m.detail=="string"?m.detail:null)??Ze(s.status,s.statusText);throw new S(s.status,g,m)}return m}var O=null;async function at(){return O||(O=tn().finally(()=>{O=null}),O)}async function tn(){let e=A.takeLegacyRefresh(),t=await sn.refresh(e??void 0);return A.setTokens(t.access),t.access}async function lt(){return A.getAccess()??at()}async function f(e,t={}){let n;try{n=await lt()}catch{throw A.clear(),new S(401,"Not signed in",null)}try{return await c(e,{...t,token:n})}catch(r){if(!(r instanceof S)||r.status!==401)throw r;try{let o=await at();return await c(e,{...t,token:o})}catch{throw A.clear(),r}}}var nn=100,Ye=20;function rn(e){if(!e)return null;try{return new URL(e,"http://page.invalid").searchParams.get("page")}catch{return null}}async function Ve(e,t){let[n,r=""]=e.split("?"),o=[],l="1";for(let p=0;p<Ye&&l;p++){let i=new URLSearchParams(r);i.set("page_size",String(nn)),l!=="1"&&i.set("page",l);let s=await f(`${n}?${i.toString()}`);o.push(...h(s)),l=rn(s.next)}return l&&console.warn(`[${t}] stopped at ${Ye} pages (${o.length} rows); list may be truncated`),o}async function je(e,t={}){if(A.getAccess())try{return{data:await f(e,t),asShopper:!0}}catch(n){if(!(n instanceof S)||n.status!==401)throw n}return{data:await c(e,t),asShopper:!1}}async function Qe(){let e=await f("/api/auth/me/");if(e.portal!=="shop")throw A.clear(),new S(403,"This session is not valid for this shop.",null);return e}var sn={login:(e,t)=>c("/api/auth/login/",{method:"POST",body:JSON.stringify({email:e,password:t,portal:"shop"}),credentials:"include"}),refresh:e=>c("/api/auth/refresh/",{method:"POST",body:JSON.stringify(e?{refresh:e,portal:"shop"}:{portal:"shop"}),credentials:"include"}),logout:async()=>{A.clear();try{await c("/api/auth/logout/",{method:"POST",body:JSON.stringify({portal:"shop"}),credentials:"include"})}catch{}},restoreSession:async()=>{let e=await lt();return await Qe(),e},me:Qe,updateMe:e=>f("/api/auth/me/",{method:"PATCH",body:JSON.stringify(e)}),changePassword:(e,t)=>f("/api/auth/me/",{method:"PATCH",body:JSON.stringify({password:t,old_password:e})}),changeEmail:(e,t)=>f("/api/shop-portal/change-email/",{method:"POST",body:JSON.stringify({new_email:e,current_password:t})}),myProfile:()=>f("/api/shop-portal/profile/"),updateMyProfile:e=>f("/api/shop-portal/profile/",{method:"PATCH",body:JSON.stringify(e)}),myAddresses:()=>f("/api/shop-portal/delivery-locations/"),createAddress:e=>f("/api/shop-portal/delivery-locations/",{method:"POST",body:JSON.stringify(e)}),updateAddress:(e,t)=>f(`/api/shop-portal/delivery-locations/${e}/`,{method:"PATCH",body:JSON.stringify(t)}),deleteAddress:e=>f(`/api/shop-portal/delivery-locations/${e}/`,{method:"DELETE"}),passwordResetRequest:e=>c("/api/auth/password-reset/",{method:"POST",body:JSON.stringify({email:e})}),passwordResetConfirm:(e,t,n)=>c("/api/auth/password-reset/confirm/",{method:"POST",body:JSON.stringify({uid:e,token:t,new_password:n})}),brands:()=>f("/api/products/brands/"),myOrders:()=>Ve("/api/shop-portal/orders/","api.myOrders"),myOrder:e=>f(`/api/shop-portal/orders/${e}/`),cancelOrder:e=>f(`/api/shop-portal/orders/${e}/cancel/`,{method:"POST"}),myReturns:e=>Ve(`/api/shop-portal/returns/${e?`?order=${encodeURIComponent(e)}`:""}`,"api.myReturns"),createReturn:e=>f("/api/shop-portal/returns/",{method:"POST",body:JSON.stringify(e)}),withdrawReturn:e=>f(`/api/shop-portal/returns/${e}/cancel/`,{method:"POST"}),uploadReturnPhoto:(e,t)=>{let n=new FormData;return n.append("claim_item",e),n.append("file",t),n.append("media_type",t.type.startsWith("video/")?"video":"image"),f("/api/shop-portal/return-media/",{method:"POST",body:n})}};function b(e){if(typeof e=="string")return e.startsWith("/media/")?oe(e):e;if(Array.isArray(e))return e.map(b);if(e&&typeof e=="object"){let t={};for(let[n,r]of Object.entries(e))t[n]=n==="captions"&&r&&typeof r=="object"&&!Array.isArray(r)?Object.fromEntries(Object.entries(r).map(([o,l])=>[b(o),l])):b(r);return t}return e}var ct=typeof window>"u"&&q!=="",on=ct?q:"",an=se,T=()=>({baseUrl:an(),audience:null});function u(e,t){let n=t?`?process=${encodeURIComponent(t)}`:"";return`/api/v1${e}${n}`}var ut=100,Xe=50;function ie(e,t,n){let r=new URLSearchParams;for(let[o,l]of Object.entries(t))l!=null&&l!==""&&r.set(o,String(l));return r.set("pageSize",String(ut)),n&&r.set("cursor",n),`/api/v1${e}?${r.toString()}`}function ln(e,t){return ie("/wheels",{process:e},t)}var ze=ut;function cn(e,t){return ie("/wheels",{slug:e.join(",")},t)}function un(e,t,n){return ie("/products",{kind:e.join(","),make:t?.make,model:t?.model,year:t?.year,modification:t?.modification},n)}function dn(e){if(!e)return null;try{return new URL(e,"http://cursor.invalid").searchParams.get("cursor")}catch{return null}}async function z(e,t,n=()=>!1,r=()=>!1){let o=[],l=null;try{for(let p=0;p<Xe;p++){let i=await c(await t(l),await d());if(o.push(...h(i)),l=dn(i.next),!l)break;if(r(o))return o}l&&console.warn(`[${e}] stopped at ${Xe} pages (${o.length} rows); catalog may be truncated`)}catch(p){if(n(p))throw p;console.warn(`[${e}] product API unavailable, returning []`,p)}return o}var et=e=>e instanceof S&&e.status===400;function tt(e){return e.flatMap(t=>t.kind==="alloy-wheel"?x([t]):[t])}async function dt(){return(await pn()).host}async function pn(){try{let{headers:e}=await import("./headers-UYHEZDAT.js"),t=await e(),n=l=>l?.split(",")[0]?.split(":")[0]?.trim().toLowerCase()||null,r=n(t.get(pe)??t.get("x-forwarded-host")??t.get("host")),o=n(t.get("host"));return{host:r,matchesRequestHost:r!==null&&r===o}}catch{return{host:null,matchesRequestHost:!1}}}async function mn(){try{let{headers:e}=await import("./headers-UYHEZDAT.js");return le((await e()).get(K))}catch{return null}}async function gn(){try{let{headers:e}=await import("./headers-UYHEZDAT.js");return(await e()).get(de)||null}catch{return null}}async function yn(){let e=await gn();if(e)return`site=${encodeURIComponent(e)}`;let t=await dt();return t?`host=${encodeURIComponent(t)}`:""}async function y(e){if(typeof window<"u"){let t=W();return t?$(e,`site=${encodeURIComponent(t)}`):e}return $(e,await yn())}function $(e,t){return t?`${e}${e.includes("?")?"&":"?"}${t}`:e}var hn="preview";async function fn(){if(typeof window<"u")return null;try{let{headers:e}=await import("./headers-UYHEZDAT.js");return(await e()).get(me)}catch{return null}}async function Sn(){try{let{headers:e}=await import("./headers-UYHEZDAT.js");return(await e()).get("user-agent")}catch{return null}}async function ee(e,t){let n=await fn();if(n===null)return[await y(e),await d(t)];let r=$(await y(e),`${hn}=${encodeURIComponent(n)}`),{next:o,cache:l,...p}=t??{},i=await d({...p,cache:"no-store"}),s=await Sn();return s&&(i.headers={...i.headers,"user-agent":s}),[r,i]}async function Pn(e){if(!ct)return;let[t,n]=await Promise.all([dt(),mn()]),r=ce(t,n,e);return Object.keys(r).length>0?r:void 0}async function d(e){let t=await Pn(ue(e)),n={baseUrl:on,...e};return t&&(n.headers={...t,...e?.headers}),n}var E=typeof window>"u";function N(e,t){let n=new URLSearchParams;for(let[o,l]of Object.entries(t))l!==void 0&&l!==""&&n.set(o,String(l));let r=n.toString();return`/api/v1/fitment${e}${r?`?${r}`:""}`}var Fr={listMakes:async e=>{if(E){let{fitmentData:n}=await import("./fitment-data-HYODY7DX.js");return n.makes(e)}let t=await c(N("/makes",{region:e}),T());return h(t)},listModels:async(e,t)=>{if(E){let{fitmentData:r}=await import("./fitment-data-HYODY7DX.js");return r.models(e,t)}let n=await c(N("/models",{make:e,region:t}),T());return h(n)},listYears:async(e,t,n)=>{if(E){let{fitmentData:o}=await import("./fitment-data-HYODY7DX.js");return o.years(e,t,n)}let r=await c(N("/years",{make:e,model:t,region:n}),T());return h(r)},listModifications:async(e,t,n,r)=>{if(E){let{fitmentData:l}=await import("./fitment-data-HYODY7DX.js");return l.modifications(e,t,n,r)}let o=await c(N("/modifications",{make:e,model:t,year:n,region:r}),T());return h(o)},getStockFitment:async(e,t,n,r,o)=>{if(E){let{fitmentData:l}=await import("./fitment-data-HYODY7DX.js");return l.stockFitment(e,t,n,r,o)}return c(N("/stock-fitment",{make:e,model:t,year:n,modification:r,region:o}),T())}},Br={listWheels:async(e,t={})=>{let n=await z("products.listWheels",async r=>await y(ln(e,r)),t.throwOnFailure?()=>!0:void 0,t.maxRows===void 0?void 0:r=>x([...r]).length>=t.maxRows);return x(b(n))},listWheelsBySlug:async(e,t={})=>{let n=[...new Set(e.map(i=>i.trim()).filter(Boolean))];if(n.length===0)return[];let r=[];for(let i=0;i<n.length;i+=ze)r.push(n.slice(i,i+ze));let o=await Promise.all(r.map(i=>z("products.listWheelsBySlug",async s=>await y(cn(i,s)),t.throwOnFailure?()=>!0:et))),l=new Set(n),p=o.flat().filter(i=>l.has(i.slug));return x(b(p))},listCatalog:async(e,t,n={})=>{if(e.length===0)throw new Error("products.listCatalog() needs at least one kind. An empty list would omit `kind`, which the contract reads as `alloy-wheel` \u2014 so the call would silently return the wheel catalog instead of nothing.");let r=await z("products.listCatalog",async o=>await y(un(e,t,o)),n.throwOnFailure?()=>!0:et,n.maxRows===void 0?void 0:o=>tt([...o]).length>=n.maxRows);return tt(b(r))},getWheel:async e=>C(b(await c(await y(u(`/wheels/${e}`)),await d()))),getTyre:async e=>b(await c(await y(u(`/tyres/${e}`)),await d())),listBundles:async(e={})=>{try{return await c(await y(u("/bundles")),await d())}catch(t){if(e.throwOnFailure)throw t;return[]}},getBundle:async e=>c(await y(u(`/bundles/${e}`)),await d()),listGalleryBuilds:async(e={})=>{let{process:t=null,wheelSlug:n=null}=e;if(typeof window>"u"){let{listGalleryBuilds:r}=await import("./gallery-builds-data-TD3QJK7L.js");return b(r(t,n))}try{let r=new URLSearchParams;t&&r.set("process",t),n&&r.set("wheelSlug",n);let o=r.toString(),l=await c(`/api/v1/gallery-builds${o?`?${o}`:""}`,T());return b(h(l))}catch(r){return console.warn("[products.listGalleryBuilds] product API unavailable, returning []",r),[]}},getSite:async()=>c(await y(u("/site")),await d()),getSiteBySlug:async e=>c(`${u("/site")}?${new URLSearchParams({site:e})}`,typeof window>"u"?await d():void 0),listPages:async()=>b(await c(await y(u("/pages")),await d())),listPopups:async()=>c(await y(u("/popups")),await d()),listProductTemplates:async()=>{try{return await c(await y(u("/product-templates")),await d())}catch(e){return console.warn("[products.listProductTemplates] unavailable, returning []",e),[]}},listDynamicPages:async e=>{let t=e?`?recordType=${encodeURIComponent(e)}`:"";try{return await c(await y(`${u("/dynamic-pages")}${t}`),await d())}catch(n){if(n instanceof S&&n.status===404)return[];throw n}},getRecord:async(e,t)=>{try{return await c(await y(u(`/records/${encodeURIComponent(e)}/${encodeURIComponent(t)}`)),await d())}catch(n){if(n instanceof S&&n.status===404)return null;throw n}},listRecordKeys:async e=>{try{let t=await c(await y(u(`/records/${encodeURIComponent(e)}`)),await d({cache:"no-store"}));return Array.isArray(t?.keys)?t.keys.filter(n=>typeof n=="string"&&n!==""):[]}catch(t){if(t instanceof S&&t.status===404)return[];throw t}},listProductTypeChoices:async()=>{try{return await c(await y(u("/product-type-choices")),await d())}catch(e){return console.warn("[products.listProductTypeChoices] unavailable, returning []",e),[]}},listFieldUsage:async()=>{try{return await c(await y(u("/field-usage")),await d())}catch(e){return console.warn("[products.listFieldUsage] unavailable, returning []",e),[]}},getPage:async(e,t={})=>{let n=t.record?`?record=${encodeURIComponent(t.record)}`:"",[r,o]=await ee(u(`/pages/${e}`)+n,t.revalidate!==void 0?{next:{revalidate:t.revalidate}}:void 0);return b(await c(r,o))},listBlogPosts:async(e={},{throwOnFailure:t=!1}={})=>{let n=e.category?`?category=${encodeURIComponent(e.category)}`:"";try{return(await c(u("/blog-posts")+n,await d())).map(o=>({...o,coverImage:D(o.coverImage)??""}))}catch(r){if(t)throw r;return console.warn("[products.listBlogPosts] blog API unavailable, returning []",r),[]}},getBlogPost:async e=>{let t=await c(u(`/blog-posts/${e}`),await d());return{...t,coverImage:D(t.coverImage)??""}},createOrder:async e=>c(u("/orders"),await d({method:"POST",body:JSON.stringify(e)})),createOrderAuthed:async e=>f(u("/orders"),await d({method:"POST",body:JSON.stringify(e)})),lookupOrder:async e=>c(u("/orders/lookup"),await d({method:"POST",body:JSON.stringify(e)})),createPaymentIntent:async e=>c(u("/payments/intent"),await d({method:"POST",body:JSON.stringify(e)})),releaseCheckout:async e=>c(u("/checkouts/release"),await d({method:"POST",body:JSON.stringify(e)})),createPaypalOrder:async e=>c(u("/payments/paypal/order"),await d({method:"POST",body:JSON.stringify(e)})),capturePaypalOrder:async e=>c(u("/payments/paypal/capture"),await d({method:"POST",body:JSON.stringify(e)})),createAfterpayCheckout:async e=>c(u("/payments/afterpay/checkout"),await d({method:"POST",body:JSON.stringify(e)})),captureAfterpayPayment:async e=>c(u("/payments/afterpay/capture"),await d({method:"POST",body:JSON.stringify(e)})),chargeSquare:async e=>c(u("/payments/square/charge"),await d({method:"POST",body:JSON.stringify(e)})),createGocardlessBillingRequest:async e=>c(u("/payments/gocardless/billing-request"),await d({method:"POST",body:JSON.stringify(e)})),completeGocardlessPayment:async e=>c(u("/payments/gocardless/complete"),await d({method:"POST",body:JSON.stringify(e)})),createZipCheckout:async e=>c(u("/payments/zip/checkout"),await d({method:"POST",body:JSON.stringify(e)})),captureZipPayment:async e=>c(u("/payments/zip/capture"),await d({method:"POST",body:JSON.stringify(e)})),createKlarnaCheckout:async e=>c(u("/payments/klarna/checkout"),await d({method:"POST",body:JSON.stringify(e)})),captureKlarnaPayment:async e=>c(u("/payments/klarna/capture"),await d({method:"POST",body:JSON.stringify(e)})),createStockAlert:async e=>c(u("/stock-alerts"),await d({method:"POST",body:JSON.stringify(e)})),createPreOrderIntent:async e=>c(u("/pre-order-intents"),await d({method:"POST",body:JSON.stringify(e)})),createNewsletterSubscription:async e=>c(u("/newsletter-subscriptions"),await d({method:"POST",body:JSON.stringify(e)})),unsubscribeNewsletter:async e=>c(u("/newsletter-unsubscribe"),await d({method:"POST",body:JSON.stringify(e)})),captureCart:async e=>c(u("/carts"),await d({method:"POST",body:JSON.stringify(e)})),restoreCart:async e=>c(u("/carts/restore"),await d({method:"POST",body:JSON.stringify(e)})),unsubscribeCartReminders:async e=>c(u("/carts/unsubscribe"),await d({method:"POST",body:JSON.stringify(e)})),listReviews:async(e={})=>{let t=new URLSearchParams;e.limit&&t.set("limit",String(e.limit)),e.designCode&&t.set("designCode",e.designCode);let n=u("/reviews"),r=t.toString();try{return await c(await y(r?`${n}?${r}`:n),await d())}catch(o){return console.warn("[products.listReviews] product API unavailable, returning []",o),[]}},submitReview:async e=>c(u("/reviews"),await d({method:"POST",body:JSON.stringify(e)})),getForm:async e=>c(u(`/forms/${encodeURIComponent(e)}`),await d()),submitForm:async(e,t)=>c(u(`/forms/${encodeURIComponent(e)}/submissions`),await d({method:"POST",body:JSON.stringify(t)})),listShippingMethods:async()=>{try{return await c(u("/shipping-methods"),await d())}catch(e){return console.warn("[products.listShippingMethods] product API unavailable, returning []",e),[]}},listCountrySubdivisions:async e=>{try{return await c(u(`/countries/${encodeURIComponent(e)}/subdivisions`),await d())}catch(t){return console.warn("[products.listCountrySubdivisions] unavailable, returning []",t),[]}},quoteCart:async e=>{let t=u("/cart/quote"),n=await d({method:"POST",body:JSON.stringify(e)});return e.couponCode?(await je(t,n)).data:c(t,n)},validateCoupon:async e=>{let{data:t,asShopper:n}=await je(u("/coupons/validate"),await d({method:"POST",body:JSON.stringify(e)}));return{...t,askedAsShopper:n}},getHeaderSettings:async()=>{let e=it({method:"GET"}),t=await c(...await ee(u("/header-settings"),{signal:e})),n=D(t.logoUrl),r=null,o=null;if(n&&Y(n)){let l=await Te(n,e);l&&(r=l.reversed,o=l.inkIsDark)}return{...t,logoUrl:n,logoReversed:r,logoInkIsDark:o}},getThemeSettings:async()=>c(...await ee(u("/theme-settings"))),getChatSettings:async()=>c(await y(u("/chat-settings")),await d())},Gr={listServices:async()=>{try{return await c(u("/bookings/services"),await d())}catch(e){return console.warn("[bookings.listServices] API unavailable, returning []",e),{results:[],currency:"USD"}}},getAvailability:async(e,t)=>c(u(`/bookings/availability?service=${encodeURIComponent(e)}&date=${t}`),await d()),create:async e=>c(u("/bookings"),await d({method:"POST",body:JSON.stringify(e)})),get:async e=>c(u(`/bookings/manage/${encodeURIComponent(e)}`),await d()),cancel:async e=>c(u(`/bookings/manage/${encodeURIComponent(e)}/cancel`),await d({method:"POST"})),createPaymentIntent:async e=>c(u("/bookings/payments/intent"),await d({method:"POST",body:JSON.stringify({manageToken:e})}))},ne=class extends Error{constructor(n,r){super(`Slug "${n}" exists on ${r} websites; a site is required to pick one.`);this.slug=n;this.count=r;this.name="AmbiguousPageSlugError"}},B=(e,t,n)=>{let r=new URLSearchParams({...t?{site:t}:{},...n?{draft:"1"}:{}}).toString();return`/api/storefront/${e}/${r?`?${r}`:""}`},H=e=>`/api/storefront/sites/${encodeURIComponent(e)}/`,bn=e=>`${H(e)}currencies/`,wn="/api/storefront/media/ingest/",re=class extends Error{constructor(){super("This editor is not connected to a website, so an upload has nowhere to go. Open the page from the website the file should belong to, then try again."),this.name="MediaUploadDestinationError"}};function An(){let e=_e();if(!e)throw new re;return`${wn}?${new URLSearchParams({site:e})}`}var Rn="X-Puck-Media-Manifest",nt=ae.contentHash,G={"X-Media-Manifest":nt,[Rn]:nt},Hr=pt({});function pt(e){return(t,n={})=>{let r=zt(),o=e.headers||r?{...r?{"Accept-Language":r}:{},...e.headers,...n.headers}:void 0;return c(t,{...n,...e.baseUrl!==void 0?{baseUrl:e.baseUrl}:{},...o?{headers:o}:{},audience:e.audience??Qt()})}}function kn(e={}){let t=pt(e),n=e.siteDrafts===!0,r=i=>B("header-settings",i,n),o=i=>B("theme-settings",i,n),l=i=>B("chat-settings",i,n),p=i=>B("social-settings",i,n);return{findPageBySlug:async(i,s,a)=>{let m=new URLSearchParams({slug:i});a&&m.set("site",a);let g=await t(`/api/storefront/pages/?${m.toString()}`,{token:s}),w=h(g);if(!a&&w.length>1)throw new ne(i,w.length);return w[0]??null},getPageById:(i,s)=>t(`/api/storefront/pages/${i}/`,{token:s}),saveLayout:(i,s,a,m,g)=>t(`/api/storefront/pages/${i}/`,{method:"PATCH",body:JSON.stringify({layout:s,expected_updated_at:m,...g?{client_id:g}:{}}),token:a}),duplicatePage:(i,s,a)=>t(`/api/storefront/pages/${i}/duplicate/`,{method:"POST",body:JSON.stringify({title:s.title,slug:s.slug}),token:a}),geocode:(i,s,a)=>t(`/api/storefront/geocode/?${new URLSearchParams(a?{q:i,country:a}:{q:i})}`,{token:s}),listBlockSources:i=>t("/api/storefront/block-sources/",{token:i}),listRecordTypes:i=>t("/api/storefront/record-types/",{token:i}),createPagePreviewLink:(i,s)=>t(`/api/storefront/pages/${i}/preview-link/`,{method:"POST",token:s}),claimPageEditLock:(i,s,a,m=!1)=>t(`/api/storefront/pages/${i}/edit-lock/`,{method:"POST",body:JSON.stringify({client_id:a,takeover:m}),token:s}),releasePageEditLock:(i,s)=>t(`/api/storefront/pages/${i}/edit-lock/`,{method:"DELETE",token:s}),createTemplate:(i,s,a)=>t("/api/storefront/page-templates/",{method:"POST",body:JSON.stringify({name:i,layout:s}),headers:G,token:a}),getTemplate:(i,s)=>t(`/api/storefront/page-templates/${i}/`,{token:s}),saveTemplateLayout:(i,s,a)=>t(`/api/storefront/page-templates/${i}/`,{method:"PATCH",body:JSON.stringify({layout:s}),headers:G,token:a}),listTemplatePages:async(i,s)=>{let a=await t(`/api/storefront/template-pages/?template=${encodeURIComponent(i)}`,{token:s});return h(a)},getPageLibrary:async i=>{let s=await t("/api/storefront/page-templates/?is_page_library=true&is_active=true",{token:i});return h(s)[0]??null},getTemplateLibrary:(i,s)=>t(`/api/storefront/pages/template-library/?site=${encodeURIComponent(i)}`,{token:s}),createPageFromTemplate:(i,s)=>t(`/api/storefront/pages/from-template/${n?"?draft=1":""}`,{method:"POST",body:JSON.stringify(i),token:s}),findTemplatePageBySlug:async(i,s,a)=>{let m=await t(`/api/storefront/template-pages/?template=${encodeURIComponent(i)}&slug=${encodeURIComponent(s)}`,{token:a});return h(m)[0]??null},createTemplatePage:(i,s,a)=>t("/api/storefront/template-pages/",{method:"POST",body:JSON.stringify({template:i,...s}),headers:G,token:a}),saveTemplatePageLayout:(i,s,a)=>t(`/api/storefront/template-pages/${i}/`,{method:"PATCH",body:JSON.stringify({layout:s}),headers:G,token:a}),deleteTemplatePage:(i,s,a)=>t(`/api/storefront/template-pages/${i}/`,{method:"DELETE",token:s,...a?.keepalive?{keepalive:!0}:{}}),listPages:async(i,s)=>{let a=new URLSearchParams({no_page:"true"});s&&a.set("site",s);let m=await t(`/api/storefront/pages/?${a.toString()}`,{token:i});return h(m)},createPage:(i,s,a,m)=>t("/api/storefront/pages/",{method:"POST",body:JSON.stringify({title:i,slug:s,layout:a}),token:m}),deletePage:(i,s)=>t(`/api/storefront/pages/${i}/`,{method:"DELETE",token:s}),getHeaderSettings:(i,s)=>t(r(s),{token:i}),listMenus:async(i,s)=>{let a=new URLSearchParams({no_page:"true"});s&&a.set("site",s);let m=await t(`/api/storefront/menus/?${a}`,{token:i});return h(m)},listBlogPosts:async(i,s={})=>{let a=new URLSearchParams({no_page:"true"});s.visibleOnly&&a.set("is_visible","true"),s.siteId&&a.set("site",s.siteId);let m=await t(`/api/storefront/blog-posts/?${a.toString()}`,{token:i});return h(m)},listFieldUsage:async(i,s)=>{let a=await t(`/api/storefront/field-usage/?site=${encodeURIComponent(s)}`,{token:i});return Array.isArray(a?.entries)?a.entries:[]},listCategories:async(i,s={})=>{let a=new URLSearchParams({no_page:"true"});s.visibleOnly&&a.set("is_visible","true"),s.siteId&&a.set("site",s.siteId);let m=await t(`/api/storefront/categories/?${a.toString()}`,{token:i});return[...h(m)].sort((w,U)=>w.sort_order-U.sort_order||w.name.localeCompare(U.name))},listForms:async(i,s={})=>{let a=new URLSearchParams({no_page:"true"});s.siteId&&a.set("site",s.siteId);let m=await t(`/api/storefront/forms/?${a.toString()}`,{token:i});return[...h(m)].sort((w,U)=>w.title.localeCompare(U.title))},listWheelSummaries:async(i,s={})=>{let a=new URLSearchParams;s.siteId&&a.set("site",s.siteId);let m=a.toString(),g=await t(`/api/storefront/wheel-curations/summaries/${m?`?${m}`:""}`,{token:i});return b(g)},listProducts:async(i,s={})=>{let a=new URLSearchParams;s.kinds?.length&&a.set("kind",s.kinds.join(",")),s.siteId&&a.set("site",s.siteId);let m=a.toString(),g=await t(`/api/storefront/products/${m?`?${m}`:""}`,{token:i});return b(g)},getWheelDetail:async(i,s,a={})=>{let m=new URLSearchParams({slug:s});return a.siteId&&m.set("site",a.siteId),C(b(await t(`/api/storefront/wheel-curations/detail/?${m.toString()}`,{token:i})))},updateHeaderSettings:(i,s,a)=>t(r(a),{method:"PATCH",body:JSON.stringify(i),token:s}),getSite:(i,s)=>t(H(i),{token:s}),listSites:async i=>{let s=await t("/api/storefront/sites/?no_page=true",{token:i});return h(s)},listSiteCurrencies:async(i,s)=>{let a=await t(bn(i),{token:s});return Array.isArray(a)?a:[]},publishSite:(i,s)=>t(`${H(i)}publish/`,{method:"POST",token:s}),getSiteLiveState:(i,s)=>t(`${H(i)}live-state/`,{token:s}),getThemeSettings:(i,s)=>t(o(s),{token:i}),updateThemeSettings:(i,s,a)=>t(o(a),{method:"PATCH",body:JSON.stringify(i),token:s}),getMyPreferences:async i=>(await t("/api/auth/me/",{token:i})).preferences??{},updateMyPreferences:(i,s)=>t("/api/auth/me/",{method:"PATCH",body:JSON.stringify({preferences:i}),token:s}),getChatSettings:(i,s)=>t(l(s),{token:i}),updateChatSettings:(i,s,a)=>t(l(a),{method:"PATCH",body:JSON.stringify(i),token:s}),getSocialSettings:(i,s)=>t(p(s),{token:i}),updateSocialSettings:(i,s,a)=>t(p(a),{method:"PATCH",body:JSON.stringify(i),token:s}),uploadHeaderLogo:(i,s,a)=>{let m=new FormData;return m.append("logo",i),t(r(a),{method:"PATCH",body:m,token:s})},clearHeaderLogo:(i,s)=>t(r(s),{method:"PATCH",body:JSON.stringify({logo:null}),token:i}),setHeaderLogoFromAsset:(i,s,a)=>t(r(a),{method:"PATCH",body:JSON.stringify({logo_asset_id:i}),token:s}),uploadMedia:async(i,s)=>{let a=new FormData;return a.append("file",i),t(An(),{method:"POST",body:a,token:s})},listMedia:async(i,s)=>{let a=new URLSearchParams({no_page:"true"});s&&a.set("kind",s);let m=await t(`/api/storefront/media-assets/?${a.toString()}`,{token:i});return h(m)}}}var $r=kn({siteDrafts:!0});function Tn(e){let t=e.trim();return t?`/api/v1/dealers?${new URLSearchParams({near:t}).toString()}`:"/api/v1/dealers"}async function Wr(e){return xe(await c(Tn(e)))}var _={audience:null,baseUrl:""};async function qr(e,t){return Fe(await c(Ie(e,t),_))}async function Kr(e){return Be(await c(Me,{..._,method:"POST",body:JSON.stringify(e)}))}async function Jr(e){try{let t=await c($e,{..._,method:"POST",body:JSON.stringify({token:e})});return Q(202,t)}catch(t){if(t instanceof S)return Q(t.status,t.data);throw t}}async function Zr(e,t){await c(ve,{..._,method:"POST",body:JSON.stringify({email:t.trim(),...e?{product:e}:{}})})}async function Yr(e,t){await c(We,{..._,method:"POST",body:JSON.stringify({email:t.trim(),...e?{product:e}:{}})})}async function Vr(e){try{return Ke(await c(qe,{..._,method:"POST",body:JSON.stringify({token:e})}))}catch(t){if(t instanceof S)return"";throw t}}export{q as a,h as b,ce as c,ue as d,A as e,yt as f,Y as g,_e as h,Ce as i,Gn as j,Hn as k,$n as l,Wn as m,Kn as n,Ne as o,Ue as p,Xn as q,zn as r,P as s,De as t,Le as u,er as v,tr as w,nr as x,rr as y,ir as z,sr as A,or as B,ar as C,lr as D,cr as E,ur as F,dr as G,pr as H,mr as I,gr as J,yr as K,hr as L,v as M,fr as N,Sr as O,Pr as P,qt as Q,S as R,te as S,X as T,Er as U,Nr as V,c as W,sn as X,dt as Y,pn as Z,mn as _,gn as $,fn as aa,Fr as ba,Br as ca,Gr as da,ne as ea,Hr as fa,$r as ga,Wr as ha,qr as ia,Kr as ja,Jr as ka,Zr as la,Yr as ma,Vr as na};
|