teodor-new-chat-ui 4.3.253 → 4.3.254

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.esm.js CHANGED
@@ -57,16 +57,16 @@ function Dm() {
57
57
  var g = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
58
58
  function w(R) {
59
59
  {
60
- for (var V = arguments.length, oe = new Array(V > 1 ? V - 1 : 0), Se = 1; Se < V; Se++)
61
- oe[Se - 1] = arguments[Se];
62
- b("error", R, oe);
60
+ for (var V = arguments.length, se = new Array(V > 1 ? V - 1 : 0), Se = 1; Se < V; Se++)
61
+ se[Se - 1] = arguments[Se];
62
+ b("error", R, se);
63
63
  }
64
64
  }
65
- function b(R, V, oe) {
65
+ function b(R, V, se) {
66
66
  {
67
67
  var Se = g.ReactDebugCurrentFrame, Ge = Se.getStackAddendum();
68
- Ge !== "" && (V += "%s", oe = oe.concat([Ge]));
69
- var lt = oe.map(function(Ue) {
68
+ Ge !== "" && (V += "%s", se = se.concat([Ge]));
69
+ var lt = se.map(function(Ue) {
70
70
  return String(Ue);
71
71
  });
72
72
  lt.unshift("Warning: " + V), Function.prototype.apply.call(console[R], console, lt);
@@ -81,12 +81,12 @@ function Dm() {
81
81
  // with.
82
82
  R.$$typeof === N || R.getModuleId !== void 0));
83
83
  }
84
- function _(R, V, oe) {
84
+ function _(R, V, se) {
85
85
  var Se = R.displayName;
86
86
  if (Se)
87
87
  return Se;
88
88
  var Ge = V.displayName || V.name || "";
89
- return Ge !== "" ? oe + "(" + Ge + ")" : oe;
89
+ return Ge !== "" ? se + "(" + Ge + ")" : se;
90
90
  }
91
91
  function L(R) {
92
92
  return R.displayName || "Context";
@@ -118,8 +118,8 @@ function Dm() {
118
118
  var V = R;
119
119
  return L(V) + ".Consumer";
120
120
  case i:
121
- var oe = R;
122
- return L(oe._context) + ".Provider";
121
+ var se = R;
122
+ return L(se._context) + ".Provider";
123
123
  case l:
124
124
  return _(R, R.render, "ForwardRef");
125
125
  case f:
@@ -199,7 +199,7 @@ function Dm() {
199
199
  }
200
200
  }
201
201
  var ee = g.ReactCurrentDispatcher, K;
202
- function M(R, V, oe) {
202
+ function M(R, V, se) {
203
203
  {
204
204
  if (K === void 0)
205
205
  try {
@@ -214,16 +214,16 @@ function Dm() {
214
214
  }
215
215
  var z = !1, te;
216
216
  {
217
- var se = typeof WeakMap == "function" ? WeakMap : Map;
218
- te = new se();
217
+ var ie = typeof WeakMap == "function" ? WeakMap : Map;
218
+ te = new ie();
219
219
  }
220
220
  function ne(R, V) {
221
221
  if (!R || z)
222
222
  return "";
223
223
  {
224
- var oe = te.get(R);
225
- if (oe !== void 0)
226
- return oe;
224
+ var se = te.get(R);
225
+ if (se !== void 0)
226
+ return se;
227
227
  }
228
228
  var Se;
229
229
  z = !0;
@@ -288,14 +288,14 @@ function Dm() {
288
288
  var $n = R ? R.displayName || R.name : "", Nn = $n ? M($n) : "";
289
289
  return typeof R == "function" && te.set(R, Nn), Nn;
290
290
  }
291
- function De(R, V, oe) {
291
+ function De(R, V, se) {
292
292
  return ne(R, !1);
293
293
  }
294
294
  function Z(R) {
295
295
  var V = R.prototype;
296
296
  return !!(V && V.isReactComponent);
297
297
  }
298
- function pe(R, V, oe) {
298
+ function pe(R, V, se) {
299
299
  if (R == null)
300
300
  return "";
301
301
  if (typeof R == "function")
@@ -313,11 +313,11 @@ function Dm() {
313
313
  case l:
314
314
  return De(R.render);
315
315
  case f:
316
- return pe(R.type, V, oe);
316
+ return pe(R.type, V, se);
317
317
  case p: {
318
318
  var Se = R, Ge = Se._payload, lt = Se._init;
319
319
  try {
320
- return pe(lt(Ge), V, oe);
320
+ return pe(lt(Ge), V, se);
321
321
  } catch {
322
322
  }
323
323
  }
@@ -327,12 +327,12 @@ function Dm() {
327
327
  var Ie = Object.prototype.hasOwnProperty, je = {}, Ke = g.ReactDebugCurrentFrame;
328
328
  function Ze(R) {
329
329
  if (R) {
330
- var V = R._owner, oe = pe(R.type, R._source, V ? V.type : null);
331
- Ke.setExtraStackFrame(oe);
330
+ var V = R._owner, se = pe(R.type, R._source, V ? V.type : null);
331
+ Ke.setExtraStackFrame(se);
332
332
  } else
333
333
  Ke.setExtraStackFrame(null);
334
334
  }
335
- function He(R, V, oe, Se, Ge) {
335
+ function He(R, V, se, Se, Ge) {
336
336
  {
337
337
  var lt = Function.call.bind(Ie);
338
338
  for (var Ue in R)
@@ -340,14 +340,14 @@ function Dm() {
340
340
  var Be = void 0;
341
341
  try {
342
342
  if (typeof R[Ue] != "function") {
343
- var Ot = Error((Se || "React class") + ": " + oe + " type `" + Ue + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof R[Ue] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
343
+ var Ot = Error((Se || "React class") + ": " + se + " type `" + Ue + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof R[Ue] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
344
344
  throw Ot.name = "Invariant Violation", Ot;
345
345
  }
346
- Be = R[Ue](V, Ue, Se, oe, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
346
+ Be = R[Ue](V, Ue, Se, se, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
347
347
  } catch (Ct) {
348
348
  Be = Ct;
349
349
  }
350
- Be && !(Be instanceof Error) && (Ze(Ge), w("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", Se || "React class", oe, Ue, typeof Be), Ze(null)), Be instanceof Error && !(Be.message in je) && (je[Be.message] = !0, Ze(Ge), w("Failed %s type: %s", oe, Be.message), Ze(null));
350
+ Be && !(Be instanceof Error) && (Ze(Ge), w("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", Se || "React class", se, Ue, typeof Be), Ze(null)), Be instanceof Error && !(Be.message in je) && (je[Be.message] = !0, Ze(Ge), w("Failed %s type: %s", se, Be.message), Ze(null));
351
351
  }
352
352
  }
353
353
  }
@@ -357,8 +357,8 @@ function Dm() {
357
357
  }
358
358
  function Qe(R) {
359
359
  {
360
- var V = typeof Symbol == "function" && Symbol.toStringTag, oe = V && R[Symbol.toStringTag] || R.constructor.name || "Object";
361
- return oe;
360
+ var V = typeof Symbol == "function" && Symbol.toStringTag, se = V && R[Symbol.toStringTag] || R.constructor.name || "Object";
361
+ return se;
362
362
  }
363
363
  }
364
364
  function et(R) {
@@ -389,7 +389,7 @@ function Dm() {
389
389
  }
390
390
  return R.ref !== void 0;
391
391
  }
392
- function ie(R) {
392
+ function oe(R) {
393
393
  if (Ie.call(R, "key")) {
394
394
  var V = Object.getOwnPropertyDescriptor(R, "key").get;
395
395
  if (V && V.isReactWarning)
@@ -402,34 +402,34 @@ function Dm() {
402
402
  }
403
403
  function Le(R, V) {
404
404
  {
405
- var oe = function() {
405
+ var se = function() {
406
406
  kt || (kt = !0, w("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", V));
407
407
  };
408
- oe.isReactWarning = !0, Object.defineProperty(R, "key", {
409
- get: oe,
408
+ se.isReactWarning = !0, Object.defineProperty(R, "key", {
409
+ get: se,
410
410
  configurable: !0
411
411
  });
412
412
  }
413
413
  }
414
414
  function ke(R, V) {
415
415
  {
416
- var oe = function() {
416
+ var se = function() {
417
417
  St || (St = !0, w("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", V));
418
418
  };
419
- oe.isReactWarning = !0, Object.defineProperty(R, "ref", {
420
- get: oe,
419
+ se.isReactWarning = !0, Object.defineProperty(R, "ref", {
420
+ get: se,
421
421
  configurable: !0
422
422
  });
423
423
  }
424
424
  }
425
- var ve = function(R, V, oe, Se, Ge, lt, Ue) {
425
+ var ve = function(R, V, se, Se, Ge, lt, Ue) {
426
426
  var Be = {
427
427
  // This tag allows us to uniquely identify this as a React Element
428
428
  $$typeof: t,
429
429
  // Built-in properties that belong on the element
430
430
  type: R,
431
431
  key: V,
432
- ref: oe,
432
+ ref: se,
433
433
  props: Ue,
434
434
  // Record the component responsible for creating this element.
435
435
  _owner: lt
@@ -451,10 +451,10 @@ function Dm() {
451
451
  value: Ge
452
452
  }), Object.freeze && (Object.freeze(Be.props), Object.freeze(Be)), Be;
453
453
  };
454
- function ue(R, V, oe, Se, Ge) {
454
+ function ue(R, V, se, Se, Ge) {
455
455
  {
456
456
  var lt, Ue = {}, Be = null, Ot = null;
457
- oe !== void 0 && (Tt(oe), Be = "" + oe), ie(V) && (Tt(V.key), Be = "" + V.key), Je(V) && (Ot = V.ref, he(V, Ge));
457
+ se !== void 0 && (Tt(se), Be = "" + se), oe(V) && (Tt(V.key), Be = "" + V.key), Je(V) && (Ot = V.ref, he(V, Ge));
458
458
  for (lt in V)
459
459
  Ie.call(V, lt) && !st.hasOwnProperty(lt) && (Ue[lt] = V[lt]);
460
460
  if (R && R.defaultProps) {
@@ -472,8 +472,8 @@ function Dm() {
472
472
  var nt = g.ReactCurrentOwner, vt = g.ReactDebugCurrentFrame;
473
473
  function U(R) {
474
474
  if (R) {
475
- var V = R._owner, oe = pe(R.type, R._source, V ? V.type : null);
476
- vt.setExtraStackFrame(oe);
475
+ var V = R._owner, se = pe(R.type, R._source, V ? V.type : null);
476
+ vt.setExtraStackFrame(se);
477
477
  } else
478
478
  vt.setExtraStackFrame(null);
479
479
  }
@@ -502,10 +502,10 @@ Check the render method of \`` + R + "`.";
502
502
  {
503
503
  var V = mt();
504
504
  if (!V) {
505
- var oe = typeof R == "string" ? R : R.displayName || R.name;
506
- oe && (V = `
505
+ var se = typeof R == "string" ? R : R.displayName || R.name;
506
+ se && (V = `
507
507
 
508
- Check the top-level render call using <` + oe + ">.");
508
+ Check the top-level render call using <` + se + ">.");
509
509
  }
510
510
  return V;
511
511
  }
@@ -515,12 +515,12 @@ Check the top-level render call using <` + oe + ">.");
515
515
  if (!R._store || R._store.validated || R.key != null)
516
516
  return;
517
517
  R._store.validated = !0;
518
- var oe = Oe(V);
519
- if (Rt[oe])
518
+ var se = Oe(V);
519
+ if (Rt[se])
520
520
  return;
521
- Rt[oe] = !0;
521
+ Rt[se] = !0;
522
522
  var Se = "";
523
- R && R._owner && R._owner !== nt.current && (Se = " It was passed a child from " + $(R._owner.type) + "."), U(R), w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', oe, Se), U(null);
523
+ R && R._owner && R._owner !== nt.current && (Se = " It was passed a child from " + $(R._owner.type) + "."), U(R), w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', se, Se), U(null);
524
524
  }
525
525
  }
526
526
  function ut(R, V) {
@@ -528,8 +528,8 @@ Check the top-level render call using <` + oe + ">.");
528
528
  if (typeof R != "object")
529
529
  return;
530
530
  if (qe(R))
531
- for (var oe = 0; oe < R.length; oe++) {
532
- var Se = R[oe];
531
+ for (var se = 0; se < R.length; se++) {
532
+ var Se = R[se];
533
533
  ye(Se) && Vt(Se, V);
534
534
  }
535
535
  else if (ye(R))
@@ -547,18 +547,18 @@ Check the top-level render call using <` + oe + ">.");
547
547
  var V = R.type;
548
548
  if (V == null || typeof V == "string")
549
549
  return;
550
- var oe;
550
+ var se;
551
551
  if (typeof V == "function")
552
- oe = V.propTypes;
552
+ se = V.propTypes;
553
553
  else if (typeof V == "object" && (V.$$typeof === l || // Note: Memo only checks outer props here.
554
554
  // Inner props are checked in the reconciler.
555
555
  V.$$typeof === f))
556
- oe = V.propTypes;
556
+ se = V.propTypes;
557
557
  else
558
558
  return;
559
- if (oe) {
559
+ if (se) {
560
560
  var Se = $(V);
561
- He(oe, R.props, "prop", Se, R);
561
+ He(se, R.props, "prop", Se, R);
562
562
  } else if (V.PropTypes !== void 0 && !be) {
563
563
  be = !0;
564
564
  var Ge = $(V);
@@ -569,8 +569,8 @@ Check the top-level render call using <` + oe + ">.");
569
569
  }
570
570
  function Dn(R) {
571
571
  {
572
- for (var V = Object.keys(R.props), oe = 0; oe < V.length; oe++) {
573
- var Se = V[oe];
572
+ for (var V = Object.keys(R.props), se = 0; se < V.length; se++) {
573
+ var Se = V[se];
574
574
  if (Se !== "children" && Se !== "key") {
575
575
  U(R), w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", Se), U(null);
576
576
  break;
@@ -580,7 +580,7 @@ Check the top-level render call using <` + oe + ">.");
580
580
  }
581
581
  }
582
582
  var Jn = {};
583
- function Ln(R, V, oe, Se, Ge, lt) {
583
+ function Ln(R, V, se, Se, Ge, lt) {
584
584
  {
585
585
  var Ue = I(R);
586
586
  if (!Ue) {
@@ -591,7 +591,7 @@ Check the top-level render call using <` + oe + ">.");
591
591
  var Ct;
592
592
  R === null ? Ct = "null" : qe(R) ? Ct = "array" : R !== void 0 && R.$$typeof === t ? (Ct = "<" + ($(R.type) || "Unknown") + " />", Be = " Did you accidentally export a JSX literal instead of a component?") : Ct = typeof R, w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", Ct, Be);
593
593
  }
594
- var wt = ue(R, V, oe, Ge, lt);
594
+ var wt = ue(R, V, se, Ge, lt);
595
595
  if (wt == null)
596
596
  return wt;
597
597
  if (Ue) {
@@ -624,11 +624,11 @@ React keys must be passed directly to JSX without using spread:
624
624
  return R === r ? Dn(wt) : Et(wt), wt;
625
625
  }
626
626
  }
627
- function ti(R, V, oe) {
628
- return Ln(R, V, oe, !0);
627
+ function ti(R, V, se) {
628
+ return Ln(R, V, se, !0);
629
629
  }
630
- function So(R, V, oe) {
631
- return Ln(R, V, oe, !1);
630
+ function So(R, V, se) {
631
+ return Ln(R, V, se, !1);
632
632
  }
633
633
  var ni = So, ri = ti;
634
634
  $r.Fragment = r, $r.jsx = ni, $r.jsxs = ri;
@@ -2968,7 +2968,7 @@ function Lx(e = {}) {
2968
2968
  threadId: A.threadId ?? null,
2969
2969
  headers: {}
2970
2970
  }, (async () => {
2971
- var fe, Ne, Ae, H, ee, K, M, z, te, se, ne, De, Z, pe, Ie, je, Ke, Ze;
2971
+ var fe, Ne, Ae, H, ee, K, M, z, te, ie, ne, De, Z, pe, Ie, je, Ke, Ze;
2972
2972
  const J = (He) => {
2973
2973
  var ze;
2974
2974
  try {
@@ -3047,7 +3047,7 @@ function Lx(e = {}) {
3047
3047
  st = [], T.current && p((ue) => ue + ve);
3048
3048
  }
3049
3049
  St = null;
3050
- }, ie = () => {
3050
+ }, oe = () => {
3051
3051
  typeof window < "u" && St == null && (St = requestAnimationFrame(Je));
3052
3052
  };
3053
3053
  let he = Date.now();
@@ -3120,10 +3120,10 @@ function Lx(e = {}) {
3120
3120
  console.error("[use-chat] Error in onEvent callback:", ut, "for event:", Oe.type);
3121
3121
  }
3122
3122
  if (Oe.type === "token" && e.autoAppendAssistant !== !1)
3123
- st.push(Oe.content), ie();
3123
+ st.push(Oe.content), oe();
3124
3124
  else if (Oe.type === "message_delta") {
3125
3125
  const ut = Oe.delta.filter((Et) => Et.type === "text").map((Et) => Et.text).join("");
3126
- ut && e.autoAppendAssistant !== !1 && (st.push(ut), ie());
3126
+ ut && e.autoAppendAssistant !== !1 && (st.push(ut), oe());
3127
3127
  } else if (Oe.type === "heartbeat") {
3128
3128
  console.debug("[use-chat] heartbeat received");
3129
3129
  try {
@@ -3135,7 +3135,7 @@ function Lx(e = {}) {
3135
3135
  m(Oe.checkpointId);
3136
3136
  else if (Oe.type === "error") {
3137
3137
  const ut = Oe;
3138
- if (d(ut.message), P = "error", D = ut.message, ut.error_type === "auth_error" || ut.code === "TOKEN_EXPIRED" || ((te = ut.message) == null ? void 0 : te.includes("token")) || ((se = ut.message) == null ? void 0 : se.includes("401")) || ((ne = ut.message) == null ? void 0 : ne.includes("unauthorized")) || ((De = ut.message) == null ? void 0 : De.includes("Unauthorized"))) {
3138
+ if (d(ut.message), P = "error", D = ut.message, ut.error_type === "auth_error" || ut.code === "TOKEN_EXPIRED" || ((te = ut.message) == null ? void 0 : te.includes("token")) || ((ie = ut.message) == null ? void 0 : ie.includes("401")) || ((ne = ut.message) == null ? void 0 : ne.includes("unauthorized")) || ((De = ut.message) == null ? void 0 : De.includes("Unauthorized"))) {
3139
3139
  console.error("[use-chat] Auth error detected:", ut.message);
3140
3140
  try {
3141
3141
  (Z = j == null ? void 0 : j.onAuthError) == null || Z.call(j, ut.message);
@@ -3884,38 +3884,38 @@ function Xx({
3884
3884
  const M = Xe(), z = Te(async () => {
3885
3885
  g(!0), b(null);
3886
3886
  try {
3887
- const ie = await c.listThreads();
3888
- h(ie ?? []);
3889
- } catch (ie) {
3890
- const he = String(ie);
3887
+ const oe = await c.listThreads();
3888
+ h(oe ?? []);
3889
+ } catch (oe) {
3890
+ const he = String(oe);
3891
3891
  b(he), s == null || s(he);
3892
3892
  } finally {
3893
3893
  g(!1);
3894
3894
  }
3895
- }, [c, s]), te = Te((ie) => {
3896
- if (!(ie != null && ie.threadId)) return;
3895
+ }, [c, s]), te = Te((oe) => {
3896
+ if (!(oe != null && oe.threadId)) return;
3897
3897
  const he = {
3898
- threadId: ie.threadId,
3899
- title: ie.title || `Thread ${ie.threadId.slice(0, 8)}`,
3900
- createdAt: ie.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
3901
- updatedAt: ie.updatedAt || (/* @__PURE__ */ new Date()).toISOString(),
3902
- messageCount: ie.messageCount ?? 1
3898
+ threadId: oe.threadId,
3899
+ title: oe.title || `Thread ${oe.threadId.slice(0, 8)}`,
3900
+ createdAt: oe.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
3901
+ updatedAt: oe.updatedAt || (/* @__PURE__ */ new Date()).toISOString(),
3902
+ messageCount: oe.messageCount ?? 1
3903
3903
  };
3904
3904
  h((Le) => Le.some((ve) => ve.threadId === he.threadId) ? (console.debug("[ChatSessionProvider] thread_info: thread already in list", he.threadId), Le) : (console.debug("[ChatSessionProvider] thread_info: adding thread to list", he.threadId), [he, ...Le]));
3905
- }, []), se = Te((ie) => {
3906
- console.log("[ChatSessionProvider] 🎯 Received thread_info:", ie.threadId), te(ie), H.current !== ie.threadId && (!H.current && E.messages.length <= 1 && (K.current = ie.threadId), y(ie.threadId));
3905
+ }, []), ie = Te((oe) => {
3906
+ console.log("[ChatSessionProvider] 🎯 Received thread_info:", oe.threadId), te(oe), H.current !== oe.threadId && (!H.current && E.messages.length <= 1 && (K.current = oe.threadId), y(oe.threadId));
3907
3907
  }, [te, E.messages.length]), { startStream: ne, stop: De, isStreaming: Z, error: pe, setAuthToken: Ie } = Gx({
3908
3908
  baseUrl: f,
3909
- onThreadInfo: se,
3909
+ onThreadInfo: ie,
3910
3910
  onMessageEvent: L,
3911
- onUnhandledEvent: (ie) => {
3912
- console.warn("[ChatSessionProvider] Unhandled event:", ie.type);
3911
+ onUnhandledEvent: (oe) => {
3912
+ console.warn("[ChatSessionProvider] Unhandled event:", oe.type);
3913
3913
  },
3914
3914
  onAuthError: i
3915
3915
  }), je = Te(
3916
- async (ie) => {
3916
+ async (oe) => {
3917
3917
  try {
3918
- const he = await c.createThread(ie);
3918
+ const he = await c.createThread(oe);
3919
3919
  return y(he.threadId), await z(), he.threadId;
3920
3920
  } catch (he) {
3921
3921
  return s == null || s(String(he)), null;
@@ -3923,37 +3923,37 @@ function Xx({
3923
3923
  },
3924
3924
  [c, z, s]
3925
3925
  ), Ke = Te(
3926
- async (ie) => {
3926
+ async (oe) => {
3927
3927
  try {
3928
- await c.deleteThread(ie), H.current === ie && (y(null), N([], {})), await z();
3928
+ await c.deleteThread(oe), H.current === oe && (y(null), N([], {})), await z();
3929
3929
  } catch (he) {
3930
3930
  s == null || s(String(he));
3931
3931
  }
3932
3932
  },
3933
3933
  [c, z, N, s]
3934
3934
  ), Ze = Te(
3935
- async (ie, he) => {
3935
+ async (oe, he) => {
3936
3936
  try {
3937
- await c.updateThread(ie, he), await z();
3937
+ await c.updateThread(oe, he), await z();
3938
3938
  } catch (Le) {
3939
3939
  s == null || s(String(Le));
3940
3940
  }
3941
3941
  },
3942
3942
  [c, z, s]
3943
3943
  ), He = Te(
3944
- (ie, he, Le) => {
3944
+ (oe, he, Le) => {
3945
3945
  const ke = he.filter((ve) => ve.checkpointId).map((ve) => ({
3946
3946
  checkpointId: ve.checkpointId,
3947
3947
  checkpointNs: ve.checkpointNs ?? void 0,
3948
3948
  createdAt: ve.createdAt ?? ""
3949
3949
  }));
3950
- console.log(`[ChatSessionProvider] Cached metadata for ${ke.length} checkpoints from ${Le}`), Ae(ie, ke);
3950
+ console.log(`[ChatSessionProvider] Cached metadata for ${ke.length} checkpoints from ${Le}`), Ae(oe, ke);
3951
3951
  },
3952
3952
  [Ae]
3953
3953
  ), ze = Te(
3954
- async (ie, he) => {
3955
- if (!ie) return;
3956
- const Le = ie;
3954
+ async (oe, he) => {
3955
+ if (!oe) return;
3956
+ const Le = oe;
3957
3957
  C(!0), k(null);
3958
3958
  try {
3959
3959
  const ke = await c.getStateHistory({
@@ -3987,7 +3987,7 @@ function Xx({
3987
3987
  M.current = ze;
3988
3988
  }, [ze]);
3989
3989
  const qe = Te(
3990
- async (ie, he) => {
3990
+ async (oe, he) => {
3991
3991
  const Le = H.current;
3992
3992
  if (!Le) return;
3993
3993
  const ke = Le;
@@ -3995,7 +3995,7 @@ function Xx({
3995
3995
  try {
3996
3996
  const ve = await c.getStateHistory({
3997
3997
  threadId: ke,
3998
- checkpointId: ie,
3998
+ checkpointId: oe,
3999
3999
  checkpointNs: he ?? void 0
4000
4000
  });
4001
4001
  if (H.current !== ke) {
@@ -4005,10 +4005,10 @@ function Xx({
4005
4005
  const { checkpoints: ue } = Ur(ve);
4006
4006
  He(ke, ue, "checkpoint navigation");
4007
4007
  const nt = ue.find(
4008
- (vt) => vt.checkpointId === ie && (he ? vt.checkpointNs === he : !0)
4008
+ (vt) => vt.checkpointId === oe && (he ? vt.checkpointNs === he : !0)
4009
4009
  );
4010
4010
  if (!nt) {
4011
- console.warn("[ChatSessionProvider] Requested checkpoint not found:", { checkpointId: ie, checkpointNs: he });
4011
+ console.warn("[ChatSessionProvider] Requested checkpoint not found:", { checkpointId: oe, checkpointNs: he });
4012
4012
  return;
4013
4013
  }
4014
4014
  G(ue), N(nt.messages ?? [], {
@@ -4023,9 +4023,9 @@ function Xx({
4023
4023
  },
4024
4024
  [c, N, s, He]
4025
4025
  ), Qe = Te(
4026
- (ie, he) => {
4026
+ (oe, he) => {
4027
4027
  N(E.messages, {
4028
- checkpointId: ie ?? null,
4028
+ checkpointId: oe ?? null,
4029
4029
  checkpointNs: he ?? null
4030
4030
  });
4031
4031
  },
@@ -4034,15 +4034,15 @@ function Xx({
4034
4034
  H.current && await ze(H.current);
4035
4035
  }, [ze]), ot = Te(async () => {
4036
4036
  if (!H.current || !Y) return;
4037
- const ie = H.current;
4037
+ const oe = H.current;
4038
4038
  j(!0);
4039
4039
  try {
4040
4040
  const he = await c.getStateHistory({
4041
- threadId: ie,
4041
+ threadId: oe,
4042
4042
  checkpointId: Y
4043
4043
  });
4044
- if (H.current !== ie) {
4045
- console.log(`[ChatSessionProvider] Thread changed during history load (was ${ie}, now ${H.current}), discarding stale data`);
4044
+ if (H.current !== oe) {
4045
+ console.log(`[ChatSessionProvider] Thread changed during history load (was ${oe}, now ${H.current}), discarding stale data`);
4046
4046
  return;
4047
4047
  }
4048
4048
  const { checkpoints: Le } = Ur(he);
@@ -4051,14 +4051,19 @@ function Xx({
4051
4051
  I((ke == null ? void 0 : ke.messages) ?? []), A(!!(ke != null && ke.nextCursor)), P((ke == null ? void 0 : ke.nextCursor) ?? null);
4052
4052
  }
4053
4053
  } catch (he) {
4054
- H.current === ie && (s == null || s(String(he)));
4054
+ H.current === oe && (s == null || s(String(he)));
4055
4055
  } finally {
4056
4056
  j(!1);
4057
4057
  }
4058
4058
  }, [c, Y, I, s]), Tt = Te(async () => {
4059
- N([], {}), y(null), De(), G([]), A(!1), P(null), C(!1), fe(!1), j(!1), k(null), await c.getAgent("default");
4060
- }, [N, De]), ht = Te(
4061
- async (ie, he, Le) => {
4059
+ N([], {}), y(null), De(), G([]), A(!1), P(null), C(!1), fe(!1), j(!1), k(null);
4060
+ try {
4061
+ await c.getAgent("default");
4062
+ } catch (oe) {
4063
+ console.warn("[ChatSessionProvider] Failed to refetch agent after clearing thread:", oe);
4064
+ }
4065
+ }, [N, De, c]), ht = Te(
4066
+ async (oe, he, Le) => {
4062
4067
  const ke = H.current;
4063
4068
  if (!ke)
4064
4069
  throw new Error("No active thread to handle interrupt");
@@ -4073,7 +4078,7 @@ function Xx({
4073
4078
  };
4074
4079
  ne(ue);
4075
4080
  } catch (ue) {
4076
- throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${ie}:`, ue), ue;
4081
+ throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${oe}:`, ue), ue;
4077
4082
  }
4078
4083
  },
4079
4084
  [E.lastCheckpointId, E.lastCheckpointNs, ne]
@@ -4081,21 +4086,21 @@ function Xx({
4081
4086
  Nt(() => {
4082
4087
  z();
4083
4088
  }, [z]), Nt(() => {
4084
- var ie, he;
4089
+ var oe, he;
4085
4090
  if (!(!o || !m || T)) {
4086
4091
  if (K.current === m) {
4087
4092
  K.current = null;
4088
4093
  return;
4089
4094
  }
4090
- ee.current !== m && (ee.current = m, n ? (console.log("[ChatSessionProvider] Loading thread with checkpoint:", n), (ie = M.current) == null || ie.call(M, m, n)) : (console.log("[ChatSessionProvider] Loading thread with latest checkpoint"), (he = M.current) == null || he.call(M, m)));
4095
+ ee.current !== m && (ee.current = m, n ? (console.log("[ChatSessionProvider] Loading thread with checkpoint:", n), (oe = M.current) == null || oe.call(M, m, n)) : (console.log("[ChatSessionProvider] Loading thread with latest checkpoint"), (he = M.current) == null || he.call(M, m)));
4091
4096
  }
4092
4097
  }, [o, m, T, n, r]), Nt(() => {
4093
4098
  a == null || a(m);
4094
4099
  }, [m, a]);
4095
4100
  const st = Te(
4096
- async (ie, he) => {
4101
+ async (oe, he) => {
4097
4102
  let Le = H.current;
4098
- const ke = (ie == null ? void 0 : ie.text) ?? "";
4103
+ const ke = (oe == null ? void 0 : oe.text) ?? "";
4099
4104
  if (!Le && !ke) return;
4100
4105
  if (!Le && ke) {
4101
4106
  const U = Math.floor(Date.now() / 1e3).toString(16).padStart(8, "0"), be = Array.from(
@@ -4106,7 +4111,7 @@ function Xx({
4106
4111
  }
4107
4112
  const { contentParts: ve } = await wx(
4108
4113
  c,
4109
- (ie == null ? void 0 : ie.attachments) ?? []
4114
+ (oe == null ? void 0 : oe.attachments) ?? []
4110
4115
  ), ue = [...ve];
4111
4116
  ke != null && ke.trim() && ue.push({ type: "text", text: ke });
4112
4117
  const nt = {
@@ -6275,7 +6280,7 @@ var ed = "PopperAnchor", td = v.forwardRef(
6275
6280
  td.displayName = ed;
6276
6281
  var Na = "PopperContent", [$v, Fv] = Ju(Na), nd = v.forwardRef(
6277
6282
  (e, t) => {
6278
- var K, M, z, te, se, ne;
6283
+ var K, M, z, te, ie, ne;
6279
6284
  const {
6280
6285
  __scopePopper: n,
6281
6286
  side: r = "bottom",
@@ -6346,7 +6351,7 @@ var Na = "PopperContent", [$v, Fv] = Ju(Na), nd = v.forwardRef(
6346
6351
  zIndex: H,
6347
6352
  "--radix-popper-transform-origin": [
6348
6353
  (te = P.transformOrigin) == null ? void 0 : te.x,
6349
- (se = P.transformOrigin) == null ? void 0 : se.y
6354
+ (ie = P.transformOrigin) == null ? void 0 : ie.y
6350
6355
  ].join(" "),
6351
6356
  // hide the content if using the hide middleware and should be hidden
6352
6357
  // set visibility to hidden and disable pointer events so the UI behaves
@@ -9609,8 +9614,8 @@ const hr = tt(
9609
9614
  const H = L[0], ee = L[L.length - 1];
9610
9615
  let K = 0;
9611
9616
  for (const M of Hs(P, H, ee)) {
9612
- const z = M.value, te = Math.max(M.start, H), se = Math.min(M.end, ee);
9613
- for (let ne = te; ne <= se; ne++)
9617
+ const z = M.value, te = Math.max(M.start, H), ie = Math.min(M.end, ee);
9618
+ for (let ne = te; ne <= ie; ne++)
9614
9619
  G.push({ data: F == null ? void 0 : F[ne], index: ne, offset: K, size: z }), K += z;
9615
9620
  }
9616
9621
  }
@@ -9630,8 +9635,8 @@ const hr = tt(
9630
9635
  M += ne * te + ne * A;
9631
9636
  }
9632
9637
  z < J && (M += (J - z) * te, z = J);
9633
- const se = Math.min(ee.end, Ne);
9634
- for (let ne = z; ne <= se && !(M >= k); ne++)
9638
+ const ie = Math.min(ee.end, Ne);
9639
+ for (let ne = z; ne <= ie && !(M >= k); ne++)
9635
9640
  H.push({ data: F == null ? void 0 : F[ne], index: ne, offset: M, size: te }), M += te + A;
9636
9641
  }
9637
9642
  });
@@ -10810,7 +10815,7 @@ const TS = /* @__PURE__ */ tt(
10810
10815
  ), at(
10811
10816
  W(
10812
10817
  _t(m, G, I, N, D, J),
10813
- Ee(([M, z, te, se, , ne]) => M && !z && te.height !== 0 && se.height !== 0 && !ne)
10818
+ Ee(([M, z, te, ie, , ne]) => M && !z && te.height !== 0 && ie.height !== 0 && !ne)
10814
10819
  ),
10815
10820
  ([, , , , M]) => {
10816
10821
  $e(J, !0), Ua(1, () => {
@@ -10851,10 +10856,10 @@ const TS = /* @__PURE__ */ tt(
10851
10856
  Re(F, (M, z) => M && M.column === z.column && M.row === z.row),
10852
10857
  Re(c)
10853
10858
  ),
10854
- le(([M, z, te, se]) => ({
10859
+ le(([M, z, te, ie]) => ({
10855
10860
  gap: te,
10856
10861
  item: z,
10857
- scrollTop: se,
10862
+ scrollTop: ie,
10858
10863
  viewport: M
10859
10864
  }))
10860
10865
  ),
@@ -10878,7 +10883,7 @@ const TS = /* @__PURE__ */ tt(
10878
10883
  ([
10879
10884
  M,
10880
10885
  [z, te],
10881
- se,
10886
+ ie,
10882
10887
  ne,
10883
10888
  De,
10884
10889
  Z,
@@ -10887,17 +10892,17 @@ const TS = /* @__PURE__ */ tt(
10887
10892
  Ie,
10888
10893
  je
10889
10894
  ]) => {
10890
- const { column: Ke, row: Ze } = se, { height: He, width: ze } = ne, { width: qe } = De;
10895
+ const { column: Ke, row: Ze } = ie, { height: He, width: ze } = ne, { width: qe } = De;
10891
10896
  if (pe === 0 && (M === 0 || qe === 0))
10892
10897
  return Rc;
10893
10898
  if (ze === 0) {
10894
- const Je = Wa(je, M), ie = Je + Math.max(pe - 1, 0);
10895
- return SS(Nc(Je, ie, Z));
10899
+ const Je = Wa(je, M), oe = Je + Math.max(pe - 1, 0);
10900
+ return SS(Nc(Je, oe, Z));
10896
10901
  }
10897
10902
  const Qe = Xf(qe, ze, Ke);
10898
10903
  let et, ot;
10899
10904
  Ie ? z === 0 && te === 0 && pe > 0 ? (et = 0, ot = pe - 1) : (et = Qe * as((z + Ze) / (He + Ze)), ot = Qe * Ec((te + Ze) / (He + Ze)) - 1, ot = Ei(M - 1, Kr(ot, Qe - 1)), et = Ei(ot, Kr(0, et))) : (et = 0, ot = -1);
10900
- const Tt = Nc(et, ot, Z), { bottom: ht, top: st } = Ac(De, se, ne, Tt), kt = Ec(M / Qe), St = kt * He + (kt - 1) * Ze - ht;
10905
+ const Tt = Nc(et, ot, Z), { bottom: ht, top: st } = Ac(De, ie, ne, Tt), kt = Ec(M / Qe), St = kt * He + (kt - 1) * Ze - ht;
10901
10906
  return { bottom: ht, itemHeight: He, items: Tt, itemWidth: ze, offsetBottom: St, offsetTop: st, top: st };
10902
10907
  }
10903
10908
  )
@@ -10914,8 +10919,8 @@ const TS = /* @__PURE__ */ tt(
10914
10919
  W(
10915
10920
  _t(N, I, E, F),
10916
10921
  Ee(([M, z, { items: te }]) => te.length > 0 && z.height !== 0 && M.height !== 0),
10917
- le(([M, z, { items: te }, se]) => {
10918
- const { bottom: ne, top: De } = Ac(M, se, z, te);
10922
+ le(([M, z, { items: te }, ie]) => {
10923
+ const { bottom: ne, top: De } = Ac(M, ie, z, te);
10919
10924
  return [De, ne];
10920
10925
  }),
10921
10926
  xt(oo)
@@ -10937,8 +10942,8 @@ const TS = /* @__PURE__ */ tt(
10937
10942
  Ee(([{ items: M }]) => M.length > 0),
10938
10943
  Fe(Ne),
10939
10944
  Ee(([[M, z], te]) => {
10940
- const se = M.items[M.items.length - 1].index === z - 1;
10941
- return (te || M.bottom > 0 && M.itemHeight > 0 && M.offsetBottom === 0 && M.items.length === z) && se;
10945
+ const ie = M.items[M.items.length - 1].index === z - 1;
10946
+ return (te || M.bottom > 0 && M.itemHeight > 0 && M.offsetBottom === 0 && M.items.length === z) && ie;
10942
10947
  }),
10943
10948
  le(([[, M]]) => M - 1),
10944
10949
  xt()
@@ -10967,10 +10972,10 @@ const TS = /* @__PURE__ */ tt(
10967
10972
  W(
10968
10973
  _,
10969
10974
  Fe(N, I, S, F),
10970
- le(([M, z, te, se, ne]) => {
10975
+ le(([M, z, te, ie, ne]) => {
10971
10976
  const De = Pf(M), { align: Z, behavior: pe, offset: Ie } = De;
10972
10977
  let je = De.index;
10973
- je === "LAST" && (je = se - 1), je = Kr(0, je, Ei(se - 1, je));
10978
+ je === "LAST" && (je = ie - 1), je = Kr(0, je, Ei(ie - 1, je));
10974
10979
  let Ke = ea(z, ne, te, je);
10975
10980
  return Z === "end" ? Ke = Ic(Ke - z.height + te.height) : Z === "center" && (Ke = Ic(Ke - z.height / 2 + te.height / 2)), Ie && (Ke += Ie), { behavior: pe, top: Ke };
10976
10981
  })
@@ -13662,7 +13667,7 @@ const Bc = B.memo(function({
13662
13667
  default:
13663
13668
  return "text-[hsl(var(--chat-bubble-ai-text))]";
13664
13669
  }
13665
- }, [D]), te = ct(() => J ? "" : CC(t.content), [J, t]), se = ct(() => J ? {} : Pp(t), [J, t]), ne = ct(
13670
+ }, [D]), te = ct(() => J ? "" : CC(t.content), [J, t]), ie = ct(() => J ? {} : Pp(t), [J, t]), ne = ct(
13666
13671
  () => J ? [] : t.content.filter((U) => U.type === "image_url"),
13667
13672
  [J, t]
13668
13673
  ), De = ct(
@@ -13930,10 +13935,10 @@ const Bc = B.memo(function({
13930
13935
  L,
13931
13936
  st,
13932
13937
  z
13933
- ]), St = ct(() => J ? "Assistant" : kC(t), [J, t]), Je = B.useMemo(() => J ? [] : Array.isArray(C) ? C : [], [C, J]), ie = B.useMemo(() => {
13938
+ ]), St = ct(() => J ? "Assistant" : kC(t), [J, t]), Je = B.useMemo(() => J ? [] : Array.isArray(C) ? C : [], [C, J]), oe = B.useMemo(() => {
13934
13939
  var U;
13935
13940
  return Je.length ? E && Je.some((be) => be.id === E) ? E : ((U = Je[0]) == null ? void 0 : U.id) ?? null : null;
13936
- }, [E, Je]), Le = B.useMemo(() => !Je.length || !S ? null : Je.some((U) => U.id === S) ? S : null, [S, Je]) ?? ie, ke = D === "user" && Je.length > 0 && typeof k == "function", ve = B.useCallback(
13941
+ }, [E, Je]), Le = B.useMemo(() => !Je.length || !S ? null : Je.some((U) => U.id === S) ? S : null, [S, Je]) ?? oe, ke = D === "user" && Je.length > 0 && typeof k == "function", ve = B.useCallback(
13937
13942
  (U) => {
13938
13943
  if (!k) return;
13939
13944
  const be = (U == null ? void 0 : U.id) ?? null, ye = (U == null ? void 0 : U.parentId) ?? N ?? null;
@@ -13989,8 +13994,8 @@ const Bc = B.memo(function({
13989
13994
  (U.key === "Enter" || U.key === " ") && (U.preventDefault(), $((be) => be === "expanded" ? "preview" : "expanded"));
13990
13995
  },
13991
13996
  children: [
13992
- /* @__PURE__ */ u.jsx("span", { children: se.name ?? "Tool Output" }),
13993
- se.toolCallId && /* @__PURE__ */ u.jsx("span", { className: "opacity-70", children: se.toolCallId.slice(0, 8) }),
13997
+ /* @__PURE__ */ u.jsx("span", { children: ie.name ?? "Tool Output" }),
13998
+ ie.toolCallId && /* @__PURE__ */ u.jsx("span", { className: "opacity-70", children: ie.toolCallId.slice(0, 8) }),
13994
13999
  L === "expanded" ? /* @__PURE__ */ u.jsx(da, { className: "h-3 w-3" }) : /* @__PURE__ */ u.jsx(ys, { className: "h-3 w-3" })
13995
14000
  ]
13996
14001
  }
@@ -14103,14 +14108,14 @@ const Bc = B.memo(function({
14103
14108
  }
14104
14109
  ),
14105
14110
  /* @__PURE__ */ u.jsx("div", { className: "relative", children: kt() }),
14106
- G && L === "expanded" && (se.toolCallId || se.name) && /* @__PURE__ */ u.jsxs("div", { className: Q("mt-2 pt-2 border-t border-current/10 text-xs opacity-60", P && "text-xs"), children: [
14107
- se.name && /* @__PURE__ */ u.jsxs("div", { children: [
14111
+ G && L === "expanded" && (ie.toolCallId || ie.name) && /* @__PURE__ */ u.jsxs("div", { className: Q("mt-2 pt-2 border-t border-current/10 text-xs opacity-60", P && "text-xs"), children: [
14112
+ ie.name && /* @__PURE__ */ u.jsxs("div", { children: [
14108
14113
  "Function: ",
14109
- se.name
14114
+ ie.name
14110
14115
  ] }),
14111
- se.toolCallId && /* @__PURE__ */ u.jsxs("div", { children: [
14116
+ ie.toolCallId && /* @__PURE__ */ u.jsxs("div", { children: [
14112
14117
  "Call ID: ",
14113
- se.toolCallId
14118
+ ie.toolCallId
14114
14119
  ] })
14115
14120
  ] }),
14116
14121
  !(i || a || G) && s && !o && /* @__PURE__ */ u.jsxs(
@@ -14543,7 +14548,7 @@ const Hc = (e, t) => (e == null ? void 0 : e.id) ?? `message-${t}`, jC = (e) =>
14543
14548
  children: "Latest"
14544
14549
  }
14545
14550
  )
14546
- ] }) : null, se = ["flex h-full flex-col md:flex-row", f].filter(Boolean).join(" "), ne = () => z ? /* @__PURE__ */ u.jsx("div", { className: "p-6 h-full overflow-y-auto", children: /* @__PURE__ */ u.jsx("div", { className: "w-full max-w-full", children: /* @__PURE__ */ u.jsx(
14551
+ ] }) : null, ie = ["flex h-full flex-col md:flex-row", f].filter(Boolean).join(" "), ne = () => z ? /* @__PURE__ */ u.jsx("div", { className: "p-6 h-full overflow-y-auto", children: /* @__PURE__ */ u.jsx("div", { className: "w-full max-w-full", children: /* @__PURE__ */ u.jsx(
14547
14552
  Bc,
14548
14553
  {
14549
14554
  message: z,
@@ -14585,7 +14590,7 @@ const Hc = (e, t) => (e == null ? void 0 : e.id) ?? `message-${t}`, jC = (e) =>
14585
14590
  }
14586
14591
  }),
14587
14592
  [fe]
14588
- ), /* @__PURE__ */ u.jsxs("div", { className: se, style: p, children: [
14593
+ ), /* @__PURE__ */ u.jsxs("div", { className: ie, style: p, children: [
14589
14594
  te,
14590
14595
  /* @__PURE__ */ u.jsx("div", { className: "relative flex-1 min-h-0", children: De ? /* @__PURE__ */ u.jsx(
14591
14596
  vS,
@@ -14714,7 +14719,7 @@ function Ai({
14714
14719
  Ae(!0);
14715
14720
  }, []), ee = Te(() => {
14716
14721
  Ae(!1);
14717
- }, []), K = !!fe || Ne, [M, z] = xe(null), [te, se] = xe(""), [ne, De] = xe(null), [Z, pe] = xe(null), [Ie, je] = xe([]), [Ke, Ze] = xe(0), [He, ze] = xe(0), [qe, Qe] = xe(!1), [et, ot] = xe(null), [Tt, ht] = xe(null), [st, kt] = xe(!1), [St, Je] = xe(null), [ie, he] = xe(!1), Le = Xe(!1), [ke, ve] = xe(() => Uc.value), ue = Xe(ke), nt = Xe(null), vt = Te((q) => {
14722
+ }, []), K = !!fe || Ne, [M, z] = xe(null), [te, ie] = xe(""), [ne, De] = xe(null), [Z, pe] = xe(null), [Ie, je] = xe([]), [Ke, Ze] = xe(0), [He, ze] = xe(0), [qe, Qe] = xe(!1), [et, ot] = xe(null), [Tt, ht] = xe(null), [st, kt] = xe(!1), [St, Je] = xe(null), [oe, he] = xe(!1), Le = Xe(!1), [ke, ve] = xe(() => Uc.value), ue = Xe(ke), nt = Xe(null), vt = Te((q) => {
14718
14723
  Uc.value = q, ve(q);
14719
14724
  }, []), [U, be] = xe(!1), ye = Xe(null), mt = Te((q) => {
14720
14725
  if (!Array.isArray(q))
@@ -14868,13 +14873,13 @@ function Ai({
14868
14873
  nt.current === null && (nt.current = ue.current), vt(te ?? "");
14869
14874
  }, [te, M, vt]);
14870
14875
  const R = Te(async () => {
14871
- if (!(!b || T || !ie))
14876
+ if (!(!b || T || !oe))
14872
14877
  try {
14873
14878
  await S();
14874
14879
  } catch (q) {
14875
14880
  console.warn("loadOlder failed", q);
14876
14881
  }
14877
- }, [b, ie, T, S]);
14882
+ }, [b, oe, T, S]);
14878
14883
  Nt(() => {
14879
14884
  (async () => {
14880
14885
  if (!y.baseUrl) {
@@ -14899,7 +14904,7 @@ function Ai({
14899
14904
  } catch (re) {
14900
14905
  return (re == null ? void 0 : re.message) || "Invalid message";
14901
14906
  }
14902
- }, oe = async (q) => {
14907
+ }, se = async (q) => {
14903
14908
  const re = q.trim();
14904
14909
  if (!(!re && Ie.length === 0)) {
14905
14910
  if (re) {
@@ -14926,7 +14931,7 @@ function Ai({
14926
14931
  checkpointId: ae,
14927
14932
  checkpointNs: Ce
14928
14933
  }
14929
- ), p == null || p(re), vt(""), pe(null), je([]), Ln(), z(null), se(""), De(null);
14934
+ ), p == null || p(re), vt(""), pe(null), je([]), Ln(), z(null), ie(""), De(null);
14930
14935
  } catch (ae) {
14931
14936
  const Ce = (ae == null ? void 0 : ae.message) || "Failed to send message";
14932
14937
  pe(Ce), m == null || m(Ce);
@@ -14934,14 +14939,14 @@ function Ai({
14934
14939
  }
14935
14940
  }, Se = B.useCallback(
14936
14941
  (q, re, ae) => {
14937
- c && (nt.current = ke, z(q), se(re), vt(re), pe(null), De({
14942
+ c && (nt.current = ke, z(q), ie(re), vt(re), pe(null), De({
14938
14943
  checkpointId: (ae == null ? void 0 : ae.checkpointId) ?? null,
14939
14944
  checkpointNs: (ae == null ? void 0 : ae.checkpointNs) ?? null
14940
14945
  }));
14941
14946
  },
14942
14947
  [ke, c, vt]
14943
14948
  ), Ge = B.useCallback(() => {
14944
- z(null), se(""), De(null), pe(null), vt(nt.current ?? ke), nt.current = null;
14949
+ z(null), ie(""), De(null), pe(null), vt(nt.current ?? ke), nt.current = null;
14945
14950
  }, [ke, vt]), lt = Te(
14946
14951
  (q, re, ae) => {
14947
14952
  Se(q, re, ae);
@@ -15088,7 +15093,7 @@ function Ai({
15088
15093
  enableMessageEditing: c,
15089
15094
  editingMessageId: M,
15090
15095
  onStartReached: () => {
15091
- ie && R();
15096
+ oe && R();
15092
15097
  },
15093
15098
  onScrollAway: (q) => {
15094
15099
  if (!Le.current) {
@@ -15246,7 +15251,7 @@ function Ai({
15246
15251
  isStreaming: $,
15247
15252
  disabled: K,
15248
15253
  maxLength: Wo,
15249
- onSend: oe,
15254
+ onSend: se,
15250
15255
  onCancelEdit: Ge,
15251
15256
  onStop: Y,
15252
15257
  allowEmptySend: Ie.length > 0,
@@ -16475,9 +16480,9 @@ var dn = 10, [vh, Xn] = Mr(ur), pT = "SelectContentImpl", hT = Tr("SelectContent
16475
16480
  }, [b]), ba();
16476
16481
  const j = v.useCallback(
16477
16482
  (K) => {
16478
- const [M, ...z] = L().map((ne) => ne.ref.current), [te] = z.slice(-1), se = document.activeElement;
16483
+ const [M, ...z] = L().map((ne) => ne.ref.current), [te] = z.slice(-1), ie = document.activeElement;
16479
16484
  for (const ne of K)
16480
- if (ne === se || (ne == null || ne.scrollIntoView({ block: "nearest" }), ne === M && C && (C.scrollTop = 0), ne === te && C && (C.scrollTop = C.scrollHeight), ne == null || ne.focus(), document.activeElement !== se)) return;
16485
+ if (ne === ie || (ne == null || ne.scrollIntoView({ block: "nearest" }), ne === M && C && (C.scrollTop = 0), ne === te && C && (C.scrollTop = C.scrollHeight), ne == null || ne.focus(), document.activeElement !== ie)) return;
16481
16486
  },
16482
16487
  [L, C]
16483
16488
  ), Y = v.useCallback(
@@ -16492,9 +16497,9 @@ var dn = 10, [vh, Xn] = Mr(ur), pT = "SelectContentImpl", hT = Tr("SelectContent
16492
16497
  if (b) {
16493
16498
  let K = { x: 0, y: 0 };
16494
16499
  const M = (te) => {
16495
- var se, ne;
16500
+ var ie, ne;
16496
16501
  K = {
16497
- x: Math.abs(Math.round(te.pageX) - (((se = D.current) == null ? void 0 : se.x) ?? 0)),
16502
+ x: Math.abs(Math.round(te.pageX) - (((ie = D.current) == null ? void 0 : ie.x) ?? 0)),
16498
16503
  y: Math.abs(Math.round(te.pageY) - (((ne = D.current) == null ? void 0 : ne.y) ?? 0))
16499
16504
  };
16500
16505
  }, z = (te) => {
@@ -16511,7 +16516,7 @@ var dn = 10, [vh, Xn] = Mr(ur), pT = "SelectContentImpl", hT = Tr("SelectContent
16511
16516
  };
16512
16517
  }, [P]);
16513
16518
  const [G, J] = Lh((K) => {
16514
- const M = L().filter((se) => !se.disabled), z = M.find((se) => se.ref.current === document.activeElement), te = $h(M, K, z);
16519
+ const M = L().filter((ie) => !ie.disabled), z = M.find((ie) => ie.ref.current === document.activeElement), te = $h(M, K, z);
16515
16520
  te && setTimeout(() => te.ref.current.focus());
16516
16521
  }), fe = v.useCallback(
16517
16522
  (K, M, z) => {
@@ -16597,9 +16602,9 @@ var dn = 10, [vh, Xn] = Mr(ur), pT = "SelectContentImpl", hT = Tr("SelectContent
16597
16602
  onKeyDown: de(g.onKeyDown, (K) => {
16598
16603
  const M = K.ctrlKey || K.altKey || K.metaKey;
16599
16604
  if (K.key === "Tab" && K.preventDefault(), !M && K.key.length === 1 && J(K.key), ["ArrowUp", "ArrowDown", "Home", "End"].includes(K.key)) {
16600
- let te = L().filter((se) => !se.disabled).map((se) => se.ref.current);
16605
+ let te = L().filter((ie) => !ie.disabled).map((ie) => ie.ref.current);
16601
16606
  if (["ArrowUp", "End"].includes(K.key) && (te = te.slice().reverse()), ["ArrowUp", "ArrowDown"].includes(K.key)) {
16602
- const se = K.target, ne = te.indexOf(se);
16607
+ const ie = K.target, ne = te.indexOf(ie);
16603
16608
  te = te.slice(ne + 1);
16604
16609
  }
16605
16610
  setTimeout(() => j(te)), K.preventDefault();
@@ -16621,7 +16626,7 @@ var mT = "SelectItemAlignedPosition", bh = v.forwardRef((e, t) => {
16621
16626
  if (s.trigger && s.valueNode && a && c && y && x && g) {
16622
16627
  const k = s.trigger.getBoundingClientRect(), E = c.getBoundingClientRect(), N = s.valueNode.getBoundingClientRect(), I = g.getBoundingClientRect();
16623
16628
  if (s.dir !== "rtl") {
16624
- const se = I.left - E.left, ne = N.left - se, De = k.left - ne, Z = k.width + De, pe = Math.max(Z, E.width), Ie = window.innerWidth - dn, je = ta(ne, [
16629
+ const ie = I.left - E.left, ne = N.left - ie, De = k.left - ne, Z = k.width + De, pe = Math.max(Z, E.width), Ie = window.innerWidth - dn, je = ta(ne, [
16625
16630
  dn,
16626
16631
  // Prevents the content from going off the starting edge of the
16627
16632
  // viewport. It may still go off the ending edge, but this can be
@@ -16632,7 +16637,7 @@ var mT = "SelectItemAlignedPosition", bh = v.forwardRef((e, t) => {
16632
16637
  ]);
16633
16638
  a.style.minWidth = Z + "px", a.style.left = je + "px";
16634
16639
  } else {
16635
- const se = E.right - I.right, ne = window.innerWidth - N.right - se, De = window.innerWidth - k.right - ne, Z = k.width + De, pe = Math.max(Z, E.width), Ie = window.innerWidth - dn, je = ta(ne, [
16640
+ const ie = E.right - I.right, ne = window.innerWidth - N.right - ie, De = window.innerWidth - k.right - ne, Z = k.width + De, pe = Math.max(Z, E.width), Ie = window.innerWidth - dn, je = ta(ne, [
16636
16641
  dn,
16637
16642
  Math.max(dn, Ie - pe)
16638
16643
  ]);
@@ -16640,21 +16645,21 @@ var mT = "SelectItemAlignedPosition", bh = v.forwardRef((e, t) => {
16640
16645
  }
16641
16646
  const _ = p(), L = window.innerHeight - dn * 2, $ = y.scrollHeight, A = window.getComputedStyle(c), F = parseInt(A.borderTopWidth, 10), j = parseInt(A.paddingTop, 10), Y = parseInt(A.borderBottomWidth, 10), P = parseInt(A.paddingBottom, 10), D = F + j + $ + P + Y, G = Math.min(x.offsetHeight * 5, D), J = window.getComputedStyle(y), fe = parseInt(J.paddingTop, 10), Ne = parseInt(J.paddingBottom, 10), Ae = k.top + k.height / 2 - dn, H = L - Ae, ee = x.offsetHeight / 2, K = x.offsetTop + ee, M = F + j + K, z = D - M;
16642
16647
  if (M <= Ae) {
16643
- const se = _.length > 0 && x === _[_.length - 1].ref.current;
16648
+ const ie = _.length > 0 && x === _[_.length - 1].ref.current;
16644
16649
  a.style.bottom = "0px";
16645
16650
  const ne = c.clientHeight - y.offsetTop - y.offsetHeight, De = Math.max(
16646
16651
  H,
16647
16652
  ee + // viewport might have padding bottom, include it to avoid a scrollable viewport
16648
- (se ? Ne : 0) + ne + Y
16653
+ (ie ? Ne : 0) + ne + Y
16649
16654
  ), Z = M + De;
16650
16655
  a.style.height = Z + "px";
16651
16656
  } else {
16652
- const se = _.length > 0 && x === _[0].ref.current;
16657
+ const ie = _.length > 0 && x === _[0].ref.current;
16653
16658
  a.style.top = "0px";
16654
16659
  const De = Math.max(
16655
16660
  Ae,
16656
16661
  F + y.offsetTop + // viewport might have padding top, include it to avoid a scrollable viewport
16657
- (se ? fe : 0) + ee
16662
+ (ie ? fe : 0) + ee
16658
16663
  ) + z;
16659
16664
  a.style.height = De + "px", y.scrollTop = M - Ae + y.offsetTop;
16660
16665
  }