tanya-chatbot 0.5.2 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/tanya-chatbot.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useEffect as M, useState as z, useRef as Ft } from "react";
|
|
2
2
|
import { jsx as a, jsxs as u, Fragment as re } from "react/jsx-runtime";
|
|
3
3
|
import { createHttpLink as lr, ApolloClient as cr, InMemoryCache as dr, ApolloProvider as ur } from "@apollo/client";
|
|
4
|
-
import { Provider as pr, useDispatch as De, useSelector as
|
|
4
|
+
import { Provider as pr, useDispatch as De, useSelector as Rt } from "react-redux";
|
|
5
5
|
import { createSlice as Le, configureStore as fr } from "@reduxjs/toolkit";
|
|
6
6
|
import * as Be from "@radix-ui/react-popover";
|
|
7
7
|
import "clsx";
|
|
@@ -78,7 +78,7 @@ const mr = {
|
|
|
78
78
|
store: wr,
|
|
79
79
|
product: br
|
|
80
80
|
}
|
|
81
|
-
}), yr = ({ children: t }) => /* @__PURE__ */ a(pr, { store: xr, children: t }),
|
|
81
|
+
}), yr = ({ children: t }) => /* @__PURE__ */ a(pr, { store: xr, children: t }), Vt = (t) => {
|
|
82
82
|
const e = new CustomEvent("reactCartUpdated", {
|
|
83
83
|
detail: {
|
|
84
84
|
cartUpdated: !0,
|
|
@@ -97,7 +97,7 @@ function kr({
|
|
|
97
97
|
}) {
|
|
98
98
|
return /* @__PURE__ */ a(Be.Trigger, { "data-slot": "popover-trigger", ...t });
|
|
99
99
|
}
|
|
100
|
-
const
|
|
100
|
+
const kt = () => ({ aiConversationUrl: "https://mdv3qwfi2j.execute-api.us-east-1.amazonaws.com/dev/api/bedrock/invoke/stream", xAPIKey: "BJBtjpPkqGatuoa3qJqdR8aHXSsHkgvGaootbubi", serverUrl: "https://tanya-sfcc-server.vercel.app/", basePath: "sc-api" }), Me = async () => {
|
|
101
101
|
const t = "https://tanya-sfcc-server.vercel.app/";
|
|
102
102
|
try {
|
|
103
103
|
const e = await E.post(
|
|
@@ -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=${tt()}&siteId=${J()}&pubCfg=${
|
|
114
|
+
`${e}api/auth/token-existing-guest-customer?dwsid=${r}&baseUrl=${tt()}&siteId=${J()}&pubCfg=${at()}&envRef=${it()}&orgRef=${st()}`,
|
|
115
115
|
{},
|
|
116
116
|
{
|
|
117
117
|
headers: {
|
|
@@ -130,9 +130,9 @@ async function Ot() {
|
|
|
130
130
|
const t = J(), e = "access_token_" + t, r = "expires_in_" + t, o = localStorage.getItem(r), n = localStorage.getItem(e);
|
|
131
131
|
return console.log(n), (c = JSON.parse(sessionStorage.getItem("customerData") || "{}")) != null && c.isGuest, console.log("access token found in local storage"), { access_token: n, expires_in: o };
|
|
132
132
|
}
|
|
133
|
-
const tt = () => sessionStorage.getItem("Host"), J = () => sessionStorage.getItem("SiteId"),
|
|
133
|
+
const tt = () => sessionStorage.getItem("Host"), J = () => sessionStorage.getItem("SiteId"), at = () => sessionStorage.getItem("pubCfg"), it = () => sessionStorage.getItem("envRef"), st = () => sessionStorage.getItem("orgRef"), xe = async (t) => {
|
|
134
134
|
console.log("fetching results");
|
|
135
|
-
const { serverUrl: e, basePath: r } =
|
|
135
|
+
const { serverUrl: e, basePath: r } = kt();
|
|
136
136
|
let o = "";
|
|
137
137
|
{
|
|
138
138
|
const n = await Ot();
|
|
@@ -141,7 +141,7 @@ const tt = () => sessionStorage.getItem("Host"), J = () => sessionStorage.getIte
|
|
|
141
141
|
try {
|
|
142
142
|
const n = tt();
|
|
143
143
|
return (await E.get(
|
|
144
|
-
`${e}${r}/search-sfcc?baseUrl=${n}&query=${t}&siteId=${J()}&pubCfg=${
|
|
144
|
+
`${e}${r}/search-sfcc?baseUrl=${n}&query=${t}&siteId=${J()}&pubCfg=${at()}&envRef=${it()}&orgRef=${st()}`,
|
|
145
145
|
{
|
|
146
146
|
headers: {
|
|
147
147
|
"Content-Type": "application/json",
|
|
@@ -152,13 +152,13 @@ const tt = () => sessionStorage.getItem("Host"), J = () => sessionStorage.getIte
|
|
|
152
152
|
} catch (n) {
|
|
153
153
|
throw console.error("Error fetching search results:", n), n;
|
|
154
154
|
}
|
|
155
|
-
},
|
|
155
|
+
}, Re = async (t) => {
|
|
156
156
|
if (!t) throw new Error("Product ID is required");
|
|
157
|
-
const { serverUrl: e, basePath: r } =
|
|
157
|
+
const { serverUrl: e, basePath: r } = kt(), o = tt();
|
|
158
158
|
console.log("calling access");
|
|
159
159
|
const { access_token: n } = await Ot();
|
|
160
|
-
return
|
|
161
|
-
`${e}${r}/product-sfcc/${t}?baseUrl=${o}&siteId=${J()}&pubCfg=${
|
|
160
|
+
return (await E.get(
|
|
161
|
+
`${e}${r}/product-sfcc/${t}?baseUrl=${o}&siteId=${J()}&pubCfg=${at()}&envRef=${it()}&orgRef=${st()}`,
|
|
162
162
|
{
|
|
163
163
|
headers: {
|
|
164
164
|
"Content-Type": "application/json",
|
|
@@ -170,9 +170,9 @@ const tt = () => sessionStorage.getItem("Host"), J = () => sessionStorage.getIte
|
|
|
170
170
|
if (!t) throw new Error("customerId is required");
|
|
171
171
|
const e = await Me(), { customer_token: r } = await He(
|
|
172
172
|
e
|
|
173
|
-
), { serverUrl: o, basePath: n } =
|
|
173
|
+
), { serverUrl: o, basePath: n } = kt(), l = (await Ot()).access_token;
|
|
174
174
|
return (await E.get(
|
|
175
|
-
`${o}${n}/get-interest?baseUrl=${tt()}&customerId=${t}&siteId=${J()}&pubCfg=${
|
|
175
|
+
`${o}${n}/get-interest?baseUrl=${tt()}&customerId=${t}&siteId=${J()}&pubCfg=${at()}&envRef=${it()}&orgRef=${st()}`,
|
|
176
176
|
{
|
|
177
177
|
headers: {
|
|
178
178
|
"Content-Type": "application/json",
|
|
@@ -215,8 +215,8 @@ const Fr = ({
|
|
|
215
215
|
(i) => i - r < 0 ? t.length - (t.length % r || r) : i - r
|
|
216
216
|
);
|
|
217
217
|
}, d = async (i) => {
|
|
218
|
-
const
|
|
219
|
-
e(oe(
|
|
218
|
+
const x = await Re(i);
|
|
219
|
+
e(oe(x));
|
|
220
220
|
};
|
|
221
221
|
return /* @__PURE__ */ a("div", { className: "mt-2 overflow-x-hidden", children: /* @__PURE__ */ u("div", { className: "flex items-center justify-center gap-4 relative", children: [
|
|
222
222
|
(t == null ? void 0 : t.length) > r && /* @__PURE__ */ a(
|
|
@@ -233,7 +233,7 @@ const Fr = ({
|
|
|
233
233
|
}
|
|
234
234
|
),
|
|
235
235
|
/* @__PURE__ */ a("div", { className: "flex gap-5 justify-center flex-1 overflow-hidden", children: t.slice(o, o + r).map((i) => {
|
|
236
|
-
var
|
|
236
|
+
var x, y, C, k;
|
|
237
237
|
return /* @__PURE__ */ u(
|
|
238
238
|
"div",
|
|
239
239
|
{
|
|
@@ -245,7 +245,7 @@ const Fr = ({
|
|
|
245
245
|
/* @__PURE__ */ a("div", { className: "w-full p-2 flex items-center justify-center bg-white", children: /* @__PURE__ */ a(
|
|
246
246
|
"img",
|
|
247
247
|
{
|
|
248
|
-
src: ((
|
|
248
|
+
src: ((x = ve(i)[0]) == null ? void 0 : x.link) || ve(i)[0] || // fallback if it's a string
|
|
249
249
|
"https://via.placeholder.com/120",
|
|
250
250
|
alt: i != null && i.productName ? i.productName : "Product",
|
|
251
251
|
className: "w-28 h-28 rounded-[10px] transition-transform duration-300 hover:scale-125 object-cover"
|
|
@@ -258,7 +258,7 @@ const Fr = ({
|
|
|
258
258
|
children: [
|
|
259
259
|
/* @__PURE__ */ u("div", { className: "relative inline-block group", children: [
|
|
260
260
|
/* @__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 : Se(
|
|
261
|
-
ye((
|
|
261
|
+
ye((y = i == null ? void 0 : i.name) == null ? void 0 : y["en-US"]),
|
|
262
262
|
60
|
|
263
263
|
) || "Product" }),
|
|
264
264
|
/* @__PURE__ */ a(
|
|
@@ -282,7 +282,7 @@ const Fr = ({
|
|
|
282
282
|
/* @__PURE__ */ u("div", { className: " flex text-center items-center gap-2 text-[14px] text-[#14121F] font-bold font-nunitoSans text-base mb-1", children: [
|
|
283
283
|
/* @__PURE__ */ a("p", { children: _r(
|
|
284
284
|
i != null && i.price ? Number(i == null ? void 0 : i.price) : ke(i).centAmount || 0,
|
|
285
|
-
(
|
|
285
|
+
(k = ke(i)) == null ? void 0 : k.currencyCode
|
|
286
286
|
) }),
|
|
287
287
|
/* @__PURE__ */ u("p", { className: "text-[#14121F] font-normal line-through text-sm font-nunitoSans truncate", children: [
|
|
288
288
|
"$",
|
|
@@ -337,14 +337,12 @@ const Fr = ({
|
|
|
337
337
|
]
|
|
338
338
|
},
|
|
339
339
|
o
|
|
340
|
-
)) }),
|
|
340
|
+
)) }), Ve = async (t, e) => {
|
|
341
341
|
var c, l;
|
|
342
|
-
const { serverUrl: r, basePath: o } =
|
|
343
|
-
console.log(`customer_token
|
|
344
|
-
`, t);
|
|
342
|
+
const { serverUrl: r, basePath: o } = kt(), n = `${r}`;
|
|
345
343
|
try {
|
|
346
344
|
const d = await E.post(
|
|
347
|
-
`${n}${o}/basket/create?baseUrl=${tt()}&siteId=${J()}&pubCfg=${
|
|
345
|
+
`${n}${o}/basket/create?baseUrl=${tt()}&siteId=${J()}&pubCfg=${at()}&envRef=${it()}&orgRef=${st()}`,
|
|
348
346
|
e,
|
|
349
347
|
{
|
|
350
348
|
headers: {
|
|
@@ -364,10 +362,10 @@ const Fr = ({
|
|
|
364
362
|
return E.isAxiosError(d) ? console.error("Error creating basket:", d.response || d.message) : console.error("Unexpected error:", d), null;
|
|
365
363
|
}
|
|
366
364
|
}, ne = async (t, e, r) => {
|
|
367
|
-
const { serverUrl: o, basePath: n } =
|
|
365
|
+
const { serverUrl: o, basePath: n } = kt(), c = `${o}`;
|
|
368
366
|
try {
|
|
369
367
|
const l = await E.post(
|
|
370
|
-
`${c}${n}/basket/add-product/${t}?baseUrl=${tt()}&siteId=${J()}&pubCfg=${
|
|
368
|
+
`${c}${n}/basket/add-product/${t}?baseUrl=${tt()}&siteId=${J()}&pubCfg=${at()}&envRef=${it()}&orgRef=${st()}`,
|
|
371
369
|
e,
|
|
372
370
|
{
|
|
373
371
|
headers: {
|
|
@@ -388,10 +386,10 @@ const Fr = ({
|
|
|
388
386
|
customer_token: e
|
|
389
387
|
}) => {
|
|
390
388
|
var c;
|
|
391
|
-
const { serverUrl: r, basePath: o } =
|
|
389
|
+
const { serverUrl: r, basePath: o } = kt(), n = `${r}`;
|
|
392
390
|
try {
|
|
393
391
|
const l = await E.get(
|
|
394
|
-
`${n}${o}/basket/${t}?baseUrl=${tt()}&siteId=${J()}&pubCfg=${
|
|
392
|
+
`${n}${o}/basket/${t}?baseUrl=${tt()}&siteId=${J()}&pubCfg=${at()}&envRef=${it()}&orgRef=${st()}`,
|
|
395
393
|
{
|
|
396
394
|
headers: {
|
|
397
395
|
"Content-Type": "application/json",
|
|
@@ -404,7 +402,7 @@ const Fr = ({
|
|
|
404
402
|
return E.isAxiosError(l) ? { status: (c = l.response) == null ? void 0 : c.status, data: null } : { status: null, data: null };
|
|
405
403
|
}
|
|
406
404
|
}, Yt = "sfcc_basket_id", _e = "sfcc_customer_token", Pt = "sfcc_token_expiry", Er = 300 * 1e3, Nt = "1.0.0";
|
|
407
|
-
const
|
|
405
|
+
const nt = (t) => {
|
|
408
406
|
try {
|
|
409
407
|
t ? localStorage.setItem(Yt, t) : localStorage.removeItem(Yt);
|
|
410
408
|
} catch (e) {
|
|
@@ -422,16 +420,15 @@ const at = (t) => {
|
|
|
422
420
|
console.error("Error storing token:", e);
|
|
423
421
|
}
|
|
424
422
|
}, Ce = 300, Tr = ({ addToCartPwa: t }) => {
|
|
425
|
-
var i,
|
|
426
|
-
const e = De(), r =
|
|
423
|
+
var i, x, y, C, k, j;
|
|
424
|
+
const e = De(), r = Rt((T) => T.product.product), o = Rt((T) => T.store.store), [n, c] = z(!!r);
|
|
427
425
|
if (M(() => {
|
|
428
426
|
c(!!r);
|
|
429
427
|
}, [r]), !r) return null;
|
|
430
428
|
const l = async () => {
|
|
431
|
-
var T, D, W,
|
|
432
|
-
console.log(r, "the prod");
|
|
429
|
+
var T, D, W, lt, R, ct, St, $t, et, _t, Ct, dt, zt, At, rt, P;
|
|
433
430
|
try {
|
|
434
|
-
if (!((D = (T = r == null ? void 0 : r.variants) == null ? void 0 : T[0]) != null && D.product_id) && !(r.type.item || r.type.bundle) && !((
|
|
431
|
+
if (!((D = (T = r == null ? void 0 : r.variants) == null ? void 0 : T[0]) != null && D.product_id) && !(r.type.item || r.type.bundle) && !((lt = (W = r == null ? void 0 : r.variants) == null ? void 0 : W[0]) != null && lt.productId)) {
|
|
435
432
|
H.error("Variants not available", {
|
|
436
433
|
position: "bottom-right",
|
|
437
434
|
autoClose: 1e3
|
|
@@ -440,92 +437,76 @@ const at = (t) => {
|
|
|
440
437
|
}
|
|
441
438
|
const _ = [
|
|
442
439
|
{
|
|
443
|
-
product_id: ((
|
|
440
|
+
product_id: ((R = r.variants) == null ? void 0 : R[0].product_id) || ((ct = r.variants) == null ? void 0 : ct[0].productId) || (r == null ? void 0 : r.id),
|
|
444
441
|
quantity: 1
|
|
445
442
|
}
|
|
446
|
-
]
|
|
447
|
-
console.log(_, "the product data");
|
|
448
|
-
const k = JSON.parse(
|
|
443
|
+
], v = JSON.parse(
|
|
449
444
|
sessionStorage.getItem("customerData") || "{}"
|
|
450
|
-
),
|
|
445
|
+
), ut = (v == null ? void 0 : v.basketId) || localStorage.getItem(Yt), Wt = !1, jt = localStorage.getItem(Pt), Dt = Date.now();
|
|
451
446
|
if (!Wt || !jt || Dt >= parseInt(jt)) {
|
|
452
447
|
let $ = "";
|
|
453
|
-
{
|
|
454
|
-
const ft = await Ot();
|
|
455
|
-
console.log("token from auth data"), $ = "Bearer " + ft.access_token;
|
|
456
|
-
}
|
|
457
|
-
if (!$) {
|
|
448
|
+
if ($ = "Bearer " + (await Ot()).access_token, !$) {
|
|
458
449
|
console.error("Failed to get customer_token");
|
|
459
450
|
return;
|
|
460
451
|
}
|
|
461
452
|
const pt = Dt + 300 * 1e3;
|
|
462
|
-
if (Kt($), localStorage.setItem(Pt, pt.toString()),
|
|
463
|
-
const
|
|
464
|
-
basketId:
|
|
453
|
+
if (Kt($), localStorage.setItem(Pt, pt.toString()), ut) {
|
|
454
|
+
const It = await Ye({
|
|
455
|
+
basketId: ut,
|
|
465
456
|
customer_token: $
|
|
466
457
|
});
|
|
467
|
-
if (
|
|
458
|
+
if (It.status === 200 && It) {
|
|
468
459
|
const L = await ne(
|
|
469
|
-
|
|
460
|
+
ut,
|
|
470
461
|
_,
|
|
471
462
|
$
|
|
472
463
|
);
|
|
473
|
-
(((
|
|
464
|
+
(((St = L == null ? void 0 : L.product_items) == null ? void 0 : St.length) > 0 || (($t = L == null ? void 0 : L.productItems) == null ? void 0 : $t.length) > 0) && (H.success("Added to cart", {
|
|
474
465
|
position: "bottom-right",
|
|
475
466
|
autoClose: 3e3,
|
|
476
467
|
hideProgressBar: !1,
|
|
477
468
|
closeOnClick: !0,
|
|
478
469
|
pauseOnHover: !0,
|
|
479
470
|
draggable: !0
|
|
480
|
-
}),
|
|
471
|
+
}), Vt(ut));
|
|
481
472
|
return;
|
|
482
473
|
}
|
|
483
474
|
}
|
|
484
475
|
const Lt = {
|
|
485
476
|
productItems: [
|
|
486
477
|
{
|
|
487
|
-
productId: ((et = r.variants) == null ? void 0 : et[0].product_id) || ((
|
|
478
|
+
productId: ((et = r.variants) == null ? void 0 : et[0].product_id) || ((_t = r.variants) == null ? void 0 : _t[0].productId) || (r == null ? void 0 : r.id),
|
|
488
479
|
quantity: 1
|
|
489
480
|
}
|
|
490
481
|
]
|
|
491
|
-
};
|
|
492
|
-
|
|
493
|
-
const h = await Re($, Lt);
|
|
494
|
-
if (console.log(
|
|
495
|
-
h,
|
|
496
|
-
h == null ? void 0 : h.basket_id,
|
|
497
|
-
h == null ? void 0 : h.basketId,
|
|
498
|
-
"the basket response"
|
|
499
|
-
), !(h != null && h.basket_id) && !(h != null && h.basketId)) {
|
|
482
|
+
}, S = await Ve($, Lt);
|
|
483
|
+
if (!(S != null && S.basket_id) && !(S != null && S.basketId)) {
|
|
500
484
|
console.error("Failed to create basket");
|
|
501
485
|
return;
|
|
502
486
|
}
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
(h == null ? void 0 : h.basket_id) || (h == null ? void 0 : h.basketId)
|
|
506
|
-
), at(
|
|
507
|
-
(h == null ? void 0 : h.basket_id) || (h == null ? void 0 : h.basketId)
|
|
487
|
+
nt(
|
|
488
|
+
(S == null ? void 0 : S.basket_id) || (S == null ? void 0 : S.basketId)
|
|
508
489
|
), console.log("adding product to basket");
|
|
509
490
|
const G = await ne(
|
|
510
|
-
(
|
|
491
|
+
(S == null ? void 0 : S.basket_id) || (S == null ? void 0 : S.basketId),
|
|
511
492
|
_,
|
|
512
493
|
$
|
|
513
494
|
);
|
|
514
|
-
console.log("object added to basket"), (((
|
|
495
|
+
console.log("object added to basket"), (((Ct = G == null ? void 0 : G.product_items) == null ? void 0 : Ct.length) > 0 || ((dt = G == null ? void 0 : G.productItems) == null ? void 0 : dt.length) > 0) && H.success("Added to cart", {
|
|
515
496
|
position: "bottom-right",
|
|
516
497
|
autoClose: 3e3,
|
|
517
498
|
hideProgressBar: !1,
|
|
518
499
|
closeOnClick: !0,
|
|
519
500
|
pauseOnHover: !0,
|
|
520
501
|
draggable: !0
|
|
521
|
-
}),
|
|
502
|
+
}), Vt(S.basket_id || (S == null ? void 0 : S.basketId));
|
|
522
503
|
}
|
|
523
504
|
} catch (_) {
|
|
524
505
|
console.error("Error adding to cart:", _), H.error("Failed to add product to cart", {
|
|
525
506
|
position: "bottom-right",
|
|
526
507
|
autoClose: 3e3
|
|
527
508
|
}), ((zt = _ == null ? void 0 : _.response) == null ? void 0 : zt.status) === 404 || // Basket not found
|
|
528
|
-
((At = _ == null ? void 0 : _.response) == null ? void 0 : At.status) === 401 ? (((rt = _ == null ? void 0 : _.response) == null ? void 0 : rt.status) === 404 &&
|
|
509
|
+
((At = _ == null ? void 0 : _.response) == null ? void 0 : At.status) === 401 ? (((rt = _ == null ? void 0 : _.response) == null ? void 0 : rt.status) === 404 && nt(null), ((P = _ == null ? void 0 : _.response) == null ? void 0 : P.status) === 401 && (nt(null), Kt(null))) : (console.error("Failed to add product to basket:", _.message), H.error("Failed to add product to cart", {
|
|
529
510
|
position: "bottom-right",
|
|
530
511
|
autoClose: 3e3
|
|
531
512
|
}));
|
|
@@ -574,7 +555,7 @@ const at = (t) => {
|
|
|
574
555
|
/* @__PURE__ */ a("div", { className: "flex flex-row items-center justify-center w-[120px] h-[120px] my-5", children: /* @__PURE__ */ a(
|
|
575
556
|
"img",
|
|
576
557
|
{
|
|
577
|
-
src: (C = (
|
|
558
|
+
src: (C = (y = (x = (i = r.imageGroups) == null ? void 0 : i[0]) == null ? void 0 : x.images) == null ? void 0 : y[0]) == null ? void 0 : C.link,
|
|
578
559
|
alt: r.name,
|
|
579
560
|
className: "rounded-[10px]"
|
|
580
561
|
}
|
|
@@ -623,7 +604,7 @@ const at = (t) => {
|
|
|
623
604
|
/* @__PURE__ */ u("div", { className: "mt-4 flex flex-col gap-2 w-full p-2", children: [
|
|
624
605
|
/* @__PURE__ */ a("div", { className: "flex flex-row items-center gap-2", children: /* @__PURE__ */ u("div", { className: "flex items-center gap-2 text-left font-nunitoSans", children: [
|
|
625
606
|
/* @__PURE__ */ u("div", { className: "text-[#323135] font-bold", children: [
|
|
626
|
-
((
|
|
607
|
+
((k = r == null ? void 0 : r.rating) == null ? void 0 : k.rate) || 0,
|
|
627
608
|
" /",
|
|
628
609
|
" ",
|
|
629
610
|
/* @__PURE__ */ a("span", { className: "text-[#68656E]", children: "5" })
|
|
@@ -700,21 +681,21 @@ const at = (t) => {
|
|
|
700
681
|
"Niece/Nephew": "his/her niece/nephew",
|
|
701
682
|
"My Friends": "his/her friends",
|
|
702
683
|
Others: "others"
|
|
703
|
-
}, c = Ft(null), l = Ft(null), d = Ft(null), i = Ft(null), [
|
|
684
|
+
}, c = Ft(null), l = Ft(null), d = Ft(null), i = Ft(null), [x, y] = z(null), [C, k] = z(!1), [j, T] = z(!1), [D, W] = z(!1), [lt, R] = z(!1), [ct, St] = z(!1), [$t, et] = z(!1), [_t, Ct] = z(""), [dt, zt] = z(""), At = (s) => ({
|
|
704
685
|
id: s.id,
|
|
705
686
|
title: s.name,
|
|
706
687
|
image: s.image ?? "",
|
|
707
688
|
price: s.price ?? 0
|
|
708
|
-
}), [rt, P] = z([]), _ = Ft(null),
|
|
689
|
+
}), [rt, P] = z([]), _ = Ft(null), v = Rt((s) => s.store.store), ut = Rt((s) => s.product.product);
|
|
709
690
|
M(() => {
|
|
710
691
|
const s = localStorage.getItem(
|
|
711
692
|
`access_token_${t.siteId}`
|
|
712
|
-
),
|
|
693
|
+
), w = localStorage.getItem(
|
|
713
694
|
`chat-token-${t.siteId}`
|
|
714
695
|
);
|
|
715
|
-
if (s &&
|
|
716
|
-
const
|
|
717
|
-
|
|
696
|
+
if (s && w === s) {
|
|
697
|
+
const h = localStorage.getItem("chatHistory");
|
|
698
|
+
h && P(JSON.parse(h));
|
|
718
699
|
} else
|
|
719
700
|
localStorage.setItem("chatHistory", JSON.stringify([])), localStorage.setItem(
|
|
720
701
|
`chat-token-${t.siteId}`,
|
|
@@ -746,44 +727,44 @@ const at = (t) => {
|
|
|
746
727
|
if ($ && pt && Date.now() < pt)
|
|
747
728
|
return $;
|
|
748
729
|
try {
|
|
749
|
-
const s = "https://us-east-1lsr29ln3u.auth.us-east-1.amazoncognito.com/oauth2/token",
|
|
730
|
+
const s = "https://us-east-1lsr29ln3u.auth.us-east-1.amazoncognito.com/oauth2/token", w = new URLSearchParams({
|
|
750
731
|
grant_type: "client_credentials",
|
|
751
732
|
client_id: "4i8rd70sgt961tc4dhskgf08c",
|
|
752
733
|
client_secret: "bnsfq1220loh2cn2cm2ttn8fdhdpt0u8m1fgj8vfk2rn61aurjg",
|
|
753
734
|
scope: "default-m2m-resource-server-8xzfzo/read"
|
|
754
|
-
}),
|
|
735
|
+
}), h = await fetch(s, {
|
|
755
736
|
method: "POST",
|
|
756
737
|
headers: {
|
|
757
738
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
758
739
|
},
|
|
759
|
-
body:
|
|
740
|
+
body: w
|
|
760
741
|
});
|
|
761
|
-
if (!
|
|
742
|
+
if (!h.ok)
|
|
762
743
|
throw new Error(
|
|
763
|
-
`Token request failed! status: ${
|
|
744
|
+
`Token request failed! status: ${h.status}`
|
|
764
745
|
);
|
|
765
|
-
const
|
|
766
|
-
$ =
|
|
767
|
-
const p =
|
|
746
|
+
const g = await h.json();
|
|
747
|
+
$ = g.access_token;
|
|
748
|
+
const p = g.expires_in || 3600;
|
|
768
749
|
return pt = Date.now() + (p - 60) * 1e3, $;
|
|
769
750
|
} catch (s) {
|
|
770
751
|
return console.error("Error obtaining JWT token:", s), $ = null, pt = null, null;
|
|
771
752
|
}
|
|
772
|
-
},
|
|
753
|
+
}, S = async () => {
|
|
773
754
|
const s = await Ot();
|
|
774
|
-
s != null &&
|
|
755
|
+
s != null && y(s);
|
|
775
756
|
};
|
|
776
757
|
M(() => {
|
|
777
758
|
if (t != null && t.siteId) {
|
|
778
|
-
const { clientID: s, host:
|
|
779
|
-
sessionStorage.setItem("Host",
|
|
759
|
+
const { clientID: s, host: w, organizationID: h, shortCode: g, siteId: p } = t;
|
|
760
|
+
sessionStorage.setItem("Host", w), sessionStorage.setItem("SiteId", p), sessionStorage.setItem("pubCfg", btoa(s)), sessionStorage.setItem("envRef", g), sessionStorage.setItem("orgRef", h);
|
|
780
761
|
}
|
|
781
|
-
|
|
762
|
+
S(), console.log("scapi environment v1");
|
|
782
763
|
}, []), M(() => {
|
|
783
|
-
e && (console.log("setting the basket id", e),
|
|
764
|
+
e && (console.log("setting the basket id", e), nt(e));
|
|
784
765
|
}, [e]), M(() => {
|
|
785
766
|
const s = async () => {
|
|
786
|
-
|
|
767
|
+
k(!1);
|
|
787
768
|
};
|
|
788
769
|
return window.addEventListener("reactCartUpdated", s), () => window.removeEventListener("reactCartUpdated", s);
|
|
789
770
|
}, []);
|
|
@@ -792,46 +773,46 @@ const at = (t) => {
|
|
|
792
773
|
sessionStorage.getItem("customerData") || "{}"
|
|
793
774
|
).customerId;
|
|
794
775
|
return (await Sr(s || "")).c_interests;
|
|
795
|
-
},
|
|
776
|
+
}, It = async (s, w) => {
|
|
796
777
|
console.log("in secondary flow", Nt);
|
|
797
|
-
const
|
|
798
|
-
if (console.log(
|
|
778
|
+
const h = await G();
|
|
779
|
+
if (console.log(h, "interests of customer", Nt), !!h)
|
|
799
780
|
try {
|
|
800
781
|
P(
|
|
801
782
|
(q) => q.map(
|
|
802
|
-
(
|
|
783
|
+
(V, Y) => Y === q.length - 1 ? { ...V, secondaryLoading: !0 } : V
|
|
803
784
|
)
|
|
804
785
|
);
|
|
805
|
-
const
|
|
806
|
-
if (!
|
|
807
|
-
const p = localStorage.getItem("customerNumber"),
|
|
808
|
-
registered: String(
|
|
786
|
+
const g = await Lt();
|
|
787
|
+
if (!g) throw new Error("Failed to fetch token");
|
|
788
|
+
const p = localStorage.getItem("customerNumber"), m = localStorage.getItem("isLoggedIn"), ft = `https://tanya.aspiresystems.com/api/bedrock/invoke/stream?${new URLSearchParams({
|
|
789
|
+
registered: String(m || !1),
|
|
809
790
|
userId: String(p || (/* @__PURE__ */ new Date()).getTime())
|
|
810
|
-
}).toString()}`,
|
|
791
|
+
}).toString()}`, ht = JSON.stringify({
|
|
811
792
|
flowId: "Q166PR519W",
|
|
812
793
|
flowAliasId: "HKFUVLWVH2",
|
|
813
794
|
input: {
|
|
814
795
|
loyaltyPoints: "",
|
|
815
796
|
productName: s,
|
|
816
|
-
productPoints: String(
|
|
817
|
-
interests:
|
|
797
|
+
productPoints: String(w || 0),
|
|
798
|
+
interests: h
|
|
818
799
|
}
|
|
819
|
-
}), B = await fetch(
|
|
800
|
+
}), B = await fetch(ft, {
|
|
820
801
|
signal: AbortSignal.timeout(3e4),
|
|
821
802
|
method: "POST",
|
|
822
803
|
headers: {
|
|
823
804
|
"Content-Type": "application/json",
|
|
824
|
-
Authorization: `Bearer ${
|
|
805
|
+
Authorization: `Bearer ${g}`
|
|
825
806
|
},
|
|
826
|
-
body:
|
|
807
|
+
body: ht
|
|
827
808
|
});
|
|
828
809
|
if (!B.body) throw new Error("Readable stream not supported");
|
|
829
|
-
const
|
|
810
|
+
const mt = B.body.getReader(), wt = new TextDecoder();
|
|
830
811
|
let U = "";
|
|
831
812
|
for (; ; ) {
|
|
832
|
-
const { done: q, value:
|
|
813
|
+
const { done: q, value: V } = await mt.read();
|
|
833
814
|
if (q) break;
|
|
834
|
-
U +=
|
|
815
|
+
U += wt.decode(V, { stream: !0 });
|
|
835
816
|
const Y = U.split(`
|
|
836
817
|
`);
|
|
837
818
|
U = Y.pop() || "";
|
|
@@ -858,16 +839,16 @@ const at = (t) => {
|
|
|
858
839
|
}
|
|
859
840
|
}
|
|
860
841
|
}
|
|
861
|
-
} catch (
|
|
862
|
-
console.error("Secondary flow error:",
|
|
842
|
+
} catch (g) {
|
|
843
|
+
console.error("Secondary flow error:", g);
|
|
863
844
|
}
|
|
864
845
|
}, L = async (s) => {
|
|
865
|
-
const
|
|
866
|
-
if (
|
|
867
|
-
|
|
868
|
-
...
|
|
846
|
+
const w = s || _t.trim();
|
|
847
|
+
if (w) {
|
|
848
|
+
St(!0), Ct(""), c.current = null, l.current = null, d.current = null, i.current = null, P((h) => [
|
|
849
|
+
...h,
|
|
869
850
|
{
|
|
870
|
-
query:
|
|
851
|
+
query: w,
|
|
871
852
|
response: "Thinking for what suits you best...",
|
|
872
853
|
potentialQuestions: "",
|
|
873
854
|
products: [],
|
|
@@ -875,38 +856,38 @@ const at = (t) => {
|
|
|
875
856
|
}
|
|
876
857
|
]);
|
|
877
858
|
try {
|
|
878
|
-
const
|
|
879
|
-
if (!
|
|
859
|
+
const h = dt, g = localStorage.getItem("customerNumber"), p = localStorage.getItem("isLoggedIn"), m = await Lt();
|
|
860
|
+
if (!m)
|
|
880
861
|
throw new Error("Failed to obtain access token");
|
|
881
|
-
const
|
|
862
|
+
const ft = `https://tanya.aspiresystems.com/api/bedrock/invoke/stream?${new URLSearchParams({
|
|
882
863
|
registered: String(p || !1),
|
|
883
|
-
userId: String(
|
|
884
|
-
}).toString()}`,
|
|
864
|
+
userId: String(g || (/* @__PURE__ */ new Date()).getTime())
|
|
865
|
+
}).toString()}`, ht = JSON.stringify({
|
|
885
866
|
flowId: "MMHQKYI1NE",
|
|
886
867
|
flowAliasId: "SZF9ZK1ATE",
|
|
887
868
|
input: {
|
|
888
|
-
userPrompt:
|
|
889
|
-
whom:
|
|
869
|
+
userPrompt: w,
|
|
870
|
+
whom: h
|
|
890
871
|
}
|
|
891
|
-
}), B = await fetch(
|
|
872
|
+
}), B = await fetch(ft, {
|
|
892
873
|
signal: AbortSignal.timeout(3e4),
|
|
893
874
|
method: "POST",
|
|
894
875
|
headers: {
|
|
895
876
|
"Content-Type": "application/json",
|
|
896
|
-
Authorization: `Bearer ${
|
|
877
|
+
Authorization: `Bearer ${m}`
|
|
897
878
|
},
|
|
898
|
-
body:
|
|
879
|
+
body: ht
|
|
899
880
|
});
|
|
900
881
|
if (!B.ok)
|
|
901
882
|
throw new Error(`HTTP error! status: ${B.status}`);
|
|
902
883
|
if (!B.body) throw new Error("Readable stream not supported");
|
|
903
|
-
const
|
|
884
|
+
const mt = B.body.getReader(), wt = new TextDecoder();
|
|
904
885
|
let U = "", q = "";
|
|
905
886
|
for (; ; ) {
|
|
906
887
|
et(!0);
|
|
907
|
-
const { done:
|
|
908
|
-
if (
|
|
909
|
-
U +=
|
|
888
|
+
const { done: V, value: Y } = await mt.read();
|
|
889
|
+
if (V) break;
|
|
890
|
+
U += wt.decode(Y, { stream: !0 });
|
|
910
891
|
const X = U.split(`
|
|
911
892
|
`);
|
|
912
893
|
U = X.pop() || "";
|
|
@@ -929,50 +910,50 @@ const at = (t) => {
|
|
|
929
910
|
}
|
|
930
911
|
}
|
|
931
912
|
or(rr(q));
|
|
932
|
-
} catch (
|
|
933
|
-
console.error("Error sending message to Tanya:",
|
|
913
|
+
} catch (h) {
|
|
914
|
+
console.error("Error sending message to Tanya:", h);
|
|
934
915
|
} finally {
|
|
935
|
-
|
|
916
|
+
St(!1);
|
|
936
917
|
}
|
|
937
918
|
}
|
|
938
919
|
}, rr = (s) => {
|
|
939
|
-
const
|
|
920
|
+
const w = s.match(
|
|
940
921
|
/top five relevant product or category names are: (.*)/i
|
|
941
|
-
), p = (
|
|
922
|
+
), p = (w ? w[1] : s).split(", ").map((A) => A.replace(/\s*(Toys|Bags|Miniature|etc\.*)\s*/gi, "").trim());
|
|
942
923
|
return [...new Set(p)].filter(Boolean).join(",");
|
|
943
924
|
}, or = async (s) => {
|
|
944
925
|
if (typeof s == "string") {
|
|
945
926
|
console.log(s, "keywords");
|
|
946
|
-
const
|
|
947
|
-
for (const
|
|
948
|
-
const
|
|
949
|
-
if (et(!1), (
|
|
927
|
+
const w = s.split(",");
|
|
928
|
+
for (const h of w) {
|
|
929
|
+
const g = await xe(h);
|
|
930
|
+
if (et(!1), (g == null ? void 0 : g.length) > 0 && (P(
|
|
950
931
|
(p) => p.map(
|
|
951
|
-
(
|
|
952
|
-
...
|
|
932
|
+
(m, A) => A === p.length - 1 ? {
|
|
933
|
+
...m,
|
|
953
934
|
products: [
|
|
954
|
-
...
|
|
955
|
-
{ keyword:
|
|
935
|
+
...m.products || [],
|
|
936
|
+
{ keyword: h, items: g, loading: !1 }
|
|
956
937
|
]
|
|
957
|
-
} :
|
|
938
|
+
} : m
|
|
958
939
|
)
|
|
959
940
|
), !c.current || l.current == null)) {
|
|
960
|
-
const p =
|
|
941
|
+
const p = g[0];
|
|
961
942
|
c.current = String((p == null ? void 0 : p.product_name) ?? ""), d.current = p.image.link, l.current = p.product_id;
|
|
962
|
-
const
|
|
963
|
-
i.current = typeof
|
|
943
|
+
const m = typeof (p == null ? void 0 : p.price) == "number" ? p.price : void 0;
|
|
944
|
+
i.current = typeof m == "number" && Number.isFinite(m) ? m : null;
|
|
964
945
|
}
|
|
965
946
|
}
|
|
966
947
|
} else
|
|
967
|
-
for (const
|
|
968
|
-
const
|
|
969
|
-
et(!1), (
|
|
970
|
-
(
|
|
971
|
-
(p,
|
|
948
|
+
for (const w of s) {
|
|
949
|
+
const h = await xe(w);
|
|
950
|
+
et(!1), (h == null ? void 0 : h.length) > 0 && P(
|
|
951
|
+
(g) => g.map(
|
|
952
|
+
(p, m) => m === g.length - 1 ? {
|
|
972
953
|
...p,
|
|
973
954
|
products: [
|
|
974
955
|
...p.products || [],
|
|
975
|
-
{ keyword:
|
|
956
|
+
{ keyword: w, items: h, loading: !1 }
|
|
976
957
|
]
|
|
977
958
|
} : p
|
|
978
959
|
)
|
|
@@ -980,9 +961,9 @@ const at = (t) => {
|
|
|
980
961
|
}
|
|
981
962
|
if (c.current) {
|
|
982
963
|
P(
|
|
983
|
-
(
|
|
984
|
-
(
|
|
985
|
-
...
|
|
964
|
+
(h) => h.map(
|
|
965
|
+
(g, p) => p === h.length - 1 ? {
|
|
966
|
+
...g,
|
|
986
967
|
productSnapshot: {
|
|
987
968
|
id: l.current,
|
|
988
969
|
name: c.current,
|
|
@@ -991,22 +972,22 @@ const at = (t) => {
|
|
|
991
972
|
points: 0,
|
|
992
973
|
quantity: 1
|
|
993
974
|
}
|
|
994
|
-
} :
|
|
975
|
+
} : g
|
|
995
976
|
)
|
|
996
977
|
);
|
|
997
|
-
const
|
|
978
|
+
const w = JSON.parse(
|
|
998
979
|
sessionStorage.getItem("customerData") || "{}"
|
|
999
980
|
);
|
|
1000
|
-
(
|
|
981
|
+
(w == null ? void 0 : w.isGuest) == !1 ? (console.log("running secondary flow", Nt), It(c.current, 0)) : console.log("not running secondary flow", Nt);
|
|
1001
982
|
}
|
|
1002
983
|
et(!1);
|
|
1003
|
-
}, nr = async (s,
|
|
1004
|
-
var
|
|
1005
|
-
|
|
984
|
+
}, nr = async (s, w) => {
|
|
985
|
+
var h, g, p, m, A, ft, ht, B, mt, wt, U, q, V, Y, X;
|
|
986
|
+
R(!0);
|
|
1006
987
|
try {
|
|
1007
|
-
const f = await
|
|
1008
|
-
if (!((
|
|
1009
|
-
|
|
988
|
+
const f = await Re(s.id);
|
|
989
|
+
if (!((g = (h = f == null ? void 0 : f.variants) == null ? void 0 : h[0]) != null && g.product_id || (m = (p = f == null ? void 0 : f.variants) == null ? void 0 : p[0]) != null && m.productId) && !(f.type.item || f.type.bundle)) {
|
|
990
|
+
R(!1), H.error("Variants not found", {
|
|
1010
991
|
position: "bottom-right",
|
|
1011
992
|
autoClose: 1e3
|
|
1012
993
|
}), console.error("No product variant found");
|
|
@@ -1014,8 +995,8 @@ const at = (t) => {
|
|
|
1014
995
|
}
|
|
1015
996
|
const K = [
|
|
1016
997
|
{
|
|
1017
|
-
product_id: ((A = f.variants) == null ? void 0 : A[0].product_id) || ((
|
|
1018
|
-
quantity:
|
|
998
|
+
product_id: ((A = f.variants) == null ? void 0 : A[0].product_id) || ((ft = f.variants) == null ? void 0 : ft[0].productId) || (f == null ? void 0 : f.id),
|
|
999
|
+
quantity: w
|
|
1019
1000
|
}
|
|
1020
1001
|
];
|
|
1021
1002
|
console.log(K, "product data", "app version", Nt);
|
|
@@ -1024,89 +1005,89 @@ const at = (t) => {
|
|
|
1024
1005
|
), O = (I == null ? void 0 : I.basketId) || localStorage.getItem(Yt), Q = !1, Bt = localStorage.getItem(Pt), we = Date.now();
|
|
1025
1006
|
if (!Q || !Bt || we >= parseInt(Bt)) {
|
|
1026
1007
|
const ar = await Me();
|
|
1027
|
-
let { customer_token:
|
|
1008
|
+
let { customer_token: gt } = await He(
|
|
1028
1009
|
ar
|
|
1029
1010
|
);
|
|
1030
|
-
if (
|
|
1011
|
+
if (gt = "Bearer " + x.access_token, !gt) {
|
|
1031
1012
|
console.error("Failed to get customer_token");
|
|
1032
1013
|
return;
|
|
1033
1014
|
}
|
|
1034
1015
|
const ir = we + 300 * 1e3;
|
|
1035
|
-
if (Kt(
|
|
1016
|
+
if (Kt(gt), localStorage.setItem(Pt, ir.toString()), console.log(O, "basketIdFromCustomer"), O) {
|
|
1036
1017
|
const ge = await Ye({
|
|
1037
1018
|
basketId: O,
|
|
1038
|
-
customer_token:
|
|
1019
|
+
customer_token: gt
|
|
1039
1020
|
});
|
|
1040
1021
|
if (ge.status === 200 && ge) {
|
|
1041
1022
|
const Gt = await ne(
|
|
1042
1023
|
O,
|
|
1043
1024
|
K,
|
|
1044
|
-
|
|
1025
|
+
gt
|
|
1045
1026
|
);
|
|
1046
|
-
((
|
|
1027
|
+
((ht = Gt == null ? void 0 : Gt.product_items) == null ? void 0 : ht.length) > 0 && (H.success("Added to cart", {
|
|
1047
1028
|
position: "bottom-right",
|
|
1048
1029
|
autoClose: 3e3,
|
|
1049
1030
|
hideProgressBar: !1,
|
|
1050
1031
|
closeOnClick: !0,
|
|
1051
1032
|
pauseOnHover: !0,
|
|
1052
1033
|
draggable: !0
|
|
1053
|
-
}),
|
|
1034
|
+
}), Vt(O), R(!1));
|
|
1054
1035
|
return;
|
|
1055
1036
|
}
|
|
1056
1037
|
}
|
|
1057
1038
|
const sr = {
|
|
1058
1039
|
productItems: [
|
|
1059
1040
|
{
|
|
1060
|
-
productId: ((B = f.variants) == null ? void 0 : B[0].product_id) || ((
|
|
1041
|
+
productId: ((B = f.variants) == null ? void 0 : B[0].product_id) || ((mt = f.variants) == null ? void 0 : mt[0].productId) || (f == null ? void 0 : f.id),
|
|
1061
1042
|
quantity: 1
|
|
1062
1043
|
}
|
|
1063
1044
|
]
|
|
1064
|
-
},
|
|
1045
|
+
}, b = await Ve(gt, sr);
|
|
1065
1046
|
if (console.log(
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1047
|
+
b,
|
|
1048
|
+
b == null ? void 0 : b.basket_id,
|
|
1049
|
+
b == null ? void 0 : b.basketId,
|
|
1069
1050
|
"the basket response"
|
|
1070
|
-
), !(
|
|
1071
|
-
|
|
1051
|
+
), !(b != null && b.basket_id || !(b != null && b.basketId))) {
|
|
1052
|
+
R(!1), console.error("Failed to create basket");
|
|
1072
1053
|
return;
|
|
1073
1054
|
}
|
|
1074
|
-
|
|
1075
|
-
(
|
|
1055
|
+
nt(
|
|
1056
|
+
(b == null ? void 0 : b.basket_id) || (b == null ? void 0 : b.basketId)
|
|
1076
1057
|
);
|
|
1077
|
-
const
|
|
1058
|
+
const bt = await r(
|
|
1078
1059
|
{
|
|
1079
1060
|
productId: l,
|
|
1080
|
-
quantity:
|
|
1061
|
+
quantity: w
|
|
1081
1062
|
},
|
|
1082
|
-
(
|
|
1063
|
+
(b == null ? void 0 : b.basket_id) || (b == null ? void 0 : b.basketId)
|
|
1083
1064
|
);
|
|
1084
|
-
(((
|
|
1065
|
+
(((wt = bt == null ? void 0 : bt.product_items) == null ? void 0 : wt.length) > 0 || ((U = bt == null ? void 0 : bt.productItems) == null ? void 0 : U.length) > 0) && H.success("Added to cart", {
|
|
1085
1066
|
position: "bottom-right",
|
|
1086
1067
|
autoClose: 3e3,
|
|
1087
1068
|
hideProgressBar: !1,
|
|
1088
1069
|
closeOnClick: !0,
|
|
1089
1070
|
pauseOnHover: !0,
|
|
1090
1071
|
draggable: !0
|
|
1091
|
-
}),
|
|
1072
|
+
}), Vt(b.basket_id || (b == null ? void 0 : b.basketId));
|
|
1092
1073
|
}
|
|
1093
1074
|
} catch (f) {
|
|
1094
|
-
|
|
1075
|
+
R(!1), console.error("Error adding to cart:", f), H.error("Failed to add product to cart", {
|
|
1095
1076
|
position: "bottom-right",
|
|
1096
1077
|
autoClose: 3e3
|
|
1097
1078
|
}), ((q = f == null ? void 0 : f.response) == null ? void 0 : q.status) === 404 || // Basket not found
|
|
1098
|
-
((
|
|
1079
|
+
((V = f == null ? void 0 : f.response) == null ? void 0 : V.status) === 401 ? (((Y = f == null ? void 0 : f.response) == null ? void 0 : Y.status) === 404 && nt(null), ((X = f == null ? void 0 : f.response) == null ? void 0 : X.status) === 401 && (nt(null), Kt(null))) : (console.error("Failed to add product to basket:", f.message), H.error("Failed to add product to cart", {
|
|
1099
1080
|
position: "bottom-right",
|
|
1100
1081
|
autoClose: 3e3
|
|
1101
1082
|
}));
|
|
1102
1083
|
}
|
|
1103
|
-
|
|
1084
|
+
R(!1);
|
|
1104
1085
|
};
|
|
1105
|
-
return /* @__PURE__ */ a("div", { className: "relative flex justify-center", children: /* @__PURE__ */ u(vr, { open: C, onOpenChange:
|
|
1086
|
+
return /* @__PURE__ */ a("div", { className: "relative flex justify-center", children: /* @__PURE__ */ u(vr, { open: C, onOpenChange: k, children: [
|
|
1106
1087
|
/* @__PURE__ */ a(
|
|
1107
1088
|
kr,
|
|
1108
1089
|
{
|
|
1109
|
-
onClick: () =>
|
|
1090
|
+
onClick: () => k(!0),
|
|
1110
1091
|
style: {
|
|
1111
1092
|
// background: storeDetails.tanyaThemeColor,
|
|
1112
1093
|
},
|
|
@@ -1171,7 +1152,7 @@ const at = (t) => {
|
|
|
1171
1152
|
"div",
|
|
1172
1153
|
{
|
|
1173
1154
|
className: "fixed inset-0 z-40 bg-black/30",
|
|
1174
|
-
onClick: () =>
|
|
1155
|
+
onClick: () => k(!1)
|
|
1175
1156
|
}
|
|
1176
1157
|
),
|
|
1177
1158
|
/* @__PURE__ */ u(
|
|
@@ -1201,7 +1182,7 @@ const at = (t) => {
|
|
|
1201
1182
|
{
|
|
1202
1183
|
style: {
|
|
1203
1184
|
display: "flex",
|
|
1204
|
-
color:
|
|
1185
|
+
color: v.tanyaThemeContrastColor,
|
|
1205
1186
|
alignItems: "center",
|
|
1206
1187
|
gap: "0.5rem"
|
|
1207
1188
|
},
|
|
@@ -1262,7 +1243,7 @@ const at = (t) => {
|
|
|
1262
1243
|
gap: "1.25rem",
|
|
1263
1244
|
margin: "0.75rem"
|
|
1264
1245
|
},
|
|
1265
|
-
children: /* @__PURE__ */ a("button", { onClick: () =>
|
|
1246
|
+
children: /* @__PURE__ */ a("button", { onClick: () => k(!1), children: /* @__PURE__ */ u(
|
|
1266
1247
|
"svg",
|
|
1267
1248
|
{
|
|
1268
1249
|
width: "24",
|
|
@@ -1314,7 +1295,7 @@ const at = (t) => {
|
|
|
1314
1295
|
/* @__PURE__ */ u(
|
|
1315
1296
|
"div",
|
|
1316
1297
|
{
|
|
1317
|
-
className: `flex flex-col h-full ${
|
|
1298
|
+
className: `flex flex-col h-full ${ut ? "lg:w-2/3 w-full" : "w-full"}`,
|
|
1318
1299
|
children: [
|
|
1319
1300
|
/* @__PURE__ */ u(
|
|
1320
1301
|
"div",
|
|
@@ -1322,7 +1303,7 @@ const at = (t) => {
|
|
|
1322
1303
|
ref: _,
|
|
1323
1304
|
className: "overflow-y-auto pr-5 pb-2 space-y-4 hide-scrollbar flex-grow mb-24",
|
|
1324
1305
|
children: [
|
|
1325
|
-
(
|
|
1306
|
+
(v == null ? void 0 : v.whomRequired) && /* @__PURE__ */ u(
|
|
1326
1307
|
"div",
|
|
1327
1308
|
{
|
|
1328
1309
|
className: "mx-3 p-3 rounded-2xl bg-[#FFFFFF]",
|
|
@@ -1334,8 +1315,8 @@ const at = (t) => {
|
|
|
1334
1315
|
onClick: () => Dt(s),
|
|
1335
1316
|
className: "px-2 py-2 font-semibold text-xs text-[#18181B] bg-[#F3F3F3] rounded-2xl",
|
|
1336
1317
|
style: {
|
|
1337
|
-
backgroundColor:
|
|
1338
|
-
borderColor:
|
|
1318
|
+
backgroundColor: dt === n[s] ? "#FFFFFF" : "#F3F3F3",
|
|
1319
|
+
borderColor: dt === n[s] ? "#BBB3DD" : ""
|
|
1339
1320
|
},
|
|
1340
1321
|
children: s
|
|
1341
1322
|
},
|
|
@@ -1344,8 +1325,8 @@ const at = (t) => {
|
|
|
1344
1325
|
]
|
|
1345
1326
|
}
|
|
1346
1327
|
),
|
|
1347
|
-
rt.map((s,
|
|
1348
|
-
var
|
|
1328
|
+
rt.map((s, w) => {
|
|
1329
|
+
var h, g;
|
|
1349
1330
|
return /* @__PURE__ */ u("div", { children: [
|
|
1350
1331
|
/* @__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: s.query }) }),
|
|
1351
1332
|
s.response && s.response.includes("Thinking") ? /* @__PURE__ */ a("div", { children: /* @__PURE__ */ a(
|
|
@@ -1365,12 +1346,12 @@ const at = (t) => {
|
|
|
1365
1346
|
}
|
|
1366
1347
|
}
|
|
1367
1348
|
) }),
|
|
1368
|
-
$t && !s.response.includes("Thinking") && ((
|
|
1369
|
-
(s == null ? void 0 : s.products) && ((
|
|
1349
|
+
$t && !s.response.includes("Thinking") && ((h = s.products) == null ? void 0 : h.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" }) }),
|
|
1350
|
+
(s == null ? void 0 : s.products) && ((g = s == null ? void 0 : s.products) == null ? void 0 : g.length) > 0 && /* @__PURE__ */ a(
|
|
1370
1351
|
Nr,
|
|
1371
1352
|
{
|
|
1372
1353
|
chat: s.products,
|
|
1373
|
-
storeDetails:
|
|
1354
|
+
storeDetails: v
|
|
1374
1355
|
}
|
|
1375
1356
|
),
|
|
1376
1357
|
s.potentialQuestions.length > 0 && /* @__PURE__ */ u("div", { className: "my-2 px-4 text-sm text-gray-700", children: [
|
|
@@ -1378,21 +1359,21 @@ const at = (t) => {
|
|
|
1378
1359
|
"p",
|
|
1379
1360
|
{
|
|
1380
1361
|
className: "font-nunitoSans font-bold text-sm text-[#494949]",
|
|
1381
|
-
style: { color:
|
|
1362
|
+
style: { color: v.themeDarkColor },
|
|
1382
1363
|
children: "Why not explore these inquiries..."
|
|
1383
1364
|
}
|
|
1384
1365
|
),
|
|
1385
|
-
s.potentialQuestions.split(",").map((p,
|
|
1366
|
+
s.potentialQuestions.split(",").map((p, m) => /* @__PURE__ */ a(
|
|
1386
1367
|
"button",
|
|
1387
1368
|
{
|
|
1388
|
-
className: `cursor-pointer font-nunitoSans font-semibold text-[#232323] border bg-[#804C9E0D] border-${
|
|
1369
|
+
className: `cursor-pointer font-nunitoSans font-semibold text-[#232323] border bg-[#804C9E0D] border-${v.themeDarkColor} m-1 rounded-xl px-2 py-1`,
|
|
1389
1370
|
onClick: () => L(p),
|
|
1390
1371
|
style: {
|
|
1391
|
-
backgroundColor:
|
|
1372
|
+
backgroundColor: v.tanyaThemeColorLight
|
|
1392
1373
|
},
|
|
1393
1374
|
children: p
|
|
1394
1375
|
},
|
|
1395
|
-
|
|
1376
|
+
m
|
|
1396
1377
|
))
|
|
1397
1378
|
] }),
|
|
1398
1379
|
s.secondaryLoading && /* @__PURE__ */ a("div", { className: "mt-3 mb-4 px-4", children: /* @__PURE__ */ u(
|
|
@@ -1413,7 +1394,7 @@ const at = (t) => {
|
|
|
1413
1394
|
"p",
|
|
1414
1395
|
{
|
|
1415
1396
|
className: "font-semibold tanya-pulse",
|
|
1416
|
-
style: { color:
|
|
1397
|
+
style: { color: v.themeDarkColor },
|
|
1417
1398
|
children: "I’ve found a special surprise crafted just for you… hang on a sec!"
|
|
1418
1399
|
}
|
|
1419
1400
|
),
|
|
@@ -1421,7 +1402,7 @@ const at = (t) => {
|
|
|
1421
1402
|
"p",
|
|
1422
1403
|
{
|
|
1423
1404
|
className: "tanya-dots mt-1",
|
|
1424
|
-
style: { color:
|
|
1405
|
+
style: { color: v.themeDarkColor },
|
|
1425
1406
|
children: "• • •"
|
|
1426
1407
|
}
|
|
1427
1408
|
)
|
|
@@ -1434,7 +1415,7 @@ const at = (t) => {
|
|
|
1434
1415
|
{
|
|
1435
1416
|
className: "text-sm text-[#232323] bg-[#FFFFFF] px-7 py-4 rounded-br-xl rounded-bl-2xl w-full",
|
|
1436
1417
|
style: {
|
|
1437
|
-
backgroundColor:
|
|
1418
|
+
backgroundColor: v.tanyaThemeColorLight
|
|
1438
1419
|
},
|
|
1439
1420
|
dangerouslySetInnerHTML: {
|
|
1440
1421
|
__html: Xt(
|
|
@@ -1449,7 +1430,7 @@ const at = (t) => {
|
|
|
1449
1430
|
{
|
|
1450
1431
|
className: "flex gap-4 items-stretch rounded-2xl p-4",
|
|
1451
1432
|
style: {
|
|
1452
|
-
backgroundColor:
|
|
1433
|
+
backgroundColor: v.tanyaThemeColorLight
|
|
1453
1434
|
},
|
|
1454
1435
|
children: [
|
|
1455
1436
|
/* @__PURE__ */ a(
|
|
@@ -1476,7 +1457,7 @@ const at = (t) => {
|
|
|
1476
1457
|
/* @__PURE__ */ a("p", { className: "font-semibold text-[15px] leading-snug", children: s.productSnapshot.name }),
|
|
1477
1458
|
/* @__PURE__ */ a("p", { className: "mt-1 text-[14px] font-medium", children: s.productSnapshot.price != null ? new Intl.NumberFormat(void 0, {
|
|
1478
1459
|
style: "currency",
|
|
1479
|
-
currency: (
|
|
1460
|
+
currency: (v == null ? void 0 : v.currency) || "USD"
|
|
1480
1461
|
}).format(
|
|
1481
1462
|
s.productSnapshot.price
|
|
1482
1463
|
) : "" }),
|
|
@@ -1498,21 +1479,21 @@ const at = (t) => {
|
|
|
1498
1479
|
className: "px-3 py-1 text-sm",
|
|
1499
1480
|
onClick: () => P(
|
|
1500
1481
|
(p) => p.map(
|
|
1501
|
-
(
|
|
1502
|
-
...
|
|
1482
|
+
(m, A) => A === w && m.productSnapshot ? {
|
|
1483
|
+
...m,
|
|
1503
1484
|
productSnapshot: {
|
|
1504
|
-
...
|
|
1485
|
+
...m.productSnapshot,
|
|
1505
1486
|
quantity: Math.max(
|
|
1506
1487
|
1,
|
|
1507
|
-
|
|
1488
|
+
m.productSnapshot.quantity - 1
|
|
1508
1489
|
)
|
|
1509
1490
|
}
|
|
1510
|
-
} :
|
|
1491
|
+
} : m
|
|
1511
1492
|
)
|
|
1512
1493
|
),
|
|
1513
1494
|
style: {
|
|
1514
1495
|
background: "transparent",
|
|
1515
|
-
color:
|
|
1496
|
+
color: v.themeDarkColor
|
|
1516
1497
|
},
|
|
1517
1498
|
children: "−"
|
|
1518
1499
|
}
|
|
@@ -1524,18 +1505,18 @@ const at = (t) => {
|
|
|
1524
1505
|
className: "px-3 py-1 text-sm",
|
|
1525
1506
|
onClick: () => P(
|
|
1526
1507
|
(p) => p.map(
|
|
1527
|
-
(
|
|
1528
|
-
...
|
|
1508
|
+
(m, A) => A === w && m.productSnapshot ? {
|
|
1509
|
+
...m,
|
|
1529
1510
|
productSnapshot: {
|
|
1530
|
-
...
|
|
1531
|
-
quantity:
|
|
1511
|
+
...m.productSnapshot,
|
|
1512
|
+
quantity: m.productSnapshot.quantity + 1
|
|
1532
1513
|
}
|
|
1533
|
-
} :
|
|
1514
|
+
} : m
|
|
1534
1515
|
)
|
|
1535
1516
|
),
|
|
1536
1517
|
style: {
|
|
1537
1518
|
background: "transparent",
|
|
1538
|
-
color:
|
|
1519
|
+
color: v.themeDarkColor
|
|
1539
1520
|
},
|
|
1540
1521
|
children: "+"
|
|
1541
1522
|
}
|
|
@@ -1552,14 +1533,14 @@ const at = (t) => {
|
|
|
1552
1533
|
s.productSnapshot.quantity
|
|
1553
1534
|
);
|
|
1554
1535
|
},
|
|
1555
|
-
disabled:
|
|
1536
|
+
disabled: lt,
|
|
1556
1537
|
className: "px-4 py-2 rounded-full font-medium",
|
|
1557
1538
|
style: {
|
|
1558
|
-
background:
|
|
1559
|
-
color: (
|
|
1560
|
-
opacity:
|
|
1539
|
+
background: v.tanyaThemeColor,
|
|
1540
|
+
color: (v == null ? void 0 : v.tanyaThemeContrastColor) || "#fff",
|
|
1541
|
+
opacity: lt ? 0.8 : 1
|
|
1561
1542
|
},
|
|
1562
|
-
children:
|
|
1543
|
+
children: lt ? "Adding..." : "Add to cart"
|
|
1563
1544
|
}
|
|
1564
1545
|
)
|
|
1565
1546
|
] })
|
|
@@ -1569,7 +1550,7 @@ const at = (t) => {
|
|
|
1569
1550
|
) })
|
|
1570
1551
|
] }) }),
|
|
1571
1552
|
/* @__PURE__ */ a("div", { className: "mb-20" })
|
|
1572
|
-
] },
|
|
1553
|
+
] }, w);
|
|
1573
1554
|
})
|
|
1574
1555
|
]
|
|
1575
1556
|
}
|
|
@@ -1587,11 +1568,11 @@ const at = (t) => {
|
|
|
1587
1568
|
{
|
|
1588
1569
|
className: "flex-1 bg-[#FFFFFF] text-[#232323] outline-none border-none px-2 py-2 text-sm",
|
|
1589
1570
|
placeholder: "How can I help you...",
|
|
1590
|
-
value:
|
|
1571
|
+
value: _t,
|
|
1591
1572
|
autoFocus: !0,
|
|
1592
|
-
onChange: (s) =>
|
|
1573
|
+
onChange: (s) => Ct(s.target.value),
|
|
1593
1574
|
onKeyDown: (s) => {
|
|
1594
|
-
s.key === "Enter" && !
|
|
1575
|
+
s.key === "Enter" && !ct && L();
|
|
1595
1576
|
}
|
|
1596
1577
|
}
|
|
1597
1578
|
),
|
|
@@ -1599,16 +1580,16 @@ const at = (t) => {
|
|
|
1599
1580
|
"button",
|
|
1600
1581
|
{
|
|
1601
1582
|
type: "submit",
|
|
1602
|
-
disabled:
|
|
1583
|
+
disabled: ct,
|
|
1603
1584
|
className: "p-3",
|
|
1604
1585
|
onClick: () => L(),
|
|
1605
|
-
children:
|
|
1586
|
+
children: ct ? /* @__PURE__ */ a(
|
|
1606
1587
|
"div",
|
|
1607
1588
|
{
|
|
1608
1589
|
className: "p-3 animate-spin rounded-full h-3 w-3 border-b-2",
|
|
1609
1590
|
style: {
|
|
1610
1591
|
borderBottom: "2px solid",
|
|
1611
|
-
color:
|
|
1592
|
+
color: v.tanyaThemeColor
|
|
1612
1593
|
}
|
|
1613
1594
|
}
|
|
1614
1595
|
) : /* @__PURE__ */ a(
|
|
@@ -1691,7 +1672,7 @@ var Qt = "Invariant Violation", Ie = Object.setPrototypeOf, zr = Ie === void 0 ?
|
|
|
1691
1672
|
return e;
|
|
1692
1673
|
})(Error)
|
|
1693
1674
|
);
|
|
1694
|
-
function
|
|
1675
|
+
function ot(t, e) {
|
|
1695
1676
|
if (!t)
|
|
1696
1677
|
throw new Ke(e);
|
|
1697
1678
|
}
|
|
@@ -1706,21 +1687,21 @@ function Ut(t) {
|
|
|
1706
1687
|
}
|
|
1707
1688
|
(function(t) {
|
|
1708
1689
|
t.debug = Ut("debug"), t.log = Ut("log"), t.warn = Ut("warn"), t.error = Ut("error");
|
|
1709
|
-
})(
|
|
1690
|
+
})(ot || (ot = {}));
|
|
1710
1691
|
var We = "3.14.0";
|
|
1711
|
-
function
|
|
1692
|
+
function xt(t) {
|
|
1712
1693
|
try {
|
|
1713
1694
|
return t();
|
|
1714
1695
|
} catch {
|
|
1715
1696
|
}
|
|
1716
1697
|
}
|
|
1717
|
-
const ie =
|
|
1698
|
+
const ie = xt(function() {
|
|
1718
1699
|
return globalThis;
|
|
1719
|
-
}) ||
|
|
1700
|
+
}) || xt(function() {
|
|
1720
1701
|
return window;
|
|
1721
|
-
}) ||
|
|
1702
|
+
}) || xt(function() {
|
|
1722
1703
|
return self;
|
|
1723
|
-
}) ||
|
|
1704
|
+
}) || xt(function() {
|
|
1724
1705
|
return global;
|
|
1725
1706
|
}) || // We don't expect the Function constructor ever to be invoked at runtime, as
|
|
1726
1707
|
// long as at least one of globalThis, window, self, or global is defined, so
|
|
@@ -1728,8 +1709,8 @@ const ie = yt(function() {
|
|
|
1728
1709
|
// detect syntactic usage of the Function constructor. If you think you can
|
|
1729
1710
|
// improve your static analysis to detect this obfuscation, think again. This
|
|
1730
1711
|
// is an arms race you cannot win, at least not in JavaScript.
|
|
1731
|
-
|
|
1732
|
-
return
|
|
1712
|
+
xt(function() {
|
|
1713
|
+
return xt.constructor("return this")();
|
|
1733
1714
|
});
|
|
1734
1715
|
var Fe = /* @__PURE__ */ new Map();
|
|
1735
1716
|
function jr(t) {
|
|
@@ -1756,12 +1737,12 @@ function qt(t) {
|
|
|
1756
1737
|
var Zt = Object.assign(function(e, r) {
|
|
1757
1738
|
for (var o = [], n = 2; n < arguments.length; n++)
|
|
1758
1739
|
o[n - 2] = arguments[n];
|
|
1759
|
-
e ||
|
|
1740
|
+
e || ot(e, ce(r, o) || de(r, o));
|
|
1760
1741
|
}, {
|
|
1761
|
-
debug: qt(
|
|
1762
|
-
log: qt(
|
|
1763
|
-
warn: qt(
|
|
1764
|
-
error: qt(
|
|
1742
|
+
debug: qt(ot.debug),
|
|
1743
|
+
log: qt(ot.log),
|
|
1744
|
+
warn: qt(ot.warn),
|
|
1745
|
+
error: qt(ot.error)
|
|
1765
1746
|
});
|
|
1766
1747
|
function Ge(t) {
|
|
1767
1748
|
for (var e = [], r = 1; r < arguments.length; r++)
|
|
@@ -1942,7 +1923,7 @@ var fe = function() {
|
|
|
1942
1923
|
return he(t) ? Symbol[t] : "@@" + t;
|
|
1943
1924
|
};
|
|
1944
1925
|
fe() && !he("observable") && (Symbol.observable = Symbol("observable"));
|
|
1945
|
-
var
|
|
1926
|
+
var Rr = me("iterator"), se = me("observable"), Qe = me("species");
|
|
1946
1927
|
function Jt(t, e) {
|
|
1947
1928
|
var r = t[e];
|
|
1948
1929
|
if (r != null) {
|
|
@@ -1954,11 +1935,11 @@ function Et(t) {
|
|
|
1954
1935
|
var e = t.constructor;
|
|
1955
1936
|
return e !== void 0 && (e = e[Qe], e === null && (e = void 0)), e !== void 0 ? e : N;
|
|
1956
1937
|
}
|
|
1957
|
-
function
|
|
1938
|
+
function Vr(t) {
|
|
1958
1939
|
return t instanceof N;
|
|
1959
1940
|
}
|
|
1960
|
-
function
|
|
1961
|
-
|
|
1941
|
+
function vt(t) {
|
|
1942
|
+
vt.log ? vt.log(t) : setTimeout(function() {
|
|
1962
1943
|
throw t;
|
|
1963
1944
|
});
|
|
1964
1945
|
}
|
|
@@ -1967,7 +1948,7 @@ function Ht(t) {
|
|
|
1967
1948
|
try {
|
|
1968
1949
|
t();
|
|
1969
1950
|
} catch (e) {
|
|
1970
|
-
|
|
1951
|
+
vt(e);
|
|
1971
1952
|
}
|
|
1972
1953
|
});
|
|
1973
1954
|
}
|
|
@@ -1982,7 +1963,7 @@ function Ze(t) {
|
|
|
1982
1963
|
r && r.call(e);
|
|
1983
1964
|
}
|
|
1984
1965
|
} catch (o) {
|
|
1985
|
-
|
|
1966
|
+
vt(o);
|
|
1986
1967
|
}
|
|
1987
1968
|
}
|
|
1988
1969
|
function le(t) {
|
|
@@ -2014,7 +1995,7 @@ function tr(t, e, r) {
|
|
|
2014
1995
|
break;
|
|
2015
1996
|
}
|
|
2016
1997
|
} catch (c) {
|
|
2017
|
-
|
|
1998
|
+
vt(c);
|
|
2018
1999
|
}
|
|
2019
2000
|
t._state === "closed" ? Ze(t) : t._state === "running" && (t._state = "ready");
|
|
2020
2001
|
}
|
|
@@ -2100,11 +2081,11 @@ var Kr = /* @__PURE__ */ (function() {
|
|
|
2100
2081
|
i.unsubscribe(), c();
|
|
2101
2082
|
}
|
|
2102
2083
|
var i = n.subscribe({
|
|
2103
|
-
next: function(
|
|
2084
|
+
next: function(x) {
|
|
2104
2085
|
try {
|
|
2105
|
-
o(
|
|
2106
|
-
} catch (
|
|
2107
|
-
l(
|
|
2086
|
+
o(x, d);
|
|
2087
|
+
} catch (y) {
|
|
2088
|
+
l(y), i.unsubscribe();
|
|
2108
2089
|
}
|
|
2109
2090
|
},
|
|
2110
2091
|
error: l,
|
|
@@ -2158,26 +2139,26 @@ var Kr = /* @__PURE__ */ (function() {
|
|
|
2158
2139
|
}, e.reduce = function(o) {
|
|
2159
2140
|
var n = this;
|
|
2160
2141
|
if (typeof o != "function") throw new TypeError(o + " is not a function");
|
|
2161
|
-
var c = Et(this), l = arguments.length > 1, d = !1, i = arguments[1],
|
|
2162
|
-
return new c(function(
|
|
2142
|
+
var c = Et(this), l = arguments.length > 1, d = !1, i = arguments[1], x = i;
|
|
2143
|
+
return new c(function(y) {
|
|
2163
2144
|
return n.subscribe({
|
|
2164
2145
|
next: function(C) {
|
|
2165
|
-
var
|
|
2166
|
-
if (d = !0, !
|
|
2146
|
+
var k = !d;
|
|
2147
|
+
if (d = !0, !k || l)
|
|
2167
2148
|
try {
|
|
2168
|
-
|
|
2149
|
+
x = o(x, C);
|
|
2169
2150
|
} catch (j) {
|
|
2170
|
-
return
|
|
2151
|
+
return y.error(j);
|
|
2171
2152
|
}
|
|
2172
2153
|
else
|
|
2173
|
-
|
|
2154
|
+
x = C;
|
|
2174
2155
|
},
|
|
2175
2156
|
error: function(C) {
|
|
2176
|
-
|
|
2157
|
+
y.error(C);
|
|
2177
2158
|
},
|
|
2178
2159
|
complete: function() {
|
|
2179
|
-
if (!d && !l) return
|
|
2180
|
-
|
|
2160
|
+
if (!d && !l) return y.error(new TypeError("Cannot reduce an empty sequence"));
|
|
2161
|
+
y.next(x), y.complete();
|
|
2181
2162
|
}
|
|
2182
2163
|
});
|
|
2183
2164
|
});
|
|
@@ -2186,9 +2167,9 @@ var Kr = /* @__PURE__ */ (function() {
|
|
|
2186
2167
|
c[l] = arguments[l];
|
|
2187
2168
|
var d = Et(this);
|
|
2188
2169
|
return new d(function(i) {
|
|
2189
|
-
var
|
|
2190
|
-
function C(
|
|
2191
|
-
|
|
2170
|
+
var x, y = 0;
|
|
2171
|
+
function C(k) {
|
|
2172
|
+
x = k.subscribe({
|
|
2192
2173
|
next: function(j) {
|
|
2193
2174
|
i.next(j);
|
|
2194
2175
|
},
|
|
@@ -2196,12 +2177,12 @@ var Kr = /* @__PURE__ */ (function() {
|
|
|
2196
2177
|
i.error(j);
|
|
2197
2178
|
},
|
|
2198
2179
|
complete: function() {
|
|
2199
|
-
|
|
2180
|
+
y === c.length ? (x = void 0, i.complete()) : C(d.from(c[y++]));
|
|
2200
2181
|
}
|
|
2201
2182
|
});
|
|
2202
2183
|
}
|
|
2203
2184
|
return C(o), function() {
|
|
2204
|
-
|
|
2185
|
+
x && (x.unsubscribe(), x = void 0);
|
|
2205
2186
|
};
|
|
2206
2187
|
});
|
|
2207
2188
|
}, e.flatMap = function(o) {
|
|
@@ -2210,40 +2191,40 @@ var Kr = /* @__PURE__ */ (function() {
|
|
|
2210
2191
|
var c = Et(this);
|
|
2211
2192
|
return new c(function(l) {
|
|
2212
2193
|
var d = [], i = n.subscribe({
|
|
2213
|
-
next: function(
|
|
2194
|
+
next: function(y) {
|
|
2214
2195
|
if (o)
|
|
2215
2196
|
try {
|
|
2216
|
-
|
|
2217
|
-
} catch (
|
|
2218
|
-
return l.error(
|
|
2197
|
+
y = o(y);
|
|
2198
|
+
} catch (k) {
|
|
2199
|
+
return l.error(k);
|
|
2219
2200
|
}
|
|
2220
|
-
var C = c.from(
|
|
2221
|
-
next: function(
|
|
2222
|
-
l.next(
|
|
2201
|
+
var C = c.from(y).subscribe({
|
|
2202
|
+
next: function(k) {
|
|
2203
|
+
l.next(k);
|
|
2223
2204
|
},
|
|
2224
|
-
error: function(
|
|
2225
|
-
l.error(
|
|
2205
|
+
error: function(k) {
|
|
2206
|
+
l.error(k);
|
|
2226
2207
|
},
|
|
2227
2208
|
complete: function() {
|
|
2228
|
-
var
|
|
2229
|
-
|
|
2209
|
+
var k = d.indexOf(C);
|
|
2210
|
+
k >= 0 && d.splice(k, 1), x();
|
|
2230
2211
|
}
|
|
2231
2212
|
});
|
|
2232
2213
|
d.push(C);
|
|
2233
2214
|
},
|
|
2234
|
-
error: function(
|
|
2235
|
-
l.error(
|
|
2215
|
+
error: function(y) {
|
|
2216
|
+
l.error(y);
|
|
2236
2217
|
},
|
|
2237
2218
|
complete: function() {
|
|
2238
|
-
|
|
2219
|
+
x();
|
|
2239
2220
|
}
|
|
2240
2221
|
});
|
|
2241
|
-
function
|
|
2222
|
+
function x() {
|
|
2242
2223
|
i.closed && d.length === 0 && l.complete();
|
|
2243
2224
|
}
|
|
2244
2225
|
return function() {
|
|
2245
|
-
d.forEach(function(
|
|
2246
|
-
return
|
|
2226
|
+
d.forEach(function(y) {
|
|
2227
|
+
return y.unsubscribe();
|
|
2247
2228
|
}), i.unsubscribe();
|
|
2248
2229
|
};
|
|
2249
2230
|
});
|
|
@@ -2256,17 +2237,17 @@ var Kr = /* @__PURE__ */ (function() {
|
|
|
2256
2237
|
if (c) {
|
|
2257
2238
|
var l = c.call(o);
|
|
2258
2239
|
if (Object(l) !== l) throw new TypeError(l + " is not an object");
|
|
2259
|
-
return
|
|
2240
|
+
return Vr(l) && l.constructor === n ? l : new n(function(d) {
|
|
2260
2241
|
return l.subscribe(d);
|
|
2261
2242
|
});
|
|
2262
2243
|
}
|
|
2263
|
-
if (he("iterator") && (c = Jt(o,
|
|
2244
|
+
if (he("iterator") && (c = Jt(o, Rr), c))
|
|
2264
2245
|
return new n(function(d) {
|
|
2265
2246
|
Ht(function() {
|
|
2266
2247
|
if (!d.closed) {
|
|
2267
|
-
for (var i = Mr(c.call(o)),
|
|
2268
|
-
var
|
|
2269
|
-
if (d.next(
|
|
2248
|
+
for (var i = Mr(c.call(o)), x; !(x = i()).done; ) {
|
|
2249
|
+
var y = x.value;
|
|
2250
|
+
if (d.next(y), d.closed) return;
|
|
2270
2251
|
}
|
|
2271
2252
|
d.complete();
|
|
2272
2253
|
}
|
|
@@ -2306,7 +2287,7 @@ var Kr = /* @__PURE__ */ (function() {
|
|
|
2306
2287
|
fe() && Object.defineProperty(N, Symbol("extensions"), {
|
|
2307
2288
|
value: {
|
|
2308
2289
|
symbol: se,
|
|
2309
|
-
hostReportError:
|
|
2290
|
+
hostReportError: vt
|
|
2310
2291
|
},
|
|
2311
2292
|
configurable: !0
|
|
2312
2293
|
});
|
|
@@ -2326,9 +2307,9 @@ function Wr(t) {
|
|
|
2326
2307
|
e = "@@observable";
|
|
2327
2308
|
return e;
|
|
2328
2309
|
}
|
|
2329
|
-
var
|
|
2330
|
-
typeof self < "u" ?
|
|
2331
|
-
Wr(
|
|
2310
|
+
var yt;
|
|
2311
|
+
typeof self < "u" ? yt = self : typeof window < "u" ? yt = window : typeof global < "u" ? yt = global : typeof module < "u" ? yt = module : yt = Function("return this")();
|
|
2312
|
+
Wr(yt);
|
|
2332
2313
|
var ze = N.prototype, Ae = "@@observable";
|
|
2333
2314
|
ze[Ae] || (ze[Ae] = function() {
|
|
2334
2315
|
return this;
|