@gengage/assistant-fe 0.6.16 → 0.6.18

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 (56) hide show
  1. package/dist/{request-text-DThlE-Xd.js → account-config-gj7_mF6Q.js} +725 -312
  2. package/dist/agentic/events/comparison.d.ts +6 -0
  3. package/dist/agentic/events/context-products.d.ts +6 -0
  4. package/dist/agentic/index.d.ts +8 -0
  5. package/dist/agentic/index.js +251 -168
  6. package/dist/agentic/recipes/catalog-assistant-flow.d.ts +50 -0
  7. package/dist/agentic/recipes/input-text/actions.d.ts +15 -0
  8. package/dist/agentic/recipes/input-text/index.d.ts +4 -0
  9. package/dist/agentic/recipes/input-text/products.d.ts +4 -0
  10. package/dist/agentic/recipes/input-text/ranking.d.ts +14 -0
  11. package/dist/agentic/recipes/input-text/steps.d.ts +31 -0
  12. package/dist/agentic/util/account-config.d.ts +8 -0
  13. package/dist/agentic/util/privacy.d.ts +12 -0
  14. package/dist/agentic/widgets/endpoints.d.ts +12 -0
  15. package/dist/agentic/worker.d.ts +8 -0
  16. package/dist/agentic/worker.js +415 -106
  17. package/dist/agentic.iife.js +7 -5
  18. package/dist/{api-paths-C7Y4wTde.js → api-paths-CEDR4rld.js} +1 -1
  19. package/dist/chat/components/InlineLauncher.d.ts +15 -0
  20. package/dist/chat/index.d.ts +1 -1
  21. package/dist/chat-runtime.js +1 -1
  22. package/dist/{chat-BP-yXukW.js → chat-rvSffJXw.js} +1 -1
  23. package/dist/chat.iife.js +15 -12
  24. package/dist/chat.js +2 -2
  25. package/dist/{common-BR9JIIjb.js → common-BBgWfT-W.js} +3 -3
  26. package/dist/common.js +8 -8
  27. package/dist/{connection-warning-DyeP1AB2.js → connection-warning-B-doodzu.js} +1 -1
  28. package/dist/{fastIntent-C8jh7D1D.js → fastIntent-CloHPZQh.js} +2 -2
  29. package/dist/index.d.ts +1 -1
  30. package/dist/index.js +13 -13
  31. package/dist/{native-webview-U9HtGabb.js → native-webview-NWc9LrJh.js} +1 -1
  32. package/dist/native.iife.js +13 -10
  33. package/dist/native.js +1 -1
  34. package/dist/{overlay-ClYgI2Kl.js → overlay-COzFFq0-.js} +1 -1
  35. package/dist/overlay.js +2 -2
  36. package/dist/{qna-B3lMzHvS.js → qna-DUs97irI.js} +1 -1
  37. package/dist/qna-runtime.js +1 -1
  38. package/dist/qna.iife.js +1 -1
  39. package/dist/qna.js +2 -2
  40. package/dist/{runtime-LY1J9JFl.js → runtime-BGCNkU1H.js} +6 -6
  41. package/dist/{runtime-Bt2VV3L3.js → runtime-CbWCU424.js} +1082 -1042
  42. package/dist/{runtime-rjNaPWIi.js → runtime-Ctqq0V6G.js} +8 -8
  43. package/dist/{simbut-DV4oPMpH.js → simbut-Dh4cJysK.js} +3 -3
  44. package/dist/simbut.iife.js +1 -1
  45. package/dist/simbut.js +1 -1
  46. package/dist/{simrel-DaAhtabq.js → simrel-B-sjHbL5.js} +4 -4
  47. package/dist/simrel-runtime.js +1 -1
  48. package/dist/simrel.iife.js +2 -2
  49. package/dist/simrel.js +2 -2
  50. package/dist/{widget-base-DRaUfd-H.js → widget-base-CIJT5AiP.js} +2 -2
  51. package/package.json +1 -1
  52. /package/dist/{context-BBuSsXZ9.js → context-heG8hv5l.js} +0 -0
  53. /package/dist/{locale-CfqNifrU.js → locale-uQ5XZ2yS.js} +0 -0
  54. /package/dist/{price-formatter-CFsWT0lP.js → price-formatter-CHUmYq8I.js} +0 -0
  55. /package/dist/{request-response-cache-zsgz3Awp.js → request-response-cache-BxRsKGJ0.js} +0 -0
  56. /package/dist/{schemas-Cq2blsO_.js → schemas-BnYUhYSy.js} +0 -0
