@commerce-blocks/sdk 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,26 +1,26 @@
1
1
  import { signal as $ } from "@preact/signals-core";
2
- import { batch as Ir, computed as br, effect as vr, signal as Fr } from "@preact/signals-core";
3
- const Qe = "2026-01", We = "https://app.uselayers.com/api/storefront/v1", Ke = 1e3, ke = 1e3, qe = 100, Xe = 300 * Ke, ze = "6.0.0", se = 250, H = 20, j = 250, ie = 250, ae = 250, ce = 1, le = 1, Y = 1, Z = 24, ue = 1, de = 1, fe = 100, Je = 20, Ye = 50, Ze = 300, et = "USD", tt = "en-US", rt = 1e3, Ce = /* @__PURE__ */ new Map();
4
- function nt(e, t) {
2
+ import { batch as br, computed as vr, effect as Fr, signal as Mr } from "@preact/signals-core";
3
+ const He = "2026-01", Qe = "https://app.uselayers.com/api/storefront/v1", Ke = 1e3, ke = 1e3, Ne = 100, We = 300 * Ke, Xe = "6.0.0", se = 250, j = 20, H = 250, ie = 250, ae = 250, ce = 1, le = 1, Y = 1, Z = 24, ue = 1, de = 1, fe = 100, ze = 20, Je = 50, Ye = 300, Ze = "USD", et = "en-US", tt = 1e3, De = /* @__PURE__ */ new Map();
4
+ function rt(e, t) {
5
5
  const r = `${e}:${t}`;
6
- let o = Ce.get(r);
7
- return o || (o = new Intl.NumberFormat(tt, {
6
+ let o = De.get(r);
7
+ return o || (o = new Intl.NumberFormat(et, {
8
8
  style: "currency",
9
9
  currency: t
10
- }).format(e), Ce.set(r, o)), o;
10
+ }).format(e), De.set(r, o)), o;
11
11
  }
12
12
  function M(e) {
13
13
  return { data: e };
14
14
  }
15
- function m(e) {
15
+ function p(e) {
16
16
  return { error: e };
17
17
  }
18
18
  function ee() {
19
19
  return (/* @__PURE__ */ new Date()).toISOString();
20
20
  }
21
- const ot = ["TIMEOUT", "CONNECTION_FAILED", "DNS_FAILED"];
21
+ const nt = ["TIMEOUT", "CONNECTION_FAILED", "DNS_FAILED"];
22
22
  function J(e) {
23
- const t = ot.includes(e.code);
23
+ const t = nt.includes(e.code);
24
24
  return {
25
25
  _tag: "NetworkError",
26
26
  code: e.code,
@@ -32,7 +32,7 @@ function J(e) {
32
32
  retryAfterMs: t ? 1e3 : void 0
33
33
  };
34
34
  }
35
- function st(e) {
35
+ function ot(e) {
36
36
  if (!e) return;
37
37
  const t = e["retry-after"] ?? e["Retry-After"];
38
38
  if (!t) return;
@@ -42,8 +42,8 @@ function st(e) {
42
42
  if (!isNaN(o.getTime()))
43
43
  return Math.max(0, o.getTime() - Date.now());
44
44
  }
45
- function O(e) {
46
- const t = e.code === "RATE_LIMITED" || e.code === "SERVICE_UNAVAILABLE" || e.status !== void 0 && e.status >= 500, r = e.retryAfterMs ?? st(e.response?.headers) ?? (t ? 1e3 : void 0);
45
+ function C(e) {
46
+ const t = e.code === "RATE_LIMITED" || e.code === "SERVICE_UNAVAILABLE" || e.status !== void 0 && e.status >= 500, r = e.retryAfterMs ?? ot(e.response?.headers) ?? (t ? 1e3 : void 0);
47
47
  return {
48
48
  _tag: "ApiError",
49
49
  code: e.code,
@@ -70,7 +70,7 @@ function D(e) {
70
70
  input: e.input
71
71
  };
72
72
  }
73
- function R(e, t, r, o) {
73
+ function A(e, t, r, o) {
74
74
  return {
75
75
  path: e.split("."),
76
76
  field: e.split(".").pop() ?? e,
@@ -96,16 +96,16 @@ function rr(e) {
96
96
  function nr(e) {
97
97
  return "retryable" in e ? e.retryable : !1;
98
98
  }
99
- function it(e, t) {
99
+ function st(e, t) {
100
100
  const r = e === 401 ? "UNAUTHORIZED" : e === 403 ? "FORBIDDEN" : e === 429 ? "RATE_LIMITED" : e >= 500 ? "SERVICE_UNAVAILABLE" : "UNKNOWN";
101
- return O({
101
+ return C({
102
102
  code: r,
103
103
  source: "layers",
104
104
  message: t || `HTTP ${e}`,
105
105
  status: e
106
106
  });
107
107
  }
108
- function Ee(e) {
108
+ function ye(e) {
109
109
  if (e instanceof Error && (e.name === "AbortError" || e.name === "TimeoutError")) {
110
110
  const t = e.name === "TimeoutError" || e.message.includes("timeout");
111
111
  return J({
@@ -123,13 +123,13 @@ function Ee(e) {
123
123
  async function _e(e) {
124
124
  if (!e.ok) {
125
125
  const t = await e.text().catch(() => "");
126
- return m(it(e.status, t));
126
+ return p(st(e.status, t));
127
127
  }
128
128
  try {
129
129
  return M(await e.json());
130
130
  } catch (t) {
131
- return m(
132
- O({
131
+ return p(
132
+ C({
133
133
  code: "PARSE_ERROR",
134
134
  source: "layers",
135
135
  message: "Invalid JSON response",
@@ -138,75 +138,75 @@ async function _e(e) {
138
138
  );
139
139
  }
140
140
  }
141
- function Ie({
141
+ function Ee({
142
142
  token: e,
143
143
  json: t = !0
144
144
  }) {
145
145
  const r = {
146
146
  Accept: "application/json",
147
147
  "X-Storefront-Access-Token": e,
148
- "X-SDK-Client": `commerce-blocks-sdk/${ze}`
148
+ "X-SDK-Client": `commerce-blocks-sdk/${Xe}`
149
149
  };
150
150
  return t && (r["Content-Type"] = "application/json"), r;
151
151
  }
152
- function be({ config: e, endpoint: t }) {
153
- const { layersBaseUrl: r = We } = e;
152
+ function Ie({ config: e, endpoint: t }) {
153
+ const { layersBaseUrl: r = Qe } = e;
154
154
  return `${r}${t}`;
155
155
  }
156
156
  async function G(e) {
157
157
  const t = e.config.fetch ?? fetch;
158
158
  try {
159
- const r = await t(be({ config: e.config, endpoint: e.endpoint }), {
159
+ const r = await t(Ie({ config: e.config, endpoint: e.endpoint }), {
160
160
  method: "POST",
161
- headers: Ie({ token: e.config.layersPublicToken }),
161
+ headers: Ee({ token: e.config.layersPublicToken }),
162
162
  body: JSON.stringify(e.body),
163
163
  signal: e.signal
164
164
  });
165
165
  return _e(r);
166
166
  } catch (r) {
167
- return m(Ee(r));
167
+ return p(ye(r));
168
168
  }
169
169
  }
170
- async function at(e) {
170
+ async function it(e) {
171
171
  const t = new URLSearchParams();
172
- for (const [s, i] of Object.entries(e.params))
173
- i != null && t.append(s, typeof i == "object" ? JSON.stringify(i) : String(i));
172
+ for (const [i, s] of Object.entries(e.params))
173
+ s != null && t.append(i, typeof s == "object" ? JSON.stringify(s) : String(s));
174
174
  const r = t.toString(), o = r ? `${e.endpoint}?${r}` : e.endpoint, n = e.config.fetch ?? fetch;
175
175
  try {
176
- const s = await n(be({ config: e.config, endpoint: o }), {
176
+ const i = await n(Ie({ config: e.config, endpoint: o }), {
177
177
  method: "GET",
178
- headers: Ie({ token: e.config.layersPublicToken }),
178
+ headers: Ee({ token: e.config.layersPublicToken }),
179
179
  signal: e.signal
180
180
  });
181
- return _e(s);
182
- } catch (s) {
183
- return m(Ee(s));
181
+ return _e(i);
182
+ } catch (i) {
183
+ return p(ye(i));
184
184
  }
185
185
  }
186
- async function ct(e) {
186
+ async function at(e) {
187
187
  const t = e.config.fetch ?? fetch;
188
188
  try {
189
- const r = await t(be({ config: e.config, endpoint: e.endpoint }), {
189
+ const r = await t(Ie({ config: e.config, endpoint: e.endpoint }), {
190
190
  method: "POST",
191
- headers: Ie({ token: e.config.layersPublicToken, json: !1 }),
191
+ headers: Ee({ token: e.config.layersPublicToken, json: !1 }),
192
192
  body: e.formData,
193
193
  signal: e.signal
194
194
  });
195
195
  return _e(r);
196
196
  } catch (r) {
197
- return m(Ee(r));
197
+ return p(ye(r));
198
198
  }
199
199
  }
200
200
  function Q(e, t) {
201
201
  if (!e) return null;
202
202
  const r = [];
203
203
  return e.page !== void 0 && e.page < ue && r.push(
204
- R("pagination.page", "OUT_OF_RANGE", `page must be >= ${ue}`, {
204
+ A("pagination.page", "OUT_OF_RANGE", `page must be >= ${ue}`, {
205
205
  value: e.page,
206
206
  constraints: { min: ue }
207
207
  })
208
208
  ), e.limit !== void 0 && (e.limit < de || e.limit > fe) && r.push(
209
- R(
209
+ A(
210
210
  "pagination.limit",
211
211
  "OUT_OF_RANGE",
212
212
  `limit must be between ${de} and ${fe}`,
@@ -217,7 +217,7 @@ function Q(e, t) {
217
217
  )
218
218
  ), r.length > 0 ? D({ operation: t, fields: r }) : null;
219
219
  }
220
- const lt = [
220
+ const ct = [
221
221
  "title",
222
222
  "handle",
223
223
  "body_html",
@@ -238,9 +238,9 @@ const lt = [
238
238
  "named_tags",
239
239
  "category"
240
240
  ];
241
- function ut(e) {
241
+ function lt(e) {
242
242
  if (!e.layersPublicToken)
243
- return m(
243
+ return p(
244
244
  B({
245
245
  code: "MISSING_CONFIG",
246
246
  message: "layersPublicToken is required",
@@ -249,7 +249,7 @@ function ut(e) {
249
249
  })
250
250
  );
251
251
  if (!e.sorts || e.sorts.length === 0)
252
- return m(
252
+ return p(
253
253
  B({
254
254
  code: "MISSING_CONFIG",
255
255
  message: "At least one sort option is required",
@@ -258,7 +258,7 @@ function ut(e) {
258
258
  })
259
259
  );
260
260
  function t(n) {
261
- return [.../* @__PURE__ */ new Set([...lt, ...e.attributes ?? [], ...n ?? []])];
261
+ return [.../* @__PURE__ */ new Set([...ct, ...e.attributes ?? [], ...n ?? []])];
262
262
  }
263
263
  const r = {
264
264
  layersPublicToken: e.layersPublicToken,
@@ -266,173 +266,173 @@ function ut(e) {
266
266
  fetch: e.fetch
267
267
  };
268
268
  return M({
269
- browse: async (n, s) => {
269
+ browse: async (n, i) => {
270
270
  if (!n.collectionHandle)
271
- return m(
271
+ return p(
272
272
  D({
273
273
  operation: "browse",
274
274
  fields: [
275
- R("collectionHandle", "REQUIRED_FIELD", "collectionHandle is required")
275
+ A("collectionHandle", "REQUIRED_FIELD", "collectionHandle is required")
276
276
  ]
277
277
  })
278
278
  );
279
279
  if (!n.sort_order_code)
280
- return m(
280
+ return p(
281
281
  D({
282
282
  operation: "browse",
283
283
  fields: [
284
- R("sort_order_code", "REQUIRED_FIELD", "sort_order_code is required")
284
+ A("sort_order_code", "REQUIRED_FIELD", "sort_order_code is required")
285
285
  ]
286
286
  })
287
287
  );
288
- const i = Q(n.pagination, "browse");
289
- if (i) return m(i);
290
- const { collectionHandle: a, attributes: l, transformBody: u, ...g } = n;
291
- let f = {
288
+ const s = Q(n.pagination, "browse");
289
+ if (s) return p(s);
290
+ const { collectionHandle: a, attributes: u, transformBody: c, ...f } = n;
291
+ let d = {
292
292
  facets: e.facets,
293
- attributes: t(l),
293
+ attributes: t(u),
294
294
  retrieveFacetCount: !0,
295
295
  includeFacetRanges: !0,
296
- ...g
296
+ ...f
297
297
  };
298
- return u && (f = u(f)), G({
298
+ return c && (d = c(d)), G({
299
299
  config: r,
300
300
  endpoint: `/browse/${a}`,
301
- body: f,
302
- signal: s
301
+ body: d,
302
+ signal: i
303
303
  });
304
304
  },
305
- predictiveSearch: async (n, s) => n ? at({
305
+ predictiveSearch: async (n, i) => n ? it({
306
306
  config: r,
307
307
  endpoint: "/search/complete",
308
308
  params: { query: n },
309
- signal: s
310
- }) : m(
309
+ signal: i
310
+ }) : p(
311
311
  D({
312
312
  operation: "predictiveSearch",
313
- fields: [R("query", "REQUIRED_FIELD", "query is required")]
313
+ fields: [A("query", "REQUIRED_FIELD", "query is required")]
314
314
  })
315
315
  ),
316
- prepareSearch: async (n, s) => {
316
+ prepareSearch: async (n, i) => {
317
317
  if (!n.query)
318
- return m(
318
+ return p(
319
319
  D({
320
320
  operation: "prepareSearch",
321
- fields: [R("query", "REQUIRED_FIELD", "query is required")]
321
+ fields: [A("query", "REQUIRED_FIELD", "query is required")]
322
322
  })
323
323
  );
324
- const { query: i, transformBody: a, ...l } = n;
325
- let u = { ...l };
326
- return a && (u = a(u)), G({
324
+ const { query: s, transformBody: a, ...u } = n;
325
+ let c = { ...u };
326
+ return a && (c = a(c)), G({
327
327
  config: r,
328
- endpoint: `/search/${encodeURIComponent(i)}/prepare`,
329
- body: u,
330
- signal: s
328
+ endpoint: `/search/${encodeURIComponent(s)}/prepare`,
329
+ body: c,
330
+ signal: i
331
331
  });
332
332
  },
333
- search: async (n, s) => {
333
+ search: async (n, i) => {
334
334
  if (!n.query)
335
- return m(
335
+ return p(
336
336
  D({
337
337
  operation: "search",
338
- fields: [R("query", "REQUIRED_FIELD", "query is required")]
338
+ fields: [A("query", "REQUIRED_FIELD", "query is required")]
339
339
  })
340
340
  );
341
- const i = Q(n.pagination, "search");
342
- if (i) return m(i);
343
- const { query: a, attributes: l, transformBody: u, ...g } = n;
344
- let f = {
341
+ const s = Q(n.pagination, "search");
342
+ if (s) return p(s);
343
+ const { query: a, attributes: u, transformBody: c, ...f } = n;
344
+ let d = {
345
345
  facets: e.facets,
346
- attributes: t(l),
346
+ attributes: t(u),
347
347
  retrieveFacetCount: !0,
348
348
  includeFacetRanges: !0,
349
- ...g
349
+ ...f
350
350
  };
351
- return u && (f = u(f)), G({
351
+ return c && (d = c(d)), G({
352
352
  config: r,
353
353
  endpoint: `/search/${encodeURIComponent(a)}/execute`,
354
- body: f,
355
- signal: s
354
+ body: d,
355
+ signal: i
356
356
  });
357
357
  },
358
- imageSearch: async (n, s) => {
358
+ imageSearch: async (n, i) => {
359
359
  if (!n.image_data && !n.image_id)
360
- return m(
360
+ return p(
361
361
  D({
362
362
  operation: "imageSearch",
363
363
  fields: [
364
- R("image_data", "REQUIRED_FIELD", "image_data or image_id is required")
364
+ A("image_data", "REQUIRED_FIELD", "image_data or image_id is required")
365
365
  ]
366
366
  })
367
367
  );
368
- const i = Q(n.pagination, "imageSearch");
369
- if (i) return m(i);
370
- const { attributes: a, transformBody: l, ...u } = n;
371
- let g = {
368
+ const s = Q(n.pagination, "imageSearch");
369
+ if (s) return p(s);
370
+ const { attributes: a, transformBody: u, ...c } = n;
371
+ let f = {
372
372
  attributes: t(a),
373
- ...u
373
+ ...c
374
374
  };
375
- return l && (g = l(g)), G({
375
+ return u && (f = u(f)), G({
376
376
  config: r,
377
377
  endpoint: "/search/image",
378
- body: g,
379
- signal: s
378
+ body: f,
379
+ signal: i
380
380
  });
381
381
  },
382
- uploadImage: async (n, s) => {
383
- const i = new FormData();
384
- return i.append("image", n), ct({
382
+ uploadImage: async (n, i) => {
383
+ const s = new FormData();
384
+ return s.append("image", n), at({
385
385
  config: r,
386
386
  endpoint: "/images/upload",
387
- formData: i,
388
- signal: s
387
+ formData: s,
388
+ signal: i
389
389
  });
390
390
  },
391
- blocks: async (n, s) => {
391
+ blocks: async (n, i) => {
392
392
  if (!n.blockId)
393
- return m(
393
+ return p(
394
394
  D({
395
395
  operation: "block",
396
- fields: [R("blockId", "REQUIRED_FIELD", "blockId is required")]
396
+ fields: [A("blockId", "REQUIRED_FIELD", "blockId is required")]
397
397
  })
398
398
  );
399
- const i = Q(n.pagination, "block");
400
- if (i) return m(i);
401
- const { blockId: a, attributes: l, transformBody: u, ...g } = n;
402
- let f = {
399
+ const s = Q(n.pagination, "block");
400
+ if (s) return p(s);
401
+ const { blockId: a, attributes: u, transformBody: c, ...f } = n;
402
+ let d = {
403
403
  facets: e.facets,
404
- attributes: t(l),
404
+ attributes: t(u),
405
405
  retrieveFacetCount: !0,
406
406
  includeFacetRanges: !0,
407
- ...g
407
+ ...f
408
408
  };
409
- return u && (f = u(f)), G({
409
+ return c && (d = c(d)), G({
410
410
  config: r,
411
411
  endpoint: `/blocks/${a}/products`,
412
- body: f,
413
- signal: s
412
+ body: d,
413
+ signal: i
414
414
  });
415
415
  },
416
- similarProducts: async (n, s) => {
416
+ similarProducts: async (n, i) => {
417
417
  if (!n.productId)
418
- return m(
418
+ return p(
419
419
  D({
420
420
  operation: "similarProducts",
421
- fields: [R("productId", "REQUIRED_FIELD", "productId is required")]
421
+ fields: [A("productId", "REQUIRED_FIELD", "productId is required")]
422
422
  })
423
423
  );
424
- const i = Q(n.pagination, "similarProducts");
425
- if (i) return m(i);
426
- const { productId: a, attributes: l, transformBody: u, ...g } = n;
427
- let f = {
428
- attributes: t(l),
429
- ...g
424
+ const s = Q(n.pagination, "similarProducts");
425
+ if (s) return p(s);
426
+ const { productId: a, attributes: u, transformBody: c, ...f } = n;
427
+ let d = {
428
+ attributes: t(u),
429
+ ...f
430
430
  };
431
- return u && (f = u(f)), G({
431
+ return c && (d = c(d)), G({
432
432
  config: r,
433
433
  endpoint: `/search/product/${a}`,
434
- body: f,
435
- signal: s
434
+ body: d,
435
+ signal: i
436
436
  });
437
437
  }
438
438
  });
@@ -442,14 +442,14 @@ const te = `
442
442
  title
443
443
  description
444
444
  }
445
- `, $e = `
445
+ `, qe = `
446
446
  fragment FilterValueFields on FilterValue {
447
447
  id
448
448
  label
449
449
  count
450
450
  input
451
451
  }
452
- `, Le = `
452
+ `, $e = `
453
453
  fragment FilterFields on Filter {
454
454
  id
455
455
  label
@@ -463,22 +463,22 @@ const te = `
463
463
  width
464
464
  height
465
465
  }
466
- `, ve = `
466
+ `, be = `
467
467
  fragment MoneyFields on MoneyV2 {
468
468
  amount
469
469
  currencyCode
470
470
  }
471
- `, Fe = `
471
+ `, ve = `
472
472
  fragment SelectedOptionFields on SelectedOption {
473
473
  name
474
474
  value
475
475
  }
476
- `, Me = `
476
+ `, Fe = `
477
477
  fragment PriceRangeFields on ProductPriceRange {
478
478
  minVariantPrice { ...MoneyFields }
479
479
  maxVariantPrice { ...MoneyFields }
480
480
  }
481
- `, Se = `
481
+ `, Me = `
482
482
  fragment ProductOptionFields on ProductOption {
483
483
  id
484
484
  name
@@ -501,7 +501,7 @@ const te = `
501
501
  type
502
502
  }
503
503
  `;
504
- function Pe(e) {
504
+ function Se(e) {
505
505
  return `
506
506
  fragment VariantFields on ProductVariant {
507
507
  id
@@ -522,7 +522,7 @@ function Pe(e) {
522
522
  }
523
523
  `;
524
524
  }
525
- function Re(e) {
525
+ function Pe(e) {
526
526
  const { maxImages: t, maxVariants: r, includeProductMetafields: o } = e;
527
527
  return `
528
528
  fragment ProductFields on Product {
@@ -549,7 +549,7 @@ function Re(e) {
549
549
  }
550
550
  `;
551
551
  }
552
- function Ue(e) {
552
+ function Le(e) {
553
553
  return `
554
554
  fragment CollectionFields on Collection {
555
555
  id
@@ -564,7 +564,7 @@ function Ue(e) {
564
564
  }
565
565
  `;
566
566
  }
567
- function Ve(e) {
567
+ function Ue(e) {
568
568
  return `
569
569
  fragment PageFields on Page {
570
570
  id
@@ -580,33 +580,33 @@ function Ve(e) {
580
580
  }
581
581
  `;
582
582
  }
583
- function dt(e) {
583
+ function ut(e) {
584
584
  const { includeProductMetafields: t, includeVariantMetafields: r } = e;
585
585
  return [
586
586
  re,
587
+ be,
587
588
  ve,
588
589
  Fe,
589
590
  Me,
590
- Se,
591
591
  t || r ? z : "",
592
- Pe(r),
593
- Re(e)
592
+ Se(r),
593
+ Pe(e)
594
594
  ].join(`
595
595
  `);
596
596
  }
597
- function ft(e = {}) {
597
+ function dt(e = {}) {
598
598
  const {
599
- maxImages: t = H,
600
- maxVariants: r = j,
599
+ maxImages: t = j,
600
+ maxVariants: r = H,
601
601
  productMetafields: o = [],
602
602
  variantMetafields: n = []
603
- } = e, s = o.length > 0, i = n.length > 0, a = ["$ids: [ID!]!"];
604
- return s && a.push("$productMetafields: [HasMetafieldsIdentifier!]!"), i && a.push("$variantMetafields: [HasMetafieldsIdentifier!]!"), `
605
- ${dt({
603
+ } = e, i = o.length > 0, s = n.length > 0, a = ["$ids: [ID!]!"];
604
+ return i && a.push("$productMetafields: [HasMetafieldsIdentifier!]!"), s && a.push("$variantMetafields: [HasMetafieldsIdentifier!]!"), `
605
+ ${ut({
606
606
  maxImages: t,
607
607
  maxVariants: r,
608
- includeProductMetafields: s,
609
- includeVariantMetafields: i
608
+ includeProductMetafields: i,
609
+ includeVariantMetafields: s
610
610
  })}
611
611
 
612
612
  query ProductsByIds(${a.join(", ")}) {
@@ -618,40 +618,40 @@ function ft(e = {}) {
618
618
  }
619
619
  `;
620
620
  }
621
- function gt(e = {}) {
621
+ function ft(e = {}) {
622
622
  const {
623
- maxImages: t = H,
624
- maxVariants: r = j,
623
+ maxImages: t = j,
624
+ maxVariants: r = H,
625
625
  productMetafields: o = [],
626
626
  variantMetafields: n = [],
627
- collectionMetafields: s = [],
628
- includeFilters: i = !1
629
- } = e, a = o.length > 0, l = n.length > 0, u = s.length > 0, g = a || l || u, f = ["$ids: [ID!]!", "$handle: String!"];
630
- return a && f.push("$productMetafields: [HasMetafieldsIdentifier!]!"), l && f.push("$variantMetafields: [HasMetafieldsIdentifier!]!"), u && f.push("$collectionMetafields: [HasMetafieldsIdentifier!]!"), `
627
+ collectionMetafields: i = [],
628
+ includeFilters: s = !1
629
+ } = e, a = o.length > 0, u = n.length > 0, c = i.length > 0, f = a || u || c, d = ["$ids: [ID!]!", "$handle: String!"];
630
+ return a && d.push("$productMetafields: [HasMetafieldsIdentifier!]!"), u && d.push("$variantMetafields: [HasMetafieldsIdentifier!]!"), c && d.push("$collectionMetafields: [HasMetafieldsIdentifier!]!"), `
631
631
  ${[
632
632
  re,
633
+ be,
633
634
  ve,
634
635
  Fe,
635
636
  Me,
636
- Se,
637
637
  te,
638
- g ? z : "",
639
- i ? $e : "",
640
- i ? Le : "",
641
- Pe(l),
642
- Re({
638
+ f ? z : "",
639
+ s ? qe : "",
640
+ s ? $e : "",
641
+ Se(u),
642
+ Pe({
643
643
  maxImages: t,
644
644
  maxVariants: r,
645
645
  includeProductMetafields: a
646
646
  }),
647
- Ue(u)
647
+ Le(c)
648
648
  ].join(`
649
649
  `)}
650
650
 
651
- query CollectionWithProducts(${f.join(", ")}) {
651
+ query CollectionWithProducts(${d.join(", ")}) {
652
652
  collection(handle: $handle) {
653
653
  ...CollectionFields
654
- ${i ? "products(first: 1) { filters { ...FilterFields } }" : ""}
654
+ ${s ? "products(first: 1) { filters { ...FilterFields } }" : ""}
655
655
  }
656
656
  nodes(ids: $ids) {
657
657
  ... on Product {
@@ -661,16 +661,16 @@ function gt(e = {}) {
661
661
  }
662
662
  `;
663
663
  }
664
- function mt(e = {}) {
664
+ function gt(e = {}) {
665
665
  const { collectionMetafields: t = [], includeFilters: r = !1 } = e, o = t.length > 0, n = ["$handle: String!"];
666
666
  return o && n.push("$collectionMetafields: [HasMetafieldsIdentifier!]!"), `
667
667
  ${[
668
668
  re,
669
669
  te,
670
670
  o ? z : "",
671
+ r ? qe : "",
671
672
  r ? $e : "",
672
- r ? Le : "",
673
- Ue(o)
673
+ Le(o)
674
674
  ].join(`
675
675
  `)}
676
676
 
@@ -682,13 +682,13 @@ function mt(e = {}) {
682
682
  }
683
683
  `;
684
684
  }
685
- function pt(e = {}) {
685
+ function mt(e = {}) {
686
686
  const { pageMetafields: t = [] } = e, r = t.length > 0, o = ["$handle: String!"];
687
687
  return r && o.push("$pageMetafields: [HasMetafieldsIdentifier!]!"), `
688
688
  ${[
689
689
  te,
690
690
  r ? z : "",
691
- Ve(r)
691
+ Ue(r)
692
692
  ].join(`
693
693
  `)}
694
694
 
@@ -699,34 +699,34 @@ function pt(e = {}) {
699
699
  }
700
700
  `;
701
701
  }
702
- function ht(e = {}) {
702
+ function pt(e = {}) {
703
703
  const {
704
- maxImages: t = H,
705
- maxVariants: r = j,
704
+ maxImages: t = j,
705
+ maxVariants: r = H,
706
706
  productMetafields: o = [],
707
707
  variantMetafields: n = [],
708
- pageMetafields: s = []
709
- } = e, i = o.length > 0, a = n.length > 0, l = s.length > 0, u = i || a || l, g = ["$ids: [ID!]!", "$handle: String!"];
710
- return i && g.push("$productMetafields: [HasMetafieldsIdentifier!]!"), a && g.push("$variantMetafields: [HasMetafieldsIdentifier!]!"), l && g.push("$pageMetafields: [HasMetafieldsIdentifier!]!"), `
708
+ pageMetafields: i = []
709
+ } = e, s = o.length > 0, a = n.length > 0, u = i.length > 0, c = s || a || u, f = ["$ids: [ID!]!", "$handle: String!"];
710
+ return s && f.push("$productMetafields: [HasMetafieldsIdentifier!]!"), a && f.push("$variantMetafields: [HasMetafieldsIdentifier!]!"), u && f.push("$pageMetafields: [HasMetafieldsIdentifier!]!"), `
711
711
  ${[
712
712
  re,
713
+ be,
713
714
  ve,
714
715
  Fe,
715
716
  Me,
716
- Se,
717
717
  te,
718
- u ? z : "",
719
- Pe(a),
720
- Re({
718
+ c ? z : "",
719
+ Se(a),
720
+ Pe({
721
721
  maxImages: t,
722
722
  maxVariants: r,
723
- includeProductMetafields: i
723
+ includeProductMetafields: s
724
724
  }),
725
- Ve(l)
725
+ Ue(u)
726
726
  ].join(`
727
727
  `)}
728
728
 
729
- query PageWithProducts(${g.join(", ")}) {
729
+ query PageWithProducts(${f.join(", ")}) {
730
730
  page(handle: $handle) {
731
731
  ...PageFields
732
732
  }
@@ -738,7 +738,7 @@ function ht(e = {}) {
738
738
  }
739
739
  `;
740
740
  }
741
- function yt({
741
+ function ht({
742
742
  shop: e,
743
743
  token: t,
744
744
  apiVersion: r,
@@ -746,23 +746,23 @@ function yt({
746
746
  }) {
747
747
  const n = `https://${e}/api/${r}/graphql.json`;
748
748
  return {
749
- async request(s, { variables: i, signal: a } = {}) {
750
- const l = await o(n, {
749
+ async request(i, { variables: s, signal: a } = {}) {
750
+ const u = await o(n, {
751
751
  method: "POST",
752
752
  headers: {
753
753
  "Content-Type": "application/json",
754
754
  "X-Shopify-Storefront-Access-Token": t
755
755
  },
756
- body: JSON.stringify({ query: s, variables: i }),
756
+ body: JSON.stringify({ query: i, variables: s }),
757
757
  signal: a
758
758
  });
759
- if (!l.ok)
759
+ if (!u.ok)
760
760
  return {
761
761
  data: null,
762
- errors: { message: `HTTP ${l.status}`, networkStatusCode: l.status }
762
+ errors: { message: `HTTP ${u.status}`, networkStatusCode: u.status }
763
763
  };
764
- const u = await l.json();
765
- return u.errors ? { data: u.data, errors: { graphQLErrors: u.errors } } : { data: u.data };
764
+ const c = await u.json();
765
+ return c.errors ? { data: c.data, errors: { graphQLErrors: c.errors } } : { data: c.data };
766
766
  }
767
767
  };
768
768
  }
@@ -772,9 +772,9 @@ function ge({ ids: e, maxSize: t }) {
772
772
  r.push(e.slice(o, o + t));
773
773
  return r;
774
774
  }
775
- function Et(e) {
775
+ function yt(e) {
776
776
  if (!e.storefrontPublicToken)
777
- return m(
777
+ return p(
778
778
  B({
779
779
  code: "MISSING_CONFIG",
780
780
  message: "storefrontPublicToken is required",
@@ -783,7 +783,7 @@ function Et(e) {
783
783
  })
784
784
  );
785
785
  if (!e.shop)
786
- return m(
786
+ return p(
787
787
  B({
788
788
  code: "MISSING_CONFIG",
789
789
  message: "shop is required",
@@ -791,7 +791,7 @@ function Et(e) {
791
791
  expected: "non-empty string"
792
792
  })
793
793
  );
794
- const { storefrontApiVersion: t = Qe } = e, r = yt({
794
+ const { storefrontApiVersion: t = He } = e, r = ht({
795
795
  shop: e.shop,
796
796
  token: e.storefrontPublicToken,
797
797
  apiVersion: t,
@@ -800,194 +800,194 @@ function Et(e) {
800
800
  return M({
801
801
  async getProducts(n) {
802
802
  const {
803
- ids: s,
804
- productMetafields: i = [],
803
+ ids: i,
804
+ productMetafields: s = [],
805
805
  variantMetafields: a = [],
806
- maxImages: l = H,
807
- maxVariants: u = j,
808
- signal: g
809
- } = n, f = me(n);
810
- if (f.length > 0)
811
- return m(D({ operation: "getProducts", fields: f }));
812
- if (s.length === 0)
806
+ maxImages: u = j,
807
+ maxVariants: c = H,
808
+ signal: f
809
+ } = n, d = me(n);
810
+ if (d.length > 0)
811
+ return p(D({ operation: "getProducts", fields: d }));
812
+ if (i.length === 0)
813
813
  return M([]);
814
- const c = ft({
815
- maxImages: l,
816
- maxVariants: u,
817
- productMetafields: i,
814
+ const m = dt({
815
+ maxImages: u,
816
+ maxVariants: c,
817
+ productMetafields: s,
818
818
  variantMetafields: a
819
- }), d = ge({ ids: s, maxSize: se }), p = [];
820
- for (const h of d) {
819
+ }), l = ge({ ids: i, maxSize: se }), g = [];
820
+ for (const h of l) {
821
821
  const y = { ids: h };
822
- i.length > 0 && (y.productMetafields = i), a.length > 0 && (y.variantMetafields = a);
823
- const I = await _t({ shopifyClient: r, query: c, variables: y, signal: g });
824
- if (I.error)
825
- return I;
826
- p.push(...I.data);
822
+ s.length > 0 && (y.productMetafields = s), a.length > 0 && (y.variantMetafields = a);
823
+ const _ = await _t({ shopifyClient: r, query: m, variables: y, signal: f });
824
+ if (_.error)
825
+ return _;
826
+ g.push(..._.data);
827
827
  }
828
- return M(p);
828
+ return M(g);
829
829
  },
830
830
  async getCollection(n) {
831
- const { handle: s, collectionMetafields: i = [], includeFilters: a = !1, signal: l } = n;
832
- if (!s)
833
- return m(
831
+ const { handle: i, collectionMetafields: s = [], includeFilters: a = !1, signal: u } = n;
832
+ if (!i)
833
+ return p(
834
834
  D({
835
835
  operation: "getCollection",
836
- fields: [R("handle", "REQUIRED_FIELD", "handle is required")]
836
+ fields: [A("handle", "REQUIRED_FIELD", "handle is required")]
837
837
  })
838
838
  );
839
- const u = mt({ collectionMetafields: i, includeFilters: a }), g = { handle: s };
840
- i.length > 0 && (g.collectionMetafields = i);
839
+ const c = gt({ collectionMetafields: s, includeFilters: a }), f = { handle: i };
840
+ s.length > 0 && (f.collectionMetafields = s);
841
841
  try {
842
- const { data: f, errors: c } = await r.request(u, { variables: g, signal: l });
843
- if (c)
844
- return m(W(c));
845
- const d = f;
846
- return d.collection ? M(d.collection) : m(
847
- O({
842
+ const { data: d, errors: m } = await r.request(c, { variables: f, signal: u });
843
+ if (m)
844
+ return p(K(m));
845
+ const l = d;
846
+ return l.collection ? M(l.collection) : p(
847
+ C({
848
848
  code: "NOT_FOUND",
849
849
  source: "shopify",
850
- message: `Collection not found: ${s}`
850
+ message: `Collection not found: ${i}`
851
851
  })
852
852
  );
853
- } catch (f) {
854
- return m(K(f));
853
+ } catch (d) {
854
+ return p(W(d));
855
855
  }
856
856
  },
857
857
  async getCollectionWithProducts(n) {
858
858
  const {
859
- handle: s,
860
- ids: i,
859
+ handle: i,
860
+ ids: s,
861
861
  productMetafields: a = [],
862
- variantMetafields: l = [],
863
- collectionMetafields: u = [],
864
- includeFilters: g = !1,
865
- maxImages: f = H,
866
- maxVariants: c = j,
867
- signal: d
868
- } = n, p = me(n);
869
- if (s || p.push(R("handle", "REQUIRED_FIELD", "handle is required")), p.length > 0)
870
- return m(
862
+ variantMetafields: u = [],
863
+ collectionMetafields: c = [],
864
+ includeFilters: f = !1,
865
+ maxImages: d = j,
866
+ maxVariants: m = H,
867
+ signal: l
868
+ } = n, g = me(n);
869
+ if (i || g.push(A("handle", "REQUIRED_FIELD", "handle is required")), g.length > 0)
870
+ return p(
871
871
  D({
872
872
  operation: "getCollectionWithProducts",
873
- fields: p
873
+ fields: g
874
874
  })
875
875
  );
876
- const h = gt({
877
- maxImages: f,
878
- maxVariants: c,
876
+ const h = ft({
877
+ maxImages: d,
878
+ maxVariants: m,
879
879
  productMetafields: a,
880
- variantMetafields: l,
881
- collectionMetafields: u,
882
- includeFilters: g
883
- }), y = i.length > 0 ? ge({ ids: i, maxSize: se }) : [[]];
884
- let I = null;
880
+ variantMetafields: u,
881
+ collectionMetafields: c,
882
+ includeFilters: f
883
+ }), y = s.length > 0 ? ge({ ids: s, maxSize: se }) : [[]];
884
+ let _ = null;
885
885
  const b = [];
886
886
  for (let v = 0; v < y.length; v++) {
887
- const E = { ids: y[v], handle: s };
888
- a.length > 0 && (E.productMetafields = a), l.length > 0 && (E.variantMetafields = l), u.length > 0 && (E.collectionMetafields = u);
887
+ const E = { ids: y[v], handle: i };
888
+ a.length > 0 && (E.productMetafields = a), u.length > 0 && (E.variantMetafields = u), c.length > 0 && (E.collectionMetafields = c);
889
889
  try {
890
- const { data: F, errors: P } = await r.request(h, { variables: E, signal: d });
890
+ const { data: F, errors: P } = await r.request(h, { variables: E, signal: l });
891
891
  if (P)
892
- return m(W(P));
893
- const A = F;
894
- if (v === 0 && (I = A.collection ?? null, !I))
895
- return m(
896
- O({
892
+ return p(K(P));
893
+ const R = F;
894
+ if (v === 0 && (_ = R.collection ?? null, !_))
895
+ return p(
896
+ C({
897
897
  code: "NOT_FOUND",
898
898
  source: "shopify",
899
- message: `Collection not found: ${s}`
899
+ message: `Collection not found: ${i}`
900
900
  })
901
901
  );
902
- const _ = (A.nodes ?? []).filter((C) => C !== null);
903
- b.push(..._);
902
+ const I = (R.nodes ?? []).filter((O) => O !== null);
903
+ b.push(...I);
904
904
  } catch (F) {
905
- return m(K(F));
905
+ return p(W(F));
906
906
  }
907
907
  }
908
- return M({ collection: I, products: b });
908
+ return M({ collection: _, products: b });
909
909
  },
910
910
  async getPage(n) {
911
- const { handle: s, pageMetafields: i = [], signal: a } = n;
912
- if (!s)
913
- return m(
911
+ const { handle: i, pageMetafields: s = [], signal: a } = n;
912
+ if (!i)
913
+ return p(
914
914
  D({
915
915
  operation: "getPage",
916
- fields: [R("handle", "REQUIRED_FIELD", "handle is required")]
916
+ fields: [A("handle", "REQUIRED_FIELD", "handle is required")]
917
917
  })
918
918
  );
919
- const l = pt({ pageMetafields: i }), u = { handle: s };
920
- i.length > 0 && (u.pageMetafields = i);
919
+ const u = mt({ pageMetafields: s }), c = { handle: i };
920
+ s.length > 0 && (c.pageMetafields = s);
921
921
  try {
922
- const { data: g, errors: f } = await r.request(l, { variables: u, signal: a });
923
- if (f)
924
- return m(W(f));
925
- const c = g;
926
- return c.page ? M(c.page) : m(
927
- O({
922
+ const { data: f, errors: d } = await r.request(u, { variables: c, signal: a });
923
+ if (d)
924
+ return p(K(d));
925
+ const m = f;
926
+ return m.page ? M(m.page) : p(
927
+ C({
928
928
  code: "NOT_FOUND",
929
929
  source: "shopify",
930
- message: `Page not found: ${s}`
930
+ message: `Page not found: ${i}`
931
931
  })
932
932
  );
933
- } catch (g) {
934
- return m(K(g));
933
+ } catch (f) {
934
+ return p(W(f));
935
935
  }
936
936
  },
937
937
  async getPageWithProducts(n) {
938
938
  const {
939
- handle: s,
940
- ids: i,
939
+ handle: i,
940
+ ids: s,
941
941
  productMetafields: a = [],
942
- variantMetafields: l = [],
943
- pageMetafields: u = [],
944
- maxImages: g = H,
945
- maxVariants: f = j,
946
- signal: c
947
- } = n, d = me(n);
948
- if (s || d.push(R("handle", "REQUIRED_FIELD", "handle is required")), d.length > 0)
949
- return m(
950
- D({ operation: "getPageWithProducts", fields: d })
942
+ variantMetafields: u = [],
943
+ pageMetafields: c = [],
944
+ maxImages: f = j,
945
+ maxVariants: d = H,
946
+ signal: m
947
+ } = n, l = me(n);
948
+ if (i || l.push(A("handle", "REQUIRED_FIELD", "handle is required")), l.length > 0)
949
+ return p(
950
+ D({ operation: "getPageWithProducts", fields: l })
951
951
  );
952
- const p = ht({
953
- maxImages: g,
954
- maxVariants: f,
952
+ const g = pt({
953
+ maxImages: f,
954
+ maxVariants: d,
955
955
  productMetafields: a,
956
- variantMetafields: l,
957
- pageMetafields: u
958
- }), h = i.length > 0 ? ge({ ids: i, maxSize: se }) : [[]];
956
+ variantMetafields: u,
957
+ pageMetafields: c
958
+ }), h = s.length > 0 ? ge({ ids: s, maxSize: se }) : [[]];
959
959
  let y = null;
960
- const I = [];
960
+ const _ = [];
961
961
  for (let b = 0; b < h.length; b++) {
962
- const S = { ids: h[b], handle: s };
963
- a.length > 0 && (S.productMetafields = a), l.length > 0 && (S.variantMetafields = l), u.length > 0 && (S.pageMetafields = u);
962
+ const S = { ids: h[b], handle: i };
963
+ a.length > 0 && (S.productMetafields = a), u.length > 0 && (S.variantMetafields = u), c.length > 0 && (S.pageMetafields = c);
964
964
  try {
965
- const { data: E, errors: F } = await r.request(p, { variables: S, signal: c });
965
+ const { data: E, errors: F } = await r.request(g, { variables: S, signal: m });
966
966
  if (F)
967
- return m(W(F));
967
+ return p(K(F));
968
968
  const P = E;
969
969
  if (b === 0 && (y = P.page ?? null, !y))
970
- return m(
971
- O({
970
+ return p(
971
+ C({
972
972
  code: "NOT_FOUND",
973
973
  source: "shopify",
974
- message: `Page not found: ${s}`
974
+ message: `Page not found: ${i}`
975
975
  })
976
976
  );
977
- const A = (P.nodes ?? []).filter((_) => _ !== null);
978
- I.push(...A);
977
+ const R = (P.nodes ?? []).filter((I) => I !== null);
978
+ _.push(...R);
979
979
  } catch (E) {
980
- return m(K(E));
980
+ return p(W(E));
981
981
  }
982
982
  }
983
- return M({ page: y, products: I });
983
+ return M({ page: y, products: _ });
984
984
  }
985
985
  });
986
986
  }
987
987
  function me(e) {
988
988
  const t = [];
989
989
  e.maxImages !== void 0 && (e.maxImages < ce || e.maxImages > ie) && t.push(
990
- R(
990
+ A(
991
991
  "maxImages",
992
992
  "OUT_OF_RANGE",
993
993
  `maxImages must be between ${ce} and ${ie}`,
@@ -997,7 +997,7 @@ function me(e) {
997
997
  }
998
998
  )
999
999
  ), e.maxVariants !== void 0 && (e.maxVariants < le || e.maxVariants > ae) && t.push(
1000
- R(
1000
+ A(
1001
1001
  "maxVariants",
1002
1002
  "OUT_OF_RANGE",
1003
1003
  `maxVariants must be between ${le} and ${ae}`,
@@ -1009,7 +1009,7 @@ function me(e) {
1009
1009
  );
1010
1010
  for (const r of e.productMetafields ?? [])
1011
1011
  (!r.namespace || !r.key) && t.push(
1012
- R(
1012
+ A(
1013
1013
  "productMetafields",
1014
1014
  "REQUIRED_FIELD",
1015
1015
  "Metafield identifier requires both namespace and key",
@@ -1021,7 +1021,7 @@ function me(e) {
1021
1021
  );
1022
1022
  for (const r of e.variantMetafields ?? [])
1023
1023
  (!r.namespace || !r.key) && t.push(
1024
- R(
1024
+ A(
1025
1025
  "variantMetafields",
1026
1026
  "REQUIRED_FIELD",
1027
1027
  "Metafield identifier requires both namespace and key",
@@ -1040,40 +1040,40 @@ async function _t({
1040
1040
  signal: o
1041
1041
  }) {
1042
1042
  try {
1043
- const { data: n, errors: s } = await e.request(t, { variables: r, signal: o });
1044
- if (s)
1045
- return m(W(s));
1046
- const i = (n?.nodes ?? []).filter(
1043
+ const { data: n, errors: i } = await e.request(t, { variables: r, signal: o });
1044
+ if (i)
1045
+ return p(K(i));
1046
+ const s = (n?.nodes ?? []).filter(
1047
1047
  (a) => a !== null
1048
1048
  );
1049
- return M(i);
1049
+ return M(s);
1050
1050
  } catch (n) {
1051
- return m(K(n));
1051
+ return p(W(n));
1052
1052
  }
1053
1053
  }
1054
- function W(e) {
1054
+ function K(e) {
1055
1055
  const t = e.networkStatusCode;
1056
- return t === 401 ? O({
1056
+ return t === 401 ? C({
1057
1057
  code: "UNAUTHORIZED",
1058
1058
  source: "shopify",
1059
1059
  message: "Unauthorized: Invalid or missing storefront access token",
1060
1060
  status: t
1061
- }) : t === 403 ? O({
1061
+ }) : t === 403 ? C({
1062
1062
  code: "FORBIDDEN",
1063
1063
  source: "shopify",
1064
1064
  message: "Forbidden: Access denied to the requested resource",
1065
1065
  status: t
1066
- }) : t === 429 ? O({
1066
+ }) : t === 429 ? C({
1067
1067
  code: "RATE_LIMITED",
1068
1068
  source: "shopify",
1069
1069
  message: "Rate limited: Too many requests to the Storefront API",
1070
1070
  status: t
1071
- }) : t !== void 0 && t >= 500 ? O({
1071
+ }) : t !== void 0 && t >= 500 ? C({
1072
1072
  code: "SERVICE_UNAVAILABLE",
1073
1073
  source: "shopify",
1074
1074
  message: `Shopify service error: ${e.message ?? `HTTP ${t}`}`,
1075
1075
  status: t
1076
- }) : O({
1076
+ }) : C({
1077
1077
  code: "GRAPHQL_ERROR",
1078
1078
  source: "shopify",
1079
1079
  message: e.message ?? "GraphQL request failed",
@@ -1087,7 +1087,7 @@ function W(e) {
1087
1087
  }
1088
1088
  });
1089
1089
  }
1090
- function K(e) {
1090
+ function W(e) {
1091
1091
  if (e instanceof Error && (e.name === "AbortError" || e.name === "TimeoutError")) {
1092
1092
  const t = e.name === "TimeoutError" || e.message.includes("timeout");
1093
1093
  return J({
@@ -1102,194 +1102,227 @@ function K(e) {
1102
1102
  cause: e
1103
1103
  });
1104
1104
  }
1105
- const Oe = 1, It = "cb-sdk-store";
1106
- function pe() {
1107
- return typeof window > "u" || !window.localStorage ? null : window.localStorage;
1105
+ const Oe = 2, Et = "cb-sdk-store";
1106
+ function It(e) {
1107
+ return typeof window > "u" || !window.localStorage ? null : {
1108
+ read: () => window.localStorage.getItem(e),
1109
+ write: (t) => window.localStorage.setItem(e, t),
1110
+ remove: () => window.localStorage.removeItem(e)
1111
+ };
1112
+ }
1113
+ function or(e, t) {
1114
+ return {
1115
+ read() {
1116
+ try {
1117
+ return t.readFileSync(e, "utf-8");
1118
+ } catch {
1119
+ return null;
1120
+ }
1121
+ },
1122
+ write(r) {
1123
+ try {
1124
+ t.writeFileSync(e, r, "utf-8");
1125
+ } catch {
1126
+ }
1127
+ },
1128
+ remove() {
1129
+ try {
1130
+ t.unlinkSync(e);
1131
+ } catch {
1132
+ }
1133
+ }
1134
+ };
1108
1135
  }
1109
1136
  function bt(e) {
1110
- typeof requestIdleCallback == "function" ? requestIdleCallback(e, { timeout: rt }) : setTimeout(e, 0);
1137
+ typeof requestIdleCallback == "function" ? requestIdleCallback(e, { timeout: tt }) : setTimeout(e, 0);
1111
1138
  }
1112
- function Ne(e) {
1139
+ function Ce(e) {
1113
1140
  return [...e].sort((t, r) => r[1].timestamp - t[1].timestamp);
1114
1141
  }
1115
1142
  function vt({
1116
- storageKey: e = It,
1143
+ storageKey: e = Et,
1117
1144
  maxProducts: t = ke,
1118
- maxQueries: r = qe
1145
+ maxQueries: r = Ne,
1146
+ adapter: o
1119
1147
  } = {}) {
1148
+ const n = o ?? It(e);
1120
1149
  return {
1121
- save(o) {
1122
- const n = pe();
1150
+ save(i) {
1123
1151
  n && bt(() => {
1124
1152
  try {
1125
1153
  const s = {
1126
- products: Ne(o.products).slice(
1154
+ products: Ce(i.products).slice(
1127
1155
  0,
1128
1156
  t
1129
1157
  ),
1130
- queries: Ne(o.queries).slice(0, r),
1131
- collections: o.collections,
1158
+ queries: Ce(i.queries).slice(0, r),
1159
+ collections: i.collections,
1132
1160
  version: Oe
1133
1161
  };
1134
- n.setItem(e, JSON.stringify(s));
1162
+ n.write(JSON.stringify(s));
1135
1163
  } catch {
1136
1164
  }
1137
1165
  });
1138
1166
  },
1139
1167
  restore() {
1140
- const o = pe();
1141
- if (!o) return null;
1168
+ if (!n) return null;
1142
1169
  try {
1143
- const n = o.getItem(e);
1144
- if (!n) return null;
1145
- const s = JSON.parse(n);
1146
- return s.version !== Oe || !Array.isArray(s.products) || !Array.isArray(s.queries) ? (o.removeItem(e), null) : s;
1170
+ const i = n.read();
1171
+ if (!i) return null;
1172
+ const s = JSON.parse(i);
1173
+ return s.version !== Oe || !Array.isArray(s.products) || !Array.isArray(s.queries) ? (n.remove(), null) : s;
1147
1174
  } catch {
1148
- return o.removeItem(e), null;
1175
+ return n.remove(), null;
1149
1176
  }
1150
1177
  },
1151
1178
  clear() {
1152
- pe()?.removeItem(e);
1179
+ n?.remove();
1153
1180
  }
1154
1181
  };
1155
1182
  }
1156
1183
  function Ft(e, t) {
1157
1184
  if (e.size <= t) return;
1158
- const o = [...e.entries()].sort((n, s) => n[1].timestamp - s[1].timestamp).slice(0, e.size - t);
1185
+ const o = [...e.entries()].sort((n, i) => n[1].timestamp - i[1].timestamp).slice(0, e.size - t);
1159
1186
  for (const [n] of o)
1160
1187
  e.delete(n);
1161
1188
  }
1162
1189
  function Mt(e, t) {
1163
1190
  if (e.size <= t) return;
1164
1191
  const r = [];
1165
- for (const [n, s] of e)
1166
- s.value && r.push([n, s.value.timestamp]);
1167
- r.sort((n, s) => n[1] - s[1]);
1192
+ for (const [n, i] of e)
1193
+ i.value && r.push([n, i.value.timestamp]);
1194
+ r.sort((n, i) => n[1] - i[1]);
1168
1195
  const o = r.slice(0, e.size - t);
1169
1196
  for (const [n] of o) {
1170
- const s = e.get(n);
1171
- s && (s.value = null), e.delete(n);
1197
+ const i = e.get(n);
1198
+ i && (i.value = null), e.delete(n);
1172
1199
  }
1173
1200
  }
1174
1201
  function St(e = {}) {
1175
1202
  const {
1176
- ttl: t = Xe,
1203
+ ttl: t = We,
1177
1204
  maxProducts: r = ke,
1178
- maxQueries: o = qe,
1179
- storageKey: n
1180
- } = e, s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), u = vt({ storageKey: n, maxProducts: r, maxQueries: o });
1181
- function g(c) {
1182
- return Date.now() - c > t;
1205
+ maxQueries: o = Ne,
1206
+ storageKey: n,
1207
+ storageAdapter: i
1208
+ } = e, s = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), f = vt({
1209
+ storageKey: n,
1210
+ maxProducts: r,
1211
+ maxQueries: o,
1212
+ adapter: i
1213
+ });
1214
+ function d(l) {
1215
+ return Date.now() - l > t;
1183
1216
  }
1184
- function f(c) {
1185
- let d = l.get(c);
1186
- return d || (d = $(null), l.set(c, d)), d;
1217
+ function m(l) {
1218
+ let g = c.get(l);
1219
+ return g || (g = $(null), c.set(l, g)), g;
1187
1220
  }
1188
1221
  return {
1189
1222
  products: {
1190
- get(c) {
1191
- const d = s.get(c);
1192
- if (d) {
1193
- if (g(d.timestamp)) {
1194
- s.delete(c);
1223
+ get(l) {
1224
+ const g = s.get(l);
1225
+ if (g) {
1226
+ if (d(g.timestamp)) {
1227
+ s.delete(l);
1195
1228
  return;
1196
1229
  }
1197
- return d.data;
1230
+ return g.data;
1198
1231
  }
1199
1232
  },
1200
- getMany(c) {
1201
- const d = [], p = [];
1202
- for (const h of c) {
1203
- const y = s.get(h);
1204
- y && !g(y.timestamp) ? d.push(y.data) : p.push(h);
1233
+ getMany(l) {
1234
+ const g = [], h = [];
1235
+ for (const y of l) {
1236
+ const _ = s.get(y);
1237
+ _ && !d(_.timestamp) ? g.push(_.data) : h.push(y);
1205
1238
  }
1206
- return { cached: d, missing: p };
1239
+ return { cached: g, missing: h };
1207
1240
  },
1208
- set(c) {
1209
- const d = Date.now();
1210
- for (const p of c)
1211
- s.set(p.gid, { data: p, timestamp: d });
1241
+ set(l) {
1242
+ const g = Date.now(), h = Array.isArray(l) ? l : [l];
1243
+ for (const y of h)
1244
+ s.set(y.gid, { data: y, timestamp: g });
1212
1245
  Ft(s, r);
1213
1246
  },
1214
- has(c) {
1215
- const d = s.get(c);
1216
- return d != null && !g(d.timestamp);
1247
+ has(l) {
1248
+ const g = s.get(l);
1249
+ return g != null && !d(g.timestamp);
1217
1250
  }
1218
1251
  },
1219
1252
  queries: {
1220
- get(c) {
1221
- return f(c);
1253
+ get(l) {
1254
+ return m(l);
1222
1255
  },
1223
- set(c, d) {
1224
- const p = f(c);
1225
- p.value = { data: d, timestamp: Date.now() }, Mt(l, o);
1256
+ set(l, g) {
1257
+ const h = m(l);
1258
+ h.value = { data: g, timestamp: Date.now() }, Mt(c, o);
1226
1259
  },
1227
- isExpired(c) {
1228
- const d = l.get(c);
1229
- return d?.value ? g(d.value.timestamp) : !0;
1260
+ isExpired(l) {
1261
+ const g = c.get(l);
1262
+ return g?.value ? d(g.value.timestamp) : !0;
1230
1263
  },
1231
- invalidate(c) {
1232
- for (const [d, p] of l)
1233
- d.includes(c) && (p.value = null);
1264
+ invalidate(l) {
1265
+ for (const [g, h] of c)
1266
+ g.includes(l) && (h.value = null);
1234
1267
  }
1235
1268
  },
1236
1269
  collections: {
1237
- get(c) {
1238
- return i.get(c);
1270
+ get(l) {
1271
+ return a.get(l);
1239
1272
  },
1240
- set(c, d) {
1241
- i.set(c, { ...d, handle: c });
1273
+ set(l, g) {
1274
+ a.set(l, { ...g, handle: l });
1242
1275
  },
1243
- delete(c) {
1244
- i.delete(c);
1276
+ delete(l) {
1277
+ a.delete(l);
1245
1278
  }
1246
1279
  },
1247
1280
  pages: {
1248
- get(c) {
1249
- return a.get(c);
1281
+ get(l) {
1282
+ return u.get(l);
1250
1283
  },
1251
- set(c, d) {
1252
- a.set(c, { ...d, handle: c });
1284
+ set(l, g) {
1285
+ u.set(l, { ...g, handle: l });
1253
1286
  },
1254
- delete(c) {
1255
- a.delete(c);
1287
+ delete(l) {
1288
+ u.delete(l);
1256
1289
  }
1257
1290
  },
1258
1291
  persist() {
1259
- const c = [], d = [], p = [];
1260
- for (const [h, y] of s)
1261
- g(y.timestamp) || c.push([h, y]);
1262
- for (const [h, y] of l)
1263
- y.value && !g(y.value.timestamp) && d.push([h, y.value]);
1264
- for (const [h, y] of i)
1265
- p.push([h, y]);
1266
- u.save({ products: c, queries: d, collections: p });
1292
+ const l = [], g = [], h = [];
1293
+ for (const [y, _] of s)
1294
+ d(_.timestamp) || l.push([y, _]);
1295
+ for (const [y, _] of c)
1296
+ _.value && !d(_.value.timestamp) && g.push([y, _.value]);
1297
+ for (const [y, _] of a)
1298
+ h.push([y, _]);
1299
+ f.save({ products: l, queries: g, collections: h });
1267
1300
  },
1268
1301
  restore() {
1269
- const c = u.restore();
1270
- if (c) {
1271
- for (const [d, p] of c.products)
1272
- g(p.timestamp) || s.set(d, p);
1273
- for (const [d, p] of c.queries)
1274
- if (!g(p.timestamp)) {
1275
- const h = f(d);
1276
- h.value = p;
1302
+ const l = f.restore();
1303
+ if (l) {
1304
+ for (const [g, h] of l.products)
1305
+ d(h.timestamp) || s.set(g, h);
1306
+ for (const [g, h] of l.queries)
1307
+ if (!d(h.timestamp)) {
1308
+ const y = m(g);
1309
+ y.value = h;
1277
1310
  }
1278
- for (const [d, p] of c.collections)
1279
- i.set(d, p);
1311
+ for (const [g, h] of l.collections)
1312
+ a.set(g, h);
1280
1313
  }
1281
1314
  },
1282
1315
  clear() {
1283
1316
  s.clear();
1284
- for (const c of l.values()) c.value = null;
1285
- l.clear(), i.clear(), a.clear(), u.clear();
1317
+ for (const l of c.values()) l.value = null;
1318
+ c.clear(), a.clear(), u.clear(), f.clear();
1286
1319
  },
1287
1320
  get stats() {
1288
1321
  return {
1289
1322
  products: s.size,
1290
- queries: l.size,
1291
- collections: i.size,
1292
- pages: a.size
1323
+ queries: c.size,
1324
+ collections: a.size,
1325
+ pages: u.size
1293
1326
  };
1294
1327
  }
1295
1328
  };
@@ -1304,112 +1337,112 @@ function Pt(e, t = {}) {
1304
1337
  const r = `/browse/${encodeURIComponent(e)}`, o = Ae(t, ["collectionHandle", "signal"]);
1305
1338
  return o ? `${r}?${o}` : r;
1306
1339
  }
1307
- function Rt(e, t = {}) {
1340
+ function At(e, t = {}) {
1308
1341
  if (!e?.trim()) return;
1309
1342
  const r = `/search/${encodeURIComponent(e)}`, o = Ae(t, ["query", "signal"]);
1310
1343
  return o ? `${r}?${o}` : r;
1311
1344
  }
1312
- function At(e, t = {}) {
1345
+ function Rt(e, t = {}) {
1313
1346
  if (!e?.trim()) return;
1314
1347
  const r = `/blocks/${encodeURIComponent(e)}`, o = Ae(t, ["blockId", "signal"]);
1315
1348
  return o ? `${r}?${o}` : r;
1316
1349
  }
1317
- var he = /* @__PURE__ */ ((e) => (e.Equal = "eq", e.NotEqual = "not_eq", e.In = "in", e.NotIn = "not_in", e.GreaterThan = "gt", e.GreaterThanOrEqual = "gte", e.LessThan = "lt", e.LessThanOrEqual = "lte", e.Exists = "exists", e.NotExists = "not_exists", e))(he || {}), Be = /* @__PURE__ */ ((e) => (e.And = "AND", e.Or = "OR", e))(Be || {});
1318
- function or(e, t) {
1350
+ var pe = /* @__PURE__ */ ((e) => (e.Equal = "eq", e.NotEqual = "not_eq", e.In = "in", e.NotIn = "not_in", e.GreaterThan = "gt", e.GreaterThanOrEqual = "gte", e.LessThan = "lt", e.LessThanOrEqual = "lte", e.Exists = "exists", e.NotExists = "not_exists", e))(pe || {}), Ve = /* @__PURE__ */ ((e) => (e.And = "AND", e.Or = "OR", e))(Ve || {});
1351
+ function sr(e, t) {
1319
1352
  return { property: e, operator: "eq", values: [t] };
1320
1353
  }
1321
- function sr(e, t) {
1354
+ function ir(e, t) {
1322
1355
  return { property: e, operator: "not_eq", values: [t] };
1323
1356
  }
1324
- function ir(e, t) {
1357
+ function ar(e, t) {
1325
1358
  return { property: e, operator: "in", values: t };
1326
1359
  }
1327
- function ar(e, t) {
1360
+ function cr(e, t) {
1328
1361
  return { property: e, operator: "not_in", values: t };
1329
1362
  }
1330
- function cr(e, t) {
1363
+ function lr(e, t) {
1331
1364
  return { property: e, operator: "gt", values: [t] };
1332
1365
  }
1333
- function lr(e, t) {
1366
+ function ur(e, t) {
1334
1367
  return { property: e, operator: "gte", values: [t] };
1335
1368
  }
1336
- function ur(e, t) {
1369
+ function dr(e, t) {
1337
1370
  return { property: e, operator: "lt", values: [t] };
1338
1371
  }
1339
- function dr(e, t) {
1372
+ function fr(e, t) {
1340
1373
  return { property: e, operator: "lte", values: [t] };
1341
1374
  }
1342
- function fr(e) {
1375
+ function gr(e) {
1343
1376
  return { property: e, operator: "exists", values: [] };
1344
1377
  }
1345
- function gr(e) {
1378
+ function mr(e) {
1346
1379
  return { property: e, operator: "not_exists", values: [] };
1347
1380
  }
1348
1381
  function Tt(...e) {
1349
1382
  return { conditional: "AND", expressions: e };
1350
1383
  }
1351
- function mr(...e) {
1384
+ function pr(...e) {
1352
1385
  return { conditional: "OR", expressions: e };
1353
1386
  }
1354
1387
  function wt(e) {
1355
1388
  return "conditional" in e;
1356
1389
  }
1357
- function pr(e) {
1390
+ function hr(e) {
1358
1391
  return { filter_group: wt(e) ? e : Tt(e) };
1359
1392
  }
1360
1393
  function Dt(e, t) {
1361
1394
  return `gid://shopify/${e}/${t}`;
1362
1395
  }
1363
- function Ct(e) {
1396
+ function Ot(e) {
1364
1397
  return Dt("Product", e);
1365
1398
  }
1366
- function xe({
1399
+ function Be({
1367
1400
  type: e,
1368
1401
  selectedOptions: t
1369
1402
  }) {
1370
1403
  const r = t.map(({ name: o, value: n }) => `${o}:${n}`).join("-");
1371
1404
  return `${e}-${r}`;
1372
1405
  }
1373
- function Ge(e) {
1406
+ function xe(e) {
1374
1407
  return e.product_id ?? e.id;
1375
1408
  }
1376
- function ye(e) {
1377
- return Ct(Ge(e));
1409
+ function he(e) {
1410
+ return Ot(xe(e));
1378
1411
  }
1379
- function Ot(e, t = {}) {
1412
+ function Ct(e, t = {}) {
1380
1413
  const {
1381
- currencyCode: r = et,
1382
- formatPrice: o = nt,
1414
+ currencyCode: r = Ze,
1415
+ formatPrice: o = rt,
1383
1416
  swatches: n = []
1384
- } = t, s = Ge(e), i = ye(e), a = e.title, l = e.handle ?? "", u = e.vendor ?? "", g = e.product_type ?? "", f = e.body_html ?? "", c = e.available ?? !1, d = e.is_gift_card ?? !1, p = Bt(e), h = e.tags ?? [], y = Nt(e), I = kt(e.price_range, r, o), b = qt(e, n), v = Lt(e, r, o), S = v.map((_) => _.compareAtPrice).filter((_) => _ !== null), E = S.length > 0 ? {
1385
- min: S.reduce((_, C) => _.amount < C.amount ? _ : C),
1386
- max: S.reduce((_, C) => _.amount > C.amount ? _ : C)
1387
- } : void 0, F = e.first_or_matched_variant ? $t(e.first_or_matched_variant) : [], P = xe({ type: "Product", selectedOptions: F }), A = e.metafields ?? {};
1417
+ } = t, i = xe(e), s = he(e), a = e.title, u = e.handle ?? "", c = e.vendor ?? "", f = e.product_type ?? "", d = e.body_html ?? "", m = e.available ?? !1, l = e.is_gift_card ?? !1, g = Bt(e), h = e.tags ?? [], y = kt(e), _ = Nt(e.price_range, r, o), b = qt(e, n), v = Lt(e, r, o), S = v.map((I) => I.compareAtPrice).filter((I) => I !== null), E = S.length > 0 ? {
1418
+ min: S.reduce((I, O) => I.amount < O.amount ? I : O),
1419
+ max: S.reduce((I, O) => I.amount > O.amount ? I : O)
1420
+ } : void 0, F = e.first_or_matched_variant ? $t(e.first_or_matched_variant) : [], P = Be({ type: "Product", selectedOptions: F }), R = e.metafields ?? {};
1388
1421
  return {
1389
1422
  id: P,
1390
- gid: i,
1391
- numericId: s,
1423
+ gid: s,
1424
+ numericId: i,
1392
1425
  title: a,
1393
- handle: l,
1394
- type: g,
1395
- vendor: u,
1396
- description: f,
1397
- availableForSale: c,
1426
+ handle: u,
1427
+ type: f,
1428
+ vendor: c,
1429
+ description: d,
1430
+ availableForSale: m,
1398
1431
  images: y,
1399
- priceRange: I,
1432
+ priceRange: _,
1400
1433
  compareAtPriceRange: E,
1401
1434
  options: b,
1402
1435
  tags: h,
1403
1436
  variants: v,
1404
1437
  selectedOptions: F,
1405
- metafields: A,
1438
+ metafields: R,
1406
1439
  calculated: e.calculated,
1407
- isGiftCard: d,
1440
+ isGiftCard: l,
1408
1441
  onlineStoreUrl: null,
1409
- totalInventory: p
1442
+ totalInventory: g
1410
1443
  };
1411
1444
  }
1412
- function Nt(e) {
1445
+ function kt(e) {
1413
1446
  return (e.images ?? []).map((t) => ({
1414
1447
  url: t.src,
1415
1448
  alt: t.alt ?? "",
@@ -1417,7 +1450,7 @@ function Nt(e) {
1417
1450
  height: t.height
1418
1451
  }));
1419
1452
  }
1420
- function kt(e, t, r) {
1453
+ function Nt(e, t, r) {
1421
1454
  const o = e?.from ?? 0, n = e?.to ?? o;
1422
1455
  return {
1423
1456
  min: { amount: o, currencyCode: t, formatted: r(o, t) },
@@ -1426,10 +1459,10 @@ function kt(e, t, r) {
1426
1459
  }
1427
1460
  function qt(e, t) {
1428
1461
  const r = [], o = e.options ?? {};
1429
- for (const [n, s] of Object.entries(o))
1430
- for (const i of s) {
1431
- const a = t.find((l) => l.name === n && l.value === i);
1432
- r.push({ name: n, value: i, swatch: a });
1462
+ for (const [n, i] of Object.entries(o))
1463
+ for (const s of i) {
1464
+ const a = t.find((u) => u.name === n && u.value === s);
1465
+ r.push({ name: n, value: s, swatch: a });
1433
1466
  }
1434
1467
  return r;
1435
1468
  }
@@ -1442,7 +1475,7 @@ function Lt(e, t, r) {
1442
1475
  function Ut(e, t, r) {
1443
1476
  const o = parseFloat(e.price), n = e.compare_at_price ? parseFloat(e.compare_at_price) : null;
1444
1477
  return {
1445
- id: xe({ type: "ProductVariant", selectedOptions: e.selected_options }),
1478
+ id: Be({ type: "ProductVariant", selectedOptions: e.selected_options }),
1446
1479
  gid: `gid://shopify/ProductVariant/${e.id}`,
1447
1480
  numericId: e.id,
1448
1481
  title: e.title,
@@ -1466,9 +1499,10 @@ function Ut(e, t, r) {
1466
1499
  width: e.featured_media.width,
1467
1500
  height: e.featured_media.height
1468
1501
  } : null,
1469
- selectedOptions: e.selected_options.map((s) => ({ name: s.name, value: s.value })),
1502
+ selectedOptions: e.selected_options.map((i) => ({ name: i.name, value: i.value })),
1470
1503
  metafields: Vt(e.metafields),
1471
- inventoryLevels: e.inventory_levels ?? {}
1504
+ inventoryLevels: e.inventory_levels ?? {},
1505
+ inStockLocationIds: e.in_stock_location_ids ?? []
1472
1506
  };
1473
1507
  }
1474
1508
  function Vt(e) {
@@ -1483,16 +1517,16 @@ function Bt(e) {
1483
1517
  const t = e.first_or_matched_variant;
1484
1518
  return t?.inventory_quantity != null ? t.inventory_quantity : 0;
1485
1519
  }
1486
- function He() {
1520
+ function Ge() {
1487
1521
  return typeof window < "u" && typeof window.document < "u";
1488
1522
  }
1489
1523
  const je = "__COMMERCE_BLOCKS__";
1490
1524
  function xt(e) {
1491
- He() && (window[je] = e);
1525
+ Ge() && (window[je] = e);
1492
1526
  }
1493
1527
  function Gt() {
1494
- if (!He())
1495
- return m(
1528
+ if (!Ge())
1529
+ return p(
1496
1530
  B({
1497
1531
  code: "INVALID_CONFIG",
1498
1532
  message: "SDK only available in browser",
@@ -1501,7 +1535,7 @@ function Gt() {
1501
1535
  })
1502
1536
  );
1503
1537
  const e = window[je];
1504
- return e ? M(e) : m(
1538
+ return e ? M(e) : p(
1505
1539
  B({
1506
1540
  code: "MISSING_CONFIG",
1507
1541
  message: "SDK not initialized. Call createSdk() first.",
@@ -1509,7 +1543,7 @@ function Gt() {
1509
1543
  })
1510
1544
  );
1511
1545
  }
1512
- function hr() {
1546
+ function yr() {
1513
1547
  return Gt().data !== void 0;
1514
1548
  }
1515
1549
  function ne({
@@ -1522,11 +1556,15 @@ function ne({
1522
1556
  totalResults: t.totalResults,
1523
1557
  totalPages: t.totalPages,
1524
1558
  page: t.page,
1525
- facets: t.facets ?? {}
1559
+ resultsPerPage: t.resultsPerPage,
1560
+ facets: t.facets ?? {},
1561
+ facetRanges: t.facetRanges,
1562
+ attributionToken: t.attributionToken,
1563
+ _workflow: t._workflow
1526
1564
  };
1527
1565
  return r ? r(o, t) : o;
1528
1566
  }
1529
- function Ht(e) {
1567
+ function jt(e) {
1530
1568
  return {
1531
1569
  id: "",
1532
1570
  handle: e.handle,
@@ -1544,65 +1582,65 @@ function Ht(e) {
1544
1582
  metafields: e.metafields
1545
1583
  };
1546
1584
  }
1547
- function jt({ ctx: e }) {
1585
+ function Ht({ ctx: e }) {
1548
1586
  function t(a) {
1549
- return a.map(ye);
1587
+ return a.map(he);
1550
1588
  }
1551
- function r(a, l) {
1552
- const u = Ot(a, e.mergeConfig);
1589
+ function r(a, u) {
1590
+ const c = Ct(a, e.mergeConfig);
1553
1591
  return e.config.extendProduct ? { ...e.config.extendProduct({
1554
- base: u,
1592
+ base: c,
1555
1593
  raw: a,
1556
- shopify: l
1557
- }), _base: u } : u;
1594
+ shopify: u
1595
+ }), _base: c } : c;
1558
1596
  }
1559
- function o(a, l, u) {
1560
- return a.map((g) => {
1561
- const f = ye(g), c = u.get(f);
1562
- return c || r(g, l.get(f) ?? null);
1597
+ function o(a, u, c) {
1598
+ return a.map((f) => {
1599
+ const d = he(f), m = c.get(d);
1600
+ return m || r(f, u.get(d) ?? null);
1563
1601
  });
1564
1602
  }
1565
- async function n(a, l = e.config.productMetafields, u = e.config.variantMetafields) {
1566
- const g = /* @__PURE__ */ new Map();
1567
- if (!e.storefrontEnabled || a.length === 0) return M(g);
1568
- const f = await e.storefront.getProducts({
1603
+ async function n(a, u = e.config.productMetafields, c = e.config.variantMetafields) {
1604
+ const f = /* @__PURE__ */ new Map();
1605
+ if (!e.storefrontEnabled || a.length === 0) return M(f);
1606
+ const d = await e.storefront.getProducts({
1569
1607
  ids: a,
1570
- productMetafields: l,
1571
- variantMetafields: u
1608
+ productMetafields: u,
1609
+ variantMetafields: c
1572
1610
  });
1573
- if (f.error) return m(f.error);
1574
- for (const c of f.data)
1575
- g.set(c.id, c);
1576
- return M(g);
1611
+ if (d.error) return p(d.error);
1612
+ for (const m of d.data)
1613
+ f.set(m.id, m);
1614
+ return M(f);
1577
1615
  }
1578
- async function s(a) {
1579
- const l = t(a), { cached: u, missing: g } = e.store.products.getMany(l), f = new Map(u.map((d) => [d.gid, d]));
1580
- if (g.length === 0)
1581
- return M(l.map((d) => f.get(d)));
1582
- const c = await n(g);
1583
- return c.error ? m(c.error) : M(o(a, c.data, f));
1616
+ async function i(a) {
1617
+ const u = t(a), { cached: c, missing: f } = e.store.products.getMany(u), d = new Map(c.map((l) => [l.gid, l]));
1618
+ if (f.length === 0)
1619
+ return M(u.map((l) => d.get(l)));
1620
+ const m = await n(f);
1621
+ return m.error ? p(m.error) : M(o(a, m.data, d));
1584
1622
  }
1585
- function i(a) {
1623
+ function s(a) {
1586
1624
  if (a) {
1587
1625
  if (e.config.transformFilters)
1588
1626
  return e.config.transformFilters(a);
1589
1627
  if (e.config.filterMap && typeof a == "object" && !Array.isArray(a)) {
1590
- const l = a, u = [];
1591
- for (const [g, f] of Object.entries(l)) {
1592
- if (f == null) continue;
1593
- const c = e.config.filterMap[g], d = typeof c == "string" ? c : c?.property ?? g, p = typeof c == "object" ? c.values : void 0, y = (Array.isArray(f) ? f : [f]).map((I) => {
1594
- const b = String(I);
1595
- return p?.[b] ?? b;
1628
+ const u = a, c = [];
1629
+ for (const [f, d] of Object.entries(u)) {
1630
+ if (d == null) continue;
1631
+ const m = e.config.filterMap[f], l = typeof m == "string" ? m : m?.property ?? f, g = typeof m == "object" ? m.values : void 0, y = (Array.isArray(d) ? d : [d]).map((_) => {
1632
+ const b = String(_);
1633
+ return g?.[b] ?? b;
1596
1634
  });
1597
- u.push({
1598
- property: d,
1599
- operator: y.length > 1 ? he.In : he.Equal,
1635
+ c.push({
1636
+ property: l,
1637
+ operator: y.length > 1 ? pe.In : pe.Equal,
1600
1638
  values: y
1601
1639
  });
1602
1640
  }
1603
- return u.length === 0 ? void 0 : {
1604
- conditional: Be.And,
1605
- expressions: u
1641
+ return c.length === 0 ? void 0 : {
1642
+ conditional: Ve.And,
1643
+ expressions: c
1606
1644
  };
1607
1645
  }
1608
1646
  return a;
@@ -1613,8 +1651,8 @@ function jt({ ctx: e }) {
1613
1651
  buildSingleProduct: r,
1614
1652
  buildProductsWithCache: o,
1615
1653
  fetchStorefrontProductsMap: n,
1616
- fetchAndBuildProducts: s,
1617
- transformFilters: i
1654
+ fetchAndBuildProducts: i,
1655
+ transformFilters: s
1618
1656
  };
1619
1657
  }
1620
1658
  function oe(e) {
@@ -1637,14 +1675,14 @@ function X({
1637
1675
  paramDefinitions: t,
1638
1676
  transformBody: r
1639
1677
  }) {
1640
- const o = Qt({ definitions: t }), n = { ...e, ...o }, s = Object.keys(n).length > 0;
1641
- if (!(!s && !r))
1642
- return (i) => {
1643
- const a = s ? { ...i, ...n } : i;
1678
+ const o = Qt({ definitions: t }), n = { ...e, ...o }, i = Object.keys(n).length > 0;
1679
+ if (!(!i && !r))
1680
+ return (s) => {
1681
+ const a = i ? { ...s, ...n } : s;
1644
1682
  return r ? r(a) : a;
1645
1683
  };
1646
1684
  }
1647
- function Wt({
1685
+ function Kt({
1648
1686
  ctx: e,
1649
1687
  helpers: t
1650
1688
  }) {
@@ -1654,86 +1692,86 @@ function Wt({
1654
1692
  error: null,
1655
1693
  isFetching: !1
1656
1694
  });
1657
- let s = null, i = o ?? e.config.sorts[0]?.code;
1695
+ let i = null, s = o ?? e.config.sorts[0]?.code;
1658
1696
  return {
1659
1697
  state: n,
1660
1698
  async execute(a = {}) {
1661
1699
  const {
1662
- page: l = Y,
1663
- limit: u = Z,
1664
- filters: g,
1665
- sortOrderCode: f,
1666
- signal: c,
1667
- includeMeta: d = e.config.includeMeta ?? !1,
1668
- collectionMetafields: p = e.config.collectionMetafields,
1700
+ page: u = Y,
1701
+ limit: c = Z,
1702
+ filters: f,
1703
+ sortOrderCode: d,
1704
+ signal: m,
1705
+ includeMeta: l = e.config.includeMeta ?? !1,
1706
+ collectionMetafields: g = e.config.collectionMetafields,
1669
1707
  includeFilters: h,
1670
1708
  dynamicLinking: y,
1671
- params: I,
1709
+ params: _,
1672
1710
  paramDefinitions: b,
1673
1711
  transformBody: v
1674
- } = a, S = f ?? i;
1675
- i = S, s?.abort(), s = oe(c);
1712
+ } = a, S = d ?? s;
1713
+ s = S, i?.abort(), i = oe(m);
1676
1714
  const E = n.value.data;
1677
1715
  n.value = { data: E, error: null, isFetching: !0 };
1678
1716
  const { data: F, error: P } = await e.layers.browse(
1679
1717
  {
1680
1718
  collectionHandle: r,
1681
1719
  sort_order_code: S,
1682
- pagination: { page: l, limit: u },
1683
- filter_group: t.transformFilters(g),
1720
+ pagination: { page: u, limit: c },
1721
+ filter_group: t.transformFilters(f),
1684
1722
  dynamicLinking: y,
1685
- transformBody: X({ params: I, paramDefinitions: b, transformBody: v })
1723
+ transformBody: X({ params: _, paramDefinitions: b, transformBody: v })
1686
1724
  },
1687
- s.signal
1725
+ i.signal
1688
1726
  );
1689
1727
  if (P)
1690
- return n.value = { data: E, error: P, isFetching: !1 }, m(P);
1691
- const { results: A } = F, _ = A, C = t.extractGids(_), { cached: N, missing: k } = e.store.products.getMany(C), L = new Map(N.map((w) => [w.gid, w])), U = d && !p?.length ? e.store.collections.get(r) : void 0, Te = U?.title !== void 0;
1728
+ return n.value = { data: E, error: P, isFetching: !1 }, p(P);
1729
+ const { results: R } = F, I = R, O = t.extractGids(I), { cached: k, missing: N } = e.store.products.getMany(O), L = new Map(k.map((w) => [w.gid, w])), U = l && !g?.length ? e.store.collections.get(r) : void 0, Re = U?.title !== void 0;
1692
1730
  let x, T;
1693
- if (k.length === 0)
1694
- x = C.map((w) => L.get(w));
1695
- else if (e.storefrontEnabled && d && !Te) {
1731
+ if (N.length === 0)
1732
+ x = O.map((w) => L.get(w));
1733
+ else if (e.storefrontEnabled && l && !Re) {
1696
1734
  const w = await e.storefront.getCollectionWithProducts({
1697
1735
  handle: r,
1698
- ids: k,
1736
+ ids: N,
1699
1737
  productMetafields: e.config.productMetafields,
1700
1738
  variantMetafields: e.config.variantMetafields,
1701
- collectionMetafields: p,
1739
+ collectionMetafields: g,
1702
1740
  includeFilters: h
1703
1741
  });
1704
1742
  if (w.data) {
1705
1743
  T = w.data.collection;
1706
1744
  const V = /* @__PURE__ */ new Map();
1707
- for (const De of w.data.products)
1708
- V.set(De.id, De);
1709
- x = t.buildProductsWithCache(_, V, L);
1745
+ for (const we of w.data.products)
1746
+ V.set(we.id, we);
1747
+ x = t.buildProductsWithCache(I, V, L);
1710
1748
  } else {
1711
- const V = await t.fetchStorefrontProductsMap(k);
1749
+ const V = await t.fetchStorefrontProductsMap(N);
1712
1750
  if (V.error)
1713
- return n.value = { data: E, error: V.error, isFetching: !1 }, m(V.error);
1751
+ return n.value = { data: E, error: V.error, isFetching: !1 }, p(V.error);
1714
1752
  x = t.buildProductsWithCache(
1715
- _,
1753
+ I,
1716
1754
  V.data,
1717
1755
  L
1718
1756
  );
1719
1757
  }
1720
1758
  } else {
1721
- const w = await t.fetchStorefrontProductsMap(k);
1759
+ const w = await t.fetchStorefrontProductsMap(N);
1722
1760
  if (w.error)
1723
- return n.value = { data: E, error: w.error, isFetching: !1 }, m(w.error);
1761
+ return n.value = { data: E, error: w.error, isFetching: !1 }, p(w.error);
1724
1762
  x = t.buildProductsWithCache(
1725
- _,
1763
+ I,
1726
1764
  w.data,
1727
1765
  L
1728
1766
  );
1729
1767
  }
1730
- if (e.storefrontEnabled && d && !T)
1731
- if (Te)
1732
- T = Ht(U);
1768
+ if (e.storefrontEnabled && l && !T)
1769
+ if (Re)
1770
+ T = jt(U);
1733
1771
  else {
1734
1772
  const w = await e.storefront.getCollection({
1735
1773
  handle: r,
1736
- collectionMetafields: p,
1774
+ collectionMetafields: g,
1737
1775
  includeFilters: h
1738
1776
  });
1739
1777
  w.data && (T = w.data);
@@ -1743,12 +1781,12 @@ function Wt({
1743
1781
  raw: F,
1744
1782
  extender: e.config.extendCollection
1745
1783
  });
1746
- d && F._meta && (q._meta = F._meta), T && (q.collection = T);
1747
- const we = Pt(r, { sortOrderCode: S, page: l, limit: u, filters: g });
1748
- return we && e.store.queries.set(we, q), e.store.products.set(x), e.store.collections.set(r, {
1784
+ l && F._meta && (q._meta = F._meta), T && (q.collection = T);
1785
+ const Te = Pt(r, { sortOrderCode: S, page: u, limit: c, filters: f });
1786
+ return Te && e.store.queries.set(Te, q), e.store.products.set(x), e.store.collections.set(r, {
1749
1787
  totalProducts: q.totalResults,
1750
1788
  totalPages: q.totalPages,
1751
- lastPageFetched: l,
1789
+ lastPageFetched: u,
1752
1790
  facets: q.facets,
1753
1791
  lastFetched: Date.now(),
1754
1792
  ...T && {
@@ -1766,12 +1804,12 @@ function Wt({
1766
1804
  }), n.value = { data: q, error: null, isFetching: !1 }, M(q);
1767
1805
  },
1768
1806
  dispose() {
1769
- s?.abort();
1807
+ i?.abort();
1770
1808
  }
1771
1809
  };
1772
1810
  };
1773
1811
  }
1774
- function Kt({
1812
+ function Wt({
1775
1813
  ctx: e,
1776
1814
  helpers: t
1777
1815
  }) {
@@ -1784,107 +1822,107 @@ function Kt({
1784
1822
  let o = null, n;
1785
1823
  return {
1786
1824
  state: r,
1787
- async prepare(s) {
1825
+ async prepare(i) {
1788
1826
  const {
1789
- query: i,
1827
+ query: s,
1790
1828
  filters: a,
1791
- tuning: l,
1792
- signal: u,
1793
- dynamicLinking: g,
1794
- params: f,
1795
- paramDefinitions: c,
1796
- transformBody: d
1797
- } = s, p = t.transformFilters(a), h = await e.layers.prepareSearch(
1829
+ tuning: u,
1830
+ signal: c,
1831
+ dynamicLinking: f,
1832
+ params: d,
1833
+ paramDefinitions: m,
1834
+ transformBody: l
1835
+ } = i, g = t.transformFilters(a), h = await e.layers.prepareSearch(
1798
1836
  {
1799
- query: i,
1800
- filter_group: p,
1801
- tuning: l,
1802
- dynamicLinking: g,
1803
- transformBody: X({ params: f, paramDefinitions: c, transformBody: d })
1837
+ query: s,
1838
+ filter_group: g,
1839
+ tuning: u,
1840
+ dynamicLinking: f,
1841
+ transformBody: X({ params: d, paramDefinitions: m, transformBody: l })
1804
1842
  },
1805
- u
1843
+ c
1806
1844
  );
1807
- return h.error ? m(h.error) : (n = h.data.search_id, M({ searchId: h.data.search_id }));
1845
+ return h.error ? p(h.error) : (n = h.data.search_id, M({ searchId: h.data.search_id }));
1808
1846
  },
1809
- async execute(s) {
1847
+ async execute(i) {
1810
1848
  const {
1811
- query: i,
1849
+ query: s,
1812
1850
  searchId: a,
1813
- page: l = Y,
1814
- limit: u = Z,
1815
- filters: g,
1816
- tuning: f,
1817
- signal: c,
1818
- dynamicLinking: d,
1819
- params: p,
1851
+ page: u = Y,
1852
+ limit: c = Z,
1853
+ filters: f,
1854
+ tuning: d,
1855
+ signal: m,
1856
+ dynamicLinking: l,
1857
+ params: g,
1820
1858
  paramDefinitions: h,
1821
1859
  transformBody: y
1822
- } = s, I = t.transformFilters(g), b = X({ params: p, paramDefinitions: h, transformBody: y });
1823
- o?.abort(), o = oe(c), r.value = { ...r.value, isFetching: !0, error: null };
1860
+ } = i, _ = t.transformFilters(f), b = X({ params: g, paramDefinitions: h, transformBody: y });
1861
+ o?.abort(), o = oe(m), r.value = { ...r.value, isFetching: !0, error: null };
1824
1862
  let v = a ?? n;
1825
1863
  if (n = void 0, !v) {
1826
- const N = await e.layers.prepareSearch(
1864
+ const k = await e.layers.prepareSearch(
1827
1865
  {
1828
- query: i,
1829
- filter_group: I,
1830
- tuning: f,
1831
- dynamicLinking: d,
1866
+ query: s,
1867
+ filter_group: _,
1868
+ tuning: d,
1869
+ dynamicLinking: l,
1832
1870
  transformBody: b
1833
1871
  },
1834
1872
  o.signal
1835
1873
  );
1836
- if (N.error)
1837
- return r.value = { ...r.value, isFetching: !1, error: N.error }, m(N.error);
1838
- v = N.data.search_id;
1874
+ if (k.error)
1875
+ return r.value = { ...r.value, isFetching: !1, error: k.error }, p(k.error);
1876
+ v = k.data.search_id;
1839
1877
  }
1840
- const S = Je;
1878
+ const S = ze;
1841
1879
  let E = await e.layers.search(
1842
1880
  {
1843
- query: i,
1881
+ query: s,
1844
1882
  search_id: v,
1845
- pagination: { page: l, limit: u },
1846
- filter_group: I,
1847
- tuning: f,
1848
- dynamicLinking: d,
1883
+ pagination: { page: u, limit: c },
1884
+ filter_group: _,
1885
+ tuning: d,
1886
+ dynamicLinking: l,
1849
1887
  transformBody: b
1850
1888
  },
1851
1889
  o.signal
1852
1890
  );
1853
- for (let N = 0; N < S && E.error; N++) {
1854
- const k = E.error;
1855
- if (k._tag !== "ApiError" || k.status !== 425) break;
1856
- let L = Ye;
1891
+ for (let k = 0; k < S && E.error; k++) {
1892
+ const N = E.error;
1893
+ if (N._tag !== "ApiError" || N.status !== 425) break;
1894
+ let L = Je;
1857
1895
  try {
1858
- const U = JSON.parse(k.message);
1896
+ const U = JSON.parse(N.message);
1859
1897
  U.retry_after_ms && (L = U.retry_after_ms);
1860
1898
  } catch {
1861
1899
  }
1862
1900
  await new Promise((U) => setTimeout(U, L)), E = await e.layers.search(
1863
1901
  {
1864
- query: i,
1902
+ query: s,
1865
1903
  search_id: v,
1866
- pagination: { page: l, limit: u },
1867
- filter_group: I,
1868
- tuning: f,
1869
- dynamicLinking: d,
1904
+ pagination: { page: u, limit: c },
1905
+ filter_group: _,
1906
+ tuning: d,
1907
+ dynamicLinking: l,
1870
1908
  transformBody: b
1871
1909
  },
1872
1910
  o.signal
1873
1911
  );
1874
1912
  }
1875
1913
  if (E.error)
1876
- return r.value = { data: r.value.data, error: E.error, isFetching: !1 }, m(E.error);
1914
+ return r.value = { data: r.value.data, error: E.error, isFetching: !1 }, p(E.error);
1877
1915
  const { results: F } = E.data, P = await t.fetchAndBuildProducts(F);
1878
1916
  if (P.error)
1879
- return r.value = { data: r.value.data, error: P.error, isFetching: !1 }, m(P.error);
1880
- const A = P.data, _ = ne({
1881
- products: A,
1917
+ return r.value = { data: r.value.data, error: P.error, isFetching: !1 }, p(P.error);
1918
+ const R = P.data, I = ne({
1919
+ products: R,
1882
1920
  raw: E.data,
1883
1921
  extender: e.config.extendSearch
1884
1922
  });
1885
- e.config.includeMeta && E.data._meta && (_._meta = E.data._meta), e.store.products.set(A);
1886
- const C = Rt(i, { page: l, limit: u, filters: g });
1887
- return C && e.store.queries.set(C, _), r.value = { data: _, error: null, isFetching: !1 }, M(_);
1923
+ e.config.includeMeta && E.data._meta && (I._meta = E.data._meta), e.store.products.set(R);
1924
+ const O = At(s, { page: u, limit: c, filters: f });
1925
+ return O && e.store.queries.set(O, I), r.value = { data: I, error: null, isFetching: !1 }, M(I);
1888
1926
  },
1889
1927
  dispose() {
1890
1928
  o?.abort();
@@ -1897,60 +1935,60 @@ function Xt({
1897
1935
  helpers: t
1898
1936
  }) {
1899
1937
  return ({ blockId: r, anchorId: o, anchorHandle: n }) => {
1900
- const s = $({
1938
+ const i = $({
1901
1939
  data: null,
1902
1940
  error: null,
1903
1941
  isFetching: !1
1904
1942
  });
1905
- let i = null;
1943
+ let s = null;
1906
1944
  return {
1907
- state: s,
1945
+ state: i,
1908
1946
  async execute(a = {}) {
1909
1947
  const {
1910
- page: l = Y,
1911
- limit: u = Z,
1912
- filters: g,
1913
- signal: f,
1914
- discountEntitlements: c,
1915
- context: d,
1916
- dynamicLinking: p,
1948
+ page: u = Y,
1949
+ limit: c = Z,
1950
+ filters: f,
1951
+ signal: d,
1952
+ discountEntitlements: m,
1953
+ context: l,
1954
+ dynamicLinking: g,
1917
1955
  params: h,
1918
1956
  paramDefinitions: y,
1919
- transformBody: I
1957
+ transformBody: _
1920
1958
  } = a;
1921
- i?.abort(), i = oe(f);
1922
- const b = s.value.data;
1923
- s.value = { data: b, error: null, isFetching: !0 };
1959
+ s?.abort(), s = oe(d);
1960
+ const b = i.value.data;
1961
+ i.value = { data: b, error: null, isFetching: !0 };
1924
1962
  const { data: v, error: S } = await e.layers.blocks(
1925
1963
  {
1926
1964
  blockId: r,
1927
1965
  anchor_id: o,
1928
1966
  anchor_handle: n,
1929
- pagination: { page: l, limit: u },
1930
- filter_group: t.transformFilters(g),
1931
- discountEntitlements: c,
1932
- context: d,
1933
- dynamicLinking: p,
1934
- transformBody: X({ params: h, paramDefinitions: y, transformBody: I })
1967
+ pagination: { page: u, limit: c },
1968
+ filter_group: t.transformFilters(f),
1969
+ discountEntitlements: m,
1970
+ context: l,
1971
+ dynamicLinking: g,
1972
+ transformBody: X({ params: h, paramDefinitions: y, transformBody: _ })
1935
1973
  },
1936
- i.signal
1974
+ s.signal
1937
1975
  );
1938
1976
  if (S)
1939
- return s.value = { data: b, error: S, isFetching: !1 }, m(S);
1977
+ return i.value = { data: b, error: S, isFetching: !1 }, p(S);
1940
1978
  const { results: E } = v, F = await t.fetchAndBuildProducts(E);
1941
1979
  if (F.error)
1942
- return s.value = { data: b, error: F.error, isFetching: !1 }, m(F.error);
1943
- const P = F.data, A = ne({
1980
+ return i.value = { data: b, error: F.error, isFetching: !1 }, p(F.error);
1981
+ const P = F.data, R = ne({
1944
1982
  products: P,
1945
1983
  raw: v,
1946
1984
  extender: e.config.extendBlock
1947
1985
  });
1948
- e.config.includeMeta && v._meta && (A._meta = v._meta), v.block && (A.block = v.block);
1949
- const _ = At(r, { anchorId: o, anchorHandle: n, page: l, limit: u, filters: g });
1950
- return _ && e.store.queries.set(_, A), e.store.products.set(P), s.value = { data: A, error: null, isFetching: !1 }, M(A);
1986
+ e.config.includeMeta && v._meta && (R._meta = v._meta), v.block && (R.block = v.block);
1987
+ const I = Rt(r, { anchorId: o, anchorHandle: n, page: u, limit: c, filters: f });
1988
+ return I && e.store.queries.set(I, R), e.store.products.set(P), i.value = { data: R, error: null, isFetching: !1 }, M(R);
1951
1989
  },
1952
1990
  dispose() {
1953
- i?.abort();
1991
+ s?.abort();
1954
1992
  }
1955
1993
  };
1956
1994
  };
@@ -1970,32 +2008,32 @@ function Jt({
1970
2008
  ctx: e
1971
2009
  }) {
1972
2010
  return (t = {}) => {
1973
- const { debounceMs: r = Ze, signal: o } = t, n = $({
2011
+ const { debounceMs: r = Ye, signal: o } = t, n = $({
1974
2012
  data: null,
1975
2013
  error: null,
1976
2014
  isFetching: !1
1977
2015
  });
1978
- let s = null;
1979
- const i = /* @__PURE__ */ new Map();
2016
+ let i = null;
2017
+ const s = /* @__PURE__ */ new Map();
1980
2018
  function a() {
1981
- l.cancel(), s?.abort();
2019
+ u.cancel(), i?.abort();
1982
2020
  }
1983
2021
  o?.addEventListener("abort", a, { once: !0 });
1984
- const l = zt(async (u) => {
1985
- if (!u.trim()) {
2022
+ const u = zt(async (c) => {
2023
+ if (!c.trim()) {
1986
2024
  n.value = { data: null, error: null, isFetching: !1 };
1987
2025
  return;
1988
2026
  }
1989
- const g = u.trim().toLowerCase(), f = i.get(g);
1990
- if (f) {
1991
- n.value = { data: f, error: null, isFetching: !1 };
2027
+ const f = c.trim().toLowerCase(), d = s.get(f);
2028
+ if (d) {
2029
+ n.value = { data: d, error: null, isFetching: !1 };
1992
2030
  return;
1993
2031
  }
1994
- s?.abort(), s = oe(o), n.value = { ...n.value, isFetching: !0 };
1995
- const c = await e.layers.predictiveSearch(u.trim(), s.signal);
1996
- c.error ? c.error._tag !== "NetworkError" || c.error.code !== "ABORTED" ? n.value = { data: null, error: c.error, isFetching: !1 } : n.value = { ...n.value, isFetching: !1 } : (i.set(g, c.data), n.value = { data: c.data, error: null, isFetching: !1 });
2032
+ i?.abort(), i = oe(o), n.value = { ...n.value, isFetching: !0 };
2033
+ const m = await e.layers.predictiveSearch(c.trim(), i.signal);
2034
+ m.error ? m.error._tag !== "NetworkError" || m.error.code !== "ABORTED" ? n.value = { data: null, error: m.error, isFetching: !1 } : n.value = { ...n.value, isFetching: !1 } : (s.set(f, m.data), n.value = { data: m.data, error: null, isFetching: !1 });
1997
2035
  }, r);
1998
- return { state: n, execute: (u) => l.call(u), dispose: a };
2036
+ return { state: n, execute: (c) => u.call(c), dispose: a };
1999
2037
  };
2000
2038
  }
2001
2039
  function Yt({
@@ -2006,8 +2044,8 @@ function Yt({
2006
2044
  ids: r,
2007
2045
  meta: o,
2008
2046
  collectionMetafields: n = e.config.collectionMetafields,
2009
- pageMetafields: s = e.config.pageMetafields,
2010
- signal: i
2047
+ pageMetafields: i = e.config.pageMetafields,
2048
+ signal: s
2011
2049
  } = t, a = $({
2012
2050
  data: null,
2013
2051
  error: null,
@@ -2015,36 +2053,36 @@ function Yt({
2015
2053
  });
2016
2054
  if (r.length === 0)
2017
2055
  return a.value = { data: { products: [] }, error: null, isFetching: !1 }, a;
2018
- const l = r, { cached: u } = e.store.products.getMany(l), g = new Map(u.map((c) => [c.gid, c])), f = l.map((c) => g.get(c)).filter((c) => c != null);
2019
- return !o || !e.storefrontEnabled ? (a.value = { data: { products: f }, error: null, isFetching: !1 }, a) : (a.value = { data: null, error: null, isFetching: !0 }, (async () => {
2020
- let c, d;
2056
+ const u = r, { cached: c } = e.store.products.getMany(u), f = new Map(c.map((m) => [m.gid, m])), d = u.map((m) => f.get(m)).filter((m) => m != null);
2057
+ return !o || !e.storefrontEnabled ? (a.value = { data: { products: d }, error: null, isFetching: !1 }, a) : (a.value = { data: null, error: null, isFetching: !0 }, (async () => {
2058
+ let m, l;
2021
2059
  if (o.collection) {
2022
2060
  const h = await e.storefront.getCollection({
2023
2061
  handle: o.collection,
2024
2062
  collectionMetafields: n,
2025
2063
  includeFilters: o.includeFilters,
2026
- signal: i
2064
+ signal: s
2027
2065
  });
2028
2066
  if (h.error) {
2029
2067
  a.value = { data: null, error: h.error, isFetching: !1 };
2030
2068
  return;
2031
2069
  }
2032
- c = h.data;
2070
+ m = h.data;
2033
2071
  }
2034
2072
  if (o.page) {
2035
2073
  const h = await e.storefront.getPage({
2036
2074
  handle: o.page,
2037
- pageMetafields: s,
2038
- signal: i
2075
+ pageMetafields: i,
2076
+ signal: s
2039
2077
  });
2040
2078
  if (h.error) {
2041
2079
  a.value = { data: null, error: h.error, isFetching: !1 };
2042
2080
  return;
2043
2081
  }
2044
- d = h.data;
2082
+ l = h.data;
2045
2083
  }
2046
- const p = { products: f };
2047
- c && (p.collection = c), d && (p.page = d), a.value = { data: p, error: null, isFetching: !1 };
2084
+ const g = { products: d };
2085
+ m && (g.collection = m), l && (g.page = l), a.value = { data: g, error: null, isFetching: !1 };
2048
2086
  })(), a);
2049
2087
  };
2050
2088
  }
@@ -2076,51 +2114,51 @@ function er({
2076
2114
  const {
2077
2115
  imageId: o,
2078
2116
  page: n = Y,
2079
- limit: s = Z,
2080
- filters: i,
2117
+ limit: i = Z,
2118
+ filters: s,
2081
2119
  tuning: a,
2082
- signal: l,
2083
- dynamicLinking: u,
2084
- params: g,
2085
- paramDefinitions: f,
2086
- transformBody: c
2087
- } = r, d = $({
2120
+ signal: u,
2121
+ dynamicLinking: c,
2122
+ params: f,
2123
+ paramDefinitions: d,
2124
+ transformBody: m
2125
+ } = r, l = $({
2088
2126
  data: null,
2089
2127
  error: null,
2090
2128
  isFetching: !0
2091
2129
  });
2092
2130
  return (async () => {
2093
- const p = await e.layers.imageSearch(
2131
+ const g = await e.layers.imageSearch(
2094
2132
  {
2095
2133
  image_id: o,
2096
- pagination: { page: n, limit: s },
2097
- filter_group: t.transformFilters(i),
2134
+ pagination: { page: n, limit: i },
2135
+ filter_group: t.transformFilters(s),
2098
2136
  tuning: a,
2099
- dynamicLinking: u,
2100
- transformBody: X({ params: g, paramDefinitions: f, transformBody: c })
2137
+ dynamicLinking: c,
2138
+ transformBody: X({ params: f, paramDefinitions: d, transformBody: m })
2101
2139
  },
2102
- l
2140
+ u
2103
2141
  );
2104
- if (p.error) {
2105
- d.value = { data: null, error: p.error, isFetching: !1 };
2142
+ if (g.error) {
2143
+ l.value = { data: null, error: g.error, isFetching: !1 };
2106
2144
  return;
2107
2145
  }
2108
- const { results: h } = p.data, y = await t.fetchAndBuildProducts(h);
2146
+ const { results: h } = g.data, y = await t.fetchAndBuildProducts(h);
2109
2147
  if (y.error) {
2110
- d.value = { data: null, error: y.error, isFetching: !1 };
2148
+ l.value = { data: null, error: y.error, isFetching: !1 };
2111
2149
  return;
2112
2150
  }
2113
- const I = y.data, b = ne({
2114
- products: I,
2115
- raw: p.data,
2151
+ const _ = y.data, b = ne({
2152
+ products: _,
2153
+ raw: g.data,
2116
2154
  extender: e.config.extendSearch
2117
2155
  });
2118
- e.store.products.set(I), d.value = { data: b, error: null, isFetching: !1 };
2119
- })(), d;
2156
+ e.store.products.set(_), l.value = { data: b, error: null, isFetching: !1 };
2157
+ })(), l;
2120
2158
  };
2121
2159
  }
2122
- function yr(e) {
2123
- const t = ut({
2160
+ function _r(e) {
2161
+ const t = lt({
2124
2162
  layersPublicToken: e.layersPublicToken,
2125
2163
  layersBaseUrl: e.layersBaseUrl,
2126
2164
  sorts: e.sorts,
@@ -2128,12 +2166,12 @@ function yr(e) {
2128
2166
  attributes: e.attributes,
2129
2167
  fetch: e.fetch
2130
2168
  });
2131
- if (t.error) return m(t.error);
2169
+ if (t.error) return p(t.error);
2132
2170
  const r = t.data;
2133
2171
  let o, n = !1;
2134
2172
  if (e.enableStorefront) {
2135
2173
  if (!e.shop || !e.storefrontPublicToken)
2136
- return m(
2174
+ return p(
2137
2175
  B({
2138
2176
  code: "MISSING_CONFIG",
2139
2177
  message: "shop and storefrontPublicToken are required when enableStorefront is true",
@@ -2141,64 +2179,77 @@ function yr(e) {
2141
2179
  expected: "non-empty string"
2142
2180
  })
2143
2181
  );
2144
- const u = Et({
2182
+ const c = yt({
2145
2183
  shop: e.shop,
2146
2184
  storefrontPublicToken: e.storefrontPublicToken,
2147
2185
  storefrontApiVersion: e.storefrontApiVersion,
2148
2186
  fetch: e.fetch
2149
2187
  });
2150
- if (u.error) return m(u.error);
2151
- o = u.data, n = !0;
2188
+ if (c.error) return p(c.error);
2189
+ o = c.data, n = !0;
2152
2190
  }
2153
- const s = St({
2191
+ const i = St({
2154
2192
  maxProducts: e.cacheMaxProducts,
2155
2193
  maxQueries: e.cacheMaxEntries,
2156
- ttl: e.cacheTtl
2157
- }), i = {
2194
+ ttl: e.cacheTtl,
2195
+ storageAdapter: e.storageAdapter
2196
+ });
2197
+ if (e.restoreFromStorage !== !1 && i.restore(), e.initialData) {
2198
+ const { products: c, queries: f, collections: d } = e.initialData;
2199
+ if (c?.length && i.products.set(c), f)
2200
+ for (const [m, l] of Object.entries(f))
2201
+ i.queries.set(m, l);
2202
+ if (d)
2203
+ for (const [m, l] of Object.entries(d))
2204
+ i.collections.set(m, l);
2205
+ }
2206
+ const s = {
2158
2207
  config: e,
2159
2208
  layers: r,
2160
2209
  storefront: o,
2161
2210
  storefrontEnabled: n,
2162
- store: s,
2211
+ store: i,
2163
2212
  mergeConfig: {
2164
2213
  currencyCode: e.currencyCode,
2165
2214
  formatPrice: e.formatPrice,
2166
2215
  swatches: e.swatches
2167
2216
  }
2168
- }, a = jt({ ctx: i }), l = {
2217
+ }, a = Ht({ ctx: s }), u = {
2169
2218
  config: e,
2170
- store: s,
2171
- collection: Wt({ ctx: i, helpers: a }),
2172
- search: Kt({ ctx: i, helpers: a }),
2173
- blocks: Xt({ ctx: i, helpers: a }),
2174
- autocomplete: Jt({ ctx: i }),
2175
- storefront: Yt({ ctx: i }),
2176
- uploadImage: Zt({ ctx: i }),
2177
- imageSearch: er({ ctx: i, helpers: a })
2219
+ store: i,
2220
+ collection: Kt({ ctx: s, helpers: a }),
2221
+ search: Wt({ ctx: s, helpers: a }),
2222
+ blocks: Xt({ ctx: s, helpers: a }),
2223
+ autocomplete: Jt({ ctx: s }),
2224
+ storefront: Yt({ ctx: s }),
2225
+ uploadImage: Zt({ ctx: s }),
2226
+ imageSearch: er({ ctx: s, helpers: a })
2178
2227
  };
2179
- return xt(l), M(l);
2228
+ return xt(u), M(u);
2180
2229
  }
2181
2230
  export {
2182
2231
  Tt as and,
2183
- Ir as batch,
2184
- br as computed,
2185
- yr as createSdk,
2186
- vr as effect,
2187
- or as eq,
2188
- fr as exists,
2189
- pr as filter,
2232
+ br as batch,
2233
+ vr as computed,
2234
+ _r as createSdk,
2235
+ Fr as effect,
2236
+ sr as eq,
2237
+ gr as exists,
2238
+ hr as filter,
2190
2239
  Gt as getSdk,
2191
- cr as gt,
2192
- lr as gte,
2193
- ir as inValues,
2194
- hr as isInitialized,
2240
+ lr as gt,
2241
+ ur as gte,
2242
+ ar as inValues,
2243
+ yr as isInitialized,
2195
2244
  nr as isRetryable,
2196
2245
  rr as isSdkError,
2197
- ur as lt,
2198
- dr as lte,
2199
- sr as notEq,
2200
- gr as notExists,
2201
- ar as notIn,
2202
- mr as or,
2203
- Fr as signal
2246
+ or as jsonFileAdapter,
2247
+ It as localStorageAdapter,
2248
+ dr as lt,
2249
+ fr as lte,
2250
+ ir as notEq,
2251
+ mr as notExists,
2252
+ cr as notIn,
2253
+ pr as or,
2254
+ Mr as signal
2204
2255
  };