@gengage/assistant-fe 0.5.1 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{api-paths-XNsAaP_N.js → api-paths-DMmq3LCM.js} +1 -1
- package/dist/assistant-fe.css +1 -1
- package/dist/chat-runtime.js +1 -1
- package/dist/chat.iife.js +7 -7
- package/dist/chat.js +1 -1
- package/dist/{common-Cb5WKXue.js → common-B5CTtAV7.js} +1 -1
- package/dist/common.js +5 -5
- package/dist/{connection-warning-BjfQKyV7.js → connection-warning-CFgiLUDI.js} +1 -1
- package/dist/{fastIntent-DxSSvrgK.js → fastIntent-Cwg4fzKy.js} +1 -1
- package/dist/index.js +10 -10
- package/dist/native.iife.js +6 -6
- package/dist/qna-runtime.js +1 -1
- package/dist/qna.iife.js +1 -1
- package/dist/qna.js +1 -1
- package/dist/{runtime-Bso-rbzX.js → runtime-B6gNwfPX.js} +136 -119
- package/dist/{runtime-B8Y5j1Xu.js → runtime-C4ee5aef.js} +3 -3
- package/dist/{runtime-CatBpqEd.js → runtime-ChBUw8vy.js} +208 -188
- package/dist/{simbut-D2WpS0Y8.js → simbut-DHPn6j5P.js} +1 -1
- package/dist/simbut.iife.js +1 -1
- package/dist/simbut.js +1 -1
- package/dist/{simrel-CNfVfah6.js → simrel-BBSrAbwm.js} +112 -101
- package/dist/simrel-runtime.js +1 -1
- package/dist/simrel.css +2 -2
- package/dist/simrel.iife.js +5 -5
- package/dist/simrel.js +2 -2
- package/dist/{widget-base-CcNNPfdn.js → widget-base-CJIr0DLe.js} +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { c as ba, d as va, h as xa, p as ya, r as wa, s as Gt, t as _a } from "./api-paths-
|
|
2
|
-
import { A as _e, C as ka, D as Ca, E as Sa, M as oe, N as pe, O as Ea, S as mt, T as Pa, _ as La, a as
|
|
3
|
-
import { i as Ne, s as $t, t as Oa } from "./widget-base-
|
|
4
|
-
import { a as le, i as Ua, n as ja, o as
|
|
1
|
+
import { c as ba, d as va, h as xa, p as ya, r as wa, s as Gt, t as _a } from "./api-paths-DMmq3LCM.js";
|
|
2
|
+
import { A as _e, C as ka, D as Ca, E as Sa, M as oe, N as pe, O as Ea, S as mt, T as Pa, _ as La, a as xe, b as Aa, d as Ta, f as Ia, g as Ma, h as Na, j as me, l as Ba, m as za, p as Ra, u as Ha, v as Fa, w as ft, x as Da } from "./context-BBuSsXZ9.js";
|
|
3
|
+
import { i as Ne, s as $t, t as Oa } from "./widget-base-CJIr0DLe.js";
|
|
4
|
+
import { a as le, i as Ua, n as ja, o as qa, r as Va, s as Ga, t as bt } from "./fastIntent-Cwg4fzKy.js";
|
|
5
5
|
import { t as De } from "./locale-CfqNifrU.js";
|
|
6
|
-
import { a as Wt, i as Kt, n as
|
|
6
|
+
import { a as Wt, i as Kt, n as ue, r as Yt, 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;
|
|
@@ -843,7 +843,7 @@ var kn = class {
|
|
|
843
843
|
ae = X.clientY - $;
|
|
844
844
|
const W = (e.getMobileState?.() ?? "full") === "full" ? Math.max(0, ae) : ae;
|
|
845
845
|
Y.preventDefault(), this.root.style.transform = `translateY(${W}px)`;
|
|
846
|
-
},
|
|
846
|
+
}, fe = () => {
|
|
847
847
|
if (!re) return;
|
|
848
848
|
re = !1;
|
|
849
849
|
const Y = e.getMobileState?.() ?? "full";
|
|
@@ -854,8 +854,8 @@ var kn = class {
|
|
|
854
854
|
}, z = () => {
|
|
855
855
|
re && (re = !1, ae = 0, this.root.style.transition = "", this.root.style.transform = "");
|
|
856
856
|
};
|
|
857
|
-
i.addEventListener("touchstart", ie, { passive: !0 }), i.addEventListener("touchmove", he, { passive: !1 }), i.addEventListener("touchend",
|
|
858
|
-
i.removeEventListener("touchstart", ie), i.removeEventListener("touchmove", he), i.removeEventListener("touchend",
|
|
857
|
+
i.addEventListener("touchstart", ie, { passive: !0 }), i.addEventListener("touchmove", he, { passive: !1 }), i.addEventListener("touchend", fe, { passive: !0 }), i.addEventListener("touchcancel", z, { passive: !0 }), this._cleanups.push(() => {
|
|
858
|
+
i.removeEventListener("touchstart", ie), i.removeEventListener("touchmove", he), i.removeEventListener("touchend", fe), i.removeEventListener("touchcancel", z);
|
|
859
859
|
});
|
|
860
860
|
}
|
|
861
861
|
const f = document.createElement("div");
|
|
@@ -917,7 +917,7 @@ var kn = class {
|
|
|
917
917
|
S = !1;
|
|
918
918
|
const { scrollTop: y, scrollHeight: $, clientHeight: ae } = this.messagesEl, re = $ - y - ae;
|
|
919
919
|
this._userScrolledUp = re > 10;
|
|
920
|
-
const ie = this._presentationPinned ? re < 96 : re < 32, he = Date.now(),
|
|
920
|
+
const ie = this._presentationPinned ? re < 96 : re < 32, he = Date.now(), fe = he < this._programmaticScrollUntil, z = !ie && he < this._userInteractionUntil, Y = fe ? !1 : z;
|
|
921
921
|
ie !== this._presentationPinned && (this._presentationPinned = ie, b()?.onPinnedToBottomChange?.(ie)), Y !== this._presentationUserInteracting && (this._presentationUserInteracting = Y, b()?.onUserInteractingChange?.(Y));
|
|
922
922
|
}));
|
|
923
923
|
};
|
|
@@ -928,31 +928,31 @@ var kn = class {
|
|
|
928
928
|
L(), y.deltaY < -6 && this._presentationFocusThreadId && this._options.presentation?.onFormerMessagesHint?.();
|
|
929
929
|
};
|
|
930
930
|
this.messagesEl.addEventListener("wheel", F, { passive: !0 }), this._cleanups.push(() => this.messagesEl.removeEventListener("wheel", F));
|
|
931
|
-
const
|
|
931
|
+
const q = (y) => {
|
|
932
932
|
L(), this._touchStartY = y.touches[0]?.clientY ?? null;
|
|
933
933
|
}, D = (y) => {
|
|
934
934
|
L();
|
|
935
935
|
const $ = y.touches[0]?.clientY, ae = this._touchStartY;
|
|
936
936
|
typeof $ == "number" && typeof ae == "number" && $ - ae > 10 && this._presentationFocusThreadId && this._options.presentation?.onFormerMessagesHint?.();
|
|
937
937
|
};
|
|
938
|
-
this.messagesEl.addEventListener("touchstart",
|
|
939
|
-
this.messagesEl.removeEventListener("touchstart",
|
|
938
|
+
this.messagesEl.addEventListener("touchstart", q, { passive: !0 }), this.messagesEl.addEventListener("touchmove", D, { passive: !0 }), this._cleanups.push(() => {
|
|
939
|
+
this.messagesEl.removeEventListener("touchstart", q), this.messagesEl.removeEventListener("touchmove", D);
|
|
940
940
|
}), w.appendChild(this.messagesEl), this._panelFloatingEl = document.createElement("div"), this._panelFloatingEl.className = "gengage-chat-panel-float", this._panelFloatingEl.dataset.gengagePart = "chat-panel-floating-layer", this._panelEl.appendChild(this._panelFloatingEl), this._resetPanelAiZoneElement(), this._pillsEl = document.createElement("div"), this._pillsEl.className = "gengage-chat-pills", this._pillsEl.dataset.gengagePart = "chat-suggestion-pills", this._pillsEl.setAttribute("role", "toolbar"), this._pillsEl.setAttribute("aria-label", this.i18n.suggestionsAriaLabel), this._pillsEl.style.display = "none";
|
|
941
941
|
const K = document.createElement("div");
|
|
942
942
|
K.className = "gengage-chat-pills-scroll", K.dataset.gengagePart = "chat-suggestion-pills-scroll", this._pillsEl.appendChild(K);
|
|
943
|
-
const
|
|
944
|
-
|
|
943
|
+
const V = document.createElement("button");
|
|
944
|
+
V.className = "gengage-chat-pills-arrow gds-btn gds-btn-ghost", V.dataset.gengagePart = "chat-suggestion-pills-more", V.type = "button", V.setAttribute("aria-label", this.i18n.moreSuggestionsAriaLabel), V.textContent = "›", V.addEventListener("click", () => {
|
|
945
945
|
K.scrollBy({
|
|
946
946
|
left: 150,
|
|
947
947
|
behavior: "smooth"
|
|
948
948
|
});
|
|
949
|
-
}), this._pillsEl.appendChild(
|
|
949
|
+
}), this._pillsEl.appendChild(V);
|
|
950
950
|
let Q = !1;
|
|
951
951
|
const R = () => {
|
|
952
952
|
Q || (Q = !0, requestAnimationFrame(() => {
|
|
953
953
|
Q = !1;
|
|
954
954
|
const y = K.scrollLeft + K.clientWidth >= K.scrollWidth - 4;
|
|
955
|
-
|
|
955
|
+
V.style.display = y ? "none" : "";
|
|
956
956
|
}));
|
|
957
957
|
};
|
|
958
958
|
K.addEventListener("scroll", R, { passive: !0 }), this._cleanups.push(() => {
|
|
@@ -974,9 +974,9 @@ var kn = class {
|
|
|
974
974
|
else if ($.items?.length) for (let ie = 0; ie < $.items.length; ie++) {
|
|
975
975
|
const he = $.items[ie];
|
|
976
976
|
if (he?.kind === "file" && he.type.startsWith("image/")) {
|
|
977
|
-
const
|
|
978
|
-
if (
|
|
979
|
-
ae =
|
|
977
|
+
const fe = he.getAsFile();
|
|
978
|
+
if (fe) {
|
|
979
|
+
ae = fe;
|
|
980
980
|
break;
|
|
981
981
|
}
|
|
982
982
|
}
|
|
@@ -1026,7 +1026,7 @@ var kn = class {
|
|
|
1026
1026
|
$ && this._routeAttachmentFile($);
|
|
1027
1027
|
});
|
|
1028
1028
|
const ee = document.createElement("div");
|
|
1029
|
-
ee.className = "gengage-chat-input-pill gds-input-shell", ee.dataset.gengagePart = "chat-input-shell", ee.appendChild(v), ee.appendChild(this.inputEl), this._voiceEnabled && Ua() && (this._micBtn = document.createElement("button"), this._micBtn.className = "gengage-chat-mic-btn gds-btn gds-btn-ghost", this._micBtn.dataset.gengagePart = "chat-mic-button", this._micBtn.type = "button", this._micBtn.setAttribute("aria-label", this.i18n.voiceButton), this._micBtn.innerHTML = '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" y1="19" x2="12" y2="23"/><line x1="8" y1="23" x2="16" y2="23"/></svg>', this._micBtn.addEventListener("click", () => this._toggleVoice()), ee.appendChild(this._micBtn), this._voiceInput = new
|
|
1029
|
+
ee.className = "gengage-chat-input-pill gds-input-shell", ee.dataset.gengagePart = "chat-input-shell", ee.appendChild(v), ee.appendChild(this.inputEl), this._voiceEnabled && Ua() && (this._micBtn = document.createElement("button"), this._micBtn.className = "gengage-chat-mic-btn gds-btn gds-btn-ghost", this._micBtn.dataset.gengagePart = "chat-mic-button", this._micBtn.type = "button", this._micBtn.setAttribute("aria-label", this.i18n.voiceButton), this._micBtn.innerHTML = '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" y1="19" x2="12" y2="23"/><line x1="8" y1="23" x2="16" y2="23"/></svg>', this._micBtn.addEventListener("click", () => this._toggleVoice()), ee.appendChild(this._micBtn), this._voiceInput = new Va({
|
|
1030
1030
|
onInterim: (y) => {
|
|
1031
1031
|
this._resizeRafId !== null && (cancelAnimationFrame(this._resizeRafId), this._resizeRafId = null), this.inputEl.value = y, this.inputEl.style.height = "auto", this.inputEl.style.height = `${Math.min(this.inputEl.scrollHeight, 120)}px`;
|
|
1032
1032
|
},
|
|
@@ -1244,7 +1244,7 @@ var kn = class {
|
|
|
1244
1244
|
this._routeAttachmentFile(e), this._closeAttachMenu();
|
|
1245
1245
|
return;
|
|
1246
1246
|
}
|
|
1247
|
-
|
|
1247
|
+
xe("gengage:global:error", {
|
|
1248
1248
|
message: this.i18n.clipboardNoImageMessage,
|
|
1249
1249
|
source: "chat"
|
|
1250
1250
|
}), this._closeAttachMenu();
|
|
@@ -2110,12 +2110,12 @@ function Oe(a, e = 18) {
|
|
|
2110
2110
|
return n;
|
|
2111
2111
|
}
|
|
2112
2112
|
var Qe = "General", St = 220, jn = 6;
|
|
2113
|
-
function
|
|
2113
|
+
function qn(a) {
|
|
2114
2114
|
if (typeof a != "string") return [Qe];
|
|
2115
2115
|
const e = a.split(/[,;|/]+/).map((t) => t.trim().replace(/\s+/g, " ")).filter((t) => t.length > 0);
|
|
2116
2116
|
return e.length === 0 ? [Qe] : Array.from(new Set(e.map((t) => t.toLocaleLowerCase()))).map((t) => e.find((n) => n.toLocaleLowerCase() === t) ?? Qe);
|
|
2117
2117
|
}
|
|
2118
|
-
function
|
|
2118
|
+
function Vn(a) {
|
|
2119
2119
|
return a === "positive" || a === "negative" || a === "neutral" ? a : "neutral";
|
|
2120
2120
|
}
|
|
2121
2121
|
function Gn(a) {
|
|
@@ -2142,7 +2142,7 @@ function Yn(a, e) {
|
|
|
2142
2142
|
}
|
|
2143
2143
|
const r = n.filter((f) => f !== null && typeof f == "object"), i = /* @__PURE__ */ new Map();
|
|
2144
2144
|
for (const f of r) {
|
|
2145
|
-
const m =
|
|
2145
|
+
const m = Vn(f.review_class), g = Gn(f.review_text), C = qn(f.review_tag);
|
|
2146
2146
|
for (const A of C) {
|
|
2147
2147
|
const _ = A.toLocaleLowerCase();
|
|
2148
2148
|
let M = i.get(_);
|
|
@@ -2271,7 +2271,7 @@ function Ze(a) {
|
|
|
2271
2271
|
const i = document.createElement("div");
|
|
2272
2272
|
i.className = "gengage-chat-campaign-price-badge__logo";
|
|
2273
2273
|
const o = document.createElement("img");
|
|
2274
|
-
o.alt = "", o.loading = "lazy", o.src = a.logoUrl,
|
|
2274
|
+
o.alt = "", o.loading = "lazy", o.src = a.logoUrl, ue(o), i.appendChild(o), e.appendChild(i);
|
|
2275
2275
|
}
|
|
2276
2276
|
const t = document.createElement("div");
|
|
2277
2277
|
t.className = "gengage-chat-campaign-price-badge__body";
|
|
@@ -2319,7 +2319,7 @@ function er(a, e, t, n, r) {
|
|
|
2319
2319
|
const o = a.product, s = o.imageUrl;
|
|
2320
2320
|
if (s && _e(s)) {
|
|
2321
2321
|
const l = document.createElement("img");
|
|
2322
|
-
l.className = "gengage-chat-ai-toppick-img", l.dataset.gengagePart = "ai-top-pick-image", oe(l, "src", s), l.loading = "lazy", l.alt = e,
|
|
2322
|
+
l.className = "gengage-chat-ai-toppick-img", l.dataset.gengagePart = "ai-top-pick-image", oe(l, "src", s), l.loading = "lazy", l.alt = e, ue(l), i.appendChild(l);
|
|
2323
2323
|
}
|
|
2324
2324
|
const c = ta(a);
|
|
2325
2325
|
if (c && !r?.skipOverlayActions) {
|
|
@@ -2693,7 +2693,7 @@ function gr(a, e) {
|
|
|
2693
2693
|
const p = t[l], d = `gengage-cat-tab-${l}`, h = `gengage-cat-panel-${l}`, u = document.createElement("button");
|
|
2694
2694
|
if (u.className = "gengage-chat-categories-tab gds-tab", u.type = "button", u.dataset.gengagePart = "categories-tab", u.id = d, 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"), p.image && _e(p.image)) {
|
|
2695
2695
|
const m = document.createElement("img");
|
|
2696
|
-
m.className = "gengage-chat-categories-tab-image", m.draggable = !1, m.src = p.image, m.alt = p.groupName, m.loading = "lazy",
|
|
2696
|
+
m.className = "gengage-chat-categories-tab-image", m.draggable = !1, m.src = p.image, m.alt = p.groupName, m.loading = "lazy", ue(m), u.appendChild(m);
|
|
2697
2697
|
}
|
|
2698
2698
|
const x = document.createElement("span");
|
|
2699
2699
|
x.className = "gengage-chat-categories-tab-text", x.textContent = p.groupName, u.appendChild(x), u.addEventListener("click", () => c(l)), u.addEventListener("keydown", (m) => {
|
|
@@ -2727,7 +2727,7 @@ function dr(a, e) {
|
|
|
2727
2727
|
const t = document.createElement("div");
|
|
2728
2728
|
if (t.className = "gengage-chat-product-card gds-card gds-product-card gds-card-interactive", t.dataset.gengagePart = "categories-product-card", a.imageUrl && _e(a.imageUrl)) {
|
|
2729
2729
|
const i = document.createElement("img");
|
|
2730
|
-
i.className = "gengage-chat-product-card-img", i.draggable = !1, i.src = a.imageUrl, i.alt = a.name, i.loading = "lazy",
|
|
2730
|
+
i.className = "gengage-chat-product-card-img", i.draggable = !1, i.src = a.imageUrl, i.alt = a.name, i.loading = "lazy", ue(i), t.appendChild(i);
|
|
2731
2731
|
}
|
|
2732
2732
|
const n = document.createElement("div");
|
|
2733
2733
|
n.className = "gengage-chat-product-card-body";
|
|
@@ -2801,9 +2801,9 @@ function mr(a, e) {
|
|
|
2801
2801
|
const g = document.createElement("div");
|
|
2802
2802
|
g.className = "gengage-chat-panel-restore-card__thumb";
|
|
2803
2803
|
const C = m.imageUrl;
|
|
2804
|
-
if (C &&
|
|
2804
|
+
if (C && me(C)) {
|
|
2805
2805
|
const A = document.createElement("img");
|
|
2806
|
-
A.loading = "lazy", A.alt = m.name || r, oe(A, "src", C),
|
|
2806
|
+
A.loading = "lazy", A.alt = m.name || r, oe(A, "src", C), ue(A), g.appendChild(A);
|
|
2807
2807
|
}
|
|
2808
2808
|
f.appendChild(g);
|
|
2809
2809
|
}
|
|
@@ -2823,11 +2823,11 @@ function fr(a, e) {
|
|
|
2823
2823
|
g.target.closest("a") || e.onProductSelect?.(t);
|
|
2824
2824
|
});
|
|
2825
2825
|
const r = t.imageUrl;
|
|
2826
|
-
if (r &&
|
|
2826
|
+
if (r && me(r)) {
|
|
2827
2827
|
const g = document.createElement("div");
|
|
2828
2828
|
g.className = "gengage-chat-product-summary__image", g.dataset.gengagePart = "product-summary-image";
|
|
2829
2829
|
const C = document.createElement("img");
|
|
2830
|
-
C.loading = "lazy", oe(C, "src", r), C.alt = t.name || "Product image",
|
|
2830
|
+
C.loading = "lazy", oe(C, "src", r), C.alt = t.name || "Product image", ue(C), g.appendChild(C), n.appendChild(g);
|
|
2831
2831
|
}
|
|
2832
2832
|
const i = document.createElement("div");
|
|
2833
2833
|
i.className = "gengage-chat-product-summary__content", i.dataset.gengagePart = "product-summary-content";
|
|
@@ -2908,7 +2908,7 @@ function fr(a, e) {
|
|
|
2908
2908
|
}
|
|
2909
2909
|
});
|
|
2910
2910
|
}), n.appendChild(g);
|
|
2911
|
-
} else if (h &&
|
|
2911
|
+
} else if (h && me(h)) {
|
|
2912
2912
|
const g = document.createElement("a");
|
|
2913
2913
|
g.className = "gengage-chat-product-summary__cta gds-chip gds-chip-active", g.dataset.gengagePart = "product-summary-cta", oe(g, "href", h), oe(g, "target", "_blank"), oe(g, "rel", "noopener noreferrer"), g.textContent = e.i18n?.productCtaLabel ?? "View", n.appendChild(g);
|
|
2914
2914
|
}
|
|
@@ -3071,7 +3071,7 @@ function At(a, e, t, n, r, i, o) {
|
|
|
3071
3071
|
const d = document.createElement("span");
|
|
3072
3072
|
d.className = "gengage-chat-product-details-current-price", d.textContent = J(n, e.pricing), a.appendChild(d);
|
|
3073
3073
|
}
|
|
3074
|
-
const p =
|
|
3074
|
+
const p = Ve(t, "discountPercent", "price_discount_rate");
|
|
3075
3075
|
if (!e.hideProductDiscountBadge && typeof p == "number" && p > 0) {
|
|
3076
3076
|
const d = document.createElement("span");
|
|
3077
3077
|
d.className = "gengage-chat-product-details-discount-badge", d.textContent = `%${Yt(p)}`, a.appendChild(d);
|
|
@@ -3095,17 +3095,17 @@ function st(a, e) {
|
|
|
3095
3095
|
}
|
|
3096
3096
|
}));
|
|
3097
3097
|
const o = n.imageUrl;
|
|
3098
|
-
if (o &&
|
|
3098
|
+
if (o && me(o)) {
|
|
3099
3099
|
const b = document.createElement("div");
|
|
3100
3100
|
b.className = "gengage-chat-product-card-img-wrapper";
|
|
3101
3101
|
const E = document.createElement("img");
|
|
3102
3102
|
E.className = "gengage-chat-product-card-img", E.loading = "lazy", oe(E, "src", o);
|
|
3103
3103
|
const F = n.name;
|
|
3104
|
-
F && (E.alt = F),
|
|
3105
|
-
const
|
|
3106
|
-
if (!e.hideProductDiscountBadge && typeof
|
|
3104
|
+
F && (E.alt = F), ue(E), b.appendChild(E);
|
|
3105
|
+
const q = n.discountPercent;
|
|
3106
|
+
if (!e.hideProductDiscountBadge && typeof q == "number" && q > 0) {
|
|
3107
3107
|
const R = document.createElement("span");
|
|
3108
|
-
R.className = "gengage-chat-product-card-discount-badge", R.textContent = `%${Yt(
|
|
3108
|
+
R.className = "gengage-chat-product-card-discount-badge", R.textContent = `%${Yt(q)}`, b.appendChild(R);
|
|
3109
3109
|
}
|
|
3110
3110
|
const D = document.createElement("div");
|
|
3111
3111
|
D.className = "gengage-chat-product-card-img-actions";
|
|
@@ -3120,8 +3120,8 @@ function st(a, e) {
|
|
|
3120
3120
|
P && P.setAttribute("fill", R.classList.contains("gengage-chat-favorite-btn--active") ? "currentColor" : "none"), e.onFavoriteToggle(K, n);
|
|
3121
3121
|
}), D.appendChild(R);
|
|
3122
3122
|
}
|
|
3123
|
-
const
|
|
3124
|
-
if (
|
|
3123
|
+
const V = n.sku, Q = e.i18n?.findSimilarLabel ?? "Find Similar";
|
|
3124
|
+
if (V) {
|
|
3125
3125
|
const R = document.createElement("button");
|
|
3126
3126
|
R.className = "gengage-chat-find-similar-pill", R.type = "button", R.setAttribute("aria-label", Q), R.dataset.tooltip = Q, R.innerHTML = '<span class="gengage-chat-find-similar-pill-icon" aria-hidden="true"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round"><circle cx="10.5" cy="10.5" r="6.5"/><path d="M16 16l5.5 5.5"/></svg></span>';
|
|
3127
3127
|
const U = document.createElement("span");
|
|
@@ -3129,7 +3129,7 @@ function st(a, e) {
|
|
|
3129
3129
|
v.stopPropagation(), e.onAction({
|
|
3130
3130
|
title: Q,
|
|
3131
3131
|
type: "findSimilar",
|
|
3132
|
-
payload: { sku:
|
|
3132
|
+
payload: { sku: V }
|
|
3133
3133
|
});
|
|
3134
3134
|
}), D.appendChild(R);
|
|
3135
3135
|
}
|
|
@@ -3161,10 +3161,10 @@ function st(a, e) {
|
|
|
3161
3161
|
b.className = "gengage-chat-product-card-rating gengage-chat-product-card-rating-compact";
|
|
3162
3162
|
const E = Kt(l), F = [`${E.toFixed(1)}`, "out of 5 stars"];
|
|
3163
3163
|
typeof p == "number" && Number.isFinite(p) && F.push(`(${p} reviews)`), b.setAttribute("aria-label", F.join(" "));
|
|
3164
|
-
const
|
|
3165
|
-
|
|
3164
|
+
const q = document.createElement("span");
|
|
3165
|
+
q.className = "gengage-chat-product-card-rating-compact-star", q.setAttribute("aria-hidden", "true"), q.innerHTML = '<svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor"><path d="M12 3.6l2.58 5.23 5.77.84-4.17 4.07.98 5.75L12 16.78l-5.16 2.71.99-5.75L3.66 9.67l5.76-.84L12 3.6z"/></svg>';
|
|
3166
3166
|
const D = document.createElement("span");
|
|
3167
|
-
D.className = "gengage-chat-product-card-rating-compact-value", D.textContent = E.toFixed(1), b.appendChild(
|
|
3167
|
+
D.className = "gengage-chat-product-card-rating-compact-value", D.textContent = E.toFixed(1), b.appendChild(q), b.appendChild(D), _.appendChild(b);
|
|
3168
3168
|
}
|
|
3169
3169
|
_.childElementCount === 0 && (_.classList.add("gengage-chat-product-card-meta-row--empty"), _.setAttribute("aria-hidden", "true")), s.appendChild(_);
|
|
3170
3170
|
const w = n.name;
|
|
@@ -3203,7 +3203,7 @@ function st(a, e) {
|
|
|
3203
3203
|
}
|
|
3204
3204
|
e.onAction(i);
|
|
3205
3205
|
}), t.appendChild(b);
|
|
3206
|
-
} else if (B &&
|
|
3206
|
+
} else if (B && me(B)) {
|
|
3207
3207
|
const b = document.createElement("a");
|
|
3208
3208
|
b.className = "gengage-chat-product-card-cta", oe(b, "href", B), oe(b, "target", "_blank"), oe(b, "rel", "noopener noreferrer"), b.textContent = S, b.addEventListener("click", (E) => {
|
|
3209
3209
|
if (t.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")) {
|
|
@@ -3222,18 +3222,18 @@ function st(a, e) {
|
|
|
3222
3222
|
b.className = "gengage-chat-comparison-select-wrapper";
|
|
3223
3223
|
const E = e.comparisonSelectedSkus?.includes(j) ?? !1;
|
|
3224
3224
|
E && b.classList.add("gengage-chat-comparison-select-wrapper--selected");
|
|
3225
|
-
const F = n.name ?? j,
|
|
3226
|
-
b.setAttribute("role", "group"), b.setAttribute("aria-label", `${String(F)}. ${
|
|
3225
|
+
const F = n.name ?? j, q = e.i18n?.comparisonSelectCardHint ?? "Tap anywhere on the card to add or remove it from comparison.";
|
|
3226
|
+
b.setAttribute("role", "group"), b.setAttribute("aria-label", `${String(F)}. ${q}`);
|
|
3227
3227
|
const D = document.createElement("button");
|
|
3228
3228
|
D.type = "button", D.className = "gengage-chat-comparison-checkbox", D.dataset.selected = E ? "true" : "false", D.setAttribute("aria-pressed", E ? "true" : "false");
|
|
3229
3229
|
const K = document.createElement("span");
|
|
3230
3230
|
K.className = "gengage-chat-comparison-checkbox-icon", K.innerHTML = E ? '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6L9 17l-5-5"/></svg>' : '<span class="gengage-chat-comparison-checkbox-dot"></span>';
|
|
3231
|
-
const
|
|
3232
|
-
|
|
3231
|
+
const V = document.createElement("span");
|
|
3232
|
+
V.className = "gengage-chat-comparison-checkbox-label", V.textContent = E ? e.i18n?.comparisonSelectedLabel ?? "Selected" : e.i18n?.comparisonSelectLabel ?? "Select to compare", D.appendChild(K), D.appendChild(V), D.addEventListener("click", (R) => {
|
|
3233
3233
|
R.stopPropagation(), e.onToggleComparisonSku?.(j);
|
|
3234
3234
|
});
|
|
3235
3235
|
const Q = document.createElement("div");
|
|
3236
|
-
return Q.className = "gengage-chat-comparison-card-hint", Q.setAttribute("aria-hidden", "true"), Q.textContent =
|
|
3236
|
+
return Q.className = "gengage-chat-comparison-card-hint", Q.setAttribute("aria-hidden", "true"), Q.textContent = q, b.addEventListener("click", (R) => {
|
|
3237
3237
|
R.target.closest(".gengage-chat-comparison-checkbox") || (R.stopPropagation(), e.onToggleComparisonSku?.(j));
|
|
3238
3238
|
}), b.appendChild(D), b.appendChild(Q), b.appendChild(t), b;
|
|
3239
3239
|
}
|
|
@@ -3290,7 +3290,7 @@ function de(a, ...e) {
|
|
|
3290
3290
|
}
|
|
3291
3291
|
}
|
|
3292
3292
|
}
|
|
3293
|
-
function
|
|
3293
|
+
function Ve(a, ...e) {
|
|
3294
3294
|
for (const t of e) {
|
|
3295
3295
|
const n = a[t];
|
|
3296
3296
|
if (typeof n == "number" && Number.isFinite(n)) return n;
|
|
@@ -3316,7 +3316,7 @@ function Lr(a) {
|
|
|
3316
3316
|
return Array.isArray(a) ? a.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
|
|
3317
3317
|
}
|
|
3318
3318
|
function Ar(a) {
|
|
3319
|
-
const e = [...Lr(a.images), de(a, "imageUrl", "image_url", "image")].filter((t) => !!t &&
|
|
3319
|
+
const e = [...Lr(a.images), de(a, "imageUrl", "image_url", "image")].filter((t) => !!t && me(t));
|
|
3320
3320
|
return Array.from(new Set(e));
|
|
3321
3321
|
}
|
|
3322
3322
|
function Tr(a) {
|
|
@@ -3364,7 +3364,7 @@ function ke(a, ...e) {
|
|
|
3364
3364
|
return de(a, ...e);
|
|
3365
3365
|
}
|
|
3366
3366
|
function Tt(a, ...e) {
|
|
3367
|
-
return
|
|
3367
|
+
return Ve(a, ...e);
|
|
3368
3368
|
}
|
|
3369
3369
|
function sa(a) {
|
|
3370
3370
|
return ke(a, "value", "option_value", "attribute_value", "label", "title", "name", "variant_name", "sku");
|
|
@@ -3439,35 +3439,35 @@ function jr(a, e) {
|
|
|
3439
3439
|
t.className = "gengage-chat-product-details-panel";
|
|
3440
3440
|
const n = a.props?.product ?? a.props;
|
|
3441
3441
|
if (!n) return t;
|
|
3442
|
-
const r = de(n, "name"), i = de(n, "brand"), o = de(n, "sku"), s = de(n, "cartCode", "cart_code"), c = de(n, "price"), l = de(n, "originalPrice", "price_original"), p = je(n, "price_async"), d = ze(e, n), h = Ue(e, n), u = !!(l && c && l !== c), x = je(n, "inStock", "in_stock"), f =
|
|
3442
|
+
const r = de(n, "name"), i = de(n, "brand"), o = de(n, "sku"), s = de(n, "cartCode", "cart_code"), c = de(n, "price"), l = de(n, "originalPrice", "price_original"), p = je(n, "price_async"), d = ze(e, n), h = Ue(e, n), u = !!(l && c && l !== c), x = je(n, "inStock", "in_stock"), f = Ve(n, "reviewCount", "review_count"), m = Ve(n, "rating"), g = Ar(n), C = oa(n).slice(0, 4);
|
|
3443
3443
|
if (g.length > 1) {
|
|
3444
3444
|
const L = document.createElement("div");
|
|
3445
3445
|
L.className = "gengage-chat-product-details-media gengage-chat-product-details-gallery gengage-chat-product-details-img-wrap";
|
|
3446
3446
|
const S = document.createElement("img");
|
|
3447
|
-
S.className = "gengage-chat-product-details-img", oe(S, "src", g[0]), S.alt = r ?? "Product image",
|
|
3447
|
+
S.className = "gengage-chat-product-details-img", oe(S, "src", g[0]), S.alt = r ?? "Product image", ue(S), L.appendChild(S);
|
|
3448
3448
|
const b = document.createElement("div");
|
|
3449
3449
|
b.className = "gengage-chat-product-gallery-thumbs";
|
|
3450
3450
|
const E = 6;
|
|
3451
|
-
let F = null,
|
|
3452
|
-
const D = e.i18n, K = D?.galleryPrevAriaLabel ?? "Previous image",
|
|
3451
|
+
let F = null, q = 0;
|
|
3452
|
+
const D = e.i18n, K = D?.galleryPrevAriaLabel ?? "Previous image", V = D?.galleryNextAriaLabel ?? "Next image", Q = (N) => N === "prev" ? '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="15 18 9 12 15 6"/></svg>' : '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="9 18 15 12 9 6"/></svg>', R = document.createElement("button");
|
|
3453
3453
|
R.type = "button", R.className = "gengage-chat-product-gallery-nav gengage-chat-product-gallery-nav--prev gds-btn gds-btn-ghost gds-icon-btn", R.setAttribute("aria-label", K), R.innerHTML = Q("prev");
|
|
3454
3454
|
const U = document.createElement("button");
|
|
3455
|
-
U.type = "button", U.className = "gengage-chat-product-gallery-nav gengage-chat-product-gallery-nav--next gds-btn gds-btn-ghost gds-icon-btn", U.setAttribute("aria-label",
|
|
3455
|
+
U.type = "button", U.className = "gengage-chat-product-gallery-nav gengage-chat-product-gallery-nav--next gds-btn gds-btn-ghost gds-icon-btn", U.setAttribute("aria-label", V), U.innerHTML = Q("next");
|
|
3456
3456
|
const v = () => {
|
|
3457
|
-
R.disabled =
|
|
3457
|
+
R.disabled = q <= 0, U.disabled = q >= g.length - 1;
|
|
3458
3458
|
}, P = (N) => {
|
|
3459
|
-
if (N < 0 || N >= g.length || N ===
|
|
3459
|
+
if (N < 0 || N >= g.length || N === q) return;
|
|
3460
3460
|
const H = g[N];
|
|
3461
3461
|
if (!H) return;
|
|
3462
3462
|
oe(S, "src", H);
|
|
3463
3463
|
const G = b.querySelectorAll(".gengage-chat-product-gallery-thumb");
|
|
3464
|
-
F && F.classList.remove("gengage-chat-product-gallery-thumb--active"), N < E && G[N] ? (G[N].classList.add("gengage-chat-product-gallery-thumb--active"), F = G[N]) : F = null,
|
|
3464
|
+
F && F.classList.remove("gengage-chat-product-gallery-thumb--active"), N < E && G[N] ? (G[N].classList.add("gengage-chat-product-gallery-thumb--active"), F = G[N]) : F = null, q = N, v();
|
|
3465
3465
|
};
|
|
3466
3466
|
for (let N = 0; N < g.length; N++) {
|
|
3467
3467
|
const H = g[N];
|
|
3468
3468
|
if (N >= E) break;
|
|
3469
3469
|
const G = document.createElement("img");
|
|
3470
|
-
G.className = "gengage-chat-product-gallery-thumb", N === 0 && (G.classList.add("gengage-chat-product-gallery-thumb--active"), F = G), oe(G, "src", H), G.alt = `${r ?? "Product"} ${N + 1}`, G.width = 48, G.height = 48,
|
|
3470
|
+
G.className = "gengage-chat-product-gallery-thumb", N === 0 && (G.classList.add("gengage-chat-product-gallery-thumb--active"), F = G), oe(G, "src", H), G.alt = `${r ?? "Product"} ${N + 1}`, G.width = 48, G.height = 48, ue(G), G.addEventListener("click", () => {
|
|
3471
3471
|
P(N);
|
|
3472
3472
|
}), b.appendChild(G);
|
|
3473
3473
|
}
|
|
@@ -3476,9 +3476,9 @@ function jr(a, e) {
|
|
|
3476
3476
|
N.className = "gengage-chat-product-gallery-thumb-more", N.textContent = `+${g.length - E}`, b.appendChild(N);
|
|
3477
3477
|
}
|
|
3478
3478
|
R.addEventListener("click", (N) => {
|
|
3479
|
-
N.stopPropagation(), P(
|
|
3479
|
+
N.stopPropagation(), P(q - 1);
|
|
3480
3480
|
}), U.addEventListener("click", (N) => {
|
|
3481
|
-
N.stopPropagation(), P(
|
|
3481
|
+
N.stopPropagation(), P(q + 1);
|
|
3482
3482
|
}), v();
|
|
3483
3483
|
let T = 0;
|
|
3484
3484
|
const O = 50;
|
|
@@ -3486,13 +3486,13 @@ function jr(a, e) {
|
|
|
3486
3486
|
T = N.changedTouches[0].clientX;
|
|
3487
3487
|
}, { passive: !0 }), S.addEventListener("touchend", (N) => {
|
|
3488
3488
|
const H = N.changedTouches[0].clientX, G = T - H;
|
|
3489
|
-
Math.abs(G) < O || P(G > 0 ? Math.min(
|
|
3489
|
+
Math.abs(G) < O || P(G > 0 ? Math.min(q + 1, g.length - 1) : Math.max(q - 1, 0));
|
|
3490
3490
|
}), L.appendChild(R), L.appendChild(U), L.appendChild(b), t.appendChild(L);
|
|
3491
3491
|
} else if (g.length === 1) {
|
|
3492
3492
|
const L = document.createElement("div");
|
|
3493
3493
|
L.className = "gengage-chat-product-details-media gengage-chat-product-details-img-wrap";
|
|
3494
3494
|
const S = document.createElement("img");
|
|
3495
|
-
S.className = "gengage-chat-product-details-img", S.loading = "lazy", oe(S, "src", g[0]),
|
|
3495
|
+
S.className = "gengage-chat-product-details-img", S.loading = "lazy", oe(S, "src", g[0]), ue(S), S.alt = r ?? "Product image", L.appendChild(S), t.appendChild(L);
|
|
3496
3496
|
}
|
|
3497
3497
|
const A = document.createElement("div");
|
|
3498
3498
|
if (A.className = "gengage-chat-product-details-content", i && (!r || !r.toLowerCase().startsWith(i.toLowerCase()))) {
|
|
@@ -3581,18 +3581,18 @@ function jr(a, e) {
|
|
|
3581
3581
|
const b = document.createElement("div");
|
|
3582
3582
|
b.className = "gengage-chat-product-variants-list";
|
|
3583
3583
|
for (const E of M) {
|
|
3584
|
-
const F = sa(E),
|
|
3585
|
-
if (!F && !
|
|
3584
|
+
const F = sa(E), q = ke(E, "sku");
|
|
3585
|
+
if (!F && !q) continue;
|
|
3586
3586
|
const D = document.createElement("button");
|
|
3587
3587
|
D.className = "gengage-chat-product-variant-btn gds-chip", D.type = "button";
|
|
3588
|
-
const K = F ??
|
|
3588
|
+
const K = F ?? q ?? "";
|
|
3589
3589
|
D.title = K;
|
|
3590
|
-
const
|
|
3591
|
-
|
|
3590
|
+
const V = je(E, "in_stock", "inStock");
|
|
3591
|
+
q && o && q === o ? (D.classList.add("gengage-chat-product-variant-btn--active"), D.setAttribute("aria-pressed", "true")) : D.setAttribute("aria-pressed", "false"), V === !1 && (D.classList.add("gengage-chat-product-variant-btn--out"), D.disabled = !0);
|
|
3592
3592
|
const Q = zr(E), R = Br(E);
|
|
3593
|
-
if (Q &&
|
|
3593
|
+
if (Q && me(Q)) {
|
|
3594
3594
|
const P = document.createElement("img");
|
|
3595
|
-
P.className = "gengage-chat-product-variant-swatch gengage-chat-product-variant-swatch--image", oe(P, "src", Q), P.alt = "", P.setAttribute("aria-hidden", "true"),
|
|
3595
|
+
P.className = "gengage-chat-product-variant-swatch gengage-chat-product-variant-swatch--image", oe(P, "src", Q), P.alt = "", P.setAttribute("aria-hidden", "true"), ue(P), D.appendChild(P);
|
|
3596
3596
|
} else if (R) {
|
|
3597
3597
|
const P = document.createElement("span");
|
|
3598
3598
|
P.className = "gengage-chat-product-variant-swatch", P.setAttribute("aria-hidden", "true"), P.style.backgroundColor = R, D.appendChild(P);
|
|
@@ -3604,13 +3604,13 @@ function jr(a, e) {
|
|
|
3604
3604
|
const P = document.createElement("span");
|
|
3605
3605
|
P.className = "gengage-chat-product-variant-price", P.textContent = J(String(v), e.pricing), D.appendChild(P);
|
|
3606
3606
|
}
|
|
3607
|
-
if (
|
|
3607
|
+
if (q && q !== o) {
|
|
3608
3608
|
const P = r ?? "", T = (typeof E.value == "string" ? E.value.trim() : "") || (typeof E.name == "string" ? E.name.trim() : "") || (typeof E.variant_name == "string" ? E.variant_name.trim() : "") || "", O = P.length > 0 ? T.length > 0 && T !== P ? `${P} (${T})` : P : K;
|
|
3609
3609
|
D.addEventListener("click", () => {
|
|
3610
3610
|
e.onAction({
|
|
3611
3611
|
title: O,
|
|
3612
3612
|
type: "launchVariant",
|
|
3613
|
-
payload: { sku:
|
|
3613
|
+
payload: { sku: q }
|
|
3614
3614
|
});
|
|
3615
3615
|
});
|
|
3616
3616
|
}
|
|
@@ -3640,7 +3640,7 @@ function jr(a, e) {
|
|
|
3640
3640
|
}), I.appendChild(L);
|
|
3641
3641
|
}
|
|
3642
3642
|
const k = de(n, "url");
|
|
3643
|
-
if (!w && k &&
|
|
3643
|
+
if (!w && k && me(k)) {
|
|
3644
3644
|
const L = document.createElement("a");
|
|
3645
3645
|
L.className = "gengage-chat-product-details-cta gds-btn gds-btn-secondary", oe(L, "href", k), oe(L, "target", "_blank"), oe(L, "rel", "noopener noreferrer"), L.textContent = e.i18n?.viewOnSiteLabel ?? e.i18n?.productCtaLabel ?? "View on Site", L.addEventListener("click", (S) => {
|
|
3646
3646
|
e.onProductClick && o && (S.preventDefault(), e.onProductClick({
|
|
@@ -3651,20 +3651,20 @@ function jr(a, e) {
|
|
|
3651
3651
|
}), I.appendChild(L);
|
|
3652
3652
|
}
|
|
3653
3653
|
const B = k;
|
|
3654
|
-
if (B &&
|
|
3654
|
+
if (B && me(B)) {
|
|
3655
3655
|
let F = function(D, K) {
|
|
3656
|
-
const
|
|
3657
|
-
|
|
3658
|
-
},
|
|
3656
|
+
const V = document.createElementNS(b, "circle");
|
|
3657
|
+
V.setAttribute("cx", D), V.setAttribute("cy", K), V.setAttribute("r", "3"), E.appendChild(V);
|
|
3658
|
+
}, q = function(D, K, V, Q) {
|
|
3659
3659
|
const R = document.createElementNS(b, "line");
|
|
3660
|
-
R.setAttribute("x1", D), R.setAttribute("y1", K), R.setAttribute("x2",
|
|
3660
|
+
R.setAttribute("x1", D), R.setAttribute("y1", K), R.setAttribute("x2", V), R.setAttribute("y2", Q), E.appendChild(R);
|
|
3661
3661
|
};
|
|
3662
3662
|
const L = document.createElement("button");
|
|
3663
3663
|
L.className = "gengage-chat-product-details-share gds-btn gds-btn-ghost gds-icon-btn", L.type = "button";
|
|
3664
3664
|
const S = e.i18n?.shareButton ?? "Share";
|
|
3665
3665
|
L.title = S, L.setAttribute("aria-label", S);
|
|
3666
3666
|
const b = "http://www.w3.org/2000/svg", E = document.createElementNS(b, "svg");
|
|
3667
|
-
E.setAttribute("width", "18"), E.setAttribute("height", "18"), E.setAttribute("viewBox", "0 0 24 24"), E.setAttribute("fill", "none"), E.setAttribute("stroke", "currentColor"), E.setAttribute("stroke-width", "2"), E.setAttribute("stroke-linecap", "round"), E.setAttribute("stroke-linejoin", "round"), F("18", "5"), F("6", "12"), F("18", "19"),
|
|
3667
|
+
E.setAttribute("width", "18"), E.setAttribute("height", "18"), E.setAttribute("viewBox", "0 0 24 24"), E.setAttribute("fill", "none"), E.setAttribute("stroke", "currentColor"), E.setAttribute("stroke-width", "2"), E.setAttribute("stroke-linecap", "round"), E.setAttribute("stroke-linejoin", "round"), F("18", "5"), F("6", "12"), F("18", "19"), q("8.59", "13.51", "15.42", "17.49"), q("15.41", "6.51", "8.59", "10.49"), L.appendChild(E), L.addEventListener("click", async () => {
|
|
3668
3668
|
try {
|
|
3669
3669
|
navigator.share ? await navigator.share({
|
|
3670
3670
|
title: r ?? "",
|
|
@@ -3698,7 +3698,7 @@ function ct(a) {
|
|
|
3698
3698
|
}
|
|
3699
3699
|
return n;
|
|
3700
3700
|
}
|
|
3701
|
-
function
|
|
3701
|
+
function qr(a, e) {
|
|
3702
3702
|
const t = e.split(/\n{2,}/).map((n) => n.replace(/\s+/g, " ").trim()).filter(Boolean);
|
|
3703
3703
|
if (t.length !== 0)
|
|
3704
3704
|
for (const n of t) {
|
|
@@ -3706,7 +3706,7 @@ function Vr(a, e) {
|
|
|
3706
3706
|
r.textContent = n, a.appendChild(r);
|
|
3707
3707
|
}
|
|
3708
3708
|
}
|
|
3709
|
-
function
|
|
3709
|
+
function Vr(a, e) {
|
|
3710
3710
|
if (a.classList.add("gengage-chat-product-description"), e.html && typeof DOMParser < "u") {
|
|
3711
3711
|
const t = new DOMParser().parseFromString(e.html, "text/html"), n = Array.from(t.body.childNodes).map((r) => ct(r)).filter((r) => !!r && (r.nodeType === Node.ELEMENT_NODE || !!r.textContent?.trim()));
|
|
3712
3712
|
if (n.length > 0) {
|
|
@@ -3714,7 +3714,7 @@ function qr(a, e) {
|
|
|
3714
3714
|
return;
|
|
3715
3715
|
}
|
|
3716
3716
|
}
|
|
3717
|
-
|
|
3717
|
+
qr(a, e.text);
|
|
3718
3718
|
}
|
|
3719
3719
|
function Gr(a, e, t) {
|
|
3720
3720
|
const n = document.createElement("div");
|
|
@@ -3726,7 +3726,7 @@ function Gr(a, e, t) {
|
|
|
3726
3726
|
const s = document.createElement("button");
|
|
3727
3727
|
s.className = "gengage-chat-product-detail-tab gds-tab gengage-chat-product-detail-tab--active is-active", s.type = "button", s.setAttribute("aria-selected", "true"), s.textContent = t.i18n?.productInfoTab ?? "Product Info", r.appendChild(s);
|
|
3728
3728
|
const c = document.createElement("div");
|
|
3729
|
-
c.className = "gengage-chat-product-detail-tab-panel",
|
|
3729
|
+
c.className = "gengage-chat-product-detail-tab-panel", Vr(c, a), i.push(c);
|
|
3730
3730
|
}
|
|
3731
3731
|
if (e) {
|
|
3732
3732
|
const s = document.createElement("button");
|
|
@@ -3882,14 +3882,14 @@ function Zr(a, e, t, n) {
|
|
|
3882
3882
|
b.setAttribute("aria-selected", E ? "true" : "false"), E && b.classList.add("gengage-chat-product-sort-option--active", "gds-menu-option-active");
|
|
3883
3883
|
const F = S.sortState.type === "related" ? "related" : `price-${S.sortState.direction ?? ""}`;
|
|
3884
3884
|
b.dataset.sortKey = F;
|
|
3885
|
-
const
|
|
3886
|
-
|
|
3885
|
+
const q = document.createElement("span");
|
|
3886
|
+
q.className = "gengage-chat-product-sort-option-icon", q.innerHTML = Mt(S.icon);
|
|
3887
3887
|
const D = document.createElement("span");
|
|
3888
3888
|
D.className = "gengage-chat-product-sort-option-label", D.textContent = S.label;
|
|
3889
3889
|
const K = document.createElement("span");
|
|
3890
|
-
K.className = "gengage-chat-product-sort-option-check", K.innerHTML = Wr(), K.setAttribute("aria-hidden", "true"), E || K.classList.add("gengage-chat-product-sort-option-check--hidden"), b.appendChild(
|
|
3891
|
-
u = S.sortState, n.onSortChange?.(S.sortState), Yr(c, s, e, S.sortState), I.querySelectorAll(".gengage-chat-product-sort-option").forEach((
|
|
3892
|
-
const Q =
|
|
3890
|
+
K.className = "gengage-chat-product-sort-option-check", K.innerHTML = Wr(), K.setAttribute("aria-hidden", "true"), E || K.classList.add("gengage-chat-product-sort-option-check--hidden"), b.appendChild(q), b.appendChild(D), b.appendChild(K), b.addEventListener("click", () => {
|
|
3891
|
+
u = S.sortState, n.onSortChange?.(S.sortState), Yr(c, s, e, S.sortState), I.querySelectorAll(".gengage-chat-product-sort-option").forEach((V) => {
|
|
3892
|
+
const Q = V, R = Q.dataset.sortKey === F;
|
|
3893
3893
|
Q.classList.toggle("gengage-chat-product-sort-option--active", R), Q.classList.toggle("gds-menu-option-active", R), Q.setAttribute("aria-selected", R ? "true" : "false"), Q.querySelector(".gengage-chat-product-sort-option-check")?.classList.toggle("gengage-chat-product-sort-option-check--hidden", !R);
|
|
3894
3894
|
}), _(S.sortState), B();
|
|
3895
3895
|
}), I.appendChild(b);
|
|
@@ -4023,7 +4023,7 @@ function Bt(a, e, t, n) {
|
|
|
4023
4023
|
const o = document.createElement("section");
|
|
4024
4024
|
o.className = "gengage-chat-consulting-loading-panel";
|
|
4025
4025
|
const s = document.createElement("h4");
|
|
4026
|
-
s.className = "gengage-chat-consulting-loading-panel-title", s.textContent =
|
|
4026
|
+
s.className = "gengage-chat-consulting-loading-panel-title", s.textContent = qe(e, n, i), o.appendChild(s);
|
|
4027
4027
|
const c = document.createElement("p");
|
|
4028
4028
|
if (c.className = "gengage-chat-consulting-loading-panel-copy", c.textContent = t === "loading" ? i.consultingStyleLoadingDescription : i.consultingStyleUnavailableDescription, o.appendChild(c), t === "loading") {
|
|
4029
4029
|
const l = document.createElement("div");
|
|
@@ -4036,7 +4036,7 @@ function Bt(a, e, t, n) {
|
|
|
4036
4036
|
}
|
|
4037
4037
|
r.appendChild(o);
|
|
4038
4038
|
}
|
|
4039
|
-
function
|
|
4039
|
+
function qe(a, e, t) {
|
|
4040
4040
|
const n = (r) => t.consultingFallbackStyleLabel.replace("{index}", String(r));
|
|
4041
4041
|
return a.style_label ?? n(e);
|
|
4042
4042
|
}
|
|
@@ -4119,16 +4119,16 @@ function ht(a, e) {
|
|
|
4119
4119
|
}
|
|
4120
4120
|
function gt(a, e, t, n) {
|
|
4121
4121
|
const r = Xe(e), i = n.consultingStyleLoadingBadge, o = n.consultingStyleUnavailableBadge;
|
|
4122
|
-
a.classList.remove("gengage-chat-consulting-style-btn--loading", "gengage-chat-consulting-style-btn--muted"), r === "loading" ? a.classList.add("gengage-chat-consulting-style-btn--loading") : r !== "ready" && a.classList.add("gengage-chat-consulting-style-btn--muted"), a.setAttribute("aria-label",
|
|
4122
|
+
a.classList.remove("gengage-chat-consulting-style-btn--loading", "gengage-chat-consulting-style-btn--muted"), r === "loading" ? a.classList.add("gengage-chat-consulting-style-btn--loading") : r !== "ready" && a.classList.add("gengage-chat-consulting-style-btn--muted"), a.setAttribute("aria-label", qe(e, t + 1, n));
|
|
4123
4123
|
let s = a.querySelector(".gengage-chat-consulting-style-media");
|
|
4124
4124
|
s ? s.innerHTML = "" : (s = document.createElement("div"), s.className = "gengage-chat-consulting-style-media", a.appendChild(s));
|
|
4125
4125
|
const c = Jr(e.image_url);
|
|
4126
|
-
if (c &&
|
|
4126
|
+
if (c && me(c)) {
|
|
4127
4127
|
const p = document.createElement("img");
|
|
4128
|
-
p.className = "gengage-chat-consulting-style-image", p.draggable = !1, oe(p, "src", c), p.alt =
|
|
4128
|
+
p.className = "gengage-chat-consulting-style-image", p.draggable = !1, oe(p, "src", c), p.alt = qe(e, t + 1, n), p.loading = "lazy", ue(p), s.appendChild(p);
|
|
4129
4129
|
}
|
|
4130
4130
|
const l = document.createElement("span");
|
|
4131
|
-
if (l.className = "gengage-chat-consulting-style-caption", l.textContent =
|
|
4131
|
+
if (l.className = "gengage-chat-consulting-style-caption", l.textContent = qe(e, t + 1, n), s.appendChild(l), r === "loading" || r !== "ready") {
|
|
4132
4132
|
const p = document.createElement("span");
|
|
4133
4133
|
p.className = "gengage-chat-consulting-style-status", p.textContent = r === "loading" ? i : o, s.appendChild(p);
|
|
4134
4134
|
}
|
|
@@ -4578,7 +4578,7 @@ function gi(a, e, t) {
|
|
|
4578
4578
|
M.className = "gengage-fl", M.dataset.gengagePart = "floating-launcher", M.innerHTML = li();
|
|
4579
4579
|
const I = M.querySelector(".gengage-fl-input"), w = M.querySelector(".gengage-fl-transcript"), k = M.querySelector(".gengage-fl-transcript-final"), B = M.querySelector(".gengage-fl-transcript-interim"), j = M.querySelector(".gengage-fl-btn-send"), Z = M.querySelector(".gengage-fl-btn-mic"), L = M.querySelector(".gengage-fl-btn-open-chat"), S = M.querySelector(".gengage-fl-cancel"), b = M.querySelector(".gengage-fl-wave"), E = M.querySelector(".gengage-fl-ring");
|
|
4580
4580
|
I.placeholder = u[0] ?? "", j.setAttribute("aria-label", g), Z.setAttribute("aria-label", C), S.setAttribute("aria-label", A), L.setAttribute("aria-label", _);
|
|
4581
|
-
let F = !1,
|
|
4581
|
+
let F = !1, q = !1, D = "", K = !1, V = null, Q = 0, R = null, U = null, v = null, P = null, T = null, O = 0;
|
|
4582
4582
|
function N() {
|
|
4583
4583
|
const z = I.value.trim().length > 0;
|
|
4584
4584
|
if (Z.classList.toggle("is-recording", F), F) {
|
|
@@ -4597,7 +4597,7 @@ function gi(a, e, t) {
|
|
|
4597
4597
|
R !== null && (clearTimeout(R), R = null);
|
|
4598
4598
|
}
|
|
4599
4599
|
function ee() {
|
|
4600
|
-
F && (F = !1, se(),
|
|
4600
|
+
F && (F = !1, se(), q = !1, ae(), m && ie(), D = "", I.style.display = "", w.style.display = "none", k.textContent = "", B.textContent = "");
|
|
4601
4601
|
const z = I.value.trim();
|
|
4602
4602
|
z && (e.onSend(z), K || (K = !0)), I.value = "", D = "", N();
|
|
4603
4603
|
}
|
|
@@ -4607,7 +4607,7 @@ function gi(a, e, t) {
|
|
|
4607
4607
|
console.warn("[FloatingLauncher] SpeechRecognition not supported.");
|
|
4608
4608
|
return;
|
|
4609
4609
|
}
|
|
4610
|
-
|
|
4610
|
+
V || (V = new Y(), V.continuous = !0, V.interimResults = !0, V.lang = f), F = !0, q = !0, D = "", I.value = "", I.style.display = "none", w.style.display = "flex", k.textContent = "", B.textContent = "", N(), $(), m && re(), V.onresult = (X) => {
|
|
4611
4611
|
if (!F) return;
|
|
4612
4612
|
let W = "", ce = "";
|
|
4613
4613
|
for (let Se = X.resultIndex; Se < X.results.length; Se++) {
|
|
@@ -4617,21 +4617,21 @@ function gi(a, e, t) {
|
|
|
4617
4617
|
Le.isFinal ? ce += Re : W += Re;
|
|
4618
4618
|
}
|
|
4619
4619
|
D += ce, k.textContent = D, B.textContent = W, I.value = `${D} ${W}`.trim(), N();
|
|
4620
|
-
},
|
|
4620
|
+
}, V.onend = () => y(), V.onerror = () => y();
|
|
4621
4621
|
try {
|
|
4622
|
-
|
|
4622
|
+
V.start();
|
|
4623
4623
|
} catch {
|
|
4624
4624
|
y();
|
|
4625
4625
|
}
|
|
4626
4626
|
}
|
|
4627
4627
|
function se() {
|
|
4628
4628
|
try {
|
|
4629
|
-
|
|
4629
|
+
V?.stop();
|
|
4630
4630
|
} catch {
|
|
4631
4631
|
}
|
|
4632
4632
|
}
|
|
4633
4633
|
function y() {
|
|
4634
|
-
|
|
4634
|
+
q && (q = !1, F = !1, ae(), m && ie(), D.trim() && (I.value = D.trim()), I.style.display = "", w.style.display = "none", k.textContent = "", B.textContent = "", N());
|
|
4635
4635
|
}
|
|
4636
4636
|
async function $() {
|
|
4637
4637
|
const z = ++O, Y = Array.from(b.querySelectorAll("span"));
|
|
@@ -4682,7 +4682,7 @@ function gi(a, e, t) {
|
|
|
4682
4682
|
j.addEventListener("click", ee), Z.addEventListener("click", (z) => {
|
|
4683
4683
|
z.preventDefault(), z.stopPropagation(), F ? se() : ne();
|
|
4684
4684
|
}), S.addEventListener("click", () => {
|
|
4685
|
-
F && (F = !1, se(),
|
|
4685
|
+
F && (F = !1, se(), q = !1, ae(), m && ie(), D = "", I.style.display = "", w.style.display = "none", k.textContent = "", B.textContent = "", N());
|
|
4686
4686
|
}), L.addEventListener("click", (z) => {
|
|
4687
4687
|
z.preventDefault(), z.stopPropagation(), e.onOpenChat();
|
|
4688
4688
|
}), I.addEventListener("input", N), I.addEventListener("keydown", (z) => {
|
|
@@ -4691,13 +4691,13 @@ function gi(a, e, t) {
|
|
|
4691
4691
|
function he() {
|
|
4692
4692
|
K = !0, N();
|
|
4693
4693
|
}
|
|
4694
|
-
function
|
|
4695
|
-
te(), ae(), ie(), F && (F = !1, se()),
|
|
4694
|
+
function fe() {
|
|
4695
|
+
te(), ae(), ie(), F && (F = !1, se()), V && (V.onresult = null, V.onend = null, V.onerror = null, V = null);
|
|
4696
4696
|
}
|
|
4697
4697
|
return {
|
|
4698
4698
|
container: M,
|
|
4699
4699
|
showOpenChatButton: he,
|
|
4700
|
-
destroy:
|
|
4700
|
+
destroy: fe
|
|
4701
4701
|
};
|
|
4702
4702
|
}
|
|
4703
4703
|
var di = /* @__PURE__ */ new Set([
|
|
@@ -4892,7 +4892,7 @@ function pt(a) {
|
|
|
4892
4892
|
function Si(a) {
|
|
4893
4893
|
a && pt(a);
|
|
4894
4894
|
}
|
|
4895
|
-
var Ei = "gengage_assistant", Pi = 3, Ee = "sessions",
|
|
4895
|
+
var Ei = "gengage_assistant", Pi = 3, Ee = "sessions", be = "context", we = "payload", ve = "favorites";
|
|
4896
4896
|
function He(a) {
|
|
4897
4897
|
return new Promise((e, t) => {
|
|
4898
4898
|
a.onsuccess = () => e(a.result), a.onerror = () => t(a.error);
|
|
@@ -4916,7 +4916,7 @@ var Li = class {
|
|
|
4916
4916
|
"userId",
|
|
4917
4917
|
"appId",
|
|
4918
4918
|
"sessionId"
|
|
4919
|
-
] }), r.createObjectStore(
|
|
4919
|
+
] }), r.createObjectStore(be, { keyPath: ["sessionId", "threadId"] }), r.createObjectStore(we, { keyPath: ["threadId", "messageId"] }).createIndex("threadId", "threadId", { unique: !1 }), r.createObjectStore(ve, { keyPath: [
|
|
4920
4920
|
"userId",
|
|
4921
4921
|
"appId",
|
|
4922
4922
|
"sku"
|
|
@@ -4924,7 +4924,7 @@ var Li = class {
|
|
|
4924
4924
|
"userId",
|
|
4925
4925
|
"appId",
|
|
4926
4926
|
"sessionId"
|
|
4927
|
-
] }), r.createObjectStore(we, { keyPath: ["threadId", "messageId"] }).createIndex("threadId", "threadId", { unique: !1 }), r.objectStoreNames.contains(
|
|
4927
|
+
] }), r.createObjectStore(we, { keyPath: ["threadId", "messageId"] }).createIndex("threadId", "threadId", { unique: !1 }), r.objectStoreNames.contains(be) || r.createObjectStore(be, { keyPath: ["sessionId", "threadId"] })), i < 3 && (r.objectStoreNames.contains(ve) || r.createObjectStore(ve, { keyPath: [
|
|
4928
4928
|
"userId",
|
|
4929
4929
|
"appId",
|
|
4930
4930
|
"sku"
|
|
@@ -4949,14 +4949,14 @@ var Li = class {
|
|
|
4949
4949
|
])) ?? null;
|
|
4950
4950
|
}
|
|
4951
4951
|
async saveContext(a) {
|
|
4952
|
-
const e = this._requireDb().transaction(
|
|
4953
|
-
e.objectStore(
|
|
4952
|
+
const e = this._requireDb().transaction(be, "readwrite");
|
|
4953
|
+
e.objectStore(be).put(a), await Ie(e);
|
|
4954
4954
|
}
|
|
4955
4955
|
async loadContext(a, e) {
|
|
4956
|
-
return await He(this._requireDb().transaction(
|
|
4956
|
+
return await He(this._requireDb().transaction(be, "readonly").objectStore(be).get([a, e])) ?? null;
|
|
4957
4957
|
}
|
|
4958
4958
|
async deleteContextsAfterThread(a, e) {
|
|
4959
|
-
const t = this._requireDb().transaction(
|
|
4959
|
+
const t = this._requireDb().transaction(be, "readwrite"), n = t.objectStore(be).openCursor();
|
|
4960
4960
|
await new Promise((r, i) => {
|
|
4961
4961
|
n.onsuccess = () => {
|
|
4962
4962
|
const o = n.result;
|
|
@@ -4974,7 +4974,7 @@ var Li = class {
|
|
|
4974
4974
|
}), await Ie(t);
|
|
4975
4975
|
}
|
|
4976
4976
|
async loadLatestContext(a) {
|
|
4977
|
-
const e = this._requireDb().transaction(
|
|
4977
|
+
const e = this._requireDb().transaction(be, "readonly").objectStore(be), t = IDBKeyRange.bound([a, ""], [a, ""]);
|
|
4978
4978
|
return new Promise((n, r) => {
|
|
4979
4979
|
const i = e.openCursor(t, "prev");
|
|
4980
4980
|
i.onsuccess = () => {
|
|
@@ -5005,22 +5005,22 @@ var Li = class {
|
|
|
5005
5005
|
});
|
|
5006
5006
|
}
|
|
5007
5007
|
async saveFavorite(a) {
|
|
5008
|
-
const e = this._requireDb().transaction(
|
|
5009
|
-
e.objectStore(
|
|
5008
|
+
const e = this._requireDb().transaction(ve, "readwrite");
|
|
5009
|
+
e.objectStore(ve).put(a), await Ie(e);
|
|
5010
5010
|
}
|
|
5011
5011
|
async removeFavorite(a, e, t) {
|
|
5012
|
-
const n = this._requireDb().transaction(
|
|
5013
|
-
n.objectStore(
|
|
5012
|
+
const n = this._requireDb().transaction(ve, "readwrite");
|
|
5013
|
+
n.objectStore(ve).delete([
|
|
5014
5014
|
a,
|
|
5015
5015
|
e,
|
|
5016
5016
|
t
|
|
5017
5017
|
]), await Ie(n);
|
|
5018
5018
|
}
|
|
5019
5019
|
async loadFavorites(a, e) {
|
|
5020
|
-
return (await He(this._requireDb().transaction(
|
|
5020
|
+
return (await He(this._requireDb().transaction(ve, "readonly").objectStore(ve).getAll())).filter((t) => t.userId === a && t.appId === e);
|
|
5021
5021
|
}
|
|
5022
5022
|
async isFavorite(a, e, t) {
|
|
5023
|
-
return await He(this._requireDb().transaction(
|
|
5023
|
+
return await He(this._requireDb().transaction(ve, "readonly").objectStore(ve).get([
|
|
5024
5024
|
a,
|
|
5025
5025
|
e,
|
|
5026
5026
|
t
|
|
@@ -5283,14 +5283,14 @@ function ji(a) {
|
|
|
5283
5283
|
preview: Ce(ye(a.preview), 140)
|
|
5284
5284
|
};
|
|
5285
5285
|
}
|
|
5286
|
-
function
|
|
5286
|
+
function qi(a) {
|
|
5287
5287
|
return {
|
|
5288
5288
|
...a,
|
|
5289
5289
|
title: Ce(ye(a.title), 72) || "New chat",
|
|
5290
5290
|
preview: Ce(ye(a.preview), 140)
|
|
5291
5291
|
};
|
|
5292
5292
|
}
|
|
5293
|
-
var
|
|
5293
|
+
var Vi = class {
|
|
5294
5294
|
constructor(a, e, t = typeof window < "u" ? window.localStorage : null) {
|
|
5295
5295
|
this._appId = a, this._userId = e, this._storage = t, this._scope = Hi(a, e);
|
|
5296
5296
|
}
|
|
@@ -5306,7 +5306,7 @@ var qi = class {
|
|
|
5306
5306
|
}
|
|
5307
5307
|
loadSession(a) {
|
|
5308
5308
|
const e = Ot(this._storage?.getItem(Fe(this._scope, a)) ?? null);
|
|
5309
|
-
return !e || e.version !== Dt ? null :
|
|
5309
|
+
return !e || e.version !== Dt ? null : qi(e);
|
|
5310
5310
|
}
|
|
5311
5311
|
saveSession(a) {
|
|
5312
5312
|
if (!this._storage) return null;
|
|
@@ -5453,7 +5453,7 @@ var qi = class {
|
|
|
5453
5453
|
await e();
|
|
5454
5454
|
} catch {
|
|
5455
5455
|
}
|
|
5456
|
-
t?.send("openURLInNewTab", { url: a }),
|
|
5456
|
+
t?.send("openURLInNewTab", { url: a }), me(a) && n(a);
|
|
5457
5457
|
}
|
|
5458
5458
|
async loadPayload(a, e) {
|
|
5459
5459
|
if (!this._db) return null;
|
|
@@ -5651,7 +5651,7 @@ var ro = ':where(:root,.gengage-chat-root,.gengage-qna-container,.gengage-simrel
|
|
|
5651
5651
|
"launchSingleProduct",
|
|
5652
5652
|
"launchProductList",
|
|
5653
5653
|
"launchHomepage"
|
|
5654
|
-
]),
|
|
5654
|
+
]), qt = /* @__PURE__ */ new Set(["PanelRestoreCard"]), oo = /* @__PURE__ */ new Set(["ComparisonTable", "ProductDetailsPanel"]);
|
|
5655
5655
|
function so(a) {
|
|
5656
5656
|
const e = a?.type;
|
|
5657
5657
|
if (e) {
|
|
@@ -5665,7 +5665,7 @@ function co(a) {
|
|
|
5665
5665
|
const e = document.createElement("template");
|
|
5666
5666
|
return e.innerHTML = pe(a), (e.content.textContent ?? "").trim().length > 0;
|
|
5667
5667
|
}
|
|
5668
|
-
function
|
|
5668
|
+
function Vt(a) {
|
|
5669
5669
|
return a.length > 120 ? !1 : /^[a-zA-Z0-9#(),.\s%/\-]+$/.test(a);
|
|
5670
5670
|
}
|
|
5671
5671
|
function nt(a) {
|
|
@@ -5684,7 +5684,7 @@ var lo = class Te extends Oa {
|
|
|
5684
5684
|
if (!this._hostScrollLockActive || !this._hostScrollLockViewport || this._hostScrollPinning || this._isMobileViewport && window.visualViewport && window.visualViewport.height < window.innerHeight) return;
|
|
5685
5685
|
const t = this._hostScrollLockViewport;
|
|
5686
5686
|
window.scrollX === t.x && window.scrollY === t.y || (this._hostScrollPinning = !0, window.scrollTo(t.x, t.y), this._hostScrollPinning = !1);
|
|
5687
|
-
}, this._messages = [], this._currentMessageId = 0, this._abortControllers = /* @__PURE__ */ new Set(), this._currentThreadId = null, this._lastThreadId = null, this._chatCreatedAt = "", this._lastBackendContext = null, this._productSort = { type: "related" }, this._comparisonSelectMode = !1, this._comparisonSelectedSkus = [], this._comparisonSelectionWarning = null, this._comparisonRefreshRafId = null, this._lastAppliedKeyboardInset = 0, this._syncVisualVh = null, this._viewedProductSkus = /* @__PURE__ */ new Set(), this._panelAiSpecByThread = /* @__PURE__ */ new Map(), this._choicePrompterEl = null, this._openState = "full", this._mobileBreakpoint = 768, this._isMobileViewport = !1, this._gaPrevMainPaneExpanded = !1, this._pdpLaunched = !1, this._plpLaunched = !1, this._homepageLaunched = !1, this._entryContextPrimed = !1, this._contextPrimingInFlight = !1, this._queuedUserMessages = [], this._productContextUnavailableSku = null, this._i18n = Be, this._extendedModeManager = null, this._activeTypewriter = null, this._activeTtsHandle = null, this._activeRequestThreadId = null, this._skuToProductItem = {}, this._conversationMode = null, this._initComplete = !1, this._pendingActions = [], this._bridgeContext = null, this._cartQuantity = null, this._threadsWithFirstBot = /* @__PURE__ */ new Set(), this._panel = null, this._localPanelHistory = [], this._currentPanelSource = null, this._currentInlineProductSummaryRecord = null, this._session = null, this._historyStorage = null, this._activeHistorySessionId = null, this._presentation = new Gi(), this._eventCallbacks = /* @__PURE__ */ new Map(), this._lastSentAction = null, this._consecutiveErrorCount = 0, this._lastErrorMessage = "", this._launcherAnchorCleanup = null, this._modeController = new Ln(), this._syncLauncherAnchor = null;
|
|
5687
|
+
}, this._messages = [], this._currentMessageId = 0, this._abortControllers = /* @__PURE__ */ new Set(), this._currentThreadId = null, this._lastThreadId = null, this._chatCreatedAt = "", this._lastBackendContext = null, this._productSort = { type: "related" }, this._comparisonSelectMode = !1, this._comparisonSelectedSkus = [], this._comparisonSelectionWarning = null, this._comparisonRefreshRafId = null, this._lastAppliedKeyboardInset = 0, this._syncVisualVh = null, this._viewedProductSkus = /* @__PURE__ */ new Set(), this._panelAiSpecByThread = /* @__PURE__ */ new Map(), this._choicePrompterEl = null, this._openState = "full", this._mobileBreakpoint = 768, this._isMobileViewport = !1, this._gaPrevMainPaneExpanded = !1, this._pdpLaunched = !1, this._plpLaunched = !1, this._homepageLaunched = !1, this._entryContextPrimed = !1, this._contextPrimingInFlight = !1, this._queuedUserMessages = [], this._productContextUnavailableSku = null, this._i18n = Be, this._extendedModeManager = null, this._activeTypewriter = null, this._activeTtsHandle = null, this._activeRequestThreadId = null, this._skuToProductItem = {}, this._conversationMode = null, this._initComplete = !1, this._pendingActions = [], this._bridgeContext = null, this._cartQuantity = null, this._threadsWithFirstBot = /* @__PURE__ */ new Set(), this._panel = null, this._localPanelHistory = [], this._currentPanelSource = null, this._currentInlineProductSummaryRecord = null, this._session = null, this._historyStorage = null, this._activeHistorySessionId = null, this._presentation = new Gi(), this._presentationScrollTimerIds = /* @__PURE__ */ new Set(), this._eventCallbacks = /* @__PURE__ */ new Map(), this._pendingAddToCartKeys = /* @__PURE__ */ new Set(), this._lastSentAction = null, this._consecutiveErrorCount = 0, this._lastErrorMessage = "", this._launcherAnchorCleanup = null, this._modeController = new Ln(), this._syncLauncherAnchor = null;
|
|
5688
5688
|
}
|
|
5689
5689
|
static {
|
|
5690
5690
|
this._MAX_COMPARISON_SELECTION = 5;
|
|
@@ -5713,7 +5713,7 @@ var lo = class Te extends Oa {
|
|
|
5713
5713
|
const t = document.createElement("style");
|
|
5714
5714
|
t.textContent = ro, this._shadow.appendChild(t);
|
|
5715
5715
|
const n = this.root, r = (m, g) => {
|
|
5716
|
-
g &&
|
|
5716
|
+
g && Vt(g) && n.style.setProperty(m, g);
|
|
5717
5717
|
};
|
|
5718
5718
|
if (r("--gengage-chat-header-bg", e.headerBg), r("--gengage-chat-header-foreground", e.headerForeground), e.theme)
|
|
5719
5719
|
for (const [m, g] of Object.entries(e.theme)) m.startsWith("--") && typeof g == "string" && r(m, g);
|
|
@@ -5830,7 +5830,7 @@ var lo = class Te extends Oa {
|
|
|
5830
5830
|
const c = this._drawer.restorePanelState(e.accountId), l = e.panelMode ?? "auto";
|
|
5831
5831
|
l === "collapsed" ? this._drawer.setPanelCollapsed(!0) : l === "expanded" && this._drawer.setForceExpanded();
|
|
5832
5832
|
const p = sessionStorage.getItem("gengage_restore_session_id"), d = sessionStorage.getItem("gengage_restore_sku"), h = sessionStorage.getItem("gengage_restore_history_id"), u = !!(p && d);
|
|
5833
|
-
u && (sessionStorage.removeItem("gengage_restore_session_id"), sessionStorage.removeItem("gengage_restore_sku")), h && sessionStorage.removeItem("gengage_restore_history_id"), this._historyStorage = new
|
|
5833
|
+
u && (sessionStorage.removeItem("gengage_restore_session_id"), sessionStorage.removeItem("gengage_restore_sku")), h && sessionStorage.removeItem("gengage_restore_history_id"), this._historyStorage = new Vi(this.config.accountId, this.config.session?.userId ?? "");
|
|
5834
5834
|
try {
|
|
5835
5835
|
const m = new Li();
|
|
5836
5836
|
await m.open(), this._session = new Ut(m);
|
|
@@ -5868,7 +5868,7 @@ var lo = class Te extends Oa {
|
|
|
5868
5868
|
};
|
|
5869
5869
|
e.allowedOrigins !== void 0 && (f.allowedOrigins = e.allowedOrigins), this._bridge = new $a(f), this._lastSku = this.config.pageContext?.sku, this._lastPageType = this.config.pageContext?.pageType, this._lastSkuListKey = this.config.pageContext?.skuList?.slice(0, 48).join(","), this._initComplete = !0;
|
|
5870
5870
|
for (const m of this._pendingActions) this._sendAction(m.action, m.options);
|
|
5871
|
-
this._pendingActions = [], this._pillLauncherApply && o === "floating" && (await this._pillLauncherApply(), this._pillLauncherApply = null),
|
|
5871
|
+
this._pendingActions = [], this._pillLauncherApply && o === "floating" && (await this._pillLauncherApply(), this._pillLauncherApply = null), xe("gengage:chat:ready", {}), Fa("chat"), e.onReady?.();
|
|
5872
5872
|
}
|
|
5873
5873
|
onUpdate(e) {
|
|
5874
5874
|
if (this.config.pageContext && e.pageType !== void 0) {
|
|
@@ -5886,7 +5886,7 @@ var lo = class Te extends Oa {
|
|
|
5886
5886
|
t && this._resetForNewPage();
|
|
5887
5887
|
}
|
|
5888
5888
|
onShow() {
|
|
5889
|
-
this._showDrawer(), this.emit("open"),
|
|
5889
|
+
this._showDrawer(), this.emit("open"), xe("gengage:chat:open", { state: this._openState }), Sa("chat"), this.config.onOpen?.(), this._showWelcomeIfNeeded(), this._maybePrimeEntryContextOpening(), !this._pdpLaunched && this.config.pageContext?.pageType === "pdp" && this.config.pageContext?.sku && (this._pdpLaunched = !0, this._contextPrimingInFlight = !0, this._sendAction({
|
|
5890
5890
|
title: "",
|
|
5891
5891
|
type: "launchSingleProduct",
|
|
5892
5892
|
payload: {
|
|
@@ -5917,7 +5917,7 @@ var lo = class Te extends Oa {
|
|
|
5917
5917
|
}));
|
|
5918
5918
|
}
|
|
5919
5919
|
onHide() {
|
|
5920
|
-
(this.config.variant ?? "floating") === "floating" && (this.root.style.display = ""), this._hideDrawer(), this.emit("close"),
|
|
5920
|
+
(this.config.variant ?? "floating") === "floating" && (this.root.style.display = ""), this._hideDrawer(), this.emit("close"), xe("gengage:chat:close", {}), this.config.onClose?.();
|
|
5921
5921
|
}
|
|
5922
5922
|
_setupLauncherAnchor(e) {
|
|
5923
5923
|
const t = e.launcherAnchor;
|
|
@@ -6003,7 +6003,7 @@ var lo = class Te extends Oa {
|
|
|
6003
6003
|
this._syncLauncherAnchor?.();
|
|
6004
6004
|
}
|
|
6005
6005
|
onDestroy() {
|
|
6006
|
-
this._releaseHostDocumentScrollLock(), this._abortAllActiveRequests(), this._activeTypewriter?.cancel(), this._activeTypewriter = null, this._activeTtsHandle?.stop(), this._activeTtsHandle = null, this._comparisonRefreshRafId !== null && (cancelAnimationFrame(this._comparisonRefreshRafId), this._comparisonRefreshRafId = null), this._launcherAnchorCleanup?.(), this._launcherAnchorCleanup = null, this._syncLauncherAnchor = null, this._floatingLauncher?.destroy(), this._floatingLauncher = null, this._drawer?.destroy(), on(), this._drawer = null, this._bridge?.destroy(), this._bridge = null, this._extendedModeManager = null, this._panel?.destroy(), this._panel = null, this._session?.close(), this._session = null, this._historyStorage = null, this._activeHistorySessionId = null, this._localPanelHistory = [], this._currentPanelSource = null, window.gengage && delete window.gengage.chat, this._shadow && (this._shadow.innerHTML = "", this._shadow = null), this._rootEl = null;
|
|
6006
|
+
this._releaseHostDocumentScrollLock(), this._abortAllActiveRequests(), this._activeTypewriter?.cancel(), this._activeTypewriter = null, this._presentationScrollTimerIds.forEach((e) => clearTimeout(e)), this._presentationScrollTimerIds.clear(), this._activeTtsHandle?.stop(), this._activeTtsHandle = null, this._comparisonRefreshRafId !== null && (cancelAnimationFrame(this._comparisonRefreshRafId), this._comparisonRefreshRafId = null), this._launcherAnchorCleanup?.(), this._launcherAnchorCleanup = null, this._syncLauncherAnchor = null, this._floatingLauncher?.destroy(), this._floatingLauncher = null, this._drawer?.destroy(), on(), this._drawer = null, this._bridge?.destroy(), this._bridge = null, this._extendedModeManager = null, this._panel?.destroy(), this._panel = null, this._session?.close(), this._session = null, this._historyStorage = null, this._activeHistorySessionId = null, this._localPanelHistory = [], this._currentPanelSource = null, window.gengage && delete window.gengage.chat, this._shadow && (this._shadow.innerHTML = "", this._shadow = null), this._rootEl = null;
|
|
6007
6007
|
}
|
|
6008
6008
|
open(e) {
|
|
6009
6009
|
e?.state !== void 0 && (this._openState = e.state, this._drawerVisible && this._applyOpenStateClasses()), this.show(), e?.initialMessage !== void 0 && this._sendMessage(e.initialMessage);
|
|
@@ -6073,8 +6073,14 @@ var lo = class Te extends Oa {
|
|
|
6073
6073
|
let t = !1;
|
|
6074
6074
|
e.type === "thread" && e.threadId ? (t = this._drawer.scrollThreadIntoView(e.threadId, e.behavior), t || (this._drawer.scrollToBottomPresentation(e.behavior), t = !0)) : e.type === "bottom" && (this._drawer.scrollToBottomPresentation(e.behavior), t = !0), t && this._presentation.consumeScrollRequest(e.id);
|
|
6075
6075
|
}
|
|
6076
|
+
_schedulePresentationScrollFlush() {
|
|
6077
|
+
const e = setTimeout(() => {
|
|
6078
|
+
this._presentationScrollTimerIds.delete(e), this._flushPresentationScroll();
|
|
6079
|
+
}, 40);
|
|
6080
|
+
this._presentationScrollTimerIds.add(e);
|
|
6081
|
+
}
|
|
6076
6082
|
_focusPresentationThread(e, t = "smooth", n = !1) {
|
|
6077
|
-
this._presentation.requestThreadFocus(e, t), n && this._drawer?.setPresentationFocus(e), this._drawer?.setFormerMessagesButtonVisible(!1),
|
|
6083
|
+
this._presentation.requestThreadFocus(e, t), n && this._drawer?.setPresentationFocus(e), this._drawer?.setFormerMessagesButtonVisible(!1), this._schedulePresentationScrollFlush();
|
|
6078
6084
|
}
|
|
6079
6085
|
_scrollInlineIntoView(e, t) {
|
|
6080
6086
|
if (t) {
|
|
@@ -6140,7 +6146,7 @@ var lo = class Te extends Oa {
|
|
|
6140
6146
|
break;
|
|
6141
6147
|
}
|
|
6142
6148
|
case "scrollToBottom":
|
|
6143
|
-
this._presentation.requestScrollToBottom("smooth"),
|
|
6149
|
+
this._presentation.requestScrollToBottom("smooth"), this._schedulePresentationScrollFlush();
|
|
6144
6150
|
break;
|
|
6145
6151
|
case "addToCardHandler":
|
|
6146
6152
|
this._bridge?.send("addToCardResult", e.payload);
|
|
@@ -6160,7 +6166,7 @@ var lo = class Te extends Oa {
|
|
|
6160
6166
|
break;
|
|
6161
6167
|
case "bgColorChange": {
|
|
6162
6168
|
const t = e.payload?.color;
|
|
6163
|
-
typeof t == "string" &&
|
|
6169
|
+
typeof t == "string" && Vt(t) && this._shadow && this._shadow.host.style.setProperty("--gengage-chat-bg", t);
|
|
6164
6170
|
break;
|
|
6165
6171
|
}
|
|
6166
6172
|
default:
|
|
@@ -6413,7 +6419,7 @@ var lo = class Te extends Oa {
|
|
|
6413
6419
|
_handleAttachment(e) {
|
|
6414
6420
|
const t = Za(e);
|
|
6415
6421
|
if (!t.ok) {
|
|
6416
|
-
|
|
6422
|
+
xe("gengage:global:error", {
|
|
6417
6423
|
message: t.reason === "invalid_type" ? this._i18n.invalidFileType : this._i18n.fileTooLarge,
|
|
6418
6424
|
source: "chat"
|
|
6419
6425
|
});
|
|
@@ -6570,7 +6576,7 @@ var lo = class Te extends Oa {
|
|
|
6570
6576
|
}
|
|
6571
6577
|
Z ? this._drawer.setPanelAiZoneState("hidden") : this._drawer.setPanelAiZoneState("analyzing", { analyzingLabel: this._i18n.aiAnalysisAnalyzingLabel });
|
|
6572
6578
|
}
|
|
6573
|
-
},
|
|
6579
|
+
}, q = (v) => {
|
|
6574
6580
|
if (!b || !this._drawer) return;
|
|
6575
6581
|
const P = this._buildRenderContext();
|
|
6576
6582
|
P.isStreaming = v;
|
|
@@ -6578,11 +6584,11 @@ var lo = class Te extends Oa {
|
|
|
6578
6584
|
j = !0, this._drawer.setPanelAiZoneState("results", { resultEl: T }), b = null;
|
|
6579
6585
|
}, D = (v, P, T) => {
|
|
6580
6586
|
if (v === "ProductGrid" || v === "CategoriesContainer") {
|
|
6581
|
-
B = !0,
|
|
6587
|
+
B = !0, q(T), F();
|
|
6582
6588
|
return;
|
|
6583
6589
|
}
|
|
6584
6590
|
P !== "appendSimilars" && P !== "append" && (B = !1, j = !1, b = null, this._drawer?.setPanelAiZoneState("hidden"));
|
|
6585
|
-
}, K = (v) => (v === "ProductGrid" || v === "CategoriesContainer") && (B || j || b !== null),
|
|
6591
|
+
}, K = (v) => (v === "ProductGrid" || v === "CategoriesContainer") && (B || j || b !== null), V = () => {
|
|
6586
6592
|
L || (L = !0, this._drawer?.removeTypingIndicator(), r(!1), this._bridge?.send("loadingMessage", { text: null }));
|
|
6587
6593
|
}, Q = (v, P, T) => {
|
|
6588
6594
|
if (!this._drawer || !this._panel) return;
|
|
@@ -6613,7 +6619,7 @@ var lo = class Te extends Oa {
|
|
|
6613
6619
|
let U = null;
|
|
6614
6620
|
if (U = en(I, {
|
|
6615
6621
|
onTextChunk: (v, P, T) => {
|
|
6616
|
-
if (!o && i !== this._activeRequestThreadId || (m += v, co(m) &&
|
|
6622
|
+
if (!o && i !== this._activeRequestThreadId || (m += v, co(m) && V(), T?.skuToProductItem && (this._skuToProductItem = {
|
|
6617
6623
|
...this._skuToProductItem,
|
|
6618
6624
|
...T.skuToProductItem
|
|
6619
6625
|
}), T?.conversationMode && (this._conversationMode = T.conversationMode), T?.renderHint && (g.renderHint = T.renderHint), !this._drawer)) return;
|
|
@@ -6695,7 +6701,7 @@ var lo = class Te extends Oa {
|
|
|
6695
6701
|
}
|
|
6696
6702
|
z.isConsulting && (E = null);
|
|
6697
6703
|
}
|
|
6698
|
-
if (so(N) &&
|
|
6704
|
+
if (so(N) && V(), ee === "panel" && this._panel && !te) {
|
|
6699
6705
|
const z = !k;
|
|
6700
6706
|
k = !0;
|
|
6701
6707
|
const Y = N?.props?.replacePanel === !0, X = N?.props?.rankingState, W = Y || X === "pending" || X === "final" ? "replace" : Mi({
|
|
@@ -6757,8 +6763,8 @@ var lo = class Te extends Oa {
|
|
|
6757
6763
|
const z = (H === "ProductGrid" ? (N?.children ?? []).map((Y) => v.elements[Y]?.props?.product).filter(Boolean) : [N?.props?.product ?? N?.props].filter(Boolean)).map((Y) => Y.imageUrl).filter((Y) => typeof Y == "string").slice(0, 5);
|
|
6758
6764
|
z.length > 0 && this._bridge?.send("previewImages", { images: z });
|
|
6759
6765
|
}
|
|
6760
|
-
const
|
|
6761
|
-
if (H === "ProductGrid" && ee === "panel" && !te &&
|
|
6766
|
+
const fe = N?.children?.length ?? 0;
|
|
6767
|
+
if (H === "ProductGrid" && ee === "panel" && !te && fe > 1 && !this._isMobileViewport && !this._modeController.isChoicePrompterHidden && !this._comparisonSelectMode && !Ci(this._currentThreadId ?? "") && (this._clearChoicePrompter(), this._choicePrompterEl = ki({
|
|
6762
6768
|
heading: this._i18n.choicePrompterHeading,
|
|
6763
6769
|
suggestion: this._i18n.choicePrompterSuggestion,
|
|
6764
6770
|
ctaLabel: this._i18n.choicePrompterCta,
|
|
@@ -6799,17 +6805,17 @@ var lo = class Te extends Oa {
|
|
|
6799
6805
|
onAction: (v) => {
|
|
6800
6806
|
if (!(!o && i !== this._activeRequestThreadId) && v.type === "action") {
|
|
6801
6807
|
const P = {};
|
|
6802
|
-
this.config.actionHandling?.unknownActionPolicy !== void 0 && (P.unknownActionPolicy = this.config.actionHandling.unknownActionPolicy), this.config.actionHandling?.allowScriptCall !== void 0 && (P.allowScriptCall = this.config.actionHandling.allowScriptCall),
|
|
6808
|
+
this.config.actionHandling?.unknownActionPolicy !== void 0 && (P.unknownActionPolicy = this.config.actionHandling.unknownActionPolicy), this.config.actionHandling?.allowScriptCall !== void 0 && (P.allowScriptCall = this.config.actionHandling.allowScriptCall), qa(v, {
|
|
6803
6809
|
openChat: () => this.open(),
|
|
6804
6810
|
navigate: (T) => {
|
|
6805
|
-
|
|
6811
|
+
me(T.url) && (this._bridge?.send("navigate", T), T.newTab ? window.open(T.url, "_blank", "noopener,noreferrer") : window.location.href = T.url);
|
|
6806
6812
|
},
|
|
6807
6813
|
saveSession: (T) => this.saveSession(T.sessionId, T.sku),
|
|
6808
6814
|
addToCart: (T) => {
|
|
6809
|
-
|
|
6815
|
+
this._runChatAddToCartFlow(T);
|
|
6810
6816
|
},
|
|
6811
6817
|
scriptCall: (T) => {
|
|
6812
|
-
|
|
6818
|
+
xe("gengage:chat:script-call", T), this.config.onScriptCall?.(T);
|
|
6813
6819
|
}
|
|
6814
6820
|
}, P);
|
|
6815
6821
|
}
|
|
@@ -6836,7 +6842,7 @@ var lo = class Te extends Oa {
|
|
|
6836
6842
|
O.audio_base64 && (this._activeTtsHandle?.stop(), this._activeTtsHandle = pi(O.audio_base64, O.content_type ?? "audio/ogg"));
|
|
6837
6843
|
}
|
|
6838
6844
|
}
|
|
6839
|
-
if ((v.meta.redirectTarget || v.meta.redirect) && (
|
|
6845
|
+
if ((v.meta.redirectTarget || v.meta.redirect) && (xe("gengage:chat:redirect", {
|
|
6840
6846
|
target: v.meta.redirectTarget ?? null,
|
|
6841
6847
|
payload: v.meta.redirect ?? null
|
|
6842
6848
|
}), Ne("redirect", "redirect dispatched", { target: v.meta.redirectTarget ?? null }), this._handleRedirectMetadata(v.meta.redirect)), v.meta.analyzeAnimation && this.config.productDetailsExtended === !0 && (w = !0, k = !1, x(), this._panel && (this._panel.currentType = null), this._drawer?.showPanelLoading(), this._panel?.updateTopBarForLoading("productDetails")), v.meta.loading) {
|
|
@@ -6850,7 +6856,7 @@ var lo = class Te extends Oa {
|
|
|
6850
6856
|
v.meta.visitorDataResponse && this._bridge?.send("engagingMessage", v.meta.visitorDataResponse), v.meta.formType && this._bridge?.send("glovForm", {
|
|
6851
6857
|
type: v.meta.formType,
|
|
6852
6858
|
data: v.meta.formPayload
|
|
6853
|
-
}), v.meta.launcherContent && this._bridge?.send("launcherContent", v.meta.launcherContent),
|
|
6859
|
+
}), v.meta.launcherContent && this._bridge?.send("launcherContent", v.meta.launcherContent), xe("gengage:chat:metadata", { payload: v.meta });
|
|
6854
6860
|
}
|
|
6855
6861
|
},
|
|
6856
6862
|
onError: (v) => {
|
|
@@ -6922,7 +6928,7 @@ var lo = class Te extends Oa {
|
|
|
6922
6928
|
const G = N?.type ?? "ProductGrid";
|
|
6923
6929
|
Q(H, O, G), R(G, N, "replace", !1), k = !0;
|
|
6924
6930
|
}
|
|
6925
|
-
E = null, b &&
|
|
6931
|
+
E = null, b && q(!1), F(), this._activeRequestThreadId = null, this._consecutiveErrorCount = 0, this._lastErrorMessage = "", r(!1), this._bridge?.send("loadingMessage", { text: null }), this._drawer?.removeTypingIndicator(), Mn(S, {
|
|
6926
6932
|
drawer: this._drawer,
|
|
6927
6933
|
ensureRendered: () => {
|
|
6928
6934
|
},
|
|
@@ -7022,7 +7028,7 @@ var lo = class Te extends Oa {
|
|
|
7022
7028
|
const t = e?.uiSpec;
|
|
7023
7029
|
if (!t) return null;
|
|
7024
7030
|
const n = t.elements[t.root];
|
|
7025
|
-
return !n ||
|
|
7031
|
+
return !n || qt.has(n.type) ? null : {
|
|
7026
7032
|
kind: "spec",
|
|
7027
7033
|
spec: t
|
|
7028
7034
|
};
|
|
@@ -7591,29 +7597,46 @@ var lo = class Te extends Oa {
|
|
|
7591
7597
|
quantity: 1
|
|
7592
7598
|
};
|
|
7593
7599
|
}
|
|
7594
|
-
|
|
7595
|
-
|
|
7596
|
-
|
|
7597
|
-
|
|
7598
|
-
|
|
7599
|
-
|
|
7600
|
-
|
|
7601
|
-
|
|
7602
|
-
|
|
7600
|
+
_hasAddToCartConfirmationHandler() {
|
|
7601
|
+
return this.config.onAddToCart !== void 0 || (this._eventCallbacks.get("gengage-cart-add")?.size ?? 0) > 0;
|
|
7602
|
+
}
|
|
7603
|
+
_addToCartRequestKey(e) {
|
|
7604
|
+
return `${e.sku}\0${e.cartCode}\0${e.quantity}`;
|
|
7605
|
+
}
|
|
7606
|
+
async _runChatAddToCartFlow(e) {
|
|
7607
|
+
const t = this._addToCartRequestKey(e);
|
|
7608
|
+
if (this._pendingAddToCartKeys.has(t)) return;
|
|
7609
|
+
this._pendingAddToCartKeys.add(t);
|
|
7610
|
+
const n = {
|
|
7603
7611
|
...e,
|
|
7604
7612
|
sessionId: this.config.session?.sessionId ?? null
|
|
7605
7613
|
};
|
|
7606
|
-
|
|
7607
|
-
|
|
7608
|
-
|
|
7609
|
-
|
|
7610
|
-
|
|
7611
|
-
|
|
7612
|
-
|
|
7614
|
+
try {
|
|
7615
|
+
if (!this._hasAddToCartConfirmationHandler()) {
|
|
7616
|
+
this._handleCallbackFailure("gengage-cart-add", n);
|
|
7617
|
+
return;
|
|
7618
|
+
}
|
|
7619
|
+
if (this.config.onAddToCart !== void 0) try {
|
|
7620
|
+
await Promise.resolve(this.config.onAddToCart(e));
|
|
7621
|
+
} catch (i) {
|
|
7622
|
+
console.error("[gengage] onAddToCart", i), this._handleCallbackFailure("gengage-cart-add", n);
|
|
7623
|
+
return;
|
|
7613
7624
|
}
|
|
7614
|
-
|
|
7615
|
-
|
|
7616
|
-
|
|
7625
|
+
if (!await this._runEventCallbacks("gengage-cart-add", n)) return;
|
|
7626
|
+
Ba(e.sku, e.quantity), xe("gengage:chat:add-to-cart", n), this._bridge?.send("addToCart", e), this._sendAction({
|
|
7627
|
+
title: this._i18n.addToCartButton ?? "Add to Cart",
|
|
7628
|
+
type: "addToCart",
|
|
7629
|
+
payload: {
|
|
7630
|
+
sku: e.sku,
|
|
7631
|
+
cart_code: e.cartCode,
|
|
7632
|
+
quantity: e.quantity
|
|
7633
|
+
}
|
|
7634
|
+
}, { preservePanel: !0 });
|
|
7635
|
+
const r = this._i18n.addedToCartToast ?? "Added to cart";
|
|
7636
|
+
this._drawer?.showCartToast(r), this._drawer?.flashCartBadge();
|
|
7637
|
+
} finally {
|
|
7638
|
+
this._pendingAddToCartKeys.delete(t);
|
|
7639
|
+
}
|
|
7617
7640
|
}
|
|
7618
7641
|
_buildRenderContext() {
|
|
7619
7642
|
const e = {
|
|
@@ -7654,7 +7677,7 @@ var lo = class Te extends Oa {
|
|
|
7654
7677
|
if (r && i && r === i) return;
|
|
7655
7678
|
}
|
|
7656
7679
|
if (n)
|
|
7657
|
-
|
|
7680
|
+
xe("gengage:similar:product-click", {
|
|
7658
7681
|
sku: t.sku,
|
|
7659
7682
|
url: t.url,
|
|
7660
7683
|
sessionId: this.config.session?.sessionId ?? null,
|
|
@@ -7757,7 +7780,7 @@ var lo = class Te extends Oa {
|
|
|
7757
7780
|
favorited: n,
|
|
7758
7781
|
sessionId: this.config.session?.sessionId ?? null
|
|
7759
7782
|
};
|
|
7760
|
-
|
|
7783
|
+
xe("gengage:chat:product-favorite", r), this._bridge?.send("productFavorite", r);
|
|
7761
7784
|
const i = this._eventCallbacks.get("gengage-product-favorite");
|
|
7762
7785
|
if (i && i.size > 0) {
|
|
7763
7786
|
for (const o of i) try {
|
|
@@ -7831,7 +7854,7 @@ var lo = class Te extends Oa {
|
|
|
7831
7854
|
_isMessageHostedUISpec(e) {
|
|
7832
7855
|
if (!e) return !1;
|
|
7833
7856
|
const t = e.elements[e.root];
|
|
7834
|
-
return !!t &&
|
|
7857
|
+
return !!t && qt.has(t.type);
|
|
7835
7858
|
}
|
|
7836
7859
|
_isPanelAiSpec(e) {
|
|
7837
7860
|
if (!e) return !1;
|
|
@@ -7921,17 +7944,14 @@ var lo = class Te extends Oa {
|
|
|
7921
7944
|
}
|
|
7922
7945
|
async _runEventCallbacks(e, t) {
|
|
7923
7946
|
const n = this._eventCallbacks.get(e);
|
|
7924
|
-
if (!
|
|
7925
|
-
|
|
7926
|
-
|
|
7927
|
-
|
|
7928
|
-
|
|
7929
|
-
|
|
7930
|
-
|
|
7931
|
-
|
|
7932
|
-
this._handleCallbackFailure(e, t);
|
|
7933
|
-
return;
|
|
7934
|
-
}
|
|
7947
|
+
if (!n || n.size === 0) return !0;
|
|
7948
|
+
for (const r of n) try {
|
|
7949
|
+
if (await Promise.resolve(r(t)) === !1)
|
|
7950
|
+
return this._handleCallbackFailure(e, t), !1;
|
|
7951
|
+
} catch {
|
|
7952
|
+
return this._handleCallbackFailure(e, t), !1;
|
|
7953
|
+
}
|
|
7954
|
+
return !0;
|
|
7935
7955
|
}
|
|
7936
7956
|
_handleCallbackFailure(e, t) {
|
|
7937
7957
|
if (e === "gengage-cart-add") {
|