@kachingappz/bundles-js 1.1.2 → 1.1.3

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