@gengage/assistant-fe 0.6.25 → 0.6.27
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/agentic/debug/activity-collector.d.ts +1 -0
- package/dist/agentic/index.js +374 -353
- package/dist/agentic/types.d.ts +3 -0
- package/dist/agentic/worker.js +1 -1
- package/dist/agentic.iife.js +5 -4
- package/dist/api-paths-C9NwnH29.js +1274 -0
- package/dist/chat-runtime.js +1 -1
- package/dist/chat.iife.js +13 -13
- package/dist/chat.js +1 -1
- package/dist/{common-aUI01FdB.js → common-Bhl1mzk2.js} +1 -1
- package/dist/common.js +5 -5
- package/dist/{connection-warning-DkdoruU2.js → connection-warning-D-0Mxk-A.js} +1 -1
- package/dist/{fastIntent-iu8Z5MpN.js → fastIntent-bAlwVoje.js} +1 -1
- package/dist/index.js +10 -10
- package/dist/native.iife.js +11 -11
- package/dist/qna-runtime.js +1 -1
- package/dist/qna.iife.js +25 -25
- package/dist/qna.js +1 -1
- package/dist/{route-params-UDemctx_.js → route-params-5K4Du1Xa.js} +678 -673
- package/dist/{runtime-aSV5XfKR.js → runtime-BAFZ7iOP.js} +3 -3
- package/dist/{runtime-DGUqplEx.js → runtime-CUNLK1KR.js} +3 -3
- package/dist/{runtime-Cu05VoNY.js → runtime-oEtmgT4U.js} +4 -4
- package/dist/{simbut-S9Kviutm.js → simbut-Dt8e5uSk.js} +1 -1
- package/dist/simbut.iife.js +1 -1
- package/dist/simbut.js +1 -1
- package/dist/simrel-runtime.js +1 -1
- package/dist/{simrel-BTn7A6VC.js → simrel-txr23_xG.js} +1 -1
- package/dist/simrel.iife.js +38 -38
- package/dist/simrel.js +2 -2
- package/dist/{widget-base-T-AFCGg6.js → widget-base-56tkaZZB.js} +1 -1
- package/package.json +1 -1
- package/dist/api-paths-C0t52SV3.js +0 -1235
|
@@ -1,1235 +0,0 @@
|
|
|
1
|
-
import { i as z } from "./widget-base-T-AFCGg6.js";
|
|
2
|
-
var G = ({ element: e, renderElement: t }) => {
|
|
3
|
-
if (!e.children || e.children.length === 0) return null;
|
|
4
|
-
const r = document.createElement("div");
|
|
5
|
-
for (const n of e.children) {
|
|
6
|
-
const o = t(n);
|
|
7
|
-
o && r.appendChild(o);
|
|
8
|
-
}
|
|
9
|
-
return r;
|
|
10
|
-
};
|
|
11
|
-
function Ue(e) {
|
|
12
|
-
const t = document.createElement("div");
|
|
13
|
-
if (t.className = e.containerClassName, !e.spec.elements[e.spec.root]) return t;
|
|
14
|
-
const r = e.unknownRenderer ?? G, n = (i) => {
|
|
15
|
-
const s = e.spec.elements[i];
|
|
16
|
-
if (!s) return null;
|
|
17
|
-
const a = e.registry[s.type];
|
|
18
|
-
return a ? a({
|
|
19
|
-
elementId: i,
|
|
20
|
-
element: s,
|
|
21
|
-
spec: e.spec,
|
|
22
|
-
context: e.context,
|
|
23
|
-
renderElement: n
|
|
24
|
-
}) : r({
|
|
25
|
-
elementId: i,
|
|
26
|
-
element: s,
|
|
27
|
-
spec: e.spec,
|
|
28
|
-
context: e.context,
|
|
29
|
-
renderElement: n
|
|
30
|
-
});
|
|
31
|
-
}, o = n(e.spec.root);
|
|
32
|
-
return o && t.appendChild(o), t;
|
|
33
|
-
}
|
|
34
|
-
function ze(e, t) {
|
|
35
|
-
if (!t) return e;
|
|
36
|
-
const r = { ...e };
|
|
37
|
-
for (const [n, o] of Object.entries(t))
|
|
38
|
-
o && (r[n] = o);
|
|
39
|
-
return r;
|
|
40
|
-
}
|
|
41
|
-
function v(e) {
|
|
42
|
-
return typeof e == "object" && e !== null && typeof e.type == "string";
|
|
43
|
-
}
|
|
44
|
-
function j(e) {
|
|
45
|
-
const t = [];
|
|
46
|
-
let r = 0, n = !1, o = !1, i = 0;
|
|
47
|
-
for (let s = 0; s < e.length; s++) {
|
|
48
|
-
const a = e[s];
|
|
49
|
-
if (o) {
|
|
50
|
-
o = !1;
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
if (a === "\\" && n) {
|
|
54
|
-
o = !0;
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
if (a === '"') {
|
|
58
|
-
n = !n;
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
n || (a === "{" && r++, a === "}" && (r--, r === 0 && (t.push(e.slice(i, s + 1)), i = s + 1)));
|
|
62
|
-
}
|
|
63
|
-
return t.length > 0 ? t : [e];
|
|
64
|
-
}
|
|
65
|
-
function I(e, t) {
|
|
66
|
-
const r = e.trim();
|
|
67
|
-
if (!r || r.startsWith(":")) return !1;
|
|
68
|
-
const n = r.startsWith("data: ") ? r.slice(6) : r;
|
|
69
|
-
if (n === "[DONE]")
|
|
70
|
-
return t.onDone?.(), !0;
|
|
71
|
-
try {
|
|
72
|
-
const o = JSON.parse(n);
|
|
73
|
-
return v(o) ? (z("stream", `event: ${o.type}`, o), t.onEvent(o), o.type === "done" ? (t.onDone?.(), !0) : !1) : !1;
|
|
74
|
-
} catch {
|
|
75
|
-
const o = j(n);
|
|
76
|
-
if (o.length > 1) {
|
|
77
|
-
for (const i of o) try {
|
|
78
|
-
const s = JSON.parse(i);
|
|
79
|
-
if (!v(s)) continue;
|
|
80
|
-
if (t.onEvent(s), s.type === "done")
|
|
81
|
-
return t.onDone?.(), !0;
|
|
82
|
-
} catch {
|
|
83
|
-
}
|
|
84
|
-
return !1;
|
|
85
|
-
}
|
|
86
|
-
return !1;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
async function M(e, t) {
|
|
90
|
-
if (!e.ok) {
|
|
91
|
-
t.onError?.(/* @__PURE__ */ new Error(`HTTP ${e.status}: ${e.statusText}`));
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
if (!e.body) {
|
|
95
|
-
t.onError?.(/* @__PURE__ */ new Error("Response body is null — streaming not supported"));
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
const r = e.body.getReader(), n = new TextDecoder("utf-8");
|
|
99
|
-
let o = "";
|
|
100
|
-
const i = t.idleTimeoutMs ?? 6e4, s = /* @__PURE__ */ Symbol("idle-timeout");
|
|
101
|
-
let a = !1;
|
|
102
|
-
try {
|
|
103
|
-
for (; ; ) {
|
|
104
|
-
const c = r.read();
|
|
105
|
-
let m;
|
|
106
|
-
const _ = await (i > 0 ? Promise.race([c.then((g) => (clearTimeout(m), g)), new Promise((g) => {
|
|
107
|
-
m = setTimeout(() => g(s), i);
|
|
108
|
-
})]) : c);
|
|
109
|
-
if (_ === s) {
|
|
110
|
-
a = !0, await r.cancel();
|
|
111
|
-
break;
|
|
112
|
-
}
|
|
113
|
-
const { done: d, value: p } = _;
|
|
114
|
-
if (d) break;
|
|
115
|
-
o += n.decode(p, { stream: !0 });
|
|
116
|
-
const l = o.split(`
|
|
117
|
-
`);
|
|
118
|
-
o = l.pop() ?? "";
|
|
119
|
-
for (const g of l) if (I(g, t)) return;
|
|
120
|
-
}
|
|
121
|
-
if (o.trim() && I(o, t))
|
|
122
|
-
return;
|
|
123
|
-
} catch (c) {
|
|
124
|
-
if (c instanceof DOMException && c.name === "AbortError") return;
|
|
125
|
-
t.onError?.(c instanceof Error ? c : new Error(String(c)));
|
|
126
|
-
} finally {
|
|
127
|
-
a || r.releaseLock();
|
|
128
|
-
}
|
|
129
|
-
t.onDone?.();
|
|
130
|
-
}
|
|
131
|
-
function Ge(e, t, r) {
|
|
132
|
-
const n = new AbortController(), o = r.signal ? $([r.signal, n.signal]) : n.signal;
|
|
133
|
-
return fetch(e, {
|
|
134
|
-
method: "POST",
|
|
135
|
-
headers: {
|
|
136
|
-
"Content-Type": "application/json",
|
|
137
|
-
...r.headers
|
|
138
|
-
},
|
|
139
|
-
body: JSON.stringify(t),
|
|
140
|
-
signal: o
|
|
141
|
-
}).then((i) => M(i, {
|
|
142
|
-
...r,
|
|
143
|
-
signal: o
|
|
144
|
-
})).catch((i) => {
|
|
145
|
-
i instanceof DOMException && i.name === "AbortError" || r.onError?.(i instanceof Error ? i : new Error(String(i)));
|
|
146
|
-
}), n;
|
|
147
|
-
}
|
|
148
|
-
function $(e) {
|
|
149
|
-
const t = new AbortController(), r = [];
|
|
150
|
-
for (const n of e) {
|
|
151
|
-
if (n.aborted)
|
|
152
|
-
return t.abort(n.reason), t.signal;
|
|
153
|
-
const o = () => t.abort(n.reason);
|
|
154
|
-
n.addEventListener("abort", o, { once: !0 }), r.push(() => n.removeEventListener("abort", o));
|
|
155
|
-
}
|
|
156
|
-
return t.signal.addEventListener("abort", () => {
|
|
157
|
-
for (const n of r) n();
|
|
158
|
-
}, { once: !0 }), t.signal;
|
|
159
|
-
}
|
|
160
|
-
var N = 3, B = (e, t) => {
|
|
161
|
-
const r = e.replace(/\s+/g, " ").trim().replace(/^[,.;:!?•-]+|[,.;:!?•-]+$/g, "");
|
|
162
|
-
if (!r) return "";
|
|
163
|
-
const n = t?.stripLeadingStopWords ? r.replace(/^(?:daha|için)\s+/i, "").trim() : r;
|
|
164
|
-
return n ? n.split(/\s+/).slice(0, 3).join(" ").trim() : "";
|
|
165
|
-
}, x = (e, t) => e ? e.split(/[•,;:/()]|(?:\sve\s)|(?:\sand\s)|(?:\sile\s)|(?:\sfor\s)|(?:\swith\s)/i).map((r) => B(r, t)).filter(Boolean) : [];
|
|
166
|
-
function K(e) {
|
|
167
|
-
const t = (e.display_keywords ?? []).flatMap((o) => x(o, { stripLeadingStopWords: !0 })), r = t.filter((o, i) => t.indexOf(o) === i);
|
|
168
|
-
if (r.length > 0) return r.slice(0, N);
|
|
169
|
-
const n = [...x(e.chosen_attribute, { stripLeadingStopWords: !0 }), ...x(e.short_name)];
|
|
170
|
-
return n.filter((o, i) => n.indexOf(o) === i).slice(0, N);
|
|
171
|
-
}
|
|
172
|
-
function V(e) {
|
|
173
|
-
return K(e).join(" • ");
|
|
174
|
-
}
|
|
175
|
-
function W(e) {
|
|
176
|
-
return e === "beauty_consulting" || e === "account_expert";
|
|
177
|
-
}
|
|
178
|
-
function P(...e) {
|
|
179
|
-
for (const t of e) {
|
|
180
|
-
if (typeof t != "string") continue;
|
|
181
|
-
const r = t.trim();
|
|
182
|
-
if (r.length > 0) return r;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
function C(e) {
|
|
186
|
-
return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0).map((t) => t.trim()) : [];
|
|
187
|
-
}
|
|
188
|
-
function R(e) {
|
|
189
|
-
const t = { ...e }, r = P(t.sku), n = C(t.group_skus);
|
|
190
|
-
if (r ? t.sku = r : delete t.sku, n.length > 0 ? t.group_skus = n : delete t.group_skus, r || n.length > 0) delete t.image_url;
|
|
191
|
-
else {
|
|
192
|
-
const o = P(t.image_url);
|
|
193
|
-
o ? t.image_url = o : delete t.image_url;
|
|
194
|
-
}
|
|
195
|
-
return t;
|
|
196
|
-
}
|
|
197
|
-
function je(e) {
|
|
198
|
-
if (typeof e.type != "string") return null;
|
|
199
|
-
if (F(e)) return e;
|
|
200
|
-
const t = e;
|
|
201
|
-
switch (t.type) {
|
|
202
|
-
case "outputText":
|
|
203
|
-
return Q(t);
|
|
204
|
-
case "suggestedActions":
|
|
205
|
-
return J(t);
|
|
206
|
-
case "productList":
|
|
207
|
-
return Y(t);
|
|
208
|
-
case "productDetails":
|
|
209
|
-
return X(t);
|
|
210
|
-
case "productDetailsSimilars":
|
|
211
|
-
return Z(t);
|
|
212
|
-
case "comparisonTable":
|
|
213
|
-
return ee(t);
|
|
214
|
-
case "context":
|
|
215
|
-
return ne(t);
|
|
216
|
-
case "chatStreamEnd":
|
|
217
|
-
return ie();
|
|
218
|
-
case "loading":
|
|
219
|
-
return se(t);
|
|
220
|
-
case "panelLoading":
|
|
221
|
-
return ae(t);
|
|
222
|
-
case "similarLoading":
|
|
223
|
-
return ce(t);
|
|
224
|
-
case "redirect":
|
|
225
|
-
return ue(t);
|
|
226
|
-
case "error":
|
|
227
|
-
return de(t);
|
|
228
|
-
case "dummy":
|
|
229
|
-
return le(t);
|
|
230
|
-
case "launcherAction":
|
|
231
|
-
return pe(t);
|
|
232
|
-
case "text":
|
|
233
|
-
return T(t);
|
|
234
|
-
case "productItem":
|
|
235
|
-
return fe(t);
|
|
236
|
-
case "text_image":
|
|
237
|
-
return L(t);
|
|
238
|
-
case "quick_qna":
|
|
239
|
-
return D(t);
|
|
240
|
-
case "reviewHighlights":
|
|
241
|
-
return ye(t);
|
|
242
|
-
case "aiProductSuggestions":
|
|
243
|
-
return _e(t);
|
|
244
|
-
case "aiProductGroupings":
|
|
245
|
-
return he(t);
|
|
246
|
-
case "aiSuggestedSearches":
|
|
247
|
-
return be(t);
|
|
248
|
-
case "prosAndCons":
|
|
249
|
-
return ge(t);
|
|
250
|
-
case "getGroundingReview":
|
|
251
|
-
return we(t);
|
|
252
|
-
case "voice":
|
|
253
|
-
return Ae(t);
|
|
254
|
-
case "visitorDataResponse":
|
|
255
|
-
return me(t);
|
|
256
|
-
case "productListPreview":
|
|
257
|
-
return Se();
|
|
258
|
-
case "groupList":
|
|
259
|
-
return xe(t);
|
|
260
|
-
case "formGetInfo":
|
|
261
|
-
case "formTestDrive":
|
|
262
|
-
case "formServiceRequest":
|
|
263
|
-
case "launchFormPage":
|
|
264
|
-
return Pe(t);
|
|
265
|
-
case "launcherContent":
|
|
266
|
-
return Te(t);
|
|
267
|
-
case "handoff":
|
|
268
|
-
return Ce(t);
|
|
269
|
-
case "uiSpec":
|
|
270
|
-
return De(t);
|
|
271
|
-
default:
|
|
272
|
-
return null;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
function F(e) {
|
|
276
|
-
const t = e.type;
|
|
277
|
-
if (typeof t != "string") return !1;
|
|
278
|
-
switch (t) {
|
|
279
|
-
case "metadata":
|
|
280
|
-
return typeof e.sessionId == "string" && typeof e.model == "string";
|
|
281
|
-
case "text_chunk":
|
|
282
|
-
return typeof e.content == "string";
|
|
283
|
-
case "ui_spec": {
|
|
284
|
-
const r = e.widget;
|
|
285
|
-
if (r !== "chat" && r !== "qna" && r !== "simrel") return !1;
|
|
286
|
-
const n = k(e.spec);
|
|
287
|
-
return n ? typeof n.root == "string" && k(n.elements) !== null : !1;
|
|
288
|
-
}
|
|
289
|
-
case "action": {
|
|
290
|
-
const r = k(e.action);
|
|
291
|
-
return r !== null && typeof r.kind == "string";
|
|
292
|
-
}
|
|
293
|
-
case "error":
|
|
294
|
-
return typeof e.code == "string" && typeof e.message == "string";
|
|
295
|
-
case "done":
|
|
296
|
-
return !0;
|
|
297
|
-
default:
|
|
298
|
-
return !1;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
function Q(e) {
|
|
302
|
-
const t = u(e.payload.text, e.payload.plain_text) ?? "", r = u(e.payload.plain_text, e.payload.text) ?? t;
|
|
303
|
-
if (e.payload.is_error) return {
|
|
304
|
-
type: "error",
|
|
305
|
-
code: "BACKEND_ERROR",
|
|
306
|
-
message: r || "Backend returned an error"
|
|
307
|
-
};
|
|
308
|
-
const n = {
|
|
309
|
-
type: "text_chunk",
|
|
310
|
-
content: t,
|
|
311
|
-
final: !0
|
|
312
|
-
}, o = e.payload.product_mentions;
|
|
313
|
-
Array.isArray(o) && o.length > 0 && (n.productMentions = o.filter((c) => typeof c == "object" && c !== null && typeof c.sku == "string" && typeof c.short_name == "string"));
|
|
314
|
-
const i = e.payload.sku_to_product_item;
|
|
315
|
-
i && typeof i == "object" && !Array.isArray(i) && (n.skuToProductItem = i);
|
|
316
|
-
const s = e.payload.conversation_mode;
|
|
317
|
-
typeof s == "string" && s && (n.conversationMode = s);
|
|
318
|
-
const a = e.payload.render_hint;
|
|
319
|
-
return typeof a == "string" && a && (n.renderHint = a), e.payload.kvkk === !0 && (n.kvkk = !0), n;
|
|
320
|
-
}
|
|
321
|
-
function J(e) {
|
|
322
|
-
return O((e.payload.actions ?? []).map((t) => {
|
|
323
|
-
const r = u(t.title) ?? "", n = b(t.requestDetails, r), o = n ? {
|
|
324
|
-
label: r,
|
|
325
|
-
action: n
|
|
326
|
-
} : null;
|
|
327
|
-
return o ? (typeof t.icon == "string" && (o.icon = t.icon), typeof t.image == "string" && (o.image = t.image), o) : null;
|
|
328
|
-
}).filter(A), "chat");
|
|
329
|
-
}
|
|
330
|
-
function Y(e) {
|
|
331
|
-
const t = (Array.isArray(e.payload.style_variations) ? e.payload.style_variations : []).map((s) => {
|
|
332
|
-
const a = u(s.style_label);
|
|
333
|
-
if (!a) return null;
|
|
334
|
-
const c = u(s.style_mood), m = u(s.image_url ?? void 0), _ = (Array.isArray(s.product_list) ? s.product_list : []).map((p) => {
|
|
335
|
-
const l = k(p);
|
|
336
|
-
return l ? E(k(l.product_detail) ?? k(l.product) ?? l) : null;
|
|
337
|
-
}).filter(A), d = Array.isArray(s.recommendation_groups) ? s.recommendation_groups.map((p) => ({
|
|
338
|
-
label: u(p.label) ?? "",
|
|
339
|
-
reason: u(p.reason) ?? "",
|
|
340
|
-
skus: Array.isArray(p.skus) ? p.skus.filter((l) => typeof l == "string" && l.trim().length > 0) : []
|
|
341
|
-
})) : [];
|
|
342
|
-
return {
|
|
343
|
-
style_label: a,
|
|
344
|
-
style_mood: c ?? "",
|
|
345
|
-
...m ? { image_url: m } : {},
|
|
346
|
-
...typeof s.status == "string" ? { status: s.status } : {},
|
|
347
|
-
product_list: _,
|
|
348
|
-
recommendation_groups: d
|
|
349
|
-
};
|
|
350
|
-
}).filter(A), r = e.payload.product_list ?? [], n = W(e.payload.source) && t.length > 0 ? t[0].product_list : null, o = n ? Ee(n, "chat") : H(r, "chat");
|
|
351
|
-
o.panelHint = "panel";
|
|
352
|
-
const i = o.spec.elements[o.spec.root];
|
|
353
|
-
if (i) {
|
|
354
|
-
const s = {};
|
|
355
|
-
typeof e.payload.offset == "number" && (s.offset = e.payload.offset), typeof e.payload.end_of_list == "boolean" && (s.endOfList = e.payload.end_of_list), typeof e.payload.title == "string" && (s.panelTitle = e.payload.title), typeof e.payload.source == "string" && (s.source = e.payload.source), t.length > 0 && (s.styleVariations = t), e.payload.replace_panel === !0 && (s.replacePanel = !0), (e.payload.ranking_state === "pending" || e.payload.ranking_state === "final") && (s.rankingState = e.payload.ranking_state);
|
|
356
|
-
const a = e.payload.sequence_id ?? e.payload.search_id;
|
|
357
|
-
typeof a == "string" && a.length > 0 && (s.sequenceId = a), Object.keys(s).length > 0 && (i.props = {
|
|
358
|
-
...i.props,
|
|
359
|
-
...s
|
|
360
|
-
});
|
|
361
|
-
}
|
|
362
|
-
return o;
|
|
363
|
-
}
|
|
364
|
-
function X(e) {
|
|
365
|
-
const t = e.payload.productDetails;
|
|
366
|
-
if (!t) return Ie("chat");
|
|
367
|
-
const r = w(t);
|
|
368
|
-
return {
|
|
369
|
-
type: "ui_spec",
|
|
370
|
-
widget: "chat",
|
|
371
|
-
spec: {
|
|
372
|
-
root: "root",
|
|
373
|
-
elements: { root: {
|
|
374
|
-
type: "ProductDetailsPanel",
|
|
375
|
-
props: { product: {
|
|
376
|
-
...t,
|
|
377
|
-
...r
|
|
378
|
-
} }
|
|
379
|
-
} }
|
|
380
|
-
},
|
|
381
|
-
panelHint: "panel"
|
|
382
|
-
};
|
|
383
|
-
}
|
|
384
|
-
function Z(e) {
|
|
385
|
-
const t = H(e.payload.similarProducts ?? [], "chat"), r = t.spec.elements[t.spec.root];
|
|
386
|
-
return r && (r.props = {
|
|
387
|
-
...r.props,
|
|
388
|
-
similarsAppend: !0
|
|
389
|
-
}), {
|
|
390
|
-
...t,
|
|
391
|
-
panelHint: "panel"
|
|
392
|
-
};
|
|
393
|
-
}
|
|
394
|
-
function ee(e) {
|
|
395
|
-
const t = e.payload.multiple_product_details ?? [], r = e.payload, n = {
|
|
396
|
-
key_differences: r.key_differences,
|
|
397
|
-
recommended_choice: r.recommended_choice,
|
|
398
|
-
recommended_choice_sku: r.recommended_choice_sku,
|
|
399
|
-
special_considerations: r.special_considerations,
|
|
400
|
-
criteria_view: r.criteria_view,
|
|
401
|
-
criteria_view_short: r.criteria_view_short,
|
|
402
|
-
compared_field_names: r.compared_field_names,
|
|
403
|
-
winner_product: r.winner_product,
|
|
404
|
-
winner_hits: r.winner_hits,
|
|
405
|
-
...e.payload.product_comparison_framework ?? {}
|
|
406
|
-
}, o = e.payload.table, i = e.payload.features_list, s = [];
|
|
407
|
-
for (const y of t) {
|
|
408
|
-
const h = w(y);
|
|
409
|
-
s.push(h);
|
|
410
|
-
}
|
|
411
|
-
const a = te(o, s, n, i);
|
|
412
|
-
let c;
|
|
413
|
-
n?.recommended_choice_sku ? c = n.recommended_choice_sku : n?.winner_product && n.winner_product.length > 0 && (c = n.winner_product[0]?.product_detail?.sku ?? n.winner_product[0]?.sku);
|
|
414
|
-
const m = c ? s.find((y) => y.sku === c) ?? s[0] : s[0], _ = [];
|
|
415
|
-
if (Array.isArray(n?.key_differences))
|
|
416
|
-
for (const y of n.key_differences) typeof y == "string" && _.push(y);
|
|
417
|
-
const d = U(n?.special_considerations), p = n?.recommended_choice, l = n?.winner_hits, g = {};
|
|
418
|
-
for (const y of s) {
|
|
419
|
-
const h = y.sku;
|
|
420
|
-
h && (g[h] = {
|
|
421
|
-
title: y.name ?? h,
|
|
422
|
-
type: "launchSingleProduct",
|
|
423
|
-
payload: { sku: h }
|
|
424
|
-
});
|
|
425
|
-
}
|
|
426
|
-
const f = {
|
|
427
|
-
products: s,
|
|
428
|
-
attributes: a,
|
|
429
|
-
highlights: _,
|
|
430
|
-
productActions: g
|
|
431
|
-
};
|
|
432
|
-
return m && (f.recommended = m), d.length > 0 && (f.specialCases = d), p && (f.recommendedText = p), l && (f.winnerHits = l), typeof n?.key_differences == "string" && (f.keyDifferencesHtml = n.key_differences), n?.special_considerations && (f.specialConsiderations = n.special_considerations), {
|
|
433
|
-
type: "ui_spec",
|
|
434
|
-
widget: "chat",
|
|
435
|
-
spec: {
|
|
436
|
-
root: "root",
|
|
437
|
-
elements: { root: {
|
|
438
|
-
type: "ComparisonTable",
|
|
439
|
-
props: f
|
|
440
|
-
} }
|
|
441
|
-
},
|
|
442
|
-
panelHint: "panel"
|
|
443
|
-
};
|
|
444
|
-
}
|
|
445
|
-
function te(e, t, r, n) {
|
|
446
|
-
if (!e) return [];
|
|
447
|
-
const o = Object.entries(e);
|
|
448
|
-
if (o.length === 0) return [];
|
|
449
|
-
const i = o[0]?.[1];
|
|
450
|
-
if (Array.isArray(i)) {
|
|
451
|
-
const d = r.criteria_view ?? r.criteria_view_short ?? {}, p = r.compared_field_names ?? Object.keys(e), l = [];
|
|
452
|
-
for (const g of p) {
|
|
453
|
-
const f = e[g];
|
|
454
|
-
if (!f || !Array.isArray(f)) continue;
|
|
455
|
-
const y = d[g] ?? g;
|
|
456
|
-
l.push({
|
|
457
|
-
label: y,
|
|
458
|
-
values: f.map((h) => typeof h == "string" ? h : String(h ?? ""))
|
|
459
|
-
});
|
|
460
|
-
}
|
|
461
|
-
return l;
|
|
462
|
-
}
|
|
463
|
-
const s = e, a = t.map((d) => String(d.sku ?? "")).filter((d) => d.length > 0), c = r.criteria_view ?? r.criteria_view_short ?? {}, m = (n && n.length > 0 ? n : r.compared_field_names && r.compared_field_names.length > 0 ? r.compared_field_names : oe(s)).filter((d) => d !== "name" && d !== "name_short" && !d.endsWith("_short")), _ = [];
|
|
464
|
-
for (const d of m) {
|
|
465
|
-
const p = a.map((g) => {
|
|
466
|
-
const f = s[g];
|
|
467
|
-
if (!f || typeof f != "object") return "";
|
|
468
|
-
const y = f[`${d}_short`], h = f[d];
|
|
469
|
-
return re(y ?? h);
|
|
470
|
-
});
|
|
471
|
-
if (p.every((g) => g.length === 0)) continue;
|
|
472
|
-
const l = c[d] ?? d;
|
|
473
|
-
_.push({
|
|
474
|
-
label: l,
|
|
475
|
-
values: p
|
|
476
|
-
});
|
|
477
|
-
}
|
|
478
|
-
return _;
|
|
479
|
-
}
|
|
480
|
-
function oe(e) {
|
|
481
|
-
const t = [], r = /* @__PURE__ */ new Set();
|
|
482
|
-
for (const n of Object.values(e))
|
|
483
|
-
if (!(!n || typeof n != "object"))
|
|
484
|
-
for (const o of Object.keys(n))
|
|
485
|
-
r.has(o) || (r.add(o), t.push(o));
|
|
486
|
-
return t;
|
|
487
|
-
}
|
|
488
|
-
function re(e) {
|
|
489
|
-
return typeof e == "string" ? e : typeof e == "number" || typeof e == "boolean" ? String(e) : "";
|
|
490
|
-
}
|
|
491
|
-
function ne(e) {
|
|
492
|
-
return {
|
|
493
|
-
type: "metadata",
|
|
494
|
-
sessionId: "",
|
|
495
|
-
model: "",
|
|
496
|
-
meta: {
|
|
497
|
-
panel: e.payload.panel,
|
|
498
|
-
messages: e.payload.messages,
|
|
499
|
-
message_id: e.payload.message_id
|
|
500
|
-
}
|
|
501
|
-
};
|
|
502
|
-
}
|
|
503
|
-
function ie() {
|
|
504
|
-
return { type: "done" };
|
|
505
|
-
}
|
|
506
|
-
function se(e) {
|
|
507
|
-
return {
|
|
508
|
-
type: "metadata",
|
|
509
|
-
sessionId: "",
|
|
510
|
-
model: "",
|
|
511
|
-
meta: {
|
|
512
|
-
loading: !0,
|
|
513
|
-
loadingText: e.payload.text,
|
|
514
|
-
thinkingMessages: e.payload.thinking_messages,
|
|
515
|
-
dynamicLoading: e.payload.is_dynamic === !0
|
|
516
|
-
}
|
|
517
|
-
};
|
|
518
|
-
}
|
|
519
|
-
function ae(e) {
|
|
520
|
-
return {
|
|
521
|
-
type: "metadata",
|
|
522
|
-
sessionId: "",
|
|
523
|
-
model: "",
|
|
524
|
-
meta: {
|
|
525
|
-
loading: !0,
|
|
526
|
-
panelLoading: !0,
|
|
527
|
-
panelPendingType: e.payload?.pending_type,
|
|
528
|
-
loadingText: e.payload?.text
|
|
529
|
-
}
|
|
530
|
-
};
|
|
531
|
-
}
|
|
532
|
-
function ce(e) {
|
|
533
|
-
return {
|
|
534
|
-
type: "metadata",
|
|
535
|
-
sessionId: "",
|
|
536
|
-
model: "",
|
|
537
|
-
meta: {
|
|
538
|
-
loading: !0,
|
|
539
|
-
similarPanelLoading: !0,
|
|
540
|
-
panelPendingType: e.payload?.pending_type,
|
|
541
|
-
loadingText: e.payload?.text
|
|
542
|
-
}
|
|
543
|
-
};
|
|
544
|
-
}
|
|
545
|
-
function ue(e) {
|
|
546
|
-
const t = u(e.payload.url);
|
|
547
|
-
return t ? {
|
|
548
|
-
type: "action",
|
|
549
|
-
action: {
|
|
550
|
-
kind: "navigate",
|
|
551
|
-
url: t,
|
|
552
|
-
newTab: e.payload.new_tab === !0
|
|
553
|
-
}
|
|
554
|
-
} : {
|
|
555
|
-
type: "metadata",
|
|
556
|
-
sessionId: "",
|
|
557
|
-
model: "",
|
|
558
|
-
meta: {
|
|
559
|
-
redirect: e.payload,
|
|
560
|
-
redirectTarget: u(e.payload.to)
|
|
561
|
-
}
|
|
562
|
-
};
|
|
563
|
-
}
|
|
564
|
-
function de(e) {
|
|
565
|
-
return {
|
|
566
|
-
type: "error",
|
|
567
|
-
code: "BACKEND_ERROR",
|
|
568
|
-
message: u(e.payload?.text, e.payload?.message, e.payload?.error) ?? "Backend returned an error"
|
|
569
|
-
};
|
|
570
|
-
}
|
|
571
|
-
function le(e) {
|
|
572
|
-
return {
|
|
573
|
-
type: "metadata",
|
|
574
|
-
sessionId: "",
|
|
575
|
-
model: "",
|
|
576
|
-
meta: { noop: !0 }
|
|
577
|
-
};
|
|
578
|
-
}
|
|
579
|
-
function pe(e) {
|
|
580
|
-
const t = e.payload ?? {};
|
|
581
|
-
if (Array.isArray(t.action_list)) {
|
|
582
|
-
const o = { action_list: t.action_list }, i = typeof t.type == "string" ? t.type : void 0, s = typeof t.theme == "string" ? t.theme : void 0;
|
|
583
|
-
return i !== void 0 && (o.type = i), s !== void 0 && (o.theme = s), D({
|
|
584
|
-
type: "quick_qna",
|
|
585
|
-
payload: o
|
|
586
|
-
});
|
|
587
|
-
}
|
|
588
|
-
const r = k(t.action);
|
|
589
|
-
if (r) {
|
|
590
|
-
const o = { action: r }, i = typeof t.text == "string" ? t.text : void 0, s = typeof t.image_url == "string" ? t.image_url : void 0, a = typeof t.theme == "string" ? t.theme : void 0;
|
|
591
|
-
return i !== void 0 && (o.text = i), s !== void 0 && (o.image_url = s), a !== void 0 && (o.theme = a), L({
|
|
592
|
-
type: "text_image",
|
|
593
|
-
payload: o
|
|
594
|
-
});
|
|
595
|
-
}
|
|
596
|
-
const n = typeof t.text == "string" ? t.text : "";
|
|
597
|
-
if (n) {
|
|
598
|
-
const o = { text: n }, i = typeof t.type == "string" ? t.type : void 0, s = typeof t.theme == "string" ? t.theme : void 0, a = k(t.payload) ?? void 0;
|
|
599
|
-
return i !== void 0 && (o.type = i), a !== void 0 && (o.payload = a), s !== void 0 && (o.theme = s), T({
|
|
600
|
-
type: "text",
|
|
601
|
-
payload: o
|
|
602
|
-
});
|
|
603
|
-
}
|
|
604
|
-
return {
|
|
605
|
-
type: "metadata",
|
|
606
|
-
sessionId: "",
|
|
607
|
-
model: "",
|
|
608
|
-
meta: { launcherAction: t }
|
|
609
|
-
};
|
|
610
|
-
}
|
|
611
|
-
function T(e) {
|
|
612
|
-
const t = { text: u(e.payload.text) ?? "" };
|
|
613
|
-
return typeof e.payload.theme == "string" && (t.theme = e.payload.theme), e.payload.payload !== void 0 && (t.payload = e.payload.payload), {
|
|
614
|
-
type: "ui_spec",
|
|
615
|
-
widget: "qna",
|
|
616
|
-
spec: {
|
|
617
|
-
root: "root",
|
|
618
|
-
elements: { root: {
|
|
619
|
-
type: "QuestionHeading",
|
|
620
|
-
props: t
|
|
621
|
-
} }
|
|
622
|
-
}
|
|
623
|
-
};
|
|
624
|
-
}
|
|
625
|
-
function fe(e) {
|
|
626
|
-
return ve(e.payload, "qna");
|
|
627
|
-
}
|
|
628
|
-
function L(e) {
|
|
629
|
-
const t = u(e.payload.text) ?? "", r = b(e.payload.action, t);
|
|
630
|
-
if (r) {
|
|
631
|
-
const o = {
|
|
632
|
-
label: t || r.title,
|
|
633
|
-
action: r
|
|
634
|
-
};
|
|
635
|
-
return typeof e.payload.image_url == "string" && (o.image = e.payload.image_url), typeof e.payload.theme == "string" && (o.theme = e.payload.theme), {
|
|
636
|
-
type: "ui_spec",
|
|
637
|
-
widget: "qna",
|
|
638
|
-
spec: {
|
|
639
|
-
root: "root",
|
|
640
|
-
elements: { root: {
|
|
641
|
-
type: "ActionButton",
|
|
642
|
-
props: o
|
|
643
|
-
} }
|
|
644
|
-
}
|
|
645
|
-
};
|
|
646
|
-
}
|
|
647
|
-
const n = { text: t };
|
|
648
|
-
return typeof e.payload.theme == "string" && (n.theme = e.payload.theme), T({
|
|
649
|
-
type: "text",
|
|
650
|
-
payload: n
|
|
651
|
-
});
|
|
652
|
-
}
|
|
653
|
-
function D(e) {
|
|
654
|
-
return O((e.payload.action_list ?? []).map((t) => {
|
|
655
|
-
const r = u(t.title) ?? "", n = b(t.requestDetails, r), o = n ? {
|
|
656
|
-
label: r,
|
|
657
|
-
action: n
|
|
658
|
-
} : null;
|
|
659
|
-
return o ? (typeof t.icon == "string" && (o.icon = t.icon), typeof t.image == "string" && (o.image = t.image), o) : null;
|
|
660
|
-
}).filter(A), "qna");
|
|
661
|
-
}
|
|
662
|
-
function ye(e) {
|
|
663
|
-
const t = { reviews: (e.payload.reviews ?? []).map((r) => {
|
|
664
|
-
const n = {};
|
|
665
|
-
return typeof r.review_class == "string" && (n.review_class = r.review_class), typeof r.review_text == "string" && (n.review_text = r.review_text), (typeof r.review_rating == "string" || typeof r.review_rating == "number") && (n.review_rating = r.review_rating), typeof r.review_tag == "string" && (n.review_tag = r.review_tag), n;
|
|
666
|
-
}) };
|
|
667
|
-
return typeof e.payload.sku == "string" && (t.sku = e.payload.sku), {
|
|
668
|
-
type: "ui_spec",
|
|
669
|
-
widget: "chat",
|
|
670
|
-
spec: {
|
|
671
|
-
root: "root",
|
|
672
|
-
elements: { root: {
|
|
673
|
-
type: "ReviewHighlights",
|
|
674
|
-
props: t
|
|
675
|
-
} }
|
|
676
|
-
}
|
|
677
|
-
};
|
|
678
|
-
}
|
|
679
|
-
function ge(e) {
|
|
680
|
-
const t = {};
|
|
681
|
-
return Array.isArray(e.payload.pros) && (t.pros = e.payload.pros), Array.isArray(e.payload.cons) && (t.cons = e.payload.cons), typeof e.payload.product_name == "string" && (t.productName = e.payload.product_name), {
|
|
682
|
-
type: "ui_spec",
|
|
683
|
-
widget: "chat",
|
|
684
|
-
spec: {
|
|
685
|
-
root: "root",
|
|
686
|
-
elements: { root: {
|
|
687
|
-
type: "ProsAndCons",
|
|
688
|
-
props: t
|
|
689
|
-
} }
|
|
690
|
-
}
|
|
691
|
-
};
|
|
692
|
-
}
|
|
693
|
-
function me(e) {
|
|
694
|
-
return {
|
|
695
|
-
type: "metadata",
|
|
696
|
-
sessionId: "",
|
|
697
|
-
model: "",
|
|
698
|
-
meta: { visitorDataResponse: e.payload }
|
|
699
|
-
};
|
|
700
|
-
}
|
|
701
|
-
function _e(e) {
|
|
702
|
-
const t = e.payload.product_suggestions ?? [], r = [];
|
|
703
|
-
for (let n = 0; n < t.length; n++) {
|
|
704
|
-
const o = t[n];
|
|
705
|
-
if (!o) continue;
|
|
706
|
-
const i = Ne(o);
|
|
707
|
-
if (!i) continue;
|
|
708
|
-
const s = { product: i }, a = b(o.requestDetails, i.name);
|
|
709
|
-
a && (s.action = a), typeof o.role == "string" && (s.role = o.role), typeof o.reason == "string" && (s.reason = o.reason), typeof o.review_highlight == "string" && (s.reviewHighlight = o.review_highlight), Array.isArray(o.labels) && (s.labels = o.labels), typeof o.expert_quality_score == "number" && (s.expertQualityScore = o.expert_quality_score), r.push(s);
|
|
710
|
-
}
|
|
711
|
-
return r.length === 0 ? {
|
|
712
|
-
type: "metadata",
|
|
713
|
-
sessionId: "",
|
|
714
|
-
model: "",
|
|
715
|
-
meta: { aiProductSuggestions: e.payload.product_suggestions ?? [] }
|
|
716
|
-
} : {
|
|
717
|
-
type: "ui_spec",
|
|
718
|
-
widget: "chat",
|
|
719
|
-
spec: {
|
|
720
|
-
root: "root",
|
|
721
|
-
elements: { root: {
|
|
722
|
-
type: "AITopPicks",
|
|
723
|
-
props: { suggestions: r }
|
|
724
|
-
} }
|
|
725
|
-
}
|
|
726
|
-
};
|
|
727
|
-
}
|
|
728
|
-
function he(e) {
|
|
729
|
-
const t = e.payload.product_groupings ?? [], r = [], n = [];
|
|
730
|
-
for (let o = 0; o < t.length; o++) {
|
|
731
|
-
const i = t[o];
|
|
732
|
-
if (!i) continue;
|
|
733
|
-
const s = u(i.name) ?? "", a = u(i.description), c = u(i.highlight), m = Array.isArray(i.labels) ? U(i.labels) : [], _ = u(i.sku, i.repr_sku), d = u(i.image, i.repr_image), p = ke(i, s, _), l = (Array.isArray(i.group_products) ? i.group_products : []).map((y) => {
|
|
734
|
-
const h = k(y);
|
|
735
|
-
return h ? E(h) : null;
|
|
736
|
-
}).filter(A), g = d ?? u(...l.map((y) => y.imageUrl));
|
|
737
|
-
if (s && l.length > 0) {
|
|
738
|
-
const y = {
|
|
739
|
-
groupName: s,
|
|
740
|
-
products: l
|
|
741
|
-
};
|
|
742
|
-
g && (y.image = g), a && (y.description = a), c && (y.highlight = c), m.length > 0 && (y.labels = m), r.push(y);
|
|
743
|
-
}
|
|
744
|
-
if (!p) continue;
|
|
745
|
-
const f = {
|
|
746
|
-
name: s,
|
|
747
|
-
action: p
|
|
748
|
-
};
|
|
749
|
-
m.length > 0 && (f.labels = m), d !== void 0 && (f.image = d), n.push(f);
|
|
750
|
-
}
|
|
751
|
-
return r.length > 0 ? {
|
|
752
|
-
type: "ui_spec",
|
|
753
|
-
widget: "chat",
|
|
754
|
-
spec: {
|
|
755
|
-
root: "root",
|
|
756
|
-
elements: { root: {
|
|
757
|
-
type: "CategoriesContainer",
|
|
758
|
-
props: { groups: r }
|
|
759
|
-
} }
|
|
760
|
-
},
|
|
761
|
-
panelHint: "panel"
|
|
762
|
-
} : n.length === 0 ? {
|
|
763
|
-
type: "metadata",
|
|
764
|
-
sessionId: "",
|
|
765
|
-
model: "",
|
|
766
|
-
meta: { aiProductGroupings: e.payload.product_groupings ?? [] }
|
|
767
|
-
} : {
|
|
768
|
-
type: "ui_spec",
|
|
769
|
-
widget: "chat",
|
|
770
|
-
spec: {
|
|
771
|
-
root: "root",
|
|
772
|
-
elements: { root: {
|
|
773
|
-
type: "AIGroupingCards",
|
|
774
|
-
props: { entries: n }
|
|
775
|
-
} }
|
|
776
|
-
}
|
|
777
|
-
};
|
|
778
|
-
}
|
|
779
|
-
function ke(e, t, r) {
|
|
780
|
-
const n = k(e.requestDetails);
|
|
781
|
-
if (n) {
|
|
782
|
-
if (n.type !== "findSimilar") return b(n, t);
|
|
783
|
-
const s = { ...k(n.payload) ?? {} };
|
|
784
|
-
r && !P(s.sku) && (s.sku = r);
|
|
785
|
-
const a = C(e.group_skus);
|
|
786
|
-
return a.length > 0 && (s.group_skus = a), b({
|
|
787
|
-
...n,
|
|
788
|
-
payload: R(s)
|
|
789
|
-
}, t);
|
|
790
|
-
}
|
|
791
|
-
const o = {};
|
|
792
|
-
r && (o.sku = r);
|
|
793
|
-
const i = C(e.group_skus);
|
|
794
|
-
return i.length > 0 && (o.group_skus = i), Object.keys(o).length === 0 ? null : b({
|
|
795
|
-
type: "findSimilar",
|
|
796
|
-
payload: R(o)
|
|
797
|
-
}, t);
|
|
798
|
-
}
|
|
799
|
-
function be(e) {
|
|
800
|
-
const t = e.payload.suggested_searches ?? [], r = [];
|
|
801
|
-
for (let n = 0; n < t.length; n++) {
|
|
802
|
-
const o = t[n];
|
|
803
|
-
if (!o) continue;
|
|
804
|
-
const i = u(o.short_name, o.chosen_attribute, o.detailed_user_message) ?? `Search ${n + 1}`, s = {}, a = u(o.detailed_user_message);
|
|
805
|
-
a && (s.text = a);
|
|
806
|
-
const c = k(k(o.requestDetails)?.payload), m = c?.group_skus;
|
|
807
|
-
o.group_skus && Array.isArray(o.group_skus) ? s.group_skus = o.group_skus : Array.isArray(m) && (s.group_skus = m.filter((h) => typeof h == "string"));
|
|
808
|
-
const _ = u(o.sku, o.representative_product_sku, c?.sku);
|
|
809
|
-
_ && (s.sku = _), s.is_suggested_text = 1;
|
|
810
|
-
const d = {
|
|
811
|
-
type: "inputText",
|
|
812
|
-
payload: s
|
|
813
|
-
}, p = b(o.requestDetails, i), l = p?.type === "findSimilar" && typeof s.text == "string" ? b(d, i) : p ?? b(d, i);
|
|
814
|
-
if (!l) continue;
|
|
815
|
-
const g = {
|
|
816
|
-
shortName: i,
|
|
817
|
-
action: l
|
|
818
|
-
}, f = u(o.detailed_user_message);
|
|
819
|
-
f && f !== i && (g.detailedMessage = f);
|
|
820
|
-
const y = V(o);
|
|
821
|
-
y && y !== i && y !== (f ?? "") && (g.whyDifferent = y), typeof o.image == "string" && (g.image = o.image), r.push(g);
|
|
822
|
-
}
|
|
823
|
-
return r.length === 0 ? {
|
|
824
|
-
type: "metadata",
|
|
825
|
-
sessionId: "",
|
|
826
|
-
model: "",
|
|
827
|
-
meta: { aiSuggestedSearches: e.payload.suggested_searches ?? [] }
|
|
828
|
-
} : {
|
|
829
|
-
type: "ui_spec",
|
|
830
|
-
widget: "chat",
|
|
831
|
-
spec: {
|
|
832
|
-
root: "root",
|
|
833
|
-
elements: { root: {
|
|
834
|
-
type: "AISuggestedSearchCards",
|
|
835
|
-
props: { entries: r }
|
|
836
|
-
} }
|
|
837
|
-
}
|
|
838
|
-
};
|
|
839
|
-
}
|
|
840
|
-
function we(e) {
|
|
841
|
-
const t = e.payload, r = b(t.requestDetails ?? t.request_details, u(t.review_count, t.reviewCount, t.text, t.title) ?? "Show product reviews");
|
|
842
|
-
if (!r) return {
|
|
843
|
-
type: "metadata",
|
|
844
|
-
sessionId: "",
|
|
845
|
-
model: "",
|
|
846
|
-
meta: { groundingReview: t }
|
|
847
|
-
};
|
|
848
|
-
const n = { action: r };
|
|
849
|
-
return t.title && (n.title = t.title), t.text && (n.text = t.text), t.review_count ? n.reviewCount = t.review_count : typeof t.reviewCount == "string" && t.reviewCount.trim() && (n.reviewCount = t.reviewCount), {
|
|
850
|
-
type: "ui_spec",
|
|
851
|
-
widget: "chat",
|
|
852
|
-
spec: {
|
|
853
|
-
root: "root",
|
|
854
|
-
elements: { root: {
|
|
855
|
-
type: "GroundingReviewCard",
|
|
856
|
-
props: n
|
|
857
|
-
} }
|
|
858
|
-
}
|
|
859
|
-
};
|
|
860
|
-
}
|
|
861
|
-
function Se() {
|
|
862
|
-
return {
|
|
863
|
-
type: "metadata",
|
|
864
|
-
sessionId: "",
|
|
865
|
-
model: "",
|
|
866
|
-
meta: { analyzeAnimation: !0 }
|
|
867
|
-
};
|
|
868
|
-
}
|
|
869
|
-
function Ae(e) {
|
|
870
|
-
return {
|
|
871
|
-
type: "metadata",
|
|
872
|
-
sessionId: "",
|
|
873
|
-
model: "",
|
|
874
|
-
meta: { voice: e.payload }
|
|
875
|
-
};
|
|
876
|
-
}
|
|
877
|
-
function xe(e) {
|
|
878
|
-
const t = e.payload.group_list ?? [], r = [];
|
|
879
|
-
for (const o of t) {
|
|
880
|
-
const i = o.group_name ?? "", s = (o.product_list ?? []).map(w);
|
|
881
|
-
r.push({
|
|
882
|
-
groupName: i,
|
|
883
|
-
products: s
|
|
884
|
-
});
|
|
885
|
-
}
|
|
886
|
-
const n = [];
|
|
887
|
-
for (const o of e.payload.filter_tags ?? []) {
|
|
888
|
-
const i = o.title ?? "";
|
|
889
|
-
if (!i) continue;
|
|
890
|
-
const s = b(o.requestDetails, i), a = { title: i };
|
|
891
|
-
s && (a.action = s), n.push(a);
|
|
892
|
-
}
|
|
893
|
-
return {
|
|
894
|
-
type: "ui_spec",
|
|
895
|
-
widget: "chat",
|
|
896
|
-
spec: {
|
|
897
|
-
root: "root",
|
|
898
|
-
elements: { root: {
|
|
899
|
-
type: "CategoriesContainer",
|
|
900
|
-
props: {
|
|
901
|
-
groups: r,
|
|
902
|
-
filterTags: n
|
|
903
|
-
}
|
|
904
|
-
} }
|
|
905
|
-
},
|
|
906
|
-
panelHint: "panel"
|
|
907
|
-
};
|
|
908
|
-
}
|
|
909
|
-
function Pe(e) {
|
|
910
|
-
return {
|
|
911
|
-
type: "metadata",
|
|
912
|
-
sessionId: "",
|
|
913
|
-
model: "",
|
|
914
|
-
meta: {
|
|
915
|
-
formType: e.type,
|
|
916
|
-
formPayload: e.payload ?? {}
|
|
917
|
-
}
|
|
918
|
-
};
|
|
919
|
-
}
|
|
920
|
-
function Ce(e) {
|
|
921
|
-
const t = {};
|
|
922
|
-
return typeof e.payload?.summary == "string" && (t.summary = e.payload.summary), Array.isArray(e.payload?.products_discussed) && (t.products_discussed = e.payload.products_discussed), typeof e.payload?.user_sentiment == "string" && (t.user_sentiment = e.payload.user_sentiment), {
|
|
923
|
-
type: "ui_spec",
|
|
924
|
-
widget: "chat",
|
|
925
|
-
spec: {
|
|
926
|
-
root: "root",
|
|
927
|
-
elements: { root: {
|
|
928
|
-
type: "HandoffNotice",
|
|
929
|
-
props: t
|
|
930
|
-
} }
|
|
931
|
-
}
|
|
932
|
-
};
|
|
933
|
-
}
|
|
934
|
-
function Te(e) {
|
|
935
|
-
return {
|
|
936
|
-
type: "metadata",
|
|
937
|
-
sessionId: "",
|
|
938
|
-
model: "",
|
|
939
|
-
meta: { launcherContent: e.payload ?? {} }
|
|
940
|
-
};
|
|
941
|
-
}
|
|
942
|
-
function q(e, t) {
|
|
943
|
-
const r = {
|
|
944
|
-
product: e,
|
|
945
|
-
index: t
|
|
946
|
-
}, n = e, o = typeof n.sku == "string" ? n.sku : void 0;
|
|
947
|
-
return o && (r.action = {
|
|
948
|
-
title: typeof n.name == "string" ? n.name : "",
|
|
949
|
-
type: "launchSingleProduct",
|
|
950
|
-
payload: { sku: o }
|
|
951
|
-
}), {
|
|
952
|
-
type: "ProductCard",
|
|
953
|
-
props: r
|
|
954
|
-
};
|
|
955
|
-
}
|
|
956
|
-
function O(e, t) {
|
|
957
|
-
const r = {}, n = [];
|
|
958
|
-
for (let o = 0; o < e.length; o++) {
|
|
959
|
-
const i = e[o];
|
|
960
|
-
if (!i) continue;
|
|
961
|
-
const s = `action-${o}`;
|
|
962
|
-
n.push(s);
|
|
963
|
-
const a = {
|
|
964
|
-
label: i.label,
|
|
965
|
-
action: i.action
|
|
966
|
-
};
|
|
967
|
-
i.icon !== void 0 && (a.icon = i.icon), i.image !== void 0 && (a.image = i.image), i.description !== void 0 && (a.description = i.description), r[s] = {
|
|
968
|
-
type: "ActionButton",
|
|
969
|
-
props: a
|
|
970
|
-
};
|
|
971
|
-
}
|
|
972
|
-
return r.root = {
|
|
973
|
-
type: "ActionButtons",
|
|
974
|
-
props: { buttons: e.map((o) => {
|
|
975
|
-
const i = {
|
|
976
|
-
label: o.label,
|
|
977
|
-
action: o.action
|
|
978
|
-
};
|
|
979
|
-
return o.image !== void 0 && (i.image = o.image), o.description !== void 0 && (i.description = o.description), o.icon !== void 0 && (i.icon = o.icon), i;
|
|
980
|
-
}) },
|
|
981
|
-
children: n
|
|
982
|
-
}, {
|
|
983
|
-
type: "ui_spec",
|
|
984
|
-
widget: t,
|
|
985
|
-
spec: {
|
|
986
|
-
root: "root",
|
|
987
|
-
elements: r
|
|
988
|
-
}
|
|
989
|
-
};
|
|
990
|
-
}
|
|
991
|
-
function H(e, t) {
|
|
992
|
-
const r = {}, n = [];
|
|
993
|
-
for (let o = 0; o < e.length; o++) {
|
|
994
|
-
const i = e[o];
|
|
995
|
-
if (!i) continue;
|
|
996
|
-
const s = w(i), a = `product-${o}`;
|
|
997
|
-
n.push(a), r[a] = q(s, o);
|
|
998
|
-
}
|
|
999
|
-
return r.root = {
|
|
1000
|
-
type: "ProductGrid",
|
|
1001
|
-
props: { layout: "grid" },
|
|
1002
|
-
children: n
|
|
1003
|
-
}, {
|
|
1004
|
-
type: "ui_spec",
|
|
1005
|
-
widget: t,
|
|
1006
|
-
spec: {
|
|
1007
|
-
root: "root",
|
|
1008
|
-
elements: r
|
|
1009
|
-
}
|
|
1010
|
-
};
|
|
1011
|
-
}
|
|
1012
|
-
function Ee(e, t) {
|
|
1013
|
-
const r = {}, n = [];
|
|
1014
|
-
for (let o = 0; o < e.length; o++) {
|
|
1015
|
-
const i = e[o];
|
|
1016
|
-
if (!i) continue;
|
|
1017
|
-
const s = `product-${o}`;
|
|
1018
|
-
n.push(s), r[s] = q(i, o);
|
|
1019
|
-
}
|
|
1020
|
-
return r.root = {
|
|
1021
|
-
type: "ProductGrid",
|
|
1022
|
-
props: { layout: "grid" },
|
|
1023
|
-
children: n
|
|
1024
|
-
}, {
|
|
1025
|
-
type: "ui_spec",
|
|
1026
|
-
widget: t,
|
|
1027
|
-
spec: {
|
|
1028
|
-
root: "root",
|
|
1029
|
-
elements: r
|
|
1030
|
-
}
|
|
1031
|
-
};
|
|
1032
|
-
}
|
|
1033
|
-
function ve(e, t) {
|
|
1034
|
-
return {
|
|
1035
|
-
type: "ui_spec",
|
|
1036
|
-
widget: t,
|
|
1037
|
-
spec: {
|
|
1038
|
-
root: "root",
|
|
1039
|
-
elements: { root: {
|
|
1040
|
-
type: "ProductCard",
|
|
1041
|
-
props: {
|
|
1042
|
-
product: w(e),
|
|
1043
|
-
index: 0
|
|
1044
|
-
}
|
|
1045
|
-
} }
|
|
1046
|
-
}
|
|
1047
|
-
};
|
|
1048
|
-
}
|
|
1049
|
-
function Ie(e) {
|
|
1050
|
-
return {
|
|
1051
|
-
type: "ui_spec",
|
|
1052
|
-
widget: e,
|
|
1053
|
-
spec: {
|
|
1054
|
-
root: "root",
|
|
1055
|
-
elements: { root: {
|
|
1056
|
-
type: "ActionButtons",
|
|
1057
|
-
props: { buttons: [] },
|
|
1058
|
-
children: []
|
|
1059
|
-
} }
|
|
1060
|
-
}
|
|
1061
|
-
};
|
|
1062
|
-
}
|
|
1063
|
-
function Ne(e) {
|
|
1064
|
-
const t = u(e.sku), r = u(e.short_name), n = { ...k(e.product_item) ?? e }, o = u(e.discount_reason, e.discountReason);
|
|
1065
|
-
return o && !u(n.discount_reason, n.discountReason) && (n.discount_reason = o), E(n, t, r);
|
|
1066
|
-
}
|
|
1067
|
-
function E(e, t, r) {
|
|
1068
|
-
const n = u(e.sku, t), o = u(e.name, r);
|
|
1069
|
-
if (!n || !o) return null;
|
|
1070
|
-
const i = {
|
|
1071
|
-
sku: n,
|
|
1072
|
-
name: o
|
|
1073
|
-
}, s = u(e.brand);
|
|
1074
|
-
s && (i.brand = s);
|
|
1075
|
-
const a = u(e.url);
|
|
1076
|
-
a && (i.url = a);
|
|
1077
|
-
const c = Re(e.images);
|
|
1078
|
-
if (c.length > 0) i.images = c;
|
|
1079
|
-
else {
|
|
1080
|
-
const f = u(e.image, e.image_url, e.imageUrl);
|
|
1081
|
-
f && (i.images = [f]);
|
|
1082
|
-
}
|
|
1083
|
-
const m = S(e.price_discounted);
|
|
1084
|
-
m !== void 0 && (i.price_discounted = m);
|
|
1085
|
-
const _ = S(e.price);
|
|
1086
|
-
_ !== void 0 && (i.price = _);
|
|
1087
|
-
const d = S(e.rating);
|
|
1088
|
-
d !== void 0 && (i.rating = d);
|
|
1089
|
-
const p = S(e.review_count) ?? S(e.reviewCount);
|
|
1090
|
-
p !== void 0 && (i.review_count = p);
|
|
1091
|
-
const l = u(e.cart_code, e.cartCode);
|
|
1092
|
-
l && (i.cart_code = l), typeof e.in_stock == "boolean" && (i.in_stock = e.in_stock), typeof e.inStock == "boolean" && (i.in_stock = e.inStock);
|
|
1093
|
-
const g = u(e.discount_reason, e.discountReason);
|
|
1094
|
-
return g && (i.discount_reason = g), w(i);
|
|
1095
|
-
}
|
|
1096
|
-
function b(e, t) {
|
|
1097
|
-
const r = k(e);
|
|
1098
|
-
if (!r) return null;
|
|
1099
|
-
const n = r.type;
|
|
1100
|
-
if (typeof n != "string" || n.length === 0) return null;
|
|
1101
|
-
const o = {
|
|
1102
|
-
title: t || n,
|
|
1103
|
-
type: n
|
|
1104
|
-
};
|
|
1105
|
-
return r.payload !== void 0 && (o.payload = r.payload), o;
|
|
1106
|
-
}
|
|
1107
|
-
function k(e) {
|
|
1108
|
-
return !e || typeof e != "object" || Array.isArray(e) ? null : e;
|
|
1109
|
-
}
|
|
1110
|
-
function u(...e) {
|
|
1111
|
-
for (const t of e) if (typeof t == "string") {
|
|
1112
|
-
const r = t.trim();
|
|
1113
|
-
if (r.length > 0) return r;
|
|
1114
|
-
}
|
|
1115
|
-
}
|
|
1116
|
-
function Re(e) {
|
|
1117
|
-
return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.length > 0) : [];
|
|
1118
|
-
}
|
|
1119
|
-
function U(e) {
|
|
1120
|
-
if (typeof e == "string") {
|
|
1121
|
-
const t = e.trim();
|
|
1122
|
-
return t ? [t] : [];
|
|
1123
|
-
}
|
|
1124
|
-
return Array.isArray(e) ? e.filter((t) => typeof t == "string").map((t) => t.trim()).filter((t) => t.length > 0) : [];
|
|
1125
|
-
}
|
|
1126
|
-
function S(e) {
|
|
1127
|
-
if (typeof e == "number" && Number.isFinite(e)) return e;
|
|
1128
|
-
if (typeof e == "string") {
|
|
1129
|
-
let t;
|
|
1130
|
-
e.includes(".") && e.includes(",") ? t = e.replace(/\./g, "").replace(",", ".") : t = e.replace(",", ".");
|
|
1131
|
-
const r = Number(t);
|
|
1132
|
-
if (Number.isFinite(r)) return r;
|
|
1133
|
-
}
|
|
1134
|
-
}
|
|
1135
|
-
function A(e) {
|
|
1136
|
-
return e != null;
|
|
1137
|
-
}
|
|
1138
|
-
var Le = /* @__PURE__ */ new Set([
|
|
1139
|
-
"sku",
|
|
1140
|
-
"name",
|
|
1141
|
-
"brand",
|
|
1142
|
-
"images",
|
|
1143
|
-
"price",
|
|
1144
|
-
"price_discounted",
|
|
1145
|
-
"price_discount_rate",
|
|
1146
|
-
"price_currency",
|
|
1147
|
-
"discount_reason",
|
|
1148
|
-
"url",
|
|
1149
|
-
"rating",
|
|
1150
|
-
"review_count",
|
|
1151
|
-
"cart_code",
|
|
1152
|
-
"in_stock",
|
|
1153
|
-
"description",
|
|
1154
|
-
"description_html",
|
|
1155
|
-
"features",
|
|
1156
|
-
"specifications",
|
|
1157
|
-
"short_name",
|
|
1158
|
-
"category_ids",
|
|
1159
|
-
"category_names",
|
|
1160
|
-
"variants",
|
|
1161
|
-
"facet_hits",
|
|
1162
|
-
"promotions"
|
|
1163
|
-
]);
|
|
1164
|
-
function w(e) {
|
|
1165
|
-
const t = e.price_discounted != null && e.price_discounted > 0, r = t ? e.price_discounted : e.price, n = t && e.price != null ? e.price : void 0;
|
|
1166
|
-
let o;
|
|
1167
|
-
n != null && r != null && n > 0 ? o = Math.round((n - r) / n * 100) : e.price_discount_rate != null && e.price_discount_rate > 0 && (o = e.price_discount_rate);
|
|
1168
|
-
const i = u(e.brand), s = u(e.name) ?? e.sku, a = i && !s.toLowerCase().startsWith(i.toLowerCase()) ? `${i} ${s}` : s, c = {
|
|
1169
|
-
sku: e.sku,
|
|
1170
|
-
name: a,
|
|
1171
|
-
url: u(e.url) ?? ""
|
|
1172
|
-
}, m = e.images?.[0];
|
|
1173
|
-
m && (c.imageUrl = m), e.images && e.images.length > 1 && (c.images = e.images), r != null && r > 0 && (c.price = String(r)), n != null && n > 0 && (c.originalPrice = String(n)), o !== void 0 && (c.discountPercent = o), i !== void 0 && (c.brand = i), e.rating !== void 0 && (c.rating = e.rating), e.review_count !== void 0 && (c.reviewCount = e.review_count), e.cart_code !== void 0 && (c.cartCode = e.cart_code), e.in_stock !== void 0 && (c.inStock = e.in_stock), e.variants && e.variants.length > 0 && (c.variants = e.variants), e.discount_reason !== void 0 && (c.discountReason = e.discount_reason), e.promotions && e.promotions.length > 0 && (c.promotions = e.promotions), e.description !== void 0 && (c.description = e.description), e.description_html !== void 0 && (c.descriptionHtml = e.description_html), e.features && e.features.length > 0 && (c.features = e.features), e.specifications !== void 0 && (c.specifications = e.specifications), e.facet_hits && (c.facetHits = e.facet_hits), e.category_names && e.category_names.length > 0 && (c.categoryNames = e.category_names), e.short_name !== void 0 && (c.shortName = e.short_name);
|
|
1174
|
-
const _ = e, d = {};
|
|
1175
|
-
let p = !1;
|
|
1176
|
-
for (const l of Object.keys(_)) Le.has(l) || (d[l] = _[l], p = !0);
|
|
1177
|
-
return p && (c.extras = d), c;
|
|
1178
|
-
}
|
|
1179
|
-
function Me(e) {
|
|
1180
|
-
return e.results.map(w);
|
|
1181
|
-
}
|
|
1182
|
-
function $e(e) {
|
|
1183
|
-
return e.product_groupings.map((t) => {
|
|
1184
|
-
const r = {
|
|
1185
|
-
name: t.name,
|
|
1186
|
-
products: (t.group_products ?? []).map(w)
|
|
1187
|
-
};
|
|
1188
|
-
return t.highlight !== void 0 && (r.highlight = t.highlight), r;
|
|
1189
|
-
});
|
|
1190
|
-
}
|
|
1191
|
-
function De(e) {
|
|
1192
|
-
const t = e.payload.type, { type: r, ...n } = e.payload;
|
|
1193
|
-
return {
|
|
1194
|
-
type: "ui_spec",
|
|
1195
|
-
widget: "chat",
|
|
1196
|
-
spec: {
|
|
1197
|
-
root: "root",
|
|
1198
|
-
elements: { root: {
|
|
1199
|
-
type: t,
|
|
1200
|
-
props: n
|
|
1201
|
-
} }
|
|
1202
|
-
}
|
|
1203
|
-
};
|
|
1204
|
-
}
|
|
1205
|
-
var qe = {
|
|
1206
|
-
process_action: "/process_action",
|
|
1207
|
-
launcher_action: "/launcher_action",
|
|
1208
|
-
similar_products: "/similar_products",
|
|
1209
|
-
product_groupings: "/product_groupings"
|
|
1210
|
-
};
|
|
1211
|
-
function Oe(e) {
|
|
1212
|
-
if (e === void 0) throw new Error("[gengage] middlewareUrl is required. Pass your Gengage backend URL in widget config.");
|
|
1213
|
-
const t = e.trim();
|
|
1214
|
-
return t === "" ? "" : t.replace(/\/+$/, "");
|
|
1215
|
-
}
|
|
1216
|
-
function Be(e, t) {
|
|
1217
|
-
return `${Oe(t?.middlewareUrl)}/chat${qe[e]}`;
|
|
1218
|
-
}
|
|
1219
|
-
export {
|
|
1220
|
-
Me as a,
|
|
1221
|
-
W as c,
|
|
1222
|
-
M as d,
|
|
1223
|
-
Ge as f,
|
|
1224
|
-
Ue as h,
|
|
1225
|
-
$e as i,
|
|
1226
|
-
K as l,
|
|
1227
|
-
G as m,
|
|
1228
|
-
Oe as n,
|
|
1229
|
-
w as o,
|
|
1230
|
-
ze as p,
|
|
1231
|
-
je as r,
|
|
1232
|
-
R as s,
|
|
1233
|
-
Be as t,
|
|
1234
|
-
V as u
|
|
1235
|
-
};
|