@gengage/assistant-fe 0.6.26 → 0.6.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agentic/debug/activity-collector.d.ts +1 -0
- package/dist/agentic/index.js +374 -353
- package/dist/agentic/types.d.ts +3 -0
- package/dist/agentic/worker.js +1 -1
- package/dist/agentic.iife.js +5 -4
- package/dist/{api-paths-CmFRzaMd.js → api-paths-C9NwnH29.js} +1 -1
- package/dist/chat-runtime.js +1 -1
- package/dist/chat.iife.js +1 -1
- package/dist/chat.js +1 -1
- package/dist/{common-uHKZ-s5H.js → common-Bhl1mzk2.js} +1 -1
- package/dist/common.js +5 -5
- package/dist/{connection-warning-xRmq7uJ3.js → connection-warning-D-0Mxk-A.js} +1 -1
- package/dist/{fastIntent-B3qZhCis.js → fastIntent-bAlwVoje.js} +1 -1
- package/dist/index.js +10 -10
- package/dist/native.iife.js +1 -1
- package/dist/qna-runtime.js +1 -1
- package/dist/qna.iife.js +1 -1
- package/dist/qna.js +1 -1
- package/dist/{route-params-UDemctx_.js → route-params-5K4Du1Xa.js} +678 -673
- package/dist/{runtime-Cpi9hXiL.js → runtime-BAFZ7iOP.js} +3 -3
- package/dist/{runtime-DhhnaNUQ.js → runtime-CUNLK1KR.js} +3 -3
- package/dist/{runtime-C1mVW5y1.js → runtime-oEtmgT4U.js} +3 -3
- package/dist/{simbut-csGdfd9_.js → simbut-Dt8e5uSk.js} +1 -1
- package/dist/simbut.iife.js +1 -1
- package/dist/simbut.js +1 -1
- package/dist/simrel-runtime.js +1 -1
- package/dist/{simrel-B1VHfhBf.js → simrel-txr23_xG.js} +1 -1
- package/dist/simrel.iife.js +1 -1
- package/dist/simrel.js +2 -2
- package/dist/{widget-base-DNT8SYtf.js → widget-base-56tkaZZB.js} +1 -1
- package/package.json +1 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { t as pe } from "./request-response-cache-BxRsKGJ0.js";
|
|
2
2
|
var me = 120 * 1e3, ye = "gengage-agentic-ref";
|
|
3
|
-
function ge({ namespace: t = ye, ttlMs: e = me, maxEntries:
|
|
4
|
-
const
|
|
3
|
+
function ge({ namespace: t = ye, ttlMs: e = me, maxEntries: n = 100 } = {}) {
|
|
4
|
+
const r = /* @__PURE__ */ new Map();
|
|
5
5
|
async function o(l, u = {}) {
|
|
6
6
|
c();
|
|
7
|
-
const f =
|
|
7
|
+
const f = be(), p = u.kind || "pageRef", m = {
|
|
8
8
|
kind: p,
|
|
9
9
|
value: l,
|
|
10
10
|
expiresAt: Date.now() + (u.ttlMs || e)
|
|
11
11
|
};
|
|
12
|
-
for (
|
|
13
|
-
return await
|
|
12
|
+
for (r.set(f, m); r.size > n; ) r.delete(r.keys().next().value);
|
|
13
|
+
return await we(t, f, m), {
|
|
14
14
|
kind: p,
|
|
15
15
|
id: f
|
|
16
16
|
};
|
|
@@ -18,18 +18,18 @@ function ge({ namespace: t = ye, ttlMs: e = me, maxEntries: r = 100 } = {}) {
|
|
|
18
18
|
async function i(l) {
|
|
19
19
|
const u = typeof l == "string" ? l : l?.id;
|
|
20
20
|
if (!u) return;
|
|
21
|
-
const f =
|
|
21
|
+
const f = r.get(u) || await ke(t, u);
|
|
22
22
|
if (f) {
|
|
23
23
|
if (f.expiresAt <= Date.now()) {
|
|
24
|
-
|
|
24
|
+
r.delete(u), await Ot(t, u);
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
|
-
return
|
|
27
|
+
return r.set(u, f), f.value;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
async function a(l) {
|
|
31
31
|
const u = typeof l == "string" ? l : l?.id;
|
|
32
|
-
u && (
|
|
32
|
+
u && (r.delete(u), await Ot(t, u));
|
|
33
33
|
}
|
|
34
34
|
async function s(l) {
|
|
35
35
|
if (he(l)) return i(l);
|
|
@@ -40,7 +40,7 @@ function ge({ namespace: t = ye, ttlMs: e = me, maxEntries: r = 100 } = {}) {
|
|
|
40
40
|
}
|
|
41
41
|
function c() {
|
|
42
42
|
const l = Date.now();
|
|
43
|
-
for (const [u, f] of
|
|
43
|
+
for (const [u, f] of r.entries()) f.expiresAt <= l && r.delete(u);
|
|
44
44
|
}
|
|
45
45
|
return {
|
|
46
46
|
put: o,
|
|
@@ -53,22 +53,22 @@ function ge({ namespace: t = ye, ttlMs: e = me, maxEntries: r = 100 } = {}) {
|
|
|
53
53
|
function he(t) {
|
|
54
54
|
return !!(t && typeof t == "object" && typeof t.kind == "string" && typeof t.id == "string");
|
|
55
55
|
}
|
|
56
|
-
function
|
|
56
|
+
function be() {
|
|
57
57
|
return globalThis.crypto?.randomUUID ? globalThis.crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
58
58
|
}
|
|
59
|
-
async function
|
|
60
|
-
const
|
|
61
|
-
|
|
59
|
+
async function we(t, e, n) {
|
|
60
|
+
const r = await ft(t);
|
|
61
|
+
r && (await H(r.transaction("refs", "readwrite").objectStore("refs").put(n, e)), r.close());
|
|
62
62
|
}
|
|
63
63
|
async function ke(t, e) {
|
|
64
|
-
const
|
|
65
|
-
if (!
|
|
66
|
-
const
|
|
67
|
-
return
|
|
64
|
+
const n = await ft(t);
|
|
65
|
+
if (!n) return;
|
|
66
|
+
const r = await H(n.transaction("refs", "readonly").objectStore("refs").get(e));
|
|
67
|
+
return n.close(), r;
|
|
68
68
|
}
|
|
69
69
|
async function Ot(t, e) {
|
|
70
|
-
const
|
|
71
|
-
|
|
70
|
+
const n = await ft(t);
|
|
71
|
+
n && (await H(n.transaction("refs", "readwrite").objectStore("refs").delete(e)), n.close());
|
|
72
72
|
}
|
|
73
73
|
async function ft(t) {
|
|
74
74
|
if (!globalThis.indexedDB) return null;
|
|
@@ -82,8 +82,8 @@ async function ft(t) {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
function H(t) {
|
|
85
|
-
return new Promise((e,
|
|
86
|
-
t.onsuccess = () => e(t.result), t.onerror = () =>
|
|
85
|
+
return new Promise((e, n) => {
|
|
86
|
+
t.onsuccess = () => e(t.result), t.onerror = () => n(t.error);
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
89
|
function Ae(t) {
|
|
@@ -92,15 +92,15 @@ function Ae(t) {
|
|
|
92
92
|
function _e(t) {
|
|
93
93
|
return !!t && typeof t == "object" && t.type === "rpc.req";
|
|
94
94
|
}
|
|
95
|
-
function
|
|
95
|
+
function Rr(t = self) {
|
|
96
96
|
let e = 1;
|
|
97
|
-
const
|
|
98
|
-
return t.addEventListener("message", (
|
|
99
|
-
const o =
|
|
97
|
+
const n = /* @__PURE__ */ new Map();
|
|
98
|
+
return t.addEventListener("message", (r) => {
|
|
99
|
+
const o = r.data;
|
|
100
100
|
if (!Ae(o)) return;
|
|
101
|
-
const i =
|
|
101
|
+
const i = n.get(o.rpcId);
|
|
102
102
|
if (i) {
|
|
103
|
-
if (
|
|
103
|
+
if (n.delete(o.rpcId), o.ok === !1) {
|
|
104
104
|
const a = typeof o.error == "object" ? o.error?.message : o.error;
|
|
105
105
|
i.reject(new Error(a || "RPC failed"));
|
|
106
106
|
return;
|
|
@@ -115,44 +115,44 @@ function Rn(t = self) {
|
|
|
115
115
|
method: o,
|
|
116
116
|
payload: i
|
|
117
117
|
}, a || []), new Promise((c, l) => {
|
|
118
|
-
|
|
118
|
+
n.set(s, {
|
|
119
119
|
resolve: (u) => c(u),
|
|
120
120
|
reject: l
|
|
121
121
|
});
|
|
122
122
|
});
|
|
123
123
|
};
|
|
124
124
|
}
|
|
125
|
-
function $
|
|
125
|
+
function $r({ worker: t, tools: e = {}, beacon: n, confirmation: r, memory: o = Se(), refStore: i }) {
|
|
126
126
|
t.addEventListener("message", (a) => {
|
|
127
127
|
const s = a.data;
|
|
128
128
|
_e(s) && xe(t, s, {
|
|
129
129
|
tools: e,
|
|
130
|
-
beacon:
|
|
131
|
-
confirmation:
|
|
130
|
+
beacon: n,
|
|
131
|
+
confirmation: r,
|
|
132
132
|
memory: o,
|
|
133
133
|
refStore: i
|
|
134
134
|
});
|
|
135
135
|
});
|
|
136
136
|
}
|
|
137
|
-
async function xe(t, e,
|
|
137
|
+
async function xe(t, e, n) {
|
|
138
138
|
try {
|
|
139
|
-
const
|
|
139
|
+
const r = await $e(e.method, e.payload, n);
|
|
140
140
|
t.postMessage({
|
|
141
141
|
type: "rpc.result",
|
|
142
142
|
rpcId: e.rpcId,
|
|
143
143
|
ok: !0,
|
|
144
|
-
value:
|
|
144
|
+
value: r
|
|
145
145
|
});
|
|
146
|
-
} catch (
|
|
146
|
+
} catch (r) {
|
|
147
147
|
t.postMessage({
|
|
148
148
|
type: "rpc.result",
|
|
149
149
|
rpcId: e.rpcId,
|
|
150
150
|
ok: !1,
|
|
151
|
-
error: { message:
|
|
151
|
+
error: { message: r instanceof Error ? r.message : String(r) }
|
|
152
152
|
});
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
|
-
var et = /* @__PURE__ */ new Map(),
|
|
155
|
+
var et = /* @__PURE__ */ new Map(), Bt = null;
|
|
156
156
|
function Se() {
|
|
157
157
|
try {
|
|
158
158
|
if (typeof sessionStorage < "u") return sessionStorage;
|
|
@@ -169,7 +169,7 @@ function Se() {
|
|
|
169
169
|
};
|
|
170
170
|
}
|
|
171
171
|
function ve() {
|
|
172
|
-
return
|
|
172
|
+
return Bt ||= ge(), Bt;
|
|
173
173
|
}
|
|
174
174
|
function je(t) {
|
|
175
175
|
if (t && typeof t == "object" && typeof t.name == "string") return t;
|
|
@@ -191,13 +191,13 @@ function Te(t) {
|
|
|
191
191
|
return !t || typeof t != "object" ? { value: t } : t;
|
|
192
192
|
}
|
|
193
193
|
function Pe(t) {
|
|
194
|
-
const e = typeof t.kind == "string" && t.kind.trim() ? t.kind.trim() : void 0,
|
|
195
|
-
return e ||
|
|
194
|
+
const e = typeof t.kind == "string" && t.kind.trim() ? t.kind.trim() : void 0, n = typeof t.ttlMs == "number" && Number.isFinite(t.ttlMs) && t.ttlMs > 0 ? t.ttlMs : void 0;
|
|
195
|
+
return e || n ? {
|
|
196
196
|
...e ? { kind: e } : {},
|
|
197
|
-
...
|
|
197
|
+
...n ? { ttlMs: n } : {}
|
|
198
198
|
} : void 0;
|
|
199
199
|
}
|
|
200
|
-
function
|
|
200
|
+
function nt(t) {
|
|
201
201
|
if (t == null) return "session";
|
|
202
202
|
if (t === "volatile" || t === "session" || t === "local" || t === "indexedDb") return t;
|
|
203
203
|
if (typeof t == "string") {
|
|
@@ -219,32 +219,32 @@ function Oe(t) {
|
|
|
219
219
|
const e = t.options?.ttlMs ?? t.ttlMs;
|
|
220
220
|
return typeof e == "number" && Number.isFinite(e) && e > 0 ? { ttlMs: e } : void 0;
|
|
221
221
|
}
|
|
222
|
-
async function
|
|
222
|
+
async function Be(t, e, n) {
|
|
223
223
|
if (dt(t)) {
|
|
224
|
-
const
|
|
225
|
-
if (!
|
|
224
|
+
const r = t.getItem(n);
|
|
225
|
+
if (!r) return null;
|
|
226
226
|
try {
|
|
227
|
-
return JSON.parse(
|
|
227
|
+
return JSON.parse(r);
|
|
228
228
|
} catch {
|
|
229
|
-
return t.removeItem?.(
|
|
229
|
+
return t.removeItem?.(n), null;
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
|
-
return pt(t) && !mt(t) ? await t.get(e,
|
|
232
|
+
return pt(t) && !mt(t) ? await t.get(e, n) ?? null : await t[e].get(n) ?? null;
|
|
233
233
|
}
|
|
234
|
-
async function
|
|
235
|
-
return dt(t) ? (t.setItem(
|
|
234
|
+
async function Me(t, e, n, r, o) {
|
|
235
|
+
return dt(t) ? (t.setItem(n, JSON.stringify(r ?? null)), !0) : pt(t) && !mt(t) ? await t.set(e, n, r ?? null, o) !== !1 : await t[e].set(n, r ?? null, o) !== !1;
|
|
236
236
|
}
|
|
237
|
-
async function Re(t, e,
|
|
238
|
-
return dt(t) ? (t.removeItem?.(
|
|
237
|
+
async function Re(t, e, n) {
|
|
238
|
+
return dt(t) ? (t.removeItem?.(n), !0) : pt(t) && !mt(t) ? t.remove ? (await t.remove(e, n), !0) : !1 : (await t[e].remove(n), !0);
|
|
239
239
|
}
|
|
240
|
-
async function $e(t, e, { tools:
|
|
240
|
+
async function $e(t, e, { tools: n, beacon: r, confirmation: o, memory: i, refStore: a }) {
|
|
241
241
|
if (t === "tool.invoke") {
|
|
242
|
-
const { name: s, input: c } = je(e), l =
|
|
242
|
+
const { name: s, input: c } = je(e), l = n[s];
|
|
243
243
|
if (typeof l != "function") throw new Error(`Unknown tool: ${s}`);
|
|
244
244
|
return l(c);
|
|
245
245
|
}
|
|
246
246
|
if (t === "beacon.send")
|
|
247
|
-
return
|
|
247
|
+
return r?.(e), { sent: !0 };
|
|
248
248
|
if (t === "confirmation.request") {
|
|
249
249
|
if (typeof o != "function") throw new Error("No confirmation handler is configured.");
|
|
250
250
|
const s = await o(e);
|
|
@@ -252,20 +252,20 @@ async function $e(t, e, { tools: r, beacon: n, confirmation: o, memory: i, refSt
|
|
|
252
252
|
}
|
|
253
253
|
if (t === "memory.get") {
|
|
254
254
|
const { key: s, tier: c } = Ce(e);
|
|
255
|
-
return
|
|
255
|
+
return Be(i, nt(c), String(s));
|
|
256
256
|
}
|
|
257
257
|
if (t === "memory.set") {
|
|
258
258
|
const s = Ee(e);
|
|
259
|
-
return { ok: await
|
|
259
|
+
return { ok: await Me(i, nt(s.tier), String(s.key), s.value, Oe(s)) };
|
|
260
260
|
}
|
|
261
261
|
if (t === "memory.remove") {
|
|
262
262
|
const { key: s, tier: c } = Ie(e);
|
|
263
|
-
return { ok: await Re(i,
|
|
263
|
+
return { ok: await Re(i, nt(c), String(s)) };
|
|
264
264
|
}
|
|
265
265
|
if (t === "ref.put") {
|
|
266
266
|
const s = V({
|
|
267
|
-
tools:
|
|
268
|
-
beacon:
|
|
267
|
+
tools: n,
|
|
268
|
+
beacon: r,
|
|
269
269
|
confirmation: o,
|
|
270
270
|
memory: i,
|
|
271
271
|
refStore: a
|
|
@@ -273,23 +273,23 @@ async function $e(t, e, { tools: r, beacon: n, confirmation: o, memory: i, refSt
|
|
|
273
273
|
return s.put(c.value, Pe(c));
|
|
274
274
|
}
|
|
275
275
|
if (t === "ref.get") return V({
|
|
276
|
-
tools:
|
|
277
|
-
beacon:
|
|
276
|
+
tools: n,
|
|
277
|
+
beacon: r,
|
|
278
278
|
confirmation: o,
|
|
279
279
|
memory: i,
|
|
280
280
|
refStore: a
|
|
281
281
|
}).get(e);
|
|
282
282
|
if (t === "ref.materialize") return V({
|
|
283
|
-
tools:
|
|
284
|
-
beacon:
|
|
283
|
+
tools: n,
|
|
284
|
+
beacon: r,
|
|
285
285
|
confirmation: o,
|
|
286
286
|
memory: i,
|
|
287
287
|
refStore: a
|
|
288
288
|
}).materialize(e);
|
|
289
289
|
if (t === "ref.remove")
|
|
290
290
|
return await V({
|
|
291
|
-
tools:
|
|
292
|
-
beacon:
|
|
291
|
+
tools: n,
|
|
292
|
+
beacon: r,
|
|
293
293
|
confirmation: o,
|
|
294
294
|
memory: i,
|
|
295
295
|
refStore: a
|
|
@@ -311,11 +311,11 @@ function N(t) {
|
|
|
311
311
|
return typeof t == "object" && t !== null && !Array.isArray(t);
|
|
312
312
|
}
|
|
313
313
|
function Ne(t) {
|
|
314
|
-
const { accountId: e, locale:
|
|
314
|
+
const { accountId: e, locale: n = "en-GB", parentUrl: r = "", threadId: o, incomingContext: i, messageLimit: a } = t, s = N(i) ? i : {}, c = N(s.thread) ? s.thread : {}, l = N(s.panel) ? s.panel : {}, u = N(s.meta) ? s.meta : {}, f = zt(s.messages, a), p = {
|
|
315
315
|
id: String(o || c.id || self.crypto.randomUUID()),
|
|
316
316
|
started_at: String(c.started_at || Le()),
|
|
317
317
|
extensions: N(c.extensions) ? { ...c.extensions } : {}
|
|
318
|
-
}, m = String(u.locale ||
|
|
318
|
+
}, m = String(u.locale || n), g = String(u.parentUrl || r || typeof self < "u" && self.location?.href || "");
|
|
319
319
|
return {
|
|
320
320
|
panel: { ...l },
|
|
321
321
|
messages: f,
|
|
@@ -327,25 +327,25 @@ function Ne(t) {
|
|
|
327
327
|
}
|
|
328
328
|
};
|
|
329
329
|
}
|
|
330
|
-
function qe(t, e,
|
|
331
|
-
const
|
|
332
|
-
return
|
|
330
|
+
function qe(t, e, n) {
|
|
331
|
+
const r = zt([e], n)[0];
|
|
332
|
+
return r ? {
|
|
333
333
|
...t,
|
|
334
|
-
messages: G([...t.messages,
|
|
334
|
+
messages: G([...t.messages, r], n)
|
|
335
335
|
} : t;
|
|
336
336
|
}
|
|
337
337
|
function G(t, e) {
|
|
338
|
-
const
|
|
339
|
-
return
|
|
338
|
+
const n = Fe(e);
|
|
339
|
+
return n === 1 / 0 ? [...t] : t.slice(-n);
|
|
340
340
|
}
|
|
341
341
|
function zt(t, e) {
|
|
342
|
-
return Array.isArray(t) ? G(t.map((
|
|
343
|
-
const
|
|
342
|
+
return Array.isArray(t) ? G(t.map((n) => {
|
|
343
|
+
const r = n?.role;
|
|
344
344
|
return {
|
|
345
|
-
role:
|
|
346
|
-
content: String(
|
|
345
|
+
role: r === "model" ? "assistant" : typeof r == "string" ? r : "",
|
|
346
|
+
content: String(n?.content || "")
|
|
347
347
|
};
|
|
348
|
-
}).filter((
|
|
348
|
+
}).filter((n) => (n.role === "user" || n.role === "assistant") && !!n.content), e) : [];
|
|
349
349
|
}
|
|
350
350
|
function Fe(t) {
|
|
351
351
|
if (t === void 0) return 50;
|
|
@@ -354,20 +354,20 @@ function Fe(t) {
|
|
|
354
354
|
return e > 0 ? e : 50;
|
|
355
355
|
}
|
|
356
356
|
var Ue = "gengage:agent:context:";
|
|
357
|
-
async function ze({ accountId: t, threadId: e, rpc:
|
|
358
|
-
const
|
|
357
|
+
async function ze({ accountId: t, threadId: e, rpc: n }) {
|
|
358
|
+
const r = await n("memory.get", {
|
|
359
359
|
tier: "session",
|
|
360
360
|
key: Dt(t, e)
|
|
361
361
|
});
|
|
362
|
-
return
|
|
362
|
+
return r && typeof r == "object" && !Array.isArray(r) ? r : {};
|
|
363
363
|
}
|
|
364
|
-
async function De({ accountId: t, threadId: e, extensions:
|
|
364
|
+
async function De({ accountId: t, threadId: e, extensions: n, panel: r, rpc: o }) {
|
|
365
365
|
await o("memory.set", {
|
|
366
366
|
tier: "session",
|
|
367
367
|
key: Dt(t, e),
|
|
368
368
|
value: {
|
|
369
|
-
thread: { extensions:
|
|
370
|
-
...
|
|
369
|
+
thread: { extensions: n },
|
|
370
|
+
...r && Object.keys(r).length > 0 ? { panel: r } : {}
|
|
371
371
|
}
|
|
372
372
|
});
|
|
373
373
|
}
|
|
@@ -377,103 +377,103 @@ function Dt(t, e) {
|
|
|
377
377
|
function h(t) {
|
|
378
378
|
return typeof t == "object" && t !== null && !Array.isArray(t);
|
|
379
379
|
}
|
|
380
|
-
var
|
|
380
|
+
var Lr = class {
|
|
381
381
|
#t = /* @__PURE__ */ new Map();
|
|
382
|
-
#
|
|
382
|
+
#n = /* @__PURE__ */ new Map();
|
|
383
383
|
#o;
|
|
384
384
|
#c;
|
|
385
385
|
#u;
|
|
386
386
|
#i;
|
|
387
387
|
#l;
|
|
388
388
|
#f;
|
|
389
|
-
#
|
|
389
|
+
#r;
|
|
390
390
|
#a;
|
|
391
391
|
#s;
|
|
392
|
-
constructor({ accountId: t, locale: e, parentUrl:
|
|
393
|
-
this.#o = t, this.#c = e, this.#u =
|
|
392
|
+
constructor({ accountId: t, locale: e, parentUrl: n, rpc: r, persistentPanelKeys: o = [], panelKeyLimits: i = {}, messageLimit: a, maxThreads: s, threadTtlMs: c }) {
|
|
393
|
+
this.#o = t, this.#c = e, this.#u = n, this.#i = r, this.#l = [...new Set(o.filter(Boolean))], this.#f = Ke(i), this.#r = rt(a), this.#a = rt(s), this.#s = rt(c);
|
|
394
394
|
}
|
|
395
395
|
get size() {
|
|
396
396
|
return this.pruneExpired(), this.#t.size;
|
|
397
397
|
}
|
|
398
398
|
get(t = "default") {
|
|
399
399
|
this.pruneExpired();
|
|
400
|
-
const e = String(t || "default"),
|
|
401
|
-
return
|
|
400
|
+
const e = String(t || "default"), n = this.#t.get(e);
|
|
401
|
+
return n ? (this.#e(e, n), n) : null;
|
|
402
402
|
}
|
|
403
403
|
getPanel(t = "default") {
|
|
404
404
|
return this.get(t)?.panel ?? null;
|
|
405
405
|
}
|
|
406
406
|
getRecentProducts(t = "default", e = "last_search_products") {
|
|
407
|
-
const
|
|
408
|
-
return Array.isArray(
|
|
407
|
+
const n = this.getPanel(t)?.[e];
|
|
408
|
+
return Array.isArray(n) ? n : [];
|
|
409
409
|
}
|
|
410
410
|
async load(t) {
|
|
411
411
|
this.pruneExpired();
|
|
412
|
-
const e = t?.session_id || t?.meta?.threadId || t?.sessionId,
|
|
413
|
-
if (
|
|
414
|
-
const a = He(
|
|
415
|
-
return this.#e(
|
|
412
|
+
const e = t?.session_id || t?.meta?.threadId || t?.sessionId, n = String(e || "default"), r = this.#t.get(n);
|
|
413
|
+
if (r) {
|
|
414
|
+
const a = He(r, t?.context, this.#r);
|
|
415
|
+
return this.#e(n, a), a;
|
|
416
416
|
}
|
|
417
417
|
const o = await ze({
|
|
418
418
|
accountId: this.#o,
|
|
419
|
-
threadId:
|
|
419
|
+
threadId: n,
|
|
420
420
|
rpc: this.#i
|
|
421
421
|
}), i = Ne({
|
|
422
422
|
accountId: this.#o,
|
|
423
423
|
locale: t?.locale || this.#c,
|
|
424
424
|
parentUrl: this.#u,
|
|
425
|
-
threadId:
|
|
425
|
+
threadId: n,
|
|
426
426
|
incomingContext: Ze(o, t?.context),
|
|
427
|
-
messageLimit: this.#
|
|
427
|
+
messageLimit: this.#r
|
|
428
428
|
});
|
|
429
|
-
return this.#e(
|
|
429
|
+
return this.#e(n, i), this.#d(), i;
|
|
430
430
|
}
|
|
431
431
|
patch(t, e) {
|
|
432
432
|
this.pruneExpired();
|
|
433
|
-
const
|
|
434
|
-
if (!
|
|
435
|
-
const o = yt(
|
|
436
|
-
return this.#e(
|
|
433
|
+
const n = String(t || "default"), r = this.#t.get(n);
|
|
434
|
+
if (!r) return null;
|
|
435
|
+
const o = yt(r, typeof e == "function" ? e(r) : e, this.#r);
|
|
436
|
+
return this.#e(n, o), o;
|
|
437
437
|
}
|
|
438
438
|
appendUserMessage(t, e) {
|
|
439
439
|
this.pruneExpired();
|
|
440
|
-
const
|
|
441
|
-
if (!e) return this.#t.get(
|
|
442
|
-
const
|
|
443
|
-
if (!
|
|
444
|
-
const o = qe(
|
|
440
|
+
const n = String(t || "default");
|
|
441
|
+
if (!e) return this.#t.get(n) ?? null;
|
|
442
|
+
const r = this.#t.get(n);
|
|
443
|
+
if (!r) return null;
|
|
444
|
+
const o = qe(r, {
|
|
445
445
|
role: "user",
|
|
446
446
|
content: e
|
|
447
|
-
}, this.#
|
|
448
|
-
return this.#e(
|
|
447
|
+
}, this.#r);
|
|
448
|
+
return this.#e(n, o), o;
|
|
449
449
|
}
|
|
450
450
|
async commit(t) {
|
|
451
451
|
this.pruneExpired();
|
|
452
|
-
const e = String(t || "default"),
|
|
453
|
-
return
|
|
452
|
+
const e = String(t || "default"), n = this.#t.get(e);
|
|
453
|
+
return n ? (this.#e(e, n), await De({
|
|
454
454
|
accountId: this.#o,
|
|
455
455
|
threadId: e,
|
|
456
|
-
extensions:
|
|
457
|
-
panel: Ve(
|
|
456
|
+
extensions: n.thread.extensions,
|
|
457
|
+
panel: Ve(n.panel, this.#l, this.#f),
|
|
458
458
|
rpc: this.#i
|
|
459
|
-
}),
|
|
459
|
+
}), n) : null;
|
|
460
460
|
}
|
|
461
461
|
delete(t) {
|
|
462
462
|
const e = String(t || "default");
|
|
463
|
-
return this.#
|
|
463
|
+
return this.#n.delete(e), this.#t.delete(e);
|
|
464
464
|
}
|
|
465
465
|
clear() {
|
|
466
|
-
this.#t.clear(), this.#
|
|
466
|
+
this.#t.clear(), this.#n.clear();
|
|
467
467
|
}
|
|
468
468
|
pruneExpired(t = Date.now()) {
|
|
469
469
|
if (!this.#s) return 0;
|
|
470
470
|
let e = 0;
|
|
471
|
-
for (const [
|
|
472
|
-
t -
|
|
471
|
+
for (const [n, r] of this.#n)
|
|
472
|
+
t - r <= this.#s || (this.#n.delete(n), this.#t.delete(n) && (e += 1));
|
|
473
473
|
return e;
|
|
474
474
|
}
|
|
475
475
|
#e(t, e) {
|
|
476
|
-
this.#t.delete(t), this.#t.set(t, e), this.#
|
|
476
|
+
this.#t.delete(t), this.#t.set(t, e), this.#n.set(t, Date.now());
|
|
477
477
|
}
|
|
478
478
|
#d() {
|
|
479
479
|
if (this.#a)
|
|
@@ -484,21 +484,21 @@ var Ln = class {
|
|
|
484
484
|
}
|
|
485
485
|
}
|
|
486
486
|
};
|
|
487
|
-
function Ve(t, e,
|
|
487
|
+
function Ve(t, e, n) {
|
|
488
488
|
if (!e.length || !h(t)) return;
|
|
489
|
-
const
|
|
490
|
-
for (const o of e) Object.prototype.hasOwnProperty.call(t, o) && (
|
|
491
|
-
return
|
|
489
|
+
const r = {};
|
|
490
|
+
for (const o of e) Object.prototype.hasOwnProperty.call(t, o) && (r[o] = Je(t[o], n[o]));
|
|
491
|
+
return r;
|
|
492
492
|
}
|
|
493
493
|
function Ke(t) {
|
|
494
494
|
const e = {};
|
|
495
|
-
for (const [
|
|
496
|
-
const o = Math.floor(Number(
|
|
497
|
-
|
|
495
|
+
for (const [n, r] of Object.entries(t || {})) {
|
|
496
|
+
const o = Math.floor(Number(r));
|
|
497
|
+
n && Number.isFinite(o) && o > 0 && (e[n] = o);
|
|
498
498
|
}
|
|
499
499
|
return e;
|
|
500
500
|
}
|
|
501
|
-
function
|
|
501
|
+
function rt(t) {
|
|
502
502
|
if (t === void 0) return;
|
|
503
503
|
const e = Math.floor(Number(t));
|
|
504
504
|
return Number.isFinite(e) && e > 0 ? e : void 0;
|
|
@@ -508,29 +508,29 @@ function Je(t, e) {
|
|
|
508
508
|
}
|
|
509
509
|
function Ze(t, e) {
|
|
510
510
|
if (!h(t) && !h(e)) return {};
|
|
511
|
-
const
|
|
512
|
-
return h(
|
|
511
|
+
const n = h(t) ? t : {}, r = yt(n, h(e) ? e : {});
|
|
512
|
+
return h(n.panel) && (r.panel = n.panel), r;
|
|
513
513
|
}
|
|
514
|
-
function He(t, e,
|
|
514
|
+
function He(t, e, n) {
|
|
515
515
|
if (!h(e)) return t;
|
|
516
|
-
const
|
|
516
|
+
const r = yt(t, e, n);
|
|
517
517
|
return {
|
|
518
|
-
...
|
|
518
|
+
...r,
|
|
519
519
|
panel: t.panel,
|
|
520
520
|
thread: {
|
|
521
|
-
...
|
|
521
|
+
...r.thread,
|
|
522
522
|
id: t.thread.id,
|
|
523
523
|
started_at: t.thread.started_at
|
|
524
524
|
},
|
|
525
525
|
meta: {
|
|
526
|
-
...
|
|
526
|
+
...r.meta,
|
|
527
527
|
accountId: t.meta.accountId
|
|
528
528
|
}
|
|
529
529
|
};
|
|
530
530
|
}
|
|
531
|
-
function yt(t, e,
|
|
531
|
+
function yt(t, e, n) {
|
|
532
532
|
if (!h(e)) return t;
|
|
533
|
-
const
|
|
533
|
+
const r = t, o = e, i = h(r.panel) ? r.panel : {}, a = h(o.panel) ? o.panel : {}, s = h(r.thread) ? r.thread : {}, c = h(o.thread) ? o.thread : {}, l = h(s.extensions) ? s.extensions : {}, u = h(c.extensions) ? c.extensions : {}, f = h(r.meta) ? r.meta : {}, p = h(o.meta) ? o.meta : {};
|
|
534
534
|
return {
|
|
535
535
|
...t,
|
|
536
536
|
...e,
|
|
@@ -550,53 +550,53 @@ function yt(t, e, r) {
|
|
|
550
550
|
...f,
|
|
551
551
|
...p
|
|
552
552
|
},
|
|
553
|
-
messages: Array.isArray(o.messages) ? G(o.messages,
|
|
553
|
+
messages: Array.isArray(o.messages) ? G(o.messages, n) : t.messages ?? []
|
|
554
554
|
};
|
|
555
555
|
}
|
|
556
556
|
function Vt(t) {
|
|
557
557
|
const e = String.fromCharCode(...t);
|
|
558
558
|
return btoa(e).replace(/\+/gu, "-").replace(/\//gu, "_").replace(/=+$/u, "");
|
|
559
559
|
}
|
|
560
|
-
function
|
|
560
|
+
function Mt(t) {
|
|
561
561
|
return Vt(new TextEncoder().encode(JSON.stringify(t)));
|
|
562
562
|
}
|
|
563
|
-
async function Ge({ accountId: t, devJwtSecret: e, ttlS:
|
|
563
|
+
async function Ge({ accountId: t, devJwtSecret: e, ttlS: n = 300 }) {
|
|
564
564
|
if (!e) throw new Error("devJwtSecret is required for local agent mode.");
|
|
565
|
-
const
|
|
565
|
+
const r = Math.floor(Date.now() / 1e3), o = `${Mt({
|
|
566
566
|
alg: "HS256",
|
|
567
567
|
typ: "JWT"
|
|
568
|
-
})}.${
|
|
568
|
+
})}.${Mt({
|
|
569
569
|
sub: t,
|
|
570
|
-
iat:
|
|
571
|
-
exp:
|
|
570
|
+
iat: r,
|
|
571
|
+
exp: r + n,
|
|
572
572
|
scope: "invoke",
|
|
573
|
-
jti: crypto.randomUUID?.() || `${
|
|
573
|
+
jti: crypto.randomUUID?.() || `${r}-${Math.random()}`
|
|
574
574
|
})}`, i = await crypto.subtle.importKey("raw", new TextEncoder().encode(e), {
|
|
575
575
|
name: "HMAC",
|
|
576
576
|
hash: "SHA-256"
|
|
577
577
|
}, !1, ["sign"]), a = await crypto.subtle.sign("HMAC", i, new TextEncoder().encode(o));
|
|
578
578
|
return `${o}.${Vt(new Uint8Array(a))}`;
|
|
579
579
|
}
|
|
580
|
-
function Qe({ accountId: t, devJwtSecret: e, tokenBrokerUrl:
|
|
580
|
+
function Qe({ accountId: t, devJwtSecret: e, tokenBrokerUrl: n, tokenBrokerAudience: r, refreshSkewS: o = 30, fetchImpl: i = fetch }) {
|
|
581
581
|
let a = null;
|
|
582
582
|
return async ({ signal: s, parentUrl: c } = {}) => {
|
|
583
583
|
if (e) return Ge({
|
|
584
584
|
accountId: t,
|
|
585
585
|
devJwtSecret: e
|
|
586
586
|
});
|
|
587
|
-
if (!
|
|
587
|
+
if (!n) throw new Error("tokenBrokerUrl is required for production agent mode.");
|
|
588
588
|
const l = Math.floor(Date.now() / 1e3);
|
|
589
589
|
return a?.token && a.expiresAtS - o > l || (a = await Ye({
|
|
590
590
|
accountId: t,
|
|
591
|
-
tokenBrokerUrl:
|
|
592
|
-
tokenBrokerAudience:
|
|
591
|
+
tokenBrokerUrl: n,
|
|
592
|
+
tokenBrokerAudience: r,
|
|
593
593
|
parentUrl: c,
|
|
594
594
|
signal: s,
|
|
595
595
|
fetchImpl: i
|
|
596
596
|
})), a.token;
|
|
597
597
|
};
|
|
598
598
|
}
|
|
599
|
-
async function Ye({ accountId: t, tokenBrokerUrl: e, tokenBrokerAudience:
|
|
599
|
+
async function Ye({ accountId: t, tokenBrokerUrl: e, tokenBrokerAudience: n, parentUrl: r, signal: o, fetchImpl: i }) {
|
|
600
600
|
const a = await i(e, {
|
|
601
601
|
method: "POST",
|
|
602
602
|
credentials: "include",
|
|
@@ -607,8 +607,8 @@ async function Ye({ accountId: t, tokenBrokerUrl: e, tokenBrokerAudience: r, par
|
|
|
607
607
|
body: JSON.stringify({
|
|
608
608
|
accountId: t,
|
|
609
609
|
scope: "invoke",
|
|
610
|
-
audience:
|
|
611
|
-
parentUrl:
|
|
610
|
+
audience: n || void 0,
|
|
611
|
+
parentUrl: r || void 0
|
|
612
612
|
}),
|
|
613
613
|
...o ? { signal: o } : {}
|
|
614
614
|
});
|
|
@@ -623,11 +623,11 @@ async function Ye({ accountId: t, tokenBrokerUrl: e, tokenBrokerAudience: r, par
|
|
|
623
623
|
function We(t) {
|
|
624
624
|
const e = t?.expiresAtS ?? t?.expires_at_s ?? t?.expiresInS ?? t?.expires_in_s;
|
|
625
625
|
if (Number.isFinite(e)) return Number(e);
|
|
626
|
-
const
|
|
627
|
-
if (Number.isFinite(
|
|
628
|
-
const
|
|
629
|
-
if (typeof
|
|
630
|
-
const o = Date.parse(
|
|
626
|
+
const n = t?.expiresIn ?? t?.expires_in;
|
|
627
|
+
if (Number.isFinite(n)) return Math.floor(Date.now() / 1e3) + Number(n);
|
|
628
|
+
const r = t?.expiresAt ?? t?.expires_at;
|
|
629
|
+
if (typeof r == "string") {
|
|
630
|
+
const o = Date.parse(r);
|
|
631
631
|
if (Number.isFinite(o)) return Math.floor(o / 1e3);
|
|
632
632
|
}
|
|
633
633
|
return null;
|
|
@@ -636,7 +636,7 @@ function Xe(t) {
|
|
|
636
636
|
try {
|
|
637
637
|
const [, e] = t.split(".");
|
|
638
638
|
if (!e) return null;
|
|
639
|
-
const
|
|
639
|
+
const n = e.replace(/-/gu, "+").replace(/_/gu, "/"), r = atob(n.padEnd(Math.ceil(n.length / 4) * 4, "=")), o = JSON.parse(r);
|
|
640
640
|
return Number.isFinite(o?.exp) ? Number(o.exp) : null;
|
|
641
641
|
} catch {
|
|
642
642
|
return null;
|
|
@@ -688,26 +688,26 @@ var Rt = {
|
|
|
688
688
|
message: "The assistant request was too large."
|
|
689
689
|
}
|
|
690
690
|
}, T = class extends Error {
|
|
691
|
-
constructor(t, e,
|
|
692
|
-
super(e), this.name = "AgentError", this.code = t, this.source =
|
|
691
|
+
constructor(t, e, n = {}) {
|
|
692
|
+
super(e), this.name = "AgentError", this.code = t, this.source = n.source || "agent", n.sourceCode && (this.sourceCode = n.sourceCode), n.detail !== void 0 && (this.detail = n.detail);
|
|
693
693
|
}
|
|
694
694
|
};
|
|
695
695
|
function Kt(t) {
|
|
696
|
-
const e = String(t?.code || "upstream_llm"),
|
|
697
|
-
return new T(
|
|
696
|
+
const e = String(t?.code || "upstream_llm"), n = Rt[e] || Rt.upstream_llm;
|
|
697
|
+
return new T(n.code, n.message, {
|
|
698
698
|
source: "be",
|
|
699
699
|
sourceCode: e,
|
|
700
700
|
detail: t?.detail
|
|
701
701
|
});
|
|
702
702
|
}
|
|
703
|
-
function
|
|
704
|
-
const
|
|
703
|
+
function tn(t, e) {
|
|
704
|
+
const n = e?.error && typeof e.error == "object" ? e.error : {};
|
|
705
705
|
return Kt({
|
|
706
|
-
code: String(
|
|
707
|
-
detail:
|
|
706
|
+
code: String(n.code || en(t)),
|
|
707
|
+
detail: n.detail
|
|
708
708
|
});
|
|
709
709
|
}
|
|
710
|
-
function
|
|
710
|
+
function Nr(t) {
|
|
711
711
|
return t instanceof T ? {
|
|
712
712
|
type: "error",
|
|
713
713
|
code: t.code,
|
|
@@ -718,19 +718,19 @@ function Nn(t) {
|
|
|
718
718
|
message: "The assistant could not complete that request."
|
|
719
719
|
};
|
|
720
720
|
}
|
|
721
|
-
function
|
|
721
|
+
function en(t) {
|
|
722
722
|
return t === 401 ? "unauthorized" : t === 403 ? "forbidden" : t === 413 ? "payload_too_large" : t === 429 ? "rate_limited" : "internal";
|
|
723
723
|
}
|
|
724
|
-
async function
|
|
724
|
+
async function qr({ beUrl: t, accountId: e, devJwtSecret: n, tokenBrokerUrl: r, tokenBrokerAudience: o, jwtProvider: i, parentUrl: a, op: s, input: c, cacheTtlS: l, cacheKey: u, browserCache: f, signal: p }) {
|
|
725
725
|
const m = await (i || Qe({
|
|
726
726
|
accountId: e,
|
|
727
|
-
devJwtSecret:
|
|
728
|
-
tokenBrokerUrl:
|
|
727
|
+
devJwtSecret: n,
|
|
728
|
+
tokenBrokerUrl: r,
|
|
729
729
|
tokenBrokerAudience: o
|
|
730
730
|
}))({
|
|
731
731
|
...p ? { signal: p } : {},
|
|
732
732
|
...a ? { parentUrl: a } : {}
|
|
733
|
-
}), { opDomain: g, opName: _ } =
|
|
733
|
+
}), { opDomain: g, opName: _ } = nn(s, e), C = {
|
|
734
734
|
method: "POST",
|
|
735
735
|
headers: {
|
|
736
736
|
authorization: `Bearer ${m}`,
|
|
@@ -746,85 +746,85 @@ async function qn({ beUrl: t, accountId: e, devJwtSecret: r, tokenBrokerUrl: n,
|
|
|
746
746
|
}),
|
|
747
747
|
...p ? { signal: p } : {}
|
|
748
748
|
}, P = `${String(t).replace(/\/+$/u, "")}/v1/execute`, O = f === !1 ? await fetch(P, C) : await pe(P, C, typeof f == "object" ? f : {});
|
|
749
|
-
if (!O.ok) throw
|
|
750
|
-
return
|
|
749
|
+
if (!O.ok) throw tn(O.status, await on(O));
|
|
750
|
+
return an(O);
|
|
751
751
|
}
|
|
752
|
-
function
|
|
752
|
+
function nn(t, e) {
|
|
753
753
|
if (!t || t.startsWith("-") || t.endsWith("-")) throw new Error(`Invalid BE op name: ${t}`);
|
|
754
754
|
return {
|
|
755
|
-
opDomain:
|
|
755
|
+
opDomain: rn(e),
|
|
756
756
|
opName: t
|
|
757
757
|
};
|
|
758
758
|
}
|
|
759
|
-
function
|
|
759
|
+
function rn(t) {
|
|
760
760
|
return t.replace(/-agentic$/u, "");
|
|
761
761
|
}
|
|
762
|
-
async function
|
|
762
|
+
async function on(t) {
|
|
763
763
|
try {
|
|
764
764
|
return await t.json();
|
|
765
765
|
} catch {
|
|
766
766
|
return { error: { code: t.statusText || "internal" } };
|
|
767
767
|
}
|
|
768
768
|
}
|
|
769
|
-
async function
|
|
769
|
+
async function an(t) {
|
|
770
770
|
const e = t.body?.getReader();
|
|
771
771
|
if (!e) throw new Error("BE response body is not readable.");
|
|
772
|
-
const
|
|
773
|
-
let
|
|
772
|
+
const n = new TextDecoder();
|
|
773
|
+
let r = "";
|
|
774
774
|
const o = {};
|
|
775
775
|
for (; ; ) {
|
|
776
776
|
const { value: a, done: s } = await e.read();
|
|
777
777
|
if (s) break;
|
|
778
|
-
|
|
779
|
-
let c =
|
|
778
|
+
r += n.decode(a, { stream: !0 });
|
|
779
|
+
let c = r.indexOf(`
|
|
780
780
|
`);
|
|
781
781
|
for (; c >= 0; ) {
|
|
782
|
-
const l =
|
|
783
|
-
|
|
782
|
+
const l = r.slice(0, c).trim();
|
|
783
|
+
r = r.slice(c + 1), l && $t(JSON.parse(l), o), c = r.indexOf(`
|
|
784
784
|
`);
|
|
785
785
|
}
|
|
786
786
|
}
|
|
787
|
-
const i =
|
|
787
|
+
const i = r.trim();
|
|
788
788
|
return i && $t(JSON.parse(i), o), o;
|
|
789
789
|
}
|
|
790
790
|
function $t(t, e) {
|
|
791
791
|
if (t._error) throw Kt(t._error);
|
|
792
792
|
if (!t._end)
|
|
793
|
-
for (const [
|
|
794
|
-
if (Object.prototype.hasOwnProperty.call(e,
|
|
793
|
+
for (const [n, r] of Object.entries(t)) {
|
|
794
|
+
if (Object.prototype.hasOwnProperty.call(e, n)) throw new T("op_failed", `BE streamed duplicate field "${n}".`, {
|
|
795
795
|
source: "be",
|
|
796
796
|
sourceCode: "schema_mismatch"
|
|
797
797
|
});
|
|
798
|
-
e[
|
|
798
|
+
e[n] = r;
|
|
799
799
|
}
|
|
800
800
|
}
|
|
801
|
-
function
|
|
801
|
+
function Fr(t = {}) {
|
|
802
802
|
return {
|
|
803
803
|
type: "metadata",
|
|
804
804
|
...t
|
|
805
805
|
};
|
|
806
806
|
}
|
|
807
|
-
function
|
|
807
|
+
function sn(t, e = !1, n = {}) {
|
|
808
808
|
return {
|
|
809
809
|
type: "text_chunk",
|
|
810
810
|
content: t,
|
|
811
811
|
final: e,
|
|
812
|
-
...
|
|
812
|
+
...n
|
|
813
813
|
};
|
|
814
814
|
}
|
|
815
|
-
function
|
|
815
|
+
function Ur(t) {
|
|
816
816
|
return {
|
|
817
817
|
type: "ui_spec",
|
|
818
818
|
...t
|
|
819
819
|
};
|
|
820
820
|
}
|
|
821
|
-
function
|
|
821
|
+
function zr(t) {
|
|
822
822
|
return {
|
|
823
823
|
type: "action",
|
|
824
824
|
action: t
|
|
825
825
|
};
|
|
826
826
|
}
|
|
827
|
-
function
|
|
827
|
+
function cn(t, e) {
|
|
828
828
|
return {
|
|
829
829
|
type: "error",
|
|
830
830
|
code: t,
|
|
@@ -834,51 +834,51 @@ function sr(t, e) {
|
|
|
834
834
|
function Jt() {
|
|
835
835
|
return { type: "done" };
|
|
836
836
|
}
|
|
837
|
-
function
|
|
837
|
+
function un(t, e) {
|
|
838
838
|
return t[e?.type || e?.action?.type || "inputText"] || t.inputText;
|
|
839
839
|
}
|
|
840
840
|
function Zt(t) {
|
|
841
841
|
return t && typeof t == "object" && !Array.isArray(t) ? t : null;
|
|
842
842
|
}
|
|
843
843
|
function gt(t, e = {}) {
|
|
844
|
-
const
|
|
845
|
-
if (!
|
|
846
|
-
const
|
|
847
|
-
if (
|
|
848
|
-
const o =
|
|
844
|
+
const n = Zt(t);
|
|
845
|
+
if (!n) return null;
|
|
846
|
+
const r = e.catalogMapper?.(n);
|
|
847
|
+
if (r) return r;
|
|
848
|
+
const o = M(n.sku, n.SKU);
|
|
849
849
|
if (!o) return null;
|
|
850
850
|
const i = {
|
|
851
851
|
sku: o,
|
|
852
|
-
name:
|
|
853
|
-
url:
|
|
854
|
-
}, a = Array.isArray(
|
|
852
|
+
name: M(n.name, n.title, n.short_name, o) || o,
|
|
853
|
+
url: M(n.url) || ""
|
|
854
|
+
}, a = Array.isArray(n.images) ? n.images : void 0, s = M(n.imageUrl, n.image_url, n.image, a?.[0]);
|
|
855
855
|
s && (i.imageUrl = s), a && a.length > 1 && (i.images = a.filter((P) => !!P).map(String));
|
|
856
|
-
const c = q(
|
|
856
|
+
const c = q(n.price_discounted), l = q(n.price), u = c || l;
|
|
857
857
|
u > 0 && (i.price = String(u));
|
|
858
858
|
const f = c > 0 ? l : 0;
|
|
859
859
|
f > 0 && (i.originalPrice = String(f));
|
|
860
|
-
const p =
|
|
860
|
+
const p = M(n.brand);
|
|
861
861
|
p && (i.brand = p);
|
|
862
|
-
const m = q(
|
|
862
|
+
const m = q(n.rating);
|
|
863
863
|
m > 0 && (i.rating = m);
|
|
864
|
-
const g = q(
|
|
864
|
+
const g = q(n.review_count) || q(n.reviewCount);
|
|
865
865
|
g > 0 && (i.reviewCount = g);
|
|
866
|
-
const _ =
|
|
867
|
-
_ && (i.cartCode = _), typeof
|
|
868
|
-
const C =
|
|
866
|
+
const _ = M(n.cart_code, n.cartCode);
|
|
867
|
+
_ && (i.cartCode = _), typeof n.in_stock == "boolean" && (i.inStock = n.in_stock), typeof n.inStock == "boolean" && (i.inStock = n.inStock);
|
|
868
|
+
const C = n.category_names;
|
|
869
869
|
return Array.isArray(C) && (i.categoryNames = C.map(String)), i;
|
|
870
870
|
}
|
|
871
871
|
function ht(t) {
|
|
872
872
|
const e = Zt(t);
|
|
873
873
|
if (!e) return t;
|
|
874
|
-
const
|
|
874
|
+
const n = e.category_names, r = Array.isArray(n) ? n : void 0, o = e.images, i = Array.isArray(o) ? o : void 0, a = {
|
|
875
875
|
sku: e.sku,
|
|
876
876
|
name: e.name || e.title,
|
|
877
877
|
url: e.url,
|
|
878
878
|
price: e.price,
|
|
879
879
|
currency: e.price_currency || e.currency,
|
|
880
|
-
category:
|
|
881
|
-
category_names:
|
|
880
|
+
category: r?.[r.length - 1] ?? void 0,
|
|
881
|
+
category_names: r ? r.slice(0, 4) : void 0,
|
|
882
882
|
image: i ? i[0] : e.image,
|
|
883
883
|
in_stock: e.in_stock,
|
|
884
884
|
rating: e.rating,
|
|
@@ -887,10 +887,10 @@ function ht(t) {
|
|
|
887
887
|
for (const s of Object.keys(a)) a[s] === void 0 && delete a[s];
|
|
888
888
|
return a;
|
|
889
889
|
}
|
|
890
|
-
function
|
|
890
|
+
function Dr(t) {
|
|
891
891
|
return Array.isArray(t) ? t.map(ht).filter((e) => !!e) : [];
|
|
892
892
|
}
|
|
893
|
-
function
|
|
893
|
+
function M(...t) {
|
|
894
894
|
for (const e of t) if (typeof e == "string" && e.trim()) return e.trim();
|
|
895
895
|
return "";
|
|
896
896
|
}
|
|
@@ -901,42 +901,42 @@ function q(t) {
|
|
|
901
901
|
function Lt(t) {
|
|
902
902
|
return Array.isArray(t) ? t.map(String).filter(Boolean) : typeof t == "string" && t ? [t] : [];
|
|
903
903
|
}
|
|
904
|
-
function Ht(t, e,
|
|
905
|
-
return `${t}:${
|
|
904
|
+
function Ht(t, e, n = {}) {
|
|
905
|
+
return `${t}:${n.version || "v2"}:${Gt(e)}`;
|
|
906
906
|
}
|
|
907
|
-
function
|
|
908
|
-
return Qt(t).map((
|
|
907
|
+
function Vr(t, e = {}) {
|
|
908
|
+
return Qt(t).map((n) => Yt(typeof n == "string" ? n : n.sku, e.locale)).filter(Boolean).filter((n, r, o) => o.indexOf(n) === r).sort((n, r) => bt(n, r, e.locale)).slice(0, e.limit || 16).join(",");
|
|
909
909
|
}
|
|
910
|
-
function
|
|
911
|
-
return Gt(Qt(t).map((
|
|
910
|
+
function Kr(t, e = {}) {
|
|
911
|
+
return Gt(Qt(t).map((n) => ln(n, e)).filter((n) => !!n).sort((n, r) => bt(String(n.sku || n.name || ""), String(r.sku || r.name || ""), e.locale)).slice(0, e.limit || 16));
|
|
912
912
|
}
|
|
913
|
-
function
|
|
913
|
+
function Jr(t, e) {
|
|
914
914
|
return E(t, e);
|
|
915
915
|
}
|
|
916
916
|
function Gt(t) {
|
|
917
917
|
let e = 2166136261;
|
|
918
|
-
const
|
|
919
|
-
for (let
|
|
920
|
-
e ^=
|
|
918
|
+
const n = fn(t);
|
|
919
|
+
for (let r = 0; r < n.length; r += 1)
|
|
920
|
+
e ^= n.charCodeAt(r), e = Math.imul(e, 16777619);
|
|
921
921
|
return (e >>> 0).toString(36);
|
|
922
922
|
}
|
|
923
|
-
function
|
|
923
|
+
function ln(t, e) {
|
|
924
924
|
if (!t || typeof t != "object" || Array.isArray(t)) return null;
|
|
925
|
-
const
|
|
926
|
-
if (
|
|
927
|
-
const o = ht(
|
|
928
|
-
return o && typeof o == "object" && !Array.isArray(o) ? U(
|
|
925
|
+
const n = t, r = e.mapProduct?.(n);
|
|
926
|
+
if (r) return U(r);
|
|
927
|
+
const o = ht(n);
|
|
928
|
+
return o && typeof o == "object" && !Array.isArray(o) ? U(dn(o, e)) : null;
|
|
929
929
|
}
|
|
930
930
|
function Qt(t) {
|
|
931
931
|
return Array.isArray(t) ? t.filter((e) => typeof e == "string" || !!(e && typeof e == "object" && !Array.isArray(e))) : [];
|
|
932
932
|
}
|
|
933
|
-
function
|
|
933
|
+
function fn(t) {
|
|
934
934
|
return JSON.stringify(U(t));
|
|
935
935
|
}
|
|
936
936
|
function U(t) {
|
|
937
|
-
return Array.isArray(t) ? t.map(U) : !t || typeof t != "object" ? t : Object.fromEntries(Object.entries(t).filter(([, e]) => e !== void 0).sort(([e], [
|
|
937
|
+
return Array.isArray(t) ? t.map(U) : !t || typeof t != "object" ? t : Object.fromEntries(Object.entries(t).filter(([, e]) => e !== void 0).sort(([e], [n]) => e.localeCompare(n)).map(([e, n]) => [e, U(n)]));
|
|
938
938
|
}
|
|
939
|
-
function
|
|
939
|
+
function dn(t, e) {
|
|
940
940
|
return {
|
|
941
941
|
sku: Yt(t.sku, e.locale),
|
|
942
942
|
name: E(t.name, e.locale),
|
|
@@ -944,7 +944,7 @@ function fr(t, e) {
|
|
|
944
944
|
price: t.price,
|
|
945
945
|
currency: E(t.currency, e.locale),
|
|
946
946
|
category: E(t.category, e.locale),
|
|
947
|
-
category_names:
|
|
947
|
+
category_names: pn(t.category_names, e.locale, 16),
|
|
948
948
|
image: E(t.image, e.locale),
|
|
949
949
|
in_stock: t.in_stock,
|
|
950
950
|
rating: t.rating,
|
|
@@ -957,36 +957,36 @@ function Yt(t, e) {
|
|
|
957
957
|
function E(t, e) {
|
|
958
958
|
return typeof t == "string" ? t.trim().replace(/\s+/gu, " ").toLocaleLowerCase(e || void 0) : "";
|
|
959
959
|
}
|
|
960
|
-
function
|
|
961
|
-
return t.localeCompare(e,
|
|
960
|
+
function bt(t, e, n) {
|
|
961
|
+
return t.localeCompare(e, n, { numeric: !0 });
|
|
962
962
|
}
|
|
963
|
-
function
|
|
964
|
-
return Array.isArray(t) ? t.map((
|
|
963
|
+
function pn(t, e, n) {
|
|
964
|
+
return Array.isArray(t) ? t.map((r) => E(r, e)).filter(Boolean).sort((r, o) => bt(r, o, e)).slice(0, n) : void 0;
|
|
965
965
|
}
|
|
966
|
-
async function
|
|
967
|
-
const c = performance.now(), l = await
|
|
968
|
-
|
|
969
|
-
const p =
|
|
966
|
+
async function Zr({ request: t, accountModule: e, contextStore: n, beClient: r, toolBridge: o, emit: i, rpc: a, signal: s }) {
|
|
967
|
+
const c = performance.now(), l = await n.load(t), u = l.thread.id, f = $n(t);
|
|
968
|
+
Cn(l, f) && n.appendUserMessage(u, f);
|
|
969
|
+
const p = un(e.flows, t);
|
|
970
970
|
if (!p)
|
|
971
|
-
return i(
|
|
971
|
+
return i(cn("unknown_action", `No agent flow for request type ${t?.type || "inputText"}`)), i(Jt()), {
|
|
972
972
|
steps: 0,
|
|
973
973
|
productSkusEmitted: []
|
|
974
974
|
};
|
|
975
975
|
const m = {
|
|
976
976
|
request: t,
|
|
977
|
-
context:
|
|
977
|
+
context: n.patch(u, {}) || l,
|
|
978
978
|
bag: {},
|
|
979
979
|
accountConfig: e.accountConfig || {},
|
|
980
980
|
threadId: u,
|
|
981
981
|
steps: 0,
|
|
982
982
|
productSkusEmitted: /* @__PURE__ */ new Set(),
|
|
983
983
|
committed: !1,
|
|
984
|
-
messageLimit:
|
|
984
|
+
messageLimit: Rn(e.contextPersistence?.messageLimit),
|
|
985
985
|
catalogMapper: e.catalogMapper,
|
|
986
986
|
similarityMapper: e.similarityMapper
|
|
987
987
|
}, g = {
|
|
988
|
-
contextStore:
|
|
989
|
-
beClient:
|
|
988
|
+
contextStore: n,
|
|
989
|
+
beClient: r,
|
|
990
990
|
toolBridge: o,
|
|
991
991
|
emit: i,
|
|
992
992
|
rpc: a,
|
|
@@ -996,7 +996,7 @@ async function Zn({ request: t, accountModule: e, contextStore: r, beClient: n,
|
|
|
996
996
|
};
|
|
997
997
|
await j(g, F("turn:start", m));
|
|
998
998
|
try {
|
|
999
|
-
await $(p, m, g), m.committed || await
|
|
999
|
+
await $(p, m, g), m.committed || await wt(m, g);
|
|
1000
1000
|
} catch (_) {
|
|
1001
1001
|
throw await j(g, {
|
|
1002
1002
|
...F("turn:error", m),
|
|
@@ -1020,75 +1020,75 @@ async function Zn({ request: t, accountModule: e, contextStore: r, beClient: n,
|
|
|
1020
1020
|
productSkusEmitted: [...m.productSkusEmitted]
|
|
1021
1021
|
};
|
|
1022
1022
|
}
|
|
1023
|
-
async function $(t, e,
|
|
1024
|
-
for (const
|
|
1025
|
-
if (
|
|
1023
|
+
async function $(t, e, n) {
|
|
1024
|
+
for (const r of t) {
|
|
1025
|
+
if (n.signal?.aborted || e.committed) return;
|
|
1026
1026
|
e.steps += 1;
|
|
1027
1027
|
const o = e.steps, i = performance.now();
|
|
1028
|
-
await j(
|
|
1028
|
+
await j(n, ot("step:start", e, r, o));
|
|
1029
1029
|
try {
|
|
1030
|
-
await
|
|
1031
|
-
...ot("step:end", e,
|
|
1030
|
+
await mn(r, e, n), await j(n, {
|
|
1031
|
+
...ot("step:end", e, r, o),
|
|
1032
1032
|
latencyMs: v(i)
|
|
1033
1033
|
});
|
|
1034
1034
|
} catch (a) {
|
|
1035
|
-
throw await j(
|
|
1036
|
-
...ot("step:error", e,
|
|
1035
|
+
throw await j(n, {
|
|
1036
|
+
...ot("step:error", e, r, o),
|
|
1037
1037
|
latencyMs: v(i),
|
|
1038
1038
|
errorCode: At(a)
|
|
1039
1039
|
}), a;
|
|
1040
1040
|
}
|
|
1041
|
-
e.context =
|
|
1041
|
+
e.context = n.contextStore.patch(e.threadId, {}) || e.context;
|
|
1042
1042
|
}
|
|
1043
1043
|
}
|
|
1044
|
-
async function
|
|
1045
|
-
const
|
|
1044
|
+
async function mn(t, e, n) {
|
|
1045
|
+
const r = R(e, n);
|
|
1046
1046
|
if (t.kind === "be_op") {
|
|
1047
|
-
await
|
|
1047
|
+
await yn(t, e, n, r);
|
|
1048
1048
|
return;
|
|
1049
1049
|
}
|
|
1050
1050
|
if (t.kind === "tool") {
|
|
1051
|
-
await
|
|
1051
|
+
await bn(t, e, n, r);
|
|
1052
1052
|
return;
|
|
1053
1053
|
}
|
|
1054
1054
|
if (t.kind === "adapter") {
|
|
1055
|
-
await
|
|
1055
|
+
await wn(t, e, n, r);
|
|
1056
1056
|
return;
|
|
1057
1057
|
}
|
|
1058
1058
|
if (t.kind === "emit") {
|
|
1059
|
-
await
|
|
1059
|
+
await kn(t, e, n);
|
|
1060
1060
|
return;
|
|
1061
1061
|
}
|
|
1062
1062
|
if (t.kind === "patch") {
|
|
1063
|
-
await
|
|
1063
|
+
await An(t, e, n);
|
|
1064
1064
|
return;
|
|
1065
1065
|
}
|
|
1066
1066
|
if (t.kind === "branch") {
|
|
1067
|
-
await
|
|
1067
|
+
await _n(t, e, n, r);
|
|
1068
1068
|
return;
|
|
1069
1069
|
}
|
|
1070
1070
|
if (t.kind === "agent_loop") {
|
|
1071
|
-
await
|
|
1071
|
+
await xn(t, e, n, r);
|
|
1072
1072
|
return;
|
|
1073
1073
|
}
|
|
1074
1074
|
if (t.kind === "parallel") {
|
|
1075
|
-
await
|
|
1075
|
+
await Sn(t, e, n);
|
|
1076
1076
|
return;
|
|
1077
1077
|
}
|
|
1078
1078
|
if (t.kind === "refusal") {
|
|
1079
|
-
await
|
|
1079
|
+
await vn(t, e, n, r);
|
|
1080
1080
|
return;
|
|
1081
1081
|
}
|
|
1082
|
-
t.kind === "commit" && await
|
|
1082
|
+
t.kind === "commit" && await jn(t, e, n);
|
|
1083
1083
|
}
|
|
1084
|
-
async function
|
|
1084
|
+
async function yn(t, e, n, r) {
|
|
1085
1085
|
const o = performance.now();
|
|
1086
1086
|
let i;
|
|
1087
1087
|
try {
|
|
1088
|
-
const s = await
|
|
1089
|
-
await kt(t, e,
|
|
1090
|
-
const m = p ? new AbortController() : null, g = Wt(
|
|
1091
|
-
i = await Y(
|
|
1088
|
+
const s = await w(t.input, r), c = gn(t, e, s, await w(t.cache, r)), l = await w(t.cacheTtlS, r) ?? c.cacheTtlS, u = await w(t.cacheKey, r) ?? c.cacheKey, f = await w(t.browserCache, r), p = z(await w(t.timeoutMs, r));
|
|
1089
|
+
await kt(t, e, n, r);
|
|
1090
|
+
const m = p ? new AbortController() : null, g = Wt(n.signal, m?.signal);
|
|
1091
|
+
i = await Y(n.beClient.invoke({
|
|
1092
1092
|
op: t.op,
|
|
1093
1093
|
input: s,
|
|
1094
1094
|
...l !== void 0 ? { cacheTtlS: l } : {},
|
|
@@ -1110,13 +1110,13 @@ async function mr(t, e, r, n) {
|
|
|
1110
1110
|
latencyMs: v(o),
|
|
1111
1111
|
errorCode: l
|
|
1112
1112
|
};
|
|
1113
|
-
if (await
|
|
1114
|
-
t.errorOut && (e.bag[t.errorOut] = s), await $(t.onError, e,
|
|
1113
|
+
if (await n.rpc("beacon.send", u), t.onError) {
|
|
1114
|
+
t.errorOut && (e.bag[t.errorOut] = s), await $(t.onError, e, n);
|
|
1115
1115
|
return;
|
|
1116
1116
|
}
|
|
1117
1117
|
throw s;
|
|
1118
1118
|
}
|
|
1119
|
-
t.out && (e.bag[t.out] = i), await Q(t, i, e,
|
|
1119
|
+
t.out && (e.bag[t.out] = i), await Q(t, i, e, n.contextStore);
|
|
1120
1120
|
const a = {
|
|
1121
1121
|
type: "agentOp",
|
|
1122
1122
|
threadId: e.threadId,
|
|
@@ -1126,37 +1126,37 @@ async function mr(t, e, r, n) {
|
|
|
1126
1126
|
status: "ok",
|
|
1127
1127
|
latencyMs: v(o)
|
|
1128
1128
|
};
|
|
1129
|
-
await
|
|
1129
|
+
await n.rpc("beacon.send", a);
|
|
1130
1130
|
}
|
|
1131
|
-
function
|
|
1132
|
-
if (!
|
|
1133
|
-
const o = z(
|
|
1131
|
+
function gn(t, e, n, r) {
|
|
1132
|
+
if (!r || r.strategy !== "input-hash") return {};
|
|
1133
|
+
const o = z(r.ttlS);
|
|
1134
1134
|
if (!o) return {};
|
|
1135
|
-
const i = e.context.meta.locale, a =
|
|
1135
|
+
const i = e.context.meta.locale, a = r.promptVersion || hn(n) || "current";
|
|
1136
1136
|
return {
|
|
1137
1137
|
cacheTtlS: o,
|
|
1138
1138
|
cacheKey: Ht(t.op, {
|
|
1139
1139
|
account: e.context.meta.accountId,
|
|
1140
1140
|
locale: i,
|
|
1141
1141
|
promptVersion: a,
|
|
1142
|
-
payload:
|
|
1142
|
+
payload: n
|
|
1143
1143
|
}, { version: "input-hash" })
|
|
1144
1144
|
};
|
|
1145
1145
|
}
|
|
1146
|
-
function
|
|
1146
|
+
function hn(t) {
|
|
1147
1147
|
if (!t || typeof t != "object" || Array.isArray(t)) return;
|
|
1148
|
-
const e = t,
|
|
1149
|
-
return typeof
|
|
1148
|
+
const e = t, n = e.prompt_version || e.promptVersion;
|
|
1149
|
+
return typeof n == "string" && n.trim() ? n.trim() : void 0;
|
|
1150
1150
|
}
|
|
1151
|
-
async function
|
|
1151
|
+
async function bn(t, e, n, r) {
|
|
1152
1152
|
const o = performance.now();
|
|
1153
1153
|
try {
|
|
1154
|
-
await kt(t, e,
|
|
1155
|
-
const i = z(await
|
|
1154
|
+
await kt(t, e, n, r);
|
|
1155
|
+
const i = z(await w(t.timeoutMs, r)), a = await Y(n.toolBridge.invoke(t.name, await w(t.input, r)), i, () => new T("tool_timeout", "The assistant tool took too long to respond.", {
|
|
1156
1156
|
source: "tool",
|
|
1157
1157
|
sourceCode: "timeout"
|
|
1158
1158
|
}));
|
|
1159
|
-
t.out && (e.bag[t.out] = a), await Q(t, a, e,
|
|
1159
|
+
t.out && (e.bag[t.out] = a), await Q(t, a, e, n.contextStore), await n.rpc("beacon.send", {
|
|
1160
1160
|
type: "agentTool",
|
|
1161
1161
|
threadId: e.threadId,
|
|
1162
1162
|
sessionId: Z(e),
|
|
@@ -1167,7 +1167,7 @@ async function hr(t, e, r, n) {
|
|
|
1167
1167
|
});
|
|
1168
1168
|
} catch (i) {
|
|
1169
1169
|
const a = i;
|
|
1170
|
-
if (await
|
|
1170
|
+
if (await n.rpc("beacon.send", {
|
|
1171
1171
|
type: "agentTool",
|
|
1172
1172
|
threadId: e.threadId,
|
|
1173
1173
|
sessionId: Z(e),
|
|
@@ -1177,122 +1177,127 @@ async function hr(t, e, r, n) {
|
|
|
1177
1177
|
latencyMs: v(o),
|
|
1178
1178
|
errorCode: String(a?.code || a?.name || "unknown")
|
|
1179
1179
|
}), t.onError) {
|
|
1180
|
-
t.errorOut && (e.bag[t.errorOut] = i), await $(t.onError, e,
|
|
1180
|
+
t.errorOut && (e.bag[t.errorOut] = i), await $(t.onError, e, n);
|
|
1181
1181
|
return;
|
|
1182
1182
|
}
|
|
1183
1183
|
throw i;
|
|
1184
1184
|
}
|
|
1185
1185
|
}
|
|
1186
|
-
async function
|
|
1187
|
-
const o =
|
|
1186
|
+
async function wn(t, e, n, r) {
|
|
1187
|
+
const o = n.adapters?.[t.name];
|
|
1188
1188
|
if (typeof o != "function") throw new Error(`Unknown flow adapter: ${t.name}`);
|
|
1189
|
-
await kt(t, e,
|
|
1190
|
-
const i = z(await
|
|
1189
|
+
await kt(t, e, n, r);
|
|
1190
|
+
const i = z(await w(t.timeoutMs, r)), a = await Y(o(await w(t.input, r), r), i, () => new T("adapter_timeout", "The assistant adapter took too long to respond.", {
|
|
1191
1191
|
source: "adapter",
|
|
1192
1192
|
sourceCode: "timeout"
|
|
1193
1193
|
}));
|
|
1194
|
-
t.out && (e.bag[t.out] = a), await Q(t, a, e,
|
|
1194
|
+
t.out && (e.bag[t.out] = a), await Q(t, a, e, n.contextStore);
|
|
1195
1195
|
}
|
|
1196
|
-
async function
|
|
1197
|
-
const
|
|
1198
|
-
|
|
1196
|
+
async function kn(t, e, n) {
|
|
1197
|
+
const r = await t.build(R(e, n));
|
|
1198
|
+
Ln(r, e.productSkusEmitted), n.emit(r);
|
|
1199
1199
|
}
|
|
1200
|
-
async function
|
|
1201
|
-
await Q(t, void 0, e,
|
|
1200
|
+
async function An(t, e, n) {
|
|
1201
|
+
await Q(t, void 0, e, n.contextStore);
|
|
1202
1202
|
}
|
|
1203
|
-
async function
|
|
1204
|
-
const o = String(await
|
|
1205
|
-
await $(t.cases[o] || t.cases.default || [], e,
|
|
1203
|
+
async function _n(t, e, n, r) {
|
|
1204
|
+
const o = String(await w(t.on, r) || "default");
|
|
1205
|
+
await $(t.cases[o] || t.cases.default || [], e, n);
|
|
1206
1206
|
}
|
|
1207
|
-
async function
|
|
1208
|
-
if (!await t.shouldContinue(e.bag,
|
|
1207
|
+
async function xn(t, e, n, r) {
|
|
1208
|
+
if (!await t.shouldContinue(e.bag, r)) return;
|
|
1209
1209
|
const o = Math.max(0, Math.floor(Number(t.maxIterations) || 0));
|
|
1210
1210
|
let i = 0;
|
|
1211
|
-
for (; !
|
|
1212
|
-
if (await $(t.body, e,
|
|
1213
|
-
const a = await t.onIterate?.(e.bag, R(e));
|
|
1211
|
+
for (; !n.signal?.aborted && !e.committed; ) {
|
|
1212
|
+
if (await $(t.body, e, n), n.signal?.aborted || e.committed || !await t.shouldContinue(e.bag, R(e, n)) || i >= o) return;
|
|
1213
|
+
const a = await t.onIterate?.(e.bag, R(e, n));
|
|
1214
1214
|
a && typeof a == "object" && Object.assign(e.bag, a), i += 1;
|
|
1215
1215
|
}
|
|
1216
1216
|
}
|
|
1217
|
-
async function
|
|
1218
|
-
const
|
|
1217
|
+
async function Sn(t, e, n) {
|
|
1218
|
+
const r = z(await w(t.timeoutMs, R(e, n))), o = r ? new AbortController() : null, i = Wt(n.signal, o?.signal), a = t.steps.map((l) => {
|
|
1219
1219
|
const u = {
|
|
1220
1220
|
...e,
|
|
1221
|
-
context:
|
|
1221
|
+
context: En(e.context),
|
|
1222
1222
|
bag: ct(e.bag),
|
|
1223
1223
|
productSkusEmitted: new Set(e.productSkusEmitted),
|
|
1224
1224
|
committed: !1
|
|
1225
1225
|
}, f = [];
|
|
1226
1226
|
return $(l, u, {
|
|
1227
|
-
...
|
|
1227
|
+
...n,
|
|
1228
1228
|
emit: (p) => {
|
|
1229
1229
|
!i?.aborted && p.type !== "done" && f.push(p);
|
|
1230
1230
|
},
|
|
1231
|
-
contextStore:
|
|
1231
|
+
contextStore: In(u),
|
|
1232
1232
|
...i ? { signal: i } : {}
|
|
1233
1233
|
}).then(() => ({
|
|
1234
1234
|
state: u,
|
|
1235
1235
|
events: f
|
|
1236
1236
|
}));
|
|
1237
|
-
}), s = await Y(Promise.all(a),
|
|
1237
|
+
}), s = await Y(Promise.all(a), r, () => new T("parallel_timeout", "The assistant parallel step took too long to respond.", {
|
|
1238
1238
|
source: "agent",
|
|
1239
1239
|
sourceCode: "timeout"
|
|
1240
1240
|
}), () => o?.abort()), c = t.merge || {};
|
|
1241
1241
|
for (const { state: l, events: u } of s) {
|
|
1242
|
-
for (const f of u)
|
|
1242
|
+
for (const f of u) n.emit(f);
|
|
1243
1243
|
for (const f of l.productSkusEmitted) e.productSkusEmitted.add(f);
|
|
1244
1244
|
for (const f of c.bag || []) Object.prototype.hasOwnProperty.call(l.bag, f) && (e.bag[f] = l.bag[f]);
|
|
1245
1245
|
if (c.panel?.length) {
|
|
1246
1246
|
const f = Nt(l.context.panel, c.panel);
|
|
1247
|
-
Object.keys(f).length && (e.context =
|
|
1247
|
+
Object.keys(f).length && (e.context = n.contextStore.patch(e.threadId, { panel: f }) || e.context);
|
|
1248
1248
|
}
|
|
1249
1249
|
if (c.threadExtensions?.length) {
|
|
1250
1250
|
const f = Nt(l.context.thread.extensions, c.threadExtensions);
|
|
1251
|
-
Object.keys(f).length && (e.context =
|
|
1251
|
+
Object.keys(f).length && (e.context = n.contextStore.patch(e.threadId, { thread: {
|
|
1252
1252
|
...e.context.thread,
|
|
1253
1253
|
extensions: f
|
|
1254
1254
|
} }) || e.context);
|
|
1255
1255
|
}
|
|
1256
1256
|
}
|
|
1257
1257
|
}
|
|
1258
|
-
async function
|
|
1259
|
-
|
|
1258
|
+
async function vn(t, e, n, r) {
|
|
1259
|
+
n.emit(sn(await w(t.message, r), !0)), await wt(e, n);
|
|
1260
1260
|
}
|
|
1261
|
-
async function
|
|
1262
|
-
await
|
|
1261
|
+
async function jn(t, e, n) {
|
|
1262
|
+
await wt(e, n);
|
|
1263
1263
|
}
|
|
1264
|
-
async function
|
|
1265
|
-
t.committed || (t.context = await e.commit(t.threadId) || t.context, t.committed = !0,
|
|
1264
|
+
async function wt(t, { contextStore: e, emit: n }) {
|
|
1265
|
+
t.committed || (t.context = await e.commit(t.threadId) || t.context, t.committed = !0, n(Jt()));
|
|
1266
1266
|
}
|
|
1267
|
-
async function Q(t, e,
|
|
1267
|
+
async function Q(t, e, n, r) {
|
|
1268
1268
|
if (typeof t.patch != "function") return;
|
|
1269
|
-
const o = await t.patch(
|
|
1270
|
-
o && (
|
|
1269
|
+
const o = await t.patch(n.context, e, R(n));
|
|
1270
|
+
o && (n.context = r.patch(n.threadId, o) || n.context);
|
|
1271
1271
|
}
|
|
1272
|
-
function R(t) {
|
|
1272
|
+
function R(t, e) {
|
|
1273
1273
|
return {
|
|
1274
1274
|
request: t.request,
|
|
1275
1275
|
context: t.context,
|
|
1276
1276
|
bag: t.bag,
|
|
1277
1277
|
accountConfig: t.accountConfig,
|
|
1278
1278
|
catalogMapper: t.catalogMapper,
|
|
1279
|
-
similarityMapper: t.similarityMapper
|
|
1279
|
+
similarityMapper: t.similarityMapper,
|
|
1280
|
+
...e ? {
|
|
1281
|
+
beClient: e.beClient,
|
|
1282
|
+
toolBridge: e.toolBridge
|
|
1283
|
+
} : {},
|
|
1284
|
+
...e?.signal ? { signal: e.signal } : {}
|
|
1280
1285
|
};
|
|
1281
1286
|
}
|
|
1282
1287
|
function Z(t) {
|
|
1283
1288
|
return t.request?.session_id || t.request?.sessionId || t.threadId;
|
|
1284
1289
|
}
|
|
1285
|
-
function
|
|
1290
|
+
function Cn(t, e) {
|
|
1286
1291
|
if (!e) return !1;
|
|
1287
|
-
const
|
|
1288
|
-
return
|
|
1292
|
+
const n = t.messages[t.messages.length - 1];
|
|
1293
|
+
return n?.role !== "user" || n.content !== e;
|
|
1289
1294
|
}
|
|
1290
1295
|
function Nt(t, e) {
|
|
1291
|
-
const
|
|
1292
|
-
for (const
|
|
1293
|
-
return
|
|
1296
|
+
const n = {};
|
|
1297
|
+
for (const r of e) Object.prototype.hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
1298
|
+
return n;
|
|
1294
1299
|
}
|
|
1295
|
-
function
|
|
1300
|
+
function En(t) {
|
|
1296
1301
|
return {
|
|
1297
1302
|
...t,
|
|
1298
1303
|
panel: ct(t.panel || {}),
|
|
@@ -1304,13 +1309,13 @@ function Cr(t) {
|
|
|
1304
1309
|
messages: t.messages
|
|
1305
1310
|
};
|
|
1306
1311
|
}
|
|
1307
|
-
function
|
|
1312
|
+
function In(t) {
|
|
1308
1313
|
return {
|
|
1309
1314
|
async load() {
|
|
1310
1315
|
return t.context;
|
|
1311
1316
|
},
|
|
1312
|
-
patch(e,
|
|
1313
|
-
return t.context =
|
|
1317
|
+
patch(e, n) {
|
|
1318
|
+
return t.context = Tn(t.context, n, t.messageLimit), t.context;
|
|
1314
1319
|
},
|
|
1315
1320
|
appendUserMessage() {
|
|
1316
1321
|
return t.context;
|
|
@@ -1320,13 +1325,13 @@ function Er(t) {
|
|
|
1320
1325
|
}
|
|
1321
1326
|
};
|
|
1322
1327
|
}
|
|
1323
|
-
function
|
|
1328
|
+
function Tn(t, e, n) {
|
|
1324
1329
|
if (!e || typeof e != "object") return t;
|
|
1325
|
-
const
|
|
1330
|
+
const r = qt(t.panel, e.panel), o = qt(t.thread?.extensions || {}, e.thread?.extensions);
|
|
1326
1331
|
return {
|
|
1327
1332
|
...t,
|
|
1328
1333
|
...e,
|
|
1329
|
-
panel:
|
|
1334
|
+
panel: r,
|
|
1330
1335
|
thread: {
|
|
1331
1336
|
...t.thread || {},
|
|
1332
1337
|
...e.thread || {},
|
|
@@ -1336,43 +1341,43 @@ function Ir(t, e, r) {
|
|
|
1336
1341
|
...t.meta || {},
|
|
1337
1342
|
...e.meta || {}
|
|
1338
1343
|
},
|
|
1339
|
-
messages: Array.isArray(e.messages) ? G(e.messages,
|
|
1344
|
+
messages: Array.isArray(e.messages) ? G(e.messages, n) : t.messages
|
|
1340
1345
|
};
|
|
1341
1346
|
}
|
|
1342
1347
|
function qt(t, e) {
|
|
1343
1348
|
if (!e || typeof e != "object" || Array.isArray(e)) return t;
|
|
1344
|
-
const
|
|
1345
|
-
for (const
|
|
1346
|
-
for (const [
|
|
1347
|
-
return
|
|
1349
|
+
const n = {};
|
|
1350
|
+
for (const r of Object.keys(t)) n[r] = t[r];
|
|
1351
|
+
for (const [r, o] of Object.entries(e)) n[r] = o;
|
|
1352
|
+
return n;
|
|
1348
1353
|
}
|
|
1349
1354
|
function ct(t) {
|
|
1350
1355
|
return new Proxy({}, {
|
|
1351
|
-
get(e,
|
|
1352
|
-
if (typeof
|
|
1353
|
-
if (Object.prototype.hasOwnProperty.call(e,
|
|
1354
|
-
const o = t[
|
|
1355
|
-
if (
|
|
1356
|
-
const i =
|
|
1357
|
-
return e[
|
|
1356
|
+
get(e, n, r) {
|
|
1357
|
+
if (typeof n != "string") return Reflect.get(e, n, r);
|
|
1358
|
+
if (Object.prototype.hasOwnProperty.call(e, n)) return e[n];
|
|
1359
|
+
const o = t[n];
|
|
1360
|
+
if (Pn(o)) {
|
|
1361
|
+
const i = On(o);
|
|
1362
|
+
return e[n] = i, i;
|
|
1358
1363
|
}
|
|
1359
1364
|
return o;
|
|
1360
1365
|
},
|
|
1361
|
-
has(e,
|
|
1362
|
-
return Reflect.has(e,
|
|
1366
|
+
has(e, n) {
|
|
1367
|
+
return Reflect.has(e, n) || Reflect.has(t, n);
|
|
1363
1368
|
},
|
|
1364
1369
|
ownKeys(e) {
|
|
1365
1370
|
return Reflect.ownKeys(e);
|
|
1366
1371
|
},
|
|
1367
|
-
getOwnPropertyDescriptor(e,
|
|
1368
|
-
return Object.getOwnPropertyDescriptor(e,
|
|
1372
|
+
getOwnPropertyDescriptor(e, n) {
|
|
1373
|
+
return Object.getOwnPropertyDescriptor(e, n);
|
|
1369
1374
|
}
|
|
1370
1375
|
});
|
|
1371
1376
|
}
|
|
1372
|
-
function
|
|
1377
|
+
function Pn(t) {
|
|
1373
1378
|
return !!(t && typeof t == "object");
|
|
1374
1379
|
}
|
|
1375
|
-
function
|
|
1380
|
+
function On(t) {
|
|
1376
1381
|
if (typeof structuredClone == "function") try {
|
|
1377
1382
|
return structuredClone(t);
|
|
1378
1383
|
} catch {
|
|
@@ -1383,7 +1388,7 @@ function Pr(t) {
|
|
|
1383
1388
|
return t;
|
|
1384
1389
|
}
|
|
1385
1390
|
}
|
|
1386
|
-
async function
|
|
1391
|
+
async function w(t, e) {
|
|
1387
1392
|
return typeof t == "function" ? await t(e) : t;
|
|
1388
1393
|
}
|
|
1389
1394
|
function z(t) {
|
|
@@ -1391,12 +1396,12 @@ function z(t) {
|
|
|
1391
1396
|
const e = Math.floor(Number(t));
|
|
1392
1397
|
return Number.isFinite(e) && e > 0 ? e : void 0;
|
|
1393
1398
|
}
|
|
1394
|
-
async function Y(t, e,
|
|
1399
|
+
async function Y(t, e, n, r) {
|
|
1395
1400
|
if (!e) return t;
|
|
1396
1401
|
let o, i = !1;
|
|
1397
1402
|
return new Promise((a, s) => {
|
|
1398
1403
|
o = setTimeout(() => {
|
|
1399
|
-
i || (i = !0,
|
|
1404
|
+
i || (i = !0, r?.(), s(n()));
|
|
1400
1405
|
}, e), Promise.resolve(t).then((c) => {
|
|
1401
1406
|
i || (i = !0, o && clearTimeout(o), a(c));
|
|
1402
1407
|
}, (c) => {
|
|
@@ -1408,41 +1413,41 @@ function Wt(t, e) {
|
|
|
1408
1413
|
if (!t) return e;
|
|
1409
1414
|
if (!e || t.aborted) return t;
|
|
1410
1415
|
if (e.aborted) return e;
|
|
1411
|
-
const
|
|
1412
|
-
return t.addEventListener("abort",
|
|
1416
|
+
const n = new AbortController(), r = () => n.abort();
|
|
1417
|
+
return t.addEventListener("abort", r, { once: !0 }), e.addEventListener("abort", r, { once: !0 }), n.signal;
|
|
1413
1418
|
}
|
|
1414
|
-
async function kt(t, e,
|
|
1419
|
+
async function kt(t, e, n, r) {
|
|
1415
1420
|
if (!t.confirm) return;
|
|
1416
|
-
const o = await
|
|
1421
|
+
const o = await w(t.confirm, r);
|
|
1417
1422
|
if (!o) return;
|
|
1418
|
-
const i =
|
|
1419
|
-
await j(
|
|
1423
|
+
const i = Bn(o, t, e);
|
|
1424
|
+
await j(n, it("confirmation:start", e, t));
|
|
1420
1425
|
try {
|
|
1421
|
-
const a = await
|
|
1422
|
-
if (await j(
|
|
1426
|
+
const a = await n.rpc("confirmation.request", i), s = typeof a == "boolean" ? a : a?.confirmed === !0;
|
|
1427
|
+
if (await j(n, it("confirmation:end", e, t)), s) return;
|
|
1423
1428
|
throw new T("confirmation_declined", "The requested action was not confirmed.", {
|
|
1424
1429
|
source: t.kind === "be_op" ? "be" : t.kind,
|
|
1425
1430
|
sourceCode: "confirmation_declined",
|
|
1426
1431
|
detail: a
|
|
1427
1432
|
});
|
|
1428
1433
|
} catch (a) {
|
|
1429
|
-
throw await j(
|
|
1434
|
+
throw await j(n, {
|
|
1430
1435
|
...it("confirmation:error", e, t),
|
|
1431
1436
|
errorCode: At(a)
|
|
1432
1437
|
}), a;
|
|
1433
1438
|
}
|
|
1434
1439
|
}
|
|
1435
|
-
function
|
|
1440
|
+
function Bn(t, e, n) {
|
|
1436
1441
|
return {
|
|
1437
|
-
...
|
|
1438
|
-
accountId:
|
|
1439
|
-
threadId:
|
|
1440
|
-
sessionId: Z(
|
|
1442
|
+
...Mn(t),
|
|
1443
|
+
accountId: n.context.meta.accountId,
|
|
1444
|
+
threadId: n.threadId,
|
|
1445
|
+
sessionId: Z(n),
|
|
1441
1446
|
stepKind: e.kind,
|
|
1442
1447
|
...e.kind === "be_op" ? { stepName: e.op } : { stepName: e.name }
|
|
1443
1448
|
};
|
|
1444
1449
|
}
|
|
1445
|
-
function
|
|
1450
|
+
function Mn(t) {
|
|
1446
1451
|
return typeof t == "string" ? { message: t } : t === !0 ? {} : t && typeof t == "object" ? {
|
|
1447
1452
|
...typeof t.title == "string" ? { title: t.title } : {},
|
|
1448
1453
|
...typeof t.message == "string" ? { message: t.message } : {},
|
|
@@ -1464,21 +1469,21 @@ function F(t, e) {
|
|
|
1464
1469
|
sessionId: Z(e)
|
|
1465
1470
|
};
|
|
1466
1471
|
}
|
|
1467
|
-
function ot(t, e,
|
|
1468
|
-
const o = Xt(
|
|
1472
|
+
function ot(t, e, n, r) {
|
|
1473
|
+
const o = Xt(n);
|
|
1469
1474
|
return {
|
|
1470
1475
|
...F(t, e),
|
|
1471
|
-
stepIndex:
|
|
1472
|
-
stepKind:
|
|
1476
|
+
stepIndex: r,
|
|
1477
|
+
stepKind: n.kind,
|
|
1473
1478
|
...o ? { stepName: o } : {}
|
|
1474
1479
|
};
|
|
1475
1480
|
}
|
|
1476
|
-
function it(t, e,
|
|
1477
|
-
const
|
|
1481
|
+
function it(t, e, n) {
|
|
1482
|
+
const r = Xt(n);
|
|
1478
1483
|
return {
|
|
1479
1484
|
...F(t, e),
|
|
1480
|
-
stepKind:
|
|
1481
|
-
...
|
|
1485
|
+
stepKind: n.kind,
|
|
1486
|
+
...r ? { stepName: r } : {}
|
|
1482
1487
|
};
|
|
1483
1488
|
}
|
|
1484
1489
|
function Xt(t) {
|
|
@@ -1492,22 +1497,22 @@ function At(t) {
|
|
|
1492
1497
|
}
|
|
1493
1498
|
return "unknown";
|
|
1494
1499
|
}
|
|
1495
|
-
function
|
|
1500
|
+
function Rn(t) {
|
|
1496
1501
|
if (t === void 0) return;
|
|
1497
1502
|
const e = Math.floor(Number(t));
|
|
1498
1503
|
return Number.isFinite(e) && e > 0 ? e : void 0;
|
|
1499
1504
|
}
|
|
1500
|
-
function
|
|
1505
|
+
function $n(t) {
|
|
1501
1506
|
const e = t?.payload;
|
|
1502
1507
|
if (typeof e == "string") return e;
|
|
1503
1508
|
if (e && typeof e == "object" && "text" in e) {
|
|
1504
|
-
const
|
|
1505
|
-
if (typeof
|
|
1509
|
+
const n = e.text;
|
|
1510
|
+
if (typeof n == "string") return n;
|
|
1506
1511
|
}
|
|
1507
1512
|
return typeof t?.action?.payload == "string" ? t.action.payload : typeof t?.action?.title == "string" ? t.action.title : "";
|
|
1508
1513
|
}
|
|
1509
|
-
function
|
|
1510
|
-
const
|
|
1514
|
+
function Ln(t, e) {
|
|
1515
|
+
const n = t, r = n.spec, o = Array.isArray(r?.items) ? r.items : void 0, i = Array.isArray(n.items) ? n.items : void 0, a = o || i;
|
|
1511
1516
|
if (Array.isArray(a)) {
|
|
1512
1517
|
for (const s of a) if (s && typeof s == "object") {
|
|
1513
1518
|
const c = s.sku;
|
|
@@ -1515,23 +1520,23 @@ function $r(t, e) {
|
|
|
1515
1520
|
}
|
|
1516
1521
|
}
|
|
1517
1522
|
}
|
|
1518
|
-
function
|
|
1519
|
-
return { invoke(e,
|
|
1523
|
+
function Hr(t) {
|
|
1524
|
+
return { invoke(e, n) {
|
|
1520
1525
|
return t("tool.invoke", {
|
|
1521
1526
|
name: e,
|
|
1522
|
-
input:
|
|
1527
|
+
input: n
|
|
1523
1528
|
});
|
|
1524
1529
|
} };
|
|
1525
1530
|
}
|
|
1526
|
-
function
|
|
1531
|
+
function Gr(t, e = {}) {
|
|
1527
1532
|
if (!Array.isArray(t)) return [];
|
|
1528
|
-
const
|
|
1529
|
-
return t.map((o) =>
|
|
1533
|
+
const n = e.maxItems ?? 8, r = e.maxFeatures ?? 8;
|
|
1534
|
+
return t.map((o) => Nn(o, e.defaultBrand, r)).filter((o) => !!o).slice(0, n);
|
|
1530
1535
|
}
|
|
1531
|
-
function
|
|
1536
|
+
function Nn(t, e, n) {
|
|
1532
1537
|
if (!t || typeof t != "object" || Array.isArray(t)) return null;
|
|
1533
|
-
const
|
|
1534
|
-
return o ?
|
|
1538
|
+
const r = t, o = ht(r);
|
|
1539
|
+
return o ? Un({
|
|
1535
1540
|
sku: o.sku,
|
|
1536
1541
|
name: o.name,
|
|
1537
1542
|
url: o.url,
|
|
@@ -1540,58 +1545,58 @@ function Lr(t, e, r) {
|
|
|
1540
1545
|
currency: o.currency,
|
|
1541
1546
|
category: o.category,
|
|
1542
1547
|
category_names: o.category_names,
|
|
1543
|
-
brand:
|
|
1544
|
-
features:
|
|
1545
|
-
specs:
|
|
1548
|
+
brand: r.brand || e,
|
|
1549
|
+
features: qn(r.features, n),
|
|
1550
|
+
specs: Fn(r.specs, n),
|
|
1546
1551
|
in_stock: o.in_stock
|
|
1547
1552
|
}) : null;
|
|
1548
1553
|
}
|
|
1549
|
-
function
|
|
1554
|
+
function qn(t, e) {
|
|
1550
1555
|
return Array.isArray(t) ? t.filter(Boolean).slice(0, e) : void 0;
|
|
1551
1556
|
}
|
|
1552
|
-
function
|
|
1557
|
+
function Fn(t, e) {
|
|
1553
1558
|
if (!(!t || typeof t != "object" || Array.isArray(t)))
|
|
1554
|
-
return Object.fromEntries(Object.entries(t).filter(([,
|
|
1559
|
+
return Object.fromEntries(Object.entries(t).filter(([, n]) => n != null).slice(0, e));
|
|
1555
1560
|
}
|
|
1556
|
-
function
|
|
1561
|
+
function Un(t) {
|
|
1557
1562
|
return Object.fromEntries(Object.entries(t).filter(([, e]) => e != null));
|
|
1558
1563
|
}
|
|
1559
1564
|
function te(t) {
|
|
1560
1565
|
if (!t || typeof t != "object" || Array.isArray(t)) return {};
|
|
1561
|
-
const e = t,
|
|
1566
|
+
const e = t, n = Array.isArray(e.rows) ? e.rows : [];
|
|
1562
1567
|
return {
|
|
1563
1568
|
...e,
|
|
1564
|
-
rows:
|
|
1569
|
+
rows: n.map(Dn).filter(Boolean)
|
|
1565
1570
|
};
|
|
1566
1571
|
}
|
|
1567
|
-
function
|
|
1568
|
-
const
|
|
1569
|
-
if (!o.length) return
|
|
1570
|
-
const i = new Map(
|
|
1571
|
-
return a.length ? a :
|
|
1572
|
+
function zn(t, e) {
|
|
1573
|
+
const n = Array.isArray(t) ? t.filter((s) => !!(s && typeof s == "object" && !Array.isArray(s))) : [], r = te(e), o = Array.isArray(r.columns) ? r.columns.map(String) : [];
|
|
1574
|
+
if (!o.length) return n;
|
|
1575
|
+
const i = new Map(n.map((s) => [String(s.sku || s.id || ""), s])), a = o.map((s) => i.get(s)).filter((s) => !!s);
|
|
1576
|
+
return a.length ? a : n;
|
|
1572
1577
|
}
|
|
1573
|
-
function
|
|
1574
|
-
const
|
|
1578
|
+
function Qr(t, e) {
|
|
1579
|
+
const n = te(t?.table), r = zn(e, n);
|
|
1575
1580
|
return {
|
|
1576
1581
|
...t || {},
|
|
1577
|
-
table:
|
|
1578
|
-
products:
|
|
1579
|
-
multiple_product_details:
|
|
1582
|
+
table: n,
|
|
1583
|
+
products: r,
|
|
1584
|
+
multiple_product_details: r
|
|
1580
1585
|
};
|
|
1581
1586
|
}
|
|
1582
|
-
function
|
|
1587
|
+
function Dn(t) {
|
|
1583
1588
|
return !t || typeof t != "object" || Array.isArray(t) ? null : Object.fromEntries(Object.entries(t).filter(([, e]) => e !== void 0));
|
|
1584
1589
|
}
|
|
1585
|
-
function
|
|
1586
|
-
const
|
|
1590
|
+
function Yr(t = [], e = {}) {
|
|
1591
|
+
const n = {}, r = [];
|
|
1587
1592
|
return (Array.isArray(t) ? t.map((o) => gt(o, e)).filter((o) => !!o) : []).forEach((o, i) => {
|
|
1588
1593
|
const a = `product-${i.toString()}`;
|
|
1589
|
-
|
|
1594
|
+
r.push(a);
|
|
1590
1595
|
const s = {
|
|
1591
1596
|
sku: o.sku,
|
|
1592
1597
|
product: o
|
|
1593
1598
|
};
|
|
1594
|
-
|
|
1599
|
+
n[a] = {
|
|
1595
1600
|
type: "ProductCard",
|
|
1596
1601
|
props: {
|
|
1597
1602
|
product: o,
|
|
@@ -1603,20 +1608,20 @@ function Yn(t = [], e = {}) {
|
|
|
1603
1608
|
}
|
|
1604
1609
|
}
|
|
1605
1610
|
};
|
|
1606
|
-
}),
|
|
1611
|
+
}), n.root = {
|
|
1607
1612
|
type: "ProductGrid",
|
|
1608
1613
|
props: { layout: "grid" },
|
|
1609
|
-
children:
|
|
1614
|
+
children: r
|
|
1610
1615
|
}, {
|
|
1611
1616
|
widget: "chat",
|
|
1612
1617
|
panelHint: "panel",
|
|
1613
1618
|
spec: {
|
|
1614
1619
|
root: "root",
|
|
1615
|
-
elements:
|
|
1620
|
+
elements: n
|
|
1616
1621
|
}
|
|
1617
1622
|
};
|
|
1618
1623
|
}
|
|
1619
|
-
function
|
|
1624
|
+
function Wr(t, e = {}) {
|
|
1620
1625
|
return {
|
|
1621
1626
|
widget: "chat",
|
|
1622
1627
|
panelHint: "panel",
|
|
@@ -1629,8 +1634,8 @@ function Wn(t, e = {}) {
|
|
|
1629
1634
|
}
|
|
1630
1635
|
};
|
|
1631
1636
|
}
|
|
1632
|
-
function
|
|
1633
|
-
const
|
|
1637
|
+
function Xr(t = {}, e = {}) {
|
|
1638
|
+
const n = (t.multiple_product_details || t.products || []).map((o) => gt(o, e)).filter((o) => !!o), r = t.table || Vn(t.comparison_table);
|
|
1634
1639
|
return {
|
|
1635
1640
|
widget: "chat",
|
|
1636
1641
|
panelHint: "panel",
|
|
@@ -1639,16 +1644,16 @@ function Xn(t = {}, e = {}) {
|
|
|
1639
1644
|
elements: { root: {
|
|
1640
1645
|
type: "ComparisonTable",
|
|
1641
1646
|
props: {
|
|
1642
|
-
products:
|
|
1643
|
-
recommended:
|
|
1644
|
-
attributes: Object.entries(
|
|
1647
|
+
products: n,
|
|
1648
|
+
recommended: n.find((o) => o.sku === t.recommended_choice_sku) || n[0],
|
|
1649
|
+
attributes: Object.entries(r).map(([o, i]) => ({
|
|
1645
1650
|
label: o,
|
|
1646
1651
|
values: Array.isArray(i) ? i.map(String) : [String(i ?? "")]
|
|
1647
1652
|
})),
|
|
1648
1653
|
highlights: Lt(t.key_differences),
|
|
1649
1654
|
specialCases: Lt(t.special_considerations),
|
|
1650
1655
|
recommendedText: t.recommended_choice,
|
|
1651
|
-
productActions: Object.fromEntries(
|
|
1656
|
+
productActions: Object.fromEntries(n.map((o) => [o.sku, {
|
|
1652
1657
|
title: o.name,
|
|
1653
1658
|
type: "launchSingleProduct",
|
|
1654
1659
|
payload: {
|
|
@@ -1661,10 +1666,10 @@ function Xn(t = {}, e = {}) {
|
|
|
1661
1666
|
}
|
|
1662
1667
|
};
|
|
1663
1668
|
}
|
|
1664
|
-
function
|
|
1669
|
+
function Vn(t) {
|
|
1665
1670
|
return Array.isArray(t) ? Object.fromEntries(t.map((e) => {
|
|
1666
|
-
const
|
|
1667
|
-
return
|
|
1671
|
+
const n = typeof e?.label == "string" ? e.label.trim() : "";
|
|
1672
|
+
return n ? [n, e.values] : null;
|
|
1668
1673
|
}).filter((e) => !!e)) : {};
|
|
1669
1674
|
}
|
|
1670
1675
|
function to(t = []) {
|
|
@@ -1676,13 +1681,13 @@ function to(t = []) {
|
|
|
1676
1681
|
elements: { root: {
|
|
1677
1682
|
type: "ActionButtons",
|
|
1678
1683
|
props: { buttons: (Array.isArray(t) ? t : []).map((e) => {
|
|
1679
|
-
const
|
|
1680
|
-
return !
|
|
1681
|
-
label:
|
|
1684
|
+
const n = e.label || e.title || e.shortName || "", r = e.action || e.requestDetails || e.request_details;
|
|
1685
|
+
return !n || !r?.type ? null : {
|
|
1686
|
+
label: n,
|
|
1682
1687
|
action: {
|
|
1683
|
-
title:
|
|
1684
|
-
type:
|
|
1685
|
-
...
|
|
1688
|
+
title: n,
|
|
1689
|
+
type: r.type,
|
|
1690
|
+
...r.payload !== void 0 ? { payload: r.payload } : {}
|
|
1686
1691
|
}
|
|
1687
1692
|
};
|
|
1688
1693
|
}).filter((e) => !!e) }
|
|
@@ -1693,20 +1698,20 @@ function to(t = []) {
|
|
|
1693
1698
|
function eo(t) {
|
|
1694
1699
|
return Object.freeze([...t]);
|
|
1695
1700
|
}
|
|
1696
|
-
function
|
|
1701
|
+
function Kn(t) {
|
|
1697
1702
|
const e = t?.payload;
|
|
1698
1703
|
if (typeof e == "string") return e;
|
|
1699
1704
|
if (e && typeof e == "object" && "text" in e) {
|
|
1700
|
-
const
|
|
1701
|
-
if (typeof
|
|
1705
|
+
const r = e.text;
|
|
1706
|
+
if (typeof r == "string") return r;
|
|
1702
1707
|
}
|
|
1703
|
-
const
|
|
1704
|
-
return
|
|
1708
|
+
const n = t?.action;
|
|
1709
|
+
return n && typeof n.payload == "string" ? n.payload : n && typeof n.title == "string" ? n.title : "";
|
|
1705
1710
|
}
|
|
1706
1711
|
var ee = [
|
|
1707
1712
|
{
|
|
1708
1713
|
pattern: /\bhttps?:\/\/[^\s?#]+(?:\?[^\s#]*)?/giu,
|
|
1709
|
-
replacement:
|
|
1714
|
+
replacement: Zn
|
|
1710
1715
|
},
|
|
1711
1716
|
{
|
|
1712
1717
|
pattern: /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/giu,
|
|
@@ -1724,19 +1729,19 @@ var ee = [
|
|
|
1724
1729
|
pattern: /\b(?:order|cart|session)[_-]?(?:id|no|number)?\s*[:#=]?\s*[A-Z0-9-]{6,}\b/giu,
|
|
1725
1730
|
replacement: "[secret]"
|
|
1726
1731
|
}
|
|
1727
|
-
],
|
|
1728
|
-
function
|
|
1729
|
-
let
|
|
1730
|
-
for (const
|
|
1731
|
-
const o =
|
|
1732
|
-
|
|
1732
|
+
], ne = { patterns: ee };
|
|
1733
|
+
function re(t, e = ne) {
|
|
1734
|
+
let n = typeof t == "string" ? t : t == null ? "" : String(t);
|
|
1735
|
+
for (const r of e.patterns || []) {
|
|
1736
|
+
const o = r.replacement;
|
|
1737
|
+
n = typeof o == "function" ? n.replace(r.pattern, (i) => o(i)) : n.replace(r.pattern, o);
|
|
1733
1738
|
}
|
|
1734
|
-
return
|
|
1739
|
+
return n;
|
|
1735
1740
|
}
|
|
1736
|
-
function
|
|
1737
|
-
return
|
|
1741
|
+
function Jn(t, e = ne) {
|
|
1742
|
+
return re(Kn(t), e);
|
|
1738
1743
|
}
|
|
1739
|
-
function
|
|
1744
|
+
function Zn(t) {
|
|
1740
1745
|
try {
|
|
1741
1746
|
const e = new URL(t);
|
|
1742
1747
|
return `${e.origin}${e.pathname}${e.search ? "?[query]" : ""}`;
|
|
@@ -1744,65 +1749,65 @@ function Jr(t) {
|
|
|
1744
1749
|
return "[url]";
|
|
1745
1750
|
}
|
|
1746
1751
|
}
|
|
1747
|
-
var
|
|
1752
|
+
var Hn = [
|
|
1748
1753
|
"assistantName",
|
|
1749
1754
|
"homeDomain",
|
|
1750
1755
|
"categories",
|
|
1751
1756
|
"policyTopics"
|
|
1752
|
-
],
|
|
1753
|
-
function
|
|
1754
|
-
const o =
|
|
1757
|
+
], Gn = { intent: ["searchContract", "competitorBrands"] };
|
|
1758
|
+
function no(t, e, n, r = {}) {
|
|
1759
|
+
const o = Qn(e, n, r);
|
|
1755
1760
|
return Object.keys(o).length ? {
|
|
1756
1761
|
...t,
|
|
1757
1762
|
account_config: o
|
|
1758
1763
|
} : t;
|
|
1759
1764
|
}
|
|
1760
|
-
function
|
|
1765
|
+
function Qn(t, e, n = {}) {
|
|
1761
1766
|
if (!t) return {};
|
|
1762
|
-
const
|
|
1763
|
-
for (const s of o) Ft(
|
|
1767
|
+
const r = {}, o = n.baseKeys || Hn;
|
|
1768
|
+
for (const s of o) Ft(r, t, s);
|
|
1764
1769
|
const i = t[e];
|
|
1765
|
-
i && typeof i == "object" && !Array.isArray(i) && Object.assign(
|
|
1766
|
-
const a =
|
|
1767
|
-
for (const s of a[e] || []) Ft(
|
|
1768
|
-
return
|
|
1770
|
+
i && typeof i == "object" && !Array.isArray(i) && Object.assign(r, Yn(i));
|
|
1771
|
+
const a = n.opAllowlist || Gn;
|
|
1772
|
+
for (const s of a[e] || []) Ft(r, t, s);
|
|
1773
|
+
return r;
|
|
1769
1774
|
}
|
|
1770
|
-
function Ft(t, e,
|
|
1771
|
-
e[
|
|
1775
|
+
function Ft(t, e, n) {
|
|
1776
|
+
e[n] !== void 0 && (t[n] = e[n]);
|
|
1772
1777
|
}
|
|
1773
|
-
function
|
|
1778
|
+
function Yn(t) {
|
|
1774
1779
|
return Object.fromEntries(Object.entries(t).filter(([, e]) => e !== void 0));
|
|
1775
1780
|
}
|
|
1776
|
-
var
|
|
1777
|
-
function
|
|
1781
|
+
var Wn = "input-hash";
|
|
1782
|
+
function Xn({ ttlS: t, promptVersion: e = "current" } = {}) {
|
|
1778
1783
|
if (!Number.isFinite(t) || t <= 0) throw new Error("inputHashCachePolicy requires a positive ttlS");
|
|
1779
1784
|
return {
|
|
1780
|
-
strategy:
|
|
1785
|
+
strategy: Wn,
|
|
1781
1786
|
ttlS: t,
|
|
1782
1787
|
promptVersion: e
|
|
1783
1788
|
};
|
|
1784
1789
|
}
|
|
1785
|
-
function
|
|
1790
|
+
function tr({ accountId: t = "", op: e, ttlS: n, promptVersion: r = "current", input: o, keyParts: i, locale: a } = {}) {
|
|
1786
1791
|
if (!e) throw new Error("declarativeBeOpCache requires an op");
|
|
1787
1792
|
return {
|
|
1788
|
-
cache:
|
|
1789
|
-
ttlS:
|
|
1790
|
-
promptVersion:
|
|
1793
|
+
cache: Xn({
|
|
1794
|
+
ttlS: n,
|
|
1795
|
+
promptVersion: r
|
|
1791
1796
|
}),
|
|
1792
|
-
cacheTtlS:
|
|
1797
|
+
cacheTtlS: n,
|
|
1793
1798
|
cacheKey: (s = {}) => Ht(e, {
|
|
1794
1799
|
account: t,
|
|
1795
1800
|
locale: at(a, s) || s.context?.meta?.locale || s.locale || "",
|
|
1796
|
-
promptVersion:
|
|
1801
|
+
promptVersion: r,
|
|
1797
1802
|
payload: ut(at(o, s)),
|
|
1798
|
-
...
|
|
1803
|
+
...er(at(i, s))
|
|
1799
1804
|
})
|
|
1800
1805
|
};
|
|
1801
1806
|
}
|
|
1802
|
-
function
|
|
1807
|
+
function ro(t, e = {}) {
|
|
1803
1808
|
return !t || t.kind !== "be_op" ? t : {
|
|
1804
1809
|
...t,
|
|
1805
|
-
...
|
|
1810
|
+
...tr({
|
|
1806
1811
|
op: t.op,
|
|
1807
1812
|
ttlS: t.cacheTtlS,
|
|
1808
1813
|
input: t.input,
|
|
@@ -1814,9 +1819,9 @@ function at(t, e) {
|
|
|
1814
1819
|
return typeof t == "function" ? t(e) : t;
|
|
1815
1820
|
}
|
|
1816
1821
|
function ut(t) {
|
|
1817
|
-
return Array.isArray(t) ? t.map(ut) : !t || typeof t != "object" ? t : Object.fromEntries(Object.entries(t).filter(([, e]) => e !== void 0).sort(([e], [
|
|
1822
|
+
return Array.isArray(t) ? t.map(ut) : !t || typeof t != "object" ? t : Object.fromEntries(Object.entries(t).filter(([, e]) => e !== void 0).sort(([e], [n]) => e.localeCompare(n)).map(([e, n]) => [e, ut(n)]));
|
|
1818
1823
|
}
|
|
1819
|
-
function
|
|
1824
|
+
function er(t) {
|
|
1820
1825
|
return !t || typeof t != "object" || Array.isArray(t) ? {} : Object.fromEntries(Object.entries(t).filter(([, e]) => e != null));
|
|
1821
1826
|
}
|
|
1822
1827
|
var oo = Object.freeze({
|
|
@@ -1841,7 +1846,7 @@ function so(t) {
|
|
|
1841
1846
|
name: "readPage",
|
|
1842
1847
|
input: () => ({}),
|
|
1843
1848
|
out: "page",
|
|
1844
|
-
patch: (
|
|
1849
|
+
patch: (n, r) => r?.product && typeof t == "function" ? t(n, r.product) : null,
|
|
1845
1850
|
onError: []
|
|
1846
1851
|
}];
|
|
1847
1852
|
};
|
|
@@ -1868,19 +1873,19 @@ function uo(t, { screenSummary: e } = {}) {
|
|
|
1868
1873
|
ui_hints: null
|
|
1869
1874
|
} };
|
|
1870
1875
|
}
|
|
1871
|
-
function
|
|
1876
|
+
function nr({ patterns: t, messageFilter: e, messageNormalizer: n = (o) => o, messageLimit: r = 10 } = {}) {
|
|
1872
1877
|
const o = { patterns: [...ee, ...Array.isArray(t) ? t : []] };
|
|
1873
1878
|
function i(c) {
|
|
1874
|
-
return
|
|
1879
|
+
return re(c, o);
|
|
1875
1880
|
}
|
|
1876
1881
|
function a(c) {
|
|
1877
|
-
return
|
|
1882
|
+
return Jn(c, o);
|
|
1878
1883
|
}
|
|
1879
1884
|
function s(c = []) {
|
|
1880
1885
|
const l = (Array.isArray(c) ? c : []).filter((u) => typeof e == "function" ? e(u) : u && typeof u == "object").filter(Boolean);
|
|
1881
|
-
return (Number.isFinite(
|
|
1886
|
+
return (Number.isFinite(r) && r > 0 ? l.slice(-r) : l).map((u) => ({
|
|
1882
1887
|
role: u.role,
|
|
1883
|
-
content: i(
|
|
1888
|
+
content: i(n(u.content)).slice(0, 1e3)
|
|
1884
1889
|
}));
|
|
1885
1890
|
}
|
|
1886
1891
|
return {
|
|
@@ -1911,29 +1916,29 @@ var k = {
|
|
|
1911
1916
|
delivery: /\b(?:delivery|shipping|cargo|stock|availability|teslimat|kargo|stok|gonderim|gönderim)\b/iu,
|
|
1912
1917
|
promotion: /\b(?:campaign|promotion|discount|coupon|deal|kampanya|indirim|kupon|firsat|fırsat)\b/iu,
|
|
1913
1918
|
variant: /\b(?:variant|size|colour|color|beden|olcu|ölçü|renk|numara)\b/iu
|
|
1914
|
-
},
|
|
1915
|
-
function fo({ accountId: t, getPageType: e, getProduct:
|
|
1916
|
-
return (i = {}) =>
|
|
1919
|
+
}, rr = /[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}|\+?\d[\d\s().-]{8,}\d|\b[A-Z]{1,2}\d[A-Z\d]?\s*\d[A-Z]{2}\b|\b(?:token|session|csrf|secret)\s*[:=]\s*[\w.-]+/giu, or = /(?:token|session|sid|auth|code|csrf|secret|key|password|passwd|phone|email|address|postcode|zip|jwt|bearer)/iu, ir = /[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}|\+?\d[\d\s().-]{8,}\d|[A-Z]{1,2}\d[A-Z\d]?\s*\d[A-Z]{2}|[A-Za-z0-9_-]{24,}/iu;
|
|
1920
|
+
function fo({ accountId: t, getPageType: e, getProduct: n, getProducts: r, normalizeProduct: o = (i) => i }) {
|
|
1921
|
+
return (i = {}) => ar({
|
|
1917
1922
|
accountId: t,
|
|
1918
1923
|
getPageType: e,
|
|
1919
|
-
getProduct:
|
|
1920
|
-
getProducts:
|
|
1924
|
+
getProduct: n,
|
|
1925
|
+
getProducts: r,
|
|
1921
1926
|
normalizeProduct: o,
|
|
1922
1927
|
input: i
|
|
1923
1928
|
});
|
|
1924
1929
|
}
|
|
1925
|
-
function
|
|
1926
|
-
const a =
|
|
1930
|
+
function ar({ accountId: t, getPageType: e, getProduct: n, getProducts: r, normalizeProduct: o = (a) => a, input: i = {} }) {
|
|
1931
|
+
const a = Or(i), s = o(i.product || st(n)), c = (st(r) || []).map(o).filter(Boolean), l = b(i.sku || s?.sku || i.product?.sku), u = l ? c.find((tt) => b(tt?.sku) === l) || s : s || c[0] || null, f = ur(l || u?.sku), p = Ut({
|
|
1927
1932
|
...f.product,
|
|
1928
1933
|
...u
|
|
1929
|
-
}), m = jt(J(u?.features), J(u?.specs),
|
|
1934
|
+
}), m = jt(J(u?.features), J(u?.specs), Ar(u?.facet_hits), J(f.product?.features), fr(), dr(), pr()).slice(0, a.features), g = ie(W(u?.reviews), f.reviews, mr()).slice(0, a.reviews), _ = ae(xt(u?.qna), yr()).slice(0, a.qna), C = se(St(u?.sellers), gr()).slice(0, a.sellers), P = B([...u?.payment || [], ...K("payment", a)]), O = B([...u?.delivery || [], ...K("delivery", a)]), Ct = B([...u?.promotions || [], ...K("promotion", a)]), Et = ce(vt(u?.variants), hr()).slice(0, a.variants), It = br(a.documents), Tt = le(u?.description, f.product?.description, wr("description"), K("description", {
|
|
1930
1935
|
...a,
|
|
1931
1936
|
textBlocks: 2
|
|
1932
|
-
})[0]), Pt = c.filter((tt) => !l ||
|
|
1937
|
+
})[0]), Pt = c.filter((tt) => !l || b(tt?.sku) !== l).map(Ut).filter(Boolean).slice(0, a.relatedProducts);
|
|
1933
1938
|
return L({
|
|
1934
1939
|
accountId: t,
|
|
1935
1940
|
pageType: st(e) || "other",
|
|
1936
|
-
url:
|
|
1941
|
+
url: Pr(),
|
|
1937
1942
|
product: p,
|
|
1938
1943
|
description: Tt,
|
|
1939
1944
|
features: m,
|
|
@@ -1948,7 +1953,7 @@ function an({ accountId: t, getPageType: e, getProduct: r, getProducts: n, norma
|
|
|
1948
1953
|
variants: Et,
|
|
1949
1954
|
documents: It,
|
|
1950
1955
|
related_products: Pt,
|
|
1951
|
-
capabilities:
|
|
1956
|
+
capabilities: Cr({
|
|
1952
1957
|
description: Tt,
|
|
1953
1958
|
features: m,
|
|
1954
1959
|
sellers: C,
|
|
@@ -1972,118 +1977,118 @@ function an({ accountId: t, getPageType: e, getProduct: r, getProducts: n, norma
|
|
|
1972
1977
|
});
|
|
1973
1978
|
}
|
|
1974
1979
|
function po(t, e) {
|
|
1975
|
-
const
|
|
1976
|
-
if (!e || typeof e != "object" || !
|
|
1977
|
-
const
|
|
1978
|
-
return
|
|
1979
|
-
const a =
|
|
1980
|
-
return
|
|
1980
|
+
const n = Array.isArray(t) ? t.filter(Boolean) : [];
|
|
1981
|
+
if (!e || typeof e != "object" || !n.length) return n;
|
|
1982
|
+
const r = b(e.product?.sku);
|
|
1983
|
+
return n.map((o, i) => {
|
|
1984
|
+
const a = b(o?.sku);
|
|
1985
|
+
return n.length === 1 || r && a && r === a || i === 0 ? cr(o, e) : o;
|
|
1981
1986
|
});
|
|
1982
1987
|
}
|
|
1983
|
-
function
|
|
1988
|
+
function sr(t) {
|
|
1984
1989
|
return !t || typeof t != "object" ? null : L({
|
|
1985
1990
|
product: t.product,
|
|
1986
1991
|
description: y(t.description, 500),
|
|
1987
|
-
features:
|
|
1988
|
-
sellers:
|
|
1989
|
-
reviews:
|
|
1990
|
-
qna:
|
|
1992
|
+
features: _r(t.features, 14),
|
|
1993
|
+
sellers: vr(t.sellers, 4),
|
|
1994
|
+
reviews: xr(t.reviews, 4),
|
|
1995
|
+
qna: Sr(t.qna, 4),
|
|
1991
1996
|
rating: t.rating,
|
|
1992
1997
|
review_count: t.review_count,
|
|
1993
1998
|
payment: I(t.payment, 5, 160),
|
|
1994
1999
|
delivery: I(t.delivery, 5, 160),
|
|
1995
2000
|
promotions: I(t.promotions, 5, 160),
|
|
1996
|
-
variants:
|
|
2001
|
+
variants: jr(t.variants, 10),
|
|
1997
2002
|
documents: I(t.documents, 5, 220),
|
|
1998
2003
|
capabilities: Array.isArray(t.capabilities) ? t.capabilities.slice(0, 12) : void 0
|
|
1999
2004
|
});
|
|
2000
2005
|
}
|
|
2001
|
-
function mo(t, e,
|
|
2002
|
-
const
|
|
2003
|
-
if (!
|
|
2004
|
-
const o = String(
|
|
2005
|
-
return a && i.push(o ? `Visible rating: ${a}.` : `Görünür puan bilgisi: ${a}.`),
|
|
2006
|
+
function mo(t, e, n = {}) {
|
|
2007
|
+
const r = sr(t);
|
|
2008
|
+
if (!r) return e;
|
|
2009
|
+
const o = String(n.locale || "").toLowerCase().startsWith("en"), i = [], a = [r.rating ? `${r.rating}/5` : "", r.review_count ? `${r.review_count} ${o ? "reviews" : "yorum"}` : ""].filter(Boolean).join(", ");
|
|
2010
|
+
return a && i.push(o ? `Visible rating: ${a}.` : `Görünür puan bilgisi: ${a}.`), r.reviews?.length && i.push(`${o ? "Visible review highlights" : "Görünür yorumlardan öne çıkanlar"}: ${r.reviews.map((s) => [s.star ? `${s.star}/5` : "", s.content].filter(Boolean).join(" ")).filter(Boolean).slice(0, 3).join(" | ")}.`), i.length ? (i.push(o ? "This summary only uses product review and rating fields visible in the browser." : "Bu özet yalnızca tarayıcıda görünen ürün yorumu ve puan alanlarından hazırlandı."), i.join(" ")) : e;
|
|
2006
2011
|
}
|
|
2007
|
-
function
|
|
2012
|
+
function cr(t, e) {
|
|
2008
2013
|
return L({
|
|
2009
2014
|
...t,
|
|
2010
2015
|
description: le(t.description, e.description),
|
|
2011
2016
|
features: jt(J(t.features), e.features).slice(0, 24),
|
|
2012
|
-
specs: t.specs || (e.features?.length ? Object.fromEntries(e.features.map(
|
|
2017
|
+
specs: t.specs || (e.features?.length ? Object.fromEntries(e.features.map(Er)) : void 0),
|
|
2013
2018
|
sellers: se(St(t.sellers), e.sellers),
|
|
2014
2019
|
reviews: ie(W(t.reviews), e.reviews),
|
|
2015
2020
|
qna: ae(xt(t.qna), e.qna),
|
|
2016
2021
|
rating: t.rating ?? e.rating,
|
|
2017
2022
|
review_count: t.review_count ?? e.review_count,
|
|
2018
|
-
payment:
|
|
2019
|
-
delivery:
|
|
2020
|
-
promotions:
|
|
2023
|
+
payment: B([...t.payment || [], ...e.payment || []]),
|
|
2024
|
+
delivery: B([...t.delivery || [], ...e.delivery || []]),
|
|
2025
|
+
promotions: B([...t.promotions || [], ...e.promotions || []]),
|
|
2021
2026
|
variants: ce(vt(t.variants), e.variants),
|
|
2022
|
-
documents:
|
|
2027
|
+
documents: B([...t.documents || [], ...e.documents || []])
|
|
2023
2028
|
});
|
|
2024
2029
|
}
|
|
2025
|
-
function
|
|
2030
|
+
function ur(t) {
|
|
2026
2031
|
const e = [];
|
|
2027
2032
|
for (const o of x('script[type="application/ld+json"]')) {
|
|
2028
|
-
const i =
|
|
2033
|
+
const i = lr(o.textContent);
|
|
2029
2034
|
for (const a of lt(i))
|
|
2030
2035
|
String(a?.["@type"] || "").toLowerCase() === "product" && e.push(a);
|
|
2031
2036
|
}
|
|
2032
|
-
const
|
|
2033
|
-
if (!
|
|
2034
|
-
const
|
|
2037
|
+
const n = e.find((o) => b(o.sku || o.productID || o.mpn) === b(t)) || e[0];
|
|
2038
|
+
if (!n) return {};
|
|
2039
|
+
const r = n.aggregateRating || {};
|
|
2035
2040
|
return {
|
|
2036
2041
|
product: L({
|
|
2037
|
-
sku:
|
|
2038
|
-
name: d(
|
|
2039
|
-
brand: d(
|
|
2040
|
-
description: d(
|
|
2041
|
-
images: I(
|
|
2042
|
-
url: D(
|
|
2043
|
-
rating: A(
|
|
2044
|
-
review_count: A(
|
|
2042
|
+
sku: b(n.sku || n.productID || n.mpn),
|
|
2043
|
+
name: d(n.name),
|
|
2044
|
+
brand: d(n.brand?.name || n.brand),
|
|
2045
|
+
description: d(n.description),
|
|
2046
|
+
images: I(n.image, 8, 280),
|
|
2047
|
+
url: D(n.url),
|
|
2048
|
+
rating: A(r.ratingValue),
|
|
2049
|
+
review_count: A(r.reviewCount || r.ratingCount)
|
|
2045
2050
|
}),
|
|
2046
|
-
reviews: W(
|
|
2047
|
-
rating: A(
|
|
2048
|
-
review_count: A(
|
|
2051
|
+
reviews: W(n.review),
|
|
2052
|
+
rating: A(r.ratingValue),
|
|
2053
|
+
review_count: A(r.reviewCount || r.ratingCount)
|
|
2049
2054
|
};
|
|
2050
2055
|
}
|
|
2051
2056
|
function lt(t) {
|
|
2052
2057
|
return Array.isArray(t) ? t.flatMap(lt) : !t || typeof t != "object" ? [] : [t, ...lt(t["@graph"])];
|
|
2053
2058
|
}
|
|
2054
|
-
function
|
|
2059
|
+
function lr(t) {
|
|
2055
2060
|
try {
|
|
2056
2061
|
return JSON.parse(String(t || ""));
|
|
2057
2062
|
} catch {
|
|
2058
2063
|
return null;
|
|
2059
2064
|
}
|
|
2060
2065
|
}
|
|
2061
|
-
function
|
|
2066
|
+
function fr() {
|
|
2062
2067
|
const t = [];
|
|
2063
2068
|
for (const e of x("table tr")) {
|
|
2064
|
-
const
|
|
2065
|
-
|
|
2066
|
-
key:
|
|
2067
|
-
value:
|
|
2069
|
+
const n = [...e.querySelectorAll?.("th,td") || []].map((r) => d(r.textContent));
|
|
2070
|
+
n.length >= 2 && n[0] && n[1] && t.push({
|
|
2071
|
+
key: n[0],
|
|
2072
|
+
value: n.slice(1).join(" ")
|
|
2068
2073
|
});
|
|
2069
2074
|
}
|
|
2070
2075
|
return t;
|
|
2071
2076
|
}
|
|
2072
|
-
function
|
|
2077
|
+
function dr() {
|
|
2073
2078
|
const t = [];
|
|
2074
2079
|
for (const e of x("dt")) {
|
|
2075
|
-
const
|
|
2076
|
-
|
|
2077
|
-
key:
|
|
2078
|
-
value:
|
|
2080
|
+
const n = d(e.textContent), r = d(e.nextElementSibling?.matches?.("dd") ? e.nextElementSibling.textContent : "");
|
|
2081
|
+
n && r && t.push({
|
|
2082
|
+
key: n,
|
|
2083
|
+
value: r
|
|
2079
2084
|
});
|
|
2080
2085
|
}
|
|
2081
2086
|
return t;
|
|
2082
2087
|
}
|
|
2083
|
-
function
|
|
2088
|
+
function pr() {
|
|
2084
2089
|
return x('[class*="spec" i], [class*="feature" i], [class*="attribute" i], li').map((t) => oe(d(t.textContent))).filter(Boolean).slice(0, k.features);
|
|
2085
2090
|
}
|
|
2086
|
-
function
|
|
2091
|
+
function mr() {
|
|
2087
2092
|
return x('[class*="review" i], [data-review], [itemprop="review"]').map((t) => {
|
|
2088
2093
|
const e = d(t.textContent);
|
|
2089
2094
|
return !e || e.length < 8 || _t.qna.test(e) ? null : {
|
|
@@ -2092,12 +2097,12 @@ function mn() {
|
|
|
2092
2097
|
};
|
|
2093
2098
|
}).filter(Boolean);
|
|
2094
2099
|
}
|
|
2095
|
-
function
|
|
2100
|
+
function yr() {
|
|
2096
2101
|
const t = x('[class*="question" i], [class*="answer" i], [data-question], [data-answer]'), e = [];
|
|
2097
|
-
for (const
|
|
2098
|
-
const
|
|
2099
|
-
if (!
|
|
2100
|
-
const o = d(
|
|
2102
|
+
for (const n of t) {
|
|
2103
|
+
const r = d(n.textContent);
|
|
2104
|
+
if (!r || !_t.qna.test(r)) continue;
|
|
2105
|
+
const o = d(n.getAttribute?.("data-question") || r), i = d(n.getAttribute?.("data-answer") || n.nextElementSibling?.textContent || "");
|
|
2101
2106
|
e.push({
|
|
2102
2107
|
question: y(o, 220),
|
|
2103
2108
|
answer: y(i, 260)
|
|
@@ -2105,50 +2110,50 @@ function yn() {
|
|
|
2105
2110
|
}
|
|
2106
2111
|
return e;
|
|
2107
2112
|
}
|
|
2108
|
-
function
|
|
2113
|
+
function gr() {
|
|
2109
2114
|
return x('[class*="seller" i], [class*="merchant" i], [data-seller], [data-merchant]').map((t) => d(t.getAttribute?.("data-seller") || t.getAttribute?.("data-merchant") || t.textContent)).filter(Boolean).map((t) => ({ merchant: y(t, 120) }));
|
|
2110
2115
|
}
|
|
2111
|
-
function
|
|
2116
|
+
function hr() {
|
|
2112
2117
|
return x('[class*="variant" i] a,[class*="variant" i] button,[class*="size" i] button,[class*="color" i] button,[data-variant],[data-size],[data-color]').map((t) => L({
|
|
2113
2118
|
name: y(fe(t), 120),
|
|
2114
2119
|
value: y(t.getAttribute?.("data-value") || t.getAttribute?.("data-size") || t.getAttribute?.("data-color"), 120),
|
|
2115
|
-
sku:
|
|
2120
|
+
sku: b(t.getAttribute?.("data-sku") || t.getAttribute?.("data-product-id")),
|
|
2116
2121
|
url: D(t.getAttribute?.("href")),
|
|
2117
2122
|
in_stock: t.getAttribute?.("disabled") == null && t.getAttribute?.("aria-disabled") !== "true"
|
|
2118
2123
|
})).filter((t) => t.name || t.value || t.sku);
|
|
2119
2124
|
}
|
|
2120
|
-
function
|
|
2125
|
+
function br(t) {
|
|
2121
2126
|
return x("a[href]").filter((e) => /\.pdf(?:$|[?#])/iu.test(e.getAttribute?.("href") || "")).map((e) => {
|
|
2122
|
-
const
|
|
2123
|
-
return
|
|
2127
|
+
const n = fe(e) || "PDF", r = D(e.getAttribute?.("href"));
|
|
2128
|
+
return r ? `${n}: ${r}` : "";
|
|
2124
2129
|
}).filter(Boolean).slice(0, t);
|
|
2125
2130
|
}
|
|
2126
2131
|
function K(t, e) {
|
|
2127
|
-
const
|
|
2128
|
-
return
|
|
2132
|
+
const n = _t[t];
|
|
2133
|
+
return n ? x("section,article,div,li,p,span,button,a").map((r) => d(r.textContent)).filter((r) => r && n.test(r) && r.length <= 900).map((r) => y(r, e.textChars || k.textChars)).filter(ue()).slice(0, e.textBlocks || k.textBlocks) : [];
|
|
2129
2134
|
}
|
|
2130
|
-
function
|
|
2135
|
+
function wr(t) {
|
|
2131
2136
|
return d(document.querySelector?.(`meta[name="${t}"]`)?.getAttribute?.("content") || document.querySelector?.(`meta[property="og:${t}"]`)?.getAttribute?.("content"));
|
|
2132
2137
|
}
|
|
2133
2138
|
function x(t) {
|
|
2134
2139
|
try {
|
|
2135
|
-
return [...document.querySelectorAll?.(t) || []].filter(
|
|
2140
|
+
return [...document.querySelectorAll?.(t) || []].filter(kr);
|
|
2136
2141
|
} catch {
|
|
2137
2142
|
return [];
|
|
2138
2143
|
}
|
|
2139
2144
|
}
|
|
2140
|
-
function
|
|
2145
|
+
function kr(t) {
|
|
2141
2146
|
if (!t) return !1;
|
|
2142
2147
|
if (!t.getBoundingClientRect) return !0;
|
|
2143
2148
|
const e = t.getBoundingClientRect();
|
|
2144
2149
|
if (e.width <= 0 || e.height <= 0) return !1;
|
|
2145
|
-
const
|
|
2146
|
-
return !
|
|
2150
|
+
const n = window.getComputedStyle?.(t);
|
|
2151
|
+
return !n || n.visibility !== "hidden" && n.display !== "none" && Number(n.opacity || 1) > 0;
|
|
2147
2152
|
}
|
|
2148
2153
|
function J(t) {
|
|
2149
|
-
return t ? (Array.isArray(t) ? t : Object.entries(t).map(([e,
|
|
2154
|
+
return t ? (Array.isArray(t) ? t : Object.entries(t).map(([e, n]) => ({
|
|
2150
2155
|
key: e,
|
|
2151
|
-
value:
|
|
2156
|
+
value: n
|
|
2152
2157
|
}))).map((e) => typeof e == "string" ? oe(e) || {
|
|
2153
2158
|
key: "",
|
|
2154
2159
|
value: d(e)
|
|
@@ -2157,10 +2162,10 @@ function J(t) {
|
|
|
2157
2162
|
value: d(e.value || e.text || "")
|
|
2158
2163
|
}).filter((e) => e.key || e.value) : [];
|
|
2159
2164
|
}
|
|
2160
|
-
function
|
|
2161
|
-
return !t || typeof t != "object" ? [] : Object.entries(t).map(([e,
|
|
2165
|
+
function Ar(t) {
|
|
2166
|
+
return !t || typeof t != "object" ? [] : Object.entries(t).map(([e, n]) => ({
|
|
2162
2167
|
key: d(e),
|
|
2163
|
-
value: d(
|
|
2168
|
+
value: d(n)
|
|
2164
2169
|
}));
|
|
2165
2170
|
}
|
|
2166
2171
|
function oe(t) {
|
|
@@ -2185,7 +2190,7 @@ function xt(t) {
|
|
|
2185
2190
|
function St(t) {
|
|
2186
2191
|
return (Array.isArray(t) ? t : t ? [t] : []).map((e) => typeof e == "string" ? { merchant: y(e, 120) } : {
|
|
2187
2192
|
merchant: y(e.merchant || e.name || e.seller || "", 120),
|
|
2188
|
-
merchant_id:
|
|
2193
|
+
merchant_id: b(e.merchant_id || e.id || ""),
|
|
2189
2194
|
merchant_rating: A(e.merchant_rating || e.rating),
|
|
2190
2195
|
price_offer: A(e.price_offer || e.price)
|
|
2191
2196
|
}).filter((e) => e.merchant || e.merchant_id);
|
|
@@ -2194,21 +2199,21 @@ function vt(t) {
|
|
|
2194
2199
|
return (Array.isArray(t) ? t : t ? [t] : []).map((e) => ({
|
|
2195
2200
|
name: y(e.name || e.label || e.title || "", 120),
|
|
2196
2201
|
value: y(e.value || e.size || e.color || "", 120),
|
|
2197
|
-
sku:
|
|
2202
|
+
sku: b(e.sku || e.code || ""),
|
|
2198
2203
|
url: D(e.url),
|
|
2199
2204
|
in_stock: e.in_stock
|
|
2200
2205
|
})).filter((e) => e.name || e.value || e.sku || e.url);
|
|
2201
2206
|
}
|
|
2202
2207
|
function jt(...t) {
|
|
2203
|
-
const e = /* @__PURE__ */ new Set(),
|
|
2204
|
-
for (const
|
|
2208
|
+
const e = /* @__PURE__ */ new Set(), n = [];
|
|
2209
|
+
for (const r of t.flat().filter(Boolean)) {
|
|
2205
2210
|
const o = {
|
|
2206
|
-
key: y(
|
|
2207
|
-
value: y(
|
|
2211
|
+
key: y(r.key || r.name || "", 90),
|
|
2212
|
+
value: y(r.value || r.text || "", 180)
|
|
2208
2213
|
}, i = `${o.key}:${o.value}`.toLocaleLowerCase("tr-TR");
|
|
2209
|
-
!o.key && !o.value || e.has(i) || (e.add(i),
|
|
2214
|
+
!o.key && !o.value || e.has(i) || (e.add(i), n.push(o));
|
|
2210
2215
|
}
|
|
2211
|
-
return
|
|
2216
|
+
return n;
|
|
2212
2217
|
}
|
|
2213
2218
|
function ie(...t) {
|
|
2214
2219
|
return X(t.flat().filter(Boolean), (e) => `${e.star || ""}:${e.content || ""}`);
|
|
@@ -2223,44 +2228,44 @@ function ce(...t) {
|
|
|
2223
2228
|
return X(t.flat().filter(Boolean), (e) => `${e.sku || ""}:${e.name || ""}:${e.value || ""}`);
|
|
2224
2229
|
}
|
|
2225
2230
|
function X(t, e) {
|
|
2226
|
-
const
|
|
2227
|
-
return t.filter((
|
|
2228
|
-
const o = e(
|
|
2229
|
-
return !o.trim() ||
|
|
2231
|
+
const n = /* @__PURE__ */ new Set();
|
|
2232
|
+
return t.filter((r) => {
|
|
2233
|
+
const o = e(r).toLocaleLowerCase("tr-TR");
|
|
2234
|
+
return !o.trim() || n.has(o) ? !1 : (n.add(o), !0);
|
|
2230
2235
|
});
|
|
2231
2236
|
}
|
|
2232
|
-
function
|
|
2237
|
+
function B(t) {
|
|
2233
2238
|
return I(t, 20, k.textChars);
|
|
2234
2239
|
}
|
|
2235
|
-
function I(t, e,
|
|
2236
|
-
return (Array.isArray(t) ? t : t ? [t] : []).map((
|
|
2240
|
+
function I(t, e, n) {
|
|
2241
|
+
return (Array.isArray(t) ? t : t ? [t] : []).map((r) => y(r, n)).filter(Boolean).filter(ue()).slice(0, e);
|
|
2237
2242
|
}
|
|
2238
2243
|
function ue() {
|
|
2239
2244
|
const t = /* @__PURE__ */ new Set();
|
|
2240
2245
|
return (e) => {
|
|
2241
|
-
const
|
|
2242
|
-
return !
|
|
2246
|
+
const n = d(e).toLocaleLowerCase("tr-TR");
|
|
2247
|
+
return !n || t.has(n) ? !1 : (t.add(n), !0);
|
|
2243
2248
|
};
|
|
2244
2249
|
}
|
|
2245
|
-
function
|
|
2250
|
+
function _r(t, e) {
|
|
2246
2251
|
return jt(t).slice(0, e);
|
|
2247
2252
|
}
|
|
2248
|
-
function
|
|
2253
|
+
function xr(t, e) {
|
|
2249
2254
|
return W(t).slice(0, e);
|
|
2250
2255
|
}
|
|
2251
|
-
function
|
|
2256
|
+
function Sr(t, e) {
|
|
2252
2257
|
return xt(t).slice(0, e);
|
|
2253
2258
|
}
|
|
2254
|
-
function
|
|
2259
|
+
function vr(t, e) {
|
|
2255
2260
|
return St(t).slice(0, e);
|
|
2256
2261
|
}
|
|
2257
|
-
function
|
|
2262
|
+
function jr(t, e) {
|
|
2258
2263
|
return vt(t).slice(0, e);
|
|
2259
2264
|
}
|
|
2260
2265
|
function Ut(t) {
|
|
2261
2266
|
return !t || typeof t != "object" ? null : L({
|
|
2262
|
-
sku:
|
|
2263
|
-
group_id:
|
|
2267
|
+
sku: b(t.sku || t.id || ""),
|
|
2268
|
+
group_id: b(t.group_id || t.groupId || ""),
|
|
2264
2269
|
name: d(t.name || t.title || ""),
|
|
2265
2270
|
brand: d(t.brand || ""),
|
|
2266
2271
|
url: D(t.url),
|
|
@@ -2269,12 +2274,12 @@ function Ut(t) {
|
|
|
2269
2274
|
price_discounted: A(t.price_discounted || t.discountedPrice),
|
|
2270
2275
|
price_text: d(t.price_text || t.priceText || ""),
|
|
2271
2276
|
price_currency: d(t.price_currency || t.currency || ""),
|
|
2272
|
-
category_ids:
|
|
2277
|
+
category_ids: Ir(t.category_ids || t.categoryIds, 8, 90),
|
|
2273
2278
|
category_names: I(t.category_names || t.categoryNames || t.category, 8, 140),
|
|
2274
2279
|
in_stock: t.in_stock
|
|
2275
2280
|
});
|
|
2276
2281
|
}
|
|
2277
|
-
function
|
|
2282
|
+
function Cr(t) {
|
|
2278
2283
|
return [
|
|
2279
2284
|
t.description ? "description" : "",
|
|
2280
2285
|
t.features?.length ? "features" : "",
|
|
@@ -2289,7 +2294,7 @@ function Cn(t) {
|
|
|
2289
2294
|
t.relatedProducts?.length ? "related_products" : ""
|
|
2290
2295
|
].filter(Boolean);
|
|
2291
2296
|
}
|
|
2292
|
-
function
|
|
2297
|
+
function Er(t) {
|
|
2293
2298
|
return [d(t.key || t.name), d(t.value || t.text)];
|
|
2294
2299
|
}
|
|
2295
2300
|
function le(...t) {
|
|
@@ -2302,20 +2307,20 @@ function fe(t) {
|
|
|
2302
2307
|
return d(t.getAttribute?.("aria-label") || t.getAttribute?.("title") || t.getAttribute?.("alt") || t.textContent);
|
|
2303
2308
|
}
|
|
2304
2309
|
function d(t) {
|
|
2305
|
-
return String(t ?? "").replace(/<script\b[\s\S]*?<\/script>/giu, " ").replace(/<style\b[\s\S]*?<\/style>/giu, " ").replace(/<[^>]+>/gu, " ").replace(
|
|
2310
|
+
return String(t ?? "").replace(/<script\b[\s\S]*?<\/script>/giu, " ").replace(/<style\b[\s\S]*?<\/style>/giu, " ").replace(/<[^>]+>/gu, " ").replace(rr, "[redacted]").replace(/\s+/gu, " ").trim();
|
|
2306
2311
|
}
|
|
2307
|
-
function
|
|
2312
|
+
function b(t) {
|
|
2308
2313
|
const e = String(t ?? "").replace(/<script\b[\s\S]*?<\/script>/giu, " ").replace(/<style\b[\s\S]*?<\/style>/giu, " ").replace(/<[^>]+>/gu, " ").replace(/\s+/gu, " ").trim();
|
|
2309
2314
|
return !e || /[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/iu.test(e) || /\b(?:token|session|csrf|secret|password|passwd|jwt|bearer)\s*[:=]\s*[\w.-]+/iu.test(e) ? "" : e.slice(0, 120);
|
|
2310
2315
|
}
|
|
2311
|
-
function
|
|
2312
|
-
return (Array.isArray(t) ? t : t ? [t] : []).map((
|
|
2316
|
+
function Ir(t, e, n) {
|
|
2317
|
+
return (Array.isArray(t) ? t : t ? [t] : []).map((r) => b(r).slice(0, n)).filter(Boolean).filter(Tr()).slice(0, e);
|
|
2313
2318
|
}
|
|
2314
|
-
function
|
|
2319
|
+
function Tr() {
|
|
2315
2320
|
const t = /* @__PURE__ */ new Set();
|
|
2316
2321
|
return (e) => {
|
|
2317
|
-
const
|
|
2318
|
-
return !
|
|
2322
|
+
const n = b(e).toLocaleLowerCase("tr-TR");
|
|
2323
|
+
return !n || t.has(n) ? !1 : (t.add(n), !0);
|
|
2319
2324
|
};
|
|
2320
2325
|
}
|
|
2321
2326
|
function A(t) {
|
|
@@ -2331,7 +2336,7 @@ function D(t) {
|
|
|
2331
2336
|
return "";
|
|
2332
2337
|
}
|
|
2333
2338
|
}
|
|
2334
|
-
function
|
|
2339
|
+
function Pr() {
|
|
2335
2340
|
try {
|
|
2336
2341
|
const t = new URL(window.location.href);
|
|
2337
2342
|
return t.hash = "", de(t), `${t.origin}${t.pathname}${t.search}`;
|
|
@@ -2340,13 +2345,13 @@ function Pn() {
|
|
|
2340
2345
|
}
|
|
2341
2346
|
}
|
|
2342
2347
|
function de(t) {
|
|
2343
|
-
for (const [e,
|
|
2344
|
-
const
|
|
2345
|
-
(
|
|
2348
|
+
for (const [e, n] of [...t.searchParams.entries()]) {
|
|
2349
|
+
const r = String(n || "");
|
|
2350
|
+
(or.test(e) || ir.test(r)) && t.searchParams.set(e, "redacted");
|
|
2346
2351
|
}
|
|
2347
2352
|
return t;
|
|
2348
2353
|
}
|
|
2349
|
-
function
|
|
2354
|
+
function Or(t = {}) {
|
|
2350
2355
|
return {
|
|
2351
2356
|
features: S(t.maxFeatures, k.features, 40),
|
|
2352
2357
|
reviews: S(t.maxReviews, k.reviews, 12),
|
|
@@ -2359,9 +2364,9 @@ function On(t = {}) {
|
|
|
2359
2364
|
textChars: S(t.textChars, k.textChars, 420)
|
|
2360
2365
|
};
|
|
2361
2366
|
}
|
|
2362
|
-
function S(t, e,
|
|
2363
|
-
const
|
|
2364
|
-
return !Number.isFinite(
|
|
2367
|
+
function S(t, e, n) {
|
|
2368
|
+
const r = Number(t);
|
|
2369
|
+
return !Number.isFinite(r) || r <= 0 ? e : Math.min(Math.floor(r), n);
|
|
2365
2370
|
}
|
|
2366
2371
|
function st(t) {
|
|
2367
2372
|
try {
|
|
@@ -2373,99 +2378,99 @@ function st(t) {
|
|
|
2373
2378
|
function L(t) {
|
|
2374
2379
|
return Object.fromEntries(Object.entries(t || {}).filter(([, e]) => e != null && e !== "" && (!Array.isArray(e) || e.length)));
|
|
2375
2380
|
}
|
|
2376
|
-
var { redactPii: yo, anonymousRequestText: go, anonymizeMessages: ho } =
|
|
2381
|
+
var { redactPii: yo, anonymousRequestText: go, anonymizeMessages: ho } = nr({ patterns: [{
|
|
2377
2382
|
pattern: /\b\d{5}\b/gu,
|
|
2378
2383
|
replacement: "[postcode]"
|
|
2379
2384
|
}, {
|
|
2380
2385
|
pattern: /\b(?:adresim|adres|mahalle|sokak|cadde)\b[^,.!?\n]{8,160}/giu,
|
|
2381
2386
|
replacement: "[address]"
|
|
2382
2387
|
}] });
|
|
2383
|
-
function
|
|
2388
|
+
function Br(t) {
|
|
2384
2389
|
return (t?.route?.flow_params && typeof t.route.flow_params == "object" ? t.route.flow_params : null) || (t?.route?.flowParams && typeof t.route.flowParams == "object" ? t.route.flowParams : null) || {};
|
|
2385
2390
|
}
|
|
2386
|
-
function
|
|
2391
|
+
function bo(t) {
|
|
2387
2392
|
return Array.isArray(t) ? t.find((e) => String(e || "").trim()) : void 0;
|
|
2388
2393
|
}
|
|
2389
|
-
function
|
|
2390
|
-
const e =
|
|
2394
|
+
function wo(t) {
|
|
2395
|
+
const e = Br(t);
|
|
2391
2396
|
return [
|
|
2392
2397
|
...e.sku ? [e.sku] : [],
|
|
2393
2398
|
...Array.isArray(e.sku_list) ? e.sku_list : [],
|
|
2394
2399
|
...Array.isArray(e.skus) ? e.skus : [],
|
|
2395
2400
|
...Array.isArray(e.target_skus) ? e.target_skus : []
|
|
2396
|
-
].map((
|
|
2401
|
+
].map((n) => String(n || "").trim()).filter(Boolean).filter((n, r, o) => o.indexOf(n) === r);
|
|
2397
2402
|
}
|
|
2398
2403
|
export {
|
|
2399
|
-
|
|
2404
|
+
Fr as $,
|
|
2400
2405
|
eo as A,
|
|
2401
|
-
|
|
2402
|
-
|
|
2406
|
+
Zr as B,
|
|
2407
|
+
Qn as C,
|
|
2403
2408
|
ee as D,
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2409
|
+
ne as E,
|
|
2410
|
+
zn as F,
|
|
2411
|
+
Jr as G,
|
|
2412
|
+
Kr as H,
|
|
2413
|
+
Qr as I,
|
|
2414
|
+
Dr as J,
|
|
2410
2415
|
gt as K,
|
|
2411
2416
|
te as L,
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2417
|
+
Xr as M,
|
|
2418
|
+
Wr as N,
|
|
2419
|
+
re as O,
|
|
2420
|
+
Yr as P,
|
|
2421
|
+
cn as Q,
|
|
2422
|
+
Gr as R,
|
|
2423
|
+
ro as S,
|
|
2424
|
+
Jn as T,
|
|
2425
|
+
Vr as U,
|
|
2421
2426
|
Ht as V,
|
|
2422
2427
|
Gt as W,
|
|
2423
|
-
|
|
2424
|
-
|
|
2428
|
+
zr as X,
|
|
2429
|
+
un as Y,
|
|
2425
2430
|
Jt as Z,
|
|
2426
2431
|
oo as _,
|
|
2427
2432
|
ge as _t,
|
|
2428
2433
|
go as a,
|
|
2429
|
-
|
|
2430
|
-
|
|
2434
|
+
Nr as at,
|
|
2435
|
+
tr as b,
|
|
2431
2436
|
fo as c,
|
|
2432
2437
|
Ge as ct,
|
|
2433
2438
|
mo as d,
|
|
2434
2439
|
v as dt,
|
|
2435
|
-
|
|
2436
|
-
|
|
2440
|
+
sn as et,
|
|
2441
|
+
nr as f,
|
|
2437
2442
|
Le as ft,
|
|
2438
2443
|
so as g,
|
|
2439
2444
|
$e as gt,
|
|
2440
2445
|
co as h,
|
|
2441
|
-
$
|
|
2446
|
+
$r as ht,
|
|
2442
2447
|
ho as i,
|
|
2443
2448
|
Kt as it,
|
|
2444
2449
|
to as j,
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2450
|
+
Kn as k,
|
|
2451
|
+
ar as l,
|
|
2452
|
+
Lr as lt,
|
|
2448
2453
|
uo as m,
|
|
2449
2454
|
Se as mt,
|
|
2450
|
-
|
|
2451
|
-
|
|
2455
|
+
Br as n,
|
|
2456
|
+
qr as nt,
|
|
2452
2457
|
yo as o,
|
|
2453
|
-
|
|
2458
|
+
tn as ot,
|
|
2454
2459
|
lo as p,
|
|
2455
|
-
|
|
2460
|
+
Rr as pt,
|
|
2456
2461
|
ht as q,
|
|
2457
|
-
|
|
2462
|
+
wo as r,
|
|
2458
2463
|
T as rt,
|
|
2459
|
-
|
|
2464
|
+
sr as s,
|
|
2460
2465
|
Qe as st,
|
|
2461
|
-
|
|
2462
|
-
|
|
2466
|
+
bo as t,
|
|
2467
|
+
Ur as tt,
|
|
2463
2468
|
po as u,
|
|
2464
2469
|
Dt as ut,
|
|
2465
2470
|
io as v,
|
|
2466
2471
|
he as vt,
|
|
2467
|
-
|
|
2468
|
-
|
|
2472
|
+
no as w,
|
|
2473
|
+
Xn as x,
|
|
2469
2474
|
ao as y,
|
|
2470
|
-
|
|
2475
|
+
Hr as z
|
|
2471
2476
|
};
|