tanya-chatbot 0.5.5 → 0.5.6

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.
@@ -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=${Y()}`
104
+ `${t}api/auth/token-bm-grant?baseUrl=${Q()}&siteId=${Y()}`
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=${Y()}&pubCfg=${it()}&envRef=${st()}&orgRef=${lt()}`,
114
+ `${e}api/auth/token-existing-guest-customer?dwsid=${r}&baseUrl=${Q()}&siteId=${Y()}&pubCfg=${it()}&envRef=${st()}&orgRef=${lt()}`,
115
115
  {},
116
116
  {
117
117
  headers: {
@@ -130,7 +130,7 @@ async function $t() {
130
130
  const t = Y(), 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 Z = () => sessionStorage.getItem("Host"), Y = () => sessionStorage.getItem("SiteId"), it = () => sessionStorage.getItem("pubCfg"), st = () => sessionStorage.getItem("envRef"), lt = () => sessionStorage.getItem("orgRef"), ye = async (t) => {
133
+ const Q = () => sessionStorage.getItem("Host"), Y = () => sessionStorage.getItem("SiteId"), it = () => sessionStorage.getItem("pubCfg"), st = () => sessionStorage.getItem("envRef"), lt = () => sessionStorage.getItem("orgRef"), ye = async (t) => {
134
134
  console.log("fetching results");
135
135
  const { serverUrl: e, basePath: r } = St();
136
136
  let o = "";
@@ -139,7 +139,7 @@ const Z = () => sessionStorage.getItem("Host"), Y = () => sessionStorage.getItem
139
139
  console.log("the token from getSearchResults", n), o = n.access_token;
140
140
  }
141
141
  try {
142
- const n = Z();
142
+ const n = Q();
143
143
  return (await E.get(
144
144
  `${e}${r}/search-sfcc?baseUrl=${n}&query=${t}&siteId=${Y()}&pubCfg=${it()}&envRef=${st()}&orgRef=${lt()}`,
145
145
  {
@@ -154,7 +154,7 @@ const Z = () => sessionStorage.getItem("Host"), Y = () => sessionStorage.getItem
154
154
  }
155
155
  }, Ve = async (t) => {
156
156
  if (!t) throw new Error("Product ID is required");
157
- const { serverUrl: e, basePath: r } = St(), o = Z();
157
+ const { serverUrl: e, basePath: r } = St(), o = Q();
158
158
  console.log("calling access");
159
159
  const { access_token: n } = await $t();
160
160
  return (await E.get(
@@ -172,7 +172,7 @@ const Z = () => sessionStorage.getItem("Host"), Y = () => sessionStorage.getItem
172
172
  e
173
173
  ), { serverUrl: o, basePath: n } = St(), l = (await $t()).access_token;
174
174
  return (await E.get(
175
- `${o}${n}/get-interest?baseUrl=${Z()}&customerId=${t}&siteId=${Y()}&pubCfg=${it()}&envRef=${st()}&orgRef=${lt()}`,
175
+ `${o}${n}/get-interest?baseUrl=${Q()}&customerId=${t}&siteId=${Y()}&pubCfg=${it()}&envRef=${st()}&orgRef=${lt()}`,
176
176
  {
177
177
  headers: {
178
178
  "Content-Type": "application/json",
@@ -342,7 +342,7 @@ const Nr = ({
342
342
  const { serverUrl: r, basePath: o } = St(), n = `${r}`;
343
343
  try {
344
344
  const d = await E.post(
345
- `${n}${o}/basket/create?baseUrl=${Z()}&siteId=${Y()}&pubCfg=${it()}&envRef=${st()}&orgRef=${lt()}`,
345
+ `${n}${o}/basket/create?baseUrl=${Q()}&siteId=${Y()}&pubCfg=${it()}&envRef=${st()}&orgRef=${lt()}`,
346
346
  e,
347
347
  {
348
348
  headers: {
@@ -365,7 +365,7 @@ const Nr = ({
365
365
  const { serverUrl: o, basePath: n } = St(), c = `${o}`;
366
366
  try {
367
367
  const l = await E.post(
368
- `${c}${n}/basket/add-product/${t}?baseUrl=${Z()}&siteId=${Y()}&pubCfg=${it()}&envRef=${st()}&orgRef=${lt()}`,
368
+ `${c}${n}/basket/add-product/${t}?baseUrl=${Q()}&siteId=${Y()}&pubCfg=${it()}&envRef=${st()}&orgRef=${lt()}`,
369
369
  e,
370
370
  {
371
371
  headers: {
@@ -389,7 +389,7 @@ const Nr = ({
389
389
  const { serverUrl: r, basePath: o } = St(), n = `${r}`;
390
390
  try {
391
391
  const l = await E.get(
392
- `${n}${o}/basket/${t}?baseUrl=${Z()}&siteId=${Y()}&pubCfg=${it()}&envRef=${st()}&orgRef=${lt()}`,
392
+ `${n}${o}/basket/${t}?baseUrl=${Q()}&siteId=${Y()}&pubCfg=${it()}&envRef=${st()}&orgRef=${lt()}`,
393
393
  {
394
394
  headers: {
395
395
  "Content-Type": "application/json",
@@ -426,9 +426,9 @@ const at = (t) => {
426
426
  c(!!r);
427
427
  }, [r]), !r) return null;
428
428
  const l = async () => {
429
- var T, A, tt, _t, ct, q, dt, Ct, zt, et, It, Ft, ut, At, jt, K;
429
+ var T, A, Z, _t, ct, q, dt, Ct, zt, tt, It, Ft, ut, At, jt, et;
430
430
  try {
431
- if (!((A = (T = r == null ? void 0 : r.variants) == null ? void 0 : T[0]) != null && A.product_id) && !(r.type.item || r.type.bundle) && !((_t = (tt = r == null ? void 0 : r.variants) == null ? void 0 : tt[0]) != null && _t.productId)) {
431
+ if (!((A = (T = r == null ? void 0 : r.variants) == null ? void 0 : T[0]) != null && A.product_id) && !(r.type.item || r.type.bundle) && !((_t = (Z = r == null ? void 0 : r.variants) == null ? void 0 : Z[0]) != null && _t.productId)) {
432
432
  U.error("Variants not available", {
433
433
  position: "bottom-right",
434
434
  autoClose: 1e3
@@ -456,12 +456,12 @@ const at = (t) => {
456
456
  customer_token: M
457
457
  });
458
458
  if (Nt.status === 200 && Nt) {
459
- const W = await ae(
459
+ const J = await ae(
460
460
  k,
461
461
  b,
462
462
  M
463
463
  );
464
- (((dt = W == null ? void 0 : W.product_items) == null ? void 0 : dt.length) > 0 || ((Ct = W == null ? void 0 : W.productItems) == null ? void 0 : Ct.length) > 0) && (U.success("Added to cart", {
464
+ (((dt = J == null ? void 0 : J.product_items) == null ? void 0 : dt.length) > 0 || ((Ct = J == null ? void 0 : J.productItems) == null ? void 0 : Ct.length) > 0) && (U.success("Added to cart", {
465
465
  position: "bottom-right",
466
466
  autoClose: 3e3,
467
467
  hideProgressBar: !1,
@@ -475,7 +475,7 @@ const at = (t) => {
475
475
  const pt = {
476
476
  productItems: [
477
477
  {
478
- productId: ((zt = r.variants) == null ? void 0 : zt[0].product_id) || ((et = r.variants) == null ? void 0 : et[0].productId) || (r == null ? void 0 : r.id),
478
+ productId: ((zt = r.variants) == null ? void 0 : zt[0].product_id) || ((tt = r.variants) == null ? void 0 : tt[0].productId) || (r == null ? void 0 : r.id),
479
479
  quantity: 1
480
480
  }
481
481
  ]
@@ -487,12 +487,12 @@ const at = (t) => {
487
487
  at(
488
488
  (S == null ? void 0 : S.basket_id) || (S == null ? void 0 : S.basketId)
489
489
  ), console.log("adding product to basket");
490
- const J = await ae(
490
+ const K = await ae(
491
491
  (S == null ? void 0 : S.basket_id) || (S == null ? void 0 : S.basketId),
492
492
  b,
493
493
  M
494
494
  );
495
- console.log("object added to basket"), (((It = J == null ? void 0 : J.product_items) == null ? void 0 : It.length) > 0 || ((Ft = J == null ? void 0 : J.productItems) == null ? void 0 : Ft.length) > 0) && U.success("Added to cart", {
495
+ console.log("object added to basket"), (((It = K == null ? void 0 : K.product_items) == null ? void 0 : It.length) > 0 || ((Ft = K == null ? void 0 : K.productItems) == null ? void 0 : Ft.length) > 0) && U.success("Added to cart", {
496
496
  position: "bottom-right",
497
497
  autoClose: 3e3,
498
498
  hideProgressBar: !1,
@@ -506,7 +506,7 @@ const at = (t) => {
506
506
  position: "bottom-right",
507
507
  autoClose: 3e3
508
508
  }), ((ut = b == null ? void 0 : b.response) == null ? void 0 : ut.status) === 404 || // Basket not found
509
- ((At = b == null ? void 0 : b.response) == null ? void 0 : At.status) === 401 ? (((jt = b == null ? void 0 : b.response) == null ? void 0 : jt.status) === 404 && at(null), ((K = b == null ? void 0 : b.response) == null ? void 0 : K.status) === 401 && (at(null), Kt(null))) : (console.error("Failed to add product to basket:", b.message), U.error("Failed to add product to cart", {
509
+ ((At = b == null ? void 0 : b.response) == null ? void 0 : At.status) === 401 ? (((jt = b == null ? void 0 : b.response) == null ? void 0 : jt.status) === 404 && at(null), ((et = b == null ? void 0 : b.response) == null ? void 0 : et.status) === 401 && (at(null), Kt(null))) : (console.error("Failed to add product to basket:", b.message), U.error("Failed to add product to cart", {
510
510
  position: "bottom-right",
511
511
  autoClose: 3e3
512
512
  }));
@@ -616,7 +616,7 @@ const at = (t) => {
616
616
  ] })
617
617
  ] }) }),
618
618
  /* @__PURE__ */ a("div", { className: "mt-2 flex flex-row items-center gap-2", children: Array.from({ length: 5 }).map((T, A) => {
619
- var tt;
619
+ var Z;
620
620
  return /* @__PURE__ */ a(
621
621
  xe,
622
622
  {
@@ -624,7 +624,7 @@ const at = (t) => {
624
624
  width: "20",
625
625
  height: "20",
626
626
  className: `text-yellow-500
627
- ${((tt = r == null ? void 0 : r.rating) == null ? void 0 : tt.rate) > A ? "text-yellow-500" : "text-gray-300"}
627
+ ${((Z = r == null ? void 0 : r.rating) == null ? void 0 : Z.rate) > A ? "text-yellow-500" : "text-gray-300"}
628
628
  `
629
629
  },
630
630
  A
@@ -681,19 +681,19 @@ const at = (t) => {
681
681
  "Niece/Nephew": "his/her niece/nephew",
682
682
  "My Friends": "his/her friends",
683
683
  Others: "others"
684
- }, c = xt(null), l = xt(null), d = xt(null), i = xt(null), [y, v] = $(null), C = xt(null), [_, O] = $(!1), [T, A] = $(!1), [tt, _t] = $(!1), [ct, q] = $(!1), [dt, Ct] = $(!1), [zt, et] = $(!1), [It, Ft] = $(""), [ut, At] = $(""), jt = (s) => ({
684
+ }, c = xt(null), l = xt(null), d = xt(null), i = xt(null), [y, v] = $(null), C = xt(null), [_, O] = $(!1), [T, A] = $(!1), [Z, _t] = $(!1), [ct, q] = $(!1), [dt, Ct] = $(!1), [zt, tt] = $(!1), [It, Ft] = $(""), [ut, At] = $(""), jt = (s) => ({
685
685
  id: s.id,
686
686
  title: s.name,
687
687
  image: s.image ?? "",
688
688
  price: s.price ?? 0
689
- }), [K, b] = $([]), rt = xt(null), k = Rt((s) => s.store.store), Wt = Rt((s) => s.product.product);
689
+ }), [et, b] = $([]), rt = xt(null), k = Rt((s) => s.store.store), Wt = Rt((s) => s.product.product);
690
690
  B(() => {
691
691
  const s = localStorage.getItem(
692
692
  `access_token_${t.siteId}`
693
- ), m = localStorage.getItem(
693
+ ), w = localStorage.getItem(
694
694
  `chat-token-${t.siteId}`
695
695
  );
696
- if (s && m === s) {
696
+ if (s && w === s) {
697
697
  const h = localStorage.getItem("chatHistory");
698
698
  h && b(JSON.parse(h));
699
699
  } else
@@ -702,12 +702,12 @@ const at = (t) => {
702
702
  s || ""
703
703
  );
704
704
  }, []), B(() => {
705
- localStorage.setItem("chatHistory", JSON.stringify(K));
705
+ localStorage.setItem("chatHistory", JSON.stringify(et));
706
706
  const s = localStorage.getItem(
707
707
  `access_token_${t.siteId}`
708
708
  );
709
709
  s && localStorage.setItem(`chat-token-${t.siteId}`, s);
710
- }, [K]);
710
+ }, [et]);
711
711
  const Dt = () => {
712
712
  _t(!0), setTimeout(() => A(!0), 10);
713
713
  }, Lt = () => {
@@ -721,13 +721,13 @@ const at = (t) => {
721
721
  };
722
722
  B(() => {
723
723
  rt.current && (rt.current.scrollTop += 150);
724
- }, [K]);
724
+ }, [et]);
725
725
  let ot = null, pt = null;
726
726
  const S = async () => {
727
727
  if (ot && pt && Date.now() < pt)
728
728
  return ot;
729
729
  try {
730
- const s = "https://us-east-1lsr29ln3u.auth.us-east-1.amazoncognito.com/oauth2/token", m = new URLSearchParams({
730
+ const s = "https://us-east-1lsr29ln3u.auth.us-east-1.amazoncognito.com/oauth2/token", w = new URLSearchParams({
731
731
  grant_type: "client_credentials",
732
732
  client_id: "4i8rd70sgt961tc4dhskgf08c",
733
733
  client_secret: "bnsfq1220loh2cn2cm2ttn8fdhdpt0u8m1fgj8vfk2rn61aurjg",
@@ -737,7 +737,7 @@ const at = (t) => {
737
737
  headers: {
738
738
  "Content-Type": "application/x-www-form-urlencoded"
739
739
  },
740
- body: m
740
+ body: w
741
741
  });
742
742
  if (!h.ok)
743
743
  throw new Error(
@@ -750,16 +750,16 @@ const at = (t) => {
750
750
  } catch (s) {
751
751
  return console.error("Error obtaining JWT token:", s), ot = null, pt = null, null;
752
752
  }
753
- }, J = async () => {
753
+ }, K = async () => {
754
754
  const s = await $t();
755
755
  s != null && v(s);
756
756
  };
757
757
  B(() => {
758
758
  if (t != null && t.siteId) {
759
- const { clientID: s, host: m, organizationID: h, shortCode: g, siteId: p } = t;
760
- sessionStorage.setItem("Host", m), sessionStorage.setItem("SiteId", p), sessionStorage.setItem("pubCfg", btoa(s)), sessionStorage.setItem("envRef", g), sessionStorage.setItem("orgRef", h);
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);
761
761
  }
762
- J(), console.log("scapi environment v1");
762
+ K(), console.log("scapi environment v1");
763
763
  }, []), B(() => {
764
764
  e && (console.log("setting the basket id", e), at(e));
765
765
  }, [e]);
@@ -768,7 +768,7 @@ const at = (t) => {
768
768
  sessionStorage.getItem("customerData") || "{}"
769
769
  ).customerId;
770
770
  return (await _r(s || "")).c_interests;
771
- }, W = async (s, m) => {
771
+ }, J = async (s, w) => {
772
772
  console.log("in secondary flow", Et);
773
773
  const h = await Nt();
774
774
  if (console.log(h, "interests of customer", Et), !!h)
@@ -780,8 +780,8 @@ const at = (t) => {
780
780
  );
781
781
  const g = await S();
782
782
  if (!g) throw new Error("Failed to fetch token");
783
- const p = localStorage.getItem("customerNumber"), w = localStorage.getItem("isLoggedIn"), ft = `https://tanya.aspiresystems.com/api/bedrock/invoke/stream?${new URLSearchParams({
784
- registered: String(w || !1),
783
+ const p = localStorage.getItem("customerNumber"), m = localStorage.getItem("isLoggedIn"), ft = `https://tanya.aspiresystems.com/api/bedrock/invoke/stream?${new URLSearchParams({
784
+ registered: String(m || !1),
785
785
  userId: String(p || (/* @__PURE__ */ new Date()).getTime())
786
786
  }).toString()}`, ht = JSON.stringify({
787
787
  flowId: "Q166PR519W",
@@ -789,7 +789,7 @@ const at = (t) => {
789
789
  input: {
790
790
  loyaltyPoints: "",
791
791
  productName: s,
792
- productPoints: String(m || 0),
792
+ productPoints: String(w || 0),
793
793
  interests: h
794
794
  }
795
795
  }), j = await fetch(ft, {
@@ -811,14 +811,14 @@ const at = (t) => {
811
811
  const R = D.split(`
812
812
  `);
813
813
  D = R.pop() || "";
814
- for (const G of R)
815
- if (G.startsWith("data:")) {
816
- const f = G.slice(5).trim();
814
+ for (const W of R)
815
+ if (W.startsWith("data:")) {
816
+ const f = W.slice(5).trim();
817
817
  try {
818
818
  const V = JSON.parse(f);
819
819
  V.index === 0 && b(
820
820
  (I) => I.map(
821
- (P, X) => X === I.length - 1 ? {
821
+ (P, G) => G === I.length - 1 ? {
822
822
  ...P,
823
823
  secondaryResponse: V.data,
824
824
  secondaryLoading: !1
@@ -828,7 +828,7 @@ const at = (t) => {
828
828
  } catch (V) {
829
829
  b(
830
830
  (I) => I.map(
831
- (P, X) => X === I.length - 1 ? { ...P, secondaryLoading: !1 } : P
831
+ (P, G) => G === I.length - 1 ? { ...P, secondaryLoading: !1 } : P
832
832
  )
833
833
  ), console.error("Secondary flow JSON parse error:", V);
834
834
  }
@@ -838,12 +838,12 @@ const at = (t) => {
838
838
  console.error("Secondary flow error:", g);
839
839
  }
840
840
  }, Gt = async (s) => {
841
- const m = s || It.trim();
842
- if (m) {
841
+ const w = s || It.trim();
842
+ if (w) {
843
843
  Ct(!0), Ft(""), c.current = null, l.current = null, d.current = null, i.current = null, b((h) => [
844
844
  ...h,
845
845
  {
846
- query: m,
846
+ query: w,
847
847
  response: "Thinking for what suits you best...",
848
848
  potentialQuestions: "",
849
849
  products: [],
@@ -851,8 +851,8 @@ const at = (t) => {
851
851
  }
852
852
  ]);
853
853
  try {
854
- const h = ut, g = localStorage.getItem("customerNumber"), p = localStorage.getItem("isLoggedIn"), w = await S();
855
- if (!w)
854
+ const h = ut, g = localStorage.getItem("customerNumber"), p = localStorage.getItem("isLoggedIn"), m = await S();
855
+ if (!m)
856
856
  throw new Error("Failed to obtain access token");
857
857
  const ft = `https://tanya.aspiresystems.com/api/bedrock/invoke/stream?${new URLSearchParams({
858
858
  registered: String(p || !1),
@@ -861,7 +861,7 @@ const at = (t) => {
861
861
  flowId: "MMHQKYI1NE",
862
862
  flowAliasId: "SZF9ZK1ATE",
863
863
  input: {
864
- userPrompt: m,
864
+ userPrompt: w,
865
865
  whom: h
866
866
  }
867
867
  }), j = await fetch(ft, {
@@ -869,7 +869,7 @@ const at = (t) => {
869
869
  method: "POST",
870
870
  headers: {
871
871
  "Content-Type": "application/json",
872
- Authorization: `Bearer ${w}`
872
+ Authorization: `Bearer ${m}`
873
873
  },
874
874
  body: ht
875
875
  });
@@ -879,24 +879,24 @@ const at = (t) => {
879
879
  const mt = j.body.getReader(), wt = new TextDecoder();
880
880
  let D = "", L = "";
881
881
  for (; ; ) {
882
- et(!0);
882
+ tt(!0);
883
883
  const { done: H, value: R } = await mt.read();
884
884
  if (H) break;
885
885
  D += wt.decode(R, { stream: !0 });
886
- const G = D.split(`
886
+ const W = D.split(`
887
887
  `);
888
- D = G.pop() || "";
889
- for (const f of G)
888
+ D = W.pop() || "";
889
+ for (const f of W)
890
890
  if (f.startsWith("data:")) {
891
891
  const V = f.slice(5).trim();
892
892
  try {
893
893
  const I = JSON.parse(V);
894
894
  I.index == 1 && (L = I.data), b(
895
895
  (P) => P.map(
896
- (X, Bt) => Bt === P.length - 1 ? {
897
- ...X,
896
+ (G, Bt) => Bt === P.length - 1 ? {
897
+ ...G,
898
898
  [I.index == 0 ? "response" : I.index == 1 ? "keywords" : I.index == 2 ? "potentialQuestions" : "end"]: I.data
899
- } : X
899
+ } : G
900
900
  )
901
901
  );
902
902
  } catch (I) {
@@ -912,43 +912,43 @@ const at = (t) => {
912
912
  }
913
913
  }
914
914
  }, or = (s) => {
915
- const m = s.match(
915
+ const w = s.match(
916
916
  /top five relevant product or category names are: (.*)/i
917
- ), p = (m ? m[1] : s).split(", ").map((z) => z.replace(/\s*(Toys|Bags|Miniature|etc\.*)\s*/gi, "").trim());
917
+ ), p = (w ? w[1] : s).split(", ").map((z) => z.replace(/\s*(Toys|Bags|Miniature|etc\.*)\s*/gi, "").trim());
918
918
  return [...new Set(p)].filter(Boolean).join(",");
919
919
  }, nr = async (s) => {
920
920
  if (typeof s == "string") {
921
921
  console.log(s, "keywords");
922
- const m = s.split(",");
923
- for (const h of m) {
922
+ const w = s.split(",");
923
+ for (const h of w) {
924
924
  const g = await ye(h);
925
- if (et(!1), (g == null ? void 0 : g.length) > 0 && (b(
925
+ if (tt(!1), (g == null ? void 0 : g.length) > 0 && (b(
926
926
  (p) => p.map(
927
- (w, z) => z === p.length - 1 ? {
928
- ...w,
927
+ (m, z) => z === p.length - 1 ? {
928
+ ...m,
929
929
  products: [
930
- ...w.products || [],
930
+ ...m.products || [],
931
931
  { keyword: h, items: g, loading: !1 }
932
932
  ]
933
- } : w
933
+ } : m
934
934
  )
935
935
  ), !c.current || l.current == null)) {
936
936
  const p = g[0];
937
937
  c.current = String((p == null ? void 0 : p.product_name) ?? ""), d.current = p.image.link, l.current = p.product_id;
938
- const w = typeof (p == null ? void 0 : p.price) == "number" ? p.price : void 0;
939
- i.current = typeof w == "number" && Number.isFinite(w) ? w : null;
938
+ const m = typeof (p == null ? void 0 : p.price) == "number" ? p.price : void 0;
939
+ i.current = typeof m == "number" && Number.isFinite(m) ? m : null;
940
940
  }
941
941
  }
942
942
  } else
943
- for (const m of s) {
944
- const h = await ye(m);
945
- et(!1), (h == null ? void 0 : h.length) > 0 && b(
943
+ for (const w of s) {
944
+ const h = await ye(w);
945
+ tt(!1), (h == null ? void 0 : h.length) > 0 && b(
946
946
  (g) => g.map(
947
- (p, w) => w === g.length - 1 ? {
947
+ (p, m) => m === g.length - 1 ? {
948
948
  ...p,
949
949
  products: [
950
950
  ...p.products || [],
951
- { keyword: m, items: h, loading: !1 }
951
+ { keyword: w, items: h, loading: !1 }
952
952
  ]
953
953
  } : p
954
954
  )
@@ -970,18 +970,18 @@ const at = (t) => {
970
970
  } : g
971
971
  )
972
972
  );
973
- const m = JSON.parse(
973
+ const w = JSON.parse(
974
974
  sessionStorage.getItem("customerData") || "{}"
975
975
  );
976
- (m == null ? void 0 : m.isGuest) == !1 ? (console.log("running secondary flow", Et), W(c.current, 0)) : console.log("not running secondary flow", Et);
976
+ (w == null ? void 0 : w.isGuest) == !1 ? (console.log("running secondary flow", Et), J(c.current, 0)) : console.log("not running secondary flow", Et);
977
977
  }
978
- et(!1);
979
- }, ar = async (s, m) => {
980
- var h, g, p, w, z, ft, ht, j, mt, wt, D, L, H, R, G;
978
+ tt(!1);
979
+ }, ar = async (s, w) => {
980
+ var h, g, p, m, z, ft, ht, j, mt, wt, D, L, H, R, W;
981
981
  q(!0);
982
982
  try {
983
983
  const f = await Ve(s.id);
984
- if (!((g = (h = f == null ? void 0 : f.variants) == null ? void 0 : h[0]) != null && g.product_id || (w = (p = f == null ? void 0 : f.variants) == null ? void 0 : p[0]) != null && w.productId) && !(f.type.item || f.type.bundle)) {
984
+ 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)) {
985
985
  q(!1), U.error("Variants not found", {
986
986
  position: "bottom-right",
987
987
  autoClose: 1e3
@@ -991,14 +991,14 @@ const at = (t) => {
991
991
  const V = [
992
992
  {
993
993
  product_id: ((z = f.variants) == null ? void 0 : z[0].product_id) || ((ft = f.variants) == null ? void 0 : ft[0].productId) || (f == null ? void 0 : f.id),
994
- quantity: m
994
+ quantity: w
995
995
  }
996
996
  ];
997
997
  console.log(V, "product data", "app version", Et);
998
998
  const I = JSON.parse(
999
999
  sessionStorage.getItem("customerData") || "{}"
1000
- ), P = (I == null ? void 0 : I.basketId) || localStorage.getItem(Yt), X = !1, Bt = localStorage.getItem(Ot), ge = Date.now();
1001
- if (!X || !Bt || ge >= parseInt(Bt)) {
1000
+ ), P = (I == null ? void 0 : I.basketId) || localStorage.getItem(Yt), G = !1, Bt = localStorage.getItem(Ot), ge = Date.now();
1001
+ if (!G || !Bt || ge >= parseInt(Bt)) {
1002
1002
  const ir = await He();
1003
1003
  let { customer_token: gt } = await Re(
1004
1004
  ir
@@ -1053,7 +1053,7 @@ const at = (t) => {
1053
1053
  const bt = await r(
1054
1054
  {
1055
1055
  productId: l,
1056
- quantity: m
1056
+ quantity: w
1057
1057
  },
1058
1058
  (x == null ? void 0 : x.basket_id) || (x == null ? void 0 : x.basketId)
1059
1059
  );
@@ -1071,7 +1071,7 @@ const at = (t) => {
1071
1071
  position: "bottom-right",
1072
1072
  autoClose: 3e3
1073
1073
  }), ((L = f == null ? void 0 : f.response) == null ? void 0 : L.status) === 404 || // Basket not found
1074
- ((H = f == null ? void 0 : f.response) == null ? void 0 : H.status) === 401 ? (((R = f == null ? void 0 : f.response) == null ? void 0 : R.status) === 404 && at(null), ((G = f == null ? void 0 : f.response) == null ? void 0 : G.status) === 401 && (at(null), Kt(null))) : (console.error("Failed to add product to basket:", f.message), U.error("Failed to add product to cart", {
1074
+ ((H = f == null ? void 0 : f.response) == null ? void 0 : H.status) === 401 ? (((R = f == null ? void 0 : f.response) == null ? void 0 : R.status) === 404 && at(null), ((W = f == null ? void 0 : f.response) == null ? void 0 : W.status) === 401 && (at(null), Kt(null))) : (console.error("Failed to add product to basket:", f.message), U.error("Failed to add product to cart", {
1075
1075
  position: "bottom-right",
1076
1076
  autoClose: 3e3
1077
1077
  }));
@@ -1144,7 +1144,7 @@ const at = (t) => {
1144
1144
  ) })
1145
1145
  }
1146
1146
  ),
1147
- tt && /* @__PURE__ */ u(oe, { children: [
1147
+ Z && /* @__PURE__ */ u(oe, { children: [
1148
1148
  /* @__PURE__ */ a(
1149
1149
  "div",
1150
1150
  {
@@ -1322,14 +1322,13 @@ const at = (t) => {
1322
1322
  ]
1323
1323
  }
1324
1324
  ),
1325
- K.map((s, m) => {
1325
+ et.map((s, w) => {
1326
1326
  var h, g;
1327
1327
  return /* @__PURE__ */ u("div", { children: [
1328
1328
  /* @__PURE__ */ a(
1329
1329
  "div",
1330
1330
  {
1331
1331
  className: "flex justify-end",
1332
- ref: m == K.length - 1 ? C : null,
1333
1332
  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 })
1334
1333
  }
1335
1334
  ),
@@ -1367,7 +1366,7 @@ const at = (t) => {
1367
1366
  children: "Why not explore these inquiries..."
1368
1367
  }
1369
1368
  ),
1370
- s.potentialQuestions.split(",").map((p, w) => /* @__PURE__ */ a(
1369
+ s.potentialQuestions.split(",").map((p, m) => /* @__PURE__ */ a(
1371
1370
  "button",
1372
1371
  {
1373
1372
  className: `cursor-pointer font-nunitoSans font-semibold text-[#232323] border bg-[#804C9E0D] border-${k.themeDarkColor} m-1 rounded-xl px-2 py-1`,
@@ -1377,7 +1376,7 @@ const at = (t) => {
1377
1376
  },
1378
1377
  children: p
1379
1378
  },
1380
- w
1379
+ m
1381
1380
  ))
1382
1381
  ] }),
1383
1382
  s.secondaryLoading && /* @__PURE__ */ a("div", { className: "mt-3 mb-4 px-4", children: /* @__PURE__ */ u(
@@ -1483,16 +1482,16 @@ const at = (t) => {
1483
1482
  className: "px-3 py-1 text-sm",
1484
1483
  onClick: () => b(
1485
1484
  (p) => p.map(
1486
- (w, z) => z === m && w.productSnapshot ? {
1487
- ...w,
1485
+ (m, z) => z === w && m.productSnapshot ? {
1486
+ ...m,
1488
1487
  productSnapshot: {
1489
- ...w.productSnapshot,
1488
+ ...m.productSnapshot,
1490
1489
  quantity: Math.max(
1491
1490
  1,
1492
- w.productSnapshot.quantity - 1
1491
+ m.productSnapshot.quantity - 1
1493
1492
  )
1494
1493
  }
1495
- } : w
1494
+ } : m
1496
1495
  )
1497
1496
  ),
1498
1497
  style: {
@@ -1509,13 +1508,13 @@ const at = (t) => {
1509
1508
  className: "px-3 py-1 text-sm",
1510
1509
  onClick: () => b(
1511
1510
  (p) => p.map(
1512
- (w, z) => z === m && w.productSnapshot ? {
1513
- ...w,
1511
+ (m, z) => z === w && m.productSnapshot ? {
1512
+ ...m,
1514
1513
  productSnapshot: {
1515
- ...w.productSnapshot,
1516
- quantity: w.productSnapshot.quantity + 1
1514
+ ...m.productSnapshot,
1515
+ quantity: m.productSnapshot.quantity + 1
1517
1516
  }
1518
- } : w
1517
+ } : m
1519
1518
  )
1520
1519
  ),
1521
1520
  style: {
@@ -1554,7 +1553,7 @@ const at = (t) => {
1554
1553
  ) })
1555
1554
  ] }) }),
1556
1555
  /* @__PURE__ */ a("div", { className: "mb-20" })
1557
- ] }, m);
1556
+ ] }, w);
1558
1557
  })
1559
1558
  ]
1560
1559
  }
@@ -1645,14 +1644,14 @@ function $r(t, e) {
1645
1644
  }
1646
1645
  t.prototype = e === null ? Object.create(e) : (r.prototype = e.prototype, new r());
1647
1646
  }
1648
- var Q = function() {
1649
- return Q = Object.assign || function(e) {
1647
+ var X = function() {
1648
+ return X = Object.assign || function(e) {
1650
1649
  for (var r, o = 1, n = arguments.length; o < n; o++) {
1651
1650
  r = arguments[o];
1652
1651
  for (var c in r) Object.prototype.hasOwnProperty.call(r, c) && (e[c] = r[c]);
1653
1652
  }
1654
1653
  return e;
1655
- }, Q.apply(this, arguments);
1654
+ }, X.apply(this, arguments);
1656
1655
  };
1657
1656
  function zr(t, e) {
1658
1657
  var r = {};
@@ -2333,10 +2332,10 @@ function Xr(t) {
2333
2332
  return t;
2334
2333
  }
2335
2334
  function Qr(t, e) {
2336
- var r = Q({}, t), o = function(c) {
2337
- typeof c == "function" ? r = Q(Q({}, r), c(r)) : r = Q(Q({}, r), c);
2335
+ var r = X({}, t), o = function(c) {
2336
+ typeof c == "function" ? r = X(X({}, r), c(r)) : r = X(X({}, r), c);
2338
2337
  }, n = function() {
2339
- return Q({}, r);
2338
+ return X({}, r);
2340
2339
  };
2341
2340
  return Object.defineProperty(e, "setContext", {
2342
2341
  enumerable: !1,