@shopify/hydrogen 2023.1.0-alpha.1 → 2023.1.0-alpha.2

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.
@@ -1,7 +1,7 @@
1
- import { createStorefrontClient as createStorefrontClient$1 } from '@shopify/storefront-kit-react';
2
- export { AnalyticsEventName, AnalyticsPageType, ClientBrowserParameters, ExternalVideo, Image, MediaFile, ModelViewer, Money, ParsedMetafields, ShopPayButton, ShopifyAddToCart, ShopifyAddToCartPayload, ShopifyAnalytics, ShopifyAnalyticsPayload, ShopifyAnalyticsProduct, ShopifyAppSource, ShopifyCookies, ShopifyPageView, ShopifyPageViewPayload, StorefrontApiResponse, StorefrontApiResponseError, StorefrontApiResponseOk, StorefrontApiResponseOkPartial, StorefrontApiResponsePartial, Video, flattenConnection, getClientBrowserParameters, getShopifyCookies, parseMetafield, sendShopifyAnalytics, storefrontApiCustomScalars, useMoney, useShopifyCookies } from '@shopify/storefront-kit-react';
1
+ import { createStorefrontClient as createStorefrontClient$1 } from '@shopify/hydrogen-react';
2
+ export { AnalyticsEventName, AnalyticsPageType, ClientBrowserParameters, ExternalVideo, Image, MediaFile, ModelViewer, Money, ParsedMetafields, ShopPayButton, ShopifyAddToCart, ShopifyAddToCartPayload, ShopifyAnalytics, ShopifyAnalyticsPayload, ShopifyAnalyticsProduct, ShopifyCookies, ShopifyPageView, ShopifyPageViewPayload, ShopifySalesChannel, StorefrontApiResponse, StorefrontApiResponseError, StorefrontApiResponseOk, StorefrontApiResponseOkPartial, StorefrontApiResponsePartial, Video, flattenConnection, getClientBrowserParameters, getShopifyCookies, parseMetafield, sendShopifyAnalytics, storefrontApiCustomScalars, useMoney, useShopifyCookies } from '@shopify/hydrogen-react';
3
3
  import { ExecutionArgs } from 'graphql';
4
- import { LanguageCode, CountryCode, Maybe } from '@shopify/storefront-kit-react/storefront-api-types';
4
+ import { LanguageCode, CountryCode, Maybe } from '@shopify/hydrogen-react/storefront-api-types';
5
5
  import * as _remix_run_server_runtime from '@remix-run/server-runtime';
6
6
  import { LoaderArgs, LoaderFunction, SerializeFrom, AppData } from '@remix-run/server-runtime';
7
7
  import React from 'react';
@@ -41,18 +41,37 @@ declare function CacheLong(overrideOptions?: CachingStrategy): AllCacheOptions;
41
41
  */
42
42
  declare function CacheCustom(overrideOptions: CachingStrategy): AllCacheOptions;
43
43
 
