@gengage/assistant-fe 0.6.39 → 0.6.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat/catalog.d.ts +1 -1
- package/dist/chat/components/ChatDrawer.d.ts +9 -2
- package/dist/chat/history-storage.d.ts +3 -0
- package/dist/chat/panel-manager.d.ts +7 -0
- package/dist/chat/runtime.d.ts +3 -0
- package/dist/chat/session-persistence.d.ts +2 -0
- package/dist/chat/types.d.ts +1 -0
- package/dist/chat-runtime.js +1 -1
- package/dist/chat.iife.js +36 -36
- package/dist/chat.js +1 -1
- package/dist/common/indexed-db.d.ts +3 -0
- package/dist/{common-DtgbqWSc.js → common-RLXFcoOo.js} +1 -1
- package/dist/common.js +5 -5
- package/dist/{connection-warning-CW7FlJH7.js → connection-warning-C1LnYGUH.js} +1 -1
- package/dist/{fastIntent-BwG6t8RV.js → fastIntent-BivJoy3l.js} +1 -1
- package/dist/index.js +10 -10
- package/dist/native.iife.js +14 -14
- package/dist/qna-runtime.js +1 -1
- package/dist/qna.iife.js +7 -7
- package/dist/qna.js +1 -1
- package/dist/{request-response-cache-DKf9Fcr5.js → request-response-cache-CVgP72eC.js} +459 -436
- package/dist/{runtime-CFzh6Ulc.js → runtime-B0aSQBLM.js} +1557 -1497
- package/dist/{runtime-ai391bmA.js → runtime-BemZwmk_.js} +3 -3
- package/dist/{runtime-CqgTa5_3.js → runtime-xuhF4izk.js} +3 -3
- package/dist/{simbut-BXTh-CaK.js → simbut-CJmAHE6w.js} +1 -1
- package/dist/simbut.iife.js +1 -1
- package/dist/simbut.js +1 -1
- package/dist/{simrel-Cv-eTKho.js → simrel-CwuklQwH.js} +1 -1
- package/dist/simrel-runtime.js +1 -1
- package/dist/simrel.iife.js +32 -32
- package/dist/simrel.js +2 -2
- package/dist/{widget-base-DOth8kwX.js → widget-base-C3v87X91.js} +1 -1
- package/package.json +1 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { i as X } from "./widget-base-
|
|
1
|
+
import { i as X } from "./widget-base-C3v87X91.js";
|
|
2
2
|
var Z = ({ element: e, renderElement: t }) => {
|
|
3
3
|
if (!e.children || e.children.length === 0) return null;
|
|
4
4
|
const r = document.createElement("div");
|
|
5
|
-
for (const
|
|
6
|
-
const
|
|
7
|
-
|
|
5
|
+
for (const n of e.children) {
|
|
6
|
+
const o = t(n);
|
|
7
|
+
o && r.appendChild(o);
|
|
8
8
|
}
|
|
9
9
|
return r;
|
|
10
10
|
};
|
|
11
|
-
function
|
|
11
|
+
function _t(e) {
|
|
12
12
|
const t = document.createElement("div");
|
|
13
13
|
if (t.className = e.containerClassName, !e.spec.elements[e.spec.root]) return t;
|
|
14
|
-
const r = e.unknownRenderer ?? Z,
|
|
14
|
+
const r = e.unknownRenderer ?? Z, n = (s) => {
|
|
15
15
|
const i = e.spec.elements[s];
|
|
16
16
|
if (!i) return null;
|
|
17
17
|
const a = e.registry[i.type];
|
|
@@ -20,63 +20,63 @@ function mt(e) {
|
|
|
20
20
|
element: i,
|
|
21
21
|
spec: e.spec,
|
|
22
22
|
context: e.context,
|
|
23
|
-
renderElement:
|
|
23
|
+
renderElement: n
|
|
24
24
|
}) : r({
|
|
25
25
|
elementId: s,
|
|
26
26
|
element: i,
|
|
27
27
|
spec: e.spec,
|
|
28
28
|
context: e.context,
|
|
29
|
-
renderElement:
|
|
29
|
+
renderElement: n
|
|
30
30
|
});
|
|
31
|
-
},
|
|
32
|
-
return
|
|
31
|
+
}, o = n(e.spec.root);
|
|
32
|
+
return o && t.appendChild(o), t;
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function ht(e, t) {
|
|
35
35
|
if (!t) return e;
|
|
36
36
|
const r = { ...e };
|
|
37
|
-
for (const [
|
|
38
|
-
|
|
37
|
+
for (const [n, o] of Object.entries(t))
|
|
38
|
+
o && (r[n] = o);
|
|
39
39
|
return r;
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function B(e) {
|
|
42
42
|
return typeof e == "object" && e !== null && typeof e.type == "string";
|
|
43
43
|
}
|
|
44
44
|
function ee(e) {
|
|
45
45
|
const t = [];
|
|
46
|
-
let r = 0,
|
|
46
|
+
let r = 0, n = !1, o = !1, s = 0;
|
|
47
47
|
for (let i = 0; i < e.length; i++) {
|
|
48
48
|
const a = e[i];
|
|
49
|
-
if (
|
|
50
|
-
|
|
49
|
+
if (o) {
|
|
50
|
+
o = !1;
|
|
51
51
|
continue;
|
|
52
52
|
}
|
|
53
|
-
if (a === "\\" &&
|
|
54
|
-
|
|
53
|
+
if (a === "\\" && n) {
|
|
54
|
+
o = !0;
|
|
55
55
|
continue;
|
|
56
56
|
}
|
|
57
57
|
if (a === '"') {
|
|
58
|
-
|
|
58
|
+
n = !n;
|
|
59
59
|
continue;
|
|
60
60
|
}
|
|
61
|
-
|
|
61
|
+
n || (a === "{" && r++, a === "}" && (r--, r === 0 && (t.push(e.slice(s, i + 1)), s = i + 1)));
|
|
62
62
|
}
|
|
63
63
|
return t.length > 0 ? t : [e];
|
|
64
64
|
}
|
|
65
|
-
function
|
|
65
|
+
function M(e, t) {
|
|
66
66
|
const r = e.trim();
|
|
67
67
|
if (!r || r.startsWith(":")) return !1;
|
|
68
|
-
const
|
|
69
|
-
if (
|
|
68
|
+
const n = r.startsWith("data: ") ? r.slice(6) : r;
|
|
69
|
+
if (n === "[DONE]")
|
|
70
70
|
return t.onDone?.(), !0;
|
|
71
71
|
try {
|
|
72
|
-
const
|
|
73
|
-
return
|
|
72
|
+
const o = JSON.parse(n);
|
|
73
|
+
return B(o) ? (X("stream", `event: ${o.type}`, o), t.onEvent(o), o.type === "done" ? (t.onDone?.(), !0) : !1) : !1;
|
|
74
74
|
} catch {
|
|
75
|
-
const
|
|
76
|
-
if (
|
|
77
|
-
for (const s of
|
|
75
|
+
const o = ee(n);
|
|
76
|
+
if (o.length > 1) {
|
|
77
|
+
for (const s of o) try {
|
|
78
78
|
const i = JSON.parse(s);
|
|
79
|
-
if (!
|
|
79
|
+
if (!B(i)) continue;
|
|
80
80
|
if (t.onEvent(i), i.type === "done")
|
|
81
81
|
return t.onDone?.(), !0;
|
|
82
82
|
} catch {
|
|
@@ -95,30 +95,30 @@ async function te(e, t) {
|
|
|
95
95
|
t.onError?.(/* @__PURE__ */ new Error("Response body is null — streaming not supported"));
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
98
|
-
const r = e.body.getReader(),
|
|
99
|
-
let
|
|
98
|
+
const r = e.body.getReader(), n = new TextDecoder("utf-8");
|
|
99
|
+
let o = "";
|
|
100
100
|
const s = t.idleTimeoutMs ?? 6e4, i = /* @__PURE__ */ Symbol("idle-timeout");
|
|
101
101
|
let a = !1;
|
|
102
102
|
try {
|
|
103
103
|
for (; ; ) {
|
|
104
104
|
const c = r.read();
|
|
105
|
-
let
|
|
106
|
-
const _ = await (s > 0 ? Promise.race([c.then((
|
|
107
|
-
|
|
105
|
+
let l;
|
|
106
|
+
const _ = await (s > 0 ? Promise.race([c.then((p) => (clearTimeout(l), p)), new Promise((p) => {
|
|
107
|
+
l = setTimeout(() => p(i), s);
|
|
108
108
|
})]) : c);
|
|
109
109
|
if (_ === i) {
|
|
110
110
|
a = !0, await r.cancel();
|
|
111
111
|
break;
|
|
112
112
|
}
|
|
113
|
-
const { done: u, value:
|
|
113
|
+
const { done: u, value: g } = _;
|
|
114
114
|
if (u) break;
|
|
115
|
-
|
|
116
|
-
const f =
|
|
115
|
+
o += n.decode(g, { stream: !0 });
|
|
116
|
+
const f = o.split(`
|
|
117
117
|
`);
|
|
118
|
-
|
|
119
|
-
for (const
|
|
118
|
+
o = f.pop() ?? "";
|
|
119
|
+
for (const p of f) if (M(p, t)) return;
|
|
120
120
|
}
|
|
121
|
-
if (
|
|
121
|
+
if (o.trim() && M(o, t))
|
|
122
122
|
return;
|
|
123
123
|
} catch (c) {
|
|
124
124
|
if (c instanceof DOMException && c.name === "AbortError") return;
|
|
@@ -128,8 +128,8 @@ async function te(e, t) {
|
|
|
128
128
|
}
|
|
129
129
|
t.onDone?.();
|
|
130
130
|
}
|
|
131
|
-
function
|
|
132
|
-
const
|
|
131
|
+
function bt(e, t, r) {
|
|
132
|
+
const n = new AbortController(), o = r.signal ? re([r.signal, n.signal]) : n.signal;
|
|
133
133
|
return fetch(e, {
|
|
134
134
|
method: "POST",
|
|
135
135
|
headers: {
|
|
@@ -137,64 +137,64 @@ function ht(e, t, r) {
|
|
|
137
137
|
...r.headers
|
|
138
138
|
},
|
|
139
139
|
body: JSON.stringify(t),
|
|
140
|
-
signal:
|
|
140
|
+
signal: o
|
|
141
141
|
}).then((s) => te(s, {
|
|
142
142
|
...r,
|
|
143
|
-
signal:
|
|
143
|
+
signal: o
|
|
144
144
|
})).catch((s) => {
|
|
145
145
|
s instanceof DOMException && s.name === "AbortError" || r.onError?.(s instanceof Error ? s : new Error(String(s)));
|
|
146
|
-
}),
|
|
146
|
+
}), n;
|
|
147
147
|
}
|
|
148
148
|
function re(e) {
|
|
149
149
|
const t = new AbortController(), r = [];
|
|
150
|
-
for (const
|
|
151
|
-
if (
|
|
152
|
-
return t.abort(
|
|
153
|
-
const
|
|
154
|
-
|
|
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
155
|
}
|
|
156
156
|
return t.signal.addEventListener("abort", () => {
|
|
157
|
-
for (const
|
|
157
|
+
for (const n of r) n();
|
|
158
158
|
}, { once: !0 }), t.signal;
|
|
159
159
|
}
|
|
160
|
-
var
|
|
160
|
+
var z = 3, ne = (e, t) => {
|
|
161
161
|
const r = e.replace(/\s+/g, " ").trim().replace(/^[,.;:!?•-]+|[,.;:!?•-]+$/g, "");
|
|
162
162
|
if (!r) return "";
|
|
163
|
-
const
|
|
164
|
-
return
|
|
165
|
-
},
|
|
166
|
-
function
|
|
167
|
-
const t = (e.display_keywords ?? []).flatMap((
|
|
168
|
-
if (r.length > 0) return r.slice(0,
|
|
169
|
-
const
|
|
170
|
-
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
|
+
}, N = (e, t) => e ? e.split(/[•,;:/()]|(?:\sve\s)|(?:\sand\s)|(?:\sile\s)|(?:\sfor\s)|(?:\swith\s)/i).map((r) => ne(r, t)).filter(Boolean) : [];
|
|
166
|
+
function oe(e) {
|
|
167
|
+
const t = (e.display_keywords ?? []).flatMap((o) => N(o, { stripLeadingStopWords: !0 })), r = t.filter((o, s) => t.indexOf(o) === s);
|
|
168
|
+
if (r.length > 0) return r.slice(0, z);
|
|
169
|
+
const n = [...N(e.chosen_attribute, { stripLeadingStopWords: !0 }), ...N(e.short_name)];
|
|
170
|
+
return n.filter((o, s) => n.indexOf(o) === s).slice(0, z);
|
|
171
171
|
}
|
|
172
172
|
function se(e) {
|
|
173
|
-
return
|
|
173
|
+
return oe(e).join(" • ");
|
|
174
174
|
}
|
|
175
175
|
function ie(e) {
|
|
176
176
|
return e === "beauty_consulting" || e === "account_expert";
|
|
177
177
|
}
|
|
178
|
-
function
|
|
178
|
+
function E(...e) {
|
|
179
179
|
for (const t of e) {
|
|
180
180
|
if (typeof t != "string") continue;
|
|
181
181
|
const r = t.trim();
|
|
182
182
|
if (r.length > 0) return r;
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
|
-
function
|
|
185
|
+
function T(e) {
|
|
186
186
|
return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0).map((t) => t.trim()) : [];
|
|
187
187
|
}
|
|
188
|
-
function
|
|
189
|
-
const t = { ...e }, r =
|
|
190
|
-
if (r ? t.sku = r : delete t.sku,
|
|
188
|
+
function I(e) {
|
|
189
|
+
const t = { ...e }, r = E(t.sku), n = T(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
191
|
else {
|
|
192
|
-
const
|
|
193
|
-
|
|
192
|
+
const o = E(t.image_url);
|
|
193
|
+
o ? t.image_url = o : delete t.image_url;
|
|
194
194
|
}
|
|
195
195
|
return t;
|
|
196
196
|
}
|
|
197
|
-
function
|
|
197
|
+
function kt(e) {
|
|
198
198
|
if (typeof e.type != "string") return null;
|
|
199
199
|
if (ae(e)) return e;
|
|
200
200
|
const t = e;
|
|
@@ -220,17 +220,17 @@ function bt(e) {
|
|
|
220
220
|
case "panelLoading":
|
|
221
221
|
return ke(t);
|
|
222
222
|
case "similarLoading":
|
|
223
|
-
return
|
|
223
|
+
return Se(t);
|
|
224
224
|
case "redirect":
|
|
225
|
-
return
|
|
225
|
+
return Ae(t);
|
|
226
226
|
case "error":
|
|
227
|
-
return
|
|
227
|
+
return we(t);
|
|
228
228
|
case "dummy":
|
|
229
229
|
return xe(t);
|
|
230
230
|
case "launcherAction":
|
|
231
231
|
return Pe(t);
|
|
232
232
|
case "text":
|
|
233
|
-
return
|
|
233
|
+
return v(t);
|
|
234
234
|
case "productItem":
|
|
235
235
|
return Ee(t);
|
|
236
236
|
case "text_image":
|
|
@@ -244,30 +244,30 @@ function bt(e) {
|
|
|
244
244
|
case "aiProductGroupings":
|
|
245
245
|
return Ne(t);
|
|
246
246
|
case "aiSuggestedSearches":
|
|
247
|
-
return
|
|
247
|
+
return Oe(t);
|
|
248
248
|
case "prosAndCons":
|
|
249
249
|
return Ce(t);
|
|
250
250
|
case "getGroundingReview":
|
|
251
|
-
return Oe(t);
|
|
252
|
-
case "voice":
|
|
253
251
|
return ve(t);
|
|
252
|
+
case "voice":
|
|
253
|
+
return je(t);
|
|
254
254
|
case "visitorDataResponse":
|
|
255
255
|
return Ie(t);
|
|
256
256
|
case "productListPreview":
|
|
257
257
|
return qe();
|
|
258
258
|
case "groupList":
|
|
259
|
-
return
|
|
259
|
+
return Be(t);
|
|
260
260
|
case "formGetInfo":
|
|
261
261
|
case "formTestDrive":
|
|
262
262
|
case "formServiceRequest":
|
|
263
263
|
case "launchFormPage":
|
|
264
|
-
return
|
|
264
|
+
return Me(t);
|
|
265
265
|
case "launcherContent":
|
|
266
|
-
return
|
|
266
|
+
return He(t);
|
|
267
267
|
case "handoff":
|
|
268
|
-
return
|
|
268
|
+
return ze(t);
|
|
269
269
|
case "uiSpec":
|
|
270
|
-
return
|
|
270
|
+
return Je(t);
|
|
271
271
|
default:
|
|
272
272
|
return null;
|
|
273
273
|
}
|
|
@@ -283,8 +283,8 @@ function ae(e) {
|
|
|
283
283
|
case "ui_spec": {
|
|
284
284
|
const r = e.widget;
|
|
285
285
|
if (r !== "chat" && r !== "qna" && r !== "simrel") return !1;
|
|
286
|
-
const
|
|
287
|
-
return
|
|
286
|
+
const n = b(e.spec);
|
|
287
|
+
return n ? typeof n.root == "string" && b(n.elements) !== null : !1;
|
|
288
288
|
}
|
|
289
289
|
case "action": {
|
|
290
290
|
const r = b(e.action);
|
|
@@ -299,55 +299,55 @@ function ae(e) {
|
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
301
|
function ce(e) {
|
|
302
|
-
const t =
|
|
302
|
+
const t = d(e.payload.text, e.payload.plain_text) ?? "", r = d(e.payload.plain_text, e.payload.text) ?? t;
|
|
303
303
|
if (e.payload.is_error) return {
|
|
304
304
|
type: "error",
|
|
305
305
|
code: "BACKEND_ERROR",
|
|
306
306
|
message: r || "Backend returned an error"
|
|
307
307
|
};
|
|
308
|
-
const
|
|
308
|
+
const n = {
|
|
309
309
|
type: "text_chunk",
|
|
310
310
|
content: t,
|
|
311
311
|
final: !0
|
|
312
|
-
},
|
|
313
|
-
Array.isArray(
|
|
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
314
|
const s = e.payload.sku_to_product_item;
|
|
315
|
-
s && typeof s == "object" && !Array.isArray(s) && (
|
|
315
|
+
s && typeof s == "object" && !Array.isArray(s) && (n.skuToProductItem = s);
|
|
316
316
|
const i = e.payload.conversation_mode;
|
|
317
|
-
typeof i == "string" && i && (
|
|
317
|
+
typeof i == "string" && i && (n.conversationMode = i);
|
|
318
318
|
const a = e.payload.render_hint;
|
|
319
|
-
return typeof a == "string" && a && (
|
|
319
|
+
return typeof a == "string" && a && (n.renderHint = a), e.payload.kvkk === !0 && (n.kvkk = !0), n;
|
|
320
320
|
}
|
|
321
321
|
function ue(e) {
|
|
322
322
|
return V((e.payload.actions ?? []).map((t) => {
|
|
323
|
-
const r =
|
|
323
|
+
const r = d(t.title) ?? "", n = k(t.requestDetails, r), o = n ? {
|
|
324
324
|
label: r,
|
|
325
|
-
action:
|
|
325
|
+
action: n
|
|
326
326
|
} : null;
|
|
327
|
-
return
|
|
328
|
-
}).filter(
|
|
327
|
+
return o ? (typeof t.icon == "string" && (o.icon = t.icon), typeof t.image == "string" && (o.image = t.image), o) : null;
|
|
328
|
+
}).filter(C), "chat");
|
|
329
329
|
}
|
|
330
330
|
function de(e) {
|
|
331
331
|
const t = Array.isArray(e.payload.grouped_assignment) ? e.payload.grouped_assignment : [], r = (Array.isArray(e.payload.style_variations) ? e.payload.style_variations : []).map((a) => {
|
|
332
|
-
const c =
|
|
332
|
+
const c = d(a.style_label);
|
|
333
333
|
if (!c) return null;
|
|
334
|
-
const
|
|
335
|
-
const
|
|
336
|
-
return
|
|
337
|
-
}).filter(
|
|
338
|
-
label:
|
|
339
|
-
reason:
|
|
340
|
-
skus: Array.isArray(f.skus) ? f.skus.filter((
|
|
334
|
+
const l = d(a.style_mood), _ = d(a.image_url ?? void 0), u = (Array.isArray(a.product_list) ? a.product_list : []).map((f) => {
|
|
335
|
+
const p = b(f);
|
|
336
|
+
return p ? j(b(p.product_detail) ?? b(p.product) ?? p) : null;
|
|
337
|
+
}).filter(C), g = Array.isArray(a.recommendation_groups) ? a.recommendation_groups.map((f) => ({
|
|
338
|
+
label: d(f.label) ?? "",
|
|
339
|
+
reason: d(f.reason) ?? "",
|
|
340
|
+
skus: Array.isArray(f.skus) ? f.skus.filter((p) => typeof p == "string" && p.trim().length > 0) : []
|
|
341
341
|
})) : [];
|
|
342
342
|
return {
|
|
343
343
|
style_label: c,
|
|
344
|
-
style_mood:
|
|
344
|
+
style_mood: l ?? "",
|
|
345
345
|
..._ ? { image_url: _ } : {},
|
|
346
346
|
...typeof a.status == "string" ? { status: a.status } : {},
|
|
347
347
|
product_list: u,
|
|
348
|
-
recommendation_groups:
|
|
348
|
+
recommendation_groups: g
|
|
349
349
|
};
|
|
350
|
-
}).filter(
|
|
350
|
+
}).filter(C), n = e.payload.product_list ?? [], o = ie(e.payload.source) && r.length > 0 ? r[0].product_list : null, s = o ? Ge(o, "chat") : t.length > 0 ? Ue(t, n, "chat") ?? R(n, "chat") : R(n, "chat");
|
|
351
351
|
s.panelHint = "panel";
|
|
352
352
|
const i = s.spec.elements[s.spec.root];
|
|
353
353
|
if (i) {
|
|
@@ -363,8 +363,8 @@ function de(e) {
|
|
|
363
363
|
}
|
|
364
364
|
function le(e) {
|
|
365
365
|
const t = e.payload.productDetails;
|
|
366
|
-
if (!t) return
|
|
367
|
-
const r =
|
|
366
|
+
if (!t) return Fe("chat");
|
|
367
|
+
const r = w(t);
|
|
368
368
|
return {
|
|
369
369
|
type: "ui_spec",
|
|
370
370
|
widget: "chat",
|
|
@@ -382,7 +382,7 @@ function le(e) {
|
|
|
382
382
|
};
|
|
383
383
|
}
|
|
384
384
|
function pe(e) {
|
|
385
|
-
const t =
|
|
385
|
+
const t = R(e.payload.similarProducts ?? [], "chat"), r = t.spec.elements[t.spec.root];
|
|
386
386
|
return r && (r.props = {
|
|
387
387
|
...r.props,
|
|
388
388
|
similarsAppend: !0
|
|
@@ -392,7 +392,7 @@ function pe(e) {
|
|
|
392
392
|
};
|
|
393
393
|
}
|
|
394
394
|
function fe(e) {
|
|
395
|
-
const t = e.payload.multiple_product_details ?? [], r = e.payload,
|
|
395
|
+
const t = e.payload.multiple_product_details ?? [], r = e.payload, n = {
|
|
396
396
|
key_differences: r.key_differences,
|
|
397
397
|
recommended_choice: r.recommended_choice,
|
|
398
398
|
recommended_choice_sku: r.recommended_choice_sku,
|
|
@@ -403,22 +403,22 @@ function fe(e) {
|
|
|
403
403
|
winner_product: r.winner_product,
|
|
404
404
|
winner_hits: r.winner_hits,
|
|
405
405
|
...e.payload.product_comparison_framework ?? {}
|
|
406
|
-
},
|
|
407
|
-
for (const
|
|
408
|
-
const h =
|
|
406
|
+
}, o = e.payload.table, s = e.payload.features_list, i = [];
|
|
407
|
+
for (const m of t) {
|
|
408
|
+
const h = w(m);
|
|
409
409
|
i.push(h);
|
|
410
410
|
}
|
|
411
|
-
const a = ye(
|
|
411
|
+
const a = ye(o, i, n, s);
|
|
412
412
|
let c;
|
|
413
|
-
|
|
414
|
-
const
|
|
415
|
-
if (Array.isArray(
|
|
416
|
-
for (const
|
|
417
|
-
const u = W(
|
|
418
|
-
for (const
|
|
419
|
-
const h =
|
|
420
|
-
h && (
|
|
421
|
-
title:
|
|
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 l = c ? i.find((m) => m.sku === c) ?? i[0] : i[0], _ = [];
|
|
415
|
+
if (Array.isArray(n?.key_differences))
|
|
416
|
+
for (const m of n.key_differences) typeof m == "string" && _.push(m);
|
|
417
|
+
const u = W(n?.special_considerations), g = n?.recommended_choice, f = n?.winner_hits, p = {};
|
|
418
|
+
for (const m of i) {
|
|
419
|
+
const h = m.sku;
|
|
420
|
+
h && (p[h] = {
|
|
421
|
+
title: m.name ?? h,
|
|
422
422
|
type: "launchSingleProduct",
|
|
423
423
|
payload: { sku: h }
|
|
424
424
|
});
|
|
@@ -427,9 +427,9 @@ function fe(e) {
|
|
|
427
427
|
products: i,
|
|
428
428
|
attributes: a,
|
|
429
429
|
highlights: _,
|
|
430
|
-
productActions:
|
|
430
|
+
productActions: p
|
|
431
431
|
};
|
|
432
|
-
return
|
|
432
|
+
return l && (y.recommended = l), u.length > 0 && (y.specialCases = u), g && (y.recommendedText = g), f && (y.winnerHits = f), typeof n?.key_differences == "string" && (y.keyDifferencesHtml = n.key_differences), n?.special_considerations && (y.specialConsiderations = n.special_considerations), {
|
|
433
433
|
type: "ui_spec",
|
|
434
434
|
widget: "chat",
|
|
435
435
|
spec: {
|
|
@@ -442,47 +442,47 @@ function fe(e) {
|
|
|
442
442
|
panelHint: "panel"
|
|
443
443
|
};
|
|
444
444
|
}
|
|
445
|
-
function ye(e, t, r,
|
|
445
|
+
function ye(e, t, r, n) {
|
|
446
446
|
if (!e) return [];
|
|
447
|
-
const
|
|
448
|
-
if (
|
|
449
|
-
const s =
|
|
447
|
+
const o = Object.entries(e);
|
|
448
|
+
if (o.length === 0) return [];
|
|
449
|
+
const s = o[0]?.[1];
|
|
450
450
|
if (Array.isArray(s)) {
|
|
451
|
-
const u = r.criteria_view ?? r.criteria_view_short ?? {},
|
|
452
|
-
for (const
|
|
453
|
-
const y = e[
|
|
451
|
+
const u = r.criteria_view ?? r.criteria_view_short ?? {}, g = r.compared_field_names ?? Object.keys(e), f = [];
|
|
452
|
+
for (const p of g) {
|
|
453
|
+
const y = e[p];
|
|
454
454
|
if (!y || !Array.isArray(y)) continue;
|
|
455
|
-
const
|
|
455
|
+
const m = u[p] ?? p;
|
|
456
456
|
f.push({
|
|
457
|
-
label:
|
|
457
|
+
label: m,
|
|
458
458
|
values: y.map((h) => typeof h == "string" ? h : String(h ?? ""))
|
|
459
459
|
});
|
|
460
460
|
}
|
|
461
461
|
return f;
|
|
462
462
|
}
|
|
463
|
-
const i = e, a = t.map((u) => String(u.sku ?? "")).filter((u) => u.length > 0), c = r.criteria_view ?? r.criteria_view_short ?? {},
|
|
464
|
-
for (const u of
|
|
465
|
-
const
|
|
466
|
-
const y = i[
|
|
463
|
+
const i = e, a = t.map((u) => String(u.sku ?? "")).filter((u) => u.length > 0), c = r.criteria_view ?? r.criteria_view_short ?? {}, l = (n && n.length > 0 ? n : r.compared_field_names && r.compared_field_names.length > 0 ? r.compared_field_names : ge(i)).filter((u) => u !== "name" && u !== "name_short" && !u.endsWith("_short")), _ = [];
|
|
464
|
+
for (const u of l) {
|
|
465
|
+
const g = a.map((p) => {
|
|
466
|
+
const y = i[p];
|
|
467
467
|
if (!y || typeof y != "object") return "";
|
|
468
|
-
const
|
|
469
|
-
return me(
|
|
468
|
+
const m = y[`${u}_short`], h = y[u];
|
|
469
|
+
return me(m ?? h);
|
|
470
470
|
});
|
|
471
|
-
if (
|
|
471
|
+
if (g.every((p) => p.length === 0)) continue;
|
|
472
472
|
const f = c[u] ?? u;
|
|
473
473
|
_.push({
|
|
474
474
|
label: f,
|
|
475
|
-
values:
|
|
475
|
+
values: g
|
|
476
476
|
});
|
|
477
477
|
}
|
|
478
478
|
return _;
|
|
479
479
|
}
|
|
480
480
|
function ge(e) {
|
|
481
481
|
const t = [], r = /* @__PURE__ */ new Set();
|
|
482
|
-
for (const
|
|
483
|
-
if (!(!
|
|
484
|
-
for (const
|
|
485
|
-
r.has(
|
|
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
486
|
return t;
|
|
487
487
|
}
|
|
488
488
|
function me(e) {
|
|
@@ -529,7 +529,7 @@ function ke(e) {
|
|
|
529
529
|
}
|
|
530
530
|
};
|
|
531
531
|
}
|
|
532
|
-
function
|
|
532
|
+
function Se(e) {
|
|
533
533
|
return {
|
|
534
534
|
type: "metadata",
|
|
535
535
|
sessionId: "",
|
|
@@ -542,8 +542,8 @@ function Ae(e) {
|
|
|
542
542
|
}
|
|
543
543
|
};
|
|
544
544
|
}
|
|
545
|
-
function
|
|
546
|
-
const t =
|
|
545
|
+
function Ae(e) {
|
|
546
|
+
const t = d(e.payload.url);
|
|
547
547
|
return t ? {
|
|
548
548
|
type: "action",
|
|
549
549
|
action: {
|
|
@@ -557,15 +557,15 @@ function we(e) {
|
|
|
557
557
|
model: "",
|
|
558
558
|
meta: {
|
|
559
559
|
redirect: e.payload,
|
|
560
|
-
redirectTarget:
|
|
560
|
+
redirectTarget: d(e.payload.to)
|
|
561
561
|
}
|
|
562
562
|
};
|
|
563
563
|
}
|
|
564
|
-
function
|
|
564
|
+
function we(e) {
|
|
565
565
|
return {
|
|
566
566
|
type: "error",
|
|
567
567
|
code: "BACKEND_ERROR",
|
|
568
|
-
message:
|
|
568
|
+
message: d(e.payload?.text, e.payload?.message, e.payload?.error) ?? "Backend returned an error"
|
|
569
569
|
};
|
|
570
570
|
}
|
|
571
571
|
function xe(e) {
|
|
@@ -579,26 +579,26 @@ function xe(e) {
|
|
|
579
579
|
function Pe(e) {
|
|
580
580
|
const t = e.payload ?? {};
|
|
581
581
|
if (Array.isArray(t.action_list)) {
|
|
582
|
-
const
|
|
583
|
-
return s !== void 0 && (
|
|
582
|
+
const o = { action_list: t.action_list }, s = typeof t.type == "string" ? t.type : void 0, i = typeof t.theme == "string" ? t.theme : void 0;
|
|
583
|
+
return s !== void 0 && (o.type = s), i !== void 0 && (o.theme = i), K({
|
|
584
584
|
type: "quick_qna",
|
|
585
|
-
payload:
|
|
585
|
+
payload: o
|
|
586
586
|
});
|
|
587
587
|
}
|
|
588
588
|
const r = b(t.action);
|
|
589
589
|
if (r) {
|
|
590
|
-
const
|
|
591
|
-
return s !== void 0 && (
|
|
590
|
+
const o = { action: r }, s = typeof t.text == "string" ? t.text : void 0, i = typeof t.image_url == "string" ? t.image_url : void 0, a = typeof t.theme == "string" ? t.theme : void 0;
|
|
591
|
+
return s !== void 0 && (o.text = s), i !== void 0 && (o.image_url = i), a !== void 0 && (o.theme = a), F({
|
|
592
592
|
type: "text_image",
|
|
593
|
-
payload:
|
|
593
|
+
payload: o
|
|
594
594
|
});
|
|
595
595
|
}
|
|
596
|
-
const
|
|
597
|
-
if (
|
|
598
|
-
const
|
|
599
|
-
return s !== void 0 && (
|
|
596
|
+
const n = typeof t.text == "string" ? t.text : "";
|
|
597
|
+
if (n) {
|
|
598
|
+
const o = { text: n }, s = typeof t.type == "string" ? t.type : void 0, i = typeof t.theme == "string" ? t.theme : void 0, a = b(t.payload) ?? void 0;
|
|
599
|
+
return s !== void 0 && (o.type = s), a !== void 0 && (o.payload = a), i !== void 0 && (o.theme = i), v({
|
|
600
600
|
type: "text",
|
|
601
|
-
payload:
|
|
601
|
+
payload: o
|
|
602
602
|
});
|
|
603
603
|
}
|
|
604
604
|
return {
|
|
@@ -608,8 +608,8 @@ function Pe(e) {
|
|
|
608
608
|
meta: { launcherAction: t }
|
|
609
609
|
};
|
|
610
610
|
}
|
|
611
|
-
function
|
|
612
|
-
const t = { text:
|
|
611
|
+
function v(e) {
|
|
612
|
+
const t = { text: d(e.payload.text) ?? "" };
|
|
613
613
|
return typeof e.payload.theme == "string" && (t.theme = e.payload.theme), e.payload.payload !== void 0 && (t.payload = e.payload.payload), {
|
|
614
614
|
type: "ui_spec",
|
|
615
615
|
widget: "qna",
|
|
@@ -623,46 +623,46 @@ function O(e) {
|
|
|
623
623
|
};
|
|
624
624
|
}
|
|
625
625
|
function Ee(e) {
|
|
626
|
-
return
|
|
626
|
+
return $e(e.payload, "qna");
|
|
627
627
|
}
|
|
628
628
|
function F(e) {
|
|
629
|
-
const t =
|
|
629
|
+
const t = d(e.payload.text) ?? "", r = k(e.payload.action, t);
|
|
630
630
|
if (r) {
|
|
631
|
-
const
|
|
631
|
+
const o = {
|
|
632
632
|
label: t || r.title,
|
|
633
633
|
action: r
|
|
634
634
|
};
|
|
635
|
-
return typeof e.payload.image_url == "string" && (
|
|
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
636
|
type: "ui_spec",
|
|
637
637
|
widget: "qna",
|
|
638
638
|
spec: {
|
|
639
639
|
root: "root",
|
|
640
640
|
elements: { root: {
|
|
641
641
|
type: "ActionButton",
|
|
642
|
-
props:
|
|
642
|
+
props: o
|
|
643
643
|
} }
|
|
644
644
|
}
|
|
645
645
|
};
|
|
646
646
|
}
|
|
647
|
-
const
|
|
648
|
-
return typeof e.payload.theme == "string" && (
|
|
647
|
+
const n = { text: t };
|
|
648
|
+
return typeof e.payload.theme == "string" && (n.theme = e.payload.theme), v({
|
|
649
649
|
type: "text",
|
|
650
|
-
payload:
|
|
650
|
+
payload: n
|
|
651
651
|
});
|
|
652
652
|
}
|
|
653
653
|
function K(e) {
|
|
654
654
|
return V((e.payload.action_list ?? []).map((t) => {
|
|
655
|
-
const r =
|
|
655
|
+
const r = d(t.title) ?? "", n = k(t.requestDetails, r), o = n ? {
|
|
656
656
|
label: r,
|
|
657
|
-
action:
|
|
657
|
+
action: n
|
|
658
658
|
} : null;
|
|
659
|
-
return
|
|
660
|
-
}).filter(
|
|
659
|
+
return o ? (typeof t.icon == "string" && (o.icon = t.icon), typeof t.image == "string" && (o.image = t.image), o) : null;
|
|
660
|
+
}).filter(C), "qna");
|
|
661
661
|
}
|
|
662
662
|
function Te(e) {
|
|
663
663
|
const t = { reviews: (e.payload.reviews ?? []).map((r) => {
|
|
664
|
-
const
|
|
665
|
-
return typeof r.review_class == "string" && (
|
|
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
666
|
}) };
|
|
667
667
|
return typeof e.payload.sku == "string" && (t.sku = e.payload.sku), {
|
|
668
668
|
type: "ui_spec",
|
|
@@ -700,13 +700,13 @@ function Ie(e) {
|
|
|
700
700
|
}
|
|
701
701
|
function De(e) {
|
|
702
702
|
const t = e.payload.product_suggestions ?? [], r = [];
|
|
703
|
-
for (let
|
|
704
|
-
const
|
|
705
|
-
if (!
|
|
706
|
-
const s =
|
|
703
|
+
for (let n = 0; n < t.length; n++) {
|
|
704
|
+
const o = t[n];
|
|
705
|
+
if (!o) continue;
|
|
706
|
+
const s = Ke(o);
|
|
707
707
|
if (!s) continue;
|
|
708
|
-
const i = { product: s }, a = k(
|
|
709
|
-
a && (i.action = a), typeof
|
|
708
|
+
const i = { product: s }, a = k(o.requestDetails, s.name);
|
|
709
|
+
a && (i.action = a), typeof o.role == "string" && (i.role = o.role), typeof o.reason == "string" && (i.reason = o.reason), typeof o.review_highlight == "string" && (i.reviewHighlight = o.review_highlight), Array.isArray(o.labels) && (i.labels = o.labels), typeof o.expert_quality_score == "number" && (i.expertQualityScore = o.expert_quality_score), r.push(i);
|
|
710
710
|
}
|
|
711
711
|
return r.length === 0 ? {
|
|
712
712
|
type: "metadata",
|
|
@@ -726,27 +726,27 @@ function De(e) {
|
|
|
726
726
|
};
|
|
727
727
|
}
|
|
728
728
|
function Ne(e) {
|
|
729
|
-
const t = e.payload.product_groupings ?? [], r = [],
|
|
730
|
-
for (let
|
|
731
|
-
const s = t[
|
|
729
|
+
const t = e.payload.product_groupings ?? [], r = [], n = [];
|
|
730
|
+
for (let o = 0; o < t.length; o++) {
|
|
731
|
+
const s = t[o];
|
|
732
732
|
if (!s) continue;
|
|
733
|
-
const i =
|
|
734
|
-
const h = b(
|
|
735
|
-
return h ?
|
|
736
|
-
}).filter(
|
|
733
|
+
const i = d(s.name) ?? "", a = d(s.description), c = d(s.highlight), l = Array.isArray(s.labels) ? W(s.labels) : [], _ = d(s.sku, s.repr_sku), u = d(s.image, s.repr_image), g = Re(s, i, _), f = (Array.isArray(s.group_products) ? s.group_products : []).map((m) => {
|
|
734
|
+
const h = b(m);
|
|
735
|
+
return h ? j(h) : null;
|
|
736
|
+
}).filter(C), p = u ?? d(...f.map((m) => m.imageUrl));
|
|
737
737
|
if (i && f.length > 0) {
|
|
738
|
-
const
|
|
738
|
+
const m = {
|
|
739
739
|
groupName: i,
|
|
740
740
|
products: f
|
|
741
741
|
};
|
|
742
|
-
|
|
742
|
+
p && (m.image = p), a && (m.description = a), c && (m.highlight = c), l.length > 0 && (m.labels = l), r.push(m);
|
|
743
743
|
}
|
|
744
|
-
if (!
|
|
744
|
+
if (!g) continue;
|
|
745
745
|
const y = {
|
|
746
746
|
name: i,
|
|
747
|
-
action:
|
|
747
|
+
action: g
|
|
748
748
|
};
|
|
749
|
-
|
|
749
|
+
l.length > 0 && (y.labels = l), u !== void 0 && (y.image = u), n.push(y);
|
|
750
750
|
}
|
|
751
751
|
return r.length > 0 ? {
|
|
752
752
|
type: "ui_spec",
|
|
@@ -759,7 +759,7 @@ function Ne(e) {
|
|
|
759
759
|
} }
|
|
760
760
|
},
|
|
761
761
|
panelHint: "panel"
|
|
762
|
-
} :
|
|
762
|
+
} : n.length === 0 ? {
|
|
763
763
|
type: "metadata",
|
|
764
764
|
sessionId: "",
|
|
765
765
|
model: "",
|
|
@@ -771,54 +771,77 @@ function Ne(e) {
|
|
|
771
771
|
root: "root",
|
|
772
772
|
elements: { root: {
|
|
773
773
|
type: "AIGroupingCards",
|
|
774
|
-
props: { entries:
|
|
774
|
+
props: { entries: n }
|
|
775
775
|
} }
|
|
776
776
|
}
|
|
777
777
|
};
|
|
778
778
|
}
|
|
779
779
|
function Re(e, t, r) {
|
|
780
|
-
const
|
|
781
|
-
if (
|
|
782
|
-
if (
|
|
783
|
-
const i = { ...b(
|
|
784
|
-
r && !
|
|
785
|
-
const a =
|
|
780
|
+
const n = b(e.requestDetails);
|
|
781
|
+
if (n) {
|
|
782
|
+
if (n.type !== "findSimilar") return k(n, t);
|
|
783
|
+
const i = { ...b(n.payload) ?? {} };
|
|
784
|
+
r && !E(i.sku) && (i.sku = r);
|
|
785
|
+
const a = T(e.group_skus);
|
|
786
786
|
return a.length > 0 && (i.group_skus = a), k({
|
|
787
|
-
...
|
|
788
|
-
payload:
|
|
787
|
+
...n,
|
|
788
|
+
payload: I(i)
|
|
789
789
|
}, t);
|
|
790
790
|
}
|
|
791
|
-
const
|
|
792
|
-
r && (
|
|
793
|
-
const s =
|
|
794
|
-
return s.length > 0 && (
|
|
791
|
+
const o = {};
|
|
792
|
+
r && (o.sku = r);
|
|
793
|
+
const s = T(e.group_skus);
|
|
794
|
+
return s.length > 0 && (o.group_skus = s), Object.keys(o).length === 0 ? null : k({
|
|
795
795
|
type: "findSimilar",
|
|
796
|
-
payload:
|
|
796
|
+
payload: I(o)
|
|
797
|
+
}, t);
|
|
798
|
+
}
|
|
799
|
+
function Le(e, t) {
|
|
800
|
+
const r = b(e.requestDetails), n = b(r?.payload), o = d(e.detailed_user_message), s = e.group_skus && Array.isArray(e.group_skus) ? T(e.group_skus) : T(n?.group_skus), i = d(e.sku, e.representative_product_sku, n?.sku);
|
|
801
|
+
if (r?.type === "findSimilar") {
|
|
802
|
+
const c = { ...n ?? {} };
|
|
803
|
+
return i && (c.sku = i), s.length > 0 && (c.group_skus = s), o && (c.input = o, E(c.text) || (c.text = o)), c.is_search_suggestion = 1, k({
|
|
804
|
+
...r,
|
|
805
|
+
payload: I(c)
|
|
806
|
+
}, t);
|
|
807
|
+
}
|
|
808
|
+
if (i) {
|
|
809
|
+
const c = {
|
|
810
|
+
sku: i,
|
|
811
|
+
is_search_suggestion: 1
|
|
812
|
+
};
|
|
813
|
+
return s.length > 0 && (c.group_skus = s), o && (c.input = o, c.text = o), k({
|
|
814
|
+
type: "findSimilar",
|
|
815
|
+
payload: I(c)
|
|
816
|
+
}, t);
|
|
817
|
+
}
|
|
818
|
+
const a = {
|
|
819
|
+
...n ?? {},
|
|
820
|
+
is_suggested_text: 1,
|
|
821
|
+
is_search_suggestion: 1
|
|
822
|
+
};
|
|
823
|
+
return o && !E(a.text) && (a.text = o), s.length > 0 && (a.group_skus = s), k(r?.type === "inputText" ? {
|
|
824
|
+
...r,
|
|
825
|
+
payload: a
|
|
826
|
+
} : {
|
|
827
|
+
type: "inputText",
|
|
828
|
+
payload: a
|
|
797
829
|
}, t);
|
|
798
830
|
}
|
|
799
|
-
function
|
|
831
|
+
function Oe(e) {
|
|
800
832
|
const t = e.payload.suggested_searches ?? [], r = [];
|
|
801
|
-
for (let
|
|
802
|
-
const
|
|
803
|
-
if (!
|
|
804
|
-
const s =
|
|
805
|
-
|
|
806
|
-
const
|
|
807
|
-
n.group_skus && Array.isArray(n.group_skus) ? i.group_skus = n.group_skus : Array.isArray(p) && (i.group_skus = p.filter((h) => typeof h == "string"));
|
|
808
|
-
const _ = l(n.sku, n.representative_product_sku, c?.sku);
|
|
809
|
-
_ && (i.sku = _), i.is_suggested_text = 1;
|
|
810
|
-
const u = {
|
|
811
|
-
type: "inputText",
|
|
812
|
-
payload: i
|
|
813
|
-
}, m = k(n.requestDetails, s), f = m?.type === "findSimilar" && typeof i.text == "string" ? k(u, s) : m ?? k(u, s);
|
|
814
|
-
if (!f) continue;
|
|
815
|
-
const d = {
|
|
833
|
+
for (let n = 0; n < t.length; n++) {
|
|
834
|
+
const o = t[n];
|
|
835
|
+
if (!o) continue;
|
|
836
|
+
const s = d(o.short_name, o.chosen_attribute, o.detailed_user_message) ?? `Search ${n + 1}`, i = Le(o, s);
|
|
837
|
+
if (!i) continue;
|
|
838
|
+
const a = {
|
|
816
839
|
shortName: s,
|
|
817
|
-
action:
|
|
818
|
-
},
|
|
819
|
-
|
|
820
|
-
const
|
|
821
|
-
|
|
840
|
+
action: i
|
|
841
|
+
}, c = d(o.detailed_user_message);
|
|
842
|
+
c && c !== s && (a.detailedMessage = c);
|
|
843
|
+
const l = se(o);
|
|
844
|
+
l && l !== s && l !== (c ?? "") && (a.whyDifferent = l), typeof o.image == "string" && (a.image = o.image), r.push(a);
|
|
822
845
|
}
|
|
823
846
|
return r.length === 0 ? {
|
|
824
847
|
type: "metadata",
|
|
@@ -837,23 +860,23 @@ function Le(e) {
|
|
|
837
860
|
}
|
|
838
861
|
};
|
|
839
862
|
}
|
|
840
|
-
function
|
|
841
|
-
const t = e.payload, r = k(t.requestDetails ?? t.request_details,
|
|
863
|
+
function ve(e) {
|
|
864
|
+
const t = e.payload, r = k(t.requestDetails ?? t.request_details, d(t.review_count, t.reviewCount, t.text, t.title) ?? "Show product reviews");
|
|
842
865
|
if (!r) return {
|
|
843
866
|
type: "metadata",
|
|
844
867
|
sessionId: "",
|
|
845
868
|
model: "",
|
|
846
869
|
meta: { groundingReview: t }
|
|
847
870
|
};
|
|
848
|
-
const
|
|
849
|
-
return t.title && (
|
|
871
|
+
const n = { action: r };
|
|
872
|
+
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
873
|
type: "ui_spec",
|
|
851
874
|
widget: "chat",
|
|
852
875
|
spec: {
|
|
853
876
|
root: "root",
|
|
854
877
|
elements: { root: {
|
|
855
878
|
type: "GroundingReviewCard",
|
|
856
|
-
props:
|
|
879
|
+
props: n
|
|
857
880
|
} }
|
|
858
881
|
}
|
|
859
882
|
};
|
|
@@ -866,7 +889,7 @@ function qe() {
|
|
|
866
889
|
meta: { analyzeAnimation: !0 }
|
|
867
890
|
};
|
|
868
891
|
}
|
|
869
|
-
function
|
|
892
|
+
function je(e) {
|
|
870
893
|
return {
|
|
871
894
|
type: "metadata",
|
|
872
895
|
sessionId: "",
|
|
@@ -874,21 +897,21 @@ function ve(e) {
|
|
|
874
897
|
meta: { voice: e.payload }
|
|
875
898
|
};
|
|
876
899
|
}
|
|
877
|
-
function
|
|
900
|
+
function Be(e) {
|
|
878
901
|
const t = e.payload.group_list ?? [], r = [];
|
|
879
|
-
for (const
|
|
880
|
-
const s =
|
|
902
|
+
for (const o of t) {
|
|
903
|
+
const s = o.group_name ?? "", i = (o.product_list ?? []).map(w);
|
|
881
904
|
r.push({
|
|
882
905
|
groupName: s,
|
|
883
906
|
products: i
|
|
884
907
|
});
|
|
885
908
|
}
|
|
886
|
-
const
|
|
887
|
-
for (const
|
|
888
|
-
const s =
|
|
909
|
+
const n = [];
|
|
910
|
+
for (const o of e.payload.filter_tags ?? []) {
|
|
911
|
+
const s = o.title ?? "";
|
|
889
912
|
if (!s) continue;
|
|
890
|
-
const i = k(
|
|
891
|
-
i && (a.action = i),
|
|
913
|
+
const i = k(o.requestDetails, s), a = { title: s };
|
|
914
|
+
i && (a.action = i), n.push(a);
|
|
892
915
|
}
|
|
893
916
|
return {
|
|
894
917
|
type: "ui_spec",
|
|
@@ -899,14 +922,14 @@ function je(e) {
|
|
|
899
922
|
type: "CategoriesContainer",
|
|
900
923
|
props: {
|
|
901
924
|
groups: r,
|
|
902
|
-
filterTags:
|
|
925
|
+
filterTags: n
|
|
903
926
|
}
|
|
904
927
|
} }
|
|
905
928
|
},
|
|
906
929
|
panelHint: "panel"
|
|
907
930
|
};
|
|
908
931
|
}
|
|
909
|
-
function
|
|
932
|
+
function Me(e) {
|
|
910
933
|
return {
|
|
911
934
|
type: "metadata",
|
|
912
935
|
sessionId: "",
|
|
@@ -917,7 +940,7 @@ function Be(e) {
|
|
|
917
940
|
}
|
|
918
941
|
};
|
|
919
942
|
}
|
|
920
|
-
function
|
|
943
|
+
function ze(e) {
|
|
921
944
|
const t = {};
|
|
922
945
|
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
946
|
type: "ui_spec",
|
|
@@ -931,7 +954,7 @@ function Me(e) {
|
|
|
931
954
|
}
|
|
932
955
|
};
|
|
933
956
|
}
|
|
934
|
-
function
|
|
957
|
+
function He(e) {
|
|
935
958
|
return {
|
|
936
959
|
type: "metadata",
|
|
937
960
|
sessionId: "",
|
|
@@ -943,23 +966,23 @@ function q(e, t) {
|
|
|
943
966
|
const r = {
|
|
944
967
|
product: e,
|
|
945
968
|
index: t
|
|
946
|
-
},
|
|
947
|
-
return
|
|
948
|
-
title: typeof
|
|
969
|
+
}, n = e, o = typeof n.sku == "string" ? n.sku : void 0;
|
|
970
|
+
return o && (r.action = {
|
|
971
|
+
title: typeof n.name == "string" ? n.name : "",
|
|
949
972
|
type: "launchSingleProduct",
|
|
950
|
-
payload: { sku:
|
|
973
|
+
payload: { sku: o }
|
|
951
974
|
}), {
|
|
952
975
|
type: "ProductCard",
|
|
953
976
|
props: r
|
|
954
977
|
};
|
|
955
978
|
}
|
|
956
979
|
function V(e, t) {
|
|
957
|
-
const r = {},
|
|
958
|
-
for (let
|
|
959
|
-
const s = e[
|
|
980
|
+
const r = {}, n = [];
|
|
981
|
+
for (let o = 0; o < e.length; o++) {
|
|
982
|
+
const s = e[o];
|
|
960
983
|
if (!s) continue;
|
|
961
|
-
const i = `action-${
|
|
962
|
-
|
|
984
|
+
const i = `action-${o}`;
|
|
985
|
+
n.push(i);
|
|
963
986
|
const a = {
|
|
964
987
|
label: s.label,
|
|
965
988
|
action: s.action
|
|
@@ -971,14 +994,14 @@ function V(e, t) {
|
|
|
971
994
|
}
|
|
972
995
|
return r.root = {
|
|
973
996
|
type: "ActionButtons",
|
|
974
|
-
props: { buttons: e.map((
|
|
997
|
+
props: { buttons: e.map((o) => {
|
|
975
998
|
const s = {
|
|
976
|
-
label:
|
|
977
|
-
action:
|
|
999
|
+
label: o.label,
|
|
1000
|
+
action: o.action
|
|
978
1001
|
};
|
|
979
|
-
return
|
|
1002
|
+
return o.image !== void 0 && (s.image = o.image), o.description !== void 0 && (s.description = o.description), o.icon !== void 0 && (s.icon = o.icon), s;
|
|
980
1003
|
}) },
|
|
981
|
-
children:
|
|
1004
|
+
children: n
|
|
982
1005
|
}, {
|
|
983
1006
|
type: "ui_spec",
|
|
984
1007
|
widget: t,
|
|
@@ -988,18 +1011,18 @@ function V(e, t) {
|
|
|
988
1011
|
}
|
|
989
1012
|
};
|
|
990
1013
|
}
|
|
991
|
-
function
|
|
992
|
-
const r = {},
|
|
993
|
-
for (let
|
|
994
|
-
const s = e[
|
|
1014
|
+
function R(e, t) {
|
|
1015
|
+
const r = {}, n = [];
|
|
1016
|
+
for (let o = 0; o < e.length; o++) {
|
|
1017
|
+
const s = e[o];
|
|
995
1018
|
if (!s) continue;
|
|
996
|
-
const i =
|
|
997
|
-
|
|
1019
|
+
const i = w(s), a = `product-${o}`;
|
|
1020
|
+
n.push(a), r[a] = q(i, o);
|
|
998
1021
|
}
|
|
999
1022
|
return r.root = {
|
|
1000
1023
|
type: "ProductGrid",
|
|
1001
1024
|
props: { layout: "grid" },
|
|
1002
|
-
children:
|
|
1025
|
+
children: n
|
|
1003
1026
|
}, {
|
|
1004
1027
|
type: "ui_spec",
|
|
1005
1028
|
widget: t,
|
|
@@ -1009,22 +1032,22 @@ function N(e, t) {
|
|
|
1009
1032
|
}
|
|
1010
1033
|
};
|
|
1011
1034
|
}
|
|
1012
|
-
function
|
|
1013
|
-
const
|
|
1014
|
-
for (const
|
|
1015
|
-
|
|
1016
|
-
if (
|
|
1017
|
-
const
|
|
1035
|
+
function Ue(e, t, r) {
|
|
1036
|
+
const n = /* @__PURE__ */ new Map();
|
|
1037
|
+
for (const l of t)
|
|
1038
|
+
l?.sku && n.set(l.sku, l);
|
|
1039
|
+
if (n.size === 0) return null;
|
|
1040
|
+
const o = /* @__PURE__ */ new Set(), s = {}, i = [], a = [];
|
|
1018
1041
|
let c = 0;
|
|
1019
|
-
for (let
|
|
1020
|
-
const _ = e[
|
|
1021
|
-
for (let
|
|
1022
|
-
const y = typeof
|
|
1023
|
-
if (!y ||
|
|
1024
|
-
const
|
|
1025
|
-
if (!
|
|
1026
|
-
|
|
1027
|
-
const h = `product-${
|
|
1042
|
+
for (let l = 0; l < e.length; l++) {
|
|
1043
|
+
const _ = e[l], u = d(_?.title) ?? "", g = Array.isArray(_?.skus) ? _.skus : [], f = [];
|
|
1044
|
+
for (let p = 0; p < g.length; p++) {
|
|
1045
|
+
const y = typeof g[p] == "string" ? g[p].trim() : "";
|
|
1046
|
+
if (!y || o.has(y)) continue;
|
|
1047
|
+
const m = n.get(y);
|
|
1048
|
+
if (!m) continue;
|
|
1049
|
+
o.add(y);
|
|
1050
|
+
const h = `product-${l}-${p}`, Y = w(m);
|
|
1028
1051
|
i.push(h), f.push(h), s[h] = q(Y, c), c += 1;
|
|
1029
1052
|
}
|
|
1030
1053
|
f.length > 0 && a.push({
|
|
@@ -1032,7 +1055,7 @@ function He(e, t, r) {
|
|
|
1032
1055
|
children: f
|
|
1033
1056
|
});
|
|
1034
1057
|
}
|
|
1035
|
-
return a.length === 0 ||
|
|
1058
|
+
return a.length === 0 || o.size < n.size ? null : (s.root = {
|
|
1036
1059
|
type: "ProductGrid",
|
|
1037
1060
|
props: {
|
|
1038
1061
|
layout: "grouped",
|
|
@@ -1048,18 +1071,18 @@ function He(e, t, r) {
|
|
|
1048
1071
|
}
|
|
1049
1072
|
});
|
|
1050
1073
|
}
|
|
1051
|
-
function
|
|
1052
|
-
const r = {},
|
|
1053
|
-
for (let
|
|
1054
|
-
const s = e[
|
|
1074
|
+
function Ge(e, t) {
|
|
1075
|
+
const r = {}, n = [];
|
|
1076
|
+
for (let o = 0; o < e.length; o++) {
|
|
1077
|
+
const s = e[o];
|
|
1055
1078
|
if (!s) continue;
|
|
1056
|
-
const i = `product-${
|
|
1057
|
-
|
|
1079
|
+
const i = `product-${o}`;
|
|
1080
|
+
n.push(i), r[i] = q(s, o);
|
|
1058
1081
|
}
|
|
1059
1082
|
return r.root = {
|
|
1060
1083
|
type: "ProductGrid",
|
|
1061
1084
|
props: { layout: "grid" },
|
|
1062
|
-
children:
|
|
1085
|
+
children: n
|
|
1063
1086
|
}, {
|
|
1064
1087
|
type: "ui_spec",
|
|
1065
1088
|
widget: t,
|
|
@@ -1069,7 +1092,7 @@ function Ue(e, t) {
|
|
|
1069
1092
|
}
|
|
1070
1093
|
};
|
|
1071
1094
|
}
|
|
1072
|
-
function
|
|
1095
|
+
function $e(e, t) {
|
|
1073
1096
|
return {
|
|
1074
1097
|
type: "ui_spec",
|
|
1075
1098
|
widget: t,
|
|
@@ -1078,14 +1101,14 @@ function Ge(e, t) {
|
|
|
1078
1101
|
elements: { root: {
|
|
1079
1102
|
type: "ProductCard",
|
|
1080
1103
|
props: {
|
|
1081
|
-
product:
|
|
1104
|
+
product: w(e),
|
|
1082
1105
|
index: 0
|
|
1083
1106
|
}
|
|
1084
1107
|
} }
|
|
1085
1108
|
}
|
|
1086
1109
|
};
|
|
1087
1110
|
}
|
|
1088
|
-
function
|
|
1111
|
+
function Fe(e) {
|
|
1089
1112
|
return {
|
|
1090
1113
|
type: "ui_spec",
|
|
1091
1114
|
widget: e,
|
|
@@ -1099,60 +1122,60 @@ function $e(e) {
|
|
|
1099
1122
|
}
|
|
1100
1123
|
};
|
|
1101
1124
|
}
|
|
1102
|
-
function
|
|
1103
|
-
const t =
|
|
1104
|
-
return
|
|
1125
|
+
function Ke(e) {
|
|
1126
|
+
const t = d(e.sku), r = d(e.short_name), n = { ...b(e.product_item) ?? e }, o = d(e.discount_reason, e.discountReason);
|
|
1127
|
+
return o && !d(n.discount_reason, n.discountReason) && (n.discount_reason = o), j(n, t, r);
|
|
1105
1128
|
}
|
|
1106
|
-
function
|
|
1107
|
-
const
|
|
1108
|
-
if (!
|
|
1129
|
+
function j(e, t, r) {
|
|
1130
|
+
const n = d(e.sku, t), o = d(e.name, r);
|
|
1131
|
+
if (!n || !o) return null;
|
|
1109
1132
|
const s = {
|
|
1110
|
-
sku:
|
|
1111
|
-
name:
|
|
1112
|
-
}, i =
|
|
1133
|
+
sku: n,
|
|
1134
|
+
name: o
|
|
1135
|
+
}, i = d(e.brand);
|
|
1113
1136
|
i && (s.brand = i);
|
|
1114
|
-
const a =
|
|
1137
|
+
const a = d(e.url);
|
|
1115
1138
|
a && (s.url = a);
|
|
1116
|
-
const c =
|
|
1139
|
+
const c = Ve(e.images);
|
|
1117
1140
|
if (c.length > 0) s.images = c;
|
|
1118
1141
|
else {
|
|
1119
|
-
const y =
|
|
1142
|
+
const y = d(e.image, e.image_url, e.imageUrl);
|
|
1120
1143
|
y && (s.images = [y]);
|
|
1121
1144
|
}
|
|
1122
|
-
const
|
|
1123
|
-
|
|
1145
|
+
const l = x(e.price_discounted);
|
|
1146
|
+
l !== void 0 && (s.price_discounted = l);
|
|
1124
1147
|
const _ = x(e.price);
|
|
1125
1148
|
_ !== void 0 && (s.price = _);
|
|
1126
1149
|
const u = x(e.rating);
|
|
1127
1150
|
u !== void 0 && (s.rating = u);
|
|
1128
|
-
const
|
|
1129
|
-
|
|
1130
|
-
const f =
|
|
1151
|
+
const g = x(e.review_count) ?? x(e.reviewCount);
|
|
1152
|
+
g !== void 0 && (s.review_count = g);
|
|
1153
|
+
const f = d(e.cart_code, e.cartCode);
|
|
1131
1154
|
f && (s.cart_code = f), typeof e.in_stock == "boolean" && (s.in_stock = e.in_stock), typeof e.inStock == "boolean" && (s.in_stock = e.inStock);
|
|
1132
|
-
const
|
|
1133
|
-
return
|
|
1155
|
+
const p = d(e.discount_reason, e.discountReason);
|
|
1156
|
+
return p && (s.discount_reason = p), w(s);
|
|
1134
1157
|
}
|
|
1135
1158
|
function k(e, t) {
|
|
1136
1159
|
const r = b(e);
|
|
1137
1160
|
if (!r) return null;
|
|
1138
|
-
const
|
|
1139
|
-
if (typeof
|
|
1140
|
-
const
|
|
1141
|
-
title: t ||
|
|
1142
|
-
type:
|
|
1161
|
+
const n = r.type;
|
|
1162
|
+
if (typeof n != "string" || n.length === 0) return null;
|
|
1163
|
+
const o = {
|
|
1164
|
+
title: t || n,
|
|
1165
|
+
type: n
|
|
1143
1166
|
};
|
|
1144
|
-
return r.payload !== void 0 && (
|
|
1167
|
+
return r.payload !== void 0 && (o.payload = r.payload), o;
|
|
1145
1168
|
}
|
|
1146
1169
|
function b(e) {
|
|
1147
1170
|
return !e || typeof e != "object" || Array.isArray(e) ? null : e;
|
|
1148
1171
|
}
|
|
1149
|
-
function
|
|
1172
|
+
function d(...e) {
|
|
1150
1173
|
for (const t of e) if (typeof t == "string") {
|
|
1151
1174
|
const r = t.trim();
|
|
1152
1175
|
if (r.length > 0) return r;
|
|
1153
1176
|
}
|
|
1154
1177
|
}
|
|
1155
|
-
function
|
|
1178
|
+
function Ve(e) {
|
|
1156
1179
|
return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.length > 0) : [];
|
|
1157
1180
|
}
|
|
1158
1181
|
function W(e) {
|
|
@@ -1171,10 +1194,10 @@ function x(e) {
|
|
|
1171
1194
|
if (Number.isFinite(r)) return r;
|
|
1172
1195
|
}
|
|
1173
1196
|
}
|
|
1174
|
-
function
|
|
1197
|
+
function C(e) {
|
|
1175
1198
|
return e != null;
|
|
1176
1199
|
}
|
|
1177
|
-
var
|
|
1200
|
+
var We = /* @__PURE__ */ new Set([
|
|
1178
1201
|
"sku",
|
|
1179
1202
|
"name",
|
|
1180
1203
|
"brand",
|
|
@@ -1200,35 +1223,35 @@ var Ve = /* @__PURE__ */ new Set([
|
|
|
1200
1223
|
"facet_hits",
|
|
1201
1224
|
"promotions"
|
|
1202
1225
|
]);
|
|
1203
|
-
function
|
|
1204
|
-
const t = e.price_discounted != null && e.price_discounted > 0, r = t ? e.price_discounted : e.price,
|
|
1205
|
-
let
|
|
1206
|
-
|
|
1207
|
-
const s =
|
|
1226
|
+
function w(e) {
|
|
1227
|
+
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;
|
|
1228
|
+
let o;
|
|
1229
|
+
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);
|
|
1230
|
+
const s = d(e.brand), i = d(e.name) ?? e.sku, a = s && !i.toLowerCase().startsWith(s.toLowerCase()) ? `${s} ${i}` : i, c = {
|
|
1208
1231
|
sku: e.sku,
|
|
1209
1232
|
name: a,
|
|
1210
|
-
url:
|
|
1211
|
-
},
|
|
1212
|
-
|
|
1233
|
+
url: d(e.url) ?? ""
|
|
1234
|
+
}, l = e.images?.[0];
|
|
1235
|
+
l && (c.imageUrl = l), 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), s !== void 0 && (c.brand = s), 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);
|
|
1213
1236
|
const _ = e, u = {};
|
|
1214
|
-
let
|
|
1215
|
-
for (const f of Object.keys(_))
|
|
1216
|
-
return
|
|
1237
|
+
let g = !1;
|
|
1238
|
+
for (const f of Object.keys(_)) We.has(f) || (u[f] = _[f], g = !0);
|
|
1239
|
+
return g && (c.extras = u), c;
|
|
1217
1240
|
}
|
|
1218
|
-
function
|
|
1219
|
-
return e.results.map(
|
|
1241
|
+
function St(e) {
|
|
1242
|
+
return e.results.map(w);
|
|
1220
1243
|
}
|
|
1221
1244
|
function At(e) {
|
|
1222
1245
|
return e.product_groupings.map((t) => {
|
|
1223
1246
|
const r = {
|
|
1224
1247
|
name: t.name,
|
|
1225
|
-
products: (t.group_products ?? []).map(
|
|
1248
|
+
products: (t.group_products ?? []).map(w)
|
|
1226
1249
|
};
|
|
1227
1250
|
return t.highlight !== void 0 && (r.highlight = t.highlight), r;
|
|
1228
1251
|
});
|
|
1229
1252
|
}
|
|
1230
|
-
function
|
|
1231
|
-
const t = e.payload.type, { type: r, ...
|
|
1253
|
+
function Je(e) {
|
|
1254
|
+
const t = e.payload.type, { type: r, ...n } = e.payload;
|
|
1232
1255
|
return {
|
|
1233
1256
|
type: "ui_spec",
|
|
1234
1257
|
widget: "chat",
|
|
@@ -1236,56 +1259,56 @@ function We(e) {
|
|
|
1236
1259
|
root: "root",
|
|
1237
1260
|
elements: { root: {
|
|
1238
1261
|
type: t,
|
|
1239
|
-
props:
|
|
1262
|
+
props: n
|
|
1240
1263
|
} }
|
|
1241
1264
|
}
|
|
1242
1265
|
};
|
|
1243
1266
|
}
|
|
1244
|
-
var
|
|
1267
|
+
var Qe = {
|
|
1245
1268
|
process_action: "/process_action",
|
|
1246
1269
|
launcher_action: "/launcher_action",
|
|
1247
1270
|
similar_products: "/similar_products",
|
|
1248
1271
|
product_groupings: "/product_groupings"
|
|
1249
1272
|
};
|
|
1250
|
-
function
|
|
1273
|
+
function Ye(e) {
|
|
1251
1274
|
if (e === void 0) throw new Error("[gengage] middlewareUrl is required. Pass your Gengage backend URL in widget config.");
|
|
1252
1275
|
const t = e.trim();
|
|
1253
1276
|
return t === "" ? "" : t.replace(/\/+$/, "");
|
|
1254
1277
|
}
|
|
1255
1278
|
function wt(e, t) {
|
|
1256
|
-
return `${
|
|
1257
|
-
}
|
|
1258
|
-
var
|
|
1259
|
-
async function
|
|
1260
|
-
const
|
|
1261
|
-
if (!
|
|
1262
|
-
const
|
|
1263
|
-
if (s) return
|
|
1279
|
+
return `${Ye(t?.middlewareUrl)}/chat${Qe[e]}`;
|
|
1280
|
+
}
|
|
1281
|
+
var Xe = 7200 * 1e3, J = 200, Ze = 5 * 1024 * 1024, et = "gengage_request_response_cache", tt = 1, A = "responses", rt = /* @__PURE__ */ new Set(["addToCart", "like"]), S = /* @__PURE__ */ new Map(), H = null;
|
|
1282
|
+
async function xt(e, t = {}, r = {}) {
|
|
1283
|
+
const n = nt(e, t);
|
|
1284
|
+
if (!n) return fetch(e, t);
|
|
1285
|
+
const o = Date.now(), s = await at(n, o);
|
|
1286
|
+
if (s) return dt(s);
|
|
1264
1287
|
const i = await fetch(e, t);
|
|
1265
|
-
return i.ok &&
|
|
1266
|
-
ttlMs: r.ttlMs ??
|
|
1288
|
+
return i.ok && ct(n, i.clone(), o, {
|
|
1289
|
+
ttlMs: r.ttlMs ?? Xe,
|
|
1267
1290
|
maxEntries: r.maxEntries ?? J,
|
|
1268
|
-
maxBodyBytes: r.maxBodyBytes ??
|
|
1291
|
+
maxBodyBytes: r.maxBodyBytes ?? Ze
|
|
1269
1292
|
}), i;
|
|
1270
1293
|
}
|
|
1271
|
-
function
|
|
1294
|
+
function nt(e, t = {}) {
|
|
1272
1295
|
if (typeof Request < "u" && e instanceof Request) return null;
|
|
1273
1296
|
const r = String(t.method || "GET").toUpperCase();
|
|
1274
1297
|
if (r !== "POST" || typeof t.body != "string") return null;
|
|
1275
|
-
const
|
|
1276
|
-
if (
|
|
1277
|
-
const
|
|
1278
|
-
if (
|
|
1279
|
-
const s = P(
|
|
1298
|
+
const n = ot(t.body);
|
|
1299
|
+
if (st(n)) return null;
|
|
1300
|
+
const o = it(n);
|
|
1301
|
+
if (o) {
|
|
1302
|
+
const s = P(n?.action);
|
|
1280
1303
|
return `rr:${$(G({
|
|
1281
1304
|
url: String(e),
|
|
1282
1305
|
method: r,
|
|
1283
1306
|
headers: U(t.headers),
|
|
1284
|
-
type:
|
|
1285
|
-
account_id:
|
|
1286
|
-
locale:
|
|
1287
|
-
outputLanguage: P(
|
|
1288
|
-
cache_key:
|
|
1307
|
+
type: n?.type ?? s?.type ?? "",
|
|
1308
|
+
account_id: n?.account_id ?? n?.accountId ?? "",
|
|
1309
|
+
locale: n?.locale ?? "",
|
|
1310
|
+
outputLanguage: P(n?.meta)?.outputLanguage ?? "",
|
|
1311
|
+
cache_key: o
|
|
1289
1312
|
}))}`;
|
|
1290
1313
|
}
|
|
1291
1314
|
return `rr:${$(G({
|
|
@@ -1303,44 +1326,44 @@ function ot(e) {
|
|
|
1303
1326
|
return null;
|
|
1304
1327
|
}
|
|
1305
1328
|
}
|
|
1306
|
-
function
|
|
1329
|
+
function st(e) {
|
|
1307
1330
|
const t = e?.type;
|
|
1308
|
-
return typeof t == "string" &&
|
|
1331
|
+
return typeof t == "string" && rt.has(t);
|
|
1309
1332
|
}
|
|
1310
|
-
function
|
|
1333
|
+
function it(e) {
|
|
1311
1334
|
const t = (P(e?.payload) ?? P(P(e?.action)?.payload))?.cache_key;
|
|
1312
1335
|
return typeof t == "string" && t.trim().length > 0 ? t.trim() : null;
|
|
1313
1336
|
}
|
|
1314
|
-
async function
|
|
1315
|
-
const r =
|
|
1316
|
-
if (r) if (r.expiresAt <= t)
|
|
1337
|
+
async function at(e, t) {
|
|
1338
|
+
const r = S.get(e);
|
|
1339
|
+
if (r) if (r.expiresAt <= t) S.delete(e);
|
|
1317
1340
|
else
|
|
1318
|
-
return r.lastAccessedAt = t,
|
|
1319
|
-
const
|
|
1320
|
-
return
|
|
1341
|
+
return r.lastAccessedAt = t, S.delete(e), S.set(e, r), L(r), r;
|
|
1342
|
+
const n = await pt(e);
|
|
1343
|
+
return n ? n.expiresAt <= t ? (S.delete(e), ft(e), null) : (n.lastAccessedAt = t, S.set(e, n), L(n), Q(J), n) : null;
|
|
1321
1344
|
}
|
|
1322
|
-
async function
|
|
1345
|
+
async function ct(e, t, r, n) {
|
|
1323
1346
|
try {
|
|
1324
|
-
const
|
|
1325
|
-
if (
|
|
1347
|
+
const o = await t.text();
|
|
1348
|
+
if (gt(o) > n.maxBodyBytes || ut(o)) return;
|
|
1326
1349
|
const s = {
|
|
1327
1350
|
key: e,
|
|
1328
1351
|
status: t.status,
|
|
1329
1352
|
statusText: t.statusText,
|
|
1330
|
-
headers:
|
|
1331
|
-
body:
|
|
1353
|
+
headers: lt(t.headers),
|
|
1354
|
+
body: o,
|
|
1332
1355
|
createdAt: r,
|
|
1333
|
-
expiresAt: r +
|
|
1356
|
+
expiresAt: r + n.ttlMs,
|
|
1334
1357
|
lastAccessedAt: r
|
|
1335
1358
|
};
|
|
1336
|
-
|
|
1359
|
+
S.set(e, s), Q(n.maxEntries), await L(s), await yt(n.maxEntries, r);
|
|
1337
1360
|
} catch {
|
|
1338
1361
|
}
|
|
1339
1362
|
}
|
|
1340
|
-
function
|
|
1363
|
+
function ut(e) {
|
|
1341
1364
|
return /"_error"\s*:/u.test(e) || /"type"\s*:\s*"error"/u.test(e);
|
|
1342
1365
|
}
|
|
1343
|
-
function
|
|
1366
|
+
function dt(e) {
|
|
1344
1367
|
return new Response(e.body, {
|
|
1345
1368
|
status: e.status,
|
|
1346
1369
|
statusText: e.statusText,
|
|
@@ -1349,104 +1372,104 @@ function ut(e) {
|
|
|
1349
1372
|
}
|
|
1350
1373
|
function U(e) {
|
|
1351
1374
|
const t = new Headers(e), r = [];
|
|
1352
|
-
return t.forEach((
|
|
1353
|
-
const s =
|
|
1354
|
-
s !== "authorization" && s !== "cookie" && r.push([s,
|
|
1355
|
-
}), r.sort(([
|
|
1375
|
+
return t.forEach((n, o) => {
|
|
1376
|
+
const s = o.toLowerCase();
|
|
1377
|
+
s !== "authorization" && s !== "cookie" && r.push([s, n]);
|
|
1378
|
+
}), r.sort(([n], [o]) => n.localeCompare(o));
|
|
1356
1379
|
}
|
|
1357
|
-
function
|
|
1380
|
+
function lt(e) {
|
|
1358
1381
|
const t = [];
|
|
1359
|
-
return e.forEach((r,
|
|
1360
|
-
const
|
|
1361
|
-
|
|
1362
|
-
}), t.sort(([r], [
|
|
1382
|
+
return e.forEach((r, n) => {
|
|
1383
|
+
const o = n.toLowerCase();
|
|
1384
|
+
o !== "set-cookie" && t.push([o, r]);
|
|
1385
|
+
}), t.sort(([r], [n]) => r.localeCompare(n));
|
|
1363
1386
|
}
|
|
1364
1387
|
function Q(e) {
|
|
1365
|
-
for (;
|
|
1366
|
-
const t = [...
|
|
1388
|
+
for (; S.size > e; ) {
|
|
1389
|
+
const t = [...S.values()].sort((r, n) => r.lastAccessedAt - n.lastAccessedAt)[0];
|
|
1367
1390
|
if (!t) break;
|
|
1368
|
-
|
|
1391
|
+
S.delete(t.key);
|
|
1369
1392
|
}
|
|
1370
1393
|
}
|
|
1371
|
-
async function
|
|
1394
|
+
async function D() {
|
|
1372
1395
|
return typeof indexedDB > "u" ? null : (H ??= new Promise((e) => {
|
|
1373
|
-
const t = indexedDB.open(
|
|
1396
|
+
const t = indexedDB.open(et, tt);
|
|
1374
1397
|
t.onupgradeneeded = () => {
|
|
1375
1398
|
const r = t.result;
|
|
1376
|
-
r.objectStoreNames.contains(
|
|
1399
|
+
r.objectStoreNames.contains(A) || r.createObjectStore(A, { keyPath: "key" }).createIndex("lastAccessedAt", "lastAccessedAt", { unique: !1 });
|
|
1377
1400
|
}, t.onsuccess = () => e(t.result), t.onerror = () => e(null), t.onblocked = () => e(null);
|
|
1378
1401
|
}), H);
|
|
1379
1402
|
}
|
|
1380
|
-
async function
|
|
1381
|
-
const t = await
|
|
1403
|
+
async function pt(e) {
|
|
1404
|
+
const t = await D();
|
|
1382
1405
|
return t ? new Promise((r) => {
|
|
1383
|
-
const
|
|
1384
|
-
|
|
1406
|
+
const n = t.transaction(A, "readonly"), o = n.objectStore(A).get(e);
|
|
1407
|
+
o.onsuccess = () => r(o.result ?? null), o.onerror = () => r(null), n.onerror = () => r(null);
|
|
1385
1408
|
}) : null;
|
|
1386
1409
|
}
|
|
1387
|
-
async function
|
|
1388
|
-
const t = await
|
|
1410
|
+
async function L(e) {
|
|
1411
|
+
const t = await D();
|
|
1389
1412
|
t && await new Promise((r) => {
|
|
1390
|
-
const
|
|
1391
|
-
|
|
1413
|
+
const n = t.transaction(A, "readwrite");
|
|
1414
|
+
n.objectStore(A).put(e), n.oncomplete = () => r(), n.onerror = () => r(), n.onabort = () => r();
|
|
1392
1415
|
});
|
|
1393
1416
|
}
|
|
1394
|
-
async function
|
|
1395
|
-
const t = await
|
|
1417
|
+
async function ft(e) {
|
|
1418
|
+
const t = await D();
|
|
1396
1419
|
t && await new Promise((r) => {
|
|
1397
|
-
const
|
|
1398
|
-
|
|
1420
|
+
const n = t.transaction(A, "readwrite");
|
|
1421
|
+
n.objectStore(A).delete(e), n.oncomplete = () => r(), n.onerror = () => r(), n.onabort = () => r();
|
|
1399
1422
|
});
|
|
1400
1423
|
}
|
|
1401
|
-
async function
|
|
1402
|
-
const r = await
|
|
1403
|
-
r && await new Promise((
|
|
1404
|
-
const
|
|
1424
|
+
async function yt(e, t) {
|
|
1425
|
+
const r = await D();
|
|
1426
|
+
r && await new Promise((n) => {
|
|
1427
|
+
const o = r.transaction(A, "readwrite"), s = o.objectStore(A), i = [], a = s.openCursor();
|
|
1405
1428
|
a.onsuccess = () => {
|
|
1406
1429
|
const c = a.result;
|
|
1407
1430
|
if (!c) {
|
|
1408
|
-
const
|
|
1409
|
-
for (const u of [...
|
|
1431
|
+
const l = i.filter((u) => u.expiresAt <= t), _ = i.filter((u) => u.expiresAt > t).sort((u, g) => u.lastAccessedAt - g.lastAccessedAt).slice(0, Math.max(0, i.length - l.length - e));
|
|
1432
|
+
for (const u of [...l, ..._]) s.delete(u.key);
|
|
1410
1433
|
return;
|
|
1411
1434
|
}
|
|
1412
1435
|
i.push(c.value), c.continue();
|
|
1413
|
-
}, a.onerror = () =>
|
|
1436
|
+
}, a.onerror = () => n(), o.oncomplete = () => n(), o.onerror = () => n(), o.onabort = () => n();
|
|
1414
1437
|
});
|
|
1415
1438
|
}
|
|
1416
1439
|
function G(e) {
|
|
1417
|
-
return JSON.stringify(
|
|
1440
|
+
return JSON.stringify(O(e));
|
|
1418
1441
|
}
|
|
1419
1442
|
function P(e) {
|
|
1420
1443
|
return e && typeof e == "object" && !Array.isArray(e) ? e : null;
|
|
1421
1444
|
}
|
|
1422
|
-
function
|
|
1423
|
-
return Array.isArray(e) ? e.map(
|
|
1445
|
+
function O(e) {
|
|
1446
|
+
return Array.isArray(e) ? e.map(O) : !e || typeof e != "object" ? e : Object.fromEntries(Object.entries(e).sort(([t], [r]) => t.localeCompare(r)).map(([t, r]) => [t, O(r)]));
|
|
1424
1447
|
}
|
|
1425
1448
|
function $(e) {
|
|
1426
1449
|
let t = 14695981039346656037n;
|
|
1427
1450
|
const r = 1099511628211n;
|
|
1428
|
-
for (let
|
|
1429
|
-
t ^= BigInt(e.charCodeAt(
|
|
1451
|
+
for (let n = 0; n < e.length; n += 1)
|
|
1452
|
+
t ^= BigInt(e.charCodeAt(n)), t = BigInt.asUintN(64, t * r);
|
|
1430
1453
|
return t.toString(16).padStart(16, "0");
|
|
1431
1454
|
}
|
|
1432
|
-
function
|
|
1455
|
+
function gt(e) {
|
|
1433
1456
|
return typeof TextEncoder < "u" ? new TextEncoder().encode(e).byteLength : e.length;
|
|
1434
1457
|
}
|
|
1435
1458
|
export {
|
|
1436
1459
|
At as a,
|
|
1437
|
-
|
|
1460
|
+
I as c,
|
|
1438
1461
|
se as d,
|
|
1439
1462
|
te as f,
|
|
1440
|
-
|
|
1463
|
+
_t as g,
|
|
1441
1464
|
Z as h,
|
|
1442
|
-
|
|
1465
|
+
kt as i,
|
|
1443
1466
|
ie as l,
|
|
1444
|
-
|
|
1467
|
+
ht as m,
|
|
1445
1468
|
wt as n,
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1469
|
+
St as o,
|
|
1470
|
+
bt as p,
|
|
1471
|
+
Ye as r,
|
|
1472
|
+
w as s,
|
|
1473
|
+
xt as t,
|
|
1474
|
+
oe as u
|
|
1452
1475
|
};
|