@shopify/hydrogen-react 2025.4.0 → 2025.5.1
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/ShopifyProvider.mjs +18 -1
- package/dist/browser-dev/ShopifyProvider.mjs.map +1 -1
- package/dist/browser-dev/analytics.mjs +4 -5
- package/dist/browser-dev/analytics.mjs.map +1 -1
- package/dist/browser-dev/cart-hooks.mjs +25 -7
- package/dist/browser-dev/cart-hooks.mjs.map +1 -1
- package/dist/browser-dev/cookies-utils.mjs +4 -4
- package/dist/browser-dev/cookies-utils.mjs.map +1 -1
- package/dist/browser-dev/index.mjs +4 -0
- package/dist/browser-dev/index.mjs.map +1 -1
- package/dist/browser-dev/packages/hydrogen-react/package.json.mjs +1 -1
- package/dist/browser-dev/tracking-utils.mjs +92 -0
- package/dist/browser-dev/tracking-utils.mjs.map +1 -0
- package/dist/browser-dev/useShopifyCookies.mjs +96 -9
- package/dist/browser-dev/useShopifyCookies.mjs.map +1 -1
- package/dist/browser-prod/ShopifyProvider.mjs +18 -1
- package/dist/browser-prod/ShopifyProvider.mjs.map +1 -1
- package/dist/browser-prod/analytics.mjs +4 -5
- package/dist/browser-prod/analytics.mjs.map +1 -1
- package/dist/browser-prod/cart-hooks.mjs +25 -7
- package/dist/browser-prod/cart-hooks.mjs.map +1 -1
- package/dist/browser-prod/cookies-utils.mjs +4 -4
- package/dist/browser-prod/cookies-utils.mjs.map +1 -1
- package/dist/browser-prod/index.mjs +4 -0
- package/dist/browser-prod/index.mjs.map +1 -1
- package/dist/browser-prod/packages/hydrogen-react/package.json.mjs +1 -1
- package/dist/browser-prod/tracking-utils.mjs +92 -0
- package/dist/browser-prod/tracking-utils.mjs.map +1 -0
- package/dist/browser-prod/useShopifyCookies.mjs +96 -9
- package/dist/browser-prod/useShopifyCookies.mjs.map +1 -1
- package/dist/node-dev/ShopifyProvider.js +18 -1
- package/dist/node-dev/ShopifyProvider.js.map +1 -1
- package/dist/node-dev/ShopifyProvider.mjs +18 -1
- package/dist/node-dev/ShopifyProvider.mjs.map +1 -1
- package/dist/node-dev/analytics.js +4 -5
- package/dist/node-dev/analytics.js.map +1 -1
- package/dist/node-dev/analytics.mjs +4 -5
- package/dist/node-dev/analytics.mjs.map +1 -1
- package/dist/node-dev/cart-hooks.js +24 -6
- package/dist/node-dev/cart-hooks.js.map +1 -1
- package/dist/node-dev/cart-hooks.mjs +25 -7
- package/dist/node-dev/cart-hooks.mjs.map +1 -1
- package/dist/node-dev/cookies-utils.js +4 -4
- package/dist/node-dev/cookies-utils.js.map +1 -1
- package/dist/node-dev/cookies-utils.mjs +4 -4
- package/dist/node-dev/cookies-utils.mjs.map +1 -1
- package/dist/node-dev/index.js +4 -0
- package/dist/node-dev/index.js.map +1 -1
- package/dist/node-dev/index.mjs +4 -0
- package/dist/node-dev/index.mjs.map +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-dev/tracking-utils.js +92 -0
- package/dist/node-dev/tracking-utils.js.map +1 -0
- package/dist/node-dev/tracking-utils.mjs +92 -0
- package/dist/node-dev/tracking-utils.mjs.map +1 -0
- package/dist/node-dev/useShopifyCookies.js +94 -7
- package/dist/node-dev/useShopifyCookies.js.map +1 -1
- package/dist/node-dev/useShopifyCookies.mjs +96 -9
- package/dist/node-dev/useShopifyCookies.mjs.map +1 -1
- package/dist/node-prod/ShopifyProvider.js +18 -1
- package/dist/node-prod/ShopifyProvider.js.map +1 -1
- package/dist/node-prod/ShopifyProvider.mjs +18 -1
- package/dist/node-prod/ShopifyProvider.mjs.map +1 -1
- package/dist/node-prod/analytics.js +4 -5
- package/dist/node-prod/analytics.js.map +1 -1
- package/dist/node-prod/analytics.mjs +4 -5
- package/dist/node-prod/analytics.mjs.map +1 -1
- package/dist/node-prod/cart-hooks.js +24 -6
- package/dist/node-prod/cart-hooks.js.map +1 -1
- package/dist/node-prod/cart-hooks.mjs +25 -7
- package/dist/node-prod/cart-hooks.mjs.map +1 -1
- package/dist/node-prod/cookies-utils.js +4 -4
- package/dist/node-prod/cookies-utils.js.map +1 -1
- package/dist/node-prod/cookies-utils.mjs +4 -4
- package/dist/node-prod/cookies-utils.mjs.map +1 -1
- package/dist/node-prod/index.js +4 -0
- package/dist/node-prod/index.js.map +1 -1
- package/dist/node-prod/index.mjs +4 -0
- package/dist/node-prod/index.mjs.map +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/node-prod/tracking-utils.js +92 -0
- package/dist/node-prod/tracking-utils.js.map +1 -0
- package/dist/node-prod/tracking-utils.mjs +92 -0
- package/dist/node-prod/tracking-utils.mjs.map +1 -0
- package/dist/node-prod/useShopifyCookies.js +94 -7
- package/dist/node-prod/useShopifyCookies.js.map +1 -1
- package/dist/node-prod/useShopifyCookies.mjs +96 -9
- package/dist/node-prod/useShopifyCookies.mjs.map +1 -1
- package/dist/types/ShopifyProvider.d.ts +5 -0
- package/dist/types/cookies-utils.d.ts +4 -0
- package/dist/types/index.d.cts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/tracking-utils.d.ts +21 -0
- package/dist/types/useShopifyCookies.d.ts +28 -2
- package/dist/umd/hydrogen-react.dev.js +275 -89
- package/dist/umd/hydrogen-react.dev.js.map +1 -1
- package/dist/umd/hydrogen-react.prod.js +18 -18
- package/dist/umd/hydrogen-react.prod.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(S,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],u):(S=typeof globalThis<"u"?globalThis:S||self,u(S.hydrogenreact={},S.React))})(this,function(S,u){"use strict";function cn(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const U=cn(u);/*! *****************************************************************************
|
|
2
2
|
Copyright (c) Microsoft Corporation.
|
|
3
3
|
|
|
4
4
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
12
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
13
|
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
-
***************************************************************************** */function
|
|
14
|
+
***************************************************************************** */function Je(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r,a,i=n.call(e),s=[];try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(o){a={error:o}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(a)throw a.error}}return s}var z;(function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"})(z||(z={}));var Xe={type:"xstate.init"};function Pe(e){return e===void 0?[]:[].concat(e)}function ne(e){return{type:"xstate.assign",assignment:e}}function ze(e,t){return typeof(e=typeof e=="string"&&t&&t[e]?t[e]:e)=="string"?{type:e}:typeof e=="function"?{type:e.name,exec:e}:e}function Se(e){return function(t){return e===t}}function et(e){return typeof e=="string"?{type:e}:e}function tt(e,t){return{value:e,context:t,actions:[],changed:!1,matches:Se(e)}}function nt(e,t,n){var r=t,a=!1;return[e.filter(function(i){if(i.type==="xstate.assign"){a=!0;var s=Object.assign({},r);return typeof i.assignment=="function"?s=i.assignment(r,n):Object.keys(i.assignment).forEach(function(o){s[o]=typeof i.assignment[o]=="function"?i.assignment[o](r,n):i.assignment[o]}),r=s,!1}return!0}),r,a]}function rt(e,t){t===void 0&&(t={});var n=Je(nt(Pe(e.states[e.initial].entry).map(function(s){return ze(s,t.actions)}),e.context,Xe),2),r=n[0],a=n[1],i={config:e,_options:t,initialState:{value:e.initial,actions:r,context:a,matches:Se(e.initial)},transition:function(s,o){var c,l,g=typeof s=="string"?{value:s,context:e.context}:s,d=g.value,y=g.context,f=et(o),h=e.states[d];if(h.on){var _=Pe(h.on[f.type]);try{for(var T=function(V){var se=typeof Symbol=="function"&&Symbol.iterator,pe=se&&V[se],Ee=0;if(pe)return pe.call(V);if(V&&typeof V.length=="number")return{next:function(){return V&&Ee>=V.length&&(V=void 0),{value:V&&V[Ee++],done:!V}}};throw new TypeError(se?"Object is not iterable.":"Symbol.iterator is not defined.")}(_),b=T.next();!b.done;b=T.next()){var I=b.value;if(I===void 0)return tt(d,y);var A=typeof I=="string"?{target:I}:I,v=A.target,p=A.actions,m=p===void 0?[]:p,E=A.cond,P=E===void 0?function(){return!0}:E,R=v===void 0,w=v??d,O=e.states[w];if(P(y,f)){var H=Je(nt((R?Pe(m):[].concat(h.exit,m,O.entry).filter(function(V){return V})).map(function(V){return ze(V,i._options.actions)}),y,f),3),k=H[0],$=H[1],X=H[2],me=v??d;return{value:me,context:$,actions:k,changed:v!==d||k.length>0||X,matches:Se(me)}}}}catch(V){c={error:V}}finally{try{b&&!b.done&&(l=T.return)&&l.call(T)}finally{if(c)throw c.error}}}return tt(d,y)}};return i}var at=function(e,t){return e.actions.forEach(function(n){var r=n.exec;return r&&r(e.context,t)})};function un(e){var t=e.initialState,n=z.NotStarted,r=new Set,a={_machine:e,send:function(i){n===z.Running&&(t=e.transition(t,i),at(t,et(i)),r.forEach(function(s){return s(t)}))},subscribe:function(i){return r.add(i),i(t),{unsubscribe:function(){return r.delete(i)}}},start:function(i){if(i){var s=typeof i=="object"?i:{context:e.config.context,value:i};t={value:s.value,actions:[],context:s.context,matches:Se(s.value)}}else t=e.initialState;return n=z.Running,at(t,Xe),a},stop:function(){return n=z.Stopped,r.clear(),a},get state(){return t},get status(){return n}};return a}var ln=u.useLayoutEffect,Oe={exports:{}},Re={},ke={exports:{}},De={};/**
|
|
15
15
|
* @license React
|
|
16
16
|
* use-sync-external-store-shim.production.min.js
|
|
17
17
|
*
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*
|
|
20
20
|
* This source code is licensed under the MIT license found in the
|
|
21
21
|
* LICENSE file in the root directory of this source tree.
|
|
22
|
-
*/var
|
|
22
|
+
*/var it;function dn(){if(it)return De;it=1;var e=u;function t(d,y){return d===y&&(d!==0||1/d===1/y)||d!==d&&y!==y}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,a=e.useEffect,i=e.useLayoutEffect,s=e.useDebugValue;function o(d,y){var f=y(),h=r({inst:{value:f,getSnapshot:y}}),_=h[0].inst,T=h[1];return i(function(){_.value=f,_.getSnapshot=y,c(_)&&T({inst:_})},[d,f,y]),a(function(){return c(_)&&T({inst:_}),d(function(){c(_)&&T({inst:_})})},[d]),s(f),f}function c(d){var y=d.getSnapshot;d=d.value;try{var f=y();return!n(d,f)}catch{return!0}}function l(d,y){return y()}var g=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?l:o;return De.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:g,De}var ot;function fn(){return ot||(ot=1,ke.exports=dn()),ke.exports}/**
|
|
23
23
|
* @license React
|
|
24
24
|
* use-sync-external-store-shim/with-selector.production.min.js
|
|
25
25
|
*
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
*
|
|
28
28
|
* This source code is licensed under the MIT license found in the
|
|
29
29
|
* LICENSE file in the root directory of this source tree.
|
|
30
|
-
*/var
|
|
30
|
+
*/var st;function hn(){if(st)return Re;st=1;var e=u,t=fn();function n(l,g){return l===g&&(l!==0||1/l===1/g)||l!==l&&g!==g}var r=typeof Object.is=="function"?Object.is:n,a=t.useSyncExternalStore,i=e.useRef,s=e.useEffect,o=e.useMemo,c=e.useDebugValue;return Re.useSyncExternalStoreWithSelector=function(l,g,d,y,f){var h=i(null);if(h.current===null){var _={hasValue:!1,value:null};h.current=_}else _=h.current;h=o(function(){function b(m){if(!I){if(I=!0,A=m,m=y(m),f!==void 0&&_.hasValue){var E=_.value;if(f(E,m))return v=E}return v=m}if(E=v,r(A,m))return E;var P=y(m);return f!==void 0&&f(E,P)?E:(A=m,v=P)}var I=!1,A,v,p=d===void 0?null:d;return[function(){return b(g())},p===null?void 0:function(){return b(p())}]},[g,d,y,f]);var T=a(l,h[0],h[1]);return s(function(){_.hasValue=!0,_.value=T},[T]),c(T),T},Re}var ct;function gn(){return ct||(ct=1,Oe.exports=hn()),Oe.exports}var yn=gn();function mn(e){var t=U.useRef();return t.current||(t.current={v:e()}),t.current.v}var pn=function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),a,i=[],s;try{for(;(t===void 0||t-- >0)&&!(a=r.next()).done;)i.push(a.value)}catch(o){s={error:o}}finally{try{a&&!a.done&&(n=r.return)&&n.call(r)}finally{if(s)throw s.error}}return i};function En(e){return e}var _n=function(e){var t;return e.subscribe(function(n){t=n}).unsubscribe(),t};function Sn(e,t){var n=u.useRef(),r=pn(mn(function(){var o=[],c=un(rt(e.config,t||e._options)),l=c.send;return c.send=function(g){if(c.status===z.NotStarted){o.push(g);return}l(g),n.current=c.state},[c,o]}),2),a=r[0],i=r[1];ln(function(){t&&(a._machine._options=t)});var s=Cn(a);return u.useEffect(function(){return a.start(n.current),i.forEach(a.send),n.current=a.state,function(){a.stop()}},[]),s}var Tn=function(e,t){return t.changed===!1};function Cn(e){var t=u.useCallback(function(){return _n(e)},[e]),n=u.useCallback(function(a){var i=e.subscribe(a).unsubscribe;return i},[e]),r=yn.useSyncExternalStoreWithSelector(n,t,t,En,Tn);return[r,e.send,e]}function Q(e){if(!e){const t=`flattenConnection(): needs a 'connection' to flatten, but received '${e??""}' instead.`;return console.error(t+" Returning an empty array"),[]}return"nodes"in e?e.nodes:"edges"in e&&Array.isArray(e.edges)?e.edges.map(t=>{if(!(t!=null&&t.node))throw new Error("flattenConnection(): Connection edges must contain nodes");return t.node}):[]}const wn=e=>`
|
|
31
31
|
mutation CartLineAdd(
|
|
32
32
|
$cartId: ID!
|
|
33
33
|
$lines: [CartLineInput!]!
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
${e}
|
|
46
|
-
`,
|
|
46
|
+
`,An=e=>`
|
|
47
47
|
mutation CartCreate(
|
|
48
48
|
$input: CartInput!
|
|
49
49
|
$numCartLines: Int = 250
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
${e}
|
|
61
|
-
`,
|
|
61
|
+
`,bn=e=>`
|
|
62
62
|
mutation CartLineRemove(
|
|
63
63
|
$cartId: ID!
|
|
64
64
|
$lines: [ID!]!
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
${e}
|
|
77
|
-
`,
|
|
77
|
+
`,In=e=>`
|
|
78
78
|
mutation CartLineUpdate(
|
|
79
79
|
$cartId: ID!
|
|
80
80
|
$lines: [CartLineUpdateInput!]!
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
${e}
|
|
93
|
-
`,
|
|
93
|
+
`,vn=e=>`
|
|
94
94
|
mutation CartNoteUpdate(
|
|
95
95
|
$cartId: ID!
|
|
96
96
|
$note: String!
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
${e}
|
|
109
|
-
`,
|
|
109
|
+
`,Pn=e=>`
|
|
110
110
|
mutation CartBuyerIdentityUpdate(
|
|
111
111
|
$cartId: ID!
|
|
112
112
|
$buyerIdentity: CartBuyerIdentityInput!
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
${e}
|
|
125
|
-
`,
|
|
125
|
+
`,On=e=>`
|
|
126
126
|
mutation CartAttributesUpdate(
|
|
127
127
|
$attributes: [AttributeInput!]!
|
|
128
128
|
$cartId: ID!
|
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
${e}
|
|
141
|
-
`,
|
|
141
|
+
`,Rn=e=>`
|
|
142
142
|
mutation CartDiscountCodesUpdate(
|
|
143
143
|
$cartId: ID!
|
|
144
144
|
$discountCodes: [String!]
|
|
@@ -154,7 +154,7 @@
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
${e}
|
|
157
|
-
`,
|
|
157
|
+
`,kn=e=>`
|
|
158
158
|
query CartQuery(
|
|
159
159
|
$id: ID!
|
|
160
160
|
$numCartLines: Int = 250
|
|
@@ -167,7 +167,7 @@
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
${e}
|
|
170
|
-
`,
|
|
170
|
+
`,Dn=`
|
|
171
171
|
fragment CartFragment on Cart {
|
|
172
172
|
id
|
|
173
173
|
checkoutUrl
|
|
@@ -268,16 +268,16 @@
|
|
|
268
268
|
width
|
|
269
269
|
height
|
|
270
270
|
}
|
|
271
|
-
`,
|
|
272
|
-
You may run into unexpected errors if these versions don't match. Received version: "${n}"; expected version "${ae}"`);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 Ue(o)?u:`${u}/${(s==null?void 0:s.storefrontApiVersion)??n}/graphql.json`},getPrivateTokenHeaders(s){if(!t&&!(s!=null&&s.privateStorefrontToken)&&!Ue(e))throw new Error(ke+"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)&&!Ue(e))throw new Error(ke+"You did not pass in a `publicStorefrontToken` while using `createStorefrontClient()` or `getPublicTokenHeaders()`");const o=(s==null?void 0:s.contentType)??a??"json";return ot(o,n,(s==null?void 0:s.publicStorefrontToken)??r??"")}}}function ot(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 st=new Set,ke="[h2:error:createStorefrontClient] ",Or=(e,t="warn")=>{st.has(e)||(console[t](`[h2:${t}:createStorefrontClient] `+e),st.add(e))},ct={storeDomain:"test",storefrontToken:"abc123",storefrontApiVersion:ae,countryIsoCode:"US",languageIsoCode:"EN",getStorefrontApiUrl(){return""},getPublicTokenHeaders(){return{}},getShopifyDomain(){return""}},ut=c.createContext(ct);function Rr({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!==ae&&console.warn(`<ShopifyProvider/>: This version of Hydrogen React is built for Shopify's Storefront API version ${ae}, 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 ot(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(ut.Provider,{value:r},e)}function ue(){const e=c.useContext(ut);if(!e)throw new Error("'useShop()' must be a descendent of <ShopifyProvider/>");return e}const Ne="shopifyCartId",lt="Shopify-Storefront-Id",dt="Shopify-Storefront-Y",ft="Shopify-Storefront-S",J="_shopify_y",X="_shopify_s";var Dr=new Set(["domain","path","max-age","expires","samesite","secure","httponly"]);function Vr(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{}Dr.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 Ur(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 ht="xxxx-4xxx-xxxx-xxxxxxxxxxxx";function Ce(){let e="";try{const t=window.crypto,r=new Uint16Array(31);t.getRandomValues(r);let n=0;e=ht.replace(/[x]/g,a=>{const i=r[n]%16,s=a==="x"?i:i&3|8;return n++,s.toString(16)}).toUpperCase()}catch{e=ht.replace(/[x]/g,r=>{const n=Math.random()*16|0;return(r==="x"?n:n&3|8).toString(16)}).toUpperCase()}return`${kr()}-${e}`}function kr(){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 Ae(e){const t=Vr(e);return{[J]:t[J]||"",[X]:t[X]||""}}function Nr(){const{storefrontId:e,getPublicTokenHeaders:t,getStorefrontApiUrl:r}=ue();return c.useCallback(({query:n,variables:a})=>{const i=t({contentType:"json"});e&&(i[lt]=e);const s=Ae(document.cookie);return i[dt]=s[J],i[ft]=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 Mr({numCartLines:e,cartFragment:t,countryCode:r="US",languageCode:n="EN"}){const a=Nr(),i=c.useCallback(h=>a({query:br(t),variables:{id:h,numCartLines:e,country:r,language:n}}),[a,t,e,r,n]),s=c.useCallback(h=>a({query:Er(t),variables:{input:h,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),o=c.useCallback((h,S)=>a({query:pr(t),variables:{cartId:h,lines:S,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),u=c.useCallback((h,S)=>a({query:_r(t),variables:{cartId:h,lines:S,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),l=c.useCallback((h,S)=>a({query:Sr(t),variables:{cartId:h,lines:S,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),y=c.useCallback((h,S)=>a({query:Tr(t),variables:{cartId:h,note:S,numCartLines:e,country:r,language:n}}),[a,t,e,r,n]),d=c.useCallback((h,S)=>a({query:Cr(t),variables:{cartId:h,buyerIdentity:S,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),g=c.useCallback((h,S)=>a({query:Ar(t),variables:{cartId:h,attributes:S,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),f=c.useCallback((h,S)=>a({query:wr(t),variables:{cartId:h,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:y,buyerIdentityUpdate:d,cartAttributesUpdate:g,discountCodesUpdate:f,cartFragment:t}),[i,s,o,u,l,y,d,g,f,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 le={CART_FETCH:{target:"cartFetching"},CART_CREATE:{target:"cartCreating"},CART_SET:{target:"idle",actions:[ne({rawCartResult:(e,t)=>t.payload.cart,cart:(e,t)=>Me(t.payload.cart)})]}},gt={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 Lr(e){return et({id:"Cart",initial:e?"idle":"uninitialized",context:{cart:e&&Me(e)},states:{uninitialized:{on:le},cartCompleted:{on:le},initializationError:{on:le},idle:{on:{...le,...gt}},error:{on:{...le,...gt}},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 xr({numCartLines:e,onCartActionEntry:t,onCartActionOptimisticUI:r,onCartActionComplete:n,data:a,cartFragment:i,countryCode:s,languageCode:o}){const{cartFetch:u,cartCreate:l,cartLineAdd:y,cartLineUpdate:d,cartLineRemove:g,noteUpdate:f,buyerIdentityUpdate:h,cartAttributesUpdate:S,discountCodesUpdate:T}=Mr({numCartLines:e,cartFragment:i,countryCode:s,languageCode:o}),b=c.useMemo(()=>Lr(a),[a]),[I,w,v]=gr(b,{actions:{cartFetchAction:async(p,m)=>{var A;if(m.type!=="CART_FETCH")return;const{data:E,errors:P}=await u((A=m==null?void 0:m.payload)==null?void 0:A.cartId),R=W(m,E==null?void 0:E.cart,P);w(R)},cartCreateAction:async(p,m)=>{var A;if(m.type!=="CART_CREATE")return;const{data:E,errors:P}=await l(m==null?void 0:m.payload),R=W(m,(A=E==null?void 0:E.cartCreate)==null?void 0:A.cart,P);w(R)},cartLineAddAction:async(p,m)=>{var A,O;if(m.type!=="CARTLINE_ADD"||!((A=p==null?void 0:p.cart)!=null&&A.id))return;const{data:E,errors:P}=await y(p.cart.id,m.payload.lines),R=W(m,(O=E==null?void 0:E.cartLinesAdd)==null?void 0:O.cart,P);w(R)},cartLineUpdateAction:async(p,m)=>{var A,O;if(m.type!=="CARTLINE_UPDATE"||!((A=p==null?void 0:p.cart)!=null&&A.id))return;const{data:E,errors:P}=await d(p.cart.id,m.payload.lines),R=W(m,(O=E==null?void 0:E.cartLinesUpdate)==null?void 0:O.cart,P);w(R)},cartLineRemoveAction:async(p,m)=>{var A,O;if(m.type!=="CARTLINE_REMOVE"||!((A=p==null?void 0:p.cart)!=null&&A.id))return;const{data:E,errors:P}=await g(p.cart.id,m.payload.lines),R=W(m,(O=E==null?void 0:E.cartLinesRemove)==null?void 0:O.cart,P);w(R)},noteUpdateAction:async(p,m)=>{var A,O;if(m.type!=="NOTE_UPDATE"||!((A=p==null?void 0:p.cart)!=null&&A.id))return;const{data:E,errors:P}=await f(p.cart.id,m.payload.note),R=W(m,(O=E==null?void 0:E.cartNoteUpdate)==null?void 0:O.cart,P);w(R)},buyerIdentityUpdateAction:async(p,m)=>{var A,O;if(m.type!=="BUYER_IDENTITY_UPDATE"||!((A=p==null?void 0:p.cart)!=null&&A.id))return;const{data:E,errors:P}=await h(p.cart.id,m.payload.buyerIdentity),R=W(m,(O=E==null?void 0:E.cartBuyerIdentityUpdate)==null?void 0:O.cart,P);w(R)},cartAttributesUpdateAction:async(p,m)=>{var A,O;if(m.type!=="CART_ATTRIBUTES_UPDATE"||!((A=p==null?void 0:p.cart)!=null&&A.id))return;const{data:E,errors:P}=await S(p.cart.id,m.payload.attributes),R=W(m,(O=E==null?void 0:E.cartAttributesUpdate)==null?void 0:O.cart,P);w(R)},discountCodesUpdateAction:async(p,m)=>{var A,O;if(m.type!=="DISCOUNT_CODES_UPDATE"||!((A=p==null?void 0:p.cart)!=null&&A.id))return;const{data:E,errors:P}=await T(p.cart.id,m.payload.discountCodes),R=W(m,(O=E==null?void 0:E.cartDiscountCodesUpdate)==null?void 0:O.cart,P);w(R)},...t&&{onCartActionEntry:(p,m)=>{Fr(m)&&t(p,m)}},...r&&{onCartActionOptimisticUI:ne((p,m)=>r(p,m))},...n&&{onCartActionComplete:(p,m)=>{jr(m)&&n(p,m)}}}});return c.useMemo(()=>[I,w,v],[I,w,v])}function Me(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:Me(t),rawCartResult:t,cartActionEvent:e}}:{type:"CART_COMPLETED",payload:{cartActionEvent:e}}}function Fr(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 jr(e){return e.type==="RESOLVE"||e.type==="ERROR"||e.type==="CART_COMPLETED"}const yt=c.createContext(null);function ie(){const e=c.useContext(yt);if(!e)throw new Error("Expected a Cart Context, but no Cart Context was found");return e}function qr({children:e,numCartLines:t,onCreate:r,onLineAdd:n,onLineRemove:a,onLineUpdate:i,onNoteUpdate:s,onBuyerIdentityUpdate:o,onAttributesUpdate:u,onDiscountCodesUpdate:l,onCreateComplete:y,onLineAddComplete:d,onLineRemoveComplete:g,onLineUpdateComplete:f,onNoteUpdateComplete:h,onBuyerIdentityUpdateComplete:S,onAttributesUpdateComplete:T,onDiscountCodesUpdateComplete:b,data:I,cartFragment:w=Ir,customerAccessToken:v,countryCode:p,languageCode:m}){var Kt,Qt,Jt,Xt,zt,er,tr;const E=ue();if(!E)throw new Error("<CartProvider> needs to be a descendant of <ShopifyProvider>");p=(p??E.countryIsoCode??"US").toUpperCase(),m=(m??E.languageIsoCode??"EN").toUpperCase(),p&&(p=p.toUpperCase());const[P,R]=c.useState(p),[A,O]=c.useState(v),H=c.useRef(!1);(P!==p||A!==v)&&(R(p),O(v),H.current=!1);const[D,$]=xr({numCartLines:t,data:I,cartFragment:w,countryCode:p,languageCode:m,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,_e;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:(_e=(M=C==null?void 0:C.cart)==null?void 0:M.lines)==null?void 0:_e.map(x=>{const Ge=N.payload.lines.find(({id:ca})=>ca===(x==null?void 0:x.id));return Ge&&Ge.quantity?{...x,quantity:Ge.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 y==null?void 0:y();case"CARTLINE_ADD":return d==null?void 0:d();case"CARTLINE_REMOVE":return g==null?void 0:g();case"CARTLINE_UPDATE":return f==null?void 0:f();case"NOTE_UPDATE":return h==null?void 0:h();case"BUYER_IDENTITY_UPDATE":return Br(C,L)&&(H.current=!0),S==null?void 0:S();case"CART_ATTRIBUTES_UPDATE":return T==null?void 0:T();case"DISCOUNT_CODES_UPDATE":return b==null?void 0:b()}}}catch(K){console.error("onCartActionComplete failed",K)}}}),ee=c.useRef(!1),[pe,U]=c.useState(!1),ce=D.matches("cartCompleted"),Ee=(D.value==="idle"||D.value==="error"||D.value==="cartCompleted")&&p!==((Jt=(Qt=(Kt=D==null?void 0:D.context)==null?void 0:Kt.cart)==null?void 0:Qt.buyerIdentity)==null?void 0:Jt.countryCode)&&!D.context.errors,Se=c.useRef(!1);c.useEffect(()=>{if(!ee.current&&!Se.current){if(!I&&Le("localStorage")){Se.current=!0;try{const C=window.localStorage.getItem(Ne);C&&$({type:"CART_FETCH",payload:{cartId:C}})}catch(C){console.warn("error fetching cartId"),console.warn(C)}}ee.current=!0,U(!0)}},[I,ee,$]),c.useEffect(()=>{!Ee||H.current||$({type:"BUYER_IDENTITY_UPDATE",payload:{buyerIdentity:{countryCode:p,customerAccessToken:v}}})},[p,v,Ee,H,$]);const B=c.useCallback(C=>{if(!ee.current)return console.warn("Cart isn't ready yet");$(C)},[$]);c.useEffect(()=>{var C,N,L;if((N=(C=D==null?void 0:D.context)==null?void 0:C.cart)!=null&&N.id&&Le("localStorage"))try{window.localStorage.setItem(Ne,(L=D.context.cart)==null?void 0:L.id)}catch(K){console.warn("Failed to save cartId to localStorage",K)}},[(zt=(Xt=D==null?void 0:D.context)==null?void 0:Xt.cart)==null?void 0:zt.id]),c.useEffect(()=>{if(ce&&Le("localStorage"))try{window.localStorage.removeItem(Ne)}catch(C){console.warn("Failed to delete cartId from localStorage",C)}},[ce]);const We=c.useCallback(C=>{var N,L;p&&!((N=C.buyerIdentity)!=null&&N.countryCode)&&(C.buyerIdentity==null&&(C.buyerIdentity={}),C.buyerIdentity.countryCode=p),v&&!((L=C.buyerIdentity)!=null&&L.customerAccessToken)&&(C.buyerIdentity==null&&(C.buyerIdentity={}),C.buyerIdentity.customerAccessToken=v),B({type:"CART_CREATE",payload:C})},[p,v,B]),V=$r(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:Hr(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:We,cartReady:pe,linesAdd(M){var _e,x;(x=(_e=V==null?void 0:V.context)==null?void 0:_e.cart)!=null&&x.id?B({type:"CARTLINE_ADD",payload:{lines:M}}):We({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:w}},[We,pe,(er=V==null?void 0:V.context)==null?void 0:er.cart,(tr=V==null?void 0:V.context)==null?void 0:tr.errors,V.value,w,B]);return React.createElement(yt.Provider,{value:sa},e)}function Hr(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 $r(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 Le(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 Br(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 mt=c.createContext(null);function Yr({children:e,data:t,initialVariantId:r}){const n=c.useMemo(()=>Q(t.variants??{}),[t.variants]);if(!Gr(n))throw new Error("<ProductProvider/> requires 'product.variants.nodes' or 'product.variants.edges'");const a=c.useMemo(()=>Wr(n),[n]),[i,s]=c.useState(()=>St(r,n)),[o,u]=c.useState(()=>_t(i));c.useEffect(()=>{const T=St(r,n);s(T),u(_t(T))},[r,n]);const l=c.useCallback((T,b)=>{u(I=>{const w={...I,[T]:b};return s(Et(n,w)),w})},[u,n]),y=c.useCallback((T,b)=>{const I=Et(n,{...o,[T]:b});return(I==null?void 0:I.availableForSale)??!0},[o,n]),d=c.useMemo(()=>Q(t.sellingPlanGroups??{}).map(T=>({...T,sellingPlans:Q((T==null?void 0:T.sellingPlans)??{})})),[t.sellingPlanGroups]),[g,f]=c.useState(void 0),h=c.useMemo(()=>{var T,b;if(!(!i||!g)){if(!((T=i.sellingPlanAllocations)!=null&&T.nodes)&&!((b=i.sellingPlanAllocations)!=null&&b.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(I=>{var w;return((w=I==null?void 0:I.sellingPlan)==null?void 0:w.id)===g.id})}},[i,g]),S=c.useMemo(()=>({product:t,variants:n,variantsConnection:t.variants,options:a,selectedVariant:i,setSelectedVariant:s,selectedOptions:o,setSelectedOption:l,setSelectedOptions:u,isOptionInStock:y,selectedSellingPlan:g,setSelectedSellingPlan:f,selectedSellingPlanAllocation:h,sellingPlanGroups:d,sellingPlanGroupsConnection:t.sellingPlanGroups}),[t,y,a,o,g,h,i,d,l,n]);return React.createElement(mt.Provider,{value:S},e)}function pt(){const e=c.useContext(mt);if(!e)throw new Error("'useProduct' must be a child of <ProductProvider />");return e}function Et(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 Wr(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 St(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 Gr(e){return!(!e||!Array.isArray(e))}function we(e){const{as:t,onClick:r,defaultOnClick:n,children:a,buttonRef:i,...s}=e,o=c.useCallback(l=>{if(r){const y=r(l);if(typeof y=="boolean"&&y===!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 Zr(e){const[t,r]=c.useState(!1),{variantId:n,quantity:a=1,attributes:i,sellingPlanId:s,onClick:o,children:u,accessibleAddingToCartLabel:l,...y}=e,{status:d,linesAdd:g}=ie(),{selectedVariant:f}=pt(),h=n??(f==null?void 0:f.id)??"",S=n===null||h===""||f===null||t||y.disabled;c.useEffect(()=>{t&&d==="idle"&&r(!1)},[d,t]);const T=c.useCallback(()=>{r(!0),g([{quantity:a,merchandiseId:h||"",attributes:i,sellingPlanId:s}])},[g,a,h,i,s]);return k.createElement(k.Fragment,null,k.createElement(we,{...y,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"},be={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"},Tt={hydrogen:"hydrogen",headless:"headless"},Ct={hydrogen:"6167201",headless:"12875497473"};function q(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 Kr(e){return typeof document>"u"?(console.error(`${e} should only be used within the useEffect callback or event handlers`),!0):!1}const Qr="trekkie_storefront_page_view/1.4",Jr="myshopify.dev";function At(e){const t=e,{id:r,resource:n}=F(t.resourceId),a=n?n.toLowerCase():void 0;return[q(Qr,j({pageType:t.pageType,customerId:parseInt(F(t.customerId).id||"0"),resourceType:a,resourceId:parseInt(r)},Xr(t)))]}function Xr(e){return{appClientId:e.shopifySalesChannel?Ct[e.shopifySalesChannel]:Ct.headless,isMerchantRequest:zr(e.url),hydrogenSubchannelId:e.storefrontId||e.hydrogenSubchannelId||"0",isPersistentCookie:e.hasUserConsent,uniqToken:e.uniqueToken,visitToken:e.visitToken,microSessionId:Ce(),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 zr(e){if(typeof e!="string")return!1;const t=new URL(e).hostname;return t.indexOf(Jr)!==-1||t==="localhost"}const en="2025.4.0",G="custom_storefront_customer_tracking/1.2",wt="page_rendered",bt="collection_page_rendered",It="product_page_rendered",tn="product_added_to_cart",vt="search_submitted";function de(e){return{canonical_url:e.canonicalUrl||e.url,customer_id:parseInt(F(e.customerId).id||"0")}}function rn(e){const t=e,r=de(t),n=t.pageType,a=[];switch(a.push(q(G,j({event_name:wt,...r},Z(t)))),n){case be.collection:a.push(q(G,j({event_name:bt,...r,collection_name:t.collectionHandle,collection_id:parseInt(F(t.collectionId).id)},Z(t))));break;case be.product:a.push(q(G,j({event_name:It,...r,products:xe(t.products),total_value:t.totalValue},Z(t))));break;case be.search:a.push(q(G,j({event_name:vt,...r,search_string:t.searchString},Z(t))));break}return a}function nn(e){const t=e,r=de(t);return[q(G,j({event_name:wt,...r},Z(t)))]}function an(e){const t=e,r=de(t);return[q(G,j({event_name:bt,...r,collection_name:t.collectionHandle,collection_id:parseInt(F(t.collectionId).id)},Z(t)))]}function on(e){const t=e,r=de(t);return[q(G,j({event_name:It,...r,products:xe(t.products),total_value:t.totalValue},Z(t)))]}function sn(e){const t=e,r=de(t);return[q(G,j({event_name:vt,...r,search_string:t.searchString},Z(t)))]}function cn(e){const t=e,r=F(t.cartId);return[q(G,j({event_name:tn,customerId:t.customerId,cart_token:r!=null&&r.id?`${r.id}`:null,total_value:t.totalValue,products:xe(t.products),customer_id:parseInt(F(t.customerId).id||"0")},Z(t)))]}function Z(e){return{source:e.shopifySalesChannel||Tt.headless,asset_version_id:e.assetVersionId||en,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:Ce(),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 xe(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 un(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(At(i),rn(i)):r===re.ADD_TO_CART?a=a.concat(cn(n)):r===re.PAGE_VIEW_2?a=a.concat(At(i),nn(i)):r===re.COLLECTION_VIEW?a=a.concat(an(i)):r===re.PRODUCT_VIEW?a=a.concat(on(i)):r===re.SEARCH_VIEW&&(a=a.concat(sn(i))),a.length?dn(a,t):Promise.resolve()}function ln(){return typeof window>"u"||!window.navigator?!1:/Chrome-Lighthouse/.test(window.navigator.userAgent)}const Pt="sendShopifyAnalytics request is unsuccessful";function dn(e,t){if(ln())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(Pt,`
|
|
271
|
+
`,re="2025-04",Vn="mock.shop",Ve=e=>e.includes(Vn);function Un({storeDomain:e,privateStorefrontToken:t,publicStorefrontToken:n,storefrontApiVersion:r=re,contentType:a}){if(!e)throw new Error(Ue+"`storeDomain` is required when creating a new Storefront client in production.");r!==re&&Nn(`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: "${r}"; expected version "${re}"`);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),c=o+(o.endsWith("/")?"api":"/api");return Ve(o)?c:`${c}/${(s==null?void 0:s.storefrontApiVersion)??r}/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":r,"Shopify-Storefront-Private-Token":(s==null?void 0:s.privateStorefrontToken)??t??"",...s!=null&&s.buyerIp?{"Shopify-Storefront-Buyer-IP":s.buyerIp}:{}}},getPublicTokenHeaders(s){if(!n&&!(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 ut(o,r,(s==null?void 0:s.publicStorefrontToken)??n??"")}}}function ut(e,t,n){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":n}}const lt=new Set,Ue="[h2:error:createStorefrontClient] ",Nn=(e,t="warn")=>{lt.has(e)||(console[t](`[h2:${t}:createStorefrontClient] `+e),lt.add(e))},dt={storeDomain:"test",storefrontToken:"abc123",storefrontApiVersion:re,countryIsoCode:"US",languageIsoCode:"EN",getStorefrontApiUrl(){return""},getPublicTokenHeaders(){return{}},getShopifyDomain(){return""}},ft=u.createContext(dt);function Mn(){var e,t,n;if(typeof window>"u")return!1;try{const r=(t=(e=window.performance)==null?void 0:e.getEntriesByType)==null?void 0:t.call(e,"navigation")[0];return!!((n=r==null?void 0:r.serverTiming)!=null&&n.some(a=>a.name==="_sfapi_proxy"))}catch{return!1}}function Fn({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!==re&&console.warn(`<ShopifyProvider/>: This version of Hydrogen React is built for Shopify's Storefront API version ${re}, 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 n=u.useMemo(()=>{const r=t.sameDomainForStorefrontApi??Mn();function a(i){const s=(i==null?void 0:i.storeDomain)??t.storeDomain;return s.includes("://")?s:`https://${s}`}return{...t,sameDomainForStorefrontApi:r,getPublicTokenHeaders(i){return ut(i.contentType,t.storefrontApiVersion,i.storefrontToken??t.storefrontToken)},getShopifyDomain:a,getStorefrontApiUrl(i){const s=r&&typeof window<"u"?window.location.origin:a({storeDomain:(i==null?void 0:i.storeDomain)??t.storeDomain});return`${s}${s.endsWith("/")?"":"/"}api/${(i==null?void 0:i.storefrontApiVersion)??t.storefrontApiVersion}/graphql.json`}}},[t]);return React.createElement(ft.Provider,{value:n},e)}function ce(){const e=u.useContext(ft);if(!e)throw new Error("'useShop()' must be a descendent of <ShopifyProvider/>");return e}const Ne="shopifyCartId",ht="Shopify-Storefront-Id",gt="Shopify-Storefront-Y",yt="Shopify-Storefront-S",Te="_shopify_y",Ce="_shopify_s",Me="X-Shopify-VisitToken",Fe="X-Shopify-UniqueToken",Le={current:null};function ee(){var t,n,r;let e;if(typeof window<"u"&&typeof window.performance<"u")try{const a=/^https?:\/\/([^/]+)(\/api\/(?:unstable|2\d{3}-\d{2})\/graphql\.json(?=$|\?))?/,i=performance.getEntriesByType("resource");let s;for(let o=i.length-1;o>=0;o--){const c=i[o];if(c.initiatorType!=="fetch")continue;const l=window.location.host,g=c.name.match(a);if(!g)continue;const[,d,y]=g;if(d===l||y&&(d==null?void 0:d.endsWith(`.${l}`))){const h=mt(c);if(h){s=h;break}}}if(s&&(e=s),e?Le.current=e:Le.current&&(e=Le.current),!e){const o=performance.getEntriesByType("navigation")[0];e=mt(o,!1)}}catch{}if(!e){const a=typeof arguments[0]=="string"?arguments[0]:typeof document<"u"?document.cookie:"";e={uniqueToken:((t=a.match(/\b_shopify_y=([^;]+)/))==null?void 0:t[1])||"",visitToken:((n=a.match(/\b_shopify_s=([^;]+)/))==null?void 0:n[1])||"",consent:((r=a.match(/\b_tracking_consent=([^;]+)/))==null?void 0:r[1])||""}}return e}function mt(e,t=!0){let n="",r="",a="";const i=e.serverTiming;if(i&&i.length>=3)for(let s=i.length-1;s>=0;s--){const{name:o,description:c}=i[s];if(!(!o||!c)&&(o==="_y"?n=c:o==="_s"?r=c:o==="_cmp"&&(a=c),n&&r&&a))break}return n&&r&&(!t||a)?{uniqueToken:n,visitToken:r,consent:a}:void 0}function Ln(){const{storefrontId:e,getPublicTokenHeaders:t,getStorefrontApiUrl:n,sameDomainForStorefrontApi:r}=ce();return u.useCallback(({query:a,variables:i})=>{const s=t({contentType:"json"});if(e&&(s[ht]=e),!r){const{uniqueToken:o,visitToken:c}=ee();o&&(s[gt]=o,s[Fe]=o),c&&(s[yt]=c,s[Me]=c)}return fetch(n(),{method:"POST",headers:s,body:JSON.stringify({query:a.toString(),variables:i})}).then(o=>o.json()).catch(o=>({data:void 0,errors:o==null?void 0:o.toString()}))},[t,e,n,r])}function xn({numCartLines:e,cartFragment:t,countryCode:n="US",languageCode:r="EN"}){const a=Ln(),i=u.useCallback(h=>a({query:kn(t),variables:{id:h,numCartLines:e,country:n,language:r}}),[a,t,e,n,r]),s=u.useCallback(h=>a({query:An(t),variables:{input:h,numCartLines:e,country:n,language:r}}),[t,n,a,e,r]),o=u.useCallback((h,_)=>a({query:wn(t),variables:{cartId:h,lines:_,numCartLines:e,country:n,language:r}}),[t,n,a,e,r]),c=u.useCallback((h,_)=>a({query:In(t),variables:{cartId:h,lines:_,numCartLines:e,country:n,language:r}}),[t,n,a,e,r]),l=u.useCallback((h,_)=>a({query:bn(t),variables:{cartId:h,lines:_,numCartLines:e,country:n,language:r}}),[t,n,a,e,r]),g=u.useCallback((h,_)=>a({query:vn(t),variables:{cartId:h,note:_,numCartLines:e,country:n,language:r}}),[a,t,e,n,r]),d=u.useCallback((h,_)=>a({query:Pn(t),variables:{cartId:h,buyerIdentity:_,numCartLines:e,country:n,language:r}}),[t,n,a,e,r]),y=u.useCallback((h,_)=>a({query:On(t),variables:{cartId:h,attributes:_,numCartLines:e,country:n,language:r}}),[t,n,a,e,r]),f=u.useCallback((h,_)=>a({query:Rn(t),variables:{cartId:h,discountCodes:_,numCartLines:e,country:n,language:r}}),[t,n,a,e,r]);return u.useMemo(()=>({cartFetch:i,cartCreate:s,cartLineAdd:o,cartLineUpdate:c,cartLineRemove:l,noteUpdate:g,buyerIdentityUpdate:d,cartAttributesUpdate:y,discountCodesUpdate:f,cartFragment:t}),[i,s,o,c,l,g,d,y,f,t])}function Y(e,t){return{entry:[...(t==null?void 0:t.entryActions)||[],ne({lastValidCart:n=>n==null?void 0:n.cart}),"onCartActionEntry","onCartActionOptimisticUI",e],on:{RESOLVE:{target:(t==null?void 0:t.resolveTarget)||"idle",actions:[ne({prevCart:n=>n==null?void 0:n.lastValidCart,cart:(n,r)=>{var a;return(a=r==null?void 0:r.payload)==null?void 0:a.cart},rawCartResult:(n,r)=>{var a;return(a=r==null?void 0:r.payload)==null?void 0:a.rawCartResult},errors:n=>{}})]},ERROR:{target:(t==null?void 0:t.errorTarget)||"error",actions:[ne({prevCart:n=>n==null?void 0:n.lastValidCart,cart:n=>n==null?void 0:n.lastValidCart,errors:(n,r)=>{var a;return(a=r==null?void 0:r.payload)==null?void 0:a.errors}})]},CART_COMPLETED:{target:"cartCompleted",actions:ne({prevCart:n=>{},cart:n=>{},lastValidCart:n=>{},rawCartResult:n=>{},errors:n=>{}})}},exit:["onCartActionComplete",...(t==null?void 0:t.exitActions)||[]]}}const ue={CART_FETCH:{target:"cartFetching"},CART_CREATE:{target:"cartCreating"},CART_SET:{target:"idle",actions:[ne({rawCartResult:(e,t)=>t.payload.cart,cart:(e,t)=>xe(t.payload.cart)})]}},pt={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 qn(e){return rt({id:"Cart",initial:e?"idle":"uninitialized",context:{cart:e&&xe(e)},states:{uninitialized:{on:ue},cartCompleted:{on:ue},initializationError:{on:ue},idle:{on:{...ue,...pt}},error:{on:{...ue,...pt}},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 jn({numCartLines:e,onCartActionEntry:t,onCartActionOptimisticUI:n,onCartActionComplete:r,data:a,cartFragment:i,countryCode:s,languageCode:o}){const{cartFetch:c,cartCreate:l,cartLineAdd:g,cartLineUpdate:d,cartLineRemove:y,noteUpdate:f,buyerIdentityUpdate:h,cartAttributesUpdate:_,discountCodesUpdate:T}=xn({numCartLines:e,cartFragment:i,countryCode:s,languageCode:o}),b=u.useMemo(()=>qn(a),[a]),[I,A,v]=Sn(b,{actions:{cartFetchAction:async(p,m)=>{var w;if(m.type!=="CART_FETCH")return;const{data:E,errors:P}=await c((w=m==null?void 0:m.payload)==null?void 0:w.cartId),R=W(m,E==null?void 0:E.cart,P);A(R)},cartCreateAction:async(p,m)=>{var w;if(m.type!=="CART_CREATE")return;const{data:E,errors:P}=await l(m==null?void 0:m.payload),R=W(m,(w=E==null?void 0:E.cartCreate)==null?void 0:w.cart,P);A(R)},cartLineAddAction:async(p,m)=>{var w,O;if(m.type!=="CARTLINE_ADD"||!((w=p==null?void 0:p.cart)!=null&&w.id))return;const{data:E,errors:P}=await g(p.cart.id,m.payload.lines),R=W(m,(O=E==null?void 0:E.cartLinesAdd)==null?void 0:O.cart,P);A(R)},cartLineUpdateAction:async(p,m)=>{var w,O;if(m.type!=="CARTLINE_UPDATE"||!((w=p==null?void 0:p.cart)!=null&&w.id))return;const{data:E,errors:P}=await d(p.cart.id,m.payload.lines),R=W(m,(O=E==null?void 0:E.cartLinesUpdate)==null?void 0:O.cart,P);A(R)},cartLineRemoveAction:async(p,m)=>{var w,O;if(m.type!=="CARTLINE_REMOVE"||!((w=p==null?void 0:p.cart)!=null&&w.id))return;const{data:E,errors:P}=await y(p.cart.id,m.payload.lines),R=W(m,(O=E==null?void 0:E.cartLinesRemove)==null?void 0:O.cart,P);A(R)},noteUpdateAction:async(p,m)=>{var w,O;if(m.type!=="NOTE_UPDATE"||!((w=p==null?void 0:p.cart)!=null&&w.id))return;const{data:E,errors:P}=await f(p.cart.id,m.payload.note),R=W(m,(O=E==null?void 0:E.cartNoteUpdate)==null?void 0:O.cart,P);A(R)},buyerIdentityUpdateAction:async(p,m)=>{var w,O;if(m.type!=="BUYER_IDENTITY_UPDATE"||!((w=p==null?void 0:p.cart)!=null&&w.id))return;const{data:E,errors:P}=await h(p.cart.id,m.payload.buyerIdentity),R=W(m,(O=E==null?void 0:E.cartBuyerIdentityUpdate)==null?void 0:O.cart,P);A(R)},cartAttributesUpdateAction:async(p,m)=>{var w,O;if(m.type!=="CART_ATTRIBUTES_UPDATE"||!((w=p==null?void 0:p.cart)!=null&&w.id))return;const{data:E,errors:P}=await _(p.cart.id,m.payload.attributes),R=W(m,(O=E==null?void 0:E.cartAttributesUpdate)==null?void 0:O.cart,P);A(R)},discountCodesUpdateAction:async(p,m)=>{var w,O;if(m.type!=="DISCOUNT_CODES_UPDATE"||!((w=p==null?void 0:p.cart)!=null&&w.id))return;const{data:E,errors:P}=await T(p.cart.id,m.payload.discountCodes),R=W(m,(O=E==null?void 0:E.cartDiscountCodesUpdate)==null?void 0:O.cart,P);A(R)},...t&&{onCartActionEntry:(p,m)=>{Hn(m)&&t(p,m)}},...n&&{onCartActionOptimisticUI:ne((p,m)=>n(p,m))},...r&&{onCartActionComplete:(p,m)=>{$n(m)&&r(p,m)}}}});return u.useMemo(()=>[I,A,v],[I,A,v])}function xe(e){return{...e,lines:Q(e==null?void 0:e.lines),note:e.note??void 0}}function W(e,t,n){return n?{type:"ERROR",payload:{errors:n,cartActionEvent:e}}:t?{type:"RESOLVE",payload:{cart:xe(t),rawCartResult:t,cartActionEvent:e}}:{type:"CART_COMPLETED",payload:{cartActionEvent:e}}}function Hn(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 $n(e){return e.type==="RESOLVE"||e.type==="ERROR"||e.type==="CART_COMPLETED"}const Et=u.createContext(null);function ae(){const e=u.useContext(Et);if(!e)throw new Error("Expected a Cart Context, but no Cart Context was found");return e}function Bn({children:e,numCartLines:t,onCreate:n,onLineAdd:r,onLineRemove:a,onLineUpdate:i,onNoteUpdate:s,onBuyerIdentityUpdate:o,onAttributesUpdate:c,onDiscountCodesUpdate:l,onCreateComplete:g,onLineAddComplete:d,onLineRemoveComplete:y,onLineUpdateComplete:f,onNoteUpdateComplete:h,onBuyerIdentityUpdateComplete:_,onAttributesUpdateComplete:T,onDiscountCodesUpdateComplete:b,data:I,cartFragment:A=Dn,customerAccessToken:v,countryCode:p,languageCode:m}){var en,tn,nn,rn,an,on,sn;const E=ce();if(!E)throw new Error("<CartProvider> needs to be a descendant of <ShopifyProvider>");p=(p??E.countryIsoCode??"US").toUpperCase(),m=(m??E.languageIsoCode??"EN").toUpperCase(),p&&(p=p.toUpperCase());const[P,R]=u.useState(p),[w,O]=u.useState(v),H=u.useRef(!1);(P!==p||w!==v)&&(R(p),O(v),H.current=!1);const[k,$]=jn({numCartLines:t,data:I,cartFragment:A,countryCode:p,languageCode:m,onCartActionEntry(C,N){try{switch(N.type){case"CART_CREATE":return n==null?void 0:n();case"CARTLINE_ADD":return r==null?void 0:r();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 c==null?void 0:c();case"DISCOUNT_CODES_UPDATE":return l==null?void 0:l()}}catch(F){console.error("Cart entry action failed",F)}},onCartActionOptimisticUI(C,N){var F,K,M,_e;if(!C.cart)return{...C};switch(N.type){case"CARTLINE_REMOVE":return{...C,cart:{...C.cart,lines:(K=(F=C==null?void 0:C.cart)==null?void 0:F.lines)==null?void 0:K.filter(L=>(L==null?void 0:L.id)&&!N.payload.lines.includes(L==null?void 0:L.id))}};case"CARTLINE_UPDATE":return{...C,cart:{...C.cart,lines:(_e=(M=C==null?void 0:C.cart)==null?void 0:M.lines)==null?void 0:_e.map(L=>{const Qe=N.payload.lines.find(({id:ga})=>ga===(L==null?void 0:L.id));return Qe&&Qe.quantity?{...L,quantity:Qe.quantity}:L})}}}return{...C}},onCartActionComplete(C,N){const F=N.payload.cartActionEvent;try{switch(N.type){case"RESOLVE":switch(F.type){case"CART_CREATE":return g==null?void 0:g();case"CARTLINE_ADD":return d==null?void 0:d();case"CARTLINE_REMOVE":return y==null?void 0:y();case"CARTLINE_UPDATE":return f==null?void 0:f();case"NOTE_UPDATE":return h==null?void 0:h();case"BUYER_IDENTITY_UPDATE":return Gn(C,F)&&(H.current=!0),_==null?void 0:_();case"CART_ATTRIBUTES_UPDATE":return T==null?void 0:T();case"DISCOUNT_CODES_UPDATE":return b==null?void 0:b()}}}catch(K){console.error("onCartActionComplete failed",K)}}}),X=u.useRef(!1),[me,V]=u.useState(!1),se=k.matches("cartCompleted"),pe=(k.value==="idle"||k.value==="error"||k.value==="cartCompleted")&&p!==((nn=(tn=(en=k==null?void 0:k.context)==null?void 0:en.cart)==null?void 0:tn.buyerIdentity)==null?void 0:nn.countryCode)&&!k.context.errors,Ee=u.useRef(!1);u.useEffect(()=>{if(!X.current&&!Ee.current){if(!I&&qe("localStorage")){Ee.current=!0;try{const C=window.localStorage.getItem(Ne);C&&$({type:"CART_FETCH",payload:{cartId:C}})}catch(C){console.warn("error fetching cartId"),console.warn(C)}}X.current=!0,V(!0)}},[I,X,$]),u.useEffect(()=>{!pe||H.current||$({type:"BUYER_IDENTITY_UPDATE",payload:{buyerIdentity:{countryCode:p,customerAccessToken:v}}})},[p,v,pe,H,$]);const B=u.useCallback(C=>{if(!X.current)return console.warn("Cart isn't ready yet");$(C)},[$]);u.useEffect(()=>{var C,N,F;if((N=(C=k==null?void 0:k.context)==null?void 0:C.cart)!=null&&N.id&&qe("localStorage"))try{window.localStorage.setItem(Ne,(F=k.context.cart)==null?void 0:F.id)}catch(K){console.warn("Failed to save cartId to localStorage",K)}},[(an=(rn=k==null?void 0:k.context)==null?void 0:rn.cart)==null?void 0:an.id]),u.useEffect(()=>{if(se&&qe("localStorage"))try{window.localStorage.removeItem(Ne)}catch(C){console.warn("Failed to delete cartId from localStorage",C)}},[se]);const Ke=u.useCallback(C=>{var N,F;p&&!((N=C.buyerIdentity)!=null&&N.countryCode)&&(C.buyerIdentity==null&&(C.buyerIdentity={}),C.buyerIdentity.countryCode=p),v&&!((F=C.buyerIdentity)!=null&&F.customerAccessToken)&&(C.buyerIdentity==null&&(C.buyerIdentity={}),C.buyerIdentity.customerAccessToken=v),B({type:"CART_CREATE",payload:C})},[p,v,B]),D=Wn(k),ha=u.useMemo(()=>{var C,N,F,K;return{...((C=D==null?void 0:D.context)==null?void 0:C.cart)??{lines:[],attributes:[]},status:Yn(D.value),error:(N=D==null?void 0:D.context)==null?void 0:N.errors,totalQuantity:((K=(F=D==null?void 0:D.context)==null?void 0:F.cart)==null?void 0:K.totalQuantity)??0,cartCreate:Ke,cartReady:me,linesAdd(M){var _e,L;(L=(_e=D==null?void 0:D.context)==null?void 0:_e.cart)!=null&&L.id?B({type:"CARTLINE_ADD",payload:{lines:M}}):Ke({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:A}},[Ke,me,(on=D==null?void 0:D.context)==null?void 0:on.cart,(sn=D==null?void 0:D.context)==null?void 0:sn.errors,D.value,A,B]);return React.createElement(Et.Provider,{value:ha},e)}function Yn(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 Wn(e){const[t,n]=u.useTransition(),[r,a]=u.useState(e),i=u.useRef(!1);t&&(i.current=!0);const s=u.useRef(!1);return!t&&i.current&&(s.current=!0),u.useEffect(()=>{n(()=>{s.current||a(e)})},[e]),s.current?e:r}function qe(e){let t;try{t=window[e];const n="__storage_test__";return t.setItem(n,n),t.removeItem(n),!0}catch(n){return!!(n instanceof DOMException&&(n.code===22||n.code===1014||n.name==="QuotaExceededError"||n.name==="NS_ERROR_DOM_QUOTA_REACHED")&&t&&t.length!==0)}}function Gn(e,t){var n,r;return!!(t.payload.buyerIdentity.countryCode&&((r=(n=e.cart)==null?void 0:n.buyerIdentity)==null?void 0:r.countryCode)!==t.payload.buyerIdentity.countryCode)}const _t=u.createContext(null);function Zn({children:e,data:t,initialVariantId:n}){const r=u.useMemo(()=>Q(t.variants??{}),[t.variants]);if(!Qn(r))throw new Error("<ProductProvider/> requires 'product.variants.nodes' or 'product.variants.edges'");const a=u.useMemo(()=>Kn(r),[r]),[i,s]=u.useState(()=>Ct(n,r)),[o,c]=u.useState(()=>wt(i));u.useEffect(()=>{const T=Ct(n,r);s(T),c(wt(T))},[n,r]);const l=u.useCallback((T,b)=>{c(I=>{const A={...I,[T]:b};return s(Tt(r,A)),A})},[c,r]),g=u.useCallback((T,b)=>{const I=Tt(r,{...o,[T]:b});return(I==null?void 0:I.availableForSale)??!0},[o,r]),d=u.useMemo(()=>Q(t.sellingPlanGroups??{}).map(T=>({...T,sellingPlans:Q((T==null?void 0:T.sellingPlans)??{})})),[t.sellingPlanGroups]),[y,f]=u.useState(void 0),h=u.useMemo(()=>{var T,b;if(!(!i||!y)){if(!((T=i.sellingPlanAllocations)!=null&&T.nodes)&&!((b=i.sellingPlanAllocations)!=null&&b.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(I=>{var A;return((A=I==null?void 0:I.sellingPlan)==null?void 0:A.id)===y.id})}},[i,y]),_=u.useMemo(()=>({product:t,variants:r,variantsConnection:t.variants,options:a,selectedVariant:i,setSelectedVariant:s,selectedOptions:o,setSelectedOption:l,setSelectedOptions:c,isOptionInStock:g,selectedSellingPlan:y,setSelectedSellingPlan:f,selectedSellingPlanAllocation:h,sellingPlanGroups:d,sellingPlanGroupsConnection:t.sellingPlanGroups}),[t,g,a,o,y,h,i,d,l,r]);return React.createElement(_t.Provider,{value:_},e)}function St(){const e=u.useContext(_t);if(!e)throw new Error("'useProduct' must be a child of <ProductProvider />");return e}function Tt(e,t){var n,r;if(!(!e.length||((r=(n=e==null?void 0:e[0])==null?void 0:n.selectedOptions)==null?void 0:r.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(c=>(c==null?void 0:c.name)===i&&(c==null?void 0:c.value)===s)}))}function Kn(e){const t=e.reduce((n,r)=>{var a;if(!r.selectedOptions)throw new Error("'getOptions' requires 'variant.selectedOptions'");return(a=r==null?void 0:r.selectedOptions)==null||a.forEach(i=>{n[(i==null?void 0:i.name)??""]=n[(i==null?void 0:i.name)??""]||new Set,n[(i==null?void 0:i.name)??""].add((i==null?void 0:i.value)??"")}),n},{});return Object.keys(t).map(n=>({name:n,values:Array.from(t[n])}))}function Ct(e,t){if(e){const n=t.find(r=>(r==null?void 0:r.id)===e);return n||console.warn("<ProductProvider/> received a 'initialVariantId' prop, but could not actually find a variant with that ID"),n}if(e===null)return null;if(e===void 0)return t.find(n=>n==null?void 0:n.availableForSale)||t[0]}function wt(e){return e!=null&&e.selectedOptions?e.selectedOptions.reduce((t,n)=>(t[(n==null?void 0:n.name)??""]=(n==null?void 0:n.value)??"",t),{}):{}}function Qn(e){return!(!e||!Array.isArray(e))}function we(e){const{as:t,onClick:n,defaultOnClick:r,children:a,buttonRef:i,...s}=e,o=u.useCallback(l=>{if(n){const g=n(l);if(typeof g=="boolean"&&g===!1||l!=null&&l.defaultPrevented)return}r==null||r(l)},[r,n]),c=t||"button";return React.createElement(c,{ref:i,onClick:o,...s},a)}function Jn(e){const[t,n]=u.useState(!1),{variantId:r,quantity:a=1,attributes:i,sellingPlanId:s,onClick:o,children:c,accessibleAddingToCartLabel:l,...g}=e,{status:d,linesAdd:y}=ae(),{selectedVariant:f}=St(),h=r??(f==null?void 0:f.id)??"",_=r===null||h===""||f===null||t||g.disabled;u.useEffect(()=>{t&&d==="idle"&&n(!1)},[d,t]);const T=u.useCallback(()=>{n(!0),y([{quantity:a,merchandiseId:h||"",attributes:i,sellingPlanId:s}])},[y,a,h,i,s]);return U.createElement(U.Fragment,null,U.createElement(we,{...g,disabled:_,onClick:o,defaultOnClick:T},c),l?U.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 te={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"},Ae={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"},At={hydrogen:"hydrogen",headless:"headless"},bt={hydrogen:"6167201",headless:"12875497473"};function j(e,t){return{schema_id:e,payload:t,metadata:{event_created_at_ms:Date.now()}}}function x(e){const t={id:"",resource:null,resourceId:null,search:"",searchParams:new URLSearchParams,hash:""};if(typeof e!="string")return t;try{const{search:n,searchParams:r,pathname:a,hash:i}=new URL(e),s=a.split("/"),o=s[s.length-1],c=s[s.length-2];return!o||!c?t:{id:`${o}${n}${i}`||"",resource:c??null,resourceId:o||null,search:n,searchParams:r,hash:i}}catch{return t}}function q(e,t){return typeof e!="object"?{}:(Object.entries(e).forEach(([n,r])=>{r&&(t[n]=r)}),t)}function Xn(e){return typeof document>"u"?(console.error(`${e} should only be used within the useEffect callback or event handlers`),!0):!1}const It="xxxx-4xxx-xxxx-xxxxxxxxxxxx";function be(){let e="";try{const t=window.crypto,n=new Uint16Array(31);t.getRandomValues(n);let r=0;e=It.replace(/[x]/g,a=>{const i=n[r]%16,s=a==="x"?i:i&3|8;return r++,s.toString(16)}).toUpperCase()}catch{e=It.replace(/[x]/g,n=>{const r=Math.random()*16|0;return(n==="x"?r:r&3|8).toString(16)}).toUpperCase()}return`${zn()}-${e}`}function zn(){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 er(e){const t=ee(e);return{[Te]:t.uniqueToken,[Ce]:t.visitToken}}const tr="trekkie_storefront_page_view/1.4",nr="myshopify.dev";function vt(e){const t=e,{id:n,resource:r}=x(t.resourceId),a=r?r.toLowerCase():void 0;return[j(tr,q({pageType:t.pageType,customerId:parseInt(x(t.customerId).id||"0"),resourceType:a,resourceId:parseInt(n)},rr(t)))]}function rr(e){return{appClientId:e.shopifySalesChannel?bt[e.shopifySalesChannel]:bt.headless,isMerchantRequest:ar(e.url),hydrogenSubchannelId:e.storefrontId||e.hydrogenSubchannelId||"0",isPersistentCookie:e.hasUserConsent,uniqToken:e.uniqueToken,visitToken:e.visitToken,microSessionId:be(),microSessionCount:1,url:e.url,path:e.path,search:e.search,referrer:e.referrer,title:e.title,shopId:parseInt(x(e.shopId).id),currency:e.currency,contentLanguage:e.acceptedLanguage||"en"}}function ar(e){if(typeof e!="string")return!1;const t=new URL(e).hostname;return t.indexOf(nr)!==-1||t==="localhost"}const ir="2025.5.1",G="custom_storefront_customer_tracking/1.2",Pt="page_rendered",Ot="collection_page_rendered",Rt="product_page_rendered",or="product_added_to_cart",kt="search_submitted";function le(e){return{canonical_url:e.canonicalUrl||e.url,customer_id:parseInt(x(e.customerId).id||"0")}}function sr(e){const t=e,n=le(t),r=t.pageType,a=[];switch(a.push(j(G,q({event_name:Pt,...n},Z(t)))),r){case Ae.collection:a.push(j(G,q({event_name:Ot,...n,collection_name:t.collectionHandle,collection_id:parseInt(x(t.collectionId).id)},Z(t))));break;case Ae.product:a.push(j(G,q({event_name:Rt,...n,products:je(t.products),total_value:t.totalValue},Z(t))));break;case Ae.search:a.push(j(G,q({event_name:kt,...n,search_string:t.searchString},Z(t))));break}return a}function cr(e){const t=e,n=le(t);return[j(G,q({event_name:Pt,...n},Z(t)))]}function ur(e){const t=e,n=le(t);return[j(G,q({event_name:Ot,...n,collection_name:t.collectionHandle,collection_id:parseInt(x(t.collectionId).id)},Z(t)))]}function lr(e){const t=e,n=le(t);return[j(G,q({event_name:Rt,...n,products:je(t.products),total_value:t.totalValue},Z(t)))]}function dr(e){const t=e,n=le(t);return[j(G,q({event_name:kt,...n,search_string:t.searchString},Z(t)))]}function fr(e){const t=e,n=x(t.cartId);return[j(G,q({event_name:or,customerId:t.customerId,cart_token:n!=null&&n.id?`${n.id}`:null,total_value:t.totalValue,products:je(t.products),customer_id:parseInt(x(t.customerId).id||"0")},Z(t)))]}function Z(e){return{source:e.shopifySalesChannel||At.headless,asset_version_id:e.assetVersionId||ir,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:be(),event_source_url:e.url,referrer:e.referrer,user_agent:e.userAgent,navigation_type:e.navigationType,navigation_api:e.navigationApi,shop_id:parseInt(x(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 je(e){return e?e.map(t=>{const n=q({variant_gid:t.variantGid,category:t.category,sku:t.sku,product_id:parseInt(x(t.productGid).id),variant_id:parseInt(x(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(n)}):[]}function hr(e,t){const{eventName:n,payload:r}=e;if(!r.hasUserConsent)return Promise.resolve();let a=[];const i=r;return n===te.PAGE_VIEW?a=a.concat(vt(i),sr(i)):n===te.ADD_TO_CART?a=a.concat(fr(r)):n===te.PAGE_VIEW_2?a=a.concat(vt(i),cr(i)):n===te.COLLECTION_VIEW?a=a.concat(ur(i)):n===te.PRODUCT_VIEW?a=a.concat(lr(i)):n===te.SEARCH_VIEW&&(a=a.concat(dr(i))),a.length?yr(a,t):Promise.resolve()}function gr(){return typeof window>"u"||!window.navigator?!1:/Chrome-Lighthouse/.test(window.navigator.userAgent)}const Dt="sendShopifyAnalytics request is unsuccessful";function yr(e,t){if(gr())return Promise.resolve();const n={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(n)}).then(r=>{if(!r.ok)throw new Error("Response failed");return r.text()}).then(r=>{r&&JSON.parse(r).result.forEach(i=>{i.status!==200&&console.error(Dt,`
|
|
273
273
|
|
|
274
|
-
`,i.message)})}).catch(n=>{console.error(Pt,n)})}catch{return Promise.resolve()}}function fn(){if(Kr("getClientBrowserParameters"))return{uniqueToken:"",visitToken:"",url:"",path:"",search:"",referrer:"",title:"",userAgent:"",navigationType:"",navigationApi:""};const[e,t]=yn(),r=Ae(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 hn(){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 gn(){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 yn(){try{let e="PerformanceNavigationTiming",t=hn();return t||(t=gn(),e="performance.navigation"),t?[t,e]:["unknown","unknown"]}catch{}return["error","error"]}function mn(e){const{cartCreate:t,checkoutUrl:r}=ie(),[n,a]=c.useState(!1),{quantity:i,variantId:s,sellingPlanId:o,onClick:u,attributes:l,children:y,...d}=e;c.useEffect(()=>{n&&r&&(window.location.href=r)},[n,r]);const g=c.useCallback(()=>{a(!0),t({lines:[{quantity:i??1,merchandiseId:s,attributes:l,sellingPlanId:o}]})},[t,i,s,l,o]);return React.createElement(we,{disabled:n??d.disabled,...d,onClick:u,defaultOnClick:g},y)}function pn(e){const[t,r]=c.useState(!1),{status:n,checkoutUrl:a}=ie(),{children:i,...s}=e;return c.useEffect(()=>{t&&a&&n==="idle"&&(window.location.href=a)},[t,n,a]),React.createElement(we,{...s,disabled:t||s.disabled,onClick:()=>r(!0)},i)}function Ot(e){const{countryIsoCode:t,languageIsoCode:r}=ue(),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:y}=c.useMemo(()=>{const f={style:"currency",currency:e.currencyCode};return{defaultFormatter:oe(n,f),nameFormatter:oe(n,{...f,currencyDisplay:"name"}),narrowSymbolFormatter:oe(n,{...f,currencyDisplay:"narrowSymbol"}),withoutTrailingZerosFormatter:oe(n,{...f,minimumFractionDigits:0,maximumFractionDigits:0}),withoutCurrencyFormatter:oe(n),withoutTrailingZerosOrCurrencyFormatter:oe(n,{minimumFractionDigits:0,maximumFractionDigits:0})}},[e.currencyCode,n]),d=f=>f.type==="currency",g=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?y().format(a):l().format(a),currencyName:()=>{var f;return((f=s().formatToParts(a).find(d))==null?void 0:f.value)??e.currencyCode},currencySymbol:()=>{var f;return((f=i().formatToParts(a).find(d))==null?void 0:f.value)??e.currencyCode},currencyNarrowSymbol:()=>{var f;return((f=o().formatToParts(a).find(d))==null?void 0:f.value)??""},amount:()=>i().formatToParts(a).filter(f=>["decimal","fraction","group","integer","literal"].includes(f.type)).map(f=>f.value).join("")}),[e,a,s,i,o,l,u,y]);return c.useMemo(()=>new Proxy(g,{get:(f,h)=>{var S;return(S=Reflect.get(f,h))==null?void 0:S.call(null)}}),[g])}const Rt=new Map;function oe(e,t){const r=JSON.stringify([e,t]);return function(){let n=Rt.get(r);return n||(n=new Intl.NumberFormat(e,t),Rt.set(r,n)),n}}function Ie({data:e,as:t,withoutCurrency:r,withoutTrailingZeros:n,measurement:a,measurementSeparator:i="/",...s}){if(!En(e))throw new Error("<Money/> needs a valid 'data' prop that has 'amount' and 'currencyCode'");const o=Ot(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 En(e){return typeof e.amount=="string"&&!!e.amount&&typeof e.currencyCode=="string"&&!!e.currencyCode}function Sn(e){const{cost:t}=ie(),{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(Ie,{...a,data:i},n)}const Dt=c.createContext(null);function Fe(){const e=c.useContext(Dt);if(e==null)throw new Error("Expected a cart line context but none was found");return e}function _n({children:e,line:t}){return React.createElement(Dt.Provider,{value:t},e)}function Tn(e){const t=Fe(),{as:r,...n}=e,a=r||"span";return React.createElement(a,{...n},t.quantity)}function Cn(e){const{status:t,linesRemove:r,linesUpdate:n}=ie(),a=Fe(),{children:i,adjust:s,onClick:o,...u}=e,l=c.useCallback(()=>{if(s==="remove"){r([(a==null?void 0:a.id)??""]);return}const d=s==="decrease"?((a==null?void 0:a.quantity)??0)-1:((a==null?void 0:a.quantity)??0)+1;if(d<=0){r([(a==null?void 0:a.id)??""]);return}const g={id:(a==null?void 0:a.id)??"",quantity:d,attributes:(a==null?void 0:a.attributes)??[]};n([g])},[s,a==null?void 0:a.attributes,a==null?void 0:a.id,a==null?void 0:a.quantity,r,n]),y=u.disabled;return React.createElement(we,{...u,onClick:o,defaultOnClick:l,disabled:typeof y<"u"?y:t!=="idle"},i)}const An={DateTime:"string",Decimal:"string",HTML:"string",URL:"string",Color:"string",UnsignedInt64:"string"},wn={DateTime:"string",Decimal:"string",HTML:"string",ISO8601DateTime:"string",URL:"string",UnsignedInt64:"string"},Vt=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 y=r.embedUrl;if(n){const d=new URL(r.embedUrl);for(const[g,f]of Object.entries(n))typeof f>"u"||d.searchParams.set(g,f.toString());y=d.toString()}return React.createElement("iframe",{...l,id:a??r.embedUrl,title:r.alt??r.id??"external video",frameBorder:i,allow:s,allowFullScreen:o,src:y,loading:u,ref:t})}),je=",",se={OPTION:":",END_OF_PREFIX:",",SEQUENCE_GAP:" ",RANGE:"-"},qe=(()=>{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 Ut(r)){a.add(i.join(je));for(let s=0;s<i.length;s++)a.add(i.slice(0,s+1).join(je))}e.set(r,a)}return!!((n=e.get(r))!=null&&n.has(t.join(je)))}})();function Ut(e){if(!e)return[];if(e.startsWith("v1_"))return In(bn(e));throw new Error("Unsupported option value encoding")}const bn=e=>e.replace(/^v1_/,"");function In(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],y=Number.parseInt(e.slice(r,n.index))||0;if(o!==null){for(;o<y;o++)i[s]=o,a.push([...i]);o=null}i[s]=y,l===se.RANGE?o=y:l===se.OPTION?s++:((l===se.SEQUENCE_GAP||l===se.END_OF_PREFIX&&e[n.index-1]!==se.END_OF_PREFIX)&&a.push([...i]),l===se.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 vn(e){return Object.assign({},...e.map(t=>({[t.name]:Object.assign({},...t!=null&&t.optionValues?t.optionValues.map((r,n)=>({[r.name]:n})):[])})))}function fe(e){return Object.assign({},...e.map(t=>({[t.name]:t.value})))}function He(e){return JSON.stringify(fe(e))}function kt(e){return Array.isArray(e)?JSON.stringify(Object.assign({},...e.map(t=>({[t.name]:t.value})))):JSON.stringify(e)}function Pn(e,t){return Object.keys(e).map(n=>t[n]?t[n][e[n]]:null).filter(n=>n!==null)}function On(e){return Object.assign({},...e.map(t=>({[kt(t.selectedOptions||[])]:t})))}const Nt=["options","selectedOrFirstAvailableVariant","adjacentVariants"],Rn=["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 Mt(e,t=!1){var a;let r=!0;const n=Object.keys(e);if((t?[...Nt,...Rn]:Nt).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=$e(s.firstSelectableVariant,"options.optionValues.firstSelectableVariant",r,t))}else r=z("options.optionValues")}return e.selectedOrFirstAvailableVariant&&(r=$e(e.selectedOrFirstAvailableVariant,"selectedOrFirstAvailableVariant",r,t)),e.adjacentVariants&&e.adjacentVariants[0]&&(r=$e(e.adjacentVariants[0],"adjacentVariants",r,t)),r?e:{}}function $e(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 Dn(e){const t=Mt(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=He(s.firstSelectableVariant.selectedOptions);r[o]=s.firstSelectableVariant}})}),t.adjacentVariants.map(a=>{const i=He(a.selectedOptions);r[i]=a});const n=t.selectedOrFirstAvailableVariant;if(n){const a=He(n.selectedOptions);r[a]=n}return Object.values(r)}function Vn(e){const t=Mt(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(h=>h.name),l=r.filter(h=>u&&u.indexOf(h.name)>=0),y=vn(r),d=On(n?[n,...a]:a),g=fe(n?n.selectedOptions:[]);return l.map((h,S)=>({...h,optionValues:h.optionValues.map(T=>{var O;const b={...g};b[h.name]=T.name;const I=kt(b||[]),v=Pn(b||[],y).slice(0,S+1),p=qe(v,i||""),m=qe(v,s||""),E=d[I]||T.firstSelectableVariant;let P={};E&&(P=fe(E.selectedOptions||[]));const R=new URLSearchParams(P),A=((O=E==null?void 0:E.product)==null?void 0:O.handle)||o;return{...T,variant:E,handle:A,variantUriQuery:R.toString(),selected:g[h.name]===T.name,exists:p,available:m,isDifferentProduct:A!==o}})}))}const Un=`#graphql
|
|
274
|
+
`,i.message)})}).catch(r=>{console.error(Dt,r)})}catch{return Promise.resolve()}}function mr(){if(Xn("getClientBrowserParameters"))return{uniqueToken:"",visitToken:"",url:"",path:"",search:"",referrer:"",title:"",userAgent:"",navigationType:"",navigationApi:""};const[e,t]=_r(),n=ee();return{uniqueToken:n.uniqueToken,visitToken:n.visitToken,url:location.href,path:location.pathname,search:location.search,referrer:document.referrer,title:document.title,userAgent:navigator.userAgent,navigationType:e,navigationApi:t}}function pr(){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 Er(){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 n=performance.navigation.type;switch(n){case PerformanceNavigation.TYPE_NAVIGATE:return"navigate";case PerformanceNavigation.TYPE_RELOAD:return"reload";case PerformanceNavigation.TYPE_BACK_FORWARD:return"back_forward";default:return`unknown: ${n}`}}}catch{}}function _r(){try{let e="PerformanceNavigationTiming",t=pr();return t||(t=Er(),e="performance.navigation"),t?[t,e]:["unknown","unknown"]}catch{}return["error","error"]}function Sr(e){const{cartCreate:t,checkoutUrl:n}=ae(),[r,a]=u.useState(!1),{quantity:i,variantId:s,sellingPlanId:o,onClick:c,attributes:l,children:g,...d}=e;u.useEffect(()=>{r&&n&&(window.location.href=n)},[r,n]);const y=u.useCallback(()=>{a(!0),t({lines:[{quantity:i??1,merchandiseId:s,attributes:l,sellingPlanId:o}]})},[t,i,s,l,o]);return React.createElement(we,{disabled:r??d.disabled,...d,onClick:c,defaultOnClick:y},g)}function Tr(e){const[t,n]=u.useState(!1),{status:r,checkoutUrl:a}=ae(),{children:i,...s}=e;return u.useEffect(()=>{t&&a&&r==="idle"&&(window.location.href=a)},[t,r,a]),React.createElement(we,{...s,disabled:t||s.disabled,onClick:()=>n(!0)},i)}function Vt(e){const{countryIsoCode:t,languageIsoCode:n}=ce(),r=n.includes("_")?n.replace("_","-"):`${n}-${t}`;if(!r)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:c,withoutCurrencyFormatter:l,withoutTrailingZerosOrCurrencyFormatter:g}=u.useMemo(()=>{const f={style:"currency",currency:e.currencyCode};return{defaultFormatter:ie(r,f),nameFormatter:ie(r,{...f,currencyDisplay:"name"}),narrowSymbolFormatter:ie(r,{...f,currencyDisplay:"narrowSymbol"}),withoutTrailingZerosFormatter:ie(r,{...f,minimumFractionDigits:0,maximumFractionDigits:0}),withoutCurrencyFormatter:ie(r),withoutTrailingZerosOrCurrencyFormatter:ie(r,{minimumFractionDigits:0,maximumFractionDigits:0})}},[e.currencyCode,r]),d=f=>f.type==="currency",y=u.useMemo(()=>({original:()=>e,currencyCode:()=>e.currencyCode,localizedString:()=>i().format(a),parts:()=>i().formatToParts(a),withoutTrailingZeros:()=>a%1===0?c().format(a):i().format(a),withoutTrailingZerosAndCurrency:()=>a%1===0?g().format(a):l().format(a),currencyName:()=>{var f;return((f=s().formatToParts(a).find(d))==null?void 0:f.value)??e.currencyCode},currencySymbol:()=>{var f;return((f=i().formatToParts(a).find(d))==null?void 0:f.value)??e.currencyCode},currencyNarrowSymbol:()=>{var f;return((f=o().formatToParts(a).find(d))==null?void 0:f.value)??""},amount:()=>i().formatToParts(a).filter(f=>["decimal","fraction","group","integer","literal"].includes(f.type)).map(f=>f.value).join("")}),[e,a,s,i,o,l,c,g]);return u.useMemo(()=>new Proxy(y,{get:(f,h)=>{var _;return(_=Reflect.get(f,h))==null?void 0:_.call(null)}}),[y])}const Ut=new Map;function ie(e,t){const n=JSON.stringify([e,t]);return function(){let r=Ut.get(n);return r||(r=new Intl.NumberFormat(e,t),Ut.set(n,r)),r}}function Ie({data:e,as:t,withoutCurrency:n,withoutTrailingZeros:r,measurement:a,measurementSeparator:i="/",...s}){if(!Cr(e))throw new Error("<Money/> needs a valid 'data' prop that has 'amount' and 'currencyCode'");const o=Vt(e),c=t??"div";let l=o.localizedString;return(n||r)&&(n&&!r?l=o.amount:!n&&r?l=o.withoutTrailingZeros:l=o.withoutTrailingZerosAndCurrency),React.createElement(c,{...s},l,a&&a.referenceUnit&&React.createElement(React.Fragment,null,i,a.referenceUnit))}function Cr(e){return typeof e.amount=="string"&&!!e.amount&&typeof e.currencyCode=="string"&&!!e.currencyCode}function wr(e){const{cost:t}=ae(),{amountType:n="total",children:r,...a}=e;let i;return n=="total"?i=t==null?void 0:t.totalAmount:n=="subtotal"?i=t==null?void 0:t.subtotalAmount:n=="tax"?i=t==null?void 0:t.totalTaxAmount:n=="duty"&&(i=t==null?void 0:t.totalDutyAmount),i==null?null:React.createElement(Ie,{...a,data:i},r)}const Nt=u.createContext(null);function He(){const e=u.useContext(Nt);if(e==null)throw new Error("Expected a cart line context but none was found");return e}function Ar({children:e,line:t}){return React.createElement(Nt.Provider,{value:t},e)}function br(e){const t=He(),{as:n,...r}=e,a=n||"span";return React.createElement(a,{...r},t.quantity)}function Ir(e){const{status:t,linesRemove:n,linesUpdate:r}=ae(),a=He(),{children:i,adjust:s,onClick:o,...c}=e,l=u.useCallback(()=>{if(s==="remove"){n([(a==null?void 0:a.id)??""]);return}const d=s==="decrease"?((a==null?void 0:a.quantity)??0)-1:((a==null?void 0:a.quantity)??0)+1;if(d<=0){n([(a==null?void 0:a.id)??""]);return}const y={id:(a==null?void 0:a.id)??"",quantity:d,attributes:(a==null?void 0:a.attributes)??[]};r([y])},[s,a==null?void 0:a.attributes,a==null?void 0:a.id,a==null?void 0:a.quantity,n,r]),g=c.disabled;return React.createElement(we,{...c,onClick:o,defaultOnClick:l,disabled:typeof g<"u"?g:t!=="idle"},i)}const vr={DateTime:"string",Decimal:"string",HTML:"string",URL:"string",Color:"string",UnsignedInt64:"string"},Pr={DateTime:"string",Decimal:"string",HTML:"string",ISO8601DateTime:"string",URL:"string",UnsignedInt64:"string"},Mt=u.forwardRef((e,t)=>{const{data:n,options:r,id:a=n.id,frameBorder:i="0",allow:s="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:o=!0,loading:c="lazy",...l}=e;if(!n.embedUrl)throw new Error("<ExternalVideo/> requires the 'embedUrl' property");let g=n.embedUrl;if(r){const d=new URL(n.embedUrl);for(const[y,f]of Object.entries(r))typeof f>"u"||d.searchParams.set(y,f.toString());g=d.toString()}return React.createElement("iframe",{...l,id:a??n.embedUrl,title:n.alt??n.id??"external video",frameBorder:i,allow:s,allowFullScreen:o,src:g,loading:c,ref:t})}),$e=",",oe={OPTION:":",END_OF_PREFIX:",",SEQUENCE_GAP:" ",RANGE:"-"},Be=(()=>{const e=new Map;return function(t,n){var r;if(t.length===0)return!1;if(!e.has(n)){const a=new Set;for(const i of Ft(n)){a.add(i.join($e));for(let s=0;s<i.length;s++)a.add(i.slice(0,s+1).join($e))}e.set(n,a)}return!!((r=e.get(n))!=null&&r.has(t.join($e)))}})();function Ft(e){if(!e)return[];if(e.startsWith("v1_"))return Rr(Or(e));throw new Error("Unsupported option value encoding")}const Or=e=>e.replace(/^v1_/,"");function Rr(e){const t=/[ :,-]/g;let n=0,r;const a=[],i=[];let s=0,o=null;for(;r=t.exec(e);){const l=r[0],g=Number.parseInt(e.slice(n,r.index))||0;if(o!==null){for(;o<g;o++)i[s]=o,a.push([...i]);o=null}i[s]=g,l===oe.RANGE?o=g:l===oe.OPTION?s++:((l===oe.SEQUENCE_GAP||l===oe.END_OF_PREFIX&&e[r.index-1]!==oe.END_OF_PREFIX)&&a.push([...i]),l===oe.END_OF_PREFIX&&(i.pop(),s--)),n=t.lastIndex}const c=e.match(/\d+$/g);if(c){const l=parseInt(c[0]);if(o!=null)for(;o<=l;o++)i[s]=o,a.push([...i]);else a.push([l])}return a}function kr(e){return Object.assign({},...e.map(t=>({[t.name]:Object.assign({},...t!=null&&t.optionValues?t.optionValues.map((n,r)=>({[n.name]:r})):[])})))}function de(e){return Object.assign({},...e.map(t=>({[t.name]:t.value})))}function Ye(e){return JSON.stringify(de(e))}function Lt(e){return Array.isArray(e)?JSON.stringify(Object.assign({},...e.map(t=>({[t.name]:t.value})))):JSON.stringify(e)}function Dr(e,t){return Object.keys(e).map(r=>t[r]?t[r][e[r]]:null).filter(r=>r!==null)}function Vr(e){return Object.assign({},...e.map(t=>({[Lt(t.selectedOptions||[])]:t})))}const xt=["options","selectedOrFirstAvailableVariant","adjacentVariants"],Ur=["handle","encodedVariantExistence","encodedVariantAvailability"];function J(e){return console.error(`[h2:error:getProductOptions] product.${e} is missing. Make sure you query for this field from the Storefront API.`),!1}function qt(e,t=!1){var a;let n=!0;const r=Object.keys(e);if((t?[...xt,...Ur]:xt).forEach(i=>{r.includes(i)||(n=J(i))}),e.options){const i=e==null?void 0:e.options[0];if(t&&!(i!=null&&i.name)&&(n=J("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)&&(n=J("options.optionValues.name")),s=e.options[0].optionValues.filter(o=>!!(o!=null&&o.firstSelectableVariant))[0],s!=null&&s.firstSelectableVariant&&(n=We(s.firstSelectableVariant,"options.optionValues.firstSelectableVariant",n,t))}else n=J("options.optionValues")}return e.selectedOrFirstAvailableVariant&&(n=We(e.selectedOrFirstAvailableVariant,"selectedOrFirstAvailableVariant",n,t)),e.adjacentVariants&&e.adjacentVariants[0]&&(n=We(e.adjacentVariants[0],"adjacentVariants",n,t)),n?e:{}}function We(e,t,n,r){var i;let a=n;if(r&&!((i=e.product)!=null&&i.handle)&&(a=J(`${t}.product.handle`)),e.selectedOptions){const s=e.selectedOptions[0];s!=null&&s.name||(a=J(`${t}.selectedOptions.name`)),s!=null&&s.value||(a=J(`${t}.selectedOptions.value`))}else a=J(`${t}.selectedOptions`);return a}function Nr(e){const t=qt(e);if(!t.options)return[];const n={};t.options.map(a=>{var i;(i=a.optionValues)==null||i.map(s=>{if(s.firstSelectableVariant){const o=Ye(s.firstSelectableVariant.selectedOptions);n[o]=s.firstSelectableVariant}})}),t.adjacentVariants.map(a=>{const i=Ye(a.selectedOptions);n[i]=a});const r=t.selectedOrFirstAvailableVariant;if(r){const a=Ye(r.selectedOptions);n[a]=r}return Object.values(n)}function Mr(e){const t=qt(e,!0);if(!t.options)return[];const{options:n,selectedOrFirstAvailableVariant:r,adjacentVariants:a,encodedVariantExistence:i,encodedVariantAvailability:s,handle:o}=t,c=r==null?void 0:r.selectedOptions.map(h=>h.name),l=n.filter(h=>c&&c.indexOf(h.name)>=0),g=kr(n),d=Vr(r?[r,...a]:a),y=de(r?r.selectedOptions:[]);return l.map((h,_)=>({...h,optionValues:h.optionValues.map(T=>{var O;const b={...y};b[h.name]=T.name;const I=Lt(b||[]),v=Dr(b||[],g).slice(0,_+1),p=Be(v,i||""),m=Be(v,s||""),E=d[I]||T.firstSelectableVariant;let P={};E&&(P=de(E.selectedOptions||[]));const R=new URLSearchParams(P),w=((O=E==null?void 0:E.product)==null?void 0:O.handle)||o;return{...T,variant:E,handle:w,variantUriQuery:R.toString(),selected:y[h.name]===T.name,exists:p,available:m,isDifferentProduct:w!==o}})}))}const Fr=`#graphql
|
|
275
275
|
fragment Image on Image {
|
|
276
276
|
altText
|
|
277
277
|
url
|
|
278
278
|
width
|
|
279
279
|
height
|
|
280
280
|
}
|
|
281
|
-
`,Lt=k.forwardRef(({alt:e,aspectRatio:t,crop:r="center",data:n,decoding:a="async",height:i="auto",loader:s=he,loading:o="lazy",sizes:u,src:l,srcSetOptions:y={intervals:15,startingWidth:200,incrementSize:200,placeholderWidth:100},width:d="100%",...g},f)=>{const h=k.useMemo(()=>{const m=n!=null&&n.width&&(n!=null&&n.height)?n==null?void 0:n.width:void 0,E=n!=null&&n.width&&(n!=null&&n.height)?n==null?void 0:n.height:void 0;return{width:m,height:E,unitsMatch:!!Ft(m,E)}},[n]),S=k.useMemo(()=>{const E=ge((d||"100%").toString()),P=`${E.number}${E.unit}`,R=i==null,A=R?null:ge(i.toString()),O=A?`${A.number}${A.unit}`:"",H=R?"auto":O,D=l||(n==null?void 0:n.url),$=n!=null&&n.altText&&!e?n==null?void 0:n.altText:e||"",ee=t||(h.unitsMatch?[ye(h.width),ye(h.height)].join("/"):void 0);return{width:P,height:H,src:D,alt:$,aspectRatio:ee}},[d,i,l,n,e,t,h,g==null?void 0:g.key]),{intervals:T,startingWidth:b,incrementSize:I,placeholderWidth:w}=y,v=k.useMemo(()=>Mn(d,T,b,I),[d,T,b,I]);return jt(S.width)?k.createElement(kn,{aspectRatio:t,crop:r,decoding:a,height:i,imageWidths:v,loader:s,loading:o,normalizedProps:S,passthroughProps:g,ref:f,width:d,data:n}):k.createElement(Nn,{aspectRatio:t,crop:r,decoding:a,imageWidths:v,loader:s,loading:o,normalizedProps:S,passthroughProps:g,placeholderWidth:w,ref:f,sizes:u,data:n})}),kn=k.forwardRef(({aspectRatio:e,crop:t,decoding:r,height:n,imageWidths:a,loader:i=he,loading:s,normalizedProps:o,passthroughProps:u,width:l,data:y},d)=>{const g=k.useMemo(()=>{const f=ye(l),h=ye(n),S=e||(Ft(o.width,o.height)?[f,h].join("/"):o.aspectRatio?o.aspectRatio:void 0),T=a===void 0?void 0:Ht(a,S,t,{width:(y==null?void 0:y.width)??void 0,height:(y==null?void 0:y.height)??void 0}),b=h||(S&&f?f*(Be(S)??1):void 0),I=qt(o.src,T,i),w=i({src:o.src,width:f,height:b,crop:o.height==="auto"?void 0:t});return{width:f,aspectRatio:S,height:b,srcSet:I,src:w}},[e,t,y,n,a,i,o,l]);return k.createElement("img",{ref:d,alt:o.alt,decoding:r,height:g.height,loading:s,src:g.src,srcSet:g.srcSet,width:g.width,style:{aspectRatio:g.aspectRatio,...u.style},...u})}),Nn=k.forwardRef(({crop:e,decoding:t,imageWidths:r,loader:n=he,loading:a,normalizedProps:i,passthroughProps:s,placeholderWidth:o,sizes:u,data:l},y)=>{const d=k.useMemo(()=>{const g=r===void 0?void 0:Ht(r,i.aspectRatio,e,{width:(l==null?void 0:l.width)??void 0,height:(l==null?void 0:l.height)??void 0}),f=i.aspectRatio&&o?o*(Be(i.aspectRatio)??1):void 0,h=qt(i.src,g,n),S=n({src:i.src,width:o,height:f,crop:e});return{placeholderHeight:f,srcSet:h,src:S}},[e,l,r,n,i,o]);return k.createElement("img",{ref:y,alt:i.alt,decoding:t,height:d.placeholderHeight,loading:a,sizes:u,src:d.src,srcSet:d.srcSet,width:o,...s,style:{width:i.width,aspectRatio:i.aspectRatio,...s.style}})}),xt="https://placeholder.shopify.com";function he({src:e,width:t,height:r,crop:n}){if(!e)return"";const a=new URL(e,xt);return t&&a.searchParams.append("width",Math.round(t).toString()),r&&a.searchParams.append("height",Math.round(r).toString()),n&&a.searchParams.append("crop",n),a.href.replace(xt,"")}function Ft(e="100%",t="auto"){return ge(e.toString()).unit===ge(t.toString()).unit}function ge(e){const t=e.replace(/[0-9.]/g,""),r=parseFloat(e.replace(t,""));return{unit:t===""?r===void 0?"auto":"px":t,number:r}}function ye(e){if(e===void 0)return;const{unit:t,number:r}=ge(e.toString());switch(t){case"em":return r*16;case"rem":return r*16;case"px":return r;case"":return r;default:return}}function jt(e){return typeof e=="number"||/\d(px|em|rem)$/.test(e)}function qt(e,t,r=he){return e?(t==null?void 0:t.length)===0||!t?e:t.map((n,a)=>`${r({src:e,width:n.width,height:n.height,crop:n.crop})} ${t.length===3?`${a+1}x`:`${n.width??0}w`}`).join(", "):""}function Mn(e="100%",t,r,n){const a=Array.from({length:t},(s,o)=>o*n+r),i=Array.from({length:3},(s,o)=>(o+1)*(ye(e)??0));return jt(e)?i:a}function Be(e){if(!e)return;const[t,r]=e.split("/");return 1/(Number(t)/Number(r))}function Ht(e,t,r="center",n){if(e)return e.map(a=>({width:a,height:t?a*(Be(t)??1):void 0,crop:r})).filter(({width:a,height:i})=>!(n!=null&&n.width&&a>n.width||n!=null&&n.height&&i&&i>n.height))}const $t={};function Ln(e,t){const r=$t[e];if(r)return r;const n=new Promise((a,i)=>{const s=document.createElement("script");t!=null&&t.module?s.type="module":s.type="text/javascript",s.src=e,s.onload=()=>{a(!0)},s.onerror=()=>{i(!1)},(t==null?void 0:t.in)==="head"?document.head.appendChild(s):document.body.appendChild(s);const o=t==null?void 0:t.attributes;o&&Object.keys(o).forEach(u=>{s.setAttribute(u,o[u])})});return $t[e]=n,n}function Ye(e,t){const[r,n]=c.useState("loading");return c.useEffect(()=>{Ln(e,t).then(()=>n("done")).catch(()=>n("error"))},[e]),r}const Bt=c.forwardRef((e,t)=>{var y;const{data:r,previewImageOptions:n,id:a=r.id,playsInline:i=!0,controls:s=!0,sourceProps:o={},...u}=e,l=he({src:((y=r.previewImage)==null?void 0:y.url)??"",...n});if(!r.sources)throw new Error("<Video/> requires a 'data.sources' array");return React.createElement("video",{...u,id:a,playsInline:i,controls:s,poster:l,ref:t},r.sources.map(d=>{if(!(d!=null&&d.url&&(d!=null&&d.mimeType)))throw new Error("<Video/> needs 'source.url' and 'source.mimeType'");return React.createElement("source",{...o,key:d.url,src:d.url,type:d.mimeType})}))});function Yt(e){var l,y,d;const[t,r]=c.useState(void 0),n=c.useCallback(g=>{r(g)},[]),{data:a,children:i,className:s,...o}=e,u=Ye("https://unpkg.com/@google/model-viewer@v1.12.1/dist/model-viewer.min.js",{module:!0});return c.useEffect(()=>{const g={error:o.onError,load:o.onLoad,preload:o.onPreload,"model-visibility":o.onModelVisibility,progress:o.onProgress,"ar-status":o.onArStatus,"ar-tracking":o.onArTracking,"quick-look-button-tapped":o.onQuickLookButtonTapped,"camera-change":o.onCameraChange,"environment-change":o.onEnvironmentChange,play:o.onPlay,pause:o.onPause,"scene-graph-ready":o.onSceneGraphReady};if(t)return Object.entries(g).forEach(([f,h])=>{h&&t.addEventListener(f,h)}),()=>{t!=null&&Object.entries(g).forEach(([f,h])=>{h&&t.removeEventListener(f,h)})}},[t,o.onArStatus,o.onArTracking,o.onCameraChange,o.onEnvironmentChange,o.onError,o.onLoad,o.onModelVisibility,o.onPause,o.onPlay,o.onPreload,o.onProgress,o.onQuickLookButtonTapped,o.onSceneGraphReady]),u!=="done"?null:(y=(l=a.sources)==null?void 0:l[0])!=null&&y.url?React.createElement("model-viewer",{ref:n,...o,class:s,id:o.id??a.id,src:a.sources[0].url,alt:a.alt??null,"camera-controls":o.cameraControls??!0,poster:(o.poster||((d=a.previewImage)==null?void 0:d.url))??null,autoplay:o.autoplay??!0,loading:o.loading,reveal:o.reveal,ar:o.ar,"ar-modes":o.arModes,"ar-scale":o.arScale,"ar-placement":o.arPlacement,"ios-src":o.iosSrc,"touch-action":o.touchAction,"disable-zoom":o.disableZoom,"orbit-sensitivity":o.orbitSensitivity,"auto-rotate":o.autoRotate,"auto-rotate-delay":o.autoRotateDelay,"rotation-per-second":o.rotationPerSecond,"interaction-policy":o.interactionPolicy,"interaction-prompt":o.interactionPrompt,"interaction-prompt-style":o.interactionPromptStyle,"interaction-prompt-threshold":o.interactionPromptThreshold,"camera-orbit":o.cameraOrbit,"camera-target":o.cameraTarget,"field-of-view":o.fieldOfView,"max-camera-orbit":o.maxCameraOrbit,"min-camera-orbit":o.minCameraOrbit,"max-field-of-view":o.maxFieldOfView,"min-field-of-view":o.minFieldOfView,bounds:o.bounds,"interpolation-decay":o.interpolationDecay??100,"skybox-image":o.skyboxImage,"environment-image":o.environmentImage,exposure:o.exposure,"shadow-intensity":o.shadowIntensity??0,"shadow-softness":o.shadowSoftness??0,"animation-name":o.animationName,"animation-crossfade-duration":o.animationCrossfadeDuration,"variant-name":o.variantName,orientation:o.orientation,scale:o.scale},i):(console.error("<ModelViewer/> requires 'data.sources' prop to be an array, with an object that has a property 'url' on it. Rendering 'null'"),null)}function xn({data:e,mediaOptions:t,...r}){switch(e.__typename){case"MediaImage":return e.image?React.createElement(Lt,{...r,...t==null?void 0:t.image,data:e.image}):(console.warn("<MediaFile/>: 'data.image' does not exist for __typename of 'MediaImage'; rendering 'null' by default."),null);case"Video":return React.createElement(Bt,{...r,...t==null?void 0:t.video,data:e});case"ExternalVideo":return React.createElement(Vt,{...r,...t==null?void 0:t.externalVideo,data:e});case"Model3d":return React.createElement(Yt,{...r,...t==null?void 0:t.modelViewer,data:e});default:return console.error("<MediaFile /> requires the '__typename' property to exist on the 'data' prop in order to render the matching sub-component for this type of media. Rendering 'null' by default"),null}}function Fn(e){if(!e.type)return console.error("parseMetafield(): The 'type' field is required in order to parse the Metafield. Returning 'parsedValue' of 'null'"),{...e,parsedValue:null};switch(e.type){case"boolean":return{...e,parsedValue:e.value==="true"};case"collection_reference":case"file_reference":case"page_reference":case"product_reference":case"variant_reference":return{...e,parsedValue:e.reference};case"color":case"multi_line_text_field":case"single_line_text_field":case"url":return{...e,parsedValue:e.value};case"dimension":case"money":case"json":case"rating":case"volume":case"weight":case"rich_text_field":case"list.color":case"list.dimension":case"list.number_integer":case"list.number_decimal":case"list.rating":case"list.single_line_text_field":case"list.url":case"list.volume":case"list.weight":{let t=null;try{t=Wt(e.value??"")}catch{console.error("parseMetafield(): attempted to JSON.parse the 'metafield.value' property, but failed. Returning 'null' for 'parsedValue'"),t=null}return{...e,parsedValue:t}}case"date":case"date_time":return{...e,parsedValue:new Date(e.value??"")};case"list.date":case"list.date_time":{const t=Wt((e==null?void 0:e.value)??"");return{...e,parsedValue:t.map(r=>new Date(r))}}case"number_decimal":case"number_integer":return{...e,parsedValue:Number(e.value)};case"list.collection_reference":case"list.file_reference":case"list.page_reference":case"list.product_reference":case"list.variant_reference":return{...e,parsedValue:Q(e.references??void 0)};default:{const t=`parseMetafield(): the 'metafield.type' you passed in is not supported. Your type: "${e.type}". If you believe this is an error, please open an issue on GitHub.`;return console.error(`${t} Returning 'parsedValue' of 'null'`),{...e,parsedValue:null}}}}function Wt(e){return String(e).includes("__proto__")?JSON.parse(e,(t,r)=>{if(t!=="__proto__")return r}):JSON.parse(e)}function jn(e){var y,d,g,f,h,S;const{priceType:t="regular",variantId:r,valueType:n="min",data:a,...i}=e;if(a==null)throw new Error("<ProductPrice/> requires a product as the 'data' prop");let s,o;const u=r?Q((a==null?void 0:a.variants)??{}).find(T=>(T==null?void 0:T.id)===r)??null:null,l=n==="max"?"maxVariantPrice":"minVariantPrice";if(t==="compareAt"){r&&u?s=u.compareAtPrice:s=(y=a==null?void 0:a.compareAtPriceRange)==null?void 0:y[l];let T;r&&u?T=parseFloat(((d=u.price)==null?void 0:d.amount)??"0"):T=parseFloat(((f=(g=a==null?void 0:a.priceRange)==null?void 0:g[l])==null?void 0:f.amount)??"0");const b=parseFloat((s==null?void 0:s.amount)??"0");if(T>=b)return null}else r&&u?(s=u.price,n==="unit"&&(s=u.unitPrice,o=u.unitPriceMeasurement)):n==="max"?s=(h=a.priceRange)==null?void 0:h.maxVariantPrice:s=(S=a.priceRange)==null?void 0:S.minVariantPrice;return s?o?React.createElement(Ie,{...i,data:s,measurement:o}):React.createElement(Ie,{...i,data:s}):null}const qn={root:Hn,heading:$n,paragraph:Bn,text:Yn,link:Wn,list:Gn,"list-item":Zn};function Hn({node:e}){return React.createElement("div",null,e.children)}function $n({node:e}){return c.createElement(`h${e.level??"1"}`,null,e.children)}function Bn({node:e}){return React.createElement("p",null,e.children)}function Yn({node:e}){return e.bold&&e.italic?React.createElement("em",null,React.createElement("strong",null,e.value)):e.bold?React.createElement("strong",null,e.value):e.italic?React.createElement("em",null,e.value):e.value}function Wn({node:e}){return React.createElement("a",{href:e.url,title:e.title,target:e.target},e.children)}function Gn({node:e}){const t=e.listType==="unordered"?"ul":"ol";return React.createElement(t,null,e.children)}function Zn({node:e}){return React.createElement("li",null,e.children)}function Kn({as:e,data:t,plain:r,components:n,...a}){try{const i=e??"div",s=c.useMemo(()=>JSON.parse(t),[t]);return React.createElement(i,{...a},r?me(s):Gt(n,s))}catch(i){throw new Error("[h2:error:RichText] Parsing error. Make sure to pass a JSON string of rich text metafield",{cause:i})}}function Gt(e={},t,r=0){let n;"children"in t&&(n=t.children.map((i,s)=>Gt(e,i,s)));const a=e[t.type==="list-item"?"listItem":t.type]??qn[t.type];switch(t.type){case"root":return c.createElement(a,{key:r,node:{type:"root",children:n}});case"heading":return c.createElement(a,{key:r,node:{type:"heading",level:t.level,children:n}});case"paragraph":return c.createElement(a,{key:r,node:{type:"paragraph",children:n}});case"text":{const i=(t.value??"").split(`
|
|
282
|
-
`).flatMap((s,o)=>{const
|
|
281
|
+
`,jt=U.forwardRef(({alt:e,aspectRatio:t,crop:n="center",data:r,decoding:a="async",height:i="auto",loader:s=fe,loading:o="lazy",sizes:c,src:l,srcSetOptions:g={intervals:15,startingWidth:200,incrementSize:200,placeholderWidth:100},width:d="100%",...y},f)=>{const h=U.useMemo(()=>{const m=r!=null&&r.width&&(r!=null&&r.height)?r==null?void 0:r.width:void 0,E=r!=null&&r.width&&(r!=null&&r.height)?r==null?void 0:r.height:void 0;return{width:m,height:E,unitsMatch:!!$t(m,E)}},[r]),_=U.useMemo(()=>{const E=he((d||"100%").toString()),P=`${E.number}${E.unit}`,R=i==null,w=R?null:he(i.toString()),O=w?`${w.number}${w.unit}`:"",H=R?"auto":O,k=l||(r==null?void 0:r.url),$=r!=null&&r.altText&&!e?r==null?void 0:r.altText:e||"",X=t||(h.unitsMatch?[ge(h.width),ge(h.height)].join("/"):void 0);return{width:P,height:H,src:k,alt:$,aspectRatio:X}},[d,i,l,r,e,t,h,y==null?void 0:y.key]),{intervals:T,startingWidth:b,incrementSize:I,placeholderWidth:A}=g,v=U.useMemo(()=>qr(d,T,b,I),[d,T,b,I]);return Bt(_.width)?U.createElement(Lr,{aspectRatio:t,crop:n,decoding:a,height:i,imageWidths:v,loader:s,loading:o,normalizedProps:_,passthroughProps:y,ref:f,width:d,data:r}):U.createElement(xr,{aspectRatio:t,crop:n,decoding:a,imageWidths:v,loader:s,loading:o,normalizedProps:_,passthroughProps:y,placeholderWidth:A,ref:f,sizes:c,data:r})}),Lr=U.forwardRef(({aspectRatio:e,crop:t,decoding:n,height:r,imageWidths:a,loader:i=fe,loading:s,normalizedProps:o,passthroughProps:c,width:l,data:g},d)=>{const y=U.useMemo(()=>{const f=ge(l),h=ge(r),_=e||($t(o.width,o.height)?[f,h].join("/"):o.aspectRatio?o.aspectRatio:void 0),T=a===void 0?void 0:Wt(a,_,t,{width:(g==null?void 0:g.width)??void 0,height:(g==null?void 0:g.height)??void 0}),b=h||(_&&f?f*(Ge(_)??1):void 0),I=Yt(o.src,T,i),A=i({src:o.src,width:f,height:b,crop:o.height==="auto"?void 0:t});return{width:f,aspectRatio:_,height:b,srcSet:I,src:A}},[e,t,g,r,a,i,o,l]);return U.createElement("img",{ref:d,alt:o.alt,decoding:n,height:y.height,loading:s,src:y.src,srcSet:y.srcSet,width:y.width,style:{aspectRatio:y.aspectRatio,...c.style},...c})}),xr=U.forwardRef(({crop:e,decoding:t,imageWidths:n,loader:r=fe,loading:a,normalizedProps:i,passthroughProps:s,placeholderWidth:o,sizes:c,data:l},g)=>{const d=U.useMemo(()=>{const y=n===void 0?void 0:Wt(n,i.aspectRatio,e,{width:(l==null?void 0:l.width)??void 0,height:(l==null?void 0:l.height)??void 0}),f=i.aspectRatio&&o?o*(Ge(i.aspectRatio)??1):void 0,h=Yt(i.src,y,r),_=r({src:i.src,width:o,height:f,crop:e});return{placeholderHeight:f,srcSet:h,src:_}},[e,l,n,r,i,o]);return U.createElement("img",{ref:g,alt:i.alt,decoding:t,height:d.placeholderHeight,loading:a,sizes:c,src:d.src,srcSet:d.srcSet,width:o,...s,style:{width:i.width,aspectRatio:i.aspectRatio,...s.style}})}),Ht="https://placeholder.shopify.com";function fe({src:e,width:t,height:n,crop:r}){if(!e)return"";const a=new URL(e,Ht);return t&&a.searchParams.append("width",Math.round(t).toString()),n&&a.searchParams.append("height",Math.round(n).toString()),r&&a.searchParams.append("crop",r),a.href.replace(Ht,"")}function $t(e="100%",t="auto"){return he(e.toString()).unit===he(t.toString()).unit}function he(e){const t=e.replace(/[0-9.]/g,""),n=parseFloat(e.replace(t,""));return{unit:t===""?n===void 0?"auto":"px":t,number:n}}function ge(e){if(e===void 0)return;const{unit:t,number:n}=he(e.toString());switch(t){case"em":return n*16;case"rem":return n*16;case"px":return n;case"":return n;default:return}}function Bt(e){return typeof e=="number"||/\d(px|em|rem)$/.test(e)}function Yt(e,t,n=fe){return e?(t==null?void 0:t.length)===0||!t?e:t.map((r,a)=>`${n({src:e,width:r.width,height:r.height,crop:r.crop})} ${t.length===3?`${a+1}x`:`${r.width??0}w`}`).join(", "):""}function qr(e="100%",t,n,r){const a=Array.from({length:t},(s,o)=>o*r+n),i=Array.from({length:3},(s,o)=>(o+1)*(ge(e)??0));return Bt(e)?i:a}function Ge(e){if(!e)return;const[t,n]=e.split("/");return 1/(Number(t)/Number(n))}function Wt(e,t,n="center",r){if(e)return e.map(a=>({width:a,height:t?a*(Ge(t)??1):void 0,crop:n})).filter(({width:a,height:i})=>!(r!=null&&r.width&&a>r.width||r!=null&&r.height&&i&&i>r.height))}const Gt={};function jr(e,t){const n=Gt[e];if(n)return n;const r=new Promise((a,i)=>{const s=document.createElement("script");t!=null&&t.module?s.type="module":s.type="text/javascript",s.src=e,s.onload=()=>{a(!0)},s.onerror=()=>{i(!1)},(t==null?void 0:t.in)==="head"?document.head.appendChild(s):document.body.appendChild(s);const o=t==null?void 0:t.attributes;o&&Object.keys(o).forEach(c=>{s.setAttribute(c,o[c])})});return Gt[e]=r,r}function Ze(e,t){const[n,r]=u.useState("loading");return u.useEffect(()=>{jr(e,t).then(()=>r("done")).catch(()=>r("error"))},[e]),n}const Zt=u.forwardRef((e,t)=>{var g;const{data:n,previewImageOptions:r,id:a=n.id,playsInline:i=!0,controls:s=!0,sourceProps:o={},...c}=e,l=fe({src:((g=n.previewImage)==null?void 0:g.url)??"",...r});if(!n.sources)throw new Error("<Video/> requires a 'data.sources' array");return React.createElement("video",{...c,id:a,playsInline:i,controls:s,poster:l,ref:t},n.sources.map(d=>{if(!(d!=null&&d.url&&(d!=null&&d.mimeType)))throw new Error("<Video/> needs 'source.url' and 'source.mimeType'");return React.createElement("source",{...o,key:d.url,src:d.url,type:d.mimeType})}))});function Kt(e){var l,g,d;const[t,n]=u.useState(void 0),r=u.useCallback(y=>{n(y)},[]),{data:a,children:i,className:s,...o}=e,c=Ze("https://unpkg.com/@google/model-viewer@v1.12.1/dist/model-viewer.min.js",{module:!0});return u.useEffect(()=>{const y={error:o.onError,load:o.onLoad,preload:o.onPreload,"model-visibility":o.onModelVisibility,progress:o.onProgress,"ar-status":o.onArStatus,"ar-tracking":o.onArTracking,"quick-look-button-tapped":o.onQuickLookButtonTapped,"camera-change":o.onCameraChange,"environment-change":o.onEnvironmentChange,play:o.onPlay,pause:o.onPause,"scene-graph-ready":o.onSceneGraphReady};if(t)return Object.entries(y).forEach(([f,h])=>{h&&t.addEventListener(f,h)}),()=>{t!=null&&Object.entries(y).forEach(([f,h])=>{h&&t.removeEventListener(f,h)})}},[t,o.onArStatus,o.onArTracking,o.onCameraChange,o.onEnvironmentChange,o.onError,o.onLoad,o.onModelVisibility,o.onPause,o.onPlay,o.onPreload,o.onProgress,o.onQuickLookButtonTapped,o.onSceneGraphReady]),c!=="done"?null:(g=(l=a.sources)==null?void 0:l[0])!=null&&g.url?React.createElement("model-viewer",{ref:r,...o,class:s,id:o.id??a.id,src:a.sources[0].url,alt:a.alt??null,"camera-controls":o.cameraControls??!0,poster:(o.poster||((d=a.previewImage)==null?void 0:d.url))??null,autoplay:o.autoplay??!0,loading:o.loading,reveal:o.reveal,ar:o.ar,"ar-modes":o.arModes,"ar-scale":o.arScale,"ar-placement":o.arPlacement,"ios-src":o.iosSrc,"touch-action":o.touchAction,"disable-zoom":o.disableZoom,"orbit-sensitivity":o.orbitSensitivity,"auto-rotate":o.autoRotate,"auto-rotate-delay":o.autoRotateDelay,"rotation-per-second":o.rotationPerSecond,"interaction-policy":o.interactionPolicy,"interaction-prompt":o.interactionPrompt,"interaction-prompt-style":o.interactionPromptStyle,"interaction-prompt-threshold":o.interactionPromptThreshold,"camera-orbit":o.cameraOrbit,"camera-target":o.cameraTarget,"field-of-view":o.fieldOfView,"max-camera-orbit":o.maxCameraOrbit,"min-camera-orbit":o.minCameraOrbit,"max-field-of-view":o.maxFieldOfView,"min-field-of-view":o.minFieldOfView,bounds:o.bounds,"interpolation-decay":o.interpolationDecay??100,"skybox-image":o.skyboxImage,"environment-image":o.environmentImage,exposure:o.exposure,"shadow-intensity":o.shadowIntensity??0,"shadow-softness":o.shadowSoftness??0,"animation-name":o.animationName,"animation-crossfade-duration":o.animationCrossfadeDuration,"variant-name":o.variantName,orientation:o.orientation,scale:o.scale},i):(console.error("<ModelViewer/> requires 'data.sources' prop to be an array, with an object that has a property 'url' on it. Rendering 'null'"),null)}function Hr({data:e,mediaOptions:t,...n}){switch(e.__typename){case"MediaImage":return e.image?React.createElement(jt,{...n,...t==null?void 0:t.image,data:e.image}):(console.warn("<MediaFile/>: 'data.image' does not exist for __typename of 'MediaImage'; rendering 'null' by default."),null);case"Video":return React.createElement(Zt,{...n,...t==null?void 0:t.video,data:e});case"ExternalVideo":return React.createElement(Mt,{...n,...t==null?void 0:t.externalVideo,data:e});case"Model3d":return React.createElement(Kt,{...n,...t==null?void 0:t.modelViewer,data:e});default:return console.error("<MediaFile /> requires the '__typename' property to exist on the 'data' prop in order to render the matching sub-component for this type of media. Rendering 'null' by default"),null}}function $r(e){if(!e.type)return console.error("parseMetafield(): The 'type' field is required in order to parse the Metafield. Returning 'parsedValue' of 'null'"),{...e,parsedValue:null};switch(e.type){case"boolean":return{...e,parsedValue:e.value==="true"};case"collection_reference":case"file_reference":case"page_reference":case"product_reference":case"variant_reference":return{...e,parsedValue:e.reference};case"color":case"multi_line_text_field":case"single_line_text_field":case"url":return{...e,parsedValue:e.value};case"dimension":case"money":case"json":case"rating":case"volume":case"weight":case"rich_text_field":case"list.color":case"list.dimension":case"list.number_integer":case"list.number_decimal":case"list.rating":case"list.single_line_text_field":case"list.url":case"list.volume":case"list.weight":{let t=null;try{t=Qt(e.value??"")}catch{console.error("parseMetafield(): attempted to JSON.parse the 'metafield.value' property, but failed. Returning 'null' for 'parsedValue'"),t=null}return{...e,parsedValue:t}}case"date":case"date_time":return{...e,parsedValue:new Date(e.value??"")};case"list.date":case"list.date_time":{const t=Qt((e==null?void 0:e.value)??"");return{...e,parsedValue:t.map(n=>new Date(n))}}case"number_decimal":case"number_integer":return{...e,parsedValue:Number(e.value)};case"list.collection_reference":case"list.file_reference":case"list.page_reference":case"list.product_reference":case"list.variant_reference":return{...e,parsedValue:Q(e.references??void 0)};default:{const t=`parseMetafield(): the 'metafield.type' you passed in is not supported. Your type: "${e.type}". If you believe this is an error, please open an issue on GitHub.`;return console.error(`${t} Returning 'parsedValue' of 'null'`),{...e,parsedValue:null}}}}function Qt(e){return String(e).includes("__proto__")?JSON.parse(e,(t,n)=>{if(t!=="__proto__")return n}):JSON.parse(e)}function Br(e){var g,d,y,f,h,_;const{priceType:t="regular",variantId:n,valueType:r="min",data:a,...i}=e;if(a==null)throw new Error("<ProductPrice/> requires a product as the 'data' prop");let s,o;const c=n?Q((a==null?void 0:a.variants)??{}).find(T=>(T==null?void 0:T.id)===n)??null:null,l=r==="max"?"maxVariantPrice":"minVariantPrice";if(t==="compareAt"){n&&c?s=c.compareAtPrice:s=(g=a==null?void 0:a.compareAtPriceRange)==null?void 0:g[l];let T;n&&c?T=parseFloat(((d=c.price)==null?void 0:d.amount)??"0"):T=parseFloat(((f=(y=a==null?void 0:a.priceRange)==null?void 0:y[l])==null?void 0:f.amount)??"0");const b=parseFloat((s==null?void 0:s.amount)??"0");if(T>=b)return null}else n&&c?(s=c.price,r==="unit"&&(s=c.unitPrice,o=c.unitPriceMeasurement)):r==="max"?s=(h=a.priceRange)==null?void 0:h.maxVariantPrice:s=(_=a.priceRange)==null?void 0:_.minVariantPrice;return s?o?React.createElement(Ie,{...i,data:s,measurement:o}):React.createElement(Ie,{...i,data:s}):null}const Yr={root:Wr,heading:Gr,paragraph:Zr,text:Kr,link:Qr,list:Jr,"list-item":Xr};function Wr({node:e}){return React.createElement("div",null,e.children)}function Gr({node:e}){return u.createElement(`h${e.level??"1"}`,null,e.children)}function Zr({node:e}){return React.createElement("p",null,e.children)}function Kr({node:e}){return e.bold&&e.italic?React.createElement("em",null,React.createElement("strong",null,e.value)):e.bold?React.createElement("strong",null,e.value):e.italic?React.createElement("em",null,e.value):e.value}function Qr({node:e}){return React.createElement("a",{href:e.url,title:e.title,target:e.target},e.children)}function Jr({node:e}){const t=e.listType==="unordered"?"ul":"ol";return React.createElement(t,null,e.children)}function Xr({node:e}){return React.createElement("li",null,e.children)}function zr({as:e,data:t,plain:n,components:r,...a}){try{const i=e??"div",s=u.useMemo(()=>JSON.parse(t),[t]);return React.createElement(i,{...a},n?ye(s):Jt(r,s))}catch(i){throw new Error("[h2:error:RichText] Parsing error. Make sure to pass a JSON string of rich text metafield",{cause:i})}}function Jt(e={},t,n=0){let r;"children"in t&&(r=t.children.map((i,s)=>Jt(e,i,s)));const a=e[t.type==="list-item"?"listItem":t.type]??Yr[t.type];switch(t.type){case"root":return u.createElement(a,{key:n,node:{type:"root",children:r}});case"heading":return u.createElement(a,{key:n,node:{type:"heading",level:t.level,children:r}});case"paragraph":return u.createElement(a,{key:n,node:{type:"paragraph",children:r}});case"text":{const i=(t.value??"").split(`
|
|
282
|
+
`).flatMap((s,o)=>{const c=`${n}-${s}-${o}`,l=u.createElement(a,{key:c,node:{type:"text",italic:t.italic,bold:t.bold,value:s}});return o===0?l:[u.createElement("br",{key:`${c}-br`}),l]});return i.length>1?u.createElement(u.Fragment,{key:n},i):i[0]}case"link":return u.createElement(a,{key:n,node:{type:"link",url:t.url,title:t.title,target:t.target,children:r}});case"list":return u.createElement(a,{key:n,node:{type:"list",listType:t.listType,children:r}});case"list-item":return u.createElement(a,{key:n,node:{type:"list-item",children:r}})}}function ye(e,t=[]){switch(e.type){case"root":e.children.forEach(n=>ye(n,t));break;case"heading":case"paragraph":e.children.forEach(n=>ye(n,t)),t.push(" ");break;case"text":t.push(e.value||"");break;case"link":e.children.forEach(n=>ye(n,t));break;case"list":e.children.forEach(n=>{n.children&&n.children.forEach(r=>ye(r,t)),t.push(" ")});break;default:throw new Error(`Unknown node encountered ${e.type}`)}return t.join("").trim()}const ea="https://cdn.shopify.com/shopifycloud/shop-js/v1.0/client.js";function ta(e){return e==="headless"||e==="hydrogen"}function na({channel:e,variantIds:t,className:n,variantIdsAndQuantities:r,width:a,storeDomain:i}){const s=ce(),o=i||(s==null?void 0:s.storeDomain),c=Ze(ea);let l=[],g;if(!o||o===dt.storeDomain)throw new Error(ra);if(t&&r)throw new Error(ia);if(!t&&!r)throw new Error(Xt);if(e)if(ta(e))g=e;else throw new Error(oa);if(t)l=t.reduce((y,f)=>{const h=x(f).id;return h&&y.push(h),y},[]);else if(r)l=r.reduce((y,f)=>{const h=x(f==null?void 0:f.id).id;return h&&y.push(`${h}:${(f==null?void 0:f.quantity)??1}`),y},[]);else throw new Error(Xt);if(l.length===0)throw new Error(aa);const d=a?{"--shop-pay-button-width":a}:void 0;return React.createElement("div",{className:n,style:d},c==="done"&&React.createElement("shop-pay-button",{...g?{channel:g}:{},"store-url":o,variants:l.join(",")}))}const ra='You must pass a "storeDomain" prop to the "ShopPayButton" component, or wrap it in a "ShopifyProvider" component.',aa='You must pass in "variantIds" in the form of ["gid://shopify/ProductVariant/1"]',Xt='You must pass in either "variantIds" or "variantIdsAndQuantities" to ShopPayButton',ia="You must provide either a variantIds or variantIdsAndQuantities prop, but not both in the ShopPayButton component",oa='Invalid channel attribution value. Must be either "headless" or "hydrogen"';function sa(e){return u.useEffect(()=>{const t=new URLSearchParams(de(e||[])),n=new URLSearchParams(window.location.search),r=new URLSearchParams({...Object.fromEntries(n),...Object.fromEntries(t)});r.size>0&&window.history.replaceState({},"",`${window.location.pathname}?${r.toString()}`)},[JSON.stringify(e)]),null}function ca(e,t,n={}){let r=e+"="+encodeURIComponent(t);return n.expires&&(r+="; Expires="+new Date(n.expires).toUTCString()),n.maxage!=null&&n.maxage>=0&&(r+="; Max-Age="+(n.maxage|0)),n.domain&&(r+="; Domain="+n.domain),n.path&&(r+="; Path="+n.path),n.samesite&&(r+="; SameSite="+n.samesite),(n.secure||n.samesite==="None")&&(r+="; Secure"),n.httponly&&(r+="; HttpOnly"),r}const ua=60*60*24*360*1,la=60*30;function da(e){const{hasUserConsent:t,domain:n="",checkoutDomain:r="",storefrontAccessToken:a,fetchTrackingValues:i,ignoreDeprecatedCookies:s=!1}=e||{},o=fa({storefrontAccessToken:a,fetchTrackingValues:i,checkoutDomain:r});return u.useEffect(()=>{if(s||!o)return;let c=n||window.location.host;if(r){const g=r.split(".").reverse(),d=c.split(".").reverse(),y=[];g.forEach((f,h)=>{f===d[h]&&y.push(f)}),c=y.reverse().join(".")}/^localhost/.test(c)&&(c="");const l=c?/^\./.test(c)?c:`.${c}`:"";if(t){const g=ee();if((g.uniqueToken||g.visitToken||"").startsWith("00000000-"))return;ve(Te,g.uniqueToken||be(),ua,l),ve(Ce,g.visitToken||be(),la,l)}else ve(Te,"",0,l),ve(Ce,"",0,l)},[o,t,n,r,s]),o}function ve(e,t,n,r){document.cookie=ca(e,t,{maxage:n,domain:r,samesite:"Lax",path:"/"})}async function zt(e,t=""){const{uniqueToken:n,visitToken:r}=ee(),a=await fetch(`${t.replace(/\/+$/,"")}/api/unstable/graphql.json`,{method:"POST",headers:{"Content-Type":"application/json",...e&&{"X-Shopify-Storefront-Access-Token":e},...r||n?{[Me]:r,[Fe]:n}:void 0},body:JSON.stringify({query:"query ensureCookies { consentManagement { cookies(visitorConsent:{}) { cookieDomain } } }"})});if(!a.ok)throw new Error(`Failed to fetch consent from browser: ${a.status} ${a.statusText}`);await a.json(),ee()}function fa({checkoutDomain:e,storefrontAccessToken:t,fetchTrackingValues:n=!1}){const[r,a]=u.useState(!n),i=u.useRef(!1);return u.useEffect(()=>{if(!n){a(!0);return}i.current||(i.current=!0,zt(t).catch(s=>e?zt(t,e):Promise.reject(s)).catch(s=>{console.warn("[h2:warn:useShopifyCookies] Failed to fetch tracking values from browser: "+(s instanceof Error?s.message:String(s)))}).finally(()=>{a(!0)}))},[e,n,t]),r}S.AddToCartButton=Jn,S.AnalyticsEventName=te,S.AnalyticsPageType=Ae,S.BuyNowButton=Sr,S.CartCheckoutButton=Tr,S.CartCost=wr,S.CartLineProvider=Ar,S.CartLineQuantity=br,S.CartLineQuantityAdjustButton=Ir,S.CartProvider=Bn,S.ExternalVideo=Mt,S.IMAGE_FRAGMENT=Fr,S.Image=jt,S.MediaFile=Hr,S.ModelViewer=Kt,S.Money=Ie,S.ProductPrice=Br,S.ProductProvider=Zn,S.RichText=zr,S.SHOPIFY_S=Ce,S.SHOPIFY_STOREFRONT_ID_HEADER=ht,S.SHOPIFY_STOREFRONT_S_HEADER=yt,S.SHOPIFY_STOREFRONT_Y_HEADER=gt,S.SHOPIFY_UNIQUE_TOKEN_HEADER=Fe,S.SHOPIFY_VISIT_TOKEN_HEADER=Me,S.SHOPIFY_Y=Te,S.ShopPayButton=na,S.ShopifyProvider=Fn,S.ShopifySalesChannel=At,S.Video=Zt,S.createStorefrontClient=Un,S.customerAccountApiCustomScalars=Pr,S.decodeEncodedVariant=Ft,S.flattenConnection=Q,S.getAdjacentAndFirstAvailableVariants=Nr,S.getClientBrowserParameters=mr,S.getProductOptions=Mr,S.getShopifyCookies=er,S.getTrackingValues=ee,S.isOptionValueCombinationInEncodedVariant=Be,S.mapSelectedProductOptionToObject=de,S.parseGid=x,S.parseMetafield=$r,S.sendShopifyAnalytics=hr,S.storefrontApiCustomScalars=vr,S.useCart=ae,S.useCartLine=He,S.useLoadScript=Ze,S.useMoney=Vt,S.useProduct=St,S.useSelectedOptionInUrlParam=sa,S.useShop=ce,S.useShopifyCookies=da,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
|
|
283
283
|
//# sourceMappingURL=hydrogen-react.prod.js.map
|