@shopify/hydrogen-react 2023.7.3 → 2023.7.4

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