@kachingappz/bundles-js 1.1.10 → 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,16 +685,6 @@ 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
688
  };
658
689
  [
659
690
  "primaryBackground",
@@ -670,18 +701,18 @@ var E = "app--2935586817", D = async (e, { language: t, country: n, useExternalM
670
701
  ].map((e) => `brand_${e}`);
671
702
  var W = /* @__PURE__ */ function(e) {
672
703
  return e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e;
673
- }({}), he = async (e, t, { country: n, language: r }) => {
704
+ }({}), Oe = async (e, t, { country: n, language: r }) => {
674
705
  let i = t.collectionBreaks;
675
706
  if (!t.collectionBreaksEnabled || !i) return;
676
707
  let a;
677
- a = i.visibility === "deal-products" ? await _(e, {
708
+ a = i.visibility === "deal-products" ? await k(e, {
678
709
  country: n,
679
710
  language: r,
680
711
  blockVisibility: t.blockVisibility,
681
712
  excludedProductGIDs: (t.excludedProductIds || []).map((e) => `gid://shopify/Product/${e}`),
682
713
  selectedProductGIDs: (t.selectedProductIds || []).map((e) => `gid://shopify/Product/${e}`),
683
714
  selectedCollectionGIDs: (t.selectedCollectionIds || []).map((e) => `gid://shopify/Collection/${e}`)
684
- }) : await _(e, {
715
+ }) : await k(e, {
685
716
  country: n,
686
717
  language: r,
687
718
  blockVisibility: i.visibility,
@@ -689,14 +720,14 @@ var W = /* @__PURE__ */ function(e) {
689
720
  selectedProductGIDs: (i.selectedProducts || []).map(({ id: e }) => e),
690
721
  selectedCollectionGIDs: (i.selectedCollections || []).map(({ id: e }) => e)
691
722
  });
692
- let o = await y(e, {
723
+ let o = await j(e, {
693
724
  country: n,
694
725
  language: r,
695
726
  productIds: a.map((e) => Number(e.split("/").pop())),
696
727
  useExternalMetafieldNamespace: !0
697
728
  }), s = i.visibility === "deal-products" && t.blockVisibility === "excluded-products";
698
- return o = o.filter((e) => e.availableForSale && (!s || U([t], e).length > 0)), o;
699
- }, 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 }) => {
700
731
  let n = {
701
732
  "system.out_of_stock": "There's not enough items in our stock, please select smaller bundle.",
702
733
  "system.invalid_variant": "Sorry, this is not currently available.",
@@ -723,13 +754,13 @@ var W = /* @__PURE__ */ function(e) {
723
754
  "system.numbers_only": "Only numbers are allowed.",
724
755
  "system.personalisation_required_alert": "Please add personalisation for every item to continue.",
725
756
  "system.gifts_required_alert": "Please choose your free gifts"
726
- }, r = e ? _e(e) : void 0;
757
+ }, r = e ? Ae(e) : void 0;
727
758
  return {
728
759
  ...n,
729
760
  ...r?.system,
730
761
  ...r?.dealBlocks[t]
731
762
  };
732
- }, _e = (e) => {
763
+ }, Ae = (e) => {
733
764
  if (typeof document > "u") return;
734
765
  let t = document.querySelector("script#kaching-bundles-translations");
735
766
  if (!t?.textContent) return;
@@ -741,41 +772,41 @@ var W = /* @__PURE__ */ function(e) {
741
772
  }
742
773
  let r = G(e);
743
774
  return n.find((e) => G(e.locale) === r)?.translations;
744
- }, G = (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 }) => {
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 }) => {
745
776
  try {
746
- let o = [Number(t.split("/").pop())], s = new we(e);
777
+ let o = [Number(t.split("/").pop())], s = new Le(e);
747
778
  i ||= s.i18n?.country, a ||= s.i18n?.language;
748
- let c = await D(s, {
779
+ let c = await oe(s, {
749
780
  language: a,
750
781
  country: i,
751
782
  useExternalMetafieldNamespace: !0
752
783
  });
753
784
  s.shopifyDomain = c.shopifyDomain;
754
- 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, {
755
786
  country: i,
756
787
  language: a,
757
788
  productIds: o,
758
789
  useExternalMetafieldNamespace: !0
759
- }), p(l, {
790
+ }), D(l, {
760
791
  useExternalMetafieldNamespace: !0,
761
792
  useMetaobjects: c.featureFlags.storefront_metaobjects
762
- })]), f = u[0];
763
- if (!f) return null;
764
- 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];
765
796
  if (!g) return null;
766
- let _ = N(g, { includeMixAndMatchSwapProducts: !1 }), v = be(l, g, {
797
+ let _ = _e(g, { includeMixAndMatchSwapProducts: !1 }), y = Ne(l, g, {
767
798
  otherProductGIDs: _,
768
799
  country: i,
769
800
  language: a
770
801
  }), [b, x, S] = await Promise.all([
771
- y(l, {
802
+ j(l, {
772
803
  country: i,
773
804
  language: a,
774
805
  productIds: _,
775
806
  useExternalMetafieldNamespace: !0
776
807
  }),
777
- k(l, ee(g), 300),
778
- ge({
808
+ ce(l, de(g), 300),
809
+ ke({
779
810
  language: a,
780
811
  dealBlockId: g.id
781
812
  })
@@ -784,27 +815,27 @@ var W = /* @__PURE__ */ function(e) {
784
815
  data: {
785
816
  config: c,
786
817
  dealBlock: g,
787
- product: f,
788
- otherProducts: b,
818
+ product: p,
819
+ otherProducts: d(g, b),
789
820
  mediaImages: x,
790
821
  translations: S
791
822
  },
792
- modalProducts: v
823
+ modalProducts: y
793
824
  };
794
825
  } catch (e) {
795
826
  return console.error(e), null;
796
827
  }
797
- }, be = async (e, t, n) => {
798
- let [r, i] = await Promise.all([xe(e, t, n), Ce(e, t, n)]);
828
+ }, Ne = async (e, t, n) => {
829
+ let [r, i] = await Promise.all([Pe(e, t, n), Ie(e, t, n)]);
799
830
  return {
800
831
  mixAndMatchSwapProducts: r,
801
832
  collectionBreaksProducts: i
802
833
  };
803
- }, xe = async (e, t, { otherProductGIDs: n, country: r, language: i }) => {
834
+ }, Pe = async (e, t, { otherProductGIDs: n, country: r, language: i }) => {
804
835
  try {
805
836
  let a = [];
806
837
  try {
807
- a = await j(e, {
838
+ a = await ue(e, {
808
839
  dealBlock: t,
809
840
  country: r,
810
841
  language: i
@@ -812,26 +843,26 @@ var W = /* @__PURE__ */ function(e) {
812
843
  } catch (e) {
813
844
  console.error(e);
814
845
  }
815
- let o = new Set(n), s = [.../* @__PURE__ */ new Set([...Se(t), ...a])].filter((e) => !o.has(e));
816
- return s.length ? await y(e, {
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, {
817
848
  country: r,
818
849
  language: i,
819
850
  productIds: s,
820
851
  useExternalMetafieldNamespace: !0
821
- }) : [];
852
+ })) : [];
822
853
  } catch (e) {
823
854
  return console.error(e), [];
824
855
  }
825
- }, Se = (e) => e.dealBars.flatMap((e) => e.dealBarType === W.MixAndMatch ? e.bundleProducts.flatMap((e) => (e.selectedProducts ?? []).map((e) => e.id)) : []), Ce = async (e, t, { country: n, language: r }) => {
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 }) => {
826
857
  try {
827
- return await he(e, t, {
858
+ return await Oe(e, t, {
828
859
  country: n,
829
860
  language: r
830
861
  }) ?? [];
831
862
  } catch (e) {
832
863
  return console.error(e), [];
833
864
  }
834
- }, we = class {
865
+ }, Le = class {
835
866
  constructor(e) {
836
867
  this.storefront = e, this.shopifyDomain = "";
837
868
  }
@@ -844,7 +875,7 @@ var W = /* @__PURE__ */ function(e) {
844
875
  }
845
876
  if ("request" in this.storefront) return (await this.storefront.request(e, t)).data;
846
877
  if ("shopifyDomain" in this.storefront && "storefrontAccessToken" in this.storefront) {
847
- 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`, {
848
879
  body: JSON.stringify({
849
880
  query: e,
850
881
  variables: t?.variables
@@ -874,9 +905,9 @@ var W = /* @__PURE__ */ function(e) {
874
905
  get i18n() {
875
906
  if ("i18n" in this.storefront) return this.storefront.i18n;
876
907
  }
877
- }, Te = async (e, t) => {
908
+ }, Re = async (e, t) => {
878
909
  try {
879
- let n = await ye(e, t);
910
+ let n = await Me(e, t);
880
911
  if (!n) return null;
881
912
  let { config: r, dealBlock: i, product: a, otherProducts: o, mediaImages: s, translations: c } = n.data, { mixAndMatchSwapProducts: l, collectionBreaksProducts: u } = await n.modalProducts;
882
913
  return {
@@ -892,34 +923,34 @@ var W = /* @__PURE__ */ function(e) {
892
923
  } catch (e) {
893
924
  return console.error(e), null;
894
925
  }
895
- }, K = "kaching-bundles-block", q = 1e4, J = "/kaching-bundles-block.js", Ee = "https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js", De = "https://bundles-integrations.kachingappz.app/kaching-bundles-block.js", Y = /* @__PURE__ */ new WeakSet(), Oe = async (e) => {
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) => {
896
927
  let t = e.document;
897
928
  if (!e.customElements.get(K)) {
898
929
  if (Y.has(t)) return Z(e, K);
899
930
  Y.add(t);
900
931
  try {
901
- await je(e);
932
+ await We(e);
902
933
  } catch (e) {
903
934
  throw Y.delete(t), e;
904
935
  }
905
936
  }
906
- }, ke = () => typeof window < "u" && window.__KACHING_DEV__ !== void 0, Ae = () => ke() ? Ee : De, je = async (e) => {
907
- let t = e.document, n = Ae();
937
+ }, He = () => typeof window < "u" && window.__KACHING_DEV__ !== void 0, Ue = () => He() ? ze : Be, We = async (e) => {
938
+ let t = e.document, n = Ue();
908
939
  if (t.querySelector(`script[src="${n}"]`)) return Z(e, K);
909
- let r = Me(t);
910
- if (r && await Pe(t, r)) return Z(e, K);
940
+ let r = Ge(t);
941
+ if (r && await qe(t, r)) return Z(e, K);
911
942
  let i = t.createElement("script");
912
943
  return i.src = n, await X(t, i), Z(e, K);
913
- }, Me = (e) => {
944
+ }, Ge = (e) => {
914
945
  let t = e.querySelectorAll(`link[rel="modulepreload"][href$="${J}"]`);
915
- return Array.from(t, (e) => e.href).find(Ne);
916
- }, Ne = (e) => {
946
+ return Array.from(t, (e) => e.href).find(Ke);
947
+ }, Ke = (e) => {
917
948
  try {
918
949
  return new URL(e).pathname.endsWith(J);
919
950
  } catch {
920
951
  return !1;
921
952
  }
922
- }, Pe = async (e, t) => {
953
+ }, qe = async (e, t) => {
923
954
  let n = e.createElement("script");
924
955
  n.type = "module", n.setAttribute("crossorigin", "anonymous"), n.src = t;
925
956
  try {
@@ -931,9 +962,9 @@ var W = /* @__PURE__ */ function(e) {
931
962
  t.onload = () => n(), t.onerror = () => r(/* @__PURE__ */ Error("Failed to load script")), e.head.appendChild(t);
932
963
  }), Z = (e, t) => new Promise((n, r) => {
933
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);
934
- }), Q = "a-f\\d", $ = `#?[${Q}]{3}[${Q}]?`, Fe = `#?[${Q}]{6}([${Q}]{2})?`, Ie = RegExp(`[^#${Q}]`, "gi"), Le = RegExp(`^${$}$|^${Fe}$`, "i");
935
- function Re(e, t = {}) {
936
- if (typeof e != "string" || Ie.test(e) || !Le.test(e)) throw TypeError("Expected a valid hex string");
965
+ }), Q = "a-f\\d", Je = `#?[${Q}]{3}[${Q}]?`, Ye = `#?[${Q}]{6}([${Q}]{2})?`, Xe = RegExp(`[^#${Q}]`, "gi"), Ze = RegExp(`^${Je}$|^${Ye}$`, "i");
966
+ function $(e, t = {}) {
967
+ if (typeof e != "string" || Xe.test(e) || !Ze.test(e)) throw TypeError("Expected a valid hex string");
937
968
  e = e.replace(/^#/, "");
938
969
  let n = 1;
939
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]);
@@ -951,7 +982,7 @@ function Re(e, t = {}) {
951
982
  };
952
983
  }
953
984
  // src/react/preview.ts
954
- var ze = ({ price: e }) => ({
985
+ var Qe = ({ price: e }) => ({
955
986
  id: 123,
956
987
  handle: "123",
957
988
  url: null,
@@ -984,7 +1015,7 @@ var ze = ({ price: e }) => ({
984
1015
  text4: null
985
1016
  },
986
1017
  isNativeBundle: !1
987
- }), Be = () => ({
1018
+ }), $e = () => ({
988
1019
  shopifyDomain: "",
989
1020
  moneyFormat: "${{amount_with_comma_separator}}",
990
1021
  locale: "en",
@@ -1040,7 +1071,7 @@ var ze = ({ price: e }) => ({
1040
1071
  },
1041
1072
  shopCustomStyles: "",
1042
1073
  featureFlags: {}
1043
- }), Ve = ({ color: e, cornerRadius: t }) => {
1074
+ }), et = ({ color: e, cornerRadius: t }) => {
1044
1075
  let n = {
1045
1076
  id: "123",
1046
1077
  nanoId: "123",
@@ -1300,14 +1331,14 @@ var ze = ({ price: e }) => ({
1300
1331
  imageCornerRadius: 6
1301
1332
  };
1302
1333
  return e !== void 0 && (n.colors.border = {
1303
- ...Re(e),
1334
+ ...$(e),
1304
1335
  alpha: 1
1305
1336
  }), n;
1306
- }, He = ({ data: t, selectedVariantId: a, preview: o, onLinesChange: s, targetWindow: c }) => {
1337
+ }, tt = ({ data: t, selectedVariantId: a, preview: o, onLinesChange: s, targetWindow: c }) => {
1307
1338
  let l = n(null), [u, d] = r(!1), f = n(!1);
1308
1339
  e(() => {
1309
1340
  l.current && !u && (async () => {
1310
- await Oe(c ?? window), d(!0);
1341
+ await Ve(c ?? window), d(!0);
1311
1342
  })();
1312
1343
  }, [u, c]), e(() => {
1313
1344
  let e = l.current;
@@ -1328,8 +1359,8 @@ var ze = ({ price: e }) => ({
1328
1359
  e.removeEventListener("kaching-bundles-block-loaded", t), e.removeEventListener("variants-changed", t);
1329
1360
  };
1330
1361
  }, [u, s]);
1331
- let p = t ? We(t, a) : o ? Ge(o) : null;
1332
- return Ue(() => {
1362
+ let p = t ? rt(t, a) : o ? it(o) : null;
1363
+ return nt(() => {
1333
1364
  let e = l.current;
1334
1365
  if (e && p) for (let [t, n] of Object.entries(p.jsonAttributes)) e.getAttribute(t) !== n && e.setAttribute(t, n);
1335
1366
  }), p ? /* @__PURE__ */ i("kaching-bundles-block", {
@@ -1338,7 +1369,7 @@ var ze = ({ price: e }) => ({
1338
1369
  ...p.jsonAttributes,
1339
1370
  "current-variant-id": p.currentVariantId
1340
1371
  }) : null;
1341
- }, Ue = typeof window > "u" ? e : t, We = ({ config: e, dealBlock: t, product: n, otherProducts: r, mixAndMatchSwapProducts: i, mediaImages: a, collectionBreaksProducts: o, translations: s }, c) => ({
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) => ({
1342
1373
  dealBlockId: t.id,
1343
1374
  currentVariantId: c ? c.split("/").pop() : String(n.variants[0].id),
1344
1375
  jsonAttributes: {
@@ -1351,8 +1382,8 @@ var ze = ({ price: e }) => ({
1351
1382
  "collection-breaks-products": JSON.stringify(o),
1352
1383
  translations: JSON.stringify(s)
1353
1384
  }
1354
- }), Ge = ({ cornerRadius: e, color: t, price: n }) => {
1355
- let r = ze({ price: n }), i = Be(), a = Ve({
1385
+ }), it = ({ cornerRadius: e, color: t, price: n }) => {
1386
+ let r = Qe({ price: n }), i = $e(), a = et({
1356
1387
  color: t,
1357
1388
  cornerRadius: e
1358
1389
  });
@@ -1371,4 +1402,4 @@ var ze = ({ price: e }) => ({
1371
1402
  }
1372
1403
  };
1373
1404
  };
1374
- export { He as KachingBundle, Te as fetchKachingBundlesData };
1405
+ export { tt as KachingBundle, Re as fetchKachingBundlesData };