teodor-new-chat-ui 4.3.226 → 4.3.227

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
@@ -51,25 +51,25 @@ function Dm() {
51
51
  function y(R) {
52
52
  if (R === null || typeof R != "object")
53
53
  return null;
54
- var V = m && R[m] || R[x];
55
- return typeof V == "function" ? V : null;
54
+ var K = m && R[m] || R[x];
55
+ return typeof K == "function" ? K : null;
56
56
  }
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, se = new Array(V > 1 ? V - 1 : 0), be = 1; be < V; be++)
60
+ for (var K = arguments.length, se = new Array(K > 1 ? K - 1 : 0), be = 1; be < K; be++)
61
61
  se[be - 1] = arguments[be];
62
62
  b("error", R, se);
63
63
  }
64
64
  }
65
- function b(R, V, se) {
65
+ function b(R, K, se) {
66
66
  {
67
67
  var be = g.ReactDebugCurrentFrame, Ge = be.getStackAddendum();
68
- Ge !== "" && (V += "%s", se = se.concat([Ge]));
68
+ Ge !== "" && (K += "%s", se = se.concat([Ge]));
69
69
  var it = se.map(function(Be) {
70
70
  return String(Be);
71
71
  });
72
- it.unshift("Warning: " + V), Function.prototype.apply.call(console[R], console, it);
72
+ it.unshift("Warning: " + K), Function.prototype.apply.call(console[R], console, it);
73
73
  }
74
74
  }
75
75
  var T = !1, C = !1, S = !1, k = !1, N = !1, E;
@@ -81,11 +81,11 @@ function Dm() {
81
81
  // with.
82
82
  R.$$typeof === E || R.getModuleId !== void 0));
83
83
  }
