@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.
- package/dist/bundles-js.iife.js +27 -18
- package/dist/index.d.ts +73 -10
- package/dist/index.js +611 -929
- package/dist/kaching-bundle-component/index.d.ts +73 -10
- package/dist/kaching-bundle-component/index.js +1118 -1357
- package/dist/react/index.cjs +26 -17
- package/dist/react/index.d.ts +73 -10
- package/dist/react/index.js +1086 -1432
- package/package.json +6 -11
package/dist/index.js
CHANGED
|
@@ -1,136 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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 : n.value;
|
|
74
|
-
return a ? JSON.parse(a) : [];
|
|
75
|
-
}, R = async (e, t) => {
|
|
76
|
-
const a = "app--2935586817--deal_block", n = [];
|
|
77
|
-
let s = null;
|
|
78
|
-
for (; ; ) {
|
|
79
|
-
const l = 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: a,
|
|
99
|
-
cursor: s
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
);
|
|
103
|
-
for (const u of l.metaobjects.nodes) {
|
|
104
|
-
const i = u.fields.find(
|
|
105
|
-
(d) => d.key === "settings"
|
|
106
|
-
);
|
|
107
|
-
i != null && i.value && n.push(JSON.parse(i.value));
|
|
108
|
-
}
|
|
109
|
-
if (!l.metaobjects.pageInfo.hasNextPage)
|
|
110
|
-
break;
|
|
111
|
-
s = l.metaobjects.pageInfo.endCursor;
|
|
112
|
-
}
|
|
113
|
-
return n;
|
|
114
|
-
}, k = async (e, {
|
|
115
|
-
country: t,
|
|
116
|
-
language: a,
|
|
117
|
-
blockVisibility: n,
|
|
118
|
-
excludedProductGIDs: s,
|
|
119
|
-
selectedProductGIDs: l,
|
|
120
|
-
selectedCollectionGIDs: u,
|
|
121
|
-
limit: i = 1e3
|
|
122
|
-
}) => {
|
|
123
|
-
switch (n) {
|
|
124
|
-
case "selected-products":
|
|
125
|
-
return l.slice(0, i);
|
|
126
|
-
case "all-products":
|
|
127
|
-
case "excluded-products": {
|
|
128
|
-
const d = w({ country: t, language: a });
|
|
129
|
-
let c = [], p = null;
|
|
130
|
-
for (; c.length < i; ) {
|
|
131
|
-
const f = Math.min(i - c.length, 250), h = await e.query(
|
|
132
|
-
`
|
|
133
|
-
query FetchProductGIDs($limit: Int!, $cursor: String) ${d} {
|
|
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 T = (e, t) => {
|
|
|
141
69
|
}
|
|
142
70
|
}
|
|
143
71
|
}
|
|
144
|
-
`,
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
`
|
|
164
|
-
query FetchCollectionProductGIDs($collectionGIDs: [ID!]!, $limit: Int!) ${d} {
|
|
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 T = (e, t) => {
|
|
|
172
98
|
}
|
|
173
99
|
}
|
|
174
100
|
}
|
|
175
|
-
`,
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
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
|
-
`, S = async (e, {
|
|
232
|
-
country: t,
|
|
233
|
-
language: a,
|
|
234
|
-
productIds: n,
|
|
235
|
-
includeSellingPlans: s = !0,
|
|
236
|
-
includeAvailableQuantity: l = !0,
|
|
237
|
-
useExternalMetafieldNamespace: u = !1,
|
|
238
|
-
batchSize: i = 250,
|
|
239
|
-
onBatchError: d,
|
|
240
|
-
variantImageTransform: c = { maxWidth: 200, maxHeight: 200 }
|
|
241
|
-
}) => {
|
|
242
|
-
if (!n.length)
|
|
243
|
-
return [];
|
|
244
|
-
const p = n.map((m) => typeof m == "string" && m.startsWith("gid://") ? m : `gid://shopify/Product/${m}`), f = w({ country: t, language: a }), h = `
|
|
245
|
-
query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $metafieldNamespace: String!, $variantImageTransform: ImageTransformInput) ${f} {
|
|
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 T = (e, t) => {
|
|
|
276
148
|
}
|
|
277
149
|
variants(first: 250) {
|
|
278
150
|
nodes {
|
|
279
|
-
${
|
|
151
|
+
${p}
|
|
280
152
|
}
|
|
281
153
|
}
|
|
282
154
|
collections(first: 50) {
|
|
@@ -296,6 +168,15 @@ const T = (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 T = (e, t) => {
|
|
|
328
209
|
}
|
|
329
210
|
}
|
|
330
211
|
}
|
|
331
|
-
`,
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
B,
|
|
375
|
-
e.shopifyDomain,
|
|
376
|
-
o
|
|
377
|
-
);
|
|
378
|
-
})
|
|
379
|
-
), b = [];
|
|
380
|
-
for (const P of m)
|
|
381
|
-
P.status === "fulfilled" ? b.push(P.value) : d(
|
|
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
|
-
(m) => x(
|
|
389
|
-
e,
|
|
390
|
-
m,
|
|
391
|
-
{
|
|
392
|
-
includeSellingPlans: s,
|
|
393
|
-
includeAvailableQuantity: l,
|
|
394
|
-
variantImageTransform: c
|
|
395
|
-
},
|
|
396
|
-
f
|
|
397
|
-
)
|
|
398
|
-
)
|
|
399
|
-
)).map(
|
|
400
|
-
(m) => A(m, e.shopifyDomain, o)
|
|
401
|
-
);
|
|
402
|
-
}, x = async (e, t, a, n = "") => {
|
|
403
|
-
if (t.variants.nodes.length < 250)
|
|
404
|
-
return t;
|
|
405
|
-
const s = /* @__PURE__ */ new Set(), l = [], u = [], i = async (d) => {
|
|
406
|
-
let c = !0, p = null;
|
|
407
|
-
for (; c; ) {
|
|
408
|
-
const f = await e.query(
|
|
409
|
-
`
|
|
410
|
-
query($productGID: ID!, $cursor: String, $reverse: Boolean, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $variantImageTransform: ImageTransformInput) ${n} {
|
|
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
|
-
${
|
|
258
|
+
${p}
|
|
415
259
|
}
|
|
416
260
|
pageInfo {
|
|
417
261
|
endCursor
|
|
@@ -420,169 +264,130 @@ const T = (e, t) => {
|
|
|
420
264
|
}
|
|
421
265
|
}
|
|
422
266
|
}
|
|
423
|
-
`,
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
(
|
|
547
|
-
),
|
|
548
|
-
options: s,
|
|
549
|
-
selectedVariantId: Number(
|
|
550
|
-
e.variants.nodes[0].id.split("/").pop()
|
|
551
|
-
),
|
|
552
|
-
variants: n,
|
|
553
|
-
requiresSellingPlan: e.requiresSellingPlan,
|
|
554
|
-
sellingPlans: i,
|
|
555
|
-
isNativeBundle: d,
|
|
556
|
-
metafields: {
|
|
557
|
-
text: ((f = e.metafield) == null ? void 0 : f.value) || null,
|
|
558
|
-
text2: ((h = e.metafield2) == null ? void 0 : h.value) || null,
|
|
559
|
-
text3: ((y = e.metafield3) == null ? void 0 : y.value) || null,
|
|
560
|
-
text4: ((v = e.metafield4) == null ? void 0 : v.value) || null
|
|
561
|
-
}
|
|
562
|
-
};
|
|
563
|
-
}, Q = (e, t, a) => e.filter((n) => a.filter(
|
|
564
|
-
(s) => s.options[t] === n.name
|
|
565
|
-
).length > 0), G = "app--2935586817", H = async (e, {
|
|
566
|
-
language: t,
|
|
567
|
-
country: a,
|
|
568
|
-
useExternalMetafieldNamespace: n
|
|
569
|
-
}) => {
|
|
570
|
-
const s = `${G}--kaching_bundles`, l = G, u = w({ country: a }), {
|
|
571
|
-
localization: {
|
|
572
|
-
country: {
|
|
573
|
-
currency: { isoCode: i }
|
|
574
|
-
}
|
|
575
|
-
},
|
|
576
|
-
shop: {
|
|
577
|
-
moneyFormat: d,
|
|
578
|
-
paymentSettings: { currencyCode: c },
|
|
579
|
-
currencyRateConstant: p,
|
|
580
|
-
primaryDomain: f,
|
|
581
|
-
settingsMetafield: h
|
|
582
|
-
}
|
|
583
|
-
} = await e.query(
|
|
584
|
-
`
|
|
585
|
-
query config($metafieldNamespace: String!, $settingsNamespace: String!) ${u} {
|
|
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,463 +411,340 @@ const T = (e, t) => {
|
|
|
606
411
|
}
|
|
607
412
|
}
|
|
608
413
|
}
|
|
609
|
-
`,
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
},
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
}
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
}, M = (e) => e.toLowerCase().replace(/_/g, "-"), $e = "2026-07", Se = async (e, {
|
|
945
|
-
productId: t,
|
|
946
|
-
dealBlockId: a,
|
|
947
|
-
country: n = void 0,
|
|
948
|
-
language: s = void 0
|
|
949
|
-
}) => {
|
|
950
|
-
var l, u;
|
|
951
|
-
try {
|
|
952
|
-
const i = [Number(t.split("/").pop())], d = new we(e);
|
|
953
|
-
n = n || ((l = d.i18n) == null ? void 0 : l.country), s = s || ((u = d.i18n) == null ? void 0 : u.language);
|
|
954
|
-
const c = await H(d, {
|
|
955
|
-
language: s,
|
|
956
|
-
country: n,
|
|
957
|
-
useExternalMetafieldNamespace: !0
|
|
958
|
-
});
|
|
959
|
-
d.shopifyDomain = c.shopifyDomain;
|
|
960
|
-
const p = c.storefrontAccessToken ? new ve(
|
|
961
|
-
c.shopifyDomain,
|
|
962
|
-
c.storefrontAccessToken
|
|
963
|
-
) : d, [f, h] = await Promise.all([
|
|
964
|
-
S(p, {
|
|
965
|
-
country: n,
|
|
966
|
-
language: s,
|
|
967
|
-
productIds: i,
|
|
968
|
-
useExternalMetafieldNamespace: !0
|
|
969
|
-
}),
|
|
970
|
-
V(p, {
|
|
971
|
-
useExternalMetafieldNamespace: !0,
|
|
972
|
-
useMetaobjects: c.featureFlags.storefront_metaobjects
|
|
973
|
-
})
|
|
974
|
-
]), y = f[0];
|
|
975
|
-
if (!y)
|
|
976
|
-
return null;
|
|
977
|
-
const v = T(h, y);
|
|
978
|
-
let r;
|
|
979
|
-
if (a ? (r = v.find(
|
|
980
|
-
(P) => P.id === a || P.nanoId === a
|
|
981
|
-
), r || (r = v[0])) : r = v[0], !r)
|
|
982
|
-
return null;
|
|
983
|
-
const o = W(r), g = ce(r), [_, I, m, b] = await Promise.all([
|
|
984
|
-
S(p, {
|
|
985
|
-
country: n,
|
|
986
|
-
language: s,
|
|
987
|
-
productIds: g,
|
|
988
|
-
useExternalMetafieldNamespace: !0
|
|
989
|
-
}),
|
|
990
|
-
z(p, o, 300),
|
|
991
|
-
Ie(p, r, {
|
|
992
|
-
country: n,
|
|
993
|
-
language: s
|
|
994
|
-
}),
|
|
995
|
-
_e({ language: s, dealBlockId: r.id })
|
|
996
|
-
]);
|
|
997
|
-
return {
|
|
998
|
-
product: y,
|
|
999
|
-
dealBlock: r,
|
|
1000
|
-
config: c,
|
|
1001
|
-
otherProducts: _,
|
|
1002
|
-
mediaImages: I,
|
|
1003
|
-
collectionBreaksProducts: m ?? [],
|
|
1004
|
-
translations: b
|
|
1005
|
-
};
|
|
1006
|
-
} catch (i) {
|
|
1007
|
-
return console.error(i), null;
|
|
1008
|
-
}
|
|
1009
|
-
};
|
|
1010
|
-
class we {
|
|
1011
|
-
constructor(t) {
|
|
1012
|
-
this.storefront = t, this.shopifyDomain = "";
|
|
1013
|
-
}
|
|
1014
|
-
async query(t, a) {
|
|
1015
|
-
var n;
|
|
1016
|
-
if ("query" in this.storefront && "i18n" in this.storefront)
|
|
1017
|
-
return await this.storefront.query(t, a);
|
|
1018
|
-
if ("graphql" in this.storefront) {
|
|
1019
|
-
const s = await this.storefront.graphql(t, a);
|
|
1020
|
-
if ((n = s.errors) != null && n.length)
|
|
1021
|
-
throw new Error(
|
|
1022
|
-
s.errors.map((l) => l.message).join(`
|
|
1023
|
-
`)
|
|
1024
|
-
);
|
|
1025
|
-
return s.data;
|
|
1026
|
-
}
|
|
1027
|
-
if ("request" in this.storefront)
|
|
1028
|
-
return (await this.storefront.request(t, a)).data;
|
|
1029
|
-
if ("shopifyDomain" in this.storefront && "storefrontAccessToken" in this.storefront) {
|
|
1030
|
-
const s = await fetch(
|
|
1031
|
-
`https://${this.storefront.shopifyDomain}/api/${$e}/graphql.json`,
|
|
1032
|
-
{
|
|
1033
|
-
body: JSON.stringify({
|
|
1034
|
-
query: t,
|
|
1035
|
-
variables: a == null ? void 0 : a.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 (!s.ok)
|
|
1045
|
-
throw new Error(s.statusText);
|
|
1046
|
-
return (await s.json()).data;
|
|
1047
|
-
} else {
|
|
1048
|
-
const s = await fetch(this.storefront.getStorefrontApiUrl(), {
|
|
1049
|
-
body: JSON.stringify({
|
|
1050
|
-
query: t,
|
|
1051
|
-
variables: a == null ? void 0 : a.variables
|
|
1052
|
-
}),
|
|
1053
|
-
headers: this.storefront.getPublicTokenHeaders(),
|
|
1054
|
-
method: "POST"
|
|
1055
|
-
});
|
|
1056
|
-
if (!s.ok)
|
|
1057
|
-
throw new Error(s.statusText);
|
|
1058
|
-
return (await s.json()).data;
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1061
|
-
get i18n() {
|
|
1062
|
-
if ("i18n" in this.storefront)
|
|
1063
|
-
return this.storefront.i18n;
|
|
1064
|
-
}
|
|
1065
|
-
}
|
|
1066
|
-
export {
|
|
1067
|
-
Se as fetchKachingBundlesData
|
|
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
|
+
...A(e),
|
|
500
|
+
...j(e),
|
|
501
|
+
...ee(e),
|
|
502
|
+
...M(e),
|
|
503
|
+
...N(e),
|
|
504
|
+
...P(e),
|
|
505
|
+
...F(e),
|
|
506
|
+
...I(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), A = (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
|
+
}, []) : [], j = (e) => {
|
|
511
|
+
if (!e.collectionBreaksEnabled || !e.collectionBreaks) return [];
|
|
512
|
+
let t = e.collectionBreaks.mediaImageGID;
|
|
513
|
+
return t ? [t] : [];
|
|
514
|
+
}, ee = (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) : [], M = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), N = (e) => e.dealBars.map((e) => e.productPersonalisation?.mediaImageGID).filter((e) => e != null), P = (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
|
+
}, F = (e) => (e.badges || []).flatMap((e) => e.badgeType === "custom" && e.imageGID ? [e.imageGID] : []), I = (e) => !e.savingsSummaryEnabled || !e.savingsSummary ? [] : e.savingsSummary.customIconGID ? [e.savingsSummary.customIconGID] : [], L = (e) => {
|
|
522
|
+
let t = [
|
|
523
|
+
...R(e),
|
|
524
|
+
...z(e),
|
|
525
|
+
...B(e),
|
|
526
|
+
...V(e),
|
|
527
|
+
...H(e),
|
|
528
|
+
...U(e),
|
|
529
|
+
...W(e),
|
|
530
|
+
...G(e)
|
|
531
|
+
];
|
|
532
|
+
return Array.from(new Set(t.filter((e) => e != null)));
|
|
533
|
+
}, R = (e) => e.dealBars.flatMap(({ freeGifts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), z = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => e ? e.flatMap((e) => e.products ? e.products.map((e) => e.id) : []) : []).filter((e) => e != null), B = (e) => e.progressiveGiftsEnabled && e.progressiveGifts?.gifts.map((e) => e.productGID).filter((e) => e != null) || [], V = (e) => e.dealBars.flatMap(({ upsells: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), H = (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"), U = (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"), W = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.map((e) => e.productGID).filter((e) => e != null), G = (e) => e.dealBars.filter((e) => e.dealBarType === d.Sku).flatMap(({ productGID: e }) => e ? [e] : []), K = 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
|
+
}, q = 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 K({
|
|
546
|
+
status: e.status,
|
|
547
|
+
operationName: t,
|
|
548
|
+
graphqlErrors: []
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
if (!e.ok || r.data === null || r.data === void 0) throw new K({
|
|
552
|
+
status: e.status,
|
|
553
|
+
operationName: t,
|
|
554
|
+
graphqlErrors: (r.errors ?? []).map(({ message: e }) => e).filter(Boolean)
|
|
555
|
+
});
|
|
556
|
+
return r.data;
|
|
557
|
+
}, J = 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}`), q(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
|
+
}, Y = (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
|
+
}, X = 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
|
+
}, Z = ({ 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 ? Q(e) : void 0;
|
|
638
|
+
return {
|
|
639
|
+
...n,
|
|
640
|
+
...r?.system,
|
|
641
|
+
...r?.dealBlocks[t]
|
|
642
|
+
};
|
|
643
|
+
}, Q = (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 = $(e);
|
|
654
|
+
return n.find((e) => $(e.locale) === r)?.translations;
|
|
655
|
+
}, $ = (e) => e.toLowerCase().replace(/_/g, "-"), te = "2026-07", ne = 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 re(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 J(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 = Y(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), _ = L(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
|
+
X(l, h, {
|
|
686
|
+
country: r,
|
|
687
|
+
language: i
|
|
688
|
+
}),
|
|
689
|
+
Z({
|
|
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
|
+
}, re = 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/${te}/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
|
+
}
|
|
1068
749
|
};
|
|
750
|
+
export { ne as fetchKachingBundlesData };
|