tanya-chatbot 0.3.6 → 0.3.7
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/tanya-chatbot.es.js
CHANGED
|
@@ -101,7 +101,7 @@ const st = () => ({ aiConversationUrl: "https://mdv3qwfi2j.execute-api.us-east-1
|
|
|
101
101
|
const t = "https://tanya-sfcc-server.vercel.app/";
|
|
102
102
|
try {
|
|
103
103
|
const e = await E.post(
|
|
104
|
-
`${t}api/auth/token-bm-grant?baseUrl=${Z()}&siteId=${
|
|
104
|
+
`${t}api/auth/token-bm-grant?baseUrl=${Z()}&siteId=${q()}`
|
|
105
105
|
);
|
|
106
106
|
return e.status === 200 && e.data.access_token ? e.data.access_token : (console.error("Failed to fetch token:", e.data), null);
|
|
107
107
|
} catch (e) {
|
|
@@ -111,7 +111,7 @@ const st = () => ({ aiConversationUrl: "https://mdv3qwfi2j.execute-api.us-east-1
|
|
|
111
111
|
const e = "https://tanya-sfcc-server.vercel.app/";
|
|
112
112
|
try {
|
|
113
113
|
const r = JSON.parse(sessionStorage.getItem("customerData") || "{}").dwsid, o = await E.post(
|
|
114
|
-
`${e}api/auth/token-existing-guest-customer?dwsid=${r}&baseUrl=${Z()}&siteId=${
|
|
114
|
+
`${e}api/auth/token-existing-guest-customer?dwsid=${r}&baseUrl=${Z()}&siteId=${q()}&pubCfg=${tt()}&envRef=${et()}&orgRef=${rt()}`,
|
|
115
115
|
{},
|
|
116
116
|
{
|
|
117
117
|
headers: {
|
|
@@ -126,31 +126,36 @@ const st = () => ({ aiConversationUrl: "https://mdv3qwfi2j.execute-api.us-east-1
|
|
|
126
126
|
}
|
|
127
127
|
};
|
|
128
128
|
async function Ot() {
|
|
129
|
-
var
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
129
|
+
var i;
|
|
130
|
+
const e = "access_token_" + q(), r = localStorage.getItem("expires_in"), o = localStorage.getItem(e);
|
|
131
|
+
console.log(o);
|
|
132
|
+
const n = ((i = JSON.parse(sessionStorage.getItem("customerData") || "{}")) == null ? void 0 : i.isGuest) || !0;
|
|
133
|
+
if (
|
|
134
|
+
// expires_in &&
|
|
135
|
+
o
|
|
136
|
+
)
|
|
137
|
+
return console.log("access token found in local storage"), { access_token: o, expires_in: r };
|
|
138
|
+
const { serverUrl: l } = st(), s = JSON.parse(
|
|
134
139
|
sessionStorage.getItem("customerData") || "{}"
|
|
135
|
-
).dwsid,
|
|
140
|
+
).dwsid, d = JSON.parse(
|
|
136
141
|
sessionStorage.getItem("customerData") || "{}"
|
|
137
142
|
).usrRef;
|
|
138
143
|
try {
|
|
139
|
-
const
|
|
140
|
-
`${
|
|
144
|
+
const g = n ? "unregister-auth" : "register-auth", w = await E.get(
|
|
145
|
+
`${l}sc-api/${g}?dwsid=${s}&email=${d}&pubCfg=${tt()}&envRef=${et()}&orgRef=${rt()}&siteId=${q()}&token=true`,
|
|
141
146
|
{
|
|
142
147
|
withCredentials: !0
|
|
143
148
|
}
|
|
144
149
|
);
|
|
145
|
-
return localStorage.setItem(
|
|
150
|
+
return localStorage.setItem(e, w.data.access_token), localStorage.setItem(
|
|
146
151
|
"expires_in",
|
|
147
|
-
String((/* @__PURE__ */ new Date()).getTime() +
|
|
148
|
-
), localStorage.setItem("isGuest",
|
|
149
|
-
} catch (
|
|
150
|
-
console.log(
|
|
152
|
+
String((/* @__PURE__ */ new Date()).getTime() + w.data.expires_in * 1e3)
|
|
153
|
+
), localStorage.setItem("isGuest", n ? "true" : "false"), w.data;
|
|
154
|
+
} catch (g) {
|
|
155
|
+
console.log(g);
|
|
151
156
|
}
|
|
152
157
|
}
|
|
153
|
-
const Z = () => sessionStorage.getItem("Host"),
|
|
158
|
+
const Z = () => sessionStorage.getItem("Host"), q = () => sessionStorage.getItem("SiteId"), tt = () => sessionStorage.getItem("pubCfg"), et = () => sessionStorage.getItem("envRef"), rt = () => sessionStorage.getItem("orgRef"), be = async (t) => {
|
|
154
159
|
console.log("fetching results");
|
|
155
160
|
const { serverUrl: e, basePath: r } = st();
|
|
156
161
|
let o = "";
|
|
@@ -161,7 +166,7 @@ const Z = () => sessionStorage.getItem("Host"), R = () => sessionStorage.getItem
|
|
|
161
166
|
try {
|
|
162
167
|
const n = Z();
|
|
163
168
|
return (await E.get(
|
|
164
|
-
`${e}${r}/search-sfcc?baseUrl=${n}&query=${t}&siteId=${
|
|
169
|
+
`${e}${r}/search-sfcc?baseUrl=${n}&query=${t}&siteId=${q()}&pubCfg=${tt()}&envRef=${et()}&orgRef=${rt()}`,
|
|
165
170
|
{
|
|
166
171
|
headers: {
|
|
167
172
|
"Content-Type": "application/json",
|
|
@@ -178,7 +183,7 @@ const Z = () => sessionStorage.getItem("Host"), R = () => sessionStorage.getItem
|
|
|
178
183
|
console.log("calling access");
|
|
179
184
|
const { access_token: n } = await Ot();
|
|
180
185
|
return console.log(n), (await E.get(
|
|
181
|
-
`${e}${r}/product-sfcc/${t}?baseUrl=${o}&siteId=${
|
|
186
|
+
`${e}${r}/product-sfcc/${t}?baseUrl=${o}&siteId=${q()}&pubCfg=${tt()}&envRef=${et()}&orgRef=${rt()}`,
|
|
182
187
|
{
|
|
183
188
|
headers: {
|
|
184
189
|
"Content-Type": "application/json",
|
|
@@ -192,7 +197,7 @@ const Z = () => sessionStorage.getItem("Host"), R = () => sessionStorage.getItem
|
|
|
192
197
|
e
|
|
193
198
|
), { serverUrl: o, basePath: n } = st(), s = (await Ot()).access_token;
|
|
194
199
|
return (await E.get(
|
|
195
|
-
`${o}${n}/get-interest?baseUrl=${Z()}&customerId=${t}&siteId=${
|
|
200
|
+
`${o}${n}/get-interest?baseUrl=${Z()}&customerId=${t}&siteId=${q()}&pubCfg=${tt()}&envRef=${et()}&orgRef=${rt()}`,
|
|
196
201
|
{
|
|
197
202
|
headers: {
|
|
198
203
|
"Content-Type": "application/json",
|
|
@@ -235,8 +240,8 @@ const _r = ({
|
|
|
235
240
|
(i) => i - r < 0 ? t.length - (t.length % r || r) : i - r
|
|
236
241
|
);
|
|
237
242
|
}, d = async (i) => {
|
|
238
|
-
const
|
|
239
|
-
e(oe(
|
|
243
|
+
const g = await He(i);
|
|
244
|
+
e(oe(g));
|
|
240
245
|
};
|
|
241
246
|
return /* @__PURE__ */ a("div", { className: "mt-2 overflow-x-hidden", children: /* @__PURE__ */ u("div", { className: "flex items-center justify-center gap-4 relative", children: [
|
|
242
247
|
(t == null ? void 0 : t.length) > r && /* @__PURE__ */ a(
|
|
@@ -253,7 +258,7 @@ const _r = ({
|
|
|
253
258
|
}
|
|
254
259
|
),
|
|
255
260
|
/* @__PURE__ */ a("div", { className: "flex gap-5 justify-center flex-1 overflow-hidden", children: t.slice(o, o + r).map((i) => {
|
|
256
|
-
var
|
|
261
|
+
var g, w, C, S;
|
|
257
262
|
return /* @__PURE__ */ u(
|
|
258
263
|
"div",
|
|
259
264
|
{
|
|
@@ -265,7 +270,7 @@ const _r = ({
|
|
|
265
270
|
/* @__PURE__ */ a("div", { className: "w-full p-2 flex items-center justify-center bg-white", children: /* @__PURE__ */ a(
|
|
266
271
|
"img",
|
|
267
272
|
{
|
|
268
|
-
src: ((
|
|
273
|
+
src: ((g = ye(i)[0]) == null ? void 0 : g.link) || ye(i)[0] || // fallback if it's a string
|
|
269
274
|
"https://via.placeholder.com/120",
|
|
270
275
|
alt: i != null && i.productName ? i.productName : "Product",
|
|
271
276
|
className: "w-28 h-28 rounded-[10px] transition-transform duration-300 hover:scale-125 object-cover"
|
|
@@ -278,7 +283,7 @@ const _r = ({
|
|
|
278
283
|
children: [
|
|
279
284
|
/* @__PURE__ */ u("div", { className: "relative inline-block group", children: [
|
|
280
285
|
/* @__PURE__ */ a("div", { className: "w-full line-clamp-1 overflow-hidden text-ellipsis text-[#000000] font-medium font-nunitoSans", children: i != null && i.productName ? i.productName : i != null && i.product_name ? i.product_name : ke(
|
|
281
|
-
xe((
|
|
286
|
+
xe((w = i == null ? void 0 : i.name) == null ? void 0 : w["en-US"]),
|
|
282
287
|
60
|
|
283
288
|
) || "Product" }),
|
|
284
289
|
/* @__PURE__ */ a(
|
|
@@ -363,7 +368,7 @@ const _r = ({
|
|
|
363
368
|
`, t);
|
|
364
369
|
try {
|
|
365
370
|
return (await E.post(
|
|
366
|
-
`${n}${o}/basket/create?baseUrl=${Z()}&siteId=${
|
|
371
|
+
`${n}${o}/basket/create?baseUrl=${Z()}&siteId=${q()}&pubCfg=${tt()}&envRef=${et()}&orgRef=${rt()}`,
|
|
367
372
|
e,
|
|
368
373
|
{
|
|
369
374
|
headers: {
|
|
@@ -379,7 +384,7 @@ const _r = ({
|
|
|
379
384
|
const { serverUrl: o, basePath: n } = st(), l = `${o}`;
|
|
380
385
|
try {
|
|
381
386
|
const s = await E.post(
|
|
382
|
-
`${l}${n}/basket/add-product/${t}?baseUrl=${Z()}&siteId=${
|
|
387
|
+
`${l}${n}/basket/add-product/${t}?baseUrl=${Z()}&siteId=${q()}&pubCfg=${tt()}&envRef=${et()}&orgRef=${rt()}`,
|
|
383
388
|
e,
|
|
384
389
|
{
|
|
385
390
|
headers: {
|
|
@@ -403,7 +408,7 @@ const _r = ({
|
|
|
403
408
|
const { serverUrl: r, basePath: o } = st(), n = `${r}`;
|
|
404
409
|
try {
|
|
405
410
|
const s = await E.get(
|
|
406
|
-
`${n}${o}/basket/${t}?baseUrl=${Z()}&siteId=${
|
|
411
|
+
`${n}${o}/basket/${t}?baseUrl=${Z()}&siteId=${q()}&pubCfg=${tt()}&envRef=${et()}&orgRef=${rt()}`,
|
|
407
412
|
{
|
|
408
413
|
headers: {
|
|
409
414
|
"Content-Type": "application/json",
|
|
@@ -434,16 +439,16 @@ const xt = (t) => {
|
|
|
434
439
|
console.error("Error storing token:", e);
|
|
435
440
|
}
|
|
436
441
|
}, Ce = 300, Nr = () => {
|
|
437
|
-
var d, i,
|
|
442
|
+
var d, i, g, w, C, S;
|
|
438
443
|
const t = Ae(), e = Mt((_) => _.product.product), r = Mt((_) => _.store.store), [o, n] = P(!!e);
|
|
439
444
|
if (bt(() => {
|
|
440
445
|
n(!!e);
|
|
441
446
|
}, [e]), !e) return null;
|
|
442
447
|
const l = async () => {
|
|
443
|
-
var _, j,
|
|
448
|
+
var _, j, M, H, lt, vt, Pt, ot, kt, St, ct, $t, zt, Ct, O, dt;
|
|
444
449
|
console.log(e, "the prod");
|
|
445
450
|
try {
|
|
446
|
-
if (!((j = (_ = e == null ? void 0 : e.variants) == null ? void 0 : _[0]) != null && j.product_id) && !(e.type.item || e.type.bundle) && !((
|
|
451
|
+
if (!((j = (_ = e == null ? void 0 : e.variants) == null ? void 0 : _[0]) != null && j.product_id) && !(e.type.item || e.type.bundle) && !((H = (M = e == null ? void 0 : e.variants) == null ? void 0 : M[0]) != null && H.productId)) {
|
|
447
452
|
U.error("Variants not available", {
|
|
448
453
|
position: "bottom-right",
|
|
449
454
|
autoClose: 1e3
|
|
@@ -459,12 +464,12 @@ const xt = (t) => {
|
|
|
459
464
|
console.log(p, "the product data");
|
|
460
465
|
const _t = JSON.parse(
|
|
461
466
|
sessionStorage.getItem("customerData") || "{}"
|
|
462
|
-
), nt = (_t == null ? void 0 : _t.basketId) || localStorage.getItem(Rt),
|
|
463
|
-
if (!
|
|
467
|
+
), nt = (_t == null ? void 0 : _t.basketId) || localStorage.getItem(Rt), Jt = !1, jt = localStorage.getItem(Tt), Y = Date.now();
|
|
468
|
+
if (!Jt || !jt || Y >= parseInt(jt)) {
|
|
464
469
|
let $ = "";
|
|
465
470
|
{
|
|
466
|
-
const
|
|
467
|
-
console.log("token from auth data"), $ = "Bearer " +
|
|
471
|
+
const J = await Ot();
|
|
472
|
+
console.log("token from auth data"), $ = "Bearer " + J.access_token;
|
|
468
473
|
}
|
|
469
474
|
if (!$) {
|
|
470
475
|
console.error("Failed to get customer_token");
|
|
@@ -472,17 +477,17 @@ const xt = (t) => {
|
|
|
472
477
|
}
|
|
473
478
|
const At = Y + 300 * 1e3;
|
|
474
479
|
if (Yt($), localStorage.setItem(Tt, At.toString()), nt) {
|
|
475
|
-
const
|
|
480
|
+
const J = await Re({
|
|
476
481
|
basketId: nt,
|
|
477
482
|
customer_token: $
|
|
478
483
|
});
|
|
479
|
-
if (console.log(nt, "basket id from customer"),
|
|
480
|
-
const
|
|
484
|
+
if (console.log(nt, "basket id from customer"), J.status === 200 && J) {
|
|
485
|
+
const W = await Vt(
|
|
481
486
|
nt,
|
|
482
487
|
p,
|
|
483
488
|
$
|
|
484
489
|
);
|
|
485
|
-
(((Pt =
|
|
490
|
+
(((Pt = W == null ? void 0 : W.product_items) == null ? void 0 : Pt.length) > 0 || ((ot = W == null ? void 0 : W.productItems) == null ? void 0 : ot.length) > 0) && (U.success("Added to cart", {
|
|
486
491
|
position: "bottom-right",
|
|
487
492
|
autoClose: 3e3,
|
|
488
493
|
hideProgressBar: !1,
|
|
@@ -493,7 +498,7 @@ const xt = (t) => {
|
|
|
493
498
|
return;
|
|
494
499
|
}
|
|
495
500
|
}
|
|
496
|
-
const
|
|
501
|
+
const Wt = {
|
|
497
502
|
productItems: [
|
|
498
503
|
{
|
|
499
504
|
productId: ((kt = e.variants) == null ? void 0 : kt[0].product_id) || ((St = e.variants) == null ? void 0 : St[0].productId) || (e == null ? void 0 : e.id),
|
|
@@ -502,7 +507,7 @@ const xt = (t) => {
|
|
|
502
507
|
]
|
|
503
508
|
};
|
|
504
509
|
console.log("before create basket");
|
|
505
|
-
const h = await Ve($,
|
|
510
|
+
const h = await Ve($, Wt);
|
|
506
511
|
if (console.log(
|
|
507
512
|
h,
|
|
508
513
|
h == null ? void 0 : h.basket_id,
|
|
@@ -518,12 +523,12 @@ const xt = (t) => {
|
|
|
518
523
|
), xt(
|
|
519
524
|
(h == null ? void 0 : h.basket_id) || (h == null ? void 0 : h.basketId)
|
|
520
525
|
), console.log("adding product to basket");
|
|
521
|
-
const
|
|
526
|
+
const K = await Vt(
|
|
522
527
|
(h == null ? void 0 : h.basket_id) || (h == null ? void 0 : h.basketId),
|
|
523
528
|
p,
|
|
524
529
|
$
|
|
525
530
|
);
|
|
526
|
-
console.log("object added to basket"), (((ct =
|
|
531
|
+
console.log("object added to basket"), (((ct = K == null ? void 0 : K.product_items) == null ? void 0 : ct.length) > 0 || (($t = K == null ? void 0 : K.productItems) == null ? void 0 : $t.length) > 0) && U.success("Added to cart", {
|
|
527
532
|
position: "bottom-right",
|
|
528
533
|
autoClose: 3e3,
|
|
529
534
|
hideProgressBar: !1,
|
|
@@ -586,7 +591,7 @@ const xt = (t) => {
|
|
|
586
591
|
/* @__PURE__ */ a("div", { className: "flex flex-row items-center justify-center w-[120px] h-[120px] my-5", children: /* @__PURE__ */ a(
|
|
587
592
|
"img",
|
|
588
593
|
{
|
|
589
|
-
src: (
|
|
594
|
+
src: (w = (g = (i = (d = e.imageGroups) == null ? void 0 : d[0]) == null ? void 0 : i.images) == null ? void 0 : g[0]) == null ? void 0 : w.link,
|
|
590
595
|
alt: e.name,
|
|
591
596
|
className: "rounded-[10px]"
|
|
592
597
|
}
|
|
@@ -647,7 +652,7 @@ const xt = (t) => {
|
|
|
647
652
|
] })
|
|
648
653
|
] }) }),
|
|
649
654
|
/* @__PURE__ */ a("div", { className: "mt-2 flex flex-row items-center gap-2", children: Array.from({ length: 5 }).map((_, j) => {
|
|
650
|
-
var
|
|
655
|
+
var M;
|
|
651
656
|
return /* @__PURE__ */ a(
|
|
652
657
|
ge,
|
|
653
658
|
{
|
|
@@ -655,7 +660,7 @@ const xt = (t) => {
|
|
|
655
660
|
width: "20",
|
|
656
661
|
height: "20",
|
|
657
662
|
className: `text-yellow-500
|
|
658
|
-
${((
|
|
663
|
+
${((M = e == null ? void 0 : e.rating) == null ? void 0 : M.rate) > j ? "text-yellow-500" : "text-gray-300"}
|
|
659
664
|
`
|
|
660
665
|
},
|
|
661
666
|
j
|
|
@@ -710,19 +715,19 @@ const xt = (t) => {
|
|
|
710
715
|
"Niece/Nephew": "his/her niece/nephew",
|
|
711
716
|
"My Friends": "his/her friends",
|
|
712
717
|
Others: "others"
|
|
713
|
-
}, o = It(null), n = It(null), l = It(null), s = It(null), [d, i] = P(null), [
|
|
718
|
+
}, o = It(null), n = It(null), l = It(null), s = It(null), [d, i] = P(null), [g, w] = P(!1), [C, S] = P(!1), [_, j] = P(!1), [M, H] = P(!1), [lt, vt] = P(!1), [Pt, ot] = P(!1), [kt, St] = P(""), [ct, $t] = P(""), zt = (c) => ({
|
|
714
719
|
id: c.id,
|
|
715
720
|
title: c.name,
|
|
716
721
|
image: c.image ?? "",
|
|
717
722
|
price: c.price ?? 0
|
|
718
723
|
}), [Ct, O] = P([]), dt = It(null), p = Mt((c) => c.store.store), _t = Mt((c) => c.product.product), nt = () => {
|
|
719
724
|
j(!0), setTimeout(() => S(!0), 10);
|
|
720
|
-
},
|
|
725
|
+
}, Jt = () => {
|
|
721
726
|
S(!1), setTimeout(() => j(!1), 300);
|
|
722
727
|
};
|
|
723
728
|
bt(() => {
|
|
724
|
-
|
|
725
|
-
}, [
|
|
729
|
+
g ? nt() : Jt();
|
|
730
|
+
}, [g]);
|
|
726
731
|
const jt = (c) => {
|
|
727
732
|
$t(r[c]);
|
|
728
733
|
};
|
|
@@ -739,54 +744,54 @@ const xt = (t) => {
|
|
|
739
744
|
client_id: "4i8rd70sgt961tc4dhskgf08c",
|
|
740
745
|
client_secret: "bnsfq1220loh2cn2cm2ttn8fdhdpt0u8m1fgj8vfk2rn61aurjg",
|
|
741
746
|
scope: "default-m2m-resource-server-8xzfzo/read"
|
|
742
|
-
}),
|
|
747
|
+
}), b = await fetch(c, {
|
|
743
748
|
method: "POST",
|
|
744
749
|
headers: {
|
|
745
750
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
746
751
|
},
|
|
747
752
|
body: k
|
|
748
753
|
});
|
|
749
|
-
if (!
|
|
754
|
+
if (!b.ok)
|
|
750
755
|
throw new Error(
|
|
751
|
-
`Token request failed! status: ${
|
|
756
|
+
`Token request failed! status: ${b.status}`
|
|
752
757
|
);
|
|
753
|
-
const y = await
|
|
758
|
+
const y = await b.json();
|
|
754
759
|
Y = y.access_token;
|
|
755
760
|
const f = y.expires_in || 3600;
|
|
756
761
|
return $ = Date.now() + (f - 60) * 1e3, Y;
|
|
757
762
|
} catch (c) {
|
|
758
763
|
return console.error("Error obtaining JWT token:", c), Y = null, $ = null, null;
|
|
759
764
|
}
|
|
760
|
-
},
|
|
765
|
+
}, Wt = async () => {
|
|
761
766
|
const c = await Ot();
|
|
762
767
|
c != null && i(c);
|
|
763
768
|
};
|
|
764
769
|
bt(() => {
|
|
765
770
|
if (t != null && t.siteId) {
|
|
766
|
-
const { clientID: c, host: k, organizationID:
|
|
767
|
-
sessionStorage.setItem("Host", k), sessionStorage.setItem("SiteId", f), sessionStorage.setItem("pubCfg", btoa(c)), sessionStorage.setItem("envRef", y), sessionStorage.setItem("orgRef",
|
|
771
|
+
const { clientID: c, host: k, organizationID: b, shortCode: y, siteId: f } = t;
|
|
772
|
+
sessionStorage.setItem("Host", k), sessionStorage.setItem("SiteId", f), sessionStorage.setItem("pubCfg", btoa(c)), sessionStorage.setItem("envRef", y), sessionStorage.setItem("orgRef", b);
|
|
768
773
|
}
|
|
769
|
-
|
|
774
|
+
Wt(), console.log("scapi environment v1");
|
|
770
775
|
}, []);
|
|
771
776
|
const h = async () => {
|
|
772
777
|
const c = JSON.parse(
|
|
773
778
|
sessionStorage.getItem("customerData") || "{}"
|
|
774
779
|
).customerId;
|
|
775
780
|
return (await vr(c || "")).c_interests;
|
|
776
|
-
},
|
|
781
|
+
}, K = async (c, k) => {
|
|
777
782
|
console.log("in secondary flow", Ft);
|
|
778
|
-
const
|
|
779
|
-
if (console.log(
|
|
783
|
+
const b = await h();
|
|
784
|
+
if (console.log(b, "interests of customer", Ft), !!b)
|
|
780
785
|
try {
|
|
781
786
|
O(
|
|
782
787
|
(L) => L.map(
|
|
783
|
-
(
|
|
788
|
+
(V, R) => R === L.length - 1 ? { ...V, secondaryLoading: !0 } : V
|
|
784
789
|
)
|
|
785
790
|
);
|
|
786
791
|
const y = await At();
|
|
787
792
|
if (!y) throw new Error("Failed to fetch token");
|
|
788
|
-
const f = localStorage.getItem("customerNumber"),
|
|
789
|
-
registered: String(
|
|
793
|
+
const f = localStorage.getItem("customerNumber"), x = localStorage.getItem("isLoggedIn"), ut = `https://tanya.aspiresystems.com/api/bedrock/invoke/stream?${new URLSearchParams({
|
|
794
|
+
registered: String(x || !1),
|
|
790
795
|
userId: String(f || (/* @__PURE__ */ new Date()).getTime())
|
|
791
796
|
}).toString()}`, pt = JSON.stringify({
|
|
792
797
|
flowId: "Q166PR519W",
|
|
@@ -795,7 +800,7 @@ const xt = (t) => {
|
|
|
795
800
|
loyaltyPoints: "",
|
|
796
801
|
productName: c,
|
|
797
802
|
productPoints: String(k || 0),
|
|
798
|
-
interests:
|
|
803
|
+
interests: b
|
|
799
804
|
}
|
|
800
805
|
}), A = await fetch(ut, {
|
|
801
806
|
signal: AbortSignal.timeout(3e4),
|
|
@@ -810,15 +815,15 @@ const xt = (t) => {
|
|
|
810
815
|
const ft = A.body.getReader(), mt = new TextDecoder();
|
|
811
816
|
let D = "";
|
|
812
817
|
for (; ; ) {
|
|
813
|
-
const { done: L, value:
|
|
818
|
+
const { done: L, value: V } = await ft.read();
|
|
814
819
|
if (L) break;
|
|
815
|
-
D += mt.decode(
|
|
816
|
-
const
|
|
820
|
+
D += mt.decode(V, { stream: !0 });
|
|
821
|
+
const R = D.split(`
|
|
817
822
|
`);
|
|
818
|
-
D =
|
|
819
|
-
for (const
|
|
820
|
-
if (
|
|
821
|
-
const m =
|
|
823
|
+
D = R.pop() || "";
|
|
824
|
+
for (const G of R)
|
|
825
|
+
if (G.startsWith("data:")) {
|
|
826
|
+
const m = G.slice(5).trim();
|
|
822
827
|
try {
|
|
823
828
|
const B = JSON.parse(m);
|
|
824
829
|
B.index === 0 && O(
|
|
@@ -842,11 +847,11 @@ const xt = (t) => {
|
|
|
842
847
|
} catch (y) {
|
|
843
848
|
console.error("Secondary flow error:", y);
|
|
844
849
|
}
|
|
845
|
-
},
|
|
850
|
+
}, J = async (c) => {
|
|
846
851
|
const k = c || kt.trim();
|
|
847
852
|
if (k) {
|
|
848
|
-
vt(!0), St(""), o.current = null, n.current = null, l.current = null, s.current = null, O((
|
|
849
|
-
...
|
|
853
|
+
vt(!0), St(""), o.current = null, n.current = null, l.current = null, s.current = null, O((b) => [
|
|
854
|
+
...b,
|
|
850
855
|
{
|
|
851
856
|
query: k,
|
|
852
857
|
response: "Thinking for what suits you best...",
|
|
@@ -856,8 +861,8 @@ const xt = (t) => {
|
|
|
856
861
|
}
|
|
857
862
|
]);
|
|
858
863
|
try {
|
|
859
|
-
const
|
|
860
|
-
if (!
|
|
864
|
+
const b = ct, y = localStorage.getItem("customerNumber"), f = localStorage.getItem("isLoggedIn"), x = await At();
|
|
865
|
+
if (!x)
|
|
861
866
|
throw new Error("Failed to obtain access token");
|
|
862
867
|
const ut = `https://tanya.aspiresystems.com/api/bedrock/invoke/stream?${new URLSearchParams({
|
|
863
868
|
registered: String(f || !1),
|
|
@@ -867,14 +872,14 @@ const xt = (t) => {
|
|
|
867
872
|
flowAliasId: "SZF9ZK1ATE",
|
|
868
873
|
input: {
|
|
869
874
|
userPrompt: k,
|
|
870
|
-
whom:
|
|
875
|
+
whom: b
|
|
871
876
|
}
|
|
872
877
|
}), A = await fetch(ut, {
|
|
873
878
|
signal: AbortSignal.timeout(3e4),
|
|
874
879
|
method: "POST",
|
|
875
880
|
headers: {
|
|
876
881
|
"Content-Type": "application/json",
|
|
877
|
-
Authorization: `Bearer ${
|
|
882
|
+
Authorization: `Bearer ${x}`
|
|
878
883
|
},
|
|
879
884
|
body: pt
|
|
880
885
|
});
|
|
@@ -885,13 +890,13 @@ const xt = (t) => {
|
|
|
885
890
|
let D = "", L = "";
|
|
886
891
|
for (; ; ) {
|
|
887
892
|
ot(!0);
|
|
888
|
-
const { done:
|
|
889
|
-
if (
|
|
890
|
-
D += mt.decode(
|
|
891
|
-
const
|
|
893
|
+
const { done: V, value: R } = await ft.read();
|
|
894
|
+
if (V) break;
|
|
895
|
+
D += mt.decode(R, { stream: !0 });
|
|
896
|
+
const G = D.split(`
|
|
892
897
|
`);
|
|
893
|
-
D =
|
|
894
|
-
for (const m of
|
|
898
|
+
D = G.pop() || "";
|
|
899
|
+
for (const m of G)
|
|
895
900
|
if (m.startsWith("data:")) {
|
|
896
901
|
const B = m.slice(5).trim();
|
|
897
902
|
try {
|
|
@@ -909,14 +914,14 @@ const xt = (t) => {
|
|
|
909
914
|
}
|
|
910
915
|
}
|
|
911
916
|
}
|
|
912
|
-
er(
|
|
913
|
-
} catch (
|
|
914
|
-
console.error("Error sending message to Tanya:",
|
|
917
|
+
er(W(L));
|
|
918
|
+
} catch (b) {
|
|
919
|
+
console.error("Error sending message to Tanya:", b);
|
|
915
920
|
} finally {
|
|
916
921
|
vt(!1);
|
|
917
922
|
}
|
|
918
923
|
}
|
|
919
|
-
},
|
|
924
|
+
}, W = (c) => {
|
|
920
925
|
const k = c.match(
|
|
921
926
|
/top five relevant product or category names are: (.*)/i
|
|
922
927
|
), f = (k ? k[1] : c).split(", ").map((z) => z.replace(/\s*(Toys|Bags|Miniature|etc\.*)\s*/gi, "").trim());
|
|
@@ -925,35 +930,35 @@ const xt = (t) => {
|
|
|
925
930
|
if (typeof c == "string") {
|
|
926
931
|
console.log(c, "keywords");
|
|
927
932
|
const k = c.split(",");
|
|
928
|
-
for (const
|
|
929
|
-
const y = await be(
|
|
933
|
+
for (const b of k) {
|
|
934
|
+
const y = await be(b);
|
|
930
935
|
if (ot(!1), (y == null ? void 0 : y.length) > 0 && (O(
|
|
931
936
|
(f) => f.map(
|
|
932
|
-
(
|
|
933
|
-
...
|
|
937
|
+
(x, z) => z === f.length - 1 ? {
|
|
938
|
+
...x,
|
|
934
939
|
products: [
|
|
935
|
-
...
|
|
936
|
-
{ keyword:
|
|
940
|
+
...x.products || [],
|
|
941
|
+
{ keyword: b, items: y, loading: !1 }
|
|
937
942
|
]
|
|
938
|
-
} :
|
|
943
|
+
} : x
|
|
939
944
|
)
|
|
940
945
|
), !o.current || n.current == null)) {
|
|
941
946
|
const f = y[0];
|
|
942
947
|
o.current = String((f == null ? void 0 : f.product_name) ?? ""), l.current = f.image.link, n.current = f.product_id;
|
|
943
|
-
const
|
|
944
|
-
s.current = typeof
|
|
948
|
+
const x = typeof (f == null ? void 0 : f.price) == "number" ? f.price : void 0;
|
|
949
|
+
s.current = typeof x == "number" && Number.isFinite(x) ? x : null;
|
|
945
950
|
}
|
|
946
951
|
}
|
|
947
952
|
} else
|
|
948
953
|
for (const k of c) {
|
|
949
|
-
const
|
|
950
|
-
ot(!1), (
|
|
954
|
+
const b = await be(k);
|
|
955
|
+
ot(!1), (b == null ? void 0 : b.length) > 0 && O(
|
|
951
956
|
(y) => y.map(
|
|
952
|
-
(f,
|
|
957
|
+
(f, x) => x === y.length - 1 ? {
|
|
953
958
|
...f,
|
|
954
959
|
products: [
|
|
955
960
|
...f.products || [],
|
|
956
|
-
{ keyword: k, items:
|
|
961
|
+
{ keyword: k, items: b, loading: !1 }
|
|
957
962
|
]
|
|
958
963
|
} : f
|
|
959
964
|
)
|
|
@@ -961,8 +966,8 @@ const xt = (t) => {
|
|
|
961
966
|
}
|
|
962
967
|
if (o.current) {
|
|
963
968
|
O(
|
|
964
|
-
(
|
|
965
|
-
(y, f) => f ===
|
|
969
|
+
(b) => b.map(
|
|
970
|
+
(y, f) => f === b.length - 1 ? {
|
|
966
971
|
...y,
|
|
967
972
|
productSnapshot: {
|
|
968
973
|
id: n.current,
|
|
@@ -978,16 +983,16 @@ const xt = (t) => {
|
|
|
978
983
|
const k = JSON.parse(
|
|
979
984
|
sessionStorage.getItem("customerData") || "{}"
|
|
980
985
|
);
|
|
981
|
-
(k == null ? void 0 : k.isGuest) == !1 ? (console.log("running secondary flow", Ft),
|
|
986
|
+
(k == null ? void 0 : k.isGuest) == !1 ? (console.log("running secondary flow", Ft), K(o.current, 0)) : console.log("not running secondary flow", Ft);
|
|
982
987
|
}
|
|
983
988
|
ot(!1);
|
|
984
989
|
}, rr = async (c, k) => {
|
|
985
|
-
var
|
|
986
|
-
|
|
990
|
+
var b, y, f, x, z, ut, pt, A, ft, mt, D, L, V, R, G;
|
|
991
|
+
H(!0);
|
|
987
992
|
try {
|
|
988
993
|
const m = await He(c.id);
|
|
989
|
-
if (!((y = (
|
|
990
|
-
|
|
994
|
+
if (!((y = (b = m == null ? void 0 : m.variants) == null ? void 0 : b[0]) != null && y.product_id || (x = (f = m == null ? void 0 : m.variants) == null ? void 0 : f[0]) != null && x.productId) && !(m.type.item || m.type.bundle)) {
|
|
995
|
+
H(!1), U.error("Variants not found", {
|
|
991
996
|
position: "bottom-right",
|
|
992
997
|
autoClose: 1e3
|
|
993
998
|
}), console.error("No product variant found");
|
|
@@ -1019,19 +1024,19 @@ const xt = (t) => {
|
|
|
1019
1024
|
customer_token: at
|
|
1020
1025
|
});
|
|
1021
1026
|
if (we.status === 200 && we) {
|
|
1022
|
-
const
|
|
1027
|
+
const Gt = await Vt(
|
|
1023
1028
|
T,
|
|
1024
1029
|
B,
|
|
1025
1030
|
at
|
|
1026
1031
|
);
|
|
1027
|
-
((pt =
|
|
1032
|
+
((pt = Gt == null ? void 0 : Gt.product_items) == null ? void 0 : pt.length) > 0 && (U.success("Added to cart", {
|
|
1028
1033
|
position: "bottom-right",
|
|
1029
1034
|
autoClose: 3e3,
|
|
1030
1035
|
hideProgressBar: !1,
|
|
1031
1036
|
closeOnClick: !0,
|
|
1032
1037
|
pauseOnHover: !0,
|
|
1033
1038
|
draggable: !0
|
|
1034
|
-
}), Ht(T),
|
|
1039
|
+
}), Ht(T), H(!1));
|
|
1035
1040
|
return;
|
|
1036
1041
|
}
|
|
1037
1042
|
}
|
|
@@ -1049,7 +1054,7 @@ const xt = (t) => {
|
|
|
1049
1054
|
v == null ? void 0 : v.basketId,
|
|
1050
1055
|
"the basket response"
|
|
1051
1056
|
), !(v != null && v.basket_id || !(v != null && v.basketId))) {
|
|
1052
|
-
|
|
1057
|
+
H(!1), console.error("Failed to create basket");
|
|
1053
1058
|
return;
|
|
1054
1059
|
}
|
|
1055
1060
|
xt(
|
|
@@ -1070,22 +1075,22 @@ const xt = (t) => {
|
|
|
1070
1075
|
}), Ht(v.basket_id || (v == null ? void 0 : v.basketId));
|
|
1071
1076
|
}
|
|
1072
1077
|
} catch (m) {
|
|
1073
|
-
|
|
1078
|
+
H(!1), console.error("Error adding to cart:", m), U.error("Failed to add product to cart", {
|
|
1074
1079
|
position: "bottom-right",
|
|
1075
1080
|
autoClose: 3e3
|
|
1076
1081
|
}), ((L = m == null ? void 0 : m.response) == null ? void 0 : L.status) === 404 || // Basket not found
|
|
1077
|
-
((
|
|
1082
|
+
((V = m == null ? void 0 : m.response) == null ? void 0 : V.status) === 401 ? (((R = m == null ? void 0 : m.response) == null ? void 0 : R.status) === 404 && xt(null), ((G = m == null ? void 0 : m.response) == null ? void 0 : G.status) === 401 && (xt(null), Yt(null))) : (console.error("Failed to add product to basket:", m.message), U.error("Failed to add product to cart", {
|
|
1078
1083
|
position: "bottom-right",
|
|
1079
1084
|
autoClose: 3e3
|
|
1080
1085
|
}));
|
|
1081
1086
|
}
|
|
1082
|
-
|
|
1087
|
+
H(!1);
|
|
1083
1088
|
};
|
|
1084
|
-
return /* @__PURE__ */ a("div", { className: "relative flex justify-center", children: /* @__PURE__ */ u(xr, { open:
|
|
1089
|
+
return /* @__PURE__ */ a("div", { className: "relative flex justify-center", children: /* @__PURE__ */ u(xr, { open: g, onOpenChange: w, children: [
|
|
1085
1090
|
/* @__PURE__ */ a(
|
|
1086
1091
|
yr,
|
|
1087
1092
|
{
|
|
1088
|
-
onClick: () =>
|
|
1093
|
+
onClick: () => w(!0),
|
|
1089
1094
|
style: {
|
|
1090
1095
|
// background: storeDetails.tanyaThemeColor,
|
|
1091
1096
|
},
|
|
@@ -1150,7 +1155,7 @@ const xt = (t) => {
|
|
|
1150
1155
|
"div",
|
|
1151
1156
|
{
|
|
1152
1157
|
className: "fixed inset-0 z-40 bg-black/30",
|
|
1153
|
-
onClick: () =>
|
|
1158
|
+
onClick: () => w(!1)
|
|
1154
1159
|
}
|
|
1155
1160
|
),
|
|
1156
1161
|
/* @__PURE__ */ u(
|
|
@@ -1241,7 +1246,7 @@ const xt = (t) => {
|
|
|
1241
1246
|
gap: "1.25rem",
|
|
1242
1247
|
margin: "0.75rem"
|
|
1243
1248
|
},
|
|
1244
|
-
children: /* @__PURE__ */ a("button", { onClick: () =>
|
|
1249
|
+
children: /* @__PURE__ */ a("button", { onClick: () => w(!1), children: /* @__PURE__ */ u(
|
|
1245
1250
|
"svg",
|
|
1246
1251
|
{
|
|
1247
1252
|
width: "24",
|
|
@@ -1324,7 +1329,7 @@ const xt = (t) => {
|
|
|
1324
1329
|
}
|
|
1325
1330
|
),
|
|
1326
1331
|
Ct.map((c, k) => {
|
|
1327
|
-
var
|
|
1332
|
+
var b, y;
|
|
1328
1333
|
return /* @__PURE__ */ u("div", { children: [
|
|
1329
1334
|
/* @__PURE__ */ a("div", { className: "flex justify-end", children: /* @__PURE__ */ a("p", { className: "text-sm font-nunitoSans font-bold text-[#000000] bg-[#E2DBFF] border border-[#C9C2DE] rounded-l-xl p-2 m-3 mb-4 rounded-br-xl max-w-[75%]", children: c.query }) }),
|
|
1330
1335
|
c.response && c.response.includes("Thinking") ? /* @__PURE__ */ a("div", { children: /* @__PURE__ */ a(
|
|
@@ -1344,7 +1349,7 @@ const xt = (t) => {
|
|
|
1344
1349
|
}
|
|
1345
1350
|
}
|
|
1346
1351
|
) }),
|
|
1347
|
-
Pt && !c.response.includes("Thinking") && ((
|
|
1352
|
+
Pt && !c.response.includes("Thinking") && ((b = c.products) == null ? void 0 : b.length) == 0 && /* @__PURE__ */ a("div", { children: /* @__PURE__ */ a("p", { className: "text-sm animate-pulse font-nunitoSans font-bold text-[#000000] bg-[#E2DBFF] border border-[#C9C2DE] rounded-l-xl p-2 m-3 mb-4 rounded-br-xl max-w-[75%]", children: "Finding best products for you" }) }),
|
|
1348
1353
|
(c == null ? void 0 : c.products) && ((y = c == null ? void 0 : c.products) == null ? void 0 : y.length) > 0 && /* @__PURE__ */ a(
|
|
1349
1354
|
Ir,
|
|
1350
1355
|
{
|
|
@@ -1361,17 +1366,17 @@ const xt = (t) => {
|
|
|
1361
1366
|
children: "Why not explore these inquiries..."
|
|
1362
1367
|
}
|
|
1363
1368
|
),
|
|
1364
|
-
c.potentialQuestions.split(",").map((f,
|
|
1369
|
+
c.potentialQuestions.split(",").map((f, x) => /* @__PURE__ */ a(
|
|
1365
1370
|
"button",
|
|
1366
1371
|
{
|
|
1367
1372
|
className: `cursor-pointer font-nunitoSans font-semibold text-[#232323] border bg-[#804C9E0D] border-${p.themeDarkColor} m-1 rounded-xl px-2 py-1`,
|
|
1368
|
-
onClick: () =>
|
|
1373
|
+
onClick: () => J(f),
|
|
1369
1374
|
style: {
|
|
1370
1375
|
backgroundColor: p.tanyaThemeColorLight
|
|
1371
1376
|
},
|
|
1372
1377
|
children: f
|
|
1373
1378
|
},
|
|
1374
|
-
|
|
1379
|
+
x
|
|
1375
1380
|
))
|
|
1376
1381
|
] }),
|
|
1377
1382
|
c.secondaryLoading && /* @__PURE__ */ a("div", { className: "mt-3 mb-4 px-4", children: /* @__PURE__ */ u(
|
|
@@ -1477,16 +1482,16 @@ const xt = (t) => {
|
|
|
1477
1482
|
className: "px-3 py-1 text-sm",
|
|
1478
1483
|
onClick: () => O(
|
|
1479
1484
|
(f) => f.map(
|
|
1480
|
-
(
|
|
1481
|
-
...
|
|
1485
|
+
(x, z) => z === k && x.productSnapshot ? {
|
|
1486
|
+
...x,
|
|
1482
1487
|
productSnapshot: {
|
|
1483
|
-
...
|
|
1488
|
+
...x.productSnapshot,
|
|
1484
1489
|
quantity: Math.max(
|
|
1485
1490
|
1,
|
|
1486
|
-
|
|
1491
|
+
x.productSnapshot.quantity - 1
|
|
1487
1492
|
)
|
|
1488
1493
|
}
|
|
1489
|
-
} :
|
|
1494
|
+
} : x
|
|
1490
1495
|
)
|
|
1491
1496
|
),
|
|
1492
1497
|
style: {
|
|
@@ -1503,13 +1508,13 @@ const xt = (t) => {
|
|
|
1503
1508
|
className: "px-3 py-1 text-sm",
|
|
1504
1509
|
onClick: () => O(
|
|
1505
1510
|
(f) => f.map(
|
|
1506
|
-
(
|
|
1507
|
-
...
|
|
1511
|
+
(x, z) => z === k && x.productSnapshot ? {
|
|
1512
|
+
...x,
|
|
1508
1513
|
productSnapshot: {
|
|
1509
|
-
...
|
|
1510
|
-
quantity:
|
|
1514
|
+
...x.productSnapshot,
|
|
1515
|
+
quantity: x.productSnapshot.quantity + 1
|
|
1511
1516
|
}
|
|
1512
|
-
} :
|
|
1517
|
+
} : x
|
|
1513
1518
|
)
|
|
1514
1519
|
),
|
|
1515
1520
|
style: {
|
|
@@ -1531,14 +1536,14 @@ const xt = (t) => {
|
|
|
1531
1536
|
c.productSnapshot.quantity
|
|
1532
1537
|
);
|
|
1533
1538
|
},
|
|
1534
|
-
disabled:
|
|
1539
|
+
disabled: M,
|
|
1535
1540
|
className: "px-4 py-2 rounded-full font-medium",
|
|
1536
1541
|
style: {
|
|
1537
1542
|
background: p.tanyaThemeColor,
|
|
1538
1543
|
color: (p == null ? void 0 : p.tanyaThemeContrastColor) || "#fff",
|
|
1539
|
-
opacity:
|
|
1544
|
+
opacity: M ? 0.8 : 1
|
|
1540
1545
|
},
|
|
1541
|
-
children:
|
|
1546
|
+
children: M ? "Adding..." : "Add to cart"
|
|
1542
1547
|
}
|
|
1543
1548
|
)
|
|
1544
1549
|
] })
|
|
@@ -1570,7 +1575,7 @@ const xt = (t) => {
|
|
|
1570
1575
|
autoFocus: !0,
|
|
1571
1576
|
onChange: (c) => St(c.target.value),
|
|
1572
1577
|
onKeyDown: (c) => {
|
|
1573
|
-
c.key === "Enter" && !lt &&
|
|
1578
|
+
c.key === "Enter" && !lt && J();
|
|
1574
1579
|
}
|
|
1575
1580
|
}
|
|
1576
1581
|
),
|
|
@@ -1580,7 +1585,7 @@ const xt = (t) => {
|
|
|
1580
1585
|
type: "submit",
|
|
1581
1586
|
disabled: lt,
|
|
1582
1587
|
className: "p-3",
|
|
1583
|
-
onClick: () =>
|
|
1588
|
+
onClick: () => J(),
|
|
1584
1589
|
children: lt ? /* @__PURE__ */ a(
|
|
1585
1590
|
"div",
|
|
1586
1591
|
{
|
|
@@ -1674,10 +1679,10 @@ function it(t, e) {
|
|
|
1674
1679
|
if (!t)
|
|
1675
1680
|
throw new Ye(e);
|
|
1676
1681
|
}
|
|
1677
|
-
var
|
|
1682
|
+
var Ke = ["debug", "log", "warn", "error", "silent"], $r = Ke.indexOf("log");
|
|
1678
1683
|
function Lt(t) {
|
|
1679
1684
|
return function() {
|
|
1680
|
-
if (
|
|
1685
|
+
if (Ke.indexOf(t) >= $r) {
|
|
1681
1686
|
var e = console[t] || console.log;
|
|
1682
1687
|
return e.apply(console, arguments);
|
|
1683
1688
|
}
|
|
@@ -1686,7 +1691,7 @@ function Lt(t) {
|
|
|
1686
1691
|
(function(t) {
|
|
1687
1692
|
t.debug = Lt("debug"), t.log = Lt("log"), t.warn = Lt("warn"), t.error = Lt("error");
|
|
1688
1693
|
})(it || (it = {}));
|
|
1689
|
-
var
|
|
1694
|
+
var Je = "3.14.0";
|
|
1690
1695
|
function wt(t) {
|
|
1691
1696
|
try {
|
|
1692
1697
|
return t();
|
|
@@ -1742,13 +1747,13 @@ var Zt = Object.assign(function(e, r) {
|
|
|
1742
1747
|
warn: Bt(it.warn),
|
|
1743
1748
|
error: Bt(it.error)
|
|
1744
1749
|
});
|
|
1745
|
-
function
|
|
1750
|
+
function We(t) {
|
|
1746
1751
|
for (var e = [], r = 1; r < arguments.length; r++)
|
|
1747
1752
|
e[r - 1] = arguments[r];
|
|
1748
1753
|
return new Ye(le(t, e) || ce(t, e));
|
|
1749
1754
|
}
|
|
1750
|
-
var Fe = Symbol.for("ApolloErrorMessageHandler_" +
|
|
1751
|
-
function
|
|
1755
|
+
var Fe = Symbol.for("ApolloErrorMessageHandler_" + Je);
|
|
1756
|
+
function Ge(t) {
|
|
1752
1757
|
if (typeof t == "string")
|
|
1753
1758
|
return t;
|
|
1754
1759
|
try {
|
|
@@ -1759,14 +1764,14 @@ function We(t) {
|
|
|
1759
1764
|
}
|
|
1760
1765
|
function le(t, e) {
|
|
1761
1766
|
if (e === void 0 && (e = []), !!t)
|
|
1762
|
-
return ae[Fe] && ae[Fe](t, e.map(
|
|
1767
|
+
return ae[Fe] && ae[Fe](t, e.map(Ge));
|
|
1763
1768
|
}
|
|
1764
1769
|
function ce(t, e) {
|
|
1765
1770
|
if (e === void 0 && (e = []), !!t)
|
|
1766
1771
|
return "An error occurred! For more details, see the full error text at https://go.apollo.dev/c/err#".concat(encodeURIComponent(JSON.stringify({
|
|
1767
|
-
version:
|
|
1772
|
+
version: Je,
|
|
1768
1773
|
message: t,
|
|
1769
|
-
args: e.map(
|
|
1774
|
+
args: e.map(Ge)
|
|
1770
1775
|
})));
|
|
1771
1776
|
}
|
|
1772
1777
|
function Ar(t) {
|
|
@@ -1922,7 +1927,7 @@ var pe = function() {
|
|
|
1922
1927
|
};
|
|
1923
1928
|
pe() && !fe("observable") && (Symbol.observable = Symbol("observable"));
|
|
1924
1929
|
var Mr = me("iterator"), ie = me("observable"), Xe = me("species");
|
|
1925
|
-
function
|
|
1930
|
+
function Kt(t, e) {
|
|
1926
1931
|
var r = t[e];
|
|
1927
1932
|
if (r != null) {
|
|
1928
1933
|
if (typeof r != "function") throw new TypeError(r + " is not a function");
|
|
@@ -1957,7 +1962,7 @@ function Qe(t) {
|
|
|
1957
1962
|
if (typeof e == "function")
|
|
1958
1963
|
e();
|
|
1959
1964
|
else {
|
|
1960
|
-
var r =
|
|
1965
|
+
var r = Kt(e, "unsubscribe");
|
|
1961
1966
|
r && r.call(e);
|
|
1962
1967
|
}
|
|
1963
1968
|
} catch (o) {
|
|
@@ -1979,7 +1984,7 @@ function Ze(t, e, r) {
|
|
|
1979
1984
|
t._state = "running";
|
|
1980
1985
|
var o = t._observer;
|
|
1981
1986
|
try {
|
|
1982
|
-
var n =
|
|
1987
|
+
var n = Kt(o, e);
|
|
1983
1988
|
switch (e) {
|
|
1984
1989
|
case "next":
|
|
1985
1990
|
n && n.call(o, r);
|
|
@@ -2079,11 +2084,11 @@ var Rr = /* @__PURE__ */ (function() {
|
|
|
2079
2084
|
i.unsubscribe(), l();
|
|
2080
2085
|
}
|
|
2081
2086
|
var i = n.subscribe({
|
|
2082
|
-
next: function(
|
|
2087
|
+
next: function(g) {
|
|
2083
2088
|
try {
|
|
2084
|
-
o(
|
|
2085
|
-
} catch (
|
|
2086
|
-
s(
|
|
2089
|
+
o(g, d);
|
|
2090
|
+
} catch (w) {
|
|
2091
|
+
s(w), i.unsubscribe();
|
|
2087
2092
|
}
|
|
2088
2093
|
},
|
|
2089
2094
|
error: s,
|
|
@@ -2137,26 +2142,26 @@ var Rr = /* @__PURE__ */ (function() {
|
|
|
2137
2142
|
}, e.reduce = function(o) {
|
|
2138
2143
|
var n = this;
|
|
2139
2144
|
if (typeof o != "function") throw new TypeError(o + " is not a function");
|
|
2140
|
-
var l = Nt(this), s = arguments.length > 1, d = !1, i = arguments[1],
|
|
2141
|
-
return new l(function(
|
|
2145
|
+
var l = Nt(this), s = arguments.length > 1, d = !1, i = arguments[1], g = i;
|
|
2146
|
+
return new l(function(w) {
|
|
2142
2147
|
return n.subscribe({
|
|
2143
2148
|
next: function(C) {
|
|
2144
2149
|
var S = !d;
|
|
2145
2150
|
if (d = !0, !S || s)
|
|
2146
2151
|
try {
|
|
2147
|
-
|
|
2152
|
+
g = o(g, C);
|
|
2148
2153
|
} catch (_) {
|
|
2149
|
-
return
|
|
2154
|
+
return w.error(_);
|
|
2150
2155
|
}
|
|
2151
2156
|
else
|
|
2152
|
-
|
|
2157
|
+
g = C;
|
|
2153
2158
|
},
|
|
2154
2159
|
error: function(C) {
|
|
2155
|
-
|
|
2160
|
+
w.error(C);
|
|
2156
2161
|
},
|
|
2157
2162
|
complete: function() {
|
|
2158
|
-
if (!d && !s) return
|
|
2159
|
-
|
|
2163
|
+
if (!d && !s) return w.error(new TypeError("Cannot reduce an empty sequence"));
|
|
2164
|
+
w.next(g), w.complete();
|
|
2160
2165
|
}
|
|
2161
2166
|
});
|
|
2162
2167
|
});
|
|
@@ -2165,9 +2170,9 @@ var Rr = /* @__PURE__ */ (function() {
|
|
|
2165
2170
|
l[s] = arguments[s];
|
|
2166
2171
|
var d = Nt(this);
|
|
2167
2172
|
return new d(function(i) {
|
|
2168
|
-
var
|
|
2173
|
+
var g, w = 0;
|
|
2169
2174
|
function C(S) {
|
|
2170
|
-
|
|
2175
|
+
g = S.subscribe({
|
|
2171
2176
|
next: function(_) {
|
|
2172
2177
|
i.next(_);
|
|
2173
2178
|
},
|
|
@@ -2175,12 +2180,12 @@ var Rr = /* @__PURE__ */ (function() {
|
|
|
2175
2180
|
i.error(_);
|
|
2176
2181
|
},
|
|
2177
2182
|
complete: function() {
|
|
2178
|
-
|
|
2183
|
+
w === l.length ? (g = void 0, i.complete()) : C(d.from(l[w++]));
|
|
2179
2184
|
}
|
|
2180
2185
|
});
|
|
2181
2186
|
}
|
|
2182
2187
|
return C(o), function() {
|
|
2183
|
-
|
|
2188
|
+
g && (g.unsubscribe(), g = void 0);
|
|
2184
2189
|
};
|
|
2185
2190
|
});
|
|
2186
2191
|
}, e.flatMap = function(o) {
|
|
@@ -2189,14 +2194,14 @@ var Rr = /* @__PURE__ */ (function() {
|
|
|
2189
2194
|
var l = Nt(this);
|
|
2190
2195
|
return new l(function(s) {
|
|
2191
2196
|
var d = [], i = n.subscribe({
|
|
2192
|
-
next: function(
|
|
2197
|
+
next: function(w) {
|
|
2193
2198
|
if (o)
|
|
2194
2199
|
try {
|
|
2195
|
-
|
|
2200
|
+
w = o(w);
|
|
2196
2201
|
} catch (S) {
|
|
2197
2202
|
return s.error(S);
|
|
2198
2203
|
}
|
|
2199
|
-
var C = l.from(
|
|
2204
|
+
var C = l.from(w).subscribe({
|
|
2200
2205
|
next: function(S) {
|
|
2201
2206
|
s.next(S);
|
|
2202
2207
|
},
|
|
@@ -2205,24 +2210,24 @@ var Rr = /* @__PURE__ */ (function() {
|
|
|
2205
2210
|
},
|
|
2206
2211
|
complete: function() {
|
|
2207
2212
|
var S = d.indexOf(C);
|
|
2208
|
-
S >= 0 && d.splice(S, 1),
|
|
2213
|
+
S >= 0 && d.splice(S, 1), g();
|
|
2209
2214
|
}
|
|
2210
2215
|
});
|
|
2211
2216
|
d.push(C);
|
|
2212
2217
|
},
|
|
2213
|
-
error: function(
|
|
2214
|
-
s.error(
|
|
2218
|
+
error: function(w) {
|
|
2219
|
+
s.error(w);
|
|
2215
2220
|
},
|
|
2216
2221
|
complete: function() {
|
|
2217
|
-
|
|
2222
|
+
g();
|
|
2218
2223
|
}
|
|
2219
2224
|
});
|
|
2220
|
-
function
|
|
2225
|
+
function g() {
|
|
2221
2226
|
i.closed && d.length === 0 && s.complete();
|
|
2222
2227
|
}
|
|
2223
2228
|
return function() {
|
|
2224
|
-
d.forEach(function(
|
|
2225
|
-
return
|
|
2229
|
+
d.forEach(function(w) {
|
|
2230
|
+
return w.unsubscribe();
|
|
2226
2231
|
}), i.unsubscribe();
|
|
2227
2232
|
};
|
|
2228
2233
|
});
|
|
@@ -2231,7 +2236,7 @@ var Rr = /* @__PURE__ */ (function() {
|
|
|
2231
2236
|
}, t.from = function(o) {
|
|
2232
2237
|
var n = typeof this == "function" ? this : t;
|
|
2233
2238
|
if (o == null) throw new TypeError(o + " is not an object");
|
|
2234
|
-
var l =
|
|
2239
|
+
var l = Kt(o, ie);
|
|
2235
2240
|
if (l) {
|
|
2236
2241
|
var s = l.call(o);
|
|
2237
2242
|
if (Object(s) !== s) throw new TypeError(s + " is not an object");
|
|
@@ -2239,13 +2244,13 @@ var Rr = /* @__PURE__ */ (function() {
|
|
|
2239
2244
|
return s.subscribe(d);
|
|
2240
2245
|
});
|
|
2241
2246
|
}
|
|
2242
|
-
if (fe("iterator") && (l =
|
|
2247
|
+
if (fe("iterator") && (l = Kt(o, Mr), l))
|
|
2243
2248
|
return new n(function(d) {
|
|
2244
2249
|
qt(function() {
|
|
2245
2250
|
if (!d.closed) {
|
|
2246
|
-
for (var i = Ur(l.call(o)),
|
|
2247
|
-
var
|
|
2248
|
-
if (d.next(
|
|
2251
|
+
for (var i = Ur(l.call(o)), g; !(g = i()).done; ) {
|
|
2252
|
+
var w = g.value;
|
|
2253
|
+
if (d.next(w), d.closed) return;
|
|
2249
2254
|
}
|
|
2250
2255
|
d.complete();
|
|
2251
2256
|
}
|
|
@@ -2289,7 +2294,7 @@ pe() && Object.defineProperty(N, Symbol("extensions"), {
|
|
|
2289
2294
|
},
|
|
2290
2295
|
configurable: !0
|
|
2291
2296
|
});
|
|
2292
|
-
function
|
|
2297
|
+
function Kr(t) {
|
|
2293
2298
|
var e, r = t.Symbol;
|
|
2294
2299
|
if (typeof r == "function")
|
|
2295
2300
|
if (r.observable)
|
|
@@ -2307,12 +2312,12 @@ function Jr(t) {
|
|
|
2307
2312
|
}
|
|
2308
2313
|
var gt;
|
|
2309
2314
|
typeof self < "u" ? gt = self : typeof window < "u" ? gt = window : typeof global < "u" ? gt = global : typeof module < "u" ? gt = module : gt = Function("return this")();
|
|
2310
|
-
|
|
2315
|
+
Kr(gt);
|
|
2311
2316
|
var $e = N.prototype, ze = "@@observable";
|
|
2312
2317
|
$e[ze] || ($e[ze] = function() {
|
|
2313
2318
|
return this;
|
|
2314
2319
|
});
|
|
2315
|
-
function
|
|
2320
|
+
function Jr(t) {
|
|
2316
2321
|
for (var e = [
|
|
2317
2322
|
"query",
|
|
2318
2323
|
"operationName",
|
|
@@ -2322,11 +2327,11 @@ function Kr(t) {
|
|
|
2322
2327
|
], r = 0, o = Object.keys(t); r < o.length; r++) {
|
|
2323
2328
|
var n = o[r];
|
|
2324
2329
|
if (e.indexOf(n) < 0)
|
|
2325
|
-
throw
|
|
2330
|
+
throw We(58, n);
|
|
2326
2331
|
}
|
|
2327
2332
|
return t;
|
|
2328
2333
|
}
|
|
2329
|
-
function
|
|
2334
|
+
function Wr(t, e) {
|
|
2330
2335
|
var r = Q({}, t), o = function(l) {
|
|
2331
2336
|
typeof l == "function" ? r = Q(Q({}, r), l(r)) : r = Q(Q({}, r), l);
|
|
2332
2337
|
}, n = function() {
|
|
@@ -2340,7 +2345,7 @@ function Gr(t, e) {
|
|
|
2340
2345
|
value: n
|
|
2341
2346
|
}), e;
|
|
2342
2347
|
}
|
|
2343
|
-
function
|
|
2348
|
+
function Gr(t) {
|
|
2344
2349
|
var e = {
|
|
2345
2350
|
variables: t.variables || {},
|
|
2346
2351
|
extensions: t.extensions || {},
|
|
@@ -2387,7 +2392,7 @@ var tr = (
|
|
|
2387
2392
|
return e(d) ? n.request(d, i) || N.of() : l.request(d, i) || N.of();
|
|
2388
2393
|
}), Object.assign(s, { left: n, right: l });
|
|
2389
2394
|
}, t.execute = function(e, r) {
|
|
2390
|
-
return e.request(
|
|
2395
|
+
return e.request(Wr(r.context, Gr(Jr(r)))) || N.of();
|
|
2391
2396
|
}, t.concat = function(e, r) {
|
|
2392
2397
|
var o = Et(e);
|
|
2393
2398
|
if (Ut(o))
|
|
@@ -2407,7 +2412,7 @@ var tr = (
|
|
|
2407
2412
|
}, t.prototype.concat = function(e) {
|
|
2408
2413
|
return t.concat(this, e);
|
|
2409
2414
|
}, t.prototype.request = function(e, r) {
|
|
2410
|
-
throw
|
|
2415
|
+
throw We(48);
|
|
2411
2416
|
}, t.prototype.onError = function(e, r) {
|
|
2412
2417
|
if (globalThis.__DEV__ !== !1 && eo("onError", function() {
|
|
2413
2418
|
globalThis.__DEV__ !== !1 && Zt.warn(49);
|