@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
package/dist/react/index.js
CHANGED
|
@@ -2,29 +2,29 @@ import { jsx as J } from "react/jsx-runtime";
|
|
|
2
2
|
import { useRef as B, useState as z, useEffect as D, useLayoutEffect as Q } from "react";
|
|
3
3
|
const H = (e, t) => {
|
|
4
4
|
const a = [], r = e.filter(
|
|
5
|
-
(
|
|
5
|
+
(i) => i.blockVisibility === "selected-products"
|
|
6
6
|
);
|
|
7
|
-
for (const
|
|
8
|
-
|
|
7
|
+
for (const i of r)
|
|
8
|
+
i.selectedProductIds.map(Number).includes(t.id) && a.push(i);
|
|
9
9
|
const s = e.filter(
|
|
10
|
-
(
|
|
10
|
+
(i) => i.blockVisibility === "selected-collections"
|
|
11
11
|
);
|
|
12
|
-
for (const
|
|
12
|
+
for (const i of s)
|
|
13
13
|
t.collectionIds.some(
|
|
14
|
-
(d) =>
|
|
15
|
-
) && a.push(
|
|
16
|
-
const
|
|
17
|
-
(
|
|
14
|
+
(d) => i.selectedCollectionIds.map(Number).includes(d)
|
|
15
|
+
) && a.push(i);
|
|
16
|
+
const l = e.filter(
|
|
17
|
+
(i) => i.blockVisibility === "excluded-products"
|
|
18
18
|
);
|
|
19
|
-
for (const
|
|
20
|
-
!
|
|
19
|
+
for (const i of l)
|
|
20
|
+
!i.excludedProductIds.map(Number).includes(t.id) && !(i.excludedCollectionIds || []).some(
|
|
21
21
|
(d) => t.collectionIds.includes(d)
|
|
22
|
-
) && a.push(
|
|
22
|
+
) && a.push(i);
|
|
23
23
|
const o = e.filter(
|
|
24
|
-
(
|
|
24
|
+
(i) => i.blockVisibility === "all-products"
|
|
25
25
|
);
|
|
26
|
-
for (const
|
|
27
|
-
a.push(
|
|
26
|
+
for (const i of o)
|
|
27
|
+
a.push(i);
|
|
28
28
|
return a;
|
|
29
29
|
}, K = (e, { language: t, country: a }) => {
|
|
30
30
|
var p, g;
|
|
@@ -32,12 +32,12 @@ const H = (e, t) => {
|
|
|
32
32
|
style: "currency",
|
|
33
33
|
currency: e,
|
|
34
34
|
currencyDisplay: "narrowSymbol"
|
|
35
|
-
}).formatToParts(123456789e-2),
|
|
35
|
+
}).formatToParts(123456789e-2), l = (p = s.find((y) => y.type === "decimal")) == null ? void 0 : p.value, o = X(
|
|
36
36
|
(g = s.find((y) => y.type === "group")) == null ? void 0 : g.value
|
|
37
|
-
),
|
|
37
|
+
), i = s.some((y) => y.type === "fraction"), d = Y(
|
|
38
38
|
o,
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
l,
|
|
40
|
+
i
|
|
41
41
|
), u = s.findIndex(C), c = s.findLastIndex(C);
|
|
42
42
|
return [
|
|
43
43
|
...s.slice(0, u).map(G),
|
|
@@ -78,7 +78,7 @@ const H = (e, t) => {
|
|
|
78
78
|
const a = "app--2935586817--deal_block", r = [];
|
|
79
79
|
let s = null;
|
|
80
80
|
for (; ; ) {
|
|
81
|
-
const
|
|
81
|
+
const l = await e.query(
|
|
82
82
|
`
|
|
83
83
|
query FetchDealBlockMetaobjects($type: String!, $cursor: String) {
|
|
84
84
|
metaobjects(type: $type, first: 250, after: $cursor) {
|
|
@@ -102,15 +102,15 @@ const H = (e, t) => {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
);
|
|
105
|
-
for (const o of
|
|
106
|
-
const
|
|
105
|
+
for (const o of l.metaobjects.nodes) {
|
|
106
|
+
const i = o.fields.find(
|
|
107
107
|
(d) => d.key === "settings"
|
|
108
108
|
);
|
|
109
|
-
|
|
109
|
+
i != null && i.value && r.push(JSON.parse(i.value));
|
|
110
110
|
}
|
|
111
|
-
if (!
|
|
111
|
+
if (!l.metaobjects.pageInfo.hasNextPage)
|
|
112
112
|
break;
|
|
113
|
-
s =
|
|
113
|
+
s = l.metaobjects.pageInfo.endCursor;
|
|
114
114
|
}
|
|
115
115
|
return r;
|
|
116
116
|
}, T = async (e, {
|
|
@@ -118,19 +118,19 @@ const H = (e, t) => {
|
|
|
118
118
|
language: a,
|
|
119
119
|
blockVisibility: r,
|
|
120
120
|
excludedProductGIDs: s,
|
|
121
|
-
selectedProductGIDs:
|
|
121
|
+
selectedProductGIDs: l,
|
|
122
122
|
selectedCollectionGIDs: o,
|
|
123
|
-
limit:
|
|
123
|
+
limit: i = 1e3
|
|
124
124
|
}) => {
|
|
125
125
|
switch (r) {
|
|
126
126
|
case "selected-products":
|
|
127
|
-
return
|
|
127
|
+
return l.slice(0, i);
|
|
128
128
|
case "all-products":
|
|
129
129
|
case "excluded-products": {
|
|
130
130
|
const d = w({ country: t, language: a });
|
|
131
131
|
let u = [], c = null;
|
|
132
|
-
for (; u.length <
|
|
133
|
-
const p = Math.min(
|
|
132
|
+
for (; u.length < i; ) {
|
|
133
|
+
const p = Math.min(i - u.length, 250), g = await e.query(
|
|
134
134
|
`
|
|
135
135
|
query FetchProductGIDs($limit: Int!, $cursor: String) ${d} {
|
|
136
136
|
products(first: $limit, after: $cursor) {
|
|
@@ -178,13 +178,13 @@ const H = (e, t) => {
|
|
|
178
178
|
{
|
|
179
179
|
variables: {
|
|
180
180
|
collectionGIDs: o,
|
|
181
|
-
limit: Math.min(
|
|
181
|
+
limit: Math.min(i, 250)
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
)).nodes.filter((c) => c !== null).flatMap(
|
|
185
185
|
(c) => c.products.nodes.map((p) => p.id)
|
|
186
186
|
);
|
|
187
|
-
return Array.from(new Set(u)).slice(0,
|
|
187
|
+
return Array.from(new Set(u)).slice(0, i);
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
}, L = `
|
|
@@ -235,9 +235,9 @@ const H = (e, t) => {
|
|
|
235
235
|
language: a,
|
|
236
236
|
productIds: r,
|
|
237
237
|
includeSellingPlans: s = !0,
|
|
238
|
-
includeAvailableQuantity:
|
|
238
|
+
includeAvailableQuantity: l = !0,
|
|
239
239
|
useExternalMetafieldNamespace: o = !1,
|
|
240
|
-
batchSize:
|
|
240
|
+
batchSize: i = 250,
|
|
241
241
|
onBatchError: d,
|
|
242
242
|
variantImageTransform: u = { maxWidth: 200, maxHeight: 200 }
|
|
243
243
|
}) => {
|
|
@@ -330,7 +330,7 @@ const H = (e, t) => {
|
|
|
330
330
|
}
|
|
331
331
|
}
|
|
332
332
|
}
|
|
333
|
-
`, y = o ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles", h = [], n = Math.min(
|
|
333
|
+
`, y = o ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles", h = [], n = Math.min(i, 250);
|
|
334
334
|
for (let f = 0; f < c.length; f += n)
|
|
335
335
|
h.push(c.slice(f, f + n));
|
|
336
336
|
let m = 1;
|
|
@@ -339,7 +339,7 @@ const H = (e, t) => {
|
|
|
339
339
|
variables: {
|
|
340
340
|
productGIDs: f,
|
|
341
341
|
includeSellingPlans: s,
|
|
342
|
-
includeAvailableQuantity:
|
|
342
|
+
includeAvailableQuantity: l,
|
|
343
343
|
metafieldNamespace: y,
|
|
344
344
|
variantImageTransform: u
|
|
345
345
|
}
|
|
@@ -362,17 +362,17 @@ const H = (e, t) => {
|
|
|
362
362
|
if (d) {
|
|
363
363
|
const f = await Promise.allSettled(
|
|
364
364
|
_.map(async (P) => {
|
|
365
|
-
const R = await
|
|
365
|
+
const R = await M(
|
|
366
366
|
e,
|
|
367
367
|
P,
|
|
368
368
|
{
|
|
369
369
|
includeSellingPlans: s,
|
|
370
|
-
includeAvailableQuantity:
|
|
370
|
+
includeAvailableQuantity: l,
|
|
371
371
|
variantImageTransform: u
|
|
372
372
|
},
|
|
373
373
|
p
|
|
374
374
|
);
|
|
375
|
-
return
|
|
375
|
+
return q(
|
|
376
376
|
R,
|
|
377
377
|
e.shopifyDomain,
|
|
378
378
|
m
|
|
@@ -387,24 +387,24 @@ const H = (e, t) => {
|
|
|
387
387
|
}
|
|
388
388
|
return (await Promise.all(
|
|
389
389
|
_.map(
|
|
390
|
-
(f) =>
|
|
390
|
+
(f) => M(
|
|
391
391
|
e,
|
|
392
392
|
f,
|
|
393
393
|
{
|
|
394
394
|
includeSellingPlans: s,
|
|
395
|
-
includeAvailableQuantity:
|
|
395
|
+
includeAvailableQuantity: l,
|
|
396
396
|
variantImageTransform: u
|
|
397
397
|
},
|
|
398
398
|
p
|
|
399
399
|
)
|
|
400
400
|
)
|
|
401
401
|
)).map(
|
|
402
|
-
(f) =>
|
|
402
|
+
(f) => q(f, e.shopifyDomain, m)
|
|
403
403
|
);
|
|
404
|
-
},
|
|
404
|
+
}, M = async (e, t, a, r = "") => {
|
|
405
405
|
if (t.variants.nodes.length < 250)
|
|
406
406
|
return t;
|
|
407
|
-
const s = /* @__PURE__ */ new Set(),
|
|
407
|
+
const s = /* @__PURE__ */ new Set(), l = [], o = [], i = async (d) => {
|
|
408
408
|
let u = !0, c = null;
|
|
409
409
|
for (; u; ) {
|
|
410
410
|
const p = await e.query(
|
|
@@ -437,16 +437,16 @@ const H = (e, t) => {
|
|
|
437
437
|
u = !1;
|
|
438
438
|
break;
|
|
439
439
|
}
|
|
440
|
-
s.add(h.id), d ? o.push(h) :
|
|
440
|
+
s.add(h.id), d ? o.push(h) : l.push(h);
|
|
441
441
|
}
|
|
442
442
|
y.hasNextPage || (u = !1), c = y.endCursor;
|
|
443
443
|
}
|
|
444
444
|
};
|
|
445
445
|
return await Promise.all([
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
]), t.variants.nodes = [...
|
|
449
|
-
},
|
|
446
|
+
i(!1),
|
|
447
|
+
i(!0)
|
|
448
|
+
]), t.variants.nodes = [...l, ...o.reverse()], t;
|
|
449
|
+
}, q = (e, t, a) => {
|
|
450
450
|
var u, c, p, g, y, h;
|
|
451
451
|
const r = e.variants.nodes.map(
|
|
452
452
|
({ unitPriceMeasurement: n, ...m }) => {
|
|
@@ -501,7 +501,7 @@ const H = (e, t) => {
|
|
|
501
501
|
position: m + 1,
|
|
502
502
|
optionValues: ae(b, m, r)
|
|
503
503
|
};
|
|
504
|
-
}),
|
|
504
|
+
}), l = (n) => {
|
|
505
505
|
const m = n.priceAdjustments[0];
|
|
506
506
|
if (!m)
|
|
507
507
|
return null;
|
|
@@ -527,11 +527,11 @@ const H = (e, t) => {
|
|
|
527
527
|
`Unknown price adjustment type: ${b.__typename}`
|
|
528
528
|
);
|
|
529
529
|
}
|
|
530
|
-
}, o = (n) => a === 1 ? Number(n) * 100 : Math.round(Number(n) * 100 * a),
|
|
530
|
+
}, o = (n) => a === 1 ? Number(n) * 100 : Math.round(Number(n) * 100 * a), i = ((u = e.sellingPlanGroups) == null ? void 0 : u.nodes.flatMap(
|
|
531
531
|
(n) => n.sellingPlans.nodes.map((m) => ({
|
|
532
532
|
id: Number(m.id.split("/").pop()),
|
|
533
533
|
name: m.name,
|
|
534
|
-
priceAdjustment:
|
|
534
|
+
priceAdjustment: l(m)
|
|
535
535
|
}))
|
|
536
536
|
)) || [], d = e.variants.nodes.some(
|
|
537
537
|
(n) => n.requiresComponents
|
|
@@ -553,7 +553,7 @@ const H = (e, t) => {
|
|
|
553
553
|
),
|
|
554
554
|
variants: r,
|
|
555
555
|
requiresSellingPlan: e.requiresSellingPlan,
|
|
556
|
-
sellingPlans:
|
|
556
|
+
sellingPlans: i,
|
|
557
557
|
isNativeBundle: d,
|
|
558
558
|
metafields: {
|
|
559
559
|
text: ((p = e.metafield) == null ? void 0 : p.value) || null,
|
|
@@ -569,10 +569,10 @@ const H = (e, t) => {
|
|
|
569
569
|
country: a,
|
|
570
570
|
useExternalMetafieldNamespace: r
|
|
571
571
|
}) => {
|
|
572
|
-
const s = `${j}--kaching_bundles`,
|
|
572
|
+
const s = `${j}--kaching_bundles`, l = j, o = w({ country: a }), {
|
|
573
573
|
localization: {
|
|
574
574
|
country: {
|
|
575
|
-
currency: { isoCode:
|
|
575
|
+
currency: { isoCode: i }
|
|
576
576
|
}
|
|
577
577
|
},
|
|
578
578
|
shop: {
|
|
@@ -612,10 +612,10 @@ const H = (e, t) => {
|
|
|
612
612
|
{
|
|
613
613
|
variables: {
|
|
614
614
|
metafieldNamespace: s,
|
|
615
|
-
settingsNamespace:
|
|
615
|
+
settingsNamespace: l
|
|
616
616
|
}
|
|
617
617
|
}
|
|
618
|
-
), y =
|
|
618
|
+
), y = i === u ? d : K(i, { language: t, country: a }), h = c ? re(c.value) : 1, n = g ? JSON.parse(g.value) : null, m = (n == null ? void 0 : n.feature_flags) ?? {}, b = (n == null ? void 0 : n.custom_selectors) ?? {};
|
|
619
619
|
return {
|
|
620
620
|
shopifyDomain: p.host,
|
|
621
621
|
moneyFormat: y,
|
|
@@ -679,16 +679,16 @@ const H = (e, t) => {
|
|
|
679
679
|
}, re = (e) => JSON.parse(e).amount / 1e6, ne = async (e, t, a = 200) => {
|
|
680
680
|
const r = [
|
|
681
681
|
...new Set(
|
|
682
|
-
t.filter(Boolean).filter((
|
|
682
|
+
t.filter(Boolean).filter((l) => !l.startsWith("placeholder"))
|
|
683
683
|
)
|
|
684
684
|
];
|
|
685
685
|
if (r.length === 0) return [];
|
|
686
686
|
const s = [];
|
|
687
|
-
for (let
|
|
688
|
-
s.push(r.slice(
|
|
687
|
+
for (let l = 0; l < r.length; l += 250)
|
|
688
|
+
s.push(r.slice(l, l + 250));
|
|
689
689
|
return (await Promise.all(
|
|
690
690
|
s.map(
|
|
691
|
-
(
|
|
691
|
+
(l) => e.query(
|
|
692
692
|
`
|
|
693
693
|
query FetchMediaImages($mediaImageIds: [ID!]!, $size: Int!) {
|
|
694
694
|
nodes(ids: $mediaImageIds) {
|
|
@@ -703,16 +703,15 @@ const H = (e, t) => {
|
|
|
703
703
|
`,
|
|
704
704
|
{
|
|
705
705
|
variables: {
|
|
706
|
-
mediaImageIds:
|
|
706
|
+
mediaImageIds: l,
|
|
707
707
|
size: a
|
|
708
708
|
}
|
|
709
709
|
}
|
|
710
710
|
)
|
|
711
711
|
)
|
|
712
|
-
)).flatMap((
|
|
713
|
-
gid:
|
|
714
|
-
|
|
715
|
-
}));
|
|
712
|
+
)).flatMap((l) => l.nodes).flatMap(
|
|
713
|
+
(l) => l != null && l.image ? [{ gid: l.id, url: l.image.url }] : []
|
|
714
|
+
);
|
|
716
715
|
};
|
|
717
716
|
var k = /* @__PURE__ */ ((e) => (e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e))(k || {});
|
|
718
717
|
const le = (e) => [
|
|
@@ -757,10 +756,10 @@ const le = (e) => [
|
|
|
757
756
|
return (a = t.productPersonalisation) == null ? void 0 : a.mediaImageGID;
|
|
758
757
|
}).filter((t) => t != null), he = (e) => {
|
|
759
758
|
var r, s;
|
|
760
|
-
const t = e.dealBars.map((
|
|
759
|
+
const t = e.dealBars.map((l) => {
|
|
761
760
|
var o;
|
|
762
|
-
return (o =
|
|
763
|
-
}).filter((
|
|
761
|
+
return (o = l.highlights) == null ? void 0 : o.customIconGID;
|
|
762
|
+
}).filter((l) => l != null), a = (s = (r = e.subscriptions) == null ? void 0 : r.highlights) == null ? void 0 : s.customIconGID;
|
|
764
763
|
return a ? [...t, a] : t;
|
|
765
764
|
}, be = (e) => (e.badges || []).flatMap(
|
|
766
765
|
(t) => t.badgeType === "custom" && t.imageGID ? [t.imageGID] : []
|
|
@@ -835,11 +834,11 @@ class xe {
|
|
|
835
834
|
this.storefrontApiVersion = "2026-07", this.storefrontAccessToken = a, this.shopifyDomain = t;
|
|
836
835
|
}
|
|
837
836
|
async query(t, a) {
|
|
838
|
-
var
|
|
837
|
+
var i;
|
|
839
838
|
const r = (a == null ? void 0 : a.variables) ?? {};
|
|
840
839
|
let s = `https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`;
|
|
841
|
-
const
|
|
842
|
-
|
|
840
|
+
const l = (i = t.match(/query\s+(\w+)/)) == null ? void 0 : i[1];
|
|
841
|
+
l && (s += `?operation_name=${l}`);
|
|
843
842
|
const o = await fetch(s, {
|
|
844
843
|
method: "POST",
|
|
845
844
|
headers: {
|
|
@@ -851,48 +850,48 @@ class xe {
|
|
|
851
850
|
variables: r
|
|
852
851
|
})
|
|
853
852
|
});
|
|
854
|
-
return Ae(o,
|
|
853
|
+
return Ae(o, l);
|
|
855
854
|
}
|
|
856
855
|
}
|
|
857
856
|
const Ee = async (e, t, { country: a, language: r }) => {
|
|
858
857
|
const s = t.collectionBreaks;
|
|
859
858
|
if (!t.collectionBreaksEnabled || !s) return;
|
|
860
|
-
let
|
|
861
|
-
s.visibility === "deal-products" ?
|
|
859
|
+
let l;
|
|
860
|
+
s.visibility === "deal-products" ? l = await T(e, {
|
|
862
861
|
country: a,
|
|
863
862
|
language: r,
|
|
864
863
|
blockVisibility: t.blockVisibility,
|
|
865
864
|
excludedProductGIDs: (t.excludedProductIds || []).map(
|
|
866
|
-
(
|
|
865
|
+
(i) => `gid://shopify/Product/${i}`
|
|
867
866
|
),
|
|
868
867
|
selectedProductGIDs: (t.selectedProductIds || []).map(
|
|
869
|
-
(
|
|
868
|
+
(i) => `gid://shopify/Product/${i}`
|
|
870
869
|
),
|
|
871
870
|
selectedCollectionGIDs: (t.selectedCollectionIds || []).map(
|
|
872
|
-
(
|
|
871
|
+
(i) => `gid://shopify/Collection/${i}`
|
|
873
872
|
)
|
|
874
|
-
}) :
|
|
873
|
+
}) : l = await T(e, {
|
|
875
874
|
country: a,
|
|
876
875
|
language: r,
|
|
877
876
|
blockVisibility: s.visibility,
|
|
878
877
|
excludedProductGIDs: (s.excludedProducts || []).map(
|
|
879
|
-
({ id:
|
|
878
|
+
({ id: i }) => i
|
|
880
879
|
),
|
|
881
880
|
selectedProductGIDs: (s.selectedProducts || []).map(
|
|
882
|
-
({ id:
|
|
881
|
+
({ id: i }) => i
|
|
883
882
|
),
|
|
884
883
|
selectedCollectionGIDs: (s.selectedCollections || []).map(
|
|
885
|
-
({ id:
|
|
884
|
+
({ id: i }) => i
|
|
886
885
|
)
|
|
887
886
|
});
|
|
888
887
|
let o = await A(e, {
|
|
889
888
|
country: a,
|
|
890
889
|
language: r,
|
|
891
|
-
productIds:
|
|
890
|
+
productIds: l.map((i) => Number(i.split("/").pop())),
|
|
892
891
|
useExternalMetafieldNamespace: !0
|
|
893
892
|
});
|
|
894
893
|
return o = o.filter(
|
|
895
|
-
(
|
|
894
|
+
(i) => i.availableForSale
|
|
896
895
|
), o;
|
|
897
896
|
}, Be = ({
|
|
898
897
|
language: e,
|
|
@@ -942,7 +941,7 @@ const Ee = async (e, t, { country: a, language: r }) => {
|
|
|
942
941
|
}
|
|
943
942
|
const r = V(e);
|
|
944
943
|
return (s = a.find(
|
|
945
|
-
(
|
|
944
|
+
(l) => V(l.locale) === r
|
|
946
945
|
)) == null ? void 0 : s.translations;
|
|
947
946
|
}, V = (e) => e.toLowerCase().replace(/_/g, "-"), Ce = "2026-07", Te = async (e, {
|
|
948
947
|
productId: t,
|
|
@@ -950,10 +949,10 @@ const Ee = async (e, t, { country: a, language: r }) => {
|
|
|
950
949
|
country: r = void 0,
|
|
951
950
|
language: s = void 0
|
|
952
951
|
}) => {
|
|
953
|
-
var
|
|
952
|
+
var l, o;
|
|
954
953
|
try {
|
|
955
|
-
const
|
|
956
|
-
r = r || ((
|
|
954
|
+
const i = [Number(t.split("/").pop())], d = new Me(e);
|
|
955
|
+
r = r || ((l = d.i18n) == null ? void 0 : l.country), s = s || ((o = d.i18n) == null ? void 0 : o.language);
|
|
957
956
|
const u = await se(d, {
|
|
958
957
|
language: s,
|
|
959
958
|
country: r,
|
|
@@ -967,7 +966,7 @@ const Ee = async (e, t, { country: a, language: r }) => {
|
|
|
967
966
|
A(c, {
|
|
968
967
|
country: r,
|
|
969
968
|
language: s,
|
|
970
|
-
productIds:
|
|
969
|
+
productIds: i,
|
|
971
970
|
useExternalMetafieldNamespace: !0
|
|
972
971
|
}),
|
|
973
972
|
Z(c, {
|
|
@@ -1006,11 +1005,11 @@ const Ee = async (e, t, { country: a, language: r }) => {
|
|
|
1006
1005
|
collectionBreaksProducts: f ?? [],
|
|
1007
1006
|
translations: v
|
|
1008
1007
|
};
|
|
1009
|
-
} catch (
|
|
1010
|
-
return console.error(
|
|
1008
|
+
} catch (i) {
|
|
1009
|
+
return console.error(i), null;
|
|
1011
1010
|
}
|
|
1012
1011
|
};
|
|
1013
|
-
class
|
|
1012
|
+
class Me {
|
|
1014
1013
|
constructor(t) {
|
|
1015
1014
|
this.storefront = t, this.shopifyDomain = "";
|
|
1016
1015
|
}
|
|
@@ -1022,7 +1021,7 @@ class qe {
|
|
|
1022
1021
|
const s = await this.storefront.graphql(t, a);
|
|
1023
1022
|
if ((r = s.errors) != null && r.length)
|
|
1024
1023
|
throw new Error(
|
|
1025
|
-
s.errors.map((
|
|
1024
|
+
s.errors.map((l) => l.message).join(`
|
|
1026
1025
|
`)
|
|
1027
1026
|
);
|
|
1028
1027
|
return s.data;
|
|
@@ -1066,7 +1065,7 @@ class qe {
|
|
|
1066
1065
|
return this.storefront.i18n;
|
|
1067
1066
|
}
|
|
1068
1067
|
}
|
|
1069
|
-
const at = Te, $ = "kaching-bundles-block", U = 1e4,
|
|
1068
|
+
const at = Te, $ = "kaching-bundles-block", U = 1e4, qe = "https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js", je = "https://bundles-integrations.kachingappz.app/kaching-bundles-block.js", N = /* @__PURE__ */ new WeakSet(), Oe = async (e) => {
|
|
1070
1069
|
const t = e.document;
|
|
1071
1070
|
if (!e.customElements.get($)) {
|
|
1072
1071
|
if (N.has(t))
|
|
@@ -1078,7 +1077,7 @@ const at = Te, $ = "kaching-bundles-block", U = 1e4, Me = "https://bundles-integ
|
|
|
1078
1077
|
throw N.delete(t), a;
|
|
1079
1078
|
}
|
|
1080
1079
|
}
|
|
1081
|
-
}, Ve = () => typeof window < "u" && typeof window.__KACHING_DEV__ < "u", Ue = () => Ve() ?
|
|
1080
|
+
}, Ve = () => typeof window < "u" && typeof window.__KACHING_DEV__ < "u", Ue = () => Ve() ? qe : je, Fe = (e) => {
|
|
1082
1081
|
const t = e.document;
|
|
1083
1082
|
return new Promise((a, r) => {
|
|
1084
1083
|
const s = Ue();
|
|
@@ -1099,8 +1098,8 @@ const at = Te, $ = "kaching-bundles-block", U = 1e4, Me = "https://bundles-integ
|
|
|
1099
1098
|
Promise.race([
|
|
1100
1099
|
e.customElements.whenDefined(t),
|
|
1101
1100
|
new Promise(
|
|
1102
|
-
(s,
|
|
1103
|
-
() =>
|
|
1101
|
+
(s, l) => setTimeout(
|
|
1102
|
+
() => l(
|
|
1104
1103
|
new Error(
|
|
1105
1104
|
`Custom element "${t}" failed to register within ${U}ms`
|
|
1106
1105
|
)
|
|
@@ -1118,14 +1117,14 @@ function Qe(e, t = {}) {
|
|
|
1118
1117
|
e = e.replace(/^#/, "");
|
|
1119
1118
|
let a = 1;
|
|
1120
1119
|
e.length === 8 && (a = Number.parseInt(e.slice(6, 8), 16) / 255, e = e.slice(0, 6)), e.length === 4 && (a = Number.parseInt(e.slice(3, 4).repeat(2), 16) / 255, e = e.slice(0, 3)), e.length === 3 && (e = e[0] + e[0] + e[1] + e[1] + e[2] + e[2]);
|
|
1121
|
-
const r = Number.parseInt(e, 16), s = r >> 16,
|
|
1120
|
+
const r = Number.parseInt(e, 16), s = r >> 16, l = r >> 8 & 255, o = r & 255, i = typeof t.alpha == "number" ? t.alpha : a;
|
|
1122
1121
|
if (t.format === "array")
|
|
1123
|
-
return [s,
|
|
1122
|
+
return [s, l, o, i];
|
|
1124
1123
|
if (t.format === "css") {
|
|
1125
|
-
const d =
|
|
1126
|
-
return `rgb(${s} ${
|
|
1124
|
+
const d = i === 1 ? "" : ` / ${Number((i * 100).toFixed(2))}%`;
|
|
1125
|
+
return `rgb(${s} ${l} ${o}${d})`;
|
|
1127
1126
|
}
|
|
1128
|
-
return { red: s, green:
|
|
1127
|
+
return { red: s, green: l, blue: o, alpha: i };
|
|
1129
1128
|
}
|
|
1130
1129
|
const He = ({ price: e }) => ({
|
|
1131
1130
|
id: 123,
|
|
@@ -1490,14 +1489,14 @@ const He = ({ price: e }) => ({
|
|
|
1490
1489
|
onLinesChange: r,
|
|
1491
1490
|
targetWindow: s
|
|
1492
1491
|
}) => {
|
|
1493
|
-
const
|
|
1492
|
+
const l = B(null), [o, i] = z(!1), d = B(!1);
|
|
1494
1493
|
D(() => {
|
|
1495
|
-
if (!
|
|
1494
|
+
if (!l.current || o) return;
|
|
1496
1495
|
(async () => {
|
|
1497
|
-
await Oe(s ?? window),
|
|
1496
|
+
await Oe(s ?? window), i(!0);
|
|
1498
1497
|
})();
|
|
1499
1498
|
}, [o, s]), D(() => {
|
|
1500
|
-
const c =
|
|
1499
|
+
const c = l.current;
|
|
1501
1500
|
if (!o || !c) return;
|
|
1502
1501
|
const p = () => {
|
|
1503
1502
|
const y = c.items().map((h) => ({
|
|
@@ -1517,14 +1516,14 @@ const He = ({ price: e }) => ({
|
|
|
1517
1516
|
}, [o, r]);
|
|
1518
1517
|
const u = e ? Ye(e, t) : a ? Ze(a) : null;
|
|
1519
1518
|
return Xe(() => {
|
|
1520
|
-
const c =
|
|
1519
|
+
const c = l.current;
|
|
1521
1520
|
if (!(!c || !u))
|
|
1522
1521
|
for (const [p, g] of Object.entries(u.jsonAttributes))
|
|
1523
1522
|
c.getAttribute(p) !== g && c.setAttribute(p, g);
|
|
1524
1523
|
}), u ? /* @__PURE__ */ J(
|
|
1525
1524
|
"kaching-bundles-block",
|
|
1526
1525
|
{
|
|
1527
|
-
ref:
|
|
1526
|
+
ref: l,
|
|
1528
1527
|
"deal-block-id": u.dealBlockId,
|
|
1529
1528
|
...u.jsonAttributes,
|
|
1530
1529
|
"current-variant-id": u.currentVariantId
|
|
@@ -1536,18 +1535,18 @@ const He = ({ price: e }) => ({
|
|
|
1536
1535
|
product: a,
|
|
1537
1536
|
otherProducts: r,
|
|
1538
1537
|
mediaImages: s,
|
|
1539
|
-
collectionBreaksProducts:
|
|
1538
|
+
collectionBreaksProducts: l,
|
|
1540
1539
|
translations: o
|
|
1541
|
-
},
|
|
1540
|
+
}, i) => ({
|
|
1542
1541
|
dealBlockId: t.id,
|
|
1543
|
-
currentVariantId:
|
|
1542
|
+
currentVariantId: i ? i.split("/").pop() : String(a.variants[0].id),
|
|
1544
1543
|
jsonAttributes: {
|
|
1545
1544
|
config: JSON.stringify(e),
|
|
1546
1545
|
"deal-block": JSON.stringify(t),
|
|
1547
1546
|
"media-images": JSON.stringify(s),
|
|
1548
1547
|
product: JSON.stringify(a),
|
|
1549
1548
|
"other-products": JSON.stringify(r),
|
|
1550
|
-
"collection-breaks-products": JSON.stringify(
|
|
1549
|
+
"collection-breaks-products": JSON.stringify(l),
|
|
1551
1550
|
translations: JSON.stringify(o)
|
|
1552
1551
|
}
|
|
1553
1552
|
}), Ze = ({
|
|
@@ -1555,13 +1554,13 @@ const He = ({ price: e }) => ({
|
|
|
1555
1554
|
color: t,
|
|
1556
1555
|
price: a
|
|
1557
1556
|
}) => {
|
|
1558
|
-
const r = He({ price: a }), s = Ke(),
|
|
1557
|
+
const r = He({ price: a }), s = Ke(), l = We({ color: t, cornerRadius: e });
|
|
1559
1558
|
return {
|
|
1560
|
-
dealBlockId:
|
|
1559
|
+
dealBlockId: l.id,
|
|
1561
1560
|
currentVariantId: String(r.variants[0].id),
|
|
1562
1561
|
jsonAttributes: {
|
|
1563
1562
|
config: JSON.stringify(s),
|
|
1564
|
-
"deal-block": JSON.stringify(
|
|
1563
|
+
"deal-block": JSON.stringify(l),
|
|
1565
1564
|
"media-images": JSON.stringify([]),
|
|
1566
1565
|
product: JSON.stringify(r),
|
|
1567
1566
|
"other-products": JSON.stringify([]),
|