@gengage/assistant-fe 0.6.33 → 0.6.35

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.
Files changed (97) hide show
  1. package/dist/chat-runtime.js +1 -1
  2. package/dist/chat.iife.js +1 -1
  3. package/dist/chat.js +1 -1
  4. package/dist/common/index.d.ts +2 -1
  5. package/dist/{common-Bhl-diYQ.js → common-C-lXfS-s.js} +1 -1
  6. package/dist/common.js +68 -67
  7. package/dist/{connection-warning-CuJ66qqt.js → connection-warning-DrXU9qN9.js} +1 -1
  8. package/dist/{fastIntent-CjgT7XpX.js → fastIntent-Diz6Vo0W.js} +1 -1
  9. package/dist/index.js +21 -21
  10. package/dist/native.iife.js +1 -1
  11. package/dist/qna-runtime.js +1 -1
  12. package/dist/qna.iife.js +1 -1
  13. package/dist/qna.js +1 -1
  14. package/dist/request-response-cache-DmnzO4Hu.js +1426 -0
  15. package/dist/{runtime-8WgpotSV.js → runtime-CiO-HX8B.js} +198 -199
  16. package/dist/{runtime-4QEfxNRC.js → runtime-D0v-KyzN.js} +36 -37
  17. package/dist/{runtime-bXec5UVj.js → runtime-hci1VRsa.js} +8 -9
  18. package/dist/{simbut-3z-Ed-TM.js → simbut-D-IPkTT8.js} +1 -1
  19. package/dist/simbut.iife.js +1 -1
  20. package/dist/simbut.js +1 -1
  21. package/dist/{simrel-Bz7xAdSc.js → simrel-BjMCvCdo.js} +1 -1
  22. package/dist/simrel-runtime.js +1 -1
  23. package/dist/simrel.iife.js +1 -1
  24. package/dist/simrel.js +2 -2
  25. package/dist/{widget-base-DhkuNWft.js → widget-base-_HBDf5VH.js} +1 -1
  26. package/package.json +3 -19
  27. package/dist/agent-ui-steps-DIWmTMuV.js +0 -3199
  28. package/dist/agentic/adaptor/create-adaptor.d.ts +0 -22
  29. package/dist/agentic/adaptor/fetch-bridge.d.ts +0 -31
  30. package/dist/agentic/adaptor/mount.d.ts +0 -45
  31. package/dist/agentic/algos/similarity.d.ts +0 -86
  32. package/dist/agentic/algos/similarity.js +0 -261
  33. package/dist/agentic/context/chat-context.d.ts +0 -17
  34. package/dist/agentic/context/context-store.d.ts +0 -57
  35. package/dist/agentic/context/persistence.d.ts +0 -14
  36. package/dist/agentic/contracts/agentic-contracts.d.ts +0 -133
  37. package/dist/agentic/debug/activity-collector.d.ts +0 -15
  38. package/dist/agentic/debug/activity-instrumentation.d.ts +0 -22
  39. package/dist/agentic/debug/activity-overlay.d.ts +0 -3
  40. package/dist/agentic/debug/activity-state.d.ts +0 -37
  41. package/dist/agentic/debug/local-dev.d.ts +0 -18
  42. package/dist/agentic/events/builders.d.ts +0 -10
  43. package/dist/agentic/events/comparison.d.ts +0 -6
  44. package/dist/agentic/events/context-products.d.ts +0 -6
  45. package/dist/agentic/events/error-taxonomy.d.ts +0 -27
  46. package/dist/agentic/events/product-normalize.d.ts +0 -50
  47. package/dist/agentic/events/ui-specs.d.ts +0 -41
  48. package/dist/agentic/flow/create-flow.d.ts +0 -2
  49. package/dist/agentic/flow/dispatch.d.ts +0 -3
  50. package/dist/agentic/index.d.ts +0 -65
  51. package/dist/agentic/index.js +0 -3493
  52. package/dist/agentic/types.d.ts +0 -360
  53. package/dist/agentic/util/account-config.d.ts +0 -8
  54. package/dist/agentic/util/assistant-host.d.ts +0 -11
  55. package/dist/agentic/util/be-url.d.ts +0 -4
  56. package/dist/agentic/util/browser-memory.d.ts +0 -13
  57. package/dist/agentic/util/browser-tools.d.ts +0 -31
  58. package/dist/agentic/util/cache-key.d.ts +0 -15
  59. package/dist/agentic/util/common/declarative-cache.d.ts +0 -21
  60. package/dist/agentic/util/common/fallback-status.d.ts +0 -10
  61. package/dist/agentic/util/common/flow-steps.d.ts +0 -8
  62. package/dist/agentic/util/common/gss-tool-aliases.d.ts +0 -66
  63. package/dist/agentic/util/common/iframe-scraper.d.ts +0 -22
  64. package/dist/agentic/util/common/llm-routing.d.ts +0 -50
  65. package/dist/agentic/util/common/object.d.ts +0 -1
  66. package/dist/agentic/util/common/open-product-page.d.ts +0 -30
  67. package/dist/agentic/util/common/panel-context.d.ts +0 -3
  68. package/dist/agentic/util/common/privacy.d.ts +0 -14
  69. package/dist/agentic/util/common/product-resolver.d.ts +0 -20
  70. package/dist/agentic/util/common/product-surface.d.ts +0 -24
  71. package/dist/agentic/util/common/ref-store.d.ts +0 -15
  72. package/dist/agentic/util/common/retail-privacy.d.ts +0 -4
  73. package/dist/agentic/util/common/route-params.d.ts +0 -3
  74. package/dist/agentic/util/common/similarity-ranking.d.ts +0 -2
  75. package/dist/agentic/util/common/site-awareness.d.ts +0 -130
  76. package/dist/agentic/util/lazy-runtime-loader.d.ts +0 -10
  77. package/dist/agentic/util/privacy.d.ts +0 -12
  78. package/dist/agentic/util/request-text.d.ts +0 -3
  79. package/dist/agentic/util/time.d.ts +0 -2
  80. package/dist/agentic/widgets/endpoints.d.ts +0 -12
  81. package/dist/agentic/worker/agent-ui-steps.d.ts +0 -43
  82. package/dist/agentic/worker/agent-ui.d.ts +0 -44
  83. package/dist/agentic/worker/be-client.d.ts +0 -32
  84. package/dist/agentic/worker/coalesce.d.ts +0 -25
  85. package/dist/agentic/worker/compaction.d.ts +0 -12
  86. package/dist/agentic/worker/entry.d.ts +0 -2
  87. package/dist/agentic/worker/flow-runner.d.ts +0 -24
  88. package/dist/agentic/worker/jwt-mint.d.ts +0 -21
  89. package/dist/agentic/worker/pdp-hydrate.d.ts +0 -30
  90. package/dist/agentic/worker/rpc.d.ts +0 -47
  91. package/dist/agentic/worker/tool-bridge.d.ts +0 -2
  92. package/dist/agentic/worker/tool-schema.d.ts +0 -19
  93. package/dist/agentic/worker.d.ts +0 -52
  94. package/dist/agentic/worker.js +0 -429
  95. package/dist/agentic.iife.js +0 -445
  96. package/dist/api-paths-BTHgM_Tz.js +0 -1274
  97. package/dist/request-response-cache-BxRsKGJ0.js +0 -154
