@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,24 +1,80 @@
1
1
  import { useEffect as e, useLayoutEffect as t, useRef as n, useState as r } from "react";
2
2
  import { jsx as i } from "react/jsx-runtime";
3
- // ../bundles-storefront-api/dist/buildMarketMoneyFormat.js
4
- var a = (e, { language: t, country: n }) => {
5
- let r = l(t, n), i = new Intl.NumberFormat(r, {
3
+ [
4
+ "primaryBackground",
5
+ "secondaryBackground",
6
+ "primaryText",
7
+ "secondaryText",
8
+ "border",
9
+ "overlay",
10
+ "primaryAccent",
11
+ "primaryAccentText",
12
+ "badgeBackground",
13
+ "badgeText",
14
+ "error"
15
+ ].map((e) => `brand_${e}`);
16
+ var a = /* @__PURE__ */ function(e) {
17
+ return e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e;
18
+ }({}), o = (e, t) => e.selectedVariants?.find((e) => e.productId === t)?.variantIds, s = (e, t) => o(e, t) !== void 0, c = (e, t, n) => o(e, t)?.includes(n) ?? !0, l = (e, t) => s(e, t.id) ? t.variants.filter((n) => c(e, t.id, n.id)).map((e) => e.id) : void 0, u = (e, t) => {
19
+ if (!t) return e;
20
+ let n = e.variants.filter((e) => t.includes(e.id)), r = e.options.map((e, t) => ({
21
+ ...e,
22
+ optionValues: e.optionValues.filter((e) => n.some((n) => n.options[t] === e.name))
23
+ })), i = n.some((t) => t.id === e.selectedVariantId) ? e.selectedVariantId : n[0]?.id ?? e.selectedVariantId;
24
+ return {
25
+ ...e,
26
+ variants: n,
27
+ options: r,
28
+ selectedVariantId: i
29
+ };
30
+ }, d = (e, t) => f(e) ? p(e, t, m(e)) : t, f = (e) => !!e.selectedVariants?.length, p = (e, t, n) => t.flatMap((t) => {
31
+ let r = l(e, t);
32
+ if (!r) return [t];
33
+ let i = u(t, [...r, ...t.variants.map((e) => e.id).filter((e) => n.has(e))]);
34
+ return i.variants.length ? [i] : [];
35
+ }), m = (e) => new Set([
36
+ ...e.dealBars.flatMap(h),
37
+ ...(e.progressiveGifts?.gifts ?? []).flatMap((e) => e.variantGIDs ?? []),
38
+ ...(e.checkboxUpsells?.upsells ?? []).flatMap((e) => e.variantGIDs ?? [])
39
+ ].map(_)), h = (e) => [
40
+ ...e.freeGifts.flatMap((e) => e.variantGIDs ?? []),
41
+ ...e.upsells.flatMap((e) => e.variantGIDs ?? []),
42
+ ...(e.multipleGiftsSelectors ?? []).flatMap((e) => e.products.flatMap((e) => e.variantGIDs ?? [])),
43
+ ...g(e)
44
+ ], g = (e) => {
45
+ switch (e.dealBarType) {
46
+ case a.Bundle: return e.bundleProducts.flatMap((e) => e.productGID === "default" ? [] : e.variantGIDs ?? []);
47
+ case a.MixAndMatch: return e.bundleProducts.flatMap((e) => [...e.productGID === "default" ? [] : e.variantGIDs ?? [], ...(e.selectedProducts ?? []).flatMap((e) => e.variantGIDs ?? [])]);
48
+ default: return [];
49
+ }
50
+ }, _ = (e) => Number(e.split("/").pop()), v = (e, t, n) => {
51
+ let r = (e) => n !== void 0 && c(e, t.id, n), i = e.filter((e) => o(e, t.id)?.some((e) => t.variants.some((t) => t.id === e))), a = i.filter(r), s = [...a], l = i.filter((e) => !a.includes(e)), u = e.filter((e) => e.blockVisibility === "selected-products");
52
+ for (let e of u) e.selectedProductIds.map(Number).includes(t.id) && s.push(e);
53
+ let d = e.filter((e) => e.blockVisibility === "selected-collections");
54
+ for (let e of d) t.collectionIds.some((t) => e.selectedCollectionIds.map(Number).includes(t)) && s.push(e);
55
+ let f = e.filter((e) => e.blockVisibility === "excluded-products");
56
+ for (let e of f) !e.excludedProductIds.map(Number).includes(t.id) && !(e.excludedCollectionIds || []).some((e) => t.collectionIds.includes(e)) && s.push(e);
57
+ let p = e.filter((e) => e.blockVisibility === "all-products");
58
+ for (let e of p) s.push(e);
59
+ return n === void 0 ? s : [...s, ...l];
60
+ }, y = (e, { language: t, country: n }) => {
61
+ let r = C(t, n), i = new Intl.NumberFormat(r, {
6
62
  style: "currency",
7
63
  currency: e,
8
64
  currencyDisplay: "narrowSymbol"
9
- }).formatToParts(1234567.89), a = i.find((e) => e.type === "decimal")?.value, s = d(u(i.find((e) => e.type === "group")?.value), a, i.some((e) => e.type === "fraction")), f = i.findIndex(c), p = i.findLastIndex(c);
65
+ }).formatToParts(1234567.89), a = i.find((e) => e.type === "decimal")?.value, o = T(w(i.find((e) => e.type === "group")?.value), a, i.some((e) => e.type === "fraction")), s = i.findIndex(S), c = i.findLastIndex(S);
10
66
  return [
11
- ...i.slice(0, f).map(o),
12
- s,
13
- ...i.slice(p + 1).map(o)
67
+ ...i.slice(0, s).map(b),
68
+ o,
69
+ ...i.slice(c + 1).map(b)
14
70
  ].join("");
15
- }, o = (e) => s(e.value), s = (e) => e.replace(/\s/g, " "), c = (e) => e.type === "integer" || e.type === "group" || e.type === "decimal" || e.type === "fraction", l = (e, t) => e && t ? `${e}-${t.toUpperCase()}` : e || (t ? t.toUpperCase() : "en"), u = (e) => e === void 0 ? void 0 : s(e).replace(/’/g, "'"), d = (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}}", f = ({ country: e, language: t }) => {
71
+ }, b = (e) => x(e.value), x = (e) => e.replace(/\s/g, " "), S = (e) => e.type === "integer" || e.type === "group" || e.type === "decimal" || e.type === "fraction", C = (e, t) => e && t ? `${e}-${t.toUpperCase()}` : e || (t ? t.toUpperCase() : "en"), w = (e) => e === void 0 ? void 0 : x(e).replace(/’/g, "'"), T = (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}}", E = ({ country: e, language: t }) => {
16
72
  let n = [];
17
73
  return e && n.push(`country: ${e}`), t && n.push(`language: ${t}`), n.length > 0 ? `@inContext(${n.join(", ")})` : "";
