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