@kachingappz/bundles-js 1.0.0 → 1.1.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,61 +1,61 @@
1
- import { jsx as G } from "react/jsx-runtime";
2
- import { useRef as B, useState as R, useEffect as E } from "react";
3
- const L = (e, t) => {
1
+ import { jsx as F } from "react/jsx-runtime";
2
+ import { useRef as B, useState as R, useEffect as D, useLayoutEffect as L } from "react";
3
+ const J = (e, t) => {
4
4
  const a = [], l = e.filter(
5
- (n) => n.blockVisibility === "selected-products"
5
+ (r) => r.blockVisibility === "selected-products"
6
6
  );
7
- for (const n of l)
8
- n.selectedProductIds.map(Number).includes(t.id) && a.push(n);
9
- const r = e.filter(
10
- (n) => n.blockVisibility === "selected-collections"
7
+ for (const r of l)
8
+ r.selectedProductIds.map(Number).includes(t.id) && a.push(r);
9
+ const s = e.filter(
10
+ (r) => r.blockVisibility === "selected-collections"
11
11
  );
12
- for (const n of r)
12
+ for (const r of s)
13
13
  t.collectionIds.some(
14
- (m) => n.selectedCollectionIds.map(Number).includes(m)
15
- ) && a.push(n);
14
+ (m) => r.selectedCollectionIds.map(Number).includes(m)
15
+ ) && a.push(r);
16
16
  const i = e.filter(
17
- (n) => n.blockVisibility === "excluded-products"
17
+ (r) => r.blockVisibility === "excluded-products"
18
18
  );
19
- for (const n of i)
20
- !n.excludedProductIds.map(Number).includes(t.id) && !(n.excludedCollectionIds || []).some(
19
+ for (const r of i)
20
+ !r.excludedProductIds.map(Number).includes(t.id) && !(r.excludedCollectionIds || []).some(
21
21
  (m) => t.collectionIds.includes(m)
22
- ) && a.push(n);
22
+ ) && a.push(r);
23
23
  const o = e.filter(
24
- (n) => n.blockVisibility === "all-products"
24
+ (r) => r.blockVisibility === "all-products"
25
25
  );
26
- for (const n of o)
27
- a.push(n);
26
+ for (const r of o)
27
+ a.push(r);
28
28
  return a;
29
- }, J = (e, { language: t, country: a }) => {
30
- var g, y;
31
- const l = z(t, a), r = new Intl.NumberFormat(l, {
29
+ }, z = (e, { language: t, country: a }) => {
30
+ var f, g;
31
+ const l = Q(t, a), s = new Intl.NumberFormat(l, {
32
32
  style: "currency",
33
33
  currency: e,
34
34
  currencyDisplay: "narrowSymbol"
35
- }).formatToParts(123456789e-2), i = (g = r.find((p) => p.type === "decimal")) == null ? void 0 : g.value, o = Q(
36
- (y = r.find((p) => p.type === "group")) == null ? void 0 : y.value
37
- ), n = r.some((p) => p.type === "fraction"), m = H(
35
+ }).formatToParts(123456789e-2), i = (f = s.find((y) => y.type === "decimal")) == null ? void 0 : f.value, o = H(
36
+ (g = s.find((y) => y.type === "group")) == null ? void 0 : g.value
37
+ ), r = s.some((y) => y.type === "fraction"), m = K(
38
38
  o,
39
39
  i,
40
- n
41
- ), c = r.findIndex(M), d = r.findLastIndex(M);
40
+ r
41
+ ), d = s.findIndex(C), c = s.findLastIndex(C);
42
42
  return [
43
- ...r.slice(0, c).map(C),
43
+ ...s.slice(0, d).map(E),
44
44
  m,
45
- ...r.slice(d + 1).map(C)
45
+ ...s.slice(c + 1).map(E)
46
46
  ].join("");
47
- }, C = (e) => V(e.value), V = (e) => e.replace(/\s/g, " "), M = (e) => e.type === "integer" || e.type === "group" || e.type === "decimal" || e.type === "fraction", z = (e, t) => e && t ? `${e}-${t.toUpperCase()}` : e || (t ? t.toUpperCase() : "en"), Q = (e) => e === void 0 ? void 0 : V(e).replace(/’/g, "'"), H = (e, t, a) => t === "," && e === "." ? a ? "{{amount_with_comma_separator}}" : "{{amount_no_decimals_with_comma_separator}}" : t === "," && e === " " ? a ? "{{amount_with_space_separator}}" : "{{amount_no_decimals_with_space_separator}}" : t === "." && e === " " ? "{{amount_with_period_and_space_separator}}" : t === "." && e === "'" ? "{{amount_with_apostrophe_separator}}" : a ? "{{amount}}" : "{{amount_no_decimals}}", w = ({
47
+ }, E = (e) => V(e.value), V = (e) => e.replace(/\s/g, " "), C = (e) => e.type === "integer" || e.type === "group" || e.type === "decimal" || e.type === "fraction", Q = (e, t) => e && t ? `${e}-${t.toUpperCase()}` : e || (t ? t.toUpperCase() : "en"), H = (e) => e === void 0 ? void 0 : V(e).replace(/’/g, "'"), K = (e, t, a) => t === "," && e === "." ? a ? "{{amount_with_comma_separator}}" : "{{amount_no_decimals_with_comma_separator}}" : t === "," && e === " " ? a ? "{{amount_with_space_separator}}" : "{{amount_no_decimals_with_space_separator}}" : t === "." && e === " " ? "{{amount_with_period_and_space_separator}}" : t === "." && e === "'" ? "{{amount_with_apostrophe_separator}}" : a ? "{{amount}}" : "{{amount_no_decimals}}", w = ({
48
48
  country: e,
49
49
  language: t
50
50
  }) => {
51
51
  const a = [];
52
52
  return e && a.push(`country: ${e}`), t && a.push(`language: ${t}`), a.length > 0 ? `@inContext(${a.join(", ")})` : "";
53
- }, K = async (e, {
53
+ }, W = async (e, {
54
54
  useExternalMetafieldNamespace: t,
55
55
  useMetaobjects: a
56
- }) => a ? X(
56
+ }) => a ? Y(
57
57
  e
58
- ) : W(e), W = async (e, t) => {
58
+ ) : X(e), X = async (e, t) => {
59
59
  var l;
60
60
  const a = (l = (await e.query(
61
61
  `
@@ -74,9 +74,9 @@ const L = (e, t) => {
74
74
  }
75
75
  )).shop.metafield) == null ? void 0 : l.value;
76
76
  return a ? JSON.parse(a) : [];
77
- }, X = async (e, t) => {
77
+ }, Y = async (e, t) => {
78
78
  const a = "app--2935586817--deal_block", l = [];
79
- let r = null;
79
+ let s = null;
80
80
  for (; ; ) {
81
81
  const i = await e.query(
82
82
  `
@@ -98,39 +98,39 @@ const L = (e, t) => {
98
98
  {
99
99
  variables: {
100
100
  type: a,
101
- cursor: r
101
+ cursor: s
102
102
  }
103
103
  }
104
104
  );
105
105
  for (const o of i.metaobjects.nodes) {
106
- const n = o.fields.find(
106
+ const r = o.fields.find(
107
107
  (m) => m.key === "settings"
108
108
  );
109
- n != null && n.value && l.push(JSON.parse(n.value));
109
+ r != null && r.value && l.push(JSON.parse(r.value));
110
110
  }
111
111
  if (!i.metaobjects.pageInfo.hasNextPage)
112
112
  break;
113
- r = i.metaobjects.pageInfo.endCursor;
113
+ s = i.metaobjects.pageInfo.endCursor;
114
114
  }
115
115
  return l;
116
- }, T = async (e, {
116
+ }, M = async (e, {
117
117
  country: t,
118
118
  language: a,
119
119
  blockVisibility: l,
120
- excludedProductGIDs: r,
120
+ excludedProductGIDs: s,
121
121
  selectedProductGIDs: i,
122
122
  selectedCollectionGIDs: o,
123
- limit: n = 1e3
123
+ limit: r = 1e3
124
124
  }) => {
125
125
  switch (l) {
126
126
  case "selected-products":
127
- return i.slice(0, n);
127
+ return i.slice(0, r);
128
128
  case "all-products":
129
129
  case "excluded-products": {
130
130
  const m = w({ country: t, language: a });
131
- let c = [], d = null;
132
- for (; c.length < n; ) {
133
- const g = Math.min(n - c.length, 250), y = await e.query(
131
+ let d = [], c = null;
132
+ for (; d.length < r; ) {
133
+ const f = Math.min(r - d.length, 250), g = await e.query(
134
134
  `
135
135
  query FetchProductGIDs($limit: Int!, $cursor: String) ${m} {
136
136
  products(first: $limit, after: $cursor) {
@@ -146,22 +146,22 @@ const L = (e, t) => {
146
146
  `,
147
147
  {
148
148
  variables: {
149
- limit: g,
150
- cursor: d
149
+ limit: f,
150
+ cursor: c
151
151
  }
152
152
  }
153
153
  );
154
- if (c.push(...y.products.nodes.map((p) => p.id)), !y.products.pageInfo.hasNextPage) break;
155
- d = y.products.pageInfo.endCursor;
154
+ if (d.push(...g.products.nodes.map((y) => y.id)), !g.products.pageInfo.hasNextPage) break;
155
+ c = g.products.pageInfo.endCursor;
156
156
  }
157
157
  if (l === "excluded-products") {
158
- const g = new Set(r);
159
- c = c.filter((y) => !g.has(y));
158
+ const f = new Set(s);
159
+ d = d.filter((g) => !f.has(g));
160
160
  }
161
- return c;
161
+ return d;
162
162
  }
163
163
  case "selected-collections": {
164
- const m = w({ country: t, language: a }), c = (await e.query(
164
+ const m = w({ country: t, language: a }), d = (await e.query(
165
165
  `
166
166
  query FetchCollectionProductGIDs($collectionGIDs: [ID!]!, $limit: Int!) ${m} {
167
167
  nodes(ids: $collectionGIDs) {
@@ -178,16 +178,16 @@ const L = (e, t) => {
178
178
  {
179
179
  variables: {
180
180
  collectionGIDs: o,
181
- limit: Math.min(n, 250)
181
+ limit: Math.min(r, 250)
182
182
  }
183
183
  }
184
- )).nodes.filter((d) => d !== null).flatMap(
185
- (d) => d.products.nodes.map((g) => g.id)
184
+ )).nodes.filter((c) => c !== null).flatMap(
185
+ (c) => c.products.nodes.map((f) => f.id)
186
186
  );
187
- return Array.from(new Set(c)).slice(0, n);
187
+ return Array.from(new Set(d)).slice(0, r);
188
188
  }
189
189
  }
190
- }, F = `
190
+ }, U = `
191
191
  id
192
192
  availableForSale
193
193
  price {
@@ -230,20 +230,20 @@ const L = (e, t) => {
230
230
  }
231
231
  }
232
232
  quantityAvailable @include(if: $includeAvailableQuantity)
233
- `, D = async (e, {
233
+ `, A = async (e, {
234
234
  country: t,
235
235
  language: a,
236
236
  productIds: l,
237
- includeSellingPlans: r = !0,
237
+ includeSellingPlans: s = !0,
238
238
  includeAvailableQuantity: i = !0,
239
239
  useExternalMetafieldNamespace: o = !1,
240
- batchSize: n = 250,
240
+ batchSize: r = 250,
241
241
  onBatchError: m
242
242
  }) => {
243
243
  if (!l.length)
244
244
  return [];
245
- const c = l.map((u) => typeof u == "string" && u.startsWith("gid://") ? u : `gid://shopify/Product/${u}`), d = w({ country: t, language: a }), g = `
246
- query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $metafieldNamespace: String!) ${d} {
245
+ const d = l.map((u) => typeof u == "string" && u.startsWith("gid://") ? u : `gid://shopify/Product/${u}`), c = w({ country: t, language: a }), f = `
246
+ query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $metafieldNamespace: String!) ${c} {
247
247
  shop {
248
248
  currencyRateConstant: metafield(namespace: $metafieldNamespace, key: "currency_rate_constant") {
249
249
  value
@@ -277,7 +277,7 @@ const L = (e, t) => {
277
277
  }
278
278
  variants(first: 250) {
279
279
  nodes {
280
- ${F}
280
+ ${U}
281
281
  }
282
282
  }
283
283
  collections(first: 50) {
@@ -329,24 +329,24 @@ const L = (e, t) => {
329
329
  }
330
330
  }
331
331
  }
332
- `, y = o ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles", p = [], h = Math.min(n, 250);
333
- for (let u = 0; u < c.length; u += h)
334
- p.push(c.slice(u, u + h));
335
- let s = 1;
336
- const f = async (u) => {
337
- const v = await e.query(g, {
332
+ `, g = o ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles", y = [], h = Math.min(r, 250);
333
+ for (let u = 0; u < d.length; u += h)
334
+ y.push(d.slice(u, u + h));
335
+ let n = 1;
336
+ const p = async (u) => {
337
+ const v = await e.query(f, {
338
338
  variables: {
339
339
  productGIDs: u,
340
- includeSellingPlans: r,
340
+ includeSellingPlans: s,
341
341
  includeAvailableQuantity: i,
342
- metafieldNamespace: y
342
+ metafieldNamespace: g
343
343
  }
344
344
  });
345
- return v.shop.currencyRateConstant && (s = JSON.parse(v.shop.currencyRateConstant.value).amount / 1e6), v;
345
+ return v.shop.currencyRateConstant && (n = JSON.parse(v.shop.currencyRateConstant.value).amount / 1e6), v;
346
346
  };
347
347
  let b;
348
348
  if (m) {
349
- const u = await Promise.allSettled(p.map(f));
349
+ const u = await Promise.allSettled(y.map(p));
350
350
  for (const v of u)
351
351
  v.status === "rejected" && m(
352
352
  v.reason instanceof Error ? v.reason : new Error(String(v.reason))
@@ -355,21 +355,21 @@ const L = (e, t) => {
355
355
  (v) => v.status === "fulfilled"
356
356
  ).flatMap((v) => v.value.nodes);
357
357
  } else
358
- b = (await Promise.all(p.map(f))).flatMap((u) => u.nodes);
358
+ b = (await Promise.all(y.map(p))).flatMap((u) => u.nodes);
359
359
  const _ = b.filter((u) => u != null);
360
360
  if (m) {
361
361
  const u = await Promise.allSettled(
362
362
  _.map(async (I) => {
363
- const P = await q(
363
+ const P = await T(
364
364
  e,
365
365
  I,
366
- { includeSellingPlans: r, includeAvailableQuantity: i },
367
- d
366
+ { includeSellingPlans: s, includeAvailableQuantity: i },
367
+ c
368
368
  );
369
- return O(
369
+ return q(
370
370
  P,
371
371
  e.shopifyDomain,
372
- s
372
+ n
373
373
  );
374
374
  })
375
375
  ), v = [];
@@ -381,32 +381,32 @@ const L = (e, t) => {
381
381
  }
382
382
  return (await Promise.all(
383
383
  _.map(
384
- (u) => q(
384
+ (u) => T(
385
385
  e,
386
386
  u,
387
387
  {
388
- includeSellingPlans: r,
388
+ includeSellingPlans: s,
389
389
  includeAvailableQuantity: i
390
390
  },
391
- d
391
+ c
392
392
  )
393
393
  )
394
394
  )).map(
395
- (u) => O(u, e.shopifyDomain, s)
395
+ (u) => q(u, e.shopifyDomain, n)
396
396
  );
397
- }, q = async (e, t, a, l = "") => {
397
+ }, T = async (e, t, a, l = "") => {
398
398
  if (t.variants.nodes.length < 250)
399
399
  return t;
400
- const r = /* @__PURE__ */ new Set(), i = [], o = [], n = async (m) => {
401
- let c = !0, d = null;
402
- for (; c; ) {
403
- const g = await e.query(
400
+ const s = /* @__PURE__ */ new Set(), i = [], o = [], r = async (m) => {
401
+ let d = !0, c = null;
402
+ for (; d; ) {
403
+ const f = await e.query(
404
404
  `
405
405
  query($productGID: ID!, $cursor: String, $reverse: Boolean, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!) ${l} {
406
406
  product(id: $productGID) {
407
407
  variants(first: 250, after: $cursor, reverse: $reverse) {
408
408
  nodes {
409
- ${F}
409
+ ${U}
410
410
  }
411
411
  pageInfo {
412
412
  endCursor
@@ -419,64 +419,64 @@ const L = (e, t) => {
419
419
  {
420
420
  variables: {
421
421
  productGID: t.id,
422
- cursor: d,
422
+ cursor: c,
423
423
  reverse: m,
424
424
  ...a
425
425
  }
426
426
  }
427
- ), { nodes: y, pageInfo: p } = g.product.variants;
428
- for (const h of y) {
429
- if (r.has(h.id)) {
430
- c = !1;
427
+ ), { nodes: g, pageInfo: y } = f.product.variants;
428
+ for (const h of g) {
429
+ if (s.has(h.id)) {
430
+ d = !1;
431
431
  break;
432
432
  }
433
- r.add(h.id), m ? o.push(h) : i.push(h);
433
+ s.add(h.id), m ? o.push(h) : i.push(h);
434
434
  }
435
- p.hasNextPage || (c = !1), d = p.endCursor;
435
+ y.hasNextPage || (d = !1), c = y.endCursor;
436
436
  }
437
437
  };
438
438
  return await Promise.all([
439
- n(!1),
440
- n(!0)
439
+ r(!1),
440
+ r(!0)
441
441
  ]), t.variants.nodes = [...i, ...o.reverse()], t;
442
- }, O = (e, t, a) => {
443
- var c, d, g, y, p, h;
442
+ }, q = (e, t, a) => {
443
+ var d, c, f, g, y, h;
444
444
  const l = e.variants.nodes.map(
445
- ({ unitPriceMeasurement: s, ...f }) => {
445
+ ({ unitPriceMeasurement: n, ...p }) => {
446
446
  var b, _;
447
447
  return {
448
- id: Number(f.id.split("/").pop()),
449
- availableForSale: f.availableForSale,
450
- price: Math.round(Number(f.price.amount) * 100),
451
- compareAtPrice: f.compareAtPrice ? Math.round(Number(f.compareAtPrice.amount) * 100) : null,
452
- options: f.selectedOptions.map((u) => u.value),
453
- imageId: f.image ? Number(f.image.id.split("/").pop()) : null,
454
- image: ((b = f.image) == null ? void 0 : b.url) || null,
455
- sellingPlans: ((_ = f.sellingPlanAllocations) == null ? void 0 : _.nodes.map((u) => ({
448
+ id: Number(p.id.split("/").pop()),
449
+ availableForSale: p.availableForSale,
450
+ price: Math.round(Number(p.price.amount) * 100),
451
+ compareAtPrice: p.compareAtPrice ? Math.round(Number(p.compareAtPrice.amount) * 100) : null,
452
+ options: p.selectedOptions.map((u) => u.value),
453
+ imageId: p.image ? Number(p.image.id.split("/").pop()) : null,
454
+ image: ((b = p.image) == null ? void 0 : b.url) || null,
455
+ sellingPlans: ((_ = p.sellingPlanAllocations) == null ? void 0 : _.nodes.map((u) => ({
456
456
  id: Number(u.sellingPlan.id.split("/").pop()),
457
- price: u.priceAdjustments.length > 0 ? Math.round(Number(u.priceAdjustments[0].price.amount) * 100) : Math.round(Number(f.price.amount) * 100),
457
+ price: u.priceAdjustments.length > 0 ? Math.round(Number(u.priceAdjustments[0].price.amount) * 100) : Math.round(Number(p.price.amount) * 100),
458
458
  compareAtPrice: u.priceAdjustments.length > 0 ? Math.round(
459
459
  Number(u.priceAdjustments[0].compareAtPrice.amount) * 100
460
- ) : Math.round(Number(f.price.amount) * 100),
460
+ ) : Math.round(Number(p.price.amount) * 100),
461
461
  perDeliveryPrice: u.priceAdjustments.length > 0 ? Math.round(
462
462
  Number(u.priceAdjustments[0].perDeliveryPrice.amount) * 100
463
- ) : Math.round(Number(f.price.amount) * 100)
463
+ ) : Math.round(Number(p.price.amount) * 100)
464
464
  }))) || [],
465
465
  inventoryManagement: null,
466
466
  // Storefront API does not return inventory management, only available in liquid
467
467
  inventoryPolicy: null,
468
468
  // Storefront API does not return inventory policy, only available in liquid
469
- inventoryQuantity: f.quantityAvailable ?? null,
470
- unitPriceMeasurement: s != null && s.quantityUnit && (s != null && s.referenceUnit) ? {
471
- quantityValue: s.quantityValue,
472
- quantityUnit: s.quantityUnit.toLowerCase(),
473
- referenceValue: s.referenceValue,
474
- referenceUnit: s.referenceUnit.toLowerCase()
469
+ inventoryQuantity: p.quantityAvailable ?? null,
470
+ unitPriceMeasurement: n != null && n.quantityUnit && (n != null && n.referenceUnit) ? {
471
+ quantityValue: n.quantityValue,
472
+ quantityUnit: n.quantityUnit.toLowerCase(),
473
+ referenceValue: n.referenceValue,
474
+ referenceUnit: n.referenceUnit.toLowerCase()
475
475
  } : null
476
476
  };
477
477
  }
478
- ), r = e.options.map((s, f) => {
479
- const b = s.optionValues.map((_) => {
478
+ ), s = e.options.map((n, p) => {
479
+ const b = n.optionValues.map((_) => {
480
480
  var u, v, I, P;
481
481
  return {
482
482
  id: Number(_.id.split("/").pop()),
@@ -489,16 +489,16 @@ const L = (e, t) => {
489
489
  };
490
490
  });
491
491
  return {
492
- defaultName: s.name,
493
- name: s.name,
494
- position: f + 1,
495
- optionValues: Y(b, f, l)
492
+ defaultName: n.name,
493
+ name: n.name,
494
+ position: p + 1,
495
+ optionValues: Z(b, p, l)
496
496
  };
497
- }), i = (s) => {
498
- const f = s.priceAdjustments[0];
499
- if (!f)
497
+ }), i = (n) => {
498
+ const p = n.priceAdjustments[0];
499
+ if (!p)
500
500
  return null;
501
- const b = f.adjustmentValue;
501
+ const b = p.adjustmentValue;
502
502
  switch (b.__typename) {
503
503
  case "SellingPlanPercentagePriceAdjustment":
504
504
  return {
@@ -520,14 +520,14 @@ const L = (e, t) => {
520
520
  `Unknown price adjustment type: ${b.__typename}`
521
521
  );
522
522
  }
523
- }, o = (s) => a === 1 ? Number(s) * 100 : Math.round(Number(s) * 100 * a), n = ((c = e.sellingPlanGroups) == null ? void 0 : c.nodes.flatMap(
524
- (s) => s.sellingPlans.nodes.map((f) => ({
525
- id: Number(f.id.split("/").pop()),
526
- name: f.name,
527
- priceAdjustment: i(f)
523
+ }, o = (n) => a === 1 ? Number(n) * 100 : Math.round(Number(n) * 100 * a), r = ((d = e.sellingPlanGroups) == null ? void 0 : d.nodes.flatMap(
524
+ (n) => n.sellingPlans.nodes.map((p) => ({
525
+ id: Number(p.id.split("/").pop()),
526
+ name: p.name,
527
+ priceAdjustment: i(p)
528
528
  }))
529
529
  )) || [], m = e.variants.nodes.some(
530
- (s) => s.requiresComponents
530
+ (n) => n.requiresComponents
531
531
  );
532
532
  return {
533
533
  id: Number(e.id.split("/").pop()),
@@ -536,44 +536,44 @@ const L = (e, t) => {
536
536
  availableForSale: e.availableForSale,
537
537
  createdAt: e.createdAt,
538
538
  title: e.title,
539
- image: ((d = e.featuredImage) == null ? void 0 : d.url) || null,
539
+ image: ((c = e.featuredImage) == null ? void 0 : c.url) || null,
540
540
  collectionIds: e.collections.nodes.map(
541
- (s) => Number(s.id.split("/").pop())
541
+ (n) => Number(n.id.split("/").pop())
542
542
  ),
543
- options: r,
543
+ options: s,
544
544
  selectedVariantId: Number(
545
545
  e.variants.nodes[0].id.split("/").pop()
546
546
  ),
547
547
  variants: l,
548
548
  requiresSellingPlan: e.requiresSellingPlan,
549
- sellingPlans: n,
549
+ sellingPlans: r,
550
550
  isNativeBundle: m,
551
551
  metafields: {
552
- text: ((g = e.metafield) == null ? void 0 : g.value) || null,
553
- text2: ((y = e.metafield2) == null ? void 0 : y.value) || null,
554
- text3: ((p = e.metafield3) == null ? void 0 : p.value) || null,
552
+ text: ((f = e.metafield) == null ? void 0 : f.value) || null,
553
+ text2: ((g = e.metafield2) == null ? void 0 : g.value) || null,
554
+ text3: ((y = e.metafield3) == null ? void 0 : y.value) || null,
555
555
  text4: ((h = e.metafield4) == null ? void 0 : h.value) || null
556
556
  }
557
557
  };
558
- }, Y = (e, t, a) => e.filter((l) => a.filter(
559
- (r) => r.options[t] === l.name
560
- ).length > 0), j = "app--2935586817", Z = async (e, {
558
+ }, Z = (e, t, a) => e.filter((l) => a.filter(
559
+ (s) => s.options[t] === l.name
560
+ ).length > 0), j = "app--2935586817", ee = async (e, {
561
561
  language: t,
562
562
  country: a,
563
563
  useExternalMetafieldNamespace: l
564
564
  }) => {
565
- const r = `${j}--kaching_bundles`, i = j, o = w({ country: a }), {
565
+ const s = `${j}--kaching_bundles`, i = j, o = w({ country: a }), {
566
566
  localization: {
567
567
  country: {
568
- currency: { isoCode: n }
568
+ currency: { isoCode: r }
569
569
  }
570
570
  },
571
571
  shop: {
572
572
  moneyFormat: m,
573
- paymentSettings: { currencyCode: c },
574
- currencyRateConstant: d,
575
- primaryDomain: g,
576
- settingsMetafield: y
573
+ paymentSettings: { currencyCode: d },
574
+ currencyRateConstant: c,
575
+ primaryDomain: f,
576
+ settingsMetafield: g
577
577
  }
578
578
  } = await e.query(
579
579
  `
@@ -604,30 +604,30 @@ const L = (e, t) => {
604
604
  `,
605
605
  {
606
606
  variables: {
607
- metafieldNamespace: r,
607
+ metafieldNamespace: s,
608
608
  settingsNamespace: i
609
609
  }
610
610
  }
611
- ), p = n === c ? m : J(n, { language: t, country: a }), h = d ? ee(d.value) : 1, s = y ? JSON.parse(y.value) : null, f = (s == null ? void 0 : s.feature_flags) ?? {}, b = (s == null ? void 0 : s.custom_selectors) ?? {};
611
+ ), y = r === d ? m : z(r, { language: t, country: a }), h = c ? te(c.value) : 1, n = g ? JSON.parse(g.value) : null, p = (n == null ? void 0 : n.feature_flags) ?? {}, b = (n == null ? void 0 : n.custom_selectors) ?? {};
612
612
  return {
613
- shopifyDomain: g.host,
614
- moneyFormat: p,
613
+ shopifyDomain: f.host,
614
+ moneyFormat: y,
615
615
  locale: (t == null ? void 0 : t.toLowerCase()) || "en",
616
616
  liquidLocale: (t == null ? void 0 : t.toLowerCase()) || "en",
617
617
  country: a ?? "US",
618
618
  currencyRate: h,
619
619
  marketId: 0,
620
620
  productId: null,
621
- storefrontAccessToken: (s == null ? void 0 : s.storefront_access_token) ?? null,
622
- includeSellingPlans: (s == null ? void 0 : s.include_selling_plans) ?? !1,
623
- includeAvailableQuantity: (s == null ? void 0 : s.include_available_quantity) ?? !1,
624
- customApiHost: (s == null ? void 0 : s.custom_api_host) ?? null,
625
- keepQuantityInput: (s == null ? void 0 : s.keep_quantity_input) ?? !1,
626
- ignoreDeselect: (s == null ? void 0 : s.ignore_deselect) ?? !1,
627
- ignoreUnitPrice: (s == null ? void 0 : s.ignore_unit_price) ?? !1,
628
- requireCustomerLogin: (s == null ? void 0 : s.require_customer_login) ?? !1,
629
- abTestsRunning: (s == null ? void 0 : s.ab_tests_running) ?? !1,
630
- webPixel: (s == null ? void 0 : s.web_pixel) ?? !1,
621
+ storefrontAccessToken: (n == null ? void 0 : n.storefront_access_token) ?? null,
622
+ includeSellingPlans: (n == null ? void 0 : n.include_selling_plans) ?? !1,
623
+ includeAvailableQuantity: (n == null ? void 0 : n.include_available_quantity) ?? !1,
624
+ customApiHost: (n == null ? void 0 : n.custom_api_host) ?? null,
625
+ keepQuantityInput: (n == null ? void 0 : n.keep_quantity_input) ?? !1,
626
+ ignoreDeselect: (n == null ? void 0 : n.ignore_deselect) ?? !1,
627
+ ignoreUnitPrice: (n == null ? void 0 : n.ignore_unit_price) ?? !1,
628
+ requireCustomerLogin: (n == null ? void 0 : n.require_customer_login) ?? !1,
629
+ abTestsRunning: (n == null ? void 0 : n.ab_tests_running) ?? !1,
630
+ webPixel: (n == null ? void 0 : n.web_pixel) ?? !1,
631
631
  b2bCustomer: !1,
632
632
  isLoggedIn: !1,
633
633
  preview: !1,
@@ -665,11 +665,11 @@ const L = (e, t) => {
665
665
  price: b.price ?? null,
666
666
  priceCompare: b.price_compare ?? null
667
667
  },
668
- shopCustomStyles: (s == null ? void 0 : s.shop_custom_styles) ?? "",
669
- featureFlags: f,
670
- brandColors: (s == null ? void 0 : s.brand_colors) ?? null
668
+ shopCustomStyles: (n == null ? void 0 : n.shop_custom_styles) ?? "",
669
+ featureFlags: p,
670
+ brandColors: (n == null ? void 0 : n.brand_colors) ?? null
671
671
  };
672
- }, ee = (e) => JSON.parse(e).amount / 1e6, te = async (e, t, a = 200) => (t = t.filter(Boolean).filter((l) => !l.startsWith("placeholder")), t.length === 0 ? [] : (await e.query(
672
+ }, te = (e) => JSON.parse(e).amount / 1e6, ae = async (e, t, a = 200) => (t = t.filter(Boolean).filter((l) => !l.startsWith("placeholder")), t.length === 0 ? [] : (await e.query(
673
673
  `
674
674
  query FetchMediaImages($mediaImageIds: [ID!]!, $size: Int!) {
675
675
  nodes(ids: $mediaImageIds) {
@@ -693,10 +693,9 @@ const L = (e, t) => {
693
693
  url: l.image.url
694
694
  })));
695
695
  var k = /* @__PURE__ */ ((e) => (e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e))(k || {});
696
- const ae = (e) => [
697
- ...se(e),
698
- ...le(e),
696
+ const se = (e) => [
699
697
  ...ne(e),
698
+ ...le(e),
700
699
  ...re(e),
701
700
  ...ie(e),
702
701
  ...oe(e),
@@ -706,85 +705,86 @@ const ae = (e) => [
706
705
  ...me(e),
707
706
  ...pe(e),
708
707
  ...fe(e),
709
- ...ye(e)
710
- ].filter((t) => t != null && !t.includes("placeholder")), se = (e) => e.dealBars.flatMap((t) => [t.mediaImageGID, t.badgeImageGID]).filter((t) => t != null), le = (e) => e.dealBars.flatMap(
708
+ ...ye(e),
709
+ ...ge(e)
710
+ ].filter((t) => t != null && !t.includes("placeholder")), ne = (e) => e.dealBars.flatMap((t) => [t.mediaImageGID, t.badgeImageGID]).filter((t) => t != null), le = (e) => e.dealBars.flatMap(
711
711
  (t) => t.dealBarType === k.Bundle ? t.bundleProducts.map(
712
712
  (a) => a.mediaImageGID
713
713
  ) : []
714
- ).filter((t) => t != null), ne = (e) => e.dealBars.map(
714
+ ).filter((t) => t != null), re = (e) => e.dealBars.map(
715
715
  ({ freeGifts: t }) => (t || []).map((a) => a.mediaImageGID)
716
- ).reduce((t, a) => t.concat(a), []).filter((t) => t != null), re = (e) => e.dealBars.flatMap(
716
+ ).reduce((t, a) => t.concat(a), []).filter((t) => t != null), ie = (e) => e.dealBars.flatMap(
717
717
  ({ multipleGiftsSelectors: t }) => (t || []).map((a) => a.mediaImageGID)
718
- ).filter((t) => t != null), ie = (e) => e.dealBars.map(({ upsells: t }) => (t || []).map((a) => a.mediaImageGID)).reduce((t, a) => t.concat(a), []).filter((t) => t != null), oe = (e) => e.swatchOptions ? e.swatchOptions.reduce((t, a) => {
719
- const l = a.images.map((r) => r.mediaImageGID).filter((r) => r != null);
718
+ ).filter((t) => t != null), oe = (e) => e.dealBars.map(({ upsells: t }) => (t || []).map((a) => a.mediaImageGID)).reduce((t, a) => t.concat(a), []).filter((t) => t != null), ce = (e) => e.swatchOptions ? e.swatchOptions.reduce((t, a) => {
719
+ const l = a.images.map((s) => s.mediaImageGID).filter((s) => s != null);
720
720
  return [...t, ...l];
721
- }, []) : [], ce = (e) => {
721
+ }, []) : [], ue = (e) => {
722
722
  if (!e.collectionBreaksEnabled || !e.collectionBreaks)
723
723
  return [];
724
724
  const t = e.collectionBreaks.mediaImageGID;
725
725
  return t ? [t] : [];
726
- }, ue = (e) => {
726
+ }, de = (e) => {
727
727
  var t, a, l;
728
728
  return e.progressiveGifts ? [
729
- ...((t = e.progressiveGifts.gifts) == null ? void 0 : t.map((r) => r.mediaImageGID)) || [],
729
+ ...((t = e.progressiveGifts.gifts) == null ? void 0 : t.map((s) => s.mediaImageGID)) || [],
730
730
  (a = e.progressiveGifts.style) == null ? void 0 : a.lockedMediaImageGID,
731
731
  (l = e.progressiveGifts.dealBarStyle) == null ? void 0 : l.lockedMediaImageGID
732
- ].filter((r) => r != null) : [];
733
- }, de = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.flatMap((t) => [t.mediaImageGID, t.badgeImageGID]).filter((t) => t != null), me = (e) => e.dealBars.map((t) => {
732
+ ].filter((s) => s != null) : [];
733
+ }, me = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.flatMap((t) => [t.mediaImageGID, t.badgeImageGID]).filter((t) => t != null), pe = (e) => e.dealBars.map((t) => {
734
734
  var a;
735
735
  return (a = t.productPersonalisation) == null ? void 0 : a.mediaImageGID;
736
- }).filter((t) => t != null), pe = (e) => {
737
- var l, r;
736
+ }).filter((t) => t != null), fe = (e) => {
737
+ var l, s;
738
738
  const t = e.dealBars.map((i) => {
739
739
  var o;
740
740
  return (o = i.highlights) == null ? void 0 : o.customIconGID;
741
- }).filter((i) => i != null), a = (r = (l = e.subscriptions) == null ? void 0 : l.highlights) == null ? void 0 : r.customIconGID;
741
+ }).filter((i) => i != null), a = (s = (l = e.subscriptions) == null ? void 0 : l.highlights) == null ? void 0 : s.customIconGID;
742
742
  return a ? [...t, a] : t;
743
- }, fe = (e) => (e.badges || []).flatMap(
743
+ }, ye = (e) => (e.badges || []).flatMap(
744
744
  (t) => t.badgeType === "custom" && t.imageGID ? [t.imageGID] : []
745
- ), ye = (e) => !e.savingsSummaryEnabled || !e.savingsSummary ? [] : e.savingsSummary.customIconGID ? [e.savingsSummary.customIconGID] : [], ge = (e) => {
745
+ ), ge = (e) => !e.savingsSummaryEnabled || !e.savingsSummary ? [] : e.savingsSummary.customIconGID ? [e.savingsSummary.customIconGID] : [], he = (e) => {
746
746
  const t = [
747
- ...he(e),
748
747
  ...be(e),
749
748
  ...ve(e),
750
749
  ..._e(e),
751
750
  ...Ie(e),
752
751
  ...Pe(e),
753
752
  ...Se(e),
754
- ...ke(e)
753
+ ...ke(e),
754
+ ...we(e)
755
755
  ];
756
756
  return Array.from(new Set(t.filter((a) => a != null)));
757
- }, he = (e) => e.dealBars.flatMap(
757
+ }, be = (e) => e.dealBars.flatMap(
758
758
  ({ freeGifts: t }) => t ? t.map((a) => a.productGID) : []
759
- ).filter((t) => t != null), be = (e) => e.dealBars.flatMap(
759
+ ).filter((t) => t != null), ve = (e) => e.dealBars.flatMap(
760
760
  ({ multipleGiftsSelectors: t }) => t ? t.flatMap(
761
761
  (a) => a.products ? a.products.map((l) => l.id) : []
762
762
  ) : []
763
- ).filter((t) => t != null), ve = (e) => {
763
+ ).filter((t) => t != null), _e = (e) => {
764
764
  var t;
765
765
  return e.progressiveGiftsEnabled ? ((t = e.progressiveGifts) == null ? void 0 : t.gifts.map((a) => a.productGID).filter((a) => a != null)) || [] : [];
766
- }, _e = (e) => e.dealBars.flatMap(({ upsells: t }) => t ? t.map((a) => a.productGID) : []).filter((t) => t != null), Ie = (e) => e.dealBars.filter((t) => t.dealBarType === k.Bundle).flatMap(
766
+ }, Ie = (e) => e.dealBars.flatMap(({ upsells: t }) => t ? t.map((a) => a.productGID) : []).filter((t) => t != null), Pe = (e) => e.dealBars.filter((t) => t.dealBarType === k.Bundle).flatMap(
767
767
  ({ bundleProducts: t }) => t ? t.map((a) => a.productGID) : []
768
- ).filter((t) => t != null).filter((t) => t !== "default"), Pe = (e) => e.dealBars.filter((t) => t.dealBarType === k.MixAndMatch).flatMap(
768
+ ).filter((t) => t != null).filter((t) => t !== "default"), Se = (e) => e.dealBars.filter((t) => t.dealBarType === k.MixAndMatch).flatMap(
769
769
  ({ bundleProducts: t }) => t ? t.flatMap((a) => {
770
770
  var l;
771
771
  return [
772
772
  a.productGID,
773
- ...((l = a.selectedProducts) == null ? void 0 : l.map((r) => r.id)) ?? []
773
+ ...((l = a.selectedProducts) == null ? void 0 : l.map((s) => s.id)) ?? []
774
774
  ];
775
775
  }) : []
776
- ).filter((t) => t != null).filter((t) => t !== "default"), Se = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.map((t) => t.productGID).filter((t) => t != null), ke = (e) => e.dealBars.filter((t) => t.dealBarType === k.Sku).flatMap(({ productGID: t }) => t ? [t] : []);
777
- class we {
776
+ ).filter((t) => t != null).filter((t) => t !== "default"), ke = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.map((t) => t.productGID).filter((t) => t != null), we = (e) => e.dealBars.filter((t) => t.dealBarType === k.Sku).flatMap(({ productGID: t }) => t ? [t] : []);
777
+ class $e {
778
778
  constructor(t, a) {
779
779
  this.storefrontApiVersion = "2026-07", this.storefrontAccessToken = a, this.shopifyDomain = t;
780
780
  }
781
781
  async query(t, a) {
782
- var n;
782
+ var r;
783
783
  const l = (a == null ? void 0 : a.variables) ?? {};
784
- let r = `https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`;
785
- const i = (n = t.match(/query\s+(\w+)/)) == null ? void 0 : n[1];
786
- i && (r += `?operation_name=${i}`);
787
- const o = await (await fetch(r, {
784
+ let s = `https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`;
785
+ const i = (r = t.match(/query\s+(\w+)/)) == null ? void 0 : r[1];
786
+ i && (s += `?operation_name=${i}`);
787
+ const o = await (await fetch(s, {
788
788
  method: "POST",
789
789
  headers: {
790
790
  "Content-Type": "application/json",
@@ -800,47 +800,47 @@ class we {
800
800
  return JSON.parse(o).data;
801
801
  }
802
802
  }
803
- const $e = async (e, t, { country: a, language: l }) => {
804
- const r = t.collectionBreaks;
805
- if (!t.collectionBreaksEnabled || !r) return;
803
+ const Ne = async (e, t, { country: a, language: l }) => {
804
+ const s = t.collectionBreaks;
805
+ if (!t.collectionBreaksEnabled || !s) return;
806
806
  let i;
807
- r.visibility === "deal-products" ? i = await T(e, {
807
+ s.visibility === "deal-products" ? i = await M(e, {
808
808
  country: a,
809
809
  language: l,
810
810
  blockVisibility: t.blockVisibility,
811
811
  excludedProductGIDs: (t.excludedProductIds || []).map(
812
- (n) => `gid://shopify/Product/${n}`
812
+ (r) => `gid://shopify/Product/${r}`
813
813
  ),
814
814
  selectedProductGIDs: (t.selectedProductIds || []).map(
815
- (n) => `gid://shopify/Product/${n}`
815
+ (r) => `gid://shopify/Product/${r}`
816
816
  ),
817
817
  selectedCollectionGIDs: (t.selectedCollectionIds || []).map(
818
- (n) => `gid://shopify/Collection/${n}`
818
+ (r) => `gid://shopify/Collection/${r}`
819
819
  )
820
- }) : i = await T(e, {
820
+ }) : i = await M(e, {
821
821
  country: a,
822
822
  language: l,
823
- blockVisibility: r.visibility,
824
- excludedProductGIDs: (r.excludedProducts || []).map(
825
- ({ id: n }) => n
823
+ blockVisibility: s.visibility,
824
+ excludedProductGIDs: (s.excludedProducts || []).map(
825
+ ({ id: r }) => r
826
826
  ),
827
- selectedProductGIDs: (r.selectedProducts || []).map(
828
- ({ id: n }) => n
827
+ selectedProductGIDs: (s.selectedProducts || []).map(
828
+ ({ id: r }) => r
829
829
  ),
830
- selectedCollectionGIDs: (r.selectedCollections || []).map(
831
- ({ id: n }) => n
830
+ selectedCollectionGIDs: (s.selectedCollections || []).map(
831
+ ({ id: r }) => r
832
832
  )
833
833
  });
834
- let o = await D(e, {
834
+ let o = await A(e, {
835
835
  country: a,
836
836
  language: l,
837
- productIds: i.map((n) => Number(n.split("/").pop())),
837
+ productIds: i.map((r) => Number(r.split("/").pop())),
838
838
  useExternalMetafieldNamespace: !0
839
839
  });
840
840
  return o = o.filter(
841
- (n) => n.availableForSale
841
+ (r) => r.availableForSale
842
842
  ), o;
843
- }, Ne = () => ({
843
+ }, De = () => ({
844
844
  "system.out_of_stock": "There's not enough items in our stock, please select smaller bundle.",
845
845
  "system.invalid_variant": "Sorry, this is not currently available.",
846
846
  "system.unavailable_option_value": "Unavailable",
@@ -865,84 +865,94 @@ const $e = async (e, t, { country: a, language: l }) => {
865
865
  "system.letters_only": "Only letters are allowed.",
866
866
  "system.numbers_only": "Only numbers are allowed.",
867
867
  "system.personalisation_required_alert": "Please add personalisation for every item to continue."
868
- }), De = "2026-07", Ae = async (e, {
868
+ }), Ae = "2026-07", xe = async (e, {
869
869
  productId: t,
870
870
  dealBlockId: a,
871
871
  country: l = void 0,
872
- language: r = void 0
872
+ language: s = void 0
873
873
  }) => {
874
874
  var i, o;
875
875
  try {
876
- const n = [Number(t.split("/").pop())], m = new xe(e);
877
- l = l || ((i = m.i18n) == null ? void 0 : i.country), r = r || ((o = m.i18n) == null ? void 0 : o.language);
878
- const c = await Z(m, {
879
- language: r,
876
+ const r = [Number(t.split("/").pop())], m = new Ge(e);
877
+ l = l || ((i = m.i18n) == null ? void 0 : i.country), s = s || ((o = m.i18n) == null ? void 0 : o.language);
878
+ const d = await ee(m, {
879
+ language: s,
880
880
  country: l,
881
881
  useExternalMetafieldNamespace: !0
882
882
  });
883
- m.shopifyDomain = c.shopifyDomain;
884
- const d = c.storefrontAccessToken ? new we(
885
- c.shopifyDomain,
886
- c.storefrontAccessToken
887
- ) : m, [g, y] = await Promise.all([
888
- D(d, {
883
+ m.shopifyDomain = d.shopifyDomain;
884
+ const c = d.storefrontAccessToken ? new $e(
885
+ d.shopifyDomain,
886
+ d.storefrontAccessToken
887
+ ) : m, [f, g] = await Promise.all([
888
+ A(c, {
889
889
  country: l,
890
- language: r,
891
- productIds: n,
890
+ language: s,
891
+ productIds: r,
892
892
  useExternalMetafieldNamespace: !0
893
893
  }),
894
- K(d, {
894
+ W(c, {
895
895
  useExternalMetafieldNamespace: !0,
896
- useMetaobjects: c.featureFlags.storefront_metaobjects
896
+ useMetaobjects: d.featureFlags.storefront_metaobjects
897
897
  })
898
- ]), p = g[0];
899
- if (!p)
898
+ ]), y = f[0];
899
+ if (!y)
900
900
  return null;
901
- const h = L(y, p);
902
- let s;
903
- if (a ? (s = h.find(
901
+ const h = J(g, y);
902
+ let n;
903
+ if (a ? (n = h.find(
904
904
  (P) => P.id === a || P.nanoId === a
905
- ), s || (s = h[0])) : s = h[0], !s)
905
+ ), n || (n = h[0])) : n = h[0], !n)
906
906
  return null;
907
- const f = ae(s), b = ge(s), [_, u, v, I] = await Promise.all([
908
- D(d, {
907
+ const p = se(n), b = he(n), [_, u, v, I] = await Promise.all([
908
+ A(c, {
909
909
  country: l,
910
- language: r,
910
+ language: s,
911
911
  productIds: b,
912
912
  useExternalMetafieldNamespace: !0
913
913
  }),
914
- te(d, f, 300),
915
- $e(d, s, {
914
+ ae(c, p, 300),
915
+ Ne(c, n, {
916
916
  country: l,
917
- language: r
917
+ language: s
918
918
  }),
919
- Ne()
919
+ De()
920
920
  ]);
921
921
  return {
922
- product: p,
923
- dealBlock: s,
924
- config: c,
922
+ product: y,
923
+ dealBlock: n,
924
+ config: d,
925
925
  otherProducts: _,
926
926
  mediaImages: u,
927
927
  collectionBreaksProducts: v ?? [],
928
928
  translations: I
929
929
  };
930
- } catch (n) {
931
- return console.error(n), null;
930
+ } catch (r) {
931
+ return console.error(r), null;
932
932
  }
933
933
  };
934
- class xe {
934
+ class Ge {
935
935
  constructor(t) {
936
936
  this.storefront = t, this.shopifyDomain = "";
937
937
  }
938
938
  async query(t, a) {
939
+ var l;
939
940
  if ("query" in this.storefront && "i18n" in this.storefront)
940
941
  return await this.storefront.query(t, a);
942
+ if ("graphql" in this.storefront) {
943
+ const s = await this.storefront.graphql(t, a);
944
+ if ((l = s.errors) != null && l.length)
945
+ throw new Error(
946
+ s.errors.map((i) => i.message).join(`
947
+ `)
948
+ );
949
+ return s.data;
950
+ }
941
951
  if ("request" in this.storefront)
942
952
  return (await this.storefront.request(t, a)).data;
943
953
  if ("shopifyDomain" in this.storefront && "storefrontAccessToken" in this.storefront) {
944
- const l = await fetch(
945
- `https://${this.storefront.shopifyDomain}/api/${De}/graphql.json`,
954
+ const s = await fetch(
955
+ `https://${this.storefront.shopifyDomain}/api/${Ae}/graphql.json`,
946
956
  {
947
957
  body: JSON.stringify({
948
958
  query: t,
@@ -955,11 +965,11 @@ class xe {
955
965
  method: "POST"
956
966
  }
957
967
  );
958
- if (!l.ok)
959
- throw new Error(l.statusText);
960
- return (await l.json()).data;
968
+ if (!s.ok)
969
+ throw new Error(s.statusText);
970
+ return (await s.json()).data;
961
971
  } else {
962
- const l = await fetch(this.storefront.getStorefrontApiUrl(), {
972
+ const s = await fetch(this.storefront.getStorefrontApiUrl(), {
963
973
  body: JSON.stringify({
964
974
  query: t,
965
975
  variables: a == null ? void 0 : a.variables
@@ -967,9 +977,9 @@ class xe {
967
977
  headers: this.storefront.getPublicTokenHeaders(),
968
978
  method: "POST"
969
979
  });
970
- if (!l.ok)
971
- throw new Error(l.statusText);
972
- return (await l.json()).data;
980
+ if (!s.ok)
981
+ throw new Error(s.statusText);
982
+ return (await s.json()).data;
973
983
  }
974
984
  }
975
985
  get i18n() {
@@ -977,32 +987,32 @@ class xe {
977
987
  return this.storefront.i18n;
978
988
  }
979
989
  }
980
- const Qe = Ae, $ = "kaching-bundles-block", U = 1e4, Ge = "https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js", Be = "https://bundles-integrations.kachingappz.app/kaching-bundles-block.js", N = /* @__PURE__ */ new WeakSet(), Ee = async (e) => {
990
+ const Xe = xe, $ = "kaching-bundles-block", O = 1e4, Be = "https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js", Ee = "https://bundles-integrations.kachingappz.app/kaching-bundles-block.js", N = /* @__PURE__ */ new WeakSet(), Ce = async (e) => {
981
991
  const t = e.document;
982
992
  if (!e.customElements.get($)) {
983
993
  if (N.has(t))
984
- return A(e, $);
994
+ return x(e, $);
985
995
  N.add(t);
986
996
  try {
987
- await Te(e);
997
+ await qe(e);
988
998
  } catch (a) {
989
999
  throw N.delete(t), a;
990
1000
  }
991
1001
  }
992
- }, Ce = () => typeof window < "u" && typeof window.__KACHING_DEV__ < "u", Me = () => Ce() ? Ge : Be, Te = (e) => {
1002
+ }, Me = () => typeof window < "u" && typeof window.__KACHING_DEV__ < "u", Te = () => Me() ? Be : Ee, qe = (e) => {
993
1003
  const t = e.document;
994
1004
  return new Promise((a, l) => {
995
- const r = Me();
1005
+ const s = Te();
996
1006
  if (t.querySelector(
997
- `script[src="${r}"]`
1007
+ `script[src="${s}"]`
998
1008
  )) {
999
- A(e, $).then(a).catch(l);
1009
+ x(e, $).then(a).catch(l);
1000
1010
  return;
1001
1011
  }
1002
1012
  const o = t.createElement("script");
1003
- o.src = r, o.onload = () => A(e, $).then(a).catch(l), o.onerror = () => l(new Error("Failed to load script")), t.head.appendChild(o);
1013
+ o.src = s, o.onload = () => x(e, $).then(a).catch(l), o.onerror = () => l(new Error("Failed to load script")), t.head.appendChild(o);
1004
1014
  });
1005
- }, A = (e, t) => new Promise((a, l) => {
1015
+ }, x = (e, t) => new Promise((a, l) => {
1006
1016
  if (e.customElements.get(t)) {
1007
1017
  a();
1008
1018
  return;
@@ -1010,35 +1020,35 @@ const Qe = Ae, $ = "kaching-bundles-block", U = 1e4, Ge = "https://bundles-integ
1010
1020
  Promise.race([
1011
1021
  e.customElements.whenDefined(t),
1012
1022
  new Promise(
1013
- (r, i) => setTimeout(
1023
+ (s, i) => setTimeout(
1014
1024
  () => i(
1015
1025
  new Error(
1016
- `Custom element "${t}" failed to register within ${U}ms`
1026
+ `Custom element "${t}" failed to register within ${O}ms`
1017
1027
  )
1018
1028
  ),
1019
- U
1029
+ O
1020
1030
  )
1021
1031
  )
1022
1032
  ]).then(() => a()).catch(l);
1023
1033
  });
1024
- var x = /* @__PURE__ */ ((e) => (e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e))(x || {});
1025
- const S = "a-f\\d", qe = `#?[${S}]{3}[${S}]?`, Oe = `#?[${S}]{6}([${S}]{2})?`, je = new RegExp(`[^#${S}]`, "gi"), Ue = new RegExp(`^${qe}$|^${Oe}$`, "i");
1026
- function Ve(e, t = {}) {
1027
- if (typeof e != "string" || je.test(e) || !Ue.test(e))
1034
+ var G = /* @__PURE__ */ ((e) => (e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e))(G || {});
1035
+ const S = "a-f\\d", je = `#?[${S}]{3}[${S}]?`, Oe = `#?[${S}]{6}([${S}]{2})?`, Ve = new RegExp(`[^#${S}]`, "gi"), Ue = new RegExp(`^${je}$|^${Oe}$`, "i");
1036
+ function Fe(e, t = {}) {
1037
+ if (typeof e != "string" || Ve.test(e) || !Ue.test(e))
1028
1038
  throw new TypeError("Expected a valid hex string");
1029
1039
  e = e.replace(/^#/, "");
1030
1040
  let a = 1;
1031
1041
  e.length === 8 && (a = Number.parseInt(e.slice(6, 8), 16) / 255, e = e.slice(0, 6)), e.length === 4 && (a = 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]);
1032
- const l = Number.parseInt(e, 16), r = l >> 16, i = l >> 8 & 255, o = l & 255, n = typeof t.alpha == "number" ? t.alpha : a;
1042
+ const l = Number.parseInt(e, 16), s = l >> 16, i = l >> 8 & 255, o = l & 255, r = typeof t.alpha == "number" ? t.alpha : a;
1033
1043
  if (t.format === "array")
1034
- return [r, i, o, n];
1044
+ return [s, i, o, r];
1035
1045
  if (t.format === "css") {
1036
- const m = n === 1 ? "" : ` / ${Number((n * 100).toFixed(2))}%`;
1037
- return `rgb(${r} ${i} ${o}${m})`;
1046
+ const m = r === 1 ? "" : ` / ${Number((r * 100).toFixed(2))}%`;
1047
+ return `rgb(${s} ${i} ${o}${m})`;
1038
1048
  }
1039
- return { red: r, green: i, blue: o, alpha: n };
1049
+ return { red: s, green: i, blue: o, alpha: r };
1040
1050
  }
1041
- const Fe = ({ price: e }) => ({
1051
+ const Re = ({ price: e }) => ({
1042
1052
  id: 123,
1043
1053
  handle: "123",
1044
1054
  url: null,
@@ -1073,7 +1083,7 @@ const Fe = ({ price: e }) => ({
1073
1083
  text4: null
1074
1084
  },
1075
1085
  isNativeBundle: !1
1076
- }), Re = () => ({
1086
+ }), Le = () => ({
1077
1087
  shopifyDomain: "",
1078
1088
  moneyFormat: "${{amount_with_comma_separator}}",
1079
1089
  locale: "en",
@@ -1129,7 +1139,7 @@ const Fe = ({ price: e }) => ({
1129
1139
  },
1130
1140
  shopCustomStyles: "",
1131
1141
  featureFlags: {}
1132
- }), Le = ({
1142
+ }), Je = ({
1133
1143
  color: e,
1134
1144
  cornerRadius: t
1135
1145
  }) => {
@@ -1183,7 +1193,7 @@ const Fe = ({ price: e }) => ({
1183
1193
  dealBars: [
1184
1194
  {
1185
1195
  id: "PfFU",
1186
- dealBarType: x.QuantityBreak,
1196
+ dealBarType: G.QuantityBreak,
1187
1197
  title: "1 pack",
1188
1198
  subtitle: "Standard price",
1189
1199
  label: "",
@@ -1203,7 +1213,7 @@ const Fe = ({ price: e }) => ({
1203
1213
  },
1204
1214
  {
1205
1215
  id: "1f-9",
1206
- dealBarType: x.QuantityBreak,
1216
+ dealBarType: G.QuantityBreak,
1207
1217
  title: "2 pack",
1208
1218
  subtitle: "You save {{saved_percentage}}",
1209
1219
  label: "SAVE {{saved_total}}",
@@ -1393,84 +1403,95 @@ const Fe = ({ price: e }) => ({
1393
1403
  imageSize: 48,
1394
1404
  imageCornerRadius: 6
1395
1405
  };
1396
- return e !== void 0 && (a.colors.border = { ...Ve(e), alpha: 1 }), a;
1397
- }, He = ({
1406
+ return e !== void 0 && (a.colors.border = { ...Fe(e), alpha: 1 }), a;
1407
+ }, Ye = ({
1398
1408
  data: e,
1399
1409
  selectedVariantId: t,
1400
1410
  preview: a,
1401
1411
  onLinesChange: l,
1402
- targetWindow: r
1412
+ targetWindow: s
1403
1413
  }) => {
1404
- const i = B(null), [o, n] = R(!1), m = B(!1);
1405
- if (E(() => {
1414
+ const i = B(null), [o, r] = R(!1), m = B(!1);
1415
+ D(() => {
1406
1416
  if (!i.current || o) return;
1407
1417
  (async () => {
1408
- await Ee(r ?? window), n(!0);
1418
+ await Ce(s ?? window), r(!0);
1409
1419
  })();
1410
- }, [o, r]), E(() => {
1420
+ }, [o, s]), D(() => {
1411
1421
  const c = i.current;
1412
1422
  if (!o || !c) return;
1413
- const d = () => {
1414
- const y = c.items().map((p) => ({
1415
- merchandiseId: `gid://shopify/ProductVariant/${p.id}`,
1416
- quantity: p.quantity,
1417
- attributes: Object.entries(p.properties).map(([h, s]) => ({
1418
- key: h,
1419
- value: String(s)
1423
+ const f = () => {
1424
+ const y = c.items().map((h) => ({
1425
+ merchandiseId: `gid://shopify/ProductVariant/${h.id}`,
1426
+ quantity: h.quantity,
1427
+ attributes: Object.entries(h.properties).map(([n, p]) => ({
1428
+ key: n,
1429
+ value: String(p)
1420
1430
  })),
1421
- sellingPlanId: p.selling_plan ? `gid://shopify/SellingPlan/${p.selling_plan}` : void 0
1431
+ sellingPlanId: h.selling_plan ? `gid://shopify/SellingPlan/${h.selling_plan}` : void 0
1422
1432
  }));
1423
1433
  l == null || l(y);
1424
1434
  };
1425
- return m.current || (typeof c.items == "function" ? d() : c.addEventListener("kaching-bundles-block-loaded", d), m.current = !0), c.addEventListener("variants-changed", d), () => {
1426
- c.removeEventListener("kaching-bundles-block-loaded", d), c.removeEventListener("variants-changed", d);
1435
+ return m.current || (typeof c.items == "function" ? f() : c.addEventListener("kaching-bundles-block-loaded", f), m.current = !0), c.addEventListener("variants-changed", f), () => {
1436
+ c.removeEventListener("kaching-bundles-block-loaded", f), c.removeEventListener("variants-changed", f);
1427
1437
  };
1428
- }, [o, l]), e) {
1429
- const {
1430
- config: c,
1431
- dealBlock: d,
1432
- product: g,
1433
- otherProducts: y,
1434
- mediaImages: p,
1435
- collectionBreaksProducts: h,
1436
- translations: s
1437
- } = e;
1438
- return /* @__PURE__ */ G(
1439
- "kaching-bundles-block",
1440
- {
1441
- ref: i,
1442
- "deal-block-id": d.id,
1443
- config: JSON.stringify(c),
1444
- "deal-block": JSON.stringify(d),
1445
- "media-images": JSON.stringify(p),
1446
- product: JSON.stringify(g),
1447
- "other-products": JSON.stringify(y),
1448
- "collection-breaks-products": JSON.stringify(h),
1449
- translations: JSON.stringify(s),
1450
- "current-variant-id": t ? t.split("/").pop() : String(g.variants[0].id)
1451
- }
1452
- );
1453
- } else if (a) {
1454
- const { cornerRadius: c, color: d, price: g } = a, y = Fe({ price: g }), p = Re(), h = Le({ color: d, cornerRadius: c });
1455
- return /* @__PURE__ */ G(
1456
- "kaching-bundles-block",
1457
- {
1458
- ref: i,
1459
- "deal-block-id": h.id,
1460
- config: JSON.stringify(p),
1461
- "deal-block": JSON.stringify(h),
1462
- "media-images": JSON.stringify([]),
1463
- product: JSON.stringify(y),
1464
- "other-products": JSON.stringify([]),
1465
- "collection-breaks-products": JSON.stringify([]),
1466
- translations: JSON.stringify({}),
1467
- "current-variant-id": String(y.variants[0].id)
1468
- }
1469
- );
1470
- } else
1471
- return null;
1438
+ }, [o, l]);
1439
+ const d = e ? Qe(e, t) : a ? He(a) : null;
1440
+ return ze(() => {
1441
+ const c = i.current;
1442
+ if (!(!c || !d))
1443
+ for (const [f, g] of Object.entries(d.jsonAttributes))
1444
+ c.getAttribute(f) !== g && c.setAttribute(f, g);
1445
+ }), d ? /* @__PURE__ */ F(
1446
+ "kaching-bundles-block",
1447
+ {
1448
+ ref: i,
1449
+ "deal-block-id": d.dealBlockId,
1450
+ ...d.jsonAttributes,
1451
+ "current-variant-id": d.currentVariantId
1452
+ }
1453
+ ) : null;
1454
+ }, ze = typeof window > "u" ? D : L, Qe = ({
1455
+ config: e,
1456
+ dealBlock: t,
1457
+ product: a,
1458
+ otherProducts: l,
1459
+ mediaImages: s,
1460
+ collectionBreaksProducts: i,
1461
+ translations: o
1462
+ }, r) => ({
1463
+ dealBlockId: t.id,
1464
+ currentVariantId: r ? r.split("/").pop() : String(a.variants[0].id),
1465
+ jsonAttributes: {
1466
+ config: JSON.stringify(e),
1467
+ "deal-block": JSON.stringify(t),
1468
+ "media-images": JSON.stringify(s),
1469
+ product: JSON.stringify(a),
1470
+ "other-products": JSON.stringify(l),
1471
+ "collection-breaks-products": JSON.stringify(i),
1472
+ translations: JSON.stringify(o)
1473
+ }
1474
+ }), He = ({
1475
+ cornerRadius: e,
1476
+ color: t,
1477
+ price: a
1478
+ }) => {
1479
+ const l = Re({ price: a }), s = Le(), i = Je({ color: t, cornerRadius: e });
1480
+ return {
1481
+ dealBlockId: i.id,
1482
+ currentVariantId: String(l.variants[0].id),
1483
+ jsonAttributes: {
1484
+ config: JSON.stringify(s),
1485
+ "deal-block": JSON.stringify(i),
1486
+ "media-images": JSON.stringify([]),
1487
+ product: JSON.stringify(l),
1488
+ "other-products": JSON.stringify([]),
1489
+ "collection-breaks-products": JSON.stringify([]),
1490
+ translations: JSON.stringify({})
1491
+ }
1492
+ };
1472
1493
  };
1473
1494
  export {
1474
- He as KachingBundle,
1475
- Qe as fetchKachingBundlesData
1495
+ Ye as KachingBundle,
1496
+ Xe as fetchKachingBundlesData
1476
1497
  };