@shopify/hydrogen-react 2022.7.0 → 2022.10.0
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/README.md +7 -5
- package/dist/dev/CartProvider.cjs +485 -0
- package/dist/dev/CartProvider.cjs.map +1 -0
- package/dist/dev/CartProvider.js +485 -0
- package/dist/dev/CartProvider.js.map +1 -0
- package/dist/dev/MediaFile.cjs.map +1 -1
- package/dist/dev/MediaFile.js.map +1 -1
- package/dist/dev/Metafield.cjs +2 -2
- package/dist/dev/Metafield.cjs.map +1 -1
- package/dist/dev/Metafield.js.map +1 -1
- package/dist/dev/ModelViewer.cjs +4 -4
- package/dist/dev/ModelViewer.cjs.map +1 -1
- package/dist/dev/Money.cjs.map +1 -1
- package/dist/dev/Money.js.map +1 -1
- package/dist/dev/ProductPrice.cjs.map +1 -1
- package/dist/dev/ProductPrice.js.map +1 -1
- package/dist/dev/ProductProvider.cjs +14 -14
- package/dist/dev/ProductProvider.cjs.map +1 -1
- package/dist/dev/ShopPayButton.cjs.map +1 -1
- package/dist/dev/ShopPayButton.js.map +1 -1
- package/dist/dev/ShopifyProvider.cjs +4 -4
- package/dist/dev/ShopifyProvider.cjs.map +1 -1
- package/dist/dev/Video.cjs +2 -2
- package/dist/dev/_virtual/index.cjs +5 -0
- package/dist/dev/_virtual/index.cjs.map +1 -0
- package/dist/dev/_virtual/index.js +5 -0
- package/dist/dev/_virtual/index.js.map +1 -0
- package/dist/dev/_virtual/use-sync-external-store-shim.development.cjs +5 -0
- package/dist/dev/_virtual/use-sync-external-store-shim.development.cjs.map +1 -0
- package/dist/dev/_virtual/use-sync-external-store-shim.development.js +5 -0
- package/dist/dev/_virtual/use-sync-external-store-shim.development.js.map +1 -0
- package/dist/dev/_virtual/use-sync-external-store-shim.production.min.cjs +5 -0
- package/dist/dev/_virtual/use-sync-external-store-shim.production.min.cjs.map +1 -0
- package/dist/dev/_virtual/use-sync-external-store-shim.production.min.js +5 -0
- package/dist/dev/_virtual/use-sync-external-store-shim.production.min.js.map +1 -0
- package/dist/dev/_virtual/with-selector.cjs +5 -0
- package/dist/dev/_virtual/with-selector.cjs.map +1 -0
- package/dist/dev/_virtual/with-selector.development.cjs +5 -0
- package/dist/dev/_virtual/with-selector.development.cjs.map +1 -0
- package/dist/dev/_virtual/with-selector.development.js +5 -0
- package/dist/dev/_virtual/with-selector.development.js.map +1 -0
- package/dist/dev/_virtual/with-selector.js +5 -0
- package/dist/dev/_virtual/with-selector.js.map +1 -0
- package/dist/dev/_virtual/with-selector.production.min.cjs +5 -0
- package/dist/dev/_virtual/with-selector.production.min.cjs.map +1 -0
- package/dist/dev/_virtual/with-selector.production.min.js +5 -0
- package/dist/dev/_virtual/with-selector.production.min.js.map +1 -0
- package/dist/dev/cart-constants.cjs +17 -0
- package/dist/dev/cart-constants.cjs.map +1 -0
- package/dist/dev/cart-constants.js +17 -0
- package/dist/dev/cart-constants.js.map +1 -0
- package/dist/dev/cart-hooks.cjs +48 -0
- package/dist/dev/cart-hooks.cjs.map +1 -0
- package/dist/dev/cart-hooks.js +48 -0
- package/dist/dev/cart-hooks.js.map +1 -0
- package/dist/dev/cart-queries.cjs +114 -0
- package/dist/dev/cart-queries.cjs.map +1 -0
- package/dist/dev/cart-queries.js +114 -0
- package/dist/dev/cart-queries.js.map +1 -0
- package/dist/dev/flatten-connection.cjs +6 -0
- package/dist/dev/flatten-connection.cjs.map +1 -1
- package/dist/dev/flatten-connection.js +6 -0
- package/dist/dev/flatten-connection.js.map +1 -1
- package/dist/dev/index.cjs +3 -0
- package/dist/dev/index.cjs.map +1 -1
- package/dist/dev/index.js +3 -0
- package/dist/dev/index.js.map +1 -1
- package/dist/dev/load-script.cjs +3 -3
- package/dist/dev/load-script.cjs.map +1 -1
- package/dist/dev/node_modules/@xstate/fsm/es/index.cjs +158 -0
- package/dist/dev/node_modules/@xstate/fsm/es/index.cjs.map +1 -0
- package/dist/dev/node_modules/@xstate/fsm/es/index.js +159 -0
- package/dist/dev/node_modules/@xstate/fsm/es/index.js.map +1 -0
- package/dist/dev/node_modules/@xstate/react/es/fsm.cjs +94 -0
- package/dist/dev/node_modules/@xstate/react/es/fsm.cjs.map +1 -0
- package/dist/dev/node_modules/@xstate/react/es/fsm.js +94 -0
- package/dist/dev/node_modules/@xstate/react/es/fsm.js.map +1 -0
- package/dist/dev/node_modules/@xstate/react/es/useConstant.cjs +30 -0
- package/dist/dev/node_modules/@xstate/react/es/useConstant.cjs.map +1 -0
- package/dist/dev/node_modules/@xstate/react/es/useConstant.js +12 -0
- package/dist/dev/node_modules/@xstate/react/es/useConstant.js.map +1 -0
- package/dist/dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.cjs +5 -0
- package/dist/dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.cjs.map +1 -0
- package/dist/dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js +6 -0
- package/dist/dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js.map +1 -0
- package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.cjs +107 -0
- package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.cjs.map +1 -0
- package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +105 -0
- package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js.map +1 -0
- package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.cjs +74 -0
- package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.cjs.map +1 -0
- package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js +72 -0
- package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js.map +1 -0
- package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.cjs +138 -0
- package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.cjs.map +1 -0
- package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +136 -0
- package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +1 -0
- package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.cjs +60 -0
- package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.cjs.map +1 -0
- package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js +58 -0
- package/dist/dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js.map +1 -0
- package/dist/dev/node_modules/use-sync-external-store/shim/index.cjs +21 -0
- package/dist/dev/node_modules/use-sync-external-store/shim/index.cjs.map +1 -0
- package/dist/dev/node_modules/use-sync-external-store/shim/index.js +21 -0
- package/dist/dev/node_modules/use-sync-external-store/shim/index.js.map +1 -0
- package/dist/dev/node_modules/use-sync-external-store/shim/with-selector.cjs +12 -0
- package/dist/dev/node_modules/use-sync-external-store/shim/with-selector.cjs.map +1 -0
- package/dist/dev/node_modules/use-sync-external-store/shim/with-selector.js +11 -0
- package/dist/dev/node_modules/use-sync-external-store/shim/with-selector.js.map +1 -0
- package/dist/dev/node_modules/worktop/cookie/index.cjs +27 -0
- package/dist/dev/node_modules/worktop/cookie/index.cjs.map +1 -0
- package/dist/dev/node_modules/worktop/cookie/index.js +27 -0
- package/dist/dev/node_modules/worktop/cookie/index.js.map +1 -0
- package/dist/dev/storefront-api-constants.cjs +1 -1
- package/dist/dev/storefront-api-constants.cjs.map +1 -1
- package/dist/dev/storefront-api-constants.js +1 -1
- package/dist/dev/storefront-api-constants.js.map +1 -1
- package/dist/dev/useCartAPIStateMachine.cjs +326 -0
- package/dist/dev/useCartAPIStateMachine.cjs.map +1 -0
- package/dist/dev/useCartAPIStateMachine.js +326 -0
- package/dist/dev/useCartAPIStateMachine.js.map +1 -0
- package/dist/dev/useCartActions.cjs +123 -0
- package/dist/dev/useCartActions.cjs.map +1 -0
- package/dist/dev/useCartActions.js +123 -0
- package/dist/dev/useCartActions.js.map +1 -0
- package/dist/dev/useMoney.cjs +5 -5
- package/dist/dev/useMoney.cjs.map +1 -1
- package/dist/prod/CartProvider.cjs +485 -0
- package/dist/prod/CartProvider.cjs.map +1 -0
- package/dist/prod/CartProvider.js +485 -0
- package/dist/prod/CartProvider.js.map +1 -0
- package/dist/prod/MediaFile.cjs.map +1 -1
- package/dist/prod/MediaFile.js.map +1 -1
- package/dist/prod/Metafield.cjs +2 -2
- package/dist/prod/Metafield.cjs.map +1 -1
- package/dist/prod/Metafield.js.map +1 -1
- package/dist/prod/ModelViewer.cjs +4 -4
- package/dist/prod/ModelViewer.cjs.map +1 -1
- package/dist/prod/Money.cjs.map +1 -1
- package/dist/prod/Money.js.map +1 -1
- package/dist/prod/ProductPrice.cjs.map +1 -1
- package/dist/prod/ProductPrice.js.map +1 -1
- package/dist/prod/ProductProvider.cjs +14 -14
- package/dist/prod/ProductProvider.cjs.map +1 -1
- package/dist/prod/ShopPayButton.cjs.map +1 -1
- package/dist/prod/ShopPayButton.js.map +1 -1
- package/dist/prod/ShopifyProvider.cjs +4 -4
- package/dist/prod/ShopifyProvider.cjs.map +1 -1
- package/dist/prod/Video.cjs +2 -2
- package/dist/prod/_virtual/index.cjs +5 -0
- package/dist/prod/_virtual/index.cjs.map +1 -0
- package/dist/prod/_virtual/index.js +5 -0
- package/dist/prod/_virtual/index.js.map +1 -0
- package/dist/prod/_virtual/use-sync-external-store-shim.development.cjs +5 -0
- package/dist/prod/_virtual/use-sync-external-store-shim.development.cjs.map +1 -0
- package/dist/prod/_virtual/use-sync-external-store-shim.development.js +5 -0
- package/dist/prod/_virtual/use-sync-external-store-shim.development.js.map +1 -0
- package/dist/prod/_virtual/use-sync-external-store-shim.production.min.cjs +5 -0
- package/dist/prod/_virtual/use-sync-external-store-shim.production.min.cjs.map +1 -0
- package/dist/prod/_virtual/use-sync-external-store-shim.production.min.js +5 -0
- package/dist/prod/_virtual/use-sync-external-store-shim.production.min.js.map +1 -0
- package/dist/prod/_virtual/with-selector.cjs +5 -0
- package/dist/prod/_virtual/with-selector.cjs.map +1 -0
- package/dist/prod/_virtual/with-selector.development.cjs +5 -0
- package/dist/prod/_virtual/with-selector.development.cjs.map +1 -0
- package/dist/prod/_virtual/with-selector.development.js +5 -0
- package/dist/prod/_virtual/with-selector.development.js.map +1 -0
- package/dist/prod/_virtual/with-selector.js +5 -0
- package/dist/prod/_virtual/with-selector.js.map +1 -0
- package/dist/prod/_virtual/with-selector.production.min.cjs +5 -0
- package/dist/prod/_virtual/with-selector.production.min.cjs.map +1 -0
- package/dist/prod/_virtual/with-selector.production.min.js +5 -0
- package/dist/prod/_virtual/with-selector.production.min.js.map +1 -0
- package/dist/prod/cart-constants.cjs +17 -0
- package/dist/prod/cart-constants.cjs.map +1 -0
- package/dist/prod/cart-constants.js +17 -0
- package/dist/prod/cart-constants.js.map +1 -0
- package/dist/prod/cart-hooks.cjs +48 -0
- package/dist/prod/cart-hooks.cjs.map +1 -0
- package/dist/prod/cart-hooks.js +48 -0
- package/dist/prod/cart-hooks.js.map +1 -0
- package/dist/prod/cart-queries.cjs +114 -0
- package/dist/prod/cart-queries.cjs.map +1 -0
- package/dist/prod/cart-queries.js +114 -0
- package/dist/prod/cart-queries.js.map +1 -0
- package/dist/prod/flatten-connection.cjs +7 -0
- package/dist/prod/flatten-connection.cjs.map +1 -1
- package/dist/prod/flatten-connection.js +7 -0
- package/dist/prod/flatten-connection.js.map +1 -1
- package/dist/prod/index.cjs +3 -0
- package/dist/prod/index.cjs.map +1 -1
- package/dist/prod/index.js +3 -0
- package/dist/prod/index.js.map +1 -1
- package/dist/prod/load-script.cjs +3 -3
- package/dist/prod/load-script.cjs.map +1 -1
- package/dist/prod/node_modules/@xstate/fsm/es/index.cjs +158 -0
- package/dist/prod/node_modules/@xstate/fsm/es/index.cjs.map +1 -0
- package/dist/prod/node_modules/@xstate/fsm/es/index.js +159 -0
- package/dist/prod/node_modules/@xstate/fsm/es/index.js.map +1 -0
- package/dist/prod/node_modules/@xstate/react/es/fsm.cjs +94 -0
- package/dist/prod/node_modules/@xstate/react/es/fsm.cjs.map +1 -0
- package/dist/prod/node_modules/@xstate/react/es/fsm.js +94 -0
- package/dist/prod/node_modules/@xstate/react/es/fsm.js.map +1 -0
- package/dist/prod/node_modules/@xstate/react/es/useConstant.cjs +30 -0
- package/dist/prod/node_modules/@xstate/react/es/useConstant.cjs.map +1 -0
- package/dist/prod/node_modules/@xstate/react/es/useConstant.js +12 -0
- package/dist/prod/node_modules/@xstate/react/es/useConstant.js.map +1 -0
- package/dist/prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.cjs +5 -0
- package/dist/prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.cjs.map +1 -0
- package/dist/prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js +6 -0
- package/dist/prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.browser.esm.js.map +1 -0
- package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.cjs +107 -0
- package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.cjs.map +1 -0
- package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +105 -0
- package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js.map +1 -0
- package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.cjs +74 -0
- package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.cjs.map +1 -0
- package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js +72 -0
- package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js.map +1 -0
- package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.cjs +138 -0
- package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.cjs.map +1 -0
- package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +136 -0
- package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +1 -0
- package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.cjs +60 -0
- package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.cjs.map +1 -0
- package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js +58 -0
- package/dist/prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js.map +1 -0
- package/dist/prod/node_modules/use-sync-external-store/shim/index.cjs +21 -0
- package/dist/prod/node_modules/use-sync-external-store/shim/index.cjs.map +1 -0
- package/dist/prod/node_modules/use-sync-external-store/shim/index.js +21 -0
- package/dist/prod/node_modules/use-sync-external-store/shim/index.js.map +1 -0
- package/dist/prod/node_modules/use-sync-external-store/shim/with-selector.cjs +12 -0
- package/dist/prod/node_modules/use-sync-external-store/shim/with-selector.cjs.map +1 -0
- package/dist/prod/node_modules/use-sync-external-store/shim/with-selector.js +11 -0
- package/dist/prod/node_modules/use-sync-external-store/shim/with-selector.js.map +1 -0
- package/dist/prod/node_modules/worktop/cookie/index.cjs +27 -0
- package/dist/prod/node_modules/worktop/cookie/index.cjs.map +1 -0
- package/dist/prod/node_modules/worktop/cookie/index.js +27 -0
- package/dist/prod/node_modules/worktop/cookie/index.js.map +1 -0
- package/dist/prod/storefront-api-constants.cjs +1 -1
- package/dist/prod/storefront-api-constants.cjs.map +1 -1
- package/dist/prod/storefront-api-constants.js +1 -1
- package/dist/prod/storefront-api-constants.js.map +1 -1
- package/dist/prod/useCartAPIStateMachine.cjs +326 -0
- package/dist/prod/useCartAPIStateMachine.cjs.map +1 -0
- package/dist/prod/useCartAPIStateMachine.js +326 -0
- package/dist/prod/useCartAPIStateMachine.js.map +1 -0
- package/dist/prod/useCartActions.cjs +123 -0
- package/dist/prod/useCartActions.cjs.map +1 -0
- package/dist/prod/useCartActions.js +123 -0
- package/dist/prod/useCartActions.js.map +1 -0
- package/dist/prod/useMoney.cjs +5 -5
- package/dist/prod/useMoney.cjs.map +1 -1
- package/dist/types/CartProvider.d.ts +61 -0
- package/dist/types/MediaFile.d.ts +0 -1
- package/dist/types/Money.d.ts +1 -1
- package/dist/types/ProductPrice.d.ts +0 -1
- package/dist/types/cart-constants.d.ts +8 -0
- package/dist/types/cart-hooks.d.ts +24 -0
- package/dist/types/cart-queries.d.ts +10 -0
- package/dist/types/cart-types.d.ts +289 -0
- package/dist/types/flatten-connection.d.ts +3 -1
- package/dist/types/index.d.cts +2 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/storefront-api-constants.d.ts +1 -1
- package/dist/types/storefront-api-types.d.ts +278 -73
- package/dist/types/useCartAPIStateMachine.d.ts +25 -0
- package/dist/types/useCartActions.d.ts +64 -0
- package/dist/umd/hydrogen-react.dev.js +1815 -109
- package/dist/umd/hydrogen-react.dev.js.map +1 -1
- package/dist/umd/hydrogen-react.prod.js +239 -2
- package/dist/umd/hydrogen-react.prod.js.map +1 -1
- package/package.json +24 -12
- package/storefront.schema.json +1 -1
|
@@ -1,3 +1,240 @@
|
|
|
1
|
-
(function(b,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],g):(b=typeof globalThis<"u"?globalThis:b||self,g(b.hydrogenreact={},b.React))})(this,function(b,g){"use strict";const Q=e=>e&&typeof e=="object"&&"default"in e?e:{default:e};function R(e){if(e&&e.__esModule)return e;const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,i.get?i:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const h=Q(g),ee=R(g);var re="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ExternalVideo.tsx";function F(e){var d,f;const{data:r,options:t,id:i=r.id,frameBorder:a="0",allow:o="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:u=!0,loading:n="lazy",...l}=e;if(!r.embedUrl)throw new Error("<ExternalVideo/> requires the 'embedUrl' property");let c=r.embedUrl;if(t){const m=new URL(r.embedUrl);for(const y of Object.keys(t))m.searchParams.set(y,t[y]);c=m.toString()}return h.default.createElement("iframe",{...l,id:i!=null?i:r.embedUrl,title:(f=(d=r.alt)!=null?d:r.id)!=null?f:"external video",frameBorder:a,allow:o,allowFullScreen:u,src:c,loading:n,__self:this,__source:{fileName:re,lineNumber:56,columnNumber:5}})}function E(e){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 ne=["cdn.shopify.com","cdn.shopifycdn.net","shopify-assets.shopifycdn.com","shopify-assets.shopifycdn.net"],te=["spin.dev"],oe=[...ne,...te],M=[352,832,1200,1920,2560];function D({src:e,width:r,height:t,crop:i,scale:a}){const o=new URL(e),u=a!=null?a:1;if(r){let n;typeof r=="string"?n=(M[0]*u).toString():n=(Number(r)*u).toString(),o.searchParams.append("width",n)}return t&&typeof t=="number"&&o.searchParams.append("height",(t*u).toString()),i&&o.searchParams.append("crop",i),o.toString()}function j(e){const r=new URL(e.src);return!oe.some(i=>r.hostname.endsWith(i))||!e.width&&!e.height&&!e.crop&&!e.scale?e.src:D(e)}function ie({data:e,loaderOptions:r,elementProps:t}){var a,o,u,n,l,c;let i=null;return(e==null?void 0:e.width)&&(e==null?void 0:e.height)&&(i=(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:(a=r==null?void 0:r.width)!=null?a:i&&typeof r.height=="number"?Math.round(i*r.height):null,height:(o=r==null?void 0:r.height)!=null?o:i&&typeof r.width=="number"?Math.round(i*r.width):null}:(t==null?void 0:t.width)||(t==null?void 0:t.height)?{width:(u=t==null?void 0:t.width)!=null?u:i&&typeof t.height=="number"?Math.round(i*t.height):null,height:(n=t==null?void 0:t.height)!=null?n:i&&typeof t.width=="number"?Math.round(i*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:(c=e==null?void 0:e.height)!=null?c:null}:{width:null,height:null}}var ae="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/Image.tsx";function P({data:e,width:r,height:t,loading:i,loader:a=j,loaderOptions:o,widths:u,decoding:n="async",...l}){var N,v,s,_,S,p;if(!e.url){const A=`<Image/>: the 'data' prop requires the 'url' property. Image: ${(N=e.id)!=null?N:"no ID provided"}`;return console.error(A),null}const{width:c,height:d}=ie({data:e,loaderOptions:o,elementProps:{width:r,height:t}});let f=e.url;if(a&&(f=a({...o,src:e.url,width:c,height:d}),typeof f!="string"||!f))throw new Error(`<Image/>: 'loader' did not return a valid string. Image: ${(v=e.id)!=null?v:e.url}`);const m=r&&c&&r<c?r:c,y=(s=l.srcSet)!=null?s:ue({...o,widths:u,src:e.url,width:m,height:d,loader:a});return ee.createElement("img",{id:(_=e.id)!=null?_:"",alt:(p=(S=e.altText)!=null?S:l.alt)!=null?p:"",loading:i!=null?i:"lazy",...l,src:f,width:c!=null?c:void 0,height:d!=null?d:void 0,srcSet:y,decoding:n,__self:this,__source:{fileName:ae,lineNumber:150,columnNumber:5}})}function ue({src:e,width:r,crop:t,scale:i,widths:a,loader:o,height:u}){const n=a&&Array.isArray(a);if(n&&a.some(f=>isNaN(f)))throw new Error(`<Image/>: the 'widths' must be an array of numbers. Image: ${e}`);let l=1;r&&u&&(l=Number(u)/Number(r));let c=n?a:M;!n&&r&&r<M[M.length-1]&&(c=M.filter(f=>f<=r));const d=o||D;return c.map(f=>`${d({src:e,width:f,height:t?Number(f)*l:void 0,crop:t,scale:i})} ${f}w`).join(", ")}var U="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/Video.tsx";function x(e){var c,d;const{data:r,previewImageOptions:t,id:i=r.id,playsInline:a=!0,controls:o=!0,sourceProps:u={},...n}=e,l=j({src:(d=(c=r.previewImage)==null?void 0:c.url)!=null?d:"",...t});if(!r.sources)throw new Error("<Video/> requires a 'data.sources' array");return h.default.createElement("video",{...n,id:i,playsInline:a,controls:o,poster:l,__self:this,__source:{fileName:U,lineNumber:42,columnNumber:5}},r.sources.map(f=>{if(!((f==null?void 0:f.url)&&(f==null?void 0:f.mimeType)))throw new Error("<Video/> needs 'source.url' and 'source.mimeType'");return h.default.createElement("source",{...u,key:f.url,src:f.url,type:f.mimeType,__self:this,__source:{fileName:U,lineNumber:54,columnNumber:11}})}))}const $={};function le(e,r){const t=$[e];if(t)return t;const i=new Promise((a,o)=>{const u=document.createElement("script");r!=null&&r.module?u.type="module":u.type="text/javascript",u.src=e,u.onload=()=>{a(!0)},u.onerror=()=>{o(!1)},(r==null?void 0:r.in)==="head"?document.head.appendChild(u):document.body.appendChild(u)});return $[e]=i,i}function q(e,r){const[t,i]=g.useState("loading"),a=JSON.stringify(r);return g.useEffect(()=>{async function o(){try{i("loading"),await le(e,r),i("done")}catch{i("error")}}o()},[e,a,r]),t}var ce="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ModelViewer.tsx";function W(e){var c,d,f,m,y,N,v,s,_,S,p;const[r,t]=g.useState(void 0),i=g.useCallback(A=>{t(A)},[]),{data:a,children:o,className:u,...n}=e,l=q("https://unpkg.com/@google/model-viewer@v1.12.1/dist/model-viewer.min.js",{module:!0});return g.useEffect(()=>{if(!!r)return n.onError&&r.addEventListener("error",n.onError),n.onLoad&&r.addEventListener("load",n.onLoad),n.onPreload&&r.addEventListener("preload",n.onPreload),n.onModelVisibility&&r.addEventListener("model-visibility",n.onModelVisibility),n.onProgress&&r.addEventListener("progress",n.onProgress),n.onArStatus&&r.addEventListener("ar-status",n.onArStatus),n.onArTracking&&r.addEventListener("ar-tracking",n.onArTracking),n.onQuickLookButtonTapped&&r.addEventListener("quick-look-button-tapped",n.onQuickLookButtonTapped),n.onCameraChange&&r.addEventListener("camera-change",n.onCameraChange),n.onEnvironmentChange&&r.addEventListener("environment-change",n.onEnvironmentChange),n.onPlay&&r.addEventListener("play",n.onPlay),n.onPause&&r.addEventListener("ar-status",n.onPause),n.onSceneGraphReady&&r.addEventListener("scene-graph-ready",n.onSceneGraphReady),()=>{r!=null&&(n.onError&&r.removeEventListener("error",n.onError),n.onLoad&&r.removeEventListener("load",n.onLoad),n.onPreload&&r.removeEventListener("preload",n.onPreload),n.onModelVisibility&&r.removeEventListener("model-visibility",n.onModelVisibility),n.onProgress&&r.removeEventListener("progress",n.onProgress),n.onArStatus&&r.removeEventListener("ar-status",n.onArStatus),n.onArTracking&&r.removeEventListener("ar-tracking",n.onArTracking),n.onQuickLookButtonTapped&&r.removeEventListener("quick-look-button-tapped",n.onQuickLookButtonTapped),n.onCameraChange&&r.removeEventListener("camera-change",n.onCameraChange),n.onEnvironmentChange&&r.removeEventListener("environment-change",n.onEnvironmentChange),n.onPlay&&r.removeEventListener("play",n.onPlay),n.onPause&&r.removeEventListener("ar-status",n.onPause),n.onSceneGraphReady&&r.removeEventListener("scene-graph-ready",n.onSceneGraphReady))}},[r,n.onArStatus,n.onArTracking,n.onCameraChange,n.onEnvironmentChange,n.onError,n.onLoad,n.onModelVisibility,n.onPause,n.onPlay,n.onPreload,n.onProgress,n.onQuickLookButtonTapped,n.onSceneGraphReady]),l!=="done"?null:(d=(c=a.sources)==null?void 0:c[0])!=null&&d.url?h.default.createElement("model-viewer",{ref:i,...n,className:u,id:(f=n.id)!=null?f:a.id,src:a.sources[0].url,alt:(m=a.alt)!=null?m:null,"camera-controls":(y=n.cameraControls)!=null?y:!0,poster:(v=n.poster||((N=a.previewImage)==null?void 0:N.url))!=null?v:null,autoplay:(s=n.autoplay)!=null?s:!0,loading:n.loading,reveal:n.reveal,ar:n.ar,"ar-modes":n.arModes,"ar-scale":n.arScale,"ar-placement":n.arPlacement,"ios-src":n.iosSrc,"touch-action":n.touchAction,"disable-zoom":n.disableZoom,"orbit-sensitivity":n.orbitSensitivity,"auto-rotate":n.autoRotate,"auto-rotate-delay":n.autoRotateDelay,"rotation-per-second":n.rotationPerSecond,"interaction-policy":n.interactionPolicy,"interaction-prompt":n.interactionPrompt,"interaction-prompt-style":n.interactionPromptStyle,"interaction-prompt-threshold":n.interactionPromptThreshold,"camera-orbit":n.cameraOrbit,"camera-target":n.cameraTarget,"field-of-view":n.fieldOfView,"max-camera-orbit":n.maxCameraOrbit,"min-camera-orbit":n.minCameraOrbit,"max-field-of-view":n.maxFieldOfView,"min-field-of-view":n.minFieldOfView,bounds:n.bounds,"interpolation-decay":(_=n.interpolationDecay)!=null?_:100,"skybox-image":n.skyboxImage,"environment-image":n.environmentImage,exposure:n.exposure,"shadow-intensity":(S=n.shadowIntensity)!=null?S:0,"shadow-softness":(p=n.shadowSoftness)!=null?p:0,"animation-name":n.animationName,"animation-crossfade-duration":n.animationCrossfadeDuration,"variant-name":n.variantName,orientation:n.orientation,scale:n.scale,__self:this,__source:{fileName:ce,lineNumber:222,columnNumber:5}},o):(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 T="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/MediaFile.tsx";function se({data:e,mediaOptions:r,...t}){switch(e.__typename){case"MediaImage":return e.image?h.default.createElement(P,{...t,...r==null?void 0:r.image,data:e.image,__self:this,__source:{fileName:T,lineNumber:51,columnNumber:9}}):(console.warn("<MediaFile/>: 'data.image' does not exist for __typename of 'MediaImage'; rendering 'null' by default."),null);case"Video":return h.default.createElement(x,{...t,...r==null?void 0:r.video,data:e,__self:this,__source:{fileName:T,lineNumber:60,columnNumber:9}});case"ExternalVideo":return h.default.createElement(F,{...t,...r==null?void 0:r.externalVideo,data:e,__self:this,__source:{fileName:T,lineNumber:65,columnNumber:9}});case"Model3d":return h.default.createElement(W,{...t,...r==null?void 0:r.modelViewer,data:e,__self:this,__source:{fileName:T,lineNumber:74,columnNumber:9}});default:return console.error("<MediaFile /> requires the '__typename' property to exist on the 'data' prop in order to correctly render the correct component for this media. Rendering 'null' by default"),null}}const C="2022-07";var fe="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ShopifyProvider.tsx";const I=g.createContext({storeDomain:"test.myshopify.com",storefrontToken:"abc123",storefrontApiVersion:C,country:{isoCode:"US"},language:{isoCode:"EN"},locale:"EN-US"});function me({children:e,shopifyConfig:r}){if(!r)throw new Error("The 'shopifyConfig' prop must be passed to '<ShopifyProvider/>'");r.storefrontApiVersion!==C&&console.warn(`This version of Hydrogen-UI is built for Shopify's Storefront API version ${C}, 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(()=>({...r,storeDomain:r.storeDomain.replace(/^https?:\/\//,"")}),[r]);return h.default.createElement(I.Provider,{value:t,__self:this,__source:{fileName:fe,lineNumber:49,columnNumber:5}},e)}function L(){const e=g.useContext(I);if(!e)throw new Error("'useShop()' must be a descendent of <ShopifyProvider/>");return e}var w="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/Metafield.tsx";function de(e){var n,l,c,d,f,m,y,N,v;const{data:r,as:t,...i}=e,{locale:a}=L(),o=g.useMemo(()=>B(r),[r]);if(!o)return console.warn("<Metafield/>: nothing was passed to the data prop 'data'. Rendering 'null'"),null;if(o.value===null||o.value===void 0){const s=`<Metafield/>: No metafield value for metafield ${(n=o.id)!=null?n:o.key}. Rendering 'null'`;return console.warn(s),null}switch(o.type){case"date":{const s=t!=null?t:"time";return h.default.createElement(s,{...i,__self:this,__source:{fileName:w,lineNumber:68,columnNumber:9}},o.value.toLocaleDateString(a))}case"date_time":{const s=t!=null?t:"time";return h.default.createElement(s,{...i,__self:this,__source:{fileName:w,lineNumber:76,columnNumber:9}},o.value.toLocaleString(a))}case"weight":case"dimension":case"volume":{const s=t!=null?t:"span";return h.default.createElement(s,{...i,__self:this,__source:{fileName:w,lineNumber:86,columnNumber:9}},_e(o.value,a))}case"rating":{const s=t!=null?t:"span";return h.default.createElement(s,{...i,__self:this,__source:{fileName:w,lineNumber:94,columnNumber:9}},o.value.value)}case"single_line_text_field":{const s=t!=null?t:"span";return h.default.createElement(s,{...i,dangerouslySetInnerHTML:{__html:o.value},__self:this,__source:{fileName:w,lineNumber:102,columnNumber:9}})}case"multi_line_text_field":{const s=t!=null?t:"div";return h.default.createElement(s,{...i,dangerouslySetInnerHTML:{__html:o.value.split(`
|
|
2
|
-
`).join("<br/>")},__self:this,__source:{fileName:w,lineNumber:111,columnNumber:9}})}case"url":{const s=new URL(o.value);return h.default.createElement("a",{href:s.href.replace(s.protocol,""),...i,__self:this,__source:{fileName:w,lineNumber:122,columnNumber:9}},o.value)}case"json":{const s=t!=null?t:"span";return h.default.createElement(s,{...i,__self:this,__source:{fileName:w,lineNumber:133,columnNumber:9}},JSON.stringify(o.value))}case"product_reference":case"variant_reference":case"page_reference":{const s=t!=null?t:"span",_=o.reference;return h.default.createElement(s,{...i,__self:this,__source:{fileName:w,lineNumber:144,columnNumber:9}},(c=(l=_==null?void 0:_.title)!=null?l:_==null?void 0:_.id)!=null?c:"")}case"list.single_line_text_field":{const s=t!=null?t:"ul",_=o.references?E(o.references):[];return h.default.createElement(s,{...i,__self:this,__source:{fileName:w,lineNumber:155,columnNumber:9}},_.map((S,p)=>h.default.createElement("li",{key:`${S!=null?S:""}-${p}`,__self:this,__source:{fileName:w,lineNumber:159,columnNumber:13}},S)))}case"file_reference":if(((d=o.reference)==null?void 0:d.__typename)==="MediaImage"){const s=o.reference;return s.image?h.default.createElement(P,{data:s.image,...i,__self:this,__source:{fileName:w,lineNumber:168,columnNumber:11}}):null}else if(((f=o.reference)==null?void 0:f.__typename)==="GenericFile"){const s=o.reference;return s.previewImage?h.default.createElement("a",{href:(y=(m=o.reference)==null?void 0:m.url)!=null?y:"",...i,__self:this,__source:{fileName:w,lineNumber:173,columnNumber:11}},h.default.createElement(P,{data:s.previewImage,__self:this,__source:{fileName:w,lineNumber:174,columnNumber:13}})):null}else if(((N=o.reference)==null?void 0:N.__typename)==="Video"){const s=o.reference;return h.default.createElement(x,{...i,data:s,__self:this,__source:{fileName:w,lineNumber:179,columnNumber:16}})}}const u=t!=null?t:"span";return h.default.createElement(u,{...i,__self:this,__source:{fileName:w,lineNumber:186,columnNumber:5}},(v=o.value)==null?void 0:v.toString())}function B(e){return e?{...e,value:H(e)}:null}function H(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 he(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 he(e){return String(e).includes("__proto__")?JSON.parse(e,(r,t)=>{if(r!=="__proto__")return t}):JSON.parse(e)}const ge={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 _e(e,r="en-us",t={}){let i={value:e.value,unit:ge[e.unit]};return i.unit==null&&(i=ye(e.value,e.unit)),new Intl.NumberFormat(r,{...t,unit:i.unit,style:"unit"}).format(i.value)}function ye(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 z(e){const{locale:r}=L();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),i=g.useMemo(()=>({style:"currency",currency:e.currencyCode}),[e.currencyCode]),a=k(r,i),o=k(r,{...i,currencyDisplay:"name"}),u=k(r,{...i,currencyDisplay:"narrowSymbol"}),n=k(r,{...i,minimumFractionDigits:0,maximumFractionDigits:0}),l=k(r),c=k(r,{minimumFractionDigits:0,maximumFractionDigits:0}),d=m=>m.type==="currency",f=g.useMemo(()=>({original:()=>e,currencyCode:()=>e.currencyCode,localizedString:()=>a().format(t),parts:()=>a().formatToParts(t),withoutTrailingZeros:()=>t%1===0?n().format(t):a().format(t),withoutTrailingZerosAndCurrency:()=>t%1===0?c().format(t):l().format(t),currencyName:()=>{var m,y;return(y=(m=o().formatToParts(t).find(d))==null?void 0:m.value)!=null?y:e.currencyCode},currencySymbol:()=>{var m,y;return(y=(m=a().formatToParts(t).find(d))==null?void 0:m.value)!=null?y:e.currencyCode},currencyNarrowSymbol:()=>{var m,y;return(y=(m=u().formatToParts(t).find(d))==null?void 0:m.value)!=null?y:""},amount:()=>a().formatToParts(t).filter(m=>["decimal","fraction","group","integer","literal"].includes(m.type)).map(m=>m.value).join("")}),[e,t,o,a,u,l,n,c]);return g.useMemo(()=>new Proxy(f,{get:(m,y)=>{var N;return(N=Reflect.get(m,y))==null?void 0:N.call(null)}}),[f])}function k(e,r){return g.useMemo(()=>{let t;return()=>t!=null?t:t=new Intl.NumberFormat(e,r)},[e,r])}var be="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/Money.tsx";function V({data:e,as:r,withoutCurrency:t,withoutTrailingZeros:i,measurement:a,measurementSeparator:o="/",...u}){if(!Se(e))throw new Error("<Money/> needs a valid 'data' prop that has 'amount' and 'currencyCode'");const n=z(e),l=r!=null?r:"div";let c=n.localizedString;return(t||i)&&(t&&!i?c=n.amount:!t&&i?c=n.withoutTrailingZeros:c=n.withoutTrailingZerosAndCurrency),h.default.createElement(l,{...u,__self:this,__source:{fileName:be,lineNumber:65,columnNumber:5}},c,a&&a.referenceUnit&&h.default.createElement(h.default.Fragment,null,o,a.referenceUnit))}function Se(e){return typeof e.amount=="string"&&!!e.amount&&typeof e.currencyCode=="string"&&!!e.currencyCode}var G="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ProductPrice.tsx";function Ne(e){var c,d,f,m,y,N,v,s;const{priceType:r="regular",variantId:t,valueType:i="min",data:a,...o}=e;if(a==null)throw new Error("<ProductPrice/> requires a product as the 'data' prop");let u,n;const l=t&&(d=E((c=a==null?void 0:a.variants)!=null?c:{}).find(_=>(_==null?void 0:_.id)===t))!=null?d:null;if(r==="compareAt")if(t&&l){if(((f=l.compareAtPriceV2)==null?void 0:f.amount)===((m=l.priceV2)==null?void 0:m.amount))return null;u=l.compareAtPriceV2}else i==="max"?u=(y=a==null?void 0:a.compareAtPriceRange)==null?void 0:y.maxVariantPrice:u=(N=a==null?void 0:a.compareAtPriceRange)==null?void 0:N.minVariantPrice;else t&&l?(u=l.priceV2,i==="unit"&&(u=l.unitPrice,n=l.unitPriceMeasurement)):i==="max"?u=(v=a.priceRange)==null?void 0:v.maxVariantPrice:u=(s=a.priceRange)==null?void 0:s.minVariantPrice;return u?n?h.default.createElement(V,{...o,data:u,measurement:n,__self:this,__source:{fileName:G,lineNumber:82,columnNumber:7}}):h.default.createElement(V,{...o,data:u,__self:this,__source:{fileName:G,lineNumber:86,columnNumber:10}}):null}var we="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ProductProvider.tsx";const O=g.createContext(null);function pe({children:e,data:r,initialVariantId:t}){const i=g.useMemo(()=>{var s;return E((s=r.variants)!=null?s:{})},[r.variants]);if(!ke(i))throw new Error("<ProductProvider/> requires 'product.variants.nodes' or 'product.variants.edges'");const a=g.useMemo(()=>Ee(i),[i]),[o,u]=g.useState(()=>J(t,i)),[n,l]=g.useState(()=>K(o));g.useEffect(()=>{const s=J(t,i);u(s),l(K(s))},[t,i]);const c=g.useCallback((s,_)=>{l(S=>{const p={...S,[s]:_};return u(X(i,p)),p})},[l,i]),d=g.useCallback((s,_)=>{var p;const S=X(i,{...n,[s]:_});return(p=S==null?void 0:S.availableForSale)!=null?p:!0},[n,i]),f=g.useMemo(()=>{var s;return E((s=r.sellingPlanGroups)!=null?s:{}).map(_=>{var S;return{..._,sellingPlans:E((S=_==null?void 0:_.sellingPlans)!=null?S:{})}})},[r.sellingPlanGroups]),[m,y]=g.useState(void 0),N=g.useMemo(()=>{var s,_;if(!(!o||!m)){if(!((s=o.sellingPlanAllocations)!=null&&s.nodes)&&!((_=o.sellingPlanAllocations)!=null&&_.edges))throw new Error("<ProductProvider/>: You must include 'sellingPlanAllocations.nodes' or 'sellingPlanAllocations.edges' in your variants in order to calculate selectedSellingPlanAllocation");return E(o.sellingPlanAllocations).find(S=>{var p;return((p=S==null?void 0:S.sellingPlan)==null?void 0:p.id)===m.id})}},[o,m]),v=g.useMemo(()=>({variants:i,variantsConnection:r.variants,options:a,selectedVariant:o,setSelectedVariant:u,selectedOptions:n,setSelectedOption:c,setSelectedOptions:l,isOptionInStock:d,selectedSellingPlan:m,setSelectedSellingPlan:y,selectedSellingPlanAllocation:N,sellingPlanGroups:f,sellingPlanGroupsConnection:r.sellingPlanGroups}),[d,a,r.sellingPlanGroups,r.variants,n,m,N,o,f,c,i]);return h.default.createElement(O.Provider,{value:v,__self:this,__source:{fileName:we,lineNumber:201,columnNumber:5}},e)}function ve(){const e=g.useContext(O);if(!e)throw new Error("'useProduct' must be a child of <ProductProvider />");return e}function X(e,r){var t,i;if(!(!e.length||((i=(t=e==null?void 0:e[0])==null?void 0:t.selectedOptions)==null?void 0:i.length)!==Object.keys(r).length))return e==null?void 0:e.find(a=>Object.entries(r).every(([o,u])=>{var n;return(n=a==null?void 0:a.selectedOptions)==null?void 0:n.some(l=>(l==null?void 0:l.name)===o&&(l==null?void 0:l.value)===u)}))}function Ee(e){const r=e.reduce((t,i)=>{var a;if(!i.selectedOptions)throw new Error("'getOptions' requires 'variant.selectedOptions'");return(a=i==null?void 0:i.selectedOptions)==null||a.forEach(o=>{var u,n,l,c;t[(u=o==null?void 0:o.name)!=null?u:""]=t[(n=o==null?void 0:o.name)!=null?n:""]||new Set,t[(l=o==null?void 0:o.name)!=null?l:""].add((c=o==null?void 0:o.value)!=null?c:"")}),t},{});return Object.keys(r).map(t=>({name:t,values:Array.from(r[t])}))}function J(e,r){if(e){const t=r.find(i=>(i==null?void 0:i.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 K(e){return e!=null&&e.selectedOptions?e.selectedOptions.reduce((r,t)=>{var i,a;return r[(i=t==null?void 0:t.name)!=null?i:""]=(a=t==null?void 0:t.value)!=null?a:"",r},{}):{}}function ke(e){return!(!e||!Array.isArray(e))}var Y="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ShopPayButton.tsx";const Me="https://cdn.shopify.com/shopifycloud/shop-js/v1.0/client.js";function Ce({variantIds:e,className:r,variantIdsAndQuantities:t,width:i}){const{storeDomain:a}=L(),o=q(Me);let u;if(e&&t)throw new Error(Te);if(e)u=e.reduce((l,c)=>{const d=Z(c);return d&&l.push(d),l},[]);else if(t)u=t.reduce((l,c)=>{var f;const d=Z(c==null?void 0:c.id);return d&&l.push(`${d}:${(f=c==null?void 0:c.quantity)!=null?f:1}`),l},[]);else throw new Error(Pe);const n=i?{"--shop-pay-button-width":i}:void 0;return h.default.createElement("div",{className:r,style:n,__self:this,__source:{fileName:Y,lineNumber:91,columnNumber:5}},o==="done"&&h.default.createElement("shop-pay-button",{"store-url":`https://${a}`,variants:u.join(","),__self:this,__source:{fileName:Y,lineNumber:93,columnNumber:9}}))}function Z(e){if(!!e)return e.split("/").pop()}const Pe='You must pass in either "variantIds" or "variantIdsAndQuantities" to ShopPayButton',Te="You must provide either a variantIds or variantIdsAndQuantities prop, but not both in the ShopPayButton component";function Le({storeDomain:e,privateStorefrontToken:r,publicStorefrontToken:t,storefrontApiVersion:i,contentType:a}){return i!==C&&console.warn(`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: "${i}"; expected version ${C}`),{getStorefrontApiUrl(o){var u,n;return`https://${(u=o==null?void 0:o.storeDomain)!=null?u:e}.myshopify.com/api/${(n=o==null?void 0:o.storefrontApiVersion)!=null?n:i}/graphql.json`},getPrivateTokenHeaders(o){var n,l,c;if(!r&&!(o!=null&&o.privateStorefrontToken))throw new Error("StorefrontClient: You did not pass in a 'privateStorefrontToken' while using 'getPrivateTokenHeaders()'");return{"content-type":((n=o==null?void 0:o.contentType)!=null?n:a)==="graphql"?"application/graphql":"application/json","X-SDK-Variant":"hydrogen-ui","X-SDK-Variant-Source":"react","X-SDK-Version":i,"Shopify-Storefront-Private-Token":(c=(l=o==null?void 0:o.privateStorefrontToken)!=null?l:r)!=null?c:"",...o!=null&&o.buyerIp?{"Shopify-Storefront-Buyer-IP":o.buyerIp}:{}}},getPublicTokenHeaders(o){var n,l,c;if(!t&&!(o!=null&&o.publicStorefrontToken))throw new Error("StorefrontClient: You did not pass in a 'publicStorefrontToken' while using 'getPublicTokenHeaders()'");return{"content-type":((n=o==null?void 0:o.contentType)!=null?n:a)==="graphql"?"application/graphql":"application/json","X-SDK-Variant":"hydrogen-ui","X-SDK-Variant-Source":"react","X-SDK-Version":i,"X-Shopify-Storefront-Access-Token":(c=(l=o==null?void 0:o.publicStorefrontToken)!=null?l:t)!=null?c:""}}}}b.ExternalVideo=F,b.Image=P,b.MediaFile=se,b.Metafield=de,b.ModelViewer=W,b.Money=V,b.ProductPrice=Ne,b.ProductProvider=pe,b.ShopPayButton=Ce,b.ShopifyProvider=me,b.Video=x,b.createStorefrontClient=Le,b.flattenConnection=E,b.parseMetafield=B,b.parseMetafieldValue=H,b.useMoney=z,b.useProduct=ve,b.useShop=L,Object.defineProperties(b,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
1
|
+
(function(U,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],g):(U=typeof globalThis<"u"?globalThis:U||self,g(U.hydrogenreact={},U.React))})(this,function(U,g){"use strict";const fr=e=>e&&typeof e=="object"&&"default"in e?e:{default:e};function yr(e){if(e&&e.__esModule)return e;const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,a.get?a:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const w=fr(g),Se=yr(g);/*! *****************************************************************************
|
|
2
|
+
Copyright (c) Microsoft Corporation.
|
|
3
|
+
|
|
4
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
+
purpose with or without fee is hereby granted.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
+
***************************************************************************** */function ve(e,r){var t=typeof Symbol=="function"&&e[Symbol.iterator];if(!t)return e;var a,o,i=t.call(e),u=[];try{for(;(r===void 0||r-- >0)&&!(a=i.next()).done;)u.push(a.value)}catch(n){o={error:n}}finally{try{a&&!a.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return u}var Y;(function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"})(Y||(Y={}));var be={type:"xstate.init"};function se(e){return e===void 0?[]:[].concat(e)}function Q(e){return{type:"xstate.assign",assignment:e}}function Te(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 Ce(e){return typeof e=="string"?{type:e}:e}function Ae(e,r){return{value:e,context:r,actions:[],changed:!1,matches:ae(e)}}function Ne(e,r,t){var a=r,o=!1;return[e.filter(function(i){if(i.type==="xstate.assign"){o=!0;var u=Object.assign({},a);return typeof i.assignment=="function"?u=i.assignment(a,t):Object.keys(i.assignment).forEach(function(n){u[n]=typeof i.assignment[n]=="function"?i.assignment[n](a,t):i.assignment[n]}),a=u,!1}return!0}),a,o]}function we(e,r){r===void 0&&(r={});var t=ve(Ne(se(e.states[e.initial].entry).map(function(u){return Te(u,r.actions)}),e.context,be),2),a=t[0],o=t[1],i={config:e,_options:r,initialState:{value:e.initial,actions:a,context:o,matches:ae(e.initial)},transition:function(u,n){var l,d,h=typeof u=="string"?{value:u,context:e.context}:u,s=h.value,m=h.context,_=Ce(n),p=e.states[s];if(p.on){var A=se(p.on[_.type]);try{for(var f=function(D){var G=typeof Symbol=="function"&&Symbol.iterator,P=G&&D[G],ue=0;if(P)return P.call(D);if(D&&typeof D.length=="number")return{next:function(){return D&&ue>=D.length&&(D=void 0),{value:D&&D[ue++],done:!D}}};throw new TypeError(G?"Object is not iterable.":"Symbol.iterator is not defined.")}(A),S=f.next();!S.done;S=f.next()){var v=S.value;if(v===void 0)return Ae(s,m);var b=typeof v=="string"?{target:v}:v,c=b.target,y=b.actions,E=y===void 0?[]:y,N=b.cond,I=N===void 0?function(){return!0}:N,C=c===void 0,O=c!=null?c:s,R=e.states[O];if(I(m,_)){var V=ve(Ne((C?se(E):[].concat(p.exit,E,R.entry).filter(function(D){return D})).map(function(D){return Te(D,i._options.actions)}),m,_),3),F=V[0],W=V[1],K=V[2],q=c!=null?c:s;return{value:q,context:W,actions:F,changed:c!==s||F.length>0||K,matches:ae(q)}}}}catch(D){l={error:D}}finally{try{S&&!S.done&&(d=f.return)&&d.call(f)}finally{if(l)throw l.error}}}return Ae(s,m)}};return i}var Ie=function(e,r){return e.actions.forEach(function(t){var a=t.exec;return a&&a(e.context,r)})};function mr(e){var r=e.initialState,t=Y.NotStarted,a=new Set,o={_machine:e,send:function(i){t===Y.Running&&(r=e.transition(r,i),Ie(r,Ce(i)),a.forEach(function(u){return u(r)}))},subscribe:function(i){return a.add(i),i(r),{unsubscribe:function(){return a.delete(i)}}},start:function(i){if(i){var u=typeof i=="object"?i:{context:e.config.context,value:i};r={value:u.value,actions:[],context:u.context,matches:ae(u.value)}}else r=e.initialState;return t=Y.Running,Ie(r,be),o},stop:function(){return t=Y.Stopped,a.clear(),o},get state(){return r},get status(){return t}};return o}var _r=g.useLayoutEffect,Oe={exports:{}},le={},de={exports:{}},fe={};/**
|
|
15
|
+
* @license React
|
|
16
|
+
* use-sync-external-store-shim.production.min.js
|
|
17
|
+
*
|
|
18
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
19
|
+
*
|
|
20
|
+
* This source code is licensed under the MIT license found in the
|
|
21
|
+
* LICENSE file in the root directory of this source tree.
|
|
22
|
+
*/var De;function hr(){if(De)return fe;De=1;var e=w.default;function r(s,m){return s===m&&(s!==0||1/s===1/m)||s!==s&&m!==m}var t=typeof Object.is=="function"?Object.is:r,a=e.useState,o=e.useEffect,i=e.useLayoutEffect,u=e.useDebugValue;function n(s,m){var _=m(),p=a({inst:{value:_,getSnapshot:m}}),A=p[0].inst,f=p[1];return i(function(){A.value=_,A.getSnapshot=m,l(A)&&f({inst:A})},[s,_,m]),o(function(){return l(A)&&f({inst:A}),s(function(){l(A)&&f({inst:A})})},[s]),u(_),_}function l(s){var m=s.getSnapshot;s=s.value;try{var _=m();return!t(s,_)}catch{return!0}}function d(s,m){return m()}var h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?d:n;return fe.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:h,fe}var ye={};/**
|
|
23
|
+
* @license React
|
|
24
|
+
* use-sync-external-store-shim.development.js
|
|
25
|
+
*
|
|
26
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
27
|
+
*
|
|
28
|
+
* This source code is licensed under the MIT license found in the
|
|
29
|
+
* LICENSE file in the root directory of this source tree.
|
|
30
|
+
*/var Le;function gr(){return Le||(Le=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=w.default,r=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function t(b){{for(var c=arguments.length,y=new Array(c>1?c-1:0),E=1;E<c;E++)y[E-1]=arguments[E];a("error",b,y)}}function a(b,c,y){{var E=r.ReactDebugCurrentFrame,N=E.getStackAddendum();N!==""&&(c+="%s",y=y.concat([N]));var I=y.map(function(C){return String(C)});I.unshift("Warning: "+c),Function.prototype.apply.call(console[b],console,I)}}function o(b,c){return b===c&&(b!==0||1/b===1/c)||b!==b&&c!==c}var i=typeof Object.is=="function"?Object.is:o,u=e.useState,n=e.useEffect,l=e.useLayoutEffect,d=e.useDebugValue,h=!1,s=!1;function m(b,c,y){h||e.startTransition!==void 0&&(h=!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 E=c();if(!s){var N=c();i(E,N)||(t("The result of getSnapshot should be cached to avoid an infinite loop"),s=!0)}var I=u({inst:{value:E,getSnapshot:c}}),C=I[0].inst,O=I[1];return l(function(){C.value=E,C.getSnapshot=c,_(C)&&O({inst:C})},[b,E,c]),n(function(){_(C)&&O({inst:C});var R=function(){_(C)&&O({inst:C})};return b(R)},[b]),d(E),E}function _(b){var c=b.getSnapshot,y=b.value;try{var E=c();return!i(y,E)}catch{return!0}}function p(b,c,y){return c()}var A=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",f=!A,S=f?p:m,v=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:S;ye.useSyncExternalStore=v,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),ye}var Ue;function Pe(){return Ue||(Ue=1,function(e){process.env.NODE_ENV==="production"?e.exports=hr():e.exports=gr()}(de)),de.exports}/**
|
|
31
|
+
* @license React
|
|
32
|
+
* use-sync-external-store-shim/with-selector.production.min.js
|
|
33
|
+
*
|
|
34
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
35
|
+
*
|
|
36
|
+
* This source code is licensed under the MIT license found in the
|
|
37
|
+
* LICENSE file in the root directory of this source tree.
|
|
38
|
+
*/var Re;function Er(){if(Re)return le;Re=1;var e=w.default,r=Pe();function t(d,h){return d===h&&(d!==0||1/d===1/h)||d!==d&&h!==h}var a=typeof Object.is=="function"?Object.is:t,o=r.useSyncExternalStore,i=e.useRef,u=e.useEffect,n=e.useMemo,l=e.useDebugValue;return le.useSyncExternalStoreWithSelector=function(d,h,s,m,_){var p=i(null);if(p.current===null){var A={hasValue:!1,value:null};p.current=A}else A=p.current;p=n(function(){function S(E){if(!v){if(v=!0,b=E,E=m(E),_!==void 0&&A.hasValue){var N=A.value;if(_(N,E))return c=N}return c=E}if(N=c,a(b,E))return N;var I=m(E);return _!==void 0&&_(N,I)?N:(b=E,c=I)}var v=!1,b,c,y=s===void 0?null:s;return[function(){return S(h())},y===null?void 0:function(){return S(y())}]},[h,s,m,_]);var f=o(d,p[0],p[1]);return u(function(){A.hasValue=!0,A.value=f},[f]),l(f),f},le}var me={};/**
|
|
39
|
+
* @license React
|
|
40
|
+
* use-sync-external-store-shim/with-selector.development.js
|
|
41
|
+
*
|
|
42
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
43
|
+
*
|
|
44
|
+
* This source code is licensed under the MIT license found in the
|
|
45
|
+
* LICENSE file in the root directory of this source tree.
|
|
46
|
+
*/var Me;function pr(){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=w.default,r=Pe();function t(h,s){return h===s&&(h!==0||1/h===1/s)||h!==h&&s!==s}var a=typeof Object.is=="function"?Object.is:t,o=r.useSyncExternalStore,i=e.useRef,u=e.useEffect,n=e.useMemo,l=e.useDebugValue;function d(h,s,m,_,p){var A=i(null),f;A.current===null?(f={hasValue:!1,value:null},A.current=f):f=A.current;var S=n(function(){var y=!1,E,N,I=function(V){if(!y){y=!0,E=V;var F=_(V);if(p!==void 0&&f.hasValue){var W=f.value;if(p(W,F))return N=W,W}return N=F,F}var K=E,q=N;if(a(K,V))return q;var D=_(V);return p!==void 0&&p(q,D)?q:(E=V,N=D,D)},C=m===void 0?null:m,O=function(){return I(s())},R=C===null?void 0:function(){return I(C())};return[O,R]},[s,m,_,p]),v=S[0],b=S[1],c=o(h,v,b);return u(function(){f.hasValue=!0,f.value=c},[c]),l(c),c}me.useSyncExternalStoreWithSelector=d,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),me}(function(e){process.env.NODE_ENV==="production"?e.exports=Er():e.exports=pr()})(Oe);function Sr(e){var r=Se.useRef();return r.current||(r.current={v:e()}),r.current.v}var $e=globalThis&&globalThis.__read||function(e,r){var t=typeof Symbol=="function"&&e[Symbol.iterator];if(!t)return e;var a=t.call(e),o,i=[],u;try{for(;(r===void 0||r-- >0)&&!(o=a.next()).done;)i.push(o.value)}catch(n){u={error:n}}finally{try{o&&!o.done&&(t=a.return)&&t.call(a)}finally{if(u)throw u.error}}return i};function vr(e){return e}var br=function(e){var r;return e.subscribe(function(t){r=t}).unsubscribe(),r};function Tr(e,r){var t=g.useRef();if(process.env.NODE_ENV!=="production"){var a=$e(g.useState(e),1),o=a[0];e!==o&&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 i=$e(Sr(function(){var d=[],h=mr(we(e.config,r||e._options)),s=h.send;return h.send=function(m){if(h.status===Y.NotStarted){d.push(m);return}s(m),t.current=h.state},[h,d]}),2),u=i[0],n=i[1];_r(function(){r&&(u._machine._options=r)});var l=Ar(u);return g.useEffect(function(){return u.start(t.current),n.forEach(u.send),t.current=u.state,function(){u.stop()}},[]),l}var Cr=function(e,r){return r.changed===!1};function Ar(e){var r=g.useCallback(function(){return br(e)},[e]),t=g.useCallback(function(o){var i=e.subscribe(o).unsubscribe;return i},[e]),a=Oe.exports.useSyncExternalStoreWithSelector(t,r,r,vr,Cr);return[a,e.send,e]}function B(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 Nr=e=>`
|
|
47
|
+
mutation CartLineAdd($cartId: ID!, $lines: [CartLineInput!]!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
|
|
48
|
+
cartLinesAdd(cartId: $cartId, lines: $lines) {
|
|
49
|
+
cart {
|
|
50
|
+
...CartFragment
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
${e}
|
|
56
|
+
`,wr=e=>`
|
|
57
|
+
mutation CartCreate($input: CartInput!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
|
|
58
|
+
cartCreate(input: $input) {
|
|
59
|
+
cart {
|
|
60
|
+
...CartFragment
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
${e}
|
|
66
|
+
`,Ir=e=>`
|
|
67
|
+
mutation CartLineRemove($cartId: ID!, $lines: [ID!]!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
|
|
68
|
+
cartLinesRemove(cartId: $cartId, lineIds: $lines) {
|
|
69
|
+
cart {
|
|
70
|
+
...CartFragment
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
${e}
|
|
76
|
+
`,Or=e=>`
|
|
77
|
+
mutation CartLineUpdate($cartId: ID!, $lines: [CartLineUpdateInput!]!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
|
|
78
|
+
cartLinesUpdate(cartId: $cartId, lines: $lines) {
|
|
79
|
+
cart {
|
|
80
|
+
...CartFragment
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
${e}
|
|
86
|
+
`,Dr=e=>`
|
|
87
|
+
mutation CartNoteUpdate($cartId: ID!, $note: String, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
|
|
88
|
+
cartNoteUpdate(cartId: $cartId, note: $note) {
|
|
89
|
+
cart {
|
|
90
|
+
...CartFragment
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
${e}
|
|
96
|
+
`,Lr=e=>`
|
|
97
|
+
mutation CartBuyerIdentityUpdate(
|
|
98
|
+
$cartId: ID!
|
|
99
|
+
$buyerIdentity: CartBuyerIdentityInput!
|
|
100
|
+
$numCartLines: Int = 250
|
|
101
|
+
$country: CountryCode = ZZ
|
|
102
|
+
) @inContext(country: $country) {
|
|
103
|
+
cartBuyerIdentityUpdate(cartId: $cartId, buyerIdentity: $buyerIdentity) {
|
|
104
|
+
cart {
|
|
105
|
+
...CartFragment
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
${e}
|
|
111
|
+
`,Ur=e=>`
|
|
112
|
+
mutation CartAttributesUpdate($attributes: [AttributeInput!]!, $cartId: ID!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
|
|
113
|
+
cartAttributesUpdate(attributes: $attributes, cartId: $cartId) {
|
|
114
|
+
cart {
|
|
115
|
+
...CartFragment
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
${e}
|
|
121
|
+
`,Pr=e=>`
|
|
122
|
+
mutation CartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!], $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
|
|
123
|
+
cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {
|
|
124
|
+
cart {
|
|
125
|
+
...CartFragment
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
${e}
|
|
131
|
+
`,Rr=e=>`
|
|
132
|
+
query CartQuery($id: ID!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
|
|
133
|
+
cart(id: $id) {
|
|
134
|
+
...CartFragment
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
${e}
|
|
139
|
+
`,X="2022-10";var Mr="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ShopifyProvider.tsx";const Ve=g.createContext({storeDomain:"test.myshopify.com",storefrontToken:"abc123",storefrontApiVersion:X,country:{isoCode:"US"},language:{isoCode:"EN"},locale:"EN-US"});function $r({children:e,shopifyConfig:r}){if(!r)throw new Error("The 'shopifyConfig' prop must be passed to '<ShopifyProvider/>'");r.storefrontApiVersion!==X&&console.warn(`This version of Hydrogen-UI is built for Shopify's Storefront API version ${X}, 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(()=>({...r,storeDomain:r.storeDomain.replace(/^https?:\/\//,"")}),[r]);return w.default.createElement(Ve.Provider,{value:t,__self:this,__source:{fileName:Mr,lineNumber:49,columnNumber:5}},e)}function J(){const e=g.useContext(Ve);if(!e)throw new Error("'useShop()' must be a descendent of <ShopifyProvider/>");return e}const _e="shopifyCartId",Vr="X-Shopify-Storefront-Access-Token",kr="Shopify-Storefront-Id",Fr="Shopify-Storefront-Y",xr="Shopify-Storefront-S",ke="_shopify_y",Fe="_shopify_s";var jr=new Set(["domain","path","max-age","expires","samesite","secure","httponly"]);function qr(e){let r={},t,a,o=0,i=e.split(/;\s*/g),u,n;for(;o<i.length;o++)if(a=i[o],t=a.indexOf("="),~t){if(u=a.substring(0,t++).trim(),n=a.substring(t).trim(),n[0]==='"'&&(n=n.substring(1,n.length-1)),~n.indexOf("%"))try{n=decodeURIComponent(n)}catch{}jr.has(a=u.toLowerCase())?a==="expires"?r.expires=new Date(n):a==="max-age"?r.maxage=+n:r[a]=n:r[u]=n}else(u=a.trim().toLowerCase())&&(u==="httponly"||u==="secure")&&(r[u]=!0);return r}function Hr(){const{storeDomain:e,storefrontApiVersion:r,storefrontToken:t,storefrontId:a}=J();return g.useCallback(({query:o,variables:i})=>{const u={"Content-Type":"application/json","X-SDK-Variant":"hydrogen","X-SDK-Version":r,[Vr]:t};a&&(u[kr]=a);const n=qr(document.cookie);return n[ke]&&n[Fe]&&(u[Fr]=n[ke],u[xr]=n[Fe]),fetch(`https://${e}/api/${r}/graphql.json`,{method:"POST",headers:u,body:JSON.stringify({query:o.toString(),variables:i})}).then(l=>l.json()).catch(l=>({data:void 0,errors:l.toString()}))},[e,r,t,a])}function Br({numCartLines:e,cartFragment:r,countryCode:t="US"}){const a=Hr(),o=g.useCallback(_=>a({query:Rr(r),variables:{id:_,numCartLines:e,country:t}}),[a,r,e,t]),i=g.useCallback(_=>a({query:wr(r),variables:{input:_,numCartLines:e,country:t}}),[r,t,a,e]),u=g.useCallback((_,p)=>a({query:Nr(r),variables:{cartId:_,lines:p,numCartLines:e,country:t}}),[r,t,a,e]),n=g.useCallback((_,p)=>a({query:Or(r),variables:{cartId:_,lines:p,numCartLines:e,country:t}}),[r,t,a,e]),l=g.useCallback((_,p)=>a({query:Ir(r),variables:{cartId:_,lines:p,numCartLines:e,country:t}}),[r,t,a,e]),d=g.useCallback((_,p)=>a({query:Dr(r),variables:{cartId:_,note:p,numCartLines:e,country:t}}),[a,r,e,t]),h=g.useCallback((_,p)=>a({query:Lr(r),variables:{cartId:_,buyerIdentity:p,numCartLines:e,country:t}}),[r,t,a,e]),s=g.useCallback((_,p)=>a({query:Ur(r),variables:{cartId:_,attributes:p,numCartLines:e,country:t}}),[r,t,a,e]),m=g.useCallback((_,p)=>a({query:Pr(r),variables:{cartId:_,discountCodes:p,numCartLines:e,country:t}}),[r,t,a,e]);return g.useMemo(()=>({cartFetch:o,cartCreate:i,cartLineAdd:u,cartLineUpdate:n,cartLineRemove:l,noteUpdate:d,buyerIdentityUpdate:h,cartAttributesUpdate:s,discountCodesUpdate:m,cartFragment:r}),[o,i,u,n,l,d,h,s,m,r])}function x(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,a)=>{var o;return(o=a==null?void 0:a.payload)==null?void 0:o.cart},rawCartResult:(t,a)=>{var o;return(o=a==null?void 0:a.payload)==null?void 0:o.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,a)=>{var o;return(o=a==null?void 0:a.payload)==null?void 0:o.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)=>he(r.payload.cart)})]}},xe={CARTLINE_ADD:{target:"cartLineAdding"},CARTLINE_UPDATE:{target:"cartLineUpdating"},CARTLINE_REMOVE:{target:"cartLineRemoving"},NOTE_UPDATE:{target:"noteUpdating"},BUYER_IDENTITY_UPDATE:{target:"buyerIdentityUpdating"},CART_ATTRIBUTES_UPDATE:{target:"cartAttributesUpdating"},DISCOUNT_CODES_UPDATE:{target:"discountCodesUpdating"}};function Wr(e){return we({id:"Cart",initial:e?"idle":"uninitialized",context:{cart:e&&he(e)},states:{uninitialized:{on:ee},cartCompleted:{on:ee},initializationError:{on:ee},idle:{on:{...ee,...xe}},error:{on:{...ee,...xe}},cartFetching:x("cartFetchAction",{errorTarget:"initializationError"}),cartCreating:x("cartCreateAction",{errorTarget:"initializationError"}),cartLineRemoving:x("cartLineRemoveAction"),cartLineUpdating:x("cartLineUpdateAction"),cartLineAdding:x("cartLineAddAction"),noteUpdating:x("noteUpdateAction"),buyerIdentityUpdating:x("buyerIdentityUpdateAction"),cartAttributesUpdating:x("cartAttributesUpdateAction"),discountCodesUpdating:x("discountCodesUpdateAction")}})}function Yr({numCartLines:e,onCartActionEntry:r,onCartActionOptimisticUI:t,onCartActionComplete:a,data:o,cartFragment:i,countryCode:u}){const{cartFetch:n,cartCreate:l,cartLineAdd:d,cartLineUpdate:h,cartLineRemove:s,noteUpdate:m,buyerIdentityUpdate:_,cartAttributesUpdate:p,discountCodesUpdate:A}=Br({numCartLines:e,cartFragment:i,countryCode:u}),f=g.useMemo(()=>Wr(o),[o]),[S,v,b]=Tr(f,{actions:{cartFetchAction:async(c,y)=>{var C;if(y.type!=="CART_FETCH")return;const{data:E,errors:N}=await n((C=y==null?void 0:y.payload)==null?void 0:C.cartId),I=j(y,E==null?void 0:E.cart,N);v(I)},cartCreateAction:async(c,y)=>{var C;if(y.type!=="CART_CREATE")return;const{data:E,errors:N}=await l(y==null?void 0:y.payload),I=j(y,(C=E==null?void 0:E.cartCreate)==null?void 0:C.cart,N);v(I)},cartLineAddAction:async(c,y)=>{var C,O;if(y.type!=="CARTLINE_ADD"||!((C=c==null?void 0:c.cart)!=null&&C.id))return;const{data:E,errors:N}=await d(c.cart.id,y.payload.lines),I=j(y,(O=E==null?void 0:E.cartLinesAdd)==null?void 0:O.cart,N);v(I)},cartLineUpdateAction:async(c,y)=>{var C,O;if(y.type!=="CARTLINE_UPDATE"||!((C=c==null?void 0:c.cart)!=null&&C.id))return;const{data:E,errors:N}=await h(c.cart.id,y.payload.lines),I=j(y,(O=E==null?void 0:E.cartLinesUpdate)==null?void 0:O.cart,N);v(I)},cartLineRemoveAction:async(c,y)=>{var C,O;if(y.type!=="CARTLINE_REMOVE"||!((C=c==null?void 0:c.cart)!=null&&C.id))return;const{data:E,errors:N}=await s(c.cart.id,y.payload.lines),I=j(y,(O=E==null?void 0:E.cartLinesRemove)==null?void 0:O.cart,N);v(I)},noteUpdateAction:async(c,y)=>{var C,O;if(y.type!=="NOTE_UPDATE"||!((C=c==null?void 0:c.cart)!=null&&C.id))return;const{data:E,errors:N}=await m(c.cart.id,y.payload.note),I=j(y,(O=E==null?void 0:E.cartNoteUpdate)==null?void 0:O.cart,N);v(I)},buyerIdentityUpdateAction:async(c,y)=>{var C,O;if(y.type!=="BUYER_IDENTITY_UPDATE"||!((C=c==null?void 0:c.cart)!=null&&C.id))return;const{data:E,errors:N}=await _(c.cart.id,y.payload.buyerIdentity),I=j(y,(O=E==null?void 0:E.cartBuyerIdentityUpdate)==null?void 0:O.cart,N);v(I)},cartAttributesUpdateAction:async(c,y)=>{var C,O;if(y.type!=="CART_ATTRIBUTES_UPDATE"||!((C=c==null?void 0:c.cart)!=null&&C.id))return;const{data:E,errors:N}=await p(c.cart.id,y.payload.attributes),I=j(y,(O=E==null?void 0:E.cartAttributesUpdate)==null?void 0:O.cart,N);v(I)},discountCodesUpdateAction:async(c,y)=>{var C,O;if(y.type!=="DISCOUNT_CODES_UPDATE"||!((C=c==null?void 0:c.cart)!=null&&C.id))return;const{data:E,errors:N}=await A(c.cart.id,y.payload.discountCodes),I=j(y,(O=E==null?void 0:E.cartDiscountCodesUpdate)==null?void 0:O.cart,N);v(I)},...r&&{onCartActionEntry:(c,y)=>{Gr(y)&&r(c,y)}},...t&&{onCartActionOptimisticUI:Q((c,y)=>t(c,y))},...a&&{onCartActionComplete:(c,y)=>{Zr(y)&&a(c,y)}}}});return g.useMemo(()=>[S,v,b],[S,v,b])}function he(e){var r;return{...e,lines:B(e==null?void 0:e.lines),note:(r=e.note)!=null?r:void 0}}function j(e,r,t){return t?{type:"ERROR",payload:{errors:t,cartActionEvent:e}}:r?{type:"RESOLVE",payload:{cart:he(r),rawCartResult:r,cartActionEvent:e}}:{type:"CART_COMPLETED",payload:{cartActionEvent:e}}}function Gr(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 Zr(e){return e.type==="RESOLVE"||e.type==="ERROR"||e.type==="CART_COMPLETED"}var Kr="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/CartProvider.tsx";const je=g.createContext(null);function zr(){const e=g.useContext(je);if(!e)throw new Error("Expected a Cart Context, but no Cart Context was found");return e}function Qr({children:e,numCartLines:r,onCreate:t,onLineAdd:a,onLineRemove:o,onLineUpdate:i,onNoteUpdate:u,onBuyerIdentityUpdate:n,onAttributesUpdate:l,onDiscountCodesUpdate:d,onCreateComplete:h,onLineAddComplete:s,onLineRemoveComplete:m,onLineUpdateComplete:_,onNoteUpdateComplete:p,onBuyerIdentityUpdateComplete:A,onAttributesUpdateComplete:f,onDiscountCodesUpdateComplete:S,data:v,cartFragment:b=rt,customerAccessToken:c,countryCode:y="US"}){var ir,or,ur,cr,sr,lr,dr;y&&(y=y.toUpperCase());const[E,N]=g.useState(y),[I,C]=g.useState(c),O=g.useRef(!1);(E!==y||I!==c)&&(N(y),C(c),O.current=!1);const[R,V]=Yr({numCartLines:r,data:v,cartFragment:b,countryCode:y,onCartActionEntry(T,M){try{switch(M.type){case"CART_CREATE":return t==null?void 0:t();case"CARTLINE_ADD":return a==null?void 0:a();case"CARTLINE_REMOVE":return o==null?void 0:o();case"CARTLINE_UPDATE":return i==null?void 0:i();case"NOTE_UPDATE":return u==null?void 0:u();case"BUYER_IDENTITY_UPDATE":return n==null?void 0:n();case"CART_ATTRIBUTES_UPDATE":return l==null?void 0:l();case"DISCOUNT_CODES_UPDATE":return d==null?void 0:d()}}catch(k){console.error("Cart entry action failed",k)}},onCartActionOptimisticUI(T,M){var k,H,te,ne;if(!(T!=null&&T.cart))return{cart:void 0};switch(M.type){case"CARTLINE_REMOVE":return{...T,lastValidCart:T.cart,cart:{...T.cart,lines:(H=(k=T==null?void 0:T.cart)==null?void 0:k.lines)==null?void 0:H.filter(L=>(L==null?void 0:L.id)&&!M.payload.lines.includes(L==null?void 0:L.id))}};case"CARTLINE_UPDATE":return{...T,lastValidCart:T.cart,cart:{...T.cart,lines:(ne=(te=T==null?void 0:T.cart)==null?void 0:te.lines)==null?void 0:ne.map(L=>{const z=M.payload.lines.find(({id:ce})=>ce===(L==null?void 0:L.id));return z&&z.quantity?{...L,quantity:z.quantity}:L})}}}return{cart:T.cart?{...T.cart}:void 0}},onCartActionComplete(T,M){const k=M.payload.cartActionEvent;try{switch(M.type){case"RESOLVE":switch(k.type){case"CART_CREATE":return h==null?void 0:h();case"CARTLINE_ADD":return s==null?void 0:s();case"CARTLINE_REMOVE":return m==null?void 0:m();case"CARTLINE_UPDATE":return _==null?void 0:_();case"NOTE_UPDATE":return p==null?void 0:p();case"BUYER_IDENTITY_UPDATE":return et(T,k)&&(O.current=!0),A==null?void 0:A();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=R.matches("cartCompleted"),K=(R.value==="idle"||R.value==="error"||R.value==="cartCompleted")&&y!==((ur=(or=(ir=R==null?void 0:R.context)==null?void 0:ir.cart)==null?void 0:or.buyerIdentity)==null?void 0:ur.countryCode)&&!R.context.errors,q=g.useRef(!1);g.useEffect(()=>{if(!F.current&&!q.current){if(!v&&ge("localStorage")){q.current=!0;try{const T=window.localStorage.getItem(_e);T&&V({type:"CART_FETCH",payload:{cartId:T}})}catch(T){console.warn("error fetching cartId"),console.warn(T)}}F.current=!0}},[v,F,V]),g.useEffect(()=>{!K||O.current||V({type:"BUYER_IDENTITY_UPDATE",payload:{buyerIdentity:{countryCode:y,customerAccessToken:c}}})},[y,c,K,O,V]);const D=g.useCallback(T=>{if(!F.current)return console.warn("Cart isn't ready yet");V(T)},[V]);g.useEffect(()=>{var T,M,k;if(((M=(T=R==null?void 0:R.context)==null?void 0:T.cart)==null?void 0:M.id)&&ge("localStorage"))try{window.localStorage.setItem(_e,(k=R.context.cart)==null?void 0:k.id)}catch(H){console.warn("Failed to save cartId to localStorage",H)}},[(sr=(cr=R==null?void 0:R.context)==null?void 0:cr.cart)==null?void 0:sr.id]),g.useEffect(()=>{if(W&&ge("localStorage"))try{window.localStorage.removeItem(_e)}catch(T){console.warn("Failed to delete cartId from localStorage",T)}},[W]);const G=g.useCallback(T=>{var M,k;y&&!((M=T.buyerIdentity)!=null&&M.countryCode)&&(T.buyerIdentity==null&&(T.buyerIdentity={}),T.buyerIdentity.countryCode=y),c&&!((k=T.buyerIdentity)!=null&&k.customerAccessToken)&&(T.buyerIdentity==null&&(T.buyerIdentity={}),T.buyerIdentity.customerAccessToken=c),D({type:"CART_CREATE",payload:T})},[y,c,D]),P=Jr(R),ue=g.useMemo(()=>{var T,M,k,H,te,ne;return{...(M=(T=P==null?void 0:P.context)==null?void 0:T.cart)!=null?M:{lines:[],attributes:[]},status:Xr(P.value),error:(k=P==null?void 0:P.context)==null?void 0:k.errors,totalQuantity:(ne=(te=(H=P==null?void 0:P.context)==null?void 0:H.cart)==null?void 0:te.totalQuantity)!=null?ne:0,cartCreate:G,linesAdd(L){var z,ce;(ce=(z=P==null?void 0:P.context)==null?void 0:z.cart)!=null&&ce.id?D({type:"CARTLINE_ADD",payload:{lines:L}}):G({lines:L})},linesRemove(L){D({type:"CARTLINE_REMOVE",payload:{lines:L}})},linesUpdate(L){D({type:"CARTLINE_UPDATE",payload:{lines:L}})},noteUpdate(L){D({type:"NOTE_UPDATE",payload:{note:L}})},buyerIdentityUpdate(L){D({type:"BUYER_IDENTITY_UPDATE",payload:{buyerIdentity:L}})},cartAttributesUpdate(L){D({type:"CART_ATTRIBUTES_UPDATE",payload:{attributes:L}})},discountCodesUpdate(L){D({type:"DISCOUNT_CODES_UPDATE",payload:{discountCodes:L}})},cartFragment:b}},[G,(lr=P==null?void 0:P.context)==null?void 0:lr.cart,(dr=P==null?void 0:P.context)==null?void 0:dr.errors,P.value,b,D]);return w.default.createElement(je.Provider,{value:ue,__self:this,__source:{fileName:Kr,lineNumber:425,columnNumber:5}},e)}function Xr(e){switch(e){case"uninitialized":case"initializationError":return"uninitialized";case"idle":case"cartCompleted":case"error":return"idle";case"cartFetching":return"fetching";case"cartCreating":return"creating";case"cartLineAdding":case"cartLineRemoving":case"cartLineUpdating":case"noteUpdating":case"buyerIdentityUpdating":case"cartAttributesUpdating":case"discountCodesUpdating":return"updating"}}function Jr(e){const[r,t]=g.useTransition(),[a,o]=g.useState(e),i=g.useRef(!1);r&&(i.current=!0);const u=g.useRef(!1);return!r&&i.current&&(u.current=!0),g.useEffect(()=>{t(()=>{u.current||o(e)})},[e]),u.current?e:a}function ge(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 et(e,r){var t,a;return r.payload.buyerIdentity.countryCode&&((a=(t=e.cart)==null?void 0:t.buyerIdentity)==null?void 0:a.countryCode)!==r.payload.buyerIdentity.countryCode}const rt=`
|
|
140
|
+
fragment CartFragment on Cart {
|
|
141
|
+
id
|
|
142
|
+
checkoutUrl
|
|
143
|
+
totalQuantity
|
|
144
|
+
buyerIdentity {
|
|
145
|
+
countryCode
|
|
146
|
+
customer {
|
|
147
|
+
id
|
|
148
|
+
email
|
|
149
|
+
firstName
|
|
150
|
+
lastName
|
|
151
|
+
displayName
|
|
152
|
+
}
|
|
153
|
+
email
|
|
154
|
+
phone
|
|
155
|
+
}
|
|
156
|
+
lines(first: $numCartLines) {
|
|
157
|
+
edges {
|
|
158
|
+
node {
|
|
159
|
+
id
|
|
160
|
+
quantity
|
|
161
|
+
attributes {
|
|
162
|
+
key
|
|
163
|
+
value
|
|
164
|
+
}
|
|
165
|
+
cost {
|
|
166
|
+
totalAmount {
|
|
167
|
+
amount
|
|
168
|
+
currencyCode
|
|
169
|
+
}
|
|
170
|
+
compareAtAmountPerQuantity {
|
|
171
|
+
amount
|
|
172
|
+
currencyCode
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
merchandise {
|
|
176
|
+
... on ProductVariant {
|
|
177
|
+
id
|
|
178
|
+
availableForSale
|
|
179
|
+
compareAtPriceV2 {
|
|
180
|
+
...MoneyFragment
|
|
181
|
+
}
|
|
182
|
+
priceV2 {
|
|
183
|
+
...MoneyFragment
|
|
184
|
+
}
|
|
185
|
+
requiresShipping
|
|
186
|
+
title
|
|
187
|
+
image {
|
|
188
|
+
...ImageFragment
|
|
189
|
+
}
|
|
190
|
+
product {
|
|
191
|
+
handle
|
|
192
|
+
title
|
|
193
|
+
}
|
|
194
|
+
selectedOptions {
|
|
195
|
+
name
|
|
196
|
+
value
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
cost {
|
|
204
|
+
subtotalAmount {
|
|
205
|
+
...MoneyFragment
|
|
206
|
+
}
|
|
207
|
+
totalAmount {
|
|
208
|
+
...MoneyFragment
|
|
209
|
+
}
|
|
210
|
+
totalDutyAmount {
|
|
211
|
+
...MoneyFragment
|
|
212
|
+
}
|
|
213
|
+
totalTaxAmount {
|
|
214
|
+
...MoneyFragment
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
note
|
|
218
|
+
attributes {
|
|
219
|
+
key
|
|
220
|
+
value
|
|
221
|
+
}
|
|
222
|
+
discountCodes {
|
|
223
|
+
code
|
|
224
|
+
}
|
|
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 tt="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ExternalVideo.tsx";function qe(e){var h,s;const{data:r,options:t,id:a=r.id,frameBorder:o="0",allow:i="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:u=!0,loading:n="lazy",...l}=e;if(!r.embedUrl)throw new Error("<ExternalVideo/> requires the 'embedUrl' property");let d=r.embedUrl;if(t){const m=new URL(r.embedUrl);for(const _ of Object.keys(t))m.searchParams.set(_,t[_]);d=m.toString()}return w.default.createElement("iframe",{...l,id:a!=null?a:r.embedUrl,title:(s=(h=r.alt)!=null?h:r.id)!=null?s:"external video",frameBorder:o,allow:i,allowFullScreen:u,src:d,loading:n,__self:this,__source:{fileName:tt,lineNumber:56,columnNumber:5}})}const nt=["cdn.shopify.com","cdn.shopifycdn.net","shopify-assets.shopifycdn.com","shopify-assets.shopifycdn.net"],at=["spin.dev"],it=[...nt,...at],re=[352,832,1200,1920,2560];function He({src:e,width:r,height:t,crop:a,scale:o}){const i=new URL(e),u=o!=null?o:1;if(r){let n;typeof r=="string"?n=(re[0]*u).toString():n=(Number(r)*u).toString(),i.searchParams.append("width",n)}return t&&typeof t=="number"&&i.searchParams.append("height",(t*u).toString()),a&&i.searchParams.append("crop",a),i.toString()}function Be(e){const r=new URL(e.src);return!it.some(a=>r.hostname.endsWith(a))||!e.width&&!e.height&&!e.crop&&!e.scale?e.src:He(e)}function ot({data:e,loaderOptions:r,elementProps:t}){var o,i,u,n,l,d;let a=null;return(e==null?void 0:e.width)&&(e==null?void 0:e.height)&&(a=(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:(o=r==null?void 0:r.width)!=null?o:a&&typeof r.height=="number"?Math.round(a*r.height):null,height:(i=r==null?void 0:r.height)!=null?i:a&&typeof r.width=="number"?Math.round(a*r.width):null}:(t==null?void 0:t.width)||(t==null?void 0:t.height)?{width:(u=t==null?void 0:t.width)!=null?u:a&&typeof t.height=="number"?Math.round(a*t.height):null,height:(n=t==null?void 0:t.height)!=null?n:a&&typeof t.width=="number"?Math.round(a*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:(d=e==null?void 0:e.height)!=null?d:null}:{width:null,height:null}}var ut="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/Image.tsx";function ie({data:e,width:r,height:t,loading:a,loader:o=Be,loaderOptions:i,widths:u,decoding:n="async",...l}){var p,A,f,S,v,b;if(!e.url){const c=`<Image/>: the 'data' prop requires the 'url' property. Image: ${(p=e.id)!=null?p:"no ID provided"}`;return console.error(c),null}const{width:d,height:h}=ot({data:e,loaderOptions:i,elementProps:{width:r,height:t}});let s=e.url;if(o&&(s=o({...i,src:e.url,width:d,height:h}),typeof s!="string"||!s))throw new Error(`<Image/>: 'loader' did not return a valid string. Image: ${(A=e.id)!=null?A:e.url}`);const m=r&&d&&r<d?r:d,_=(f=l.srcSet)!=null?f:ct({...i,widths:u,src:e.url,width:m,height:h,loader:o});return Se.createElement("img",{id:(S=e.id)!=null?S:"",alt:(b=(v=e.altText)!=null?v:l.alt)!=null?b:"",loading:a!=null?a:"lazy",...l,src:s,width:d!=null?d:void 0,height:h!=null?h:void 0,srcSet:_,decoding:n,__self:this,__source:{fileName:ut,lineNumber:150,columnNumber:5}})}function ct({src:e,width:r,crop:t,scale:a,widths:o,loader:i,height:u}){const n=o&&Array.isArray(o);if(n&&o.some(s=>isNaN(s)))throw new Error(`<Image/>: the 'widths' must be an array of numbers. Image: ${e}`);let l=1;r&&u&&(l=Number(u)/Number(r));let d=n?o:re;!n&&r&&r<re[re.length-1]&&(d=re.filter(s=>s<=r));const h=i||He;return d.map(s=>`${h({src:e,width:s,height:t?Number(s)*l:void 0,crop:t,scale:a})} ${s}w`).join(", ")}var We="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/Video.tsx";function Ee(e){var d,h;const{data:r,previewImageOptions:t,id:a=r.id,playsInline:o=!0,controls:i=!0,sourceProps:u={},...n}=e,l=Be({src:(h=(d=r.previewImage)==null?void 0:d.url)!=null?h:"",...t});if(!r.sources)throw new Error("<Video/> requires a 'data.sources' array");return w.default.createElement("video",{...n,id:a,playsInline:o,controls:i,poster:l,__self:this,__source:{fileName:We,lineNumber:42,columnNumber:5}},r.sources.map(s=>{if(!((s==null?void 0:s.url)&&(s==null?void 0:s.mimeType)))throw new Error("<Video/> needs 'source.url' and 'source.mimeType'");return w.default.createElement("source",{...u,key:s.url,src:s.url,type:s.mimeType,__self:this,__source:{fileName:We,lineNumber:54,columnNumber:11}})}))}const Ye={};function st(e,r){const t=Ye[e];if(t)return t;const a=new Promise((o,i)=>{const u=document.createElement("script");r!=null&&r.module?u.type="module":u.type="text/javascript",u.src=e,u.onload=()=>{o(!0)},u.onerror=()=>{i(!1)},(r==null?void 0:r.in)==="head"?document.head.appendChild(u):document.body.appendChild(u)});return Ye[e]=a,a}function Ge(e,r){const[t,a]=g.useState("loading"),o=JSON.stringify(r);return g.useEffect(()=>{async function i(){try{a("loading"),await st(e,r),a("done")}catch{a("error")}}i()},[e,o,r]),t}var lt="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ModelViewer.tsx";function Ze(e){var d,h,s,m,_,p,A,f,S,v,b;const[r,t]=g.useState(void 0),a=g.useCallback(c=>{t(c)},[]),{data:o,children:i,className:u,...n}=e,l=Ge("https://unpkg.com/@google/model-viewer@v1.12.1/dist/model-viewer.min.js",{module:!0});return g.useEffect(()=>{if(!!r)return n.onError&&r.addEventListener("error",n.onError),n.onLoad&&r.addEventListener("load",n.onLoad),n.onPreload&&r.addEventListener("preload",n.onPreload),n.onModelVisibility&&r.addEventListener("model-visibility",n.onModelVisibility),n.onProgress&&r.addEventListener("progress",n.onProgress),n.onArStatus&&r.addEventListener("ar-status",n.onArStatus),n.onArTracking&&r.addEventListener("ar-tracking",n.onArTracking),n.onQuickLookButtonTapped&&r.addEventListener("quick-look-button-tapped",n.onQuickLookButtonTapped),n.onCameraChange&&r.addEventListener("camera-change",n.onCameraChange),n.onEnvironmentChange&&r.addEventListener("environment-change",n.onEnvironmentChange),n.onPlay&&r.addEventListener("play",n.onPlay),n.onPause&&r.addEventListener("ar-status",n.onPause),n.onSceneGraphReady&&r.addEventListener("scene-graph-ready",n.onSceneGraphReady),()=>{r!=null&&(n.onError&&r.removeEventListener("error",n.onError),n.onLoad&&r.removeEventListener("load",n.onLoad),n.onPreload&&r.removeEventListener("preload",n.onPreload),n.onModelVisibility&&r.removeEventListener("model-visibility",n.onModelVisibility),n.onProgress&&r.removeEventListener("progress",n.onProgress),n.onArStatus&&r.removeEventListener("ar-status",n.onArStatus),n.onArTracking&&r.removeEventListener("ar-tracking",n.onArTracking),n.onQuickLookButtonTapped&&r.removeEventListener("quick-look-button-tapped",n.onQuickLookButtonTapped),n.onCameraChange&&r.removeEventListener("camera-change",n.onCameraChange),n.onEnvironmentChange&&r.removeEventListener("environment-change",n.onEnvironmentChange),n.onPlay&&r.removeEventListener("play",n.onPlay),n.onPause&&r.removeEventListener("ar-status",n.onPause),n.onSceneGraphReady&&r.removeEventListener("scene-graph-ready",n.onSceneGraphReady))}},[r,n.onArStatus,n.onArTracking,n.onCameraChange,n.onEnvironmentChange,n.onError,n.onLoad,n.onModelVisibility,n.onPause,n.onPlay,n.onPreload,n.onProgress,n.onQuickLookButtonTapped,n.onSceneGraphReady]),l!=="done"?null:(h=(d=o.sources)==null?void 0:d[0])!=null&&h.url?w.default.createElement("model-viewer",{ref:a,...n,className:u,id:(s=n.id)!=null?s:o.id,src:o.sources[0].url,alt:(m=o.alt)!=null?m:null,"camera-controls":(_=n.cameraControls)!=null?_:!0,poster:(A=n.poster||((p=o.previewImage)==null?void 0:p.url))!=null?A:null,autoplay:(f=n.autoplay)!=null?f:!0,loading:n.loading,reveal:n.reveal,ar:n.ar,"ar-modes":n.arModes,"ar-scale":n.arScale,"ar-placement":n.arPlacement,"ios-src":n.iosSrc,"touch-action":n.touchAction,"disable-zoom":n.disableZoom,"orbit-sensitivity":n.orbitSensitivity,"auto-rotate":n.autoRotate,"auto-rotate-delay":n.autoRotateDelay,"rotation-per-second":n.rotationPerSecond,"interaction-policy":n.interactionPolicy,"interaction-prompt":n.interactionPrompt,"interaction-prompt-style":n.interactionPromptStyle,"interaction-prompt-threshold":n.interactionPromptThreshold,"camera-orbit":n.cameraOrbit,"camera-target":n.cameraTarget,"field-of-view":n.fieldOfView,"max-camera-orbit":n.maxCameraOrbit,"min-camera-orbit":n.minCameraOrbit,"max-field-of-view":n.maxFieldOfView,"min-field-of-view":n.minFieldOfView,bounds:n.bounds,"interpolation-decay":(S=n.interpolationDecay)!=null?S:100,"skybox-image":n.skyboxImage,"environment-image":n.environmentImage,exposure:n.exposure,"shadow-intensity":(v=n.shadowIntensity)!=null?v:0,"shadow-softness":(b=n.shadowSoftness)!=null?b:0,"animation-name":n.animationName,"animation-crossfade-duration":n.animationCrossfadeDuration,"variant-name":n.variantName,orientation:n.orientation,scale:n.scale,__self:this,__source:{fileName:lt,lineNumber:222,columnNumber:5}},i):(console.error("<ModelViewer/> requires 'data.sources' prop to be an array, with an object that has a property 'url' on it. Rendering 'null'"),null)}var oe="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/MediaFile.tsx";function dt({data:e,mediaOptions:r,...t}){switch(e.__typename){case"MediaImage":return e.image?w.default.createElement(ie,{...t,...r==null?void 0:r.image,data:e.image,__self:this,__source:{fileName:oe,lineNumber:50,columnNumber:9}}):(console.warn("<MediaFile/>: 'data.image' does not exist for __typename of 'MediaImage'; rendering 'null' by default."),null);case"Video":return w.default.createElement(Ee,{...t,...r==null?void 0:r.video,data:e,__self:this,__source:{fileName:oe,lineNumber:59,columnNumber:9}});case"ExternalVideo":return w.default.createElement(qe,{...t,...r==null?void 0:r.externalVideo,data:e,__self:this,__source:{fileName:oe,lineNumber:64,columnNumber:9}});case"Model3d":return w.default.createElement(Ze,{...t,...r==null?void 0:r.modelViewer,data:e,__self:this,__source:{fileName:oe,lineNumber:73,columnNumber:9}});default:return console.error("<MediaFile /> requires the '__typename' property to exist on the 'data' prop in order to correctly render the correct component for this media. Rendering 'null' by default"),null}}var $="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/Metafield.tsx";function ft(e){var n,l,d,h,s,m,_,p,A;const{data:r,as:t,...a}=e,{locale:o}=J(),i=g.useMemo(()=>Ke(r),[r]);if(!i)return console.warn("<Metafield/>: nothing was passed to the data prop 'data'. Rendering 'null'"),null;if(i.value===null||i.value===void 0){const f=`<Metafield/>: No metafield value for metafield ${(n=i.id)!=null?n:i.key}. Rendering 'null'`;return console.warn(f),null}switch(i.type){case"date":{const f=t!=null?t:"time";return w.default.createElement(f,{...a,__self:this,__source:{fileName:$,lineNumber:68,columnNumber:9}},i.value.toLocaleDateString(o))}case"date_time":{const f=t!=null?t:"time";return w.default.createElement(f,{...a,__self:this,__source:{fileName:$,lineNumber:76,columnNumber:9}},i.value.toLocaleString(o))}case"weight":case"dimension":case"volume":{const f=t!=null?t:"span";return w.default.createElement(f,{...a,__self:this,__source:{fileName:$,lineNumber:86,columnNumber:9}},_t(i.value,o))}case"rating":{const f=t!=null?t:"span";return w.default.createElement(f,{...a,__self:this,__source:{fileName:$,lineNumber:94,columnNumber:9}},i.value.value)}case"single_line_text_field":{const f=t!=null?t:"span";return w.default.createElement(f,{...a,dangerouslySetInnerHTML:{__html:i.value},__self:this,__source:{fileName:$,lineNumber:102,columnNumber:9}})}case"multi_line_text_field":{const f=t!=null?t:"div";return w.default.createElement(f,{...a,dangerouslySetInnerHTML:{__html:i.value.split(`
|
|
239
|
+
`).join("<br/>")},__self:this,__source:{fileName:$,lineNumber:111,columnNumber:9}})}case"url":{const f=new URL(i.value);return w.default.createElement("a",{href:f.href.replace(f.protocol,""),...a,__self:this,__source:{fileName:$,lineNumber:122,columnNumber:9}},i.value)}case"json":{const f=t!=null?t:"span";return w.default.createElement(f,{...a,__self:this,__source:{fileName:$,lineNumber:133,columnNumber:9}},JSON.stringify(i.value))}case"product_reference":case"variant_reference":case"page_reference":{const f=t!=null?t:"span",S=i.reference;return w.default.createElement(f,{...a,__self:this,__source:{fileName:$,lineNumber:144,columnNumber:9}},(d=(l=S==null?void 0:S.title)!=null?l:S==null?void 0:S.id)!=null?d:"")}case"list.single_line_text_field":{const f=t!=null?t:"ul",S=i.references?B(i.references):[];return w.default.createElement(f,{...a,__self:this,__source:{fileName:$,lineNumber:154,columnNumber:9}},S.map((v,b)=>w.default.createElement("li",{key:`${v!=null?v:""}-${b}`,__self:this,__source:{fileName:$,lineNumber:158,columnNumber:13}},v)))}case"file_reference":if(((h=i.reference)==null?void 0:h.__typename)==="MediaImage"){const f=i.reference;return f.image?w.default.createElement(ie,{data:f.image,...a,__self:this,__source:{fileName:$,lineNumber:167,columnNumber:11}}):null}else if(((s=i.reference)==null?void 0:s.__typename)==="GenericFile"){const f=i.reference;return f.previewImage?w.default.createElement("a",{href:(_=(m=i.reference)==null?void 0:m.url)!=null?_:"",...a,__self:this,__source:{fileName:$,lineNumber:172,columnNumber:11}},w.default.createElement(ie,{data:f.previewImage,__self:this,__source:{fileName:$,lineNumber:173,columnNumber:13}})):null}else if(((p=i.reference)==null?void 0:p.__typename)==="Video"){const f=i.reference;return w.default.createElement(Ee,{...a,data:f,__self:this,__source:{fileName:$,lineNumber:178,columnNumber:16}})}}const u=t!=null?t:"span";return w.default.createElement(u,{...a,__self:this,__source:{fileName:$,lineNumber:185,columnNumber:5}},(A=i.value)==null?void 0:A.toString())}function Ke(e){return e?{...e,value:ze(e)}:null}function ze(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 yt(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 yt(e){return String(e).includes("__proto__")?JSON.parse(e,(r,t)=>{if(r!=="__proto__")return t}):JSON.parse(e)}const mt={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 _t(e,r="en-us",t={}){let a={value:e.value,unit:mt[e.unit]};return a.unit==null&&(a=ht(e.value,e.unit)),new Intl.NumberFormat(r,{...t,unit:a.unit,style:"unit"}).format(a.value)}function ht(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 Qe(e){const{locale:r}=J();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),a=g.useMemo(()=>({style:"currency",currency:e.currencyCode}),[e.currencyCode]),o=Z(r,a),i=Z(r,{...a,currencyDisplay:"name"}),u=Z(r,{...a,currencyDisplay:"narrowSymbol"}),n=Z(r,{...a,minimumFractionDigits:0,maximumFractionDigits:0}),l=Z(r),d=Z(r,{minimumFractionDigits:0,maximumFractionDigits:0}),h=m=>m.type==="currency",s=g.useMemo(()=>({original:()=>e,currencyCode:()=>e.currencyCode,localizedString:()=>o().format(t),parts:()=>o().formatToParts(t),withoutTrailingZeros:()=>t%1===0?n().format(t):o().format(t),withoutTrailingZerosAndCurrency:()=>t%1===0?d().format(t):l().format(t),currencyName:()=>{var m,_;return(_=(m=i().formatToParts(t).find(h))==null?void 0:m.value)!=null?_:e.currencyCode},currencySymbol:()=>{var m,_;return(_=(m=o().formatToParts(t).find(h))==null?void 0:m.value)!=null?_:e.currencyCode},currencyNarrowSymbol:()=>{var m,_;return(_=(m=u().formatToParts(t).find(h))==null?void 0:m.value)!=null?_:""},amount:()=>o().formatToParts(t).filter(m=>["decimal","fraction","group","integer","literal"].includes(m.type)).map(m=>m.value).join("")}),[e,t,i,o,u,l,n,d]);return g.useMemo(()=>new Proxy(s,{get:(m,_)=>{var p;return(p=Reflect.get(m,_))==null?void 0:p.call(null)}}),[s])}function Z(e,r){return g.useMemo(()=>{let t;return()=>t!=null?t:t=new Intl.NumberFormat(e,r)},[e,r])}var gt="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/Money.tsx";function pe({data:e,as:r,withoutCurrency:t,withoutTrailingZeros:a,measurement:o,measurementSeparator:i="/",...u}){if(!Et(e))throw new Error("<Money/> needs a valid 'data' prop that has 'amount' and 'currencyCode'");const n=Qe(e),l=r!=null?r:"div";let d=n.localizedString;return(t||a)&&(t&&!a?d=n.amount:!t&&a?d=n.withoutTrailingZeros:d=n.withoutTrailingZerosAndCurrency),w.default.createElement(l,{...u,__self:this,__source:{fileName:gt,lineNumber:65,columnNumber:5}},d,o&&o.referenceUnit&&w.default.createElement(w.default.Fragment,null,i,o.referenceUnit))}function Et(e){return typeof e.amount=="string"&&!!e.amount&&typeof e.currencyCode=="string"&&!!e.currencyCode}var Xe="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ProductPrice.tsx";function pt(e){var d,h,s,m,_,p,A,f;const{priceType:r="regular",variantId:t,valueType:a="min",data:o,...i}=e;if(o==null)throw new Error("<ProductPrice/> requires a product as the 'data' prop");let u,n;const l=t&&(h=B((d=o==null?void 0:o.variants)!=null?d:{}).find(S=>(S==null?void 0:S.id)===t))!=null?h:null;if(r==="compareAt")if(t&&l){if(((s=l.compareAtPriceV2)==null?void 0:s.amount)===((m=l.priceV2)==null?void 0:m.amount))return null;u=l.compareAtPriceV2}else a==="max"?u=(_=o==null?void 0:o.compareAtPriceRange)==null?void 0:_.maxVariantPrice:u=(p=o==null?void 0:o.compareAtPriceRange)==null?void 0:p.minVariantPrice;else t&&l?(u=l.priceV2,a==="unit"&&(u=l.unitPrice,n=l.unitPriceMeasurement)):a==="max"?u=(A=o.priceRange)==null?void 0:A.maxVariantPrice:u=(f=o.priceRange)==null?void 0:f.minVariantPrice;return u?n?w.default.createElement(pe,{...i,data:u,measurement:n,__self:this,__source:{fileName:Xe,lineNumber:81,columnNumber:7}}):w.default.createElement(pe,{...i,data:u,__self:this,__source:{fileName:Xe,lineNumber:85,columnNumber:10}}):null}var St="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ProductProvider.tsx";const Je=g.createContext(null);function vt({children:e,data:r,initialVariantId:t}){const a=g.useMemo(()=>{var f;return B((f=r.variants)!=null?f:{})},[r.variants]);if(!Ct(a))throw new Error("<ProductProvider/> requires 'product.variants.nodes' or 'product.variants.edges'");const o=g.useMemo(()=>Tt(a),[a]),[i,u]=g.useState(()=>rr(t,a)),[n,l]=g.useState(()=>tr(i));g.useEffect(()=>{const f=rr(t,a);u(f),l(tr(f))},[t,a]);const d=g.useCallback((f,S)=>{l(v=>{const b={...v,[f]:S};return u(er(a,b)),b})},[l,a]),h=g.useCallback((f,S)=>{var b;const v=er(a,{...n,[f]:S});return(b=v==null?void 0:v.availableForSale)!=null?b:!0},[n,a]),s=g.useMemo(()=>{var f;return B((f=r.sellingPlanGroups)!=null?f:{}).map(S=>{var v;return{...S,sellingPlans:B((v=S==null?void 0:S.sellingPlans)!=null?v:{})}})},[r.sellingPlanGroups]),[m,_]=g.useState(void 0),p=g.useMemo(()=>{var f,S;if(!(!i||!m)){if(!((f=i.sellingPlanAllocations)!=null&&f.nodes)&&!((S=i.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 B(i.sellingPlanAllocations).find(v=>{var b;return((b=v==null?void 0:v.sellingPlan)==null?void 0:b.id)===m.id})}},[i,m]),A=g.useMemo(()=>({variants:a,variantsConnection:r.variants,options:o,selectedVariant:i,setSelectedVariant:u,selectedOptions:n,setSelectedOption:d,setSelectedOptions:l,isOptionInStock:h,selectedSellingPlan:m,setSelectedSellingPlan:_,selectedSellingPlanAllocation:p,sellingPlanGroups:s,sellingPlanGroupsConnection:r.sellingPlanGroups}),[h,o,r.sellingPlanGroups,r.variants,n,m,p,i,s,d,a]);return w.default.createElement(Je.Provider,{value:A,__self:this,__source:{fileName:St,lineNumber:201,columnNumber:5}},e)}function bt(){const e=g.useContext(Je);if(!e)throw new Error("'useProduct' must be a child of <ProductProvider />");return e}function er(e,r){var t,a;if(!(!e.length||((a=(t=e==null?void 0:e[0])==null?void 0:t.selectedOptions)==null?void 0:a.length)!==Object.keys(r).length))return e==null?void 0:e.find(o=>Object.entries(r).every(([i,u])=>{var n;return(n=o==null?void 0:o.selectedOptions)==null?void 0:n.some(l=>(l==null?void 0:l.name)===i&&(l==null?void 0:l.value)===u)}))}function Tt(e){const r=e.reduce((t,a)=>{var o;if(!a.selectedOptions)throw new Error("'getOptions' requires 'variant.selectedOptions'");return(o=a==null?void 0:a.selectedOptions)==null||o.forEach(i=>{var u,n,l,d;t[(u=i==null?void 0:i.name)!=null?u:""]=t[(n=i==null?void 0:i.name)!=null?n:""]||new Set,t[(l=i==null?void 0:i.name)!=null?l:""].add((d=i==null?void 0:i.value)!=null?d:"")}),t},{});return Object.keys(r).map(t=>({name:t,values:Array.from(r[t])}))}function rr(e,r){if(e){const t=r.find(a=>(a==null?void 0:a.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 tr(e){return e!=null&&e.selectedOptions?e.selectedOptions.reduce((r,t)=>{var a,o;return r[(a=t==null?void 0:t.name)!=null?a:""]=(o=t==null?void 0:t.value)!=null?o:"",r},{}):{}}function Ct(e){return!(!e||!Array.isArray(e))}var nr="/home/runner/work/hydrogen-ui/hydrogen-ui/packages/react/src/ShopPayButton.tsx";const At="https://cdn.shopify.com/shopifycloud/shop-js/v1.0/client.js";function Nt({variantIds:e,className:r,variantIdsAndQuantities:t,width:a}){const{storeDomain:o}=J(),i=Ge(At);let u;if(e&&t)throw new Error(It);if(e)u=e.reduce((l,d)=>{const h=ar(d);return h&&l.push(h),l},[]);else if(t)u=t.reduce((l,d)=>{var s;const h=ar(d==null?void 0:d.id);return h&&l.push(`${h}:${(s=d==null?void 0:d.quantity)!=null?s:1}`),l},[]);else throw new Error(wt);const n=a?{"--shop-pay-button-width":a}:void 0;return w.default.createElement("div",{className:r,style:n,__self:this,__source:{fileName:nr,lineNumber:90,columnNumber:5}},i==="done"&&w.default.createElement("shop-pay-button",{"store-url":`https://${o}`,variants:u.join(","),__self:this,__source:{fileName:nr,lineNumber:92,columnNumber:9}}))}function ar(e){if(!!e)return e.split("/").pop()}const wt='You must pass in either "variantIds" or "variantIdsAndQuantities" to ShopPayButton',It="You must provide either a variantIds or variantIdsAndQuantities prop, but not both in the ShopPayButton component";function Ot({storeDomain:e,privateStorefrontToken:r,publicStorefrontToken:t,storefrontApiVersion:a,contentType:o}){return a!==X&&console.warn(`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: "${a}"; expected version ${X}`),{getStorefrontApiUrl(i){var u,n;return`https://${(u=i==null?void 0:i.storeDomain)!=null?u:e}.myshopify.com/api/${(n=i==null?void 0:i.storefrontApiVersion)!=null?n:a}/graphql.json`},getPrivateTokenHeaders(i){var n,l,d;if(!r&&!(i!=null&&i.privateStorefrontToken))throw new Error("StorefrontClient: You did not pass in a 'privateStorefrontToken' while using 'getPrivateTokenHeaders()'");return{"content-type":((n=i==null?void 0:i.contentType)!=null?n:o)==="graphql"?"application/graphql":"application/json","X-SDK-Variant":"hydrogen-ui","X-SDK-Variant-Source":"react","X-SDK-Version":a,"Shopify-Storefront-Private-Token":(d=(l=i==null?void 0:i.privateStorefrontToken)!=null?l:r)!=null?d:"",...i!=null&&i.buyerIp?{"Shopify-Storefront-Buyer-IP":i.buyerIp}:{}}},getPublicTokenHeaders(i){var n,l,d;if(!t&&!(i!=null&&i.publicStorefrontToken))throw new Error("StorefrontClient: You did not pass in a 'publicStorefrontToken' while using 'getPublicTokenHeaders()'");return{"content-type":((n=i==null?void 0:i.contentType)!=null?n:o)==="graphql"?"application/graphql":"application/json","X-SDK-Variant":"hydrogen-ui","X-SDK-Variant-Source":"react","X-SDK-Version":a,"X-Shopify-Storefront-Access-Token":(d=(l=i==null?void 0:i.publicStorefrontToken)!=null?l:t)!=null?d:""}}}}U.CartProvider=Qr,U.ExternalVideo=qe,U.Image=ie,U.MediaFile=dt,U.Metafield=ft,U.ModelViewer=Ze,U.Money=pe,U.ProductPrice=pt,U.ProductProvider=vt,U.ShopPayButton=Nt,U.ShopifyProvider=$r,U.Video=Ee,U.createStorefrontClient=Ot,U.flattenConnection=B,U.parseMetafield=Ke,U.parseMetafieldValue=ze,U.useCart=zr,U.useMoney=Qe,U.useProduct=bt,U.useShop=J,Object.defineProperties(U,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
3
240
|
//# sourceMappingURL=hydrogen-react.prod.js.map
|