@kachingappz/bundles-js 1.1.2 → 1.1.4
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 +27 -18
- package/dist/index.d.ts +73 -10
- package/dist/index.js +611 -929
- package/dist/kaching-bundle-component/index.d.ts +73 -10
- package/dist/kaching-bundle-component/index.js +1118 -1357
- package/dist/react/index.cjs +26 -17
- package/dist/react/index.d.ts +73 -10
- package/dist/react/index.js +1086 -1432
- package/package.json +6 -11
package/dist/react/index.js
CHANGED
|
@@ -1,138 +1,66 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
metafield(namespace: $metafieldNamespace, key: "deal_blocks") {
|
|
65
|
-
value
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
`,
|
|
70
|
-
{
|
|
71
|
-
variables: {
|
|
72
|
-
metafieldNamespace: "app--2935586817--kaching_bundles"
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
)).shop.metafield) == null ? void 0 : r.value;
|
|
76
|
-
return a ? JSON.parse(a) : [];
|
|
77
|
-
}, te = async (e, t) => {
|
|
78
|
-
const a = "app--2935586817--deal_block", r = [];
|
|
79
|
-
let s = null;
|
|
80
|
-
for (; ; ) {
|
|
81
|
-
const l = await e.query(
|
|
82
|
-
`
|
|
83
|
-
query FetchDealBlockMetaobjects($type: String!, $cursor: String) {
|
|
84
|
-
metaobjects(type: $type, first: 250, after: $cursor) {
|
|
85
|
-
nodes {
|
|
86
|
-
fields {
|
|
87
|
-
key
|
|
88
|
-
value
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
pageInfo {
|
|
92
|
-
hasNextPage
|
|
93
|
-
endCursor
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
`,
|
|
98
|
-
{
|
|
99
|
-
variables: {
|
|
100
|
-
type: a,
|
|
101
|
-
cursor: s
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
);
|
|
105
|
-
for (const o of l.metaobjects.nodes) {
|
|
106
|
-
const i = o.fields.find(
|
|
107
|
-
(d) => d.key === "settings"
|
|
108
|
-
);
|
|
109
|
-
i != null && i.value && r.push(JSON.parse(i.value));
|
|
110
|
-
}
|
|
111
|
-
if (!l.metaobjects.pageInfo.hasNextPage)
|
|
112
|
-
break;
|
|
113
|
-
s = l.metaobjects.pageInfo.endCursor;
|
|
114
|
-
}
|
|
115
|
-
return r;
|
|
116
|
-
}, T = async (e, {
|
|
117
|
-
country: t,
|
|
118
|
-
language: a,
|
|
119
|
-
blockVisibility: r,
|
|
120
|
-
excludedProductGIDs: s,
|
|
121
|
-
selectedProductGIDs: l,
|
|
122
|
-
selectedCollectionGIDs: o,
|
|
123
|
-
limit: i = 1e3
|
|
124
|
-
}) => {
|
|
125
|
-
switch (r) {
|
|
126
|
-
case "selected-products":
|
|
127
|
-
return l.slice(0, i);
|
|
128
|
-
case "all-products":
|
|
129
|
-
case "excluded-products": {
|
|
130
|
-
const d = w({ country: t, language: a });
|
|
131
|
-
let u = [], c = null;
|
|
132
|
-
for (; u.length < i; ) {
|
|
133
|
-
const p = Math.min(i - u.length, 250), g = await e.query(
|
|
134
|
-
`
|
|
135
|
-
query FetchProductGIDs($limit: Int!, $cursor: String) ${d} {
|
|
1
|
+
import { useEffect as e, useLayoutEffect as t, useRef as n, useState as r } from "react";
|
|
2
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
3
|
+
// ../bundles-storefront-api/dist/buildMarketMoneyFormat.js
|
|
4
|
+
var a = (e, { language: t, country: n }) => {
|
|
5
|
+
let r = l(t, n), i = new Intl.NumberFormat(r, {
|
|
6
|
+
style: "currency",
|
|
7
|
+
currency: e,
|
|
8
|
+
currencyDisplay: "narrowSymbol"
|
|
9
|
+
}).formatToParts(1234567.89), a = i.find((e) => e.type === "decimal")?.value, s = d(u(i.find((e) => e.type === "group")?.value), a, i.some((e) => e.type === "fraction")), f = i.findIndex(c), p = i.findLastIndex(c);
|
|
10
|
+
return [
|
|
11
|
+
...i.slice(0, f).map(o),
|
|
12
|
+
s,
|
|
13
|
+
...i.slice(p + 1).map(o)
|
|
14
|
+
].join("");
|
|
15
|
+
}, o = (e) => s(e.value), s = (e) => e.replace(/\s/g, " "), c = (e) => e.type === "integer" || e.type === "group" || e.type === "decimal" || e.type === "fraction", l = (e, t) => e && t ? `${e}-${t.toUpperCase()}` : e || (t ? t.toUpperCase() : "en"), u = (e) => e === void 0 ? void 0 : s(e).replace(/’/g, "'"), d = (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}}", f = ({ country: e, language: t }) => {
|
|
16
|
+
let n = [];
|
|
17
|
+
return e && n.push(`country: ${e}`), t && n.push(`language: ${t}`), n.length > 0 ? `@inContext(${n.join(", ")})` : "";
|
|
18
|
+
}, p = async (e, { useExternalMetafieldNamespace: t, useMetaobjects: n }) => n ? h(e, t) : m(e, t), m = async (e, t) => {
|
|
19
|
+
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;
|
|
20
|
+
return n ? JSON.parse(n) : [];
|
|
21
|
+
}, h = async (e, t) => {
|
|
22
|
+
let n = t ? "app--2935586817--deal_block" : "$app:deal_block", r = [], i = null;
|
|
23
|
+
for (;;) {
|
|
24
|
+
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: {
|
|
25
|
+
type: n,
|
|
26
|
+
cursor: i
|
|
27
|
+
} });
|
|
28
|
+
for (let e of t.metaobjects.nodes) {
|
|
29
|
+
let t = e.fields.find((e) => e.key === "settings");
|
|
30
|
+
t?.value && r.push(JSON.parse(t.value));
|
|
31
|
+
}
|
|
32
|
+
if (!t.metaobjects.pageInfo.hasNextPage) break;
|
|
33
|
+
i = t.metaobjects.pageInfo.endCursor;
|
|
34
|
+
}
|
|
35
|
+
return r;
|
|
36
|
+
};
|
|
37
|
+
[
|
|
38
|
+
"primaryBackground",
|
|
39
|
+
"secondaryBackground",
|
|
40
|
+
"primaryText",
|
|
41
|
+
"secondaryText",
|
|
42
|
+
"border",
|
|
43
|
+
"overlay",
|
|
44
|
+
"primaryAccent",
|
|
45
|
+
"primaryAccentText",
|
|
46
|
+
"badgeBackground",
|
|
47
|
+
"badgeText",
|
|
48
|
+
"error"
|
|
49
|
+
].map((e) => `brand_${e}`);
|
|
50
|
+
var g = /* @__PURE__ */ function(e) {
|
|
51
|
+
return e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e;
|
|
52
|
+
}({}), _ = async (e, { country: t, language: n, blockVisibility: r, excludedProductGIDs: i, selectedProductGIDs: a, selectedCollectionGIDs: o, limit: s = 1e3 }) => {
|
|
53
|
+
switch (r) {
|
|
54
|
+
case "selected-products": return a.slice(0, s);
|
|
55
|
+
case "all-products":
|
|
56
|
+
case "excluded-products": {
|
|
57
|
+
let a = f({
|
|
58
|
+
country: t,
|
|
59
|
+
language: n
|
|
60
|
+
}), o = [], c = null;
|
|
61
|
+
for (; o.length < s;) {
|
|
62
|
+
let t = Math.min(s - o.length, 250), n = await e.query(`
|
|
63
|
+
query FetchProductGIDs($limit: Int!, $cursor: String) ${a} {
|
|
136
64
|
products(first: $limit, after: $cursor) {
|
|
137
65
|
nodes {
|
|
138
66
|
id
|
|
@@ -143,27 +71,25 @@ const H = (e, t) => {
|
|
|
143
71
|
}
|
|
144
72
|
}
|
|
145
73
|
}
|
|
146
|
-
`,
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
`
|
|
166
|
-
query FetchCollectionProductGIDs($collectionGIDs: [ID!]!, $limit: Int!) ${d} {
|
|
74
|
+
`, { variables: {
|
|
75
|
+
limit: t,
|
|
76
|
+
cursor: c
|
|
77
|
+
} });
|
|
78
|
+
if (o.push(...n.products.nodes.map((e) => e.id)), !n.products.pageInfo.hasNextPage) break;
|
|
79
|
+
c = n.products.pageInfo.endCursor;
|
|
80
|
+
}
|
|
81
|
+
if (r === "excluded-products") {
|
|
82
|
+
let e = new Set(i);
|
|
83
|
+
o = o.filter((t) => !e.has(t));
|
|
84
|
+
}
|
|
85
|
+
return o;
|
|
86
|
+
}
|
|
87
|
+
case "selected-collections": {
|
|
88
|
+
let r = f({
|
|
89
|
+
country: t,
|
|
90
|
+
language: n
|
|
91
|
+
}), i = (await e.query(`
|
|
92
|
+
query FetchCollectionProductGIDs($collectionGIDs: [ID!]!, $limit: Int!) ${r} {
|
|
167
93
|
nodes(ids: $collectionGIDs) {
|
|
168
94
|
... on Collection {
|
|
169
95
|
products(first: $limit) {
|
|
@@ -174,77 +100,23 @@ const H = (e, t) => {
|
|
|
174
100
|
}
|
|
175
101
|
}
|
|
176
102
|
}
|
|
177
|
-
`,
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
amount
|
|
195
|
-
}
|
|
196
|
-
compareAtPrice {
|
|
197
|
-
amount
|
|
198
|
-
}
|
|
199
|
-
selectedOptions {
|
|
200
|
-
name
|
|
201
|
-
value
|
|
202
|
-
}
|
|
203
|
-
image {
|
|
204
|
-
id
|
|
205
|
-
url(transform: $variantImageTransform)
|
|
206
|
-
}
|
|
207
|
-
unitPriceMeasurement {
|
|
208
|
-
quantityUnit
|
|
209
|
-
quantityValue
|
|
210
|
-
referenceUnit
|
|
211
|
-
referenceValue
|
|
212
|
-
}
|
|
213
|
-
requiresComponents
|
|
214
|
-
sellingPlanAllocations(first: 100) @include(if: $includeSellingPlans) {
|
|
215
|
-
nodes {
|
|
216
|
-
sellingPlan {
|
|
217
|
-
id
|
|
218
|
-
}
|
|
219
|
-
priceAdjustments {
|
|
220
|
-
price {
|
|
221
|
-
amount
|
|
222
|
-
}
|
|
223
|
-
compareAtPrice {
|
|
224
|
-
amount
|
|
225
|
-
}
|
|
226
|
-
perDeliveryPrice {
|
|
227
|
-
amount
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
quantityAvailable @include(if: $includeAvailableQuantity)
|
|
233
|
-
`, A = async (e, {
|
|
234
|
-
country: t,
|
|
235
|
-
language: a,
|
|
236
|
-
productIds: r,
|
|
237
|
-
includeSellingPlans: s = !0,
|
|
238
|
-
includeAvailableQuantity: l = !0,
|
|
239
|
-
useExternalMetafieldNamespace: o = !1,
|
|
240
|
-
batchSize: i = 250,
|
|
241
|
-
onBatchError: d,
|
|
242
|
-
variantImageTransform: u = { maxWidth: 200, maxHeight: 200 }
|
|
243
|
-
}) => {
|
|
244
|
-
if (!r.length)
|
|
245
|
-
return [];
|
|
246
|
-
const c = r.map((f) => typeof f == "string" && f.startsWith("gid://") ? f : `gid://shopify/Product/${f}`), p = w({ country: t, language: a }), g = `
|
|
247
|
-
query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $metafieldNamespace: String!, $variantImageTransform: ImageTransformInput) ${p} {
|
|
103
|
+
`, { variables: {
|
|
104
|
+
collectionGIDs: o,
|
|
105
|
+
limit: Math.min(s, 250)
|
|
106
|
+
} })).nodes.filter((e) => e !== null).flatMap((e) => e.products.nodes.map((e) => e.id));
|
|
107
|
+
return Array.from(new Set(i)).slice(0, s);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}, v = "\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", y = async (e, { country: t, language: n, productIds: r, includeSellingPlans: i = !0, includeAvailableQuantity: a = !0, includeProductRating: o = !1, includeProductSubtitle: s = !1, productSubtitleMetafield: c = "descriptors.subtitle", useExternalMetafieldNamespace: l = !1, batchSize: u = 250, onBatchError: d, variantImageTransform: p = {
|
|
111
|
+
maxWidth: 200,
|
|
112
|
+
maxHeight: 200
|
|
113
|
+
} }) => {
|
|
114
|
+
if (!r.length) return [];
|
|
115
|
+
let m = r.map((e) => typeof e == "string" && e.startsWith("gid://") ? e : `gid://shopify/Product/${e}`), h = f({
|
|
116
|
+
country: t,
|
|
117
|
+
language: n
|
|
118
|
+
}), g = `
|
|
119
|
+
query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $includeProductRating: Boolean!, $includeProductSubtitle: Boolean!, $subtitleNamespace: String!, $subtitleKey: String!, $metafieldNamespace: String!, $variantImageTransform: ImageTransformInput) ${h} {
|
|
248
120
|
shop {
|
|
249
121
|
currencyRateConstant: metafield(namespace: $metafieldNamespace, key: "currency_rate_constant") {
|
|
250
122
|
value
|
|
@@ -278,7 +150,7 @@ const H = (e, t) => {
|
|
|
278
150
|
}
|
|
279
151
|
variants(first: 250) {
|
|
280
152
|
nodes {
|
|
281
|
-
${
|
|
153
|
+
${v}
|
|
282
154
|
}
|
|
283
155
|
}
|
|
284
156
|
collections(first: 50) {
|
|
@@ -298,6 +170,15 @@ const H = (e, t) => {
|
|
|
298
170
|
metafield4: metafield(namespace: $metafieldNamespace, key: "text4") {
|
|
299
171
|
value
|
|
300
172
|
}
|
|
173
|
+
reviewsRating: metafield(namespace: "reviews", key: "rating") @include(if: $includeProductRating) {
|
|
174
|
+
value
|
|
175
|
+
}
|
|
176
|
+
reviewsRatingCount: metafield(namespace: "reviews", key: "rating_count") @include(if: $includeProductRating) {
|
|
177
|
+
value
|
|
178
|
+
}
|
|
179
|
+
subtitle: metafield(namespace: $subtitleNamespace, key: $subtitleKey) @include(if: $includeProductSubtitle) {
|
|
180
|
+
value
|
|
181
|
+
}
|
|
301
182
|
requiresSellingPlan
|
|
302
183
|
sellingPlanGroups(first: 100) @include(if: $includeSellingPlans) {
|
|
303
184
|
nodes {
|
|
@@ -330,90 +211,53 @@ const H = (e, t) => {
|
|
|
330
211
|
}
|
|
331
212
|
}
|
|
332
213
|
}
|
|
333
|
-
`,
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
return q(
|
|
376
|
-
R,
|
|
377
|
-
e.shopifyDomain,
|
|
378
|
-
m
|
|
379
|
-
);
|
|
380
|
-
})
|
|
381
|
-
), v = [];
|
|
382
|
-
for (const P of f)
|
|
383
|
-
P.status === "fulfilled" ? v.push(P.value) : d(
|
|
384
|
-
P.reason instanceof Error ? P.reason : new Error(String(P.reason))
|
|
385
|
-
);
|
|
386
|
-
return v;
|
|
387
|
-
}
|
|
388
|
-
return (await Promise.all(
|
|
389
|
-
_.map(
|
|
390
|
-
(f) => M(
|
|
391
|
-
e,
|
|
392
|
-
f,
|
|
393
|
-
{
|
|
394
|
-
includeSellingPlans: s,
|
|
395
|
-
includeAvailableQuantity: l,
|
|
396
|
-
variantImageTransform: u
|
|
397
|
-
},
|
|
398
|
-
p
|
|
399
|
-
)
|
|
400
|
-
)
|
|
401
|
-
)).map(
|
|
402
|
-
(f) => q(f, e.shopifyDomain, m)
|
|
403
|
-
);
|
|
404
|
-
}, M = async (e, t, a, r = "") => {
|
|
405
|
-
if (t.variants.nodes.length < 250)
|
|
406
|
-
return t;
|
|
407
|
-
const s = /* @__PURE__ */ new Set(), l = [], o = [], i = async (d) => {
|
|
408
|
-
let u = !0, c = null;
|
|
409
|
-
for (; u; ) {
|
|
410
|
-
const p = await e.query(
|
|
411
|
-
`
|
|
214
|
+
`, _ = l ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles", y = c.indexOf("."), S = c.slice(0, y), C = c.slice(y + 1), w = [], T = Math.min(u, 250);
|
|
215
|
+
for (let e = 0; e < m.length; e += T) w.push(m.slice(e, e + T));
|
|
216
|
+
let E = 1, D = async (t) => {
|
|
217
|
+
let n = await e.query(g, { variables: {
|
|
218
|
+
productGIDs: t,
|
|
219
|
+
includeSellingPlans: i,
|
|
220
|
+
includeAvailableQuantity: a,
|
|
221
|
+
includeProductRating: o,
|
|
222
|
+
includeProductSubtitle: s,
|
|
223
|
+
subtitleNamespace: S,
|
|
224
|
+
subtitleKey: C,
|
|
225
|
+
metafieldNamespace: _,
|
|
226
|
+
variantImageTransform: p
|
|
227
|
+
} });
|
|
228
|
+
return n.shop.currencyRateConstant && (E = JSON.parse(n.shop.currencyRateConstant.value).amount / 1e6), n;
|
|
229
|
+
}, O;
|
|
230
|
+
if (d) {
|
|
231
|
+
let e = await Promise.allSettled(w.map(D));
|
|
232
|
+
for (let t of e) t.status === "rejected" && d(t.reason instanceof Error ? t.reason : Error(String(t.reason)));
|
|
233
|
+
O = e.filter((e) => e.status === "fulfilled").flatMap((e) => e.value.nodes);
|
|
234
|
+
} else O = (await Promise.all(w.map(D))).flatMap((e) => e.nodes);
|
|
235
|
+
let k = O.filter((e) => e != null);
|
|
236
|
+
if (d) {
|
|
237
|
+
let t = await Promise.allSettled(k.map(async (t) => x(await b(e, t, {
|
|
238
|
+
includeSellingPlans: i,
|
|
239
|
+
includeAvailableQuantity: a,
|
|
240
|
+
variantImageTransform: p
|
|
241
|
+
}, h), e.shopifyDomain, E))), n = [];
|
|
242
|
+
for (let e of t) e.status === "fulfilled" ? n.push(e.value) : d(e.reason instanceof Error ? e.reason : Error(String(e.reason)));
|
|
243
|
+
return n;
|
|
244
|
+
}
|
|
245
|
+
return (await Promise.all(k.map((t) => b(e, t, {
|
|
246
|
+
includeSellingPlans: i,
|
|
247
|
+
includeAvailableQuantity: a,
|
|
248
|
+
variantImageTransform: p
|
|
249
|
+
}, h)))).map((t) => x(t, e.shopifyDomain, E));
|
|
250
|
+
}, b = async (e, t, n, r = "") => {
|
|
251
|
+
if (t.variants.nodes.length < 250) return t;
|
|
252
|
+
let i = /* @__PURE__ */ new Set(), a = [], o = [], s = async (s) => {
|
|
253
|
+
let c = !0, l = null;
|
|
254
|
+
for (; c;) {
|
|
255
|
+
let { nodes: u, pageInfo: d } = (await e.query(`
|
|
412
256
|
query($productGID: ID!, $cursor: String, $reverse: Boolean, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $variantImageTransform: ImageTransformInput) ${r} {
|
|
413
257
|
product(id: $productGID) {
|
|
414
258
|
variants(first: 250, after: $cursor, reverse: $reverse) {
|
|
415
259
|
nodes {
|
|
416
|
-
${
|
|
260
|
+
${v}
|
|
417
261
|
}
|
|
418
262
|
pageInfo {
|
|
419
263
|
endCursor
|
|
@@ -422,169 +266,130 @@ const H = (e, t) => {
|
|
|
422
266
|
}
|
|
423
267
|
}
|
|
424
268
|
}
|
|
425
|
-
`,
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
(
|
|
549
|
-
),
|
|
550
|
-
options: s,
|
|
551
|
-
selectedVariantId: Number(
|
|
552
|
-
e.variants.nodes[0].id.split("/").pop()
|
|
553
|
-
),
|
|
554
|
-
variants: r,
|
|
555
|
-
requiresSellingPlan: e.requiresSellingPlan,
|
|
556
|
-
sellingPlans: i,
|
|
557
|
-
isNativeBundle: d,
|
|
558
|
-
metafields: {
|
|
559
|
-
text: ((p = e.metafield) == null ? void 0 : p.value) || null,
|
|
560
|
-
text2: ((g = e.metafield2) == null ? void 0 : g.value) || null,
|
|
561
|
-
text3: ((y = e.metafield3) == null ? void 0 : y.value) || null,
|
|
562
|
-
text4: ((h = e.metafield4) == null ? void 0 : h.value) || null
|
|
563
|
-
}
|
|
564
|
-
};
|
|
565
|
-
}, ae = (e, t, a) => e.filter((r) => a.filter(
|
|
566
|
-
(s) => s.options[t] === r.name
|
|
567
|
-
).length > 0), j = "app--2935586817", se = async (e, {
|
|
568
|
-
language: t,
|
|
569
|
-
country: a,
|
|
570
|
-
useExternalMetafieldNamespace: r
|
|
571
|
-
}) => {
|
|
572
|
-
const s = `${j}--kaching_bundles`, l = j, o = w({ country: a }), {
|
|
573
|
-
localization: {
|
|
574
|
-
country: {
|
|
575
|
-
currency: { isoCode: i }
|
|
576
|
-
}
|
|
577
|
-
},
|
|
578
|
-
shop: {
|
|
579
|
-
moneyFormat: d,
|
|
580
|
-
paymentSettings: { currencyCode: u },
|
|
581
|
-
currencyRateConstant: c,
|
|
582
|
-
primaryDomain: p,
|
|
583
|
-
settingsMetafield: g
|
|
584
|
-
}
|
|
585
|
-
} = await e.query(
|
|
586
|
-
`
|
|
587
|
-
query config($metafieldNamespace: String!, $settingsNamespace: String!) ${o} {
|
|
269
|
+
`, { variables: {
|
|
270
|
+
productGID: t.id,
|
|
271
|
+
cursor: l,
|
|
272
|
+
reverse: s,
|
|
273
|
+
...n
|
|
274
|
+
} })).product.variants;
|
|
275
|
+
for (let e of u) {
|
|
276
|
+
if (i.has(e.id)) {
|
|
277
|
+
c = !1;
|
|
278
|
+
break;
|
|
279
|
+
}
|
|
280
|
+
i.add(e.id), s ? o.push(e) : a.push(e);
|
|
281
|
+
}
|
|
282
|
+
d.hasNextPage || (c = !1), l = d.endCursor;
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
return await Promise.all([s(!1), s(!0)]), t.variants.nodes = [...a, ...o.reverse()], t;
|
|
286
|
+
}, x = (e, t, n) => {
|
|
287
|
+
let r = e.variants.nodes.map(({ unitPriceMeasurement: e, ...t }) => ({
|
|
288
|
+
id: Number(t.id.split("/").pop()),
|
|
289
|
+
availableForSale: t.availableForSale,
|
|
290
|
+
price: Math.round(Number(t.price.amount) * 100),
|
|
291
|
+
compareAtPrice: t.compareAtPrice ? Math.round(Number(t.compareAtPrice.amount) * 100) : null,
|
|
292
|
+
options: t.selectedOptions.map((e) => e.value),
|
|
293
|
+
imageId: t.image ? Number(t.image.id.split("/").pop()) : null,
|
|
294
|
+
image: t.image?.url || null,
|
|
295
|
+
sellingPlans: t.sellingPlanAllocations?.nodes.map((e) => ({
|
|
296
|
+
id: Number(e.sellingPlan.id.split("/").pop()),
|
|
297
|
+
price: e.priceAdjustments.length > 0 ? Math.round(Number(e.priceAdjustments[0].price.amount) * 100) : Math.round(Number(t.price.amount) * 100),
|
|
298
|
+
compareAtPrice: e.priceAdjustments.length > 0 ? Math.round(Number(e.priceAdjustments[0].compareAtPrice.amount) * 100) : Math.round(Number(t.price.amount) * 100),
|
|
299
|
+
perDeliveryPrice: e.priceAdjustments.length > 0 ? Math.round(Number(e.priceAdjustments[0].perDeliveryPrice.amount) * 100) : Math.round(Number(t.price.amount) * 100)
|
|
300
|
+
})) || [],
|
|
301
|
+
inventoryManagement: null,
|
|
302
|
+
inventoryPolicy: null,
|
|
303
|
+
inventoryQuantity: t.quantityAvailable ?? null,
|
|
304
|
+
unitPriceMeasurement: e?.quantityUnit && e?.referenceUnit ? {
|
|
305
|
+
quantityValue: e.quantityValue,
|
|
306
|
+
quantityUnit: e.quantityUnit.toLowerCase(),
|
|
307
|
+
referenceValue: e.referenceValue,
|
|
308
|
+
referenceUnit: e.referenceUnit.toLowerCase()
|
|
309
|
+
} : null
|
|
310
|
+
})), i = e.options.map((e, t) => {
|
|
311
|
+
let n = e.optionValues.map((e) => ({
|
|
312
|
+
id: Number(e.id.split("/").pop()),
|
|
313
|
+
defaultName: e.name,
|
|
314
|
+
name: e.name,
|
|
315
|
+
swatch: {
|
|
316
|
+
color: e.swatch?.color || null,
|
|
317
|
+
image: e.swatch?.image?.previewImage?.url || null
|
|
318
|
+
}
|
|
319
|
+
}));
|
|
320
|
+
return {
|
|
321
|
+
defaultName: e.name,
|
|
322
|
+
name: e.name,
|
|
323
|
+
position: t + 1,
|
|
324
|
+
optionValues: w(n, t, r)
|
|
325
|
+
};
|
|
326
|
+
}), a = (e) => {
|
|
327
|
+
let t = e.priceAdjustments[0];
|
|
328
|
+
if (!t) return null;
|
|
329
|
+
let n = t.adjustmentValue;
|
|
330
|
+
switch (n.__typename) {
|
|
331
|
+
case "SellingPlanPercentagePriceAdjustment": return {
|
|
332
|
+
type: "percentage",
|
|
333
|
+
value: n.adjustmentPercentage
|
|
334
|
+
};
|
|
335
|
+
case "SellingPlanFixedAmountPriceAdjustment": return {
|
|
336
|
+
type: "fixed_amount",
|
|
337
|
+
value: o(n.adjustmentAmount.amount)
|
|
338
|
+
};
|
|
339
|
+
case "SellingPlanFixedPriceAdjustment": return {
|
|
340
|
+
type: "price",
|
|
341
|
+
value: o(n.price.amount)
|
|
342
|
+
};
|
|
343
|
+
default: throw Error(`Unknown price adjustment type: ${n.__typename}`);
|
|
344
|
+
}
|
|
345
|
+
}, o = (e) => n === 1 ? Number(e) * 100 : Math.round(Number(e) * 100 * n), s = e.sellingPlanGroups?.nodes.flatMap((e) => e.sellingPlans.nodes.map((e) => ({
|
|
346
|
+
id: Number(e.id.split("/").pop()),
|
|
347
|
+
name: e.name,
|
|
348
|
+
priceAdjustment: a(e)
|
|
349
|
+
}))) || [], c = e.variants.nodes.some((e) => e.requiresComponents);
|
|
350
|
+
return {
|
|
351
|
+
id: Number(e.id.split("/").pop()),
|
|
352
|
+
handle: e.handle,
|
|
353
|
+
url: e.onlineStoreUrl || `https://${t}/products/${e.handle}`,
|
|
354
|
+
availableForSale: e.availableForSale,
|
|
355
|
+
createdAt: e.createdAt,
|
|
356
|
+
title: e.title,
|
|
357
|
+
image: e.featuredImage?.url || null,
|
|
358
|
+
collectionIds: e.collections.nodes.map((e) => Number(e.id.split("/").pop())),
|
|
359
|
+
options: i,
|
|
360
|
+
selectedVariantId: Number(e.variants.nodes[0].id.split("/").pop()),
|
|
361
|
+
variants: r,
|
|
362
|
+
requiresSellingPlan: e.requiresSellingPlan,
|
|
363
|
+
sellingPlans: s,
|
|
364
|
+
isNativeBundle: c,
|
|
365
|
+
metafields: {
|
|
366
|
+
text: e.metafield?.value || null,
|
|
367
|
+
text2: e.metafield2?.value || null,
|
|
368
|
+
text3: e.metafield3?.value || null,
|
|
369
|
+
text4: e.metafield4?.value || null
|
|
370
|
+
},
|
|
371
|
+
rating: S(e.reviewsRating, e.reviewsRatingCount),
|
|
372
|
+
subtitle: e.subtitle?.value || null
|
|
373
|
+
};
|
|
374
|
+
}, S = (e, t) => {
|
|
375
|
+
if (!e) return null;
|
|
376
|
+
let n = C(e.value);
|
|
377
|
+
if (n === null) return null;
|
|
378
|
+
let r = Number(t?.value);
|
|
379
|
+
return {
|
|
380
|
+
value: n,
|
|
381
|
+
count: Number.isInteger(r) && r > 0 ? r : null
|
|
382
|
+
};
|
|
383
|
+
}, C = (e) => {
|
|
384
|
+
try {
|
|
385
|
+
let { value: t, scale_max: n } = JSON.parse(e), r = Number(t) / Number(n) * 5;
|
|
386
|
+
return Number.isFinite(r) && r > 0 ? Math.min(5, r) : null;
|
|
387
|
+
} catch {
|
|
388
|
+
return null;
|
|
389
|
+
}
|
|
390
|
+
}, w = (e, t, n) => e.filter((e) => n.filter((n) => n.options[t] === e.name).length > 0), T = "app--2935586817", E = async (e, { language: t, country: n, useExternalMetafieldNamespace: r }) => {
|
|
391
|
+
let i = r ? `${T}--kaching_bundles` : "$app:kaching_bundles", o = r ? T : "$app", s = f({ country: n }), { localization: { country: { currency: { isoCode: c } } }, shop: { moneyFormat: l, paymentSettings: { currencyCode: u }, currencyRateConstant: d, primaryDomain: p, settingsMetafield: m } } = await e.query(`
|
|
392
|
+
query config($metafieldNamespace: String!, $settingsNamespace: String!) ${s} {
|
|
588
393
|
localization {
|
|
589
394
|
country {
|
|
590
395
|
currency {
|
|
@@ -608,968 +413,817 @@ const H = (e, t) => {
|
|
|
608
413
|
}
|
|
609
414
|
}
|
|
610
415
|
}
|
|
611
|
-
`,
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
416
|
+
`, { variables: {
|
|
417
|
+
metafieldNamespace: i,
|
|
418
|
+
settingsNamespace: o
|
|
419
|
+
} }), h = c === u ? l : a(c, {
|
|
420
|
+
language: t,
|
|
421
|
+
country: n
|
|
422
|
+
}), g = d ? D(d.value) : 1, _ = m ? JSON.parse(m.value) : null, v = _?.feature_flags ?? {}, y = _?.custom_selectors ?? {};
|
|
423
|
+
return {
|
|
424
|
+
shopifyDomain: p.host,
|
|
425
|
+
moneyFormat: h,
|
|
426
|
+
locale: t?.toLowerCase() || "en",
|
|
427
|
+
liquidLocale: t?.toLowerCase() || "en",
|
|
428
|
+
country: n ?? "US",
|
|
429
|
+
currencyRate: g,
|
|
430
|
+
marketId: 0,
|
|
431
|
+
productId: null,
|
|
432
|
+
storefrontAccessToken: _?.storefront_access_token ?? null,
|
|
433
|
+
includeSellingPlans: _?.include_selling_plans ?? !1,
|
|
434
|
+
includeAvailableQuantity: _?.include_available_quantity ?? !1,
|
|
435
|
+
customApiHost: _?.custom_api_host ?? null,
|
|
436
|
+
keepQuantityInput: _?.keep_quantity_input ?? !1,
|
|
437
|
+
ignoreDeselect: _?.ignore_deselect ?? !1,
|
|
438
|
+
ignoreUnitPrice: _?.ignore_unit_price ?? !1,
|
|
439
|
+
requireCustomerLogin: _?.require_customer_login ?? !1,
|
|
440
|
+
abTestsRunning: _?.ab_tests_running ?? !1,
|
|
441
|
+
webPixel: _?.web_pixel ?? !1,
|
|
442
|
+
b2bCustomer: !1,
|
|
443
|
+
isLoggedIn: !1,
|
|
444
|
+
preview: !1,
|
|
445
|
+
previewAlerts: !1,
|
|
446
|
+
previewScratchOff: !1,
|
|
447
|
+
defaultTranslations: {
|
|
448
|
+
"system.out_of_stock": "Out of stock",
|
|
449
|
+
"system.invalid_variant": "Invalid variant",
|
|
450
|
+
"system.unavailable_option_value": "Unavailable option value",
|
|
451
|
+
"system.confirm": "Confirm",
|
|
452
|
+
"system.cancel": "Cancel",
|
|
453
|
+
"system.free": "FREE",
|
|
454
|
+
"system.search": "Search",
|
|
455
|
+
"system.quantity": "Quantity",
|
|
456
|
+
"system.subscription_plan": "Subscription plan",
|
|
457
|
+
"system.remove": "Remove",
|
|
458
|
+
"system.sort_by": "Sort by",
|
|
459
|
+
"system.sort_relevance": "Relevance",
|
|
460
|
+
"system.sort_newest_first": "Newest first",
|
|
461
|
+
"system.sort_price_low_to_high": "Price: Low → High",
|
|
462
|
+
"system.sort_price_high_to_low": "Price: High → Low",
|
|
463
|
+
"system.no_results_found": "No results found",
|
|
464
|
+
"system.no_results_description": "We can't find any item matching your search.",
|
|
465
|
+
"system.clear_search": "Clear search",
|
|
466
|
+
"system.no_products_available": "No products available",
|
|
467
|
+
"system.original_price": "Original price:",
|
|
468
|
+
"system.price": "Price:",
|
|
469
|
+
"system.letters_only": "Only letters are allowed.",
|
|
470
|
+
"system.numbers_only": "Only numbers are allowed."
|
|
471
|
+
},
|
|
472
|
+
customSelectors: {
|
|
473
|
+
quantity: y.quantity ?? null,
|
|
474
|
+
addToCartButton: y.add_to_cart_button ?? null,
|
|
475
|
+
variantPicker: y.variant_picker ?? null,
|
|
476
|
+
price: y.price ?? null,
|
|
477
|
+
priceCompare: y.price_compare ?? null
|
|
478
|
+
},
|
|
479
|
+
shopCustomStyles: _?.shop_custom_styles ?? "",
|
|
480
|
+
featureFlags: v,
|
|
481
|
+
brandColors: _?.brand_colors ?? null
|
|
482
|
+
};
|
|
483
|
+
}, D = (e) => JSON.parse(e).amount / 1e6, O = async (e, t, n = 200) => {
|
|
484
|
+
let r = [...new Set(t.filter(Boolean).filter((e) => !e.startsWith("placeholder")))];
|
|
485
|
+
if (r.length === 0) return [];
|
|
486
|
+
let i = [];
|
|
487
|
+
for (let e = 0; e < r.length; e += 250) i.push(r.slice(e, e + 250));
|
|
488
|
+
return (await Promise.all(i.map((t) => e.query("\n query FetchMediaImages($mediaImageIds: [ID!]!, $size: Int!) {\n nodes(ids: $mediaImageIds) {\n ... on MediaImage {\n id\n image {\n url(transform: { maxWidth: $size, maxHeight: $size })\n }\n }\n }\n }\n ", { variables: {
|
|
489
|
+
mediaImageIds: t,
|
|
490
|
+
size: n
|
|
491
|
+
} })))).flatMap((e) => e.nodes).flatMap((e) => e?.image ? [{
|
|
492
|
+
gid: e.id,
|
|
493
|
+
url: e.image.url
|
|
494
|
+
}] : []);
|
|
495
|
+
}, k = (e) => [
|
|
496
|
+
...A(e),
|
|
497
|
+
...ee(e),
|
|
498
|
+
...te(e),
|
|
499
|
+
...ne(e),
|
|
500
|
+
...re(e),
|
|
501
|
+
...ie(e),
|
|
502
|
+
...ae(e),
|
|
503
|
+
...oe(e),
|
|
504
|
+
...se(e),
|
|
505
|
+
...ce(e),
|
|
506
|
+
...j(e),
|
|
507
|
+
...M(e),
|
|
508
|
+
...N(e)
|
|
509
|
+
].filter((e) => e != null && !e.includes("placeholder")), A = (e) => e.dealBars.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), ee = (e) => e.dealBars.flatMap((e) => e.dealBarType === g.Bundle ? e.bundleProducts.map((e) => e.mediaImageGID) : []).filter((e) => e != null), te = (e) => e.dealBars.map(({ freeGifts: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), ne = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => (e || []).map((e) => e.mediaImageGID)).filter((e) => e != null), re = (e) => e.dealBars.map(({ upsells: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), ie = (e) => e.swatchOptions ? e.swatchOptions.reduce((e, t) => {
|
|
510
|
+
let n = t.images.map((e) => e.mediaImageGID).filter((e) => e != null);
|
|
511
|
+
return [...e, ...n];
|
|
512
|
+
}, []) : [], ae = (e) => {
|
|
513
|
+
if (!e.collectionBreaksEnabled || !e.collectionBreaks) return [];
|
|
514
|
+
let t = e.collectionBreaks.mediaImageGID;
|
|
515
|
+
return t ? [t] : [];
|
|
516
|
+
}, oe = (e) => e.progressiveGifts ? [
|
|
517
|
+
...e.progressiveGifts.gifts?.map((e) => e.mediaImageGID) || [],
|
|
518
|
+
e.progressiveGifts.style?.lockedMediaImageGID,
|
|
519
|
+
e.progressiveGifts.dealBarStyle?.lockedMediaImageGID
|
|
520
|
+
].filter((e) => e != null) : [], se = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), ce = (e) => e.dealBars.map((e) => e.productPersonalisation?.mediaImageGID).filter((e) => e != null), j = (e) => {
|
|
521
|
+
let t = e.dealBars.map((e) => e.highlights?.customIconGID).filter((e) => e != null), n = e.subscriptions?.highlights?.customIconGID;
|
|
522
|
+
return n ? [...t, n] : t;
|
|
523
|
+
}, M = (e) => (e.badges || []).flatMap((e) => e.badgeType === "custom" && e.imageGID ? [e.imageGID] : []), N = (e) => !e.savingsSummaryEnabled || !e.savingsSummary ? [] : e.savingsSummary.customIconGID ? [e.savingsSummary.customIconGID] : [], P = (e) => {
|
|
524
|
+
let t = [
|
|
525
|
+
...F(e),
|
|
526
|
+
...I(e),
|
|
527
|
+
...L(e),
|
|
528
|
+
...R(e),
|
|
529
|
+
...z(e),
|
|
530
|
+
...B(e),
|
|
531
|
+
...V(e),
|
|
532
|
+
...H(e)
|
|
533
|
+
];
|
|
534
|
+
return Array.from(new Set(t.filter((e) => e != null)));
|
|
535
|
+
}, F = (e) => e.dealBars.flatMap(({ freeGifts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), I = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => e ? e.flatMap((e) => e.products ? e.products.map((e) => e.id) : []) : []).filter((e) => e != null), L = (e) => e.progressiveGiftsEnabled && e.progressiveGifts?.gifts.map((e) => e.productGID).filter((e) => e != null) || [], R = (e) => e.dealBars.flatMap(({ upsells: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), z = (e) => e.dealBars.filter((e) => e.dealBarType === g.Bundle).flatMap(({ bundleProducts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null).filter((e) => e !== "default"), B = (e) => e.dealBars.filter((e) => e.dealBarType === g.MixAndMatch).flatMap(({ bundleProducts: e }) => e ? e.flatMap((e) => [e.productGID, ...e.selectedProducts?.map((e) => e.id) ?? []]) : []).filter((e) => e != null).filter((e) => e !== "default"), V = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.map((e) => e.productGID).filter((e) => e != null), H = (e) => e.dealBars.filter((e) => e.dealBarType === g.Sku).flatMap(({ productGID: e }) => e ? [e] : []), U = class extends Error {
|
|
536
|
+
constructor({ status: e, operationName: t, graphqlErrors: n }) {
|
|
537
|
+
let r = n.length ? `: ${n.join("; ")}` : "";
|
|
538
|
+
super(`Storefront API ${t ?? "query"} failed (HTTP ${e})${r}`), this.name = "StorefrontApiError", this.status = e, this.operationName = t, this.graphqlErrors = n;
|
|
539
|
+
}
|
|
540
|
+
}, W = async (e, t) => {
|
|
541
|
+
let n = await e.text();
|
|
542
|
+
if (!n) throw Error("Empty graphql response");
|
|
543
|
+
let r;
|
|
544
|
+
try {
|
|
545
|
+
r = JSON.parse(n);
|
|
546
|
+
} catch (n) {
|
|
547
|
+
throw e.ok ? n : new U({
|
|
548
|
+
status: e.status,
|
|
549
|
+
operationName: t,
|
|
550
|
+
graphqlErrors: []
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
if (!e.ok || r.data === null || r.data === void 0) throw new U({
|
|
554
|
+
status: e.status,
|
|
555
|
+
operationName: t,
|
|
556
|
+
graphqlErrors: (r.errors ?? []).map(({ message: e }) => e).filter(Boolean)
|
|
557
|
+
});
|
|
558
|
+
return r.data;
|
|
559
|
+
}, G = class {
|
|
560
|
+
constructor(e, t) {
|
|
561
|
+
this.storefrontApiVersion = "2026-07", this.storefrontAccessToken = t, this.shopifyDomain = e;
|
|
562
|
+
}
|
|
563
|
+
async query(e, t) {
|
|
564
|
+
let n = t?.variables ?? {}, r = `https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`, i = e.match(/query\s+(\w+)/)?.[1];
|
|
565
|
+
return i && (r += `?operation_name=${i}`), W(await fetch(r, {
|
|
566
|
+
method: "POST",
|
|
567
|
+
headers: {
|
|
568
|
+
"Content-Type": "application/json",
|
|
569
|
+
"X-Shopify-Storefront-Access-Token": this.storefrontAccessToken
|
|
570
|
+
},
|
|
571
|
+
body: JSON.stringify({
|
|
572
|
+
query: e,
|
|
573
|
+
variables: n
|
|
574
|
+
})
|
|
575
|
+
}), i);
|
|
576
|
+
}
|
|
577
|
+
}, le = (e, t) => {
|
|
578
|
+
let n = [], r = e.filter((e) => e.blockVisibility === "selected-products");
|
|
579
|
+
for (let e of r) e.selectedProductIds.map(Number).includes(t.id) && n.push(e);
|
|
580
|
+
let i = e.filter((e) => e.blockVisibility === "selected-collections");
|
|
581
|
+
for (let e of i) t.collectionIds.some((t) => e.selectedCollectionIds.map(Number).includes(t)) && n.push(e);
|
|
582
|
+
let a = e.filter((e) => e.blockVisibility === "excluded-products");
|
|
583
|
+
for (let e of a) !e.excludedProductIds.map(Number).includes(t.id) && !(e.excludedCollectionIds || []).some((e) => t.collectionIds.includes(e)) && n.push(e);
|
|
584
|
+
let o = e.filter((e) => e.blockVisibility === "all-products");
|
|
585
|
+
for (let e of o) n.push(e);
|
|
586
|
+
return n;
|
|
587
|
+
}, ue = async (e, t, { country: n, language: r }) => {
|
|
588
|
+
let i = t.collectionBreaks;
|
|
589
|
+
if (!t.collectionBreaksEnabled || !i) return;
|
|
590
|
+
let a;
|
|
591
|
+
a = i.visibility === "deal-products" ? await _(e, {
|
|
592
|
+
country: n,
|
|
593
|
+
language: r,
|
|
594
|
+
blockVisibility: t.blockVisibility,
|
|
595
|
+
excludedProductGIDs: (t.excludedProductIds || []).map((e) => `gid://shopify/Product/${e}`),
|
|
596
|
+
selectedProductGIDs: (t.selectedProductIds || []).map((e) => `gid://shopify/Product/${e}`),
|
|
597
|
+
selectedCollectionGIDs: (t.selectedCollectionIds || []).map((e) => `gid://shopify/Collection/${e}`)
|
|
598
|
+
}) : await _(e, {
|
|
599
|
+
country: n,
|
|
600
|
+
language: r,
|
|
601
|
+
blockVisibility: i.visibility,
|
|
602
|
+
excludedProductGIDs: (i.excludedProducts || []).map(({ id: e }) => e),
|
|
603
|
+
selectedProductGIDs: (i.selectedProducts || []).map(({ id: e }) => e),
|
|
604
|
+
selectedCollectionGIDs: (i.selectedCollections || []).map(({ id: e }) => e)
|
|
605
|
+
});
|
|
606
|
+
let o = await y(e, {
|
|
607
|
+
country: n,
|
|
608
|
+
language: r,
|
|
609
|
+
productIds: a.map((e) => Number(e.split("/").pop())),
|
|
610
|
+
useExternalMetafieldNamespace: !0
|
|
611
|
+
});
|
|
612
|
+
return o = o.filter((e) => e.availableForSale), o;
|
|
613
|
+
}, de = ({ language: e, dealBlockId: t }) => {
|
|
614
|
+
let n = {
|
|
615
|
+
"system.out_of_stock": "There's not enough items in our stock, please select smaller bundle.",
|
|
616
|
+
"system.invalid_variant": "Sorry, this is not currently available.",
|
|
617
|
+
"system.unavailable_option_value": "Unavailable",
|
|
618
|
+
"system.confirm": "Confirm",
|
|
619
|
+
"system.cancel": "Cancel",
|
|
620
|
+
"system.free": "FREE",
|
|
621
|
+
"system.search": "Search",
|
|
622
|
+
"system.quantity": "Quantity",
|
|
623
|
+
"system.subscription_plan": "Subscription plan",
|
|
624
|
+
"system.remove": "Remove",
|
|
625
|
+
"system.sort_by": "Sort by",
|
|
626
|
+
"system.sort_relevance": "Relevance",
|
|
627
|
+
"system.sort_newest_first": "Newest first",
|
|
628
|
+
"system.sort_price_low_to_high": "Price: Low → High",
|
|
629
|
+
"system.sort_price_high_to_low": "Price: High → Low",
|
|
630
|
+
"system.no_results_found": "No results found",
|
|
631
|
+
"system.no_results_description": "We can't find any item matching your search.",
|
|
632
|
+
"system.clear_search": "Clear search",
|
|
633
|
+
"system.no_products_available": "No products available",
|
|
634
|
+
"system.original_price": "Original price:",
|
|
635
|
+
"system.price": "Price:",
|
|
636
|
+
"system.letters_only": "Only letters are allowed.",
|
|
637
|
+
"system.numbers_only": "Only numbers are allowed.",
|
|
638
|
+
"system.personalisation_required_alert": "Please add personalisation for every item to continue."
|
|
639
|
+
}, r = e ? fe(e) : void 0;
|
|
640
|
+
return {
|
|
641
|
+
...n,
|
|
642
|
+
...r?.system,
|
|
643
|
+
...r?.dealBlocks[t]
|
|
644
|
+
};
|
|
747
645
|
}, fe = (e) => {
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
excludedProductGIDs: (s.excludedProducts || []).map(
|
|
878
|
-
({ id: i }) => i
|
|
879
|
-
),
|
|
880
|
-
selectedProductGIDs: (s.selectedProducts || []).map(
|
|
881
|
-
({ id: i }) => i
|
|
882
|
-
),
|
|
883
|
-
selectedCollectionGIDs: (s.selectedCollections || []).map(
|
|
884
|
-
({ id: i }) => i
|
|
885
|
-
)
|
|
886
|
-
});
|
|
887
|
-
let o = await A(e, {
|
|
888
|
-
country: a,
|
|
889
|
-
language: r,
|
|
890
|
-
productIds: l.map((i) => Number(i.split("/").pop())),
|
|
891
|
-
useExternalMetafieldNamespace: !0
|
|
892
|
-
});
|
|
893
|
-
return o = o.filter(
|
|
894
|
-
(i) => i.availableForSale
|
|
895
|
-
), o;
|
|
896
|
-
}, Be = ({
|
|
897
|
-
language: e,
|
|
898
|
-
dealBlockId: t
|
|
899
|
-
}) => {
|
|
900
|
-
const a = {
|
|
901
|
-
"system.out_of_stock": "There's not enough items in our stock, please select smaller bundle.",
|
|
902
|
-
"system.invalid_variant": "Sorry, this is not currently available.",
|
|
903
|
-
"system.unavailable_option_value": "Unavailable",
|
|
904
|
-
"system.confirm": "Confirm",
|
|
905
|
-
"system.cancel": "Cancel",
|
|
906
|
-
"system.free": "FREE",
|
|
907
|
-
"system.search": "Search",
|
|
908
|
-
"system.quantity": "Quantity",
|
|
909
|
-
"system.subscription_plan": "Subscription plan",
|
|
910
|
-
"system.remove": "Remove",
|
|
911
|
-
"system.sort_by": "Sort by",
|
|
912
|
-
"system.sort_relevance": "Relevance",
|
|
913
|
-
"system.sort_newest_first": "Newest first",
|
|
914
|
-
"system.sort_price_low_to_high": "Price: Low → High",
|
|
915
|
-
"system.sort_price_high_to_low": "Price: High → Low",
|
|
916
|
-
"system.no_results_found": "No results found",
|
|
917
|
-
"system.no_results_description": "We can't find any item matching your search.",
|
|
918
|
-
"system.clear_search": "Clear search",
|
|
919
|
-
"system.no_products_available": "No products available",
|
|
920
|
-
"system.original_price": "Original price:",
|
|
921
|
-
"system.price": "Price:",
|
|
922
|
-
"system.letters_only": "Only letters are allowed.",
|
|
923
|
-
"system.numbers_only": "Only numbers are allowed.",
|
|
924
|
-
"system.personalisation_required_alert": "Please add personalisation for every item to continue."
|
|
925
|
-
}, r = e ? Ge(e) : void 0;
|
|
926
|
-
return {
|
|
927
|
-
...a,
|
|
928
|
-
...r == null ? void 0 : r.system,
|
|
929
|
-
...r == null ? void 0 : r.dealBlocks[t]
|
|
930
|
-
};
|
|
931
|
-
}, Ge = (e) => {
|
|
932
|
-
var s;
|
|
933
|
-
if (typeof document > "u") return;
|
|
934
|
-
const t = document.querySelector("script#kaching-bundles-translations");
|
|
935
|
-
if (!(t != null && t.textContent)) return;
|
|
936
|
-
let a;
|
|
937
|
-
try {
|
|
938
|
-
a = JSON.parse(t.textContent);
|
|
939
|
-
} catch {
|
|
940
|
-
return;
|
|
941
|
-
}
|
|
942
|
-
const r = V(e);
|
|
943
|
-
return (s = a.find(
|
|
944
|
-
(l) => V(l.locale) === r
|
|
945
|
-
)) == null ? void 0 : s.translations;
|
|
946
|
-
}, V = (e) => e.toLowerCase().replace(/_/g, "-"), Ce = "2026-07", Te = async (e, {
|
|
947
|
-
productId: t,
|
|
948
|
-
dealBlockId: a,
|
|
949
|
-
country: r = void 0,
|
|
950
|
-
language: s = void 0
|
|
951
|
-
}) => {
|
|
952
|
-
var l, o;
|
|
953
|
-
try {
|
|
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);
|
|
956
|
-
const u = await se(d, {
|
|
957
|
-
language: s,
|
|
958
|
-
country: r,
|
|
959
|
-
useExternalMetafieldNamespace: !0
|
|
960
|
-
});
|
|
961
|
-
d.shopifyDomain = u.shopifyDomain;
|
|
962
|
-
const c = u.storefrontAccessToken ? new xe(
|
|
963
|
-
u.shopifyDomain,
|
|
964
|
-
u.storefrontAccessToken
|
|
965
|
-
) : d, [p, g] = await Promise.all([
|
|
966
|
-
A(c, {
|
|
967
|
-
country: r,
|
|
968
|
-
language: s,
|
|
969
|
-
productIds: i,
|
|
970
|
-
useExternalMetafieldNamespace: !0
|
|
971
|
-
}),
|
|
972
|
-
Z(c, {
|
|
973
|
-
useExternalMetafieldNamespace: !0,
|
|
974
|
-
useMetaobjects: u.featureFlags.storefront_metaobjects
|
|
975
|
-
})
|
|
976
|
-
]), y = p[0];
|
|
977
|
-
if (!y)
|
|
978
|
-
return null;
|
|
979
|
-
const h = H(g, y);
|
|
980
|
-
let n;
|
|
981
|
-
if (a ? (n = h.find(
|
|
982
|
-
(P) => P.id === a || P.nanoId === a
|
|
983
|
-
), n || (n = h[0])) : n = h[0], !n)
|
|
984
|
-
return null;
|
|
985
|
-
const m = le(n), b = _e(n), [I, _, f, v] = await Promise.all([
|
|
986
|
-
A(c, {
|
|
987
|
-
country: r,
|
|
988
|
-
language: s,
|
|
989
|
-
productIds: b,
|
|
990
|
-
useExternalMetafieldNamespace: !0
|
|
991
|
-
}),
|
|
992
|
-
ne(c, m, 300),
|
|
993
|
-
Ee(c, n, {
|
|
994
|
-
country: r,
|
|
995
|
-
language: s
|
|
996
|
-
}),
|
|
997
|
-
Be({ language: s, dealBlockId: n.id })
|
|
998
|
-
]);
|
|
999
|
-
return {
|
|
1000
|
-
product: y,
|
|
1001
|
-
dealBlock: n,
|
|
1002
|
-
config: u,
|
|
1003
|
-
otherProducts: I,
|
|
1004
|
-
mediaImages: _,
|
|
1005
|
-
collectionBreaksProducts: f ?? [],
|
|
1006
|
-
translations: v
|
|
1007
|
-
};
|
|
1008
|
-
} catch (i) {
|
|
1009
|
-
return console.error(i), null;
|
|
1010
|
-
}
|
|
1011
|
-
};
|
|
1012
|
-
class Me {
|
|
1013
|
-
constructor(t) {
|
|
1014
|
-
this.storefront = t, this.shopifyDomain = "";
|
|
1015
|
-
}
|
|
1016
|
-
async query(t, a) {
|
|
1017
|
-
var r;
|
|
1018
|
-
if ("query" in this.storefront && "i18n" in this.storefront)
|
|
1019
|
-
return await this.storefront.query(t, a);
|
|
1020
|
-
if ("graphql" in this.storefront) {
|
|
1021
|
-
const s = await this.storefront.graphql(t, a);
|
|
1022
|
-
if ((r = s.errors) != null && r.length)
|
|
1023
|
-
throw new Error(
|
|
1024
|
-
s.errors.map((l) => l.message).join(`
|
|
1025
|
-
`)
|
|
1026
|
-
);
|
|
1027
|
-
return s.data;
|
|
1028
|
-
}
|
|
1029
|
-
if ("request" in this.storefront)
|
|
1030
|
-
return (await this.storefront.request(t, a)).data;
|
|
1031
|
-
if ("shopifyDomain" in this.storefront && "storefrontAccessToken" in this.storefront) {
|
|
1032
|
-
const s = await fetch(
|
|
1033
|
-
`https://${this.storefront.shopifyDomain}/api/${Ce}/graphql.json`,
|
|
1034
|
-
{
|
|
1035
|
-
body: JSON.stringify({
|
|
1036
|
-
query: t,
|
|
1037
|
-
variables: a == null ? void 0 : a.variables
|
|
1038
|
-
}),
|
|
1039
|
-
headers: {
|
|
1040
|
-
"Content-Type": "application/json",
|
|
1041
|
-
"X-Shopify-Storefront-Access-Token": this.storefront.storefrontAccessToken
|
|
1042
|
-
},
|
|
1043
|
-
method: "POST"
|
|
1044
|
-
}
|
|
1045
|
-
);
|
|
1046
|
-
if (!s.ok)
|
|
1047
|
-
throw new Error(s.statusText);
|
|
1048
|
-
return (await s.json()).data;
|
|
1049
|
-
} else {
|
|
1050
|
-
const s = await fetch(this.storefront.getStorefrontApiUrl(), {
|
|
1051
|
-
body: JSON.stringify({
|
|
1052
|
-
query: t,
|
|
1053
|
-
variables: a == null ? void 0 : a.variables
|
|
1054
|
-
}),
|
|
1055
|
-
headers: this.storefront.getPublicTokenHeaders(),
|
|
1056
|
-
method: "POST"
|
|
1057
|
-
});
|
|
1058
|
-
if (!s.ok)
|
|
1059
|
-
throw new Error(s.statusText);
|
|
1060
|
-
return (await s.json()).data;
|
|
1061
|
-
}
|
|
1062
|
-
}
|
|
1063
|
-
get i18n() {
|
|
1064
|
-
if ("i18n" in this.storefront)
|
|
1065
|
-
return this.storefront.i18n;
|
|
1066
|
-
}
|
|
1067
|
-
}
|
|
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) => {
|
|
1069
|
-
const t = e.document;
|
|
1070
|
-
if (!e.customElements.get($)) {
|
|
1071
|
-
if (N.has(t))
|
|
1072
|
-
return x(e, $);
|
|
1073
|
-
N.add(t);
|
|
1074
|
-
try {
|
|
1075
|
-
await Fe(e);
|
|
1076
|
-
} catch (a) {
|
|
1077
|
-
throw N.delete(t), a;
|
|
1078
|
-
}
|
|
1079
|
-
}
|
|
1080
|
-
}, Ve = () => typeof window < "u" && typeof window.__KACHING_DEV__ < "u", Ue = () => Ve() ? qe : je, Fe = (e) => {
|
|
1081
|
-
const t = e.document;
|
|
1082
|
-
return new Promise((a, r) => {
|
|
1083
|
-
const s = Ue();
|
|
1084
|
-
if (t.querySelector(
|
|
1085
|
-
`script[src="${s}"]`
|
|
1086
|
-
)) {
|
|
1087
|
-
x(e, $).then(a).catch(r);
|
|
1088
|
-
return;
|
|
1089
|
-
}
|
|
1090
|
-
const o = t.createElement("script");
|
|
1091
|
-
o.src = s, o.onload = () => x(e, $).then(a).catch(r), o.onerror = () => r(new Error("Failed to load script")), t.head.appendChild(o);
|
|
1092
|
-
});
|
|
1093
|
-
}, x = (e, t) => new Promise((a, r) => {
|
|
1094
|
-
if (e.customElements.get(t)) {
|
|
1095
|
-
a();
|
|
1096
|
-
return;
|
|
1097
|
-
}
|
|
1098
|
-
Promise.race([
|
|
1099
|
-
e.customElements.whenDefined(t),
|
|
1100
|
-
new Promise(
|
|
1101
|
-
(s, l) => setTimeout(
|
|
1102
|
-
() => l(
|
|
1103
|
-
new Error(
|
|
1104
|
-
`Custom element "${t}" failed to register within ${U}ms`
|
|
1105
|
-
)
|
|
1106
|
-
),
|
|
1107
|
-
U
|
|
1108
|
-
)
|
|
1109
|
-
)
|
|
1110
|
-
]).then(() => a()).catch(r);
|
|
646
|
+
if (typeof document > "u") return;
|
|
647
|
+
let t = document.querySelector("script#kaching-bundles-translations");
|
|
648
|
+
if (!t?.textContent) return;
|
|
649
|
+
let n;
|
|
650
|
+
try {
|
|
651
|
+
n = JSON.parse(t.textContent);
|
|
652
|
+
} catch {
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
let r = K(e);
|
|
656
|
+
return n.find((e) => K(e.locale) === r)?.translations;
|
|
657
|
+
}, K = (e) => e.toLowerCase().replace(/_/g, "-"), pe = "2026-07", me = async (e, { productId: t, dealBlockId: n, country: r = void 0, language: i = void 0 }) => {
|
|
658
|
+
try {
|
|
659
|
+
let a = [Number(t.split("/").pop())], o = new he(e);
|
|
660
|
+
r ||= o.i18n?.country, i ||= o.i18n?.language;
|
|
661
|
+
let s = await E(o, {
|
|
662
|
+
language: i,
|
|
663
|
+
country: r,
|
|
664
|
+
useExternalMetafieldNamespace: !0
|
|
665
|
+
});
|
|
666
|
+
o.shopifyDomain = s.shopifyDomain;
|
|
667
|
+
let c = s.storefrontAccessToken ? new G(s.shopifyDomain, s.storefrontAccessToken) : o, [l, u] = await Promise.all([y(c, {
|
|
668
|
+
country: r,
|
|
669
|
+
language: i,
|
|
670
|
+
productIds: a,
|
|
671
|
+
useExternalMetafieldNamespace: !0
|
|
672
|
+
}), p(c, {
|
|
673
|
+
useExternalMetafieldNamespace: !0,
|
|
674
|
+
useMetaobjects: s.featureFlags.storefront_metaobjects
|
|
675
|
+
})]), d = l[0];
|
|
676
|
+
if (!d) return null;
|
|
677
|
+
let f = le(u, d), m;
|
|
678
|
+
if (n ? (m = f.find((e) => e.id === n || e.nanoId === n), m ||= f[0]) : m = f[0], !m) return null;
|
|
679
|
+
let h = k(m), g = P(m), [_, v, b, x] = await Promise.all([
|
|
680
|
+
y(c, {
|
|
681
|
+
country: r,
|
|
682
|
+
language: i,
|
|
683
|
+
productIds: g,
|
|
684
|
+
useExternalMetafieldNamespace: !0
|
|
685
|
+
}),
|
|
686
|
+
O(c, h, 300),
|
|
687
|
+
ue(c, m, {
|
|
688
|
+
country: r,
|
|
689
|
+
language: i
|
|
690
|
+
}),
|
|
691
|
+
de({
|
|
692
|
+
language: i,
|
|
693
|
+
dealBlockId: m.id
|
|
694
|
+
})
|
|
695
|
+
]);
|
|
696
|
+
return {
|
|
697
|
+
product: d,
|
|
698
|
+
dealBlock: m,
|
|
699
|
+
config: s,
|
|
700
|
+
otherProducts: _,
|
|
701
|
+
mediaImages: v,
|
|
702
|
+
collectionBreaksProducts: b ?? [],
|
|
703
|
+
translations: x
|
|
704
|
+
};
|
|
705
|
+
} catch (e) {
|
|
706
|
+
return console.error(e), null;
|
|
707
|
+
}
|
|
708
|
+
}, he = class {
|
|
709
|
+
constructor(e) {
|
|
710
|
+
this.storefront = e, this.shopifyDomain = "";
|
|
711
|
+
}
|
|
712
|
+
async query(e, t) {
|
|
713
|
+
if ("query" in this.storefront && "i18n" in this.storefront) return await this.storefront.query(e, t);
|
|
714
|
+
if ("graphql" in this.storefront) {
|
|
715
|
+
let n = await this.storefront.graphql(e, t);
|
|
716
|
+
if (n.errors?.length) throw Error(n.errors.map((e) => e.message).join("\n"));
|
|
717
|
+
return n.data;
|
|
718
|
+
}
|
|
719
|
+
if ("request" in this.storefront) return (await this.storefront.request(e, t)).data;
|
|
720
|
+
if ("shopifyDomain" in this.storefront && "storefrontAccessToken" in this.storefront) {
|
|
721
|
+
let n = await fetch(`https://${this.storefront.shopifyDomain}/api/${pe}/graphql.json`, {
|
|
722
|
+
body: JSON.stringify({
|
|
723
|
+
query: e,
|
|
724
|
+
variables: t?.variables
|
|
725
|
+
}),
|
|
726
|
+
headers: {
|
|
727
|
+
"Content-Type": "application/json",
|
|
728
|
+
"X-Shopify-Storefront-Access-Token": this.storefront.storefrontAccessToken
|
|
729
|
+
},
|
|
730
|
+
method: "POST"
|
|
731
|
+
});
|
|
732
|
+
if (!n.ok) throw Error(n.statusText);
|
|
733
|
+
return (await n.json()).data;
|
|
734
|
+
}
|
|
735
|
+
{
|
|
736
|
+
let n = await fetch(this.storefront.getStorefrontApiUrl(), {
|
|
737
|
+
body: JSON.stringify({
|
|
738
|
+
query: e,
|
|
739
|
+
variables: t?.variables
|
|
740
|
+
}),
|
|
741
|
+
headers: this.storefront.getPublicTokenHeaders(),
|
|
742
|
+
method: "POST"
|
|
743
|
+
});
|
|
744
|
+
if (!n.ok) throw Error(n.statusText);
|
|
745
|
+
return (await n.json()).data;
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
get i18n() {
|
|
749
|
+
if ("i18n" in this.storefront) return this.storefront.i18n;
|
|
750
|
+
}
|
|
751
|
+
}, ge = me, q = "kaching-bundles-block", J = 1e4, _e = "https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js", ve = "https://bundles-integrations.kachingappz.app/kaching-bundles-block.js", Y = /* @__PURE__ */ new WeakSet(), ye = async (e) => {
|
|
752
|
+
let t = e.document;
|
|
753
|
+
if (!e.customElements.get(q)) {
|
|
754
|
+
if (Y.has(t)) return X(e, q);
|
|
755
|
+
Y.add(t);
|
|
756
|
+
try {
|
|
757
|
+
await Se(e);
|
|
758
|
+
} catch (e) {
|
|
759
|
+
throw Y.delete(t), e;
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
}, be = () => typeof window < "u" && window.__KACHING_DEV__ !== void 0, xe = () => be() ? _e : ve, Se = (e) => {
|
|
763
|
+
let t = e.document;
|
|
764
|
+
return new Promise((n, r) => {
|
|
765
|
+
let i = xe();
|
|
766
|
+
if (t.querySelector(`script[src="${i}"]`)) {
|
|
767
|
+
X(e, q).then(n).catch(r);
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
770
|
+
let a = t.createElement("script");
|
|
771
|
+
a.src = i, a.onload = () => X(e, q).then(n).catch(r), a.onerror = () => r(/* @__PURE__ */ Error("Failed to load script")), t.head.appendChild(a);
|
|
772
|
+
});
|
|
773
|
+
}, X = (e, t) => new Promise((n, r) => {
|
|
774
|
+
e.customElements.get(t) ? n() : Promise.race([e.customElements.whenDefined(t), new Promise((e, n) => setTimeout(() => n(/* @__PURE__ */ Error(`Custom element "${t}" failed to register within ${J}ms`)), J))]).then(() => n()).catch(r);
|
|
1111
775
|
});
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
776
|
+
[
|
|
777
|
+
"primaryBackground",
|
|
778
|
+
"secondaryBackground",
|
|
779
|
+
"primaryText",
|
|
780
|
+
"secondaryText",
|
|
781
|
+
"border",
|
|
782
|
+
"overlay",
|
|
783
|
+
"primaryAccent",
|
|
784
|
+
"primaryAccentText",
|
|
785
|
+
"badgeBackground",
|
|
786
|
+
"badgeText",
|
|
787
|
+
"error"
|
|
788
|
+
].map((e) => `brand_${e}`);
|
|
789
|
+
var Z = /* @__PURE__ */ function(e) {
|
|
790
|
+
return e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e;
|
|
791
|
+
}({}), Q = "a-f\\d", Ce = `#?[${Q}]{3}[${Q}]?`, we = `#?[${Q}]{6}([${Q}]{2})?`, Te = RegExp(`[^#${Q}]`, "gi"), Ee = RegExp(`^${Ce}$|^${we}$`, "i");
|
|
792
|
+
function De(e, t = {}) {
|
|
793
|
+
if (typeof e != "string" || Te.test(e) || !Ee.test(e)) throw TypeError("Expected a valid hex string");
|
|
794
|
+
e = e.replace(/^#/, "");
|
|
795
|
+
let n = 1;
|
|
796
|
+
e.length === 8 && (n = Number.parseInt(e.slice(6, 8), 16) / 255, e = e.slice(0, 6)), e.length === 4 && (n = 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]);
|
|
797
|
+
let r = Number.parseInt(e, 16), i = r >> 16, a = r >> 8 & 255, o = r & 255, s = typeof t.alpha == "number" ? t.alpha : n;
|
|
798
|
+
return t.format === "array" ? [
|
|
799
|
+
i,
|
|
800
|
+
a,
|
|
801
|
+
o,
|
|
802
|
+
s
|
|
803
|
+
] : t.format === "css" ? `rgb(${i} ${a} ${o}${s === 1 ? "" : ` / ${Number((s * 100).toFixed(2))}%`})` : {
|
|
804
|
+
red: i,
|
|
805
|
+
green: a,
|
|
806
|
+
blue: o,
|
|
807
|
+
alpha: s
|
|
808
|
+
};
|
|
1128
809
|
}
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
product: JSON.stringify(a),
|
|
1548
|
-
"other-products": JSON.stringify(r),
|
|
1549
|
-
"collection-breaks-products": JSON.stringify(l),
|
|
1550
|
-
translations: JSON.stringify(o)
|
|
1551
|
-
}
|
|
1552
|
-
}), Ze = ({
|
|
1553
|
-
cornerRadius: e,
|
|
1554
|
-
color: t,
|
|
1555
|
-
price: a
|
|
1556
|
-
}) => {
|
|
1557
|
-
const r = He({ price: a }), s = Ke(), l = We({ color: t, cornerRadius: e });
|
|
1558
|
-
return {
|
|
1559
|
-
dealBlockId: l.id,
|
|
1560
|
-
currentVariantId: String(r.variants[0].id),
|
|
1561
|
-
jsonAttributes: {
|
|
1562
|
-
config: JSON.stringify(s),
|
|
1563
|
-
"deal-block": JSON.stringify(l),
|
|
1564
|
-
"media-images": JSON.stringify([]),
|
|
1565
|
-
product: JSON.stringify(r),
|
|
1566
|
-
"other-products": JSON.stringify([]),
|
|
1567
|
-
"collection-breaks-products": JSON.stringify([]),
|
|
1568
|
-
translations: JSON.stringify({})
|
|
1569
|
-
}
|
|
1570
|
-
};
|
|
1571
|
-
};
|
|
1572
|
-
export {
|
|
1573
|
-
st as KachingBundle,
|
|
1574
|
-
at as fetchKachingBundlesData
|
|
810
|
+
// src/react/preview.ts
|
|
811
|
+
var $ = ({ price: e }) => ({
|
|
812
|
+
id: 123,
|
|
813
|
+
handle: "123",
|
|
814
|
+
url: null,
|
|
815
|
+
availableForSale: !0,
|
|
816
|
+
requiresSellingPlan: !1,
|
|
817
|
+
title: "",
|
|
818
|
+
image: null,
|
|
819
|
+
selectedVariantId: 456,
|
|
820
|
+
collectionIds: [],
|
|
821
|
+
options: [],
|
|
822
|
+
sellingPlans: [],
|
|
823
|
+
variants: [{
|
|
824
|
+
id: 456,
|
|
825
|
+
availableForSale: !0,
|
|
826
|
+
price: Math.round((e ?? 10) * 100),
|
|
827
|
+
compareAtPrice: null,
|
|
828
|
+
options: [],
|
|
829
|
+
imageId: null,
|
|
830
|
+
image: null,
|
|
831
|
+
sellingPlans: [],
|
|
832
|
+
inventoryManagement: null,
|
|
833
|
+
inventoryPolicy: null,
|
|
834
|
+
inventoryQuantity: 50,
|
|
835
|
+
unitPriceMeasurement: null
|
|
836
|
+
}],
|
|
837
|
+
metafields: {
|
|
838
|
+
text: null,
|
|
839
|
+
text2: null,
|
|
840
|
+
text3: null,
|
|
841
|
+
text4: null
|
|
842
|
+
},
|
|
843
|
+
isNativeBundle: !1
|
|
844
|
+
}), Oe = () => ({
|
|
845
|
+
shopifyDomain: "",
|
|
846
|
+
moneyFormat: "${{amount_with_comma_separator}}",
|
|
847
|
+
locale: "en",
|
|
848
|
+
liquidLocale: "en",
|
|
849
|
+
country: "US",
|
|
850
|
+
marketId: 0,
|
|
851
|
+
productId: null,
|
|
852
|
+
storefrontAccessToken: null,
|
|
853
|
+
includeSellingPlans: !1,
|
|
854
|
+
includeAvailableQuantity: !1,
|
|
855
|
+
customApiHost: null,
|
|
856
|
+
keepQuantityInput: !1,
|
|
857
|
+
ignoreDeselect: !1,
|
|
858
|
+
ignoreUnitPrice: !1,
|
|
859
|
+
requireCustomerLogin: !1,
|
|
860
|
+
abTestsRunning: !1,
|
|
861
|
+
webPixel: !1,
|
|
862
|
+
b2bCustomer: !1,
|
|
863
|
+
isLoggedIn: !1,
|
|
864
|
+
preview: !1,
|
|
865
|
+
previewAlerts: !1,
|
|
866
|
+
previewScratchOff: !1,
|
|
867
|
+
currencyRate: 1,
|
|
868
|
+
defaultTranslations: {
|
|
869
|
+
"system.out_of_stock": "",
|
|
870
|
+
"system.invalid_variant": "",
|
|
871
|
+
"system.unavailable_option_value": "",
|
|
872
|
+
"system.confirm": "",
|
|
873
|
+
"system.cancel": "",
|
|
874
|
+
"system.free": "",
|
|
875
|
+
"system.search": "",
|
|
876
|
+
"system.quantity": "",
|
|
877
|
+
"system.subscription_plan": "",
|
|
878
|
+
"system.remove": "",
|
|
879
|
+
"system.sort_by": "",
|
|
880
|
+
"system.sort_relevance": "",
|
|
881
|
+
"system.sort_newest_first": "",
|
|
882
|
+
"system.sort_price_low_to_high": "",
|
|
883
|
+
"system.sort_price_high_to_low": "",
|
|
884
|
+
"system.no_results_found": "",
|
|
885
|
+
"system.no_results_description": "",
|
|
886
|
+
"system.clear_search": "",
|
|
887
|
+
"system.no_products_available": "",
|
|
888
|
+
"system.original_price": "",
|
|
889
|
+
"system.price": "",
|
|
890
|
+
"system.letters_only": "",
|
|
891
|
+
"system.numbers_only": ""
|
|
892
|
+
},
|
|
893
|
+
customSelectors: {
|
|
894
|
+
quantity: null,
|
|
895
|
+
addToCartButton: null,
|
|
896
|
+
variantPicker: null
|
|
897
|
+
},
|
|
898
|
+
shopCustomStyles: "",
|
|
899
|
+
featureFlags: {}
|
|
900
|
+
}), ke = ({ color: e, cornerRadius: t }) => {
|
|
901
|
+
let n = {
|
|
902
|
+
id: "123",
|
|
903
|
+
nanoId: "123",
|
|
904
|
+
blockName: "Bundle",
|
|
905
|
+
discountName: "",
|
|
906
|
+
blockTitle: "BUNDLE & SAVE",
|
|
907
|
+
blockLayout: "vertical",
|
|
908
|
+
blockVisibility: "all-products",
|
|
909
|
+
marketId: null,
|
|
910
|
+
currency: null,
|
|
911
|
+
excludedProductIds: [],
|
|
912
|
+
excludedCollectionIds: [],
|
|
913
|
+
selectedProductIds: [],
|
|
914
|
+
selectedCollectionIds: [],
|
|
915
|
+
excludeB2bCustomers: !1,
|
|
916
|
+
excludePos: !1,
|
|
917
|
+
startTimestamp: 175811496e4,
|
|
918
|
+
endTimestamp: null,
|
|
919
|
+
differentVariantsEnabled: !0,
|
|
920
|
+
hideVariantPicker: !1,
|
|
921
|
+
showPricesPerItem: !1,
|
|
922
|
+
showBothPrices: !1,
|
|
923
|
+
useProductCompareAtPrice: !0,
|
|
924
|
+
showPricesWithoutDecimals: !1,
|
|
925
|
+
priceRounding: !1,
|
|
926
|
+
priceRoundingPrecision: ".00",
|
|
927
|
+
updateNativePrice: !1,
|
|
928
|
+
updateNativePriceType: "item",
|
|
929
|
+
skipCart: !1,
|
|
930
|
+
showVariantsForSingleQuantity: !0,
|
|
931
|
+
preselectedDealBarId: "1f-9",
|
|
932
|
+
defaultVariantsV2: [],
|
|
933
|
+
collectionBreaksEnabled: !1,
|
|
934
|
+
collectionBreaks: null,
|
|
935
|
+
chooseProductModal: null,
|
|
936
|
+
timerEnabled: !1,
|
|
937
|
+
timer: null,
|
|
938
|
+
subscriptionsEnabled: !1,
|
|
939
|
+
subscriptions: null,
|
|
940
|
+
stickyAtcEnabled: !1,
|
|
941
|
+
stickyAtc: null,
|
|
942
|
+
progressiveGiftsEnabled: !1,
|
|
943
|
+
progressiveGifts: null,
|
|
944
|
+
checkboxUpsellsEnabled: !1,
|
|
945
|
+
checkboxUpsells: null,
|
|
946
|
+
lowStockAlertEnabled: !1,
|
|
947
|
+
lowStockAlert: null,
|
|
948
|
+
dealBars: [{
|
|
949
|
+
id: "PfFU",
|
|
950
|
+
dealBarType: Z.QuantityBreak,
|
|
951
|
+
title: "1 pack",
|
|
952
|
+
subtitle: "Standard price",
|
|
953
|
+
label: "",
|
|
954
|
+
quantity: 1,
|
|
955
|
+
discountType: "default",
|
|
956
|
+
discountValue: "",
|
|
957
|
+
badgeStyle: "simple",
|
|
958
|
+
badgeText: "",
|
|
959
|
+
badgeImageGID: null,
|
|
960
|
+
mediaImageGID: null,
|
|
961
|
+
freeGifts: [],
|
|
962
|
+
multipleGiftsSelectors: [],
|
|
963
|
+
upsells: [],
|
|
964
|
+
showAsSoldOutEnabled: !1,
|
|
965
|
+
showAsSoldOut: null,
|
|
966
|
+
productPersonalisation: null
|
|
967
|
+
}, {
|
|
968
|
+
id: "1f-9",
|
|
969
|
+
dealBarType: Z.QuantityBreak,
|
|
970
|
+
title: "2 pack",
|
|
971
|
+
subtitle: "You save {{saved_percentage}}",
|
|
972
|
+
label: "SAVE {{saved_total}}",
|
|
973
|
+
quantity: 2,
|
|
974
|
+
discountType: "percentage",
|
|
975
|
+
discountValue: "15",
|
|
976
|
+
badgeStyle: "most-popular",
|
|
977
|
+
badgeText: "",
|
|
978
|
+
badgeImageGID: null,
|
|
979
|
+
mediaImageGID: null,
|
|
980
|
+
freeGifts: [],
|
|
981
|
+
multipleGiftsSelectors: [],
|
|
982
|
+
upsells: [],
|
|
983
|
+
showAsSoldOutEnabled: !1,
|
|
984
|
+
showAsSoldOut: null,
|
|
985
|
+
productPersonalisation: null
|
|
986
|
+
}],
|
|
987
|
+
badgesEnabled: !0,
|
|
988
|
+
badges: [{
|
|
989
|
+
id: "bdg1",
|
|
990
|
+
attachedTo: {
|
|
991
|
+
type: "dealBar",
|
|
992
|
+
dealBarId: "1f-9"
|
|
993
|
+
},
|
|
994
|
+
text: "MOST POPULAR",
|
|
995
|
+
colors: null,
|
|
996
|
+
badgeType: "most-popular",
|
|
997
|
+
size: 90
|
|
998
|
+
}],
|
|
999
|
+
cornerRadius: t ?? 8,
|
|
1000
|
+
spacing: 1,
|
|
1001
|
+
colors: {
|
|
1002
|
+
background: {
|
|
1003
|
+
red: 255,
|
|
1004
|
+
green: 255,
|
|
1005
|
+
blue: 255,
|
|
1006
|
+
alpha: 1
|
|
1007
|
+
},
|
|
1008
|
+
selectedBackground: {
|
|
1009
|
+
red: 255,
|
|
1010
|
+
green: 255,
|
|
1011
|
+
blue: 255,
|
|
1012
|
+
alpha: 1
|
|
1013
|
+
},
|
|
1014
|
+
border: {
|
|
1015
|
+
red: 0,
|
|
1016
|
+
green: 0,
|
|
1017
|
+
blue: 0,
|
|
1018
|
+
alpha: 1
|
|
1019
|
+
},
|
|
1020
|
+
blockTitle: {
|
|
1021
|
+
red: 0,
|
|
1022
|
+
green: 0,
|
|
1023
|
+
blue: 0,
|
|
1024
|
+
alpha: 1
|
|
1025
|
+
},
|
|
1026
|
+
title: {
|
|
1027
|
+
red: 0,
|
|
1028
|
+
green: 0,
|
|
1029
|
+
blue: 0,
|
|
1030
|
+
alpha: 1
|
|
1031
|
+
},
|
|
1032
|
+
subtitle: {
|
|
1033
|
+
red: 85,
|
|
1034
|
+
green: 85,
|
|
1035
|
+
blue: 85,
|
|
1036
|
+
alpha: 1
|
|
1037
|
+
},
|
|
1038
|
+
price: {
|
|
1039
|
+
red: 0,
|
|
1040
|
+
green: 0,
|
|
1041
|
+
blue: 0,
|
|
1042
|
+
alpha: 1
|
|
1043
|
+
},
|
|
1044
|
+
fullPrice: {
|
|
1045
|
+
red: 85,
|
|
1046
|
+
green: 85,
|
|
1047
|
+
blue: 85,
|
|
1048
|
+
alpha: 1
|
|
1049
|
+
},
|
|
1050
|
+
labelBackground: {
|
|
1051
|
+
red: 238,
|
|
1052
|
+
green: 238,
|
|
1053
|
+
blue: 238,
|
|
1054
|
+
alpha: 1
|
|
1055
|
+
},
|
|
1056
|
+
label: {
|
|
1057
|
+
red: 0,
|
|
1058
|
+
green: 0,
|
|
1059
|
+
blue: 0,
|
|
1060
|
+
alpha: 1
|
|
1061
|
+
},
|
|
1062
|
+
badgeBackground: {
|
|
1063
|
+
red: 255,
|
|
1064
|
+
green: 17,
|
|
1065
|
+
blue: 17,
|
|
1066
|
+
alpha: 1
|
|
1067
|
+
},
|
|
1068
|
+
badgeText: {
|
|
1069
|
+
red: 255,
|
|
1070
|
+
green: 255,
|
|
1071
|
+
blue: 255,
|
|
1072
|
+
alpha: 1
|
|
1073
|
+
},
|
|
1074
|
+
freeGiftBackground: {
|
|
1075
|
+
red: 0,
|
|
1076
|
+
green: 0,
|
|
1077
|
+
blue: 0,
|
|
1078
|
+
alpha: .3
|
|
1079
|
+
},
|
|
1080
|
+
freeGiftText: {
|
|
1081
|
+
red: 0,
|
|
1082
|
+
green: 0,
|
|
1083
|
+
blue: 0,
|
|
1084
|
+
alpha: 1
|
|
1085
|
+
},
|
|
1086
|
+
freeGiftSelectedBackground: {
|
|
1087
|
+
red: 0,
|
|
1088
|
+
green: 0,
|
|
1089
|
+
blue: 0,
|
|
1090
|
+
alpha: 1
|
|
1091
|
+
},
|
|
1092
|
+
freeGiftSelectedText: {
|
|
1093
|
+
red: 255,
|
|
1094
|
+
green: 255,
|
|
1095
|
+
blue: 255,
|
|
1096
|
+
alpha: 1
|
|
1097
|
+
},
|
|
1098
|
+
upsellBackground: {
|
|
1099
|
+
red: 0,
|
|
1100
|
+
green: 0,
|
|
1101
|
+
blue: 0,
|
|
1102
|
+
alpha: .2
|
|
1103
|
+
},
|
|
1104
|
+
upsellText: {
|
|
1105
|
+
red: 0,
|
|
1106
|
+
green: 0,
|
|
1107
|
+
blue: 0,
|
|
1108
|
+
alpha: 1
|
|
1109
|
+
},
|
|
1110
|
+
upsellSelectedBackground: {
|
|
1111
|
+
red: 0,
|
|
1112
|
+
green: 0,
|
|
1113
|
+
blue: 0,
|
|
1114
|
+
alpha: .2
|
|
1115
|
+
},
|
|
1116
|
+
upsellSelectedText: {
|
|
1117
|
+
red: 0,
|
|
1118
|
+
green: 0,
|
|
1119
|
+
blue: 0,
|
|
1120
|
+
alpha: 1
|
|
1121
|
+
}
|
|
1122
|
+
},
|
|
1123
|
+
fonts: {
|
|
1124
|
+
blockTitle: {
|
|
1125
|
+
size: "14",
|
|
1126
|
+
style: "bold"
|
|
1127
|
+
},
|
|
1128
|
+
title: {
|
|
1129
|
+
size: "20",
|
|
1130
|
+
style: "bold"
|
|
1131
|
+
},
|
|
1132
|
+
subtitle: {
|
|
1133
|
+
size: "14",
|
|
1134
|
+
style: "regular"
|
|
1135
|
+
},
|
|
1136
|
+
label: {
|
|
1137
|
+
size: "12",
|
|
1138
|
+
style: "regular"
|
|
1139
|
+
},
|
|
1140
|
+
freeGift: {
|
|
1141
|
+
size: "13",
|
|
1142
|
+
style: "bold"
|
|
1143
|
+
},
|
|
1144
|
+
upsell: {
|
|
1145
|
+
size: "13",
|
|
1146
|
+
style: "bold"
|
|
1147
|
+
},
|
|
1148
|
+
unitLabel: {
|
|
1149
|
+
size: "14",
|
|
1150
|
+
style: "regular"
|
|
1151
|
+
}
|
|
1152
|
+
},
|
|
1153
|
+
swatchOptions: [],
|
|
1154
|
+
swatchSize: 18,
|
|
1155
|
+
swatchShape: "circle",
|
|
1156
|
+
imageSize: 48,
|
|
1157
|
+
imageCornerRadius: 6
|
|
1158
|
+
};
|
|
1159
|
+
return e !== void 0 && (n.colors.border = {
|
|
1160
|
+
...De(e),
|
|
1161
|
+
alpha: 1
|
|
1162
|
+
}), n;
|
|
1163
|
+
}, Ae = ({ data: t, selectedVariantId: a, preview: o, onLinesChange: s, targetWindow: c }) => {
|
|
1164
|
+
let l = n(null), [u, d] = r(!1), f = n(!1);
|
|
1165
|
+
e(() => {
|
|
1166
|
+
l.current && !u && (async () => {
|
|
1167
|
+
await ye(c ?? window), d(!0);
|
|
1168
|
+
})();
|
|
1169
|
+
}, [u, c]), e(() => {
|
|
1170
|
+
let e = l.current;
|
|
1171
|
+
if (!u || !e) return;
|
|
1172
|
+
let t = () => {
|
|
1173
|
+
let t = e.items().map((e) => ({
|
|
1174
|
+
merchandiseId: `gid://shopify/ProductVariant/${e.id}`,
|
|
1175
|
+
quantity: e.quantity,
|
|
1176
|
+
attributes: Object.entries(e.properties).map(([e, t]) => ({
|
|
1177
|
+
key: e,
|
|
1178
|
+
value: String(t)
|
|
1179
|
+
})),
|
|
1180
|
+
sellingPlanId: e.selling_plan ? `gid://shopify/SellingPlan/${e.selling_plan}` : void 0
|
|
1181
|
+
}));
|
|
1182
|
+
s?.(t);
|
|
1183
|
+
};
|
|
1184
|
+
return f.current ||= (typeof e.items == "function" ? t() : e.addEventListener("kaching-bundles-block-loaded", t), !0), e.addEventListener("variants-changed", t), () => {
|
|
1185
|
+
e.removeEventListener("kaching-bundles-block-loaded", t), e.removeEventListener("variants-changed", t);
|
|
1186
|
+
};
|
|
1187
|
+
}, [u, s]);
|
|
1188
|
+
let p = t ? Me(t, a) : o ? Ne(o) : null;
|
|
1189
|
+
return je(() => {
|
|
1190
|
+
let e = l.current;
|
|
1191
|
+
if (e && p) for (let [t, n] of Object.entries(p.jsonAttributes)) e.getAttribute(t) !== n && e.setAttribute(t, n);
|
|
1192
|
+
}), p ? /* @__PURE__ */ i("kaching-bundles-block", {
|
|
1193
|
+
ref: l,
|
|
1194
|
+
"deal-block-id": p.dealBlockId,
|
|
1195
|
+
...p.jsonAttributes,
|
|
1196
|
+
"current-variant-id": p.currentVariantId
|
|
1197
|
+
}) : null;
|
|
1198
|
+
}, je = typeof window > "u" ? e : t, Me = ({ config: e, dealBlock: t, product: n, otherProducts: r, mediaImages: i, collectionBreaksProducts: a, translations: o }, s) => ({
|
|
1199
|
+
dealBlockId: t.id,
|
|
1200
|
+
currentVariantId: s ? s.split("/").pop() : String(n.variants[0].id),
|
|
1201
|
+
jsonAttributes: {
|
|
1202
|
+
config: JSON.stringify(e),
|
|
1203
|
+
"deal-block": JSON.stringify(t),
|
|
1204
|
+
"media-images": JSON.stringify(i),
|
|
1205
|
+
product: JSON.stringify(n),
|
|
1206
|
+
"other-products": JSON.stringify(r),
|
|
1207
|
+
"collection-breaks-products": JSON.stringify(a),
|
|
1208
|
+
translations: JSON.stringify(o)
|
|
1209
|
+
}
|
|
1210
|
+
}), Ne = ({ cornerRadius: e, color: t, price: n }) => {
|
|
1211
|
+
let r = $({ price: n }), i = Oe(), a = ke({
|
|
1212
|
+
color: t,
|
|
1213
|
+
cornerRadius: e
|
|
1214
|
+
});
|
|
1215
|
+
return {
|
|
1216
|
+
dealBlockId: a.id,
|
|
1217
|
+
currentVariantId: String(r.variants[0].id),
|
|
1218
|
+
jsonAttributes: {
|
|
1219
|
+
config: JSON.stringify(i),
|
|
1220
|
+
"deal-block": JSON.stringify(a),
|
|
1221
|
+
"media-images": JSON.stringify([]),
|
|
1222
|
+
product: JSON.stringify(r),
|
|
1223
|
+
"other-products": JSON.stringify([]),
|
|
1224
|
+
"collection-breaks-products": JSON.stringify([]),
|
|
1225
|
+
translations: JSON.stringify({})
|
|
1226
|
+
}
|
|
1227
|
+
};
|
|
1575
1228
|
};
|
|
1229
|
+
export { Ae as KachingBundle, ge as fetchKachingBundlesData };
|