@shopify/hydrogen-react 2025.1.1 → 2025.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-dev/packages/hydrogen-react/package.json.mjs +1 -1
- package/dist/browser-prod/packages/hydrogen-react/package.json.mjs +1 -1
- package/dist/node-dev/packages/hydrogen-react/package.json.js +1 -1
- package/dist/node-dev/packages/hydrogen-react/package.json.mjs +1 -1
- package/dist/node-prod/packages/hydrogen-react/package.json.js +1 -1
- package/dist/node-prod/packages/hydrogen-react/package.json.mjs +1 -1
- package/dist/umd/hydrogen-react.dev.js +1 -1
- package/dist/umd/hydrogen-react.prod.js +1 -1
- package/package.json +1 -2
|
@@ -2405,7 +2405,7 @@ Refer to the authentication https://shopify.dev/api/storefront#authentication do
|
|
|
2405
2405
|
}
|
|
2406
2406
|
return false;
|
|
2407
2407
|
}
|
|
2408
|
-
const version = "2025.1.
|
|
2408
|
+
const version = "2025.1.2";
|
|
2409
2409
|
const SCHEMA_ID = "custom_storefront_customer_tracking/1.2";
|
|
2410
2410
|
const PAGE_RENDERED_EVENT_NAME = "page_rendered";
|
|
2411
2411
|
const COLLECTION_PAGE_RENDERED_EVENT_NAME = "collection_page_rendered";
|
|
@@ -269,7 +269,7 @@
|
|
|
269
269
|
height
|
|
270
270
|
}
|
|
271
271
|
`,ie="2025-01",jr="mock.shop",Ve=e=>e.includes(jr);function $r({storeDomain:e,privateStorefrontToken:t,publicStorefrontToken:r,storefrontApiVersion:n=ie,contentType:a}){if(!e)throw new Error(Ue+"`storeDomain` is required when creating a new Storefront client in production.");n!==ie&&qr(`The Storefront API version that you're using is different than the version this build of Hydrogen React is targeting.
|
|
272
|
-
You may run into unexpected errors if these versions don't match. Received version: "${n}"; expected version "${ie}"`);const i=s=>{const o=(s==null?void 0:s.storeDomain)??e;return o.includes("://")?o:`https://${o}`};return{getShopifyDomain:i,getStorefrontApiUrl(s){const o=i(s),u=o+(o.endsWith("/")?"api":"/api");return Ve(o)?u:`${u}/${(s==null?void 0:s.storefrontApiVersion)??n}/graphql.json`},getPrivateTokenHeaders(s){if(!t&&!(s!=null&&s.privateStorefrontToken)&&!Ve(e))throw new Error(Ue+"You did not pass in a `privateStorefrontToken` while using `createStorefrontClient()` or `getPrivateTokenHeaders()`");return{"content-type":((s==null?void 0:s.contentType)??a)==="graphql"?"application/graphql":"application/json","X-SDK-Variant":"hydrogen-react","X-SDK-Variant-Source":"react","X-SDK-Version":n,"Shopify-Storefront-Private-Token":(s==null?void 0:s.privateStorefrontToken)??t??"",...s!=null&&s.buyerIp?{"Shopify-Storefront-Buyer-IP":s.buyerIp}:{}}},getPublicTokenHeaders(s){if(!r&&!(s!=null&&s.publicStorefrontToken)&&!Ve(e))throw new Error(Ue+"You did not pass in a `publicStorefrontToken` while using `createStorefrontClient()` or `getPublicTokenHeaders()`");const o=(s==null?void 0:s.contentType)??a??"json";return it(o,n,(s==null?void 0:s.publicStorefrontToken)??r??"")}}}function it(e,t,r){return{"content-type":e==="graphql"?"application/graphql":"application/json","X-SDK-Variant":"hydrogen-react","X-SDK-Variant-Source":"react","X-SDK-Version":t,"X-Shopify-Storefront-Access-Token":r}}const ot=new Set,Ue="[h2:error:createStorefrontClient] ",qr=(e,t="warn")=>{ot.has(e)||(console[t](`[h2:${t}:createStorefrontClient] `+e),ot.add(e))},st={storeDomain:"test",storefrontToken:"abc123",storefrontApiVersion:ie,countryIsoCode:"US",languageIsoCode:"EN",getStorefrontApiUrl(){return""},getPublicTokenHeaders(){return{}},getShopifyDomain(){return""}},ct=c.createContext(st);function Hr({children:e,...t}){if(!t.countryIsoCode||!t.languageIsoCode||!t.storeDomain||!t.storefrontToken||!t.storefrontApiVersion)throw new Error("Please provide the necessary props to '<ShopifyProvider/>'");t.storefrontApiVersion!==ie&&console.warn(`<ShopifyProvider/>: This version of Hydrogen React is built for Shopify's Storefront API version ${ie}, but it looks like you're using version ${t.storefrontApiVersion}. There may be issues or bugs if you use a mismatched version of Hydrogen React and the Storefront API.`);const r=c.useMemo(()=>{function n(a){const i=(a==null?void 0:a.storeDomain)??t.storeDomain;return i.includes("://")?i:`https://${i}`}return{...t,getPublicTokenHeaders(a){return it(a.contentType,t.storefrontApiVersion,a.storefrontToken??t.storefrontToken)},getShopifyDomain:n,getStorefrontApiUrl(a){const i=n({storeDomain:(a==null?void 0:a.storeDomain)??t.storeDomain});return`${i}${i.endsWith("/")?"":"/"}api/${(a==null?void 0:a.storefrontApiVersion)??t.storefrontApiVersion}/graphql.json`}}},[t]);return React.createElement(ct.Provider,{value:r},e)}function le(){const e=c.useContext(ct);if(!e)throw new Error("'useShop()' must be a descendent of <ShopifyProvider/>");return e}const ke="shopifyCartId",ut="Shopify-Storefront-Id",lt="Shopify-Storefront-Y",dt="Shopify-Storefront-S",J="_shopify_y",X="_shopify_s";var Br=new Set(["domain","path","max-age","expires","samesite","secure","httponly"]);function Yr(e){let t={},r,n,a=0,i=e.split(/;\s*/g),s,o;for(;a<i.length;a++)if(n=i[a],r=n.indexOf("="),~r){if(s=n.substring(0,r++).trim(),o=n.substring(r).trim(),o[0]==='"'&&(o=o.substring(1,o.length-1)),~o.indexOf("%"))try{o=decodeURIComponent(o)}catch{}Br.has(n=s.toLowerCase())?n==="expires"?t.expires=new Date(o):n==="max-age"?t.maxage=+o:t[n]=o:t[s]=o}else(s=n.trim().toLowerCase())&&(s==="httponly"||s==="secure")&&(t[s]=!0);return t}function Wr(e,t,r={}){let n=e+"="+encodeURIComponent(t);return r.expires&&(n+="; Expires="+new Date(r.expires).toUTCString()),r.maxage!=null&&r.maxage>=0&&(n+="; Max-Age="+(r.maxage|0)),r.domain&&(n+="; Domain="+r.domain),r.path&&(n+="; Path="+r.path),r.samesite&&(n+="; SameSite="+r.samesite),(r.secure||r.samesite==="None")&&(n+="; Secure"),r.httponly&&(n+="; HttpOnly"),n}const ft="xxxx-4xxx-xxxx-xxxxxxxxxxxx";function we(){let e="";try{const t=window.crypto,r=new Uint16Array(31);t.getRandomValues(r);let n=0;e=ft.replace(/[x]/g,a=>{const i=r[n]%16,s=a==="x"?i:i&3|8;return n++,s.toString(16)}).toUpperCase()}catch{e=ft.replace(/[x]/g,r=>{const n=Math.random()*16|0;return(r==="x"?n:n&3|8).toString(16)}).toUpperCase()}return`${Gr()}-${e}`}function Gr(){let e=0,t=0;e=new Date().getTime()>>>0;try{t=performance.now()>>>0}catch{t=0}return Math.abs(e+t).toString(16).toLowerCase().padStart(8,"0")}function be(e){const t=Yr(e);return{[J]:t[J]||"",[X]:t[X]||""}}function Zr(){const{storefrontId:e,getPublicTokenHeaders:t,getStorefrontApiUrl:r}=le();return c.useCallback(({query:n,variables:a})=>{const i=t({contentType:"json"});e&&(i[ut]=e);const s=be(document.cookie);return i[lt]=s[J],i[dt]=s[X],fetch(r(),{method:"POST",headers:i,body:JSON.stringify({query:n.toString(),variables:a})}).then(o=>o.json()).catch(o=>({data:void 0,errors:o==null?void 0:o.toString()}))},[t,e,r])}function Kr({numCartLines:e,cartFragment:t,countryCode:r="US",languageCode:n="EN"}){const a=Zr(),i=c.useCallback(f=>a({query:xr(t),variables:{id:f,numCartLines:e,country:r,language:n}}),[a,t,e,r,n]),s=c.useCallback(f=>a({query:Dr(t),variables:{input:f,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),o=c.useCallback((f,S)=>a({query:Rr(t),variables:{cartId:f,lines:S,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),u=c.useCallback((f,S)=>a({query:Ur(t),variables:{cartId:f,lines:S,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),l=c.useCallback((f,S)=>a({query:Vr(t),variables:{cartId:f,lines:S,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),g=c.useCallback((f,S)=>a({query:kr(t),variables:{cartId:f,note:S,numCartLines:e,country:r,language:n}}),[a,t,e,r,n]),h=c.useCallback((f,S)=>a({query:Nr(t),variables:{cartId:f,buyerIdentity:S,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),y=c.useCallback((f,S)=>a({query:Mr(t),variables:{cartId:f,attributes:S,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),d=c.useCallback((f,S)=>a({query:Lr(t),variables:{cartId:f,discountCodes:S,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]);return c.useMemo(()=>({cartFetch:i,cartCreate:s,cartLineAdd:o,cartLineUpdate:u,cartLineRemove:l,noteUpdate:g,buyerIdentityUpdate:h,cartAttributesUpdate:y,discountCodesUpdate:d,cartFragment:t}),[i,s,o,u,l,g,h,y,d,t])}function Y(e,t){return{entry:[...(t==null?void 0:t.entryActions)||[],ne({lastValidCart:r=>r==null?void 0:r.cart}),"onCartActionEntry","onCartActionOptimisticUI",e],on:{RESOLVE:{target:(t==null?void 0:t.resolveTarget)||"idle",actions:[ne({prevCart:r=>r==null?void 0:r.lastValidCart,cart:(r,n)=>{var a;return(a=n==null?void 0:n.payload)==null?void 0:a.cart},rawCartResult:(r,n)=>{var a;return(a=n==null?void 0:n.payload)==null?void 0:a.rawCartResult},errors:r=>{}})]},ERROR:{target:(t==null?void 0:t.errorTarget)||"error",actions:[ne({prevCart:r=>r==null?void 0:r.lastValidCart,cart:r=>r==null?void 0:r.lastValidCart,errors:(r,n)=>{var a;return(a=n==null?void 0:n.payload)==null?void 0:a.errors}})]},CART_COMPLETED:{target:"cartCompleted",actions:ne({prevCart:r=>{},cart:r=>{},lastValidCart:r=>{},rawCartResult:r=>{},errors:r=>{}})}},exit:["onCartActionComplete",...(t==null?void 0:t.exitActions)||[]]}}const de={CART_FETCH:{target:"cartFetching"},CART_CREATE:{target:"cartCreating"},CART_SET:{target:"idle",actions:[ne({rawCartResult:(e,t)=>t.payload.cart,cart:(e,t)=>Ne(t.payload.cart)})]}},ht={CARTLINE_ADD:{target:"cartLineAdding"},CARTLINE_UPDATE:{target:"cartLineUpdating"},CARTLINE_REMOVE:{target:"cartLineRemoving"},NOTE_UPDATE:{target:"noteUpdating"},BUYER_IDENTITY_UPDATE:{target:"buyerIdentityUpdating"},CART_ATTRIBUTES_UPDATE:{target:"cartAttributesUpdating"},DISCOUNT_CODES_UPDATE:{target:"discountCodesUpdating"}};function Qr(e){return ze({id:"Cart",initial:e?"idle":"uninitialized",context:{cart:e&&Ne(e)},states:{uninitialized:{on:de},cartCompleted:{on:de},initializationError:{on:de},idle:{on:{...de,...ht}},error:{on:{...de,...ht}},cartFetching:Y("cartFetchAction",{errorTarget:"initializationError"}),cartCreating:Y("cartCreateAction",{errorTarget:"initializationError"}),cartLineRemoving:Y("cartLineRemoveAction"),cartLineUpdating:Y("cartLineUpdateAction"),cartLineAdding:Y("cartLineAddAction"),noteUpdating:Y("noteUpdateAction"),buyerIdentityUpdating:Y("buyerIdentityUpdateAction"),cartAttributesUpdating:Y("cartAttributesUpdateAction"),discountCodesUpdating:Y("discountCodesUpdateAction")}})}function Jr({numCartLines:e,onCartActionEntry:t,onCartActionOptimisticUI:r,onCartActionComplete:n,data:a,cartFragment:i,countryCode:s,languageCode:o}){const{cartFetch:u,cartCreate:l,cartLineAdd:g,cartLineUpdate:h,cartLineRemove:y,noteUpdate:d,buyerIdentityUpdate:f,cartAttributesUpdate:S,discountCodesUpdate:T}=Kr({numCartLines:e,cartFragment:i,countryCode:s,languageCode:o}),w=c.useMemo(()=>Qr(a),[a]),[v,b,R]=vr(w,{actions:{cartFetchAction:async(m,p)=>{var A;if(p.type!=="CART_FETCH")return;const{data:_,errors:P}=await u((A=p==null?void 0:p.payload)==null?void 0:A.cartId),O=W(p,_==null?void 0:_.cart,P);b(O)},cartCreateAction:async(m,p)=>{var A;if(p.type!=="CART_CREATE")return;const{data:_,errors:P}=await l(p==null?void 0:p.payload),O=W(p,(A=_==null?void 0:_.cartCreate)==null?void 0:A.cart,P);b(O)},cartLineAddAction:async(m,p)=>{var A,I;if(p.type!=="CARTLINE_ADD"||!((A=m==null?void 0:m.cart)!=null&&A.id))return;const{data:_,errors:P}=await g(m.cart.id,p.payload.lines),O=W(p,(I=_==null?void 0:_.cartLinesAdd)==null?void 0:I.cart,P);b(O)},cartLineUpdateAction:async(m,p)=>{var A,I;if(p.type!=="CARTLINE_UPDATE"||!((A=m==null?void 0:m.cart)!=null&&A.id))return;const{data:_,errors:P}=await h(m.cart.id,p.payload.lines),O=W(p,(I=_==null?void 0:_.cartLinesUpdate)==null?void 0:I.cart,P);b(O)},cartLineRemoveAction:async(m,p)=>{var A,I;if(p.type!=="CARTLINE_REMOVE"||!((A=m==null?void 0:m.cart)!=null&&A.id))return;const{data:_,errors:P}=await y(m.cart.id,p.payload.lines),O=W(p,(I=_==null?void 0:_.cartLinesRemove)==null?void 0:I.cart,P);b(O)},noteUpdateAction:async(m,p)=>{var A,I;if(p.type!=="NOTE_UPDATE"||!((A=m==null?void 0:m.cart)!=null&&A.id))return;const{data:_,errors:P}=await d(m.cart.id,p.payload.note),O=W(p,(I=_==null?void 0:_.cartNoteUpdate)==null?void 0:I.cart,P);b(O)},buyerIdentityUpdateAction:async(m,p)=>{var A,I;if(p.type!=="BUYER_IDENTITY_UPDATE"||!((A=m==null?void 0:m.cart)!=null&&A.id))return;const{data:_,errors:P}=await f(m.cart.id,p.payload.buyerIdentity),O=W(p,(I=_==null?void 0:_.cartBuyerIdentityUpdate)==null?void 0:I.cart,P);b(O)},cartAttributesUpdateAction:async(m,p)=>{var A,I;if(p.type!=="CART_ATTRIBUTES_UPDATE"||!((A=m==null?void 0:m.cart)!=null&&A.id))return;const{data:_,errors:P}=await S(m.cart.id,p.payload.attributes),O=W(p,(I=_==null?void 0:_.cartAttributesUpdate)==null?void 0:I.cart,P);b(O)},discountCodesUpdateAction:async(m,p)=>{var A,I;if(p.type!=="DISCOUNT_CODES_UPDATE"||!((A=m==null?void 0:m.cart)!=null&&A.id))return;const{data:_,errors:P}=await T(m.cart.id,p.payload.discountCodes),O=W(p,(I=_==null?void 0:_.cartDiscountCodesUpdate)==null?void 0:I.cart,P);b(O)},...t&&{onCartActionEntry:(m,p)=>{Xr(p)&&t(m,p)}},...r&&{onCartActionOptimisticUI:ne((m,p)=>r(m,p))},...n&&{onCartActionComplete:(m,p)=>{zr(p)&&n(m,p)}}}});return c.useMemo(()=>[v,b,R],[v,b,R])}function Ne(e){return{...e,lines:Q(e==null?void 0:e.lines),note:e.note??void 0}}function W(e,t,r){return r?{type:"ERROR",payload:{errors:r,cartActionEvent:e}}:t?{type:"RESOLVE",payload:{cart:Ne(t),rawCartResult:t,cartActionEvent:e}}:{type:"CART_COMPLETED",payload:{cartActionEvent:e}}}function Xr(e){return e.type==="CART_CREATE"||e.type==="CARTLINE_ADD"||e.type==="CARTLINE_UPDATE"||e.type==="CARTLINE_REMOVE"||e.type==="NOTE_UPDATE"||e.type==="BUYER_IDENTITY_UPDATE"||e.type==="CART_ATTRIBUTES_UPDATE"||e.type==="DISCOUNT_CODES_UPDATE"}function zr(e){return e.type==="RESOLVE"||e.type==="ERROR"||e.type==="CART_COMPLETED"}const gt=c.createContext(null);function oe(){const e=c.useContext(gt);if(!e)throw new Error("Expected a Cart Context, but no Cart Context was found");return e}function en({children:e,numCartLines:t,onCreate:r,onLineAdd:n,onLineRemove:a,onLineUpdate:i,onNoteUpdate:s,onBuyerIdentityUpdate:o,onAttributesUpdate:u,onDiscountCodesUpdate:l,onCreateComplete:g,onLineAddComplete:h,onLineRemoveComplete:y,onLineUpdateComplete:d,onNoteUpdateComplete:f,onBuyerIdentityUpdateComplete:S,onAttributesUpdateComplete:T,onDiscountCodesUpdateComplete:w,data:v,cartFragment:b=Fr,customerAccessToken:R,countryCode:m,languageCode:p}){var Zt,Kt,Qt,Jt,Xt,zt,er;const _=le();if(!_)throw new Error("<CartProvider> needs to be a descendant of <ShopifyProvider>");m=(m??_.countryIsoCode??"US").toUpperCase(),p=(p??_.languageIsoCode??"EN").toUpperCase(),m&&(m=m.toUpperCase());const[P,O]=c.useState(m),[A,I]=c.useState(R),q=c.useRef(!1);(P!==m||A!==R)&&(O(m),I(R),q.current=!1);const[D,H]=Jr({numCartLines:t,data:v,cartFragment:b,countryCode:m,languageCode:p,onCartActionEntry(C,N){try{switch(N.type){case"CART_CREATE":return r==null?void 0:r();case"CARTLINE_ADD":return n==null?void 0:n();case"CARTLINE_REMOVE":return a==null?void 0:a();case"CARTLINE_UPDATE":return i==null?void 0:i();case"NOTE_UPDATE":return s==null?void 0:s();case"BUYER_IDENTITY_UPDATE":return o==null?void 0:o();case"CART_ATTRIBUTES_UPDATE":return u==null?void 0:u();case"DISCOUNT_CODES_UPDATE":return l==null?void 0:l()}}catch(L){console.error("Cart entry action failed",L)}},onCartActionOptimisticUI(C,N){var L,K,M,Te;if(!C.cart)return{...C};switch(N.type){case"CARTLINE_REMOVE":return{...C,cart:{...C.cart,lines:(K=(L=C==null?void 0:C.cart)==null?void 0:L.lines)==null?void 0:K.filter(x=>(x==null?void 0:x.id)&&!N.payload.lines.includes(x==null?void 0:x.id))}};case"CARTLINE_UPDATE":return{...C,cart:{...C.cart,lines:(Te=(M=C==null?void 0:C.cart)==null?void 0:M.lines)==null?void 0:Te.map(x=>{const We=N.payload.lines.find(({id:Ta})=>Ta===(x==null?void 0:x.id));return We&&We.quantity?{...x,quantity:We.quantity}:x})}}}return{...C}},onCartActionComplete(C,N){const L=N.payload.cartActionEvent;try{switch(N.type){case"RESOLVE":switch(L.type){case"CART_CREATE":return g==null?void 0:g();case"CARTLINE_ADD":return h==null?void 0:h();case"CARTLINE_REMOVE":return y==null?void 0:y();case"CARTLINE_UPDATE":return d==null?void 0:d();case"NOTE_UPDATE":return f==null?void 0:f();case"BUYER_IDENTITY_UPDATE":return nn(C,L)&&(q.current=!0),S==null?void 0:S();case"CART_ATTRIBUTES_UPDATE":return T==null?void 0:T();case"DISCOUNT_CODES_UPDATE":return w==null?void 0:w()}}}catch(K){console.error("onCartActionComplete failed",K)}}}),ee=c.useRef(!1),[Ee,U]=c.useState(!1),ue=D.matches("cartCompleted"),_e=(D.value==="idle"||D.value==="error"||D.value==="cartCompleted")&&m!==((Qt=(Kt=(Zt=D==null?void 0:D.context)==null?void 0:Zt.cart)==null?void 0:Kt.buyerIdentity)==null?void 0:Qt.countryCode)&&!D.context.errors,Se=c.useRef(!1);c.useEffect(()=>{if(!ee.current&&!Se.current){if(!v&&Me("localStorage")){Se.current=!0;try{const C=window.localStorage.getItem(ke);C&&H({type:"CART_FETCH",payload:{cartId:C}})}catch(C){console.warn("error fetching cartId"),console.warn(C)}}ee.current=!0,U(!0)}},[v,ee,H]),c.useEffect(()=>{!_e||q.current||H({type:"BUYER_IDENTITY_UPDATE",payload:{buyerIdentity:{countryCode:m,customerAccessToken:R}}})},[m,R,_e,q,H]);const B=c.useCallback(C=>{if(!ee.current)return console.warn("Cart isn't ready yet");H(C)},[H]);c.useEffect(()=>{var C,N,L;if((N=(C=D==null?void 0:D.context)==null?void 0:C.cart)!=null&&N.id&&Me("localStorage"))try{window.localStorage.setItem(ke,(L=D.context.cart)==null?void 0:L.id)}catch(K){console.warn("Failed to save cartId to localStorage",K)}},[(Xt=(Jt=D==null?void 0:D.context)==null?void 0:Jt.cart)==null?void 0:Xt.id]),c.useEffect(()=>{if(ue&&Me("localStorage"))try{window.localStorage.removeItem(ke)}catch(C){console.warn("Failed to delete cartId from localStorage",C)}},[ue]);const Ye=c.useCallback(C=>{var N,L;m&&!((N=C.buyerIdentity)!=null&&N.countryCode)&&(C.buyerIdentity==null&&(C.buyerIdentity={}),C.buyerIdentity.countryCode=m),R&&!((L=C.buyerIdentity)!=null&&L.customerAccessToken)&&(C.buyerIdentity==null&&(C.buyerIdentity={}),C.buyerIdentity.customerAccessToken=R),B({type:"CART_CREATE",payload:C})},[m,R,B]),V=rn(D),Sa=c.useMemo(()=>{var C,N,L,K;return{...((C=V==null?void 0:V.context)==null?void 0:C.cart)??{lines:[],attributes:[]},status:tn(V.value),error:(N=V==null?void 0:V.context)==null?void 0:N.errors,totalQuantity:((K=(L=V==null?void 0:V.context)==null?void 0:L.cart)==null?void 0:K.totalQuantity)??0,cartCreate:Ye,cartReady:Ee,linesAdd(M){var Te,x;(x=(Te=V==null?void 0:V.context)==null?void 0:Te.cart)!=null&&x.id?B({type:"CARTLINE_ADD",payload:{lines:M}}):Ye({lines:M})},linesRemove(M){B({type:"CARTLINE_REMOVE",payload:{lines:M}})},linesUpdate(M){B({type:"CARTLINE_UPDATE",payload:{lines:M}})},noteUpdate(M){B({type:"NOTE_UPDATE",payload:{note:M}})},buyerIdentityUpdate(M){B({type:"BUYER_IDENTITY_UPDATE",payload:{buyerIdentity:M}})},cartAttributesUpdate(M){B({type:"CART_ATTRIBUTES_UPDATE",payload:{attributes:M}})},discountCodesUpdate(M){B({type:"DISCOUNT_CODES_UPDATE",payload:{discountCodes:M}})},cartFragment:b}},[Ye,Ee,(zt=V==null?void 0:V.context)==null?void 0:zt.cart,(er=V==null?void 0:V.context)==null?void 0:er.errors,V.value,b,B]);return React.createElement(gt.Provider,{value:Sa},e)}function tn(e){switch(e){case"uninitialized":case"initializationError":return"uninitialized";case"idle":case"cartCompleted":case"error":return"idle";case"cartFetching":return"fetching";case"cartCreating":return"creating";case"cartLineAdding":case"cartLineRemoving":case"cartLineUpdating":case"noteUpdating":case"buyerIdentityUpdating":case"cartAttributesUpdating":case"discountCodesUpdating":return"updating"}}function rn(e){const[t,r]=c.useTransition(),[n,a]=c.useState(e),i=c.useRef(!1);t&&(i.current=!0);const s=c.useRef(!1);return!t&&i.current&&(s.current=!0),c.useEffect(()=>{r(()=>{s.current||a(e)})},[e]),s.current?e:n}function Me(e){let t;try{t=window[e];const r="__storage_test__";return t.setItem(r,r),t.removeItem(r),!0}catch(r){return!!(r instanceof DOMException&&(r.code===22||r.code===1014||r.name==="QuotaExceededError"||r.name==="NS_ERROR_DOM_QUOTA_REACHED")&&t&&t.length!==0)}}function nn(e,t){var r,n;return!!(t.payload.buyerIdentity.countryCode&&((n=(r=e.cart)==null?void 0:r.buyerIdentity)==null?void 0:n.countryCode)!==t.payload.buyerIdentity.countryCode)}const yt=c.createContext(null);function an({children:e,data:t,initialVariantId:r}){const n=c.useMemo(()=>Q(t.variants??{}),[t.variants]);if(!sn(n))throw new Error("<ProductProvider/> requires 'product.variants.nodes' or 'product.variants.edges'");const a=c.useMemo(()=>on(n),[n]),[i,s]=c.useState(()=>Et(r,n)),[o,u]=c.useState(()=>_t(i));c.useEffect(()=>{const T=Et(r,n);s(T),u(_t(T))},[r,n]);const l=c.useCallback((T,w)=>{u(v=>{const b={...v,[T]:w};return s(pt(n,b)),b})},[u,n]),g=c.useCallback((T,w)=>{const v=pt(n,{...o,[T]:w});return(v==null?void 0:v.availableForSale)??!0},[o,n]),h=c.useMemo(()=>Q(t.sellingPlanGroups??{}).map(T=>({...T,sellingPlans:Q((T==null?void 0:T.sellingPlans)??{})})),[t.sellingPlanGroups]),[y,d]=c.useState(void 0),f=c.useMemo(()=>{var T,w;if(!(!i||!y)){if(!((T=i.sellingPlanAllocations)!=null&&T.nodes)&&!((w=i.sellingPlanAllocations)!=null&&w.edges))throw new Error("<ProductProvider/>: You must include 'sellingPlanAllocations.nodes' or 'sellingPlanAllocations.edges' in your variants in order to calculate selectedSellingPlanAllocation");return Q(i.sellingPlanAllocations).find(v=>{var b;return((b=v==null?void 0:v.sellingPlan)==null?void 0:b.id)===y.id})}},[i,y]),S=c.useMemo(()=>({product:t,variants:n,variantsConnection:t.variants,options:a,selectedVariant:i,setSelectedVariant:s,selectedOptions:o,setSelectedOption:l,setSelectedOptions:u,isOptionInStock:g,selectedSellingPlan:y,setSelectedSellingPlan:d,selectedSellingPlanAllocation:f,sellingPlanGroups:h,sellingPlanGroupsConnection:t.sellingPlanGroups}),[t,g,a,o,y,f,i,h,l,n]);return React.createElement(yt.Provider,{value:S},e)}function mt(){const e=c.useContext(yt);if(!e)throw new Error("'useProduct' must be a child of <ProductProvider />");return e}function pt(e,t){var r,n;if(!(!e.length||((n=(r=e==null?void 0:e[0])==null?void 0:r.selectedOptions)==null?void 0:n.length)!==Object.keys(t).length))return e==null?void 0:e.find(a=>Object.entries(t).every(([i,s])=>{var o;return(o=a==null?void 0:a.selectedOptions)==null?void 0:o.some(u=>(u==null?void 0:u.name)===i&&(u==null?void 0:u.value)===s)}))}function on(e){const t=e.reduce((r,n)=>{var a;if(!n.selectedOptions)throw new Error("'getOptions' requires 'variant.selectedOptions'");return(a=n==null?void 0:n.selectedOptions)==null||a.forEach(i=>{r[(i==null?void 0:i.name)??""]=r[(i==null?void 0:i.name)??""]||new Set,r[(i==null?void 0:i.name)??""].add((i==null?void 0:i.value)??"")}),r},{});return Object.keys(t).map(r=>({name:r,values:Array.from(t[r])}))}function Et(e,t){if(e){const r=t.find(n=>(n==null?void 0:n.id)===e);return r||console.warn("<ProductProvider/> received a 'initialVariantId' prop, but could not actually find a variant with that ID"),r}if(e===null)return null;if(e===void 0)return t.find(r=>r==null?void 0:r.availableForSale)||t[0]}function _t(e){return e!=null&&e.selectedOptions?e.selectedOptions.reduce((t,r)=>(t[(r==null?void 0:r.name)??""]=(r==null?void 0:r.value)??"",t),{}):{}}function sn(e){return!(!e||!Array.isArray(e))}function Ie(e){const{as:t,onClick:r,defaultOnClick:n,children:a,buttonRef:i,...s}=e,o=c.useCallback(l=>{if(r){const g=r(l);if(typeof g=="boolean"&&g===!1||l!=null&&l.defaultPrevented)return}n==null||n(l)},[n,r]),u=t||"button";return React.createElement(u,{ref:i,onClick:o,...s},a)}function cn(e){const[t,r]=c.useState(!1),{variantId:n,quantity:a=1,attributes:i,sellingPlanId:s,onClick:o,children:u,accessibleAddingToCartLabel:l,...g}=e,{status:h,linesAdd:y}=oe(),{selectedVariant:d}=mt(),f=n??(d==null?void 0:d.id)??"",S=n===null||f===""||d===null||t||g.disabled;c.useEffect(()=>{t&&h==="idle"&&r(!1)},[h,t]);const T=c.useCallback(()=>{r(!0),y([{quantity:a,merchandiseId:f||"",attributes:i,sellingPlanId:s}])},[y,a,f,i,s]);return k.createElement(k.Fragment,null,k.createElement(Ie,{...g,disabled:S,onClick:o,defaultOnClick:T},u),l?k.createElement("p",{style:{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"},role:"alert","aria-live":"assertive"},t?l:null):null)}const re={PAGE_VIEW:"PAGE_VIEW",ADD_TO_CART:"ADD_TO_CART",PAGE_VIEW_2:"PAGE_VIEW_2",COLLECTION_VIEW:"COLLECTION_VIEW",PRODUCT_VIEW:"PRODUCT_VIEW",SEARCH_VIEW:"SEARCH_VIEW"},ve={article:"article",blog:"blog",captcha:"captcha",cart:"cart",collection:"collection",customersAccount:"customers/account",customersActivateAccount:"customers/activate_account",customersAddresses:"customers/addresses",customersLogin:"customers/login",customersOrder:"customers/order",customersRegister:"customers/register",customersResetPassword:"customers/reset_password",giftCard:"gift_card",home:"index",listCollections:"list-collections",forbidden:"403",notFound:"404",page:"page",password:"password",product:"product",policy:"policy",search:"search"},St={hydrogen:"hydrogen",headless:"headless"},Tt={hydrogen:"6167201",headless:"12875497473"};function $(e,t){return{schema_id:e,payload:t,metadata:{event_created_at_ms:Date.now()}}}function F(e){const t={id:"",resource:null,resourceId:null,search:"",searchParams:new URLSearchParams,hash:""};if(typeof e!="string")return t;try{const{search:r,searchParams:n,pathname:a,hash:i}=new URL(e),s=a.split("/"),o=s[s.length-1],u=s[s.length-2];return!o||!u?t:{id:`${o}${r}${i}`||"",resource:u??null,resourceId:o||null,search:r,searchParams:n,hash:i}}catch{return t}}function j(e,t){return typeof e!="object"?{}:(Object.entries(e).forEach(([r,n])=>{n&&(t[r]=n)}),t)}function un(e){return typeof document>"u"?(console.error(`${e} should only be used within the useEffect callback or event handlers`),!0):!1}const ln="trekkie_storefront_page_view/1.4",dn="myshopify.dev";function Ct(e){const t=e,{id:r,resource:n}=F(t.resourceId),a=n?n.toLowerCase():void 0;return[$(ln,j({pageType:t.pageType,customerId:parseInt(F(t.customerId).id||"0"),resourceType:a,resourceId:parseInt(r)},fn(t)))]}function fn(e){return{appClientId:e.shopifySalesChannel?Tt[e.shopifySalesChannel]:Tt.headless,isMerchantRequest:hn(e.url),hydrogenSubchannelId:e.storefrontId||e.hydrogenSubchannelId||"0",isPersistentCookie:e.hasUserConsent,uniqToken:e.uniqueToken,visitToken:e.visitToken,microSessionId:we(),microSessionCount:1,url:e.url,path:e.path,search:e.search,referrer:e.referrer,title:e.title,shopId:parseInt(F(e.shopId).id),currency:e.currency,contentLanguage:e.acceptedLanguage||"en"}}function hn(e){if(typeof e!="string")return!1;const t=new URL(e).hostname;return t.indexOf(dn)!==-1||t==="localhost"}const gn="2025.1.1",G="custom_storefront_customer_tracking/1.2",At="page_rendered",wt="collection_page_rendered",bt="product_page_rendered",yn="product_added_to_cart",It="search_submitted";function fe(e){return{canonical_url:e.canonicalUrl||e.url,customer_id:parseInt(F(e.customerId).id||"0")}}function mn(e){const t=e,r=fe(t),n=t.pageType,a=[];switch(a.push($(G,j({event_name:At,...r},Z(t)))),n){case ve.collection:a.push($(G,j({event_name:wt,...r,collection_name:t.collectionHandle,collection_id:parseInt(F(t.collectionId).id)},Z(t))));break;case ve.product:a.push($(G,j({event_name:bt,...r,products:Le(t.products),total_value:t.totalValue},Z(t))));break;case ve.search:a.push($(G,j({event_name:It,...r,search_string:t.searchString},Z(t))));break}return a}function pn(e){const t=e,r=fe(t);return[$(G,j({event_name:At,...r},Z(t)))]}function En(e){const t=e,r=fe(t);return[$(G,j({event_name:wt,...r,collection_name:t.collectionHandle,collection_id:parseInt(F(t.collectionId).id)},Z(t)))]}function _n(e){const t=e,r=fe(t);return[$(G,j({event_name:bt,...r,products:Le(t.products),total_value:t.totalValue},Z(t)))]}function Sn(e){const t=e,r=fe(t);return[$(G,j({event_name:It,...r,search_string:t.searchString},Z(t)))]}function Tn(e){const t=e,r=F(t.cartId);return[$(G,j({event_name:yn,customerId:t.customerId,cart_token:r!=null&&r.id?`${r.id}`:null,total_value:t.totalValue,products:Le(t.products),customer_id:parseInt(F(t.customerId).id||"0")},Z(t)))]}function Z(e){return{source:e.shopifySalesChannel||St.headless,asset_version_id:e.assetVersionId||gn,hydrogenSubchannelId:e.storefrontId||e.hydrogenSubchannelId||"0",is_persistent_cookie:e.hasUserConsent,deprecated_visit_token:e.visitToken,unique_token:e.uniqueToken,event_time:Date.now(),event_id:we(),event_source_url:e.url,referrer:e.referrer,user_agent:e.userAgent,navigation_type:e.navigationType,navigation_api:e.navigationApi,shop_id:parseInt(F(e.shopId).id),currency:e.currency,ccpa_enforced:e.ccpaEnforced||!1,gdpr_enforced:e.gdprEnforced||!1,gdpr_enforced_as_string:e.gdprEnforced?"true":"false",analytics_allowed:e.analyticsAllowed||!1,marketing_allowed:e.marketingAllowed||!1,sale_of_data_allowed:e.saleOfDataAllowed||!1}}function Le(e){return e?e.map(t=>{const r=j({variant_gid:t.variantGid,category:t.category,sku:t.sku,product_id:parseInt(F(t.productGid).id),variant_id:parseInt(F(t.variantGid).id)},{product_gid:t.productGid,name:t.name,variant:t.variantName||"",brand:t.brand,price:parseFloat(t.price),quantity:Number(t.quantity||0)});return JSON.stringify(r)}):[]}function Cn(e,t){const{eventName:r,payload:n}=e;if(!n.hasUserConsent)return Promise.resolve();let a=[];const i=n;return r===re.PAGE_VIEW?a=a.concat(Ct(i),mn(i)):r===re.ADD_TO_CART?a=a.concat(Tn(n)):r===re.PAGE_VIEW_2?a=a.concat(Ct(i),pn(i)):r===re.COLLECTION_VIEW?a=a.concat(En(i)):r===re.PRODUCT_VIEW?a=a.concat(_n(i)):r===re.SEARCH_VIEW&&(a=a.concat(Sn(i))),a.length?wn(a,t):Promise.resolve()}function An(){return typeof window>"u"||!window.navigator?!1:/Chrome-Lighthouse/.test(window.navigator.userAgent)}const vt="sendShopifyAnalytics request is unsuccessful";function wn(e,t){if(An())return Promise.resolve();const r={events:e,metadata:{event_sent_at_ms:Date.now()}};try{return fetch(t?`https://${t}/.well-known/shopify/monorail/unstable/produce_batch`:"https://monorail-edge.shopifysvc.com/unstable/produce_batch",{method:"post",headers:{"content-type":"text/plain"},body:JSON.stringify(r)}).then(n=>{if(!n.ok)throw new Error("Response failed");return n.text()}).then(n=>{n&&JSON.parse(n).result.forEach(i=>{i.status!==200&&console.error(vt,`
|
|
272
|
+
You may run into unexpected errors if these versions don't match. Received version: "${n}"; expected version "${ie}"`);const i=s=>{const o=(s==null?void 0:s.storeDomain)??e;return o.includes("://")?o:`https://${o}`};return{getShopifyDomain:i,getStorefrontApiUrl(s){const o=i(s),u=o+(o.endsWith("/")?"api":"/api");return Ve(o)?u:`${u}/${(s==null?void 0:s.storefrontApiVersion)??n}/graphql.json`},getPrivateTokenHeaders(s){if(!t&&!(s!=null&&s.privateStorefrontToken)&&!Ve(e))throw new Error(Ue+"You did not pass in a `privateStorefrontToken` while using `createStorefrontClient()` or `getPrivateTokenHeaders()`");return{"content-type":((s==null?void 0:s.contentType)??a)==="graphql"?"application/graphql":"application/json","X-SDK-Variant":"hydrogen-react","X-SDK-Variant-Source":"react","X-SDK-Version":n,"Shopify-Storefront-Private-Token":(s==null?void 0:s.privateStorefrontToken)??t??"",...s!=null&&s.buyerIp?{"Shopify-Storefront-Buyer-IP":s.buyerIp}:{}}},getPublicTokenHeaders(s){if(!r&&!(s!=null&&s.publicStorefrontToken)&&!Ve(e))throw new Error(Ue+"You did not pass in a `publicStorefrontToken` while using `createStorefrontClient()` or `getPublicTokenHeaders()`");const o=(s==null?void 0:s.contentType)??a??"json";return it(o,n,(s==null?void 0:s.publicStorefrontToken)??r??"")}}}function it(e,t,r){return{"content-type":e==="graphql"?"application/graphql":"application/json","X-SDK-Variant":"hydrogen-react","X-SDK-Variant-Source":"react","X-SDK-Version":t,"X-Shopify-Storefront-Access-Token":r}}const ot=new Set,Ue="[h2:error:createStorefrontClient] ",qr=(e,t="warn")=>{ot.has(e)||(console[t](`[h2:${t}:createStorefrontClient] `+e),ot.add(e))},st={storeDomain:"test",storefrontToken:"abc123",storefrontApiVersion:ie,countryIsoCode:"US",languageIsoCode:"EN",getStorefrontApiUrl(){return""},getPublicTokenHeaders(){return{}},getShopifyDomain(){return""}},ct=c.createContext(st);function Hr({children:e,...t}){if(!t.countryIsoCode||!t.languageIsoCode||!t.storeDomain||!t.storefrontToken||!t.storefrontApiVersion)throw new Error("Please provide the necessary props to '<ShopifyProvider/>'");t.storefrontApiVersion!==ie&&console.warn(`<ShopifyProvider/>: This version of Hydrogen React is built for Shopify's Storefront API version ${ie}, but it looks like you're using version ${t.storefrontApiVersion}. There may be issues or bugs if you use a mismatched version of Hydrogen React and the Storefront API.`);const r=c.useMemo(()=>{function n(a){const i=(a==null?void 0:a.storeDomain)??t.storeDomain;return i.includes("://")?i:`https://${i}`}return{...t,getPublicTokenHeaders(a){return it(a.contentType,t.storefrontApiVersion,a.storefrontToken??t.storefrontToken)},getShopifyDomain:n,getStorefrontApiUrl(a){const i=n({storeDomain:(a==null?void 0:a.storeDomain)??t.storeDomain});return`${i}${i.endsWith("/")?"":"/"}api/${(a==null?void 0:a.storefrontApiVersion)??t.storefrontApiVersion}/graphql.json`}}},[t]);return React.createElement(ct.Provider,{value:r},e)}function le(){const e=c.useContext(ct);if(!e)throw new Error("'useShop()' must be a descendent of <ShopifyProvider/>");return e}const ke="shopifyCartId",ut="Shopify-Storefront-Id",lt="Shopify-Storefront-Y",dt="Shopify-Storefront-S",J="_shopify_y",X="_shopify_s";var Br=new Set(["domain","path","max-age","expires","samesite","secure","httponly"]);function Yr(e){let t={},r,n,a=0,i=e.split(/;\s*/g),s,o;for(;a<i.length;a++)if(n=i[a],r=n.indexOf("="),~r){if(s=n.substring(0,r++).trim(),o=n.substring(r).trim(),o[0]==='"'&&(o=o.substring(1,o.length-1)),~o.indexOf("%"))try{o=decodeURIComponent(o)}catch{}Br.has(n=s.toLowerCase())?n==="expires"?t.expires=new Date(o):n==="max-age"?t.maxage=+o:t[n]=o:t[s]=o}else(s=n.trim().toLowerCase())&&(s==="httponly"||s==="secure")&&(t[s]=!0);return t}function Wr(e,t,r={}){let n=e+"="+encodeURIComponent(t);return r.expires&&(n+="; Expires="+new Date(r.expires).toUTCString()),r.maxage!=null&&r.maxage>=0&&(n+="; Max-Age="+(r.maxage|0)),r.domain&&(n+="; Domain="+r.domain),r.path&&(n+="; Path="+r.path),r.samesite&&(n+="; SameSite="+r.samesite),(r.secure||r.samesite==="None")&&(n+="; Secure"),r.httponly&&(n+="; HttpOnly"),n}const ft="xxxx-4xxx-xxxx-xxxxxxxxxxxx";function we(){let e="";try{const t=window.crypto,r=new Uint16Array(31);t.getRandomValues(r);let n=0;e=ft.replace(/[x]/g,a=>{const i=r[n]%16,s=a==="x"?i:i&3|8;return n++,s.toString(16)}).toUpperCase()}catch{e=ft.replace(/[x]/g,r=>{const n=Math.random()*16|0;return(r==="x"?n:n&3|8).toString(16)}).toUpperCase()}return`${Gr()}-${e}`}function Gr(){let e=0,t=0;e=new Date().getTime()>>>0;try{t=performance.now()>>>0}catch{t=0}return Math.abs(e+t).toString(16).toLowerCase().padStart(8,"0")}function be(e){const t=Yr(e);return{[J]:t[J]||"",[X]:t[X]||""}}function Zr(){const{storefrontId:e,getPublicTokenHeaders:t,getStorefrontApiUrl:r}=le();return c.useCallback(({query:n,variables:a})=>{const i=t({contentType:"json"});e&&(i[ut]=e);const s=be(document.cookie);return i[lt]=s[J],i[dt]=s[X],fetch(r(),{method:"POST",headers:i,body:JSON.stringify({query:n.toString(),variables:a})}).then(o=>o.json()).catch(o=>({data:void 0,errors:o==null?void 0:o.toString()}))},[t,e,r])}function Kr({numCartLines:e,cartFragment:t,countryCode:r="US",languageCode:n="EN"}){const a=Zr(),i=c.useCallback(f=>a({query:xr(t),variables:{id:f,numCartLines:e,country:r,language:n}}),[a,t,e,r,n]),s=c.useCallback(f=>a({query:Dr(t),variables:{input:f,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),o=c.useCallback((f,S)=>a({query:Rr(t),variables:{cartId:f,lines:S,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),u=c.useCallback((f,S)=>a({query:Ur(t),variables:{cartId:f,lines:S,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),l=c.useCallback((f,S)=>a({query:Vr(t),variables:{cartId:f,lines:S,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),g=c.useCallback((f,S)=>a({query:kr(t),variables:{cartId:f,note:S,numCartLines:e,country:r,language:n}}),[a,t,e,r,n]),h=c.useCallback((f,S)=>a({query:Nr(t),variables:{cartId:f,buyerIdentity:S,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),y=c.useCallback((f,S)=>a({query:Mr(t),variables:{cartId:f,attributes:S,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),d=c.useCallback((f,S)=>a({query:Lr(t),variables:{cartId:f,discountCodes:S,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]);return c.useMemo(()=>({cartFetch:i,cartCreate:s,cartLineAdd:o,cartLineUpdate:u,cartLineRemove:l,noteUpdate:g,buyerIdentityUpdate:h,cartAttributesUpdate:y,discountCodesUpdate:d,cartFragment:t}),[i,s,o,u,l,g,h,y,d,t])}function Y(e,t){return{entry:[...(t==null?void 0:t.entryActions)||[],ne({lastValidCart:r=>r==null?void 0:r.cart}),"onCartActionEntry","onCartActionOptimisticUI",e],on:{RESOLVE:{target:(t==null?void 0:t.resolveTarget)||"idle",actions:[ne({prevCart:r=>r==null?void 0:r.lastValidCart,cart:(r,n)=>{var a;return(a=n==null?void 0:n.payload)==null?void 0:a.cart},rawCartResult:(r,n)=>{var a;return(a=n==null?void 0:n.payload)==null?void 0:a.rawCartResult},errors:r=>{}})]},ERROR:{target:(t==null?void 0:t.errorTarget)||"error",actions:[ne({prevCart:r=>r==null?void 0:r.lastValidCart,cart:r=>r==null?void 0:r.lastValidCart,errors:(r,n)=>{var a;return(a=n==null?void 0:n.payload)==null?void 0:a.errors}})]},CART_COMPLETED:{target:"cartCompleted",actions:ne({prevCart:r=>{},cart:r=>{},lastValidCart:r=>{},rawCartResult:r=>{},errors:r=>{}})}},exit:["onCartActionComplete",...(t==null?void 0:t.exitActions)||[]]}}const de={CART_FETCH:{target:"cartFetching"},CART_CREATE:{target:"cartCreating"},CART_SET:{target:"idle",actions:[ne({rawCartResult:(e,t)=>t.payload.cart,cart:(e,t)=>Ne(t.payload.cart)})]}},ht={CARTLINE_ADD:{target:"cartLineAdding"},CARTLINE_UPDATE:{target:"cartLineUpdating"},CARTLINE_REMOVE:{target:"cartLineRemoving"},NOTE_UPDATE:{target:"noteUpdating"},BUYER_IDENTITY_UPDATE:{target:"buyerIdentityUpdating"},CART_ATTRIBUTES_UPDATE:{target:"cartAttributesUpdating"},DISCOUNT_CODES_UPDATE:{target:"discountCodesUpdating"}};function Qr(e){return ze({id:"Cart",initial:e?"idle":"uninitialized",context:{cart:e&&Ne(e)},states:{uninitialized:{on:de},cartCompleted:{on:de},initializationError:{on:de},idle:{on:{...de,...ht}},error:{on:{...de,...ht}},cartFetching:Y("cartFetchAction",{errorTarget:"initializationError"}),cartCreating:Y("cartCreateAction",{errorTarget:"initializationError"}),cartLineRemoving:Y("cartLineRemoveAction"),cartLineUpdating:Y("cartLineUpdateAction"),cartLineAdding:Y("cartLineAddAction"),noteUpdating:Y("noteUpdateAction"),buyerIdentityUpdating:Y("buyerIdentityUpdateAction"),cartAttributesUpdating:Y("cartAttributesUpdateAction"),discountCodesUpdating:Y("discountCodesUpdateAction")}})}function Jr({numCartLines:e,onCartActionEntry:t,onCartActionOptimisticUI:r,onCartActionComplete:n,data:a,cartFragment:i,countryCode:s,languageCode:o}){const{cartFetch:u,cartCreate:l,cartLineAdd:g,cartLineUpdate:h,cartLineRemove:y,noteUpdate:d,buyerIdentityUpdate:f,cartAttributesUpdate:S,discountCodesUpdate:T}=Kr({numCartLines:e,cartFragment:i,countryCode:s,languageCode:o}),w=c.useMemo(()=>Qr(a),[a]),[v,b,R]=vr(w,{actions:{cartFetchAction:async(m,p)=>{var A;if(p.type!=="CART_FETCH")return;const{data:_,errors:P}=await u((A=p==null?void 0:p.payload)==null?void 0:A.cartId),O=W(p,_==null?void 0:_.cart,P);b(O)},cartCreateAction:async(m,p)=>{var A;if(p.type!=="CART_CREATE")return;const{data:_,errors:P}=await l(p==null?void 0:p.payload),O=W(p,(A=_==null?void 0:_.cartCreate)==null?void 0:A.cart,P);b(O)},cartLineAddAction:async(m,p)=>{var A,I;if(p.type!=="CARTLINE_ADD"||!((A=m==null?void 0:m.cart)!=null&&A.id))return;const{data:_,errors:P}=await g(m.cart.id,p.payload.lines),O=W(p,(I=_==null?void 0:_.cartLinesAdd)==null?void 0:I.cart,P);b(O)},cartLineUpdateAction:async(m,p)=>{var A,I;if(p.type!=="CARTLINE_UPDATE"||!((A=m==null?void 0:m.cart)!=null&&A.id))return;const{data:_,errors:P}=await h(m.cart.id,p.payload.lines),O=W(p,(I=_==null?void 0:_.cartLinesUpdate)==null?void 0:I.cart,P);b(O)},cartLineRemoveAction:async(m,p)=>{var A,I;if(p.type!=="CARTLINE_REMOVE"||!((A=m==null?void 0:m.cart)!=null&&A.id))return;const{data:_,errors:P}=await y(m.cart.id,p.payload.lines),O=W(p,(I=_==null?void 0:_.cartLinesRemove)==null?void 0:I.cart,P);b(O)},noteUpdateAction:async(m,p)=>{var A,I;if(p.type!=="NOTE_UPDATE"||!((A=m==null?void 0:m.cart)!=null&&A.id))return;const{data:_,errors:P}=await d(m.cart.id,p.payload.note),O=W(p,(I=_==null?void 0:_.cartNoteUpdate)==null?void 0:I.cart,P);b(O)},buyerIdentityUpdateAction:async(m,p)=>{var A,I;if(p.type!=="BUYER_IDENTITY_UPDATE"||!((A=m==null?void 0:m.cart)!=null&&A.id))return;const{data:_,errors:P}=await f(m.cart.id,p.payload.buyerIdentity),O=W(p,(I=_==null?void 0:_.cartBuyerIdentityUpdate)==null?void 0:I.cart,P);b(O)},cartAttributesUpdateAction:async(m,p)=>{var A,I;if(p.type!=="CART_ATTRIBUTES_UPDATE"||!((A=m==null?void 0:m.cart)!=null&&A.id))return;const{data:_,errors:P}=await S(m.cart.id,p.payload.attributes),O=W(p,(I=_==null?void 0:_.cartAttributesUpdate)==null?void 0:I.cart,P);b(O)},discountCodesUpdateAction:async(m,p)=>{var A,I;if(p.type!=="DISCOUNT_CODES_UPDATE"||!((A=m==null?void 0:m.cart)!=null&&A.id))return;const{data:_,errors:P}=await T(m.cart.id,p.payload.discountCodes),O=W(p,(I=_==null?void 0:_.cartDiscountCodesUpdate)==null?void 0:I.cart,P);b(O)},...t&&{onCartActionEntry:(m,p)=>{Xr(p)&&t(m,p)}},...r&&{onCartActionOptimisticUI:ne((m,p)=>r(m,p))},...n&&{onCartActionComplete:(m,p)=>{zr(p)&&n(m,p)}}}});return c.useMemo(()=>[v,b,R],[v,b,R])}function Ne(e){return{...e,lines:Q(e==null?void 0:e.lines),note:e.note??void 0}}function W(e,t,r){return r?{type:"ERROR",payload:{errors:r,cartActionEvent:e}}:t?{type:"RESOLVE",payload:{cart:Ne(t),rawCartResult:t,cartActionEvent:e}}:{type:"CART_COMPLETED",payload:{cartActionEvent:e}}}function Xr(e){return e.type==="CART_CREATE"||e.type==="CARTLINE_ADD"||e.type==="CARTLINE_UPDATE"||e.type==="CARTLINE_REMOVE"||e.type==="NOTE_UPDATE"||e.type==="BUYER_IDENTITY_UPDATE"||e.type==="CART_ATTRIBUTES_UPDATE"||e.type==="DISCOUNT_CODES_UPDATE"}function zr(e){return e.type==="RESOLVE"||e.type==="ERROR"||e.type==="CART_COMPLETED"}const gt=c.createContext(null);function oe(){const e=c.useContext(gt);if(!e)throw new Error("Expected a Cart Context, but no Cart Context was found");return e}function en({children:e,numCartLines:t,onCreate:r,onLineAdd:n,onLineRemove:a,onLineUpdate:i,onNoteUpdate:s,onBuyerIdentityUpdate:o,onAttributesUpdate:u,onDiscountCodesUpdate:l,onCreateComplete:g,onLineAddComplete:h,onLineRemoveComplete:y,onLineUpdateComplete:d,onNoteUpdateComplete:f,onBuyerIdentityUpdateComplete:S,onAttributesUpdateComplete:T,onDiscountCodesUpdateComplete:w,data:v,cartFragment:b=Fr,customerAccessToken:R,countryCode:m,languageCode:p}){var Zt,Kt,Qt,Jt,Xt,zt,er;const _=le();if(!_)throw new Error("<CartProvider> needs to be a descendant of <ShopifyProvider>");m=(m??_.countryIsoCode??"US").toUpperCase(),p=(p??_.languageIsoCode??"EN").toUpperCase(),m&&(m=m.toUpperCase());const[P,O]=c.useState(m),[A,I]=c.useState(R),q=c.useRef(!1);(P!==m||A!==R)&&(O(m),I(R),q.current=!1);const[D,H]=Jr({numCartLines:t,data:v,cartFragment:b,countryCode:m,languageCode:p,onCartActionEntry(C,N){try{switch(N.type){case"CART_CREATE":return r==null?void 0:r();case"CARTLINE_ADD":return n==null?void 0:n();case"CARTLINE_REMOVE":return a==null?void 0:a();case"CARTLINE_UPDATE":return i==null?void 0:i();case"NOTE_UPDATE":return s==null?void 0:s();case"BUYER_IDENTITY_UPDATE":return o==null?void 0:o();case"CART_ATTRIBUTES_UPDATE":return u==null?void 0:u();case"DISCOUNT_CODES_UPDATE":return l==null?void 0:l()}}catch(L){console.error("Cart entry action failed",L)}},onCartActionOptimisticUI(C,N){var L,K,M,Te;if(!C.cart)return{...C};switch(N.type){case"CARTLINE_REMOVE":return{...C,cart:{...C.cart,lines:(K=(L=C==null?void 0:C.cart)==null?void 0:L.lines)==null?void 0:K.filter(x=>(x==null?void 0:x.id)&&!N.payload.lines.includes(x==null?void 0:x.id))}};case"CARTLINE_UPDATE":return{...C,cart:{...C.cart,lines:(Te=(M=C==null?void 0:C.cart)==null?void 0:M.lines)==null?void 0:Te.map(x=>{const We=N.payload.lines.find(({id:Ta})=>Ta===(x==null?void 0:x.id));return We&&We.quantity?{...x,quantity:We.quantity}:x})}}}return{...C}},onCartActionComplete(C,N){const L=N.payload.cartActionEvent;try{switch(N.type){case"RESOLVE":switch(L.type){case"CART_CREATE":return g==null?void 0:g();case"CARTLINE_ADD":return h==null?void 0:h();case"CARTLINE_REMOVE":return y==null?void 0:y();case"CARTLINE_UPDATE":return d==null?void 0:d();case"NOTE_UPDATE":return f==null?void 0:f();case"BUYER_IDENTITY_UPDATE":return nn(C,L)&&(q.current=!0),S==null?void 0:S();case"CART_ATTRIBUTES_UPDATE":return T==null?void 0:T();case"DISCOUNT_CODES_UPDATE":return w==null?void 0:w()}}}catch(K){console.error("onCartActionComplete failed",K)}}}),ee=c.useRef(!1),[Ee,U]=c.useState(!1),ue=D.matches("cartCompleted"),_e=(D.value==="idle"||D.value==="error"||D.value==="cartCompleted")&&m!==((Qt=(Kt=(Zt=D==null?void 0:D.context)==null?void 0:Zt.cart)==null?void 0:Kt.buyerIdentity)==null?void 0:Qt.countryCode)&&!D.context.errors,Se=c.useRef(!1);c.useEffect(()=>{if(!ee.current&&!Se.current){if(!v&&Me("localStorage")){Se.current=!0;try{const C=window.localStorage.getItem(ke);C&&H({type:"CART_FETCH",payload:{cartId:C}})}catch(C){console.warn("error fetching cartId"),console.warn(C)}}ee.current=!0,U(!0)}},[v,ee,H]),c.useEffect(()=>{!_e||q.current||H({type:"BUYER_IDENTITY_UPDATE",payload:{buyerIdentity:{countryCode:m,customerAccessToken:R}}})},[m,R,_e,q,H]);const B=c.useCallback(C=>{if(!ee.current)return console.warn("Cart isn't ready yet");H(C)},[H]);c.useEffect(()=>{var C,N,L;if((N=(C=D==null?void 0:D.context)==null?void 0:C.cart)!=null&&N.id&&Me("localStorage"))try{window.localStorage.setItem(ke,(L=D.context.cart)==null?void 0:L.id)}catch(K){console.warn("Failed to save cartId to localStorage",K)}},[(Xt=(Jt=D==null?void 0:D.context)==null?void 0:Jt.cart)==null?void 0:Xt.id]),c.useEffect(()=>{if(ue&&Me("localStorage"))try{window.localStorage.removeItem(ke)}catch(C){console.warn("Failed to delete cartId from localStorage",C)}},[ue]);const Ye=c.useCallback(C=>{var N,L;m&&!((N=C.buyerIdentity)!=null&&N.countryCode)&&(C.buyerIdentity==null&&(C.buyerIdentity={}),C.buyerIdentity.countryCode=m),R&&!((L=C.buyerIdentity)!=null&&L.customerAccessToken)&&(C.buyerIdentity==null&&(C.buyerIdentity={}),C.buyerIdentity.customerAccessToken=R),B({type:"CART_CREATE",payload:C})},[m,R,B]),V=rn(D),Sa=c.useMemo(()=>{var C,N,L,K;return{...((C=V==null?void 0:V.context)==null?void 0:C.cart)??{lines:[],attributes:[]},status:tn(V.value),error:(N=V==null?void 0:V.context)==null?void 0:N.errors,totalQuantity:((K=(L=V==null?void 0:V.context)==null?void 0:L.cart)==null?void 0:K.totalQuantity)??0,cartCreate:Ye,cartReady:Ee,linesAdd(M){var Te,x;(x=(Te=V==null?void 0:V.context)==null?void 0:Te.cart)!=null&&x.id?B({type:"CARTLINE_ADD",payload:{lines:M}}):Ye({lines:M})},linesRemove(M){B({type:"CARTLINE_REMOVE",payload:{lines:M}})},linesUpdate(M){B({type:"CARTLINE_UPDATE",payload:{lines:M}})},noteUpdate(M){B({type:"NOTE_UPDATE",payload:{note:M}})},buyerIdentityUpdate(M){B({type:"BUYER_IDENTITY_UPDATE",payload:{buyerIdentity:M}})},cartAttributesUpdate(M){B({type:"CART_ATTRIBUTES_UPDATE",payload:{attributes:M}})},discountCodesUpdate(M){B({type:"DISCOUNT_CODES_UPDATE",payload:{discountCodes:M}})},cartFragment:b}},[Ye,Ee,(zt=V==null?void 0:V.context)==null?void 0:zt.cart,(er=V==null?void 0:V.context)==null?void 0:er.errors,V.value,b,B]);return React.createElement(gt.Provider,{value:Sa},e)}function tn(e){switch(e){case"uninitialized":case"initializationError":return"uninitialized";case"idle":case"cartCompleted":case"error":return"idle";case"cartFetching":return"fetching";case"cartCreating":return"creating";case"cartLineAdding":case"cartLineRemoving":case"cartLineUpdating":case"noteUpdating":case"buyerIdentityUpdating":case"cartAttributesUpdating":case"discountCodesUpdating":return"updating"}}function rn(e){const[t,r]=c.useTransition(),[n,a]=c.useState(e),i=c.useRef(!1);t&&(i.current=!0);const s=c.useRef(!1);return!t&&i.current&&(s.current=!0),c.useEffect(()=>{r(()=>{s.current||a(e)})},[e]),s.current?e:n}function Me(e){let t;try{t=window[e];const r="__storage_test__";return t.setItem(r,r),t.removeItem(r),!0}catch(r){return!!(r instanceof DOMException&&(r.code===22||r.code===1014||r.name==="QuotaExceededError"||r.name==="NS_ERROR_DOM_QUOTA_REACHED")&&t&&t.length!==0)}}function nn(e,t){var r,n;return!!(t.payload.buyerIdentity.countryCode&&((n=(r=e.cart)==null?void 0:r.buyerIdentity)==null?void 0:n.countryCode)!==t.payload.buyerIdentity.countryCode)}const yt=c.createContext(null);function an({children:e,data:t,initialVariantId:r}){const n=c.useMemo(()=>Q(t.variants??{}),[t.variants]);if(!sn(n))throw new Error("<ProductProvider/> requires 'product.variants.nodes' or 'product.variants.edges'");const a=c.useMemo(()=>on(n),[n]),[i,s]=c.useState(()=>Et(r,n)),[o,u]=c.useState(()=>_t(i));c.useEffect(()=>{const T=Et(r,n);s(T),u(_t(T))},[r,n]);const l=c.useCallback((T,w)=>{u(v=>{const b={...v,[T]:w};return s(pt(n,b)),b})},[u,n]),g=c.useCallback((T,w)=>{const v=pt(n,{...o,[T]:w});return(v==null?void 0:v.availableForSale)??!0},[o,n]),h=c.useMemo(()=>Q(t.sellingPlanGroups??{}).map(T=>({...T,sellingPlans:Q((T==null?void 0:T.sellingPlans)??{})})),[t.sellingPlanGroups]),[y,d]=c.useState(void 0),f=c.useMemo(()=>{var T,w;if(!(!i||!y)){if(!((T=i.sellingPlanAllocations)!=null&&T.nodes)&&!((w=i.sellingPlanAllocations)!=null&&w.edges))throw new Error("<ProductProvider/>: You must include 'sellingPlanAllocations.nodes' or 'sellingPlanAllocations.edges' in your variants in order to calculate selectedSellingPlanAllocation");return Q(i.sellingPlanAllocations).find(v=>{var b;return((b=v==null?void 0:v.sellingPlan)==null?void 0:b.id)===y.id})}},[i,y]),S=c.useMemo(()=>({product:t,variants:n,variantsConnection:t.variants,options:a,selectedVariant:i,setSelectedVariant:s,selectedOptions:o,setSelectedOption:l,setSelectedOptions:u,isOptionInStock:g,selectedSellingPlan:y,setSelectedSellingPlan:d,selectedSellingPlanAllocation:f,sellingPlanGroups:h,sellingPlanGroupsConnection:t.sellingPlanGroups}),[t,g,a,o,y,f,i,h,l,n]);return React.createElement(yt.Provider,{value:S},e)}function mt(){const e=c.useContext(yt);if(!e)throw new Error("'useProduct' must be a child of <ProductProvider />");return e}function pt(e,t){var r,n;if(!(!e.length||((n=(r=e==null?void 0:e[0])==null?void 0:r.selectedOptions)==null?void 0:n.length)!==Object.keys(t).length))return e==null?void 0:e.find(a=>Object.entries(t).every(([i,s])=>{var o;return(o=a==null?void 0:a.selectedOptions)==null?void 0:o.some(u=>(u==null?void 0:u.name)===i&&(u==null?void 0:u.value)===s)}))}function on(e){const t=e.reduce((r,n)=>{var a;if(!n.selectedOptions)throw new Error("'getOptions' requires 'variant.selectedOptions'");return(a=n==null?void 0:n.selectedOptions)==null||a.forEach(i=>{r[(i==null?void 0:i.name)??""]=r[(i==null?void 0:i.name)??""]||new Set,r[(i==null?void 0:i.name)??""].add((i==null?void 0:i.value)??"")}),r},{});return Object.keys(t).map(r=>({name:r,values:Array.from(t[r])}))}function Et(e,t){if(e){const r=t.find(n=>(n==null?void 0:n.id)===e);return r||console.warn("<ProductProvider/> received a 'initialVariantId' prop, but could not actually find a variant with that ID"),r}if(e===null)return null;if(e===void 0)return t.find(r=>r==null?void 0:r.availableForSale)||t[0]}function _t(e){return e!=null&&e.selectedOptions?e.selectedOptions.reduce((t,r)=>(t[(r==null?void 0:r.name)??""]=(r==null?void 0:r.value)??"",t),{}):{}}function sn(e){return!(!e||!Array.isArray(e))}function Ie(e){const{as:t,onClick:r,defaultOnClick:n,children:a,buttonRef:i,...s}=e,o=c.useCallback(l=>{if(r){const g=r(l);if(typeof g=="boolean"&&g===!1||l!=null&&l.defaultPrevented)return}n==null||n(l)},[n,r]),u=t||"button";return React.createElement(u,{ref:i,onClick:o,...s},a)}function cn(e){const[t,r]=c.useState(!1),{variantId:n,quantity:a=1,attributes:i,sellingPlanId:s,onClick:o,children:u,accessibleAddingToCartLabel:l,...g}=e,{status:h,linesAdd:y}=oe(),{selectedVariant:d}=mt(),f=n??(d==null?void 0:d.id)??"",S=n===null||f===""||d===null||t||g.disabled;c.useEffect(()=>{t&&h==="idle"&&r(!1)},[h,t]);const T=c.useCallback(()=>{r(!0),y([{quantity:a,merchandiseId:f||"",attributes:i,sellingPlanId:s}])},[y,a,f,i,s]);return k.createElement(k.Fragment,null,k.createElement(Ie,{...g,disabled:S,onClick:o,defaultOnClick:T},u),l?k.createElement("p",{style:{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"},role:"alert","aria-live":"assertive"},t?l:null):null)}const re={PAGE_VIEW:"PAGE_VIEW",ADD_TO_CART:"ADD_TO_CART",PAGE_VIEW_2:"PAGE_VIEW_2",COLLECTION_VIEW:"COLLECTION_VIEW",PRODUCT_VIEW:"PRODUCT_VIEW",SEARCH_VIEW:"SEARCH_VIEW"},ve={article:"article",blog:"blog",captcha:"captcha",cart:"cart",collection:"collection",customersAccount:"customers/account",customersActivateAccount:"customers/activate_account",customersAddresses:"customers/addresses",customersLogin:"customers/login",customersOrder:"customers/order",customersRegister:"customers/register",customersResetPassword:"customers/reset_password",giftCard:"gift_card",home:"index",listCollections:"list-collections",forbidden:"403",notFound:"404",page:"page",password:"password",product:"product",policy:"policy",search:"search"},St={hydrogen:"hydrogen",headless:"headless"},Tt={hydrogen:"6167201",headless:"12875497473"};function $(e,t){return{schema_id:e,payload:t,metadata:{event_created_at_ms:Date.now()}}}function F(e){const t={id:"",resource:null,resourceId:null,search:"",searchParams:new URLSearchParams,hash:""};if(typeof e!="string")return t;try{const{search:r,searchParams:n,pathname:a,hash:i}=new URL(e),s=a.split("/"),o=s[s.length-1],u=s[s.length-2];return!o||!u?t:{id:`${o}${r}${i}`||"",resource:u??null,resourceId:o||null,search:r,searchParams:n,hash:i}}catch{return t}}function j(e,t){return typeof e!="object"?{}:(Object.entries(e).forEach(([r,n])=>{n&&(t[r]=n)}),t)}function un(e){return typeof document>"u"?(console.error(`${e} should only be used within the useEffect callback or event handlers`),!0):!1}const ln="trekkie_storefront_page_view/1.4",dn="myshopify.dev";function Ct(e){const t=e,{id:r,resource:n}=F(t.resourceId),a=n?n.toLowerCase():void 0;return[$(ln,j({pageType:t.pageType,customerId:parseInt(F(t.customerId).id||"0"),resourceType:a,resourceId:parseInt(r)},fn(t)))]}function fn(e){return{appClientId:e.shopifySalesChannel?Tt[e.shopifySalesChannel]:Tt.headless,isMerchantRequest:hn(e.url),hydrogenSubchannelId:e.storefrontId||e.hydrogenSubchannelId||"0",isPersistentCookie:e.hasUserConsent,uniqToken:e.uniqueToken,visitToken:e.visitToken,microSessionId:we(),microSessionCount:1,url:e.url,path:e.path,search:e.search,referrer:e.referrer,title:e.title,shopId:parseInt(F(e.shopId).id),currency:e.currency,contentLanguage:e.acceptedLanguage||"en"}}function hn(e){if(typeof e!="string")return!1;const t=new URL(e).hostname;return t.indexOf(dn)!==-1||t==="localhost"}const gn="2025.1.2",G="custom_storefront_customer_tracking/1.2",At="page_rendered",wt="collection_page_rendered",bt="product_page_rendered",yn="product_added_to_cart",It="search_submitted";function fe(e){return{canonical_url:e.canonicalUrl||e.url,customer_id:parseInt(F(e.customerId).id||"0")}}function mn(e){const t=e,r=fe(t),n=t.pageType,a=[];switch(a.push($(G,j({event_name:At,...r},Z(t)))),n){case ve.collection:a.push($(G,j({event_name:wt,...r,collection_name:t.collectionHandle,collection_id:parseInt(F(t.collectionId).id)},Z(t))));break;case ve.product:a.push($(G,j({event_name:bt,...r,products:Le(t.products),total_value:t.totalValue},Z(t))));break;case ve.search:a.push($(G,j({event_name:It,...r,search_string:t.searchString},Z(t))));break}return a}function pn(e){const t=e,r=fe(t);return[$(G,j({event_name:At,...r},Z(t)))]}function En(e){const t=e,r=fe(t);return[$(G,j({event_name:wt,...r,collection_name:t.collectionHandle,collection_id:parseInt(F(t.collectionId).id)},Z(t)))]}function _n(e){const t=e,r=fe(t);return[$(G,j({event_name:bt,...r,products:Le(t.products),total_value:t.totalValue},Z(t)))]}function Sn(e){const t=e,r=fe(t);return[$(G,j({event_name:It,...r,search_string:t.searchString},Z(t)))]}function Tn(e){const t=e,r=F(t.cartId);return[$(G,j({event_name:yn,customerId:t.customerId,cart_token:r!=null&&r.id?`${r.id}`:null,total_value:t.totalValue,products:Le(t.products),customer_id:parseInt(F(t.customerId).id||"0")},Z(t)))]}function Z(e){return{source:e.shopifySalesChannel||St.headless,asset_version_id:e.assetVersionId||gn,hydrogenSubchannelId:e.storefrontId||e.hydrogenSubchannelId||"0",is_persistent_cookie:e.hasUserConsent,deprecated_visit_token:e.visitToken,unique_token:e.uniqueToken,event_time:Date.now(),event_id:we(),event_source_url:e.url,referrer:e.referrer,user_agent:e.userAgent,navigation_type:e.navigationType,navigation_api:e.navigationApi,shop_id:parseInt(F(e.shopId).id),currency:e.currency,ccpa_enforced:e.ccpaEnforced||!1,gdpr_enforced:e.gdprEnforced||!1,gdpr_enforced_as_string:e.gdprEnforced?"true":"false",analytics_allowed:e.analyticsAllowed||!1,marketing_allowed:e.marketingAllowed||!1,sale_of_data_allowed:e.saleOfDataAllowed||!1}}function Le(e){return e?e.map(t=>{const r=j({variant_gid:t.variantGid,category:t.category,sku:t.sku,product_id:parseInt(F(t.productGid).id),variant_id:parseInt(F(t.variantGid).id)},{product_gid:t.productGid,name:t.name,variant:t.variantName||"",brand:t.brand,price:parseFloat(t.price),quantity:Number(t.quantity||0)});return JSON.stringify(r)}):[]}function Cn(e,t){const{eventName:r,payload:n}=e;if(!n.hasUserConsent)return Promise.resolve();let a=[];const i=n;return r===re.PAGE_VIEW?a=a.concat(Ct(i),mn(i)):r===re.ADD_TO_CART?a=a.concat(Tn(n)):r===re.PAGE_VIEW_2?a=a.concat(Ct(i),pn(i)):r===re.COLLECTION_VIEW?a=a.concat(En(i)):r===re.PRODUCT_VIEW?a=a.concat(_n(i)):r===re.SEARCH_VIEW&&(a=a.concat(Sn(i))),a.length?wn(a,t):Promise.resolve()}function An(){return typeof window>"u"||!window.navigator?!1:/Chrome-Lighthouse/.test(window.navigator.userAgent)}const vt="sendShopifyAnalytics request is unsuccessful";function wn(e,t){if(An())return Promise.resolve();const r={events:e,metadata:{event_sent_at_ms:Date.now()}};try{return fetch(t?`https://${t}/.well-known/shopify/monorail/unstable/produce_batch`:"https://monorail-edge.shopifysvc.com/unstable/produce_batch",{method:"post",headers:{"content-type":"text/plain"},body:JSON.stringify(r)}).then(n=>{if(!n.ok)throw new Error("Response failed");return n.text()}).then(n=>{n&&JSON.parse(n).result.forEach(i=>{i.status!==200&&console.error(vt,`
|
|
273
273
|
|
|
274
274
|
`,i.message)})}).catch(n=>{console.error(vt,n)})}catch{return Promise.resolve()}}function bn(){if(un("getClientBrowserParameters"))return{uniqueToken:"",visitToken:"",url:"",path:"",search:"",referrer:"",title:"",userAgent:"",navigationType:"",navigationApi:""};const[e,t]=Pn(),r=be(document.cookie);return{uniqueToken:r[J],visitToken:r[X],url:location.href,path:location.pathname,search:location.search,referrer:document.referrer,title:document.title,userAgent:navigator.userAgent,navigationType:e,navigationApi:t}}function In(){try{const e=(performance==null?void 0:performance.getEntriesByType)&&(performance==null?void 0:performance.getEntriesByType("navigation"));if(e&&e[0]){const t=window.performance.getEntriesByType("navigation")[0].type;return t&&t.toString()}}catch{}}function vn(){var e,t;try{if(PerformanceNavigation&&((e=performance==null?void 0:performance.navigation)==null?void 0:e.type)!==null&&((t=performance==null?void 0:performance.navigation)==null?void 0:t.type)!==void 0){const r=performance.navigation.type;switch(r){case PerformanceNavigation.TYPE_NAVIGATE:return"navigate";case PerformanceNavigation.TYPE_RELOAD:return"reload";case PerformanceNavigation.TYPE_BACK_FORWARD:return"back_forward";default:return`unknown: ${r}`}}}catch{}}function Pn(){try{let e="PerformanceNavigationTiming",t=In();return t||(t=vn(),e="performance.navigation"),t?[t,e]:["unknown","unknown"]}catch{}return["error","error"]}function On(e){const{cartCreate:t,checkoutUrl:r}=oe(),[n,a]=c.useState(!1),{quantity:i,variantId:s,sellingPlanId:o,onClick:u,attributes:l,children:g,...h}=e;c.useEffect(()=>{n&&r&&(window.location.href=r)},[n,r]);const y=c.useCallback(()=>{a(!0),t({lines:[{quantity:i??1,merchandiseId:s,attributes:l,sellingPlanId:o}]})},[t,i,s,l,o]);return React.createElement(Ie,{disabled:n??h.disabled,...h,onClick:u,defaultOnClick:y},g)}function Rn(e){const[t,r]=c.useState(!1),{status:n,checkoutUrl:a}=oe(),{children:i,...s}=e;return c.useEffect(()=>{t&&a&&n==="idle"&&(window.location.href=a)},[t,n,a]),React.createElement(Ie,{...s,disabled:t||s.disabled,onClick:()=>r(!0)},i)}function Pt(e){const{countryIsoCode:t,languageIsoCode:r}=le(),n=r.includes("_")?r.replace("_","-"):`${r}-${t}`;if(!n)throw new Error("useMoney(): Unable to get 'locale' from 'useShop()', which means that 'locale' was not passed to '<ShopifyProvider/>'. 'locale' is required for 'useMoney()' to work");const a=parseFloat(e.amount),{defaultFormatter:i,nameFormatter:s,narrowSymbolFormatter:o,withoutTrailingZerosFormatter:u,withoutCurrencyFormatter:l,withoutTrailingZerosOrCurrencyFormatter:g}=c.useMemo(()=>{const d={style:"currency",currency:e.currencyCode};return{defaultFormatter:se(n,d),nameFormatter:se(n,{...d,currencyDisplay:"name"}),narrowSymbolFormatter:se(n,{...d,currencyDisplay:"narrowSymbol"}),withoutTrailingZerosFormatter:se(n,{...d,minimumFractionDigits:0,maximumFractionDigits:0}),withoutCurrencyFormatter:se(n),withoutTrailingZerosOrCurrencyFormatter:se(n,{minimumFractionDigits:0,maximumFractionDigits:0})}},[e.currencyCode,n]),h=d=>d.type==="currency",y=c.useMemo(()=>({original:()=>e,currencyCode:()=>e.currencyCode,localizedString:()=>i().format(a),parts:()=>i().formatToParts(a),withoutTrailingZeros:()=>a%1===0?u().format(a):i().format(a),withoutTrailingZerosAndCurrency:()=>a%1===0?g().format(a):l().format(a),currencyName:()=>{var d;return((d=s().formatToParts(a).find(h))==null?void 0:d.value)??e.currencyCode},currencySymbol:()=>{var d;return((d=i().formatToParts(a).find(h))==null?void 0:d.value)??e.currencyCode},currencyNarrowSymbol:()=>{var d;return((d=o().formatToParts(a).find(h))==null?void 0:d.value)??""},amount:()=>i().formatToParts(a).filter(d=>["decimal","fraction","group","integer","literal"].includes(d.type)).map(d=>d.value).join("")}),[e,a,s,i,o,l,u,g]);return c.useMemo(()=>new Proxy(y,{get:(d,f)=>{var S;return(S=Reflect.get(d,f))==null?void 0:S.call(null)}}),[y])}const Ot=new Map;function se(e,t){const r=JSON.stringify([e,t]);return function(){let n=Ot.get(r);return n||(n=new Intl.NumberFormat(e,t),Ot.set(r,n)),n}}function Pe({data:e,as:t,withoutCurrency:r,withoutTrailingZeros:n,measurement:a,measurementSeparator:i="/",...s}){if(!Dn(e))throw new Error("<Money/> needs a valid 'data' prop that has 'amount' and 'currencyCode'");const o=Pt(e),u=t??"div";let l=o.localizedString;return(r||n)&&(r&&!n?l=o.amount:!r&&n?l=o.withoutTrailingZeros:l=o.withoutTrailingZerosAndCurrency),React.createElement(u,{...s},l,a&&a.referenceUnit&&React.createElement(React.Fragment,null,i,a.referenceUnit))}function Dn(e){return typeof e.amount=="string"&&!!e.amount&&typeof e.currencyCode=="string"&&!!e.currencyCode}function Vn(e){const{cost:t}=oe(),{amountType:r="total",children:n,...a}=e;let i;return r=="total"?i=t==null?void 0:t.totalAmount:r=="subtotal"?i=t==null?void 0:t.subtotalAmount:r=="tax"?i=t==null?void 0:t.totalTaxAmount:r=="duty"&&(i=t==null?void 0:t.totalDutyAmount),i==null?null:React.createElement(Pe,{...a,data:i},n)}const Rt=c.createContext(null);function xe(){const e=c.useContext(Rt);if(e==null)throw new Error("Expected a cart line context but none was found");return e}function Un({children:e,line:t}){return React.createElement(Rt.Provider,{value:t},e)}function kn(e){const t=xe(),{as:r,...n}=e,a=r||"span";return React.createElement(a,{...n},t.quantity)}function Nn(e){const{status:t,linesRemove:r,linesUpdate:n}=oe(),a=xe(),{children:i,adjust:s,onClick:o,...u}=e,l=c.useCallback(()=>{if(s==="remove"){r([(a==null?void 0:a.id)??""]);return}const h=s==="decrease"?((a==null?void 0:a.quantity)??0)-1:((a==null?void 0:a.quantity)??0)+1;if(h<=0){r([(a==null?void 0:a.id)??""]);return}const y={id:(a==null?void 0:a.id)??"",quantity:h,attributes:(a==null?void 0:a.attributes)??[]};n([y])},[s,a==null?void 0:a.attributes,a==null?void 0:a.id,a==null?void 0:a.quantity,r,n]),g=u.disabled;return React.createElement(Ie,{...u,onClick:o,defaultOnClick:l,disabled:typeof g<"u"?g:t!=="idle"},i)}const Mn={DateTime:"string",Decimal:"string",HTML:"string",URL:"string",Color:"string",UnsignedInt64:"string"},Ln={DateTime:"string",Decimal:"string",HTML:"string",ISO8601DateTime:"string",URL:"string",UnsignedInt64:"string"},Dt=c.forwardRef((e,t)=>{const{data:r,options:n,id:a=r.id,frameBorder:i="0",allow:s="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:o=!0,loading:u="lazy",...l}=e;if(!r.embedUrl)throw new Error("<ExternalVideo/> requires the 'embedUrl' property");let g=r.embedUrl;if(n){const h=new URL(r.embedUrl);for(const[y,d]of Object.entries(n))typeof d>"u"||h.searchParams.set(y,d.toString());g=h.toString()}return React.createElement("iframe",{...l,id:a??r.embedUrl,title:r.alt??r.id??"external video",frameBorder:i,allow:s,allowFullScreen:o,src:g,loading:u,ref:t})}),Fe=",",ce={OPTION:":",END_OF_PREFIX:",",SEQUENCE_GAP:" ",RANGE:"-"},je=(()=>{const e=new Map;return function(t,r){var n;if(t.length===0)return!1;if(!e.has(r)){const a=new Set;for(const i of Vt(r)){a.add(i.join(Fe));for(let s=0;s<i.length;s++)a.add(i.slice(0,s+1).join(Fe))}e.set(r,a)}return!!((n=e.get(r))!=null&&n.has(t.join(Fe)))}})();function Vt(e){if(!e)return[];if(e.startsWith("v1_"))return Fn(xn(e));throw new Error("Unsupported option value encoding")}const xn=e=>e.replace(/^v1_/,"");function Fn(e){const t=/[ :,-]/g;let r=0,n;const a=[],i=[];let s=0,o=null;for(;n=t.exec(e);){const l=n[0],g=Number.parseInt(e.slice(r,n.index))||0;if(o!==null){for(;o<g;o++)i[s]=o,a.push([...i]);o=null}i[s]=g,l===ce.RANGE?o=g:l===ce.OPTION?s++:((l===ce.SEQUENCE_GAP||l===ce.END_OF_PREFIX&&e[n.index-1]!==ce.END_OF_PREFIX)&&a.push([...i]),l===ce.END_OF_PREFIX&&(i.pop(),s--)),r=t.lastIndex}const u=e.match(/\d+$/g);if(u){const l=parseInt(u[0]);if(o!=null)for(;o<=l;o++)i[s]=o,a.push([...i]);else a.push([l])}return a}function jn(e){return Object.assign({},...e.map(t=>({[t.name]:Object.assign({},...t!=null&&t.optionValues?t.optionValues.map((r,n)=>({[r.name]:n})):[])})))}function he(e){return Object.assign({},...e.map(t=>({[t.name]:t.value})))}function $e(e){return JSON.stringify(he(e))}function Ut(e){return Array.isArray(e)?JSON.stringify(Object.assign({},...e.map(t=>({[t.name]:t.value})))):JSON.stringify(e)}function $n(e,t){return Object.keys(e).map(n=>t[n]?t[n][e[n]]:null).filter(n=>n!==null)}function qn(e){return Object.assign({},...e.map(t=>({[Ut(t.selectedOptions||[])]:t})))}const kt=["options","selectedOrFirstAvailableVariant","adjacentVariants"],Hn=["handle","encodedVariantExistence","encodedVariantAvailability"];function z(e){return console.error(`[h2:error:getProductOptions] product.${e} is missing. Make sure you query for this field from the Storefront API.`),!1}function Nt(e,t=!1){var a;let r=!0;const n=Object.keys(e);if((t?[...kt,...Hn]:kt).forEach(i=>{n.includes(i)||(r=z(i))}),e.options){const i=e==null?void 0:e.options[0];if(t&&!(i!=null&&i.name)&&(r=z("options.name")),(a=e==null?void 0:e.options[0])!=null&&a.optionValues){let s=e.options[0].optionValues[0];t&&!(s!=null&&s.name)&&(r=z("options.optionValues.name")),s=e.options[0].optionValues.filter(o=>!!(o!=null&&o.firstSelectableVariant))[0],s!=null&&s.firstSelectableVariant&&(r=qe(s.firstSelectableVariant,"options.optionValues.firstSelectableVariant",r,t))}else r=z("options.optionValues")}return e.selectedOrFirstAvailableVariant&&(r=qe(e.selectedOrFirstAvailableVariant,"selectedOrFirstAvailableVariant",r,t)),e.adjacentVariants&&e.adjacentVariants[0]&&(r=qe(e.adjacentVariants[0],"adjacentVariants",r,t)),r?e:{}}function qe(e,t,r,n){var i;let a=r;if(n&&!((i=e.product)!=null&&i.handle)&&(a=z(`${t}.product.handle`)),e.selectedOptions){const s=e.selectedOptions[0];s!=null&&s.name||(a=z(`${t}.selectedOptions.name`)),s!=null&&s.value||(a=z(`${t}.selectedOptions.value`))}else a=z(`${t}.selectedOptions`);return a}function Bn(e){const t=Nt(e);if(!t.options)return[];const r={};t.options.map(a=>{var i;(i=a.optionValues)==null||i.map(s=>{if(s.firstSelectableVariant){const o=$e(s.firstSelectableVariant.selectedOptions);r[o]=s.firstSelectableVariant}})}),t.adjacentVariants.map(a=>{const i=$e(a.selectedOptions);r[i]=a});const n=t.selectedOrFirstAvailableVariant;if(n){const a=$e(n.selectedOptions);r[a]=n}return Object.values(r)}function Yn(e){const t=Nt(e,!0);if(!t.options)return[];const{options:r,selectedOrFirstAvailableVariant:n,adjacentVariants:a,encodedVariantExistence:i,encodedVariantAvailability:s,handle:o}=t,u=n==null?void 0:n.selectedOptions.map(f=>f.name),l=r.filter(f=>u&&u.indexOf(f.name)>=0),g=jn(r),h=qn(n?[n,...a]:a),y=he(n?n.selectedOptions:[]);return l.map((f,S)=>({...f,optionValues:f.optionValues.map(T=>{var I;const w={...y};w[f.name]=T.name;const v=Ut(w||[]),R=$n(w||[],g).slice(0,S+1),m=je(R,i||""),p=je(R,s||""),_=h[v]||T.firstSelectableVariant;let P={};_&&(P=he(_.selectedOptions||[]));const O=new URLSearchParams(P),A=((I=_==null?void 0:_.product)==null?void 0:I.handle)||o;return{...T,variant:_,handle:A,variantUriQuery:O.toString(),selected:y[f.name]===T.name,exists:m,available:p,isDifferentProduct:A!==o}})}))}const Wn=`#graphql
|
|
275
275
|
fragment Image on Image {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopify/hydrogen-react",
|
|
3
|
-
"version": "2025.1.
|
|
3
|
+
"version": "2025.1.2",
|
|
4
4
|
"description": "React components, hooks, and utilities for creating custom Shopify storefronts",
|
|
5
5
|
"homepage": "https://github.com/Shopify/hydrogen/tree/main/packages/hydrogen-react",
|
|
6
6
|
"license": "MIT",
|
|
@@ -148,7 +148,6 @@
|
|
|
148
148
|
"cpy-cli": "^4.2.0",
|
|
149
149
|
"happy-dom": "^17.0.0",
|
|
150
150
|
"npm-run-all": "^4.1.5",
|
|
151
|
-
"prettier": "^3.4.2",
|
|
152
151
|
"react": "^18.0.0",
|
|
153
152
|
"react-dom": "^18.0.0",
|
|
154
153
|
"rimraf": "^4.1.2",
|