@opencx/widget-react-headless 5.3.0 → 5.4.0

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,13 +1,13 @@
1
- import K, { useSyncExternalStore as Ke, useRef as R, useCallback as U, useEffect as z, useMemo as te, useState as J, createContext as qe, useContext as Ne, memo as ya, useLayoutEffect as ba } from "react";
2
- import { isAgentStreamKeepalive as Ca, isRecord as Sa, genUuid as Et, buildSendMessageBody as Ea, log as ye, resolveClientPresentation as wa, ConnectionRequestExpiredError as Ia, ConnectionAttemptUnavailableError as _a, PrimitiveState as Er, WidgetCtx as Aa, resolveSidebarMode as Ta, resolveSidebarSide as xa, normalizeCompanionLayouts as Ma, resolveCompanionDefaultLayout as Pa } from "@opencx/widget-core";
1
+ import K, { useSyncExternalStore as $e, useRef as R, useCallback as U, useEffect as q, useMemo as te, useState as J, createContext as ze, useContext as Ne, memo as ya, useLayoutEffect as ba } from "react";
2
+ import { isAgentStreamKeepalive as Ca, isRecord as Sa, genUuid as Et, buildSendMessageBody as Ea, log as ye, resolveClientPresentation as wa, ConnectionRequestExpiredError as Ia, ConnectionAttemptUnavailableError as _a, PrimitiveState as Er, WidgetCtx as Aa, resolveSidebarMode as xa, resolveSidebarSide as Ta, normalizeCompanionLayouts as Ma, resolveCompanionDefaultLayout as Pa } from "@opencx/widget-core";
3
3
  import * as Jt from "zod/v4";
4
4
  import { z as o } from "zod/v4";
5
5
  import { ZodFirstPartyTypeKind as P } from "zod/v3";
6
6
  import "react/jsx-runtime";
7
7
  import { z as N } from "zod";
