@kachingappz/bundles-js 1.1.10 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,24 +1,84 @@
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
+ availableForSale: n.some((e) => e.availableForSale)
30
+ };
31
+ }, d = (e, t) => p(e) ? m(e, t, /* @__PURE__ */ new Set()) : t, f = (e, t) => p(e) ? m(e, t, h(e)) : t, p = (e) => !!e.selectedVariants?.length, m = (e, t, n) => t.flatMap((t) => {
32
+ let r = l(e, t);
33
+ if (!r) return [t];
34
+ let i = u(t, [...r, ...t.variants.map((e) => e.id).filter((e) => n.has(e))]);
35
+ return i.variants.length ? [i] : [];
36
+ }), h = (e) => new Set([
37
+ ...e.dealBars.flatMap(g),
38
+ ...(e.progressiveGifts?.gifts ?? []).flatMap((e) => e.variantGIDs ?? []),
39
+ ...(e.checkboxUpsells?.upsells ?? []).flatMap((e) => e.variantGIDs ?? [])
40
+ ].map(v)), g = (e) => [
41
+ ...e.freeGifts.flatMap((e) => e.variantGIDs ?? []),
42
+ ...e.upsells.flatMap((e) => e.variantGIDs ?? []),
43
+ ...(e.multipleGiftsSelectors ?? []).flatMap((e) => e.products.flatMap((e) => e.variantGIDs ?? [])),
44
+ ..._(e)
45
+ ], _ = (e) => {
46
+ switch (e.dealBarType) {
47
+ case a.Bundle: return e.bundleProducts.flatMap((e) => e.productGID === "default" ? [] : e.variantGIDs ?? []);
48
+ case a.MixAndMatch: return e.bundleProducts.flatMap((e) => [...e.productGID === "default" ? [] : e.variantGIDs ?? [], ...(e.selectedProducts ?? []).flatMap((e) => e.variantGIDs ?? [])]);
49
+ default: return [];
50
+ }
51
+ }, v = (e) => Number(e.split("/").pop()), y = (e, t) => t ? e : e.map(b), b = (e) => {
52
+ let t = { ...e };
53
+ return delete t.selectedVariants, t;
54
+ }, x = (e, t, n) => {
55
+ 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");
56
+ for (let e of u) e.selectedProductIds.map(Number).includes(t.id) && s.push(e);
57
+ let d = e.filter((e) => e.blockVisibility === "selected-collections");
58
+ for (let e of d) t.collectionIds.some((t) => e.selectedCollectionIds.map(Number).includes(t)) && s.push(e);
59
+ let f = e.filter((e) => e.blockVisibility === "excluded-products");
60
+ for (let e of f) !e.excludedProductIds.map(Number).includes(t.id) && !(e.excludedCollectionIds || []).some((e) => t.collectionIds.includes(e)) && s.push(e);
61
+ let p = e.filter((e) => e.blockVisibility === "all-products");
62
+ for (let e of p) s.push(e);
63
+ return n === void 0 ? s : [...s, ...l];
64
+ }, S = (e, { language: t, country: n }) => {
65
+ let r = E(t, n), i = new Intl.NumberFormat(r, {
6
66
  style: "currency",
7
67
  currency: e,
8
68
  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);
69
+ }).formatToParts(1234567.89), a = i.find((e) => e.type === "decimal")?.value, o = te(ee(i.find((e) => e.type === "group")?.value), a, i.some((e) => e.type === "fraction")), s = i.findIndex(T), c = i.findLastIndex(T);
10
70
  return [
11
- ...i.slice(0, f).map(o),
12
- s,
13
- ...i.slice(p + 1).map(o)
71
+ ...i.slice(0, s).map(C),
72
+ o,
73
+ ...i.slice(c + 1).map(C)
14
74
  ].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 }) => {
75
+ }, C = (e) => w(e.value), w = (e) => e.replace(/\s/g, " "), T = (e) => e.type === "integer" || e.type === "group" || e.type === "decimal" || e.type === "fraction", E = (e, t) => e && t ? `${e}-${t.toUpperCase()}` : e || (t ? t.toUpperCase() : "en"), ee = (e) => e === void 0 ? void 0 : w(e).replace(/’/g, "'"), te = (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}}", D = ({ country: e, language: t }) => {
16
76
  let n = [];
