@shopify/hydrogen-react 2022.10.5 → 2022.10.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-dev/CartProvider.mjs +5 -109
- package/dist/browser-dev/CartProvider.mjs.map +1 -1
- package/dist/browser-dev/cart-queries.mjs +207 -59
- package/dist/browser-dev/cart-queries.mjs.map +1 -1
- package/dist/browser-dev/useCartAPIStateMachine.mjs +6 -3
- package/dist/browser-dev/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/browser-prod/CartProvider.mjs +5 -109
- package/dist/browser-prod/CartProvider.mjs.map +1 -1
- package/dist/browser-prod/cart-queries.mjs +207 -59
- package/dist/browser-prod/cart-queries.mjs.map +1 -1
- package/dist/browser-prod/useCartAPIStateMachine.mjs +6 -3
- package/dist/browser-prod/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/node-dev/CartProvider.js +6 -110
- package/dist/node-dev/CartProvider.js.map +1 -1
- package/dist/node-dev/CartProvider.mjs +5 -109
- package/dist/node-dev/CartProvider.mjs.map +1 -1
- package/dist/node-dev/cart-queries.js +206 -58
- package/dist/node-dev/cart-queries.js.map +1 -1
- package/dist/node-dev/cart-queries.mjs +207 -59
- package/dist/node-dev/cart-queries.mjs.map +1 -1
- package/dist/node-dev/useCartAPIStateMachine.js +6 -3
- package/dist/node-dev/useCartAPIStateMachine.js.map +1 -1
- package/dist/node-dev/useCartAPIStateMachine.mjs +6 -3
- package/dist/node-dev/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/node-prod/CartProvider.js +6 -110
- package/dist/node-prod/CartProvider.js.map +1 -1
- package/dist/node-prod/CartProvider.mjs +5 -109
- package/dist/node-prod/CartProvider.mjs.map +1 -1
- package/dist/node-prod/cart-queries.js +206 -58
- package/dist/node-prod/cart-queries.js.map +1 -1
- package/dist/node-prod/cart-queries.mjs +207 -59
- package/dist/node-prod/cart-queries.mjs.map +1 -1
- package/dist/node-prod/useCartAPIStateMachine.js +6 -3
- package/dist/node-prod/useCartAPIStateMachine.js.map +1 -1
- package/dist/node-prod/useCartAPIStateMachine.mjs +6 -3
- package/dist/node-prod/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/types/CartProvider.d.ts +0 -1
- package/dist/types/cart-queries.d.ts +1 -1
- package/dist/umd/hydrogen-react.dev.js +216 -170
- package/dist/umd/hydrogen-react.dev.js.map +1 -1
- package/dist/umd/hydrogen-react.prod.js +195 -148
- package/dist/umd/hydrogen-react.prod.js.map +1 -1
- package/package.json +3 -8
|
@@ -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 Te(e,r){var t=typeof Symbol=="function"&&e[Symbol.iterator];if(!t)return e;var n,u,a=t.call(e),o=[];try{for(;(r===void 0||r-- >0)&&!(n=a.next()).done;)o.push(n.value)}catch(i){u={error:i}}finally{try{n&&!n.done&&(t=a.return)&&t.call(a)}finally{if(u)throw u.error}}return o}var Y;(function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"})(Y||(Y={}));var
|
|
14
|
+
***************************************************************************** */function Te(e,r){var t=typeof Symbol=="function"&&e[Symbol.iterator];if(!t)return e;var n,u,a=t.call(e),o=[];try{for(;(r===void 0||r-- >0)&&!(n=a.next()).done;)o.push(n.value)}catch(i){u={error:i}}finally{try{n&&!n.done&&(t=a.return)&&t.call(a)}finally{if(u)throw u.error}}return o}var Y;(function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"})(Y||(Y={}));var Ae={type:"xstate.init"};function le(e){return e===void 0?[]:[].concat(e)}function Z(e){return{type:"xstate.assign",assignment:e}}function Ne(e,r){return typeof(e=typeof e=="string"&&r&&r[e]?r[e]:e)=="string"?{type:e}:typeof e=="function"?{type:e.name,exec:e}:e}function ae(e){return function(r){return e===r}}function we(e){return typeof e=="string"?{type:e}:e}function Ie(e,r){return{value:e,context:r,actions:[],changed:!1,matches:ae(e)}}function Oe(e,r,t){var n=r,u=!1;return[e.filter(function(a){if(a.type==="xstate.assign"){u=!0;var o=Object.assign({},n);return typeof a.assignment=="function"?o=a.assignment(n,t):Object.keys(a.assignment).forEach(function(i){o[i]=typeof a.assignment[i]=="function"?a.assignment[i](n,t):a.assignment[i]}),n=o,!1}return!0}),n,u]}function De(e,r){r===void 0&&(r={});var t=Te(Oe(le(e.states[e.initial].entry).map(function(o){return Ne(o,r.actions)}),e.context,Ae),2),n=t[0],u=t[1],a={config:e,_options:r,initialState:{value:e.initial,actions:n,context:u,matches:ae(e.initial)},transition:function(o,i){var l,s,m=typeof o=="string"?{value:o,context:e.context}:o,c=m.value,_=m.context,y=we(i),E=e.states[c];if(E.on){var T=le(E.on[y.type]);try{for(var f=function(L){var G=typeof Symbol=="function"&&Symbol.iterator,k=G&&L[G],se=0;if(k)return k.call(L);if(L&&typeof L.length=="number")return{next:function(){return L&&se>=L.length&&(L=void 0),{value:L&&L[se++],done:!L}}};throw new TypeError(G?"Object is not iterable.":"Symbol.iterator is not defined.")}(T),S=f.next();!S.done;S=f.next()){var b=S.value;if(b===void 0)return Ie(c,_);var v=typeof b=="string"?{target:b}:b,d=v.target,h=v.actions,p=h===void 0?[]:h,w=v.cond,I=w===void 0?function(){return!0}:w,A=d===void 0,O=d!=null?d:c,M=e.states[O];if(I(_,y)){var $=Te(Oe((A?le(p):[].concat(E.exit,p,M.entry).filter(function(L){return L})).map(function(L){return Ne(L,a._options.actions)}),_,y),3),F=$[0],W=$[1],K=$[2],q=d!=null?d:c;return{value:q,context:W,actions:F,changed:d!==c||F.length>0||K,matches:ae(q)}}}}catch(L){l={error:L}}finally{try{S&&!S.done&&(s=f.return)&&s.call(f)}finally{if(l)throw l.error}}}return Ie(c,_)}};return a}var Le=function(e,r){return e.actions.forEach(function(t){var n=t.exec;return n&&n(e.context,r)})};function br(e){var r=e.initialState,t=Y.NotStarted,n=new Set,u={_machine:e,send:function(a){t===Y.Running&&(r=e.transition(r,a),Le(r,we(a)),n.forEach(function(o){return o(r)}))},subscribe:function(a){return n.add(a),a(r),{unsubscribe:function(){return n.delete(a)}}},start:function(a){if(a){var o=typeof a=="object"?a:{context:e.config.context,value:a};r={value:o.value,actions:[],context:o.context,matches:ae(o.value)}}else r=e.initialState;return t=Y.Running,Le(r,Ae),u},stop:function(){return t=Y.Stopped,n.clear(),u},get state(){return r},get status(){return t}};return u}var vr=g.useLayoutEffect,Ue={exports:{}},de={},fe={exports:{}},me={};/**
|
|
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 Me;function Tr(){return Me||(Me=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=C.default,r=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function t(v){{for(var d=arguments.length,h=new Array(d>1?d-1:0),p=1;p<d;p++)h[p-1]=arguments[p];n("error",v,h)}}function n(v,d,h){{var p=r.ReactDebugCurrentFrame,w=p.getStackAddendum();w!==""&&(d+="%s",h=h.concat([w]));var I=h.map(function(A){return String(A)});I.unshift("Warning: "+d),Function.prototype.apply.call(console[v],console,I)}}function u(v,d){return v===d&&(v!==0||1/v===1/d)||v!==v&&d!==d}var a=typeof Object.is=="function"?Object.is:u,o=e.useState,i=e.useEffect,l=e.useLayoutEffect,s=e.useDebugValue,m=!1,c=!1;function _(v,d,h){m||e.startTransition!==void 0&&(m=!0,t("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var p=d();if(!c){var w=d();a(p,w)||(t("The result of getSnapshot should be cached to avoid an infinite loop"),c=!0)}var I=o({inst:{value:p,getSnapshot:d}}),A=I[0].inst,O=I[1];return l(function(){A.value=p,A.getSnapshot=d,y(A)&&O({inst:A})},[v,p,d]),i(function(){y(A)&&O({inst:A});var M=function(){y(A)&&O({inst:A})};return v(M)},[v]),s(p),p}function y(v){var d=v.getSnapshot,h=v.value;try{var p=d();return!a(h,p)}catch{return!0}}function E(v,d,h){return d()}var T=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",f=!T,S=f?E:_,b=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:S;ye.useSyncExternalStore=b,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),ye}var Re;function
|
|
30
|
+
*/var Me;function Tr(){return Me||(Me=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=C.default,r=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function t(v){{for(var d=arguments.length,h=new Array(d>1?d-1:0),p=1;p<d;p++)h[p-1]=arguments[p];n("error",v,h)}}function n(v,d,h){{var p=r.ReactDebugCurrentFrame,w=p.getStackAddendum();w!==""&&(d+="%s",h=h.concat([w]));var I=h.map(function(A){return String(A)});I.unshift("Warning: "+d),Function.prototype.apply.call(console[v],console,I)}}function u(v,d){return v===d&&(v!==0||1/v===1/d)||v!==v&&d!==d}var a=typeof Object.is=="function"?Object.is:u,o=e.useState,i=e.useEffect,l=e.useLayoutEffect,s=e.useDebugValue,m=!1,c=!1;function _(v,d,h){m||e.startTransition!==void 0&&(m=!0,t("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var p=d();if(!c){var w=d();a(p,w)||(t("The result of getSnapshot should be cached to avoid an infinite loop"),c=!0)}var I=o({inst:{value:p,getSnapshot:d}}),A=I[0].inst,O=I[1];return l(function(){A.value=p,A.getSnapshot=d,y(A)&&O({inst:A})},[v,p,d]),i(function(){y(A)&&O({inst:A});var M=function(){y(A)&&O({inst:A})};return v(M)},[v]),s(p),p}function y(v){var d=v.getSnapshot,h=v.value;try{var p=d();return!a(h,p)}catch{return!0}}function E(v,d,h){return d()}var T=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",f=!T,S=f?E:_,b=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:S;ye.useSyncExternalStore=b,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),ye}var Re;function Pe(){return Re||(Re=1,function(e){process.env.NODE_ENV==="production"?e.exports=Cr():e.exports=Tr()}(fe)),fe.exports}/**
|
|
31
31
|
* @license React
|
|
32
32
|
* use-sync-external-store-shim/with-selector.production.min.js
|
|
33
33
|
*
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
*
|
|
36
36
|
* This source code is licensed under the MIT license found in the
|
|
37
37
|
* LICENSE file in the root directory of this source tree.
|
|
38
|
-
*/var
|
|
38
|
+
*/var $e;function Ar(){if($e)return de;$e=1;var e=C.default,r=Pe();function t(s,m){return s===m&&(s!==0||1/s===1/m)||s!==s&&m!==m}var n=typeof Object.is=="function"?Object.is:t,u=r.useSyncExternalStore,a=e.useRef,o=e.useEffect,i=e.useMemo,l=e.useDebugValue;return de.useSyncExternalStoreWithSelector=function(s,m,c,_,y){var E=a(null);if(E.current===null){var T={hasValue:!1,value:null};E.current=T}else T=E.current;E=i(function(){function S(p){if(!b){if(b=!0,v=p,p=_(p),y!==void 0&&T.hasValue){var w=T.value;if(y(w,p))return d=w}return d=p}if(w=d,n(v,p))return w;var I=_(p);return y!==void 0&&y(w,I)?w:(v=p,d=I)}var b=!1,v,d,h=c===void 0?null:c;return[function(){return S(m())},h===null?void 0:function(){return S(h())}]},[m,c,_,y]);var f=u(s,E[0],E[1]);return o(function(){T.hasValue=!0,T.value=f},[f]),l(f),f},de}var he={};/**
|
|
39
39
|
* @license React
|
|
40
40
|
* use-sync-external-store-shim/with-selector.development.js
|
|
41
41
|
*
|
|
@@ -43,198 +43,245 @@
|
|
|
43
43
|
*
|
|
44
44
|
* This source code is licensed under the MIT license found in the
|
|
45
45
|
* LICENSE file in the root directory of this source tree.
|
|
46
|
-
*/var Ve;function
|
|
47
|
-
mutation CartLineAdd(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
*/var Ve;function Nr(){return Ve||(Ve=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=C.default,r=Pe();function t(m,c){return m===c&&(m!==0||1/m===1/c)||m!==m&&c!==c}var n=typeof Object.is=="function"?Object.is:t,u=r.useSyncExternalStore,a=e.useRef,o=e.useEffect,i=e.useMemo,l=e.useDebugValue;function s(m,c,_,y,E){var T=a(null),f;T.current===null?(f={hasValue:!1,value:null},T.current=f):f=T.current;var S=i(function(){var h=!1,p,w,I=function($){if(!h){h=!0,p=$;var F=y($);if(E!==void 0&&f.hasValue){var W=f.value;if(E(W,F))return w=W,W}return w=F,F}var K=p,q=w;if(n(K,$))return q;var L=y($);return E!==void 0&&E(q,L)?q:(p=$,w=L,L)},A=_===void 0?null:_,O=function(){return I(c())},M=A===null?void 0:function(){return I(A())};return[O,M]},[c,_,y,E]),b=S[0],v=S[1],d=u(m,b,v);return o(function(){f.hasValue=!0,f.value=d},[d]),l(d),d}he.useSyncExternalStoreWithSelector=s,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),he}(function(e){process.env.NODE_ENV==="production"?e.exports=Ar():e.exports=Nr()})(Ue);function wr(e){var r=Ce.useRef();return r.current||(r.current={v:e()}),r.current.v}var Fe=globalThis&&globalThis.__read||function(e,r){var t=typeof Symbol=="function"&&e[Symbol.iterator];if(!t)return e;var n=t.call(e),u,a=[],o;try{for(;(r===void 0||r-- >0)&&!(u=n.next()).done;)a.push(u.value)}catch(i){o={error:i}}finally{try{u&&!u.done&&(t=n.return)&&t.call(n)}finally{if(o)throw o.error}}return a};function Ir(e){return e}var Or=function(e){var r;return e.subscribe(function(t){r=t}).unsubscribe(),r};function Dr(e,r){var t=g.useRef();if(process.env.NODE_ENV!=="production"){var n=Fe(g.useState(e),1),u=n[0];e!==u&&console.warn("Machine given to `useMachine` has changed between renders. This is not supported and might lead to unexpected results.\nPlease make sure that you pass the same Machine as argument each time.")}var a=Fe(wr(function(){var s=[],m=br(De(e.config,r||e._options)),c=m.send;return m.send=function(_){if(m.status===Y.NotStarted){s.push(_);return}c(_),t.current=m.state},[m,s]}),2),o=a[0],i=a[1];vr(function(){r&&(o._machine._options=r)});var l=Ur(o);return g.useEffect(function(){return o.start(t.current),i.forEach(o.send),t.current=o.state,function(){o.stop()}},[]),l}var Lr=function(e,r){return r.changed===!1};function Ur(e){var r=g.useCallback(function(){return Or(e)},[e]),t=g.useCallback(function(u){var a=e.subscribe(u).unsubscribe;return a},[e]),n=Ue.exports.useSyncExternalStoreWithSelector(t,r,r,Ir,Lr);return[n,e.send,e]}function x(e){if(!e){const r=`flattenConnection(): needs a 'connection' to flatten, but received '${e}' instead`;return console.error(r),[]}return e.nodes?e.nodes:e.edges?e.edges.map(r=>{if(!(r!=null&&r.node))throw new Error("Connection edges must contain nodes");return r.node}):[]}const kr=e=>`
|
|
47
|
+
mutation CartLineAdd(
|
|
48
|
+
$cartId: ID!
|
|
49
|
+
$lines: [CartLineInput!]!
|
|
50
|
+
$numCartLines: Int = 250
|
|
51
|
+
$country: CountryCode = ZZ
|
|
52
|
+
) @inContext(country: $country) {
|
|
53
|
+
cartLinesAdd(cartId: $cartId, lines: $lines) {
|
|
54
|
+
cart {
|
|
55
|
+
...CartFragment
|
|
56
|
+
}
|
|
51
57
|
}
|
|
52
58
|
}
|
|
53
|
-
}
|
|
54
59
|
|
|
55
|
-
${e}
|
|
60
|
+
${e}
|
|
56
61
|
`,Mr=e=>`
|
|
57
|
-
mutation CartCreate(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
62
|
+
mutation CartCreate(
|
|
63
|
+
$input: CartInput!
|
|
64
|
+
$numCartLines: Int = 250
|
|
65
|
+
$country: CountryCode = ZZ
|
|
66
|
+
) @inContext(country: $country) {
|
|
67
|
+
cartCreate(input: $input) {
|
|
68
|
+
cart {
|
|
69
|
+
...CartFragment
|
|
70
|
+
}
|
|
61
71
|
}
|
|
62
72
|
}
|
|
63
|
-
}
|
|
64
73
|
|
|
65
|
-
${e}
|
|
74
|
+
${e}
|
|
66
75
|
`,Rr=e=>`
|
|
67
|
-
mutation CartLineRemove(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
76
|
+
mutation CartLineRemove(
|
|
77
|
+
$cartId: ID!
|
|
78
|
+
$lines: [ID!]!
|
|
79
|
+
$numCartLines: Int = 250
|
|
80
|
+
$country: CountryCode = ZZ
|
|
81
|
+
) @inContext(country: $country) {
|
|
82
|
+
cartLinesRemove(cartId: $cartId, lineIds: $lines) {
|
|
83
|
+
cart {
|
|
84
|
+
...CartFragment
|
|
85
|
+
}
|
|
71
86
|
}
|
|
72
87
|
}
|
|
73
|
-
}
|
|
74
88
|
|
|
75
|
-
${e}
|
|
76
|
-
|
|
77
|
-
mutation CartLineUpdate(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
89
|
+
${e}
|
|
90
|
+
`,Pr=e=>`
|
|
91
|
+
mutation CartLineUpdate(
|
|
92
|
+
$cartId: ID!
|
|
93
|
+
$lines: [CartLineUpdateInput!]!
|
|
94
|
+
$numCartLines: Int = 250
|
|
95
|
+
$country: CountryCode = ZZ
|
|
96
|
+
) @inContext(country: $country) {
|
|
97
|
+
cartLinesUpdate(cartId: $cartId, lines: $lines) {
|
|
98
|
+
cart {
|
|
99
|
+
...CartFragment
|
|
100
|
+
}
|
|
81
101
|
}
|
|
82
102
|
}
|
|
83
|
-
}
|
|
84
103
|
|
|
85
|
-
${e}
|
|
86
|
-
|
|
87
|
-
mutation CartNoteUpdate(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
104
|
+
${e}
|
|
105
|
+
`,$r=e=>`
|
|
106
|
+
mutation CartNoteUpdate(
|
|
107
|
+
$cartId: ID!
|
|
108
|
+
$note: String
|
|
109
|
+
$numCartLines: Int = 250
|
|
110
|
+
$country: CountryCode = ZZ
|
|
111
|
+
) @inContext(country: $country) {
|
|
112
|
+
cartNoteUpdate(cartId: $cartId, note: $note) {
|
|
113
|
+
cart {
|
|
114
|
+
...CartFragment
|
|
115
|
+
}
|
|
91
116
|
}
|
|
92
117
|
}
|
|
93
|
-
}
|
|
94
118
|
|
|
95
|
-
${e}
|
|
119
|
+
${e}
|
|
96
120
|
`,Vr=e=>`
|
|
97
|
-
mutation CartBuyerIdentityUpdate(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
) @inContext(country: $country) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
121
|
+
mutation CartBuyerIdentityUpdate(
|
|
122
|
+
$cartId: ID!
|
|
123
|
+
$buyerIdentity: CartBuyerIdentityInput!
|
|
124
|
+
$numCartLines: Int = 250
|
|
125
|
+
$country: CountryCode = ZZ
|
|
126
|
+
) @inContext(country: $country) {
|
|
127
|
+
cartBuyerIdentityUpdate(cartId: $cartId, buyerIdentity: $buyerIdentity) {
|
|
128
|
+
cart {
|
|
129
|
+
...CartFragment
|
|
130
|
+
}
|
|
106
131
|
}
|
|
107
132
|
}
|
|
108
|
-
}
|
|
109
133
|
|
|
110
|
-
${e}
|
|
134
|
+
${e}
|
|
111
135
|
`,Fr=e=>`
|
|
112
|
-
mutation CartAttributesUpdate(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
136
|
+
mutation CartAttributesUpdate(
|
|
137
|
+
$attributes: [AttributeInput!]!
|
|
138
|
+
$cartId: ID!
|
|
139
|
+
$numCartLines: Int = 250
|
|
140
|
+
$country: CountryCode = ZZ
|
|
141
|
+
) @inContext(country: $country) {
|
|
142
|
+
cartAttributesUpdate(attributes: $attributes, cartId: $cartId) {
|
|
143
|
+
cart {
|
|
144
|
+
...CartFragment
|
|
145
|
+
}
|
|
116
146
|
}
|
|
117
147
|
}
|
|
118
|
-
}
|
|
119
148
|
|
|
120
|
-
${e}
|
|
149
|
+
${e}
|
|
121
150
|
`,xr=e=>`
|
|
122
|
-
mutation CartDiscountCodesUpdate(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
151
|
+
mutation CartDiscountCodesUpdate(
|
|
152
|
+
$cartId: ID!
|
|
153
|
+
$discountCodes: [String!]
|
|
154
|
+
$numCartLines: Int = 250
|
|
155
|
+
$country: CountryCode = ZZ
|
|
156
|
+
) @inContext(country: $country) {
|
|
157
|
+
cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {
|
|
158
|
+
cart {
|
|
159
|
+
...CartFragment
|
|
160
|
+
}
|
|
126
161
|
}
|
|
127
162
|
}
|
|
128
|
-
}
|
|
129
163
|
|
|
130
|
-
${e}
|
|
164
|
+
${e}
|
|
131
165
|
`,jr=e=>`
|
|
132
|
-
query CartQuery(
|
|
133
|
-
|
|
134
|
-
|
|
166
|
+
query CartQuery(
|
|
167
|
+
$id: ID!
|
|
168
|
+
$numCartLines: Int = 250
|
|
169
|
+
$country: CountryCode = ZZ
|
|
170
|
+
) @inContext(country: $country) {
|
|
171
|
+
cart(id: $id) {
|
|
172
|
+
...CartFragment
|
|
173
|
+
}
|
|
135
174
|
}
|
|
136
|
-
}
|
|
137
175
|
|
|
138
|
-
${e}
|
|
139
|
-
`,J="2022-10",xe=new Set,Br=e=>{xe.has(e)||(console.warn(e),xe.add(e))};function qr({storeDomain:e,privateStorefrontToken:r,publicStorefrontToken:t,storefrontApiVersion:n,contentType:u}){return n!==J&&Br(`StorefrontClient: The Storefront API version that you're using is different than the version this build of Hydrogen-UI is targeting. You may run into unexpected errors if these versions don't match. Received verion: "${n}"; expected version "${J}"`),{getShopifyDomain(a){var o;return`https://${(o=a==null?void 0:a.storeDomain)!=null?o:e}.myshopify.com`},getStorefrontApiUrl(a){var o,i;return`https://${(o=a==null?void 0:a.storeDomain)!=null?o:e}.myshopify.com/api/${(i=a==null?void 0:a.storefrontApiVersion)!=null?i:n}/graphql.json`},getPrivateTokenHeaders(a){var i,l,s;if(!r&&!(a!=null&&a.privateStorefrontToken))throw new Error("StorefrontClient: You did not pass in a 'privateStorefrontToken' while using 'getPrivateTokenHeaders()'");return{"content-type":((i=a==null?void 0:a.contentType)!=null?i:u)==="graphql"?"application/graphql":"application/json","X-SDK-Variant":"hydrogen-ui","X-SDK-Variant-Source":"react","X-SDK-Version":n,"Shopify-Storefront-Private-Token":(s=(l=a==null?void 0:a.privateStorefrontToken)!=null?l:r)!=null?s:"",...a!=null&&a.buyerIp?{"Shopify-Storefront-Buyer-IP":a.buyerIp}:{}}},getPublicTokenHeaders(a){var i,l,s,m;if(!t&&!(a!=null&&a.publicStorefrontToken))throw new Error("StorefrontClient: You did not pass in a 'publicStorefrontToken' while using 'getPublicTokenHeaders()'");const o=(l=(i=a==null?void 0:a.contentType)!=null?i:u)!=null?l:"json";return je(o,n,(m=(s=a==null?void 0:a.publicStorefrontToken)!=null?s:t)!=null?m:"")}}}function je(e,r,t){return{"content-type":e==="graphql"?"application/graphql":"application/json","X-SDK-Variant":"hydrogen-ui","X-SDK-Variant-Source":"react","X-SDK-Version":r,"X-Shopify-Storefront-Access-Token":t}}var Hr="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ShopifyProvider.tsx";const Be=g.createContext({storeDomain:"test",storefrontToken:"abc123",storefrontApiVersion:J,country:{isoCode:"US"},language:{isoCode:"EN"},locale:"EN-US",getStorefrontApiUrl(){return""},getPublicTokenHeaders(){return{}},getShopifyDomain(){return""}});function Wr({children:e,shopifyConfig:r}){if(!r)throw new Error("The 'shopifyConfig' prop must be passed to '<ShopifyProvider/>'");r.storefrontApiVersion!==J&&console.warn(`<ShopifyProvider/>: This version of Hydrogen-UI is built for Shopify's Storefront API version ${J}, but it looks like you're using version ${r.storefrontApiVersion}. There may be issues or bugs if you use a mismatched version of Hydrogen-UI and the Storefront API.`);const t=g.useMemo(()=>{const n=r.storeDomain.replace(/^https?:\/\//,"");n.includes(".myshopify.com");function u(a){var i;let o=(i=a==null?void 0:a.storeDomain)!=null?i:n;return o=o.replace(".myshopify.com",""),`https://${o}.myshopify.com`}return{...r,storeDomain:n,getPublicTokenHeaders(a){var o;return je(a.contentType,r.storefrontApiVersion,(o=a.storefrontToken)!=null?o:r.storefrontToken)},getShopifyDomain:u,getStorefrontApiUrl(a){var o,i,l;return(o=a==null?void 0:a.storeDomain)!=null&&o.includes(".myshopify.com"),`${u({storeDomain:(i=a==null?void 0:a.storeDomain)!=null?i:n})}/api/${(l=a==null?void 0:a.storefrontApiVersion)!=null?l:r.storefrontApiVersion}/graphql.json`}}},[r]);return C.default.createElement(Be.Provider,{value:t,__self:this,__source:{fileName:Hr,lineNumber:99,columnNumber:5}},e)}function X(){const e=g.useContext(Be);if(!e)throw new Error("'useShop()' must be a descendent of <ShopifyProvider/>");return e}const _e="shopifyCartId",Yr="Shopify-Storefront-Id",Gr="Shopify-Storefront-Y",Zr="Shopify-Storefront-S",qe="_shopify_y",He="_shopify_s";var zr=new Set(["domain","path","max-age","expires","samesite","secure","httponly"]);function Kr(e){let r={},t,n,u=0,a=e.split(/;\s*/g),o,i;for(;u<a.length;u++)if(n=a[u],t=n.indexOf("="),~t){if(o=n.substring(0,t++).trim(),i=n.substring(t).trim(),i[0]==='"'&&(i=i.substring(1,i.length-1)),~i.indexOf("%"))try{i=decodeURIComponent(i)}catch{}zr.has(n=o.toLowerCase())?n==="expires"?r.expires=new Date(i):n==="max-age"?r.maxage=+i:r[n]=i:r[o]=i}else(o=n.trim().toLowerCase())&&(o==="httponly"||o==="secure")&&(r[o]=!0);return r}function Qr(){const{storefrontId:e,getPublicTokenHeaders:r,getStorefrontApiUrl:t}=X();return g.useCallback(({query:n,variables:u})=>{const a=r({contentType:"json"});e&&(a[Yr]=e);const o=Kr(document.cookie);return o[qe]&&o[He]&&(a[Gr]=o[qe],a[Zr]=o[He]),fetch(t(),{method:"POST",headers:a,body:JSON.stringify({query:n.toString(),variables:u})}).then(i=>i.json()).catch(i=>({data:void 0,errors:i.toString()}))},[r,e,t])}function Jr({numCartLines:e,cartFragment:r,countryCode:t="US"}){const n=Qr(),u=g.useCallback(y=>n({query:jr(r),variables:{id:y,numCartLines:e,country:t}}),[n,r,e,t]),a=g.useCallback(y=>n({query:Mr(r),variables:{input:y,numCartLines:e,country:t}}),[r,t,n,e]),o=g.useCallback((y,E)=>n({query:kr(r),variables:{cartId:y,lines:E,numCartLines:e,country:t}}),[r,t,n,e]),i=g.useCallback((y,E)=>n({query:$r(r),variables:{cartId:y,lines:E,numCartLines:e,country:t}}),[r,t,n,e]),l=g.useCallback((y,E)=>n({query:Rr(r),variables:{cartId:y,lines:E,numCartLines:e,country:t}}),[r,t,n,e]),s=g.useCallback((y,E)=>n({query:Pr(r),variables:{cartId:y,note:E,numCartLines:e,country:t}}),[n,r,e,t]),m=g.useCallback((y,E)=>n({query:Vr(r),variables:{cartId:y,buyerIdentity:E,numCartLines:e,country:t}}),[r,t,n,e]),c=g.useCallback((y,E)=>n({query:Fr(r),variables:{cartId:y,attributes:E,numCartLines:e,country:t}}),[r,t,n,e]),_=g.useCallback((y,E)=>n({query:xr(r),variables:{cartId:y,discountCodes:E,numCartLines:e,country:t}}),[r,t,n,e]);return g.useMemo(()=>({cartFetch:u,cartCreate:a,cartLineAdd:o,cartLineUpdate:i,cartLineRemove:l,noteUpdate:s,buyerIdentityUpdate:m,cartAttributesUpdate:c,discountCodesUpdate:_,cartFragment:r}),[u,a,o,i,l,s,m,c,_,r])}function j(e,r){return{entry:[...(r==null?void 0:r.entryActions)||[],"onCartActionEntry","onCartActionOptimisticUI",e],on:{RESOLVE:{target:(r==null?void 0:r.resolveTarget)||"idle",actions:[Q({prevCart:t=>t==null?void 0:t.cart,cart:(t,n)=>{var u;return(u=n==null?void 0:n.payload)==null?void 0:u.cart},rawCartResult:(t,n)=>{var u;return(u=n==null?void 0:n.payload)==null?void 0:u.rawCartResult},errors:t=>{}})]},ERROR:{target:(r==null?void 0:r.errorTarget)||"error",actions:[Q({prevCart:t=>t==null?void 0:t.cart,cart:t=>t==null?void 0:t.lastValidCart,errors:(t,n)=>{var u;return(u=n==null?void 0:n.payload)==null?void 0:u.errors}})]},CART_COMPLETED:{target:"cartCompleted",actions:Q({prevCart:t=>{},cart:t=>{},lastValidCart:t=>{},errors:t=>{}})}},exit:["onCartActionComplete",...(r==null?void 0:r.exitActions)||[]]}}const ee={CART_FETCH:{target:"cartFetching"},CART_CREATE:{target:"cartCreating"},CART_SET:{target:"idle",actions:[Q({rawCartResult:(e,r)=>r.payload.cart,cart:(e,r)=>ge(r.payload.cart)})]}},We={CARTLINE_ADD:{target:"cartLineAdding"},CARTLINE_UPDATE:{target:"cartLineUpdating"},CARTLINE_REMOVE:{target:"cartLineRemoving"},NOTE_UPDATE:{target:"noteUpdating"},BUYER_IDENTITY_UPDATE:{target:"buyerIdentityUpdating"},CART_ATTRIBUTES_UPDATE:{target:"cartAttributesUpdating"},DISCOUNT_CODES_UPDATE:{target:"discountCodesUpdating"}};function Xr(e){return De({id:"Cart",initial:e?"idle":"uninitialized",context:{cart:e&&ge(e)},states:{uninitialized:{on:ee},cartCompleted:{on:ee},initializationError:{on:ee},idle:{on:{...ee,...We}},error:{on:{...ee,...We}},cartFetching:j("cartFetchAction",{errorTarget:"initializationError"}),cartCreating:j("cartCreateAction",{errorTarget:"initializationError"}),cartLineRemoving:j("cartLineRemoveAction"),cartLineUpdating:j("cartLineUpdateAction"),cartLineAdding:j("cartLineAddAction"),noteUpdating:j("noteUpdateAction"),buyerIdentityUpdating:j("buyerIdentityUpdateAction"),cartAttributesUpdating:j("cartAttributesUpdateAction"),discountCodesUpdating:j("discountCodesUpdateAction")}})}function et({numCartLines:e,onCartActionEntry:r,onCartActionOptimisticUI:t,onCartActionComplete:n,data:u,cartFragment:a,countryCode:o}){const{cartFetch:i,cartCreate:l,cartLineAdd:s,cartLineUpdate:m,cartLineRemove:c,noteUpdate:_,buyerIdentityUpdate:y,cartAttributesUpdate:E,discountCodesUpdate:T}=Jr({numCartLines:e,cartFragment:a,countryCode:o}),f=g.useMemo(()=>Xr(u),[u]),[S,b,v]=Dr(f,{actions:{cartFetchAction:async(d,h)=>{var A;if(h.type!=="CART_FETCH")return;const{data:p,errors:w}=await i((A=h==null?void 0:h.payload)==null?void 0:A.cartId),I=B(h,p==null?void 0:p.cart,w);b(I)},cartCreateAction:async(d,h)=>{var A;if(h.type!=="CART_CREATE")return;const{data:p,errors:w}=await l(h==null?void 0:h.payload),I=B(h,(A=p==null?void 0:p.cartCreate)==null?void 0:A.cart,w);b(I)},cartLineAddAction:async(d,h)=>{var A,O;if(h.type!=="CARTLINE_ADD"||!((A=d==null?void 0:d.cart)!=null&&A.id))return;const{data:p,errors:w}=await s(d.cart.id,h.payload.lines),I=B(h,(O=p==null?void 0:p.cartLinesAdd)==null?void 0:O.cart,w);b(I)},cartLineUpdateAction:async(d,h)=>{var A,O;if(h.type!=="CARTLINE_UPDATE"||!((A=d==null?void 0:d.cart)!=null&&A.id))return;const{data:p,errors:w}=await m(d.cart.id,h.payload.lines),I=B(h,(O=p==null?void 0:p.cartLinesUpdate)==null?void 0:O.cart,w);b(I)},cartLineRemoveAction:async(d,h)=>{var A,O;if(h.type!=="CARTLINE_REMOVE"||!((A=d==null?void 0:d.cart)!=null&&A.id))return;const{data:p,errors:w}=await c(d.cart.id,h.payload.lines),I=B(h,(O=p==null?void 0:p.cartLinesRemove)==null?void 0:O.cart,w);b(I)},noteUpdateAction:async(d,h)=>{var A,O;if(h.type!=="NOTE_UPDATE"||!((A=d==null?void 0:d.cart)!=null&&A.id))return;const{data:p,errors:w}=await _(d.cart.id,h.payload.note),I=B(h,(O=p==null?void 0:p.cartNoteUpdate)==null?void 0:O.cart,w);b(I)},buyerIdentityUpdateAction:async(d,h)=>{var A,O;if(h.type!=="BUYER_IDENTITY_UPDATE"||!((A=d==null?void 0:d.cart)!=null&&A.id))return;const{data:p,errors:w}=await y(d.cart.id,h.payload.buyerIdentity),I=B(h,(O=p==null?void 0:p.cartBuyerIdentityUpdate)==null?void 0:O.cart,w);b(I)},cartAttributesUpdateAction:async(d,h)=>{var A,O;if(h.type!=="CART_ATTRIBUTES_UPDATE"||!((A=d==null?void 0:d.cart)!=null&&A.id))return;const{data:p,errors:w}=await E(d.cart.id,h.payload.attributes),I=B(h,(O=p==null?void 0:p.cartAttributesUpdate)==null?void 0:O.cart,w);b(I)},discountCodesUpdateAction:async(d,h)=>{var A,O;if(h.type!=="DISCOUNT_CODES_UPDATE"||!((A=d==null?void 0:d.cart)!=null&&A.id))return;const{data:p,errors:w}=await T(d.cart.id,h.payload.discountCodes),I=B(h,(O=p==null?void 0:p.cartDiscountCodesUpdate)==null?void 0:O.cart,w);b(I)},...r&&{onCartActionEntry:(d,h)=>{rt(h)&&r(d,h)}},...t&&{onCartActionOptimisticUI:Q((d,h)=>t(d,h))},...n&&{onCartActionComplete:(d,h)=>{tt(h)&&n(d,h)}}}});return g.useMemo(()=>[S,b,v],[S,b,v])}function ge(e){var r;return{...e,lines:x(e==null?void 0:e.lines),note:(r=e.note)!=null?r:void 0}}function B(e,r,t){return t?{type:"ERROR",payload:{errors:t,cartActionEvent:e}}:r?{type:"RESOLVE",payload:{cart:ge(r),rawCartResult:r,cartActionEvent:e}}:{type:"CART_COMPLETED",payload:{cartActionEvent:e}}}function rt(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 tt(e){return e.type==="RESOLVE"||e.type==="ERROR"||e.type==="CART_COMPLETED"}var nt="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/CartProvider.tsx";const Ye=g.createContext(null);function ie(){const e=g.useContext(Ye);if(!e)throw new Error("Expected a Cart Context, but no Cart Context was found");return e}function at({children:e,numCartLines:r,onCreate:t,onLineAdd:n,onLineRemove:u,onLineUpdate:a,onNoteUpdate:o,onBuyerIdentityUpdate:i,onAttributesUpdate:l,onDiscountCodesUpdate:s,onCreateComplete:m,onLineAddComplete:c,onLineRemoveComplete:_,onLineUpdateComplete:y,onNoteUpdateComplete:E,onBuyerIdentityUpdateComplete:T,onAttributesUpdateComplete:f,onDiscountCodesUpdateComplete:S,data:b,cartFragment:v=st,customerAccessToken:d,countryCode:h="US"}){var fr,mr,yr,hr,_r,gr,pr;h&&(h=h.toUpperCase());const[p,w]=g.useState(h),[I,A]=g.useState(d),O=g.useRef(!1);(p!==h||I!==d)&&(w(h),A(d),O.current=!1);const[M,P]=et({numCartLines:r,data:b,cartFragment:v,countryCode:h,onCartActionEntry(N,R){try{switch(R.type){case"CART_CREATE":return t==null?void 0:t();case"CARTLINE_ADD":return n==null?void 0:n();case"CARTLINE_REMOVE":return u==null?void 0:u();case"CARTLINE_UPDATE":return a==null?void 0:a();case"NOTE_UPDATE":return o==null?void 0:o();case"BUYER_IDENTITY_UPDATE":return i==null?void 0:i();case"CART_ATTRIBUTES_UPDATE":return l==null?void 0:l();case"DISCOUNT_CODES_UPDATE":return s==null?void 0:s()}}catch(V){console.error("Cart entry action failed",V)}},onCartActionOptimisticUI(N,R){var V,H,te,ne;if(!(N!=null&&N.cart))return{cart:void 0};switch(R.type){case"CARTLINE_REMOVE":return{...N,lastValidCart:N.cart,cart:{...N.cart,lines:(H=(V=N==null?void 0:N.cart)==null?void 0:V.lines)==null?void 0:H.filter(U=>(U==null?void 0:U.id)&&!R.payload.lines.includes(U==null?void 0:U.id))}};case"CARTLINE_UPDATE":return{...N,lastValidCart:N.cart,cart:{...N.cart,lines:(ne=(te=N==null?void 0:N.cart)==null?void 0:te.lines)==null?void 0:ne.map(U=>{const K=R.payload.lines.find(({id:ce})=>ce===(U==null?void 0:U.id));return K&&K.quantity?{...U,quantity:K.quantity}:U})}}}return{cart:N.cart?{...N.cart}:void 0}},onCartActionComplete(N,R){const V=R.payload.cartActionEvent;try{switch(R.type){case"RESOLVE":switch(V.type){case"CART_CREATE":return m==null?void 0:m();case"CARTLINE_ADD":return c==null?void 0:c();case"CARTLINE_REMOVE":return _==null?void 0:_();case"CARTLINE_UPDATE":return y==null?void 0:y();case"NOTE_UPDATE":return E==null?void 0:E();case"BUYER_IDENTITY_UPDATE":return ut(N,V)&&(O.current=!0),T==null?void 0:T();case"CART_ATTRIBUTES_UPDATE":return f==null?void 0:f();case"DISCOUNT_CODES_UPDATE":return S==null?void 0:S()}}}catch(H){console.error("onCartActionComplete failed",H)}}}),F=g.useRef(!1),W=M.matches("cartCompleted"),z=(M.value==="idle"||M.value==="error"||M.value==="cartCompleted")&&h!==((yr=(mr=(fr=M==null?void 0:M.context)==null?void 0:fr.cart)==null?void 0:mr.buyerIdentity)==null?void 0:yr.countryCode)&&!M.context.errors,q=g.useRef(!1);g.useEffect(()=>{if(!F.current&&!q.current){if(!b&&pe("localStorage")){q.current=!0;try{const N=window.localStorage.getItem(_e);N&&P({type:"CART_FETCH",payload:{cartId:N}})}catch(N){console.warn("error fetching cartId"),console.warn(N)}}F.current=!0}},[b,F,P]),g.useEffect(()=>{!z||O.current||P({type:"BUYER_IDENTITY_UPDATE",payload:{buyerIdentity:{countryCode:h,customerAccessToken:d}}})},[h,d,z,O,P]);const L=g.useCallback(N=>{if(!F.current)return console.warn("Cart isn't ready yet");P(N)},[P]);g.useEffect(()=>{var N,R,V;if(((R=(N=M==null?void 0:M.context)==null?void 0:N.cart)==null?void 0:R.id)&&pe("localStorage"))try{window.localStorage.setItem(_e,(V=M.context.cart)==null?void 0:V.id)}catch(H){console.warn("Failed to save cartId to localStorage",H)}},[(_r=(hr=M==null?void 0:M.context)==null?void 0:hr.cart)==null?void 0:_r.id]),g.useEffect(()=>{if(W&&pe("localStorage"))try{window.localStorage.removeItem(_e)}catch(N){console.warn("Failed to delete cartId from localStorage",N)}},[W]);const G=g.useCallback(N=>{var R,V;h&&!((R=N.buyerIdentity)!=null&&R.countryCode)&&(N.buyerIdentity==null&&(N.buyerIdentity={}),N.buyerIdentity.countryCode=h),d&&!((V=N.buyerIdentity)!=null&&V.customerAccessToken)&&(N.buyerIdentity==null&&(N.buyerIdentity={}),N.buyerIdentity.customerAccessToken=d),L({type:"CART_CREATE",payload:N})},[h,d,L]),k=ot(M),se=g.useMemo(()=>{var N,R,V,H,te,ne;return{...(R=(N=k==null?void 0:k.context)==null?void 0:N.cart)!=null?R:{lines:[],attributes:[]},status:it(k.value),error:(V=k==null?void 0:k.context)==null?void 0:V.errors,totalQuantity:(ne=(te=(H=k==null?void 0:k.context)==null?void 0:H.cart)==null?void 0:te.totalQuantity)!=null?ne:0,cartCreate:G,linesAdd(U){var K,ce;(ce=(K=k==null?void 0:k.context)==null?void 0:K.cart)!=null&&ce.id?L({type:"CARTLINE_ADD",payload:{lines:U}}):G({lines:U})},linesRemove(U){L({type:"CARTLINE_REMOVE",payload:{lines:U}})},linesUpdate(U){L({type:"CARTLINE_UPDATE",payload:{lines:U}})},noteUpdate(U){L({type:"NOTE_UPDATE",payload:{note:U}})},buyerIdentityUpdate(U){L({type:"BUYER_IDENTITY_UPDATE",payload:{buyerIdentity:U}})},cartAttributesUpdate(U){L({type:"CART_ATTRIBUTES_UPDATE",payload:{attributes:U}})},discountCodesUpdate(U){L({type:"DISCOUNT_CODES_UPDATE",payload:{discountCodes:U}})},cartFragment:v}},[G,(gr=k==null?void 0:k.context)==null?void 0:gr.cart,(pr=k==null?void 0:k.context)==null?void 0:pr.errors,k.value,v,L]);return C.default.createElement(Ye.Provider,{value:se,__self:this,__source:{fileName:nt,lineNumber:425,columnNumber:5}},e)}function it(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 ot(e){const[r,t]=g.useTransition(),[n,u]=g.useState(e),a=g.useRef(!1);r&&(a.current=!0);const o=g.useRef(!1);return!r&&a.current&&(o.current=!0),g.useEffect(()=>{t(()=>{o.current||u(e)})},[e]),o.current?e:n}function pe(e){let r;try{r=window[e];const t="__storage_test__";return r.setItem(t,t),r.removeItem(t),!0}catch(t){return t instanceof DOMException&&(t.code===22||t.code===1014||t.name==="QuotaExceededError"||t.name==="NS_ERROR_DOM_QUOTA_REACHED")&&r&&r.length!==0}}function ut(e,r){var t,n;return r.payload.buyerIdentity.countryCode&&((n=(t=e.cart)==null?void 0:t.buyerIdentity)==null?void 0:n.countryCode)!==r.payload.buyerIdentity.countryCode}const st=`
|
|
140
|
-
fragment CartFragment on Cart {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
176
|
+
${e}
|
|
177
|
+
`,Br=`
|
|
178
|
+
fragment CartFragment on Cart {
|
|
179
|
+
id
|
|
180
|
+
checkoutUrl
|
|
181
|
+
totalQuantity
|
|
182
|
+
buyerIdentity {
|
|
183
|
+
countryCode
|
|
184
|
+
customer {
|
|
185
|
+
id
|
|
186
|
+
email
|
|
187
|
+
firstName
|
|
188
|
+
lastName
|
|
189
|
+
displayName
|
|
190
|
+
}
|
|
148
191
|
email
|
|
149
|
-
|
|
150
|
-
lastName
|
|
151
|
-
displayName
|
|
192
|
+
phone
|
|
152
193
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
attributes {
|
|
162
|
-
key
|
|
163
|
-
value
|
|
164
|
-
}
|
|
165
|
-
cost {
|
|
166
|
-
totalAmount {
|
|
167
|
-
amount
|
|
168
|
-
currencyCode
|
|
169
|
-
}
|
|
170
|
-
compareAtAmountPerQuantity {
|
|
171
|
-
amount
|
|
172
|
-
currencyCode
|
|
194
|
+
lines(first: $numCartLines) {
|
|
195
|
+
edges {
|
|
196
|
+
node {
|
|
197
|
+
id
|
|
198
|
+
quantity
|
|
199
|
+
attributes {
|
|
200
|
+
key
|
|
201
|
+
value
|
|
173
202
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
availableForSale
|
|
179
|
-
compareAtPriceV2 {
|
|
180
|
-
...MoneyFragment
|
|
181
|
-
}
|
|
182
|
-
priceV2 {
|
|
183
|
-
...MoneyFragment
|
|
203
|
+
cost {
|
|
204
|
+
totalAmount {
|
|
205
|
+
amount
|
|
206
|
+
currencyCode
|
|
184
207
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
...ImageFragment
|
|
208
|
+
compareAtAmountPerQuantity {
|
|
209
|
+
amount
|
|
210
|
+
currencyCode
|
|
189
211
|
}
|
|
190
|
-
|
|
191
|
-
|
|
212
|
+
}
|
|
213
|
+
merchandise {
|
|
214
|
+
... on ProductVariant {
|
|
215
|
+
id
|
|
216
|
+
availableForSale
|
|
217
|
+
compareAtPrice {
|
|
218
|
+
...MoneyFragment
|
|
219
|
+
}
|
|
220
|
+
# @deprecated remove in next major
|
|
221
|
+
compareAtPriceV2 {
|
|
222
|
+
...MoneyFragment
|
|
223
|
+
}
|
|
224
|
+
price {
|
|
225
|
+
...MoneyFragment
|
|
226
|
+
}
|
|
227
|
+
# @deprecated remove in next major
|
|
228
|
+
priceV2 {
|
|
229
|
+
...MoneyFragment
|
|
230
|
+
}
|
|
231
|
+
requiresShipping
|
|
192
232
|
title
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
233
|
+
image {
|
|
234
|
+
...ImageFragment
|
|
235
|
+
}
|
|
236
|
+
product {
|
|
237
|
+
handle
|
|
238
|
+
title
|
|
239
|
+
id
|
|
240
|
+
}
|
|
241
|
+
selectedOptions {
|
|
242
|
+
name
|
|
243
|
+
value
|
|
244
|
+
}
|
|
197
245
|
}
|
|
198
246
|
}
|
|
199
247
|
}
|
|
200
248
|
}
|
|
201
249
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
250
|
+
cost {
|
|
251
|
+
subtotalAmount {
|
|
252
|
+
...MoneyFragment
|
|
253
|
+
}
|
|
254
|
+
totalAmount {
|
|
255
|
+
...MoneyFragment
|
|
256
|
+
}
|
|
257
|
+
totalDutyAmount {
|
|
258
|
+
...MoneyFragment
|
|
259
|
+
}
|
|
260
|
+
totalTaxAmount {
|
|
261
|
+
...MoneyFragment
|
|
262
|
+
}
|
|
209
263
|
}
|
|
210
|
-
|
|
211
|
-
|
|
264
|
+
note
|
|
265
|
+
attributes {
|
|
266
|
+
key
|
|
267
|
+
value
|
|
212
268
|
}
|
|
213
|
-
|
|
214
|
-
|
|
269
|
+
discountCodes {
|
|
270
|
+
code
|
|
215
271
|
}
|
|
216
272
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
273
|
+
|
|
274
|
+
fragment MoneyFragment on MoneyV2 {
|
|
275
|
+
currencyCode
|
|
276
|
+
amount
|
|
221
277
|
}
|
|
222
|
-
|
|
223
|
-
|
|
278
|
+
fragment ImageFragment on Image {
|
|
279
|
+
id
|
|
280
|
+
url
|
|
281
|
+
altText
|
|
282
|
+
width
|
|
283
|
+
height
|
|
224
284
|
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
fragment MoneyFragment on MoneyV2 {
|
|
228
|
-
currencyCode
|
|
229
|
-
amount
|
|
230
|
-
}
|
|
231
|
-
fragment ImageFragment on Image {
|
|
232
|
-
id
|
|
233
|
-
url
|
|
234
|
-
altText
|
|
235
|
-
width
|
|
236
|
-
height
|
|
237
|
-
}
|
|
238
|
-
`;var ct="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ProductProvider.tsx";const Ge=g.createContext(null);function lt({children:e,data:r,initialVariantId:t}){const n=g.useMemo(()=>{var f;return x((f=r.variants)!=null?f:{})},[r.variants]);if(!ft(n))throw new Error("<ProductProvider/> requires 'product.variants.nodes' or 'product.variants.edges'");const u=g.useMemo(()=>dt(n),[n]),[a,o]=g.useState(()=>Ke(t,n)),[i,l]=g.useState(()=>Qe(a));g.useEffect(()=>{const f=Ke(t,n);o(f),l(Qe(f))},[t,n]);const s=g.useCallback((f,S)=>{l(b=>{const v={...b,[f]:S};return o(ze(n,v)),v})},[l,n]),m=g.useCallback((f,S)=>{var v;const b=ze(n,{...i,[f]:S});return(v=b==null?void 0:b.availableForSale)!=null?v:!0},[i,n]),c=g.useMemo(()=>{var f;return x((f=r.sellingPlanGroups)!=null?f:{}).map(S=>{var b;return{...S,sellingPlans:x((b=S==null?void 0:S.sellingPlans)!=null?b:{})}})},[r.sellingPlanGroups]),[_,y]=g.useState(void 0),E=g.useMemo(()=>{var f,S;if(!(!a||!_)){if(!((f=a.sellingPlanAllocations)!=null&&f.nodes)&&!((S=a.sellingPlanAllocations)!=null&&S.edges))throw new Error("<ProductProvider/>: You must include 'sellingPlanAllocations.nodes' or 'sellingPlanAllocations.edges' in your variants in order to calculate selectedSellingPlanAllocation");return x(a.sellingPlanAllocations).find(b=>{var v;return((v=b==null?void 0:b.sellingPlan)==null?void 0:v.id)===_.id})}},[a,_]),T=g.useMemo(()=>({variants:n,variantsConnection:r.variants,options:u,selectedVariant:a,setSelectedVariant:o,selectedOptions:i,setSelectedOption:s,setSelectedOptions:l,isOptionInStock:m,selectedSellingPlan:_,setSelectedSellingPlan:y,selectedSellingPlanAllocation:E,sellingPlanGroups:c,sellingPlanGroupsConnection:r.sellingPlanGroups}),[m,u,r.sellingPlanGroups,r.variants,i,_,E,a,c,s,n]);return C.default.createElement(Ge.Provider,{value:T,__self:this,__source:{fileName:ct,lineNumber:201,columnNumber:5}},e)}function Ze(){const e=g.useContext(Ge);if(!e)throw new Error("'useProduct' must be a child of <ProductProvider />");return e}function ze(e,r){var t,n;if(!(!e.length||((n=(t=e==null?void 0:e[0])==null?void 0:t.selectedOptions)==null?void 0:n.length)!==Object.keys(r).length))return e==null?void 0:e.find(u=>Object.entries(r).every(([a,o])=>{var i;return(i=u==null?void 0:u.selectedOptions)==null?void 0:i.some(l=>(l==null?void 0:l.name)===a&&(l==null?void 0:l.value)===o)}))}function dt(e){const r=e.reduce((t,n)=>{var u;if(!n.selectedOptions)throw new Error("'getOptions' requires 'variant.selectedOptions'");return(u=n==null?void 0:n.selectedOptions)==null||u.forEach(a=>{var o,i,l,s;t[(o=a==null?void 0:a.name)!=null?o:""]=t[(i=a==null?void 0:a.name)!=null?i:""]||new Set,t[(l=a==null?void 0:a.name)!=null?l:""].add((s=a==null?void 0:a.value)!=null?s:"")}),t},{});return Object.keys(r).map(t=>({name:t,values:Array.from(r[t])}))}function Ke(e,r){if(e){const t=r.find(n=>(n==null?void 0:n.id)===e);return t||console.warn("<ProductProvider/> received a 'initialVariantId' prop, but could not actually find a variant with that ID"),t}if(e===null)return null;if(e===void 0)return r.find(t=>t==null?void 0:t.availableForSale)||r[0]}function Qe(e){return e!=null&&e.selectedOptions?e.selectedOptions.reduce((r,t)=>{var n,u;return r[(n=t==null?void 0:t.name)!=null?n:""]=(u=t==null?void 0:t.value)!=null?u:"",r},{}):{}}function ft(e){return!(!e||!Array.isArray(e))}var mt="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/BaseButton.tsx";function Ee(e){const{as:r,onClick:t,defaultOnClick:n,children:u,buttonRef:a,...o}=e,i=g.useCallback(s=>{if(t){const m=t(s);if(typeof m=="boolean"&&m===!1||(s==null?void 0:s.defaultPrevented))return}n==null||n(s)},[n,t]),l=r||"button";return C.default.createElement(l,{ref:a,onClick:i,...o,__self:this,__source:{fileName:mt,lineNumber:59,columnNumber:5}},u)}var Je="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/AddToCartButton.tsx";function yt(e){var S;const[r,t]=g.useState(!1),{variantId:n,quantity:u=1,attributes:a,sellingPlanId:o,onClick:i,children:l,accessibleAddingToCartLabel:s,...m}=e,{status:c,linesAdd:_}=ie(),{selectedVariant:y}=Ze(),E=(S=n!=null?n:y==null?void 0:y.id)!=null?S:"",T=n===null||E===""||y===null||r||m.disabled;g.useEffect(()=>{r&&c==="idle"&&t(!1)},[c,r]);const f=g.useCallback(()=>{t(!0),_([{quantity:u,merchandiseId:E||"",attributes:a,sellingPlanId:o}])},[_,u,E,a,o]);return C.default.createElement(C.default.Fragment,null,C.default.createElement(Ee,{...m,disabled:T,onClick:i,defaultOnClick:f,__self:this,__source:{fileName:Je,lineNumber:71,columnNumber:7}},l),s?C.default.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",__self:this,__source:{fileName:Je,lineNumber:80,columnNumber:9}},r?s:null):null)}var ht="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/BuyNowButton.tsx";function _t(e){const{cartCreate:r,checkoutUrl:t}=ie(),[n,u]=g.useState(!1),{quantity:a,variantId:o,onClick:i,attributes:l,children:s,...m}=e;g.useEffect(()=>{t&&(window.location.href=t)},[t]);const c=g.useCallback(()=>{u(!0),r({lines:[{quantity:a!=null?a:1,merchandiseId:o,attributes:l}]})},[r,a,o,l]);return C.default.createElement(Ee,{disabled:n!=null?n:m.disabled,...m,onClick:i,defaultOnClick:c,__self:this,__source:{fileName:ht,lineNumber:53,columnNumber:5}},s)}var gt="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/CartCheckoutButton.tsx";function pt(e){const[r,t]=g.useState(!1),{status:n,checkoutUrl:u}=ie(),{children:a,...o}=e;return g.useEffect(()=>{r&&u&&n==="idle"&&(window.location.href=u)},[r,n,u]),C.default.createElement(Ee,{...o,disabled:r||o.disabled,onClick:()=>t(!0),__self:this,__source:{fileName:gt,lineNumber:28,columnNumber:5}},a)}const Et={DateTime:"string",Decimal:"string",HTML:"string",URL:"string",Color:"string",UnsignedInt64:"string"};var St="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ExternalVideo.tsx";function Xe(e){var m,c;const{data:r,options:t,id:n=r.id,frameBorder:u="0",allow:a="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:o=!0,loading:i="lazy",...l}=e;if(!r.embedUrl)throw new Error("<ExternalVideo/> requires the 'embedUrl' property");let s=r.embedUrl;if(t){const _=new URL(r.embedUrl);for(const y of Object.keys(t))_.searchParams.set(y,t[y]);s=_.toString()}return C.default.createElement("iframe",{...l,id:n!=null?n:r.embedUrl,title:(c=(m=r.alt)!=null?m:r.id)!=null?c:"external video",frameBorder:u,allow:a,allowFullScreen:o,src:s,loading:i,__self:this,__source:{fileName:St,lineNumber:56,columnNumber:5}})}const bt=["cdn.shopify.com","cdn.shopifycdn.net","shopify-assets.shopifycdn.com","shopify-assets.shopifycdn.net"],vt=["spin.dev"],Ct=[...bt,...vt],re=[352,832,1200,1920,2560];function er({src:e,width:r,height:t,crop:n,scale:u}){const a=new URL(e),o=u!=null?u:1;if(r){let i;typeof r=="string"?i=(re[0]*o).toString():i=(Number(r)*o).toString(),a.searchParams.append("width",i)}return t&&typeof t=="number"&&a.searchParams.append("height",(t*o).toString()),n&&a.searchParams.append("crop",n),a.toString()}function rr(e){const r=new URL(e.src);return!Ct.some(n=>r.hostname.endsWith(n))||!e.width&&!e.height&&!e.crop&&!e.scale?e.src:er(e)}function Tt({data:e,loaderOptions:r,elementProps:t}){var u,a,o,i,l,s;let n=null;return(e==null?void 0:e.width)&&(e==null?void 0:e.height)&&(n=(e==null?void 0:e.width)/(e==null?void 0:e.height)),(r==null?void 0:r.width)||(r==null?void 0:r.height)?{width:(u=r==null?void 0:r.width)!=null?u:n&&typeof r.height=="number"?Math.round(n*r.height):null,height:(a=r==null?void 0:r.height)!=null?a:n&&typeof r.width=="number"?Math.round(n*r.width):null}:(t==null?void 0:t.width)||(t==null?void 0:t.height)?{width:(o=t==null?void 0:t.width)!=null?o:n&&typeof t.height=="number"?Math.round(n*t.height):null,height:(i=t==null?void 0:t.height)!=null?i:n&&typeof t.width=="number"?Math.round(n*t.width):null}:(e==null?void 0:e.width)||(e==null?void 0:e.height)?{width:(l=e==null?void 0:e.width)!=null?l:null,height:(s=e==null?void 0:e.height)!=null?s:null}:{width:null,height:null}}var Nt="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/Image.tsx";function oe({data:e,width:r,height:t,loading:n,loader:u=rr,loaderOptions:a,widths:o,decoding:i="async",...l}){var E,T,f,S,b,v;if(!e.url){const d=`<Image/>: the 'data' prop requires the 'url' property. Image: ${(E=e.id)!=null?E:"no ID provided"}`;return console.error(d),null}const{width:s,height:m}=Tt({data:e,loaderOptions:a,elementProps:{width:r,height:t}});let c=e.url;if(u&&(c=u({...a,src:e.url,width:s,height:m}),typeof c!="string"||!c))throw new Error(`<Image/>: 'loader' did not return a valid string. Image: ${(T=e.id)!=null?T:e.url}`);const _=r&&s&&r<s?r:s,y=(f=l.srcSet)!=null?f:At({...a,widths:o,src:e.url,width:_,height:m,loader:u});return Ce.createElement("img",{id:(S=e.id)!=null?S:"",alt:(v=(b=e.altText)!=null?b:l.alt)!=null?v:"",loading:n!=null?n:"lazy",...l,src:c,width:s!=null?s:void 0,height:m!=null?m:void 0,srcSet:y,decoding:i,__self:this,__source:{fileName:Nt,lineNumber:150,columnNumber:5}})}function At({src:e,width:r,crop:t,scale:n,widths:u,loader:a,height:o}){const i=u&&Array.isArray(u);if(i&&u.some(c=>isNaN(c)))throw new Error(`<Image/>: the 'widths' must be an array of numbers. Image: ${e}`);let l=1;r&&o&&(l=Number(o)/Number(r));let s=i?u:re;!i&&r&&r<re[re.length-1]&&(s=re.filter(c=>c<=r));const m=a||er;return s.map(c=>`${m({src:e,width:c,height:t?Number(c)*l:void 0,crop:t,scale:n})} ${c}w`).join(", ")}var tr="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/Video.tsx";function Se(e){var s,m;const{data:r,previewImageOptions:t,id:n=r.id,playsInline:u=!0,controls:a=!0,sourceProps:o={},...i}=e,l=rr({src:(m=(s=r.previewImage)==null?void 0:s.url)!=null?m:"",...t});if(!r.sources)throw new Error("<Video/> requires a 'data.sources' array");return C.default.createElement("video",{...i,id:n,playsInline:u,controls:a,poster:l,__self:this,__source:{fileName:tr,lineNumber:42,columnNumber:5}},r.sources.map(c=>{if(!((c==null?void 0:c.url)&&(c==null?void 0:c.mimeType)))throw new Error("<Video/> needs 'source.url' and 'source.mimeType'");return C.default.createElement("source",{...o,key:c.url,src:c.url,type:c.mimeType,__self:this,__source:{fileName:tr,lineNumber:54,columnNumber:11}})}))}const nr={};function wt(e,r){const t=nr[e];if(t)return t;const n=new Promise((u,a)=>{const o=document.createElement("script");r!=null&&r.module?o.type="module":o.type="text/javascript",o.src=e,o.onload=()=>{u(!0)},o.onerror=()=>{a(!1)},(r==null?void 0:r.in)==="head"?document.head.appendChild(o):document.body.appendChild(o)});return nr[e]=n,n}function ar(e,r){const[t,n]=g.useState("loading"),u=JSON.stringify(r);return g.useEffect(()=>{async function a(){try{n("loading"),await wt(e,r),n("done")}catch{n("error")}}a()},[e,u,r]),t}var It="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ModelViewer.tsx";function ir(e){var s,m,c,_,y,E,T,f,S,b,v;const[r,t]=g.useState(void 0),n=g.useCallback(d=>{t(d)},[]),{data:u,children:a,className:o,...i}=e,l=ar("https://unpkg.com/@google/model-viewer@v1.12.1/dist/model-viewer.min.js",{module:!0});return g.useEffect(()=>{if(!!r)return i.onError&&r.addEventListener("error",i.onError),i.onLoad&&r.addEventListener("load",i.onLoad),i.onPreload&&r.addEventListener("preload",i.onPreload),i.onModelVisibility&&r.addEventListener("model-visibility",i.onModelVisibility),i.onProgress&&r.addEventListener("progress",i.onProgress),i.onArStatus&&r.addEventListener("ar-status",i.onArStatus),i.onArTracking&&r.addEventListener("ar-tracking",i.onArTracking),i.onQuickLookButtonTapped&&r.addEventListener("quick-look-button-tapped",i.onQuickLookButtonTapped),i.onCameraChange&&r.addEventListener("camera-change",i.onCameraChange),i.onEnvironmentChange&&r.addEventListener("environment-change",i.onEnvironmentChange),i.onPlay&&r.addEventListener("play",i.onPlay),i.onPause&&r.addEventListener("ar-status",i.onPause),i.onSceneGraphReady&&r.addEventListener("scene-graph-ready",i.onSceneGraphReady),()=>{r!=null&&(i.onError&&r.removeEventListener("error",i.onError),i.onLoad&&r.removeEventListener("load",i.onLoad),i.onPreload&&r.removeEventListener("preload",i.onPreload),i.onModelVisibility&&r.removeEventListener("model-visibility",i.onModelVisibility),i.onProgress&&r.removeEventListener("progress",i.onProgress),i.onArStatus&&r.removeEventListener("ar-status",i.onArStatus),i.onArTracking&&r.removeEventListener("ar-tracking",i.onArTracking),i.onQuickLookButtonTapped&&r.removeEventListener("quick-look-button-tapped",i.onQuickLookButtonTapped),i.onCameraChange&&r.removeEventListener("camera-change",i.onCameraChange),i.onEnvironmentChange&&r.removeEventListener("environment-change",i.onEnvironmentChange),i.onPlay&&r.removeEventListener("play",i.onPlay),i.onPause&&r.removeEventListener("ar-status",i.onPause),i.onSceneGraphReady&&r.removeEventListener("scene-graph-ready",i.onSceneGraphReady))}},[r,i.onArStatus,i.onArTracking,i.onCameraChange,i.onEnvironmentChange,i.onError,i.onLoad,i.onModelVisibility,i.onPause,i.onPlay,i.onPreload,i.onProgress,i.onQuickLookButtonTapped,i.onSceneGraphReady]),l!=="done"?null:(m=(s=u.sources)==null?void 0:s[0])!=null&&m.url?C.default.createElement("model-viewer",{ref:n,...i,className:o,id:(c=i.id)!=null?c:u.id,src:u.sources[0].url,alt:(_=u.alt)!=null?_:null,"camera-controls":(y=i.cameraControls)!=null?y:!0,poster:(T=i.poster||((E=u.previewImage)==null?void 0:E.url))!=null?T:null,autoplay:(f=i.autoplay)!=null?f:!0,loading:i.loading,reveal:i.reveal,ar:i.ar,"ar-modes":i.arModes,"ar-scale":i.arScale,"ar-placement":i.arPlacement,"ios-src":i.iosSrc,"touch-action":i.touchAction,"disable-zoom":i.disableZoom,"orbit-sensitivity":i.orbitSensitivity,"auto-rotate":i.autoRotate,"auto-rotate-delay":i.autoRotateDelay,"rotation-per-second":i.rotationPerSecond,"interaction-policy":i.interactionPolicy,"interaction-prompt":i.interactionPrompt,"interaction-prompt-style":i.interactionPromptStyle,"interaction-prompt-threshold":i.interactionPromptThreshold,"camera-orbit":i.cameraOrbit,"camera-target":i.cameraTarget,"field-of-view":i.fieldOfView,"max-camera-orbit":i.maxCameraOrbit,"min-camera-orbit":i.minCameraOrbit,"max-field-of-view":i.maxFieldOfView,"min-field-of-view":i.minFieldOfView,bounds:i.bounds,"interpolation-decay":(S=i.interpolationDecay)!=null?S:100,"skybox-image":i.skyboxImage,"environment-image":i.environmentImage,exposure:i.exposure,"shadow-intensity":(b=i.shadowIntensity)!=null?b:0,"shadow-softness":(v=i.shadowSoftness)!=null?v:0,"animation-name":i.animationName,"animation-crossfade-duration":i.animationCrossfadeDuration,"variant-name":i.variantName,orientation:i.orientation,scale:i.scale,__self:this,__source:{fileName:It,lineNumber:222,columnNumber:5}},a):(console.error("<ModelViewer/> requires 'data.sources' prop to be an array, with an object that has a property 'url' on it. Rendering 'null'"),null)}var ue="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/MediaFile.tsx";function Ot({data:e,mediaOptions:r,...t}){switch(e.__typename){case"MediaImage":return e.image?C.default.createElement(oe,{...t,...r==null?void 0:r.image,data:e.image,__self:this,__source:{fileName:ue,lineNumber:54,columnNumber:9}}):(console.warn("<MediaFile/>: 'data.image' does not exist for __typename of 'MediaImage'; rendering 'null' by default."),null);case"Video":return C.default.createElement(Se,{...t,...r==null?void 0:r.video,data:e,__self:this,__source:{fileName:ue,lineNumber:63,columnNumber:9}});case"ExternalVideo":return C.default.createElement(Xe,{...t,...r==null?void 0:r.externalVideo,data:e,__self:this,__source:{fileName:ue,lineNumber:68,columnNumber:9}});case"Model3d":return C.default.createElement(ir,{...t,...r==null?void 0:r.modelViewer,data:e,__self:this,__source:{fileName:ue,lineNumber:78,columnNumber:9}});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}}var $="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/Metafield.tsx";function Dt(e){var i,l,s,m,c,_,y,E,T;const{data:r,as:t,...n}=e,{locale:u}=X(),a=g.useMemo(()=>or(r),[r]);if(!a)return console.warn("<Metafield/>: nothing was passed to the data prop 'data'. Rendering 'null'"),null;if(a.value===null||a.value===void 0){const f=`<Metafield/>: No metafield value for metafield ${(i=a.id)!=null?i:a.key}. Rendering 'null'`;return console.warn(f),null}switch(a.type){case"date":{const f=t!=null?t:"time";return C.default.createElement(f,{...n,__self:this,__source:{fileName:$,lineNumber:68,columnNumber:9}},a.value.toLocaleDateString(u))}case"date_time":{const f=t!=null?t:"time";return C.default.createElement(f,{...n,__self:this,__source:{fileName:$,lineNumber:76,columnNumber:9}},a.value.toLocaleString(u))}case"weight":case"dimension":case"volume":{const f=t!=null?t:"span";return C.default.createElement(f,{...n,__self:this,__source:{fileName:$,lineNumber:86,columnNumber:9}},Ut(a.value,u))}case"rating":{const f=t!=null?t:"span";return C.default.createElement(f,{...n,__self:this,__source:{fileName:$,lineNumber:94,columnNumber:9}},a.value.value)}case"single_line_text_field":{const f=t!=null?t:"span";return C.default.createElement(f,{...n,dangerouslySetInnerHTML:{__html:a.value},__self:this,__source:{fileName:$,lineNumber:102,columnNumber:9}})}case"multi_line_text_field":{const f=t!=null?t:"div";return C.default.createElement(f,{...n,dangerouslySetInnerHTML:{__html:a.value.split(`
|
|
239
|
-
`).join("<br/>")},__self:this,__source:{fileName:$,lineNumber:111,columnNumber:9}})}case"url":{const f=new URL(a.value);return C.default.createElement("a",{href:f.href.replace(f.protocol,""),...n,__self:this,__source:{fileName:$,lineNumber:122,columnNumber:9}},a.value)}case"json":{const f=t!=null?t:"span";return C.default.createElement(f,{...n,__self:this,__source:{fileName:$,lineNumber:133,columnNumber:9}},JSON.stringify(a.value))}case"product_reference":case"variant_reference":case"page_reference":{const f=t!=null?t:"span",S=a.reference;return C.default.createElement(f,{...n,__self:this,__source:{fileName:$,lineNumber:144,columnNumber:9}},(s=(l=S==null?void 0:S.title)!=null?l:S==null?void 0:S.id)!=null?s:"")}case"list.single_line_text_field":{const f=t!=null?t:"ul",S=a.references?x(a.references):[];return C.default.createElement(f,{...n,__self:this,__source:{fileName:$,lineNumber:154,columnNumber:9}},S.map((b,v)=>C.default.createElement("li",{key:`${b!=null?b:""}-${v}`,__self:this,__source:{fileName:$,lineNumber:158,columnNumber:13}},b)))}case"file_reference":if(((m=a.reference)==null?void 0:m.__typename)==="MediaImage"){const f=a.reference;return f.image?C.default.createElement(oe,{data:f.image,...n,__self:this,__source:{fileName:$,lineNumber:167,columnNumber:11}}):null}else if(((c=a.reference)==null?void 0:c.__typename)==="GenericFile"){const f=a.reference;return f.previewImage?C.default.createElement("a",{href:(y=(_=a.reference)==null?void 0:_.url)!=null?y:"",...n,__self:this,__source:{fileName:$,lineNumber:172,columnNumber:11}},C.default.createElement(oe,{data:f.previewImage,__self:this,__source:{fileName:$,lineNumber:173,columnNumber:13}})):null}else if(((E=a.reference)==null?void 0:E.__typename)==="Video"){const f=a.reference;return C.default.createElement(Se,{...n,data:f,__self:this,__source:{fileName:$,lineNumber:178,columnNumber:16}})}}const o=t!=null?t:"span";return C.default.createElement(o,{...n,__self:this,__source:{fileName:$,lineNumber:185,columnNumber:5}},(T=a.value)==null?void 0:T.toString())}function or(e){return e?{...e,value:ur(e)}:null}function ur(e){if(!e)return null;if(e.value===null||e.value===void 0)return e.value;switch(e.type){case"boolean":return e.value==="true";case"number_integer":return parseInt(e.value);case"number_decimal":return parseFloat(e.value);case"date":case"date_time":return new Date(e.value);case"json":case"weight":case"dimension":case"volume":case"rating":return be(e.value);case"color":case"single_line_text_field":case"multi_line_text_field":case"product_reference":case"page_reference":case"variant_reference":case"file_reference":case"url":default:return e.value}}function be(e){return String(e).includes("__proto__")?JSON.parse(e,(r,t)=>{if(r!=="__proto__")return t}):JSON.parse(e)}const Lt={mm:"millimeter",cm:"centimeter",m:"meter",in:"inch",ft:"foot",yd:"yard",ml:"milliliter",l:"liter",us_fl_oz:"fluid-ounce",us_gal:"gallon",kg:"kilogram",g:"gram",lb:"pound",oz:"ounce"};function Ut(e,r="en-us",t={}){let n={value:e.value,unit:Lt[e.unit]};return n.unit==null&&(n=kt(e.value,e.unit)),new Intl.NumberFormat(r,{...t,unit:n.unit,style:"unit"}).format(n.value)}function kt(e,r){switch(r){case"cl":return{value:e/1e3,unit:"liter"};case"m3":return{value:e*1e3,unit:"liter"};case"us_pt":return{value:e*.125,unit:"gallon"};case"us_qt":return{value:e*.5,unit:"gallon"};case"us_oz":return{value:e/128,unit:"gallon"};case"imp_pt":return{value:e/6.661,unit:"gallon"};case"imp_qt":return{value:e/3.331,unit:"gallon"};case"imp_gal":return{value:e/1.201,unit:"gallon"};case"imp_fl_oz":return{value:e*.96076,unit:"fluid-ounce"};default:throw new Error(`Unit not supported: ${r}`)}}function Mt(e){var r,t,n,u;if(!e.type)return console.error("metafieldParser(): 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 a=null;try{a=be((r=e.value)!=null?r:"")}catch{console.error("metafieldParser(): attempted to JSON.parse the 'metafield.value' property, but failed. Returning 'null' for 'parsedValue'"),a=null}return{...e,parsedValue:a}}case"date":case"date_time":return{...e,parsedValue:new Date((t=e.value)!=null?t:"")};case"list.date":case"list.date_time":{const a=be((n=e==null?void 0:e.value)!=null?n:"");return{...e,parsedValue:a.map(o=>new Date(o))}}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:x((u=e.references)!=null?u:void 0)};default:{const a=`metafieldParser(): 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(`${a} Returning 'parsedValue' of 'null'`),{...e,parsedValue:null}}}}function sr(e){const{locale:r}=X();if(!r)throw new Error("useMoney(): Unable to get 'locale' from 'useShop()', which means that 'locale' was not passed to '<ShopifyProvider/>'. 'locale' is required for 'useMoney()' to work");const t=parseFloat(e.amount),n=g.useMemo(()=>({style:"currency",currency:e.currencyCode}),[e.currencyCode]),u=Z(r,n),a=Z(r,{...n,currencyDisplay:"name"}),o=Z(r,{...n,currencyDisplay:"narrowSymbol"}),i=Z(r,{...n,minimumFractionDigits:0,maximumFractionDigits:0}),l=Z(r),s=Z(r,{minimumFractionDigits:0,maximumFractionDigits:0}),m=_=>_.type==="currency",c=g.useMemo(()=>({original:()=>e,currencyCode:()=>e.currencyCode,localizedString:()=>u().format(t),parts:()=>u().formatToParts(t),withoutTrailingZeros:()=>t%1===0?i().format(t):u().format(t),withoutTrailingZerosAndCurrency:()=>t%1===0?s().format(t):l().format(t),currencyName:()=>{var _,y;return(y=(_=a().formatToParts(t).find(m))==null?void 0:_.value)!=null?y:e.currencyCode},currencySymbol:()=>{var _,y;return(y=(_=u().formatToParts(t).find(m))==null?void 0:_.value)!=null?y:e.currencyCode},currencyNarrowSymbol:()=>{var _,y;return(y=(_=o().formatToParts(t).find(m))==null?void 0:_.value)!=null?y:""},amount:()=>u().formatToParts(t).filter(_=>["decimal","fraction","group","integer","literal"].includes(_.type)).map(_=>_.value).join("")}),[e,t,a,u,o,l,i,s]);return g.useMemo(()=>new Proxy(c,{get:(_,y)=>{var E;return(E=Reflect.get(_,y))==null?void 0:E.call(null)}}),[c])}function Z(e,r){return g.useMemo(()=>{let t;return()=>t!=null?t:t=new Intl.NumberFormat(e,r)},[e,r])}var Rt="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/Money.tsx";function ve({data:e,as:r,withoutCurrency:t,withoutTrailingZeros:n,measurement:u,measurementSeparator:a="/",...o}){if(!$t(e))throw new Error("<Money/> needs a valid 'data' prop that has 'amount' and 'currencyCode'");const i=sr(e),l=r!=null?r:"div";let s=i.localizedString;return(t||n)&&(t&&!n?s=i.amount:!t&&n?s=i.withoutTrailingZeros:s=i.withoutTrailingZerosAndCurrency),C.default.createElement(l,{...o,__self:this,__source:{fileName:Rt,lineNumber:65,columnNumber:5}},s,u&&u.referenceUnit&&C.default.createElement(C.default.Fragment,null,a,u.referenceUnit))}function $t(e){return typeof e.amount=="string"&&!!e.amount&&typeof e.currencyCode=="string"&&!!e.currencyCode}var cr="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ProductPrice.tsx";function Pt(e){var s,m,c,_,y,E,T,f;const{priceType:r="regular",variantId:t,valueType:n="min",data:u,...a}=e;if(u==null)throw new Error("<ProductPrice/> requires a product as the 'data' prop");let o,i;const l=t&&(m=x((s=u==null?void 0:u.variants)!=null?s:{}).find(S=>(S==null?void 0:S.id)===t))!=null?m:null;if(r==="compareAt")if(t&&l){if(((c=l.compareAtPriceV2)==null?void 0:c.amount)===((_=l.priceV2)==null?void 0:_.amount))return null;o=l.compareAtPriceV2}else n==="max"?o=(y=u==null?void 0:u.compareAtPriceRange)==null?void 0:y.maxVariantPrice:o=(E=u==null?void 0:u.compareAtPriceRange)==null?void 0:E.minVariantPrice;else t&&l?(o=l.priceV2,n==="unit"&&(o=l.unitPrice,i=l.unitPriceMeasurement)):n==="max"?o=(T=u.priceRange)==null?void 0:T.maxVariantPrice:o=(f=u.priceRange)==null?void 0:f.minVariantPrice;return o?i?C.default.createElement(ve,{...a,data:o,measurement:i,__self:this,__source:{fileName:cr,lineNumber:81,columnNumber:7}}):C.default.createElement(ve,{...a,data:o,__self:this,__source:{fileName:cr,lineNumber:85,columnNumber:10}}):null}var lr="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ShopPayButton.tsx";const Vt="https://cdn.shopify.com/shopifycloud/shop-js/v1.0/client.js";function Ft({variantIds:e,className:r,variantIdsAndQuantities:t,width:n}){const{storeDomain:u}=X(),a=ar(Vt);let o;if(e&&t)throw new Error(jt);if(e)o=e.reduce((l,s)=>{const m=dr(s);return m&&l.push(m),l},[]);else if(t)o=t.reduce((l,s)=>{var c;const m=dr(s==null?void 0:s.id);return m&&l.push(`${m}:${(c=s==null?void 0:s.quantity)!=null?c:1}`),l},[]);else throw new Error(xt);const i=n?{"--shop-pay-button-width":n}:void 0;return C.default.createElement("div",{className:r,style:i,__self:this,__source:{fileName:lr,lineNumber:90,columnNumber:5}},a==="done"&&C.default.createElement("shop-pay-button",{"store-url":`https://${u}`,variants:o.join(","),__self:this,__source:{fileName:lr,lineNumber:92,columnNumber:9}}))}function dr(e){if(!!e)return e.split("/").pop()}const xt='You must pass in either "variantIds" or "variantIdsAndQuantities" to ShopPayButton',jt="You must provide either a variantIds or variantIdsAndQuantities prop, but not both in the ShopPayButton component";D.AddToCartButton=yt,D.BuyNowButton=_t,D.CartCheckoutButton=pt,D.CartProvider=at,D.ExternalVideo=Xe,D.Image=oe,D.MediaFile=Ot,D.Metafield=Dt,D.ModelViewer=ir,D.Money=ve,D.ProductPrice=Pt,D.ProductProvider=lt,D.ShopPayButton=Ft,D.ShopifyProvider=Wr,D.Video=Se,D.createStorefrontClient=qr,D.flattenConnection=x,D.metafieldParser=Mt,D.parseMetafield=or,D.parseMetafieldValue=ur,D.storefrontApiCustomScalars=Et,D.useCart=ie,D.useMoney=sr,D.useProduct=Ze,D.useShop=X,Object.defineProperties(D,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
285
|
+
`,J="2022-10",xe=new Set,qr=e=>{xe.has(e)||(console.warn(e),xe.add(e))};function Hr({storeDomain:e,privateStorefrontToken:r,publicStorefrontToken:t,storefrontApiVersion:n,contentType:u}){return n!==J&&qr(`StorefrontClient: The Storefront API version that you're using is different than the version this build of Hydrogen-UI is targeting. You may run into unexpected errors if these versions don't match. Received verion: "${n}"; expected version "${J}"`),{getShopifyDomain(a){var o;return`https://${(o=a==null?void 0:a.storeDomain)!=null?o:e}.myshopify.com`},getStorefrontApiUrl(a){var o,i;return`https://${(o=a==null?void 0:a.storeDomain)!=null?o:e}.myshopify.com/api/${(i=a==null?void 0:a.storefrontApiVersion)!=null?i:n}/graphql.json`},getPrivateTokenHeaders(a){var i,l,s;if(!r&&!(a!=null&&a.privateStorefrontToken))throw new Error("StorefrontClient: You did not pass in a 'privateStorefrontToken' while using 'getPrivateTokenHeaders()'");return{"content-type":((i=a==null?void 0:a.contentType)!=null?i:u)==="graphql"?"application/graphql":"application/json","X-SDK-Variant":"hydrogen-ui","X-SDK-Variant-Source":"react","X-SDK-Version":n,"Shopify-Storefront-Private-Token":(s=(l=a==null?void 0:a.privateStorefrontToken)!=null?l:r)!=null?s:"",...a!=null&&a.buyerIp?{"Shopify-Storefront-Buyer-IP":a.buyerIp}:{}}},getPublicTokenHeaders(a){var i,l,s,m;if(!t&&!(a!=null&&a.publicStorefrontToken))throw new Error("StorefrontClient: You did not pass in a 'publicStorefrontToken' while using 'getPublicTokenHeaders()'");const o=(l=(i=a==null?void 0:a.contentType)!=null?i:u)!=null?l:"json";return je(o,n,(m=(s=a==null?void 0:a.publicStorefrontToken)!=null?s:t)!=null?m:"")}}}function je(e,r,t){return{"content-type":e==="graphql"?"application/graphql":"application/json","X-SDK-Variant":"hydrogen-ui","X-SDK-Variant-Source":"react","X-SDK-Version":r,"X-Shopify-Storefront-Access-Token":t}}var Wr="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ShopifyProvider.tsx";const Be=g.createContext({storeDomain:"test",storefrontToken:"abc123",storefrontApiVersion:J,country:{isoCode:"US"},language:{isoCode:"EN"},locale:"EN-US",getStorefrontApiUrl(){return""},getPublicTokenHeaders(){return{}},getShopifyDomain(){return""}});function Yr({children:e,shopifyConfig:r}){if(!r)throw new Error("The 'shopifyConfig' prop must be passed to '<ShopifyProvider/>'");r.storefrontApiVersion!==J&&console.warn(`<ShopifyProvider/>: This version of Hydrogen-UI is built for Shopify's Storefront API version ${J}, but it looks like you're using version ${r.storefrontApiVersion}. There may be issues or bugs if you use a mismatched version of Hydrogen-UI and the Storefront API.`);const t=g.useMemo(()=>{const n=r.storeDomain.replace(/^https?:\/\//,"");n.includes(".myshopify.com");function u(a){var i;let o=(i=a==null?void 0:a.storeDomain)!=null?i:n;return o=o.replace(".myshopify.com",""),`https://${o}.myshopify.com`}return{...r,storeDomain:n,getPublicTokenHeaders(a){var o;return je(a.contentType,r.storefrontApiVersion,(o=a.storefrontToken)!=null?o:r.storefrontToken)},getShopifyDomain:u,getStorefrontApiUrl(a){var o,i,l;return(o=a==null?void 0:a.storeDomain)!=null&&o.includes(".myshopify.com"),`${u({storeDomain:(i=a==null?void 0:a.storeDomain)!=null?i:n})}/api/${(l=a==null?void 0:a.storefrontApiVersion)!=null?l:r.storefrontApiVersion}/graphql.json`}}},[r]);return C.default.createElement(Be.Provider,{value:t,__self:this,__source:{fileName:Wr,lineNumber:99,columnNumber:5}},e)}function X(){const e=g.useContext(Be);if(!e)throw new Error("'useShop()' must be a descendent of <ShopifyProvider/>");return e}const _e="shopifyCartId",Gr="Shopify-Storefront-Id",Zr="Shopify-Storefront-Y",zr="Shopify-Storefront-S",qe="_shopify_y",He="_shopify_s";var Kr=new Set(["domain","path","max-age","expires","samesite","secure","httponly"]);function Qr(e){let r={},t,n,u=0,a=e.split(/;\s*/g),o,i;for(;u<a.length;u++)if(n=a[u],t=n.indexOf("="),~t){if(o=n.substring(0,t++).trim(),i=n.substring(t).trim(),i[0]==='"'&&(i=i.substring(1,i.length-1)),~i.indexOf("%"))try{i=decodeURIComponent(i)}catch{}Kr.has(n=o.toLowerCase())?n==="expires"?r.expires=new Date(i):n==="max-age"?r.maxage=+i:r[n]=i:r[o]=i}else(o=n.trim().toLowerCase())&&(o==="httponly"||o==="secure")&&(r[o]=!0);return r}function Jr(){const{storefrontId:e,getPublicTokenHeaders:r,getStorefrontApiUrl:t}=X();return g.useCallback(({query:n,variables:u})=>{const a=r({contentType:"json"});e&&(a[Gr]=e);const o=Qr(document.cookie);return o[qe]&&o[He]&&(a[Zr]=o[qe],a[zr]=o[He]),fetch(t(),{method:"POST",headers:a,body:JSON.stringify({query:n.toString(),variables:u})}).then(i=>i.json()).catch(i=>({data:void 0,errors:i.toString()}))},[r,e,t])}function Xr({numCartLines:e,cartFragment:r,countryCode:t="US"}){const n=Jr(),u=g.useCallback(y=>n({query:jr(r),variables:{id:y,numCartLines:e,country:t}}),[n,r,e,t]),a=g.useCallback(y=>n({query:Mr(r),variables:{input:y,numCartLines:e,country:t}}),[r,t,n,e]),o=g.useCallback((y,E)=>n({query:kr(r),variables:{cartId:y,lines:E,numCartLines:e,country:t}}),[r,t,n,e]),i=g.useCallback((y,E)=>n({query:Pr(r),variables:{cartId:y,lines:E,numCartLines:e,country:t}}),[r,t,n,e]),l=g.useCallback((y,E)=>n({query:Rr(r),variables:{cartId:y,lines:E,numCartLines:e,country:t}}),[r,t,n,e]),s=g.useCallback((y,E)=>n({query:$r(r),variables:{cartId:y,note:E,numCartLines:e,country:t}}),[n,r,e,t]),m=g.useCallback((y,E)=>n({query:Vr(r),variables:{cartId:y,buyerIdentity:E,numCartLines:e,country:t}}),[r,t,n,e]),c=g.useCallback((y,E)=>n({query:Fr(r),variables:{cartId:y,attributes:E,numCartLines:e,country:t}}),[r,t,n,e]),_=g.useCallback((y,E)=>n({query:xr(r),variables:{cartId:y,discountCodes:E,numCartLines:e,country:t}}),[r,t,n,e]);return g.useMemo(()=>({cartFetch:u,cartCreate:a,cartLineAdd:o,cartLineUpdate:i,cartLineRemove:l,noteUpdate:s,buyerIdentityUpdate:m,cartAttributesUpdate:c,discountCodesUpdate:_,cartFragment:r}),[u,a,o,i,l,s,m,c,_,r])}function j(e,r){return{entry:[...(r==null?void 0:r.entryActions)||[],Z({lastValidCart:t=>t==null?void 0:t.cart}),"onCartActionEntry","onCartActionOptimisticUI",e],on:{RESOLVE:{target:(r==null?void 0:r.resolveTarget)||"idle",actions:[Z({prevCart:t=>t==null?void 0:t.lastValidCart,cart:(t,n)=>{var u;return(u=n==null?void 0:n.payload)==null?void 0:u.cart},rawCartResult:(t,n)=>{var u;return(u=n==null?void 0:n.payload)==null?void 0:u.rawCartResult},errors:t=>{}})]},ERROR:{target:(r==null?void 0:r.errorTarget)||"error",actions:[Z({prevCart:t=>t==null?void 0:t.lastValidCart,cart:t=>t==null?void 0:t.lastValidCart,errors:(t,n)=>{var u;return(u=n==null?void 0:n.payload)==null?void 0:u.errors}})]},CART_COMPLETED:{target:"cartCompleted",actions:Z({prevCart:t=>{},cart:t=>{},lastValidCart:t=>{},rawCartResult:t=>{},errors:t=>{}})}},exit:["onCartActionComplete",...(r==null?void 0:r.exitActions)||[]]}}const ee={CART_FETCH:{target:"cartFetching"},CART_CREATE:{target:"cartCreating"},CART_SET:{target:"idle",actions:[Z({rawCartResult:(e,r)=>r.payload.cart,cart:(e,r)=>ge(r.payload.cart)})]}},We={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 et(e){return De({id:"Cart",initial:e?"idle":"uninitialized",context:{cart:e&&ge(e)},states:{uninitialized:{on:ee},cartCompleted:{on:ee},initializationError:{on:ee},idle:{on:{...ee,...We}},error:{on:{...ee,...We}},cartFetching:j("cartFetchAction",{errorTarget:"initializationError"}),cartCreating:j("cartCreateAction",{errorTarget:"initializationError"}),cartLineRemoving:j("cartLineRemoveAction"),cartLineUpdating:j("cartLineUpdateAction"),cartLineAdding:j("cartLineAddAction"),noteUpdating:j("noteUpdateAction"),buyerIdentityUpdating:j("buyerIdentityUpdateAction"),cartAttributesUpdating:j("cartAttributesUpdateAction"),discountCodesUpdating:j("discountCodesUpdateAction")}})}function rt({numCartLines:e,onCartActionEntry:r,onCartActionOptimisticUI:t,onCartActionComplete:n,data:u,cartFragment:a,countryCode:o}){const{cartFetch:i,cartCreate:l,cartLineAdd:s,cartLineUpdate:m,cartLineRemove:c,noteUpdate:_,buyerIdentityUpdate:y,cartAttributesUpdate:E,discountCodesUpdate:T}=Xr({numCartLines:e,cartFragment:a,countryCode:o}),f=g.useMemo(()=>et(u),[u]),[S,b,v]=Dr(f,{actions:{cartFetchAction:async(d,h)=>{var A;if(h.type!=="CART_FETCH")return;const{data:p,errors:w}=await i((A=h==null?void 0:h.payload)==null?void 0:A.cartId),I=B(h,p==null?void 0:p.cart,w);b(I)},cartCreateAction:async(d,h)=>{var A;if(h.type!=="CART_CREATE")return;const{data:p,errors:w}=await l(h==null?void 0:h.payload),I=B(h,(A=p==null?void 0:p.cartCreate)==null?void 0:A.cart,w);b(I)},cartLineAddAction:async(d,h)=>{var A,O;if(h.type!=="CARTLINE_ADD"||!((A=d==null?void 0:d.cart)!=null&&A.id))return;const{data:p,errors:w}=await s(d.cart.id,h.payload.lines),I=B(h,(O=p==null?void 0:p.cartLinesAdd)==null?void 0:O.cart,w);b(I)},cartLineUpdateAction:async(d,h)=>{var A,O;if(h.type!=="CARTLINE_UPDATE"||!((A=d==null?void 0:d.cart)!=null&&A.id))return;const{data:p,errors:w}=await m(d.cart.id,h.payload.lines),I=B(h,(O=p==null?void 0:p.cartLinesUpdate)==null?void 0:O.cart,w);b(I)},cartLineRemoveAction:async(d,h)=>{var A,O;if(h.type!=="CARTLINE_REMOVE"||!((A=d==null?void 0:d.cart)!=null&&A.id))return;const{data:p,errors:w}=await c(d.cart.id,h.payload.lines),I=B(h,(O=p==null?void 0:p.cartLinesRemove)==null?void 0:O.cart,w);b(I)},noteUpdateAction:async(d,h)=>{var A,O;if(h.type!=="NOTE_UPDATE"||!((A=d==null?void 0:d.cart)!=null&&A.id))return;const{data:p,errors:w}=await _(d.cart.id,h.payload.note),I=B(h,(O=p==null?void 0:p.cartNoteUpdate)==null?void 0:O.cart,w);b(I)},buyerIdentityUpdateAction:async(d,h)=>{var A,O;if(h.type!=="BUYER_IDENTITY_UPDATE"||!((A=d==null?void 0:d.cart)!=null&&A.id))return;const{data:p,errors:w}=await y(d.cart.id,h.payload.buyerIdentity),I=B(h,(O=p==null?void 0:p.cartBuyerIdentityUpdate)==null?void 0:O.cart,w);b(I)},cartAttributesUpdateAction:async(d,h)=>{var A,O;if(h.type!=="CART_ATTRIBUTES_UPDATE"||!((A=d==null?void 0:d.cart)!=null&&A.id))return;const{data:p,errors:w}=await E(d.cart.id,h.payload.attributes),I=B(h,(O=p==null?void 0:p.cartAttributesUpdate)==null?void 0:O.cart,w);b(I)},discountCodesUpdateAction:async(d,h)=>{var A,O;if(h.type!=="DISCOUNT_CODES_UPDATE"||!((A=d==null?void 0:d.cart)!=null&&A.id))return;const{data:p,errors:w}=await T(d.cart.id,h.payload.discountCodes),I=B(h,(O=p==null?void 0:p.cartDiscountCodesUpdate)==null?void 0:O.cart,w);b(I)},...r&&{onCartActionEntry:(d,h)=>{tt(h)&&r(d,h)}},...t&&{onCartActionOptimisticUI:Z((d,h)=>t(d,h))},...n&&{onCartActionComplete:(d,h)=>{nt(h)&&n(d,h)}}}});return g.useMemo(()=>[S,b,v],[S,b,v])}function ge(e){var r;return{...e,lines:x(e==null?void 0:e.lines),note:(r=e.note)!=null?r:void 0}}function B(e,r,t){return t?{type:"ERROR",payload:{errors:t,cartActionEvent:e}}:r?{type:"RESOLVE",payload:{cart:ge(r),rawCartResult:r,cartActionEvent:e}}:{type:"CART_COMPLETED",payload:{cartActionEvent:e}}}function tt(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 nt(e){return e.type==="RESOLVE"||e.type==="ERROR"||e.type==="CART_COMPLETED"}var at="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/CartProvider.tsx";const Ye=g.createContext(null);function ie(){const e=g.useContext(Ye);if(!e)throw new Error("Expected a Cart Context, but no Cart Context was found");return e}function it({children:e,numCartLines:r,onCreate:t,onLineAdd:n,onLineRemove:u,onLineUpdate:a,onNoteUpdate:o,onBuyerIdentityUpdate:i,onAttributesUpdate:l,onDiscountCodesUpdate:s,onCreateComplete:m,onLineAddComplete:c,onLineRemoveComplete:_,onLineUpdateComplete:y,onNoteUpdateComplete:E,onBuyerIdentityUpdateComplete:T,onAttributesUpdateComplete:f,onDiscountCodesUpdateComplete:S,data:b,cartFragment:v=Br,customerAccessToken:d,countryCode:h="US"}){var fr,mr,yr,hr,_r,gr,pr;h&&(h=h.toUpperCase());const[p,w]=g.useState(h),[I,A]=g.useState(d),O=g.useRef(!1);(p!==h||I!==d)&&(w(h),A(d),O.current=!1);const[M,$]=rt({numCartLines:r,data:b,cartFragment:v,countryCode:h,onCartActionEntry(N,R){try{switch(R.type){case"CART_CREATE":return t==null?void 0:t();case"CARTLINE_ADD":return n==null?void 0:n();case"CARTLINE_REMOVE":return u==null?void 0:u();case"CARTLINE_UPDATE":return a==null?void 0:a();case"NOTE_UPDATE":return o==null?void 0:o();case"BUYER_IDENTITY_UPDATE":return i==null?void 0:i();case"CART_ATTRIBUTES_UPDATE":return l==null?void 0:l();case"DISCOUNT_CODES_UPDATE":return s==null?void 0:s()}}catch(V){console.error("Cart entry action failed",V)}},onCartActionOptimisticUI(N,R){var V,H,te,ne;if(!N.cart)return{...N};switch(R.type){case"CARTLINE_REMOVE":return{...N,cart:{...N.cart,lines:(H=(V=N==null?void 0:N.cart)==null?void 0:V.lines)==null?void 0:H.filter(U=>(U==null?void 0:U.id)&&!R.payload.lines.includes(U==null?void 0:U.id))}};case"CARTLINE_UPDATE":return{...N,cart:{...N.cart,lines:(ne=(te=N==null?void 0:N.cart)==null?void 0:te.lines)==null?void 0:ne.map(U=>{const Q=R.payload.lines.find(({id:ce})=>ce===(U==null?void 0:U.id));return Q&&Q.quantity?{...U,quantity:Q.quantity}:U})}}}return{...N}},onCartActionComplete(N,R){const V=R.payload.cartActionEvent;try{switch(R.type){case"RESOLVE":switch(V.type){case"CART_CREATE":return m==null?void 0:m();case"CARTLINE_ADD":return c==null?void 0:c();case"CARTLINE_REMOVE":return _==null?void 0:_();case"CARTLINE_UPDATE":return y==null?void 0:y();case"NOTE_UPDATE":return E==null?void 0:E();case"BUYER_IDENTITY_UPDATE":return st(N,V)&&(O.current=!0),T==null?void 0:T();case"CART_ATTRIBUTES_UPDATE":return f==null?void 0:f();case"DISCOUNT_CODES_UPDATE":return S==null?void 0:S()}}}catch(H){console.error("onCartActionComplete failed",H)}}}),F=g.useRef(!1),W=M.matches("cartCompleted"),K=(M.value==="idle"||M.value==="error"||M.value==="cartCompleted")&&h!==((yr=(mr=(fr=M==null?void 0:M.context)==null?void 0:fr.cart)==null?void 0:mr.buyerIdentity)==null?void 0:yr.countryCode)&&!M.context.errors,q=g.useRef(!1);g.useEffect(()=>{if(!F.current&&!q.current){if(!b&&pe("localStorage")){q.current=!0;try{const N=window.localStorage.getItem(_e);N&&$({type:"CART_FETCH",payload:{cartId:N}})}catch(N){console.warn("error fetching cartId"),console.warn(N)}}F.current=!0}},[b,F,$]),g.useEffect(()=>{!K||O.current||$({type:"BUYER_IDENTITY_UPDATE",payload:{buyerIdentity:{countryCode:h,customerAccessToken:d}}})},[h,d,K,O,$]);const L=g.useCallback(N=>{if(!F.current)return console.warn("Cart isn't ready yet");$(N)},[$]);g.useEffect(()=>{var N,R,V;if(((R=(N=M==null?void 0:M.context)==null?void 0:N.cart)==null?void 0:R.id)&&pe("localStorage"))try{window.localStorage.setItem(_e,(V=M.context.cart)==null?void 0:V.id)}catch(H){console.warn("Failed to save cartId to localStorage",H)}},[(_r=(hr=M==null?void 0:M.context)==null?void 0:hr.cart)==null?void 0:_r.id]),g.useEffect(()=>{if(W&&pe("localStorage"))try{window.localStorage.removeItem(_e)}catch(N){console.warn("Failed to delete cartId from localStorage",N)}},[W]);const G=g.useCallback(N=>{var R,V;h&&!((R=N.buyerIdentity)!=null&&R.countryCode)&&(N.buyerIdentity==null&&(N.buyerIdentity={}),N.buyerIdentity.countryCode=h),d&&!((V=N.buyerIdentity)!=null&&V.customerAccessToken)&&(N.buyerIdentity==null&&(N.buyerIdentity={}),N.buyerIdentity.customerAccessToken=d),L({type:"CART_CREATE",payload:N})},[h,d,L]),k=ut(M),se=g.useMemo(()=>{var N,R,V,H,te,ne;return{...(R=(N=k==null?void 0:k.context)==null?void 0:N.cart)!=null?R:{lines:[],attributes:[]},status:ot(k.value),error:(V=k==null?void 0:k.context)==null?void 0:V.errors,totalQuantity:(ne=(te=(H=k==null?void 0:k.context)==null?void 0:H.cart)==null?void 0:te.totalQuantity)!=null?ne:0,cartCreate:G,linesAdd(U){var Q,ce;(ce=(Q=k==null?void 0:k.context)==null?void 0:Q.cart)!=null&&ce.id?L({type:"CARTLINE_ADD",payload:{lines:U}}):G({lines:U})},linesRemove(U){L({type:"CARTLINE_REMOVE",payload:{lines:U}})},linesUpdate(U){L({type:"CARTLINE_UPDATE",payload:{lines:U}})},noteUpdate(U){L({type:"NOTE_UPDATE",payload:{note:U}})},buyerIdentityUpdate(U){L({type:"BUYER_IDENTITY_UPDATE",payload:{buyerIdentity:U}})},cartAttributesUpdate(U){L({type:"CART_ATTRIBUTES_UPDATE",payload:{attributes:U}})},discountCodesUpdate(U){L({type:"DISCOUNT_CODES_UPDATE",payload:{discountCodes:U}})},cartFragment:v}},[G,(gr=k==null?void 0:k.context)==null?void 0:gr.cart,(pr=k==null?void 0:k.context)==null?void 0:pr.errors,k.value,v,L]);return C.default.createElement(Ye.Provider,{value:se,__self:this,__source:{fileName:at,lineNumber:424,columnNumber:5}},e)}function ot(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 ut(e){const[r,t]=g.useTransition(),[n,u]=g.useState(e),a=g.useRef(!1);r&&(a.current=!0);const o=g.useRef(!1);return!r&&a.current&&(o.current=!0),g.useEffect(()=>{t(()=>{o.current||u(e)})},[e]),o.current?e:n}function pe(e){let r;try{r=window[e];const t="__storage_test__";return r.setItem(t,t),r.removeItem(t),!0}catch(t){return t instanceof DOMException&&(t.code===22||t.code===1014||t.name==="QuotaExceededError"||t.name==="NS_ERROR_DOM_QUOTA_REACHED")&&r&&r.length!==0}}function st(e,r){var t,n;return r.payload.buyerIdentity.countryCode&&((n=(t=e.cart)==null?void 0:t.buyerIdentity)==null?void 0:n.countryCode)!==r.payload.buyerIdentity.countryCode}var ct="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ProductProvider.tsx";const Ge=g.createContext(null);function lt({children:e,data:r,initialVariantId:t}){const n=g.useMemo(()=>{var f;return x((f=r.variants)!=null?f:{})},[r.variants]);if(!ft(n))throw new Error("<ProductProvider/> requires 'product.variants.nodes' or 'product.variants.edges'");const u=g.useMemo(()=>dt(n),[n]),[a,o]=g.useState(()=>Ke(t,n)),[i,l]=g.useState(()=>Qe(a));g.useEffect(()=>{const f=Ke(t,n);o(f),l(Qe(f))},[t,n]);const s=g.useCallback((f,S)=>{l(b=>{const v={...b,[f]:S};return o(ze(n,v)),v})},[l,n]),m=g.useCallback((f,S)=>{var v;const b=ze(n,{...i,[f]:S});return(v=b==null?void 0:b.availableForSale)!=null?v:!0},[i,n]),c=g.useMemo(()=>{var f;return x((f=r.sellingPlanGroups)!=null?f:{}).map(S=>{var b;return{...S,sellingPlans:x((b=S==null?void 0:S.sellingPlans)!=null?b:{})}})},[r.sellingPlanGroups]),[_,y]=g.useState(void 0),E=g.useMemo(()=>{var f,S;if(!(!a||!_)){if(!((f=a.sellingPlanAllocations)!=null&&f.nodes)&&!((S=a.sellingPlanAllocations)!=null&&S.edges))throw new Error("<ProductProvider/>: You must include 'sellingPlanAllocations.nodes' or 'sellingPlanAllocations.edges' in your variants in order to calculate selectedSellingPlanAllocation");return x(a.sellingPlanAllocations).find(b=>{var v;return((v=b==null?void 0:b.sellingPlan)==null?void 0:v.id)===_.id})}},[a,_]),T=g.useMemo(()=>({variants:n,variantsConnection:r.variants,options:u,selectedVariant:a,setSelectedVariant:o,selectedOptions:i,setSelectedOption:s,setSelectedOptions:l,isOptionInStock:m,selectedSellingPlan:_,setSelectedSellingPlan:y,selectedSellingPlanAllocation:E,sellingPlanGroups:c,sellingPlanGroupsConnection:r.sellingPlanGroups}),[m,u,r.sellingPlanGroups,r.variants,i,_,E,a,c,s,n]);return C.default.createElement(Ge.Provider,{value:T,__self:this,__source:{fileName:ct,lineNumber:201,columnNumber:5}},e)}function Ze(){const e=g.useContext(Ge);if(!e)throw new Error("'useProduct' must be a child of <ProductProvider />");return e}function ze(e,r){var t,n;if(!(!e.length||((n=(t=e==null?void 0:e[0])==null?void 0:t.selectedOptions)==null?void 0:n.length)!==Object.keys(r).length))return e==null?void 0:e.find(u=>Object.entries(r).every(([a,o])=>{var i;return(i=u==null?void 0:u.selectedOptions)==null?void 0:i.some(l=>(l==null?void 0:l.name)===a&&(l==null?void 0:l.value)===o)}))}function dt(e){const r=e.reduce((t,n)=>{var u;if(!n.selectedOptions)throw new Error("'getOptions' requires 'variant.selectedOptions'");return(u=n==null?void 0:n.selectedOptions)==null||u.forEach(a=>{var o,i,l,s;t[(o=a==null?void 0:a.name)!=null?o:""]=t[(i=a==null?void 0:a.name)!=null?i:""]||new Set,t[(l=a==null?void 0:a.name)!=null?l:""].add((s=a==null?void 0:a.value)!=null?s:"")}),t},{});return Object.keys(r).map(t=>({name:t,values:Array.from(r[t])}))}function Ke(e,r){if(e){const t=r.find(n=>(n==null?void 0:n.id)===e);return t||console.warn("<ProductProvider/> received a 'initialVariantId' prop, but could not actually find a variant with that ID"),t}if(e===null)return null;if(e===void 0)return r.find(t=>t==null?void 0:t.availableForSale)||r[0]}function Qe(e){return e!=null&&e.selectedOptions?e.selectedOptions.reduce((r,t)=>{var n,u;return r[(n=t==null?void 0:t.name)!=null?n:""]=(u=t==null?void 0:t.value)!=null?u:"",r},{}):{}}function ft(e){return!(!e||!Array.isArray(e))}var mt="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/BaseButton.tsx";function Ee(e){const{as:r,onClick:t,defaultOnClick:n,children:u,buttonRef:a,...o}=e,i=g.useCallback(s=>{if(t){const m=t(s);if(typeof m=="boolean"&&m===!1||(s==null?void 0:s.defaultPrevented))return}n==null||n(s)},[n,t]),l=r||"button";return C.default.createElement(l,{ref:a,onClick:i,...o,__self:this,__source:{fileName:mt,lineNumber:59,columnNumber:5}},u)}var Je="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/AddToCartButton.tsx";function yt(e){var S;const[r,t]=g.useState(!1),{variantId:n,quantity:u=1,attributes:a,sellingPlanId:o,onClick:i,children:l,accessibleAddingToCartLabel:s,...m}=e,{status:c,linesAdd:_}=ie(),{selectedVariant:y}=Ze(),E=(S=n!=null?n:y==null?void 0:y.id)!=null?S:"",T=n===null||E===""||y===null||r||m.disabled;g.useEffect(()=>{r&&c==="idle"&&t(!1)},[c,r]);const f=g.useCallback(()=>{t(!0),_([{quantity:u,merchandiseId:E||"",attributes:a,sellingPlanId:o}])},[_,u,E,a,o]);return C.default.createElement(C.default.Fragment,null,C.default.createElement(Ee,{...m,disabled:T,onClick:i,defaultOnClick:f,__self:this,__source:{fileName:Je,lineNumber:71,columnNumber:7}},l),s?C.default.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",__self:this,__source:{fileName:Je,lineNumber:80,columnNumber:9}},r?s:null):null)}var ht="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/BuyNowButton.tsx";function _t(e){const{cartCreate:r,checkoutUrl:t}=ie(),[n,u]=g.useState(!1),{quantity:a,variantId:o,onClick:i,attributes:l,children:s,...m}=e;g.useEffect(()=>{t&&(window.location.href=t)},[t]);const c=g.useCallback(()=>{u(!0),r({lines:[{quantity:a!=null?a:1,merchandiseId:o,attributes:l}]})},[r,a,o,l]);return C.default.createElement(Ee,{disabled:n!=null?n:m.disabled,...m,onClick:i,defaultOnClick:c,__self:this,__source:{fileName:ht,lineNumber:53,columnNumber:5}},s)}var gt="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/CartCheckoutButton.tsx";function pt(e){const[r,t]=g.useState(!1),{status:n,checkoutUrl:u}=ie(),{children:a,...o}=e;return g.useEffect(()=>{r&&u&&n==="idle"&&(window.location.href=u)},[r,n,u]),C.default.createElement(Ee,{...o,disabled:r||o.disabled,onClick:()=>t(!0),__self:this,__source:{fileName:gt,lineNumber:28,columnNumber:5}},a)}const Et={DateTime:"string",Decimal:"string",HTML:"string",URL:"string",Color:"string",UnsignedInt64:"string"};var St="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ExternalVideo.tsx";function Xe(e){var m,c;const{data:r,options:t,id:n=r.id,frameBorder:u="0",allow:a="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:o=!0,loading:i="lazy",...l}=e;if(!r.embedUrl)throw new Error("<ExternalVideo/> requires the 'embedUrl' property");let s=r.embedUrl;if(t){const _=new URL(r.embedUrl);for(const y of Object.keys(t))_.searchParams.set(y,t[y]);s=_.toString()}return C.default.createElement("iframe",{...l,id:n!=null?n:r.embedUrl,title:(c=(m=r.alt)!=null?m:r.id)!=null?c:"external video",frameBorder:u,allow:a,allowFullScreen:o,src:s,loading:i,__self:this,__source:{fileName:St,lineNumber:56,columnNumber:5}})}const bt=["cdn.shopify.com","cdn.shopifycdn.net","shopify-assets.shopifycdn.com","shopify-assets.shopifycdn.net"],vt=["spin.dev"],Ct=[...bt,...vt],re=[352,832,1200,1920,2560];function er({src:e,width:r,height:t,crop:n,scale:u}){const a=new URL(e),o=u!=null?u:1;if(r){let i;typeof r=="string"?i=(re[0]*o).toString():i=(Number(r)*o).toString(),a.searchParams.append("width",i)}return t&&typeof t=="number"&&a.searchParams.append("height",(t*o).toString()),n&&a.searchParams.append("crop",n),a.toString()}function rr(e){const r=new URL(e.src);return!Ct.some(n=>r.hostname.endsWith(n))||!e.width&&!e.height&&!e.crop&&!e.scale?e.src:er(e)}function Tt({data:e,loaderOptions:r,elementProps:t}){var u,a,o,i,l,s;let n=null;return(e==null?void 0:e.width)&&(e==null?void 0:e.height)&&(n=(e==null?void 0:e.width)/(e==null?void 0:e.height)),(r==null?void 0:r.width)||(r==null?void 0:r.height)?{width:(u=r==null?void 0:r.width)!=null?u:n&&typeof r.height=="number"?Math.round(n*r.height):null,height:(a=r==null?void 0:r.height)!=null?a:n&&typeof r.width=="number"?Math.round(n*r.width):null}:(t==null?void 0:t.width)||(t==null?void 0:t.height)?{width:(o=t==null?void 0:t.width)!=null?o:n&&typeof t.height=="number"?Math.round(n*t.height):null,height:(i=t==null?void 0:t.height)!=null?i:n&&typeof t.width=="number"?Math.round(n*t.width):null}:(e==null?void 0:e.width)||(e==null?void 0:e.height)?{width:(l=e==null?void 0:e.width)!=null?l:null,height:(s=e==null?void 0:e.height)!=null?s:null}:{width:null,height:null}}var At="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/Image.tsx";function oe({data:e,width:r,height:t,loading:n,loader:u=rr,loaderOptions:a,widths:o,decoding:i="async",...l}){var E,T,f,S,b,v;if(!e.url){const d=`<Image/>: the 'data' prop requires the 'url' property. Image: ${(E=e.id)!=null?E:"no ID provided"}`;return console.error(d),null}const{width:s,height:m}=Tt({data:e,loaderOptions:a,elementProps:{width:r,height:t}});let c=e.url;if(u&&(c=u({...a,src:e.url,width:s,height:m}),typeof c!="string"||!c))throw new Error(`<Image/>: 'loader' did not return a valid string. Image: ${(T=e.id)!=null?T:e.url}`);const _=r&&s&&r<s?r:s,y=(f=l.srcSet)!=null?f:Nt({...a,widths:o,src:e.url,width:_,height:m,loader:u});return Ce.createElement("img",{id:(S=e.id)!=null?S:"",alt:(v=(b=e.altText)!=null?b:l.alt)!=null?v:"",loading:n!=null?n:"lazy",...l,src:c,width:s!=null?s:void 0,height:m!=null?m:void 0,srcSet:y,decoding:i,__self:this,__source:{fileName:At,lineNumber:150,columnNumber:5}})}function Nt({src:e,width:r,crop:t,scale:n,widths:u,loader:a,height:o}){const i=u&&Array.isArray(u);if(i&&u.some(c=>isNaN(c)))throw new Error(`<Image/>: the 'widths' must be an array of numbers. Image: ${e}`);let l=1;r&&o&&(l=Number(o)/Number(r));let s=i?u:re;!i&&r&&r<re[re.length-1]&&(s=re.filter(c=>c<=r));const m=a||er;return s.map(c=>`${m({src:e,width:c,height:t?Number(c)*l:void 0,crop:t,scale:n})} ${c}w`).join(", ")}var tr="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/Video.tsx";function Se(e){var s,m;const{data:r,previewImageOptions:t,id:n=r.id,playsInline:u=!0,controls:a=!0,sourceProps:o={},...i}=e,l=rr({src:(m=(s=r.previewImage)==null?void 0:s.url)!=null?m:"",...t});if(!r.sources)throw new Error("<Video/> requires a 'data.sources' array");return C.default.createElement("video",{...i,id:n,playsInline:u,controls:a,poster:l,__self:this,__source:{fileName:tr,lineNumber:42,columnNumber:5}},r.sources.map(c=>{if(!((c==null?void 0:c.url)&&(c==null?void 0:c.mimeType)))throw new Error("<Video/> needs 'source.url' and 'source.mimeType'");return C.default.createElement("source",{...o,key:c.url,src:c.url,type:c.mimeType,__self:this,__source:{fileName:tr,lineNumber:54,columnNumber:11}})}))}const nr={};function wt(e,r){const t=nr[e];if(t)return t;const n=new Promise((u,a)=>{const o=document.createElement("script");r!=null&&r.module?o.type="module":o.type="text/javascript",o.src=e,o.onload=()=>{u(!0)},o.onerror=()=>{a(!1)},(r==null?void 0:r.in)==="head"?document.head.appendChild(o):document.body.appendChild(o)});return nr[e]=n,n}function ar(e,r){const[t,n]=g.useState("loading"),u=JSON.stringify(r);return g.useEffect(()=>{async function a(){try{n("loading"),await wt(e,r),n("done")}catch{n("error")}}a()},[e,u,r]),t}var It="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ModelViewer.tsx";function ir(e){var s,m,c,_,y,E,T,f,S,b,v;const[r,t]=g.useState(void 0),n=g.useCallback(d=>{t(d)},[]),{data:u,children:a,className:o,...i}=e,l=ar("https://unpkg.com/@google/model-viewer@v1.12.1/dist/model-viewer.min.js",{module:!0});return g.useEffect(()=>{if(!!r)return i.onError&&r.addEventListener("error",i.onError),i.onLoad&&r.addEventListener("load",i.onLoad),i.onPreload&&r.addEventListener("preload",i.onPreload),i.onModelVisibility&&r.addEventListener("model-visibility",i.onModelVisibility),i.onProgress&&r.addEventListener("progress",i.onProgress),i.onArStatus&&r.addEventListener("ar-status",i.onArStatus),i.onArTracking&&r.addEventListener("ar-tracking",i.onArTracking),i.onQuickLookButtonTapped&&r.addEventListener("quick-look-button-tapped",i.onQuickLookButtonTapped),i.onCameraChange&&r.addEventListener("camera-change",i.onCameraChange),i.onEnvironmentChange&&r.addEventListener("environment-change",i.onEnvironmentChange),i.onPlay&&r.addEventListener("play",i.onPlay),i.onPause&&r.addEventListener("ar-status",i.onPause),i.onSceneGraphReady&&r.addEventListener("scene-graph-ready",i.onSceneGraphReady),()=>{r!=null&&(i.onError&&r.removeEventListener("error",i.onError),i.onLoad&&r.removeEventListener("load",i.onLoad),i.onPreload&&r.removeEventListener("preload",i.onPreload),i.onModelVisibility&&r.removeEventListener("model-visibility",i.onModelVisibility),i.onProgress&&r.removeEventListener("progress",i.onProgress),i.onArStatus&&r.removeEventListener("ar-status",i.onArStatus),i.onArTracking&&r.removeEventListener("ar-tracking",i.onArTracking),i.onQuickLookButtonTapped&&r.removeEventListener("quick-look-button-tapped",i.onQuickLookButtonTapped),i.onCameraChange&&r.removeEventListener("camera-change",i.onCameraChange),i.onEnvironmentChange&&r.removeEventListener("environment-change",i.onEnvironmentChange),i.onPlay&&r.removeEventListener("play",i.onPlay),i.onPause&&r.removeEventListener("ar-status",i.onPause),i.onSceneGraphReady&&r.removeEventListener("scene-graph-ready",i.onSceneGraphReady))}},[r,i.onArStatus,i.onArTracking,i.onCameraChange,i.onEnvironmentChange,i.onError,i.onLoad,i.onModelVisibility,i.onPause,i.onPlay,i.onPreload,i.onProgress,i.onQuickLookButtonTapped,i.onSceneGraphReady]),l!=="done"?null:(m=(s=u.sources)==null?void 0:s[0])!=null&&m.url?C.default.createElement("model-viewer",{ref:n,...i,className:o,id:(c=i.id)!=null?c:u.id,src:u.sources[0].url,alt:(_=u.alt)!=null?_:null,"camera-controls":(y=i.cameraControls)!=null?y:!0,poster:(T=i.poster||((E=u.previewImage)==null?void 0:E.url))!=null?T:null,autoplay:(f=i.autoplay)!=null?f:!0,loading:i.loading,reveal:i.reveal,ar:i.ar,"ar-modes":i.arModes,"ar-scale":i.arScale,"ar-placement":i.arPlacement,"ios-src":i.iosSrc,"touch-action":i.touchAction,"disable-zoom":i.disableZoom,"orbit-sensitivity":i.orbitSensitivity,"auto-rotate":i.autoRotate,"auto-rotate-delay":i.autoRotateDelay,"rotation-per-second":i.rotationPerSecond,"interaction-policy":i.interactionPolicy,"interaction-prompt":i.interactionPrompt,"interaction-prompt-style":i.interactionPromptStyle,"interaction-prompt-threshold":i.interactionPromptThreshold,"camera-orbit":i.cameraOrbit,"camera-target":i.cameraTarget,"field-of-view":i.fieldOfView,"max-camera-orbit":i.maxCameraOrbit,"min-camera-orbit":i.minCameraOrbit,"max-field-of-view":i.maxFieldOfView,"min-field-of-view":i.minFieldOfView,bounds:i.bounds,"interpolation-decay":(S=i.interpolationDecay)!=null?S:100,"skybox-image":i.skyboxImage,"environment-image":i.environmentImage,exposure:i.exposure,"shadow-intensity":(b=i.shadowIntensity)!=null?b:0,"shadow-softness":(v=i.shadowSoftness)!=null?v:0,"animation-name":i.animationName,"animation-crossfade-duration":i.animationCrossfadeDuration,"variant-name":i.variantName,orientation:i.orientation,scale:i.scale,__self:this,__source:{fileName:It,lineNumber:222,columnNumber:5}},a):(console.error("<ModelViewer/> requires 'data.sources' prop to be an array, with an object that has a property 'url' on it. Rendering 'null'"),null)}var ue="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/MediaFile.tsx";function Ot({data:e,mediaOptions:r,...t}){switch(e.__typename){case"MediaImage":return e.image?C.default.createElement(oe,{...t,...r==null?void 0:r.image,data:e.image,__self:this,__source:{fileName:ue,lineNumber:54,columnNumber:9}}):(console.warn("<MediaFile/>: 'data.image' does not exist for __typename of 'MediaImage'; rendering 'null' by default."),null);case"Video":return C.default.createElement(Se,{...t,...r==null?void 0:r.video,data:e,__self:this,__source:{fileName:ue,lineNumber:63,columnNumber:9}});case"ExternalVideo":return C.default.createElement(Xe,{...t,...r==null?void 0:r.externalVideo,data:e,__self:this,__source:{fileName:ue,lineNumber:68,columnNumber:9}});case"Model3d":return C.default.createElement(ir,{...t,...r==null?void 0:r.modelViewer,data:e,__self:this,__source:{fileName:ue,lineNumber:78,columnNumber:9}});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}}var P="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/Metafield.tsx";function Dt(e){var i,l,s,m,c,_,y,E,T;const{data:r,as:t,...n}=e,{locale:u}=X(),a=g.useMemo(()=>or(r),[r]);if(!a)return console.warn("<Metafield/>: nothing was passed to the data prop 'data'. Rendering 'null'"),null;if(a.value===null||a.value===void 0){const f=`<Metafield/>: No metafield value for metafield ${(i=a.id)!=null?i:a.key}. Rendering 'null'`;return console.warn(f),null}switch(a.type){case"date":{const f=t!=null?t:"time";return C.default.createElement(f,{...n,__self:this,__source:{fileName:P,lineNumber:68,columnNumber:9}},a.value.toLocaleDateString(u))}case"date_time":{const f=t!=null?t:"time";return C.default.createElement(f,{...n,__self:this,__source:{fileName:P,lineNumber:76,columnNumber:9}},a.value.toLocaleString(u))}case"weight":case"dimension":case"volume":{const f=t!=null?t:"span";return C.default.createElement(f,{...n,__self:this,__source:{fileName:P,lineNumber:86,columnNumber:9}},Ut(a.value,u))}case"rating":{const f=t!=null?t:"span";return C.default.createElement(f,{...n,__self:this,__source:{fileName:P,lineNumber:94,columnNumber:9}},a.value.value)}case"single_line_text_field":{const f=t!=null?t:"span";return C.default.createElement(f,{...n,dangerouslySetInnerHTML:{__html:a.value},__self:this,__source:{fileName:P,lineNumber:102,columnNumber:9}})}case"multi_line_text_field":{const f=t!=null?t:"div";return C.default.createElement(f,{...n,dangerouslySetInnerHTML:{__html:a.value.split(`
|
|
286
|
+
`).join("<br/>")},__self:this,__source:{fileName:P,lineNumber:111,columnNumber:9}})}case"url":{const f=new URL(a.value);return C.default.createElement("a",{href:f.href.replace(f.protocol,""),...n,__self:this,__source:{fileName:P,lineNumber:122,columnNumber:9}},a.value)}case"json":{const f=t!=null?t:"span";return C.default.createElement(f,{...n,__self:this,__source:{fileName:P,lineNumber:133,columnNumber:9}},JSON.stringify(a.value))}case"product_reference":case"variant_reference":case"page_reference":{const f=t!=null?t:"span",S=a.reference;return C.default.createElement(f,{...n,__self:this,__source:{fileName:P,lineNumber:144,columnNumber:9}},(s=(l=S==null?void 0:S.title)!=null?l:S==null?void 0:S.id)!=null?s:"")}case"list.single_line_text_field":{const f=t!=null?t:"ul",S=a.references?x(a.references):[];return C.default.createElement(f,{...n,__self:this,__source:{fileName:P,lineNumber:154,columnNumber:9}},S.map((b,v)=>C.default.createElement("li",{key:`${b!=null?b:""}-${v}`,__self:this,__source:{fileName:P,lineNumber:158,columnNumber:13}},b)))}case"file_reference":if(((m=a.reference)==null?void 0:m.__typename)==="MediaImage"){const f=a.reference;return f.image?C.default.createElement(oe,{data:f.image,...n,__self:this,__source:{fileName:P,lineNumber:167,columnNumber:11}}):null}else if(((c=a.reference)==null?void 0:c.__typename)==="GenericFile"){const f=a.reference;return f.previewImage?C.default.createElement("a",{href:(y=(_=a.reference)==null?void 0:_.url)!=null?y:"",...n,__self:this,__source:{fileName:P,lineNumber:172,columnNumber:11}},C.default.createElement(oe,{data:f.previewImage,__self:this,__source:{fileName:P,lineNumber:173,columnNumber:13}})):null}else if(((E=a.reference)==null?void 0:E.__typename)==="Video"){const f=a.reference;return C.default.createElement(Se,{...n,data:f,__self:this,__source:{fileName:P,lineNumber:178,columnNumber:16}})}}const o=t!=null?t:"span";return C.default.createElement(o,{...n,__self:this,__source:{fileName:P,lineNumber:185,columnNumber:5}},(T=a.value)==null?void 0:T.toString())}function or(e){return e?{...e,value:ur(e)}:null}function ur(e){if(!e)return null;if(e.value===null||e.value===void 0)return e.value;switch(e.type){case"boolean":return e.value==="true";case"number_integer":return parseInt(e.value);case"number_decimal":return parseFloat(e.value);case"date":case"date_time":return new Date(e.value);case"json":case"weight":case"dimension":case"volume":case"rating":return be(e.value);case"color":case"single_line_text_field":case"multi_line_text_field":case"product_reference":case"page_reference":case"variant_reference":case"file_reference":case"url":default:return e.value}}function be(e){return String(e).includes("__proto__")?JSON.parse(e,(r,t)=>{if(r!=="__proto__")return t}):JSON.parse(e)}const Lt={mm:"millimeter",cm:"centimeter",m:"meter",in:"inch",ft:"foot",yd:"yard",ml:"milliliter",l:"liter",us_fl_oz:"fluid-ounce",us_gal:"gallon",kg:"kilogram",g:"gram",lb:"pound",oz:"ounce"};function Ut(e,r="en-us",t={}){let n={value:e.value,unit:Lt[e.unit]};return n.unit==null&&(n=kt(e.value,e.unit)),new Intl.NumberFormat(r,{...t,unit:n.unit,style:"unit"}).format(n.value)}function kt(e,r){switch(r){case"cl":return{value:e/1e3,unit:"liter"};case"m3":return{value:e*1e3,unit:"liter"};case"us_pt":return{value:e*.125,unit:"gallon"};case"us_qt":return{value:e*.5,unit:"gallon"};case"us_oz":return{value:e/128,unit:"gallon"};case"imp_pt":return{value:e/6.661,unit:"gallon"};case"imp_qt":return{value:e/3.331,unit:"gallon"};case"imp_gal":return{value:e/1.201,unit:"gallon"};case"imp_fl_oz":return{value:e*.96076,unit:"fluid-ounce"};default:throw new Error(`Unit not supported: ${r}`)}}function Mt(e){var r,t,n,u;if(!e.type)return console.error("metafieldParser(): 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 a=null;try{a=be((r=e.value)!=null?r:"")}catch{console.error("metafieldParser(): attempted to JSON.parse the 'metafield.value' property, but failed. Returning 'null' for 'parsedValue'"),a=null}return{...e,parsedValue:a}}case"date":case"date_time":return{...e,parsedValue:new Date((t=e.value)!=null?t:"")};case"list.date":case"list.date_time":{const a=be((n=e==null?void 0:e.value)!=null?n:"");return{...e,parsedValue:a.map(o=>new Date(o))}}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:x((u=e.references)!=null?u:void 0)};default:{const a=`metafieldParser(): 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(`${a} Returning 'parsedValue' of 'null'`),{...e,parsedValue:null}}}}function sr(e){const{locale:r}=X();if(!r)throw new Error("useMoney(): Unable to get 'locale' from 'useShop()', which means that 'locale' was not passed to '<ShopifyProvider/>'. 'locale' is required for 'useMoney()' to work");const t=parseFloat(e.amount),n=g.useMemo(()=>({style:"currency",currency:e.currencyCode}),[e.currencyCode]),u=z(r,n),a=z(r,{...n,currencyDisplay:"name"}),o=z(r,{...n,currencyDisplay:"narrowSymbol"}),i=z(r,{...n,minimumFractionDigits:0,maximumFractionDigits:0}),l=z(r),s=z(r,{minimumFractionDigits:0,maximumFractionDigits:0}),m=_=>_.type==="currency",c=g.useMemo(()=>({original:()=>e,currencyCode:()=>e.currencyCode,localizedString:()=>u().format(t),parts:()=>u().formatToParts(t),withoutTrailingZeros:()=>t%1===0?i().format(t):u().format(t),withoutTrailingZerosAndCurrency:()=>t%1===0?s().format(t):l().format(t),currencyName:()=>{var _,y;return(y=(_=a().formatToParts(t).find(m))==null?void 0:_.value)!=null?y:e.currencyCode},currencySymbol:()=>{var _,y;return(y=(_=u().formatToParts(t).find(m))==null?void 0:_.value)!=null?y:e.currencyCode},currencyNarrowSymbol:()=>{var _,y;return(y=(_=o().formatToParts(t).find(m))==null?void 0:_.value)!=null?y:""},amount:()=>u().formatToParts(t).filter(_=>["decimal","fraction","group","integer","literal"].includes(_.type)).map(_=>_.value).join("")}),[e,t,a,u,o,l,i,s]);return g.useMemo(()=>new Proxy(c,{get:(_,y)=>{var E;return(E=Reflect.get(_,y))==null?void 0:E.call(null)}}),[c])}function z(e,r){return g.useMemo(()=>{let t;return()=>t!=null?t:t=new Intl.NumberFormat(e,r)},[e,r])}var Rt="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/Money.tsx";function ve({data:e,as:r,withoutCurrency:t,withoutTrailingZeros:n,measurement:u,measurementSeparator:a="/",...o}){if(!Pt(e))throw new Error("<Money/> needs a valid 'data' prop that has 'amount' and 'currencyCode'");const i=sr(e),l=r!=null?r:"div";let s=i.localizedString;return(t||n)&&(t&&!n?s=i.amount:!t&&n?s=i.withoutTrailingZeros:s=i.withoutTrailingZerosAndCurrency),C.default.createElement(l,{...o,__self:this,__source:{fileName:Rt,lineNumber:65,columnNumber:5}},s,u&&u.referenceUnit&&C.default.createElement(C.default.Fragment,null,a,u.referenceUnit))}function Pt(e){return typeof e.amount=="string"&&!!e.amount&&typeof e.currencyCode=="string"&&!!e.currencyCode}var cr="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ProductPrice.tsx";function $t(e){var s,m,c,_,y,E,T,f;const{priceType:r="regular",variantId:t,valueType:n="min",data:u,...a}=e;if(u==null)throw new Error("<ProductPrice/> requires a product as the 'data' prop");let o,i;const l=t&&(m=x((s=u==null?void 0:u.variants)!=null?s:{}).find(S=>(S==null?void 0:S.id)===t))!=null?m:null;if(r==="compareAt")if(t&&l){if(((c=l.compareAtPriceV2)==null?void 0:c.amount)===((_=l.priceV2)==null?void 0:_.amount))return null;o=l.compareAtPriceV2}else n==="max"?o=(y=u==null?void 0:u.compareAtPriceRange)==null?void 0:y.maxVariantPrice:o=(E=u==null?void 0:u.compareAtPriceRange)==null?void 0:E.minVariantPrice;else t&&l?(o=l.priceV2,n==="unit"&&(o=l.unitPrice,i=l.unitPriceMeasurement)):n==="max"?o=(T=u.priceRange)==null?void 0:T.maxVariantPrice:o=(f=u.priceRange)==null?void 0:f.minVariantPrice;return o?i?C.default.createElement(ve,{...a,data:o,measurement:i,__self:this,__source:{fileName:cr,lineNumber:81,columnNumber:7}}):C.default.createElement(ve,{...a,data:o,__self:this,__source:{fileName:cr,lineNumber:85,columnNumber:10}}):null}var lr="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ShopPayButton.tsx";const Vt="https://cdn.shopify.com/shopifycloud/shop-js/v1.0/client.js";function Ft({variantIds:e,className:r,variantIdsAndQuantities:t,width:n}){const{storeDomain:u}=X(),a=ar(Vt);let o;if(e&&t)throw new Error(jt);if(e)o=e.reduce((l,s)=>{const m=dr(s);return m&&l.push(m),l},[]);else if(t)o=t.reduce((l,s)=>{var c;const m=dr(s==null?void 0:s.id);return m&&l.push(`${m}:${(c=s==null?void 0:s.quantity)!=null?c:1}`),l},[]);else throw new Error(xt);const i=n?{"--shop-pay-button-width":n}:void 0;return C.default.createElement("div",{className:r,style:i,__self:this,__source:{fileName:lr,lineNumber:90,columnNumber:5}},a==="done"&&C.default.createElement("shop-pay-button",{"store-url":`https://${u}`,variants:o.join(","),__self:this,__source:{fileName:lr,lineNumber:92,columnNumber:9}}))}function dr(e){if(!!e)return e.split("/").pop()}const xt='You must pass in either "variantIds" or "variantIdsAndQuantities" to ShopPayButton',jt="You must provide either a variantIds or variantIdsAndQuantities prop, but not both in the ShopPayButton component";D.AddToCartButton=yt,D.BuyNowButton=_t,D.CartCheckoutButton=pt,D.CartProvider=it,D.ExternalVideo=Xe,D.Image=oe,D.MediaFile=Ot,D.Metafield=Dt,D.ModelViewer=ir,D.Money=ve,D.ProductPrice=$t,D.ProductProvider=lt,D.ShopPayButton=Ft,D.ShopifyProvider=Yr,D.Video=Se,D.createStorefrontClient=Hr,D.flattenConnection=x,D.metafieldParser=Mt,D.parseMetafield=or,D.parseMetafieldValue=ur,D.storefrontApiCustomScalars=Et,D.useCart=ie,D.useMoney=sr,D.useProduct=Ze,D.useShop=X,Object.defineProperties(D,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
240
287
|
//# sourceMappingURL=hydrogen-react.prod.js.map
|