8
- const Ra = "5.3.0";
9
- function G(t) {
10
- return Ke(t.subscribe, t.get, t.get);
8
+ const Ra = "5.4.0";
9
+ function H(t) {
10
+ return $e(t.subscribe, t.get, t.get);
11
11
  }
12
12
  function Oa({
13
13
  turnSources: t,
@@ -59,7 +59,7 @@ var wr = "vercel.ai.error", ja = Symbol.for(wr), Kt, Yt, ge = class Ir extends (
59
59
  function _r(t) {
60
60
  return t == null ? "unknown error" : typeof t == "string" ? t : t instanceof Error ? t.toString() : JSON.stringify(t);
61
61
  }
62
- var Ar = "AI_InvalidArgumentError", Tr = `vercel.ai.error.${Ar}`, Da = Symbol.for(Tr), Ht, Gt, ka = class extends (Gt = ge, Ht = Da, Gt) {
62
+ var Ar = "AI_InvalidArgumentError", xr = `vercel.ai.error.${Ar}`, Da = Symbol.for(xr), Ht, Gt, ka = class extends (Gt = ge, Ht = Da, Gt) {
63
63
  constructor({
64
64
  message: t,
65
65
  cause: e,
@@ -68,12 +68,12 @@ var Ar = "AI_InvalidArgumentError", Tr = `vercel.ai.error.${Ar}`, Da = Symbol.fo
68
68
  super({ name: Ar, message: t, cause: e }), this[Ht] = !0, this.argument = r;
69
69
  }
70
70
  static isInstance(t) {
71
- return ge.hasMarker(t, Tr);
71
+ return ge.hasMarker(t, xr);
72
72
  }
73
- }, xr = "AI_JSONParseError", Mr = `vercel.ai.error.${xr}`, La = Symbol.for(Mr), Qt, Xt, er = class extends (Xt = ge, Qt = La, Xt) {
73
+ }, Tr = "AI_JSONParseError", Mr = `vercel.ai.error.${Tr}`, La = Symbol.for(Mr), Qt, Xt, er = class extends (Xt = ge, Qt = La, Xt) {
74
74
  constructor({ text: t, cause: e }) {
75
75
  super({
76
- name: xr,
76
+ name: Tr,
77
77
  message: `JSON parsing failed: Text: ${t}.
78
78
  Error message: ${_r(e)}`,
79
79
  cause: e
@@ -82,7 +82,7 @@ Error message: ${_r(e)}`,
82
82
  static isInstance(t) {
83
83
  return ge.hasMarker(t, Mr);
84
84
  }
85
- }, Pr = "AI_TypeValidationError", Rr = `vercel.ai.error.${Pr}`, Fa = Symbol.for(Rr), tr, rr, Ue = class Pt extends (rr = ge, tr = Fa, rr) {
85
+ }, Pr = "AI_TypeValidationError", Rr = `vercel.ai.error.${Pr}`, Fa = Symbol.for(Rr), tr, rr, qe = class Pt extends (rr = ge, tr = Fa, rr) {
86
86
  constructor({
87
87
  value: e,
88
88
  cause: r,
@@ -129,7 +129,7 @@ class wt extends Error {
129
129
  super(e), this.name = "ParseError", this.type = r.type, this.field = r.field, this.value = r.value, this.line = r.line;
130
130
  }
131
131
  }
132
- const ar = 10, $a = 13, xe = 32;
132
+ const ar = 10, $a = 13, Te = 32;
133
133
  function It(t) {
134
134
  }
135
135
  function Ua(t) {
@@ -180,7 +180,7 @@ function Ua(t) {
180
180
  }
181
181
  const h = g.charCodeAt(m);
182
182
  if (nr(g, m, h)) {
183
- const w = g.charCodeAt(m + 5) === xe ? m + 6 : m + 5, k = g.slice(w, y);
183
+ const w = g.charCodeAt(m + 5) === Te ? m + 6 : m + 5, k = g.slice(w, y);
184
184
  if (d === 0 && g.charCodeAt(y + 1) === ar) {
185
185
  e({ id: c, event: C, data: k }), c = void 0, p = "", C = void 0, m = y + 2, y = g.indexOf(`
186
186
  `, m);
@@ -189,7 +189,7 @@ function Ua(t) {
189
189
  p = d === 0 ? k : `${p}
190
190
  ${k}`, d++;
191
191
  } else sr(g, m, h) ? C = g.slice(
192
- g.charCodeAt(m + 6) === xe ? m + 7 : m + 6,
192
+ g.charCodeAt(m + 6) === Te ? m + 7 : m + 6,
193
193
  y
194
194
  ) || void 0 : _(g, m, y);
195
195
  m = y + 1, y = g.indexOf(`
@@ -214,24 +214,24 @@ ${k}`, d++;
214
214
  }
215
215
  const h = g.charCodeAt(m);
216
216
  if (nr(g, m, h)) {
217
- const $ = g.charCodeAt(m + 5) === xe ? m + 6 : m + 5, W = g.slice($, y);
217
+ const $ = g.charCodeAt(m + 5) === Te ? m + 6 : m + 5, W = g.slice($, y);
218
218
  p = d === 0 ? W : `${p}
219
219
  ${W}`, d++;
220
220
  return;
221
221
  }
222
222
  if (sr(g, m, h)) {
223
- C = g.slice(g.charCodeAt(m + 6) === xe ? m + 7 : m + 6, y) || void 0;
223
+ C = g.slice(g.charCodeAt(m + 6) === Te ? m + 7 : m + 6, y) || void 0;
224
224
  return;
225
225
  }
226
226
  if (h === 105 && g.charCodeAt(m + 1) === 100 && g.charCodeAt(m + 2) === 58) {
227
- const $ = g.slice(g.charCodeAt(m + 3) === xe ? m + 4 : m + 3, y);
227
+ const $ = g.slice(g.charCodeAt(m + 3) === Te ? m + 4 : m + 3, y);
228
228
  c = $.includes("\0") ? void 0 : $;
229
229
  return;
230
230
  }
231
231
  if (h === 58) {
232
232
  if (n) {
233
233
  const $ = g.slice(m, y);
234
- n($.slice(g.charCodeAt(m + 1) === xe ? 2 : 1));
234
+ n($.slice(g.charCodeAt(m + 1) === Te ? 2 : 1));
235
235
  }
236
236
  return;
237
237
  }
@@ -240,7 +240,7 @@ ${W}`, d++;
240
240
  S(w, "", w);
241
241
  return;
242
242
  }
243
- const D = w.slice(0, k), V = w.charCodeAt(k + 1) === xe ? 2 : 1, Z = w.slice(k + V);
243
+ const D = w.slice(0, k), B = w.charCodeAt(k + 1) === Te ? 2 : 1, Z = w.slice(k + B);
244
244
  S(D, Z, w);
245
245
  }
246
246
  function S(g, m, y) {
@@ -360,12 +360,12 @@ function Za(t) {
360
360
  var e, r;
361
361
  return (r = (e = globalThis.Buffer) == null ? void 0 : e.isBuffer(t)) != null ? r : !1;
362
362
  }
363
- var Wa = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/, Ba = /"(?: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*:/;
363
+ var Wa = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/, Va = /"(?: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*:/;
364
364
  function ir(t) {
365
365
  const e = JSON.parse(t);
366
- return e === null || typeof e != "object" || Wa.test(t) === !1 && Ba.test(t) === !1 ? e : Va(e);
366
+ return e === null || typeof e != "object" || Wa.test(t) === !1 && Va.test(t) === !1 ? e : Ba(e);
367
367
  }
368
- function Va(t) {
368
+ function Ba(t) {
369
369
  let e = [t];
370
370
  for (; e.length; ) {
371
371
  const r = e;
@@ -443,7 +443,7 @@ var Ka = /* @__PURE__ */ Symbol(
443
443
  ...or,
444
444
  ...t
445
445
  };
446
- function se() {
446
+ function ie() {
447
447
  return {};
448
448
  }
449
449
  function Ha(t, e) {
@@ -528,7 +528,7 @@ function tn(t, e) {
528
528
  };
529
529
  }
530
530
  function rn(t, e) {
531
- return e.effectStrategy === "input" ? F(t.schema._def, e) : se();
531
+ return e.effectStrategy === "input" ? F(t.schema._def, e) : ie();
532
532
  }
533
533
  function an(t) {
534
534
  return {
@@ -870,10 +870,10 @@ function un(t, e) {
870
870
  const r = F(t.keyType._def, {
871
871
  ...e,
872
872
  currentPath: [...e.currentPath, "items", "items", "0"]
873
- }) || se(), a = F(t.valueType._def, {
873
+ }) || ie(), a = F(t.valueType._def, {
874
874
  ...e,
875
875
  currentPath: [...e.currentPath, "items", "items", "1"]
876
- }) || se();
876
+ }) || ie();
877
877
  return {
878
878
  type: "array",
879
879
  maxItems: 125,
@@ -895,7 +895,7 @@ function dn(t) {
895
895
  };
896
896
  }
897
897
  function pn() {
898
- return { not: se() };
898
+ return { not: ie() };
899
899
  }
900
900
  function fn() {
901
901
  return {
@@ -1065,7 +1065,7 @@ var Sn = (t, e) => {
1065
1065
  ...e,
1066
1066
  currentPath: [...e.currentPath, "anyOf", "1"]
1067
1067
  });
1068
- return a ? { anyOf: [{ not: se() }, a] } : se();
1068
+ return a ? { anyOf: [{ not: ie() }, a] } : ie();
1069
1069
  }, En = (t, e) => {
1070
1070
  if (e.pipeStrategy === "input")
1071
1071
  return F(t.in._def, e);
@@ -1132,13 +1132,13 @@ function _n(t, e) {
1132
1132
  }
1133
1133
  function An() {
1134
1134
  return {
1135
- not: se()
1135
+ not: ie()
1136
1136
  };
1137
1137
  }
1138
- function Tn() {
1139
- return se();
1138
+ function xn() {
1139
+ return ie();
1140
1140
  }
1141
- var xn = (t, e) => F(t.innerType._def, e), Mn = (t, e, r) => {
1141
+ var Tn = (t, e) => F(t.innerType._def, e), Mn = (t, e, r) => {
1142
1142
  switch (e) {
1143
1143
  case P.ZodString:
1144
1144
  return jr(t, r);
@@ -1191,15 +1191,15 @@ var xn = (t, e) => F(t.innerType._def, e), Mn = (t, e, r) => {
1191
1191
  case P.ZodEffects:
1192
1192
  return rn(t, r);
1193
1193
  case P.ZodAny:
1194
- return se();
1194
+ return ie();
1195
1195
  case P.ZodUnknown:
1196
- return Tn();
1196
+ return xn();
1197
1197
  case P.ZodDefault:
1198
1198
  return tn(t, r);
1199
1199
  case P.ZodBranded:
1200
1200
  return Or(t, r);
1201
1201
  case P.ZodReadonly:
1202
- return xn(t, r);
1202
+ return Tn(t, r);
1203
1203
  case P.ZodCatch:
1204
1204
  return Xa(t, r);
1205
1205
  case P.ZodPipeline:
@@ -1258,7 +1258,7 @@ var Rn = (t, e) => {
1258
1258
  `Recursive reference detected at ${e.currentPath.join(
1259
1259
  "/"
1260
1260
  )}! Defaulting to any`
1261
- ), se()) : e.$refStrategy === "seen" ? se() : void 0;
1261
+ ), ie()) : e.$refStrategy === "seen" ? ie() : void 0;
1262
1262
  }
1263
1263
  }, On = (t, e, r) => (t.description && (r.description = t.description), r), Nn = (t) => {
1264
1264
  const e = Ya(t), r = e.name !== void 0 ? [...e.basePath, e.definitionPath, e.name] : e.basePath;
@@ -1293,7 +1293,7 @@ var Rn = (t, e) => {
1293
1293
  currentPath: [...a.basePath, a.definitionPath, p]
1294
1294
  },
1295
1295
  !0
1296
- )) != null ? C : se()
1296
+ )) != null ? C : ie()
1297
1297
  };
1298
1298
  },
1299
1299
  {}
@@ -1305,7 +1305,7 @@ var Rn = (t, e) => {
1305
1305
  currentPath: [...a.basePath, a.definitionPath, i]
1306
1306
  },
1307
1307
  !1
1308
- )) != null ? r : se(), s = typeof e == "object" && e.name !== void 0 && e.nameStrategy === "title" ? e.name : void 0;
1308
+ )) != null ? r : ie(), s = typeof e == "object" && e.name !== void 0 && e.nameStrategy === "title" ? e.name : void 0;
1309
1309
  s !== void 0 && (l.title = s);
1310
1310
  const f = i === void 0 ? n ? {
1311
1311
  ...l,
@@ -1368,7 +1368,7 @@ function Ln(t) {
1368
1368
  const r = await t["~standard"].validate(e);
1369
1369
  return "value" in r ? { success: !0, value: r.value } : {
1370
1370
  success: !1,
1371
- error: new Ue({
1371
+ error: new qe({
1372
1372
  value: e,
1373
1373
  cause: r.issues
1374
1374
  })
@@ -1429,7 +1429,7 @@ async function cr({
1429
1429
  }) {
1430
1430
  const a = await He({ value: t, schema: e, context: r });
1431
1431
  if (!a.success)
1432
- throw Ue.wrap({ value: t, cause: a.error, context: r });
1432
+ throw qe.wrap({ value: t, cause: a.error, context: r });
1433
1433
  return a.value;
1434
1434
  }
1435
1435
  async function He({
@@ -1444,13 +1444,13 @@ async function He({
1444
1444
  const n = await a.validate(t);
1445
1445
  return n.success ? { success: !0, value: n.value, rawValue: t } : {
1446
1446
  success: !1,
1447
- error: Ue.wrap({ value: t, cause: n.error, context: r }),
1447
+ error: qe.wrap({ value: t, cause: n.error, context: r }),
1448
1448
  rawValue: t
1449
1449
  };
1450
1450
  } catch (n) {
1451
1451
  return {
1452
1452
  success: !1,
1453
- error: Ue.wrap({ value: t, cause: n, context: r }),
1453
+ error: qe.wrap({ value: t, cause: n, context: r }),
1454
1454
  rawValue: t
1455
1455
  };
1456
1456
  }
@@ -1489,10 +1489,10 @@ new TextDecoder();
1489
1489
  function Zn(t) {
1490
1490
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
1491
1491
  }
1492
- var Wn = Object.defineProperty, Bn = (t, e) => {
1492
+ var Wn = Object.defineProperty, Vn = (t, e) => {
1493
1493
  for (var r in e)
1494
1494
  Wn(t, r, { get: e[r], enumerable: !0 });
1495
- }, Lr = "AI_NoObjectGeneratedError", Fr = `vercel.ai.error.${Lr}`, Vn = Symbol.for(Fr), $r, Ae = class extends ge {
1495
+ }, Lr = "AI_NoObjectGeneratedError", Fr = `vercel.ai.error.${Lr}`, Bn = Symbol.for(Fr), $r, Ae = class extends ge {
1496
1496
  constructor({
1497
1497
  message: t = "No object generated.",
1498
1498
  cause: e,
@@ -1507,7 +1507,7 @@ var Wn = Object.defineProperty, Bn = (t, e) => {
1507
1507
  return ge.hasMarker(t, Fr);
1508
1508
  }
1509
1509
  };
1510
- $r = Vn;
1510
+ $r = Bn;
1511
1511
  var Ur = "AI_UIMessageStreamError", qr = `vercel.ai.error.${Ur}`, Jn = Symbol.for(qr), zr, Pe = class extends ge {
1512
1512
  constructor({
1513
1513
  chunkType: t,
@@ -1530,7 +1530,7 @@ var Oe = o.lazy(
1530
1530
  o.record(o.string(), Oe.optional()),
1531
1531
  o.array(Oe)
1532
1532
  ])
1533
- ), x = o.record(
1533
+ ), T = o.record(
1534
1534
  o.string(),
1535
1535
  o.record(o.string(), Oe.optional())
1536
1536
  ), Ge = o.union([
@@ -1541,7 +1541,7 @@ var Oe = o.lazy(
1541
1541
  ]), $t = o.record(o.string(), o.string()), Zr = o.object({
1542
1542
  type: o.literal("text"),
1543
1543
  text: o.string(),
1544
- providerOptions: x.optional()
1544
+ providerOptions: T.optional()
1545
1545
  }), Kn = o.object({
1546
1546
  type: o.literal("image"),
1547
1547
  image: o.union([
@@ -1550,7 +1550,7 @@ var Oe = o.lazy(
1550
1550
  $t
1551
1551
  ]),
1552
1552
  mediaType: o.string().optional(),
1553
- providerOptions: x.optional()
1553
+ providerOptions: T.optional()
1554
1554
  }), Wr = o.discriminatedUnion("type", [
1555
1555
  o.object({ type: o.literal("data"), data: Ge }),
1556
1556
  o.object({ type: o.literal("url"), url: o.instanceof(URL) }),
@@ -1562,7 +1562,7 @@ var Oe = o.lazy(
1562
1562
  ]), Yn = o.discriminatedUnion("type", [
1563
1563
  o.object({ type: o.literal("data"), data: Ge }),
1564
1564
  o.object({ type: o.literal("url"), url: o.instanceof(URL) })
1565
- ]), Br = o.object({
1565
+ ]), Vr = o.object({
1566
1566
  type: o.literal("file"),
1567
1567
  data: o.union([
1568
1568
  Wr,
@@ -1572,15 +1572,15 @@ var Oe = o.lazy(
1572
1572
  ]),
1573
1573
  filename: o.string().optional(),
1574
1574
  mediaType: o.string(),
1575
- providerOptions: x.optional()
1575
+ providerOptions: T.optional()
1576
1576
  }), Hn = o.object({
1577
1577
  type: o.literal("reasoning"),
1578
1578
  text: o.string(),
1579
- providerOptions: x.optional()
1579
+ providerOptions: T.optional()
1580
1580
  }), Gn = o.object({
1581
1581
  type: o.literal("custom"),
1582
1582
  kind: o.string().transform((t) => t),
1583
- providerOptions: x.optional()
1583
+ providerOptions: T.optional()
1584
1584
  }), Qn = o.object({
1585
1585
  type: o.literal("reasoning-file"),
1586
1586
  data: o.union([
@@ -1589,13 +1589,13 @@ var Oe = o.lazy(
1589
1589
  o.instanceof(URL)
1590
1590
  ]),
1591
1591
  mediaType: o.string(),
1592
- providerOptions: x.optional()
1592
+ providerOptions: T.optional()
1593
1593
  }), Xn = o.object({
1594
1594
  type: o.literal("tool-call"),
1595
1595
  toolCallId: o.string(),
1596
1596
  toolName: o.string(),
1597
1597
  input: o.unknown(),
1598
- providerOptions: x.optional(),
1598
+ providerOptions: T.optional(),
1599
1599
  providerExecuted: o.boolean().optional()
1600
1600
  }), es = o.discriminatedUnion(
1601
1601
  "type",
@@ -1603,27 +1603,27 @@ var Oe = o.lazy(
1603
1603
  o.object({
1604
1604
  type: o.literal("text"),
1605
1605
  value: o.string(),
1606
- providerOptions: x.optional()
1606
+ providerOptions: T.optional()
1607
1607
  }),
1608
1608
  o.object({
1609
1609
  type: o.literal("json"),
1610
1610
  value: Oe,
1611
- providerOptions: x.optional()
1611
+ providerOptions: T.optional()
1612
1612
  }),
1613
1613
  o.object({
1614
1614
  type: o.literal("execution-denied"),
1615
1615
  reason: o.string().optional(),
1616
- providerOptions: x.optional()
1616
+ providerOptions: T.optional()
1617
1617
  }),
1618
1618
  o.object({
1619
1619
  type: o.literal("error-text"),
1620
1620
  value: o.string(),
1621
- providerOptions: x.optional()
1621
+ providerOptions: T.optional()
1622
1622
  }),
1623
1623
  o.object({
1624
1624
  type: o.literal("error-json"),
1625
1625
  value: Oe,
1626
- providerOptions: x.optional()
1626
+ providerOptions: T.optional()
1627
1627
  }),
1628
1628
  o.object({
1629
1629
  type: o.literal("content"),
@@ -1632,14 +1632,14 @@ var Oe = o.lazy(
1632
1632
  o.object({
1633
1633
  type: o.literal("text"),
1634
1634
  text: o.string(),
1635
- providerOptions: x.optional()
1635
+ providerOptions: T.optional()
1636
1636
  }),
1637
1637
  o.object({
1638
1638
  type: o.literal("file"),
1639
1639
  data: Wr,
1640
1640
  mediaType: o.string(),
1641
1641
  filename: o.string().optional(),
1642
- providerOptions: x.optional()
1642
+ providerOptions: T.optional()
1643
1643
  }),
1644
1644
  o.object({
1645
1645
  // Deprecated.
@@ -1647,66 +1647,66 @@ var Oe = o.lazy(
1647
1647
  data: o.string(),
1648
1648
  mediaType: o.string(),
1649
1649
  filename: o.string().optional(),
1650
- providerOptions: x.optional()
1650
+ providerOptions: T.optional()
1651
1651
  }),
1652
1652
  o.object({
1653
1653
  // Deprecated.
1654
1654
  type: o.literal("file-url"),
1655
1655
  url: o.string(),
1656
1656
  mediaType: o.string().optional(),
1657
- providerOptions: x.optional()
1657
+ providerOptions: T.optional()
1658
1658
  }),
1659
1659
  o.object({
1660
1660
  // Deprecated.
1661
1661
  type: o.literal("file-id"),
1662
1662
  fileId: o.union([o.string(), o.record(o.string(), o.string())]),
1663
- providerOptions: x.optional()
1663
+ providerOptions: T.optional()
1664
1664
  }),
1665
1665
  o.object({
1666
1666
  // Deprecated.
1667
1667
  type: o.literal("file-reference"),
1668
1668
  providerReference: o.record(o.string(), o.string()),
1669
- providerOptions: x.optional()
1669
+ providerOptions: T.optional()
1670
1670
  }),
1671
1671
  o.object({
1672
1672
  // Deprecated.
1673
1673
  type: o.literal("image-data"),
1674
1674
  data: o.string(),
1675
1675
  mediaType: o.string(),
1676
- providerOptions: x.optional()
1676
+ providerOptions: T.optional()
1677
1677
  }),
1678
1678
  o.object({
1679
1679
  // Deprecated.
1680
1680
  type: o.literal("image-url"),
1681
1681
  url: o.string(),
1682
- providerOptions: x.optional()
1682
+ providerOptions: T.optional()
1683
1683
  }),
1684
1684
  o.object({
1685
1685
  // Deprecated.
1686
1686
  type: o.literal("image-file-id"),
1687
1687
  fileId: o.union([o.string(), o.record(o.string(), o.string())]),
1688
- providerOptions: x.optional()
1688
+ providerOptions: T.optional()
1689
1689
  }),
1690
1690
  o.object({
1691
1691
  // Deprecated.
1692
1692
  type: o.literal("image-file-reference"),
1693
1693
  providerReference: o.record(o.string(), o.string()),
1694
- providerOptions: x.optional()
1694
+ providerOptions: T.optional()
1695
1695
  }),
1696
1696
  o.object({
1697
1697
  type: o.literal("custom"),
1698
- providerOptions: x.optional()
1698
+ providerOptions: T.optional()
1699
1699
  })
1700
1700
  ])
1701
1701
  )
1702
1702
  })
1703
1703
  ]
1704
- ), Vr = o.object({
1704
+ ), Br = o.object({
1705
1705
  type: o.literal("tool-result"),
1706
1706
  toolCallId: o.string(),
1707
1707
  toolName: o.string(),
1708
1708
  output: es,
1709
- providerOptions: x.optional()
1709
+ providerOptions: T.optional()
1710
1710
  }), ts = o.object({
1711
1711
  type: o.literal("tool-approval-request"),
1712
1712
  approvalId: o.string(),
@@ -1720,15 +1720,15 @@ var Oe = o.lazy(
1720
1720
  {
1721
1721
  role: o.literal("system"),
1722
1722
  content: o.string(),
1723
- providerOptions: x.optional()
1723
+ providerOptions: T.optional()
1724
1724
  }
1725
1725
  ), ns = o.object({
1726
1726
  role: o.literal("user"),
1727
1727
  content: o.union([
1728
1728
  o.string(),
1729
- o.array(o.union([Zr, Kn, Br]))
1729
+ o.array(o.union([Zr, Kn, Vr]))
1730
1730
  ]),
1731
- providerOptions: x.optional()
1731
+ providerOptions: T.optional()
1732
1732
  }), ss = o.object({
1733
1733
  role: o.literal("assistant"),
1734
1734
  content: o.union([
@@ -1737,20 +1737,20 @@ var Oe = o.lazy(
1737
1737
  o.union([
1738
1738
  Zr,
1739
1739
  Gn,
1740
- Br,
1740
+ Vr,
1741
1741
  Hn,
1742
1742
  Qn,
1743
1743
  Xn,
1744
- Vr,
1744
+ Br,
1745
1745
  ts
1746
1746
  ])
1747
1747
  )
1748
1748
  ]),
1749
- providerOptions: x.optional()
1749
+ providerOptions: T.optional()
1750
1750
  }), is = o.object({
1751
1751
  role: o.literal("tool"),
1752
- content: o.array(o.union([Vr, rs])),
1753
- providerOptions: x.optional()
1752
+ content: o.array(o.union([Br, rs])),
1753
+ providerOptions: T.optional()
1754
1754
  });
1755
1755
  o.union([
1756
1756
  as,
@@ -1780,7 +1780,7 @@ function Jr(t, e) {
1780
1780
  return r;
1781
1781
  }
1782
1782
  var os = {};
1783
- Bn(os, {
1783
+ Vn(os, {
1784
1784
  array: () => ds,
1785
1785
  choice: () => ps,
1786
1786
  json: () => fs,
@@ -2157,7 +2157,7 @@ var cs = () => ({
2157
2157
  if (s == null || typeof s != "object" || !("elements" in s) || !Array.isArray(s.elements))
2158
2158
  throw new Ae({
2159
2159
  message: "No object generated: response did not match schema.",
2160
- cause: new Ue({
2160
+ cause: new qe({
2161
2161
  value: s,
2162
2162
  cause: "response must be an object with an elements array"
2163
2163
  }),
@@ -2255,7 +2255,7 @@ var cs = () => ({
2255
2255
  if (l == null || typeof l != "object" || !("result" in l) || typeof l.result != "string" || !t.includes(l.result))
2256
2256
  throw new Ae({
2257
2257
  message: "No object generated: response did not match schema.",
2258
- cause: new Ue({
2258
+ cause: new qe({
2259
2259
  value: l,
2260
2260
  cause: "response must be an object that contains a choice value."
2261
2261
  }),
@@ -2349,7 +2349,7 @@ ce({
2349
2349
  });
2350
2350
  }
2351
2351
  });
2352
- var We = o.record(
2352
+ var Ve = o.record(
2353
2353
  o.string(),
2354
2354
  Oe.optional()
2355
2355
  ), ms = Dn(
@@ -2358,18 +2358,18 @@ var We = o.record(
2358
2358
  o.strictObject({
2359
2359
  type: o.literal("text-start"),
2360
2360
  id: o.string(),
2361
- providerMetadata: x.optional()
2361
+ providerMetadata: T.optional()
2362
2362
  }),
2363
2363
  o.strictObject({
2364
2364
  type: o.literal("text-delta"),
2365
2365
  id: o.string(),
2366
2366
  delta: o.string(),
2367
- providerMetadata: x.optional()
2367
+ providerMetadata: T.optional()
2368
2368
  }),
2369
2369
  o.strictObject({
2370
2370
  type: o.literal("text-end"),
2371
2371
  id: o.string(),
2372
- providerMetadata: x.optional()
2372
+ providerMetadata: T.optional()
2373
2373
  }),
2374
2374
  o.strictObject({
2375
2375
  type: o.literal("error"),
@@ -2380,8 +2380,8 @@ var We = o.record(
2380
2380
  toolCallId: o.string(),
2381
2381
  toolName: o.string(),
2382
2382
  providerExecuted: o.boolean().optional(),
2383
- providerMetadata: x.optional(),
2384
- toolMetadata: We.optional(),
2383
+ providerMetadata: T.optional(),
2384
+ toolMetadata: Ve.optional(),
2385
2385
  dynamic: o.boolean().optional(),
2386
2386
  title: o.string().optional()
2387
2387
  }),
@@ -2396,8 +2396,8 @@ var We = o.record(
2396
2396
  toolName: o.string(),
2397
2397
  input: o.unknown(),
2398
2398
  providerExecuted: o.boolean().optional(),
2399
- providerMetadata: x.optional(),
2400
- toolMetadata: We.optional(),
2399
+ providerMetadata: T.optional(),
2400
+ toolMetadata: Ve.optional(),
2401
2401
  dynamic: o.boolean().optional(),
2402
2402
  title: o.string().optional()
2403
2403
  }),
@@ -2407,8 +2407,8 @@ var We = o.record(
2407
2407
  toolName: o.string(),
2408
2408
  input: o.unknown(),
2409
2409
  providerExecuted: o.boolean().optional(),
2410
- providerMetadata: x.optional(),
2411
- toolMetadata: We.optional(),
2410
+ providerMetadata: T.optional(),
2411
+ toolMetadata: Ve.optional(),
2412
2412
  dynamic: o.boolean().optional(),
2413
2413
  errorText: o.string(),
2414
2414
  title: o.string().optional()
@@ -2426,15 +2426,15 @@ var We = o.record(
2426
2426
  approved: o.boolean(),
2427
2427
  reason: o.string().optional(),
2428
2428
  providerExecuted: o.boolean().optional(),
2429
- providerMetadata: x.optional()
2429
+ providerMetadata: T.optional()
2430
2430
  }),
2431
2431
  o.strictObject({
2432
2432
  type: o.literal("tool-output-available"),
2433
2433
  toolCallId: o.string(),
2434
2434
  output: o.unknown(),
2435
2435
  providerExecuted: o.boolean().optional(),
2436
- providerMetadata: x.optional(),
2437
- toolMetadata: We.optional(),
2436
+ providerMetadata: T.optional(),
2437
+ toolMetadata: Ve.optional(),
2438
2438
  dynamic: o.boolean().optional(),
2439
2439
  preliminary: o.boolean().optional()
2440
2440
  }),
@@ -2443,8 +2443,8 @@ var We = o.record(
2443
2443
  toolCallId: o.string(),
2444
2444
  errorText: o.string(),
2445
2445
  providerExecuted: o.boolean().optional(),
2446
- providerMetadata: x.optional(),
2447
- toolMetadata: We.optional(),
2446
+ providerMetadata: T.optional(),
2447
+ toolMetadata: Ve.optional(),
2448
2448
  dynamic: o.boolean().optional()
2449
2449
  }),
2450
2450
  o.strictObject({
@@ -2454,30 +2454,30 @@ var We = o.record(
2454
2454
  o.strictObject({
2455
2455
  type: o.literal("reasoning-start"),
2456
2456
  id: o.string(),
2457
- providerMetadata: x.optional()
2457
+ providerMetadata: T.optional()
2458
2458
  }),
2459
2459
  o.strictObject({
2460
2460
  type: o.literal("reasoning-delta"),
2461
2461
  id: o.string(),
2462
2462
  delta: o.string(),
2463
- providerMetadata: x.optional()
2463
+ providerMetadata: T.optional()
2464
2464
  }),
2465
2465
  o.strictObject({
2466
2466
  type: o.literal("reasoning-end"),
2467
2467
  id: o.string(),
2468
- providerMetadata: x.optional()
2468
+ providerMetadata: T.optional()
2469
2469
  }),
2470
2470
  o.strictObject({
2471
2471
  type: o.literal("custom"),
2472
2472
  kind: o.string().transform((t) => t),
2473
- providerMetadata: x.optional()
2473
+ providerMetadata: T.optional()
2474
2474
  }),
2475
2475
  o.strictObject({
2476
2476
  type: o.literal("source-url"),
2477
2477
  sourceId: o.string(),
2478
2478
  url: o.string(),
2479
2479
  title: o.string().optional(),
2480
- providerMetadata: x.optional()
2480
+ providerMetadata: T.optional()
2481
2481
  }),
2482
2482
  o.strictObject({
2483
2483
  type: o.literal("source-document"),
@@ -2485,19 +2485,19 @@ var We = o.record(
2485
2485
  mediaType: o.string(),
2486
2486
  title: o.string(),
2487
2487
  filename: o.string().optional(),
2488
- providerMetadata: x.optional()
2488
+ providerMetadata: T.optional()
2489
2489
  }),
2490
2490
  o.strictObject({
2491
2491
  type: o.literal("file"),
2492
2492
  url: o.string(),
2493
2493
  mediaType: o.string(),
2494
- providerMetadata: x.optional()
2494
+ providerMetadata: T.optional()
2495
2495
  }),
2496
2496
  o.strictObject({
2497
2497
  type: o.literal("reasoning-file"),
2498
2498
  url: o.string(),
2499
2499
  mediaType: o.string(),
2500
- providerMetadata: x.optional()
2500
+ providerMetadata: T.optional()
2501
2501
  }),
2502
2502
  o.strictObject({
2503
2503
  type: o.custom(
@@ -2554,7 +2554,7 @@ function Nt(t) {
2554
2554
  function Kr(t) {
2555
2555
  return t.type === "dynamic-tool";
2556
2556
  }
2557
- function $e(t) {
2557
+ function Ue(t) {
2558
2558
  return Nt(t) || Kr(t);
2559
2559
  }
2560
2560
  function jt(t) {
@@ -2594,7 +2594,7 @@ function ys({
2594
2594
  await a(async ({ state: c, write: p }) => {
2595
2595
  var d, C, v, O;
2596
2596
  function I(u) {
2597
- const m = c.message.parts.filter($e).find(
2597
+ const m = c.message.parts.filter(Ue).find(
2598
2598
  (y) => y.toolCallId === u
2599
2599
  );
2600
2600
  if (m == null)
@@ -2606,7 +2606,7 @@ function ys({
2606
2606
  return m;
2607
2607
  }
2608
2608
  function E(u) {
2609
- const m = c.message.parts.filter($e).find(
2609
+ const m = c.message.parts.filter(Ue).find(
2610
2610
  (y) => {
2611
2611
  var h;
2612
2612
  return ((h = y.approval) == null ? void 0 : h.id) === u;
@@ -2884,7 +2884,7 @@ function ys({
2884
2884
  break;
2885
2885
  }
2886
2886
  case "tool-input-error": {
2887
- const u = c.message.parts.filter($e).find((m) => m.toolCallId === s.toolCallId);
2887
+ const u = c.message.parts.filter(Ue).find((m) => m.toolCallId === s.toolCallId);
2888
2888
  (u != null ? u.type === "dynamic-tool" : !!s.dynamic) ? S({
2889
2889
  toolCallId: s.toolCallId,
2890
2890
  toolName: s.toolName,
@@ -3326,7 +3326,7 @@ var Es = class {
3326
3326
  reason: v,
3327
3327
  options: O
3328
3328
  }) => this.jobExecutor.run(async () => {
3329
- const I = this.state.messages, E = I[I.length - 1], _ = (S) => $e(S) && S.state === "approval-requested" && S.approval.id === d ? {
3329
+ const I = this.state.messages, E = I[I.length - 1], _ = (S) => Ue(S) && S.state === "approval-requested" && S.approval.id === d ? {
3330
3330
  ...S,
3331
3331
  state: "approval-responded",
3332
3332
  approval: { ...S.approval, id: d, approved: C, reason: v }
@@ -3349,7 +3349,7 @@ var Es = class {
3349
3349
  errorText: O,
3350
3350
  options: I
3351
3351
  }) => this.jobExecutor.run(async () => {
3352
- const E = this.state.messages, _ = E[E.length - 1], S = (M) => $e(M) && M.toolCallId === C ? { ...M, state: d, output: v, errorText: O } : M;
3352
+ const E = this.state.messages, _ = E[E.length - 1], S = (M) => Ue(M) && M.toolCallId === C ? { ...M, state: d, output: v, errorText: O } : M;
3353
3353
  this.state.replaceMessage(E.length - 1, {
3354
3354
  ..._,
3355
3355
  parts: _.parts.map(S)
@@ -3510,9 +3510,9 @@ var Es = class {
3510
3510
  body: a
3511
3511
  });
3512
3512
  }
3513
- }, Tt, ur;
3513
+ }, xt, ur;
3514
3514
  function Is() {
3515
- if (ur) return Tt;
3515
+ if (ur) return xt;
3516
3516
  ur = 1;
3517
3517
  function t(e, r) {
3518
3518
  if (typeof e != "function")
@@ -3526,83 +3526,83 @@ function Is() {
3526
3526
  }, c);
3527
3527
  };
3528
3528
  }
3529
- return Tt = t, Tt;
3529
+ return xt = t, xt;
3530
3530
  }
3531
3531
  var _s = /* @__PURE__ */ Is();
3532
3532
  const As = /* @__PURE__ */ Zn(_s);
3533
3533
  var Yr = (t, e, r) => {
3534
3534
  if (!e.has(t))
3535
3535
  throw TypeError("Cannot " + r);
3536
- }, B = (t, e, r) => (Yr(t, e, "read from private field"), r ? r.call(t) : e.get(t)), me = (t, e, r) => {
3536
+ }, V = (t, e, r) => (Yr(t, e, "read from private field"), r ? r.call(t) : e.get(t)), me = (t, e, r) => {
3537
3537
  if (e.has(t))
3538
3538
  throw TypeError("Cannot add the same private member more than once");
3539
3539
  e instanceof WeakSet ? e.add(t) : e.set(t, r);
3540
3540
  }, Ie = (t, e, r, a) => (Yr(t, e, "write to private field"), e.set(t, r), r);
3541
- function Ts(t, e) {
3541
+ function xs(t, e) {
3542
3542
  return e != null ? As(t, e) : t;
3543
3543
  }
3544
- var le, it, ot, Be, Ve, Je, Le, Dt, kt, xs = class {
3544
+ var le, it, ot, Be, Je, Ke, Le, Dt, kt, Ts = class {
3545
3545
  constructor(t = []) {
3546
- me(this, le, void 0), me(this, it, "ready"), me(this, ot, void 0), me(this, Be, /* @__PURE__ */ new Set()), me(this, Ve, /* @__PURE__ */ new Set()), me(this, Je, /* @__PURE__ */ new Set()), this.pushMessage = (e) => {
3547
- Ie(this, le, B(this, le).concat(e)), B(this, Le).call(this);
3546
+ me(this, le, void 0), me(this, it, "ready"), me(this, ot, void 0), me(this, Be, /* @__PURE__ */ new Set()), me(this, Je, /* @__PURE__ */ new Set()), me(this, Ke, /* @__PURE__ */ new Set()), this.pushMessage = (e) => {
3547
+ Ie(this, le, V(this, le).concat(e)), V(this, Le).call(this);
3548
3548
  }, this.popMessage = () => {
3549
- Ie(this, le, B(this, le).slice(0, -1)), B(this, Le).call(this);
3549
+ Ie(this, le, V(this, le).slice(0, -1)), V(this, Le).call(this);
3550
3550
  }, this.replaceMessage = (e, r) => {
3551
3551
  Ie(this, le, [
3552
- ...B(this, le).slice(0, e),
3552
+ ...V(this, le).slice(0, e),
3553
3553
  // We deep clone the message here to ensure the new React Compiler (currently in RC) detects deeply nested parts/metadata changes:
3554
3554
  this.snapshot(r),
3555
- ...B(this, le).slice(e + 1)
3556
- ]), B(this, Le).call(this);
3555
+ ...V(this, le).slice(e + 1)
3556
+ ]), V(this, Le).call(this);
3557
3557
  }, this.snapshot = (e) => structuredClone(e), this["~registerMessagesCallback"] = (e, r) => {
3558
- const a = r ? Ts(e, r) : e;
3559
- return B(this, Be).add(a), () => {
3560
- B(this, Be).delete(a);
3558
+ const a = r ? xs(e, r) : e;
3559
+ return V(this, Be).add(a), () => {
3560
+ V(this, Be).delete(a);
3561
3561
  };
3562
- }, this["~registerStatusCallback"] = (e) => (B(this, Ve).add(e), () => {
3563
- B(this, Ve).delete(e);
3564
- }), this["~registerErrorCallback"] = (e) => (B(this, Je).add(e), () => {
3565
- B(this, Je).delete(e);
3562
+ }, this["~registerStatusCallback"] = (e) => (V(this, Je).add(e), () => {
3563
+ V(this, Je).delete(e);
3564
+ }), this["~registerErrorCallback"] = (e) => (V(this, Ke).add(e), () => {
3565
+ V(this, Ke).delete(e);
3566
3566
  }), me(this, Le, () => {
3567
- B(this, Be).forEach((e) => e());
3567
+ V(this, Be).forEach((e) => e());
3568
3568
  }), me(this, Dt, () => {
3569
- B(this, Ve).forEach((e) => e());
3569
+ V(this, Je).forEach((e) => e());
3570
3570
  }), me(this, kt, () => {
3571
- B(this, Je).forEach((e) => e());
3571
+ V(this, Ke).forEach((e) => e());
3572
3572
  }), Ie(this, le, t);
3573
3573
  }
3574
3574
  get status() {
3575
- return B(this, it);
3575
+ return V(this, it);
3576
3576
  }
3577
3577
  set status(t) {
3578
- Ie(this, it, t), B(this, Dt).call(this);
3578
+ Ie(this, it, t), V(this, Dt).call(this);
3579
3579
  }
3580
3580
  get error() {
3581
- return B(this, ot);
3581
+ return V(this, ot);
3582
3582
  }
3583
3583
  set error(t) {
3584
- Ie(this, ot, t), B(this, kt).call(this);
3584
+ Ie(this, ot, t), V(this, kt).call(this);
3585
3585
  }
3586
3586
  get messages() {
3587
- return B(this, le);
3587
+ return V(this, le);
3588
3588
  }
3589
3589
  set messages(t) {
3590
- Ie(this, le, [...t]), B(this, Le).call(this);
3590
+ Ie(this, le, [...t]), V(this, Le).call(this);
3591
3591
  }
3592
3592
  };
3593
3593
  le = /* @__PURE__ */ new WeakMap();
3594
3594
  it = /* @__PURE__ */ new WeakMap();
3595
3595
  ot = /* @__PURE__ */ new WeakMap();
3596
3596
  Be = /* @__PURE__ */ new WeakMap();
3597
- Ve = /* @__PURE__ */ new WeakMap();
3598
3597
  Je = /* @__PURE__ */ new WeakMap();
3598
+ Ke = /* @__PURE__ */ new WeakMap();
3599
3599
  Le = /* @__PURE__ */ new WeakMap();
3600
3600
  Dt = /* @__PURE__ */ new WeakMap();
3601
3601
  kt = /* @__PURE__ */ new WeakMap();
3602
3602
  var Fe, dr = class extends ws {
3603
3603
  constructor({ messages: t, ...e }) {
3604
- const r = new xs(t);
3605
- super({ ...e, state: r }), me(this, Fe, void 0), this["~registerMessagesCallback"] = (a, n) => B(this, Fe)["~registerMessagesCallback"](a, n), this["~registerStatusCallback"] = (a) => B(this, Fe)["~registerStatusCallback"](a), this["~registerErrorCallback"] = (a) => B(this, Fe)["~registerErrorCallback"](a), Ie(this, Fe, r);
3604
+ const r = new Ts(t);
3605
+ super({ ...e, state: r }), me(this, Fe, void 0), this["~registerMessagesCallback"] = (a, n) => V(this, Fe)["~registerMessagesCallback"](a, n), this["~registerStatusCallback"] = (a) => V(this, Fe)["~registerStatusCallback"](a), this["~registerErrorCallback"] = (a) => V(this, Fe)["~registerErrorCallback"](a), Ie(this, Fe, r);
3606
3606
  }
3607
3607
  };
3608
3608
  Fe = /* @__PURE__ */ new WeakMap();
@@ -3660,15 +3660,15 @@ function Ms({
3660
3660
  // `chatRef.current.id` is required to trigger re-subscription when the chat ID changes
3661
3661
  // eslint-disable-next-line react-hooks/exhaustive-deps
3662
3662
  [n, c.current.id]
3663
- ), C = Ke(
3663
+ ), C = $e(
3664
3664
  d,
3665
3665
  () => c.current.messages,
3666
3666
  () => c.current.messages
3667
- ), v = Ke(
3667
+ ), v = $e(
3668
3668
  c.current["~registerStatusCallback"],
3669
3669
  () => c.current.status,
3670
3670
  () => c.current.status
3671
- ), O = Ke(
3671
+ ), O = $e(
3672
3672
  c.current["~registerErrorCallback"],
3673
3673
  () => c.current.error,
3674
3674
  () => c.current.error
@@ -3678,7 +3678,7 @@ function Ms({
3678
3678
  },
3679
3679
  [c]
3680
3680
  );
3681
- return z(() => {
3681
+ return q(() => {
3682
3682
  r && c.current.resumeStream();
3683
3683
  }, [r, c]), {
3684
3684
  id: c.current.id,
@@ -3783,7 +3783,7 @@ function ks(t, e) {
3783
3783
  }))
3784
3784
  };
3785
3785
  }
3786
- function xt(t) {
3786
+ function Tt(t) {
3787
3787
  try {
3788
3788
  return JSON.parse(t);
3789
3789
  } catch {
@@ -3792,19 +3792,19 @@ function xt(t) {
3792
3792
  }
3793
3793
  function Ls(t) {
3794
3794
  if (t == null) return null;
3795
- if (typeof t == "string") return xt(t);
3795
+ if (typeof t == "string") return Tt(t);
3796
3796
  if (Array.isArray(t)) {
3797
3797
  for (const e of t)
3798
3798
  if (e && typeof e == "object" && "text" in e) {
3799
3799
  const r = e.text;
3800
- if (typeof r == "string") return xt(r);
3800
+ if (typeof r == "string") return Tt(r);
3801
3801
  }
3802
3802
  return null;
3803
3803
  }
3804
3804
  if (typeof t == "object") {
3805
3805
  if ("text" in t) {
3806
3806
  const e = t.text;
3807
- if (typeof e == "string") return xt(e);
3807
+ if (typeof e == "string") return Tt(e);
3808
3808
  }
3809
3809
  return t;
3810
3810
  }
@@ -3816,7 +3816,7 @@ function mr(t, e) {
3816
3816
  const a = Os.safeParse(r);
3817
3817
  return a.success ? ks(a.data, e) : null;
3818
3818
  }
3819
- function Mi(t, e) {
3819
+ function Ni(t, e) {
3820
3820
  const r = [];
3821
3821
  for (const a of t.questions) {
3822
3822
  const n = e.get(a.id);
@@ -3923,13 +3923,13 @@ function Ws(t, e) {
3923
3923
  `toolActivity=${encodeURIComponent(e.toolActivity)}`
3924
3924
  ), (e == null ? void 0 : e.reasoning) !== void 0 && r.push(`reasoning=${String(e.reasoning)}`), r.length === 0 ? t : `${t}${t.includes("?") ? "&" : "?"}${r.join("&")}`;
3925
3925
  }
3926
- function Bs(t) {
3926
+ function Vs(t) {
3927
3927
  return ({ id: e }) => ({
3928
3928
  api: t.reconnectApi(e),
3929
3929
  headers: t.headers()
3930
3930
  });
3931
3931
  }
3932
- function Vs(t) {
3932
+ function Bs(t) {
3933
3933
  return new Ut({
3934
3934
  api: t.api,
3935
3935
  headers: () => t.headers(),
@@ -3937,7 +3937,7 @@ function Vs(t) {
3937
3937
  // Every send carries its full body; a send without one is a programming
3938
3938
  // error, and an empty body would be rejected server-side just as loudly.
3939
3939
  prepareSendMessagesRequest: ({ body: e }) => ({ body: e ?? {} }),
3940
- prepareReconnectToStreamRequest: Bs(t)
3940
+ prepareReconnectToStreamRequest: Vs(t)
3941
3941
  });
3942
3942
  }
3943
3943
  function Js({
@@ -4008,7 +4008,7 @@ function ei({
4008
4008
  sessionId: r,
4009
4009
  persistedMessages: a
4010
4010
  }) {
4011
- var Bt, Vt;
4011
+ var Vt, Bt;
4012
4012
  const { api: n, messageCtx: i } = t, l = R(e);
4013
4013
  l.current = e;
4014
4014
  const {
@@ -4016,7 +4016,7 @@ function ei({
4016
4016
  clientTools: f,
4017
4017
  pageActions: c
4018
4018
  } = t.features, p = te(
4019
- () => Vs({
4019
+ () => Bs({
4020
4020
  ...n.getStreamTransportOptions(),
4021
4021
  headers: () => n.getStreamTransportOptions().headers,
4022
4022
  reconnectApi: (b) => Ws(
@@ -4052,20 +4052,20 @@ function ei({
4052
4052
  onFinish: C
4053
4053
  }), m = R(E);
4054
4054
  m.current = E;
4055
- const y = R(new pr(yr)), h = R("idle"), [w, k] = J(!1), D = R(Promise.resolve()), V = R(0), Z = R(0), [$, W] = J(0), [ae, oe] = J(!1), ue = R(ae);
4056
- ue.current = ae;
4057
- const [be, Q] = J([]), [Te, he] = J([]), [ve, q] = J(null), H = R(null), ne = U((b) => {
4058
- H.current = b, q(b);
4059
- }, []), re = R(null), ze = R(null), je = R(I), ft = R(r), Ze = ft.current === r, mt = R(null), gt = R(null), zt = R(S), Ce = R(I);
4055
+ const y = R(new pr(yr)), h = R("idle"), [w, k] = J(!1), D = R(Promise.resolve()), B = R(0), Z = R(0), [$, W] = J(0), [ne, oe] = J(!1), ue = R(ne);
4056
+ ue.current = ne;
4057
+ const [be, Q] = J([]), [xe, he] = J([]), [ve, z] = J(null), G = R(null), se = U((b) => {
4058
+ G.current = b, z(b);
4059
+ }, []), ae = R(null), Ze = R(null), je = R(I), ft = R(r), We = ft.current === r, mt = R(null), gt = R(null), zt = R(S), Ce = R(I);
4060
4060
  Ce.current = I;
4061
4061
  const Xe = U((b, A) => {
4062
4062
  const j = vr(b.parts);
4063
4063
  if (!j || j.rowIds.length === 0) return;
4064
- const T = lt(b.parts);
4065
- T.length !== 0 && Q(
4064
+ const x = lt(b.parts);
4065
+ x.length !== 0 && Q(
4066
4066
  (L) => L.some((X) => X.turnId === j.turnId) ? L : [
4067
4067
  ...L,
4068
- { key: A, turnId: j.turnId, rowIds: j.rowIds, items: T }
4068
+ { key: A, turnId: j.turnId, rowIds: j.rowIds, items: x }
4069
4069
  ]
4070
4070
  );
4071
4071
  }, []), Zt = U(
@@ -4080,7 +4080,7 @@ function ei({
4080
4080
  }),
4081
4081
  [t]
4082
4082
  );
4083
- z(() => {
4083
+ q(() => {
4084
4084
  const b = zt.current;
4085
4085
  zt.current = S;
4086
4086
  const A = ft.current;
@@ -4090,10 +4090,10 @@ function ei({
4090
4090
  return;
4091
4091
  }
4092
4092
  const j = Ce.current === "submitted" || Ce.current === "streaming" || je.current === "submitted" || je.current === "streaming" || h.current === "in-flight";
4093
- Z.current += 1, V.current = 0, D.current = Promise.resolve(), y.current = new pr(yr), h.current = "idle", k(!1), ze.current = null, re.current = null, C(null), v.current = !1, gt.current = null, mt.current = I === "submitted" || I === "streaming" ? I : null, je.current = "ready", Ce.current = "ready", u(), W((T) => T + 1), oe(!1), Q([]), ne(null), j && Promise.resolve().then(() => b()).catch((T) => {
4094
- ye.error("agent chat client stream cancel failed", T);
4093
+ Z.current += 1, B.current = 0, D.current = Promise.resolve(), y.current = new pr(yr), h.current = "idle", k(!1), Ze.current = null, ae.current = null, C(null), v.current = !1, gt.current = null, mt.current = I === "submitted" || I === "streaming" ? I : null, je.current = "ready", Ce.current = "ready", u(), W((x) => x + 1), oe(!1), Q([]), se(null), j && Promise.resolve().then(() => b()).catch((x) => {
4094
+ ye.error("agent chat client stream cancel failed", x);
4095
4095
  });
4096
- }, [r, I, S, u, ne]), z(() => {
4096
+ }, [r, I, S, u, se]), q(() => {
4097
4097
  var L, X;
4098
4098
  const b = mt.current;
4099
4099
  if (b !== null && I === b) {
@@ -4102,8 +4102,8 @@ function ei({
4102
4102
  }
4103
4103
  mt.current = null;
4104
4104
  const A = je.current;
4105
- if (je.current = I, (I === "submitted" || I === "streaming") && (A !== "submitted" && A !== "streaming" && H.current === null && ne(`turn-resumed-${Et()}`), oe(!0)), I === "streaming") {
4106
- const Y = (L = ze.current) == null ? void 0 : L.userMessage.id;
4105
+ if (je.current = I, (I === "submitted" || I === "streaming") && (A !== "submitted" && A !== "streaming" && G.current === null && se(`turn-resumed-${Et()}`), oe(!0)), I === "streaming") {
4106
+ const Y = (L = Ze.current) == null ? void 0 : L.userMessage.id;
4107
4107
  Y && i.markUserMessageDelivered(Y);
4108
4108
  return;
4109
4109
  }
@@ -4111,9 +4111,9 @@ function ei({
4111
4111
  if (A === "streaming" || A === "submitted" || // An empty response can finish before React observes an active status.
4112
4112
  h.current === "in-flight" && (d == null ? void 0 : d.messages) === m.current) {
4113
4113
  oe(!0), h.current === "in-flight" && (h.current = "idle");
4114
- const Y = m.current.at(-1), Ee = H.current;
4115
- if (re.current = Ee, Ee !== null && Y && Y.role === "assistant" && Xe(Y, Ee), I === "ready") {
4116
- const we = (X = ze.current) == null ? void 0 : X.userMessage.id;
4114
+ const Y = m.current.at(-1), Ee = G.current;
4115
+ if (ae.current = Ee, Ee !== null && Y && Y.role === "assistant" && Xe(Y, Ee), I === "ready") {
4116
+ const we = (X = Ze.current) == null ? void 0 : X.userMessage.id;
4117
4117
  we && i.markUserMessageDelivered(we);
4118
4118
  }
4119
4119
  h.current === "stopping" || (r ? (h.current = "reconciling", t.reconcileAfterStream(r).catch((we) => {
@@ -4123,10 +4123,10 @@ function ei({
4123
4123
  })) : oe(!1));
4124
4124
  }
4125
4125
  if (h.current !== "idle" || !r || ue.current && I !== "error") return;
4126
- const T = y.current.dequeueNext();
4127
- T && (h.current = "in-flight", k(!1), ze.current = T, C(null), v.current = !1, ne(`turn-${T.userMessage.id}`), i.appendUserMessageIfAbsent(T.userMessage), W((Y) => Y + 1), _(
4128
- { text: T.userMessage.content },
4129
- { body: Zt(T) }
4126
+ const x = y.current.dequeueNext();
4127
+ x && (h.current = "in-flight", k(!1), Ze.current = x, C(null), v.current = !1, se(`turn-${x.userMessage.id}`), i.appendUserMessageIfAbsent(x.userMessage), W((Y) => Y + 1), _(
4128
+ { text: x.userMessage.content },
4129
+ { body: Zt(x) }
4130
4130
  ));
4131
4131
  }, [
4132
4132
  I,
@@ -4137,14 +4137,14 @@ function ei({
4137
4137
  t,
4138
4138
  Zt,
4139
4139
  Xe,
4140
- ne,
4140
+ se,
4141
4141
  d
4142
4142
  ]);
4143
4143
  const Wt = U(
4144
4144
  (b) => {
4145
4145
  const A = Z.current;
4146
- V.current++;
4147
- const T = D.current.then(
4146
+ B.current++;
4147
+ const x = D.current.then(
4148
4148
  async () => {
4149
4149
  if (A !== Z.current) return;
4150
4150
  const L = h.current, Y = Ce.current === "submitted" || Ce.current === "streaming" || L !== "idle" || ue.current || y.current.size > 0 ? ti(i.buildQueuedUserMessage(b)) : await i.stageUserTurn(b, { pending: !0 });
@@ -4159,18 +4159,18 @@ function ei({
4159
4159
  W((we) => we + 1), i.notifySendAccepted(b);
4160
4160
  }
4161
4161
  ).finally(() => {
4162
- A === Z.current && V.current--;
4162
+ A === Z.current && B.current--;
4163
4163
  });
4164
- return D.current = T.then(
4164
+ return D.current = x.then(
4165
4165
  () => {
4166
4166
  },
4167
4167
  () => {
4168
4168
  }
4169
- ), T;
4169
+ ), x;
4170
4170
  },
4171
4171
  [i]
4172
4172
  ), la = U(() => {
4173
- const b = ze.current;
4173
+ const b = Ze.current;
4174
4174
  if (!b) return;
4175
4175
  if (!y.current.enqueue({
4176
4176
  ...b,
@@ -4205,24 +4205,24 @@ function ei({
4205
4205
  b === Z.current && (h.current = "idle", W((A) => A + 1));
4206
4206
  });
4207
4207
  }, [n, r, S, t]);
4208
- z(() => {
4208
+ q(() => {
4209
4209
  const b = {
4210
4210
  send: Wt,
4211
- hasPendingWork: () => V.current > 0 || ue.current || y.current.size > 0 || h.current !== "idle" || Ce.current === "submitted" || Ce.current === "streaming"
4211
+ hasPendingWork: () => B.current > 0 || ue.current || y.current.size > 0 || h.current !== "idle" || Ce.current === "submitted" || Ce.current === "streaming"
4212
4212
  };
4213
4213
  return i.registerAgentHandlers(b), () => i.unregisterAgentHandlers(b);
4214
4214
  }, [i, Wt]);
4215
- const et = (Bt = e.presentation) == null ? void 0 : Bt.toolActivity, tt = (Vt = e.presentation) == null ? void 0 : Vt.reasoning;
4216
- z(() => he([]), [r]), z(() => {
4215
+ const et = (Vt = e.presentation) == null ? void 0 : Vt.toolActivity, tt = (Bt = e.presentation) == null ? void 0 : Bt.reasoning;
4216
+ q(() => he([]), [r]), q(() => {
4217
4217
  var L, X;
4218
4218
  if (!r) return;
4219
4219
  const b = et === void 0 && tt === void 0 ? void 0 : { toolActivity: et, reasoning: tt }, A = gt.current, j = (A == null ? void 0 : A.sessionId) === r && (((L = A.presentation) == null ? void 0 : L.toolActivity) !== et || ((X = A.presentation) == null ? void 0 : X.reasoning) !== tt);
4220
4220
  gt.current = { sessionId: r, presentation: b };
4221
- let T = !1;
4221
+ let x = !1;
4222
4222
  return (async () => {
4223
4223
  try {
4224
4224
  const Y = b === void 0 ? await n.getAgentTurnMessages(r) : await n.getAgentTurnMessages(r, b);
4225
- if (!Y || T) return;
4225
+ if (!Y || x) return;
4226
4226
  he(Y.handled_connection_request_ids), Q(
4227
4227
  (Ee) => Js({ existing: Ee, fetched: Y, refreshItems: j })
4228
4228
  );
@@ -4230,7 +4230,7 @@ function ei({
4230
4230
  ye.error("agent chat turn sources fetch failed", Y);
4231
4231
  }
4232
4232
  })(), () => {
4233
- T = !0;
4233
+ x = !0;
4234
4234
  };
4235
4235
  }, [r, n, et, tt]);
4236
4236
  const [ht, da] = J(() => /* @__PURE__ */ new Set()), rt = R(ht), vt = R(/* @__PURE__ */ new Set()), at = te(() => {
@@ -4240,8 +4240,8 @@ function ei({
4240
4240
  if (!b || b.role !== "assistant") return [];
4241
4241
  const A = [];
4242
4242
  for (const j of b.parts) {
4243
- if (!$e(j)) continue;
4244
- const T = hs(j), L = T === Qs ? "highlight-element" : T === Xs ? "act-on-page" : null;
4243
+ if (!Ue(j)) continue;
4244
+ const x = hs(j), L = x === Qs ? "highlight-element" : x === Xs ? "act-on-page" : null;
4245
4245
  L && j.state === "input-available" && A.push({
4246
4246
  key: `${r ?? "pending"}:${j.toolCallId}`,
4247
4247
  type: L,
@@ -4262,7 +4262,7 @@ function ei({
4262
4262
  ht
4263
4263
  ]
4264
4264
  ), yt = U(
4265
- (b, A, j, T) => {
4265
+ (b, A, j, x) => {
4266
4266
  if (!r) return;
4267
4267
  const L = `${r}:${b}`;
4268
4268
  if (rt.current.has(L)) return;
@@ -4279,7 +4279,7 @@ function ei({
4279
4279
  // The page as it is after the action. Without it a flow that
4280
4280
  // crosses screens stops dead: the agent is holding refs to the
4281
4281
  // screen it just left.
4282
- ...t.features.pageContext && T ? { controls: T.controls, truncated: T.truncated } : {}
4282
+ ...t.features.pageContext && x ? { controls: x.controls, truncated: x.truncated } : {}
4283
4283
  });
4284
4284
  },
4285
4285
  [n, r, t]
@@ -4292,16 +4292,16 @@ function ei({
4292
4292
  A(!1);
4293
4293
  return;
4294
4294
  }
4295
- vt.current.add(j), Se.current.forEach((T) => T(!1)), Se.current.clear(), Se.current.set(b.callId, A), bt(b);
4295
+ vt.current.add(j), Se.current.forEach((x) => x(!1)), Se.current.clear(), Se.current.set(b.callId, A), bt(b);
4296
4296
  }),
4297
4297
  [r]
4298
4298
  ), Ct = U((b, A) => {
4299
4299
  const j = Se.current.get(b);
4300
4300
  Se.current.delete(b), bt(
4301
- (T) => (T == null ? void 0 : T.callId) === b ? null : T
4301
+ (x) => (x == null ? void 0 : x.callId) === b ? null : x
4302
4302
  ), j == null || j(A);
4303
4303
  }, []);
4304
- z(() => {
4304
+ q(() => {
4305
4305
  for (const b of at)
4306
4306
  s && f && (b.type !== "act-on-page" || c) || (Ct(b.callId, !1), vt.current.has(b.key) || yt(b.callId, "declined"));
4307
4307
  }, [
@@ -4313,49 +4313,49 @@ function ei({
4313
4313
  yt
4314
4314
  ]);
4315
4315
  const de = I === "submitted" || I === "streaming";
4316
- z(
4316
+ q(
4317
4317
  () => () => {
4318
4318
  Se.current.forEach((b) => b(!1)), Se.current.clear();
4319
4319
  },
4320
4320
  [r]
4321
- ), z(() => {
4321
+ ), q(() => {
4322
4322
  if (de && !w) return;
4323
4323
  const b = Se.current;
4324
4324
  b.size !== 0 && (b.forEach((A) => A(!1)), b.clear(), bt(null));
4325
- }, [de, w]), z(() => {
4325
+ }, [de, w]), q(() => {
4326
4326
  if (de) return;
4327
- const b = re.current;
4327
+ const b = ae.current;
4328
4328
  if (b === null) return;
4329
4329
  const A = E.at(-1);
4330
4330
  A && A.role === "assistant" && Xe(A, b);
4331
4331
  }, [E, de, Xe]);
4332
4332
  const St = U(() => {
4333
- r && (de || M === void 0 && !ae || g());
4334
- }, [r, de, ae, M, g]);
4335
- z(
4333
+ r && (de || M === void 0 && !ne || g());
4334
+ }, [r, de, ne, M, g]);
4335
+ q(
4336
4336
  () => Hs(St),
4337
4337
  [St]
4338
- ), z(() => {
4339
- if (de || !ae) return;
4338
+ ), q(() => {
4339
+ if (de || !ne) return;
4340
4340
  const b = () => {
4341
- oe(!1), W((T) => T + 1), H.current === re.current && ne(null), re.current = null;
4341
+ oe(!1), W((x) => x + 1), G.current === ae.current && se(null), ae.current = null;
4342
4342
  };
4343
- if (H.current === re.current && (d == null ? void 0 : d.messages) === E && !d.isError && !d.isDisconnect && (!d.isAbort || v.current) && !lt(d.message.parts).some(
4344
- (T) => T.kind !== "steps"
4343
+ if (G.current === ae.current && (d == null ? void 0 : d.messages) === E && !d.isError && !d.isDisconnect && (!d.isAbort || v.current) && !lt(d.message.parts).some(
4344
+ (x) => x.kind !== "steps"
4345
4345
  )) {
4346
- const T = a.findLast((L) => L.type === "USER");
4347
- T && i.state.setPartial({ settledAgentUserMessageId: T.id }), b();
4346
+ const x = a.findLast((L) => L.type === "USER");
4347
+ x && i.state.setPartial({ settledAgentUserMessageId: x.id }), b();
4348
4348
  return;
4349
4349
  }
4350
4350
  if (d && d.messages !== E) return;
4351
4351
  const A = E.at(-1), j = (A == null ? void 0 : A.role) === "assistant" ? vr(A.parts) : null;
4352
4352
  if (j && j.rowIds.length > 0) {
4353
- const T = new Set(a.map((L) => L.id));
4354
- j.rowIds.every((L) => T.has(L)) && b();
4353
+ const x = new Set(a.map((L) => L.id));
4354
+ j.rowIds.every((L) => x.has(L)) && b();
4355
4355
  return;
4356
4356
  }
4357
- for (let T = a.length - 1; T >= 0; T -= 1) {
4358
- const L = a[T];
4357
+ for (let x = a.length - 1; x >= 0; x -= 1) {
4358
+ const L = a[x];
4359
4359
  if (L) {
4360
4360
  if (L.type === "USER") return;
4361
4361
  if (!(L.type !== "AI" && L.type !== "AGENT")) {
@@ -4366,9 +4366,9 @@ function ei({
4366
4366
  }
4367
4367
  }, [
4368
4368
  de,
4369
- ae,
4370
- a,
4371
4369
  ne,
4370
+ a,
4371
+ se,
4372
4372
  d,
4373
4373
  E,
4374
4374
  i,
@@ -4378,7 +4378,7 @@ function ei({
4378
4378
  t.agent.presentation,
4379
4379
  e.presentation
4380
4380
  ), nt = De == null ? void 0 : De.toolActivity, st = De == null ? void 0 : De.reasoning, ga = te(() => {
4381
- if (!Ze || ve === null || I === "submitted" || !de && !ae)
4381
+ if (!We || ve === null || I === "submitted" || !de && !ne)
4382
4382
  return [];
4383
4383
  const b = E.at(-1);
4384
4384
  return !b || b.role !== "assistant" ? [] : fr(lt(b.parts), {
@@ -4389,20 +4389,20 @@ function ei({
4389
4389
  E,
4390
4390
  I,
4391
4391
  de,
4392
- ae,
4392
+ ne,
4393
4393
  nt,
4394
4394
  st,
4395
- Ze,
4395
+ We,
4396
4396
  ve
4397
4397
  ]), ha = te(
4398
- () => Ze ? be.flatMap((b) => {
4398
+ () => We ? be.flatMap((b) => {
4399
4399
  const A = fr(b.items, {
4400
4400
  toolActivity: nt,
4401
4401
  reasoning: st
4402
4402
  });
4403
4403
  return A.length === 0 ? [] : [A === b.items ? b : { ...b, items: A }];
4404
4404
  }) : [],
4405
- [be, nt, st, Ze]
4405
+ [be, nt, st, We]
4406
4406
  ), va = te(
4407
4407
  () => y.current.items.filter((b) => !b.input.background).map((b) => b.userMessage),
4408
4408
  // eslint-disable-next-line react-hooks/exhaustive-deps -- queueRef is mutable; queueVersion is the signal
@@ -4427,14 +4427,14 @@ function ei({
4427
4427
  pendingPageAction: fa,
4428
4428
  requestPageActionConsent: ma,
4429
4429
  resolvePageAction: Ct,
4430
- handledConnectionRequestIds: Te,
4431
- sourceSessionId: Ze ? r : null
4430
+ handledConnectionRequestIds: xe,
4431
+ sourceSessionId: We ? r : null
4432
4432
  };
4433
4433
  }
4434
4434
  function ti(t) {
4435
4435
  return t ? { ...t, initialMessages: [] } : null;
4436
4436
  }
4437
- const br = 2e3, Cr = 6e5, ri = 1e4, ut = qe(null), ai = (t, e) => e === "dismiss" ? {
4437
+ const br = 2e3, Cr = 6e5, ri = 1e4, ut = ze(null), ai = (t, e) => e === "dismiss" ? {
4438
4438
  content: `Continue without connecting ${t.name}.`,
4439
4439
  connectionRequestId: t.request_id
4440
4440
  } : e === "renew" ? {
@@ -4464,15 +4464,15 @@ function ni({
4464
4464
  var D;
4465
4465
  C.current.abort(), (D = v.current) == null || D.close(), v.current = null;
4466
4466
  }, []);
4467
- z(() => (u(), _.current = null, E.current = null, I.current = null, i("idle"), s(null), c(null), d(null), u), [u, e == null ? void 0 : e.request_id, e == null ? void 0 : e.server_id, r]), z(() => (S.current = !0, () => {
4467
+ q(() => (u(), _.current = null, E.current = null, I.current = null, i("idle"), s(null), c(null), d(null), u), [u, e == null ? void 0 : e.request_id, e == null ? void 0 : e.server_id, r]), q(() => (S.current = !0, () => {
4468
4468
  S.current = !1, u();
4469
4469
  }), [u]);
4470
4470
  const g = U(
4471
4471
  async (D) => {
4472
4472
  if (!e) return;
4473
- const V = e.request_id;
4474
- if (O.current.has(V)) return;
4475
- O.current.add(V), I.current = D, c(D), d(null);
4473
+ const B = e.request_id;
4474
+ if (O.current.has(B)) return;
4475
+ O.current.add(B), I.current = D, c(D), d(null);
4476
4476
  let Z = !1;
4477
4477
  try {
4478
4478
  await r.messageCtx.sendMessage({
@@ -4480,20 +4480,20 @@ function ni({
4480
4480
  onAccepted: () => {
4481
4481
  Z = !0, a(e.request_id);
4482
4482
  }
4483
- }), S.current && M.current === V && !Z && d(
4483
+ }), S.current && M.current === B && !Z && d(
4484
4484
  D === "renew" ? "Could not request a new connection. Try again." : "Could not continue your request. Try again."
4485
4485
  );
4486
4486
  } catch {
4487
- S.current && M.current === V && d(
4487
+ S.current && M.current === B && d(
4488
4488
  D === "renew" ? "Could not request a new connection. Try again." : "Could not continue your request. Try again."
4489
4489
  );
4490
4490
  } finally {
4491
- O.current.delete(V), S.current && M.current === V && c(null);
4491
+ O.current.delete(B), S.current && M.current === B && c(null);
4492
4492
  }
4493
4493
  },
4494
4494
  [a, e, r]
4495
4495
  ), m = U(async () => {
4496
- var V, Z;
4496
+ var B, Z;
4497
4497
  if (!e) return;
4498
4498
  u(), _.current = e.request_id, C.current = new AbortController();
4499
4499
  const { signal: D } = C.current;
@@ -4514,7 +4514,7 @@ function ni({
4514
4514
  host: W.host,
4515
4515
  completion: $.completion,
4516
4516
  ...$.completion === "oauth" ? { attemptId: $.attempt_id } : {}
4517
- }), E.current = Date.now() + Cr, (V = v.current) != null && V.closed ? (v.current = null, i("ready")) : v.current ? (v.current.location.replace(W.href), i("waiting")) : i("ready");
4517
+ }), E.current = Date.now() + Cr, (B = v.current) != null && B.closed ? (v.current = null, i("ready")) : v.current ? (v.current.location.replace(W.href), i("waiting")) : i("ready");
4518
4518
  } catch ($) {
4519
4519
  if (D.aborted) return;
4520
4520
  if ((Z = v.current) == null || Z.close(), v.current = null, s(null), i("idle"), $ instanceof Ia) {
@@ -4526,36 +4526,36 @@ function ni({
4526
4526
  );
4527
4527
  }
4528
4528
  }, [u, e, g, r]);
4529
- z(() => {
4529
+ q(() => {
4530
4530
  if (n !== "waiting" && n !== "ready" || !l || !e)
4531
4531
  return;
4532
4532
  const D = new AbortController();
4533
- let V;
4533
+ let B;
4534
4534
  const Z = E.current ?? Date.now() + Cr;
4535
4535
  E.current = Z;
4536
- let $ = 0, W = document.hidden || !document.hasFocus(), ae = !1;
4536
+ let $ = 0, W = document.hidden || !document.hasFocus(), ne = !1;
4537
4537
  const oe = () => {
4538
4538
  W = !0;
4539
4539
  }, ue = () => {
4540
- W && (ae = !0);
4540
+ W && (ne = !0);
4541
4541
  }, be = () => document.hidden ? oe() : ue();
4542
4542
  window.addEventListener("blur", oe), window.addEventListener("focus", ue), document.addEventListener("visibilitychange", be);
4543
- const Q = (q) => {
4544
- var H;
4545
- D.abort(), (H = v.current) == null || H.close(), v.current = null, d(q), i("idle");
4546
- }, Te = setTimeout(
4543
+ const Q = (z) => {
4544
+ var G;
4545
+ D.abort(), (G = v.current) == null || G.close(), v.current = null, d(z), i("idle");
4546
+ }, xe = setTimeout(
4547
4547
  () => Q("Connection timed out. Try again."),
4548
4548
  Math.max(0, Z - Date.now())
4549
- ), he = (q = br) => {
4550
- V = setTimeout(ve, q);
4549
+ ), he = (z = br) => {
4550
+ B = setTimeout(ve, z);
4551
4551
  }, ve = async () => {
4552
- var q, H, ne;
4552
+ var z, G, se;
4553
4553
  if (Date.now() >= Z) {
4554
4554
  Q("Connection timed out. Try again.");
4555
4555
  return;
4556
4556
  }
4557
4557
  if (l.completion === "external") {
4558
- if (n === "waiting" && ((q = v.current) != null && q.closed || ae)) {
4558
+ if (n === "waiting" && ((z = v.current) != null && z.closed || ne)) {
4559
4559
  i("external");
4560
4560
  return;
4561
4561
  }
@@ -4567,33 +4567,33 @@ function ni({
4567
4567
  return;
4568
4568
  }
4569
4569
  try {
4570
- const re = await r.api.getConnectionAttempt(
4570
+ const ae = await r.api.getConnectionAttempt(
4571
4571
  e.server_id,
4572
4572
  l.attemptId,
4573
4573
  D.signal
4574
4574
  );
4575
4575
  if (D.signal.aborted) return;
4576
- if ($ = 0, re === "connected") {
4577
- (H = v.current) == null || H.close(), v.current = null, i("connected");
4576
+ if ($ = 0, ae === "connected") {
4577
+ (G = v.current) == null || G.close(), v.current = null, i("connected");
4578
4578
  return;
4579
4579
  }
4580
- if (re === "canceled") {
4580
+ if (ae === "canceled") {
4581
4581
  Q("Connection was canceled. Try again.");
4582
4582
  return;
4583
4583
  }
4584
- if (re === "failed") {
4584
+ if (ae === "failed") {
4585
4585
  Q("Connection approval failed. Try again.");
4586
4586
  return;
4587
4587
  }
4588
- if (re === "expired") {
4588
+ if (ae === "expired") {
4589
4589
  Q("Connection attempt expired. Try again.");
4590
4590
  return;
4591
4591
  }
4592
- (ne = v.current) != null && ne.closed && (v.current = null, i("ready")), he();
4593
- } catch (re) {
4592
+ (se = v.current) != null && se.closed && (v.current = null, i("ready")), he();
4593
+ } catch (ae) {
4594
4594
  if (D.signal.aborted) return;
4595
- if (re instanceof _a) {
4596
- Q(re.message);
4595
+ if (ae instanceof _a) {
4596
+ Q(ae.message);
4597
4597
  return;
4598
4598
  }
4599
4599
  $ += 1, he(
@@ -4605,9 +4605,9 @@ function ni({
4605
4605
  }
4606
4606
  };
4607
4607
  return ve(), () => {
4608
- D.abort(), V && clearTimeout(V), Te && clearTimeout(Te), window.removeEventListener("blur", oe), window.removeEventListener("focus", ue), document.removeEventListener("visibilitychange", be);
4608
+ D.abort(), B && clearTimeout(B), xe && clearTimeout(xe), window.removeEventListener("blur", oe), window.removeEventListener("focus", ue), document.removeEventListener("visibilitychange", be);
4609
4609
  };
4610
- }, [l, n, e, r]), z(() => {
4610
+ }, [l, n, e, r]), q(() => {
4611
4611
  n !== "connected" && n !== "external" || _.current !== (e == null ? void 0 : e.request_id) || g(n === "external" ? "external" : "resume");
4612
4612
  }, [n, e == null ? void 0 : e.request_id, g]);
4613
4613
  const y = U(() => i("waiting"), []), h = U(async () => {
@@ -4664,7 +4664,7 @@ function si({
4664
4664
  function ii() {
4665
4665
  return Ne(ut);
4666
4666
  }
4667
- function Pi(t) {
4667
+ function ji(t) {
4668
4668
  const e = Ne(ut);
4669
4669
  if (!e || e.request.request_id !== t.request_id)
4670
4670
  throw new Error(
@@ -4696,7 +4696,7 @@ const qt = {
4696
4696
  },
4697
4697
  pendingClarification: null,
4698
4698
  pendingConnection: null
4699
- }, dt = qe(null);
4699
+ }, dt = ze(null);
4700
4700
  function Gr() {
4701
4701
  return Ne(dt) ?? qt;
4702
4702
  }
@@ -4705,8 +4705,8 @@ function oi({
4705
4705
  widgetCtx: e,
4706
4706
  config: r
4707
4707
  }) {
4708
- var ue, be, Q, Te, he, ve;
4709
- const a = G(e.sessionCtx.sessionState), n = G(e.messageCtx.state), {
4708
+ var ue, be, Q, xe, he, ve;
4709
+ const a = H(e.sessionCtx.sessionState), n = H(e.messageCtx.state), {
4710
4710
  isStreaming: i,
4711
4711
  liveItems: l,
4712
4712
  turnSources: s,
@@ -4729,20 +4729,20 @@ function oi({
4729
4729
  config: r,
4730
4730
  sessionId: ((ue = a.session) == null ? void 0 : ue.id) ?? null,
4731
4731
  persistedMessages: n.messages
4732
- }), m = ((be = n.messages.at(-1)) == null ? void 0 : be.type) === "USER", y = R(/* @__PURE__ */ new Set()), h = R(((Q = a.session) == null ? void 0 : Q.id) ?? null), w = ((Te = a.session) == null ? void 0 : Te.id) ?? null;
4732
+ }), m = ((be = n.messages.at(-1)) == null ? void 0 : be.type) === "USER", y = R(/* @__PURE__ */ new Set()), h = R(((Q = a.session) == null ? void 0 : Q.id) ?? null), w = ((xe = a.session) == null ? void 0 : xe.id) ?? null;
4733
4733
  h.current !== w && (h.current = w, y.current.clear()), u.forEach(
4734
- (q) => y.current.add(q)
4734
+ (z) => y.current.add(z)
4735
4735
  );
4736
4736
  const k = (he = [
4737
- ...s.flatMap((q) => q.items),
4737
+ ...s.flatMap((z) => z.items),
4738
4738
  ...l
4739
4739
  ].findLast(
4740
- (q) => q.kind === "connection" && !y.current.has(q.request.request_id)
4741
- )) == null ? void 0 : he.request, [D, V] = J({ sessionId: w, request: null }), Z = ((ve = r.capabilities) == null ? void 0 : ve.connections) === !0, $ = Z && w !== null && D.sessionId === w ? D.request : null;
4742
- z(() => {
4743
- !Z || w === null || g !== w || V((q) => {
4744
- const H = q.sessionId === w && q.request && !y.current.has(q.request.request_id) ? q.request : k ?? null;
4745
- return q.sessionId === w && q.request === H ? q : { sessionId: w, request: H };
4740
+ (z) => z.kind === "connection" && !y.current.has(z.request.request_id)
4741
+ )) == null ? void 0 : he.request, [D, B] = J({ sessionId: w, request: null }), Z = ((ve = r.capabilities) == null ? void 0 : ve.connections) === !0, $ = Z && w !== null && D.sessionId === w ? D.request : null;
4742
+ q(() => {
4743
+ !Z || w === null || g !== w || B((z) => {
4744
+ const G = z.sessionId === w && z.request && !y.current.has(z.request.request_id) ? z.request : k ?? null;
4745
+ return z.sessionId === w && z.request === G ? z : { sessionId: w, request: G };
4746
4746
  });
4747
4747
  }, [
4748
4748
  w,
@@ -4752,14 +4752,14 @@ function oi({
4752
4752
  Z,
4753
4753
  $
4754
4754
  ]);
4755
- const W = U((q) => {
4756
- y.current.add(q), V(
4757
- (H) => {
4758
- var ne;
4759
- return ((ne = H.request) == null ? void 0 : ne.request_id) === q ? { ...H, request: null } : H;
4755
+ const W = U((z) => {
4756
+ y.current.add(z), B(
4757
+ (G) => {
4758
+ var se;
4759
+ return ((se = G.request) == null ? void 0 : se.request_id) === z ? { ...G, request: null } : G;
4760
4760
  }
4761
4761
  );
4762
- }, []), ae = te(
4762
+ }, []), ne = te(
4763
4763
  () => ({
4764
4764
  isStreaming: i,
4765
4765
  liveItems: l,
@@ -4803,7 +4803,7 @@ function oi({
4803
4803
  m,
4804
4804
  $
4805
4805
  ]
4806
- ), oe = /* @__PURE__ */ K.createElement(dt.Provider, { value: ae }, t);
4806
+ ), oe = /* @__PURE__ */ K.createElement(dt.Provider, { value: ne }, t);
4807
4807
  return /* @__PURE__ */ K.createElement(
4808
4808
  ni,
4809
4809
  {
@@ -4819,7 +4819,7 @@ function Qr({
4819
4819
  widgetCtx: e,
4820
4820
  config: r
4821
4821
  }) {
4822
- return G(e.messageCtx.state), e.streaming ? /* @__PURE__ */ K.createElement(oi, { widgetCtx: e, config: r }, t) : /* @__PURE__ */ K.createElement(dt.Provider, { value: qt }, t);
4822
+ return H(e.messageCtx.state), e.streaming ? /* @__PURE__ */ K.createElement(oi, { widgetCtx: e, config: r }, t) : /* @__PURE__ */ K.createElement(dt.Provider, { value: qt }, t);
4823
4823
  }
4824
4824
  class li {
4825
4825
  constructor(e) {
@@ -4919,14 +4919,14 @@ class li {
4919
4919
  return !e.closed && !r && !this.isWorking(e) && !e.ctx.messageCtx.state.get().messages.length && !a && !n.length && !e.ctx.uploadCtx.state.get().length;
4920
4920
  }
4921
4921
  }
4922
- const Xr = qe(null), ci = new Er({ chats: [], activeId: 0 });
4922
+ const Xr = ze(null), ci = new Er({ chats: [], activeId: 0 });
4923
4923
  function ea() {
4924
- const t = Ne(Xr), e = G((t == null ? void 0 : t.state) ?? ci), r = e.chats.filter((n) => !n.closed), a = r.filter(
4924
+ const t = Ne(Xr), e = H((t == null ? void 0 : t.state) ?? ci), r = e.chats.filter((n) => !n.closed), a = r.filter(
4925
4925
  (n) => n.hasSession || n.working || n.hasDraft || n.title
4926
4926
  );
4927
4927
  return { workspace: t, chats: r, openChats: a, activeId: e.activeId };
4928
4928
  }
4929
- function Ri() {
4929
+ function Di() {
4930
4930
  const { workspace: t, ...e } = ea();
4931
4931
  if (!t)
4932
4932
  throw new Error("Companion chats require a conversation workspace");
@@ -4942,10 +4942,10 @@ function ui({
4942
4942
  ctx: e,
4943
4943
  workspace: r
4944
4944
  }) {
4945
- const a = Gr(), n = ii(), i = G(e.messageCtx.state), l = G(e.sessionCtx.sessionState), s = G(e.messageCtx.draftState), f = G(e.uploadCtx.state), c = i.messages.find(
4945
+ const a = Gr(), n = ii(), i = H(e.messageCtx.state), l = H(e.sessionCtx.sessionState), s = H(e.messageCtx.draftState), f = H(e.uploadCtx.state), c = i.messages.find(
4946
4946
  (O) => O.type === "USER"
4947
4947
  ), p = (c == null ? void 0 : c.type) === "USER" ? c.content.slice(0, 60) : "", d = a.isStreaming || i.isSendingMessage || l.isCreatingSession, C = !!l.session, v = !!s.text || s.mentions.length > 0 || f.length > 0;
4948
- return z(
4948
+ return q(
4949
4949
  () => r.update(t, {
4950
4950
  title: p,
4951
4951
  working: d,
@@ -4974,8 +4974,8 @@ function pi({
4974
4974
  () => new li(t),
4975
4975
  [t]
4976
4976
  );
4977
- z(() => a.mount(), [a]);
4978
- const { chats: n, activeId: i } = G(a.state), l = n.find((f) => f.id === i), s = te(
4977
+ q(() => a.mount(), [a]);
4978
+ const { chats: n, activeId: i } = H(a.state), l = n.find((f) => f.id === i), s = te(
4979
4979
  () => n.map((f) => /* @__PURE__ */ K.createElement(
4980
4980
  di,
4981
4981
  {
@@ -5071,8 +5071,8 @@ const Sr = N.object({
5071
5071
  externalId: e.externalId ?? null,
5072
5072
  opaqueToken: r
5073
5073
  });
5074
- }, ta = qe(null);
5075
- function Oi({
5074
+ }, ta = ze(null);
5075
+ function ki({
5076
5076
  options: t,
5077
5077
  children: e,
5078
5078
  components: r,
@@ -5089,7 +5089,7 @@ function Oi({
5089
5089
  }),
5090
5090
  [r]
5091
5091
  );
5092
- if (z(() => {
5092
+ if (q(() => {
5093
5093
  var u, g, m;
5094
5094
  if (((u = d.current) == null ? void 0 : u.identity) !== f) {
5095
5095
  const y = (g = d.current) == null ? void 0 : g.widgetCtx.dispose({
@@ -5136,7 +5136,7 @@ function Oi({
5136
5136
  });
5137
5137
  }
5138
5138
  );
5139
- }, [f, t, a]), z(
5139
+ }, [f, t, a]), q(
5140
5140
  () => () => {
5141
5141
  var S;
5142
5142
  p.current = null, (S = d.current) == null || S.widgetCtx.dispose(), d.current = null;
@@ -5168,13 +5168,13 @@ function Oi({
5168
5168
  /* @__PURE__ */ K.createElement(Qr, { key: f, widgetCtx: I, config: t }, e)
5169
5169
  );
5170
5170
  }
5171
- function ie() {
5171
+ function re() {
5172
5172
  const t = Ne(ta);
5173
5173
  if (!t)
5174
5174
  throw new Error("useWidget must be used within a WidgetProvider");
5175
5175
  return t;
5176
5176
  }
5177
- function Ni({
5177
+ function Li({
5178
5178
  liveItems: t,
5179
5179
  turnSources: e
5180
5180
  }) {
@@ -5188,8 +5188,8 @@ function Ni({
5188
5188
  if (i) return i.plan;
5189
5189
  }
5190
5190
  }
5191
- function ji() {
5192
- const { config: t, widgetCtx: e } = ie(), { name: r, avatarUrl: a } = e.agent, n = t.bot;
5191
+ function Fi() {
5192
+ const { config: t, widgetCtx: e } = re(), { name: r, avatarUrl: a } = e.agent, n = t.bot;
5193
5193
  return te(
5194
5194
  () => ({
5195
5195
  isAi: !0,
@@ -5202,23 +5202,23 @@ function ji() {
5202
5202
  );
5203
5203
  }
5204
5204
  function pt() {
5205
- const { config: t } = ie();
5205
+ const { config: t } = re();
5206
5206
  return t;
5207
5207
  }
5208
- function Di() {
5209
- const { config: t } = ie();
5208
+ function $i() {
5209
+ const { config: t } = re();
5210
5210
  return t.displayMode ?? "popover";
5211
5211
  }
5212
- function ki() {
5213
- const { widgetCtx: t } = ie();
5212
+ function Ui() {
5213
+ const { widgetCtx: t } = re();
5214
5214
  return {
5215
- contactState: G(t.contactCtx.state),
5215
+ contactState: H(t.contactCtx.state),
5216
5216
  createUnverifiedContact: t.contactCtx.createUnverifiedContact
5217
5217
  };
5218
5218
  }
5219
5219
  function vi() {
5220
5220
  const [t, e] = J("ltr");
5221
- return z(() => {
5221
+ return q(() => {
5222
5222
  const r = () => {
5223
5223
  typeof document > "u" || e(
5224
5224
  window.getComputedStyle((window.top || window).document.body).direction
@@ -5265,11 +5265,11 @@ function Ci() {
5265
5265
  var t;
5266
5266
  return `${aa}|${((t = ra()) == null ? void 0 : t.location.href) ?? ""}`;
5267
5267
  }
5268
- function Li() {
5269
- return Ke(bi, Ci, () => "");
5268
+ function qi() {
5269
+ return $e(bi, Ci, () => "");
5270
5270
  }
5271
5271
  function na() {
5272
- const { widgetCtx: t } = ie(), e = G(t.messageCtx.state), { isStreaming: r } = Gr();
5272
+ const { widgetCtx: t } = re(), e = H(t.messageCtx.state), { isStreaming: r } = Gr();
5273
5273
  return {
5274
5274
  messagesState: r ? { ...e, isSendingMessage: !0, isSendingMessageToAI: !0 } : e,
5275
5275
  sendMessage: t.messageCtx.sendMessage,
@@ -5281,7 +5281,7 @@ function na() {
5281
5281
  }
5282
5282
  function sa() {
5283
5283
  var f;
5284
- const { widgetCtx: t } = ie(), { oneOpenSessionAllowed: e } = pt(), r = G(t.sessionCtx.sessionState), a = G(t.sessionCtx.sessionsState), { openSessions: n, closedSessions: i } = te(() => ({
5284
+ const { widgetCtx: t } = re(), { oneOpenSessionAllowed: e } = pt(), r = H(t.sessionCtx.sessionState), a = H(t.sessionCtx.sessionsState), { openSessions: n, closedSessions: i } = te(() => ({
5285
5285
  openSessions: a.data.filter((c) => c.isOpened === !0),
5286
5286
  closedSessions: a.data.filter((c) => c.isOpened === !1)
5287
5287
  }), [a.data]), { workspace: l } = ea(), s = l ? l.canCreateChat() : !e || n.length === 0 && !r.isCreatingSession && !((f = r.session) != null && f.isOpened);
@@ -5296,23 +5296,71 @@ function sa() {
5296
5296
  canCreateNewSession: s
5297
5297
  };
5298
5298
  }
5299
- function Fi() {
5299
+ function zi() {
5300
5300
  var l, s;
5301
5301
  const { sessionState: t } = sa(), { messagesState: e } = na(), r = ((l = t.session) == null ? void 0 : l.assignee.kind) === "ai", a = (s = e.messages) == null ? void 0 : s.at(-1), n = (a == null ? void 0 : a.type) === "USER" && a.id !== e.settledAgentUserMessageId;
5302
5302
  return { isAwaitingBotReply: !!(e.isSendingMessageToAI || (r || t.isCreatingSession) && (e.isSendingMessage || n)) };
5303
5303
  }
5304
- function $i() {
5305
- const { widgetCtx: t } = ie();
5304
+ function Si() {
5305
+ const { widgetCtx: t } = re();
5306
5306
  return {
5307
- routerState: G(t.routerCtx.state),
5307
+ routerState: H(t.routerCtx.state),
5308
5308
  toSessionsScreen: t.routerCtx.toSessionsScreen,
5309
5309
  toChatScreen: t.routerCtx.toChatScreen
5310
5310
  };
5311
5311
  }
5312
- function Ui() {
5312
+ function Zi() {
5313
+ const { widgetCtx: t } = re(), { unreadSessionIds: e, count: r } = H(
5314
+ t.unreadCtx.state
5315
+ ), a = U(
5316
+ (n) => e.includes(n),
5317
+ [e]
5318
+ );
5319
+ return { count: r, hasUnread: r > 0, unreadSessionIds: e, isUnread: a };
5320
+ }
5321
+ const ia = ze(null);
5322
+ function Wi({ children: t }) {
5323
+ const e = pt(), [r, a] = J(() => e.inline ? !0 : e.isOpen ?? !1);
5324
+ return q(() => {
5325
+ a((n) => e.isOpen ?? n);
5326
+ }, [e.isOpen]), q(() => {
5327
+ const n = e.openAfterNSeconds;
5328
+ if (typeof n != "number" || isNaN(n))
5329
+ return;
5330
+ const i = setTimeout(() => a(!0), n * 1e3);
5331
+ return () => clearTimeout(i);
5332
+ }, [e.openAfterNSeconds]), /* @__PURE__ */ K.createElement(ia.Provider, { value: { isOpen: r, setIsOpen: a } }, t);
5333
+ }
5334
+ function Ei() {
5335
+ const t = Ne(ia);
5336
+ if (!t)
5337
+ throw new Error(
5338
+ "useWidgetTrigger must be used within a WidgetTriggerProvider"
5339
+ );
5340
+ return t;
5341
+ }
5342
+ const wi = (t) => (document.addEventListener("visibilitychange", t), () => document.removeEventListener("visibilitychange", t)), Ii = () => document.visibilityState !== "hidden";
5343
+ function Vi({
5344
+ transcriptVisible: t = !0
5345
+ } = {}) {
5346
+ const { widgetCtx: e } = re(), { isOpen: r } = Ei(), { routerState: a } = Si(), { session: n } = H(e.sessionCtx.sessionState), { isInitialFetchLoading: i } = H(
5347
+ e.messageCtx.state
5348
+ ), l = $e(
5349
+ wi,
5350
+ Ii,
5351
+ () => !0
5352
+ ), s = r && l && t && a.screen === "chat" && !i ? (n == null ? void 0 : n.id) ?? null : null;
5353
+ q(() => {
5354
+ e.unreadCtx.setViewingSessionId(s);
5355
+ }, [e, s]), q(
5356
+ () => () => e.unreadCtx.setViewingSessionId(null),
5357
+ [e]
5358
+ );
5359
+ }
5360
+ function Bi() {
5313
5361
  const {
5314
5362
  widgetCtx: { uploadCtx: t }
5315
- } = ie(), e = G(t.state), r = te(
5363
+ } = re(), e = H(t.state), r = te(
5316
5364
  () => e.filter((a) => a.status === "success" && a.fileUrl),
5317
5365
  [e]
5318
5366
  );
@@ -5335,47 +5383,26 @@ function Ui() {
5335
5383
  isUploading: e.some((a) => a.status === "uploading")
5336
5384
  };
5337
5385
  }
5338
- const ia = qe(null);
5339
- function qi({ children: t }) {
5340
- const e = pt(), [r, a] = J(() => e.inline ? !0 : e.isOpen ?? !1);
5341
- return z(() => {
5342
- a((n) => e.isOpen ?? n);
5343
- }, [e.isOpen]), z(() => {
5344
- const n = e.openAfterNSeconds;
5345
- if (typeof n != "number" || isNaN(n))
5346
- return;
5347
- const i = setTimeout(() => a(!0), n * 1e3);
5348
- return () => clearTimeout(i);
5349
- }, [e.openAfterNSeconds]), /* @__PURE__ */ K.createElement(ia.Provider, { value: { isOpen: r, setIsOpen: a } }, t);
5350
- }
5351
- function zi() {
5352
- const t = Ne(ia);
5353
- if (!t)
5354
- throw new Error(
5355
- "useWidgetTrigger must be used within a WidgetTriggerProvider"
5356
- );
5357
- return t;
5358
- }
5359
- function Si(t) {
5386
+ function _i(t) {
5360
5387
  return t !== "fullscreen";
5361
5388
  }
5362
- const oa = qe(null);
5363
- function Zi({ children: t }) {
5389
+ const oa = ze(null);
5390
+ function Ji({ children: t }) {
5364
5391
  var n, i;
5365
- const { companion: e } = pt(), { dir: r } = vi(), { widgetCtx: a } = ie();
5392
+ const { companion: e } = pt(), { dir: r } = vi(), { widgetCtx: a } = re();
5366
5393
  return /* @__PURE__ */ K.createElement(
5367
- Ei,
5394
+ Ai,
5368
5395
  {
5369
5396
  configuredDefaultLayout: e == null ? void 0 : e.defaultLayout,
5370
5397
  configuredLayouts: e == null ? void 0 : e.layouts,
5371
- configuredSidebarSide: xa((n = e == null ? void 0 : e.sidebar) == null ? void 0 : n.side, r),
5372
- configuredSidebarMode: Ta((i = e == null ? void 0 : e.sidebar) == null ? void 0 : i.mode),
5398
+ configuredSidebarSide: Ta((n = e == null ? void 0 : e.sidebar) == null ? void 0 : n.side, r),
5399
+ configuredSidebarMode: xa((i = e == null ? void 0 : e.sidebar) == null ? void 0 : i.mode),
5373
5400
  storage: a.storageCtx
5374
5401
  },
5375
5402
  t
5376
5403
  );
5377
5404
  }
5378
- function Ei({
5405
+ function Ai({
5379
5406
  configuredDefaultLayout: t,
5380
5407
  configuredLayouts: e,
5381
5408
  configuredSidebarSide: r,
@@ -5399,7 +5426,7 @@ function Ei({
5399
5426
  }, O = R(l);
5400
5427
  O.current = l;
5401
5428
  const I = (h) => {
5402
- v(h), O.current.includes(h) && Si(h) && (n == null || n.setCompanionLayout(h).catch(() => {
5429
+ v(h), O.current.includes(h) && _i(h) && (n == null || n.setCompanionLayout(h).catch(() => {
5403
5430
  }));
5404
5431
  }, [E, _] = J(r), [S, M] = J(a), [u, g] = J({
5405
5432
  side: r,
@@ -5408,7 +5435,7 @@ function Ei({
5408
5435
  (u.side !== r || u.mode !== a) && (g({
5409
5436
  side: r,
5410
5437
  mode: a
5411
- }), u.side !== r && _(r), u.mode !== a && M(a)), z(() => {
5438
+ }), u.side !== r && _(r), u.mode !== a && M(a)), q(() => {
5412
5439
  if (!n) return;
5413
5440
  let h = !1;
5414
5441
  return n.getCompanionLayout().then((w) => {
@@ -5455,7 +5482,7 @@ function Ei({
5455
5482
  i
5456
5483
  );
5457
5484
  }
5458
- function Wi() {
5485
+ function Ki() {
5459
5486
  const t = Ne(oa);
5460
5487
  if (!t)
5461
5488
  throw new Error(
@@ -5463,9 +5490,9 @@ function Wi() {
5463
5490
  );
5464
5491
  return t;
5465
5492
  }
5466
- function Bi() {
5493
+ function Yi() {
5467
5494
  var s, f;
5468
- const { widgetCtx: t } = ie(), { modesComponents: e } = pt(), { sessionState: r } = sa(), a = t.modes, n = (s = r.session) == null ? void 0 : s.modeId, i = a.find((c) => c.id === n), l = (f = e == null ? void 0 : e.find(
5495
+ const { widgetCtx: t } = re(), { modesComponents: e } = pt(), { sessionState: r } = sa(), a = t.modes, n = (s = r.session) == null ? void 0 : s.modeId, i = a.find((c) => c.id === n), l = (f = e == null ? void 0 : e.find(
5469
5496
  (c) => {
5470
5497
  var p, d;
5471
5498
  return [
@@ -5483,8 +5510,8 @@ function Bi() {
5483
5510
  Component: l
5484
5511
  };
5485
5512
  }
5486
- function Vi() {
5487
- const { widgetCtx: t } = ie(), {
5513
+ function Hi() {
5514
+ const { widgetCtx: t } = re(), {
5488
5515
  messagesState: { messages: e }
5489
5516
  } = na(), {
5490
5517
  csatRequestedMessage: r,
@@ -5518,8 +5545,8 @@ function Vi() {
5518
5545
  submittedFeedback: s
5519
5546
  };
5520
5547
  }
5521
- function Ji(t) {
5522
- const { widgetCtx: e } = ie(), r = e.dictationCtx, a = G(r.state), n = R(t);
5548
+ function Gi(t) {
5549
+ const { widgetCtx: e } = re(), r = e.dictationCtx, a = H(r.state), n = R(t);
5523
5550
  n.current = t;
5524
5551
  const i = U(() => {
5525
5552
  r.start({
@@ -5533,7 +5560,7 @@ function Ji(t) {
5533
5560
  }, [r]), l = U(() => {
5534
5561
  r.isActive() ? r.stop() : i();
5535
5562
  }, [r, i]);
5536
- return z(() => () => r.stop({ executeFinalCommand: !1 }), [r]), {
5563
+ return q(() => () => r.stop({ executeFinalCommand: !1 }), [r]), {
5537
5564
  enabled: e.features.dictation,
5538
5565
  status: a.status,
5539
5566
  error: a.error,
@@ -5546,8 +5573,8 @@ function Ji(t) {
5546
5573
  prewarm: r.prewarm
5547
5574
  };
5548
5575
  }
5549
- function Ki() {
5550
- const { widgetCtx: t } = ie(), e = t.messageCtx.draftState, r = G(e), a = U(
5576
+ function Qi() {
5577
+ const { widgetCtx: t } = re(), e = t.messageCtx.draftState, r = H(e), a = U(
5551
5578
  (l) => {
5552
5579
  e.setPartial({
5553
5580
  text: typeof l == "function" ? l(e.get().text) : l
@@ -5569,33 +5596,35 @@ function Ki() {
5569
5596
  }
5570
5597
  export {
5571
5598
  Mt as HOST_CONTEXT_CHANGED_EVENT,
5572
- Zi as WidgetLayoutProvider,
5573
- Oi as WidgetProvider,
5574
- qi as WidgetTriggerProvider,
5599
+ Ji as WidgetLayoutProvider,
5600
+ ki as WidgetProvider,
5601
+ Wi as WidgetTriggerProvider,
5575
5602
  fr as applyPresentation,
5576
- Mi as formatAskQuestionsAnswers,
5577
- Ni as sessionPlan,
5603
+ Ni as formatAskQuestionsAnswers,
5604
+ Li as sessionPlan,
5578
5605
  Gr as useAgentChatUi,
5579
- ji as useBot,
5580
- Ri as useCompanionChats,
5581
- Ki as useComposerDraft,
5606
+ Fi as useBot,
5607
+ Di as useCompanionChats,
5608
+ Qi as useComposerDraft,
5582
5609
  pt as useConfig,
5583
- Pi as useConnection,
5584
- ki as useContact,
5585
- Vi as useCsat,
5586
- Ji as useDictation,
5587
- Di as useDisplayMode,
5610
+ ji as useConnection,
5611
+ Ui as useContact,
5612
+ Hi as useCsat,
5613
+ Gi as useDictation,
5614
+ $i as useDisplayMode,
5588
5615
  vi as useDocumentDir,
5589
- Li as useHostLocation,
5590
- Fi as useIsAwaitingBotReply,
5616
+ qi as useHostLocation,
5617
+ zi as useIsAwaitingBotReply,
5591
5618
  na as useMessages,
5592
- Bi as useModes,
5593
- G as usePrimitiveState,
5619
+ Yi as useModes,
5620
+ H as usePrimitiveState,
5594
5621
  sa as useSessions,
5595
- Ui as useUploadFiles,
5596
- ie as useWidget,
5597
- Wi as useWidgetLayout,
5598
- $i as useWidgetRouter,
5599
- zi as useWidgetTrigger
5622
+ Zi as useUnread,
5623
+ Vi as useUnreadViewing,
5624
+ Bi as useUploadFiles,
5625
+ re as useWidget,
5626
+ Ki as useWidgetLayout,
5627
+ Si as useWidgetRouter,
5628
+ Ei as useWidgetTrigger
5600
5629
  };
5601
5630
  //# sourceMappingURL=index.js.map