@kachingappz/bundles-js 0.1.2 → 0.2.1

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.
@@ -1,4 +1,4 @@
1
- const G = {
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
- }, T = {
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
- }, q = {
244
+ }, T = {
245
245
  config: B,
246
- dealBlock: T,
247
- product: G,
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 s = [];
257
- return t && s.push(`country: ${t}`), e && s.push(`language: ${e}`), s.length > 0 ? `@inContext(${s.join(", ")})` : "";
258
- }, M = async (t, {
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: s
261
- }) => s ? j(
260
+ useMetaobjects: l
261
+ }) => l ? U(
262
262
  t
263
- ) : O(t), O = async (t, e) => {
264
- var l;
265
- const s = (l = (await t.query(
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 : l.value;
281
- return s ? JSON.parse(s) : [];
282
- }, j = async (t, e) => {
283
- const s = "app--2935586817--deal_block", l = [];
284
- let a = null;
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 r = await t.query(
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: s,
306
- cursor: a
305
+ type: l,
306
+ cursor: i
307
307
  }
308
308
  }
309
309
  );
310
- for (const c of r.metaobjects.nodes) {
311
- const n = c.fields.find(
312
- (m) => m.key === "settings"
310
+ for (const c of o.metaobjects.nodes) {
311
+ const s = c.fields.find(
312
+ (d) => d.key === "settings"
313
313
  );
314
- n != null && n.value && l.push(JSON.parse(n.value));
314
+ s != null && s.value && a.push(JSON.parse(s.value));
315
315
  }
316
- if (!r.metaobjects.pageInfo.hasNextPage)
316
+ if (!o.metaobjects.pageInfo.hasNextPage)
317
317
  break;
318
- a = r.metaobjects.pageInfo.endCursor;
318
+ i = o.metaobjects.pageInfo.endCursor;
319
319
  }
320
- return l;
321
- }, E = "app--2935586817", U = async (t, {
320
+ return a;
321
+ }, E = "app--2935586817", L = async (t, {
322
322
  language: e,
323
- country: s,
324
- useExternalMetafieldNamespace: l
323
+ country: l,
324
+ useExternalMetafieldNamespace: a
325
325
  }) => {
326
- const a = `${E}--kaching_bundles`, r = E, {
326
+ const i = `${E}--kaching_bundles`, o = E, {
327
327
  shop: {
328
328
  moneyFormat: c,
329
- currencyRateConstant: n,
330
- primaryDomain: m,
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: a,
353
- settingsNamespace: r
352
+ metafieldNamespace: i,
353
+ settingsNamespace: o
354
354
  }
355
355
  }
356
- ), u = n ? V(n.value) : 1, i = p ? JSON.parse(p.value) : null, d = (i == null ? void 0 : i.feature_flags) ?? {}, o = (i == null ? void 0 : i.custom_selectors) ?? {};
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: m.host,
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: s ?? "US",
363
- currencyRate: u,
362
+ country: l ?? "US",
363
+ currencyRate: m,
364
364
  marketId: 0,
365
365
  productId: null,
366
- storefrontAccessToken: (i == null ? void 0 : i.storefront_access_token) ?? null,
367
- accessScopes: (i == null ? void 0 : i.access_scopes) ?? [],
368
- customApiHost: (i == null ? void 0 : i.custom_api_host) ?? null,
369
- keepQuantityInput: (i == null ? void 0 : i.keep_quantity_input) ?? !1,
370
- ignoreDeselect: (i == null ? void 0 : i.ignore_deselect) ?? !1,
371
- ignoreUnitPrice: (i == null ? void 0 : i.ignore_unit_price) ?? !1,
372
- requireCustomerLogin: (i == null ? void 0 : i.require_customer_login) ?? !1,
373
- abTestsRunning: (i == null ? void 0 : i.ab_tests_running) ?? !1,
374
- webPixel: (i == null ? void 0 : i.web_pixel) ?? !1,
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: o.quantity ?? null,
399
- addToCartButton: o.add_to_cart_button ?? null,
400
- variantPicker: o.variant_picker ?? null,
401
- price: o.price ?? null,
402
- priceCompare: o.price_compare ?? null
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: (i == null ? void 0 : i.shop_custom_styles) ?? "",
405
- featureFlags: d
404
+ shopCustomStyles: (n == null ? void 0 : n.shop_custom_styles) ?? "",
405
+ featureFlags: u
406
406
  };
407
- }, V = (t) => JSON.parse(t).amount / 1e6, L = async (t, e, s = 200) => (e = e.filter(Boolean).filter((l) => !l.startsWith("placeholder")), e.length === 0 ? [] : (await t.query(
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: s
423
+ size: l
424
424
  }
425
425
  }
426
- )).nodes.filter(Boolean).map((l) => ({
427
- gid: l.id,
428
- url: l.image.url
429
- }))), w = async (t, {
426
+ )).nodes.filter(Boolean).map((a) => ({
427
+ gid: a.id,
428
+ url: a.image.url
429
+ }))), A = async (t, {
430
430
  country: e,
431
- language: s,
432
- blockVisibility: l,
433
- excludedProductGIDs: a,
434
- selectedProductGIDs: r,
431
+ language: l,
432
+ blockVisibility: a,
433
+ excludedProductGIDs: i,
434
+ selectedProductGIDs: o,
435
435
  selectedCollectionGIDs: c,
436
- limit: n = 250
436
+ limit: s = 250
437
437
  }) => {
438
- switch (l) {
438
+ switch (a) {
439
439
  case "selected-products":
440
- return r.slice(0, n);
440
+ return o.slice(0, s);
441
441
  case "all-products":
442
442
  case "excluded-products": {
443
- const m = P({ country: e, language: s });
443
+ const d = P({ country: e, language: l });
444
444
  let p = (await t.query(
445
445
  `
446
- query FetchProductGIDs($limit: Int!) ${m} {
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: n
456
+ limit: s
457
457
  }
458
458
  }
459
- )).products.nodes.map((u) => u.id);
460
- return l === "excluded-products" && (p = p.filter(
461
- (u) => !a.includes(u)
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 m = P({ country: e, language: s }), p = (await t.query(
465
+ const d = P({ country: e, language: l }), p = (await t.query(
466
466
  `
467
- query FetchCollectionProductGIDs($collectionGIDs: [ID!]!, $limit: Int!) ${m} {
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: n
482
+ limit: s
483
483
  }
484
484
  }
485
- )).nodes.filter((u) => u !== null).flatMap(
486
- (u) => u.products.nodes.map((i) => i.id)
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, n);
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: s,
531
- productIds: l,
532
- includeSellingPlans: a = !0,
533
- includeAvailableQuantity: r = !0,
530
+ language: l,
531
+ productIds: a,
532
+ includeSellingPlans: i = !0,
533
+ includeAvailableQuantity: o = !0,
534
534
  useExternalMetafieldNamespace: c = !1
535
535
  }) => {
536
- if (!l.length)
536
+ if (!a.length)
537
537
  return [];
538
- const n = l.map((u) => typeof u == "string" && u.startsWith("gid://") ? u : `gid://shopify/Product/${u}`), m = P({ country: e, language: s });
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!) ${m} {
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: n,
626
- includeSellingPlans: a,
627
- includeAvailableQuantity: r,
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
- (u) => u != null
632
+ (m) => m != null
633
633
  );
634
634
  return p = await Promise.all(
635
635
  p.map(
636
- (u) => F(t, u, {
637
- includeSellingPlans: a,
638
- includeAvailableQuantity: r
636
+ (m) => F(t, m, {
637
+ includeSellingPlans: i,
638
+ includeAvailableQuantity: o
639
639
  })
640
640
  )
641
- ), p.map(R);
642
- }, F = async (t, e, s) => {
641
+ ), p.map(j);
642
+ }, F = async (t, e, l) => {
643
643
  if (e.variants.nodes.length < 250)
644
644
  return e;
645
- const l = /* @__PURE__ */ new Set(), a = [], r = [], c = async (n) => {
646
- let m = !0, p = null;
647
- for (; m; ) {
648
- const u = await t.query(
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: n,
669
- ...s
668
+ reverse: s,
669
+ ...l
670
670
  }
671
671
  }
672
- ), { nodes: i, pageInfo: d } = u.product.variants;
673
- for (const o of i) {
674
- if (l.has(o.id)) {
675
- m = !1;
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
- l.add(o.id), n ? r.push(o) : a.push(o);
678
+ a.add(r.id), s ? o.push(r) : i.push(r);
679
679
  }
680
- d.hasNextPage || (m = !1), p = d.endCursor;
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 = [...a, ...r.reverse()], e;
687
- }, R = (t) => {
688
- var c, n, m, p, u, i;
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: d, ...o }) => {
691
- var h, f;
690
+ ({ unitPriceMeasurement: u, ...r }) => {
691
+ var f, g;
692
692
  return {
693
- id: Number(o.id.split("/").pop()),
694
- availableForSale: o.availableForSale,
695
- price: Math.round(Number(o.price.amount) * 100),
696
- compareAtPrice: o.compareAtPrice ? Math.round(Number(o.compareAtPrice.amount) * 100) : null,
697
- options: o.selectedOptions.map((g) => g.value),
698
- imageId: o.image ? Number(o.image.id.split("/").pop()) : null,
699
- image: ((h = o.image) == null ? void 0 : h.url) || null,
700
- sellingPlans: ((f = o.sellingPlanAllocations) == null ? void 0 : f.nodes.map((g) => ({
701
- id: Number(g.sellingPlan.id.split("/").pop()),
702
- price: g.priceAdjustments.length > 0 ? Math.round(Number(g.priceAdjustments[0].price.amount) * 100) : Math.round(Number(o.price.amount) * 100)
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: o.quantityAvailable ?? null,
709
- unitPriceMeasurement: d != null && d.quantityUnit && (d != null && d.referenceUnit) ? {
710
- quantityValue: d.quantityValue,
711
- quantityUnit: d.quantityUnit.toLowerCase(),
712
- referenceValue: d.referenceValue,
713
- referenceUnit: d.referenceUnit.toLowerCase()
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
- ), s = t.options.map((d, o) => {
718
- const h = d.optionValues.map((f) => {
719
- var g, b, y, v;
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(f.id.split("/").pop()),
722
- defaultName: f.name,
723
- name: f.name,
721
+ id: Number(g.id.split("/").pop()),
722
+ defaultName: g.name,
723
+ name: g.name,
724
724
  swatch: {
725
- color: ((g = f.swatch) == null ? void 0 : g.color) || null,
726
- image: ((v = (y = (b = f.swatch) == null ? void 0 : b.image) == null ? void 0 : y.previewImage) == null ? void 0 : v.url) || null
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: d.name,
732
- name: d.name,
733
- position: o + 1,
734
- optionValues: z(h, o, e)
731
+ defaultName: u.name,
732
+ name: u.name,
733
+ position: r + 1,
734
+ optionValues: z(f, r, e)
735
735
  };
736
- }), l = (d) => {
737
- const o = d.priceAdjustments[0];
738
- if (!o)
736
+ }), a = (u) => {
737
+ const r = u.priceAdjustments[0];
738
+ if (!r)
739
739
  return null;
740
- const h = o.adjustmentValue;
741
- switch (h.__typename) {
740
+ const f = r.adjustmentValue;
741
+ switch (f.__typename) {
742
742
  case "SellingPlanPercentagePriceAdjustment":
743
743
  return {
744
744
  type: "percentage",
745
- value: h.adjustmentPercentage
745
+ value: f.adjustmentPercentage
746
746
  };
747
747
  case "SellingPlanFixedAmountPriceAdjustment":
748
748
  return {
749
749
  type: "fixed_amount",
750
- value: Number(h.adjustmentAmount.amount) * 100
750
+ value: Number(f.adjustmentAmount.amount) * 100
751
751
  };
752
752
  case "SellingPlanFixedPriceAdjustment":
753
753
  return {
754
754
  type: "price",
755
- value: Number(h.price.amount) * 100
755
+ value: Number(f.price.amount) * 100
756
756
  };
757
757
  default:
758
758
  throw new Error(
759
- `Unknown price adjustment type: ${h.__typename}`
759
+ `Unknown price adjustment type: ${f.__typename}`
760
760
  );
761
761
  }
762
- }, a = ((c = t.sellingPlanGroups) == null ? void 0 : c.nodes.flatMap(
763
- (d) => d.sellingPlans.nodes.map((o) => ({
764
- id: Number(o.id.split("/").pop()),
765
- name: o.name,
766
- priceAdjustment: l(o)
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
- )) || [], r = t.variants.nodes.some(
769
- (d) => d.requiresComponents
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: ((n = t.featuredImage) == null ? void 0 : n.url) || null,
778
+ image: ((s = t.featuredImage) == null ? void 0 : s.url) || null,
779
779
  collectionIds: t.collections.nodes.map(
780
- (d) => Number(d.id.split("/").pop())
780
+ (u) => Number(u.id.split("/").pop())
781
781
  ),
782
- options: s,
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: a,
789
- isNativeBundle: r,
788
+ sellingPlans: i,
789
+ isNativeBundle: o,
790
790
  metafields: {
791
- text: ((m = t.metafield) == null ? void 0 : m.value) || null,
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: ((u = t.metafield3) == null ? void 0 : u.value) || null,
794
- text4: ((i = t.metafield4) == null ? void 0 : i.value) || null
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, s) => t.filter((l) => s.filter(
798
- (a) => a.options[e] === l.name
799
- ).length > 0), H = (t, e) => {
800
- const s = [], l = t.filter(
801
- (n) => n.blockVisibility === "selected-products"
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 n of l)
804
- n.selectedProductIds.map(Number).includes(e.id) && s.push(n);
805
- const a = t.filter(
806
- (n) => n.blockVisibility === "selected-collections"
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 n of a)
808
+ for (const s of i)
809
809
  e.collectionIds.some(
810
- (m) => n.selectedCollectionIds.map(Number).includes(m)
811
- ) && s.push(n);
812
- const r = t.filter(
813
- (n) => n.blockVisibility === "excluded-products"
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 n of r)
816
- !n.excludedProductIds.map(Number).includes(e.id) && !(n.excludedCollectionIds || []).some(
817
- (m) => e.collectionIds.includes(m)
818
- ) && s.push(n);
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
- (n) => n.blockVisibility === "all-products"
820
+ (s) => s.blockVisibility === "all-products"
821
821
  );
822
- for (const n of c)
823
- s.push(n);
824
- return s;
825
- }, J = (t) => [
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")), Q = (t) => t.dealBars.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), W = (t) => t.dealBars.map(
837
- ({ freeGifts: e }) => (e || []).map((s) => s.mediaImageGID)
838
- ).reduce((e, s) => e.concat(s), []).filter((e) => e != null), X = (t) => t.dealBars.flatMap(
839
- ({ multipleGiftsSelectors: e }) => (e || []).map((s) => s.mediaImageGID)
840
- ).filter((e) => e != null), K = (t) => t.dealBars.map(({ upsells: e }) => (e || []).map((s) => s.mediaImageGID)).reduce((e, s) => e.concat(s), []).filter((e) => e != null), Y = (t) => t.swatchOptions ? t.swatchOptions.reduce((e, s) => {
841
- const l = s.images.map((a) => a.mediaImageGID).filter((a) => a != null);
842
- return [...e, ...l];
843
- }, []) : [], Z = (t) => {
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
- }, ee = (t) => {
849
- var e, s, l;
848
+ }, Z = (t) => {
849
+ var e, l, a;
850
850
  return t.progressiveGifts ? [
851
- ...((e = t.progressiveGifts.gifts) == null ? void 0 : e.map((a) => a.mediaImageGID)) || [],
852
- (s = t.progressiveGifts.style) == null ? void 0 : s.lockedMediaImageGID,
853
- (l = t.progressiveGifts.dealBarStyle) == null ? void 0 : l.lockedMediaImageGID
854
- ].filter((a) => a != null) : [];
855
- }, te = (t) => !t.checkboxUpsellsEnabled || !t.checkboxUpsells ? [] : t.checkboxUpsells.upsells.map((e) => e.mediaImageGID).filter((e) => e != null), se = (t) => t.dealBars.map((e) => {
856
- var s;
857
- return (s = e.productPersonalisation) == null ? void 0 : s.mediaImageGID;
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 s;
860
- return (s = e.highlights) == null ? void 0 : s.customIconGID;
861
- }).filter((e) => e != null), ne = (t) => {
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((s) => s != null)));
871
+ return Array.from(new Set(e.filter((l) => l != null)));
872
872
  }, ae = (t) => t.dealBars.flatMap(
873
- ({ freeGifts: e }) => e ? e.map((s) => s.productGID) : []
874
- ).filter((e) => e != null), ie = (t) => t.dealBars.flatMap(
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
- (s) => s.products ? s.products.map((l) => l.id) : []
876
+ (l) => l.products ? l.products.map((a) => a.id) : []
877
877
  ) : []
878
- ).filter((e) => e != null), re = (t) => {
878
+ ).filter((e) => e != null), ie = (t) => {
879
879
  var e;
880
- return t.progressiveGiftsEnabled ? ((e = t.progressiveGifts) == null ? void 0 : e.gifts.map((s) => s.productGID).filter((s) => s != null)) || [] : [];
881
- }, oe = (t) => t.dealBars.flatMap(({ upsells: e }) => e ? e.map((s) => s.productGID) : []).filter((e) => e != null), ce = (t) => t.dealBars.filter((e) => e.dealBarType === "bundle").flatMap(
882
- ({ bundleProducts: e }) => e ? e.map((s) => s.productGID) : []
883
- ).filter((e) => e != null).filter((e) => e !== "default"), ue = (t) => !t.checkboxUpsellsEnabled || !t.checkboxUpsells ? [] : t.checkboxUpsells.upsells.map((e) => e.productGID).filter((e) => e != null), de = (t) => t.dealBars.filter((e) => e.dealBarType === "sku").flatMap(({ productGID: e }) => e ? [e] : []);
884
- class me {
885
- constructor(e, s) {
886
- this.storefrontApiVersion = "2025-10", this.storefrontAccessToken = s, this.shopifyDomain = e;
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 w {
885
+ constructor(e, l) {
886
+ this.storefrontApiVersion = "2025-10", this.storefrontAccessToken = l, this.shopifyDomain = e;
887
887
  }
888
- async query(e, s) {
889
- var n;
890
- const l = (s == null ? void 0 : s.variables) ?? {};
891
- let a = `https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`;
892
- const r = (n = e.match(/query\s+(\w+)/)) == null ? void 0 : n[1];
893
- r && (a += `?operation_name=${r}`);
894
- const c = await (await fetch(a, {
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: l
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 pe = async (t, e, { country: s, language: l }) => {
911
- const a = e.collectionBreaks;
912
- if (!e.collectionBreaksEnabled || !a) return;
913
- let r;
914
- a.visibility === "deal-products" ? r = await w(t, {
915
- country: s,
916
- language: l,
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 A(t, {
915
+ country: l,
916
+ language: a,
917
917
  blockVisibility: e.blockVisibility,
918
918
  excludedProductGIDs: (e.excludedProductIds || []).map(
919
- (n) => `gid://shopify/Product/${n}`
919
+ (s) => `gid://shopify/Product/${s}`
920
920
  ),
921
921
  selectedProductGIDs: (e.selectedProductIds || []).map(
922
- (n) => `gid://shopify/Product/${n}`
922
+ (s) => `gid://shopify/Product/${s}`
923
923
  ),
924
924
  selectedCollectionGIDs: (e.selectedCollectionIds || []).map(
925
- (n) => `gid://shopify/Collection/${n}`
925
+ (s) => `gid://shopify/Collection/${s}`
926
926
  )
927
- }) : r = await w(t, {
928
- country: s,
929
- language: l,
930
- blockVisibility: a.visibility,
931
- excludedProductGIDs: (a.excludedProducts || []).map(
932
- ({ id: n }) => n
927
+ }) : o = await A(t, {
928
+ country: l,
929
+ language: a,
930
+ blockVisibility: i.visibility,
931
+ excludedProductGIDs: (i.excludedProducts || []).map(
932
+ ({ id: s }) => s
933
933
  ),
934
- selectedProductGIDs: (a.selectedProducts || []).map(
935
- ({ id: n }) => n
934
+ selectedProductGIDs: (i.selectedProducts || []).map(
935
+ ({ id: s }) => s
936
936
  ),
937
- selectedCollectionGIDs: (a.selectedCollections || []).map(
938
- ({ id: n }) => n
937
+ selectedCollectionGIDs: (i.selectedCollections || []).map(
938
+ ({ id: s }) => s
939
939
  )
940
- }), r = r.slice(0, 250);
940
+ }), o = o.slice(0, 250);
941
941
  let c = await _(t, {
942
- country: s,
943
- language: l,
944
- productIds: r.map((n) => Number(n.split("/").pop())),
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
- (n) => n.availableForSale
948
+ (s) => s.availableForSale
949
949
  ), c;
950
- }, fe = () => ({
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
- }), he = "2025-10", ge = async (t, {
967
+ }), pe = async (t, {
968
968
  productId: e,
969
- dealBlockId: s,
970
- country: l = void 0,
971
- language: a = void 0
969
+ dealBlockId: l,
970
+ country: a,
971
+ language: i
972
972
  }) => {
973
- var r, c;
974
973
  try {
975
- const n = [Number(e.split("/").pop())], m = new be(t);
976
- l = l || ((r = m.i18n) == null ? void 0 : r.country), a = a || ((c = m.i18n) == null ? void 0 : c.language);
977
- const p = await U(m, {
978
- language: a,
979
- country: l,
974
+ const o = [Number(e.split("/").pop())], c = new w(
975
+ t.shopifyDomain,
976
+ t.storefrontAccessToken
977
+ ), s = await L(c, {
978
+ language: i,
979
+ country: a,
980
980
  useExternalMetafieldNamespace: !0
981
- }), u = p.storefrontAccessToken ? new me(
982
- p.shopifyDomain,
983
- p.storefrontAccessToken
984
- ) : m, [i, d] = await Promise.all([
985
- _(u, {
986
- country: l,
987
- language: a,
988
- productIds: n,
981
+ }), d = s.storefrontAccessToken ? new w(
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
- M(u, {
991
+ q(d, {
992
992
  useExternalMetafieldNamespace: !0,
993
- useMetaobjects: p.featureFlags.storefront_metaobjects
993
+ useMetaobjects: s.featureFlags.storefront_metaobjects
994
994
  })
995
- ]), o = i[0];
996
- if (!o)
995
+ ]), n = p[0];
996
+ if (!n)
997
997
  return null;
998
- const h = H(d, o);
999
- let f;
1000
- if (s ? (f = h.find(
1001
- (k) => k.id === s || k.nanoId === s
1002
- ), f || (f = h[0])) : f = h[0], !f)
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 g = J(f), b = ne(f), [y, v, x, C] = await Promise.all([
1005
- _(u, {
1006
- country: l,
1007
- language: a,
1008
- productIds: b,
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
- L(u, g, 300),
1012
- pe(u, f, {
1013
- country: l,
1014
- language: a
1011
+ V(d, f, 300),
1012
+ de(d, r, {
1013
+ country: a,
1014
+ language: i
1015
1015
  }),
1016
- fe()
1016
+ me()
1017
1017
  ]);
1018
1018
  return {
1019
- product: o,
1020
- dealBlock: f,
1021
- config: p,
1022
- otherProducts: y,
1023
- mediaImages: v,
1024
- collectionBreaksProducts: x ?? [],
1025
- translations: C
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 (n) {
1028
- return console.error(n), null;
1029
- }
1030
- };
1031
- class be {
1032
- constructor(e) {
1033
- this.storefront = e;
1027
+ } catch (o) {
1028
+ return console.error(o), null;
1034
1029
  }
1035
- async query(e, s) {
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(S)) {
1080
- if (I.has(e))
1081
- return N(t, S);
1082
- I.add(e);
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 _e(t);
1085
- } catch (s) {
1086
- throw I.delete(e), s;
1037
+ await ye(t);
1038
+ } catch (l) {
1039
+ throw v.delete(e), l;
1087
1040
  }
1088
1041
  }
1089
- }, Ie = () => typeof window < "u" && typeof window.__KACHING_DEV__ < "u", Pe = () => Ie() ? ye : ve, _e = (t) => {
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((s, l) => {
1092
- const a = Pe();
1044
+ return new Promise((l, a) => {
1045
+ const i = be();
1093
1046
  if (e.querySelector(
1094
- `script[src="${a}"]`
1047
+ `script[src="${i}"]`
1095
1048
  )) {
1096
- s();
1049
+ l();
1097
1050
  return;
1098
1051
  }
1099
1052
  const c = e.createElement("script");
1100
- c.src = a, c.onload = () => N(t, S).then(s).catch(l), c.onerror = () => l(new Error("Failed to load script")), e.head.appendChild(c);
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
- }, N = (t, e) => new Promise((s, l) => {
1055
+ }, C = (t, e) => new Promise((l, a) => {
1103
1056
  if (t.customElements.get(e)) {
1104
- s();
1057
+ l();
1105
1058
  return;
1106
1059
  }
1107
1060
  Promise.race([
1108
1061
  t.customElements.whenDefined(e),
1109
1062
  new Promise(
1110
- (a, r) => setTimeout(
1111
- () => r(
1063
+ (i, o) => setTimeout(
1064
+ () => o(
1112
1065
  new Error(
1113
- `Custom element "${e}" failed to register within ${A}ms`
1066
+ `Custom element "${e}" failed to register within ${D}ms`
1114
1067
  )
1115
1068
  ),
1116
- A
1069
+ D
1117
1070
  )
1118
1071
  )
1119
- ]).then(() => s()).catch(l);
1072
+ ]).then(() => l()).catch(a);
1120
1073
  });
1121
- class Se extends HTMLElement {
1074
+ class Ie extends HTMLElement {
1122
1075
  constructor() {
1123
- super(...arguments), this.innerElement = null, this.handleItemsChanged = null, this.currentProductId = null;
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 r, c;
1133
- if (this.hasAttribute("demo")) {
1134
- this.cleanup(), await D(window), this.renderInnerElement(q);
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 e = this.getAttribute("shop-domain"), s = this.getAttribute("storefront-token"), l = this.getAttribute("product-id");
1138
- if (!e || !s || !l || l === this.currentProductId) return;
1139
- this.currentProductId = l, this.cleanup();
1140
- const [a] = await Promise.all([
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: e,
1144
- storefrontAccessToken: s
1097
+ shopifyDomain: l,
1098
+ storefrontAccessToken: a
1145
1099
  },
1146
1100
  {
1147
- productId: l,
1101
+ productId: i,
1148
1102
  dealBlockId: this.getAttribute("deal-block-id") ?? void 0,
1149
- country: ((r = this.getAttribute("country")) == null ? void 0 : r.toUpperCase()) ?? void 0,
1150
- language: ((c = this.getAttribute("language")) == null ? void 0 : c.toUpperCase()) ?? void 0
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
- D(window)
1107
+ $(window)
1154
1108
  ]);
1155
- !a || l !== this.currentProductId || this.renderInnerElement(a);
1109
+ !o || e !== this.initializeId || this.renderInnerElement(o);
1156
1110
  }
1157
1111
  renderInnerElement(e) {
1158
1112
  const {
1159
- config: s,
1160
- dealBlock: l,
1161
- product: a,
1162
- otherProducts: r,
1113
+ config: l,
1114
+ dealBlock: a,
1115
+ product: i,
1116
+ otherProducts: o,
1163
1117
  mediaImages: c,
1164
- collectionBreaksProducts: n,
1165
- translations: m
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", l.id), this.innerElement.setAttribute("config", JSON.stringify(s)), this.innerElement.setAttribute("deal-block", JSON.stringify(l)), this.innerElement.setAttribute(
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(a)), this.innerElement.setAttribute(
1126
+ ), this.innerElement.setAttribute("product", JSON.stringify(i)), this.innerElement.setAttribute(
1173
1127
  "other-products",
1174
- JSON.stringify(r ?? [])
1128
+ JSON.stringify(o ?? [])
1175
1129
  ), this.innerElement.setAttribute(
1176
1130
  "collection-breaks-products",
1177
- JSON.stringify(n ?? [])
1131
+ JSON.stringify(s ?? [])
1178
1132
  ), this.innerElement.setAttribute(
1179
1133
  "translations",
1180
- JSON.stringify(m ?? {})
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() : a.variants[0].id)
1186
- ), this.appendChild(this.innerElement);
1187
- const u = () => {
1188
- const i = this.innerElement.items();
1189
- i && this.dispatchEvent(
1139
+ String(p ? p.split("/").pop() : i.variants[0].id)
1140
+ ), this.hasAttribute("deal-bars-only") && this.innerElement.setAttribute("deal-bars-only", ""), this.appendChild(this.innerElement);
1141
+ const m = () => {
1142
+ const n = this.innerElement.items();
1143
+ n && this.dispatchEvent(
1190
1144
  new CustomEvent("items-changed", {
1191
- detail: { items: i },
1145
+ detail: { items: n },
1192
1146
  bubbles: !0
1193
1147
  })
1194
1148
  );
1195
1149
  };
1196
- this.handleItemsChanged = (i) => {
1197
- i.stopPropagation(), u();
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
- ), u(), this.dispatchEvent(new CustomEvent("loaded", { bubbles: !0 }));
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, s, l) {
1216
- s !== l && (e === "product-id" ? this.initialize() : e === "selected-variant-id" && this.innerElement && l && this.innerElement.setAttribute(
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
- l.includes("/") ? String(l.split("/").pop()) : l
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.currentProductId = null;
1179
+ this.cleanup(), this.initializeId++;
1226
1180
  }
1227
1181
  }
1228
- customElements.define("kaching-bundle-component", Se);
1182
+ customElements.define("kaching-bundle-component", Ie);