@shopify/hydrogen 2024.7.2 → 2024.7.4

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.
@@ -1,20 +1,20 @@
1
- import { createStorefrontClient, SHOPIFY_STOREFRONT_ID_HEADER, getShopifyCookies, SHOPIFY_Y, SHOPIFY_STOREFRONT_Y_HEADER, SHOPIFY_S, SHOPIFY_STOREFRONT_S_HEADER, flattenConnection, ShopPayButton, useLoadScript, RichText, useShopifyCookies, sendShopifyAnalytics, AnalyticsEventName, AnalyticsPageType, parseGid, getClientBrowserParameters } from '@shopify/hydrogen-react';
1
+ import { useLoadScript, createStorefrontClient, SHOPIFY_STOREFRONT_ID_HEADER, getShopifyCookies, SHOPIFY_Y, SHOPIFY_STOREFRONT_Y_HEADER, SHOPIFY_S, SHOPIFY_STOREFRONT_S_HEADER, flattenConnection, ShopPayButton, RichText, useShopifyCookies, sendShopifyAnalytics, AnalyticsEventName, AnalyticsPageType, parseGid, getClientBrowserParameters } from '@shopify/hydrogen-react';
2
2
  export { AnalyticsEventName, AnalyticsPageType, ExternalVideo, IMAGE_FRAGMENT, Image, MediaFile, ModelViewer, Money, ShopifySalesChannel, Video, customerAccountApiCustomScalars, flattenConnection, getClientBrowserParameters, getShopifyCookies, parseGid, parseMetafield, sendShopifyAnalytics, storefrontApiCustomScalars, useLoadScript, useMoney, useShopifyCookies } from '@shopify/hydrogen-react';
3
3
  import { lazy, createContext, forwardRef, useMemo, createElement, Suspense, Fragment, useRef, useEffect, useState, useContext } from 'react';
4
4
  import { useMatches, useLocation, useNavigation, Link, useNavigate, useFetcher, useFetchers } from '@remix-run/react';
5
5
  import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
6
6
  import { parse, stringify } from 'worktop/cookie';
7
- import ba from 'content-security-policy-builder';
7
+ import Dn from 'content-security-policy-builder';
8
8
 
