@kachingappz/bundles-js 1.1.10 → 1.2.1
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/bundles-js.iife.js +19 -19
- package/dist/index.d.ts +7 -2
- package/dist/index.js +247 -212
- package/dist/kaching-bundle-component/index.d.ts +7 -2
- package/dist/kaching-bundle-component/index.js +265 -230
- package/dist/react/index.cjs +19 -19
- package/dist/react/index.d.ts +7 -2
- package/dist/react/index.js +248 -213
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -1,22 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
[
|
|
2
|
+
"primaryBackground",
|
|
3
|
+
"secondaryBackground",
|
|
4
|
+
"primaryText",
|
|
5
|
+
"secondaryText",
|
|
6
|
+
"border",
|
|
7
|
+
"overlay",
|
|
8
|
+
"primaryAccent",
|
|
9
|
+
"primaryAccentText",
|
|
10
|
+
"badgeBackground",
|
|
11
|
+
"badgeText",
|
|
12
|
+
"error"
|
|
13
|
+
].map((e) => `brand_${e}`);
|
|
14
|
+
var e = /* @__PURE__ */ function(e) {
|
|
15
|
+
return e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e;
|
|
16
|
+
}({}), t = (e, t) => e.selectedVariants?.find((e) => e.productId === t)?.variantIds, n = (e, n) => t(e, n) !== void 0, r = (e, n, r) => t(e, n)?.includes(r) ?? !0, i = (e, t) => n(e, t.id) ? t.variants.filter((n) => r(e, t.id, n.id)).map((e) => e.id) : void 0, a = (e, t) => {
|
|
17
|
+
if (!t) return e;
|
|
18
|
+
let n = e.variants.filter((e) => t.includes(e.id)), r = e.options.map((e, t) => ({
|
|
19
|
+
...e,
|
|
20
|
+
optionValues: e.optionValues.filter((e) => n.some((n) => n.options[t] === e.name))
|
|
21
|
+
})), i = n.some((t) => t.id === e.selectedVariantId) ? e.selectedVariantId : n[0]?.id ?? e.selectedVariantId;
|
|
22
|
+
return {
|
|
23
|
+
...e,
|
|
24
|
+
variants: n,
|
|
25
|
+
options: r,
|
|
26
|
+
selectedVariantId: i,
|
|
27
|
+
availableForSale: n.some((e) => e.availableForSale)
|
|
28
|
+
};
|
|
29
|
+
}, o = (e, t) => c(e) ? l(e, t, /* @__PURE__ */ new Set()) : t, s = (e, t) => c(e) ? l(e, t, u(e)) : t, c = (e) => !!e.selectedVariants?.length, l = (e, t, n) => t.flatMap((t) => {
|
|
30
|
+
let r = i(e, t);
|
|
31
|
+
if (!r) return [t];
|
|
32
|
+
let o = a(t, [...r, ...t.variants.map((e) => e.id).filter((e) => n.has(e))]);
|
|
33
|
+
return o.variants.length ? [o] : [];
|
|
34
|
+
}), u = (e) => new Set([
|
|
35
|
+
...e.dealBars.flatMap(d),
|
|
36
|
+
...(e.progressiveGifts?.gifts ?? []).flatMap((e) => e.variantGIDs ?? []),
|
|
37
|
+
...(e.checkboxUpsells?.upsells ?? []).flatMap((e) => e.variantGIDs ?? [])
|
|
38
|
+
].map(p)), d = (e) => [
|
|
39
|
+
...e.freeGifts.flatMap((e) => e.variantGIDs ?? []),
|
|
40
|
+
...e.upsells.flatMap((e) => e.variantGIDs ?? []),
|
|
41
|
+
...(e.multipleGiftsSelectors ?? []).flatMap((e) => e.products.flatMap((e) => e.variantGIDs ?? [])),
|
|
42
|
+
...f(e)
|
|
43
|
+
], f = (t) => {
|
|
44
|
+
switch (t.dealBarType) {
|
|
45
|
+
case e.Bundle: return t.bundleProducts.flatMap((e) => e.productGID === "default" ? [] : e.variantGIDs ?? []);
|
|
46
|
+
case e.MixAndMatch: return t.bundleProducts.flatMap((e) => [...e.productGID === "default" ? [] : e.variantGIDs ?? [], ...(e.selectedProducts ?? []).flatMap((e) => e.variantGIDs ?? [])]);
|
|
47
|
+
default: return [];
|
|
48
|
+
}
|
|
49
|
+
}, p = (e) => Number(e.split("/").pop()), m = (e, t) => t ? e : e.map(h), h = (e) => {
|
|
50
|
+
let t = { ...e };
|
|
51
|
+
return delete t.selectedVariants, t;
|
|
52
|
+
}, g = (e, n, i) => {
|
|
53
|
+
let a = (e) => i !== void 0 && r(e, n.id, i), o = e.filter((e) => t(e, n.id)?.some((e) => n.variants.some((t) => t.id === e))), s = o.filter(a), c = [...s], l = o.filter((e) => !s.includes(e)), u = e.filter((e) => e.blockVisibility === "selected-products");
|
|
54
|
+
for (let e of u) e.selectedProductIds.map(Number).includes(n.id) && c.push(e);
|
|
55
|
+
let d = e.filter((e) => e.blockVisibility === "selected-collections");
|
|
56
|
+
for (let e of d) n.collectionIds.some((t) => e.selectedCollectionIds.map(Number).includes(t)) && c.push(e);
|
|
57
|
+
let f = e.filter((e) => e.blockVisibility === "excluded-products");
|
|
58
|
+
for (let e of f) !e.excludedProductIds.map(Number).includes(n.id) && !(e.excludedCollectionIds || []).some((e) => n.collectionIds.includes(e)) && c.push(e);
|
|
59
|
+
let p = e.filter((e) => e.blockVisibility === "all-products");
|
|
60
|
+
for (let e of p) c.push(e);
|
|
61
|
+
return i === void 0 ? c : [...c, ...l];
|
|
62
|
+
}, _ = (e, { language: t, country: n }) => {
|
|
63
|
+
let r = x(t, n), i = new Intl.NumberFormat(r, {
|
|
4
64
|
style: "currency",
|
|
5
65
|
currency: e,
|
|
6
66
|
currencyDisplay: "narrowSymbol"
|
|
7
|
-
}).formatToParts(1234567.89),
|
|
67
|
+
}).formatToParts(1234567.89), a = i.find((e) => e.type === "decimal")?.value, o = C(S(i.find((e) => e.type === "group")?.value), a, i.some((e) => e.type === "fraction")), s = i.findIndex(b), c = i.findLastIndex(b);
|
|
8
68
|
return [
|
|
9
|
-
...
|
|
10
|
-
|
|
11
|
-
...
|
|
69
|
+
...i.slice(0, s).map(v),
|
|
70
|
+
o,
|
|
71
|
+
...i.slice(c + 1).map(v)
|
|
12
72
|
].join("");
|
|
13
|
-
},
|
|
73
|
+
}, v = (e) => y(e.value), y = (e) => e.replace(/\s/g, " "), b = (e) => e.type === "integer" || e.type === "group" || e.type === "decimal" || e.type === "fraction", x = (e, t) => e && t ? `${e}-${t.toUpperCase()}` : e || (t ? t.toUpperCase() : "en"), S = (e) => e === void 0 ? void 0 : y(e).replace(/’/g, "'"), C = (e, t, n) => t === "," && e === "." ? n ? "{{amount_with_comma_separator}}" : "{{amount_no_decimals_with_comma_separator}}" : t === "," && e === " " ? n ? "{{amount_with_space_separator}}" : "{{amount_no_decimals_with_space_separator}}" : t === "." && e === " " ? "{{amount_with_period_and_space_separator}}" : t === "." && e === "'" ? "{{amount_with_apostrophe_separator}}" : n ? "{{amount}}" : "{{amount_no_decimals}}", w = ({ country: e, language: t }) => {
|
|
14
74
|
let n = [];
|
|
15
75
|
return e && n.push(`country: ${e}`), t && n.push(`language: ${t}`), n.length > 0 ? `@inContext(${n.join(", ")})` : "";
|
|
16
|
-
},
|
|
76
|
+
}, T = async (e, { useExternalMetafieldNamespace: t, useMetaobjects: n }) => n ? D(e, t) : E(e, t), E = async (e, t) => {
|
|
17
77
|
let n = (await e.query("\n query FetchDealBlocks($metafieldNamespace: String!) {\n shop {\n metafield(namespace: $metafieldNamespace, key: \"deal_blocks\") {\n value\n }\n }\n }\n ", { variables: { metafieldNamespace: t ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles" } })).shop.metafield?.value;
|
|
18
78
|
return n ? JSON.parse(n) : [];
|
|
19
|
-
},
|
|
79
|
+
}, D = async (e, t) => {
|
|
20
80
|
let n = t ? "app--2935586817--deal_block" : "$app:deal_block", r = [], i = null;
|
|
21
81
|
for (;;) {
|
|
22
82
|
let t = await e.query("\n query FetchDealBlockMetaobjects($type: String!, $cursor: String) {\n metaobjects(type: $type, first: 250, after: $cursor) {\n nodes {\n fields {\n key\n value\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n ", { variables: {
|
|
@@ -45,19 +105,19 @@ var e = (e, { language: n, country: s }) => {
|
|
|
45
105
|
"badgeText",
|
|
46
106
|
"error"
|
|
47
107
|
].map((e) => `brand_${e}`);
|
|
48
|
-
var
|
|
108
|
+
var O = /* @__PURE__ */ function(e) {
|
|
49
109
|
return e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e;
|
|
50
|
-
}({}),
|
|
110
|
+
}({}), k = async (e, { country: t, language: n, blockVisibility: r, excludedProductGIDs: i, selectedProductGIDs: a, selectedCollectionGIDs: o, limit: s = 1e3 }) => {
|
|
51
111
|
switch (r) {
|
|
52
|
-
case "selected-products": return a.slice(0,
|
|
112
|
+
case "selected-products": return a.slice(0, s);
|
|
53
113
|
case "all-products":
|
|
54
114
|
case "excluded-products": {
|
|
55
|
-
let a =
|
|
115
|
+
let a = w({
|
|
56
116
|
country: t,
|
|
57
117
|
language: n
|
|
58
|
-
}), o = [],
|
|
59
|
-
for (; o.length <
|
|
60
|
-
let t = Math.min(
|
|
118
|
+
}), o = [], c = null;
|
|
119
|
+
for (; o.length < s;) {
|
|
120
|
+
let t = Math.min(s - o.length, 250), n = await e.query(`
|
|
61
121
|
query FetchProductGIDs($limit: Int!, $cursor: String) ${a} {
|
|
62
122
|
products(first: $limit, after: $cursor) {
|
|
63
123
|
nodes {
|
|
@@ -71,10 +131,10 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
71
131
|
}
|
|
72
132
|
`, { variables: {
|
|
73
133
|
limit: t,
|
|
74
|
-
cursor:
|
|
134
|
+
cursor: c
|
|
75
135
|
} });
|
|
76
136
|
if (o.push(...n.products.nodes.map((e) => e.id)), !n.products.pageInfo.hasNextPage) break;
|
|
77
|
-
|
|
137
|
+
c = n.products.pageInfo.endCursor;
|
|
78
138
|
}
|
|
79
139
|
if (r === "excluded-products") {
|
|
80
140
|
let e = new Set(i);
|
|
@@ -83,7 +143,7 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
83
143
|
return o;
|
|
84
144
|
}
|
|
85
145
|
case "selected-collections": {
|
|
86
|
-
let r =
|
|
146
|
+
let r = w({
|
|
87
147
|
country: t,
|
|
88
148
|
language: n
|
|
89
149
|
}), i = (await e.query(`
|
|
@@ -100,21 +160,21 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
100
160
|
}
|
|
101
161
|
`, { variables: {
|
|
102
162
|
collectionGIDs: o,
|
|
103
|
-
limit: Math.min(
|
|
163
|
+
limit: Math.min(s, 250)
|
|
104
164
|
} })).nodes.filter((e) => e !== null).flatMap((e) => e.products.nodes.map((e) => e.id));
|
|
105
|
-
return Array.from(new Set(i)).slice(0,
|
|
165
|
+
return Array.from(new Set(i)).slice(0, s);
|
|
106
166
|
}
|
|
107
167
|
}
|
|
108
|
-
},
|
|
168
|
+
}, A = "\n id\n availableForSale\n price {\n amount\n }\n compareAtPrice {\n amount\n }\n selectedOptions {\n name\n value\n }\n image {\n id\n url(transform: $variantImageTransform)\n }\n unitPriceMeasurement {\n quantityUnit\n quantityValue\n referenceUnit\n referenceValue\n }\n requiresComponents\n sellingPlanAllocations(first: 100) @include(if: $includeSellingPlans) {\n nodes {\n sellingPlan {\n id\n }\n priceAdjustments {\n price {\n amount\n }\n compareAtPrice {\n amount\n }\n perDeliveryPrice {\n amount\n }\n }\n }\n }\n quantityAvailable @include(if: $includeAvailableQuantity)\n", j = async (e, { country: t, language: n, productIds: r, includeSellingPlans: i = !0, includeAvailableQuantity: a = !0, includeProductRating: o = !1, includeProductSubtitle: s = !1, includeProductTabFields: c = !1, productSubtitleMetafield: l = "descriptors.subtitle", useExternalMetafieldNamespace: u = !1, batchSize: d = 250, onBatchError: f, variantImageTransform: p = {
|
|
109
169
|
maxWidth: 200,
|
|
110
170
|
maxHeight: 200
|
|
111
171
|
} }) => {
|
|
112
172
|
if (!r.length) return [];
|
|
113
|
-
let
|
|
173
|
+
let m = r.map((e) => typeof e == "string" && e.startsWith("gid://") ? e : `gid://shopify/Product/${e}`), h = w({
|
|
114
174
|
country: t,
|
|
115
175
|
language: n
|
|
116
|
-
}),
|
|
117
|
-
query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $includeProductRating: Boolean!, $includeProductSubtitle: Boolean!, $includeProductTabFields: Boolean!, $subtitleNamespace: String!, $subtitleKey: String!, $metafieldNamespace: String!, $variantImageTransform: ImageTransformInput) ${
|
|
176
|
+
}), g = `
|
|
177
|
+
query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $includeProductRating: Boolean!, $includeProductSubtitle: Boolean!, $includeProductTabFields: Boolean!, $subtitleNamespace: String!, $subtitleKey: String!, $metafieldNamespace: String!, $variantImageTransform: ImageTransformInput) ${h} {
|
|
118
178
|
shop {
|
|
119
179
|
currencyRateConstant: metafield(namespace: $metafieldNamespace, key: "currency_rate_constant") {
|
|
120
180
|
value
|
|
@@ -148,7 +208,7 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
148
208
|
}
|
|
149
209
|
variants(first: 250) {
|
|
150
210
|
nodes {
|
|
151
|
-
${
|
|
211
|
+
${A}
|
|
152
212
|
}
|
|
153
213
|
}
|
|
154
214
|
collections(first: 50) {
|
|
@@ -214,50 +274,50 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
214
274
|
}
|
|
215
275
|
}
|
|
216
276
|
}
|
|
217
|
-
`,
|
|
218
|
-
for (let e = 0; e <
|
|
219
|
-
let
|
|
220
|
-
let [r,
|
|
277
|
+
`, _ = u ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles", v = l.indexOf("."), y = l.slice(0, v), b = l.slice(v + 1), x = [], S = Math.min(d, 250);
|
|
278
|
+
for (let e = 0; e < m.length; e += S) x.push(m.slice(e, e + S));
|
|
279
|
+
let C = 1, T = async (n) => {
|
|
280
|
+
let [r, l] = await Promise.all([e.query(g, { variables: {
|
|
221
281
|
productGIDs: n,
|
|
222
282
|
includeSellingPlans: i,
|
|
223
283
|
includeAvailableQuantity: a,
|
|
224
284
|
includeProductRating: o,
|
|
225
|
-
includeProductSubtitle:
|
|
226
|
-
includeProductTabFields:
|
|
227
|
-
subtitleNamespace:
|
|
228
|
-
subtitleKey:
|
|
229
|
-
metafieldNamespace:
|
|
230
|
-
variantImageTransform:
|
|
231
|
-
} }),
|
|
232
|
-
return r.shop.currencyRateConstant && (
|
|
285
|
+
includeProductSubtitle: s,
|
|
286
|
+
includeProductTabFields: c,
|
|
287
|
+
subtitleNamespace: y,
|
|
288
|
+
subtitleKey: b,
|
|
289
|
+
metafieldNamespace: _,
|
|
290
|
+
variantImageTransform: p
|
|
291
|
+
} }), c ? ee(e, t, n) : null]);
|
|
292
|
+
return r.shop.currencyRateConstant && (C = JSON.parse(r.shop.currencyRateConstant.value).amount / 1e6), l ? { nodes: r.nodes.map((e) => e && {
|
|
233
293
|
...e,
|
|
234
|
-
productType:
|
|
294
|
+
productType: l.get(e.id)
|
|
235
295
|
}) } : r;
|
|
236
|
-
},
|
|
237
|
-
if (
|
|
238
|
-
let e = await Promise.allSettled(
|
|
239
|
-
for (let t of e) t.status === "rejected" &&
|
|
240
|
-
|
|
241
|
-
} else
|
|
242
|
-
let
|
|
243
|
-
if (
|
|
244
|
-
let t = await Promise.allSettled(
|
|
296
|
+
}, E;
|
|
297
|
+
if (f) {
|
|
298
|
+
let e = await Promise.allSettled(x.map(T));
|
|
299
|
+
for (let t of e) t.status === "rejected" && f(t.reason instanceof Error ? t.reason : Error(String(t.reason)));
|
|
300
|
+
E = e.filter((e) => e.status === "fulfilled").flatMap((e) => e.value.nodes);
|
|
301
|
+
} else E = (await Promise.all(x.map(T))).flatMap((e) => e.nodes);
|
|
302
|
+
let D = E.filter((e) => e != null);
|
|
303
|
+
if (f) {
|
|
304
|
+
let t = await Promise.allSettled(D.map(async (t) => N(await M(e, t, {
|
|
245
305
|
includeSellingPlans: i,
|
|
246
306
|
includeAvailableQuantity: a,
|
|
247
|
-
variantImageTransform:
|
|
248
|
-
},
|
|
249
|
-
for (let e of t) e.status === "fulfilled" ? n.push(e.value) :
|
|
307
|
+
variantImageTransform: p
|
|
308
|
+
}, h), e.shopifyDomain, C))), n = [];
|
|
309
|
+
for (let e of t) e.status === "fulfilled" ? n.push(e.value) : f(e.reason instanceof Error ? e.reason : Error(String(e.reason)));
|
|
250
310
|
return n;
|
|
251
311
|
}
|
|
252
|
-
return (await Promise.all(
|
|
312
|
+
return (await Promise.all(D.map((t) => M(e, t, {
|
|
253
313
|
includeSellingPlans: i,
|
|
254
314
|
includeAvailableQuantity: a,
|
|
255
|
-
variantImageTransform:
|
|
256
|
-
},
|
|
257
|
-
},
|
|
315
|
+
variantImageTransform: p
|
|
316
|
+
}, h)))).map((t) => N(t, e.shopifyDomain, C));
|
|
317
|
+
}, ee = async (e, t, n) => {
|
|
258
318
|
try {
|
|
259
319
|
let r = await e.query(`
|
|
260
|
-
query FetchProductTypes($productGIDs: [ID!]!) ${
|
|
320
|
+
query FetchProductTypes($productGIDs: [ID!]!) ${w({ country: t })} {
|
|
261
321
|
nodes(ids: $productGIDs) {
|
|
262
322
|
... on Product {
|
|
263
323
|
id
|
|
@@ -270,7 +330,7 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
270
330
|
} catch (e) {
|
|
271
331
|
return console.error(e), null;
|
|
272
332
|
}
|
|
273
|
-
},
|
|
333
|
+
}, M = async (e, t, n, r = "") => {
|
|
274
334
|
if (t.variants.nodes.length < 250) return t;
|
|
275
335
|
let i = /* @__PURE__ */ new Set(), a = [], o = [], s = async (s) => {
|
|
276
336
|
let c = !0, l = null;
|
|
@@ -280,7 +340,7 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
280
340
|
product(id: $productGID) {
|
|
281
341
|
variants(first: 250, after: $cursor, reverse: $reverse) {
|
|
282
342
|
nodes {
|
|
283
|
-
${
|
|
343
|
+
${A}
|
|
284
344
|
}
|
|
285
345
|
pageInfo {
|
|
286
346
|
endCursor
|
|
@@ -306,7 +366,7 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
306
366
|
}
|
|
307
367
|
};
|
|
308
368
|
return await Promise.all([s(!1), s(!0)]), t.variants.nodes = [...a, ...o.reverse()], t;
|
|
309
|
-
},
|
|
369
|
+
}, N = (e, t, n) => {
|
|
310
370
|
let r = e.variants.nodes.map(({ unitPriceMeasurement: e, ...t }) => ({
|
|
311
371
|
id: Number(t.id.split("/").pop()),
|
|
312
372
|
availableForSale: t.availableForSale,
|
|
@@ -344,7 +404,7 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
344
404
|
defaultName: e.name,
|
|
345
405
|
name: e.name,
|
|
346
406
|
position: t + 1,
|
|
347
|
-
optionValues:
|
|
407
|
+
optionValues: re(n, t, r)
|
|
348
408
|
};
|
|
349
409
|
}), a = (e) => {
|
|
350
410
|
let t = e.priceAdjustments[0];
|
|
@@ -392,46 +452,31 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
392
452
|
text3: e.metafield3?.value || null,
|
|
393
453
|
text4: e.metafield4?.value || null
|
|
394
454
|
},
|
|
395
|
-
rating:
|
|
455
|
+
rating: te(e.reviewsRating, e.reviewsRatingCount),
|
|
396
456
|
subtitle: e.subtitle?.value || null,
|
|
397
457
|
productType: e.productType || null,
|
|
398
458
|
categoryGid: e.category?.id ?? null,
|
|
399
459
|
tags: e.tags ?? []
|
|
400
460
|
};
|
|
401
|
-
},
|
|
461
|
+
}, te = (e, t) => {
|
|
402
462
|
if (!e) return null;
|
|
403
|
-
let n =
|
|
463
|
+
let n = ne(e.value);
|
|
404
464
|
if (n === null) return null;
|
|
405
465
|
let r = Number(t?.value);
|
|
406
466
|
return {
|
|
407
467
|
value: n,
|
|
408
468
|
count: Number.isInteger(r) && r > 0 ? r : null
|
|
409
469
|
};
|
|
410
|
-
},
|
|
470
|
+
}, ne = (e) => {
|
|
411
471
|
try {
|
|
412
472
|
let { value: t, scale_max: n } = JSON.parse(e), r = Number(t) / Number(n) * 5;
|
|
413
473
|
return Number.isFinite(r) && r > 0 ? Math.min(5, r) : null;
|
|
414
474
|
} catch {
|
|
415
475
|
return null;
|
|
416
476
|
}
|
|
417
|
-
},
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
"secondaryBackground",
|
|
421
|
-
"primaryText",
|
|
422
|
-
"secondaryText",
|
|
423
|
-
"border",
|
|
424
|
-
"overlay",
|
|
425
|
-
"primaryAccent",
|
|
426
|
-
"primaryAccentText",
|
|
427
|
-
"badgeBackground",
|
|
428
|
-
"badgeText",
|
|
429
|
-
"error"
|
|
430
|
-
].map((e) => `brand_${e}`);
|
|
431
|
-
// ../bundles-storefront-api/dist/fetchGlobalConfig.js
|
|
432
|
-
var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalMetafieldNamespace: i }) => {
|
|
433
|
-
let a = i ? `${x}--kaching_bundles` : "$app:kaching_bundles", o = i ? x : "$app", c = s({ country: r }), { localization: { country: { currency: { isoCode: l } } }, shop: { moneyFormat: u, paymentSettings: { currencyCode: d }, currencyRateConstant: f, primaryDomain: p, settingsMetafield: m } } = await t.query(`
|
|
434
|
-
query config($metafieldNamespace: String!, $settingsNamespace: String!) ${c} {
|
|
477
|
+
}, re = (e, t, n) => e.filter((e) => n.filter((n) => n.options[t] === e.name).length > 0), P = "app--2935586817", F = async (e, { language: t, country: n, useExternalMetafieldNamespace: r }) => {
|
|
478
|
+
let i = r ? `${P}--kaching_bundles` : "$app:kaching_bundles", a = r ? P : "$app", o = w({ country: n }), { localization: { country: { currency: { isoCode: s } } }, shop: { moneyFormat: c, paymentSettings: { currencyCode: l }, currencyRateConstant: u, primaryDomain: d, settingsMetafield: f } } = await e.query(`
|
|
479
|
+
query config($metafieldNamespace: String!, $settingsNamespace: String!) ${o} {
|
|
435
480
|
localization {
|
|
436
481
|
country {
|
|
437
482
|
currency {
|
|
@@ -456,31 +501,31 @@ var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalM
|
|
|
456
501
|
}
|
|
457
502
|
}
|
|
458
503
|
`, { variables: {
|
|
459
|
-
metafieldNamespace:
|
|
460
|
-
settingsNamespace:
|
|
461
|
-
} }),
|
|
462
|
-
language:
|
|
463
|
-
country:
|
|
464
|
-
}),
|
|
504
|
+
metafieldNamespace: i,
|
|
505
|
+
settingsNamespace: a
|
|
506
|
+
} }), p = s === l ? c : _(s, {
|
|
507
|
+
language: t,
|
|
508
|
+
country: n
|
|
509
|
+
}), m = u ? I(u.value) : 1, h = f ? JSON.parse(f.value) : null, g = h?.feature_flags ?? {}, v = h?.custom_selectors ?? {};
|
|
465
510
|
return {
|
|
466
|
-
shopifyDomain:
|
|
467
|
-
moneyFormat:
|
|
468
|
-
locale:
|
|
469
|
-
liquidLocale:
|
|
470
|
-
country:
|
|
471
|
-
currencyRate:
|
|
511
|
+
shopifyDomain: d.host,
|
|
512
|
+
moneyFormat: p,
|
|
513
|
+
locale: t?.toLowerCase() || "en",
|
|
514
|
+
liquidLocale: t?.toLowerCase() || "en",
|
|
515
|
+
country: n ?? "US",
|
|
516
|
+
currencyRate: m,
|
|
472
517
|
marketId: 0,
|
|
473
518
|
productId: null,
|
|
474
|
-
storefrontAccessToken:
|
|
475
|
-
includeSellingPlans:
|
|
476
|
-
includeAvailableQuantity:
|
|
477
|
-
customApiHost:
|
|
478
|
-
keepQuantityInput:
|
|
479
|
-
ignoreDeselect:
|
|
480
|
-
ignoreUnitPrice:
|
|
481
|
-
requireCustomerLogin:
|
|
482
|
-
abTestsRunning:
|
|
483
|
-
webPixel:
|
|
519
|
+
storefrontAccessToken: h?.storefront_access_token ?? null,
|
|
520
|
+
includeSellingPlans: h?.include_selling_plans ?? !1,
|
|
521
|
+
includeAvailableQuantity: h?.include_available_quantity ?? !1,
|
|
522
|
+
customApiHost: h?.custom_api_host ?? null,
|
|
523
|
+
keepQuantityInput: h?.keep_quantity_input ?? !1,
|
|
524
|
+
ignoreDeselect: h?.ignore_deselect ?? !1,
|
|
525
|
+
ignoreUnitPrice: h?.ignore_unit_price ?? !1,
|
|
526
|
+
requireCustomerLogin: h?.require_customer_login ?? !1,
|
|
527
|
+
abTestsRunning: h?.ab_tests_running ?? !1,
|
|
528
|
+
webPixel: h?.web_pixel ?? !1,
|
|
484
529
|
b2bCustomer: !1,
|
|
485
530
|
isLoggedIn: !1,
|
|
486
531
|
preview: !1,
|
|
@@ -512,17 +557,17 @@ var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalM
|
|
|
512
557
|
"system.numbers_only": "Only numbers are allowed."
|
|
513
558
|
},
|
|
514
559
|
customSelectors: {
|
|
515
|
-
quantity:
|
|
516
|
-
addToCartButton:
|
|
517
|
-
variantPicker:
|
|
518
|
-
price:
|
|
519
|
-
priceCompare:
|
|
560
|
+
quantity: v.quantity ?? null,
|
|
561
|
+
addToCartButton: v.add_to_cart_button ?? null,
|
|
562
|
+
variantPicker: v.variant_picker ?? null,
|
|
563
|
+
price: v.price ?? null,
|
|
564
|
+
priceCompare: v.price_compare ?? null
|
|
520
565
|
},
|
|
521
|
-
shopCustomStyles:
|
|
522
|
-
featureFlags:
|
|
523
|
-
brandColors:
|
|
566
|
+
shopCustomStyles: h?.shop_custom_styles ?? "",
|
|
567
|
+
featureFlags: g,
|
|
568
|
+
brandColors: h?.brand_colors ?? null
|
|
524
569
|
};
|
|
525
|
-
},
|
|
570
|
+
}, I = (e) => JSON.parse(e).amount / 1e6, L = async (e, t, n = 200) => {
|
|
526
571
|
let r = [...new Set(t.filter(Boolean).filter((e) => !e.startsWith("placeholder")))];
|
|
527
572
|
if (r.length === 0) return [];
|
|
528
573
|
let i = [];
|
|
@@ -534,10 +579,10 @@ var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalM
|
|
|
534
579
|
gid: e.id,
|
|
535
580
|
url: e.image.url
|
|
536
581
|
}] : []);
|
|
537
|
-
},
|
|
538
|
-
let i = [...new Set(t.dealBars.flatMap((e) => e.dealBarType ===
|
|
582
|
+
}, R = 100, z = async (e, { dealBlock: t, country: n, language: r }) => {
|
|
583
|
+
let i = [...new Set(t.dealBars.flatMap((e) => e.dealBarType === O.MixAndMatch ? e.bundleProducts : []).flatMap((e) => (e.selectedCollections ?? []).map((e) => e.id)))];
|
|
539
584
|
if (i.length === 0) return [];
|
|
540
|
-
let a =
|
|
585
|
+
let a = w({
|
|
541
586
|
country: n,
|
|
542
587
|
language: r
|
|
543
588
|
}), o = await e.query(`
|
|
@@ -545,7 +590,7 @@ var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalM
|
|
|
545
590
|
nodes(ids: $collectionGIDs) {
|
|
546
591
|
... on Collection {
|
|
547
592
|
id
|
|
548
|
-
products(first: ${
|
|
593
|
+
products(first: ${R}) {
|
|
549
594
|
nodes {
|
|
550
595
|
id
|
|
551
596
|
variants(first: 1) {
|
|
@@ -560,77 +605,77 @@ var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalM
|
|
|
560
605
|
}
|
|
561
606
|
`, { variables: { collectionGIDs: i } });
|
|
562
607
|
return [...new Set(o.nodes.filter((e) => e !== null).flatMap((e) => e.products.nodes).filter((e) => !e.variants.nodes.some((e) => e.requiresComponents)).map((e) => e.id))];
|
|
563
|
-
},
|
|
564
|
-
...
|
|
565
|
-
...
|
|
566
|
-
...
|
|
567
|
-
...
|
|
568
|
-
...
|
|
569
|
-
...
|
|
570
|
-
...
|
|
571
|
-
...
|
|
572
|
-
...
|
|
573
|
-
...
|
|
574
|
-
...
|
|
575
|
-
...
|
|
576
|
-
...
|
|
577
|
-
].filter((e) => e != null && !e.includes("placeholder")),
|
|
608
|
+
}, B = (e) => [
|
|
609
|
+
...V(e),
|
|
610
|
+
...H(e),
|
|
611
|
+
...U(e),
|
|
612
|
+
...W(e),
|
|
613
|
+
...G(e),
|
|
614
|
+
...K(e),
|
|
615
|
+
...q(e),
|
|
616
|
+
...J(e),
|
|
617
|
+
...Y(e),
|
|
618
|
+
...X(e),
|
|
619
|
+
...ie(e),
|
|
620
|
+
...ae(e),
|
|
621
|
+
...oe(e)
|
|
622
|
+
].filter((e) => e != null && !e.includes("placeholder")), V = (e) => e.dealBars.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), H = (e) => e.dealBars.flatMap((e) => e.dealBarType === O.Bundle ? e.bundleProducts.map((e) => e.mediaImageGID) : []).filter((e) => e != null), U = (e) => e.dealBars.map(({ freeGifts: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), W = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => (e || []).map((e) => e.mediaImageGID)).filter((e) => e != null), G = (e) => e.dealBars.map(({ upsells: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), K = (e) => e.swatchOptions ? e.swatchOptions.reduce((e, t) => {
|
|
578
623
|
let n = t.images.map((e) => e.mediaImageGID).filter((e) => e != null);
|
|
579
624
|
return [...e, ...n];
|
|
580
|
-
}, []) : [],
|
|
625
|
+
}, []) : [], q = (e) => {
|
|
581
626
|
if (!e.collectionBreaksEnabled || !e.collectionBreaks) return [];
|
|
582
627
|
let t = e.collectionBreaks.mediaImageGID;
|
|
583
628
|
return t ? [t] : [];
|
|
584
|
-
},
|
|
629
|
+
}, J = (e) => e.progressiveGifts ? [
|
|
585
630
|
...e.progressiveGifts.gifts?.map((e) => e.mediaImageGID) || [],
|
|
586
631
|
e.progressiveGifts.style?.lockedMediaImageGID,
|
|
587
632
|
e.progressiveGifts.dealBarStyle?.lockedMediaImageGID
|
|
588
|
-
].filter((e) => e != null) : [],
|
|
633
|
+
].filter((e) => e != null) : [], Y = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), X = (e) => e.dealBars.map((e) => e.productPersonalisation?.mediaImageGID).filter((e) => e != null), ie = (e) => {
|
|
589
634
|
let t = e.dealBars.map((e) => e.highlights?.customIconGID).filter((e) => e != null), n = e.subscriptions?.highlights?.customIconGID;
|
|
590
635
|
return n ? [...t, n] : t;
|
|
591
|
-
},
|
|
636
|
+
}, ae = (e) => (e.badges || []).flatMap((e) => e.badgeType === "custom" && e.imageGID ? [e.imageGID] : []), oe = (e) => !e.savingsSummaryEnabled || !e.savingsSummary ? [] : e.savingsSummary.customIconGID ? [e.savingsSummary.customIconGID] : [], se = (e, { includeMixAndMatchSwapProducts: t = !0 } = {}) => {
|
|
592
637
|
let n = [
|
|
593
|
-
...
|
|
594
|
-
...
|
|
595
|
-
...
|
|
596
|
-
...
|
|
597
|
-
...
|
|
598
|
-
...
|
|
599
|
-
...
|
|
600
|
-
...
|
|
638
|
+
...ce(e),
|
|
639
|
+
...le(e),
|
|
640
|
+
...ue(e),
|
|
641
|
+
...de(e),
|
|
642
|
+
...fe(e),
|
|
643
|
+
...pe(e, t),
|
|
644
|
+
...me(e),
|
|
645
|
+
...he(e)
|
|
601
646
|
];
|
|
602
647
|
return Array.from(new Set(n.filter((e) => e != null)));
|
|
603
|
-
},
|
|
648
|
+
}, ce = (e) => e.dealBars.flatMap(({ freeGifts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), le = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => e ? e.flatMap((e) => e.products ? e.products.map((e) => e.id) : []) : []).filter((e) => e != null), ue = (e) => e.progressiveGiftsEnabled && e.progressiveGifts?.gifts.map((e) => e.productGID).filter((e) => e != null) || [], de = (e) => e.dealBars.flatMap(({ upsells: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), fe = (e) => e.dealBars.filter((e) => e.dealBarType === O.Bundle).flatMap(({ bundleProducts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null).filter((e) => e !== "default"), pe = (e, t) => e.dealBars.filter((e) => e.dealBarType === O.MixAndMatch).flatMap(({ bundleProducts: e }) => e ? e.flatMap((e) => [e.productGID, ...t ? e.selectedProducts?.map((e) => e.id) ?? [] : []]) : []).filter((e) => e != null).filter((e) => e !== "default"), me = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.map((e) => e.productGID).filter((e) => e != null), he = (e) => e.dealBars.filter((e) => e.dealBarType === O.Sku).flatMap(({ productGID: e }) => e ? [e] : []), Z = class extends Error {
|
|
604
649
|
constructor({ status: e, operationName: t, graphqlErrors: n }) {
|
|
605
650
|
let r = n.length ? `: ${n.join("; ")}` : "";
|
|
606
651
|
super(`Storefront API ${t ?? "query"} failed (HTTP ${e})${r}`), this.name = "StorefrontApiError", this.status = e, this.operationName = t, this.graphqlErrors = n;
|
|
607
652
|
}
|
|
608
|
-
},
|
|
653
|
+
}, ge = async (e, t) => {
|
|
609
654
|
let n = await e.text();
|
|
610
655
|
if (!n) throw Error("Empty graphql response");
|
|
611
656
|
let r;
|
|
612
657
|
try {
|
|
613
658
|
r = JSON.parse(n);
|
|
614
659
|
} catch (n) {
|
|
615
|
-
throw e.ok ? n : new
|
|
660
|
+
throw e.ok ? n : new Z({
|
|
616
661
|
status: e.status,
|
|
617
662
|
operationName: t,
|
|
618
663
|
graphqlErrors: []
|
|
619
664
|
});
|
|
620
665
|
}
|
|
621
|
-
if (!e.ok || r.data === null || r.data === void 0) throw new
|
|
666
|
+
if (!e.ok || r.data === null || r.data === void 0) throw new Z({
|
|
622
667
|
status: e.status,
|
|
623
668
|
operationName: t,
|
|
624
669
|
graphqlErrors: (r.errors ?? []).map(({ message: e }) => e).filter(Boolean)
|
|
625
670
|
});
|
|
626
671
|
return r.data;
|
|
627
|
-
},
|
|
672
|
+
}, _e = class {
|
|
628
673
|
constructor(e, t) {
|
|
629
674
|
this.storefrontApiVersion = "2026-07", this.storefrontAccessToken = t, this.shopifyDomain = e;
|
|
630
675
|
}
|
|
631
676
|
async query(e, t) {
|
|
632
677
|
let n = t?.variables ?? {}, r = `https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`, i = e.match(/query\s+(\w+)/)?.[1];
|
|
633
|
-
return i && (r += `?operation_name=${i}`),
|
|
678
|
+
return i && (r += `?operation_name=${i}`), ge(await fetch(r, {
|
|
634
679
|
method: "POST",
|
|
635
680
|
headers: {
|
|
636
681
|
"Content-Type": "application/json",
|
|
@@ -642,16 +687,6 @@ var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalM
|
|
|
642
687
|
})
|
|
643
688
|
}), i);
|
|
644
689
|
}
|
|
645
|
-
}, Z = (e, t) => {
|
|
646
|
-
let n = [], r = e.filter((e) => e.blockVisibility === "selected-products");
|
|
647
|
-
for (let e of r) e.selectedProductIds.map(Number).includes(t.id) && n.push(e);
|
|
648
|
-
let i = e.filter((e) => e.blockVisibility === "selected-collections");
|
|
649
|
-
for (let e of i) t.collectionIds.some((t) => e.selectedCollectionIds.map(Number).includes(t)) && n.push(e);
|
|
650
|
-
let a = e.filter((e) => e.blockVisibility === "excluded-products");
|
|
651
|
-
for (let e of a) !e.excludedProductIds.map(Number).includes(t.id) && !(e.excludedCollectionIds || []).some((e) => t.collectionIds.includes(e)) && n.push(e);
|
|
652
|
-
let o = e.filter((e) => e.blockVisibility === "all-products");
|
|
653
|
-
for (let e of o) n.push(e);
|
|
654
|
-
return n;
|
|
655
690
|
};
|
|
656
691
|
[
|
|
657
692
|
"primaryBackground",
|
|
@@ -666,20 +701,20 @@ var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalM
|
|
|
666
701
|
"badgeText",
|
|
667
702
|
"error"
|
|
668
703
|
].map((e) => `brand_${e}`);
|
|
669
|
-
var
|
|
704
|
+
var ve = /* @__PURE__ */ function(e) {
|
|
670
705
|
return e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e;
|
|
671
|
-
}({}),
|
|
706
|
+
}({}), ye = async (e, t, { country: n, language: r }) => {
|
|
672
707
|
let i = t.collectionBreaks;
|
|
673
708
|
if (!t.collectionBreaksEnabled || !i) return;
|
|
674
709
|
let a;
|
|
675
|
-
a = i.visibility === "deal-products" ? await
|
|
710
|
+
a = i.visibility === "deal-products" ? await k(e, {
|
|
676
711
|
country: n,
|
|
677
712
|
language: r,
|
|
678
713
|
blockVisibility: t.blockVisibility,
|
|
679
714
|
excludedProductGIDs: (t.excludedProductIds || []).map((e) => `gid://shopify/Product/${e}`),
|
|
680
|
-
selectedProductGIDs:
|
|
715
|
+
selectedProductGIDs: [...t.selectedProductIds || [], ...(t.selectedVariants || []).map(({ productId: e }) => e)].map((e) => `gid://shopify/Product/${e}`),
|
|
681
716
|
selectedCollectionGIDs: (t.selectedCollectionIds || []).map((e) => `gid://shopify/Collection/${e}`)
|
|
682
|
-
}) : await
|
|
717
|
+
}) : await k(e, {
|
|
683
718
|
country: n,
|
|
684
719
|
language: r,
|
|
685
720
|
blockVisibility: i.visibility,
|
|
@@ -687,14 +722,14 @@ var ne = /* @__PURE__ */ function(e) {
|
|
|
687
722
|
selectedProductGIDs: (i.selectedProducts || []).map(({ id: e }) => e),
|
|
688
723
|
selectedCollectionGIDs: (i.selectedCollections || []).map(({ id: e }) => e)
|
|
689
724
|
});
|
|
690
|
-
let
|
|
725
|
+
let s = await j(e, {
|
|
691
726
|
country: n,
|
|
692
727
|
language: r,
|
|
693
728
|
productIds: a.map((e) => Number(e.split("/").pop())),
|
|
694
729
|
useExternalMetafieldNamespace: !0
|
|
695
|
-
}),
|
|
696
|
-
return o
|
|
697
|
-
},
|
|
730
|
+
}), c = i.visibility === "deal-products" && t.blockVisibility === "excluded-products";
|
|
731
|
+
return o(t, s).filter((e) => e.availableForSale && (!c || g([t], e).length > 0));
|
|
732
|
+
}, be = ({ language: e, dealBlockId: t }) => {
|
|
698
733
|
let n = {
|
|
699
734
|
"system.out_of_stock": "There's not enough items in our stock, please select smaller bundle.",
|
|
700
735
|
"system.invalid_variant": "Sorry, this is not currently available.",
|
|
@@ -721,13 +756,13 @@ var ne = /* @__PURE__ */ function(e) {
|
|
|
721
756
|
"system.numbers_only": "Only numbers are allowed.",
|
|
722
757
|
"system.personalisation_required_alert": "Please add personalisation for every item to continue.",
|
|
723
758
|
"system.gifts_required_alert": "Please choose your free gifts"
|
|
724
|
-
}, r = e ?
|
|
759
|
+
}, r = e ? xe(e) : void 0;
|
|
725
760
|
return {
|
|
726
761
|
...n,
|
|
727
762
|
...r?.system,
|
|
728
763
|
...r?.dealBlocks[t]
|
|
729
764
|
};
|
|
730
|
-
},
|
|
765
|
+
}, xe = (e) => {
|
|
731
766
|
if (typeof document > "u") return;
|
|
732
767
|
let t = document.querySelector("script#kaching-bundles-translations");
|
|
733
768
|
if (!t?.textContent) return;
|
|
@@ -739,70 +774,70 @@ var ne = /* @__PURE__ */ function(e) {
|
|
|
739
774
|
}
|
|
740
775
|
let r = Q(e);
|
|
741
776
|
return n.find((e) => Q(e.locale) === r)?.translations;
|
|
742
|
-
}, Q = (e) => e.toLowerCase().replace(/_/g, "-"),
|
|
777
|
+
}, Q = (e) => e.toLowerCase().replace(/_/g, "-"), Se = "2026-07", Ce = async (e, { productId: t, dealBlockId: n, abTestVariantId: r, country: i = void 0, language: a = void 0 }) => {
|
|
743
778
|
try {
|
|
744
|
-
let o = [Number(t.split("/").pop())],
|
|
745
|
-
i ||=
|
|
746
|
-
let l = await
|
|
779
|
+
let o = [Number(t.split("/").pop())], c = new De(e);
|
|
780
|
+
i ||= c.i18n?.country, a ||= c.i18n?.language;
|
|
781
|
+
let l = await F(c, {
|
|
747
782
|
language: a,
|
|
748
783
|
country: i,
|
|
749
784
|
useExternalMetafieldNamespace: !0
|
|
750
785
|
});
|
|
751
|
-
|
|
752
|
-
let u = l.storefrontAccessToken ? new
|
|
786
|
+
c.shopifyDomain = l.shopifyDomain;
|
|
787
|
+
let u = l.storefrontAccessToken ? new _e(l.shopifyDomain, l.storefrontAccessToken) : c, [d, f] = await Promise.all([j(u, {
|
|
753
788
|
country: i,
|
|
754
789
|
language: a,
|
|
755
790
|
productIds: o,
|
|
756
791
|
useExternalMetafieldNamespace: !0
|
|
757
|
-
}),
|
|
792
|
+
}), T(u, {
|
|
758
793
|
useExternalMetafieldNamespace: !0,
|
|
759
794
|
useMetaobjects: l.featureFlags.storefront_metaobjects
|
|
760
|
-
})]), p = d[0];
|
|
761
|
-
if (!
|
|
762
|
-
let
|
|
763
|
-
if (!
|
|
764
|
-
let
|
|
765
|
-
otherProductGIDs:
|
|
795
|
+
})]), p = m(f, l.featureFlags.selected_variants), h = d[0];
|
|
796
|
+
if (!h) return null;
|
|
797
|
+
let _ = g(p, h), v = n ? _.filter((e) => e.id === n || e.nanoId === n) : _, y = (r ? v.find((e) => e.abTestVariantId === r) : void 0) ?? v[0] ?? _[0];
|
|
798
|
+
if (!y) return null;
|
|
799
|
+
let b = se(y, { includeMixAndMatchSwapProducts: !1 }), x = $(u, y, {
|
|
800
|
+
otherProductGIDs: b,
|
|
766
801
|
country: i,
|
|
767
802
|
language: a
|
|
768
|
-
}), [
|
|
769
|
-
|
|
803
|
+
}), [S, C, w] = await Promise.all([
|
|
804
|
+
j(u, {
|
|
770
805
|
country: i,
|
|
771
806
|
language: a,
|
|
772
|
-
productIds:
|
|
807
|
+
productIds: b,
|
|
773
808
|
useExternalMetafieldNamespace: !0
|
|
774
809
|
}),
|
|
775
|
-
|
|
776
|
-
|
|
810
|
+
L(u, B(y), 300),
|
|
811
|
+
be({
|
|
777
812
|
language: a,
|
|
778
|
-
dealBlockId:
|
|
813
|
+
dealBlockId: y.id
|
|
779
814
|
})
|
|
780
815
|
]);
|
|
781
816
|
return {
|
|
782
817
|
data: {
|
|
783
818
|
config: l,
|
|
784
|
-
dealBlock:
|
|
785
|
-
product:
|
|
786
|
-
otherProducts:
|
|
787
|
-
mediaImages:
|
|
788
|
-
translations:
|
|
819
|
+
dealBlock: y,
|
|
820
|
+
product: h,
|
|
821
|
+
otherProducts: s(y, S),
|
|
822
|
+
mediaImages: C,
|
|
823
|
+
translations: w
|
|
789
824
|
},
|
|
790
|
-
modalProducts:
|
|
825
|
+
modalProducts: x
|
|
791
826
|
};
|
|
792
827
|
} catch (e) {
|
|
793
828
|
return console.error(e), null;
|
|
794
829
|
}
|
|
795
|
-
},
|
|
796
|
-
let [r, i] = await Promise.all([
|
|
830
|
+
}, $ = async (e, t, n) => {
|
|
831
|
+
let [r, i] = await Promise.all([we(e, t, n), Ee(e, t, n)]);
|
|
797
832
|
return {
|
|
798
833
|
mixAndMatchSwapProducts: r,
|
|
799
834
|
collectionBreaksProducts: i
|
|
800
835
|
};
|
|
801
|
-
},
|
|
836
|
+
}, we = async (e, t, { otherProductGIDs: n, country: r, language: i }) => {
|
|
802
837
|
try {
|
|
803
838
|
let a = [];
|
|
804
839
|
try {
|
|
805
|
-
a = await
|
|
840
|
+
a = await z(e, {
|
|
806
841
|
dealBlock: t,
|
|
807
842
|
country: r,
|
|
808
843
|
language: i
|
|
@@ -810,26 +845,26 @@ var ne = /* @__PURE__ */ function(e) {
|
|
|
810
845
|
} catch (e) {
|
|
811
846
|
console.error(e);
|
|
812
847
|
}
|
|
813
|
-
let o = new Set(n),
|
|
814
|
-
return
|
|
848
|
+
let o = new Set(n), c = [.../* @__PURE__ */ new Set([...Te(t), ...a])].filter((e) => !o.has(e));
|
|
849
|
+
return c.length ? s(t, await j(e, {
|
|
815
850
|
country: r,
|
|
816
851
|
language: i,
|
|
817
|
-
productIds:
|
|
852
|
+
productIds: c,
|
|
818
853
|
useExternalMetafieldNamespace: !0
|
|
819
|
-
}) : [];
|
|
854
|
+
})) : [];
|
|
820
855
|
} catch (e) {
|
|
821
856
|
return console.error(e), [];
|
|
822
857
|
}
|
|
823
|
-
},
|
|
858
|
+
}, Te = (e) => e.dealBars.flatMap((e) => e.dealBarType === ve.MixAndMatch ? e.bundleProducts.flatMap((e) => (e.selectedProducts ?? []).map((e) => e.id)) : []), Ee = async (e, t, { country: n, language: r }) => {
|
|
824
859
|
try {
|
|
825
|
-
return await
|
|
860
|
+
return await ye(e, t, {
|
|
826
861
|
country: n,
|
|
827
862
|
language: r
|
|
828
863
|
}) ?? [];
|
|
829
864
|
} catch (e) {
|
|
830
865
|
return console.error(e), [];
|
|
831
866
|
}
|
|
832
|
-
},
|
|
867
|
+
}, De = class {
|
|
833
868
|
constructor(e) {
|
|
834
869
|
this.storefront = e, this.shopifyDomain = "";
|
|
835
870
|
}
|
|
@@ -842,7 +877,7 @@ var ne = /* @__PURE__ */ function(e) {
|
|
|
842
877
|
}
|
|
843
878
|
if ("request" in this.storefront) return (await this.storefront.request(e, t)).data;
|
|
844
879
|
if ("shopifyDomain" in this.storefront && "storefrontAccessToken" in this.storefront) {
|
|
845
|
-
let n = await fetch(`https://${this.storefront.shopifyDomain}/api/${
|
|
880
|
+
let n = await fetch(`https://${this.storefront.shopifyDomain}/api/${Se}/graphql.json`, {
|
|
846
881
|
body: JSON.stringify({
|
|
847
882
|
query: e,
|
|
848
883
|
variables: t?.variables
|
|
@@ -872,9 +907,9 @@ var ne = /* @__PURE__ */ function(e) {
|
|
|
872
907
|
get i18n() {
|
|
873
908
|
if ("i18n" in this.storefront) return this.storefront.i18n;
|
|
874
909
|
}
|
|
875
|
-
},
|
|
910
|
+
}, Oe = async (e, t) => {
|
|
876
911
|
try {
|
|
877
|
-
let n = await
|
|
912
|
+
let n = await Ce(e, t);
|
|
878
913
|
if (!n) return null;
|
|
879
914
|
let { config: r, dealBlock: i, product: a, otherProducts: o, mediaImages: s, translations: c } = n.data, { mixAndMatchSwapProducts: l, collectionBreaksProducts: u } = await n.modalProducts;
|
|
880
915
|
return {
|
|
@@ -891,4 +926,4 @@ var ne = /* @__PURE__ */ function(e) {
|
|
|
891
926
|
return console.error(e), null;
|
|
892
927
|
}
|
|
893
928
|
};
|
|
894
|
-
export {
|
|
929
|
+
export { Oe as fetchKachingBundlesData };
|