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