@shopify/hydrogen-react 2023.7.6 → 2023.10.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/CartProvider.mjs.map +1 -1
- package/dist/browser-dev/Image.mjs +0 -22
- package/dist/browser-dev/Image.mjs.map +1 -1
- package/dist/browser-dev/ModelViewer.mjs.map +1 -1
- package/dist/browser-dev/Money.mjs.map +1 -1
- package/dist/browser-dev/ShopPayButton.mjs +22 -1
- package/dist/browser-dev/ShopPayButton.mjs.map +1 -1
- package/dist/browser-dev/Video.mjs.map +1 -1
- package/dist/browser-dev/codegen.helpers.mjs.map +1 -1
- package/dist/browser-dev/storefront-api-constants.mjs +1 -1
- package/dist/browser-dev/storefront-api-constants.mjs.map +1 -1
- package/dist/browser-dev/storefront-client.mjs +2 -2
- package/dist/browser-dev/storefront-client.mjs.map +1 -1
- package/dist/browser-dev/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/browser-dev/useCartActions.mjs.map +1 -1
- package/dist/browser-prod/CartProvider.mjs.map +1 -1
- package/dist/browser-prod/Image.mjs +0 -2
- package/dist/browser-prod/Image.mjs.map +1 -1
- package/dist/browser-prod/ModelViewer.mjs.map +1 -1
- package/dist/browser-prod/Money.mjs.map +1 -1
- package/dist/browser-prod/ShopPayButton.mjs +22 -1
- package/dist/browser-prod/ShopPayButton.mjs.map +1 -1
- package/dist/browser-prod/Video.mjs.map +1 -1
- package/dist/browser-prod/codegen.helpers.mjs.map +1 -1
- package/dist/browser-prod/storefront-api-constants.mjs +1 -1
- package/dist/browser-prod/storefront-api-constants.mjs.map +1 -1
- package/dist/browser-prod/storefront-client.mjs +1 -1
- package/dist/browser-prod/storefront-client.mjs.map +1 -1
- package/dist/browser-prod/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/browser-prod/useCartActions.mjs.map +1 -1
- package/dist/node-dev/CartProvider.js.map +1 -1
- package/dist/node-dev/CartProvider.mjs.map +1 -1
- package/dist/node-dev/Image.js +0 -22
- package/dist/node-dev/Image.js.map +1 -1
- package/dist/node-dev/Image.mjs +0 -22
- package/dist/node-dev/Image.mjs.map +1 -1
- package/dist/node-dev/ModelViewer.js.map +1 -1
- package/dist/node-dev/ModelViewer.mjs.map +1 -1
- package/dist/node-dev/Money.js.map +1 -1
- package/dist/node-dev/Money.mjs.map +1 -1
- package/dist/node-dev/ShopPayButton.js +22 -1
- package/dist/node-dev/ShopPayButton.js.map +1 -1
- package/dist/node-dev/ShopPayButton.mjs +22 -1
- package/dist/node-dev/ShopPayButton.mjs.map +1 -1
- package/dist/node-dev/Video.js.map +1 -1
- package/dist/node-dev/Video.mjs.map +1 -1
- package/dist/node-dev/codegen.helpers.js.map +1 -1
- package/dist/node-dev/codegen.helpers.mjs.map +1 -1
- package/dist/node-dev/storefront-api-constants.js +1 -1
- package/dist/node-dev/storefront-api-constants.js.map +1 -1
- package/dist/node-dev/storefront-api-constants.mjs +1 -1
- package/dist/node-dev/storefront-api-constants.mjs.map +1 -1
- package/dist/node-dev/storefront-client.js +2 -2
- package/dist/node-dev/storefront-client.js.map +1 -1
- package/dist/node-dev/storefront-client.mjs +2 -2
- package/dist/node-dev/storefront-client.mjs.map +1 -1
- package/dist/node-dev/useCartAPIStateMachine.js.map +1 -1
- package/dist/node-dev/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/node-dev/useCartActions.js.map +1 -1
- package/dist/node-dev/useCartActions.mjs.map +1 -1
- package/dist/node-prod/CartProvider.js.map +1 -1
- package/dist/node-prod/CartProvider.mjs.map +1 -1
- package/dist/node-prod/Image.js +0 -2
- package/dist/node-prod/Image.js.map +1 -1
- package/dist/node-prod/Image.mjs +0 -2
- package/dist/node-prod/Image.mjs.map +1 -1
- package/dist/node-prod/ModelViewer.js.map +1 -1
- package/dist/node-prod/ModelViewer.mjs.map +1 -1
- package/dist/node-prod/Money.js.map +1 -1
- package/dist/node-prod/Money.mjs.map +1 -1
- package/dist/node-prod/ShopPayButton.js +22 -1
- package/dist/node-prod/ShopPayButton.js.map +1 -1
- package/dist/node-prod/ShopPayButton.mjs +22 -1
- package/dist/node-prod/ShopPayButton.mjs.map +1 -1
- package/dist/node-prod/Video.js.map +1 -1
- package/dist/node-prod/Video.mjs.map +1 -1
- package/dist/node-prod/codegen.helpers.js.map +1 -1
- package/dist/node-prod/codegen.helpers.mjs.map +1 -1
- package/dist/node-prod/storefront-api-constants.js +1 -1
- package/dist/node-prod/storefront-api-constants.js.map +1 -1
- package/dist/node-prod/storefront-api-constants.mjs +1 -1
- package/dist/node-prod/storefront-api-constants.mjs.map +1 -1
- package/dist/node-prod/storefront-client.js +1 -1
- package/dist/node-prod/storefront-client.js.map +1 -1
- package/dist/node-prod/storefront-client.mjs +1 -1
- package/dist/node-prod/storefront-client.mjs.map +1 -1
- package/dist/node-prod/useCartAPIStateMachine.js.map +1 -1
- package/dist/node-prod/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/node-prod/useCartActions.js.map +1 -1
- package/dist/node-prod/useCartActions.mjs.map +1 -1
- package/dist/types/CartProvider.d.ts +2 -2
- package/dist/types/Image.d.ts +1 -18
- package/dist/types/ModelViewer.d.ts +1 -1
- package/dist/types/Money.d.ts +1 -1
- package/dist/types/ShopPayButton.d.ts +8 -2
- package/dist/types/Video.d.ts +1 -1
- package/dist/types/codegen.helpers.d.ts +5 -1
- package/dist/types/storefront-api-constants.d.ts +1 -1
- package/dist/types/storefront-api-types.d.ts +1046 -979
- package/dist/types/useCartAPIStateMachine.d.ts +2 -2
- package/dist/types/useCartActions.d.ts +2 -2
- package/dist/umd/hydrogen-react.dev.js +24 -26
- 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 +8 -8
- package/storefront.schema.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(E,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],u):(E=typeof globalThis<"u"?globalThis:E||self,u(E.hydrogenreact={},E.React))})(this,function(E,u){"use strict";function Ut(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const N=Ut(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 Me(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),s=[];try{for(;(t===void 0||t-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}var J;(function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"})(J||(J={}));var Ve={type:"xstate.init"};function Ae(e){return e===void 0?[]:[].concat(e)}function K(e){return{type:"xstate.assign",assignment:e}}function Le(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 he(e){return function(t){return e===t}}function xe(e){return typeof e=="string"?{type:e}:e}function Fe(e,t){return{value:e,context:t,actions:[],changed:!1,matches:he(e)}}function $e(e,t,r){var n=t,o=!1;return[e.filter(function(i){if(i.type==="xstate.assign"){o=!0;var s=Object.assign({},n);return typeof i.assignment=="function"?s=i.assignment(n,r):Object.keys(i.assignment).forEach(function(a){s[a]=typeof i.assignment[a]=="function"?i.assignment[a](n,r):i.assignment[a]}),n=s,!1}return!0}),n,o]}function qe(e,t){t===void 0&&(t={});var r=Me($e(Ae(e.states[e.initial].entry).map(function(s){return Le(s,t.actions)}),e.context,Ve),2),n=r[0],o=r[1],i={config:e,_options:t,initialState:{value:e.initial,actions:n,context:o,matches:he(e.initial)},transition:function(s,a){var c,d,f=typeof s=="string"?{value:s,context:e.context}:s,g=f.value,h=f.context,p=xe(a),l=e.states[g];if(l.on){var T=Ae(l.on[p.type]);try{for(var _=function(O){var ae=typeof Symbol=="function"&&Symbol.iterator,F=ae&&O[ae],oe=0;if(F)return F.call(O);if(O&&typeof O.length=="number")return{next:function(){return O&&oe>=O.length&&(O=void 0),{value:O&&O[oe++],done:!O}}};throw new TypeError(ae?"Object is not iterable.":"Symbol.iterator is not defined.")}(T),P=_.next();!P.done;P=_.next()){var b=P.value;if(b===void 0)return Fe(g,h);var v=typeof b=="string"?{target:b}:b,D=v.target,y=v.actions,m=y===void 0?[]:y,S=v.cond,R=S===void 0?function(){return!0}:S,I=D===void 0,A=D??g,w=e.states[A];if(R(h,p)){var $=Me($e((I?Ae(m):[].concat(l.exit,m,w.entry).filter(function(O){return O})).map(function(O){return Le(O,i._options.actions)}),h,p),3),k=$[0],q=$[1],Q=$[2],ye=D??g;return{value:ye,context:q,actions:k,changed:D!==g||k.length>0||Q,matches:he(ye)}}}}catch(O){c={error:O}}finally{try{P&&!P.done&&(d=_.return)&&d.call(_)}finally{if(c)throw c.error}}}return Fe(g,h)}};return i}var He=function(e,t){return e.actions.forEach(function(r){var n=r.exec;return n&&n(e.context,t)})};function Ot(e){var t=e.initialState,r=J.NotStarted,n=new Set,o={_machine:e,send:function(i){r===J.Running&&(t=e.transition(t,i),He(t,xe(i)),n.forEach(function(s){return s(t)}))},subscribe:function(i){return n.add(i),i(t),{unsubscribe:function(){return n.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:he(s.value)}}else t=e.initialState;return r=J.Running,He(t,Ve),o},stop:function(){return r=J.Stopped,n.clear(),o},get state(){return t},get status(){return r}};return o}var Nt=u.useLayoutEffect,Be={exports:{}},Ye={},je={exports:{}},Ge={};/**
|
|
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 z=u;function Mt(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Vt=typeof Object.is=="function"?Object.is:Mt,Lt=z.useState,xt=z.useEffect,Ft=z.useLayoutEffect,$t=z.useDebugValue;function qt(e,t){var r=t(),n=Lt({inst:{value:r,getSnapshot:t}}),o=n[0].inst,i=n[1];return Ft(function(){o.value=r,o.getSnapshot=t,ve(o)&&i({inst:o})},[e,r,t]),xt(function(){return ve(o)&&i({inst:o}),e(function(){ve(o)&&i({inst:o})})},[e]),$t(r),r}function ve(e){var t=e.getSnapshot;e=e.value;try{var r=t();return!Vt(e,r)}catch{return!0}}function Ht(e,t){return t()}var Bt=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Ht:qt;Ge.useSyncExternalStore=z.useSyncExternalStore!==void 0?z.useSyncExternalStore:Bt,je.exports=Ge;var Yt=je.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 me=u,Yt
|
|
30
|
+
*/var me=u,jt=Yt;function Gt(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Zt=typeof Object.is=="function"?Object.is:Gt,Wt=jt.useSyncExternalStore,Qt=me.useRef,Jt=me.useEffect,Xt=me.useMemo,Kt=me.useDebugValue;Ye.useSyncExternalStoreWithSelector=function(e,t,r,n,o){var i=Qt(null);if(i.current===null){var s={hasValue:!1,value:null};i.current=s}else s=i.current;i=Xt(function(){function c(p){if(!d){if(d=!0,f=p,p=n(p),o!==void 0&&s.hasValue){var l=s.value;if(o(l,p))return g=l}return g=p}if(l=g,Zt(f,p))return l;var T=n(p);return o!==void 0&&o(l,T)?l:(f=p,g=T)}var d=!1,f,g,h=r===void 0?null:r;return[function(){return c(t())},h===null?void 0:function(){return c(h())}]},[t,r,n,o]);var a=Wt(e,i[0],i[1]);return Jt(function(){s.hasValue=!0,s.value=a},[a]),Kt(a),a},Be.exports=Ye;var zt=Be.exports;function er(e){var t=N.useRef();return t.current||(t.current={v:e()}),t.current.v}var tr=globalThis&&globalThis.__read||function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),o,i=[],s;try{for(;(t===void 0||t-- >0)&&!(o=n.next()).done;)i.push(o.value)}catch(a){s={error:a}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return i};function rr(e){return e}var nr=function(e){var t;return e.subscribe(function(r){t=r}).unsubscribe(),t};function ar(e,t){var r=u.useRef(),n=tr(er(function(){var a=[],c=Ot(qe(e.config,t||e._options)),d=c.send;return c.send=function(f){if(c.status===J.NotStarted){a.push(f);return}d(f),r.current=c.state},[c,a]}),2),o=n[0],i=n[1];Nt(function(){t&&(o._machine._options=t)});var s=ir(o);return u.useEffect(function(){return o.start(r.current),i.forEach(o.send),r.current=o.state,function(){o.stop()}},[]),s}var or=function(e,t){return t.changed===!1};function ir(e){var t=u.useCallback(function(){return nr(e)},[e]),r=u.useCallback(function(o){var i=e.subscribe(o).unsubscribe;return i},[e]),n=zt.useSyncExternalStoreWithSelector(r,t,t,rr,or);return[n,e.send,e]}function G(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 sr=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
|
+
`,cr=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
|
+
`,ur=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
|
+
`,lr=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
|
+
`,dr=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
|
+
`,fr=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
|
+
`,yr=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
|
+
`,gr=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
|
+
`,hr=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
|
+
`,mr=`
|
|
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
|
-
Received "${t}".`);
|
|
273
|
-
You may run into unexpected errors if these versions don't match. Received verion: "${a}"; expected version "${te}"`);const s=c=>c.includes("mock.shop"),o=c=>{const f=(c==null?void 0:c.storeDomain)??t;return f.includes("://")?f:`https://${f}`};return{getShopifyDomain:o,getStorefrontApiUrl(c){const f=o(c),l=f+(f.endsWith("/")?"api":"/api");return s(f)?l:`${l}/${(c==null?void 0:c.storefrontApiVersion)??a}/graphql.json`},getPrivateTokenHeaders(c){if(!r&&!(c!=null&&c.privateStorefrontToken)&&!s(t))throw new Error(be+"You did not pass in a `privateStorefrontToken` while using `createStorefrontClient()` or `getPrivateTokenHeaders()`");return{"content-type":((c==null?void 0:c.contentType)??i)==="graphql"?"application/graphql":"application/json","X-SDK-Variant":"hydrogen-react","X-SDK-Variant-Source":"react","X-SDK-Version":a,"Shopify-Storefront-Private-Token":(c==null?void 0:c.privateStorefrontToken)??r??"",...c!=null&&c.buyerIp?{"Shopify-Storefront-Buyer-IP":c.buyerIp}:{}}},getPublicTokenHeaders(c){if(!n&&!(c!=null&&c.publicStorefrontToken)&&!s(t))throw new Error(be+"You did not pass in a `publicStorefrontToken` while using `createStorefrontClient()` or `getPublicTokenHeaders()`");const f=(c==null?void 0:c.contentType)??i??"json";return Ge(f,a,(c==null?void 0:c.publicStorefrontToken)??n??"")}}}function Ge(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 Ze=new Set,be="[h2:error:createStorefrontClient] ",pr="[h2:warn:createStorefrontClient] ",Er=e=>{Ze.has(e)||(console.warn(pr+e),Ze.add(e))},We={storeDomain:"test",storefrontToken:"abc123",storefrontApiVersion:te,countryIsoCode:"US",languageIsoCode:"EN",getStorefrontApiUrl(){return""},getPublicTokenHeaders(){return{}},getShopifyDomain(){return""}},Qe=u.createContext(We);function Sr({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!==te&&console.warn(`<ShopifyProvider/>: This version of Hydrogen React is built for Shopify's Storefront API version ${te}, 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=u.useMemo(()=>{function n(a){return(a==null?void 0:a.storeDomain)??t.storeDomain}return{...t,getPublicTokenHeaders(a){return Ge(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(Qe.Provider,{value:r},e)}function se(){const e=u.useContext(Qe);if(!e)throw new Error("'useShop()' must be a descendent of <ShopifyProvider/>");return e}const we="shopifyCartId",Je="Shopify-Storefront-Id",Xe="Shopify-Storefront-Y",Ke="Shopify-Storefront-S",Z="_shopify_y",W="_shopify_s";var Tr=new Set(["domain","path","max-age","expires","samesite","secure","httponly"]);function Cr(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{}Tr.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 _r(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 ze="xxxx-4xxx-xxxx-xxxxxxxxxxxx";function pe(){let e="";try{const t=window.crypto,r=new Uint16Array(31);t.getRandomValues(r);let n=0;e=ze.replace(/[x]/g,a=>{const i=r[n]%16,s=a==="x"?i:i&3|8;return n++,s.toString(16)}).toUpperCase()}catch{e=ze.replace(/[x]/g,r=>{const n=Math.random()*16|0;return(r==="x"?n:n&3|8).toString(16)}).toUpperCase()}return`${Ar()}-${e}`}function Ar(){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 Ee(e){const t=Cr(e);return{[Z]:t[Z]||"",[W]:t[W]||""}}function vr(){const{storefrontId:e,getPublicTokenHeaders:t,getStorefrontApiUrl:r}=se();return u.useCallback(({query:n,variables:a})=>{const i=t({contentType:"json"});e&&(i[Je]=e);const s=Ee(document.cookie);return i[Xe]=s[Z],i[Ke]=s[W],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 br({numCartLines:e,cartFragment:t,countryCode:r="US",languageCode:n="EN"}){const a=vr(),i=u.useCallback(d=>a({query:gr(t),variables:{id:d,numCartLines:e,country:r,language:n}}),[a,t,e,r,n]),s=u.useCallback(d=>a({query:sr(t),variables:{input:d,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),o=u.useCallback((d,C)=>a({query:ir(t),variables:{cartId:d,lines:C,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),c=u.useCallback((d,C)=>a({query:ur(t),variables:{cartId:d,lines:C,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),f=u.useCallback((d,C)=>a({query:cr(t),variables:{cartId:d,lines:C,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),l=u.useCallback((d,C)=>a({query:lr(t),variables:{cartId:d,note:C,numCartLines:e,country:r,language:n}}),[a,t,e,r,n]),y=u.useCallback((d,C)=>a({query:dr(t),variables:{cartId:d,buyerIdentity:C,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),h=u.useCallback((d,C)=>a({query:fr(t),variables:{cartId:d,attributes:C,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]),S=u.useCallback((d,C)=>a({query:yr(t),variables:{cartId:d,discountCodes:C,numCartLines:e,country:r,language:n}}),[t,r,a,e,n]);return u.useMemo(()=>({cartFetch:i,cartCreate:s,cartLineAdd:o,cartLineUpdate:c,cartLineRemove:f,noteUpdate:l,buyerIdentityUpdate:y,cartAttributesUpdate:h,discountCodesUpdate:S,cartFragment:t}),[i,s,o,c,f,l,y,h,S,t])}function H(e,t){return{entry:[...(t==null?void 0:t.entryActions)||[],z({lastValidCart:r=>r==null?void 0:r.cart}),"onCartActionEntry","onCartActionOptimisticUI",e],on:{RESOLVE:{target:(t==null?void 0:t.resolveTarget)||"idle",actions:[z({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:[z({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:z({prevCart:r=>{},cart:r=>{},lastValidCart:r=>{},rawCartResult:r=>{},errors:r=>{}})}},exit:["onCartActionComplete",...(t==null?void 0:t.exitActions)||[]]}}const ce={CART_FETCH:{target:"cartFetching"},CART_CREATE:{target:"cartCreating"},CART_SET:{target:"idle",actions:[z({rawCartResult:(e,t)=>t.payload.cart,cart:(e,t)=>Ie(t.payload.cart)})]}},et={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 wr(e){return $e({id:"Cart",initial:e?"idle":"uninitialized",context:{cart:e&&Ie(e)},states:{uninitialized:{on:ce},cartCompleted:{on:ce},initializationError:{on:ce},idle:{on:{...ce,...et}},error:{on:{...ce,...et}},cartFetching:H("cartFetchAction",{errorTarget:"initializationError"}),cartCreating:H("cartCreateAction",{errorTarget:"initializationError"}),cartLineRemoving:H("cartLineRemoveAction"),cartLineUpdating:H("cartLineUpdateAction"),cartLineAdding:H("cartLineAddAction"),noteUpdating:H("noteUpdateAction"),buyerIdentityUpdating:H("buyerIdentityUpdateAction"),cartAttributesUpdating:H("cartAttributesUpdateAction"),discountCodesUpdating:H("discountCodesUpdateAction")}})}function Ir({numCartLines:e,onCartActionEntry:t,onCartActionOptimisticUI:r,onCartActionComplete:n,data:a,cartFragment:i,countryCode:s,languageCode:o}){const{cartFetch:c,cartCreate:f,cartLineAdd:l,cartLineUpdate:y,cartLineRemove:h,noteUpdate:S,buyerIdentityUpdate:d,cartAttributesUpdate:C,discountCodesUpdate:_}=br({numCartLines:e,cartFragment:i,countryCode:s,languageCode:o}),R=u.useMemo(()=>wr(a),[a]),[I,v,D]=nr(R,{actions:{cartFetchAction:async(g,m)=>{var A;if(m.type!=="CART_FETCH")return;const{data:E,errors:P}=await c((A=m==null?void 0:m.payload)==null?void 0:A.cartId),b=B(m,E==null?void 0:E.cart,P);v(b)},cartCreateAction:async(g,m)=>{var A;if(m.type!=="CART_CREATE")return;const{data:E,errors:P}=await f(m==null?void 0:m.payload),b=B(m,(A=E==null?void 0:E.cartCreate)==null?void 0:A.cart,P);v(b)},cartLineAddAction:async(g,m)=>{var A,w;if(m.type!=="CARTLINE_ADD"||!((A=g==null?void 0:g.cart)!=null&&A.id))return;const{data:E,errors:P}=await l(g.cart.id,m.payload.lines),b=B(m,(w=E==null?void 0:E.cartLinesAdd)==null?void 0:w.cart,P);v(b)},cartLineUpdateAction:async(g,m)=>{var A,w;if(m.type!=="CARTLINE_UPDATE"||!((A=g==null?void 0:g.cart)!=null&&A.id))return;const{data:E,errors:P}=await y(g.cart.id,m.payload.lines),b=B(m,(w=E==null?void 0:E.cartLinesUpdate)==null?void 0:w.cart,P);v(b)},cartLineRemoveAction:async(g,m)=>{var A,w;if(m.type!=="CARTLINE_REMOVE"||!((A=g==null?void 0:g.cart)!=null&&A.id))return;const{data:E,errors:P}=await h(g.cart.id,m.payload.lines),b=B(m,(w=E==null?void 0:E.cartLinesRemove)==null?void 0:w.cart,P);v(b)},noteUpdateAction:async(g,m)=>{var A,w;if(m.type!=="NOTE_UPDATE"||!((A=g==null?void 0:g.cart)!=null&&A.id))return;const{data:E,errors:P}=await S(g.cart.id,m.payload.note),b=B(m,(w=E==null?void 0:E.cartNoteUpdate)==null?void 0:w.cart,P);v(b)},buyerIdentityUpdateAction:async(g,m)=>{var A,w;if(m.type!=="BUYER_IDENTITY_UPDATE"||!((A=g==null?void 0:g.cart)!=null&&A.id))return;const{data:E,errors:P}=await d(g.cart.id,m.payload.buyerIdentity),b=B(m,(w=E==null?void 0:E.cartBuyerIdentityUpdate)==null?void 0:w.cart,P);v(b)},cartAttributesUpdateAction:async(g,m)=>{var A,w;if(m.type!=="CART_ATTRIBUTES_UPDATE"||!((A=g==null?void 0:g.cart)!=null&&A.id))return;const{data:E,errors:P}=await C(g.cart.id,m.payload.attributes),b=B(m,(w=E==null?void 0:E.cartAttributesUpdate)==null?void 0:w.cart,P);v(b)},discountCodesUpdateAction:async(g,m)=>{var A,w;if(m.type!=="DISCOUNT_CODES_UPDATE"||!((A=g==null?void 0:g.cart)!=null&&A.id))return;const{data:E,errors:P}=await _(g.cart.id,m.payload.discountCodes),b=B(m,(w=E==null?void 0:E.cartDiscountCodesUpdate)==null?void 0:w.cart,P);v(b)},...t&&{onCartActionEntry:(g,m)=>{Pr(m)&&t(g,m)}},...r&&{onCartActionOptimisticUI:z((g,m)=>r(g,m))},...n&&{onCartActionComplete:(g,m)=>{Rr(m)&&n(g,m)}}}});return u.useMemo(()=>[I,v,D],[I,v,D])}function Ie(e){return{...e,lines:G(e==null?void 0:e.lines),note:e.note??void 0}}function B(e,t,r){return r?{type:"ERROR",payload:{errors:r,cartActionEvent:e}}:t?{type:"RESOLVE",payload:{cart:Ie(t),rawCartResult:t,cartActionEvent:e}}:{type:"CART_COMPLETED",payload:{cartActionEvent:e}}}function Pr(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 Rr(e){return e.type==="RESOLVE"||e.type==="ERROR"||e.type==="CART_COMPLETED"}const tt=u.createContext(null);function re(){const e=u.useContext(tt);if(!e)throw new Error("Expected a Cart Context, but no Cart Context was found");return e}function Dr({children:e,numCartLines:t,onCreate:r,onLineAdd:n,onLineRemove:a,onLineUpdate:i,onNoteUpdate:s,onBuyerIdentityUpdate:o,onAttributesUpdate:c,onDiscountCodesUpdate:f,onCreateComplete:l,onLineAddComplete:y,onLineRemoveComplete:h,onLineUpdateComplete:S,onNoteUpdateComplete:d,onBuyerIdentityUpdateComplete:C,onAttributesUpdateComplete:_,onDiscountCodesUpdateComplete:R,data:I,cartFragment:v=hr,customerAccessToken:D,countryCode:g,languageCode:m}){var vt,bt,wt,It,Pt,Rt,Dt;const E=se();if(!E)throw new Error("<CartProvider> needs to be a descendant of <ShopifyProvider>");g=(g??E.countryIsoCode??"US").toUpperCase(),m=(m??E.languageIsoCode??"EN").toUpperCase(),g&&(g=g.toUpperCase());const[P,b]=u.useState(g),[A,w]=u.useState(D),$=u.useRef(!1);(P!==g||A!==D)&&(b(g),w(D),$.current=!1);const[k,q]=Ir({numCartLines:t,data:I,cartFragment:v,countryCode:g,languageCode:m,onCartActionEntry(T,M){try{switch(M.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 c==null?void 0:c();case"DISCOUNT_CODES_UPDATE":return f==null?void 0:f()}}catch(L){console.error("Cart entry action failed",L)}},onCartActionOptimisticUI(T,M){var L,j,V,ge;if(!T.cart)return{...T};switch(M.type){case"CARTLINE_REMOVE":return{...T,cart:{...T.cart,lines:(j=(L=T==null?void 0:T.cart)==null?void 0:L.lines)==null?void 0:j.filter(x=>(x==null?void 0:x.id)&&!M.payload.lines.includes(x==null?void 0:x.id))}};case"CARTLINE_UPDATE":return{...T,cart:{...T.cart,lines:(ge=(V=T==null?void 0:T.cart)==null?void 0:V.lines)==null?void 0:ge.map(x=>{const Oe=M.payload.lines.find(({id:Rn})=>Rn===(x==null?void 0:x.id));return Oe&&Oe.quantity?{...x,quantity:Oe.quantity}:x})}}}return{...T}},onCartActionComplete(T,M){const L=M.payload.cartActionEvent;try{switch(M.type){case"RESOLVE":switch(L.type){case"CART_CREATE":return l==null?void 0:l();case"CARTLINE_ADD":return y==null?void 0:y();case"CARTLINE_REMOVE":return h==null?void 0:h();case"CARTLINE_UPDATE":return S==null?void 0:S();case"NOTE_UPDATE":return d==null?void 0:d();case"BUYER_IDENTITY_UPDATE":return Or(T,L)&&($.current=!0),C==null?void 0:C();case"CART_ATTRIBUTES_UPDATE":return _==null?void 0:_();case"DISCOUNT_CODES_UPDATE":return R==null?void 0:R()}}}catch(j){console.error("onCartActionComplete failed",j)}}}),Q=u.useRef(!1),K=k.matches("cartCompleted"),U=(k.value==="idle"||k.value==="error"||k.value==="cartCompleted")&&g!==((wt=(bt=(vt=k==null?void 0:k.context)==null?void 0:vt.cart)==null?void 0:bt.buyerIdentity)==null?void 0:wt.countryCode)&&!k.context.errors,oe=u.useRef(!1);u.useEffect(()=>{if(!Q.current&&!oe.current){if(!I&&Pe("localStorage")){oe.current=!0;try{const T=window.localStorage.getItem(we);T&&q({type:"CART_FETCH",payload:{cartId:T}})}catch(T){console.warn("error fetching cartId"),console.warn(T)}}Q.current=!0}},[I,Q,q]),u.useEffect(()=>{!U||$.current||q({type:"BUYER_IDENTITY_UPDATE",payload:{buyerIdentity:{countryCode:g,customerAccessToken:D}}})},[g,D,U,$,q]);const F=u.useCallback(T=>{if(!Q.current)return console.warn("Cart isn't ready yet");q(T)},[q]);u.useEffect(()=>{var T,M,L;if((M=(T=k==null?void 0:k.context)==null?void 0:T.cart)!=null&&M.id&&Pe("localStorage"))try{window.localStorage.setItem(we,(L=k.context.cart)==null?void 0:L.id)}catch(j){console.warn("Failed to save cartId to localStorage",j)}},[(Pt=(It=k==null?void 0:k.context)==null?void 0:It.cart)==null?void 0:Pt.id]),u.useEffect(()=>{if(K&&Pe("localStorage"))try{window.localStorage.removeItem(we)}catch(T){console.warn("Failed to delete cartId from localStorage",T)}},[K]);const ie=u.useCallback(T=>{var M,L;g&&!((M=T.buyerIdentity)!=null&&M.countryCode)&&(T.buyerIdentity==null&&(T.buyerIdentity={}),T.buyerIdentity.countryCode=g),D&&!((L=T.buyerIdentity)!=null&&L.customerAccessToken)&&(T.buyerIdentity==null&&(T.buyerIdentity={}),T.buyerIdentity.customerAccessToken=D),F({type:"CART_CREATE",payload:T})},[g,D,F]),O=Ur(k),Pn=u.useMemo(()=>{var T,M,L,j;return{...((T=O==null?void 0:O.context)==null?void 0:T.cart)??{lines:[],attributes:[]},status:kr(O.value),error:(M=O==null?void 0:O.context)==null?void 0:M.errors,totalQuantity:((j=(L=O==null?void 0:O.context)==null?void 0:L.cart)==null?void 0:j.totalQuantity)??0,cartCreate:ie,linesAdd(V){var ge,x;(x=(ge=O==null?void 0:O.context)==null?void 0:ge.cart)!=null&&x.id?F({type:"CARTLINE_ADD",payload:{lines:V}}):ie({lines:V})},linesRemove(V){F({type:"CARTLINE_REMOVE",payload:{lines:V}})},linesUpdate(V){F({type:"CARTLINE_UPDATE",payload:{lines:V}})},noteUpdate(V){F({type:"NOTE_UPDATE",payload:{note:V}})},buyerIdentityUpdate(V){F({type:"BUYER_IDENTITY_UPDATE",payload:{buyerIdentity:V}})},cartAttributesUpdate(V){F({type:"CART_ATTRIBUTES_UPDATE",payload:{attributes:V}})},discountCodesUpdate(V){F({type:"DISCOUNT_CODES_UPDATE",payload:{discountCodes:V}})},cartFragment:v}},[ie,(Rt=O==null?void 0:O.context)==null?void 0:Rt.cart,(Dt=O==null?void 0:O.context)==null?void 0:Dt.errors,O.value,v,F]);return React.createElement(tt.Provider,{value:Pn},e)}function kr(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 Ur(e){const[t,r]=u.useTransition(),[n,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(()=>{r(()=>{s.current||a(e)})},[e]),s.current?e:n}function Pe(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 Or(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 rt=u.createContext(null);function Nr({children:e,data:t,initialVariantId:r}){const n=u.useMemo(()=>G(t.variants??{}),[t.variants]);if(!Vr(n))throw new Error("<ProductProvider/> requires 'product.variants.nodes' or 'product.variants.edges'");const a=u.useMemo(()=>Mr(n),[n]),[i,s]=u.useState(()=>ot(r,n)),[o,c]=u.useState(()=>it(i));u.useEffect(()=>{const _=ot(r,n);s(_),c(it(_))},[r,n]);const f=u.useCallback((_,R)=>{c(I=>{const v={...I,[_]:R};return s(at(n,v)),v})},[c,n]),l=u.useCallback((_,R)=>{const I=at(n,{...o,[_]:R});return(I==null?void 0:I.availableForSale)??!0},[o,n]),y=u.useMemo(()=>G(t.sellingPlanGroups??{}).map(_=>({..._,sellingPlans:G((_==null?void 0:_.sellingPlans)??{})})),[t.sellingPlanGroups]),[h,S]=u.useState(void 0),d=u.useMemo(()=>{var _,R;if(!(!i||!h)){if(!((_=i.sellingPlanAllocations)!=null&&_.nodes)&&!((R=i.sellingPlanAllocations)!=null&&R.edges))throw new Error("<ProductProvider/>: You must include 'sellingPlanAllocations.nodes' or 'sellingPlanAllocations.edges' in your variants in order to calculate selectedSellingPlanAllocation");return G(i.sellingPlanAllocations).find(I=>{var v;return((v=I==null?void 0:I.sellingPlan)==null?void 0:v.id)===h.id})}},[i,h]),C=u.useMemo(()=>({product:t,variants:n,variantsConnection:t.variants,options:a,selectedVariant:i,setSelectedVariant:s,selectedOptions:o,setSelectedOption:f,setSelectedOptions:c,isOptionInStock:l,selectedSellingPlan:h,setSelectedSellingPlan:S,selectedSellingPlanAllocation:d,sellingPlanGroups:y,sellingPlanGroupsConnection:t.sellingPlanGroups}),[t,l,a,o,h,d,i,y,f,n]);return React.createElement(rt.Provider,{value:C},e)}function nt(){const e=u.useContext(rt);if(!e)throw new Error("'useProduct' must be a child of <ProductProvider />");return e}function at(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(c=>(c==null?void 0:c.name)===i&&(c==null?void 0:c.value)===s)}))}function Mr(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 ot(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 it(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 Vr(e){return!(!e||!Array.isArray(e))}function Se(e){const{as:t,onClick:r,defaultOnClick:n,children:a,buttonRef:i,...s}=e,o=u.useCallback(f=>{if(r){const l=r(f);if(typeof l=="boolean"&&l===!1||f!=null&&f.defaultPrevented)return}n==null||n(f)},[n,r]),c=t||"button";return React.createElement(c,{ref:i,onClick:o,...s},a)}function Lr(e){const[t,r]=u.useState(!1),{variantId:n,quantity:a=1,attributes:i,sellingPlanId:s,onClick:o,children:c,accessibleAddingToCartLabel:f,...l}=e,{status:y,linesAdd:h}=re(),{selectedVariant:S}=nt(),d=n??(S==null?void 0:S.id)??"",C=n===null||d===""||S===null||t||l.disabled;u.useEffect(()=>{t&&y==="idle"&&r(!1)},[y,t]);const _=u.useCallback(()=>{r(!0),h([{quantity:a,merchandiseId:d||"",attributes:i,sellingPlanId:s}])},[h,a,d,i,s]);return N.createElement(N.Fragment,null,N.createElement(Se,{...l,disabled:C,onClick:o,defaultOnClick:_},c),f?N.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?f:null):null)}const Re={PAGE_VIEW:"PAGE_VIEW",ADD_TO_CART:"ADD_TO_CART"},Te={article:"article",blog:"blog",captcha:"captcha",cart:"cart",collection:"collection",customersAccount:"customers/account",customersActivateAccount:"customers/activate_account",customersAddresses:"customers/addresses",customersLogin:"customers/login",customersOrder:"customers/order",customersRegister:"customers/register",customersResetPassword:"customers/reset_password",giftCard:"gift_card",home:"index",listCollections:"list-collections",forbidden:"403",notFound:"404",page:"page",password:"password",product:"product",policy:"policy",search:"search"},st={hydrogen:"hydrogen",headless:"headless"},ct={hydrogen:"6167201",headless:"12875497473"};function ne(e,t){return{schema_id:e,payload:t,metadata:{event_created_at_ms:Date.now()}}}function Y(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],c=s[s.length-2];return!o||!c?t:{id:`${o}${r}${i}`||"",resource:c??null,resourceId:o||null,search:r,searchParams:n,hash:i}}catch{return t}}function X(e,t){return typeof e!="object"?{}:(Object.entries(e).forEach(([r,n])=>{n&&(t[r]=n)}),t)}function xr(e){return typeof document>"u"?(console.error(`${e} should only be used within the useEffect callback or event handlers`),!0):!1}const Fr="trekkie_storefront_page_view/1.4",$r="myshopify.dev";function qr(e){const t=e,{id:r,resource:n}=Y(t.resourceId),a=n?n.toLowerCase():void 0;return[ne(Fr,X({pageType:t.pageType,customerId:t.customerId,resourceType:a,resourceId:parseInt(r)},Hr(t)))]}function Hr(e){return{appClientId:e.shopifySalesChannel?ct[e.shopifySalesChannel]:ct.headless,isMerchantRequest:Br(e.url),hydrogenSubchannelId:e.storefrontId||"0",isPersistentCookie:e.hasUserConsent,uniqToken:e.uniqueToken,visitToken:e.visitToken,microSessionId:pe(),microSessionCount:1,url:e.url,path:e.path,search:e.search,referrer:e.referrer,title:e.title,shopId:parseInt(Y(e.shopId).id),currency:e.currency,contentLanguage:e.acceptedLanguage||"en"}}function Br(e){if(typeof e!="string")return!1;const t=new URL(e).hostname;return t.indexOf($r)!==-1||t==="localhost"}const ue="custom_storefront_customer_tracking/1.0",Yr="page_rendered",jr="collection_page_rendered",Gr="product_page_rendered",Zr="product_added_to_cart",Wr="search_submitted";function Qr(e){const t=e,r={canonical_url:t.canonicalUrl||t.url,customer_id:t.customerId},n=t.pageType,a=[];switch(a.push(ne(ue,X({event_name:Yr,...r},le(t)))),n){case Te.collection:a.push(ne(ue,X({event_name:jr,...r,collection_name:t.collectionHandle},le(t))));break;case Te.product:a.push(ne(ue,X({event_name:Gr,...r,products:ut(t.products),total_value:t.totalValue},le(t))));break;case Te.search:a.push(ne(ue,X({event_name:Wr,...r,search_string:t.searchString},le(t))));break}return a}function Jr(e){const t=e,r=Y(t.cartId),n=r!=null&&r.id?`${r.id}`:null;return[ne(ue,X({event_name:Zr,customerId:t.customerId,cart_token:n,total_value:t.totalValue,products:ut(t.products)},le(t)))]}function le(e){return{source:e.shopifySalesChannel||st.headless,hydrogenSubchannelId:e.storefrontId||"0",is_persistent_cookie:e.hasUserConsent,ccpa_enforced:!1,gdpr_enforced:!1,unique_token:e.uniqueToken,event_time:Date.now(),event_id:pe(),event_source_url:e.url,referrer:e.referrer,user_agent:e.userAgent,navigation_type:e.navigationType,navigation_api:e.navigationApi,shop_id:parseInt(Y(e.shopId).id),currency:e.currency}}function ut(e){return e?e.map(t=>{const r=X({variant_gid:t.variantGid,category:t.category,sku:t.sku,product_id:parseInt(Y(t.productGid).id),variant_id:parseInt(Y(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 Xr(e,t){const{eventName:r,payload:n}=e;if(!n.hasUserConsent)return Promise.resolve();let a=[];if(r===Re.PAGE_VIEW){const i=n;a=a.concat(qr(i),Qr(i))}else r===Re.ADD_TO_CART&&(a=a.concat(Jr(n)));return a.length?Kr(a,t):Promise.resolve()}const lt="sendShopifyAnalytics request is unsuccessful";function Kr(e,t){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(lt,`
|
|
271
|
+
`,ee="2023-10",be=e=>e.includes("mock.shop");function pr(e){const{storeDomain:t,privateStorefrontToken:r,publicStorefrontToken:n,storefrontApiVersion:o=ee,contentType:i}=e;if(!t)throw new Error(we+`\`storeDomain\` is required when creating a new Storefront client.
|
|
272
|
+
Received "${t}".`);o!==ee&&Sr(`The Storefront API version that you're using is different than the version this build of Hydrogen React is targeting.
|
|
273
|
+
You may run into unexpected errors if these versions don't match. Received verion: "${o}"; expected version "${ee}"`);const s=a=>{const c=(a==null?void 0:a.storeDomain)??t;return c.includes("://")?c:`https://${c}`};return{getShopifyDomain:s,getStorefrontApiUrl(a){const c=s(a),d=c+(c.endsWith("/")?"api":"/api");return be(c)?d:`${d}/${(a==null?void 0:a.storefrontApiVersion)??o}/graphql.json`},getPrivateTokenHeaders(a){if(!r&&!(a!=null&&a.privateStorefrontToken)&&!be(t))throw new Error(we+"You did not pass in a `privateStorefrontToken` while using `createStorefrontClient()` or `getPrivateTokenHeaders()`");return{"content-type":((a==null?void 0:a.contentType)??i)==="graphql"?"application/graphql":"application/json","X-SDK-Variant":"hydrogen-react","X-SDK-Variant-Source":"react","X-SDK-Version":o,"Shopify-Storefront-Private-Token":(a==null?void 0:a.privateStorefrontToken)??r??"",...a!=null&&a.buyerIp?{"Shopify-Storefront-Buyer-IP":a.buyerIp}:{}}},getPublicTokenHeaders(a){if(!n&&!(a!=null&&a.publicStorefrontToken)&&!be(t))throw new Error(we+"You did not pass in a `publicStorefrontToken` while using `createStorefrontClient()` or `getPublicTokenHeaders()`");const c=(a==null?void 0:a.contentType)??i??"json";return Ze(c,o,(a==null?void 0:a.publicStorefrontToken)??n??"")}}}function Ze(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 We=new Set,we="[h2:error:createStorefrontClient] ",Er="[h2:warn:createStorefrontClient] ",Sr=e=>{We.has(e)||(console.warn(Er+e),We.add(e))},Qe={storeDomain:"test",storefrontToken:"abc123",storefrontApiVersion:ee,countryIsoCode:"US",languageIsoCode:"EN",getStorefrontApiUrl(){return""},getPublicTokenHeaders(){return{}},getShopifyDomain(){return""}},Je=u.createContext(Qe);function Cr({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!==ee&&console.warn(`<ShopifyProvider/>: This version of Hydrogen React is built for Shopify's Storefront API version ${ee}, 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=u.useMemo(()=>{function n(o){return(o==null?void 0:o.storeDomain)??t.storeDomain}return{...t,getPublicTokenHeaders(o){return Ze(o.contentType,t.storefrontApiVersion,o.storefrontToken??t.storefrontToken)},getShopifyDomain:n,getStorefrontApiUrl(o){const i=n({storeDomain:(o==null?void 0:o.storeDomain)??t.storeDomain});return`${i}${i.endsWith("/")?"":"/"}api/${(o==null?void 0:o.storefrontApiVersion)??t.storefrontApiVersion}/graphql.json`}}},[t]);return React.createElement(Je.Provider,{value:r},e)}function ie(){const e=u.useContext(Je);if(!e)throw new Error("'useShop()' must be a descendent of <ShopifyProvider/>");return e}const Ie="shopifyCartId",Xe="Shopify-Storefront-Id",Ke="Shopify-Storefront-Y",ze="Shopify-Storefront-S",Z="_shopify_y",W="_shopify_s";var Tr=new Set(["domain","path","max-age","expires","samesite","secure","httponly"]);function _r(e){let t={},r,n,o=0,i=e.split(/;\s*/g),s,a;for(;o<i.length;o++)if(n=i[o],r=n.indexOf("="),~r){if(s=n.substring(0,r++).trim(),a=n.substring(r).trim(),a[0]==='"'&&(a=a.substring(1,a.length-1)),~a.indexOf("%"))try{a=decodeURIComponent(a)}catch{}Tr.has(n=s.toLowerCase())?n==="expires"?t.expires=new Date(a):n==="max-age"?t.maxage=+a:t[n]=a:t[s]=a}else(s=n.trim().toLowerCase())&&(s==="httponly"||s==="secure")&&(t[s]=!0);return t}function Ar(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 et="xxxx-4xxx-xxxx-xxxxxxxxxxxx";function pe(){let e="";try{const t=window.crypto,r=new Uint16Array(31);t.getRandomValues(r);let n=0;e=et.replace(/[x]/g,o=>{const i=r[n]%16,s=o==="x"?i:i&3|8;return n++,s.toString(16)}).toUpperCase()}catch{e=et.replace(/[x]/g,r=>{const n=Math.random()*16|0;return(r==="x"?n:n&3|8).toString(16)}).toUpperCase()}return`${vr()}-${e}`}function vr(){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 Ee(e){const t=_r(e);return{[Z]:t[Z]||"",[W]:t[W]||""}}function br(){const{storefrontId:e,getPublicTokenHeaders:t,getStorefrontApiUrl:r}=ie();return u.useCallback(({query:n,variables:o})=>{const i=t({contentType:"json"});e&&(i[Xe]=e);const s=Ee(document.cookie);return i[Ke]=s[Z],i[ze]=s[W],fetch(r(),{method:"POST",headers:i,body:JSON.stringify({query:n.toString(),variables:o})}).then(a=>a.json()).catch(a=>({data:void 0,errors:a==null?void 0:a.toString()}))},[t,e,r])}function wr({numCartLines:e,cartFragment:t,countryCode:r="US",languageCode:n="EN"}){const o=br(),i=u.useCallback(l=>o({query:hr(t),variables:{id:l,numCartLines:e,country:r,language:n}}),[o,t,e,r,n]),s=u.useCallback(l=>o({query:cr(t),variables:{input:l,numCartLines:e,country:r,language:n}}),[t,r,o,e,n]),a=u.useCallback((l,T)=>o({query:sr(t),variables:{cartId:l,lines:T,numCartLines:e,country:r,language:n}}),[t,r,o,e,n]),c=u.useCallback((l,T)=>o({query:lr(t),variables:{cartId:l,lines:T,numCartLines:e,country:r,language:n}}),[t,r,o,e,n]),d=u.useCallback((l,T)=>o({query:ur(t),variables:{cartId:l,lines:T,numCartLines:e,country:r,language:n}}),[t,r,o,e,n]),f=u.useCallback((l,T)=>o({query:dr(t),variables:{cartId:l,note:T,numCartLines:e,country:r,language:n}}),[o,t,e,r,n]),g=u.useCallback((l,T)=>o({query:fr(t),variables:{cartId:l,buyerIdentity:T,numCartLines:e,country:r,language:n}}),[t,r,o,e,n]),h=u.useCallback((l,T)=>o({query:yr(t),variables:{cartId:l,attributes:T,numCartLines:e,country:r,language:n}}),[t,r,o,e,n]),p=u.useCallback((l,T)=>o({query:gr(t),variables:{cartId:l,discountCodes:T,numCartLines:e,country:r,language:n}}),[t,r,o,e,n]);return u.useMemo(()=>({cartFetch:i,cartCreate:s,cartLineAdd:a,cartLineUpdate:c,cartLineRemove:d,noteUpdate:f,buyerIdentityUpdate:g,cartAttributesUpdate:h,discountCodesUpdate:p,cartFragment:t}),[i,s,a,c,d,f,g,h,p,t])}function H(e,t){return{entry:[...(t==null?void 0:t.entryActions)||[],K({lastValidCart:r=>r==null?void 0:r.cart}),"onCartActionEntry","onCartActionOptimisticUI",e],on:{RESOLVE:{target:(t==null?void 0:t.resolveTarget)||"idle",actions:[K({prevCart:r=>r==null?void 0:r.lastValidCart,cart:(r,n)=>{var o;return(o=n==null?void 0:n.payload)==null?void 0:o.cart},rawCartResult:(r,n)=>{var o;return(o=n==null?void 0:n.payload)==null?void 0:o.rawCartResult},errors:r=>{}})]},ERROR:{target:(t==null?void 0:t.errorTarget)||"error",actions:[K({prevCart:r=>r==null?void 0:r.lastValidCart,cart:r=>r==null?void 0:r.lastValidCart,errors:(r,n)=>{var o;return(o=n==null?void 0:n.payload)==null?void 0:o.errors}})]},CART_COMPLETED:{target:"cartCompleted",actions:K({prevCart:r=>{},cart:r=>{},lastValidCart:r=>{},rawCartResult:r=>{},errors:r=>{}})}},exit:["onCartActionComplete",...(t==null?void 0:t.exitActions)||[]]}}const se={CART_FETCH:{target:"cartFetching"},CART_CREATE:{target:"cartCreating"},CART_SET:{target:"idle",actions:[K({rawCartResult:(e,t)=>t.payload.cart,cart:(e,t)=>Pe(t.payload.cart)})]}},tt={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 Ir(e){return qe({id:"Cart",initial:e?"idle":"uninitialized",context:{cart:e&&Pe(e)},states:{uninitialized:{on:se},cartCompleted:{on:se},initializationError:{on:se},idle:{on:{...se,...tt}},error:{on:{...se,...tt}},cartFetching:H("cartFetchAction",{errorTarget:"initializationError"}),cartCreating:H("cartCreateAction",{errorTarget:"initializationError"}),cartLineRemoving:H("cartLineRemoveAction"),cartLineUpdating:H("cartLineUpdateAction"),cartLineAdding:H("cartLineAddAction"),noteUpdating:H("noteUpdateAction"),buyerIdentityUpdating:H("buyerIdentityUpdateAction"),cartAttributesUpdating:H("cartAttributesUpdateAction"),discountCodesUpdating:H("discountCodesUpdateAction")}})}function Pr({numCartLines:e,onCartActionEntry:t,onCartActionOptimisticUI:r,onCartActionComplete:n,data:o,cartFragment:i,countryCode:s,languageCode:a}){const{cartFetch:c,cartCreate:d,cartLineAdd:f,cartLineUpdate:g,cartLineRemove:h,noteUpdate:p,buyerIdentityUpdate:l,cartAttributesUpdate:T,discountCodesUpdate:_}=wr({numCartLines:e,cartFragment:i,countryCode:s,languageCode:a}),P=u.useMemo(()=>Ir(o),[o]),[b,v,D]=ar(P,{actions:{cartFetchAction:async(y,m)=>{var A;if(m.type!=="CART_FETCH")return;const{data:S,errors:R}=await c((A=m==null?void 0:m.payload)==null?void 0:A.cartId),I=B(m,S==null?void 0:S.cart,R);v(I)},cartCreateAction:async(y,m)=>{var A;if(m.type!=="CART_CREATE")return;const{data:S,errors:R}=await d(m==null?void 0:m.payload),I=B(m,(A=S==null?void 0:S.cartCreate)==null?void 0:A.cart,R);v(I)},cartLineAddAction:async(y,m)=>{var A,w;if(m.type!=="CARTLINE_ADD"||!((A=y==null?void 0:y.cart)!=null&&A.id))return;const{data:S,errors:R}=await f(y.cart.id,m.payload.lines),I=B(m,(w=S==null?void 0:S.cartLinesAdd)==null?void 0:w.cart,R);v(I)},cartLineUpdateAction:async(y,m)=>{var A,w;if(m.type!=="CARTLINE_UPDATE"||!((A=y==null?void 0:y.cart)!=null&&A.id))return;const{data:S,errors:R}=await g(y.cart.id,m.payload.lines),I=B(m,(w=S==null?void 0:S.cartLinesUpdate)==null?void 0:w.cart,R);v(I)},cartLineRemoveAction:async(y,m)=>{var A,w;if(m.type!=="CARTLINE_REMOVE"||!((A=y==null?void 0:y.cart)!=null&&A.id))return;const{data:S,errors:R}=await h(y.cart.id,m.payload.lines),I=B(m,(w=S==null?void 0:S.cartLinesRemove)==null?void 0:w.cart,R);v(I)},noteUpdateAction:async(y,m)=>{var A,w;if(m.type!=="NOTE_UPDATE"||!((A=y==null?void 0:y.cart)!=null&&A.id))return;const{data:S,errors:R}=await p(y.cart.id,m.payload.note),I=B(m,(w=S==null?void 0:S.cartNoteUpdate)==null?void 0:w.cart,R);v(I)},buyerIdentityUpdateAction:async(y,m)=>{var A,w;if(m.type!=="BUYER_IDENTITY_UPDATE"||!((A=y==null?void 0:y.cart)!=null&&A.id))return;const{data:S,errors:R}=await l(y.cart.id,m.payload.buyerIdentity),I=B(m,(w=S==null?void 0:S.cartBuyerIdentityUpdate)==null?void 0:w.cart,R);v(I)},cartAttributesUpdateAction:async(y,m)=>{var A,w;if(m.type!=="CART_ATTRIBUTES_UPDATE"||!((A=y==null?void 0:y.cart)!=null&&A.id))return;const{data:S,errors:R}=await T(y.cart.id,m.payload.attributes),I=B(m,(w=S==null?void 0:S.cartAttributesUpdate)==null?void 0:w.cart,R);v(I)},discountCodesUpdateAction:async(y,m)=>{var A,w;if(m.type!=="DISCOUNT_CODES_UPDATE"||!((A=y==null?void 0:y.cart)!=null&&A.id))return;const{data:S,errors:R}=await _(y.cart.id,m.payload.discountCodes),I=B(m,(w=S==null?void 0:S.cartDiscountCodesUpdate)==null?void 0:w.cart,R);v(I)},...t&&{onCartActionEntry:(y,m)=>{Rr(m)&&t(y,m)}},...r&&{onCartActionOptimisticUI:K((y,m)=>r(y,m))},...n&&{onCartActionComplete:(y,m)=>{Dr(m)&&n(y,m)}}}});return u.useMemo(()=>[b,v,D],[b,v,D])}function Pe(e){return{...e,lines:G(e==null?void 0:e.lines),note:e.note??void 0}}function B(e,t,r){return r?{type:"ERROR",payload:{errors:r,cartActionEvent:e}}:t?{type:"RESOLVE",payload:{cart:Pe(t),rawCartResult:t,cartActionEvent:e}}:{type:"CART_COMPLETED",payload:{cartActionEvent:e}}}function Rr(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 Dr(e){return e.type==="RESOLVE"||e.type==="ERROR"||e.type==="CART_COMPLETED"}const rt=u.createContext(null);function te(){const e=u.useContext(rt);if(!e)throw new Error("Expected a Cart Context, but no Cart Context was found");return e}function kr({children:e,numCartLines:t,onCreate:r,onLineAdd:n,onLineRemove:o,onLineUpdate:i,onNoteUpdate:s,onBuyerIdentityUpdate:a,onAttributesUpdate:c,onDiscountCodesUpdate:d,onCreateComplete:f,onLineAddComplete:g,onLineRemoveComplete:h,onLineUpdateComplete:p,onNoteUpdateComplete:l,onBuyerIdentityUpdateComplete:T,onAttributesUpdateComplete:_,onDiscountCodesUpdateComplete:P,data:b,cartFragment:v=mr,customerAccessToken:D,countryCode:y,languageCode:m}){var bt,wt,It,Pt,Rt,Dt,kt;const S=ie();if(!S)throw new Error("<CartProvider> needs to be a descendant of <ShopifyProvider>");y=(y??S.countryIsoCode??"US").toUpperCase(),m=(m??S.languageIsoCode??"EN").toUpperCase(),y&&(y=y.toUpperCase());const[R,I]=u.useState(y),[A,w]=u.useState(D),$=u.useRef(!1);(R!==y||A!==D)&&(I(y),w(D),$.current=!1);const[k,q]=Pr({numCartLines:t,data:b,cartFragment:v,countryCode:y,languageCode:m,onCartActionEntry(C,M){try{switch(M.type){case"CART_CREATE":return r==null?void 0:r();case"CARTLINE_ADD":return n==null?void 0:n();case"CARTLINE_REMOVE":return o==null?void 0:o();case"CARTLINE_UPDATE":return i==null?void 0:i();case"NOTE_UPDATE":return s==null?void 0:s();case"BUYER_IDENTITY_UPDATE":return a==null?void 0:a();case"CART_ATTRIBUTES_UPDATE":return c==null?void 0:c();case"DISCOUNT_CODES_UPDATE":return d==null?void 0:d()}}catch(L){console.error("Cart entry action failed",L)}},onCartActionOptimisticUI(C,M){var L,j,V,ge;if(!C.cart)return{...C};switch(M.type){case"CARTLINE_REMOVE":return{...C,cart:{...C.cart,lines:(j=(L=C==null?void 0:C.cart)==null?void 0:L.lines)==null?void 0:j.filter(x=>(x==null?void 0:x.id)&&!M.payload.lines.includes(x==null?void 0:x.id))}};case"CARTLINE_UPDATE":return{...C,cart:{...C.cart,lines:(ge=(V=C==null?void 0:C.cart)==null?void 0:V.lines)==null?void 0:ge.map(x=>{const Ne=M.payload.lines.find(({id:Un})=>Un===(x==null?void 0:x.id));return Ne&&Ne.quantity?{...x,quantity:Ne.quantity}:x})}}}return{...C}},onCartActionComplete(C,M){const L=M.payload.cartActionEvent;try{switch(M.type){case"RESOLVE":switch(L.type){case"CART_CREATE":return f==null?void 0:f();case"CARTLINE_ADD":return g==null?void 0:g();case"CARTLINE_REMOVE":return h==null?void 0:h();case"CARTLINE_UPDATE":return p==null?void 0:p();case"NOTE_UPDATE":return l==null?void 0:l();case"BUYER_IDENTITY_UPDATE":return Nr(C,L)&&($.current=!0),T==null?void 0:T();case"CART_ATTRIBUTES_UPDATE":return _==null?void 0:_();case"DISCOUNT_CODES_UPDATE":return P==null?void 0:P()}}}catch(j){console.error("onCartActionComplete failed",j)}}}),Q=u.useRef(!1),ye=k.matches("cartCompleted"),O=(k.value==="idle"||k.value==="error"||k.value==="cartCompleted")&&y!==((It=(wt=(bt=k==null?void 0:k.context)==null?void 0:bt.cart)==null?void 0:wt.buyerIdentity)==null?void 0:It.countryCode)&&!k.context.errors,ae=u.useRef(!1);u.useEffect(()=>{if(!Q.current&&!ae.current){if(!b&&Re("localStorage")){ae.current=!0;try{const C=window.localStorage.getItem(Ie);C&&q({type:"CART_FETCH",payload:{cartId:C}})}catch(C){console.warn("error fetching cartId"),console.warn(C)}}Q.current=!0}},[b,Q,q]),u.useEffect(()=>{!O||$.current||q({type:"BUYER_IDENTITY_UPDATE",payload:{buyerIdentity:{countryCode:y,customerAccessToken:D}}})},[y,D,O,$,q]);const F=u.useCallback(C=>{if(!Q.current)return console.warn("Cart isn't ready yet");q(C)},[q]);u.useEffect(()=>{var C,M,L;if((M=(C=k==null?void 0:k.context)==null?void 0:C.cart)!=null&&M.id&&Re("localStorage"))try{window.localStorage.setItem(Ie,(L=k.context.cart)==null?void 0:L.id)}catch(j){console.warn("Failed to save cartId to localStorage",j)}},[(Rt=(Pt=k==null?void 0:k.context)==null?void 0:Pt.cart)==null?void 0:Rt.id]),u.useEffect(()=>{if(ye&&Re("localStorage"))try{window.localStorage.removeItem(Ie)}catch(C){console.warn("Failed to delete cartId from localStorage",C)}},[ye]);const oe=u.useCallback(C=>{var M,L;y&&!((M=C.buyerIdentity)!=null&&M.countryCode)&&(C.buyerIdentity==null&&(C.buyerIdentity={}),C.buyerIdentity.countryCode=y),D&&!((L=C.buyerIdentity)!=null&&L.customerAccessToken)&&(C.buyerIdentity==null&&(C.buyerIdentity={}),C.buyerIdentity.customerAccessToken=D),F({type:"CART_CREATE",payload:C})},[y,D,F]),U=Or(k),kn=u.useMemo(()=>{var C,M,L,j;return{...((C=U==null?void 0:U.context)==null?void 0:C.cart)??{lines:[],attributes:[]},status:Ur(U.value),error:(M=U==null?void 0:U.context)==null?void 0:M.errors,totalQuantity:((j=(L=U==null?void 0:U.context)==null?void 0:L.cart)==null?void 0:j.totalQuantity)??0,cartCreate:oe,linesAdd(V){var ge,x;(x=(ge=U==null?void 0:U.context)==null?void 0:ge.cart)!=null&&x.id?F({type:"CARTLINE_ADD",payload:{lines:V}}):oe({lines:V})},linesRemove(V){F({type:"CARTLINE_REMOVE",payload:{lines:V}})},linesUpdate(V){F({type:"CARTLINE_UPDATE",payload:{lines:V}})},noteUpdate(V){F({type:"NOTE_UPDATE",payload:{note:V}})},buyerIdentityUpdate(V){F({type:"BUYER_IDENTITY_UPDATE",payload:{buyerIdentity:V}})},cartAttributesUpdate(V){F({type:"CART_ATTRIBUTES_UPDATE",payload:{attributes:V}})},discountCodesUpdate(V){F({type:"DISCOUNT_CODES_UPDATE",payload:{discountCodes:V}})},cartFragment:v}},[oe,(Dt=U==null?void 0:U.context)==null?void 0:Dt.cart,(kt=U==null?void 0:U.context)==null?void 0:kt.errors,U.value,v,F]);return React.createElement(rt.Provider,{value:kn},e)}function Ur(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 Or(e){const[t,r]=u.useTransition(),[n,o]=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(()=>{r(()=>{s.current||o(e)})},[e]),s.current?e:n}function Re(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 Nr(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 nt=u.createContext(null);function Mr({children:e,data:t,initialVariantId:r}){const n=u.useMemo(()=>G(t.variants??{}),[t.variants]);if(!Lr(n))throw new Error("<ProductProvider/> requires 'product.variants.nodes' or 'product.variants.edges'");const o=u.useMemo(()=>Vr(n),[n]),[i,s]=u.useState(()=>it(r,n)),[a,c]=u.useState(()=>st(i));u.useEffect(()=>{const _=it(r,n);s(_),c(st(_))},[r,n]);const d=u.useCallback((_,P)=>{c(b=>{const v={...b,[_]:P};return s(ot(n,v)),v})},[c,n]),f=u.useCallback((_,P)=>{const b=ot(n,{...a,[_]:P});return(b==null?void 0:b.availableForSale)??!0},[a,n]),g=u.useMemo(()=>G(t.sellingPlanGroups??{}).map(_=>({..._,sellingPlans:G((_==null?void 0:_.sellingPlans)??{})})),[t.sellingPlanGroups]),[h,p]=u.useState(void 0),l=u.useMemo(()=>{var _,P;if(!(!i||!h)){if(!((_=i.sellingPlanAllocations)!=null&&_.nodes)&&!((P=i.sellingPlanAllocations)!=null&&P.edges))throw new Error("<ProductProvider/>: You must include 'sellingPlanAllocations.nodes' or 'sellingPlanAllocations.edges' in your variants in order to calculate selectedSellingPlanAllocation");return G(i.sellingPlanAllocations).find(b=>{var v;return((v=b==null?void 0:b.sellingPlan)==null?void 0:v.id)===h.id})}},[i,h]),T=u.useMemo(()=>({product:t,variants:n,variantsConnection:t.variants,options:o,selectedVariant:i,setSelectedVariant:s,selectedOptions:a,setSelectedOption:d,setSelectedOptions:c,isOptionInStock:f,selectedSellingPlan:h,setSelectedSellingPlan:p,selectedSellingPlanAllocation:l,sellingPlanGroups:g,sellingPlanGroupsConnection:t.sellingPlanGroups}),[t,f,o,a,h,l,i,g,d,n]);return React.createElement(nt.Provider,{value:T},e)}function at(){const e=u.useContext(nt);if(!e)throw new Error("'useProduct' must be a child of <ProductProvider />");return e}function ot(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(o=>Object.entries(t).every(([i,s])=>{var a;return(a=o==null?void 0:o.selectedOptions)==null?void 0:a.some(c=>(c==null?void 0:c.name)===i&&(c==null?void 0:c.value)===s)}))}function Vr(e){const t=e.reduce((r,n)=>{var o;if(!n.selectedOptions)throw new Error("'getOptions' requires 'variant.selectedOptions'");return(o=n==null?void 0:n.selectedOptions)==null||o.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 it(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 st(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 Lr(e){return!(!e||!Array.isArray(e))}function Se(e){const{as:t,onClick:r,defaultOnClick:n,children:o,buttonRef:i,...s}=e,a=u.useCallback(d=>{if(r){const f=r(d);if(typeof f=="boolean"&&f===!1||d!=null&&d.defaultPrevented)return}n==null||n(d)},[n,r]),c=t||"button";return React.createElement(c,{ref:i,onClick:a,...s},o)}function xr(e){const[t,r]=u.useState(!1),{variantId:n,quantity:o=1,attributes:i,sellingPlanId:s,onClick:a,children:c,accessibleAddingToCartLabel:d,...f}=e,{status:g,linesAdd:h}=te(),{selectedVariant:p}=at(),l=n??(p==null?void 0:p.id)??"",T=n===null||l===""||p===null||t||f.disabled;u.useEffect(()=>{t&&g==="idle"&&r(!1)},[g,t]);const _=u.useCallback(()=>{r(!0),h([{quantity:o,merchandiseId:l||"",attributes:i,sellingPlanId:s}])},[h,o,l,i,s]);return N.createElement(N.Fragment,null,N.createElement(Se,{...f,disabled:T,onClick:a,defaultOnClick:_},c),d?N.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?d:null):null)}const De={PAGE_VIEW:"PAGE_VIEW",ADD_TO_CART:"ADD_TO_CART"},Ce={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"},ct={hydrogen:"hydrogen",headless:"headless"},ut={hydrogen:"6167201",headless:"12875497473"};function re(e,t){return{schema_id:e,payload:t,metadata:{event_created_at_ms:Date.now()}}}function Y(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:o,hash:i}=new URL(e),s=o.split("/"),a=s[s.length-1],c=s[s.length-2];return!a||!c?t:{id:`${a}${r}${i}`||"",resource:c??null,resourceId:a||null,search:r,searchParams:n,hash:i}}catch{return t}}function X(e,t){return typeof e!="object"?{}:(Object.entries(e).forEach(([r,n])=>{n&&(t[r]=n)}),t)}function Fr(e){return typeof document>"u"?(console.error(`${e} should only be used within the useEffect callback or event handlers`),!0):!1}const $r="trekkie_storefront_page_view/1.4",qr="myshopify.dev";function Hr(e){const t=e,{id:r,resource:n}=Y(t.resourceId),o=n?n.toLowerCase():void 0;return[re($r,X({pageType:t.pageType,customerId:t.customerId,resourceType:o,resourceId:parseInt(r)},Br(t)))]}function Br(e){return{appClientId:e.shopifySalesChannel?ut[e.shopifySalesChannel]:ut.headless,isMerchantRequest:Yr(e.url),hydrogenSubchannelId:e.storefrontId||"0",isPersistentCookie:e.hasUserConsent,uniqToken:e.uniqueToken,visitToken:e.visitToken,microSessionId:pe(),microSessionCount:1,url:e.url,path:e.path,search:e.search,referrer:e.referrer,title:e.title,shopId:parseInt(Y(e.shopId).id),currency:e.currency,contentLanguage:e.acceptedLanguage||"en"}}function Yr(e){if(typeof e!="string")return!1;const t=new URL(e).hostname;return t.indexOf(qr)!==-1||t==="localhost"}const ce="custom_storefront_customer_tracking/1.0",jr="page_rendered",Gr="collection_page_rendered",Zr="product_page_rendered",Wr="product_added_to_cart",Qr="search_submitted";function Jr(e){const t=e,r={canonical_url:t.canonicalUrl||t.url,customer_id:t.customerId},n=t.pageType,o=[];switch(o.push(re(ce,X({event_name:jr,...r},ue(t)))),n){case Ce.collection:o.push(re(ce,X({event_name:Gr,...r,collection_name:t.collectionHandle},ue(t))));break;case Ce.product:o.push(re(ce,X({event_name:Zr,...r,products:lt(t.products),total_value:t.totalValue},ue(t))));break;case Ce.search:o.push(re(ce,X({event_name:Qr,...r,search_string:t.searchString},ue(t))));break}return o}function Xr(e){const t=e,r=Y(t.cartId),n=r!=null&&r.id?`${r.id}`:null;return[re(ce,X({event_name:Wr,customerId:t.customerId,cart_token:n,total_value:t.totalValue,products:lt(t.products)},ue(t)))]}function ue(e){return{source:e.shopifySalesChannel||ct.headless,hydrogenSubchannelId:e.storefrontId||"0",is_persistent_cookie:e.hasUserConsent,ccpa_enforced:!1,gdpr_enforced:!1,unique_token:e.uniqueToken,event_time:Date.now(),event_id:pe(),event_source_url:e.url,referrer:e.referrer,user_agent:e.userAgent,navigation_type:e.navigationType,navigation_api:e.navigationApi,shop_id:parseInt(Y(e.shopId).id),currency:e.currency}}function lt(e){return e?e.map(t=>{const r=X({variant_gid:t.variantGid,category:t.category,sku:t.sku,product_id:parseInt(Y(t.productGid).id),variant_id:parseInt(Y(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 Kr(e,t){const{eventName:r,payload:n}=e;if(!n.hasUserConsent)return Promise.resolve();let o=[];if(r===De.PAGE_VIEW){const i=n;o=o.concat(Hr(i),Jr(i))}else r===De.ADD_TO_CART&&(o=o.concat(Xr(n)));return o.length?zr(o,t):Promise.resolve()}const dt="sendShopifyAnalytics request is unsuccessful";function zr(e,t){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(dt,`
|
|
274
274
|
|
|
275
|
-
`,i.message)})}).catch(n=>{console.error(
|
|
275
|
+
`,i.message)})}).catch(n=>{console.error(dt,n)})}catch{return Promise.resolve()}}function en(){if(Fr("getClientBrowserParameters"))return{uniqueToken:"",visitToken:"",url:"",path:"",search:"",referrer:"",title:"",userAgent:"",navigationType:"",navigationApi:""};const[e,t]=nn(),r=Ee(document.cookie);return{uniqueToken:r[Z],visitToken:r[W],url:location.href,path:location.pathname,search:location.search,referrer:document.referrer,title:document.title,userAgent:navigator.userAgent,navigationType:e,navigationApi:t}}function tn(){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 rn(){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 nn(){try{let e="PerformanceNavigationTiming",t=tn();return t||(t=rn(),e="performance.navigation"),t?[t,e]:["unknown","unknown"]}catch{}return["error","error"]}function an(e){const{cartCreate:t,checkoutUrl:r}=te(),[n,o]=u.useState(!1),{quantity:i,variantId:s,onClick:a,attributes:c,children:d,...f}=e;u.useEffect(()=>{n&&r&&(window.location.href=r)},[n,r]);const g=u.useCallback(()=>{o(!0),t({lines:[{quantity:i??1,merchandiseId:s,attributes:c}]})},[t,i,s,c]);return React.createElement(Se,{disabled:n??f.disabled,...f,onClick:a,defaultOnClick:g},d)}function on(e){const[t,r]=u.useState(!1),{status:n,checkoutUrl:o}=te(),{children:i,...s}=e;return u.useEffect(()=>{t&&o&&n==="idle"&&(window.location.href=o)},[t,n,o]),React.createElement(Se,{...s,disabled:t||s.disabled,onClick:()=>r(!0)},i)}function ft(e){const{countryIsoCode:t,languageIsoCode:r}=ie(),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 o=parseFloat(e.amount),i=u.useMemo(()=>({style:"currency",currency:e.currencyCode}),[e.currencyCode]),s=ne(n,i),a=ne(n,{...i,currencyDisplay:"name"}),c=ne(n,{...i,currencyDisplay:"narrowSymbol"}),d=ne(n,{...i,minimumFractionDigits:0,maximumFractionDigits:0}),f=ne(n),g=ne(n,{minimumFractionDigits:0,maximumFractionDigits:0}),h=l=>l.type==="currency",p=u.useMemo(()=>({original:()=>e,currencyCode:()=>e.currencyCode,localizedString:()=>s().format(o),parts:()=>s().formatToParts(o),withoutTrailingZeros:()=>o%1===0?d().format(o):s().format(o),withoutTrailingZerosAndCurrency:()=>o%1===0?g().format(o):f().format(o),currencyName:()=>{var l;return((l=a().formatToParts(o).find(h))==null?void 0:l.value)??e.currencyCode},currencySymbol:()=>{var l;return((l=s().formatToParts(o).find(h))==null?void 0:l.value)??e.currencyCode},currencyNarrowSymbol:()=>{var l;return((l=c().formatToParts(o).find(h))==null?void 0:l.value)??""},amount:()=>s().formatToParts(o).filter(l=>["decimal","fraction","group","integer","literal"].includes(l.type)).map(l=>l.value).join("")}),[e,o,a,s,c,f,d,g]);return u.useMemo(()=>new Proxy(p,{get:(l,T)=>{var _;return(_=Reflect.get(l,T))==null?void 0:_.call(null)}}),[p])}function ne(e,t){return u.useMemo(()=>{let r;return()=>r??(r=new Intl.NumberFormat(e,t))},[e,t])}function Te({data:e,as:t,withoutCurrency:r,withoutTrailingZeros:n,measurement:o,measurementSeparator:i="/",...s}){if(!sn(e))throw new Error("<Money/> needs a valid 'data' prop that has 'amount' and 'currencyCode'");const a=ft(e),c=t??"div";let d=a.localizedString;return(r||n)&&(r&&!n?d=a.amount:!r&&n?d=a.withoutTrailingZeros:d=a.withoutTrailingZerosAndCurrency),React.createElement(c,{...s},d,o&&o.referenceUnit&&React.createElement(React.Fragment,null,i,o.referenceUnit))}function sn(e){return typeof e.amount=="string"&&!!e.amount&&typeof e.currencyCode=="string"&&!!e.currencyCode}function cn(e){const{cost:t}=te(),{amountType:r="total",children:n,...o}=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(Te,{...o,data:i},n)}const yt=u.createContext(null);function ke(){const e=u.useContext(yt);if(e==null)throw new Error("Expected a cart line context but none was found");return e}function un({children:e,line:t}){return React.createElement(yt.Provider,{value:t},e)}function ln(e){const t=ke(),{as:r,...n}=e,o=r||"span";return React.createElement(o,{...n},t.quantity)}function dn(e){const{status:t,linesRemove:r,linesUpdate:n}=te(),o=ke(),{children:i,adjust:s,onClick:a,...c}=e,d=u.useCallback(()=>{if(s==="remove"){r([(o==null?void 0:o.id)??""]);return}const g=s==="decrease"?((o==null?void 0:o.quantity)??0)-1:((o==null?void 0:o.quantity)??0)+1;if(g<=0){r([(o==null?void 0:o.id)??""]);return}const h={id:(o==null?void 0:o.id)??"",quantity:g,attributes:(o==null?void 0:o.attributes)??[]};n([h])},[s,o==null?void 0:o.attributes,o==null?void 0:o.id,o==null?void 0:o.quantity,r,n]),f=c.disabled;return React.createElement(Se,{...c,onClick:a,defaultOnClick:d,disabled:typeof f<"u"?f:t!=="idle"},i)}const fn={DateTime:"string",Decimal:"string",HTML:"string",URL:"string",Color:"string",UnsignedInt64:"string"};function gt(e){const{data:t,options:r,id:n=t.id,frameBorder:o="0",allow:i="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:s=!0,loading:a="lazy",...c}=e;if(!t.embedUrl)throw new Error("<ExternalVideo/> requires the 'embedUrl' property");let d=t.embedUrl;if(r){const f=new URL(t.embedUrl);for(const g of Object.keys(r))f.searchParams.set(g,r[g]);d=f.toString()}return React.createElement("iframe",{...c,id:n??t.embedUrl,title:t.alt??t.id??"external video",frameBorder:o,allow:i,allowFullScreen:s,src:d,loading:a})}const yn=`#graphql
|
|
276
276
|
fragment Image on Image {
|
|
277
277
|
altText
|
|
278
278
|
url
|
|
279
279
|
width
|
|
280
280
|
height
|
|
281
281
|
}
|
|
282
|
-
`,gt=N.forwardRef(({alt:e,aspectRatio:t,crop:r="center",data:n,decoding:a="async",height:i="auto",loader:s=de,loaderOptions:o,loading:c="lazy",sizes:f,src:l,srcSetOptions:y={intervals:15,startingWidth:200,incrementSize:200,placeholderWidth:100},width:h="100%",widths:S,...d},C)=>{const _=N.useMemo(()=>{const P=n!=null&&n.width&&(n!=null&&n.height)?n==null?void 0:n.width:void 0,b=n!=null&&n.width&&(n!=null&&n.height)?n==null?void 0:n.height:void 0;return{width:P,height:b,unitsMatch:!!ht(P,b)}},[n]),R=N.useMemo(()=>{const b=fe((h||"100%").toString()),A=`${b.number}${b.unit}`,w=i==null,$=w?null:fe(i.toString()),k=$?`${$.number}${$.unit}`:"",q=w?"auto":k,Q=l||(n==null?void 0:n.url),K=n!=null&&n.altText&&!e?n==null?void 0:n.altText:e||"",U=t||(_.unitsMatch?[ye(_.width),ye(_.height)].join("/"):void 0);return{width:A,height:q,src:Q,alt:K,aspectRatio:U}},[h,i,l,n,e,t,_,d==null?void 0:d.key]),{intervals:I,startingWidth:v,incrementSize:D,placeholderWidth:g}=y,m=N.useMemo(()=>hn(h,I,v,D),[h,I,v,D]);return mt(R.width)?N.createElement(yn,{aspectRatio:t,crop:r,decoding:a,height:i,imageWidths:m,loader:s,loading:c,normalizedProps:R,passthroughProps:d,ref:C,width:h}):N.createElement(gn,{aspectRatio:t,crop:r,decoding:a,imageWidths:m,loader:s,loading:c,normalizedProps:R,passthroughProps:d,placeholderWidth:g,ref:C,sizes:f})}),yn=N.forwardRef(({aspectRatio:e,crop:t,decoding:r,height:n,imageWidths:a,loader:i=de,loading:s,normalizedProps:o,passthroughProps:c,width:f},l)=>{const y=N.useMemo(()=>{const h=ye(f),S=ye(n),d=e||(ht(o.width,o.height)?[h,S].join("/"):o.aspectRatio?o.aspectRatio:void 0),C=a===void 0?void 0:Et(a,d,t),_=S||(d&&h?h*(ke(d)??1):void 0),R=pt(o.src,C,i),I=i({src:o.src,width:h,height:_,crop:o.height==="auto"?void 0:t});return{width:h,aspectRatio:d,height:_,srcSet:R,src:I}},[e,t,n,a,i,o,f]);return N.createElement("img",{ref:l,alt:o.alt,decoding:r,height:y.height,loading:s,src:y.src,srcSet:y.srcSet,width:y.width,style:{aspectRatio:y.aspectRatio,...c.style},...c})}),gn=N.forwardRef(({crop:e,decoding:t,imageWidths:r,loader:n=de,loading:a,normalizedProps:i,passthroughProps:s,placeholderWidth:o,sizes:c},f)=>{const l=N.useMemo(()=>{const y=r===void 0?void 0:Et(r,i.aspectRatio,e),h=i.aspectRatio&&o?o*(ke(i.aspectRatio)??1):void 0,S=pt(i.src,y,n),d=n({src:i.src,width:o,height:h,crop:e});return{placeholderHeight:h,srcSet:S,src:d}},[e,r,n,i,o]);return N.createElement("img",{ref:f,alt:i.alt,decoding:t,height:l.placeholderHeight,loading:a,sizes:c,src:l.src,srcSet:l.srcSet,width:o,...s,style:{width:i.width,aspectRatio:i.aspectRatio,...s.style}})});function de({src:e,width:t,height:r,crop:n}){if(!e)return"";const a=new URL(e);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}function ht(e="100%",t="auto"){return fe(e.toString()).unit===fe(t.toString()).unit}function fe(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}=fe(e.toString());switch(t){case"em":return r*16;case"rem":return r*16;case"px":return r;case"":return r;default:return}}function mt(e){return typeof e=="number"||typeof e=="string"&&/\d(px|em|rem)$/.test(e)}function pt(e,t,r=de){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 hn(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 mt(e)?i:a}function ke(e){if(!e)return;const[t,r]=e.split("/");return 1/(Number(t)/Number(r))}function Et(e,t,r="center"){return e?e.map(a=>({width:a,height:t?a*(ke(t)??1):void 0,crop:r})):void 0}const St={};function mn(e,t){const r=St[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(c=>{s.setAttribute(c,o[c])})});return St[e]=n,n}function Ue(e,t){const[r,n]=u.useState("loading"),a=JSON.stringify(t);return u.useEffect(()=>{async function i(){try{n("loading"),await mn(e,t),n("done")}catch{n("error")}}i().catch(()=>{n("error")})},[e,a,t]),r}function Tt(e){var f;const{data:t,previewImageOptions:r,id:n=t.id,playsInline:a=!0,controls:i=!0,sourceProps:s={},...o}=e,c=de({src:((f=t.previewImage)==null?void 0:f.url)??"",...r});if(!t.sources)throw new Error("<Video/> requires a 'data.sources' array");return React.createElement("video",{...o,id:n,playsInline:a,controls:i,poster:c},t.sources.map(l=>{if(!(l!=null&&l.url&&(l!=null&&l.mimeType)))throw new Error("<Video/> needs 'source.url' and 'source.mimeType'");return React.createElement("source",{...s,key:l.url,src:l.url,type:l.mimeType})}))}function Ct(e){var f,l,y;const[t,r]=u.useState(void 0),n=u.useCallback(h=>{r(h)},[]),{data:a,children:i,className:s,...o}=e,c=Ue("https://unpkg.com/@google/model-viewer@v1.12.1/dist/model-viewer.min.js",{module:!0});return u.useEffect(()=>{if(t)return o.onError&&t.addEventListener("error",o.onError),o.onLoad&&t.addEventListener("load",o.onLoad),o.onPreload&&t.addEventListener("preload",o.onPreload),o.onModelVisibility&&t.addEventListener("model-visibility",o.onModelVisibility),o.onProgress&&t.addEventListener("progress",o.onProgress),o.onArStatus&&t.addEventListener("ar-status",o.onArStatus),o.onArTracking&&t.addEventListener("ar-tracking",o.onArTracking),o.onQuickLookButtonTapped&&t.addEventListener("quick-look-button-tapped",o.onQuickLookButtonTapped),o.onCameraChange&&t.addEventListener("camera-change",o.onCameraChange),o.onEnvironmentChange&&t.addEventListener("environment-change",o.onEnvironmentChange),o.onPlay&&t.addEventListener("play",o.onPlay),o.onPause&&t.addEventListener("ar-status",o.onPause),o.onSceneGraphReady&&t.addEventListener("scene-graph-ready",o.onSceneGraphReady),()=>{t!=null&&(o.onError&&t.removeEventListener("error",o.onError),o.onLoad&&t.removeEventListener("load",o.onLoad),o.onPreload&&t.removeEventListener("preload",o.onPreload),o.onModelVisibility&&t.removeEventListener("model-visibility",o.onModelVisibility),o.onProgress&&t.removeEventListener("progress",o.onProgress),o.onArStatus&&t.removeEventListener("ar-status",o.onArStatus),o.onArTracking&&t.removeEventListener("ar-tracking",o.onArTracking),o.onQuickLookButtonTapped&&t.removeEventListener("quick-look-button-tapped",o.onQuickLookButtonTapped),o.onCameraChange&&t.removeEventListener("camera-change",o.onCameraChange),o.onEnvironmentChange&&t.removeEventListener("environment-change",o.onEnvironmentChange),o.onPlay&&t.removeEventListener("play",o.onPlay),o.onPause&&t.removeEventListener("ar-status",o.onPause),o.onSceneGraphReady&&t.removeEventListener("scene-graph-ready",o.onSceneGraphReady))}},[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:(l=(f=a.sources)==null?void 0:f[0])!=null&&l.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||((y=a.previewImage)==null?void 0:y.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 pn({data:e,mediaOptions:t,...r}){switch(e.__typename){case"MediaImage":return e.image?React.createElement(gt,{...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(Tt,{...r,...t==null?void 0:t.video,data:e});case"ExternalVideo":return React.createElement(yt,{...r,...t==null?void 0:t.externalVideo,data:e});case"Model3d":return React.createElement(Ct,{...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 En(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"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=_t(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=_t((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:G(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 _t(e){return String(e).includes("__proto__")?JSON.parse(e,(t,r)=>{if(t!=="__proto__")return r}):JSON.parse(e)}function Sn(e){var f,l,y,h,S,d;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 c=r?G((a==null?void 0:a.variants)??{}).find(C=>(C==null?void 0:C.id)===r)??null:null;if(t==="compareAt")if(r&&c){if(((f=c.compareAtPriceV2)==null?void 0:f.amount)===((l=c.priceV2)==null?void 0:l.amount))return null;s=c.compareAtPriceV2}else n==="max"?s=(y=a==null?void 0:a.compareAtPriceRange)==null?void 0:y.maxVariantPrice:s=(h=a==null?void 0:a.compareAtPriceRange)==null?void 0:h.minVariantPrice;else r&&c?(s=c.priceV2,n==="unit"&&(s=c.unitPrice,o=c.unitPriceMeasurement)):n==="max"?s=(S=a.priceRange)==null?void 0:S.maxVariantPrice:s=(d=a.priceRange)==null?void 0:d.minVariantPrice;return s?o?React.createElement(Ce,{...i,data:s,measurement:o}):React.createElement(Ce,{...i,data:s}):null}const Tn="https://cdn.shopify.com/shopifycloud/shop-js/v1.0/client.js";function Cn({variantIds:e,className:t,variantIdsAndQuantities:r,width:n,storeDomain:a}){const i=se(),s=a||(i==null?void 0:i.storeDomain),o=Ue(Tn);let c=[];if(!s||s===We.storeDomain)throw new Error(_n);if(e&&r)throw new Error(vn);if(!e&&!r)throw new Error(At);if(e)c=e.reduce((l,y)=>{const h=Y(y).id;return h&&l.push(h),l},[]);else if(r)c=r.reduce((l,y)=>{const h=Y(y==null?void 0:y.id).id;return h&&l.push(`${h}:${(y==null?void 0:y.quantity)??1}`),l},[]);else throw new Error(At);if(c.length===0)throw new Error(An);const f=n?{"--shop-pay-button-width":n}:void 0;return React.createElement("div",{className:t,style:f},o==="done"&&React.createElement("shop-pay-button",{"store-url":s,variants:c.join(",")}))}const _n='You must pass a "storeDomain" prop to the "ShopPayButton" component, or wrap it in a "ShopifyProvider" component.',An='You must pass in "variantIds" in the form of ["gid://shopify/ProductVariant/1"]',At='You must pass in either "variantIds" or "variantIdsAndQuantities" to ShopPayButton',vn="You must provide either a variantIds or variantIdsAndQuantities prop, but not both in the ShopPayButton component",bn=60*60*24*360*1,wn=60*30;function In(e){const{hasUserConsent:t=!1,domain:r=""}=e||{};u.useEffect(()=>{const n=Ee(document.cookie);t?(_e(Z,n[Z]||pe(),bn,r),_e(W,n[W]||pe(),wn,r)):(_e(Z,"",0,r),_e(W,"",0,r))})}function _e(e,t,r,n){document.cookie=_r(e,t,{maxage:r,domain:n,samesite:"Lax",path:"/"})}p.AddToCartButton=Lr,p.AnalyticsEventName=Re,p.AnalyticsPageType=Te,p.BuyNowButton=nn,p.CartCheckoutButton=an,p.CartCost=sn,p.CartLineProvider=cn,p.CartLineQuantity=un,p.CartLineQuantityAdjustButton=ln,p.CartProvider=Dr,p.ExternalVideo=yt,p.IMAGE_FRAGMENT=fn,p.Image=gt,p.MediaFile=pn,p.ModelViewer=Ct,p.Money=Ce,p.ProductPrice=Sn,p.ProductProvider=Nr,p.SHOPIFY_S=W,p.SHOPIFY_STOREFRONT_ID_HEADER=Je,p.SHOPIFY_STOREFRONT_S_HEADER=Ke,p.SHOPIFY_STOREFRONT_Y_HEADER=Xe,p.SHOPIFY_Y=Z,p.ShopPayButton=Cn,p.ShopifyProvider=Sr,p.ShopifySalesChannel=st,p.Video=Tt,p.createStorefrontClient=mr,p.flattenConnection=G,p.getClientBrowserParameters=zr,p.getShopifyCookies=Ee,p.parseGid=Y,p.parseMetafield=En,p.sendShopifyAnalytics=Xr,p.storefrontApiCustomScalars=dn,p.useCart=re,p.useCartLine=De,p.useLoadScript=Ue,p.useMoney=dt,p.useProduct=nt,p.useShop=se,p.useShopifyCookies=In,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
|
|
282
|
+
`,ht=N.forwardRef(({alt:e,aspectRatio:t,crop:r="center",data:n,decoding:o="async",height:i="auto",loader:s=le,loading:a="lazy",sizes:c,src:d,srcSetOptions:f={intervals:15,startingWidth:200,incrementSize:200,placeholderWidth:100},width:g="100%",...h},p)=>{const l=N.useMemo(()=>{const m=n!=null&&n.width&&(n!=null&&n.height)?n==null?void 0:n.width:void 0,S=n!=null&&n.width&&(n!=null&&n.height)?n==null?void 0:n.height:void 0;return{width:m,height:S,unitsMatch:!!mt(m,S)}},[n]),T=N.useMemo(()=>{const S=de((g||"100%").toString()),R=`${S.number}${S.unit}`,I=i==null,A=I?null:de(i.toString()),w=A?`${A.number}${A.unit}`:"",$=I?"auto":w,k=d||(n==null?void 0:n.url),q=n!=null&&n.altText&&!e?n==null?void 0:n.altText:e||"",Q=t||(l.unitsMatch?[fe(l.width),fe(l.height)].join("/"):void 0);return{width:R,height:$,src:k,alt:q,aspectRatio:Q}},[g,i,d,n,e,t,l,h==null?void 0:h.key]),{intervals:_,startingWidth:P,incrementSize:b,placeholderWidth:v}=f,D=N.useMemo(()=>mn(g,_,P,b),[g,_,P,b]);return pt(T.width)?N.createElement(gn,{aspectRatio:t,crop:r,decoding:o,height:i,imageWidths:D,loader:s,loading:a,normalizedProps:T,passthroughProps:h,ref:p,width:g}):N.createElement(hn,{aspectRatio:t,crop:r,decoding:o,imageWidths:D,loader:s,loading:a,normalizedProps:T,passthroughProps:h,placeholderWidth:v,ref:p,sizes:c})}),gn=N.forwardRef(({aspectRatio:e,crop:t,decoding:r,height:n,imageWidths:o,loader:i=le,loading:s,normalizedProps:a,passthroughProps:c,width:d},f)=>{const g=N.useMemo(()=>{const h=fe(d),p=fe(n),l=e||(mt(a.width,a.height)?[h,p].join("/"):a.aspectRatio?a.aspectRatio:void 0),T=o===void 0?void 0:St(o,l,t),_=p||(l&&h?h*(Ue(l)??1):void 0),P=Et(a.src,T,i),b=i({src:a.src,width:h,height:_,crop:a.height==="auto"?void 0:t});return{width:h,aspectRatio:l,height:_,srcSet:P,src:b}},[e,t,n,o,i,a,d]);return N.createElement("img",{ref:f,alt:a.alt,decoding:r,height:g.height,loading:s,src:g.src,srcSet:g.srcSet,width:g.width,style:{aspectRatio:g.aspectRatio,...c.style},...c})}),hn=N.forwardRef(({crop:e,decoding:t,imageWidths:r,loader:n=le,loading:o,normalizedProps:i,passthroughProps:s,placeholderWidth:a,sizes:c},d)=>{const f=N.useMemo(()=>{const g=r===void 0?void 0:St(r,i.aspectRatio,e),h=i.aspectRatio&&a?a*(Ue(i.aspectRatio)??1):void 0,p=Et(i.src,g,n),l=n({src:i.src,width:a,height:h,crop:e});return{placeholderHeight:h,srcSet:p,src:l}},[e,r,n,i,a]);return N.createElement("img",{ref:d,alt:i.alt,decoding:t,height:f.placeholderHeight,loading:o,sizes:c,src:f.src,srcSet:f.srcSet,width:a,...s,style:{width:i.width,aspectRatio:i.aspectRatio,...s.style}})});function le({src:e,width:t,height:r,crop:n}){if(!e)return"";const o=new URL(e);return t&&o.searchParams.append("width",Math.round(t).toString()),r&&o.searchParams.append("height",Math.round(r).toString()),n&&o.searchParams.append("crop",n),o.href}function mt(e="100%",t="auto"){return de(e.toString()).unit===de(t.toString()).unit}function de(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 fe(e){if(e===void 0)return;const{unit:t,number:r}=de(e.toString());switch(t){case"em":return r*16;case"rem":return r*16;case"px":return r;case"":return r;default:return}}function pt(e){return typeof e=="number"||typeof e=="string"&&/\d(px|em|rem)$/.test(e)}function Et(e,t,r=le){return e?(t==null?void 0:t.length)===0||!t?e:t.map((n,o)=>`${r({src:e,width:n.width,height:n.height,crop:n.crop})} ${t.length===3?`${o+1}x`:`${n.width??0}w`}`).join(", "):""}function mn(e="100%",t,r,n){const o=Array.from({length:t},(s,a)=>a*n+r),i=Array.from({length:3},(s,a)=>(a+1)*(fe(e)??0));return pt(e)?i:o}function Ue(e){if(!e)return;const[t,r]=e.split("/");return 1/(Number(t)/Number(r))}function St(e,t,r="center"){return e?e.map(o=>({width:o,height:t?o*(Ue(t)??1):void 0,crop:r})):void 0}const Ct={};function pn(e,t){const r=Ct[e];if(r)return r;const n=new Promise((o,i)=>{const s=document.createElement("script");t!=null&&t.module?s.type="module":s.type="text/javascript",s.src=e,s.onload=()=>{o(!0)},s.onerror=()=>{i(!1)},(t==null?void 0:t.in)==="head"?document.head.appendChild(s):document.body.appendChild(s);const a=t==null?void 0:t.attributes;a&&Object.keys(a).forEach(c=>{s.setAttribute(c,a[c])})});return Ct[e]=n,n}function Oe(e,t){const[r,n]=u.useState("loading"),o=JSON.stringify(t);return u.useEffect(()=>{async function i(){try{n("loading"),await pn(e,t),n("done")}catch{n("error")}}i().catch(()=>{n("error")})},[e,o,t]),r}function Tt(e){var d;const{data:t,previewImageOptions:r,id:n=t.id,playsInline:o=!0,controls:i=!0,sourceProps:s={},...a}=e,c=le({src:((d=t.previewImage)==null?void 0:d.url)??"",...r});if(!t.sources)throw new Error("<Video/> requires a 'data.sources' array");return React.createElement("video",{...a,id:n,playsInline:o,controls:i,poster:c},t.sources.map(f=>{if(!(f!=null&&f.url&&(f!=null&&f.mimeType)))throw new Error("<Video/> needs 'source.url' and 'source.mimeType'");return React.createElement("source",{...s,key:f.url,src:f.url,type:f.mimeType})}))}function _t(e){var d,f,g;const[t,r]=u.useState(void 0),n=u.useCallback(h=>{r(h)},[]),{data:o,children:i,className:s,...a}=e,c=Oe("https://unpkg.com/@google/model-viewer@v1.12.1/dist/model-viewer.min.js",{module:!0});return u.useEffect(()=>{if(t)return a.onError&&t.addEventListener("error",a.onError),a.onLoad&&t.addEventListener("load",a.onLoad),a.onPreload&&t.addEventListener("preload",a.onPreload),a.onModelVisibility&&t.addEventListener("model-visibility",a.onModelVisibility),a.onProgress&&t.addEventListener("progress",a.onProgress),a.onArStatus&&t.addEventListener("ar-status",a.onArStatus),a.onArTracking&&t.addEventListener("ar-tracking",a.onArTracking),a.onQuickLookButtonTapped&&t.addEventListener("quick-look-button-tapped",a.onQuickLookButtonTapped),a.onCameraChange&&t.addEventListener("camera-change",a.onCameraChange),a.onEnvironmentChange&&t.addEventListener("environment-change",a.onEnvironmentChange),a.onPlay&&t.addEventListener("play",a.onPlay),a.onPause&&t.addEventListener("ar-status",a.onPause),a.onSceneGraphReady&&t.addEventListener("scene-graph-ready",a.onSceneGraphReady),()=>{t!=null&&(a.onError&&t.removeEventListener("error",a.onError),a.onLoad&&t.removeEventListener("load",a.onLoad),a.onPreload&&t.removeEventListener("preload",a.onPreload),a.onModelVisibility&&t.removeEventListener("model-visibility",a.onModelVisibility),a.onProgress&&t.removeEventListener("progress",a.onProgress),a.onArStatus&&t.removeEventListener("ar-status",a.onArStatus),a.onArTracking&&t.removeEventListener("ar-tracking",a.onArTracking),a.onQuickLookButtonTapped&&t.removeEventListener("quick-look-button-tapped",a.onQuickLookButtonTapped),a.onCameraChange&&t.removeEventListener("camera-change",a.onCameraChange),a.onEnvironmentChange&&t.removeEventListener("environment-change",a.onEnvironmentChange),a.onPlay&&t.removeEventListener("play",a.onPlay),a.onPause&&t.removeEventListener("ar-status",a.onPause),a.onSceneGraphReady&&t.removeEventListener("scene-graph-ready",a.onSceneGraphReady))}},[t,a.onArStatus,a.onArTracking,a.onCameraChange,a.onEnvironmentChange,a.onError,a.onLoad,a.onModelVisibility,a.onPause,a.onPlay,a.onPreload,a.onProgress,a.onQuickLookButtonTapped,a.onSceneGraphReady]),c!=="done"?null:(f=(d=o.sources)==null?void 0:d[0])!=null&&f.url?React.createElement("model-viewer",{ref:n,...a,class:s,id:a.id??o.id,src:o.sources[0].url,alt:o.alt??null,"camera-controls":a.cameraControls??!0,poster:(a.poster||((g=o.previewImage)==null?void 0:g.url))??null,autoplay:a.autoplay??!0,loading:a.loading,reveal:a.reveal,ar:a.ar,"ar-modes":a.arModes,"ar-scale":a.arScale,"ar-placement":a.arPlacement,"ios-src":a.iosSrc,"touch-action":a.touchAction,"disable-zoom":a.disableZoom,"orbit-sensitivity":a.orbitSensitivity,"auto-rotate":a.autoRotate,"auto-rotate-delay":a.autoRotateDelay,"rotation-per-second":a.rotationPerSecond,"interaction-policy":a.interactionPolicy,"interaction-prompt":a.interactionPrompt,"interaction-prompt-style":a.interactionPromptStyle,"interaction-prompt-threshold":a.interactionPromptThreshold,"camera-orbit":a.cameraOrbit,"camera-target":a.cameraTarget,"field-of-view":a.fieldOfView,"max-camera-orbit":a.maxCameraOrbit,"min-camera-orbit":a.minCameraOrbit,"max-field-of-view":a.maxFieldOfView,"min-field-of-view":a.minFieldOfView,bounds:a.bounds,"interpolation-decay":a.interpolationDecay??100,"skybox-image":a.skyboxImage,"environment-image":a.environmentImage,exposure:a.exposure,"shadow-intensity":a.shadowIntensity??0,"shadow-softness":a.shadowSoftness??0,"animation-name":a.animationName,"animation-crossfade-duration":a.animationCrossfadeDuration,"variant-name":a.variantName,orientation:a.orientation,scale:a.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 En({data:e,mediaOptions:t,...r}){switch(e.__typename){case"MediaImage":return e.image?React.createElement(ht,{...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(Tt,{...r,...t==null?void 0:t.video,data:e});case"ExternalVideo":return React.createElement(gt,{...r,...t==null?void 0:t.externalVideo,data:e});case"Model3d":return React.createElement(_t,{...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 Sn(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"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=At(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=At((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:G(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 At(e){return String(e).includes("__proto__")?JSON.parse(e,(t,r)=>{if(t!=="__proto__")return r}):JSON.parse(e)}function Cn(e){var d,f,g,h,p,l;const{priceType:t="regular",variantId:r,valueType:n="min",data:o,...i}=e;if(o==null)throw new Error("<ProductPrice/> requires a product as the 'data' prop");let s,a;const c=r?G((o==null?void 0:o.variants)??{}).find(T=>(T==null?void 0:T.id)===r)??null:null;if(t==="compareAt")if(r&&c){if(((d=c.compareAtPriceV2)==null?void 0:d.amount)===((f=c.priceV2)==null?void 0:f.amount))return null;s=c.compareAtPriceV2}else n==="max"?s=(g=o==null?void 0:o.compareAtPriceRange)==null?void 0:g.maxVariantPrice:s=(h=o==null?void 0:o.compareAtPriceRange)==null?void 0:h.minVariantPrice;else r&&c?(s=c.priceV2,n==="unit"&&(s=c.unitPrice,a=c.unitPriceMeasurement)):n==="max"?s=(p=o.priceRange)==null?void 0:p.maxVariantPrice:s=(l=o.priceRange)==null?void 0:l.minVariantPrice;return s?a?React.createElement(Te,{...i,data:s,measurement:a}):React.createElement(Te,{...i,data:s}):null}const Tn="https://cdn.shopify.com/shopifycloud/shop-js/v1.0/client.js";function _n(e){return e==="headless"||e==="hydrogen"}function An({channel:e,variantIds:t,className:r,variantIdsAndQuantities:n,width:o,storeDomain:i}){const s=ie(),a=i||(s==null?void 0:s.storeDomain),c=Oe(Tn);let d=[],f;if(!a||a===Qe.storeDomain)throw new Error(vn);if(t&&n)throw new Error(wn);if(!t&&!n)throw new Error(vt);if(e)if(_n(e))f=e;else throw new Error(In);if(t)d=t.reduce((h,p)=>{const l=Y(p).id;return l&&h.push(l),h},[]);else if(n)d=n.reduce((h,p)=>{const l=Y(p==null?void 0:p.id).id;return l&&h.push(`${l}:${(p==null?void 0:p.quantity)??1}`),h},[]);else throw new Error(vt);if(d.length===0)throw new Error(bn);const g=o?{"--shop-pay-button-width":o}:void 0;return React.createElement("div",{className:r,style:g},c==="done"&&React.createElement("shop-pay-button",{...f?{channel:f}:{},"store-url":a,variants:d.join(",")}))}const vn='You must pass a "storeDomain" prop to the "ShopPayButton" component, or wrap it in a "ShopifyProvider" component.',bn='You must pass in "variantIds" in the form of ["gid://shopify/ProductVariant/1"]',vt='You must pass in either "variantIds" or "variantIdsAndQuantities" to ShopPayButton',wn="You must provide either a variantIds or variantIdsAndQuantities prop, but not both in the ShopPayButton component",In='Invalid channel attribution value. Must be either "headless" or "hydrogen"',Pn=60*60*24*360*1,Rn=60*30;function Dn(e){const{hasUserConsent:t=!1,domain:r=""}=e||{};u.useEffect(()=>{const n=Ee(document.cookie);t?(_e(Z,n[Z]||pe(),Pn,r),_e(W,n[W]||pe(),Rn,r)):(_e(Z,"",0,r),_e(W,"",0,r))})}function _e(e,t,r,n){document.cookie=Ar(e,t,{maxage:r,domain:n,samesite:"Lax",path:"/"})}E.AddToCartButton=xr,E.AnalyticsEventName=De,E.AnalyticsPageType=Ce,E.BuyNowButton=an,E.CartCheckoutButton=on,E.CartCost=cn,E.CartLineProvider=un,E.CartLineQuantity=ln,E.CartLineQuantityAdjustButton=dn,E.CartProvider=kr,E.ExternalVideo=gt,E.IMAGE_FRAGMENT=yn,E.Image=ht,E.MediaFile=En,E.ModelViewer=_t,E.Money=Te,E.ProductPrice=Cn,E.ProductProvider=Mr,E.SHOPIFY_S=W,E.SHOPIFY_STOREFRONT_ID_HEADER=Xe,E.SHOPIFY_STOREFRONT_S_HEADER=ze,E.SHOPIFY_STOREFRONT_Y_HEADER=Ke,E.SHOPIFY_Y=Z,E.ShopPayButton=An,E.ShopifyProvider=Cr,E.ShopifySalesChannel=ct,E.Video=Tt,E.createStorefrontClient=pr,E.flattenConnection=G,E.getClientBrowserParameters=en,E.getShopifyCookies=Ee,E.parseGid=Y,E.parseMetafield=Sn,E.sendShopifyAnalytics=Kr,E.storefrontApiCustomScalars=fn,E.useCart=te,E.useCartLine=ke,E.useLoadScript=Oe,E.useMoney=ft,E.useProduct=at,E.useShop=ie,E.useShopifyCookies=Dn,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})});
|
|
283
283
|
//# sourceMappingURL=hydrogen-react.prod.js.map
|