@gengage/assistant-fe 0.4.17 → 0.4.18
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/chat/runtime.d.ts +4 -0
- package/dist/chat-runtime.js +1 -1
- package/dist/chat.iife.js +9 -9
- package/dist/chat.js +1 -1
- package/dist/index.js +1 -1
- package/dist/native.iife.js +8 -8
- package/dist/{runtime-NJI0NPN6.js → runtime-CAUALvac.js} +223 -194
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { f as ma, m as fa, r as ba, s as va, t as xa, u as ya } from "./api-paths-BX3Lea3A.js";
|
|
2
2
|
import { C as wa, S as _a, _ as ka, a as Vt, b as Ca, f as Sa, g as Ea, n as Me, p as Pa, t as La, x as Ta, y as Aa } from "./widget-base-bdJaGJYi.js";
|
|
3
|
-
import { A as we, C as Ia, D as Ma, E as Na, M as oe, N as pe, O as Ba, S as mt, T as za, _ as
|
|
3
|
+
import { A as we, C as Ia, D as Ma, E as Na, M as oe, N as pe, O as Ba, S as mt, T as za, _ as Ra, a as he, b as Ha, d as Fa, f as Da, g as Ua, h as Oa, j as fe, l as ja, m as qa, p as Va, u as Ga, v as $a, w as ft, x as Wa } from "./context-DGz5F81j.js";
|
|
4
4
|
import { a as le, i as Ka, n as Ya, o as Za, r as Xa, s as Qa, t as bt } from "./fastIntent-CINRmM8r.js";
|
|
5
5
|
import { t as De } from "./locale-CfqNifrU.js";
|
|
6
|
-
import { a as Gt, i as $t, n as
|
|
6
|
+
import { a as Gt, i as $t, n as me, r as Wt, t as J } from "./price-formatter-xI3g9Cd4.js";
|
|
7
7
|
function vt() {
|
|
8
8
|
const a = Date.now(), e = new Uint8Array(16);
|
|
9
9
|
crypto.getRandomValues(e), e[0] = a / 2 ** 40 & 255, e[1] = a / 2 ** 32 & 255, e[2] = a / 2 ** 24 & 255, e[3] = a / 2 ** 16 & 255, e[4] = a / 2 ** 8 & 255, e[5] = a & 255, e[6] = e[6] & 15 | 112, e[8] = e[8] & 63 | 128;
|
|
@@ -892,9 +892,9 @@ var An = class {
|
|
|
892
892
|
_.className = "gengage-chat-conversation", _.dataset.gengagePart = "chat-conversation", this._conversationEl = _, _.appendChild(r);
|
|
893
893
|
const E = document.createElement("div");
|
|
894
894
|
E.className = "gengage-chat-offline-bar gds-evidence-card gds-evidence-card-warning", E.dataset.gengagePart = "chat-offline-bar", E.setAttribute("role", "status"), E.setAttribute("aria-live", "polite"), E.textContent = this.i18n.offlineMessage, typeof navigator < "u" && !navigator.onLine && E.classList.add("gengage-chat-offline-bar--visible"), _.appendChild(E);
|
|
895
|
-
const
|
|
896
|
-
window.addEventListener("offline",
|
|
897
|
-
window.removeEventListener("offline",
|
|
895
|
+
const R = () => E.classList.add("gengage-chat-offline-bar--visible"), W = () => E.classList.remove("gengage-chat-offline-bar--visible");
|
|
896
|
+
window.addEventListener("offline", R), window.addEventListener("online", W), this._cleanups.push(() => {
|
|
897
|
+
window.removeEventListener("offline", R), window.removeEventListener("online", W);
|
|
898
898
|
}), this._kvkkSlot = document.createElement("div"), this._kvkkSlot.className = "gengage-chat-kvkk-slot", this._kvkkSlot.dataset.gengagePart = "chat-kvkk-slot", _.appendChild(this._kvkkSlot), this.messagesEl = document.createElement("div"), this.messagesEl.id = rt, this.messagesEl.className = "gengage-chat-messages", this.messagesEl.dataset.gengagePart = "chat-messages", this.messagesEl.setAttribute("role", "log"), this.messagesEl.setAttribute("aria-live", "polite"), this.messagesEl.setAttribute("aria-atomic", "false"), this.messagesEl.setAttribute("aria-label", this.i18n.chatMessagesAriaLabel), xt(this.messagesEl);
|
|
899
899
|
const Z = document.createElement("button");
|
|
900
900
|
Z.type = "button", Z.className = "gengage-chat-former-messages-btn gds-chip", Z.dataset.gengagePart = "chat-former-messages-button", Z.textContent = this.i18n.showFormerMessagesButton, Z.setAttribute("aria-label", this.i18n.showFormerMessagesButton), Z.style.display = "none", Z.addEventListener("click", () => {
|
|
@@ -986,8 +986,8 @@ var An = class {
|
|
|
986
986
|
});
|
|
987
987
|
const B = document.createElement("div");
|
|
988
988
|
this._attachMenuEl = B, B.className = "gengage-chat-attach-menu gds-menu", B.dataset.gengagePart = "chat-attach-menu", B.setAttribute("role", "menu"), B.setAttribute("hidden", "");
|
|
989
|
-
const
|
|
990
|
-
|
|
989
|
+
const H = document.createElement("button");
|
|
990
|
+
H.type = "button", H.className = "gengage-chat-attach-menu-item gds-btn gds-btn-ghost", H.dataset.gengagePart = "chat-attach-menu-select-photo", H.setAttribute("role", "menuitem"), H.innerHTML = `<span class="gengage-chat-attach-menu-icon" aria-hidden="true"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"/><circle cx="12" cy="13" r="4"/></svg></span><span class="gengage-chat-attach-menu-label">${this.i18n.attachMenuSelectPhoto}</span>`, H.addEventListener("click", (w) => {
|
|
991
991
|
w.stopPropagation(), this._closeAttachMenu(), this._fileInput.click();
|
|
992
992
|
});
|
|
993
993
|
const A = document.createElement("div");
|
|
@@ -997,7 +997,7 @@ var An = class {
|
|
|
997
997
|
w.stopPropagation();
|
|
998
998
|
const K = typeof navigator.clipboard?.read == "function" ? navigator.clipboard.read() : void 0;
|
|
999
999
|
this._pasteImageFromClipboardMenu(K);
|
|
1000
|
-
}), B.appendChild(
|
|
1000
|
+
}), B.appendChild(H), B.appendChild(A), B.appendChild(Y), N.appendChild(x), N.appendChild(B), this._previewStrip = document.createElement("div"), this._previewStrip.className = "gengage-chat-attachment-preview gengage-chat-attachment-preview--hidden gds-card-soft", this._previewStrip.dataset.gengagePart = "chat-attachment-preview";
|
|
1001
1001
|
const V = document.createElement("img");
|
|
1002
1002
|
V.className = "gengage-chat-attachment-preview-thumb", V.dataset.gengagePart = "chat-attachment-preview-thumb", V.alt = "", this._previewName = document.createElement("span"), this._previewName.className = "gengage-chat-attachment-name", this._previewName.dataset.gengagePart = "chat-attachment-preview-name";
|
|
1003
1003
|
const ee = document.createElement("button");
|
|
@@ -1382,8 +1382,8 @@ var An = class {
|
|
|
1382
1382
|
const y = document.createElement("ul");
|
|
1383
1383
|
y.className = "gengage-chat-comparison-skeleton-hl-list";
|
|
1384
1384
|
for (let _ = 0; _ < 3; _++) {
|
|
1385
|
-
const E = document.createElement("li"),
|
|
1386
|
-
|
|
1385
|
+
const E = document.createElement("li"), R = document.createElement("div");
|
|
1386
|
+
R.className = "gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-hl-line", _ === 1 && R.classList.add("gengage-chat-comparison-skeleton-hl-line--medium"), _ === 2 && R.classList.add("gengage-chat-comparison-skeleton-hl-line--short"), E.appendChild(R), y.appendChild(E);
|
|
1387
1387
|
}
|
|
1388
1388
|
h.appendChild(y), o.appendChild(h), r.appendChild(o);
|
|
1389
1389
|
const p = document.createElement("div");
|
|
@@ -1410,19 +1410,19 @@ var An = class {
|
|
|
1410
1410
|
for (let _ = 0; _ < 3; _++) {
|
|
1411
1411
|
const E = document.createElement("div");
|
|
1412
1412
|
E.className = "gengage-chat-comparison-skeleton-table-col";
|
|
1413
|
-
const
|
|
1414
|
-
|
|
1413
|
+
const R = document.createElement("div");
|
|
1414
|
+
R.className = "gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-th-img";
|
|
1415
1415
|
const W = document.createElement("div");
|
|
1416
1416
|
W.className = "gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-th-name";
|
|
1417
1417
|
const Z = document.createElement("div");
|
|
1418
|
-
Z.className = "gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-th-price", E.appendChild(
|
|
1418
|
+
Z.className = "gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-th-price", E.appendChild(R), E.appendChild(W), E.appendChild(Z), I.appendChild(E);
|
|
1419
1419
|
}
|
|
1420
1420
|
k.appendChild(I);
|
|
1421
1421
|
for (let _ = 0; _ < 3; _++) {
|
|
1422
1422
|
const E = document.createElement("div");
|
|
1423
1423
|
E.className = "gengage-chat-comparison-skeleton-table-row";
|
|
1424
|
-
const
|
|
1425
|
-
|
|
1424
|
+
const R = document.createElement("div");
|
|
1425
|
+
R.className = "gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-label", E.appendChild(R);
|
|
1426
1426
|
for (let W = 0; W < 3; W++) {
|
|
1427
1427
|
const Z = document.createElement("div");
|
|
1428
1428
|
Z.className = "gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-cell", E.appendChild(Z);
|
|
@@ -1764,7 +1764,7 @@ var An = class {
|
|
|
1764
1764
|
function Mn(a) {
|
|
1765
1765
|
return typeof a == "string" && In.includes(a) ? a : null;
|
|
1766
1766
|
}
|
|
1767
|
-
function
|
|
1767
|
+
function ue(a) {
|
|
1768
1768
|
return a == null || typeof a != "object" || Array.isArray(a) ? null : a;
|
|
1769
1769
|
}
|
|
1770
1770
|
function Nn(...a) {
|
|
@@ -1774,7 +1774,7 @@ function Nn(...a) {
|
|
|
1774
1774
|
}
|
|
1775
1775
|
}
|
|
1776
1776
|
function Bn(a) {
|
|
1777
|
-
const e =
|
|
1777
|
+
const e = ue(a);
|
|
1778
1778
|
if (!e) return null;
|
|
1779
1779
|
const t = Nn(e.assistant_mode, e.assistantMode);
|
|
1780
1780
|
return !t || !Xt.includes(t) ? null : t;
|
|
@@ -1828,7 +1828,7 @@ var zn = class {
|
|
|
1828
1828
|
const t = Mn(e);
|
|
1829
1829
|
t ? this._mode = t : Me("mode", "ignoring unrecognised assistant_mode from context", e);
|
|
1830
1830
|
} else e === null && (this._mode = "shopping");
|
|
1831
|
-
this._uiHints =
|
|
1831
|
+
this._uiHints = ue(a.ui_hints) ?? null;
|
|
1832
1832
|
}
|
|
1833
1833
|
reset() {
|
|
1834
1834
|
const a = this._mode !== "shopping";
|
|
@@ -1841,13 +1841,13 @@ var zn = class {
|
|
|
1841
1841
|
return this._mode !== "shopping";
|
|
1842
1842
|
}
|
|
1843
1843
|
};
|
|
1844
|
-
function
|
|
1844
|
+
function Rn() {
|
|
1845
1845
|
return {
|
|
1846
1846
|
streamIncludedBeautyPhotoStep: !1,
|
|
1847
1847
|
pendingPhotoStepSkip: !1
|
|
1848
1848
|
};
|
|
1849
1849
|
}
|
|
1850
|
-
function
|
|
1850
|
+
function Hn(a, e, t, n, i) {
|
|
1851
1851
|
if (a === "PhotoAnalysisCard") {
|
|
1852
1852
|
const r = Yt(e);
|
|
1853
1853
|
return r ? (i.photoAnalysis = r, i.renderHint = "photo_analysis", n.ensureRendered(), n.cancelTypewriter(), n.drawer?.updateBotMessage(i.id, i.content ?? "", "photo_analysis", i.photoAnalysis), !0) : (Me("beauty", "PhotoAnalysisCard parse failed, falling through to generic renderer", e), !1);
|
|
@@ -2263,7 +2263,7 @@ function Ze(a) {
|
|
|
2263
2263
|
const r = document.createElement("div");
|
|
2264
2264
|
r.className = "gengage-chat-campaign-price-badge__logo";
|
|
2265
2265
|
const o = document.createElement("img");
|
|
2266
|
-
o.alt = "", o.loading = "lazy", o.src = a.logoUrl,
|
|
2266
|
+
o.alt = "", o.loading = "lazy", o.src = a.logoUrl, me(o), r.appendChild(o), e.appendChild(r);
|
|
2267
2267
|
}
|
|
2268
2268
|
const t = document.createElement("div");
|
|
2269
2269
|
t.className = "gengage-chat-campaign-price-badge__body";
|
|
@@ -2311,7 +2311,7 @@ function si(a, e, t, n, i) {
|
|
|
2311
2311
|
const o = a.product, s = o.imageUrl;
|
|
2312
2312
|
if (s && we(s)) {
|
|
2313
2313
|
const l = document.createElement("img");
|
|
2314
|
-
l.className = "gengage-chat-ai-toppick-img", l.dataset.gengagePart = "ai-top-pick-image", oe(l, "src", s), l.loading = "lazy", l.alt = e,
|
|
2314
|
+
l.className = "gengage-chat-ai-toppick-img", l.dataset.gengagePart = "ai-top-pick-image", oe(l, "src", s), l.loading = "lazy", l.alt = e, me(l), r.appendChild(l);
|
|
2315
2315
|
}
|
|
2316
2316
|
const c = Jt(a);
|
|
2317
2317
|
if (c && !i?.skipOverlayActions) {
|
|
@@ -2449,8 +2449,8 @@ function Et(a, e, t, n) {
|
|
|
2449
2449
|
const _ = document.createElement("div");
|
|
2450
2450
|
if (_.className = "gengage-chat-ai-toppick-spinner", _.dataset.gengagePart = "ai-top-pick-spinner", _.style.display = I ? "" : "none", i.appendChild(_), z) {
|
|
2451
2451
|
const E = document.createElement("button");
|
|
2452
|
-
E.className = "gengage-chat-ai-toppick-cta gds-btn gds-btn-primary", E.dataset.gengagePart = "ai-top-pick-cta", E.type = "button", E.textContent = g ? e.i18n?.addToCartButton ?? "Add to Cart" : e.i18n?.viewDetails ?? "View Details", E.addEventListener("click", (
|
|
2453
|
-
if (
|
|
2452
|
+
E.className = "gengage-chat-ai-toppick-cta gds-btn gds-btn-primary", E.dataset.gengagePart = "ai-top-pick-cta", E.type = "button", E.textContent = g ? e.i18n?.addToCartButton ?? "Add to Cart" : e.i18n?.viewDetails ?? "View Details", E.addEventListener("click", (R) => {
|
|
2453
|
+
if (R.stopPropagation(), g) {
|
|
2454
2454
|
e.onAction({
|
|
2455
2455
|
title: e.i18n?.addToCartButton ?? "Add to Cart",
|
|
2456
2456
|
type: "addToCart",
|
|
@@ -2692,7 +2692,7 @@ function bi(a, e) {
|
|
|
2692
2692
|
const d = t[l], g = `gengage-cat-tab-${l}`, h = `gengage-cat-panel-${l}`, u = document.createElement("button");
|
|
2693
2693
|
if (u.className = "gengage-chat-categories-tab gds-tab", u.type = "button", u.dataset.gengagePart = "categories-tab", u.id = g, u.setAttribute("role", "tab"), u.setAttribute("aria-controls", h), u.setAttribute("aria-selected", String(l === 0)), u.tabIndex = l === 0 ? 0 : -1, l === 0 && u.classList.add("gengage-chat-categories-tab--active", "is-active"), d.image && we(d.image)) {
|
|
2694
2694
|
const f = document.createElement("img");
|
|
2695
|
-
f.className = "gengage-chat-categories-tab-image", f.draggable = !1, f.src = d.image, f.alt = d.groupName, f.loading = "lazy",
|
|
2695
|
+
f.className = "gengage-chat-categories-tab-image", f.draggable = !1, f.src = d.image, f.alt = d.groupName, f.loading = "lazy", me(f), u.appendChild(f);
|
|
2696
2696
|
}
|
|
2697
2697
|
const y = document.createElement("span");
|
|
2698
2698
|
y.className = "gengage-chat-categories-tab-text", y.textContent = d.groupName, u.appendChild(y), u.addEventListener("click", () => c(l)), u.addEventListener("keydown", (f) => {
|
|
@@ -2726,7 +2726,7 @@ function vi(a, e) {
|
|
|
2726
2726
|
const t = document.createElement("div");
|
|
2727
2727
|
if (t.className = "gengage-chat-product-card gds-card gds-product-card gds-card-interactive", t.dataset.gengagePart = "categories-product-card", a.imageUrl && we(a.imageUrl)) {
|
|
2728
2728
|
const r = document.createElement("img");
|
|
2729
|
-
r.className = "gengage-chat-product-card-img", r.draggable = !1, r.src = a.imageUrl, r.alt = a.name, r.loading = "lazy",
|
|
2729
|
+
r.className = "gengage-chat-product-card-img", r.draggable = !1, r.src = a.imageUrl, r.alt = a.name, r.loading = "lazy", me(r), t.appendChild(r);
|
|
2730
2730
|
}
|
|
2731
2731
|
const n = document.createElement("div");
|
|
2732
2732
|
n.className = "gengage-chat-product-card-body";
|
|
@@ -2800,9 +2800,9 @@ function _i(a, e) {
|
|
|
2800
2800
|
const m = document.createElement("div");
|
|
2801
2801
|
m.className = "gengage-chat-panel-restore-card__thumb";
|
|
2802
2802
|
const S = f.imageUrl;
|
|
2803
|
-
if (S &&
|
|
2803
|
+
if (S && fe(S)) {
|
|
2804
2804
|
const T = document.createElement("img");
|
|
2805
|
-
T.loading = "lazy", T.alt = f.name || i, oe(T, "src", S),
|
|
2805
|
+
T.loading = "lazy", T.alt = f.name || i, oe(T, "src", S), me(T), m.appendChild(T);
|
|
2806
2806
|
}
|
|
2807
2807
|
p.appendChild(m);
|
|
2808
2808
|
}
|
|
@@ -2822,11 +2822,11 @@ function ki(a, e) {
|
|
|
2822
2822
|
m.target.closest("a") || e.onProductSelect?.(t);
|
|
2823
2823
|
});
|
|
2824
2824
|
const i = t.imageUrl;
|
|
2825
|
-
if (i &&
|
|
2825
|
+
if (i && fe(i)) {
|
|
2826
2826
|
const m = document.createElement("div");
|
|
2827
2827
|
m.className = "gengage-chat-product-summary__image", m.dataset.gengagePart = "product-summary-image";
|
|
2828
2828
|
const S = document.createElement("img");
|
|
2829
|
-
S.loading = "lazy", oe(S, "src", i), S.alt = t.name || "Product image",
|
|
2829
|
+
S.loading = "lazy", oe(S, "src", i), S.alt = t.name || "Product image", me(S), m.appendChild(S), n.appendChild(m);
|
|
2830
2830
|
}
|
|
2831
2831
|
const r = document.createElement("div");
|
|
2832
2832
|
r.className = "gengage-chat-product-summary__content", r.dataset.gengagePart = "product-summary-content";
|
|
@@ -2861,8 +2861,8 @@ function ki(a, e) {
|
|
|
2861
2861
|
k.classList.add("gengage-chat-product-summary__price--inline"), k.appendChild(_);
|
|
2862
2862
|
const E = document.createElement("span");
|
|
2863
2863
|
E.className = "gengage-chat-product-summary__price-sep", E.setAttribute("aria-hidden", "true");
|
|
2864
|
-
const
|
|
2865
|
-
|
|
2864
|
+
const R = document.createElement("span");
|
|
2865
|
+
R.className = "gengage-chat-product-summary__price-original", R.textContent = J(g, e.pricing), k.appendChild(E), k.appendChild(R);
|
|
2866
2866
|
} else {
|
|
2867
2867
|
const E = document.createElement("span");
|
|
2868
2868
|
E.className = "gengage-chat-product-summary__price-original", E.textContent = J(g, e.pricing), k.appendChild(E), k.appendChild(document.createTextNode(" ")), k.appendChild(_);
|
|
@@ -2875,8 +2875,8 @@ function ki(a, e) {
|
|
|
2875
2875
|
_.className = "gengage-chat-product-summary__price-current", _.textContent = J(d, e.pricing);
|
|
2876
2876
|
const E = document.createElement("span");
|
|
2877
2877
|
E.className = "gengage-chat-product-summary__price-sep", E.setAttribute("aria-hidden", "true");
|
|
2878
|
-
const
|
|
2879
|
-
|
|
2878
|
+
const R = document.createElement("span");
|
|
2879
|
+
R.className = "gengage-chat-product-summary__price-original", R.textContent = J(g, e.pricing), k.appendChild(_), k.appendChild(E), k.appendChild(R);
|
|
2880
2880
|
} else if (T) {
|
|
2881
2881
|
const _ = document.createElement("span");
|
|
2882
2882
|
_.className = "gengage-chat-product-summary__price-original", _.textContent = J(g, e.pricing), k.appendChild(_), k.appendChild(document.createTextNode(" "));
|
|
@@ -2907,7 +2907,7 @@ function ki(a, e) {
|
|
|
2907
2907
|
}
|
|
2908
2908
|
});
|
|
2909
2909
|
}), n.appendChild(m);
|
|
2910
|
-
} else if (h &&
|
|
2910
|
+
} else if (h && fe(h)) {
|
|
2911
2911
|
const m = document.createElement("a");
|
|
2912
2912
|
m.className = "gengage-chat-product-summary__cta gds-chip gds-chip-active", m.dataset.gengagePart = "product-summary-cta", oe(m, "href", h), oe(m, "target", "_blank"), oe(m, "rel", "noopener noreferrer"), m.textContent = e.i18n?.productCtaLabel ?? "View", n.appendChild(m);
|
|
2913
2913
|
}
|
|
@@ -3094,13 +3094,13 @@ function st(a, e) {
|
|
|
3094
3094
|
}
|
|
3095
3095
|
}));
|
|
3096
3096
|
const o = n.imageUrl;
|
|
3097
|
-
if (o &&
|
|
3097
|
+
if (o && fe(o)) {
|
|
3098
3098
|
const b = document.createElement("div");
|
|
3099
3099
|
b.className = "gengage-chat-product-card-img-wrapper";
|
|
3100
3100
|
const C = document.createElement("img");
|
|
3101
3101
|
C.className = "gengage-chat-product-card-img", C.loading = "lazy", oe(C, "src", o);
|
|
3102
3102
|
const F = n.name;
|
|
3103
|
-
F && (C.alt = F),
|
|
3103
|
+
F && (C.alt = F), me(C), b.appendChild(C);
|
|
3104
3104
|
const j = n.discountPercent;
|
|
3105
3105
|
if (!e.hideProductDiscountBadge && typeof j == "number" && j > 0) {
|
|
3106
3106
|
const M = document.createElement("span");
|
|
@@ -3180,7 +3180,7 @@ function st(a, e) {
|
|
|
3180
3180
|
b.className = `gengage-chat-product-card-stock ${E ? "is-in-stock" : "is-out-of-stock"}`, b.textContent = E ? e.i18n?.inStockLabel ?? "In Stock" : e.i18n?.outOfStockLabel ?? "Out of Stock", s.appendChild(b);
|
|
3181
3181
|
}
|
|
3182
3182
|
t.appendChild(s);
|
|
3183
|
-
const
|
|
3183
|
+
const R = n.url, W = n.sku, Z = n.cartCode, L = !!(Z && W && E !== !1), P = e.i18n?.productCtaLabel ?? "View";
|
|
3184
3184
|
if (L) {
|
|
3185
3185
|
const b = document.createElement("div");
|
|
3186
3186
|
b.className = "gengage-chat-product-card-buy-footer";
|
|
@@ -3205,16 +3205,16 @@ function st(a, e) {
|
|
|
3205
3205
|
}
|
|
3206
3206
|
e.onAction(r);
|
|
3207
3207
|
}), t.appendChild(b);
|
|
3208
|
-
} else if (
|
|
3208
|
+
} else if (R && fe(R)) {
|
|
3209
3209
|
const b = document.createElement("a");
|
|
3210
|
-
b.className = "gengage-chat-product-card-cta", oe(b, "href",
|
|
3210
|
+
b.className = "gengage-chat-product-card-cta", oe(b, "href", R), oe(b, "target", "_blank"), oe(b, "rel", "noopener noreferrer"), b.textContent = P, b.addEventListener("click", (C) => {
|
|
3211
3211
|
if (t.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")) {
|
|
3212
3212
|
C.preventDefault(), C.stopPropagation();
|
|
3213
3213
|
return;
|
|
3214
3214
|
}
|
|
3215
3215
|
e.onProductClick && W && (C.preventDefault(), e.onProductClick({
|
|
3216
3216
|
sku: W,
|
|
3217
|
-
url:
|
|
3217
|
+
url: R,
|
|
3218
3218
|
..._ ? { name: _ } : {}
|
|
3219
3219
|
}));
|
|
3220
3220
|
}), t.appendChild(b);
|
|
@@ -3317,17 +3317,17 @@ function Bi(a, ...e) {
|
|
|
3317
3317
|
function zi(a) {
|
|
3318
3318
|
return Array.isArray(a) ? a.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
|
|
3319
3319
|
}
|
|
3320
|
-
function
|
|
3321
|
-
const e = [...zi(a.images), ge(a, "imageUrl", "image_url", "image")].filter((t) => !!t &&
|
|
3320
|
+
function Ri(a) {
|
|
3321
|
+
const e = [...zi(a.images), ge(a, "imageUrl", "image_url", "image")].filter((t) => !!t && fe(t));
|
|
3322
3322
|
return Array.from(new Set(e));
|
|
3323
3323
|
}
|
|
3324
|
-
function
|
|
3324
|
+
function Hi(a) {
|
|
3325
3325
|
return typeof DOMParser < "u" ? (new DOMParser().parseFromString(a, "text/html").body.textContent ?? "").replace(/\s+/g, " ").trim() : a.replace(/<[^>]*>/g, " ").replace(/\s+/g, " ").trim();
|
|
3326
3326
|
}
|
|
3327
3327
|
function Fi(a) {
|
|
3328
3328
|
const e = ge(a, "description_html", "descriptionHtml");
|
|
3329
3329
|
if (e) {
|
|
3330
|
-
const n =
|
|
3330
|
+
const n = Hi(e);
|
|
3331
3331
|
if (n) return {
|
|
3332
3332
|
text: n,
|
|
3333
3333
|
html: e
|
|
@@ -3441,12 +3441,12 @@ function Yi(a, e) {
|
|
|
3441
3441
|
t.className = "gengage-chat-product-details-panel";
|
|
3442
3442
|
const n = a.props?.product ?? a.props;
|
|
3443
3443
|
if (!n) return t;
|
|
3444
|
-
const i = ge(n, "name"), r = ge(n, "brand"), o = ge(n, "sku"), s = ge(n, "cartCode", "cart_code"), c = ge(n, "price"), l = ge(n, "originalPrice", "price_original"), d = je(n, "price_async"), g = Be(e, n), h = Oe(e, n), u = !!(l && c && l !== c), y = je(n, "inStock", "in_stock"), p = Ve(n, "reviewCount", "review_count"), f = Ve(n, "rating"), m =
|
|
3444
|
+
const i = ge(n, "name"), r = ge(n, "brand"), o = ge(n, "sku"), s = ge(n, "cartCode", "cart_code"), c = ge(n, "price"), l = ge(n, "originalPrice", "price_original"), d = je(n, "price_async"), g = Be(e, n), h = Oe(e, n), u = !!(l && c && l !== c), y = je(n, "inStock", "in_stock"), p = Ve(n, "reviewCount", "review_count"), f = Ve(n, "rating"), m = Ri(n), S = ia(n).slice(0, 4);
|
|
3445
3445
|
if (m.length > 1) {
|
|
3446
3446
|
const L = document.createElement("div");
|
|
3447
3447
|
L.className = "gengage-chat-product-details-media gengage-chat-product-details-gallery gengage-chat-product-details-img-wrap";
|
|
3448
3448
|
const P = document.createElement("img");
|
|
3449
|
-
P.className = "gengage-chat-product-details-img", oe(P, "src", m[0]), P.alt = i ?? "Product image",
|
|
3449
|
+
P.className = "gengage-chat-product-details-img", oe(P, "src", m[0]), P.alt = i ?? "Product image", me(P), L.appendChild(P);
|
|
3450
3450
|
const b = document.createElement("div");
|
|
3451
3451
|
b.className = "gengage-chat-product-gallery-thumbs";
|
|
3452
3452
|
const C = 6;
|
|
@@ -3469,7 +3469,7 @@ function Yi(a, e) {
|
|
|
3469
3469
|
const Y = m[A];
|
|
3470
3470
|
if (A >= C) break;
|
|
3471
3471
|
const V = document.createElement("img");
|
|
3472
|
-
V.className = "gengage-chat-product-gallery-thumb", A === 0 && (V.classList.add("gengage-chat-product-gallery-thumb--active"), F = V), oe(V, "src", Y), V.alt = `${i ?? "Product"} ${A + 1}`, V.width = 48, V.height = 48,
|
|
3472
|
+
V.className = "gengage-chat-product-gallery-thumb", A === 0 && (V.classList.add("gengage-chat-product-gallery-thumb--active"), F = V), oe(V, "src", Y), V.alt = `${i ?? "Product"} ${A + 1}`, V.width = 48, V.height = 48, me(V), V.addEventListener("click", () => {
|
|
3473
3473
|
x(A);
|
|
3474
3474
|
}), b.appendChild(V);
|
|
3475
3475
|
}
|
|
@@ -3483,18 +3483,18 @@ function Yi(a, e) {
|
|
|
3483
3483
|
A.stopPropagation(), x(j + 1);
|
|
3484
3484
|
}), N();
|
|
3485
3485
|
let B = 0;
|
|
3486
|
-
const
|
|
3486
|
+
const H = 50;
|
|
3487
3487
|
P.addEventListener("touchstart", (A) => {
|
|
3488
3488
|
B = A.changedTouches[0].clientX;
|
|
3489
3489
|
}, { passive: !0 }), P.addEventListener("touchend", (A) => {
|
|
3490
3490
|
const Y = A.changedTouches[0].clientX, V = B - Y;
|
|
3491
|
-
Math.abs(V) <
|
|
3491
|
+
Math.abs(V) < H || x(V > 0 ? Math.min(j + 1, m.length - 1) : Math.max(j - 1, 0));
|
|
3492
3492
|
}), L.appendChild(M), L.appendChild(v), L.appendChild(b), t.appendChild(L);
|
|
3493
3493
|
} else if (m.length === 1) {
|
|
3494
3494
|
const L = document.createElement("div");
|
|
3495
3495
|
L.className = "gengage-chat-product-details-media gengage-chat-product-details-img-wrap";
|
|
3496
3496
|
const P = document.createElement("img");
|
|
3497
|
-
P.className = "gengage-chat-product-details-img", P.loading = "lazy", oe(P, "src", m[0]),
|
|
3497
|
+
P.className = "gengage-chat-product-details-img", P.loading = "lazy", oe(P, "src", m[0]), me(P), P.alt = i ?? "Product image", L.appendChild(P), t.appendChild(L);
|
|
3498
3498
|
}
|
|
3499
3499
|
const T = document.createElement("div");
|
|
3500
3500
|
if (T.className = "gengage-chat-product-details-content", r && (!i || !i.toLowerCase().startsWith(r.toLowerCase()))) {
|
|
@@ -3592,9 +3592,9 @@ function Yi(a, e) {
|
|
|
3592
3592
|
const q = je(C, "in_stock", "inStock");
|
|
3593
3593
|
j && o && j === o ? (D.classList.add("gengage-chat-product-variant-btn--active"), D.setAttribute("aria-pressed", "true")) : D.setAttribute("aria-pressed", "false"), q === !1 && (D.classList.add("gengage-chat-product-variant-btn--out"), D.disabled = !0);
|
|
3594
3594
|
const X = ji(C), M = Oi(C);
|
|
3595
|
-
if (X &&
|
|
3595
|
+
if (X && fe(X)) {
|
|
3596
3596
|
const x = document.createElement("img");
|
|
3597
|
-
x.className = "gengage-chat-product-variant-swatch gengage-chat-product-variant-swatch--image", oe(x, "src", X), x.alt = "", x.setAttribute("aria-hidden", "true"),
|
|
3597
|
+
x.className = "gengage-chat-product-variant-swatch gengage-chat-product-variant-swatch--image", oe(x, "src", X), x.alt = "", x.setAttribute("aria-hidden", "true"), me(x), D.appendChild(x);
|
|
3598
3598
|
} else if (M) {
|
|
3599
3599
|
const x = document.createElement("span");
|
|
3600
3600
|
x.className = "gengage-chat-product-variant-swatch", x.setAttribute("aria-hidden", "true"), x.style.backgroundColor = M, D.appendChild(x);
|
|
@@ -3607,10 +3607,10 @@ function Yi(a, e) {
|
|
|
3607
3607
|
x.className = "gengage-chat-product-variant-price", x.textContent = J(String(N), e.pricing), D.appendChild(x);
|
|
3608
3608
|
}
|
|
3609
3609
|
if (j && j !== o) {
|
|
3610
|
-
const x = i ?? "", B = (typeof C.value == "string" ? C.value.trim() : "") || (typeof C.name == "string" ? C.name.trim() : "") || (typeof C.variant_name == "string" ? C.variant_name.trim() : "") || "",
|
|
3610
|
+
const x = i ?? "", B = (typeof C.value == "string" ? C.value.trim() : "") || (typeof C.name == "string" ? C.name.trim() : "") || (typeof C.variant_name == "string" ? C.variant_name.trim() : "") || "", H = x.length > 0 ? B.length > 0 && B !== x ? `${x} (${B})` : x : G;
|
|
3611
3611
|
D.addEventListener("click", () => {
|
|
3612
3612
|
e.onAction({
|
|
3613
|
-
title:
|
|
3613
|
+
title: H,
|
|
3614
3614
|
type: "launchVariant",
|
|
3615
3615
|
payload: { sku: j }
|
|
3616
3616
|
});
|
|
@@ -3642,7 +3642,7 @@ function Yi(a, e) {
|
|
|
3642
3642
|
}), z.appendChild(L);
|
|
3643
3643
|
}
|
|
3644
3644
|
const E = ge(n, "url");
|
|
3645
|
-
if (!_ && E &&
|
|
3645
|
+
if (!_ && E && fe(E)) {
|
|
3646
3646
|
const L = document.createElement("a");
|
|
3647
3647
|
L.className = "gengage-chat-product-details-cta gds-btn gds-btn-secondary", oe(L, "href", E), oe(L, "target", "_blank"), oe(L, "rel", "noopener noreferrer"), L.textContent = e.i18n?.viewOnSiteLabel ?? e.i18n?.productCtaLabel ?? "View on Site", L.addEventListener("click", (P) => {
|
|
3648
3648
|
e.onProductClick && o && (P.preventDefault(), e.onProductClick({
|
|
@@ -3652,8 +3652,8 @@ function Yi(a, e) {
|
|
|
3652
3652
|
}));
|
|
3653
3653
|
}), z.appendChild(L);
|
|
3654
3654
|
}
|
|
3655
|
-
const
|
|
3656
|
-
if (
|
|
3655
|
+
const R = E;
|
|
3656
|
+
if (R && fe(R)) {
|
|
3657
3657
|
let F = function(D, G) {
|
|
3658
3658
|
const q = document.createElementNS(b, "circle");
|
|
3659
3659
|
q.setAttribute("cx", D), q.setAttribute("cy", G), q.setAttribute("r", "3"), C.appendChild(q);
|
|
@@ -3670,8 +3670,8 @@ function Yi(a, e) {
|
|
|
3670
3670
|
try {
|
|
3671
3671
|
navigator.share ? await navigator.share({
|
|
3672
3672
|
title: i ?? "",
|
|
3673
|
-
url:
|
|
3674
|
-
}) : navigator.clipboard && (await navigator.clipboard.writeText(
|
|
3673
|
+
url: R
|
|
3674
|
+
}) : navigator.clipboard && (await navigator.clipboard.writeText(R), L.classList.add("gengage-chat-product-details-share--copied"), setTimeout(() => L.classList.remove("gengage-chat-product-details-share--copied"), 1500));
|
|
3675
3675
|
} catch {
|
|
3676
3676
|
}
|
|
3677
3677
|
}), z.appendChild(L);
|
|
@@ -3860,12 +3860,12 @@ function nr(a, e, t, n) {
|
|
|
3860
3860
|
z.className = "gengage-chat-product-sort-menu gds-menu", z.hidden = !0, z.setAttribute("role", "listbox"), z.setAttribute("aria-label", m);
|
|
3861
3861
|
const _ = h.ownerDocument;
|
|
3862
3862
|
let E = null;
|
|
3863
|
-
const
|
|
3863
|
+
const R = () => {
|
|
3864
3864
|
z.hidden = !0, p.classList.remove("gengage-chat-product-sort-dropdown--open"), f.setAttribute("aria-expanded", "false"), E?.abort(), E = null;
|
|
3865
3865
|
}, W = (P) => {
|
|
3866
|
-
p.classList.contains("gengage-chat-product-sort-dropdown--open") && (p.contains(P.target) ||
|
|
3866
|
+
p.classList.contains("gengage-chat-product-sort-dropdown--open") && (p.contains(P.target) || R());
|
|
3867
3867
|
}, Z = (P) => {
|
|
3868
|
-
P.key === "Escape" && (P.preventDefault(),
|
|
3868
|
+
P.key === "Escape" && (P.preventDefault(), R());
|
|
3869
3869
|
}, L = () => {
|
|
3870
3870
|
z.hidden = !1, p.classList.add("gengage-chat-product-sort-dropdown--open"), f.setAttribute("aria-expanded", "true"), E = new AbortController();
|
|
3871
3871
|
const { signal: P } = E;
|
|
@@ -3875,7 +3875,7 @@ function nr(a, e, t, n) {
|
|
|
3875
3875
|
});
|
|
3876
3876
|
};
|
|
3877
3877
|
f.addEventListener("click", (P) => {
|
|
3878
|
-
P.stopPropagation(), p.classList.contains("gengage-chat-product-sort-dropdown--open") ?
|
|
3878
|
+
P.stopPropagation(), p.classList.contains("gengage-chat-product-sort-dropdown--open") ? R() : L();
|
|
3879
3879
|
});
|
|
3880
3880
|
for (const P of y) {
|
|
3881
3881
|
const b = document.createElement("button");
|
|
@@ -3893,7 +3893,7 @@ function nr(a, e, t, n) {
|
|
|
3893
3893
|
u = P.sortState, n.onSortChange?.(P.sortState), ar(c, s, e, P.sortState), z.querySelectorAll(".gengage-chat-product-sort-option").forEach((q) => {
|
|
3894
3894
|
const X = q, M = X.dataset.sortKey === F;
|
|
3895
3895
|
X.classList.toggle("gengage-chat-product-sort-option--active", M), X.classList.toggle("gds-menu-option-active", M), X.setAttribute("aria-selected", M ? "true" : "false"), X.querySelector(".gengage-chat-product-sort-option-check")?.classList.toggle("gengage-chat-product-sort-option-check--hidden", !M);
|
|
3896
|
-
}), k(P.sortState),
|
|
3896
|
+
}), k(P.sortState), R();
|
|
3897
3897
|
}), z.appendChild(b);
|
|
3898
3898
|
}
|
|
3899
3899
|
if (p.appendChild(f), p.appendChild(z), h.appendChild(p), n.onToggleComparisonSku) {
|
|
@@ -4072,16 +4072,16 @@ function ht(a, e) {
|
|
|
4072
4072
|
z.className = "gengage-chat-consulting-group-header";
|
|
4073
4073
|
const _ = document.createElement("h4");
|
|
4074
4074
|
if (_.className = "gengage-chat-consulting-group-label", _.textContent = `${m} (${S.length})`, z.appendChild(_), typeof k == "string" && k.trim().length > 0) {
|
|
4075
|
-
const
|
|
4076
|
-
|
|
4075
|
+
const R = document.createElement("p");
|
|
4076
|
+
R.className = "gengage-chat-consulting-group-reason", R.textContent = k, z.appendChild(R);
|
|
4077
4077
|
}
|
|
4078
4078
|
I.appendChild(z);
|
|
4079
4079
|
const E = document.createElement("div");
|
|
4080
4080
|
E.className = "gengage-chat-product-grid gengage-chat-consulting-group-grid", T && E.classList.add("gengage-chat-consulting-group-grid--single-group"), E.style.setProperty("--consulting-group-columns", String(Math.max(1, Math.min(4, S.length))));
|
|
4081
|
-
for (const
|
|
4081
|
+
for (const R of S) {
|
|
4082
4082
|
const W = st({
|
|
4083
4083
|
type: "ProductCard",
|
|
4084
|
-
props: { product:
|
|
4084
|
+
props: { product: R }
|
|
4085
4085
|
}, r ?? { onAction: () => {
|
|
4086
4086
|
} });
|
|
4087
4087
|
E.appendChild(W);
|
|
@@ -4125,9 +4125,9 @@ function gt(a, e, t, n) {
|
|
|
4125
4125
|
let s = a.querySelector(".gengage-chat-consulting-style-media");
|
|
4126
4126
|
s ? s.innerHTML = "" : (s = document.createElement("div"), s.className = "gengage-chat-consulting-style-media", a.appendChild(s));
|
|
4127
4127
|
const c = or(e.image_url);
|
|
4128
|
-
if (c &&
|
|
4128
|
+
if (c && fe(c)) {
|
|
4129
4129
|
const d = document.createElement("img");
|
|
4130
|
-
d.className = "gengage-chat-consulting-style-image", d.draggable = !1, oe(d, "src", c), d.alt = qe(e, t + 1, n), d.loading = "lazy",
|
|
4130
|
+
d.className = "gengage-chat-consulting-style-image", d.draggable = !1, oe(d, "src", c), d.alt = qe(e, t + 1, n), d.loading = "lazy", me(d), s.appendChild(d);
|
|
4131
4131
|
}
|
|
4132
4132
|
const l = document.createElement("span");
|
|
4133
4133
|
if (l.className = "gengage-chat-consulting-style-caption", l.textContent = qe(e, t + 1, n), s.appendChild(l), i === "loading" || i !== "ready") {
|
|
@@ -4578,9 +4578,9 @@ function br(a, e, t) {
|
|
|
4578
4578
|
}
|
|
4579
4579
|
const I = document.createElement("div");
|
|
4580
4580
|
I.className = "gengage-fl", I.dataset.gengagePart = "floating-launcher", I.innerHTML = fr();
|
|
4581
|
-
const z = I.querySelector(".gengage-fl-input"), _ = I.querySelector(".gengage-fl-transcript"), E = I.querySelector(".gengage-fl-transcript-final"),
|
|
4581
|
+
const z = I.querySelector(".gengage-fl-input"), _ = I.querySelector(".gengage-fl-transcript"), E = I.querySelector(".gengage-fl-transcript-final"), R = I.querySelector(".gengage-fl-transcript-interim"), W = I.querySelector(".gengage-fl-btn-send"), Z = I.querySelector(".gengage-fl-btn-mic"), L = I.querySelector(".gengage-fl-btn-open-chat"), P = I.querySelector(".gengage-fl-cancel"), b = I.querySelector(".gengage-fl-wave"), C = I.querySelector(".gengage-fl-ring");
|
|
4582
4582
|
z.placeholder = u[0] ?? "", W.setAttribute("aria-label", m), Z.setAttribute("aria-label", S), P.setAttribute("aria-label", T), L.setAttribute("aria-label", k);
|
|
4583
|
-
let F = !1, j = !1, D = "", G = !1, q = null, X = 0, M = null, v = null, N = null, x = null, B = null,
|
|
4583
|
+
let F = !1, j = !1, D = "", G = !1, q = null, X = 0, M = null, v = null, N = null, x = null, B = null, H = 0;
|
|
4584
4584
|
function A() {
|
|
4585
4585
|
const O = z.value.trim().length > 0;
|
|
4586
4586
|
if (Z.classList.toggle("is-recording", F), F) {
|
|
@@ -4599,7 +4599,7 @@ function br(a, e, t) {
|
|
|
4599
4599
|
M !== null && (clearTimeout(M), M = null);
|
|
4600
4600
|
}
|
|
4601
4601
|
function ae() {
|
|
4602
|
-
F && (F = !1, ce(), j = !1, te(), f && ie(), D = "", z.style.display = "", _.style.display = "none", E.textContent = "",
|
|
4602
|
+
F && (F = !1, ce(), j = !1, te(), f && ie(), D = "", z.style.display = "", _.style.display = "none", E.textContent = "", R.textContent = "");
|
|
4603
4603
|
const O = z.value.trim();
|
|
4604
4604
|
O && (e.onSend(O), G || (G = !0)), z.value = "", D = "", A();
|
|
4605
4605
|
}
|
|
@@ -4609,16 +4609,16 @@ function br(a, e, t) {
|
|
|
4609
4609
|
console.warn("[FloatingLauncher] SpeechRecognition not supported.");
|
|
4610
4610
|
return;
|
|
4611
4611
|
}
|
|
4612
|
-
q || (q = new Q(), q.continuous = !0, q.interimResults = !0, q.lang = p), F = !0, j = !0, D = "", z.value = "", z.style.display = "none", _.style.display = "flex", E.textContent = "",
|
|
4612
|
+
q || (q = new Q(), q.continuous = !0, q.interimResults = !0, q.lang = p), F = !0, j = !0, D = "", z.value = "", z.style.display = "none", _.style.display = "flex", E.textContent = "", R.textContent = "", A(), K(), f && ne(), q.onresult = (U) => {
|
|
4613
4613
|
if (!F) return;
|
|
4614
4614
|
let re = "", ze = "";
|
|
4615
4615
|
for (let Ce = U.resultIndex; Ce < U.results.length; Ce++) {
|
|
4616
4616
|
const Pe = U.results[Ce];
|
|
4617
4617
|
if (!Pe) continue;
|
|
4618
|
-
const
|
|
4619
|
-
Pe.isFinal ? ze +=
|
|
4618
|
+
const Re = Pe[0]?.transcript ?? "";
|
|
4619
|
+
Pe.isFinal ? ze += Re : re += Re;
|
|
4620
4620
|
}
|
|
4621
|
-
D += ze, E.textContent = D,
|
|
4621
|
+
D += ze, E.textContent = D, R.textContent = re, z.value = `${D} ${re}`.trim(), A();
|
|
4622
4622
|
}, q.onend = () => w(), q.onerror = () => w();
|
|
4623
4623
|
try {
|
|
4624
4624
|
q.start();
|
|
@@ -4633,13 +4633,13 @@ function br(a, e, t) {
|
|
|
4633
4633
|
}
|
|
4634
4634
|
}
|
|
4635
4635
|
function w() {
|
|
4636
|
-
j && (j = !1, F = !1, te(), f && ie(), D.trim() && (z.value = D.trim()), z.style.display = "", _.style.display = "none", E.textContent = "",
|
|
4636
|
+
j && (j = !1, F = !1, te(), f && ie(), D.trim() && (z.value = D.trim()), z.style.display = "", _.style.display = "none", E.textContent = "", R.textContent = "", A());
|
|
4637
4637
|
}
|
|
4638
4638
|
async function K() {
|
|
4639
|
-
const O = ++
|
|
4639
|
+
const O = ++H, Q = Array.from(b.querySelectorAll("span"));
|
|
4640
4640
|
try {
|
|
4641
4641
|
const U = await navigator.mediaDevices.getUserMedia({ audio: !0 });
|
|
4642
|
-
if (!F || O !==
|
|
4642
|
+
if (!F || O !== H) {
|
|
4643
4643
|
U.getTracks().forEach((Le) => Le.stop());
|
|
4644
4644
|
return;
|
|
4645
4645
|
}
|
|
@@ -4648,29 +4648,29 @@ function br(a, e, t) {
|
|
|
4648
4648
|
if (!ze)
|
|
4649
4649
|
throw v = null, U.getTracks().forEach((Le) => Le.stop()), new Error("AudioContext not supported");
|
|
4650
4650
|
const Ce = new ze();
|
|
4651
|
-
if (!F || O !==
|
|
4651
|
+
if (!F || O !== H) {
|
|
4652
4652
|
U.getTracks().forEach((Le) => Le.stop()), Ce.close().catch(() => {
|
|
4653
4653
|
});
|
|
4654
4654
|
return;
|
|
4655
4655
|
}
|
|
4656
4656
|
N = Ce, x = Ce.createAnalyser(), x.fftSize = 256, Ce.createMediaStreamSource(U).connect(x);
|
|
4657
|
-
const Pe = new Uint8Array(x.frequencyBinCount),
|
|
4658
|
-
if (!F || O !==
|
|
4657
|
+
const Pe = new Uint8Array(x.frequencyBinCount), Re = () => {
|
|
4658
|
+
if (!F || O !== H || !x) return;
|
|
4659
4659
|
x.getByteFrequencyData(Pe);
|
|
4660
4660
|
const Le = Math.max(1, Math.floor(Pe.length / Q.length));
|
|
4661
4661
|
Q.forEach((ha, ua) => {
|
|
4662
4662
|
ha.style.height = `${4 + Math.round((Pe[ua * Le] ?? 0) / 255 * 8)}px`;
|
|
4663
|
-
}), B = requestAnimationFrame(
|
|
4663
|
+
}), B = requestAnimationFrame(Re);
|
|
4664
4664
|
};
|
|
4665
|
-
|
|
4665
|
+
Re();
|
|
4666
4666
|
} catch {
|
|
4667
|
-
if (!F || O !==
|
|
4667
|
+
if (!F || O !== H) return;
|
|
4668
4668
|
B !== null && (cancelAnimationFrame(B), B = null), x && (x.disconnect(), x = null), N && (N.close().catch(() => {
|
|
4669
4669
|
}), N = null), v && (v.getTracks().forEach((U) => U.stop()), v = null), b.classList.add("is-css-animated");
|
|
4670
4670
|
}
|
|
4671
4671
|
}
|
|
4672
4672
|
function te() {
|
|
4673
|
-
|
|
4673
|
+
H += 1, b.classList.remove("is-css-animated"), B !== null && (cancelAnimationFrame(B), B = null), x && (x.disconnect(), x = null), N && (N.close().catch(() => {
|
|
4674
4674
|
}), N = null), v && (v.getTracks().forEach((O) => O.stop()), v = null), Array.from(b.querySelectorAll("span")).forEach((O) => {
|
|
4675
4675
|
O.style.height = "4px";
|
|
4676
4676
|
});
|
|
@@ -4684,7 +4684,7 @@ function br(a, e, t) {
|
|
|
4684
4684
|
W.addEventListener("click", ae), Z.addEventListener("click", (O) => {
|
|
4685
4685
|
O.preventDefault(), O.stopPropagation(), F ? ce() : se();
|
|
4686
4686
|
}), P.addEventListener("click", () => {
|
|
4687
|
-
F && (F = !1, ce(), j = !1, te(), f && ie(), D = "", z.style.display = "", _.style.display = "none", E.textContent = "",
|
|
4687
|
+
F && (F = !1, ce(), j = !1, te(), f && ie(), D = "", z.style.display = "", _.style.display = "none", E.textContent = "", R.textContent = "", A());
|
|
4688
4688
|
}), L.addEventListener("click", (O) => {
|
|
4689
4689
|
O.preventDefault(), O.stopPropagation(), e.onOpenChat();
|
|
4690
4690
|
}), z.addEventListener("input", A), z.addEventListener("keydown", (O) => {
|
|
@@ -4870,7 +4870,7 @@ function Ar(a) {
|
|
|
4870
4870
|
pt(a.threadId), e.remove(), a.onDismiss?.();
|
|
4871
4871
|
}), r.appendChild(s), e.appendChild(r), e;
|
|
4872
4872
|
}
|
|
4873
|
-
function
|
|
4873
|
+
function Rt() {
|
|
4874
4874
|
try {
|
|
4875
4875
|
sessionStorage.removeItem(We), sessionStorage.removeItem(Tr);
|
|
4876
4876
|
} catch {
|
|
@@ -4894,8 +4894,8 @@ function pt(a) {
|
|
|
4894
4894
|
function Mr(a) {
|
|
4895
4895
|
a && pt(a);
|
|
4896
4896
|
}
|
|
4897
|
-
var Nr = "gengage_assistant", Br = 3, Se = "sessions",
|
|
4898
|
-
function
|
|
4897
|
+
var Nr = "gengage_assistant", Br = 3, Se = "sessions", be = "context", ye = "payload", ve = "favorites";
|
|
4898
|
+
function He(a) {
|
|
4899
4899
|
return new Promise((e, t) => {
|
|
4900
4900
|
a.onsuccess = () => e(a.result), a.onerror = () => t(a.error);
|
|
4901
4901
|
});
|
|
@@ -4918,15 +4918,15 @@ var zr = class {
|
|
|
4918
4918
|
"userId",
|
|
4919
4919
|
"appId",
|
|
4920
4920
|
"sessionId"
|
|
4921
|
-
] }), i.createObjectStore(
|
|
4921
|
+
] }), i.createObjectStore(be, { keyPath: ["sessionId", "threadId"] }), i.createObjectStore(ye, { keyPath: ["threadId", "messageId"] }).createIndex("threadId", "threadId", { unique: !1 }), i.createObjectStore(ve, { keyPath: [
|
|
4922
4922
|
"userId",
|
|
4923
4923
|
"appId",
|
|
4924
4924
|
"sku"
|
|
4925
|
-
] })), r >= 1 && r < 2 && (i.objectStoreNames.contains(Se) && i.deleteObjectStore(Se), i.objectStoreNames.contains(
|
|
4925
|
+
] })), r >= 1 && r < 2 && (i.objectStoreNames.contains(Se) && i.deleteObjectStore(Se), i.objectStoreNames.contains(ye) && i.deleteObjectStore(ye), i.createObjectStore(Se, { keyPath: [
|
|
4926
4926
|
"userId",
|
|
4927
4927
|
"appId",
|
|
4928
4928
|
"sessionId"
|
|
4929
|
-
] }), i.createObjectStore(
|
|
4929
|
+
] }), i.createObjectStore(ye, { keyPath: ["threadId", "messageId"] }).createIndex("threadId", "threadId", { unique: !1 }), i.objectStoreNames.contains(be) || i.createObjectStore(be, { keyPath: ["sessionId", "threadId"] })), r < 3 && (i.objectStoreNames.contains(ve) || i.createObjectStore(ve, { keyPath: [
|
|
4930
4930
|
"userId",
|
|
4931
4931
|
"appId",
|
|
4932
4932
|
"sku"
|
|
@@ -4944,21 +4944,21 @@ var zr = class {
|
|
|
4944
4944
|
e.objectStore(Se).put(a), await Ae(e);
|
|
4945
4945
|
}
|
|
4946
4946
|
async loadSession(a, e, t) {
|
|
4947
|
-
return await
|
|
4947
|
+
return await He(this._requireDb().transaction(Se, "readonly").objectStore(Se).get([
|
|
4948
4948
|
a,
|
|
4949
4949
|
e,
|
|
4950
4950
|
t
|
|
4951
4951
|
])) ?? null;
|
|
4952
4952
|
}
|
|
4953
4953
|
async saveContext(a) {
|
|
4954
|
-
const e = this._requireDb().transaction(
|
|
4955
|
-
e.objectStore(
|
|
4954
|
+
const e = this._requireDb().transaction(be, "readwrite");
|
|
4955
|
+
e.objectStore(be).put(a), await Ae(e);
|
|
4956
4956
|
}
|
|
4957
4957
|
async loadContext(a, e) {
|
|
4958
|
-
return await
|
|
4958
|
+
return await He(this._requireDb().transaction(be, "readonly").objectStore(be).get([a, e])) ?? null;
|
|
4959
4959
|
}
|
|
4960
4960
|
async deleteContextsAfterThread(a, e) {
|
|
4961
|
-
const t = this._requireDb().transaction(
|
|
4961
|
+
const t = this._requireDb().transaction(be, "readwrite"), n = t.objectStore(be).openCursor();
|
|
4962
4962
|
await new Promise((i, r) => {
|
|
4963
4963
|
n.onsuccess = () => {
|
|
4964
4964
|
const o = n.result;
|
|
@@ -4976,7 +4976,7 @@ var zr = class {
|
|
|
4976
4976
|
}), await Ae(t);
|
|
4977
4977
|
}
|
|
4978
4978
|
async loadLatestContext(a) {
|
|
4979
|
-
const e = this._requireDb().transaction(
|
|
4979
|
+
const e = this._requireDb().transaction(be, "readonly").objectStore(be), t = IDBKeyRange.bound([a, ""], [a, ""]);
|
|
4980
4980
|
return new Promise((n, i) => {
|
|
4981
4981
|
const r = e.openCursor(t, "prev");
|
|
4982
4982
|
r.onsuccess = () => {
|
|
@@ -4986,14 +4986,14 @@ var zr = class {
|
|
|
4986
4986
|
});
|
|
4987
4987
|
}
|
|
4988
4988
|
async savePayload(a) {
|
|
4989
|
-
const e = this._requireDb().transaction(
|
|
4990
|
-
e.objectStore(
|
|
4989
|
+
const e = this._requireDb().transaction(ye, "readwrite");
|
|
4990
|
+
e.objectStore(ye).put(a), await Ae(e);
|
|
4991
4991
|
}
|
|
4992
4992
|
async loadPayload(a, e) {
|
|
4993
|
-
return await
|
|
4993
|
+
return await He(this._requireDb().transaction(ye, "readonly").objectStore(ye).get([a, e])) ?? null;
|
|
4994
4994
|
}
|
|
4995
4995
|
async loadPayloadsByThread(a) {
|
|
4996
|
-
const e = this._requireDb().transaction(
|
|
4996
|
+
const e = this._requireDb().transaction(ye, "readonly").objectStore(ye).index("threadId"), t = [];
|
|
4997
4997
|
return new Promise((n, i) => {
|
|
4998
4998
|
const r = e.openCursor(IDBKeyRange.only(a));
|
|
4999
4999
|
r.onsuccess = () => {
|
|
@@ -5007,22 +5007,22 @@ var zr = class {
|
|
|
5007
5007
|
});
|
|
5008
5008
|
}
|
|
5009
5009
|
async saveFavorite(a) {
|
|
5010
|
-
const e = this._requireDb().transaction(
|
|
5011
|
-
e.objectStore(
|
|
5010
|
+
const e = this._requireDb().transaction(ve, "readwrite");
|
|
5011
|
+
e.objectStore(ve).put(a), await Ae(e);
|
|
5012
5012
|
}
|
|
5013
5013
|
async removeFavorite(a, e, t) {
|
|
5014
|
-
const n = this._requireDb().transaction(
|
|
5015
|
-
n.objectStore(
|
|
5014
|
+
const n = this._requireDb().transaction(ve, "readwrite");
|
|
5015
|
+
n.objectStore(ve).delete([
|
|
5016
5016
|
a,
|
|
5017
5017
|
e,
|
|
5018
5018
|
t
|
|
5019
5019
|
]), await Ae(n);
|
|
5020
5020
|
}
|
|
5021
5021
|
async loadFavorites(a, e) {
|
|
5022
|
-
return (await
|
|
5022
|
+
return (await He(this._requireDb().transaction(ve, "readonly").objectStore(ve).getAll())).filter((t) => t.userId === a && t.appId === e);
|
|
5023
5023
|
}
|
|
5024
5024
|
async isFavorite(a, e, t) {
|
|
5025
|
-
return await
|
|
5025
|
+
return await He(this._requireDb().transaction(ve, "readonly").objectStore(ve).get([
|
|
5026
5026
|
a,
|
|
5027
5027
|
e,
|
|
5028
5028
|
t
|
|
@@ -5032,15 +5032,15 @@ var zr = class {
|
|
|
5032
5032
|
if (!this._db) throw new Error("GengageIndexedDB: database not open. Call open() first.");
|
|
5033
5033
|
return this._db;
|
|
5034
5034
|
}
|
|
5035
|
-
},
|
|
5035
|
+
}, Rr = [
|
|
5036
5036
|
"comparisonTable",
|
|
5037
5037
|
"groupList",
|
|
5038
5038
|
"productDetailsSimilars",
|
|
5039
5039
|
"productList"
|
|
5040
|
-
],
|
|
5040
|
+
], Hr = class {
|
|
5041
5041
|
constructor(a) {
|
|
5042
5042
|
this._lockCount = 1, this._hiddenByUser = !1, this._lastPanelContentType = null, this._chatShown = !1, this._isFavoritesMode = !1, this._lastExtended = !1, this._onChange = a.onChange;
|
|
5043
|
-
const e = new Set(
|
|
5043
|
+
const e = new Set(Rr);
|
|
5044
5044
|
a.productDetailsInPanel && e.add("productDetails"), this._panelContentTypes = e;
|
|
5045
5045
|
}
|
|
5046
5046
|
get isExtended() {
|
|
@@ -5121,7 +5121,7 @@ var zr = class {
|
|
|
5121
5121
|
case "ProductDetailsPanel":
|
|
5122
5122
|
return t.panelTitleProductDetails;
|
|
5123
5123
|
case "ProductGrid":
|
|
5124
|
-
return
|
|
5124
|
+
return Ht(this.lastActionType) ? t.panelTitleSearchResults : t.panelTitleSimilarProducts;
|
|
5125
5125
|
case "ComparisonTable":
|
|
5126
5126
|
return t.panelTitleComparisonResults;
|
|
5127
5127
|
case "AIGroupingCards":
|
|
@@ -5140,7 +5140,7 @@ var zr = class {
|
|
|
5140
5140
|
updateTopBarForLoading(a) {
|
|
5141
5141
|
const e = this.deps.i18n(), t = {
|
|
5142
5142
|
productDetails: e.panelTitleProductDetails,
|
|
5143
|
-
productList:
|
|
5143
|
+
productList: Ht(this.lastActionType) ? e.panelTitleSearchResults : e.panelTitleSimilarProducts,
|
|
5144
5144
|
comparisonTable: e.panelTitleComparisonResults,
|
|
5145
5145
|
groupList: e.panelTitleCategories
|
|
5146
5146
|
}[a] ?? "";
|
|
@@ -5196,7 +5196,7 @@ var zr = class {
|
|
|
5196
5196
|
this.snapshots.clear(), this._snapshotRebuilders.clear(), this.snapshotTypes.clear(), this.activePanelMessageId = null, this.currentType = null, this.threads = [];
|
|
5197
5197
|
}
|
|
5198
5198
|
};
|
|
5199
|
-
function
|
|
5199
|
+
function Ht(a) {
|
|
5200
5200
|
return a === "user_message" || a === "inputText";
|
|
5201
5201
|
}
|
|
5202
5202
|
function Dr(a) {
|
|
@@ -5207,7 +5207,7 @@ function ke(a, e) {
|
|
|
5207
5207
|
const t = a.replace(/\s+/g, " ").trim();
|
|
5208
5208
|
return t.length <= e ? t : `${t.slice(0, Math.max(0, e - 1)).trimEnd()}…`;
|
|
5209
5209
|
}
|
|
5210
|
-
function
|
|
5210
|
+
function xe(a) {
|
|
5211
5211
|
const e = a.trim();
|
|
5212
5212
|
if (e.length === 0) return "";
|
|
5213
5213
|
if (typeof document < "u") {
|
|
@@ -5235,7 +5235,7 @@ function Fe(a, e) {
|
|
|
5235
5235
|
}
|
|
5236
5236
|
function da(a) {
|
|
5237
5237
|
if (a.silent) return !1;
|
|
5238
|
-
const e = typeof a.content == "string" ?
|
|
5238
|
+
const e = typeof a.content == "string" ? xe(a.content) : "", t = "attachment" in a && a.attachment !== void 0;
|
|
5239
5239
|
return e.length > 0 || a.uiSpec !== void 0 || t;
|
|
5240
5240
|
}
|
|
5241
5241
|
function Gr(a) {
|
|
@@ -5246,21 +5246,21 @@ function Gr(a) {
|
|
|
5246
5246
|
timestamp: e.timestamp,
|
|
5247
5247
|
status: e.status === "error" ? "error" : "done"
|
|
5248
5248
|
};
|
|
5249
|
-
return e.threadId !== void 0 && (t.threadId = e.threadId), e.content !== void 0 && (t.content = e.content), e.attachment !== void 0 &&
|
|
5249
|
+
return e.threadId !== void 0 && (t.threadId = e.threadId), e.content !== void 0 && (t.content = e.content), e.attachment !== void 0 && xe(t.content ?? "").length === 0 && (t.content = qr), e.uiSpec !== void 0 && (t.uiSpec = e.uiSpec), e.frontendOnly && (t.frontendOnly = !0), e.silent && (t.silent = !0), e.renderHint !== void 0 && (t.renderHint = e.renderHint), e.photoAnalysis !== void 0 && (t.photoAnalysis = e.photoAnalysis), t;
|
|
5250
5250
|
});
|
|
5251
5251
|
}
|
|
5252
5252
|
function $r(a) {
|
|
5253
|
-
const e = a.find((n) => n.role === "user" && !n.silent && typeof n.content == "string" &&
|
|
5254
|
-
if (e?.content) return ke(
|
|
5253
|
+
const e = a.find((n) => n.role === "user" && !n.silent && typeof n.content == "string" && xe(n.content).length > 0);
|
|
5254
|
+
if (e?.content) return ke(xe(e.content), 72);
|
|
5255
5255
|
const t = a.find((n) => da(n));
|
|
5256
|
-
return t?.content ? ke(
|
|
5256
|
+
return t?.content ? ke(xe(t.content), 72) : "New chat";
|
|
5257
5257
|
}
|
|
5258
5258
|
function Wr(a) {
|
|
5259
5259
|
for (let e = a.length - 1; e >= 0; e--) {
|
|
5260
5260
|
const t = a[e];
|
|
5261
5261
|
if (!(!t || t.silent)) {
|
|
5262
5262
|
if (typeof t.content == "string" && t.content.trim().length > 0) {
|
|
5263
|
-
const n =
|
|
5263
|
+
const n = xe(t.content);
|
|
5264
5264
|
if (n.length > 0) return ke(n, 140);
|
|
5265
5265
|
}
|
|
5266
5266
|
if (t.uiSpec) {
|
|
@@ -5281,15 +5281,15 @@ function Kr(a) {
|
|
|
5281
5281
|
function Yr(a) {
|
|
5282
5282
|
return {
|
|
5283
5283
|
...a,
|
|
5284
|
-
title: ke(
|
|
5285
|
-
preview: ke(
|
|
5284
|
+
title: ke(xe(a.title), 72) || "New chat",
|
|
5285
|
+
preview: ke(xe(a.preview), 140)
|
|
5286
5286
|
};
|
|
5287
5287
|
}
|
|
5288
5288
|
function Zr(a) {
|
|
5289
5289
|
return {
|
|
5290
5290
|
...a,
|
|
5291
|
-
title: ke(
|
|
5292
|
-
preview: ke(
|
|
5291
|
+
title: ke(xe(a.title), 72) || "New chat",
|
|
5292
|
+
preview: ke(xe(a.preview), 140)
|
|
5293
5293
|
};
|
|
5294
5294
|
}
|
|
5295
5295
|
var Xr = class {
|
|
@@ -5313,7 +5313,7 @@ var Xr = class {
|
|
|
5313
5313
|
saveSession(a) {
|
|
5314
5314
|
if (!this._storage) return null;
|
|
5315
5315
|
const e = Gr(a.messages);
|
|
5316
|
-
if (!e.some((d) => d.role === "user" && !d.silent && typeof d.content == "string" &&
|
|
5316
|
+
if (!e.some((d) => d.role === "user" && !d.silent && typeof d.content == "string" && xe(d.content).length > 0)) return null;
|
|
5317
5317
|
const t = (/* @__PURE__ */ new Date()).toISOString(), n = $r(e), i = Wr(e), r = {};
|
|
5318
5318
|
for (const [d, g] of a.panelSnapshots)
|
|
5319
5319
|
g.querySelector(".gengage-chat-panel-skeleton") || (r[d] = g.innerHTML);
|
|
@@ -5455,7 +5455,7 @@ var Xr = class {
|
|
|
5455
5455
|
await e();
|
|
5456
5456
|
} catch {
|
|
5457
5457
|
}
|
|
5458
|
-
t?.send("openURLInNewTab", { url: a }),
|
|
5458
|
+
t?.send("openURLInNewTab", { url: a }), fe(a) && n(a);
|
|
5459
5459
|
}
|
|
5460
5460
|
async loadPayload(a, e) {
|
|
5461
5461
|
if (!this._db) return null;
|
|
@@ -5763,7 +5763,7 @@ var uo = class Te extends La {
|
|
|
5763
5763
|
e.headerCartUrl ? this._saveSessionAndOpenURL(e.headerCartUrl) : e.onCartClick?.();
|
|
5764
5764
|
} } : {},
|
|
5765
5765
|
onFavoritesClick: () => {
|
|
5766
|
-
if (
|
|
5766
|
+
if (Ha(), typeof e.onFavoritesClick == "function") {
|
|
5767
5767
|
e.onFavoritesClick();
|
|
5768
5768
|
return;
|
|
5769
5769
|
}
|
|
@@ -5801,7 +5801,7 @@ var uo = class Te extends La {
|
|
|
5801
5801
|
shouldBlockSoftAutoScroll: () => this._presentation.shouldBlockStreamAutoScroll(),
|
|
5802
5802
|
onReleasePresentationFocus: () => this._releasePresentationFocus()
|
|
5803
5803
|
}
|
|
5804
|
-
}), this._applyUiHints(), this._extendedModeManager = new
|
|
5804
|
+
}), this._applyUiHints(), this._extendedModeManager = new Hr({
|
|
5805
5805
|
onChange: (f) => this._panel?.notifyExtension(f),
|
|
5806
5806
|
productDetailsInPanel: (e.isDemoWebsite ?? !1) && (e.productDetailsExtended ?? !1)
|
|
5807
5807
|
}), this._panel = new Fr({
|
|
@@ -5959,7 +5959,7 @@ var uo = class Te extends La {
|
|
|
5959
5959
|
this._messages.length = 0, this._messages.push(...e);
|
|
5960
5960
|
}
|
|
5961
5961
|
_clearConversationState(e) {
|
|
5962
|
-
this._activeRequestThreadId = null, this._abortAllActiveRequests(), this._activeTypewriter?.cancel(), this._activeTypewriter = null, this._activeTtsHandle?.stop(), this._activeTtsHandle = null, this._messages.length = 0, this._drawer?.clearMessages(), this._drawer?.clearPanel(), this._currentPanelSource = null, this._localPanelHistory = [], this._panel && (this._panel.clearSnapshots(), this._panel.threads = [], this._panel.activePanelMessageId = null, this._panel.currentType = null), this._panelAiSpecByThread.clear(), this._comparisonSelectMode = !1, this._comparisonSelectedSkus = [], this._comparisonSelectionWarning = null, this._viewedProductSkus.clear(), this._threadsWithFirstBot.clear(), this._currentThreadId = null, this._lastThreadId = null, this._lastBackendContext = null, this._chatCreatedAt = (/* @__PURE__ */ new Date()).toISOString(), e && (this._pdpLaunched = !1, this._plpLaunched = !1, this._homepageLaunched = !1, this._entryContextPrimed = !1), this._contextPrimingInFlight = !1, this._queuedUserMessages = [], this._productContextUnavailableSku = null, this._presentation.reset(), this._presentation.setShown(this._drawerVisible), this._drawer?.setPresentationFocus(null), this._drawer?.setFormerMessagesButtonVisible(!1), this._drawer?.setPills([]),
|
|
5962
|
+
this._activeRequestThreadId = null, this._abortAllActiveRequests(), this._activeTypewriter?.cancel(), this._activeTypewriter = null, this._activeTtsHandle?.stop(), this._activeTtsHandle = null, this._messages.length = 0, this._drawer?.clearMessages(), this._drawer?.clearPanel(), this._currentPanelSource = null, this._localPanelHistory = [], this._panel && (this._panel.clearSnapshots(), this._panel.threads = [], this._panel.activePanelMessageId = null, this._panel.currentType = null), this._panelAiSpecByThread.clear(), this._comparisonSelectMode = !1, this._comparisonSelectedSkus = [], this._comparisonSelectionWarning = null, this._viewedProductSkus.clear(), this._threadsWithFirstBot.clear(), this._currentThreadId = null, this._lastThreadId = null, this._lastBackendContext = null, this._chatCreatedAt = (/* @__PURE__ */ new Date()).toISOString(), e && (this._pdpLaunched = !1, this._plpLaunched = !1, this._homepageLaunched = !1, this._entryContextPrimed = !1), this._contextPrimingInFlight = !1, this._queuedUserMessages = [], this._productContextUnavailableSku = null, this._presentation.reset(), this._presentation.setShown(this._drawerVisible), this._drawer?.setPresentationFocus(null), this._drawer?.setFormerMessagesButtonVisible(!1), this._drawer?.setPills([]), Rt(), this._modeController.reset() && (this._drawer?.setInputPlaceholder(this._i18n.inputPlaceholder), this._drawer?.setAttachmentControlsVisible(!0), this._drawer?.setBeautyPhotoStepCard({ visible: !1 }));
|
|
5963
5963
|
}
|
|
5964
5964
|
_resetForNewPage() {
|
|
5965
5965
|
this._activeHistorySessionId = null, this._bridgeContext = null, this._clearConversationState(!0);
|
|
@@ -6375,7 +6375,7 @@ var uo = class Te extends La {
|
|
|
6375
6375
|
});
|
|
6376
6376
|
return;
|
|
6377
6377
|
}
|
|
6378
|
-
if (this._clearChoicePrompter(), t?.preservePanel ||
|
|
6378
|
+
if (this._clearChoicePrompter(), t?.preservePanel || Rt(), !t?.preservePanel && this._comparisonSelectMode && e.type !== "getComparisonTable" && (this._comparisonSelectMode = !1, this._comparisonSelectedSkus = []), t?.preservePanel || (this._localPanelHistory = []), this._currentThreadId && this._lastThreadId && this._lastThreadId > this._currentThreadId) {
|
|
6379
6379
|
const v = this._currentThreadId, N = this._messages.filter((x) => x.threadId !== void 0 && x.threadId > v);
|
|
6380
6380
|
this._messages = this._messages.filter((x) => !x.threadId || x.threadId <= v);
|
|
6381
6381
|
for (const x of N)
|
|
@@ -6460,8 +6460,8 @@ var uo = class Te extends La {
|
|
|
6460
6460
|
};
|
|
6461
6461
|
this.config.session?.userId !== void 0 && (k.user_id = this.config.session.userId), this.config.session?.viewId !== void 0 && (k.view_id = this.config.session.viewId), T.payload !== void 0 && (k.payload = T.payload), !c && this.config.pageContext?.sku !== void 0 && (k.sku = this.config.pageContext.sku), !c && this.config.pageContext?.pageType !== void 0 && (k.page_type = this.config.pageContext.pageType);
|
|
6462
6462
|
const I = crypto.randomUUID(), z = Date.now();
|
|
6463
|
-
let _ = 0, E = !1,
|
|
6464
|
-
const P =
|
|
6463
|
+
let _ = 0, E = !1, R = !1, W = !1, Z = !1, L = !1;
|
|
6464
|
+
const P = Rn();
|
|
6465
6465
|
let b = null, C = null;
|
|
6466
6466
|
const F = () => {
|
|
6467
6467
|
if (this._drawer && !Z) {
|
|
@@ -6487,10 +6487,10 @@ var uo = class Te extends La {
|
|
|
6487
6487
|
if (!this._drawer || !this._panel) return;
|
|
6488
6488
|
const B = v.elements[v.root];
|
|
6489
6489
|
if (x === "ProductGrid" && B) {
|
|
6490
|
-
const
|
|
6491
|
-
if (
|
|
6490
|
+
const H = dt(B);
|
|
6491
|
+
if (H.isConsulting) {
|
|
6492
6492
|
const A = this._drawer.getPanelContentElement();
|
|
6493
|
-
if (A && pr(A,
|
|
6493
|
+
if (A && pr(A, H, N)) {
|
|
6494
6494
|
this._comparisonSelectMode = !1, this._comparisonSelectedSkus = [], this._comparisonSelectionWarning = null, this._drawer.setComparisonDockContent(null), this._currentPanelSource = {
|
|
6495
6495
|
kind: "spec",
|
|
6496
6496
|
spec: v
|
|
@@ -6506,8 +6506,8 @@ var uo = class Te extends La {
|
|
|
6506
6506
|
}, X = (v, N, x, B) => {
|
|
6507
6507
|
if (!this._panel) return;
|
|
6508
6508
|
v === "ProductDetailsPanel" && e.type === "launchSingleProduct" && this._clearUnavailableProductContext(), p.threadId && !this._panel.threads.includes(p.threadId) && this._panel.threads.push(p.threadId), this._isMobileViewport && v === "ProductGrid" && this._ensureMobilePanelOverlayVisible();
|
|
6509
|
-
const
|
|
6510
|
-
this._panel.updateTopBar(
|
|
6509
|
+
const H = this._panel.currentType ?? v, A = N?.props?.panelTitle;
|
|
6510
|
+
this._panel.updateTopBar(H, A), this._panel.updateExtendedMode(v), this._isMobileViewport && o && this._drawer?.hideMobilePanel(), D(v, x, B);
|
|
6511
6511
|
};
|
|
6512
6512
|
this.track(_a(this.analyticsContext(), {
|
|
6513
6513
|
endpoint: "process_action",
|
|
@@ -6526,8 +6526,8 @@ var uo = class Te extends La {
|
|
|
6526
6526
|
widget: "chat"
|
|
6527
6527
|
})), !this._drawer)) return;
|
|
6528
6528
|
let B = y;
|
|
6529
|
-
const
|
|
6530
|
-
if (N &&
|
|
6529
|
+
const H = x?.kvkk === !0 || o && ut(B);
|
|
6530
|
+
if (N && H) {
|
|
6531
6531
|
const Y = this.config.accountId;
|
|
6532
6532
|
if (!Ot(Y)) {
|
|
6533
6533
|
const V = co(B);
|
|
@@ -6570,8 +6570,8 @@ var uo = class Te extends La {
|
|
|
6570
6570
|
onUISpec: (v, N, x, B) => {
|
|
6571
6571
|
if (!i && n !== this._activeRequestThreadId || N !== "chat") return;
|
|
6572
6572
|
B && (this._clearAssistantPanelLikeStreamClearPanel(), E = !1, C = null);
|
|
6573
|
-
const
|
|
6574
|
-
if (
|
|
6573
|
+
const H = v.elements[v.root], A = H?.type ?? "unknown";
|
|
6574
|
+
if (Hn(A, H?.props ?? {}, P, {
|
|
6575
6575
|
drawer: this._drawer,
|
|
6576
6576
|
ensureRendered: () => this._ensureAssistantMessageRendered(p),
|
|
6577
6577
|
cancelTypewriter: () => {
|
|
@@ -6583,7 +6583,7 @@ var uo = class Te extends La {
|
|
|
6583
6583
|
A === "PhotoAnalysisCard" && p.threadId && this._focusPresentationThread(p.threadId, "auto");
|
|
6584
6584
|
return;
|
|
6585
6585
|
}
|
|
6586
|
-
const Y = it(
|
|
6586
|
+
const Y = it(H), V = this.config.productDetailsExtended !== !0 && (A === "ProductDetailsPanel" || Y);
|
|
6587
6587
|
V && !B && (this._clearAssistantPanelLikeStreamClearPanel(), E = !1);
|
|
6588
6588
|
const ee = A === "ProductDetailsPanel" && x !== "panel" ? "panel" : x;
|
|
6589
6589
|
this.track(wa(this.analyticsContext(), {
|
|
@@ -6594,16 +6594,16 @@ var uo = class Te extends La {
|
|
|
6594
6594
|
}));
|
|
6595
6595
|
const ae = this._buildRenderContext();
|
|
6596
6596
|
if (ae.isStreaming = !0, A === "ComparisonTable") {
|
|
6597
|
-
const $ =
|
|
6597
|
+
const $ = H?.props?.products;
|
|
6598
6598
|
qa(Array.isArray($) ? $.length : 0);
|
|
6599
6599
|
}
|
|
6600
6600
|
if (A === "ProductGrid") {
|
|
6601
|
-
const $ =
|
|
6601
|
+
const $ = H?.children?.length ?? 0;
|
|
6602
6602
|
za(void 0, $);
|
|
6603
6603
|
}
|
|
6604
6604
|
const se = ee === "panel" && this._panel ? this._panel.toPanelSpec(v) : v;
|
|
6605
|
-
if (ee === "panel" && this._panel && !V && A === "ProductGrid" &&
|
|
6606
|
-
const $ = dt(
|
|
6605
|
+
if (ee === "panel" && this._panel && !V && A === "ProductGrid" && H) {
|
|
6606
|
+
const $ = dt(H);
|
|
6607
6607
|
if ($.isConsulting && !dr($)) {
|
|
6608
6608
|
C = v;
|
|
6609
6609
|
return;
|
|
@@ -6611,11 +6611,11 @@ var uo = class Te extends La {
|
|
|
6611
6611
|
$.isConsulting && (C = null);
|
|
6612
6612
|
}
|
|
6613
6613
|
if (ee === "panel" && this._panel && !V) {
|
|
6614
|
-
const $ = !
|
|
6615
|
-
|
|
6616
|
-
const O =
|
|
6614
|
+
const $ = !R;
|
|
6615
|
+
R = !0;
|
|
6616
|
+
const O = H?.props?.replacePanel === !0, Q = H?.props?.rankingState, U = O || Q === "pending" || Q === "final" ? "replace" : Dr({
|
|
6617
6617
|
componentType: A,
|
|
6618
|
-
similarsAppend:
|
|
6618
|
+
similarsAppend: H?.props?.similarsAppend === !0,
|
|
6619
6619
|
currentPanelType: this._panel.currentType,
|
|
6620
6620
|
hasPanelContent: this._drawer?.hasPanelContent() ?? !1,
|
|
6621
6621
|
isPanelLoading: this._drawer?.isPanelLoading() ?? !1,
|
|
@@ -6624,10 +6624,10 @@ var uo = class Te extends La {
|
|
|
6624
6624
|
ae.panelProductListHeading = void 0, A === "ProductGrid" && (U === "appendSimilars" ? ae.panelProductListHeading = this._i18n.similarProductsLabel ?? "Similar Products" : this._applyPanelListHeadingToContext(ae, {
|
|
6625
6625
|
kind: "spec",
|
|
6626
6626
|
spec: se
|
|
6627
|
-
})), U === "appendSimilars" ? this._appendSimilarsToPanel(se, ae) : U === "append" ? (this._drawer?.appendPanelContent(this._renderUISpec(se, ae)), this._comparisonSelectMode && this._refreshComparisonUI()) : q(se, ae, A), X(A,
|
|
6627
|
+
})), U === "appendSimilars" ? this._appendSimilarsToPanel(se, ae) : U === "append" ? (this._drawer?.appendPanelContent(this._renderUISpec(se, ae)), this._comparisonSelectMode && this._refreshComparisonUI()) : q(se, ae, A), X(A, H, U, !0);
|
|
6628
6628
|
}
|
|
6629
6629
|
if (A === "ProductDetailsPanel" && ee === "panel" && (!p.silent || o)) {
|
|
6630
|
-
const $ =
|
|
6630
|
+
const $ = H?.props?.product;
|
|
6631
6631
|
if ($) {
|
|
6632
6632
|
o && (s = $);
|
|
6633
6633
|
const O = {
|
|
@@ -6641,11 +6641,11 @@ var uo = class Te extends La {
|
|
|
6641
6641
|
const U = this._renderUISpec(O, ae);
|
|
6642
6642
|
p.threadId && (U.dataset.threadId = p.threadId);
|
|
6643
6643
|
const re = this._shadow?.querySelector(`[data-message-id="${p.id}"]`);
|
|
6644
|
-
re && re.parentNode === Q ? re.after(U) : Q.appendChild(U), this._scrollInlineIntoView(U, p.threadId), this._drawer?.refreshPresentationCollapsed(),
|
|
6644
|
+
re && re.parentNode === Q ? re.after(U) : Q.appendChild(U), this._scrollInlineIntoView(U, p.threadId), this._drawer?.refreshPresentationCollapsed(), R = !0;
|
|
6645
6645
|
}
|
|
6646
6646
|
}
|
|
6647
6647
|
}
|
|
6648
|
-
const ce = A === "AITopPicks" || A === "AIGroupingCards", w = A === "ActionButtons" ?
|
|
6648
|
+
const ce = A === "AITopPicks" || A === "AIGroupingCards", w = A === "ActionButtons" ? H?.props?.buttons : void 0, K = A === "ActionButtons" && this._modeController.mode !== "shopping" && Array.isArray(w) && w.length > 0 && w.every(($) => $.action?.type === "inputText");
|
|
6649
6649
|
let te = !1, ne = !1;
|
|
6650
6650
|
if (V && Y && (ae.panelProductListHeading = this._i18n.similarProductsLabel ?? "Similar Products"), ce && (!p.silent || r))
|
|
6651
6651
|
if (p.threadId && this._rememberPanelAiSpec(p.threadId, v), W) {
|
|
@@ -6658,21 +6658,21 @@ var uo = class Te extends La {
|
|
|
6658
6658
|
const $ = this._shadow?.querySelector(".gengage-chat-messages");
|
|
6659
6659
|
if ($) {
|
|
6660
6660
|
const O = this._renderUISpec(v, ae);
|
|
6661
|
-
p.threadId && (O.dataset.threadId = p.threadId), $.appendChild(O), this._scrollInlineIntoView(O, p.threadId), this._drawer?.refreshPresentationCollapsed(), V && A === "ProductGrid" && (
|
|
6661
|
+
p.threadId && (O.dataset.threadId = p.threadId), $.appendChild(O), this._scrollInlineIntoView(O, p.threadId), this._drawer?.refreshPresentationCollapsed(), V && A === "ProductGrid" && (R = !0);
|
|
6662
6662
|
}
|
|
6663
6663
|
}
|
|
6664
6664
|
if ((A === "ProductGrid" || A === "ProductCard") && p.threadId) {
|
|
6665
|
-
const $ =
|
|
6665
|
+
const $ = H?.children ?? [], O = A === "ProductGrid" ? $.map((Q) => v.elements[Q]?.props?.product).filter(Boolean) : [H?.props?.product].filter(Boolean);
|
|
6666
6666
|
for (const Q of O) {
|
|
6667
6667
|
const U = Q.sku;
|
|
6668
6668
|
U && this._viewedProductSkus.add(U);
|
|
6669
6669
|
}
|
|
6670
6670
|
}
|
|
6671
6671
|
if (A === "ProductGrid" || A === "ProductDetailsPanel") {
|
|
6672
|
-
const $ = (A === "ProductGrid" ? (
|
|
6672
|
+
const $ = (A === "ProductGrid" ? (H?.children ?? []).map((O) => v.elements[O]?.props?.product).filter(Boolean) : [H?.props?.product ?? H?.props].filter(Boolean)).map((O) => O.imageUrl).filter((O) => typeof O == "string").slice(0, 5);
|
|
6673
6673
|
$.length > 0 && this._bridge?.send("previewImages", { images: $ });
|
|
6674
6674
|
}
|
|
6675
|
-
const de =
|
|
6675
|
+
const de = H?.children?.length ?? 0;
|
|
6676
6676
|
if (A === "ProductGrid" && ee === "panel" && !V && de > 1 && !this._isMobileViewport && !this._modeController.isChoicePrompterHidden && !this._comparisonSelectMode && !Ir(this._currentThreadId ?? "") && (this._clearChoicePrompter(), this._choicePrompterEl = Ar({
|
|
6677
6677
|
heading: this._i18n.choicePrompterHeading,
|
|
6678
6678
|
suggestion: this._i18n.choicePrompterSuggestion,
|
|
@@ -6686,7 +6686,7 @@ var uo = class Te extends La {
|
|
|
6686
6686
|
this._choicePrompterEl = null;
|
|
6687
6687
|
}
|
|
6688
6688
|
}), this._mountChoicePrompter()), A === "ActionButtons") {
|
|
6689
|
-
const $ =
|
|
6689
|
+
const $ = H?.props?.buttons;
|
|
6690
6690
|
if ($ && $.length > 0 && !K) {
|
|
6691
6691
|
const O = [], Q = [];
|
|
6692
6692
|
for (const U of $) if (Lr(U)) {
|
|
@@ -6717,7 +6717,7 @@ var uo = class Te extends La {
|
|
|
6717
6717
|
this.config.actionHandling?.unknownActionPolicy !== void 0 && (N.unknownActionPolicy = this.config.actionHandling.unknownActionPolicy), this.config.actionHandling?.allowScriptCall !== void 0 && (N.allowScriptCall = this.config.actionHandling.allowScriptCall), Za(v, {
|
|
6718
6718
|
openChat: () => this.open(),
|
|
6719
6719
|
navigate: (x) => {
|
|
6720
|
-
|
|
6720
|
+
fe(x.url) && (this._bridge?.send("navigate", x), x.newTab ? window.open(x.url, "_blank", "noopener,noreferrer") : window.location.href = x.url);
|
|
6721
6721
|
},
|
|
6722
6722
|
saveSession: (x) => this.saveSession(x.sessionId, x.sku),
|
|
6723
6723
|
addToCart: (x) => {
|
|
@@ -6733,12 +6733,12 @@ var uo = class Te extends La {
|
|
|
6733
6733
|
if (!(!i && n !== this._activeRequestThreadId) && v.type === "metadata" && v.meta) {
|
|
6734
6734
|
if (v.meta.panel !== void 0 || v.meta.messages !== void 0 || v.meta.message_id !== void 0) {
|
|
6735
6735
|
this._lastBackendContext = v.meta;
|
|
6736
|
-
const x =
|
|
6736
|
+
const x = ue(v.meta.panel);
|
|
6737
6737
|
x && (this._modeController.updateFromContext(x), this._applyUiHints());
|
|
6738
6738
|
}
|
|
6739
6739
|
if (v.meta.panelLoading) {
|
|
6740
6740
|
const x = typeof v.meta.panelPendingType == "string" ? v.meta.panelPendingType : void 0;
|
|
6741
|
-
this.config.productDetailsExtended !== !0 && (x === "productDetails" || x === "productDetailsSimilars") || (E = !0,
|
|
6741
|
+
this.config.productDetailsExtended !== !0 && (x === "productDetails" || x === "productDetailsSimilars") || (E = !0, R = !1, h(), this._panel && (this._panel.currentType = null), this._drawer?.showPanelLoading(x), this._isMobileViewport && x === "productList" && this._ensureMobilePanelOverlayVisible(), x && this._panel?.updateTopBarForLoading(x));
|
|
6742
6742
|
}
|
|
6743
6743
|
if (v.meta.voice) {
|
|
6744
6744
|
const x = new CustomEvent("gengage:chat:voice", {
|
|
@@ -6747,18 +6747,18 @@ var uo = class Te extends La {
|
|
|
6747
6747
|
cancelable: !0
|
|
6748
6748
|
}), B = window.dispatchEvent(x);
|
|
6749
6749
|
if (Ba(), B) {
|
|
6750
|
-
const
|
|
6751
|
-
|
|
6750
|
+
const H = v.meta.voice;
|
|
6751
|
+
H.audio_base64 && (this._activeTtsHandle?.stop(), this._activeTtsHandle = xr(H.audio_base64, H.content_type ?? "audio/ogg"));
|
|
6752
6752
|
}
|
|
6753
6753
|
}
|
|
6754
6754
|
if ((v.meta.redirectTarget || v.meta.redirect) && (he("gengage:chat:redirect", {
|
|
6755
6755
|
target: v.meta.redirectTarget ?? null,
|
|
6756
6756
|
payload: v.meta.redirect ?? null
|
|
6757
|
-
}), Me("redirect", "redirect dispatched", { target: v.meta.redirectTarget ?? null }), this._handleRedirectMetadata(v.meta.redirect)), v.meta.analyzeAnimation && this.config.productDetailsExtended === !0 && (E = !0,
|
|
6758
|
-
const x = Array.isArray(v.meta.thinkingMessages) ? v.meta.thinkingMessages.filter((
|
|
6757
|
+
}), Me("redirect", "redirect dispatched", { target: v.meta.redirectTarget ?? null }), this._handleRedirectMetadata(v.meta.redirect)), v.meta.analyzeAnimation && this.config.productDetailsExtended === !0 && (E = !0, R = !1, h(), this._panel && (this._panel.currentType = null), this._drawer?.showPanelLoading(), this._panel?.updateTopBarForLoading("productDetails")), v.meta.loading) {
|
|
6758
|
+
const x = Array.isArray(v.meta.thinkingMessages) ? v.meta.thinkingMessages.filter((H) => typeof H == "string") : [], B = typeof v.meta.loadingText == "string" ? v.meta.loadingText : void 0;
|
|
6759
6759
|
if (x.length > 0) {
|
|
6760
|
-
const
|
|
6761
|
-
this._drawer?.setThinkingSteps(
|
|
6760
|
+
const H = B && this._modeController.shouldCondenseThinking() ? [...x.slice(0, 2), B] : x;
|
|
6761
|
+
this._drawer?.setThinkingSteps(H);
|
|
6762
6762
|
}
|
|
6763
6763
|
typeof B == "string" && B.length > 0 && (this._drawer?.addThinkingStep(B), this._bridge?.send("loadingMessage", { text: B }));
|
|
6764
6764
|
}
|
|
@@ -6786,16 +6786,16 @@ var uo = class Te extends La {
|
|
|
6786
6786
|
sendSkipMessage: () => this._sendMessage(this._i18n.beautyPhotoStepSkipMessage),
|
|
6787
6787
|
streamDone: !0
|
|
6788
6788
|
});
|
|
6789
|
-
const N =
|
|
6790
|
-
E && !
|
|
6791
|
-
const x = p.content != null && p.content.length > 0 || y.length > 0 || N, B = p.silent || x,
|
|
6789
|
+
const N = R;
|
|
6790
|
+
E && !R && u(), E = !1, R = !1;
|
|
6791
|
+
const x = p.content != null && p.content.length > 0 || y.length > 0 || N, B = p.silent || x, H = typeof navigator < "u" && navigator.onLine === !1 && Vt(v), A = () => {
|
|
6792
6792
|
this._shadow?.querySelector(`[data-message-id="${le(p.id)}"]`)?.remove();
|
|
6793
6793
|
const ee = this._messages.indexOf(p);
|
|
6794
6794
|
ee >= 0 && this._messages.splice(ee, 1);
|
|
6795
6795
|
};
|
|
6796
6796
|
let Y = !1;
|
|
6797
6797
|
const V = () => {
|
|
6798
|
-
if (
|
|
6798
|
+
if (H) return;
|
|
6799
6799
|
this.emit("error", v);
|
|
6800
6800
|
const ee = v.message;
|
|
6801
6801
|
ee === this._lastErrorMessage ? this._consecutiveErrorCount++ : (this._consecutiveErrorCount = 1, this._lastErrorMessage = ee);
|
|
@@ -6828,8 +6828,8 @@ var uo = class Te extends La {
|
|
|
6828
6828
|
} else p.status = "done";
|
|
6829
6829
|
else if (B)
|
|
6830
6830
|
this._drawer?.setPills([]), p.silent || V();
|
|
6831
|
-
else if (V(),
|
|
6832
|
-
r && (this._contextPrimingInFlight = !1, this._flushQueuedUserMessages()), !Y && p.status === "streaming" && (p.status = "error"),
|
|
6831
|
+
else if (V(), H) return;
|
|
6832
|
+
r && (this._contextPrimingInFlight = !1, this._flushQueuedUserMessages()), !Y && p.status === "streaming" && (p.status = "error"), H || this.track(Ta(this.analyticsContext(), {
|
|
6833
6833
|
request_id: I,
|
|
6834
6834
|
error_code: "STREAM_ERROR",
|
|
6835
6835
|
error_message: v.message,
|
|
@@ -6841,13 +6841,13 @@ var uo = class Te extends La {
|
|
|
6841
6841
|
if (L = !0, C && this._panel && this._drawer) {
|
|
6842
6842
|
const B = this._buildRenderContext();
|
|
6843
6843
|
B.isStreaming = !1;
|
|
6844
|
-
const
|
|
6844
|
+
const H = C.elements[C.root], A = this._panel.toPanelSpec(C);
|
|
6845
6845
|
this._applyPanelListHeadingToContext(B, {
|
|
6846
6846
|
kind: "spec",
|
|
6847
6847
|
spec: A
|
|
6848
6848
|
});
|
|
6849
|
-
const Y =
|
|
6850
|
-
q(A, B, Y), X(Y,
|
|
6849
|
+
const Y = H?.type ?? "ProductGrid";
|
|
6850
|
+
q(A, B, Y), X(Y, H, "replace", !1), R = !0;
|
|
6851
6851
|
}
|
|
6852
6852
|
C = null, b && j(!1), F(), this._activeRequestThreadId = null, this._consecutiveErrorCount = 0, this._lastErrorMessage = "", this._bridge?.send("isResponding", !1), this._bridge?.send("loadingMessage", { text: null }), this._drawer?.removeTypingIndicator(), Dn(P, {
|
|
6853
6853
|
drawer: this._drawer,
|
|
@@ -6858,12 +6858,12 @@ var uo = class Te extends La {
|
|
|
6858
6858
|
sendSkipMessage: () => this._sendMessage(this._i18n.beautyPhotoStepSkipMessage),
|
|
6859
6859
|
streamDone: !0
|
|
6860
6860
|
});
|
|
6861
|
-
const v =
|
|
6862
|
-
if (E && !
|
|
6861
|
+
const v = R;
|
|
6862
|
+
if (E && !R && u(), E = !1, o && !y && !v) {
|
|
6863
6863
|
const B = this._i18n.productNotFoundMessage;
|
|
6864
6864
|
p.content = B, this._ensureAssistantMessageRendered(p), this._drawer?.updateBotMessage(p.id, B), this._markUnavailableProductContext();
|
|
6865
6865
|
}
|
|
6866
|
-
if (
|
|
6866
|
+
if (R = !1, r) {
|
|
6867
6867
|
this._contextPrimingInFlight = !1;
|
|
6868
6868
|
const B = this._queuedUserMessages.length > 0;
|
|
6869
6869
|
this._flushQueuedUserMessages(), !B && o && this._ensurePdpPrimeSuggestedUiIfNeeded(s);
|
|
@@ -6929,13 +6929,35 @@ var uo = class Te extends La {
|
|
|
6929
6929
|
if (!e) return null;
|
|
6930
6930
|
const t = e.elements[e.root];
|
|
6931
6931
|
if (!t || t.type !== "ProductDetailsPanel") return null;
|
|
6932
|
-
const n =
|
|
6933
|
-
return
|
|
6932
|
+
const n = ue(t.props);
|
|
6933
|
+
return ue(n?.product) ?? n ?? null;
|
|
6934
|
+
}
|
|
6935
|
+
_productGridRecordFromSpec(e, t) {
|
|
6936
|
+
if (!e) return null;
|
|
6937
|
+
const n = e.elements[e.root];
|
|
6938
|
+
if (!n || n.type !== "ProductGrid") return null;
|
|
6939
|
+
const i = Object.values(e.elements).filter((o) => o.type === "ProductCard").map((o) => ue(o.props?.product)).filter((o) => o !== null);
|
|
6940
|
+
if (i.length === 0) return null;
|
|
6941
|
+
const r = this._coerceSkuKey(t);
|
|
6942
|
+
if (r) {
|
|
6943
|
+
const o = i.find((s) => this._productRecordMatchesSku(s, r));
|
|
6944
|
+
if (o) return o;
|
|
6945
|
+
}
|
|
6946
|
+
return i.length === 1 ? i[0] : null;
|
|
6947
|
+
}
|
|
6948
|
+
_productRecordMatchesSku(e, t) {
|
|
6949
|
+
if (this._coerceSkuKey(e.sku) === t || this._coerceSkuKey(e.group_id ?? e.groupId) === t) return !0;
|
|
6950
|
+
const n = ue(e.extras);
|
|
6951
|
+
return this._coerceSkuKey(n?.group_id ?? n?.groupId) === t;
|
|
6934
6952
|
}
|
|
6935
6953
|
_getCurrentPanelProductRecord() {
|
|
6936
6954
|
const e = this._currentPanelSource;
|
|
6937
6955
|
return e ? e.kind === "spec" ? this._productDetailsRecordFromSpec(e.spec) : e.kind === "productDetailsWithSimilars" ? this._productDetailsRecordFromSpec(e.pdpSpec) : null : null;
|
|
6938
6956
|
}
|
|
6957
|
+
_getCurrentPanelProductGridRecord(e) {
|
|
6958
|
+
const t = this._currentPanelSource;
|
|
6959
|
+
return t ? t.kind === "spec" ? this._productGridRecordFromSpec(t.spec, e) : t.kind === "productDetailsWithSimilars" ? this._productGridRecordFromSpec(t.similarsSpec, e) : null : null;
|
|
6960
|
+
}
|
|
6939
6961
|
_panelSourceFromMessage(e) {
|
|
6940
6962
|
const t = e?.uiSpec;
|
|
6941
6963
|
if (!t) return null;
|
|
@@ -6952,6 +6974,13 @@ var uo = class Te extends La {
|
|
|
6952
6974
|
}
|
|
6953
6975
|
return null;
|
|
6954
6976
|
}
|
|
6977
|
+
_getLatestProductGridRecord(e) {
|
|
6978
|
+
for (let t = this._messages.length - 1; t >= 0; t -= 1) {
|
|
6979
|
+
const n = this._productGridRecordFromSpec(this._messages[t]?.uiSpec, e);
|
|
6980
|
+
if (n) return n;
|
|
6981
|
+
}
|
|
6982
|
+
return null;
|
|
6983
|
+
}
|
|
6955
6984
|
_getCurrentPanelProductSku() {
|
|
6956
6985
|
const e = this._getCurrentPanelProductRecord();
|
|
6957
6986
|
return e && this._coerceSkuKey(e.sku) || null;
|
|
@@ -7479,13 +7508,13 @@ var uo = class Te extends La {
|
|
|
7479
7508
|
return t ? (this._runChatAddToCartFlow(t), !0) : !1;
|
|
7480
7509
|
}
|
|
7481
7510
|
_resolveCurrentProductAddToCartParams() {
|
|
7482
|
-
const e =
|
|
7483
|
-
if (!
|
|
7484
|
-
const
|
|
7485
|
-
this._currentPanelSource ||
|
|
7486
|
-
for (const
|
|
7487
|
-
const
|
|
7488
|
-
if (
|
|
7511
|
+
const e = ue(this.config.pageContext?.extra), t = this._activeSkuForProductSummaryClick() ?? this._coerceSkuKey(this._bridgeContext?.sku), n = this.config.pageContext?.pageType === "pdp", i = this._getCurrentPanelProductRecord(), r = n ? this._getCurrentPanelProductGridRecord(t) : null;
|
|
7512
|
+
if (!i && !r && this._currentPanelSource) return null;
|
|
7513
|
+
const o = [i, r];
|
|
7514
|
+
this._currentPanelSource || (o.push(this._getLatestProductDetailsRecord()), n && o.push(this._getLatestProductGridRecord(t))), n && o.push(ue(this._bridgeContext?.product), ue(this._bridgeContext?.productDetails), this._bridgeContext, ue(e?.product), ue(e?.productDetails), e);
|
|
7515
|
+
for (const s of o) {
|
|
7516
|
+
const c = this._extractAddToCartParamsFromRecord(s, t);
|
|
7517
|
+
if (c) return c;
|
|
7489
7518
|
}
|
|
7490
7519
|
return null;
|
|
7491
7520
|
}
|
|
@@ -7551,7 +7580,7 @@ var uo = class Te extends La {
|
|
|
7551
7580
|
}
|
|
7552
7581
|
if (t.type === "findSimilar") {
|
|
7553
7582
|
const i = typeof t.payload == "object" && t.payload !== null && "sku" in t.payload ? String(t.payload.sku) : "";
|
|
7554
|
-
|
|
7583
|
+
Ra(i);
|
|
7555
7584
|
}
|
|
7556
7585
|
if (t.type === "getComparisonTable") {
|
|
7557
7586
|
const i = t.payload, r = i && typeof i == "object" ? i : null, o = r && typeof r.gengage_analytics_source == "string" ? r.gengage_analytics_source : "";
|