@opencx/widget-react-headless 5.7.1 → 5.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,19 +1,19 @@
1
- var er = (t) => {
1
+ var tr = (t) => {
2
2
  throw TypeError(t);
3
3
  };
4
- var tr = (t, e, r) => e.has(t) || er("Cannot " + r);
5
- var V = (t, e, r) => (tr(t, e, "read from private field"), r ? r.call(t) : e.get(t)), me = (t, e, r) => e.has(t) ? er("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r), Q = (t, e, r, n) => (tr(t, e, "write to private field"), n ? n.call(t, r) : e.set(t, r), r);
6
- import K, { useSyncExternalStore as zt, useRef as P, useMemo as X, useEffect as F, useState as J, useCallback as Z, createContext as Ye, useContext as $e, memo as Dn, useLayoutEffect as Ln } from "react";
7
- import { isAgentStreamKeepalive as jn, log as oe, isRecord as Tr, genUuid as Pt, buildSendMessageBody as kn, isAgentOrAiMessage as $n, resolveClientPresentation as Fn, ConnectionRequestExpiredError as Un, ConnectionAttemptUnavailableError as qn, PrimitiveState as Mr, WidgetCtx as zn, resolveSidebarMode as Zn, resolveSidebarSide as Vn, normalizeCompanionLayouts as Bn, resolveCompanionDefaultLayout as Wn } from "@opencx/widget-core";
8
- import { safeParseAsync as Jn, lazy as Yn, unknown as Kn, union as Hn, string as Gn, record as Qn, object as Xn, number as es, null as ts, never as rs, looseObject as ns, literal as ss, instanceof as as, enum as is, discriminatedUnion as os, custom as ls, boolean as cs, array as us } from "zod/v4";
9
- import { toJSONSchema as ds } from "zod/v4/core";
4
+ var rr = (t, e, r) => e.has(t) || tr("Cannot " + r);
5
+ var V = (t, e, r) => (rr(t, e, "read from private field"), r ? r.call(t) : e.get(t)), ge = (t, e, r) => e.has(t) ? tr("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r), Q = (t, e, r, n) => (rr(t, e, "write to private field"), n ? n.call(t, r) : e.set(t, r), r);
6
+ import Y, { useSyncExternalStore as zt, useRef as R, useMemo as X, useEffect as F, useState as J, useCallback as z, createContext as Ye, useContext as Fe, memo as jn, useLayoutEffect as kn } from "react";
7
+ import { isAgentStreamKeepalive as $n, log as le, isRecord as Mr, genUuid as Rt, buildSendMessageBody as Fn, isAgentOrAiMessage as Un, resolveClientPresentation as qn, ConnectionRequestExpiredError as zn, ConnectionAttemptUnavailableError as Zn, PrimitiveState as _r, WidgetCtx as Vn, resolveSidebarMode as Bn, resolveSidebarSide as Wn, normalizeCompanionLayouts as Jn, resolveCompanionDefaultLayout as Yn } from "@opencx/widget-core";
8
+ import { safeParseAsync as Kn, lazy as Hn, unknown as Gn, union as Qn, string as Xn, record as es, object as ts, number as rs, null as ns, never as ss, looseObject as as, literal as is, instanceof as os, enum as ls, discriminatedUnion as cs, custom as us, boolean as ds, array as ps } from "zod/v4";
9
+ import { toJSONSchema as fs } from "zod/v4/core";
10
10
  import "react/jsx-runtime";
11
11
  import { z as L } from "zod";
12
- const _r = "5.7.1";
12
+ const Rr = "5.7.2";
13
13
  function H(t) {
14
14
  return zt(t.subscribe, t.get, t.get);
15
15
  }
16
- function ps({
16
+ function ms({
17
17
  turnSources: t,
18
18
  liveItems: e,
19
19
  isStreaming: r,
@@ -22,17 +22,17 @@ function ps({
22
22
  var o;
23
23
  if (r || n) return null;
24
24
  const s = e.length > 0 ? e : (o = t.at(-1)) == null ? void 0 : o.items;
25
- return s ? fs(s) : null;
25
+ return s ? gs(s) : null;
26
26
  }
27
- function fs(t) {
27
+ function gs(t) {
28
28
  for (let e = t.length - 1; e >= 0; e--) {
29
29
  const r = t[e];
30
30
  if ((r == null ? void 0 : r.kind) === "questions") return r.request;
31
31
  }
32
32
  return null;
33
33
  }
34
- const Pr = "vercel.ai.error", ms = Symbol.for(Pr);
35
- var ee = class Rr extends Error {
34
+ const Pr = "vercel.ai.error", hs = Symbol.for(Pr);
35
+ var ee = class Or extends Error {
36
36
  /**
37
37
  * Creates an AI SDK Error.
38
38
  *
@@ -42,7 +42,7 @@ var ee = class Rr extends Error {
42
42
  * @param {unknown} [params.cause] - The underlying cause of the error.
43
43
  */
44
44
  constructor({ name: e, message: r, cause: n }) {
45
- super(r), this[ms] = !0, this.name = e, this.cause = n;
45
+ super(r), this[hs] = !0, this.name = e, this.cause = n;
46
46
  }
47
47
  /**
48
48
  * Checks if the given error is an AI SDK Error.
@@ -50,69 +50,69 @@ var ee = class Rr extends Error {
50
50
  * @returns {boolean} True if the error is an AI SDK Error, false otherwise.
51
51
  */
52
52
  static isInstance(e) {
53
- return Rr.hasMarker(e, Pr);
53
+ return Or.hasMarker(e, Pr);
54
54
  }
55
55
  static hasMarker(e, r) {
56
56
  const n = Symbol.for(r);
57
57
  return e != null && typeof e == "object" && n in e && typeof e[n] == "boolean" && e[n] === !0;
58
58
  }
59
59
  };
60
- const Or = "AI_APICallError", Nr = `vercel.ai.error.${Or}`, gs = Symbol.for(Nr);
61
- var Dr = class extends ee {
60
+ const Nr = "AI_APICallError", Dr = `vercel.ai.error.${Nr}`, ys = Symbol.for(Dr);
61
+ var Lr = class extends ee {
62
62
  constructor({ message: t, url: e, requestBodyValues: r, statusCode: n, responseHeaders: s, responseBody: o, cause: l, isRetryable: u = n != null && (n === 408 || n === 409 || n === 429 || n >= 500), data: y }) {
63
63
  super({
64
- name: Or,
64
+ name: Nr,
65
65
  message: t,
66
66
  cause: l
67
- }), this[gs] = !0, this.url = e, this.requestBodyValues = r, this.statusCode = n, this.responseHeaders = s, this.responseBody = o, this.isRetryable = u, this.data = y;
67
+ }), this[ys] = !0, this.url = e, this.requestBodyValues = r, this.statusCode = n, this.responseHeaders = s, this.responseBody = o, this.isRetryable = u, this.data = y;
68
68
  }
69
69
  static isInstance(t) {
70
- return ee.hasMarker(t, Nr);
70
+ return ee.hasMarker(t, Dr);
71
71
  }
72
72
  };
73
- const Lr = "AI_EmptyResponseBodyError", jr = `vercel.ai.error.${Lr}`, hs = Symbol.for(jr);
73
+ const jr = "AI_EmptyResponseBodyError", kr = `vercel.ai.error.${jr}`, vs = Symbol.for(kr);
74
74
  var ft = class extends ee {
75
75
  constructor({ message: t = "Empty response body" } = {}) {
76
76
  super({
77
- name: Lr,
77
+ name: jr,
78
78
  message: t
79
- }), this[hs] = !0;
79
+ }), this[vs] = !0;
80
80
  }
81
81
  static isInstance(t) {
82
- return ee.hasMarker(t, jr);
82
+ return ee.hasMarker(t, kr);
83
83
  }
84
84
  };
85
- function kr(t) {
85
+ function $r(t) {
86
86
  return t == null ? "unknown error" : typeof t == "string" ? t : t instanceof Error ? t.toString() : JSON.stringify(t);
87
87
  }
88
- const $r = "AI_InvalidArgumentError", Fr = `vercel.ai.error.${$r}`, ys = Symbol.for(Fr);
89
- var vs = class extends ee {
88
+ const Fr = "AI_InvalidArgumentError", Ur = `vercel.ai.error.${Fr}`, bs = Symbol.for(Ur);
89
+ var Ss = class extends ee {
90
90
  constructor({ message: e, cause: r, argument: n }) {
91
91
  super({
92
- name: $r,
92
+ name: Fr,
93
93
  message: e,
94
94
  cause: r
95
- }), this[ys] = !0, this.argument = n;
95
+ }), this[bs] = !0, this.argument = n;
96
96
  }
97
97
  static isInstance(e) {
98
- return ee.hasMarker(e, Fr);
98
+ return ee.hasMarker(e, Ur);
99
99
  }
100
100
  };
101
- const Ur = "AI_JSONParseError", qr = `vercel.ai.error.${Ur}`, bs = Symbol.for(qr);
102
- var rr = class extends ee {
101
+ const qr = "AI_JSONParseError", zr = `vercel.ai.error.${qr}`, Is = Symbol.for(zr);
102
+ var nr = class extends ee {
103
103
  constructor({ text: t, cause: e }) {
104
104
  super({
105
- name: Ur,
105
+ name: qr,
106
106
  message: `JSON parsing failed: Text: ${t}.
107
- Error message: ${kr(e)}`,
107
+ Error message: ${$r(e)}`,
108
108
  cause: e
109
- }), this[bs] = !0, this.text = t;
109
+ }), this[Is] = !0, this.text = t;
110
110
  }
111
111
  static isInstance(t) {
112
- return ee.hasMarker(t, qr);
112
+ return ee.hasMarker(t, zr);
113
113
  }
114
114
  };
115
- const zr = "AI_TypeValidationError", Zr = `vercel.ai.error.${zr}`, Ss = Symbol.for(Zr);
115
+ const Zr = "AI_TypeValidationError", Vr = `vercel.ai.error.${Zr}`, Es = Symbol.for(Vr);
116
116
  var mt = class $t extends ee {
117
117
  constructor({ value: e, cause: r, context: n }) {
118
118
  let s = "Type validation failed";
@@ -122,14 +122,14 @@ var mt = class $t extends ee {
122
122
  n.entityName && o.push(n.entityName), n.entityId && o.push(`id: "${n.entityId}"`), s += o.join(", "), s += ")";
123
123
  }
124
124
  super({
125
- name: zr,
125
+ name: Zr,
126
126
  message: `${s}: Value: ${JSON.stringify(e)}.
127
- Error message: ${kr(r)}`,
127
+ Error message: ${$r(r)}`,
128
128
  cause: r
129
- }), this[Ss] = !0, this.value = e, this.context = n;
129
+ }), this[Es] = !0, this.value = e, this.context = n;
130
130
  }
131
131
  static isInstance(e) {
132
- return ee.hasMarker(e, Zr);
132
+ return ee.hasMarker(e, Vr);
133
133
  }
134
134
  /**
135
135
  * Wraps an error into a TypeValidationError.
@@ -151,34 +151,34 @@ Error message: ${kr(r)}`,
151
151
  });
152
152
  }
153
153
  };
154
- const Vr = "AI_UnsupportedFunctionalityError", Br = `vercel.ai.error.${Vr}`, Is = Symbol.for(Br);
155
- var Es = class extends ee {
154
+ const Br = "AI_UnsupportedFunctionalityError", Wr = `vercel.ai.error.${Br}`, Cs = Symbol.for(Wr);
155
+ var ws = class extends ee {
156
156
  constructor({ functionality: t, message: e = `'${t}' functionality not supported.` }) {
157
157
  super({
158
- name: Vr,
158
+ name: Br,
159
159
  message: e
160
- }), this[Is] = !0, this.functionality = t;
160
+ }), this[Cs] = !0, this.functionality = t;
161
161
  }
162
162
  static isInstance(t) {
163
- return ee.hasMarker(t, Br);
163
+ return ee.hasMarker(t, Wr);
164
164
  }
165
165
  };
166
- class Rt extends Error {
166
+ class Pt extends Error {
167
167
  constructor(e, r) {
168
168
  super(e), this.name = "ParseError", this.type = r.type, this.field = r.field, this.value = r.value, this.line = r.line;
169
169
  }
170
170
  }
171
- const nr = 10, Cs = 13, Re = 32;
171
+ const sr = 10, As = 13, Oe = 32;
172
172
  function Ot(t) {
173
173
  }
174
- function ws(t) {
174
+ function xs(t) {
175
175
  if (typeof t == "function")
176
176
  throw new TypeError(
177
177
  "`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?"
178
178
  );
179
179
  const { onEvent: e = Ot, onError: r = Ot, onRetry: n = Ot, onComment: s, maxBufferSize: o } = t, l = [];
180
180
  let u = 0, y = !0, g, i = "", d = 0, p, b = !1;
181
- function R(c) {
181
+ function P(c) {
182
182
  if (b)
183
183
  throw new Error(
184
184
  "Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing."
@@ -201,7 +201,7 @@ function ws(t) {
201
201
  }
202
202
  function M() {
203
203
  o !== void 0 && (u + i.length <= o || (b = !0, l.length = 0, u = 0, g = void 0, i = "", d = 0, p = void 0, r(
204
- new Rt(`Buffered data exceeded max buffer size of ${o} characters`, {
204
+ new Pt(`Buffered data exceeded max buffer size of ${o} characters`, {
205
205
  type: "max-buffer-size-exceeded"
206
206
  })
207
207
  )));
@@ -218,19 +218,19 @@ function ws(t) {
218
218
  continue;
219
219
  }
220
220
  const h = c.charCodeAt(m);
221
- if (sr(c, m, h)) {
222
- const S = c.charCodeAt(m + 5) === Re ? m + 6 : m + 5, N = c.slice(S, f);
223
- if (d === 0 && c.charCodeAt(f + 1) === nr) {
221
+ if (ar(c, m, h)) {
222
+ const S = c.charCodeAt(m + 5) === Oe ? m + 6 : m + 5, N = c.slice(S, f);
223
+ if (d === 0 && c.charCodeAt(f + 1) === sr) {
224
224
  e({ id: g, event: p, data: N }), g = void 0, i = "", p = void 0, m = f + 2, f = c.indexOf(`
225
225
  `, m);
226
226
  continue;
227
227
  }
228
228
  i = d === 0 ? N : `${i}
229
229
  ${N}`, d++;
230
- } else ar(c, m, h) ? p = c.slice(
231
- c.charCodeAt(m + 6) === Re ? m + 7 : m + 6,
230
+ } else ir(c, m, h) ? p = c.slice(
231
+ c.charCodeAt(m + 6) === Oe ? m + 7 : m + 6,
232
232
  f
233
- ) || void 0 : T(c, m, f);
233
+ ) || void 0 : x(c, m, f);
234
234
  m = f + 1, f = c.indexOf(`
235
235
  `, m);
236
236
  }
@@ -242,35 +242,35 @@ ${N}`, d++;
242
242
  let S = -1;
243
243
  if (f !== -1 && h !== -1 ? S = f < h ? f : h : f !== -1 ? f === c.length - 1 ? S = -1 : S = f : h !== -1 && (S = h), S === -1)
244
244
  break;
245
- T(c, m, S), m = S + 1, c.charCodeAt(m - 1) === Cs && c.charCodeAt(m) === nr && m++;
245
+ x(c, m, S), m = S + 1, c.charCodeAt(m - 1) === As && c.charCodeAt(m) === sr && m++;
246
246
  }
247
247
  return c.slice(m);
248
248
  }
249
- function T(c, m, f) {
249
+ function x(c, m, f) {
250
250
  if (m === f) {
251
251
  I();
252
252
  return;
253
253
  }
254
254
  const h = c.charCodeAt(m);
255
- if (sr(c, m, h)) {
256
- const j = c.charCodeAt(m + 5) === Re ? m + 6 : m + 5, k = c.slice(j, f);
257
- i = d === 0 ? k : `${i}
258
- ${k}`, d++;
255
+ if (ar(c, m, h)) {
256
+ const j = c.charCodeAt(m + 5) === Oe ? m + 6 : m + 5, $ = c.slice(j, f);
257
+ i = d === 0 ? $ : `${i}
258
+ ${$}`, d++;
259
259
  return;
260
260
  }
261
- if (ar(c, m, h)) {
262
- p = c.slice(c.charCodeAt(m + 6) === Re ? m + 7 : m + 6, f) || void 0;
261
+ if (ir(c, m, h)) {
262
+ p = c.slice(c.charCodeAt(m + 6) === Oe ? m + 7 : m + 6, f) || void 0;
263
263
  return;
264
264
  }
265
265
  if (h === 105 && c.charCodeAt(m + 1) === 100 && c.charCodeAt(m + 2) === 58) {
266
- const j = c.slice(c.charCodeAt(m + 3) === Re ? m + 4 : m + 3, f);
266
+ const j = c.slice(c.charCodeAt(m + 3) === Oe ? m + 4 : m + 3, f);
267
267
  g = j.includes("\0") ? void 0 : j;
268
268
  return;
269
269
  }
270
270
  if (h === 58) {
271
271
  if (s) {
272
272
  const j = c.slice(m, f);
273
- s(j.slice(c.charCodeAt(m + 1) === Re ? 2 : 1));
273
+ s(j.slice(c.charCodeAt(m + 1) === Oe ? 2 : 1));
274
274
  }
275
275
  return;
276
276
  }
@@ -279,7 +279,7 @@ ${k}`, d++;
279
279
  w(S, "", S);
280
280
  return;
281
281
  }
282
- const D = S.slice(0, N), B = S.charCodeAt(N + 1) === Re ? 2 : 1, W = S.slice(N + B);
282
+ const D = S.slice(0, N), B = S.charCodeAt(N + 1) === Oe ? 2 : 1, W = S.slice(N + B);
283
283
  w(D, W, S);
284
284
  }
285
285
  function w(c, m, f) {
@@ -296,7 +296,7 @@ ${m}`, d++;
296
296
  break;
297
297
  case "retry":
298
298
  /^\d+$/.test(m) ? n(parseInt(m, 10)) : r(
299
- new Rt(`Invalid \`retry\` value: "${m}"`, {
299
+ new Pt(`Invalid \`retry\` value: "${m}"`, {
300
300
  type: "invalid-retry",
301
301
  value: m,
302
302
  line: f
@@ -305,7 +305,7 @@ ${m}`, d++;
305
305
  break;
306
306
  default:
307
307
  r(
308
- new Rt(
308
+ new Pt(
309
309
  `Unknown field "${c.length > 20 ? `${c.slice(0, 20)}…` : c}"`,
310
310
  { type: "unknown-field", field: c, value: m, line: f }
311
311
  )
@@ -323,24 +323,24 @@ ${m}`, d++;
323
323
  function C(c = {}) {
324
324
  if (c.consume && l.length > 0) {
325
325
  const m = l.join("");
326
- T(m, 0, m.length);
326
+ x(m, 0, m.length);
327
327
  }
328
328
  y = !0, g = void 0, i = "", d = 0, p = void 0, l.length = 0, u = 0, b = !1;
329
329
  }
330
- return { feed: R, reset: C };
330
+ return { feed: P, reset: C };
331
331
  }
332
- function sr(t, e, r) {
332
+ function ar(t, e, r) {
333
333
  return r === 100 && t.charCodeAt(e + 1) === 97 && t.charCodeAt(e + 2) === 116 && t.charCodeAt(e + 3) === 97 && t.charCodeAt(e + 4) === 58;
334
334
  }
335
- function ar(t, e, r) {
335
+ function ir(t, e, r) {
336
336
  return r === 101 && t.charCodeAt(e + 1) === 118 && t.charCodeAt(e + 2) === 101 && t.charCodeAt(e + 3) === 110 && t.charCodeAt(e + 4) === 116 && t.charCodeAt(e + 5) === 58;
337
337
  }
338
- class As extends TransformStream {
338
+ class Ts extends TransformStream {
339
339
  constructor({ onError: e, onRetry: r, onComment: n, maxBufferSize: s } = {}) {
340
340
  let o;
341
341
  super({
342
342
  start(l) {
343
- o = ws({
343
+ o = xs({
344
344
  onEvent: (u) => {
345
345
  l.enqueue(u);
346
346
  },
@@ -378,22 +378,22 @@ const te = ({ prefix: t, size: e = 16, alphabet: r = "0123456789ABCDEFGHIJKLMNOP
378
378
  return l.join("");
379
379
  };
380
380
  if (t == null) return s;
381
- if (r.includes(n)) throw new vs({
381
+ if (r.includes(n)) throw new Ss({
382
382
  argument: "separator",
383
383
  message: `The separator "${n}" must not be part of the alphabet "${r}".`
384
384
  });
385
385
  return () => `${t}${n}${s()}`;
386
- }, xs = te();
387
- function Ts(t) {
386
+ }, Ms = te();
387
+ function _s(t) {
388
388
  var e;
389
389
  return ((e = globalThis.Buffer) == null ? void 0 : e.isBuffer(t)) ?? !1;
390
390
  }
391
- const Ms = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/, _s = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
392
- function ir(t) {
391
+ const Rs = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/, Ps = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
392
+ function or(t) {
393
393
  const e = JSON.parse(t);
394
- return e === null || typeof e != "object" || Ms.test(t) === !1 && _s.test(t) === !1 ? e : Ps(e);
394
+ return e === null || typeof e != "object" || Rs.test(t) === !1 && Ps.test(t) === !1 ? e : Os(e);
395
395
  }
396
- function Ps(t) {
396
+ function Os(t) {
397
397
  let e = [t];
398
398
  for (; e.length; ) {
399
399
  const r = e;
@@ -409,15 +409,15 @@ function Ps(t) {
409
409
  }
410
410
  return t;
411
411
  }
412
- function Rs(t) {
412
+ function Ns(t) {
413
413
  const { stackTraceLimit: e } = Error;
414
414
  try {
415
415
  Error.stackTraceLimit = 0;
416
416
  } catch {
417
- return ir(t);
417
+ return or(t);
418
418
  }
419
419
  try {
420
- return ir(t);
420
+ return or(t);
421
421
  } finally {
422
422
  Error.stackTraceLimit = e;
423
423
  }
@@ -437,7 +437,7 @@ function Zt(t) {
437
437
  function Me(t) {
438
438
  return typeof t == "boolean" ? t : Zt(t);
439
439
  }
440
- const Os = Symbol("Let zodToJsonSchema decide on which parser to use"), or = {
440
+ const Ds = Symbol("Let zodToJsonSchema decide on which parser to use"), lr = {
441
441
  name: void 0,
442
442
  $refStrategy: "root",
443
443
  basePath: ["#"],
@@ -457,17 +457,17 @@ const Os = Symbol("Let zodToJsonSchema decide on which parser to use"), or = {
457
457
  emailStrategy: "format:email",
458
458
  base64Strategy: "contentEncoding:base64",
459
459
  nameStrategy: "ref"
460
- }, Ns = (t) => typeof t == "string" ? {
461
- ...or,
460
+ }, Ls = (t) => typeof t == "string" ? {
461
+ ...lr,
462
462
  name: t
463
463
  } : {
464
- ...or,
464
+ ...lr,
465
465
  ...t
466
466
  };
467
- function ce() {
467
+ function ue() {
468
468
  return {};
469
469
  }
470
- function Ds(t, e) {
470
+ function js(t, e) {
471
471
  var n, s, o;
472
472
  const r = { type: "array" };
473
473
  return (n = t.type) != null && n._def && ((o = (s = t.type) == null ? void 0 : s._def) == null ? void 0 : o.typeName) !== "ZodAny" && (r.items = q(t.type._def, {
@@ -475,7 +475,7 @@ function Ds(t, e) {
475
475
  currentPath: [...e.currentPath, "items"]
476
476
  })), t.minLength && (r.minItems = t.minLength.value), t.maxLength && (r.maxItems = t.maxLength.value), t.exactLength && (r.minItems = t.exactLength.value, r.maxItems = t.exactLength.value), r;
477
477
  }
478
- function Ls(t) {
478
+ function ks(t) {
479
479
  const e = {
480
480
  type: "integer",
481
481
  format: "int64"
@@ -493,16 +493,16 @@ function Ls(t) {
493
493
  }
494
494
  return e;
495
495
  }
496
- function js() {
496
+ function $s() {
497
497
  return { type: "boolean" };
498
498
  }
499
- function Wr(t, e) {
499
+ function Jr(t, e) {
500
500
  return q(t.type._def, e);
501
501
  }
502
- const ks = (t, e) => q(t.innerType._def, e);
503
- function Jr(t, e, r) {
502
+ const Fs = (t, e) => q(t.innerType._def, e);
503
+ function Yr(t, e, r) {
504
504
  const n = r ?? e.dateStrategy;
505
- if (Array.isArray(n)) return { anyOf: n.map((s) => Jr(t, e, s)) };
505
+ if (Array.isArray(n)) return { anyOf: n.map((s) => Yr(t, e, s)) };
506
506
  switch (n) {
507
507
  case "string":
508
508
  case "format:date-time":
@@ -516,10 +516,10 @@ function Jr(t, e, r) {
516
516
  format: "date"
517
517
  };
518
518
  case "integer":
519
- return $s(t);
519
+ return Us(t);
520
520
  }
521
521
  }
522
- const $s = (t) => {
522
+ const Us = (t) => {
523
523
  const e = {
524
524
  type: "integer",
525
525
  format: "unix-time"
@@ -533,23 +533,23 @@ const $s = (t) => {
533
533
  }
534
534
  return e;
535
535
  };
536
- function Fs(t, e) {
536
+ function qs(t, e) {
537
537
  return {
538
538
  ...q(t.innerType._def, e),
539
539
  default: t.defaultValue()
540
540
  };
541
541
  }
542
- function Us(t, e) {
543
- return e.effectStrategy === "input" ? q(t.schema._def, e) : ce();
542
+ function zs(t, e) {
543
+ return e.effectStrategy === "input" ? q(t.schema._def, e) : ue();
544
544
  }
545
- function qs(t) {
545
+ function Zs(t) {
546
546
  return {
547
547
  type: "string",
548
548
  enum: Array.from(t.values)
549
549
  };
550
550
  }
551
- const zs = (t) => "type" in t && t.type === "string" ? !1 : "allOf" in t;
552
- function Zs(t, e) {
551
+ const Vs = (t) => "type" in t && t.type === "string" ? !1 : "allOf" in t;
552
+ function Bs(t, e) {
553
553
  const r = [q(t.left._def, {
554
554
  ...e,
555
555
  currentPath: [
@@ -566,7 +566,7 @@ function Zs(t, e) {
566
566
  ]
567
567
  })].filter((s) => !!s), n = [];
568
568
  return r.forEach((s) => {
569
- if (zs(s)) n.push(...s.allOf);
569
+ if (Vs(s)) n.push(...s.allOf);
570
570
  else {
571
571
  let o = s;
572
572
  if ("additionalProperties" in s && s.additionalProperties === !1) {
@@ -577,7 +577,7 @@ function Zs(t, e) {
577
577
  }
578
578
  }), n.length ? { allOf: n } : void 0;
579
579
  }
580
- function Vs(t) {
580
+ function Ws(t) {
581
581
  const e = typeof t.value;
582
582
  return e !== "bigint" && e !== "number" && e !== "boolean" && e !== "string" ? { type: Array.isArray(t.value) ? "array" : "object" } : {
583
583
  type: e === "bigint" ? "integer" : e,
@@ -585,7 +585,7 @@ function Vs(t) {
585
585
  };
586
586
  }
587
587
  let Nt;
588
- const ge = {
588
+ const he = {
589
589
  /**
590
590
  * `c` was changed to `[cC]` to replicate /i flag
591
591
  */
@@ -627,7 +627,7 @@ const ge = {
627
627
  nanoid: /^[a-zA-Z0-9_-]{21}$/,
628
628
  jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
629
629
  };
630
- function Yr(t, e) {
630
+ function Kr(t, e) {
631
631
  const r = { type: "string" };
632
632
  if (t.checks) for (const n of t.checks) switch (n.kind) {
633
633
  case "min":
@@ -639,114 +639,114 @@ function Yr(t, e) {
639
639
  case "email":
640
640
  switch (e.emailStrategy) {
641
641
  case "format:email":
642
- he(r, "email", n.message, e);
642
+ ye(r, "email", n.message, e);
643
643
  break;
644
644
  case "format:idn-email":
645
- he(r, "idn-email", n.message, e);
645
+ ye(r, "idn-email", n.message, e);
646
646
  break;
647
647
  case "pattern:zod":
648
- re(r, ge.email, n.message, e);
648
+ ne(r, he.email, n.message, e);
649
649
  }
650
650
  break;
651
651
  case "url":
652
- he(r, "uri", n.message, e);
652
+ ye(r, "uri", n.message, e);
653
653
  break;
654
654
  case "uuid":
655
- he(r, "uuid", n.message, e);
655
+ ye(r, "uuid", n.message, e);
656
656
  break;
657
657
  case "regex":
658
- re(r, n.regex, n.message, e);
658
+ ne(r, n.regex, n.message, e);
659
659
  break;
660
660
  case "cuid":
661
- re(r, ge.cuid, n.message, e);
661
+ ne(r, he.cuid, n.message, e);
662
662
  break;
663
663
  case "cuid2":
664
- re(r, ge.cuid2, n.message, e);
664
+ ne(r, he.cuid2, n.message, e);
665
665
  break;
666
666
  case "startsWith":
667
- re(r, RegExp(`^${Dt(n.value, e)}`), n.message, e);
667
+ ne(r, RegExp(`^${Dt(n.value, e)}`), n.message, e);
668
668
  break;
669
669
  case "endsWith":
670
- re(r, RegExp(`${Dt(n.value, e)}$`), n.message, e);
670
+ ne(r, RegExp(`${Dt(n.value, e)}$`), n.message, e);
671
671
  break;
672
672
  case "datetime":
673
- he(r, "date-time", n.message, e);
673
+ ye(r, "date-time", n.message, e);
674
674
  break;
675
675
  case "date":
676
- he(r, "date", n.message, e);
676
+ ye(r, "date", n.message, e);
677
677
  break;
678
678
  case "time":
679
- he(r, "time", n.message, e);
679
+ ye(r, "time", n.message, e);
680
680
  break;
681
681
  case "duration":
682
- he(r, "duration", n.message, e);
682
+ ye(r, "duration", n.message, e);
683
683
  break;
684
684
  case "length":
685
685
  r.minLength = typeof r.minLength == "number" ? Math.max(r.minLength, n.value) : n.value, r.maxLength = typeof r.maxLength == "number" ? Math.min(r.maxLength, n.value) : n.value;
686
686
  break;
687
687
  case "includes":
688
- re(r, RegExp(Dt(n.value, e)), n.message, e);
688
+ ne(r, RegExp(Dt(n.value, e)), n.message, e);
689
689
  break;
690
690
  case "ip":
691
- n.version !== "v6" && he(r, "ipv4", n.message, e), n.version !== "v4" && he(r, "ipv6", n.message, e);
691
+ n.version !== "v6" && ye(r, "ipv4", n.message, e), n.version !== "v4" && ye(r, "ipv6", n.message, e);
692
692
  break;
693
693
  case "base64url":
694
- re(r, ge.base64url, n.message, e);
694
+ ne(r, he.base64url, n.message, e);
695
695
  break;
696
696
  case "jwt":
697
- re(r, ge.jwt, n.message, e);
697
+ ne(r, he.jwt, n.message, e);
698
698
  break;
699
699
  case "cidr":
700
- n.version !== "v6" && re(r, ge.ipv4Cidr, n.message, e), n.version !== "v4" && re(r, ge.ipv6Cidr, n.message, e);
700
+ n.version !== "v6" && ne(r, he.ipv4Cidr, n.message, e), n.version !== "v4" && ne(r, he.ipv6Cidr, n.message, e);
701
701
  break;
702
702
  case "emoji":
703
- re(r, ge.emoji(), n.message, e);
703
+ ne(r, he.emoji(), n.message, e);
704
704
  break;
705
705
  case "ulid":
706
- re(r, ge.ulid, n.message, e);
706
+ ne(r, he.ulid, n.message, e);
707
707
  break;
708
708
  case "base64":
709
709
  switch (e.base64Strategy) {
710
710
  case "format:binary":
711
- he(r, "binary", n.message, e);
711
+ ye(r, "binary", n.message, e);
712
712
  break;
713
713
  case "contentEncoding:base64":
714
714
  r.contentEncoding = "base64";
715
715
  break;
716
716
  case "pattern:zod":
717
- re(r, ge.base64, n.message, e);
717
+ ne(r, he.base64, n.message, e);
718
718
  }
719
719
  break;
720
720
  case "nanoid":
721
- re(r, ge.nanoid, n.message, e);
721
+ ne(r, he.nanoid, n.message, e);
722
722
  }
723
723
  return r;
724
724
  }
725
725
  function Dt(t, e) {
726
- return e.patternStrategy === "escape" ? Ws(t) : t;
726
+ return e.patternStrategy === "escape" ? Ys(t) : t;
727
727
  }
728
- const Bs = /* @__PURE__ */ new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
729
- function Ws(t) {
728
+ const Js = /* @__PURE__ */ new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
729
+ function Ys(t) {
730
730
  let e = "";
731
731
  for (let r = 0; r < t.length; r++)
732
- Bs.has(t[r]) || (e += "\\"), e += t[r];
732
+ Js.has(t[r]) || (e += "\\"), e += t[r];
733
733
  return e;
734
734
  }
735
- function he(t, e, r, n) {
735
+ function ye(t, e, r, n) {
736
736
  var s;
737
737
  t.format || (s = t.anyOf) != null && s.some((o) => o.format) ? (t.anyOf || (t.anyOf = []), t.format && (t.anyOf.push({ format: t.format }), delete t.format), t.anyOf.push({
738
738
  format: e,
739
739
  ...r && n.errorMessages && { errorMessage: { format: r } }
740
740
  })) : t.format = e;
741
741
  }
742
- function re(t, e, r, n) {
742
+ function ne(t, e, r, n) {
743
743
  var s;
744
744
  t.pattern || (s = t.allOf) != null && s.some((o) => o.pattern) ? (t.allOf || (t.allOf = []), t.pattern && (t.allOf.push({ pattern: t.pattern }), delete t.pattern), t.allOf.push({
745
- pattern: lr(e, n),
745
+ pattern: cr(e, n),
746
746
  ...r && n.errorMessages && { errorMessage: { pattern: r } }
747
- })) : t.pattern = lr(e, n);
747
+ })) : t.pattern = cr(e, n);
748
748
  }
749
- function lr(t, e) {
749
+ function cr(t, e) {
750
750
  var y;
751
751
  if (!e.applyRegexFlags || !t.flags) return t.source;
752
752
  const r = {
@@ -797,7 +797,7 @@ function lr(t, e) {
797
797
  }
798
798
  return s;
799
799
  }
800
- function Kr(t, e) {
800
+ function Hr(t, e) {
801
801
  var n, s, o, l, u;
802
802
  const r = {
803
803
  type: "object",
@@ -807,7 +807,7 @@ function Kr(t, e) {
807
807
  }) ?? e.allowedAdditionalProperties
808
808
  };
809
809
  if (((n = t.keyType) == null ? void 0 : n._def.typeName) === "ZodString" && ((s = t.keyType._def.checks) != null && s.length)) {
810
- const { type: y, ...g } = Yr(t.keyType._def, e);
810
+ const { type: y, ...g } = Kr(t.keyType._def, e);
811
811
  return {
812
812
  ...r,
813
813
  propertyNames: g
@@ -818,7 +818,7 @@ function Kr(t, e) {
818
818
  propertyNames: { enum: t.keyType._def.values }
819
819
  };
820
820
  if (((l = t.keyType) == null ? void 0 : l._def.typeName) === "ZodBranded" && t.keyType._def.type._def.typeName === "ZodString" && ((u = t.keyType._def.type._def.checks) != null && u.length)) {
821
- const { type: y, ...g } = Wr(t.keyType._def, e);
821
+ const { type: y, ...g } = Jr(t.keyType._def, e);
822
822
  return {
823
823
  ...r,
824
824
  propertyNames: g
@@ -827,8 +827,8 @@ function Kr(t, e) {
827
827
  }
828
828
  return r;
829
829
  }
830
- function Js(t, e) {
831
- return e.mapStrategy === "record" ? Kr(t, e) : {
830
+ function Ks(t, e) {
831
+ return e.mapStrategy === "record" ? Hr(t, e) : {
832
832
  type: "array",
833
833
  maxItems: 125,
834
834
  items: {
@@ -841,7 +841,7 @@ function Js(t, e) {
841
841
  "items",
842
842
  "0"
843
843
  ]
844
- }) || ce(), q(t.valueType._def, {
844
+ }) || ue(), q(t.valueType._def, {
845
845
  ...e,
846
846
  currentPath: [
847
847
  ...e.currentPath,
@@ -849,23 +849,23 @@ function Js(t, e) {
849
849
  "items",
850
850
  "1"
851
851
  ]
852
- }) || ce()],
852
+ }) || ue()],
853
853
  minItems: 2,
854
854
  maxItems: 2
855
855
  }
856
856
  };
857
857
  }
858
- function Ys(t) {
858
+ function Hs(t) {
859
859
  const e = t.values, r = Object.keys(t.values).filter((s) => typeof e[e[s]] != "number").map((s) => e[s]), n = Array.from(new Set(r.map((s) => typeof s)));
860
860
  return {
861
861
  type: n.length === 1 ? n[0] === "string" ? "string" : "number" : ["string", "number"],
862
862
  enum: r
863
863
  };
864
864
  }
865
- function Ks() {
866
- return { not: ce() };
865
+ function Gs() {
866
+ return { not: ue() };
867
867
  }
868
- function Hs() {
868
+ function Qs() {
869
869
  return { type: "null" };
870
870
  }
871
871
  const Ft = {
@@ -875,7 +875,7 @@ const Ft = {
875
875
  ZodBoolean: "boolean",
876
876
  ZodNull: "null"
877
877
  };
878
- function Gs(t, e) {
878
+ function Xs(t, e) {
879
879
  const r = t.options instanceof Map ? Array.from(t.options.values()) : t.options;
880
880
  if (r.every((n) => n._def.typeName in Ft && (!n._def.checks || !n._def.checks.length))) {
881
881
  const n = r.reduce((s, o) => {
@@ -910,9 +910,9 @@ function Gs(t, e) {
910
910
  type: "string",
911
911
  enum: r.reduce((n, s) => [...n, ...s._def.values.filter((o) => !n.includes(o))], [])
912
912
  };
913
- return Qs(t, e);
913
+ return ea(t, e);
914
914
  }
915
- const Qs = (t, e) => {
915
+ const ea = (t, e) => {
916
916
  const r = (t.options instanceof Map ? Array.from(t.options.values()) : t.options).map((n, s) => q(n._def, {
917
917
  ...e,
918
918
  currentPath: [
@@ -923,7 +923,7 @@ const Qs = (t, e) => {
923
923
  })).filter((n) => !!n && (!e.strictUnions || typeof n == "object" && Object.keys(n).length > 0));
924
924
  return r.length ? { anyOf: r } : void 0;
925
925
  };
926
- function Xs(t, e) {
926
+ function ta(t, e) {
927
927
  if ([
928
928
  "ZodString",
929
929
  "ZodNumber",
@@ -941,7 +941,7 @@ function Xs(t, e) {
941
941
  });
942
942
  return r && { anyOf: [r, { type: "null" }] };
943
943
  }
944
- function ea(t) {
944
+ function ra(t) {
945
945
  const e = { type: "number" };
946
946
  if (!t.checks) return e;
947
947
  for (const r of t.checks) switch (r.kind) {
@@ -959,7 +959,7 @@ function ea(t) {
959
959
  }
960
960
  return e;
961
961
  }
962
- function ta(t, e) {
962
+ function na(t, e) {
963
963
  const r = {
964
964
  type: "object",
965
965
  properties: {}
@@ -967,7 +967,7 @@ function ta(t, e) {
967
967
  for (const l in s) {
968
968
  let u = s[l];
969
969
  if (u === void 0 || u._def === void 0) continue;
970
- const y = na(u), g = q(u._def, {
970
+ const y = aa(u), g = q(u._def, {
971
971
  ...e,
972
972
  currentPath: [
973
973
  ...e.currentPath,
@@ -983,10 +983,10 @@ function ta(t, e) {
983
983
  g !== void 0 && (r.properties[l] = g, y || n.push(l));
984
984
  }
985
985
  n.length && (r.required = n);
986
- const o = ra(t, e);
986
+ const o = sa(t, e);
987
987
  return o !== void 0 && (r.additionalProperties = o), r;
988
988
  }
989
- function ra(t, e) {
989
+ function sa(t, e) {
990
990
  if (t.catchall._def.typeName !== "ZodNever") return q(t.catchall._def, {
991
991
  ...e,
992
992
  currentPath: [...e.currentPath, "additionalProperties"]
@@ -1000,14 +1000,14 @@ function ra(t, e) {
1000
1000
  return e.removeAdditionalStrategy === "strict" ? e.allowedAdditionalProperties : e.rejectedAdditionalProperties;
1001
1001
  }
1002
1002
  }
1003
- function na(t) {
1003
+ function aa(t) {
1004
1004
  try {
1005
1005
  return t.isOptional();
1006
1006
  } catch {
1007
1007
  return !0;
1008
1008
  }
1009
1009
  }
1010
- const sa = (t, e) => {
1010
+ const ia = (t, e) => {
1011
1011
  var n;
1012
1012
  if (e.currentPath.toString() === ((n = e.propertyPath) == null ? void 0 : n.toString())) return q(t.innerType._def, e);
1013
1013
  const r = q(t.innerType._def, {
@@ -1018,8 +1018,8 @@ const sa = (t, e) => {
1018
1018
  "1"
1019
1019
  ]
1020
1020
  });
1021
- return r ? { anyOf: [{ not: ce() }, r] } : ce();
1022
- }, aa = (t, e) => {
1021
+ return r ? { anyOf: [{ not: ue() }, r] } : ue();
1022
+ }, oa = (t, e) => {
1023
1023
  if (e.pipeStrategy === "input") return q(t.in._def, e);
1024
1024
  if (e.pipeStrategy === "output") return q(t.out._def, e);
1025
1025
  const r = q(t.in._def, {
@@ -1039,10 +1039,10 @@ const sa = (t, e) => {
1039
1039
  ]
1040
1040
  })].filter((n) => n !== void 0) };
1041
1041
  };
1042
- function ia(t, e) {
1042
+ function la(t, e) {
1043
1043
  return q(t.type._def, e);
1044
1044
  }
1045
- function oa(t, e) {
1045
+ function ca(t, e) {
1046
1046
  const r = {
1047
1047
  type: "array",
1048
1048
  uniqueItems: !0,
@@ -1053,7 +1053,7 @@ function oa(t, e) {
1053
1053
  };
1054
1054
  return t.minSize && (r.minItems = t.minSize.value), t.maxSize && (r.maxItems = t.maxSize.value), r;
1055
1055
  }
1056
- function la(t, e) {
1056
+ function ua(t, e) {
1057
1057
  return t.rest ? {
1058
1058
  type: "array",
1059
1059
  minItems: t.items.length,
@@ -1083,78 +1083,78 @@ function la(t, e) {
1083
1083
  })).reduce((r, n) => n === void 0 ? r : [...r, n], [])
1084
1084
  };
1085
1085
  }
1086
- function ca() {
1087
- return { not: ce() };
1086
+ function da() {
1087
+ return { not: ue() };
1088
1088
  }
1089
- function ua() {
1090
- return ce();
1089
+ function pa() {
1090
+ return ue();
1091
1091
  }
1092
- const da = (t, e) => q(t.innerType._def, e), pa = (t, e, r) => {
1092
+ const fa = (t, e) => q(t.innerType._def, e), ma = (t, e, r) => {
1093
1093
  switch (e) {
1094
1094
  case "ZodString":
1095
- return Yr(t, r);
1095
+ return Kr(t, r);
1096
1096
  case "ZodNumber":
1097
- return ea(t);
1097
+ return ra(t);
1098
1098
  case "ZodObject":
1099
- return ta(t, r);
1099
+ return na(t, r);
1100
1100
  case "ZodBigInt":
1101
- return Ls(t);
1101
+ return ks(t);
1102
1102
  case "ZodBoolean":
1103
- return js();
1103
+ return $s();
1104
1104
  case "ZodDate":
1105
- return Jr(t, r);
1105
+ return Yr(t, r);
1106
1106
  case "ZodUndefined":
1107
- return ca();
1107
+ return da();
1108
1108
  case "ZodNull":
1109
- return Hs();
1109
+ return Qs();
1110
1110
  case "ZodArray":
1111
- return Ds(t, r);
1111
+ return js(t, r);
1112
1112
  case "ZodUnion":
1113
1113
  case "ZodDiscriminatedUnion":
1114
- return Gs(t, r);
1114
+ return Xs(t, r);
1115
1115
  case "ZodIntersection":
1116
- return Zs(t, r);
1116
+ return Bs(t, r);
1117
1117
  case "ZodTuple":
1118
- return la(t, r);
1118
+ return ua(t, r);
1119
1119
  case "ZodRecord":
1120
- return Kr(t, r);
1120
+ return Hr(t, r);
1121
1121
  case "ZodLiteral":
1122
- return Vs(t);
1122
+ return Ws(t);
1123
1123
  case "ZodEnum":
1124
- return qs(t);
1124
+ return Zs(t);
1125
1125
  case "ZodNativeEnum":
1126
- return Ys(t);
1126
+ return Hs(t);
1127
1127
  case "ZodNullable":
1128
- return Xs(t, r);
1128
+ return ta(t, r);
1129
1129
  case "ZodOptional":
1130
- return sa(t, r);
1130
+ return ia(t, r);
1131
1131
  case "ZodMap":
1132
- return Js(t, r);
1132
+ return Ks(t, r);
1133
1133
  case "ZodSet":
1134
- return oa(t, r);
1134
+ return ca(t, r);
1135
1135
  case "ZodLazy":
1136
1136
  return () => t.getter()._def;
1137
1137
  case "ZodPromise":
1138
- return ia(t, r);
1138
+ return la(t, r);
1139
1139
  case "ZodNaN":
1140
1140
  case "ZodNever":
1141
- return Ks();
1141
+ return Gs();
1142
1142
  case "ZodEffects":
1143
- return Us(t, r);
1143
+ return zs(t, r);
1144
1144
  case "ZodAny":
1145
- return ce();
1145
+ return ue();
1146
1146
  case "ZodUnknown":
1147
- return ua();
1147
+ return pa();
1148
1148
  case "ZodDefault":
1149
- return Fs(t, r);
1149
+ return qs(t, r);
1150
1150
  case "ZodBranded":
1151
- return Wr(t, r);
1151
+ return Jr(t, r);
1152
1152
  case "ZodReadonly":
1153
- return da(t, r);
1153
+ return fa(t, r);
1154
1154
  case "ZodCatch":
1155
- return ks(t, r);
1155
+ return Fs(t, r);
1156
1156
  case "ZodPipeline":
1157
- return aa(t, r);
1157
+ return oa(t, r);
1158
1158
  case "ZodFunction":
1159
1159
  case "ZodVoid":
1160
1160
  case "ZodSymbol":
@@ -1163,7 +1163,7 @@ const da = (t, e) => q(t.innerType._def, e), pa = (t, e, r) => {
1163
1163
  return /* @__PURE__ */ ((n) => {
1164
1164
  })();
1165
1165
  }
1166
- }, fa = (t, e) => {
1166
+ }, ga = (t, e) => {
1167
1167
  let r = 0;
1168
1168
  for (; r < t.length && r < e.length && t[r] === e[r]; r++) ;
1169
1169
  return [(t.length - r).toString(), ...e.slice(r)].join("/");
@@ -1173,10 +1173,10 @@ function q(t, e, r = !1) {
1173
1173
  const n = e.seen.get(t);
1174
1174
  if (e.override) {
1175
1175
  const y = (u = e.override) == null ? void 0 : u.call(e, t, e, n, r);
1176
- if (y !== Os) return y;
1176
+ if (y !== Ds) return y;
1177
1177
  }
1178
1178
  if (n && !r) {
1179
- const y = ma(n, e);
1179
+ const y = ha(n, e);
1180
1180
  if (y !== void 0) return y;
1181
1181
  }
1182
1182
  const s = {
@@ -1185,25 +1185,25 @@ function q(t, e, r = !1) {
1185
1185
  jsonSchema: void 0
1186
1186
  };
1187
1187
  e.seen.set(t, s);
1188
- const o = pa(t, t.typeName, e), l = typeof o == "function" ? q(o(), e) : o;
1189
- if (l && ga(t, e, l), e.postProcess) {
1188
+ const o = ma(t, t.typeName, e), l = typeof o == "function" ? q(o(), e) : o;
1189
+ if (l && ya(t, e, l), e.postProcess) {
1190
1190
  const y = e.postProcess(l, t, e);
1191
1191
  return s.jsonSchema = l, y;
1192
1192
  }
1193
1193
  return s.jsonSchema = l, l;
1194
1194
  }
1195
- const ma = (t, e) => {
1195
+ const ha = (t, e) => {
1196
1196
  switch (e.$refStrategy) {
1197
1197
  case "root":
1198
1198
  return { $ref: t.path.join("/") };
1199
1199
  case "relative":
1200
- return { $ref: fa(e.currentPath, t.path) };
1200
+ return { $ref: ga(e.currentPath, t.path) };
1201
1201
  case "none":
1202
1202
  case "seen":
1203
- return t.path.length < e.currentPath.length && t.path.every((r, n) => e.currentPath[n] === r) ? (console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`), ce()) : e.$refStrategy === "seen" ? ce() : void 0;
1203
+ return t.path.length < e.currentPath.length && t.path.every((r, n) => e.currentPath[n] === r) ? (console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`), ue()) : e.$refStrategy === "seen" ? ue() : void 0;
1204
1204
  }
1205
- }, ga = (t, e, r) => (t.description && (r.description = t.description), r), ha = (t) => {
1206
- const e = Ns(t), r = e.name !== void 0 ? [
1205
+ }, ya = (t, e, r) => (t.description && (r.description = t.description), r), va = (t) => {
1206
+ const e = Ls(t), r = e.name !== void 0 ? [
1207
1207
  ...e.basePath,
1208
1208
  e.definitionPath,
1209
1209
  e.name
@@ -1222,8 +1222,8 @@ const ma = (t, e) => {
1222
1222
  jsonSchema: void 0
1223
1223
  }]))
1224
1224
  };
1225
- }, ya = (t, e) => {
1226
- const r = ha(e);
1225
+ }, ba = (t, e) => {
1226
+ const r = va(e);
1227
1227
  let n = typeof e == "object" && e.definitions ? Object.entries(e.definitions).reduce((y, [g, i]) => ({
1228
1228
  ...y,
1229
1229
  [g]: q(i._def, {
@@ -1233,7 +1233,7 @@ const ma = (t, e) => {
1233
1233
  r.definitionPath,
1234
1234
  g
1235
1235
  ]
1236
- }, !0) ?? ce()
1236
+ }, !0) ?? ue()
1237
1237
  }), {}) : void 0;
1238
1238
  const s = typeof e == "string" ? e : (e == null ? void 0 : e.nameStrategy) === "title" || e == null ? void 0 : e.name, o = q(t._def, s === void 0 ? r : {
1239
1239
  ...r,
@@ -1242,7 +1242,7 @@ const ma = (t, e) => {
1242
1242
  r.definitionPath,
1243
1243
  s
1244
1244
  ]
1245
- }, !1) ?? ce(), l = typeof e == "object" && e.name !== void 0 && e.nameStrategy === "title" ? e.name : void 0;
1245
+ }, !1) ?? ue(), l = typeof e == "object" && e.name !== void 0 && e.nameStrategy === "title" ? e.name : void 0;
1246
1246
  l !== void 0 && (o.title = l);
1247
1247
  const u = s === void 0 ? n ? {
1248
1248
  ...o,
@@ -1260,7 +1260,7 @@ const ma = (t, e) => {
1260
1260
  };
1261
1261
  return u.$schema = "http://json-schema.org/draft-07/schema#", u;
1262
1262
  }, Ut = Symbol.for("vercel.ai.schema");
1263
- function va(t) {
1263
+ function Sa(t) {
1264
1264
  let e;
1265
1265
  return () => (e == null && (e = t()), e);
1266
1266
  }
@@ -1274,19 +1274,19 @@ function vt(t, { validate: e } = {}) {
1274
1274
  validate: e
1275
1275
  };
1276
1276
  }
1277
- function ba(t) {
1277
+ function Ia(t) {
1278
1278
  return typeof t == "object" && t !== null && Ut in t && t[Ut] === !0 && "jsonSchema" in t && "validate" in t;
1279
1279
  }
1280
- function Sa(t) {
1280
+ function Ea(t) {
1281
1281
  return t == null ? vt({
1282
1282
  type: "object",
1283
1283
  properties: {},
1284
1284
  additionalProperties: !1
1285
- }) : ba(t) ? t : "~standard" in t ? t["~standard"].vendor === "zod" ? Hr(t) : Ia(t) : t();
1285
+ }) : Ia(t) ? t : "~standard" in t ? t["~standard"].vendor === "zod" ? Gr(t) : Ca(t) : t();
1286
1286
  }
1287
- function Ia(t) {
1287
+ function Ca(t) {
1288
1288
  return vt(() => {
1289
- if (!Ea(t)) throw new Error(`Standard schema vendor '${t["~standard"].vendor}' does not support JSON Schema conversion.`);
1289
+ if (!wa(t)) throw new Error(`Standard schema vendor '${t["~standard"].vendor}' does not support JSON Schema conversion.`);
1290
1290
  return Zt(t["~standard"].jsonSchema.input({ target: "draft-07" }));
1291
1291
  }, { validate: async (e) => {
1292
1292
  const r = await t["~standard"].validate(e);
@@ -1302,11 +1302,11 @@ function Ia(t) {
1302
1302
  };
1303
1303
  } });
1304
1304
  }
1305
- function Ea(t) {
1305
+ function wa(t) {
1306
1306
  return t["~standard"].jsonSchema != null;
1307
1307
  }
1308
- function Ca(t, e) {
1309
- return vt(() => ya(t, { $refStrategy: "none" }), { validate: async (r) => {
1308
+ function Aa(t, e) {
1309
+ return vt(() => ba(t, { $refStrategy: "none" }), { validate: async (r) => {
1310
1310
  const n = await t.safeParseAsync(r);
1311
1311
  return n.success ? {
1312
1312
  success: !0,
@@ -1317,13 +1317,13 @@ function Ca(t, e) {
1317
1317
  };
1318
1318
  } });
1319
1319
  }
1320
- function wa(t, e) {
1321
- return vt(() => Zt(ds(t, {
1320
+ function xa(t, e) {
1321
+ return vt(() => Zt(fs(t, {
1322
1322
  target: "draft-7",
1323
1323
  io: "input",
1324
1324
  reused: "inline"
1325
1325
  })), { validate: async (r) => {
1326
- const n = await Jn(t, r);
1326
+ const n = await Kn(t, r);
1327
1327
  return n.success ? {
1328
1328
  success: !0,
1329
1329
  value: n.data
@@ -1333,14 +1333,14 @@ function wa(t, e) {
1333
1333
  };
1334
1334
  } });
1335
1335
  }
1336
- function Aa(t) {
1336
+ function Ta(t) {
1337
1337
  return "_zod" in t;
1338
1338
  }
1339
- function Hr(t, e) {
1340
- return Aa(t) ? wa(t) : Ca(t);
1339
+ function Gr(t, e) {
1340
+ return Ta(t) ? xa(t) : Aa(t);
1341
1341
  }
1342
- async function cr({ value: t, schema: e, context: r }) {
1343
- const n = await Gr({
1342
+ async function ur({ value: t, schema: e, context: r }) {
1343
+ const n = await Qr({
1344
1344
  value: t,
1345
1345
  schema: e,
1346
1346
  context: r
@@ -1352,8 +1352,8 @@ async function cr({ value: t, schema: e, context: r }) {
1352
1352
  });
1353
1353
  return n.value;
1354
1354
  }
1355
- async function Gr({ value: t, schema: e, context: r }) {
1356
- const n = Sa(e);
1355
+ async function Qr({ value: t, schema: e, context: r }) {
1356
+ const n = Ea(e);
1357
1357
  try {
1358
1358
  if (n.validate == null) return {
1359
1359
  success: !0,
@@ -1388,19 +1388,19 @@ async function Gr({ value: t, schema: e, context: r }) {
1388
1388
  }
1389
1389
  async function qt({ text: t, schema: e }) {
1390
1390
  try {
1391
- const r = Rs(t);
1391
+ const r = Ns(t);
1392
1392
  return e == null ? {
1393
1393
  success: !0,
1394
1394
  value: r,
1395
1395
  rawValue: r
1396
- } : await Gr({
1396
+ } : await Qr({
1397
1397
  value: r,
1398
1398
  schema: e
1399
1399
  });
1400
1400
  } catch (r) {
1401
1401
  return {
1402
1402
  success: !1,
1403
- error: rr.isInstance(r) ? r : new rr({
1403
+ error: nr.isInstance(r) ? r : new nr({
1404
1404
  text: t,
1405
1405
  cause: r
1406
1406
  }),
@@ -1408,8 +1408,8 @@ async function qt({ text: t, schema: e }) {
1408
1408
  };
1409
1409
  }
1410
1410
  }
1411
- function xa({ stream: t, schema: e }) {
1412
- return t.pipeThrough(new TextDecoderStream()).pipeThrough(new As()).pipeThrough(new TransformStream({ async transform({ data: r }, n) {
1411
+ function Ma({ stream: t, schema: e }) {
1412
+ return t.pipeThrough(new TextDecoderStream()).pipeThrough(new Ts()).pipeThrough(new TransformStream({ async transform({ data: r }, n) {
1413
1413
  r !== "[DONE]" && n.enqueue(await qt({
1414
1414
  text: r,
1415
1415
  schema: e
@@ -1420,34 +1420,34 @@ async function Ve(t) {
1420
1420
  return typeof t == "function" && (t = t()), t;
1421
1421
  }
1422
1422
  new TextDecoder();
1423
- function Ta(t) {
1423
+ function _a(t) {
1424
1424
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
1425
1425
  }
1426
- const Qr = "AI_InvalidArgumentError", Xr = `vercel.ai.error.${Qr}`, Ma = Symbol.for(Xr);
1426
+ const Xr = "AI_InvalidArgumentError", en = `vercel.ai.error.${Xr}`, Ra = Symbol.for(en);
1427
1427
  var ut = class extends ee {
1428
1428
  constructor({ parameter: t, value: e, message: r }) {
1429
1429
  super({
1430
- name: Qr,
1430
+ name: Xr,
1431
1431
  message: `Invalid argument for parameter ${t}: ${r}`
1432
- }), this[Ma] = !0, this.parameter = t, this.value = e;
1432
+ }), this[Ra] = !0, this.parameter = t, this.value = e;
1433
1433
  }
1434
1434
  static isInstance(t) {
1435
- return ee.hasMarker(t, Xr);
1435
+ return ee.hasMarker(t, en);
1436
1436
  }
1437
1437
  };
1438
- const en = "AI_UIMessageStreamError", tn = `vercel.ai.error.${en}`, _a = Symbol.for(tn);
1439
- var Oe = class extends ee {
1438
+ const tn = "AI_UIMessageStreamError", rn = `vercel.ai.error.${tn}`, Pa = Symbol.for(rn);
1439
+ var Ne = class extends ee {
1440
1440
  constructor({ chunkType: t, chunkId: e, message: r }) {
1441
1441
  super({
1442
- name: en,
1442
+ name: tn,
1443
1443
  message: r
1444
- }), this[_a] = !0, this.chunkType = t, this.chunkId = e;
1444
+ }), this[Pa] = !0, this.chunkType = t, this.chunkId = e;
1445
1445
  }
1446
1446
  static isInstance(t) {
1447
- return ee.hasMarker(t, tn);
1447
+ return ee.hasMarker(t, rn);
1448
1448
  }
1449
1449
  };
1450
- function rn(t, e) {
1450
+ function nn(t, e) {
1451
1451
  if (t === void 0 && e === void 0) return;
1452
1452
  if (t === void 0) return e;
1453
1453
  if (e === void 0) return t;
@@ -1457,45 +1457,45 @@ function rn(t, e) {
1457
1457
  const s = e[n];
1458
1458
  if (s === void 0) continue;
1459
1459
  const o = n in t ? t[n] : void 0, l = s !== null && typeof s == "object" && !Array.isArray(s) && !(s instanceof Date) && !(s instanceof RegExp), u = o != null && typeof o == "object" && !Array.isArray(o) && !(o instanceof Date) && !(o instanceof RegExp);
1460
- l && u ? r[n] = rn(o, s) : r[n] = s;
1460
+ l && u ? r[n] = nn(o, s) : r[n] = s;
1461
1461
  }
1462
1462
  return r;
1463
1463
  }
1464
1464
  const a = {
1465
- array: us,
1466
- boolean: cs,
1467
- custom: ls,
1468
- discriminatedUnion: os,
1469
- enum: is,
1470
- instanceof: as,
1471
- lazy: Yn,
1472
- literal: ss,
1473
- looseObject: ns,
1474
- never: rs,
1475
- null: ts,
1476
- number: es,
1477
- object: Xn,
1478
- record: Qn,
1479
- string: Gn,
1480
- union: Hn,
1481
- unknown: Kn
1482
- }, ke = a.lazy(() => a.union([
1465
+ array: ps,
1466
+ boolean: ds,
1467
+ custom: us,
1468
+ discriminatedUnion: cs,
1469
+ enum: ls,
1470
+ instanceof: os,
1471
+ lazy: Hn,
1472
+ literal: is,
1473
+ looseObject: as,
1474
+ never: ss,
1475
+ null: ns,
1476
+ number: rs,
1477
+ object: ts,
1478
+ record: es,
1479
+ string: Xn,
1480
+ union: Qn,
1481
+ unknown: Gn
1482
+ }, $e = a.lazy(() => a.union([
1483
1483
  a.null(),
1484
1484
  a.string(),
1485
1485
  a.number(),
1486
1486
  a.boolean(),
1487
- a.record(a.string(), ke.optional()),
1488
- a.array(ke)
1489
- ])), _ = a.record(a.string(), a.record(a.string(), ke.optional())), et = a.union([
1487
+ a.record(a.string(), $e.optional()),
1488
+ a.array($e)
1489
+ ])), _ = a.record(a.string(), a.record(a.string(), $e.optional())), et = a.union([
1490
1490
  a.string(),
1491
1491
  a.instanceof(Uint8Array),
1492
1492
  a.instanceof(ArrayBuffer),
1493
- a.custom(Ts, { message: "Must be a Buffer" })
1494
- ]), Vt = a.record(a.string(), a.string()), nn = a.object({
1493
+ a.custom(_s, { message: "Must be a Buffer" })
1494
+ ]), Vt = a.record(a.string(), a.string()), sn = a.object({
1495
1495
  type: a.literal("text"),
1496
1496
  text: a.string(),
1497
1497
  providerOptions: _.optional()
1498
- }), Pa = a.object({
1498
+ }), Oa = a.object({
1499
1499
  type: a.literal("image"),
1500
1500
  image: a.union([
1501
1501
  et,
@@ -1504,7 +1504,7 @@ const a = {
1504
1504
  ]),
1505
1505
  mediaType: a.string().optional(),
1506
1506
  providerOptions: _.optional()
1507
- }), sn = a.discriminatedUnion("type", [
1507
+ }), an = a.discriminatedUnion("type", [
1508
1508
  a.object({
1509
1509
  type: a.literal("data"),
1510
1510
  data: et
@@ -1521,16 +1521,16 @@ const a = {
1521
1521
  type: a.literal("text"),
1522
1522
  text: a.string()
1523
1523
  })
1524
- ]), Ra = a.discriminatedUnion("type", [a.object({
1524
+ ]), Na = a.discriminatedUnion("type", [a.object({
1525
1525
  type: a.literal("data"),
1526
1526
  data: et
1527
1527
  }), a.object({
1528
1528
  type: a.literal("url"),
1529
1529
  url: a.instanceof(URL)
1530
- })]), an = a.object({
1530
+ })]), on = a.object({
1531
1531
  type: a.literal("file"),
1532
1532
  data: a.union([
1533
- sn,
1533
+ an,
1534
1534
  et,
1535
1535
  a.instanceof(URL),
1536
1536
  Vt
@@ -1538,31 +1538,31 @@ const a = {
1538
1538
  filename: a.string().optional(),
1539
1539
  mediaType: a.string(),
1540
1540
  providerOptions: _.optional()
1541
- }), Oa = a.object({
1541
+ }), Da = a.object({
1542
1542
  type: a.literal("reasoning"),
1543
1543
  text: a.string(),
1544
1544
  providerOptions: _.optional()
1545
- }), Na = a.object({
1545
+ }), La = a.object({
1546
1546
  type: a.literal("custom"),
1547
1547
  kind: a.string().transform((t) => t),
1548
1548
  providerOptions: _.optional()
1549
- }), Da = a.object({
1549
+ }), ja = a.object({
1550
1550
  type: a.literal("reasoning-file"),
1551
1551
  data: a.union([
1552
- Ra,
1552
+ Na,
1553
1553
  et,
1554
1554
  a.instanceof(URL)
1555
1555
  ]),
1556
1556
  mediaType: a.string(),
1557
1557
  providerOptions: _.optional()
1558
- }), La = a.object({
1558
+ }), ka = a.object({
1559
1559
  type: a.literal("tool-call"),
1560
1560
  toolCallId: a.string(),
1561
1561
  toolName: a.string(),
1562
1562
  input: a.unknown(),
1563
1563
  providerOptions: _.optional(),
1564
1564
  providerExecuted: a.boolean().optional()
1565
- }), ja = a.discriminatedUnion("type", [
1565
+ }), $a = a.discriminatedUnion("type", [
1566
1566
  a.object({
1567
1567
  type: a.literal("text"),
1568
1568
  value: a.string(),
@@ -1570,7 +1570,7 @@ const a = {
1570
1570
  }),
1571
1571
  a.object({
1572
1572
  type: a.literal("json"),
1573
- value: ke,
1573
+ value: $e,
1574
1574
  providerOptions: _.optional()
1575
1575
  }),
1576
1576
  a.object({
@@ -1585,7 +1585,7 @@ const a = {
1585
1585
  }),
1586
1586
  a.object({
1587
1587
  type: a.literal("error-json"),
1588
- value: ke,
1588
+ value: $e,
1589
1589
  providerOptions: _.optional()
1590
1590
  }),
1591
1591
  a.object({
@@ -1598,7 +1598,7 @@ const a = {
1598
1598
  }),
1599
1599
  a.object({
1600
1600
  type: a.literal("file"),
1601
- data: sn,
1601
+ data: an,
1602
1602
  mediaType: a.string(),
1603
1603
  filename: a.string().optional(),
1604
1604
  providerOptions: _.optional()
@@ -1653,13 +1653,13 @@ const a = {
1653
1653
  })
1654
1654
  ]))
1655
1655
  })
1656
- ]), on = a.object({
1656
+ ]), ln = a.object({
1657
1657
  type: a.literal("tool-result"),
1658
1658
  toolCallId: a.string(),
1659
1659
  toolName: a.string(),
1660
- output: ja,
1660
+ output: $a,
1661
1661
  providerOptions: _.optional()
1662
- }), ka = a.object({
1662
+ }), Fa = a.object({
1663
1663
  type: a.literal("tool-approval-request"),
1664
1664
  approvalId: a.string(),
1665
1665
  toolCallId: a.string(),
@@ -1667,48 +1667,48 @@ const a = {
1667
1667
  isAutomatic: a.boolean().optional(),
1668
1668
  signature: a.string().optional(),
1669
1669
  inputSchemaInput: a.unknown().optional()
1670
- }), $a = a.object({
1670
+ }), Ua = a.object({
1671
1671
  type: a.literal("tool-approval-response"),
1672
1672
  approvalId: a.string(),
1673
1673
  approved: a.boolean(),
1674
1674
  reason: a.string().optional()
1675
- }), Fa = a.object({
1675
+ }), qa = a.object({
1676
1676
  role: a.literal("system"),
1677
1677
  content: a.string(),
1678
1678
  providerOptions: _.optional()
1679
- }), Ua = a.object({
1679
+ }), za = a.object({
1680
1680
  role: a.literal("user"),
1681
1681
  content: a.union([a.string(), a.array(a.union([
1682
- nn,
1683
- Pa,
1684
- an
1682
+ sn,
1683
+ Oa,
1684
+ on
1685
1685
  ]))]),
1686
1686
  providerOptions: _.optional()
1687
- }), qa = a.object({
1687
+ }), Za = a.object({
1688
1688
  role: a.literal("assistant"),
1689
1689
  content: a.union([a.string(), a.array(a.union([
1690
- nn,
1691
- Na,
1692
- an,
1693
- Oa,
1694
- Da,
1690
+ sn,
1695
1691
  La,
1696
1692
  on,
1697
- ka
1693
+ Da,
1694
+ ja,
1695
+ ka,
1696
+ ln,
1697
+ Fa
1698
1698
  ]))]),
1699
1699
  providerOptions: _.optional()
1700
- }), za = a.object({
1700
+ }), Va = a.object({
1701
1701
  role: a.literal("tool"),
1702
- content: a.array(a.union([on, $a])),
1702
+ content: a.array(a.union([ln, Ua])),
1703
1703
  providerOptions: _.optional()
1704
1704
  });
1705
1705
  a.union([
1706
- Fa,
1707
- Ua,
1708
1706
  qa,
1709
- za
1707
+ za,
1708
+ Za,
1709
+ Va
1710
1710
  ]);
1711
- function Za(t) {
1711
+ function Ba(t) {
1712
1712
  const e = ["ROOT"];
1713
1713
  let r = -1, n = null, s = 0;
1714
1714
  function o(i) {
@@ -1909,7 +1909,7 @@ function Za(t) {
1909
1909
  }
1910
1910
  return g;
1911
1911
  }
1912
- async function Va(t) {
1912
+ async function Wa(t) {
1913
1913
  if (t === void 0) return {
1914
1914
  value: void 0,
1915
1915
  state: "undefined-input"
@@ -1918,7 +1918,7 @@ async function Va(t) {
1918
1918
  return e.success ? {
1919
1919
  value: e.value,
1920
1920
  state: "successful-parse"
1921
- } : (e = await qt({ text: Za(t) }), e.success ? {
1921
+ } : (e = await qt({ text: Ba(t) }), e.success ? {
1922
1922
  value: e.value,
1923
1923
  state: "repaired-parse"
1924
1924
  } : {
@@ -1952,7 +1952,7 @@ te({
1952
1952
  });
1953
1953
  }
1954
1954
  });
1955
- const Ba = a.object({
1955
+ const Ja = a.object({
1956
1956
  source: a.discriminatedUnion("sourceType", [a.object({
1957
1957
  type: a.literal("source"),
1958
1958
  sourceType: a.literal("url"),
@@ -1972,7 +1972,7 @@ const Ba = a.object({
1972
1972
  startIndex: a.number().int().nonnegative().optional(),
1973
1973
  endIndex: a.number().int().nonnegative().optional(),
1974
1974
  citedText: a.string().optional()
1975
- }), Ge = a.record(a.string(), ke.optional()), Wa = va(() => Hr(a.union([
1975
+ }), Ge = a.record(a.string(), $e.optional()), Ya = Sa(() => Gr(a.union([
1976
1976
  a.looseObject({
1977
1977
  type: a.literal("text-start"),
1978
1978
  id: a.string(),
@@ -1987,7 +1987,7 @@ const Ba = a.object({
1987
1987
  a.looseObject({
1988
1988
  type: a.literal("text-end"),
1989
1989
  id: a.string(),
1990
- citations: a.array(Ba).optional(),
1990
+ citations: a.array(Ja).optional(),
1991
1991
  providerMetadata: _.optional()
1992
1992
  }),
1993
1993
  a.looseObject({
@@ -2158,7 +2158,7 @@ const Ba = a.object({
2158
2158
  messageMetadata: a.unknown()
2159
2159
  })
2160
2160
  ])));
2161
- function Ja(t) {
2161
+ function Ka(t) {
2162
2162
  return t.type.startsWith("data-");
2163
2163
  }
2164
2164
  function Be() {
@@ -2167,19 +2167,19 @@ function Be() {
2167
2167
  function gt(t) {
2168
2168
  return t.type.startsWith("tool-");
2169
2169
  }
2170
- function ln(t) {
2170
+ function cn(t) {
2171
2171
  return t.type === "dynamic-tool";
2172
2172
  }
2173
- function de(t) {
2174
- return gt(t) || ln(t);
2173
+ function pe(t) {
2174
+ return gt(t) || cn(t);
2175
2175
  }
2176
2176
  function ht(t) {
2177
2177
  return t.type.split("-").slice(1).join("-");
2178
2178
  }
2179
- function Ya(t) {
2180
- return ln(t) ? t.toolName : ht(t);
2179
+ function Ha(t) {
2180
+ return cn(t) ? t.toolName : ht(t);
2181
2181
  }
2182
- function cn({ lastMessage: t, messageId: e }) {
2182
+ function un({ lastMessage: t, messageId: e }) {
2183
2183
  const r = (t == null ? void 0 : t.role) === "assistant" ? t : {
2184
2184
  id: e,
2185
2185
  metadata: void 0,
@@ -2188,7 +2188,7 @@ function cn({ lastMessage: t, messageId: e }) {
2188
2188
  }, n = Be(), s = r.parts.findLastIndex((l) => l.type === "step-start");
2189
2189
  let o = 0;
2190
2190
  for (const l of r.parts.slice(s + 1)) {
2191
- if (!de(l)) continue;
2191
+ if (!pe(l)) continue;
2192
2192
  const u = o;
2193
2193
  gt(l) && o++, l.state === "input-streaming" && (n[l.toolCallId] = {
2194
2194
  text: l.rawInput ?? "",
@@ -2207,18 +2207,18 @@ function cn({ lastMessage: t, messageId: e }) {
2207
2207
  partialToolCalls: n
2208
2208
  };
2209
2209
  }
2210
- function Ka({ stream: t, messageMetadataSchema: e, dataPartSchemas: r, runUpdateMessageJob: n, onError: s, onToolCall: o, onData: l, resetStateOnMessageIdChange: u = !1, resetStateOnFirstMessageStart: y = !1 }) {
2210
+ function Ga({ stream: t, messageMetadataSchema: e, dataPartSchemas: r, runUpdateMessageJob: n, onError: s, onToolCall: o, onData: l, resetStateOnMessageIdChange: u = !1, resetStateOnFirstMessageStart: y = !1 }) {
2211
2211
  let g = !0;
2212
2212
  return t.pipeThrough(new TransformStream({ async transform(i, d) {
2213
2213
  await n(async ({ state: p, write: b }) => {
2214
- function R() {
2214
+ function P() {
2215
2215
  const c = p.message.parts;
2216
2216
  let m = c.length - 1;
2217
2217
  for (; m >= 0 && c[m].type !== "step-start"; ) m--;
2218
2218
  return c.slice(m + 1);
2219
2219
  }
2220
2220
  function M() {
2221
- return R().filter(de);
2221
+ return P().filter(pe);
2222
2222
  }
2223
2223
  function O(c) {
2224
2224
  let m = M().find((f) => f.toolCallId === c);
@@ -2226,25 +2226,25 @@ function Ka({ stream: t, messageMetadataSchema: e, dataPartSchemas: r, runUpdate
2226
2226
  const f = p.message.parts;
2227
2227
  for (let h = f.length - 1; h >= 0; h--) {
2228
2228
  const S = f[h];
2229
- if (de(S) && S.toolCallId === c) {
2229
+ if (pe(S) && S.toolCallId === c) {
2230
2230
  m = S;
2231
2231
  break;
2232
2232
  }
2233
2233
  }
2234
2234
  }
2235
- if (m == null) throw new Oe({
2235
+ if (m == null) throw new Ne({
2236
2236
  chunkType: "tool-invocation",
2237
2237
  chunkId: c,
2238
2238
  message: `No tool invocation found for tool call ID "${c}".`
2239
2239
  });
2240
2240
  return m;
2241
2241
  }
2242
- function T(c) {
2243
- const m = p.message.parts.filter(de).find((f) => {
2242
+ function x(c) {
2243
+ const m = p.message.parts.filter(pe).find((f) => {
2244
2244
  var h;
2245
2245
  return ((h = f.approval) == null ? void 0 : h.id) === c;
2246
2246
  });
2247
- if (m == null) throw new Oe({
2247
+ if (m == null) throw new Ne({
2248
2248
  chunkType: "tool-approval-response",
2249
2249
  chunkId: c,
2250
2250
  message: `No tool invocation found for approval ID "${c}".`
@@ -2252,7 +2252,7 @@ function Ka({ stream: t, messageMetadataSchema: e, dataPartSchemas: r, runUpdate
2252
2252
  return m;
2253
2253
  }
2254
2254
  function w(c, m) {
2255
- const f = m ?? R().find((N) => gt(N) && N.toolCallId === c.toolCallId), h = c, S = f;
2255
+ const f = m ?? P().find((N) => gt(N) && N.toolCallId === c.toolCallId), h = c, S = f;
2256
2256
  if (f != null) {
2257
2257
  f.state = c.state, S.type = `tool-${c.toolName}`, S.input = h.input, S.output = h.output, S.errorText = h.errorText, S.rawInput = h.rawInput, h.inputEncoding != null ? S.inputEncoding = h.inputEncoding : delete S.inputEncoding, S.preliminary = h.preliminary, c.title !== void 0 && (S.title = c.title), c.toolMetadata !== void 0 && (S.toolMetadata = c.toolMetadata), S.providerExecuted = h.providerExecuted ?? f.providerExecuted;
2258
2258
  const N = h.providerMetadata;
@@ -2279,7 +2279,7 @@ function Ka({ stream: t, messageMetadataSchema: e, dataPartSchemas: r, runUpdate
2279
2279
  });
2280
2280
  }
2281
2281
  function I(c, m) {
2282
- const f = m ?? R().find((N) => N.type === "dynamic-tool" && N.toolCallId === c.toolCallId), h = c, S = f;
2282
+ const f = m ?? P().find((N) => N.type === "dynamic-tool" && N.toolCallId === c.toolCallId), h = c, S = f;
2283
2283
  if (f != null) {
2284
2284
  f.state = c.state, S.toolName = c.toolName, S.input = h.input, S.output = h.output, S.errorText = h.errorText, S.rawInput = h.rawInput, h.inputEncoding != null ? S.inputEncoding = h.inputEncoding : delete S.inputEncoding, S.preliminary = h.preliminary, c.title !== void 0 && (S.title = c.title), c.toolMetadata !== void 0 && (S.toolMetadata = c.toolMetadata), S.providerExecuted = h.providerExecuted ?? f.providerExecuted;
2285
2285
  const N = h.providerMetadata;
@@ -2307,8 +2307,8 @@ function Ka({ stream: t, messageMetadataSchema: e, dataPartSchemas: r, runUpdate
2307
2307
  }
2308
2308
  async function C(c) {
2309
2309
  if (c != null) {
2310
- const m = p.message.metadata != null ? rn(p.message.metadata, c) : c;
2311
- e != null && await cr({
2310
+ const m = p.message.metadata != null ? nn(p.message.metadata, c) : c;
2311
+ e != null && await ur({
2312
2312
  value: m,
2313
2313
  schema: e,
2314
2314
  context: {
@@ -2331,7 +2331,7 @@ function Ka({ stream: t, messageMetadataSchema: e, dataPartSchemas: r, runUpdate
2331
2331
  }
2332
2332
  case "text-delta": {
2333
2333
  const c = p.activeTextParts[i.id];
2334
- if (c == null) throw new Oe({
2334
+ if (c == null) throw new Ne({
2335
2335
  chunkType: "text-delta",
2336
2336
  chunkId: i.id,
2337
2337
  message: `Received text-delta for missing text part with ID "${i.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`
@@ -2341,7 +2341,7 @@ function Ka({ stream: t, messageMetadataSchema: e, dataPartSchemas: r, runUpdate
2341
2341
  }
2342
2342
  case "text-end": {
2343
2343
  const c = p.activeTextParts[i.id];
2344
- if (c == null) throw new Oe({
2344
+ if (c == null) throw new Ne({
2345
2345
  chunkType: "text-end",
2346
2346
  chunkId: i.id,
2347
2347
  message: `Received text-end for missing text part with ID "${i.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`
@@ -2371,7 +2371,7 @@ function Ka({ stream: t, messageMetadataSchema: e, dataPartSchemas: r, runUpdate
2371
2371
  }
2372
2372
  case "reasoning-delta": {
2373
2373
  const c = p.activeReasoningParts[i.id];
2374
- if (c == null) throw new Oe({
2374
+ if (c == null) throw new Ne({
2375
2375
  chunkType: "reasoning-delta",
2376
2376
  chunkId: i.id,
2377
2377
  message: `Received reasoning-delta for missing reasoning part with ID "${i.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`
@@ -2381,7 +2381,7 @@ function Ka({ stream: t, messageMetadataSchema: e, dataPartSchemas: r, runUpdate
2381
2381
  }
2382
2382
  case "reasoning-end": {
2383
2383
  const c = p.activeReasoningParts[i.id];
2384
- if (c == null) throw new Oe({
2384
+ if (c == null) throw new Ne({
2385
2385
  chunkType: "reasoning-end",
2386
2386
  chunkId: i.id,
2387
2387
  message: `Received reasoning-end for missing reasoning part with ID "${i.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`
@@ -2418,7 +2418,7 @@ function Ka({ stream: t, messageMetadataSchema: e, dataPartSchemas: r, runUpdate
2418
2418
  }), b();
2419
2419
  break;
2420
2420
  case "tool-input-start": {
2421
- const c = R().filter(gt);
2421
+ const c = P().filter(gt);
2422
2422
  p.partialToolCalls[i.toolCallId] = {
2423
2423
  text: "",
2424
2424
  inputEncoding: i.inputEncoding,
@@ -2452,13 +2452,13 @@ function Ka({ stream: t, messageMetadataSchema: e, dataPartSchemas: r, runUpdate
2452
2452
  }
2453
2453
  case "tool-input-delta": {
2454
2454
  const c = p.partialToolCalls[i.toolCallId];
2455
- if (c == null) throw new Oe({
2455
+ if (c == null) throw new Ne({
2456
2456
  chunkType: "tool-input-delta",
2457
2457
  chunkId: i.toolCallId,
2458
2458
  message: `Received tool-input-delta for missing tool call with ID "${i.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`
2459
2459
  });
2460
2460
  c.text += i.inputTextDelta;
2461
- const m = c.inputEncoding === "text" ? c.text : (await Va(c.text)).value;
2461
+ const m = c.inputEncoding === "text" ? c.text : (await Wa(c.text)).value;
2462
2462
  c.dynamic ? I({
2463
2463
  toolCallId: i.toolCallId,
2464
2464
  toolName: c.toolName,
@@ -2502,7 +2502,7 @@ function Ka({ stream: t, messageMetadataSchema: e, dataPartSchemas: r, runUpdate
2502
2502
  }), b(), o && !i.providerExecuted && await o({ toolCall: i });
2503
2503
  break;
2504
2504
  case "tool-input-error": {
2505
- const c = R().filter(de).find((m) => m.toolCallId === i.toolCallId);
2505
+ const c = P().filter(pe).find((m) => m.toolCallId === i.toolCallId);
2506
2506
  (c != null ? c.type === "dynamic-tool" : i.dynamic) ? I({
2507
2507
  toolCallId: i.toolCallId,
2508
2508
  toolName: i.toolName,
@@ -2537,7 +2537,7 @@ function Ka({ stream: t, messageMetadataSchema: e, dataPartSchemas: r, runUpdate
2537
2537
  break;
2538
2538
  }
2539
2539
  case "tool-approval-response": {
2540
- const c = T(i.approvalId), m = c.approval == null ? { id: i.approvalId } : c.approval;
2540
+ const c = x(i.approvalId), m = c.approval == null ? { id: i.approvalId } : c.approval;
2541
2541
  c.state = "approval-responded", c.approval = {
2542
2542
  ...m,
2543
2543
  id: i.approvalId,
@@ -2610,13 +2610,13 @@ function Ka({ stream: t, messageMetadataSchema: e, dataPartSchemas: r, runUpdate
2610
2610
  case "finish-step":
2611
2611
  break;
2612
2612
  case "reset-step": {
2613
- const c = R();
2613
+ const c = P();
2614
2614
  p.activeTextParts = Be(), p.activeReasoningParts = Be(), p.partialToolCalls = Be(), c.length > 0 && (p.message.parts.splice(p.message.parts.length - c.length, c.length), b());
2615
2615
  break;
2616
2616
  }
2617
2617
  case "start": {
2618
2618
  const c = y && g || u && i.messageId != null && i.messageId !== p.message.id;
2619
- g = !1, c && Object.assign(p, cn({
2619
+ g = !1, c && Object.assign(p, un({
2620
2620
  lastMessage: void 0,
2621
2621
  messageId: i.messageId ?? p.message.id
2622
2622
  }), { finishReason: void 0 }), i.messageId != null && (p.message.id = i.messageId), await C(i.messageMetadata), (c || i.messageId != null || i.messageMetadata != null) && b({ updateStatus: !1 });
@@ -2632,10 +2632,10 @@ function Ka({ stream: t, messageMetadataSchema: e, dataPartSchemas: r, runUpdate
2632
2632
  s == null || s(new Error(i.errorText));
2633
2633
  break;
2634
2634
  default:
2635
- if (Ja(i)) {
2635
+ if (Ka(i)) {
2636
2636
  if ((r == null ? void 0 : r[i.type]) != null) {
2637
2637
  const f = p.message.parts.findIndex((S) => "id" in S && "data" in S && S.id === i.id && S.type === i.type), h = f >= 0 ? f : p.message.parts.length;
2638
- await cr({
2638
+ await ur({
2639
2639
  value: i.data,
2640
2640
  schema: r[i.type],
2641
2641
  context: {
@@ -2658,7 +2658,7 @@ function Ka({ stream: t, messageMetadataSchema: e, dataPartSchemas: r, runUpdate
2658
2658
  });
2659
2659
  } }));
2660
2660
  }
2661
- async function Ha({ stream: t, onError: e, abortSignal: r }) {
2661
+ async function Qa({ stream: t, onError: e, abortSignal: r }) {
2662
2662
  const n = t.getReader(), s = () => {
2663
2663
  n.cancel().catch(() => {
2664
2664
  });
@@ -2675,7 +2675,7 @@ async function Ha({ stream: t, onError: e, abortSignal: r }) {
2675
2675
  r == null || r.removeEventListener("abort", s), n.releaseLock();
2676
2676
  }
2677
2677
  }
2678
- function Ga() {
2678
+ function Xa() {
2679
2679
  let t, e;
2680
2680
  return {
2681
2681
  promise: new Promise((r, n) => {
@@ -2701,7 +2701,7 @@ te({
2701
2701
  prefix: "call",
2702
2702
  size: 24
2703
2703
  });
2704
- a.record(a.string(), ke.optional());
2704
+ a.record(a.string(), $e.optional());
2705
2705
  a.record(a.string(), a.string());
2706
2706
  te({
2707
2707
  prefix: "call",
@@ -2720,7 +2720,7 @@ te({
2720
2720
  prefix: "aiobj",
2721
2721
  size: 24
2722
2722
  });
2723
- var Qa = class {
2723
+ var ei = class {
2724
2724
  constructor() {
2725
2725
  this.queue = [], this.isProcessing = !1, this.idleWaiters = [];
2726
2726
  }
@@ -2791,9 +2791,9 @@ te({
2791
2791
  prefix: "call",
2792
2792
  size: 24
2793
2793
  });
2794
- async function ur({ response: t, url: e, fallbackMessage: r }) {
2794
+ async function dr({ response: t, url: e, fallbackMessage: r }) {
2795
2795
  const n = await t.text();
2796
- return new Dr({
2796
+ return new Lr({
2797
2797
  message: n || r,
2798
2798
  url: e,
2799
2799
  requestBodyValues: void 0,
@@ -2801,9 +2801,9 @@ async function ur({ response: t, url: e, fallbackMessage: r }) {
2801
2801
  responseBody: n
2802
2802
  });
2803
2803
  }
2804
- async function Xa(t) {
2804
+ async function ti(t) {
2805
2805
  if (t == null) return [];
2806
- if (!globalThis.FileList || !(t instanceof globalThis.FileList)) throw new Es({
2806
+ if (!globalThis.FileList || !(t instanceof globalThis.FileList)) throw new ws({
2807
2807
  functionality: "FileList",
2808
2808
  message: "FileList is not supported in the current environment"
2809
2809
  });
@@ -2823,11 +2823,11 @@ async function Xa(t) {
2823
2823
  };
2824
2824
  }));
2825
2825
  }
2826
- function ei(t, e) {
2826
+ function ri(t, e) {
2827
2827
  const r = t.search(/[?#]/), n = r === -1 ? t : t.slice(0, r), s = r === -1 ? "" : t.slice(r);
2828
2828
  return `${n.endsWith("/") && e.startsWith("/") ? n.slice(0, -1) : n}${e}${s}`;
2829
2829
  }
2830
- var ti = class {
2830
+ var ni = class {
2831
2831
  constructor({ api: t = "/api/chat", credentials: e, headers: r, body: n, fetch: s, prepareSendMessagesRequest: o, prepareReconnectToStreamRequest: l }) {
2832
2832
  this.api = t, this.credentials = e, this.headers = r, this.body = n, this.fetch = s, this.prepareSendMessagesRequest = o, this.prepareReconnectToStreamRequest = l;
2833
2833
  }
@@ -2866,7 +2866,7 @@ var ti = class {
2866
2866
  credentials: i,
2867
2867
  signal: t
2868
2868
  });
2869
- if (!d.ok) throw await ur({
2869
+ if (!d.ok) throw await dr({
2870
2870
  response: d,
2871
2871
  url: u,
2872
2872
  fallbackMessage: "Failed to fetch the chat response."
@@ -2897,7 +2897,7 @@ var ti = class {
2897
2897
  value: t.chatId,
2898
2898
  message: 'Chat IDs must not be "." or ".." when using the default reconnect URL.'
2899
2899
  });
2900
- l = ei(this.api, `/${encodeURIComponent(t.chatId)}/stream`);
2900
+ l = ri(this.api, `/${encodeURIComponent(t.chatId)}/stream`);
2901
2901
  }
2902
2902
  const u = (o == null ? void 0 : o.headers) !== void 0 ? Ze(o.headers) : s, y = (o == null ? void 0 : o.credentials) ?? n, g = await (this.fetch ?? globalThis.fetch)(l, {
2903
2903
  method: "GET",
@@ -2906,7 +2906,7 @@ var ti = class {
2906
2906
  signal: t.abortSignal
2907
2907
  });
2908
2908
  if (g.status === 204) return null;
2909
- if (!g.ok) throw await ur({
2909
+ if (!g.ok) throw await dr({
2910
2910
  response: g,
2911
2911
  url: l,
2912
2912
  fallbackMessage: "Failed to fetch the chat response."
@@ -2914,39 +2914,39 @@ var ti = class {
2914
2914
  if (!g.body) throw new ft({ message: "The response body is empty." });
2915
2915
  return this.processResponseStream(g.body);
2916
2916
  }
2917
- }, yt = class extends ti {
2917
+ }, yt = class extends ni {
2918
2918
  constructor({ resumeStreamIsReplay: t = !0, ...e } = {}) {
2919
2919
  super(e), this.resumeStreamIsReplay = t;
2920
2920
  }
2921
2921
  processResponseStream(t) {
2922
- return xa({
2922
+ return Ma({
2923
2923
  stream: t,
2924
- schema: Wa
2924
+ schema: Ya
2925
2925
  }).pipeThrough(new TransformStream({ async transform(e, r) {
2926
2926
  if (!e.success) throw e.error;
2927
2927
  r.enqueue(e.value);
2928
2928
  } }));
2929
2929
  }
2930
- }, ri = class {
2930
+ }, si = class {
2931
2931
  get id() {
2932
2932
  return this._id ?? (this._id = this.generateId());
2933
2933
  }
2934
- constructor({ generateId: t = xs, id: e, transport: r = new yt(), messageMetadataSchema: n, dataPartSchemas: s, state: o, onError: l, onToolCall: u, onFinish: y, onData: g, sendAutomaticallyWhen: i }) {
2935
- this.pendingMessagePreparations = /* @__PURE__ */ new Set(), this.interruptedMessageIds = /* @__PURE__ */ new Set(), this.activeResponse = void 0, this.activeResumeRequest = void 0, this.resumableStreamState = void 0, this.jobExecutor = new Qa(), this.activeStopCount = 0, this.stopGeneration = 0, this.sendMessage = async (d, p) => {
2936
- var R;
2934
+ constructor({ generateId: t = Ms, id: e, transport: r = new yt(), messageMetadataSchema: n, dataPartSchemas: s, state: o, onError: l, onToolCall: u, onFinish: y, onData: g, sendAutomaticallyWhen: i }) {
2935
+ this.pendingMessagePreparations = /* @__PURE__ */ new Set(), this.interruptedMessageIds = /* @__PURE__ */ new Set(), this.activeResponse = void 0, this.activeResumeRequest = void 0, this.resumableStreamState = void 0, this.jobExecutor = new ei(), this.activeStopCount = 0, this.stopGeneration = 0, this.sendMessage = async (d, p) => {
2936
+ var P;
2937
2937
  if (d == null) {
2938
2938
  let M = this.pendingApprovalMessageId;
2939
2939
  if (M == null) {
2940
- M = (R = this.lastMessage) == null ? void 0 : R.id;
2941
- for (let T = this.state.messages.length - 1; T >= 0; T--) {
2942
- const w = this.state.messages[T];
2943
- if (w.role === "assistant" && w.parts.some((I) => de(I) && I.state === "approval-responded")) {
2940
+ M = (P = this.lastMessage) == null ? void 0 : P.id;
2941
+ for (let x = this.state.messages.length - 1; x >= 0; x--) {
2942
+ const w = this.state.messages[x];
2943
+ if (w.role === "assistant" && w.parts.some((I) => pe(I) && I.state === "approval-responded")) {
2944
2944
  M = w.id;
2945
2945
  break;
2946
2946
  }
2947
2947
  }
2948
2948
  }
2949
- const O = M != null && M === this.pendingApprovalMessageId ? this.state.messages.findIndex((T) => T.id === M) : -1;
2949
+ const O = M != null && M === this.pendingApprovalMessageId ? this.state.messages.findIndex((x) => x.id === M) : -1;
2950
2950
  await this.makeRequestForToolApproval({
2951
2951
  messageId: M,
2952
2952
  messageIndex: O,
@@ -2960,7 +2960,7 @@ var ti = class {
2960
2960
  this.pendingMessagePreparations.add(M);
2961
2961
  let O;
2962
2962
  try {
2963
- O = Array.isArray(d.files) ? d.files : await Xa(d.files);
2963
+ O = Array.isArray(d.files) ? d.files : await ti(d.files);
2964
2964
  } finally {
2965
2965
  this.pendingMessagePreparations.delete(M);
2966
2966
  }
@@ -3000,7 +3000,7 @@ var ti = class {
3000
3000
  ...p
3001
3001
  });
3002
3002
  }, this.regenerate = async ({ messageId: d, ...p } = {}) => {
3003
- const b = d == null ? this.state.messages.length - 1 : this.state.messages.findIndex((R) => R.id === d);
3003
+ const b = d == null ? this.state.messages.length - 1 : this.state.messages.findIndex((P) => P.id === d);
3004
3004
  if (b === -1) throw new ut({
3005
3005
  parameter: "messageId",
3006
3006
  value: d,
@@ -3021,8 +3021,8 @@ var ti = class {
3021
3021
  this.resumableStreamState == null && p != null && (await p.completionPromise, this.resumableStreamState !== p.state) || this.resumableStreamState != null && d() && await this.resumeStream();
3022
3022
  }, this.clearError = () => {
3023
3023
  this.status === "error" && (this.state.error = void 0, this.setStatus({ status: "ready" }));
3024
- }, this.addToolApprovalResponse = async ({ id: d, approved: p, reason: b, options: R }) => this.jobExecutor.run(async () => {
3025
- const M = this.state.messages, O = (w) => de(w) && w.state === "approval-requested" && w.approval.id === d ? {
3024
+ }, this.addToolApprovalResponse = async ({ id: d, approved: p, reason: b, options: P }) => this.jobExecutor.run(async () => {
3025
+ const M = this.state.messages, O = (w) => pe(w) && w.state === "approval-requested" && w.approval.id === d ? {
3026
3026
  ...w,
3027
3027
  state: "approval-responded",
3028
3028
  approval: {
@@ -3031,29 +3031,29 @@ var ti = class {
3031
3031
  approved: p,
3032
3032
  reason: b
3033
3033
  }
3034
- } : w, T = M.findIndex((w) => w.parts.some((I) => de(I) && I.state === "approval-requested" && I.approval.id === d));
3035
- if (T !== -1) {
3036
- const w = M[T];
3037
- this.state.replaceMessage(T, {
3034
+ } : w, x = M.findIndex((w) => w.parts.some((I) => pe(I) && I.state === "approval-requested" && I.approval.id === d));
3035
+ if (x !== -1) {
3036
+ const w = M[x];
3037
+ this.state.replaceMessage(x, {
3038
3038
  ...w,
3039
3039
  parts: w.parts.map(O)
3040
3040
  }), this.pendingApprovalMessageId = w.id;
3041
3041
  }
3042
- if (this.activeResponse && (this.activeResponse.state.message.parts = this.activeResponse.state.message.parts.map(O)), T !== -1 && this.status !== "streaming" && this.status !== "submitted" && this.sendAutomaticallyWhen) {
3043
- const w = await this.shouldSendAutomatically(M[T].id);
3042
+ if (this.activeResponse && (this.activeResponse.state.message.parts = this.activeResponse.state.message.parts.map(O)), x !== -1 && this.status !== "streaming" && this.status !== "submitted" && this.sendAutomaticallyWhen) {
3043
+ const w = await this.shouldSendAutomatically(M[x].id);
3044
3044
  w && this.runAutomaticRequest(() => {
3045
3045
  var C;
3046
- const I = T === -1 ? (C = this.lastMessage) == null ? void 0 : C.id : M[T].id;
3046
+ const I = x === -1 ? (C = this.lastMessage) == null ? void 0 : C.id : M[x].id;
3047
3047
  return this.makeRequestForToolApproval({
3048
3048
  messageId: I,
3049
- messageIndex: T,
3050
- ...R
3049
+ messageIndex: x,
3050
+ ...P
3051
3051
  });
3052
3052
  }, w);
3053
3053
  }
3054
- }), this.addToolOutput = async ({ state: d, toolCallId: p, output: b, errorText: R, options: M }) => this.jobExecutor.run(async () => {
3055
- const O = this.state.messages, T = (I) => {
3056
- if (!de(I) || I.toolCallId !== p) return I;
3054
+ }), this.addToolOutput = async ({ state: d, toolCallId: p, output: b, errorText: P, options: M }) => this.jobExecutor.run(async () => {
3055
+ const O = this.state.messages, x = (I) => {
3056
+ if (!pe(I) || I.toolCallId !== p) return I;
3057
3057
  const { approval: C, ...c } = I, m = (C == null ? void 0 : C.approved) === !0 ? { approval: {
3058
3058
  ...C,
3059
3059
  approved: C.approved
@@ -3064,7 +3064,7 @@ var ti = class {
3064
3064
  state: d,
3065
3065
  input: I.input,
3066
3066
  output: void 0,
3067
- errorText: R
3067
+ errorText: P
3068
3068
  } : {
3069
3069
  ...c,
3070
3070
  ...m,
@@ -3073,15 +3073,15 @@ var ti = class {
3073
3073
  output: b,
3074
3074
  errorText: void 0
3075
3075
  };
3076
- }, w = O.findIndex((I) => I.parts.some((C) => de(C) && C.toolCallId === p));
3076
+ }, w = O.findIndex((I) => I.parts.some((C) => pe(C) && C.toolCallId === p));
3077
3077
  if (w !== -1) {
3078
3078
  const I = O[w];
3079
3079
  this.state.replaceMessage(w, {
3080
3080
  ...I,
3081
- parts: I.parts.map(T)
3081
+ parts: I.parts.map(x)
3082
3082
  });
3083
3083
  }
3084
- if (this.activeResponse && (this.activeResponse.state.message.parts = this.activeResponse.state.message.parts.map(T)), w !== -1 && this.status !== "streaming" && this.status !== "submitted" && this.sendAutomaticallyWhen) {
3084
+ if (this.activeResponse && (this.activeResponse.state.message.parts = this.activeResponse.state.message.parts.map(x)), w !== -1 && this.status !== "streaming" && this.status !== "submitted" && this.sendAutomaticallyWhen) {
3085
3085
  const I = await this.shouldSendAutomatically(O[w].id);
3086
3086
  I && this.runAutomaticRequest(() => this.makeRequest({
3087
3087
  trigger: "submit-message",
@@ -3152,7 +3152,7 @@ var ti = class {
3152
3152
  }), n && this.status === "error" && this.pendingApprovalMessageId == null && (this.pendingApprovalMessageId = ((s = this.state.messages[e]) == null ? void 0 : s.id) ?? t);
3153
3153
  }
3154
3154
  async makeRequest(t) {
3155
- const e = Ga();
3155
+ const e = Xa();
3156
3156
  try {
3157
3157
  await this.makeRequestImpl({
3158
3158
  ...t,
@@ -3208,11 +3208,11 @@ var ti = class {
3208
3208
  status: "submitted",
3209
3209
  error: void 0
3210
3210
  });
3211
- const d = this.lastMessage, p = t === "submit-message" && s != null ? this.state.messages.findIndex((f) => f.id === s) : this.state.messages.length - 1, b = p === -1 ? d : this.state.messages[p], R = b == null ? void 0 : b.id, M = t === "resume-stream" && (b == null ? void 0 : b.role) === "assistant" && b.parts.some((f) => de(f) && (f.state === "input-streaming" || f.state === "input-available" && f.providerExecuted || f.state === "approval-responded")) ? this.state.snapshot(b) : void 0, O = p !== -1 && p < this.state.messages.length - 1 && (b == null ? void 0 : b.role) === "assistant";
3212
- let T = !1, w = !1, I = !1, C;
3211
+ const d = this.lastMessage, p = t === "submit-message" && s != null ? this.state.messages.findIndex((f) => f.id === s) : this.state.messages.length - 1, b = p === -1 ? d : this.state.messages[p], P = b == null ? void 0 : b.id, M = t === "resume-stream" && (b == null ? void 0 : b.role) === "assistant" && b.parts.some((f) => pe(f) && (f.state === "input-streaming" || f.state === "input-available" && f.providerExecuted || f.state === "approval-responded")) ? this.state.snapshot(b) : void 0, O = p !== -1 && p < this.state.messages.length - 1 && (b == null ? void 0 : b.role) === "assistant";
3212
+ let x = !1, w = !1, I = !1, C;
3213
3213
  try {
3214
3214
  const f = {
3215
- state: t === "resume-stream" && this.resumableStreamState != null ? this.resumableStreamState : cn({
3215
+ state: t === "resume-stream" && this.resumableStreamState != null ? this.resumableStreamState : un({
3216
3216
  lastMessage: t === "resume-stream" ? M : t === "regenerate-message" ? void 0 : this.state.snapshot(b),
3217
3217
  messageId: this.generateId()
3218
3218
  }),
@@ -3220,7 +3220,7 @@ var ti = class {
3220
3220
  completionPromise: o
3221
3221
  };
3222
3222
  C = f, f.abortController.signal.addEventListener("abort", () => {
3223
- T = !0;
3223
+ x = !0;
3224
3224
  }), this.activeResponse = f;
3225
3225
  let h;
3226
3226
  t === "resume-stream" ? h = i : h = await this.transport.sendMessages({
@@ -3241,13 +3241,13 @@ var ti = class {
3241
3241
  const B = this.state.messages.findLastIndex((W) => W.id === f.state.message.id);
3242
3242
  if (B !== -1) this.state.replaceMessage(B, f.state.message);
3243
3243
  else if (O) {
3244
- const W = this.state.messages.findLastIndex((j) => j.id === R);
3244
+ const W = this.state.messages.findLastIndex((j) => j.id === P);
3245
3245
  W !== -1 ? this.state.replaceMessage(W, f.state.message) : this.state.pushMessage(f.state.message);
3246
3246
  } else this.state.pushMessage(f.state.message);
3247
3247
  }
3248
3248
  }));
3249
- if (await Ha({
3250
- stream: Ka({
3249
+ if (await Qa({
3250
+ stream: Ga({
3251
3251
  stream: h,
3252
3252
  resetStateOnMessageIdChange: t === "resume-stream",
3253
3253
  resetStateOnFirstMessageStart: t === "resume-stream" && this.transport.resumeStreamIsReplay,
@@ -3264,12 +3264,12 @@ var ti = class {
3264
3264
  onError: (N) => {
3265
3265
  throw N;
3266
3266
  }
3267
- }), T)
3267
+ }), x)
3268
3268
  return y() && (this.setStatus({ status: "ready" }), this.resumableStreamState === f.state && (this.resumableStreamState = void 0)), null;
3269
3269
  y() && (this.setStatus({ status: "ready" }), this.resumableStreamState === f.state && (this.resumableStreamState = void 0));
3270
3270
  } catch (f) {
3271
- if (T || f.name === "AbortError")
3272
- return T = !0, y() && (this.setStatus({ status: "ready" }), this.resumableStreamState === (C == null ? void 0 : C.state) && (this.resumableStreamState = void 0)), null;
3271
+ if (x || f.name === "AbortError")
3272
+ return x = !0, y() && (this.setStatus({ status: "ready" }), this.resumableStreamState === (C == null ? void 0 : C.state) && (this.resumableStreamState = void 0)), null;
3273
3273
  if (!y()) return null;
3274
3274
  if (I = !0, f instanceof TypeError) {
3275
3275
  const h = f.message.toLowerCase();
@@ -3283,10 +3283,10 @@ var ti = class {
3283
3283
  try {
3284
3284
  if (C) {
3285
3285
  const { message: f, finishReason: h } = C.state;
3286
- h === "interrupted" ? this.interruptedMessageIds.add(f.id) : !T && !I && this.interruptedMessageIds.delete(f.id), (m = this.onFinish) == null || m.call(this, {
3286
+ h === "interrupted" ? this.interruptedMessageIds.add(f.id) : !x && !I && this.interruptedMessageIds.delete(f.id), (m = this.onFinish) == null || m.call(this, {
3287
3287
  message: C.state.message,
3288
3288
  messages: this.state.messages,
3289
- isAbort: T,
3289
+ isAbort: x,
3290
3290
  isDisconnect: w,
3291
3291
  isError: I,
3292
3292
  finishReason: C.state.finishReason
@@ -3296,7 +3296,7 @@ var ti = class {
3296
3296
  this.activeResponse === C && (this.activeResponse = void 0), g();
3297
3297
  }
3298
3298
  }
3299
- !T && !I && (C == null ? void 0 : C.state.finishReason) !== "interrupted" && await this.runAutomaticRequest(() => {
3299
+ !x && !I && (C == null ? void 0 : C.state.finishReason) !== "interrupted" && await this.runAutomaticRequest(() => {
3300
3300
  var f;
3301
3301
  return this.makeRequest({
3302
3302
  trigger: "submit-message",
@@ -3307,10 +3307,10 @@ var ti = class {
3307
3307
  });
3308
3308
  });
3309
3309
  }
3310
- }, Lt, dr;
3311
- function ni() {
3312
- if (dr) return Lt;
3313
- dr = 1;
3310
+ }, Lt, pr;
3311
+ function ai() {
3312
+ if (pr) return Lt;
3313
+ pr = 1;
3314
3314
  function t(e, r) {
3315
3315
  if (typeof e != "function")
3316
3316
  throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);
@@ -3325,34 +3325,34 @@ function ni() {
3325
3325
  }
3326
3326
  return Lt = t, Lt;
3327
3327
  }
3328
- var si = /* @__PURE__ */ ni();
3329
- const ai = /* @__PURE__ */ Ta(si);
3330
- function ii(t, e) {
3331
- return e != null ? ai(t, e) : t;
3328
+ var ii = /* @__PURE__ */ ai();
3329
+ const oi = /* @__PURE__ */ _a(ii);
3330
+ function li(t, e) {
3331
+ return e != null ? oi(t, e) : t;
3332
3332
  }
3333
- function oi(t) {
3333
+ function ci(t) {
3334
3334
  return Array.isArray(t) ? [...t] : t != null && typeof t == "object" && (Object.getPrototypeOf(t) === Object.prototype || Object.getPrototypeOf(t) === null) ? { ...t } : t;
3335
3335
  }
3336
- var le, We, Je, Ne, De, Le, _e, Qe, Xe, Ar, li = (Ar = class {
3336
+ var ce, We, Je, De, Le, je, _e, Qe, Xe, xr, ui = (xr = class {
3337
3337
  constructor(t = []) {
3338
- me(this, le);
3339
- me(this, We);
3340
- me(this, Je);
3341
- me(this, Ne);
3342
- me(this, De);
3343
- me(this, Le);
3344
- me(this, _e);
3345
- me(this, Qe);
3346
- me(this, Xe);
3347
- Q(this, We, "ready"), Q(this, Je, void 0), Q(this, Ne, /* @__PURE__ */ new Set()), Q(this, De, /* @__PURE__ */ new Set()), Q(this, Le, /* @__PURE__ */ new Set()), this.pushMessage = (e) => {
3348
- Q(this, le, V(this, le).concat(e)), V(this, _e).call(this);
3338
+ ge(this, ce);
3339
+ ge(this, We);
3340
+ ge(this, Je);
3341
+ ge(this, De);
3342
+ ge(this, Le);
3343
+ ge(this, je);
3344
+ ge(this, _e);
3345
+ ge(this, Qe);
3346
+ ge(this, Xe);
3347
+ Q(this, We, "ready"), Q(this, Je, void 0), Q(this, De, /* @__PURE__ */ new Set()), Q(this, Le, /* @__PURE__ */ new Set()), Q(this, je, /* @__PURE__ */ new Set()), this.pushMessage = (e) => {
3348
+ Q(this, ce, V(this, ce).concat(e)), V(this, _e).call(this);
3349
3349
  }, this.popMessage = () => {
3350
- Q(this, le, V(this, le).slice(0, -1)), V(this, _e).call(this);
3350
+ Q(this, ce, V(this, ce).slice(0, -1)), V(this, _e).call(this);
3351
3351
  }, this.replaceMessage = (e, r) => {
3352
- Q(this, le, [
3353
- ...V(this, le).slice(0, e),
3352
+ Q(this, ce, [
3353
+ ...V(this, ce).slice(0, e),
3354
3354
  this.snapshot(r),
3355
- ...V(this, le).slice(e + 1)
3355
+ ...V(this, ce).slice(e + 1)
3356
3356
  ]), V(this, _e).call(this);
3357
3357
  }, this.snapshot = (e) => {
3358
3358
  if (e == null || typeof e != "object" || !("parts" in e) || !Array.isArray(e.parts)) return e;
@@ -3360,23 +3360,23 @@ var le, We, Je, Ne, De, Le, _e, Qe, Xe, Ar, li = (Ar = class {
3360
3360
  ...r,
3361
3361
  parts: r.parts.map((s) => ({ ...s }))
3362
3362
  };
3363
- return "metadata" in r && (n.metadata = oi(r.metadata)), n;
3363
+ return "metadata" in r && (n.metadata = ci(r.metadata)), n;
3364
3364
  }, this["~registerMessagesCallback"] = (e, r) => {
3365
- const n = r ? ii(e, r) : e;
3366
- return V(this, Ne).add(n), () => {
3367
- V(this, Ne).delete(n);
3365
+ const n = r ? li(e, r) : e;
3366
+ return V(this, De).add(n), () => {
3367
+ V(this, De).delete(n);
3368
3368
  };
3369
- }, this["~registerStatusCallback"] = (e) => (V(this, De).add(e), () => {
3370
- V(this, De).delete(e);
3371
- }), this["~registerErrorCallback"] = (e) => (V(this, Le).add(e), () => {
3369
+ }, this["~registerStatusCallback"] = (e) => (V(this, Le).add(e), () => {
3372
3370
  V(this, Le).delete(e);
3371
+ }), this["~registerErrorCallback"] = (e) => (V(this, je).add(e), () => {
3372
+ V(this, je).delete(e);
3373
3373
  }), Q(this, _e, () => {
3374
- V(this, Ne).forEach((e) => e());
3375
- }), Q(this, Qe, () => {
3376
3374
  V(this, De).forEach((e) => e());
3377
- }), Q(this, Xe, () => {
3375
+ }), Q(this, Qe, () => {
3378
3376
  V(this, Le).forEach((e) => e());
3379
- }), Q(this, le, t);
3377
+ }), Q(this, Xe, () => {
3378
+ V(this, je).forEach((e) => e());
3379
+ }), Q(this, ce, t);
3380
3380
  }
3381
3381
  get status() {
3382
3382
  return V(this, We);
@@ -3391,36 +3391,36 @@ var le, We, Je, Ne, De, Le, _e, Qe, Xe, Ar, li = (Ar = class {
3391
3391
  Q(this, Je, t), V(this, Xe).call(this);
3392
3392
  }
3393
3393
  get messages() {
3394
- return V(this, le);
3394
+ return V(this, ce);
3395
3395
  }
3396
3396
  set messages(t) {
3397
- Q(this, le, [...t]), V(this, _e).call(this);
3397
+ Q(this, ce, [...t]), V(this, _e).call(this);
3398
3398
  }
3399
- }, le = new WeakMap(), We = new WeakMap(), Je = new WeakMap(), Ne = new WeakMap(), De = new WeakMap(), Le = new WeakMap(), _e = new WeakMap(), Qe = new WeakMap(), Xe = new WeakMap(), Ar), je, xr, ci = (xr = class extends ri {
3399
+ }, ce = new WeakMap(), We = new WeakMap(), Je = new WeakMap(), De = new WeakMap(), Le = new WeakMap(), je = new WeakMap(), _e = new WeakMap(), Qe = new WeakMap(), Xe = new WeakMap(), xr), ke, Tr, di = (Tr = class extends si {
3400
3400
  constructor({ messages: e, ...r }) {
3401
- const n = new li(e);
3401
+ const n = new ui(e);
3402
3402
  super({
3403
3403
  ...r,
3404
3404
  state: n
3405
3405
  });
3406
- me(this, je);
3407
- this["~registerMessagesCallback"] = (s, o) => V(this, je)["~registerMessagesCallback"](s, o), this["~registerStatusCallback"] = (s) => V(this, je)["~registerStatusCallback"](s), this["~registerErrorCallback"] = (s) => V(this, je)["~registerErrorCallback"](s), Q(this, je, n);
3406
+ ge(this, ke);
3407
+ this["~registerMessagesCallback"] = (s, o) => V(this, ke)["~registerMessagesCallback"](s, o), this["~registerStatusCallback"] = (s) => V(this, ke)["~registerStatusCallback"](s), this["~registerErrorCallback"] = (s) => V(this, ke)["~registerErrorCallback"](s), Q(this, ke, n);
3408
3408
  }
3409
- }, je = new WeakMap(), xr);
3409
+ }, ke = new WeakMap(), Tr);
3410
3410
  const dt = /* @__PURE__ */ new WeakMap();
3411
- function ui({ chat: t, state: e }) {
3411
+ function pi({ chat: t, state: e }) {
3412
3412
  if (document.visibilityState !== "visible" || e.pendingVisibilityResume != null) return;
3413
3413
  const r = () => dt.get(t) === e && e.registrations.size > 0, n = () => {
3414
3414
  e.pendingVisibilityResume = void 0;
3415
3415
  };
3416
3416
  e.pendingVisibilityResume = t["~resumeStreamIfDisconnected"]({ shouldResume: () => r() && document.visibilityState === "visible" }).then(n, n);
3417
3417
  }
3418
- function di({ chat: t, registration: e }) {
3418
+ function fi({ chat: t, registration: e }) {
3419
3419
  let r = dt.get(t);
3420
3420
  if (r == null) {
3421
3421
  const o = { registrations: /* @__PURE__ */ new Set() };
3422
3422
  if (dt.set(t, o), r = o, typeof document < "u") {
3423
- const l = () => ui({
3423
+ const l = () => pi({
3424
3424
  chat: t,
3425
3425
  state: o
3426
3426
  });
@@ -3443,11 +3443,11 @@ function ct(t) {
3443
3443
  error: t.error
3444
3444
  };
3445
3445
  }
3446
- function pr(t, e) {
3446
+ function fr(t, e) {
3447
3447
  return t.chat === e.chat && t.messages === e.messages && t.status === e.status && t.error === e.error;
3448
3448
  }
3449
- function pi({ throttle: t, experimental_throttle: e, resume: r = !1, ...n } = {}) {
3450
- const s = t ?? e, o = P({}), l = P({});
3449
+ function mi({ throttle: t, experimental_throttle: e, resume: r = !1, ...n } = {}) {
3450
+ const s = t ?? e, o = R({}), l = R({});
3451
3451
  "chat" in n || (l.current = {
3452
3452
  onToolCall: n.onToolCall,
3453
3453
  onData: n.onData,
@@ -3487,7 +3487,7 @@ function pi({ throttle: t, experimental_throttle: e, resume: r = !1, ...n } = {}
3487
3487
  return ((c = (C = l.current).sendAutomaticallyWhen) == null ? void 0 : c.call(C, I)) ?? !1;
3488
3488
  }
3489
3489
  }, i = "chat" in n ? n.chat : n.id, { chat: d, isExternallyManaged: p } = X(() => ({
3490
- chat: "chat" in n ? n.chat : new ci(g),
3490
+ chat: "chat" in n ? n.chat : new di(g),
3491
3491
  isExternallyManaged: "chat" in n
3492
3492
  }), [i]);
3493
3493
  F(() => {
@@ -3496,27 +3496,27 @@ function pi({ throttle: t, experimental_throttle: e, resume: r = !1, ...n } = {}
3496
3496
  d.stop();
3497
3497
  };
3498
3498
  }, [d, p]);
3499
- const [b, R] = J(() => ct(d));
3500
- b.chat !== d && R(ct(d)), F(() => {
3499
+ const [b, P] = J(() => ct(d));
3500
+ b.chat !== d && P(ct(d)), F(() => {
3501
3501
  let I = !0;
3502
3502
  const C = () => {
3503
3503
  if (!I) return;
3504
3504
  const f = ct(d);
3505
- R((h) => h.chat !== d || pr(h, f) ? h : f);
3505
+ P((h) => h.chat !== d || fr(h, f) ? h : f);
3506
3506
  }, c = [
3507
3507
  d["~registerMessagesCallback"](C, s),
3508
3508
  d["~registerStatusCallback"](C),
3509
3509
  d["~registerErrorCallback"](C)
3510
3510
  ], m = ct(d);
3511
- return R((f) => pr(f, m) ? f : m), () => {
3511
+ return P((f) => fr(f, m) ? f : m), () => {
3512
3512
  I = !1, c.forEach((f) => f());
3513
3513
  };
3514
3514
  }, [d, s]);
3515
- const { messages: M, status: O, error: T } = b, w = Z((I) => {
3515
+ const { messages: M, status: O, error: x } = b, w = z((I) => {
3516
3516
  typeof I == "function" && (I = I(d.messages)), d.messages = I;
3517
3517
  }, [d]);
3518
3518
  return F(() => {
3519
- if (r) return di({
3519
+ if (r) return fi({
3520
3520
  chat: d,
3521
3521
  registration: o.current
3522
3522
  });
@@ -3530,7 +3530,7 @@ function pi({ throttle: t, experimental_throttle: e, resume: r = !1, ...n } = {}
3530
3530
  regenerate: d.regenerate,
3531
3531
  clearError: d.clearError,
3532
3532
  stop: d.stop,
3533
- error: T,
3533
+ error: x,
3534
3534
  resumeStream: d.resumeStream,
3535
3535
  status: O,
3536
3536
  /**
@@ -3541,7 +3541,7 @@ function pi({ throttle: t, experimental_throttle: e, resume: r = !1, ...n } = {}
3541
3541
  addToolApprovalResponse: d.addToolApprovalResponse
3542
3542
  };
3543
3543
  }
3544
- class fr {
3544
+ class mr {
3545
3545
  constructor(e) {
3546
3546
  this.buffer = [], this.cap = Math.max(1, Math.floor(e));
3547
3547
  }
@@ -3574,7 +3574,7 @@ class fr {
3574
3574
  return n ?? null;
3575
3575
  }
3576
3576
  }
3577
- function mr(t, e) {
3577
+ function gr(t, e) {
3578
3578
  const r = t.flatMap((n) => {
3579
3579
  if (n.kind === "text" && n.streaming && (e == null ? void 0 : e.streaming) === !1)
3580
3580
  return [];
@@ -3586,30 +3586,30 @@ function mr(t, e) {
3586
3586
  });
3587
3587
  return r.length === t.length && r.every((n, s) => n === t[s]) ? t : r;
3588
3588
  }
3589
- const fi = L.union([
3589
+ const gi = L.union([
3590
3590
  L.string(),
3591
3591
  L.looseObject({ id: L.string().optional(), label: L.string() })
3592
- ]), mi = L.looseObject({
3592
+ ]), hi = L.looseObject({
3593
3593
  id: L.string().optional(),
3594
3594
  prompt: L.string(),
3595
3595
  selection: L.enum(["single", "multiple"]).default("single"),
3596
- options: L.array(fi).min(1)
3597
- }), gi = L.looseObject({
3596
+ options: L.array(gi).min(1)
3597
+ }), yi = L.looseObject({
3598
3598
  request_id: L.string().optional(),
3599
- questions: L.array(mi).min(1)
3599
+ questions: L.array(hi).min(1)
3600
3600
  });
3601
- function hi(t) {
3601
+ function vi(t) {
3602
3602
  return !!(t != null && t.includes("ask_questions"));
3603
3603
  }
3604
- const yi = [
3604
+ const bi = [
3605
3605
  /\bi[’'ʼ‘]?ll\s+(type|describe|enter|write|tell)\b/i,
3606
3606
  /\b(type|describe|enter|write|tell)\s+(it|my\s+own|manually)\b/i,
3607
3607
  /^\s*(other|custom|none\s+of\s+the\s+above|something\s+else)\s*\.?\s*$/i
3608
3608
  ];
3609
- function vi(t) {
3610
- return yi.some((e) => e.test(t));
3609
+ function Si(t) {
3610
+ return bi.some((e) => e.test(t));
3611
3611
  }
3612
- function bi(t, e) {
3612
+ function Ii(t, e) {
3613
3613
  return {
3614
3614
  request_id: t.request_id ?? e ?? "req-clarification",
3615
3615
  questions: t.questions.map((r, n) => ({
@@ -3621,7 +3621,7 @@ function bi(t, e) {
3621
3621
  id: s.id ?? `q${n}-o${o}`,
3622
3622
  label: s.label
3623
3623
  }
3624
- ).filter((s) => !vi(s.label))
3624
+ ).filter((s) => !Si(s.label))
3625
3625
  }))
3626
3626
  };
3627
3627
  }
@@ -3632,7 +3632,7 @@ function jt(t) {
3632
3632
  return null;
3633
3633
  }
3634
3634
  }
3635
- function Si(t) {
3635
+ function Ei(t) {
3636
3636
  if (t == null) return null;
3637
3637
  if (typeof t == "string") return jt(t);
3638
3638
  if (Array.isArray(t)) {
@@ -3652,13 +3652,13 @@ function Si(t) {
3652
3652
  }
3653
3653
  return null;
3654
3654
  }
3655
- function gr(t, e) {
3656
- const r = Si(t);
3655
+ function hr(t, e) {
3656
+ const r = Ei(t);
3657
3657
  if (r == null) return null;
3658
- const n = gi.safeParse(r);
3659
- return n.success ? bi(n.data, e) : null;
3658
+ const n = yi.safeParse(r);
3659
+ return n.success ? Ii(n.data, e) : null;
3660
3660
  }
3661
- function wo(t, e) {
3661
+ function xo(t, e) {
3662
3662
  const r = [];
3663
3663
  for (const n of t.questions) {
3664
3664
  const s = e.get(n.id);
@@ -3669,13 +3669,13 @@ A: ${s.trim()}`);
3669
3669
 
3670
3670
  `);
3671
3671
  }
3672
- const Ii = L.object({
3672
+ const Ci = L.object({
3673
3673
  request_id: L.string().uuid(),
3674
3674
  server_id: L.string().uuid(),
3675
3675
  name: L.string().min(1).max(120)
3676
- }), Ei = L.object({
3677
- connection_required: Ii
3678
- }), hr = "data-spec", Ci = L.object({ label: L.string(), done: L.boolean() }), wi = L.object({
3676
+ }), wi = L.object({
3677
+ connection_required: Ci
3678
+ }), yr = "data-spec", Ai = L.object({ label: L.string(), done: L.boolean() }), xi = L.object({
3679
3679
  plan: L.array(
3680
3680
  L.object({
3681
3681
  step: L.string(),
@@ -3690,9 +3690,9 @@ function pt(t) {
3690
3690
  }, n = (l) => l === "output-available" || l === "output-error";
3691
3691
  let s = null, o;
3692
3692
  for (const l of t)
3693
- if (!jn(l) && un(l) !== "highlight_element") {
3693
+ if (!$n(l) && dn(l) !== "highlight_element") {
3694
3694
  if (l.state === "output-available" && (l.type === "dynamic-tool" || l.type.startsWith("tool-"))) {
3695
- const u = Ei.safeParse(l.output);
3695
+ const u = wi.safeParse(l.output);
3696
3696
  if (u.success) {
3697
3697
  e.push({
3698
3698
  kind: "connection",
@@ -3701,23 +3701,23 @@ function pt(t) {
3701
3701
  continue;
3702
3702
  }
3703
3703
  }
3704
- if (Ai(l)) {
3705
- const u = xi(l);
3704
+ if (Ti(l)) {
3705
+ const u = Mi(l);
3706
3706
  u && e.push(u);
3707
3707
  continue;
3708
3708
  }
3709
3709
  if (l.type === "data-plan") {
3710
- const u = wi.safeParse(l.data);
3710
+ const u = xi.safeParse(l.data);
3711
3711
  u.success && (o ? o.plan = u.data.plan : (o = { kind: "plan", plan: u.data.plan }, e.push(o)));
3712
3712
  } else if (l.type === "data-tool-activity") {
3713
- const u = Ci.safeParse(l.data);
3713
+ const u = Ai.safeParse(l.data);
3714
3714
  u.success && r({
3715
3715
  kind: "tool",
3716
3716
  label: u.data.label,
3717
3717
  done: u.data.done
3718
3718
  });
3719
- } else if (l.type === hr)
3720
- s || (s = { kind: "spec", parts: [] }, e.push(s)), s.parts.push({ type: hr, data: l.data });
3719
+ } else if (l.type === yr)
3720
+ s || (s = { kind: "spec", parts: [] }, e.push(s)), s.parts.push({ type: yr, data: l.data });
3721
3721
  else if (l.type === "text") {
3722
3722
  const u = typeof l.text == "string" ? l.text : "";
3723
3723
  u.trim().length > 0 && e.push({
@@ -3733,46 +3733,46 @@ function pt(t) {
3733
3733
  kind: "tool",
3734
3734
  label: typeof l.toolName == "string" ? l.toolName : "tool",
3735
3735
  done: n(l.state),
3736
- ...yr(l)
3736
+ ...vr(l)
3737
3737
  }) : l.type.startsWith("tool-") && r({
3738
3738
  kind: "tool",
3739
3739
  label: l.type.slice(5),
3740
3740
  done: n(l.state),
3741
- ...yr(l)
3741
+ ...vr(l)
3742
3742
  });
3743
3743
  }
3744
3744
  return e;
3745
3745
  }
3746
- function un(t) {
3746
+ function dn(t) {
3747
3747
  return t.type === "dynamic-tool" ? typeof t.toolName == "string" ? t.toolName : void 0 : t.type.startsWith("tool-") ? t.type.slice(5) : void 0;
3748
3748
  }
3749
- function Ai(t) {
3750
- return hi(un(t));
3749
+ function Ti(t) {
3750
+ return vi(dn(t));
3751
3751
  }
3752
- function xi(t) {
3753
- const e = typeof t.toolCallId == "string" ? t.toolCallId : void 0, r = gr(t.output, e) ?? gr(t.input, e);
3752
+ function Mi(t) {
3753
+ const e = typeof t.toolCallId == "string" ? t.toolCallId : void 0, r = hr(t.output, e) ?? hr(t.input, e);
3754
3754
  return r ? { kind: "questions", request: r } : null;
3755
3755
  }
3756
- function yr(t) {
3756
+ function vr(t) {
3757
3757
  return {
3758
3758
  ...t.input === void 0 ? {} : { input: t.input },
3759
3759
  ...t.output === void 0 ? {} : { output: t.output }
3760
3760
  };
3761
3761
  }
3762
- function Ti(t, e) {
3762
+ function _i(t, e) {
3763
3763
  const r = [];
3764
3764
  return e != null && e.toolActivity && r.push(
3765
3765
  `toolActivity=${encodeURIComponent(e.toolActivity)}`
3766
3766
  ), (e == null ? void 0 : e.reasoning) !== void 0 && r.push(`reasoning=${String(e.reasoning)}`), r.length === 0 ? t : `${t}${t.includes("?") ? "&" : "?"}${r.join("&")}`;
3767
3767
  }
3768
- function vr(t) {
3768
+ function br(t) {
3769
3769
  return ({ id: e }) => ({
3770
3770
  api: t.reconnectApi(e),
3771
3771
  headers: t.headers()
3772
3772
  });
3773
3773
  }
3774
- const Mi = [0, 500, 1500];
3775
- function _i(t, e) {
3774
+ const Ri = [0, 500, 1500];
3775
+ function Pi(t, e) {
3776
3776
  return new Promise((r) => {
3777
3777
  if (t === 0 || e != null && e.aborted) {
3778
3778
  r();
@@ -3784,10 +3784,10 @@ function _i(t, e) {
3784
3784
  e == null || e.addEventListener("abort", n);
3785
3785
  });
3786
3786
  }
3787
- function Pi(t) {
3787
+ function Oi(t) {
3788
3788
  return t && "session_id" in t && typeof t.session_id == "string" ? t.session_id : void 0;
3789
3789
  }
3790
- class Ri extends yt {
3790
+ class Ni extends yt {
3791
3791
  constructor(e) {
3792
3792
  super({
3793
3793
  api: e.api,
@@ -3796,14 +3796,14 @@ class Ri extends yt {
3796
3796
  // Every send carries its full body; a send without one is a programming
3797
3797
  // error, and an empty body would be rejected server-side just as loudly.
3798
3798
  prepareSendMessagesRequest: ({ body: r }) => ({ body: r ?? {} }),
3799
- prepareReconnectToStreamRequest: vr(e)
3799
+ prepareReconnectToStreamRequest: br(e)
3800
3800
  }), this.agentOptions = e;
3801
3801
  }
3802
3802
  async sendMessages(e) {
3803
3803
  try {
3804
3804
  return await super.sendMessages(e);
3805
3805
  } catch (r) {
3806
- const n = Pi(e.body);
3806
+ const n = Oi(e.body);
3807
3807
  if (n === void 0) throw r;
3808
3808
  return this.readThroughRecoveryFetch(r, "send", {
3809
3809
  chatId: n,
@@ -3830,17 +3830,17 @@ class Ri extends yt {
3830
3830
  api: this.agentOptions.api,
3831
3831
  headers: () => this.agentOptions.headers(),
3832
3832
  fetch: s,
3833
- prepareReconnectToStreamRequest: vr(
3833
+ prepareReconnectToStreamRequest: br(
3834
3834
  this.agentOptions
3835
3835
  )
3836
3836
  });
3837
- for (const d of Mi) {
3838
- if (await _i(d, n.abortSignal), (y = n.abortSignal) != null && y.aborted) throw e;
3837
+ for (const d of Ri) {
3838
+ if (await Pi(d, n.abortSignal), (y = n.abortSignal) != null && y.aborted) throw e;
3839
3839
  let p;
3840
3840
  try {
3841
3841
  p = await o.reconnectToStream(n);
3842
3842
  } catch (b) {
3843
- throw oe.warn("agent chat recovery read failed", b), e;
3843
+ throw le.warn("agent chat recovery read failed", b), e;
3844
3844
  }
3845
3845
  if (p)
3846
3846
  return (i = (g = this.agentOptions).onRecovered) == null || i.call(g, r, e), p;
@@ -3848,10 +3848,10 @@ class Ri extends yt {
3848
3848
  throw e;
3849
3849
  }
3850
3850
  }
3851
- function Oi(t) {
3852
- return new Ri(t);
3851
+ function Di(t) {
3852
+ return new Ni(t);
3853
3853
  }
3854
- function Ni({
3854
+ function Li({
3855
3855
  existing: t,
3856
3856
  fetched: e,
3857
3857
  refreshItems: r = !1
@@ -3863,7 +3863,7 @@ function Ni({
3863
3863
  if (s.add(u.turn_id), u.message_uuids.length === 0) continue;
3864
3864
  const y = n.get(u.turn_id);
3865
3865
  if (y && !r) {
3866
- Di(y.rowIds, u.message_uuids) ? o.push(y) : o.push({ ...y, rowIds: u.message_uuids });
3866
+ ji(y.rowIds, u.message_uuids) ? o.push(y) : o.push({ ...y, rowIds: u.message_uuids });
3867
3867
  continue;
3868
3868
  }
3869
3869
  if (u.ui_parts !== null) {
@@ -3881,16 +3881,16 @@ function Ni({
3881
3881
  s.has(u.turnId) || o.push(u);
3882
3882
  return o.length === t.length && o.every((u, y) => u === t[y]) ? t : o;
3883
3883
  }
3884
- const Di = (t, e) => t.length === e.length && t.every((r, n) => r === e[n]), Li = (t) => Array.isArray(t) && t.every((e) => typeof e == "string");
3885
- function br(t) {
3884
+ const ji = (t, e) => t.length === e.length && t.every((r, n) => r === e[n]), ki = (t) => Array.isArray(t) && t.every((e) => typeof e == "string");
3885
+ function Sr(t) {
3886
3886
  for (const e of t) {
3887
3887
  if (e.type !== "data-turn-settled") continue;
3888
3888
  const r = e.data;
3889
- return !Tr(r) || typeof r.turn_id != "string" || !Li(r.message_uuids) ? null : { turnId: r.turn_id, rowIds: r.message_uuids };
3889
+ return !Mr(r) || typeof r.turn_id != "string" || !ki(r.message_uuids) ? null : { turnId: r.turn_id, rowIds: r.message_uuids };
3890
3890
  }
3891
3891
  return null;
3892
3892
  }
3893
- function ji(t) {
3893
+ function $i(t) {
3894
3894
  if (typeof document > "u" || typeof window > "u" || typeof window.addEventListener != "function")
3895
3895
  return () => {
3896
3896
  };
@@ -3901,7 +3901,7 @@ function ji(t) {
3901
3901
  document.removeEventListener("visibilitychange", e), window.removeEventListener("online", e);
3902
3902
  };
3903
3903
  }
3904
- async function ki({
3904
+ async function Fi({
3905
3905
  api: t,
3906
3906
  sessionId: e,
3907
3907
  chatStop: r
@@ -3912,12 +3912,12 @@ async function ki({
3912
3912
  e && await t.stopStream(e);
3913
3913
  }
3914
3914
  }
3915
- const $i = /^[A-Za-z0-9_$.]{1,100}$/;
3916
- function Sr(t) {
3917
- const e = $i.test(t.name) ? t.name : "Error";
3915
+ const Ui = /^[A-Za-z0-9_$.]{1,100}$/;
3916
+ function Ir(t) {
3917
+ const e = Ui.test(t.name) ? t.name : "Error";
3918
3918
  if (ft.isInstance(t))
3919
3919
  return { kind: "empty_body", error_name: e };
3920
- if (Dr.isInstance(t)) {
3920
+ if (Lr.isInstance(t)) {
3921
3921
  const r = t.statusCode;
3922
3922
  return r !== void 0 && r >= 100 && r <= 599 ? { kind: "http_error", error_name: e, http_status: r } : { kind: "http_error", error_name: e };
3923
3923
  }
@@ -3928,26 +3928,26 @@ function Sr(t) {
3928
3928
  }
3929
3929
  return { kind: "other", error_name: e };
3930
3930
  }
3931
- const Ir = 20, Fi = [1e3, 3e3, 8e3], Ui = "highlight_element", qi = "act_on_page";
3932
- function zi({
3931
+ const Er = 20, qi = [1e3, 3e3, 8e3], zi = "highlight_element", Zi = "act_on_page";
3932
+ function Vi({
3933
3933
  widgetCtx: t,
3934
3934
  config: e,
3935
3935
  sessionId: r,
3936
3936
  persistedMessages: n
3937
3937
  }) {
3938
3938
  var Qt, Xt;
3939
- const { api: s, messageCtx: o } = t, l = P(e);
3939
+ const { api: s, messageCtx: o } = t, l = R(e);
3940
3940
  l.current = e;
3941
3941
  const {
3942
3942
  pageContext: u,
3943
3943
  clientTools: y,
3944
3944
  pageActions: g
3945
- } = t.features, i = P(() => {
3945
+ } = t.features, i = R(() => {
3946
3946
  }), d = X(
3947
- () => Oi({
3947
+ () => Di({
3948
3948
  ...s.getStreamTransportOptions(),
3949
3949
  headers: () => s.getStreamTransportOptions().headers,
3950
- reconnectApi: (v) => Ti(
3950
+ reconnectApi: (v) => _i(
3951
3951
  s.getStreamTransportOptions().reconnectApi(v),
3952
3952
  l.current.presentation
3953
3953
  ),
@@ -3960,15 +3960,15 @@ function zi({
3960
3960
  // fetch already failed, so there is nothing else to try.
3961
3961
  recoveryFetch: () => {
3962
3962
  const v = l.current.streamingFetch;
3963
- return v && v !== globalThis.fetch ? (E, x) => globalThis.fetch(E, x) : void 0;
3963
+ return v && v !== globalThis.fetch ? (E, T) => globalThis.fetch(E, T) : void 0;
3964
3964
  },
3965
3965
  onRecovered: (v, E) => i.current(v, E)
3966
3966
  }),
3967
3967
  [s]
3968
- ), [p, b] = J(null), R = P(!1), [M] = J(Pt), O = P(Promise.resolve()), T = P(0), w = P(0), I = P(r), C = X(
3969
- () => r !== null && !(I.current === null && T.current > 0),
3968
+ ), [p, b] = J(null), P = R(!1), [M] = J(Rt), O = R(Promise.resolve()), x = R(0), w = R(0), I = R(r), C = X(
3969
+ () => r !== null && !(I.current === null && x.current > 0),
3970
3970
  [r]
3971
- ), c = P(() => {
3971
+ ), c = R(() => {
3972
3972
  }), {
3973
3973
  status: m,
3974
3974
  messages: f,
@@ -3977,7 +3977,7 @@ function zi({
3977
3977
  error: N,
3978
3978
  clearError: D,
3979
3979
  resumeStream: B
3980
- } = pi({
3980
+ } = mi({
3981
3981
  id: r ?? M,
3982
3982
  resume: C,
3983
3983
  transport: d,
@@ -3987,64 +3987,63 @@ function zi({
3987
3987
  throttle: 50,
3988
3988
  onError: (v) => c.current(v),
3989
3989
  onFinish: b
3990
- }), W = P(f);
3990
+ }), W = R(f);
3991
3991
  W.current = f;
3992
- const j = P(new fr(Ir));
3992
+ const j = R(new mr(Er));
3993
3993
  F(() => {
3994
3994
  if (!p || p.messages !== f) return;
3995
- const { isAbort: v, isDisconnect: E, isError: x, message: A } = p;
3996
- v || E || x || j.current.size > 0 || o.state.setPartial({
3997
- lastAIResMightSolveUserIssue: Tr(A.metadata) && A.metadata.mightSolveUserIssue === !0
3995
+ const { isAbort: v, isDisconnect: E, isError: T, message: A } = p;
3996
+ v || E || T || j.current.size > 0 || o.state.setPartial({
3997
+ lastAIResMightSolveUserIssue: Mr(A.metadata) && A.metadata.mightSolveUserIssue === !0
3998
3998
  });
3999
3999
  }, [p, f, o]);
4000
- const k = P("idle"), [ve, be] = J(!1), [ye, se] = J(0), [G, ue] = J(!1), pe = P(G);
4001
- pe.current = G;
4002
- const [Ie, U] = J([]), [ae, Ee] = J([]), [fe, En] = J(null), Ke = P(null), Pe = Z((v) => {
4003
- Ke.current = v, En(v);
4004
- }, []), Fe = P(null), Ce = P(null), Ue = P(
4005
- null
4006
- ), Wt = P(r);
4000
+ const $ = R("idle"), [Se, Ie] = J(!1), [ve, ae] = J(0), [G, de] = J(!1), fe = R(G);
4001
+ fe.current = G;
4002
+ const [Ee, U] = J([]), [ie, Ce] = J([]), [me, Cn] = J(null), Ke = R(null), Re = z((v) => {
4003
+ Ke.current = v, Cn(v);
4004
+ }, []), Ue = R(null), we = R(null), Ae = R(null), Wt = R(r);
4007
4005
  Wt.current = r;
4008
- const Jt = (v, E, x) => {
4006
+ const Jt = (v, E, T) => {
4009
4007
  const A = Wt.current;
4010
4008
  A && s.reportClientStreamError(A, {
4011
- ...Sr(v),
4009
+ ...Ir(v),
4012
4010
  phase: E,
4013
- recovered: x,
4014
- widget_version: _r,
4011
+ recovered: T,
4012
+ widget_version: Rr,
4015
4013
  platform: typeof navigator < "u" && navigator.product === "ReactNative" ? "react-native" : "web"
4016
4014
  });
4017
4015
  };
4018
4016
  c.current = (v) => {
4019
- oe.error("agent chat stream error", v), Sr(v).kind === "empty_body" && oe.error(
4017
+ le.error("agent chat stream error", v), Ir(v).kind === "empty_body" && le.error(
4020
4018
  "the streaming response has no readable body. In React Native, pass `streamingFetch` from `expo/fetch` and return its response unchanged: React Native's global Response cannot stream."
4021
4019
  );
4022
- const E = k.current === "in-flight" ? "send" : "resume", x = Ce.current;
4023
- E === "send" && x && (Ue.current = {
4024
- wireId: x.retryUuid ?? x.userMessage.id,
4025
- bubbleId: x.userMessage.id
4026
- }), Jt(v, E, !1);
4020
+ const E = $.current === "in-flight" ? "send" : "resume", T = we.current;
4021
+ E === "send" && T ? Ae.current = {
4022
+ kind: "send",
4023
+ wireId: T.retryUuid ?? T.userMessage.id,
4024
+ bubbleId: T.userMessage.id
4025
+ } : E === "resume" && Ae.current === null && (Ae.current = { kind: "resume" }), Jt(v, E, !1);
4027
4026
  };
4028
- const Yt = P(!1);
4027
+ const Yt = R(!1);
4029
4028
  i.current = (v, E) => {
4030
- Yt.current || (Yt.current = !0, oe.warn(
4029
+ Yt.current || (Yt.current = !0, le.warn(
4031
4030
  "the `streamingFetch` response has no readable body, so replies are read through the global fetch instead. Return the `expo/fetch` response unchanged to stream it directly."
4032
4031
  )), Jt(E, v, !0);
4033
4032
  };
4034
- const qe = P(m), He = I.current === r, Et = P(null), Ct = P(null), Kt = P(S), we = P(m);
4035
- we.current = m;
4036
- const tt = Z((v, E) => {
4037
- const x = br(v.parts);
4038
- if (!x || x.rowIds.length === 0) return;
4033
+ const qe = R(m), He = I.current === r, Et = R(null), Ct = R(null), Kt = R(S), xe = R(m);
4034
+ xe.current = m;
4035
+ const tt = z((v, E) => {
4036
+ const T = Sr(v.parts);
4037
+ if (!T || T.rowIds.length === 0) return;
4039
4038
  const A = pt(v.parts);
4040
4039
  A.length !== 0 && U(
4041
- ($) => $.some((Y) => Y.turnId === x.turnId) ? $ : [
4042
- ...$,
4043
- { key: E, turnId: x.turnId, rowIds: x.rowIds, items: A }
4040
+ (k) => k.some((K) => K.turnId === T.turnId) ? k : [
4041
+ ...k,
4042
+ { key: E, turnId: T.turnId, rowIds: T.rowIds, items: A }
4044
4043
  ]
4045
4044
  );
4046
- }, []), Ht = Z(
4047
- (v) => kn({
4045
+ }, []), Ht = z(
4046
+ (v) => Fn({
4048
4047
  config: l.current,
4049
4048
  input: v.input,
4050
4049
  uuid: v.retryUuid ?? v.userMessage.id,
@@ -4064,12 +4063,12 @@ function zi({
4064
4063
  U([]);
4065
4064
  return;
4066
4065
  }
4067
- const x = we.current === "submitted" || we.current === "streaming" || qe.current === "submitted" || qe.current === "streaming" || k.current === "in-flight";
4068
- w.current += 1, T.current = 0, O.current = Promise.resolve(), j.current = new fr(Ir), k.current = "idle", be(!1), Ce.current = null, Ue.current = null, Fe.current = null, b(null), R.current = !1, Ct.current = null, Et.current = m === "submitted" || m === "streaming" ? m : null, qe.current = "ready", we.current = "ready", D(), se((A) => A + 1), ue(!1), U([]), Pe(null), x && Promise.resolve().then(() => v()).catch((A) => {
4069
- oe.error("agent chat client stream cancel failed", A);
4066
+ const T = xe.current === "submitted" || xe.current === "streaming" || qe.current === "submitted" || qe.current === "streaming" || $.current === "in-flight";
4067
+ w.current += 1, x.current = 0, O.current = Promise.resolve(), j.current = new mr(Er), $.current = "idle", Ie(!1), we.current = null, Ae.current = null, Ue.current = null, b(null), P.current = !1, Ct.current = null, Et.current = m === "submitted" || m === "streaming" ? m : null, qe.current = "ready", xe.current = "ready", D(), ae((A) => A + 1), de(!1), U([]), Re(null), T && Promise.resolve().then(() => v()).catch((A) => {
4068
+ le.error("agent chat client stream cancel failed", A);
4070
4069
  });
4071
- }, [r, m, S, D, Pe]), F(() => {
4072
- var $, Y;
4070
+ }, [r, m, S, D, Re]), F(() => {
4071
+ var k, K;
4073
4072
  const v = Et.current;
4074
4073
  if (v !== null && m === v) {
4075
4074
  qe.current = "ready";
@@ -4077,66 +4076,66 @@ function zi({
4077
4076
  }
4078
4077
  Et.current = null;
4079
4078
  const E = qe.current;
4080
- if (qe.current = m, (m === "submitted" || m === "streaming") && (E !== "submitted" && E !== "streaming" && Ke.current === null && Pe(`turn-resumed-${Pt()}`), ue(!0)), m === "streaming") {
4081
- const z = ($ = Ce.current) == null ? void 0 : $.userMessage.id;
4082
- z && o.markUserMessageDelivered(z);
4079
+ if (qe.current = m, (m === "submitted" || m === "streaming") && (E !== "submitted" && E !== "streaming" && Ke.current === null && Re(`turn-resumed-${Rt()}`), de(!0)), m === "streaming") {
4080
+ const Z = (k = we.current) == null ? void 0 : k.userMessage.id;
4081
+ Z && o.markUserMessageDelivered(Z);
4083
4082
  return;
4084
4083
  }
4085
4084
  if (m !== "ready" && m !== "error") return;
4086
4085
  if (E === "streaming" || E === "submitted" || // An empty response can finish before React observes an active status.
4087
- k.current === "in-flight" && (p == null ? void 0 : p.messages) === W.current) {
4088
- ue(!0);
4089
- const z = k.current === "in-flight";
4090
- z && (k.current = "idle");
4091
- const Se = W.current.at(-1), xe = Ke.current;
4092
- if (Fe.current = xe, xe !== null && Se && Se.role === "assistant" && tt(Se, xe), m === "ready") {
4093
- const Te = (Y = Ce.current) == null ? void 0 : Y.userMessage.id;
4094
- Te && o.markUserMessageDelivered(Te);
4095
- } else z && E !== "streaming" && Ce.current && o.releaseUnsentOptionPick(Ce.current.input);
4096
- k.current === "stopping" || (r ? (k.current = "reconciling", t.reconcileAfterStream(r).catch((Te) => {
4097
- oe.error("agent chat post-turn reconcile failed", Te);
4086
+ $.current === "in-flight" && (p == null ? void 0 : p.messages) === W.current) {
4087
+ de(!0);
4088
+ const Z = $.current === "in-flight";
4089
+ Z && ($.current = "idle");
4090
+ const re = W.current.at(-1), be = Ke.current;
4091
+ if (Ue.current = be, be !== null && re && re.role === "assistant" && tt(re, be), m === "ready") {
4092
+ const Pe = (K = we.current) == null ? void 0 : K.userMessage.id;
4093
+ Pe && o.markUserMessageDelivered(Pe);
4094
+ } else Z && E !== "streaming" && we.current && o.releaseUnsentOptionPick(we.current.input);
4095
+ $.current === "stopping" || (r ? ($.current = "reconciling", t.reconcileAfterStream(r).catch((Pe) => {
4096
+ le.error("agent chat post-turn reconcile failed", Pe);
4098
4097
  }).finally(() => {
4099
- k.current === "reconciling" && (k.current = "idle"), se((Te) => Te + 1);
4100
- })) : ue(!1));
4098
+ $.current === "reconciling" && ($.current = "idle"), ae((Pe) => Pe + 1);
4099
+ })) : de(!1));
4101
4100
  }
4102
- if (k.current !== "idle" || !r || pe.current && m !== "error") return;
4101
+ if ($.current !== "idle" || !r || fe.current && m !== "error") return;
4103
4102
  const A = j.current.dequeueNext();
4104
- A && (k.current = "in-flight", be(!1), Ce.current = A, Ue.current = null, b(null), R.current = !1, Pe(`turn-${A.userMessage.id}`), o.appendUserMessageIfAbsent(A.userMessage), se((z) => z + 1), h(
4103
+ A && ($.current = "in-flight", Ie(!1), we.current = A, Ae.current = null, b(null), P.current = !1, Re(`turn-${A.userMessage.id}`), o.appendUserMessageIfAbsent(A.userMessage), ae((Z) => Z + 1), h(
4105
4104
  { text: A.userMessage.content },
4106
4105
  { body: Ht(A) }
4107
4106
  ));
4108
4107
  }, [
4109
4108
  m,
4110
4109
  r,
4111
- ye,
4110
+ ve,
4112
4111
  h,
4113
4112
  o,
4114
4113
  t,
4115
4114
  Ht,
4116
4115
  tt,
4117
- Pe,
4116
+ Re,
4118
4117
  p
4119
4118
  ]);
4120
- const Gt = Z(
4119
+ const Gt = z(
4121
4120
  (v) => {
4122
4121
  const E = w.current;
4123
- T.current++;
4122
+ x.current++;
4124
4123
  const A = O.current.then(
4125
4124
  async () => {
4126
4125
  if (E !== w.current) return;
4127
- const $ = k.current, z = we.current === "submitted" || we.current === "streaming" || $ !== "idle" || pe.current || j.current.size > 0 ? Zi(o.buildQueuedUserMessage(v)) : await o.stageUserTurn(v, { pending: !0 });
4128
- if (!z || E !== w.current) return;
4129
- const Se = { ...z, input: v };
4130
- if (!j.current.enqueue(Se)) {
4131
- oe.warn("agent chat queue full; rejecting newest send", {
4132
- rejectedMessageId: Se.userMessage.id
4126
+ const k = $.current, Z = xe.current === "submitted" || xe.current === "streaming" || k !== "idle" || fe.current || j.current.size > 0 ? Bi(o.buildQueuedUserMessage(v)) : await o.stageUserTurn(v, { pending: !0 });
4127
+ if (!Z || E !== w.current) return;
4128
+ const re = { ...Z, input: v };
4129
+ if (!j.current.enqueue(re)) {
4130
+ le.warn("agent chat queue full; rejecting newest send", {
4131
+ rejectedMessageId: re.userMessage.id
4133
4132
  });
4134
4133
  return;
4135
4134
  }
4136
- se((xe) => xe + 1), o.notifySendAccepted(v);
4135
+ ae((be) => be + 1), o.notifySendAccepted(v);
4137
4136
  }
4138
4137
  ).finally(() => {
4139
- E === w.current && T.current--;
4138
+ E === w.current && x.current--;
4140
4139
  });
4141
4140
  return O.current = A.then(
4142
4141
  () => {
@@ -4146,95 +4145,95 @@ function zi({
4146
4145
  ), A;
4147
4146
  },
4148
4147
  [o]
4149
- ), Cn = Z(() => {
4150
- var Y;
4151
- const v = Ce.current;
4148
+ ), wn = z(() => {
4149
+ var K;
4150
+ const v = we.current;
4152
4151
  if (!v) return;
4153
- const E = v.input.optionReply, x = E ? n.find((z) => z.id === E.messageId) : void 0, A = x && $n(x) ? (Y = x.messageOptions) == null ? void 0 : Y.pickedOptionId : null;
4152
+ const E = v.input.optionReply, T = E ? n.find((Z) => Z.id === E.messageId) : void 0, A = T && Un(T) ? (K = T.messageOptions) == null ? void 0 : K.pickedOptionId : null;
4154
4153
  if (E && A && A !== E.optionId) return;
4155
4154
  if (!j.current.enqueue({
4156
4155
  ...v,
4157
- retryUuid: Pt()
4156
+ retryUuid: Rt()
4158
4157
  })) {
4159
- oe.warn("agent chat queue full; retry not enqueued");
4158
+ le.warn("agent chat queue full; retry not enqueued");
4160
4159
  return;
4161
4160
  }
4162
- E && o.setMessageOptionPick(E.messageId, E.optionId), D(), se((z) => z + 1);
4163
- }, [D, o, n]), wn = Z(
4161
+ E && o.setMessageOptionPick(E.messageId, E.optionId), D(), ae((Z) => Z + 1);
4162
+ }, [D, o, n]), An = z(
4164
4163
  (v) => {
4165
4164
  const E = j.current.removeWhere(
4166
- (x) => x.userMessage.id === v
4165
+ (T) => T.userMessage.id === v
4167
4166
  );
4168
- E && (o.releaseUnsentOptionPick(E.input), se((x) => x + 1));
4167
+ E && (o.releaseUnsentOptionPick(E.input), ae((T) => T + 1));
4169
4168
  },
4170
4169
  [o]
4171
- ), An = Z(() => {
4172
- k.current = "stopping", be(!0), R.current = !1;
4170
+ ), xn = z(() => {
4171
+ $.current = "stopping", Ie(!0), P.current = !1;
4173
4172
  const v = w.current;
4174
- ki({ api: s, sessionId: r, chatStop: S }).then(() => {
4175
- v === w.current && (R.current = !0);
4173
+ Fi({ api: s, sessionId: r, chatStop: S }).then(() => {
4174
+ v === w.current && (P.current = !0);
4176
4175
  }).catch((E) => {
4177
- oe.error("agent chat stop failed", E);
4176
+ le.error("agent chat stop failed", E);
4178
4177
  }).then(() => {
4179
4178
  if (v === w.current) {
4180
4179
  if (!r) {
4181
- ue(!1);
4180
+ de(!1);
4182
4181
  return;
4183
4182
  }
4184
4183
  return t.reconcileAfterStream(r).catch((E) => {
4185
- oe.error("agent chat post-stop reconcile failed", E);
4184
+ le.error("agent chat post-stop reconcile failed", E);
4186
4185
  });
4187
4186
  }
4188
4187
  }).finally(() => {
4189
- v === w.current && (k.current = "idle", se((E) => E + 1));
4188
+ v === w.current && ($.current = "idle", ae((E) => E + 1));
4190
4189
  });
4191
4190
  }, [s, r, S, t]);
4192
4191
  F(() => {
4193
4192
  const v = {
4194
4193
  send: Gt,
4195
- hasPendingWork: () => T.current > 0 || pe.current || j.current.size > 0 || k.current !== "idle" || we.current === "submitted" || we.current === "streaming"
4194
+ hasPendingWork: () => x.current > 0 || fe.current || j.current.size > 0 || $.current !== "idle" || xe.current === "submitted" || xe.current === "streaming"
4196
4195
  };
4197
4196
  return o.registerAgentHandlers(v), () => o.unregisterAgentHandlers(v);
4198
4197
  }, [o, Gt]);
4199
4198
  const rt = (Qt = e.presentation) == null ? void 0 : Qt.toolActivity, nt = (Xt = e.presentation) == null ? void 0 : Xt.reasoning;
4200
- F(() => Ee([]), [r]), F(() => {
4201
- var $, Y;
4199
+ F(() => Ce([]), [r]), F(() => {
4200
+ var k, K;
4202
4201
  if (!r) return;
4203
- const v = rt === void 0 && nt === void 0 ? void 0 : { toolActivity: rt, reasoning: nt }, E = Ct.current, x = (E == null ? void 0 : E.sessionId) === r && ((($ = E.presentation) == null ? void 0 : $.toolActivity) !== rt || ((Y = E.presentation) == null ? void 0 : Y.reasoning) !== nt);
4202
+ const v = rt === void 0 && nt === void 0 ? void 0 : { toolActivity: rt, reasoning: nt }, E = Ct.current, T = (E == null ? void 0 : E.sessionId) === r && (((k = E.presentation) == null ? void 0 : k.toolActivity) !== rt || ((K = E.presentation) == null ? void 0 : K.reasoning) !== nt);
4204
4203
  Ct.current = { sessionId: r, presentation: v };
4205
4204
  let A = !1;
4206
4205
  return (async () => {
4207
4206
  try {
4208
- const z = v === void 0 ? await s.getAgentTurnMessages(r) : await s.getAgentTurnMessages(r, v);
4209
- if (!z || A) return;
4210
- Ee(z.handled_connection_request_ids), U(
4211
- (Se) => Ni({ existing: Se, fetched: z, refreshItems: x })
4207
+ const Z = v === void 0 ? await s.getAgentTurnMessages(r) : await s.getAgentTurnMessages(r, v);
4208
+ if (!Z || A) return;
4209
+ Ce(Z.handled_connection_request_ids), U(
4210
+ (re) => Li({ existing: re, fetched: Z, refreshItems: T })
4212
4211
  );
4213
- } catch (z) {
4214
- oe.error("agent chat turn sources fetch failed", z);
4212
+ } catch (Z) {
4213
+ le.error("agent chat turn sources fetch failed", Z);
4215
4214
  }
4216
4215
  })(), () => {
4217
4216
  A = !0;
4218
4217
  };
4219
4218
  }, [r, s, rt, nt]);
4220
- const [wt, xn] = J(() => /* @__PURE__ */ new Set()), st = P(wt), At = P(/* @__PURE__ */ new Set()), at = X(() => {
4221
- if (ve || m !== "streaming" && m !== "submitted")
4219
+ const [wt, Tn] = J(() => /* @__PURE__ */ new Set()), st = R(wt), At = R(/* @__PURE__ */ new Set()), at = X(() => {
4220
+ if (Se || m !== "streaming" && m !== "submitted")
4222
4221
  return [];
4223
4222
  const v = f.at(-1);
4224
4223
  if (!v || v.role !== "assistant") return [];
4225
4224
  const E = [];
4226
- for (const x of v.parts) {
4227
- if (!de(x)) continue;
4228
- const A = Ya(x), $ = A === Ui ? "highlight-element" : A === qi ? "act-on-page" : null;
4229
- $ && x.state === "input-available" && E.push({
4230
- key: `${r ?? "pending"}:${x.toolCallId}`,
4231
- type: $,
4232
- input: x.input,
4233
- callId: x.toolCallId
4225
+ for (const T of v.parts) {
4226
+ if (!pe(T)) continue;
4227
+ const A = Ha(T), k = A === zi ? "highlight-element" : A === Zi ? "act-on-page" : null;
4228
+ k && T.state === "input-available" && E.push({
4229
+ key: `${r ?? "pending"}:${T.toolCallId}`,
4230
+ type: k,
4231
+ input: T.input,
4232
+ callId: T.toolCallId
4234
4233
  });
4235
4234
  }
4236
4235
  return E;
4237
- }, [f, r, m, ve]), Tn = X(
4236
+ }, [f, r, m, Se]), Mn = X(
4238
4237
  () => at.filter(
4239
4238
  (v) => u && y && (v.type !== "act-on-page" || g) && !wt.has(v.key)
4240
4239
  ),
@@ -4245,21 +4244,21 @@ function zi({
4245
4244
  g,
4246
4245
  wt
4247
4246
  ]
4248
- ), xt = Z(
4249
- (v, E, x, A) => {
4247
+ ), xt = z(
4248
+ (v, E, T, A) => {
4250
4249
  if (!r) return;
4251
- const $ = `${r}:${v}`;
4252
- if (st.current.has($)) return;
4253
- At.current.delete($);
4254
- const Y = new Set(st.current);
4255
- if (Y.add($), Y.size > 200) {
4256
- const z = Y.values().next().value;
4257
- z !== void 0 && Y.delete(z);
4250
+ const k = `${r}:${v}`;
4251
+ if (st.current.has(k)) return;
4252
+ At.current.delete(k);
4253
+ const K = new Set(st.current);
4254
+ if (K.add(k), K.size > 200) {
4255
+ const Z = K.values().next().value;
4256
+ Z !== void 0 && K.delete(Z);
4258
4257
  }
4259
- st.current = Y, xn(Y), s.sendPageReply(r, {
4258
+ st.current = K, Tn(K), s.sendPageReply(r, {
4260
4259
  callId: v,
4261
4260
  outcome: E,
4262
- ...x ? { detail: x } : {},
4261
+ ...T ? { detail: T } : {},
4263
4262
  // The page as it is after the action. Without it a flow that
4264
4263
  // crosses screens stops dead: the agent is holding refs to the
4265
4264
  // screen it just left.
@@ -4267,23 +4266,23 @@ function zi({
4267
4266
  });
4268
4267
  },
4269
4268
  [s, r, t]
4270
- ), [Mn, Tt] = J(null), Ae = P(
4269
+ ), [_n, Tt] = J(null), Te = R(
4271
4270
  /* @__PURE__ */ new Map()
4272
- ), _n = Z(
4271
+ ), Rn = z(
4273
4272
  (v) => new Promise((E) => {
4274
- const x = `${r ?? "pending"}:${v.callId}`;
4275
- if (st.current.has(x)) {
4273
+ const T = `${r ?? "pending"}:${v.callId}`;
4274
+ if (st.current.has(T)) {
4276
4275
  E(!1);
4277
4276
  return;
4278
4277
  }
4279
- At.current.add(x), Ae.current.forEach((A) => A(!1)), Ae.current.clear(), Ae.current.set(v.callId, E), Tt(v);
4278
+ At.current.add(T), Te.current.forEach((A) => A(!1)), Te.current.clear(), Te.current.set(v.callId, E), Tt(v);
4280
4279
  }),
4281
4280
  [r]
4282
- ), Mt = Z((v, E) => {
4283
- const x = Ae.current.get(v);
4284
- Ae.current.delete(v), Tt(
4281
+ ), Mt = z((v, E) => {
4282
+ const T = Te.current.get(v);
4283
+ Te.current.delete(v), Tt(
4285
4284
  (A) => (A == null ? void 0 : A.callId) === v ? null : A
4286
- ), x == null || x(E);
4285
+ ), T == null || T(E);
4287
4286
  }, []);
4288
4287
  F(() => {
4289
4288
  for (const v of at)
@@ -4296,36 +4295,41 @@ function zi({
4296
4295
  Mt,
4297
4296
  xt
4298
4297
  ]);
4299
- const ie = m === "submitted" || m === "streaming";
4298
+ const oe = m === "submitted" || m === "streaming";
4300
4299
  F(() => {
4301
- const v = Ue.current;
4302
- if (N === void 0 || ie || !v || !r) return;
4303
- const E = new Set(n.map((Y) => Y.id));
4304
- let x = !1, A;
4305
- const $ = async (Y) => {
4306
- let z;
4300
+ var Z;
4301
+ const v = Ae.current;
4302
+ if (N === void 0 || oe || !v || !r) return;
4303
+ const E = v.kind === "send" ? v.wireId : (Z = n.findLast(
4304
+ (re) => re.type === "USER" && !re.pending
4305
+ )) == null ? void 0 : Z.id;
4306
+ if (E === void 0) return;
4307
+ const T = new Set(n.map((re) => re.id));
4308
+ let A = !1, k;
4309
+ const K = async (re) => {
4310
+ let be;
4307
4311
  try {
4308
- z = await s.getAgentTurnMessages(r);
4312
+ be = await s.getAgentTurnMessages(r);
4309
4313
  } catch (lt) {
4310
- oe.warn("agent chat failed-send check failed", lt);
4314
+ le.warn("agent chat failed-turn check failed", lt);
4311
4315
  return;
4312
4316
  }
4313
- if (x || Ue.current !== v) return;
4314
- if (z == null ? void 0 : z.turns.some(
4315
- (lt) => (lt.input_message_uuids ?? []).includes(v.wireId) && lt.message_uuids.some((Nn) => E.has(Nn))
4317
+ if (A || Ae.current !== v) return;
4318
+ if (be == null ? void 0 : be.turns.some(
4319
+ (lt) => (lt.input_message_uuids ?? []).includes(E) && lt.message_uuids.some((Ln) => T.has(Ln))
4316
4320
  )) {
4317
- Ue.current = null, o.markUserMessageDelivered(v.bubbleId), D();
4321
+ Ae.current = null, v.kind === "send" && o.markUserMessageDelivered(v.bubbleId), D();
4318
4322
  return;
4319
4323
  }
4320
- const [xe, ...Te] = Y;
4321
- xe !== void 0 && (A = setTimeout(() => void $(Te), xe));
4324
+ const [er, ...Dn] = re;
4325
+ er !== void 0 && (k = setTimeout(() => void K(Dn), er));
4322
4326
  };
4323
- return $(Fi), () => {
4324
- x = !0, A !== void 0 && clearTimeout(A);
4327
+ return K(qi), () => {
4328
+ A = !0, k !== void 0 && clearTimeout(k);
4325
4329
  };
4326
4330
  }, [
4327
4331
  N,
4328
- ie,
4332
+ oe,
4329
4333
  n,
4330
4334
  r,
4331
4335
  s,
@@ -4333,126 +4337,126 @@ function zi({
4333
4337
  D
4334
4338
  ]), F(
4335
4339
  () => () => {
4336
- Ae.current.forEach((v) => v(!1)), Ae.current.clear();
4340
+ Te.current.forEach((v) => v(!1)), Te.current.clear();
4337
4341
  },
4338
4342
  [r]
4339
4343
  ), F(() => {
4340
- if (ie && !ve) return;
4341
- const v = Ae.current;
4344
+ if (oe && !Se) return;
4345
+ const v = Te.current;
4342
4346
  v.size !== 0 && (v.forEach((E) => E(!1)), v.clear(), Tt(null));
4343
- }, [ie, ve]), F(() => {
4344
- if (ie) return;
4345
- const v = Fe.current;
4347
+ }, [oe, Se]), F(() => {
4348
+ if (oe) return;
4349
+ const v = Ue.current;
4346
4350
  if (v === null) return;
4347
4351
  const E = f.at(-1);
4348
4352
  E && E.role === "assistant" && tt(E, v);
4349
- }, [f, ie, tt]);
4350
- const _t = Z(() => {
4351
- r && (ie || N === void 0 && !G || B());
4352
- }, [r, ie, G, N, B]);
4353
+ }, [f, oe, tt]);
4354
+ const _t = z(() => {
4355
+ r && (oe || N === void 0 && !G || B());
4356
+ }, [r, oe, G, N, B]);
4353
4357
  F(
4354
- () => ji(_t),
4358
+ () => $i(_t),
4355
4359
  [_t]
4356
4360
  ), F(() => {
4357
- if (ie || !G) return;
4361
+ if (oe || !G) return;
4358
4362
  const v = () => {
4359
- ue(!1), se((A) => A + 1), Ke.current === Fe.current && Pe(null), Fe.current = null;
4363
+ de(!1), ae((A) => A + 1), Ke.current === Ue.current && Re(null), Ue.current = null;
4360
4364
  };
4361
- if (Ke.current === Fe.current && (p == null ? void 0 : p.messages) === f && !p.isError && !p.isDisconnect && (!p.isAbort || R.current) && !pt(p.message.parts).some(
4365
+ if (Ke.current === Ue.current && (p == null ? void 0 : p.messages) === f && !p.isError && !p.isDisconnect && (!p.isAbort || P.current) && !pt(p.message.parts).some(
4362
4366
  (A) => A.kind !== "steps"
4363
4367
  )) {
4364
- const A = n.findLast(($) => $.type === "USER");
4368
+ const A = n.findLast((k) => k.type === "USER");
4365
4369
  A && o.state.setPartial({ settledAgentUserMessageId: A.id }), v();
4366
4370
  return;
4367
4371
  }
4368
4372
  if (p && p.messages !== f) return;
4369
- const E = f.at(-1), x = (E == null ? void 0 : E.role) === "assistant" ? br(E.parts) : null;
4370
- if (x && x.rowIds.length > 0) {
4371
- const A = new Set(n.map(($) => $.id));
4372
- x.rowIds.every(($) => A.has($)) && v();
4373
+ const E = f.at(-1), T = (E == null ? void 0 : E.role) === "assistant" ? Sr(E.parts) : null;
4374
+ if (T && T.rowIds.length > 0) {
4375
+ const A = new Set(n.map((k) => k.id));
4376
+ T.rowIds.every((k) => A.has(k)) && v();
4373
4377
  return;
4374
4378
  }
4375
4379
  for (let A = n.length - 1; A >= 0; A -= 1) {
4376
- const $ = n[A];
4377
- if ($) {
4378
- if ($.type === "USER") return;
4379
- if (!($.type !== "AI" && $.type !== "AGENT")) {
4380
+ const k = n[A];
4381
+ if (k) {
4382
+ if (k.type === "USER") return;
4383
+ if (!(k.type !== "AI" && k.type !== "AGENT")) {
4380
4384
  v();
4381
4385
  return;
4382
4386
  }
4383
4387
  }
4384
4388
  }
4385
4389
  }, [
4386
- ie,
4390
+ oe,
4387
4391
  G,
4388
4392
  n,
4389
- Pe,
4393
+ Re,
4390
4394
  p,
4391
4395
  f,
4392
4396
  o,
4393
- ye
4397
+ ve
4394
4398
  ]);
4395
- const ze = Fn(
4399
+ const ze = qn(
4396
4400
  t.agent.presentation,
4397
4401
  e.presentation
4398
4402
  ), it = ze == null ? void 0 : ze.toolActivity, ot = ze == null ? void 0 : ze.reasoning, Pn = X(() => {
4399
- if (!He || fe === null || m === "submitted" || !ie && !G)
4403
+ if (!He || me === null || m === "submitted" || !oe && !G)
4400
4404
  return [];
4401
4405
  const v = f.at(-1);
4402
- return !v || v.role !== "assistant" ? [] : mr(pt(v.parts), {
4406
+ return !v || v.role !== "assistant" ? [] : gr(pt(v.parts), {
4403
4407
  toolActivity: it,
4404
4408
  reasoning: ot
4405
4409
  });
4406
4410
  }, [
4407
4411
  f,
4408
4412
  m,
4409
- ie,
4413
+ oe,
4410
4414
  G,
4411
4415
  it,
4412
4416
  ot,
4413
4417
  He,
4414
- fe
4415
- ]), Rn = X(
4416
- () => He ? Ie.flatMap((v) => {
4417
- const E = mr(v.items, {
4418
+ me
4419
+ ]), On = X(
4420
+ () => He ? Ee.flatMap((v) => {
4421
+ const E = gr(v.items, {
4418
4422
  toolActivity: it,
4419
4423
  reasoning: ot
4420
4424
  });
4421
4425
  return E.length === 0 ? [] : [E === v.items ? v : { ...v, items: E }];
4422
4426
  }) : [],
4423
- [Ie, it, ot, He]
4424
- ), On = X(
4427
+ [Ee, it, ot, He]
4428
+ ), Nn = X(
4425
4429
  () => j.current.items.filter((v) => !v.input.background).map((v) => v.userMessage),
4426
4430
  // eslint-disable-next-line react-hooks/exhaustive-deps -- queueRef is mutable; queueVersion is the signal
4427
- [ye]
4431
+ [ve]
4428
4432
  );
4429
4433
  return {
4430
- isStreaming: ie,
4434
+ isStreaming: oe,
4431
4435
  liveItems: Pn,
4432
4436
  /** Finished turns' render sources — see `TurnRenderSource`. */
4433
- turnSources: Rn,
4437
+ turnSources: On,
4434
4438
  /** The live turn's node key (stable through the retained promotion). */
4435
- liveTurnKey: fe,
4439
+ liveTurnKey: me,
4436
4440
  /** The last turn failed — the transcript renders a visible error row. */
4437
4441
  turnFailed: N !== void 0,
4438
- retryFailedTurn: Cn,
4442
+ retryFailedTurn: wn,
4439
4443
  resumeInterruptedTurn: _t,
4440
- queuedUserMessages: On,
4441
- removeQueued: wn,
4442
- stop: An,
4443
- pageEffects: Tn,
4444
+ queuedUserMessages: Nn,
4445
+ removeQueued: An,
4446
+ stop: xn,
4447
+ pageEffects: Mn,
4444
4448
  replyToPageCall: xt,
4445
- pendingPageAction: Mn,
4446
- requestPageActionConsent: _n,
4449
+ pendingPageAction: _n,
4450
+ requestPageActionConsent: Rn,
4447
4451
  resolvePageAction: Mt,
4448
- handledConnectionRequestIds: ae,
4452
+ handledConnectionRequestIds: ie,
4449
4453
  sourceSessionId: He ? r : null
4450
4454
  };
4451
4455
  }
4452
- function Zi(t) {
4456
+ function Bi(t) {
4453
4457
  return t ? { ...t, initialMessages: [] } : null;
4454
4458
  }
4455
- const Er = 2e3, Cr = 6e5, Vi = 1e4, bt = Ye(null), Bi = (t, e) => e === "dismiss" ? {
4459
+ const Cr = 2e3, wr = 6e5, Wi = 1e4, bt = Ye(null), Ji = (t, e) => e === "dismiss" ? {
4456
4460
  content: `Continue without connecting ${t.name}.`,
4457
4461
  connectionRequestId: t.request_id
4458
4462
  } : e === "renew" ? {
@@ -4468,7 +4472,7 @@ const Er = 2e3, Cr = 6e5, Vi = 1e4, bt = Ye(null), Bi = (t, e) => e === "dismiss
4468
4472
  connectionRequestId: t.request_id,
4469
4473
  content: `The connection to ${t.name} is ready. Please use its tools to continue my previous request.`
4470
4474
  };
4471
- function Wi({
4475
+ function Yi({
4472
4476
  children: t,
4473
4477
  request: e,
4474
4478
  widgetCtx: r,
@@ -4476,25 +4480,25 @@ function Wi({
4476
4480
  }) {
4477
4481
  const [s, o] = J("idle"), [l, u] = J(null), [y, g] = J(
4478
4482
  null
4479
- ), [i, d] = J(null), p = P(new AbortController()), b = P(null), R = P(/* @__PURE__ */ new Set()), M = P(null), O = P(null), T = P(null), w = P(!0), I = P((e == null ? void 0 : e.request_id) ?? null);
4483
+ ), [i, d] = J(null), p = R(new AbortController()), b = R(null), P = R(/* @__PURE__ */ new Set()), M = R(null), O = R(null), x = R(null), w = R(!0), I = R((e == null ? void 0 : e.request_id) ?? null);
4480
4484
  I.current = (e == null ? void 0 : e.request_id) ?? null;
4481
- const C = Z(() => {
4485
+ const C = z(() => {
4482
4486
  var D;
4483
4487
  p.current.abort(), (D = b.current) == null || D.close(), b.current = null;
4484
4488
  }, []);
4485
- F(() => (C(), T.current = null, O.current = null, M.current = null, o("idle"), u(null), g(null), d(null), C), [C, e == null ? void 0 : e.request_id, e == null ? void 0 : e.server_id, r]), F(() => (w.current = !0, () => {
4489
+ F(() => (C(), x.current = null, O.current = null, M.current = null, o("idle"), u(null), g(null), d(null), C), [C, e == null ? void 0 : e.request_id, e == null ? void 0 : e.server_id, r]), F(() => (w.current = !0, () => {
4486
4490
  w.current = !1, C();
4487
4491
  }), [C]);
4488
- const c = Z(
4492
+ const c = z(
4489
4493
  async (D) => {
4490
4494
  if (!e) return;
4491
4495
  const B = e.request_id;
4492
- if (R.current.has(B)) return;
4493
- R.current.add(B), M.current = D, g(D), d(null);
4496
+ if (P.current.has(B)) return;
4497
+ P.current.add(B), M.current = D, g(D), d(null);
4494
4498
  let W = !1;
4495
4499
  try {
4496
4500
  await r.messageCtx.sendMessage({
4497
- ...Bi(e, D),
4501
+ ...Ji(e, D),
4498
4502
  onAccepted: () => {
4499
4503
  W = !0, n(e.request_id);
4500
4504
  }
@@ -4506,14 +4510,14 @@ function Wi({
4506
4510
  D === "renew" ? "Could not request a new connection. Try again." : "Could not continue your request. Try again."
4507
4511
  );
4508
4512
  } finally {
4509
- R.current.delete(B), w.current && I.current === B && g(null);
4513
+ P.current.delete(B), w.current && I.current === B && g(null);
4510
4514
  }
4511
4515
  },
4512
4516
  [n, e, r]
4513
- ), m = Z(async () => {
4517
+ ), m = z(async () => {
4514
4518
  var B, W;
4515
4519
  if (!e) return;
4516
- C(), T.current = e.request_id, p.current = new AbortController();
4520
+ C(), x.current = e.request_id, p.current = new AbortController();
4517
4521
  const { signal: D } = p.current;
4518
4522
  o("loading"), M.current = null, u(null), d(null);
4519
4523
  try {
@@ -4524,18 +4528,18 @@ function Wi({
4524
4528
  D
4525
4529
  );
4526
4530
  if (D.aborted) return;
4527
- const k = new URL(j.authorization_url);
4528
- if (!(k.protocol === "https:" || k.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(k.hostname)) || k.username || k.password)
4531
+ const $ = new URL(j.authorization_url);
4532
+ if (!($.protocol === "https:" || $.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes($.hostname)) || $.username || $.password)
4529
4533
  throw new Error("Invalid connection page");
4530
4534
  u({
4531
- url: k.href,
4532
- host: k.host,
4535
+ url: $.href,
4536
+ host: $.host,
4533
4537
  completion: j.completion,
4534
4538
  ...j.completion === "oauth" ? { attemptId: j.attempt_id } : {}
4535
- }), O.current = Date.now() + Cr, (B = b.current) != null && B.closed ? (b.current = null, o("ready")) : b.current ? (b.current.location.replace(k.href), o("waiting")) : o("ready");
4539
+ }), O.current = Date.now() + wr, (B = b.current) != null && B.closed ? (b.current = null, o("ready")) : b.current ? (b.current.location.replace($.href), o("waiting")) : o("ready");
4536
4540
  } catch (j) {
4537
4541
  if (D.aborted) return;
4538
- if ((W = b.current) == null || W.close(), b.current = null, u(null), o("idle"), j instanceof Un) {
4542
+ if ((W = b.current) == null || W.close(), b.current = null, u(null), o("idle"), j instanceof zn) {
4539
4543
  await c("renew");
4540
4544
  return;
4541
4545
  }
@@ -4549,35 +4553,35 @@ function Wi({
4549
4553
  return;
4550
4554
  const D = new AbortController();
4551
4555
  let B;
4552
- const W = O.current ?? Date.now() + Cr;
4556
+ const W = O.current ?? Date.now() + wr;
4553
4557
  O.current = W;
4554
- let j = 0, k = document.hidden || !document.hasFocus(), ve = !1;
4555
- const be = () => {
4556
- k = !0;
4557
- }, ye = () => {
4558
- k && (ve = !0);
4559
- }, se = () => document.hidden ? be() : ye();
4560
- window.addEventListener("blur", be), window.addEventListener("focus", ye), document.addEventListener("visibilitychange", se);
4558
+ let j = 0, $ = document.hidden || !document.hasFocus(), Se = !1;
4559
+ const Ie = () => {
4560
+ $ = !0;
4561
+ }, ve = () => {
4562
+ $ && (Se = !0);
4563
+ }, ae = () => document.hidden ? Ie() : ve();
4564
+ window.addEventListener("blur", Ie), window.addEventListener("focus", ve), document.addEventListener("visibilitychange", ae);
4561
4565
  const G = (U) => {
4562
- var ae;
4563
- D.abort(), (ae = b.current) == null || ae.close(), b.current = null, d(U), o("idle");
4564
- }, ue = setTimeout(
4566
+ var ie;
4567
+ D.abort(), (ie = b.current) == null || ie.close(), b.current = null, d(U), o("idle");
4568
+ }, de = setTimeout(
4565
4569
  () => G("Connection timed out. Try again."),
4566
4570
  Math.max(0, W - Date.now())
4567
- ), pe = (U = Er) => {
4568
- B = setTimeout(Ie, U);
4569
- }, Ie = async () => {
4570
- var U, ae, Ee;
4571
+ ), fe = (U = Cr) => {
4572
+ B = setTimeout(Ee, U);
4573
+ }, Ee = async () => {
4574
+ var U, ie, Ce;
4571
4575
  if (Date.now() >= W) {
4572
4576
  G("Connection timed out. Try again.");
4573
4577
  return;
4574
4578
  }
4575
4579
  if (l.completion === "external") {
4576
- if (s === "waiting" && ((U = b.current) != null && U.closed || ve)) {
4580
+ if (s === "waiting" && ((U = b.current) != null && U.closed || Se)) {
4577
4581
  o("external");
4578
4582
  return;
4579
4583
  }
4580
- pe();
4584
+ fe();
4581
4585
  return;
4582
4586
  }
4583
4587
  if (!l.attemptId) {
@@ -4585,52 +4589,52 @@ function Wi({
4585
4589
  return;
4586
4590
  }
4587
4591
  try {
4588
- const fe = await r.api.getConnectionAttempt(
4592
+ const me = await r.api.getConnectionAttempt(
4589
4593
  e.server_id,
4590
4594
  l.attemptId,
4591
4595
  D.signal
4592
4596
  );
4593
4597
  if (D.signal.aborted) return;
4594
- if (j = 0, fe === "connected") {
4595
- (ae = b.current) == null || ae.close(), b.current = null, o("connected");
4598
+ if (j = 0, me === "connected") {
4599
+ (ie = b.current) == null || ie.close(), b.current = null, o("connected");
4596
4600
  return;
4597
4601
  }
4598
- if (fe === "canceled") {
4602
+ if (me === "canceled") {
4599
4603
  G("Connection was canceled. Try again.");
4600
4604
  return;
4601
4605
  }
4602
- if (fe === "failed") {
4606
+ if (me === "failed") {
4603
4607
  G("Connection approval failed. Try again.");
4604
4608
  return;
4605
4609
  }
4606
- if (fe === "expired") {
4610
+ if (me === "expired") {
4607
4611
  G("Connection attempt expired. Try again.");
4608
4612
  return;
4609
4613
  }
4610
- (Ee = b.current) != null && Ee.closed && (b.current = null, o("ready")), pe();
4611
- } catch (fe) {
4614
+ (Ce = b.current) != null && Ce.closed && (b.current = null, o("ready")), fe();
4615
+ } catch (me) {
4612
4616
  if (D.signal.aborted) return;
4613
- if (fe instanceof qn) {
4614
- G(fe.message);
4617
+ if (me instanceof Zn) {
4618
+ G(me.message);
4615
4619
  return;
4616
4620
  }
4617
- j += 1, pe(
4621
+ j += 1, fe(
4618
4622
  Math.min(
4619
- Er * 2 ** (j - 1),
4620
- Vi
4623
+ Cr * 2 ** (j - 1),
4624
+ Wi
4621
4625
  )
4622
4626
  );
4623
4627
  }
4624
4628
  };
4625
- return Ie(), () => {
4626
- D.abort(), B && clearTimeout(B), ue && clearTimeout(ue), window.removeEventListener("blur", be), window.removeEventListener("focus", ye), document.removeEventListener("visibilitychange", se);
4629
+ return Ee(), () => {
4630
+ D.abort(), B && clearTimeout(B), de && clearTimeout(de), window.removeEventListener("blur", Ie), window.removeEventListener("focus", ve), document.removeEventListener("visibilitychange", ae);
4627
4631
  };
4628
4632
  }, [l, s, e, r]), F(() => {
4629
- s !== "connected" && s !== "external" || T.current !== (e == null ? void 0 : e.request_id) || c(s === "external" ? "external" : "resume");
4633
+ s !== "connected" && s !== "external" || x.current !== (e == null ? void 0 : e.request_id) || c(s === "external" ? "external" : "resume");
4630
4634
  }, [s, e == null ? void 0 : e.request_id, c]);
4631
- const f = Z(() => o("waiting"), []), h = Z(async () => {
4635
+ const f = z(() => o("waiting"), []), h = z(async () => {
4632
4636
  C(), u(null), o("idle"), await c("dismiss");
4633
- }, [C, c]), S = Z(async () => {
4637
+ }, [C, c]), S = z(async () => {
4634
4638
  const D = M.current;
4635
4639
  if (D) {
4636
4640
  await c(D);
@@ -4661,7 +4665,7 @@ function Wi({
4661
4665
  m
4662
4666
  ]
4663
4667
  );
4664
- return K.createElement(
4668
+ return Y.createElement(
4665
4669
  bt.Provider,
4666
4670
  {
4667
4671
  value: N
@@ -4669,21 +4673,21 @@ function Wi({
4669
4673
  t
4670
4674
  );
4671
4675
  }
4672
- function Ji({
4676
+ function Ki({
4673
4677
  children: t,
4674
4678
  connection: e
4675
4679
  }) {
4676
- return K.createElement(
4680
+ return Y.createElement(
4677
4681
  bt.Provider,
4678
4682
  { value: e },
4679
4683
  t
4680
4684
  );
4681
4685
  }
4682
- function Yi() {
4683
- return $e(bt);
4686
+ function Hi() {
4687
+ return Fe(bt);
4684
4688
  }
4685
- function Ao(t) {
4686
- const e = $e(bt);
4689
+ function To(t) {
4690
+ const e = Fe(bt);
4687
4691
  if (!e || e.request.request_id !== t.request_id)
4688
4692
  throw new Error(
4689
4693
  "useConnection must be used for the active ConnectionAttemptProvider request"
@@ -4715,15 +4719,15 @@ const Bt = {
4715
4719
  pendingClarification: null,
4716
4720
  pendingConnection: null
4717
4721
  }, St = Ye(null);
4718
- function dn() {
4719
- return $e(St) ?? Bt;
4722
+ function pn() {
4723
+ return Fe(St) ?? Bt;
4720
4724
  }
4721
- function Ki({
4725
+ function Gi({
4722
4726
  children: t,
4723
4727
  widgetCtx: e,
4724
4728
  config: r
4725
4729
  }) {
4726
- var ye, se, G, ue, pe, Ie;
4730
+ var ve, ae, G, de, fe, Ee;
4727
4731
  const n = H(e.sessionCtx.sessionState), s = H(e.messageCtx.state), {
4728
4732
  isStreaming: o,
4729
4733
  liveItems: l,
@@ -4734,33 +4738,33 @@ function Ki({
4734
4738
  resumeInterruptedTurn: d,
4735
4739
  queuedUserMessages: p,
4736
4740
  removeQueued: b,
4737
- stop: R,
4741
+ stop: P,
4738
4742
  pageEffects: M,
4739
4743
  replyToPageCall: O,
4740
- pendingPageAction: T,
4744
+ pendingPageAction: x,
4741
4745
  requestPageActionConsent: w,
4742
4746
  resolvePageAction: I,
4743
4747
  handledConnectionRequestIds: C,
4744
4748
  sourceSessionId: c
4745
- } = zi({
4749
+ } = Vi({
4746
4750
  widgetCtx: e,
4747
4751
  config: r,
4748
- sessionId: ((ye = n.session) == null ? void 0 : ye.id) ?? null,
4752
+ sessionId: ((ve = n.session) == null ? void 0 : ve.id) ?? null,
4749
4753
  persistedMessages: s.messages
4750
- }), m = ((se = s.messages.at(-1)) == null ? void 0 : se.type) === "USER", f = P(/* @__PURE__ */ new Set()), h = P(((G = n.session) == null ? void 0 : G.id) ?? null), S = ((ue = n.session) == null ? void 0 : ue.id) ?? null;
4754
+ }), m = ((ae = s.messages.at(-1)) == null ? void 0 : ae.type) === "USER", f = R(/* @__PURE__ */ new Set()), h = R(((G = n.session) == null ? void 0 : G.id) ?? null), S = ((de = n.session) == null ? void 0 : de.id) ?? null;
4751
4755
  h.current !== S && (h.current = S, f.current.clear()), C.forEach(
4752
4756
  (U) => f.current.add(U)
4753
4757
  );
4754
- const N = (pe = [
4758
+ const N = (fe = [
4755
4759
  ...u.flatMap((U) => U.items),
4756
4760
  ...l
4757
4761
  ].findLast(
4758
4762
  (U) => U.kind === "connection" && !f.current.has(U.request.request_id)
4759
- )) == null ? void 0 : pe.request, [D, B] = J({ sessionId: S, request: null }), W = ((Ie = r.capabilities) == null ? void 0 : Ie.connections) === !0, j = W && S !== null && D.sessionId === S ? D.request : null;
4763
+ )) == null ? void 0 : fe.request, [D, B] = J({ sessionId: S, request: null }), W = ((Ee = r.capabilities) == null ? void 0 : Ee.connections) === !0, j = W && S !== null && D.sessionId === S ? D.request : null;
4760
4764
  F(() => {
4761
4765
  !W || S === null || c !== S || B((U) => {
4762
- const ae = U.sessionId === S && U.request && !f.current.has(U.request.request_id) ? U.request : N ?? null;
4763
- return U.sessionId === S && U.request === ae ? U : { sessionId: S, request: ae };
4766
+ const ie = U.sessionId === S && U.request && !f.current.has(U.request.request_id) ? U.request : N ?? null;
4767
+ return U.sessionId === S && U.request === ie ? U : { sessionId: S, request: ie };
4764
4768
  });
4765
4769
  }, [
4766
4770
  S,
@@ -4770,14 +4774,14 @@ function Ki({
4770
4774
  W,
4771
4775
  j
4772
4776
  ]);
4773
- const k = Z((U) => {
4777
+ const $ = z((U) => {
4774
4778
  f.current.add(U), B(
4775
- (ae) => {
4776
- var Ee;
4777
- return ((Ee = ae.request) == null ? void 0 : Ee.request_id) === U ? { ...ae, request: null } : ae;
4779
+ (ie) => {
4780
+ var Ce;
4781
+ return ((Ce = ie.request) == null ? void 0 : Ce.request_id) === U ? { ...ie, request: null } : ie;
4778
4782
  }
4779
4783
  );
4780
- }, []), ve = X(
4784
+ }, []), Se = X(
4781
4785
  () => ({
4782
4786
  isStreaming: o,
4783
4787
  liveItems: l,
@@ -4788,14 +4792,14 @@ function Ki({
4788
4792
  resumeInterruptedTurn: d,
4789
4793
  queuedUserMessages: p,
4790
4794
  removeQueued: b,
4791
- stop: R,
4795
+ stop: P,
4792
4796
  pageEffects: M,
4793
4797
  replyToPageCall: O,
4794
- pendingPageAction: T,
4798
+ pendingPageAction: x,
4795
4799
  requestPageActionConsent: w,
4796
4800
  resolvePageAction: I,
4797
4801
  pendingConnection: j,
4798
- pendingClarification: ps({
4802
+ pendingClarification: ms({
4799
4803
  turnSources: u,
4800
4804
  liveItems: l,
4801
4805
  isStreaming: o,
@@ -4812,34 +4816,34 @@ function Ki({
4812
4816
  d,
4813
4817
  p,
4814
4818
  b,
4815
- R,
4819
+ P,
4816
4820
  M,
4817
4821
  O,
4818
- T,
4822
+ x,
4819
4823
  w,
4820
4824
  I,
4821
4825
  m,
4822
4826
  j
4823
4827
  ]
4824
- ), be = /* @__PURE__ */ K.createElement(St.Provider, { value: ve }, t);
4825
- return /* @__PURE__ */ K.createElement(
4826
- Wi,
4828
+ ), Ie = /* @__PURE__ */ Y.createElement(St.Provider, { value: Se }, t);
4829
+ return /* @__PURE__ */ Y.createElement(
4830
+ Yi,
4827
4831
  {
4828
4832
  request: j,
4829
4833
  widgetCtx: e,
4830
- onHandled: k
4834
+ onHandled: $
4831
4835
  },
4832
- be
4836
+ Ie
4833
4837
  );
4834
4838
  }
4835
- function pn({
4839
+ function fn({
4836
4840
  children: t,
4837
4841
  widgetCtx: e,
4838
4842
  config: r
4839
4843
  }) {
4840
- return H(e.messageCtx.state), e.streaming ? /* @__PURE__ */ K.createElement(Ki, { widgetCtx: e, config: r }, t) : /* @__PURE__ */ K.createElement(St.Provider, { value: Bt }, t);
4844
+ return H(e.messageCtx.state), e.streaming ? /* @__PURE__ */ Y.createElement(Gi, { widgetCtx: e, config: r }, t) : /* @__PURE__ */ Y.createElement(St.Provider, { value: Bt }, t);
4841
4845
  }
4842
- class Hi {
4846
+ class Qi {
4843
4847
  constructor(e) {
4844
4848
  this.root = e, this.nextId = 1, this.mountVersion = 0, this.disposed = !1, this.mount = () => {
4845
4849
  const n = ++this.mountVersion;
@@ -4912,7 +4916,7 @@ class Hi {
4912
4916
  });
4913
4917
  };
4914
4918
  const r = this.makeChat(e);
4915
- this.state = new Mr({ chats: [r], activeId: r.id });
4919
+ this.state = new _r({ chats: [r], activeId: r.id });
4916
4920
  }
4917
4921
  makeChat(e) {
4918
4922
  return {
@@ -4937,15 +4941,15 @@ class Hi {
4937
4941
  return !e.closed && !r && !this.isWorking(e) && !e.ctx.messageCtx.state.get().messages.length && !n && !s.length && !e.ctx.uploadCtx.state.get().length;
4938
4942
  }
4939
4943
  }
4940
- const fn = Ye(null), Gi = new Mr({ chats: [], activeId: 0 });
4941
- function mn() {
4942
- const t = $e(fn), e = H((t == null ? void 0 : t.state) ?? Gi), r = e.chats.filter((s) => !s.closed), n = r.filter(
4944
+ const mn = Ye(null), Xi = new _r({ chats: [], activeId: 0 });
4945
+ function gn() {
4946
+ const t = Fe(mn), e = H((t == null ? void 0 : t.state) ?? Xi), r = e.chats.filter((s) => !s.closed), n = r.filter(
4943
4947
  (s) => s.hasSession || s.working || s.hasDraft || s.title
4944
4948
  );
4945
4949
  return { workspace: t, chats: r, openChats: n, activeId: e.activeId };
4946
4950
  }
4947
- function xo() {
4948
- const { workspace: t, ...e } = mn();
4951
+ function Mo() {
4952
+ const { workspace: t, ...e } = gn();
4949
4953
  if (!t)
4950
4954
  throw new Error("Companion chats require a conversation workspace");
4951
4955
  return {
@@ -4955,13 +4959,13 @@ function xo() {
4955
4959
  newChat: t.open
4956
4960
  };
4957
4961
  }
4958
- function Qi({
4962
+ function eo({
4959
4963
  chatId: t,
4960
4964
  ctx: e,
4961
4965
  workspace: r
4962
4966
  }) {
4963
- const n = dn(), s = Yi(), o = H(e.messageCtx.state), l = H(e.sessionCtx.sessionState), u = H(e.messageCtx.draftState), y = H(e.uploadCtx.state), g = o.messages.find(
4964
- (R) => R.type === "USER"
4967
+ const n = pn(), s = Hi(), o = H(e.messageCtx.state), l = H(e.sessionCtx.sessionState), u = H(e.messageCtx.draftState), y = H(e.uploadCtx.state), g = o.messages.find(
4968
+ (P) => P.type === "USER"
4965
4969
  ), i = (g == null ? void 0 : g.type) === "USER" ? g.content.slice(0, 60) : "", d = n.isStreaming || o.isSendingMessage || l.isCreatingSession, p = !!l.session, b = !!u.text || u.mentions.length > 0 || y.length > 0;
4966
4970
  return F(
4967
4971
  () => r.update(t, {
@@ -4975,27 +4979,27 @@ function Qi({
4975
4979
  [r, t, i, d, p, b, n, s]
4976
4980
  ), null;
4977
4981
  }
4978
- const Xi = Dn(function({
4982
+ const to = jn(function({
4979
4983
  chatId: e,
4980
4984
  ctx: r,
4981
4985
  config: n,
4982
4986
  workspace: s
4983
4987
  }) {
4984
- return /* @__PURE__ */ K.createElement(pn, { widgetCtx: r, config: n }, /* @__PURE__ */ K.createElement(Qi, { chatId: e, ctx: r, workspace: s }));
4988
+ return /* @__PURE__ */ Y.createElement(fn, { widgetCtx: r, config: n }, /* @__PURE__ */ Y.createElement(eo, { chatId: e, ctx: r, workspace: s }));
4985
4989
  });
4986
- function eo({
4990
+ function ro({
4987
4991
  widgetCtx: t,
4988
4992
  config: e = t.config,
4989
4993
  children: r
4990
4994
  }) {
4991
4995
  const n = X(
4992
- () => new Hi(t),
4996
+ () => new Qi(t),
4993
4997
  [t]
4994
4998
  );
4995
4999
  F(() => n.mount(), [n]);
4996
5000
  const { chats: s, activeId: o } = H(n.state), l = s.find((y) => y.id === o), u = X(
4997
- () => s.map((y) => /* @__PURE__ */ K.createElement(
4998
- Xi,
5001
+ () => s.map((y) => /* @__PURE__ */ Y.createElement(
5002
+ to,
4999
5003
  {
5000
5004
  key: y.id,
5001
5005
  chatId: y.id,
@@ -5006,9 +5010,9 @@ function eo({
5006
5010
  )),
5007
5011
  [s, e, n]
5008
5012
  );
5009
- return /* @__PURE__ */ K.createElement(fn.Provider, { value: n }, u, /* @__PURE__ */ K.createElement(Ji, { connection: l.connection }, /* @__PURE__ */ K.createElement(St.Provider, { value: l.ui }, r(l.ctx))));
5013
+ return /* @__PURE__ */ Y.createElement(mn.Provider, { value: n }, u, /* @__PURE__ */ Y.createElement(Ki, { connection: l.connection }, /* @__PURE__ */ Y.createElement(St.Provider, { value: l.ui }, r(l.ctx))));
5010
5014
  }
5011
- class to {
5015
+ class no {
5012
5016
  constructor(e) {
5013
5017
  this.components = [];
5014
5018
  const { components: r } = e;
@@ -5034,22 +5038,22 @@ class to {
5034
5038
  return (r = this.get(e)) == null ? void 0 : r.component;
5035
5039
  }
5036
5040
  }
5037
- const wr = L.object({
5041
+ const Ar = L.object({
5038
5042
  org_id: L.string(),
5039
5043
  contact: L.object({ id: L.string(), verified: L.boolean() }),
5040
5044
  mcp_access: L.object({
5041
5045
  server_ids: L.array(L.string()),
5042
5046
  account_id: L.string().optional()
5043
5047
  }).optional()
5044
- }), ro = L.union([
5048
+ }), so = L.union([
5045
5049
  L.object({
5046
5050
  sub: L.object({
5047
5051
  type: L.literal("widget-contact"),
5048
- payload: wr
5052
+ payload: Ar
5049
5053
  })
5050
5054
  }).transform(({ sub: t }) => t.payload),
5051
- wr
5052
- ]), no = (t) => {
5055
+ Ar
5056
+ ]), ao = (t) => {
5053
5057
  const e = t.split(".")[1];
5054
5058
  if (!e) return null;
5055
5059
  try {
@@ -5061,7 +5065,7 @@ const wr = L.object({
5061
5065
  } catch {
5062
5066
  return null;
5063
5067
  }
5064
- }, so = (t) => {
5068
+ }, io = (t) => {
5065
5069
  var s, o;
5066
5070
  const e = t.user, r = e == null ? void 0 : e.token;
5067
5071
  if (!r)
@@ -5071,7 +5075,7 @@ const wr = L.object({
5071
5075
  externalId: (e == null ? void 0 : e.externalId) ?? null,
5072
5076
  verifiedOwner: null
5073
5077
  });
5074
- const n = ro.safeParse(no(r));
5078
+ const n = so.safeParse(ao(r));
5075
5079
  return n.success ? JSON.stringify({
5076
5080
  apiUrl: t.apiUrl ?? null,
5077
5081
  botToken: t.token,
@@ -5089,8 +5093,8 @@ const wr = L.object({
5089
5093
  externalId: e.externalId ?? null,
5090
5094
  opaqueToken: r
5091
5095
  });
5092
- }, gn = Ye(null);
5093
- function To({
5096
+ }, hn = Ye(null);
5097
+ function _o({
5094
5098
  options: t,
5095
5099
  children: e,
5096
5100
  components: r,
@@ -5098,11 +5102,11 @@ function To({
5098
5102
  loadingComponent: s,
5099
5103
  errorComponent: o
5100
5104
  }) {
5101
- var T;
5102
- const l = P(Promise.resolve()), u = P(t);
5105
+ var x;
5106
+ const l = R(Promise.resolve()), u = R(t);
5103
5107
  u.current = t;
5104
- const y = so(t), g = P(null), i = P(null), d = P(null), [p, b] = J({ status: "loading" }), R = X(
5105
- () => new to({
5108
+ const y = io(t), g = R(null), i = R(null), d = R(null), [p, b] = J({ status: "loading" }), P = X(
5109
+ () => new no({
5106
5110
  components: r
5107
5111
  }),
5108
5112
  [r]
@@ -5121,7 +5125,7 @@ function To({
5121
5125
  ((m = i.current) == null ? void 0 : m.identity) !== y && (b({ status: "loading" }), i.current = {
5122
5126
  identity: y,
5123
5127
  request: l.current.then(
5124
- () => zn.initialize({
5128
+ () => Vn.initialize({
5125
5129
  config: t,
5126
5130
  storage: n,
5127
5131
  getClientCapabilities: () => u.current.capabilities,
@@ -5147,7 +5151,7 @@ function To({
5147
5151
  var S;
5148
5152
  if (((S = i.current) == null ? void 0 : S.request) !== w) return;
5149
5153
  const h = f instanceof Error ? f : new Error("Widget initialization failed", { cause: f });
5150
- oe.error("widget initialization failed", h), b({
5154
+ le.error("widget initialization failed", h), b({
5151
5155
  status: "error",
5152
5156
  identity: I,
5153
5157
  error: h
@@ -5160,39 +5164,39 @@ function To({
5160
5164
  i.current = null, (w = d.current) == null || w.widgetCtx.dispose(), d.current = null;
5161
5165
  },
5162
5166
  []
5163
- ), Ln(() => {
5167
+ ), kn(() => {
5164
5168
  var w;
5165
5169
  p.status !== "ready" || p.identity !== y || (w = t.user) != null && w.token && p.widgetCtx.api.setAuthToken(t.user.token);
5166
- }, [(T = t.user) == null ? void 0 : T.token, y, p]), p.status === "loading" || "identity" in p && p.identity !== y)
5167
- return s ? /* @__PURE__ */ K.createElement(K.Fragment, null, s) : null;
5170
+ }, [(x = t.user) == null ? void 0 : x.token, y, p]), p.status === "loading" || "identity" in p && p.identity !== y)
5171
+ return s ? /* @__PURE__ */ Y.createElement(Y.Fragment, null, s) : null;
5168
5172
  if (p.status === "error")
5169
- return o ? /* @__PURE__ */ K.createElement(K.Fragment, null, o(p.error)) : null;
5170
- const { widgetCtx: M } = p, O = (w, I) => /* @__PURE__ */ K.createElement(
5171
- gn.Provider,
5173
+ return o ? /* @__PURE__ */ Y.createElement(Y.Fragment, null, o(p.error)) : null;
5174
+ const { widgetCtx: M } = p, O = (w, I) => /* @__PURE__ */ Y.createElement(
5175
+ hn.Provider,
5172
5176
  {
5173
5177
  value: {
5174
5178
  widgetCtx: w,
5175
5179
  config: t,
5176
5180
  components: r,
5177
- componentStore: R,
5178
- version: _r,
5181
+ componentStore: P,
5182
+ version: Rr,
5179
5183
  contentIframeRef: g
5180
5184
  }
5181
5185
  },
5182
5186
  I
5183
5187
  );
5184
- return t.displayMode === "companion" && !t.inline ? /* @__PURE__ */ K.createElement(eo, { widgetCtx: M, config: t }, (w) => O(w, e)) : O(
5188
+ return t.displayMode === "companion" && !t.inline ? /* @__PURE__ */ Y.createElement(ro, { widgetCtx: M, config: t }, (w) => O(w, e)) : O(
5185
5189
  M,
5186
- /* @__PURE__ */ K.createElement(pn, { key: y, widgetCtx: M, config: t }, e)
5190
+ /* @__PURE__ */ Y.createElement(fn, { key: y, widgetCtx: M, config: t }, e)
5187
5191
  );
5188
5192
  }
5189
- function ne() {
5190
- const t = $e(gn);
5193
+ function se() {
5194
+ const t = Fe(hn);
5191
5195
  if (!t)
5192
5196
  throw new Error("useWidget must be used within a WidgetProvider");
5193
5197
  return t;
5194
5198
  }
5195
- function Mo({
5199
+ function Ro({
5196
5200
  liveItems: t,
5197
5201
  turnSources: e
5198
5202
  }) {
@@ -5206,8 +5210,8 @@ function Mo({
5206
5210
  if (o) return o.plan;
5207
5211
  }
5208
5212
  }
5209
- function _o() {
5210
- const { config: t, widgetCtx: e } = ne(), { name: r, avatarUrl: n } = e.agent, s = t.bot;
5213
+ function Po() {
5214
+ const { config: t, widgetCtx: e } = se(), { name: r, avatarUrl: n } = e.agent, s = t.bot;
5211
5215
  return X(
5212
5216
  () => ({
5213
5217
  isAi: !0,
@@ -5220,21 +5224,21 @@ function _o() {
5220
5224
  );
5221
5225
  }
5222
5226
  function It() {
5223
- const { config: t } = ne();
5227
+ const { config: t } = se();
5224
5228
  return t;
5225
5229
  }
5226
- function Po() {
5227
- const { config: t } = ne();
5230
+ function Oo() {
5231
+ const { config: t } = se();
5228
5232
  return t.displayMode ?? "popover";
5229
5233
  }
5230
- function Ro() {
5231
- const { widgetCtx: t } = ne();
5234
+ function No() {
5235
+ const { widgetCtx: t } = se();
5232
5236
  return {
5233
5237
  contactState: H(t.contactCtx.state),
5234
5238
  createUnverifiedContact: t.contactCtx.createUnverifiedContact
5235
5239
  };
5236
5240
  }
5237
- function ao() {
5241
+ function oo() {
5238
5242
  const [t, e] = J("ltr");
5239
5243
  return F(() => {
5240
5244
  const r = () => {
@@ -5255,8 +5259,8 @@ function ao() {
5255
5259
  };
5256
5260
  }, []), { dir: t };
5257
5261
  }
5258
- const io = 500, kt = "opencx:context-changed";
5259
- function hn() {
5262
+ const lo = 500, kt = "opencx:context-changed";
5263
+ function yn() {
5260
5264
  if (typeof window > "u") return null;
5261
5265
  try {
5262
5266
  const t = window.top ?? window;
@@ -5265,29 +5269,29 @@ function hn() {
5265
5269
  return null;
5266
5270
  }
5267
5271
  }
5268
- function oo(t) {
5269
- const e = hn();
5272
+ function co(t) {
5273
+ const e = yn();
5270
5274
  if (!e) return () => {
5271
5275
  };
5272
5276
  const r = (s) => {
5273
- (s == null ? void 0 : s.type) === kt && (yn += 1), t();
5277
+ (s == null ? void 0 : s.type) === kt && (vn += 1), t();
5274
5278
  };
5275
5279
  e.addEventListener("popstate", r), e.addEventListener("hashchange", r), e.addEventListener(kt, r);
5276
- const n = e.setInterval(r, io);
5280
+ const n = e.setInterval(r, lo);
5277
5281
  return () => {
5278
5282
  e.removeEventListener("popstate", r), e.removeEventListener("hashchange", r), e.removeEventListener(kt, r), e.clearInterval(n);
5279
5283
  };
5280
5284
  }
5281
- let yn = 0;
5282
- function lo() {
5285
+ let vn = 0;
5286
+ function uo() {
5283
5287
  var t;
5284
- return `${yn}|${((t = hn()) == null ? void 0 : t.location.href) ?? ""}`;
5288
+ return `${vn}|${((t = yn()) == null ? void 0 : t.location.href) ?? ""}`;
5285
5289
  }
5286
- function Oo() {
5287
- return zt(oo, lo, () => "");
5290
+ function Do() {
5291
+ return zt(co, uo, () => "");
5288
5292
  }
5289
- function vn() {
5290
- const { widgetCtx: t } = ne(), e = H(t.messageCtx.state), { isStreaming: r } = dn();
5293
+ function bn() {
5294
+ const { widgetCtx: t } = se(), e = H(t.messageCtx.state), { isStreaming: r } = pn();
5291
5295
  return {
5292
5296
  messagesState: r ? { ...e, isSendingMessage: !0, isSendingMessageToAI: !0 } : e,
5293
5297
  sendMessage: t.messageCtx.sendMessage,
@@ -5297,12 +5301,12 @@ function vn() {
5297
5301
  getSentTextHistory: t.messageCtx.getSentTextHistory
5298
5302
  };
5299
5303
  }
5300
- function bn() {
5304
+ function Sn() {
5301
5305
  var y;
5302
- const { widgetCtx: t } = ne(), { oneOpenSessionAllowed: e } = It(), r = H(t.sessionCtx.sessionState), n = H(t.sessionCtx.sessionsState), { openSessions: s, closedSessions: o } = X(() => ({
5306
+ const { widgetCtx: t } = se(), { oneOpenSessionAllowed: e } = It(), r = H(t.sessionCtx.sessionState), n = H(t.sessionCtx.sessionsState), { openSessions: s, closedSessions: o } = X(() => ({
5303
5307
  openSessions: n.data.filter((g) => g.isOpened === !0),
5304
5308
  closedSessions: n.data.filter((g) => g.isOpened === !1)
5305
- }), [n.data]), { workspace: l } = mn(), u = l ? l.canCreateChat() : !e || s.length === 0 && !r.isCreatingSession && !((y = r.session) != null && y.isOpened);
5309
+ }), [n.data]), { workspace: l } = gn(), u = l ? l.canCreateChat() : !e || s.length === 0 && !r.isCreatingSession && !((y = r.session) != null && y.isOpened);
5306
5310
  return {
5307
5311
  sessionState: r,
5308
5312
  sessionsState: n,
@@ -5314,30 +5318,30 @@ function bn() {
5314
5318
  canCreateNewSession: u
5315
5319
  };
5316
5320
  }
5317
- function No() {
5321
+ function Lo() {
5318
5322
  var l, u;
5319
- const { sessionState: t } = bn(), { messagesState: e } = vn(), r = ((l = t.session) == null ? void 0 : l.assignee.kind) === "ai", n = (u = e.messages) == null ? void 0 : u.at(-1), s = (n == null ? void 0 : n.type) === "USER" && n.id !== e.settledAgentUserMessageId;
5323
+ const { sessionState: t } = Sn(), { messagesState: e } = bn(), r = ((l = t.session) == null ? void 0 : l.assignee.kind) === "ai", n = (u = e.messages) == null ? void 0 : u.at(-1), s = (n == null ? void 0 : n.type) === "USER" && n.id !== e.settledAgentUserMessageId;
5320
5324
  return { isAwaitingBotReply: !!(e.isSendingMessageToAI || (r || t.isCreatingSession) && (e.isSendingMessage || s)) };
5321
5325
  }
5322
- function co() {
5323
- const { widgetCtx: t } = ne();
5326
+ function po() {
5327
+ const { widgetCtx: t } = se();
5324
5328
  return {
5325
5329
  routerState: H(t.routerCtx.state),
5326
5330
  toSessionsScreen: t.routerCtx.toSessionsScreen,
5327
5331
  toChatScreen: t.routerCtx.toChatScreen
5328
5332
  };
5329
5333
  }
5330
- function Do() {
5331
- const { widgetCtx: t } = ne(), { unreadSessionIds: e, count: r } = H(
5334
+ function jo() {
5335
+ const { widgetCtx: t } = se(), { unreadSessionIds: e, count: r } = H(
5332
5336
  t.unreadCtx.state
5333
- ), n = Z(
5337
+ ), n = z(
5334
5338
  (s) => e.includes(s),
5335
5339
  [e]
5336
5340
  );
5337
5341
  return { count: r, hasUnread: r > 0, unreadSessionIds: e, isUnread: n };
5338
5342
  }
5339
- const Sn = Ye(null);
5340
- function Lo({ children: t }) {
5343
+ const In = Ye(null);
5344
+ function ko({ children: t }) {
5341
5345
  const e = It(), [r, n] = J(() => e.inline ? !0 : e.isOpen ?? !1);
5342
5346
  return F(() => {
5343
5347
  n((s) => e.isOpen ?? s);
@@ -5347,25 +5351,25 @@ function Lo({ children: t }) {
5347
5351
  return;
5348
5352
  const o = setTimeout(() => n(!0), s * 1e3);
5349
5353
  return () => clearTimeout(o);
5350
- }, [e.openAfterNSeconds]), /* @__PURE__ */ K.createElement(Sn.Provider, { value: { isOpen: r, setIsOpen: n } }, t);
5354
+ }, [e.openAfterNSeconds]), /* @__PURE__ */ Y.createElement(In.Provider, { value: { isOpen: r, setIsOpen: n } }, t);
5351
5355
  }
5352
- function uo() {
5353
- const t = $e(Sn);
5356
+ function fo() {
5357
+ const t = Fe(In);
5354
5358
  if (!t)
5355
5359
  throw new Error(
5356
5360
  "useWidgetTrigger must be used within a WidgetTriggerProvider"
5357
5361
  );
5358
5362
  return t;
5359
5363
  }
5360
- const po = (t) => (document.addEventListener("visibilitychange", t), () => document.removeEventListener("visibilitychange", t)), fo = () => document.visibilityState !== "hidden";
5361
- function jo({
5364
+ const mo = (t) => (document.addEventListener("visibilitychange", t), () => document.removeEventListener("visibilitychange", t)), go = () => document.visibilityState !== "hidden";
5365
+ function $o({
5362
5366
  transcriptVisible: t = !0
5363
5367
  } = {}) {
5364
- const { widgetCtx: e } = ne(), { isOpen: r } = uo(), { routerState: n } = co(), { session: s } = H(e.sessionCtx.sessionState), { isInitialFetchLoading: o } = H(
5368
+ const { widgetCtx: e } = se(), { isOpen: r } = fo(), { routerState: n } = po(), { session: s } = H(e.sessionCtx.sessionState), { isInitialFetchLoading: o } = H(
5365
5369
  e.messageCtx.state
5366
5370
  ), l = zt(
5367
- po,
5368
- fo,
5371
+ mo,
5372
+ go,
5369
5373
  () => !0
5370
5374
  ), u = r && l && t && n.screen === "chat" && !o ? (s == null ? void 0 : s.id) ?? null : null;
5371
5375
  F(() => {
@@ -5375,10 +5379,10 @@ function jo({
5375
5379
  [e]
5376
5380
  );
5377
5381
  }
5378
- function ko() {
5382
+ function Fo() {
5379
5383
  const {
5380
5384
  widgetCtx: { uploadCtx: t }
5381
- } = ne(), e = H(t.state), r = X(
5385
+ } = se(), e = H(t.state), r = X(
5382
5386
  () => e.filter((n) => n.status === "success" && n.fileUrl),
5383
5387
  [e]
5384
5388
  );
@@ -5401,26 +5405,26 @@ function ko() {
5401
5405
  isUploading: e.some((n) => n.status === "uploading")
5402
5406
  };
5403
5407
  }
5404
- function mo(t) {
5408
+ function ho(t) {
5405
5409
  return t !== "fullscreen";
5406
5410
  }
5407
- const In = Ye(null);
5408
- function $o({ children: t }) {
5411
+ const En = Ye(null);
5412
+ function Uo({ children: t }) {
5409
5413
  var s, o;
5410
- const { companion: e } = It(), { dir: r } = ao(), { widgetCtx: n } = ne();
5411
- return /* @__PURE__ */ K.createElement(
5412
- go,
5414
+ const { companion: e } = It(), { dir: r } = oo(), { widgetCtx: n } = se();
5415
+ return /* @__PURE__ */ Y.createElement(
5416
+ yo,
5413
5417
  {
5414
5418
  configuredDefaultLayout: e == null ? void 0 : e.defaultLayout,
5415
5419
  configuredLayouts: e == null ? void 0 : e.layouts,
5416
- configuredSidebarSide: Vn((s = e == null ? void 0 : e.sidebar) == null ? void 0 : s.side, r),
5417
- configuredSidebarMode: Zn((o = e == null ? void 0 : e.sidebar) == null ? void 0 : o.mode),
5420
+ configuredSidebarSide: Wn((s = e == null ? void 0 : e.sidebar) == null ? void 0 : s.side, r),
5421
+ configuredSidebarMode: Bn((o = e == null ? void 0 : e.sidebar) == null ? void 0 : o.mode),
5418
5422
  storage: n.storageCtx
5419
5423
  },
5420
5424
  t
5421
5425
  );
5422
5426
  }
5423
- function go({
5427
+ function yo({
5424
5428
  configuredDefaultLayout: t,
5425
5429
  configuredLayouts: e,
5426
5430
  configuredSidebarSide: r,
@@ -5428,7 +5432,7 @@ function go({
5428
5432
  storage: s,
5429
5433
  children: o
5430
5434
  }) {
5431
- const l = Bn(e), u = Wn(
5435
+ const l = Jn(e), u = Yn(
5432
5436
  t,
5433
5437
  l
5434
5438
  ), y = l.join("|"), [g, i] = J(u), [d, p] = J({
@@ -5441,26 +5445,26 @@ function go({
5441
5445
  const N = typeof h == "function" ? h(S) : h;
5442
5446
  return l.includes(N) ? N : S;
5443
5447
  });
5444
- }, R = P(l);
5445
- R.current = l;
5448
+ }, P = R(l);
5449
+ P.current = l;
5446
5450
  const M = (h) => {
5447
- b(h), R.current.includes(h) && mo(h) && (s == null || s.setCompanionLayout(h).catch(() => {
5451
+ b(h), P.current.includes(h) && ho(h) && (s == null || s.setCompanionLayout(h).catch(() => {
5448
5452
  }));
5449
- }, [O, T] = J(r), [w, I] = J(n), [C, c] = J({
5453
+ }, [O, x] = J(r), [w, I] = J(n), [C, c] = J({
5450
5454
  side: r,
5451
5455
  mode: n
5452
5456
  });
5453
5457
  (C.side !== r || C.mode !== n) && (c({
5454
5458
  side: r,
5455
5459
  mode: n
5456
- }), C.side !== r && T(r), C.mode !== n && I(n)), F(() => {
5460
+ }), C.side !== r && x(r), C.mode !== n && I(n)), F(() => {
5457
5461
  if (!s) return;
5458
5462
  let h = !1;
5459
5463
  return s.getCompanionLayout().then((S) => {
5460
- h || !S || R.current.includes(S) && i(S);
5464
+ h || !S || P.current.includes(S) && i(S);
5461
5465
  }).catch(() => {
5462
5466
  }), s.getCompanionSidebarSide().then((S) => {
5463
- !h && S && T(S);
5467
+ !h && S && x(S);
5464
5468
  }).catch(() => {
5465
5469
  }), s.getCompanionSidebarMode().then((S) => {
5466
5470
  !h && S && I(S);
@@ -5469,21 +5473,21 @@ function go({
5469
5473
  h = !0;
5470
5474
  };
5471
5475
  }, [s]);
5472
- const m = Z(
5476
+ const m = z(
5473
5477
  (h) => {
5474
- T(h), s == null || s.setCompanionSidebarSide(h).catch(() => {
5478
+ x(h), s == null || s.setCompanionSidebarSide(h).catch(() => {
5475
5479
  });
5476
5480
  },
5477
5481
  [s]
5478
- ), f = Z(
5482
+ ), f = z(
5479
5483
  (h) => {
5480
5484
  I(h), s == null || s.setCompanionSidebarMode(h).catch(() => {
5481
5485
  });
5482
5486
  },
5483
5487
  [s]
5484
5488
  );
5485
- return /* @__PURE__ */ K.createElement(
5486
- In.Provider,
5489
+ return /* @__PURE__ */ Y.createElement(
5490
+ En.Provider,
5487
5491
  {
5488
5492
  value: {
5489
5493
  layout: g,
@@ -5500,17 +5504,17 @@ function go({
5500
5504
  o
5501
5505
  );
5502
5506
  }
5503
- function Fo() {
5504
- const t = $e(In);
5507
+ function qo() {
5508
+ const t = Fe(En);
5505
5509
  if (!t)
5506
5510
  throw new Error(
5507
5511
  "useWidgetLayout must be used within a WidgetLayoutProvider"
5508
5512
  );
5509
5513
  return t;
5510
5514
  }
5511
- function Uo() {
5515
+ function zo() {
5512
5516
  var u, y;
5513
- const { widgetCtx: t } = ne(), { modesComponents: e } = It(), { sessionState: r } = bn(), n = t.modes, s = (u = r.session) == null ? void 0 : u.modeId, o = n.find((g) => g.id === s), l = (y = e == null ? void 0 : e.find(
5517
+ const { widgetCtx: t } = se(), { modesComponents: e } = It(), { sessionState: r } = Sn(), n = t.modes, s = (u = r.session) == null ? void 0 : u.modeId, o = n.find((g) => g.id === s), l = (y = e == null ? void 0 : e.find(
5514
5518
  (g) => {
5515
5519
  var i, d;
5516
5520
  return [
@@ -5528,10 +5532,10 @@ function Uo() {
5528
5532
  Component: l
5529
5533
  };
5530
5534
  }
5531
- function qo() {
5532
- const { widgetCtx: t } = ne(), {
5535
+ function Zo() {
5536
+ const { widgetCtx: t } = se(), {
5533
5537
  messagesState: { messages: e }
5534
- } = vn(), {
5538
+ } = bn(), {
5535
5539
  csatRequestedMessage: r,
5536
5540
  isCsatRequested: n,
5537
5541
  csatSubmittedMessage: s,
@@ -5563,10 +5567,10 @@ function qo() {
5563
5567
  submittedFeedback: u
5564
5568
  };
5565
5569
  }
5566
- function zo(t) {
5567
- const { widgetCtx: e } = ne(), r = e.dictationCtx, n = H(r.state), s = P(t);
5570
+ function Vo(t) {
5571
+ const { widgetCtx: e } = se(), r = e.dictationCtx, n = H(r.state), s = R(t);
5568
5572
  s.current = t;
5569
- const o = Z(() => {
5573
+ const o = z(() => {
5570
5574
  r.start({
5571
5575
  getValue: () => s.current.getValue(),
5572
5576
  setValue: (u) => s.current.setValue(u),
@@ -5575,7 +5579,7 @@ function zo(t) {
5575
5579
  return (y = (u = s.current).onSend) == null ? void 0 : y.call(u);
5576
5580
  }
5577
5581
  });
5578
- }, [r]), l = Z(() => {
5582
+ }, [r]), l = z(() => {
5579
5583
  r.isActive() ? r.stop() : o();
5580
5584
  }, [r, o]);
5581
5585
  return F(() => () => r.stop({ executeFinalCommand: !1 }), [r]), {
@@ -5591,22 +5595,22 @@ function zo(t) {
5591
5595
  prewarm: r.prewarm
5592
5596
  };
5593
5597
  }
5594
- function Zo() {
5595
- const { widgetCtx: t } = ne(), e = t.messageCtx.draftState, r = H(e), n = Z(
5598
+ function Bo() {
5599
+ const { widgetCtx: t } = se(), e = t.messageCtx.draftState, r = H(e), n = z(
5596
5600
  (l) => {
5597
5601
  e.setPartial({
5598
5602
  text: typeof l == "function" ? l(e.get().text) : l
5599
5603
  });
5600
5604
  },
5601
5605
  [e]
5602
- ), s = Z(
5606
+ ), s = z(
5603
5607
  (l) => {
5604
5608
  e.setPartial({
5605
5609
  mentions: typeof l == "function" ? l(e.get().mentions) : l
5606
5610
  });
5607
5611
  },
5608
5612
  [e]
5609
- ), o = Z(
5613
+ ), o = z(
5610
5614
  (l = r) => e.get() !== l ? !1 : (e.reset(), !0),
5611
5615
  [e, r]
5612
5616
  );
@@ -5614,35 +5618,35 @@ function Zo() {
5614
5618
  }
5615
5619
  export {
5616
5620
  kt as HOST_CONTEXT_CHANGED_EVENT,
5617
- $o as WidgetLayoutProvider,
5618
- To as WidgetProvider,
5619
- Lo as WidgetTriggerProvider,
5620
- mr as applyPresentation,
5621
- wo as formatAskQuestionsAnswers,
5622
- Mo as sessionPlan,
5623
- dn as useAgentChatUi,
5624
- _o as useBot,
5625
- xo as useCompanionChats,
5626
- Zo as useComposerDraft,
5621
+ Uo as WidgetLayoutProvider,
5622
+ _o as WidgetProvider,
5623
+ ko as WidgetTriggerProvider,
5624
+ gr as applyPresentation,
5625
+ xo as formatAskQuestionsAnswers,
5626
+ Ro as sessionPlan,
5627
+ pn as useAgentChatUi,
5628
+ Po as useBot,
5629
+ Mo as useCompanionChats,
5630
+ Bo as useComposerDraft,
5627
5631
  It as useConfig,
5628
- Ao as useConnection,
5629
- Ro as useContact,
5630
- qo as useCsat,
5631
- zo as useDictation,
5632
- Po as useDisplayMode,
5633
- ao as useDocumentDir,
5634
- Oo as useHostLocation,
5635
- No as useIsAwaitingBotReply,
5636
- vn as useMessages,
5637
- Uo as useModes,
5632
+ To as useConnection,
5633
+ No as useContact,
5634
+ Zo as useCsat,
5635
+ Vo as useDictation,
5636
+ Oo as useDisplayMode,
5637
+ oo as useDocumentDir,
5638
+ Do as useHostLocation,
5639
+ Lo as useIsAwaitingBotReply,
5640
+ bn as useMessages,
5641
+ zo as useModes,
5638
5642
  H as usePrimitiveState,
5639
- bn as useSessions,
5640
- Do as useUnread,
5641
- jo as useUnreadViewing,
5642
- ko as useUploadFiles,
5643
- ne as useWidget,
5644
- Fo as useWidgetLayout,
5645
- co as useWidgetRouter,
5646
- uo as useWidgetTrigger
5643
+ Sn as useSessions,
5644
+ jo as useUnread,
5645
+ $o as useUnreadViewing,
5646
+ Fo as useUploadFiles,
5647
+ se as useWidget,
5648
+ qo as useWidgetLayout,
5649
+ po as useWidgetRouter,
5650
+ fo as useWidgetTrigger
5647
5651
  };
5648
5652
  //# sourceMappingURL=index.js.map