44
- type StorefrontClient = ReturnType<typeof createStorefrontClient>;
45
- type Storefront = StorefrontClient['storefront'];
46
- type CreateStorefrontClientOptions = Parameters<typeof createStorefrontClient$1>[0] & {
44
+ type I18nBase = {
45
+ language: LanguageCode;
46
+ country: CountryCode;
47
+ };
48
+ type StorefrontClient<TI18n extends I18nBase> = {
49
+ storefront: Storefront<TI18n>;
50
+ };
51
+ type Storefront<TI18n extends I18nBase> = {
52
+ query: <T>(query: string, payload?: StorefrontCommonOptions & {
53
+ cache?: CachingStrategy;
54
+ }) => Promise<T>;
55
+ mutate: <T>(mutation: string, payload?: StorefrontCommonOptions) => Promise<T>;
56
+ cache?: Cache;
57
+ CacheNone: typeof CacheNone;
58
+ CacheLong: typeof CacheLong;
59
+ CacheShort: typeof CacheShort;
60
+ CacheCustom: typeof CacheCustom;
61
+ generateCacheControlHeader: typeof generateCacheControlHeader;
62
+ getPublicTokenHeaders: ReturnType<typeof createStorefrontClient$1>['getPublicTokenHeaders'];
63
+ getPrivateTokenHeaders: ReturnType<typeof createStorefrontClient$1>['getPrivateTokenHeaders'];
64
+ getShopifyDomain: ReturnType<typeof createStorefrontClient$1>['getShopifyDomain'];
65
+ getApiUrl: ReturnType<typeof createStorefrontClient$1>['getStorefrontApiUrl'];
66
+ isApiError: (error: any) => boolean;
67
+ i18n: TI18n;
68
+ };
69
+ type CreateStorefrontClientOptions<TI18n extends I18nBase> = Parameters<typeof createStorefrontClient$1>[0] & {
47
70
  cache?: Cache;
48
71
  buyerIp?: string;
49
72
  requestGroupId?: string;
50
73
  waitUntil?: ExecutionContext['waitUntil'];
51
- i18n?: {
52
- language: LanguageCode;
53
- country: CountryCode;
54
- pathPrefix?: string;
55
- };
74
+ i18n?: TI18n;
56
75
  };
57
76
  type StorefrontCommonOptions = {
58
77
  variables?: ExecutionArgs['variableValues'] & {
@@ -73,114 +92,7 @@ type StorefrontMutationOptions = StorefrontCommonOptions & {
73
92
  cache?: never;
74
93
  };
75
94
  declare const isStorefrontApiError: (error: any) => boolean;
76
- declare function createStorefrontClient({ cache, waitUntil, buyerIp, i18n, requestGroupId, ...clientOptions }: CreateStorefrontClientOptions): {
77
- storefront: {
78
- /**
79
- * Sends a GraphQL query to the Storefront API.
80
- *
81
- * Example:
82
- *
83
- * ```js
84
- * async function loader ({context: {storefront}}) {
85
- * const data = await storefront.query('query { ... }', {
86
- * variables: {},
87
- * cache: storefront.CacheLong()
88
- * });
89
- * }
90
- * ```
91
- */
92
- query: <T>(query: string, payload?: StorefrontCommonOptions & {
93
- cache?: CachingStrategy;
94
- }) => Promise<T>;
95
- /**
96
- * Sends a GraphQL mutation to the Storefront API.
97
- *
98
- * Example:
99
- *
100
- * ```js
101
- * async function loader ({context: {storefront}}) {
102
- * await storefront.mutate('mutation { ... }', {
103
- * variables: {},
104
- * });
105
- * }
106
- * ```
107
- */
108
- mutate: <T_1>(mutation: string, payload?: StorefrontCommonOptions) => Promise<T_1>;
109
- cache: Cache | undefined;
110
- CacheNone: typeof CacheNone;
111
- CacheLong: typeof CacheLong;
112
- CacheShort: typeof CacheShort;
113
- CacheCustom: typeof CacheCustom;
114
- generateCacheControlHeader: typeof generateCacheControlHeader;
115
- getPublicTokenHeaders: (props?: (Partial<Pick<{
116
- storeDomain: string;
117
- privateStorefrontToken?: string | undefined;
118
- publicStorefrontToken?: string | undefined;
119
- storefrontApiVersion: string;
120
- contentType?: "json" | "graphql" | undefined;
121
- }, "contentType">> & Pick<{
122
- storeDomain: string;
123
- privateStorefrontToken?: string | undefined;
124
- publicStorefrontToken?: string | undefined;
125
- storefrontApiVersion: string;
126
- contentType?: "json" | "graphql" | undefined;
127
- }, "publicStorefrontToken">) | undefined) => Record<string, string>;
128
- getPrivateTokenHeaders: (props?: (Partial<Pick<{
129
- storeDomain: string;
130
- privateStorefrontToken?: string | undefined;
131
- publicStorefrontToken?: string | undefined;
132
- storefrontApiVersion: string;
133
- contentType?: "json" | "graphql" | undefined;
134
- }, "contentType">> & Pick<{
135
- storeDomain: string;
136
- privateStorefrontToken?: string | undefined;
137
- publicStorefrontToken?: string | undefined;
138
- storefrontApiVersion: string;
139
- contentType?: "json" | "graphql" | undefined;
140
- }, "privateStorefrontToken"> & {
141
- buyerIp?: string | undefined;
142
- }) | undefined) => Record<string, string>;
143
- getShopifyDomain: (props?: Partial<Pick<{
144
- storeDomain: string;
145
- privateStorefrontToken?: string | undefined;
146
- publicStorefrontToken?: string | undefined;
147
- storefrontApiVersion: string;
148
- contentType?: "json" | "graphql" | undefined;
149
- }, "storeDomain">> | undefined) => string;
150
- getApiUrl: (props?: Partial<Pick<{
151
- storeDomain: string;
152
- privateStorefrontToken?: string | undefined;
153
- publicStorefrontToken?: string | undefined;
154
- storefrontApiVersion: string;
155
- contentType?: "json" | "graphql" | undefined;
156
- }, "storeDomain" | "storefrontApiVersion">> | undefined) => string;
157
- /**
158
- * Wether it's a GraphQL error returned in the Storefront API response.
159
- *
160
- * Example:
161
- *
162
- * ```js
163
- * async function loader ({context: {storefront}}) {
164
- * try {
165
- * await storefront.query(...);
166
- * } catch(error) {
167
- * if (storefront.isApiError(error)) {
168
- * // ...
169
- * }
170
- *
171
- * throw error;
172
- * }
173
- * }
174
- * ```
175
- */
176
- isApiError: (error: any) => boolean;
177
- i18n: {
178
- language: LanguageCode;
179
- country: CountryCode;
180
- pathPrefix: string;
181
- };
182
- };
183
- };
95
+ declare function createStorefrontClient<TI18n extends I18nBase>({ cache, waitUntil, buyerIp, i18n, requestGroupId, ...clientOptions }: CreateStorefrontClientOptions<TI18n>): StorefrontClient<TI18n>;
184
96
 
185
97
  /**
186
98
  * This is a limited implementation of an in-memory cache.
@@ -201,7 +113,7 @@ declare class InMemoryCache implements Cache {
201
113
  }
202
114
 
203
115
  type StorefrontRedirect = {
204
- storefront: Storefront;
116
+ storefront: Storefront<I18nBase>;
205
117
  request: Request;
206
118
  response?: Response;
207
119
  };
@@ -216,9 +128,105 @@ type StorefrontRedirect = {
216
128
  declare function storefrontRedirect({ storefront, request, response, }: StorefrontRedirect): Promise<Response>;
217
129
 
218
130
  declare function graphiqlLoader({ context }?: _remix_run_server_runtime.DataFunctionArgs & {
219
- context: LoaderArgs['context'] & StorefrontClient;
131
+ context: LoaderArgs['context'] & StorefrontClient<I18nBase>;
220
132
  }): Response;
221
133
 
134
+ /**
135
+ * Collects data under a certain key from useMatches
136
+ * @param dataKey - The key in `event.data` to collect data from
137
+ * @returns A merged object of the specified key
138
+ *
139
+ * @example
140
+ * ```tsx
141
+ * import {
142
+ * useDataFromMatches
143
+ * } from '@shopify/hydrogen';
144
+ *
145
+ * export async function loader({request, context}: LoaderArgs) {
146
+ * return defer({
147
+ * analytics: {
148
+ * shopId: 'gid://shopify/Shop/1',
149
+ * },
150
+ * });
151
+ * }
152
+ *
153
+ * export default function App() {
154
+ * const analytics = useDataFromMatches('analytics');
155
+ *
156
+ * console.log(analytics);
157
+ * // {
158
+ * // shopId: 'gid://shopify/Shop/1',
159
+ * // }
160
+ * ```
161
+ **/
162
+ declare function useDataFromMatches(dataKey: string): Record<string, unknown>;
163
+ /**
164
+ * Collects data under a certain key from useFetches.
165
+ *
166
+ * @param formDataKey - The form data key
167
+ * @param formDataValue - The value of formDataKey
168
+ * @param dataKey - the key in `fetcher.data` to collect data from
169
+ * @returns A merged object of the specified key
170
+ *
171
+ * @example
172
+ * ```tsx
173
+ * // In routes/cart.tsx
174
+ * import {
175
+ * useDataFromFetchers
176
+ * } from '@shopify/hydrogen';
177
+ *
178
+ * export async function action({request, context}: ActionArgs) {
179
+ * const cartId = await session.get('cartId');
180
+ * ...
181
+ * return json({
182
+ * analytics: {
183
+ * cartId,
184
+ * },
185
+ * });
186
+ * }
187
+ *
188
+ * // Anywhere when an action can be requested, make sure there is a form input and value
189
+ * // to identify the fetcher
190
+ * export function AddToCartButton({
191
+ * ...
192
+ * return (
193
+ * <fetcher.Form action="/cart" method="post">
194
+ * <input type="hidden" name="cartAction" value={CartAction.ADD_TO_CART} />
195
+ *
196
+ * // You can add additional data as hidden form inputs and it will also be collected
197
+ * // As long as it is JSON parse-able.
198
+ * export function AddToCartButton({
199
+ *
200
+ * const analytics = {
201
+ * products: [product]
202
+ * };
203
+ *
204
+ * return (
205
+ * <fetcher.Form action="/cart" method="post">
206
+ * <input type="hidden" name="cartAction" value={CartAction.ADD_TO_CART} />
207
+ * <input type="hidden" name="analytics" value={JSON.stringify(analytics)} />
208
+ *
209
+ * // In root.tsx
210
+ * export default function App() {
211
+ * const cartData = useDataFromFetchers({
212
+ * formDataKey: 'cartAction',
213
+ * formDataValue: CartAction.ADD_TO_CART,
214
+ * dataKey: 'analytics',
215
+ * });
216
+ *
217
+ * console.log(cartData);
218
+ * // {
219
+ * // cartId: 'gid://shopify/Cart/abc123',
220
+ * // products: [...]
221
+ * // }
222
+ * ```
223
+ **/
224
+ declare function useDataFromFetchers({ formDataKey, formDataValue, dataKey, }: {
225
+ formDataKey: string;
226
+ formDataValue: unknown;
227
+ dataKey: string;
228
+ }): Record<string, unknown> | undefined;
229
+
222
230
  interface Seo$1 {
223
231
  /**
224
232
  * The <title> HTML element defines the document's title that is shown in a
@@ -417,4 +425,4 @@ declare function Seo({ debug }: SeoProps): React.FunctionComponentElement<{
417
425
  children?: React.ReactNode;
418
426
  }>;
419
427
 
420
- export { CacheCustom, CacheLong, CacheNone, CacheShort, CreateStorefrontClientOptions, InMemoryCache, Seo, SeoHandleFunction, Storefront, StorefrontClient, StorefrontMutationOptions, StorefrontQueryOptions, createStorefrontClient, generateCacheControlHeader, graphiqlLoader, isStorefrontApiError, storefrontRedirect };
428
+ export { CacheCustom, CacheLong, CacheNone, CacheShort, CreateStorefrontClientOptions, I18nBase, InMemoryCache, Seo, SeoHandleFunction, Storefront, StorefrontClient, StorefrontMutationOptions, StorefrontQueryOptions, createStorefrontClient, generateCacheControlHeader, graphiqlLoader, isStorefrontApiError, storefrontRedirect, useDataFromFetchers, useDataFromMatches };
@@ -1,11 +1,11 @@
1
- import { a, b as b$1, d } from './chunk-2226DACX.js';
2
- import { createStorefrontClient } from '@shopify/storefront-kit-react';
3
- export { AnalyticsEventName, AnalyticsPageType, ExternalVideo, Image, MediaFile, ModelViewer, Money, ShopPayButton, ShopifyAppSource, Video, flattenConnection, getClientBrowserParameters, getShopifyCookies, parseMetafield, sendShopifyAnalytics, storefrontApiCustomScalars, useMoney, useShopifyCookies } from '@shopify/storefront-kit-react';
1
+ import { a, b, d } from './chunk-2226DACX.js';
2
+ import { createStorefrontClient } from '@shopify/hydrogen-react';
3
+ export { AnalyticsEventName, AnalyticsPageType, ExternalVideo, Image, MediaFile, ModelViewer, Money, ShopPayButton, ShopifySalesChannel, Video, flattenConnection, getClientBrowserParameters, getShopifyCookies, parseMetafield, sendShopifyAnalytics, storefrontApiCustomScalars, useMoney, useShopifyCookies } from '@shopify/hydrogen-react';
4
4
  import { redirect } from '@remix-run/server-runtime';
5
- import { useMatches, useLocation } from '@remix-run/react';
5
+ import { useMatches, useFetchers, useLocation } from '@remix-run/react';
6
6
 
7
- var _e=a(f=>{var A=Symbol.for("react.element"),et=Symbol.for("react.portal"),tt=Symbol.for("react.fragment"),rt=Symbol.for("react.strict_mode"),nt=Symbol.for("react.profiler"),ot=Symbol.for("react.provider"),st=Symbol.for("react.context"),at=Symbol.for("react.forward_ref"),it=Symbol.for("react.suspense"),ct=Symbol.for("react.memo"),ut=Symbol.for("react.lazy"),Se=Symbol.iterator;function pt(e){return e===null||typeof e!="object"?null:(e=Se&&e[Se]||e["@@iterator"],typeof e=="function"?e:null)}var we={isMounted:function(){return !1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Te=Object.assign,xe={};function E(e,t,r){this.props=e,this.context=t,this.refs=xe,this.updater=r||we;}E.prototype.isReactComponent={};E.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState");};E.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate");};function Ee(){}Ee.prototype=E.prototype;function J(e,t,r){this.props=e,this.context=t,this.refs=xe,this.updater=r||we;}var z=J.prototype=new Ee;z.constructor=J;Te(z,E.prototype);z.isPureReactComponent=!0;var Ce=Array.isArray,be=Object.prototype.hasOwnProperty,K={current:null},Ae={key:!0,ref:!0,__self:!0,__source:!0};function ke(e,t,r){var n,o={},a=null,c=null;if(t!=null)for(n in t.ref!==void 0&&(c=t.ref),t.key!==void 0&&(a=""+t.key),t)be.call(t,n)&&!Ae.hasOwnProperty(n)&&(o[n]=t[n]);var i=arguments.length-2;if(i===1)o.children=r;else if(1<i){for(var s=Array(i),u=0;u<i;u++)s[u]=arguments[u+2];o.children=s;}if(e&&e.defaultProps)for(n in i=e.defaultProps,i)o[n]===void 0&&(o[n]=i[n]);return {$$typeof:A,type:e,key:a,ref:c,props:o,_owner:K.current}}function ft(e,t){return {$$typeof:A,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Y(e){return typeof e=="object"&&e!==null&&e.$$typeof===A}function lt(e){var t={"=":"=0",":":"=2"};return "$"+e.replace(/[=:]/g,function(r){return t[r]})}var Re=/\/+/g;function G(e,t){return typeof e=="object"&&e!==null&&e.key!=null?lt(""+e.key):t.toString(36)}function I(e,t,r,n,o){var a=typeof e;(a==="undefined"||a==="boolean")&&(e=null);var c=!1;if(e===null)c=!0;else switch(a){case"string":case"number":c=!0;break;case"object":switch(e.$$typeof){case A:case et:c=!0;}}if(c)return c=e,o=o(c),e=n===""?"."+G(c,0):n,Ce(o)?(r="",e!=null&&(r=e.replace(Re,"$&/")+"/"),I(o,t,r,"",function(u){return u})):o!=null&&(Y(o)&&(o=ft(o,r+(!o.key||c&&c.key===o.key?"":(""+o.key).replace(Re,"$&/")+"/")+e)),t.push(o)),1;if(c=0,n=n===""?".":n+":",Ce(e))for(var i=0;i<e.length;i++){a=e[i];var s=n+G(a,i);c+=I(a,t,r,s,o);}else if(s=pt(e),typeof s=="function")for(e=s.call(e),i=0;!(a=e.next()).done;)a=a.value,s=n+G(a,i++),c+=I(a,t,r,s,o);else if(a==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return c}function O(e,t,r){if(e==null)return e;var n=[],o=0;return I(e,n,"","",function(a){return t.call(r,a,o++)}),n}function yt(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(r){(e._status===0||e._status===-1)&&(e._status=1,e._result=r);},function(r){(e._status===0||e._status===-1)&&(e._status=2,e._result=r);}),e._status===-1&&(e._status=0,e._result=t);}if(e._status===1)return e._result.default;throw e._result}var d={current:null},v={transition:null},dt={ReactCurrentDispatcher:d,ReactCurrentBatchConfig:v,ReactCurrentOwner:K};f.Children={map:O,forEach:function(e,t,r){O(e,function(){t.apply(this,arguments);},r);},count:function(e){var t=0;return O(e,function(){t++;}),t},toArray:function(e){return O(e,function(t){return t})||[]},only:function(e){if(!Y(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};f.Component=E;f.Fragment=tt;f.Profiler=nt;f.PureComponent=J;f.StrictMode=rt;f.Suspense=it;f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=dt;f.cloneElement=function(e,t,r){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var n=Te({},e.props),o=e.key,a=e.ref,c=e._owner;if(t!=null){if(t.ref!==void 0&&(a=t.ref,c=K.current),t.key!==void 0&&(o=""+t.key),e.type&&e.type.defaultProps)var i=e.type.defaultProps;for(s in t)be.call(t,s)&&!Ae.hasOwnProperty(s)&&(n[s]=t[s]===void 0&&i!==void 0?i[s]:t[s]);}var s=arguments.length-2;if(s===1)n.children=r;else if(1<s){i=Array(s);for(var u=0;u<s;u++)i[u]=arguments[u+2];n.children=i;}return {$$typeof:A,type:e.type,key:o,ref:a,props:n,_owner:c}};f.createContext=function(e){return e={$$typeof:st,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:ot,_context:e},e.Consumer=e};f.createElement=ke;f.createFactory=function(e){var t=ke.bind(null,e);return t.type=e,t};f.createRef=function(){return {current:null}};f.forwardRef=function(e){return {$$typeof:at,render:e}};f.isValidElement=Y;f.lazy=function(e){return {$$typeof:ut,_payload:{_status:-1,_result:e},_init:yt}};f.memo=function(e,t){return {$$typeof:ct,type:e,compare:t===void 0?null:t}};f.startTransition=function(e){var t=v.transition;v.transition={};try{e();}finally{v.transition=t;}};f.unstable_act=function(){throw Error("act(...) is not supported in production builds of React.")};f.useCallback=function(e,t){return d.current.useCallback(e,t)};f.useContext=function(e){return d.current.useContext(e)};f.useDebugValue=function(){};f.useDeferredValue=function(e){return d.current.useDeferredValue(e)};f.useEffect=function(e,t){return d.current.useEffect(e,t)};f.useId=function(){return d.current.useId()};f.useImperativeHandle=function(e,t,r){return d.current.useImperativeHandle(e,t,r)};f.useInsertionEffect=function(e,t){return d.current.useInsertionEffect(e,t)};f.useLayoutEffect=function(e,t){return d.current.useLayoutEffect(e,t)};f.useMemo=function(e,t){return d.current.useMemo(e,t)};f.useReducer=function(e,t,r){return d.current.useReducer(e,t,r)};f.useRef=function(e){return d.current.useRef(e)};f.useState=function(e){return d.current.useState(e)};f.useSyncExternalStore=function(e,t,r){return d.current.useSyncExternalStore(e,t,r)};f.useTransition=function(){return d.current.useTransition()};f.version="18.2.0";});var Oe=a((er,Pe)=>{Pe.exports=_e();});function te(e){let t=Array.isArray(e)?e:[e],r="";for(let n of t)n!=null&&(typeof n=="object"?!!n.body&&typeof n.body=="string"?r+=n.body:r+=JSON.stringify(n):r+=n);return r}var j="public",$e="private",je="no-store",re={maxAge:"max-age",staleWhileRevalidate:"stale-while-revalidate",sMaxAge:"s-maxage",staleIfError:"stale-if-error"};function b(e){let t=[];return Object.keys(e).forEach(r=>{r==="mode"?t.push(e[r]):re[r]&&t.push(`${re[r]}=${e[r]}`);}),t.join(", ")}function D(){return {mode:je}}function ne(e){if(e?.mode&&e?.mode!==j&&e?.mode!==$e)throw Error("'mode' must be either 'public' or 'private'")}function R(e){return ne(e),{mode:j,maxAge:1,staleWhileRevalidate:9,...e}}function H(e){return ne(e),{mode:j,maxAge:3600,staleWhileRevalidate:82800,...e}}function F(e){return e}function _(e,t){return e&&t?{...e,...t}:e||R()}function N(e){return b(_(e))}async function De(e,t){if(!e)return;let r=await e.match(t);if(!r){t.url;return}return t.url,r}async function He(e,t,r,n){if(!e)return;let o=_(n);t.headers.set("cache-control",N(_(o,{maxAge:(o.maxAge||0)+(o.staleWhileRevalidate||0)})));let a=N(_(o));r.headers.set("cache-control",a),r.headers.set("real-cache-control",a),r.headers.set("cache-put-date",new Date().toUTCString()),t.url,await e.put(t,r);}async function Fe(e,t){!e||(t.url,await e.delete(t));}function Ne(e,t){let r=t.headers.get("cache-put-date"),n=t.headers.get("real-cache-control"),o=0;if(n){let s=n.match(/max-age=(\d*)/);s&&s.length>1&&(o=parseFloat(s[1]));}if(!r)return !1;let i=(new Date().valueOf()-new Date(r).valueOf())/1e3>o;return i&&(e.url,void 0),i}var P={get:De,set:He,delete:Fe,generateDefaultCacheControlHeader:N,isStale:Ne};function V(e){return `https://shopify.dev/?${e}`}function Ve(e){return e||R()}async function oe(e,t){if(!e)return;let r=V(t),n=new Request(r),o=await P.get(e,n);if(!!o)return [await o.json(),o]}async function W(e,t,r,n){if(!e)return;let o=V(t),a=new Request(o),c=new Response(JSON.stringify(r));await P.set(e,a,c,Ve(n));}function se(e,t){return P.isStale(new Request(V(e)),t)}function ae(e,t){return [e,{status:t.status,statusText:t.statusText,headers:Array.from(t.headers.entries())}]}var ie=e=>!e?.errors,B=new Set;async function ce(e,t,{cacheInstance:r,cache:n,cacheKey:o=[e,t],shouldCacheResponse:a=()=>!0,waitUntil:c,returnType:i="json"}={}){!n&&(!t.method||t.method==="GET")&&(n=R());let s=async()=>{let p=await fetch(e,t),l;try{l=await p[i]();}catch{l=await p.text();}return [l,p]};if(!r||!o||!n)return s();let u=te([...typeof o=="string"?[o]:o]),h=await oe(r,u);if(h){let[p,l]=h;if(!B.has(u)&&se(u,l)){B.add(u);let T=Promise.resolve().then(async()=>{try{let[m,k]=await s();a(m,k)&&await W(r,u,ae(m,k),n);}catch(m){m.message&&(m.message="SWR in sub-request failed: "+m.message),console.error(m);}finally{B.delete(u);}});c?.(T);}let[g,w]=p;return [g,new Response(g,w)]}let[S,C]=await s();if(a(S,C)){let p=W(r,u,ae(S,C),n);c?.(p);}return [S,C]}var ue="Custom-Storefront-Request-Group-ID",pe="Shopify-Storefront-Buyer-IP";function fe(){return typeof crypto<"u"&&!!crypto.randomUUID?crypto.randomUUID():`weak-${Math.random().toString(16).substring(2)}`}function le(e){return String(e).includes("__proto__")?JSON.parse(e,We):JSON.parse(e)}function We(e,t){if(e!=="__proto__")return t}var ye=new Set,de=e=>{ye.has(e)||(console.warn(e),ye.add(e));};var me=class extends Error{},Qe=e=>e instanceof me,Ge=/(^|}\s)query[\s({]/im,Je=/(^|}\s)mutation[\s({]/im;function he(e){return e.replace(/\s*#.*$/gm,"").replace(/\s+/gm," ").trim()}function Qt({cache:e,waitUntil:t,buyerIp:r,i18n:n={language:"EN",country:"US"},requestGroupId:o=fe(),...a}){e||de("Storefront API client created without a cache instance. This may slow down your sub-requests.");let{getPublicTokenHeaders:c,getPrivateTokenHeaders:i,getStorefrontApiUrl:s,getShopifyDomain:u}=createStorefrontClient(a),S=(a.privateStorefrontToken?i:c)({contentType:"json"});S[ue]=o,r&&(S[pe]=r);async function C({query:p,mutation:l,variables:g,cache:w,headers:T=[],storefrontApiVersion:m}){let k=T instanceof Headers?Object.fromEntries(T.entries()):Array.isArray(T)?Object.fromEntries(T):T;p=p??l;let q={...g};n&&(!g?.country&&/\$country/.test(p)&&(q.country=n.country),!g?.language&&/\$language/.test(p)&&(q.language=n.language));let Me=s({storefrontApiVersion:m}),qe={method:"POST",headers:{...S,...k},body:JSON.stringify({query:p,variables:q})},[L,U]=await ce(Me,qe,{cacheInstance:l?void 0:e,cache:w||R(),shouldCacheResponse:ie,waitUntil:t});if(!U.ok){let $;try{$=le(L);}catch{$=[{message:L}];}ge(U,$);}let{data:Le,errors:X}=L;return X?.length&&ge(U,X,me),Le}return {storefront:{query:(p,l)=>{if(p=he(p),Je.test(p))throw new Error("storefront.query cannot execute mutations");return C({...l,query:p})},mutate:(p,l)=>{if(p=he(p),Ge.test(p))throw new Error("storefront.mutate cannot execute queries");return C({...l,mutation:p})},cache:e,CacheNone:D,CacheLong:H,CacheShort:R,CacheCustom:F,generateCacheControlHeader:b,getPublicTokenHeaders:c,getPrivateTokenHeaders:i,getShopifyDomain:u,getApiUrl:s,isApiError:Qe,i18n:{pathPrefix:"",...n}}}}function ge(e,t,r=Error){let n=e.headers.get("x-request-id"),o=n?` - Request ID: ${n}`:"";if(t){let a=typeof t=="string"?t:t.map(c=>c.message).join(`
8
- `);throw new r(a+o)}throw new r(`API response error: ${e.status}`+o)}var Q=class{#e;constructor(){this.#e=new Map;}add(t){throw new Error("Method not implemented. Use `put` instead.")}addAll(t){throw new Error("Method not implemented. Use `put` instead.")}matchAll(t,r){throw new Error("Method not implemented. Use `match` instead.")}async put(t,r){if(t.method!=="GET")throw new TypeError("Cannot cache response to non-GET request.");if(r.status===206)throw new TypeError("Cannot cache response to a range request (206 Partial Content).");if(r.headers.get("vary")?.includes("*"))throw new TypeError("Cannot cache response with 'Vary: *' header.");this.#e.set(t.url,{body:new Uint8Array(await r.arrayBuffer()),status:r.status,headers:[...r.headers],timestamp:Date.now()});}async match(t){if(t.method!=="GET")return;let r=this.#e.get(t.url);if(!r)return;let{body:n,timestamp:o,...a}=r,c=new Headers(a.headers),i=c.get("cache-control")||c.get("real-cache-control")||"",s=parseInt(i.match(/max-age=(\d+)/)?.[1]||"0",10),u=parseInt(i.match(/stale-while-revalidate=(\d+)/)?.[1]||"0",10),h=(Date.now()-o)/1e3;if(h>s+u){this.#e.delete(t.url);return}let C=h>s;return c.set("cache",C?"STALE":"HIT"),c.set("date",new Date(o).toUTCString()),new Response(n,{status:a.status??200,headers:c})}async delete(t){return this.#e.has(t.url)?(this.#e.delete(t.url),!0):!1}keys(t){let r=[];for(let n of this.#e.keys())(!t||t.url===n)&&r.push(new Request(n));return Promise.resolve(r)}};async function Ke({storefront:e,request:t,response:r=new Response("Not Found",{status:404})}){let{pathname:n,search:o}=new URL(t.url),a=n+o;try{let{urlRedirects:c}=await e.query(Xe,{variables:{query:"path:"+a},storefrontApiVersion:"2023-01"}),i=c?.edges?.[0]?.node?.target;if(i)return new Response(null,{status:302,headers:{location:i}});let s=new URLSearchParams(o),u=s.get("return_to")||s.get("redirect");if(u){if(Ye(u))return redirect(u);console.warn(`Cross-domain redirects are not supported. Tried to redirect from ${a} to ${u}`);}}catch(c){console.error(`Failed to fetch redirects from Storefront API for route ${a}`,c);}return r}function Ye(e){try{new URL(e);}catch{return !0}return !1}var Xe=`#graphql
7
+ var Ie=a(f=>{var k=Symbol.for("react.element"),st=Symbol.for("react.portal"),at=Symbol.for("react.fragment"),it=Symbol.for("react.strict_mode"),ct=Symbol.for("react.profiler"),ut=Symbol.for("react.provider"),pt=Symbol.for("react.context"),ft=Symbol.for("react.forward_ref"),lt=Symbol.for("react.suspense"),yt=Symbol.for("react.memo"),dt=Symbol.for("react.lazy"),Se=Symbol.iterator;function ht(e){return e===null||typeof e!="object"?null:(e=Se&&e[Se]||e["@@iterator"],typeof e=="function"?e:null)}var Re={isMounted:function(){return !1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},we=Object.assign,xe={};function b(e,t,r){this.props=e,this.context=t,this.refs=xe,this.updater=r||Re;}b.prototype.isReactComponent={};b.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState");};b.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate");};function be(){}be.prototype=b.prototype;function J(e,t,r){this.props=e,this.context=t,this.refs=xe,this.updater=r||Re;}var z=J.prototype=new be;z.constructor=J;we(z,b.prototype);z.isPureReactComponent=!0;var Ce=Array.isArray,Ee=Object.prototype.hasOwnProperty,K={current:null},ke={key:!0,ref:!0,__self:!0,__source:!0};function Ae(e,t,r){var n,o={},a=null,c=null;if(t!=null)for(n in t.ref!==void 0&&(c=t.ref),t.key!==void 0&&(a=""+t.key),t)Ee.call(t,n)&&!ke.hasOwnProperty(n)&&(o[n]=t[n]);var i=arguments.length-2;if(i===1)o.children=r;else if(1<i){for(var s=Array(i),u=0;u<i;u++)s[u]=arguments[u+2];o.children=s;}if(e&&e.defaultProps)for(n in i=e.defaultProps,i)o[n]===void 0&&(o[n]=i[n]);return {$$typeof:k,type:e,key:a,ref:c,props:o,_owner:K.current}}function gt(e,t){return {$$typeof:k,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Y(e){return typeof e=="object"&&e!==null&&e.$$typeof===k}function mt(e){var t={"=":"=0",":":"=2"};return "$"+e.replace(/[=:]/g,function(r){return t[r]})}var Te=/\/+/g;function G(e,t){return typeof e=="object"&&e!==null&&e.key!=null?mt(""+e.key):t.toString(36)}function O(e,t,r,n,o){var a=typeof e;(a==="undefined"||a==="boolean")&&(e=null);var c=!1;if(e===null)c=!0;else switch(a){case"string":case"number":c=!0;break;case"object":switch(e.$$typeof){case k:case st:c=!0;}}if(c)return c=e,o=o(c),e=n===""?"."+G(c,0):n,Ce(o)?(r="",e!=null&&(r=e.replace(Te,"$&/")+"/"),O(o,t,r,"",function(u){return u})):o!=null&&(Y(o)&&(o=gt(o,r+(!o.key||c&&c.key===o.key?"":(""+o.key).replace(Te,"$&/")+"/")+e)),t.push(o)),1;if(c=0,n=n===""?".":n+":",Ce(e))for(var i=0;i<e.length;i++){a=e[i];var s=n+G(a,i);c+=O(a,t,r,s,o);}else if(s=ht(e),typeof s=="function")for(e=s.call(e),i=0;!(a=e.next()).done;)a=a.value,s=n+G(a,i++),c+=O(a,t,r,s,o);else if(a==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return c}function _(e,t,r){if(e==null)return e;var n=[],o=0;return O(e,n,"","",function(a){return t.call(r,a,o++)}),n}function St(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(r){(e._status===0||e._status===-1)&&(e._status=1,e._result=r);},function(r){(e._status===0||e._status===-1)&&(e._status=2,e._result=r);}),e._status===-1&&(e._status=0,e._result=t);}if(e._status===1)return e._result.default;throw e._result}var d={current:null},v={transition:null},Ct={ReactCurrentDispatcher:d,ReactCurrentBatchConfig:v,ReactCurrentOwner:K};f.Children={map:_,forEach:function(e,t,r){_(e,function(){t.apply(this,arguments);},r);},count:function(e){var t=0;return _(e,function(){t++;}),t},toArray:function(e){return _(e,function(t){return t})||[]},only:function(e){if(!Y(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};f.Component=b;f.Fragment=at;f.Profiler=ct;f.PureComponent=J;f.StrictMode=it;f.Suspense=lt;f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Ct;f.cloneElement=function(e,t,r){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var n=we({},e.props),o=e.key,a=e.ref,c=e._owner;if(t!=null){if(t.ref!==void 0&&(a=t.ref,c=K.current),t.key!==void 0&&(o=""+t.key),e.type&&e.type.defaultProps)var i=e.type.defaultProps;for(s in t)Ee.call(t,s)&&!ke.hasOwnProperty(s)&&(n[s]=t[s]===void 0&&i!==void 0?i[s]:t[s]);}var s=arguments.length-2;if(s===1)n.children=r;else if(1<s){i=Array(s);for(var u=0;u<s;u++)i[u]=arguments[u+2];n.children=i;}return {$$typeof:k,type:e.type,key:o,ref:a,props:n,_owner:c}};f.createContext=function(e){return e={$$typeof:pt,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:ut,_context:e},e.Consumer=e};f.createElement=Ae;f.createFactory=function(e){var t=Ae.bind(null,e);return t.type=e,t};f.createRef=function(){return {current:null}};f.forwardRef=function(e){return {$$typeof:ft,render:e}};f.isValidElement=Y;f.lazy=function(e){return {$$typeof:dt,_payload:{_status:-1,_result:e},_init:St}};f.memo=function(e,t){return {$$typeof:yt,type:e,compare:t===void 0?null:t}};f.startTransition=function(e){var t=v.transition;v.transition={};try{e();}finally{v.transition=t;}};f.unstable_act=function(){throw Error("act(...) is not supported in production builds of React.")};f.useCallback=function(e,t){return d.current.useCallback(e,t)};f.useContext=function(e){return d.current.useContext(e)};f.useDebugValue=function(){};f.useDeferredValue=function(e){return d.current.useDeferredValue(e)};f.useEffect=function(e,t){return d.current.useEffect(e,t)};f.useId=function(){return d.current.useId()};f.useImperativeHandle=function(e,t,r){return d.current.useImperativeHandle(e,t,r)};f.useInsertionEffect=function(e,t){return d.current.useInsertionEffect(e,t)};f.useLayoutEffect=function(e,t){return d.current.useLayoutEffect(e,t)};f.useMemo=function(e,t){return d.current.useMemo(e,t)};f.useReducer=function(e,t,r){return d.current.useReducer(e,t,r)};f.useRef=function(e){return d.current.useRef(e)};f.useState=function(e){return d.current.useState(e)};f.useSyncExternalStore=function(e,t,r){return d.current.useSyncExternalStore(e,t,r)};f.useTransition=function(){return d.current.useTransition()};f.version="18.2.0";});var _e=a((ir,Pe)=>{Pe.exports=Ie();});function te(e){let t=Array.isArray(e)?e:[e],r="";for(let n of t)n!=null&&(typeof n=="object"?!!n.body&&typeof n.body=="string"?r+=n.body:r+=JSON.stringify(n):r+=n);return r}var j="public",De="private",je="no-store",re={maxAge:"max-age",staleWhileRevalidate:"stale-while-revalidate",sMaxAge:"s-maxage",staleIfError:"stale-if-error"};function E(e){let t=[];return Object.keys(e).forEach(r=>{r==="mode"?t.push(e[r]):re[r]&&t.push(`${re[r]}=${e[r]}`);}),t.join(", ")}function $(){return {mode:je}}function ne(e){if(e?.mode&&e?.mode!==j&&e?.mode!==De)throw Error("'mode' must be either 'public' or 'private'")}function T(e){return ne(e),{mode:j,maxAge:1,staleWhileRevalidate:9,...e}}function H(e){return ne(e),{mode:j,maxAge:3600,staleWhileRevalidate:82800,...e}}function F(e){return e}function I(e,t){return e&&t?{...e,...t}:e||T()}function N(e){return E(I(e))}async function $e(e,t){if(!e)return;let r=await e.match(t);if(!r){t.url;return}return t.url,r}async function He(e,t,r,n){if(!e)return;let o=I(n);t.headers.set("cache-control",N(I(o,{maxAge:(o.maxAge||0)+(o.staleWhileRevalidate||0)})));let a=N(I(o));r.headers.set("cache-control",a),r.headers.set("real-cache-control",a),r.headers.set("cache-put-date",new Date().toUTCString()),t.url,await e.put(t,r);}async function Fe(e,t){!e||(t.url,await e.delete(t));}function Ne(e,t){let r=t.headers.get("cache-put-date"),n=t.headers.get("real-cache-control"),o=0;if(n){let s=n.match(/max-age=(\d*)/);s&&s.length>1&&(o=parseFloat(s[1]));}if(!r)return !1;let i=(new Date().valueOf()-new Date(r).valueOf())/1e3>o;return i&&(e.url,void 0),i}var P={get:$e,set:He,delete:Fe,generateDefaultCacheControlHeader:N,isStale:Ne};function B(e){return `https://shopify.dev/?${e}`}function Be(e){return e||T()}async function oe(e,t){if(!e)return;let r=B(t),n=new Request(r),o=await P.get(e,n);if(!!o)return [await o.json(),o]}async function V(e,t,r,n){if(!e)return;let o=B(t),a=new Request(o),c=new Response(JSON.stringify(r));await P.set(e,a,c,Be(n));}function se(e,t){return P.isStale(new Request(B(e)),t)}function ae(e,t){return [e,{status:t.status,statusText:t.statusText,headers:Array.from(t.headers.entries())}]}var ie=e=>!e?.errors,W=new Set;async function ce(e,t,{cacheInstance:r,cache:n,cacheKey:o=[e,t],shouldCacheResponse:a=()=>!0,waitUntil:c,returnType:i="json"}={}){!n&&(!t.method||t.method==="GET")&&(n=T());let s=async()=>{let p=await fetch(e,t),l;try{l=await p[i]();}catch{l=await p.text();}return [l,p]};if(!r||!o||!n)return s();let u=te([...typeof o=="string"?[o]:o]),h=await oe(r,u);if(h){let[p,l]=h;if(!W.has(u)&&se(u,l)){W.add(u);let w=Promise.resolve().then(async()=>{try{let[m,A]=await s();a(m,A)&&await V(r,u,ae(m,A),n);}catch(m){m.message&&(m.message="SWR in sub-request failed: "+m.message),console.error(m);}finally{W.delete(u);}});c?.(w);}let[g,R]=p;return [g,new Response(g,R)]}let[S,C]=await s();if(a(S,C)){let p=V(r,u,ae(S,C),n);c?.(p);}return [S,C]}var ue="Custom-Storefront-Request-Group-ID",pe="Shopify-Storefront-Buyer-IP";function fe(){return typeof crypto<"u"&&!!crypto.randomUUID?crypto.randomUUID():`weak-${Math.random().toString(16).substring(2)}`}function le(e){return String(e).includes("__proto__")?JSON.parse(e,Ve):JSON.parse(e)}function Ve(e,t){if(e!=="__proto__")return t}var ye=new Set,de=e=>{ye.has(e)||(console.warn(e),ye.add(e));};var me=class extends Error{},Qe=e=>e instanceof me,Ge=/(^|}\s)query[\s({]/im,Je=/(^|}\s)mutation[\s({]/im;function he(e){return e.replace(/\s*#.*$/gm,"").replace(/\s+/gm," ").trim()}var ze={language:"EN",country:"US"};function Yt({cache:e,waitUntil:t,buyerIp:r,i18n:n,requestGroupId:o=fe(),...a}){e||de("Storefront API client created without a cache instance. This may slow down your sub-requests.");let{getPublicTokenHeaders:c,getPrivateTokenHeaders:i,getStorefrontApiUrl:s,getShopifyDomain:u}=createStorefrontClient(a),S=(a.privateStorefrontToken?i:c)({contentType:"json"});S[ue]=o,r&&(S[pe]=r);async function C({query:p,mutation:l,variables:g,cache:R,headers:w=[],storefrontApiVersion:m}){let A=w instanceof Headers?Object.fromEntries(w.entries()):Array.isArray(w)?Object.fromEntries(w):w;p=p??l;let q={...g};n&&(!g?.country&&/\$country/.test(p)&&(q.country=n.country),!g?.language&&/\$language/.test(p)&&(q.language=n.language));let Me=s({storefrontApiVersion:m}),qe={method:"POST",headers:{...S,...A},body:JSON.stringify({query:p,variables:q})},[L,U]=await ce(Me,qe,{cacheInstance:l?void 0:e,cache:R||T(),shouldCacheResponse:ie,waitUntil:t});if(!U.ok){let D;try{D=le(L);}catch{D=[{message:L}];}ge(U,D);}let{data:Le,errors:X}=L;return X?.length&&ge(U,X,me),Le}return {storefront:{query:(p,l)=>{if(p=he(p),Je.test(p))throw new Error("storefront.query cannot execute mutations");return C({...l,query:p})},mutate:(p,l)=>{if(p=he(p),Ge.test(p))throw new Error("storefront.mutate cannot execute queries");return C({...l,mutation:p})},cache:e,CacheNone:$,CacheLong:H,CacheShort:T,CacheCustom:F,generateCacheControlHeader:E,getPublicTokenHeaders:c,getPrivateTokenHeaders:i,getShopifyDomain:u,getApiUrl:s,isApiError:Qe,i18n:n??ze}}}function ge(e,t,r=Error){let n=e.headers.get("x-request-id"),o=n?` - Request ID: ${n}`:"";if(t){let a=typeof t=="string"?t:t.map(c=>c.message).join(`
8
+ `);throw new r(a+o)}throw new r(`API response error: ${e.status}`+o)}var Q=class{#e;constructor(){this.#e=new Map;}add(t){throw new Error("Method not implemented. Use `put` instead.")}addAll(t){throw new Error("Method not implemented. Use `put` instead.")}matchAll(t,r){throw new Error("Method not implemented. Use `match` instead.")}async put(t,r){if(t.method!=="GET")throw new TypeError("Cannot cache response to non-GET request.");if(r.status===206)throw new TypeError("Cannot cache response to a range request (206 Partial Content).");if(r.headers.get("vary")?.includes("*"))throw new TypeError("Cannot cache response with 'Vary: *' header.");this.#e.set(t.url,{body:new Uint8Array(await r.arrayBuffer()),status:r.status,headers:[...r.headers],timestamp:Date.now()});}async match(t){if(t.method!=="GET")return;let r=this.#e.get(t.url);if(!r)return;let{body:n,timestamp:o,...a}=r,c=new Headers(a.headers),i=c.get("cache-control")||c.get("real-cache-control")||"",s=parseInt(i.match(/max-age=(\d+)/)?.[1]||"0",10),u=parseInt(i.match(/stale-while-revalidate=(\d+)/)?.[1]||"0",10),h=(Date.now()-o)/1e3;if(h>s+u){this.#e.delete(t.url);return}let C=h>s;return c.set("cache",C?"STALE":"HIT"),c.set("date",new Date(o).toUTCString()),new Response(n,{status:a.status??200,headers:c})}async delete(t){return this.#e.has(t.url)?(this.#e.delete(t.url),!0):!1}keys(t){let r=[];for(let n of this.#e.keys())(!t||t.url===n)&&r.push(new Request(n));return Promise.resolve(r)}};async function Ye({storefront:e,request:t,response:r=new Response("Not Found",{status:404})}){let{pathname:n,search:o}=new URL(t.url),a=n+o;try{let{urlRedirects:c}=await e.query(Ze,{variables:{query:"path:"+a},storefrontApiVersion:"2023-01"}),i=c?.edges?.[0]?.node?.target;if(i)return new Response(null,{status:302,headers:{location:i}});let s=new URLSearchParams(o),u=s.get("return_to")||s.get("redirect");if(u){if(Xe(u))return redirect(u);console.warn(`Cross-domain redirects are not supported. Tried to redirect from ${a} to ${u}`);}}catch(c){console.error(`Failed to fetch redirects from Storefront API for route ${a}`,c);}return r}function Xe(e){try{new URL(e);}catch{return !0}return !1}var Ze=`#graphql
9
9
  query redirects($query: String) {
10
10
  urlRedirects(first: 1, query: $query) {
11
11
  edges {
@@ -15,7 +15,7 @@ var _e=a(f=>{var A=Symbol.for("react.element"),et=Symbol.for("react.portal"),tt=
15
15
  }
16
16
  }
17
17
  }
18
- `;function Ze({context:e}={}){if(!e?.storefront)throw new Error("GraphiQL: Hydrogen's storefront client must be injected in the loader context.");let t=e.storefront.getApiUrl(),r=e.storefront.getPublicTokenHeaders()["X-Shopify-Storefront-Access-Token"];return new Response(`
18
+ `;function et({context:e}={}){if(!e?.storefront)throw new Error("GraphiQL: Hydrogen's storefront client must be injected in the loader context.");let t=e.storefront.getApiUrl(),r=e.storefront.getPublicTokenHeaders()["X-Shopify-Storefront-Access-Token"];return new Response(`
19
19
  <!DOCTYPE html>
20
20
  <html lang="en">
21
21
  <head>
@@ -69,7 +69,7 @@ var _e=a(f=>{var A=Symbol.for("react.element"),et=Symbol.for("react.portal"),tt=
69
69
  <\/script>
70
70
  </body>
71
71
  </html>
72
- `,{status:200,headers:{"content-type":"text/html"}})}var x=b$1(Oe(),1);function ve(e){let t=[],r={"@context":"https://schema.org","@type":"Thing"};for(let o of Object.keys(e)){let i=(Array.isArray(e[o])?e[o]:[e[o]]).map(s=>{let u=[];if(!s)return u;switch(o){case"title":let h=ht(e.titleTemplate,s);u.push(y("title",h),y("meta",{property:"og:title",content:h}),y("meta",{name:"twitter:title",content:h})),r.name=h;break;case"description":u.push(y("meta",{name:"description",content:s}),y("meta",{property:"og:description",content:s}),y("meta",{name:"twitter:description",content:s})),r.description=s;break;case"url":u.push(y("meta",{property:"og:url",content:s}),y("link",{rel:"canonical",href:s})),r.url=s,r["@type"]=mt(s);break;case"handle":u.push(y("meta",{name:"twitter:site",content:s}),y("meta",{name:"twitter:creator",content:s}));break;case"ldJson":r={...r,...s};break;case"media":let S=Array.isArray(s)?s:[s];for(let p of S)if(typeof p=="string"&&(u.push(y("meta",{name:"og:image",content:s})),r.image=s),p&&typeof p=="object"){let l=p.type||"image",g=p?{url:p?.url,secure_url:p?.url,type:gt(p?.url),width:p?.width,height:p?.height,alt:p?.altText}:{};for(let w of Object.keys(g))g[w]&&u.push(y("meta",{property:`og:${l}:${w}`,content:g[w]},g.url));}break;case"alternates":let C=Array.isArray(s)?s:[s];for(let p of C){let{language:l,media:g,url:w,default:T}=p,m=l?`${l}${T?"-default":""}`:void 0;u.push(y("link",{rel:"alternate",hreflang:m,media:g,href:w}));}break}return u}).flat();t.push(i.filter(s=>!!s));}let n=[y("meta",{property:"og:type",content:"website"}),y("meta",{name:"twitter:card",content:"summary_large_image"})];return [...t,...n].flat().sort((o,a)=>o.key.localeCompare(a.key)).concat(y("script",{type:"application/ld+json",children:JSON.stringify(r)})).flat()}function y(e,t,r){let n={tag:e,props:{}};return e==="title"?(n.children=t,n.key=Ie(n),n):(e==="script"&&(n.children=t.children,delete t.children),n.props=t,Object.keys(n.props).forEach(o=>!n.props[o]&&delete n.props[o]),n.key=Ie(n,r),n)}function Ie(e,t){let{tag:r,props:n}=e;if(r==="title")return "0-title";if(r==="meta"){let o=n.content===t&&!n.property.endsWith("secure_url")&&"0";return [r,...[t,o],n.property||n.name].filter(c=>c).join("-")}return r==="link"?[r,n.rel,n.hreflang||n.media].filter(a=>a).join("-").replace(/\s+/g,"-"):`${r}-${n.type}`}function ht(e,t){return e?typeof e=="function"?e(t):e.replace("%s",t??""):t}function gt(e){let t=e.split(".").pop();return t==="svg"?"image/svg+xml":t==="png"?"image/png":t==="jpg"||t==="jpeg"?"image/jpeg":t==="gif"?"image/gif":t==="swf"?"application/x-shockwave-flash":t==="mp3"?"audio/mpeg":"image/jpeg"}function mt(e){let t="Thing",n=[{type:"WebSite",pattern:"^/$"},{type:"Product",pattern:"/products/.*"},{type:"ItemList",pattern:/\/collections$/},{type:"ItemList",pattern:/\/collections\/([^\/]+)/},{type:"WebPage",pattern:/\/pages\/([^\/]+)/},{type:"WebSite",pattern:/\/blogs\/([^\/]+)/},{type:"BlogPosting",pattern:/\/blogs\/([^\/]+)\/([^\/]+)/},{type:"Organization",pattern:"/policies"},{type:"Organization",pattern:/\/policies\/([^\/]+)/}].filter(o=>{let{pattern:a}=o;return new RegExp(a).test(e)});return n.length>0?n[n.length-1].type:t}var Rt=x.default.lazy(()=>import('./log-seo-tags-3MQL2PTY.js'));function wt({debug:e}){let t=useMatches(),r=useLocation(),n=t.flatMap(i=>{let{handle:s,...u}=i,h={...u,...r};return s===void 0||s.seo===void 0?[]:M(s.seo,h)}).reduce((i,s)=>(Object.keys(s).forEach(u=>!s[u]&&delete s[u]),{...i,...s}),{}),o=ve(n);e&&d(o);let a=o.map(i=>i.tag==="script"?x.default.createElement(i.tag,{...i.props,key:i.key,dangerouslySetInnerHTML:{__html:i.children}}):x.default.createElement(i.tag,{...i.props,key:i.key},i.children)),c=x.default.createElement(x.default.Suspense,{fallback:null},x.default.createElement(Rt,{headTags:o}));return x.default.createElement(x.default.Fragment,null,a,e&&c)}function M(e,...t){if(e instanceof Function)return M(e(...t),...t);let r={};return Array.isArray(e)?(r=e.reduce((n,o)=>[...n,M(o)],[]),r):e instanceof Object?(Object.entries(e).forEach(([o,a])=>{r[o]=M(a,...t);}),r):e}/**
72
+ `,{status:200,headers:{"content-type":"text/html"}})}function nt(e){let t=useMatches(),r={};return t.forEach(n=>{let o=n?.data;o&&o[e]&&Object.assign(r,o[e]);}),r}function ot({formDataKey:e,formDataValue:t,dataKey:r}){let n=useFetchers(),o={};for(let a of n){let c=a.submission?.formData,i=a.data;if(c&&c.get(e)===t&&i&&i[r]){Object.assign(o,i[r]);try{if(c.get(r)){let s=JSON.parse(String(c.get(r)));Object.assign(o,s);}}catch{}}}return Object.keys(o).length?o:void 0}var x=b(_e(),1);function ve(e){let t=[],r={"@context":"https://schema.org","@type":"Thing"};for(let o of Object.keys(e)){let i=(Array.isArray(e[o])?e[o]:[e[o]]).map(s=>{let u=[];if(!s)return u;switch(o){case"title":let h=Tt(e.titleTemplate,s);u.push(y("title",h),y("meta",{property:"og:title",content:h}),y("meta",{name:"twitter:title",content:h})),r.name=h;break;case"description":u.push(y("meta",{name:"description",content:s}),y("meta",{property:"og:description",content:s}),y("meta",{name:"twitter:description",content:s})),r.description=s;break;case"url":u.push(y("meta",{property:"og:url",content:s}),y("link",{rel:"canonical",href:s})),r.url=s,r["@type"]=wt(s);break;case"handle":u.push(y("meta",{name:"twitter:site",content:s}),y("meta",{name:"twitter:creator",content:s}));break;case"ldJson":r={...r,...s};break;case"media":let S=Array.isArray(s)?s:[s];for(let p of S)if(typeof p=="string"&&(u.push(y("meta",{name:"og:image",content:s})),r.image=s),p&&typeof p=="object"){let l=p.type||"image",g=p?{url:p?.url,secure_url:p?.url,type:Rt(p?.url),width:p?.width,height:p?.height,alt:p?.altText}:{};for(let R of Object.keys(g))g[R]&&u.push(y("meta",{property:`og:${l}:${R}`,content:g[R]},g.url));}break;case"alternates":let C=Array.isArray(s)?s:[s];for(let p of C){let{language:l,media:g,url:R,default:w}=p,m=l?`${l}${w?"-default":""}`:void 0;u.push(y("link",{rel:"alternate",hreflang:m,media:g,href:R}));}break}return u}).flat();t.push(i.filter(s=>!!s));}let n=[y("meta",{property:"og:type",content:"website"}),y("meta",{name:"twitter:card",content:"summary_large_image"})];return [...t,...n].flat().sort((o,a)=>o.key.localeCompare(a.key)).concat(y("script",{type:"application/ld+json",children:JSON.stringify(r)})).flat()}function y(e,t,r){let n={tag:e,props:{}};return e==="title"?(n.children=t,n.key=Oe(n),n):(e==="script"&&(n.children=t.children,delete t.children),n.props=t,Object.keys(n.props).forEach(o=>!n.props[o]&&delete n.props[o]),n.key=Oe(n,r),n)}function Oe(e,t){let{tag:r,props:n}=e;if(r==="title")return "0-title";if(r==="meta"){let o=n.content===t&&!n.property.endsWith("secure_url")&&"0";return [r,...[t,o],n.property||n.name].filter(c=>c).join("-")}return r==="link"?[r,n.rel,n.hreflang||n.media].filter(a=>a).join("-").replace(/\s+/g,"-"):`${r}-${n.type}`}function Tt(e,t){return e?typeof e=="function"?e(t):e.replace("%s",t??""):t}function Rt(e){let t=e.split(".").pop();return t==="svg"?"image/svg+xml":t==="png"?"image/png":t==="jpg"||t==="jpeg"?"image/jpeg":t==="gif"?"image/gif":t==="swf"?"application/x-shockwave-flash":t==="mp3"?"audio/mpeg":"image/jpeg"}function wt(e){let t="Thing",n=[{type:"WebSite",pattern:"^/$"},{type:"Product",pattern:"/products/.*"},{type:"ItemList",pattern:/\/collections$/},{type:"ItemList",pattern:/\/collections\/([^\/]+)/},{type:"WebPage",pattern:/\/pages\/([^\/]+)/},{type:"WebSite",pattern:/\/blogs\/([^\/]+)/},{type:"BlogPosting",pattern:/\/blogs\/([^\/]+)\/([^\/]+)/},{type:"Organization",pattern:"/policies"},{type:"Organization",pattern:/\/policies\/([^\/]+)/}].filter(o=>{let{pattern:a}=o;return new RegExp(a).test(e)});return n.length>0?n[n.length-1].type:t}var Et=x.default.lazy(()=>import('./log-seo-tags-3MQL2PTY.js'));function kt({debug:e}){let t=useMatches(),r=useLocation(),n=t.flatMap(i=>{let{handle:s,...u}=i,h={...u,...r};return s===void 0||s.seo===void 0?[]:M(s.seo,h)}).reduce((i,s)=>(Object.keys(s).forEach(u=>!s[u]&&delete s[u]),{...i,...s}),{}),o=ve(n);e&&d(o);let a=o.map(i=>i.tag==="script"?x.default.createElement(i.tag,{...i.props,key:i.key,dangerouslySetInnerHTML:{__html:i.children}}):x.default.createElement(i.tag,{...i.props,key:i.key},i.children)),c=x.default.createElement(x.default.Suspense,{fallback:null},x.default.createElement(Et,{headTags:o}));return x.default.createElement(x.default.Fragment,null,a,e&&c)}function M(e,...t){if(e instanceof Function)return M(e(...t),...t);let r={};return Array.isArray(e)?(r=e.reduce((n,o)=>[...n,M(o)],[]),r):e instanceof Object?(Object.entries(e).forEach(([o,a])=>{r[o]=M(a,...t);}),r):e}/**
73
73
  * @license React
74
74
  * react.production.min.js
75
75
  *
@@ -79,6 +79,6 @@ var _e=a(f=>{var A=Symbol.for("react.element"),et=Symbol.for("react.portal"),tt=
79
79
  * LICENSE file in the root directory of this source tree.
80
80
  */
81
81
 
82
- export { F as CacheCustom, H as CacheLong, D as CacheNone, R as CacheShort, Q as InMemoryCache, wt as Seo, Qt as createStorefrontClient, b as generateCacheControlHeader, Ze as graphiqlLoader, Qe as isStorefrontApiError, Ke as storefrontRedirect };
82
+ export { F as CacheCustom, H as CacheLong, $ as CacheNone, T as CacheShort, Q as InMemoryCache, kt as Seo, Yt as createStorefrontClient, E as generateCacheControlHeader, et as graphiqlLoader, Qe as isStorefrontApiError, Ye as storefrontRedirect, ot as useDataFromFetchers, nt as useDataFromMatches };
83
83
  //# sourceMappingURL=out.js.map
84
84
  //# sourceMappingURL=index.js.map