@commerce-blocks/sdk 2.0.0-alpha.3 → 2.0.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,59 +1,45 @@
1
- import { effect as re, signal as P, computed as O } from "@preact/signals-core";
2
- import { batch as Wt, computed as Zt, effect as en, signal as tn } from "@preact/signals-core";
3
- const Se = "2.0.0-alpha.3", Re = {
4
- version: Se
5
- }, Te = "https://app.uselayers.com/api/storefront/v1", ke = 1e3, Oe = 100, Ne = 300 * ke, oe = Re.version, K = 1, J = 24, Z = 1, ee = 1, te = 100, Ce = 20, Le = 50, Pe = 300, De = 50, ve = "USD", Me = "en-US", qe = 1e3, pe = /* @__PURE__ */ new Map();
6
- function _e(e, t) {
7
- const r = `${e}:${t}`;
8
- let n = pe.get(r);
9
- return n || (n = new Intl.NumberFormat(Me, {
10
- style: "currency",
11
- currency: t
12
- }).format(e), pe.set(r, n)), n;
13
- }
14
- function L(e) {
1
+ import { effect as se, signal as q, computed as O } from "@preact/signals-core";
2
+ import { batch as tr, computed as rr, effect as nr, signal as or } from "@preact/signals-core";
3
+ const Te = "2.0.0", Ce = {
4
+ version: Te
5
+ }, ke = "https://app.uselayers.com/api/storefront/v1", Oe = 1e3, Ne = 100, Pe = 300 * Oe, ie = Ce.version, K = 1, X = 24, re = 1, ne = 1, oe = 100, Le = 20, qe = 50, De = 300, Fe = 50, Ue = 1e3;
6
+ function N(e) {
15
7
  return { data: e };
16
8
  }
17
- function b(e) {
9
+ function h(e) {
18
10
  return { error: e };
19
11
  }
20
- const Ue = ["TIMEOUT", "CONNECTION_FAILED", "DNS_FAILED"];
21
- function ae(e) {
22
- const t = Ue.includes(e.code);
12
+ function Q(e) {
23
13
  return {
24
14
  _tag: "NetworkError",
25
15
  code: e.code,
26
16
  message: e.message,
27
- cause: e.cause,
28
- retryable: t,
29
- retryAfterMs: t ? 1e3 : void 0
17
+ cause: e.cause
30
18
  };
31
19
  }
32
- function Fe(e) {
20
+ function Me(e) {
33
21
  if (!e) return;
34
22
  const t = e["retry-after"] ?? e["Retry-After"];
35
23
  if (!t) return;
36
24
  const r = t.trim();
37
25
  if (/^\d+$/.test(r))
38
26
  return Number(r) * 1e3;
39
- const n = new Date(t);
40
- if (!isNaN(n.getTime()))
41
- return Math.max(0, n.getTime() - Date.now());
27
+ const o = new Date(t);
28
+ if (!isNaN(o.getTime()))
29
+ return Math.max(0, o.getTime() - Date.now());
42
30
  }
43
- function be(e) {
44
- const t = e.code === "RATE_LIMITED" || e.code === "SERVICE_UNAVAILABLE" || e.code === "NOT_READY" || e.status !== void 0 && e.status >= 500, r = e.retryAfterMs ?? Fe(e.responseHeaders) ?? (t ? 1e3 : void 0);
31
+ function Ee(e) {
45
32
  return {
46
33
  _tag: "ApiError",
47
34
  code: e.code,
48
35
  source: e.source,
49
36
  message: e.message,
50
37
  status: e.status,
51
- retryable: t,
52
- retryAfterMs: r,
38
+ retryAfterMs: e.retryAfterMs ?? Me(e.responseHeaders),
53
39
  cause: e.cause
54
40
  };
55
41
  }
56
- function x(e) {
42
+ function B(e) {
57
43
  return {
58
44
  _tag: "ValidationError",
59
45
  code: "VALIDATION_FAILED",
@@ -63,15 +49,15 @@ function x(e) {
63
49
  input: e.input
64
50
  };
65
51
  }
66
- function F(e, t, r, n) {
52
+ function M(e, t, r, o) {
67
53
  return {
68
54
  field: e,
69
55
  code: t,
70
56
  message: r,
71
- ...n
57
+ ...o
72
58
  };
73
59
  }
74
- function Q(e) {
60
+ function z(e) {
75
61
  return {
76
62
  _tag: "ConfigError",
77
63
  code: e.code,
@@ -82,64 +68,61 @@ function Q(e) {
82
68
  };
83
69
  }
84
70
  const $e = /* @__PURE__ */ new Set(["NetworkError", "ApiError", "ValidationError", "ConfigError"]);
85
- function Ct(e) {
71
+ function Lt(e) {
86
72
  return typeof e == "object" && e !== null && $e.has(e._tag ?? "");
87
73
  }
88
- function Ve(e) {
89
- return "retryable" in e ? e.retryable : !1;
74
+ function qt(e) {
75
+ return e._tag === "NetworkError" ? e.code === "TIMEOUT" || e.code === "CONNECTION_FAILED" || e.code === "DNS_FAILED" : e._tag === "ApiError" ? e.code === "RATE_LIMITED" || e.code === "SERVICE_UNAVAILABLE" || e.code === "NOT_READY" || e.status !== void 0 && e.status >= 500 : !1;
90
76
  }
91
- function Be(e) {
92
- if ("retryAfterMs" in e) return e.retryAfterMs;
93
- }
94
- const xe = {
77
+ const Ve = {
95
78
  401: "UNAUTHORIZED",
96
79
  403: "FORBIDDEN",
97
80
  404: "NOT_FOUND",
98
81
  425: "NOT_READY",
99
82
  429: "RATE_LIMITED"
100
83
  };
101
- function Ge(e, t) {
102
- const { status: r } = e, n = xe[r] ?? (r >= 500 ? "SERVICE_UNAVAILABLE" : "UNKNOWN");
103
- let a;
84
+ function Be(e, t) {
85
+ const { status: r } = e, o = Ve[r] ?? (r >= 500 ? "SERVICE_UNAVAILABLE" : "UNKNOWN");
86
+ let i;
104
87
  try {
105
- const o = JSON.parse(t);
106
- typeof o.retry_after_ms == "number" && (a = o.retry_after_ms);
88
+ const n = JSON.parse(t);
89
+ typeof n.retry_after_ms == "number" && (i = n.retry_after_ms);
107
90
  } catch {
108
91
  }
109
- return be({
110
- code: n,
92
+ return Ee({
93
+ code: o,
111
94
  source: "layers",
112
95
  message: t || `HTTP ${r}`,
113
96
  status: r,
114
- retryAfterMs: a,
97
+ retryAfterMs: i,
115
98
  responseHeaders: Object.fromEntries(e.headers.entries())
116
99
  });
117
100
  }
118
- function He(e) {
101
+ function Ge(e) {
119
102
  if (e instanceof Error && (e.name === "AbortError" || e.name === "TimeoutError")) {
120
103
  const t = e.name === "TimeoutError" || e.message.includes("timeout");
121
- return ae({
104
+ return Q({
122
105
  code: t ? "TIMEOUT" : "ABORTED",
123
106
  message: t ? "Request timed out" : "Request was aborted",
124
107
  cause: e
125
108
  });
126
109
  }
127
- return ae({
110
+ return Q({
128
111
  code: "CONNECTION_FAILED",
129
112
  message: e instanceof Error ? e.message : "Network request failed",
130
113
  cause: e
131
114
  });
132
115
  }
133
- async function je(e) {
116
+ async function xe(e) {
134
117
  if (!e.ok) {
135
118
  const t = await e.text().catch(() => "");
136
- return b(Ge(e, t));
119
+ return h(Be(e, t));
137
120
  }
138
121
  try {
139
- return L(await e.json());
122
+ return N(await e.json());
140
123
  } catch (t) {
141
- return b(
142
- be({
124
+ return h(
125
+ Ee({
143
126
  code: "PARSE_ERROR",
144
127
  source: "layers",
145
128
  message: "Invalid JSON response",
@@ -148,95 +131,94 @@ async function je(e) {
148
131
  );
149
132
  }
150
133
  }
151
- function ie({
134
+ function le({
152
135
  token: e,
153
136
  json: t = !0
154
137
  }) {
155
138
  const r = {
156
139
  Accept: "application/json",
157
140
  "X-Storefront-Access-Token": e,
158
- "X-SDK-Client": `commerce-blocks-sdk/${oe}`
141
+ "X-SDK-Client": `commerce-blocks-sdk/${ie}`
159
142
  };
160
143
  return t && (r["Content-Type"] = "application/json"), r;
161
144
  }
162
- function ce({ config: e, endpoint: t }) {
163
- const { baseUrl: r = Te } = e;
145
+ function de({ config: e, endpoint: t }) {
146
+ const { baseUrl: r = ke } = e;
164
147
  return `${r}${t}`;
165
148
  }
166
- function ue(e) {
149
+ function fe(e) {
167
150
  return e.fetch ?? ((t, r) => fetch(t, r));
168
151
  }
169
- async function le(e, t, r) {
152
+ async function me(e, t, r) {
170
153
  try {
171
- const n = await e(t, r);
172
- return je(n);
173
- } catch (n) {
174
- return b(He(n));
154
+ const o = await e(t, r);
155
+ return xe(o);
156
+ } catch (o) {
157
+ return h(Ge(o));
175
158
  }
176
159
  }
177
- async function B(e) {
178
- return le(ue(e.config), ce(e), {
160
+ async function V(e) {
161
+ return me(fe(e.config), de(e), {
179
162
  method: "POST",
180
- headers: ie({ token: e.config.token }),
163
+ headers: le({ token: e.config.token }),
181
164
  body: JSON.stringify(e.body),
182
165
  signal: e.signal
183
166
  });
184
167
  }
185
- async function Qe(e) {
168
+ async function je(e) {
186
169
  const t = new URLSearchParams();
187
- for (const [a, o] of Object.entries(e.params))
188
- o != null && t.append(a, typeof o == "object" ? JSON.stringify(o) : String(o));
189
- const r = t.toString(), n = r ? `${e.endpoint}?${r}` : e.endpoint;
190
- return le(
191
- ue(e.config),
192
- ce({ config: e.config, endpoint: n }),
170
+ for (const [i, n] of Object.entries(e.params))
171
+ n != null && t.append(i, typeof n == "object" ? JSON.stringify(n) : String(n));
172
+ const r = t.toString(), o = r ? `${e.endpoint}?${r}` : e.endpoint;
173
+ return me(
174
+ fe(e.config),
175
+ de({ config: e.config, endpoint: o }),
193
176
  {
194
177
  method: "GET",
195
- headers: ie({ token: e.config.token }),
178
+ headers: le({ token: e.config.token }),
196
179
  signal: e.signal
197
180
  }
198
181
  );
199
182
  }
200
- async function Ke(e) {
201
- return le(ue(e.config), ce(e), {
183
+ async function He(e) {
184
+ return me(fe(e.config), de(e), {
202
185
  method: "POST",
203
- headers: ie({ token: e.config.token, json: !1 }),
186
+ headers: le({ token: e.config.token, json: !1 }),
204
187
  body: e.formData,
205
188
  signal: e.signal
206
189
  });
207
190
  }
208
191
  function U(e, t, r) {
209
- return r ? null : x({
192
+ return r ? null : B({
210
193
  operation: e,
211
- fields: [F(t, "REQUIRED_FIELD", `${t} is required`)]
194
+ fields: [M(t, "REQUIRED_FIELD", `${t} is required`)]
212
195
  });
213
196
  }
214
- function j(e, t) {
197
+ function H(e, t) {
215
198
  if (!e) return null;
216
199
  const r = [];
217
- return e.page !== void 0 && e.page < Z && r.push(
218
- F("page", "OUT_OF_RANGE", `page must be >= ${Z}`, {
200
+ return e.page !== void 0 && e.page < re && r.push(
201
+ M("page", "OUT_OF_RANGE", `page must be >= ${re}`, {
219
202
  value: e.page,
220
- constraints: { min: Z }
203
+ constraints: { min: re }
221
204
  })
222
- ), e.limit !== void 0 && (e.limit < ee || e.limit > te) && r.push(
223
- F(
205
+ ), e.limit !== void 0 && (e.limit < ne || e.limit > oe) && r.push(
206
+ M(
224
207
  "limit",
225
208
  "OUT_OF_RANGE",
226
- `limit must be between ${ee} and ${te}`,
209
+ `limit must be between ${ne} and ${oe}`,
227
210
  {
228
211
  value: e.limit,
229
- constraints: { min: ee, max: te }
212
+ constraints: { min: ne, max: oe }
230
213
  }
231
214
  )
232
- ), r.length > 0 ? x({ operation: t, fields: r }) : null;
215
+ ), r.length > 0 ? B({ operation: t, fields: r }) : null;
233
216
  }
234
- const Je = [
217
+ const Qe = [
235
218
  "title",
236
219
  "handle",
237
220
  "available",
238
221
  "images",
239
- "options",
240
222
  "options_v2",
241
223
  "variants",
242
224
  "first_or_matched_variant",
@@ -251,10 +233,10 @@ const Je = [
251
233
  "combined_listing_parent_product_id",
252
234
  "combined_listing_role"
253
235
  ];
254
- function Ye(e) {
236
+ function Je(e) {
255
237
  if (!e.token)
256
- return b(
257
- Q({
238
+ return h(
239
+ z({
258
240
  code: "MISSING_CONFIG",
259
241
  message: "token is required",
260
242
  field: "token",
@@ -262,136 +244,150 @@ function Ye(e) {
262
244
  })
263
245
  );
264
246
  if (!e.sorts || e.sorts.length === 0)
265
- return b(
266
- Q({
247
+ return h(
248
+ z({
267
249
  code: "MISSING_CONFIG",
268
250
  message: "At least one sort option is required",
269
251
  field: "sorts",
270
252
  expected: "non-empty array of Sort"
271
253
  })
272
254
  );
273
- function t(o) {
274
- return [.../* @__PURE__ */ new Set([...Je, ...e.attributes ?? [], ...o ?? []])];
255
+ function t(n) {
256
+ return [.../* @__PURE__ */ new Set([...Qe, ...e.attributes ?? [], ...n ?? []])];
275
257
  }
276
258
  function r({
277
- attributes: o,
259
+ attributes: n,
278
260
  transformBody: s,
279
261
  rest: u,
280
262
  includeFacets: c = !0
281
263
  }) {
282
264
  let l = {
283
- attributes: t(o),
265
+ attributes: t(n),
284
266
  ...u
285
267
  };
286
- return c && (l.facets = e.facets.map((i) => i.code), l.retrieveFacetCount = !0, l.includeFacetRanges = !0), s && (l = s(l)), l;
268
+ return c && (l.facets = e.facets.map((a) => a.code), l.retrieveFacetCount = !0, l.includeFacetRanges = !0), s && (l = s(l)), l;
287
269
  }
288
- const n = {
270
+ const o = {
289
271
  token: e.token,
290
272
  baseUrl: e.baseUrl,
291
273
  fetch: e.fetch
292
274
  };
293
- return L({
294
- browse: async (o, s) => {
295
- const u = U("browse", "collectionHandle", o.collectionHandle);
296
- if (u) return b(u);
297
- const c = U("browse", "sort_order_code", o.sort_order_code);
298
- if (c) return b(c);
299
- const l = j(o.pagination, "browse");
300
- if (l) return b(l);
301
- const { collectionHandle: i, attributes: f, transformBody: g, ...p } = o;
302
- return B({
303
- config: n,
304
- endpoint: `/browse/${i}`,
305
- body: r({ attributes: f, transformBody: g, rest: p }),
275
+ return N({
276
+ browse: async (n, s) => {
277
+ const u = U("browse", "collectionHandle", n.collectionHandle);
278
+ if (u) return h(u);
279
+ const c = U("browse", "sort_order_code", n.sort_order_code);
280
+ if (c) return h(c);
281
+ const l = H(n.pagination, "browse");
282
+ if (l) return h(l);
283
+ const { collectionHandle: a, attributes: d, transformBody: m, ...g } = n;
284
+ return V({
285
+ config: o,
286
+ endpoint: `/browse/${a}`,
287
+ body: r({ attributes: d, transformBody: m, rest: g }),
306
288
  signal: s
307
289
  });
308
290
  },
309
- predictiveSearch: async (o, s) => {
310
- const u = U("predictiveSearch", "query", o);
311
- return u ? b(u) : Qe({
312
- config: n,
291
+ predictiveSearch: async (n, s) => {
292
+ const u = U("predictiveSearch", "query", n);
293
+ return u ? h(u) : je({
294
+ config: o,
313
295
  endpoint: "/search/complete",
314
- params: { query: o },
296
+ params: { query: n },
315
297
  signal: s
316
298
  });
317
299
  },
318
- prepareSearch: async (o, s) => {
319
- const u = U("prepareSearch", "query", o.query);
320
- if (u) return b(u);
321
- const { query: c, transformBody: l, ...i } = o;
322
- let f = { ...i };
323
- return l && (f = l(f)), B({
324
- config: n,
300
+ prepareSearch: async (n, s) => {
301
+ const u = U("prepareSearch", "query", n.query);
302
+ if (u) return h(u);
303
+ const { query: c, transformBody: l, ...a } = n;
304
+ let d = { ...a };
305
+ return l && (d = l(d)), V({
306
+ config: o,
325
307
  endpoint: `/search/${encodeURIComponent(c)}/prepare`,
326
- body: f,
308
+ body: d,
327
309
  signal: s
328
310
  });
329
311
  },
330
- search: async (o, s) => {
331
- const u = U("search", "query", o.query);
332
- if (u) return b(u);
333
- const c = j(o.pagination, "search");
334
- if (c) return b(c);
335
- const { query: l, attributes: i, transformBody: f, ...g } = o;
336
- return B({
337
- config: n,
312
+ search: async (n, s) => {
313
+ const u = U("search", "query", n.query);
314
+ if (u) return h(u);
315
+ const c = H(n.pagination, "search");
316
+ if (c) return h(c);
317
+ const { query: l, attributes: a, transformBody: d, ...m } = n;
318
+ return V({
319
+ config: o,
338
320
  endpoint: `/search/${encodeURIComponent(l)}/execute`,
339
- body: r({ attributes: i, transformBody: f, rest: g }),
321
+ body: r({ attributes: a, transformBody: d, rest: m }),
340
322
  signal: s
341
323
  });
342
324
  },
343
- imageSearch: async (o, s) => {
344
- if (!o.image_data && !o.image_id)
345
- return b(
346
- x({
325
+ imageSearch: async (n, s) => {
326
+ if (!n.image_data && !n.image_id)
327
+ return h(
328
+ B({
347
329
  operation: "imageSearch",
348
330
  fields: [
349
- F("image_data", "REQUIRED_FIELD", "image_data or image_id is required")
331
+ M("image_data", "REQUIRED_FIELD", "image_data or image_id is required")
350
332
  ]
351
333
  })
352
334
  );
353
- const u = j(o.pagination, "imageSearch");
354
- if (u) return b(u);
355
- const { attributes: c, transformBody: l, ...i } = o;
356
- return B({
357
- config: n,
335
+ const u = H(n.pagination, "imageSearch");
336
+ if (u) return h(u);
337
+ const { attributes: c, transformBody: l, ...a } = n;
338
+ return V({
339
+ config: o,
358
340
  endpoint: "/search/image",
359
- body: r({ attributes: c, transformBody: l, rest: i, includeFacets: !1 }),
341
+ body: r({ attributes: c, transformBody: l, rest: a, includeFacets: !1 }),
360
342
  signal: s
361
343
  });
362
344
  },
363
- uploadImage: async (o, s) => {
345
+ uploadImage: async (n, s) => {
364
346
  const u = new FormData();
365
- return u.append("image", o), Ke({
366
- config: n,
347
+ return u.append("image", n), He({
348
+ config: o,
367
349
  endpoint: "/images/upload",
368
350
  formData: u,
369
351
  signal: s
370
352
  });
371
353
  },
372
- blocks: async (o, s) => {
373
- const u = U("block", "blockId", o.blockId);
374
- if (u) return b(u);
375
- const c = j(o.pagination, "block");
376
- if (c) return b(c);
377
- const { blockId: l, attributes: i, transformBody: f, ...g } = o;
378
- return B({
379
- config: n,
354
+ blocks: async (n, s) => {
355
+ const u = U("block", "blockId", n.blockId);
356
+ if (u) return h(u);
357
+ const c = H(n.pagination, "block");
358
+ if (c) return h(c);
359
+ const { blockId: l, attributes: a, transformBody: d, ...m } = n;
360
+ return V({
361
+ config: o,
380
362
  endpoint: `/blocks/${l}/products`,
381
- body: r({ attributes: i, transformBody: f, rest: g }),
363
+ body: r({ attributes: a, transformBody: d, rest: m }),
364
+ signal: s
365
+ });
366
+ },
367
+ searchContent: async (n, s) => {
368
+ const u = U("searchContent", "query", n.query);
369
+ if (u) return h(u);
370
+ const c = H(n.pagination, "searchContent");
371
+ if (c) return h(c);
372
+ const { query: l, transformBody: a, ...d } = n;
373
+ let m = { ...d };
374
+ return a && (m = a(m)), V({
375
+ config: o,
376
+ endpoint: `/search/content/${encodeURIComponent(l)}/execute`,
377
+ body: m,
382
378
  signal: s
383
379
  });
384
380
  }
385
381
  });
386
382
  }
387
- function ze(e) {
383
+ function Ke(e) {
388
384
  return typeof window > "u" || !window.localStorage ? null : {
389
385
  read: () => window.localStorage.getItem(e),
390
386
  write: (t) => window.localStorage.setItem(e, t),
391
387
  remove: () => window.localStorage.removeItem(e)
392
388
  };
393
389
  }
394
- function Lt(e, t) {
390
+ function Dt(e, t) {
395
391
  return {
396
392
  read() {
397
393
  try {
@@ -415,58 +411,58 @@ function Lt(e, t) {
415
411
  };
416
412
  }
417
413
  const Xe = "cb-sdk-store";
418
- function We(e, t) {
414
+ function Ye(e, t) {
419
415
  if (e.size <= t) return;
420
- const n = [...e.entries()].sort((a, o) => a[1].timestamp - o[1].timestamp).slice(0, e.size - t);
421
- for (const [a] of n)
422
- e.delete(a);
416
+ const o = [...e.entries()].sort((i, n) => i[1].timestamp - n[1].timestamp).slice(0, e.size - t);
417
+ for (const [i] of o)
418
+ e.delete(i);
423
419
  }
424
- function Ze(e) {
425
- typeof requestIdleCallback == "function" ? requestIdleCallback(e, { timeout: qe }) : setTimeout(e, 0);
420
+ function ze(e) {
421
+ typeof requestIdleCallback == "function" ? requestIdleCallback(e, { timeout: Ue }) : setTimeout(e, 0);
426
422
  }
427
- function et(e = {}) {
423
+ function We(e = {}) {
428
424
  const {
429
- ttl: t = Ne,
430
- maxEntries: r = Oe,
431
- storageKey: n = Xe,
432
- storageAdapter: a
433
- } = e, o = /* @__PURE__ */ new Map(), s = a ?? ze(n);
425
+ ttl: t = Pe,
426
+ maxEntries: r = Ne,
427
+ storageKey: o = Xe,
428
+ storageAdapter: i
429
+ } = e, n = /* @__PURE__ */ new Map(), s = i ?? Ke(o);
434
430
  let u = 0;
435
- function c(i) {
436
- return Date.now() - i > t;
431
+ function c(a) {
432
+ return Date.now() - a > t;
437
433
  }
438
434
  function l() {
439
435
  if (!s) return;
440
- const i = ++u;
441
- Ze(() => {
442
- if (i === u)
436
+ const a = ++u;
437
+ ze(() => {
438
+ if (a === u)
443
439
  try {
444
- const f = [];
445
- for (const [p, v] of o)
446
- c(v.timestamp) || f.push([p, v]);
447
- const g = {
448
- queries: f.slice(0, r),
449
- version: oe
440
+ const d = [];
441
+ for (const [g, v] of n)
442
+ c(v.timestamp) || d.push([g, v]);
443
+ const m = {
444
+ queries: d.slice(0, r),
445
+ version: ie
450
446
  };
451
- s.write(JSON.stringify(g));
447
+ s.write(JSON.stringify(m));
452
448
  } catch {
453
449
  }
454
450
  });
455
451
  }
456
452
  return {
457
- get(i) {
458
- return o.get(i) ?? null;
453
+ get(a) {
454
+ return n.get(a) ?? null;
459
455
  },
460
- set(i, f) {
461
- o.set(i, { data: f, timestamp: Date.now() }), We(o, r), l();
456
+ set(a, d) {
457
+ n.set(a, { data: d, timestamp: Date.now() }), Ye(n, r), l();
462
458
  },
463
- isExpired(i) {
464
- const f = o.get(i);
465
- return f ? c(f.timestamp) : !0;
459
+ isExpired(a) {
460
+ const d = n.get(a);
461
+ return d ? c(d.timestamp) : !0;
466
462
  },
467
- invalidate(i) {
468
- for (const f of o.keys())
469
- f.includes(i) && o.delete(f);
463
+ invalidate(a) {
464
+ for (const d of n.keys())
465
+ d.includes(a) && n.delete(d);
470
466
  },
471
467
  persist() {
472
468
  l();
@@ -474,74 +470,79 @@ function et(e = {}) {
474
470
  restore() {
475
471
  if (s)
476
472
  try {
477
- const i = s.read();
478
- if (!i) return;
479
- const f = JSON.parse(i);
480
- if (f.version !== oe) {
473
+ const a = s.read();
474
+ if (!a) return;
475
+ const d = JSON.parse(a);
476
+ if (d.version !== ie) {
481
477
  s.remove();
482
478
  return;
483
479
  }
484
- if (!Array.isArray(f.queries)) {
480
+ if (!Array.isArray(d.queries)) {
485
481
  s.remove();
486
482
  return;
487
483
  }
488
- for (const [g, p] of f.queries)
489
- c(p.timestamp) || o.set(g, p);
484
+ for (const [m, g] of d.queries)
485
+ c(g.timestamp) || n.set(m, g);
490
486
  } catch {
491
487
  s.remove();
492
488
  }
493
489
  },
494
490
  clear() {
495
- o.clear(), u++, s?.remove();
491
+ n.clear(), u++, s?.remove();
496
492
  },
497
493
  get stats() {
498
- return { entries: o.size };
494
+ return { entries: n.size };
499
495
  }
500
496
  };
501
497
  }
502
- function de({
498
+ function ce(e) {
499
+ return e === null || typeof e != "object" ? JSON.stringify(e) : Array.isArray(e) ? `[${e.map(ce).join(",")}]` : `{${Object.keys(e).sort().map(
500
+ (o) => `${JSON.stringify(o)}:${ce(e[o])}`
501
+ ).join(",")}}`;
502
+ }
503
+ function W({
503
504
  prefix: e,
504
505
  id: t,
505
506
  params: r = {}
506
507
  }) {
507
508
  if (!t?.trim()) return;
508
- const n = `${e}/${encodeURIComponent(t)}`, a = Object.entries(r).filter(([o, s]) => s != null && o !== "signal").sort(([o], [s]) => o.localeCompare(s)).map(
509
- ([o, s]) => `${encodeURIComponent(o)}=${encodeURIComponent(typeof s == "object" ? JSON.stringify(s) : String(s))}`
509
+ const o = `${e}/${encodeURIComponent(t)}`, i = Object.entries(r).filter(([n, s]) => s != null && n !== "signal").sort(([n], [s]) => n.localeCompare(s)).map(
510
+ ([n, s]) => `${encodeURIComponent(n)}=${encodeURIComponent(typeof s == "object" ? ce(s) : String(s))}`
510
511
  ).join("&");
511
- return a ? `${n}?${a}` : n;
512
+ return i ? `${o}?${i}` : o;
512
513
  }
513
- function ne() {
514
- return b(ae({ code: "ABORTED", message: "Request aborted" }));
514
+ function ae() {
515
+ return h(Q({ code: "ABORTED", message: "Request aborted" }));
515
516
  }
516
- function tt() {
517
+ function Ze() {
517
518
  const e = /* @__PURE__ */ new Map();
518
519
  return {
519
520
  async resolve(t) {
520
- const { key: r, cache: n, signal: a, onFetch: o, fn: s } = t;
521
+ const { key: r, cache: o, signal: i, onFetch: n, fn: s } = t;
521
522
  if (!r)
522
- return o?.(), s(a);
523
- const u = n.get(r);
524
- if (u && !n.isExpired(r))
523
+ return n?.(), s(i);
524
+ const u = o.get(r);
525
+ if (u && !o.isExpired(r))
525
526
  return { data: u.data };
526
- if (a.aborted) return ne();
527
+ if (i.aborted) return ae();
527
528
  const c = e.get(r);
528
529
  if (c) {
529
- c.consumers++, o?.();
530
- const p = () => {
530
+ c.consumers++, n?.();
531
+ const g = () => {
531
532
  c.consumers--, c.consumers <= 0 && (c.controller.abort(), e.delete(r));
532
533
  };
533
- a.addEventListener("abort", p, { once: !0 });
534
+ i.addEventListener("abort", g, { once: !0 });
534
535
  const v = await c.promise;
535
- return a.removeEventListener("abort", p), a.aborted ? ne() : v;
536
+ return i.removeEventListener("abort", g), i.aborted ? ae() : v;
536
537
  }
537
- const l = new AbortController(), i = { promise: null, controller: l, consumers: 1 }, f = () => {
538
- i.consumers--, i.consumers <= 0 && (l.abort(), e.delete(r));
538
+ const l = new AbortController(), a = { promise: null, controller: l, consumers: 1 }, d = () => {
539
+ a.consumers--, a.consumers <= 0 && (l.abort(), e.delete(r));
539
540
  };
540
- a.addEventListener("abort", f, { once: !0 }), o?.(), i.promise = s(l.signal).finally(() => {
541
+ i.addEventListener("abort", d, { once: !0 }), n?.(), e.set(r, a), a.promise = s(l.signal).finally(() => {
541
542
  e.delete(r);
542
- }), e.set(r, i);
543
- const g = await i.promise;
544
- return a.removeEventListener("abort", f), a.aborted ? ne() : g;
543
+ });
544
+ const m = await a.promise;
545
+ return i.removeEventListener("abort", d), i.aborted ? ae() : m;
545
546
  },
546
547
  clear() {
547
548
  for (const t of e.values())
@@ -550,131 +551,152 @@ function tt() {
550
551
  }
551
552
  };
552
553
  }
553
- var se = /* @__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))(se || {}), ye = /* @__PURE__ */ ((e) => (e.And = "AND", e.Or = "OR", e))(ye || {});
554
- function Pt(e, t) {
554
+ var ue = /* @__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))(ue || {}), we = /* @__PURE__ */ ((e) => (e.And = "AND", e.Or = "OR", e))(we || {});
555
+ function Ft(e, t) {
555
556
  return { property: e, operator: "eq", values: [t] };
556
557
  }
557
- function Dt(e, t) {
558
+ function Ut(e, t) {
558
559
  return { property: e, operator: "not_eq", values: [t] };
559
560
  }
560
561
  function Mt(e, t) {
561
562
  return { property: e, operator: "in", values: t };
562
563
  }
563
- function qt(e, t) {
564
+ function $t(e, t) {
564
565
  return { property: e, operator: "not_in", values: t };
565
566
  }
566
- function Ut(e, t) {
567
+ function Vt(e, t) {
567
568
  return { property: e, operator: "gt", values: [t] };
568
569
  }
569
- function Ft(e, t) {
570
+ function Bt(e, t) {
570
571
  return { property: e, operator: "gte", values: [t] };
571
572
  }
572
- function $t(e, t) {
573
+ function Gt(e, t) {
573
574
  return { property: e, operator: "lt", values: [t] };
574
575
  }
575
- function Vt(e, t) {
576
+ function xt(e, t) {
576
577
  return { property: e, operator: "lte", values: [t] };
577
578
  }
578
- function Bt(e) {
579
+ function jt(e) {
579
580
  return { property: e, operator: "exists", values: [] };
580
581
  }
581
- function xt(e) {
582
+ function Ht(e) {
582
583
  return { property: e, operator: "not_exists", values: [] };
583
584
  }
584
- function nt(...e) {
585
+ function et(...e) {
585
586
  return { conditional: "AND", expressions: e };
586
587
  }
587
- function Gt(...e) {
588
+ function Qt(...e) {
588
589
  return { conditional: "OR", expressions: e };
589
590
  }
590
- function rt(e) {
591
+ function tt(e) {
591
592
  return "conditional" in e;
592
593
  }
593
- function Ht(e) {
594
- return rt(e) ? e : nt(e);
594
+ function Jt(e) {
595
+ return tt(e) ? e : et(e);
595
596
  }
596
- function Ee(e, t) {
597
+ function Ie(e, t) {
597
598
  return `gid://shopify/${e}/${t}`;
598
599
  }
599
- function ot(e) {
600
- return Ee("Product", e);
600
+ function rt(e) {
601
+ return Ie("Product", e);
601
602
  }
602
- function at(e) {
603
- return Ee("ProductVariant", e);
603
+ function nt(e) {
604
+ return Ie("ProductVariant", e);
604
605
  }
605
- const he = (e) => encodeURIComponent(e).replace(/-/g, "%2D");
606
- function we({
606
+ const _e = (e) => encodeURIComponent(e).replace(/-/g, "%2D");
607
+ function Ae({
607
608
  type: e,
608
609
  selectedOptions: t
609
610
  }) {
610
611
  if (t.length === 0)
611
612
  return `${e}-`;
612
- const r = t.map(({ name: n, value: a }) => `${he(n)}:${he(a)}`).join("-");
613
+ const r = t.map(({ name: o, value: i }) => `${_e(o)}:${_e(i)}`).join("-");
613
614
  return `${e}-${r}`;
614
615
  }
615
- function Ie(e) {
616
+ function Se(e) {
616
617
  return e.product_id ?? e.id;
617
618
  }
618
- function st(e) {
619
- return ot(Ie(e));
619
+ function ot(e) {
620
+ return rt(Se(e));
621
+ }
622
+ const ge = "USD", at = "en-US";
623
+ function G(e, t, r) {
624
+ return { amount: e, currencyCode: t, formatted: r(e, t) };
625
+ }
626
+ const be = /* @__PURE__ */ new Map();
627
+ function pe(e, t) {
628
+ const r = `${e}:${t}`;
629
+ let o = be.get(r);
630
+ return o || (o = new Intl.NumberFormat(at, {
631
+ style: "currency",
632
+ currency: t
633
+ }).format(e), be.set(r, o)), o;
634
+ }
635
+ function st(e, t, r) {
636
+ const o = e?.["variants.price"];
637
+ if (o)
638
+ return {
639
+ min: G(o.min, t, r),
640
+ max: G(o.max, t, r)
641
+ };
620
642
  }
621
643
  function it({
622
644
  layers: e,
623
- currencyCode: t = ve,
624
- formatPrice: r = _e,
625
- swatches: n = [],
626
- breakoutContext: a
645
+ currencyCode: t = ge,
646
+ formatPrice: r = pe,
647
+ swatches: o = [],
648
+ breakoutContext: i
627
649
  }) {
628
- const o = Ie(e), s = st(e), u = e.title, c = e.handle, l = e.vendor ?? "", i = e.product_type ?? "", f = e.available, g = e.tags, p = ct(e), v = ut(e.price_range, t, r), I = dt(e, n), y = mt(e, t, r), R = y.map((h) => h.compareAtPrice).filter((h) => h !== null), T = R.length > 0 ? {
629
- min: R.reduce((h, A) => h.amount < A.amount ? h : A),
630
- max: R.reduce((h, A) => h.amount > A.amount ? h : A)
631
- } : void 0, N = e.first_or_matched_variant ? ft(e.first_or_matched_variant) : [], w = we({ type: "Product", selectedOptions: N }), k = e.metafields, d = e.calculated, m = e.category ? {
650
+ const n = Se(e), s = ot(e), u = e.title, c = e.handle, l = e.vendor ?? "", a = e.product_type ?? "", d = e.available, m = e.tags, g = ct(e), v = ut(e.price_range, t, r), I = lt(e, o), _ = ft(e, t, r), R = _.map((y) => y.compareAtPrice).filter((y) => y !== null), T = R.length > 0 ? {
651
+ min: R.reduce((y, S) => y.amount < S.amount ? y : S),
652
+ max: R.reduce((y, S) => y.amount > S.amount ? y : S)
653
+ } : null, k = e.first_or_matched_variant ? dt(e.first_or_matched_variant) : [], b = Ae({ type: "Product", selectedOptions: k }), A = e.metafields, f = e.calculated, p = e.category ? {
632
654
  id: e.category.id,
633
655
  name: e.category.name,
634
656
  fullName: e.category.full_name,
635
657
  isLeaf: e.category.is_leaf,
636
658
  isRoot: e.category.is_root
637
- } : null, E = e.featured_media ? {
659
+ } : null, w = e.featured_media ? {
638
660
  mediaContentType: e.featured_media.media_type ?? null,
639
661
  url: e.featured_media.src,
640
662
  alt: e.featured_media.alt ?? "",
641
663
  width: e.featured_media.width,
642
664
  height: e.featured_media.height
643
- } : null, _ = e.first_or_matched_variant ? y.find((h) => h.numericId === e.first_or_matched_variant.id) ?? null : null;
644
- let S = [], C = null;
645
- if (a?.isVariantTile) {
646
- C = a.variantId;
647
- const h = y.find((A) => A.numericId === C);
648
- if (h) {
649
- const A = new Set(a.optionCodes);
650
- S = h.selectedOptions.filter((V) => A.has(V.name));
665
+ } : null, E = e.first_or_matched_variant ? _.find((y) => y.numericId === e.first_or_matched_variant.id) ?? null : null;
666
+ let C = [], P = null;
667
+ if (i?.isVariantTile) {
668
+ P = i.variantId;
669
+ const y = _.find((S) => S.numericId === P);
670
+ if (y) {
671
+ const S = new Set(i.optionCodes);
672
+ C = y.selectedOptions.filter((j) => S.has(j.name));
651
673
  }
652
674
  }
653
675
  return {
654
- id: w,
676
+ id: b,
655
677
  gid: s,
656
- numericId: o,
678
+ numericId: n,
657
679
  title: u,
658
680
  handle: c,
659
- type: i,
681
+ type: a,
660
682
  vendor: l,
661
- availableForSale: f,
662
- images: p,
683
+ availableForSale: d,
684
+ images: g,
663
685
  priceRange: v,
664
686
  compareAtPriceRange: T,
665
687
  options: I,
666
- tags: g,
667
- variants: y,
668
- selectedOptions: N,
669
- metafields: k,
670
- calculated: d,
671
- category: m,
672
- featuredMedia: E,
688
+ tags: m,
689
+ variants: _,
690
+ selectedOptions: k,
691
+ metafields: A,
692
+ calculated: f,
693
+ category: p,
694
+ featuredMedia: w,
673
695
  combinedListingParentProductId: e.combined_listing_parent_product_id,
674
696
  combinedListingRole: e.combined_listing_role,
675
- selectedVariant: _,
676
- breakoutOptions: S,
677
- breakoutVariantId: C
697
+ selectedVariant: E,
698
+ breakoutOptions: C,
699
+ breakoutVariantId: P
678
700
  };
679
701
  }
680
702
  function ct(e) {
@@ -688,56 +710,43 @@ function ct(e) {
688
710
  }));
689
711
  }
690
712
  function ut(e, t, r) {
691
- const n = e.from, a = e.to;
692
713
  return {
693
- min: { amount: n, currencyCode: t, formatted: r(n, t) },
694
- max: { amount: a, currencyCode: t, formatted: r(a, t) }
714
+ min: G(e.from, t, r),
715
+ max: G(e.to, t, r)
695
716
  };
696
717
  }
697
- function lt(e) {
698
- if (e.length === 0) return;
699
- const t = /* @__PURE__ */ new Map();
700
- for (const r of e)
701
- for (const n of r.values)
702
- n.swatch && (!n.swatch.color && !n.swatch.image || t.set(`${r.name}:${n.value}`, {
703
- name: r.name,
704
- value: n.value,
705
- color: n.swatch.color,
706
- imageUrl: n.swatch.image?.url ?? null
707
- }));
708
- return t.size > 0 ? t : void 0;
709
- }
710
- function dt(e, t) {
711
- const r = [], n = e.options, a = lt(e.options_v2);
712
- for (const [o, s] of Object.entries(n))
713
- for (const u of s) {
714
- const c = a?.get(`${o}:${u}`) ?? t.find((l) => l.name === o && l.value === u);
715
- r.push({ name: o, value: u, swatch: c });
718
+ function lt(e, t) {
719
+ const r = [];
720
+ for (const o of e.options_v2)
721
+ for (const i of o.values) {
722
+ const n = i.swatch, u = n && (n.color || n.image) ? {
723
+ name: o.name,
724
+ value: i.value,
725
+ color: n.color,
726
+ imageUrl: n.image?.url ?? null
727
+ } : t.find((c) => c.name === o.name && c.value === i.value);
728
+ r.push({ name: o.name, code: o.code, value: i.value, swatch: u });
716
729
  }
717
730
  return r;
718
731
  }
719
- function ft(e) {
732
+ function dt(e) {
720
733
  return e.selected_options.map((t) => ({ name: t.name, value: t.value }));
721
734
  }
722
- function mt(e, t, r) {
723
- return e.variants.map((n) => gt(n, t, r));
735
+ function ft(e, t, r) {
736
+ return e.variants.map((o) => mt(o, t, r));
724
737
  }
725
- function gt(e, t, r) {
726
- const n = parseFloat(e.price), a = e.compare_at_price ? parseFloat(e.compare_at_price) : null;
738
+ function mt(e, t, r) {
739
+ const o = parseFloat(e.price), i = e.compare_at_price ? parseFloat(e.compare_at_price) : null;
727
740
  return {
728
- id: we({ type: "ProductVariant", selectedOptions: e.selected_options }),
729
- gid: at(e.id),
741
+ id: Ae({ type: "ProductVariant", selectedOptions: e.selected_options }),
742
+ gid: nt(e.id),
730
743
  numericId: e.id,
731
744
  title: e.title,
732
745
  availableForSale: e.available,
733
746
  sku: e.sku,
734
747
  position: e.position,
735
- price: { amount: n, currencyCode: t, formatted: r(n, t) },
736
- compareAtPrice: a != null ? {
737
- amount: a,
738
- currencyCode: t,
739
- formatted: r(a, t)
740
- } : null,
748
+ price: G(o, t, r),
749
+ compareAtPrice: i != null ? G(i, t, r) : null,
741
750
  image: e.featured_media ? {
742
751
  url: e.featured_media.src,
743
752
  alt: e.featured_media.alt ?? "",
@@ -746,7 +755,7 @@ function gt(e, t, r) {
746
755
  position: 0,
747
756
  variantIds: [e.id]
748
757
  } : null,
749
- selectedOptions: e.selected_options.map((o) => ({ name: o.name, value: o.value })),
758
+ selectedOptions: e.selected_options.map((n) => ({ name: n.name, value: n.value })),
750
759
  inventoryLevels: e.inventory_levels ?? {},
751
760
  inventoryPolicy: e.inventory_policy ?? null,
752
761
  inStockLocationIds: e.in_stock_location_ids ?? [],
@@ -754,7 +763,35 @@ function gt(e, t, r) {
754
763
  hasSellingPlan: e.has_selling_plan ?? !1
755
764
  };
756
765
  }
757
- function G({
766
+ function Z({
767
+ results: e,
768
+ meta: t,
769
+ currencyCode: r = ge,
770
+ formatPrice: o = pe,
771
+ swatches: i,
772
+ extender: n
773
+ }) {
774
+ const s = t?.variantBreakouts?.map((u) => u.optionCode) ?? [];
775
+ return e.map((u) => {
776
+ const c = gt(u, s), l = it({
777
+ layers: u,
778
+ currencyCode: r,
779
+ formatPrice: o,
780
+ swatches: i,
781
+ breakoutContext: c
782
+ });
783
+ return n ? { ...l, ...n({ base: l, raw: u }) } : l;
784
+ });
785
+ }
786
+ function gt(e, t) {
787
+ if (!(e.__typename !== "Variant" || t.length === 0))
788
+ return {
789
+ isVariantTile: !0,
790
+ variantId: e.variant_id,
791
+ optionCodes: t
792
+ };
793
+ }
794
+ function x({
758
795
  state: e,
759
796
  isFetching: t = !0
760
797
  }) {
@@ -766,69 +803,69 @@ function D({
766
803
  }) {
767
804
  return { data: e, error: null, isFetching: t };
768
805
  }
769
- function M({
806
+ function L({
770
807
  error: e,
771
808
  data: t = null,
772
809
  isFetching: r = !1
773
810
  }) {
774
811
  return { data: t, error: e, isFetching: r };
775
812
  }
776
- const fe = "__COMMERCE_BLOCKS__", me = typeof window < "u" && typeof window.document < "u";
813
+ const he = "__COMMERCE_BLOCKS__", ye = typeof window < "u" && typeof window.document < "u";
777
814
  function pt(e) {
778
- me && (window[fe] = e);
815
+ ye && (window[he] = e);
779
816
  }
780
- function jt() {
781
- if (!me)
782
- return b(
783
- Q({
817
+ function Kt() {
818
+ if (!ye)
819
+ return h(
820
+ z({
784
821
  code: "INVALID_CONFIG",
785
822
  message: "Client only available in browser",
786
823
  field: "environment",
787
824
  expected: "browser"
788
825
  })
789
826
  );
790
- const e = window[fe];
791
- return e ? L(e) : b(
792
- Q({
827
+ const e = window[he];
828
+ return e ? N(e) : h(
829
+ z({
793
830
  code: "MISSING_CONFIG",
794
831
  message: "Client not initialized. Call createClient() first.",
795
832
  field: "client"
796
833
  })
797
834
  );
798
835
  }
799
- function Qt() {
800
- return me && !!window[fe];
836
+ function Xt() {
837
+ return ye && !!window[he];
801
838
  }
802
839
  function Y(e) {
803
840
  let t = null;
804
841
  return {
805
842
  next(r) {
806
- return t?.abort(), t = ge(r, e), t.signal;
843
+ return t?.abort(), t = ve(r, e), t.signal;
807
844
  },
808
845
  abort() {
809
846
  t?.abort();
810
847
  }
811
848
  };
812
849
  }
813
- function ge(...e) {
850
+ function ve(...e) {
814
851
  const t = new AbortController(), r = [];
815
- for (const n of e) {
816
- if (!n) continue;
817
- if (n.aborted) {
818
- t.abort(n.reason);
852
+ for (const o of e) {
853
+ if (!o) continue;
854
+ if (o.aborted) {
855
+ t.abort(o.reason);
819
856
  break;
820
857
  }
821
- const a = () => t.abort(n.reason);
822
- n.addEventListener("abort", a, { once: !0 }), r.push(() => n.removeEventListener("abort", a));
858
+ const i = () => t.abort(o.reason);
859
+ o.addEventListener("abort", i, { once: !0 }), r.push(() => o.removeEventListener("abort", i));
823
860
  }
824
- return r.length && t.signal.addEventListener("abort", () => r.forEach((n) => n()), {
861
+ return r.length && t.signal.addEventListener("abort", () => r.forEach((o) => o()), {
825
862
  once: !0
826
863
  }), t;
827
864
  }
828
865
  function $(e, t) {
829
- return re(() => t(e.value));
866
+ return se(() => t(e.value));
830
867
  }
831
- function q() {
868
+ function F() {
832
869
  const e = /* @__PURE__ */ new Set();
833
870
  return {
834
871
  add(t) {
@@ -841,14 +878,14 @@ function q() {
841
878
  }
842
879
  };
843
880
  }
844
- function z({
881
+ function ee({
845
882
  products: e,
846
883
  raw: t,
847
884
  extender: r,
848
- currencyCode: n = ve,
849
- formatPrice: a = _e
885
+ currencyCode: o = ge,
886
+ formatPrice: i = pe
850
887
  }) {
851
- const o = {
888
+ const n = {
852
889
  products: e,
853
890
  totalResults: t.totalResults,
854
891
  totalPages: t.totalPages,
@@ -856,149 +893,145 @@ function z({
856
893
  resultsPerPage: t.resultsPerPage,
857
894
  facets: t.facets ?? {},
858
895
  facetRanges: t.facetRanges,
859
- priceRange: ht(t.facetRanges, n, a),
896
+ priceRange: st(t.facetRanges, o, i),
860
897
  attributionToken: t.attributionToken,
861
898
  _workflow: t._workflow
862
899
  };
863
- return r ? r(o, t) : o;
864
- }
865
- function ht(e, t, r) {
866
- const n = e?.["variants.price"];
867
- if (n)
868
- return {
869
- min: { amount: n.min, currencyCode: t, formatted: r(n.min, t) },
870
- max: { amount: n.max, currencyCode: t, formatted: r(n.max, t) }
871
- };
872
- }
873
- function vt(e, t) {
874
- if (!(e.__typename !== "Variant" || t.length === 0))
875
- return {
876
- isVariantTile: !0,
877
- variantId: e.variant_id,
878
- optionCodes: t
879
- };
900
+ return r ? r(n, t) : n;
880
901
  }
881
- function X(e, { results: t, meta: r }) {
882
- const n = r?.variantBreakouts?.map((a) => a.optionCode) ?? [];
883
- return t.map((a) => {
884
- const o = vt(a, n), s = it({
885
- layers: a,
886
- currencyCode: e.config.currency,
887
- formatPrice: e.config.formatPrice,
888
- swatches: e.config.swatches,
889
- breakoutContext: o
890
- });
891
- return e.config.transforms?.product ? { ...s, ...e.config.transforms.product({ base: s, raw: a }) } : s;
892
- });
893
- }
894
- function H(e, t) {
902
+ function J(e, t) {
895
903
  if (t) {
896
904
  if (e.config.transforms?.filters)
897
905
  return e.config.transforms.filters(t);
898
906
  if (e.config.filterAliases && typeof t == "object" && !Array.isArray(t)) {
899
- const r = t, n = [];
900
- for (const [a, o] of Object.entries(r)) {
901
- if (o == null) continue;
902
- const s = e.config.filterAliases[a], u = typeof s == "string" ? s : s?.property ?? a, c = typeof s == "object" ? s.values : void 0, i = (Array.isArray(o) ? o : [o]).map((f) => {
903
- const g = String(f);
904
- return c?.[g] ?? g;
907
+ const r = t, o = [];
908
+ for (const [i, n] of Object.entries(r)) {
909
+ if (n == null) continue;
910
+ const s = e.config.filterAliases[i], u = typeof s == "string" ? s : s?.property ?? i, c = typeof s == "object" ? s.values : void 0, a = (Array.isArray(n) ? n : [n]).map((d) => {
911
+ const m = String(d);
912
+ return c?.[m] ?? m;
905
913
  });
906
- n.push({
914
+ o.push({
907
915
  property: u,
908
- operator: i.length > 1 ? se.In : se.Equal,
909
- values: i
916
+ operator: a.length > 1 ? ue.In : ue.Equal,
917
+ values: a
910
918
  });
911
919
  }
912
- return n.length === 0 ? void 0 : {
913
- conditional: ye.And,
914
- expressions: n
920
+ return o.length === 0 ? void 0 : {
921
+ conditional: we.And,
922
+ expressions: o
915
923
  };
916
924
  }
917
925
  return t;
918
926
  }
919
927
  }
920
- function _t({ ctx: e }) {
928
+ function ht({ ctx: e }) {
921
929
  return ({ handle: t, defaultSort: r }) => {
922
- const n = P({
930
+ const o = q({
923
931
  data: null,
924
932
  error: null,
925
933
  isFetching: !1
926
- }), a = Y();
927
- let o = r ?? e.config.sorts[0]?.code;
928
- const s = q();
934
+ }), i = Y();
935
+ let n = r ?? e.config.sorts[0]?.code;
936
+ const s = F();
929
937
  return {
930
- state: n,
938
+ state: o,
931
939
  async execute(u = {}) {
932
940
  const {
933
941
  page: c = K,
934
- limit: l = J,
935
- filters: i,
936
- sort: f,
937
- signal: g,
938
- includeMeta: p = e.config.includeMeta ?? !1,
942
+ limit: l = X,
943
+ filters: a,
944
+ sort: d,
945
+ signal: m,
946
+ includeMeta: g = e.config.includeMeta ?? !1,
939
947
  linking: v,
940
948
  transformRequest: I
941
- } = u, y = f ?? o;
942
- o = y;
943
- const R = a.next(g), T = de({
949
+ } = u, _ = d ?? n;
950
+ n = _;
951
+ const R = i.next(m), T = W({
944
952
  prefix: "/browse",
945
953
  id: t,
946
- params: { sort: y, page: c, limit: l, filters: i }
947
- }), { data: N, error: w } = await e.coordinator.resolve({
954
+ params: { sort: _, page: c, limit: l, filters: a }
955
+ }), { data: k, error: b } = await e.coordinator.resolve({
948
956
  key: T,
949
957
  cache: e.cache,
950
958
  signal: R,
951
959
  onFetch: () => {
952
- n.value = G({ state: n.value });
960
+ o.value = x({ state: o.value });
953
961
  },
954
- fn: async (k) => {
955
- const { data: d, error: m } = await e.layers.browse(
962
+ fn: async (A) => {
963
+ const { data: f, error: p } = await e.layers.browse(
956
964
  {
957
965
  collectionHandle: t,
958
- sort_order_code: y,
966
+ sort_order_code: _,
959
967
  pagination: { page: c, limit: l },
960
- filter_group: H(e, i),
968
+ filter_group: J(e, a),
961
969
  dynamicLinking: v,
962
970
  transformBody: I
963
971
  },
964
- k
972
+ A
965
973
  );
966
- if (m) return b(m);
967
- const { results: E, _meta: _ } = d, S = X(e, { results: E, meta: _ }), C = z({
968
- products: S,
969
- raw: d,
974
+ if (p) return h(p);
975
+ const { results: w, _meta: E } = f, C = Z({
976
+ results: w,
977
+ meta: E,
978
+ currencyCode: e.config.currency,
979
+ formatPrice: e.config.formatPrice,
980
+ swatches: e.config.swatches,
981
+ extender: e.config.transforms?.product
982
+ }), P = ee({
983
+ products: C,
984
+ raw: f,
970
985
  extender: e.config.transforms?.collection,
971
986
  currencyCode: e.config.currency,
972
987
  formatPrice: e.config.formatPrice
973
988
  });
974
- return p && d._meta && (C._meta = d._meta), T && e.cache.set(T, C), L(C);
989
+ return g && f._meta && (P._meta = f._meta), T && e.cache.set(T, P), N(P);
975
990
  }
976
991
  });
977
- return w ? (n.value = M({ error: w, data: n.value.data }), b(w)) : (n.value = D({ data: N }), L(N));
992
+ return b ? (o.value = L({ error: b, data: o.value.data }), h(b)) : (o.value = D({ data: k }), N(k));
978
993
  },
979
994
  subscribe(u) {
980
- return s.add($(n, u));
995
+ return s.add($(o, u));
981
996
  },
982
997
  dispose() {
983
- s.clear(), a.abort();
998
+ s.clear(), i.abort();
984
999
  }
985
1000
  };
986
1001
  };
987
1002
  }
988
- async function bt(e, { maxRetries: t = 3, defaultDelayMs: r = 1e3 } = {}) {
1003
+ function yt(e, t) {
1004
+ return t?.aborted ? Promise.resolve() : new Promise((r) => {
1005
+ const o = setTimeout(r, e);
1006
+ t?.addEventListener(
1007
+ "abort",
1008
+ () => {
1009
+ clearTimeout(o), r();
1010
+ },
1011
+ { once: !0 }
1012
+ );
1013
+ });
1014
+ }
1015
+ async function vt(e, { maxRetries: t = 3, defaultDelayMs: r = 1e3, signal: o, shouldRetry: i }) {
989
1016
  let n = await e();
990
- for (let a = 0; a < t && n.error && Ve(n.error); a++)
991
- await new Promise((o) => setTimeout(o, Be(n.error) ?? r)), n = await e();
1017
+ for (let s = 0; s < t && n.error && !(!i(n.error) || o?.aborted); s++) {
1018
+ const u = "retryAfterMs" in n.error ? n.error.retryAfterMs ?? r : r;
1019
+ if (await yt(u, o), o?.aborted) break;
1020
+ n = await e();
1021
+ }
992
1022
  return n;
993
1023
  }
994
- function yt({ ctx: e }) {
1024
+ function _t(e) {
1025
+ return e._tag === "ApiError" && e.status === 425;
1026
+ }
1027
+ function bt({ ctx: e }) {
995
1028
  return (t = {}) => {
996
- const r = P({
1029
+ const r = q({
997
1030
  data: null,
998
1031
  error: null,
999
1032
  isFetching: !1
1000
1033
  });
1001
- let n = {
1034
+ let o = {
1002
1035
  query: t.query,
1003
1036
  page: t.page,
1004
1037
  limit: t.limit,
@@ -1007,181 +1040,200 @@ function yt({ ctx: e }) {
1007
1040
  linking: t.linking,
1008
1041
  transformRequest: t.transformRequest
1009
1042
  };
1010
- const a = Y(t.signal);
1011
- let o;
1012
- const s = q();
1043
+ const i = Y(t.signal);
1044
+ let n;
1045
+ const s = F();
1013
1046
  function u(c = {}) {
1014
- const l = { ...n, ...c };
1015
- return c.temporary || (n = l), l;
1047
+ const { signal: l, searchId: a, temporary: d, ...m } = c, g = { ...o, ...m };
1048
+ return d || (o = g), { ...g, signal: l, searchId: a };
1016
1049
  }
1017
1050
  return {
1018
1051
  state: r,
1019
1052
  async prepare(c = {}) {
1020
- const l = u(c), { query: i, filters: f, tuning: g, linking: p, transformRequest: v } = l;
1021
- if (!i)
1022
- return b(
1023
- x({
1053
+ const l = u(c), { query: a, filters: d, tuning: m, linking: g, transformRequest: v } = l;
1054
+ if (!a)
1055
+ return h(
1056
+ B({
1024
1057
  operation: "search.prepare",
1025
- fields: [F("query", "REQUIRED_FIELD", "query is required")]
1058
+ fields: [M("query", "REQUIRED_FIELD", "query is required")]
1026
1059
  })
1027
1060
  );
1028
- const I = H(e, f), y = await e.layers.prepareSearch(
1061
+ const I = J(e, d), _ = await e.layers.prepareSearch(
1029
1062
  {
1030
- query: i,
1063
+ query: a,
1031
1064
  filter_group: I,
1032
- tuning: g,
1033
- dynamicLinking: p,
1065
+ tuning: m,
1066
+ dynamicLinking: g,
1034
1067
  transformBody: v
1035
1068
  },
1036
1069
  c.signal
1037
1070
  );
1038
- return y.error ? b(y.error) : (o = y.data.search_id, L({ searchId: y.data.search_id }));
1071
+ return _.error ? h(_.error) : (n = _.data.search_id, N({ searchId: _.data.search_id }));
1039
1072
  },
1040
1073
  async execute(c = {}) {
1041
1074
  const l = u(c), {
1042
- query: i,
1043
- page: f = K,
1044
- limit: g = J,
1045
- filters: p,
1075
+ query: a,
1076
+ page: d = K,
1077
+ limit: m = X,
1078
+ filters: g,
1046
1079
  tuning: v,
1047
1080
  linking: I,
1048
- transformRequest: y
1081
+ transformRequest: _
1049
1082
  } = l;
1050
- if (!i) {
1051
- const E = x({
1083
+ if (!a) {
1084
+ const w = B({
1052
1085
  operation: "search.execute",
1053
- fields: [F("query", "REQUIRED_FIELD", "query is required")]
1086
+ fields: [M("query", "REQUIRED_FIELD", "query is required")]
1054
1087
  });
1055
- return r.value = M({ error: E, data: r.value.data }), b(E);
1088
+ return r.value = L({ error: w, data: r.value.data }), h(w);
1056
1089
  }
1057
- const R = c.searchId, T = H(e, p), N = a.next(c.signal), w = R ?? o;
1058
- o = void 0;
1059
- const k = de({
1090
+ const R = c.searchId, T = J(e, g), k = i.next(c.signal), b = R ?? n;
1091
+ n = void 0;
1092
+ const A = W({
1060
1093
  prefix: "/search",
1061
- id: i,
1062
- params: { page: f, limit: g, filters: p }
1063
- }), { data: d, error: m } = await e.coordinator.resolve({
1064
- key: k,
1094
+ id: a,
1095
+ params: { page: d, limit: m, filters: g }
1096
+ }), { data: f, error: p } = await e.coordinator.resolve({
1097
+ key: A,
1065
1098
  cache: e.cache,
1066
- signal: N,
1099
+ signal: k,
1067
1100
  onFetch: () => {
1068
- r.value = G({ state: r.value });
1101
+ r.value = x({ state: r.value });
1069
1102
  },
1070
- fn: async (E) => {
1071
- let _ = w;
1072
- if (!_) {
1073
- const W = await e.layers.prepareSearch(
1103
+ fn: async (w) => {
1104
+ let E = b;
1105
+ if (!E) {
1106
+ const te = await e.layers.prepareSearch(
1074
1107
  {
1075
- query: i,
1108
+ query: a,
1076
1109
  filter_group: T,
1077
1110
  tuning: v,
1078
1111
  dynamicLinking: I,
1079
- transformBody: y
1112
+ transformBody: _
1080
1113
  },
1081
- E
1114
+ w
1082
1115
  );
1083
- if (W.error) return b(W.error);
1084
- _ = W.data.search_id;
1116
+ if (te.error) return h(te.error);
1117
+ E = te.data.search_id;
1085
1118
  }
1086
- const S = await bt(
1119
+ const C = await vt(
1087
1120
  () => e.layers.search(
1088
1121
  {
1089
- query: i,
1090
- search_id: _,
1091
- pagination: { page: f, limit: g },
1122
+ query: a,
1123
+ search_id: E,
1124
+ pagination: { page: d, limit: m },
1092
1125
  filter_group: T,
1093
1126
  tuning: v,
1094
1127
  dynamicLinking: I,
1095
- transformBody: y
1128
+ transformBody: _
1096
1129
  },
1097
- E
1130
+ w
1098
1131
  ),
1099
- { maxRetries: Ce, defaultDelayMs: Le }
1132
+ {
1133
+ maxRetries: Le,
1134
+ defaultDelayMs: qe,
1135
+ signal: w,
1136
+ shouldRetry: _t
1137
+ }
1100
1138
  );
1101
- if (S.error) return b(S.error);
1102
- const { results: C, _meta: h } = S.data, A = X(e, { results: C, meta: h }), V = z({
1103
- products: A,
1104
- raw: S.data,
1139
+ if (C.error) return h(C.error);
1140
+ const { results: P, _meta: y } = C.data, S = Z({
1141
+ results: P,
1142
+ meta: y,
1143
+ currencyCode: e.config.currency,
1144
+ formatPrice: e.config.formatPrice,
1145
+ swatches: e.config.swatches,
1146
+ extender: e.config.transforms?.product
1147
+ }), j = ee({
1148
+ products: S,
1149
+ raw: C.data,
1105
1150
  extender: e.config.transforms?.search,
1106
1151
  currencyCode: e.config.currency,
1107
1152
  formatPrice: e.config.formatPrice
1108
1153
  });
1109
- return e.config.includeMeta && S.data._meta && (V._meta = S.data._meta), k && e.cache.set(k, V), L(V);
1154
+ return e.config.includeMeta && C.data._meta && (j._meta = C.data._meta), A && e.cache.set(A, j), N(j);
1110
1155
  }
1111
1156
  });
1112
- return m ? (r.value = M({ error: m, data: r.value.data }), b(m)) : (r.value = D({ data: d }), L(d));
1157
+ return p ? (r.value = L({ error: p, data: r.value.data }), h(p)) : (r.value = D({ data: f }), N(f));
1113
1158
  },
1114
1159
  subscribe(c) {
1115
1160
  return s.add($(r, c));
1116
1161
  },
1117
1162
  dispose() {
1118
- s.clear(), a.abort();
1163
+ s.clear(), i.abort();
1119
1164
  }
1120
1165
  };
1121
1166
  };
1122
1167
  }
1123
1168
  function Et({ ctx: e }) {
1124
1169
  return ({ blockId: t, anchor: r }) => {
1125
- const n = P({
1170
+ const o = q({
1126
1171
  data: null,
1127
1172
  error: null,
1128
1173
  isFetching: !1
1129
- }), a = Y(), o = q();
1174
+ }), i = Y(), n = F();
1130
1175
  return {
1131
- state: n,
1176
+ state: o,
1132
1177
  async execute(s = {}) {
1133
1178
  const {
1134
1179
  page: u = K,
1135
- limit: c = J,
1180
+ limit: c = X,
1136
1181
  filters: l,
1137
- signal: i,
1138
- discounts: f,
1139
- context: g,
1140
- linking: p,
1182
+ signal: a,
1183
+ discounts: d,
1184
+ context: m,
1185
+ linking: g,
1141
1186
  transformRequest: v
1142
- } = s, I = a.next(i), y = de({
1187
+ } = s, I = i.next(a), _ = W({
1143
1188
  prefix: "/blocks",
1144
1189
  id: t,
1145
1190
  params: { anchor: r, page: u, limit: c, filters: l }
1146
1191
  }), { data: R, error: T } = await e.coordinator.resolve({
1147
- key: y,
1192
+ key: _,
1148
1193
  cache: e.cache,
1149
1194
  signal: I,
1150
1195
  onFetch: () => {
1151
- n.value = G({ state: n.value });
1196
+ o.value = x({ state: o.value });
1152
1197
  },
1153
- fn: async (N) => {
1154
- const { data: w, error: k } = await e.layers.blocks(
1198
+ fn: async (k) => {
1199
+ const { data: b, error: A } = await e.layers.blocks(
1155
1200
  {
1156
1201
  blockId: t,
1157
1202
  anchor_id: r,
1158
1203
  pagination: { page: u, limit: c },
1159
- filter_group: H(e, l),
1160
- discountEntitlements: f,
1161
- context: g,
1162
- dynamicLinking: p,
1204
+ filter_group: J(e, l),
1205
+ discountEntitlements: d,
1206
+ context: m,
1207
+ dynamicLinking: g,
1163
1208
  transformBody: v
1164
1209
  },
1165
- N
1210
+ k
1166
1211
  );
1167
- if (k) return b(k);
1168
- const { results: d, _meta: m } = w, E = X(e, { results: d, meta: m }), _ = z({
1169
- products: E,
1170
- raw: w,
1212
+ if (A) return h(A);
1213
+ const { results: f, _meta: p } = b, w = Z({
1214
+ results: f,
1215
+ meta: p,
1216
+ currencyCode: e.config.currency,
1217
+ formatPrice: e.config.formatPrice,
1218
+ swatches: e.config.swatches,
1219
+ extender: e.config.transforms?.product
1220
+ }), E = ee({
1221
+ products: w,
1222
+ raw: b,
1171
1223
  extender: e.config.transforms?.block,
1172
1224
  currencyCode: e.config.currency,
1173
1225
  formatPrice: e.config.formatPrice
1174
1226
  });
1175
- return e.config.includeMeta && w._meta && (_._meta = w._meta), w.block && (_.block = w.block), y && e.cache.set(y, _), L(_);
1227
+ return e.config.includeMeta && b._meta && (E._meta = b._meta), b.block && (E.block = b.block), _ && e.cache.set(_, E), N(E);
1176
1228
  }
1177
1229
  });
1178
- return T ? (n.value = M({ error: T, data: n.value.data }), b(T)) : (n.value = D({ data: R }), L(R));
1230
+ return T ? (o.value = L({ error: T, data: o.value.data }), h(T)) : (o.value = D({ data: R }), N(R));
1179
1231
  },
1180
1232
  subscribe(s) {
1181
- return o.add($(n, s));
1233
+ return n.add($(o, s));
1182
1234
  },
1183
1235
  dispose() {
1184
- o.clear(), a.abort();
1236
+ n.clear(), i.abort();
1185
1237
  }
1186
1238
  };
1187
1239
  };
@@ -1189,9 +1241,9 @@ function Et({ ctx: e }) {
1189
1241
  function wt(e, t) {
1190
1242
  let r = null;
1191
1243
  return {
1192
- call(...n) {
1244
+ call(...o) {
1193
1245
  r && clearTimeout(r), r = setTimeout(() => {
1194
- r = null, e(...n);
1246
+ r = null, e(...o);
1195
1247
  }, t);
1196
1248
  },
1197
1249
  cancel() {
@@ -1200,87 +1252,91 @@ function wt(e, t) {
1200
1252
  };
1201
1253
  }
1202
1254
  function It(e, t) {
1203
- const r = new Set(t.map((n) => n.toLowerCase()));
1204
- return e.filter((n) => !r.has(n.toLowerCase()));
1255
+ const r = new Set(t.map((o) => o.toLowerCase()));
1256
+ return e.filter((o) => !r.has(o.toLowerCase()));
1205
1257
  }
1206
1258
  function At({ ctx: e }) {
1207
1259
  return (t = {}) => {
1208
1260
  const {
1209
- debounce: r = Pe,
1210
- excludeInputQuery: n = !1,
1211
- excludeQueries: a,
1212
- signal: o
1213
- } = t, s = P({
1261
+ debounce: r = De,
1262
+ excludeInputQuery: o = !1,
1263
+ excludeQueries: i,
1264
+ signal: n
1265
+ } = t, s = q({
1214
1266
  data: null,
1215
1267
  error: null,
1216
1268
  isFetching: !1
1217
- }), u = Y(o);
1269
+ }), u = Y(n);
1218
1270
  let c = 0;
1219
- const l = /* @__PURE__ */ new Map(), i = q();
1220
- function f() {
1221
- i.clear(), g.cancel(), u.abort(), l.clear(), o?.removeEventListener("abort", f);
1271
+ const l = /* @__PURE__ */ new Map(), a = F();
1272
+ function d() {
1273
+ a.clear(), m.cancel(), u.abort(), l.clear(), n?.removeEventListener("abort", d);
1222
1274
  }
1223
- o?.addEventListener("abort", f, { once: !0 });
1224
- const g = wt(async (v) => {
1275
+ n?.addEventListener("abort", d, { once: !0 });
1276
+ const m = wt(async (v) => {
1225
1277
  const I = v.trim();
1226
1278
  if (!I) {
1227
1279
  s.value = { data: null, error: null, isFetching: !1 };
1228
1280
  return;
1229
1281
  }
1230
- const y = I.toLowerCase(), R = l.get(y);
1282
+ const _ = I.toLowerCase(), R = l.get(_);
1231
1283
  if (R) {
1232
1284
  s.value = D({ data: R });
1233
1285
  return;
1234
1286
  }
1235
- const T = u.next(), N = ++c;
1236
- s.value = G({ state: s.value });
1237
- const w = await e.layers.predictiveSearch(I, T);
1238
- if (N === c)
1239
- if (w.error)
1240
- w.error._tag !== "NetworkError" || w.error.code !== "ABORTED" ? s.value = M({ error: w.error }) : s.value = G({ state: s.value, isFetching: !1 });
1287
+ const T = u.next(), k = ++c;
1288
+ s.value = x({ state: s.value });
1289
+ const b = await e.layers.predictiveSearch(I, T);
1290
+ if (k === c)
1291
+ if (b.error)
1292
+ b.error._tag !== "NetworkError" || b.error.code !== "ABORTED" ? s.value = L({ error: b.error }) : s.value = x({ state: s.value, isFetching: !1 });
1241
1293
  else {
1242
- const k = [
1243
- ...n ? [w.data.originalQuery, w.data.normalizedQuery] : [],
1244
- ...a ?? []
1245
- ], d = k.length ? {
1246
- ...w.data,
1247
- matchedQueries: It(w.data.matchedQueries, k)
1248
- } : w.data;
1249
- l.set(y, d), l.size > De && l.delete(l.keys().next().value), s.value = D({ data: d });
1294
+ const A = [
1295
+ ...o ? [b.data.originalQuery, b.data.normalizedQuery] : [],
1296
+ ...i ?? []
1297
+ ], f = A.length ? {
1298
+ ...b.data,
1299
+ matchedQueries: It(b.data.matchedQueries, A)
1300
+ } : b.data;
1301
+ l.set(_, f), l.size > Fe && l.delete(l.keys().next().value), s.value = D({ data: f });
1250
1302
  }
1251
1303
  }, r);
1252
- function p(v) {
1253
- return i.add($(s, v));
1304
+ function g(v) {
1305
+ return a.add($(s, v));
1254
1306
  }
1255
1307
  return {
1256
1308
  state: s,
1257
- execute: (v) => g.call(v),
1258
- subscribe: p,
1259
- dispose: f
1309
+ execute: (v) => m.call(v),
1310
+ subscribe: g,
1311
+ dispose: d
1260
1312
  };
1261
1313
  };
1262
1314
  }
1263
1315
  function St({ ctx: e }) {
1264
1316
  return ({ image: t, signal: r }) => {
1265
- const n = P({
1317
+ const o = q({
1266
1318
  data: null,
1267
1319
  error: null,
1268
1320
  isFetching: !0
1269
- }), a = q(), o = ge(r);
1321
+ }), i = F(), n = ve(r);
1270
1322
  return (async () => {
1271
- const s = await e.layers.uploadImage(t, o.signal);
1323
+ const s = await e.layers.uploadImage(t, n.signal);
1272
1324
  if (s.error) {
1273
- n.value = M({ error: s.error });
1325
+ o.value = L({ error: s.error });
1274
1326
  return;
1275
1327
  }
1276
- n.value = D({ data: { imageId: s.data.imageId } });
1277
- })(), {
1278
- state: n,
1328
+ o.value = D({ data: { imageId: s.data.imageId } });
1329
+ })().catch((s) => {
1330
+ o.value = L({
1331
+ error: Q({ code: "CONNECTION_FAILED", message: String(s) })
1332
+ });
1333
+ }), {
1334
+ state: o,
1279
1335
  subscribe(s) {
1280
- return a.add($(n, s));
1336
+ return i.add($(o, s));
1281
1337
  },
1282
1338
  dispose() {
1283
- a.clear(), o.abort();
1339
+ i.clear(), n.abort();
1284
1340
  }
1285
1341
  };
1286
1342
  };
@@ -1289,55 +1345,161 @@ function Rt({ ctx: e }) {
1289
1345
  return (t) => {
1290
1346
  const {
1291
1347
  imageId: r,
1292
- page: n = K,
1293
- limit: a = J,
1294
- filters: o,
1348
+ page: o = K,
1349
+ limit: i = X,
1350
+ filters: n,
1295
1351
  tuning: s,
1296
1352
  signal: u,
1297
1353
  linking: c,
1298
1354
  transformRequest: l
1299
- } = t, i = P({
1355
+ } = t, a = q({
1300
1356
  data: null,
1301
1357
  error: null,
1302
1358
  isFetching: !0
1303
- }), f = q(), g = ge(u);
1359
+ }), d = F(), m = ve(u);
1304
1360
  return (async () => {
1305
- const p = await e.layers.imageSearch(
1361
+ const g = await e.layers.imageSearch(
1306
1362
  {
1307
1363
  image_id: r,
1308
- pagination: { page: n, limit: a },
1309
- filter_group: H(e, o),
1364
+ pagination: { page: o, limit: i },
1365
+ filter_group: J(e, n),
1310
1366
  tuning: s,
1311
1367
  dynamicLinking: c,
1312
1368
  transformBody: l
1313
1369
  },
1314
- g.signal
1370
+ m.signal
1315
1371
  );
1316
- if (p.error) {
1317
- i.value = M({ error: p.error });
1372
+ if (g.error) {
1373
+ a.value = L({ error: g.error });
1318
1374
  return;
1319
1375
  }
1320
- const { results: v, _meta: I } = p.data, y = X(e, { results: v, meta: I }), R = z({
1321
- products: y,
1322
- raw: p.data,
1376
+ const { results: v, _meta: I } = g.data, _ = Z({
1377
+ results: v,
1378
+ meta: I,
1379
+ currencyCode: e.config.currency,
1380
+ formatPrice: e.config.formatPrice,
1381
+ swatches: e.config.swatches,
1382
+ extender: e.config.transforms?.product
1383
+ }), R = ee({
1384
+ products: _,
1385
+ raw: g.data,
1323
1386
  extender: e.config.transforms?.search,
1324
1387
  currencyCode: e.config.currency,
1325
1388
  formatPrice: e.config.formatPrice
1326
1389
  });
1327
- i.value = D({ data: R });
1328
- })(), {
1329
- state: i,
1330
- subscribe(p) {
1331
- return f.add($(i, p));
1390
+ a.value = D({ data: R });
1391
+ })().catch((g) => {
1392
+ a.value = L({
1393
+ error: Q({ code: "CONNECTION_FAILED", message: String(g) })
1394
+ });
1395
+ }), {
1396
+ state: a,
1397
+ subscribe(g) {
1398
+ return d.add($(a, g));
1399
+ },
1400
+ dispose() {
1401
+ d.clear(), m.abort();
1402
+ }
1403
+ };
1404
+ };
1405
+ }
1406
+ function Tt(e) {
1407
+ return {
1408
+ title: e.title,
1409
+ handle: e.handle,
1410
+ summary: e.summary_text,
1411
+ author: e.author,
1412
+ tags: e.tags,
1413
+ image: e.image,
1414
+ publishedAt: e.published_at
1415
+ };
1416
+ }
1417
+ function Ct({ ctx: e }) {
1418
+ return (t = {}) => {
1419
+ const r = q({
1420
+ data: null,
1421
+ error: null,
1422
+ isFetching: !1
1423
+ });
1424
+ let o = {
1425
+ query: t.query,
1426
+ contentType: t.contentType,
1427
+ page: t.page,
1428
+ limit: t.limit,
1429
+ tuning: t.tuning,
1430
+ transformRequest: t.transformRequest
1431
+ };
1432
+ const i = Y(t.signal), n = F();
1433
+ function s(u = {}) {
1434
+ const { signal: c, temporary: l, ...a } = u, d = { ...o, ...a };
1435
+ return l || (o = d), { ...d, signal: c };
1436
+ }
1437
+ return {
1438
+ state: r,
1439
+ async execute(u = {}) {
1440
+ const c = s(u), {
1441
+ query: l,
1442
+ contentType: a,
1443
+ page: d = K,
1444
+ limit: m = X,
1445
+ tuning: g,
1446
+ transformRequest: v
1447
+ } = c;
1448
+ if (!l) {
1449
+ const k = B({
1450
+ operation: "searchContent.execute",
1451
+ fields: [M("query", "REQUIRED_FIELD", "query is required")]
1452
+ });
1453
+ return r.value = L({ error: k, data: r.value.data }), h(k);
1454
+ }
1455
+ const I = i.next(u.signal), _ = W({
1456
+ prefix: "/search-content",
1457
+ id: l,
1458
+ params: { contentType: a, page: d, limit: m }
1459
+ }), { data: R, error: T } = await e.coordinator.resolve({
1460
+ key: _,
1461
+ cache: e.cache,
1462
+ signal: I,
1463
+ onFetch: () => {
1464
+ r.value = x({ state: r.value });
1465
+ },
1466
+ fn: async (k) => {
1467
+ const b = await e.layers.searchContent(
1468
+ {
1469
+ query: l,
1470
+ content_type: a,
1471
+ pagination: { page: d, limit: m },
1472
+ tuning: g,
1473
+ transformBody: v
1474
+ },
1475
+ k
1476
+ );
1477
+ if (b.error) return h(b.error);
1478
+ const A = b.data;
1479
+ let f = {
1480
+ articles: A.results.map(Tt),
1481
+ query: A.query,
1482
+ contentType: A.contentType,
1483
+ totalResults: A.totalResults,
1484
+ page: A.page,
1485
+ resultsPerPage: A.resultsPerPage
1486
+ };
1487
+ return e.config.transforms?.searchContent && (f = e.config.transforms.searchContent(f, A)), _ && e.cache.set(_, f), N(f);
1488
+ }
1489
+ });
1490
+ return T ? (r.value = L({ error: T, data: r.value.data }), h(T)) : (r.value = D({ data: R }), N(R));
1491
+ },
1492
+ subscribe(u) {
1493
+ return n.add($(r, u));
1332
1494
  },
1333
1495
  dispose() {
1334
- f.clear(), g.abort();
1496
+ n.clear(), i.abort();
1335
1497
  }
1336
1498
  };
1337
1499
  };
1338
1500
  }
1339
- function Kt(e) {
1340
- const t = Ye({
1501
+ function Yt(e) {
1502
+ const t = Je({
1341
1503
  token: e.token,
1342
1504
  baseUrl: e.baseUrl,
1343
1505
  sorts: e.sorts,
@@ -1345,151 +1507,152 @@ function Kt(e) {
1345
1507
  attributes: e.attributes,
1346
1508
  fetch: e.fetch
1347
1509
  });
1348
- if (t.error) return b(t.error);
1349
- const r = t.data, n = et({
1510
+ if (t.error) return h(t.error);
1511
+ const r = t.data, o = We({
1350
1512
  maxEntries: e.cacheLimit,
1351
1513
  ttl: e.cacheLifetime,
1352
1514
  storageAdapter: e.storage
1353
1515
  });
1354
- if (e.restoreCache !== !1 && n.restore(), e.initialData)
1516
+ if (e.restoreCache !== !1 && o.restore(), e.initialData)
1355
1517
  for (const [u, c] of Object.entries(e.initialData))
1356
- n.set(u, c);
1357
- const a = tt(), o = {
1518
+ o.set(u, c);
1519
+ const i = Ze(), n = {
1358
1520
  config: e,
1359
1521
  layers: r,
1360
- cache: n,
1361
- coordinator: a
1522
+ cache: o,
1523
+ coordinator: i
1362
1524
  }, s = {
1363
1525
  config: e,
1364
- cache: n,
1365
- collection: _t({ ctx: o }),
1366
- search: yt({ ctx: o }),
1367
- blocks: Et({ ctx: o }),
1368
- suggest: At({ ctx: o }),
1369
- uploadImage: St({ ctx: o }),
1370
- searchByImage: Rt({ ctx: o })
1526
+ cache: o,
1527
+ collection: ht({ ctx: n }),
1528
+ search: bt({ ctx: n }),
1529
+ blocks: Et({ ctx: n }),
1530
+ suggest: At({ ctx: n }),
1531
+ uploadImage: St({ ctx: n }),
1532
+ searchByImage: Rt({ ctx: n }),
1533
+ searchContent: Ct({ ctx: n })
1371
1534
  };
1372
- return pt(s), L(s);
1535
+ return pt(s), N(s);
1373
1536
  }
1374
- function Jt({
1537
+ function zt({
1375
1538
  product: e,
1376
1539
  selectedOptions: t = [],
1377
1540
  breakoutOptions: r
1378
1541
  }) {
1379
- const n = r ?? e.breakoutOptions ?? [], a = new Set(n.map((d) => d.name)), o = P(t), s = P(null), u = q(), c = O(() => Tt(e.variants, n)), l = O(() => {
1380
- const d = o.value.filter((m) => !a.has(m.name));
1381
- return [...n, ...d];
1382
- }), i = O(
1383
- () => Ae(c.value, l.value)
1384
- ), f = O(
1385
- () => kt({
1542
+ const o = r ?? e.breakoutOptions ?? [], i = new Set(o.map((f) => f.name)), n = q(t), s = q(null), u = F(), c = O(() => kt(e.variants, o)), l = O(() => {
1543
+ const f = n.value.filter((p) => !i.has(p.name));
1544
+ return [...o, ...f];
1545
+ }), a = O(
1546
+ () => Re(c.value, l.value)
1547
+ ), d = O(
1548
+ () => Ot({
1386
1549
  variants: c.value,
1387
1550
  productOptions: e.options,
1388
- selectedOptions: o.value,
1389
- breakoutOptions: n,
1390
- breakoutNames: a
1551
+ selectedOptions: n.value,
1552
+ breakoutOptions: o,
1553
+ breakoutNames: i
1391
1554
  })
1392
- ), g = O(() => e.options.find((m) => m.swatch)?.name ?? null), p = O(() => {
1393
- const d = g.value;
1394
- if (!d) return /* @__PURE__ */ new Map();
1395
- const m = /* @__PURE__ */ new Map();
1396
- for (const E of c.value) {
1397
- const _ = E.selectedOptions.find((S) => S.name === d);
1398
- _ && m.set(E.numericId, _.value);
1555
+ ), m = O(() => e.options.find((p) => p.swatch)?.name ?? null), g = O(() => {
1556
+ const f = m.value;
1557
+ if (!f) return /* @__PURE__ */ new Map();
1558
+ const p = /* @__PURE__ */ new Map();
1559
+ for (const w of c.value) {
1560
+ const E = w.selectedOptions.find((C) => C.name === f);
1561
+ E && p.set(w.numericId, E.value);
1399
1562
  }
1400
- return m;
1563
+ return p;
1401
1564
  }), v = O(() => {
1402
- const d = g.value;
1403
- return d ? e.options.filter((m) => m.name === d).map((m) => m.value) : [];
1565
+ const f = m.value;
1566
+ return f ? e.options.filter((p) => p.name === f).map((p) => p.value) : [];
1404
1567
  }), I = O(
1405
- () => Ot({
1568
+ () => Nt({
1406
1569
  images: e.images,
1407
1570
  swatchValues: v.value,
1408
- variantSwatchMap: p.value,
1409
- selectedVariantId: i.value?.numericId ?? null
1571
+ variantSwatchMap: g.value,
1572
+ selectedVariantId: a.value?.numericId ?? null
1410
1573
  })
1411
- ), y = O(() => {
1412
- const d = i.value;
1413
- if (!d?.image) return I.value;
1414
- if (!g.value) return d.image ? [d.image] : I.value;
1415
- const E = p.value.get(d.numericId);
1416
- return E ? I.value.filter((_) => _.variantIds.length === 0 ? !0 : _.variantIds.some(
1417
- (S) => p.value.get(S) === E
1418
- )) : d.image ? [d.image] : I.value;
1574
+ ), _ = O(() => {
1575
+ const f = a.value;
1576
+ if (!f?.image) return I.value;
1577
+ if (!m.value) return f.image ? [f.image] : I.value;
1578
+ const w = g.value.get(f.numericId);
1579
+ return w ? I.value.filter((E) => E.variantIds.length === 0 ? !0 : E.variantIds.some(
1580
+ (C) => g.value.get(C) === w
1581
+ )) : f.image ? [f.image] : I.value;
1419
1582
  }), R = O(() => {
1420
- const d = i.value;
1421
- if (!d) return { price: null, compareAtPrice: null, isOnSale: !1 };
1422
- const m = d.compareAtPrice !== null && d.compareAtPrice.amount > d.price.amount;
1423
- return { price: d.price, compareAtPrice: d.compareAtPrice, isOnSale: m };
1583
+ const f = a.value;
1584
+ if (!f) return { price: null, compareAtPrice: null, isOnSale: !1 };
1585
+ const p = f.compareAtPrice !== null && f.compareAtPrice.amount > f.price.amount;
1586
+ return { price: f.price, compareAtPrice: f.compareAtPrice, isOnSale: p };
1424
1587
  }), T = O(() => {
1425
- const d = c.value;
1426
- if (d.length === 0)
1588
+ const f = c.value;
1589
+ if (f.length === 0)
1427
1590
  return { priceRange: e.priceRange, compareAtPriceRange: null };
1428
- const m = d.map((h) => h.price), E = m.reduce((h, A) => h.amount < A.amount ? h : A), _ = m.reduce((h, A) => h.amount > A.amount ? h : A), S = d.map((h) => h.compareAtPrice).filter((h) => h !== null), C = S.length > 0 ? {
1429
- min: S.reduce((h, A) => h.amount < A.amount ? h : A),
1430
- max: S.reduce((h, A) => h.amount > A.amount ? h : A)
1591
+ const p = f.map((y) => y.price), w = p.reduce((y, S) => y.amount < S.amount ? y : S), E = p.reduce((y, S) => y.amount > S.amount ? y : S), C = f.map((y) => y.compareAtPrice).filter((y) => y !== null), P = C.length > 0 ? {
1592
+ min: C.reduce((y, S) => y.amount < S.amount ? y : S),
1593
+ max: C.reduce((y, S) => y.amount > S.amount ? y : S)
1431
1594
  } : null;
1432
- return { priceRange: { min: E, max: _ }, compareAtPriceRange: C };
1433
- }), N = O(() => {
1434
- const d = /* @__PURE__ */ new Set();
1435
- for (const m of f.value) d.add(m.name);
1436
- return d;
1437
- }), w = O(() => {
1438
- const d = new Set(l.value.map((m) => m.name));
1439
- return [...N.value].every((m) => d.has(m));
1595
+ return { priceRange: { min: w, max: E }, compareAtPriceRange: P };
1440
1596
  }), k = O(() => {
1441
- const d = s.value;
1442
- if (d !== null) return d;
1443
- const m = i.value;
1444
- if (!m?.image) return 1;
1445
- const E = y.value.findIndex((_) => _.url === m.image?.url);
1446
- return E >= 0 ? E + 1 : 1;
1597
+ const f = /* @__PURE__ */ new Set();
1598
+ for (const p of d.value) f.add(p.name);
1599
+ return f;
1600
+ }), b = O(() => {
1601
+ const f = new Set(l.value.map((p) => p.name));
1602
+ return [...k.value].every((p) => f.has(p));
1603
+ }), A = O(() => {
1604
+ const f = s.value;
1605
+ if (f !== null) return f;
1606
+ const p = a.value;
1607
+ if (!p?.image) return 1;
1608
+ const w = _.value.findIndex((E) => E.url === p.image?.url);
1609
+ return w >= 0 ? w + 1 : 1;
1447
1610
  });
1448
1611
  return u.add(
1449
- re(() => {
1450
- o.value, s.value = null;
1612
+ se(() => {
1613
+ n.value, s.value = null;
1451
1614
  })
1452
1615
  ), {
1453
1616
  product: e,
1454
1617
  // Reactive state
1455
1618
  variants: c,
1456
- selectedVariant: i,
1457
- options: f,
1458
- images: y,
1619
+ selectedVariant: a,
1620
+ options: d,
1621
+ images: _,
1459
1622
  price: R,
1460
1623
  priceRange: T,
1461
- carouselPosition: k,
1462
- isSelectionComplete: w,
1624
+ carouselPosition: A,
1625
+ isSelectionComplete: b,
1463
1626
  // Actions
1464
- selectOption(d) {
1465
- const m = o.value;
1466
- o.value = m.filter((E) => E.name !== d.name).concat(d);
1627
+ selectOption(f) {
1628
+ const p = n.value;
1629
+ n.value = p.filter((w) => w.name !== f.name).concat(f);
1467
1630
  },
1468
- setSelectedOptions(d) {
1469
- const m = new Set(d.map((_) => _.name)), E = o.value.filter((_) => !m.has(_.name));
1470
- o.value = [...E, ...d];
1631
+ setSelectedOptions(f) {
1632
+ const p = new Set(f.map((E) => E.name)), w = n.value.filter((E) => !p.has(E.name));
1633
+ n.value = [...w, ...f];
1471
1634
  },
1472
- setSelectedVariant(d) {
1473
- const m = c.value.find((_) => _.numericId === d);
1474
- if (!m) return;
1475
- const E = m.selectedOptions.filter((_) => !a.has(_.name));
1476
- o.value = E;
1635
+ setSelectedVariant(f) {
1636
+ const p = c.value.find((E) => E.numericId === f);
1637
+ if (!p) return;
1638
+ const w = p.selectedOptions.filter((E) => !i.has(E.name));
1639
+ n.value = w;
1477
1640
  },
1478
- setCarouselPosition(d) {
1479
- s.value = d;
1641
+ setCarouselPosition(f) {
1642
+ s.value = f;
1480
1643
  },
1481
- subscribe(d) {
1644
+ subscribe(f) {
1482
1645
  return u.add(
1483
- re(() => {
1484
- d({
1646
+ se(() => {
1647
+ f({
1485
1648
  variants: c.value,
1486
- selectedVariant: i.value,
1487
- options: f.value,
1488
- images: y.value,
1649
+ selectedVariant: a.value,
1650
+ options: d.value,
1651
+ images: _.value,
1489
1652
  price: R.value,
1490
1653
  priceRange: T.value,
1491
- carouselPosition: k.value,
1492
- isSelectionComplete: w.value
1654
+ carouselPosition: A.value,
1655
+ isSelectionComplete: b.value
1493
1656
  });
1494
1657
  })
1495
1658
  );
@@ -1499,141 +1662,141 @@ function Jt({
1499
1662
  }
1500
1663
  };
1501
1664
  }
1502
- function Tt(e, t) {
1665
+ function kt(e, t) {
1503
1666
  return t.length === 0 ? e : e.filter(
1504
1667
  (r) => t.every(
1505
- (n) => r.selectedOptions.some((a) => a.name === n.name && a.value === n.value)
1668
+ (o) => r.selectedOptions.some((i) => i.name === o.name && i.value === o.value)
1506
1669
  )
1507
1670
  );
1508
1671
  }
1509
- function Ae(e, t) {
1672
+ function Re(e, t) {
1510
1673
  return t.length === 0 ? e.length === 1 ? e[0] : null : e.find(
1511
1674
  (r) => t.every(
1512
- (n) => r.selectedOptions.some((a) => a.name === n.name && a.value === n.value)
1675
+ (o) => r.selectedOptions.some((i) => i.name === o.name && i.value === o.value)
1513
1676
  )
1514
1677
  ) ?? null;
1515
1678
  }
1516
- function kt({
1679
+ function Ot({
1517
1680
  variants: e,
1518
1681
  productOptions: t,
1519
1682
  selectedOptions: r,
1520
- breakoutOptions: n,
1521
- breakoutNames: a
1683
+ breakoutOptions: o,
1684
+ breakoutNames: i
1522
1685
  }) {
1523
- const o = /* @__PURE__ */ new Set();
1524
- for (const i of e)
1525
- for (const f of i.selectedOptions)
1526
- a.has(f.name) || o.add(`${f.name}:${f.value}`);
1686
+ const n = /* @__PURE__ */ new Set();
1687
+ for (const a of e)
1688
+ for (const d of a.selectedOptions)
1689
+ i.has(d.name) || n.add(`${d.name}:${d.value}`);
1527
1690
  const s = /* @__PURE__ */ new Map();
1528
- for (const i of t)
1529
- i.swatch && s.set(`${i.name}:${i.value}`, i.swatch);
1691
+ for (const a of t)
1692
+ a.swatch && s.set(`${a.name}:${a.value}`, a.swatch);
1530
1693
  const u = /* @__PURE__ */ new Set();
1531
- for (const i of r) u.add(`${i.name}:${i.value}`);
1532
- const c = /* @__PURE__ */ new Map(), l = [...n, ...r];
1533
- for (const i of t) {
1534
- if (a.has(i.name) || !o.has(`${i.name}:${i.value}`)) continue;
1535
- c.has(i.name) || c.set(i.name, []);
1536
- const f = l.filter((I) => I.name !== i.name).concat({ name: i.name, value: i.value }), g = [...n, ...f.filter((I) => !a.has(I.name))], p = Ae(e, g);
1694
+ for (const a of r) u.add(`${a.name}:${a.value}`);
1695
+ const c = /* @__PURE__ */ new Map(), l = [...o, ...r];
1696
+ for (const a of t) {
1697
+ if (i.has(a.name) || !n.has(`${a.name}:${a.value}`)) continue;
1698
+ c.has(a.name) || c.set(a.name, []);
1699
+ const d = l.filter((I) => I.name !== a.name).concat({ name: a.name, value: a.value }), m = [...o, ...d.filter((I) => !i.has(I.name))], g = Re(e, m);
1537
1700
  let v;
1538
- p ? p.availableForSale ? v = "available" : p.inventoryPolicy === "CONTINUE" ? v = "backorderable" : v = "sold-out" : v = "unavailable", c.get(i.name).push({
1539
- value: i.value,
1701
+ g ? g.availableForSale ? v = "available" : g.inventoryPolicy === "CONTINUE" ? v = "backorderable" : v = "sold-out" : v = "unavailable", c.get(a.name).push({
1702
+ value: a.value,
1540
1703
  status: v,
1541
- selected: u.has(`${i.name}:${i.value}`),
1542
- swatch: s.get(`${i.name}:${i.value}`) ?? null
1704
+ selected: u.has(`${a.name}:${a.value}`),
1705
+ swatch: s.get(`${a.name}:${a.value}`) ?? null
1543
1706
  });
1544
1707
  }
1545
- return Array.from(c.entries()).map(([i, f]) => ({ name: i, values: f }));
1708
+ return Array.from(c.entries()).map(([a, d]) => ({ name: a, values: d }));
1546
1709
  }
1547
- function Ot({
1710
+ function Nt({
1548
1711
  images: e,
1549
1712
  swatchValues: t,
1550
1713
  variantSwatchMap: r,
1551
- selectedVariantId: n
1714
+ selectedVariantId: o
1552
1715
  }) {
1553
1716
  if (t.length === 0)
1554
1717
  return [...e].sort((c, l) => c.position - l.position);
1555
- const a = n !== null ? r.get(n) ?? null : null, o = /* @__PURE__ */ new Map(), s = [];
1718
+ const i = o !== null ? r.get(o) ?? null : null, n = /* @__PURE__ */ new Map(), s = [];
1556
1719
  for (const c of e) {
1557
1720
  if (c.variantIds.length === 0) {
1558
1721
  s.push(c);
1559
1722
  continue;
1560
1723
  }
1561
1724
  let l = null;
1562
- for (const i of c.variantIds) {
1563
- const f = r.get(i);
1564
- if (f) {
1565
- l = f;
1725
+ for (const a of c.variantIds) {
1726
+ const d = r.get(a);
1727
+ if (d) {
1728
+ l = d;
1566
1729
  break;
1567
1730
  }
1568
1731
  }
1569
1732
  if (l) {
1570
- const i = o.get(l) ?? [];
1571
- i.push(c), o.set(l, i);
1733
+ const a = n.get(l) ?? [];
1734
+ a.push(c), n.set(l, a);
1572
1735
  } else
1573
1736
  s.push(c);
1574
1737
  }
1575
- for (const c of o.values())
1576
- c.sort((l, i) => l.position - i.position);
1738
+ for (const c of n.values())
1739
+ c.sort((l, a) => l.position - a.position);
1577
1740
  s.sort((c, l) => c.position - l.position);
1578
1741
  const u = [];
1579
- a && o.has(a) && u.push(...o.get(a));
1742
+ i && n.has(i) && u.push(...n.get(i));
1580
1743
  for (const c of t)
1581
- c !== a && o.has(c) && u.push(...o.get(c));
1744
+ c !== i && n.has(c) && u.push(...n.get(c));
1582
1745
  return u.push(...s), u;
1583
1746
  }
1584
- function Yt(e, t = {}) {
1585
- return new Promise((r, n) => {
1586
- const a = new XMLHttpRequest();
1587
- if (a.open(t.method || "GET", e, !0), t.headers) {
1588
- const o = t.headers;
1589
- for (const s in o) a.setRequestHeader(s, o[s]);
1747
+ function Wt(e, t = {}) {
1748
+ return new Promise((r, o) => {
1749
+ const i = new XMLHttpRequest();
1750
+ if (i.open(t.method || "GET", e, !0), t.headers) {
1751
+ const n = t.headers;
1752
+ for (const s in n) i.setRequestHeader(s, n[s]);
1590
1753
  }
1591
- if (t.signal && (t.signal.addEventListener("abort", () => a.abort()), t.signal.aborted)) {
1592
- n(new DOMException("Aborted", "AbortError"));
1754
+ if (t.signal && (t.signal.addEventListener("abort", () => i.abort()), t.signal.aborted)) {
1755
+ o(new DOMException("Aborted", "AbortError"));
1593
1756
  return;
1594
1757
  }
1595
- a.onload = () => {
1596
- const o = new Headers();
1597
- a.getAllResponseHeaders().trim().split(`\r
1758
+ i.onload = () => {
1759
+ const n = new Headers();
1760
+ i.getAllResponseHeaders().trim().split(`\r
1598
1761
  `).forEach((s) => {
1599
1762
  const [u, ...c] = s.split(": ");
1600
- u && o.append(u, c.join(": "));
1763
+ u && n.append(u, c.join(": "));
1601
1764
  }), r(
1602
- new Response(a.response, {
1603
- status: a.status,
1604
- statusText: a.statusText,
1605
- headers: o
1765
+ new Response(i.response, {
1766
+ status: i.status,
1767
+ statusText: i.statusText,
1768
+ headers: n
1606
1769
  })
1607
1770
  );
1608
- }, a.onerror = () => n(new TypeError("Network request failed")), a.ontimeout = () => n(new DOMException("Timeout", "TimeoutError")), a.onabort = () => n(new DOMException("Aborted", "AbortError")), a.send(t.body);
1771
+ }, i.onerror = () => o(new TypeError("Network request failed")), i.ontimeout = () => o(new DOMException("Timeout", "TimeoutError")), i.onabort = () => o(new DOMException("Aborted", "AbortError")), i.send(t.body);
1609
1772
  });
1610
1773
  }
1611
1774
  export {
1612
- nt as and,
1613
- Wt as batch,
1614
- Zt as computed,
1615
- Kt as createClient,
1616
- Jt as createProductCard,
1617
- en as effect,
1618
- Pt as eq,
1619
- Bt as exists,
1620
- Lt as fileStorage,
1621
- Ht as filter,
1622
- jt as getClient,
1623
- Ut as gt,
1624
- Ft as gte,
1775
+ et as and,
1776
+ tr as batch,
1777
+ rr as computed,
1778
+ Yt as createClient,
1779
+ zt as createProductCard,
1780
+ nr as effect,
1781
+ Ft as eq,
1782
+ jt as exists,
1783
+ Dt as fileStorage,
1784
+ Jt as filter,
1785
+ Kt as getClient,
1786
+ Vt as gt,
1787
+ Bt as gte,
1625
1788
  Mt as inValues,
1626
- Ct as isClientError,
1627
- Qt as isInitialized,
1628
- Ve as isRetryable,
1629
- ze as localStorageAdapter,
1630
- $t as lt,
1631
- Vt as lte,
1632
- Dt as notEq,
1633
- xt as notExists,
1634
- qt as notIn,
1635
- Gt as or,
1636
- tn as signal,
1789
+ Lt as isClientError,
1790
+ Xt as isInitialized,
1791
+ qt as isRetryable,
1792
+ Ke as localStorageAdapter,
1793
+ Gt as lt,
1794
+ xt as lte,
1795
+ Ut as notEq,
1796
+ Ht as notExists,
1797
+ $t as notIn,
1798
+ Qt as or,
1799
+ or as signal,
1637
1800
  $ as subscribe,
1638
- Yt as xhrFetch
1801
+ Wt as xhrFetch
1639
1802
  };