hydrogen-sfdgspsdmq-test1 0.0.1-security → 2024.1.14

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.

Potentially problematic release.


This version of hydrogen-sfdgspsdmq-test1 might be problematic. Click here for more details.

@@ -0,0 +1,626 @@
1
+ import { createStorefrontClient, SHOPIFY_STOREFRONT_ID_HEADER, getShopifyCookies, SHOPIFY_Y, SHOPIFY_STOREFRONT_Y_HEADER, SHOPIFY_S, SHOPIFY_STOREFRONT_S_HEADER, flattenConnection, ShopPayButton } from '@shopify/hydrogen-react';
2
+ export { AnalyticsEventName, AnalyticsPageType, ExternalVideo, IMAGE_FRAGMENT, Image, MediaFile, ModelViewer, Money, ShopifySalesChannel, Video, customerAccountApiCustomScalars, flattenConnection, getClientBrowserParameters, getShopifyCookies, parseGid, parseMetafield, sendShopifyAnalytics, storefrontApiCustomScalars, useLoadScript, useMoney, useShopifyCookies } from '@shopify/hydrogen-react';
3
+ import { lazy, createContext, forwardRef, useMemo, createElement, Suspense, Fragment, useRef, useEffect, useContext } from 'react';
4
+ import { useMatches, useLocation, useNavigation, Link, useNavigate, useFetcher, useFetchers } from '@remix-run/react';
5
+ import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
6
+ import ln from 'content-security-policy-builder';
7
+
8
+ function at(e){let t=Array.isArray(e)?e:[e],r="";for(let n of t)n!=null&&(typeof n=="object"?r+=JSON.stringify(n):r+=n.toString());return encodeURIComponent(r)}var ie="public",Ft="private",Ae="no-store",ot={maxAge:"max-age",staleWhileRevalidate:"stale-while-revalidate",sMaxAge:"s-maxage",staleIfError:"stale-if-error"};function Z(e){let t=[];return Object.keys(e).forEach(r=>{r==="mode"?t.push(e[r]):ot[r]&&t.push(`${ot[r]}=${e[r]}`);}),t.join(", ")}function xe(){return {mode:Ae}}function Ee(e){if(e?.mode&&e?.mode!==ie&&e?.mode!==Ft)throw Error("'mode' must be either 'public' or 'private'")}function G(e){return Ee(e),{mode:ie,maxAge:1,staleWhileRevalidate:9,...e}}function be(e){return Ee(e),{mode:ie,maxAge:3600,staleWhileRevalidate:82800,...e}}function V(e){return Ee(e),{mode:ie,maxAge:1,staleWhileRevalidate:86399,...e}}function Pe(e){return e}function $(e){return String(e).includes("__proto__")?JSON.parse(e,$t):JSON.parse(e)}function $t(e,t){if(e!=="__proto__")return t}function ce(e,t){return e&&t?{...e,...t}:e||V()}function Oe(e){return Z(ce(e))}async function qt(e,t){if(!e)return;let r=await e.match(t);if(!r){return}return r}async function Ht(e,t,r,n){if(!e)return;let a=ce(n),o=Oe(ce(a,{maxAge:(a.maxAge||0)+(a.staleWhileRevalidate||0)})),s=Oe(ce(a));r.headers.set("cache-control",o),r.headers.set("real-cache-control",s),r.headers.set("cache-put-date",new Date().toUTCString()),await e.put(t,r);}async function Qt(e,t){e&&await e.delete(t);}function Gt(e,t){let r=e.headers.get("real-cache-control"),n=0;if(r){let o=r.match(/max-age=(\d*)/);o&&o.length>1&&(n=parseFloat(o[1]));}return [(new Date().valueOf()-new Date(t).valueOf())/1e3,n]}function Vt(e,t){let r=t.headers.get("cache-put-date");if(!r)return !1;let[n,a]=Gt(t,r),o=n>a;return o}var ue={get:qt,set:Ht,delete:Qt,generateDefaultCacheControlHeader:Oe,isStale:Vt};function we(e){return `https://shopify.dev/?${e}`}function Bt(e){return e||V()}async function st(e,t){if(!e)return;let r=we(t),n=new Request(r),a=await ue.get(e,n);if(!a)return;let o=await a.text();try{return [$(o),a]}catch{return [o,a]}}async function De(e,t,r,n){if(!e)return;let a=we(t),o=new Request(a),s=new Response(JSON.stringify(r));await ue.set(e,o,s,Bt(n));}function it(e,t){return ue.isStale(new Request(we(e)),t)}function ct(e,t){return [e,{status:t.status,statusText:t.statusText,headers:Array.from(t.headers.entries())}]}function ut([e,t]){return [e,new Response(e,t)]}var pt=(e,t)=>!e?.errors&&t.status<400,Ue=new Set;async function Le(e,t,{strategy:r=G(),cacheInstance:n,shouldCacheResult:a=()=>!0,waitUntil:o,debugInfo:s}){let c=at([...typeof e=="string"?[e]:e]),l=m=>{({displayName:m.displayName,url:m.response?.url,responseInit:{status:m.response?.status||0,statusText:m.response?.statusText||"",headers:Array.from(m.response?.headers.entries()||[])}});},p=void 0;if(!n||!r||r.mode===Ae){let m=await t({addDebugData:l});return m}let f=await st(n,c);if(f){let[m,C]=f,S=it(c,C)?"STALE":"HIT";if(!Ue.has(c)&&S==="STALE"){Ue.add(c);let g=Promise.resolve().then(async()=>{let b=Date.now();try{let d=await t({addDebugData:l});a(d)&&(await De(n,c,d,r),p?.({result:d,cacheStatus:"PUT",overrideStartTime:b}));}catch(d){d.message&&(d.message="SWR in sub-request failed: "+d.message),console.error(d);}finally{Ue.delete(c);}});o?.(g);}return m}let y=await t({addDebugData:l});if(a(y)){let m=Promise.resolve().then(async()=>{await De(n,c,y,r);});o?.(m);}return y}async function dt(e,t,{cacheInstance:r,cache:n,cacheKey:a=[e,t],shouldCacheResponse:o=()=>!0,waitUntil:s,returnType:i="json",debugInfo:c}={}){return !n&&(!t.method||t.method==="GET")&&(n=G()),Le(a,async()=>{let u=await fetch(e,t),l;try{l=await u[i]();}catch{try{l=await u.text();}catch{return ct("",u)}}return ct(l,u)},{cacheInstance:r,waitUntil:s,strategy:n??null,debugInfo:c,shouldCacheResult:u=>o(...ut(u))}).then(ut)}var ve="Custom-Storefront-Request-Group-ID",ke="X-Shopify-Storefront-Access-Token",Ne="X-SDK-Variant",_e="X-SDK-Variant-Source",Me="X-SDK-Version";function lt(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():`weak-${Math.random().toString(16).substring(2)}`}var ee="2024.1.6";function B(e){return e.replace(/\s*#.*$/gm,"").replace(/\s+/gm," ").trim()}var Wt=/(^|}\s)query[\s({]/im,jt=/(^|}\s)mutation[\s({]/im;function pe(e,t){if(!Wt.test(e))throw new Error(`[h2:error:${t}] Can only execute queries`)}function de(e,t){if(!jt.test(e))throw new Error(`[h2:error:${t}] Can only execute mutations`)}var q=class extends Error{locations;path;extensions;constructor(t,r={}){let a=(r.clientOperation?`[h2:error:${r.clientOperation}] `:"")+t+(r.requestId?` - Request ID: ${r.requestId}`:"");super(a),this.name="GraphQLError",this.extensions=r.extensions,this.locations=r.locations,this.path=r.path,this.stack=r.stack||void 0;try{this.cause=JSON.stringify({...typeof r.cause=="object"?r.cause:{},requestId:r.requestId});}catch{r.cause&&(this.cause=r.cause);}}get[Symbol.toStringTag](){return this.name}toString(){let t=`${this.name}: ${this.message}`;if(this.path)try{t+=` | path: ${JSON.stringify(this.path)}`;}catch{}if(this.extensions)try{t+=` | extensions: ${JSON.stringify(this.extensions)}`;}catch{}return t+=`
9
+ `,this.stack&&(t+=`${this.stack.slice(this.stack.indexOf(`
10
+ `)+1)}
11
+ `),t}toJSON(){return {name:"Error",message:""}}};function te({url:e,response:t,errors:r,type:n,query:a,queryVariables:o,ErrorConstructor:s=Error,client:i="storefront"}){let c=(typeof r=="string"?r:r?.map?.(l=>l.message).join(`
12
+ `))||`URL: ${e}
13
+ API response error: ${t.status}`,u=new q(c,{query:a,queryVariables:o,cause:{errors:r},clientOperation:`${i}.${n}`,requestId:t.headers.get("x-request-id")});throw new s(u.message,{cause:u.cause})}function W(e,t={}){let r=new Error,n=(a,o="Error")=>{let s=(r.stack??"").split(`
14
+ `).slice(3+(t.stackOffset??0)).join(`
15
+ `).replace(/ at loader(\d+) \(/,(i,c)=>i.replace(c,""));return `${o}: ${a}
16
+ `+s};return e.then(a=>{if(a?.errors&&Array.isArray(a.errors)){let o=typeof t.logErrors=="function"?t.logErrors:()=>t.logErrors??!1;a.errors.forEach(s=>{s&&(s.stack=n(s.message,s.name),o(s)&&console.error(s));});}return a}).catch(a=>{throw a&&(a.stack=n(a.message,a.name)),a})}var k=void 0;var Zt={language:"EN",country:"US"};function aa(e){let {storefrontHeaders:t,cache:r,waitUntil:n,i18n:a,storefrontId:o,logErrors:s=!0,...i}=e,{getPublicTokenHeaders:u,getPrivateTokenHeaders:l,getStorefrontApiUrl:p,getShopifyDomain:f}=createStorefrontClient(i),m=(i.privateStorefrontToken?l:u)({contentType:"json",buyerIp:t?.buyerIp||""});if(m[ve]=t?.requestGroupId||lt(),o&&(m[SHOPIFY_STOREFRONT_ID_HEADER]=o),(m["user-agent"]=`Hydrogen ${ee}`),t&&t.cookie){let g=getShopifyCookies(t.cookie??"");g[SHOPIFY_Y]&&(m[SHOPIFY_STOREFRONT_Y_HEADER]=g[SHOPIFY_Y]),g[SHOPIFY_S]&&(m[SHOPIFY_STOREFRONT_S_HEADER]=g[SHOPIFY_S]);}let C=JSON.stringify({"content-type":m["content-type"],"user-agent":m["user-agent"],[Ne]:m[Ne],[_e]:m[_e],[Me]:m[Me],[ke]:m[ke]});async function S({query:g,mutation:b,variables:d,cache:I,headers:R=[],storefrontApiVersion:x,displayName:N,stackInfo:J}){let L=R instanceof Headers?Object.fromEntries(R.entries()):Array.isArray(R)?Object.fromEntries(R):R;g=g??b;let D={...d};a&&(!d?.country&&/\$country/.test(g)&&(D.country=a.country),!d?.language&&/\$language/.test(g)&&(D.language=a.language));let v=p({storefrontApiVersion:x}),E=JSON.stringify({query:g,variables:D}),w={method:"POST",headers:{...m,...L},body:E},z=[v,w.method,C,w.body],[_,F]=await dt(v,w,{cacheInstance:b?void 0:r,cache:I||V(),cacheKey:z,shouldCacheResponse:pt,waitUntil:n,debugInfo:{url:v,graphql:E,requestId:w.headers[ve],purpose:t?.purpose,stackInfo:J,displayName:N}}),Y={url:v,response:F,type:b?"mutation":"query",query:g,queryVariables:D,errors:void 0};if(!F.ok){let X;try{X=$(_);}catch{X=[{message:_}];}te({...Y,errors:X});}let{data:se,errors:Re}=_,Te=Re?.map(({message:X,...nt})=>new q(X,{...nt,clientOperation:`storefront.${Y.type}`,requestId:F.headers.get("x-request-id"),queryVariables:D,query:g}));return h(se,Te)}return {storefront:{query(g,b){g=B(g),pe(g,"storefront.query");let d=gt?.(g);return W(S({...b,query:g,stackInfo:k?.(d)}),{stackOffset:d,logErrors:s})},mutate(g,b){g=B(g),de(g,"storefront.mutate");let d=gt?.(g);return W(S({...b,mutation:g,stackInfo:k?.(d)}),{stackOffset:d,logErrors:s})},cache:r,CacheNone:xe,CacheLong:be,CacheShort:G,CacheCustom:Pe,generateCacheControlHeader:Z,getPublicTokenHeaders:u,getPrivateTokenHeaders:l,getShopifyDomain:f,getApiUrl:p,isApiError:g=>!1,i18n:a??Zt}}}var gt=void 0;function h(e,t){return {...e,...t&&{errors:t}}}function le(e,t){let r=e.headers?.get?.(t)??e.headers?.[t];return typeof r=="string"?r:null}function H(e){return {requestId:e?le(e,"request-id"):void 0,purpose:e?le(e,"purpose"):void 0}}function pa({cache:e,waitUntil:t,request:r}){return function(a,o,s){return Le(a,s,{strategy:o,cacheInstance:e,waitUntil:t,debugInfo:{...H(r),stackInfo:k?.()}})}}var Fe=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:a,...o}=r,s=new Headers(o.headers),i=s.get("cache-control")||s.get("real-cache-control")||"",c=parseInt(i.match(/max-age=(\d+)/)?.[1]||"0",10),u=parseInt(i.match(/stale-while-revalidate=(\d+)/)?.[1]||"0",10),l=(Date.now()-a)/1e3;if(l>c+u){this.#e.delete(t.url);return}let f=l>c;return s.set("cache",f?"STALE":"HIT"),s.set("date",new Date(a).toUTCString()),new Response(n,{status:o.status??200,headers:s})}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)}};function fe(e){if(!e)return;let{pathname:t,search:r}=new URL(e),n=t+r,a=new URLSearchParams(r),o=a.get("return_to")||a.get("redirect");if(o){if(er(e,o))return o;console.warn(`Cross-domain redirects are not supported. Tried to redirect from ${n} to ${o}`);}}function er(e,t){try{return new URL(e).origin===new URL(t,e).origin}catch{return !1}}async function tr(e){let{storefront:t,request:r,noAdminRedirect:n,response:a=new Response("Not Found",{status:404})}=e,o=new URL(r.url),s=o.searchParams.has("_data");o.searchParams.delete("_data");let i=o.toString().replace(o.origin,"");if(o.pathname==="/admin"&&!n)return $e(`${t.getShopifyDomain()}/admin`,s);try{let{urlRedirects:c}=await t.query(rr,{variables:{query:"path:"+i}}),u=c?.edges?.[0]?.node?.target;if(u)return $e(u,s);let l=fe(r.url);if(l)return $e(l,s)}catch(c){console.error(`Failed to fetch redirects from Storefront API for route ${i}`,c);}return a}function $e(e,t){return t?new Response(null,{status:200,headers:{"X-Remix-Redirect":e,"X-Remix-Status":"302"}}):new Response(null,{status:302,headers:{location:e}})}var rr=`#graphql
17
+ query redirects($query: String) {
18
+ urlRedirects(first: 1, query: $query) {
19
+ edges {
20
+ node {
21
+ target
22
+ }
23
+ }
24
+ }
25
+ }
26
+ `;var nr=async function({request:t,context:r}){let n=r.storefront,a=r.customerAccount,o=new URL(t.url);if(!n)throw new Error("GraphiQL: Hydrogen's storefront client must be injected in the loader context.");let s={};if(n){let u="X-Shopify-Storefront-Access-Token";s.storefront={name:"Storefront API",authHeader:u,accessToken:n.getPublicTokenHeaders()[u],apiUrl:n.getApiUrl(),icon:"SF"};}if(a){let u=await(await fetch(o.origin+"/graphiql/customer-account.schema.json")).json(),l=await a.getAccessToken();u&&(s["customer-account"]={name:"Customer Account API",value:u,authHeader:"Authorization",accessToken:l,apiUrl:a.getApiUrl(),icon:"CA"});}let i="https://avatars.githubusercontent.com/u/12972006?s=48&v=4",c=String.raw;return new Response(c`
27
+ <!DOCTYPE html>
28
+ <html lang="en">
29
+ <head>
30
+ <title>GraphiQL</title>
31
+ <link rel="icon" type="image/x-icon" href="${i}" />
32
+ <style>
33
+ body {
34
+ height: 100%;
35
+ margin: 0;
36
+ width: 100%;
37
+ overflow: hidden;
38
+ background-color: hsl(219, 29%, 18%);
39
+ }
40
+
41
+ #graphiql {
42
+ height: 100vh;
43
+ }
44
+
45
+ #graphiql > .placeholder {
46
+ color: slategray;
47
+ width: fit-content;
48
+ margin: 40px auto;
49
+ font-family: Arial;
50
+ }
51
+
52
+ .graphiql-api-toolbar-label {
53
+ position: absolute;
54
+ bottom: -6px;
55
+ right: -4px;
56
+ font-size: 8px;
57
+ }
58
+ </style>
59
+
60
+ <script
61
+ crossorigin
62
+ src="https://unpkg.com/react@18/umd/react.development.js"
63
+ ></script>
64
+ <script
65
+ crossorigin
66
+ src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"
67
+ ></script>
68
+ <link
69
+ rel="stylesheet"
70
+ href="https://unpkg.com/graphiql@3/graphiql.min.css"
71
+ />
72
+ <link
73
+ rel="stylesheet"
74
+ href="https://unpkg.com/@graphiql/plugin-explorer/dist/style.css"
75
+ />
76
+ </head>
77
+
78
+ <body>
79
+ <div id="graphiql">
80
+ <div class="placeholder">Loading GraphiQL...</div>
81
+ </div>
82
+
83
+ <script
84
+ src="https://unpkg.com/graphiql@3/graphiql.min.js"
85
+ type="application/javascript"
86
+ crossorigin="anonymous"
87
+ ></script>
88
+ <script
89
+ src="https://unpkg.com/@graphiql/plugin-explorer/dist/index.umd.js"
90
+ type="application/javascript"
91
+ crossorigin="anonymous"
92
+ ></script>
93
+
94
+ <script>
95
+ const windowUrl = new URL(document.URL);
96
+ const startingSchemaKey =
97
+ windowUrl.searchParams.get('schema') || 'storefront';
98
+
99
+ let query = '{ shop { name } }';
100
+ if (windowUrl.searchParams.has('query')) {
101
+ query = decodeURIComponent(
102
+ windowUrl.searchParams.get('query') ?? query,
103
+ );
104
+ }
105
+
106
+ // Prettify query
107
+ query = GraphiQL.GraphQL.print(GraphiQL.GraphQL.parse(query));
108
+
109
+ let variables;
110
+ if (windowUrl.searchParams.has('variables')) {
111
+ variables = decodeURIComponent(
112
+ windowUrl.searchParams.get('variables') ?? '',
113
+ );
114
+ }
115
+
116
+ // Prettify variables
117
+ if (variables) {
118
+ variables = JSON.stringify(JSON.parse(variables), null, 2);
119
+ }
120
+
121
+ const schemas = ${JSON.stringify(s)};
122
+ let lastActiveTabIndex = -1;
123
+ let lastTabAmount = -1;
124
+
125
+ const root = ReactDOM.createRoot(
126
+ document.getElementById('graphiql'),
127
+ );
128
+
129
+ root.render(React.createElement(RootWrapper));
130
+
131
+ const TAB_STATE_KEY = 'graphiql:tabState';
132
+ const storage = {
133
+ getTabState: () =>
134
+ JSON.parse(localStorage.getItem(TAB_STATE_KEY)),
135
+ setTabState: (state) =>
136
+ localStorage.setItem(TAB_STATE_KEY, JSON.stringify(state)),
137
+ };
138
+
139
+ let nextSchemaKey;
140
+
141
+ function RootWrapper() {
142
+ const [activeSchema, setActiveSchema] =
143
+ React.useState(startingSchemaKey);
144
+
145
+ const schema = schemas[activeSchema];
146
+ if (!schema) {
147
+ throw new Error('No schema found for ' + activeSchema);
148
+ }
149
+
150
+ const keys = Object.keys(schemas);
151
+
152
+ return React.createElement(
153
+ GraphiQL,
154
+ {
155
+ fetcher: GraphiQL.createFetcher({
156
+ url: schema.apiUrl,
157
+ headers: {[schema.authHeader]: schema.accessToken},
158
+ }),
159
+ defaultEditorToolsVisibility: true,
160
+ query,
161
+ variables,
162
+ schema: schema.value,
163
+ plugins: [GraphiQLPluginExplorer.explorerPlugin()],
164
+ onTabChange: (state) => {
165
+ const {activeTabIndex, tabs} = state;
166
+ const activeTab = tabs[activeTabIndex];
167
+
168
+ if (
169
+ activeTabIndex === lastActiveTabIndex &&
170
+ lastTabAmount === tabs.length
171
+ ) {
172
+ if (
173
+ nextSchemaKey &&
174
+ activeTab &&
175
+ activeTab.schemaKey !== nextSchemaKey
176
+ ) {
177
+ activeTab.schemaKey = nextSchemaKey;
178
+ nextSchemaKey = undefined;
179
+
180
+ // Sync state to localStorage. GraphiQL resets the state
181
+ // asynchronously, so we need to do it in a timeout.
182
+ storage.setTabState(state);
183
+ setTimeout(() => storage.setTabState(state), 500);
184
+ }
185
+
186
+ // React rerrendering, skip
187
+ return;
188
+ }
189
+
190
+ if (activeTab) {
191
+ if (!activeTab.schemaKey) {
192
+ // Creating a new tab
193
+ if (lastTabAmount < tabs.length) {
194
+ activeTab.schemaKey = activeSchema;
195
+ storage.setTabState(state);
196
+ }
197
+ }
198
+
199
+ const nextSchema = activeTab.schemaKey || 'storefront';
200
+
201
+ if (nextSchema !== activeSchema) {
202
+ setActiveSchema(nextSchema);
203
+ }
204
+ }
205
+
206
+ lastActiveTabIndex = activeTabIndex;
207
+ lastTabAmount = tabs.length;
208
+ },
209
+ toolbar: {
210
+ additionalComponent: function () {
211
+ const schema = schemas[activeSchema];
212
+
213
+ return React.createElement(
214
+ GraphiQL.React.ToolbarButton,
215
+ {
216
+ onClick: () => {
217
+ const activeKeyIndex = keys.indexOf(activeSchema);
218
+ nextSchemaKey =
219
+ keys[(activeKeyIndex + 1) % keys.length];
220
+
221
+ // This triggers onTabChange
222
+ if (nextSchemaKey) setActiveSchema(nextSchemaKey);
223
+ },
224
+ label: 'Toggle between different API schemas',
225
+ },
226
+ React.createElement(
227
+ 'div',
228
+ {
229
+ key: 'api-wrapper',
230
+ className: 'graphiql-toolbar-icon',
231
+ style: {position: 'relative', fontWeight: 'bolder'},
232
+ },
233
+ [
234
+ React.createElement(
235
+ 'div',
236
+ {key: 'icon', style: {textAlign: 'center'}},
237
+ [
238
+ schema.icon,
239
+ React.createElement(
240
+ 'div',
241
+ {
242
+ key: 'icon-label',
243
+ className: 'graphiql-api-toolbar-label',
244
+ },
245
+ 'API',
246
+ ),
247
+ ],
248
+ ),
249
+ ],
250
+ ),
251
+ );
252
+ },
253
+ },
254
+ },
255
+ [
256
+ React.createElement(
257
+ GraphiQL.Logo,
258
+ {
259
+ key: 'Logo replacement',
260
+ },
261
+ [
262
+ React.createElement(
263
+ 'div',
264
+ {
265
+ key: 'Logo wrapper',
266
+ style: {display: 'flex', alignItems: 'center'},
267
+ },
268
+ [
269
+ React.createElement(
270
+ 'div',
271
+ {
272
+ key: 'api',
273
+ className: 'graphiql-logo',
274
+ style: {
275
+ paddingRight: 0,
276
+ whiteSpace: 'nowrap',
277
+ },
278
+ },
279
+ [schema.name],
280
+ ),
281
+ React.createElement(GraphiQL.Logo, {key: 'logo'}),
282
+ ],
283
+ ),
284
+ ],
285
+ ),
286
+ ],
287
+ );
288
+ }
289
+ </script>
290
+ </body>
291
+ </html>
292
+ `,{status:200,headers:{"content-type":"text/html"}})};var ar={"&":"\\u0026",">":"\\u003e","<":"\\u003c","\u2028":"\\u2028","\u2029":"\\u2029"},or=/[&><\u2028\u2029]/g;function yt(e){return e.replace(or,t=>ar[t])}var M="Error in SEO input: ",me={title:{validate:e=>{if(typeof e!="string")throw new Error(M.concat("`title` should be a string"));if(typeof e=="string"&&e.length>120)throw new Error(M.concat("`title` should not be longer than 120 characters"));return e}},description:{validate:e=>{if(typeof e!="string")throw new Error(M.concat("`description` should be a string"));if(typeof e=="string"&&e.length>155)throw new Error(M.concat("`description` should not be longer than 155 characters"));return e}},url:{validate:e=>{if(typeof e!="string")throw new Error(M.concat("`url` should be a string"));if(typeof e=="string"&&!e.startsWith("http"))throw new Error(M.concat("`url` should be a valid URL"));return e}},handle:{validate:e=>{if(typeof e!="string")throw new Error(M.concat("`handle` should be a string"));if(typeof e=="string"&&!e.startsWith("@"))throw new Error(M.concat("`handle` should start with `@`"));return e}}};function ht(e){let t=[];for(let r of Object.keys(e))switch(r){case"title":{let n=ge(me.title,e.title),a=sr(e?.titleTemplate,n);if(!a)break;t.push(P("title",{title:a}),P("meta",{property:"og:title",content:a}),P("meta",{name:"twitter:title",content:a}));break}case"description":{let n=ge(me.description,e.description);if(!n)break;t.push(P("meta",{name:"description",content:n}),P("meta",{property:"og:description",content:n}),P("meta",{name:"twitter:description",content:n}));break}case"url":{let n=ge(me.url,e.url);if(!n)break;let o=n.split("?")[0].replace(/\/$/,"");t.push(P("link",{rel:"canonical",href:o}),P("meta",{property:"og:url",content:o}));break}case"handle":{let n=ge(me.handle,e.handle);if(!n)break;t.push(P("meta",{name:"twitter:site",content:n}),P("meta",{name:"twitter:creator",content:n}));break}case"media":{let n,a=He(e.media);for(let o of a)if(typeof o=="string"&&t.push(P("meta",{name:"og:image",content:o})),o&&typeof o=="object"){let s=o.type||"image",i=o?{url:o?.url,secure_url:o?.url,type:ir(o.url),width:o?.width,height:o?.height,alt:o?.altText}:{};for(let c of Object.keys(i))i[c]&&(n=i[c],t.push(P("meta",{property:`og:${s}:${c}`,content:n},i.url)));}break}case"jsonLd":{let n=He(e.jsonLd),a=0;for(let o of n){if(typeof o!="object")continue;let s=P("script",{type:"application/ld+json",children:JSON.stringify(o,(i,c)=>typeof c=="string"?yt(c):c)},`json-ld-${o?.["@type"]||o?.name||a++}`);t.push(s);}break}case"alternates":{let n=He(e.alternates);for(let a of n){if(!a)continue;let{language:o,url:s,default:i}=a,c=o?`${o}${i?"-default":""}`:void 0;t.push(P("link",{rel:"alternate",hrefLang:c,href:s}));}break}case"robots":{if(!e.robots)break;let{maxImagePreview:n,maxSnippet:a,maxVideoPreview:o,noArchive:s,noFollow:i,noImageIndex:c,noIndex:u,noSnippet:l,noTranslate:p,unavailableAfter:f}=e.robots,y=[s&&"noarchive",c&&"noimageindex",l&&"nosnippet",p&&"notranslate",n&&`max-image-preview:${n}`,a&&`max-snippet:${a}`,o&&`max-video-preview:${o}`,f&&`unavailable_after:${f}`],m=(u?"noindex":"index")+","+(i?"nofollow":"follow");for(let C of y)C&&(m+=`,${C}`);t.push(P("meta",{name:"robots",content:m}));break}}return t.flat().sort((r,n)=>r.key.localeCompare(n.key))}function P(e,t,r){let n={tag:e,props:{},key:""};return e==="title"?(n.children=t.title,n.key=qe(n),n):e==="script"?(n.children=typeof t.children=="string"?t.children:"",n.key=qe(n,r),delete t.children,n.props=t,n):(n.props=t,Object.keys(n.props).forEach(a=>!n.props[a]&&delete n.props[a]),n.key=qe(n,r),n)}function qe(e,t){let{tag:r,props:n}=e;if(r==="title")return "0-title";if(r==="meta"){let a=n.content===t&&typeof n.property=="string"&&!n.property.endsWith("secure_url")&&"0";return [r,...[t,a],n.property||n.name].filter(s=>s).join("-")}return r==="link"?[r,n.rel,n.hrefLang||n.media].filter(o=>o).join("-").replace(/\s+/g,"-"):r==="script"?`${r}-${t}`:`${r}-${n.type}`}function sr(e,t){if(t)return e?typeof e=="function"?e(t):e.replace("%s",t??""):t}function ir(e){switch(e&&e.split(".").pop()){case"svg":return "image/svg+xml";case"png":return "image/png";case"gif":return "image/gif";case"swf":return "application/x-shockwave-flash";case"mp3":return "audio/mpeg";case"jpg":case"jpeg":default:return "image/jpeg"}}function He(e){return Array.isArray(e)?e:[e]}function ge(e,t){try{return e.validate(t)}catch(r){return console.warn(r.message),t}}var fr=lazy(()=>import('./log-seo-tags-TY72EQWZ.js'));function mr({debug:e}){let t=useMatches(),r=useLocation(),n=useMemo(()=>t.flatMap(s=>{let{handle:i,...c}=s,u={...c,...r},l=i?.seo,p=c?.data?.seo;return !l&&!p?[]:l?ye(l,u):[p]}).reduce((s,i)=>{Object.keys(i).forEach(u=>!i[u]&&delete i[u]);let{jsonLd:c}=i;return c?s?.jsonLd?Array.isArray(c)?{...s,...i,jsonLd:[...s.jsonLd,...c]}:{...s,...i,jsonLd:[...s.jsonLd,c]}:{...s,...i,jsonLd:[c]}:{...s,...i}},{}),[t,r]),{html:a,loggerMarkup:o}=useMemo(()=>{let s=ht(n),i=s.map(u=>u.tag==="script"?createElement(u.tag,{...u.props,key:u.key,dangerouslySetInnerHTML:{__html:u.children}}):createElement(u.tag,{...u.props,key:u.key},u.children)),c=createElement(Suspense,{fallback:null},createElement(fr,{headTags:s}));return {html:i,loggerMarkup:c}},[n]);return createElement(Fragment,null,a,e&&o)}function ye(e,...t){if(e instanceof Function)return ye(e(...t),...t);let r={};return Array.isArray(e)?(r=e.reduce((n,a)=>[...n,ye(a)],[]),r):e instanceof Object?(Object.entries(e).forEach(([a,o])=>{r[a]=ye(o,...t);}),r):e}function Sr({connection:e,children:t=()=>(console.warn("<Pagination> requires children to work properly"),null)}){let n=useNavigation().state==="loading",{endCursor:a,hasNextPage:o,hasPreviousPage:s,nextPageUrl:i,nodes:c,previousPageUrl:u,startCursor:l}=Ir(e),p=useMemo(()=>({pageInfo:{endCursor:a,hasPreviousPage:s,hasNextPage:o,startCursor:l},nodes:c}),[a,o,s,l,c]),f=useMemo(()=>forwardRef(function(C,S){return o?createElement(Link,{preventScrollReset:!0,...C,to:i,state:p,replace:!0,ref:S}):null}),[o,i,p]),y=useMemo(()=>forwardRef(function(C,S){return s?createElement(Link,{preventScrollReset:!0,...C,to:u,state:p,replace:!0,ref:S}):null}),[s,u,p]);return t({state:p,hasNextPage:o,hasPreviousPage:s,isLoading:n,nextPageUrl:i,nodes:c,previousPageUrl:u,NextLink:f,PreviousLink:y})}function he(e){let t=new URLSearchParams(e);return t.delete("cursor"),t.delete("direction"),t.toString()}function ne(e){throw new Error(`The Pagination component requires ${"`"+e+"`"} to be a part of your query. See the guide on how to setup your query to include ${"`"+e+"`"}: https://shopify.dev/docs/custom-storefronts/hydrogen/data-fetching/pagination#setup-the-paginated-query`)}function Ir(e){e.pageInfo||ne("pageInfo"),typeof e.pageInfo.startCursor>"u"&&ne("pageInfo.startCursor"),typeof e.pageInfo.endCursor>"u"&&ne("pageInfo.endCursor"),typeof e.pageInfo.hasNextPage>"u"&&ne("pageInfo.hasNextPage"),typeof e.pageInfo.hasPreviousPage>"u"&&ne("pageInfo.hasPreviousPage");let t=useNavigate(),{state:r,search:n,pathname:a}=useLocation(),i=new URLSearchParams(n).get("direction")==="previous",c=useMemo(()=>!globalThis?.window?.__hydrogenHydrated||!r||!r?.nodes?flattenConnection(e):i?[...flattenConnection(e),...r.nodes]:[...r.nodes,...flattenConnection(e)],[r,e]),u=useMemo(()=>{let y=globalThis?.window?.__hydrogenHydrated,m=!y||r?.pageInfo?.startCursor===void 0?e.pageInfo.startCursor:r.pageInfo.startCursor,C=!y||r?.pageInfo?.endCursor===void 0?e.pageInfo.endCursor:r.pageInfo.endCursor,S=!y||r?.pageInfo?.hasPreviousPage===void 0?e.pageInfo.hasPreviousPage:r.pageInfo.hasPreviousPage,g=!y||r?.pageInfo?.hasNextPage===void 0?e.pageInfo.hasNextPage:r.pageInfo.hasNextPage;return r?.nodes&&(i?(m=e.pageInfo.startCursor,S=e.pageInfo.hasPreviousPage):(C=e.pageInfo.endCursor,g=e.pageInfo.hasNextPage)),{startCursor:m,endCursor:C,hasPreviousPage:S,hasNextPage:g}},[i,r,e.pageInfo.hasNextPage,e.pageInfo.hasPreviousPage,e.pageInfo.startCursor,e.pageInfo.endCursor]),l=useRef({params:he(n),pathname:a});useEffect(()=>{window.__hydrogenHydrated=!0;},[]),useEffect(()=>{(he(n)!==l.current.params||a!==l.current.pathname)&&(l.current={pathname:a,params:he(n)},t(`${a}?${he(n)}`,{replace:!0,preventScrollReset:!0,state:{nodes:void 0,pageInfo:void 0}}));},[a,n]);let p=useMemo(()=>{let y=new URLSearchParams(n);return y.set("direction","previous"),u.startCursor&&y.set("cursor",u.startCursor),`?${y.toString()}`},[n,u.startCursor]),f=useMemo(()=>{let y=new URLSearchParams(n);return y.set("direction","next"),u.endCursor&&y.set("cursor",u.endCursor),`?${y.toString()}`},[n,u.endCursor]);return {...u,previousPageUrl:p,nextPageUrl:f,nodes:c}}function Rr(e,t={pageBy:20}){if(typeof e?.url>"u")throw new Error("getPaginationVariables must be called with the Request object passed to your loader function");let{pageBy:r}=t,n=new URLSearchParams(new URL(e.url).search),a=n.get("cursor")??void 0;return (n.get("direction")==="previous"?"previous":"next")==="previous"?{last:r,startCursor:a??null}:{first:r,endCursor:a??null}}var Ce="2024-01",j=`Shopify Hydrogen ${ee}`,At="30243aa5-17c1-465a-8493-944bcc4e88aa",O="customerAccount";var U=class extends Response{constructor(t,r,n){super(`Bad request: ${t}`,{status:400,headers:n});}};function oe(e,t={}){let r=t.headers?new Headers(t.headers):new Headers({});return r.set("location",e),new Response(null,{status:t.status||302,headers:r})}async function Tr({session:e,customerAccountId:t,customerAccountUrl:r,origin:n,debugInfo:a}){let o=new URLSearchParams,i=e.get(O)?.refreshToken;if(!i)throw new U("Unauthorized","No refreshToken found in the session. Make sure your session is configured correctly and passed to `createCustomerAccountClient`.");o.append("grant_type","refresh_token"),o.append("refresh_token",i),o.append("client_id",t);let c={"content-type":"application/x-www-form-urlencoded","User-Agent":j,Origin:n};new Date().getTime();let l=`${r}/auth/oauth/token`,p=await fetch(l,{method:"POST",headers:c,body:o});if(!p.ok){let g=await p.text();throw new Response(g,{status:p.status,headers:{"Content-Type":"text/html; charset=utf-8"}})}let{access_token:f,expires_in:y,id_token:m,refresh_token:C}=await p.json(),S=await Ge(f,t,r,n);e.set(O,{accessToken:S,expiresAt:new Date(new Date().getTime()+(y-120)*1e3).getTime()+"",refreshToken:C,idToken:m});}function K(e){e.unset(O);}async function xt({locks:e,expiresAt:t,session:r,customerAccountId:n,customerAccountUrl:a,origin:o,debugInfo:s}){if(parseInt(t,10)-1e3<new Date().getTime())try{e.refresh||(e.refresh=Tr({session:r,customerAccountId:n,customerAccountUrl:a,origin:o,debugInfo:s})),await e.refresh,delete e.refresh;}catch(i){throw K(r),i&&i.status!==401?i:new U("Unauthorized","Login before querying the Customer Account API.",{"Set-Cookie":await r.commit()})}}async function Et(){let e=Ar();return Pt(e)}async function bt(e){let t=await crypto.subtle.digest({name:"SHA-256"},new TextEncoder().encode(e)),r=xr(t);return Pt(r)}function Ar(){let e=new Uint8Array(32);return crypto.getRandomValues(e),String.fromCharCode.apply(null,Array.from(e))}function Pt(e){return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function xr(e){let t=new Uint8Array(e),r=Array.from(t);return String.fromCharCode(...r)}async function Ot(){let e=Date.now().toString(),t=Math.random().toString(36).substring(2);return e+t}async function Ge(e,t,r,n,a){let o=t;if(!e)throw new U("Unauthorized","oAuth access token was not provided during token exchange.");let s=new URLSearchParams;s.append("grant_type","urn:ietf:params:oauth:grant-type:token-exchange"),s.append("client_id",o),s.append("audience",At),s.append("subject_token",e),s.append("subject_token_type","urn:ietf:params:oauth:token-type:access_token"),s.append("scopes","https://api.customers.com/auth/customer.graphql");let i={"content-type":"application/x-www-form-urlencoded","User-Agent":j,Origin:n};new Date().getTime();let u=`${r}/auth/oauth/token`,l=await fetch(u,{method:"POST",headers:i,body:s});let p=await l.json();if(p.error)throw new U(p.error_description);return p.access_token}function wt(e){return Er(e).payload.nonce}function Er(e){let[t,r,n]=e.split("."),a=JSON.parse(atob(t)),o=JSON.parse(atob(r));return {header:a,payload:o,signature:n}}function Se(){return Pr(br())}function br(){try{return crypto.getRandomValues(new Uint8Array(16))}catch{return new Uint8Array(16).map(()=>Math.random()*255|0)}}function Pr(e){return Array.from(e,function(t){return ("0"+(t&255).toString(16)).slice(-2)}).join("")}var Dt="/account/login",Or="/account/authorize",Ut="/account";function wr(e){if(!e.url)return Dt;let{pathname:t}=new URL(e.url),r=Dt+`?${new URLSearchParams({return_to:t}).toString()}`;return oe(r)}function Dr({session:e,customerAccountId:t,customerAccountUrl:r,customerApiVersion:n=Ce,request:a,waitUntil:o,authUrl:s=Or,customAuthStatusHandler:i,logErrors:c=!0}){if(n!==Ce&&console.warn(`[h2:warn:createCustomerAccountClient] You are using Customer Account API version ${n} when this version of Hydrogen was built for ${Ce}.`),(!t||!r)&&console.warn("[h2:warn:createCustomerAccountClient] `customerAccountId` and `customerAccountUrl` need to be provided to use Customer Account API. Mock.shop doesn't automatically supply these variables.\nUse `npx shopify hydrogen env pull` to link your store credentials."),!a?.url)throw new Error("[h2:error:createCustomerAccountClient] The request object does not contain a URL.");let u=i||(()=>wr(a)),l=new URL(a.url),p=l.protocol==="http:"?l.origin.replace("http","https"):l.origin,f=s.startsWith("/")?p+s:s,y=`${r}/account/customer/api/${n}/graphql`,m={};async function C({query:d,type:I,variables:R={}}){let x=await b();if(!x)throw u();new Date().getTime();let L=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json","User-Agent":j,Origin:p,Authorization:x},body:JSON.stringify({query:d,variables:R})});let D=await L.text(),v={url:y,response:L,type:I,query:d,queryVariables:R,errors:void 0,client:"customer"};if(!L.ok){if(L.status===401){K(e);let w=u();throw w instanceof Response&&w.headers.set("Set-Cookie",await e.commit()),w}let E;try{E=$(D);}catch{E=[{message:D}];}te({...v,errors:E});}try{let E=$(D),{errors:w}=E,z=w?.map(({message:_,...F})=>new q(_,{...F,clientOperation:`customerAccount.${v.type}`,requestId:L.headers.get("x-request-id"),queryVariables:R,query:d}));return {...E,...w&&{errors:z}}}catch{te({...v,errors:[{message:D}]});}}async function S(){let d=e.get(O),I=d?.accessToken,R=d?.expiresAt;if(!I||!R)return !1;let x=k?.();try{await xt({locks:m,expiresAt:R,session:e,customerAccountId:t,customerAccountUrl:r,origin:p,debugInfo:{waitUntil:o,stackInfo:x,...H(a)}});}catch{return !1}return !0}async function g(){if(!await S())throw u()}async function b(){if(await S())return e.get(O)?.accessToken}return {login:async()=>{let d=new URL(r+"/auth/oauth/authorize"),I=await Ot(),R=await Se();d.searchParams.set("client_id",t),d.searchParams.set("scope","openid email"),d.searchParams.append("response_type","code"),d.searchParams.append("redirect_uri",f),d.searchParams.set("scope","openid email https://api.customers.com/auth/customer.graphql"),d.searchParams.append("state",I),d.searchParams.append("nonce",R);let x=await Et(),N=await bt(x);return e.set(O,{...e.get(O),codeVerifier:x,state:I,nonce:R,redirectPath:fe(a.url)||le(a,"Referer")||Ut}),d.searchParams.append("code_challenge",N),d.searchParams.append("code_challenge_method","S256"),oe(d.toString(),{headers:{"Set-Cookie":await e.commit()}})},logout:async()=>{let d=e.get(O)?.idToken;return K(e),oe(`${r}/auth/logout?id_token_hint=${d}`,{status:302,headers:{"Set-Cookie":await e.commit()}})},isLoggedIn:S,handleAuthStatus:g,getAccessToken:b,getApiUrl:()=>y,mutate(d,I){return d=B(d),de(d,"customer.mutate"),W(C({query:d,type:"mutation",...I}),{logErrors:c})},query(d,I){return d=B(d),pe(d,"customer.query"),W(C({query:d,type:"query",...I}),{logErrors:c})},authorize:async()=>{let d=l.searchParams.get("code"),I=l.searchParams.get("state");if(!d||!I)throw K(e),new U("Unauthorized","No code or state parameter found in the redirect URL.",{"Set-Cookie":await e.commit()});if(e.get(O)?.state!==I)throw K(e),new U("Unauthorized","The session state does not match the state parameter. Make sure that the session is configured correctly and passed to `createCustomerAccountClient`.",{"Set-Cookie":await e.commit()});let R=t,x=new URLSearchParams;x.append("grant_type","authorization_code"),x.append("client_id",R),x.append("redirect_uri",f),x.append("code",d);let N=e.get(O)?.codeVerifier;if(!N)throw new U("Unauthorized","No code verifier found in the session. Make sure that the session is configured correctly and passed to `createCustomerAccountClient`.");x.append("code_verifier",N);let J={"content-type":"application/x-www-form-urlencoded","User-Agent":j,Origin:p},L=k?.();new Date().getTime();let v=`${r}/auth/oauth/token`,E=await fetch(v,{method:"POST",headers:J,body:x});if(!E.ok)throw new Response(await E.text(),{status:E.status,headers:{"Content-Type":"text/html; charset=utf-8"}});let{access_token:w,expires_in:z,id_token:_,refresh_token:F}=await E.json(),Y=e.get(O)?.nonce,se=await wt(_);if(Y!==se)throw new U("Unauthorized",`Returned nonce does not match: ${Y} !== ${se}`);let Re=await Ge(w,t,r,p,{waitUntil:o,stackInfo:L,...H(a)}),Te=e.get(O)?.redirectPath;return e.set(O,{accessToken:Re,expiresAt:new Date(new Date().getTime()+(z-120)*1e3).getTime()+"",refreshToken:F,idToken:_,redirectPath:void 0}),oe(Te||Ut,{headers:{"Set-Cookie":await e.commit()}})}}}var Ur="https://raw.githubusercontent.com/Shopify/hydrogen/main/docs/changelog.json";async function Lr({request:e,changelogUrl:t}){new URL(e.url).searchParams;return fetch(t||Ur)}var Lt="cartFormInput";function Ie({children:e,action:t,inputs:r,route:n,fetcherKey:a}){let o=useFetcher({key:a});return jsxs(o.Form,{action:n||"",method:"post",children:[(t||r)&&jsx("input",{type:"hidden",name:Lt,value:JSON.stringify({action:t,inputs:r})}),typeof e=="function"?e(o):e]})}Ie.INPUT_NAME=Lt;Ie.ACTIONS={AttributesUpdateInput:"AttributesUpdateInput",BuyerIdentityUpdate:"BuyerIdentityUpdate",Create:"Create",DiscountCodesUpdate:"DiscountCodesUpdate",LinesAdd:"LinesAdd",LinesRemove:"LinesRemove",LinesUpdate:"LinesUpdate",NoteUpdate:"NoteUpdate",SelectedDeliveryOptionsUpdate:"SelectedDeliveryOptionsUpdate",MetafieldsSet:"MetafieldsSet",MetafieldDelete:"MetafieldDelete"};function kr(e){let t={};for(let s of e.entries()){let i=s[0],c=e.getAll(i);t[i]=c.length>1?c:s[1];}let{cartFormInput:r,...n}=t,{action:a,inputs:o}=r?JSON.parse(String(r)):{};return {action:a,inputs:{...o,...n}}}Ie.getFormInput=kr;var T=`#graphql
293
+ fragment CartApiError on CartUserError {
294
+ message
295
+ field
296
+ code
297
+ }
298
+ `,A=`#graphql
299
+ fragment CartApiMutation on Cart {
300
+ id
301
+ totalQuantity
302
+ }
303
+ `;function Ve(e){return async(t,r)=>{let{cartId:n,...a}=r||{},{cartCreate:o,errors:s}=await e.storefront.mutate(Mr(e.cartFragment),{variables:{input:t,...a}});return h(o,s)}}var Mr=(e=A)=>`#graphql
304
+ mutation cartCreate(
305
+ $input: CartInput!
306
+ $country: CountryCode = ZZ
307
+ $language: LanguageCode
308
+ ) @inContext(country: $country, language: $language) {
309
+ cartCreate(input: $input) {
310
+ cart {
311
+ ...CartApiMutation
312
+ checkoutUrl
313
+ }
314
+ userErrors {
315
+ ...CartApiError
316
+ }
317
+ }
318
+ }
319
+ ${e}
320
+ ${T}
321
+ `;function Be({storefront:e,customerAccount:t,getCartId:r,cartFragment:n}){return async a=>{let o=r();if(!o)return null;let[s,{cart:i,errors:c}]=await Promise.all([t?t.isLoggedIn():!1,e.query($r(n),{variables:{cartId:o,...a},cache:e.CacheNone()})]);return h(Fr(s,i),c)}}function Fr(e,t){if(e&&t&&t.checkoutUrl){let r=new URL(t.checkoutUrl);r.searchParams.set("logged_in","true"),t.checkoutUrl=r.toString();}return t}var $r=(e=qr)=>`#graphql
322
+ query CartQuery(
323
+ $cartId: ID!
324
+ $numCartLines: Int = 100
325
+ $country: CountryCode = ZZ
326
+ $language: LanguageCode
327
+ ) @inContext(country: $country, language: $language) {
328
+ cart(id: $cartId) {
329
+ ...CartApiQuery
330
+ }
331
+ }
332
+
333
+ ${e}
334
+ `,qr=`#graphql
335
+ fragment CartApiQuery on Cart {
336
+ id
337
+ checkoutUrl
338
+ totalQuantity
339
+ buyerIdentity {
340
+ countryCode
341
+ customer {
342
+ id
343
+ email
344
+ firstName
345
+ lastName
346
+ displayName
347
+ }
348
+ email
349
+ phone
350
+ }
351
+ lines(first: $numCartLines) {
352
+ edges {
353
+ node {
354
+ id
355
+ quantity
356
+ attributes {
357
+ key
358
+ value
359
+ }
360
+ cost {
361
+ totalAmount {
362
+ amount
363
+ currencyCode
364
+ }
365
+ amountPerQuantity {
366
+ amount
367
+ currencyCode
368
+ }
369
+ compareAtAmountPerQuantity {
370
+ amount
371
+ currencyCode
372
+ }
373
+ }
374
+ merchandise {
375
+ ... on ProductVariant {
376
+ id
377
+ availableForSale
378
+ compareAtPrice {
379
+ ...CartApiMoney
380
+ }
381
+ price {
382
+ ...CartApiMoney
383
+ }
384
+ requiresShipping
385
+ title
386
+ image {
387
+ ...CartApiImage
388
+ }
389
+ product {
390
+ handle
391
+ title
392
+ id
393
+ }
394
+ selectedOptions {
395
+ name
396
+ value
397
+ }
398
+ }
399
+ }
400
+ }
401
+ }
402
+ }
403
+ cost {
404
+ subtotalAmount {
405
+ ...CartApiMoney
406
+ }
407
+ totalAmount {
408
+ ...CartApiMoney
409
+ }
410
+ totalDutyAmount {
411
+ ...CartApiMoney
412
+ }
413
+ totalTaxAmount {
414
+ ...CartApiMoney
415
+ }
416
+ }
417
+ note
418
+ attributes {
419
+ key
420
+ value
421
+ }
422
+ discountCodes {
423
+ applicable
424
+ code
425
+ }
426
+ }
427
+
428
+ fragment CartApiMoney on MoneyV2 {
429
+ currencyCode
430
+ amount
431
+ }
432
+
433
+ fragment CartApiImage on Image {
434
+ id
435
+ url
436
+ altText
437
+ width
438
+ height
439
+ }
440
+ `;function We(e){return async(t,r)=>{let{cartLinesAdd:n,errors:a}=await e.storefront.mutate(Hr(e.cartFragment),{variables:{cartId:e.getCartId(),lines:t,...r}});return h(n,a)}}var Hr=(e=A)=>`#graphql
441
+ mutation cartLinesAdd(
442
+ $cartId: ID!
443
+ $lines: [CartLineInput!]!
444
+ $country: CountryCode = ZZ
445
+ $language: LanguageCode
446
+ ) @inContext(country: $country, language: $language) {
447
+ cartLinesAdd(cartId: $cartId, lines: $lines) {
448
+ cart {
449
+ ...CartApiMutation
450
+ }
451
+ userErrors {
452
+ ...CartApiError
453
+ }
454
+ }
455
+ }
456
+
457
+ ${e}
458
+ ${T}
459
+ `;function je(e){return async(t,r)=>{let{cartLinesUpdate:n,errors:a}=await e.storefront.mutate(Qr(e.cartFragment),{variables:{cartId:e.getCartId(),lines:t,...r}});return h(n,a)}}var Qr=(e=A)=>`#graphql
460
+ mutation cartLinesUpdate(
461
+ $cartId: ID!
462
+ $lines: [CartLineUpdateInput!]!
463
+ $language: LanguageCode
464
+ $country: CountryCode
465
+ ) @inContext(country: $country, language: $language) {
466
+ cartLinesUpdate(cartId: $cartId, lines: $lines) {
467
+ cart {
468
+ ...CartApiMutation
469
+ }
470
+ userErrors {
471
+ ...CartApiError
472
+ }
473
+ }
474
+ }
475
+
476
+ ${e}
477
+ ${T}
478
+ `;function Ke(e){return async(t,r)=>{let{cartLinesRemove:n,errors:a}=await e.storefront.mutate(Gr(e.cartFragment),{variables:{cartId:e.getCartId(),lineIds:t,...r}});return h(n,a)}}var Gr=(e=A)=>`#graphql
479
+ mutation cartLinesRemove(
480
+ $cartId: ID!
481
+ $lineIds: [ID!]!
482
+ $language: LanguageCode
483
+ $country: CountryCode
484
+ ) @inContext(country: $country, language: $language) {
485
+ cartLinesRemove(cartId: $cartId, lineIds: $lineIds) {
486
+ cart {
487
+ ...CartApiMutation
488
+ }
489
+ userErrors {
490
+ ...CartApiError
491
+ }
492
+ }
493
+ }
494
+
495
+ ${e}
496
+ ${T}
497
+ `;function Je(e){return async(t,r)=>{let n=t.filter((s,i,c)=>c.indexOf(s)===i),{cartDiscountCodesUpdate:a,errors:o}=await e.storefront.mutate(Vr(e.cartFragment),{variables:{cartId:e.getCartId(),discountCodes:n,...r}});return h(a,o)}}var Vr=(e=A)=>`#graphql
498
+ mutation cartDiscountCodesUpdate(
499
+ $cartId: ID!
500
+ $discountCodes: [String!]
501
+ $language: LanguageCode
502
+ $country: CountryCode
503
+ ) @inContext(country: $country, language: $language) {
504
+ cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {
505
+ cart {
506
+ ...CartApiMutation
507
+ }
508
+ userErrors {
509
+ ...CartApiError
510
+ }
511
+ }
512
+ }
513
+ ${e}
514
+ ${T}
515
+ `;function ze(e){return async(t,r)=>{let{cartBuyerIdentityUpdate:n,errors:a}=await e.storefront.mutate(Br(e.cartFragment),{variables:{cartId:e.getCartId(),buyerIdentity:t,...r}});return h(n,a)}}var Br=(e=A)=>`#graphql
516
+ mutation cartBuyerIdentityUpdate(
517
+ $cartId: ID!
518
+ $buyerIdentity: CartBuyerIdentityInput!
519
+ $language: LanguageCode
520
+ $country: CountryCode
521
+ ) @inContext(country: $country, language: $language) {
522
+ cartBuyerIdentityUpdate(cartId: $cartId, buyerIdentity: $buyerIdentity) {
523
+ cart {
524
+ ...CartApiMutation
525
+ }
526
+ userErrors {
527
+ ...CartApiError
528
+ }
529
+ }
530
+ }
531
+ ${e}
532
+ ${T}
533
+ `;function Ye(e){return async(t,r)=>{let{cartNoteUpdate:n,errors:a}=await e.storefront.mutate(Wr(e.cartFragment),{variables:{cartId:e.getCartId(),note:t,...r}});return h(n,a)}}var Wr=(e=A)=>`#graphql
534
+ mutation cartNoteUpdate(
535
+ $cartId: ID!
536
+ $note: String
537
+ $language: LanguageCode
538
+ $country: CountryCode
539
+ ) @inContext(country: $country, language: $language) {
540
+ cartNoteUpdate(cartId: $cartId, note: $note) {
541
+ cart {
542
+ ...CartApiMutation
543
+ }
544
+ userErrors {
545
+ ...CartApiError
546
+ }
547
+ }
548
+ }
549
+ ${e}
550
+ ${T}
551
+ `;function Xe(e){return async(t,r)=>{let{cartSelectedDeliveryOptionsUpdate:n,errors:a}=await e.storefront.mutate(jr(e.cartFragment),{variables:{cartId:e.getCartId(),selectedDeliveryOptions:t,...r}});return h(n,a)}}var jr=(e=A)=>`#graphql
552
+ mutation cartSelectedDeliveryOptionsUpdate(
553
+ $cartId: ID!
554
+ $selectedDeliveryOptions: [CartSelectedDeliveryOptionInput!]!
555
+ $language: LanguageCode
556
+ $country: CountryCode
557
+ ) @inContext(country: $country, language: $language) {
558
+ cartSelectedDeliveryOptionsUpdate(cartId: $cartId, selectedDeliveryOptions: $selectedDeliveryOptions) {
559
+ cart {
560
+ ...CartApiMutation
561
+ }
562
+ userErrors {
563
+ ...CartApiError
564
+ }
565
+ }
566
+ }
567
+ ${e}
568
+ ${T}
569
+ `;function Ze(e){return async(t,r)=>{let{cartAttributesUpdate:n,errors:a}=await e.storefront.mutate(Kr(e.cartFragment),{variables:{cartId:r?.cartId||e.getCartId(),attributes:t}});return h(n,a)}}var Kr=(e=A)=>`#graphql
570
+ mutation cartAttributesUpdate(
571
+ $cartId: ID!
572
+ $attributes: [AttributeInput!]!
573
+ ) {
574
+ cartAttributesUpdate(cartId: $cartId, attributes: $attributes) {
575
+ cart {
576
+ ...CartApiMutation
577
+ }
578
+ userErrors {
579
+ ...CartApiError
580
+ }
581
+ }
582
+ }
583
+ ${e}
584
+ ${T}
585
+ `;function et(e){return async(t,r)=>{let n=r?.cartId||e.getCartId(),a=t.map(i=>({...i,ownerId:n})),{cartMetafieldsSet:o,errors:s}=await e.storefront.mutate(Jr(),{variables:{metafields:a}});return h({cart:{id:n},...o},s)}}var Jr=()=>`#graphql
586
+ mutation cartMetafieldsSet(
587
+ $metafields: [CartMetafieldsSetInput!]!
588
+ $language: LanguageCode
589
+ $country: CountryCode
590
+ ) @inContext(country: $country, language: $language) {
591
+ cartMetafieldsSet(metafields: $metafields) {
592
+ userErrors {
593
+ code
594
+ elementIndex
595
+ field
596
+ message
597
+ }
598
+ }
599
+ }
600
+ `;function tt(e){return async(t,r)=>{let n=r?.cartId||e.getCartId(),{cartMetafieldDelete:a,errors:o}=await e.storefront.mutate(zr(),{variables:{input:{ownerId:n,key:t}}});return h({cart:{id:n},...a},o)}}var zr=()=>`#graphql
601
+ mutation cartMetafieldDelete(
602
+ $input: CartMetafieldDeleteInput!
603
+ ) {
604
+ cartMetafieldDelete(input: $input) {
605
+ userErrors {
606
+ code
607
+ field
608
+ message
609
+ }
610
+ }
611
+ }
612
+ `;var Yr=new Set(["domain","path","max-age","expires","samesite","secure","httponly"]);function vt(e){let t={},r,n,a=0,o=e.split(/;\s*/g),s,i;for(;a<o.length;a++)if(n=o[a],r=n.indexOf("="),~r){if(s=n.substring(0,r++).trim(),i=n.substring(r).trim(),i[0]==='"'&&(i=i.substring(1,i.length-1)),~i.indexOf("%"))try{i=decodeURIComponent(i);}catch{}Yr.has(n=s.toLowerCase())?n==="expires"?t.expires=new Date(i):n==="max-age"?t.maxage=+i:t[n]=i:t[s]=i;}else (s=n.trim().toLowerCase())&&(s==="httponly"||s==="secure")&&(t[s]=!0);return t}function kt(e,t,r={}){let n=e+"="+encodeURIComponent(t);return r.expires&&(n+="; Expires="+new Date(r.expires).toUTCString()),r.maxage!=null&&r.maxage>=0&&(n+="; Max-Age="+(r.maxage|0)),r.domain&&(n+="; Domain="+r.domain),r.path&&(n+="; Path="+r.path),r.samesite&&(n+="; SameSite="+r.samesite),(r.secure||r.samesite==="None")&&(n+="; Secure"),r.httponly&&(n+="; HttpOnly"),n}var Xr=e=>{let t=vt(e.get("Cookie")||"");return ()=>t.cart?`gid://shopify/Cart/${t.cart}`:void 0};var Zr=e=>t=>{let r=new Headers;return r.append("Set-Cookie",kt("cart",t.split("/").pop()||"",{path:"/",...e})),r};function en(e){let{getCartId:t,setCartId:r,storefront:n,customerAccount:a,cartQueryFragment:o,cartMutateFragment:s}=e,i={storefront:n,getCartId:t,cartFragment:s},c=t(),u=Ve(i),l={get:Be({storefront:n,customerAccount:a,getCartId:t,cartFragment:o}),getCartId:t,setCartId:r,create:u,addLines:async(p,f)=>c||f?.cartId?await We(i)(p,f):await u({lines:p},f),updateLines:je(i),removeLines:Ke(i),updateDiscountCodes:async(p,f)=>c||f?.cartId?await Je(i)(p,f):await u({discountCodes:p},f),updateBuyerIdentity:async(p,f)=>c||f?.cartId?await ze(i)(p,f):await u({buyerIdentity:p},f),updateNote:async(p,f)=>c||f?.cartId?await Ye(i)(p,f):await u({note:p},f),updateSelectedDeliveryOption:Xe(i),updateAttributes:async(p,f)=>c||f?.cartId?await Ze(i)(p,f):await u({attributes:p},f),setMetafields:async(p,f)=>c||f?.cartId?await et(i)(p,f):await u({metafields:p},f),deleteMetafield:tt(i)};return "customMethods"in e?{...l,...e.customMethods??{}}:l}function on({handle:e,options:t=[],variants:r=[],productPath:n="products",children:a}){let o=r instanceof Array?r:flattenConnection(r),{searchParams:s,path:i,alreadyOnProductPage:c}=cn(e,n),u=t.filter(l=>l?.values?.length===1);return createElement(Fragment,null,...useMemo(()=>t.filter(l=>l?.values?.length>1).map(l=>{let p,f=[];for(let y of l.values){let m=new URLSearchParams(c?s:void 0);m.set(l.name,y),u.forEach(d=>{m.set(d.name,d.values[0]);});let C=o.find(d=>d?.selectedOptions?.every(I=>m.get(I?.name)===I?.value)),S=s.get(l.name),g=S?S===y:!1;g&&(p=y);let b="?"+m.toString();f.push({value:y,isAvailable:C?C.availableForSale:!0,to:i+b,search:b,isActive:g});}return a({option:{name:l.name,value:p,values:f}})}),[t,o,a]))}var sn=e=>{if(typeof e?.url>"u")throw new TypeError(`Expected a Request instance, got ${typeof e}`);let t=new URL(e.url).searchParams,r=[];return t.forEach((n,a)=>{r.push({name:a,value:n});}),r};function cn(e,t){let{pathname:r,search:n}=useLocation();return useMemo(()=>{let a=/(\/[a-zA-Z]{2}-[a-zA-Z]{2}\/)/g.exec(r),o=a&&a.length>0;t=t.startsWith("/")?t.substring(1):t;let s=o?`${a[0]}${t}/${e}`:`/${t}/${e}`;return {searchParams:new URLSearchParams(n),alreadyOnProductPage:s===r,path:s}},[r,n,e,t])}var _t=createContext(void 0),fn=_t.Provider,rt=()=>useContext(_t);function mn(e={}){let t=Se(),r=gn(t,e);return {nonce:t,header:r,NonceProvider:({children:a})=>createElement(fn,{value:t},a)}}function gn(e,t={}){let r=`'nonce-${e}'`,s={baseUri:["'self'"],defaultSrc:["'self'",r,"https://cdn.shopify.com","https://shopify.com"],frameAncestors:["none"],styleSrc:["'self'","'unsafe-inline'","https://cdn.shopify.com"],connectSrc:["'self'","https://monorail-edge.shopifysvc.com"]},i=Object.assign({},s,t);for(let c in s)t[c]&&(i[c]=yn(t[c],s[c]));return i.scriptSrc instanceof Array&&!i.scriptSrc.includes(r)?i.scriptSrc.push(r):i.defaultSrc instanceof Array&&!i.defaultSrc.includes(r)&&i.defaultSrc.push(r),ln({directives:i})}function yn(e,t){let r=typeof t=="string"?[t]:t,n=Array.isArray(e)?e:[String(e)];return Array.isArray(r)?[...n,...r]:r}var Cn=forwardRef((e,t)=>{let r=rt();return jsx("script",{suppressHydrationWarning:!0,...e,nonce:r,ref:t})});function Rn(e){let t=useFetchers(),r={};for(let{formData:n}of t)if(n?.get("optimistic-identifier")===e)try{if(n.has("optimistic-data")){let a=JSON.parse(String(n.get("optimistic-data")));Object.assign(r,a);}}catch{}return r}function Tn({id:e,data:t}){return jsxs(Fragment$1,{children:[jsx("input",{type:"hidden",name:"optimistic-identifier",value:e}),jsx("input",{type:"hidden",name:"optimistic-data",value:JSON.stringify(t)})]})}function bn(e){return jsx(ShopPayButton,{channel:"hydrogen",...e})}//! @see: https://shopify.dev/docs/api/storefront/latest/mutations/cartCreate
613
+ //! @see https://shopify.dev/docs/api/storefront/latest/queries/cart
614
+ //! @see: https://shopify.dev/docs/api/storefront/latest/mutations/cartLinesAdd
615
+ //! @see: https://shopify.dev/docs/api/storefront/latest/mutations/cartLinesUpdate
616
+ //! @see: https://shopify.dev/docs/api/storefront/latest/mutations/cartLinesRemove
617
+ //! @see https://shopify.dev/docs/api/storefront/latest/mutations/cartDiscountCodesUpdate
618
+ //! @see https://shopify.dev/docs/api/storefront/latest/mutations/cartBuyerIdentityUpdate
619
+ //! @see https://shopify.dev/docs/api/storefront/latest/mutations/cartNoteUpdate
620
+ //! @see https://shopify.dev/docs/api/storefront/latest/mutations/cartSelectedDeliveryOptionsUpdate
621
+ //! @see https://shopify.dev/docs/api/storefront/latest/mutations/cartMetafieldsSet
622
+ //! @see https://shopify.dev/docs/api/storefront/2024-01/mutations/cartMetafieldDelete
623
+
624
+ export { Pe as CacheCustom, be as CacheLong, xe as CacheNone, G as CacheShort, Ie as CartForm, Fe as InMemoryCache, Tn as OptimisticInput, Sr as Pagination, Cn as Script, mr as Seo, bn as ShopPayButton, on as VariantSelector, Ze as cartAttributesUpdateDefault, ze as cartBuyerIdentityUpdateDefault, Ve as cartCreateDefault, Je as cartDiscountCodesUpdateDefault, Be as cartGetDefault, Xr as cartGetIdDefault, We as cartLinesAddDefault, Ke as cartLinesRemoveDefault, je as cartLinesUpdateDefault, tt as cartMetafieldDeleteDefault, et as cartMetafieldsSetDefault, Ye as cartNoteUpdateDefault, Xe as cartSelectedDeliveryOptionsUpdateDefault, Zr as cartSetIdDefault, Lr as changelogHandler, en as createCartHandler, mn as createContentSecurityPolicy, Dr as createCustomerAccountClient, aa as createStorefrontClient, pa as createWithCache, h as formatAPIResult, Z as generateCacheControlHeader, Rr as getPaginationVariables, sn as getSelectedProductOptions, nr as graphiqlLoader, tr as storefrontRedirect, rt as useNonce, Rn as useOptimisticData };
625
+ //# sourceMappingURL=out.js.map
626
+ //# sourceMappingURL=index.js.map