@gengage/assistant-fe 0.4.21 → 0.5.0
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/README.md +1 -1
- package/dist/{api-paths-Bg6iwO5w.js → api-paths-y5nkfEBG.js} +1 -1
- package/dist/chat-runtime.js +1 -1
- package/dist/chat.iife.js +43 -43
- package/dist/chat.js +1 -1
- package/dist/common-BKPSOoIP.js +324 -0
- package/dist/common.js +64 -81
- package/dist/{connection-warning-BeD-B0Ec.js → connection-warning-DJiyLM46.js} +1 -1
- package/dist/{fastIntent-BeeDIwd2.js → fastIntent-1T2g9art.js} +2 -2
- package/dist/index.js +49 -52
- package/dist/{native-webview-Bbcvvi_5.js → native-webview-y3a9R9hH.js} +1 -1
- package/dist/native.iife.js +23 -23
- package/dist/native.js +1 -1
- package/dist/{overlay-O4nlUrzw.js → overlay-v3nvcGlE.js} +2 -5
- package/dist/overlay.js +2 -2
- package/dist/qna-runtime.js +1 -1
- package/dist/qna.iife.js +36 -36
- package/dist/qna.js +1 -1
- package/dist/{runtime-C8ZBidd2.js → runtime-BMNOS2Mq.js} +176 -196
- package/dist/runtime-DOS9yRRx.js +650 -0
- package/dist/{runtime-Ct1qOl8V.js → runtime-DsP6go8z.js} +2194 -2225
- package/dist/{simbut-BrAeZ6SH.js → simbut-BwxzoBcY.js} +7 -7
- package/dist/simbut.iife.js +12 -12
- package/dist/simbut.js +1 -1
- package/dist/{simrel-Cha5de6P.js → simrel-C07wZN8Q.js} +2 -2
- package/dist/simrel-runtime.js +1 -1
- package/dist/simrel.iife.js +35 -35
- package/dist/simrel.js +2 -2
- package/dist/widget-base-Dliq3QAf.js +362 -0
- package/package.json +1 -2
- package/dist/common-DDJSeQhg.js +0 -491
- package/dist/runtime-CRSFPLku.js +0 -688
- package/dist/widget-base-BtBl_PCR.js +0 -589
- /package/dist/{context-DGz5F81j.js → context-BBuSsXZ9.js} +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { d as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { t as
|
|
5
|
-
import { n as
|
|
6
|
-
async function
|
|
7
|
-
const o =
|
|
1
|
+
import { d as x, h as Q, p as R, r as N, t as H } from "./api-paths-y5nkfEBG.js";
|
|
2
|
+
import { A as O, D as U, E as j, a as q, v as M } from "./context-BBuSsXZ9.js";
|
|
3
|
+
import { o as F, t as W } from "./widget-base-Dliq3QAf.js";
|
|
4
|
+
import { t as A } from "./locale-CfqNifrU.js";
|
|
5
|
+
import { n as D } from "./connection-warning-DJiyLM46.js";
|
|
6
|
+
async function z(e, t, n) {
|
|
7
|
+
const o = H("launcher_action", t), i = {
|
|
8
8
|
uiSpecs: [],
|
|
9
9
|
actions: []
|
|
10
10
|
}, a = {
|
|
@@ -15,18 +15,18 @@ async function Z(e, t, n) {
|
|
|
15
15
|
n !== void 0 && (a.signal = n);
|
|
16
16
|
const l = await fetch(o, a);
|
|
17
17
|
if (!l.ok) throw new Error(`HTTP ${l.status}: ${l.statusText}`);
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
if (
|
|
21
|
-
for (const
|
|
22
|
-
const
|
|
23
|
-
i.actions.push(
|
|
18
|
+
const s = { onEvent: (c) => {
|
|
19
|
+
const r = N(c);
|
|
20
|
+
if (r && (r.type === "ui_spec" && i.uiSpecs.push(r.spec), r.type === "ui_spec" && r.spec.elements)) {
|
|
21
|
+
for (const u of Object.values(r.spec.elements)) if (u.type === "ActionButton" && u.props?.action) {
|
|
22
|
+
const m = u.props.action;
|
|
23
|
+
i.actions.push(m);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
} };
|
|
27
|
-
return n !== void 0 && (
|
|
27
|
+
return n !== void 0 && (s.signal = n), await x(l, s), i;
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function T(e) {
|
|
30
30
|
const t = document.createElement("div");
|
|
31
31
|
t.className = "gengage-qna-buttons gds-toolbar", t.dataset.gengagePart = "qna-button-row", t.setAttribute("role", "group"), t.setAttribute("aria-label", e.quickQuestionsAriaLabel ?? "Quick questions"), e.orientation === "vertical" && (t.style.flexDirection = "column");
|
|
32
32
|
for (const n of e.actions) {
|
|
@@ -47,7 +47,7 @@ function C(e) {
|
|
|
47
47
|
}
|
|
48
48
|
return t;
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function $(e) {
|
|
51
51
|
const t = document.createElement("div");
|
|
52
52
|
t.className = "gengage-qna-input-wrapper", t.dataset.gengagePart = "qna-input-wrapper";
|
|
53
53
|
const n = document.createElement("div");
|
|
@@ -57,115 +57,115 @@ function K(e) {
|
|
|
57
57
|
const i = Array.isArray(e.placeholders) ? e.placeholders : e.placeholders ? [e.placeholders] : [e.defaultInputPlaceholder ?? "Ask a question..."];
|
|
58
58
|
let a = 0, l = i[0] ?? "";
|
|
59
59
|
o.placeholder = l;
|
|
60
|
-
let
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
let s = null, c = null, r = !1;
|
|
61
|
+
const u = () => {
|
|
62
|
+
s && clearInterval(s), s = null, c && clearTimeout(c), c = null, o.classList.remove("gengage-qna-input--fade");
|
|
63
|
+
}, m = () => i.length > 1 && !r && o.value.trim().length === 0, g = () => {
|
|
64
|
+
u(), m() && (s = setInterval(() => {
|
|
65
|
+
m() && (o.classList.add("gengage-qna-input--fade"), c = setTimeout(() => {
|
|
66
66
|
a = (a + 1) % i.length, l = i[a] ?? "", o.placeholder = l, o.classList.remove("gengage-qna-input--fade");
|
|
67
67
|
}, 180));
|
|
68
68
|
}, 3e3));
|
|
69
|
-
},
|
|
70
|
-
|
|
69
|
+
}, h = document.createElement("div");
|
|
70
|
+
h.className = "gengage-qna-input-actions", h.dataset.gengagePart = "qna-input-actions";
|
|
71
|
+
const f = document.createElement("button");
|
|
72
|
+
f.className = "gengage-qna-icon-btn gengage-qna-clear gengage-qna-icon-btn--hidden", f.type = "button", f.dataset.gengagePart = "qna-clear", f.setAttribute("aria-label", "Clear question"), f.innerHTML = '<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M18 6L6 18" /><path d="M6 6L18 18" /></svg>';
|
|
71
73
|
const p = document.createElement("button");
|
|
72
|
-
p.className = "gengage-qna-icon-btn gengage-qna-
|
|
73
|
-
const u = document.createElement("button");
|
|
74
|
-
u.className = "gengage-qna-icon-btn gengage-qna-send gengage-qna-icon-btn--hidden", u.type = "button", u.dataset.gengagePart = "qna-send", u.setAttribute("aria-label", e.sendQuestionAriaLabel ?? "Send question"), u.disabled = !0, u.innerHTML = `<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M22 2L11 13" /><path d="M22 2L15 22L11 13L2 9L22 2Z" /></svg><span class="gengage-qna-sr-only">${e.ctaLabel ?? e.sendButtonText ?? "Ask"}</span>`;
|
|
74
|
+
p.className = "gengage-qna-icon-btn gengage-qna-send gengage-qna-icon-btn--hidden", p.type = "button", p.dataset.gengagePart = "qna-send", p.setAttribute("aria-label", e.sendQuestionAriaLabel ?? "Send question"), p.disabled = !0, p.innerHTML = `<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M22 2L11 13" /><path d="M22 2L15 22L11 13L2 9L22 2Z" /></svg><span class="gengage-qna-sr-only">${e.ctaLabel ?? e.sendButtonText ?? "Ask"}</span>`;
|
|
75
75
|
const y = () => {
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
},
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
title:
|
|
76
|
+
const d = o.value.trim().length > 0;
|
|
77
|
+
f.classList.toggle("gengage-qna-icon-btn--hidden", !d), p.classList.toggle("gengage-qna-icon-btn--hidden", !d), p.classList.toggle("gengage-qna-send--active", d), p.disabled = !d;
|
|
78
|
+
}, b = () => {
|
|
79
|
+
const d = o.value.trim();
|
|
80
|
+
d && (e.onSubmit({
|
|
81
|
+
title: d,
|
|
82
82
|
type: "user_message",
|
|
83
|
-
payload:
|
|
84
|
-
}), o.value = "", y(),
|
|
83
|
+
payload: d
|
|
84
|
+
}), o.value = "", y(), g());
|
|
85
85
|
};
|
|
86
|
-
return
|
|
86
|
+
return f.addEventListener("click", () => {
|
|
87
87
|
o.value = "", y(), o.focus({ preventScroll: !0 });
|
|
88
|
-
}),
|
|
89
|
-
|
|
88
|
+
}), p.addEventListener("click", b), o.addEventListener("focus", () => {
|
|
89
|
+
r = !0, u(), o.placeholder = "";
|
|
90
90
|
}), o.addEventListener("blur", () => {
|
|
91
|
-
|
|
91
|
+
r = !1, o.value.trim().length === 0 && (o.placeholder = l), g();
|
|
92
92
|
}), o.addEventListener("input", () => {
|
|
93
93
|
if (y(), o.value.trim().length > 0) {
|
|
94
|
-
|
|
94
|
+
u();
|
|
95
95
|
return;
|
|
96
96
|
}
|
|
97
|
-
o.placeholder =
|
|
98
|
-
}), o.addEventListener("keydown", (
|
|
99
|
-
|
|
100
|
-
}),
|
|
101
|
-
|
|
97
|
+
o.placeholder = r ? "" : l, g();
|
|
98
|
+
}), o.addEventListener("keydown", (d) => {
|
|
99
|
+
d.key === "Enter" && (d.preventDefault(), b()), d.key === "Escape" && o.value.length > 0 && (o.value = "", y(), g());
|
|
100
|
+
}), h.appendChild(f), h.appendChild(p), n.appendChild(o), n.appendChild(h), t.appendChild(n), y(), g(), t._cleanup = () => {
|
|
101
|
+
u();
|
|
102
102
|
}, t;
|
|
103
103
|
}
|
|
104
|
-
function
|
|
104
|
+
function v(e, t) {
|
|
105
105
|
if (!e || typeof e != "object") return null;
|
|
106
106
|
const n = e, o = n.type;
|
|
107
107
|
if (typeof o != "string" || o.length === 0) return null;
|
|
108
108
|
const i = n.title, a = n.payload, l = typeof i == "string" && i.length > 0 ? i : t;
|
|
109
109
|
if (!l) return null;
|
|
110
|
-
const
|
|
110
|
+
const s = {
|
|
111
111
|
title: l,
|
|
112
112
|
type: o
|
|
113
113
|
};
|
|
114
|
-
return a !== void 0 && (
|
|
114
|
+
return a !== void 0 && (s.payload = a), s;
|
|
115
115
|
}
|
|
116
|
-
function
|
|
116
|
+
function E(e) {
|
|
117
117
|
const t = {
|
|
118
118
|
title: e.title,
|
|
119
119
|
type: e.type
|
|
120
120
|
};
|
|
121
121
|
return e.payload !== void 0 && (t.payload = e.payload), t;
|
|
122
122
|
}
|
|
123
|
-
function
|
|
123
|
+
function C(e, t) {
|
|
124
124
|
const n = [], o = e.props?.actions;
|
|
125
125
|
if (Array.isArray(o)) for (const l of o) {
|
|
126
|
-
const
|
|
127
|
-
|
|
126
|
+
const s = v(l);
|
|
127
|
+
s && n.push(s);
|
|
128
128
|
}
|
|
129
129
|
const i = e.props?.buttons;
|
|
130
130
|
if (Array.isArray(i)) for (const l of i) {
|
|
131
131
|
if (!l || typeof l != "object") continue;
|
|
132
|
-
const
|
|
133
|
-
|
|
132
|
+
const s = l, c = typeof s.label == "string" ? s.label : void 0, r = v(s.action, c);
|
|
133
|
+
r && n.push(r);
|
|
134
134
|
}
|
|
135
135
|
if (e.children) for (const l of e.children) {
|
|
136
|
-
const
|
|
137
|
-
if (!
|
|
138
|
-
const c = typeof
|
|
139
|
-
|
|
136
|
+
const s = t.elements[l];
|
|
137
|
+
if (!s || s.type !== "ActionButton") continue;
|
|
138
|
+
const c = typeof s.props?.label == "string" ? s.props.label : void 0, r = v(s.props?.action, c);
|
|
139
|
+
r && n.push(r);
|
|
140
140
|
}
|
|
141
141
|
const a = /* @__PURE__ */ new Set();
|
|
142
142
|
return n.filter((l) => a.has(l.title) ? !1 : (a.add(l.title), !0));
|
|
143
143
|
}
|
|
144
|
-
var
|
|
144
|
+
var L = {
|
|
145
145
|
ButtonRow: ({ element: e, spec: t, context: n }) => {
|
|
146
|
-
const o =
|
|
146
|
+
const o = C(e, t).map(E), i = e.props?.orientation, a = {
|
|
147
147
|
actions: o,
|
|
148
148
|
onAction: n.onAction,
|
|
149
149
|
defaultCtaText: n.i18n.defaultCtaText,
|
|
150
150
|
quickQuestionsAriaLabel: n.i18n.quickQuestionsAriaLabel
|
|
151
151
|
};
|
|
152
|
-
return n.onOpenChat !== void 0 && (a.onOpenChat = n.onOpenChat), n.ctaText !== void 0 && (a.ctaText = n.ctaText), (i === "horizontal" || i === "vertical") && (a.orientation = i),
|
|
152
|
+
return n.onOpenChat !== void 0 && (a.onOpenChat = n.onOpenChat), n.ctaText !== void 0 && (a.ctaText = n.ctaText), (i === "horizontal" || i === "vertical") && (a.orientation = i), T(a);
|
|
153
153
|
},
|
|
154
154
|
ActionButtons: ({ element: e, spec: t, context: n }) => {
|
|
155
155
|
const o = {
|
|
156
|
-
actions:
|
|
156
|
+
actions: C(e, t).map(E),
|
|
157
157
|
onAction: n.onAction,
|
|
158
158
|
defaultCtaText: n.i18n.defaultCtaText,
|
|
159
159
|
quickQuestionsAriaLabel: n.i18n.quickQuestionsAriaLabel
|
|
160
160
|
};
|
|
161
|
-
return n.onOpenChat !== void 0 && (o.onOpenChat = n.onOpenChat), n.ctaText !== void 0 && (o.ctaText = n.ctaText),
|
|
161
|
+
return n.onOpenChat !== void 0 && (o.onOpenChat = n.onOpenChat), n.ctaText !== void 0 && (o.ctaText = n.ctaText), T(o);
|
|
162
162
|
},
|
|
163
163
|
ActionButton: ({ element: e, context: t }) => {
|
|
164
164
|
const n = document.createElement("button");
|
|
165
165
|
n.className = "gengage-qna-button gds-chip", n.type = "button", n.dataset.gengagePart = "qna-action-button";
|
|
166
166
|
const o = e.props?.label;
|
|
167
167
|
typeof o == "string" ? n.textContent = o : n.textContent = t.i18n.defaultCtaText;
|
|
168
|
-
const i =
|
|
168
|
+
const i = v(e.props?.action, typeof o == "string" ? o : void 0);
|
|
169
169
|
return i && n.addEventListener("click", () => t.onAction(i)), n;
|
|
170
170
|
},
|
|
171
171
|
TextInput: ({ element: e, context: t }) => {
|
|
@@ -176,7 +176,7 @@ var w = {
|
|
|
176
176
|
sendButtonText: t.i18n.sendButton,
|
|
177
177
|
sendQuestionAriaLabel: t.i18n.sendQuestionAriaLabel
|
|
178
178
|
};
|
|
179
|
-
return o !== void 0 && (a.placeholders = o), i !== void 0 && (a.ctaLabel = i),
|
|
179
|
+
return o !== void 0 && (a.placeholders = o), i !== void 0 && (a.ctaLabel = i), $(a);
|
|
180
180
|
},
|
|
181
181
|
QuestionHeading: ({ element: e, context: t }) => {
|
|
182
182
|
const n = document.createElement("h3");
|
|
@@ -185,7 +185,7 @@ var w = {
|
|
|
185
185
|
return n.textContent = typeof i == "string" && i.trim().length > 0 ? i : typeof o == "string" ? o : "", n;
|
|
186
186
|
},
|
|
187
187
|
ProductCard: () => null
|
|
188
|
-
},
|
|
188
|
+
}, S = ({ element: e, renderElement: t }) => {
|
|
189
189
|
if (!e.children || e.children.length === 0) return null;
|
|
190
190
|
const n = document.createElement("div");
|
|
191
191
|
for (const o of e.children) {
|
|
@@ -194,11 +194,11 @@ var w = {
|
|
|
194
194
|
}
|
|
195
195
|
return n;
|
|
196
196
|
};
|
|
197
|
-
function
|
|
198
|
-
return { ...
|
|
197
|
+
function G() {
|
|
198
|
+
return { ...L };
|
|
199
199
|
}
|
|
200
|
-
function
|
|
201
|
-
return
|
|
200
|
+
function J(e, t, n = L, o = S) {
|
|
201
|
+
return Q({
|
|
202
202
|
spec: e,
|
|
203
203
|
context: t,
|
|
204
204
|
registry: n,
|
|
@@ -206,7 +206,7 @@ function tt(e, t, n = w, o = P) {
|
|
|
206
206
|
unknownRenderer: o
|
|
207
207
|
});
|
|
208
208
|
}
|
|
209
|
-
function
|
|
209
|
+
function V(e) {
|
|
210
210
|
if (!e) return;
|
|
211
211
|
const t = e.extra;
|
|
212
212
|
if (t && typeof t == "object" && !Array.isArray(t)) {
|
|
@@ -219,7 +219,7 @@ function et(e) {
|
|
|
219
219
|
const n = typeof e.sku == "string" && e.sku.trim() ? e.sku.trim() : void 0;
|
|
220
220
|
return n ? [n] : void 0;
|
|
221
221
|
}
|
|
222
|
-
function
|
|
222
|
+
function P(e, t) {
|
|
223
223
|
if (!e) return null;
|
|
224
224
|
const n = e.action;
|
|
225
225
|
if (!n || typeof n != "object") return null;
|
|
@@ -227,13 +227,13 @@ function x(e, t) {
|
|
|
227
227
|
if (typeof i != "string" || i.length === 0) return null;
|
|
228
228
|
const a = o.title, l = typeof a == "string" && a.length > 0 ? a : typeof t == "string" && t.length > 0 ? t : "";
|
|
229
229
|
if (!l) return null;
|
|
230
|
-
const
|
|
230
|
+
const s = o.payload, c = {
|
|
231
231
|
title: l,
|
|
232
232
|
type: i
|
|
233
233
|
};
|
|
234
|
-
return
|
|
234
|
+
return s !== void 0 && (c.payload = s), c;
|
|
235
235
|
}
|
|
236
|
-
function
|
|
236
|
+
function Y(e, t) {
|
|
237
237
|
const n = e.elements[e.root];
|
|
238
238
|
if (!n) return !1;
|
|
239
239
|
const o = (i) => {
|
|
@@ -241,7 +241,7 @@ function nt(e, t) {
|
|
|
241
241
|
const a = i.props;
|
|
242
242
|
if (!a || typeof a != "object") return !1;
|
|
243
243
|
const l = typeof a.label == "string" ? a.label : void 0;
|
|
244
|
-
return l === t ? !0 :
|
|
244
|
+
return l === t ? !0 : P(a, l)?.title === t;
|
|
245
245
|
};
|
|
246
246
|
if (n.type === "ActionButton") return o(n);
|
|
247
247
|
if (n.children) for (const i of n.children) {
|
|
@@ -254,14 +254,14 @@ function nt(e, t) {
|
|
|
254
254
|
}
|
|
255
255
|
return !1;
|
|
256
256
|
}
|
|
257
|
-
var
|
|
258
|
-
function
|
|
259
|
-
return
|
|
257
|
+
var I = 0;
|
|
258
|
+
function w() {
|
|
259
|
+
return I += 1, `gengage-merge-${I}`;
|
|
260
260
|
}
|
|
261
|
-
function
|
|
261
|
+
function Z(e, t) {
|
|
262
262
|
const n = e.elements[e.root];
|
|
263
263
|
if (!n || n.type !== "ButtonRow") return;
|
|
264
|
-
const o =
|
|
264
|
+
const o = w();
|
|
265
265
|
e.elements[o] = {
|
|
266
266
|
type: "ActionButton",
|
|
267
267
|
props: {
|
|
@@ -274,10 +274,10 @@ function ot(e, t) {
|
|
|
274
274
|
}
|
|
275
275
|
}, n.children = n.children ? [o, ...n.children] : [o];
|
|
276
276
|
}
|
|
277
|
-
function
|
|
277
|
+
function K(e, t) {
|
|
278
278
|
const n = e.elements[e.root];
|
|
279
279
|
if (!n || n.type !== "ActionButtons") return;
|
|
280
|
-
const o =
|
|
280
|
+
const o = w();
|
|
281
281
|
e.elements[o] = {
|
|
282
282
|
type: "ActionButton",
|
|
283
283
|
props: {
|
|
@@ -302,7 +302,7 @@ function it(e, t) {
|
|
|
302
302
|
buttons: [a, ...i]
|
|
303
303
|
};
|
|
304
304
|
}
|
|
305
|
-
function
|
|
305
|
+
function X(e) {
|
|
306
306
|
const t = {}, n = [];
|
|
307
307
|
for (let o = 0; o < e.length; o++) {
|
|
308
308
|
const i = e[o], a = `action-${o}`;
|
|
@@ -326,13 +326,13 @@ function at(e) {
|
|
|
326
326
|
elements: t
|
|
327
327
|
};
|
|
328
328
|
}
|
|
329
|
-
function
|
|
329
|
+
function tt(e) {
|
|
330
330
|
return e.find((t) => {
|
|
331
331
|
const n = t.elements[t.root];
|
|
332
332
|
return n?.type === "ActionButtons" || n?.type === "ButtonRow";
|
|
333
333
|
});
|
|
334
334
|
}
|
|
335
|
-
function
|
|
335
|
+
function k(e, t) {
|
|
336
336
|
const n = e.productContextQuickPillLabel, o = { text: n };
|
|
337
337
|
return t && t.length > 0 && (o.sku_list = t), {
|
|
338
338
|
title: n,
|
|
@@ -340,29 +340,29 @@ function L(e, t) {
|
|
|
340
340
|
payload: o
|
|
341
341
|
};
|
|
342
342
|
}
|
|
343
|
-
function
|
|
343
|
+
function et(e, t, n) {
|
|
344
344
|
const o = n?.skuList, i = [], a = [];
|
|
345
345
|
for (const c of e) {
|
|
346
|
-
const
|
|
347
|
-
if (
|
|
348
|
-
const
|
|
349
|
-
if (
|
|
350
|
-
i.push(
|
|
346
|
+
const r = c.elements[c.root];
|
|
347
|
+
if (r?.type === "ActionButton") {
|
|
348
|
+
const u = r.props;
|
|
349
|
+
if (P(u, typeof u?.label == "string" ? u.label : void 0)?.type === "findSimilar") {
|
|
350
|
+
i.push(k(t, o));
|
|
351
351
|
continue;
|
|
352
352
|
}
|
|
353
353
|
}
|
|
354
354
|
a.push(c);
|
|
355
355
|
}
|
|
356
356
|
if (i.length === 0) return e;
|
|
357
|
-
const l =
|
|
358
|
-
if (!
|
|
359
|
-
if (!
|
|
360
|
-
const c =
|
|
361
|
-
c?.type === "ActionButtons" ?
|
|
357
|
+
const l = k(t, o), s = tt(a);
|
|
358
|
+
if (!s) return [...a, X([l])];
|
|
359
|
+
if (!Y(s, l.title)) {
|
|
360
|
+
const c = s.elements[s.root];
|
|
361
|
+
c?.type === "ActionButtons" ? K(s, l) : c?.type === "ButtonRow" && Z(s, l);
|
|
362
362
|
}
|
|
363
363
|
return a;
|
|
364
364
|
}
|
|
365
|
-
var
|
|
365
|
+
var B = {
|
|
366
366
|
quickQuestionsAriaLabel: "Hızlı sorular",
|
|
367
367
|
askQuestionAriaLabel: "Soru sorun",
|
|
368
368
|
defaultInputPlaceholder: "Bir soru sorun...",
|
|
@@ -371,7 +371,7 @@ var R = {
|
|
|
371
371
|
defaultCtaText: "Başka bir şey sor",
|
|
372
372
|
redirectingToChat: "Sohbete yönlendiriliyor...",
|
|
373
373
|
productContextQuickPillLabel: "Bu ürün hakkında ne bilmeliyim?"
|
|
374
|
-
},
|
|
374
|
+
}, nt = {
|
|
375
375
|
quickQuestionsAriaLabel: "Quick questions",
|
|
376
376
|
askQuestionAriaLabel: "Ask a question",
|
|
377
377
|
defaultInputPlaceholder: "Ask a question...",
|
|
@@ -381,25 +381,25 @@ var R = {
|
|
|
381
381
|
redirectingToChat: "Redirecting to chat...",
|
|
382
382
|
productContextQuickPillLabel: "What should I know about this product?"
|
|
383
383
|
};
|
|
384
|
-
function
|
|
384
|
+
function ot(e) {
|
|
385
385
|
return e ? e.toLowerCase().split("-")[0] ?? "tr" : "tr";
|
|
386
386
|
}
|
|
387
|
-
function
|
|
388
|
-
return
|
|
387
|
+
function it(e) {
|
|
388
|
+
return ot(e) === "en" ? nt : B;
|
|
389
389
|
}
|
|
390
|
-
var
|
|
390
|
+
var at = class extends W {
|
|
391
391
|
constructor(...e) {
|
|
392
|
-
super(...e), this._abortController = null, this._debounceTimer = null, this._contentEl = null, this._i18n =
|
|
392
|
+
super(...e), this._abortController = null, this._debounceTimer = null, this._contentEl = null, this._i18n = B, this._actionHandler = this._handleAction.bind(this), this._openChatHandler = this._handleOpenChat.bind(this);
|
|
393
393
|
}
|
|
394
394
|
async onInit(e) {
|
|
395
|
-
this._i18n = this._resolveI18n(e), this._contentEl = document.createElement("div"), this._contentEl.className = "gengage-qna-container", this._contentEl.dataset.gengagePart = "qna-container", this._contentEl.lang =
|
|
395
|
+
this._i18n = this._resolveI18n(e), this._contentEl = document.createElement("div"), this._contentEl.className = "gengage-qna-container", this._contentEl.dataset.gengagePart = "qna-container", this._contentEl.lang = A(e.locale);
|
|
396
396
|
const t = this._createChrome(e);
|
|
397
397
|
if (t) {
|
|
398
398
|
const o = document.createElement("div");
|
|
399
399
|
o.className = "gengage-qna-chrome-widget", o.dataset.gengagePart = "qna-chrome-widget", o.appendChild(this._contentEl), t.appendChild(o), this.root.appendChild(t);
|
|
400
400
|
} else this.root.appendChild(this._contentEl);
|
|
401
401
|
const n = e.pageContext?.sku;
|
|
402
|
-
n && (this._lastSku = n, await this._fetchAndRender(n)),
|
|
402
|
+
n && (this._lastSku = n, await this._fetchAndRender(n)), M("qna");
|
|
403
403
|
}
|
|
404
404
|
onUpdate(e) {
|
|
405
405
|
const t = e.sku;
|
|
@@ -436,88 +436,68 @@ var ut = class extends W {
|
|
|
436
436
|
this._cleanupTextInputTimers(), this._contentEl.innerHTML = "";
|
|
437
437
|
const t = this._createLoadingIndicator();
|
|
438
438
|
this._contentEl.appendChild(t);
|
|
439
|
-
const n = { middlewareUrl: this.config.middlewareUrl }, o =
|
|
439
|
+
const n = { middlewareUrl: this.config.middlewareUrl }, o = D({
|
|
440
440
|
source: "qna",
|
|
441
441
|
locale: this.config.locale
|
|
442
442
|
});
|
|
443
|
-
this.track(z(this.analyticsContext(), {
|
|
444
|
-
endpoint: "launcher_action",
|
|
445
|
-
request_id: o,
|
|
446
|
-
widget: "qna"
|
|
447
|
-
}));
|
|
448
443
|
try {
|
|
449
|
-
const
|
|
444
|
+
const i = this.config.session?.sessionId ?? "", a = {
|
|
450
445
|
account_id: this.config.accountId,
|
|
451
|
-
session_id:
|
|
452
|
-
correlation_id:
|
|
446
|
+
session_id: i,
|
|
447
|
+
correlation_id: i,
|
|
453
448
|
sku: e,
|
|
454
|
-
locale:
|
|
449
|
+
locale: A(this.config.locale)
|
|
455
450
|
};
|
|
456
|
-
this.config.session?.userId !== void 0 && (
|
|
457
|
-
const
|
|
458
|
-
|
|
459
|
-
const s = await
|
|
460
|
-
if (this.
|
|
461
|
-
request_id: o,
|
|
462
|
-
latency_ms: Date.now() - i,
|
|
463
|
-
chunk_count: s.actions.length,
|
|
464
|
-
widget: "qna"
|
|
465
|
-
})), this.track(M(this.analyticsContext(), {
|
|
466
|
-
message_count: s.actions.length,
|
|
467
|
-
history_ref: o,
|
|
468
|
-
redaction_level: "none",
|
|
469
|
-
widget: "qna"
|
|
470
|
-
})), !this._contentEl) return;
|
|
451
|
+
this.config.session?.userId !== void 0 && (a.user_id = this.config.session.userId), this.config.session?.viewId !== void 0 && (a.view_id = this.config.session.viewId);
|
|
452
|
+
const l = this.config.pageContext?.pageType;
|
|
453
|
+
l !== void 0 && (a.page_type = l);
|
|
454
|
+
const s = await z(a, n, this._abortController.signal);
|
|
455
|
+
if (!this._contentEl) return;
|
|
471
456
|
this._contentEl.innerHTML = "";
|
|
472
|
-
const
|
|
473
|
-
|
|
474
|
-
const
|
|
475
|
-
if (!
|
|
476
|
-
const
|
|
477
|
-
|
|
457
|
+
const c = document.createElement("div");
|
|
458
|
+
c.className = "gengage-qna-panel gds-panel", c.dataset.gengagePart = "qna-panel", this._contentEl.appendChild(c);
|
|
459
|
+
const r = this._specIncludesType(s.uiSpecs, "QuestionHeading"), u = this._resolvedQnaHeaderTitle() ?? (this.config.showStaticQuestion && this.config.staticQuestionText ? this.config.staticQuestionText : void 0);
|
|
460
|
+
if (!r && u) {
|
|
461
|
+
const d = document.createElement("h3");
|
|
462
|
+
d.className = "gengage-qna-heading", d.textContent = u, c.appendChild(d);
|
|
478
463
|
}
|
|
479
464
|
const m = this.config.inputPlaceholder;
|
|
480
|
-
let
|
|
481
|
-
if (m !== !0)
|
|
465
|
+
let g;
|
|
466
|
+
if (m !== !0) g = m ?? this._i18n.defaultInputPlaceholder;
|
|
482
467
|
else if (s.actions.length > 0) {
|
|
483
|
-
const
|
|
484
|
-
|
|
485
|
-
} else
|
|
486
|
-
const
|
|
468
|
+
const d = s.actions.filter((_) => _.type === "user_message" || _.title.includes("?")).map((_) => _.title);
|
|
469
|
+
g = d.length > 0 ? d : this._i18n.defaultInputPlaceholder;
|
|
470
|
+
} else g = this._i18n.defaultInputPlaceholder;
|
|
471
|
+
const h = {
|
|
487
472
|
onAction: this._actionHandler,
|
|
488
473
|
i18n: this._i18n
|
|
489
|
-
},
|
|
490
|
-
|
|
491
|
-
const
|
|
492
|
-
for (const
|
|
493
|
-
const _ = this._renderUISpec(
|
|
494
|
-
|
|
474
|
+
}, f = this._resolvedQnaHeaderTitle();
|
|
475
|
+
f !== void 0 && (h.headingTitleOverride = f), this.config.hideButtonRowCta || (h.onOpenChat = this._openChatHandler, this.config.ctaText !== void 0 && (h.ctaText = this.config.ctaText)), g !== void 0 && (h.inputPlaceholder = g);
|
|
476
|
+
const p = this._buildFallbackActionsSpec(s.actions), y = V(this.config.pageContext), b = (s.uiSpecs.length > 0 ? et(s.uiSpecs, this._i18n, { skuList: y }) : [p]).filter((d) => Object.keys(d.elements).length > 0);
|
|
477
|
+
for (const d of b) {
|
|
478
|
+
const _ = this._renderUISpec(d, h);
|
|
479
|
+
c.appendChild(_);
|
|
495
480
|
}
|
|
496
|
-
|
|
497
|
-
} catch (
|
|
498
|
-
if (
|
|
499
|
-
if (
|
|
481
|
+
b.length > 0 && j("qna"), this._specIncludesType(b, "TextInput") || this._insertStandaloneInputBeforePills(c, h, g);
|
|
482
|
+
} catch (i) {
|
|
483
|
+
if (i instanceof DOMException && i.name === "AbortError") return;
|
|
484
|
+
if (q("gengage:global:error", {
|
|
500
485
|
source: "qna",
|
|
501
486
|
code: "FETCH_ERROR",
|
|
502
|
-
message: F(this.config.locale,
|
|
503
|
-
}), this.
|
|
504
|
-
request_id: o,
|
|
505
|
-
error_code: "FETCH_ERROR",
|
|
506
|
-
error_message: l instanceof Error ? l.message : String(l),
|
|
507
|
-
widget: "qna"
|
|
508
|
-
})), this._contentEl) {
|
|
487
|
+
message: F(this.config.locale, i)
|
|
488
|
+
}), this._contentEl) {
|
|
509
489
|
this._cleanupTextInputTimers(), this._contentEl.innerHTML = "";
|
|
510
|
-
const
|
|
511
|
-
|
|
512
|
-
const
|
|
490
|
+
const a = document.createElement("div");
|
|
491
|
+
a.className = "gengage-qna-panel", this._contentEl.appendChild(a);
|
|
492
|
+
const l = this.config.inputPlaceholder === !0 ? this._i18n.defaultInputPlaceholder : this.config.inputPlaceholder ?? this._i18n.defaultInputPlaceholder, s = {
|
|
513
493
|
onAction: this._actionHandler,
|
|
514
494
|
i18n: this._i18n,
|
|
515
495
|
onOpenChat: this._openChatHandler
|
|
516
|
-
},
|
|
517
|
-
|
|
496
|
+
}, c = this._resolvedQnaHeaderTitle();
|
|
497
|
+
c !== void 0 && (s.headingTitleOverride = c), this.config.ctaText !== void 0 && (s.ctaText = this.config.ctaText), this._appendStandaloneInput(s, l, a);
|
|
518
498
|
}
|
|
519
499
|
} finally {
|
|
520
|
-
|
|
500
|
+
o();
|
|
521
501
|
}
|
|
522
502
|
}
|
|
523
503
|
_createLoadingIndicator() {
|
|
@@ -531,41 +511,41 @@ var ut = class extends W {
|
|
|
531
511
|
}
|
|
532
512
|
_resolveI18n(e) {
|
|
533
513
|
return {
|
|
534
|
-
...
|
|
514
|
+
...it(e.locale),
|
|
535
515
|
...e.i18n
|
|
536
516
|
};
|
|
537
517
|
}
|
|
538
518
|
_createChrome(e) {
|
|
539
519
|
const t = e.chrome;
|
|
540
520
|
if (!t) return null;
|
|
541
|
-
const n = typeof t.title == "string" ? t.title.trim() : "", o = typeof t.subtitle == "string" ? t.subtitle.trim() : "", i = typeof t.startButtonLabel == "string" ? t.startButtonLabel.trim() : "", a = typeof t.imageUrl == "string" ? t.imageUrl.trim() : "", l = typeof t.imagePadding == "string" ? t.imagePadding.trim() : "",
|
|
542
|
-
|
|
521
|
+
const n = typeof t.title == "string" ? t.title.trim() : "", o = typeof t.subtitle == "string" ? t.subtitle.trim() : "", i = typeof t.startButtonLabel == "string" ? t.startButtonLabel.trim() : "", a = typeof t.imageUrl == "string" ? t.imageUrl.trim() : "", l = typeof t.imagePadding == "string" ? t.imagePadding.trim() : "", s = document.createElement("section");
|
|
522
|
+
s.className = "gengage-qna-chrome", s.dataset.gengagePart = "qna-chrome", t.layout === "side-image" && (s.classList.add("gengage-qna-chrome--side-image"), s.dataset.gengageChromeLayout = "side-image"), l && s.style.setProperty("--gengage-qna-chrome-image-padding", l);
|
|
543
523
|
const c = document.createElement("div");
|
|
544
524
|
if (c.className = "gengage-qna-chrome-copy", c.dataset.gengagePart = "qna-chrome-copy", n) {
|
|
545
|
-
const
|
|
546
|
-
|
|
525
|
+
const r = document.createElement("h2");
|
|
526
|
+
r.className = "gengage-qna-chrome-title", r.dataset.gengagePart = "qna-chrome-title", r.textContent = n, c.appendChild(r);
|
|
547
527
|
}
|
|
548
528
|
if (o) {
|
|
549
|
-
const
|
|
550
|
-
|
|
529
|
+
const r = document.createElement("p");
|
|
530
|
+
r.className = "gengage-qna-chrome-subtitle", r.dataset.gengagePart = "qna-chrome-subtitle", r.textContent = o, c.appendChild(r);
|
|
551
531
|
}
|
|
552
|
-
if (c.children.length > 0 &&
|
|
553
|
-
const
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
}, { once: !0 }),
|
|
532
|
+
if (c.children.length > 0 && s.appendChild(c), a && O(a)) {
|
|
533
|
+
const r = document.createElement("img");
|
|
534
|
+
r.className = "gengage-qna-chrome-image", r.dataset.gengagePart = "qna-chrome-image", r.src = a, r.alt = typeof t.imageAlt == "string" ? t.imageAlt : "", r.loading = "lazy", r.addEventListener("error", () => {
|
|
535
|
+
r.style.display = "none";
|
|
536
|
+
}, { once: !0 }), s.appendChild(r);
|
|
557
537
|
}
|
|
558
538
|
if (i) {
|
|
559
|
-
const
|
|
560
|
-
|
|
539
|
+
const r = document.createElement("button");
|
|
540
|
+
r.className = "gengage-qna-chrome-start", r.dataset.gengagePart = "qna-chrome-start", r.type = "button", r.textContent = i, r.addEventListener("click", () => this._handleOpenChat()), s.appendChild(r);
|
|
561
541
|
}
|
|
562
|
-
return
|
|
542
|
+
return s.children.length === 0 ? null : s;
|
|
563
543
|
}
|
|
564
544
|
_resolveUISpecRegistry() {
|
|
565
|
-
return
|
|
545
|
+
return R(G(), this.config.renderer?.registry);
|
|
566
546
|
}
|
|
567
547
|
_renderUISpec(e, t) {
|
|
568
|
-
const n = this._resolveUISpecRegistry(), o = this.config.renderer?.unknownRenderer ??
|
|
548
|
+
const n = this._resolveUISpecRegistry(), o = this.config.renderer?.unknownRenderer ?? S, i = (l, s) => J(l, s, n, o), a = this.config.renderer?.renderUISpec;
|
|
569
549
|
return a ? a(e, t, {
|
|
570
550
|
registry: n,
|
|
571
551
|
unknownRenderer: o,
|
|
@@ -613,11 +593,11 @@ var ut = class extends W {
|
|
|
613
593
|
} }
|
|
614
594
|
}, i = this._renderUISpec(o, t), a = i.querySelector(".gengage-qna-input-wrapper");
|
|
615
595
|
if (!a) return;
|
|
616
|
-
const l = e.querySelector(".gengage-qna-uispec"),
|
|
617
|
-
if (
|
|
596
|
+
const l = e.querySelector(".gengage-qna-uispec"), s = e.querySelector(".gengage-qna-uispec > .gengage-qna-buttons"), c = this.config.inputAfterPills === !0;
|
|
597
|
+
if (s) c ? s.insertAdjacentElement("afterend", a) : s.insertAdjacentElement("beforebegin", a);
|
|
618
598
|
else if (l) {
|
|
619
|
-
const
|
|
620
|
-
!c &&
|
|
599
|
+
const r = l.querySelector(":scope > .gengage-qna-heading");
|
|
600
|
+
!c && r ? r.insertAdjacentElement("afterend", a) : l.appendChild(a);
|
|
621
601
|
} else {
|
|
622
602
|
e.appendChild(i);
|
|
623
603
|
return;
|
|
@@ -636,10 +616,10 @@ var ut = class extends W {
|
|
|
636
616
|
(n ?? this._contentEl).appendChild(i);
|
|
637
617
|
}
|
|
638
618
|
_handleAction(e) {
|
|
639
|
-
this._showTransitionIndicator(),
|
|
619
|
+
this._showTransitionIndicator(), U(e.title, e.type), this.config.onActionSelected?.(e), setTimeout(() => q("gengage:qna:action", e), 350);
|
|
640
620
|
}
|
|
641
621
|
_handleOpenChat() {
|
|
642
|
-
this._showTransitionIndicator(), this.config.onOpenChat?.(), setTimeout(() =>
|
|
622
|
+
this._showTransitionIndicator(), this.config.onOpenChat?.(), setTimeout(() => q("gengage:qna:open-chat", {}), 350);
|
|
643
623
|
}
|
|
644
624
|
_showTransitionIndicator() {
|
|
645
625
|
if (!this._contentEl) return;
|
|
@@ -650,13 +630,13 @@ var ut = class extends W {
|
|
|
650
630
|
}, 600);
|
|
651
631
|
}
|
|
652
632
|
};
|
|
653
|
-
function
|
|
654
|
-
return new
|
|
633
|
+
function ut() {
|
|
634
|
+
return new at();
|
|
655
635
|
}
|
|
656
636
|
export {
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
637
|
+
J as a,
|
|
638
|
+
S as i,
|
|
639
|
+
ut as n,
|
|
640
|
+
G as r,
|
|
641
|
+
at as t
|
|
662
642
|
};
|