@shopify/hydrogen-react 2024.7.1 → 2024.7.3

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