@@ -1,16 +1,16 @@
1
- import { t as ce } from "./request-response-cache-zsgz3Awp.js";
2
- function se(e) {
1
+ import { t as Ae } from "./request-response-cache-BxRsKGJ0.js";
2
+ function xe(e) {
3
3
  return !!e && typeof e == "object" && e.type === "rpc.result";
4
4
  }
5
- function ue(e) {
5
+ function _e(e) {
6
6
  return !!e && typeof e == "object" && e.type === "rpc.req";
7
7
  }
8
- function yt(e = self) {
8
+ function ur(e = self) {
9
9
  let t = 1;
10
10
  const r = /* @__PURE__ */ new Map();
11
11
  return e.addEventListener("message", (n) => {
12
12
  const o = n.data;
13
- if (!se(o)) return;
13
+ if (!xe(o)) return;
14
14
  const i = r.get(o.rpcId);
15
15
  if (i) {
16
16
  if (r.delete(o.rpcId), o.ok === !1) {
@@ -35,19 +35,19 @@ function yt(e = self) {
35
35
  });
36
36
  };
37
37
  }
38
- function gt({ worker: e, tools: t = {}, beacon: r, memory: n = sessionStorage }) {
38
+ function lr({ worker: e, tools: t = {}, beacon: r, memory: n = sessionStorage }) {
39
39
  e.addEventListener("message", (o) => {
40
40
  const i = o.data;
41
- ue(i) && le(e, i, {
41
+ _e(i) && Te(e, i, {
42
42
  tools: t,
43
43
  beacon: r,
44
44
  memory: n
45
45
  });
46
46
  });
47
47
  }
48
- async function le(e, t, r) {
48
+ async function Te(e, t, r) {
49
49
  try {
50
- const n = await me(t.method, t.payload, r);
50
+ const n = await Ie(t.method, t.payload, r);
51
51
  e.postMessage({
52
52
  type: "rpc.result",
53
53
  rpcId: t.rpcId,
@@ -63,70 +63,70 @@ async function le(e, t, r) {
63
63
  });
64
64
  }
65
65
  }
66
- function fe(e) {
66
+ function je(e) {
67
67
  if (e && typeof e == "object" && typeof e.name == "string") return e;
68
68
  throw new Error("tool.invoke requires { name, input }");
69
69
  }
70
- function de(e) {
70
+ function Ee(e) {
71
71
  if (e && typeof e == "object" && e.key !== void 0) return e;
72
72
  throw new Error("memory.get requires { key }");
73
73
  }
74
- function pe(e) {
74
+ function Oe(e) {
75
75
  if (e && typeof e == "object" && e.key !== void 0) return e;
76
76
  throw new Error("memory.set requires { key }");
77
77
  }
78
- async function me(e, t, { tools: r, beacon: n, memory: o }) {
78
+ async function Ie(e, t, { tools: r, beacon: n, memory: o }) {
79
79
  if (e === "tool.invoke") {
80
- const { name: i, input: a } = fe(t), c = r[i];
80
+ const { name: i, input: a } = je(t), c = r[i];
81
81
  if (typeof c != "function") throw new Error(`Unknown tool: ${i}`);
82
82
  return c(a);
83
83
  }
84
84
  if (e === "beacon.send")
85
85
  return n?.(t), { sent: !0 };
86
86
  if (e === "memory.get") {
87
- const { key: i } = de(t), a = o.getItem(String(i));
87
+ const { key: i } = Ee(t), a = o.getItem(String(i));
88
88
  return a ? JSON.parse(a) : null;
89
89
  }
90
90
  if (e === "memory.set") {
91
- const { key: i, value: a } = pe(t);
91
+ const { key: i, value: a } = Oe(t);
92
92
  return o.setItem(String(i), JSON.stringify(a ?? null)), { ok: !0 };
93
93
  }
94
94
  throw new Error(`Unknown RPC method: ${e}`);
95
95
  }
96
- function ye() {
96
+ function Pe() {
97
97
  return (/* @__PURE__ */ new Date()).toISOString();
98
98
  }
99
- function O(e) {
99
+ function I(e) {
100
100
  return Math.max(0, Math.round(performance.now() - e));
101
101
  }
102
102
  function E(e) {
103
103
  return typeof e == "object" && e !== null && !Array.isArray(e);
104
104
  }
105
- function ge(e) {
106
- const { accountId: t, locale: r = "en-GB", parentUrl: n = "", threadId: o, incomingContext: i } = e, a = E(i) ? i : {}, c = E(a.thread) ? a.thread : {}, s = E(a.panel) ? a.panel : {}, u = E(a.meta) ? a.meta : {}, l = Q(a.messages), f = {
105
+ function Ce(e) {
106
+ const { accountId: t, locale: r = "en-GB", parentUrl: n = "", threadId: o, incomingContext: i } = e, a = E(i) ? i : {}, c = E(a.thread) ? a.thread : {}, s = E(a.panel) ? a.panel : {}, u = E(a.meta) ? a.meta : {}, l = oe(a.messages), f = {
107
107
  id: String(o || c.id || self.crypto.randomUUID()),
108
- started_at: String(c.started_at || ye()),
108
+ started_at: String(c.started_at || Pe()),
109
109
  extensions: E(c.extensions) ? { ...c.extensions } : {}
110
- }, m = String(u.locale || r), d = String(u.parentUrl || n || typeof self < "u" && self.location?.href || "");
110
+ }, p = String(u.locale || r), d = String(u.parentUrl || n || typeof self < "u" && self.location?.href || "");
111
111
  return {
112
112
  panel: { ...s },
113
113
  messages: l,
114
114
  thread: f,
115
115
  meta: {
116
- locale: m,
116
+ locale: p,
117
117
  parentUrl: d,
118
118
  accountId: t
119
119
  }
120
120
  };
121
121
  }
122
- function he(e, t) {
123
- const r = Q([t])[0];
122
+ function Me(e, t) {
123
+ const r = oe([t])[0];
124
124
  return r ? {
125
125
  ...e,
126
126
  messages: [...e.messages, r].slice(-50)
127
127
  } : e;
128
128
  }
129
- function Q(e) {
129
+ function oe(e) {
130
130
  return Array.isArray(e) ? e.map((t) => {
131
131
  const r = t?.role;
132
132
  return {
@@ -135,31 +135,31 @@ function Q(e) {
135
135
  };
136
136
  }).filter((t) => (t.role === "user" || t.role === "assistant") && !!t.content).slice(-50) : [];
137
137
  }
138
- var we = "gengage:agent:context:";
139
- async function ke({ accountId: e, threadId: t, rpc: r }) {
138
+ var Be = "gengage:agent:context:";
139
+ async function Ne({ accountId: e, threadId: t, rpc: r }) {
140
140
  const n = await r("memory.get", {
141
141
  tier: "session",
142
- key: Y(e, t)
142
+ key: ie(e, t)
143
143
  });
144
144
  return n && typeof n == "object" && !Array.isArray(n) ? n : {};
145
145
  }
146
- async function be({ accountId: e, threadId: t, extensions: r, panel: n, rpc: o }) {
146
+ async function Re({ accountId: e, threadId: t, extensions: r, panel: n, rpc: o }) {
147
147
  await o("memory.set", {
148
148
  tier: "session",
149
- key: Y(e, t),
149
+ key: ie(e, t),
150
150
  value: {
151
151
  thread: { extensions: r },
152
152
  ...n && Object.keys(n).length > 0 ? { panel: n } : {}
153
153
  }
154
154
  });
155
155
  }
156
- function Y(e, t) {
157
- return `${we}${e}:${t}`;
156
+ function ie(e, t) {
157
+ return `${Be}${e}:${t}`;
158
158
  }
159
159
  function g(e) {
160
160
  return typeof e == "object" && e !== null && !Array.isArray(e);
161
161
  }
162
- var ht = class {
162
+ var fr = class {
163
163
  #e = /* @__PURE__ */ new Map();
164
164
  #t;
165
165
  #n;
@@ -172,23 +172,23 @@ var ht = class {
172
172
  async load(e) {
173
173
  const t = e?.meta?.threadId || e?.session_id || e?.sessionId, r = String(t || "default"), n = this.#e.get(r);
174
174
  if (n) return n;
175
- const o = await ke({
175
+ const o = await Ne({
176
176
  accountId: this.#t,
177
177
  threadId: r,
178
178
  rpc: this.#r
179
- }), i = ge({
179
+ }), i = Ce({
180
180
  accountId: this.#t,
181
181
  locale: e?.locale || this.#n,
182
182
  parentUrl: this.#o,
183
183
  threadId: r,
184
- incomingContext: xe(o, e?.context)
184
+ incomingContext: $e(o, e?.context)
185
185
  });
186
186
  return this.#e.set(r, i), i;
187
187
  }
188
188
  patch(e, t) {
189
189
  const r = String(e || "default"), n = this.#e.get(r);
190
190
  if (!n) return null;
191
- const o = X(n, typeof t == "function" ? t(n) : t);
191
+ const o = ae(n, typeof t == "function" ? t(n) : t);
192
192
  return this.#e.set(r, o), o;
193
193
  }
194
194
  appendUserMessage(e, t) {
@@ -196,7 +196,7 @@ var ht = class {
196
196
  if (!t) return this.#e.get(r) ?? null;
197
197
  const n = this.#e.get(r);
198
198
  if (!n) return null;
199
- const o = he(n, {
199
+ const o = Me(n, {
200
200
  role: "user",
201
201
  content: t
202
202
  });
@@ -204,25 +204,25 @@ var ht = class {
204
204
  }
205
205
  async commit(e) {
206
206
  const t = String(e || "default"), r = this.#e.get(t);
207
- return r ? (await be({
207
+ return r ? (await Re({
208
208
  accountId: this.#t,
209
209
  threadId: t,
210
210
  extensions: r.thread.extensions,
211
- panel: Se(r.panel, this.#i),
211
+ panel: Ue(r.panel, this.#i),
212
212
  rpc: this.#r
213
213
  }), r) : null;
214
214
  }
215
215
  };
216
- function Se(e, t) {
216
+ function Ue(e, t) {
217
217
  if (!t.length || !g(e)) return;
218
218
  const r = {};
219
219
  for (const n of t) Object.prototype.hasOwnProperty.call(e, n) && (r[n] = e[n]);
220
220
  return r;
221
221
  }
222
- function xe(e, t) {
223
- return !g(e) && !g(t) ? {} : X(g(e) ? e : {}, g(t) ? t : {});
222
+ function $e(e, t) {
223
+ return !g(e) && !g(t) ? {} : ae(g(e) ? e : {}, g(t) ? t : {});
224
224
  }
225
- function X(e, t) {
225
+ function ae(e, t) {
226
226
  if (!g(t)) return e;
227
227
  const r = e, n = t, o = g(r.panel) ? r.panel : {}, i = g(n.panel) ? n.panel : {}, a = g(r.thread) ? r.thread : {}, c = g(n.thread) ? n.thread : {}, s = g(a.extensions) ? a.extensions : {}, u = g(c.extensions) ? c.extensions : {}, l = g(r.meta) ? r.meta : {}, f = g(n.meta) ? n.meta : {};
228
228
  return {
@@ -247,19 +247,19 @@ function X(e, t) {
247
247
  messages: Array.isArray(n.messages) ? n.messages.slice(-50) : e.messages ?? []
248
248
  };
249
249
  }
250
- function Z(e) {
250
+ function ce(e) {
251
251
  const t = String.fromCharCode(...e);
252
252
  return btoa(t).replace(/\+/gu, "-").replace(/\//gu, "_").replace(/=+$/u, "");
253
253
  }
254
- function K(e) {
255
- return Z(new TextEncoder().encode(JSON.stringify(e)));
254
+ function V(e) {
255
+ return ce(new TextEncoder().encode(JSON.stringify(e)));
256
256
  }
257
- async function _e({ accountId: e, devJwtSecret: t, ttlS: r = 300 }) {
257
+ async function Fe({ accountId: e, devJwtSecret: t, ttlS: r = 300 }) {
258
258
  if (!t) throw new Error("devJwtSecret is required for local agent mode.");
259
- const n = Math.floor(Date.now() / 1e3), o = `${K({
259
+ const n = Math.floor(Date.now() / 1e3), o = `${V({
260
260
  alg: "HS256",
261
261
  typ: "JWT"
262
- })}.${K({
262
+ })}.${V({
263
263
  sub: e,
264
264
  iat: n,
265
265
  exp: n + r,
@@ -269,18 +269,18 @@ async function _e({ accountId: e, devJwtSecret: t, ttlS: r = 300 }) {
269
269
  name: "HMAC",
270
270
  hash: "SHA-256"
271
271
  }, !1, ["sign"]), a = await crypto.subtle.sign("HMAC", i, new TextEncoder().encode(o));
272
- return `${o}.${Z(new Uint8Array(a))}`;
272
+ return `${o}.${ce(new Uint8Array(a))}`;
273
273
  }
274
- function Ae({ accountId: e, devJwtSecret: t, tokenBrokerUrl: r, tokenBrokerAudience: n, refreshSkewS: o = 30, fetchImpl: i = fetch }) {
274
+ function De({ accountId: e, devJwtSecret: t, tokenBrokerUrl: r, tokenBrokerAudience: n, refreshSkewS: o = 30, fetchImpl: i = fetch }) {
275
275
  let a = null;
276
276
  return async ({ signal: c, parentUrl: s } = {}) => {
277
- if (t) return _e({
277
+ if (t) return Fe({
278
278
  accountId: e,
279
279
  devJwtSecret: t
280
280
  });
281
281
  if (!r) throw new Error("tokenBrokerUrl is required for production agent mode.");
282
282
  const u = Math.floor(Date.now() / 1e3);
283
- return a?.token && a.expiresAtS - o > u || (a = await Te({
283
+ return a?.token && a.expiresAtS - o > u || (a = await ze({
284
284
  accountId: e,
285
285
  tokenBrokerUrl: r,
286
286
  tokenBrokerAudience: n,
@@ -290,7 +290,7 @@ function Ae({ accountId: e, devJwtSecret: t, tokenBrokerUrl: r, tokenBrokerAudie
290
290
  })), a.token;
291
291
  };
292
292
  }
293
- async function Te({ accountId: e, tokenBrokerUrl: t, tokenBrokerAudience: r, parentUrl: n, signal: o, fetchImpl: i }) {
293
+ async function ze({ accountId: e, tokenBrokerUrl: t, tokenBrokerAudience: r, parentUrl: n, signal: o, fetchImpl: i }) {
294
294
  const a = await i(t, {
295
295
  method: "POST",
296
296
  credentials: "include",
@@ -311,10 +311,10 @@ async function Te({ accountId: e, tokenBrokerUrl: t, tokenBrokerAudience: r, par
311
311
  if (!s || typeof s != "string") throw new Error("Token broker response did not include a JWT.");
312
312
  return {
313
313
  token: s,
314
- expiresAtS: Ie(c) || Ee(s) || Math.floor(Date.now() / 1e3) + 300
314
+ expiresAtS: Le(c) || Ke(s) || Math.floor(Date.now() / 1e3) + 300
315
315
  };
316
316
  }
317
- function Ie(e) {
317
+ function Le(e) {
318
318
  const t = e?.expiresAtS ?? e?.expires_at_s ?? e?.expiresInS ?? e?.expires_in_s;
319
319
  if (Number.isFinite(t)) return Number(t);
320
320
  const r = e?.expiresIn ?? e?.expires_in;
@@ -326,7 +326,7 @@ function Ie(e) {
326
326
  }
327
327
  return null;
328
328
  }
329
- function Ee(e) {
329
+ function Ke(e) {
330
330
  try {
331
331
  const [, t] = e.split(".");
332
332
  if (!t) return null;
@@ -336,7 +336,7 @@ function Ee(e) {
336
336
  return null;
337
337
  }
338
338
  }
339
- var q = {
339
+ var G = {
340
340
  unauthorized: {
341
341
  code: "auth",
342
342
  message: "Assistant authentication failed. Please retry."
@@ -381,28 +381,28 @@ var q = {
381
381
  code: "invalid_request",
382
382
  message: "The assistant request was too large."
383
383
  }
384
- }, v = class extends Error {
384
+ }, L = class extends Error {
385
385
  constructor(e, t, r = {}) {
386
386
  super(t), this.name = "AgentError", this.code = e, this.source = r.source || "agent", r.sourceCode && (this.sourceCode = r.sourceCode), r.detail !== void 0 && (this.detail = r.detail);
387
387
  }
388
388
  };
389
- function ee(e) {
390
- const t = String(e?.code || "upstream_llm"), r = q[t] || q.upstream_llm;
391
- return new v(r.code, r.message, {
389
+ function se(e) {
390
+ const t = String(e?.code || "upstream_llm"), r = G[t] || G.upstream_llm;
391
+ return new L(r.code, r.message, {
392
392
  source: "be",
393
393
  sourceCode: t,
394
394
  detail: e?.detail
395
395
  });
396
396
  }
397
- function je(e, t) {
397
+ function ve(e, t) {
398
398
  const r = t?.error && typeof t.error == "object" ? t.error : {};
399
- return ee({
400
- code: String(r.code || Oe(e)),
399
+ return se({
400
+ code: String(r.code || qe(e)),
401
401
  detail: r.detail
402
402
  });
403
403
  }
404
- function wt(e) {
405
- return e instanceof v ? {
404
+ function dr(e) {
405
+ return e instanceof L ? {
406
406
  type: "error",
407
407
  code: e.code,
408
408
  message: e.message
@@ -412,19 +412,19 @@ function wt(e) {
412
412
  message: "The assistant could not complete that request."
413
413
  };
414
414
  }
415
- function Oe(e) {
415
+ function qe(e) {
416
416
  return e === 401 ? "unauthorized" : e === 403 ? "forbidden" : e === 413 ? "payload_too_large" : e === 429 ? "rate_limited" : "internal";
417
417
  }
418
- async function kt({ beUrl: e, accountId: t, devJwtSecret: r, tokenBrokerUrl: n, tokenBrokerAudience: o, jwtProvider: i, parentUrl: a, op: c, input: s, cacheTtlS: u, cacheKey: l, browserCache: f, signal: m }) {
419
- const d = await (i || Ae({
418
+ async function mr({ beUrl: e, accountId: t, devJwtSecret: r, tokenBrokerUrl: n, tokenBrokerAudience: o, jwtProvider: i, parentUrl: a, op: c, input: s, cacheTtlS: u, cacheKey: l, browserCache: f, signal: p }) {
419
+ const d = await (i || De({
420
420
  accountId: t,
421
421
  devJwtSecret: r,
422
422
  tokenBrokerUrl: n,
423
423
  tokenBrokerAudience: o
424
424
  }))({
425
- ...m ? { signal: m } : {},
425
+ ...p ? { signal: p } : {},
426
426
  ...a ? { parentUrl: a } : {}
427
- }), { opDomain: h, opName: p } = Ce(c, t), A = {
427
+ }), { opDomain: h, opName: m } = Je(c, t), _ = {
428
428
  method: "POST",
429
429
  headers: {
430
430
  authorization: `Bearer ${d}`,
@@ -433,34 +433,34 @@ async function kt({ beUrl: e, accountId: t, devJwtSecret: r, tokenBrokerUrl: n,
433
433
  },
434
434
  body: JSON.stringify({
435
435
  op_domain: h,
436
- op_name: p,
436
+ op_name: m,
437
437
  op_payload: s,
438
438
  ...u !== void 0 ? { cache_ttl_s: u } : {},
439
439
  ...l !== void 0 ? { cache_key: l } : {}
440
440
  }),
441
- ...m ? { signal: m } : {}
442
- }, z = `${String(e).replace(/\/+$/u, "")}/v1/execute`, M = f === !1 ? await fetch(z, A) : await ce(z, A, typeof f == "object" ? f : {});
443
- if (!M.ok) throw je(M.status, await Me(M));
444
- return Ne(M);
441
+ ...p ? { signal: p } : {}
442
+ }, Q = `${String(e).replace(/\/+$/u, "")}/v1/execute`, B = f === !1 ? await fetch(Q, _) : await Ae(Q, _, typeof f == "object" ? f : {});
443
+ if (!B.ok) throw ve(B.status, await He(B));
444
+ return Qe(B);
445
445
  }
446
- function Ce(e, t) {
446
+ function Je(e, t) {
447
447
  if (!e || e.startsWith("-") || e.endsWith("-")) throw new Error(`Invalid BE op name: ${e}`);
448
448
  return {
449
- opDomain: Pe(t),
449
+ opDomain: We(t),
450
450
  opName: e
451
451
  };
452
452
  }
453
- function Pe(e) {
453
+ function We(e) {
454
454
  return e.replace(/-agentic$/u, "");
455
455
  }
456
- async function Me(e) {
456
+ async function He(e) {
457
457
  try {
458
458
  return await e.json();
459
459
  } catch {
460
460
  return { error: { code: e.statusText || "internal" } };
461
461
  }
462
462
  }
463
- async function Ne(e) {
463
+ async function Qe(e) {
464
464
  const t = e.body?.getReader();
465
465
  if (!t) throw new Error("BE response body is not readable.");
466
466
  const r = new TextDecoder();
@@ -474,31 +474,31 @@ async function Ne(e) {
474
474
  `);
475
475
  for (; s >= 0; ) {
476
476
  const u = n.slice(0, s).trim();
477
- n = n.slice(s + 1), u && J(JSON.parse(u), o), s = n.indexOf(`
477
+ n = n.slice(s + 1), u && Z(JSON.parse(u), o), s = n.indexOf(`
478
478
  `);
479
479
  }
480
480
  }
481
481
  const i = n.trim();
482
- return i && J(JSON.parse(i), o), o;
482
+ return i && Z(JSON.parse(i), o), o;
483
483
  }
484
- function J(e, t) {
485
- if (e._error) throw ee(e._error);
484
+ function Z(e, t) {
485
+ if (e._error) throw se(e._error);
486
486
  if (!e._end)
487
487
  for (const [r, n] of Object.entries(e)) {
488
- if (Object.prototype.hasOwnProperty.call(t, r)) throw new v("op_failed", `BE streamed duplicate field "${r}".`, {
488
+ if (Object.prototype.hasOwnProperty.call(t, r)) throw new L("op_failed", `BE streamed duplicate field "${r}".`, {
489
489
  source: "be",
490
490
  sourceCode: "schema_mismatch"
491
491
  });
492
492
  t[r] = n;
493
493
  }
494
494
  }
495
- function bt(e = {}) {
495
+ function pr(e = {}) {
496
496
  return {
497
497
  type: "metadata",
498
498
  ...e
499
499
  };
500
500
  }
501
- function Be(e, t = !1, r = {}) {
501
+ function ue(e, t = !1, r = {}) {
502
502
  return {
503
503
  type: "text_chunk",
504
504
  content: e,
@@ -506,37 +506,37 @@ function Be(e, t = !1, r = {}) {
506
506
  ...r
507
507
  };
508
508
  }
509
- function St(e) {
509
+ function U(e) {
510
510
  return {
511
511
  type: "ui_spec",
512
512
  ...e
513
513
  };
514
514
  }
515
- function xt(e) {
515
+ function yr(e) {
516
516
  return {
517
517
  type: "action",
518
518
  action: e
519
519
  };
520
520
  }
521
- function ve(e, t) {
521
+ function Ve(e, t) {
522
522
  return {
523
523
  type: "error",
524
524
  code: e,
525
525
  message: t
526
526
  };
527
527
  }
528
- function te() {
528
+ function le() {
529
529
  return { type: "done" };
530
530
  }
531
- function Re(e, t) {
531
+ function Ge(e, t) {
532
532
  return e[t?.type || t?.action?.type || "inputText"] || e.inputText;
533
533
  }
534
- async function _t({ request: e, accountModule: t, contextStore: r, beClient: n, toolBridge: o, emit: i, rpc: a, signal: c }) {
535
- const s = performance.now(), u = await r.load(e), l = u.thread.id, f = Ge(e);
534
+ async function gr({ request: e, accountModule: t, contextStore: r, beClient: n, toolBridge: o, emit: i, rpc: a, signal: c }) {
535
+ const s = performance.now(), u = await r.load(e), l = u.thread.id, f = ut(e);
536
536
  r.appendUserMessage(l, f);
537
- const m = Re(t.flows, e);
538
- if (!m)
539
- return i(ve("unknown_action", `No agent flow for request type ${e?.type || "inputText"}`)), i(te()), {
537
+ const p = Ge(t.flows, e);
538
+ if (!p)
539
+ return i(Ve("unknown_action", `No agent flow for request type ${e?.type || "inputText"}`)), i(le()), {
540
540
  steps: 0,
541
541
  productSkusEmitted: []
542
542
  };
@@ -558,58 +558,58 @@ async function _t({ request: e, accountModule: t, contextStore: r, beClient: n,
558
558
  adapters: t.adapters || {},
559
559
  ...c ? { signal: c } : {}
560
560
  };
561
- return await P(m, d, h), d.committed || await R(d, h), await a("beacon.send", {
561
+ return await C(p, d, h), d.committed || await K(d, h), await a("beacon.send", {
562
562
  type: "turnSummary",
563
563
  threadId: l,
564
564
  sessionId: e?.session_id || e?.sessionId || l,
565
565
  accountId: t.accountId || d.context.meta.accountId,
566
566
  steps: d.steps,
567
- totalLatencyMs: O(s),
567
+ totalLatencyMs: I(s),
568
568
  productSkusEmitted: [...d.productSkusEmitted]
569
569
  }), {
570
570
  steps: d.steps,
571
571
  productSkusEmitted: [...d.productSkusEmitted]
572
572
  };
573
573
  }
574
- async function P(e, t, r) {
574
+ async function C(e, t, r) {
575
575
  for (const n of e) {
576
576
  if (r.signal?.aborted) return;
577
- t.steps += 1, await $e(n, t, r), t.context = r.contextStore.patch(t.threadId, {}) || t.context;
577
+ t.steps += 1, await Ze(n, t, r), t.context = r.contextStore.patch(t.threadId, {}) || t.context;
578
578
  }
579
579
  }
580
- async function $e(e, t, r) {
581
- const n = U(t);
580
+ async function Ze(e, t, r) {
581
+ const n = q(t);
582
582
  if (e.kind === "be_op") {
583
- await Ue(e, t, r, n);
583
+ await Ye(e, t, r, n);
584
584
  return;
585
585
  }
586
586
  if (e.kind === "tool") {
587
- await Fe(e, t, r, n);
587
+ await Xe(e, t, r, n);
588
588
  return;
589
589
  }
590
590
  if (e.kind === "adapter") {
591
- await De(e, t, r, n);
591
+ await et(e, t, r, n);
592
592
  return;
593
593
  }
594
594
  if (e.kind === "emit") {
595
- ze(e, t, r);
595
+ tt(e, t, r);
596
596
  return;
597
597
  }
598
598
  if (e.kind === "branch") {
599
- await Ke(e, t, r, n);
599
+ await rt(e, t, r, n);
600
600
  return;
601
601
  }
602
602
  if (e.kind === "parallel") {
603
- await qe(e, t, r);
603
+ await nt(e, t, r);
604
604
  return;
605
605
  }
606
606
  if (e.kind === "refusal") {
607
- await Je(e, t, r, n);
607
+ await ot(e, t, r, n);
608
608
  return;
609
609
  }
610
- e.kind === "commit" && await Le(e, t, r);
610
+ e.kind === "commit" && await it(e, t, r);
611
611
  }
612
- async function Ue(e, t, r, n) {
612
+ async function Ye(e, t, r, n) {
613
613
  const o = performance.now();
614
614
  let i;
615
615
  const a = x(e.cacheTtlS, n), c = x(e.cacheKey, n), s = x(e.browserCache, n);
@@ -623,23 +623,23 @@ async function Ue(e, t, r, n) {
623
623
  ...r.signal ? { signal: r.signal } : {}
624
624
  });
625
625
  } catch (l) {
626
- const f = l, m = String(f?.sourceCode || f?.code || "unknown"), d = {
626
+ const f = l, p = String(f?.sourceCode || f?.code || "unknown"), d = {
627
627
  type: "agentOp",
628
628
  threadId: t.threadId,
629
629
  sessionId: t.request?.session_id || t.request?.sessionId || t.threadId,
630
630
  accountId: t.context.meta.accountId,
631
631
  op: e.op,
632
632
  status: "error",
633
- latencyMs: O(o),
634
- errorCode: m
633
+ latencyMs: I(o),
634
+ errorCode: p
635
635
  };
636
636
  if (await r.rpc("beacon.send", d), e.onError) {
637
- e.errorOut && (t.bag[e.errorOut] = l), await P(e.onError, t, r);
637
+ e.errorOut && (t.bag[e.errorOut] = l), await C(e.onError, t, r);
638
638
  return;
639
639
  }
640
640
  throw l;
641
641
  }
642
- e.out && (t.bag[e.out] = i), $(e, i, t, r.contextStore);
642
+ e.out && (t.bag[e.out] = i), v(e, i, t, r.contextStore);
643
643
  const u = {
644
644
  type: "agentOp",
645
645
  threadId: t.threadId,
@@ -647,77 +647,77 @@ async function Ue(e, t, r, n) {
647
647
  accountId: t.context.meta.accountId,
648
648
  op: e.op,
649
649
  status: "ok",
650
- latencyMs: O(o)
650
+ latencyMs: I(o)
651
651
  };
652
652
  await r.rpc("beacon.send", u);
653
653
  }
654
- async function Fe(e, t, r, n) {
654
+ async function Xe(e, t, r, n) {
655
655
  const o = performance.now();
656
656
  try {
657
657
  const i = await r.toolBridge.invoke(e.name, x(e.input, n));
658
- e.out && (t.bag[e.out] = i), $(e, i, t, r.contextStore), await r.rpc("beacon.send", {
658
+ e.out && (t.bag[e.out] = i), v(e, i, t, r.contextStore), await r.rpc("beacon.send", {
659
659
  type: "agentTool",
660
660
  threadId: t.threadId,
661
- sessionId: L(t),
661
+ sessionId: Y(t),
662
662
  accountId: t.context.meta.accountId,
663
663
  tool: e.name,
664
664
  status: "ok",
665
- latencyMs: O(o)
665
+ latencyMs: I(o)
666
666
  });
667
667
  } catch (i) {
668
668
  const a = i;
669
669
  if (await r.rpc("beacon.send", {
670
670
  type: "agentTool",
671
671
  threadId: t.threadId,
672
- sessionId: L(t),
672
+ sessionId: Y(t),
673
673
  accountId: t.context.meta.accountId,
674
674
  tool: e.name,
675
675
  status: "error",
676
- latencyMs: O(o),
676
+ latencyMs: I(o),
677
677
  errorCode: String(a?.code || a?.name || "unknown")
678
678
  }), e.onError) {
679
- e.errorOut && (t.bag[e.errorOut] = i), await P(e.onError, t, r);
679
+ e.errorOut && (t.bag[e.errorOut] = i), await C(e.onError, t, r);
680
680
  return;
681
681
  }
682
682
  throw i;
683
683
  }
684
684
  }
685
- async function De(e, t, r, n) {
685
+ async function et(e, t, r, n) {
686
686
  const o = r.adapters?.[e.name];
687
687
  if (typeof o != "function") throw new Error(`Unknown flow adapter: ${e.name}`);
688
688
  const i = await o(x(e.input, n), n);
689
- e.out && (t.bag[e.out] = i), $(e, i, t, r.contextStore);
689
+ e.out && (t.bag[e.out] = i), v(e, i, t, r.contextStore);
690
690
  }
691
- function ze(e, t, r) {
692
- const n = e.build(U(t));
693
- Qe(n, t.productSkusEmitted), r.emit(n);
691
+ function tt(e, t, r) {
692
+ const n = e.build(q(t));
693
+ lt(n, t.productSkusEmitted), r.emit(n);
694
694
  }
695
- async function Ke(e, t, r, n) {
695
+ async function rt(e, t, r, n) {
696
696
  const o = String(x(e.on, n) || "default");
697
- await P(e.cases[o] || e.cases.default || [], t, r);
697
+ await C(e.cases[o] || e.cases.default || [], t, r);
698
698
  }
699
- async function qe(e, t, r) {
699
+ async function nt(e, t, r) {
700
700
  const n = e.steps.map((a) => {
701
701
  const c = {
702
702
  ...t,
703
- context: He(t.context),
703
+ context: at(t.context),
704
704
  bag: { ...t.bag },
705
705
  productSkusEmitted: t.productSkusEmitted,
706
706
  committed: !1
707
707
  };
708
- return P(a, c, {
708
+ return C(a, c, {
709
709
  ...r,
710
- contextStore: We(c)
710
+ contextStore: ct(c)
711
711
  }).then(() => c);
712
712
  }), o = await Promise.all(n), i = e.merge || {};
713
713
  for (const a of o) {
714
714
  for (const c of i.bag || []) Object.prototype.hasOwnProperty.call(a.bag, c) && (t.bag[c] = a.bag[c]);
715
715
  if (i.panel?.length) {
716
- const c = H(a.context.panel, i.panel);
716
+ const c = X(a.context.panel, i.panel);
717
717
  Object.keys(c).length && (t.context = r.contextStore.patch(t.threadId, { panel: c }) || t.context);
718
718
  }
719
719
  if (i.threadExtensions?.length) {
720
- const c = H(a.context.thread.extensions, i.threadExtensions);
720
+ const c = X(a.context.thread.extensions, i.threadExtensions);
721
721
  Object.keys(c).length && (t.context = r.contextStore.patch(t.threadId, { thread: {
722
722
  ...t.context.thread,
723
723
  extensions: c
@@ -725,21 +725,21 @@ async function qe(e, t, r) {
725
725
  }
726
726
  }
727
727
  }
728
- async function Je(e, t, r, n) {
729
- r.emit(Be(x(e.message, n), !0)), await R(t, r);
728
+ async function ot(e, t, r, n) {
729
+ r.emit(ue(x(e.message, n), !0)), await K(t, r);
730
730
  }
731
- async function Le(e, t, r) {
732
- await R(t, r);
731
+ async function it(e, t, r) {
732
+ await K(t, r);
733
733
  }
734
- async function R(e, { contextStore: t, emit: r }) {
735
- e.committed || (e.context = await t.commit(e.threadId) || e.context, e.committed = !0, r(te()));
734
+ async function K(e, { contextStore: t, emit: r }) {
735
+ e.committed || (e.context = await t.commit(e.threadId) || e.context, e.committed = !0, r(le()));
736
736
  }
737
- function $(e, t, r, n) {
737
+ function v(e, t, r, n) {
738
738
  if (typeof e.patch != "function") return;
739
- const o = e.patch(r.context, t, U(r));
739
+ const o = e.patch(r.context, t, q(r));
740
740
  o && (r.context = n.patch(r.threadId, o) || r.context);
741
741
  }
742
- function U(e) {
742
+ function q(e) {
743
743
  return {
744
744
  request: e.request,
745
745
  context: e.context,
@@ -747,24 +747,24 @@ function U(e) {
747
747
  accountConfig: e.accountConfig
748
748
  };
749
749
  }
750
- function L(e) {
750
+ function Y(e) {
751
751
  return e.request?.session_id || e.request?.sessionId || e.threadId;
752
752
  }
753
- function He(e) {
753
+ function at(e) {
754
754
  return typeof structuredClone == "function" ? structuredClone(e) : JSON.parse(JSON.stringify(e));
755
755
  }
756
- function H(e, t) {
756
+ function X(e, t) {
757
757
  const r = {};
758
758
  for (const n of t) Object.prototype.hasOwnProperty.call(e, n) && (r[n] = e[n]);
759
759
  return r;
760
760
  }
761
- function We(e) {
761
+ function ct(e) {
762
762
  return {
763
763
  async load() {
764
764
  return e.context;
765
765
  },
766
766
  patch(t, r) {
767
- return e.context = Ve(e.context, r), e.context;
767
+ return e.context = st(e.context, r), e.context;
768
768
  },
769
769
  appendUserMessage() {
770
770
  return e.context;
@@ -774,7 +774,7 @@ function We(e) {
774
774
  }
775
775
  };
776
776
  }
777
- function Ve(e, t) {
777
+ function st(e, t) {
778
778
  return !t || typeof t != "object" ? e : {
779
779
  ...e,
780
780
  ...t,
@@ -800,7 +800,7 @@ function Ve(e, t) {
800
800
  function x(e, t) {
801
801
  return typeof e == "function" ? e(t) : e;
802
802
  }
803
- function Ge(e) {
803
+ function ut(e) {
804
804
  const t = e?.payload;
805
805
  if (typeof t == "string") return t;
806
806
  if (t && typeof t == "object" && "text" in t) {
@@ -809,7 +809,7 @@ function Ge(e) {
809
809
  }
810
810
  return typeof e?.action?.payload == "string" ? e.action.payload : typeof e?.action?.title == "string" ? e.action.title : "";
811
811
  }
812
- function Qe(e, t) {
812
+ function lt(e, t) {
813
813
  const r = e, n = r.spec, o = Array.isArray(n?.items) ? n.items : void 0, i = Array.isArray(r.items) ? r.items : void 0, a = o || i;
814
814
  if (Array.isArray(a)) {
815
815
  for (const c of a) if (c && typeof c == "object") {
@@ -818,7 +818,7 @@ function Qe(e, t) {
818
818
  }
819
819
  }
820
820
  }
821
- function At(e) {
821
+ function hr(e) {
822
822
  return { invoke(t, r) {
823
823
  return e("tool.invoke", {
824
824
  name: t,
@@ -826,11 +826,11 @@ function At(e) {
826
826
  });
827
827
  } };
828
828
  }
829
- function re(e) {
829
+ function fe(e) {
830
830
  return e && typeof e == "object" && !Array.isArray(e) ? e : null;
831
831
  }
832
- function F(e) {
833
- const t = re(e);
832
+ function J(e) {
833
+ const t = fe(e);
834
834
  if (!t) return null;
835
835
  const r = T(t.sku, t.SKU);
836
836
  if (!r) return null;
@@ -839,24 +839,24 @@ function F(e) {
839
839
  name: T(t.name, t.title, t.short_name, r) || r,
840
840
  url: T(t.url) || ""
841
841
  }, o = Array.isArray(t.images) ? t.images : void 0, i = T(t.imageUrl, t.image_url, t.image, o?.[0]);
842
- i && (n.imageUrl = i), o && o.length > 1 && (n.images = o.filter((p) => !!p).map(String));
843
- const a = j(t.price_discounted), c = j(t.price), s = a || c;
842
+ i && (n.imageUrl = i), o && o.length > 1 && (n.images = o.filter((m) => !!m).map(String));
843
+ const a = O(t.price_discounted), c = O(t.price), s = a || c;
844
844
  s > 0 && (n.price = String(s));
845
845
  const u = a > 0 ? c : 0;
846
846
  u > 0 && (n.originalPrice = String(u));
847
847
  const l = T(t.brand);
848
848
  l && (n.brand = l);
849
- const f = j(t.rating);
849
+ const f = O(t.rating);
850
850
  f > 0 && (n.rating = f);
851
- const m = j(t.review_count) || j(t.reviewCount);
852
- m > 0 && (n.reviewCount = m);
851
+ const p = O(t.review_count) || O(t.reviewCount);
852
+ p > 0 && (n.reviewCount = p);
853
853
  const d = T(t.cart_code, t.cartCode);
854
854
  d && (n.cartCode = d), typeof t.in_stock == "boolean" && (n.inStock = t.in_stock), typeof t.inStock == "boolean" && (n.inStock = t.inStock);
855
855
  const h = t.category_names;
856
856
  return Array.isArray(h) && (n.categoryNames = h.map(String)), n;
857
857
  }
858
- function ne(e) {
859
- const t = re(e);
858
+ function W(e) {
859
+ const t = fe(e);
860
860
  if (!t) return e;
861
861
  const r = t.category_names, n = Array.isArray(r) ? r : void 0, o = t.images, i = Array.isArray(o) ? o : void 0, a = {
862
862
  sku: t.sku,
@@ -874,85 +874,144 @@ function ne(e) {
874
874
  for (const c of Object.keys(a)) a[c] === void 0 && delete a[c];
875
875
  return a;
876
876
  }
877
- function Tt(e) {
878
- return Array.isArray(e) ? e.map(ne).filter((t) => !!t) : [];
877
+ function br(e) {
878
+ return Array.isArray(e) ? e.map(W).filter((t) => !!t) : [];
879
879
  }
880
880
  function T(...e) {
881
881
  for (const t of e) if (typeof t == "string" && t.trim()) return t.trim();
882
882
  return "";
883
883
  }
884
- function j(e) {
884
+ function O(e) {
885
885
  const t = Number(e);
886
886
  return Number.isFinite(t) ? t : 0;
887
887
  }
888
- function W(e) {
888
+ function ee(e) {
889
889
  return Array.isArray(e) ? e.map(String).filter(Boolean) : typeof e == "string" && e ? [e] : [];
890
890
  }
891
- function It(e, t, r = {}) {
892
- return `${e}:${r.version || "v2"}:${oe(t)}`;
891
+ function kr(e, t, r = {}) {
892
+ return `${e}:${r.version || "v2"}:${de(t)}`;
893
893
  }
894
- function Et(e, t = {}) {
895
- return ie(e).map((r) => ae(typeof r == "string" ? r : r.sku, t.locale)).filter(Boolean).filter((r, n, o) => o.indexOf(r) === n).sort((r, n) => D(r, n, t.locale)).slice(0, t.limit || 16).join(",");
894
+ function wr(e, t = {}) {
895
+ return me(e).map((r) => pe(typeof r == "string" ? r : r.sku, t.locale)).filter(Boolean).filter((r, n, o) => o.indexOf(r) === n).sort((r, n) => H(r, n, t.locale)).slice(0, t.limit || 16).join(",");
896
896
  }
897
- function jt(e, t = {}) {
898
- return oe(ie(e).map((r) => Ye(r, t)).filter((r) => !!r).sort((r, n) => D(String(r.sku || r.name || ""), String(n.sku || n.name || ""), t.locale)).slice(0, t.limit || 16));
897
+ function Sr(e, t = {}) {
898
+ return de(me(e).map((r) => ft(r, t)).filter((r) => !!r).sort((r, n) => H(String(r.sku || r.name || ""), String(n.sku || n.name || ""), t.locale)).slice(0, t.limit || 16));
899
899
  }
900
- function Ot(e, t) {
901
- return S(e, t);
900
+ function Ar(e, t) {
901
+ return A(e, t);
902
902
  }
903
- function oe(e) {
903
+ function de(e) {
904
904
  let t = 2166136261;
905
- const r = Xe(e);
905
+ const r = dt(e);
906
906
  for (let n = 0; n < r.length; n += 1)
907
907
  t ^= r.charCodeAt(n), t = Math.imul(t, 16777619);
908
908
  return (t >>> 0).toString(36);
909
909
  }
910
- function Ye(e, t) {
910
+ function ft(e, t) {
911
911
  if (!e || typeof e != "object" || Array.isArray(e)) return null;
912
912
  const r = e, n = t.mapProduct?.(r);
913
- if (n) return C(n);
914
- const o = ne(r);
915
- return o && typeof o == "object" && !Array.isArray(o) ? C(Ze(o, t)) : null;
913
+ if (n) return P(n);
914
+ const o = W(r);
915
+ return o && typeof o == "object" && !Array.isArray(o) ? P(mt(o, t)) : null;
916
916
  }
917
- function ie(e) {
917
+ function me(e) {
918
918
  return Array.isArray(e) ? e.filter((t) => typeof t == "string" || !!(t && typeof t == "object" && !Array.isArray(t))) : [];
919
919
  }
920
- function Xe(e) {
921
- return JSON.stringify(C(e));
920
+ function dt(e) {
921
+ return JSON.stringify(P(e));
922
922
  }
923
- function C(e) {
924
- return Array.isArray(e) ? e.map(C) : !e || typeof e != "object" ? e : Object.fromEntries(Object.entries(e).filter(([, t]) => t !== void 0).sort(([t], [r]) => t.localeCompare(r)).map(([t, r]) => [t, C(r)]));
923
+ function P(e) {
924
+ return Array.isArray(e) ? e.map(P) : !e || typeof e != "object" ? e : Object.fromEntries(Object.entries(e).filter(([, t]) => t !== void 0).sort(([t], [r]) => t.localeCompare(r)).map(([t, r]) => [t, P(r)]));
925
925
  }
926
- function Ze(e, t) {
926
+ function mt(e, t) {
927
927
  return {
928
- sku: ae(e.sku, t.locale),
929
- name: S(e.name, t.locale),
930
- url: S(e.url, t.locale),
928
+ sku: pe(e.sku, t.locale),
929
+ name: A(e.name, t.locale),
930
+ url: A(e.url, t.locale),
931
931
  price: e.price,
932
- currency: S(e.currency, t.locale),
933
- category: S(e.category, t.locale),
934
- category_names: et(e.category_names, t.locale, 16),
935
- image: S(e.image, t.locale),
932
+ currency: A(e.currency, t.locale),
933
+ category: A(e.category, t.locale),
934
+ category_names: pt(e.category_names, t.locale, 16),
935
+ image: A(e.image, t.locale),
936
936
  in_stock: e.in_stock,
937
937
  rating: e.rating,
938
938
  review_count: e.review_count
939
939
  };
940
940
  }
941
- function ae(e, t) {
942
- return S(e, t).toUpperCase();
941
+ function pe(e, t) {
942
+ return A(e, t).toUpperCase();
943
943
  }
944
- function S(e, t) {
944
+ function A(e, t) {
945
945
  return typeof e == "string" ? e.trim().replace(/\s+/gu, " ").toLocaleLowerCase(t || void 0) : "";
946
946
  }
947
- function D(e, t, r) {
947
+ function H(e, t, r) {
948
948
  return e.localeCompare(t, r, { numeric: !0 });
949
949
  }
950
- function et(e, t, r) {
951
- return Array.isArray(e) ? e.map((n) => S(n, t)).filter(Boolean).sort((n, o) => D(n, o, t)).slice(0, r) : void 0;
950
+ function pt(e, t, r) {
951
+ return Array.isArray(e) ? e.map((n) => A(n, t)).filter(Boolean).sort((n, o) => H(n, o, t)).slice(0, r) : void 0;
952
+ }
953
+ function xr(e, t = {}) {
954
+ if (!Array.isArray(e)) return [];
955
+ const r = t.maxItems ?? 8, n = t.maxFeatures ?? 8;
956
+ return e.map((o) => yt(o, t.defaultBrand, n)).filter((o) => !!o).slice(0, r);
957
+ }
958
+ function yt(e, t, r) {
959
+ if (!e || typeof e != "object" || Array.isArray(e)) return null;
960
+ const n = e, o = W(n);
961
+ return o ? bt({
962
+ sku: o.sku,
963
+ name: o.name,
964
+ url: o.url,
965
+ image: o.image,
966
+ price: o.price,
967
+ currency: o.currency,
968
+ category: o.category,
969
+ category_names: o.category_names,
970
+ brand: n.brand || t,
971
+ features: gt(n.features, r),
972
+ specs: ht(n.specs, r),
973
+ in_stock: o.in_stock
974
+ }) : null;
975
+ }
976
+ function gt(e, t) {
977
+ return Array.isArray(e) ? e.filter(Boolean).slice(0, t) : void 0;
978
+ }
979
+ function ht(e, t) {
980
+ if (!(!e || typeof e != "object" || Array.isArray(e)))
981
+ return Object.fromEntries(Object.entries(e).filter(([, r]) => r != null).slice(0, t));
982
+ }
983
+ function bt(e) {
984
+ return Object.fromEntries(Object.entries(e).filter(([, t]) => t != null));
985
+ }
986
+ function ye(e) {
987
+ if (!e || typeof e != "object" || Array.isArray(e)) return {};
988
+ const t = e, r = Array.isArray(t.rows) ? t.rows : [];
989
+ return {
990
+ ...t,
991
+ rows: r.map(wt).filter(Boolean)
992
+ };
993
+ }
994
+ function kt(e, t) {
995
+ const r = Array.isArray(e) ? e.filter((c) => !!(c && typeof c == "object" && !Array.isArray(c))) : [], n = ye(t), o = Array.isArray(n.columns) ? n.columns.map(String) : [];
996
+ if (!o.length) return r;
997
+ const i = new Map(r.map((c) => [String(c.sku || c.id || ""), c])), a = o.map((c) => i.get(c)).filter((c) => !!c);
998
+ return a.length ? a : r;
999
+ }
1000
+ function _r(e, t) {
1001
+ const r = ye(e?.table), n = kt(t, r);
1002
+ return {
1003
+ ...e || {},
1004
+ table: r,
1005
+ products: n,
1006
+ multiple_product_details: n
1007
+ };
952
1008
  }
953
- function Ct(e = []) {
1009
+ function wt(e) {
1010
+ return !e || typeof e != "object" || Array.isArray(e) ? null : Object.fromEntries(Object.entries(e).filter(([, t]) => t !== void 0));
1011
+ }
1012
+ function St(e = []) {
954
1013
  const t = {}, r = [];
955
- return (Array.isArray(e) ? e.map(F).filter((n) => !!n) : []).forEach((n, o) => {
1014
+ return (Array.isArray(e) ? e.map(J).filter((n) => !!n) : []).forEach((n, o) => {
956
1015
  const i = `product-${o.toString()}`;
957
1016
  r.push(i);
958
1017
  const a = {
@@ -984,7 +1043,7 @@ function Ct(e = []) {
984
1043
  }
985
1044
  };
986
1045
  }
987
- function Pt(e) {
1046
+ function At(e) {
988
1047
  return {
989
1048
  widget: "chat",
990
1049
  panelHint: "panel",
@@ -992,13 +1051,13 @@ function Pt(e) {
992
1051
  root: "root",
993
1052
  elements: { root: {
994
1053
  type: "ProductDetailsPanel",
995
- props: { product: F(e) || e || {} }
1054
+ props: { product: J(e) || e || {} }
996
1055
  } }
997
1056
  }
998
1057
  };
999
1058
  }
1000
- function Mt(e = {}) {
1001
- const t = (e.multiple_product_details || e.products || []).map(F).filter((n) => !!n), r = e.table || {};
1059
+ function xt(e = {}) {
1060
+ const t = (e.multiple_product_details || e.products || []).map(J).filter((n) => !!n), r = e.table || {};
1002
1061
  return {
1003
1062
  widget: "chat",
1004
1063
  panelHint: "panel",
@@ -1013,8 +1072,8 @@ function Mt(e = {}) {
1013
1072
  label: n,
1014
1073
  values: Array.isArray(o) ? o.map(String) : [String(o ?? "")]
1015
1074
  })),
1016
- highlights: W(e.key_differences),
1017
- specialCases: W(e.special_considerations),
1075
+ highlights: ee(e.key_differences),
1076
+ specialCases: ee(e.special_considerations),
1018
1077
  recommendedText: e.recommended_choice,
1019
1078
  productActions: Object.fromEntries(t.map((n) => [n.sku, {
1020
1079
  title: n.name,
@@ -1029,7 +1088,7 @@ function Mt(e = {}) {
1029
1088
  }
1030
1089
  };
1031
1090
  }
1032
- function Nt(e = []) {
1091
+ function _t(e = []) {
1033
1092
  return {
1034
1093
  widget: "chat",
1035
1094
  panelHint: "inline",
@@ -1052,17 +1111,17 @@ function Nt(e = []) {
1052
1111
  }
1053
1112
  };
1054
1113
  }
1055
- function Bt(e) {
1114
+ function Tr(e) {
1056
1115
  return Object.freeze([...e]);
1057
1116
  }
1058
- var V = /* @__PURE__ */ new Set([
1117
+ var te = /* @__PURE__ */ new Set([
1059
1118
  "and",
1060
1119
  "are",
1061
1120
  "for",
1062
1121
  "from",
1063
1122
  "the",
1064
1123
  "with"
1065
- ]), tt = {
1124
+ ]), Tt = {
1066
1125
  token: 0.26,
1067
1126
  keyword: 0.22,
1068
1127
  category: 0.18,
@@ -1071,7 +1130,7 @@ var V = /* @__PURE__ */ new Set([
1071
1130
  attribute: 0.06,
1072
1131
  price: 0.08,
1073
1132
  retrieval: 0.08
1074
- }, rt = [
1133
+ }, jt = [
1075
1134
  "amber",
1076
1135
  "beige",
1077
1136
  "black",
@@ -1095,18 +1154,18 @@ var V = /* @__PURE__ */ new Set([
1095
1154
  "white",
1096
1155
  "yellow"
1097
1156
  ];
1098
- function _(e) {
1157
+ function w(e) {
1099
1158
  return String(e ?? "").normalize("NFKD").replace(new RegExp("\\p{Diacritic}", "gu"), "").toLowerCase().replace(/[^\p{L}\p{N}]+/gu, " ").replace(/\s+/gu, " ").trim();
1100
1159
  }
1101
- function w(e, t = V) {
1102
- const r = t instanceof Set ? t : /* @__PURE__ */ new Set([...V, ...t]), n = /* @__PURE__ */ new Set(), o = [];
1103
- for (const i of _(e).split(/\s+/u))
1160
+ function b(e, t = te) {
1161
+ const r = t instanceof Set ? t : /* @__PURE__ */ new Set([...te, ...t]), n = /* @__PURE__ */ new Set(), o = [];
1162
+ for (const i of w(e).split(/\s+/u))
1104
1163
  i.length < 3 || r.has(i) || n.has(i) || (n.add(i), o.push(i));
1105
1164
  return o;
1106
1165
  }
1107
- function B(e, t = {}) {
1108
- if (ot(e)) return e;
1109
- const r = t.facetKeys, n = y(e.category_names ?? e.category), o = y(e.category_ids), i = it(e.facet_hits), a = Object.entries(i).filter(([p]) => !r || r.some((A) => _(A) === _(p))).map(([, p]) => p), c = k(e.name, e.title), s = k(e.brand), u = t.sourceKeywords ?? [], l = [
1166
+ function $(e, t = {}) {
1167
+ if (Ot(e)) return e;
1168
+ const r = t.facetKeys, n = y(e.category_names ?? e.category), o = y(e.category_ids), i = It(e.facet_hits), a = Object.entries(i).filter(([m]) => !r || r.some((_) => w(_) === w(m))).map(([, m]) => m), c = k(e.name, e.title), s = k(e.brand), u = t.sourceKeywords ?? [], l = [
1110
1169
  c,
1111
1170
  s,
1112
1171
  ...n,
@@ -1114,31 +1173,31 @@ function B(e, t = {}) {
1114
1173
  ...y(e.promotions),
1115
1174
  k(e.description),
1116
1175
  ...u
1117
- ].join(" "), f = w(l, t.stopWords), m = k(t.sourceProductType, st(n, c, f), f[0]), d = b([...ct(l, rt), ...Object.entries(i).filter(([p]) => /colou?r/iu.test(p)).flatMap(([, p]) => w(p, t.stopWords))]), h = b([...a.flatMap((p) => w(p, t.stopWords)), ...y(e.promotions).flatMap((p) => w(p, t.stopWords))]).slice(0, 24);
1176
+ ].join(" "), f = b(l, t.stopWords), p = k(t.sourceProductType, Mt(n, c, f), f[0]), d = S([...Ct(l, jt), ...Object.entries(i).filter(([m]) => /colou?r/iu.test(m)).flatMap(([, m]) => b(m, t.stopWords))]), h = S([...a.flatMap((m) => b(m, t.stopWords)), ...y(e.promotions).flatMap((m) => b(m, t.stopWords))]).slice(0, 24);
1118
1177
  return {
1119
1178
  sku: k(e.sku),
1120
1179
  title: c,
1121
1180
  brand: s,
1122
- productType: m,
1181
+ productType: p,
1123
1182
  categoryNames: n,
1124
1183
  categoryIds: o,
1125
1184
  facets: i,
1126
- keywords: b([...u.flatMap((p) => w(p, t.stopWords)), ...f]).slice(0, 12),
1185
+ keywords: S([...u.flatMap((m) => b(m, t.stopWords)), ...f]).slice(0, 12),
1127
1186
  tokens: f,
1128
1187
  colors: d,
1129
1188
  attributes: h,
1130
- price: at(e)
1189
+ price: Pt(e)
1131
1190
  };
1132
1191
  }
1133
- function vt(e, t = {}) {
1134
- const r = k(e.product_type, e.productType), n = k(e.title, r, y(e.keywords).join(" ")), o = b([
1192
+ function jr(e, t = {}) {
1193
+ const r = k(e.product_type, e.productType), n = k(e.title, r, y(e.keywords).join(" ")), o = S([
1135
1194
  ...y(e.keywords),
1136
1195
  ...y(e.colors),
1137
1196
  ...y(e.materials),
1138
1197
  ...y(e.styles),
1139
1198
  ...y(e.attributes)
1140
1199
  ]);
1141
- return B({
1200
+ return $({
1142
1201
  sku: "__photo__",
1143
1202
  name: n,
1144
1203
  category_names: r ? [r] : [],
@@ -1155,9 +1214,9 @@ function vt(e, t = {}) {
1155
1214
  sourceKeywords: o
1156
1215
  });
1157
1216
  }
1158
- function Rt(e, t = {}) {
1159
- const r = B(e, t);
1160
- return b([
1217
+ function Er(e, t = {}) {
1218
+ const r = $(e, t);
1219
+ return S([
1161
1220
  ...t.sourceQueries ?? [],
1162
1221
  N([
1163
1222
  r.productType,
@@ -1170,23 +1229,23 @@ function Rt(e, t = {}) {
1170
1229
  r.productType
1171
1230
  ].map((n) => n.trim()).filter(Boolean)).slice(0, t.queryLimit ?? 6);
1172
1231
  }
1173
- function nt(e, t, r = {}) {
1232
+ function Et(e, t, r = {}) {
1174
1233
  const n = {
1175
- ...tt,
1234
+ ...Tt,
1176
1235
  ...r.weights
1177
- }, o = B(t, r), i = [], a = I(e.tokens, o.tokens), c = I(e.keywords, o.tokens), s = ut(e.categoryNames, o.categoryNames) || I(G(e.categoryNames), G(o.categoryNames)), u = I(e.attributes, o.attributes), l = I(e.colors, o.colors), f = I(e.attributes, o.tokens), m = lt(e.price, o.price), d = ft(o.sku, r.hitCounts) > 0 ? 1 : 0, h = dt(e, o), p = a * n.token + c * n.keyword + s * n.category + u * n.facet + l * n.color + f * n.attribute + m * n.price + d * n.retrieval, A = pt(h ? p : p * 0.35);
1178
- return h && e.productType && e.productType === o.productType && i.push("same product type"), s > 0.4 && i.push("similar category"), u > 0.2 && i.push("matching product attributes"), l > 0 && i.push("matching colour"), m > 0.8 && i.push("similar price"), h || i.push("weaker product-type match"), {
1179
- score: Number(A.toFixed(4)),
1236
+ }, o = $(t, r), i = [], a = j(e.tokens, o.tokens), c = j(e.keywords, o.tokens), s = Bt(e.categoryNames, o.categoryNames) || j(re(e.categoryNames), re(o.categoryNames)), u = j(e.attributes, o.attributes), l = j(e.colors, o.colors), f = j(e.attributes, o.tokens), p = Nt(e.price, o.price), d = Rt(o.sku, r.hitCounts) > 0 ? 1 : 0, h = Ut(e, o), m = a * n.token + c * n.keyword + s * n.category + u * n.facet + l * n.color + f * n.attribute + p * n.price + d * n.retrieval, _ = $t(h ? m : m * 0.35);
1237
+ return h && e.productType && e.productType === o.productType && i.push("same product type"), s > 0.4 && i.push("similar category"), u > 0.2 && i.push("matching product attributes"), l > 0 && i.push("matching colour"), p > 0.8 && i.push("similar price"), h || i.push("weaker product-type match"), {
1238
+ score: Number(_.toFixed(4)),
1180
1239
  reasons: i
1181
1240
  };
1182
1241
  }
1183
- function $t(e, t, r = {}) {
1184
- const n = B(e, r), o = new Set([n.sku, ...r.ignoreSkus ?? []].filter(Boolean));
1242
+ function Or(e, t, r = {}) {
1243
+ const n = $(e, r), o = new Set([n.sku, ...r.ignoreSkus ?? []].filter(Boolean));
1185
1244
  return t.filter((i) => {
1186
1245
  const a = k(i.sku);
1187
1246
  return a && !o.has(a);
1188
1247
  }).map((i) => {
1189
- const a = nt(n, i, r);
1248
+ const a = Et(n, i, r);
1190
1249
  return {
1191
1250
  ...i,
1192
1251
  similarity_score: a.score,
@@ -1194,7 +1253,7 @@ function $t(e, t, r = {}) {
1194
1253
  };
1195
1254
  }).sort((i, a) => a.similarity_score - i.similarity_score).slice(0, Math.max(1, Math.min(r.limit ?? 12, 100)));
1196
1255
  }
1197
- function ot(e) {
1256
+ function Ot(e) {
1198
1257
  return !!(e && typeof e == "object" && Array.isArray(e.tokens));
1199
1258
  }
1200
1259
  function k(...e) {
@@ -1204,64 +1263,311 @@ function k(...e) {
1204
1263
  function y(e) {
1205
1264
  return Array.isArray(e) ? e.map((t) => k(t)).filter(Boolean) : typeof e == "string" && e.trim() ? e.split(/[,;/|]+/u).map((t) => t.trim()).filter(Boolean) : [];
1206
1265
  }
1207
- function it(e) {
1266
+ function It(e) {
1208
1267
  return !e || typeof e != "object" || Array.isArray(e) ? {} : Object.fromEntries(Object.entries(e).map(([t, r]) => [t, k(r)]).filter(([, t]) => t));
1209
1268
  }
1210
- function at(e) {
1269
+ function Pt(e) {
1211
1270
  const t = Number(e.price_discounted);
1212
1271
  if (Number.isFinite(t) && t > 0) return t;
1213
1272
  const r = Number(e.price);
1214
1273
  return Number.isFinite(r) && r > 0 ? r : 0;
1215
1274
  }
1216
- function b(e) {
1275
+ function S(e) {
1217
1276
  const t = /* @__PURE__ */ new Set(), r = [];
1218
1277
  for (const n of e) {
1219
- const o = _(n);
1278
+ const o = w(n);
1220
1279
  !o || t.has(o) || (t.add(o), r.push(o));
1221
1280
  }
1222
1281
  return r;
1223
1282
  }
1224
- function ct(e, t) {
1225
- const r = ` ${_(e)} `;
1226
- return t.filter((n) => r.includes(` ${_(n)} `));
1283
+ function Ct(e, t) {
1284
+ const r = ` ${w(e)} `;
1285
+ return t.filter((n) => r.includes(` ${w(n)} `));
1227
1286
  }
1228
- function st(e, t, r) {
1229
- const n = _(e[e.length - 1] ?? e[0] ?? "");
1287
+ function Mt(e, t, r) {
1288
+ const n = w(e[e.length - 1] ?? e[0] ?? "");
1230
1289
  if (n) {
1231
- const o = w(n), i = new Set(w(t));
1290
+ const o = b(n), i = new Set(b(t));
1232
1291
  return o.find((a) => i.has(a)) ?? o[0] ?? n;
1233
1292
  }
1234
1293
  return r[0] ?? "";
1235
1294
  }
1236
1295
  function N(e) {
1237
- return e.map((t) => _(t)).filter(Boolean).join(" ").replace(/\s+/gu, " ").trim().slice(0, 120);
1296
+ return e.map((t) => w(t)).filter(Boolean).join(" ").replace(/\s+/gu, " ").trim().slice(0, 120);
1238
1297
  }
1239
- function G(e) {
1240
- return e.flatMap((t) => w(t));
1298
+ function re(e) {
1299
+ return e.flatMap((t) => b(t));
1241
1300
  }
1242
- function I(e, t) {
1243
- const r = b(e), n = new Set(b(t));
1301
+ function j(e, t) {
1302
+ const r = S(e), n = new Set(S(t));
1244
1303
  return r.length === 0 || n.size === 0 ? 0 : r.filter((o) => n.has(o)).length / r.length;
1245
1304
  }
1246
- function ut(e, t) {
1247
- const r = b(e), n = new Set(b(t));
1305
+ function Bt(e, t) {
1306
+ const r = S(e), n = new Set(S(t));
1248
1307
  return r.length === 0 || n.size === 0 ? 0 : r.filter((o) => n.has(o)).length / r.length;
1249
1308
  }
1250
- function lt(e, t) {
1309
+ function Nt(e, t) {
1251
1310
  return e <= 0 || t <= 0 ? 0 : Math.min(e, t) / Math.max(e, t);
1252
1311
  }
1253
- function ft(e, t) {
1312
+ function Rt(e, t) {
1254
1313
  return !e || !t ? 0 : typeof t.get == "function" ? t.get(e) ?? 0 : t[e] ?? 0;
1255
1314
  }
1256
- function dt(e, t) {
1315
+ function Ut(e, t) {
1257
1316
  if (!e.productType || !t.productType || e.productType === t.productType) return !0;
1258
- const r = new Set(w(e.productType)), n = /* @__PURE__ */ new Set([...w(t.productType), ...t.tokens]);
1317
+ const r = new Set(b(e.productType)), n = /* @__PURE__ */ new Set([...b(t.productType), ...t.tokens]);
1259
1318
  return [...r].some((o) => n.has(o));
1260
1319
  }
1261
- function pt(e) {
1320
+ function $t(e) {
1262
1321
  return Math.max(0, Math.min(1, e));
1263
1322
  }
1264
- function Ut(e) {
1323
+ function Ir(e, t = {}) {
1324
+ if (!Array.isArray(e)) return [];
1325
+ const r = e.filter((n) => !!(n && typeof n == "object" && !Array.isArray(n))).map((n, o) => ({
1326
+ product: n,
1327
+ index: o,
1328
+ score: Ft(n, t)
1329
+ })).sort((n, o) => o.score - n.score || n.index - o.index).map(({ product: n }) => n);
1330
+ return typeof t.limit == "number" ? r.slice(0, t.limit) : r;
1331
+ }
1332
+ function Ft(e, t = {}) {
1333
+ const r = Dt(t), n = ge(e);
1334
+ let o = 0;
1335
+ for (const i of r) n.includes(i) && (o += i.length > 3 ? 3 : 1);
1336
+ return zt(e) && (o += 2), Lt(e) && (o += 2), Kt(e) && (o += 1), e.in_stock === !1 && (o -= 5), o;
1337
+ }
1338
+ function Dt(e = {}) {
1339
+ const t = [
1340
+ e.query,
1341
+ e.searchInput?.brands,
1342
+ e.searchInput?.categories,
1343
+ e.searchInput?.features,
1344
+ e.searchInput?.keywords,
1345
+ e.intent?.brands,
1346
+ e.intent?.categories,
1347
+ e.intent?.keywords
1348
+ ];
1349
+ return [...new Set(t.flatMap(qt))];
1350
+ }
1351
+ function zt(e) {
1352
+ return e.price != null || e.price_discounted != null || e.priceText != null;
1353
+ }
1354
+ function Lt(e) {
1355
+ return !!(e.image || e.imageUrl || Array.isArray(e.images) && e.images[0]);
1356
+ }
1357
+ function Kt(e) {
1358
+ return !!(e.category || e.category_names || e.features || e.specs || e.facet_hits);
1359
+ }
1360
+ function ge(e) {
1361
+ return w([
1362
+ e.name,
1363
+ e.title,
1364
+ e.brand,
1365
+ e.category,
1366
+ e.category_names,
1367
+ e.features,
1368
+ e.specs,
1369
+ e.facet_hits
1370
+ ].flatMap(R).join(" "));
1371
+ }
1372
+ function vt(e) {
1373
+ return w(typeof e == "string" ? e : e == null ? "" : String(e));
1374
+ }
1375
+ function qt(e) {
1376
+ return R(e).join(" ").split(/\s+/u).map(vt).filter((t) => t.length > 1);
1377
+ }
1378
+ function R(e) {
1379
+ return Array.isArray(e) ? e.flatMap(R) : e && typeof e == "object" ? Object.values(e).flatMap(R) : e == null ? [] : [String(e)];
1380
+ }
1381
+ function z(e) {
1382
+ if (!Array.isArray(e)) return [];
1383
+ const t = /* @__PURE__ */ new Set(), r = [];
1384
+ for (const n of e) {
1385
+ if (!n || typeof n != "object" || Array.isArray(n)) continue;
1386
+ const o = n, i = String(o.sku || o.url || o.name || "");
1387
+ !i || t.has(i) || (t.add(i), r.push(o));
1388
+ }
1389
+ return r;
1390
+ }
1391
+ function Pr(e, t) {
1392
+ const r = z(e);
1393
+ if (!t || typeof t != "object" || Array.isArray(t)) return r;
1394
+ const n = Object.values(t).flatMap((o) => Array.isArray(o) ? o : [o]).map((o) => String(o || "").trim().toLocaleLowerCase()).filter(Boolean);
1395
+ return n.length ? r.filter((o) => {
1396
+ const i = ge(o);
1397
+ return n.some((a) => i.includes(a));
1398
+ }) : r;
1399
+ }
1400
+ function Cr(e, t, r = 8) {
1401
+ const n = z(e), o = z(t), i = new Set(o.map((a) => String(a.sku || a.url || a.name || "")));
1402
+ return n.map((a, c) => ({
1403
+ product: a,
1404
+ index: c,
1405
+ score: Jt(a, i)
1406
+ })).sort((a, c) => c.score - a.score || a.index - c.index).map(({ product: a }) => a).slice(0, r);
1407
+ }
1408
+ function Jt(e, t) {
1409
+ const r = String(e.sku || e.url || e.name || "");
1410
+ return t.has(r) ? 10 : 0;
1411
+ }
1412
+ function Wt(e, t = {}) {
1413
+ const r = e.sku, n = t.labels || {};
1414
+ return [
1415
+ t.includeCompare !== !1 && r ? D(n.compare || "Compare", {
1416
+ type: "compare",
1417
+ payload: { skus: [r] }
1418
+ }) : null,
1419
+ t.includeSpecs !== !1 && r ? D(n.specs || "Specs", {
1420
+ type: "productQuestion",
1421
+ payload: {
1422
+ sku: r,
1423
+ text: n.specs || "Specs"
1424
+ }
1425
+ }) : null,
1426
+ t.includeSimilar !== !1 && r ? D(n.similar || "Similar", {
1427
+ type: "findSimilar",
1428
+ payload: { sku: r }
1429
+ }) : null
1430
+ ].filter((o) => !!o);
1431
+ }
1432
+ function Mr(e, t = {}) {
1433
+ return Array.isArray(e) ? e.flatMap((r) => r && typeof r == "object" && !Array.isArray(r) ? Wt(r, t) : []) : [];
1434
+ }
1435
+ function D(e, t) {
1436
+ return {
1437
+ label: he(e),
1438
+ requestDetails: t
1439
+ };
1440
+ }
1441
+ function Br(e, t = 4) {
1442
+ return Array.isArray(e) ? e.map((r) => r && typeof r == "object" && !Array.isArray(r) ? r : null).filter((r) => !!r).map((r) => ({
1443
+ ...r,
1444
+ label: he(r.label)
1445
+ })).filter((r) => r.label).slice(0, t) : [];
1446
+ }
1447
+ function he(e, t = 48) {
1448
+ const r = typeof e == "string" ? e.trim().replace(/\s+/gu, " ") : "";
1449
+ return r.length > t ? `${r.slice(0, t - 1).trim()}...` : r;
1450
+ }
1451
+ function Nr(e = {}) {
1452
+ return e.steps ? [...e.steps] : F("intent", "intent", e);
1453
+ }
1454
+ function Rr(e = {}) {
1455
+ return e.steps ? [...e.steps] : [
1456
+ be("search", "products", e),
1457
+ ...e.emitProducts === !1 ? [] : [ke(e.out || "products")],
1458
+ ...M(e)
1459
+ ];
1460
+ }
1461
+ function Ht(e = {}) {
1462
+ if (e.steps) return [...e.steps];
1463
+ const t = e.out || "answer";
1464
+ return [
1465
+ ...F("product-answer", "answer", e),
1466
+ ...e.emitProductDetails ? [Vt("product")] : [],
1467
+ ...M(e, t)
1468
+ ];
1469
+ }
1470
+ function Ur(e = {}) {
1471
+ return Ht(e);
1472
+ }
1473
+ function $r(e = {}) {
1474
+ if (e.steps) return [...e.steps];
1475
+ const t = e.out || "comparison";
1476
+ return [
1477
+ ...F("compare", "comparison", e),
1478
+ ...e.emitComparison === !1 ? [] : [we(t)],
1479
+ ...M(e, t)
1480
+ ];
1481
+ }
1482
+ function Fr(e = {}) {
1483
+ return e.steps ? [...e.steps] : [be("search", "products", e)];
1484
+ }
1485
+ function Dr(e = {}) {
1486
+ return Qt(e);
1487
+ }
1488
+ function Qt(e = {}) {
1489
+ return e.steps ? [...e.steps] : [we(e.out || "comparison"), ...M(e, "comparison")];
1490
+ }
1491
+ function zr(e = {}) {
1492
+ return e.steps ? [...e.steps] : [ke(e.out || "products"), ...M(e, "products")];
1493
+ }
1494
+ function Lr(e = {}) {
1495
+ return e.steps ? [...e.steps] : [...F("suggested-actions", "suggestedActions", e), ...e.emitActions === !1 ? [] : [Gt(e.out || "suggestedActions")]];
1496
+ }
1497
+ function F(e, t, r) {
1498
+ return [{
1499
+ kind: "be_op",
1500
+ op: r.beOpName || e,
1501
+ input: r.input ?? (() => ({})),
1502
+ ...r.cacheTtlS !== void 0 ? { cacheTtlS: r.cacheTtlS } : {},
1503
+ ...r.cacheKey !== void 0 ? { cacheKey: r.cacheKey } : {},
1504
+ ...r.browserCache !== void 0 ? { browserCache: r.browserCache } : {},
1505
+ ...r.errorOut ? { errorOut: r.errorOut } : {},
1506
+ ...r.onError ? { onError: r.onError } : {},
1507
+ ...r.patch ? { patch: r.patch } : {},
1508
+ out: r.out || t
1509
+ }];
1510
+ }
1511
+ function be(e, t, r) {
1512
+ return {
1513
+ kind: "tool",
1514
+ name: r.toolName || e,
1515
+ input: r.input ?? (() => ({})),
1516
+ ...r.errorOut ? { errorOut: r.errorOut } : {},
1517
+ ...r.onError ? { onError: r.onError } : {},
1518
+ ...r.patch ? { patch: r.patch } : {},
1519
+ out: r.out || t
1520
+ };
1521
+ }
1522
+ function ke(e) {
1523
+ return {
1524
+ kind: "emit",
1525
+ build: ({ bag: t }) => U(St(Yt(t[e])))
1526
+ };
1527
+ }
1528
+ function Vt(e) {
1529
+ return {
1530
+ kind: "emit",
1531
+ build: ({ bag: t }) => U(At(t[e]))
1532
+ };
1533
+ }
1534
+ function we(e) {
1535
+ return {
1536
+ kind: "emit",
1537
+ build: ({ bag: t }) => U(xt(t[e]))
1538
+ };
1539
+ }
1540
+ function Gt(e) {
1541
+ return {
1542
+ kind: "emit",
1543
+ build: ({ bag: t }) => U(_t(Xt(t[e])))
1544
+ };
1545
+ }
1546
+ function M(e, t) {
1547
+ return !e.emitText && !t ? [] : [{
1548
+ kind: "emit",
1549
+ build: (r) => ue(Zt(e.emitText, r, t), !0)
1550
+ }];
1551
+ }
1552
+ function Zt(e, t, r) {
1553
+ if (typeof e == "function") return e(t);
1554
+ if (typeof e == "string") return e;
1555
+ const n = r ? t.bag[r] : void 0;
1556
+ return String(n?.answer_html || n?.plain_text || n?.summary || "");
1557
+ }
1558
+ function Yt(e) {
1559
+ return Array.isArray(e) ? e : e && typeof e == "object" && Array.isArray(e.products) ? e.products : [];
1560
+ }
1561
+ function Xt(e) {
1562
+ if (Array.isArray(e)) return e;
1563
+ if (e && typeof e == "object") {
1564
+ const t = e;
1565
+ if (Array.isArray(t.actions)) return t.actions;
1566
+ if (Array.isArray(t.buttons)) return t.buttons;
1567
+ }
1568
+ return [];
1569
+ }
1570
+ function er(e) {
1265
1571
  const t = e?.payload;
1266
1572
  if (typeof t == "string") return t;
1267
1573
  if (t && typeof t == "object" && "text" in t) {
@@ -1271,48 +1577,155 @@ function Ut(e) {
1271
1577
  const r = e?.action;
1272
1578
  return r && typeof r.payload == "string" ? r.payload : r && typeof r.title == "string" ? r.title : "";
1273
1579
  }
1580
+ var tr = [
1581
+ {
1582
+ pattern: /\bhttps?:\/\/[^\s?#]+(?:\?[^\s#]*)?/giu,
1583
+ replacement: nr
1584
+ },
1585
+ {
1586
+ pattern: /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/giu,
1587
+ replacement: "[email]"
1588
+ },
1589
+ {
1590
+ pattern: /\b(?:\+?\d[\d\s().-]{7,}\d)\b/gu,
1591
+ replacement: "[phone]"
1592
+ },
1593
+ {
1594
+ pattern: /\b(?:token|secret|csrf|cookie|bearer|session|sid|cart(?:[_-]?id)?)\s*[:=]\s*[^\s,;&]+/giu,
1595
+ replacement: "[secret]"
1596
+ },
1597
+ {
1598
+ pattern: /\b(?:order|cart|session)[_-]?(?:id|no|number)?\s*[:#=]?\s*[A-Z0-9-]{6,}\b/giu,
1599
+ replacement: "[secret]"
1600
+ }
1601
+ ], Se = { patterns: tr };
1602
+ function rr(e, t = Se) {
1603
+ let r = typeof e == "string" ? e : e == null ? "" : String(e);
1604
+ for (const n of t.patterns || []) {
1605
+ const o = n.replacement;
1606
+ r = typeof o == "function" ? r.replace(n.pattern, (i) => o(i)) : r.replace(n.pattern, o);
1607
+ }
1608
+ return r;
1609
+ }
1610
+ function Kr(e, t = Se) {
1611
+ return rr(er(e), t);
1612
+ }
1613
+ function nr(e) {
1614
+ try {
1615
+ const t = new URL(e);
1616
+ return `${t.origin}${t.pathname}${t.search ? "?[query]" : ""}`;
1617
+ } catch {
1618
+ return "[url]";
1619
+ }
1620
+ }
1621
+ var or = [
1622
+ "assistantName",
1623
+ "homeDomain",
1624
+ "categories",
1625
+ "policyTopics"
1626
+ ], ir = { intent: ["searchContract", "competitorBrands"] };
1627
+ function vr(e, t, r, n = {}) {
1628
+ const o = ar(t, r, n);
1629
+ return Object.keys(o).length ? {
1630
+ ...e,
1631
+ account_config: o
1632
+ } : e;
1633
+ }
1634
+ function ar(e, t, r = {}) {
1635
+ if (!e) return {};
1636
+ const n = {}, o = r.baseKeys || or;
1637
+ for (const c of o) ne(n, e, c);
1638
+ const i = e[t];
1639
+ i && typeof i == "object" && !Array.isArray(i) && Object.assign(n, cr(i));
1640
+ const a = r.opAllowlist || ir;
1641
+ for (const c of a[t] || []) ne(n, e, c);
1642
+ return n;
1643
+ }
1644
+ function ne(e, t, r) {
1645
+ t[r] !== void 0 && (e[r] = t[r]);
1646
+ }
1647
+ function cr(e) {
1648
+ return Object.fromEntries(Object.entries(e).filter(([, t]) => t !== void 0));
1649
+ }
1274
1650
  export {
1275
- St as A,
1276
- ye as B,
1277
- _t as C,
1278
- ve as D,
1279
- te as E,
1280
- je as F,
1281
- gt as H,
1282
- Ae as I,
1283
- _e as L,
1284
- v as M,
1285
- ee as N,
1286
- bt as O,
1287
- wt as P,
1288
- ht as R,
1289
- At as S,
1290
- xt as T,
1291
- me as U,
1292
- yt as V,
1293
- oe as _,
1294
- _ as a,
1295
- ne as b,
1296
- w as c,
1297
- Mt as d,
1298
- Pt as f,
1299
- Et as g,
1300
- jt as h,
1301
- Rt as i,
1302
- kt as j,
1303
- Be as k,
1304
- Bt as l,
1305
- It as m,
1306
- vt as n,
1307
- $t as o,
1308
- Ct as p,
1309
- B as r,
1310
- nt as s,
1311
- Ut as t,
1312
- Nt as u,
1313
- Ot as v,
1314
- Re as w,
1315
- Tt as x,
1316
- F as y,
1317
- O as z
1651
+ wr as $,
1652
+ vt as A,
1653
+ Et as B,
1654
+ Jt as C,
1655
+ Pe as Ct,
1656
+ Lt as D,
1657
+ z as E,
1658
+ Ie as Et,
1659
+ jr as F,
1660
+ At as G,
1661
+ Tr as H,
1662
+ $ as I,
1663
+ _r as J,
1664
+ St as K,
1665
+ Er as L,
1666
+ ge as M,
1667
+ Ir as N,
1668
+ zt as O,
1669
+ Dt as P,
1670
+ Sr as Q,
1671
+ w as R,
1672
+ Mr as S,
1673
+ I as St,
1674
+ Pr as T,
1675
+ lr as Tt,
1676
+ _t as U,
1677
+ b as V,
1678
+ xt as W,
1679
+ xr as X,
1680
+ ye as Y,
1681
+ kr as Z,
1682
+ Lr as _,
1683
+ dr as _t,
1684
+ tr as a,
1685
+ hr as at,
1686
+ Br as b,
1687
+ Fe as bt,
1688
+ Dr as c,
1689
+ yr as ct,
1690
+ $r as d,
1691
+ pr as dt,
1692
+ de as et,
1693
+ Nr as f,
1694
+ ue as ft,
1695
+ Rr as g,
1696
+ se as gt,
1697
+ zr as h,
1698
+ L as ht,
1699
+ Se as i,
1700
+ br as it,
1701
+ Ft as j,
1702
+ Kt as k,
1703
+ Qt as l,
1704
+ le as lt,
1705
+ Ht as m,
1706
+ mr as mt,
1707
+ vr as n,
1708
+ J as nt,
1709
+ rr as o,
1710
+ gr as ot,
1711
+ Ur as p,
1712
+ U as pt,
1713
+ kt as q,
1714
+ Kr as r,
1715
+ W as rt,
1716
+ er as s,
1717
+ Ge as st,
1718
+ ar as t,
1719
+ Ar as tt,
1720
+ Fr as u,
1721
+ Ve as ut,
1722
+ D as v,
1723
+ ve as vt,
1724
+ Cr as w,
1725
+ ur as wt,
1726
+ Wt as x,
1727
+ fr as xt,
1728
+ he as y,
1729
+ De as yt,
1730
+ Or as z
1318
1731
  };