9
- var Ee="public",Wr="private",je="no-store",Lt={maxAge:"max-age",staleWhileRevalidate:"stale-while-revalidate",sMaxAge:"s-maxage",staleIfError:"stale-if-error"};function fe(e){let t=[];return Object.keys(e).forEach(r=>{r==="mode"?t.push(e[r]):Lt[r]&&t.push(`${Lt[r]}=${e[r]}`);}),t.join(", ")}function Ke(){return {mode:je}}function ze(e){if(e?.mode&&e?.mode!==Ee&&e?.mode!==Wr)throw Error("'mode' must be either 'public' or 'private'")}function J(e){return ze(e),{mode:Ee,maxAge:1,staleWhileRevalidate:9,...e}}function Je(e){return ze(e),{mode:Ee,maxAge:3600,staleWhileRevalidate:82800,...e}}function ae(e){return ze(e),{mode:Ee,maxAge:1,staleWhileRevalidate:86399,...e}}function Ye(e){return e}function Y(e){return String(e).includes("__proto__")?JSON.parse(e,jr):JSON.parse(e)}function jr(e,t){if(e!=="__proto__")return t}function Oe(e,t){return e&&t?{...e,...t}:e||ae()}function Xe(e){return fe(Oe(e))}async function Kr(e,t){if(!e)return;let r=await e.match(t);if(!r){return}return r}async function zr(e,t,r,o){if(!e)return;let a=Oe(o),n=Xe(Oe(a,{maxAge:(a.maxAge||0)+(a.staleWhileRevalidate||0)})),i=Xe(Oe(a));r.headers.set("cache-control",n),r.headers.set("real-cache-control",i),r.headers.set("cache-put-date",String(Date.now())),await e.put(t,r);}async function Jr(e,t){e&&await e.delete(t);}function Yr(e,t){let r=e.headers.get("real-cache-control"),o=0;if(r){let n=r.match(/max-age=(\d*)/);n&&n.length>1&&(o=parseFloat(n[1]));}return [(Date.now()-Number(t))/1e3,o]}function Xr(e,t){let r=t.headers.get("cache-put-date");if(!r)return !1;let[o,a]=Yr(t,r),n=o>a;return n}var De={get:Kr,set:zr,delete:Jr,generateDefaultCacheControlHeader:Xe,isStale:Xr};function me(e){return `https://shopify.dev/?${e}`}function Zr(e){return e||ae()}async function _t(e,t){if(!e)return;let r=me(t),o=new Request(r),a=await De.get(e,o);if(!a)return;let n=await a.text();try{return [Y(n),a]}catch{return [n,a]}}async function Ut(e,t,r,o){if(!e)return;let a=me(t),n=new Request(a),i=new Response(JSON.stringify(r));await De.set(e,n,i,Zr(o));}function Vt(e,t){return De.isStale(new Request(me(e)),t)}function Nt(e){let t=Array.isArray(e)?e:[e],r="";for(let o of t)o!=null&&(typeof o=="object"?r+=JSON.stringify(o):r+=o.toString());return encodeURIComponent(r)}var Ze=new Set;async function xe(e,t,{strategy:r=J(),cacheInstance:o,shouldCacheResult:a=()=>!0,waitUntil:n,debugInfo:i}){let c=Nt([...typeof e=="string"?[e]:e]),y=f=>{({displayName:f.displayName,url:f.response?.url,responseInit:{status:f.response?.status||0,statusText:f.response?.statusText||"",headers:Array.from(f.response?.headers.entries()||[])}});},d=void 0;if(!o||!r||r.mode===je){let f=await t({addDebugData:y});return f}let p=f=>Ut(o,c,{value:f,debugInfo:void 0},r),h=await _t(o,c);if(h&&typeof h[0]!="string"){let[{value:f,debugInfo:T},I]=h;let _=Vt(c,I)?"STALE":"HIT";if(!Ze.has(c)&&_==="STALE"){Ze.add(c);let U=Promise.resolve().then(async()=>{let re=Date.now();try{let V=await t({addDebugData:y});a(V)&&(await p(V),d?.({result:V,cacheStatus:"PUT",overrideStartTime:re}));}catch(V){V.message&&(V.message="SWR in sub-request failed: "+V.message),console.error(V);}finally{Ze.delete(c);}});n?.(U);}return f}let g=await t({addDebugData:y});if(a(g)){let f=Promise.resolve().then(async()=>{await p(g);});n?.(f);}return g}function Mt(e,t){return [e,{status:t.status,statusText:t.statusText,headers:Array.from(t.headers.entries())}]}function Ft([e,t]){return [e,new Response(e,t)]}var qt=(e,t)=>!e?.errors&&t.status<400;async function $t(e,t,{cacheInstance:r,cache:o,cacheKey:a=[e,t],shouldCacheResponse:n=()=>!0,waitUntil:i,returnType:u="json",debugInfo:c}={}){return !o&&(!t.method||t.method==="GET")&&(o=J()),xe(a,async()=>{let s=await fetch(e,t),l;try{l=await s[u]();}catch{try{l=await s.text();}catch{return Mt("",s)}}return Mt(l,s)},{cacheInstance:r,waitUntil:i,strategy:o??null,debugInfo:c,shouldCacheResult:s=>n(...Ft(s))}).then(Ft)}var et="Custom-Storefront-Request-Group-ID",tt="X-Shopify-Storefront-Access-Token",rt="X-SDK-Variant",ot="X-SDK-Variant-Source",at="X-SDK-Version";function Ht(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():`weak-${Math.random().toString(16).substring(2)}`}var Qt=new Set,Bt=e=>{Qt.has(e)||(console.warn(e),Qt.add(e));},Gt=new Set,nt=e=>{Gt.has(e)||(console.error(new Error(e)),Gt.add(e));};var he="2024.7.2";function ne(e){return e.replace(/\s*#.*$/gm,"").replace(/\s+/gm," ").trim()}var eo=/(^|}\s)query[\s({]/im,to=/(^|}\s)mutation[\s({]/im;function ke(e,t){if(!eo.test(e))throw new Error(`[h2:error:${t}] Can only execute queries`)}function Le(e,t){if(!to.test(e))throw new Error(`[h2:error:${t}] Can only execute mutations`)}var X=class extends Error{locations;path;extensions;constructor(t,r={}){let a=(r.clientOperation?`[h2:error:${r.clientOperation}] `:"")+t+(r.requestId?` - Request ID: ${r.requestId}`:"");super(a),this.name="GraphQLError",this.extensions=r.extensions,this.locations=r.locations,this.path=r.path,this.stack=r.stack||void 0;try{this.cause=JSON.stringify({...typeof r.cause=="object"?r.cause:{},requestId:r.requestId});}catch{r.cause&&(this.cause=r.cause);}}get[Symbol.toStringTag](){return this.name}toString(){let t=`${this.name}: ${this.message}`;if(this.path)try{t+=` | path: ${JSON.stringify(this.path)}`;}catch{}if(this.extensions)try{t+=` | extensions: ${JSON.stringify(this.extensions)}`;}catch{}return t+=`
9
+ var Oe="public",Zr="private",je="no-store",Mt={maxAge:"max-age",staleWhileRevalidate:"stale-while-revalidate",sMaxAge:"s-maxage",staleIfError:"stale-if-error"};function me(e){let t=[];return Object.keys(e).forEach(r=>{r==="mode"?t.push(e[r]):Mt[r]&&t.push(`${Mt[r]}=${e[r]}`);}),t.join(", ")}function Ke(){return {mode:je}}function ze(e){if(e?.mode&&e?.mode!==Oe&&e?.mode!==Zr)throw Error("'mode' must be either 'public' or 'private'")}function Y(e){return ze(e),{mode:Oe,maxAge:1,staleWhileRevalidate:9,...e}}function Je(e){return ze(e),{mode:Oe,maxAge:3600,staleWhileRevalidate:82800,...e}}function ae(e){return ze(e),{mode:Oe,maxAge:1,staleWhileRevalidate:86399,...e}}function Ye(e){return e}function X(e){return String(e).includes("__proto__")?JSON.parse(e,eo):JSON.parse(e)}function eo(e,t){if(e!=="__proto__")return t}function xe(e,t){return e&&t?{...e,...t}:e||ae()}function Xe(e){return me(xe(e))}async function to(e,t){if(!e)return;let r=await e.match(t);if(!r){return}return r}async function ro(e,t,r,o){if(!e)return;let n=xe(o),a=Xe(xe(n,{maxAge:(n.maxAge||0)+(n.staleWhileRevalidate||0)})),s=Xe(xe(n));r.headers.set("cache-control",a),r.headers.set("real-cache-control",s),r.headers.set("cache-put-date",String(Date.now())),await e.put(t,r);}async function oo(e,t){e&&await e.delete(t);}function no(e,t){let r=e.headers.get("real-cache-control"),o=0;if(r){let a=r.match(/max-age=(\d*)/);a&&a.length>1&&(o=parseFloat(a[1]));}return [(Date.now()-Number(t))/1e3,o]}function ao(e,t){let r=t.headers.get("cache-put-date");if(!r)return !1;let[o,n]=no(t,r),a=o>n;return a}var De={get:to,set:ro,delete:oo,generateDefaultCacheControlHeader:Xe,isStale:ao};function ge(e){return `https://shopify.dev/?${e}`}function so(e){return e||ae()}async function Ht(e,t){if(!e)return;let r=ge(t),o=new Request(r),n=await De.get(e,o);if(!n)return;let a=await n.text();try{return [X(a),n]}catch{return [a,n]}}async function Ft(e,t,r,o){if(!e)return;let n=ge(t),a=new Request(n),s=new Response(JSON.stringify(r));await De.set(e,a,s,so(o));}function qt(e,t){return De.isStale(new Request(ge(e)),t)}function $t(e){let t=Array.isArray(e)?e:[e],r="";for(let o of t)o!=null&&(typeof o=="object"?r+=JSON.stringify(o):r+=o.toString());return encodeURIComponent(r)}var Ze=new Set;async function Le(e,t,{strategy:r=Y(),cacheInstance:o,shouldCacheResult:n=()=>!0,waitUntil:a,debugInfo:s}){let i=$t([...typeof e=="string"?[e]:e]),l=f=>{({displayName:f.displayName,url:f.response?.url,responseInit:{status:f.response?.status||0,statusText:f.response?.statusText||"",headers:Array.from(f.response?.headers.entries()||[])}});},p=void 0;if(!o||!r||r.mode===je){let f=await t({addDebugData:l});return f}let y=f=>Ft(o,i,{value:f,debugInfo:void 0},r),g=await Ht(o,i);if(g&&typeof g[0]!="string"){let[{value:f,debugInfo:v},I]=g;let k=qt(i,I)?"STALE":"HIT";if(!Ze.has(i)&&k==="STALE"){Ze.add(i);let _=Promise.resolve().then(async()=>{let oe=Date.now();try{let V=await t({addDebugData:l});n(V)&&(await y(V),p?.({result:V,cacheStatus:"PUT",overrideStartTime:oe}));}catch(V){V.message&&(V.message="SWR in sub-request failed: "+V.message),console.error(V);}finally{Ze.delete(i);}});a?.(_);}return f}let h=await t({addDebugData:l});if(n(h)){let f=Promise.resolve().then(async()=>{await y(h);});a?.(f);}return h}function Bt(e,t){return [e,{status:t.status,statusText:t.statusText,headers:Array.from(t.headers.entries())}]}function Qt([e,t]){return [e,new Response(e,t)]}var Gt=(e,t)=>!e?.errors&&t.status<400;async function Wt(e,t,{cacheInstance:r,cache:o,cacheKey:n=[e,t],shouldCacheResponse:a=()=>!0,waitUntil:s,returnType:u="json",debugInfo:i}={}){return !o&&(!t.method||t.method==="GET")&&(o=Y()),Le(n,async()=>{let c=await fetch(e,t),d;try{d=await c[u]();}catch{try{d=await c.text();}catch{return Bt("",c)}}return Bt(d,c)},{cacheInstance:r,waitUntil:s,strategy:o??null,debugInfo:i,shouldCacheResult:c=>a(...Qt(c))}).then(Qt)}var et="Custom-Storefront-Request-Group-ID",tt="X-Shopify-Storefront-Access-Token",rt="X-SDK-Variant",ot="X-SDK-Variant-Source",nt="X-SDK-Version";function jt(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():`weak-${Math.random().toString(16).substring(2)}`}var Kt=new Set,Jt=e=>{Kt.has(e)||(console.warn(e),Kt.add(e));},zt=new Set,at=e=>{zt.has(e)||(console.error(new Error(e)),zt.add(e));};var he="2024.7.4";function se(e){return e.replace(/\s*#.*$/gm,"").replace(/\s+/gm," ").trim()}var io=/(^|}\s)query[\s({]/im,co=/(^|}\s)mutation[\s({]/im;function Ue(e,t){if(!io.test(e))throw new Error(`[h2:error:${t}] Can only execute queries`)}function ke(e,t){if(!co.test(e))throw new Error(`[h2:error:${t}] Can only execute mutations`)}var Z=class extends Error{locations;path;extensions;constructor(t,r={}){let n=(r.clientOperation?`[h2:error:${r.clientOperation}] `:"")+t+(r.requestId?` - Request ID: ${r.requestId}`:"");super(n),this.name="GraphQLError",this.extensions=r.extensions,this.locations=r.locations,this.path=r.path,this.stack=r.stack||void 0;try{this.cause=JSON.stringify({...typeof r.cause=="object"?r.cause:{},requestId:r.requestId});}catch{r.cause&&(this.cause=r.cause);}}get[Symbol.toStringTag](){return this.name}toString(){let t=`${this.name}: ${this.message}`;if(this.path)try{t+=` | path: ${JSON.stringify(this.path)}`;}catch{}if(this.extensions)try{t+=` | extensions: ${JSON.stringify(this.extensions)}`;}catch{}return t+=`
10
10
  `,this.stack&&(t+=`${this.stack.slice(this.stack.indexOf(`
11
11
  `)+1)}
12
- `),t}toJSON(){return {name:"Error",message:""}}};function ge({url:e,response:t,errors:r,type:o,query:a,queryVariables:n,ErrorConstructor:i=Error,client:u="storefront"}){let c=(typeof r=="string"?r:r?.map?.(l=>l.message).join(`
12
+ `),t}toJSON(){return {name:"Error",message:""}}};function Ce({url:e,response:t,errors:r,type:o,query:n,queryVariables:a,ErrorConstructor:s=Error,client:u="storefront"}){let i=(typeof r=="string"?r:r?.map?.(d=>d.message).join(`
13
13
  `))||`URL: ${e}
14
- API response error: ${t.status}`,s=new X(c,{query:a,queryVariables:n,cause:{errors:r},clientOperation:`${u}.${o}`,requestId:t.headers.get("x-request-id")});throw new i(s.message,{cause:s.cause})}function ie(e,t={}){let r=new Error,o=(a,n="Error")=>{let i=(r.stack??"").split(`
14
+ API response error: ${t.status}`,c=new Z(i,{query:n,queryVariables:a,cause:{errors:r},clientOperation:`${u}.${o}`,requestId:t.headers.get("x-request-id")});throw new s(c.message,{cause:c.cause})}function ie(e,t={}){let r=new Error,o=(n,a="Error")=>{let s=(r.stack??"").split(`
15
15
  `).slice(3+(t.stackOffset??0)).join(`
16
- `).replace(/ at loader(\d+) \(/,(u,c)=>u.replace(c,""));return `${n}: ${a}
17
- `+i};return e.then(a=>{if(a?.errors&&Array.isArray(a.errors)){let n=typeof t.logErrors=="function"?t.logErrors:()=>t.logErrors??!1;a.errors.forEach(i=>{i&&(i.stack=o(i.message,i.name),n(i)&&console.error(i));});}return a}).catch(a=>{throw a&&(a.stack=o(a.message,a.name)),a})}var $=void 0;var so={language:"EN",country:"US"};function si(e){let {storefrontHeaders:t,cache:r,waitUntil:o,i18n:a,storefrontId:n,logErrors:i=!0,...u}=e,{getPublicTokenHeaders:s,getPrivateTokenHeaders:l,getStorefrontApiUrl:y,getShopifyDomain:m}=createStorefrontClient(u),p=(u.privateStorefrontToken?l:s)({contentType:"json",buyerIp:t?.buyerIp||""});if(p[et]=t?.requestGroupId||Ht(),n&&(p[SHOPIFY_STOREFRONT_ID_HEADER]=n),(p["user-agent"]=`Hydrogen ${he}`),t&&t.cookie){let f=getShopifyCookies(t.cookie??"");f[SHOPIFY_Y]&&(p[SHOPIFY_STOREFRONT_Y_HEADER]=f[SHOPIFY_Y]),f[SHOPIFY_S]&&(p[SHOPIFY_STOREFRONT_S_HEADER]=f[SHOPIFY_S]);}let h=JSON.stringify({"content-type":p["content-type"],"user-agent":p["user-agent"],[rt]:p[rt],[ot]:p[ot],[at]:p[at],[tt]:p[tt]});async function g({query:f,mutation:T,variables:I,cache:_,headers:U=[],storefrontApiVersion:re,displayName:V,stackInfo:be}){let C=U instanceof Headers?Object.fromEntries(U.entries()):Array.isArray(U)?Object.fromEntries(U):U,P=f??T,A={...I};a&&(!I?.country&&/\$country/.test(P)&&(A.country=a.country),!I?.language&&/\$language/.test(P)&&(A.language=a.language));let v=y({storefrontApiVersion:re}),M=JSON.stringify({query:P,variables:A}),F={method:"POST",headers:{...p,...C},body:M},D=[v,F.method,h,F.body],[x,k]=await $t(v,F,{cacheInstance:T?void 0:r,cache:_||ae(),cacheKey:D,shouldCacheResponse:qt,waitUntil:o,debugInfo:{requestId:F.headers[et],displayName:V,url:v,stackInfo:be,graphql:M,purpose:t?.purpose}}),b={url:v,response:k,type:T?"mutation":"query",query:P,queryVariables:A,errors:void 0};if(!k.ok){let q;try{q=Y(x);}catch{q=[{message:x}];}ge({...b,errors:q});}let{data:W,errors:le}=x,oe=le?.map(({message:q,...ye})=>new X(q,{...ye,clientOperation:`storefront.${b.type}`,requestId:k.headers.get("x-request-id"),queryVariables:A,query:P}));return S(W,oe)}return {storefront:{query(f,T){f=ne(f),ke(f,"storefront.query");let I=Kt?.(f);return ie(g({...T,query:f,stackInfo:$?.(I)}),{stackOffset:I,logErrors:i})},mutate(f,T){f=ne(f),Le(f,"storefront.mutate");let I=Kt?.(f);return ie(g({...T,mutation:f,stackInfo:$?.(I)}),{stackOffset:I,logErrors:i})},cache:r,CacheNone:Ke,CacheLong:Je,CacheShort:J,CacheCustom:Ye,generateCacheControlHeader:fe,getPublicTokenHeaders:s,getPrivateTokenHeaders:l,getShopifyDomain:m,getApiUrl:y,i18n:a??so}}}var Kt=void 0;function S(e,t){return {...e,...t&&{errors:t}}}function _e(e,t){let r=e.headers?.get?.(t)??e.headers?.[t];return typeof r=="string"?r:null}function Z(e){return {requestId:e?_e(e,"request-id"):void 0,purpose:e?_e(e,"purpose"):void 0}}function co({cache:e,waitUntil:t,request:r}){return function(a,n,i){return xe(a,i,{strategy:n,cacheInstance:e,waitUntil:t,debugInfo:{...Z(r),stackInfo:$?.()}})}}var it=class{#e;constructor(){this.#e=new Map;}add(t){throw new Error("Method not implemented. Use `put` instead.")}addAll(t){throw new Error("Method not implemented. Use `put` instead.")}matchAll(t,r){throw new Error("Method not implemented. Use `match` instead.")}async put(t,r){if(t.method!=="GET")throw new TypeError("Cannot cache response to non-GET request.");if(r.status===206)throw new TypeError("Cannot cache response to a range request (206 Partial Content).");if(r.headers.get("vary")?.includes("*"))throw new TypeError("Cannot cache response with 'Vary: *' header.");this.#e.set(t.url,{body:new Uint8Array(await r.arrayBuffer()),status:r.status,headers:[...r.headers],timestamp:Date.now()});}async match(t){if(t.method!=="GET")return;let r=this.#e.get(t.url);if(!r)return;let{body:o,timestamp:a,...n}=r,i=new Headers(n.headers),u=i.get("cache-control")||i.get("real-cache-control")||"",c=parseInt(u.match(/max-age=(\d+)/)?.[1]||"0",10),s=parseInt(u.match(/stale-while-revalidate=(\d+)/)?.[1]||"0",10),l=(Date.now()-a)/1e3;if(l>c+s){this.#e.delete(t.url);return}let m=l>c;return i.set("cache",m?"STALE":"HIT"),i.set("date",new Date(a).toUTCString()),new Response(o,{status:n.status??200,headers:i})}async delete(t){return this.#e.has(t.url)?(this.#e.delete(t.url),!0):!1}keys(t){let r=[];for(let o of this.#e.keys())(!t||t.url===o)&&r.push(new Request(o));return Promise.resolve(r)}};function Ue(e){if(!e)return;let{pathname:t,search:r}=new URL(e),o=t+r,a=new URLSearchParams(r),n=a.get("return_to")||a.get("redirect");if(n){if(Jt(e,n))return n;console.warn(`Cross-domain redirects are not supported. Tried to redirect from ${o} to ${n}`);}}function Jt(e,t){try{return new URL(e).origin===new URL(t,e).origin}catch{return !1}}function st({requestUrl:e,defaultUrl:t,redirectUrl:r}){let o=e,a=zt(e,t),n=r?zt(e,r):a;return Jt(e,n.toString())?n.toString():(console.warn(`Cross-domain redirects are not supported. Tried to redirect from ${o} to ${n}. Default url ${a} is used instead.`),a.toString())}function zt(e,t){return uo(t)?new URL(t):new URL(t,new URL(e).origin)}function uo(e){try{return new URL(e),!0}catch{return !1}}async function po(e){let{storefront:t,request:r,noAdminRedirect:o,matchQueryParams:a,response:n=new Response("Not Found",{status:404})}=e,i=new URL(r.url),{pathname:u,searchParams:c}=i,s=c.has("_data");c.delete("redirect"),c.delete("return_to"),c.delete("_data");let l=(a?i.toString().replace(i.origin,""):u).toLowerCase();if(i.pathname==="/admin"&&!o)return ut(`${t.getShopifyDomain()}/admin`,s,c,a);try{let{urlRedirects:y}=await t.query(lo,{variables:{query:"path:"+l.replace(/\/+$/,"")}}),m=y?.edges?.[0]?.node?.target;if(m)return ut(m,s,c,a);let d=Ue(r.url);if(d)return ut(d,s,c,a)}catch(y){console.error(`Failed to fetch redirects from Storefront API for route ${l}`,y);}return n}var ct="https://example.com";function ut(e,t,r,o){let a=new URL(e,ct);if(!o)for(let[n,i]of r)a.searchParams.append(n,i);return t?new Response(null,{status:200,headers:{"X-Remix-Redirect":a.toString().replace(ct,""),"X-Remix-Status":"301"}}):new Response(null,{status:301,headers:{location:a.toString().replace(ct,"")}})}var lo=`#graphql
16
+ `).replace(/ at loader(\d+) \(/,(u,i)=>u.replace(i,""));return `${a}: ${n}
17
+ `+s};return e.then(n=>{if(n?.errors&&Array.isArray(n.errors)){let a=typeof t.logErrors=="function"?t.logErrors:()=>t.logErrors??!1;n.errors.forEach(s=>{s&&(s.stack=o(s.message,s.name),a(s)&&console.error(s));});}return n}).catch(n=>{throw n&&(n.stack=o(n.message,n.name)),n})}var q=void 0;var mo={language:"EN",country:"US"};function er(e){let {storefrontHeaders:t,cache:r,waitUntil:o,i18n:n,storefrontId:a,logErrors:s=!0,...u}=e,{getPublicTokenHeaders:c,getPrivateTokenHeaders:d,getStorefrontApiUrl:l,getShopifyDomain:m}=createStorefrontClient(u),y=(u.privateStorefrontToken?d:c)({contentType:"json",buyerIp:t?.buyerIp||""});if(y[et]=t?.requestGroupId||jt(),a&&(y[SHOPIFY_STOREFRONT_ID_HEADER]=a),(y["user-agent"]=`Hydrogen ${he}`),t&&t.cookie){let f=getShopifyCookies(t.cookie??"");f[SHOPIFY_Y]&&(y[SHOPIFY_STOREFRONT_Y_HEADER]=f[SHOPIFY_Y]),f[SHOPIFY_S]&&(y[SHOPIFY_STOREFRONT_S_HEADER]=f[SHOPIFY_S]);}let g=JSON.stringify({"content-type":y["content-type"],"user-agent":y["user-agent"],[rt]:y[rt],[ot]:y[ot],[nt]:y[nt],[tt]:y[tt]});async function h({query:f,mutation:v,variables:I,cache:k,headers:_=[],storefrontApiVersion:oe,displayName:V,stackInfo:we}){let C=_ instanceof Headers?Object.fromEntries(_.entries()):Array.isArray(_)?Object.fromEntries(_):_,S=f??v,A={...I};n&&(!I?.country&&/\$country/.test(S)&&(A.country=n.country),!I?.language&&/\$language/.test(S)&&(A.language=n.language));let T=l({storefrontApiVersion:oe}),M=JSON.stringify({query:S,variables:A}),H={method:"POST",headers:{...y,...C},body:M},x=[T,H.method,g,H.body],[D,L]=await Wt(T,H,{cacheInstance:v?void 0:r,cache:k||ae(),cacheKey:x,shouldCacheResponse:Gt,waitUntil:o,debugInfo:{requestId:H.headers[et],displayName:V,url:T,stackInfo:we,graphql:M,purpose:t?.purpose}}),E={url:T,response:L,type:v?"mutation":"query",query:S,queryVariables:A,errors:void 0};if(!L.ok){let F;try{F=X(D);}catch{F=[{message:D}];}Ce({...E,errors:F});}let{data:j,errors:ye}=D,ne=ye?.map(({message:F,...fe})=>new Z(F,{...fe,clientOperation:`storefront.${E.type}`,requestId:L.headers.get("x-request-id"),queryVariables:A,query:S}));return P(j,ne)}return {storefront:{query(f,v){f=se(f),Ue(f,"storefront.query");let I=Zt?.(f);return ie(h({...v,query:f,stackInfo:q?.(I)}),{stackOffset:I,logErrors:s})},mutate(f,v){f=se(f),ke(f,"storefront.mutate");let I=Zt?.(f);return ie(h({...v,mutation:f,stackInfo:q?.(I)}),{stackOffset:I,logErrors:s})},cache:r,CacheNone:Ke,CacheLong:Je,CacheShort:Y,CacheCustom:Ye,generateCacheControlHeader:me,getPublicTokenHeaders:c,getPrivateTokenHeaders:d,getShopifyDomain:m,getApiUrl:l,i18n:n??mo}}}var Zt=void 0;function P(e,t){return {...e,...t&&{errors:t}}}function $(e,t){return st(e.headers,t)}function st(e,t){let r=e?.get?.(t)??e?.[t];return typeof r=="string"?r:null}function ee(e){return {requestId:e?$(e,"request-id"):void 0,purpose:e?$(e,"purpose"):void 0}}function go(e){let{cache:t,waitUntil:r,request:o}=e;return function(a,s,u){return Le(a,u,{strategy:s,cacheInstance:t,waitUntil:r,debugInfo:{...ee(o),stackInfo:q?.()}})}}var it=class{#e;constructor(){this.#e=new Map;}add(t){throw new Error("Method not implemented. Use `put` instead.")}addAll(t){throw new Error("Method not implemented. Use `put` instead.")}matchAll(t,r){throw new Error("Method not implemented. Use `match` instead.")}async put(t,r){if(t.method!=="GET")throw new TypeError("Cannot cache response to non-GET request.");if(r.status===206)throw new TypeError("Cannot cache response to a range request (206 Partial Content).");if(r.headers.get("vary")?.includes("*"))throw new TypeError("Cannot cache response with 'Vary: *' header.");this.#e.set(t.url,{body:new Uint8Array(await r.arrayBuffer()),status:r.status,headers:[...r.headers],timestamp:Date.now()});}async match(t){if(t.method!=="GET")return;let r=this.#e.get(t.url);if(!r)return;let{body:o,timestamp:n,...a}=r,s=new Headers(a.headers),u=s.get("cache-control")||s.get("real-cache-control")||"",i=parseInt(u.match(/max-age=(\d+)/)?.[1]||"0",10),c=parseInt(u.match(/stale-while-revalidate=(\d+)/)?.[1]||"0",10),d=(Date.now()-n)/1e3;if(d>i+c){this.#e.delete(t.url);return}let m=d>i;return s.set("cache",m?"STALE":"HIT"),s.set("date",new Date(n).toUTCString()),new Response(o,{status:a.status??200,headers:s})}async delete(t){return this.#e.has(t.url)?(this.#e.delete(t.url),!0):!1}keys(t){let r=[];for(let o of this.#e.keys())(!t||t.url===o)&&r.push(new Request(o));return Promise.resolve(r)}};function _e(e){if(!e)return;let{pathname:t,search:r}=new URL(e),o=t+r,n=new URLSearchParams(r),a=n.get("return_to")||n.get("redirect");if(a){if(rr(e,a))return a;console.warn(`Cross-domain redirects are not supported. Tried to redirect from ${o} to ${a}`);}}function rr(e,t){try{return new URL(e).origin===new URL(t,e).origin}catch{return !1}}function ct({requestUrl:e,defaultUrl:t,redirectUrl:r}){let o=e,n=tr(e,t),a=r?tr(e,r):n;return rr(e,a.toString())?a.toString():(console.warn(`Cross-domain redirects are not supported. Tried to redirect from ${o} to ${a}. Default url ${n} is used instead.`),n.toString())}function tr(e,t){return ho(t)?new URL(t):new URL(t,new URL(e).origin)}function ho(e){try{return new URL(e),!0}catch{return !1}}async function Co(e){let{storefront:t,request:r,noAdminRedirect:o,matchQueryParams:n,response:a=new Response("Not Found",{status:404})}=e,s=new URL(r.url),{pathname:u,searchParams:i}=s,c=i.has("_data");i.delete("redirect"),i.delete("return_to"),i.delete("_data");let d=(n?s.toString().replace(s.origin,""):u).toLowerCase();if(s.pathname==="/admin"&&!o)return pt(`${t.getShopifyDomain()}/admin`,c,i,n);try{let{urlRedirects:l}=await t.query(So,{variables:{query:"path:"+d.replace(/\/+$/,"")}}),m=l?.edges?.[0]?.node?.target;if(m)return pt(m,c,i,n);let p=_e(r.url);if(p)return pt(p,c,i,n)}catch(l){console.error(`Failed to fetch redirects from Storefront API for route ${d}`,l);}return a}var ut="https://example.com";function pt(e,t,r,o){let n=new URL(e,ut);if(!o)for(let[a,s]of r)n.searchParams.append(a,s);return t?new Response(null,{status:200,headers:{"X-Remix-Redirect":n.toString().replace(ut,""),"X-Remix-Status":"301"}}):new Response(null,{status:301,headers:{location:n.toString().replace(ut,"")}})}var So=`#graphql
18
18
  query redirects($query: String) {
19
19
  urlRedirects(first: 1, query: $query) {
20
20
  edges {
@@ -24,7 +24,7 @@ API response error: ${t.status}`,s=new X(c,{query:a,queryVariables:n,cause:{erro
24
24
  }
25
25
  }
26
26
  }
27
- `;var yo=async function({request:t,context:r}){let o=r.storefront,a=r.customerAccount,n=new URL(t.url);if(!o)throw new Error("GraphiQL: Hydrogen's storefront client must be injected in the loader context.");let i={};if(o){let s="X-Shopify-Storefront-Access-Token";i.storefront={name:"Storefront API",authHeader:s,accessToken:o.getPublicTokenHeaders()[s],apiUrl:o.getApiUrl(),icon:"SF"};}if(a){let s=await(await fetch(n.origin+"/graphiql/customer-account.schema.json")).json(),l=await a.getAccessToken();s&&(i["customer-account"]={name:"Customer Account API",value:s,authHeader:"Authorization",accessToken:l,apiUrl:a.getApiUrl(),icon:"CA"});}let u="https://avatars.githubusercontent.com/u/12972006?s=48&v=4",c=String.raw;return new Response(c`
27
+ `;var Po=async function({request:t,context:r}){let o=r.storefront,n=r.customerAccount,a=new URL(t.url);if(!o)throw new Error("GraphiQL: Hydrogen's storefront client must be injected in the loader context.");let s={};if(o){let c="X-Shopify-Storefront-Access-Token";s.storefront={name:"Storefront API",authHeader:c,accessToken:o.getPublicTokenHeaders()[c],apiUrl:o.getApiUrl(),icon:"SF"};}if(n){let c=await(await fetch(a.origin+"/graphiql/customer-account.schema.json")).json(),d=await n.getAccessToken();c&&(s["customer-account"]={name:"Customer Account API",value:c,authHeader:"Authorization",accessToken:d,apiUrl:n.getApiUrl(),icon:"CA"});}let u="https://avatars.githubusercontent.com/u/12972006?s=48&v=4",i=String.raw;return new Response(i`
28
28
  <!DOCTYPE html>
29
29
  <html lang="en">
30
30
  <head>
@@ -119,7 +119,7 @@ API response error: ${t.status}`,s=new X(c,{query:a,queryVariables:n,cause:{erro
119
119
  variables = JSON.stringify(JSON.parse(variables), null, 2);
120
120
  }
121
121
 
122
- const schemas = ${JSON.stringify(i)};
122
+ const schemas = ${JSON.stringify(s)};
123
123
  let lastActiveTabIndex = -1;
124
124
  let lastTabAmount = -1;
125
125
 
@@ -290,24 +290,24 @@ API response error: ${t.status}`,s=new X(c,{query:a,queryVariables:n,cause:{erro
290
290
  </script>
291
291
  </body>
292
292
  </html>
293
- `,{status:200,headers:{"content-type":"text/html"}})};var fo={"&":"\\u0026",">":"\\u003e","<":"\\u003c","\u2028":"\\u2028","\u2029":"\\u2029"},mo=/[&><\u2028\u2029]/g;function Yt(e){return e.replace(mo,t=>fo[t])}var j="Error in SEO input: ",H={title:{validate:e=>{if(typeof e!="string")throw new Error(j.concat("`title` should be a string"));if(typeof e=="string"&&e.length>120)throw new Error(j.concat("`title` should not be longer than 120 characters"));return e}},description:{validate:e=>{if(typeof e!="string")throw new Error(j.concat("`description` should be a string"));if(typeof e=="string"&&e.length>155)throw new Error(j.concat("`description` should not be longer than 155 characters"));return e}},url:{validate:e=>{if(typeof e!="string")throw new Error(j.concat("`url` should be a string"));if(typeof e=="string"&&!e.startsWith("http"))throw new Error(j.concat("`url` should be a valid URL"));return e}},handle:{validate:e=>{if(typeof e!="string")throw new Error(j.concat("`handle` should be a string"));if(typeof e=="string"&&!e.startsWith("@"))throw new Error(j.concat("`handle` should start with `@`"));return e}}};function Xt(e){let t=[];for(let r of Object.keys(e))switch(r){case"title":{let o=Q(H.title,e.title),a=dt(e?.titleTemplate,o);if(!a)break;t.push(E("title",{title:a}),E("meta",{property:"og:title",content:a}),E("meta",{name:"twitter:title",content:a}));break}case"description":{let o=Q(H.description,e.description);if(!o)break;t.push(E("meta",{name:"description",content:o}),E("meta",{property:"og:description",content:o}),E("meta",{name:"twitter:description",content:o}));break}case"url":{let o=Q(H.url,e.url);if(!o)break;let n=o.split("?")[0].replace(/\/$/,"");t.push(E("link",{rel:"canonical",href:n}),E("meta",{property:"og:url",content:n}));break}case"handle":{let o=Q(H.handle,e.handle);if(!o)break;t.push(E("meta",{name:"twitter:site",content:o}),E("meta",{name:"twitter:creator",content:o}));break}case"media":{let o,a=K(e.media);for(let n of a)if(typeof n=="string"&&t.push(E("meta",{name:"og:image",content:n})),n&&typeof n=="object"){let i=n.type||"image",u=n?{url:n?.url,secure_url:n?.url,type:lt(n.url),width:n?.width,height:n?.height,alt:n?.altText}:{};for(let c of Object.keys(u))u[c]&&(o=u[c],t.push(E("meta",{property:`og:${i}:${c}`,content:o},u.url)));}break}case"jsonLd":{let o=K(e.jsonLd),a=0;for(let n of o){if(typeof n!="object")continue;let i=E("script",{type:"application/ld+json",children:JSON.stringify(n,(u,c)=>typeof c=="string"?Yt(c):c)},`json-ld-${n?.["@type"]||n?.name||a++}`);t.push(i);}break}case"alternates":{let o=K(e.alternates);for(let a of o){if(!a)continue;let{language:n,url:i,default:u}=a,c=n?`${n}${u?"-default":""}`:void 0;t.push(E("link",{rel:"alternate",hrefLang:c,href:i}));}break}case"robots":{if(!e.robots)break;let{maxImagePreview:o,maxSnippet:a,maxVideoPreview:n,noArchive:i,noFollow:u,noImageIndex:c,noIndex:s,noSnippet:l,noTranslate:y,unavailableAfter:m}=e.robots,d=[i&&"noarchive",c&&"noimageindex",l&&"nosnippet",y&&"notranslate",o&&`max-image-preview:${o}`,a&&`max-snippet:${a}`,n&&`max-video-preview:${n}`,m&&`unavailable_after:${m}`],p=(s?"noindex":"index")+","+(u?"nofollow":"follow");for(let h of d)h&&(p+=`,${h}`);t.push(E("meta",{name:"robots",content:p}));break}}return t.flat().sort((r,o)=>r.key.localeCompare(o.key))}function E(e,t,r){let o={tag:e,props:{},key:""};return e==="title"?(o.children=t.title,o.key=pt(o),o):e==="script"?(o.children=typeof t.children=="string"?t.children:"",o.key=pt(o,r),delete t.children,o.props=t,o):(o.props=t,Object.keys(o.props).forEach(a=>!o.props[a]&&delete o.props[a]),o.key=pt(o,r),o)}function pt(e,t){let{tag:r,props:o}=e;if(r==="title")return "0-title";if(r==="meta"){let a=o.content===t&&typeof o.property=="string"&&!o.property.endsWith("secure_url")&&"0";return [r,...[t,a],o.property||o.name].filter(i=>i).join("-")}return r==="link"?[r,o.rel,o.hrefLang||o.media].filter(n=>n).join("-").replace(/\s+/g,"-"):r==="script"?`${r}-${t}`:`${r}-${o.type}`}function dt(e,t){if(t)return e?typeof e=="function"?e(t):e.replace("%s",t??""):t}function lt(e){switch(e&&e.split(".").pop()){case"svg":return "image/svg+xml";case"png":return "image/png";case"gif":return "image/gif";case"swf":return "application/x-shockwave-flash";case"mp3":return "audio/mpeg";case"jpg":case"jpeg":default:return "image/jpeg"}}function K(e){return Array.isArray(e)?e:[e]}function Q(e,t){try{return e.validate(t)}catch(r){return console.warn(r.message),t}}var Ao=lazy(()=>import('./log-seo-tags-TY72EQWZ.js'));function vo({debug:e}){let t=useMatches(),r=useLocation();console.warn("[h2:warn:Seo] The `<Seo/>` component is deprecated. Use `getSeoMeta` instead.\nSee: https://shopify.dev/docs/api/hydrogen/2024-01/utilities/getseometa");let o=useMemo(()=>t.flatMap(i=>{let{handle:u,...c}=i,s={...c,...r},l=u?.seo,y=c?.data?.seo;return !l&&!y?[]:l?Ve(l,s):[y]}).reduce((i,u)=>{Object.keys(u).forEach(s=>!u[s]&&delete u[s]);let{jsonLd:c}=u;return c?i?.jsonLd?Array.isArray(c)?{...i,...u,jsonLd:[...i.jsonLd,...c]}:{...i,...u,jsonLd:[...i.jsonLd,c]}:{...i,...u,jsonLd:[c]}:{...i,...u}},{}),[t,r]),{html:a,loggerMarkup:n}=useMemo(()=>{let i=Xt(o),u=i.map(s=>s.tag==="script"?createElement(s.tag,{...s.props,key:s.key,dangerouslySetInnerHTML:{__html:s.children}}):createElement(s.tag,{...s.props,key:s.key},s.children)),c=createElement(Suspense,{fallback:null},createElement(Ao,{headTags:i}));return {html:u,loggerMarkup:c}},[o]);return createElement(Fragment,null,a,e&&n)}function Ve(e,...t){if(e instanceof Function)return Ve(e(...t),...t);let r={};return Array.isArray(e)?(r=e.reduce((o,a)=>[...o,Ve(a)],[]),r):e instanceof Object?(Object.entries(e).forEach(([a,n])=>{r[a]=Ve(n,...t);}),r):e}function To(...e){let t=[],r=e.reduce((o,a)=>{if(!a)return o;Object.keys(a).forEach(i=>!a[i]&&delete a[i]);let{jsonLd:n}=a;return n?o?.jsonLd?{...o,...a,jsonLd:K(o.jsonLd).concat(n)}:{...o,...a,jsonLd:[n]}:{...o,...a}},{})||{};for(let o of Object.keys(r))switch(o){case"title":{let a=Q(H.title,r.title),n=dt(r?.titleTemplate,a);if(!n)break;t.push({title:n},{property:"og:title",content:n},{property:"twitter:title",content:n});break}case"description":{let a=Q(H.description,r.description);if(!a)break;t.push({name:"description",content:a},{property:"og:description",content:a},{property:"twitter:description",content:a});break}case"url":{let a=Q(H.url,r.url);if(!a)break;let i=a.split("?")[0].replace(/\/$/,"");t.push({tagName:"link",rel:"canonical",href:i},{property:"og:url",content:i});break}case"handle":{let a=Q(H.handle,r.handle);if(!a)break;t.push({property:"twitter:site",content:a},{property:"twitter:creator",content:a});break}case"media":{let a,n=K(r.media);for(let i of n)if(typeof i=="string"&&t.push({property:"og:image",content:i}),i&&typeof i=="object"){let u=i.type||"image",c=i?{url:i?.url,secure_url:i?.url,type:lt(i.url),width:i?.width,height:i?.height,alt:i?.altText}:{};for(let s of Object.keys(c))c[s]&&(a=c[s],t.push({property:`og:${u}:${s}`,content:a}));}break}case"jsonLd":{let a=K(r.jsonLd);for(let i of a)typeof i!="object"||Object.keys(i).length===0||t.push({"script:ld+json":i});break}case"alternates":{let a=K(r.alternates);for(let n of a){if(!n)continue;let{language:i,url:u,default:c}=n,s=i?`${i}${c?"-default":""}`:void 0;t.push({tagName:"link",rel:"alternate",hrefLang:s,href:u});}break}case"robots":{if(!r.robots)break;let{maxImagePreview:a,maxSnippet:n,maxVideoPreview:i,noArchive:u,noFollow:c,noImageIndex:s,noIndex:l,noSnippet:y,noTranslate:m,unavailableAfter:d}=r.robots,p=[u&&"noarchive",s&&"noimageindex",y&&"nosnippet",m&&"notranslate",a&&`max-image-preview:${a}`,n&&`max-snippet:${n}`,i&&`max-video-preview:${i}`,d&&`unavailable_after:${d}`],h=(l?"noindex":"index")+","+(c?"nofollow":"follow");for(let g of p)g&&(h+=`,${g}`);t.push({name:"robots",content:h});break}}return t}function Eo({connection:e,children:t=()=>(console.warn("<Pagination> requires children to work properly"),null)}){let o=useNavigation().state==="loading",{endCursor:a,hasNextPage:n,hasPreviousPage:i,nextPageUrl:u,nodes:c,previousPageUrl:s,startCursor:l}=Oo(e),y=useMemo(()=>({pageInfo:{endCursor:a,hasPreviousPage:i,hasNextPage:n,startCursor:l},nodes:c}),[a,n,i,l,c]),m=useMemo(()=>forwardRef(function(h,g){return n?createElement(Link,{preventScrollReset:!0,...h,to:u,state:y,replace:!0,ref:g}):null}),[n,u,y]),d=useMemo(()=>forwardRef(function(h,g){return i?createElement(Link,{preventScrollReset:!0,...h,to:s,state:y,replace:!0,ref:g}):null}),[i,s,y]);return t({state:y,hasNextPage:n,hasPreviousPage:i,isLoading:o,nextPageUrl:u,nodes:c,previousPageUrl:s,NextLink:m,PreviousLink:d})}function Ne(e){let t=new URLSearchParams(e);return t.delete("cursor"),t.delete("direction"),t.toString()}function Pe(e){throw new Error(`The Pagination component requires ${"`"+e+"`"} to be a part of your query. See the guide on how to setup your query to include ${"`"+e+"`"}: https://shopify.dev/docs/custom-storefronts/hydrogen/data-fetching/pagination#setup-the-paginated-query`)}function Oo(e){e.pageInfo||Pe("pageInfo"),typeof e.pageInfo.startCursor>"u"&&Pe("pageInfo.startCursor"),typeof e.pageInfo.endCursor>"u"&&Pe("pageInfo.endCursor"),typeof e.pageInfo.hasNextPage>"u"&&Pe("pageInfo.hasNextPage"),typeof e.pageInfo.hasPreviousPage>"u"&&Pe("pageInfo.hasPreviousPage");let t=useNavigate(),{state:r,search:o,pathname:a}=useLocation(),u=new URLSearchParams(o).get("direction")==="previous",c=useMemo(()=>!globalThis?.window?.__hydrogenHydrated||!r||!r?.nodes?flattenConnection(e):u?[...flattenConnection(e),...r.nodes]:[...r.nodes,...flattenConnection(e)],[r,e]),s=useMemo(()=>{let d=globalThis?.window?.__hydrogenHydrated,p=!d||r?.pageInfo?.startCursor===void 0?e.pageInfo.startCursor:r.pageInfo.startCursor,h=!d||r?.pageInfo?.endCursor===void 0?e.pageInfo.endCursor:r.pageInfo.endCursor,g=!d||r?.pageInfo?.hasPreviousPage===void 0?e.pageInfo.hasPreviousPage:r.pageInfo.hasPreviousPage,f=!d||r?.pageInfo?.hasNextPage===void 0?e.pageInfo.hasNextPage:r.pageInfo.hasNextPage;return r?.nodes&&(u?(p=e.pageInfo.startCursor,g=e.pageInfo.hasPreviousPage):(h=e.pageInfo.endCursor,f=e.pageInfo.hasNextPage)),{startCursor:p,endCursor:h,hasPreviousPage:g,hasNextPage:f}},[u,r,e.pageInfo.hasNextPage,e.pageInfo.hasPreviousPage,e.pageInfo.startCursor,e.pageInfo.endCursor]),l=useRef({params:Ne(o),pathname:a});useEffect(()=>{window.__hydrogenHydrated=!0;},[]),useEffect(()=>{(Ne(o)!==l.current.params||a!==l.current.pathname)&&(l.current={pathname:a,params:Ne(o)},t(`${a}?${Ne(o)}`,{replace:!0,preventScrollReset:!0,state:{nodes:void 0,pageInfo:void 0}}));},[a,o]);let y=useMemo(()=>{let d=new URLSearchParams(o);return d.set("direction","previous"),s.startCursor&&d.set("cursor",s.startCursor),`?${d.toString()}`},[o,s.startCursor]),m=useMemo(()=>{let d=new URLSearchParams(o);return d.set("direction","next"),s.endCursor&&d.set("cursor",s.endCursor),`?${d.toString()}`},[o,s.endCursor]);return {...s,previousPageUrl:y,nextPageUrl:m,nodes:c}}function Do(e,t={pageBy:20}){if(typeof e?.url>"u")throw new Error("getPaginationVariables must be called with the Request object passed to your loader function");let{pageBy:r}=t,o=new URLSearchParams(new URL(e.url).search),a=o.get("cursor")??void 0;return (o.get("direction")==="previous"?"previous":"next")==="previous"?{last:r,startCursor:a??null}:{first:r,endCursor:a??null}}var Me="2024-07",se=`Shopify Hydrogen ${he}`,ar="30243aa5-17c1-465a-8493-944bcc4e88aa",O="customerAccount",ce="buyer";var N=class extends Response{constructor(t,r,o){super(`Bad request: ${t}`,{status:400,headers:o});}};function Ae(e,t={}){let r=t.headers?new Headers(t.headers):new Headers({});return r.set("location",e),new Response(null,{status:t.status||302,headers:r})}async function xo({session:e,customerAccountId:t,customerAccountUrl:r,httpsOrigin:o,debugInfo:a,exchangeForStorefrontCustomerAccessToken:n}){let i=new URLSearchParams,u=e.get(O),c=u?.refreshToken,s=u?.idToken;if(!c)throw new N("Unauthorized","No refreshToken found in the session. Make sure your session is configured correctly and passed to `createCustomerAccountClient`.");i.append("grant_type","refresh_token"),i.append("refresh_token",c),i.append("client_id",t);let l={"content-type":"application/x-www-form-urlencoded","User-Agent":se,Origin:o};new Date().getTime();let m=`${r}/auth/oauth/token`,d=await fetch(m,{method:"POST",headers:l,body:i});if(!d.ok){let T=await d.text();throw new Response(T,{status:d.status,headers:{"Content-Type":"text/html; charset=utf-8"}})}let{access_token:p,expires_in:h,refresh_token:g}=await d.json(),f=await ft(p,t,r,o);e.set(O,{accessToken:f,expiresAt:new Date(new Date().getTime()+(h-120)*1e3).getTime()+"",refreshToken:g,idToken:s}),await n();}function ue(e){e.unset(O),e.unset(ce);}async function nr({locks:e,expiresAt:t,session:r,customerAccountId:o,customerAccountUrl:a,httpsOrigin:n,debugInfo:i,exchangeForStorefrontCustomerAccessToken:u}){if(parseInt(t,10)-1e3<new Date().getTime())try{e.refresh||(e.refresh=xo({session:r,customerAccountId:o,customerAccountUrl:a,httpsOrigin:n,debugInfo:i,exchangeForStorefrontCustomerAccessToken:u})),await e.refresh,delete e.refresh;}catch(c){throw ue(r),c&&c.status!==401?c:new N("Unauthorized","Login before querying the Customer Account API.")}}function ir(){let e=ko();return cr(e)}async function sr(e){let t=await crypto.subtle.digest({name:"SHA-256"},new TextEncoder().encode(e)),r=Lo(t);return cr(r)}function ko(){let e=new Uint8Array(32);return crypto.getRandomValues(e),String.fromCharCode.apply(null,Array.from(e))}function cr(e){return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Lo(e){let t=new Uint8Array(e),r=Array.from(t);return String.fromCharCode(...r)}function ur(){let e=Date.now().toString(),t=Math.random().toString(36).substring(2);return e+t}async function ft(e,t,r,o,a){let n=t;if(!e)throw new N("Unauthorized","oAuth access token was not provided during token exchange.");let i=new URLSearchParams;i.append("grant_type","urn:ietf:params:oauth:grant-type:token-exchange"),i.append("client_id",n),i.append("audience",ar),i.append("subject_token",e),i.append("subject_token_type","urn:ietf:params:oauth:token-type:access_token"),i.append("scopes","https://api.customers.com/auth/customer.graphql");let u={"content-type":"application/x-www-form-urlencoded","User-Agent":se,Origin:o};new Date().getTime();let s=`${r}/auth/oauth/token`,l=await fetch(s,{method:"POST",headers:u,body:i});let y=await l.json();if(y.error)throw new N(y.error_description);return y.access_token}function pr(e){return _o(e).payload.nonce}function _o(e){let[t,r,o]=e.split("."),a=JSON.parse(atob(t)),n=JSON.parse(atob(r));return {header:a,payload:n,signature:o}}function Fe(){return Vo(Uo())}function Uo(){try{return crypto.getRandomValues(new Uint8Array(16))}catch{return new Uint8Array(16).map(()=>Math.random()*255|0)}}function Vo(e){return Array.from(e,function(t){return ("0"+(t&255).toString(16)).slice(-2)}).join("")}var dr="/account/login",No="/account/authorize",lr="/account";function Mo(e){if(!e.url)return dr;let{pathname:t}=new URL(e.url),r=dr+`?${new URLSearchParams({return_to:t}).toString()}`;return Ae(r)}function Fo({session:e,customerAccountId:t,customerAccountUrl:r,customerApiVersion:o=Me,request:a,waitUntil:n,authUrl:i,customAuthStatusHandler:u,logErrors:c=!0,unstableB2b:s=!1}){if(o!==Me&&console.warn(`[h2:warn:createCustomerAccountClient] You are using Customer Account API version ${o} when this version of Hydrogen was built for ${Me}.`),!a?.url)throw new Error("[h2:error:createCustomerAccountClient] The request object does not contain a URL.");let l=u||(()=>Mo(a)),y=new URL(a.url),m=y.protocol==="http:"?y.origin.replace("http","https"):y.origin,d=st({requestUrl:m,defaultUrl:No,redirectUrl:i}),p=`${r}/account/customer/api/${o}/graphql`,h={};async function g({query:C,type:P,variables:A={}}){let v=await I();if(!v)throw l();new Date().getTime();let D=await fetch(p,{method:"POST",headers:{"Content-Type":"application/json","User-Agent":se,Origin:m,Authorization:v},body:JSON.stringify({query:C,variables:A})});let x=await D.text(),k={url:p,response:D,type:P,query:C,queryVariables:A,errors:void 0,client:"customer"};if(!D.ok){if(D.status===401)throw ue(e),l();let b;try{b=Y(x);}catch{b=[{message:x}];}ge({...k,errors:b});}try{let b=Y(x),{errors:W}=b,le=W?.map(({message:oe,...q})=>new X(oe,{...q,clientOperation:`customerAccount.${k.type}`,requestId:D.headers.get("x-request-id"),queryVariables:A,query:C}));return {...b,...W&&{errors:le}}}catch{ge({...k,errors:[{message:x}]});}}async function f(){if(!r||!t)return !1;let C=e.get(O),P=C?.accessToken,A=C?.expiresAt;if(!P||!A)return !1;let v=$?.();try{await nr({locks:h,expiresAt:A,session:e,customerAccountId:t,customerAccountUrl:r,httpsOrigin:m,debugInfo:{waitUntil:n,stackInfo:v,...Z(a)},exchangeForStorefrontCustomerAccessToken:be});}catch{return !1}return !0}async function T(){if(!await f())throw l()}async function I(){if(await f())return e.get(O)?.accessToken}async function _(C,P){return ve(r,t),C=ne(C),Le(C,"customer.mutate"),ie(g({query:C,type:"mutation",...P}),{logErrors:c})}async function U(C,P){return ve(r,t),C=ne(C),ke(C,"customer.query"),ie(g({query:C,type:"query",...P}),{logErrors:c})}function re(C){e.set(ce,{...e.get(ce),...C});}async function V(){if(await f())return e.get(ce)}async function be(){if(!s)return;let C=`#graphql
293
+ `,{status:200,headers:{"content-type":"text/html"}})};var Ao={"&":"\\u0026",">":"\\u003e","<":"\\u003c","\u2028":"\\u2028","\u2029":"\\u2029"},To=/[&><\u2028\u2029]/g;function or(e){return e.replace(To,t=>Ao[t])}var K="Error in SEO input: ",B={title:{validate:e=>{if(typeof e!="string")throw new Error(K.concat("`title` should be a string"));if(typeof e=="string"&&e.length>120)throw new Error(K.concat("`title` should not be longer than 120 characters"));return e}},description:{validate:e=>{if(typeof e!="string")throw new Error(K.concat("`description` should be a string"));if(typeof e=="string"&&e.length>155)throw new Error(K.concat("`description` should not be longer than 155 characters"));return e}},url:{validate:e=>{if(typeof e!="string")throw new Error(K.concat("`url` should be a string"));if(typeof e=="string"&&!e.startsWith("http"))throw new Error(K.concat("`url` should be a valid URL"));return e}},handle:{validate:e=>{if(typeof e!="string")throw new Error(K.concat("`handle` should be a string"));if(typeof e=="string"&&!e.startsWith("@"))throw new Error(K.concat("`handle` should start with `@`"));return e}}};function nr(e){let t=[];for(let r of Object.keys(e))switch(r){case"title":{let o=Q(B.title,e.title),n=lt(e?.titleTemplate,o);if(!n)break;t.push(w("title",{title:n}),w("meta",{property:"og:title",content:n}),w("meta",{name:"twitter:title",content:n}));break}case"description":{let o=Q(B.description,e.description);if(!o)break;t.push(w("meta",{name:"description",content:o}),w("meta",{property:"og:description",content:o}),w("meta",{name:"twitter:description",content:o}));break}case"url":{let o=Q(B.url,e.url);if(!o)break;let a=o.split("?")[0].replace(/\/$/,"");t.push(w("link",{rel:"canonical",href:a}),w("meta",{property:"og:url",content:a}));break}case"handle":{let o=Q(B.handle,e.handle);if(!o)break;t.push(w("meta",{name:"twitter:site",content:o}),w("meta",{name:"twitter:creator",content:o}));break}case"media":{let o,n=z(e.media);for(let a of n)if(typeof a=="string"&&t.push(w("meta",{name:"og:image",content:a})),a&&typeof a=="object"){let s=a.type||"image",u=a?{url:a?.url,secure_url:a?.url,type:yt(a.url),width:a?.width,height:a?.height,alt:a?.altText}:{};for(let i of Object.keys(u))u[i]&&(o=u[i],t.push(w("meta",{property:`og:${s}:${i}`,content:o},u.url)));}break}case"jsonLd":{let o=z(e.jsonLd),n=0;for(let a of o){if(typeof a!="object")continue;let s=w("script",{type:"application/ld+json",children:JSON.stringify(a,(u,i)=>typeof i=="string"?or(i):i)},`json-ld-${a?.["@type"]||a?.name||n++}`);t.push(s);}break}case"alternates":{let o=z(e.alternates);for(let n of o){if(!n)continue;let{language:a,url:s,default:u}=n,i=a?`${a}${u?"-default":""}`:void 0;t.push(w("link",{rel:"alternate",hrefLang:i,href:s}));}break}case"robots":{if(!e.robots)break;let{maxImagePreview:o,maxSnippet:n,maxVideoPreview:a,noArchive:s,noFollow:u,noImageIndex:i,noIndex:c,noSnippet:d,noTranslate:l,unavailableAfter:m}=e.robots,p=[s&&"noarchive",i&&"noimageindex",d&&"nosnippet",l&&"notranslate",o&&`max-image-preview:${o}`,n&&`max-snippet:${n}`,a&&`max-video-preview:${a}`,m&&`unavailable_after:${m}`],y=(c?"noindex":"index")+","+(u?"nofollow":"follow");for(let g of p)g&&(y+=`,${g}`);t.push(w("meta",{name:"robots",content:y}));break}}return t.flat().sort((r,o)=>r.key.localeCompare(o.key))}function w(e,t,r){let o={tag:e,props:{},key:""};return e==="title"?(o.children=t.title,o.key=dt(o),o):e==="script"?(o.children=typeof t.children=="string"?t.children:"",o.key=dt(o,r),delete t.children,o.props=t,o):(o.props=t,Object.keys(o.props).forEach(n=>!o.props[n]&&delete o.props[n]),o.key=dt(o,r),o)}function dt(e,t){let{tag:r,props:o}=e;if(r==="title")return "0-title";if(r==="meta"){let n=o.content===t&&typeof o.property=="string"&&!o.property.endsWith("secure_url")&&"0";return [r,...[t,n],o.property||o.name].filter(s=>s).join("-")}return r==="link"?[r,o.rel,o.hrefLang||o.media].filter(a=>a).join("-").replace(/\s+/g,"-"):r==="script"?`${r}-${t}`:`${r}-${o.type}`}function lt(e,t){if(t)return e?typeof e=="function"?e(t):e.replace("%s",t??""):t}function yt(e){switch(e&&e.split(".").pop()){case"svg":return "image/svg+xml";case"png":return "image/png";case"gif":return "image/gif";case"swf":return "application/x-shockwave-flash";case"mp3":return "audio/mpeg";case"jpg":case"jpeg":default:return "image/jpeg"}}function z(e){return Array.isArray(e)?e:[e]}function Q(e,t){try{return e.validate(t)}catch(r){return console.warn(r.message),t}}var wo=lazy(()=>import('./log-seo-tags-TY72EQWZ.js'));function Oo({debug:e}){let t=useMatches(),r=useLocation();console.warn("[h2:warn:Seo] The `<Seo/>` component is deprecated. Use `getSeoMeta` instead.\nSee: https://shopify.dev/docs/api/hydrogen/2024-07/utilities/getseometa");let o=useMemo(()=>t.flatMap(s=>{let{handle:u,...i}=s,c={...i,...r},d=u?.seo,l=i?.data?.seo;return !d&&!l?[]:d?Ve(d,c):[l]}).reduce((s,u)=>{Object.keys(u).forEach(c=>!u[c]&&delete u[c]);let{jsonLd:i}=u;return i?s?.jsonLd?Array.isArray(i)?{...s,...u,jsonLd:[...s.jsonLd,...i]}:{...s,...u,jsonLd:[...s.jsonLd,i]}:{...s,...u,jsonLd:[i]}:{...s,...u}},{}),[t,r]),{html:n,loggerMarkup:a}=useMemo(()=>{let s=nr(o),u=s.map(c=>c.tag==="script"?createElement(c.tag,{...c.props,key:c.key,dangerouslySetInnerHTML:{__html:c.children}}):createElement(c.tag,{...c.props,key:c.key},c.children)),i=createElement(Suspense,{fallback:null},createElement(wo,{headTags:s}));return {html:u,loggerMarkup:i}},[o]);return createElement(Fragment,null,n,e&&a)}function Ve(e,...t){if(e instanceof Function)return Ve(e(...t),...t);let r={};return Array.isArray(e)?(r=e.reduce((o,n)=>[...o,Ve(n)],[]),r):e instanceof Object?(Object.entries(e).forEach(([n,a])=>{r[n]=Ve(a,...t);}),r):e}function xo(...e){let t=[],r=e.reduce((o,n)=>{if(!n)return o;Object.keys(n).forEach(s=>!n[s]&&delete n[s]);let{jsonLd:a}=n;return a?o?.jsonLd?{...o,...n,jsonLd:z(o.jsonLd).concat(a)}:{...o,...n,jsonLd:[a]}:{...o,...n}},{})||{};for(let o of Object.keys(r))switch(o){case"title":{let n=Q(B.title,r.title),a=lt(r?.titleTemplate,n);if(!a)break;t.push({title:a},{property:"og:title",content:a},{property:"twitter:title",content:a});break}case"description":{let n=Q(B.description,r.description);if(!n)break;t.push({name:"description",content:n},{property:"og:description",content:n},{property:"twitter:description",content:n});break}case"url":{let n=Q(B.url,r.url);if(!n)break;let s=n.split("?")[0].replace(/\/$/,"");t.push({tagName:"link",rel:"canonical",href:s},{property:"og:url",content:s});break}case"handle":{let n=Q(B.handle,r.handle);if(!n)break;t.push({property:"twitter:site",content:n},{property:"twitter:creator",content:n});break}case"media":{let n,a=z(r.media);for(let s of a)if(typeof s=="string"&&t.push({property:"og:image",content:s}),s&&typeof s=="object"){let u=s.type||"image",i=s?{url:s?.url,secure_url:s?.url,type:yt(s.url),width:s?.width,height:s?.height,alt:s?.altText}:{};for(let c of Object.keys(i))i[c]&&(n=i[c],t.push({property:`og:${u}:${c}`,content:n}));}break}case"jsonLd":{let n=z(r.jsonLd);for(let s of n)typeof s!="object"||Object.keys(s).length===0||t.push({"script:ld+json":s});break}case"alternates":{let n=z(r.alternates);for(let a of n){if(!a)continue;let{language:s,url:u,default:i}=a,c=s?`${s}${i?"-default":""}`:void 0;t.push({tagName:"link",rel:"alternate",hrefLang:c,href:u});}break}case"robots":{if(!r.robots)break;let{maxImagePreview:n,maxSnippet:a,maxVideoPreview:s,noArchive:u,noFollow:i,noImageIndex:c,noIndex:d,noSnippet:l,noTranslate:m,unavailableAfter:p}=r.robots,y=[u&&"noarchive",c&&"noimageindex",l&&"nosnippet",m&&"notranslate",n&&`max-image-preview:${n}`,a&&`max-snippet:${a}`,s&&`max-video-preview:${s}`,p&&`unavailable_after:${p}`],g=(d?"noindex":"index")+","+(i?"nofollow":"follow");for(let h of y)h&&(g+=`,${h}`);t.push({name:"robots",content:g});break}}return t}function _o({connection:e,children:t=()=>(console.warn("<Pagination> requires children to work properly"),null)}){let o=useNavigation().state==="loading",{endCursor:n,hasNextPage:a,hasPreviousPage:s,nextPageUrl:u,nodes:i,previousPageUrl:c,startCursor:d}=Vo(e),l=useMemo(()=>({pageInfo:{endCursor:n,hasPreviousPage:s,hasNextPage:a,startCursor:d},nodes:i}),[n,a,s,d,i]),m=useMemo(()=>forwardRef(function(g,h){return a?createElement(Link,{preventScrollReset:!0,...g,to:u,state:l,replace:!0,ref:h}):null}),[a,u,l]),p=useMemo(()=>forwardRef(function(g,h){return s?createElement(Link,{preventScrollReset:!0,...g,to:c,state:l,replace:!0,ref:h}):null}),[s,c,l]);return t({state:l,hasNextPage:a,hasPreviousPage:s,isLoading:o,nextPageUrl:u,nodes:i,previousPageUrl:c,NextLink:m,PreviousLink:p})}function Ne(e){let t=new URLSearchParams(e);return t.delete("cursor"),t.delete("direction"),t.toString()}function Pe(e){throw new Error(`The Pagination component requires ${"`"+e+"`"} to be a part of your query. See the guide on how to setup your query to include ${"`"+e+"`"}: https://shopify.dev/docs/custom-storefronts/hydrogen/data-fetching/pagination#setup-the-paginated-query`)}function Vo(e){e.pageInfo||Pe("pageInfo"),typeof e.pageInfo.startCursor>"u"&&Pe("pageInfo.startCursor"),typeof e.pageInfo.endCursor>"u"&&Pe("pageInfo.endCursor"),typeof e.pageInfo.hasNextPage>"u"&&Pe("pageInfo.hasNextPage"),typeof e.pageInfo.hasPreviousPage>"u"&&Pe("pageInfo.hasPreviousPage");let t=useNavigate(),{state:r,search:o,pathname:n}=useLocation(),u=new URLSearchParams(o).get("direction")==="previous",i=useMemo(()=>!globalThis?.window?.__hydrogenHydrated||!r||!r?.nodes?flattenConnection(e):u?[...flattenConnection(e),...r.nodes]:[...r.nodes,...flattenConnection(e)],[r,e]),c=useMemo(()=>{let p=globalThis?.window?.__hydrogenHydrated,y=!p||r?.pageInfo?.startCursor===void 0?e.pageInfo.startCursor:r.pageInfo.startCursor,g=!p||r?.pageInfo?.endCursor===void 0?e.pageInfo.endCursor:r.pageInfo.endCursor,h=!p||r?.pageInfo?.hasPreviousPage===void 0?e.pageInfo.hasPreviousPage:r.pageInfo.hasPreviousPage,f=!p||r?.pageInfo?.hasNextPage===void 0?e.pageInfo.hasNextPage:r.pageInfo.hasNextPage;return r?.nodes&&(u?(y=e.pageInfo.startCursor,h=e.pageInfo.hasPreviousPage):(g=e.pageInfo.endCursor,f=e.pageInfo.hasNextPage)),{startCursor:y,endCursor:g,hasPreviousPage:h,hasNextPage:f}},[u,r,e.pageInfo.hasNextPage,e.pageInfo.hasPreviousPage,e.pageInfo.startCursor,e.pageInfo.endCursor]),d=useRef({params:Ne(o),pathname:n});useEffect(()=>{window.__hydrogenHydrated=!0;},[]),useEffect(()=>{(Ne(o)!==d.current.params||n!==d.current.pathname)&&(d.current={pathname:n,params:Ne(o)},t(`${n}?${Ne(o)}`,{replace:!0,preventScrollReset:!0,state:{nodes:void 0,pageInfo:void 0}}));},[n,o]);let l=useMemo(()=>{let p=new URLSearchParams(o);return p.set("direction","previous"),c.startCursor&&p.set("cursor",c.startCursor),`?${p.toString()}`},[o,c.startCursor]),m=useMemo(()=>{let p=new URLSearchParams(o);return p.set("direction","next"),c.endCursor&&p.set("cursor",c.endCursor),`?${p.toString()}`},[o,c.endCursor]);return {...c,previousPageUrl:l,nextPageUrl:m,nodes:i}}function No(e,t={pageBy:20}){if(typeof e?.url>"u")throw new Error("getPaginationVariables must be called with the Request object passed to your loader function");let{pageBy:r}=t,o=new URLSearchParams(new URL(e.url).search),n=o.get("cursor")??void 0;return (o.get("direction")==="previous"?"previous":"next")==="previous"?{last:r,startCursor:n??null}:{first:r,endCursor:n??null}}var Me="2024-07",ce=`Shopify Hydrogen ${he}`,pr="30243aa5-17c1-465a-8493-944bcc4e88aa",O="customerAccount",ue="buyer";var N=class extends Response{constructor(t,r,o){super(`Bad request: ${t}`,{status:400,headers:o});}};function Te(e,t={}){let r=t.headers?new Headers(t.headers):new Headers({});return r.set("location",e),new Response(null,{status:t.status||302,headers:r})}async function Mo({session:e,customerAccountId:t,customerAccountUrl:r,httpsOrigin:o,debugInfo:n,exchangeForStorefrontCustomerAccessToken:a}){let s=new URLSearchParams,u=e.get(O),i=u?.refreshToken,c=u?.idToken;if(!i)throw new N("Unauthorized","No refreshToken found in the session. Make sure your session is configured correctly and passed to `createCustomerAccountClient`.");s.append("grant_type","refresh_token"),s.append("refresh_token",i),s.append("client_id",t);let d={"content-type":"application/x-www-form-urlencoded","User-Agent":ce,Origin:o};new Date().getTime();let m=`${r}/auth/oauth/token`,p=await fetch(m,{method:"POST",headers:d,body:s});if(!p.ok){let v=await p.text();throw new Response(v,{status:p.status,headers:{"Content-Type":"text/html; charset=utf-8"}})}let{access_token:y,expires_in:g,refresh_token:h}=await p.json(),f=await mt(y,t,r,o);e.set(O,{accessToken:f,expiresAt:new Date(new Date().getTime()+(g-120)*1e3).getTime()+"",refreshToken:h,idToken:c}),await a();}function pe(e){e.unset(O),e.unset(ue);}async function dr({locks:e,expiresAt:t,session:r,customerAccountId:o,customerAccountUrl:n,httpsOrigin:a,debugInfo:s,exchangeForStorefrontCustomerAccessToken:u}){if(parseInt(t,10)-1e3<new Date().getTime())try{e.refresh||(e.refresh=Mo({session:r,customerAccountId:o,customerAccountUrl:n,httpsOrigin:a,debugInfo:s,exchangeForStorefrontCustomerAccessToken:u})),await e.refresh,delete e.refresh;}catch(i){throw pe(r),i&&i.status!==401?i:new N("Unauthorized","Login before querying the Customer Account API.")}}function lr(){let e=Ho();return fr(e)}async function yr(e){let t=await crypto.subtle.digest({name:"SHA-256"},new TextEncoder().encode(e)),r=Fo(t);return fr(r)}function Ho(){let e=new Uint8Array(32);return crypto.getRandomValues(e),String.fromCharCode.apply(null,Array.from(e))}function fr(e){return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Fo(e){let t=new Uint8Array(e),r=Array.from(t);return String.fromCharCode(...r)}function mr(){let e=Date.now().toString(),t=Math.random().toString(36).substring(2);return e+t}async function mt(e,t,r,o,n){let a=t;if(!e)throw new N("Unauthorized","oAuth access token was not provided during token exchange.");let s=new URLSearchParams;s.append("grant_type","urn:ietf:params:oauth:grant-type:token-exchange"),s.append("client_id",a),s.append("audience",pr),s.append("subject_token",e),s.append("subject_token_type","urn:ietf:params:oauth:token-type:access_token"),s.append("scopes","https://api.customers.com/auth/customer.graphql");let u={"content-type":"application/x-www-form-urlencoded","User-Agent":ce,Origin:o};new Date().getTime();let c=`${r}/auth/oauth/token`,d=await fetch(c,{method:"POST",headers:u,body:s});let l=await d.json();if(l.error)throw new N(l.error_description);return l.access_token}function gr(e){return qo(e).payload.nonce}function qo(e){let[t,r,o]=e.split("."),n=JSON.parse(atob(t)),a=JSON.parse(atob(r));return {header:n,payload:a,signature:o}}function He(){return Bo($o())}function $o(){try{return crypto.getRandomValues(new Uint8Array(16))}catch{return new Uint8Array(16).map(()=>Math.random()*255|0)}}function Bo(e){return Array.from(e,function(t){return ("0"+(t&255).toString(16)).slice(-2)}).join("")}var hr="/account/login",Qo="/account/authorize",Cr="/account";function Go(e){if(!e.url)return hr;let{pathname:t}=new URL(e.url),r=hr+`?${new URLSearchParams({return_to:t}).toString()}`;return Te(r)}function gt({session:e,customerAccountId:t,customerAccountUrl:r,customerApiVersion:o=Me,request:n,waitUntil:a,authUrl:s,customAuthStatusHandler:u,logErrors:i=!0,unstableB2b:c=!1}){if(o!==Me&&console.warn(`[h2:warn:createCustomerAccountClient] You are using Customer Account API version ${o} when this version of Hydrogen was built for ${Me}.`),e||console.warn("[h2:warn:createCustomerAccountClient] session is required to use Customer Account API. Ensure the session object passed in exist."),!n?.url)throw new Error("[h2:error:createCustomerAccountClient] The request object does not contain a URL.");let d=u||(()=>Go(n)),l=new URL(n.url),m=l.protocol==="http:"?l.origin.replace("http","https"):l.origin,p=ct({requestUrl:m,defaultUrl:Qo,redirectUrl:s}),y=`${r}/account/customer/api/${o}/graphql`,g={};async function h({query:C,type:S,variables:A={}}){let T=await I();if(!T)throw d();new Date().getTime();let x=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json","User-Agent":ce,Origin:m,Authorization:T},body:JSON.stringify({query:C,variables:A})});let D=await x.text(),L={url:y,response:x,type:S,query:C,queryVariables:A,errors:void 0,client:"customer"};if(!x.ok){if(x.status===401)throw pe(e),d();let E;try{E=X(D);}catch{E=[{message:D}];}Ce({...L,errors:E});}try{let E=X(D),{errors:j}=E,ye=j?.map(({message:ne,...F})=>new Z(ne,{...F,clientOperation:`customerAccount.${L.type}`,requestId:x.headers.get("x-request-id"),queryVariables:A,query:C}));return {...E,...j&&{errors:ye}}}catch{Ce({...L,errors:[{message:D}]});}}async function f(){if(!r||!t)return !1;let C=e.get(O),S=C?.accessToken,A=C?.expiresAt;if(!S||!A)return !1;let T=q?.();try{await dr({locks:g,expiresAt:A,session:e,customerAccountId:t,customerAccountUrl:r,httpsOrigin:m,debugInfo:{waitUntil:a,stackInfo:T,...ee(n)},exchangeForStorefrontCustomerAccessToken:we});}catch{return !1}return !0}async function v(){if(!await f())throw d()}async function I(){if(await f())return e.get(O)?.accessToken}async function k(C,S){return ve(r,t),C=se(C),ke(C,"customer.mutate"),ie(h({query:C,type:"mutation",...S}),{logErrors:i})}async function _(C,S){return ve(r,t),C=se(C),Ue(C,"customer.query"),ie(h({query:C,type:"query",...S}),{logErrors:i})}function oe(C){e.set(ue,{...e.get(ue),...C});}async function V(){if(await f())return e.get(ue)}async function we(){if(!c)return;let C=`#graphql
294
294
  mutation storefrontCustomerAccessTokenCreate {
295
295
  storefrontCustomerAccessTokenCreate {
296
296
  customerAccessToken
297
297
  }
298
298
  }
299
- `,{data:P}=await _(C),A=P?.storefrontCustomerAccessTokenCreate?.customerAccessToken;A&&re({customerAccessToken:A});}return {login:async C=>{ve(r,t);let P=new URL(`${r}/auth/oauth/authorize`),A=ur(),v=Fe();if(P.searchParams.set("client_id",t),P.searchParams.set("scope","openid email"),P.searchParams.append("response_type","code"),P.searchParams.append("redirect_uri",d),P.searchParams.set("scope","openid email https://api.customers.com/auth/customer.graphql"),P.searchParams.append("state",A),P.searchParams.append("nonce",v),C?.uiLocales){let[D,x]=C.uiLocales.split("-"),k=D.toLowerCase();x&&(k+=`-${x.toUpperCase()}`),P.searchParams.append("ui_locales",k);}let M=ir(),F=await sr(M);return e.set(O,{...e.get(O),codeVerifier:M,state:A,nonce:v,redirectPath:Ue(a.url)||_e(a,"Referer")||lr}),P.searchParams.append("code_challenge",F),P.searchParams.append("code_challenge_method","S256"),Ae(P.toString())},logout:async C=>{ve(r,t);let P=e.get(O)?.idToken,A=st({requestUrl:m,defaultUrl:m,redirectUrl:C?.postLogoutRedirectUri}),v=P?new URL(`${r}/auth/logout?${new URLSearchParams([["id_token_hint",P],["post_logout_redirect_uri",A]]).toString()}`).toString():A;return ue(e),Ae(v)},isLoggedIn:f,handleAuthStatus:T,getAccessToken:I,getApiUrl:()=>p,mutate:_,query:U,authorize:async()=>{ve(r,t);let C=y.searchParams.get("code"),P=y.searchParams.get("state");if(!C||!P)throw ue(e),new N("Unauthorized","No code or state parameter found in the redirect URL.");if(e.get(O)?.state!==P)throw ue(e),new N("Unauthorized","The session state does not match the state parameter. Make sure that the session is configured correctly and passed to `createCustomerAccountClient`.");let A=t,v=new URLSearchParams;v.append("grant_type","authorization_code"),v.append("client_id",A),v.append("redirect_uri",d),v.append("code",C);let M=e.get(O)?.codeVerifier;if(!M)throw new N("Unauthorized","No code verifier found in the session. Make sure that the session is configured correctly and passed to `createCustomerAccountClient`.");v.append("code_verifier",M);let F={"content-type":"application/x-www-form-urlencoded","User-Agent":se,Origin:m},D=$?.();new Date().getTime();let k=`${r}/auth/oauth/token`,b=await fetch(k,{method:"POST",headers:F,body:v});if(!b.ok)throw new Response(await b.text(),{status:b.status,headers:{"Content-Type":"text/html; charset=utf-8"}});let{access_token:W,expires_in:le,id_token:oe,refresh_token:q}=await b.json(),ye=e.get(O)?.nonce,kt=await pr(oe);if(ye!==kt)throw new N("Unauthorized",`Returned nonce does not match: ${ye} !== ${kt}`);let Gr=await ft(W,t,r,m,{waitUntil:n,stackInfo:D,...Z(a)}),Br=e.get(O)?.redirectPath;return e.set(O,{accessToken:Gr,expiresAt:new Date(new Date().getTime()+(le-120)*1e3).getTime()+"",refreshToken:q,idToken:oe}),await be(),Ae(Br||lr)},UNSTABLE_setBuyer:re,UNSTABLE_getBuyer:V}}function ve(e,t){try{if(!e||!t)throw Error();new URL(e);}catch{console.error(new Error("[h2:error:customerAccount] You do not have the valid credential to use Customer Account API.\nRun `h2 env pull` to link your store credentials."));let r="Internal Server Error";throw new Response(r,{status:500})}}var qo="https://raw.githubusercontent.com/Shopify/hydrogen/main/docs/changelog.json";async function $o({request:e,changelogUrl:t}){new URL(e.url).searchParams;return fetch(t||qo)}var yr="cartFormInput";function G({children:e,action:t,inputs:r,route:o,fetcherKey:a}){let n=useFetcher({key:a});return jsxs(n.Form,{action:o||"",method:"post",children:[(t||r)&&jsx("input",{type:"hidden",name:yr,value:JSON.stringify({action:t,inputs:r})}),typeof e=="function"?e(n):e]})}G.INPUT_NAME=yr;G.ACTIONS={AttributesUpdateInput:"AttributesUpdateInput",BuyerIdentityUpdate:"BuyerIdentityUpdate",Create:"Create",DiscountCodesUpdate:"DiscountCodesUpdate",LinesAdd:"LinesAdd",LinesRemove:"LinesRemove",LinesUpdate:"LinesUpdate",NoteUpdate:"NoteUpdate",SelectedDeliveryOptionsUpdate:"SelectedDeliveryOptionsUpdate",MetafieldsSet:"MetafieldsSet",MetafieldDelete:"MetafieldDelete"};function Qo(e){let t={};for(let i of e.entries()){let u=i[0],c=e.getAll(u);t[u]=c.length>1?c:i[1];}let{cartFormInput:r,...o}=t,{action:a,inputs:n}=r?JSON.parse(String(r)):{};return {action:a,inputs:{...n,...o}}}G.getFormInput=Qo;var R=`#graphql
299
+ `,{data:S}=await k(C),A=S?.storefrontCustomerAccessTokenCreate?.customerAccessToken;A&&oe({customerAccessToken:A});}return {login:async C=>{ve(r,t);let S=new URL(`${r}/auth/oauth/authorize`),A=mr(),T=He();if(S.searchParams.set("client_id",t),S.searchParams.set("scope","openid email"),S.searchParams.append("response_type","code"),S.searchParams.append("redirect_uri",p),S.searchParams.set("scope","openid email https://api.customers.com/auth/customer.graphql"),S.searchParams.append("state",A),S.searchParams.append("nonce",T),C?.uiLocales){let[x,D]=C.uiLocales.split("-"),L=x.toLowerCase();D&&(L+=`-${D.toUpperCase()}`),S.searchParams.append("ui_locales",L);}let M=lr(),H=await yr(M);return e.set(O,{...e.get(O),codeVerifier:M,state:A,nonce:T,redirectPath:_e(n.url)||$(n,"Referer")||Cr}),S.searchParams.append("code_challenge",H),S.searchParams.append("code_challenge_method","S256"),Te(S.toString())},logout:async C=>{ve(r,t);let S=e.get(O)?.idToken,A=ct({requestUrl:m,defaultUrl:m,redirectUrl:C?.postLogoutRedirectUri}),T=S?new URL(`${r}/auth/logout?${new URLSearchParams([["id_token_hint",S],["post_logout_redirect_uri",A]]).toString()}`).toString():A;return pe(e),Te(T)},isLoggedIn:f,handleAuthStatus:v,getAccessToken:I,getApiUrl:()=>y,mutate:k,query:_,authorize:async()=>{ve(r,t);let C=l.searchParams.get("code"),S=l.searchParams.get("state");if(!C||!S)throw pe(e),new N("Unauthorized","No code or state parameter found in the redirect URL.");if(e.get(O)?.state!==S)throw pe(e),new N("Unauthorized","The session state does not match the state parameter. Make sure that the session is configured correctly and passed to `createCustomerAccountClient`.");let A=t,T=new URLSearchParams;T.append("grant_type","authorization_code"),T.append("client_id",A),T.append("redirect_uri",p),T.append("code",C);let M=e.get(O)?.codeVerifier;if(!M)throw new N("Unauthorized","No code verifier found in the session. Make sure that the session is configured correctly and passed to `createCustomerAccountClient`.");T.append("code_verifier",M);let H={"content-type":"application/x-www-form-urlencoded","User-Agent":ce,Origin:m},x=q?.();new Date().getTime();let L=`${r}/auth/oauth/token`,E=await fetch(L,{method:"POST",headers:H,body:T});if(!E.ok)throw new Response(await E.text(),{status:E.status,headers:{"Content-Type":"text/html; charset=utf-8"}});let{access_token:j,expires_in:ye,id_token:ne,refresh_token:F}=await E.json(),fe=e.get(O)?.nonce,Nt=await gr(ne);if(fe!==Nt)throw new N("Unauthorized",`Returned nonce does not match: ${fe} !== ${Nt}`);let Yr=await mt(j,t,r,m,{waitUntil:a,stackInfo:x,...ee(n)}),Xr=e.get(O)?.redirectPath;return e.set(O,{accessToken:Yr,expiresAt:new Date(new Date().getTime()+(ye-120)*1e3).getTime()+"",refreshToken:F,idToken:ne}),await we(),Te(Xr||Cr)},UNSTABLE_setBuyer:oe,UNSTABLE_getBuyer:V}}function ve(e,t){try{if(!e||!t)throw Error();new URL(e);}catch{console.error(new Error("[h2:error:customerAccount] You do not have the valid credential to use Customer Account API.\nRun `h2 env pull` to link your store credentials."));let r="Internal Server Error";throw new Response(r,{status:500})}}var Wo="https://raw.githubusercontent.com/Shopify/hydrogen/main/docs/changelog.json";async function jo({request:e,changelogUrl:t}){new URL(e.url).searchParams;return fetch(t||Wo)}var Sr="cartFormInput";function G({children:e,action:t,inputs:r,route:o,fetcherKey:n}){let a=useFetcher({key:n});return jsxs(a.Form,{action:o||"",method:"post",children:[(t||r)&&jsx("input",{type:"hidden",name:Sr,value:JSON.stringify({action:t,inputs:r})}),typeof e=="function"?e(a):e]})}G.INPUT_NAME=Sr;G.ACTIONS={AttributesUpdateInput:"AttributesUpdateInput",BuyerIdentityUpdate:"BuyerIdentityUpdate",Create:"Create",DiscountCodesUpdate:"DiscountCodesUpdate",LinesAdd:"LinesAdd",LinesRemove:"LinesRemove",LinesUpdate:"LinesUpdate",NoteUpdate:"NoteUpdate",SelectedDeliveryOptionsUpdate:"SelectedDeliveryOptionsUpdate",MetafieldsSet:"MetafieldsSet",MetafieldDelete:"MetafieldDelete"};function zo(e){let t={};for(let s of e.entries()){let u=s[0],i=e.getAll(u);t[u]=i.length>1?i:s[1];}let{cartFormInput:r,...o}=t,{action:n,inputs:a}=r?JSON.parse(String(r)):{};return {action:n,inputs:{...a,...o}}}G.getFormInput=zo;var R=`#graphql
300
300
  fragment CartApiError on CartUserError {
301
301
  message
302
302
  field
303
303
  code
304
304
  }
305
- `,w=`#graphql
305
+ `,b=`#graphql
306
306
  fragment CartApiMutation on Cart {
307
307
  id
308
308
  totalQuantity
309
309
  }
310
- `;function mt(e){return async(t,r)=>{let o=e.customerAccount?await e.customerAccount.UNSTABLE_getBuyer():void 0,{cartId:a,...n}=r||{},{buyerIdentity:i,...u}=t,{cartCreate:c,errors:s}=await e.storefront.mutate(Wo(e.cartFragment),{variables:{input:{...u,buyerIdentity:{...o,...i}},...n}});return S(c,s)}}var Wo=(e=w)=>`#graphql
310
+ `;function ht(e){return async(t,r)=>{let o=e.customerAccount?await e.customerAccount.UNSTABLE_getBuyer():void 0,{cartId:n,...a}=r||{},{buyerIdentity:s,...u}=t,{cartCreate:i,errors:c}=await e.storefront.mutate(Xo(e.cartFragment),{variables:{input:{...u,buyerIdentity:{...o,...s}},...a}});return P(i,c)}}var Xo=(e=b)=>`#graphql
311
311
  mutation cartCreate(
312
312
  $input: CartInput!
313
313
  $country: CountryCode = ZZ
@@ -325,7 +325,7 @@ API response error: ${t.status}`,s=new X(c,{query:a,queryVariables:n,cause:{erro
325
325
  }
326
326
  ${e}
327
327
  ${R}
328
- `;function ht({storefront:e,customerAccount:t,getCartId:r,cartFragment:o}){return async a=>{let n=r();if(!n)return null;let[i,{cart:u,errors:c}]=await Promise.all([t?t.isLoggedIn():!1,e.query(jo(o),{variables:{cartId:n,...a},cache:e.CacheNone()})]);if(i&&u?.checkoutUrl){let s=new URL(u.checkoutUrl);s.searchParams.set("logged_in","true"),u.checkoutUrl=s.toString();}return u||c?S(u,c):null}}var jo=(e=Ko)=>`#graphql
328
+ `;function Ct({storefront:e,customerAccount:t,getCartId:r,cartFragment:o}){return async n=>{let a=r();if(!a)return null;let[s,{cart:u,errors:i}]=await Promise.all([t?t.isLoggedIn():!1,e.query(Zo(o),{variables:{cartId:a,...n},cache:e.CacheNone()})]);if(s&&u?.checkoutUrl){let c=new URL(u.checkoutUrl);c.searchParams.set("logged_in","true"),u.checkoutUrl=c.toString();}return u||i?P(u,i):null}}var Zo=(e=en)=>`#graphql
329
329
  query CartQuery(
330
330
  $cartId: ID!
331
331
  $numCartLines: Int = 100
@@ -338,7 +338,7 @@ API response error: ${t.status}`,s=new X(c,{query:a,queryVariables:n,cause:{erro
338
338
  }
339
339
 
340
340
  ${e}
341
- `,Ko=`#graphql
341
+ `,en=`#graphql
342
342
  fragment CartApiQuery on Cart {
343
343
  updatedAt
344
344
  id
@@ -446,7 +446,7 @@ API response error: ${t.status}`,s=new X(c,{query:a,queryVariables:n,cause:{erro
446
446
  width
447
447
  height
448
448
  }
449
- `;function gt(e){return async(t,r)=>{let{cartLinesAdd:o,errors:a}=await e.storefront.mutate(zo(e.cartFragment),{variables:{cartId:e.getCartId(),lines:t,...r}});return S(o,a)}}var zo=(e=w)=>`#graphql
449
+ `;function St(e){return async(t,r)=>{let{cartLinesAdd:o,errors:n}=await e.storefront.mutate(tn(e.cartFragment),{variables:{cartId:e.getCartId(),lines:t,...r}});return P(o,n)}}var tn=(e=b)=>`#graphql
450
450
  mutation cartLinesAdd(
451
451
  $cartId: ID!
452
452
  $lines: [CartLineInput!]!
@@ -465,7 +465,7 @@ API response error: ${t.status}`,s=new X(c,{query:a,queryVariables:n,cause:{erro
465
465
 
466
466
  ${e}
467
467
  ${R}
468
- `;var fr="__h_pending_";function mr(e){return fr+e}function qe(e){return e.startsWith(fr)}function $e(e,t){if(t.some(r=>qe(typeof r=="string"?r:r.id)))throw new Error(`Tried to perform an action on an optimistic line. Make sure to disable your "${e}" CartForm action when the line is optimistic.`)}function Ct(e){return async(t,r)=>{$e("updateLines",t);let{cartLinesUpdate:o,errors:a}=await e.storefront.mutate(Jo(e.cartFragment),{variables:{cartId:e.getCartId(),lines:t,...r}});return S(o,a)}}var Jo=(e=w)=>`#graphql
468
+ `;var Pr="__h_pending_";function Ar(e){return Pr+e}function Fe(e){return e.startsWith(Pr)}function qe(e,t){if(t.some(r=>Fe(typeof r=="string"?r:r.id)))throw new Error(`Tried to perform an action on an optimistic line. Make sure to disable your "${e}" CartForm action when the line is optimistic.`)}function Pt(e){return async(t,r)=>{qe("updateLines",t);let{cartLinesUpdate:o,errors:n}=await e.storefront.mutate(rn(e.cartFragment),{variables:{cartId:e.getCartId(),lines:t,...r}});return P(o,n)}}var rn=(e=b)=>`#graphql
469
469
  mutation cartLinesUpdate(
470
470
  $cartId: ID!
471
471
  $lines: [CartLineUpdateInput!]!
@@ -484,7 +484,7 @@ API response error: ${t.status}`,s=new X(c,{query:a,queryVariables:n,cause:{erro
484
484
 
485
485
  ${e}
486
486
  ${R}
487
- `;function Pt(e){return async(t,r)=>{$e("removeLines",t);let{cartLinesRemove:o,errors:a}=await e.storefront.mutate(Yo(e.cartFragment),{variables:{cartId:e.getCartId(),lineIds:t,...r}});return S(o,a)}}var Yo=(e=w)=>`#graphql
487
+ `;function At(e){return async(t,r)=>{qe("removeLines",t);let{cartLinesRemove:o,errors:n}=await e.storefront.mutate(on(e.cartFragment),{variables:{cartId:e.getCartId(),lineIds:t,...r}});return P(o,n)}}var on=(e=b)=>`#graphql
488
488
  mutation cartLinesRemove(
489
489
  $cartId: ID!
490
490
  $lineIds: [ID!]!
@@ -503,7 +503,7 @@ API response error: ${t.status}`,s=new X(c,{query:a,queryVariables:n,cause:{erro
503
503
 
504
504
  ${e}
505
505
  ${R}
506
- `;function St(e){return async(t,r)=>{let o=t.filter((i,u,c)=>c.indexOf(i)===u),{cartDiscountCodesUpdate:a,errors:n}=await e.storefront.mutate(Xo(e.cartFragment),{variables:{cartId:e.getCartId(),discountCodes:o,...r}});return S(a,n)}}var Xo=(e=w)=>`#graphql
506
+ `;function Tt(e){return async(t,r)=>{let o=t.filter((s,u,i)=>i.indexOf(s)===u),{cartDiscountCodesUpdate:n,errors:a}=await e.storefront.mutate(nn(e.cartFragment),{variables:{cartId:e.getCartId(),discountCodes:o,...r}});return P(n,a)}}var nn=(e=b)=>`#graphql
507
507
  mutation cartDiscountCodesUpdate(
508
508
  $cartId: ID!
509
509
  $discountCodes: [String!]
@@ -521,7 +521,7 @@ API response error: ${t.status}`,s=new X(c,{query:a,queryVariables:n,cause:{erro
521
521
  }
522
522
  ${e}
523
523
  ${R}
524
- `;function At(e){return async(t,r)=>{t.companyLocationId&&e.customerAccount&&e.customerAccount.UNSTABLE_setBuyer({companyLocationId:t.companyLocationId});let o=e.customerAccount?await e.customerAccount.UNSTABLE_getBuyer():void 0,{cartBuyerIdentityUpdate:a,errors:n}=await e.storefront.mutate(Zo(e.cartFragment),{variables:{cartId:e.getCartId(),buyerIdentity:{...o,...t},...r}});return S(a,n)}}var Zo=(e=w)=>`#graphql
524
+ `;function vt(e){return async(t,r)=>{t.companyLocationId&&e.customerAccount&&e.customerAccount.UNSTABLE_setBuyer({companyLocationId:t.companyLocationId});let o=e.customerAccount?await e.customerAccount.UNSTABLE_getBuyer():void 0,{cartBuyerIdentityUpdate:n,errors:a}=await e.storefront.mutate(an(e.cartFragment),{variables:{cartId:e.getCartId(),buyerIdentity:{...o,...t},...r}});return P(n,a)}}var an=(e=b)=>`#graphql
525
525
  mutation cartBuyerIdentityUpdate(
526
526
  $cartId: ID!
527
527
  $buyerIdentity: CartBuyerIdentityInput!
@@ -539,7 +539,7 @@ API response error: ${t.status}`,s=new X(c,{query:a,queryVariables:n,cause:{erro
539
539
  }
540
540
  ${e}
541
541
  ${R}
542
- `;function vt(e){return async(t,r)=>{let{cartNoteUpdate:o,errors:a}=await e.storefront.mutate(ea(e.cartFragment),{variables:{cartId:e.getCartId(),note:t,...r}});return S(o,a)}}var ea=(e=w)=>`#graphql
542
+ `;function It(e){return async(t,r)=>{let{cartNoteUpdate:o,errors:n}=await e.storefront.mutate(sn(e.cartFragment),{variables:{cartId:e.getCartId(),note:t,...r}});return P(o,n)}}var sn=(e=b)=>`#graphql
543
543
  mutation cartNoteUpdate(
544
544
  $cartId: ID!
545
545
  $note: String!
@@ -557,7 +557,7 @@ API response error: ${t.status}`,s=new X(c,{query:a,queryVariables:n,cause:{erro
557
557
  }
558
558
  ${e}
559
559
  ${R}
560
- `;function Tt(e){return async(t,r)=>{let{cartSelectedDeliveryOptionsUpdate:o,errors:a}=await e.storefront.mutate(ta(e.cartFragment),{variables:{cartId:e.getCartId(),selectedDeliveryOptions:t,...r}});return S(o,a)}}var ta=(e=w)=>`#graphql
560
+ `;function Rt(e){return async(t,r)=>{let{cartSelectedDeliveryOptionsUpdate:o,errors:n}=await e.storefront.mutate(cn(e.cartFragment),{variables:{cartId:e.getCartId(),selectedDeliveryOptions:t,...r}});return P(o,n)}}var cn=(e=b)=>`#graphql
561
561
  mutation cartSelectedDeliveryOptionsUpdate(
562
562
  $cartId: ID!
563
563
  $selectedDeliveryOptions: [CartSelectedDeliveryOptionInput!]!
@@ -575,7 +575,7 @@ API response error: ${t.status}`,s=new X(c,{query:a,queryVariables:n,cause:{erro
575
575
  }
576
576
  ${e}
577
577
  ${R}
578
- `;function It(e){return async(t,r)=>{let{cartAttributesUpdate:o,errors:a}=await e.storefront.mutate(ra(e.cartFragment),{variables:{cartId:r?.cartId||e.getCartId(),attributes:t}});return S(o,a)}}var ra=(e=w)=>`#graphql
578
+ `;function bt(e){return async(t,r)=>{let{cartAttributesUpdate:o,errors:n}=await e.storefront.mutate(un(e.cartFragment),{variables:{cartId:r?.cartId||e.getCartId(),attributes:t}});return P(o,n)}}var un=(e=b)=>`#graphql
579
579
  mutation cartAttributesUpdate(
580
580
  $cartId: ID!
581
581
  $attributes: [AttributeInput!]!
@@ -591,7 +591,7 @@ API response error: ${t.status}`,s=new X(c,{query:a,queryVariables:n,cause:{erro
591
591
  }
592
592
  ${e}
593
593
  ${R}
594
- `;function Rt(e){return async(t,r)=>{let o=r?.cartId||e.getCartId(),a=t.map(u=>({...u,ownerId:o})),{cartMetafieldsSet:n,errors:i}=await e.storefront.mutate(oa(),{variables:{metafields:a}});return S({cart:{id:o},...n},i)}}var oa=()=>`#graphql
594
+ `;function Et(e){return async(t,r)=>{let o=r?.cartId||e.getCartId(),n=t.map(u=>({...u,ownerId:o})),{cartMetafieldsSet:a,errors:s}=await e.storefront.mutate(pn(),{variables:{metafields:n}});return P({cart:{id:o},...a},s)}}var pn=()=>`#graphql
595
595
  mutation cartMetafieldsSet(
596
596
  $metafields: [CartMetafieldsSetInput!]!
597
597
  $language: LanguageCode
@@ -606,7 +606,7 @@ API response error: ${t.status}`,s=new X(c,{query:a,queryVariables:n,cause:{erro
606
606
  }
607
607
  }
608
608
  }
609
- `;function wt(e){return async(t,r)=>{let o=r?.cartId||e.getCartId(),{cartMetafieldDelete:a,errors:n}=await e.storefront.mutate(aa(),{variables:{input:{ownerId:o,key:t}}});return S({cart:{id:o},...a},n)}}var aa=()=>`#graphql
609
+ `;function wt(e){return async(t,r)=>{let o=r?.cartId||e.getCartId(),{cartMetafieldDelete:n,errors:a}=await e.storefront.mutate(dn(),{variables:{input:{ownerId:o,key:t}}});return P({cart:{id:o},...n},a)}}var dn=()=>`#graphql
610
610
  mutation cartMetafieldDelete(
611
611
  $input: CartMetafieldDeleteInput!
612
612
  ) {
@@ -618,7 +618,7 @@ API response error: ${t.status}`,s=new X(c,{query:a,queryVariables:n,cause:{erro
618
618
  }
619
619
  }
620
620
  }
621
- `;var ia=e=>{let t=parse(e.get("Cookie")||"");return ()=>t.cart?`gid://shopify/Cart/${t.cart}`:void 0};var ca=e=>t=>{let r=new Headers;return r.append("Set-Cookie",stringify("cart",t.split("/").pop()||"",{path:"/",...e})),r};function ua(e){let{getCartId:t,setCartId:r,storefront:o,customerAccount:a,cartQueryFragment:n,cartMutateFragment:i}=e,u=t(),c=()=>u||t(),s={storefront:o,getCartId:c,cartFragment:i,customerAccount:a},l=mt(s),y=async function(...d){let p=await l(...d);return u=p?.cart?.id,p},m={get:ht({storefront:o,customerAccount:a,getCartId:c,cartFragment:n}),getCartId:c,setCartId:r,create:y,addLines:async(d,p)=>{let h=d.map(g=>({attributes:g.attributes,quantity:g.quantity,merchandiseId:g.merchandiseId,sellingPlanId:g.sellingPlanId}));return u||p?.cartId?await gt(s)(h,p):await y({lines:h},p)},updateLines:Ct(s),removeLines:Pt(s),updateDiscountCodes:async(d,p)=>u||p?.cartId?await St(s)(d,p):await y({discountCodes:d},p),updateBuyerIdentity:async(d,p)=>u||p?.cartId?await At(s)(d,p):await y({buyerIdentity:d},p),updateNote:async(d,p)=>u||p?.cartId?await vt(s)(d,p):await y({note:d},p),updateSelectedDeliveryOption:Tt(s),updateAttributes:async(d,p)=>u||p?.cartId?await It(s)(d,p):await y({attributes:d},p),setMetafields:async(d,p)=>u||p?.cartId?await Rt(s)(d,p):await y({metafields:d},p),deleteMetafield:wt(s)};return "customMethods"in e?{...m,...e.customMethods??{}}:m}function da(e){let t=useFetchers();if(!t||!t.length)return e;let r=e?.lines?structuredClone(e):{lines:{nodes:[]}},o=r.lines.nodes,a=!1;for(let{formData:n}of t){if(!n)continue;let i=G.getFormInput(n);if(i.action===G.ACTIONS.LinesAdd)for(let u of i.inputs.lines){if(!u.selectedVariant){console.error("[h2:error:useOptimisticCart] No selected variant was passed in the cart action. Make sure to pass the selected variant if you want to use an optimistic cart");continue}let c=o.find(s=>s.merchandise.id===u.selectedVariant?.id);a=!0,c?(c.quantity=(c.quantity||1)+(u.quantity||1),c.isOptimistic=!0):o.unshift({id:mr(u.selectedVariant.id),merchandise:u.selectedVariant,isOptimistic:!0,quantity:u.quantity||1});}else if(i.action===G.ACTIONS.LinesRemove)for(let u of i.inputs.lineIds){let c=o.findIndex(s=>s.id===u);if(c!==-1){if(qe(o[c].id)){console.error("[h2:error:useOptimisticCart] Tried to remove an optimistic line that has not been added to the cart yet");continue}o.splice(c,1),a=!0;}else console.warn(`[h2:warn:useOptimisticCart] Tried to remove line '${u}' but it doesn't exist in the cart`);}else if(i.action===G.ACTIONS.LinesUpdate)for(let u of i.inputs.lines){let c=o.findIndex(s=>u.id===s.id);if(c>-1){if(qe(o[c].id)){console.error("[h2:error:useOptimisticCart] Tried to update an optimistic line that has not been added to the cart yet");continue}o[c].quantity=u.quantity,o[c].quantity===0&&o.splice(c,1),a=!0;}else console.warn(`[h2:warn:useOptimisticCart] Tried to update line '${u.id}' but it doesn't exist in the cart`);}}return a&&(r.isOptimistic=a),r}function ga({handle:e,options:t=[],variants:r=[],productPath:o="products",waitForNavigation:a=!1,children:n}){let i=r instanceof Array?r:flattenConnection(r),{searchParams:u,path:c,alreadyOnProductPage:s}=Pa(e,o,a),l=t.filter(y=>y?.values?.length===1);return createElement(Fragment,null,...useMemo(()=>t.map(y=>{let m,d=[];for(let p of y.values){let h=new URLSearchParams(s?u:void 0);h.set(y.name,p),l.forEach(_=>{h.set(_.name,_.values[0]);});let g=i.find(_=>_?.selectedOptions?.every(U=>h.get(U?.name)===U?.value)),f=u.get(y.name),T=f?f===p:!1;T&&(m=p);let I="?"+h.toString();d.push({value:p,isAvailable:g?g.availableForSale:!0,to:c+I,search:I,isActive:T,variant:g});}return n({option:{name:y.name,value:m,values:d}})}),[t,i,n]))}var Ca=e=>{if(typeof e?.url>"u")throw new TypeError(`Expected a Request instance, got ${typeof e}`);let t=new URL(e.url).searchParams,r=[];return t.forEach((o,a)=>{r.push({name:a,value:o});}),r};function Pa(e,t,r){let{pathname:o,search:a}=useLocation(),n=useNavigation();return useMemo(()=>{let i=/(\/[a-zA-Z]{2}-[a-zA-Z]{2}\/)/g.exec(o),u=i&&i.length>0;t=t.startsWith("/")?t.substring(1):t;let c=u?`${i[0]}${t}/${e}`:`/${t}/${e}`;return {searchParams:new URLSearchParams(r||n.state!=="loading"?a:n.location.search),alreadyOnProductPage:c===o,path:c}},[o,a,r,e,t,n])}function Ta(e,t){let r=useNavigation(),[o,a]=useState([]);if(useEffect(()=>{Promise.resolve(t).then(n=>{n&&a(n instanceof Array?n:n.product?.variants?.nodes||[]);}).catch(n=>{reportError(new Error("[h2:error:useOptimisticVariant] An error occurred while resolving the variants for the optimistic product hook.",{cause:n}));});},[t]),r.state==="loading"){let n=new URLSearchParams(r.location.search),i=!1,u=o.find(c=>c.selectedOptions?c.selectedOptions.every(s=>n.get(s.name)===s.value):(i||(i=!0,reportError(new Error("[h2:error:useOptimisticVariant] The optimistic product hook requires your product query to include variants with the selectedOptions field."))),!1));if(u)return {...u,isOptimistic:!0}}return e}var gr=createContext(void 0),Ea=gr.Provider,bt=()=>useContext(gr);function Oa(e){let t=Fe(),r=Da(t,e);return {nonce:t,header:r,NonceProvider:({children:a})=>createElement(Ea,{value:t},a)}}function Da(e,t){let{shop:r,...o}=t??{},a=`'nonce-${e}'`,n=["'self'","'unsafe-inline'","https://cdn.shopify.com"],i=["'self'","https://monorail-edge.shopifysvc.com"];r&&r.checkoutDomain&&i.push(`https://${r.checkoutDomain}`),r&&r.storeDomain&&i.push(`https://${r.storeDomain}`);let c={baseUri:["'self'"],defaultSrc:["'self'",a,"https://cdn.shopify.com","https://shopify.com"],frameAncestors:["'none'"],styleSrc:n,connectSrc:i},s=Object.assign({},c,o);for(let l in c){let y=o[l];l&&y&&(s[l]=xa(y,c[l]));}return s.scriptSrc instanceof Array&&!s.scriptSrc.includes(a)?s.scriptSrc.push(a):s.defaultSrc instanceof Array&&!s.defaultSrc.includes(a)&&s.defaultSrc.push(a),ba({directives:s})}function xa(e,t){let r=typeof t=="string"?[t]:t,o=Array.isArray(e)?e:[String(e)];return Array.isArray(r)?r.every(n=>n==="'none'")?o:[...o,...r]:r}var La=forwardRef((e,t)=>{let r=bt();return jsx("script",{suppressHydrationWarning:!0,...e,nonce:r,ref:t})});function Va(e){let t=useFetchers(),r={};for(let{formData:o}of t)if(o?.get("optimistic-identifier")===e)try{if(o.has("optimistic-data")){let a=JSON.parse(String(o.get("optimistic-data")));Object.assign(r,a);}}catch{}return r}function Na({id:e,data:t}){return jsxs(Fragment$1,{children:[jsx("input",{type:"hidden",name:"optimistic-identifier",value:e}),jsx("input",{type:"hidden",name:"optimistic-data",value:JSON.stringify(t)})]})}function $a(e){return jsx(ShopPayButton,{channel:"hydrogen",...e})}function pe(e){let{type:t,data:r={},customData:o}=e,a=useLocation(),{publish:n,cart:i,prevCart:u,shop:c,customData:s}=B(),l=a.pathname+a.search,y={...r,customData:{...s,...o},cart:i,prevCart:u,shop:c};return useEffect(()=>{c?.shopId&&(y={...y,url:window.location.href},n(t,y));},[n,l,c?.shopId]),null}function Pr(e){return jsx(pe,{...e,type:"page_viewed"})}function Sr(e){return jsx(pe,{...e,type:"product_viewed"})}function Ar(e){return jsx(pe,{...e,type:"collection_viewed"})}function vr(e){return jsx(pe,{...e,type:"cart_viewed"})}function Tr(e){return jsx(pe,{...e,type:"search_viewed"})}function Ir(e){return jsx(pe,{...e})}var L={PAGE_VIEWED:"page_viewed",PRODUCT_VIEWED:"product_viewed",COLLECTION_VIEWED:"collection_viewed",CART_VIEWED:"cart_viewed",SEARCH_VIEWED:"search_viewed",CART_UPDATED:"cart_updated",PRODUCT_ADD_TO_CART:"product_added_to_cart",PRODUCT_REMOVED_FROM_CART:"product_removed_from_cart",CUSTOM_EVENT:"custom_"};var ja="https://cdn.shopify.com/shopifycloud/consent-tracking-api/v0.1/consent-tracking-api.js",Ka="https://cdn.shopify.com/shopifycloud/privacy-banner/storefront-banner.js";function wr(e){console.error(`[h2:error:useCustomerPrivacy] Unable to setup Customer Privacy API: Missing consent.${e} configuration.`);}function Et(e){let{withPrivacyBanner:t=!0,onVisitorConsentCollected:r,onReady:o,...a}=e,n=useRef(!1),i=useLoadScript(t?Ka:ja,{attributes:{id:"customer-privacy-api"}});useEffect(()=>{let u=c=>{r&&r(c.detail);};return document.addEventListener("visitorConsentCollected",u),()=>{document.removeEventListener("visitorConsentCollected",u);}},[r]),useEffect(()=>{if(i!=="done"||n.current)return;n.current=!0;let{checkoutDomain:u,storefrontAccessToken:c}=a;u||wr("checkoutDomain"),c||wr("storefrontAccessToken"),(c.startsWith("shpat_")||c.length!==32)&&console.error("[h2:error:useCustomerPrivacy] It looks like you passed a private access token, make sure to use the public token");let s={checkoutRootDomain:u,storefrontAccessToken:c};if(u){let m=window.document.location.host,d=u.split(".").reverse(),p=m.split(".").reverse(),h=[];d.forEach((g,f)=>{g===p[f]&&h.push(g);}),m=h.reverse().join("."),m&&(s.storefrontRootDomain=m);}if(t&&window?.privacyBanner&&window.privacyBanner?.loadBanner(s),!window.Shopify?.customerPrivacy)return;let l=window.Shopify.customerPrivacy.setTrackingConsent;function y(m,d){l({...m,headlessStorefront:!0,...s},d);}window.Shopify.customerPrivacy.setTrackingConsent=y,o&&o();},[i,t,a]);}function Ot(){try{return window.Shopify&&window.Shopify.customerPrivacy?window.Shopify?.customerPrivacy:null}catch{return null}}function Xa(){let e=Ot();if(!e)throw new Error("Shopify Customer Privacy API not available. Must be used within a useEffect. Make sure to load the Shopify Customer Privacy API with useCustomerPrivacy() or <AnalyticsProvider>.");return e}function Er({consent:e,onReady:t,domain:r}){let{subscribe:o,register:a,canTrack:n}=B(),[i,u]=useState(!1),[c,s]=useState(!1),{ready:l}=a("Internal_Shopify_Analytics"),{ready:y}=a("Internal_Shopify_CustomerPrivacy"),m=()=>{i&&c&&t();},d=()=>{s(!0),y(),m();},{checkoutDomain:p,storefrontAccessToken:h,withPrivacyBanner:g}=e;return Et({checkoutDomain:p||"mock.shop",storefrontAccessToken:h||"abcdefghijklmnopqrstuvwxyz123456",withPrivacyBanner:g,onVisitorConsentCollected:d,onReady:()=>{setTimeout(d,3e3);}}),useShopifyCookies({hasUserConsent:i&&c?n():!0,domain:r,checkoutDomain:p}),useEffect(()=>{o(L.PAGE_VIEWED,en),o(L.PRODUCT_VIEWED,tn),o(L.COLLECTION_VIEWED,rn),o(L.SEARCH_VIEWED,on),o(L.PRODUCT_ADD_TO_CART,an),l(),u(!0),m();},[o,l]),null}function He(e){console.error(`[h2:error:ShopifyAnalytics] Unable to send Shopify analytics: Missing shop.${e} configuration.`);}function Re(e){let t=Xa(),r=t.analyticsProcessingAllowed();if(!e?.shop?.shopId){He("shopId");return}if(!e?.shop?.acceptedLanguage){He("acceptedLanguage");return}if(!e?.shop?.currency){He("currency");return}if(!e?.shop?.hydrogenSubchannelId){He("hydrogenSubchannelId");return}return {shopifySalesChannel:"hydrogen",...e.shop,hasUserConsent:r,...getClientBrowserParameters(),ccpaEnforced:!t.saleOfDataAllowed(),gdprEnforced:!(t.marketingAllowed()&&t.analyticsProcessingAllowed())}}function Za(e,t){if(t===null)return;let r=Re(e);return r?{...r,cartId:t.id}:void 0}var z={};function en(e){let t=Re(e);t&&(sendShopifyAnalytics({eventName:AnalyticsEventName.PAGE_VIEW_2,payload:{...t,...z}}),z={});}function tn(e){let t=Re(e);if(t&&Or({type:"product",products:e.products})){let r=Dt(e.products);z={pageType:AnalyticsPageType.product,resourceId:r[0].productGid},t={...t,...z,products:Dt(e.products)},sendShopifyAnalytics({eventName:AnalyticsEventName.PRODUCT_VIEW,payload:t});}}function rn(e){let t=Re(e);t&&(z={pageType:AnalyticsPageType.collection,resourceId:e.collection.id},t={...t,...z,collectionHandle:e.collection.handle},sendShopifyAnalytics({eventName:AnalyticsEventName.COLLECTION_VIEW,payload:t}));}function on(e){let t=Re(e);t&&(z={pageType:AnalyticsPageType.search},t={...t,...z,searchString:e.searchTerm},sendShopifyAnalytics({eventName:AnalyticsEventName.SEARCH_VIEW,payload:t}));}function an(e){let{cart:t,currentLine:r}=e,o=Za(e,t);!o||!r?.id||nn({matchedLine:r,eventPayload:o});}function nn({matchedLine:e,eventPayload:t}){let r={id:e.merchandise.product.id,variantId:e.id,title:e.merchandise.product.title,variantTitle:e.merchandise.title,vendor:e.merchandise.product.vendor,price:e.merchandise.price.amount,quantity:e.quantity,productType:e.merchandise.product.productType,sku:e.merchandise.sku};Or({type:"cart",products:[r]})&&sendShopifyAnalytics({eventName:AnalyticsEventName.ADD_TO_CART,payload:{...t,products:Dt([r])}});}function te(e,t,r,o){if(e==="cart"){let a=`${r?"merchandise":"merchandise.product"}.${t}`;console.error(`[h2:error:ShopifyAnalytics] Can't set up cart analytics events because the \`cart.lines[].${a}\` value is missing from your GraphQL cart query. In your project, search for where \`fragment CartLine on CartLine\` is defined and make sure \`${a}\` is part of your cart query. Check the Hydrogen Skeleton template for reference: https://github.com/Shopify/hydrogen/blob/main/templates/skeleton/app/lib/fragments.ts#L25-L56.`);}else {let a=`${o||t}`;console.error(`[h2:error:ShopifyAnalytics] Can't set up product view analytics events because the \`${a}\` is missing from your \`<Analytics.ProductView>\`. Make sure \`${a}\` is part of your products data prop. Check the Hydrogen Skeleton template for reference: https://github.com/Shopify/hydrogen/blob/main/templates/skeleton/app/routes/products.%24handle.tsx#L159-L165.`);}}function Or({type:e,products:t}){return !t||t.length===0?(te(e,"",!1,"data.products"),!1):(t.forEach(r=>{if(!r.id)return te(e,"id",!1),!1;if(!r.title)return te(e,"title",!1),!1;if(!r.price)return te(e,"price.amount",!0,"price"),!1;if(!r.vendor)return te(e,"vendor",!1),!1;if(!r.variantId)return te(e,"id",!0,"variantId"),!1;if(!r.variantTitle)return te(e,"title",!0,"variantTitle"),!1}),!0)}function Dt(e){return e.map(t=>{let r={productGid:t.id,variantGid:t.variantId,name:t.title,variantName:t.variantTitle,brand:t.vendor,price:t.price,quantity:t.quantity||1,category:t.productType};return t.sku&&(r.sku=t.sku),t.productType&&(r.category=t.productType),r})}function kr(e){console.error(`[h2:error:CartAnalytics] Can't set up cart analytics events because the \`cart.${e}\` value is missing from your GraphQL cart query. In your project, search for where \`fragment CartApiQuery on Cart\` is defined and make sure \`${e}\` is part of your cart query. Check the Hydrogen Skeleton template for reference: https://github.com/Shopify/hydrogen/blob/main/templates/skeleton/app/lib/fragments.ts#L59.`);}function Lr({cart:e,setCarts:t}){let{publish:r,shop:o,customData:a,canTrack:n,cart:i,prevCart:u}=B(),c=useRef(null);return useEffect(()=>{if(e)return Promise.resolve(e).then(s=>{if(s&&s.lines){if(!s.id){kr("id");return}if(!s.updatedAt){kr("updatedAt");return}}t(({cart:l,prevCart:y})=>s?.updatedAt!==l?.updatedAt?{cart:s,prevCart:l}:{cart:l,prevCart:y});}),()=>{}},[t,e]),useEffect(()=>{if(!i||!i?.updatedAt||i?.updatedAt===u?.updatedAt)return;let s;try{s=JSON.parse(localStorage.getItem("cartLastUpdatedAt")||"");}catch{s=null;}if(i.id===s?.id&&i.updatedAt===s?.updatedAt)return;let l={eventTimestamp:Date.now(),cart:i,prevCart:u,shop:o,customData:a};if(i.updatedAt===c.current)return;c.current=i.updatedAt,r("cart_updated",l),localStorage.setItem("cartLastUpdatedAt",JSON.stringify({id:i.id,updatedAt:i.updatedAt}));let y=u?.lines?flattenConnection(u?.lines):[],m=i.lines?flattenConnection(i.lines):[];y?.forEach(d=>{let p=m.filter(h=>d.id===h.id);if(p?.length===1){let h=p[0];d.quantity<h.quantity?r("product_added_to_cart",{...l,prevLine:d,currentLine:h}):d.quantity>h.quantity&&r("product_removed_from_cart",{...l,prevLine:d,currentLine:h});}else r("product_removed_from_cart",{...l,prevLine:d});}),m?.forEach(d=>{let p=y.filter(h=>d.id===h.id);(!p||p.length===0)&&r("product_added_to_cart",{...l,currentLine:d});});},[i,u,r,o,a,n]),null}var ln="https://cdn.shopify.com/shopifycloud/perf-kit/shopify-perf-kit-1bd852a.min.js";function _r({shop:e}){let t=useRef(!1),{subscribe:r,register:o}=B(),{ready:a}=o("Internal_Shopify_Perf_Kit"),n=useLoadScript(ln,{attributes:{id:"perfkit","data-application":"hydrogen","data-shop-id":parseGid(e.shopId).id.toString(),"data-storefront-id":e.hydrogenSubchannelId,"data-monorail-region":"global","data-spa-mode":"true","data-resource-timing-sampling-rate":"100"}});return useEffect(()=>{n!=="done"||t.current||(t.current=!0,r(L.PAGE_VIEWED,()=>{window.PerfKit?.navigate();}),r(L.PRODUCT_VIEWED,()=>{window.PerfKit?.setPageType("product");}),r(L.COLLECTION_VIEWED,()=>{window.PerfKit?.setPageType("collection");}),r(L.SEARCH_VIEWED,()=>{window.PerfKit?.setPageType("search");}),r(L.CART_VIEWED,()=>{window.PerfKit?.setPageType("cart");}),a());},[r,a,n]),null}var Cn={canTrack:()=>!1,cart:null,customData:{},prevCart:null,publish:()=>{},shop:null,subscribe:()=>{},register:()=>({ready:()=>{}})},qr=createContext(Cn),Be=new Map,we={};function $r(){return Object.values(we).every(Boolean)}function Ur(e,t){Be.has(e)||Be.set(e,new Map),Be.get(e)?.set(t.toString(),t);}var We=new Map;function Vr(e,t){if(!$r()){We.set(e,t);return}Hr(e,t);}function Hr(e,t){(Be.get(e)??new Map).forEach((r,o)=>{try{r(t);}catch(a){typeof a=="object"&&a instanceof Error?console.error("Analytics publish error",a.message,o,a.stack):console.error("Analytics publish error",a,o);}});}function Nr(e){return we.hasOwnProperty(e)||(we[e]=!1),{ready:()=>{we[e]=!0,$r()&&We.size>0&&(We.forEach((t,r)=>{Hr(r,t);}),We.clear());}}}function Mr(){try{return window.Shopify.customerPrivacy.analyticsProcessingAllowed()}catch{}return !1}function Fr(e,t){return `[h2:error:Analytics.Provider] - ${e} is required. Make sure ${t} is defined in your environment variables. See https://h2o.fyi/analytics/consent to learn how to setup environment variables in the Shopify admin.`}function Pn({canTrack:e,cart:t,children:r,consent:o,customData:a={},shop:n=null,disableThrowOnError:i=!1,cookieDomain:u}){let c=useRef(!1),{shop:s}=Sn(n),[l,y]=useState(!!e),[m,d]=useState({cart:null,prevCart:null}),[p,h]=useState(e?()=>e:()=>Mr);if(s)if(/\/68817551382$/.test(s.shopId))Bt("[h2:error:Analytics.Provider] - Mock shop is used. Analytics will not work properly.");else {if(!o.checkoutDomain){let f=Fr("consent.checkoutDomain","PUBLIC_CHECKOUT_DOMAIN");nt(f);}if(!o.storefrontAccessToken){let f=Fr("consent.storefrontAccessToken","PUBLIC_STOREFRONT_API_TOKEN");nt(f);}}let g=useMemo(()=>({canTrack:p,...m,customData:a,publish:p()?Vr:()=>{},shop:s,subscribe:Ur,register:Nr}),[l,p(),p,JSON.stringify(p),m,m.cart?.updatedAt,m.prevCart,Vr,Ur,a,s,Nr,JSON.stringify(we)]);return jsxs(qr.Provider,{value:g,children:[r,!!s&&jsx(Pr,{}),!!s&&!!t&&jsx(Lr,{cart:t,setCarts:d}),!!s&&o.checkoutDomain&&jsx(Er,{consent:o,onReady:()=>{c.current=!0,y(!0),h(()=>Mr);},domain:u}),!!s&&jsx(_r,{shop:s})]})}function B(){let e=useContext(qr);if(!e)throw new Error("[h2:error:useAnalytics] 'useAnalytics()' must be a descendent of <AnalyticsProvider/>");return e}function Sn(e){let[t,r]=useState(null);return useEffect(()=>(Promise.resolve(e).then(r),()=>{}),[r,e]),{shop:t}}async function An({storefront:e,publicStorefrontId:t="0"}){return e.query(vn,{cache:e.CacheLong()}).then(({shop:r,localization:o})=>({shopId:r.id,acceptedLanguage:o.language.isoCode,currency:o.country.currency.isoCode,hydrogenSubchannelId:t}))}var vn=`#graphql
621
+ `;var Ot=e=>{let t=parse(st(e,"Cookie")||"");return ()=>t.cart?`gid://shopify/Cart/${t.cart}`:void 0};var xt=e=>t=>{let r=new Headers;return r.append("Set-Cookie",stringify("cart",t.split("/").pop()||"",{path:"/",...e})),r};function Dt(e){let{getCartId:t,setCartId:r,storefront:o,customerAccount:n,cartQueryFragment:a,cartMutateFragment:s}=e,u=t(),i=()=>u||t(),c={storefront:o,getCartId:i,cartFragment:s,customerAccount:n},d=ht(c),l=async function(...p){let y=await d(...p);return u=y?.cart?.id,y},m={get:Ct({storefront:o,customerAccount:n,getCartId:i,cartFragment:a}),getCartId:i,setCartId:r,create:l,addLines:async(p,y)=>{let g=p.map(h=>({attributes:h.attributes,quantity:h.quantity,merchandiseId:h.merchandiseId,sellingPlanId:h.sellingPlanId}));return u||y?.cartId?await St(c)(g,y):await l({lines:g},y)},updateLines:Pt(c),removeLines:At(c),updateDiscountCodes:async(p,y)=>u||y?.cartId?await Tt(c)(p,y):await l({discountCodes:p},y),updateBuyerIdentity:async(p,y)=>u||y?.cartId?await vt(c)(p,y):await l({buyerIdentity:p},y),updateNote:async(p,y)=>u||y?.cartId?await It(c)(p,y):await l({note:p},y),updateSelectedDeliveryOption:Rt(c),updateAttributes:async(p,y)=>u||y?.cartId?await bt(c)(p,y):await l({attributes:p},y),setMetafields:async(p,y)=>u||y?.cartId?await Et(c)(p,y):await l({metafields:p},y),deleteMetafield:wt(c)};return "customMethods"in e?{...m,...e.customMethods??{}}:m}function mn(e){let t=useFetchers();if(!t||!t.length)return e;let r=e?.lines?structuredClone(e):{lines:{nodes:[]}},o=r.lines.nodes,n=!1;for(let{formData:a}of t){if(!a)continue;let s=G.getFormInput(a);if(s.action===G.ACTIONS.LinesAdd)for(let u of s.inputs.lines){if(!u.selectedVariant){console.error("[h2:error:useOptimisticCart] No selected variant was passed in the cart action. Make sure to pass the selected variant if you want to use an optimistic cart");continue}let i=o.find(c=>c.merchandise.id===u.selectedVariant?.id);n=!0,i?(i.quantity=(i.quantity||1)+(u.quantity||1),i.isOptimistic=!0):o.unshift({id:Ar(u.selectedVariant.id),merchandise:u.selectedVariant,isOptimistic:!0,quantity:u.quantity||1});}else if(s.action===G.ACTIONS.LinesRemove)for(let u of s.inputs.lineIds){let i=o.findIndex(c=>c.id===u);if(i!==-1){if(Fe(o[i].id)){console.error("[h2:error:useOptimisticCart] Tried to remove an optimistic line that has not been added to the cart yet");continue}o.splice(i,1),n=!0;}else console.warn(`[h2:warn:useOptimisticCart] Tried to remove line '${u}' but it doesn't exist in the cart`);}else if(s.action===G.ACTIONS.LinesUpdate)for(let u of s.inputs.lines){let i=o.findIndex(c=>u.id===c.id);if(i>-1){if(Fe(o[i].id)){console.error("[h2:error:useOptimisticCart] Tried to update an optimistic line that has not been added to the cart yet");continue}o[i].quantity=u.quantity,o[i].quantity===0&&o.splice(i,1),n=!0;}else console.warn(`[h2:warn:useOptimisticCart] Tried to update line '${u.id}' but it doesn't exist in the cart`);}}return n&&(r.isOptimistic=n),r}function An({handle:e,options:t=[],variants:r=[],productPath:o="products",waitForNavigation:n=!1,children:a}){let s=r instanceof Array?r:flattenConnection(r),{searchParams:u,path:i,alreadyOnProductPage:c}=vn(e,o,n),d=t.filter(l=>l?.values?.length===1);return createElement(Fragment,null,...useMemo(()=>t.map(l=>{let m,p=[];for(let y of l.values){let g=new URLSearchParams(c?u:void 0);g.set(l.name,y),d.forEach(k=>{g.set(k.name,k.values[0]);});let h=s.find(k=>k?.selectedOptions?.every(_=>g.get(_?.name)===_?.value)),f=u.get(l.name),v=f?f===y:!1;v&&(m=y);let I="?"+g.toString();p.push({value:y,isAvailable:h?h.availableForSale:!0,to:i+I,search:I,isActive:v,variant:h});}return a({option:{name:l.name,value:m,values:p}})}),[t,s,a]))}var Tn=e=>{if(typeof e?.url>"u")throw new TypeError(`Expected a Request instance, got ${typeof e}`);let t=new URL(e.url).searchParams,r=[];return t.forEach((o,n)=>{r.push({name:n,value:o});}),r};function vn(e,t,r){let{pathname:o,search:n}=useLocation(),a=useNavigation();return useMemo(()=>{let s=/(\/[a-zA-Z]{2}-[a-zA-Z]{2}\/)/g.exec(o),u=s&&s.length>0;t=t.startsWith("/")?t.substring(1):t;let i=u?`${s[0]}${t}/${e}`:`/${t}/${e}`;return {searchParams:new URLSearchParams(r||a.state!=="loading"?n:a.location.search),alreadyOnProductPage:i===o,path:i}},[o,n,r,e,t,a])}function En(e,t){let r=useNavigation(),[o,n]=useState([]);if(useEffect(()=>{Promise.resolve(t).then(a=>{a&&n(a instanceof Array?a:a.product?.variants?.nodes||[]);}).catch(a=>{reportError(new Error("[h2:error:useOptimisticVariant] An error occurred while resolving the variants for the optimistic product hook.",{cause:a}));});},[t]),r.state==="loading"){let a=new URLSearchParams(r.location.search),s=!1,u=o.find(i=>i.selectedOptions?i.selectedOptions.every(c=>a.get(c.name)===c.value):(s||(s=!0,reportError(new Error("[h2:error:useOptimisticVariant] The optimistic product hook requires your product query to include variants with the selectedOptions field."))),!1));if(u)return {...u,isOptimistic:!0}}return e}var vr=createContext(void 0),Ln=vr.Provider,Lt=()=>useContext(vr);function Un(e){let t=He(),r=kn(t,e);return {nonce:t,header:r,NonceProvider:({children:n})=>createElement(Ln,{value:t},n)}}function kn(e,t){let{shop:r,...o}=t??{},n=`'nonce-${e}'`,a=["'self'","'unsafe-inline'","https://cdn.shopify.com"],s=["'self'","https://monorail-edge.shopifysvc.com"];r&&r.checkoutDomain&&s.push(`https://${r.checkoutDomain}`),r&&r.storeDomain&&s.push(`https://${r.storeDomain}`);let i={baseUri:["'self'"],defaultSrc:["'self'",n,"https://cdn.shopify.com","https://shopify.com"],frameAncestors:["'none'"],styleSrc:a,connectSrc:s},c=Object.assign({},i,o);for(let d in i){let l=o[d];d&&l&&(c[d]=_n(l,i[d]));}return c.scriptSrc instanceof Array&&!c.scriptSrc.includes(n)?c.scriptSrc.push(n):c.defaultSrc instanceof Array&&!c.defaultSrc.includes(n)&&c.defaultSrc.push(n),Dn({directives:c})}function _n(e,t){let r=typeof t=="string"?[t]:t,o=Array.isArray(e)?e:[String(e)];return Array.isArray(r)?r.every(a=>a==="'none'")?o:[...o,...r]:r}var Mn=forwardRef((e,t)=>{let{waitForHydration:r,src:o,...n}=e;if(r)return jsx(Hn,{src:o,options:n});let a=Lt();return jsx("script",{suppressHydrationWarning:!0,...n,src:o,nonce:a,ref:t})});function Hn({src:e,options:t}){if(!e)throw new Error("`waitForHydration` with the Script component requires a `src` prop");return useLoadScript(e,{attributes:t}),null}function qn(e){let t=useFetchers(),r={};for(let{formData:o}of t)if(o?.get("optimistic-identifier")===e)try{if(o.has("optimistic-data")){let n=JSON.parse(String(o.get("optimistic-data")));Object.assign(r,n);}}catch{}return r}function $n({id:e,data:t}){return jsxs(Fragment$1,{children:[jsx("input",{type:"hidden",name:"optimistic-identifier",value:e}),jsx("input",{type:"hidden",name:"optimistic-data",value:JSON.stringify(t)})]})}function Wn(e){return jsx(ShopPayButton,{channel:"hydrogen",...e})}function de(e){let{type:t,data:r={},customData:o}=e,n=useLocation(),{publish:a,cart:s,prevCart:u,shop:i,customData:c}=W(),d=n.pathname+n.search,l={...r,customData:{...c,...o},cart:s,prevCart:u,shop:i};return useEffect(()=>{i?.shopId&&(l={...l,url:window.location.href},a(t,l));},[a,d,i?.shopId]),null}function br(e){return jsx(de,{...e,type:"page_viewed"})}function Er(e){return jsx(de,{...e,type:"product_viewed"})}function wr(e){return jsx(de,{...e,type:"collection_viewed"})}function Or(e){return jsx(de,{...e,type:"cart_viewed"})}function xr(e){return jsx(de,{...e,type:"search_viewed"})}function Dr(e){return jsx(de,{...e})}var U={PAGE_VIEWED:"page_viewed",PRODUCT_VIEWED:"product_viewed",COLLECTION_VIEWED:"collection_viewed",CART_VIEWED:"cart_viewed",SEARCH_VIEWED:"search_viewed",CART_UPDATED:"cart_updated",PRODUCT_ADD_TO_CART:"product_added_to_cart",PRODUCT_REMOVED_FROM_CART:"product_removed_from_cart",CUSTOM_EVENT:"custom_"};var Xn="https://cdn.shopify.com/shopifycloud/consent-tracking-api/v0.1/consent-tracking-api.js",Zn="https://cdn.shopify.com/shopifycloud/privacy-banner/storefront-banner.js";function Ur(e){console.error(`[h2:error:useCustomerPrivacy] Unable to setup Customer Privacy API: Missing consent.${e} configuration.`);}function Ut(e){let{withPrivacyBanner:t=!0,onVisitorConsentCollected:r,onReady:o,...n}=e,a=useRef(!1),s=useLoadScript(t?Zn:Xn,{attributes:{id:"customer-privacy-api"}});useEffect(()=>{let u=i=>{r&&r(i.detail);};return document.addEventListener("visitorConsentCollected",u),()=>{document.removeEventListener("visitorConsentCollected",u);}},[r]),useEffect(()=>{if(s!=="done"||a.current)return;a.current=!0;let{checkoutDomain:u,storefrontAccessToken:i}=n;u||Ur("checkoutDomain"),i||Ur("storefrontAccessToken"),(i.startsWith("shpat_")||i.length!==32)&&console.error("[h2:error:useCustomerPrivacy] It looks like you passed a private access token, make sure to use the public token");let c={checkoutRootDomain:u,storefrontAccessToken:i};if(u){let m=window.document.location.host,p=u.split(".").reverse(),y=m.split(".").reverse(),g=[];p.forEach((h,f)=>{h===y[f]&&g.push(h);}),m=g.reverse().join("."),m&&(c.storefrontRootDomain=m);}if(t&&window?.privacyBanner&&window.privacyBanner?.loadBanner(c),!window.Shopify?.customerPrivacy)return;let d=window.Shopify.customerPrivacy.setTrackingConsent;function l(m,p){d({...m,headlessStorefront:!0,...c},p);}window.Shopify.customerPrivacy.setTrackingConsent=l,o&&o();},[s,t,n]);}function kt(){try{return window.Shopify&&window.Shopify.customerPrivacy?window.Shopify?.customerPrivacy:null}catch{return null}}function na(){let e=kt();if(!e)throw new Error("Shopify Customer Privacy API not available. Must be used within a useEffect. Make sure to load the Shopify Customer Privacy API with useCustomerPrivacy() or <AnalyticsProvider>.");return e}function _r({consent:e,onReady:t,domain:r}){let{subscribe:o,register:n,canTrack:a}=W(),[s,u]=useState(!1),[i,c]=useState(!1),d=useRef(!1),{ready:l}=n("Internal_Shopify_Analytics"),{ready:m}=n("Internal_Shopify_CustomerPrivacy"),p=()=>{s&&i&&t();},y=()=>{c(!0),m(),p();},{checkoutDomain:g,storefrontAccessToken:h,withPrivacyBanner:f}=e;return Ut({checkoutDomain:g||"mock.shop",storefrontAccessToken:h||"abcdefghijklmnopqrstuvwxyz123456",withPrivacyBanner:f,onVisitorConsentCollected:y,onReady:()=>{setTimeout(y,3e3);}}),useShopifyCookies({hasUserConsent:s&&i?a():!0,domain:r,checkoutDomain:g}),useEffect(()=>{d.current||(d.current=!0,o(U.PAGE_VIEWED,sa),o(U.PRODUCT_VIEWED,ia),o(U.COLLECTION_VIEWED,ca),o(U.SEARCH_VIEWED,ua),o(U.PRODUCT_ADD_TO_CART,pa),l(),u(!0),p());},[o,l]),null}function $e(e){console.error(`[h2:error:ShopifyAnalytics] Unable to send Shopify analytics: Missing shop.${e} configuration.`);}function be(e){let t=na(),r=t.analyticsProcessingAllowed();if(!e?.shop?.shopId){$e("shopId");return}if(!e?.shop?.acceptedLanguage){$e("acceptedLanguage");return}if(!e?.shop?.currency){$e("currency");return}if(!e?.shop?.hydrogenSubchannelId){$e("hydrogenSubchannelId");return}return {shopifySalesChannel:"hydrogen",...e.shop,hasUserConsent:r,...getClientBrowserParameters(),ccpaEnforced:!t.saleOfDataAllowed(),gdprEnforced:!(t.marketingAllowed()&&t.analyticsProcessingAllowed())}}function aa(e,t){if(t===null)return;let r=be(e);return r?{...r,cartId:t.id}:void 0}var J={};function sa(e){let t=be(e);t&&(sendShopifyAnalytics({eventName:AnalyticsEventName.PAGE_VIEW_2,payload:{...t,...J}}),J={});}function ia(e){let t=be(e);if(t&&Vr({type:"product",products:e.products})){let r=_t(e.products);J={pageType:AnalyticsPageType.product,resourceId:r[0].productGid},t={...t,...J,products:_t(e.products)},sendShopifyAnalytics({eventName:AnalyticsEventName.PRODUCT_VIEW,payload:t});}}function ca(e){let t=be(e);t&&(J={pageType:AnalyticsPageType.collection,resourceId:e.collection.id},t={...t,...J,collectionHandle:e.collection.handle},sendShopifyAnalytics({eventName:AnalyticsEventName.COLLECTION_VIEW,payload:t}));}function ua(e){let t=be(e);t&&(J={pageType:AnalyticsPageType.search},t={...t,...J,searchString:e.searchTerm},sendShopifyAnalytics({eventName:AnalyticsEventName.SEARCH_VIEW,payload:t}));}function pa(e){let{cart:t,currentLine:r}=e,o=aa(e,t);!o||!r?.id||da({matchedLine:r,eventPayload:o});}function da({matchedLine:e,eventPayload:t}){let r={id:e.merchandise.product.id,variantId:e.id,title:e.merchandise.product.title,variantTitle:e.merchandise.title,vendor:e.merchandise.product.vendor,price:e.merchandise.price.amount,quantity:e.quantity,productType:e.merchandise.product.productType,sku:e.merchandise.sku};Vr({type:"cart",products:[r]})&&sendShopifyAnalytics({eventName:AnalyticsEventName.ADD_TO_CART,payload:{...t,products:_t([r])}});}function re(e,t,r,o){if(e==="cart"){let n=`${r?"merchandise":"merchandise.product"}.${t}`;console.error(`[h2:error:ShopifyAnalytics] Can't set up cart analytics events because the \`cart.lines[].${n}\` value is missing from your GraphQL cart query. In your project, search for where \`fragment CartLine on CartLine\` is defined and make sure \`${n}\` is part of your cart query. Check the Hydrogen Skeleton template for reference: https://github.com/Shopify/hydrogen/blob/main/templates/skeleton/app/lib/fragments.ts#L25-L56.`);}else {let n=`${o||t}`;console.error(`[h2:error:ShopifyAnalytics] Can't set up product view analytics events because the \`${n}\` is missing from your \`<Analytics.ProductView>\`. Make sure \`${n}\` is part of your products data prop. Check the Hydrogen Skeleton template for reference: https://github.com/Shopify/hydrogen/blob/main/templates/skeleton/app/routes/products.%24handle.tsx#L159-L165.`);}}function Vr({type:e,products:t}){return !t||t.length===0?(re(e,"",!1,"data.products"),!1):(t.forEach(r=>{if(!r.id)return re(e,"id",!1),!1;if(!r.title)return re(e,"title",!1),!1;if(!r.price)return re(e,"price.amount",!0,"price"),!1;if(!r.vendor)return re(e,"vendor",!1),!1;if(!r.variantId)return re(e,"id",!0,"variantId"),!1;if(!r.variantTitle)return re(e,"title",!0,"variantTitle"),!1}),!0)}function _t(e){return e.map(t=>{let r={productGid:t.id,variantGid:t.variantId,name:t.title,variantName:t.variantTitle,brand:t.vendor,price:t.price,quantity:t.quantity||1,category:t.productType};return t.sku&&(r.sku=t.sku),t.productType&&(r.category=t.productType),r})}function Hr(e){console.error(`[h2:error:CartAnalytics] Can't set up cart analytics events because the \`cart.${e}\` value is missing from your GraphQL cart query. In your project, search for where \`fragment CartApiQuery on Cart\` is defined and make sure \`${e}\` is part of your cart query. Check the Hydrogen Skeleton template for reference: https://github.com/Shopify/hydrogen/blob/main/templates/skeleton/app/lib/fragments.ts#L59.`);}function Fr({cart:e,setCarts:t}){let{publish:r,shop:o,customData:n,canTrack:a,cart:s,prevCart:u}=W(),i=useRef(null);return useEffect(()=>{if(e)return Promise.resolve(e).then(c=>{if(c&&c.lines){if(!c.id){Hr("id");return}if(!c.updatedAt){Hr("updatedAt");return}}t(({cart:d,prevCart:l})=>c?.updatedAt!==d?.updatedAt?{cart:c,prevCart:d}:{cart:d,prevCart:l});}),()=>{}},[t,e]),useEffect(()=>{if(!s||!s?.updatedAt||s?.updatedAt===u?.updatedAt)return;let c;try{c=JSON.parse(localStorage.getItem("cartLastUpdatedAt")||"");}catch{c=null;}if(s.id===c?.id&&s.updatedAt===c?.updatedAt)return;let d={eventTimestamp:Date.now(),cart:s,prevCart:u,shop:o,customData:n};if(s.updatedAt===i.current)return;i.current=s.updatedAt,r("cart_updated",d),localStorage.setItem("cartLastUpdatedAt",JSON.stringify({id:s.id,updatedAt:s.updatedAt}));let l=u?.lines?flattenConnection(u?.lines):[],m=s.lines?flattenConnection(s.lines):[];l?.forEach(p=>{let y=m.filter(g=>p.id===g.id);if(y?.length===1){let g=y[0];p.quantity<g.quantity?r("product_added_to_cart",{...d,prevLine:p,currentLine:g}):p.quantity>g.quantity&&r("product_removed_from_cart",{...d,prevLine:p,currentLine:g});}else r("product_removed_from_cart",{...d,prevLine:p});}),m?.forEach(p=>{let y=l.filter(g=>p.id===g.id);(!y||y.length===0)&&r("product_added_to_cart",{...d,currentLine:p});});},[s,u,r,o,n,a]),null}var ha="https://cdn.shopify.com/shopifycloud/perf-kit/shopify-perf-kit-1bd852a.min.js";function qr({shop:e}){let t=useRef(!1),{subscribe:r,register:o}=W(),{ready:n}=o("Internal_Shopify_Perf_Kit"),a=useLoadScript(ha,{attributes:{id:"perfkit","data-application":"hydrogen","data-shop-id":parseGid(e.shopId).id.toString(),"data-storefront-id":e.hydrogenSubchannelId,"data-monorail-region":"global","data-spa-mode":"true","data-resource-timing-sampling-rate":"100"}});return useEffect(()=>{a!=="done"||t.current||(t.current=!0,r(U.PAGE_VIEWED,()=>{window.PerfKit?.navigate();}),r(U.PRODUCT_VIEWED,()=>{window.PerfKit?.setPageType("product");}),r(U.COLLECTION_VIEWED,()=>{window.PerfKit?.setPageType("collection");}),r(U.SEARCH_VIEWED,()=>{window.PerfKit?.setPageType("search");}),r(U.CART_VIEWED,()=>{window.PerfKit?.setPageType("cart");}),n());},[r,n,a]),null}var va={canTrack:()=>!1,cart:null,customData:{},prevCart:null,publish:()=>{},shop:null,subscribe:()=>{},register:()=>({ready:()=>{}})},jr=createContext(va),Ge=new Map,Ee={};function Kr(){return Object.values(Ee).every(Boolean)}function $r(e,t){Ge.has(e)||Ge.set(e,new Map),Ge.get(e)?.set(t.toString(),t);}var We=new Map;function Br(e,t){if(!Kr()){We.set(e,t);return}zr(e,t);}function zr(e,t){(Ge.get(e)??new Map).forEach((r,o)=>{try{r(t);}catch(n){typeof n=="object"&&n instanceof Error?console.error("Analytics publish error",n.message,o,n.stack):console.error("Analytics publish error",n,o);}});}function Qr(e){return Ee.hasOwnProperty(e)||(Ee[e]=!1),{ready:()=>{Ee[e]=!0,Kr()&&We.size>0&&(We.forEach((t,r)=>{zr(r,t);}),We.clear());}}}function Gr(){try{return window.Shopify.customerPrivacy.analyticsProcessingAllowed()}catch{}return !1}function Wr(e,t){return `[h2:error:Analytics.Provider] - ${e} is required. Make sure ${t} is defined in your environment variables. See https://h2o.fyi/analytics/consent to learn how to setup environment variables in the Shopify admin.`}function Ia({canTrack:e,cart:t,children:r,consent:o,customData:n={},shop:a=null,cookieDomain:s}){let u=useRef(!1),{shop:i}=Ra(a),[c,d]=useState(!!e),[l,m]=useState({cart:null,prevCart:null}),[p,y]=useState(e?()=>e:()=>Gr);if(i)if(/\/68817551382$/.test(i.shopId))Jt("[h2:error:Analytics.Provider] - Mock shop is used. Analytics will not work properly.");else {if(!o.checkoutDomain){let h=Wr("consent.checkoutDomain","PUBLIC_CHECKOUT_DOMAIN");at(h);}if(!o.storefrontAccessToken){let h=Wr("consent.storefrontAccessToken","PUBLIC_STOREFRONT_API_TOKEN");at(h);}}let g=useMemo(()=>({canTrack:p,...l,customData:n,publish:p()?Br:()=>{},shop:i,subscribe:$r,register:Qr}),[c,p(),p,JSON.stringify(p),l,l.cart?.updatedAt,l.prevCart,Br,$r,n,i,Qr,JSON.stringify(Ee)]);return jsxs(jr.Provider,{value:g,children:[r,!!i&&jsx(br,{}),!!i&&!!t&&jsx(Fr,{cart:t,setCarts:m}),!!i&&o.checkoutDomain&&jsx(_r,{consent:o,onReady:()=>{u.current=!0,d(!0),y(()=>Gr);},domain:s}),!!i&&jsx(qr,{shop:i})]})}function W(){let e=useContext(jr);if(!e)throw new Error("[h2:error:useAnalytics] 'useAnalytics()' must be a descendent of <AnalyticsProvider/>");return e}function Ra(e){let[t,r]=useState(null);return useEffect(()=>(Promise.resolve(e).then(r),()=>{}),[r,e]),{shop:t}}async function ba({storefront:e,publicStorefrontId:t="0"}){return e.query(Ea,{cache:e.CacheLong()}).then(({shop:r,localization:o})=>({shopId:r.id,acceptedLanguage:o.language.isoCode,currency:o.country.currency.isoCode,hydrogenSubchannelId:t}))}var Ea=`#graphql
622
622
  query ShopData(
623
623
  $country: CountryCode
624
624
  $language: LanguageCode
@@ -637,7 +637,7 @@ API response error: ${t.status}`,s=new X(c,{query:a,queryVariables:n,cause:{erro
637
637
  }
638
638
  }
639
639
  }
640
- `,Tn={CartView:vr,CollectionView:Ar,CustomView:Ir,ProductView:Sr,Provider:Pn,SearchView:Tr};var bn=function(e){return jsx(RichText,{...e,components:{link:({node:t})=>jsx(Link,{to:t.url,title:t.title,target:t.target,prefetch:"intent",children:t.children}),...e.components}})};//! @see: https://shopify.dev/docs/api/storefront/latest/mutations/cartCreate
640
+ `,wa={CartView:Or,CollectionView:wr,CustomView:Dr,ProductView:Er,Provider:Ia,SearchView:xr};var La=function(e){return jsx(RichText,{...e,components:{link:({node:t})=>jsx(Link,{to:t.url,title:t.title,target:t.target,prefetch:"intent",children:t.children}),...e.components}})};function Ua(e){let{env:t,request:r,cache:o,waitUntil:n,i18n:a,session:s,logErrors:u,storefront:i={},customerAccount:c,cart:d={}}=e;s||console.warn("[h2:warn:createHydrogenContext] A session object is required to create hydrogen context.");let{storefront:l}=er({cache:o,waitUntil:n,i18n:a,logErrors:u,storefrontHeaders:i.headers||ka(r),storefrontApiVersion:i.apiVersion,storefrontId:t.PUBLIC_STOREFRONT_ID,storeDomain:t.PUBLIC_STORE_DOMAIN,privateStorefrontToken:t.PRIVATE_STOREFRONT_API_TOKEN,publicStorefrontToken:t.PUBLIC_STOREFRONT_API_TOKEN}),m=gt({session:s,request:r,waitUntil:n,logErrors:u,customerApiVersion:c?.apiVersion,authUrl:c?.authUrl,customAuthStatusHandler:c?.customAuthStatusHandler,unstableB2b:c?.unstableB2b,customerAccountId:t.PUBLIC_CUSTOMER_ACCOUNT_API_CLIENT_ID,customerAccountUrl:t.PUBLIC_CUSTOMER_ACCOUNT_API_URL}),p=Dt({getCartId:d.getId||Ot(r.headers),setCartId:d.setId||xt(),cartQueryFragment:d.queryFragment,cartMutateFragment:d.mutateFragment,customMethods:d.customMethods,storefront:l,customerAccount:m});return {storefront:l,customerAccount:m,cart:p,env:t,waitUntil:n,session:s}}function ka(e){return {requestGroupId:$(e,"request-id"),buyerIp:$(e,"oxygen-buyer-ip"),cookie:$(e,"cookie"),purpose:$(e,"purpose")}}//! @see: https://shopify.dev/docs/api/storefront/latest/mutations/cartCreate
641
641
  //! @see https://shopify.dev/docs/api/storefront/latest/queries/cart
642
642
  //! @see: https://shopify.dev/docs/api/storefront/latest/mutations/cartLinesAdd
643
643
  //! @see: https://shopify.dev/docs/api/storefront/latest/mutations/cartLinesUpdate
@@ -649,6 +649,6 @@ API response error: ${t.status}`,s=new X(c,{query:a,queryVariables:n,cause:{erro
649
649
  //! @see https://shopify.dev/docs/api/storefront/latest/mutations/cartMetafieldsSet
650
650
  //! @see https://shopify.dev/docs/api/storefront/2024-07/mutations/cartMetafieldDelete
651
651
 
652
- export { Tn as Analytics, L as AnalyticsEvent, Ye as CacheCustom, Je as CacheLong, Ke as CacheNone, J as CacheShort, G as CartForm, it as InMemoryCache, Na as OptimisticInput, Eo as Pagination, bn as RichText, La as Script, vo as Seo, $a as ShopPayButton, ga as VariantSelector, It as cartAttributesUpdateDefault, At as cartBuyerIdentityUpdateDefault, mt as cartCreateDefault, St as cartDiscountCodesUpdateDefault, ht as cartGetDefault, ia as cartGetIdDefault, gt as cartLinesAddDefault, Pt as cartLinesRemoveDefault, Ct as cartLinesUpdateDefault, wt as cartMetafieldDeleteDefault, Rt as cartMetafieldsSetDefault, vt as cartNoteUpdateDefault, Tt as cartSelectedDeliveryOptionsUpdateDefault, ca as cartSetIdDefault, $o as changelogHandler, ua as createCartHandler, Oa as createContentSecurityPolicy, Fo as createCustomerAccountClient, si as createStorefrontClient, co as createWithCache, S as formatAPIResult, fe as generateCacheControlHeader, Ot as getCustomerPrivacy, Do as getPaginationVariables, Ca as getSelectedProductOptions, To as getSeoMeta, An as getShopAnalytics, yo as graphiqlLoader, po as storefrontRedirect, B as useAnalytics, Et as useCustomerPrivacy, bt as useNonce, da as useOptimisticCart, Va as useOptimisticData, Ta as useOptimisticVariant };
652
+ export { wa as Analytics, U as AnalyticsEvent, Ye as CacheCustom, Je as CacheLong, Ke as CacheNone, Y as CacheShort, G as CartForm, it as InMemoryCache, $n as OptimisticInput, _o as Pagination, La as RichText, Mn as Script, Oo as Seo, Wn as ShopPayButton, An as VariantSelector, bt as cartAttributesUpdateDefault, vt as cartBuyerIdentityUpdateDefault, ht as cartCreateDefault, Tt as cartDiscountCodesUpdateDefault, Ct as cartGetDefault, Ot as cartGetIdDefault, St as cartLinesAddDefault, At as cartLinesRemoveDefault, Pt as cartLinesUpdateDefault, wt as cartMetafieldDeleteDefault, Et as cartMetafieldsSetDefault, It as cartNoteUpdateDefault, Rt as cartSelectedDeliveryOptionsUpdateDefault, xt as cartSetIdDefault, jo as changelogHandler, Dt as createCartHandler, Un as createContentSecurityPolicy, gt as createCustomerAccountClient, Ua as createHydrogenContext, er as createStorefrontClient, go as createWithCache, P as formatAPIResult, me as generateCacheControlHeader, kt as getCustomerPrivacy, No as getPaginationVariables, Tn as getSelectedProductOptions, xo as getSeoMeta, ba as getShopAnalytics, Po as graphiqlLoader, Co as storefrontRedirect, W as useAnalytics, Ut as useCustomerPrivacy, Lt as useNonce, mn as useOptimisticCart, qn as useOptimisticData, En as useOptimisticVariant };
653
653
  //# sourceMappingURL=out.js.map
654
654
  //# sourceMappingURL=index.js.map