84
- function P(R, V, se) {
84
+ function P(R, K, se) {
85
85
  var be = R.displayName;
86
86
  if (be)
87
87
  return be;
88
- var Ge = V.displayName || V.name || "";
88
+ var Ge = K.displayName || K.name || "";
89
89
  return Ge !== "" ? se + "(" + Ge + ")" : se;
90
90
  }
91
91
  function L(R) {
@@ -115,8 +115,8 @@ function Dm() {
115
115
  if (typeof R == "object")
116
116
  switch (R.$$typeof) {
117
117
  case a:
118
- var V = R;
119
- return L(V) + ".Consumer";
118
+ var K = R;
119
+ return L(K) + ".Consumer";
120
120
  case i:
121
121
  var se = R;
122
122
  return L(se._context) + ".Provider";
@@ -163,7 +163,7 @@ function Dm() {
163
163
  $++;
164
164
  }
165
165
  }
166
- function K() {
166
+ function W() {
167
167
  {
168
168
  if ($--, $ === 0) {
169
169
  var R = {
@@ -199,7 +199,7 @@ function Dm() {
199
199
  }
200
200
  }
201
201
  var ee = g.ReactCurrentDispatcher, q;
202
- function M(R, V, se) {
202
+ function M(R, K, se) {
203
203
  {
204
204
  if (q === void 0)
205
205
  try {
@@ -217,7 +217,7 @@ function Dm() {
217
217
  var oe = typeof WeakMap == "function" ? WeakMap : Map;
218
218
  te = new oe();
219
219
  }
220
- function ne(R, V) {
220
+ function ne(R, K) {
221
221
  if (!R || H)
222
222
  return "";
223
223
  {
@@ -232,7 +232,7 @@ function Dm() {
232
232
  var it;
233
233
  it = ee.current, ee.current = null, Ae();
234
234
  try {
235
- if (V) {
235
+ if (K) {
236
236
  var Be = function() {
237
237
  throw Error();
238
238
  };
@@ -283,19 +283,19 @@ function Dm() {
283
283
  }
284
284
  }
285
285
  } finally {
286
- H = !1, ee.current = it, K(), Error.prepareStackTrace = Ge;
286
+ H = !1, ee.current = it, W(), Error.prepareStackTrace = Ge;
287
287
  }
288
288
  var Fn = R ? R.displayName || R.name : "", Nn = Fn ? M(Fn) : "";
289
289
  return typeof R == "function" && te.set(R, Nn), Nn;
290
290
  }
291
- function Te(R, V, se) {
291
+ function Te(R, K, se) {
292
292
  return ne(R, !1);
293
293
  }
294
294
  function Z(R) {
295
- var V = R.prototype;
296
- return !!(V && V.isReactComponent);
295
+ var K = R.prototype;
296
+ return !!(K && K.isReactComponent);
297
297
  }
298
- function de(R, V, se) {
298
+ function de(R, K, 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 Te(R.render);
315
315
  case f:
316
- return de(R.type, V, se);
316
+ return de(R.type, K, se);
317
317
  case p: {
318
318
  var be = R, Ge = be._payload, it = be._init;
319
319
  try {
320
- return de(it(Ge), V, se);
320
+ return de(it(Ge), K, se);
321
321
  } catch {
322
322
  }
323
323
  }
@@ -327,12 +327,12 @@ function Dm() {
327
327
  var Ee = Object.prototype.hasOwnProperty, Ne = {}, Le = g.ReactDebugCurrentFrame;
328
328
  function Je(R) {
329
329
  if (R) {
330
- var V = R._owner, se = de(R.type, R._source, V ? V.type : null);
330
+ var K = R._owner, se = de(R.type, R._source, K ? K.type : null);
331
331
  Le.setExtraStackFrame(se);
332
332
  } else
333
333
  Le.setExtraStackFrame(null);
334
334
  }
335
- function He(R, V, se, be, Ge) {
335
+ function He(R, K, se, be, Ge) {
336
336
  {
337
337
  var it = Function.call.bind(Ee);
338
338
  for (var Be in R)
@@ -343,7 +343,7 @@ function Dm() {
343
343
  var Ot = Error((be || "React class") + ": " + se + " type `" + Be + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof R[Be] + "`.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
- $e = R[Be](V, Be, be, se, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
346
+ $e = R[Be](K, Be, be, se, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
347
347
  } catch (bt) {
348
348
  $e = bt;
349
349
  }
@@ -357,7 +357,7 @@ function Dm() {
357
357
  }
358
358
  function Xe(R) {
359
359
  {
360
- var V = typeof Symbol == "function" && Symbol.toStringTag, se = V && R[Symbol.toStringTag] || R.constructor.name || "Object";
360
+ var K = typeof Symbol == "function" && Symbol.toStringTag, se = K && R[Symbol.toStringTag] || R.constructor.name || "Object";
361
361
  return se;
362
362
  }
363
363
  }
@@ -383,27 +383,27 @@ function Dm() {
383
383
  }, ce, fe;
384
384
  function he(R) {
385
385
  if (Ee.call(R, "ref")) {
386
- var V = Object.getOwnPropertyDescriptor(R, "ref").get;
387
- if (V && V.isReactWarning)
386
+ var K = Object.getOwnPropertyDescriptor(R, "ref").get;
387
+ if (K && K.isReactWarning)
388
388
  return !1;
389
389
  }
390
390
  return R.ref !== void 0;
391
391
  }
392
392
  function qe(R) {
393
393
  if (Ee.call(R, "key")) {
394
- var V = Object.getOwnPropertyDescriptor(R, "key").get;
395
- if (V && V.isReactWarning)
394
+ var K = Object.getOwnPropertyDescriptor(R, "key").get;
395
+ if (K && K.isReactWarning)
396
396
  return !1;
397
397
  }
398
398
  return R.key !== void 0;
399
399
  }
400
- function Fe(R, V) {
400
+ function Fe(R, K) {
401
401
  typeof R.ref == "string" && ht.current;
402
402
  }
403
- function yt(R, V) {
403
+ function yt(R, K) {
404
404
  {
405
405
  var se = function() {
406
- ce || (ce = !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));
406
+ ce || (ce = !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)", K));
407
407
  };
408
408
  se.isReactWarning = !0, Object.defineProperty(R, "key", {
409
409
  get: se,
@@ -411,10 +411,10 @@ function Dm() {
411
411
  });
412
412
  }
413
413
  }
414
- function At(R, V) {
414
+ function At(R, K) {
415
415
  {
416
416
  var se = function() {
417
- fe || (fe = !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));
417
+ fe || (fe = !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)", K));
418
418
  };
419
419
  se.isReactWarning = !0, Object.defineProperty(R, "ref", {
420
420
  get: se,
@@ -422,13 +422,13 @@ function Dm() {
422
422
  });
423
423
  }
424
424
  }
425
- var st = function(R, V, se, be, Ge, it, Be) {
425
+ var st = function(R, K, se, be, Ge, it, Be) {
426
426
  var $e = {
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
- key: V,
431
+ key: K,
432
432
  ref: se,
433
433
  props: Be,
434
434
  // Record the component responsible for creating this element.
@@ -451,12 +451,12 @@ function Dm() {
451
451
  value: Ge
452
452
  }), Object.freeze && (Object.freeze($e.props), Object.freeze($e)), $e;
453
453
  };
454
- function ze(R, V, se, be, Ge) {
454
+ function ze(R, K, se, be, Ge) {
455
455
  {
456
456
  var it, Be = {}, $e = null, Ot = null;
457
- se !== void 0 && (Nt(se), $e = "" + se), qe(V) && (Nt(V.key), $e = "" + V.key), he(V) && (Ot = V.ref, Fe(V, Ge));
458
- for (it in V)
459
- Ee.call(V, it) && !lt.hasOwnProperty(it) && (Be[it] = V[it]);
457
+ se !== void 0 && (Nt(se), $e = "" + se), qe(K) && (Nt(K.key), $e = "" + K.key), he(K) && (Ot = K.ref, Fe(K, Ge));
458
+ for (it in K)
459
+ Ee.call(K, it) && !lt.hasOwnProperty(it) && (Be[it] = K[it]);
460
460
  if (R && R.defaultProps) {
461
461
  var bt = R.defaultProps;
462
462
  for (it in bt)
@@ -470,9 +470,9 @@ function Dm() {
470
470
  }
471
471
  }
472
472
  var Pt = g.ReactCurrentOwner, jt = g.ReactDebugCurrentFrame;
473
- function W(R) {
473
+ function V(R) {
474
474
  if (R) {
475
- var V = R._owner, se = de(R.type, R._source, V ? V.type : null);
475
+ var K = R._owner, se = de(R.type, R._source, K ? K.type : null);
476
476
  jt.setExtraStackFrame(se);
477
477
  } else
478
478
  jt.setExtraStackFrame(null);
@@ -500,37 +500,37 @@ Check the render method of \`` + R + "`.";
500
500
  var St = {};
501
501
  function Pe(R) {
502
502
  {
503
- var V = pt();
504
- if (!V) {
503
+ var K = pt();
504
+ if (!K) {
505
505
  var se = typeof R == "string" ? R : R.displayName || R.name;
506
- se && (V = `
506
+ se && (K = `
507
507
 
508
508
  Check the top-level render call using <` + se + ">.");
509
509
  }
510
- return V;
510
+ return K;
511
511
  }
512
512
  }
513
- function Vt(R, V) {
513
+ function Vt(R, K) {
514
514
  {
515
515
  if (!R._store || R._store.validated || R.key != null)
516
516
  return;
517
517
  R._store.validated = !0;
518
- var se = Pe(V);
518
+ var se = Pe(K);
519
519
  if (St[se])
520
520
  return;
521
521
  St[se] = !0;
522
522
  var be = "";
523
- R && R._owner && R._owner !== Pt.current && (be = " It was passed a child from " + F(R._owner.type) + "."), W(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, be), W(null);
523
+ R && R._owner && R._owner !== Pt.current && (be = " It was passed a child from " + F(R._owner.type) + "."), V(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, be), V(null);
524
524
  }
525
525
  }
526
- function ct(R, V) {
526
+ function ct(R, K) {
527
527
  {
528
528
  if (typeof R != "object")
529
529
  return;
530
530
  if (Ke(R))
531
531
  for (var se = 0; se < R.length; se++) {
532
532
  var be = R[se];
533
- ye(be) && Vt(be, V);
533
+ ye(be) && Vt(be, K);
534
534
  }
535
535
  else if (ye(R))
536
536
  R._store && (R._store.validated = !0);
@@ -538,49 +538,49 @@ Check the top-level render call using <` + se + ">.");
538
538
  var Ge = y(R);
539
539
  if (typeof Ge == "function" && Ge !== R.entries)
540
540
  for (var it = Ge.call(R), Be; !(Be = it.next()).done; )
541
- ye(Be.value) && Vt(Be.value, V);
541
+ ye(Be.value) && Vt(Be.value, K);
542
542
  }
543
543
  }
544
544
  }
545
545
  function Ct(R) {
546
546
  {
547
- var V = R.type;
548
- if (V == null || typeof V == "string")
547
+ var K = R.type;
548
+ if (K == null || typeof K == "string")
549
549
  return;
550
550
  var se;
551
- if (typeof V == "function")
552
- se = V.propTypes;
553
- else if (typeof V == "object" && (V.$$typeof === l || // Note: Memo only checks outer props here.
551
+ if (typeof K == "function")
552
+ se = K.propTypes;
553
+ else if (typeof K == "object" && (K.$$typeof === l || // Note: Memo only checks outer props here.
554
554
  // Inner props are checked in the reconciler.
555
- V.$$typeof === f))
556
- se = V.propTypes;
555
+ K.$$typeof === f))
556
+ se = K.propTypes;
557
557
  else
558
558
  return;
559
559
  if (se) {
560
- var be = F(V);
560
+ var be = F(K);
561
561
  He(se, R.props, "prop", be, R);
562
- } else if (V.PropTypes !== void 0 && !we) {
562
+ } else if (K.PropTypes !== void 0 && !we) {
563
563
  we = !0;
564
- var Ge = F(V);
564
+ var Ge = F(K);
565
565
  w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", Ge || "Unknown");
566
566
  }
567
- typeof V.getDefaultProps == "function" && !V.getDefaultProps.isReactClassApproved && w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
567
+ typeof K.getDefaultProps == "function" && !K.getDefaultProps.isReactClassApproved && w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
568
568
  }
569
569
  }
570
570
  function Dn(R) {
571
571
  {
572
- for (var V = Object.keys(R.props), se = 0; se < V.length; se++) {
573
- var be = V[se];
572
+ for (var K = Object.keys(R.props), se = 0; se < K.length; se++) {
573
+ var be = K[se];
574
574
  if (be !== "children" && be !== "key") {
575
- W(R), w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", be), W(null);
575
+ V(R), w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", be), V(null);
576
576
  break;
577
577
  }
578
578
  }
579
- R.ref !== null && (W(R), w("Invalid attribute `ref` supplied to `React.Fragment`."), W(null));
579
+ R.ref !== null && (V(R), w("Invalid attribute `ref` supplied to `React.Fragment`."), V(null));
580
580
  }
581
581
  }
582
582
  var Jn = {};
583
- function Ln(R, V, se, be, Ge, it) {
583
+ function Ln(R, K, se, be, Ge, it) {
584
584
  {
585
585
  var Be = I(R);
586
586
  if (!Be) {
@@ -591,11 +591,11 @@ Check the top-level render call using <` + se + ">.");
591
591
  var bt;
592
592
  R === null ? bt = "null" : Ke(R) ? bt = "array" : R !== void 0 && R.$$typeof === t ? (bt = "<" + (F(R.type) || "Unknown") + " />", $e = " Did you accidentally export a JSX literal instead of a component?") : bt = 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", bt, $e);
593
593
  }
594
- var vt = ze(R, V, se, Ge, it);
594
+ var vt = ze(R, K, se, Ge, it);
595
595
  if (vt == null)
596
596
  return vt;
597
597
  if (Be) {
598
- var Kt = V.children;
598
+ var Kt = K.children;
599
599
  if (Kt !== void 0)
600
600
  if (be)
601
601
  if (Ke(Kt)) {
@@ -607,8 +607,8 @@ Check the top-level render call using <` + se + ">.");
607
607
  else
608
608
  ct(Kt, R);
609
609
  }
610
- if (Ee.call(V, "key")) {
611
- var Nn = F(R), Ft = Object.keys(V).filter(function(re) {
610
+ if (Ee.call(K, "key")) {
611
+ var Nn = F(R), Ft = Object.keys(K).filter(function(re) {
612
612
  return re !== "key";
613
613
  }), Dr = Ft.length > 0 ? "{key: someKey, " + Ft.join(": ..., ") + ": ...}" : "{key: someKey}";
614
614
  if (!Jn[Nn + Dr]) {
@@ -624,11 +624,11 @@ React keys must be passed directly to JSX without using spread:
624
624
  return R === r ? Dn(vt) : Ct(vt), vt;
625
625
  }
626
626
  }
627
- function ti(R, V, se) {
628
- return Ln(R, V, se, !0);
627
+ function ti(R, K, se) {
628
+ return Ln(R, K, se, !0);
629
629
  }
630
- function So(R, V, se) {
631
- return Ln(R, V, se, !1);
630
+ function So(R, K, se) {
631
+ return Ln(R, K, se, !1);
632
632
  }
633
633
  var ni = So, ri = ti;
634
634
  Fr.Fragment = r, Fr.jsx = ni, Fr.jsxs = ri;
@@ -1904,8 +1904,8 @@ const xu = (e) => {
1904
1904
  const O = d && (k === "stream" || k === "response");
1905
1905
  if (d && (C || O && j)) {
1906
1906
  const X = {};
1907
- ["status", "statusText", "headers"].forEach((K) => {
1908
- X[K] = D[K];
1907
+ ["status", "statusText", "headers"].forEach((W) => {
1908
+ X[W] = D[W];
1909
1909
  });
1910
1910
  const pe = _.toFiniteNumber(D.headers.get("content-length")), [Ie, Ae] = C && wl(
1911
1911
  pe,
@@ -3415,7 +3415,7 @@ function Kx(e = {}) {
3415
3415
  threadId: j.threadId ?? null,
3416
3416
  headers: {}
3417
3417
  }, (async () => {
3418
- var pe, Ie, Ae, K, ee, q, M, H, te, oe, ne, Te, Z, de, Ee, Ne, Le, Je;
3418
+ var pe, Ie, Ae, W, ee, q, M, H, te, oe, ne, Te, Z, de, Ee, Ne, Le, Je;
3419
3419
  const X = (He) => {
3420
3420
  var Ve;
3421
3421
  try {
@@ -3441,8 +3441,8 @@ function Kx(e = {}) {
3441
3441
  we && (jt = ((Ae = JSON.parse(we)) == null ? void 0 : Ae.apiKey) || null);
3442
3442
  } catch {
3443
3443
  }
3444
- const W = ze || Pt || jt || null;
3445
- W && (He = { Authorization: `Bearer ${W}` });
3444
+ const V = ze || Pt || jt || null;
3445
+ V && (He = { Authorization: `Bearer ${V}` });
3446
3446
  }
3447
3447
  } catch {
3448
3448
  }
@@ -3454,7 +3454,7 @@ function Kx(e = {}) {
3454
3454
  let Ve = {};
3455
3455
  if (typeof window < "u")
3456
3456
  try {
3457
- const st = (K = window.localStorage) == null ? void 0 : K.getItem("authSessionId");
3457
+ const st = (W = window.localStorage) == null ? void 0 : W.getItem("authSessionId");
3458
3458
  st && (Ve = { "X-Session-Id": st });
3459
3459
  } catch {
3460
3460
  }
@@ -3511,9 +3511,9 @@ function Kx(e = {}) {
3511
3511
  ...S.current,
3512
3512
  threadId: Pt
3513
3513
  }), (q = A == null ? void 0 : A.onOpen) == null || q.call(A, { threadId: Pt, created: jt }); ; ) {
3514
- const { value: W, done: we } = await tt.read();
3514
+ const { value: V, done: we } = await tt.read();
3515
3515
  if (we) break;
3516
- ht += Nt.decode(W, { stream: !0 }), ht.length > At && (ht = "", console.warn("Stream buffer reset: exceeded 1MB"));
3516
+ ht += Nt.decode(V, { stream: !0 }), ht.length > At && (ht = "", console.warn("Stream buffer reset: exceeded 1MB"));
3517
3517
  let ye;
3518
3518
  for (; (ye = ht.indexOf(`
3519
3519
 
@@ -3875,14 +3875,18 @@ function Xx({
3875
3875
  onThreadChange: a,
3876
3876
  checkpointMetadataCache: l
3877
3877
  }) {
3878
- const { api: c, baseUrl: d } = Tu(), f = at(() => _n(d), [d]), [p, h] = xe([]), [m, x] = xe(t), [y, g] = xe(!1), [w, b] = xe(null), [T, C] = xe(!1), [S, k] = xe(null), { state: N, seed: E, prepend: I, pushUser: P, onEvent: L } = Bx(), [F, j] = xe(!1), [$, A] = xe(!1), [B, D] = xe(null), [O, J] = xe([]), [X, pe] = xe(!1), Ie = l ?? Lx(), { setCacheForThread: Ae } = Ie, K = Qe(m), ee = Qe(null);
3878
+ const { api: c, baseUrl: d } = Tu(), f = at(() => _n(d), [d]), [p, h] = xe([]), [m, x] = xe(t), [y, g] = xe(!1), [w, b] = xe(null), [T, C] = xe(!1), [S, k] = xe(null), { state: N, seed: E, prepend: I, pushUser: P, onEvent: L } = Bx(), [F, j] = xe(!1), [$, A] = xe(!1), [B, D] = xe(null), [O, J] = xe([]), [X, pe] = xe(!1), Ie = l ?? Lx(), { setCacheForThread: Ae } = Ie, W = Qe(m), ee = Qe(null);
3879
3879
  kt(() => {
3880
- K.current = m;
3880
+ W.current = m;
3881
3881
  }, [m]);
3882
3882
  const q = Qe(), { startStream: M, stop: H, isStreaming: te, error: oe, setAuthToken: ne } = Yx({
3883
3883
  baseUrl: f,
3884
3884
  onThreadInfo: (ce) => {
3885
- console.log("[ChatSessionProvider] Thread info:", ce.threadId), K.current !== ce.threadId && x(ce.threadId);
3885
+ if (console.log("[ChatSessionProvider] Thread info:", ce.threadId), W.current === null) {
3886
+ console.log("[ChatSessionProvider] Ignoring thread info: no active thread (new chat mode)");
3887
+ return;
3888
+ }
3889
+ W.current !== ce.threadId && x(ce.threadId);
3886
3890
  },
3887
3891
  onMessageEvent: L,
3888
3892
  onUnhandledEvent: (ce) => {
@@ -3913,7 +3917,7 @@ function Xx({
3913
3917
  ), de = ke(
3914
3918
  async (ce) => {
3915
3919
  try {
3916
- await c.deleteThread(ce), K.current === ce && (x(null), E([], {})), await Te();
3920
+ await c.deleteThread(ce), W.current === ce && (x(null), E([], {})), await Te();
3917
3921
  } catch (fe) {
3918
3922
  s == null || s(String(fe));
3919
3923
  }
@@ -3969,7 +3973,7 @@ function Xx({
3969
3973
  }, [Le]);
3970
3974
  const Je = ke(
3971
3975
  async (ce, fe) => {
3972
- const he = K.current;
3976
+ const he = W.current;
3973
3977
  if (he) {
3974
3978
  pe(!0);
3975
3979
  try {
@@ -4007,13 +4011,13 @@ function Xx({
4007
4011
  },
4008
4012
  [E, N.messages]
4009
4013
  ), Ve = ke(async () => {
4010
- K.current && await Le(K.current);
4014
+ W.current && await Le(W.current);
4011
4015
  }, [Le]), Ke = ke(async () => {
4012
- if (!(!K.current || !B)) {
4016
+ if (!(!W.current || !B)) {
4013
4017
  A(!0);
4014
4018
  try {
4015
4019
  const ce = await c.getStateHistory({
4016
- threadId: K.current,
4020
+ threadId: W.current,
4017
4021
  checkpointId: B
4018
4022
  }), { checkpoints: fe } = Ur(ce);
4019
4023
  if (fe.length > 0) {
@@ -4027,8 +4031,8 @@ function Xx({
4027
4031
  }
4028
4032
  }
4029
4033
  }, [c, B, I, s]), Xe = ke(async () => {
4030
- E([], {}), J([]), j(!1), D(null), x(null);
4031
- }, [E]), Ze = ke(
4034
+ H(), W.current = null, ee.current = null, E([], {}), J([]), j(!1), D(null), x(null);
4035
+ }, [E, H]), Ze = ke(
4032
4036
  async (ce, fe) => {
4033
4037
  console.log("[ChatSessionProvider] Interrupt:", ce, fe);
4034
4038
  },
@@ -4044,7 +4048,7 @@ function Xx({
4044
4048
  }, [m, a]);
4045
4049
  const tt = ke(
4046
4050
  async (ce, fe) => {
4047
- const he = K.current, qe = (ce == null ? void 0 : ce.text) ?? "";
4051
+ const he = W.current, qe = (ce == null ? void 0 : ce.text) ?? "";
4048
4052
  if (!he && !qe) return;
4049
4053
  if (!he) {
4050
4054
  await Z("New Chat");
@@ -6273,7 +6277,7 @@ var Na = "PopperContent", [Fv, $v] = Ju(Na), nd = v.forwardRef(
6273
6277
  Lt(() => {
6274
6278
  B && (X == null || X());
6275
6279
  }, [B, X]);
6276
- const pe = (q = D.arrow) == null ? void 0 : q.x, Ie = (M = D.arrow) == null ? void 0 : M.y, Ae = ((H = D.arrow) == null ? void 0 : H.centerOffset) !== 0, [K, ee] = v.useState();
6280
+ const pe = (q = D.arrow) == null ? void 0 : q.x, Ie = (M = D.arrow) == null ? void 0 : M.y, Ae = ((H = D.arrow) == null ? void 0 : H.centerOffset) !== 0, [W, ee] = v.useState();
6277
6281
  return Lt(() => {
6278
6282
  g && ee(window.getComputedStyle(g).zIndex);
6279
6283
  }, [g]), /* @__PURE__ */ u.jsx(
@@ -6286,7 +6290,7 @@ var Na = "PopperContent", [Fv, $v] = Ju(Na), nd = v.forwardRef(
6286
6290
  transform: B ? $.transform : "translate(0, -200%)",
6287
6291
  // keep off the page when measuring
6288
6292
  minWidth: "max-content",
6289
- zIndex: K,
6293
+ zIndex: W,
6290
6294
  "--radix-popper-transform-origin": [
6291
6295
  (te = D.transformOrigin) == null ? void 0 : te.x,
6292
6296
  (oe = D.transformOrigin) == null ? void 0 : oe.y
@@ -7272,7 +7276,7 @@ var an = "MenuContent", [eb, Pa] = dr(an), Ad = v.forwardRef(
7272
7276
  ...x
7273
7277
  } = e, y = fr(an, n), g = yo(an, n), w = Ls(n), b = Rd(n), T = Gw(n), [C, S] = v.useState(null), k = v.useRef(null), N = We(t, k, y.onContentChange), E = v.useRef(0), I = v.useRef(""), P = v.useRef(0), L = v.useRef(null), F = v.useRef("right"), j = v.useRef(0), $ = m ? Ds : v.Fragment, A = m ? { as: rb, allowPinchZoom: !0 } : void 0, B = (O) => {
7274
7278
  var q, M;
7275
- const J = I.current + O, X = T().filter((H) => !H.disabled), pe = document.activeElement, Ie = (q = X.find((H) => H.ref.current === pe)) == null ? void 0 : q.textValue, Ae = X.map((H) => H.textValue), K = mb(Ae, J, Ie), ee = (M = X.find((H) => H.textValue === K)) == null ? void 0 : M.ref.current;
7279
+ const J = I.current + O, X = T().filter((H) => !H.disabled), pe = document.activeElement, Ie = (q = X.find((H) => H.ref.current === pe)) == null ? void 0 : q.textValue, Ae = X.map((H) => H.textValue), W = mb(Ae, J, Ie), ee = (M = X.find((H) => H.textValue === W)) == null ? void 0 : M.ref.current;
7276
7280
  (function H(te) {
7277
7281
  I.current = te, window.clearTimeout(E.current), te !== "" && (E.current = window.setTimeout(() => H(""), 1e3));
7278
7282
  })(J), ee && setTimeout(() => ee.focus());
@@ -9549,10 +9553,10 @@ const hr = et(
9549
9553
  );
9550
9554
  const J = [];
9551
9555
  if (L.length > 0) {
9552
- const K = L[0], ee = L[L.length - 1];
9556
+ const W = L[0], ee = L[L.length - 1];
9553
9557
  let q = 0;
9554
- for (const M of Hs(D, K, ee)) {
9555
- const H = M.value, te = Math.max(M.start, K), oe = Math.min(M.end, ee);
9558
+ for (const M of Hs(D, W, ee)) {
9559
+ const H = M.value, te = Math.max(M.start, W), oe = Math.min(M.end, ee);
9556
9560
  for (let ne = te; ne <= oe; ne++)
9557
9561
  J.push({ data: $ == null ? void 0 : $[ne], index: ne, offset: q, size: H }), q += H;
9558
9562
  }
@@ -9562,7 +9566,7 @@ const hr = et(
9562
9566
  const X = L.length > 0 ? L[L.length - 1] + 1 : 0, pe = I0(B, S, k, X);
9563
9567
  if (pe.length === 0)
9564
9568
  return null;
9565
- const Ie = N - 1, Ae = Bs([], (K) => {
9569
+ const Ie = N - 1, Ae = Bs([], (W) => {
9566
9570
  for (const ee of pe) {
9567
9571
  const q = ee.value;
9568
9572
  let M = q.offset, H = ee.start;
@@ -9575,7 +9579,7 @@ const hr = et(
9575
9579
  H < X && (M += (X - H) * te, H = X);
9576
9580
  const oe = Math.min(ee.end, Ie);
9577
9581
  for (let ne = H; ne <= oe && !(M >= k); ne++)
9578
- K.push({ data: $ == null ? void 0 : $[ne], index: ne, offset: M, size: te }), M += te + j;
9582
+ W.push({ data: $ == null ? void 0 : $[ne], index: ne, offset: M, size: te }), M += te + j;
9579
9583
  }
9580
9584
  });
9581
9585
  return Ko(Ae, J, N, j, A, F);
@@ -10886,7 +10890,7 @@ const TS = /* @__PURE__ */ et(
10886
10890
  ae(([[, M]]) => M - 1),
10887
10891
  gt()
10888
10892
  )
10889
- ), K = en(
10893
+ ), W = en(
10890
10894
  U(
10891
10895
  Ce(N),
10892
10896
  Re(({ items: M }) => M.length > 0 && M[0].index === 0),
@@ -10969,7 +10973,7 @@ const TS = /* @__PURE__ */ et(
10969
10973
  endReached: Ae,
10970
10974
  propsReady: x,
10971
10975
  rangeChanged: ee,
10972
- startReached: K,
10976
+ startReached: W,
10973
10977
  stateChanged: A,
10974
10978
  stateRestoreInProgress: D,
10975
10979
  ...C
@@ -13588,7 +13592,7 @@ const Bc = z.memo(function({
13588
13592
  }) {
13589
13593
  const [I, P] = xe(!1), [L, F] = xe("preview"), [j, $] = xe(!1), { currentThreadId: A } = xa(), { respondToInterrupt: B } = ya(), D = l === "phone" || l === "half-screen", O = t.role, J = O === "tool", X = at(() => "type" in t && t.type === "default_message" ? t : null, [t]), pe = !!X, Ie = !(r && O !== "user"), {
13590
13594
  uploadingFiles: Ae,
13591
- handleFileClick: K,
13595
+ handleFileClick: W,
13592
13596
  fileViewerOpen: ee,
13593
13597
  currentFileInfo: q,
13594
13598
  closeFileViewer: M
@@ -13606,16 +13610,16 @@ const Bc = z.memo(function({
13606
13610
  return "text-[hsl(var(--chat-bubble-ai-text))]";
13607
13611
  }
13608
13612
  }, [O]), te = at(() => X ? "" : CC(t.content), [X, t]), oe = at(() => X ? {} : Pp(t), [X, t]), ne = at(
13609
- () => X ? [] : t.content.filter((W) => W.type === "image_url"),
13613
+ () => X ? [] : t.content.filter((V) => V.type === "image_url"),
13610
13614
  [X, t]
13611
13615
  ), Te = at(
13612
- () => X ? [] : t.content.filter((W) => W.type === "file"),
13616
+ () => X ? [] : t.content.filter((V) => V.type === "file"),
13613
13617
  [X, t]
13614
13618
  ), Z = at(
13615
- () => X ? [] : t.content.filter((W) => W.type === "interrupt"),
13619
+ () => X ? [] : t.content.filter((V) => V.type === "interrupt"),
13616
13620
  [X, t]
13617
13621
  ), de = (g == null ? void 0 : g.id) ?? (g == null ? void 0 : g.interrupt_id), Ee = Mo(de), Ne = g == null ? void 0 : g.value, Le = at(() => X ? "" : TC(t.content), [X, t]), Je = z.useCallback(async () => {
13618
- const W = J ? Le : te;
13622
+ const V = J ? Le : te;
13619
13623
  async function we(ye) {
13620
13624
  if (navigator.clipboard && typeof navigator.clipboard.writeText == "function") {
13621
13625
  await navigator.clipboard.writeText(ye);
@@ -13633,17 +13637,17 @@ const Bc = z.memo(function({
13633
13637
  throw new Error("Clipboard API not supported in this context.");
13634
13638
  }
13635
13639
  try {
13636
- await we(W), P(!0), setTimeout(() => P(!1), 2e3), y == null || y(W);
13640
+ await we(V), P(!0), setTimeout(() => P(!1), 2e3), y == null || y(V);
13637
13641
  } catch (ye) {
13638
13642
  console.error("Failed to copy:", ye);
13639
13643
  }
13640
13644
  }, [J, Le, te, y]), He = z.useCallback(() => {
13641
13645
  if (!h) return;
13642
- const W = J ? Le : te, we = "type" in t && t.type === "default_message" ? void 0 : {
13646
+ const V = J ? Le : te, we = "type" in t && t.type === "default_message" ? void 0 : {
13643
13647
  checkpointId: t.checkpointId ?? null,
13644
13648
  checkpointNs: t.checkpointNs ?? null
13645
13649
  };
13646
- h(t.id, W, we);
13650
+ h(t.id, V, we);
13647
13651
  }, [h, t.id, J, Le, te, t]), Ve = z.useCallback(() => {
13648
13652
  m == null || m(n);
13649
13653
  }, [m, n]), Ke = z.useCallback(() => {
@@ -13659,25 +13663,25 @@ const Bc = z.memo(function({
13659
13663
  return /* @__PURE__ */ u.jsx(si, { className: we });
13660
13664
  }
13661
13665
  }, [D, H, O]), Xe = z.useCallback(() => {
13662
- const W = "group relative mb-4 flex w-full";
13666
+ const V = "group relative mb-4 flex w-full";
13663
13667
  switch (O) {
13664
13668
  case "user":
13665
- return Q(W, "justify-end");
13669
+ return Q(V, "justify-end");
13666
13670
  case "assistant":
13667
13671
  case "tool":
13668
13672
  case "system":
13669
- return Q(W, "justify-start");
13673
+ return Q(V, "justify-start");
13670
13674
  default:
13671
- return W;
13675
+ return V;
13672
13676
  }
13673
13677
  }, [O]), Ze = z.useCallback(() => {
13674
- const W = Q(
13678
+ const V = Q(
13675
13679
  "rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",
13676
13680
  D && "px-3 py-2 text-sm"
13677
13681
  );
13678
13682
  if (pe)
13679
13683
  return Q(
13680
- W,
13684
+ V,
13681
13685
  "w-full",
13682
13686
  "bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]",
13683
13687
  "border border-border/60 dark:border-border/40 shadow-sm"
@@ -13685,25 +13689,25 @@ const Bc = z.memo(function({
13685
13689
  switch (O) {
13686
13690
  case "user":
13687
13691
  return Q(
13688
- W,
13692
+ V,
13689
13693
  "w-full md:max-w-[95%]",
13690
13694
  "bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]",
13691
13695
  "border border-transparent"
13692
13696
  );
13693
13697
  case "assistant":
13694
13698
  return Q(
13695
- W,
13699
+ V,
13696
13700
  "w-full md:max-w-[95%]",
13697
13701
  "bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]",
13698
13702
  "border border-border/60 dark:border-border/40"
13699
13703
  );
13700
13704
  case "tool":
13701
- return Q(W, "w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");
13705
+ return Q(V, "w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");
13702
13706
  case "system":
13703
- return Q(W, "w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");
13707
+ return Q(V, "w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");
13704
13708
  default:
13705
13709
  return Q(
13706
- W,
13710
+ V,
13707
13711
  "w-full md:max-w-[95%]",
13708
13712
  "bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]",
13709
13713
  "border border-border/60 dark:border-border/40"
@@ -13724,14 +13728,14 @@ const Bc = z.memo(function({
13724
13728
  }
13725
13729
  )
13726
13730
  ] }) });
13727
- const tt = z.useCallback(async (W) => {
13731
+ const tt = z.useCallback(async (V) => {
13728
13732
  if (w)
13729
13733
  return;
13730
13734
  const we = Mo(
13731
- (W == null ? void 0 : W.id) ?? (W == null ? void 0 : W.interrupt_id)
13735
+ (V == null ? void 0 : V.id) ?? (V == null ? void 0 : V.interrupt_id)
13732
13736
  );
13733
13737
  if (!we) {
13734
- console.warn("Interrupt part missing id", W);
13738
+ console.warn("Interrupt part missing id", V);
13735
13739
  return;
13736
13740
  }
13737
13741
  try {
@@ -13741,14 +13745,14 @@ const Bc = z.memo(function({
13741
13745
  } finally {
13742
13746
  T == null || T();
13743
13747
  }
13744
- }, [w, T, b, B]), Nt = z.useCallback(async (W) => {
13748
+ }, [w, T, b, B]), Nt = z.useCallback(async (V) => {
13745
13749
  if (w)
13746
13750
  return;
13747
13751
  const we = Mo(
13748
- (W == null ? void 0 : W.id) ?? (W == null ? void 0 : W.interrupt_id)
13752
+ (V == null ? void 0 : V.id) ?? (V == null ? void 0 : V.interrupt_id)
13749
13753
  );
13750
13754
  if (!we) {
13751
- console.warn("Interrupt part missing id", W);
13755
+ console.warn("Interrupt part missing id", V);
13752
13756
  return;
13753
13757
  }
13754
13758
  try {
@@ -13758,9 +13762,9 @@ const Bc = z.memo(function({
13758
13762
  } finally {
13759
13763
  T == null || T();
13760
13764
  }
13761
- }, [w, T, b, B]), ht = z.useCallback(({ part: W, i: we }) => {
13762
- if (W.type === "text") {
13763
- const ye = W.text ?? "", pt = ye.trim(), mt = Ja(pt);
13765
+ }, [w, T, b, B]), ht = z.useCallback(({ part: V, i: we }) => {
13766
+ if (V.type === "text") {
13767
+ const ye = V.text ?? "", pt = ye.trim(), mt = Ja(pt);
13764
13768
  return mt && O !== "tool" ? /* @__PURE__ */ u.jsx(Op, { data: mt }, we) : O === "user" && c && pt.length > d ? /* @__PURE__ */ u.jsx(
13765
13769
  NC,
13766
13770
  {
@@ -13773,8 +13777,8 @@ const Bc = z.memo(function({
13773
13777
  we
13774
13778
  ) : /* @__PURE__ */ u.jsx(fs, { content: ye, allowHtml: !1 }, we);
13775
13779
  }
13776
- if (W.type === "image_url") {
13777
- const ye = W;
13780
+ if (V.type === "image_url") {
13781
+ const ye = V;
13778
13782
  return /* @__PURE__ */ u.jsx("div", { className: "my-2", children: /* @__PURE__ */ u.jsx(
13779
13783
  "img",
13780
13784
  {
@@ -13785,13 +13789,13 @@ const Bc = z.memo(function({
13785
13789
  }
13786
13790
  ) }, we);
13787
13791
  }
13788
- if (W.type === "file") {
13789
- const ye = W, pt = ye.name || "file";
13792
+ if (V.type === "file") {
13793
+ const ye = V, pt = ye.name || "file";
13790
13794
  return /* @__PURE__ */ u.jsxs(
13791
13795
  "a",
13792
13796
  {
13793
13797
  href: ye.url,
13794
- onClick: (mt) => K(mt, ye, we),
13798
+ onClick: (mt) => W(mt, ye, we),
13795
13799
  className: `inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
13796
13800
  dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,
13797
13801
  children: [
@@ -13805,8 +13809,8 @@ const Bc = z.memo(function({
13805
13809
  we
13806
13810
  );
13807
13811
  }
13808
- if (W.type === "interrupt") {
13809
- const ye = W, pt = Mo(
13812
+ if (V.type === "interrupt") {
13813
+ const ye = V, pt = Mo(
13810
13814
  (ye == null ? void 0 : ye.id) ?? (ye == null ? void 0 : ye.interrupt_id)
13811
13815
  ), mt = !!(Ee && pt && pt === Ee), St = mt ? Ne ?? (ye == null ? void 0 : ye.value) : ye == null ? void 0 : ye.value, Pe = pt ? { ...ye, id: pt, interrupt_id: pt } : ye;
13812
13816
  return /* @__PURE__ */ u.jsx(
@@ -13824,7 +13828,7 @@ const Bc = z.memo(function({
13824
13828
  }
13825
13829
  return null;
13826
13830
  }, [
13827
- K,
13831
+ W,
13828
13832
  Ae,
13829
13833
  tt,
13830
13834
  Nt,
@@ -13842,10 +13846,10 @@ const Bc = z.memo(function({
13842
13846
  /* @__PURE__ */ u.jsx(ji, { className: "h-4 w-4 text-muted-foreground" }),
13843
13847
  /* @__PURE__ */ u.jsx("span", { className: "text-sm text-muted-foreground", children: "File upload" })
13844
13848
  ] }), []), ce = z.useCallback(() => {
13845
- const W = te.trim().length > 0 || ne.length > 0 || Te.length > 0 || Z.length > 0;
13849
+ const V = te.trim().length > 0 || ne.length > 0 || Te.length > 0 || Z.length > 0;
13846
13850
  if (!J && Te.length > 0 && !r)
13847
13851
  return lt();
13848
- if (!J && !W && !r)
13852
+ if (!J && !V && !r)
13849
13853
  return null;
13850
13854
  if (J)
13851
13855
  return /* @__PURE__ */ u.jsx(
@@ -13874,22 +13878,22 @@ const Bc = z.memo(function({
13874
13878
  lt,
13875
13879
  H
13876
13880
  ]), fe = at(() => X ? "Assistant" : kC(t), [X, t]), he = z.useMemo(() => X ? [] : Array.isArray(C) ? C : [], [C, X]), qe = z.useMemo(() => {
13877
- var W;
13878
- return he.length ? N && he.some((we) => we.id === N) ? N : ((W = he[0]) == null ? void 0 : W.id) ?? null : null;
13879
- }, [N, he]), yt = z.useMemo(() => !he.length || !S ? null : he.some((W) => W.id === S) ? S : null, [S, he]) ?? qe, At = O === "user" && he.length > 0 && typeof k == "function", st = z.useCallback(
13880
- (W) => {
13881
+ var V;
13882
+ return he.length ? N && he.some((we) => we.id === N) ? N : ((V = he[0]) == null ? void 0 : V.id) ?? null : null;
13883
+ }, [N, he]), yt = z.useMemo(() => !he.length || !S ? null : he.some((V) => V.id === S) ? S : null, [S, he]) ?? qe, At = O === "user" && he.length > 0 && typeof k == "function", st = z.useCallback(
13884
+ (V) => {
13881
13885
  if (!k) return;
13882
- const we = (W == null ? void 0 : W.id) ?? null, ye = (W == null ? void 0 : W.parentId) ?? E ?? null;
13886
+ const we = (V == null ? void 0 : V.id) ?? null, ye = (V == null ? void 0 : V.parentId) ?? E ?? null;
13883
13887
  k(we, ye);
13884
13888
  },
13885
13889
  [E, k]
13886
- ), ze = z.useMemo(() => yt ? he.findIndex((W) => W.id === yt) : -1, [yt, he]), Pt = z.useMemo(() => ze < 0 ? null : he[ze] ?? null, [ze, he]), jt = z.useCallback((W) => {
13890
+ ), ze = z.useMemo(() => yt ? he.findIndex((V) => V.id === yt) : -1, [yt, he]), Pt = z.useMemo(() => ze < 0 ? null : he[ze] ?? null, [ze, he]), jt = z.useCallback((V) => {
13887
13891
  const we = [];
13888
- if (W.step !== null && we.push(`Step ${W.step}`), W.source && we.push(W.source), !W.createdAt)
13889
- return we.length ? we.join(" • ") : W.id.slice(0, 8);
13892
+ if (V.step !== null && we.push(`Step ${V.step}`), V.source && we.push(V.source), !V.createdAt)
13893
+ return we.length ? we.join(" • ") : V.id.slice(0, 8);
13890
13894
  let ye = "";
13891
13895
  try {
13892
- const pt = new Date(W.createdAt);
13896
+ const pt = new Date(V.createdAt);
13893
13897
  Number.isNaN(pt.getTime()) || (ye = new Intl.DateTimeFormat(void 0, {
13894
13898
  hour: "2-digit",
13895
13899
  minute: "2-digit"
@@ -13927,9 +13931,9 @@ const Bc = z.memo(function({
13927
13931
  role: "button",
13928
13932
  tabIndex: 0,
13929
13933
  "aria-expanded": L === "expanded",
13930
- onClick: () => F((W) => W === "expanded" ? "preview" : "expanded"),
13931
- onKeyDown: (W) => {
13932
- (W.key === "Enter" || W.key === " ") && (W.preventDefault(), F((we) => we === "expanded" ? "preview" : "expanded"));
13934
+ onClick: () => F((V) => V === "expanded" ? "preview" : "expanded"),
13935
+ onKeyDown: (V) => {
13936
+ (V.key === "Enter" || V.key === " ") && (V.preventDefault(), F((we) => we === "expanded" ? "preview" : "expanded"));
13933
13937
  },
13934
13938
  children: [
13935
13939
  /* @__PURE__ */ u.jsx("span", { children: oe.name ?? "Tool Output" }),
@@ -13951,8 +13955,8 @@ const Bc = z.memo(function({
13951
13955
  ),
13952
13956
  onClick: () => {
13953
13957
  if (ze <= 0) return;
13954
- const W = he[ze - 1];
13955
- W && st(W);
13958
+ const V = he[ze - 1];
13959
+ V && st(V);
13956
13960
  },
13957
13961
  "aria-label": "Previous checkpoint",
13958
13962
  disabled: ze <= 0,
@@ -13977,8 +13981,8 @@ const Bc = z.memo(function({
13977
13981
  ),
13978
13982
  onClick: () => {
13979
13983
  if (ze >= he.length - 1) return;
13980
- const W = he[ze + 1];
13981
- W && st(W);
13984
+ const V = he[ze + 1];
13985
+ V && st(V);
13982
13986
  },
13983
13987
  "aria-label": "Next checkpoint",
13984
13988
  disabled: ze >= he.length - 1,
@@ -14427,7 +14431,7 @@ const Hc = (e, t) => (e == null ? void 0 : e.id) ?? `message-${t}`, jC = (e) =>
14427
14431
  }
14428
14432
  }
14429
14433
  };
14430
- }, [a]), K = at(() => !m || x ? !1 : A ? "auto" : !1, [A, m, x]), ee = at(() => P ?? [], [P]), q = E ?? (ee.length ? ee[ee.length - 1].id : null), M = ee.length > 0, H = at(() => {
14434
+ }, [a]), W = at(() => !m || x ? !1 : A ? "auto" : !1, [A, m, x]), ee = at(() => P ?? [], [P]), q = E ?? (ee.length ? ee[ee.length - 1].id : null), M = ee.length > 0, H = at(() => {
14431
14435
  if (typeof h != "string") return null;
14432
14436
  const Z = h.trim();
14433
14437
  return Z ? {
@@ -14540,7 +14544,7 @@ const Hc = (e, t) => (e == null ? void 0 : e.id) ?? `message-${t}`, jC = (e) =>
14540
14544
  j.current = Z instanceof HTMLDivElement ? Z : null;
14541
14545
  },
14542
14546
  data: pe,
14543
- followOutput: K,
14547
+ followOutput: W,
14544
14548
  overscan: 200,
14545
14549
  increaseViewportBy: { top: 100, bottom: 200 },
14546
14550
  defaultItemHeight: 80,
@@ -14653,13 +14657,13 @@ function Ai({
14653
14657
  kt(() => {
14654
14658
  pe || Ae(!1);
14655
14659
  }, [pe]);
14656
- const K = ke(() => {
14660
+ const W = ke(() => {
14657
14661
  Ae(!0);
14658
14662
  }, []), ee = ke(() => {
14659
14663
  Ae(!1);
14660
14664
  }, []), q = !!pe || Ie, [M, H] = xe(null), [te, oe] = xe(""), [ne, Te] = xe(null), [Z, de] = xe(null), [Ee, Ne] = xe([]), [Le, Je] = xe(0), [He, Ve] = xe(0), [Ke, Xe] = xe(!1), [Ze, tt] = xe(null), [Nt, ht] = xe(null), [lt, ce] = xe(!1), [fe, he] = xe(null), [qe, Fe] = xe(!1), yt = Qe(!1), [At, st] = xe(() => Uc.value), ze = Qe(At), Pt = Qe(null), jt = ke((G) => {
14661
14665
  Uc.value = G, st(G);
14662
- }, []), [W, we] = xe(!1), ye = Qe(null), pt = ke((G) => {
14666
+ }, []), [V, we] = xe(!1), ye = Qe(null), pt = ke((G) => {
14663
14667
  if (!Array.isArray(G))
14664
14668
  return { text: null, messageId: null };
14665
14669
  for (let re = G.length - 1; re >= 0; re--) {
@@ -14834,7 +14838,7 @@ function Ai({
14834
14838
  }, [x.baseUrl]), kt(() => {
14835
14839
  j && !lt && (m == null || m(j));
14836
14840
  }, [j, lt, m]);
14837
- const V = (G) => {
14841
+ const K = (G) => {
14838
14842
  if (G.length > Wo)
14839
14843
  return `Message too long (${G.length}/${Wo} characters)`;
14840
14844
  try {
@@ -14846,7 +14850,7 @@ function Ai({
14846
14850
  const re = G.trim();
14847
14851
  if (!(!re && Ee.length === 0)) {
14848
14852
  if (re) {
14849
- const ie = V(re);
14853
+ const ie = K(re);
14850
14854
  if (ie) {
14851
14855
  de(ie);
14852
14856
  return;
@@ -15044,10 +15048,10 @@ function Ai({
15044
15048
  onRegenerate: Be,
15045
15049
  onCancelEdit: Ge,
15046
15050
  emptyMessage: fe ?? void 0,
15047
- isNavigatingCheckpoint: W,
15051
+ isNavigatingCheckpoint: V,
15048
15052
  activeInterrupt: pe,
15049
15053
  disableInterruptActions: Ie,
15050
- onInterruptActionStart: K,
15054
+ onInterruptActionStart: W,
15051
15055
  onInterruptActionEnd: ee,
15052
15056
  showToolMessages: d,
15053
15057
  checkpointMetaById: Vt,
@@ -15066,7 +15070,7 @@ function Ai({
15066
15070
  /* @__PURE__ */ u.jsx(zr, { className: "h-6 w-6 animate-spin" }),
15067
15071
  /* @__PURE__ */ u.jsx("span", { className: "text-xs font-semibold uppercase tracking-wide", children: "Loading messages…" })
15068
15072
  ] }),
15069
- (T || W) && /* @__PURE__ */ u.jsxs("div", { className: "absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground", children: [
15073
+ (T || V) && /* @__PURE__ */ u.jsxs("div", { className: "absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground", children: [
15070
15074
  /* @__PURE__ */ u.jsx(zr, { className: "h-6 w-6 animate-spin" }),
15071
15075
  /* @__PURE__ */ u.jsx("span", { className: "text-xs font-semibold uppercase tracking-wide", children: "Loading checkpoint…" })
15072
15076
  ] })
@@ -15781,78 +15785,78 @@ function Kc({
15781
15785
  actions: x
15782
15786
  } = xa(), { loadThread: y } = ya(), { createThread: g, deleteThread: w, renameThread: b } = x, [T, C] = xe(Array.isArray(f) ? f : []), S = Qe(T.length > 0), k = Qe(null), N = Qe(0), [E, I] = xe(null), [P, L] = xe(""), [F, j] = xe(!1);
15783
15787
  kt(() => {
15784
- const K = Array.isArray(f) ? f : [];
15785
- if (K.length > 0) {
15786
- S.current = !0, C(K);
15788
+ const W = Array.isArray(f) ? f : [];
15789
+ if (W.length > 0) {
15790
+ S.current = !0, C(W);
15787
15791
  return;
15788
15792
  }
15789
- m || (S.current = !1, C(K));
15793
+ m || (S.current = !1, C(W));
15790
15794
  }, [f, m]), kt(() => {
15791
15795
  if (!k.current) return;
15792
- const K = k.current.querySelector(
15796
+ const W = k.current.querySelector(
15793
15797
  "[data-radix-scroll-area-viewport]"
15794
15798
  );
15795
- if (!K) return;
15799
+ if (!W) return;
15796
15800
  let ee = null, q = null;
15797
15801
  return ee = requestAnimationFrame(() => {
15798
15802
  q = requestAnimationFrame(() => {
15799
- K.scrollTop = N.current;
15803
+ W.scrollTop = N.current;
15800
15804
  });
15801
15805
  }), () => {
15802
15806
  ee !== null && cancelAnimationFrame(ee), q !== null && cancelAnimationFrame(q);
15803
15807
  };
15804
15808
  }, [T]);
15805
- const $ = async (K) => {
15809
+ const $ = async (W) => {
15806
15810
  try {
15807
- h(K), await y(K), a == null || a(K), l == null || l(K);
15811
+ h(W), await y(W), a == null || a(W), l == null || l(W);
15808
15812
  } catch (ee) {
15809
15813
  console.error("Failed to select thread:", ee);
15810
15814
  }
15811
15815
  }, A = async () => {
15812
15816
  try {
15813
15817
  j(!0);
15814
- const K = await g();
15815
- K && (c == null || c(K), a == null || a(K));
15816
- } catch (K) {
15817
- console.error("Failed to create thread:", K);
15818
+ const W = await g();
15819
+ W && (c == null || c(W), a == null || a(W));
15820
+ } catch (W) {
15821
+ console.error("Failed to create thread:", W);
15818
15822
  } finally {
15819
15823
  j(!1);
15820
15824
  }
15821
- }, B = async (K, ee) => {
15825
+ }, B = async (W, ee) => {
15822
15826
  if (ee.stopPropagation(), !!confirm("Delete this thread?")) {
15823
15827
  if (k.current) {
15824
15828
  const q = k.current.querySelector("[data-radix-scroll-area-viewport]");
15825
15829
  q && (N.current = q.scrollTop);
15826
15830
  }
15827
15831
  try {
15828
- await w(K), d == null || d(K);
15832
+ await w(W), d == null || d(W);
15829
15833
  } catch (q) {
15830
15834
  console.error("Failed to delete thread:", q);
15831
15835
  }
15832
15836
  }
15833
- }, D = (K, ee) => {
15834
- ee.stopPropagation(), I(K.threadId), L(K.title || `Thread ${K.threadId.slice(0, 8)}`);
15835
- }, O = async (K) => {
15837
+ }, D = (W, ee) => {
15838
+ ee.stopPropagation(), I(W.threadId), L(W.title || `Thread ${W.threadId.slice(0, 8)}`);
15839
+ }, O = async (W) => {
15836
15840
  if (P.trim())
15837
15841
  try {
15838
- await b(K, P.trim()), I(null), L("");
15842
+ await b(W, P.trim()), I(null), L("");
15839
15843
  } catch (ee) {
15840
15844
  console.error("Failed to update title:", ee);
15841
15845
  }
15842
15846
  }, J = () => {
15843
15847
  I(null), L("");
15844
- }, X = (K, ee) => {
15845
- K.key === "Enter" ? O(ee) : K.key === "Escape" && J();
15846
- }, pe = (K) => {
15847
- if (!K) return "";
15848
+ }, X = (W, ee) => {
15849
+ W.key === "Enter" ? O(ee) : W.key === "Escape" && J();
15850
+ }, pe = (W) => {
15851
+ if (!W) return "";
15848
15852
  try {
15849
- const ee = new Date(K), M = (/* @__PURE__ */ new Date()).getTime() - ee.getTime(), H = Math.floor(M / (1e3 * 60 * 60 * 24));
15853
+ const ee = new Date(W), M = (/* @__PURE__ */ new Date()).getTime() - ee.getTime(), H = Math.floor(M / (1e3 * 60 * 60 * 24));
15850
15854
  return H === 0 ? ee.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) : H === 1 ? "Yesterday" : H < 7 ? `${H} days ago` : ee.toLocaleDateString();
15851
15855
  } catch {
15852
15856
  return "";
15853
15857
  }
15854
- }, Ie = (K) => K.title || `Thread ${K.threadId.slice(0, 8)}`, Ae = (K) => {
15855
- const ee = Ie(K);
15858
+ }, Ie = (W) => W.title || `Thread ${W.threadId.slice(0, 8)}`, Ae = (W) => {
15859
+ const ee = Ie(W);
15856
15860
  return ee.length <= Vc ? ee : `${ee.slice(0, Vc)}...`;
15857
15861
  };
15858
15862
  return /* @__PURE__ */ u.jsxs("div", { className: `flex flex-col h-full ${e} ${s.container || ""}`, children: [
@@ -15880,32 +15884,32 @@ function Kc({
15880
15884
  ] }) : T.length === 0 ? /* @__PURE__ */ u.jsxs("div", { className: "text-center py-8 text-slate-400", children: [
15881
15885
  /* @__PURE__ */ u.jsx(Sm, { className: "w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500" }),
15882
15886
  /* @__PURE__ */ u.jsx("p", { className: "text-sm text-slate-500", children: "No conversations yet" })
15883
- ] }) : T.slice().sort((K, ee) => new Date(ee.updatedAt || ee.createdAt || "").getTime() - new Date(K.updatedAt || K.createdAt || "").getTime()).map((K) => /* @__PURE__ */ u.jsxs(
15887
+ ] }) : T.slice().sort((W, ee) => new Date(ee.updatedAt || ee.createdAt || "").getTime() - new Date(W.updatedAt || W.createdAt || "").getTime()).map((W) => /* @__PURE__ */ u.jsxs(
15884
15888
  "div",
15885
15889
  {
15886
- onClick: () => $(K.threadId),
15887
- className: `group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i ?? p) === K.threadId ? `${s.activeThread || "bg-slate-600 border-slate-500"} ` : `${s.threadItem || "bg-slate-700 border-slate-600 hover:bg-slate-600 text-gray-900 dark:text-slate-100"}`} ${s.threadItem || ""} text-gray-900 dark:text-slate-100`,
15890
+ onClick: () => $(W.threadId),
15891
+ className: `group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i ?? p) === W.threadId ? `${s.activeThread || "bg-slate-600 border-slate-500"} ` : `${s.threadItem || "bg-slate-700 border-slate-600 hover:bg-slate-600 text-gray-900 dark:text-slate-100"}`} ${s.threadItem || ""} text-gray-900 dark:text-slate-100`,
15888
15892
  children: [
15889
15893
  /* @__PURE__ */ u.jsxs("div", { className: "flex items-center justify-between", children: [
15890
- /* @__PURE__ */ u.jsx("div", { className: "flex-1 min-w-0", children: E === K.threadId ? /* @__PURE__ */ u.jsxs("div", { className: "flex items-center gap-2", onClick: (ee) => ee.stopPropagation(), children: [
15891
- /* @__PURE__ */ u.jsx(ps, { value: P, onChange: (ee) => L(ee.target.value), onKeyDown: (ee) => X(ee, K.threadId), className: "h-6 text-sm", autoFocus: !0 }),
15892
- /* @__PURE__ */ u.jsx(rt, { variant: "ghost", size: "sm", onClick: () => O(K.threadId), className: "h-6 w-6 p-0", children: /* @__PURE__ */ u.jsx(ca, { size: 12 }) }),
15894
+ /* @__PURE__ */ u.jsx("div", { className: "flex-1 min-w-0", children: E === W.threadId ? /* @__PURE__ */ u.jsxs("div", { className: "flex items-center gap-2", onClick: (ee) => ee.stopPropagation(), children: [
15895
+ /* @__PURE__ */ u.jsx(ps, { value: P, onChange: (ee) => L(ee.target.value), onKeyDown: (ee) => X(ee, W.threadId), className: "h-6 text-sm", autoFocus: !0 }),
15896
+ /* @__PURE__ */ u.jsx(rt, { variant: "ghost", size: "sm", onClick: () => O(W.threadId), className: "h-6 w-6 p-0", children: /* @__PURE__ */ u.jsx(ca, { size: 12 }) }),
15893
15897
  /* @__PURE__ */ u.jsx(rt, { variant: "ghost", size: "sm", onClick: J, className: "h-6 w-6 p-0", children: /* @__PURE__ */ u.jsx(vr, { size: 12 }) })
15894
15898
  ] }) : /* @__PURE__ */ u.jsxs(u.Fragment, { children: [
15895
- /* @__PURE__ */ u.jsx("div", { className: "font-medium text-sm truncate text-gray-900 dark:text-slate-100", children: Ae(K) }),
15899
+ /* @__PURE__ */ u.jsx("div", { className: "font-medium text-sm truncate text-gray-900 dark:text-slate-100", children: Ae(W) }),
15896
15900
  /* @__PURE__ */ u.jsxs("div", { className: "flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1", children: [
15897
15901
  /* @__PURE__ */ u.jsx(Cm, { size: 10 }),
15898
- /* @__PURE__ */ u.jsx("span", { children: pe(K.updatedAt || K.createdAt) })
15902
+ /* @__PURE__ */ u.jsx("span", { children: pe(W.updatedAt || W.createdAt) })
15899
15903
  ] })
15900
15904
  ] }) }),
15901
15905
  /* @__PURE__ */ u.jsxs("div", { className: "flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2", children: [
15902
- r && E !== K.threadId && /* @__PURE__ */ u.jsx(rt, { variant: "ghost", size: "sm", onClick: (ee) => D(K, ee), className: "h-6 w-6 p-0", title: "Edit title", children: /* @__PURE__ */ u.jsx(Jc, { size: 12 }) }),
15906
+ r && E !== W.threadId && /* @__PURE__ */ u.jsx(rt, { variant: "ghost", size: "sm", onClick: (ee) => D(W, ee), className: "h-6 w-6 p-0", title: "Edit title", children: /* @__PURE__ */ u.jsx(Jc, { size: 12 }) }),
15903
15907
  n && /* @__PURE__ */ u.jsx(
15904
15908
  rt,
15905
15909
  {
15906
15910
  variant: "ghost",
15907
15911
  size: "sm",
15908
- onClick: (ee) => B(K.threadId, ee),
15912
+ onClick: (ee) => B(W.threadId, ee),
15909
15913
  className: "h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",
15910
15914
  title: "Delete thread",
15911
15915
  children: /* @__PURE__ */ u.jsx(Tm, { size: 12 })
@@ -15913,10 +15917,10 @@ function Kc({
15913
15917
  )
15914
15918
  ] })
15915
15919
  ] }),
15916
- i === K.threadId && /* @__PURE__ */ u.jsx("div", { className: "absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r" })
15920
+ i === W.threadId && /* @__PURE__ */ u.jsx("div", { className: "absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r" })
15917
15921
  ]
15918
15922
  },
15919
- K.threadId
15923
+ W.threadId
15920
15924
  )) })
15921
15925
  }
15922
15926
  )
@@ -16468,7 +16472,7 @@ var dn = 10, [vh, Xn] = Mr(ur), pT = "SelectContentImpl", hT = Tr("SelectContent
16468
16472
  (w.value !== void 0 && w.value === M || te) && P(q);
16469
16473
  },
16470
16474
  [w.value]
16471
- ), K = r === "popper" ? na : bh, ee = K === na ? {
16475
+ ), W = r === "popper" ? na : bh, ee = W === na ? {
16472
16476
  side: a,
16473
16477
  sideOffset: l,
16474
16478
  align: c,
@@ -16518,7 +16522,7 @@ var dn = 10, [vh, Xn] = Mr(ur), pT = "SelectContentImpl", hT = Tr("SelectContent
16518
16522
  onFocusOutside: (q) => q.preventDefault(),
16519
16523
  onDismiss: () => w.onOpenChange(!1),
16520
16524
  children: /* @__PURE__ */ u.jsx(
16521
- K,
16525
+ W,
16522
16526
  {
16523
16527
  role: "listbox",
16524
16528
  id: w.contentId,
@@ -16581,12 +16585,12 @@ var mT = "SelectItemAlignedPosition", bh = v.forwardRef((e, t) => {
16581
16585
  ]);
16582
16586
  a.style.minWidth = Z + "px", a.style.right = Ne + "px";
16583
16587
  }
16584
- const P = p(), L = window.innerHeight - dn * 2, F = x.scrollHeight, j = window.getComputedStyle(c), $ = parseInt(j.borderTopWidth, 10), A = parseInt(j.paddingTop, 10), B = parseInt(j.borderBottomWidth, 10), D = parseInt(j.paddingBottom, 10), O = $ + A + F + D + B, J = Math.min(y.offsetHeight * 5, O), X = window.getComputedStyle(x), pe = parseInt(X.paddingTop, 10), Ie = parseInt(X.paddingBottom, 10), Ae = k.top + k.height / 2 - dn, K = L - Ae, ee = y.offsetHeight / 2, q = y.offsetTop + ee, M = $ + A + q, H = O - M;
16588
+ const P = p(), L = window.innerHeight - dn * 2, F = x.scrollHeight, j = window.getComputedStyle(c), $ = parseInt(j.borderTopWidth, 10), A = parseInt(j.paddingTop, 10), B = parseInt(j.borderBottomWidth, 10), D = parseInt(j.paddingBottom, 10), O = $ + A + F + D + B, J = Math.min(y.offsetHeight * 5, O), X = window.getComputedStyle(x), pe = parseInt(X.paddingTop, 10), Ie = parseInt(X.paddingBottom, 10), Ae = k.top + k.height / 2 - dn, W = L - Ae, ee = y.offsetHeight / 2, q = y.offsetTop + ee, M = $ + A + q, H = O - M;
16585
16589
  if (M <= Ae) {
16586
16590
  const oe = P.length > 0 && y === P[P.length - 1].ref.current;
16587
16591
  a.style.bottom = "0px";
16588
16592
  const ne = c.clientHeight - x.offsetTop - x.offsetHeight, Te = Math.max(
16589
- K,
16593
+ W,
16590
16594
  ee + // viewport might have padding bottom, include it to avoid a scrollable viewport
16591
16595
  (oe ? Ie : 0) + ne + B
16592
16596
  ), Z = M + Te;