18
- }, p = async (e, { useExternalMetafieldNamespace: t, useMetaobjects: n }) => n ? h(e, t) : m(e, t), m = async (e, t) => {
74
+ }, D = async (e, { useExternalMetafieldNamespace: t, useMetaobjects: n }) => n ? te(e, t) : ee(e, t), ee = async (e, t) => {
19
75
  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;
20
76
  return n ? JSON.parse(n) : [];
21
- }, h = async (e, t) => {
77
+ }, te = async (e, t) => {
22
78
  let n = t ? "app--2935586817--deal_block" : "$app:deal_block", r = [], i = null;
23
79
  for (;;) {
24
80
  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: {
@@ -47,14 +103,14 @@ var a = (e, { language: t, country: n }) => {
47
103
  "badgeText",
48
104
  "error"
49
105
  ].map((e) => `brand_${e}`);
50
- var g = /* @__PURE__ */ function(e) {
106
+ var O = /* @__PURE__ */ function(e) {
51
107
  return e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e;
52
- }({}), _ = async (e, { country: t, language: n, blockVisibility: r, excludedProductGIDs: i, selectedProductGIDs: a, selectedCollectionGIDs: o, limit: s = 1e3 }) => {
108
+ }({}), k = async (e, { country: t, language: n, blockVisibility: r, excludedProductGIDs: i, selectedProductGIDs: a, selectedCollectionGIDs: o, limit: s = 1e3 }) => {
53
109
  switch (r) {
54
110
  case "selected-products": return a.slice(0, s);
55
111
  case "all-products":
56
112
  case "excluded-products": {
57
- let a = f({
113
+ let a = E({
58
114
  country: t,
59
115
  language: n
60
116
  }), o = [], c = null;
@@ -85,7 +141,7 @@ var g = /* @__PURE__ */ function(e) {
85
141
  return o;
86
142
  }
87
143
  case "selected-collections": {
88
- let r = f({
144
+ let r = E({
89
145
  country: t,
90
146
  language: n
91
147
  }), i = (await e.query(`
@@ -107,16 +163,16 @@ var g = /* @__PURE__ */ function(e) {
107
163
  return Array.from(new Set(i)).slice(0, s);
108
164
  }
109
165
  }
110
- }, v = "\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", y = 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: p, variantImageTransform: m = {
166
+ }, A = "\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", j = 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 = {
111
167
  maxWidth: 200,
112
168
  maxHeight: 200
113
169
  } }) => {
114
170
  if (!r.length) return [];
115
- let h = r.map((e) => typeof e == "string" && e.startsWith("gid://") ? e : `gid://shopify/Product/${e}`), g = f({
171
+ let m = r.map((e) => typeof e == "string" && e.startsWith("gid://") ? e : `gid://shopify/Product/${e}`), h = E({
116
172
  country: t,
117
173
  language: n
118
- }), _ = `
119
- query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $includeProductRating: Boolean!, $includeProductSubtitle: Boolean!, $includeProductTabFields: Boolean!, $subtitleNamespace: String!, $subtitleKey: String!, $metafieldNamespace: String!, $variantImageTransform: ImageTransformInput) ${g} {
174
+ }), g = `
175
+ query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $includeProductRating: Boolean!, $includeProductSubtitle: Boolean!, $includeProductTabFields: Boolean!, $subtitleNamespace: String!, $subtitleKey: String!, $metafieldNamespace: String!, $variantImageTransform: ImageTransformInput) ${h} {
120
176
  shop {
121
177
  currencyRateConstant: metafield(namespace: $metafieldNamespace, key: "currency_rate_constant") {
122
178
  value
@@ -150,7 +206,7 @@ var g = /* @__PURE__ */ function(e) {
150
206
  }
151
207
  variants(first: 250) {
152
208
  nodes {
153
- ${v}
209
+ ${A}
154
210
  }
155
211
  }
156
212
  collections(first: 50) {
@@ -216,50 +272,50 @@ var g = /* @__PURE__ */ function(e) {
216
272
  }
217
273
  }
218
274
  }
219
- `, y = u ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles", C = l.indexOf("."), w = l.slice(0, C), T = l.slice(C + 1), E = [], D = Math.min(d, 250);
220
- for (let e = 0; e < h.length; e += D) E.push(h.slice(e, e + D));
221
- let O = 1, k = async (n) => {
222
- let [r, l] = await Promise.all([e.query(_, { variables: {
275
+ `, _ = u ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles", v = l.indexOf("."), y = l.slice(0, v), b = l.slice(v + 1), x = [], S = Math.min(d, 250);
276
+ for (let e = 0; e < m.length; e += S) x.push(m.slice(e, e + S));
277
+ let C = 1, w = async (n) => {
278
+ let [r, l] = await Promise.all([e.query(g, { variables: {
223
279
  productGIDs: n,
224
280
  includeSellingPlans: i,
225
281
  includeAvailableQuantity: a,
226
282
  includeProductRating: o,
227
283
  includeProductSubtitle: s,
228
284
  includeProductTabFields: c,
229
- subtitleNamespace: w,
230
- subtitleKey: T,
231
- metafieldNamespace: y,
232
- variantImageTransform: m
233
- } }), c ? b(e, t, n) : null]);
234
- return r.shop.currencyRateConstant && (O = JSON.parse(r.shop.currencyRateConstant.value).amount / 1e6), l ? { nodes: r.nodes.map((e) => e && {
285
+ subtitleNamespace: y,
286
+ subtitleKey: b,
287
+ metafieldNamespace: _,
288
+ variantImageTransform: p
289
+ } }), c ? ne(e, t, n) : null]);
290
+ return r.shop.currencyRateConstant && (C = JSON.parse(r.shop.currencyRateConstant.value).amount / 1e6), l ? { nodes: r.nodes.map((e) => e && {
235
291
  ...e,
236
292
  productType: l.get(e.id)
237
293
  }) } : r;
238
- }, A;
239
- if (p) {
240
- let e = await Promise.allSettled(E.map(k));
241
- for (let t of e) t.status === "rejected" && p(t.reason instanceof Error ? t.reason : Error(String(t.reason)));
242
- A = e.filter((e) => e.status === "fulfilled").flatMap((e) => e.value.nodes);
243
- } else A = (await Promise.all(E.map(k))).flatMap((e) => e.nodes);
244
- let j = A.filter((e) => e != null);
245
- if (p) {
246
- let t = await Promise.allSettled(j.map(async (t) => S(await x(e, t, {
294
+ }, T;
295
+ if (f) {
296
+ let e = await Promise.allSettled(x.map(w));
297
+ for (let t of e) t.status === "rejected" && f(t.reason instanceof Error ? t.reason : Error(String(t.reason)));
298
+ T = e.filter((e) => e.status === "fulfilled").flatMap((e) => e.value.nodes);
299
+ } else T = (await Promise.all(x.map(w))).flatMap((e) => e.nodes);
300
+ let D = T.filter((e) => e != null);
301
+ if (f) {
302
+ let t = await Promise.allSettled(D.map(async (t) => N(await M(e, t, {
247
303
  includeSellingPlans: i,
248
304
  includeAvailableQuantity: a,
249
- variantImageTransform: m
250
- }, g), e.shopifyDomain, O))), n = [];
251
- for (let e of t) e.status === "fulfilled" ? n.push(e.value) : p(e.reason instanceof Error ? e.reason : Error(String(e.reason)));
305
+ variantImageTransform: p
306
+ }, h), e.shopifyDomain, C))), n = [];
307
+ for (let e of t) e.status === "fulfilled" ? n.push(e.value) : f(e.reason instanceof Error ? e.reason : Error(String(e.reason)));
252
308
  return n;
253
309
  }
254
- return (await Promise.all(j.map((t) => x(e, t, {
310
+ return (await Promise.all(D.map((t) => M(e, t, {
255
311
  includeSellingPlans: i,
256
312
  includeAvailableQuantity: a,
257
- variantImageTransform: m
258
- }, g)))).map((t) => S(t, e.shopifyDomain, O));
259
- }, b = async (e, t, n) => {
313
+ variantImageTransform: p
314
+ }, h)))).map((t) => N(t, e.shopifyDomain, C));
315
+ }, ne = async (e, t, n) => {
260
316
  try {
261
317
  let r = await e.query(`
262
- query FetchProductTypes($productGIDs: [ID!]!) ${f({ country: t })} {
318
+ query FetchProductTypes($productGIDs: [ID!]!) ${E({ country: t })} {
263
319
  nodes(ids: $productGIDs) {
264
320
  ... on Product {
265
321
  id
@@ -272,7 +328,7 @@ var g = /* @__PURE__ */ function(e) {
272
328
  } catch (e) {
273
329
  return console.error(e), null;
274
330
  }
275
- }, x = async (e, t, n, r = "") => {
331
+ }, M = async (e, t, n, r = "") => {
276
332
  if (t.variants.nodes.length < 250) return t;
277
333
  let i = /* @__PURE__ */ new Set(), a = [], o = [], s = async (s) => {
278
334
  let c = !0, l = null;
@@ -282,7 +338,7 @@ var g = /* @__PURE__ */ function(e) {
282
338
  product(id: $productGID) {
283
339
  variants(first: 250, after: $cursor, reverse: $reverse) {
284
340
  nodes {
285
- ${v}
341
+ ${A}
286
342
  }
287
343
  pageInfo {
288
344
  endCursor
@@ -308,7 +364,7 @@ var g = /* @__PURE__ */ function(e) {
308
364
  }
309
365
  };
310
366
  return await Promise.all([s(!1), s(!0)]), t.variants.nodes = [...a, ...o.reverse()], t;
311
- }, S = (e, t, n) => {
367
+ }, N = (e, t, n) => {
312
368
  let r = e.variants.nodes.map(({ unitPriceMeasurement: e, ...t }) => ({
313
369
  id: Number(t.id.split("/").pop()),
314
370
  availableForSale: t.availableForSale,
@@ -346,7 +402,7 @@ var g = /* @__PURE__ */ function(e) {
346
402
  defaultName: e.name,
347
403
  name: e.name,
348
404
  position: t + 1,
349
- optionValues: T(n, t, r)
405
+ optionValues: ae(n, t, r)
350
406
  };
351
407
  }), a = (e) => {
352
408
  let t = e.priceAdjustments[0];
@@ -394,46 +450,31 @@ var g = /* @__PURE__ */ function(e) {
394
450
  text3: e.metafield3?.value || null,
395
451
  text4: e.metafield4?.value || null
396
452
  },
397
- rating: C(e.reviewsRating, e.reviewsRatingCount),
453
+ rating: re(e.reviewsRating, e.reviewsRatingCount),
398
454
  subtitle: e.subtitle?.value || null,
399
455
  productType: e.productType || null,
400
456
  categoryGid: e.category?.id ?? null,
401
457
  tags: e.tags ?? []
402
458
  };
403
- }, C = (e, t) => {
459
+ }, re = (e, t) => {
404
460
  if (!e) return null;
405
- let n = w(e.value);
461
+ let n = ie(e.value);
406
462
  if (n === null) return null;
407
463
  let r = Number(t?.value);
408
464
  return {
409
465
  value: n,
410
466
  count: Number.isInteger(r) && r > 0 ? r : null
411
467
  };
412
- }, w = (e) => {
468
+ }, ie = (e) => {
413
469
  try {
414
470
  let { value: t, scale_max: n } = JSON.parse(e), r = Number(t) / Number(n) * 5;
415
471
  return Number.isFinite(r) && r > 0 ? Math.min(5, r) : null;
416
472
  } catch {
417
473
  return null;
418
474
  }
419
- }, T = (e, t, n) => e.filter((e) => n.filter((n) => n.options[t] === e.name).length > 0);
420
- [
421
- "primaryBackground",
422
- "secondaryBackground",
423
- "primaryText",
424
- "secondaryText",
425
- "border",
426
- "overlay",
427
- "primaryAccent",
428
- "primaryAccentText",
429
- "badgeBackground",
430
- "badgeText",
431
- "error"
432
- ].map((e) => `brand_${e}`);
433
- // ../bundles-storefront-api/dist/fetchGlobalConfig.js
434
- var E = "app--2935586817", D = async (e, { language: t, country: n, useExternalMetafieldNamespace: r }) => {
435
- let i = r ? `${E}--kaching_bundles` : "$app:kaching_bundles", o = r ? E : "$app", s = f({ country: n }), { localization: { country: { currency: { isoCode: c } } }, shop: { moneyFormat: l, paymentSettings: { currencyCode: u }, currencyRateConstant: d, primaryDomain: p, settingsMetafield: m } } = await e.query(`
436
- query config($metafieldNamespace: String!, $settingsNamespace: String!) ${s} {
475
+ }, ae = (e, t, n) => e.filter((e) => n.filter((n) => n.options[t] === e.name).length > 0), P = "app--2935586817", oe = async (e, { language: t, country: n, useExternalMetafieldNamespace: r }) => {
476
+ let i = r ? `${P}--kaching_bundles` : "$app:kaching_bundles", a = r ? P : "$app", o = E({ country: n }), { localization: { country: { currency: { isoCode: s } } }, shop: { moneyFormat: c, paymentSettings: { currencyCode: l }, currencyRateConstant: u, primaryDomain: d, settingsMetafield: f } } = await e.query(`
477
+ query config($metafieldNamespace: String!, $settingsNamespace: String!) ${o} {
437
478
  localization {
438
479
  country {
439
480
  currency {
@@ -459,30 +500,30 @@ var E = "app--2935586817", D = async (e, { language: t, country: n, useExternalM
459
500
  }
460
501
  `, { variables: {
461
502
  metafieldNamespace: i,
462
- settingsNamespace: o
463
- } }), h = c === u ? l : a(c, {
503
+ settingsNamespace: a
504
+ } }), p = s === l ? c : y(s, {
464
505
  language: t,
465
506
  country: n
466
- }), g = d ? O(d.value) : 1, _ = m ? JSON.parse(m.value) : null, v = _?.feature_flags ?? {}, y = _?.custom_selectors ?? {};
507
+ }), m = u ? se(u.value) : 1, h = f ? JSON.parse(f.value) : null, g = h?.feature_flags ?? {}, _ = h?.custom_selectors ?? {};
467
508
  return {
468
- shopifyDomain: p.host,
469
- moneyFormat: h,
509
+ shopifyDomain: d.host,
510
+ moneyFormat: p,
470
511
  locale: t?.toLowerCase() || "en",
471
512
  liquidLocale: t?.toLowerCase() || "en",
472
513
  country: n ?? "US",
473
- currencyRate: g,
514
+ currencyRate: m,
474
515
  marketId: 0,
475
516
  productId: null,
476
- storefrontAccessToken: _?.storefront_access_token ?? null,
477
- includeSellingPlans: _?.include_selling_plans ?? !1,
478
- includeAvailableQuantity: _?.include_available_quantity ?? !1,
479
- customApiHost: _?.custom_api_host ?? null,
480
- keepQuantityInput: _?.keep_quantity_input ?? !1,
481
- ignoreDeselect: _?.ignore_deselect ?? !1,
482
- ignoreUnitPrice: _?.ignore_unit_price ?? !1,
483
- requireCustomerLogin: _?.require_customer_login ?? !1,
484
- abTestsRunning: _?.ab_tests_running ?? !1,
485
- webPixel: _?.web_pixel ?? !1,
517
+ storefrontAccessToken: h?.storefront_access_token ?? null,
518
+ includeSellingPlans: h?.include_selling_plans ?? !1,
519
+ includeAvailableQuantity: h?.include_available_quantity ?? !1,
520
+ customApiHost: h?.custom_api_host ?? null,
521
+ keepQuantityInput: h?.keep_quantity_input ?? !1,
522
+ ignoreDeselect: h?.ignore_deselect ?? !1,
523
+ ignoreUnitPrice: h?.ignore_unit_price ?? !1,
524
+ requireCustomerLogin: h?.require_customer_login ?? !1,
525
+ abTestsRunning: h?.ab_tests_running ?? !1,
526
+ webPixel: h?.web_pixel ?? !1,
486
527
  b2bCustomer: !1,
487
528
  isLoggedIn: !1,
488
529
  preview: !1,
@@ -514,17 +555,17 @@ var E = "app--2935586817", D = async (e, { language: t, country: n, useExternalM
514
555
  "system.numbers_only": "Only numbers are allowed."
515
556
  },
516
557
  customSelectors: {
517
- quantity: y.quantity ?? null,
518
- addToCartButton: y.add_to_cart_button ?? null,
519
- variantPicker: y.variant_picker ?? null,
520
- price: y.price ?? null,
521
- priceCompare: y.price_compare ?? null
558
+ quantity: _.quantity ?? null,
559
+ addToCartButton: _.add_to_cart_button ?? null,
560
+ variantPicker: _.variant_picker ?? null,
561
+ price: _.price ?? null,
562
+ priceCompare: _.price_compare ?? null
522
563
  },
523
- shopCustomStyles: _?.shop_custom_styles ?? "",
524
- featureFlags: v,
525
- brandColors: _?.brand_colors ?? null
564
+ shopCustomStyles: h?.shop_custom_styles ?? "",
565
+ featureFlags: g,
566
+ brandColors: h?.brand_colors ?? null
526
567
  };
527
- }, O = (e) => JSON.parse(e).amount / 1e6, k = async (e, t, n = 200) => {
568
+ }, se = (e) => JSON.parse(e).amount / 1e6, ce = async (e, t, n = 200) => {
528
569
  let r = [...new Set(t.filter(Boolean).filter((e) => !e.startsWith("placeholder")))];
529
570
  if (r.length === 0) return [];
530
571
  let i = [];
@@ -536,10 +577,10 @@ var E = "app--2935586817", D = async (e, { language: t, country: n, useExternalM
536
577
  gid: e.id,
537
578
  url: e.image.url
538
579
  }] : []);
539
- }, A = 100, j = async (e, { dealBlock: t, country: n, language: r }) => {
540
- let i = [...new Set(t.dealBars.flatMap((e) => e.dealBarType === g.MixAndMatch ? e.bundleProducts : []).flatMap((e) => (e.selectedCollections ?? []).map((e) => e.id)))];
580
+ }, le = 100, ue = async (e, { dealBlock: t, country: n, language: r }) => {
581
+ let i = [...new Set(t.dealBars.flatMap((e) => e.dealBarType === O.MixAndMatch ? e.bundleProducts : []).flatMap((e) => (e.selectedCollections ?? []).map((e) => e.id)))];
541
582
  if (i.length === 0) return [];
542
- let a = f({
583
+ let a = E({
543
584
  country: n,
544
585
  language: r
545
586
  }), o = await e.query(`
@@ -547,7 +588,7 @@ var E = "app--2935586817", D = async (e, { language: t, country: n, useExternalM
547
588
  nodes(ids: $collectionGIDs) {
548
589
  ... on Collection {
549
590
  id
550
- products(first: ${A}) {
591
+ products(first: ${le}) {
551
592
  nodes {
552
593
  id
553
594
  variants(first: 1) {
@@ -562,77 +603,77 @@ var E = "app--2935586817", D = async (e, { language: t, country: n, useExternalM
562
603
  }
563
604
  `, { variables: { collectionGIDs: i } });
564
605
  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))];
565
- }, ee = (e) => [
566
- ...te(e),
567
- ...ne(e),
568
- ...re(e),
569
- ...ie(e),
570
- ...ae(e),
571
- ...oe(e),
572
- ...se(e),
573
- ...ce(e),
574
- ...le(e),
575
- ...ue(e),
576
- ...de(e),
606
+ }, de = (e) => [
607
+ ...F(e),
608
+ ...I(e),
609
+ ...L(e),
610
+ ...R(e),
611
+ ...z(e),
612
+ ...B(e),
613
+ ...V(e),
614
+ ...H(e),
577
615
  ...fe(e),
578
- ...M(e)
579
- ].filter((e) => e != null && !e.includes("placeholder")), te = (e) => e.dealBars.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), ne = (e) => e.dealBars.flatMap((e) => e.dealBarType === g.Bundle ? e.bundleProducts.map((e) => e.mediaImageGID) : []).filter((e) => e != null), re = (e) => e.dealBars.map(({ freeGifts: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), ie = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => (e || []).map((e) => e.mediaImageGID)).filter((e) => e != null), ae = (e) => e.dealBars.map(({ upsells: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), oe = (e) => e.swatchOptions ? e.swatchOptions.reduce((e, t) => {
616
+ ...pe(e),
617
+ ...me(e),
618
+ ...he(e),
619
+ ...ge(e)
620
+ ].filter((e) => e != null && !e.includes("placeholder")), F = (e) => e.dealBars.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), I = (e) => e.dealBars.flatMap((e) => e.dealBarType === O.Bundle ? e.bundleProducts.map((e) => e.mediaImageGID) : []).filter((e) => e != null), L = (e) => e.dealBars.map(({ freeGifts: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), R = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => (e || []).map((e) => e.mediaImageGID)).filter((e) => e != null), z = (e) => e.dealBars.map(({ upsells: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), B = (e) => e.swatchOptions ? e.swatchOptions.reduce((e, t) => {
580
621
  let n = t.images.map((e) => e.mediaImageGID).filter((e) => e != null);
581
622
  return [...e, ...n];
582
- }, []) : [], se = (e) => {
623
+ }, []) : [], V = (e) => {
583
624
  if (!e.collectionBreaksEnabled || !e.collectionBreaks) return [];
584
625
  let t = e.collectionBreaks.mediaImageGID;
585
626
  return t ? [t] : [];
586
- }, ce = (e) => e.progressiveGifts ? [
627
+ }, H = (e) => e.progressiveGifts ? [
587
628
  ...e.progressiveGifts.gifts?.map((e) => e.mediaImageGID) || [],
588
629
  e.progressiveGifts.style?.lockedMediaImageGID,
589
630
  e.progressiveGifts.dealBarStyle?.lockedMediaImageGID
590
- ].filter((e) => e != null) : [], le = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), ue = (e) => e.dealBars.map((e) => e.productPersonalisation?.mediaImageGID).filter((e) => e != null), de = (e) => {
631
+ ].filter((e) => e != null) : [], fe = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), pe = (e) => e.dealBars.map((e) => e.productPersonalisation?.mediaImageGID).filter((e) => e != null), me = (e) => {
591
632
  let t = e.dealBars.map((e) => e.highlights?.customIconGID).filter((e) => e != null), n = e.subscriptions?.highlights?.customIconGID;
592
633
  return n ? [...t, n] : t;
593
- }, fe = (e) => (e.badges || []).flatMap((e) => e.badgeType === "custom" && e.imageGID ? [e.imageGID] : []), M = (e) => !e.savingsSummaryEnabled || !e.savingsSummary ? [] : e.savingsSummary.customIconGID ? [e.savingsSummary.customIconGID] : [], N = (e, { includeMixAndMatchSwapProducts: t = !0 } = {}) => {
634
+ }, he = (e) => (e.badges || []).flatMap((e) => e.badgeType === "custom" && e.imageGID ? [e.imageGID] : []), ge = (e) => !e.savingsSummaryEnabled || !e.savingsSummary ? [] : e.savingsSummary.customIconGID ? [e.savingsSummary.customIconGID] : [], _e = (e, { includeMixAndMatchSwapProducts: t = !0 } = {}) => {
594
635
  let n = [
595
- ...P(e),
596
- ...F(e),
597
- ...I(e),
598
- ...L(e),
599
- ...R(e),
600
- ...z(e, t),
601
- ...B(e),
602
- ...V(e)
636
+ ...ve(e),
637
+ ...ye(e),
638
+ ...be(e),
639
+ ...xe(e),
640
+ ...Se(e),
641
+ ...Ce(e, t),
642
+ ...we(e),
643
+ ...Te(e)
603
644
  ];
604
645
  return Array.from(new Set(n.filter((e) => e != null)));
605
- }, P = (e) => e.dealBars.flatMap(({ freeGifts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), F = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => e ? e.flatMap((e) => e.products ? e.products.map((e) => e.id) : []) : []).filter((e) => e != null), I = (e) => e.progressiveGiftsEnabled && e.progressiveGifts?.gifts.map((e) => e.productGID).filter((e) => e != null) || [], L = (e) => e.dealBars.flatMap(({ upsells: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), R = (e) => e.dealBars.filter((e) => e.dealBarType === g.Bundle).flatMap(({ bundleProducts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null).filter((e) => e !== "default"), z = (e, t) => e.dealBars.filter((e) => e.dealBarType === g.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"), B = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.map((e) => e.productGID).filter((e) => e != null), V = (e) => e.dealBars.filter((e) => e.dealBarType === g.Sku).flatMap(({ productGID: e }) => e ? [e] : []), H = class extends Error {
646
+ }, ve = (e) => e.dealBars.flatMap(({ freeGifts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), ye = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => e ? e.flatMap((e) => e.products ? e.products.map((e) => e.id) : []) : []).filter((e) => e != null), be = (e) => e.progressiveGiftsEnabled && e.progressiveGifts?.gifts.map((e) => e.productGID).filter((e) => e != null) || [], xe = (e) => e.dealBars.flatMap(({ upsells: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), Se = (e) => e.dealBars.filter((e) => e.dealBarType === O.Bundle).flatMap(({ bundleProducts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null).filter((e) => e !== "default"), Ce = (e, t) => e.dealBars.filter((e) => e.dealBarType === O.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"), we = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.map((e) => e.productGID).filter((e) => e != null), Te = (e) => e.dealBars.filter((e) => e.dealBarType === O.Sku).flatMap(({ productGID: e }) => e ? [e] : []), U = class extends Error {
606
647
  constructor({ status: e, operationName: t, graphqlErrors: n }) {
607
648
  let r = n.length ? `: ${n.join("; ")}` : "";
608
649
  super(`Storefront API ${t ?? "query"} failed (HTTP ${e})${r}`), this.name = "StorefrontApiError", this.status = e, this.operationName = t, this.graphqlErrors = n;
609
650
  }
610
- }, pe = async (e, t) => {
651
+ }, Ee = async (e, t) => {
611
652
  let n = await e.text();
612
653
  if (!n) throw Error("Empty graphql response");
613
654
  let r;
614
655
  try {
615
656
  r = JSON.parse(n);
616
657
  } catch (n) {
617
- throw e.ok ? n : new H({
658
+ throw e.ok ? n : new U({
618
659
  status: e.status,
619
660
  operationName: t,
620
661
  graphqlErrors: []
621
662
  });
622
663
  }
623
- if (!e.ok || r.data === null || r.data === void 0) throw new H({
664
+ if (!e.ok || r.data === null || r.data === void 0) throw new U({
624
665
  status: e.status,
625
666
  operationName: t,
626
667
  graphqlErrors: (r.errors ?? []).map(({ message: e }) => e).filter(Boolean)
627
668
  });
628
669
  return r.data;
629
- }, me = class {
670
+ }, De = class {
630
671
  constructor(e, t) {
631
672
  this.storefrontApiVersion = "2026-07", this.storefrontAccessToken = t, this.shopifyDomain = e;
632
673
  }
633
674
  async query(e, t) {
634
675
  let n = t?.variables ?? {}, r = `https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`, i = e.match(/query\s+(\w+)/)?.[1];
635
- return i && (r += `?operation_name=${i}`), pe(await fetch(r, {
676
+ return i && (r += `?operation_name=${i}`), Ee(await fetch(r, {
636
677
  method: "POST",
637
678
  headers: {
638
679
  "Content-Type": "application/json",
@@ -644,28 +685,34 @@ var E = "app--2935586817", D = async (e, { language: t, country: n, useExternalM
644
685
  })
645
686
  }), i);
646
687
  }
647
- }, U = (e, t) => {
648
- let n = [], r = e.filter((e) => e.blockVisibility === "selected-products");
649
- for (let e of r) e.selectedProductIds.map(Number).includes(t.id) && n.push(e);
650
- let i = e.filter((e) => e.blockVisibility === "selected-collections");
651
- for (let e of i) t.collectionIds.some((t) => e.selectedCollectionIds.map(Number).includes(t)) && n.push(e);
652
- let a = e.filter((e) => e.blockVisibility === "excluded-products");
653
- for (let e of a) !e.excludedProductIds.map(Number).includes(t.id) && !(e.excludedCollectionIds || []).some((e) => t.collectionIds.includes(e)) && n.push(e);
654
- let o = e.filter((e) => e.blockVisibility === "all-products");
655
- for (let e of o) n.push(e);
656
- return n;
657
- }, he = async (e, t, { country: n, language: r }) => {
688
+ };
689
+ [
690
+ "primaryBackground",
691
+ "secondaryBackground",
692
+ "primaryText",
693
+ "secondaryText",
694
+ "border",
695
+ "overlay",
696
+ "primaryAccent",
697
+ "primaryAccentText",
698
+ "badgeBackground",
699
+ "badgeText",
700
+ "error"
701
+ ].map((e) => `brand_${e}`);
702
+ var W = /* @__PURE__ */ function(e) {
703
+ return e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e;
704
+ }({}), Oe = async (e, t, { country: n, language: r }) => {
658
705
  let i = t.collectionBreaks;
659
706
  if (!t.collectionBreaksEnabled || !i) return;
660
707
  let a;
661
- a = i.visibility === "deal-products" ? await _(e, {
708
+ a = i.visibility === "deal-products" ? await k(e, {
662
709
  country: n,
663
710
  language: r,
664
711
  blockVisibility: t.blockVisibility,
665
712
  excludedProductGIDs: (t.excludedProductIds || []).map((e) => `gid://shopify/Product/${e}`),
666
713
  selectedProductGIDs: (t.selectedProductIds || []).map((e) => `gid://shopify/Product/${e}`),
667
714
  selectedCollectionGIDs: (t.selectedCollectionIds || []).map((e) => `gid://shopify/Collection/${e}`)
668
- }) : await _(e, {
715
+ }) : await k(e, {
669
716
  country: n,
670
717
  language: r,
671
718
  blockVisibility: i.visibility,
@@ -673,14 +720,14 @@ var E = "app--2935586817", D = async (e, { language: t, country: n, useExternalM
673
720
  selectedProductGIDs: (i.selectedProducts || []).map(({ id: e }) => e),
674
721
  selectedCollectionGIDs: (i.selectedCollections || []).map(({ id: e }) => e)
675
722
  });
676
- let o = await y(e, {
723
+ let o = await j(e, {
677
724
  country: n,
678
725
  language: r,
679
726
  productIds: a.map((e) => Number(e.split("/").pop())),
680
727
  useExternalMetafieldNamespace: !0
681
728
  }), s = i.visibility === "deal-products" && t.blockVisibility === "excluded-products";
682
- return o = o.filter((e) => e.availableForSale && (!s || U([t], e).length > 0)), o;
683
- }, ge = ({ language: e, dealBlockId: t }) => {
729
+ return o = o.filter((e) => e.availableForSale && (!s || v([t], e).length > 0)), o;
730
+ }, ke = ({ language: e, dealBlockId: t }) => {
684
731
  let n = {
685
732
  "system.out_of_stock": "There's not enough items in our stock, please select smaller bundle.",
686
733
  "system.invalid_variant": "Sorry, this is not currently available.",
@@ -707,13 +754,13 @@ var E = "app--2935586817", D = async (e, { language: t, country: n, useExternalM
707
754
  "system.numbers_only": "Only numbers are allowed.",
708
755
  "system.personalisation_required_alert": "Please add personalisation for every item to continue.",
709
756
  "system.gifts_required_alert": "Please choose your free gifts"
710
- }, r = e ? _e(e) : void 0;
757
+ }, r = e ? Ae(e) : void 0;
711
758
  return {
712
759
  ...n,
713
760
  ...r?.system,
714
761
  ...r?.dealBlocks[t]
715
762
  };
716
- }, _e = (e) => {
763
+ }, Ae = (e) => {
717
764
  if (typeof document > "u") return;
718
765
  let t = document.querySelector("script#kaching-bundles-translations");
719
766
  if (!t?.textContent) return;
@@ -723,72 +770,99 @@ var E = "app--2935586817", D = async (e, { language: t, country: n, useExternalM
723
770
  } catch {
724
771
  return;
725
772
  }
726
- let r = W(e);
727
- return n.find((e) => W(e.locale) === r)?.translations;
728
- }, W = (e) => e.toLowerCase().replace(/_/g, "-"), ve = "2026-07", ye = async (e, { productId: t, dealBlockId: n, abTestVariantId: r, country: i = void 0, language: a = void 0 }) => {
773
+ let r = G(e);
774
+ return n.find((e) => G(e.locale) === r)?.translations;
775
+ }, G = (e) => e.toLowerCase().replace(/_/g, "-"), je = "2026-07", Me = async (e, { productId: t, dealBlockId: n, abTestVariantId: r, country: i = void 0, language: a = void 0 }) => {
729
776
  try {
730
- let o = [Number(t.split("/").pop())], s = new be(e);
777
+ let o = [Number(t.split("/").pop())], s = new Le(e);
731
778
  i ||= s.i18n?.country, a ||= s.i18n?.language;
732
- let c = await D(s, {
779
+ let c = await oe(s, {
733
780
  language: a,
734
781
  country: i,
735
782
  useExternalMetafieldNamespace: !0
736
783
  });
737
784
  s.shopifyDomain = c.shopifyDomain;
738
- let l = c.storefrontAccessToken ? new me(c.shopifyDomain, c.storefrontAccessToken) : s, [u, d] = await Promise.all([y(l, {
785
+ let l = c.storefrontAccessToken ? new De(c.shopifyDomain, c.storefrontAccessToken) : s, [u, f] = await Promise.all([j(l, {
739
786
  country: i,
740
787
  language: a,
741
788
  productIds: o,
742
789
  useExternalMetafieldNamespace: !0
743
- }), p(l, {
790
+ }), D(l, {
744
791
  useExternalMetafieldNamespace: !0,
745
792
  useMetaobjects: c.featureFlags.storefront_metaobjects
746
- })]), f = u[0];
747
- if (!f) return null;
748
- let m = U(d, f), h = n ? m.filter((e) => e.id === n || e.nanoId === n) : m, g = (r ? h.find((e) => e.abTestVariantId === r) : void 0) ?? h[0] ?? m[0];
793
+ })]), p = u[0];
794
+ if (!p) return null;
795
+ let m = v(f, p), h = n ? m.filter((e) => e.id === n || e.nanoId === n) : m, g = (r ? h.find((e) => e.abTestVariantId === r) : void 0) ?? h[0] ?? m[0];
749
796
  if (!g) return null;
750
- let _ = ee(g), [v, b, x, S] = await Promise.all([
751
- (async () => {
752
- let e = [];
753
- try {
754
- e = await j(l, {
755
- dealBlock: g,
756
- country: i,
757
- language: a
758
- });
759
- } catch (e) {
760
- console.error(e);
761
- }
762
- return y(l, {
763
- country: i,
764
- language: a,
765
- productIds: [.../* @__PURE__ */ new Set([...N(g), ...e])],
766
- useExternalMetafieldNamespace: !0
767
- });
768
- })(),
769
- k(l, _, 300),
770
- he(l, g, {
797
+ let _ = _e(g, { includeMixAndMatchSwapProducts: !1 }), y = Ne(l, g, {
798
+ otherProductGIDs: _,
799
+ country: i,
800
+ language: a
801
+ }), [b, x, S] = await Promise.all([
802
+ j(l, {
771
803
  country: i,
772
- language: a
804
+ language: a,
805
+ productIds: _,
806
+ useExternalMetafieldNamespace: !0
773
807
  }),
774
- ge({
808
+ ce(l, de(g), 300),
809
+ ke({
775
810
  language: a,
776
811
  dealBlockId: g.id
777
812
  })
778
813
  ]);
779
814
  return {
780
- product: f,
781
- dealBlock: g,
782
- config: c,
783
- otherProducts: v,
784
- mediaImages: b,
785
- collectionBreaksProducts: x ?? [],
786
- translations: S
815
+ data: {
816
+ config: c,
817
+ dealBlock: g,
818
+ product: p,
819
+ otherProducts: d(g, b),
820
+ mediaImages: x,
821
+ translations: S
822
+ },
823
+ modalProducts: y
787
824
  };
788
825
  } catch (e) {
789
826
  return console.error(e), null;
790
827
  }
791
- }, be = class {
828
+ }, Ne = async (e, t, n) => {
829
+ let [r, i] = await Promise.all([Pe(e, t, n), Ie(e, t, n)]);
830
+ return {
831
+ mixAndMatchSwapProducts: r,
832
+ collectionBreaksProducts: i
833
+ };
834
+ }, Pe = async (e, t, { otherProductGIDs: n, country: r, language: i }) => {
835
+ try {
836
+ let a = [];
837
+ try {
838
+ a = await ue(e, {
839
+ dealBlock: t,
840
+ country: r,
841
+ language: i
842
+ });
843
+ } catch (e) {
844
+ console.error(e);
845
+ }
846
+ let o = new Set(n), s = [.../* @__PURE__ */ new Set([...Fe(t), ...a])].filter((e) => !o.has(e));
847
+ return s.length ? d(t, await j(e, {
848
+ country: r,
849
+ language: i,
850
+ productIds: s,
851
+ useExternalMetafieldNamespace: !0
852
+ })) : [];
853
+ } catch (e) {
854
+ return console.error(e), [];
855
+ }
856
+ }, Fe = (e) => e.dealBars.flatMap((e) => e.dealBarType === W.MixAndMatch ? e.bundleProducts.flatMap((e) => (e.selectedProducts ?? []).map((e) => e.id)) : []), Ie = async (e, t, { country: n, language: r }) => {
857
+ try {
858
+ return await Oe(e, t, {
859
+ country: n,
860
+ language: r
861
+ }) ?? [];
862
+ } catch (e) {
863
+ return console.error(e), [];
864
+ }
865
+ }, Le = class {
792
866
  constructor(e) {
793
867
  this.storefront = e, this.shopifyDomain = "";
794
868
  }
@@ -801,7 +875,7 @@ var E = "app--2935586817", D = async (e, { language: t, country: n, useExternalM
801
875
  }
802
876
  if ("request" in this.storefront) return (await this.storefront.request(e, t)).data;
803
877
  if ("shopifyDomain" in this.storefront && "storefrontAccessToken" in this.storefront) {
804
- let n = await fetch(`https://${this.storefront.shopifyDomain}/api/${ve}/graphql.json`, {
878
+ let n = await fetch(`https://${this.storefront.shopifyDomain}/api/${je}/graphql.json`, {
805
879
  body: JSON.stringify({
806
880
  query: e,
807
881
  variables: t?.variables
@@ -831,64 +905,66 @@ var E = "app--2935586817", D = async (e, { language: t, country: n, useExternalM
831
905
  get i18n() {
832
906
  if ("i18n" in this.storefront) return this.storefront.i18n;
833
907
  }
834
- }, xe = ye, G = "kaching-bundles-block", K = 1e4, q = "/kaching-bundles-block.js", Se = "https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js", Ce = "https://bundles-integrations.kachingappz.app/kaching-bundles-block.js", J = /* @__PURE__ */ new WeakSet(), we = async (e) => {
908
+ }, Re = async (e, t) => {
909
+ try {
910
+ let n = await Me(e, t);
911
+ if (!n) return null;
912
+ let { config: r, dealBlock: i, product: a, otherProducts: o, mediaImages: s, translations: c } = n.data, { mixAndMatchSwapProducts: l, collectionBreaksProducts: u } = await n.modalProducts;
913
+ return {
914
+ config: r,
915
+ dealBlock: i,
916
+ product: a,
917
+ otherProducts: o,
918
+ mixAndMatchSwapProducts: l,
919
+ mediaImages: s,
920
+ collectionBreaksProducts: u,
921
+ translations: c
922
+ };
923
+ } catch (e) {
924
+ return console.error(e), null;
925
+ }
926
+ }, K = "kaching-bundles-block", q = 1e4, J = "/kaching-bundles-block.js", ze = "https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js", Be = "https://bundles-integrations.kachingappz.app/kaching-bundles-block.js", Y = /* @__PURE__ */ new WeakSet(), Ve = async (e) => {
835
927
  let t = e.document;
836
- if (!e.customElements.get(G)) {
837
- if (J.has(t)) return X(e, G);
838
- J.add(t);
928
+ if (!e.customElements.get(K)) {
929
+ if (Y.has(t)) return Z(e, K);
930
+ Y.add(t);
839
931
  try {
840
- await De(e);
932
+ await We(e);
841
933
  } catch (e) {
842
- throw J.delete(t), e;
934
+ throw Y.delete(t), e;
843
935
  }
844
936
  }
845
- }, Te = () => typeof window < "u" && window.__KACHING_DEV__ !== void 0, Ee = () => Te() ? Se : Ce, De = async (e) => {
846
- let t = e.document, n = Ee();
847
- if (t.querySelector(`script[src="${n}"]`)) return X(e, G);
848
- let r = Oe(t);
849
- if (r && await Ae(t, r)) return X(e, G);
937
+ }, He = () => typeof window < "u" && window.__KACHING_DEV__ !== void 0, Ue = () => He() ? ze : Be, We = async (e) => {
938
+ let t = e.document, n = Ue();
939
+ if (t.querySelector(`script[src="${n}"]`)) return Z(e, K);
940
+ let r = Ge(t);
941
+ if (r && await qe(t, r)) return Z(e, K);
850
942
  let i = t.createElement("script");
851
- return i.src = n, await Y(t, i), X(e, G);
852
- }, Oe = (e) => {
853
- let t = e.querySelectorAll(`link[rel="modulepreload"][href$="${q}"]`);
854
- return Array.from(t, (e) => e.href).find(ke);
855
- }, ke = (e) => {
943
+ return i.src = n, await X(t, i), Z(e, K);
944
+ }, Ge = (e) => {
945
+ let t = e.querySelectorAll(`link[rel="modulepreload"][href$="${J}"]`);
946
+ return Array.from(t, (e) => e.href).find(Ke);
947
+ }, Ke = (e) => {
856
948
  try {
857
- return new URL(e).pathname.endsWith(q);
949
+ return new URL(e).pathname.endsWith(J);
858
950
  } catch {
859
951
  return !1;
860
952
  }
861
- }, Ae = async (e, t) => {
953
+ }, qe = async (e, t) => {
862
954
  let n = e.createElement("script");
863
955
  n.type = "module", n.setAttribute("crossorigin", "anonymous"), n.src = t;
864
956
  try {
865
- return await Y(e, n), !0;
957
+ return await X(e, n), !0;
866
958
  } catch {
867
959
  return n.remove(), !1;
868
960
  }
869
- }, Y = (e, t) => new Promise((n, r) => {
961
+ }, X = (e, t) => new Promise((n, r) => {
870
962
  t.onload = () => n(), t.onerror = () => r(/* @__PURE__ */ Error("Failed to load script")), e.head.appendChild(t);
871
- }), X = (e, t) => new Promise((n, r) => {
872
- 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);
873
- });
874
- [
875
- "primaryBackground",
876
- "secondaryBackground",
877
- "primaryText",
878
- "secondaryText",
879
- "border",
880
- "overlay",
881
- "primaryAccent",
882
- "primaryAccentText",
883
- "badgeBackground",
884
- "badgeText",
885
- "error"
886
- ].map((e) => `brand_${e}`);
887
- var Z = /* @__PURE__ */ function(e) {
888
- return e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e;
889
- }({}), Q = "a-f\\d", je = `#?[${Q}]{3}[${Q}]?`, Me = `#?[${Q}]{6}([${Q}]{2})?`, Ne = RegExp(`[^#${Q}]`, "gi"), Pe = RegExp(`^${je}$|^${Me}$`, "i");
963
+ }), Z = (e, t) => new Promise((n, r) => {
964
+ 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);
965
+ }), Q = "a-f\\d", Je = `#?[${Q}]{3}[${Q}]?`, Ye = `#?[${Q}]{6}([${Q}]{2})?`, Xe = RegExp(`[^#${Q}]`, "gi"), Ze = RegExp(`^${Je}$|^${Ye}$`, "i");
890
966
  function $(e, t = {}) {
891
- if (typeof e != "string" || Ne.test(e) || !Pe.test(e)) throw TypeError("Expected a valid hex string");
967
+ if (typeof e != "string" || Xe.test(e) || !Ze.test(e)) throw TypeError("Expected a valid hex string");
892
968
  e = e.replace(/^#/, "");
893
969
  let n = 1;
894
970
  e.length === 8 && (n = Number.parseInt(e.slice(6, 8), 16) / 255, e = e.slice(0, 6)), e.length === 4 && (n = Number.parseInt(e.slice(3, 4).repeat(2), 16) / 255, e = e.slice(0, 3)), e.length === 3 && (e = e[0] + e[0] + e[1] + e[1] + e[2] + e[2]);
@@ -906,7 +982,7 @@ function $(e, t = {}) {
906
982
  };
907
983
  }
908
984
  // src/react/preview.ts
909
- var Fe = ({ price: e }) => ({
985
+ var Qe = ({ price: e }) => ({
910
986
  id: 123,
911
987
  handle: "123",
912
988
  url: null,
@@ -939,7 +1015,7 @@ var Fe = ({ price: e }) => ({
939
1015
  text4: null
940
1016
  },
941
1017
  isNativeBundle: !1
942
- }), Ie = () => ({
1018
+ }), $e = () => ({
943
1019
  shopifyDomain: "",
944
1020
  moneyFormat: "${{amount_with_comma_separator}}",
945
1021
  locale: "en",
@@ -995,7 +1071,7 @@ var Fe = ({ price: e }) => ({
995
1071
  },
996
1072
  shopCustomStyles: "",
997
1073
  featureFlags: {}
998
- }), Le = ({ color: e, cornerRadius: t }) => {
1074
+ }), et = ({ color: e, cornerRadius: t }) => {
999
1075
  let n = {
1000
1076
  id: "123",
1001
1077
  nanoId: "123",
@@ -1045,7 +1121,7 @@ var Fe = ({ price: e }) => ({
1045
1121
  lowStockAlert: null,
1046
1122
  dealBars: [{
1047
1123
  id: "PfFU",
1048
- dealBarType: Z.QuantityBreak,
1124
+ dealBarType: W.QuantityBreak,
1049
1125
  title: "1 pack",
1050
1126
  subtitle: "Standard price",
1051
1127
  label: "",
@@ -1064,7 +1140,7 @@ var Fe = ({ price: e }) => ({
1064
1140
  productPersonalisation: null
1065
1141
  }, {
1066
1142
  id: "1f-9",
1067
- dealBarType: Z.QuantityBreak,
1143
+ dealBarType: W.QuantityBreak,
1068
1144
  title: "2 pack",
1069
1145
  subtitle: "You save {{saved_percentage}}",
1070
1146
  label: "SAVE {{saved_total}}",
@@ -1258,11 +1334,11 @@ var Fe = ({ price: e }) => ({
1258
1334
  ...$(e),
1259
1335
  alpha: 1
1260
1336
  }), n;
1261
- }, Re = ({ data: t, selectedVariantId: a, preview: o, onLinesChange: s, targetWindow: c }) => {
1337
+ }, tt = ({ data: t, selectedVariantId: a, preview: o, onLinesChange: s, targetWindow: c }) => {
1262
1338
  let l = n(null), [u, d] = r(!1), f = n(!1);
1263
1339
  e(() => {
1264
1340
  l.current && !u && (async () => {
1265
- await we(c ?? window), d(!0);
1341
+ await Ve(c ?? window), d(!0);
1266
1342
  })();
1267
1343
  }, [u, c]), e(() => {
1268
1344
  let e = l.current;
@@ -1283,8 +1359,8 @@ var Fe = ({ price: e }) => ({
1283
1359
  e.removeEventListener("kaching-bundles-block-loaded", t), e.removeEventListener("variants-changed", t);
1284
1360
  };
1285
1361
  }, [u, s]);
1286
- let p = t ? Be(t, a) : o ? Ve(o) : null;
1287
- return ze(() => {
1362
+ let p = t ? rt(t, a) : o ? it(o) : null;
1363
+ return nt(() => {
1288
1364
  let e = l.current;
1289
1365
  if (e && p) for (let [t, n] of Object.entries(p.jsonAttributes)) e.getAttribute(t) !== n && e.setAttribute(t, n);
1290
1366
  }), p ? /* @__PURE__ */ i("kaching-bundles-block", {
@@ -1293,20 +1369,21 @@ var Fe = ({ price: e }) => ({
1293
1369
  ...p.jsonAttributes,
1294
1370
  "current-variant-id": p.currentVariantId
1295
1371
  }) : null;
1296
- }, ze = typeof window > "u" ? e : t, Be = ({ config: e, dealBlock: t, product: n, otherProducts: r, mediaImages: i, collectionBreaksProducts: a, translations: o }, s) => ({
1372
+ }, nt = typeof window > "u" ? e : t, rt = ({ config: e, dealBlock: t, product: n, otherProducts: r, mixAndMatchSwapProducts: i, mediaImages: a, collectionBreaksProducts: o, translations: s }, c) => ({
1297
1373
  dealBlockId: t.id,
1298
- currentVariantId: s ? s.split("/").pop() : String(n.variants[0].id),
1374
+ currentVariantId: c ? c.split("/").pop() : String(n.variants[0].id),
1299
1375
  jsonAttributes: {
1300
1376
  config: JSON.stringify(e),
1301
1377
  "deal-block": JSON.stringify(t),
1302
- "media-images": JSON.stringify(i),
1378
+ "media-images": JSON.stringify(a),
1303
1379
  product: JSON.stringify(n),
1304
1380
  "other-products": JSON.stringify(r),
1305
- "collection-breaks-products": JSON.stringify(a),
1306
- translations: JSON.stringify(o)
1381
+ "mix-and-match-swap-products": JSON.stringify(i ?? []),
1382
+ "collection-breaks-products": JSON.stringify(o),
1383
+ translations: JSON.stringify(s)
1307
1384
  }
1308
- }), Ve = ({ cornerRadius: e, color: t, price: n }) => {
1309
- let r = Fe({ price: n }), i = Ie(), a = Le({
1385
+ }), it = ({ cornerRadius: e, color: t, price: n }) => {
1386
+ let r = Qe({ price: n }), i = $e(), a = et({
1310
1387
  color: t,
1311
1388
  cornerRadius: e
1312
1389
  });
@@ -1319,9 +1396,10 @@ var Fe = ({ price: e }) => ({
1319
1396
  "media-images": JSON.stringify([]),
1320
1397
  product: JSON.stringify(r),
1321
1398
  "other-products": JSON.stringify([]),
1399
+ "mix-and-match-swap-products": JSON.stringify([]),
1322
1400
  "collection-breaks-products": JSON.stringify([]),
1323
1401
  translations: JSON.stringify({})
1324
1402
  }
1325
1403
  };
1326
1404
  };
1327
- export { Re as KachingBundle, xe as fetchKachingBundlesData };
1405
+ export { tt as KachingBundle, Re as fetchKachingBundlesData };