@kachingappz/bundles-js 1.1.2 → 1.1.4

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,136 +1,64 @@
1
- const F = (e, t) => {
2
- const s = [], a = e.filter(
3
- (r) => r.blockVisibility === "selected-products"
4
- );
5
- for (const r of a)
6
- r.selectedProductIds.map(Number).includes(t.id) && s.push(r);
7
- const n = e.filter(
8
- (r) => r.blockVisibility === "selected-collections"
9
- );
10
- for (const r of n)
11
- t.collectionIds.some(
12
- (m) => r.selectedCollectionIds.map(Number).includes(m)
13
- ) && s.push(r);
14
- const i = e.filter(
15
- (r) => r.blockVisibility === "excluded-products"
16
- );
17
- for (const r of i)
18
- !r.excludedProductIds.map(Number).includes(t.id) && !(r.excludedCollectionIds || []).some(
19
- (m) => t.collectionIds.includes(m)
20
- ) && s.push(r);
21
- const o = e.filter(
22
- (r) => r.blockVisibility === "all-products"
23
- );
24
- for (const r of o)
25
- s.push(r);
26
- return s;
27
- }, z = (e, { language: t, country: s }) => {
28
- var h, g;
29
- const a = R(t, s), n = new Intl.NumberFormat(a, {
30
- style: "currency",
31
- currency: e,
32
- currencyDisplay: "narrowSymbol"
33
- }).formatToParts(123456789e-2), i = (h = n.find((f) => f.type === "decimal")) == null ? void 0 : h.value, o = Q(
34
- (g = n.find((f) => f.type === "group")) == null ? void 0 : g.value
35
- ), r = n.some((f) => f.type === "fraction"), m = J(
36
- o,
37
- i,
38
- r
39
- ), c = n.findIndex(C), u = n.findLastIndex(C);
40
- return [
41
- ...n.slice(0, c).map(x),
42
- m,
43
- ...n.slice(u + 1).map(x)
44
- ].join("");
45
- }, x = (e) => L(e.value), L = (e) => e.replace(/\s/g, " "), C = (e) => e.type === "integer" || e.type === "group" || e.type === "decimal" || e.type === "fraction", R = (e, t) => e && t ? `${e}-${t.toUpperCase()}` : e || (t ? t.toUpperCase() : "en"), Q = (e) => e === void 0 ? void 0 : L(e).replace(/’/g, "'"), J = (e, t, s) => t === "," && e === "." ? s ? "{{amount_with_comma_separator}}" : "{{amount_no_decimals_with_comma_separator}}" : t === "," && e === " " ? s ? "{{amount_with_space_separator}}" : "{{amount_no_decimals_with_space_separator}}" : t === "." && e === " " ? "{{amount_with_period_and_space_separator}}" : t === "." && e === "'" ? "{{amount_with_apostrophe_separator}}" : s ? "{{amount}}" : "{{amount_no_decimals}}", w = ({
46
- country: e,
47
- language: t
48
- }) => {
49
- const s = [];
50
- return e && s.push(`country: ${e}`), t && s.push(`language: ${t}`), s.length > 0 ? `@inContext(${s.join(", ")})` : "";
51
- }, H = async (e, {
52
- useExternalMetafieldNamespace: t,
53
- useMetaobjects: s
54
- }) => s ? W(
55
- e
56
- ) : X(e), X = async (e, t) => {
57
- var a;
58
- const s = (a = (await e.query(
59
- `
60
- query FetchDealBlocks($metafieldNamespace: String!) {
61
- shop {
62
- metafield(namespace: $metafieldNamespace, key: "deal_blocks") {
63
- value
64
- }
65
- }
66
- }
67
- `,
68
- {
69
- variables: {
70
- metafieldNamespace: "app--2935586817--kaching_bundles"
71
- }
72
- }
73
- )).shop.metafield) == null ? void 0 : a.value;
74
- return s ? JSON.parse(s) : [];
75
- }, W = async (e, t) => {
76
- const s = "app--2935586817--deal_block", a = [];
77
- let n = null;
78
- for (; ; ) {
79
- const i = await e.query(
80
- `
81
- query FetchDealBlockMetaobjects($type: String!, $cursor: String) {
82
- metaobjects(type: $type, first: 250, after: $cursor) {
83
- nodes {
84
- fields {
85
- key
86
- value
87
- }
88
- }
89
- pageInfo {
90
- hasNextPage
91
- endCursor
92
- }
93
- }
94
- }
95
- `,
96
- {
97
- variables: {
98
- type: s,
99
- cursor: n
100
- }
101
- }
102
- );
103
- for (const o of i.metaobjects.nodes) {
104
- const r = o.fields.find(
105
- (m) => m.key === "settings"
106
- );
107
- r != null && r.value && a.push(JSON.parse(r.value));
108
- }
109
- if (!i.metaobjects.pageInfo.hasNextPage)
110
- break;
111
- n = i.metaobjects.pageInfo.endCursor;
112
- }
113
- return a;
114
- }, N = async (e, {
115
- country: t,
116
- language: s,
117
- blockVisibility: a,
118
- excludedProductGIDs: n,
119
- selectedProductGIDs: i,
120
- selectedCollectionGIDs: o,
121
- limit: r = 1e3
122
- }) => {
123
- switch (a) {
124
- case "selected-products":
125
- return i.slice(0, r);
126
- case "all-products":
127
- case "excluded-products": {
128
- const m = w({ country: t, language: s });
129
- let c = [], u = null;
130
- for (; c.length < r; ) {
131
- const h = Math.min(r - c.length, 250), g = await e.query(
132
- `
133
- query FetchProductGIDs($limit: Int!, $cursor: String) ${m} {
1
+ // ../bundles-storefront-api/dist/buildMarketMoneyFormat.js
2
+ var e = (e, { language: n, country: s }) => {
3
+ let c = i(n, s), l = new Intl.NumberFormat(c, {
4
+ style: "currency",
5
+ currency: e,
6
+ currencyDisplay: "narrowSymbol"
7
+ }).formatToParts(1234567.89), u = l.find((e) => e.type === "decimal")?.value, d = o(a(l.find((e) => e.type === "group")?.value), u, l.some((e) => e.type === "fraction")), f = l.findIndex(r), p = l.findLastIndex(r);
8
+ return [
9
+ ...l.slice(0, f).map(t),
10
+ d,
11
+ ...l.slice(p + 1).map(t)
12
+ ].join("");
13
+ }, t = (e) => n(e.value), n = (e) => e.replace(/\s/g, " "), r = (e) => e.type === "integer" || e.type === "group" || e.type === "decimal" || e.type === "fraction", i = (e, t) => e && t ? `${e}-${t.toUpperCase()}` : e || (t ? t.toUpperCase() : "en"), a = (e) => e === void 0 ? void 0 : n(e).replace(/’/g, "'"), o = (e, t, n) => t === "," && e === "." ? n ? "{{amount_with_comma_separator}}" : "{{amount_no_decimals_with_comma_separator}}" : t === "," && e === " " ? n ? "{{amount_with_space_separator}}" : "{{amount_no_decimals_with_space_separator}}" : t === "." && e === " " ? "{{amount_with_period_and_space_separator}}" : t === "." && e === "'" ? "{{amount_with_apostrophe_separator}}" : n ? "{{amount}}" : "{{amount_no_decimals}}", s = ({ country: e, language: t }) => {
14
+ let n = [];
15
+ return e && n.push(`country: ${e}`), t && n.push(`language: ${t}`), n.length > 0 ? `@inContext(${n.join(", ")})` : "";
16
+ }, c = async (e, { useExternalMetafieldNamespace: t, useMetaobjects: n }) => n ? u(e, t) : l(e, t), l = async (e, t) => {
17
+ let n = (await e.query("\n query FetchDealBlocks($metafieldNamespace: String!) {\n shop {\n metafield(namespace: $metafieldNamespace, key: \"deal_blocks\") {\n value\n }\n }\n }\n ", { variables: { metafieldNamespace: t ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles" } })).shop.metafield?.value;
18
+ return n ? JSON.parse(n) : [];
19
+ }, u = async (e, t) => {
20
+ let n = t ? "app--2935586817--deal_block" : "$app:deal_block", r = [], i = null;
21
+ for (;;) {
22
+ 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: {
23
+ type: n,
24
+ cursor: i
25
+ } });
26
+ for (let e of t.metaobjects.nodes) {
27
+ let t = e.fields.find((e) => e.key === "settings");
28
+ t?.value && r.push(JSON.parse(t.value));
29
+ }
30
+ if (!t.metaobjects.pageInfo.hasNextPage) break;
31
+ i = t.metaobjects.pageInfo.endCursor;
32
+ }
33
+ return r;
34
+ };
35
+ [
36
+ "primaryBackground",
37
+ "secondaryBackground",
38
+ "primaryText",
39
+ "secondaryText",
40
+ "border",
41
+ "overlay",
42
+ "primaryAccent",
43
+ "primaryAccentText",
44
+ "badgeBackground",
45
+ "badgeText",
46
+ "error"
47
+ ].map((e) => `brand_${e}`);
48
+ var d = /* @__PURE__ */ function(e) {
49
+ return e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e;
50
+ }({}), f = async (e, { country: t, language: n, blockVisibility: r, excludedProductGIDs: i, selectedProductGIDs: a, selectedCollectionGIDs: o, limit: c = 1e3 }) => {
51
+ switch (r) {
52
+ case "selected-products": return a.slice(0, c);
53
+ case "all-products":
54
+ case "excluded-products": {
55
+ let a = s({
56
+ country: t,
57
+ language: n
58
+ }), o = [], l = null;
59
+ for (; o.length < c;) {
60
+ let t = Math.min(c - o.length, 250), n = await e.query(`
61
+ query FetchProductGIDs($limit: Int!, $cursor: String) ${a} {
134
62
  products(first: $limit, after: $cursor) {
135
63
  nodes {
136
64
  id
@@ -141,27 +69,25 @@ const F = (e, t) => {
141
69
  }
142
70
  }
143
71
  }
144
- `,
145
- {
146
- variables: {
147
- limit: h,
148
- cursor: u
149
- }
150
- }
151
- );
152
- if (c.push(...g.products.nodes.map((f) => f.id)), !g.products.pageInfo.hasNextPage) break;
153
- u = g.products.pageInfo.endCursor;
154
- }
155
- if (a === "excluded-products") {
156
- const h = new Set(n);
157
- c = c.filter((g) => !h.has(g));
158
- }
159
- return c;
160
- }
161
- case "selected-collections": {
162
- const m = w({ country: t, language: s }), c = (await e.query(
163
- `
164
- query FetchCollectionProductGIDs($collectionGIDs: [ID!]!, $limit: Int!) ${m} {
72
+ `, { variables: {
73
+ limit: t,
74
+ cursor: l
75
+ } });
76
+ if (o.push(...n.products.nodes.map((e) => e.id)), !n.products.pageInfo.hasNextPage) break;
77
+ l = n.products.pageInfo.endCursor;
78
+ }
79
+ if (r === "excluded-products") {
80
+ let e = new Set(i);
81
+ o = o.filter((t) => !e.has(t));
82
+ }
83
+ return o;
84
+ }
85
+ case "selected-collections": {
86
+ let r = s({
87
+ country: t,
88
+ language: n
89
+ }), i = (await e.query(`
90
+ query FetchCollectionProductGIDs($collectionGIDs: [ID!]!, $limit: Int!) ${r} {
165
91
  nodes(ids: $collectionGIDs) {
166
92
  ... on Collection {
167
93
  products(first: $limit) {
@@ -172,77 +98,23 @@ const F = (e, t) => {
172
98
  }
173
99
  }
174
100
  }
175
- `,
176
- {
177
- variables: {
178
- collectionGIDs: o,
179
- limit: Math.min(r, 250)
180
- }
181
- }
182
- )).nodes.filter((u) => u !== null).flatMap(
183
- (u) => u.products.nodes.map((h) => h.id)
184
- );
185
- return Array.from(new Set(c)).slice(0, r);
186
- }
187
- }
188
- }, U = `
189
- id
190
- availableForSale
191
- price {
192
- amount
193
- }
194
- compareAtPrice {
195
- amount
196
- }
197
- selectedOptions {
198
- name
199
- value
200
- }
201
- image {
202
- id
203
- url(transform: $variantImageTransform)
204
- }
205
- unitPriceMeasurement {
206
- quantityUnit
207
- quantityValue
208
- referenceUnit
209
- referenceValue
210
- }
211
- requiresComponents
212
- sellingPlanAllocations(first: 100) @include(if: $includeSellingPlans) {
213
- nodes {
214
- sellingPlan {
215
- id
216
- }
217
- priceAdjustments {
218
- price {
219
- amount
220
- }
221
- compareAtPrice {
222
- amount
223
- }
224
- perDeliveryPrice {
225
- amount
226
- }
227
- }
228
- }
229
- }
230
- quantityAvailable @include(if: $includeAvailableQuantity)
231
- `, $ = async (e, {
232
- country: t,
233
- language: s,
234
- productIds: a,
235
- includeSellingPlans: n = !0,
236
- includeAvailableQuantity: i = !0,
237
- useExternalMetafieldNamespace: o = !1,
238
- batchSize: r = 250,
239
- onBatchError: m,
240
- variantImageTransform: c = { maxWidth: 200, maxHeight: 200 }
241
- }) => {
242
- if (!a.length)
243
- return [];
244
- const u = a.map((p) => typeof p == "string" && p.startsWith("gid://") ? p : `gid://shopify/Product/${p}`), h = w({ country: t, language: s }), g = `
245
- query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $metafieldNamespace: String!, $variantImageTransform: ImageTransformInput) ${h} {
101
+ `, { variables: {
102
+ collectionGIDs: o,
103
+ limit: Math.min(c, 250)
104
+ } })).nodes.filter((e) => e !== null).flatMap((e) => e.products.nodes.map((e) => e.id));
105
+ return Array.from(new Set(i)).slice(0, c);
106
+ }
107
+ }
108
+ }, p = "\n id\n availableForSale\n price {\n amount\n }\n compareAtPrice {\n amount\n }\n selectedOptions {\n name\n value\n }\n image {\n id\n url(transform: $variantImageTransform)\n }\n unitPriceMeasurement {\n quantityUnit\n quantityValue\n referenceUnit\n referenceValue\n }\n requiresComponents\n sellingPlanAllocations(first: 100) @include(if: $includeSellingPlans) {\n nodes {\n sellingPlan {\n id\n }\n priceAdjustments {\n price {\n amount\n }\n compareAtPrice {\n amount\n }\n perDeliveryPrice {\n amount\n }\n }\n }\n }\n quantityAvailable @include(if: $includeAvailableQuantity)\n", m = async (e, { country: t, language: n, productIds: r, includeSellingPlans: i = !0, includeAvailableQuantity: a = !0, includeProductRating: o = !1, includeProductSubtitle: c = !1, productSubtitleMetafield: l = "descriptors.subtitle", useExternalMetafieldNamespace: u = !1, batchSize: d = 250, onBatchError: f, variantImageTransform: m = {
109
+ maxWidth: 200,
110
+ maxHeight: 200
111
+ } }) => {
112
+ if (!r.length) return [];
113
+ let _ = r.map((e) => typeof e == "string" && e.startsWith("gid://") ? e : `gid://shopify/Product/${e}`), v = s({
114
+ country: t,
115
+ language: n
116
+ }), y = `
117
+ query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $includeProductRating: Boolean!, $includeProductSubtitle: Boolean!, $subtitleNamespace: String!, $subtitleKey: String!, $metafieldNamespace: String!, $variantImageTransform: ImageTransformInput) ${v} {
246
118
  shop {
247
119
  currencyRateConstant: metafield(namespace: $metafieldNamespace, key: "currency_rate_constant") {
248
120
  value
@@ -276,7 +148,7 @@ const F = (e, t) => {
276
148
  }
277
149
  variants(first: 250) {
278
150
  nodes {
279
- ${U}
151
+ ${p}
280
152
  }
281
153
  }
282
154
  collections(first: 50) {
@@ -296,6 +168,15 @@ const F = (e, t) => {
296
168
  metafield4: metafield(namespace: $metafieldNamespace, key: "text4") {
297
169
  value
298
170
  }
171
+ reviewsRating: metafield(namespace: "reviews", key: "rating") @include(if: $includeProductRating) {
172
+ value
173
+ }
174
+ reviewsRatingCount: metafield(namespace: "reviews", key: "rating_count") @include(if: $includeProductRating) {
175
+ value
176
+ }
177
+ subtitle: metafield(namespace: $subtitleNamespace, key: $subtitleKey) @include(if: $includeProductSubtitle) {
178
+ value
179
+ }
299
180
  requiresSellingPlan
300
181
  sellingPlanGroups(first: 100) @include(if: $includeSellingPlans) {
301
182
  nodes {
@@ -328,90 +209,53 @@ const F = (e, t) => {
328
209
  }
329
210
  }
330
211
  }
331
- `, f = o ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles", v = [], l = Math.min(r, 250);
332
- for (let p = 0; p < u.length; p += l)
333
- v.push(u.slice(p, p + l));
334
- let d = 1;
335
- const y = async (p) => {
336
- const b = await e.query(g, {
337
- variables: {
338
- productGIDs: p,
339
- includeSellingPlans: n,
340
- includeAvailableQuantity: i,
341
- metafieldNamespace: f,
342
- variantImageTransform: c
343
- }
344
- });
345
- return b.shop.currencyRateConstant && (d = JSON.parse(b.shop.currencyRateConstant.value).amount / 1e6), b;
346
- };
347
- let _;
348
- if (m) {
349
- const p = await Promise.allSettled(v.map(y));
350
- for (const b of p)
351
- b.status === "rejected" && m(
352
- b.reason instanceof Error ? b.reason : new Error(String(b.reason))
353
- );
354
- _ = p.filter(
355
- (b) => b.status === "fulfilled"
356
- ).flatMap((b) => b.value.nodes);
357
- } else
358
- _ = (await Promise.all(v.map(y))).flatMap((p) => p.nodes);
359
- const I = _.filter((p) => p != null);
360
- if (m) {
361
- const p = await Promise.allSettled(
362
- I.map(async (P) => {
363
- const V = await G(
364
- e,
365
- P,
366
- {
367
- includeSellingPlans: n,
368
- includeAvailableQuantity: i,
369
- variantImageTransform: c
370
- },
371
- h
372
- );
373
- return T(
374
- V,
375
- e.shopifyDomain,
376
- d
377
- );
378
- })
379
- ), b = [];
380
- for (const P of p)
381
- P.status === "fulfilled" ? b.push(P.value) : m(
382
- P.reason instanceof Error ? P.reason : new Error(String(P.reason))
383
- );
384
- return b;
385
- }
386
- return (await Promise.all(
387
- I.map(
388
- (p) => G(
389
- e,
390
- p,
391
- {
392
- includeSellingPlans: n,
393
- includeAvailableQuantity: i,
394
- variantImageTransform: c
395
- },
396
- h
397
- )
398
- )
399
- )).map(
400
- (p) => T(p, e.shopifyDomain, d)
401
- );
402
- }, G = async (e, t, s, a = "") => {
403
- if (t.variants.nodes.length < 250)
404
- return t;
405
- const n = /* @__PURE__ */ new Set(), i = [], o = [], r = async (m) => {
406
- let c = !0, u = null;
407
- for (; c; ) {
408
- const h = await e.query(
409
- `
410
- query($productGID: ID!, $cursor: String, $reverse: Boolean, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $variantImageTransform: ImageTransformInput) ${a} {
212
+ `, b = u ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles", x = l.indexOf("."), S = l.slice(0, x), C = l.slice(x + 1), w = [], T = Math.min(d, 250);
213
+ for (let e = 0; e < _.length; e += T) w.push(_.slice(e, e + T));
214
+ let E = 1, D = async (t) => {
215
+ let n = await e.query(y, { variables: {
216
+ productGIDs: t,
217
+ includeSellingPlans: i,
218
+ includeAvailableQuantity: a,
219
+ includeProductRating: o,
220
+ includeProductSubtitle: c,
221
+ subtitleNamespace: S,
222
+ subtitleKey: C,
223
+ metafieldNamespace: b,
224
+ variantImageTransform: m
225
+ } });
226
+ return n.shop.currencyRateConstant && (E = JSON.parse(n.shop.currencyRateConstant.value).amount / 1e6), n;
227
+ }, O;
228
+ if (f) {
229
+ let e = await Promise.allSettled(w.map(D));
230
+ for (let t of e) t.status === "rejected" && f(t.reason instanceof Error ? t.reason : Error(String(t.reason)));
231
+ O = e.filter((e) => e.status === "fulfilled").flatMap((e) => e.value.nodes);
232
+ } else O = (await Promise.all(w.map(D))).flatMap((e) => e.nodes);
233
+ let k = O.filter((e) => e != null);
234
+ if (f) {
235
+ let t = await Promise.allSettled(k.map(async (t) => g(await h(e, t, {
236
+ includeSellingPlans: i,
237
+ includeAvailableQuantity: a,
238
+ variantImageTransform: m
239
+ }, v), e.shopifyDomain, E))), n = [];
240
+ for (let e of t) e.status === "fulfilled" ? n.push(e.value) : f(e.reason instanceof Error ? e.reason : Error(String(e.reason)));
241
+ return n;
242
+ }
243
+ return (await Promise.all(k.map((t) => h(e, t, {
244
+ includeSellingPlans: i,
245
+ includeAvailableQuantity: a,
246
+ variantImageTransform: m
247
+ }, v)))).map((t) => g(t, e.shopifyDomain, E));
248
+ }, h = async (e, t, n, r = "") => {
249
+ if (t.variants.nodes.length < 250) return t;
250
+ let i = /* @__PURE__ */ new Set(), a = [], o = [], s = async (s) => {
251
+ let c = !0, l = null;
252
+ for (; c;) {
253
+ let { nodes: u, pageInfo: d } = (await e.query(`
254
+ query($productGID: ID!, $cursor: String, $reverse: Boolean, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $variantImageTransform: ImageTransformInput) ${r} {
411
255
  product(id: $productGID) {
412
256
  variants(first: 250, after: $cursor, reverse: $reverse) {
413
257
  nodes {
414
- ${U}
258
+ ${p}
415
259
  }
416
260
  pageInfo {
417
261
  endCursor
@@ -420,169 +264,130 @@ const F = (e, t) => {
420
264
  }
421
265
  }
422
266
  }
423
- `,
424
- {
425
- variables: {
426
- productGID: t.id,
427
- cursor: u,
428
- reverse: m,
429
- ...s
430
- }
431
- }
432
- ), { nodes: g, pageInfo: f } = h.product.variants;
433
- for (const v of g) {
434
- if (n.has(v.id)) {
435
- c = !1;
436
- break;
437
- }
438
- n.add(v.id), m ? o.push(v) : i.push(v);
439
- }
440
- f.hasNextPage || (c = !1), u = f.endCursor;
441
- }
442
- };
443
- return await Promise.all([
444
- r(!1),
445
- r(!0)
446
- ]), t.variants.nodes = [...i, ...o.reverse()], t;
447
- }, T = (e, t, s) => {
448
- var c, u, h, g, f, v;
449
- const a = e.variants.nodes.map(
450
- ({ unitPriceMeasurement: l, ...d }) => {
451
- var y, _;
452
- return {
453
- id: Number(d.id.split("/").pop()),
454
- availableForSale: d.availableForSale,
455
- price: Math.round(Number(d.price.amount) * 100),
456
- compareAtPrice: d.compareAtPrice ? Math.round(Number(d.compareAtPrice.amount) * 100) : null,
457
- options: d.selectedOptions.map((I) => I.value),
458
- imageId: d.image ? Number(d.image.id.split("/").pop()) : null,
459
- image: ((y = d.image) == null ? void 0 : y.url) || null,
460
- sellingPlans: ((_ = d.sellingPlanAllocations) == null ? void 0 : _.nodes.map((I) => ({
461
- id: Number(I.sellingPlan.id.split("/").pop()),
462
- price: I.priceAdjustments.length > 0 ? Math.round(Number(I.priceAdjustments[0].price.amount) * 100) : Math.round(Number(d.price.amount) * 100),
463
- compareAtPrice: I.priceAdjustments.length > 0 ? Math.round(
464
- Number(I.priceAdjustments[0].compareAtPrice.amount) * 100
465
- ) : Math.round(Number(d.price.amount) * 100),
466
- perDeliveryPrice: I.priceAdjustments.length > 0 ? Math.round(
467
- Number(I.priceAdjustments[0].perDeliveryPrice.amount) * 100
468
- ) : Math.round(Number(d.price.amount) * 100)
469
- }))) || [],
470
- inventoryManagement: null,
471
- // Storefront API does not return inventory management, only available in liquid
472
- inventoryPolicy: null,
473
- // Storefront API does not return inventory policy, only available in liquid
474
- inventoryQuantity: d.quantityAvailable ?? null,
475
- unitPriceMeasurement: l != null && l.quantityUnit && (l != null && l.referenceUnit) ? {
476
- quantityValue: l.quantityValue,
477
- quantityUnit: l.quantityUnit.toLowerCase(),
478
- referenceValue: l.referenceValue,
479
- referenceUnit: l.referenceUnit.toLowerCase()
480
- } : null
481
- };
482
- }
483
- ), n = e.options.map((l, d) => {
484
- const y = l.optionValues.map((_) => {
485
- var I, p, b, P;
486
- return {
487
- id: Number(_.id.split("/").pop()),
488
- defaultName: _.name,
489
- name: _.name,
490
- swatch: {
491
- color: ((I = _.swatch) == null ? void 0 : I.color) || null,
492
- image: ((P = (b = (p = _.swatch) == null ? void 0 : p.image) == null ? void 0 : b.previewImage) == null ? void 0 : P.url) || null
493
- }
494
- };
495
- });
496
- return {
497
- defaultName: l.name,
498
- name: l.name,
499
- position: d + 1,
500
- optionValues: K(y, d, a)
501
- };
502
- }), i = (l) => {
503
- const d = l.priceAdjustments[0];
504
- if (!d)
505
- return null;
506
- const y = d.adjustmentValue;
507
- switch (y.__typename) {
508
- case "SellingPlanPercentagePriceAdjustment":
509
- return {
510
- type: "percentage",
511
- value: y.adjustmentPercentage
512
- };
513
- case "SellingPlanFixedAmountPriceAdjustment":
514
- return {
515
- type: "fixed_amount",
516
- value: o(y.adjustmentAmount.amount)
517
- };
518
- case "SellingPlanFixedPriceAdjustment":
519
- return {
520
- type: "price",
521
- value: o(y.price.amount)
522
- };
523
- default:
524
- throw new Error(
525
- `Unknown price adjustment type: ${y.__typename}`
526
- );
527
- }
528
- }, o = (l) => s === 1 ? Number(l) * 100 : Math.round(Number(l) * 100 * s), r = ((c = e.sellingPlanGroups) == null ? void 0 : c.nodes.flatMap(
529
- (l) => l.sellingPlans.nodes.map((d) => ({
530
- id: Number(d.id.split("/").pop()),
531
- name: d.name,
532
- priceAdjustment: i(d)
533
- }))
534
- )) || [], m = e.variants.nodes.some(
535
- (l) => l.requiresComponents
536
- );
537
- return {
538
- id: Number(e.id.split("/").pop()),
539
- handle: e.handle,
540
- url: e.onlineStoreUrl || `https://${t}/products/${e.handle}`,
541
- availableForSale: e.availableForSale,
542
- createdAt: e.createdAt,
543
- title: e.title,
544
- image: ((u = e.featuredImage) == null ? void 0 : u.url) || null,
545
- collectionIds: e.collections.nodes.map(
546
- (l) => Number(l.id.split("/").pop())
547
- ),
548
- options: n,
549
- selectedVariantId: Number(
550
- e.variants.nodes[0].id.split("/").pop()
551
- ),
552
- variants: a,
553
- requiresSellingPlan: e.requiresSellingPlan,
554
- sellingPlans: r,
555
- isNativeBundle: m,
556
- metafields: {
557
- text: ((h = e.metafield) == null ? void 0 : h.value) || null,
558
- text2: ((g = e.metafield2) == null ? void 0 : g.value) || null,
559
- text3: ((f = e.metafield3) == null ? void 0 : f.value) || null,
560
- text4: ((v = e.metafield4) == null ? void 0 : v.value) || null
561
- }
562
- };
563
- }, K = (e, t, s) => e.filter((a) => s.filter(
564
- (n) => n.options[t] === a.name
565
- ).length > 0), B = "app--2935586817", Y = async (e, {
566
- language: t,
567
- country: s,
568
- useExternalMetafieldNamespace: a
569
- }) => {
570
- const n = `${B}--kaching_bundles`, i = B, o = w({ country: s }), {
571
- localization: {
572
- country: {
573
- currency: { isoCode: r }
574
- }
575
- },
576
- shop: {
577
- moneyFormat: m,
578
- paymentSettings: { currencyCode: c },
579
- currencyRateConstant: u,
580
- primaryDomain: h,
581
- settingsMetafield: g
582
- }
583
- } = await e.query(
584
- `
585
- query config($metafieldNamespace: String!, $settingsNamespace: String!) ${o} {
267
+ `, { variables: {
268
+ productGID: t.id,
269
+ cursor: l,
270
+ reverse: s,
271
+ ...n
272
+ } })).product.variants;
273
+ for (let e of u) {
274
+ if (i.has(e.id)) {
275
+ c = !1;
276
+ break;
277
+ }
278
+ i.add(e.id), s ? o.push(e) : a.push(e);
279
+ }
280
+ d.hasNextPage || (c = !1), l = d.endCursor;
281
+ }
282
+ };
283
+ return await Promise.all([s(!1), s(!0)]), t.variants.nodes = [...a, ...o.reverse()], t;
284
+ }, g = (e, t, n) => {
285
+ let r = e.variants.nodes.map(({ unitPriceMeasurement: e, ...t }) => ({
286
+ id: Number(t.id.split("/").pop()),
287
+ availableForSale: t.availableForSale,
288
+ price: Math.round(Number(t.price.amount) * 100),
289
+ compareAtPrice: t.compareAtPrice ? Math.round(Number(t.compareAtPrice.amount) * 100) : null,
290
+ options: t.selectedOptions.map((e) => e.value),
291
+ imageId: t.image ? Number(t.image.id.split("/").pop()) : null,
292
+ image: t.image?.url || null,
293
+ sellingPlans: t.sellingPlanAllocations?.nodes.map((e) => ({
294
+ id: Number(e.sellingPlan.id.split("/").pop()),
295
+ price: e.priceAdjustments.length > 0 ? Math.round(Number(e.priceAdjustments[0].price.amount) * 100) : Math.round(Number(t.price.amount) * 100),
296
+ compareAtPrice: e.priceAdjustments.length > 0 ? Math.round(Number(e.priceAdjustments[0].compareAtPrice.amount) * 100) : Math.round(Number(t.price.amount) * 100),
297
+ perDeliveryPrice: e.priceAdjustments.length > 0 ? Math.round(Number(e.priceAdjustments[0].perDeliveryPrice.amount) * 100) : Math.round(Number(t.price.amount) * 100)
298
+ })) || [],
299
+ inventoryManagement: null,
300
+ inventoryPolicy: null,
301
+ inventoryQuantity: t.quantityAvailable ?? null,
302
+ unitPriceMeasurement: e?.quantityUnit && e?.referenceUnit ? {
303
+ quantityValue: e.quantityValue,
304
+ quantityUnit: e.quantityUnit.toLowerCase(),
305
+ referenceValue: e.referenceValue,
306
+ referenceUnit: e.referenceUnit.toLowerCase()
307
+ } : null
308
+ })), i = e.options.map((e, t) => {
309
+ let n = e.optionValues.map((e) => ({
310
+ id: Number(e.id.split("/").pop()),
311
+ defaultName: e.name,
312
+ name: e.name,
313
+ swatch: {
314
+ color: e.swatch?.color || null,
315
+ image: e.swatch?.image?.previewImage?.url || null
316
+ }
317
+ }));
318
+ return {
319
+ defaultName: e.name,
320
+ name: e.name,
321
+ position: t + 1,
322
+ optionValues: y(n, t, r)
323
+ };
324
+ }), a = (e) => {
325
+ let t = e.priceAdjustments[0];
326
+ if (!t) return null;
327
+ let n = t.adjustmentValue;
328
+ switch (n.__typename) {
329
+ case "SellingPlanPercentagePriceAdjustment": return {
330
+ type: "percentage",
331
+ value: n.adjustmentPercentage
332
+ };
333
+ case "SellingPlanFixedAmountPriceAdjustment": return {
334
+ type: "fixed_amount",
335
+ value: o(n.adjustmentAmount.amount)
336
+ };
337
+ case "SellingPlanFixedPriceAdjustment": return {
338
+ type: "price",
339
+ value: o(n.price.amount)
340
+ };
341
+ default: throw Error(`Unknown price adjustment type: ${n.__typename}`);
342
+ }
343
+ }, o = (e) => n === 1 ? Number(e) * 100 : Math.round(Number(e) * 100 * n), s = e.sellingPlanGroups?.nodes.flatMap((e) => e.sellingPlans.nodes.map((e) => ({
344
+ id: Number(e.id.split("/").pop()),
345
+ name: e.name,
346
+ priceAdjustment: a(e)
347
+ }))) || [], c = e.variants.nodes.some((e) => e.requiresComponents);
348
+ return {
349
+ id: Number(e.id.split("/").pop()),
350
+ handle: e.handle,
351
+ url: e.onlineStoreUrl || `https://${t}/products/${e.handle}`,
352
+ availableForSale: e.availableForSale,
353
+ createdAt: e.createdAt,
354
+ title: e.title,
355
+ image: e.featuredImage?.url || null,
356
+ collectionIds: e.collections.nodes.map((e) => Number(e.id.split("/").pop())),
357
+ options: i,
358
+ selectedVariantId: Number(e.variants.nodes[0].id.split("/").pop()),
359
+ variants: r,
360
+ requiresSellingPlan: e.requiresSellingPlan,
361
+ sellingPlans: s,
362
+ isNativeBundle: c,
363
+ metafields: {
364
+ text: e.metafield?.value || null,
365
+ text2: e.metafield2?.value || null,
366
+ text3: e.metafield3?.value || null,
367
+ text4: e.metafield4?.value || null
368
+ },
369
+ rating: _(e.reviewsRating, e.reviewsRatingCount),
370
+ subtitle: e.subtitle?.value || null
371
+ };
372
+ }, _ = (e, t) => {
373
+ if (!e) return null;
374
+ let n = v(e.value);
375
+ if (n === null) return null;
376
+ let r = Number(t?.value);
377
+ return {
378
+ value: n,
379
+ count: Number.isInteger(r) && r > 0 ? r : null
380
+ };
381
+ }, v = (e) => {
382
+ try {
383
+ let { value: t, scale_max: n } = JSON.parse(e), r = Number(t) / Number(n) * 5;
384
+ return Number.isFinite(r) && r > 0 ? Math.min(5, r) : null;
385
+ } catch {
386
+ return null;
387
+ }
388
+ }, y = (e, t, n) => e.filter((e) => n.filter((n) => n.options[t] === e.name).length > 0), b = "app--2935586817", x = async (t, { language: n, country: r, useExternalMetafieldNamespace: i }) => {
389
+ let a = i ? `${b}--kaching_bundles` : "$app:kaching_bundles", o = i ? b : "$app", c = s({ country: r }), { localization: { country: { currency: { isoCode: l } } }, shop: { moneyFormat: u, paymentSettings: { currencyCode: d }, currencyRateConstant: f, primaryDomain: p, settingsMetafield: m } } = await t.query(`
390
+ query config($metafieldNamespace: String!, $settingsNamespace: String!) ${c} {
586
391
  localization {
587
392
  country {
588
393
  currency {
@@ -606,892 +411,848 @@ const F = (e, t) => {
606
411
  }
607
412
  }
608
413
  }
609
- `,
610
- {
611
- variables: {
612
- metafieldNamespace: n,
613
- settingsNamespace: i
614
- }
615
- }
616
- ), f = r === c ? m : z(r, { language: t, country: s }), v = u ? Z(u.value) : 1, l = g ? JSON.parse(g.value) : null, d = (l == null ? void 0 : l.feature_flags) ?? {}, y = (l == null ? void 0 : l.custom_selectors) ?? {};
617
- return {
618
- shopifyDomain: h.host,
619
- moneyFormat: f,
620
- locale: (t == null ? void 0 : t.toLowerCase()) || "en",
621
- liquidLocale: (t == null ? void 0 : t.toLowerCase()) || "en",
622
- country: s ?? "US",
623
- currencyRate: v,
624
- marketId: 0,
625
- productId: null,
626
- storefrontAccessToken: (l == null ? void 0 : l.storefront_access_token) ?? null,
627
- includeSellingPlans: (l == null ? void 0 : l.include_selling_plans) ?? !1,
628
- includeAvailableQuantity: (l == null ? void 0 : l.include_available_quantity) ?? !1,
629
- customApiHost: (l == null ? void 0 : l.custom_api_host) ?? null,
630
- keepQuantityInput: (l == null ? void 0 : l.keep_quantity_input) ?? !1,
631
- ignoreDeselect: (l == null ? void 0 : l.ignore_deselect) ?? !1,
632
- ignoreUnitPrice: (l == null ? void 0 : l.ignore_unit_price) ?? !1,
633
- requireCustomerLogin: (l == null ? void 0 : l.require_customer_login) ?? !1,
634
- abTestsRunning: (l == null ? void 0 : l.ab_tests_running) ?? !1,
635
- webPixel: (l == null ? void 0 : l.web_pixel) ?? !1,
636
- b2bCustomer: !1,
637
- isLoggedIn: !1,
638
- preview: !1,
639
- previewAlerts: !1,
640
- previewScratchOff: !1,
641
- defaultTranslations: {
642
- "system.out_of_stock": "Out of stock",
643
- "system.invalid_variant": "Invalid variant",
644
- "system.unavailable_option_value": "Unavailable option value",
645
- "system.confirm": "Confirm",
646
- "system.cancel": "Cancel",
647
- "system.free": "FREE",
648
- "system.search": "Search",
649
- "system.quantity": "Quantity",
650
- "system.subscription_plan": "Subscription plan",
651
- "system.remove": "Remove",
652
- "system.sort_by": "Sort by",
653
- "system.sort_relevance": "Relevance",
654
- "system.sort_newest_first": "Newest first",
655
- "system.sort_price_low_to_high": "Price: Low → High",
656
- "system.sort_price_high_to_low": "Price: High → Low",
657
- "system.no_results_found": "No results found",
658
- "system.no_results_description": "We can't find any item matching your search.",
659
- "system.clear_search": "Clear search",
660
- "system.no_products_available": "No products available",
661
- "system.original_price": "Original price:",
662
- "system.price": "Price:",
663
- "system.letters_only": "Only letters are allowed.",
664
- "system.numbers_only": "Only numbers are allowed."
665
- },
666
- customSelectors: {
667
- quantity: y.quantity ?? null,
668
- addToCartButton: y.add_to_cart_button ?? null,
669
- variantPicker: y.variant_picker ?? null,
670
- price: y.price ?? null,
671
- priceCompare: y.price_compare ?? null
672
- },
673
- shopCustomStyles: (l == null ? void 0 : l.shop_custom_styles) ?? "",
674
- featureFlags: d,
675
- brandColors: (l == null ? void 0 : l.brand_colors) ?? null
676
- };
677
- }, Z = (e) => JSON.parse(e).amount / 1e6, ee = async (e, t, s = 200) => {
678
- const a = [
679
- ...new Set(
680
- t.filter(Boolean).filter((i) => !i.startsWith("placeholder"))
681
- )
682
- ];
683
- if (a.length === 0) return [];
684
- const n = [];
685
- for (let i = 0; i < a.length; i += 250)
686
- n.push(a.slice(i, i + 250));
687
- return (await Promise.all(
688
- n.map(
689
- (i) => e.query(
690
- `
691
- query FetchMediaImages($mediaImageIds: [ID!]!, $size: Int!) {
692
- nodes(ids: $mediaImageIds) {
693
- ... on MediaImage {
694
- id
695
- image {
696
- url(transform: { maxWidth: $size, maxHeight: $size })
697
- }
698
- }
699
- }
700
- }
701
- `,
702
- {
703
- variables: {
704
- mediaImageIds: i,
705
- size: s
706
- }
707
- }
708
- )
709
- )
710
- )).flatMap((i) => i.nodes).flatMap(
711
- (i) => i != null && i.image ? [{ gid: i.id, url: i.image.url }] : []
712
- );
713
- };
714
- var S = /* @__PURE__ */ ((e) => (e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e))(S || {});
715
- const te = (e) => [
716
- ...se(e),
717
- ...ae(e),
718
- ...ne(e),
719
- ...le(e),
720
- ...re(e),
721
- ...ie(e),
722
- ...oe(e),
723
- ...ce(e),
724
- ...ue(e),
725
- ...de(e),
726
- ...me(e),
727
- ...pe(e),
728
- ...fe(e)
729
- ].filter((t) => t != null && !t.includes("placeholder")), se = (e) => e.dealBars.flatMap((t) => [t.mediaImageGID, t.badgeImageGID]).filter((t) => t != null), ae = (e) => e.dealBars.flatMap(
730
- (t) => t.dealBarType === S.Bundle ? t.bundleProducts.map(
731
- (s) => s.mediaImageGID
732
- ) : []
733
- ).filter((t) => t != null), ne = (e) => e.dealBars.map(
734
- ({ freeGifts: t }) => (t || []).map((s) => s.mediaImageGID)
735
- ).reduce((t, s) => t.concat(s), []).filter((t) => t != null), le = (e) => e.dealBars.flatMap(
736
- ({ multipleGiftsSelectors: t }) => (t || []).map((s) => s.mediaImageGID)
737
- ).filter((t) => t != null), re = (e) => e.dealBars.map(({ upsells: t }) => (t || []).map((s) => s.mediaImageGID)).reduce((t, s) => t.concat(s), []).filter((t) => t != null), ie = (e) => e.swatchOptions ? e.swatchOptions.reduce((t, s) => {
738
- const a = s.images.map((n) => n.mediaImageGID).filter((n) => n != null);
739
- return [...t, ...a];
740
- }, []) : [], oe = (e) => {
741
- if (!e.collectionBreaksEnabled || !e.collectionBreaks)
742
- return [];
743
- const t = e.collectionBreaks.mediaImageGID;
744
- return t ? [t] : [];
745
- }, ce = (e) => {
746
- var t, s, a;
747
- return e.progressiveGifts ? [
748
- ...((t = e.progressiveGifts.gifts) == null ? void 0 : t.map((n) => n.mediaImageGID)) || [],
749
- (s = e.progressiveGifts.style) == null ? void 0 : s.lockedMediaImageGID,
750
- (a = e.progressiveGifts.dealBarStyle) == null ? void 0 : a.lockedMediaImageGID
751
- ].filter((n) => n != null) : [];
752
- }, ue = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.flatMap((t) => [t.mediaImageGID, t.badgeImageGID]).filter((t) => t != null), de = (e) => e.dealBars.map((t) => {
753
- var s;
754
- return (s = t.productPersonalisation) == null ? void 0 : s.mediaImageGID;
755
- }).filter((t) => t != null), me = (e) => {
756
- var a, n;
757
- const t = e.dealBars.map((i) => {
758
- var o;
759
- return (o = i.highlights) == null ? void 0 : o.customIconGID;
760
- }).filter((i) => i != null), s = (n = (a = e.subscriptions) == null ? void 0 : a.highlights) == null ? void 0 : n.customIconGID;
761
- return s ? [...t, s] : t;
762
- }, pe = (e) => (e.badges || []).flatMap(
763
- (t) => t.badgeType === "custom" && t.imageGID ? [t.imageGID] : []
764
- ), fe = (e) => !e.savingsSummaryEnabled || !e.savingsSummary ? [] : e.savingsSummary.customIconGID ? [e.savingsSummary.customIconGID] : [], he = (e) => {
765
- const t = [
766
- ...ge(e),
767
- ...ye(e),
768
- ...be(e),
769
- ...ve(e),
770
- ...Ie(e),
771
- ..._e(e),
772
- ...Pe(e),
773
- ...Se(e)
774
- ];
775
- return Array.from(new Set(t.filter((s) => s != null)));
776
- }, ge = (e) => e.dealBars.flatMap(
777
- ({ freeGifts: t }) => t ? t.map((s) => s.productGID) : []
778
- ).filter((t) => t != null), ye = (e) => e.dealBars.flatMap(
779
- ({ multipleGiftsSelectors: t }) => t ? t.flatMap(
780
- (s) => s.products ? s.products.map((a) => a.id) : []
781
- ) : []
782
- ).filter((t) => t != null), be = (e) => {
783
- var t;
784
- return e.progressiveGiftsEnabled ? ((t = e.progressiveGifts) == null ? void 0 : t.gifts.map((s) => s.productGID).filter((s) => s != null)) || [] : [];
785
- }, ve = (e) => e.dealBars.flatMap(({ upsells: t }) => t ? t.map((s) => s.productGID) : []).filter((t) => t != null), Ie = (e) => e.dealBars.filter((t) => t.dealBarType === S.Bundle).flatMap(
786
- ({ bundleProducts: t }) => t ? t.map((s) => s.productGID) : []
787
- ).filter((t) => t != null).filter((t) => t !== "default"), _e = (e) => e.dealBars.filter((t) => t.dealBarType === S.MixAndMatch).flatMap(
788
- ({ bundleProducts: t }) => t ? t.flatMap((s) => {
789
- var a;
790
- return [
791
- s.productGID,
792
- ...((a = s.selectedProducts) == null ? void 0 : a.map((n) => n.id)) ?? []
793
- ];
794
- }) : []
795
- ).filter((t) => t != null).filter((t) => t !== "default"), Pe = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.map((t) => t.productGID).filter((t) => t != null), Se = (e) => e.dealBars.filter((t) => t.dealBarType === S.Sku).flatMap(({ productGID: t }) => t ? [t] : []);
796
- class M extends Error {
797
- constructor({
798
- status: t,
799
- operationName: s,
800
- graphqlErrors: a
801
- }) {
802
- const n = a.length ? `: ${a.join("; ")}` : "";
803
- super(
804
- `Storefront API ${s ?? "query"} failed (HTTP ${t})${n}`
805
- ), this.name = "StorefrontApiError", this.status = t, this.operationName = s, this.graphqlErrors = a;
806
- }
807
- }
808
- const ke = async (e, t) => {
809
- const s = await e.text();
810
- if (!s)
811
- throw new Error("Empty graphql response");
812
- let a;
813
- try {
814
- a = JSON.parse(s);
815
- } catch (n) {
816
- throw e.ok ? n : new M({
817
- status: e.status,
818
- operationName: t,
819
- graphqlErrors: []
820
- });
821
- }
822
- if (!e.ok || a.data === null || a.data === void 0)
823
- throw new M({
824
- status: e.status,
825
- operationName: t,
826
- graphqlErrors: (a.errors ?? []).map(({ message: n }) => n).filter(Boolean)
827
- });
828
- return a.data;
829
- };
830
- class we {
831
- constructor(t, s) {
832
- this.storefrontApiVersion = "2026-07", this.storefrontAccessToken = s, this.shopifyDomain = t;
833
- }
834
- async query(t, s) {
835
- var r;
836
- const a = (s == null ? void 0 : s.variables) ?? {};
837
- let n = `https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`;
838
- const i = (r = t.match(/query\s+(\w+)/)) == null ? void 0 : r[1];
839
- i && (n += `?operation_name=${i}`);
840
- const o = await fetch(n, {
841
- method: "POST",
842
- headers: {
843
- "Content-Type": "application/json",
844
- "X-Shopify-Storefront-Access-Token": this.storefrontAccessToken
845
- },
846
- body: JSON.stringify({
847
- query: t,
848
- variables: a
849
- })
850
- });
851
- return ke(o, i);
852
- }
853
- }
854
- const Ee = async (e, t, { country: s, language: a }) => {
855
- const n = t.collectionBreaks;
856
- if (!t.collectionBreaksEnabled || !n) return;
857
- let i;
858
- n.visibility === "deal-products" ? i = await N(e, {
859
- country: s,
860
- language: a,
861
- blockVisibility: t.blockVisibility,
862
- excludedProductGIDs: (t.excludedProductIds || []).map(
863
- (r) => `gid://shopify/Product/${r}`
864
- ),
865
- selectedProductGIDs: (t.selectedProductIds || []).map(
866
- (r) => `gid://shopify/Product/${r}`
867
- ),
868
- selectedCollectionGIDs: (t.selectedCollectionIds || []).map(
869
- (r) => `gid://shopify/Collection/${r}`
870
- )
871
- }) : i = await N(e, {
872
- country: s,
873
- language: a,
874
- blockVisibility: n.visibility,
875
- excludedProductGIDs: (n.excludedProducts || []).map(
876
- ({ id: r }) => r
877
- ),
878
- selectedProductGIDs: (n.selectedProducts || []).map(
879
- ({ id: r }) => r
880
- ),
881
- selectedCollectionGIDs: (n.selectedCollections || []).map(
882
- ({ id: r }) => r
883
- )
884
- });
885
- let o = await $(e, {
886
- country: s,
887
- language: a,
888
- productIds: i.map((r) => Number(r.split("/").pop())),
889
- useExternalMetafieldNamespace: !0
890
- });
891
- return o = o.filter(
892
- (r) => r.availableForSale
893
- ), o;
894
- }, Ae = ({
895
- language: e,
896
- dealBlockId: t
897
- }) => {
898
- const s = {
899
- "system.out_of_stock": "There's not enough items in our stock, please select smaller bundle.",
900
- "system.invalid_variant": "Sorry, this is not currently available.",
901
- "system.unavailable_option_value": "Unavailable",
902
- "system.confirm": "Confirm",
903
- "system.cancel": "Cancel",
904
- "system.free": "FREE",
905
- "system.search": "Search",
906
- "system.quantity": "Quantity",
907
- "system.subscription_plan": "Subscription plan",
908
- "system.remove": "Remove",
909
- "system.sort_by": "Sort by",
910
- "system.sort_relevance": "Relevance",
911
- "system.sort_newest_first": "Newest first",
912
- "system.sort_price_low_to_high": "Price: Low → High",
913
- "system.sort_price_high_to_low": "Price: High → Low",
914
- "system.no_results_found": "No results found",
915
- "system.no_results_description": "We can't find any item matching your search.",
916
- "system.clear_search": "Clear search",
917
- "system.no_products_available": "No products available",
918
- "system.original_price": "Original price:",
919
- "system.price": "Price:",
920
- "system.letters_only": "Only letters are allowed.",
921
- "system.numbers_only": "Only numbers are allowed.",
922
- "system.personalisation_required_alert": "Please add personalisation for every item to continue."
923
- }, a = e ? $e(e) : void 0;
924
- return {
925
- ...s,
926
- ...a == null ? void 0 : a.system,
927
- ...a == null ? void 0 : a.dealBlocks[t]
928
- };
929
- }, $e = (e) => {
930
- var n;
931
- if (typeof document > "u") return;
932
- const t = document.querySelector("script#kaching-bundles-translations");
933
- if (!(t != null && t.textContent)) return;
934
- let s;
935
- try {
936
- s = JSON.parse(t.textContent);
937
- } catch {
938
- return;
939
- }
940
- const a = q(e);
941
- return (n = s.find(
942
- (i) => q(i.locale) === a
943
- )) == null ? void 0 : n.translations;
944
- }, q = (e) => e.toLowerCase().replace(/_/g, "-"), De = "2026-07", xe = async (e, {
945
- productId: t,
946
- dealBlockId: s,
947
- country: a = void 0,
948
- language: n = void 0
949
- }) => {
950
- var i, o;
951
- try {
952
- const r = [Number(t.split("/").pop())], m = new Ce(e);
953
- a = a || ((i = m.i18n) == null ? void 0 : i.country), n = n || ((o = m.i18n) == null ? void 0 : o.language);
954
- const c = await Y(m, {
955
- language: n,
956
- country: a,
957
- useExternalMetafieldNamespace: !0
958
- });
959
- m.shopifyDomain = c.shopifyDomain;
960
- const u = c.storefrontAccessToken ? new we(
961
- c.shopifyDomain,
962
- c.storefrontAccessToken
963
- ) : m, [h, g] = await Promise.all([
964
- $(u, {
965
- country: a,
966
- language: n,
967
- productIds: r,
968
- useExternalMetafieldNamespace: !0
969
- }),
970
- H(u, {
971
- useExternalMetafieldNamespace: !0,
972
- useMetaobjects: c.featureFlags.storefront_metaobjects
973
- })
974
- ]), f = h[0];
975
- if (!f)
976
- return null;
977
- const v = F(g, f);
978
- let l;
979
- if (s ? (l = v.find(
980
- (P) => P.id === s || P.nanoId === s
981
- ), l || (l = v[0])) : l = v[0], !l)
982
- return null;
983
- const d = te(l), y = he(l), [_, I, p, b] = await Promise.all([
984
- $(u, {
985
- country: a,
986
- language: n,
987
- productIds: y,
988
- useExternalMetafieldNamespace: !0
989
- }),
990
- ee(u, d, 300),
991
- Ee(u, l, {
992
- country: a,
993
- language: n
994
- }),
995
- Ae({ language: n, dealBlockId: l.id })
996
- ]);
997
- return {
998
- product: f,
999
- dealBlock: l,
1000
- config: c,
1001
- otherProducts: _,
1002
- mediaImages: I,
1003
- collectionBreaksProducts: p ?? [],
1004
- translations: b
1005
- };
1006
- } catch (r) {
1007
- return console.error(r), null;
1008
- }
1009
- };
1010
- class Ce {
1011
- constructor(t) {
1012
- this.storefront = t, this.shopifyDomain = "";
1013
- }
1014
- async query(t, s) {
1015
- var a;
1016
- if ("query" in this.storefront && "i18n" in this.storefront)
1017
- return await this.storefront.query(t, s);
1018
- if ("graphql" in this.storefront) {
1019
- const n = await this.storefront.graphql(t, s);
1020
- if ((a = n.errors) != null && a.length)
1021
- throw new Error(
1022
- n.errors.map((i) => i.message).join(`
1023
- `)
1024
- );
1025
- return n.data;
1026
- }
1027
- if ("request" in this.storefront)
1028
- return (await this.storefront.request(t, s)).data;
1029
- if ("shopifyDomain" in this.storefront && "storefrontAccessToken" in this.storefront) {
1030
- const n = await fetch(
1031
- `https://${this.storefront.shopifyDomain}/api/${De}/graphql.json`,
1032
- {
1033
- body: JSON.stringify({
1034
- query: t,
1035
- variables: s == null ? void 0 : s.variables
1036
- }),
1037
- headers: {
1038
- "Content-Type": "application/json",
1039
- "X-Shopify-Storefront-Access-Token": this.storefront.storefrontAccessToken
1040
- },
1041
- method: "POST"
1042
- }
1043
- );
1044
- if (!n.ok)
1045
- throw new Error(n.statusText);
1046
- return (await n.json()).data;
1047
- } else {
1048
- const n = await fetch(this.storefront.getStorefrontApiUrl(), {
1049
- body: JSON.stringify({
1050
- query: t,
1051
- variables: s == null ? void 0 : s.variables
1052
- }),
1053
- headers: this.storefront.getPublicTokenHeaders(),
1054
- method: "POST"
1055
- });
1056
- if (!n.ok)
1057
- throw new Error(n.statusText);
1058
- return (await n.json()).data;
1059
- }
1060
- }
1061
- get i18n() {
1062
- if ("i18n" in this.storefront)
1063
- return this.storefront.i18n;
1064
- }
1065
- }
1066
- const E = "kaching-bundles-block", O = 1e4, Ne = "https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js", Ge = "https://bundles-integrations.kachingappz.app/kaching-bundles-block.js", A = /* @__PURE__ */ new WeakSet(), j = async (e) => {
1067
- const t = e.document;
1068
- if (!e.customElements.get(E)) {
1069
- if (A.has(t))
1070
- return D(e, E);
1071
- A.add(t);
1072
- try {
1073
- await Me(e);
1074
- } catch (s) {
1075
- throw A.delete(t), s;
1076
- }
1077
- }
1078
- }, Te = () => typeof window < "u" && typeof window.__KACHING_DEV__ < "u", Be = () => Te() ? Ne : Ge, Me = (e) => {
1079
- const t = e.document;
1080
- return new Promise((s, a) => {
1081
- const n = Be();
1082
- if (t.querySelector(
1083
- `script[src="${n}"]`
1084
- )) {
1085
- D(e, E).then(s).catch(a);
1086
- return;
1087
- }
1088
- const o = t.createElement("script");
1089
- o.src = n, o.onload = () => D(e, E).then(s).catch(a), o.onerror = () => a(new Error("Failed to load script")), t.head.appendChild(o);
1090
- });
1091
- }, D = (e, t) => new Promise((s, a) => {
1092
- if (e.customElements.get(t)) {
1093
- s();
1094
- return;
1095
- }
1096
- Promise.race([
1097
- e.customElements.whenDefined(t),
1098
- new Promise(
1099
- (n, i) => setTimeout(
1100
- () => i(
1101
- new Error(
1102
- `Custom element "${t}" failed to register within ${O}ms`
1103
- )
1104
- ),
1105
- O
1106
- )
1107
- )
1108
- ]).then(() => s()).catch(a);
414
+ `, { variables: {
415
+ metafieldNamespace: a,
416
+ settingsNamespace: o
417
+ } }), h = l === d ? u : e(l, {
418
+ language: n,
419
+ country: r
420
+ }), g = f ? S(f.value) : 1, _ = m ? JSON.parse(m.value) : null, v = _?.feature_flags ?? {}, y = _?.custom_selectors ?? {};
421
+ return {
422
+ shopifyDomain: p.host,
423
+ moneyFormat: h,
424
+ locale: n?.toLowerCase() || "en",
425
+ liquidLocale: n?.toLowerCase() || "en",
426
+ country: r ?? "US",
427
+ currencyRate: g,
428
+ marketId: 0,
429
+ productId: null,
430
+ storefrontAccessToken: _?.storefront_access_token ?? null,
431
+ includeSellingPlans: _?.include_selling_plans ?? !1,
432
+ includeAvailableQuantity: _?.include_available_quantity ?? !1,
433
+ customApiHost: _?.custom_api_host ?? null,
434
+ keepQuantityInput: _?.keep_quantity_input ?? !1,
435
+ ignoreDeselect: _?.ignore_deselect ?? !1,
436
+ ignoreUnitPrice: _?.ignore_unit_price ?? !1,
437
+ requireCustomerLogin: _?.require_customer_login ?? !1,
438
+ abTestsRunning: _?.ab_tests_running ?? !1,
439
+ webPixel: _?.web_pixel ?? !1,
440
+ b2bCustomer: !1,
441
+ isLoggedIn: !1,
442
+ preview: !1,
443
+ previewAlerts: !1,
444
+ previewScratchOff: !1,
445
+ defaultTranslations: {
446
+ "system.out_of_stock": "Out of stock",
447
+ "system.invalid_variant": "Invalid variant",
448
+ "system.unavailable_option_value": "Unavailable option value",
449
+ "system.confirm": "Confirm",
450
+ "system.cancel": "Cancel",
451
+ "system.free": "FREE",
452
+ "system.search": "Search",
453
+ "system.quantity": "Quantity",
454
+ "system.subscription_plan": "Subscription plan",
455
+ "system.remove": "Remove",
456
+ "system.sort_by": "Sort by",
457
+ "system.sort_relevance": "Relevance",
458
+ "system.sort_newest_first": "Newest first",
459
+ "system.sort_price_low_to_high": "Price: Low → High",
460
+ "system.sort_price_high_to_low": "Price: High → Low",
461
+ "system.no_results_found": "No results found",
462
+ "system.no_results_description": "We can't find any item matching your search.",
463
+ "system.clear_search": "Clear search",
464
+ "system.no_products_available": "No products available",
465
+ "system.original_price": "Original price:",
466
+ "system.price": "Price:",
467
+ "system.letters_only": "Only letters are allowed.",
468
+ "system.numbers_only": "Only numbers are allowed."
469
+ },
470
+ customSelectors: {
471
+ quantity: y.quantity ?? null,
472
+ addToCartButton: y.add_to_cart_button ?? null,
473
+ variantPicker: y.variant_picker ?? null,
474
+ price: y.price ?? null,
475
+ priceCompare: y.price_compare ?? null
476
+ },
477
+ shopCustomStyles: _?.shop_custom_styles ?? "",
478
+ featureFlags: v,
479
+ brandColors: _?.brand_colors ?? null
480
+ };
481
+ }, S = (e) => JSON.parse(e).amount / 1e6, C = async (e, t, n = 200) => {
482
+ let r = [...new Set(t.filter(Boolean).filter((e) => !e.startsWith("placeholder")))];
483
+ if (r.length === 0) return [];
484
+ let i = [];
485
+ for (let e = 0; e < r.length; e += 250) i.push(r.slice(e, e + 250));
486
+ return (await Promise.all(i.map((t) => e.query("\n query FetchMediaImages($mediaImageIds: [ID!]!, $size: Int!) {\n nodes(ids: $mediaImageIds) {\n ... on MediaImage {\n id\n image {\n url(transform: { maxWidth: $size, maxHeight: $size })\n }\n }\n }\n }\n ", { variables: {
487
+ mediaImageIds: t,
488
+ size: n
489
+ } })))).flatMap((e) => e.nodes).flatMap((e) => e?.image ? [{
490
+ gid: e.id,
491
+ url: e.image.url
492
+ }] : []);
493
+ }, w = (e) => [
494
+ ...T(e),
495
+ ...E(e),
496
+ ...D(e),
497
+ ...O(e),
498
+ ...k(e),
499
+ ...ee(e),
500
+ ...te(e),
501
+ ...ne(e),
502
+ ...re(e),
503
+ ...A(e),
504
+ ...j(e),
505
+ ...M(e),
506
+ ...ie(e)
507
+ ].filter((e) => e != null && !e.includes("placeholder")), T = (e) => e.dealBars.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), E = (e) => e.dealBars.flatMap((e) => e.dealBarType === d.Bundle ? e.bundleProducts.map((e) => e.mediaImageGID) : []).filter((e) => e != null), D = (e) => e.dealBars.map(({ freeGifts: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), O = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => (e || []).map((e) => e.mediaImageGID)).filter((e) => e != null), k = (e) => e.dealBars.map(({ upsells: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), ee = (e) => e.swatchOptions ? e.swatchOptions.reduce((e, t) => {
508
+ let n = t.images.map((e) => e.mediaImageGID).filter((e) => e != null);
509
+ return [...e, ...n];
510
+ }, []) : [], te = (e) => {
511
+ if (!e.collectionBreaksEnabled || !e.collectionBreaks) return [];
512
+ let t = e.collectionBreaks.mediaImageGID;
513
+ return t ? [t] : [];
514
+ }, ne = (e) => e.progressiveGifts ? [
515
+ ...e.progressiveGifts.gifts?.map((e) => e.mediaImageGID) || [],
516
+ e.progressiveGifts.style?.lockedMediaImageGID,
517
+ e.progressiveGifts.dealBarStyle?.lockedMediaImageGID
518
+ ].filter((e) => e != null) : [], re = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), A = (e) => e.dealBars.map((e) => e.productPersonalisation?.mediaImageGID).filter((e) => e != null), j = (e) => {
519
+ let t = e.dealBars.map((e) => e.highlights?.customIconGID).filter((e) => e != null), n = e.subscriptions?.highlights?.customIconGID;
520
+ return n ? [...t, n] : t;
521
+ }, M = (e) => (e.badges || []).flatMap((e) => e.badgeType === "custom" && e.imageGID ? [e.imageGID] : []), ie = (e) => !e.savingsSummaryEnabled || !e.savingsSummary ? [] : e.savingsSummary.customIconGID ? [e.savingsSummary.customIconGID] : [], ae = (e) => {
522
+ let t = [
523
+ ...oe(e),
524
+ ...se(e),
525
+ ...N(e),
526
+ ...P(e),
527
+ ...F(e),
528
+ ...I(e),
529
+ ...L(e),
530
+ ...R(e)
531
+ ];
532
+ return Array.from(new Set(t.filter((e) => e != null)));
533
+ }, oe = (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), N = (e) => e.progressiveGiftsEnabled && e.progressiveGifts?.gifts.map((e) => e.productGID).filter((e) => e != null) || [], P = (e) => e.dealBars.flatMap(({ upsells: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), F = (e) => e.dealBars.filter((e) => e.dealBarType === d.Bundle).flatMap(({ bundleProducts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null).filter((e) => e !== "default"), I = (e) => e.dealBars.filter((e) => e.dealBarType === d.MixAndMatch).flatMap(({ bundleProducts: e }) => e ? e.flatMap((e) => [e.productGID, ...e.selectedProducts?.map((e) => e.id) ?? []]) : []).filter((e) => e != null).filter((e) => e !== "default"), L = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.map((e) => e.productGID).filter((e) => e != null), R = (e) => e.dealBars.filter((e) => e.dealBarType === d.Sku).flatMap(({ productGID: e }) => e ? [e] : []), z = class extends Error {
534
+ constructor({ status: e, operationName: t, graphqlErrors: n }) {
535
+ let r = n.length ? `: ${n.join("; ")}` : "";
536
+ super(`Storefront API ${t ?? "query"} failed (HTTP ${e})${r}`), this.name = "StorefrontApiError", this.status = e, this.operationName = t, this.graphqlErrors = n;
537
+ }
538
+ }, B = async (e, t) => {
539
+ let n = await e.text();
540
+ if (!n) throw Error("Empty graphql response");
541
+ let r;
542
+ try {
543
+ r = JSON.parse(n);
544
+ } catch (n) {
545
+ throw e.ok ? n : new z({
546
+ status: e.status,
547
+ operationName: t,
548
+ graphqlErrors: []
549
+ });
550
+ }
551
+ if (!e.ok || r.data === null || r.data === void 0) throw new z({
552
+ status: e.status,
553
+ operationName: t,
554
+ graphqlErrors: (r.errors ?? []).map(({ message: e }) => e).filter(Boolean)
555
+ });
556
+ return r.data;
557
+ }, V = class {
558
+ constructor(e, t) {
559
+ this.storefrontApiVersion = "2026-07", this.storefrontAccessToken = t, this.shopifyDomain = e;
560
+ }
561
+ async query(e, t) {
562
+ let n = t?.variables ?? {}, r = `https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`, i = e.match(/query\s+(\w+)/)?.[1];
563
+ return i && (r += `?operation_name=${i}`), B(await fetch(r, {
564
+ method: "POST",
565
+ headers: {
566
+ "Content-Type": "application/json",
567
+ "X-Shopify-Storefront-Access-Token": this.storefrontAccessToken
568
+ },
569
+ body: JSON.stringify({
570
+ query: e,
571
+ variables: n
572
+ })
573
+ }), i);
574
+ }
575
+ }, H = (e, t) => {
576
+ let n = [], r = e.filter((e) => e.blockVisibility === "selected-products");
577
+ for (let e of r) e.selectedProductIds.map(Number).includes(t.id) && n.push(e);
578
+ let i = e.filter((e) => e.blockVisibility === "selected-collections");
579
+ for (let e of i) t.collectionIds.some((t) => e.selectedCollectionIds.map(Number).includes(t)) && n.push(e);
580
+ let a = e.filter((e) => e.blockVisibility === "excluded-products");
581
+ for (let e of a) !e.excludedProductIds.map(Number).includes(t.id) && !(e.excludedCollectionIds || []).some((e) => t.collectionIds.includes(e)) && n.push(e);
582
+ let o = e.filter((e) => e.blockVisibility === "all-products");
583
+ for (let e of o) n.push(e);
584
+ return n;
585
+ }, U = async (e, t, { country: n, language: r }) => {
586
+ let i = t.collectionBreaks;
587
+ if (!t.collectionBreaksEnabled || !i) return;
588
+ let a;
589
+ a = i.visibility === "deal-products" ? await f(e, {
590
+ country: n,
591
+ language: r,
592
+ blockVisibility: t.blockVisibility,
593
+ excludedProductGIDs: (t.excludedProductIds || []).map((e) => `gid://shopify/Product/${e}`),
594
+ selectedProductGIDs: (t.selectedProductIds || []).map((e) => `gid://shopify/Product/${e}`),
595
+ selectedCollectionGIDs: (t.selectedCollectionIds || []).map((e) => `gid://shopify/Collection/${e}`)
596
+ }) : await f(e, {
597
+ country: n,
598
+ language: r,
599
+ blockVisibility: i.visibility,
600
+ excludedProductGIDs: (i.excludedProducts || []).map(({ id: e }) => e),
601
+ selectedProductGIDs: (i.selectedProducts || []).map(({ id: e }) => e),
602
+ selectedCollectionGIDs: (i.selectedCollections || []).map(({ id: e }) => e)
603
+ });
604
+ let o = await m(e, {
605
+ country: n,
606
+ language: r,
607
+ productIds: a.map((e) => Number(e.split("/").pop())),
608
+ useExternalMetafieldNamespace: !0
609
+ });
610
+ return o = o.filter((e) => e.availableForSale), o;
611
+ }, W = ({ language: e, dealBlockId: t }) => {
612
+ let n = {
613
+ "system.out_of_stock": "There's not enough items in our stock, please select smaller bundle.",
614
+ "system.invalid_variant": "Sorry, this is not currently available.",
615
+ "system.unavailable_option_value": "Unavailable",
616
+ "system.confirm": "Confirm",
617
+ "system.cancel": "Cancel",
618
+ "system.free": "FREE",
619
+ "system.search": "Search",
620
+ "system.quantity": "Quantity",
621
+ "system.subscription_plan": "Subscription plan",
622
+ "system.remove": "Remove",
623
+ "system.sort_by": "Sort by",
624
+ "system.sort_relevance": "Relevance",
625
+ "system.sort_newest_first": "Newest first",
626
+ "system.sort_price_low_to_high": "Price: Low → High",
627
+ "system.sort_price_high_to_low": "Price: High → Low",
628
+ "system.no_results_found": "No results found",
629
+ "system.no_results_description": "We can't find any item matching your search.",
630
+ "system.clear_search": "Clear search",
631
+ "system.no_products_available": "No products available",
632
+ "system.original_price": "Original price:",
633
+ "system.price": "Price:",
634
+ "system.letters_only": "Only letters are allowed.",
635
+ "system.numbers_only": "Only numbers are allowed.",
636
+ "system.personalisation_required_alert": "Please add personalisation for every item to continue."
637
+ }, r = e ? G(e) : void 0;
638
+ return {
639
+ ...n,
640
+ ...r?.system,
641
+ ...r?.dealBlocks[t]
642
+ };
643
+ }, G = (e) => {
644
+ if (typeof document > "u") return;
645
+ let t = document.querySelector("script#kaching-bundles-translations");
646
+ if (!t?.textContent) return;
647
+ let n;
648
+ try {
649
+ n = JSON.parse(t.textContent);
650
+ } catch {
651
+ return;
652
+ }
653
+ let r = K(e);
654
+ return n.find((e) => K(e.locale) === r)?.translations;
655
+ }, K = (e) => e.toLowerCase().replace(/_/g, "-"), ce = "2026-07", q = async (e, { productId: t, dealBlockId: n, country: r = void 0, language: i = void 0 }) => {
656
+ try {
657
+ let a = [Number(t.split("/").pop())], o = new le(e);
658
+ r ||= o.i18n?.country, i ||= o.i18n?.language;
659
+ let s = await x(o, {
660
+ language: i,
661
+ country: r,
662
+ useExternalMetafieldNamespace: !0
663
+ });
664
+ o.shopifyDomain = s.shopifyDomain;
665
+ let l = s.storefrontAccessToken ? new V(s.shopifyDomain, s.storefrontAccessToken) : o, [u, d] = await Promise.all([m(l, {
666
+ country: r,
667
+ language: i,
668
+ productIds: a,
669
+ useExternalMetafieldNamespace: !0
670
+ }), c(l, {
671
+ useExternalMetafieldNamespace: !0,
672
+ useMetaobjects: s.featureFlags.storefront_metaobjects
673
+ })]), f = u[0];
674
+ if (!f) return null;
675
+ let p = H(d, f), h;
676
+ if (n ? (h = p.find((e) => e.id === n || e.nanoId === n), h ||= p[0]) : h = p[0], !h) return null;
677
+ let g = w(h), _ = ae(h), [v, y, b, S] = await Promise.all([
678
+ m(l, {
679
+ country: r,
680
+ language: i,
681
+ productIds: _,
682
+ useExternalMetafieldNamespace: !0
683
+ }),
684
+ C(l, g, 300),
685
+ U(l, h, {
686
+ country: r,
687
+ language: i
688
+ }),
689
+ W({
690
+ language: i,
691
+ dealBlockId: h.id
692
+ })
693
+ ]);
694
+ return {
695
+ product: f,
696
+ dealBlock: h,
697
+ config: s,
698
+ otherProducts: v,
699
+ mediaImages: y,
700
+ collectionBreaksProducts: b ?? [],
701
+ translations: S
702
+ };
703
+ } catch (e) {
704
+ return console.error(e), null;
705
+ }
706
+ }, le = class {
707
+ constructor(e) {
708
+ this.storefront = e, this.shopifyDomain = "";
709
+ }
710
+ async query(e, t) {
711
+ if ("query" in this.storefront && "i18n" in this.storefront) return await this.storefront.query(e, t);
712
+ if ("graphql" in this.storefront) {
713
+ let n = await this.storefront.graphql(e, t);
714
+ if (n.errors?.length) throw Error(n.errors.map((e) => e.message).join("\n"));
715
+ return n.data;
716
+ }
717
+ if ("request" in this.storefront) return (await this.storefront.request(e, t)).data;
718
+ if ("shopifyDomain" in this.storefront && "storefrontAccessToken" in this.storefront) {
719
+ let n = await fetch(`https://${this.storefront.shopifyDomain}/api/${ce}/graphql.json`, {
720
+ body: JSON.stringify({
721
+ query: e,
722
+ variables: t?.variables
723
+ }),
724
+ headers: {
725
+ "Content-Type": "application/json",
726
+ "X-Shopify-Storefront-Access-Token": this.storefront.storefrontAccessToken
727
+ },
728
+ method: "POST"
729
+ });
730
+ if (!n.ok) throw Error(n.statusText);
731
+ return (await n.json()).data;
732
+ }
733
+ {
734
+ let n = await fetch(this.storefront.getStorefrontApiUrl(), {
735
+ body: JSON.stringify({
736
+ query: e,
737
+ variables: t?.variables
738
+ }),
739
+ headers: this.storefront.getPublicTokenHeaders(),
740
+ method: "POST"
741
+ });
742
+ if (!n.ok) throw Error(n.statusText);
743
+ return (await n.json()).data;
744
+ }
745
+ }
746
+ get i18n() {
747
+ if ("i18n" in this.storefront) return this.storefront.i18n;
748
+ }
749
+ }, J = "kaching-bundles-block", Y = 1e4, ue = "https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js", de = "https://bundles-integrations.kachingappz.app/kaching-bundles-block.js", X = /* @__PURE__ */ new WeakSet(), Z = async (e) => {
750
+ let t = e.document;
751
+ if (!e.customElements.get(J)) {
752
+ if (X.has(t)) return Q(e, J);
753
+ X.add(t);
754
+ try {
755
+ await me(e);
756
+ } catch (e) {
757
+ throw X.delete(t), e;
758
+ }
759
+ }
760
+ }, fe = () => typeof window < "u" && window.__KACHING_DEV__ !== void 0, pe = () => fe() ? ue : de, me = (e) => {
761
+ let t = e.document;
762
+ return new Promise((n, r) => {
763
+ let i = pe();
764
+ if (t.querySelector(`script[src="${i}"]`)) {
765
+ Q(e, J).then(n).catch(r);
766
+ return;
767
+ }
768
+ let a = t.createElement("script");
769
+ a.src = i, a.onload = () => Q(e, J).then(n).catch(r), a.onerror = () => r(/* @__PURE__ */ Error("Failed to load script")), t.head.appendChild(a);
770
+ });
771
+ }, Q = (e, t) => new Promise((n, r) => {
772
+ 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 ${Y}ms`)), Y))]).then(() => n()).catch(r);
1109
773
  });
1110
- var k = /* @__PURE__ */ ((e) => (e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e))(k || {});
1111
- const qe = {
1112
- id: 1,
1113
- handle: "example-product",
1114
- url: null,
1115
- availableForSale: !0,
1116
- title: "Example product",
1117
- image: null,
1118
- collectionIds: [],
1119
- options: [],
1120
- selectedVariantId: 1,
1121
- variants: [
1122
- {
1123
- id: 1,
1124
- availableForSale: !0,
1125
- price: 8e3,
1126
- compareAtPrice: null,
1127
- options: ["Default Title"],
1128
- imageId: null,
1129
- image: null,
1130
- unitPriceMeasurement: null,
1131
- sellingPlans: [],
1132
- inventoryManagement: null,
1133
- inventoryPolicy: null,
1134
- inventoryQuantity: 50
1135
- }
1136
- ],
1137
- metafields: { text: null, text2: null, text3: null, text4: null },
1138
- requiresSellingPlan: !1,
1139
- sellingPlans: [],
1140
- isNativeBundle: !1
1141
- }, Oe = {
1142
- id: "example",
1143
- nanoId: "example",
1144
- blockName: "Bundle",
1145
- discountName: "",
1146
- blockTitle: "BUNDLE & SAVE",
1147
- blockLayout: "vertical",
1148
- blockVisibility: "all-products",
1149
- marketId: null,
1150
- currency: null,
1151
- excludeB2bCustomers: !1,
1152
- excludePos: !1,
1153
- startTimestamp: 0,
1154
- endTimestamp: null,
1155
- differentVariantsEnabled: !0,
1156
- hideVariantPicker: !0,
1157
- disableVariantOptionSync: !1,
1158
- hideUnavailableOptions: !1,
1159
- showPricesPerItem: !1,
1160
- showBothPrices: !1,
1161
- unitLabel: "",
1162
- useProductCompareAtPrice: !0,
1163
- showPricesWithoutDecimals: !1,
1164
- priceRounding: !1,
1165
- priceRoundingPrecision: ".00",
1166
- updateNativePrice: !1,
1167
- updateNativePriceType: "item",
1168
- skipCart: !1,
1169
- showVariantsForSingleQuantity: !1,
1170
- preselectedDealBarId: "duo",
1171
- cornerRadius: 16,
1172
- spacing: 1,
1173
- selectedProductIds: [],
1174
- selectedCollectionIds: [],
1175
- excludedProductIds: [],
1176
- excludedCollectionIds: [],
1177
- colors: {
1178
- background: { red: 245, green: 245, blue: 245, alpha: 1 },
1179
- selectedBackground: { red: 255, green: 255, blue: 255, alpha: 1 },
1180
- border: { red: 0, green: 0, blue: 0, alpha: 1 },
1181
- blockTitle: { red: 0, green: 0, blue: 0, alpha: 1 },
1182
- title: { red: 0, green: 0, blue: 0, alpha: 1 },
1183
- subtitle: { red: 85, green: 85, blue: 85, alpha: 1 },
1184
- price: { red: 0, green: 0, blue: 0, alpha: 1 },
1185
- fullPrice: { red: 85, green: 85, blue: 85, alpha: 1 },
1186
- labelBackground: { red: 171, green: 239, blue: 198, alpha: 1 },
1187
- label: { red: 0, green: 0, blue: 0, alpha: 1 },
1188
- badgeBackground: { red: 0, green: 0, blue: 0, alpha: 1 },
1189
- badgeText: { red: 255, green: 255, blue: 255, alpha: 1 },
1190
- freeGiftBackground: { red: 0, green: 0, blue: 0, alpha: 0.3 },
1191
- freeGiftText: { red: 0, green: 0, blue: 0, alpha: 1 },
1192
- freeGiftSelectedBackground: { red: 0, green: 0, blue: 0, alpha: 1 },
1193
- freeGiftSelectedText: { red: 255, green: 255, blue: 255, alpha: 1 },
1194
- upsellBackground: { red: 0, green: 0, blue: 0, alpha: 0.2 },
1195
- upsellText: { red: 0, green: 0, blue: 0, alpha: 1 },
1196
- upsellSelectedBackground: { red: 0, green: 0, blue: 0, alpha: 0.2 },
1197
- upsellSelectedText: { red: 0, green: 0, blue: 0, alpha: 1 }
1198
- },
1199
- fonts: {
1200
- blockTitle: { size: "14", style: "bold" },
1201
- title: { size: "20", style: "bold" },
1202
- subtitle: { size: "14", style: "regular" },
1203
- label: { size: "12", style: "bold" },
1204
- freeGift: { size: "13", style: "bold" },
1205
- upsell: { size: "13", style: "bold" },
1206
- unitLabel: { size: "14", style: "regular" }
1207
- },
1208
- dealBars: [
1209
- {
1210
- id: "single",
1211
- dealBarType: k.QuantityBreak,
1212
- quantitySelector: !1,
1213
- title: "Single",
1214
- subtitle: "Standard price",
1215
- label: "",
1216
- quantity: 1,
1217
- discountType: "default",
1218
- discountValue: "",
1219
- badgeStyle: "simple",
1220
- badgeText: "",
1221
- badgeImageGID: null,
1222
- mediaImageGID: null,
1223
- freeGifts: [],
1224
- multipleGiftsSelectors: [],
1225
- upsells: [],
1226
- showAsSoldOutEnabled: !1,
1227
- showAsSoldOut: null,
1228
- productPersonalisation: null,
1229
- highlights: null,
1230
- sellingPlanEnabled: !1,
1231
- sellingPlanGid: null,
1232
- subscriptionMode: "customer-choice"
1233
- },
1234
- {
1235
- id: "duo",
1236
- dealBarType: k.QuantityBreak,
1237
- quantitySelector: !1,
1238
- title: "Duo",
1239
- subtitle: "You save 20%",
1240
- label: "SAVE $32",
1241
- quantity: 2,
1242
- discountType: "percentage",
1243
- discountValue: "20",
1244
- badgeStyle: "most-popular",
1245
- badgeText: "",
1246
- badgeImageGID: null,
1247
- mediaImageGID: null,
1248
- freeGifts: [],
1249
- multipleGiftsSelectors: [],
1250
- upsells: [],
1251
- showAsSoldOutEnabled: !1,
1252
- showAsSoldOut: null,
1253
- productPersonalisation: null,
1254
- highlights: null,
1255
- sellingPlanEnabled: !1,
1256
- sellingPlanGid: null,
1257
- subscriptionMode: "customer-choice"
1258
- },
1259
- {
1260
- id: "trio",
1261
- dealBarType: k.QuantityBreak,
1262
- quantitySelector: !1,
1263
- title: "Trio",
1264
- subtitle: "You save 25%",
1265
- label: "SAVE $60",
1266
- quantity: 3,
1267
- discountType: "percentage",
1268
- discountValue: "25",
1269
- badgeStyle: "simple",
1270
- badgeText: "",
1271
- badgeImageGID: null,
1272
- mediaImageGID: null,
1273
- freeGifts: [],
1274
- multipleGiftsSelectors: [],
1275
- upsells: [],
1276
- showAsSoldOutEnabled: !1,
1277
- showAsSoldOut: null,
1278
- productPersonalisation: null,
1279
- highlights: null,
1280
- sellingPlanEnabled: !1,
1281
- sellingPlanGid: null,
1282
- subscriptionMode: "customer-choice"
1283
- }
1284
- ],
1285
- badgesEnabled: !0,
1286
- badges: [
1287
- {
1288
- id: "bdg1",
1289
- attachedTo: { type: "dealBar", dealBarId: "duo" },
1290
- text: "MOST POPULAR",
1291
- colors: null,
1292
- badgeType: "most-popular",
1293
- size: 90
1294
- }
1295
- ],
1296
- swatchOptions: [],
1297
- swatchSize: 18,
1298
- swatchShape: "circle",
1299
- imageSize: 48,
1300
- imageCornerRadius: 6,
1301
- defaultVariantsV2: [],
1302
- collectionBreaksEnabled: !1,
1303
- collectionBreaks: null,
1304
- chooseProductModal: null,
1305
- timerEnabled: !1,
1306
- timer: null,
1307
- subscriptionsEnabled: !1,
1308
- subscriptions: null,
1309
- stickyAtcEnabled: !1,
1310
- stickyAtc: null,
1311
- progressiveGiftsEnabled: !1,
1312
- progressiveGifts: null,
1313
- checkboxUpsellsEnabled: !1,
1314
- checkboxUpsells: null,
1315
- customStylesEnabled: !1,
1316
- shopCustomStyles: "",
1317
- customStyles: "",
1318
- lowStockAlertEnabled: !1,
1319
- lowStockAlert: null
1320
- }, je = {
1321
- shopifyDomain: "",
1322
- moneyFormat: "${{amount}}",
1323
- locale: "en",
1324
- country: "US",
1325
- currencyRate: 1,
1326
- marketId: 0,
1327
- productId: null,
1328
- storefrontAccessToken: null,
1329
- includeSellingPlans: !1,
1330
- includeAvailableQuantity: !1,
1331
- customApiHost: null,
1332
- keepQuantityInput: !1,
1333
- ignoreDeselect: !1,
1334
- ignoreUnitPrice: !1,
1335
- requireCustomerLogin: !1,
1336
- abTestsRunning: !1,
1337
- webPixel: !1,
1338
- b2bCustomer: !1,
1339
- isLoggedIn: !1,
1340
- preview: !0,
1341
- previewAlerts: !1,
1342
- previewScratchOff: !1,
1343
- defaultTranslations: {
1344
- "system.out_of_stock": "There's not enough items in our stock, please select smaller bundle.",
1345
- "system.invalid_variant": "Sorry, this is not currently available.",
1346
- "system.unavailable_option_value": "Unavailable",
1347
- "system.confirm": "Confirm",
1348
- "system.cancel": "Cancel",
1349
- "system.free": "FREE",
1350
- "system.search": "Search",
1351
- "system.quantity": "Quantity",
1352
- "system.subscription_plan": "Subscription plan",
1353
- "system.remove": "Remove",
1354
- "system.sort_by": "Sort by",
1355
- "system.sort_relevance": "Relevance",
1356
- "system.sort_newest_first": "Newest first",
1357
- "system.sort_price_low_to_high": "Price: Low → High",
1358
- "system.sort_price_high_to_low": "Price: High → Low",
1359
- "system.no_results_found": "No results found",
1360
- "system.no_results_description": "We can't find any item matching your search.",
1361
- "system.clear_search": "Clear search",
1362
- "system.no_products_available": "No products available",
1363
- "system.original_price": "Original price:",
1364
- "system.price": "Price:",
1365
- "system.letters_only": "Only letters are allowed.",
1366
- "system.numbers_only": "Only numbers are allowed."
1367
- },
1368
- customSelectors: {
1369
- quantity: null,
1370
- addToCartButton: null,
1371
- variantPicker: null,
1372
- price: null,
1373
- priceCompare: null
1374
- },
1375
- featureFlags: {},
1376
- shopCustomStyles: ""
1377
- }, Le = {
1378
- config: je,
1379
- dealBlock: Oe,
1380
- product: qe,
1381
- otherProducts: [],
1382
- mediaImages: [],
1383
- collectionBreaksProducts: [],
1384
- translations: {}
1385
- };
1386
- class Ue extends HTMLElement {
1387
- constructor() {
1388
- super(...arguments), this.innerElement = null, this.handleItemsChanged = null, this.initializeId = 0;
1389
- }
1390
- static get observedAttributes() {
1391
- return ["selected-variant-id", "product-id", "country", "language"];
1392
- }
1393
- async connectedCallback() {
1394
- await this.initialize();
1395
- }
1396
- async initialize() {
1397
- var o, r;
1398
- const t = ++this.initializeId;
1399
- if (this.cleanup(), this.hasAttribute("demo")) {
1400
- if (await j(window), t !== this.initializeId) return;
1401
- this.renderInnerElement(Le);
1402
- return;
1403
- }
1404
- const s = this.getAttribute("shop-domain"), a = this.getAttribute("storefront-token"), n = this.getAttribute("product-id");
1405
- if (!s || !a || !n) return;
1406
- const [i] = await Promise.all([
1407
- xe(
1408
- {
1409
- shopifyDomain: s,
1410
- storefrontAccessToken: a
1411
- },
1412
- {
1413
- productId: n,
1414
- dealBlockId: this.getAttribute("deal-block-id") ?? void 0,
1415
- country: ((o = this.getAttribute("country")) == null ? void 0 : o.toUpperCase()) ?? void 0,
1416
- language: ((r = this.getAttribute("language")) == null ? void 0 : r.toUpperCase()) ?? void 0
1417
- }
1418
- ),
1419
- j(window)
1420
- ]);
1421
- !i || t !== this.initializeId || this.renderInnerElement(i);
1422
- }
1423
- renderInnerElement(t) {
1424
- const {
1425
- config: s,
1426
- dealBlock: a,
1427
- product: n,
1428
- otherProducts: i,
1429
- mediaImages: o,
1430
- collectionBreaksProducts: r,
1431
- translations: m
1432
- } = t;
1433
- this.innerElement = document.createElement(
1434
- "kaching-bundles-block"
1435
- ), this.innerElement.setAttribute("deal-block-id", a.id), this.innerElement.setAttribute("config", JSON.stringify(s)), this.innerElement.setAttribute("deal-block", JSON.stringify(a)), this.innerElement.setAttribute(
1436
- "media-images",
1437
- JSON.stringify(o ?? [])
1438
- ), this.innerElement.setAttribute("product", JSON.stringify(n)), this.innerElement.setAttribute(
1439
- "other-products",
1440
- JSON.stringify(i ?? [])
1441
- ), this.innerElement.setAttribute(
1442
- "collection-breaks-products",
1443
- JSON.stringify(r ?? [])
1444
- ), this.innerElement.setAttribute(
1445
- "translations",
1446
- JSON.stringify(m ?? {})
1447
- );
1448
- const c = this.getAttribute("selected-variant-id");
1449
- this.innerElement.setAttribute(
1450
- "current-variant-id",
1451
- String(c ? c.split("/").pop() : n.variants[0].id)
1452
- ), this.hasAttribute("compact") && this.innerElement.setAttribute("compact", "");
1453
- const u = this.innerElement, h = () => {
1454
- if (this.innerElement !== u) return;
1455
- const f = u.items();
1456
- f && this.dispatchEvent(
1457
- new CustomEvent("items-changed", {
1458
- detail: { items: f },
1459
- bubbles: !0
1460
- })
1461
- );
1462
- };
1463
- this.handleItemsChanged = (f) => {
1464
- f.stopPropagation(), h();
1465
- };
1466
- const g = this.handleItemsChanged;
1467
- u.addEventListener(
1468
- "kaching-bundles-block-loaded",
1469
- () => {
1470
- this.innerElement === u && (u.addEventListener("items-changed", g), this.dispatchEvent(new CustomEvent("loaded", { bubbles: !0 })));
1471
- },
1472
- { once: !0 }
1473
- ), this.appendChild(this.innerElement);
1474
- }
1475
- cleanup() {
1476
- this.handleItemsChanged && this.innerElement && (this.innerElement.removeEventListener(
1477
- "items-changed",
1478
- this.handleItemsChanged
1479
- ), this.handleItemsChanged = null), this.innerElement && (this.innerElement.remove(), this.innerElement = null);
1480
- }
1481
- attributeChangedCallback(t, s, a) {
1482
- s !== a && this.isConnected && (t === "product-id" || t === "country" || t === "language" ? this.initialize() : t === "selected-variant-id" && this.innerElement && a && this.innerElement.setAttribute(
1483
- "current-variant-id",
1484
- a.includes("/") ? String(a.split("/").pop()) : a
1485
- ));
1486
- }
1487
- items() {
1488
- return this.innerElement ? this.innerElement.items() : [];
1489
- }
1490
- disconnectedCallback() {
1491
- this.cleanup(), this.initializeId++;
1492
- }
1493
- }
1494
- customElements.define("kaching-bundle-component", Ue);
1495
- export {
1496
- xe as fetchKachingBundlesData
774
+ [
775
+ "primaryBackground",
776
+ "secondaryBackground",
777
+ "primaryText",
778
+ "secondaryText",
779
+ "border",
780
+ "overlay",
781
+ "primaryAccent",
782
+ "primaryAccentText",
783
+ "badgeBackground",
784
+ "badgeText",
785
+ "error"
786
+ ].map((e) => `brand_${e}`);
787
+ var $ = /* @__PURE__ */ function(e) {
788
+ return e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e;
789
+ }({}), he = {
790
+ config: {
791
+ shopifyDomain: "",
792
+ moneyFormat: "${{amount}}",
793
+ locale: "en",
794
+ country: "US",
795
+ currencyRate: 1,
796
+ marketId: 0,
797
+ productId: null,
798
+ storefrontAccessToken: null,
799
+ includeSellingPlans: !1,
800
+ includeAvailableQuantity: !1,
801
+ customApiHost: null,
802
+ keepQuantityInput: !1,
803
+ ignoreDeselect: !1,
804
+ ignoreUnitPrice: !1,
805
+ requireCustomerLogin: !1,
806
+ abTestsRunning: !1,
807
+ webPixel: !1,
808
+ b2bCustomer: !1,
809
+ isLoggedIn: !1,
810
+ preview: !0,
811
+ previewAlerts: !1,
812
+ previewScratchOff: !1,
813
+ defaultTranslations: {
814
+ "system.out_of_stock": "There's not enough items in our stock, please select smaller bundle.",
815
+ "system.invalid_variant": "Sorry, this is not currently available.",
816
+ "system.unavailable_option_value": "Unavailable",
817
+ "system.confirm": "Confirm",
818
+ "system.cancel": "Cancel",
819
+ "system.free": "FREE",
820
+ "system.search": "Search",
821
+ "system.quantity": "Quantity",
822
+ "system.subscription_plan": "Subscription plan",
823
+ "system.remove": "Remove",
824
+ "system.sort_by": "Sort by",
825
+ "system.sort_relevance": "Relevance",
826
+ "system.sort_newest_first": "Newest first",
827
+ "system.sort_price_low_to_high": "Price: Low → High",
828
+ "system.sort_price_high_to_low": "Price: High → Low",
829
+ "system.no_results_found": "No results found",
830
+ "system.no_results_description": "We can't find any item matching your search.",
831
+ "system.clear_search": "Clear search",
832
+ "system.no_products_available": "No products available",
833
+ "system.original_price": "Original price:",
834
+ "system.price": "Price:",
835
+ "system.letters_only": "Only letters are allowed.",
836
+ "system.numbers_only": "Only numbers are allowed."
837
+ },
838
+ customSelectors: {
839
+ quantity: null,
840
+ addToCartButton: null,
841
+ variantPicker: null,
842
+ price: null,
843
+ priceCompare: null
844
+ },
845
+ featureFlags: {},
846
+ shopCustomStyles: ""
847
+ },
848
+ dealBlock: {
849
+ id: "example",
850
+ nanoId: "example",
851
+ blockName: "Bundle",
852
+ discountName: "",
853
+ blockTitle: "BUNDLE & SAVE",
854
+ blockLayout: "vertical",
855
+ blockVisibility: "all-products",
856
+ marketId: null,
857
+ currency: null,
858
+ excludeB2bCustomers: !1,
859
+ excludePos: !1,
860
+ startTimestamp: 0,
861
+ endTimestamp: null,
862
+ differentVariantsEnabled: !0,
863
+ hideVariantPicker: !0,
864
+ disableVariantOptionSync: !1,
865
+ hideUnavailableOptions: !1,
866
+ showPricesPerItem: !1,
867
+ showBothPrices: !1,
868
+ unitLabel: "",
869
+ useProductCompareAtPrice: !0,
870
+ showPricesWithoutDecimals: !1,
871
+ priceRounding: !1,
872
+ priceRoundingPrecision: ".00",
873
+ updateNativePrice: !1,
874
+ updateNativePriceType: "item",
875
+ skipCart: !1,
876
+ showVariantsForSingleQuantity: !1,
877
+ preselectedDealBarId: "duo",
878
+ cornerRadius: 16,
879
+ spacing: 1,
880
+ selectedProductIds: [],
881
+ selectedCollectionIds: [],
882
+ excludedProductIds: [],
883
+ excludedCollectionIds: [],
884
+ colors: {
885
+ background: {
886
+ red: 245,
887
+ green: 245,
888
+ blue: 245,
889
+ alpha: 1
890
+ },
891
+ selectedBackground: {
892
+ red: 255,
893
+ green: 255,
894
+ blue: 255,
895
+ alpha: 1
896
+ },
897
+ border: {
898
+ red: 0,
899
+ green: 0,
900
+ blue: 0,
901
+ alpha: 1
902
+ },
903
+ blockTitle: {
904
+ red: 0,
905
+ green: 0,
906
+ blue: 0,
907
+ alpha: 1
908
+ },
909
+ title: {
910
+ red: 0,
911
+ green: 0,
912
+ blue: 0,
913
+ alpha: 1
914
+ },
915
+ subtitle: {
916
+ red: 85,
917
+ green: 85,
918
+ blue: 85,
919
+ alpha: 1
920
+ },
921
+ price: {
922
+ red: 0,
923
+ green: 0,
924
+ blue: 0,
925
+ alpha: 1
926
+ },
927
+ fullPrice: {
928
+ red: 85,
929
+ green: 85,
930
+ blue: 85,
931
+ alpha: 1
932
+ },
933
+ labelBackground: {
934
+ red: 171,
935
+ green: 239,
936
+ blue: 198,
937
+ alpha: 1
938
+ },
939
+ label: {
940
+ red: 0,
941
+ green: 0,
942
+ blue: 0,
943
+ alpha: 1
944
+ },
945
+ badgeBackground: {
946
+ red: 0,
947
+ green: 0,
948
+ blue: 0,
949
+ alpha: 1
950
+ },
951
+ badgeText: {
952
+ red: 255,
953
+ green: 255,
954
+ blue: 255,
955
+ alpha: 1
956
+ },
957
+ freeGiftBackground: {
958
+ red: 0,
959
+ green: 0,
960
+ blue: 0,
961
+ alpha: .3
962
+ },
963
+ freeGiftText: {
964
+ red: 0,
965
+ green: 0,
966
+ blue: 0,
967
+ alpha: 1
968
+ },
969
+ freeGiftSelectedBackground: {
970
+ red: 0,
971
+ green: 0,
972
+ blue: 0,
973
+ alpha: 1
974
+ },
975
+ freeGiftSelectedText: {
976
+ red: 255,
977
+ green: 255,
978
+ blue: 255,
979
+ alpha: 1
980
+ },
981
+ upsellBackground: {
982
+ red: 0,
983
+ green: 0,
984
+ blue: 0,
985
+ alpha: .2
986
+ },
987
+ upsellText: {
988
+ red: 0,
989
+ green: 0,
990
+ blue: 0,
991
+ alpha: 1
992
+ },
993
+ upsellSelectedBackground: {
994
+ red: 0,
995
+ green: 0,
996
+ blue: 0,
997
+ alpha: .2
998
+ },
999
+ upsellSelectedText: {
1000
+ red: 0,
1001
+ green: 0,
1002
+ blue: 0,
1003
+ alpha: 1
1004
+ }
1005
+ },
1006
+ fonts: {
1007
+ blockTitle: {
1008
+ size: "14",
1009
+ style: "bold"
1010
+ },
1011
+ title: {
1012
+ size: "20",
1013
+ style: "bold"
1014
+ },
1015
+ subtitle: {
1016
+ size: "14",
1017
+ style: "regular"
1018
+ },
1019
+ label: {
1020
+ size: "12",
1021
+ style: "bold"
1022
+ },
1023
+ freeGift: {
1024
+ size: "13",
1025
+ style: "bold"
1026
+ },
1027
+ upsell: {
1028
+ size: "13",
1029
+ style: "bold"
1030
+ },
1031
+ unitLabel: {
1032
+ size: "14",
1033
+ style: "regular"
1034
+ }
1035
+ },
1036
+ dealBars: [
1037
+ {
1038
+ id: "single",
1039
+ dealBarType: $.QuantityBreak,
1040
+ quantitySelector: !1,
1041
+ title: "Single",
1042
+ subtitle: "Standard price",
1043
+ label: "",
1044
+ quantity: 1,
1045
+ discountType: "default",
1046
+ discountValue: "",
1047
+ badgeStyle: "simple",
1048
+ badgeText: "",
1049
+ badgeImageGID: null,
1050
+ mediaImageGID: null,
1051
+ freeGifts: [],
1052
+ multipleGiftsSelectors: [],
1053
+ upsells: [],
1054
+ showAsSoldOutEnabled: !1,
1055
+ showAsSoldOut: null,
1056
+ productPersonalisation: null,
1057
+ highlights: null,
1058
+ sellingPlanEnabled: !1,
1059
+ sellingPlanGid: null,
1060
+ subscriptionMode: "customer-choice"
1061
+ },
1062
+ {
1063
+ id: "duo",
1064
+ dealBarType: $.QuantityBreak,
1065
+ quantitySelector: !1,
1066
+ title: "Duo",
1067
+ subtitle: "You save 20%",
1068
+ label: "SAVE $32",
1069
+ quantity: 2,
1070
+ discountType: "percentage",
1071
+ discountValue: "20",
1072
+ badgeStyle: "most-popular",
1073
+ badgeText: "",
1074
+ badgeImageGID: null,
1075
+ mediaImageGID: null,
1076
+ freeGifts: [],
1077
+ multipleGiftsSelectors: [],
1078
+ upsells: [],
1079
+ showAsSoldOutEnabled: !1,
1080
+ showAsSoldOut: null,
1081
+ productPersonalisation: null,
1082
+ highlights: null,
1083
+ sellingPlanEnabled: !1,
1084
+ sellingPlanGid: null,
1085
+ subscriptionMode: "customer-choice"
1086
+ },
1087
+ {
1088
+ id: "trio",
1089
+ dealBarType: $.QuantityBreak,
1090
+ quantitySelector: !1,
1091
+ title: "Trio",
1092
+ subtitle: "You save 25%",
1093
+ label: "SAVE $60",
1094
+ quantity: 3,
1095
+ discountType: "percentage",
1096
+ discountValue: "25",
1097
+ badgeStyle: "simple",
1098
+ badgeText: "",
1099
+ badgeImageGID: null,
1100
+ mediaImageGID: null,
1101
+ freeGifts: [],
1102
+ multipleGiftsSelectors: [],
1103
+ upsells: [],
1104
+ showAsSoldOutEnabled: !1,
1105
+ showAsSoldOut: null,
1106
+ productPersonalisation: null,
1107
+ highlights: null,
1108
+ sellingPlanEnabled: !1,
1109
+ sellingPlanGid: null,
1110
+ subscriptionMode: "customer-choice"
1111
+ }
1112
+ ],
1113
+ badgesEnabled: !0,
1114
+ badges: [{
1115
+ id: "bdg1",
1116
+ attachedTo: {
1117
+ type: "dealBar",
1118
+ dealBarId: "duo"
1119
+ },
1120
+ text: "MOST POPULAR",
1121
+ colors: null,
1122
+ badgeType: "most-popular",
1123
+ size: 90
1124
+ }],
1125
+ swatchOptions: [],
1126
+ swatchSize: 18,
1127
+ swatchShape: "circle",
1128
+ imageSize: 48,
1129
+ imageCornerRadius: 6,
1130
+ defaultVariantsV2: [],
1131
+ collectionBreaksEnabled: !1,
1132
+ collectionBreaks: null,
1133
+ chooseProductModal: null,
1134
+ timerEnabled: !1,
1135
+ timer: null,
1136
+ subscriptionsEnabled: !1,
1137
+ subscriptions: null,
1138
+ stickyAtcEnabled: !1,
1139
+ stickyAtc: null,
1140
+ progressiveGiftsEnabled: !1,
1141
+ progressiveGifts: null,
1142
+ checkboxUpsellsEnabled: !1,
1143
+ checkboxUpsells: null,
1144
+ customStylesEnabled: !1,
1145
+ shopCustomStyles: "",
1146
+ customStyles: "",
1147
+ lowStockAlertEnabled: !1,
1148
+ lowStockAlert: null
1149
+ },
1150
+ product: {
1151
+ id: 1,
1152
+ handle: "example-product",
1153
+ url: null,
1154
+ availableForSale: !0,
1155
+ title: "Example product",
1156
+ image: null,
1157
+ collectionIds: [],
1158
+ options: [],
1159
+ selectedVariantId: 1,
1160
+ variants: [{
1161
+ id: 1,
1162
+ availableForSale: !0,
1163
+ price: 8e3,
1164
+ compareAtPrice: null,
1165
+ options: ["Default Title"],
1166
+ imageId: null,
1167
+ image: null,
1168
+ unitPriceMeasurement: null,
1169
+ sellingPlans: [],
1170
+ inventoryManagement: null,
1171
+ inventoryPolicy: null,
1172
+ inventoryQuantity: 50
1173
+ }],
1174
+ metafields: {
1175
+ text: null,
1176
+ text2: null,
1177
+ text3: null,
1178
+ text4: null
1179
+ },
1180
+ requiresSellingPlan: !1,
1181
+ sellingPlans: [],
1182
+ isNativeBundle: !1
1183
+ },
1184
+ otherProducts: [],
1185
+ mediaImages: [],
1186
+ collectionBreaksProducts: [],
1187
+ translations: {}
1188
+ }, ge = class extends HTMLElement {
1189
+ constructor(...e) {
1190
+ super(...e), this.innerElement = null, this.handleItemsChanged = null, this.initializeId = 0;
1191
+ }
1192
+ static get observedAttributes() {
1193
+ return [
1194
+ "selected-variant-id",
1195
+ "product-id",
1196
+ "country",
1197
+ "language"
1198
+ ];
1199
+ }
1200
+ async connectedCallback() {
1201
+ await this.initialize();
1202
+ }
1203
+ async initialize() {
1204
+ let e = ++this.initializeId;
1205
+ if (this.cleanup(), this.hasAttribute("demo")) {
1206
+ if (await Z(window), e !== this.initializeId) return;
1207
+ this.renderInnerElement(he);
1208
+ return;
1209
+ }
1210
+ let t = this.getAttribute("shop-domain"), n = this.getAttribute("storefront-token"), r = this.getAttribute("product-id");
1211
+ if (!t || !n || !r) return;
1212
+ let [i] = await Promise.all([q({
1213
+ shopifyDomain: t,
1214
+ storefrontAccessToken: n
1215
+ }, {
1216
+ productId: r,
1217
+ dealBlockId: this.getAttribute("deal-block-id") ?? void 0,
1218
+ country: this.getAttribute("country")?.toUpperCase() ?? void 0,
1219
+ language: this.getAttribute("language")?.toUpperCase() ?? void 0
1220
+ }), Z(window)]);
1221
+ i && e === this.initializeId && this.renderInnerElement(i);
1222
+ }
1223
+ renderInnerElement(e) {
1224
+ let { config: t, dealBlock: n, product: r, otherProducts: i, mediaImages: a, collectionBreaksProducts: o, translations: s } = e;
1225
+ this.innerElement = document.createElement("kaching-bundles-block"), this.innerElement.setAttribute("deal-block-id", n.id), this.innerElement.setAttribute("config", JSON.stringify(t)), this.innerElement.setAttribute("deal-block", JSON.stringify(n)), this.innerElement.setAttribute("media-images", JSON.stringify(a ?? [])), this.innerElement.setAttribute("product", JSON.stringify(r)), this.innerElement.setAttribute("other-products", JSON.stringify(i ?? [])), this.innerElement.setAttribute("collection-breaks-products", JSON.stringify(o ?? [])), this.innerElement.setAttribute("translations", JSON.stringify(s ?? {}));
1226
+ let c = this.getAttribute("selected-variant-id");
1227
+ this.innerElement.setAttribute("current-variant-id", String(c ? c.split("/").pop() : r.variants[0].id)), this.hasAttribute("compact") && this.innerElement.setAttribute("compact", "");
1228
+ let l = this.innerElement, u = () => {
1229
+ if (this.innerElement !== l) return;
1230
+ let e = l.items();
1231
+ e && this.dispatchEvent(new CustomEvent("items-changed", {
1232
+ detail: { items: e },
1233
+ bubbles: !0
1234
+ }));
1235
+ };
1236
+ this.handleItemsChanged = (e) => {
1237
+ e.stopPropagation(), u();
1238
+ };
1239
+ let d = this.handleItemsChanged;
1240
+ l.addEventListener("kaching-bundles-block-loaded", () => {
1241
+ this.innerElement === l && (l.addEventListener("items-changed", d), this.dispatchEvent(new CustomEvent("loaded", { bubbles: !0 })));
1242
+ }, { once: !0 }), this.appendChild(this.innerElement);
1243
+ }
1244
+ cleanup() {
1245
+ this.handleItemsChanged && this.innerElement && (this.innerElement.removeEventListener("items-changed", this.handleItemsChanged), this.handleItemsChanged = null), this.innerElement &&= (this.innerElement.remove(), null);
1246
+ }
1247
+ attributeChangedCallback(e, t, n) {
1248
+ t !== n && this.isConnected && (e === "product-id" || e === "country" || e === "language" ? this.initialize() : e === "selected-variant-id" && this.innerElement && n && this.innerElement.setAttribute("current-variant-id", n.includes("/") ? String(n.split("/").pop()) : n));
1249
+ }
1250
+ items() {
1251
+ return this.innerElement ? this.innerElement.items() : [];
1252
+ }
1253
+ disconnectedCallback() {
1254
+ this.cleanup(), this.initializeId++;
1255
+ }
1497
1256
  };
1257
+ customElements.define("kaching-bundle-component", ge);
1258
+ export { q as fetchKachingBundlesData };