@kachingappz/bundles-js 0.1.1 → 0.2.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/dist/bundles-js.iife.js +15 -15
- package/dist/bundles-js.js +369 -415
- package/package.json +1 -1
package/dist/bundles-js.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const N = {
|
|
2
2
|
id: 1,
|
|
3
3
|
handle: "example-product",
|
|
4
4
|
url: null,
|
|
@@ -28,7 +28,7 @@ const G = {
|
|
|
28
28
|
requiresSellingPlan: !1,
|
|
29
29
|
sellingPlans: [],
|
|
30
30
|
isNativeBundle: !1
|
|
31
|
-
},
|
|
31
|
+
}, x = {
|
|
32
32
|
id: "example",
|
|
33
33
|
nanoId: "example",
|
|
34
34
|
blockName: "Bundle",
|
|
@@ -241,10 +241,10 @@ const G = {
|
|
|
241
241
|
},
|
|
242
242
|
featureFlags: {},
|
|
243
243
|
shopCustomStyles: ""
|
|
244
|
-
},
|
|
244
|
+
}, T = {
|
|
245
245
|
config: B,
|
|
246
|
-
dealBlock:
|
|
247
|
-
product:
|
|
246
|
+
dealBlock: x,
|
|
247
|
+
product: N,
|
|
248
248
|
otherProducts: [],
|
|
249
249
|
mediaImages: [],
|
|
250
250
|
collectionBreaksProducts: [],
|
|
@@ -253,16 +253,16 @@ const G = {
|
|
|
253
253
|
country: t,
|
|
254
254
|
language: e
|
|
255
255
|
}) => {
|
|
256
|
-
const
|
|
257
|
-
return t &&
|
|
258
|
-
},
|
|
256
|
+
const l = [];
|
|
257
|
+
return t && l.push(`country: ${t}`), e && l.push(`language: ${e}`), l.length > 0 ? `@inContext(${l.join(", ")})` : "";
|
|
258
|
+
}, q = async (t, {
|
|
259
259
|
useExternalMetafieldNamespace: e,
|
|
260
|
-
useMetaobjects:
|
|
261
|
-
}) =>
|
|
260
|
+
useMetaobjects: l
|
|
261
|
+
}) => l ? U(
|
|
262
262
|
t
|
|
263
|
-
) :
|
|
264
|
-
var
|
|
265
|
-
const
|
|
263
|
+
) : M(t), M = async (t, e) => {
|
|
264
|
+
var a;
|
|
265
|
+
const l = (a = (await t.query(
|
|
266
266
|
`
|
|
267
267
|
query FetchDealBlocks($metafieldNamespace: String!) {
|
|
268
268
|
shop {
|
|
@@ -277,13 +277,13 @@ const G = {
|
|
|
277
277
|
metafieldNamespace: "app--2935586817--kaching_bundles"
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
|
-
)).shop.metafield) == null ? void 0 :
|
|
281
|
-
return
|
|
282
|
-
},
|
|
283
|
-
const
|
|
284
|
-
let
|
|
280
|
+
)).shop.metafield) == null ? void 0 : a.value;
|
|
281
|
+
return l ? JSON.parse(l) : [];
|
|
282
|
+
}, U = async (t, e) => {
|
|
283
|
+
const l = "app--2935586817--deal_block", a = [];
|
|
284
|
+
let i = null;
|
|
285
285
|
for (; ; ) {
|
|
286
|
-
const
|
|
286
|
+
const o = await t.query(
|
|
287
287
|
`
|
|
288
288
|
query FetchDealBlockMetaobjects($type: String!, $cursor: String) {
|
|
289
289
|
metaobjects(type: $type, first: 250, after: $cursor) {
|
|
@@ -302,32 +302,32 @@ const G = {
|
|
|
302
302
|
`,
|
|
303
303
|
{
|
|
304
304
|
variables: {
|
|
305
|
-
type:
|
|
306
|
-
cursor:
|
|
305
|
+
type: l,
|
|
306
|
+
cursor: i
|
|
307
307
|
}
|
|
308
308
|
}
|
|
309
309
|
);
|
|
310
|
-
for (const c of
|
|
311
|
-
const
|
|
312
|
-
(
|
|
310
|
+
for (const c of o.metaobjects.nodes) {
|
|
311
|
+
const s = c.fields.find(
|
|
312
|
+
(d) => d.key === "settings"
|
|
313
313
|
);
|
|
314
|
-
|
|
314
|
+
s != null && s.value && a.push(JSON.parse(s.value));
|
|
315
315
|
}
|
|
316
|
-
if (!
|
|
316
|
+
if (!o.metaobjects.pageInfo.hasNextPage)
|
|
317
317
|
break;
|
|
318
|
-
|
|
318
|
+
i = o.metaobjects.pageInfo.endCursor;
|
|
319
319
|
}
|
|
320
|
-
return
|
|
321
|
-
}, E = "app--2935586817",
|
|
320
|
+
return a;
|
|
321
|
+
}, E = "app--2935586817", L = async (t, {
|
|
322
322
|
language: e,
|
|
323
|
-
country:
|
|
324
|
-
useExternalMetafieldNamespace:
|
|
323
|
+
country: l,
|
|
324
|
+
useExternalMetafieldNamespace: a
|
|
325
325
|
}) => {
|
|
326
|
-
const
|
|
326
|
+
const i = `${E}--kaching_bundles`, o = E, {
|
|
327
327
|
shop: {
|
|
328
328
|
moneyFormat: c,
|
|
329
|
-
currencyRateConstant:
|
|
330
|
-
primaryDomain:
|
|
329
|
+
currencyRateConstant: s,
|
|
330
|
+
primaryDomain: d,
|
|
331
331
|
settingsMetafield: p
|
|
332
332
|
}
|
|
333
333
|
} = await t.query(
|
|
@@ -349,29 +349,29 @@ const G = {
|
|
|
349
349
|
`,
|
|
350
350
|
{
|
|
351
351
|
variables: {
|
|
352
|
-
metafieldNamespace:
|
|
353
|
-
settingsNamespace:
|
|
352
|
+
metafieldNamespace: i,
|
|
353
|
+
settingsNamespace: o
|
|
354
354
|
}
|
|
355
355
|
}
|
|
356
|
-
),
|
|
356
|
+
), m = s ? O(s.value) : 1, n = p ? JSON.parse(p.value) : null, u = (n == null ? void 0 : n.feature_flags) ?? {}, r = (n == null ? void 0 : n.custom_selectors) ?? {};
|
|
357
357
|
return {
|
|
358
|
-
shopifyDomain:
|
|
358
|
+
shopifyDomain: d.host,
|
|
359
359
|
moneyFormat: c,
|
|
360
360
|
locale: (e == null ? void 0 : e.toLowerCase()) || "en",
|
|
361
361
|
liquidLocale: (e == null ? void 0 : e.toLowerCase()) || "en",
|
|
362
|
-
country:
|
|
363
|
-
currencyRate:
|
|
362
|
+
country: l ?? "US",
|
|
363
|
+
currencyRate: m,
|
|
364
364
|
marketId: 0,
|
|
365
365
|
productId: null,
|
|
366
|
-
storefrontAccessToken: (
|
|
367
|
-
accessScopes: (
|
|
368
|
-
customApiHost: (
|
|
369
|
-
keepQuantityInput: (
|
|
370
|
-
ignoreDeselect: (
|
|
371
|
-
ignoreUnitPrice: (
|
|
372
|
-
requireCustomerLogin: (
|
|
373
|
-
abTestsRunning: (
|
|
374
|
-
webPixel: (
|
|
366
|
+
storefrontAccessToken: (n == null ? void 0 : n.storefront_access_token) ?? null,
|
|
367
|
+
accessScopes: (n == null ? void 0 : n.access_scopes) ?? [],
|
|
368
|
+
customApiHost: (n == null ? void 0 : n.custom_api_host) ?? null,
|
|
369
|
+
keepQuantityInput: (n == null ? void 0 : n.keep_quantity_input) ?? !1,
|
|
370
|
+
ignoreDeselect: (n == null ? void 0 : n.ignore_deselect) ?? !1,
|
|
371
|
+
ignoreUnitPrice: (n == null ? void 0 : n.ignore_unit_price) ?? !1,
|
|
372
|
+
requireCustomerLogin: (n == null ? void 0 : n.require_customer_login) ?? !1,
|
|
373
|
+
abTestsRunning: (n == null ? void 0 : n.ab_tests_running) ?? !1,
|
|
374
|
+
webPixel: (n == null ? void 0 : n.web_pixel) ?? !1,
|
|
375
375
|
b2bCustomer: !1,
|
|
376
376
|
isLoggedIn: !1,
|
|
377
377
|
preview: !1,
|
|
@@ -395,16 +395,16 @@ const G = {
|
|
|
395
395
|
"system.no_products_available": "No products available"
|
|
396
396
|
},
|
|
397
397
|
customSelectors: {
|
|
398
|
-
quantity:
|
|
399
|
-
addToCartButton:
|
|
400
|
-
variantPicker:
|
|
401
|
-
price:
|
|
402
|
-
priceCompare:
|
|
398
|
+
quantity: r.quantity ?? null,
|
|
399
|
+
addToCartButton: r.add_to_cart_button ?? null,
|
|
400
|
+
variantPicker: r.variant_picker ?? null,
|
|
401
|
+
price: r.price ?? null,
|
|
402
|
+
priceCompare: r.price_compare ?? null
|
|
403
403
|
},
|
|
404
|
-
shopCustomStyles: (
|
|
405
|
-
featureFlags:
|
|
404
|
+
shopCustomStyles: (n == null ? void 0 : n.shop_custom_styles) ?? "",
|
|
405
|
+
featureFlags: u
|
|
406
406
|
};
|
|
407
|
-
},
|
|
407
|
+
}, O = (t) => JSON.parse(t).amount / 1e6, V = async (t, e, l = 200) => (e = e.filter(Boolean).filter((a) => !a.startsWith("placeholder")), e.length === 0 ? [] : (await t.query(
|
|
408
408
|
`
|
|
409
409
|
query FetchMediaImages($mediaImageIds: [ID!]!, $size: Int!) {
|
|
410
410
|
nodes(ids: $mediaImageIds) {
|
|
@@ -420,30 +420,30 @@ const G = {
|
|
|
420
420
|
{
|
|
421
421
|
variables: {
|
|
422
422
|
mediaImageIds: e,
|
|
423
|
-
size:
|
|
423
|
+
size: l
|
|
424
424
|
}
|
|
425
425
|
}
|
|
426
|
-
)).nodes.filter(Boolean).map((
|
|
427
|
-
gid:
|
|
428
|
-
url:
|
|
426
|
+
)).nodes.filter(Boolean).map((a) => ({
|
|
427
|
+
gid: a.id,
|
|
428
|
+
url: a.image.url
|
|
429
429
|
}))), w = async (t, {
|
|
430
430
|
country: e,
|
|
431
|
-
language:
|
|
432
|
-
blockVisibility:
|
|
433
|
-
excludedProductGIDs:
|
|
434
|
-
selectedProductGIDs:
|
|
431
|
+
language: l,
|
|
432
|
+
blockVisibility: a,
|
|
433
|
+
excludedProductGIDs: i,
|
|
434
|
+
selectedProductGIDs: o,
|
|
435
435
|
selectedCollectionGIDs: c,
|
|
436
|
-
limit:
|
|
436
|
+
limit: s = 250
|
|
437
437
|
}) => {
|
|
438
|
-
switch (
|
|
438
|
+
switch (a) {
|
|
439
439
|
case "selected-products":
|
|
440
|
-
return
|
|
440
|
+
return o.slice(0, s);
|
|
441
441
|
case "all-products":
|
|
442
442
|
case "excluded-products": {
|
|
443
|
-
const
|
|
443
|
+
const d = P({ country: e, language: l });
|
|
444
444
|
let p = (await t.query(
|
|
445
445
|
`
|
|
446
|
-
query FetchProductGIDs($limit: Int!) ${
|
|
446
|
+
query FetchProductGIDs($limit: Int!) ${d} {
|
|
447
447
|
products(first: $limit) {
|
|
448
448
|
nodes {
|
|
449
449
|
id
|
|
@@ -453,18 +453,18 @@ const G = {
|
|
|
453
453
|
`,
|
|
454
454
|
{
|
|
455
455
|
variables: {
|
|
456
|
-
limit:
|
|
456
|
+
limit: s
|
|
457
457
|
}
|
|
458
458
|
}
|
|
459
|
-
)).products.nodes.map((
|
|
460
|
-
return
|
|
461
|
-
(
|
|
459
|
+
)).products.nodes.map((m) => m.id);
|
|
460
|
+
return a === "excluded-products" && (p = p.filter(
|
|
461
|
+
(m) => !i.includes(m)
|
|
462
462
|
)), p;
|
|
463
463
|
}
|
|
464
464
|
case "selected-collections": {
|
|
465
|
-
const
|
|
465
|
+
const d = P({ country: e, language: l }), p = (await t.query(
|
|
466
466
|
`
|
|
467
|
-
query FetchCollectionProductGIDs($collectionGIDs: [ID!]!, $limit: Int!) ${
|
|
467
|
+
query FetchCollectionProductGIDs($collectionGIDs: [ID!]!, $limit: Int!) ${d} {
|
|
468
468
|
nodes(ids: $collectionGIDs) {
|
|
469
469
|
... on Collection {
|
|
470
470
|
products(first: $limit) {
|
|
@@ -479,16 +479,16 @@ const G = {
|
|
|
479
479
|
{
|
|
480
480
|
variables: {
|
|
481
481
|
collectionGIDs: c,
|
|
482
|
-
limit:
|
|
482
|
+
limit: s
|
|
483
483
|
}
|
|
484
484
|
}
|
|
485
|
-
)).nodes.filter((
|
|
486
|
-
(
|
|
485
|
+
)).nodes.filter((m) => m !== null).flatMap(
|
|
486
|
+
(m) => m.products.nodes.map((n) => n.id)
|
|
487
487
|
);
|
|
488
|
-
return Array.from(new Set(p)).slice(0,
|
|
488
|
+
return Array.from(new Set(p)).slice(0, s);
|
|
489
489
|
}
|
|
490
490
|
}
|
|
491
|
-
},
|
|
491
|
+
}, G = `
|
|
492
492
|
id
|
|
493
493
|
availableForSale
|
|
494
494
|
price {
|
|
@@ -527,18 +527,18 @@ const G = {
|
|
|
527
527
|
quantityAvailable @include(if: $includeAvailableQuantity)
|
|
528
528
|
`, _ = async (t, {
|
|
529
529
|
country: e,
|
|
530
|
-
language:
|
|
531
|
-
productIds:
|
|
532
|
-
includeSellingPlans:
|
|
533
|
-
includeAvailableQuantity:
|
|
530
|
+
language: l,
|
|
531
|
+
productIds: a,
|
|
532
|
+
includeSellingPlans: i = !0,
|
|
533
|
+
includeAvailableQuantity: o = !0,
|
|
534
534
|
useExternalMetafieldNamespace: c = !1
|
|
535
535
|
}) => {
|
|
536
|
-
if (!
|
|
536
|
+
if (!a.length)
|
|
537
537
|
return [];
|
|
538
|
-
const
|
|
538
|
+
const s = a.map((m) => typeof m == "string" && m.startsWith("gid://") ? m : `gid://shopify/Product/${m}`), d = P({ country: e, language: l });
|
|
539
539
|
let p = (await t.query(
|
|
540
540
|
`
|
|
541
|
-
query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $metafieldNamespace: String!) ${
|
|
541
|
+
query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $metafieldNamespace: String!) ${d} {
|
|
542
542
|
nodes(ids: $productGIDs) {
|
|
543
543
|
... on Product {
|
|
544
544
|
id
|
|
@@ -567,7 +567,7 @@ const G = {
|
|
|
567
567
|
}
|
|
568
568
|
variants(first: 250) {
|
|
569
569
|
nodes {
|
|
570
|
-
${
|
|
570
|
+
${G}
|
|
571
571
|
}
|
|
572
572
|
}
|
|
573
573
|
collections(first: 50) {
|
|
@@ -622,36 +622,36 @@ const G = {
|
|
|
622
622
|
`,
|
|
623
623
|
{
|
|
624
624
|
variables: {
|
|
625
|
-
productGIDs:
|
|
626
|
-
includeSellingPlans:
|
|
627
|
-
includeAvailableQuantity:
|
|
625
|
+
productGIDs: s,
|
|
626
|
+
includeSellingPlans: i,
|
|
627
|
+
includeAvailableQuantity: o,
|
|
628
628
|
metafieldNamespace: c ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles"
|
|
629
629
|
}
|
|
630
630
|
}
|
|
631
631
|
)).nodes.filter(
|
|
632
|
-
(
|
|
632
|
+
(m) => m != null
|
|
633
633
|
);
|
|
634
634
|
return p = await Promise.all(
|
|
635
635
|
p.map(
|
|
636
|
-
(
|
|
637
|
-
includeSellingPlans:
|
|
638
|
-
includeAvailableQuantity:
|
|
636
|
+
(m) => F(t, m, {
|
|
637
|
+
includeSellingPlans: i,
|
|
638
|
+
includeAvailableQuantity: o
|
|
639
639
|
})
|
|
640
640
|
)
|
|
641
|
-
), p.map(
|
|
642
|
-
}, F = async (t, e,
|
|
641
|
+
), p.map(j);
|
|
642
|
+
}, F = async (t, e, l) => {
|
|
643
643
|
if (e.variants.nodes.length < 250)
|
|
644
644
|
return e;
|
|
645
|
-
const
|
|
646
|
-
let
|
|
647
|
-
for (;
|
|
648
|
-
const
|
|
645
|
+
const a = /* @__PURE__ */ new Set(), i = [], o = [], c = async (s) => {
|
|
646
|
+
let d = !0, p = null;
|
|
647
|
+
for (; d; ) {
|
|
648
|
+
const m = await t.query(
|
|
649
649
|
`
|
|
650
650
|
query($productGID: ID!, $cursor: String, $reverse: Boolean, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!) {
|
|
651
651
|
product(id: $productGID) {
|
|
652
652
|
variants(first: 250, after: $cursor, reverse: $reverse) {
|
|
653
653
|
nodes {
|
|
654
|
-
${
|
|
654
|
+
${G}
|
|
655
655
|
}
|
|
656
656
|
pageInfo {
|
|
657
657
|
endCursor
|
|
@@ -665,108 +665,108 @@ const G = {
|
|
|
665
665
|
variables: {
|
|
666
666
|
productGID: e.id,
|
|
667
667
|
cursor: p,
|
|
668
|
-
reverse:
|
|
669
|
-
...
|
|
668
|
+
reverse: s,
|
|
669
|
+
...l
|
|
670
670
|
}
|
|
671
671
|
}
|
|
672
|
-
), { nodes:
|
|
673
|
-
for (const
|
|
674
|
-
if (
|
|
675
|
-
|
|
672
|
+
), { nodes: n, pageInfo: u } = m.product.variants;
|
|
673
|
+
for (const r of n) {
|
|
674
|
+
if (a.has(r.id)) {
|
|
675
|
+
d = !1;
|
|
676
676
|
break;
|
|
677
677
|
}
|
|
678
|
-
|
|
678
|
+
a.add(r.id), s ? o.push(r) : i.push(r);
|
|
679
679
|
}
|
|
680
|
-
|
|
680
|
+
u.hasNextPage || (d = !1), p = u.endCursor;
|
|
681
681
|
}
|
|
682
682
|
};
|
|
683
683
|
return await Promise.all([
|
|
684
684
|
c(!1),
|
|
685
685
|
c(!0)
|
|
686
|
-
]), e.variants.nodes = [...
|
|
687
|
-
},
|
|
688
|
-
var c,
|
|
686
|
+
]), e.variants.nodes = [...i, ...o.reverse()], e;
|
|
687
|
+
}, j = (t) => {
|
|
688
|
+
var c, s, d, p, m, n;
|
|
689
689
|
const e = t.variants.nodes.map(
|
|
690
|
-
({ unitPriceMeasurement:
|
|
691
|
-
var
|
|
690
|
+
({ unitPriceMeasurement: u, ...r }) => {
|
|
691
|
+
var f, g;
|
|
692
692
|
return {
|
|
693
|
-
id: Number(
|
|
694
|
-
availableForSale:
|
|
695
|
-
price: Math.round(Number(
|
|
696
|
-
compareAtPrice:
|
|
697
|
-
options:
|
|
698
|
-
imageId:
|
|
699
|
-
image: ((
|
|
700
|
-
sellingPlans: ((
|
|
701
|
-
id: Number(
|
|
702
|
-
price:
|
|
693
|
+
id: Number(r.id.split("/").pop()),
|
|
694
|
+
availableForSale: r.availableForSale,
|
|
695
|
+
price: Math.round(Number(r.price.amount) * 100),
|
|
696
|
+
compareAtPrice: r.compareAtPrice ? Math.round(Number(r.compareAtPrice.amount) * 100) : null,
|
|
697
|
+
options: r.selectedOptions.map((h) => h.value),
|
|
698
|
+
imageId: r.image ? Number(r.image.id.split("/").pop()) : null,
|
|
699
|
+
image: ((f = r.image) == null ? void 0 : f.url) || null,
|
|
700
|
+
sellingPlans: ((g = r.sellingPlanAllocations) == null ? void 0 : g.nodes.map((h) => ({
|
|
701
|
+
id: Number(h.sellingPlan.id.split("/").pop()),
|
|
702
|
+
price: h.priceAdjustments.length > 0 ? Math.round(Number(h.priceAdjustments[0].price.amount) * 100) : Math.round(Number(r.price.amount) * 100)
|
|
703
703
|
}))) || [],
|
|
704
704
|
inventoryManagement: null,
|
|
705
705
|
// Storefront API does not return inventory management, only available in liquid
|
|
706
706
|
inventoryPolicy: null,
|
|
707
707
|
// Storefront API does not return inventory policy, only available in liquid
|
|
708
|
-
inventoryQuantity:
|
|
709
|
-
unitPriceMeasurement:
|
|
710
|
-
quantityValue:
|
|
711
|
-
quantityUnit:
|
|
712
|
-
referenceValue:
|
|
713
|
-
referenceUnit:
|
|
708
|
+
inventoryQuantity: r.quantityAvailable ?? null,
|
|
709
|
+
unitPriceMeasurement: u != null && u.quantityUnit && (u != null && u.referenceUnit) ? {
|
|
710
|
+
quantityValue: u.quantityValue,
|
|
711
|
+
quantityUnit: u.quantityUnit.toLowerCase(),
|
|
712
|
+
referenceValue: u.referenceValue,
|
|
713
|
+
referenceUnit: u.referenceUnit.toLowerCase()
|
|
714
714
|
} : null
|
|
715
715
|
};
|
|
716
716
|
}
|
|
717
|
-
),
|
|
718
|
-
const
|
|
719
|
-
var
|
|
717
|
+
), l = t.options.map((u, r) => {
|
|
718
|
+
const f = u.optionValues.map((g) => {
|
|
719
|
+
var h, b, y, I;
|
|
720
720
|
return {
|
|
721
|
-
id: Number(
|
|
722
|
-
defaultName:
|
|
723
|
-
name:
|
|
721
|
+
id: Number(g.id.split("/").pop()),
|
|
722
|
+
defaultName: g.name,
|
|
723
|
+
name: g.name,
|
|
724
724
|
swatch: {
|
|
725
|
-
color: ((
|
|
726
|
-
image: ((
|
|
725
|
+
color: ((h = g.swatch) == null ? void 0 : h.color) || null,
|
|
726
|
+
image: ((I = (y = (b = g.swatch) == null ? void 0 : b.image) == null ? void 0 : y.previewImage) == null ? void 0 : I.url) || null
|
|
727
727
|
}
|
|
728
728
|
};
|
|
729
729
|
});
|
|
730
730
|
return {
|
|
731
|
-
defaultName:
|
|
732
|
-
name:
|
|
733
|
-
position:
|
|
734
|
-
optionValues: z(
|
|
731
|
+
defaultName: u.name,
|
|
732
|
+
name: u.name,
|
|
733
|
+
position: r + 1,
|
|
734
|
+
optionValues: z(f, r, e)
|
|
735
735
|
};
|
|
736
|
-
}),
|
|
737
|
-
const
|
|
738
|
-
if (!
|
|
736
|
+
}), a = (u) => {
|
|
737
|
+
const r = u.priceAdjustments[0];
|
|
738
|
+
if (!r)
|
|
739
739
|
return null;
|
|
740
|
-
const
|
|
741
|
-
switch (
|
|
740
|
+
const f = r.adjustmentValue;
|
|
741
|
+
switch (f.__typename) {
|
|
742
742
|
case "SellingPlanPercentagePriceAdjustment":
|
|
743
743
|
return {
|
|
744
744
|
type: "percentage",
|
|
745
|
-
value:
|
|
745
|
+
value: f.adjustmentPercentage
|
|
746
746
|
};
|
|
747
747
|
case "SellingPlanFixedAmountPriceAdjustment":
|
|
748
748
|
return {
|
|
749
749
|
type: "fixed_amount",
|
|
750
|
-
value: Number(
|
|
750
|
+
value: Number(f.adjustmentAmount.amount) * 100
|
|
751
751
|
};
|
|
752
752
|
case "SellingPlanFixedPriceAdjustment":
|
|
753
753
|
return {
|
|
754
754
|
type: "price",
|
|
755
|
-
value: Number(
|
|
755
|
+
value: Number(f.price.amount) * 100
|
|
756
756
|
};
|
|
757
757
|
default:
|
|
758
758
|
throw new Error(
|
|
759
|
-
`Unknown price adjustment type: ${
|
|
759
|
+
`Unknown price adjustment type: ${f.__typename}`
|
|
760
760
|
);
|
|
761
761
|
}
|
|
762
|
-
},
|
|
763
|
-
(
|
|
764
|
-
id: Number(
|
|
765
|
-
name:
|
|
766
|
-
priceAdjustment:
|
|
762
|
+
}, i = ((c = t.sellingPlanGroups) == null ? void 0 : c.nodes.flatMap(
|
|
763
|
+
(u) => u.sellingPlans.nodes.map((r) => ({
|
|
764
|
+
id: Number(r.id.split("/").pop()),
|
|
765
|
+
name: r.name,
|
|
766
|
+
priceAdjustment: a(r)
|
|
767
767
|
}))
|
|
768
|
-
)) || [],
|
|
769
|
-
(
|
|
768
|
+
)) || [], o = t.variants.nodes.some(
|
|
769
|
+
(u) => u.requiresComponents
|
|
770
770
|
);
|
|
771
771
|
return {
|
|
772
772
|
id: Number(t.id.split("/").pop()),
|
|
@@ -775,54 +775,55 @@ const G = {
|
|
|
775
775
|
availableForSale: t.availableForSale,
|
|
776
776
|
createdAt: t.createdAt,
|
|
777
777
|
title: t.title,
|
|
778
|
-
image: ((
|
|
778
|
+
image: ((s = t.featuredImage) == null ? void 0 : s.url) || null,
|
|
779
779
|
collectionIds: t.collections.nodes.map(
|
|
780
|
-
(
|
|
780
|
+
(u) => Number(u.id.split("/").pop())
|
|
781
781
|
),
|
|
782
|
-
options:
|
|
782
|
+
options: l,
|
|
783
783
|
selectedVariantId: Number(
|
|
784
784
|
t.variants.nodes[0].id.split("/").pop()
|
|
785
785
|
),
|
|
786
786
|
variants: e,
|
|
787
787
|
requiresSellingPlan: t.requiresSellingPlan,
|
|
788
|
-
sellingPlans:
|
|
789
|
-
isNativeBundle:
|
|
788
|
+
sellingPlans: i,
|
|
789
|
+
isNativeBundle: o,
|
|
790
790
|
metafields: {
|
|
791
|
-
text: ((
|
|
791
|
+
text: ((d = t.metafield) == null ? void 0 : d.value) || null,
|
|
792
792
|
text2: ((p = t.metafield2) == null ? void 0 : p.value) || null,
|
|
793
|
-
text3: ((
|
|
794
|
-
text4: ((
|
|
793
|
+
text3: ((m = t.metafield3) == null ? void 0 : m.value) || null,
|
|
794
|
+
text4: ((n = t.metafield4) == null ? void 0 : n.value) || null
|
|
795
795
|
}
|
|
796
796
|
};
|
|
797
|
-
}, z = (t, e,
|
|
798
|
-
(
|
|
799
|
-
).length > 0),
|
|
800
|
-
const
|
|
801
|
-
(
|
|
797
|
+
}, z = (t, e, l) => t.filter((a) => l.filter(
|
|
798
|
+
(i) => i.options[e] === a.name
|
|
799
|
+
).length > 0), R = (t, e) => {
|
|
800
|
+
const l = [], a = t.filter(
|
|
801
|
+
(s) => s.blockVisibility === "selected-products"
|
|
802
802
|
);
|
|
803
|
-
for (const
|
|
804
|
-
|
|
805
|
-
const
|
|
806
|
-
(
|
|
803
|
+
for (const s of a)
|
|
804
|
+
s.selectedProductIds.map(Number).includes(e.id) && l.push(s);
|
|
805
|
+
const i = t.filter(
|
|
806
|
+
(s) => s.blockVisibility === "selected-collections"
|
|
807
807
|
);
|
|
808
|
-
for (const
|
|
808
|
+
for (const s of i)
|
|
809
809
|
e.collectionIds.some(
|
|
810
|
-
(
|
|
811
|
-
) &&
|
|
812
|
-
const
|
|
813
|
-
(
|
|
810
|
+
(d) => s.selectedCollectionIds.map(Number).includes(d)
|
|
811
|
+
) && l.push(s);
|
|
812
|
+
const o = t.filter(
|
|
813
|
+
(s) => s.blockVisibility === "excluded-products"
|
|
814
814
|
);
|
|
815
|
-
for (const
|
|
816
|
-
!
|
|
817
|
-
(
|
|
818
|
-
) &&
|
|
815
|
+
for (const s of o)
|
|
816
|
+
!s.excludedProductIds.map(Number).includes(e.id) && !(s.excludedCollectionIds || []).some(
|
|
817
|
+
(d) => e.collectionIds.includes(d)
|
|
818
|
+
) && l.push(s);
|
|
819
819
|
const c = t.filter(
|
|
820
|
-
(
|
|
820
|
+
(s) => s.blockVisibility === "all-products"
|
|
821
821
|
);
|
|
822
|
-
for (const
|
|
823
|
-
|
|
824
|
-
return
|
|
825
|
-
},
|
|
822
|
+
for (const s of c)
|
|
823
|
+
l.push(s);
|
|
824
|
+
return l;
|
|
825
|
+
}, H = (t) => [
|
|
826
|
+
...J(t),
|
|
826
827
|
...Q(t),
|
|
827
828
|
...W(t),
|
|
828
829
|
...X(t),
|
|
@@ -831,67 +832,66 @@ const G = {
|
|
|
831
832
|
...Z(t),
|
|
832
833
|
...ee(t),
|
|
833
834
|
...te(t),
|
|
834
|
-
...se(t),
|
|
835
835
|
...le(t)
|
|
836
|
-
].filter((e) => e != null && !e.includes("placeholder")),
|
|
837
|
-
({ freeGifts: e }) => (e || []).map((
|
|
838
|
-
).reduce((e,
|
|
839
|
-
({ multipleGiftsSelectors: e }) => (e || []).map((
|
|
840
|
-
).filter((e) => e != null),
|
|
841
|
-
const
|
|
842
|
-
return [...e, ...
|
|
843
|
-
}, []) : [],
|
|
836
|
+
].filter((e) => e != null && !e.includes("placeholder")), J = (t) => t.dealBars.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), Q = (t) => t.dealBars.map(
|
|
837
|
+
({ freeGifts: e }) => (e || []).map((l) => l.mediaImageGID)
|
|
838
|
+
).reduce((e, l) => e.concat(l), []).filter((e) => e != null), W = (t) => t.dealBars.flatMap(
|
|
839
|
+
({ multipleGiftsSelectors: e }) => (e || []).map((l) => l.mediaImageGID)
|
|
840
|
+
).filter((e) => e != null), X = (t) => t.dealBars.map(({ upsells: e }) => (e || []).map((l) => l.mediaImageGID)).reduce((e, l) => e.concat(l), []).filter((e) => e != null), K = (t) => t.swatchOptions ? t.swatchOptions.reduce((e, l) => {
|
|
841
|
+
const a = l.images.map((i) => i.mediaImageGID).filter((i) => i != null);
|
|
842
|
+
return [...e, ...a];
|
|
843
|
+
}, []) : [], Y = (t) => {
|
|
844
844
|
if (!t.collectionBreaksEnabled || !t.collectionBreaks)
|
|
845
845
|
return [];
|
|
846
846
|
const e = t.collectionBreaks.mediaImageGID;
|
|
847
847
|
return e ? [e] : [];
|
|
848
|
-
},
|
|
849
|
-
var e,
|
|
848
|
+
}, Z = (t) => {
|
|
849
|
+
var e, l, a;
|
|
850
850
|
return t.progressiveGifts ? [
|
|
851
|
-
...((e = t.progressiveGifts.gifts) == null ? void 0 : e.map((
|
|
852
|
-
(
|
|
853
|
-
(
|
|
854
|
-
].filter((
|
|
855
|
-
},
|
|
856
|
-
var
|
|
857
|
-
return (
|
|
851
|
+
...((e = t.progressiveGifts.gifts) == null ? void 0 : e.map((i) => i.mediaImageGID)) || [],
|
|
852
|
+
(l = t.progressiveGifts.style) == null ? void 0 : l.lockedMediaImageGID,
|
|
853
|
+
(a = t.progressiveGifts.dealBarStyle) == null ? void 0 : a.lockedMediaImageGID
|
|
854
|
+
].filter((i) => i != null) : [];
|
|
855
|
+
}, ee = (t) => !t.checkboxUpsellsEnabled || !t.checkboxUpsells ? [] : t.checkboxUpsells.upsells.map((e) => e.mediaImageGID).filter((e) => e != null), te = (t) => t.dealBars.map((e) => {
|
|
856
|
+
var l;
|
|
857
|
+
return (l = e.productPersonalisation) == null ? void 0 : l.mediaImageGID;
|
|
858
858
|
}).filter((e) => e != null), le = (t) => t.dealBars.map((e) => {
|
|
859
|
-
var
|
|
860
|
-
return (
|
|
861
|
-
}).filter((e) => e != null),
|
|
859
|
+
var l;
|
|
860
|
+
return (l = e.highlights) == null ? void 0 : l.customIconGID;
|
|
861
|
+
}).filter((e) => e != null), se = (t) => {
|
|
862
862
|
const e = [
|
|
863
863
|
...ae(t),
|
|
864
|
+
...ne(t),
|
|
864
865
|
...ie(t),
|
|
865
866
|
...re(t),
|
|
866
867
|
...oe(t),
|
|
867
868
|
...ce(t),
|
|
868
|
-
...ue(t)
|
|
869
|
-
...de(t)
|
|
869
|
+
...ue(t)
|
|
870
870
|
];
|
|
871
|
-
return Array.from(new Set(e.filter((
|
|
871
|
+
return Array.from(new Set(e.filter((l) => l != null)));
|
|
872
872
|
}, ae = (t) => t.dealBars.flatMap(
|
|
873
|
-
({ freeGifts: e }) => e ? e.map((
|
|
874
|
-
).filter((e) => e != null),
|
|
873
|
+
({ freeGifts: e }) => e ? e.map((l) => l.productGID) : []
|
|
874
|
+
).filter((e) => e != null), ne = (t) => t.dealBars.flatMap(
|
|
875
875
|
({ multipleGiftsSelectors: e }) => e ? e.flatMap(
|
|
876
|
-
(
|
|
876
|
+
(l) => l.products ? l.products.map((a) => a.id) : []
|
|
877
877
|
) : []
|
|
878
|
-
).filter((e) => e != null),
|
|
878
|
+
).filter((e) => e != null), ie = (t) => {
|
|
879
879
|
var e;
|
|
880
|
-
return t.progressiveGiftsEnabled ? ((e = t.progressiveGifts) == null ? void 0 : e.gifts.map((
|
|
881
|
-
},
|
|
882
|
-
({ bundleProducts: e }) => e ? e.map((
|
|
883
|
-
).filter((e) => e != null).filter((e) => e !== "default"),
|
|
884
|
-
class
|
|
885
|
-
constructor(e,
|
|
886
|
-
this.storefrontApiVersion = "2025-10", this.storefrontAccessToken =
|
|
880
|
+
return t.progressiveGiftsEnabled ? ((e = t.progressiveGifts) == null ? void 0 : e.gifts.map((l) => l.productGID).filter((l) => l != null)) || [] : [];
|
|
881
|
+
}, re = (t) => t.dealBars.flatMap(({ upsells: e }) => e ? e.map((l) => l.productGID) : []).filter((e) => e != null), oe = (t) => t.dealBars.filter((e) => e.dealBarType === "bundle").flatMap(
|
|
882
|
+
({ bundleProducts: e }) => e ? e.map((l) => l.productGID) : []
|
|
883
|
+
).filter((e) => e != null).filter((e) => e !== "default"), ce = (t) => !t.checkboxUpsellsEnabled || !t.checkboxUpsells ? [] : t.checkboxUpsells.upsells.map((e) => e.productGID).filter((e) => e != null), ue = (t) => t.dealBars.filter((e) => e.dealBarType === "sku").flatMap(({ productGID: e }) => e ? [e] : []);
|
|
884
|
+
class A {
|
|
885
|
+
constructor(e, l) {
|
|
886
|
+
this.storefrontApiVersion = "2025-10", this.storefrontAccessToken = l, this.shopifyDomain = e;
|
|
887
887
|
}
|
|
888
|
-
async query(e,
|
|
889
|
-
var
|
|
890
|
-
const
|
|
891
|
-
let
|
|
892
|
-
const
|
|
893
|
-
|
|
894
|
-
const c = await (await fetch(
|
|
888
|
+
async query(e, l) {
|
|
889
|
+
var s;
|
|
890
|
+
const a = (l == null ? void 0 : l.variables) ?? {};
|
|
891
|
+
let i = `https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`;
|
|
892
|
+
const o = (s = e.match(/query\s+(\w+)/)) == null ? void 0 : s[1];
|
|
893
|
+
o && (i += `?operation_name=${o}`);
|
|
894
|
+
const c = await (await fetch(i, {
|
|
895
895
|
method: "POST",
|
|
896
896
|
headers: {
|
|
897
897
|
"Content-Type": "application/json",
|
|
@@ -899,7 +899,7 @@ class me {
|
|
|
899
899
|
},
|
|
900
900
|
body: JSON.stringify({
|
|
901
901
|
query: e,
|
|
902
|
-
variables:
|
|
902
|
+
variables: a
|
|
903
903
|
})
|
|
904
904
|
})).text();
|
|
905
905
|
if (!c)
|
|
@@ -907,47 +907,47 @@ class me {
|
|
|
907
907
|
return JSON.parse(c).data;
|
|
908
908
|
}
|
|
909
909
|
}
|
|
910
|
-
const
|
|
911
|
-
const
|
|
912
|
-
if (!e.collectionBreaksEnabled || !
|
|
913
|
-
let
|
|
914
|
-
|
|
915
|
-
country:
|
|
916
|
-
language:
|
|
910
|
+
const de = async (t, e, { country: l, language: a }) => {
|
|
911
|
+
const i = e.collectionBreaks;
|
|
912
|
+
if (!e.collectionBreaksEnabled || !i) return;
|
|
913
|
+
let o;
|
|
914
|
+
i.visibility === "deal-products" ? o = await w(t, {
|
|
915
|
+
country: l,
|
|
916
|
+
language: a,
|
|
917
917
|
blockVisibility: e.blockVisibility,
|
|
918
918
|
excludedProductGIDs: (e.excludedProductIds || []).map(
|
|
919
|
-
(
|
|
919
|
+
(s) => `gid://shopify/Product/${s}`
|
|
920
920
|
),
|
|
921
921
|
selectedProductGIDs: (e.selectedProductIds || []).map(
|
|
922
|
-
(
|
|
922
|
+
(s) => `gid://shopify/Product/${s}`
|
|
923
923
|
),
|
|
924
924
|
selectedCollectionGIDs: (e.selectedCollectionIds || []).map(
|
|
925
|
-
(
|
|
925
|
+
(s) => `gid://shopify/Collection/${s}`
|
|
926
926
|
)
|
|
927
|
-
}) :
|
|
928
|
-
country:
|
|
929
|
-
language:
|
|
930
|
-
blockVisibility:
|
|
931
|
-
excludedProductGIDs: (
|
|
932
|
-
({ id:
|
|
927
|
+
}) : o = await w(t, {
|
|
928
|
+
country: l,
|
|
929
|
+
language: a,
|
|
930
|
+
blockVisibility: i.visibility,
|
|
931
|
+
excludedProductGIDs: (i.excludedProducts || []).map(
|
|
932
|
+
({ id: s }) => s
|
|
933
933
|
),
|
|
934
|
-
selectedProductGIDs: (
|
|
935
|
-
({ id:
|
|
934
|
+
selectedProductGIDs: (i.selectedProducts || []).map(
|
|
935
|
+
({ id: s }) => s
|
|
936
936
|
),
|
|
937
|
-
selectedCollectionGIDs: (
|
|
938
|
-
({ id:
|
|
937
|
+
selectedCollectionGIDs: (i.selectedCollections || []).map(
|
|
938
|
+
({ id: s }) => s
|
|
939
939
|
)
|
|
940
|
-
}),
|
|
940
|
+
}), o = o.slice(0, 250);
|
|
941
941
|
let c = await _(t, {
|
|
942
|
-
country:
|
|
943
|
-
language:
|
|
944
|
-
productIds:
|
|
942
|
+
country: l,
|
|
943
|
+
language: a,
|
|
944
|
+
productIds: o.map((s) => Number(s.split("/").pop())),
|
|
945
945
|
useExternalMetafieldNamespace: !0
|
|
946
946
|
});
|
|
947
947
|
return c = c.filter(
|
|
948
|
-
(
|
|
948
|
+
(s) => s.availableForSale
|
|
949
949
|
), c;
|
|
950
|
-
},
|
|
950
|
+
}, me = () => ({
|
|
951
951
|
"system.out_of_stock": "There's not enough items in our stock, please select smaller bundle.",
|
|
952
952
|
"system.invalid_variant": "Sorry, this is not currently available.",
|
|
953
953
|
"system.unavailable_option_value": "Unavailable",
|
|
@@ -964,163 +964,116 @@ const pe = async (t, e, { country: s, language: l }) => {
|
|
|
964
964
|
"system.no_results_description": "We can't find any item matching your search.",
|
|
965
965
|
"system.clear_search": "Clear search",
|
|
966
966
|
"system.no_products_available": "No products available"
|
|
967
|
-
}),
|
|
967
|
+
}), pe = async (t, {
|
|
968
968
|
productId: e,
|
|
969
|
-
dealBlockId:
|
|
970
|
-
country:
|
|
971
|
-
language:
|
|
969
|
+
dealBlockId: l,
|
|
970
|
+
country: a,
|
|
971
|
+
language: i
|
|
972
972
|
}) => {
|
|
973
|
-
var r, c;
|
|
974
973
|
try {
|
|
975
|
-
const
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
974
|
+
const o = [Number(e.split("/").pop())], c = new A(
|
|
975
|
+
t.shopifyDomain,
|
|
976
|
+
t.storefrontAccessToken
|
|
977
|
+
), s = await L(c, {
|
|
978
|
+
language: i,
|
|
979
|
+
country: a,
|
|
980
980
|
useExternalMetafieldNamespace: !0
|
|
981
|
-
}),
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
) :
|
|
985
|
-
_(
|
|
986
|
-
country:
|
|
987
|
-
language:
|
|
988
|
-
productIds:
|
|
981
|
+
}), d = s.storefrontAccessToken ? new A(
|
|
982
|
+
s.shopifyDomain,
|
|
983
|
+
s.storefrontAccessToken
|
|
984
|
+
) : c, [p, m] = await Promise.all([
|
|
985
|
+
_(d, {
|
|
986
|
+
country: a,
|
|
987
|
+
language: i,
|
|
988
|
+
productIds: o,
|
|
989
989
|
useExternalMetafieldNamespace: !0
|
|
990
990
|
}),
|
|
991
|
-
|
|
991
|
+
q(d, {
|
|
992
992
|
useExternalMetafieldNamespace: !0,
|
|
993
|
-
useMetaobjects:
|
|
993
|
+
useMetaobjects: s.featureFlags.storefront_metaobjects
|
|
994
994
|
})
|
|
995
|
-
]),
|
|
996
|
-
if (!
|
|
995
|
+
]), n = p[0];
|
|
996
|
+
if (!n)
|
|
997
997
|
return null;
|
|
998
|
-
const
|
|
999
|
-
let
|
|
1000
|
-
if (
|
|
1001
|
-
(
|
|
1002
|
-
),
|
|
998
|
+
const u = R(m, n);
|
|
999
|
+
let r;
|
|
1000
|
+
if (l ? (r = u.find(
|
|
1001
|
+
(S) => S.id === l || S.nanoId === l
|
|
1002
|
+
), r || (r = u[0])) : r = u[0], !r)
|
|
1003
1003
|
return null;
|
|
1004
|
-
const
|
|
1005
|
-
_(
|
|
1006
|
-
country:
|
|
1007
|
-
language:
|
|
1008
|
-
productIds:
|
|
1004
|
+
const f = H(r), g = se(r), [h, b, y, I] = await Promise.all([
|
|
1005
|
+
_(d, {
|
|
1006
|
+
country: a,
|
|
1007
|
+
language: i,
|
|
1008
|
+
productIds: g,
|
|
1009
1009
|
useExternalMetafieldNamespace: !0
|
|
1010
1010
|
}),
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
country:
|
|
1014
|
-
language:
|
|
1011
|
+
V(d, f, 300),
|
|
1012
|
+
de(d, r, {
|
|
1013
|
+
country: a,
|
|
1014
|
+
language: i
|
|
1015
1015
|
}),
|
|
1016
|
-
|
|
1016
|
+
me()
|
|
1017
1017
|
]);
|
|
1018
1018
|
return {
|
|
1019
|
-
product:
|
|
1020
|
-
dealBlock:
|
|
1021
|
-
config:
|
|
1022
|
-
otherProducts:
|
|
1023
|
-
mediaImages:
|
|
1024
|
-
collectionBreaksProducts:
|
|
1025
|
-
translations:
|
|
1019
|
+
product: n,
|
|
1020
|
+
dealBlock: r,
|
|
1021
|
+
config: s,
|
|
1022
|
+
otherProducts: h,
|
|
1023
|
+
mediaImages: b,
|
|
1024
|
+
collectionBreaksProducts: y ?? [],
|
|
1025
|
+
translations: I
|
|
1026
1026
|
};
|
|
1027
|
-
} catch (
|
|
1028
|
-
return console.error(
|
|
1029
|
-
}
|
|
1030
|
-
};
|
|
1031
|
-
class be {
|
|
1032
|
-
constructor(e) {
|
|
1033
|
-
this.storefront = e;
|
|
1027
|
+
} catch (o) {
|
|
1028
|
+
return console.error(o), null;
|
|
1034
1029
|
}
|
|
1035
|
-
|
|
1036
|
-
if ("query" in this.storefront && "i18n" in this.storefront)
|
|
1037
|
-
return await this.storefront.query(e, s);
|
|
1038
|
-
if ("request" in this.storefront)
|
|
1039
|
-
return (await this.storefront.request(e, s)).data;
|
|
1040
|
-
if ("shopifyDomain" in this.storefront && "storefrontAccessToken" in this.storefront) {
|
|
1041
|
-
const l = await fetch(
|
|
1042
|
-
`https://${this.storefront.shopifyDomain}/api/${he}/graphql.json`,
|
|
1043
|
-
{
|
|
1044
|
-
body: JSON.stringify({
|
|
1045
|
-
query: e,
|
|
1046
|
-
variables: s == null ? void 0 : s.variables
|
|
1047
|
-
}),
|
|
1048
|
-
headers: {
|
|
1049
|
-
"Content-Type": "application/json",
|
|
1050
|
-
"X-Shopify-Storefront-Access-Token": this.storefront.storefrontAccessToken
|
|
1051
|
-
},
|
|
1052
|
-
method: "POST"
|
|
1053
|
-
}
|
|
1054
|
-
);
|
|
1055
|
-
if (!l.ok)
|
|
1056
|
-
throw new Error(l.statusText);
|
|
1057
|
-
return (await l.json()).data;
|
|
1058
|
-
} else {
|
|
1059
|
-
const l = await fetch(this.storefront.getStorefrontApiUrl(), {
|
|
1060
|
-
body: JSON.stringify({
|
|
1061
|
-
query: e,
|
|
1062
|
-
variables: s == null ? void 0 : s.variables
|
|
1063
|
-
}),
|
|
1064
|
-
headers: this.storefront.getPublicTokenHeaders(),
|
|
1065
|
-
method: "POST"
|
|
1066
|
-
});
|
|
1067
|
-
if (!l.ok)
|
|
1068
|
-
throw new Error(l.statusText);
|
|
1069
|
-
return (await l.json()).data;
|
|
1070
|
-
}
|
|
1071
|
-
}
|
|
1072
|
-
get i18n() {
|
|
1073
|
-
if ("i18n" in this.storefront)
|
|
1074
|
-
return this.storefront.i18n;
|
|
1075
|
-
}
|
|
1076
|
-
}
|
|
1077
|
-
const S = "kaching-bundles-block", A = 1e4, ye = "https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js", ve = "https://bundles-integrations.kachingappz.app/kaching-bundles-block.js", I = /* @__PURE__ */ new WeakSet(), D = async (t) => {
|
|
1030
|
+
}, k = "kaching-bundles-block", D = 1e4, fe = "https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js", ge = "https://bundles-integrations.kachingappz.app/kaching-bundles-block.js", v = /* @__PURE__ */ new WeakSet(), $ = async (t) => {
|
|
1078
1031
|
const e = t.document;
|
|
1079
|
-
if (!t.customElements.get(
|
|
1080
|
-
if (
|
|
1081
|
-
return
|
|
1082
|
-
|
|
1032
|
+
if (!t.customElements.get(k)) {
|
|
1033
|
+
if (v.has(e))
|
|
1034
|
+
return C(t, k);
|
|
1035
|
+
v.add(e);
|
|
1083
1036
|
try {
|
|
1084
|
-
await
|
|
1085
|
-
} catch (
|
|
1086
|
-
throw
|
|
1037
|
+
await ye(t);
|
|
1038
|
+
} catch (l) {
|
|
1039
|
+
throw v.delete(e), l;
|
|
1087
1040
|
}
|
|
1088
1041
|
}
|
|
1089
|
-
},
|
|
1042
|
+
}, he = () => typeof window < "u" && typeof window.__KACHING_DEV__ < "u", be = () => he() ? fe : ge, ye = (t) => {
|
|
1090
1043
|
const e = t.document;
|
|
1091
|
-
return new Promise((
|
|
1092
|
-
const
|
|
1044
|
+
return new Promise((l, a) => {
|
|
1045
|
+
const i = be();
|
|
1093
1046
|
if (e.querySelector(
|
|
1094
|
-
`script[src="${
|
|
1047
|
+
`script[src="${i}"]`
|
|
1095
1048
|
)) {
|
|
1096
|
-
|
|
1049
|
+
l();
|
|
1097
1050
|
return;
|
|
1098
1051
|
}
|
|
1099
1052
|
const c = e.createElement("script");
|
|
1100
|
-
c.src =
|
|
1053
|
+
c.src = i, c.onload = () => C(t, k).then(l).catch(a), c.onerror = () => a(new Error("Failed to load script")), e.head.appendChild(c);
|
|
1101
1054
|
});
|
|
1102
|
-
},
|
|
1055
|
+
}, C = (t, e) => new Promise((l, a) => {
|
|
1103
1056
|
if (t.customElements.get(e)) {
|
|
1104
|
-
|
|
1057
|
+
l();
|
|
1105
1058
|
return;
|
|
1106
1059
|
}
|
|
1107
1060
|
Promise.race([
|
|
1108
1061
|
t.customElements.whenDefined(e),
|
|
1109
1062
|
new Promise(
|
|
1110
|
-
(
|
|
1111
|
-
() =>
|
|
1063
|
+
(i, o) => setTimeout(
|
|
1064
|
+
() => o(
|
|
1112
1065
|
new Error(
|
|
1113
|
-
`Custom element "${e}" failed to register within ${
|
|
1066
|
+
`Custom element "${e}" failed to register within ${D}ms`
|
|
1114
1067
|
)
|
|
1115
1068
|
),
|
|
1116
|
-
|
|
1069
|
+
D
|
|
1117
1070
|
)
|
|
1118
1071
|
)
|
|
1119
|
-
]).then(() =>
|
|
1072
|
+
]).then(() => l()).catch(a);
|
|
1120
1073
|
});
|
|
1121
|
-
class
|
|
1074
|
+
class Ie extends HTMLElement {
|
|
1122
1075
|
constructor() {
|
|
1123
|
-
super(...arguments), this.innerElement = null, this.handleItemsChanged = null, this.
|
|
1076
|
+
super(...arguments), this.innerElement = null, this.handleItemsChanged = null, this.initializeId = 0;
|
|
1124
1077
|
}
|
|
1125
1078
|
static get observedAttributes() {
|
|
1126
1079
|
return ["selected-variant-id", "product-id"];
|
|
@@ -1129,79 +1082,80 @@ class Se extends HTMLElement {
|
|
|
1129
1082
|
await this.initialize();
|
|
1130
1083
|
}
|
|
1131
1084
|
async initialize() {
|
|
1132
|
-
var
|
|
1133
|
-
|
|
1134
|
-
|
|
1085
|
+
var c, s;
|
|
1086
|
+
const e = ++this.initializeId;
|
|
1087
|
+
if (this.cleanup(), this.hasAttribute("demo")) {
|
|
1088
|
+
if (await $(window), e !== this.initializeId) return;
|
|
1089
|
+
this.renderInnerElement(T);
|
|
1135
1090
|
return;
|
|
1136
1091
|
}
|
|
1137
|
-
const
|
|
1138
|
-
if (!
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
ge(
|
|
1092
|
+
const l = this.getAttribute("shop-domain"), a = this.getAttribute("storefront-token"), i = this.getAttribute("product-id");
|
|
1093
|
+
if (!l || !a || !i) return;
|
|
1094
|
+
const [o] = await Promise.all([
|
|
1095
|
+
pe(
|
|
1142
1096
|
{
|
|
1143
|
-
shopifyDomain:
|
|
1144
|
-
storefrontAccessToken:
|
|
1097
|
+
shopifyDomain: l,
|
|
1098
|
+
storefrontAccessToken: a
|
|
1145
1099
|
},
|
|
1146
1100
|
{
|
|
1147
|
-
productId:
|
|
1101
|
+
productId: i,
|
|
1148
1102
|
dealBlockId: this.getAttribute("deal-block-id") ?? void 0,
|
|
1149
|
-
country: ((
|
|
1150
|
-
language: ((
|
|
1103
|
+
country: ((c = this.getAttribute("country")) == null ? void 0 : c.toUpperCase()) ?? void 0,
|
|
1104
|
+
language: ((s = this.getAttribute("language")) == null ? void 0 : s.toUpperCase()) ?? void 0
|
|
1151
1105
|
}
|
|
1152
1106
|
),
|
|
1153
|
-
|
|
1107
|
+
$(window)
|
|
1154
1108
|
]);
|
|
1155
|
-
!
|
|
1109
|
+
!o || e !== this.initializeId || this.renderInnerElement(o);
|
|
1156
1110
|
}
|
|
1157
1111
|
renderInnerElement(e) {
|
|
1158
1112
|
const {
|
|
1159
|
-
config:
|
|
1160
|
-
dealBlock:
|
|
1161
|
-
product:
|
|
1162
|
-
otherProducts:
|
|
1113
|
+
config: l,
|
|
1114
|
+
dealBlock: a,
|
|
1115
|
+
product: i,
|
|
1116
|
+
otherProducts: o,
|
|
1163
1117
|
mediaImages: c,
|
|
1164
|
-
collectionBreaksProducts:
|
|
1165
|
-
translations:
|
|
1118
|
+
collectionBreaksProducts: s,
|
|
1119
|
+
translations: d
|
|
1166
1120
|
} = e;
|
|
1167
1121
|
this.innerElement = document.createElement(
|
|
1168
1122
|
"kaching-bundles-block"
|
|
1169
|
-
), this.innerElement.setAttribute("deal-block-id",
|
|
1123
|
+
), this.innerElement.setAttribute("deal-block-id", a.id), this.innerElement.setAttribute("config", JSON.stringify(l)), this.innerElement.setAttribute("deal-block", JSON.stringify(a)), this.innerElement.setAttribute(
|
|
1170
1124
|
"media-images",
|
|
1171
1125
|
JSON.stringify(c ?? [])
|
|
1172
|
-
), this.innerElement.setAttribute("product", JSON.stringify(
|
|
1126
|
+
), this.innerElement.setAttribute("product", JSON.stringify(i)), this.innerElement.setAttribute(
|
|
1173
1127
|
"other-products",
|
|
1174
|
-
JSON.stringify(
|
|
1128
|
+
JSON.stringify(o ?? [])
|
|
1175
1129
|
), this.innerElement.setAttribute(
|
|
1176
1130
|
"collection-breaks-products",
|
|
1177
|
-
JSON.stringify(
|
|
1131
|
+
JSON.stringify(s ?? [])
|
|
1178
1132
|
), this.innerElement.setAttribute(
|
|
1179
1133
|
"translations",
|
|
1180
|
-
JSON.stringify(
|
|
1134
|
+
JSON.stringify(d ?? {})
|
|
1181
1135
|
);
|
|
1182
1136
|
const p = this.getAttribute("selected-variant-id");
|
|
1183
1137
|
this.innerElement.setAttribute(
|
|
1184
1138
|
"current-variant-id",
|
|
1185
|
-
String(p ? p.split("/").pop() :
|
|
1139
|
+
String(p ? p.split("/").pop() : i.variants[0].id)
|
|
1186
1140
|
), this.appendChild(this.innerElement);
|
|
1187
|
-
const
|
|
1188
|
-
const
|
|
1189
|
-
|
|
1141
|
+
const m = () => {
|
|
1142
|
+
const n = this.innerElement.items();
|
|
1143
|
+
n && this.dispatchEvent(
|
|
1190
1144
|
new CustomEvent("items-changed", {
|
|
1191
|
-
detail: { items:
|
|
1145
|
+
detail: { items: n },
|
|
1192
1146
|
bubbles: !0
|
|
1193
1147
|
})
|
|
1194
1148
|
);
|
|
1195
1149
|
};
|
|
1196
|
-
this.handleItemsChanged = (
|
|
1197
|
-
|
|
1150
|
+
this.handleItemsChanged = (n) => {
|
|
1151
|
+
n.stopPropagation(), m();
|
|
1198
1152
|
}, this.innerElement.addEventListener(
|
|
1199
1153
|
"kaching-bundles-block-loaded",
|
|
1200
1154
|
() => {
|
|
1201
1155
|
this.innerElement.addEventListener(
|
|
1202
1156
|
"items-changed",
|
|
1203
1157
|
this.handleItemsChanged
|
|
1204
|
-
),
|
|
1158
|
+
), m(), this.dispatchEvent(new CustomEvent("loaded", { bubbles: !0 }));
|
|
1205
1159
|
},
|
|
1206
1160
|
{ once: !0 }
|
|
1207
1161
|
);
|
|
@@ -1212,17 +1166,17 @@ class Se extends HTMLElement {
|
|
|
1212
1166
|
this.handleItemsChanged
|
|
1213
1167
|
), this.handleItemsChanged = null), this.innerElement && (this.innerElement.remove(), this.innerElement = null);
|
|
1214
1168
|
}
|
|
1215
|
-
attributeChangedCallback(e,
|
|
1216
|
-
|
|
1169
|
+
attributeChangedCallback(e, l, a) {
|
|
1170
|
+
l !== a && (e === "product-id" ? this.initialize() : e === "selected-variant-id" && this.innerElement && a && this.innerElement.setAttribute(
|
|
1217
1171
|
"current-variant-id",
|
|
1218
|
-
|
|
1172
|
+
a.includes("/") ? String(a.split("/").pop()) : a
|
|
1219
1173
|
));
|
|
1220
1174
|
}
|
|
1221
1175
|
items() {
|
|
1222
1176
|
return this.innerElement ? this.innerElement.items() : [];
|
|
1223
1177
|
}
|
|
1224
1178
|
disconnectedCallback() {
|
|
1225
|
-
this.cleanup(), this.
|
|
1179
|
+
this.cleanup(), this.initializeId++;
|
|
1226
1180
|
}
|
|
1227
1181
|
}
|
|
1228
|
-
customElements.define("kaching-bundle-component",
|
|
1182
|
+
customElements.define("kaching-bundle-component", Ie);
|