@kachingappz/bundles-js 1.1.9 → 1.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.
@@ -1,22 +1,78 @@
1
- // ../bundles-storefront-api/dist/buildMarketMoneyFormat.js
2
- var e = (e, { language: n, country: s }) => {
3
- let c = i(n, s), l = new Intl.NumberFormat(c, {
1
+ [
2
+ "primaryBackground",
3
+ "secondaryBackground",
4
+ "primaryText",
5
+ "secondaryText",
6
+ "border",
7
+ "overlay",
8
+ "primaryAccent",
9
+ "primaryAccentText",
10
+ "badgeBackground",
11
+ "badgeText",
12
+ "error"
13
+ ].map((e) => `brand_${e}`);
14
+ var e = /* @__PURE__ */ function(e) {
15
+ return e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e;
16
+ }({}), t = (e, t) => e.selectedVariants?.find((e) => e.productId === t)?.variantIds, n = (e, n) => t(e, n) !== void 0, r = (e, n, r) => t(e, n)?.includes(r) ?? !0, i = (e, t) => n(e, t.id) ? t.variants.filter((n) => r(e, t.id, n.id)).map((e) => e.id) : void 0, a = (e, t) => {
17
+ if (!t) return e;
18
+ let n = e.variants.filter((e) => t.includes(e.id)), r = e.options.map((e, t) => ({
19
+ ...e,
20
+ optionValues: e.optionValues.filter((e) => n.some((n) => n.options[t] === e.name))
21
+ })), i = n.some((t) => t.id === e.selectedVariantId) ? e.selectedVariantId : n[0]?.id ?? e.selectedVariantId;
22
+ return {
23
+ ...e,
24
+ variants: n,
25
+ options: r,
26
+ selectedVariantId: i
27
+ };
28
+ }, o = (e, t) => s(e) ? c(e, t, l(e)) : t, s = (e) => !!e.selectedVariants?.length, c = (e, t, n) => t.flatMap((t) => {
29
+ let r = i(e, t);
30
+ if (!r) return [t];
31
+ let o = a(t, [...r, ...t.variants.map((e) => e.id).filter((e) => n.has(e))]);
32
+ return o.variants.length ? [o] : [];
33
+ }), l = (e) => new Set([
34
+ ...e.dealBars.flatMap(u),
35
+ ...(e.progressiveGifts?.gifts ?? []).flatMap((e) => e.variantGIDs ?? []),
36
+ ...(e.checkboxUpsells?.upsells ?? []).flatMap((e) => e.variantGIDs ?? [])
37
+ ].map(f)), u = (e) => [
38
+ ...e.freeGifts.flatMap((e) => e.variantGIDs ?? []),
39
+ ...e.upsells.flatMap((e) => e.variantGIDs ?? []),
40
+ ...(e.multipleGiftsSelectors ?? []).flatMap((e) => e.products.flatMap((e) => e.variantGIDs ?? [])),
41
+ ...d(e)
42
+ ], d = (t) => {
43
+ switch (t.dealBarType) {
44
+ case e.Bundle: return t.bundleProducts.flatMap((e) => e.productGID === "default" ? [] : e.variantGIDs ?? []);
45
+ case e.MixAndMatch: return t.bundleProducts.flatMap((e) => [...e.productGID === "default" ? [] : e.variantGIDs ?? [], ...(e.selectedProducts ?? []).flatMap((e) => e.variantGIDs ?? [])]);
46
+ default: return [];
47
+ }
48
+ }, f = (e) => Number(e.split("/").pop()), p = (e, n, i) => {
49
+ let a = (e) => i !== void 0 && r(e, n.id, i), o = e.filter((e) => t(e, n.id)?.some((e) => n.variants.some((t) => t.id === e))), s = o.filter(a), c = [...s], l = o.filter((e) => !s.includes(e)), u = e.filter((e) => e.blockVisibility === "selected-products");
50
+ for (let e of u) e.selectedProductIds.map(Number).includes(n.id) && c.push(e);
51
+ let d = e.filter((e) => e.blockVisibility === "selected-collections");
52
+ for (let e of d) n.collectionIds.some((t) => e.selectedCollectionIds.map(Number).includes(t)) && c.push(e);
53
+ let f = e.filter((e) => e.blockVisibility === "excluded-products");
54
+ for (let e of f) !e.excludedProductIds.map(Number).includes(n.id) && !(e.excludedCollectionIds || []).some((e) => n.collectionIds.includes(e)) && c.push(e);
55
+ let p = e.filter((e) => e.blockVisibility === "all-products");
56
+ for (let e of p) c.push(e);
57
+ return i === void 0 ? c : [...c, ...l];
58
+ }, m = (e, { language: t, country: n }) => {
59
+ let r = v(t, n), i = new Intl.NumberFormat(r, {
4
60
  style: "currency",
5
61
  currency: e,
6
62
  currencyDisplay: "narrowSymbol"
7
- }).formatToParts(1234567.89), u = l.find((e) => e.type === "decimal")?.value, d = o(a(l.find((e) => e.type === "group")?.value), u, l.some((e) => e.type === "fraction")), f = l.findIndex(r), p = l.findLastIndex(r);
63
+ }).formatToParts(1234567.89), a = i.find((e) => e.type === "decimal")?.value, o = b(y(i.find((e) => e.type === "group")?.value), a, i.some((e) => e.type === "fraction")), s = i.findIndex(_), c = i.findLastIndex(_);
8
64
  return [
9
- ...l.slice(0, f).map(t),
10
- d,
11
- ...l.slice(p + 1).map(t)
65
+ ...i.slice(0, s).map(h),
66
+ o,
67
+ ...i.slice(c + 1).map(h)
12
68
  ].join("");
13
- }, t = (e) => n(e.value), n = (e) => e.replace(/\s/g, " "), r = (e) => e.type === "integer" || e.type === "group" || e.type === "decimal" || e.type === "fraction", i = (e, t) => e && t ? `${e}-${t.toUpperCase()}` : e || (t ? t.toUpperCase() : "en"), a = (e) => e === void 0 ? void 0 : n(e).replace(/’/g, "'"), o = (e, t, n) => t === "," && e === "." ? n ? "{{amount_with_comma_separator}}" : "{{amount_no_decimals_with_comma_separator}}" : t === "," && e === " " ? n ? "{{amount_with_space_separator}}" : "{{amount_no_decimals_with_space_separator}}" : t === "." && e === " " ? "{{amount_with_period_and_space_separator}}" : t === "." && e === "'" ? "{{amount_with_apostrophe_separator}}" : n ? "{{amount}}" : "{{amount_no_decimals}}", s = ({ country: e, language: t }) => {
69
+ }, h = (e) => g(e.value), g = (e) => e.replace(/\s/g, " "), _ = (e) => e.type === "integer" || e.type === "group" || e.type === "decimal" || e.type === "fraction", v = (e, t) => e && t ? `${e}-${t.toUpperCase()}` : e || (t ? t.toUpperCase() : "en"), y = (e) => e === void 0 ? void 0 : g(e).replace(/’/g, "'"), b = (e, t, n) => t === "," && e === "." ? n ? "{{amount_with_comma_separator}}" : "{{amount_no_decimals_with_comma_separator}}" : t === "," && e === " " ? n ? "{{amount_with_space_separator}}" : "{{amount_no_decimals_with_space_separator}}" : t === "." && e === " " ? "{{amount_with_period_and_space_separator}}" : t === "." && e === "'" ? "{{amount_with_apostrophe_separator}}" : n ? "{{amount}}" : "{{amount_no_decimals}}", x = ({ country: e, language: t }) => {
14
70
  let n = [];
15
71
  return e && n.push(`country: ${e}`), t && n.push(`language: ${t}`), n.length > 0 ? `@inContext(${n.join(", ")})` : "";
16
- }, c = async (e, { useExternalMetafieldNamespace: t, useMetaobjects: n }) => n ? u(e, t) : l(e, t), l = async (e, t) => {
72
+ }, S = async (e, { useExternalMetafieldNamespace: t, useMetaobjects: n }) => n ? w(e, t) : C(e, t), C = async (e, t) => {
17
73
  let n = (await e.query("\n query FetchDealBlocks($metafieldNamespace: String!) {\n shop {\n metafield(namespace: $metafieldNamespace, key: \"deal_blocks\") {\n value\n }\n }\n }\n ", { variables: { metafieldNamespace: t ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles" } })).shop.metafield?.value;
18
74
  return n ? JSON.parse(n) : [];
19
- }, u = async (e, t) => {
75
+ }, w = async (e, t) => {
20
76
  let n = t ? "app--2935586817--deal_block" : "$app:deal_block", r = [], i = null;
21
77
  for (;;) {
22
78
  let t = await e.query("\n query FetchDealBlockMetaobjects($type: String!, $cursor: String) {\n metaobjects(type: $type, first: 250, after: $cursor) {\n nodes {\n fields {\n key\n value\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n ", { variables: {
@@ -45,19 +101,19 @@ var e = (e, { language: n, country: s }) => {
45
101
  "badgeText",
46
102
  "error"
47
103
  ].map((e) => `brand_${e}`);
48
- var d = /* @__PURE__ */ function(e) {
104
+ var T = /* @__PURE__ */ function(e) {
49
105
  return e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e;
50
- }({}), f = async (e, { country: t, language: n, blockVisibility: r, excludedProductGIDs: i, selectedProductGIDs: a, selectedCollectionGIDs: o, limit: c = 1e3 }) => {
106
+ }({}), E = async (e, { country: t, language: n, blockVisibility: r, excludedProductGIDs: i, selectedProductGIDs: a, selectedCollectionGIDs: o, limit: s = 1e3 }) => {
51
107
  switch (r) {
52
- case "selected-products": return a.slice(0, c);
108
+ case "selected-products": return a.slice(0, s);
53
109
  case "all-products":
54
110
  case "excluded-products": {
55
- let a = s({
111
+ let a = x({
56
112
  country: t,
57
113
  language: n
58
- }), o = [], l = null;
59
- for (; o.length < c;) {
60
- let t = Math.min(c - o.length, 250), n = await e.query(`
114
+ }), o = [], c = null;
115
+ for (; o.length < s;) {
116
+ let t = Math.min(s - o.length, 250), n = await e.query(`
61
117
  query FetchProductGIDs($limit: Int!, $cursor: String) ${a} {
62
118
  products(first: $limit, after: $cursor) {
63
119
  nodes {
@@ -71,10 +127,10 @@ var d = /* @__PURE__ */ function(e) {
71
127
  }
72
128
  `, { variables: {
73
129
  limit: t,
74
- cursor: l
130
+ cursor: c
75
131
  } });
76
132
  if (o.push(...n.products.nodes.map((e) => e.id)), !n.products.pageInfo.hasNextPage) break;
77
- l = n.products.pageInfo.endCursor;
133
+ c = n.products.pageInfo.endCursor;
78
134
  }
79
135
  if (r === "excluded-products") {
80
136
  let e = new Set(i);
@@ -83,7 +139,7 @@ var d = /* @__PURE__ */ function(e) {
83
139
  return o;
84
140
  }
85
141
  case "selected-collections": {
86
- let r = s({
142
+ let r = x({
87
143
  country: t,
88
144
  language: n
89
145
  }), i = (await e.query(`
@@ -100,21 +156,21 @@ var d = /* @__PURE__ */ function(e) {
100
156
  }
101
157
  `, { variables: {
102
158
  collectionGIDs: o,
103
- limit: Math.min(c, 250)
159
+ limit: Math.min(s, 250)
104
160
  } })).nodes.filter((e) => e !== null).flatMap((e) => e.products.nodes.map((e) => e.id));
105
- return Array.from(new Set(i)).slice(0, c);
161
+ return Array.from(new Set(i)).slice(0, s);
106
162
  }
107
163
  }
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 = {
164
+ }, D = "\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", O = async (e, { country: t, language: n, productIds: r, includeSellingPlans: i = !0, includeAvailableQuantity: a = !0, includeProductRating: o = !1, includeProductSubtitle: s = !1, includeProductTabFields: c = !1, productSubtitleMetafield: l = "descriptors.subtitle", useExternalMetafieldNamespace: u = !1, batchSize: d = 250, onBatchError: f, variantImageTransform: p = {
109
165
  maxWidth: 200,
110
166
  maxHeight: 200
111
167
  } }) => {
112
168
  if (!r.length) return [];
113
- let y = r.map((e) => typeof e == "string" && e.startsWith("gid://") ? e : `gid://shopify/Product/${e}`), b = s({
169
+ let m = r.map((e) => typeof e == "string" && e.startsWith("gid://") ? e : `gid://shopify/Product/${e}`), h = x({
114
170
  country: t,
115
171
  language: n
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} {
172
+ }), g = `
173
+ query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $includeProductRating: Boolean!, $includeProductSubtitle: Boolean!, $includeProductTabFields: Boolean!, $subtitleNamespace: String!, $subtitleKey: String!, $metafieldNamespace: String!, $variantImageTransform: ImageTransformInput) ${h} {
118
174
  shop {
119
175
  currencyRateConstant: metafield(namespace: $metafieldNamespace, key: "currency_rate_constant") {
120
176
  value
@@ -148,7 +204,7 @@ var d = /* @__PURE__ */ function(e) {
148
204
  }
149
205
  variants(first: 250) {
150
206
  nodes {
151
- ${p}
207
+ ${D}
152
208
  }
153
209
  }
154
210
  collections(first: 50) {
@@ -214,50 +270,50 @@ var d = /* @__PURE__ */ function(e) {
214
270
  }
215
271
  }
216
272
  }
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: {
273
+ `, _ = u ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles", v = l.indexOf("."), y = l.slice(0, v), b = l.slice(v + 1), S = [], C = Math.min(d, 250);
274
+ for (let e = 0; e < m.length; e += C) S.push(m.slice(e, e + C));
275
+ let w = 1, T = async (n) => {
276
+ let [r, l] = await Promise.all([e.query(g, { variables: {
221
277
  productGIDs: n,
222
278
  includeSellingPlans: i,
223
279
  includeAvailableQuantity: a,
224
280
  includeProductRating: o,
225
- includeProductSubtitle: c,
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 && {
281
+ includeProductSubtitle: s,
282
+ includeProductTabFields: c,
283
+ subtitleNamespace: y,
284
+ subtitleKey: b,
285
+ metafieldNamespace: _,
286
+ variantImageTransform: p
287
+ } }), c ? ee(e, t, n) : null]);
288
+ return r.shop.currencyRateConstant && (w = JSON.parse(r.shop.currencyRateConstant.value).amount / 1e6), l ? { nodes: r.nodes.map((e) => e && {
233
289
  ...e,
234
- productType: s.get(e.id)
290
+ productType: l.get(e.id)
235
291
  }) } : 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, {
292
+ }, E;
293
+ if (f) {
294
+ let e = await Promise.allSettled(S.map(T));
295
+ for (let t of e) t.status === "rejected" && f(t.reason instanceof Error ? t.reason : Error(String(t.reason)));
296
+ E = e.filter((e) => e.status === "fulfilled").flatMap((e) => e.value.nodes);
297
+ } else E = (await Promise.all(S.map(T))).flatMap((e) => e.nodes);
298
+ let O = E.filter((e) => e != null);
299
+ if (f) {
300
+ let t = await Promise.allSettled(O.map(async (t) => A(await k(e, t, {
245
301
  includeSellingPlans: i,
246
302
  includeAvailableQuantity: a,
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)));
303
+ variantImageTransform: p
304
+ }, h), e.shopifyDomain, w))), n = [];
305
+ for (let e of t) e.status === "fulfilled" ? n.push(e.value) : f(e.reason instanceof Error ? e.reason : Error(String(e.reason)));
250
306
  return n;
251
307
  }
252
- return (await Promise.all(j.map((t) => g(e, t, {
308
+ return (await Promise.all(O.map((t) => k(e, t, {
253
309
  includeSellingPlans: i,
254
310
  includeAvailableQuantity: a,
255
- variantImageTransform: v
256
- }, b)))).map((t) => _(t, e.shopifyDomain, O));
257
- }, h = async (e, t, n) => {
311
+ variantImageTransform: p
312
+ }, h)))).map((t) => A(t, e.shopifyDomain, w));
313
+ }, ee = async (e, t, n) => {
258
314
  try {
259
315
  let r = await e.query(`
260
- query FetchProductTypes($productGIDs: [ID!]!) ${s({ country: t })} {
316
+ query FetchProductTypes($productGIDs: [ID!]!) ${x({ country: t })} {
261
317
  nodes(ids: $productGIDs) {
262
318
  ... on Product {
263
319
  id
@@ -270,7 +326,7 @@ var d = /* @__PURE__ */ function(e) {
270
326
  } catch (e) {
271
327
  return console.error(e), null;
272
328
  }
273
- }, g = async (e, t, n, r = "") => {
329
+ }, k = async (e, t, n, r = "") => {
274
330
  if (t.variants.nodes.length < 250) return t;
275
331
  let i = /* @__PURE__ */ new Set(), a = [], o = [], s = async (s) => {
276
332
  let c = !0, l = null;
@@ -280,7 +336,7 @@ var d = /* @__PURE__ */ function(e) {
280
336
  product(id: $productGID) {
281
337
  variants(first: 250, after: $cursor, reverse: $reverse) {
282
338
  nodes {
283
- ${p}
339
+ ${D}
284
340
  }
285
341
  pageInfo {
286
342
  endCursor
@@ -306,7 +362,7 @@ var d = /* @__PURE__ */ function(e) {
306
362
  }
307
363
  };
308
364
  return await Promise.all([s(!1), s(!0)]), t.variants.nodes = [...a, ...o.reverse()], t;
309
- }, _ = (e, t, n) => {
365
+ }, A = (e, t, n) => {
310
366
  let r = e.variants.nodes.map(({ unitPriceMeasurement: e, ...t }) => ({
311
367
  id: Number(t.id.split("/").pop()),
312
368
  availableForSale: t.availableForSale,
@@ -344,7 +400,7 @@ var d = /* @__PURE__ */ function(e) {
344
400
  defaultName: e.name,
345
401
  name: e.name,
346
402
  position: t + 1,
347
- optionValues: b(n, t, r)
403
+ optionValues: re(n, t, r)
348
404
  };
349
405
  }), a = (e) => {
350
406
  let t = e.priceAdjustments[0];
@@ -392,46 +448,31 @@ var d = /* @__PURE__ */ function(e) {
392
448
  text3: e.metafield3?.value || null,
393
449
  text4: e.metafield4?.value || null
394
450
  },
395
- rating: v(e.reviewsRating, e.reviewsRatingCount),
451
+ rating: te(e.reviewsRating, e.reviewsRatingCount),
396
452
  subtitle: e.subtitle?.value || null,
397
453
  productType: e.productType || null,
398
454
  categoryGid: e.category?.id ?? null,
399
455
  tags: e.tags ?? []
400
456
  };
401
- }, v = (e, t) => {
457
+ }, te = (e, t) => {
402
458
  if (!e) return null;
403
- let n = y(e.value);
459
+ let n = ne(e.value);
404
460
  if (n === null) return null;
405
461
  let r = Number(t?.value);
406
462
  return {
407
463
  value: n,
408
464
  count: Number.isInteger(r) && r > 0 ? r : null
409
465
  };
410
- }, y = (e) => {
466
+ }, ne = (e) => {
411
467
  try {
412
468
  let { value: t, scale_max: n } = JSON.parse(e), r = Number(t) / Number(n) * 5;
413
469
  return Number.isFinite(r) && r > 0 ? Math.min(5, r) : null;
414
470
  } catch {
415
471
  return null;
416
472
  }
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(`
434
- query config($metafieldNamespace: String!, $settingsNamespace: String!) ${c} {
473
+ }, re = (e, t, n) => e.filter((e) => n.filter((n) => n.options[t] === e.name).length > 0), j = "app--2935586817", ie = async (e, { language: t, country: n, useExternalMetafieldNamespace: r }) => {
474
+ let i = r ? `${j}--kaching_bundles` : "$app:kaching_bundles", a = r ? j : "$app", o = x({ country: n }), { localization: { country: { currency: { isoCode: s } } }, shop: { moneyFormat: c, paymentSettings: { currencyCode: l }, currencyRateConstant: u, primaryDomain: d, settingsMetafield: f } } = await e.query(`
475
+ query config($metafieldNamespace: String!, $settingsNamespace: String!) ${o} {
435
476
  localization {
436
477
  country {
437
478
  currency {
@@ -456,31 +497,31 @@ var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalM
456
497
  }
457
498
  }
458
499
  `, { variables: {
459
- metafieldNamespace: a,
460
- settingsNamespace: o
461
- } }), h = l === d ? u : e(l, {
462
- language: n,
463
- country: r
464
- }), g = f ? C(f.value) : 1, _ = m ? JSON.parse(m.value) : null, v = _?.feature_flags ?? {}, y = _?.custom_selectors ?? {};
500
+ metafieldNamespace: i,
501
+ settingsNamespace: a
502
+ } }), p = s === l ? c : m(s, {
503
+ language: t,
504
+ country: n
505
+ }), h = u ? ae(u.value) : 1, g = f ? JSON.parse(f.value) : null, _ = g?.feature_flags ?? {}, v = g?.custom_selectors ?? {};
465
506
  return {
466
- shopifyDomain: p.host,
467
- moneyFormat: h,
468
- locale: n?.toLowerCase() || "en",
469
- liquidLocale: n?.toLowerCase() || "en",
470
- country: r ?? "US",
471
- currencyRate: g,
507
+ shopifyDomain: d.host,
508
+ moneyFormat: p,
509
+ locale: t?.toLowerCase() || "en",
510
+ liquidLocale: t?.toLowerCase() || "en",
511
+ country: n ?? "US",
512
+ currencyRate: h,
472
513
  marketId: 0,
473
514
  productId: null,
474
- storefrontAccessToken: _?.storefront_access_token ?? null,
475
- includeSellingPlans: _?.include_selling_plans ?? !1,
476
- includeAvailableQuantity: _?.include_available_quantity ?? !1,
477
- customApiHost: _?.custom_api_host ?? null,
478
- keepQuantityInput: _?.keep_quantity_input ?? !1,
479
- ignoreDeselect: _?.ignore_deselect ?? !1,
480
- ignoreUnitPrice: _?.ignore_unit_price ?? !1,
481
- requireCustomerLogin: _?.require_customer_login ?? !1,
482
- abTestsRunning: _?.ab_tests_running ?? !1,
483
- webPixel: _?.web_pixel ?? !1,
515
+ storefrontAccessToken: g?.storefront_access_token ?? null,
516
+ includeSellingPlans: g?.include_selling_plans ?? !1,
517
+ includeAvailableQuantity: g?.include_available_quantity ?? !1,
518
+ customApiHost: g?.custom_api_host ?? null,
519
+ keepQuantityInput: g?.keep_quantity_input ?? !1,
520
+ ignoreDeselect: g?.ignore_deselect ?? !1,
521
+ ignoreUnitPrice: g?.ignore_unit_price ?? !1,
522
+ requireCustomerLogin: g?.require_customer_login ?? !1,
523
+ abTestsRunning: g?.ab_tests_running ?? !1,
524
+ webPixel: g?.web_pixel ?? !1,
484
525
  b2bCustomer: !1,
485
526
  isLoggedIn: !1,
486
527
  preview: !1,
@@ -512,17 +553,17 @@ var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalM
512
553
  "system.numbers_only": "Only numbers are allowed."
513
554
  },
514
555
  customSelectors: {
515
- quantity: y.quantity ?? null,
516
- addToCartButton: y.add_to_cart_button ?? null,
517
- variantPicker: y.variant_picker ?? null,
518
- price: y.price ?? null,
519
- priceCompare: y.price_compare ?? null
556
+ quantity: v.quantity ?? null,
557
+ addToCartButton: v.add_to_cart_button ?? null,
558
+ variantPicker: v.variant_picker ?? null,
559
+ price: v.price ?? null,
560
+ priceCompare: v.price_compare ?? null
520
561
  },
521
- shopCustomStyles: _?.shop_custom_styles ?? "",
522
- featureFlags: v,
523
- brandColors: _?.brand_colors ?? null
562
+ shopCustomStyles: g?.shop_custom_styles ?? "",
563
+ featureFlags: _,
564
+ brandColors: g?.brand_colors ?? null
524
565
  };
525
- }, C = (e) => JSON.parse(e).amount / 1e6, w = async (e, t, n = 200) => {
566
+ }, ae = (e) => JSON.parse(e).amount / 1e6, oe = async (e, t, n = 200) => {
526
567
  let r = [...new Set(t.filter(Boolean).filter((e) => !e.startsWith("placeholder")))];
527
568
  if (r.length === 0) return [];
528
569
  let i = [];
@@ -534,10 +575,10 @@ var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalM
534
575
  gid: e.id,
535
576
  url: e.image.url
536
577
  }] : []);
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)))];
578
+ }, se = 100, ce = async (e, { dealBlock: t, country: n, language: r }) => {
579
+ let i = [...new Set(t.dealBars.flatMap((e) => e.dealBarType === T.MixAndMatch ? e.bundleProducts : []).flatMap((e) => (e.selectedCollections ?? []).map((e) => e.id)))];
539
580
  if (i.length === 0) return [];
540
- let a = s({
581
+ let a = x({
541
582
  country: n,
542
583
  language: r
543
584
  }), o = await e.query(`
@@ -545,7 +586,7 @@ var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalM
545
586
  nodes(ids: $collectionGIDs) {
546
587
  ... on Collection {
547
588
  id
548
- products(first: ${T}) {
589
+ products(first: ${se}) {
549
590
  nodes {
550
591
  id
551
592
  variants(first: 1) {
@@ -560,77 +601,77 @@ var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalM
560
601
  }
561
602
  `, { variables: { collectionGIDs: i } });
562
603
  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) => [
564
- ...O(e),
565
- ...k(e),
566
- ...A(e),
567
- ...j(e),
568
- ...ee(e),
569
- ...te(e),
604
+ }, le = (e) => [
605
+ ...ue(e),
606
+ ...de(e),
607
+ ...fe(e),
608
+ ...pe(e),
609
+ ...me(e),
570
610
  ...M(e),
571
- ...ne(e),
572
611
  ...N(e),
573
612
  ...P(e),
574
- ...re(e),
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) => {
613
+ ...F(e),
614
+ ...I(e),
615
+ ...L(e),
616
+ ...R(e),
617
+ ...z(e)
618
+ ].filter((e) => e != null && !e.includes("placeholder")), ue = (e) => e.dealBars.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), de = (e) => e.dealBars.flatMap((e) => e.dealBarType === T.Bundle ? e.bundleProducts.map((e) => e.mediaImageGID) : []).filter((e) => e != null), fe = (e) => e.dealBars.map(({ freeGifts: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), pe = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => (e || []).map((e) => e.mediaImageGID)).filter((e) => e != null), me = (e) => e.dealBars.map(({ upsells: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), M = (e) => e.swatchOptions ? e.swatchOptions.reduce((e, t) => {
578
619
  let n = t.images.map((e) => e.mediaImageGID).filter((e) => e != null);
579
620
  return [...e, ...n];
580
- }, []) : [], M = (e) => {
621
+ }, []) : [], N = (e) => {
581
622
  if (!e.collectionBreaksEnabled || !e.collectionBreaks) return [];
582
623
  let t = e.collectionBreaks.mediaImageGID;
583
624
  return t ? [t] : [];
584
- }, ne = (e) => e.progressiveGifts ? [
625
+ }, P = (e) => e.progressiveGifts ? [
585
626
  ...e.progressiveGifts.gifts?.map((e) => e.mediaImageGID) || [],
586
627
  e.progressiveGifts.style?.lockedMediaImageGID,
587
628
  e.progressiveGifts.dealBarStyle?.lockedMediaImageGID
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) => {
629
+ ].filter((e) => e != null) : [], F = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), I = (e) => e.dealBars.map((e) => e.productPersonalisation?.mediaImageGID).filter((e) => e != null), L = (e) => {
589
630
  let t = e.dealBars.map((e) => e.highlights?.customIconGID).filter((e) => e != null), n = e.subscriptions?.highlights?.customIconGID;
590
631
  return n ? [...t, n] : t;
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 } = {}) => {
632
+ }, R = (e) => (e.badges || []).flatMap((e) => e.badgeType === "custom" && e.imageGID ? [e.imageGID] : []), z = (e) => !e.savingsSummaryEnabled || !e.savingsSummary ? [] : e.savingsSummary.customIconGID ? [e.savingsSummary.customIconGID] : [], he = (e, { includeMixAndMatchSwapProducts: t = !0 } = {}) => {
592
633
  let n = [
593
- ...se(e),
594
- ...ce(e),
595
- ...le(e),
596
- ...ue(e),
597
- ...F(e),
598
- ...I(e, t),
599
- ...L(e),
600
- ...R(e)
634
+ ...ge(e),
635
+ ..._e(e),
636
+ ...ve(e),
637
+ ...ye(e),
638
+ ...be(e),
639
+ ...xe(e, t),
640
+ ...Se(e),
641
+ ...Ce(e)
601
642
  ];
602
643
  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 {
644
+ }, ge = (e) => e.dealBars.flatMap(({ freeGifts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), _e = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => e ? e.flatMap((e) => e.products ? e.products.map((e) => e.id) : []) : []).filter((e) => e != null), ve = (e) => e.progressiveGiftsEnabled && e.progressiveGifts?.gifts.map((e) => e.productGID).filter((e) => e != null) || [], ye = (e) => e.dealBars.flatMap(({ upsells: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), be = (e) => e.dealBars.filter((e) => e.dealBarType === T.Bundle).flatMap(({ bundleProducts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null).filter((e) => e !== "default"), xe = (e, t) => e.dealBars.filter((e) => e.dealBarType === T.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"), Se = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.map((e) => e.productGID).filter((e) => e != null), Ce = (e) => e.dealBars.filter((e) => e.dealBarType === T.Sku).flatMap(({ productGID: e }) => e ? [e] : []), B = class extends Error {
604
645
  constructor({ status: e, operationName: t, graphqlErrors: n }) {
605
646
  let r = n.length ? `: ${n.join("; ")}` : "";
606
647
  super(`Storefront API ${t ?? "query"} failed (HTTP ${e})${r}`), this.name = "StorefrontApiError", this.status = e, this.operationName = t, this.graphqlErrors = n;
607
648
  }
608
- }, B = async (e, t) => {
649
+ }, we = async (e, t) => {
609
650
  let n = await e.text();
610
651
  if (!n) throw Error("Empty graphql response");
611
652
  let r;
612
653
  try {
613
654
  r = JSON.parse(n);
614
655
  } catch (n) {
615
- throw e.ok ? n : new z({
656
+ throw e.ok ? n : new B({
616
657
  status: e.status,
617
658
  operationName: t,
618
659
  graphqlErrors: []
619
660
  });
620
661
  }
621
- if (!e.ok || r.data === null || r.data === void 0) throw new z({
662
+ if (!e.ok || r.data === null || r.data === void 0) throw new B({
622
663
  status: e.status,
623
664
  operationName: t,
624
665
  graphqlErrors: (r.errors ?? []).map(({ message: e }) => e).filter(Boolean)
625
666
  });
626
667
  return r.data;
627
- }, V = class {
668
+ }, Te = class {
628
669
  constructor(e, t) {
629
670
  this.storefrontApiVersion = "2026-07", this.storefrontAccessToken = t, this.shopifyDomain = e;
630
671
  }
631
672
  async query(e, t) {
632
673
  let n = t?.variables ?? {}, r = `https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`, i = e.match(/query\s+(\w+)/)?.[1];
633
- return i && (r += `?operation_name=${i}`), B(await fetch(r, {
674
+ return i && (r += `?operation_name=${i}`), we(await fetch(r, {
634
675
  method: "POST",
635
676
  headers: {
636
677
  "Content-Type": "application/json",
@@ -642,28 +683,34 @@ var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalM
642
683
  })
643
684
  }), i);
644
685
  }
645
- }, H = (e, t) => {
646
- let n = [], r = e.filter((e) => e.blockVisibility === "selected-products");
647
- for (let e of r) e.selectedProductIds.map(Number).includes(t.id) && n.push(e);
648
- let i = e.filter((e) => e.blockVisibility === "selected-collections");
649
- for (let e of i) t.collectionIds.some((t) => e.selectedCollectionIds.map(Number).includes(t)) && n.push(e);
650
- let a = e.filter((e) => e.blockVisibility === "excluded-products");
651
- for (let e of a) !e.excludedProductIds.map(Number).includes(t.id) && !(e.excludedCollectionIds || []).some((e) => t.collectionIds.includes(e)) && n.push(e);
652
- let o = e.filter((e) => e.blockVisibility === "all-products");
653
- for (let e of o) n.push(e);
654
- return n;
655
- }, U = async (e, t, { country: n, language: r }) => {
686
+ };
687
+ [
688
+ "primaryBackground",
689
+ "secondaryBackground",
690
+ "primaryText",
691
+ "secondaryText",
692
+ "border",
693
+ "overlay",
694
+ "primaryAccent",
695
+ "primaryAccentText",
696
+ "badgeBackground",
697
+ "badgeText",
698
+ "error"
699
+ ].map((e) => `brand_${e}`);
700
+ var V = /* @__PURE__ */ function(e) {
701
+ return e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e;
702
+ }({}), Ee = async (e, t, { country: n, language: r }) => {
656
703
  let i = t.collectionBreaks;
657
704
  if (!t.collectionBreaksEnabled || !i) return;
658
705
  let a;
659
- a = i.visibility === "deal-products" ? await f(e, {
706
+ a = i.visibility === "deal-products" ? await E(e, {
660
707
  country: n,
661
708
  language: r,
662
709
  blockVisibility: t.blockVisibility,
663
710
  excludedProductGIDs: (t.excludedProductIds || []).map((e) => `gid://shopify/Product/${e}`),
664
711
  selectedProductGIDs: (t.selectedProductIds || []).map((e) => `gid://shopify/Product/${e}`),
665
712
  selectedCollectionGIDs: (t.selectedCollectionIds || []).map((e) => `gid://shopify/Collection/${e}`)
666
- }) : await f(e, {
713
+ }) : await E(e, {
667
714
  country: n,
668
715
  language: r,
669
716
  blockVisibility: i.visibility,
@@ -671,14 +718,14 @@ var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalM
671
718
  selectedProductGIDs: (i.selectedProducts || []).map(({ id: e }) => e),
672
719
  selectedCollectionGIDs: (i.selectedCollections || []).map(({ id: e }) => e)
673
720
  });
674
- let o = await m(e, {
721
+ let o = await O(e, {
675
722
  country: n,
676
723
  language: r,
677
724
  productIds: a.map((e) => Number(e.split("/").pop())),
678
725
  useExternalMetafieldNamespace: !0
679
726
  }), s = i.visibility === "deal-products" && t.blockVisibility === "excluded-products";
680
- return o = o.filter((e) => e.availableForSale && (!s || H([t], e).length > 0)), o;
681
- }, de = ({ language: e, dealBlockId: t }) => {
727
+ return o = o.filter((e) => e.availableForSale && (!s || p([t], e).length > 0)), o;
728
+ }, De = ({ language: e, dealBlockId: t }) => {
682
729
  let n = {
683
730
  "system.out_of_stock": "There's not enough items in our stock, please select smaller bundle.",
684
731
  "system.invalid_variant": "Sorry, this is not currently available.",
@@ -705,13 +752,13 @@ var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalM
705
752
  "system.numbers_only": "Only numbers are allowed.",
706
753
  "system.personalisation_required_alert": "Please add personalisation for every item to continue.",
707
754
  "system.gifts_required_alert": "Please choose your free gifts"
708
- }, r = e ? fe(e) : void 0;
755
+ }, r = e ? Oe(e) : void 0;
709
756
  return {
710
757
  ...n,
711
758
  ...r?.system,
712
759
  ...r?.dealBlocks[t]
713
760
  };
714
- }, fe = (e) => {
761
+ }, Oe = (e) => {
715
762
  if (typeof document > "u") return;
716
763
  let t = document.querySelector("script#kaching-bundles-translations");
717
764
  if (!t?.textContent) return;
@@ -721,72 +768,99 @@ var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalM
721
768
  } catch {
722
769
  return;
723
770
  }
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 }) => {
771
+ let r = H(e);
772
+ return n.find((e) => H(e.locale) === r)?.translations;
773
+ }, H = (e) => e.toLowerCase().replace(/_/g, "-"), ke = "2026-07", U = async (e, { productId: t, dealBlockId: n, abTestVariantId: r, country: i = void 0, language: a = void 0 }) => {
727
774
  try {
728
- let o = [Number(t.split("/").pop())], s = new me(e);
729
- i ||= s.i18n?.country, a ||= s.i18n?.language;
730
- let l = await S(s, {
775
+ let s = [Number(t.split("/").pop())], c = new Pe(e);
776
+ i ||= c.i18n?.country, a ||= c.i18n?.language;
777
+ let l = await ie(c, {
731
778
  language: a,
732
779
  country: i,
733
780
  useExternalMetafieldNamespace: !0
734
781
  });
735
- s.shopifyDomain = l.shopifyDomain;
736
- let u = l.storefrontAccessToken ? new V(l.shopifyDomain, l.storefrontAccessToken) : s, [d, f] = await Promise.all([m(u, {
782
+ c.shopifyDomain = l.shopifyDomain;
783
+ let u = l.storefrontAccessToken ? new Te(l.shopifyDomain, l.storefrontAccessToken) : c, [d, f] = await Promise.all([O(u, {
737
784
  country: i,
738
785
  language: a,
739
- productIds: o,
786
+ productIds: s,
740
787
  useExternalMetafieldNamespace: !0
741
- }), c(u, {
788
+ }), S(u, {
742
789
  useExternalMetafieldNamespace: !0,
743
790
  useMetaobjects: l.featureFlags.storefront_metaobjects
744
- })]), p = d[0];
745
- if (!p) return null;
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];
791
+ })]), m = d[0];
792
+ if (!m) return null;
793
+ let h = p(f, m), 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];
747
794
  if (!_) return null;
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, _, {
795
+ let v = he(_, { includeMixAndMatchSwapProducts: !1 }), y = Ae(u, _, {
796
+ otherProductGIDs: v,
797
+ country: i,
798
+ language: a
799
+ }), [b, x, C] = await Promise.all([
800
+ O(u, {
769
801
  country: i,
770
- language: a
802
+ language: a,
803
+ productIds: v,
804
+ useExternalMetafieldNamespace: !0
771
805
  }),
772
- de({
806
+ oe(u, le(_), 300),
807
+ De({
773
808
  language: a,
774
809
  dealBlockId: _.id
775
810
  })
776
811
  ]);
777
812
  return {
778
- product: p,
779
- dealBlock: _,
780
- config: l,
781
- otherProducts: y,
782
- mediaImages: b,
783
- collectionBreaksProducts: x ?? [],
784
- translations: C
813
+ data: {
814
+ config: l,
815
+ dealBlock: _,
816
+ product: m,
817
+ otherProducts: o(_, b),
818
+ mediaImages: x,
819
+ translations: C
820
+ },
821
+ modalProducts: y
785
822
  };
786
823
  } catch (e) {
787
824
  return console.error(e), null;
788
825
  }
789
- }, me = class {
826
+ }, Ae = async (e, t, n) => {
827
+ let [r, i] = await Promise.all([je(e, t, n), Ne(e, t, n)]);
828
+ return {
829
+ mixAndMatchSwapProducts: r,
830
+ collectionBreaksProducts: i
831
+ };
832
+ }, je = async (e, t, { otherProductGIDs: n, country: r, language: i }) => {
833
+ try {
834
+ let a = [];
835
+ try {
836
+ a = await ce(e, {
837
+ dealBlock: t,
838
+ country: r,
839
+ language: i
840
+ });
841
+ } catch (e) {
842
+ console.error(e);
843
+ }
844
+ let s = new Set(n), c = [.../* @__PURE__ */ new Set([...Me(t), ...a])].filter((e) => !s.has(e));
845
+ return c.length ? o(t, await O(e, {
846
+ country: r,
847
+ language: i,
848
+ productIds: c,
849
+ useExternalMetafieldNamespace: !0
850
+ })) : [];
851
+ } catch (e) {
852
+ return console.error(e), [];
853
+ }
854
+ }, Me = (e) => e.dealBars.flatMap((e) => e.dealBarType === V.MixAndMatch ? e.bundleProducts.flatMap((e) => (e.selectedProducts ?? []).map((e) => e.id)) : []), Ne = async (e, t, { country: n, language: r }) => {
855
+ try {
856
+ return await Ee(e, t, {
857
+ country: n,
858
+ language: r
859
+ }) ?? [];
860
+ } catch (e) {
861
+ return console.error(e), [];
862
+ }
863
+ }, Pe = class {
790
864
  constructor(e) {
791
865
  this.storefront = e, this.shopifyDomain = "";
792
866
  }
@@ -799,7 +873,7 @@ var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalM
799
873
  }
800
874
  if ("request" in this.storefront) return (await this.storefront.request(e, t)).data;
801
875
  if ("shopifyDomain" in this.storefront && "storefrontAccessToken" in this.storefront) {
802
- let n = await fetch(`https://${this.storefront.shopifyDomain}/api/${pe}/graphql.json`, {
876
+ let n = await fetch(`https://${this.storefront.shopifyDomain}/api/${ke}/graphql.json`, {
803
877
  body: JSON.stringify({
804
878
  query: e,
805
879
  variables: t?.variables
@@ -829,62 +903,46 @@ var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalM
829
903
  get i18n() {
830
904
  if ("i18n" in this.storefront) return this.storefront.i18n;
831
905
  }
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) => {
906
+ }, W = "kaching-bundles-block", G = 1e4, K = "/kaching-bundles-block.js", Fe = "https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js", Ie = "https://bundles-integrations.kachingappz.app/kaching-bundles-block.js", q = /* @__PURE__ */ new WeakSet(), J = async (e) => {
833
907
  let t = e.document;
834
- if (!e.customElements.get(K)) {
835
- if (Y.has(t)) return Q(e, K);
836
- Y.add(t);
908
+ if (!e.customElements.get(W)) {
909
+ if (q.has(t)) return Z(e, W);
910
+ q.add(t);
837
911
  try {
838
- await ye(e);
912
+ await ze(e);
839
913
  } catch (e) {
840
- throw Y.delete(t), e;
914
+ throw q.delete(t), e;
841
915
  }
842
916
  }
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);
917
+ }, Le = () => typeof window < "u" && window.__KACHING_DEV__ !== void 0, Re = () => Le() ? Fe : Ie, ze = async (e) => {
918
+ let t = e.document, n = Re();
919
+ if (t.querySelector(`script[src="${n}"]`)) return Z(e, W);
920
+ let r = Be(t);
921
+ if (r && await Y(t, r)) return Z(e, W);
848
922
  let i = t.createElement("script");
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) => {
923
+ return i.src = n, await X(t, i), Z(e, W);
924
+ }, Be = (e) => {
925
+ let t = e.querySelectorAll(`link[rel="modulepreload"][href$="${K}"]`);
926
+ return Array.from(t, (e) => e.href).find(Ve);
927
+ }, Ve = (e) => {
854
928
  try {
855
- return new URL(e).pathname.endsWith(J);
929
+ return new URL(e).pathname.endsWith(K);
856
930
  } catch {
857
931
  return !1;
858
932
  }
859
- }, Se = async (e, t) => {
933
+ }, Y = async (e, t) => {
860
934
  let n = e.createElement("script");
861
935
  n.type = "module", n.setAttribute("crossorigin", "anonymous"), n.src = t;
862
936
  try {
863
- return await Z(e, n), !0;
937
+ return await X(e, n), !0;
864
938
  } catch {
865
939
  return n.remove(), !1;
866
940
  }
867
- }, Z = (e, t) => new Promise((n, r) => {
941
+ }, X = (e, t) => new Promise((n, r) => {
868
942
  t.onload = () => n(), t.onerror = () => r(/* @__PURE__ */ Error("Failed to load script")), e.head.appendChild(t);
869
- }), Q = (e, t) => new Promise((n, 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);
871
- });
872
- [
873
- "primaryBackground",
874
- "secondaryBackground",
875
- "primaryText",
876
- "secondaryText",
877
- "border",
878
- "overlay",
879
- "primaryAccent",
880
- "primaryAccentText",
881
- "badgeBackground",
882
- "badgeText",
883
- "error"
884
- ].map((e) => `brand_${e}`);
885
- var $ = /* @__PURE__ */ function(e) {
886
- return e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e;
887
- }({}), Ce = {
943
+ }), Z = (e, t) => new Promise((n, r) => {
944
+ 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 ${G}ms`)), G))]).then(() => n()).catch(r);
945
+ }), Q = {
888
946
  config: {
889
947
  shopifyDomain: "",
890
948
  moneyFormat: "${{amount}}",
@@ -1134,7 +1192,7 @@ var $ = /* @__PURE__ */ function(e) {
1134
1192
  dealBars: [
1135
1193
  {
1136
1194
  id: "single",
1137
- dealBarType: $.QuantityBreak,
1195
+ dealBarType: V.QuantityBreak,
1138
1196
  quantitySelector: !1,
1139
1197
  title: "Single",
1140
1198
  subtitle: "Standard price",
@@ -1159,7 +1217,7 @@ var $ = /* @__PURE__ */ function(e) {
1159
1217
  },
1160
1218
  {
1161
1219
  id: "duo",
1162
- dealBarType: $.QuantityBreak,
1220
+ dealBarType: V.QuantityBreak,
1163
1221
  quantitySelector: !1,
1164
1222
  title: "Duo",
1165
1223
  subtitle: "You save 20%",
@@ -1184,7 +1242,7 @@ var $ = /* @__PURE__ */ function(e) {
1184
1242
  },
1185
1243
  {
1186
1244
  id: "trio",
1187
- dealBarType: $.QuantityBreak,
1245
+ dealBarType: V.QuantityBreak,
1188
1246
  quantitySelector: !1,
1189
1247
  title: "Trio",
1190
1248
  subtitle: "You save 25%",
@@ -1280,10 +1338,29 @@ var $ = /* @__PURE__ */ function(e) {
1280
1338
  isNativeBundle: !1
1281
1339
  },
1282
1340
  otherProducts: [],
1341
+ mixAndMatchSwapProducts: [],
1283
1342
  mediaImages: [],
1284
1343
  collectionBreaksProducts: [],
1285
1344
  translations: {}
1286
- }, we = class extends HTMLElement {
1345
+ }, He = async (e, t) => {
1346
+ try {
1347
+ let n = await U(e, t);
1348
+ if (!n) return null;
1349
+ let { config: r, dealBlock: i, product: a, otherProducts: o, mediaImages: s, translations: c } = n.data, { mixAndMatchSwapProducts: l, collectionBreaksProducts: u } = await n.modalProducts;
1350
+ return {
1351
+ config: r,
1352
+ dealBlock: i,
1353
+ product: a,
1354
+ otherProducts: o,
1355
+ mixAndMatchSwapProducts: l,
1356
+ mediaImages: s,
1357
+ collectionBreaksProducts: u,
1358
+ translations: c
1359
+ };
1360
+ } catch (e) {
1361
+ return console.error(e), null;
1362
+ }
1363
+ }, Ue = class extends HTMLElement {
1287
1364
  constructor(...e) {
1288
1365
  super(...e), this.innerElement = null, this.handleItemsChanged = null, this.initializeId = 0;
1289
1366
  }
@@ -1301,13 +1378,13 @@ var $ = /* @__PURE__ */ function(e) {
1301
1378
  async initialize() {
1302
1379
  let e = ++this.initializeId;
1303
1380
  if (this.cleanup(), this.hasAttribute("demo")) {
1304
- if (await X(window), e !== this.initializeId) return;
1305
- this.renderInnerElement(Ce);
1381
+ if (await J(window), e !== this.initializeId) return;
1382
+ $(this.renderInnerElement(Q), Q);
1306
1383
  return;
1307
1384
  }
1308
1385
  let t = this.getAttribute("shop-domain"), n = this.getAttribute("storefront-token"), r = this.getAttribute("product-id");
1309
1386
  if (!t || !n || !r) return;
1310
- let [i] = await Promise.all([G({
1387
+ let [i] = await Promise.all([U({
1311
1388
  shopifyDomain: t,
1312
1389
  storefrontAccessToken: n
1313
1390
  }, {
@@ -1316,29 +1393,31 @@ var $ = /* @__PURE__ */ function(e) {
1316
1393
  abTestVariantId: this.getAttribute("ab-test-variant-id") ?? void 0,
1317
1394
  country: this.getAttribute("country")?.toUpperCase() ?? void 0,
1318
1395
  language: this.getAttribute("language")?.toUpperCase() ?? void 0
1319
- }), X(window)]);
1320
- i && e === this.initializeId && this.renderInnerElement(i);
1396
+ }), J(window)]);
1397
+ if (!i || e !== this.initializeId) return;
1398
+ let a = this.renderInnerElement(i.data), o = await i.modalProducts;
1399
+ e === this.initializeId && this.innerElement === a && $(a, o);
1321
1400
  }
1322
1401
  renderInnerElement(e) {
1323
- let { config: t, dealBlock: n, product: r, otherProducts: i, mediaImages: a, collectionBreaksProducts: o, translations: s } = e;
1324
- this.innerElement = document.createElement("kaching-bundles-block"), this.innerElement.setAttribute("deal-block-id", n.id), this.innerElement.setAttribute("config", JSON.stringify(t)), this.innerElement.setAttribute("deal-block", JSON.stringify(n)), this.innerElement.setAttribute("media-images", JSON.stringify(a ?? [])), this.innerElement.setAttribute("product", JSON.stringify(r)), this.innerElement.setAttribute("other-products", JSON.stringify(i ?? [])), this.innerElement.setAttribute("collection-breaks-products", JSON.stringify(o ?? [])), this.innerElement.setAttribute("translations", JSON.stringify(s ?? {}));
1325
- let c = this.getAttribute("selected-variant-id");
1326
- this.innerElement.setAttribute("current-variant-id", String(c ? c.split("/").pop() : r.variants[0].id)), this.hasAttribute("compact") && this.innerElement.setAttribute("compact", "");
1327
- let l = this.innerElement, u = () => {
1328
- if (this.innerElement !== l) return;
1329
- let e = l.items();
1402
+ let { config: t, dealBlock: n, product: r, otherProducts: i, mediaImages: a, translations: o } = e;
1403
+ this.innerElement = document.createElement("kaching-bundles-block"), this.innerElement.setAttribute("deal-block-id", n.id), this.innerElement.setAttribute("config", JSON.stringify(t)), this.innerElement.setAttribute("deal-block", JSON.stringify(n)), this.innerElement.setAttribute("media-images", JSON.stringify(a ?? [])), this.innerElement.setAttribute("product", JSON.stringify(r)), this.innerElement.setAttribute("other-products", JSON.stringify(i ?? [])), this.innerElement.setAttribute("translations", JSON.stringify(o ?? {}));
1404
+ let s = this.getAttribute("selected-variant-id");
1405
+ this.innerElement.setAttribute("current-variant-id", String(s ? s.split("/").pop() : r.variants[0].id)), this.hasAttribute("compact") && this.innerElement.setAttribute("compact", "");
1406
+ let c = this.innerElement, l = () => {
1407
+ if (this.innerElement !== c) return;
1408
+ let e = c.items();
1330
1409
  e && this.dispatchEvent(new CustomEvent("items-changed", {
1331
1410
  detail: { items: e },
1332
1411
  bubbles: !0
1333
1412
  }));
1334
1413
  };
1335
1414
  this.handleItemsChanged = (e) => {
1336
- e.stopPropagation(), u();
1415
+ e.stopPropagation(), l();
1337
1416
  };
1338
- let d = this.handleItemsChanged;
1339
- l.addEventListener("kaching-bundles-block-loaded", () => {
1340
- this.innerElement === l && (l.addEventListener("items-changed", d), this.dispatchEvent(new CustomEvent("loaded", { bubbles: !0 })));
1341
- }, { once: !0 }), this.appendChild(this.innerElement);
1417
+ let u = this.handleItemsChanged;
1418
+ return c.addEventListener("kaching-bundles-block-loaded", () => {
1419
+ this.innerElement === c && (c.addEventListener("items-changed", u), this.dispatchEvent(new CustomEvent("loaded", { bubbles: !0 })));
1420
+ }, { once: !0 }), this.appendChild(c), c;
1342
1421
  }
1343
1422
  cleanup() {
1344
1423
  this.handleItemsChanged && this.innerElement && (this.innerElement.removeEventListener("items-changed", this.handleItemsChanged), this.handleItemsChanged = null), this.innerElement &&= (this.innerElement.remove(), null);
@@ -1352,6 +1431,8 @@ var $ = /* @__PURE__ */ function(e) {
1352
1431
  disconnectedCallback() {
1353
1432
  this.cleanup(), this.initializeId++;
1354
1433
  }
1434
+ }, $ = (e, { mixAndMatchSwapProducts: t, collectionBreaksProducts: n }) => {
1435
+ t.length && e.setAttribute("mix-and-match-swap-products", JSON.stringify(t)), e.setAttribute("collection-breaks-products", JSON.stringify(n));
1355
1436
  };
1356
- customElements.define("kaching-bundle-component", we);
1357
- export { G as fetchKachingBundlesData };
1437
+ customElements.define("kaching-bundle-component", Ue);
1438
+ export { He as fetchKachingBundlesData };