@kachingappz/bundles-js 1.1.8 → 1.1.9

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.
@@ -105,16 +105,16 @@ var d = /* @__PURE__ */ function(e) {
105
105
  return Array.from(new Set(i)).slice(0, c);
106
106
  }
107
107
  }
108
- }, p = "\n id\n availableForSale\n price {\n amount\n }\n compareAtPrice {\n amount\n }\n selectedOptions {\n name\n value\n }\n image {\n id\n url(transform: $variantImageTransform)\n }\n unitPriceMeasurement {\n quantityUnit\n quantityValue\n referenceUnit\n referenceValue\n }\n requiresComponents\n sellingPlanAllocations(first: 100) @include(if: $includeSellingPlans) {\n nodes {\n sellingPlan {\n id\n }\n priceAdjustments {\n price {\n amount\n }\n compareAtPrice {\n amount\n }\n perDeliveryPrice {\n amount\n }\n }\n }\n }\n quantityAvailable @include(if: $includeAvailableQuantity)\n", m = async (e, { country: t, language: n, productIds: r, includeSellingPlans: i = !0, includeAvailableQuantity: a = !0, includeProductRating: o = !1, includeProductSubtitle: c = !1, productSubtitleMetafield: l = "descriptors.subtitle", useExternalMetafieldNamespace: u = !1, batchSize: d = 250, onBatchError: f, variantImageTransform: m = {
108
+ }, p = "\n id\n availableForSale\n price {\n amount\n }\n compareAtPrice {\n amount\n }\n selectedOptions {\n name\n value\n }\n image {\n id\n url(transform: $variantImageTransform)\n }\n unitPriceMeasurement {\n quantityUnit\n quantityValue\n referenceUnit\n referenceValue\n }\n requiresComponents\n sellingPlanAllocations(first: 100) @include(if: $includeSellingPlans) {\n nodes {\n sellingPlan {\n id\n }\n priceAdjustments {\n price {\n amount\n }\n compareAtPrice {\n amount\n }\n perDeliveryPrice {\n amount\n }\n }\n }\n }\n quantityAvailable @include(if: $includeAvailableQuantity)\n", m = async (e, { country: t, language: n, productIds: r, includeSellingPlans: i = !0, includeAvailableQuantity: a = !0, includeProductRating: o = !1, includeProductSubtitle: c = !1, includeProductTabFields: l = !1, productSubtitleMetafield: u = "descriptors.subtitle", useExternalMetafieldNamespace: d = !1, batchSize: f = 250, onBatchError: m, variantImageTransform: v = {
109
109
  maxWidth: 200,
110
110
  maxHeight: 200
111
111
  } }) => {
112
112
  if (!r.length) return [];
113
- let _ = r.map((e) => typeof e == "string" && e.startsWith("gid://") ? e : `gid://shopify/Product/${e}`), v = s({
113
+ let y = r.map((e) => typeof e == "string" && e.startsWith("gid://") ? e : `gid://shopify/Product/${e}`), b = s({
114
114
  country: t,
115
115
  language: n
116
- }), y = `
117
- query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $includeProductRating: Boolean!, $includeProductSubtitle: Boolean!, $subtitleNamespace: String!, $subtitleKey: String!, $metafieldNamespace: String!, $variantImageTransform: ImageTransformInput) ${v} {
116
+ }), x = `
117
+ query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $includeProductRating: Boolean!, $includeProductSubtitle: Boolean!, $includeProductTabFields: Boolean!, $subtitleNamespace: String!, $subtitleKey: String!, $metafieldNamespace: String!, $variantImageTransform: ImageTransformInput) ${b} {
118
118
  shop {
119
119
  currencyRateConstant: metafield(namespace: $metafieldNamespace, key: "currency_rate_constant") {
120
120
  value
@@ -177,6 +177,10 @@ var d = /* @__PURE__ */ function(e) {
177
177
  subtitle: metafield(namespace: $subtitleNamespace, key: $subtitleKey) @include(if: $includeProductSubtitle) {
178
178
  value
179
179
  }
180
+ category @include(if: $includeProductTabFields) {
181
+ id
182
+ }
183
+ tags @include(if: $includeProductTabFields)
180
184
  requiresSellingPlan
181
185
  sellingPlanGroups(first: 100) @include(if: $includeSellingPlans) {
182
186
  nodes {
@@ -184,6 +188,7 @@ var d = /* @__PURE__ */ function(e) {
184
188
  nodes {
185
189
  id
186
190
  name
191
+ recurringDeliveries
187
192
  priceAdjustments {
188
193
  adjustmentValue {
189
194
  __typename
@@ -209,43 +214,63 @@ var d = /* @__PURE__ */ function(e) {
209
214
  }
210
215
  }
211
216
  }
212
- `, b = u ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles", x = l.indexOf("."), S = l.slice(0, x), C = l.slice(x + 1), w = [], T = Math.min(d, 250);
213
- for (let e = 0; e < _.length; e += T) w.push(_.slice(e, e + T));
214
- let E = 1, D = async (t) => {
215
- let n = await e.query(y, { variables: {
216
- productGIDs: t,
217
+ `, S = d ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles", C = u.indexOf("."), w = u.slice(0, C), T = u.slice(C + 1), E = [], D = Math.min(f, 250);
218
+ for (let e = 0; e < y.length; e += D) E.push(y.slice(e, e + D));
219
+ let O = 1, k = async (n) => {
220
+ let [r, s] = await Promise.all([e.query(x, { variables: {
221
+ productGIDs: n,
217
222
  includeSellingPlans: i,
218
223
  includeAvailableQuantity: a,
219
224
  includeProductRating: o,
220
225
  includeProductSubtitle: c,
221
- subtitleNamespace: S,
222
- subtitleKey: C,
223
- metafieldNamespace: b,
224
- variantImageTransform: m
225
- } });
226
- return n.shop.currencyRateConstant && (E = JSON.parse(n.shop.currencyRateConstant.value).amount / 1e6), n;
227
- }, O;
228
- if (f) {
229
- let e = await Promise.allSettled(w.map(D));
230
- for (let t of e) t.status === "rejected" && f(t.reason instanceof Error ? t.reason : Error(String(t.reason)));
231
- O = e.filter((e) => e.status === "fulfilled").flatMap((e) => e.value.nodes);
232
- } else O = (await Promise.all(w.map(D))).flatMap((e) => e.nodes);
233
- let k = O.filter((e) => e != null);
234
- if (f) {
235
- let t = await Promise.allSettled(k.map(async (t) => g(await h(e, t, {
226
+ includeProductTabFields: l,
227
+ subtitleNamespace: w,
228
+ subtitleKey: T,
229
+ metafieldNamespace: S,
230
+ variantImageTransform: v
231
+ } }), l ? h(e, t, n) : null]);
232
+ return r.shop.currencyRateConstant && (O = JSON.parse(r.shop.currencyRateConstant.value).amount / 1e6), s ? { nodes: r.nodes.map((e) => e && {
233
+ ...e,
234
+ productType: s.get(e.id)
235
+ }) } : r;
236
+ }, A;
237
+ if (m) {
238
+ let e = await Promise.allSettled(E.map(k));
239
+ for (let t of e) t.status === "rejected" && m(t.reason instanceof Error ? t.reason : Error(String(t.reason)));
240
+ A = e.filter((e) => e.status === "fulfilled").flatMap((e) => e.value.nodes);
241
+ } else A = (await Promise.all(E.map(k))).flatMap((e) => e.nodes);
242
+ let j = A.filter((e) => e != null);
243
+ if (m) {
244
+ let t = await Promise.allSettled(j.map(async (t) => _(await g(e, t, {
236
245
  includeSellingPlans: i,
237
246
  includeAvailableQuantity: a,
238
- variantImageTransform: m
239
- }, v), e.shopifyDomain, E))), n = [];
240
- for (let e of t) e.status === "fulfilled" ? n.push(e.value) : f(e.reason instanceof Error ? e.reason : Error(String(e.reason)));
247
+ variantImageTransform: v
248
+ }, b), e.shopifyDomain, O))), n = [];
249
+ for (let e of t) e.status === "fulfilled" ? n.push(e.value) : m(e.reason instanceof Error ? e.reason : Error(String(e.reason)));
241
250
  return n;
242
251
  }
243
- return (await Promise.all(k.map((t) => h(e, t, {
252
+ return (await Promise.all(j.map((t) => g(e, t, {
244
253
  includeSellingPlans: i,
245
254
  includeAvailableQuantity: a,
246
- variantImageTransform: m
247
- }, v)))).map((t) => g(t, e.shopifyDomain, E));
248
- }, h = async (e, t, n, r = "") => {
255
+ variantImageTransform: v
256
+ }, b)))).map((t) => _(t, e.shopifyDomain, O));
257
+ }, h = async (e, t, n) => {
258
+ try {
259
+ let r = await e.query(`
260
+ query FetchProductTypes($productGIDs: [ID!]!) ${s({ country: t })} {
261
+ nodes(ids: $productGIDs) {
262
+ ... on Product {
263
+ id
264
+ productType
265
+ }
266
+ }
267
+ }
268
+ `, { variables: { productGIDs: n } });
269
+ return new Map(r.nodes.filter((e) => e != null).map((e) => [e.id, e.productType]));
270
+ } catch (e) {
271
+ return console.error(e), null;
272
+ }
273
+ }, g = async (e, t, n, r = "") => {
249
274
  if (t.variants.nodes.length < 250) return t;
250
275
  let i = /* @__PURE__ */ new Set(), a = [], o = [], s = async (s) => {
251
276
  let c = !0, l = null;
@@ -281,7 +306,7 @@ var d = /* @__PURE__ */ function(e) {
281
306
  }
282
307
  };
283
308
  return await Promise.all([s(!1), s(!0)]), t.variants.nodes = [...a, ...o.reverse()], t;
284
- }, g = (e, t, n) => {
309
+ }, _ = (e, t, n) => {
285
310
  let r = e.variants.nodes.map(({ unitPriceMeasurement: e, ...t }) => ({
286
311
  id: Number(t.id.split("/").pop()),
287
312
  availableForSale: t.availableForSale,
@@ -319,7 +344,7 @@ var d = /* @__PURE__ */ function(e) {
319
344
  defaultName: e.name,
320
345
  name: e.name,
321
346
  position: t + 1,
322
- optionValues: y(n, t, r)
347
+ optionValues: b(n, t, r)
323
348
  };
324
349
  }), a = (e) => {
325
350
  let t = e.priceAdjustments[0];
@@ -343,6 +368,7 @@ var d = /* @__PURE__ */ function(e) {
343
368
  }, o = (e) => n === 1 ? Number(e) * 100 : Math.round(Number(e) * 100 * n), s = e.sellingPlanGroups?.nodes.flatMap((e) => e.sellingPlans.nodes.map((e) => ({
344
369
  id: Number(e.id.split("/").pop()),
345
370
  name: e.name,
371
+ recurringDeliveries: e.recurringDeliveries,
346
372
  priceAdjustment: a(e)
347
373
  }))) || [], c = e.variants.nodes.some((e) => e.requiresComponents);
348
374
  return {
@@ -366,27 +392,45 @@ var d = /* @__PURE__ */ function(e) {
366
392
  text3: e.metafield3?.value || null,
367
393
  text4: e.metafield4?.value || null
368
394
  },
369
- rating: _(e.reviewsRating, e.reviewsRatingCount),
370
- subtitle: e.subtitle?.value || null
395
+ rating: v(e.reviewsRating, e.reviewsRatingCount),
396
+ subtitle: e.subtitle?.value || null,
397
+ productType: e.productType || null,
398
+ categoryGid: e.category?.id ?? null,
399
+ tags: e.tags ?? []
371
400
  };
372
- }, _ = (e, t) => {
401
+ }, v = (e, t) => {
373
402
  if (!e) return null;
374
- let n = v(e.value);
403
+ let n = y(e.value);
375
404
  if (n === null) return null;
376
405
  let r = Number(t?.value);
377
406
  return {
378
407
  value: n,
379
408
  count: Number.isInteger(r) && r > 0 ? r : null
380
409
  };
381
- }, v = (e) => {
410
+ }, y = (e) => {
382
411
  try {
383
412
  let { value: t, scale_max: n } = JSON.parse(e), r = Number(t) / Number(n) * 5;
384
413
  return Number.isFinite(r) && r > 0 ? Math.min(5, r) : null;
385
414
  } catch {
386
415
  return null;
387
416
  }
388
- }, y = (e, t, n) => e.filter((e) => n.filter((n) => n.options[t] === e.name).length > 0), b = "app--2935586817", x = async (t, { language: n, country: r, useExternalMetafieldNamespace: i }) => {
389
- let a = i ? `${b}--kaching_bundles` : "$app:kaching_bundles", o = i ? b : "$app", c = s({ country: r }), { localization: { country: { currency: { isoCode: l } } }, shop: { moneyFormat: u, paymentSettings: { currencyCode: d }, currencyRateConstant: f, primaryDomain: p, settingsMetafield: m } } = await t.query(`
417
+ }, b = (e, t, n) => e.filter((e) => n.filter((n) => n.options[t] === e.name).length > 0);
418
+ [
419
+ "primaryBackground",
420
+ "secondaryBackground",
421
+ "primaryText",
422
+ "secondaryText",
423
+ "border",
424
+ "overlay",
425
+ "primaryAccent",
426
+ "primaryAccentText",
427
+ "badgeBackground",
428
+ "badgeText",
429
+ "error"
430
+ ].map((e) => `brand_${e}`);
431
+ // ../bundles-storefront-api/dist/fetchGlobalConfig.js
432
+ var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalMetafieldNamespace: i }) => {
433
+ let a = i ? `${x}--kaching_bundles` : "$app:kaching_bundles", o = i ? x : "$app", c = s({ country: r }), { localization: { country: { currency: { isoCode: l } } }, shop: { moneyFormat: u, paymentSettings: { currencyCode: d }, currencyRateConstant: f, primaryDomain: p, settingsMetafield: m } } = await t.query(`
390
434
  query config($metafieldNamespace: String!, $settingsNamespace: String!) ${c} {
391
435
  localization {
392
436
  country {
@@ -417,7 +461,7 @@ var d = /* @__PURE__ */ function(e) {
417
461
  } }), h = l === d ? u : e(l, {
418
462
  language: n,
419
463
  country: r
420
- }), g = f ? S(f.value) : 1, _ = m ? JSON.parse(m.value) : null, v = _?.feature_flags ?? {}, y = _?.custom_selectors ?? {};
464
+ }), g = f ? C(f.value) : 1, _ = m ? JSON.parse(m.value) : null, v = _?.feature_flags ?? {}, y = _?.custom_selectors ?? {};
421
465
  return {
422
466
  shopifyDomain: p.host,
423
467
  moneyFormat: h,
@@ -478,7 +522,7 @@ var d = /* @__PURE__ */ function(e) {
478
522
  featureFlags: v,
479
523
  brandColors: _?.brand_colors ?? null
480
524
  };
481
- }, S = (e) => JSON.parse(e).amount / 1e6, C = async (e, t, n = 200) => {
525
+ }, C = (e) => JSON.parse(e).amount / 1e6, w = async (e, t, n = 200) => {
482
526
  let r = [...new Set(t.filter(Boolean).filter((e) => !e.startsWith("placeholder")))];
483
527
  if (r.length === 0) return [];
484
528
  let i = [];
@@ -490,77 +534,103 @@ var d = /* @__PURE__ */ function(e) {
490
534
  gid: e.id,
491
535
  url: e.image.url
492
536
  }] : []);
493
- }, w = (e) => [
494
- ...T(e),
495
- ...E(e),
496
- ...D(e),
537
+ }, T = 100, E = async (e, { dealBlock: t, country: n, language: r }) => {
538
+ let i = [...new Set(t.dealBars.flatMap((e) => e.dealBarType === d.MixAndMatch ? e.bundleProducts : []).flatMap((e) => (e.selectedCollections ?? []).map((e) => e.id)))];
539
+ if (i.length === 0) return [];
540
+ let a = s({
541
+ country: n,
542
+ language: r
543
+ }), o = await e.query(`
544
+ query FetchMixAndMatchCollectionProductGIDs($collectionGIDs: [ID!]!) ${a} {
545
+ nodes(ids: $collectionGIDs) {
546
+ ... on Collection {
547
+ id
548
+ products(first: ${T}) {
549
+ nodes {
550
+ id
551
+ variants(first: 1) {
552
+ nodes {
553
+ requiresComponents
554
+ }
555
+ }
556
+ }
557
+ }
558
+ }
559
+ }
560
+ }
561
+ `, { variables: { collectionGIDs: i } });
562
+ return [...new Set(o.nodes.filter((e) => e !== null).flatMap((e) => e.products.nodes).filter((e) => !e.variants.nodes.some((e) => e.requiresComponents)).map((e) => e.id))];
563
+ }, D = (e) => [
497
564
  ...O(e),
498
565
  ...k(e),
499
566
  ...A(e),
500
567
  ...j(e),
501
- ...M(e),
502
568
  ...ee(e),
503
569
  ...te(e),
570
+ ...M(e),
504
571
  ...ne(e),
572
+ ...N(e),
573
+ ...P(e),
505
574
  ...re(e),
506
- ...ie(e)
507
- ].filter((e) => e != null && !e.includes("placeholder")), T = (e) => e.dealBars.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), E = (e) => e.dealBars.flatMap((e) => e.dealBarType === d.Bundle ? e.bundleProducts.map((e) => e.mediaImageGID) : []).filter((e) => e != null), D = (e) => e.dealBars.map(({ freeGifts: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), O = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => (e || []).map((e) => e.mediaImageGID)).filter((e) => e != null), k = (e) => e.dealBars.map(({ upsells: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), A = (e) => e.swatchOptions ? e.swatchOptions.reduce((e, t) => {
575
+ ...ie(e),
576
+ ...ae(e)
577
+ ].filter((e) => e != null && !e.includes("placeholder")), O = (e) => e.dealBars.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), k = (e) => e.dealBars.flatMap((e) => e.dealBarType === d.Bundle ? e.bundleProducts.map((e) => e.mediaImageGID) : []).filter((e) => e != null), A = (e) => e.dealBars.map(({ freeGifts: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), j = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => (e || []).map((e) => e.mediaImageGID)).filter((e) => e != null), ee = (e) => e.dealBars.map(({ upsells: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), te = (e) => e.swatchOptions ? e.swatchOptions.reduce((e, t) => {
508
578
  let n = t.images.map((e) => e.mediaImageGID).filter((e) => e != null);
509
579
  return [...e, ...n];
510
- }, []) : [], j = (e) => {
580
+ }, []) : [], M = (e) => {
511
581
  if (!e.collectionBreaksEnabled || !e.collectionBreaks) return [];
512
582
  let t = e.collectionBreaks.mediaImageGID;
513
583
  return t ? [t] : [];
514
- }, M = (e) => e.progressiveGifts ? [
584
+ }, ne = (e) => e.progressiveGifts ? [
515
585
  ...e.progressiveGifts.gifts?.map((e) => e.mediaImageGID) || [],
516
586
  e.progressiveGifts.style?.lockedMediaImageGID,
517
587
  e.progressiveGifts.dealBarStyle?.lockedMediaImageGID
518
- ].filter((e) => e != null) : [], ee = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), te = (e) => e.dealBars.map((e) => e.productPersonalisation?.mediaImageGID).filter((e) => e != null), ne = (e) => {
588
+ ].filter((e) => e != null) : [], N = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), P = (e) => e.dealBars.map((e) => e.productPersonalisation?.mediaImageGID).filter((e) => e != null), re = (e) => {
519
589
  let t = e.dealBars.map((e) => e.highlights?.customIconGID).filter((e) => e != null), n = e.subscriptions?.highlights?.customIconGID;
520
590
  return n ? [...t, n] : t;
521
- }, re = (e) => (e.badges || []).flatMap((e) => e.badgeType === "custom" && e.imageGID ? [e.imageGID] : []), ie = (e) => !e.savingsSummaryEnabled || !e.savingsSummary ? [] : e.savingsSummary.customIconGID ? [e.savingsSummary.customIconGID] : [], ae = (e) => {
522
- let t = [
523
- ...oe(e),
591
+ }, ie = (e) => (e.badges || []).flatMap((e) => e.badgeType === "custom" && e.imageGID ? [e.imageGID] : []), ae = (e) => !e.savingsSummaryEnabled || !e.savingsSummary ? [] : e.savingsSummary.customIconGID ? [e.savingsSummary.customIconGID] : [], oe = (e, { includeMixAndMatchSwapProducts: t = !0 } = {}) => {
592
+ let n = [
524
593
  ...se(e),
525
594
  ...ce(e),
526
595
  ...le(e),
527
596
  ...ue(e),
528
- ...N(e),
529
- ...P(e),
530
- ...F(e)
597
+ ...F(e),
598
+ ...I(e, t),
599
+ ...L(e),
600
+ ...R(e)
531
601
  ];
532
- return Array.from(new Set(t.filter((e) => e != null)));
533
- }, oe = (e) => e.dealBars.flatMap(({ freeGifts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), se = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => e ? e.flatMap((e) => e.products ? e.products.map((e) => e.id) : []) : []).filter((e) => e != null), ce = (e) => e.progressiveGiftsEnabled && e.progressiveGifts?.gifts.map((e) => e.productGID).filter((e) => e != null) || [], le = (e) => e.dealBars.flatMap(({ upsells: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), ue = (e) => e.dealBars.filter((e) => e.dealBarType === d.Bundle).flatMap(({ bundleProducts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null).filter((e) => e !== "default"), N = (e) => e.dealBars.filter((e) => e.dealBarType === d.MixAndMatch).flatMap(({ bundleProducts: e }) => e ? e.flatMap((e) => [e.productGID, ...e.selectedProducts?.map((e) => e.id) ?? []]) : []).filter((e) => e != null).filter((e) => e !== "default"), P = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.map((e) => e.productGID).filter((e) => e != null), F = (e) => e.dealBars.filter((e) => e.dealBarType === d.Sku).flatMap(({ productGID: e }) => e ? [e] : []), I = class extends Error {
602
+ return Array.from(new Set(n.filter((e) => e != null)));
603
+ }, se = (e) => e.dealBars.flatMap(({ freeGifts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), ce = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => e ? e.flatMap((e) => e.products ? e.products.map((e) => e.id) : []) : []).filter((e) => e != null), le = (e) => e.progressiveGiftsEnabled && e.progressiveGifts?.gifts.map((e) => e.productGID).filter((e) => e != null) || [], ue = (e) => e.dealBars.flatMap(({ upsells: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), F = (e) => e.dealBars.filter((e) => e.dealBarType === d.Bundle).flatMap(({ bundleProducts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null).filter((e) => e !== "default"), I = (e, t) => e.dealBars.filter((e) => e.dealBarType === d.MixAndMatch).flatMap(({ bundleProducts: e }) => e ? e.flatMap((e) => [e.productGID, ...t ? e.selectedProducts?.map((e) => e.id) ?? [] : []]) : []).filter((e) => e != null).filter((e) => e !== "default"), L = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.map((e) => e.productGID).filter((e) => e != null), R = (e) => e.dealBars.filter((e) => e.dealBarType === d.Sku).flatMap(({ productGID: e }) => e ? [e] : []), z = class extends Error {
534
604
  constructor({ status: e, operationName: t, graphqlErrors: n }) {
535
605
  let r = n.length ? `: ${n.join("; ")}` : "";
536
606
  super(`Storefront API ${t ?? "query"} failed (HTTP ${e})${r}`), this.name = "StorefrontApiError", this.status = e, this.operationName = t, this.graphqlErrors = n;
537
607
  }
538
- }, L = async (e, t) => {
608
+ }, B = async (e, t) => {
539
609
  let n = await e.text();
540
610
  if (!n) throw Error("Empty graphql response");
541
611
  let r;
542
612
  try {
543
613
  r = JSON.parse(n);
544
614
  } catch (n) {
545
- throw e.ok ? n : new I({
615
+ throw e.ok ? n : new z({
546
616
  status: e.status,
547
617
  operationName: t,
548
618
  graphqlErrors: []
549
619
  });
550
620
  }
551
- if (!e.ok || r.data === null || r.data === void 0) throw new I({
621
+ if (!e.ok || r.data === null || r.data === void 0) throw new z({
552
622
  status: e.status,
553
623
  operationName: t,
554
624
  graphqlErrors: (r.errors ?? []).map(({ message: e }) => e).filter(Boolean)
555
625
  });
556
626
  return r.data;
557
- }, R = class {
627
+ }, V = class {
558
628
  constructor(e, t) {
559
629
  this.storefrontApiVersion = "2026-07", this.storefrontAccessToken = t, this.shopifyDomain = e;
560
630
  }
561
631
  async query(e, t) {
562
632
  let n = t?.variables ?? {}, r = `https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`, i = e.match(/query\s+(\w+)/)?.[1];
563
- return i && (r += `?operation_name=${i}`), L(await fetch(r, {
633
+ return i && (r += `?operation_name=${i}`), B(await fetch(r, {
564
634
  method: "POST",
565
635
  headers: {
566
636
  "Content-Type": "application/json",
@@ -572,7 +642,7 @@ var d = /* @__PURE__ */ function(e) {
572
642
  })
573
643
  }), i);
574
644
  }
575
- }, z = (e, t) => {
645
+ }, H = (e, t) => {
576
646
  let n = [], r = e.filter((e) => e.blockVisibility === "selected-products");
577
647
  for (let e of r) e.selectedProductIds.map(Number).includes(t.id) && n.push(e);
578
648
  let i = e.filter((e) => e.blockVisibility === "selected-collections");
@@ -582,7 +652,7 @@ var d = /* @__PURE__ */ function(e) {
582
652
  let o = e.filter((e) => e.blockVisibility === "all-products");
583
653
  for (let e of o) n.push(e);
584
654
  return n;
585
- }, B = async (e, t, { country: n, language: r }) => {
655
+ }, U = async (e, t, { country: n, language: r }) => {
586
656
  let i = t.collectionBreaks;
587
657
  if (!t.collectionBreaksEnabled || !i) return;
588
658
  let a;
@@ -607,8 +677,8 @@ var d = /* @__PURE__ */ function(e) {
607
677
  productIds: a.map((e) => Number(e.split("/").pop())),
608
678
  useExternalMetafieldNamespace: !0
609
679
  }), s = i.visibility === "deal-products" && t.blockVisibility === "excluded-products";
610
- return o = o.filter((e) => e.availableForSale && (!s || z([t], e).length > 0)), o;
611
- }, V = ({ language: e, dealBlockId: t }) => {
680
+ return o = o.filter((e) => e.availableForSale && (!s || H([t], e).length > 0)), o;
681
+ }, de = ({ language: e, dealBlockId: t }) => {
612
682
  let n = {
613
683
  "system.out_of_stock": "There's not enough items in our stock, please select smaller bundle.",
614
684
  "system.invalid_variant": "Sorry, this is not currently available.",
@@ -635,13 +705,13 @@ var d = /* @__PURE__ */ function(e) {
635
705
  "system.numbers_only": "Only numbers are allowed.",
636
706
  "system.personalisation_required_alert": "Please add personalisation for every item to continue.",
637
707
  "system.gifts_required_alert": "Please choose your free gifts"
638
- }, r = e ? H(e) : void 0;
708
+ }, r = e ? fe(e) : void 0;
639
709
  return {
640
710
  ...n,
641
711
  ...r?.system,
642
712
  ...r?.dealBlocks[t]
643
713
  };
644
- }, H = (e) => {
714
+ }, fe = (e) => {
645
715
  if (typeof document > "u") return;
646
716
  let t = document.querySelector("script#kaching-bundles-translations");
647
717
  if (!t?.textContent) return;
@@ -651,19 +721,19 @@ var d = /* @__PURE__ */ function(e) {
651
721
  } catch {
652
722
  return;
653
723
  }
654
- let r = U(e);
655
- return n.find((e) => U(e.locale) === r)?.translations;
656
- }, U = (e) => e.toLowerCase().replace(/_/g, "-"), de = "2026-07", W = async (e, { productId: t, dealBlockId: n, abTestVariantId: r, country: i = void 0, language: a = void 0 }) => {
724
+ let r = W(e);
725
+ return n.find((e) => W(e.locale) === r)?.translations;
726
+ }, W = (e) => e.toLowerCase().replace(/_/g, "-"), pe = "2026-07", G = async (e, { productId: t, dealBlockId: n, abTestVariantId: r, country: i = void 0, language: a = void 0 }) => {
657
727
  try {
658
- let o = [Number(t.split("/").pop())], s = new fe(e);
728
+ let o = [Number(t.split("/").pop())], s = new me(e);
659
729
  i ||= s.i18n?.country, a ||= s.i18n?.language;
660
- let l = await x(s, {
730
+ let l = await S(s, {
661
731
  language: a,
662
732
  country: i,
663
733
  useExternalMetafieldNamespace: !0
664
734
  });
665
735
  s.shopifyDomain = l.shopifyDomain;
666
- let u = l.storefrontAccessToken ? new R(l.shopifyDomain, l.storefrontAccessToken) : s, [d, f] = await Promise.all([m(u, {
736
+ let u = l.storefrontAccessToken ? new V(l.shopifyDomain, l.storefrontAccessToken) : s, [d, f] = await Promise.all([m(u, {
667
737
  country: i,
668
738
  language: a,
669
739
  productIds: o,
@@ -673,21 +743,33 @@ var d = /* @__PURE__ */ function(e) {
673
743
  useMetaobjects: l.featureFlags.storefront_metaobjects
674
744
  })]), p = d[0];
675
745
  if (!p) return null;
676
- let h = z(f, p), g = n ? h.filter((e) => e.id === n || e.nanoId === n) : h, _ = (r ? g.find((e) => e.abTestVariantId === r) : void 0) ?? g[0] ?? h[0];
746
+ let h = H(f, p), g = n ? h.filter((e) => e.id === n || e.nanoId === n) : h, _ = (r ? g.find((e) => e.abTestVariantId === r) : void 0) ?? g[0] ?? h[0];
677
747
  if (!_) return null;
678
- let v = w(_), y = ae(_), [b, S, T, E] = await Promise.all([
679
- m(u, {
680
- country: i,
681
- language: a,
682
- productIds: y,
683
- useExternalMetafieldNamespace: !0
684
- }),
685
- C(u, v, 300),
686
- B(u, _, {
748
+ let v = D(_), [y, b, x, C] = await Promise.all([
749
+ (async () => {
750
+ let e = [];
751
+ try {
752
+ e = await E(u, {
753
+ dealBlock: _,
754
+ country: i,
755
+ language: a
756
+ });
757
+ } catch (e) {
758
+ console.error(e);
759
+ }
760
+ return m(u, {
761
+ country: i,
762
+ language: a,
763
+ productIds: [.../* @__PURE__ */ new Set([...oe(_), ...e])],
764
+ useExternalMetafieldNamespace: !0
765
+ });
766
+ })(),
767
+ w(u, v, 300),
768
+ U(u, _, {
687
769
  country: i,
688
770
  language: a
689
771
  }),
690
- V({
772
+ de({
691
773
  language: a,
692
774
  dealBlockId: _.id
693
775
  })
@@ -696,15 +778,15 @@ var d = /* @__PURE__ */ function(e) {
696
778
  product: p,
697
779
  dealBlock: _,
698
780
  config: l,
699
- otherProducts: b,
700
- mediaImages: S,
701
- collectionBreaksProducts: T ?? [],
702
- translations: E
781
+ otherProducts: y,
782
+ mediaImages: b,
783
+ collectionBreaksProducts: x ?? [],
784
+ translations: C
703
785
  };
704
786
  } catch (e) {
705
787
  return console.error(e), null;
706
788
  }
707
- }, fe = class {
789
+ }, me = class {
708
790
  constructor(e) {
709
791
  this.storefront = e, this.shopifyDomain = "";
710
792
  }
@@ -717,7 +799,7 @@ var d = /* @__PURE__ */ function(e) {
717
799
  }
718
800
  if ("request" in this.storefront) return (await this.storefront.request(e, t)).data;
719
801
  if ("shopifyDomain" in this.storefront && "storefrontAccessToken" in this.storefront) {
720
- let n = await fetch(`https://${this.storefront.shopifyDomain}/api/${de}/graphql.json`, {
802
+ let n = await fetch(`https://${this.storefront.shopifyDomain}/api/${pe}/graphql.json`, {
721
803
  body: JSON.stringify({
722
804
  query: e,
723
805
  variables: t?.variables
@@ -747,34 +829,34 @@ var d = /* @__PURE__ */ function(e) {
747
829
  get i18n() {
748
830
  if ("i18n" in this.storefront) return this.storefront.i18n;
749
831
  }
750
- }, G = "kaching-bundles-block", K = 1e4, q = "/kaching-bundles-block.js", pe = "https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js", me = "https://bundles-integrations.kachingappz.app/kaching-bundles-block.js", J = /* @__PURE__ */ new WeakSet(), Y = async (e) => {
832
+ }, K = "kaching-bundles-block", q = 1e4, J = "/kaching-bundles-block.js", he = "https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js", ge = "https://bundles-integrations.kachingappz.app/kaching-bundles-block.js", Y = /* @__PURE__ */ new WeakSet(), X = async (e) => {
751
833
  let t = e.document;
752
- if (!e.customElements.get(G)) {
753
- if (J.has(t)) return Q(e, G);
754
- J.add(t);
834
+ if (!e.customElements.get(K)) {
835
+ if (Y.has(t)) return Q(e, K);
836
+ Y.add(t);
755
837
  try {
756
- await _e(e);
838
+ await ye(e);
757
839
  } catch (e) {
758
- throw J.delete(t), e;
840
+ throw Y.delete(t), e;
759
841
  }
760
842
  }
761
- }, he = () => typeof window < "u" && window.__KACHING_DEV__ !== void 0, ge = () => he() ? pe : me, _e = async (e) => {
762
- let t = e.document, n = ge();
763
- if (t.querySelector(`script[src="${n}"]`)) return Q(e, G);
764
- let r = ve(t);
765
- if (r && await X(t, r)) return Q(e, G);
843
+ }, _e = () => typeof window < "u" && window.__KACHING_DEV__ !== void 0, ve = () => _e() ? he : ge, ye = async (e) => {
844
+ let t = e.document, n = ve();
845
+ if (t.querySelector(`script[src="${n}"]`)) return Q(e, K);
846
+ let r = be(t);
847
+ if (r && await Se(t, r)) return Q(e, K);
766
848
  let i = t.createElement("script");
767
- return i.src = n, await Z(t, i), Q(e, G);
768
- }, ve = (e) => {
769
- let t = e.querySelectorAll(`link[rel="modulepreload"][href$="${q}"]`);
770
- return Array.from(t, (e) => e.href).find(ye);
771
- }, ye = (e) => {
849
+ return i.src = n, await Z(t, i), Q(e, K);
850
+ }, be = (e) => {
851
+ let t = e.querySelectorAll(`link[rel="modulepreload"][href$="${J}"]`);
852
+ return Array.from(t, (e) => e.href).find(xe);
853
+ }, xe = (e) => {
772
854
  try {
773
- return new URL(e).pathname.endsWith(q);
855
+ return new URL(e).pathname.endsWith(J);
774
856
  } catch {
775
857
  return !1;
776
858
  }
777
- }, X = async (e, t) => {
859
+ }, Se = async (e, t) => {
778
860
  let n = e.createElement("script");
779
861
  n.type = "module", n.setAttribute("crossorigin", "anonymous"), n.src = t;
780
862
  try {
@@ -785,7 +867,7 @@ var d = /* @__PURE__ */ function(e) {
785
867
  }, Z = (e, t) => new Promise((n, r) => {
786
868
  t.onload = () => n(), t.onerror = () => r(/* @__PURE__ */ Error("Failed to load script")), e.head.appendChild(t);
787
869
  }), Q = (e, t) => new Promise((n, r) => {
788
- e.customElements.get(t) ? n() : Promise.race([e.customElements.whenDefined(t), new Promise((e, n) => setTimeout(() => n(/* @__PURE__ */ Error(`Custom element "${t}" failed to register within ${K}ms`)), K))]).then(() => n()).catch(r);
870
+ e.customElements.get(t) ? n() : Promise.race([e.customElements.whenDefined(t), new Promise((e, n) => setTimeout(() => n(/* @__PURE__ */ Error(`Custom element "${t}" failed to register within ${q}ms`)), q))]).then(() => n()).catch(r);
789
871
  });
790
872
  [
791
873
  "primaryBackground",
@@ -802,7 +884,7 @@ var d = /* @__PURE__ */ function(e) {
802
884
  ].map((e) => `brand_${e}`);
803
885
  var $ = /* @__PURE__ */ function(e) {
804
886
  return e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e;
805
- }({}), be = {
887
+ }({}), Ce = {
806
888
  config: {
807
889
  shopifyDomain: "",
808
890
  moneyFormat: "${{amount}}",
@@ -1201,7 +1283,7 @@ var $ = /* @__PURE__ */ function(e) {
1201
1283
  mediaImages: [],
1202
1284
  collectionBreaksProducts: [],
1203
1285
  translations: {}
1204
- }, xe = class extends HTMLElement {
1286
+ }, we = class extends HTMLElement {
1205
1287
  constructor(...e) {
1206
1288
  super(...e), this.innerElement = null, this.handleItemsChanged = null, this.initializeId = 0;
1207
1289
  }
@@ -1219,13 +1301,13 @@ var $ = /* @__PURE__ */ function(e) {
1219
1301
  async initialize() {
1220
1302
  let e = ++this.initializeId;
1221
1303
  if (this.cleanup(), this.hasAttribute("demo")) {
1222
- if (await Y(window), e !== this.initializeId) return;
1223
- this.renderInnerElement(be);
1304
+ if (await X(window), e !== this.initializeId) return;
1305
+ this.renderInnerElement(Ce);
1224
1306
  return;
1225
1307
  }
1226
1308
  let t = this.getAttribute("shop-domain"), n = this.getAttribute("storefront-token"), r = this.getAttribute("product-id");
1227
1309
  if (!t || !n || !r) return;
1228
- let [i] = await Promise.all([W({
1310
+ let [i] = await Promise.all([G({
1229
1311
  shopifyDomain: t,
1230
1312
  storefrontAccessToken: n
1231
1313
  }, {
@@ -1234,7 +1316,7 @@ var $ = /* @__PURE__ */ function(e) {
1234
1316
  abTestVariantId: this.getAttribute("ab-test-variant-id") ?? void 0,
1235
1317
  country: this.getAttribute("country")?.toUpperCase() ?? void 0,
1236
1318
  language: this.getAttribute("language")?.toUpperCase() ?? void 0
1237
- }), Y(window)]);
1319
+ }), X(window)]);
1238
1320
  i && e === this.initializeId && this.renderInnerElement(i);
1239
1321
  }
1240
1322
  renderInnerElement(e) {
@@ -1271,5 +1353,5 @@ var $ = /* @__PURE__ */ function(e) {
1271
1353
  this.cleanup(), this.initializeId++;
1272
1354
  }
1273
1355
  };
1274
- customElements.define("kaching-bundle-component", xe);
1275
- export { W as fetchKachingBundlesData };
1356
+ customElements.define("kaching-bundle-component", we);
1357
+ export { G as fetchKachingBundlesData };