@kachingappz/bundles-js 1.1.1 → 1.1.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/dist/bundles-js.iife.js +2 -2
- package/dist/index.d.ts +3 -4
- package/dist/index.js +7 -8
- package/dist/kaching-bundle-component/index.d.ts +3 -4
- package/dist/kaching-bundle-component/index.js +158 -156
- package/dist/react/index.cjs +12 -12
- package/dist/react/index.d.ts +3 -4
- package/dist/react/index.js +114 -115
- package/package.json +1 -1
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
const F = (e, t) => {
|
|
2
|
-
const
|
|
2
|
+
const s = [], a = e.filter(
|
|
3
3
|
(r) => r.blockVisibility === "selected-products"
|
|
4
4
|
);
|
|
5
|
-
for (const r of
|
|
6
|
-
r.selectedProductIds.map(Number).includes(t.id) &&
|
|
5
|
+
for (const r of a)
|
|
6
|
+
r.selectedProductIds.map(Number).includes(t.id) && s.push(r);
|
|
7
7
|
const n = e.filter(
|
|
8
8
|
(r) => r.blockVisibility === "selected-collections"
|
|
9
9
|
);
|
|
10
10
|
for (const r of n)
|
|
11
11
|
t.collectionIds.some(
|
|
12
12
|
(m) => r.selectedCollectionIds.map(Number).includes(m)
|
|
13
|
-
) &&
|
|
13
|
+
) && s.push(r);
|
|
14
14
|
const i = e.filter(
|
|
15
15
|
(r) => r.blockVisibility === "excluded-products"
|
|
16
16
|
);
|
|
17
17
|
for (const r of i)
|
|
18
18
|
!r.excludedProductIds.map(Number).includes(t.id) && !(r.excludedCollectionIds || []).some(
|
|
19
19
|
(m) => t.collectionIds.includes(m)
|
|
20
|
-
) &&
|
|
20
|
+
) && s.push(r);
|
|
21
21
|
const o = e.filter(
|
|
22
22
|
(r) => r.blockVisibility === "all-products"
|
|
23
23
|
);
|
|
24
24
|
for (const r of o)
|
|
25
|
-
|
|
26
|
-
return
|
|
27
|
-
}, z = (e, { language: t, country:
|
|
25
|
+
s.push(r);
|
|
26
|
+
return s;
|
|
27
|
+
}, z = (e, { language: t, country: s }) => {
|
|
28
28
|
var h, g;
|
|
29
|
-
const
|
|
29
|
+
const a = R(t, s), n = new Intl.NumberFormat(a, {
|
|
30
30
|
style: "currency",
|
|
31
31
|
currency: e,
|
|
32
32
|
currencyDisplay: "narrowSymbol"
|
|
@@ -42,20 +42,20 @@ const F = (e, t) => {
|
|
|
42
42
|
m,
|
|
43
43
|
...n.slice(u + 1).map(x)
|
|
44
44
|
].join("");
|
|
45
|
-
}, x = (e) => L(e.value), L = (e) => e.replace(/\s/g, " "), C = (e) => e.type === "integer" || e.type === "group" || e.type === "decimal" || e.type === "fraction", R = (e, t) => e && t ? `${e}-${t.toUpperCase()}` : e || (t ? t.toUpperCase() : "en"), Q = (e) => e === void 0 ? void 0 : L(e).replace(/’/g, "'"), J = (e, t,
|
|
45
|
+
}, x = (e) => L(e.value), L = (e) => e.replace(/\s/g, " "), C = (e) => e.type === "integer" || e.type === "group" || e.type === "decimal" || e.type === "fraction", R = (e, t) => e && t ? `${e}-${t.toUpperCase()}` : e || (t ? t.toUpperCase() : "en"), Q = (e) => e === void 0 ? void 0 : L(e).replace(/’/g, "'"), J = (e, t, s) => t === "," && e === "." ? s ? "{{amount_with_comma_separator}}" : "{{amount_no_decimals_with_comma_separator}}" : t === "," && e === " " ? s ? "{{amount_with_space_separator}}" : "{{amount_no_decimals_with_space_separator}}" : t === "." && e === " " ? "{{amount_with_period_and_space_separator}}" : t === "." && e === "'" ? "{{amount_with_apostrophe_separator}}" : s ? "{{amount}}" : "{{amount_no_decimals}}", w = ({
|
|
46
46
|
country: e,
|
|
47
47
|
language: t
|
|
48
48
|
}) => {
|
|
49
|
-
const
|
|
50
|
-
return e &&
|
|
49
|
+
const s = [];
|
|
50
|
+
return e && s.push(`country: ${e}`), t && s.push(`language: ${t}`), s.length > 0 ? `@inContext(${s.join(", ")})` : "";
|
|
51
51
|
}, H = async (e, {
|
|
52
52
|
useExternalMetafieldNamespace: t,
|
|
53
|
-
useMetaobjects:
|
|
54
|
-
}) =>
|
|
53
|
+
useMetaobjects: s
|
|
54
|
+
}) => s ? W(
|
|
55
55
|
e
|
|
56
56
|
) : X(e), X = async (e, t) => {
|
|
57
|
-
var
|
|
58
|
-
const
|
|
57
|
+
var a;
|
|
58
|
+
const s = (a = (await e.query(
|
|
59
59
|
`
|
|
60
60
|
query FetchDealBlocks($metafieldNamespace: String!) {
|
|
61
61
|
shop {
|
|
@@ -70,10 +70,10 @@ const F = (e, t) => {
|
|
|
70
70
|
metafieldNamespace: "app--2935586817--kaching_bundles"
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
)).shop.metafield) == null ? void 0 :
|
|
74
|
-
return
|
|
73
|
+
)).shop.metafield) == null ? void 0 : a.value;
|
|
74
|
+
return s ? JSON.parse(s) : [];
|
|
75
75
|
}, W = async (e, t) => {
|
|
76
|
-
const
|
|
76
|
+
const s = "app--2935586817--deal_block", a = [];
|
|
77
77
|
let n = null;
|
|
78
78
|
for (; ; ) {
|
|
79
79
|
const i = await e.query(
|
|
@@ -95,7 +95,7 @@ const F = (e, t) => {
|
|
|
95
95
|
`,
|
|
96
96
|
{
|
|
97
97
|
variables: {
|
|
98
|
-
type:
|
|
98
|
+
type: s,
|
|
99
99
|
cursor: n
|
|
100
100
|
}
|
|
101
101
|
}
|
|
@@ -104,28 +104,28 @@ const F = (e, t) => {
|
|
|
104
104
|
const r = o.fields.find(
|
|
105
105
|
(m) => m.key === "settings"
|
|
106
106
|
);
|
|
107
|
-
r != null && r.value &&
|
|
107
|
+
r != null && r.value && a.push(JSON.parse(r.value));
|
|
108
108
|
}
|
|
109
109
|
if (!i.metaobjects.pageInfo.hasNextPage)
|
|
110
110
|
break;
|
|
111
111
|
n = i.metaobjects.pageInfo.endCursor;
|
|
112
112
|
}
|
|
113
|
-
return
|
|
113
|
+
return a;
|
|
114
114
|
}, N = async (e, {
|
|
115
115
|
country: t,
|
|
116
|
-
language:
|
|
117
|
-
blockVisibility:
|
|
116
|
+
language: s,
|
|
117
|
+
blockVisibility: a,
|
|
118
118
|
excludedProductGIDs: n,
|
|
119
119
|
selectedProductGIDs: i,
|
|
120
120
|
selectedCollectionGIDs: o,
|
|
121
121
|
limit: r = 1e3
|
|
122
122
|
}) => {
|
|
123
|
-
switch (
|
|
123
|
+
switch (a) {
|
|
124
124
|
case "selected-products":
|
|
125
125
|
return i.slice(0, r);
|
|
126
126
|
case "all-products":
|
|
127
127
|
case "excluded-products": {
|
|
128
|
-
const m = w({ country: t, language:
|
|
128
|
+
const m = w({ country: t, language: s });
|
|
129
129
|
let c = [], u = null;
|
|
130
130
|
for (; c.length < r; ) {
|
|
131
131
|
const h = Math.min(r - c.length, 250), g = await e.query(
|
|
@@ -152,14 +152,14 @@ const F = (e, t) => {
|
|
|
152
152
|
if (c.push(...g.products.nodes.map((f) => f.id)), !g.products.pageInfo.hasNextPage) break;
|
|
153
153
|
u = g.products.pageInfo.endCursor;
|
|
154
154
|
}
|
|
155
|
-
if (
|
|
155
|
+
if (a === "excluded-products") {
|
|
156
156
|
const h = new Set(n);
|
|
157
157
|
c = c.filter((g) => !h.has(g));
|
|
158
158
|
}
|
|
159
159
|
return c;
|
|
160
160
|
}
|
|
161
161
|
case "selected-collections": {
|
|
162
|
-
const m = w({ country: t, language:
|
|
162
|
+
const m = w({ country: t, language: s }), c = (await e.query(
|
|
163
163
|
`
|
|
164
164
|
query FetchCollectionProductGIDs($collectionGIDs: [ID!]!, $limit: Int!) ${m} {
|
|
165
165
|
nodes(ids: $collectionGIDs) {
|
|
@@ -230,8 +230,8 @@ const F = (e, t) => {
|
|
|
230
230
|
quantityAvailable @include(if: $includeAvailableQuantity)
|
|
231
231
|
`, $ = async (e, {
|
|
232
232
|
country: t,
|
|
233
|
-
language:
|
|
234
|
-
productIds:
|
|
233
|
+
language: s,
|
|
234
|
+
productIds: a,
|
|
235
235
|
includeSellingPlans: n = !0,
|
|
236
236
|
includeAvailableQuantity: i = !0,
|
|
237
237
|
useExternalMetafieldNamespace: o = !1,
|
|
@@ -239,9 +239,9 @@ const F = (e, t) => {
|
|
|
239
239
|
onBatchError: m,
|
|
240
240
|
variantImageTransform: c = { maxWidth: 200, maxHeight: 200 }
|
|
241
241
|
}) => {
|
|
242
|
-
if (!
|
|
242
|
+
if (!a.length)
|
|
243
243
|
return [];
|
|
244
|
-
const u =
|
|
244
|
+
const u = a.map((p) => typeof p == "string" && p.startsWith("gid://") ? p : `gid://shopify/Product/${p}`), h = w({ country: t, language: s }), g = `
|
|
245
245
|
query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $metafieldNamespace: String!, $variantImageTransform: ImageTransformInput) ${h} {
|
|
246
246
|
shop {
|
|
247
247
|
currencyRateConstant: metafield(namespace: $metafieldNamespace, key: "currency_rate_constant") {
|
|
@@ -399,7 +399,7 @@ const F = (e, t) => {
|
|
|
399
399
|
)).map(
|
|
400
400
|
(p) => T(p, e.shopifyDomain, d)
|
|
401
401
|
);
|
|
402
|
-
}, G = async (e, t,
|
|
402
|
+
}, G = async (e, t, s, a = "") => {
|
|
403
403
|
if (t.variants.nodes.length < 250)
|
|
404
404
|
return t;
|
|
405
405
|
const n = /* @__PURE__ */ new Set(), i = [], o = [], r = async (m) => {
|
|
@@ -407,7 +407,7 @@ const F = (e, t) => {
|
|
|
407
407
|
for (; c; ) {
|
|
408
408
|
const h = await e.query(
|
|
409
409
|
`
|
|
410
|
-
query($productGID: ID!, $cursor: String, $reverse: Boolean, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $variantImageTransform: ImageTransformInput) ${
|
|
410
|
+
query($productGID: ID!, $cursor: String, $reverse: Boolean, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $variantImageTransform: ImageTransformInput) ${a} {
|
|
411
411
|
product(id: $productGID) {
|
|
412
412
|
variants(first: 250, after: $cursor, reverse: $reverse) {
|
|
413
413
|
nodes {
|
|
@@ -426,7 +426,7 @@ const F = (e, t) => {
|
|
|
426
426
|
productGID: t.id,
|
|
427
427
|
cursor: u,
|
|
428
428
|
reverse: m,
|
|
429
|
-
...
|
|
429
|
+
...s
|
|
430
430
|
}
|
|
431
431
|
}
|
|
432
432
|
), { nodes: g, pageInfo: f } = h.product.variants;
|
|
@@ -444,9 +444,9 @@ const F = (e, t) => {
|
|
|
444
444
|
r(!1),
|
|
445
445
|
r(!0)
|
|
446
446
|
]), t.variants.nodes = [...i, ...o.reverse()], t;
|
|
447
|
-
}, T = (e, t,
|
|
447
|
+
}, T = (e, t, s) => {
|
|
448
448
|
var c, u, h, g, f, v;
|
|
449
|
-
const
|
|
449
|
+
const a = e.variants.nodes.map(
|
|
450
450
|
({ unitPriceMeasurement: l, ...d }) => {
|
|
451
451
|
var y, _;
|
|
452
452
|
return {
|
|
@@ -497,7 +497,7 @@ const F = (e, t) => {
|
|
|
497
497
|
defaultName: l.name,
|
|
498
498
|
name: l.name,
|
|
499
499
|
position: d + 1,
|
|
500
|
-
optionValues: K(y, d,
|
|
500
|
+
optionValues: K(y, d, a)
|
|
501
501
|
};
|
|
502
502
|
}), i = (l) => {
|
|
503
503
|
const d = l.priceAdjustments[0];
|
|
@@ -525,7 +525,7 @@ const F = (e, t) => {
|
|
|
525
525
|
`Unknown price adjustment type: ${y.__typename}`
|
|
526
526
|
);
|
|
527
527
|
}
|
|
528
|
-
}, o = (l) =>
|
|
528
|
+
}, o = (l) => s === 1 ? Number(l) * 100 : Math.round(Number(l) * 100 * s), r = ((c = e.sellingPlanGroups) == null ? void 0 : c.nodes.flatMap(
|
|
529
529
|
(l) => l.sellingPlans.nodes.map((d) => ({
|
|
530
530
|
id: Number(d.id.split("/").pop()),
|
|
531
531
|
name: d.name,
|
|
@@ -549,7 +549,7 @@ const F = (e, t) => {
|
|
|
549
549
|
selectedVariantId: Number(
|
|
550
550
|
e.variants.nodes[0].id.split("/").pop()
|
|
551
551
|
),
|
|
552
|
-
variants:
|
|
552
|
+
variants: a,
|
|
553
553
|
requiresSellingPlan: e.requiresSellingPlan,
|
|
554
554
|
sellingPlans: r,
|
|
555
555
|
isNativeBundle: m,
|
|
@@ -560,14 +560,14 @@ const F = (e, t) => {
|
|
|
560
560
|
text4: ((v = e.metafield4) == null ? void 0 : v.value) || null
|
|
561
561
|
}
|
|
562
562
|
};
|
|
563
|
-
}, K = (e, t,
|
|
564
|
-
(n) => n.options[t] ===
|
|
563
|
+
}, K = (e, t, s) => e.filter((a) => s.filter(
|
|
564
|
+
(n) => n.options[t] === a.name
|
|
565
565
|
).length > 0), B = "app--2935586817", Y = async (e, {
|
|
566
566
|
language: t,
|
|
567
|
-
country:
|
|
568
|
-
useExternalMetafieldNamespace:
|
|
567
|
+
country: s,
|
|
568
|
+
useExternalMetafieldNamespace: a
|
|
569
569
|
}) => {
|
|
570
|
-
const n = `${B}--kaching_bundles`, i = B, o = w({ country:
|
|
570
|
+
const n = `${B}--kaching_bundles`, i = B, o = w({ country: s }), {
|
|
571
571
|
localization: {
|
|
572
572
|
country: {
|
|
573
573
|
currency: { isoCode: r }
|
|
@@ -613,13 +613,13 @@ const F = (e, t) => {
|
|
|
613
613
|
settingsNamespace: i
|
|
614
614
|
}
|
|
615
615
|
}
|
|
616
|
-
), f = r === c ? m : z(r, { language: t, country:
|
|
616
|
+
), f = r === c ? m : z(r, { language: t, country: s }), v = u ? Z(u.value) : 1, l = g ? JSON.parse(g.value) : null, d = (l == null ? void 0 : l.feature_flags) ?? {}, y = (l == null ? void 0 : l.custom_selectors) ?? {};
|
|
617
617
|
return {
|
|
618
618
|
shopifyDomain: h.host,
|
|
619
619
|
moneyFormat: f,
|
|
620
620
|
locale: (t == null ? void 0 : t.toLowerCase()) || "en",
|
|
621
621
|
liquidLocale: (t == null ? void 0 : t.toLowerCase()) || "en",
|
|
622
|
-
country:
|
|
622
|
+
country: s ?? "US",
|
|
623
623
|
currencyRate: v,
|
|
624
624
|
marketId: 0,
|
|
625
625
|
productId: null,
|
|
@@ -674,16 +674,16 @@ const F = (e, t) => {
|
|
|
674
674
|
featureFlags: d,
|
|
675
675
|
brandColors: (l == null ? void 0 : l.brand_colors) ?? null
|
|
676
676
|
};
|
|
677
|
-
}, Z = (e) => JSON.parse(e).amount / 1e6, ee = async (e, t,
|
|
678
|
-
const
|
|
677
|
+
}, Z = (e) => JSON.parse(e).amount / 1e6, ee = async (e, t, s = 200) => {
|
|
678
|
+
const a = [
|
|
679
679
|
...new Set(
|
|
680
680
|
t.filter(Boolean).filter((i) => !i.startsWith("placeholder"))
|
|
681
681
|
)
|
|
682
682
|
];
|
|
683
|
-
if (
|
|
683
|
+
if (a.length === 0) return [];
|
|
684
684
|
const n = [];
|
|
685
|
-
for (let i = 0; i <
|
|
686
|
-
n.push(
|
|
685
|
+
for (let i = 0; i < a.length; i += 250)
|
|
686
|
+
n.push(a.slice(i, i + 250));
|
|
687
687
|
return (await Promise.all(
|
|
688
688
|
n.map(
|
|
689
689
|
(i) => e.query(
|
|
@@ -702,20 +702,19 @@ const F = (e, t) => {
|
|
|
702
702
|
{
|
|
703
703
|
variables: {
|
|
704
704
|
mediaImageIds: i,
|
|
705
|
-
size:
|
|
705
|
+
size: s
|
|
706
706
|
}
|
|
707
707
|
}
|
|
708
708
|
)
|
|
709
709
|
)
|
|
710
|
-
)).flatMap((i) => i.nodes).
|
|
711
|
-
gid: i.id,
|
|
712
|
-
|
|
713
|
-
}));
|
|
710
|
+
)).flatMap((i) => i.nodes).flatMap(
|
|
711
|
+
(i) => i != null && i.image ? [{ gid: i.id, url: i.image.url }] : []
|
|
712
|
+
);
|
|
714
713
|
};
|
|
715
714
|
var S = /* @__PURE__ */ ((e) => (e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e))(S || {});
|
|
716
715
|
const te = (e) => [
|
|
717
|
-
...ae(e),
|
|
718
716
|
...se(e),
|
|
717
|
+
...ae(e),
|
|
719
718
|
...ne(e),
|
|
720
719
|
...le(e),
|
|
721
720
|
...re(e),
|
|
@@ -727,39 +726,39 @@ const te = (e) => [
|
|
|
727
726
|
...me(e),
|
|
728
727
|
...pe(e),
|
|
729
728
|
...fe(e)
|
|
730
|
-
].filter((t) => t != null && !t.includes("placeholder")),
|
|
729
|
+
].filter((t) => t != null && !t.includes("placeholder")), se = (e) => e.dealBars.flatMap((t) => [t.mediaImageGID, t.badgeImageGID]).filter((t) => t != null), ae = (e) => e.dealBars.flatMap(
|
|
731
730
|
(t) => t.dealBarType === S.Bundle ? t.bundleProducts.map(
|
|
732
|
-
(
|
|
731
|
+
(s) => s.mediaImageGID
|
|
733
732
|
) : []
|
|
734
733
|
).filter((t) => t != null), ne = (e) => e.dealBars.map(
|
|
735
|
-
({ freeGifts: t }) => (t || []).map((
|
|
736
|
-
).reduce((t,
|
|
737
|
-
({ multipleGiftsSelectors: t }) => (t || []).map((
|
|
738
|
-
).filter((t) => t != null), re = (e) => e.dealBars.map(({ upsells: t }) => (t || []).map((
|
|
739
|
-
const
|
|
740
|
-
return [...t, ...
|
|
734
|
+
({ freeGifts: t }) => (t || []).map((s) => s.mediaImageGID)
|
|
735
|
+
).reduce((t, s) => t.concat(s), []).filter((t) => t != null), le = (e) => e.dealBars.flatMap(
|
|
736
|
+
({ multipleGiftsSelectors: t }) => (t || []).map((s) => s.mediaImageGID)
|
|
737
|
+
).filter((t) => t != null), re = (e) => e.dealBars.map(({ upsells: t }) => (t || []).map((s) => s.mediaImageGID)).reduce((t, s) => t.concat(s), []).filter((t) => t != null), ie = (e) => e.swatchOptions ? e.swatchOptions.reduce((t, s) => {
|
|
738
|
+
const a = s.images.map((n) => n.mediaImageGID).filter((n) => n != null);
|
|
739
|
+
return [...t, ...a];
|
|
741
740
|
}, []) : [], oe = (e) => {
|
|
742
741
|
if (!e.collectionBreaksEnabled || !e.collectionBreaks)
|
|
743
742
|
return [];
|
|
744
743
|
const t = e.collectionBreaks.mediaImageGID;
|
|
745
744
|
return t ? [t] : [];
|
|
746
745
|
}, ce = (e) => {
|
|
747
|
-
var t,
|
|
746
|
+
var t, s, a;
|
|
748
747
|
return e.progressiveGifts ? [
|
|
749
748
|
...((t = e.progressiveGifts.gifts) == null ? void 0 : t.map((n) => n.mediaImageGID)) || [],
|
|
750
|
-
(
|
|
751
|
-
(
|
|
749
|
+
(s = e.progressiveGifts.style) == null ? void 0 : s.lockedMediaImageGID,
|
|
750
|
+
(a = e.progressiveGifts.dealBarStyle) == null ? void 0 : a.lockedMediaImageGID
|
|
752
751
|
].filter((n) => n != null) : [];
|
|
753
752
|
}, ue = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.flatMap((t) => [t.mediaImageGID, t.badgeImageGID]).filter((t) => t != null), de = (e) => e.dealBars.map((t) => {
|
|
754
|
-
var
|
|
755
|
-
return (
|
|
753
|
+
var s;
|
|
754
|
+
return (s = t.productPersonalisation) == null ? void 0 : s.mediaImageGID;
|
|
756
755
|
}).filter((t) => t != null), me = (e) => {
|
|
757
|
-
var
|
|
756
|
+
var a, n;
|
|
758
757
|
const t = e.dealBars.map((i) => {
|
|
759
758
|
var o;
|
|
760
759
|
return (o = i.highlights) == null ? void 0 : o.customIconGID;
|
|
761
|
-
}).filter((i) => i != null),
|
|
762
|
-
return
|
|
760
|
+
}).filter((i) => i != null), s = (n = (a = e.subscriptions) == null ? void 0 : a.highlights) == null ? void 0 : n.customIconGID;
|
|
761
|
+
return s ? [...t, s] : t;
|
|
763
762
|
}, pe = (e) => (e.badges || []).flatMap(
|
|
764
763
|
(t) => t.badgeType === "custom" && t.imageGID ? [t.imageGID] : []
|
|
765
764
|
), fe = (e) => !e.savingsSummaryEnabled || !e.savingsSummary ? [] : e.savingsSummary.customIconGID ? [e.savingsSummary.customIconGID] : [], he = (e) => {
|
|
@@ -773,46 +772,46 @@ const te = (e) => [
|
|
|
773
772
|
...Pe(e),
|
|
774
773
|
...Se(e)
|
|
775
774
|
];
|
|
776
|
-
return Array.from(new Set(t.filter((
|
|
775
|
+
return Array.from(new Set(t.filter((s) => s != null)));
|
|
777
776
|
}, ge = (e) => e.dealBars.flatMap(
|
|
778
|
-
({ freeGifts: t }) => t ? t.map((
|
|
777
|
+
({ freeGifts: t }) => t ? t.map((s) => s.productGID) : []
|
|
779
778
|
).filter((t) => t != null), ye = (e) => e.dealBars.flatMap(
|
|
780
779
|
({ multipleGiftsSelectors: t }) => t ? t.flatMap(
|
|
781
|
-
(
|
|
780
|
+
(s) => s.products ? s.products.map((a) => a.id) : []
|
|
782
781
|
) : []
|
|
783
782
|
).filter((t) => t != null), be = (e) => {
|
|
784
783
|
var t;
|
|
785
|
-
return e.progressiveGiftsEnabled ? ((t = e.progressiveGifts) == null ? void 0 : t.gifts.map((
|
|
786
|
-
}, ve = (e) => e.dealBars.flatMap(({ upsells: t }) => t ? t.map((
|
|
787
|
-
({ bundleProducts: t }) => t ? t.map((
|
|
784
|
+
return e.progressiveGiftsEnabled ? ((t = e.progressiveGifts) == null ? void 0 : t.gifts.map((s) => s.productGID).filter((s) => s != null)) || [] : [];
|
|
785
|
+
}, ve = (e) => e.dealBars.flatMap(({ upsells: t }) => t ? t.map((s) => s.productGID) : []).filter((t) => t != null), Ie = (e) => e.dealBars.filter((t) => t.dealBarType === S.Bundle).flatMap(
|
|
786
|
+
({ bundleProducts: t }) => t ? t.map((s) => s.productGID) : []
|
|
788
787
|
).filter((t) => t != null).filter((t) => t !== "default"), _e = (e) => e.dealBars.filter((t) => t.dealBarType === S.MixAndMatch).flatMap(
|
|
789
|
-
({ bundleProducts: t }) => t ? t.flatMap((
|
|
790
|
-
var
|
|
788
|
+
({ bundleProducts: t }) => t ? t.flatMap((s) => {
|
|
789
|
+
var a;
|
|
791
790
|
return [
|
|
792
|
-
|
|
793
|
-
...((
|
|
791
|
+
s.productGID,
|
|
792
|
+
...((a = s.selectedProducts) == null ? void 0 : a.map((n) => n.id)) ?? []
|
|
794
793
|
];
|
|
795
794
|
}) : []
|
|
796
795
|
).filter((t) => t != null).filter((t) => t !== "default"), Pe = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.map((t) => t.productGID).filter((t) => t != null), Se = (e) => e.dealBars.filter((t) => t.dealBarType === S.Sku).flatMap(({ productGID: t }) => t ? [t] : []);
|
|
797
796
|
class M extends Error {
|
|
798
797
|
constructor({
|
|
799
798
|
status: t,
|
|
800
|
-
operationName:
|
|
801
|
-
graphqlErrors:
|
|
799
|
+
operationName: s,
|
|
800
|
+
graphqlErrors: a
|
|
802
801
|
}) {
|
|
803
|
-
const n =
|
|
802
|
+
const n = a.length ? `: ${a.join("; ")}` : "";
|
|
804
803
|
super(
|
|
805
|
-
`Storefront API ${
|
|
806
|
-
), this.name = "StorefrontApiError", this.status = t, this.operationName =
|
|
804
|
+
`Storefront API ${s ?? "query"} failed (HTTP ${t})${n}`
|
|
805
|
+
), this.name = "StorefrontApiError", this.status = t, this.operationName = s, this.graphqlErrors = a;
|
|
807
806
|
}
|
|
808
807
|
}
|
|
809
808
|
const ke = async (e, t) => {
|
|
810
|
-
const
|
|
811
|
-
if (!
|
|
809
|
+
const s = await e.text();
|
|
810
|
+
if (!s)
|
|
812
811
|
throw new Error("Empty graphql response");
|
|
813
|
-
let
|
|
812
|
+
let a;
|
|
814
813
|
try {
|
|
815
|
-
|
|
814
|
+
a = JSON.parse(s);
|
|
816
815
|
} catch (n) {
|
|
817
816
|
throw e.ok ? n : new M({
|
|
818
817
|
status: e.status,
|
|
@@ -820,21 +819,21 @@ const ke = async (e, t) => {
|
|
|
820
819
|
graphqlErrors: []
|
|
821
820
|
});
|
|
822
821
|
}
|
|
823
|
-
if (!e.ok ||
|
|
822
|
+
if (!e.ok || a.data === null || a.data === void 0)
|
|
824
823
|
throw new M({
|
|
825
824
|
status: e.status,
|
|
826
825
|
operationName: t,
|
|
827
|
-
graphqlErrors: (
|
|
826
|
+
graphqlErrors: (a.errors ?? []).map(({ message: n }) => n).filter(Boolean)
|
|
828
827
|
});
|
|
829
|
-
return
|
|
828
|
+
return a.data;
|
|
830
829
|
};
|
|
831
830
|
class we {
|
|
832
|
-
constructor(t,
|
|
833
|
-
this.storefrontApiVersion = "2026-07", this.storefrontAccessToken =
|
|
831
|
+
constructor(t, s) {
|
|
832
|
+
this.storefrontApiVersion = "2026-07", this.storefrontAccessToken = s, this.shopifyDomain = t;
|
|
834
833
|
}
|
|
835
|
-
async query(t,
|
|
834
|
+
async query(t, s) {
|
|
836
835
|
var r;
|
|
837
|
-
const
|
|
836
|
+
const a = (s == null ? void 0 : s.variables) ?? {};
|
|
838
837
|
let n = `https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`;
|
|
839
838
|
const i = (r = t.match(/query\s+(\w+)/)) == null ? void 0 : r[1];
|
|
840
839
|
i && (n += `?operation_name=${i}`);
|
|
@@ -846,19 +845,19 @@ class we {
|
|
|
846
845
|
},
|
|
847
846
|
body: JSON.stringify({
|
|
848
847
|
query: t,
|
|
849
|
-
variables:
|
|
848
|
+
variables: a
|
|
850
849
|
})
|
|
851
850
|
});
|
|
852
851
|
return ke(o, i);
|
|
853
852
|
}
|
|
854
853
|
}
|
|
855
|
-
const Ee = async (e, t, { country:
|
|
854
|
+
const Ee = async (e, t, { country: s, language: a }) => {
|
|
856
855
|
const n = t.collectionBreaks;
|
|
857
856
|
if (!t.collectionBreaksEnabled || !n) return;
|
|
858
857
|
let i;
|
|
859
858
|
n.visibility === "deal-products" ? i = await N(e, {
|
|
860
|
-
country:
|
|
861
|
-
language:
|
|
859
|
+
country: s,
|
|
860
|
+
language: a,
|
|
862
861
|
blockVisibility: t.blockVisibility,
|
|
863
862
|
excludedProductGIDs: (t.excludedProductIds || []).map(
|
|
864
863
|
(r) => `gid://shopify/Product/${r}`
|
|
@@ -870,8 +869,8 @@ const Ee = async (e, t, { country: a, language: s }) => {
|
|
|
870
869
|
(r) => `gid://shopify/Collection/${r}`
|
|
871
870
|
)
|
|
872
871
|
}) : i = await N(e, {
|
|
873
|
-
country:
|
|
874
|
-
language:
|
|
872
|
+
country: s,
|
|
873
|
+
language: a,
|
|
875
874
|
blockVisibility: n.visibility,
|
|
876
875
|
excludedProductGIDs: (n.excludedProducts || []).map(
|
|
877
876
|
({ id: r }) => r
|
|
@@ -884,8 +883,8 @@ const Ee = async (e, t, { country: a, language: s }) => {
|
|
|
884
883
|
)
|
|
885
884
|
});
|
|
886
885
|
let o = await $(e, {
|
|
887
|
-
country:
|
|
888
|
-
language:
|
|
886
|
+
country: s,
|
|
887
|
+
language: a,
|
|
889
888
|
productIds: i.map((r) => Number(r.split("/").pop())),
|
|
890
889
|
useExternalMetafieldNamespace: !0
|
|
891
890
|
});
|
|
@@ -896,7 +895,7 @@ const Ee = async (e, t, { country: a, language: s }) => {
|
|
|
896
895
|
language: e,
|
|
897
896
|
dealBlockId: t
|
|
898
897
|
}) => {
|
|
899
|
-
const
|
|
898
|
+
const s = {
|
|
900
899
|
"system.out_of_stock": "There's not enough items in our stock, please select smaller bundle.",
|
|
901
900
|
"system.invalid_variant": "Sorry, this is not currently available.",
|
|
902
901
|
"system.unavailable_option_value": "Unavailable",
|
|
@@ -921,40 +920,40 @@ const Ee = async (e, t, { country: a, language: s }) => {
|
|
|
921
920
|
"system.letters_only": "Only letters are allowed.",
|
|
922
921
|
"system.numbers_only": "Only numbers are allowed.",
|
|
923
922
|
"system.personalisation_required_alert": "Please add personalisation for every item to continue."
|
|
924
|
-
},
|
|
923
|
+
}, a = e ? $e(e) : void 0;
|
|
925
924
|
return {
|
|
926
|
-
...
|
|
927
|
-
...
|
|
928
|
-
...
|
|
925
|
+
...s,
|
|
926
|
+
...a == null ? void 0 : a.system,
|
|
927
|
+
...a == null ? void 0 : a.dealBlocks[t]
|
|
929
928
|
};
|
|
930
929
|
}, $e = (e) => {
|
|
931
930
|
var n;
|
|
932
931
|
if (typeof document > "u") return;
|
|
933
932
|
const t = document.querySelector("script#kaching-bundles-translations");
|
|
934
933
|
if (!(t != null && t.textContent)) return;
|
|
935
|
-
let
|
|
934
|
+
let s;
|
|
936
935
|
try {
|
|
937
|
-
|
|
936
|
+
s = JSON.parse(t.textContent);
|
|
938
937
|
} catch {
|
|
939
938
|
return;
|
|
940
939
|
}
|
|
941
|
-
const
|
|
942
|
-
return (n =
|
|
943
|
-
(i) => q(i.locale) ===
|
|
940
|
+
const a = q(e);
|
|
941
|
+
return (n = s.find(
|
|
942
|
+
(i) => q(i.locale) === a
|
|
944
943
|
)) == null ? void 0 : n.translations;
|
|
945
944
|
}, q = (e) => e.toLowerCase().replace(/_/g, "-"), De = "2026-07", xe = async (e, {
|
|
946
945
|
productId: t,
|
|
947
|
-
dealBlockId:
|
|
948
|
-
country:
|
|
946
|
+
dealBlockId: s,
|
|
947
|
+
country: a = void 0,
|
|
949
948
|
language: n = void 0
|
|
950
949
|
}) => {
|
|
951
950
|
var i, o;
|
|
952
951
|
try {
|
|
953
952
|
const r = [Number(t.split("/").pop())], m = new Ce(e);
|
|
954
|
-
|
|
953
|
+
a = a || ((i = m.i18n) == null ? void 0 : i.country), n = n || ((o = m.i18n) == null ? void 0 : o.language);
|
|
955
954
|
const c = await Y(m, {
|
|
956
955
|
language: n,
|
|
957
|
-
country:
|
|
956
|
+
country: a,
|
|
958
957
|
useExternalMetafieldNamespace: !0
|
|
959
958
|
});
|
|
960
959
|
m.shopifyDomain = c.shopifyDomain;
|
|
@@ -963,7 +962,7 @@ const Ee = async (e, t, { country: a, language: s }) => {
|
|
|
963
962
|
c.storefrontAccessToken
|
|
964
963
|
) : m, [h, g] = await Promise.all([
|
|
965
964
|
$(u, {
|
|
966
|
-
country:
|
|
965
|
+
country: a,
|
|
967
966
|
language: n,
|
|
968
967
|
productIds: r,
|
|
969
968
|
useExternalMetafieldNamespace: !0
|
|
@@ -977,20 +976,20 @@ const Ee = async (e, t, { country: a, language: s }) => {
|
|
|
977
976
|
return null;
|
|
978
977
|
const v = F(g, f);
|
|
979
978
|
let l;
|
|
980
|
-
if (
|
|
981
|
-
(P) => P.id ===
|
|
979
|
+
if (s ? (l = v.find(
|
|
980
|
+
(P) => P.id === s || P.nanoId === s
|
|
982
981
|
), l || (l = v[0])) : l = v[0], !l)
|
|
983
982
|
return null;
|
|
984
983
|
const d = te(l), y = he(l), [_, I, p, b] = await Promise.all([
|
|
985
984
|
$(u, {
|
|
986
|
-
country:
|
|
985
|
+
country: a,
|
|
987
986
|
language: n,
|
|
988
987
|
productIds: y,
|
|
989
988
|
useExternalMetafieldNamespace: !0
|
|
990
989
|
}),
|
|
991
990
|
ee(u, d, 300),
|
|
992
991
|
Ee(u, l, {
|
|
993
|
-
country:
|
|
992
|
+
country: a,
|
|
994
993
|
language: n
|
|
995
994
|
}),
|
|
996
995
|
Ae({ language: n, dealBlockId: l.id })
|
|
@@ -1012,13 +1011,13 @@ class Ce {
|
|
|
1012
1011
|
constructor(t) {
|
|
1013
1012
|
this.storefront = t, this.shopifyDomain = "";
|
|
1014
1013
|
}
|
|
1015
|
-
async query(t,
|
|
1016
|
-
var
|
|
1014
|
+
async query(t, s) {
|
|
1015
|
+
var a;
|
|
1017
1016
|
if ("query" in this.storefront && "i18n" in this.storefront)
|
|
1018
|
-
return await this.storefront.query(t,
|
|
1017
|
+
return await this.storefront.query(t, s);
|
|
1019
1018
|
if ("graphql" in this.storefront) {
|
|
1020
|
-
const n = await this.storefront.graphql(t,
|
|
1021
|
-
if ((
|
|
1019
|
+
const n = await this.storefront.graphql(t, s);
|
|
1020
|
+
if ((a = n.errors) != null && a.length)
|
|
1022
1021
|
throw new Error(
|
|
1023
1022
|
n.errors.map((i) => i.message).join(`
|
|
1024
1023
|
`)
|
|
@@ -1026,14 +1025,14 @@ class Ce {
|
|
|
1026
1025
|
return n.data;
|
|
1027
1026
|
}
|
|
1028
1027
|
if ("request" in this.storefront)
|
|
1029
|
-
return (await this.storefront.request(t,
|
|
1028
|
+
return (await this.storefront.request(t, s)).data;
|
|
1030
1029
|
if ("shopifyDomain" in this.storefront && "storefrontAccessToken" in this.storefront) {
|
|
1031
1030
|
const n = await fetch(
|
|
1032
1031
|
`https://${this.storefront.shopifyDomain}/api/${De}/graphql.json`,
|
|
1033
1032
|
{
|
|
1034
1033
|
body: JSON.stringify({
|
|
1035
1034
|
query: t,
|
|
1036
|
-
variables:
|
|
1035
|
+
variables: s == null ? void 0 : s.variables
|
|
1037
1036
|
}),
|
|
1038
1037
|
headers: {
|
|
1039
1038
|
"Content-Type": "application/json",
|
|
@@ -1049,7 +1048,7 @@ class Ce {
|
|
|
1049
1048
|
const n = await fetch(this.storefront.getStorefrontApiUrl(), {
|
|
1050
1049
|
body: JSON.stringify({
|
|
1051
1050
|
query: t,
|
|
1052
|
-
variables:
|
|
1051
|
+
variables: s == null ? void 0 : s.variables
|
|
1053
1052
|
}),
|
|
1054
1053
|
headers: this.storefront.getPublicTokenHeaders(),
|
|
1055
1054
|
method: "POST"
|
|
@@ -1072,26 +1071,26 @@ const E = "kaching-bundles-block", O = 1e4, Ne = "https://bundles-integrations-d
|
|
|
1072
1071
|
A.add(t);
|
|
1073
1072
|
try {
|
|
1074
1073
|
await Me(e);
|
|
1075
|
-
} catch (
|
|
1076
|
-
throw A.delete(t),
|
|
1074
|
+
} catch (s) {
|
|
1075
|
+
throw A.delete(t), s;
|
|
1077
1076
|
}
|
|
1078
1077
|
}
|
|
1079
1078
|
}, Te = () => typeof window < "u" && typeof window.__KACHING_DEV__ < "u", Be = () => Te() ? Ne : Ge, Me = (e) => {
|
|
1080
1079
|
const t = e.document;
|
|
1081
|
-
return new Promise((
|
|
1080
|
+
return new Promise((s, a) => {
|
|
1082
1081
|
const n = Be();
|
|
1083
1082
|
if (t.querySelector(
|
|
1084
1083
|
`script[src="${n}"]`
|
|
1085
1084
|
)) {
|
|
1086
|
-
D(e, E).then(
|
|
1085
|
+
D(e, E).then(s).catch(a);
|
|
1087
1086
|
return;
|
|
1088
1087
|
}
|
|
1089
1088
|
const o = t.createElement("script");
|
|
1090
|
-
o.src = n, o.onload = () => D(e, E).then(
|
|
1089
|
+
o.src = n, o.onload = () => D(e, E).then(s).catch(a), o.onerror = () => a(new Error("Failed to load script")), t.head.appendChild(o);
|
|
1091
1090
|
});
|
|
1092
|
-
}, D = (e, t) => new Promise((
|
|
1091
|
+
}, D = (e, t) => new Promise((s, a) => {
|
|
1093
1092
|
if (e.customElements.get(t)) {
|
|
1094
|
-
|
|
1093
|
+
s();
|
|
1095
1094
|
return;
|
|
1096
1095
|
}
|
|
1097
1096
|
Promise.race([
|
|
@@ -1106,7 +1105,7 @@ const E = "kaching-bundles-block", O = 1e4, Ne = "https://bundles-integrations-d
|
|
|
1106
1105
|
O
|
|
1107
1106
|
)
|
|
1108
1107
|
)
|
|
1109
|
-
]).then(() =>
|
|
1108
|
+
]).then(() => s()).catch(a);
|
|
1110
1109
|
});
|
|
1111
1110
|
var k = /* @__PURE__ */ ((e) => (e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e))(k || {});
|
|
1112
1111
|
const qe = {
|
|
@@ -1229,7 +1228,8 @@ const qe = {
|
|
|
1229
1228
|
productPersonalisation: null,
|
|
1230
1229
|
highlights: null,
|
|
1231
1230
|
sellingPlanEnabled: !1,
|
|
1232
|
-
sellingPlanGid: null
|
|
1231
|
+
sellingPlanGid: null,
|
|
1232
|
+
subscriptionMode: "customer-choice"
|
|
1233
1233
|
},
|
|
1234
1234
|
{
|
|
1235
1235
|
id: "duo",
|
|
@@ -1253,7 +1253,8 @@ const qe = {
|
|
|
1253
1253
|
productPersonalisation: null,
|
|
1254
1254
|
highlights: null,
|
|
1255
1255
|
sellingPlanEnabled: !1,
|
|
1256
|
-
sellingPlanGid: null
|
|
1256
|
+
sellingPlanGid: null,
|
|
1257
|
+
subscriptionMode: "customer-choice"
|
|
1257
1258
|
},
|
|
1258
1259
|
{
|
|
1259
1260
|
id: "trio",
|
|
@@ -1277,7 +1278,8 @@ const qe = {
|
|
|
1277
1278
|
productPersonalisation: null,
|
|
1278
1279
|
highlights: null,
|
|
1279
1280
|
sellingPlanEnabled: !1,
|
|
1280
|
-
sellingPlanGid: null
|
|
1281
|
+
sellingPlanGid: null,
|
|
1282
|
+
subscriptionMode: "customer-choice"
|
|
1281
1283
|
}
|
|
1282
1284
|
],
|
|
1283
1285
|
badgesEnabled: !0,
|
|
@@ -1399,13 +1401,13 @@ class Ue extends HTMLElement {
|
|
|
1399
1401
|
this.renderInnerElement(Le);
|
|
1400
1402
|
return;
|
|
1401
1403
|
}
|
|
1402
|
-
const
|
|
1403
|
-
if (!
|
|
1404
|
+
const s = this.getAttribute("shop-domain"), a = this.getAttribute("storefront-token"), n = this.getAttribute("product-id");
|
|
1405
|
+
if (!s || !a || !n) return;
|
|
1404
1406
|
const [i] = await Promise.all([
|
|
1405
1407
|
xe(
|
|
1406
1408
|
{
|
|
1407
|
-
shopifyDomain:
|
|
1408
|
-
storefrontAccessToken:
|
|
1409
|
+
shopifyDomain: s,
|
|
1410
|
+
storefrontAccessToken: a
|
|
1409
1411
|
},
|
|
1410
1412
|
{
|
|
1411
1413
|
productId: n,
|
|
@@ -1420,8 +1422,8 @@ class Ue extends HTMLElement {
|
|
|
1420
1422
|
}
|
|
1421
1423
|
renderInnerElement(t) {
|
|
1422
1424
|
const {
|
|
1423
|
-
config:
|
|
1424
|
-
dealBlock:
|
|
1425
|
+
config: s,
|
|
1426
|
+
dealBlock: a,
|
|
1425
1427
|
product: n,
|
|
1426
1428
|
otherProducts: i,
|
|
1427
1429
|
mediaImages: o,
|
|
@@ -1430,7 +1432,7 @@ class Ue extends HTMLElement {
|
|
|
1430
1432
|
} = t;
|
|
1431
1433
|
this.innerElement = document.createElement(
|
|
1432
1434
|
"kaching-bundles-block"
|
|
1433
|
-
), this.innerElement.setAttribute("deal-block-id",
|
|
1435
|
+
), this.innerElement.setAttribute("deal-block-id", a.id), this.innerElement.setAttribute("config", JSON.stringify(s)), this.innerElement.setAttribute("deal-block", JSON.stringify(a)), this.innerElement.setAttribute(
|
|
1434
1436
|
"media-images",
|
|
1435
1437
|
JSON.stringify(o ?? [])
|
|
1436
1438
|
), this.innerElement.setAttribute("product", JSON.stringify(n)), this.innerElement.setAttribute(
|
|
@@ -1476,10 +1478,10 @@ class Ue extends HTMLElement {
|
|
|
1476
1478
|
this.handleItemsChanged
|
|
1477
1479
|
), this.handleItemsChanged = null), this.innerElement && (this.innerElement.remove(), this.innerElement = null);
|
|
1478
1480
|
}
|
|
1479
|
-
attributeChangedCallback(t,
|
|
1480
|
-
|
|
1481
|
+
attributeChangedCallback(t, s, a) {
|
|
1482
|
+
s !== a && this.isConnected && (t === "product-id" || t === "country" || t === "language" ? this.initialize() : t === "selected-variant-id" && this.innerElement && a && this.innerElement.setAttribute(
|
|
1481
1483
|
"current-variant-id",
|
|
1482
|
-
|
|
1484
|
+
a.includes("/") ? String(a.split("/").pop()) : a
|
|
1483
1485
|
));
|
|
1484
1486
|
}
|
|
1485
1487
|
items() {
|