efficient-storefront-blocks 0.0.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +429 -0
- package/LICENSE +10 -0
- package/README.md +279 -2
- package/dist/chunks/EditorPreviewCheckout-D2J57RZY.js +4 -0
- package/dist/chunks/PreviewFooter-WL76Z4NK.js +1 -0
- package/dist/chunks/SectionEditorShell-U3CXCPYO.js +1 -0
- package/dist/chunks/SiteEditorProvider-N7LE6HYF.js +1 -0
- package/dist/chunks/chunk-BAXOL3AI.js +1 -0
- package/dist/chunks/chunk-I5J42GI3.js +16 -0
- package/dist/chunks/chunk-I5J42GI3.js.LEGAL.txt +27 -0
- package/dist/chunks/chunk-NQIIJI3Z.js +1 -0
- package/dist/chunks/chunk-QL3UVEEM.js +1 -0
- package/dist/chunks/chunk-R2JQPRJX.js +1 -0
- package/dist/chunks/chunk-XNYKOAQ3.js +153 -0
- package/dist/chunks/chunk-XNYKOAQ3.js.LEGAL.txt +4 -0
- package/dist/chunks/chunk-Y6SLVHK3.js +1 -0
- package/dist/chunks/chunk-YARJ4IUJ.js +230 -0
- package/dist/chunks/fitment-data-3PTG4BJX.js +1 -0
- package/dist/chunks/gallery-builds-data-SWA6XKFF.js +1 -0
- package/dist/chunks/headers-VF4VTX37.js +1 -0
- package/dist/chunks/render-client-DYF6CWVJ.js +1 -0
- package/dist/contract.d.ts +48 -0
- package/dist/contract.js +1 -0
- package/dist/editor.css +1 -0
- package/dist/index.d.ts +721 -0
- package/dist/index.js +10498 -0
- package/dist/links.d.ts +145 -0
- package/dist/links.js +1 -0
- package/package.json +54 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as W,e as G,i as V,k as T,q as I,r as K,t as k}from"./chunk-NQIIJI3Z.js";var E="x-forwarded-for";function j(e){let t=(e??"").split(",").map(r=>r.trim()).filter(Boolean);return t.length>0?t[t.length-1]:null}var ve="x-forwarded-host";function z(e,t,r){let n={};return e&&(n[ve]=e),t&&r==="uncached"&&(n[E]=t),n}function Z(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 Q="x-storefront-site",Y="x-storefront-host";var X={contentHash:"db2b679aad5380c6",schema:1,mediaFields:{ImageBlock:["src"],LogoBlock:["src"],Flex:["bgImage"],FeaturedCover:["image"],LongRead:["image"],Banner:["imageSrc"],Timeline:["imageSrc"],Logos:["items[].src"],ContactLocations:["locations[].photo"],HeroSingle:["imageFocal","mediaImage","mediaVideo","poster"],HeroSlide:["mediaImage","mediaVideo","poster"],PostCard:["image"],Gallery:["othersCards[].image","othersCards[].photos[].src","vehicleCards[].image","vehicleCards[].photos[].src","wheelCards[].image","wheelCards[].photos[].src"],GalleryItem:["image","photos[].src"],Manifesto:["imageSrc"],SectionHeader:["logoSrc"],IntroBleed:["imageSrc","imageSrcMobile"],Split:["imageSrc","textBgSrc"],ProcessSteps:["steps[].image"],DetailRows:["rows[].image"],PaymentBadges:["badges[].src"]},mediaKeyNames:["bgImage","image","imageFocal","imageSrc","imageSrcMobile","logoSrc","mediaImage","mediaVideo","photo","poster","src","textBgSrc"],snapshotObjects:{ProductGrid:{source:{keep:["slug"]}},GalleryItem:{product:{keep:["code","finish"]}},FeaturedCover:{source:{keep:["slug"]}},LongRead:{source:{keep:["slug"]}}},hydratedLists:{Events:["posts"],SubscribeBlogs:["posts"]},technicalStateKeys:["imageFocal"]};var Ie="shop_access_token",ee="shop_refresh_token",B=null;function q(){k.removeItem(Ie),k.removeItem(ee)}var b={getAccess(){return B},takeLegacyRefresh(){let e=k.getItem(ee);return q(),e},setTokens(e){B=e,q()},clear(){B=null,q()}};function Ee(e){return!!e.src}function A(e){let t=e.finishes.filter(Ee);if(t.length===e.finishes.length)return e;let r=e.defaultFinish&&t.some(n=>n.name===e.defaultFinish)?e.defaultFinish:null;return{...e,finishes:t,defaultFinish:r}}function Be(e){return e.listable!==!1}function $(e){return e.map(A).filter(Be)}var se=["fill","stroke","stop-color","color","flood-color","lighting-color","solid-color"],oe=new Set(["none","transparent","currentcolor","inherit","initial","unset","context-fill","context-stroke"]),O={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]},ie=12,ae=/\burl\(/i,ce=new RegExp(`(?<![-\\w])(${se.join("|")})(\\s*=\\s*)(["'])([^"']*)\\3`,"gi"),le=new RegExp(`((?:^|[;{\\s"'])(?:${se.join("|")})\\s*:\\s*)([^;}"'<>]+)`,"gi"),qe=/<svg\b([^>]*)>/i,$e=/\bfill\s*[=:]/i;function Le(e){let t=e.replace(ce,(r,n,s,o,m)=>{let u=te(m);return u===null?r:`${n}${s}${o}${u}${o}`}).replace(le,(r,n,s)=>{let o=te(s);return o===null?r:`${n}${o}`});return t=t.replace(qe,(r,n)=>$e.test(n)?r:`<svg fill="#ffffff"${n}>`),t}function te(e){let t=/!important/i.test(e),n=e.replace(/!important/gi,"").trim().toLowerCase();if(!n||ae.test(n)||oe.has(n))return null;let s=n in O?[...O[n],1]:me(n);if(!s)return null;let[o,m,u,p]=s;if(Math.max(o,m,u)-Math.min(o,m,u)>ie)return null;let y=Ne(255-o,255-m,255-u,p);return t?`${y} !important`:y}function Ne(e,t,r,n){if(n<1)return`rgba(${e}, ${t}, ${r}, ${n})`;let s=o=>o.toString(16).padStart(2,"0");return`#${s(e)}${s(t)}${s(r)}`}function me(e){return e.startsWith("#")?Ue(e):e.startsWith("rgb")?Me(e):e.startsWith("hsl")?De(e):null}function Ue(e){let t=e.slice(1),r=1;if(t.length===3||t.length===4)t.length===4&&(r=parseInt(t[3]+t[3],16)/255),t=t.slice(0,3).split("").map(n=>n+n).join("");else if(t.length===6||t.length===8)t.length===8&&(r=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),r]:null}function Me(e){let t=e.slice(e.indexOf("(")+1,e.lastIndexOf(")")),[r,n]=t.split("/"),s=r.split(/[\s,]+/).filter(Boolean).slice(0,3);if(s.length<3)return null;let o=s.map(u=>u.endsWith("%")?Math.round(parseFloat(u)/100*255):Math.round(parseFloat(u)));if(o.some(u=>Number.isNaN(u)))return null;let m=n?v(n):He(r);return[o[0],o[1],o[2],m]}function He(e){let t=e.split(/[\s,]+/).filter(Boolean);return t.length>=4?v(t[3]):1}function v(e){let t=e.trim().endsWith("%")?parseFloat(e)/100:parseFloat(e);return Number.isNaN(t)?1:t}function De(e){let t=e.slice(e.indexOf("(")+1,e.lastIndexOf(")")),[r,n]=t.split("/"),s=r.split(/[\s,]+/).filter(Boolean);if(s.length<3)return null;let o=parseFloat(s[0]),m=parseFloat(s[1])/100,u=parseFloat(s[2])/100;if([o,m,u].some(Oe=>Number.isNaN(Oe)))return null;let p=n?v(n):s.length>=4?v(s[3]):1,[y,S,P]=Je(o,m,u);return[y,S,P,p]}function Je(e,t,r){let n=(1-Math.abs(2*r-1))*t,s=(e%360+360)%360/60,o=n*(1-Math.abs(s%2-1)),m=0,u=0,p=0;s<1?[m,u,p]=[n,o,0]:s<2?[m,u,p]=[o,n,0]:s<3?[m,u,p]=[0,n,o]:s<4?[m,u,p]=[0,o,n]:s<5?[m,u,p]=[o,0,n]:[m,u,p]=[n,0,o];let y=r-n/2;return[Math.round((m+y)*255),Math.round((u+y)*255),Math.round((p+y)*255)]}var re=512*1024;function L(e){return/\.svg(\?|$)/i.test(e)}function We(e){return`data:image/svg+xml,${encodeURIComponent(Le(e))}`}function Ge(e){let t=e.replace(/!important/gi,"").trim().toLowerCase();if(!t||ae.test(t)||oe.has(t))return null;let r=t in O?[...O[t],1]:me(t);if(!r)return null;let[n,s,o]=r;return Math.max(n,s,o)-Math.min(n,s,o)>ie?null:(.2126*n+.7152*s+.0722*o)/255}function Ve(e){let t=[],r=n=>{let s=Ge(n);s!==null&&t.push(s)};for(let n of e.matchAll(ce))r(n[4]);for(let n of e.matchAll(le))r(n[2]);return t.length?t.reduce((n,s)=>n+s,0)/t.length<.5:null}var ne=/^(?:\uFEFF|\s+|<\?xml[^>]*\?>|<!--[\s\S]*?-->|<!DOCTYPE\s+svg[^>[]*>)/i;function Ke(e){let t=e;for(let r=ne.exec(t);r&&r[0].length>0;r=ne.exec(t))t=t.slice(r[0].length);return/^<svg[\s>/]/i.test(t)}async function je(e,t){if(!L(e))return null;try{let r=await fetch(e,{signal:t,redirect:"manual"});if(!r.ok)return null;let n=Number(r.headers.get("content-length"));if(Number.isFinite(n)&&n>re)return null;let s=await r.text();return s.length>re?null:Ke(s)?s:null}catch{return null}}async function ue(e,t){let r=await je(e,t);return r===null?null:{reversed:We(r),inkIsDark:Ve(r)}}function pe(){return W().siteId()}var ze="",f=class extends Error{constructor(t,r,n){super(r),this.status=t,this.data=n}},U="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.",Ze=new Set([502,503,504]),N=0,Qe="This editor runs on its host's own backend, which does not serve this request.",Ye=5e3,Xe=15e3,et=()=>typeof window>"u"?Ye:Xe;function Ae(e){let t=(e.method??"GET").toUpperCase();if(!(e.body!=null||t!=="GET"&&t!=="HEAD")&&e.audience!=="admin"&&typeof AbortSignal?.timeout=="function")return AbortSignal.timeout(et())}var de=e=>e instanceof Error&&e.name==="TimeoutError",ge=(e,t)=>Ze.has(e)?U:t;function tt(e){if(typeof window>"u"||!e.startsWith("/api/v1/"))return e;let t=I();return!t||/[?&]site=/.test(e)?e:M(e,`site=${encodeURIComponent(t)}`)}async function i(e,t={}){let{token:r,baseUrl:n,headers:s,audience:o,...m}=t;if(typeof window<"u"&&!G())throw new f(N,Qe,null);if(typeof window>"u"&&n===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 u=typeof FormData<"u"&&m.body instanceof FormData,p;try{p=await fetch(`${n??ze}${tt(e)}`,{...m,headers:{...u?{}:{"Content-Type":"application/json"},...r?{Authorization:`Bearer ${r}`}:{},...o===null?{}:{"X-Portal-Audience":o??"shop"},...s},signal:m.signal??Ae({...m,audience:o})})}catch(P){throw P instanceof TypeError||de(P)?new f(N,U,null):P}let y;try{y=await p.text()}catch(P){throw de(P)?new f(N,U,null):P}let S=null;if(y)try{S=JSON.parse(y)}catch{throw new f(p.status,p.ok?"Expected JSON but received a non-JSON response":ge(p.status,p.statusText),y)}if(!p.ok){let P=(S&&typeof S=="object"&&"detail"in S&&typeof S.detail=="string"?S.detail:null)??ge(p.status,p.statusText);throw new f(p.status,P,S)}return S}var R=null;async function Re(){return R||(R=rt().finally(()=>{R=null}),R)}async function rt(){let e=b.takeLegacyRefresh(),t=await nt.refresh(e??void 0);return b.setTokens(t.access),t.access}async function _e(){return b.getAccess()??Re()}async function d(e,t={}){let r;try{r=await _e()}catch{throw b.clear(),new f(401,"Not signed in",null)}try{return await i(e,{...t,token:r})}catch(n){if(!(n instanceof f)||n.status!==401)throw n;try{let s=await Re();return await i(e,{...t,token:s})}catch{throw b.clear(),n}}}async function he(e,t={}){if(b.getAccess())try{return{data:await d(e,t),asShopper:!0}}catch(r){if(!(r instanceof f)||r.status!==401)throw r}return{data:await i(e,t),asShopper:!1}}async function ye(){let e=await d("/api/auth/me/");if(e.portal!=="shop")throw b.clear(),new f(403,"This session is not valid for this shop.",null);return e}var nt={login:(e,t)=>i("/api/auth/login/",{method:"POST",body:JSON.stringify({email:e,password:t,portal:"shop"}),credentials:"include"}),refresh:e=>i("/api/auth/refresh/",{method:"POST",body:JSON.stringify(e?{refresh:e,portal:"shop"}:{portal:"shop"}),credentials:"include"}),logout:async()=>{b.clear();try{await i("/api/auth/logout/",{method:"POST",body:JSON.stringify({portal:"shop"}),credentials:"include"})}catch{}},restoreSession:async()=>{let e=await _e();return await ye(),e},me:ye,updateMe:e=>d("/api/auth/me/",{method:"PATCH",body:JSON.stringify(e)}),changePassword:(e,t)=>d("/api/auth/me/",{method:"PATCH",body:JSON.stringify({password:t,old_password:e})}),changeEmail:(e,t)=>d("/api/shop-portal/change-email/",{method:"POST",body:JSON.stringify({new_email:e,current_password:t})}),myProfile:()=>d("/api/shop-portal/profile/"),updateMyProfile:e=>d("/api/shop-portal/profile/",{method:"PATCH",body:JSON.stringify(e)}),myAddresses:()=>d("/api/shop-portal/delivery-locations/"),createAddress:e=>d("/api/shop-portal/delivery-locations/",{method:"POST",body:JSON.stringify(e)}),updateAddress:(e,t)=>d(`/api/shop-portal/delivery-locations/${e}/`,{method:"PATCH",body:JSON.stringify(t)}),deleteAddress:e=>d(`/api/shop-portal/delivery-locations/${e}/`,{method:"DELETE"}),passwordResetRequest:e=>i("/api/auth/password-reset/",{method:"POST",body:JSON.stringify({email:e})}),passwordResetConfirm:(e,t,r)=>i("/api/auth/password-reset/confirm/",{method:"POST",body:JSON.stringify({uid:e,token:t,new_password:r})}),brands:()=>d("/api/products/brands/"),myOrders:()=>d("/api/shop-portal/orders/").then(e=>e.results),myOrder:e=>d(`/api/shop-portal/orders/${e}/`),cancelOrder:e=>d(`/api/shop-portal/orders/${e}/cancel/`,{method:"POST"}),myReturns:e=>d(`/api/shop-portal/returns/${e?`?order=${encodeURIComponent(e)}`:""}`).then(t=>t.results),createReturn:e=>d("/api/shop-portal/returns/",{method:"POST",body:JSON.stringify(e)}),withdrawReturn:e=>d(`/api/shop-portal/returns/${e}/cancel/`,{method:"POST"}),uploadReturnPhoto:(e,t)=>{let r=new FormData;return r.append("claim_item",e),r.append("file",t),r.append("media_type",t.type.startsWith("video/")?"video":"image"),d("/api/shop-portal/return-media/",{method:"POST",body:r})}};function h(e){if(typeof e=="string")return e.startsWith("/media/")?V(e):e;if(Array.isArray(e))return e.map(h);if(e&&typeof e=="object"){let t={};for(let[r,n]of Object.entries(e))t[r]=r==="captions"&&n&&typeof n=="object"&&!Array.isArray(n)?Object.fromEntries(Object.entries(n).map(([s,o])=>[h(s),o])):h(n);return t}return e}var st="",Ce="".replace(/\/+$/,""),xe=typeof window>"u"&&Ce!=="",ot=xe?Ce:st,it=K,w=()=>({baseUrl:it(),audience:null});function c(e,t){let r=t?`?process=${encodeURIComponent(t)}`:"";return`/api/v1${e}${r}`}var at=100,fe=50;function Te(e,t,r){let n=new URLSearchParams;for(let[s,o]of Object.entries(t))o!=null&&o!==""&&n.set(s,String(o));return n.set("pageSize",String(at)),r&&n.set("cursor",r),`/api/v1${e}?${n.toString()}`}function ct(e,t){return Te("/wheels",{process:e},t)}function lt(e,t,r){return Te("/products",{kind:e.join(","),make:t?.make,model:t?.model,year:t?.year,modification:t?.modification},r)}function mt(e){if(!e)return null;try{return new URL(e,"http://cursor.invalid").searchParams.get("cursor")}catch{return null}}async function Se(e,t,r=()=>!1){let n=[],s=null;try{for(let o=0;o<fe;o++){let m=await i(await t(s),await a());if(n.push(...m.results),s=mt(m.next),!s)break}s&&console.warn(`[${e}] stopped at ${fe} pages (${n.length} rows); catalog may be truncated`)}catch(o){if(r(o))throw o;console.warn(`[${e}] product API unavailable, returning []`,o)}return n}var ut=e=>e instanceof f&&e.status===400;function pt(e){return e.flatMap(t=>t.kind==="alloy-wheel"?$([t]):[t])}async function ke(){return(await dt()).host}async function dt(){try{let{headers:e}=await import("./headers-VF4VTX37.js"),t=await e(),r=o=>o?.split(",")[0]?.split(":")[0]?.trim().toLowerCase()||null,n=r(t.get(Y)??t.get("x-forwarded-host")??t.get("host")),s=r(t.get("host"));return{host:n,matchesRequestHost:n!==null&&n===s}}catch{return{host:null,matchesRequestHost:!1}}}async function gt(){try{let{headers:e}=await import("./headers-VF4VTX37.js");return j((await e()).get(E))}catch{return null}}async function ht(){try{let{headers:e}=await import("./headers-VF4VTX37.js");return(await e()).get(Q)||null}catch{return null}}async function yt(){let e=await ht();if(e)return`site=${encodeURIComponent(e)}`;let t=await ke();return t?`host=${encodeURIComponent(t)}`:""}async function g(e){if(typeof window<"u"){let t=I();return t?M(e,`site=${encodeURIComponent(t)}`):e}return M(e,await yt())}function M(e,t){return t?`${e}${e.includes("?")?"&":"?"}${t}`:e}async function ft(e){if(!xe)return;let[t,r]=await Promise.all([ke(),gt()]),n=z(t,r,e);return Object.keys(n).length>0?n:void 0}async function a(e){let t=await ft(Z(e)),r={baseUrl:ot,...e};return t&&(r.headers={...t,...e?.headers}),r}var _=typeof window>"u";function C(e,t){let r=new URLSearchParams;for(let[s,o]of Object.entries(t))o!==void 0&&o!==""&&r.set(s,String(o));let n=r.toString();return`/api/v1/fitment${e}${n?`?${n}`:""}`}var Gt={listMakes:async e=>{if(_){let{fitmentData:r}=await import("./fitment-data-3PTG4BJX.js");return r.makes(e)}return(await i(C("/makes",{region:e}),w())).results},listModels:async(e,t)=>{if(_){let{fitmentData:n}=await import("./fitment-data-3PTG4BJX.js");return n.models(e,t)}return(await i(C("/models",{make:e,region:t}),w())).results},listYears:async(e,t,r)=>{if(_){let{fitmentData:s}=await import("./fitment-data-3PTG4BJX.js");return s.years(e,t,r)}return(await i(C("/years",{make:e,model:t,region:r}),w())).results},listModifications:async(e,t,r,n)=>{if(_){let{fitmentData:o}=await import("./fitment-data-3PTG4BJX.js");return o.modifications(e,t,r,n)}return(await i(C("/modifications",{make:e,model:t,year:r,region:n}),w())).results},getStockFitment:async(e,t,r,n,s)=>{if(_){let{fitmentData:o}=await import("./fitment-data-3PTG4BJX.js");return o.stockFitment(e,t,r,n,s)}return i(C("/stock-fitment",{make:e,model:t,year:r,modification:n,region:s}),w())}},Vt={listWheels:async e=>{let t=await Se("products.listWheels",async r=>await g(ct(e,r)));return $(h(t))},listCatalog:async(e,t)=>{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 Se("products.listCatalog",async n=>await g(lt(e,t,n)),ut);return pt(h(r))},getWheel:async e=>A(h(await i(await g(c(`/wheels/${e}`)),await a()))),getTyre:async e=>h(await i(await g(c(`/tyres/${e}`)),await a())),listBundles:async()=>{try{return await i(await g(c("/bundles")),await a())}catch{return[]}},getBundle:async e=>i(await g(c(`/bundles/${e}`)),await a()),listGalleryBuilds:async(e={})=>{let{process:t=null,wheelSlug:r=null}=e;if(typeof window>"u"){let{listGalleryBuilds:n}=await import("./gallery-builds-data-SWA6XKFF.js");return h(n(t,r))}try{let n=new URLSearchParams;t&&n.set("process",t),r&&n.set("wheelSlug",r);let s=n.toString(),o=await i(`/api/v1/gallery-builds${s?`?${s}`:""}`,w());return h(o.results)}catch(n){return console.warn("[products.listGalleryBuilds] product API unavailable, returning []",n),[]}},getSite:async()=>i(await g(c("/site")),await a()),getSiteBySlug:async e=>i(`${c("/site")}?${new URLSearchParams({site:e})}`,typeof window>"u"?await a():void 0),listBrands:async()=>{try{return(await i(await g(c("/brands")),await a())).results??[]}catch(e){return console.warn("[products.listBrands] product API unavailable, returning []",e),[]}},listBrandsForSite:async e=>(await i(`${c("/brands")}?${new URLSearchParams({site:e})}`,typeof window>"u"?await a():void 0)).results??[],listPages:async()=>h(await i(await g(c("/pages")),await a())),listProductTemplates:async()=>{try{return await i(await g(c("/product-templates")),await a())}catch(e){return console.warn("[products.listProductTemplates] unavailable, returning []",e),[]}},listProductTypeChoices:async()=>{try{return await i(await g(c("/product-type-choices")),await a())}catch(e){return console.warn("[products.listProductTypeChoices] unavailable, returning []",e),[]}},listFieldUsage:async()=>{try{return await i(await g(c("/field-usage")),await a())}catch(e){return console.warn("[products.listFieldUsage] unavailable, returning []",e),[]}},getPage:async(e,t={})=>h(await i(await g(c(`/pages/${e}`)),await a(t.revalidate!==void 0?{next:{revalidate:t.revalidate}}:void 0))),listBlogPosts:async()=>{try{return(await i(c("/blog-posts"),await a())).map(t=>({...t,coverImage:T(t.coverImage)??""}))}catch(e){return console.warn("[products.listBlogPosts] blog API unavailable, returning []",e),[]}},getBlogPost:async e=>{let t=await i(c(`/blog-posts/${e}`),await a());return{...t,coverImage:T(t.coverImage)??""}},createOrder:async e=>i(c("/orders"),await a({method:"POST",body:JSON.stringify(e)})),createOrderAuthed:async e=>d(c("/orders"),await a({method:"POST",body:JSON.stringify(e)})),lookupOrder:async e=>i(c("/orders/lookup"),await a({method:"POST",body:JSON.stringify(e)})),createPaymentIntent:async e=>i(c("/payments/intent"),await a({method:"POST",body:JSON.stringify(e)})),createPaypalOrder:async e=>i(c("/payments/paypal/order"),await a({method:"POST",body:JSON.stringify(e)})),capturePaypalOrder:async e=>i(c("/payments/paypal/capture"),await a({method:"POST",body:JSON.stringify(e)})),createAfterpayCheckout:async e=>i(c("/payments/afterpay/checkout"),await a({method:"POST",body:JSON.stringify(e)})),captureAfterpayPayment:async e=>i(c("/payments/afterpay/capture"),await a({method:"POST",body:JSON.stringify(e)})),chargeSquare:async e=>i(c("/payments/square/charge"),await a({method:"POST",body:JSON.stringify(e)})),createGocardlessBillingRequest:async e=>i(c("/payments/gocardless/billing-request"),await a({method:"POST",body:JSON.stringify(e)})),completeGocardlessPayment:async e=>i(c("/payments/gocardless/complete"),await a({method:"POST",body:JSON.stringify(e)})),createZipCheckout:async e=>i(c("/payments/zip/checkout"),await a({method:"POST",body:JSON.stringify(e)})),captureZipPayment:async e=>i(c("/payments/zip/capture"),await a({method:"POST",body:JSON.stringify(e)})),createKlarnaCheckout:async e=>i(c("/payments/klarna/checkout"),await a({method:"POST",body:JSON.stringify(e)})),captureKlarnaPayment:async e=>i(c("/payments/klarna/capture"),await a({method:"POST",body:JSON.stringify(e)})),createStockAlert:async e=>i(c("/stock-alerts"),await a({method:"POST",body:JSON.stringify(e)})),createPreOrderIntent:async e=>i(c("/pre-order-intents"),await a({method:"POST",body:JSON.stringify(e)})),createNewsletterSubscription:async e=>i(c("/newsletter-subscriptions"),await a({method:"POST",body:JSON.stringify(e)})),unsubscribeNewsletter:async e=>i(c("/newsletter-unsubscribe"),await a({method:"POST",body:JSON.stringify(e)})),captureCart:async e=>i(c("/carts"),await a({method:"POST",body:JSON.stringify(e)})),restoreCart:async e=>i(c("/carts/restore"),await a({method:"POST",body:JSON.stringify(e)})),unsubscribeCartReminders:async e=>i(c("/carts/unsubscribe"),await a({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 r=c("/reviews"),n=t.toString();try{return await i(await g(n?`${r}?${n}`:r),await a())}catch(s){return console.warn("[products.listReviews] product API unavailable, returning []",s),[]}},submitReview:async e=>i(c("/reviews"),await a({method:"POST",body:JSON.stringify(e)})),getForm:async e=>i(c(`/forms/${encodeURIComponent(e)}`),await a()),submitForm:async(e,t)=>i(c(`/forms/${encodeURIComponent(e)}/submissions`),await a({method:"POST",body:JSON.stringify(t)})),listShippingMethods:async()=>{try{return await i(c("/shipping-methods"),await a())}catch(e){return console.warn("[products.listShippingMethods] product API unavailable, returning []",e),[]}},listCountrySubdivisions:async e=>{try{return await i(c(`/countries/${encodeURIComponent(e)}/subdivisions`),await a())}catch(t){return console.warn("[products.listCountrySubdivisions] unavailable, returning []",t),[]}},quoteCart:async e=>{let t=c("/cart/quote"),r=await a({method:"POST",body:JSON.stringify(e)});return e.couponCode?(await he(t,r)).data:i(t,r)},validateCoupon:async e=>{let{data:t,asShopper:r}=await he(c("/coupons/validate"),await a({method:"POST",body:JSON.stringify(e)}));return{...t,askedAsShopper:r}},getHeaderSettings:async()=>{let e=Ae({method:"GET"}),t=await i(await g(c("/header-settings")),await a({signal:e})),r=T(t.logoUrl),n=null,s=null;if(r&&L(r)){let o=await ue(r,e);o&&(n=o.reversed,s=o.inkIsDark)}return{...t,logoUrl:r,logoReversed:n,logoInkIsDark:s}},getThemeSettings:async()=>i(await g(c("/theme-settings")),await a()),getChatSettings:async()=>i(await g(c("/chat-settings")),await a())},Kt={listServices:async()=>{try{return await i(c("/bookings/services"),await a())}catch(e){return console.warn("[bookings.listServices] API unavailable, returning []",e),{results:[],currency:"USD"}}},getAvailability:async(e,t)=>i(c(`/bookings/availability?service=${encodeURIComponent(e)}&date=${t}`),await a()),create:async e=>i(c("/bookings"),await a({method:"POST",body:JSON.stringify(e)})),get:async e=>i(c(`/bookings/manage/${encodeURIComponent(e)}`),await a()),cancel:async e=>i(c(`/bookings/manage/${encodeURIComponent(e)}/cancel`),await a({method:"POST"})),createPaymentIntent:async e=>i(c("/bookings/payments/intent"),await a({method:"POST",body:JSON.stringify({manageToken:e})}))},H=class extends Error{constructor(r,n){super(`Slug "${r}" exists on ${n} websites; a site is required to pick one.`);this.slug=r;this.count=n;this.name="AmbiguousPageSlugError"}},x=e=>e?`/api/storefront/header-settings/?${new URLSearchParams({site:e})}`:"/api/storefront/header-settings/",Pe=e=>e?`/api/storefront/theme-settings/?${new URLSearchParams({site:e})}`:"/api/storefront/theme-settings/",be=e=>e?`/api/storefront/chat-settings/?${new URLSearchParams({site:e})}`:"/api/storefront/chat-settings/",we=e=>`/api/storefront/social-settings/?${new URLSearchParams({site:e})}`,D=e=>`/api/storefront/sites/${encodeURIComponent(e)}/`,St=e=>`${D(e)}currencies/`,Pt="/api/storefront/media/ingest/",J=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 bt(){let e=pe();if(!e)throw new J;return`${Pt}?${new URLSearchParams({site:e})}`}var F={"X-Puck-Media-Manifest":X.contentHash},l=(e,t={})=>i(e,{...t,audience:"admin"}),jt={findPageBySlug:async(e,t,r)=>{let n=new URLSearchParams({slug:e});r&&n.set("site",r);let s=await l(`/api/storefront/pages/?${n.toString()}`,{token:t}),o=Array.isArray(s)?s:s.results??[];if(!r&&o.length>1)throw new H(e,o.length);return o[0]??null},getPageById:(e,t)=>l(`/api/storefront/pages/${e}/`,{token:t}),saveLayout:(e,t,r,n,s)=>l(`/api/storefront/pages/${e}/`,{method:"PATCH",body:JSON.stringify({layout:t,expected_updated_at:n,...s?{client_id:s}:{}}),token:r}),publishPage:(e,t,r)=>l(`/api/storefront/pages/${e}/publish/`,{method:"POST",body:r?JSON.stringify({expected_updated_at:r}):void 0,token:t}),claimPageEditLock:(e,t,r,n=!1)=>l(`/api/storefront/pages/${e}/edit-lock/`,{method:"POST",body:JSON.stringify({client_id:r,takeover:n}),token:t}),releasePageEditLock:(e,t)=>l(`/api/storefront/pages/${e}/edit-lock/`,{method:"DELETE",token:t}),createTemplate:(e,t,r)=>l("/api/storefront/page-templates/",{method:"POST",body:JSON.stringify({name:e,layout:t}),headers:F,token:r}),getTemplate:(e,t)=>l(`/api/storefront/page-templates/${e}/`,{token:t}),saveTemplateLayout:(e,t,r)=>l(`/api/storefront/page-templates/${e}/`,{method:"PATCH",body:JSON.stringify({layout:t}),headers:F,token:r}),listTemplatePages:async(e,t)=>{let r=await l(`/api/storefront/template-pages/?template=${encodeURIComponent(e)}`,{token:t});return Array.isArray(r)?r:r.results??[]},findTemplatePageBySlug:async(e,t,r)=>{let n=await l(`/api/storefront/template-pages/?template=${encodeURIComponent(e)}&slug=${encodeURIComponent(t)}`,{token:r});return(Array.isArray(n)?n:n.results??[])[0]??null},createTemplatePage:(e,t,r)=>l("/api/storefront/template-pages/",{method:"POST",body:JSON.stringify({template:e,...t}),headers:F,token:r}),saveTemplatePageLayout:(e,t,r)=>l(`/api/storefront/template-pages/${e}/`,{method:"PATCH",body:JSON.stringify({layout:t}),headers:F,token:r}),deleteTemplatePage:(e,t)=>l(`/api/storefront/template-pages/${e}/`,{method:"DELETE",token:t}),listPages:async(e,t)=>{let r=new URLSearchParams({no_page:"true"});t&&r.set("site",t);let n=await l(`/api/storefront/pages/?${r.toString()}`,{token:e});return Array.isArray(n)?n:n.results??[]},createPage:(e,t,r,n)=>l("/api/storefront/pages/",{method:"POST",body:JSON.stringify({title:e,slug:t,layout:r}),token:n}),deletePage:(e,t)=>l(`/api/storefront/pages/${e}/`,{method:"DELETE",token:t}),getHeaderSettings:(e,t)=>l(x(t),{token:e}),listMenus:async(e,t)=>{let r=new URLSearchParams({no_page:"true"});t&&r.set("site",t);let n=await l(`/api/storefront/menus/?${r}`,{token:e});return Array.isArray(n)?n:n.results??[]},listBlogPosts:async(e,t={})=>{let r=new URLSearchParams({no_page:"true"});t.visibleOnly&&r.set("is_visible","true"),t.siteId&&r.set("site",t.siteId);let n=await l(`/api/storefront/blog-posts/?${r.toString()}`,{token:e});return Array.isArray(n)?n:n.results??[]},listFieldUsage:async(e,t)=>{let r=await l(`/api/storefront/field-usage/?site=${encodeURIComponent(t)}`,{token:e});return Array.isArray(r?.entries)?r.entries:[]},listCategories:async(e,t={})=>{let r=new URLSearchParams({no_page:"true"});t.visibleOnly&&r.set("is_visible","true"),t.siteId&&r.set("site",t.siteId);let n=await l(`/api/storefront/categories/?${r.toString()}`,{token:e});return[...Array.isArray(n)?n:n.results??[]].sort((o,m)=>o.sort_order-m.sort_order||o.name.localeCompare(m.name))},listForms:async(e,t={})=>{let r=new URLSearchParams({no_page:"true"});t.siteId&&r.set("site",t.siteId);let n=await l(`/api/storefront/forms/?${r.toString()}`,{token:e});return[...Array.isArray(n)?n:n.results??[]].sort((o,m)=>o.title.localeCompare(m.title))},listWheelSummaries:async(e,t={})=>{let r=new URLSearchParams;t.siteId&&r.set("site",t.siteId);let n=r.toString(),s=await l(`/api/storefront/wheel-curations/summaries/${n?`?${n}`:""}`,{token:e});return h(s)},listProducts:async(e,t={})=>{let r=new URLSearchParams;t.kinds?.length&&r.set("kind",t.kinds.join(",")),t.siteId&&r.set("site",t.siteId);let n=r.toString(),s=await l(`/api/storefront/products/${n?`?${n}`:""}`,{token:e});return h(s)},getWheelDetail:async(e,t,r={})=>{let n=new URLSearchParams({slug:t});return r.siteId&&n.set("site",r.siteId),A(h(await l(`/api/storefront/wheel-curations/detail/?${n.toString()}`,{token:e})))},updateHeaderSettings:(e,t,r)=>l(x(r),{method:"PATCH",body:JSON.stringify(e),token:t}),getSite:(e,t)=>l(D(e),{token:t}),listSiteCurrencies:async(e,t)=>{let r=await l(St(e),{token:t});return Array.isArray(r)?r:[]},updateSite:(e,t,r)=>l(D(e),{method:"PATCH",body:JSON.stringify(t),token:r}),getThemeSettings:(e,t)=>l(Pe(t),{token:e}),updateThemeSettings:(e,t,r)=>l(Pe(r),{method:"PATCH",body:JSON.stringify(e),token:t}),getChatSettings:(e,t)=>l(be(t),{token:e}),updateChatSettings:(e,t,r)=>l(be(r),{method:"PATCH",body:JSON.stringify(e),token:t}),getSocialSettings:(e,t)=>l(we(t),{token:e}),updateSocialSettings:(e,t,r)=>l(we(r),{method:"PATCH",body:JSON.stringify(e),token:t}),uploadHeaderLogo:(e,t,r)=>{let n=new FormData;return n.append("logo",e),l(x(r),{method:"PATCH",body:n,token:t})},clearHeaderLogo:(e,t)=>l(x(t),{method:"PATCH",body:JSON.stringify({logo:null}),token:e}),setHeaderLogoFromAsset:(e,t,r)=>l(x(r),{method:"PATCH",body:JSON.stringify({logo_asset_id:e}),token:t}),uploadMedia:async(e,t)=>{let r=new FormData;return r.append("file",e),l(bt(),{method:"POST",body:r,token:t})},listMedia:async(e,t)=>{let r=new URLSearchParams({no_page:"true"});t&&r.set("kind",t);let n=await l(`/api/storefront/media-assets/?${r.toString()}`,{token:e});return Array.isArray(n)?n:n.results??[]}};export{X as a,z as b,Z as c,b as d,Ee as e,L as f,pe as g,ze as h,f as i,U as j,N as k,i as l,nt as m,st as n,ke as o,dt as p,gt as q,ht as r,Gt as s,Vt as t,Kt as u,H as v,l as w,jt as x};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{f as nt,i as me,p as rt,r as ot,t as q}from"./chunk-QL3UVEEM.js";import{Ma as de,Na as Ze,Qa as Re,Ra as et}from"./chunk-BAXOL3AI.js";import{e as Je,r as tt,t as re}from"./chunk-NQIIJI3Z.js";import{createContext as Qt,useContext as jt,useEffect as Jt,useMemo as pe,useState as at}from"react";function it(e,t){return e.map(n=>({partNumber:n.partNumber,quantity:n.wheels*t}))}function oe(e,t){if(e.length===0)return null;let n=0;for(let r of e){let o=r.prices?.[t];if(typeof o!="number"||!Number.isFinite(o)||o<=0)return null;n+=o*r.wheels}return n}var Me=4,sr=1,ar={unit:"set",spares:0,spareSide:"left"};function st(e){return e.unit==="single"?1:Me+e.spares}function lr(e,t){return[{partNumber:e.partNumber,wheels:st(t),prices:e.prices}]}function ur(e,t){let n=st(t)-Me;if(n<=0||e.length===0)return e;let r=Xt(e),o=r?r[t.spareSide]:0;return e.map((i,s)=>s===o?{...i,wheels:i.wheels+n}:i)}function Xt(e){let t,n;for(let r=0;r<e.length;r+=1){let o=e[r].hand;if(o!=="left"&&o!=="right")continue;if((o==="left"?t:n)!==void 0)return null;o==="left"?t=r:n=r}return t!==void 0&&n!==void 0?{left:t,right:n}:null}function Yt(e,t){return t.spares>0?`${e} + spare`:e}function cr(e){return e.unit==="single"?"Single":Yt(`Set of ${Me}`,e)}var dr="data-add-to-basket",De=9,Oe="en";function fe(e,t,n=0){return new Intl.NumberFormat(Oe,{style:"currency",currency:t,minimumFractionDigits:0,maximumFractionDigits:n}).format(e)}import{jsx as tn}from"react/jsx-runtime";var lt="storefront-country",ut=Qt(null);function Zt(e){return ct(e,"catalogue")}function en(e){return ct(e,"money")}function ct(e,t){let n=new Map(e.map(o=>[o.code,o.decimalPlaces])),r=new Map;return(o,i)=>{if(!i)return"";let s=r.get(i);if(!s){let u=n.get(i)??0;s=new Intl.NumberFormat(Oe,{style:"currency",currency:i,minimumFractionDigits:t==="money"?u:0,maximumFractionDigits:u}),r.set(i,s)}return s.format(o)}}function yr({children:e,currencies:t,countries:n,defaultCurrency:r,defaultCountry:o}){let i=pe(()=>t??[],[t]),s=pe(()=>n??[],[n]),u=pe(()=>r||i.find(C=>C.isDefault)?.code||i[0]?.code||"",[r,i]),c=pe(()=>o||s.find(C=>C.isDefault)?.code||s[0]?.code||"",[o,s]),[l,d]=at(c),[f,P]=at(!1);Jt(()=>{let C=re.getItem(lt);C&&s.some(L=>L.code===C)&&d(C),P(!0)},[s]);function w(C){d(C),re.setItem(lt,C)}let h=pe(()=>{let C=s.find(I=>I.code===l)??null,L=C?.currency,N=L&&i.some(I=>I.code===L)?L:u,M=Zt(i),x=en(i);return{country:l,currency:N,setCountry:w,currencies:i,countries:s,activeCountry:C,formatPrice:(I,S)=>M(I,S??N),formatMoney:(I,S)=>x(I,S??N),ready:f}},[l,i,s,u,f]);return tn(ut.Provider,{value:h,children:e})}function dt(){let e=jt(ut);if(!e)throw new Error("useCurrency must be used within a CurrencyProvider");return e}import{createContext as pn,useCallback as _,useContext as gn,useEffect as X,useMemo as St,useRef as ie,useState as A}from"react";function ft(e,t){return e.valid?!1:e.reason==="firstOrderOnly"?!0:e.reason==="notEligible"&&!t}var pt="We'll confirm this discount when you place your order.",xr="Confirmed at checkout";function Sr(e){return e&&(e.valid||e.deferred)?e.code:void 0}var mt="coupon_code: ";function vr(e){return!(e instanceof me)||e.status!==400||!e.message.startsWith(mt)?null:e.message.slice(mt.length)}function gt(e,t){return e.map(n=>({qty:n.qty,slug:n.slug,name:`${n.name.lead}${n.name.accent}`.trim(),finish:n.finishName,size:n.size,kind:n.kind,sku:n.sku,pack:n.pack,priceLabel:t(n)}))}var Pe="Price on request",rn="Request a quote";function Fe(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Ue(e,t){let n=e?.[t];return Fe(n)?n:null}function Ir(e,t,n,r){let o=Ue(e,n),i=Ue(t,n);return o===null&&i===null?0:o===null?1:i===null?-1:r==="asc"?o-i:i-o}function wr(e,t,n,r){if(n==null&&r==null)return!0;let o=Ue(e,t);return!(o===null||n!=null&&o<n||r!=null&&o>r)}var on={priced:!1,unit:null,was:null,onSale:!1,setTotal:null};function sn(e,t,n){if(!Fe(e))return on;let r=Fe(t)&&t>e?t:null;return{priced:!0,unit:e,was:r,onSale:r!==null,setTotal:n!=null?e*n:null}}function Tr(e,t,n=""){return!e.priced||e.unit==null?Pe:`${n}${fe(e.unit,t)}`}function Nr(e,t){return e.was==null?null:fe(e.was,t)}function an(e,t,n=1){let r=oe(e,t);if(r===null)return{priced:!1,unit:null,isFrom:!1,setTotal:null};let o=e.reduce((s,u)=>s+u.wheels,0),i=Math.min(...e.map(s=>s.prices[t]));return{priced:!0,unit:i,isFrom:i*o!==r,setTotal:r*n}}var ln={priced:!1,unit:null,isFrom:!1,was:null,onSale:!1,setTotal:null};function kr(e,t,n,r=1){let o=sn(e.prices[n],e.msrpPrices?.[n],4),i=o.setTotal==null?null:o.setTotal*r;if(!t)return{priced:o.priced,unit:o.unit,isFrom:!0,was:o.was,onSale:o.onSale,setTotal:null,fromSetTotal:i};let s=an(t.components,n,r);return s.priced?{priced:!0,unit:s.unit,isFrom:s.isFrom,was:null,onSale:!1,setTotal:s.setTotal,fromSetTotal:i}:{...ln,fromSetTotal:i}}function un(e,t){return!e.priced||e.unit==null?Pe:`${e.isFrom?"from ":""}${fe(e.unit,t)}`}function _r(e,t){return e.was==null?null:fe(e.was,t)}function Ar(e,t){return!e.priced||e.unit==null?rn:un(e,t)}var cn=/^[^@\s]+@[^@\s]+\.[^@\s]+$/;function yt(e){return cn.test(e.trim())}var bt="sf:ga-purchases",dn=20;function Ct(){return typeof window>"u"||window.parent!==window}function ge(...e){try{if(Ct()||typeof window.gtag!="function")return;window.gtag(...e)}catch{}}function mn(e,t){let n=e.config.find(r=>r.gold)?.label;return{item_id:`${e.slug}|${e.finishName}|${e.size}`,item_name:`${e.name.lead}${e.name.accent}`.trim(),...n?{item_variant:n}:{},price:oe(e.components,t)??0,quantity:e.qty}}function $e(e,t){return e.filter(Le).map(n=>mn(n,t))}function Ur(e){ge("event","view_item",{currency:e.currency,value:e.pricePerSet,items:[{item_id:e.itemId,item_name:e.itemName,...e.variant?{item_variant:e.variant}:{},price:e.pricePerSet,quantity:1}]})}function xt(e,t){let n=$e([e],t);n.length!==0&&ge("event","add_to_cart",{currency:t,value:n[0].price*n[0].quantity,items:n})}function $r(e){let t=$e(e.lines,e.currency);t.length!==0&&ge("event","begin_checkout",{currency:e.currency,value:e.value,...e.coupon?{coupon:e.coupon}:{},items:t})}var ht=new Set;function fn(e){if(ht.has(e))return!1;ht.add(e);try{let t=JSON.parse(re.getItem(bt)??"[]");if(t.includes(e))return!1;re.setItem(bt,JSON.stringify([...t,e].slice(-dn)))}catch{}return!0}function qr(e){let t=e.confirmation;if(Ct()||!fn(t.orderNumber))return;let n=t.currency,r=Number(t.grandTotal);ge("event","purchase",{transaction_id:t.orderNumber,currency:n,value:r,shipping:Number(t.freightCharge),...t.couponCode?{coupon:t.couponCode}:{},items:$e(e.lines,n)}),e.adsSendTo&&ge("event","conversion",{send_to:e.adsSendTo,transaction_id:t.orderNumber,currency:n,value:r})}import{jsx as Cn}from"react/jsx-runtime";var yn=400,bn=400,hn=1500;function Le(e){return(e.components?.length??0)>0}function vt(e,t){return{code:e,valid:t.valid,deferred:ft(t,t.askedAsShopper),message:t.message||void 0,effects:t.effects??void 0}}function Pt(e,t){return oe(e.components,t)}function qe(e,t){let n=Pt(e,t);return n===null?null:n*e.qty}function Et(e){return e!=="tyre"}var Lt=pn(null);function jr({children:e,preview:t=!1}){let{currency:n,country:r,formatMoney:o}=dt(),[i,s]=A(t),[u,c]=A([]),[l,d]=A([]),[f,P]=A([]),[w,h]=A(!1),[C,L]=A(!1),[N,M]=A(!1),[x,I]=A(!1),[S,H]=A(null),[W,Q]=A(void 0),b=ie(r),v=ie("");b.current=b.current||r;let[m,K]=A(null),[j,z]=A(!1),[R,J]=A(null),Z=ie(void 0),D=_(()=>s(!0),[]),Ce=_(()=>s(!1),[]),O=_(()=>s(a=>!a),[]);X(()=>{t||typeof window>"u"||new URLSearchParams(window.location.search).get("cart")==="open"&&D()},[D,t]);let xe=_(a=>{I(!0),Et(a)&&M(!0)},[]),ee=N||u.some(a=>Et(a.kind)),ae=x||u.length>0;X(()=>{if(t||!ee||w)return;let a=!0;return q.listWheels().then(p=>{a&&(d(p),h(!0))}),()=>{a=!1}},[t,ee,w]),X(()=>{if(t||!ae||C)return;let a=!0;return q.listBundles().then(p=>{a&&(P(p),L(!0))}),()=>{a=!1}},[t,ae,C]);let U=S?.deliveryOptions??[];X(()=>{U.length!==0&&J(a=>a&&U.some(p=>p.id===a)?a:U[0]?.id??null)},[S]);let V=_(()=>u.filter(Le).flatMap(a=>it(a.components,a.qty)),[u]),le=_(async(a,p)=>{let y=a.trim().toUpperCase();if(!y)return;let g=V();if(g.length===0){K({code:y,valid:!1,message:"Add a wheel to the cart first."});return}z(!0),Z.current=p;try{let T=await q.validateCoupon({code:y,items:g,currency:n,shippingMethodId:R??void 0,customerEmail:p});K(vt(y,T))}catch{K({code:y,valid:!1,message:"Could not check that code. Please try again."})}finally{z(!1)}},[V,n,R]),te=_(()=>{K(null),Z.current=void 0},[]),Se=_(a=>{if(!m)return;let{code:p}=m;K(y=>y&&y.code===p?{code:p,valid:!1,refused:!0,message:a}:y)},[m]);X(()=>{if(!m||m.refused)return;let a=m.code,p=g=>g!==null&&g.code===a&&!g.refused,y=setTimeout(async()=>{let g=V();if(g.length===0){K(T=>p(T)?{code:a,valid:!1,message:"Add a wheel to the cart first."}:T);return}z(!0);try{let T=await q.validateCoupon({code:a,items:g,currency:n,shippingMethodId:R??void 0,customerEmail:Z.current});K(ce=>p(ce)?vt(a,T):ce)}catch{}finally{z(!1)}},yn);return()=>clearTimeout(y)},[u,n,R]);let ve=m&&!m.refused?m.code:void 0;X(()=>{if(t)return;let a=!0,p=setTimeout(async()=>{let y=V();if(y.length===0){H(null),Q(void 0);return}try{let g=await q.quoteCart({items:y,currency:n,shippingMethodId:R??void 0,couponCode:ve,customerEmail:Z.current||void 0,country:b.current||void 0,subdivision:v.current||void 0});if(!a)return;H(g)}catch{if(!a)return}Q(ve)},bn);return()=>{a=!1,clearTimeout(p)}},[u,n,R,ve,r]);let E=_(a=>{c(p=>{let y=p.findIndex(g=>g.id===a.id);return y===-1?[...p,a]:p.map((g,T)=>T===y?{...g,qty:Math.min(De,g.qty+a.qty)}:g)}),xt(a,n)},[n]),F=_(a=>{c(p=>p.filter(y=>y.id!==a))},[]),G=_((a,p)=>{let y=Math.max(1,Math.min(De,p));c(g=>g.map(T=>T.id===a?{...T,qty:y}:T))},[]),ze=_(a=>{c(a)},[]),[ue,Ht]=A(null),Ve=ie(null);Ve.current=ue;let $=ie(null),_e=ie(""),Ge=_((a,p)=>{let y=a.trim().toLowerCase();yt(y)&&Ht(g=>g&&g.email===y&&g.firstName===(p??"")?g:{email:y,firstName:p??""})},[]);X(()=>{if(t||!ue)return;let a=gt(u.filter(Le),g=>qe(g,n)===null?Pe:o(qe(g,n),n)),p={email:ue.email,firstName:ue.firstName,currency:n,items:a},y=JSON.stringify(p);if(y!==_e.current)return $.current&&clearTimeout($.current),$.current=setTimeout(()=>{$.current=null,_e.current=y,q.captureCart(p).catch(g=>{})},hn),()=>{$.current&&(clearTimeout($.current),$.current=null)}},[u,ue,n,t]);let Xe=_(()=>{$.current&&(clearTimeout($.current),$.current=null);let a=Ve.current;a&&(_e.current="",q.captureCart({email:a.email,firstName:a.firstName,currency:n,items:[]}).catch(p=>{}))},[n]),Ye=St(()=>{let a=u.reduce((k,ne)=>{let Ee=qe(ne,n);return Ee===null?k:k+Ee},0),p=u.some(k=>Pt(k,n)===null),y=u.reduce((k,ne)=>k+ne.qty,0),g=m?.valid?m.effects:void 0,T=g?Math.min(a,Number(g.discountAmount)):0,ce=S?.bundleDiscount??0,Wt=S?.appliedBundles??[],Qe=!!g?.freeShipping,Bt=U.find(k=>k.id===R),je=Qe?0:S?.shipping??Bt?.amount??0,Ae={};for(let k of g?.freeUnits??[])Ae[k.partNumber]=(Ae[k.partNumber]??0)+k.quantity;let zt=S?.tax??null,Vt=S?S.grandTotal:a-T-ce+je;return{sets:y,units:u.reduce((k,ne)=>k+(ne.components??[]).reduce((Ee,Gt)=>Ee+Gt.wheels*ne.qty,0),0),subtotal:a,hasUnpricedLine:p,discount:T,bundleDiscount:ce,appliedBundles:Wt,shipping:je,freeShipping:Qe,freeUnitsByPartNumber:Ae,tax:zt,grand:Vt,repricing:!!m?.refused&&S!==null&&W===m?.code,currency:n}},[u,n,m,U,R,S,W]),Kt=St(()=>({isOpen:i,preview:t,open:D,close:Ce,toggle:O,items:u,catalog:l,bundles:f,warmCatalog:xe,add:E,remove:F,setQty:G,replaceItems:ze,identify:Ge,clearCapturedCart:Xe,coupon:m,applyCoupon:le,removeCoupon:te,refuseCoupon:Se,couponBusy:j,deliveryOptions:U,shippingMethodId:R,setShippingMethodId:J,totals:Ye}),[i,t,D,Ce,O,u,l,f,xe,E,F,G,ze,Ge,Xe,m,le,te,Se,j,U,R,Ye]);return Cn(Lt.Provider,{value:Kt,children:e})}function It(){let e=gn(Lt);if(!e)throw new Error("useCart() must be called inside <CartProvider>. Mount the provider in app/layout.tsx.");return e}import{cache as kn}from"react";function wt(e,t,n,r){for(;e.size>=t;){let o,i;for(let[u,c]of e){if(c.expiresAt<=r){o=u;break}i===void 0&&n(u)&&(i=u)}let s=o??i??e.keys().next().value;if(s===void 0)return;e.delete(s)}}var xn=6e4,Sn=5e3,vn=500,Ie=new Map;async function En(e){let{host:t,matchesRequestHost:n}=await rt();if(!t)return"";let r=await ot();return r?`${e}|slug:${encodeURIComponent(t)}/${encodeURIComponent(r)}`:n?`${e}|host:${t}`:`${e}|xhost:${t}`}var Pn=e=>e.includes("|slug:")||e.includes("|xhost:");async function Tt(e,t){let n=await En(e);if(!n)return t();let r=Date.now(),o=Ie.get(n);if(o&&o.expiresAt>r)return o.load;let i=await t(),s=i.outcome.state==="failed",u=s?Sn:xn,c=Ie.get(n)?.lastGood,l=i.outcome.state==="ok"?i:s?c:void 0,d=s&&l?l:i;return wt(Ie,vn,Pn,r),Ie.set(n,{load:d,expiresAt:r+u,lastGood:l}),d}var Ln=404;function In(e){if(e instanceof me&&e.status===Ln)return{state:"absent"};let t=e instanceof me?e.status:-1,n=e instanceof Error?e.message:String(e);return{state:"failed",status:t,detail:n}}var wn="[storefront:chrome-load-failed]";function Tn(e,t){console.error(`${wn} ${e} status=${t.status} \u2014 serving fallback chrome`,t.detail)}async function Nt(e,t,n,r){try{let o=await t();return r?.(o)?{value:o,outcome:{state:"absent"}}:{value:o,outcome:{state:"ok"}}}catch(o){let i=In(o);return i.state==="failed"&&Tn(e,i),{value:n,outcome:i}}}function Nn(e){return e==="production"?"silent":"banner"}var io=Nn("production");function _n(e,t){return e?.trim()||t}function po({legalName:e,foundedYear:t,siteName:n},r=new Date().getFullYear()){let o=_n(e,n);return`\xA9 ${t&&t<r?`${t}\u2013${r}`:`${r}`} ${o}`}var An={name:de,legalName:null,foundedYear:null,faviconUrl:null,currencies:[],defaultCurrency:null,countries:[],defaultCountry:null,commerceEnabled:!0,cardPayments:!1,paymentMethods:[],paypalClientId:null,paypalEnvironment:null,squareApplicationId:null,squareLocationId:null,squareEnvironment:null,ga4MeasurementId:null,googleAdsId:null,googleAdsConversionLabel:null,metaPixelId:null,mapsApiKey:null,mapsMapId:null,socialLinks:Re},go=kn(async()=>Tt("site",()=>Nt("site",async()=>{let e=await q.getSite();return{name:Ze(e.name),legalName:e.legalName?.trim()||null,foundedYear:e.foundedYear??null,faviconUrl:e.faviconUrl??null,currencies:e.currencies??[],defaultCurrency:e.defaultCurrency??null,countries:e.countries??[],defaultCountry:e.defaultCountry??null,commerceEnabled:e.commerceEnabled??!0,cardPayments:e.cardPayments??!1,paymentMethods:e.paymentMethods??(e.cardPayments?["card"]:[]),paypalClientId:e.paypalClientId??null,paypalEnvironment:e.paypalEnvironment??null,squareApplicationId:e.squareApplicationId??null,squareLocationId:e.squareLocationId??null,squareEnvironment:e.squareEnvironment??null,ga4MeasurementId:e.ga4MeasurementId??null,googleAdsId:e.googleAdsId??null,googleAdsConversionLabel:(e.googleAdsId?e.googleAdsConversionLabel:null)??null,metaPixelId:e.metaPixelId??null,mapsApiKey:e.mapsApiKey??null,mapsMapId:e.mapsMapId??null,socialLinks:et(e.socialLinks)}},An)));var yo={name:de,legalName:null,foundedYear:null,faviconUrl:null,currencies:[{code:"USD",symbol:"$",decimalPlaces:2,isDefault:!0}],defaultCurrency:"USD",countries:[{code:"US",name:"United States",currency:"USD",url:"",isDefault:!0,chargeTax:!1,taxDisplay:"none",taxName:"",taxRate:null,postalLabel:"Zip Code"}],defaultCountry:"US",commerceEnabled:!0,cardPayments:!0,paymentMethods:["card"],paypalClientId:null,paypalEnvironment:null,squareApplicationId:null,squareLocationId:null,squareEnvironment:null,ga4MeasurementId:null,googleAdsId:null,googleAdsConversionLabel:null,metaPixelId:null,mapsApiKey:null,mapsMapId:null,socialLinks:Re};import{useEffect as we,useRef as _t,useState as Te}from"react";var ye=new Map,Rn=64;async function Mn(e){if(!Je())return null;try{let t=await fetch(`${tt()}/logo-analysis.json?url=${encodeURIComponent(e)}`);if(!t.ok)return null;let n=await t.json();if(!n||typeof n!="object")return null;let{reversed:r,inkIsDark:o}=n;return typeof r!="string"?null:{reversed:r,inkIsDark:typeof o=="boolean"?o:null}}catch{return null}}function kt(e){let t=ye.get(e);if(t)return t;let n=Mn(e);if(ye.set(e,n),ye.size>Rn){let r=ye.keys().next();r.done||ye.delete(r.value)}return n}import{jsx as At,jsxs as Rt}from"react/jsx-runtime";var Dn={small:54,medium:66,large:84},On=44,Fn=202/22,Lo=16,Io=140,Un=.88,wo=16,$n="invert(1)";function qn({variant:e="header",scrolled:t=!0,src:n,reverse:r=!1,onLightSurface:o,reversedSrc:i,inkIsDark:s,size:u="medium",sizePx:c,wordmark:l,siteName:d=de,fitToContainer:f=!1,fitWordmarkToContainer:P=!1,fitFloorPx:w}){let h=l&&l.trim()?l.trim():d,[C,L]=Te(!1),N=_t(null),M=E=>{N.current=E};we(()=>{let E=N.current?.ownerDocument??document,F=()=>{L(E.documentElement.getAttribute("data-theme")==="light")};F();let G=new MutationObserver(F);return G.observe(E.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>G.disconnect()},[]);let x=n&&n.trim()?n.trim():null,I=!!x&&nt(x),S=o??(C&&t),H=r&&I&&x&&i!=null?{reversed:i,inkIsDark:s??null}:null,W=H!==null,[Q,b]=Te(null);we(()=>{if(!r||!x||!I||W){b(null);return}let E=!1;return b(null),kt(x).then(F=>{E||b(F)}),()=>{E=!0}},[r,x,I,W]);let v=H??Q,m=!!v&&v.inkIsDark!==null&&(S?!v.inkIsDark:v.inkIsDark),K=r&&!!x&&!I&&!S,j=m&&v?v.reversed:x,z=j?[j]:[],[R,J]=Te(0);we(()=>{J(0)},[x,m]);let Z=e==="footer"?On:Dn[u],D=c&&c>0?c:Z,Ce=Math.round(D*Fn),O=R<z.length?z[R]:null,[xe,ee]=Te(j),ae=O!==null&&O===xe,U=_t(null);we(()=>{let E=U.current;if(!E||!E.complete)return;if(E.naturalWidth>0||E.naturalHeight>0){ee(O);return}let F=!1;return E.decode().then(()=>!F&&ee(O),()=>!F&&J(G=>G+1)),()=>{F=!0}},[O]);let V=f||P,le=`calc(100cqi / ${((h.length+1)*Un).toFixed(2)})`,te=V&&w&&w>0?Math.min(w,D):null,Se=V?te===null?`min(${D}px, ${le})`:`clamp(${te}px, ${le}, ${D}px)`:`${D}px`;return Rt("span",{ref:M,className:"inline-flex items-center",children:[!ae&&Rt("span",{className:`font-display font-bold tracking-[0.18em] ${te===null?"whitespace-nowrap":"whitespace-normal"}`,style:{fontSize:Se,lineHeight:1},"aria-label":h,children:[h,At("span",{className:"text-accent",children:"."})]}),O&&At("img",{ref:U,src:O,alt:h,width:Ce,height:D,className:"shrink-0 object-contain",style:{...ae?{height:`${D}px`,width:"auto",...f?{maxWidth:"100cqi"}:{}}:{display:"none"},...K?{filter:$n}:{}},onLoad:()=>ee(O),onError:()=>J(E=>E+1)},O)]})}import{Children as Kn,isValidElement as Wn,useEffect as Dt,useId as Bn,useLayoutEffect as zn,useRef as Y,useState as Ot}from"react";var Ne=(e,t)=>!!e[t]&&!e[t].disabled;function He(e,t,n){let r=e.length;for(let o=1;o<=r;o++){let i=((t+n*o)%r+r)%r;if(Ne(e,i))return i}return t}function Ke(e,t){return He(e,t===1?-1:e.length,t)}function We(e,t){return Ne(e,t)?t:Math.max(Ke(e,1),0)}function Mt(e,t,n){let{open:r,focus:o}=e,i=s=>({...e,...s});if(t.length===1&&/\S/.test(t)){let s=e.typed+t.toLowerCase(),u=n.findIndex((c,l)=>Ne(n,l)&&c.label.toLowerCase().startsWith(s));return{state:i({open:!0,typed:s,focus:u>=0?u:o}),handled:!0}}if(!r)return t==="ArrowDown"||t==="ArrowUp"||t==="Enter"||t===" "?{state:i({open:!0,typed:""}),handled:!0}:{state:e,handled:!1};switch(t){case"ArrowDown":return{state:i({focus:He(n,o,1)}),handled:!0};case"ArrowUp":return{state:i({focus:He(n,o,-1)}),handled:!0};case"Home":return{state:i({focus:Ke(n,1)}),handled:!0};case"End":return{state:i({focus:Ke(n,-1)}),handled:!0};case"Enter":case" ":return Ne(n,o)?{state:i({open:!1,typed:""}),commit:o,refocus:!0,handled:!0}:{state:e,handled:!0};case"Escape":return{state:i({open:!1,typed:""}),refocus:!0,handled:!0};case"Tab":return{state:i({open:!1,typed:""}),handled:!1};default:return{state:e,handled:!1}}}import{Fragment as Qn,jsx as B,jsxs as Ft}from"react/jsx-runtime";function Vn({items:e,value:t,onPick:n,open:r,onOpen:o,onClose:i}){let[s,u]=Ot(!1),c=r!==void 0,l=c?r:s,[d,f]=Ot(0),P=Y({text:"",timer:0}),w=Y(null),h=Y(null),C=Y(null),L=Bn(),N=Y(null),M=e.findIndex(b=>b.value===t),x=b=>{b!==l&&(c||u(b),b?o?.():i?.())},I=b=>{let v=e[b];!v||v.disabled||(n(v.value),x(!1),h.current?.focus())},S=b=>{let v={open:l,focus:l?d:We(e,M),typed:P.current.text},m=Mt(v,b,e);return!m.handled&&m.state.open===l?!1:(m.state.typed!==v.typed&&(P.current.text=m.state.typed,window.clearTimeout(P.current.timer),P.current.timer=window.setTimeout(()=>{P.current.text=""},500)),f(m.state.focus),m.commit!==void 0?I(m.commit):x(m.state.open),m.refocus&&h.current?.focus(),m.handled)},H=Y(S);H.current=S;let W=Y(()=>x(!1));W.current=()=>x(!1);let Q=b=>{l||(N.current=b.nativeEvent,H.current(b.key)&&b.preventDefault())};return Dt(()=>{if(!l)return;let b=m=>{w.current?.contains(m.target)||W.current()},v=m=>{m!==N.current&&H.current(m.key)&&m.preventDefault()};return document.addEventListener("mousedown",b),document.addEventListener("keydown",v),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",v)}},[l]),Dt(()=>{l&&(P.current.text||f(We(e,M)))},[l]),zn(()=>{if(!l||!C.current)return;C.current.children.item(d)?.scrollIntoView({block:"nearest"})},[d,l]),{open:l,toggle:()=>x(!l),close:()=>x(!1),focusIdx:d,setFocusIdx:f,pick:b=>I(e.findIndex(v=>v.value===b)),wrapRef:w,triggerRef:h,listRef:C,listId:L,onTriggerKeyDown:Q,activeId:l?`${L}-${d}`:void 0}}var Gn={select:{list:"absolute left-0 top-full z-50 mt-1 max-h-[280px] w-max min-w-full overflow-y-auto border-2 border-accent bg-bg shadow-xl",item:(e,t,n)=>["px-3 py-2.5 font-mono text-[13px] font-semibold uppercase tracking-[0.1em] transition-colors whitespace-nowrap",n?"cursor-not-allowed opacity-40":"cursor-pointer",e&&!n?"bg-accent text-bg":"bg-bg text-fg"].join(" ")},cell:{list:"absolute left-0 top-full z-50 mt-1 max-h-[320px] w-max min-w-full overflow-y-auto border-2 border-accent bg-bg shadow-xl",item:e=>["cursor-pointer whitespace-nowrap px-6 py-3 font-mono text-[length:var(--size-label,13px)] font-semibold uppercase tracking-[0.1em] transition-colors",e?"bg-accent text-bg":"bg-bg text-fg"].join(" "),pickerMarker:!0},hairline:{list:"absolute left-0 top-full z-50 max-h-[320px] w-full overflow-y-auto border border-line bg-bg shadow-[0_6px_20px_rgba(0,0,0,0.10)]",item:(e,t)=>["flex cursor-pointer items-center justify-between gap-4 border-b border-line px-4 py-3 text-left text-[length:var(--size-body,14px)] transition-colors last:border-b-0",t?"border-fg font-medium text-fg":e?"border-fg text-fg":"text-fg-dim"].join(" "),pickerMarker:!0},region:{list:"absolute right-0 top-full z-[200] mt-2 flex min-w-[240px] flex-col border border-line bg-surface text-fg",item:(e,t,n,r)=>["flex w-full cursor-pointer items-center gap-3 px-3.5 py-3 text-left transition-colors","font-mono text-[13px] uppercase tracking-[0.18em]",e?"bg-surface-2 text-fg":"",r?"":"border-b border-line",t?"text-accent":""].join(" "),itemStyle:e=>e?void 0:{color:"color-mix(in oklab, currentColor 80%, transparent)"}}};function Xn({id:e,tone:t,items:n,value:r,focusIdx:o,onFocus:i,onPick:s,listRef:u,ariaLabel:c}){let l=Gn[t];return B("ul",{ref:u,id:e,role:"listbox","aria-label":c,...l.pickerMarker?{"data-picker-menu":""}:{},className:l.list,children:n.map((d,f)=>{let P=d.value===r;return B("li",{id:`${e}-${f}`,role:"option","aria-selected":P,"aria-disabled":d.disabled||void 0,onMouseEnter:()=>!d.disabled&&i(f),onMouseDown:w=>{w.preventDefault(),d.disabled||s(d.value)},className:l.item(f===o,P&&d.value!=="",!!d.disabled,f===n.length-1),style:l.itemStyle?.(P),children:d.meta===void 0?d.label:Ft(Qn,{children:[B("span",{className:"flex-1 whitespace-nowrap",children:d.label}),B("span",{className:"ml-auto text-[12px] opacity-50",children:d.meta})]})},`${d.value}_${f}`)})})}function Yn({value:e,onChange:t,disabled:n,children:r,className:o,style:i,name:s,id:u,"aria-label":c}){let l=Kn.toArray(r).flatMap(h=>{if(!Wn(h))return[];if(h.type!=="option")return[];let L=h.props,N=L.value!==void 0?String(L.value):"",M=L.children,x=typeof M=="string"||typeof M=="number"?String(M):N;return[{value:N,label:x,disabled:!!L.disabled}]}),d=e??"",f=Vn({items:l,value:d,onPick:h=>t?.({target:{value:h}})}),w=l.find(h=>h.value===d)?.label??l[0]?.label??"";return Ft("div",{ref:f.wrapRef,className:"relative",children:[s&&B("input",{type:"hidden",name:s,value:d}),B("button",{ref:h=>{f.triggerRef.current=h},type:"button",disabled:n,"aria-haspopup":"listbox","aria-expanded":f.open,"aria-controls":f.open?f.listId:void 0,"aria-activedescendant":f.activeId,"aria-label":c,id:u,onClick:()=>!n&&f.toggle(),onKeyDown:h=>!n&&f.onTriggerKeyDown(h),className:`block w-full ${o??""}`,style:i,children:B("span",{className:"block w-full truncate text-left",children:w})}),f.open&&B(Xn,{id:f.listId,tone:"select",items:l,value:d,focusIdx:f.focusIdx,onFocus:f.setFocusIdx,onPick:f.pick,listRef:f.listRef})]})}var Fo="#c9a461",Ut=[{f:"black",label:"Black",hex:"#171717"},{f:"silver",label:"Silver",hex:"#cccccc"},{f:"bronze",label:"Bronze",hex:"#8a6438"},{f:"graphite",label:"Graphite",hex:"#3a3c3f"},{f:"red",label:"Candy Red",hex:"#7a0f14"}],Uo={name:"",color:"var(--fg)",family:"silver",src:""};function jn(e,t){let n=r=>{let o=Ut.findIndex(i=>i.f===r);return o===-1?Ut.length:o};return n(e)-n(t)||e.localeCompare(t)}function $o(e){let t=new Set;for(let n of e)for(let r of n.finishes??[])r?.family&&t.add(r.family);return[...t].sort(jn)}import{jsx as be,jsxs as ke}from"react/jsx-runtime";var Jn="font-mono text-[length:var(--size-label,12px)]",Zn="font-semibold uppercase tracking-[0.22em] text-fg";function $t(e){return`${e??Jn} ${Zn}`}function qt(){return be("span",{className:"text-accent",children:" *"})}function er({children:e,required:t,labelFace:n}){return ke("span",{className:$t(n),children:[e,t?be(qt,{}):null]})}function tr({label:e,required:t,hint:n,separate:r,htmlFor:o,labelFace:i,className:s,children:u}){let c=s?`flex flex-col gap-2 ${s}`:"flex flex-col gap-2",l=n?be("span",{className:"font-mono text-[11px] uppercase tracking-[0.22em] text-fg-dim",children:n}):null;return r||n?ke("div",{className:c,children:[ke("label",{htmlFor:o,className:$t(i),children:[e,t?be(qt,{}):null]}),u,l]}):ke("label",{htmlFor:o,className:c,children:[be(er,{required:t,labelFace:i,children:e}),u]})}import{jsx as he,jsxs as rr}from"react/jsx-runtime";function nr({spokes:e,mesh:t=!1,className:n}){let s=c=>Math.round(c*1e3)/1e3,u=[];for(let c=0;c<e;c++){let l=c/e*Math.PI*2-Math.PI/2;if(u.push({x1:s(100+Math.cos(l)*22),y1:s(100+Math.sin(l)*22),x2:s(100+Math.cos(l)*86),y2:s(100+Math.sin(l)*86),main:!0}),t){let d=l+Math.PI/e;u.push({x1:s(100+Math.cos(d)*22*1.4),y1:s(100+Math.sin(d)*22*1.4),x2:s(100+Math.cos(d)*78),y2:s(100+Math.sin(d)*78),main:!1})}}return rr("svg",{viewBox:"0 0 200 200",fill:"none",stroke:"currentColor",className:n??"block h-[70%] w-[70%] transition-transform duration-700 [transition-timing-function:cubic-bezier(.2,.6,.2,1)]",children:[he("circle",{cx:100,cy:100,r:92,strokeWidth:2}),he("circle",{cx:100,cy:100,r:84,strokeWidth:1,opacity:.4}),he("circle",{cx:100,cy:100,r:22,strokeWidth:2}),he("circle",{cx:100,cy:100,r:6,fill:"currentColor"}),u.map((c,l)=>he("line",{x1:c.x1,y1:c.y1,x2:c.x2,y2:c.y2,stroke:"currentColor",strokeWidth:c.main?6:3,strokeLinecap:"round",opacity:c.main?1:.5},l))]})}import{useState as or}from"react";import{jsx as se,jsxs as Be}from"react/jsx-runtime";function ir({customerEmail:e}){let{coupon:t,applyCoupon:n,removeCoupon:r,couponBusy:o}=It(),[i,s]=or("");async function u(){o||!i.trim()||(await n(i,e),s(""))}return Be("div",{className:"flex flex-col gap-2",children:[t===null?Be("div",{className:"flex border border-line",children:[se("input",{type:"text",value:i,onChange:c=>s(c.target.value),onKeyDown:c=>{c.key==="Enter"&&(c.preventDefault(),u())},placeholder:"Coupon code","aria-label":"Coupon code",className:"flex-1 bg-transparent px-3.5 py-3.5 font-mono text-[11px] uppercase tracking-[0.18em] text-fg outline-none placeholder:text-fg-dim"}),se("button",{type:"button",onClick:()=>{u()},disabled:o,className:"border-l border-line px-4 font-mono text-[10px] uppercase tracking-[0.26em] text-btn transition-colors hover:bg-btn hover:text-btn-ink disabled:cursor-wait disabled:opacity-60",children:o?"\u2026":"Apply"})]}):Be("div",{className:["flex items-center justify-between gap-3 border px-3.5 py-3",t.valid?"border-accent":"border-line"].join(" "),style:t.valid?{background:"color-mix(in oklab, var(--accent) 8%, transparent)"}:void 0,children:[se("span",{className:["font-mono text-[11px] uppercase tracking-[0.22em]",t.valid?"text-accent":t.deferred?"text-fg":"text-fg-dim line-through"].join(" "),children:t.code}),se("button",{type:"button",onClick:r,"aria-label":`Remove coupon ${t.code}`,className:"font-mono text-[12px] text-fg-dim transition-colors hover:text-fg",children:"\u2715"})]}),t?.deferred?se("p",{className:"font-mono text-[10px] uppercase tracking-[0.18em] text-fg-dim",children:pt}):t&&!t.valid&&t.message&&se("p",{className:"font-mono text-[10px] uppercase tracking-[0.18em] text-alert",children:t.message})]})}function Qo(){let e=typeof crypto<"u"?crypto:void 0;if(typeof e?.randomUUID=="function")return e.randomUUID();let t=new Uint8Array(16);if(typeof e?.getRandomValues=="function")e.getRandomValues(t);else for(let r=0;r<t.length;r++)t[r]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=Array.from(t,r=>r.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}export{xr as a,Sr as b,vr as c,it as d,Me as e,sr as f,ar as g,lr as h,ur as i,Xt as j,Yt as k,cr as l,dr as m,De as n,Oe as o,fe as p,Pe as q,rn as r,Ue as s,Ir as t,wr as u,sn as v,Tr as w,Nr as x,an as y,kr as z,un as A,_r as B,Ar as C,yt as D,Ur as E,$r as F,qr as G,yr as H,dt as I,Le as J,qe as K,jr as L,It as M,po as N,An as O,yo as P,Dn as Q,On as R,Lo as S,Io as T,wo as U,qn as V,Vn as W,Xn as X,Yn as Y,Fo as Z,Ut as _,Uo as $,jn as aa,$o as ba,er as ca,tr as da,nr as ea,ir as fa,Qo as ga};
|