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