17
77
  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) => {
78
+ }, ne = async (e, { useExternalMetafieldNamespace: t, useMetaobjects: n }) => n ? ie(e, t) : re(e, t), re = async (e, t) => {
19
79
  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
80
  return n ? JSON.parse(n) : [];
21
- }, h = async (e, t) => {
81
+ }, ie = async (e, t) => {
22
82
  let n = t ? "app--2935586817--deal_block" : "$app:deal_block", r = [], i = null;
23
83
  for (;;) {
24
84
  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 +107,14 @@ var a = (e, { language: t, country: n }) => {
47
107
  "badgeText",
48
108
  "error"
49
109
  ].map((e) => `brand_${e}`);
50
- var g = /* @__PURE__ */ function(e) {
110
+ var O = /* @__PURE__ */ function(e) {
51
111
  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 }) => {
112
+ }({}), k = async (e, { country: t, language: n, blockVisibility: r, excludedProductGIDs: i, selectedProductGIDs: a, selectedCollectionGIDs: o, limit: s = 1e3 }) => {
53
113
  switch (r) {
54
114
  case "selected-products": return a.slice(0, s);
55
115
  case "all-products":
56
116
  case "excluded-products": {
57
- let a = f({
117
+ let a = D({
58
118
  country: t,
59
119
  language: n
60
120
  }), o = [], c = null;
@@ -85,7 +145,7 @@ var g = /* @__PURE__ */ function(e) {
85
145
  return o;
86
146
  }
87
147
  case "selected-collections": {
88
- let r = f({
148
+ let r = D({
89
149
  country: t,
90
150
  language: n
91
151
  }), i = (await e.query(`
@@ -107,16 +167,16 @@ var g = /* @__PURE__ */ function(e) {
107
167
  return Array.from(new Set(i)).slice(0, s);
108
168
  }
109
169
  }
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 = {
170
+ }, 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
171
  maxWidth: 200,
112
172
  maxHeight: 200
113
173
  } }) => {
114
174
  if (!r.length) return [];
115
- let h = r.map((e) => typeof e == "string" && e.startsWith("gid://") ? e : `gid://shopify/Product/${e}`), g = f({
175
+ let m = r.map((e) => typeof e == "string" && e.startsWith("gid://") ? e : `gid://shopify/Product/${e}`), h = D({
116
176
  country: t,
117
177
  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} {
178
+ }), g = `
179
+ query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $includeProductRating: Boolean!, $includeProductSubtitle: Boolean!, $includeProductTabFields: Boolean!, $subtitleNamespace: String!, $subtitleKey: String!, $metafieldNamespace: String!, $variantImageTransform: ImageTransformInput) ${h} {
120
180
  shop {
121
181
  currencyRateConstant: metafield(namespace: $metafieldNamespace, key: "currency_rate_constant") {
122
182
  value
@@ -150,7 +210,7 @@ var g = /* @__PURE__ */ function(e) {
150
210
  }
151
211
  variants(first: 250) {
152
212
  nodes {
153
- ${v}
213
+ ${A}
154
214
  }
155
215
  }
156
216
  collections(first: 50) {
@@ -216,50 +276,50 @@ var g = /* @__PURE__ */ function(e) {
216
276
  }
217
277
  }
218
278
  }
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: {
279
+ `, _ = 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);
280
+ for (let e = 0; e < m.length; e += S) x.push(m.slice(e, e + S));
281
+ let C = 1, w = async (n) => {
282
+ let [r, l] = await Promise.all([e.query(g, { variables: {
223
283
  productGIDs: n,
224
284
  includeSellingPlans: i,
225
285
  includeAvailableQuantity: a,
226
286
  includeProductRating: o,
227
287
  includeProductSubtitle: s,
228
288
  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 && {
289
+ subtitleNamespace: y,
290
+ subtitleKey: b,
291
+ metafieldNamespace: _,
292
+ variantImageTransform: p
293
+ } }), c ? ae(e, t, n) : null]);
294
+ return r.shop.currencyRateConstant && (C = JSON.parse(r.shop.currencyRateConstant.value).amount / 1e6), l ? { nodes: r.nodes.map((e) => e && {
235
295
  ...e,
236
296
  productType: l.get(e.id)
237
297
  }) } : 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, {
298
+ }, T;
299
+ if (f) {
300
+ let e = await Promise.allSettled(x.map(w));
301
+ for (let t of e) t.status === "rejected" && f(t.reason instanceof Error ? t.reason : Error(String(t.reason)));
302
+ T = e.filter((e) => e.status === "fulfilled").flatMap((e) => e.value.nodes);
303
+ } else T = (await Promise.all(x.map(w))).flatMap((e) => e.nodes);
304
+ let E = T.filter((e) => e != null);
305
+ if (f) {
306
+ let t = await Promise.allSettled(E.map(async (t) => N(await M(e, t, {
247
307
  includeSellingPlans: i,
248
308
  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)));
309
+ variantImageTransform: p
310
+ }, h), e.shopifyDomain, C))), n = [];
311
+ for (let e of t) e.status === "fulfilled" ? n.push(e.value) : f(e.reason instanceof Error ? e.reason : Error(String(e.reason)));
252
312
  return n;
253
313
  }
254
- return (await Promise.all(j.map((t) => x(e, t, {
314
+ return (await Promise.all(E.map((t) => M(e, t, {
255
315
  includeSellingPlans: i,
256
316
  includeAvailableQuantity: a,
257
- variantImageTransform: m
258
- }, g)))).map((t) => S(t, e.shopifyDomain, O));
259
- }, b = async (e, t, n) => {
317
+ variantImageTransform: p
318
+ }, h)))).map((t) => N(t, e.shopifyDomain, C));
319
+ }, ae = async (e, t, n) => {
260
320
  try {
261
321
  let r = await e.query(`
262
- query FetchProductTypes($productGIDs: [ID!]!) ${f({ country: t })} {
322
+ query FetchProductTypes($productGIDs: [ID!]!) ${D({ country: t })} {
263
323
  nodes(ids: $productGIDs) {
264
324
  ... on Product {
265
325
  id
@@ -272,7 +332,7 @@ var g = /* @__PURE__ */ function(e) {
272
332
  } catch (e) {
273
333
  return console.error(e), null;
274
334
  }
275
- }, x = async (e, t, n, r = "") => {
335
+ }, M = async (e, t, n, r = "") => {
276
336
  if (t.variants.nodes.length < 250) return t;
277
337
  let i = /* @__PURE__ */ new Set(), a = [], o = [], s = async (s) => {
278
338
  let c = !0, l = null;
@@ -282,7 +342,7 @@ var g = /* @__PURE__ */ function(e) {
282
342
  product(id: $productGID) {
283
343
  variants(first: 250, after: $cursor, reverse: $reverse) {
284
344
  nodes {
285
- ${v}
345
+ ${A}
286
346
  }
287
347
  pageInfo {
288
348
  endCursor
@@ -308,7 +368,7 @@ var g = /* @__PURE__ */ function(e) {
308
368
  }
309
369
  };
310
370
  return await Promise.all([s(!1), s(!0)]), t.variants.nodes = [...a, ...o.reverse()], t;
311
- }, S = (e, t, n) => {
371
+ }, N = (e, t, n) => {
312
372
  let r = e.variants.nodes.map(({ unitPriceMeasurement: e, ...t }) => ({
313
373
  id: Number(t.id.split("/").pop()),
314
374
  availableForSale: t.availableForSale,
@@ -346,7 +406,7 @@ var g = /* @__PURE__ */ function(e) {
346
406
  defaultName: e.name,
347
407
  name: e.name,
348
408
  position: t + 1,
349
- optionValues: T(n, t, r)
409
+ optionValues: ce(n, t, r)
350
410
  };
351
411
  }), a = (e) => {
352
412
  let t = e.priceAdjustments[0];
@@ -394,46 +454,31 @@ var g = /* @__PURE__ */ function(e) {
394
454
  text3: e.metafield3?.value || null,
395
455
  text4: e.metafield4?.value || null
396
456
  },
397
- rating: C(e.reviewsRating, e.reviewsRatingCount),
457
+ rating: oe(e.reviewsRating, e.reviewsRatingCount),
398
458
  subtitle: e.subtitle?.value || null,
399
459
  productType: e.productType || null,
400
460
  categoryGid: e.category?.id ?? null,
401
461
  tags: e.tags ?? []
402
462
  };
403
- }, C = (e, t) => {
463
+ }, oe = (e, t) => {
404
464
  if (!e) return null;
405
- let n = w(e.value);
465
+ let n = se(e.value);
406
466
  if (n === null) return null;
407
467
  let r = Number(t?.value);
408
468
  return {
409
469
  value: n,
410
470
  count: Number.isInteger(r) && r > 0 ? r : null
411
471
  };
412
- }, w = (e) => {
472
+ }, se = (e) => {
413
473
  try {
414
474
  let { value: t, scale_max: n } = JSON.parse(e), r = Number(t) / Number(n) * 5;
415
475
  return Number.isFinite(r) && r > 0 ? Math.min(5, r) : null;
416
476
  } catch {
417
477
  return null;
418
478
  }
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} {
479
+ }, ce = (e, t, n) => e.filter((e) => n.filter((n) => n.options[t] === e.name).length > 0), P = "app--2935586817", le = async (e, { language: t, country: n, useExternalMetafieldNamespace: r }) => {
480
+ let i = r ? `${P}--kaching_bundles` : "$app:kaching_bundles", a = r ? P : "$app", o = D({ country: n }), { localization: { country: { currency: { isoCode: s } } }, shop: { moneyFormat: c, paymentSettings: { currencyCode: l }, currencyRateConstant: u, primaryDomain: d, settingsMetafield: f } } = await e.query(`
481
+ query config($metafieldNamespace: String!, $settingsNamespace: String!) ${o} {
437
482
  localization {
438
483
  country {
439
484
  currency {
@@ -459,30 +504,30 @@ var E = "app--2935586817", D = async (e, { language: t, country: n, useExternalM
459
504
  }
460
505
  `, { variables: {
461
506
  metafieldNamespace: i,
462
- settingsNamespace: o
463
- } }), h = c === u ? l : a(c, {
507
+ settingsNamespace: a
508
+ } }), p = s === l ? c : S(s, {
464
509
  language: t,
465
510
  country: n
466
- }), g = d ? O(d.value) : 1, _ = m ? JSON.parse(m.value) : null, v = _?.feature_flags ?? {}, y = _?.custom_selectors ?? {};
511
+ }), m = u ? ue(u.value) : 1, h = f ? JSON.parse(f.value) : null, g = h?.feature_flags ?? {}, _ = h?.custom_selectors ?? {};
467
512
  return {
468
- shopifyDomain: p.host,
469
- moneyFormat: h,
513
+ shopifyDomain: d.host,
514
+ moneyFormat: p,
470
515
  locale: t?.toLowerCase() || "en",
471
516
  liquidLocale: t?.toLowerCase() || "en",
472
517
  country: n ?? "US",
473
- currencyRate: g,
518
+ currencyRate: m,
474
519
  marketId: 0,
475
520
  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,
521
+ storefrontAccessToken: h?.storefront_access_token ?? null,
522
+ includeSellingPlans: h?.include_selling_plans ?? !1,
523
+ includeAvailableQuantity: h?.include_available_quantity ?? !1,
524
+ customApiHost: h?.custom_api_host ?? null,
525
+ keepQuantityInput: h?.keep_quantity_input ?? !1,
526
+ ignoreDeselect: h?.ignore_deselect ?? !1,
527
+ ignoreUnitPrice: h?.ignore_unit_price ?? !1,
528
+ requireCustomerLogin: h?.require_customer_login ?? !1,
529
+ abTestsRunning: h?.ab_tests_running ?? !1,
530
+ webPixel: h?.web_pixel ?? !1,
486
531
  b2bCustomer: !1,
487
532
  isLoggedIn: !1,
488
533
  preview: !1,
@@ -514,17 +559,17 @@ var E = "app--2935586817", D = async (e, { language: t, country: n, useExternalM
514
559
  "system.numbers_only": "Only numbers are allowed."
515
560
  },
516
561
  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
562
+ quantity: _.quantity ?? null,
563
+ addToCartButton: _.add_to_cart_button ?? null,
564
+ variantPicker: _.variant_picker ?? null,
565
+ price: _.price ?? null,
566
+ priceCompare: _.price_compare ?? null
522
567
  },
523
- shopCustomStyles: _?.shop_custom_styles ?? "",
524
- featureFlags: v,
525
- brandColors: _?.brand_colors ?? null
568
+ shopCustomStyles: h?.shop_custom_styles ?? "",
569
+ featureFlags: g,
570
+ brandColors: h?.brand_colors ?? null
526
571
  };
527
- }, O = (e) => JSON.parse(e).amount / 1e6, k = async (e, t, n = 200) => {
572
+ }, ue = (e) => JSON.parse(e).amount / 1e6, de = async (e, t, n = 200) => {
528
573
  let r = [...new Set(t.filter(Boolean).filter((e) => !e.startsWith("placeholder")))];
529
574
  if (r.length === 0) return [];
530
575
  let i = [];
@@ -536,10 +581,10 @@ var E = "app--2935586817", D = async (e, { language: t, country: n, useExternalM
536
581
  gid: e.id,
537
582
  url: e.image.url
538
583
  }] : []);
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)))];
584
+ }, F = 100, I = async (e, { dealBlock: t, country: n, language: r }) => {
585
+ let i = [...new Set(t.dealBars.flatMap((e) => e.dealBarType === O.MixAndMatch ? e.bundleProducts : []).flatMap((e) => (e.selectedCollections ?? []).map((e) => e.id)))];
541
586
  if (i.length === 0) return [];
542
- let a = f({
587
+ let a = D({
543
588
  country: n,
544
589
  language: r
545
590
  }), o = await e.query(`
@@ -547,7 +592,7 @@ var E = "app--2935586817", D = async (e, { language: t, country: n, useExternalM
547
592
  nodes(ids: $collectionGIDs) {
548
593
  ... on Collection {
549
594
  id
550
- products(first: ${A}) {
595
+ products(first: ${F}) {
551
596
  nodes {
552
597
  id
553
598
  variants(first: 1) {
@@ -562,77 +607,77 @@ var E = "app--2935586817", D = async (e, { language: t, country: n, useExternalM
562
607
  }
563
608
  `, { variables: { collectionGIDs: i } });
564
609
  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),
610
+ }, L = (e) => [
611
+ ...R(e),
612
+ ...z(e),
613
+ ...B(e),
614
+ ...V(e),
615
+ ...H(e),
577
616
  ...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) => {
617
+ ...pe(e),
618
+ ...me(e),
619
+ ...he(e),
620
+ ...ge(e),
621
+ ..._e(e),
622
+ ...ve(e),
623
+ ...ye(e)
624
+ ].filter((e) => e != null && !e.includes("placeholder")), R = (e) => e.dealBars.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), z = (e) => e.dealBars.flatMap((e) => e.dealBarType === O.Bundle ? e.bundleProducts.map((e) => e.mediaImageGID) : []).filter((e) => e != null), B = (e) => e.dealBars.map(({ freeGifts: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), V = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => (e || []).map((e) => e.mediaImageGID)).filter((e) => e != null), H = (e) => e.dealBars.map(({ upsells: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), fe = (e) => e.swatchOptions ? e.swatchOptions.reduce((e, t) => {
580
625
  let n = t.images.map((e) => e.mediaImageGID).filter((e) => e != null);
581
626
  return [...e, ...n];
582
- }, []) : [], se = (e) => {
627
+ }, []) : [], pe = (e) => {
583
628
  if (!e.collectionBreaksEnabled || !e.collectionBreaks) return [];
584
629
  let t = e.collectionBreaks.mediaImageGID;
585
630
  return t ? [t] : [];
586
- }, ce = (e) => e.progressiveGifts ? [
631
+ }, me = (e) => e.progressiveGifts ? [
587
632
  ...e.progressiveGifts.gifts?.map((e) => e.mediaImageGID) || [],
588
633
  e.progressiveGifts.style?.lockedMediaImageGID,
589
634
  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) => {
635
+ ].filter((e) => e != null) : [], he = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), ge = (e) => e.dealBars.map((e) => e.productPersonalisation?.mediaImageGID).filter((e) => e != null), _e = (e) => {
591
636
  let t = e.dealBars.map((e) => e.highlights?.customIconGID).filter((e) => e != null), n = e.subscriptions?.highlights?.customIconGID;
592
637
  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 } = {}) => {
638
+ }, ve = (e) => (e.badges || []).flatMap((e) => e.badgeType === "custom" && e.imageGID ? [e.imageGID] : []), ye = (e) => !e.savingsSummaryEnabled || !e.savingsSummary ? [] : e.savingsSummary.customIconGID ? [e.savingsSummary.customIconGID] : [], be = (e, { includeMixAndMatchSwapProducts: t = !0 } = {}) => {
594
639
  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)
640
+ ...xe(e),
641
+ ...Se(e),
642
+ ...Ce(e),
643
+ ...we(e),
644
+ ...Te(e),
645
+ ...Ee(e, t),
646
+ ...De(e),
647
+ ...Oe(e)
603
648
  ];
604
649
  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 {
650
+ }, xe = (e) => e.dealBars.flatMap(({ freeGifts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), Se = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => e ? e.flatMap((e) => e.products ? e.products.map((e) => e.id) : []) : []).filter((e) => e != null), Ce = (e) => e.progressiveGiftsEnabled && e.progressiveGifts?.gifts.map((e) => e.productGID).filter((e) => e != null) || [], we = (e) => e.dealBars.flatMap(({ upsells: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), Te = (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"), Ee = (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"), De = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.map((e) => e.productGID).filter((e) => e != null), Oe = (e) => e.dealBars.filter((e) => e.dealBarType === O.Sku).flatMap(({ productGID: e }) => e ? [e] : []), U = class extends Error {
606
651
  constructor({ status: e, operationName: t, graphqlErrors: n }) {
607
652
  let r = n.length ? `: ${n.join("; ")}` : "";
608
653
  super(`Storefront API ${t ?? "query"} failed (HTTP ${e})${r}`), this.name = "StorefrontApiError", this.status = e, this.operationName = t, this.graphqlErrors = n;
609
654
  }
610
- }, pe = async (e, t) => {
655
+ }, ke = async (e, t) => {
611
656
  let n = await e.text();
612
657
  if (!n) throw Error("Empty graphql response");
613
658
  let r;
614
659
  try {
615
660
  r = JSON.parse(n);
616
661
  } catch (n) {
617
- throw e.ok ? n : new H({
662
+ throw e.ok ? n : new U({
618
663
  status: e.status,
619
664
  operationName: t,
620
665
  graphqlErrors: []
621
666
  });
622
667
  }
623
- if (!e.ok || r.data === null || r.data === void 0) throw new H({
668
+ if (!e.ok || r.data === null || r.data === void 0) throw new U({
624
669
  status: e.status,
625
670
  operationName: t,
626
671
  graphqlErrors: (r.errors ?? []).map(({ message: e }) => e).filter(Boolean)
627
672
  });
628
673
  return r.data;
629
- }, me = class {
674
+ }, Ae = class {
630
675
  constructor(e, t) {
631
676
  this.storefrontApiVersion = "2026-07", this.storefrontAccessToken = t, this.shopifyDomain = e;
632
677
  }
633
678
  async query(e, t) {
634
679
  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, {
680
+ return i && (r += `?operation_name=${i}`), ke(await fetch(r, {
636
681
  method: "POST",
637
682
  headers: {
638
683
  "Content-Type": "application/json",
@@ -644,16 +689,6 @@ var E = "app--2935586817", D = async (e, { language: t, country: n, useExternalM
644
689
  })
645
690
  }), i);
646
691
  }
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
692
  };
658
693
  [
659
694
  "primaryBackground",
@@ -670,18 +705,18 @@ var E = "app--2935586817", D = async (e, { language: t, country: n, useExternalM
670
705
  ].map((e) => `brand_${e}`);
671
706
  var W = /* @__PURE__ */ function(e) {
672
707
  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 }) => {
708
+ }({}), je = async (e, t, { country: n, language: r }) => {
674
709
  let i = t.collectionBreaks;
675
710
  if (!t.collectionBreaksEnabled || !i) return;
676
711
  let a;
677
- a = i.visibility === "deal-products" ? await _(e, {
712
+ a = i.visibility === "deal-products" ? await k(e, {
678
713
  country: n,
679
714
  language: r,
680
715
  blockVisibility: t.blockVisibility,
681
716
  excludedProductGIDs: (t.excludedProductIds || []).map((e) => `gid://shopify/Product/${e}`),
682
- selectedProductGIDs: (t.selectedProductIds || []).map((e) => `gid://shopify/Product/${e}`),
717
+ selectedProductGIDs: [...t.selectedProductIds || [], ...(t.selectedVariants || []).map(({ productId: e }) => e)].map((e) => `gid://shopify/Product/${e}`),
683
718
  selectedCollectionGIDs: (t.selectedCollectionIds || []).map((e) => `gid://shopify/Collection/${e}`)
684
- }) : await _(e, {
719
+ }) : await k(e, {
685
720
  country: n,
686
721
  language: r,
687
722
  blockVisibility: i.visibility,
@@ -689,14 +724,14 @@ var W = /* @__PURE__ */ function(e) {
689
724
  selectedProductGIDs: (i.selectedProducts || []).map(({ id: e }) => e),
690
725
  selectedCollectionGIDs: (i.selectedCollections || []).map(({ id: e }) => e)
691
726
  });
692
- let o = await y(e, {
727
+ let o = await j(e, {
693
728
  country: n,
694
729
  language: r,
695
730
  productIds: a.map((e) => Number(e.split("/").pop())),
696
731
  useExternalMetafieldNamespace: !0
697
732
  }), 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 }) => {
733
+ return d(t, o).filter((e) => e.availableForSale && (!s || x([t], e).length > 0));
734
+ }, Me = ({ language: e, dealBlockId: t }) => {
700
735
  let n = {
701
736
  "system.out_of_stock": "There's not enough items in our stock, please select smaller bundle.",
702
737
  "system.invalid_variant": "Sorry, this is not currently available.",
@@ -723,13 +758,13 @@ var W = /* @__PURE__ */ function(e) {
723
758
  "system.numbers_only": "Only numbers are allowed.",
724
759
  "system.personalisation_required_alert": "Please add personalisation for every item to continue.",
725
760
  "system.gifts_required_alert": "Please choose your free gifts"
726
- }, r = e ? _e(e) : void 0;
761
+ }, r = e ? Ne(e) : void 0;
727
762
  return {
728
763
  ...n,
729
764
  ...r?.system,
730
765
  ...r?.dealBlocks[t]
731
766
  };
732
- }, _e = (e) => {
767
+ }, Ne = (e) => {
733
768
  if (typeof document > "u") return;
734
769
  let t = document.querySelector("script#kaching-bundles-translations");
735
770
  if (!t?.textContent) return;
@@ -741,70 +776,70 @@ var W = /* @__PURE__ */ function(e) {
741
776
  }
742
777
  let r = G(e);
743
778
  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 }) => {
779
+ }, G = (e) => e.toLowerCase().replace(/_/g, "-"), Pe = "2026-07", Fe = async (e, { productId: t, dealBlockId: n, abTestVariantId: r, country: i = void 0, language: a = void 0 }) => {
745
780
  try {
746
- let o = [Number(t.split("/").pop())], s = new we(e);
781
+ let o = [Number(t.split("/").pop())], s = new Be(e);
747
782
  i ||= s.i18n?.country, a ||= s.i18n?.language;
748
- let c = await D(s, {
783
+ let c = await le(s, {
749
784
  language: a,
750
785
  country: i,
751
786
  useExternalMetafieldNamespace: !0
752
787
  });
753
788
  s.shopifyDomain = c.shopifyDomain;
754
- let l = c.storefrontAccessToken ? new me(c.shopifyDomain, c.storefrontAccessToken) : s, [u, d] = await Promise.all([y(l, {
789
+ let l = c.storefrontAccessToken ? new Ae(c.shopifyDomain, c.storefrontAccessToken) : s, [u, d] = await Promise.all([j(l, {
755
790
  country: i,
756
791
  language: a,
757
792
  productIds: o,
758
793
  useExternalMetafieldNamespace: !0
759
- }), p(l, {
794
+ }), ne(l, {
760
795
  useExternalMetafieldNamespace: !0,
761
796
  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];
765
- if (!g) return null;
766
- let _ = N(g, { includeMixAndMatchSwapProducts: !1 }), v = be(l, g, {
767
- otherProductGIDs: _,
797
+ })]), p = y(d, c.featureFlags.selected_variants), m = u[0];
798
+ if (!m) return null;
799
+ let h = x(p, m), g = n ? h.filter((e) => e.id === n || e.nanoId === n) : h, _ = (r ? g.find((e) => e.abTestVariantId === r) : void 0) ?? g[0] ?? h[0];
800
+ if (!_) return null;
801
+ let v = be(_, { includeMixAndMatchSwapProducts: !1 }), b = Ie(l, _, {
802
+ otherProductGIDs: v,
768
803
  country: i,
769
804
  language: a
770
- }), [b, x, S] = await Promise.all([
771
- y(l, {
805
+ }), [S, C, w] = await Promise.all([
806
+ j(l, {
772
807
  country: i,
773
808
  language: a,
774
- productIds: _,
809
+ productIds: v,
775
810
  useExternalMetafieldNamespace: !0
776
811
  }),
777
- k(l, ee(g), 300),
778
- ge({
812
+ de(l, L(_), 300),
813
+ Me({
779
814
  language: a,
780
- dealBlockId: g.id
815
+ dealBlockId: _.id
781
816
  })
782
817
  ]);
783
818
  return {
784
819
  data: {
785
820
  config: c,
786
- dealBlock: g,
787
- product: f,
788
- otherProducts: b,
789
- mediaImages: x,
790
- translations: S
821
+ dealBlock: _,
822
+ product: m,
823
+ otherProducts: f(_, S),
824
+ mediaImages: C,
825
+ translations: w
791
826
  },
792
- modalProducts: v
827
+ modalProducts: b
793
828
  };
794
829
  } catch (e) {
795
830
  return console.error(e), null;
796
831
  }
797
- }, be = async (e, t, n) => {
798
- let [r, i] = await Promise.all([xe(e, t, n), Ce(e, t, n)]);
832
+ }, Ie = async (e, t, n) => {
833
+ let [r, i] = await Promise.all([Le(e, t, n), ze(e, t, n)]);
799
834
  return {
800
835
  mixAndMatchSwapProducts: r,
801
836
  collectionBreaksProducts: i
802
837
  };
803
- }, xe = async (e, t, { otherProductGIDs: n, country: r, language: i }) => {
838
+ }, Le = async (e, t, { otherProductGIDs: n, country: r, language: i }) => {
804
839
  try {
805
840
  let a = [];
806
841
  try {
807
- a = await j(e, {
842
+ a = await I(e, {
808
843
  dealBlock: t,
809
844
  country: r,
810
845
  language: i
@@ -812,26 +847,26 @@ var W = /* @__PURE__ */ function(e) {
812
847
  } catch (e) {
813
848
  console.error(e);
814
849
  }
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, {
850
+ let o = new Set(n), s = [.../* @__PURE__ */ new Set([...Re(t), ...a])].filter((e) => !o.has(e));
851
+ return s.length ? f(t, await j(e, {
817
852
  country: r,
818
853
  language: i,
819
854
  productIds: s,
820
855
  useExternalMetafieldNamespace: !0
821
- }) : [];
856
+ })) : [];
822
857
  } catch (e) {
823
858
  return console.error(e), [];
824
859
  }
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 }) => {
860
+ }, Re = (e) => e.dealBars.flatMap((e) => e.dealBarType === W.MixAndMatch ? e.bundleProducts.flatMap((e) => (e.selectedProducts ?? []).map((e) => e.id)) : []), ze = async (e, t, { country: n, language: r }) => {
826
861
  try {
827
- return await he(e, t, {
862
+ return await je(e, t, {
828
863
  country: n,
829
864
  language: r
830
865
  }) ?? [];
831
866
  } catch (e) {
832
867
  return console.error(e), [];
833
868
  }
834
- }, we = class {
869
+ }, Be = class {
835
870
  constructor(e) {
836
871
  this.storefront = e, this.shopifyDomain = "";
837
872
  }
@@ -844,7 +879,7 @@ var W = /* @__PURE__ */ function(e) {
844
879
  }
845
880
  if ("request" in this.storefront) return (await this.storefront.request(e, t)).data;
846
881
  if ("shopifyDomain" in this.storefront && "storefrontAccessToken" in this.storefront) {
847
- let n = await fetch(`https://${this.storefront.shopifyDomain}/api/${ve}/graphql.json`, {
882
+ let n = await fetch(`https://${this.storefront.shopifyDomain}/api/${Pe}/graphql.json`, {
848
883
  body: JSON.stringify({
849
884
  query: e,
850
885
  variables: t?.variables
@@ -874,9 +909,9 @@ var W = /* @__PURE__ */ function(e) {
874
909
  get i18n() {
875
910
  if ("i18n" in this.storefront) return this.storefront.i18n;
876
911
  }
877
- }, Te = async (e, t) => {
912
+ }, Ve = async (e, t) => {
878
913
  try {
879
- let n = await ye(e, t);
914
+ let n = await Fe(e, t);
880
915
  if (!n) return null;
881
916
  let { config: r, dealBlock: i, product: a, otherProducts: o, mediaImages: s, translations: c } = n.data, { mixAndMatchSwapProducts: l, collectionBreaksProducts: u } = await n.modalProducts;
882
917
  return {
@@ -892,34 +927,34 @@ var W = /* @__PURE__ */ function(e) {
892
927
  } catch (e) {
893
928
  return console.error(e), null;
894
929
  }
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) => {
930
+ }, K = "kaching-bundles-block", q = 1e4, J = "/kaching-bundles-block.js", He = "https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js", Ue = "https://bundles-integrations.kachingappz.app/kaching-bundles-block.js", Y = /* @__PURE__ */ new WeakSet(), We = async (e) => {
896
931
  let t = e.document;
897
932
  if (!e.customElements.get(K)) {
898
933
  if (Y.has(t)) return Z(e, K);
899
934
  Y.add(t);
900
935
  try {
901
- await je(e);
936
+ await qe(e);
902
937
  } catch (e) {
903
938
  throw Y.delete(t), e;
904
939
  }
905
940
  }
906
- }, ke = () => typeof window < "u" && window.__KACHING_DEV__ !== void 0, Ae = () => ke() ? Ee : De, je = async (e) => {
907
- let t = e.document, n = Ae();
941
+ }, Ge = () => typeof window < "u" && window.__KACHING_DEV__ !== void 0, Ke = () => Ge() ? He : Ue, qe = async (e) => {
942
+ let t = e.document, n = Ke();
908
943
  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);
944
+ let r = Je(t);
945
+ if (r && await Xe(t, r)) return Z(e, K);
911
946
  let i = t.createElement("script");
912
947
  return i.src = n, await X(t, i), Z(e, K);
913
- }, Me = (e) => {
948
+ }, Je = (e) => {
914
949
  let t = e.querySelectorAll(`link[rel="modulepreload"][href$="${J}"]`);
915
- return Array.from(t, (e) => e.href).find(Ne);
916
- }, Ne = (e) => {
950
+ return Array.from(t, (e) => e.href).find(Ye);
951
+ }, Ye = (e) => {
917
952
  try {
918
953
  return new URL(e).pathname.endsWith(J);
919
954
  } catch {
920
955
  return !1;
921
956
  }
922
- }, Pe = async (e, t) => {
957
+ }, Xe = async (e, t) => {
923
958
  let n = e.createElement("script");
924
959
  n.type = "module", n.setAttribute("crossorigin", "anonymous"), n.src = t;
925
960
  try {
@@ -931,9 +966,9 @@ var W = /* @__PURE__ */ function(e) {
931
966
  t.onload = () => n(), t.onerror = () => r(/* @__PURE__ */ Error("Failed to load script")), e.head.appendChild(t);
932
967
  }), Z = (e, t) => new Promise((n, r) => {
933
968
  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");
969
+ }), Q = "a-f\\d", Ze = `#?[${Q}]{3}[${Q}]?`, $ = `#?[${Q}]{6}([${Q}]{2})?`, Qe = RegExp(`[^#${Q}]`, "gi"), $e = RegExp(`^${Ze}$|^${$}$`, "i");
970
+ function et(e, t = {}) {
971
+ if (typeof e != "string" || Qe.test(e) || !$e.test(e)) throw TypeError("Expected a valid hex string");
937
972
  e = e.replace(/^#/, "");
938
973
  let n = 1;
939
974
  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 +986,7 @@ function Re(e, t = {}) {
951
986
  };
952
987
  }
953
988
  // src/react/preview.ts
954
- var ze = ({ price: e }) => ({
989
+ var tt = ({ price: e }) => ({
955
990
  id: 123,
956
991
  handle: "123",
957
992
  url: null,
@@ -984,7 +1019,7 @@ var ze = ({ price: e }) => ({
984
1019
  text4: null
985
1020
  },
986
1021
  isNativeBundle: !1
987
- }), Be = () => ({
1022
+ }), nt = () => ({
988
1023
  shopifyDomain: "",
989
1024
  moneyFormat: "${{amount_with_comma_separator}}",
990
1025
  locale: "en",
@@ -1040,7 +1075,7 @@ var ze = ({ price: e }) => ({
1040
1075
  },
1041
1076
  shopCustomStyles: "",
1042
1077
  featureFlags: {}
1043
- }), Ve = ({ color: e, cornerRadius: t }) => {
1078
+ }), rt = ({ color: e, cornerRadius: t }) => {
1044
1079
  let n = {
1045
1080
  id: "123",
1046
1081
  nanoId: "123",
@@ -1300,14 +1335,14 @@ var ze = ({ price: e }) => ({
1300
1335
  imageCornerRadius: 6
1301
1336
  };
1302
1337
  return e !== void 0 && (n.colors.border = {
1303
- ...Re(e),
1338
+ ...et(e),
1304
1339
  alpha: 1
1305
1340
  }), n;
1306
- }, He = ({ data: t, selectedVariantId: a, preview: o, onLinesChange: s, targetWindow: c }) => {
1341
+ }, it = ({ data: t, selectedVariantId: a, preview: o, onLinesChange: s, targetWindow: c }) => {
1307
1342
  let l = n(null), [u, d] = r(!1), f = n(!1);
1308
1343
  e(() => {
1309
1344
  l.current && !u && (async () => {
1310
- await Oe(c ?? window), d(!0);
1345
+ await We(c ?? window), d(!0);
1311
1346
  })();
1312
1347
  }, [u, c]), e(() => {
1313
1348
  let e = l.current;
@@ -1328,8 +1363,8 @@ var ze = ({ price: e }) => ({
1328
1363
  e.removeEventListener("kaching-bundles-block-loaded", t), e.removeEventListener("variants-changed", t);
1329
1364
  };
1330
1365
  }, [u, s]);
1331
- let p = t ? We(t, a) : o ? Ge(o) : null;
1332
- return Ue(() => {
1366
+ let p = t ? ot(t, a) : o ? st(o) : null;
1367
+ return at(() => {
1333
1368
  let e = l.current;
1334
1369
  if (e && p) for (let [t, n] of Object.entries(p.jsonAttributes)) e.getAttribute(t) !== n && e.setAttribute(t, n);
1335
1370
  }), p ? /* @__PURE__ */ i("kaching-bundles-block", {
@@ -1338,7 +1373,7 @@ var ze = ({ price: e }) => ({
1338
1373
  ...p.jsonAttributes,
1339
1374
  "current-variant-id": p.currentVariantId
1340
1375
  }) : 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) => ({
1376
+ }, at = typeof window > "u" ? e : t, ot = ({ config: e, dealBlock: t, product: n, otherProducts: r, mixAndMatchSwapProducts: i, mediaImages: a, collectionBreaksProducts: o, translations: s }, c) => ({
1342
1377
  dealBlockId: t.id,
1343
1378
  currentVariantId: c ? c.split("/").pop() : String(n.variants[0].id),
1344
1379
  jsonAttributes: {
@@ -1351,8 +1386,8 @@ var ze = ({ price: e }) => ({
1351
1386
  "collection-breaks-products": JSON.stringify(o),
1352
1387
  translations: JSON.stringify(s)
1353
1388
  }
1354
- }), Ge = ({ cornerRadius: e, color: t, price: n }) => {
1355
- let r = ze({ price: n }), i = Be(), a = Ve({
1389
+ }), st = ({ cornerRadius: e, color: t, price: n }) => {
1390
+ let r = tt({ price: n }), i = nt(), a = rt({
1356
1391
  color: t,
1357
1392
  cornerRadius: e
1358
1393
  });
@@ -1371,4 +1406,4 @@ var ze = ({ price: e }) => ({
1371
1406
  }
1372
1407
  };
1373
1408
  };
1374
- export { He as KachingBundle, Te as fetchKachingBundlesData };
1409
+ export { it as KachingBundle, Ve as fetchKachingBundlesData };