@@ -1,3493 +0,0 @@
1
- import { buildPhotoSimilarityProfile as yo, buildProductSimilarityProfile as wo, buildSimilarityQueries as vo, normalizeSimilarityText as xo, rankSimilarProducts as ko, rankSimilarProductsAsync as _o, scoreSimilarityCandidate as So, tokenizeSimilarityText as Eo } from "./algos/similarity.js";
2
- import { $ as pt, A as Co, At as ft, B as Ao, C as Ro, Ct as mt, D as Po, E as Lo, Et as jo, F as No, G as Io, H as Uo, I as qo, J as Fo, K as Bo, L as Oo, M as Mo, Mt as $o, N as Do, O as Go, Ot as Be, P as zo, Q as gt, R as Ho, S as Wo, T as Vo, Tt as Ko, U as Jo, V as Yo, W as Zo, X as Qo, Y as Xo, Z as ei, _ as ti, _t as ri, a as ni, at as oi, b as ii, bt as ai, c as si, ct as ci, d as li, dt as ui, et as di, f as pi, ft as fi, g as mi, gt as ht, h as gi, ht as hi, i as bi, it as ue, j as yi, jt as wi, k as vi, kt as bt, l as xi, lt as ki, m as _i, mt as Si, n as Ei, nt as Ti, o as Ci, ot as Ai, p as Ri, pt as Pi, q as Li, r as ji, rt as Ni, s as Ii, st as Ui, t as qi, tt as Fi, u as Bi, ut as Oi, v as Mi, vt as $i, w as Di, wt as Gi, x as yt, xt as Oe, y as zi, yt as wt, z as Hi } from "../agent-ui-steps-DIWmTMuV.js";
3
- var vt = 512, xt = 0.74;
4
- function kt({ accountId: e, worker: t, beUrl: r, devJwtSecret: n, tokenBrokerUrl: o, tokenBrokerAudience: i, defaultLocale: a, tools: s = {}, beacon: d, confirmation: c, memory: p = Be() }) {
5
- let b = 1;
6
- const m = /* @__PURE__ */ new Map();
7
- return bt({
8
- worker: t,
9
- tools: s,
10
- beacon: (u) => d?.({
11
- ...u,
12
- accountId: u.accountId || e
13
- }),
14
- ...c ? { confirmation: c } : {},
15
- memory: p
16
- }), t.addEventListener("message", (u) => {
17
- const f = u.data || {};
18
- if (f.type === "activity" && f.entry) {
19
- Me(f.entry);
20
- return;
21
- }
22
- const g = typeof f.id == "number" ? f.id : null;
23
- if (g == null) return;
24
- const l = m.get(g);
25
- if (l) {
26
- if (f.type === "event" && f.event) {
27
- oe(l, f.event);
28
- return;
29
- }
30
- if (f.type === "error") {
31
- l.onError(new Error(f.message || "Agent worker failed")), m.delete(g);
32
- return;
33
- }
34
- f.type === "end" && m.delete(g);
35
- }
36
- }), (u, f, g, l) => {
37
- const h = b++;
38
- m.set(h, f);
39
- const w = () => {
40
- m.delete(h), t.postMessage({
41
- id: h,
42
- type: "abort"
43
- });
44
- }, k = (v) => {
45
- if (g.aborted) {
46
- w();
47
- return;
48
- }
49
- t.postMessage({
50
- id: h,
51
- type: "invoke",
52
- accountId: e,
53
- beUrl: r,
54
- devJwtSecret: n,
55
- tokenBrokerUrl: o,
56
- tokenBrokerAudience: i,
57
- defaultLocale: a,
58
- request: v,
59
- parentUrl: window.location.href,
60
- debugActivity: _t()
61
- });
62
- };
63
- if (g.aborted) {
64
- w();
65
- return;
66
- }
67
- if (g.addEventListener("abort", w, { once: !0 }), l) {
68
- $e(u, l).then(k).catch((v) => {
69
- m.delete(h), f.onError(v instanceof Error ? v : /* @__PURE__ */ new Error("Failed to read image attachment"));
70
- });
71
- return;
72
- }
73
- k(u);
74
- };
75
- }
76
- function Me(e) {
77
- const t = window;
78
- (t.__GENGAGE_AGENTIC_DEBUG_RECORD__ || t.__GENGAGE_AGENTIC_DEBUG_RECORD_BE__)?.(e);
79
- }
80
- function _t() {
81
- const e = window;
82
- return typeof (e.__GENGAGE_AGENTIC_DEBUG_RECORD__ || e.__GENGAGE_AGENTIC_DEBUG_RECORD_BE__) == "function";
83
- }
84
- function St({ accountId: e, accountModule: t, beUrl: r, devJwtSecret: n, tokenBrokerUrl: o, tokenBrokerAudience: i, defaultLocale: a, tools: s = {}, beacon: d, confirmation: c, memory: p }) {
85
- let b = null;
86
- const m = Et({
87
- accountId: e,
88
- tools: s,
89
- beacon: d,
90
- confirmation: c,
91
- memory: p ?? Be()
92
- }), u = gt(m), f = Oe({
93
- accountId: e,
94
- ...n ? { devJwtSecret: n } : {},
95
- ...o ? { tokenBrokerUrl: o } : {},
96
- ...i ? { tokenBrokerAudience: i } : {}
97
- });
98
- return async (g, l, h, w) => {
99
- const k = await $e(g || {}, w);
100
- b ||= new mt({
101
- accountId: e,
102
- locale: k?.locale || a,
103
- parentUrl: window.location.href,
104
- rpc: m,
105
- persistentPanelKeys: t.contextPersistence?.panelKeys,
106
- panelKeyLimits: t.contextPersistence?.panelKeyLimits,
107
- messageLimit: t.contextPersistence?.messageLimit,
108
- maxThreads: t.contextPersistence?.maxThreads,
109
- threadTtlMs: t.contextPersistence?.threadTtlMs
110
- });
111
- try {
112
- await pt({
113
- request: k,
114
- accountModule: {
115
- ...t,
116
- accountId: e,
117
- trace: async (v) => {
118
- Me({
119
- kind: "flow/trace",
120
- event: v
121
- }), await t.trace?.(v);
122
- }
123
- },
124
- contextStore: b,
125
- beClient: { invoke({ op: v, input: T, signal: x, cacheTtlS: C, cacheKey: M, browserCache: H }) {
126
- return ht({
127
- beUrl: r,
128
- accountId: e,
129
- jwtProvider: f,
130
- parentUrl: window.location.href,
131
- op: v,
132
- input: T,
133
- cacheTtlS: C,
134
- cacheKey: M,
135
- browserCache: H,
136
- ...x ? { signal: x } : {}
137
- });
138
- } },
139
- toolBridge: u,
140
- emit: (v) => oe(l, v),
141
- rpc: m,
142
- signal: h
143
- });
144
- } catch (v) {
145
- h?.aborted || (oe(l, wt(v)), l.onDone());
146
- }
147
- };
148
- }
149
- function Et({ accountId: e, tools: t, beacon: r, confirmation: n, memory: o }) {
150
- const i = (a) => r?.({
151
- ...a,
152
- accountId: a.accountId || e
153
- });
154
- return ((a, s) => ft(a, s, {
155
- tools: t,
156
- beacon: i,
157
- confirmation: n,
158
- memory: o
159
- }));
160
- }
161
- async function $e(e, t) {
162
- if (!t || !t.type?.startsWith("image/")) return e;
163
- const r = await At(t), n = {
164
- ...Tt(e.payload ?? e.action?.payload),
165
- image_data_url: r.dataUrl,
166
- image_mime: r.mime
167
- };
168
- return {
169
- ...e,
170
- payload: n,
171
- ...e.action ? { action: {
172
- ...e.action,
173
- payload: n
174
- } } : {}
175
- };
176
- }
177
- function Tt(e) {
178
- return Ct(e) ? { ...e } : typeof e == "string" ? { text: e } : {};
179
- }
180
- function Ct(e) {
181
- return typeof e == "object" && e !== null && !Array.isArray(e);
182
- }
183
- async function At(e) {
184
- const t = await Rt(e);
185
- return t || {
186
- dataUrl: await De(e),
187
- mime: e.type
188
- };
189
- }
190
- async function Rt(e) {
191
- if (typeof createImageBitmap != "function" || typeof document > "u") return null;
192
- let t = null;
193
- try {
194
- t = await createImageBitmap(e);
195
- const r = Math.min(1, vt / Math.max(t.width, t.height)), n = Math.max(1, Math.round(t.width * r)), o = Math.max(1, Math.round(t.height * r)), i = document.createElement("canvas");
196
- i.width = n, i.height = o;
197
- const a = i.getContext("2d");
198
- if (!a) return null;
199
- a.drawImage(t, 0, 0, n, o);
200
- const s = await new Promise((d) => i.toBlob(d, "image/jpeg", xt));
201
- return s ? {
202
- dataUrl: await De(s),
203
- mime: s.type || "image/jpeg"
204
- } : null;
205
- } catch {
206
- return null;
207
- } finally {
208
- t?.close();
209
- }
210
- }
211
- async function De(e) {
212
- const t = new Uint8Array(await e.arrayBuffer());
213
- let r = "";
214
- const n = 32768;
215
- for (let o = 0; o < t.length; o += n) r += String.fromCharCode(...t.subarray(o, o + n));
216
- return `data:${e.type};base64,${btoa(r)}`;
217
- }
218
- function oe(e, t) {
219
- switch (t?.type) {
220
- case "text_chunk": {
221
- const r = t;
222
- e.onTextChunk(r.content || "", r.final === !0, r);
223
- break;
224
- }
225
- case "ui_spec": {
226
- const r = t;
227
- e.onUISpec(r.spec, r.widget, r.panelHint, r.clearPanel === !0);
228
- break;
229
- }
230
- case "action":
231
- e.onAction(t);
232
- break;
233
- case "metadata":
234
- e.onMetadata(t);
235
- break;
236
- case "error":
237
- e.onError(Pt(t));
238
- break;
239
- case "done":
240
- e.onDone();
241
- break;
242
- default:
243
- break;
244
- }
245
- }
246
- function Pt(e) {
247
- const t = new Error(e.message || e.code || "Agent error");
248
- return e.code && (t.code = e.code), t;
249
- }
250
- var Lt = "entries", jt = 1, Nt = {
251
- volatile: "Hot per-page state and sensitive request context.",
252
- session: "Current-visit tool context without raw tokens or PII-heavy payloads.",
253
- local: "Small, non-sensitive capability facts or user preferences.",
254
- indexedDb: "Larger product/search payload caches with short TTLs."
255
- }, _e = /* @__PURE__ */ new Map();
256
- function ie() {
257
- return Date.now();
258
- }
259
- function U(e) {
260
- return e?.expiresAt != null && e.expiresAt <= ie();
261
- }
262
- function de(e, t) {
263
- return {
264
- value: e,
265
- createdAt: ie(),
266
- expiresAt: t ? ie() + t : null
267
- };
268
- }
269
- function It(e, t, r) {
270
- try {
271
- const n = e.getItem(`${t}${r}`);
272
- if (!n) return null;
273
- const o = JSON.parse(n);
274
- return U(o) ? (e.removeItem(`${t}${r}`), null) : o.value;
275
- } catch {
276
- return null;
277
- }
278
- }
279
- function Ut(e, t, r, n, o) {
280
- try {
281
- return e.setItem(`${t}${r}`, JSON.stringify(de(n, o))), !0;
282
- } catch {
283
- return !1;
284
- }
285
- }
286
- function qt(e, t, r) {
287
- try {
288
- e.removeItem(`${t}${r}`);
289
- } catch {
290
- }
291
- }
292
- function Se(e, t) {
293
- if (!e) return 0;
294
- let r = 0;
295
- try {
296
- const n = [];
297
- for (let o = 0; o < e.length; o += 1) {
298
- const i = e.key(o);
299
- i?.startsWith(t) && n.push(i);
300
- }
301
- for (const o of n) try {
302
- const i = JSON.parse(e.getItem(o) || "null");
303
- (!i || U(i)) && (e.removeItem(o), r += 1);
304
- } catch {
305
- e.removeItem(o), r += 1;
306
- }
307
- } catch {
308
- return r;
309
- }
310
- return r;
311
- }
312
- function Ee(e) {
313
- try {
314
- return window[e];
315
- } catch {
316
- return null;
317
- }
318
- }
319
- function Te(e, t) {
320
- return e ? {
321
- get: (r) => It(e, t, r),
322
- set: (r, n, o = {}) => Ut(e, t, r, n, o.ttlMs),
323
- remove: (r) => qt(e, t, r)
324
- } : {
325
- get: () => null,
326
- set: () => !1,
327
- remove: () => {
328
- }
329
- };
330
- }
331
- function Ft(e, t) {
332
- const r = t.dbName || `gengage-${e}`, n = t.dbStore || Lt, o = t.dbVersion || jt, i = /* @__PURE__ */ new Map();
333
- let a = null;
334
- const s = () => "indexedDB" in window ? a || (a = new Promise((m) => {
335
- const u = indexedDB.open(r, o);
336
- u.onupgradeneeded = () => {
337
- u.result.createObjectStore(n, { keyPath: "key" });
338
- }, u.onsuccess = () => m(u.result), u.onerror = () => m(null), u.onblocked = () => m(null);
339
- }), a) : Promise.resolve(null);
340
- return {
341
- volatileEntries: i,
342
- idbGet: async (m) => {
343
- const u = await s();
344
- return u ? new Promise((f) => {
345
- const g = u.transaction(n, "readwrite").objectStore(n), l = g.get(m);
346
- l.onsuccess = () => {
347
- const h = l.result;
348
- if (!h || U(h)) {
349
- h && g.delete(m), f(null);
350
- return;
351
- }
352
- f(h.value);
353
- }, l.onerror = () => f(null);
354
- }) : null;
355
- },
356
- idbSet: async (m, u, f = {}) => {
357
- const g = await s();
358
- return g ? new Promise((l) => {
359
- const h = g.transaction(n, "readwrite");
360
- h.oncomplete = () => l(!0), h.onerror = () => l(!1), h.objectStore(n).put({
361
- key: m,
362
- ...de(u, f.ttlMs)
363
- });
364
- }) : !1;
365
- },
366
- idbRemove: async (m) => {
367
- const u = await s();
368
- u && u.transaction(n, "readwrite").objectStore(n).delete(m);
369
- },
370
- idbGc: async () => {
371
- const m = await s();
372
- return m ? new Promise((u) => {
373
- let f = 0;
374
- const g = m.transaction(n, "readwrite"), l = g.objectStore(n).openCursor();
375
- l.onsuccess = () => {
376
- const h = l.result;
377
- if (!h) return;
378
- const w = h.value;
379
- (!w || U(w)) && (h.delete(), f += 1), h.continue();
380
- }, g.oncomplete = () => u(f), g.onerror = () => u(f), l.onerror = () => u(f);
381
- }) : 0;
382
- }
383
- };
384
- }
385
- function Ge(e, t = {}) {
386
- const r = window, n = r.gengage || (r.gengage = {}), o = n.memory || (n.memory = {}), i = o[e];
387
- if (i) return i;
388
- const a = _e.get(e) || Ft(e, t);
389
- _e.set(e, a);
390
- const s = t.sessionPrefix || `gengage:${e}:session:`, d = t.localPrefix || `gengage:${e}:local:`, c = Ee("sessionStorage"), p = Ee("localStorage"), m = {
391
- get: (l) => {
392
- const h = a.volatileEntries.get(l);
393
- return h ? U(h) ? (a.volatileEntries.delete(l), null) : h.value : null;
394
- },
395
- set: (l, h, w = {}) => (a.volatileEntries.set(l, de(h, w.ttlMs)), !0),
396
- remove: (l) => {
397
- a.volatileEntries.delete(l);
398
- },
399
- clear: () => a.volatileEntries.clear()
400
- }, u = {
401
- get: a.idbGet,
402
- set: a.idbSet,
403
- remove: a.idbRemove
404
- }, f = async () => {
405
- let l = 0;
406
- for (const [v, T] of a.volatileEntries)
407
- U(T) && (a.volatileEntries.delete(v), l += 1);
408
- const h = Se(c, s), w = Se(p, d), k = await a.idbGc();
409
- return {
410
- volatile: l,
411
- session: h,
412
- local: w,
413
- indexedDb: k
414
- };
415
- }, g = {
416
- accountId: e,
417
- volatile: m,
418
- session: Te(c, s),
419
- local: Te(p, d),
420
- indexedDb: u,
421
- gc: f,
422
- stableKey: ue,
423
- policy: {
424
- ...Nt,
425
- ...t.policy || {}
426
- }
427
- };
428
- o[e] = g;
429
- for (const l of t.aliases || []) o[l] = g;
430
- return Bt(g), g;
431
- }
432
- function Bt(e) {
433
- const t = window, r = () => {
434
- e.gc().catch(() => {
435
- });
436
- };
437
- if (typeof t.requestIdleCallback == "function") {
438
- t.requestIdleCallback(r);
439
- return;
440
- }
441
- setTimeout(r, 5e3);
442
- }
443
- var V = "__gengageAgentFetchBridge", Ot = 1e3 * 60 * 60 * 24 * 14;
444
- function Wi({ accountId: e, streamTransport: t, endpoints: r = {}, endpointCache: n }) {
445
- if (!e) throw new Error("accountId is required.");
446
- if (typeof t != "function") throw new Error("streamTransport is required.");
447
- const o = Mt(), i = `https://gengage-injector.invalid/${encodeURIComponent(e)}`, a = /* @__PURE__ */ new Set(), s = n ? Wt({
448
- accountId: e,
449
- endpointCache: n,
450
- fetchImpl: o.originalFetch
451
- }) : void 0, d = (c) => {
452
- const p = `${i}/chat/${c}`;
453
- a.add(p);
454
- const b = r[c], m = {
455
- streamTransport: t,
456
- endpoint: c
457
- };
458
- b && (m.endpointHandler = b), s && (m.endpointCache = s), o.routes.set(p, m);
459
- };
460
- d("process_action");
461
- for (const c of Object.keys(r)) c !== "process_action" && d(c);
462
- return {
463
- middlewareUrl: i,
464
- stop() {
465
- for (const c of a) o.routes.delete(c);
466
- $t(o);
467
- }
468
- };
469
- }
470
- function Mt() {
471
- const e = window, t = e[V];
472
- if (t) return t;
473
- const r = e.fetch.bind(e), n = {
474
- routes: /* @__PURE__ */ new Map(),
475
- originalFetch: r,
476
- installedFetch: r
477
- };
478
- return n.installedFetch = (o, i) => {
479
- const a = ze(o), s = n.routes.get(a);
480
- return s ? Gt(s, o, i) : r(o, i);
481
- }, e.fetch = n.installedFetch, e[V] = n, n;
482
- }
483
- function $t(e) {
484
- if (e.routes.size > 0) return;
485
- const t = window;
486
- t.fetch === e.installedFetch && (t.fetch = e.originalFetch), t[V] === e && delete t[V];
487
- }
488
- function ze(e) {
489
- return typeof e == "string" ? e : e instanceof URL ? e.href : e?.url || "";
490
- }
491
- function Ce(e, t) {
492
- if (t?.signal) return t.signal;
493
- if (typeof Request < "u" && e instanceof Request) return e.signal;
494
- }
495
- function He(e, t) {
496
- return t?.body !== void 0 && t?.body !== null ? t.body : typeof Request < "u" && e instanceof Request ? e.clone().text() : null;
497
- }
498
- async function Dt(e, t) {
499
- const r = He(e, t);
500
- if (r instanceof FormData) {
501
- const o = r.get("request"), i = r.get("attachment");
502
- return {
503
- request: JSON.parse(String(o || "{}")),
504
- ...i instanceof File ? { attachment: i } : {}
505
- };
506
- }
507
- const n = await Promise.resolve(r);
508
- return typeof n == "string" ? { request: JSON.parse(n || "{}") } : { request: {} };
509
- }
510
- async function Gt(e, t, r) {
511
- if (e.endpoint && e.endpoint !== "process_action" && e.endpointHandler) {
512
- const c = new AbortController(), p = Ce(t, r);
513
- let b = null;
514
- if (p) {
515
- const m = () => c.abort();
516
- p.aborted && m(), p.addEventListener("abort", m, { once: !0 }), b = () => p.removeEventListener("abort", m);
517
- }
518
- try {
519
- const m = await zt(t, r), u = {
520
- accountId: Ht(t),
521
- endpoint: e.endpoint,
522
- signal: c.signal
523
- }, f = Vt(e.endpointCache, e.endpoint, m, u.accountId);
524
- if (f) {
525
- const l = await Kt(e.endpointCache, f, c.signal);
526
- if (l) return er(l);
527
- }
528
- const g = await e.endpointHandler(m, u);
529
- return f && g.ok && await Jt(e.endpointCache, f, g.clone(), c.signal), g;
530
- } finally {
531
- b?.();
532
- }
533
- }
534
- const n = new TextEncoder(), o = new AbortController(), i = Ce(t, r);
535
- let a = !1, s = null;
536
- const d = new ReadableStream({
537
- async start(c) {
538
- const p = (u) => {
539
- a || c.enqueue(n.encode(`${JSON.stringify(u)}
540
- `));
541
- }, b = () => {
542
- a || (a = !0, s?.(), c.close());
543
- }, m = (u) => {
544
- p({
545
- type: "error",
546
- code: u?.code || "agent_bridge_error",
547
- message: u instanceof Error ? u.message : String(u)
548
- }), p({ type: "done" }), b();
549
- };
550
- if (i) {
551
- const u = () => {
552
- o.abort(), a || (a = !0, s?.(), c.error(new DOMException("Aborted", "AbortError")));
553
- };
554
- if (i.aborted) {
555
- u();
556
- return;
557
- }
558
- i.addEventListener("abort", u, { once: !0 }), s = () => i.removeEventListener("abort", u);
559
- }
560
- try {
561
- const { request: u, attachment: f } = await Dt(t, r), g = e.streamTransport(u, {
562
- onTextChunk: (l, h, w = {}) => p({
563
- type: "text_chunk",
564
- content: l,
565
- final: h === !0,
566
- ...w
567
- }),
568
- onUISpec: (l, h, w, k) => p({
569
- type: "ui_spec",
570
- spec: l,
571
- widget: h,
572
- ...w ? { panelHint: w } : {},
573
- ...k ? { clearPanel: !0 } : {}
574
- }),
575
- onAction: (l) => {
576
- p(l?.type === "action" ? l : {
577
- type: "action",
578
- action: l
579
- });
580
- },
581
- onMetadata: (l) => {
582
- p(l?.type === "metadata" ? l : {
583
- type: "metadata",
584
- ...l
585
- });
586
- },
587
- onError: m,
588
- onDone: () => {
589
- p({ type: "done" }), b();
590
- }
591
- }, o.signal, f);
592
- or(g) && (await g, o.signal.aborted || (p({ type: "done" }), b()));
593
- } catch (u) {
594
- o.signal.aborted || m(u);
595
- }
596
- },
597
- cancel() {
598
- o.abort(), s?.(), a = !0;
599
- }
600
- });
601
- return new Response(d, {
602
- status: 200,
603
- headers: { "Content-Type": "application/x-ndjson" }
604
- });
605
- }
606
- async function zt(e, t) {
607
- const r = await Promise.resolve(He(e, t));
608
- return typeof r != "string" || r.trim() === "" ? {} : JSON.parse(r);
609
- }
610
- function Ht(e) {
611
- try {
612
- const [t] = new URL(ze(e)).pathname.split("/").filter(Boolean);
613
- return decodeURIComponent(t || "");
614
- } catch {
615
- return "";
616
- }
617
- }
618
- function Wt({ accountId: e, endpointCache: t, fetchImpl: r }) {
619
- return {
620
- accountId: e,
621
- beUrl: t.beUrl,
622
- ...t.parentUrl ? { parentUrl: t.parentUrl } : {},
623
- ttlMs: t.ttlMs ?? Ot,
624
- policies: t.policies,
625
- fetchImpl: r,
626
- jwtProvider: Oe({
627
- accountId: e,
628
- ...t.devJwtSecret ? { devJwtSecret: t.devJwtSecret } : {},
629
- ...t.tokenBrokerUrl ? { tokenBrokerUrl: t.tokenBrokerUrl } : {},
630
- ...t.tokenBrokerAudience ? { tokenBrokerAudience: t.tokenBrokerAudience } : {},
631
- fetchImpl: r
632
- })
633
- };
634
- }
635
- function Vt(e, t, r, n) {
636
- if (!e) return null;
637
- const o = e.policies[t];
638
- if (!o) return null;
639
- const i = o(r, {
640
- accountId: n,
641
- endpoint: t
642
- });
643
- return !i?.partition || !i?.key ? null : {
644
- partition: i.partition,
645
- key: i.key,
646
- ttlMs: i.ttlMs ?? e.ttlMs
647
- };
648
- }
649
- async function Kt(e, t, r) {
650
- const n = Je(e.accountId, t), o = await tr(e.accountId, n);
651
- if (Ke(o)) return o;
652
- const i = await Yt(e, t, r);
653
- return i ? (await Ye(e.accountId, n, i, t.ttlMs), i) : null;
654
- }
655
- async function Jt(e, t, r, n) {
656
- try {
657
- const o = await Xt(r);
658
- if (nr(o.body)) return;
659
- const i = Je(e.accountId, t);
660
- await Ye(e.accountId, i, o, t.ttlMs), Zt(e, t, o, n);
661
- } catch {
662
- }
663
- }
664
- async function Yt(e, t, r) {
665
- try {
666
- const n = await e.fetchImpl(Ve(e.beUrl), {
667
- method: "POST",
668
- headers: await We(e, r),
669
- body: JSON.stringify({
670
- partition: t.partition,
671
- key: t.key
672
- }),
673
- signal: r
674
- });
675
- if (!n.ok) return null;
676
- const o = await n.json();
677
- return o.hit === !0 && Ke(o.payload) ? o.payload : null;
678
- } catch {
679
- return null;
680
- }
681
- }
682
- async function Zt(e, t, r, n) {
683
- try {
684
- await e.fetchImpl(Ve(e.beUrl), {
685
- method: "POST",
686
- headers: await We(e, n),
687
- body: JSON.stringify({
688
- partition: t.partition,
689
- key: t.key,
690
- ttl_s: Math.max(1, Math.ceil(t.ttlMs / 1e3)),
691
- payload: r
692
- }),
693
- signal: n
694
- });
695
- } catch {
696
- }
697
- }
698
- async function We(e, t) {
699
- return {
700
- authorization: `Bearer ${await e.jwtProvider({
701
- signal: t,
702
- parentUrl: e.parentUrl || Qt()
703
- })}`,
704
- "content-type": "application/json",
705
- accept: "application/json"
706
- };
707
- }
708
- function Qt() {
709
- try {
710
- return window.location?.href || "";
711
- } catch {
712
- return "";
713
- }
714
- }
715
- function Ve(e) {
716
- return `${String(e).replace(/\/+$/u, "")}/v1/cache`;
717
- }
718
- async function Xt(e) {
719
- return {
720
- status: e.status,
721
- statusText: e.statusText,
722
- headers: [...e.headers.entries()].filter(([t]) => rr(t)),
723
- body: await e.text()
724
- };
725
- }
726
- function er(e) {
727
- return new Response(e.body, {
728
- status: e.status,
729
- statusText: e.statusText,
730
- headers: new Headers(e.headers)
731
- });
732
- }
733
- function Ke(e) {
734
- if (!e || typeof e != "object" || Array.isArray(e)) return !1;
735
- const t = e;
736
- return typeof t.status == "number" && typeof t.statusText == "string" && typeof t.body == "string" && Array.isArray(t.headers);
737
- }
738
- function Je(e, t) {
739
- return `endpoint-response:${ue({
740
- accountId: e,
741
- partition: t.partition,
742
- key: t.key
743
- })}`;
744
- }
745
- async function tr(e, t) {
746
- const r = Ge(e);
747
- return r.volatile.get(t) || await r.indexedDb.get(t) || r.local.get(t);
748
- }
749
- async function Ye(e, t, r, n) {
750
- const o = Ge(e);
751
- o.volatile.set(t, r, { ttlMs: n }), await o.indexedDb.set(t, r, { ttlMs: n }) || o.local.set(t, r, { ttlMs: n });
752
- }
753
- function rr(e) {
754
- return ["content-type", "cache-control"].includes(e.toLowerCase());
755
- }
756
- function nr(e) {
757
- return /"_error"\s*:/u.test(e) || /"type"\s*:\s*"error"/u.test(e);
758
- }
759
- function or(e) {
760
- return e !== null && (typeof e == "object" || typeof e == "function") && typeof e.then == "function";
761
- }
762
- function Vi({ accountId: e, beUrl: t, devJwtSecret: r, tokenBrokerUrl: n, tokenBrokerAudience: o, workerUrl: i, defaultLocale: a = "en-GB", accountModule: s, tools: d = {}, beacon: c, confirmation: p, memory: b, allowBlobWorker: m = !1, signal: u }) {
763
- if (!e) throw new Error("accountId is required.");
764
- if (!t) throw new Error("beUrl is required. The injector owns backend URLs; the SDK has no default.");
765
- if (!i) throw new Error("workerUrl is required.");
766
- const f = window, g = f.GengageAssistantInjector || (f.GengageAssistantInjector = {}), l = g[e] || (g[e] = {});
767
- if (l.agentController) return l.agentController;
768
- const h = Ze(i) || m ? ir(i, `gengage-${e}-agent`, { allowBlobWorker: m }) : null;
769
- h || c?.({
770
- type: "agentRuntime",
771
- accountId: e,
772
- transport: "main-thread",
773
- reason: "cross-origin-worker-url",
774
- workerUrl: i
775
- }), l.streamTransport = h ? kt({
776
- accountId: e,
777
- worker: h.worker,
778
- beUrl: t,
779
- ...r ? { devJwtSecret: r } : {},
780
- ...n ? { tokenBrokerUrl: n } : {},
781
- ...o ? { tokenBrokerAudience: o } : {},
782
- defaultLocale: a,
783
- tools: d,
784
- ...c ? { beacon: c } : {},
785
- ...p ? { confirmation: p } : {},
786
- ...b ? { memory: b } : {}
787
- }) : St({
788
- accountId: e,
789
- accountModule: s,
790
- beUrl: t,
791
- ...r ? { devJwtSecret: r } : {},
792
- ...n ? { tokenBrokerUrl: n } : {},
793
- ...o ? { tokenBrokerAudience: o } : {},
794
- defaultLocale: a,
795
- tools: d,
796
- ...c ? { beacon: c } : {},
797
- ...p ? { confirmation: p } : {},
798
- ...b ? { memory: b } : {}
799
- });
800
- const w = new AbortController(), k = [], v = () => {
801
- for (; k.length; ) {
802
- const C = k.pop();
803
- try {
804
- C?.();
805
- } catch {
806
- }
807
- }
808
- }, T = () => {
809
- w.signal.aborted || (w.abort(), u?.removeEventListener("abort", T), delete l.streamTransport, h?.worker.terminate(), h?.cleanup(), v(), delete l.agentController);
810
- };
811
- u?.addEventListener("abort", T, { once: !0 });
812
- const x = {
813
- type: "agent",
814
- signal: w.signal,
815
- addCleanup(C) {
816
- if (typeof C == "function") {
817
- if (w.signal.aborted) {
818
- C();
819
- return;
820
- }
821
- k.push(C);
822
- }
823
- },
824
- stop: T,
825
- diagnostics() {
826
- return {
827
- accountId: e,
828
- beUrl: t,
829
- workerUrl: i,
830
- mounted: !0,
831
- transport: h ? "worker" : "main-thread",
832
- transportReason: h ? "module-worker" : "cross-origin-worker-url",
833
- flows: Object.keys(s?.flows || {})
834
- };
835
- }
836
- };
837
- return l.agentController = x, x;
838
- }
839
- function Ze(e) {
840
- const t = new URL(e, window.location.href);
841
- return t.origin === window.location.origin || t.protocol === "blob:";
842
- }
843
- function ir(e, t, r = {}) {
844
- const n = new URL(e, window.location.href);
845
- if (Ze(e)) return {
846
- worker: new Worker(n.href, {
847
- type: "module",
848
- name: t
849
- }),
850
- cleanup() {
851
- }
852
- };
853
- if (!r.allowBlobWorker) throw new Error("Cross-origin agent workers require allowBlobWorker=true or a same-origin workerUrl.");
854
- const o = new Blob([`import ${JSON.stringify(n.href)};
855
- `], { type: "text/javascript" }), i = URL.createObjectURL(o);
856
- try {
857
- return {
858
- worker: new Worker(i, {
859
- type: "module",
860
- name: t
861
- }),
862
- cleanup() {
863
- URL.revokeObjectURL(i);
864
- }
865
- };
866
- } catch (a) {
867
- throw URL.revokeObjectURL(i), a;
868
- }
869
- }
870
- function ar(e, t, r = "v1") {
871
- return `endpoint:${r}:${ue({
872
- endpoint: e,
873
- request: t
874
- })}`;
875
- }
876
- function Ki(e) {
877
- const t = e.version || "v1", r = (n) => (o) => ({
878
- partition: `${e.partitionPrefix}/${n}`,
879
- key: ar(n, o, t),
880
- ...e.ttlMs ? { ttlMs: e.ttlMs } : {}
881
- });
882
- return {
883
- launcher_action: r("launcher_action"),
884
- similar_products: r("similar_products"),
885
- product_groupings: r("product_groupings")
886
- };
887
- }
888
- function Ji(e) {
889
- return { ...e };
890
- }
891
- function Yi(e, t = {}) {
892
- return new Response(e.map((r) => JSON.stringify(r)).join(`
893
- `) + `
894
- `, {
895
- ...t,
896
- headers: {
897
- "content-type": "application/x-ndjson",
898
- ...t.headers || {}
899
- }
900
- });
901
- }
902
- function Zi(e, t = {}) {
903
- return new Response(JSON.stringify(e), {
904
- ...t,
905
- headers: {
906
- "content-type": "application/json",
907
- ...t.headers || {}
908
- }
909
- });
910
- }
911
- function sr(e) {
912
- const t = (e?.chat || e?._chat)?.root || e?._chat?.root;
913
- return t ? t.getRootNode?.()?.host || t : Array.from(document.querySelectorAll("*")).find((r) => r.shadowRoot?.querySelector?.(".gengage-chat-root, .gengage-chat-launcher-container"));
914
- }
915
- function Qi(e, t) {
916
- const r = sr(e);
917
- r?.style && (t ? r.style.removeProperty("display") : r.style.setProperty("display", "none", "important")), t || (e?.chat || e?._chat)?.close?.();
918
- }
919
- var cr = "nd_be_url";
920
- function Xi(e, t) {
921
- const r = lr() || e.beUrl || t;
922
- if (!r) throw new Error("resolveBeUrl: backend URL is required. The injector must supply a fallback URL; the SDK has no default.");
923
- return r;
924
- }
925
- function lr() {
926
- try {
927
- const e = new URLSearchParams(window.location.search).get(cr)?.trim();
928
- if (!e) return null;
929
- const t = new URL(e);
930
- return t.protocol !== "https:" && t.protocol !== "http:" ? null : t.toString().replace(/\/+$/u, "");
931
- } catch {
932
- return null;
933
- }
934
- }
935
- var ur = [
936
- "addToCart",
937
- "search",
938
- "searchKeyword",
939
- "facetedSearch",
940
- "searchGiftOptions",
941
- "similaritySearch"
942
- ];
943
- function ea(e, t, r = {}) {
944
- const n = window, o = n.gengage || (n.gengage = {}), i = o.tools || (o.tools = {});
945
- i[e] = t;
946
- for (const a of r.accountAliases || []) i[a] = t;
947
- if (r.exposeStandardAliases !== !1) for (const a of r.standardAliases || ur) {
948
- const s = t[a];
949
- typeof s == "function" && (i[a] = i[a] || s);
950
- }
951
- return t;
952
- }
953
- function ta({ getPageType: e, getProduct: t }) {
954
- return () => ({
955
- url: window.location.href,
956
- title: document.title,
957
- pageType: e(),
958
- product: t()
959
- });
960
- }
961
- function ra({ accountId: e, getPageType: t, getProduct: r, getToolNames: n, getSearchCapabilities: o, getMemory: i }) {
962
- return async () => ({
963
- accountId: e,
964
- url: window.location.href,
965
- pageType: t(),
966
- productSku: r()?.sku ?? null,
967
- toolNames: n(),
968
- ...o ? { searchCapabilities: o() } : {},
969
- ...i ? { memoryPolicy: i().policy } : {},
970
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
971
- });
972
- }
973
- function na({ accountId: e, runtimeFile: t = "runtime.js", startExport: r = "start", globalBaseUrlKey: n, errorLabel: o, trustedRuntimeOrigins: i } = {}) {
974
- if (!e) throw new Error("accountId is required.");
975
- const a = o || e, s = window, d = () => {
976
- const u = s.GengageInjectorConfig || {}, f = u[e] || {};
977
- return {
978
- ...u,
979
- ...f
980
- };
981
- }, c = () => {
982
- const u = d();
983
- if (u.runtimeUrl) return u.runtimeUrl;
984
- const f = u.assetBaseUrl || u.baseUrl || document.currentScript?.getAttribute("src") || (n ? s[n] : null);
985
- if (!f) throw new Error(`${a} runtime URL cannot be resolved.`);
986
- return new URL(t, f).href;
987
- }, p = (u) => {
988
- if (i === !0) return u;
989
- const f = new URL(u, window.location.href).origin, g = /* @__PURE__ */ new Set([window.location.origin]), l = d();
990
- $(g, document.currentScript?.getAttribute("src")), $(g, l.assetBaseUrl), $(g, l.baseUrl), $(g, n ? s[n] : void 0);
991
- for (const h of i || []) $(g, h);
992
- if (!g.has(f)) throw new Error(`${a} runtime origin ${f} is not trusted.`);
993
- return u;
994
- }, b = s.GengageAssistantInjector || (s.GengageAssistantInjector = {}), m = b[e] || (b[e] = {});
995
- return m.loaderPromise || (m.loaderPromise = import(
996
- /* @vite-ignore */
997
- p(c())
998
- ).then((u) => {
999
- const f = u[r];
1000
- if (typeof f != "function") throw new Error(`${a} runtime export ${r} is unavailable.`);
1001
- return f();
1002
- }).catch((u) => {
1003
- throw delete m.loaderPromise, console.error(`[Gengage][${e}] runtime load failed`, u), u;
1004
- })), m.loaderPromise;
1005
- }
1006
- function $(e, t) {
1007
- if (t)
1008
- try {
1009
- const r = new URL(t, window.location.href);
1010
- e.add(r.origin);
1011
- } catch {
1012
- e.add(t);
1013
- }
1014
- }
1015
- var dr = 500, Ae = "__GENGAGE_AGENTIC_ACTIVITY__";
1016
- function pr({ accountId: e, clock: t = () => Date.now() } = {}) {
1017
- const r = /* @__PURE__ */ new Set();
1018
- let n = 1;
1019
- const o = {
1020
- accountId: e,
1021
- entries: []
1022
- };
1023
- function i(a) {
1024
- const s = mr({
1025
- id: n++,
1026
- at: t(),
1027
- accountId: e,
1028
- ...a
1029
- });
1030
- o.entries.push(s), o.entries.length > dr && (o.entries = o.entries.slice(-500));
1031
- for (const d of r) d(s, o.entries);
1032
- return s;
1033
- }
1034
- return {
1035
- accountId: e,
1036
- get entries() {
1037
- return o.entries.slice();
1038
- },
1039
- clear() {
1040
- o.entries = [];
1041
- for (const a of r) a(null, o.entries);
1042
- },
1043
- record: i,
1044
- subscribe(a) {
1045
- return typeof a != "function" ? () => {
1046
- } : (r.add(a), a(null, o.entries), () => r.delete(a));
1047
- }
1048
- };
1049
- }
1050
- function fr(e) {
1051
- const t = window[Ae];
1052
- if (t?.accountId === e && typeof t.record == "function") return t;
1053
- const r = pr({ accountId: e });
1054
- return window[Ae] = r, r;
1055
- }
1056
- function mr(e) {
1057
- const t = String(e.kind || e.type || "activity"), r = hr(t), n = e.severity || br({
1058
- ...e,
1059
- kind: t
1060
- });
1061
- return {
1062
- ...e,
1063
- kind: t,
1064
- section: r,
1065
- severity: n,
1066
- group: e.group || yr({
1067
- ...e,
1068
- kind: t,
1069
- section: r
1070
- }),
1071
- noise: e.noise === !0 || n === "info" && gr({
1072
- ...e,
1073
- kind: t
1074
- })
1075
- };
1076
- }
1077
- function gr(e) {
1078
- const t = String(e?.kind || "");
1079
- if (t === "flow/trace") {
1080
- const r = String(e?.event?.type || "");
1081
- if (r === "step:start" || r === "step:end") return !0;
1082
- }
1083
- if (t === "flow/metadata") {
1084
- const r = String(e?.event?.phase || e?.event?.type || e?.event?.name || "").toLowerCase();
1085
- if (r === "panelloading" || r === "heartbeat" || r === "tick") return !0;
1086
- }
1087
- return !!t.startsWith("runtime/");
1088
- }
1089
- function hr(e) {
1090
- return e.startsWith("flow/") ? "Flow" : e.startsWith("intent/") ? "Intent" : e.startsWith("be/") ? "Backend" : e.startsWith("tool/") ? "Tools" : e === "beacon" ? "Telemetry" : "Runtime";
1091
- }
1092
- function br(e) {
1093
- const t = String(e?.kind || "");
1094
- return /\/(?:error|rejected|thrown)$/u.test(t) || e?.error || t === "be/response" && Number(e?.status) >= 400 ? "error" : t === "flow/metadata" && /fallback|retry|missing|empty/iu.test(String(e?.event?.phase || e?.event?.type || "")) || t === "be/response" && Number(e?.status) >= 300 ? "warn" : "info";
1095
- }
1096
- function yr(e) {
1097
- const t = String(e?.kind || "");
1098
- if (t.startsWith("tool/")) return e?.tool ? `Tool: ${e.tool}` : "Tools";
1099
- if (t.startsWith("be/")) return e?.op ? `BE: ${e.op}` : "Backend";
1100
- if (t === "flow/request") {
1101
- const r = e?.request?.type || e?.request?.action?.type;
1102
- return r ? `Flow: ${r}` : "Flow request";
1103
- }
1104
- if (t === "flow/action") {
1105
- const r = e?.event?.name || e?.event?.action || e?.event?.type;
1106
- return r ? `Action: ${r}` : "Flow action";
1107
- }
1108
- return t === "flow/ui" ? e?.widget ? `UI: ${e.widget}` : "UI" : t.startsWith("flow/") ? "Flow lifecycle" : t.startsWith("intent/") ? e?.intent?.kind ? `Intent: ${e.intent.kind}` : "Intent" : t === "beacon" ? e?.payload?.type ? `Beacon: ${e.payload.type}` : "Beacon" : e?.section || "Runtime";
1109
- }
1110
- var wr = 8, pe = 120;
1111
- function vr(e = []) {
1112
- const t = Array.isArray(e) ? e : [], r = {
1113
- status: "idle",
1114
- sessionId: "",
1115
- requestType: "",
1116
- actionType: "",
1117
- model: "",
1118
- current: "Waiting for activity",
1119
- errors: 0,
1120
- warnings: 0,
1121
- startedAt: null,
1122
- lastAt: null,
1123
- tools: [],
1124
- beOps: [],
1125
- uiSurfaces: [],
1126
- timeline: []
1127
- }, n = {
1128
- intent: null,
1129
- route: null,
1130
- panel: null,
1131
- threadExtensions: {},
1132
- pageProduct: null,
1133
- products: null,
1134
- ui: null,
1135
- lastText: ""
1136
- };
1137
- for (const o of t) xr(r, n, o);
1138
- return r.tools = te(r.tools).slice(-8), r.beOps = te(r.beOps).slice(-8), r.uiSurfaces = te(r.uiSurfaces).slice(-8), r.timeline = r.timeline.slice(-36), !r.lastAt && t.length && (r.lastAt = t.at(-1)?.at || null), {
1139
- flow: r,
1140
- context: n
1141
- };
1142
- }
1143
- function Y(e, t = "") {
1144
- if (!e || typeof e != "object") return null;
1145
- const r = E({
1146
- source: t,
1147
- panel: ae(e.panel || e.panel_state),
1148
- threadExtensions: Pr(e.thread?.extensions || e.threadExtensions || e.extensions),
1149
- pageProduct: Ur(e.product || e.page?.product),
1150
- products: I(e.products || e.last_search_products || e.items),
1151
- ui: Qe(e.spec),
1152
- intent: fe(e.intent),
1153
- route: Q({
1154
- searchParams: e.searchParams || e.search_params,
1155
- flowParams: e.flowParams || e.flow_params
1156
- })
1157
- });
1158
- return Object.keys(r).some((n) => n !== "source") ? r : null;
1159
- }
1160
- function ae(e) {
1161
- if (!e || typeof e != "object") return null;
1162
- const t = I(e.last_search_products || e.current_panel_products), r = q(e.screen_sku_list || e.search_suggestions_skus);
1163
- return E({
1164
- source: e.list_source || e.source,
1165
- screenType: y(e.screen_type || e.screen),
1166
- screenSummary: y(e.screen_summary || e.ai_plist_summary),
1167
- screenSkus: r,
1168
- chatMentionedSkus: q(e.chat_mentioned_skus),
1169
- lastSearch: Lr(e.last_search),
1170
- productCount: t?.count ?? me(e.current_panel_product_count),
1171
- productSkus: t?.skus
1172
- });
1173
- }
1174
- function Qe(e, t = "", r = "") {
1175
- if (!e || typeof e != "object") return null;
1176
- const n = qr(e);
1177
- if (!n) return null;
1178
- const o = n.props || {}, i = jr(e, n, o), a = Array.isArray(o.buttons) ? o.buttons : Array.isArray(o.actions) ? o.actions : [], s = Array.isArray(o.rows) ? o.rows.length : Array.isArray(o.comparison_table) ? o.comparison_table.length : void 0;
1179
- return E({
1180
- widget: t,
1181
- panelHint: r,
1182
- rootType: n.type,
1183
- productCount: i?.count,
1184
- productSkus: i?.skus,
1185
- buttonCount: a.length || void 0,
1186
- buttonLabels: a.length ? q(a.map((d) => d.label || d.title)) : void 0,
1187
- comparisonRows: s
1188
- });
1189
- }
1190
- function xr(e, t, r = {}) {
1191
- if (!(!r || typeof r != "object"))
1192
- switch (e.lastAt = r.at || e.lastAt, r.severity === "error" && (e.errors += 1), r.severity === "warn" && (e.warnings += 1), r.state && Z(t, r.state), r.kind) {
1193
- case "flow/request":
1194
- kr(e, t, r);
1195
- break;
1196
- case "flow/metadata":
1197
- _r(e, t, r);
1198
- break;
1199
- case "flow/trace":
1200
- Er(e, r);
1201
- break;
1202
- case "flow/ui":
1203
- Sr(e, t, r);
1204
- break;
1205
- case "flow/text-final":
1206
- t.lastText = y(r.content, pe), S(e, r, "Text", t.lastText, "done");
1207
- break;
1208
- case "flow/done":
1209
- e.status = e.status === "error" ? "error" : "done", e.current = "Done", S(e, r, "Done", "Flow completed", "done");
1210
- break;
1211
- case "flow/error":
1212
- case "flow/rejected":
1213
- case "flow/thrown":
1214
- e.status = "error", e.current = "Flow error", S(e, r, "Error", y(r.error || r.kind), "error");
1215
- break;
1216
- case "tool/start":
1217
- e.status = e.status === "idle" ? "running" : e.status, e.current = `Tool: ${r.tool || "tool"}`, e.tools.push(r.tool || "tool"), S(e, r, "Tool", r.tool || "tool", "running");
1218
- break;
1219
- case "tool/done":
1220
- e.tools.push(r.tool || "tool"), S(e, r, "Tool", r.tool || "tool", "done");
1221
- break;
1222
- case "tool/error":
1223
- e.status = "error", e.current = `Tool error: ${r.tool || "tool"}`, e.tools.push(r.tool || "tool"), S(e, r, "Tool", r.tool || "tool", "error");
1224
- break;
1225
- case "be/request":
1226
- e.status = e.status === "idle" ? "running" : e.status, e.current = `BE: ${r.op || "request"}`, e.beOps.push(r.op || "unknown"), Tr(t, r), S(e, r, "BE", r.op || "request", "running");
1227
- break;
1228
- case "be/response":
1229
- e.beOps.push(r.op || r.result?.op || "unknown"), Cr(t, r.result), S(e, r, "BE", r.op || r.result?.intent?.kind || "response", r.severity || "done");
1230
- break;
1231
- case "intent/selected":
1232
- t.intent = fe(r.intent), t.route = Q({
1233
- searchParams: r.searchParams,
1234
- flowParams: r.flowParams
1235
- }), e.current = `Intent: ${t.intent?.kind || "selected"}`, S(e, r, "Intent", t.intent?.kind || "selected", "done");
1236
- break;
1237
- default:
1238
- r.kind?.startsWith?.("runtime/") && S(e, r, "Runtime", r.title || r.kind, "done");
1239
- break;
1240
- }
1241
- }
1242
- function kr(e, t, r) {
1243
- const n = r.request || {};
1244
- e.status = "running", e.startedAt = r.at || e.startedAt, e.sessionId = y(n.session_id || n.sessionId || e.sessionId), e.requestType = y(n.type || e.requestType), e.actionType = y(n.action?.type || n.payload?.type || e.actionType), e.current = e.actionType || e.requestType || "Flow request", Z(t, Y(n.context || {}, "request.context")), S(e, r, "Request", [e.requestType, e.actionType].filter(Boolean).join(" / ") || "request", "running");
1245
- }
1246
- function _r(e, t, r) {
1247
- const n = r.event || {};
1248
- e.sessionId = y(n.sessionId || n.session_id || e.sessionId), e.model = y(n.model || e.model), n.panelLoading === !0 && (e.current = "Panel loading"), Z(t, Y(n, "flow.metadata")), S(e, r, "Metadata", y(n.name || n.phase || n.type || "metadata"), r.severity);
1249
- }
1250
- function Sr(e, t, r) {
1251
- const n = Qe(r.spec, r.widget, r.panelHint);
1252
- n && (t.ui = n, typeof n.productCount == "number" && (t.products = {
1253
- count: n.productCount,
1254
- skus: n.productSkus || []
1255
- }), e.uiSurfaces.push(n.rootType), e.current = `UI: ${n.rootType}`, S(e, r, "UI", n.rootType || "ui", "done"));
1256
- }
1257
- function Er(e, t) {
1258
- const r = t.event || {}, n = y(r.type || "trace"), o = y(r.stepName || r.stepKind || "");
1259
- e.sessionId = y(r.sessionId || e.sessionId), e.current = o ? `${n}: ${o}` : n, S(e, t, "Trace", [n, o].filter(Boolean).join(" / ") || "trace", Fr(n));
1260
- }
1261
- function Tr(e, t) {
1262
- const r = t.params || {};
1263
- Z(e, Y(r, "be.params")), r.panel_state && (e.panel = ae(r.panel_state)), r.structured_context && (e.panel = Xe(e.panel, ae(r.structured_context)));
1264
- const n = Q({
1265
- searchParams: r.search_params,
1266
- flowParams: r.flow_params
1267
- });
1268
- n && (e.route = n);
1269
- }
1270
- function Cr(e, t) {
1271
- if (!t || typeof t != "object") return;
1272
- t.intent && (e.intent = fe(t.intent));
1273
- const r = Q({
1274
- searchParams: t.search_params,
1275
- flowParams: t.flow_params
1276
- });
1277
- r && (e.route = r);
1278
- }
1279
- function Z(e, t) {
1280
- !t || typeof t != "object" || (t.panel && (e.panel = Xe(e.panel, t.panel)), t.threadExtensions && (e.threadExtensions = {
1281
- ...e.threadExtensions,
1282
- ...t.threadExtensions
1283
- }), t.pageProduct && (e.pageProduct = t.pageProduct), t.products && (e.products = t.products), t.ui && (e.ui = t.ui), t.intent && (e.intent = t.intent), t.route && (e.route = t.route));
1284
- }
1285
- function Xe(e, t) {
1286
- return e ? t ? E({
1287
- ...e,
1288
- ...t
1289
- }) : e : t || null;
1290
- }
1291
- function S(e, t, r, n, o = "done") {
1292
- e.timeline.push(E({
1293
- id: t.id,
1294
- at: t.at,
1295
- label: r,
1296
- detail: y(n, pe),
1297
- status: o === "info" ? "done" : o,
1298
- kind: t.kind
1299
- }));
1300
- }
1301
- function fe(e) {
1302
- return !e || typeof e != "object" ? null : E({
1303
- kind: y(e.kind || e.intent || e.type),
1304
- target: y(e.target),
1305
- confidence: typeof e.confidence == "number" ? Math.round(e.confidence * 100) / 100 : void 0
1306
- });
1307
- }
1308
- function Q({ searchParams: e, flowParams: t } = {}) {
1309
- const r = E({
1310
- search: Ar(e),
1311
- flow: Rr(t)
1312
- });
1313
- return Object.keys(r).length ? r : null;
1314
- }
1315
- function Ar(e) {
1316
- return !e || typeof e != "object" ? null : E({
1317
- query: y(e.query || e.search_query),
1318
- category: y(e.category || e.category_name || e.categoryName),
1319
- categoryId: y(e.categoryId || e.category_id),
1320
- limit: me(e.limit),
1321
- facets: Array.isArray(e.facets) ? e.facets.length : void 0
1322
- });
1323
- }
1324
- function Rr(e) {
1325
- return !e || typeof e != "object" ? null : E({
1326
- target: y(e.target),
1327
- sku: y(e.sku || e.product_sku),
1328
- skus: q(e.skus || e.sku_list),
1329
- action: y(e.action || e.action_type)
1330
- });
1331
- }
1332
- function Pr(e) {
1333
- if (!e || typeof e != "object") return {};
1334
- const t = {};
1335
- for (const [r, n] of Object.entries(e))
1336
- n != null && (t[r] = n && typeof n == "object" ? E({
1337
- keys: Object.keys(n).slice(0, 8),
1338
- summary: y(n.summary || n.occasion || n.target_date_iso || n.type)
1339
- }) : y(n));
1340
- return t;
1341
- }
1342
- function Lr(e) {
1343
- return !e || typeof e != "object" ? null : E({
1344
- query: y(e.query),
1345
- source: y(e.source),
1346
- category: y(e.category || e.category_name),
1347
- count: me(e.count)
1348
- });
1349
- }
1350
- function I(e) {
1351
- if (!Array.isArray(e)) return null;
1352
- const t = e.filter(Boolean);
1353
- return E({
1354
- count: t.length,
1355
- skus: q(t.map((r) => r?.sku || r?.code || r?.id)),
1356
- names: q(t.map((r) => r?.name || r?.title), 4)
1357
- });
1358
- }
1359
- function jr(e, t, r) {
1360
- if (t.type === "ProductDetailsPanel") return I([r.product || r.item].filter(Boolean));
1361
- if (t.type === "ProductGrid") {
1362
- const n = Nr(r.products, r.items, r.cards);
1363
- return I(n || Ir(e, t));
1364
- }
1365
- return I(r.products || r.items || r.cards);
1366
- }
1367
- function Nr(...e) {
1368
- return e.find((t) => Array.isArray(t)) || null;
1369
- }
1370
- function Ir(e, t) {
1371
- const r = e.elements || {};
1372
- return (Array.isArray(t.children) ? t.children : []).map((n) => r[n]).filter((n) => n?.type === "ProductCard").map((n) => n.props?.product || n.props?.item || n.props).filter(Boolean);
1373
- }
1374
- function Ur(e) {
1375
- return !e || typeof e != "object" ? null : E({
1376
- sku: y(e.sku || e.code || e.id),
1377
- name: y(e.name || e.title),
1378
- category: y(e.category),
1379
- url: y(e.url)
1380
- });
1381
- }
1382
- function qr(e) {
1383
- const t = e.elements || {};
1384
- return t[e.root || "root"] || t.root || e.rootElement || null;
1385
- }
1386
- function q(e, t = wr) {
1387
- if (!Array.isArray(e)) return;
1388
- const r = e.map((n) => y(n)).filter(Boolean);
1389
- return r.length ? r.slice(0, t) : void 0;
1390
- }
1391
- function te(e) {
1392
- return [...new Set(e.map((t) => y(t)).filter(Boolean))];
1393
- }
1394
- function me(e) {
1395
- return Number.isFinite(Number(e)) ? Number(e) : void 0;
1396
- }
1397
- function Fr(e) {
1398
- return /error$/u.test(e) ? "error" : /start$/u.test(e) ? "running" : "done";
1399
- }
1400
- function y(e, t = pe) {
1401
- const r = String(e ?? "").replace(/\s+/gu, " ").trim();
1402
- return r.length > t ? `${r.slice(0, t - 1)}...` : r;
1403
- }
1404
- function E(e) {
1405
- return Object.fromEntries(Object.entries(e || {}).filter(([, t]) => t == null || t === "" ? !1 : Array.isArray(t) ? t.length > 0 : typeof t == "object" ? Object.keys(t).length > 0 : !0));
1406
- }
1407
- function Br(e, t) {
1408
- if (!e || typeof e != "object" || !t) return e;
1409
- const r = { ...e };
1410
- for (const [n, o] of Object.entries(e))
1411
- typeof o != "function" || o.__gengageActivityWrapped || (r[n] = async function(a, ...s) {
1412
- t.record({
1413
- kind: "tool/start",
1414
- tool: n,
1415
- params: a
1416
- });
1417
- try {
1418
- const d = await o.call(this, a, ...s);
1419
- return t.record({
1420
- kind: "tool/done",
1421
- tool: n,
1422
- params: a,
1423
- result: Zr(d),
1424
- state: Y(d, `tool:${n}`)
1425
- }), d;
1426
- } catch (d) {
1427
- throw t.record({
1428
- kind: "tool/error",
1429
- tool: n,
1430
- params: a,
1431
- error: F(d)
1432
- }), d;
1433
- }
1434
- }, Object.defineProperty(r[n], "__gengageActivityWrapped", { value: !0 }));
1435
- return r;
1436
- }
1437
- function Or(e, t) {
1438
- return t ? (r) => (t.record({
1439
- kind: "beacon",
1440
- payload: r
1441
- }), e?.(r)) : e;
1442
- }
1443
- function Mr(e, t) {
1444
- if (!t) return !1;
1445
- const r = window.GengageAssistantInjector?.[e], n = r?.streamTransport;
1446
- if (typeof n != "function" || n.__gengageActivityWrapped) return !1;
1447
- const o = function(a, s, d, c) {
1448
- t.record({
1449
- kind: "flow/request",
1450
- request: a
1451
- });
1452
- try {
1453
- const p = n.call(this, a, Dr(s, t), d, c);
1454
- return p && typeof p.then == "function" ? p.catch((b) => {
1455
- throw t.record({
1456
- kind: "flow/rejected",
1457
- requestType: a?.type,
1458
- error: F(b)
1459
- }), b;
1460
- }) : p;
1461
- } catch (p) {
1462
- throw t.record({
1463
- kind: "flow/thrown",
1464
- requestType: a?.type,
1465
- error: F(p)
1466
- }), p;
1467
- }
1468
- };
1469
- return Object.defineProperty(o, "__gengageActivityWrapped", { value: !0 }), r.streamTransport = o, t.record({
1470
- kind: "runtime/transport-wrapped",
1471
- title: "streamTransport wrapped"
1472
- }), !0;
1473
- }
1474
- function $r({ accountId: e, collector: t, promptBaseUrl: r } = {}) {
1475
- if (!t || window.__GENGAGE_ACTIVITY_FETCH_PATCHED__) return;
1476
- window.__GENGAGE_ACTIVITY_FETCH_PATCHED__ = !0;
1477
- const n = window.fetch?.bind(window);
1478
- typeof n == "function" && (window.fetch = async (o, i) => {
1479
- const a = Vr(o, i), s = Jr(a.url);
1480
- let d = "";
1481
- s && (d = a.body?.op_name || a.body?.op || "unknown", t.record({
1482
- kind: "be/request",
1483
- source: "main-thread-fetch",
1484
- url: a.url,
1485
- op: d,
1486
- opDomain: a.body?.op_domain || "",
1487
- prompt: await Gr({
1488
- accountId: e,
1489
- opName: d,
1490
- promptBaseUrl: r
1491
- }),
1492
- params: a.body?.op_payload || {},
1493
- rawBody: a.body
1494
- }));
1495
- const c = await n(o, i);
1496
- return s && c.clone().text().then((p) => {
1497
- const b = Yr(p);
1498
- t.record({
1499
- kind: "be/response",
1500
- source: "main-thread-fetch",
1501
- url: a.url,
1502
- status: c.status,
1503
- op: d,
1504
- result: b,
1505
- rawText: p
1506
- }), et(t, b);
1507
- }).catch((p) => {
1508
- t.record({
1509
- kind: "be/response",
1510
- source: "main-thread-fetch",
1511
- url: a.url,
1512
- status: c.status,
1513
- op: d,
1514
- error: F(p)
1515
- });
1516
- }), c;
1517
- });
1518
- }
1519
- function Dr(e, t) {
1520
- if (!e || e.__gengageActivityWrapped) return e;
1521
- const r = { ...e };
1522
- Object.defineProperty(r, "__gengageActivityWrapped", { value: !0 });
1523
- for (const n of [
1524
- "onAction",
1525
- "onMetadata",
1526
- "onUISpec",
1527
- "onTextChunk",
1528
- "onError",
1529
- "onDone"
1530
- ])
1531
- typeof e[n] == "function" && (r[n] = (...o) => (n === "onAction" ? t.record({
1532
- kind: "flow/action",
1533
- event: o[0]
1534
- }) : n === "onMetadata" ? t.record({
1535
- kind: "flow/metadata",
1536
- event: o[0]
1537
- }) : n === "onUISpec" ? t.record({
1538
- kind: "flow/ui",
1539
- widget: o[1],
1540
- panelHint: o[2],
1541
- clearPanel: o[3] === !0,
1542
- spec: o[0]
1543
- }) : n === "onTextChunk" && o[1] === !0 ? t.record({
1544
- kind: "flow/text-final",
1545
- content: o[0],
1546
- extra: o[2]
1547
- }) : n === "onError" ? t.record({
1548
- kind: "flow/error",
1549
- error: F(o[0])
1550
- }) : n === "onDone" && t.record({ kind: "flow/done" }), e[n](...o)));
1551
- return r;
1552
- }
1553
- function Re(e, t) {
1554
- !e || !t || (e.record(t), t.kind === "be/response" && et(e, t.result));
1555
- }
1556
- async function Gr({ accountId: e, opName: t, promptBaseUrl: r }) {
1557
- if (!e || !t) return null;
1558
- const n = zr({
1559
- accountId: e,
1560
- baseId: String(e).replace(/-agentic$/u, ""),
1561
- promptBaseUrl: r
1562
- });
1563
- if (!n) return { error: "Configure agenticActivityPromptBaseUrl to inspect prompt source in this build." };
1564
- try {
1565
- const o = new URL(`${t}.yaml`, n).href, i = await fetch(o, { cache: "no-store" });
1566
- return i.ok ? {
1567
- url: o,
1568
- yaml: await i.text()
1569
- } : {
1570
- url: o,
1571
- error: `HTTP ${i.status}`
1572
- };
1573
- } catch (o) {
1574
- return { error: F(o) };
1575
- }
1576
- }
1577
- function zr({ accountId: e, baseId: t, promptBaseUrl: r }) {
1578
- if (typeof r == "string" && r.trim()) return r;
1579
- const n = Hr(e, t);
1580
- return n || Wr(t);
1581
- }
1582
- function Hr(e, t) {
1583
- const r = window.__GENGAGE_AGENTIC_PROMPT_BASE_URL__;
1584
- if (typeof r == "string" && r.trim()) return r;
1585
- if (r && typeof r == "object") {
1586
- const o = r[e] || r[t];
1587
- if (typeof o == "string" && o.trim()) return o;
1588
- }
1589
- const n = (window.GengageInjectorConfig?.[e] || window.GengageInjectorConfig?.[t])?.agenticActivityPromptBaseUrl;
1590
- return typeof n == "string" && n.trim() ? n : null;
1591
- }
1592
- function Wr(e) {
1593
- const t = Array.from(document.scripts || []);
1594
- for (const r of t) {
1595
- const n = r?.src || "";
1596
- if (n.includes("/agentic/index.js")) return new URL(`../prompts/${e}/`, n).href;
1597
- if (n.includes("/agentic.iife.js")) return new URL(`prompts/${e}/`, n).href;
1598
- }
1599
- return null;
1600
- }
1601
- function et(e, t) {
1602
- const r = t?.intent;
1603
- r && e.record({
1604
- kind: "intent/selected",
1605
- intent: r,
1606
- searchParams: t?.search_params,
1607
- flowParams: t?.flow_params
1608
- });
1609
- }
1610
- function Vr(e, t) {
1611
- const r = typeof e == "string" ? e : e?.url || "", n = t?.body || (typeof e != "string" ? e?.body : null);
1612
- return {
1613
- url: String(r || ""),
1614
- body: Kr(n)
1615
- };
1616
- }
1617
- function Kr(e) {
1618
- if (!e || typeof e != "string") return {};
1619
- try {
1620
- return JSON.parse(e);
1621
- } catch {
1622
- return { raw: e };
1623
- }
1624
- }
1625
- function Jr(e) {
1626
- try {
1627
- const t = new URL(e, window.location.href);
1628
- return t.pathname === "/v1/execute" && /agentic\.gengage\.ai$/u.test(t.hostname);
1629
- } catch {
1630
- return !1;
1631
- }
1632
- }
1633
- function Yr(e) {
1634
- const t = {};
1635
- for (const r of String(e || "").split(/\r?\n/u)) {
1636
- const n = r.trim();
1637
- if (n)
1638
- try {
1639
- Object.assign(t, JSON.parse(n));
1640
- } catch {
1641
- t._raw = [t._raw, n].filter(Boolean).join(`
1642
- `);
1643
- }
1644
- }
1645
- return t;
1646
- }
1647
- function Zr(e) {
1648
- if (Array.isArray(e)) return {
1649
- type: "array",
1650
- length: e.length,
1651
- preview: e.slice(0, 5)
1652
- };
1653
- if (!e || typeof e != "object") return e;
1654
- const t = {};
1655
- for (const [r, n] of Object.entries(e)) Array.isArray(n) ? t[r] = {
1656
- type: "array",
1657
- length: n.length,
1658
- preview: n.slice(0, 5)
1659
- } : n && typeof n == "object" ? t[r] = {
1660
- type: "object",
1661
- keys: Object.keys(n).slice(0, 20)
1662
- } : t[r] = n;
1663
- return t;
1664
- }
1665
- function F(e) {
1666
- return e?.message || String(e);
1667
- }
1668
- var Pe = "gengage-agentic-activity-overlay", z = "all", se = "all", Le = [
1669
- "Flow",
1670
- "Tools",
1671
- "Backend",
1672
- "Intent",
1673
- "Telemetry",
1674
- "Runtime"
1675
- ], je = [
1676
- "info",
1677
- "warn",
1678
- "error"
1679
- ];
1680
- function Qr(e) {
1681
- if (!e || typeof e.subscribe != "function") return null;
1682
- const t = document.getElementById(Pe);
1683
- if (t?.shadowRoot) return t;
1684
- const r = document.createElement("div");
1685
- r.id = Pe, r.style.cssText = "position:fixed;left:10px;top:10px;bottom:10px;z-index:2147483647;";
1686
- const n = r.attachShadow({ mode: "open" });
1687
- n.innerHTML = Sn(e.accountId), document.documentElement.appendChild(r);
1688
- const o = {
1689
- entries: [],
1690
- section: z,
1691
- severity: se,
1692
- search: "",
1693
- grouped: !1,
1694
- follow: !0,
1695
- stateVisible: !0,
1696
- verbose: !1
1697
- }, i = {
1698
- stateView: n.querySelector('[data-role="state-view"]'),
1699
- list: n.querySelector('[data-role="list"]'),
1700
- count: n.querySelector('[data-role="count"]'),
1701
- visibleCount: n.querySelector('[data-role="visible-count"]'),
1702
- panel: n.querySelector('[data-role="panel"]'),
1703
- search: n.querySelector('[data-role="search"]'),
1704
- sections: n.querySelector('[data-role="section-filters"]'),
1705
- severities: n.querySelector('[data-role="severity-filters"]'),
1706
- groupToggle: n.querySelector('[data-action="group"]'),
1707
- followToggle: n.querySelector('[data-action="follow"]'),
1708
- stateToggle: n.querySelector('[data-action="state"]'),
1709
- verboseToggle: n.querySelector('[data-action="verbose"]')
1710
- };
1711
- Xr(r, i.list);
1712
- const a = () => tn(i, o), s = n.querySelector('[data-role="filters-popup"]'), d = n.querySelector('[data-action="filters-toggle"]');
1713
- return d?.addEventListener("click", () => {
1714
- const c = s.classList.toggle("is-hidden") === !1;
1715
- d.setAttribute("aria-pressed", String(c));
1716
- }), n.addEventListener("click", (c) => {
1717
- s.classList.contains("is-hidden") || s.contains(c.target) || d.contains(c.target) || (s.classList.add("is-hidden"), d.setAttribute("aria-pressed", "false"));
1718
- }), n.querySelector('[data-action="clear"]')?.addEventListener("click", () => e.clear()), n.querySelector('[data-action="toggle"]')?.addEventListener("click", (c) => {
1719
- const p = i.panel.classList.toggle("is-minimized");
1720
- c.currentTarget.textContent = p ? "Open" : "Min", r.style.bottom = p ? "auto" : "10px";
1721
- }), i.search?.addEventListener("input", () => {
1722
- o.search = i.search.value || "", a();
1723
- }), i.sections?.addEventListener("click", (c) => {
1724
- const p = c.target?.closest?.("[data-section-filter]")?.dataset?.sectionFilter;
1725
- p && (o.section = p, a());
1726
- }), i.severities?.addEventListener("click", (c) => {
1727
- const p = c.target?.closest?.("[data-severity-filter]")?.dataset?.severityFilter;
1728
- p && (o.severity = p, a());
1729
- }), i.groupToggle?.addEventListener("click", () => {
1730
- o.grouped = !o.grouped, i.groupToggle.setAttribute("aria-pressed", String(o.grouped)), i.groupToggle.textContent = o.grouped ? "Grouped" : "Flat", a();
1731
- }), i.followToggle?.addEventListener("click", () => {
1732
- o.follow = !o.follow, i.followToggle.setAttribute("aria-pressed", String(o.follow)), i.followToggle.textContent = o.follow ? "Follow" : "Paused";
1733
- }), i.stateToggle?.addEventListener("click", () => {
1734
- o.stateVisible = !o.stateVisible, i.stateToggle.setAttribute("aria-pressed", String(o.stateVisible)), i.stateToggle.textContent = o.stateVisible ? "State" : "State off", a();
1735
- }), i.verboseToggle?.addEventListener("click", () => {
1736
- o.verbose = !o.verbose, i.verboseToggle.setAttribute("aria-pressed", String(o.verbose)), i.verboseToggle.textContent = o.verbose ? "Verbose" : "Concise", a();
1737
- }), n.querySelector('[data-action="expand-all"]')?.addEventListener("click", () => {
1738
- i.list?.querySelectorAll("details").forEach((c) => {
1739
- c.open = !0;
1740
- });
1741
- }), n.querySelector('[data-action="collapse-all"]')?.addEventListener("click", () => {
1742
- i.list?.querySelectorAll("details").forEach((c) => {
1743
- c.open = !1;
1744
- });
1745
- }), i.list?.addEventListener("click", (c) => {
1746
- const p = c.target?.closest?.('[data-action="copy-json"]');
1747
- if (!p) return;
1748
- const b = Number(p.dataset.entryId || 0);
1749
- xn(o.entries.find((m) => m.id === b), p);
1750
- }), e.subscribe((c, p) => {
1751
- o.entries = p.slice(), a();
1752
- }), r;
1753
- }
1754
- function Xr(e, t) {
1755
- e.addEventListener("wheel", (r) => {
1756
- const n = en(r.composedPath?.() || [], t);
1757
- n && (n.scrollTop += r.deltaY, n.scrollLeft += r.deltaX, r.preventDefault(), r.stopPropagation());
1758
- }, {
1759
- passive: !1,
1760
- capture: !0
1761
- });
1762
- }
1763
- function en(e, t) {
1764
- for (const r of e)
1765
- if (!(!r || r.nodeType !== 1) && Ne(r))
1766
- return r;
1767
- return Ne(t) ? t : null;
1768
- }
1769
- function Ne(e) {
1770
- return !!(e && (e.scrollHeight > e.clientHeight + 1 || e.scrollWidth > e.clientWidth + 1) && getComputedStyle(e).overflow !== "hidden");
1771
- }
1772
- function tn(e, t) {
1773
- const r = rn(t.entries, t), n = r.slice(-260).reverse();
1774
- Ie(e.sections, t.entries, t.section, "section"), Ie(e.severities, t.entries, t.severity, "severity"), e.count && (e.count.textContent = String(t.entries.length)), e.visibleCount && (e.visibleCount.textContent = String(r.length)), sn(e.stateView, vr(t.entries), t.stateVisible), an(e.list, n, t);
1775
- }
1776
- function rn(e, t = {}) {
1777
- const r = t.section || z, n = t.severity || se, o = nt(t.search), i = t.verbose === !0;
1778
- return (Array.isArray(e) ? e : []).filter((a) => !i && a.noise === !0 || r !== z && a.section !== r || n !== se && a.severity !== n ? !1 : o ? _n(a).includes(o) : !0);
1779
- }
1780
- function Ie(e, t, r, n) {
1781
- if (!e) return;
1782
- e.textContent = "";
1783
- const o = n === "section" ? nn(t) : on(t), i = document.createElement("button");
1784
- i.type = "button", i.dataset[`${n}Filter`] = z, i.className = r === z ? "chip is-active" : "chip", i.textContent = `All ${t.length}`, e.appendChild(i);
1785
- for (const a of o) {
1786
- const s = t.filter((c) => c[n] === a).length, d = document.createElement("button");
1787
- d.type = "button", d.dataset[`${n}Filter`] = a, d.className = r === a ? `chip is-active ${n}-${B(a)}` : `chip ${n}-${B(a)}`, d.textContent = `${at(a)} ${s}`, e.appendChild(d);
1788
- }
1789
- }
1790
- function nn(e) {
1791
- const t = new Set(e.map((r) => r.section).filter(Boolean));
1792
- return Le.filter((r) => t.has(r)).concat([...t].filter((r) => !Le.includes(r)).sort());
1793
- }
1794
- function on(e) {
1795
- const t = new Set(e.map((r) => r.severity).filter(Boolean));
1796
- return je.filter((r) => t.has(r)).concat([...t].filter((r) => !je.includes(r)).sort());
1797
- }
1798
- function an(e, t, r) {
1799
- if (!e) return;
1800
- if (e.textContent = "", !t.length) {
1801
- const o = document.createElement("div");
1802
- o.className = "empty", o.textContent = r.entries.length ? "No activity matches the current filters." : "Waiting for agentic activity...", e.appendChild(o);
1803
- return;
1804
- }
1805
- const n = document.createDocumentFragment();
1806
- if (r.grouped) for (const o of yn(t)) n.appendChild(wn(o));
1807
- else for (const o of t) n.appendChild(rt(o));
1808
- e.appendChild(n), r.follow && requestAnimationFrame(() => e.scrollTop = 0);
1809
- }
1810
- function sn(e, t, r) {
1811
- if (!e || (e.textContent = "", e.classList.toggle("is-hidden", !r), !r)) return;
1812
- const { flow: n, context: o } = t, i = document.createDocumentFragment();
1813
- i.appendChild(cn(n)), i.appendChild(ln(o)), i.appendChild(un(n.timeline)), e.appendChild(i);
1814
- }
1815
- function cn(e) {
1816
- const t = document.createElement("section");
1817
- return t.className = `viz-card flow-card status-${B(e.status)}`, t.appendChild(ge("Flow State", e.status)), tt(t, [
1818
- ["Current", e.current],
1819
- ["Session", e.sessionId],
1820
- ["Request", [e.requestType, e.actionType].filter(Boolean).join(" / ")],
1821
- ["Model", e.model],
1822
- ["Tools", e.tools?.join(", ")],
1823
- ["BE ops", e.beOps?.join(", ")],
1824
- ["UI", e.uiSurfaces?.join(", ")],
1825
- ["Health", dn(e)]
1826
- ]), t;
1827
- }
1828
- function ln(e) {
1829
- const t = document.createElement("section");
1830
- return t.className = "viz-card context-card", t.appendChild(ge("Context State", e.panel?.screenType || e.ui?.rootType || "empty")), tt(t, [
1831
- ["Intent", pn(e.intent)],
1832
- ["Route", fn(e.route)],
1833
- ["Screen", mn(e)],
1834
- ["Last search", gn(e.panel?.lastSearch)],
1835
- ["Products", hn(e.panel, e.products)],
1836
- ["Page product", bn(e.pageProduct)],
1837
- ["Extensions", Object.keys(e.threadExtensions || {}).join(", ")],
1838
- ["Last text", e.lastText]
1839
- ]), t;
1840
- }
1841
- function un(e) {
1842
- const t = document.createElement("section");
1843
- t.className = "viz-card timeline-card", t.appendChild(ge("Flow Timeline", `${e.length} steps`));
1844
- const r = document.createElement("ol");
1845
- if (r.className = "timeline", e.length)
1846
- for (const n of e) {
1847
- const o = document.createElement("li");
1848
- o.className = `timeline-step step-${B(n.status || "done")}`;
1849
- const i = document.createElement("span");
1850
- i.className = "timeline-time", i.textContent = it(n.at);
1851
- const a = document.createElement("span");
1852
- a.className = "timeline-label", a.textContent = n.label || n.kind || "Step";
1853
- const s = document.createElement("span");
1854
- s.className = "timeline-detail", s.textContent = n.detail || n.kind || "", o.append(i, a, s), r.appendChild(o);
1855
- }
1856
- else {
1857
- const n = document.createElement("li");
1858
- n.className = "timeline-empty", n.textContent = "No flow events yet.", r.appendChild(n);
1859
- }
1860
- return t.appendChild(r), t;
1861
- }
1862
- function ge(e, t) {
1863
- const r = document.createElement("div");
1864
- r.className = "viz-title";
1865
- const n = document.createElement("span");
1866
- n.textContent = e;
1867
- const o = document.createElement("span");
1868
- return o.className = "viz-badge", o.textContent = t || "idle", r.append(n, o), r;
1869
- }
1870
- function tt(e, t) {
1871
- for (const [r, n] of t) {
1872
- if (n == null || n === "") continue;
1873
- const o = document.createElement("div");
1874
- o.className = "viz-row";
1875
- const i = document.createElement("span");
1876
- i.className = "viz-key", i.textContent = r;
1877
- const a = document.createElement("span");
1878
- a.className = "viz-value", a.textContent = String(n), o.append(i, a), e.appendChild(o);
1879
- }
1880
- }
1881
- function dn(e) {
1882
- return !e.errors && !e.warnings ? "clean" : `${e.errors || 0} errors, ${e.warnings || 0} warnings`;
1883
- }
1884
- function pn(e) {
1885
- return e ? [
1886
- e.kind,
1887
- e.target,
1888
- e.confidence != null ? `conf ${e.confidence}` : ""
1889
- ].filter(Boolean).join(" / ") : "";
1890
- }
1891
- function fn(e) {
1892
- return e ? [e.search ? [
1893
- e.search.query,
1894
- e.search.category,
1895
- e.search.categoryId,
1896
- e.search.facets ? `${e.search.facets} facets` : ""
1897
- ].filter(Boolean).join(" / ") : "", e.flow ? [
1898
- e.flow.target,
1899
- e.flow.sku,
1900
- e.flow.skus?.join(", "),
1901
- e.flow.action
1902
- ].filter(Boolean).join(" / ") : ""].filter(Boolean).join(" -> ") : "";
1903
- }
1904
- function mn(e) {
1905
- const t = e.panel || {}, r = e.ui || {};
1906
- return [
1907
- t.screenType,
1908
- r.rootType,
1909
- r.widget,
1910
- r.panelHint
1911
- ].filter(Boolean).join(" / ");
1912
- }
1913
- function gn(e) {
1914
- return e ? [
1915
- e.query,
1916
- e.source,
1917
- e.category,
1918
- e.count != null ? `${e.count} results` : ""
1919
- ].filter(Boolean).join(" / ") : "";
1920
- }
1921
- function hn(e, t) {
1922
- const r = e?.productSkus || e?.screenSkus || t?.skus || [], n = e?.productCount ?? t?.count;
1923
- return n == null && !r.length ? "" : [`${n ?? r.length} products`, r.join(", ")].filter(Boolean).join(" / ");
1924
- }
1925
- function bn(e) {
1926
- return e ? [
1927
- e.sku,
1928
- e.name,
1929
- e.category
1930
- ].filter(Boolean).join(" / ") : "";
1931
- }
1932
- function yn(e) {
1933
- const t = /* @__PURE__ */ new Map();
1934
- for (const r of e) {
1935
- const n = `${r.section || "Runtime"}:${r.group || r.kind}`, o = t.get(n) || {
1936
- key: n,
1937
- section: r.section || "Runtime",
1938
- severity: r.severity || "info",
1939
- title: r.group || r.kind,
1940
- entries: []
1941
- };
1942
- o.entries.push(r), o.severity = kn(o.severity, r.severity), t.set(n, o);
1943
- }
1944
- return [...t.values()];
1945
- }
1946
- function wn(e) {
1947
- const t = document.createElement("section");
1948
- t.className = `group group-${B(e.severity)}`, t.dataset.section = e.section;
1949
- const r = document.createElement("div");
1950
- r.className = "group-head";
1951
- const n = document.createElement("span");
1952
- n.className = "section", n.textContent = e.section;
1953
- const o = document.createElement("span");
1954
- o.className = "group-title", o.textContent = e.title;
1955
- const i = document.createElement("span");
1956
- i.className = "group-count", i.textContent = String(e.entries.length), r.append(n, o, i), t.appendChild(r);
1957
- for (const a of e.entries) t.appendChild(rt(a));
1958
- return t;
1959
- }
1960
- function rt(e) {
1961
- const t = document.createElement("details");
1962
- t.dataset.entryId = String(e.id || ""), t.dataset.section = e.section || "Runtime", t.dataset.severity = e.severity || "info", t.className = `entry entry-${B(e.severity || "info")}`, t.open = e.severity === "error";
1963
- const r = document.createElement("summary"), n = document.createElement("div");
1964
- n.className = "entry-meta";
1965
- const o = document.createElement("span");
1966
- o.className = "sev-dot";
1967
- const i = document.createElement("span");
1968
- i.className = "time", i.textContent = it(e.at);
1969
- const a = document.createElement("span");
1970
- a.className = "section", a.textContent = e.section || "Runtime";
1971
- const s = document.createElement("span");
1972
- if (s.className = "kind-chip", s.textContent = e.kind || "", n.append(o, i, a, s), e.severity === "warn" || e.severity === "error") {
1973
- const l = document.createElement("span");
1974
- l.className = "severity", l.textContent = at(e.severity), n.append(l);
1975
- }
1976
- const d = document.createElement("div");
1977
- d.className = "entry-title-row";
1978
- const c = document.createElement("span");
1979
- c.className = "caret", c.textContent = "▸";
1980
- const p = document.createElement("span");
1981
- p.className = "title", p.textContent = ot(e), d.append(c, p), r.append(n, d);
1982
- const b = document.createElement("div");
1983
- b.className = "entry-body";
1984
- const m = document.createElement("div");
1985
- if (m.className = "entry-toolbar", e.group) {
1986
- const l = document.createElement("span");
1987
- l.className = "kind", l.textContent = e.group, m.append(l);
1988
- }
1989
- const u = document.createElement("button");
1990
- u.type = "button", u.dataset.action = "copy-json", u.dataset.entryId = String(e.id || ""), u.textContent = "Copy JSON", m.append(u);
1991
- const f = document.createElement("pre"), g = document.createElement("code");
1992
- return g.innerHTML = vn(e), f.appendChild(g), b.append(m, f), t.append(r, b), t;
1993
- }
1994
- function vn(e) {
1995
- const t = he(e), r = /("(?:\\u[\da-fA-F]{4}|\\[^u]|[^\\"])*"(?:\s*:)?|\btrue\b|\bfalse\b|\bnull\b|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/gu;
1996
- let n = "", o = 0;
1997
- for (const i of t.matchAll(r)) {
1998
- const a = i[0];
1999
- n += G(t.slice(o, i.index));
2000
- let s = "json-number";
2001
- a.startsWith('"') ? s = a.endsWith(":") ? "json-key" : "json-string" : a === "true" || a === "false" ? s = "json-boolean" : a === "null" && (s = "json-null"), n += `<span class="${s}">${G(a)}</span>`, o = i.index + a.length;
2002
- }
2003
- return n + G(t.slice(o));
2004
- }
2005
- function xn(e, t) {
2006
- if (!e) return;
2007
- const r = he(e), n = () => {
2008
- const o = t.textContent;
2009
- t.textContent = "Copied", setTimeout(() => {
2010
- t.textContent = o;
2011
- }, 900);
2012
- };
2013
- if (navigator.clipboard?.writeText) {
2014
- navigator.clipboard.writeText(r).then(n).catch(() => Ue(r, n));
2015
- return;
2016
- }
2017
- Ue(r, n);
2018
- }
2019
- function Ue(e, t) {
2020
- const r = document.createElement("textarea");
2021
- r.value = e, r.style.cssText = "position:fixed;left:-9999px;top:-9999px;", document.body.appendChild(r), r.select();
2022
- try {
2023
- document.execCommand("copy"), t();
2024
- } finally {
2025
- r.remove();
2026
- }
2027
- }
2028
- function kn(e, t) {
2029
- const r = {
2030
- info: 0,
2031
- warn: 1,
2032
- error: 2
2033
- };
2034
- return (r[t] || 0) > (r[e] || 0) ? t : e;
2035
- }
2036
- function _n(e) {
2037
- return nt([
2038
- e.kind,
2039
- e.section,
2040
- e.severity,
2041
- e.group,
2042
- ot(e),
2043
- e.tool,
2044
- e.op,
2045
- e.request?.type,
2046
- e.request?.action?.type,
2047
- e.event?.name,
2048
- e.event?.action,
2049
- e.event?.type,
2050
- he(e)
2051
- ].join(" "));
2052
- }
2053
- function nt(e) {
2054
- return String(e || "").toLocaleLowerCase("tr-TR").trim();
2055
- }
2056
- function ot(e) {
2057
- if (e.kind === "flow/request") return e.request?.type || e.request?.action?.type || "request";
2058
- if (e.kind === "flow/action") return e.event?.name || e.event?.action || e.event?.type || "action";
2059
- if (e.kind === "flow/metadata") return e.event?.name || e.event?.phase || e.event?.type || "metadata";
2060
- if (e.kind === "flow/ui") return e.widget || e.panelHint || "ui";
2061
- if (e.kind === "flow/text-final") return En(e.content || "final text", 90);
2062
- if (e.kind === "be/request") return e.op || "BE request";
2063
- if (e.kind === "be/response") {
2064
- const t = e.result?.intent?.kind || e.result?.intent_kind || e.result?.kind;
2065
- return t ? `intent selected: ${t}` : e.op || "BE response";
2066
- }
2067
- return e.kind === "intent/selected" ? e.intent?.kind || e.kind : e.kind.startsWith("tool/") ? e.tool || "tool" : e.kind === "beacon" ? e.payload?.type || "beacon" : e.title || e.kind;
2068
- }
2069
- function Sn(e) {
2070
- return `
2071
- <style>
2072
- :host { all: initial; }
2073
- .panel {
2074
- width: 460px;
2075
- max-width: calc(100vw - 20px);
2076
- height: 100%;
2077
- max-height: 100%;
2078
- display: flex;
2079
- flex-direction: column;
2080
- overflow: hidden;
2081
- color: #1f2937;
2082
- background: rgba(255, 255, 255, 0.98);
2083
- border: 1px solid #b8c2d2;
2084
- border-radius: 8px;
2085
- box-shadow: 0 18px 48px rgba(17, 24, 39, 0.24);
2086
- font: 12px/1.4 Inter, Arial, sans-serif;
2087
- }
2088
- .head {
2089
- position: relative;
2090
- display: flex;
2091
- align-items: center;
2092
- justify-content: space-between;
2093
- gap: 10px;
2094
- padding: 9px 10px;
2095
- background: #111827;
2096
- color: #fff;
2097
- font-weight: 700;
2098
- }
2099
- .filters-popup {
2100
- position: absolute;
2101
- top: calc(100% + 4px);
2102
- right: 8px;
2103
- left: 8px;
2104
- z-index: 5;
2105
- display: flex;
2106
- flex-direction: column;
2107
- gap: 10px;
2108
- padding: 10px;
2109
- background: #fff;
2110
- color: #1f2937;
2111
- border: 1px solid #cbd5e1;
2112
- border-radius: 8px;
2113
- box-shadow: 0 14px 36px rgba(17, 24, 39, 0.28);
2114
- }
2115
- .filters-popup.is-hidden { display: none; }
2116
- .popup-group { display: flex; flex-direction: column; gap: 5px; }
2117
- .popup-label {
2118
- font-size: 10px;
2119
- font-weight: 800;
2120
- letter-spacing: 0.04em;
2121
- text-transform: uppercase;
2122
- color: #64748b;
2123
- }
2124
- .actions button[data-action="filters-toggle"][aria-pressed="true"] {
2125
- background: rgba(255, 255, 255, 0.28);
2126
- }
2127
- .meta { display: flex; gap: 7px; align-items: center; min-width: 0; }
2128
- .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
2129
- .count { color: #d1d5db; font-weight: 600; white-space: nowrap; }
2130
- .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
2131
- button {
2132
- appearance: none;
2133
- border: 1px solid rgba(255,255,255,0.34);
2134
- border-radius: 5px;
2135
- background: rgba(255,255,255,0.12);
2136
- color: inherit;
2137
- padding: 3px 7px;
2138
- font: inherit;
2139
- cursor: pointer;
2140
- }
2141
- button:hover { filter: brightness(1.08); }
2142
- .controls {
2143
- padding: 7px 8px;
2144
- background: #f8fafc;
2145
- border-bottom: 1px solid #d9dee7;
2146
- }
2147
- .search {
2148
- width: 100%;
2149
- box-sizing: border-box;
2150
- border: 1px solid #cbd5e1;
2151
- border-radius: 6px;
2152
- background: #fff;
2153
- color: #111827;
2154
- padding: 6px 8px;
2155
- font: inherit;
2156
- }
2157
- .filters, .toggles {
2158
- display: flex;
2159
- flex-wrap: wrap;
2160
- gap: 5px;
2161
- align-items: center;
2162
- }
2163
- .chip, .toggles button {
2164
- color: #334155;
2165
- border-color: #cbd5e1;
2166
- background: #fff;
2167
- font-weight: 650;
2168
- }
2169
- .chip.is-active, .toggles button[aria-pressed="true"] {
2170
- background: #111827;
2171
- border-color: #111827;
2172
- color: #fff;
2173
- }
2174
- .section-flow { border-color: #38bdf8; }
2175
- .section-tools { border-color: #34d399; }
2176
- .section-backend { border-color: #fb923c; }
2177
- .section-intent { border-color: #a78bfa; }
2178
- .section-telemetry { border-color: #2dd4bf; }
2179
- .severity-warn { border-color: #f59e0b; }
2180
- .severity-error { border-color: #ef4444; }
2181
- .list {
2182
- flex: 1.4 1 0;
2183
- min-height: 0;
2184
- overflow: auto;
2185
- overscroll-behavior: contain;
2186
- touch-action: pan-x pan-y;
2187
- padding: 8px;
2188
- background: #f1f5f9;
2189
- }
2190
- /* The state dashboard (flow + context + timeline) is the most valuable
2191
- trace surface, so it gets a real vertical share of the rail — a single
2192
- column (full width, nothing squeezed) that scrolls internally and is
2193
- capped to ~45% of the panel so the log below always stays visible. */
2194
- .state-view {
2195
- display: flex;
2196
- flex-direction: column;
2197
- gap: 8px;
2198
- padding: 8px;
2199
- background: #eef4fb;
2200
- border-bottom: 1px solid #d9dee7;
2201
- flex: 1 1 0;
2202
- min-height: 120px;
2203
- overflow: auto;
2204
- overscroll-behavior: contain;
2205
- }
2206
- .state-view.is-hidden { display: none; }
2207
- .viz-card {
2208
- min-width: 0;
2209
- /* In the flex-column state-view, keep each card at its natural content
2210
- height — never let flex shrink it to its title. The state-view
2211
- itself scrolls when the cards together exceed its cap. */
2212
- flex: none;
2213
- border: 1px solid #cbd5e1;
2214
- border-radius: 7px;
2215
- background: #fff;
2216
- overflow: hidden;
2217
- }
2218
- .viz-title {
2219
- display: flex;
2220
- justify-content: space-between;
2221
- gap: 8px;
2222
- align-items: center;
2223
- padding: 6px 8px;
2224
- background: #e2e8f0;
2225
- color: #172033;
2226
- font-weight: 800;
2227
- }
2228
- .viz-badge {
2229
- max-width: 48%;
2230
- overflow: hidden;
2231
- text-overflow: ellipsis;
2232
- white-space: nowrap;
2233
- padding: 1px 6px;
2234
- border-radius: 999px;
2235
- background: #fff;
2236
- border: 1px solid #cbd5e1;
2237
- color: #475569;
2238
- font-weight: 750;
2239
- }
2240
- .status-running .viz-title { background: #dbeafe; }
2241
- .status-done .viz-title { background: #dcfce7; }
2242
- .status-error .viz-title { background: #fee2e2; }
2243
- .viz-row {
2244
- display: grid;
2245
- grid-template-columns: 82px minmax(0, 1fr);
2246
- gap: 6px;
2247
- padding: 5px 8px;
2248
- border-top: 1px solid #eef2f7;
2249
- align-items: baseline;
2250
- }
2251
- .viz-key {
2252
- color: #64748b;
2253
- font-weight: 750;
2254
- }
2255
- /* Wrap rather than ellipsis so no state value is silently clipped. */
2256
- .viz-value {
2257
- color: #111827;
2258
- min-width: 0;
2259
- word-break: break-word;
2260
- overflow-wrap: anywhere;
2261
- }
2262
- .timeline {
2263
- list-style: none;
2264
- margin: 0;
2265
- padding: 0;
2266
- max-height: 122px;
2267
- overflow: auto;
2268
- }
2269
- .timeline-step, .timeline-empty {
2270
- display: grid;
2271
- grid-template-columns: 64px auto minmax(0, 1fr);
2272
- gap: 7px;
2273
- align-items: baseline;
2274
- padding: 5px 8px;
2275
- border-top: 1px solid #eef2f7;
2276
- }
2277
- .timeline-time {
2278
- color: #64748b;
2279
- font-variant-numeric: tabular-nums;
2280
- }
2281
- .timeline-label {
2282
- width: fit-content;
2283
- border-radius: 999px;
2284
- padding: 1px 7px;
2285
- background: #e2e8f0;
2286
- color: #334155;
2287
- font-weight: 750;
2288
- white-space: nowrap;
2289
- }
2290
- .timeline-detail {
2291
- min-width: 0;
2292
- word-break: break-word;
2293
- overflow-wrap: anywhere;
2294
- }
2295
- .step-running .timeline-label { background: #dbeafe; color: #1d4ed8; }
2296
- .step-warn .timeline-label { background: #fef3c7; color: #92400e; }
2297
- .step-error .timeline-label { background: #fee2e2; color: #991b1b; }
2298
- .empty { color: #64748b; padding: 10px; }
2299
- .group {
2300
- border: 1px solid #d6dce6;
2301
- border-radius: 7px;
2302
- margin: 0 0 8px;
2303
- background: #fff;
2304
- overflow: hidden;
2305
- }
2306
- .group-head {
2307
- display: grid;
2308
- grid-template-columns: auto minmax(0, 1fr) auto;
2309
- gap: 7px;
2310
- align-items: center;
2311
- padding: 6px 7px;
2312
- background: #e9eef6;
2313
- border-bottom: 1px solid #d6dce6;
2314
- font-weight: 750;
2315
- }
2316
- .group-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
2317
- .group-count {
2318
- min-width: 20px;
2319
- text-align: center;
2320
- color: #475569;
2321
- background: #fff;
2322
- border: 1px solid #cbd5e1;
2323
- border-radius: 999px;
2324
- padding: 1px 6px;
2325
- }
2326
- details.entry {
2327
- border: 1px solid #d6dce6;
2328
- border-left-width: 4px;
2329
- border-radius: 6px;
2330
- margin: 0 0 6px;
2331
- background: #fff;
2332
- overflow: hidden;
2333
- }
2334
- details.entry:hover { border-color: #b6c2d4; }
2335
- details.entry[open] { box-shadow: 0 1px 4px rgba(17, 24, 39, 0.1); }
2336
- .group details.entry {
2337
- border-left-width: 4px;
2338
- border-right-width: 0;
2339
- border-bottom-width: 0;
2340
- border-radius: 0;
2341
- margin: 0;
2342
- }
2343
- details[data-severity="info"] { border-left-color: #94a3b8; }
2344
- details[data-severity="warn"] { border-left-color: #f59e0b; }
2345
- details[data-severity="error"] { border-left-color: #ef4444; }
2346
- summary {
2347
- cursor: pointer;
2348
- padding: 6px 9px;
2349
- display: flex;
2350
- flex-direction: column;
2351
- gap: 3px;
2352
- color: #1f2937;
2353
- list-style: none;
2354
- }
2355
- summary::-webkit-details-marker { display: none; }
2356
- .entry-meta {
2357
- display: flex;
2358
- align-items: center;
2359
- gap: 7px;
2360
- flex-wrap: wrap;
2361
- }
2362
- .sev-dot {
2363
- width: 7px;
2364
- height: 7px;
2365
- border-radius: 50%;
2366
- background: #94a3b8;
2367
- flex: none;
2368
- }
2369
- [data-severity="warn"] .sev-dot { background: #f59e0b; }
2370
- [data-severity="error"] .sev-dot { background: #ef4444; }
2371
- .time { color: #64748b; font-variant-numeric: tabular-nums; font-size: 11px; }
2372
- .section, .severity {
2373
- padding: 1px 7px;
2374
- border-radius: 999px;
2375
- background: #eef2f7;
2376
- color: #334155;
2377
- font-weight: 700;
2378
- font-size: 11px;
2379
- letter-spacing: 0.01em;
2380
- }
2381
- .kind-chip {
2382
- color: #64748b;
2383
- font: 10px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
2384
- background: #f1f5f9;
2385
- border-radius: 4px;
2386
- padding: 1px 5px;
2387
- }
2388
- [data-section="Flow"] .section { background: #e0f2fe; color: #075985; }
2389
- [data-section="Tools"] .section { background: #dcfce7; color: #166534; }
2390
- [data-section="Backend"] .section { background: #ffedd5; color: #9a3412; }
2391
- [data-section="Intent"] .section { background: #ede9fe; color: #5b21b6; }
2392
- [data-section="Telemetry"] .section { background: #ccfbf1; color: #115e59; }
2393
- [data-severity="warn"] .severity { background: #fef3c7; color: #92400e; }
2394
- [data-severity="error"] .severity { background: #fee2e2; color: #991b1b; }
2395
- .entry-title-row {
2396
- display: flex;
2397
- gap: 6px;
2398
- align-items: baseline;
2399
- }
2400
- .caret {
2401
- color: #94a3b8;
2402
- flex: none;
2403
- transition: transform 0.12s ease;
2404
- font-size: 10px;
2405
- line-height: 1.5;
2406
- }
2407
- details[open] .caret { transform: rotate(90deg); }
2408
- /* Title wraps to full width — no truncation, no information loss. */
2409
- .title {
2410
- color: #1f2937;
2411
- font-weight: 600;
2412
- word-break: break-word;
2413
- overflow-wrap: anywhere;
2414
- }
2415
- details[data-severity="error"] .title { color: #991b1b; }
2416
- .entry-body { border-top: 1px solid #d6dce6; background: #0b1020; }
2417
- .entry-toolbar {
2418
- display: flex;
2419
- gap: 6px;
2420
- align-items: center;
2421
- padding: 6px 8px;
2422
- color: #dbeafe;
2423
- border-bottom: 1px solid rgba(148, 163, 184, 0.32);
2424
- }
2425
- .kind {
2426
- overflow: hidden;
2427
- text-overflow: ellipsis;
2428
- white-space: nowrap;
2429
- border: 1px solid rgba(148, 163, 184, 0.38);
2430
- border-radius: 999px;
2431
- padding: 2px 6px;
2432
- }
2433
- .entry-toolbar button {
2434
- margin-left: auto;
2435
- color: #e5e7eb;
2436
- border-color: rgba(148, 163, 184, 0.42);
2437
- background: rgba(255,255,255,0.08);
2438
- }
2439
- pre {
2440
- margin: 0;
2441
- padding: 8px;
2442
- max-height: 430px;
2443
- overflow: auto;
2444
- overscroll-behavior: contain;
2445
- touch-action: pan-x pan-y;
2446
- color: #dbeafe;
2447
- font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
2448
- white-space: pre-wrap;
2449
- word-break: break-word;
2450
- }
2451
- .json-key { color: #93c5fd; }
2452
- .json-string { color: #86efac; }
2453
- .json-number { color: #fbbf24; }
2454
- .json-boolean { color: #f0abfc; }
2455
- .json-null { color: #cbd5e1; }
2456
- /* Minimized: collapse to just the header. The body sections are hidden
2457
- AND the panel/host stop reserving full viewport height (the host's
2458
- inline bottom offset is released in JS), so only the title bar remains
2459
- and the page underneath is clickable again. */
2460
- .is-minimized { height: auto; max-height: none; }
2461
- .is-minimized .controls, .is-minimized .list { display: none; }
2462
- .is-minimized .state-view { display: none; }
2463
- .is-minimized .filters-popup { display: none; }
2464
- @media (max-width: 620px) {
2465
- .panel { width: calc(100vw - 20px); }
2466
- }
2467
- </style>
2468
- <div class="panel" data-role="panel">
2469
- <div class="head">
2470
- <div class="meta">
2471
- <span class="name" title="${G(e)}">${G(e)}</span>
2472
- <span class="count"><span data-role="visible-count">0</span>/<span data-role="count">0</span></span>
2473
- </div>
2474
- <div class="actions">
2475
- <button type="button" data-action="filters-toggle" aria-pressed="false" title="Filters & view options">Filters ▾</button>
2476
- <button type="button" data-action="clear">Clear</button>
2477
- <button type="button" data-action="toggle">Min</button>
2478
- </div>
2479
- <div class="filters-popup is-hidden" data-role="filters-popup">
2480
- <div class="popup-group">
2481
- <div class="popup-label">Section</div>
2482
- <div class="filters" data-role="section-filters"></div>
2483
- </div>
2484
- <div class="popup-group">
2485
- <div class="popup-label">Severity</div>
2486
- <div class="filters" data-role="severity-filters"></div>
2487
- </div>
2488
- <div class="popup-group">
2489
- <div class="popup-label">View</div>
2490
- <div class="toggles">
2491
- <button type="button" data-action="state" aria-pressed="true">State</button>
2492
- <button type="button" data-action="group" aria-pressed="false">Flat</button>
2493
- <button type="button" data-action="follow" aria-pressed="true">Follow</button>
2494
- <button type="button" data-action="verbose" aria-pressed="false">Concise</button>
2495
- <button type="button" data-action="expand-all">Expand all</button>
2496
- <button type="button" data-action="collapse-all">Collapse all</button>
2497
- </div>
2498
- </div>
2499
- </div>
2500
- </div>
2501
- <div class="controls">
2502
- <input class="search" type="search" data-role="search" placeholder="Filter by tool, op, kind, title, or JSON value" />
2503
- </div>
2504
- <div class="state-view" data-role="state-view"></div>
2505
- <div class="list" data-role="list"></div>
2506
- </div>
2507
- `;
2508
- }
2509
- function he(e) {
2510
- try {
2511
- return JSON.stringify(e, null, 2);
2512
- } catch {
2513
- return String(e);
2514
- }
2515
- }
2516
- function it(e) {
2517
- try {
2518
- return new Date(e || Date.now()).toLocaleTimeString();
2519
- } catch {
2520
- return "";
2521
- }
2522
- }
2523
- function En(e, t) {
2524
- const r = String(e || "");
2525
- return r.length > t ? `${r.slice(0, t - 1)}...` : r;
2526
- }
2527
- function at(e) {
2528
- const t = String(e || "");
2529
- return t ? `${t.slice(0, 1).toLocaleUpperCase("en-US")}${t.slice(1)}` : "";
2530
- }
2531
- function B(e) {
2532
- return String(e || "").toLocaleLowerCase("en-US").replace(/[^a-z0-9]+/gu, "-").replace(/^-|-$/gu, "");
2533
- }
2534
- function G(e) {
2535
- return String(e).replace(/[&<>"']/gu, (t) => t === "&" ? "&amp;" : t === "<" ? "&lt;" : t === ">" ? "&gt;" : t === '"' ? "&quot;" : "&#39;");
2536
- }
2537
- function oa({ accountId: e, config: t = {}, tools: r, beacon: n } = {}) {
2538
- if (!Tn(e, t)) return {
2539
- enabled: !1,
2540
- tools: r,
2541
- beacon: n,
2542
- record() {
2543
- },
2544
- wrapTransport() {
2545
- }
2546
- };
2547
- const o = fr(e);
2548
- return window.__GENGAGE_AGENTIC_DEBUG_RECORD__ = (i) => Re(o, i), window.__GENGAGE_AGENTIC_DEBUG_RECORD_BE__ = (i) => Re(o, i), Qr(o), $r({
2549
- accountId: e,
2550
- collector: o,
2551
- promptBaseUrl: t.agenticActivityPromptBaseUrl
2552
- }), o.record({
2553
- kind: "runtime/debug-enabled",
2554
- title: "Agentic activity debug enabled"
2555
- }), {
2556
- enabled: !0,
2557
- collector: o,
2558
- tools: Br(r, o),
2559
- beacon: Or(n, o),
2560
- record: (i) => o.record(i),
2561
- wrapTransport: () => Mr(e, o)
2562
- };
2563
- }
2564
- function Tn(e, t = {}) {
2565
- return t.agenticActivityDebug === !1 ? !1 : t.agenticActivityDebug === !0 || window.__GENGAGE_PWTEST_ACCOUNT__ === e || window.__GENGAGE_AGENTIC_ACTIVITY_DEBUG__ === !0 ? !0 : !!(t.debug === !0 && Cn(e));
2566
- }
2567
- function Cn(e) {
2568
- return Array.from(document.scripts || []).some((t) => {
2569
- const r = t?.src || "";
2570
- return r.includes(`/${e}/glov.js`) && /[?&]pwtest=/u.test(r);
2571
- });
2572
- }
2573
- var An = [
2574
- "sku",
2575
- "group_id",
2576
- "name",
2577
- "brand",
2578
- "rating",
2579
- "review_count",
2580
- "cart_code",
2581
- "images",
2582
- "price_currency",
2583
- "price",
2584
- "price_discounted",
2585
- "discount_reason",
2586
- "url",
2587
- "category_ids",
2588
- "category_names",
2589
- "facet_hits",
2590
- "in_stock",
2591
- "promotions",
2592
- "variants"
2593
- ], Rn = [
2594
- "description",
2595
- "description_html",
2596
- "features",
2597
- "service",
2598
- "sellers",
2599
- "reviews",
2600
- "qna",
2601
- "documents",
2602
- "delivery",
2603
- "payment"
2604
- ], Pn = [
2605
- "accountId",
2606
- "query",
2607
- "products",
2608
- "pendingProducts",
2609
- "rankedSkus",
2610
- "facets",
2611
- "facetsUsed",
2612
- "available_facets",
2613
- "logs",
2614
- "meta"
2615
- ], Ln = [
2616
- "source",
2617
- "sourceType",
2618
- "sourceProfile",
2619
- "products",
2620
- "queries",
2621
- "logs"
2622
- ], jn = [
2623
- "items",
2624
- "kind",
2625
- "label",
2626
- "href",
2627
- "count",
2628
- "privacy"
2629
- ];
2630
- function ia({ accountId: e, search: t, facetedSearch: r, similaritySearch: n, searchGiftOptions: o, filters: i = {}, resultContract: a = {}, limitations: s = [], extraTools: d = [] } = {}) {
2631
- return {
2632
- searchKeyword: async (p = {}, b = {}) => t(In(p, b)),
2633
- facetedSearch: typeof r == "function" ? (p = {}, b = {}) => r(qe(p, b)) : async (p = {}, b = {}) => t(qe(p, b)),
2634
- getSearchCapabilities: () => Nn({
2635
- accountId: e,
2636
- hasSimilarity: typeof n == "function",
2637
- hasGiftSearch: typeof o == "function",
2638
- filters: i,
2639
- resultContract: a,
2640
- limitations: s,
2641
- extraTools: d
2642
- })
2643
- };
2644
- }
2645
- function Nn({ accountId: e, hasSimilarity: t = !0, hasGiftSearch: r = !1, filters: n = {}, resultContract: o = {}, limitations: i = [], extraTools: a = [] } = {}) {
2646
- return {
2647
- accountId: e,
2648
- tools: Un([
2649
- "search",
2650
- "searchKeyword",
2651
- "facetedSearch",
2652
- r ? "searchGiftOptions" : "",
2653
- t ? "similaritySearch" : "",
2654
- "scanSite",
2655
- "siteGrep",
2656
- "discoverSiteContent",
2657
- "runSiteCommand",
2658
- "describeVisualContext",
2659
- "inspectProductSurface",
2660
- "openProductPage",
2661
- ...a
2662
- ].filter(Boolean)),
2663
- filters: {
2664
- query: "LLM-selected merchant search phrase or empty string when structured metadata is enough.",
2665
- categoryId: "Optional native merchant category id selected from account metadata or visible page state.",
2666
- categoryName: "Optional shopper-facing category label selected by the LLM/router.",
2667
- categoryHints: "Optional category hints supplied by the LLM/router.",
2668
- brandHints: "Optional brand hints supplied by the LLM/router.",
2669
- featureHints: "Optional feature, material, style, size, compatibility, or project hints supplied by the LLM/router.",
2670
- facets: "Optional structured facet array of { key, value } selected from route payloads or merchant metadata.",
2671
- facetParams: "Optional native account facet map selected from account metadata.",
2672
- priceMin: "Optional numeric lower price bound.",
2673
- priceMax: "Optional numeric upper price bound.",
2674
- ...n
2675
- },
2676
- resultContract: {
2677
- productItemFields: An,
2678
- productDetailFields: Rn,
2679
- searchResultFields: Pn,
2680
- similarityResultFields: Ln,
2681
- siteContentFields: jn,
2682
- ...o
2683
- },
2684
- privacy: [
2685
- "Runs in the shopper browser with merchant-origin state.",
2686
- "Does not expose raw HTML, cookies, storage, cart/session tokens, CSRF values, or form values.",
2687
- "Returns compact product, content, and visible-page facts only.",
2688
- "Free-text intent and search planning stay LLM-owned; runtime wrappers only forward structured inputs."
2689
- ],
2690
- limitations: i
2691
- };
2692
- }
2693
- function In(e, t) {
2694
- return ce(typeof e == "string" ? {
2695
- ...t,
2696
- query: e
2697
- } : {
2698
- ...t,
2699
- ...e || {}
2700
- });
2701
- }
2702
- function qe(e, t) {
2703
- const r = typeof e == "string" ? { query: e } : e || {}, n = r.query ?? t.query ?? "", o = ce({
2704
- ...t,
2705
- ...r,
2706
- query: n,
2707
- categoryId: r.categoryId ?? r.category_id ?? t.categoryId ?? t.category_id,
2708
- categoryName: r.categoryName ?? r.category_name ?? t.categoryName ?? t.category_name,
2709
- facets: r.facets ?? t.facets,
2710
- facetParams: r.facetParams ?? r.facet_params ?? t.facetParams ?? t.facet_params,
2711
- priceMin: r.priceMin ?? r.price_min ?? r.budgetMin ?? r.min_budget ?? t.priceMin,
2712
- priceMax: r.priceMax ?? r.price_max ?? r.budgetMax ?? r.max_budget ?? t.priceMax,
2713
- limit: r.limit ?? r.pageSize ?? t.limit ?? t.pageSize
2714
- });
2715
- return n === "" && (o.query = ""), o;
2716
- }
2717
- function Un(e) {
2718
- const t = /* @__PURE__ */ new Set();
2719
- return e.filter((r) => {
2720
- const n = String(r || "");
2721
- return !n || t.has(n) ? !1 : (t.add(n), !0);
2722
- });
2723
- }
2724
- function ce(e) {
2725
- return Object.fromEntries(Object.entries(e || {}).filter(([, t]) => t != null && t !== "" && (!Array.isArray(t) || t.length)));
2726
- }
2727
- var qn = 15e3, Fn = "glov_agentic_iframe", Bn = "position:absolute;width:1px;height:1px;left:-9999px;top:-9999px;opacity:0;pointer-events:none;";
2728
- function aa({ markerParam: e = Fn, markerValue: t = "agentic-scraper", frameName: r = t, sandbox: n = "allow-same-origin", timeoutMs: o = qn, hiddenStyle: i = Bn, messageType: a, parser: s, isBlockedDocument: d } = {}) {
2729
- const c = a || `gengage:agentic-iframe-scraper:${t}`;
2730
- function p(f, g = {}) {
2731
- const l = new URL(String(f), re());
2732
- for (const [h, w] of Object.entries(g || {})) w != null && w !== "" && l.searchParams.set(h, String(w));
2733
- return l.searchParams.set(e, t), l.href;
2734
- }
2735
- function b(f = globalThis.window?.location, g = globalThis.window?.name || "") {
2736
- if (g === r || g === t) return !0;
2737
- try {
2738
- return new URL(f?.href || String(f || ""), re()).searchParams.get(e) === t;
2739
- } catch {
2740
- return !1;
2741
- }
2742
- }
2743
- async function m(f, g = {}, l = {}) {
2744
- const h = l.parser || s, w = l.isBlockedDocument || d, k = globalThis.document, v = globalThis.window;
2745
- if (!k?.body || typeof k.createElement != "function" || typeof k.body.appendChild != "function") return {
2746
- attempted: !1,
2747
- doc: null,
2748
- result: null,
2749
- blocked: !1,
2750
- timedOut: !1,
2751
- via: "unavailable"
2752
- };
2753
- const T = p(f), x = k.createElement("iframe");
2754
- x.name = r;
2755
- try {
2756
- x.sandbox = n;
2757
- } catch {
2758
- }
2759
- return x.style && (x.style.cssText = i), new Promise((C) => {
2760
- let M = !1;
2761
- const H = typeof v?.addEventListener == "function" && typeof v?.removeEventListener == "function", ut = v.setTimeout(() => {
2762
- ee({
2763
- attempted: !0,
2764
- doc: null,
2765
- result: null,
2766
- blocked: !1,
2767
- timedOut: !0,
2768
- via: "timeout"
2769
- });
2770
- }, o);
2771
- function dt() {
2772
- v.clearTimeout(ut), H && v.removeEventListener("message", ke), typeof x.remove == "function" && x.remove();
2773
- }
2774
- function ee(A) {
2775
- M || (M = !0, dt(), C(A));
2776
- }
2777
- function ke(A) {
2778
- if (A.source && x.contentWindow && A.source !== x.contentWindow) return;
2779
- const L = A.data;
2780
- !L || L.type !== c || L.marker !== t || ee({
2781
- attempted: !0,
2782
- doc: null,
2783
- result: L.payload || null,
2784
- blocked: !!L.blocked,
2785
- timedOut: !1,
2786
- via: "postMessage"
2787
- });
2788
- }
2789
- x.addEventListener("load", () => {
2790
- if (x.contentWindow?.location?.href !== "about:blank")
2791
- try {
2792
- const A = x.contentDocument || x.contentWindow?.document || null, L = !!w?.(A);
2793
- ee({
2794
- attempted: !0,
2795
- doc: A,
2796
- result: typeof h == "function" ? h(A, {
2797
- url: T,
2798
- input: g
2799
- }) : null,
2800
- blocked: L,
2801
- timedOut: !1,
2802
- via: "contentDocument"
2803
- });
2804
- } catch {
2805
- }
2806
- }), H && v.addEventListener("message", ke), k.body.appendChild(x), x.src = T;
2807
- });
2808
- }
2809
- function u(f = s, { targetOrigin: g = re() } = {}) {
2810
- const l = globalThis.window;
2811
- if (!l?.parent || !b(l.location, l.name)) return !1;
2812
- const h = typeof f == "function" ? f(globalThis.document, {
2813
- url: l.location?.href || "",
2814
- input: {}
2815
- }) : f;
2816
- return l.parent.postMessage({
2817
- type: c,
2818
- marker: t,
2819
- payload: h
2820
- }, g || "*"), !0;
2821
- }
2822
- return {
2823
- markerParam: e,
2824
- markerValue: t,
2825
- frameName: r,
2826
- messageType: c,
2827
- decorateUrl: p,
2828
- isScraperFrame: b,
2829
- load: m,
2830
- postCurrentDocument: u
2831
- };
2832
- }
2833
- function sa(e, { accountId: t, type: r = "agenticSearchFrame" } = {}) {
2834
- return e?.isScraperFrame?.() ? (t && globalThis.window && (globalThis.window.GengageAssistantInjector ||= {}, globalThis.window.GengageAssistantInjector[t] ||= { type: r }), !0) : !1;
2835
- }
2836
- function re() {
2837
- return globalThis.window?.location?.origin || globalThis.location?.origin || "https://example.invalid";
2838
- }
2839
- function ca({ rootUrl: e, successMessage: t, alreadyCurrentPageMessage: r = t, missingUrlMessage: n = "Ürün sayfasını açmak için ürün bağlantısı gerekiyor." } = {}) {
2840
- const o = new URL(e).origin;
2841
- return async function(a = {}) {
2842
- const s = a.product || {}, d = On(a.url || a.productUrl || s.url, e, o), c = a.sku || s.sku || null;
2843
- return d ? $n(d) ? {
2844
- ok: !0,
2845
- sku: c,
2846
- url: d,
2847
- method: "already-current-page",
2848
- alreadyCurrentPage: !0,
2849
- message: r || t
2850
- } : (Mn(d), {
2851
- ok: !0,
2852
- sku: c,
2853
- url: d,
2854
- method: "browser-navigation",
2855
- message: t
2856
- }) : {
2857
- ok: !1,
2858
- sku: c,
2859
- reason: "missing-url",
2860
- message: n
2861
- };
2862
- };
2863
- }
2864
- function On(e, t, r = new URL(t).origin) {
2865
- if (!e) return "";
2866
- try {
2867
- const n = new URL(e, t);
2868
- return n.protocol !== "https:" || n.origin !== r ? "" : (n.hash = "", n.href);
2869
- } catch {
2870
- return "";
2871
- }
2872
- }
2873
- function Mn(e) {
2874
- if (typeof document > "u") {
2875
- window.location.href = e;
2876
- return;
2877
- }
2878
- const t = document.createElement("a");
2879
- t.href = e, t.target = "_self", t.rel = "noreferrer", t.style.display = "none", document.body.appendChild(t), t.click(), t.remove(), setTimeout(() => {
2880
- window.location.href !== e && window.location.assign(e);
2881
- }, 0);
2882
- }
2883
- function $n(e) {
2884
- try {
2885
- const t = new URL(globalThis.window?.location?.href || "", e), r = new URL(e, t.href);
2886
- return t.hash = "", r.hash = "", t.href === r.href;
2887
- } catch {
2888
- return !1;
2889
- }
2890
- }
2891
- function Dn({ accountId: e, supplied: t = [], pageProduct: r = null, listingProducts: n = [], skus: o = [], limit: i = 4, storedProducts: a = [], getStoredPanelProducts: s } = {}) {
2892
- const d = st(o), c = Array.isArray(n) ? n : [], p = typeof s == "function" ? s({
2893
- accountId: e,
2894
- visibleProducts: c
2895
- }) : a;
2896
- return Gn([
2897
- ...K(t),
2898
- ...K(p),
2899
- r,
2900
- ...c
2901
- ], {
2902
- skus: d,
2903
- limit: i
2904
- });
2905
- }
2906
- function la({ accountId: e, rootUrl: t, getProduct: r, getProducts: n, getStoredPanelProducts: o, limit: i = 4 } = {}) {
2907
- return async function(s = {}) {
2908
- return {
2909
- accountId: e,
2910
- products: Dn({
2911
- accountId: e,
2912
- supplied: Array.isArray(s.products) ? s.products : [],
2913
- pageProduct: r?.(),
2914
- listingProducts: n?.(),
2915
- getStoredPanelProducts: o,
2916
- skus: s.skus || s.sku_list || [],
2917
- limit: i
2918
- }),
2919
- rootUrl: t
2920
- };
2921
- };
2922
- }
2923
- function Gn(e, { skus: t = [], limit: r = 4 } = {}) {
2924
- const n = new Set(st(t)), o = /* @__PURE__ */ new Set(), i = [];
2925
- for (const a of K(e)) {
2926
- if (!a) continue;
2927
- const s = W(a?.sku);
2928
- if (n.size && !n.has(s)) continue;
2929
- const d = s || W(a?.url) || W(a?.name || a?.title);
2930
- if (!(d && o.has(d)) && (d && o.add(d), i.push(a), i.length >= r))
2931
- break;
2932
- }
2933
- return i;
2934
- }
2935
- function st(e) {
2936
- return K(e).map(W).filter(Boolean);
2937
- }
2938
- function W(e) {
2939
- return String(e || "").trim();
2940
- }
2941
- function K(e) {
2942
- return Array.isArray(e) ? e.filter(Boolean) : e ? [e] : [];
2943
- }
2944
- var N = {
2945
- headings: 8,
2946
- products: 8,
2947
- controls: 12,
2948
- textMatches: 8,
2949
- snippetChars: 180
2950
- }, J = /\b(?:checkout|payment|pay now|place order|delete|remove|confirm|submit|ödeme|odeme|siparişi tamamla|siparisi tamamla|satın al|satin al|sil|kaldır|kaldir|onayla|gönder|gonder)\b/iu, zn = /(?:token|session|sid|auth|code|csrf|secret|key|password|passwd|phone|email|address|postcode|zip|jwt|bearer)/iu, Hn = /[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, Wn = {
2951
- campaign: /\b(?:campaign|promotion|discount|deal|coupon|kampanya|indirim|firsat|fırsat|kupon)\b/iu,
2952
- blog: /\b(?:blog|journal|guide|article|editorial|inspiration|rehber|makale|ilham|icerik|içerik)\b/iu,
2953
- category: /\b(?:category|collection|department|kategori|koleksiyon|reyon)\b/iu
2954
- };
2955
- function ua({ accountId: e, getPageType: t, getProduct: r, getProducts: n, normalizeProduct: o = (i) => i }) {
2956
- return {
2957
- scanSite: (i = {}) => Vn({
2958
- accountId: e,
2959
- getPageType: t,
2960
- getProduct: r,
2961
- getProducts: n,
2962
- normalizeProduct: o,
2963
- input: i
2964
- }),
2965
- siteGrep: (i = {}) => Kn(i),
2966
- discoverSiteContent: (i = {}) => ct(i, e),
2967
- runSiteCommand: (i = {}) => Jn(i),
2968
- describeVisualContext: (i = {}) => Yn(i, e),
2969
- inspectProductSurface: yt({
2970
- accountId: e,
2971
- getPageType: t,
2972
- getProduct: r,
2973
- getProducts: n,
2974
- normalizeProduct: o
2975
- }),
2976
- getSiteCapabilities: () => Xn(e)
2977
- };
2978
- }
2979
- function Vn({ accountId: e, getPageType: t, getProduct: r, getProducts: n, normalizeProduct: o, input: i }) {
2980
- const a = _(i.query || i.text || ""), s = ve(i), d = ne(r), c = ne(n) || [];
2981
- return xe({
2982
- accountId: e,
2983
- url: mo(),
2984
- title: P(document.title || ""),
2985
- pageType: ne(t) || "other",
2986
- viewport: go(),
2987
- product: Fe(o(d)),
2988
- products: c.map(o).map(Fe).filter(Boolean).slice(0, s.products),
2989
- content: i.includeContent === !1 ? void 0 : ct(i, e).items,
2990
- headings: eo(s.headings),
2991
- controls: i.includeControls === !1 ? void 0 : to(s.controls),
2992
- textMatches: a ? be(a, s) : [],
2993
- privacy: {
2994
- rawHtml: !1,
2995
- formValues: !1,
2996
- redacted: !0,
2997
- browserLocal: !0
2998
- }
2999
- });
3000
- }
3001
- function ct(e = {}, t = "") {
3002
- const r = ve(e), n = new Set(oo(e.kinds || e.kind)), o = ro(r.controls).filter((i) => !n.size || n.has(i.kind)).slice(0, r.controls);
3003
- return {
3004
- accountId: t,
3005
- items: o,
3006
- count: o.length,
3007
- privacy: R()
3008
- };
3009
- }
3010
- function Kn(e = {}) {
3011
- const t = _(e.query || e.text || e.pattern || "");
3012
- if (!t) return {
3013
- ok: !1,
3014
- matches: [],
3015
- message: "Provide a query to scan visible page text.",
3016
- privacy: R()
3017
- };
3018
- const r = be(t, ve(e));
3019
- return {
3020
- ok: r.length > 0,
3021
- query: t,
3022
- matches: r,
3023
- count: r.length,
3024
- privacy: R()
3025
- };
3026
- }
3027
- function Jn(e = {}) {
3028
- const t = _(e.command || e.action || "").toLowerCase();
3029
- return t === "scroll_to_text" || t === "scrolltotext" ? Zn(e) : t === "click_visible_text" || t === "clickvisibletext" ? Qn(e) : t === "scroll_top" || t === "scrolltotop" ? (window.scrollTo({
3030
- top: 0,
3031
- behavior: "smooth"
3032
- }), {
3033
- ok: !0,
3034
- command: "scroll_top",
3035
- message: "Scrolled to the top of the page.",
3036
- privacy: R()
3037
- }) : {
3038
- ok: !1,
3039
- command: t,
3040
- message: "Supported commands are scroll_to_text, click_visible_text, and scroll_top.",
3041
- privacy: R()
3042
- };
3043
- }
3044
- function Yn(e = {}, t) {
3045
- const r = e.visual_consent === !0 || e.visualConsent === !0 || e.consent === !0, n = r ? ao(e.visual_observations || e.visualObservations) : [], o = io(Number(e.maxImages || 8));
3046
- return {
3047
- accountId: t,
3048
- ok: r || o.length > 0,
3049
- consentedObservations: n,
3050
- visibleImages: o,
3051
- message: so({
3052
- consented: r,
3053
- observations: n,
3054
- visibleImages: o
3055
- }),
3056
- privacy: {
3057
- rawHtml: !1,
3058
- formValues: !1,
3059
- screenshotPixels: !1,
3060
- redacted: !0,
3061
- browserLocal: !0,
3062
- requiresConsentForExternalVisualFacts: !0
3063
- }
3064
- };
3065
- }
3066
- function Zn(e) {
3067
- const t = _(e.query || e.text || e.label || ""), r = t ? uo(t) : null;
3068
- return r ? (r.scrollIntoView({
3069
- block: "center",
3070
- inline: "nearest",
3071
- behavior: "smooth"
3072
- }), {
3073
- ok: !0,
3074
- command: "scroll_to_text",
3075
- label: O(r),
3076
- message: "Scrolled to the matching page area.",
3077
- privacy: R()
3078
- }) : {
3079
- ok: !1,
3080
- command: "scroll_to_text",
3081
- message: "No visible matching text found."
3082
- };
3083
- }
3084
- function Qn(e) {
3085
- const t = _(e.label || e.query || e.text || "");
3086
- if (!t) return {
3087
- ok: !1,
3088
- command: "click_visible_text",
3089
- message: "Provide a visible label to click."
3090
- };
3091
- if (J.test(t)) return {
3092
- ok: !1,
3093
- blocked: !0,
3094
- command: "click_visible_text",
3095
- message: "This looks like a checkout, payment, destructive, or final confirmation action, so it was not clicked.",
3096
- privacy: R()
3097
- };
3098
- const r = lo(t);
3099
- if (!r) return {
3100
- ok: !1,
3101
- command: "click_visible_text",
3102
- message: "No safe visible clickable control found."
3103
- };
3104
- const n = O(r);
3105
- return J.test(n) ? {
3106
- ok: !1,
3107
- blocked: !0,
3108
- command: "click_visible_text",
3109
- label: n,
3110
- message: "The matched control is blocked by the safe-click policy.",
3111
- privacy: R()
3112
- } : (r.click(), {
3113
- ok: !0,
3114
- command: "click_visible_text",
3115
- label: n,
3116
- message: "Clicked the safe visible control.",
3117
- privacy: R()
3118
- });
3119
- }
3120
- function Xn(e) {
3121
- return {
3122
- accountId: e,
3123
- tools: [
3124
- "scanSite",
3125
- "siteGrep",
3126
- "discoverSiteContent",
3127
- "runSiteCommand",
3128
- "describeVisualContext",
3129
- "inspectProductSurface"
3130
- ],
3131
- commands: {
3132
- scanSite: "Returns a compact browser-local summary of page type, title, headings, products, controls, and matching visible text.",
3133
- siteGrep: "Finds capped visible text snippets by plain query, like grep for the rendered page.",
3134
- discoverSiteContent: "Returns visible campaign, blog/editorial, and category/content links as compact browser-local metadata.",
3135
- runSiteCommand: "Runs guarded browser-local page commands: scroll_to_text, click_visible_text, scroll_top. Checkout, payment, destructive, and final-confirm controls are blocked.",
3136
- describeVisualContext: "Summarizes visible image metadata and explicit shopper-consented redacted visual observations without capturing screenshots or pixels.",
3137
- inspectProductSurface: "Returns compact GSS-style product detail evidence visible in the browser: description, specs, seller, QNA, reviews/ratings, installment/payment, shipping/stock, campaigns, variants, documents, and related visible products."
3138
- },
3139
- privacy: [
3140
- "Runs in the shopper browser.",
3141
- "Does not return raw HTML, cookies, storage, hidden text, or form values.",
3142
- "Redacts emails, phone numbers, tokens, and address-like postal snippets before returning text.",
3143
- "Returns compact capped snippets only.",
3144
- "Does not send screenshots or pixels implicitly; external visual observations must be explicitly consented."
3145
- ]
3146
- };
3147
- }
3148
- function eo(e) {
3149
- return [...document.querySelectorAll('h1,h2,h3,[role="heading"]')].filter(j).map((t) => P(_(t.textContent))).filter(Boolean).slice(0, e);
3150
- }
3151
- function to(e) {
3152
- return [...document.querySelectorAll('button,a,[role="button"],summary,input[type="button"],input[type="submit"]')].filter(j).map((t) => ({
3153
- label: O(t),
3154
- tag: t.tagName?.toLowerCase(),
3155
- role: t.getAttribute?.("role") || null,
3156
- href: lt(t),
3157
- safeClick: !J.test(O(t))
3158
- })).filter((t) => t.label).filter(X((t) => `${t.tag}:${t.label}:${t.href || ""}`)).slice(0, e);
3159
- }
3160
- function ro(e) {
3161
- return [...document.querySelectorAll('a[href],button,[role="button"],summary')].filter(j).map((t) => {
3162
- const r = O(t), n = lt(t), o = no([
3163
- r,
3164
- n,
3165
- le(t)
3166
- ].join(" "));
3167
- return o ? xe({
3168
- kind: o,
3169
- label: r,
3170
- href: n,
3171
- heading: le(t),
3172
- safeClick: !J.test(r)
3173
- }) : null;
3174
- }).filter(Boolean).filter(X((t) => `${t.kind}:${t.label}:${t.href || ""}`)).slice(0, Math.max(1, Math.min(e, 30)));
3175
- }
3176
- function no(e) {
3177
- for (const [t, r] of Object.entries(Wn)) if (r.test(e)) return t;
3178
- return "";
3179
- }
3180
- function oo(e) {
3181
- return (Array.isArray(e) ? e : String(e || "").split(/[,|]/u)).map((t) => _(t).toLowerCase()).filter(Boolean);
3182
- }
3183
- function be(e, t) {
3184
- const r = e.toLocaleLowerCase("tr-TR");
3185
- return co(document.body).map((n) => ({
3186
- node: n,
3187
- text: _(n.nodeValue || "")
3188
- })).filter(({ text: n }) => n && n.toLocaleLowerCase("tr-TR").includes(r)).map(({ node: n, text: o }) => ({
3189
- snippet: po(o, e, t.snippetChars),
3190
- tag: n.parentElement?.tagName?.toLowerCase() || "",
3191
- heading: le(n.parentElement)
3192
- })).filter((n) => n.snippet).filter(X((n) => n.snippet)).slice(0, t.textMatches);
3193
- }
3194
- function io(e) {
3195
- return [...document.querySelectorAll("img")].filter(j).map((t) => ({
3196
- alt: P(_(t.getAttribute("alt") || t.getAttribute("aria-label") || "")),
3197
- title: P(_(t.getAttribute("title") || "")),
3198
- src: ye(t.currentSrc || t.getAttribute("src")),
3199
- width: Math.round(t.getBoundingClientRect().width),
3200
- height: Math.round(t.getBoundingClientRect().height)
3201
- })).filter((t) => t.alt || t.title || t.src).filter(X((t) => `${t.alt}:${t.title}:${t.src}`)).slice(0, Math.max(1, Math.min(Number.isFinite(e) && e > 0 ? Math.floor(e) : 8, 20)));
3202
- }
3203
- function ao(e) {
3204
- return (Array.isArray(e) ? e : String(e || "").split(/\n|;|\|/u)).map((t) => P(t).slice(0, 180)).filter(Boolean).slice(0, 8);
3205
- }
3206
- function so({ consented: e, observations: t, visibleImages: r }) {
3207
- const n = [];
3208
- if (t.length && n.push(`Consented visual observations: ${t.slice(0, 3).join(" | ")}.`), r.length) {
3209
- const o = r.map((i) => i.alt || i.title).filter(Boolean).slice(0, 3);
3210
- n.push(o.length ? `Visible image labels: ${o.join(", ")}.` : `${r.length} visible images found.`);
3211
- }
3212
- return !n.length && !e && n.push("I can use visible image labels, but external visual observations need explicit shopper consent."), n.push("No screenshots or pixels were captured or sent."), n.join(" ");
3213
- }
3214
- function co(e) {
3215
- if (!e) return [];
3216
- const t = document.createTreeWalker(e, NodeFilter.SHOW_TEXT, { acceptNode(n) {
3217
- const o = n.parentElement;
3218
- return !o || !j(o) || /^(script|style|noscript|template|svg)$/iu.test(o.tagName || "") || fo(o) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT;
3219
- } }), r = [];
3220
- for (; r.length < 500; ) {
3221
- const n = t.nextNode();
3222
- if (!n) break;
3223
- r.push(n);
3224
- }
3225
- return r;
3226
- }
3227
- function lo(e) {
3228
- return [...document.querySelectorAll('button,a,[role="button"],summary,input[type="button"],input[type="submit"]')].filter(j).find((t) => O(t).toLocaleLowerCase("tr-TR").includes(e.toLocaleLowerCase("tr-TR")));
3229
- }
3230
- function uo(e) {
3231
- const t = be(e, {
3232
- ...N,
3233
- textMatches: 1
3234
- })[0];
3235
- return t ? [...document.querySelectorAll("body *")].filter(j).find((r) => _(r.textContent).includes(t.snippet.slice(0, 24))) : null;
3236
- }
3237
- function O(e) {
3238
- return e ? P(_(e.getAttribute?.("aria-label") || e.getAttribute?.("title") || e.getAttribute?.("alt") || e.value || e.textContent || "")).slice(0, 90) : "";
3239
- }
3240
- function le(e) {
3241
- let t = e;
3242
- for (let r = 0; t && r < 5; r += 1) {
3243
- const n = _((t.matches?.('h1,h2,h3,[role="heading"]') ? t : t.querySelector?.('h1,h2,h3,[role="heading"]'))?.textContent || "");
3244
- if (n) return P(n).slice(0, 90);
3245
- t = t.parentElement;
3246
- }
3247
- return "";
3248
- }
3249
- function Fe(e) {
3250
- return e ? xe({
3251
- sku: _(e.sku || e.id || ""),
3252
- name: _(e.name || e.title || ""),
3253
- url: ye(e.url),
3254
- price_text: _(e.price_text || e.priceText || ""),
3255
- price: e.price,
3256
- currency: e.price_currency || e.currency,
3257
- in_stock: e.in_stock,
3258
- category: _(e.category || "")
3259
- }) : null;
3260
- }
3261
- function po(e, t, r) {
3262
- const n = P(e), o = n.toLocaleLowerCase("tr-TR").indexOf(t.toLocaleLowerCase("tr-TR")), i = Math.max(0, o - Math.floor(r / 3));
3263
- return n.slice(i, i + r).trim();
3264
- }
3265
- function j(e) {
3266
- if (!e || !e.getBoundingClientRect) return !1;
3267
- const t = e.getBoundingClientRect();
3268
- if (t.width <= 0 || t.height <= 0) return !1;
3269
- const r = window.getComputedStyle(e);
3270
- return r.visibility !== "hidden" && r.display !== "none" && Number(r.opacity || 1) > 0;
3271
- }
3272
- function fo(e) {
3273
- return !!e.closest?.('input,textarea,select,[contenteditable="true"]');
3274
- }
3275
- function lt(e) {
3276
- return e.tagName?.toLowerCase() !== "a" ? null : ye(e.getAttribute("href"));
3277
- }
3278
- function ye(e) {
3279
- if (!e) return "";
3280
- try {
3281
- const t = new URL(e, window.location.href);
3282
- return /^https?:$/u.test(t.protocol) ? (t.hash = "", we(t), t.href) : "";
3283
- } catch {
3284
- return "";
3285
- }
3286
- }
3287
- function mo() {
3288
- const e = new URL(window.location.href);
3289
- return we(e), `${e.origin}${e.pathname}${e.search}`;
3290
- }
3291
- function go() {
3292
- return {
3293
- width: window.innerWidth,
3294
- height: window.innerHeight,
3295
- scrollY: Math.round(window.scrollY || 0),
3296
- documentHeight: Math.round(document.documentElement?.scrollHeight || 0)
3297
- };
3298
- }
3299
- function P(e) {
3300
- return _(e).replace(/https?:\/\/[^\s?#]+(?:\?[^#\s]*)?/giu, ho).replace(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/giu, "<email>").replace(/\b(?:\+?\d[\d\s().-]{8,}\d)\b/gu, "<phone>").replace(/\b[A-Z]{1,2}\d[A-Z\d]?\s*\d[A-Z]{2}\b/giu, "<postcode>").replace(/\btoken\s*=\s*[\w.-]+/giu, "token=<redacted>").replace(/\b(?:api[_-]?key|session|csrf|secret)\s*[:=]\s*[\w.-]+/giu, "<secret>");
3301
- }
3302
- function ho(e) {
3303
- try {
3304
- const t = new URL(e);
3305
- return t.hash = "", we(t), t.href;
3306
- } catch {
3307
- return String(e || "").replace(/\?[^#\s]*/u, "?redacted");
3308
- }
3309
- }
3310
- function we(e) {
3311
- for (const [t, r] of [...e.searchParams.entries()]) {
3312
- const n = String(r || "");
3313
- (zn.test(t) || Hn.test(n)) && e.searchParams.set(t, "redacted");
3314
- }
3315
- return e;
3316
- }
3317
- function _(e) {
3318
- return String(e || "").replace(/\s+/gu, " ").trim();
3319
- }
3320
- function ve(e) {
3321
- return {
3322
- headings: D(e.maxHeadings, N.headings, 20),
3323
- products: D(e.maxProducts, N.products, 20),
3324
- controls: D(e.maxControls, N.controls, 30),
3325
- textMatches: D(e.maxMatches || e.limit, N.textMatches, 20),
3326
- snippetChars: D(e.snippetChars, N.snippetChars, 320)
3327
- };
3328
- }
3329
- function D(e, t, r) {
3330
- const n = Number(e);
3331
- return !Number.isFinite(n) || n <= 0 ? t : Math.min(Math.floor(n), r);
3332
- }
3333
- function R() {
3334
- return {
3335
- rawHtml: !1,
3336
- formValues: !1,
3337
- redacted: !0,
3338
- browserLocal: !0
3339
- };
3340
- }
3341
- function xe(e) {
3342
- return Object.fromEntries(Object.entries(e).filter(([, t]) => t != null));
3343
- }
3344
- function ne(e) {
3345
- try {
3346
- return typeof e == "function" ? e() : null;
3347
- } catch {
3348
- return null;
3349
- }
3350
- }
3351
- function X(e) {
3352
- const t = /* @__PURE__ */ new Set();
3353
- return (r) => {
3354
- const n = e(r);
3355
- return !n || t.has(n) ? !1 : (t.add(n), !0);
3356
- };
3357
- }
3358
- export {
3359
- ri as AgentError,
3360
- mt as ContextStore,
3361
- Co as FALLBACK_STATUS,
3362
- li as __resetAllCartCoalescersForTesting,
3363
- xi as __resetAllPdpHydratorsForTesting,
3364
- Oi as action,
3365
- Zo as actionButtonsUiSpec,
3366
- Fo as alignProductsToTable,
3367
- Ho as anonymousRequestText,
3368
- ji as applyCompactionResult,
3369
- $i as beErrorToAgentError,
3370
- vr as buildActivityVisualization,
3371
- bi as buildCompactionRequest,
3372
- qi as buildPdpFollowupSteps,
3373
- yo as buildPhotoSimilarityProfile,
3374
- wo as buildProductSimilarityProfile,
3375
- vo as buildSimilarityQueries,
3376
- Ei as buildToolUiSteps,
3377
- Ze as canUseModuleWorker,
3378
- wt as caughtToStreamError,
3379
- pi as coalesceAddToCart,
3380
- qo as compactAccountConfig,
3381
- ei as compactContextProducts,
3382
- Go as compactObject,
3383
- ii as compactProductSurfaceForLlm,
3384
- Xo as comparisonResultForUi,
3385
- Io as comparisonUiSpec,
3386
- pr as createActivityCollector,
3387
- Ge as createBrowserMemory,
3388
- ra as createDiagnosticsTool,
3389
- Ki as createEndpointCachePolicies,
3390
- Ji as createEndpointHandlers,
3391
- Jo as createFlow,
3392
- ia as createGssToolAliases,
3393
- aa as createIframeScraper,
3394
- kt as createInjectorAdapter,
3395
- wi as createLocalRefStore,
3396
- St as createMainThreadInjectorAdapter,
3397
- ir as createModuleWorker,
3398
- ca as createOpenProductPageTool,
3399
- Vo as createPrivacyHelpers,
3400
- yt as createProductSurfaceInspector,
3401
- vi as createReadPageStep,
3402
- ta as createReadPageTool,
3403
- la as createResolveProductsTool,
3404
- ua as createSiteAwarenessTools,
3405
- Do as declarativeBeOpCache,
3406
- Hi as defaultPiiPatternPack,
3407
- Ao as defaultPiiPatterns,
3408
- ui as done,
3409
- Ko as elapsedMs,
3410
- ar as endpointStableKey,
3411
- fi as error,
3412
- yi as fallbackStatus,
3413
- rn as filterActivityEntries,
3414
- _i as firstArrayValue,
3415
- vn as formatJsonHtml,
3416
- fr as getOrCreateActivityCollector,
3417
- yr as groupForEntry,
3418
- Nn as gssSearchCapabilities,
3419
- Po as homePanelReset,
3420
- ai as httpErrorToAgentError,
3421
- zo as inputHashCachePolicy,
3422
- Wo as inspectProductSurface,
3423
- $r as installActivityFetchPatch,
3424
- ea as installBrowserTools,
3425
- Wi as installFetchTransportBridge,
3426
- sa as installIframeScraperBypass,
3427
- oa as installLocalAgenticActivityDebug,
3428
- Mo as isFallbackStatus,
3429
- $o as isRef,
3430
- Zi as jsonResponse,
3431
- Fi as llmCacheKey,
3432
- Ro as mergeProductSurfaceEvidence,
3433
- Ci as mergeRoundProducts,
3434
- Pi as metadata,
3435
- Vi as mountAccount,
3436
- Qr as mountActivityOverlay,
3437
- Mn as navigateSameTab,
3438
- Yi as ndjsonResponse,
3439
- Qo as normalizeComparisonTable,
3440
- mr as normalizeEntry,
3441
- Ai as normalizeProduct,
3442
- On as normalizeSameOriginUrl,
3443
- xo as normalizeSimilarityText,
3444
- jo as nowIso,
3445
- Lo as plainMessageContent,
3446
- Bo as productDetailsUiSpec,
3447
- Ti as productFactsKey,
3448
- Ni as productSkuKey,
3449
- Di as productSurfaceReviewText,
3450
- Li as productsUiSpec,
3451
- ko as rankSimilarProducts,
3452
- _o as rankSimilarProductsAsync,
3453
- Re as recordBeDebugPayload,
3454
- Yo as redactPii,
3455
- Uo as requestText,
3456
- Xi as resolveBeUrl,
3457
- ki as resolveFlow,
3458
- Dn as resolveProductCandidates,
3459
- ti as retailAnonymizeMessages,
3460
- Mi as retailAnonymousRequestText,
3461
- zi as retailRedactPii,
3462
- gi as routeFlowParams,
3463
- mi as routeSkuList,
3464
- So as scoreSimilarityCandidate,
3465
- Ii as searchFollowUpPills,
3466
- hr as sectionForKind,
3467
- Qi as setAssistantHostVisible,
3468
- br as severityForEntry,
3469
- ni as shouldCompact,
3470
- Tn as shouldInstallActivityDebug,
3471
- Ri as singleFlight,
3472
- ue as stableKey,
3473
- na as startLazyRuntimeLoader,
3474
- Gi as stickyContextKey,
3475
- Y as summarizeDebugState,
3476
- ae as summarizePanelState,
3477
- Qe as summarizeUiSpec,
3478
- Si as textChunk,
3479
- oi as textKey,
3480
- Eo as tokenizeSimilarityText,
3481
- Ui as trimProductFactsCore,
3482
- ci as trimProductFactsListCore,
3483
- hi as uiSpec,
3484
- Gn as uniqueProductsBySku,
3485
- di as validateToolArgs,
3486
- Oo as withAccountConfig,
3487
- No as withDeclarativeBeOpCache,
3488
- si as withSimilarsAppend,
3489
- Or as wrapActivityBeacon,
3490
- Br as wrapActivityTools,
3491
- Mr as wrapActivityTransport,
3492
- Bi as wrapResolveProductsWithPdpHydration
3493
- };