teodor-new-chat-ui 4.3.289 → 4.3.290

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 Em() {
51
51
  function y(R) {
52
52
  if (R === null || typeof R != "object")
53
53
  return null;
54
- var W = m && R[m] || R[x];
55
- return typeof W == "function" ? W : null;
54
+ var V = m && R[m] || R[x];
55
+ return typeof V == "function" ? V : 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 W = arguments.length, le = new Array(W > 1 ? W - 1 : 0), Ee = 1; Ee < W; Ee++)
60
+ for (var V = arguments.length, le = new Array(V > 1 ? V - 1 : 0), Ee = 1; Ee < V; Ee++)
61
61
  le[Ee - 1] = arguments[Ee];
62
62
  b("error", R, le);
63
63
  }
64
64
  }
65
- function b(R, W, le) {
65
+ function b(R, V, le) {
66
66
  {
67
67
  var Ee = g.ReactDebugCurrentFrame, tt = Ee.getStackAddendum();
68
- tt !== "" && (W += "%s", le = le.concat([tt]));
68
+ tt !== "" && (V += "%s", le = le.concat([tt]));
69
69
  var lt = le.map(function(Ke) {
70
70
  return String(Ke);
71
71
  });
72
- lt.unshift("Warning: " + W), Function.prototype.apply.call(console[R], console, lt);
72
+ lt.unshift("Warning: " + V), Function.prototype.apply.call(console[R], console, lt);
73
73
  }
74
74
  }
75
75
  var T = !1, C = !1, S = !1, k = !1, E = !1, N;
@@ -81,11 +81,11 @@ function Em() {
81
81
  // with.
82
82
  R.$$typeof === N || R.getModuleId !== void 0));
83
83
  }
84
- function j(R, W, le) {
84
+ function j(R, V, le) {
85
85
  var Ee = R.displayName;
86
86
  if (Ee)
87
87
  return Ee;
88
- var tt = W.displayName || W.name || "";
88
+ var tt = V.displayName || V.name || "";
89
89
  return tt !== "" ? le + "(" + tt + ")" : le;
90
90
  }
91
91
  function P(R) {
@@ -115,8 +115,8 @@ function Em() {
115
115
  if (typeof R == "object")
116
116
  switch (R.$$typeof) {
117
117
  case a:
118
- var W = R;
119
- return P(W) + ".Consumer";
118
+ var V = R;
119
+ return P(V) + ".Consumer";
120
120
  case i:
121
121
  var le = R;
122
122
  return P(le._context) + ".Provider";
@@ -163,7 +163,7 @@ function Em() {
163
163
  F++;
164
164
  }
165
165
  }
166
- function K() {
166
+ function q() {
167
167
  {
168
168
  if (F--, F === 0) {
169
169
  var R = {
@@ -199,7 +199,7 @@ function Em() {
199
199
  }
200
200
  }
201
201
  var oe = g.ReactCurrentDispatcher, Y;
202
- function D(R, W, le) {
202
+ function D(R, V, le) {
203
203
  {
204
204
  if (Y === void 0)
205
205
  try {
@@ -217,7 +217,7 @@ function Em() {
217
217
  var se = typeof WeakMap == "function" ? WeakMap : Map;
218
218
  ne = new se();
219
219
  }
220
- function q(R, W) {
220
+ function K(R, V) {
221
221
  if (!R || H)
222
222
  return "";
223
223
  {
@@ -232,7 +232,7 @@ function Em() {
232
232
  var lt;
233
233
  lt = oe.current, oe.current = null, Ae();
234
234
  try {
235
- if (W) {
235
+ if (V) {
236
236
  var Ke = function() {
237
237
  throw Error();
238
238
  };
@@ -283,23 +283,23 @@ function Em() {
283
283
  }
284
284
  }
285
285
  } finally {
286
- H = !1, oe.current = lt, K(), Error.prepareStackTrace = tt;
286
+ H = !1, oe.current = lt, q(), Error.prepareStackTrace = tt;
287
287
  }
288
288
  var de = R ? R.displayName || R.name : "", fe = de ? D(de) : "";
289
289
  return typeof R == "function" && ne.set(R, fe), fe;
290
290
  }
291
- function Me(R, W, le) {
292
- return q(R, !1);
291
+ function Me(R, V, le) {
292
+ return K(R, !1);
293
293
  }
294
294
  function Ue(R) {
295
- var W = R.prototype;
296
- return !!(W && W.isReactComponent);
295
+ var V = R.prototype;
296
+ return !!(V && V.isReactComponent);
297
297
  }
298
- function Ze(R, W, le) {
298
+ function Ze(R, V, le) {
299
299
  if (R == null)
300
300
  return "";
301
301
  if (typeof R == "function")
302
- return q(R, Ue(R));
302
+ return K(R, Ue(R));
303
303
  if (typeof R == "string")
304
304
  return D(R);
305
305
  switch (R) {
@@ -313,11 +313,11 @@ function Em() {
313
313
  case l:
314
314
  return Me(R.render);
315
315
  case f:
316
- return Ze(R.type, W, le);
316
+ return Ze(R.type, V, le);
317
317
  case p: {
318
318
  var Ee = R, tt = Ee._payload, lt = Ee._init;
319
319
  try {
320
- return Ze(lt(tt), W, le);
320
+ return Ze(lt(tt), V, le);
321
321
  } catch {
322
322
  }
323
323
  }
@@ -327,12 +327,12 @@ function Em() {
327
327
  var re = Object.prototype.hasOwnProperty, me = {}, Le = g.ReactDebugCurrentFrame;
328
328
  function Fe(R) {
329
329
  if (R) {
330
- var W = R._owner, le = Ze(R.type, R._source, W ? W.type : null);
330
+ var V = R._owner, le = Ze(R.type, R._source, V ? V.type : null);
331
331
  Le.setExtraStackFrame(le);
332
332
  } else
333
333
  Le.setExtraStackFrame(null);
334
334
  }
335
- function Pe(R, W, le, Ee, tt) {
335
+ function Pe(R, V, le, Ee, tt) {
336
336
  {
337
337
  var lt = Function.call.bind(re);
338
338
  for (var Ke in R)
@@ -343,7 +343,7 @@ function Em() {
343
343
  var Pt = Error((Ee || "React class") + ": " + le + " type `" + Ke + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof R[Ke] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
344
344
  throw Pt.name = "Invariant Violation", Pt;
345
345
  }
346
- Be = R[Ke](W, Ke, Ee, le, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
346
+ Be = R[Ke](V, Ke, Ee, le, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
347
347
  } catch (wt) {
348
348
  Be = wt;
349
349
  }
@@ -357,7 +357,7 @@ function Em() {
357
357
  }
358
358
  function Ge(R) {
359
359
  {
360
- var W = typeof Symbol == "function" && Symbol.toStringTag, le = W && R[Symbol.toStringTag] || R.constructor.name || "Object";
360
+ var V = typeof Symbol == "function" && Symbol.toStringTag, le = V && R[Symbol.toStringTag] || R.constructor.name || "Object";
361
361
  return le;
362
362
  }
363
363
  }
@@ -383,27 +383,27 @@ function Em() {
383
383
  }, ft, it;
384
384
  function Ve(R) {
385
385
  if (re.call(R, "ref")) {
386
- var W = Object.getOwnPropertyDescriptor(R, "ref").get;
387
- if (W && W.isReactWarning)
386
+ var V = Object.getOwnPropertyDescriptor(R, "ref").get;
387
+ if (V && V.isReactWarning)
388
388
  return !1;
389
389
  }
390
390
  return R.ref !== void 0;
391
391
  }
392
392
  function jt(R) {
393
393
  if (re.call(R, "key")) {
394
- var W = Object.getOwnPropertyDescriptor(R, "key").get;
395
- if (W && W.isReactWarning)
394
+ var V = Object.getOwnPropertyDescriptor(R, "key").get;
395
+ if (V && V.isReactWarning)
396
396
  return !1;
397
397
  }
398
398
  return R.key !== void 0;
399
399
  }
400
- function Ct(R, W) {
400
+ function Ct(R, V) {
401
401
  typeof R.ref == "string" && mt.current;
402
402
  }
403
- function Zt(R, W) {
403
+ function Zt(R, V) {
404
404
  {
405
405
  var le = function() {
406
- ft || (ft = !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)", W));
406
+ ft || (ft = !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
408
  le.isReactWarning = !0, Object.defineProperty(R, "key", {
409
409
  get: le,
@@ -411,10 +411,10 @@ function Em() {
411
411
  });
412
412
  }
413
413
  }
414
- function ln(R, W) {
414
+ function ln(R, V) {
415
415
  {
416
416
  var le = function() {
417
- it || (it = !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)", W));
417
+ it || (it = !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
419
  le.isReactWarning = !0, Object.defineProperty(R, "ref", {
420
420
  get: le,
@@ -422,13 +422,13 @@ function Em() {
422
422
  });
423
423
  }
424
424
  }
425
- var Ye = function(R, W, le, Ee, tt, lt, Ke) {
425
+ var Ye = function(R, V, le, Ee, tt, lt, Ke) {
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
- key: W,
431
+ key: V,
432
432
  ref: le,
433
433
  props: Ke,
434
434
  // Record the component responsible for creating this element.
@@ -451,12 +451,12 @@ function Em() {
451
451
  value: tt
452
452
  }), Object.freeze && (Object.freeze(Be.props), Object.freeze(Be)), Be;
453
453
  };
454
- function _e(R, W, le, Ee, tt) {
454
+ function _e(R, V, le, Ee, tt) {
455
455
  {
456
456
  var lt, Ke = {}, Be = null, Pt = null;
457
- le !== void 0 && (St(le), Be = "" + le), jt(W) && (St(W.key), Be = "" + W.key), Ve(W) && (Pt = W.ref, Ct(W, tt));
458
- for (lt in W)
459
- re.call(W, lt) && !gt.hasOwnProperty(lt) && (Ke[lt] = W[lt]);
457
+ le !== void 0 && (St(le), Be = "" + le), jt(V) && (St(V.key), Be = "" + V.key), Ve(V) && (Pt = V.ref, Ct(V, tt));
458
+ for (lt in V)
459
+ re.call(V, lt) && !gt.hasOwnProperty(lt) && (Ke[lt] = V[lt]);
460
460
  if (R && R.defaultProps) {
461
461
  var wt = R.defaultProps;
462
462
  for (lt in wt)
@@ -472,7 +472,7 @@ function Em() {
472
472
  var _t = g.ReactCurrentOwner, zt = g.ReactDebugCurrentFrame;
473
473
  function B(R) {
474
474
  if (R) {
475
- var W = R._owner, le = Ze(R.type, R._source, W ? W.type : null);
475
+ var V = R._owner, le = Ze(R.type, R._source, V ? V.type : null);
476
476
  zt.setExtraStackFrame(le);
477
477
  } else
478
478
  zt.setExtraStackFrame(null);
@@ -494,28 +494,28 @@ Check the render method of \`` + R + "`.";
494
494
  return "";
495
495
  }
496
496
  }
497
- function V(R) {
497
+ function W(R) {
498
498
  return "";
499
499
  }
500
500
  var ie = {};
501
501
  function ee(R) {
502
502
  {
503
- var W = at();
504
- if (!W) {
503
+ var V = at();
504
+ if (!V) {
505
505
  var le = typeof R == "string" ? R : R.displayName || R.name;
506
- le && (W = `
506
+ le && (V = `
507
507
 
508
508
  Check the top-level render call using <` + le + ">.");
509
509
  }
510
- return W;
510
+ return V;
511
511
  }
512
512
  }
513
- function Se(R, W) {
513
+ function Se(R, V) {
514
514
  {
515
515
  if (!R._store || R._store.validated || R.key != null)
516
516
  return;
517
517
  R._store.validated = !0;
518
- var le = ee(W);
518
+ var le = ee(V);
519
519
  if (ie[le])
520
520
  return;
521
521
  ie[le] = !0;
@@ -523,14 +523,14 @@ Check the top-level render call using <` + le + ">.");
523
523
  R && R._owner && R._owner !== _t.current && (Ee = " It was passed a child from " + $(R._owner.type) + "."), B(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.', le, Ee), B(null);
524
524
  }
525
525
  }
526
- function ae(R, W) {
526
+ function ae(R, V) {
527
527
  {
528
528
  if (typeof R != "object")
529
529
  return;
530
530
  if (We(R))
531
531
  for (var le = 0; le < R.length; le++) {
532
532
  var Ee = R[le];
533
- ve(Ee) && Se(Ee, W);
533
+ ve(Ee) && Se(Ee, V);
534
534
  }
535
535
  else if (ve(R))
536
536
  R._store && (R._store.validated = !0);
@@ -538,39 +538,39 @@ Check the top-level render call using <` + le + ">.");
538
538
  var tt = y(R);
539
539
  if (typeof tt == "function" && tt !== R.entries)
540
540
  for (var lt = tt.call(R), Ke; !(Ke = lt.next()).done; )
541
- ve(Ke.value) && Se(Ke.value, W);
541
+ ve(Ke.value) && Se(Ke.value, V);
542
542
  }
543
543
  }
544
544
  }
545
545
  function Te(R) {
546
546
  {
547
- var W = R.type;
548
- if (W == null || typeof W == "string")
547
+ var V = R.type;
548
+ if (V == null || typeof V == "string")
549
549
  return;
550
550
  var le;
551
- if (typeof W == "function")
552
- le = W.propTypes;
553
- else if (typeof W == "object" && (W.$$typeof === l || // Note: Memo only checks outer props here.
551
+ if (typeof V == "function")
552
+ le = V.propTypes;
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
- W.$$typeof === f))
556
- le = W.propTypes;
555
+ V.$$typeof === f))
556
+ le = V.propTypes;
557
557
  else
558
558
  return;
559
559
  if (le) {
560
- var Ee = $(W);
560
+ var Ee = $(V);
561
561
  Pe(le, R.props, "prop", Ee, R);
562
- } else if (W.PropTypes !== void 0 && !ye) {
562
+ } else if (V.PropTypes !== void 0 && !ye) {
563
563
  ye = !0;
564
- var tt = $(W);
564
+ var tt = $(V);
565
565
  w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", tt || "Unknown");
566
566
  }
567
- typeof W.getDefaultProps == "function" && !W.getDefaultProps.isReactClassApproved && w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
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.");
568
568
  }
569
569
  }
570
570
  function Ut(R) {
571
571
  {
572
- for (var W = Object.keys(R.props), le = 0; le < W.length; le++) {
573
- var Ee = W[le];
572
+ for (var V = Object.keys(R.props), le = 0; le < V.length; le++) {
573
+ var Ee = V[le];
574
574
  if (Ee !== "children" && Ee !== "key") {
575
575
  B(R), w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", Ee), B(null);
576
576
  break;
@@ -580,22 +580,22 @@ Check the top-level render call using <` + le + ">.");
580
580
  }
581
581
  }
582
582
  var Tt = {};
583
- function cn(R, W, le, Ee, tt, lt) {
583
+ function cn(R, V, le, Ee, tt, lt) {
584
584
  {
585
585
  var Ke = M(R);
586
586
  if (!Ke) {
587
587
  var Be = "";
588
588
  (R === void 0 || typeof R == "object" && R !== null && Object.keys(R).length === 0) && (Be += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
589
- var Pt = V();
589
+ var Pt = W();
590
590
  Pt ? Be += Pt : Be += at();
591
591
  var wt;
592
592
  R === null ? wt = "null" : We(R) ? wt = "array" : R !== void 0 && R.$$typeof === t ? (wt = "<" + ($(R.type) || "Unknown") + " />", Be = " Did you accidentally export a JSX literal instead of a component?") : wt = 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", wt, Be);
593
593
  }
594
- var bt = _e(R, W, le, tt, lt);
594
+ var bt = _e(R, V, le, tt, lt);
595
595
  if (bt == null)
596
596
  return bt;
597
597
  if (Ke) {
598
- var Q = W.children;
598
+ var Q = V.children;
599
599
  if (Q !== void 0)
600
600
  if (Ee)
601
601
  if (We(Q)) {
@@ -607,8 +607,8 @@ Check the top-level render call using <` + le + ">.");
607
607
  else
608
608
  ae(Q, R);
609
609
  }
610
- if (re.call(W, "key")) {
611
- var fe = $(R), be = Object.keys(W).filter(function(un) {
610
+ if (re.call(V, "key")) {
611
+ var fe = $(R), be = Object.keys(V).filter(function(un) {
612
612
  return un !== "key";
613
613
  }), ct = be.length > 0 ? "{key: someKey, " + be.join(": ..., ") + ": ...}" : "{key: someKey}";
614
614
  if (!Tt[fe + ct]) {
@@ -624,11 +624,11 @@ React keys must be passed directly to JSX without using spread:
624
624
  return R === r ? Ut(bt) : Te(bt), bt;
625
625
  }
626
626
  }
627
- function kt(R, W, le) {
628
- return cn(R, W, le, !0);
627
+ function kt(R, V, le) {
628
+ return cn(R, V, le, !0);
629
629
  }
630
- function Mn(R, W, le) {
631
- return cn(R, W, le, !1);
630
+ function Mn(R, V, le) {
631
+ return cn(R, V, le, !1);
632
632
  }
633
633
  var Zs = Mn, vo = kt;
634
634
  Dr.Fragment = r, Dr.jsx = Zs, Dr.jsxs = vo;
@@ -1904,8 +1904,8 @@ const uu = (e) => {
1904
1904
  const _ = d && (k === "stream" || k === "response");
1905
1905
  if (d && (C || _ && I)) {
1906
1906
  const G = {};
1907
- ["status", "statusText", "headers"].forEach((K) => {
1908
- G[K] = L[K];
1907
+ ["status", "statusText", "headers"].forEach((q) => {
1908
+ G[q] = L[q];
1909
1909
  });
1910
1910
  const pe = O.toFiniteNumber(L.headers.get("content-length")), [Re, Ae] = C && pl(
1911
1911
  pe,
@@ -3048,7 +3048,7 @@ function Ox(e = {}) {
3048
3048
  threadId: I.threadId ?? null,
3049
3049
  headers: {}
3050
3050
  }, (async () => {
3051
- var pe, Re, Ae, K, oe, Y, D, H, ne, se, q, Me, Ue, Ze, re, me, Le, Fe;
3051
+ var pe, Re, Ae, q, oe, Y, D, H, ne, se, K, Me, Ue, Ze, re, me, Le, Fe;
3052
3052
  const G = (Pe) => {
3053
3053
  var et;
3054
3054
  try {
@@ -3087,7 +3087,7 @@ function Ox(e = {}) {
3087
3087
  let et = {};
3088
3088
  if (typeof window < "u")
3089
3089
  try {
3090
- const Ye = (K = window.localStorage) == null ? void 0 : K.getItem("authSessionId");
3090
+ const Ye = (q = window.localStorage) == null ? void 0 : q.getItem("authSessionId");
3091
3091
  Ye && (et = { "X-Session-Id": Ye });
3092
3092
  } catch {
3093
3093
  }
@@ -3153,13 +3153,13 @@ function Ox(e = {}) {
3153
3153
  `)) >= 0; ) {
3154
3154
  const at = mt.slice(0, ve);
3155
3155
  mt = mt.slice(ve + 2);
3156
- const V = Dx(at);
3157
- if (!V) continue;
3156
+ const W = Dx(at);
3157
+ if (!W) continue;
3158
3158
  let ie;
3159
3159
  try {
3160
- ie = JSON.parse(V);
3160
+ ie = JSON.parse(W);
3161
3161
  } catch {
3162
- console.debug("[use-chat] malformed SSE:", V.slice(0, 200));
3162
+ console.debug("[use-chat] malformed SSE:", W.slice(0, 200));
3163
3163
  continue;
3164
3164
  }
3165
3165
  const ee = Mx(ie) ? ie.data : ie;
@@ -3215,7 +3215,7 @@ function Ox(e = {}) {
3215
3215
  m(ee.checkpointId);
3216
3216
  else if (ee.type === "error") {
3217
3217
  const ae = ee;
3218
- if (d(ae.message), L = "error", _ = ae.message, ae.error_type === "auth_error" || ae.code === "TOKEN_EXPIRED" || ((ne = ae.message) == null ? void 0 : ne.includes("token")) || ((se = ae.message) == null ? void 0 : se.includes("401")) || ((q = ae.message) == null ? void 0 : q.includes("unauthorized")) || ((Me = ae.message) == null ? void 0 : Me.includes("Unauthorized"))) {
3218
+ if (d(ae.message), L = "error", _ = ae.message, ae.error_type === "auth_error" || ae.code === "TOKEN_EXPIRED" || ((ne = ae.message) == null ? void 0 : ne.includes("token")) || ((se = ae.message) == null ? void 0 : se.includes("401")) || ((K = ae.message) == null ? void 0 : K.includes("unauthorized")) || ((Me = ae.message) == null ? void 0 : Me.includes("Unauthorized"))) {
3219
3219
  console.error("[use-chat] Auth error detected:", ae.message);
3220
3220
  try {
3221
3221
  (Ue = A == null ? void 0 : A.onAuthError) == null || Ue.call(A, ae.message);
@@ -3966,66 +3966,66 @@ function qx({
3966
3966
  onThreadChange: a,
3967
3967
  checkpointMetadataCache: l
3968
3968
  }) {
3969
- const { api: c, baseUrl: d } = xu(), f = rt(() => _n(d), [d]), [p, h] = we([]), [m, x] = we(t), [y, g] = we(!1), [w, b] = we(null), [T, C] = we(!1), [S, k] = we(null), { state: E, seed: N, prepend: M, pushUser: j, onEvent: P } = zx(), [$, I] = we(!1), [F, A] = we(!1), [X, L] = we(null), [_, J] = we([]), [G, pe] = we([]), [Re, Ae] = we(!1), K = ke(
3970
- (V) => {
3971
- if (!V.length) return;
3969
+ const { api: c, baseUrl: d } = xu(), f = rt(() => _n(d), [d]), [p, h] = we([]), [m, x] = we(t), [y, g] = we(!1), [w, b] = we(null), [T, C] = we(!1), [S, k] = we(null), { state: E, seed: N, prepend: M, pushUser: j, onEvent: P } = zx(), [$, I] = we(!1), [F, A] = we(!1), [X, L] = we(null), [_, J] = we([]), [G, pe] = we([]), [Re, Ae] = we(!1), q = ke(
3970
+ (W) => {
3971
+ if (!W.length) return;
3972
3972
  const ie = new Set(
3973
- V.map((ee) => ee.checkpointId).filter((ee) => !!(ee != null && ee.trim()))
3973
+ W.map((ee) => ee.checkpointId).filter((ee) => !!(ee != null && ee.trim()))
3974
3974
  );
3975
3975
  J((ee) => [...ee.filter((ae) => {
3976
3976
  const Te = ae.checkpointId;
3977
3977
  return Te ? !ie.has(Te) : !0;
3978
- }), ...V]);
3978
+ }), ...W]);
3979
3979
  },
3980
3980
  []
3981
- ), oe = ke((V) => {
3982
- if (!V.length) return;
3983
- const ie = new Set(V.map((ee) => ee.id));
3984
- pe((ee) => [...ee.filter((ae) => !ie.has(ae.id)), ...V]);
3981
+ ), oe = ke((W) => {
3982
+ if (!W.length) return;
3983
+ const ie = new Set(W.map((ee) => ee.id));
3984
+ pe((ee) => [...ee.filter((ae) => !ie.has(ae.id)), ...W]);
3985
3985
  }, []), Y = rt(
3986
- () => _.flatMap((V) => V.messages ?? []),
3986
+ () => _.flatMap((W) => W.messages ?? []),
3987
3987
  [_]
3988
3988
  ), D = rt(() => Px(Y), [Y]), H = l ?? Kx(), { setCacheForThread: ne } = H, se = ke(
3989
- (V, ie, ee) => {
3989
+ (W, ie, ee) => {
3990
3990
  const Se = ie.filter((ae) => ae.checkpointId).map((ae) => ({
3991
3991
  checkpointId: ae.checkpointId,
3992
3992
  checkpointNs: ae.checkpointNs ?? void 0,
3993
3993
  createdAt: ae.createdAt ?? ""
3994
3994
  }));
3995
- console.log(`[ChatSessionProvider] Cached metadata for ${Se.length} checkpoints from ${ee}`), ne(V, Se);
3995
+ console.log(`[ChatSessionProvider] Cached metadata for ${Se.length} checkpoints from ${ee}`), ne(W, Se);
3996
3996
  },
3997
3997
  [ne]
3998
- ), q = He(m), Me = He(null), Ue = He(null), Ze = He(null), re = He(null), me = He(!1), Le = He(null), Fe = He(/* @__PURE__ */ new Map());
3998
+ ), K = He(m), Me = He(null), Ue = He(null), Ze = He(null), re = He(null), me = He(!1), Le = He(null), Fe = He(/* @__PURE__ */ new Map());
3999
3999
  Et(() => {
4000
- q.current = m;
4000
+ K.current = m;
4001
4001
  }, [m]);
4002
4002
  const Pe = ke(async () => {
4003
4003
  g(!0), b(null);
4004
4004
  try {
4005
- const V = await c.listThreads();
4006
- h(V ?? []);
4007
- } catch (V) {
4008
- const ie = String(V);
4005
+ const W = await c.listThreads();
4006
+ h(W ?? []);
4007
+ } catch (W) {
4008
+ const ie = String(W);
4009
4009
  b(ie), s == null || s(ie);
4010
4010
  } finally {
4011
4011
  g(!1);
4012
4012
  }
4013
- }, [c, s]), et = ke((V) => {
4014
- if (!(V != null && V.threadId)) return;
4013
+ }, [c, s]), et = ke((W) => {
4014
+ if (!(W != null && W.threadId)) return;
4015
4015
  const ie = {
4016
- threadId: V.threadId,
4017
- title: V.title || `Thread ${V.threadId.slice(0, 8)}`,
4018
- createdAt: V.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
4019
- updatedAt: V.updatedAt || (/* @__PURE__ */ new Date()).toISOString(),
4020
- messageCount: V.messageCount ?? 1
4016
+ threadId: W.threadId,
4017
+ title: W.title || `Thread ${W.threadId.slice(0, 8)}`,
4018
+ createdAt: W.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
4019
+ updatedAt: W.updatedAt || (/* @__PURE__ */ new Date()).toISOString(),
4020
+ messageCount: W.messageCount ?? 1
4021
4021
  };
4022
4022
  h((ee) => ee.some((ae) => ae.threadId === ie.threadId) ? (console.debug("[ChatSessionProvider] thread_info: thread already in list", ie.threadId), ee) : (console.debug("[ChatSessionProvider] thread_info: adding thread to list", ie.threadId), [ie, ...ee]));
4023
4023
  }, []), We = ke(
4024
- (V) => {
4025
- const ie = V.threadId ?? q.current;
4026
- if (!ie || q.current && q.current !== ie)
4024
+ (W) => {
4025
+ const ie = W.threadId ?? K.current;
4026
+ if (!ie || K.current && K.current !== ie)
4027
4027
  return;
4028
- const { checkpoints: ee, timeline: Se } = hr(V);
4028
+ const { checkpoints: ee, timeline: Se } = hr(W);
4029
4029
  if (!ee.length)
4030
4030
  return;
4031
4031
  se(ie, ee, "stream state_history");
@@ -4033,24 +4033,24 @@ function qx({
4033
4033
  N((ae == null ? void 0 : ae.messages) ?? [], {
4034
4034
  checkpointId: (ae == null ? void 0 : ae.checkpointId) ?? null,
4035
4035
  checkpointNs: (ae == null ? void 0 : ae.checkpointNs) ?? null
4036
- }), oe(Se), K(ee), I(!!(ae != null && ae.nextCursor)), L((ae == null ? void 0 : ae.nextCursor) ?? null), Le.current = `${ie}:latest`, Ue.current = null, Ze.current = null;
4036
+ }), oe(Se), q(ee), I(!!(ae != null && ae.nextCursor)), L((ae == null ? void 0 : ae.nextCursor) ?? null), Le.current = `${ie}:latest`, Ue.current = null, Ze.current = null;
4037
4037
  },
4038
- [K, oe, se, N]
4039
- ), Ge = ke((V) => {
4040
- console.log("[ChatSessionProvider] 🎯 Received thread_info:", V.threadId), et(V), q.current !== V.threadId && (Ue.current = V.threadId, Ze.current = V.threadId, console.log("[ChatSessionProvider] thread_info: marking to skip auto-load for new thread"), x(V.threadId));
4038
+ [q, oe, se, N]
4039
+ ), Ge = ke((W) => {
4040
+ console.log("[ChatSessionProvider] 🎯 Received thread_info:", W.threadId), et(W), K.current !== W.threadId && ((W.created ?? !K.current) && (Ue.current = W.threadId), Ze.current = W.threadId, console.log("[ChatSessionProvider] thread_info: marking to skip auto-load for new thread"), x(W.threadId));
4041
4041
  }, [et]), { startStream: qe, stop: Qe, isStreaming: St, error: mt, setAuthToken: gt } = Vx({
4042
4042
  baseUrl: f,
4043
4043
  onThreadInfo: Ge,
4044
4044
  onMessageEvent: P,
4045
4045
  onStateHistory: We,
4046
- onUnhandledEvent: (V) => {
4047
- console.warn("[ChatSessionProvider] Unhandled event:", V.type);
4046
+ onUnhandledEvent: (W) => {
4047
+ console.warn("[ChatSessionProvider] Unhandled event:", W.type);
4048
4048
  },
4049
4049
  onAuthError: i
4050
4050
  }), ft = ke(
4051
- async (V) => {
4051
+ async (W) => {
4052
4052
  try {
4053
- const ie = await c.createThread(V);
4053
+ const ie = await c.createThread(W);
4054
4054
  return x(ie.threadId), await Pe(), ie.threadId;
4055
4055
  } catch (ie) {
4056
4056
  return s == null || s(String(ie)), null;
@@ -4058,39 +4058,39 @@ function qx({
4058
4058
  },
4059
4059
  [c, Pe, s]
4060
4060
  ), it = ke(
4061
- async (V) => {
4061
+ async (W) => {
4062
4062
  try {
4063
- await c.deleteThread(V), q.current === V && (x(null), N([], {})), await Pe();
4063
+ await c.deleteThread(W), K.current === W && (x(null), N([], {})), await Pe();
4064
4064
  } catch (ie) {
4065
4065
  s == null || s(String(ie));
4066
4066
  }
4067
4067
  },
4068
4068
  [c, Pe, N, s]
4069
4069
  ), Ve = ke(
4070
- async (V, ie) => {
4070
+ async (W, ie) => {
4071
4071
  try {
4072
- await c.updateThread(V, ie), await Pe();
4072
+ await c.updateThread(W, ie), await Pe();
4073
4073
  } catch (ee) {
4074
4074
  s == null || s(String(ee));
4075
4075
  }
4076
4076
  },
4077
4077
  [c, Pe, s]
4078
4078
  ), jt = ke(
4079
- async (V, ie) => {
4080
- if (!V) return;
4081
- const ee = `${V}:${ie ?? "latest"}`, Se = Fe.current.get(ee);
4079
+ async (W, ie) => {
4080
+ if (!W) return;
4081
+ const ee = `${W}:${ie ?? "latest"}`, Se = Fe.current.get(ee);
4082
4082
  if (Se)
4083
4083
  return Se;
4084
4084
  const ae = (async () => {
4085
- const Te = V;
4085
+ const Te = W;
4086
4086
  C(!0), k(null);
4087
4087
  try {
4088
4088
  const Ut = await c.getStateHistory({
4089
4089
  threadId: Te,
4090
4090
  checkpointId: ie || void 0
4091
4091
  });
4092
- if (q.current !== Te) {
4093
- console.log(`[ChatSessionProvider] Thread changed during load (was ${Te}, now ${q.current}), discarding stale data`);
4092
+ if (K.current !== Te) {
4093
+ console.log(`[ChatSessionProvider] Thread changed during load (was ${Te}, now ${K.current}), discarding stale data`);
4094
4094
  return;
4095
4095
  }
4096
4096
  const { checkpoints: Tt, timeline: cn } = hr(Ut);
@@ -4101,7 +4101,7 @@ function qx({
4101
4101
  checkpointNs: (kt == null ? void 0 : kt.checkpointNs) ?? null
4102
4102
  }), pe(cn), J(Tt), I(!!(kt != null && kt.nextCursor)), L((kt == null ? void 0 : kt.nextCursor) ?? null);
4103
4103
  } catch (Ut) {
4104
- if (q.current === Te) {
4104
+ if (K.current === Te) {
4105
4105
  const Tt = String(Ut);
4106
4106
  k(Tt), s == null || s(Tt);
4107
4107
  }
@@ -4115,16 +4115,16 @@ function qx({
4115
4115
  } finally {
4116
4116
  Fe.current.delete(ee);
4117
4117
  }
4118
- return q.current === V && (Le.current = ee), ae;
4118
+ return K.current === W && (Le.current = ee), ae;
4119
4119
  },
4120
4120
  [c, N, s, se]
4121
4121
  ), Ct = ke(
4122
- async (V, ie) => {
4123
- re.current = V;
4122
+ async (W, ie) => {
4123
+ re.current = W;
4124
4124
  try {
4125
- await jt(V, ie);
4125
+ await jt(W, ie);
4126
4126
  } finally {
4127
- re.current === V && (re.current = null);
4127
+ re.current === W && (re.current = null);
4128
4128
  }
4129
4129
  },
4130
4130
  [jt]
@@ -4147,9 +4147,9 @@ function qx({
4147
4147
  if (Me.current === m)
4148
4148
  return;
4149
4149
  Me.current = m;
4150
- const V = !me.current && !!n && m === t;
4150
+ const W = !me.current && !!n && m === t;
4151
4151
  let ie;
4152
- V && n ? (ie = n, me.current = !0, console.log(
4152
+ W && n ? (ie = n, me.current = !0, console.log(
4153
4153
  "[ChatSessionProvider] Loading thread with checkpoint:",
4154
4154
  ie,
4155
4155
  r ? `(ns: ${r})` : ""
@@ -4167,28 +4167,28 @@ function qx({
4167
4167
  Ct
4168
4168
  ]);
4169
4169
  const Zt = ke(
4170
- async (V, ie) => {
4171
- const ee = q.current;
4170
+ async (W, ie) => {
4171
+ const ee = K.current;
4172
4172
  if (!ee) return;
4173
4173
  const Se = ee;
4174
4174
  Ae(!0);
4175
4175
  try {
4176
4176
  const ae = await c.getStateHistory({
4177
4177
  threadId: Se,
4178
- checkpointId: V,
4178
+ checkpointId: W,
4179
4179
  checkpointNs: ie ?? void 0
4180
4180
  });
4181
- if (q.current !== Se) {
4182
- console.log(`[ChatSessionProvider] Thread changed during checkpoint navigation (was ${Se}, now ${q.current}), discarding stale data`);
4181
+ if (K.current !== Se) {
4182
+ console.log(`[ChatSessionProvider] Thread changed during checkpoint navigation (was ${Se}, now ${K.current}), discarding stale data`);
4183
4183
  return;
4184
4184
  }
4185
4185
  const { checkpoints: Te, timeline: Ut } = hr(ae);
4186
4186
  se(Se, Te, "checkpoint navigation");
4187
4187
  const Tt = Te.find(
4188
- (cn) => cn.checkpointId === V && (ie ? cn.checkpointNs === ie : !0)
4188
+ (cn) => cn.checkpointId === W && (ie ? cn.checkpointNs === ie : !0)
4189
4189
  );
4190
4190
  if (!Tt) {
4191
- console.warn("[ChatSessionProvider] Requested checkpoint not found:", { checkpointId: V, checkpointNs: ie });
4191
+ console.warn("[ChatSessionProvider] Requested checkpoint not found:", { checkpointId: W, checkpointNs: ie });
4192
4192
  return;
4193
4193
  }
4194
4194
  pe(Ut), J(Te), N(Tt.messages ?? [], {
@@ -4196,33 +4196,33 @@ function qx({
4196
4196
  checkpointNs: Tt.checkpointNs ?? null
4197
4197
  });
4198
4198
  } catch (ae) {
4199
- q.current === Se && (s == null || s(String(ae)));
4199
+ K.current === Se && (s == null || s(String(ae)));
4200
4200
  } finally {
4201
4201
  Ae(!1);
4202
4202
  }
4203
4203
  },
4204
4204
  [c, N, s, se]
4205
4205
  ), ln = ke(
4206
- (V, ie) => {
4206
+ (W, ie) => {
4207
4207
  N(E.messages, {
4208
- checkpointId: V ?? null,
4208
+ checkpointId: W ?? null,
4209
4209
  checkpointNs: ie ?? null
4210
4210
  });
4211
4211
  },
4212
4212
  [N, E.messages]
4213
4213
  ), Ye = ke(async () => {
4214
- q.current && await Ct(q.current);
4214
+ K.current && await Ct(K.current);
4215
4215
  }, [Ct]), _e = ke(async () => {
4216
- if (!q.current || !X) return;
4217
- const V = q.current;
4216
+ if (!K.current || !X) return;
4217
+ const W = K.current;
4218
4218
  A(!0);
4219
4219
  try {
4220
4220
  const ie = await c.getStateHistory({
4221
- threadId: V,
4221
+ threadId: W,
4222
4222
  checkpointId: X
4223
4223
  });
4224
- if (q.current !== V) {
4225
- console.log(`[ChatSessionProvider] Thread changed during history load (was ${V}, now ${q.current}), discarding stale data`);
4224
+ if (K.current !== W) {
4225
+ console.log(`[ChatSessionProvider] Thread changed during history load (was ${W}, now ${K.current}), discarding stale data`);
4226
4226
  return;
4227
4227
  }
4228
4228
  const { checkpoints: ee } = hr(ie);
@@ -4231,7 +4231,7 @@ function qx({
4231
4231
  M((Se == null ? void 0 : Se.messages) ?? []), I(!!(Se != null && Se.nextCursor)), L((Se == null ? void 0 : Se.nextCursor) ?? null);
4232
4232
  }
4233
4233
  } catch (ie) {
4234
- q.current === V && (s == null || s(String(ie)));
4234
+ K.current === W && (s == null || s(String(ie)));
4235
4235
  } finally {
4236
4236
  A(!1);
4237
4237
  }
@@ -4239,12 +4239,12 @@ function qx({
4239
4239
  N([], {}), x(null), Qe(), J([]), pe([]), I(!1), L(null), C(!1), Ae(!1), A(!1), k(null);
4240
4240
  try {
4241
4241
  await c.getAgent("default");
4242
- } catch (V) {
4243
- console.warn("[ChatSessionProvider] Failed to refetch agent after clearing thread:", V);
4242
+ } catch (W) {
4243
+ console.warn("[ChatSessionProvider] Failed to refetch agent after clearing thread:", W);
4244
4244
  }
4245
4245
  }, [N, Qe, c]), zt = ke(
4246
- async (V, ie, ee) => {
4247
- const Se = q.current;
4246
+ async (W, ie, ee) => {
4247
+ const Se = K.current;
4248
4248
  if (!Se)
4249
4249
  throw new Error("No active thread to handle interrupt");
4250
4250
  const ae = ie ? ee ?? !0 : !1;
@@ -4258,7 +4258,7 @@ function qx({
4258
4258
  };
4259
4259
  qe(Te);
4260
4260
  } catch (Te) {
4261
- throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${V}:`, Te), Te;
4261
+ throw console.error(`[ChatSessionProvider] Failed to handle interrupt ${W}:`, Te), Te;
4262
4262
  }
4263
4263
  },
4264
4264
  [E.lastCheckpointId, E.lastCheckpointNs, qe]
@@ -4269,9 +4269,9 @@ function qx({
4269
4269
  a == null || a(m);
4270
4270
  }, [m, a]);
4271
4271
  const B = ke(
4272
- async (V, ie) => {
4273
- let ee = q.current;
4274
- const Se = (V == null ? void 0 : V.text) ?? "";
4272
+ async (W, ie) => {
4273
+ let ee = K.current;
4274
+ const Se = (W == null ? void 0 : W.text) ?? "";
4275
4275
  if (!ee && !Se) return;
4276
4276
  if (!ee && Se) {
4277
4277
  const cn = Math.floor(Date.now() / 1e3).toString(16).padStart(8, "0"), kt = Array.from(
@@ -4282,7 +4282,7 @@ function qx({
4282
4282
  }
4283
4283
  const { contentParts: ae } = await dx(
4284
4284
  c,
4285
- (V == null ? void 0 : V.attachments) ?? []
4285
+ (W == null ? void 0 : W.attachments) ?? []
4286
4286
  ), Te = [...ae];
4287
4287
  Se != null && Se.trim() && Te.push({ type: "text", text: Se });
4288
4288
  const Ut = {
@@ -6455,7 +6455,7 @@ var qu = "PopperAnchor", Gu = v.forwardRef(
6455
6455
  Gu.displayName = qu;
6456
6456
  var Ca = "PopperContent", [Mv, Dv] = Wu(Ca), Yu = v.forwardRef(
6457
6457
  (e, t) => {
6458
- var Y, D, H, ne, se, q;
6458
+ var Y, D, H, ne, se, K;
6459
6459
  const {
6460
6460
  __scopePopper: n,
6461
6461
  side: r = "bottom",
@@ -6510,7 +6510,7 @@ var Ca = "PopperContent", [Mv, Dv] = Wu(Ca), Yu = v.forwardRef(
6510
6510
  Mt(() => {
6511
6511
  X && (G == null || G());
6512
6512
  }, [X, G]);
6513
- const pe = (Y = L.arrow) == null ? void 0 : Y.x, Re = (D = L.arrow) == null ? void 0 : D.y, Ae = ((H = L.arrow) == null ? void 0 : H.centerOffset) !== 0, [K, oe] = v.useState();
6513
+ const pe = (Y = L.arrow) == null ? void 0 : Y.x, Re = (D = L.arrow) == null ? void 0 : D.y, Ae = ((H = L.arrow) == null ? void 0 : H.centerOffset) !== 0, [q, oe] = v.useState();
6514
6514
  return Mt(() => {
6515
6515
  g && oe(window.getComputedStyle(g).zIndex);
6516
6516
  }, [g]), /* @__PURE__ */ u.jsx(
@@ -6523,7 +6523,7 @@ var Ca = "PopperContent", [Mv, Dv] = Wu(Ca), Yu = v.forwardRef(
6523
6523
  transform: X ? F.transform : "translate(0, -200%)",
6524
6524
  // keep off the page when measuring
6525
6525
  minWidth: "max-content",
6526
- zIndex: K,
6526
+ zIndex: q,
6527
6527
  "--radix-popper-transform-origin": [
6528
6528
  (ne = L.transformOrigin) == null ? void 0 : ne.x,
6529
6529
  (se = L.transformOrigin) == null ? void 0 : se.y
@@ -6531,7 +6531,7 @@ var Ca = "PopperContent", [Mv, Dv] = Wu(Ca), Yu = v.forwardRef(
6531
6531
  // hide the content if using the hide middleware and should be hidden
6532
6532
  // set visibility to hidden and disable pointer events so the UI behaves
6533
6533
  // as if the PopperContent isn't there at all
6534
- ...((q = L.hide) == null ? void 0 : q.referenceHidden) && {
6534
+ ...((K = L.hide) == null ? void 0 : K.referenceHidden) && {
6535
6535
  visibility: "hidden",
6536
6536
  pointerEvents: "none"
6537
6537
  }
@@ -7509,7 +7509,7 @@ var rn = "MenuContent", [Jw, Ea] = ir(rn), Cd = v.forwardRef(
7509
7509
  ...x
7510
7510
  } = e, y = ar(rn, n), g = mo(rn, n), w = Os(n), b = vd(n), T = Vw(n), [C, S] = v.useState(null), k = v.useRef(null), E = Je(t, k, y.onContentChange), N = v.useRef(0), M = v.useRef(""), j = v.useRef(0), P = v.useRef(null), $ = v.useRef("right"), I = v.useRef(0), F = m ? Ps : v.Fragment, A = m ? { as: eb, allowPinchZoom: !0 } : void 0, X = (_) => {
7511
7511
  var Y, D;
7512
- const J = M.current + _, G = T().filter((H) => !H.disabled), pe = document.activeElement, Re = (Y = G.find((H) => H.ref.current === pe)) == null ? void 0 : Y.textValue, Ae = G.map((H) => H.textValue), K = fb(Ae, J, Re), oe = (D = G.find((H) => H.textValue === K)) == null ? void 0 : D.ref.current;
7512
+ const J = M.current + _, G = T().filter((H) => !H.disabled), pe = document.activeElement, Re = (Y = G.find((H) => H.ref.current === pe)) == null ? void 0 : Y.textValue, Ae = G.map((H) => H.textValue), q = fb(Ae, J, Re), oe = (D = G.find((H) => H.textValue === q)) == null ? void 0 : D.ref.current;
7513
7513
  (function H(ne) {
7514
7514
  M.current = ne, window.clearTimeout(N.current), ne !== "" && (N.current = window.setTimeout(() => H(""), 1e3));
7515
7515
  })(J), oe && setTimeout(() => oe.focus());
@@ -9786,12 +9786,12 @@ const cr = nt(
9786
9786
  );
9787
9787
  const J = [];
9788
9788
  if (P.length > 0) {
9789
- const K = P[0], oe = P[P.length - 1];
9789
+ const q = P[0], oe = P[P.length - 1];
9790
9790
  let Y = 0;
9791
- for (const D of Fs(L, K, oe)) {
9792
- const H = D.value, ne = Math.max(D.start, K), se = Math.min(D.end, oe);
9793
- for (let q = ne; q <= se; q++)
9794
- J.push({ data: F == null ? void 0 : F[q], index: q, offset: Y, size: H }), Y += H;
9791
+ for (const D of Fs(L, q, oe)) {
9792
+ const H = D.value, ne = Math.max(D.start, q), se = Math.min(D.end, oe);
9793
+ for (let K = ne; K <= se; K++)
9794
+ J.push({ data: F == null ? void 0 : F[K], index: K, offset: Y, size: H }), Y += H;
9795
9795
  }
9796
9796
  }
9797
9797
  if (!j)
@@ -9799,20 +9799,20 @@ const cr = nt(
9799
9799
  const G = P.length > 0 ? P[P.length - 1] + 1 : 0, pe = k0(X, S, k, G);
9800
9800
  if (pe.length === 0)
9801
9801
  return null;
9802
- const Re = E - 1, Ae = $s([], (K) => {
9802
+ const Re = E - 1, Ae = $s([], (q) => {
9803
9803
  for (const oe of pe) {
9804
9804
  const Y = oe.value;
9805
9805
  let D = Y.offset, H = oe.start;
9806
9806
  const ne = Y.size;
9807
9807
  if (Y.offset < S) {
9808
9808
  H += Math.floor((S - Y.offset + I) / (ne + I));
9809
- const q = H - oe.start;
9810
- D += q * ne + q * I;
9809
+ const K = H - oe.start;
9810
+ D += K * ne + K * I;
9811
9811
  }
9812
9812
  H < G && (D += (G - H) * ne, H = G);
9813
9813
  const se = Math.min(oe.end, Re);
9814
- for (let q = H; q <= se && !(D >= k); q++)
9815
- K.push({ data: F == null ? void 0 : F[q], index: q, offset: D, size: ne }), D += ne + I;
9814
+ for (let K = H; K <= se && !(D >= k); K++)
9815
+ q.push({ data: F == null ? void 0 : F[K], index: K, offset: D, size: ne }), D += ne + I;
9816
9816
  }
9817
9817
  });
9818
9818
  return Uo(Ae, J, E, I, A, $);
@@ -10990,7 +10990,7 @@ const bS = /* @__PURE__ */ nt(
10990
10990
  ), st(
10991
10991
  U(
10992
10992
  Nt(m, J, M, N, _, G),
10993
- Ne(([D, H, ne, se, , q]) => D && !H && ne.height !== 0 && se.height !== 0 && !q)
10993
+ Ne(([D, H, ne, se, , K]) => D && !H && ne.height !== 0 && se.height !== 0 && !K)
10994
10994
  ),
10995
10995
  ([, , , , D]) => {
10996
10996
  $e(G, !0), La(1, () => {
@@ -11059,7 +11059,7 @@ const bS = /* @__PURE__ */ nt(
11059
11059
  D,
11060
11060
  [H, ne],
11061
11061
  se,
11062
- q,
11062
+ K,
11063
11063
  Me,
11064
11064
  Ue,
11065
11065
  Ze,
@@ -11067,7 +11067,7 @@ const bS = /* @__PURE__ */ nt(
11067
11067
  re,
11068
11068
  me
11069
11069
  ]) => {
11070
- const { column: Le, row: Fe } = se, { height: Pe, width: et } = q, { width: We } = Me;
11070
+ const { column: Le, row: Fe } = se, { height: Pe, width: et } = K, { width: We } = Me;
11071
11071
  if (Ze === 0 && (D === 0 || We === 0))
11072
11072
  return vc;
11073
11073
  if (et === 0) {
@@ -11077,7 +11077,7 @@ const bS = /* @__PURE__ */ nt(
11077
11077
  const Ge = Uf(We, et, Le);
11078
11078
  let qe, Qe;
11079
11079
  re ? H === 0 && ne === 0 && Ze > 0 ? (qe = 0, Qe = Ze - 1) : (qe = Ge * os((H + Fe) / (Pe + Fe)), Qe = Ge * wc((ne + Fe) / (Pe + Fe)) - 1, Qe = bi(D - 1, Ur(Qe, Ge - 1)), qe = bi(Qe, Ur(0, qe))) : (qe = 0, Qe = -1);
11080
- const St = Sc(qe, Qe, Ue), { bottom: mt, top: gt } = Cc(Me, se, q, St), ft = wc(D / Ge), it = ft * Pe + (ft - 1) * Fe - mt;
11080
+ const St = Sc(qe, Qe, Ue), { bottom: mt, top: gt } = Cc(Me, se, K, St), ft = wc(D / Ge), it = ft * Pe + (ft - 1) * Fe - mt;
11081
11081
  return { bottom: mt, itemHeight: Pe, items: St, itemWidth: et, offsetBottom: it, offsetTop: gt, top: gt };
11082
11082
  }
11083
11083
  )
@@ -11095,8 +11095,8 @@ const bS = /* @__PURE__ */ nt(
11095
11095
  Nt(N, M, E, F),
11096
11096
  Ne(([D, H, { items: ne }]) => ne.length > 0 && H.height !== 0 && D.height !== 0),
11097
11097
  ce(([D, H, { items: ne }, se]) => {
11098
- const { bottom: q, top: Me } = Cc(D, se, H, ne);
11099
- return [Me, q];
11098
+ const { bottom: K, top: Me } = Cc(D, se, H, ne);
11099
+ return [Me, K];
11100
11100
  }),
11101
11101
  pt(to)
11102
11102
  ),
@@ -11123,7 +11123,7 @@ const bS = /* @__PURE__ */ nt(
11123
11123
  ce(([[, D]]) => D - 1),
11124
11124
  pt()
11125
11125
  )
11126
- ), K = Jt(
11126
+ ), q = Jt(
11127
11127
  U(
11128
11128
  Ie(E),
11129
11129
  Ne(({ items: D }) => D.length > 0 && D[0].index === 0),
@@ -11147,11 +11147,11 @@ const bS = /* @__PURE__ */ nt(
11147
11147
  U(
11148
11148
  j,
11149
11149
  ze(N, M, S, F),
11150
- ce(([D, H, ne, se, q]) => {
11150
+ ce(([D, H, ne, se, K]) => {
11151
11151
  const Me = Rf(D), { align: Ue, behavior: Ze, offset: re } = Me;
11152
11152
  let me = Me.index;
11153
11153
  me === "LAST" && (me = se - 1), me = Ur(0, me, bi(se - 1, me));
11154
- let Le = Gi(H, q, ne, me);
11154
+ let Le = Gi(H, K, ne, me);
11155
11155
  return Ue === "end" ? Le = bc(Le - H.height + ne.height) : Ue === "center" && (Le = bc(Le - H.height / 2 + ne.height / 2)), re && (Le += re), { behavior: Ze, top: Le };
11156
11156
  })
11157
11157
  ),
@@ -11206,7 +11206,7 @@ const bS = /* @__PURE__ */ nt(
11206
11206
  endReached: Ae,
11207
11207
  propsReady: x,
11208
11208
  rangeChanged: oe,
11209
- startReached: K,
11209
+ startReached: q,
11210
11210
  stateChanged: A,
11211
11211
  stateRestoreInProgress: L,
11212
11212
  ...C
@@ -13825,7 +13825,7 @@ const Oc = z.memo(function({
13825
13825
  }) {
13826
13826
  const [M, j] = we(!1), [P, $] = we("preview"), [I, F] = we(!1), { currentThreadId: A } = da(), { respondToInterrupt: X } = fa(), L = l === "phone" || l === "half-screen", _ = t.role, J = _ === "tool", G = rt(() => "type" in t && t.type === "default_message" ? t : null, [t]), pe = !!G, Re = !(r && _ !== "user"), {
13827
13827
  uploadingFiles: Ae,
13828
- handleFileClick: K,
13828
+ handleFileClick: q,
13829
13829
  fileViewerOpen: oe,
13830
13830
  currentFileInfo: Y,
13831
13831
  closeFileViewer: D
@@ -13842,7 +13842,7 @@ const Oc = z.memo(function({
13842
13842
  default:
13843
13843
  return "text-[hsl(var(--chat-bubble-ai-text))]";
13844
13844
  }
13845
- }, [_]), ne = rt(() => G ? "" : wC(t.content), [G, t]), se = rt(() => G ? {} : Rp(t), [G, t]), q = rt(
13845
+ }, [_]), ne = rt(() => G ? "" : wC(t.content), [G, t]), se = rt(() => G ? {} : Rp(t), [G, t]), K = rt(
13846
13846
  () => G ? [] : t.content.filter((B) => B.type === "image_url"),
13847
13847
  [G, t]
13848
13848
  ), Me = rt(
@@ -13997,8 +13997,8 @@ const Oc = z.memo(function({
13997
13997
  }
13998
13998
  }, [w, T, b, X]), mt = z.useCallback(({ part: B, i: ye }) => {
13999
13999
  if (B.type === "text") {
14000
- const ve = B.text ?? "", at = ve.trim(), V = Va(at);
14001
- return V && _ !== "tool" ? /* @__PURE__ */ u.jsx(Ep, { data: V }, ye) : _ === "user" && c && at.length > d ? /* @__PURE__ */ u.jsx(
14000
+ const ve = B.text ?? "", at = ve.trim(), W = Va(at);
14001
+ return W && _ !== "tool" ? /* @__PURE__ */ u.jsx(Ep, { data: W }, ye) : _ === "user" && c && at.length > d ? /* @__PURE__ */ u.jsx(
14002
14002
  RC,
14003
14003
  {
14004
14004
  text: at,
@@ -14028,7 +14028,7 @@ const Oc = z.memo(function({
14028
14028
  "a",
14029
14029
  {
14030
14030
  href: ve.url,
14031
- onClick: (V) => K(V, ve, ye),
14031
+ onClick: (W) => q(W, ve, ye),
14032
14032
  className: `inline-flex items-center gap-2 rounded px-2 py-1 text-xs bg-gray-100 border hover:bg-gray-200
14033
14033
  dark:bg-background/10 dark:border-border/30 dark:hover:bg-background/20`,
14034
14034
  children: [
@@ -14045,7 +14045,7 @@ const Oc = z.memo(function({
14045
14045
  if (B.type === "interrupt") {
14046
14046
  const ve = B, at = jo(
14047
14047
  (ve == null ? void 0 : ve.id) ?? (ve == null ? void 0 : ve.interrupt_id)
14048
- ), V = !!(re && at && at === re), ie = V ? me ?? (ve == null ? void 0 : ve.value) : ve == null ? void 0 : ve.value, ee = at ? { ...ve, id: at, interrupt_id: at } : ve;
14048
+ ), W = !!(re && at && at === re), ie = W ? me ?? (ve == null ? void 0 : ve.value) : ve == null ? void 0 : ve.value, ee = at ? { ...ve, id: at, interrupt_id: at } : ve;
14049
14049
  return /* @__PURE__ */ u.jsx(
14050
14050
  TC,
14051
14051
  {
@@ -14053,7 +14053,7 @@ const Oc = z.memo(function({
14053
14053
  onApprove: Qe,
14054
14054
  onReject: St,
14055
14055
  disabled: w,
14056
- isActive: V,
14056
+ isActive: W,
14057
14057
  payload: ie
14058
14058
  },
14059
14059
  ye
@@ -14061,7 +14061,7 @@ const Oc = z.memo(function({
14061
14061
  }
14062
14062
  return null;
14063
14063
  }, [
14064
- K,
14064
+ q,
14065
14065
  Ae,
14066
14066
  Qe,
14067
14067
  St,
@@ -14079,7 +14079,7 @@ const Oc = z.memo(function({
14079
14079
  /* @__PURE__ */ u.jsx(ki, { className: "h-4 w-4 text-muted-foreground" }),
14080
14080
  /* @__PURE__ */ u.jsx("span", { className: "text-sm text-muted-foreground", children: "File upload" })
14081
14081
  ] }), []), ft = z.useCallback(() => {
14082
- const B = ne.trim().length > 0 || q.length > 0 || Me.length > 0 || Ue.length > 0;
14082
+ const B = ne.trim().length > 0 || K.length > 0 || Me.length > 0 || Ue.length > 0;
14083
14083
  if (!J && Me.length > 0 && !r)
14084
14084
  return gt();
14085
14085
  if (!J && !B && !r)
@@ -14094,7 +14094,7 @@ const Oc = z.memo(function({
14094
14094
  t.id
14095
14095
  );
14096
14096
  if (!J && !G) {
14097
- const ye = t, ve = /* @__PURE__ */ u.jsx("div", { className: "space-y-2", children: ye.content.map((at, V) => /* @__PURE__ */ u.jsx(mt, { part: at, i: V }, V)) });
14097
+ const ye = t, ve = /* @__PURE__ */ u.jsx("div", { className: "space-y-2", children: ye.content.map((at, W) => /* @__PURE__ */ u.jsx(mt, { part: at, i: W }, W)) });
14098
14098
  return r ? /* @__PURE__ */ u.jsxs("div", { "aria-busy": "true", role: "status", children: [
14099
14099
  ve,
14100
14100
  /* @__PURE__ */ u.jsx(CC, { className: H })
@@ -14102,7 +14102,7 @@ const Oc = z.memo(function({
14102
14102
  }
14103
14103
  }, [
14104
14104
  ne,
14105
- q.length,
14105
+ K.length,
14106
14106
  Me.length,
14107
14107
  Ue.length,
14108
14108
  r,
@@ -14721,7 +14721,7 @@ const IC = ({
14721
14721
  content: [],
14722
14722
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
14723
14723
  }
14724
- ] : pe, [pe, t, $]), Ae = rt(() => S ? Re : Re.filter((re) => (re == null ? void 0 : re.role) !== "tool"), [Re, S]), K = rt(() => {
14724
+ ] : pe, [pe, t, $]), Ae = rt(() => S ? Re : Re.filter((re) => (re == null ? void 0 : re.role) !== "tool"), [Re, S]), q = rt(() => {
14725
14725
  const re = /* @__PURE__ */ new Set(), me = [];
14726
14726
  for (let Le = Ae.length - 1; Le >= 0; Le--) {
14727
14727
  const Fe = Ae[Le];
@@ -14758,7 +14758,7 @@ const IC = ({
14758
14758
  content: re,
14759
14759
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
14760
14760
  } : null;
14761
- }, [h]), q = ne ? /* @__PURE__ */ u.jsx(
14761
+ }, [h]), K = ne ? /* @__PURE__ */ u.jsx(
14762
14762
  IC,
14763
14763
  {
14764
14764
  timelineEntries: H,
@@ -14783,14 +14783,14 @@ const IC = ({
14783
14783
  onCancelEdit: () => {
14784
14784
  }
14785
14785
  }
14786
- ) }) }) : /* @__PURE__ */ u.jsx("div", { className: "flex h-full items-center justify-center py-8 text-center text-muted-foreground", children: h ?? "No messages yet. Start a conversation!" }), Ze = K.length > 0;
14786
+ ) }) }) : /* @__PURE__ */ u.jsx("div", { className: "flex h-full items-center justify-center py-8 text-center text-muted-foreground", children: h ?? "No messages yet. Start a conversation!" }), Ze = q.length > 0;
14787
14787
  return Qh(
14788
14788
  I,
14789
14789
  () => ({
14790
14790
  scrollToLatest: () => {
14791
14791
  var re, me;
14792
- if (F.current && K.length > 0) {
14793
- const Le = K.length - 1;
14792
+ if (F.current && q.length > 0) {
14793
+ const Le = q.length - 1;
14794
14794
  (me = (re = F.current).scrollToIndex) == null || me.call(re, {
14795
14795
  index: Le,
14796
14796
  align: "end",
@@ -14800,16 +14800,16 @@ const IC = ({
14800
14800
  },
14801
14801
  scrollToTop: () => {
14802
14802
  var re, me;
14803
- F.current && K.length > 0 ? (me = (re = F.current).scrollToIndex) == null || me.call(re, {
14803
+ F.current && q.length > 0 ? (me = (re = F.current).scrollToIndex) == null || me.call(re, {
14804
14804
  index: 0,
14805
14805
  align: "start",
14806
14806
  behavior: "auto"
14807
14807
  }) : A.current && (A.current.scrollTop = 0);
14808
14808
  }
14809
14809
  }),
14810
- [K]
14810
+ [q]
14811
14811
  ), /* @__PURE__ */ u.jsxs("div", { className: Me, style: p, children: [
14812
- q,
14812
+ K,
14813
14813
  /* @__PURE__ */ u.jsx("div", { className: "relative flex-1 min-h-0", children: Ze ? /* @__PURE__ */ u.jsx(
14814
14814
  gS,
14815
14815
  {
@@ -14819,7 +14819,7 @@ const IC = ({
14819
14819
  scrollerRef: (re) => {
14820
14820
  A.current = re instanceof HTMLDivElement ? re : null;
14821
14821
  },
14822
- data: K,
14822
+ data: q,
14823
14823
  followOutput: D,
14824
14824
  overscan: 200,
14825
14825
  increaseViewportBy: { top: 100, bottom: 200 },
@@ -14933,11 +14933,11 @@ function Ti({
14933
14933
  Et(() => {
14934
14934
  pe || Ae(!1);
14935
14935
  }, [pe]);
14936
- const K = ke(() => {
14936
+ const q = ke(() => {
14937
14937
  Ae(!0);
14938
14938
  }, []), oe = ke(() => {
14939
14939
  Ae(!1);
14940
- }, []), Y = !!pe || Re, [D, H] = we(null), [ne, se] = we(""), [q, Me] = we(null), [Ue, Ze] = we(null), [re, me] = we([]), [Le, Fe] = we(0), [Pe, et] = we(0), [We, Ge] = we(!1), [qe, Qe] = we(null), [St, mt] = we(null), [gt, ft] = we(!1), [it, Ve] = we(null), jt = He(!1), [Ct, Zt] = we(() => Dc.value), ln = He(Ct), Ye = He(null), _e = ke((Q) => {
14940
+ }, []), Y = !!pe || Re, [D, H] = we(null), [ne, se] = we(""), [K, Me] = we(null), [Ue, Ze] = we(null), [re, me] = we([]), [Le, Fe] = we(0), [Pe, et] = we(0), [We, Ge] = we(!1), [qe, Qe] = we(null), [St, mt] = we(null), [gt, ft] = we(!1), [it, Ve] = we(null), jt = He(!1), [Ct, Zt] = we(() => Dc.value), ln = He(Ct), Ye = He(null), _e = ke((Q) => {
14941
14941
  Dc.value = Q, Zt(Q);
14942
14942
  }, []), [_t, zt] = we(!1), B = He(null), ye = ke(
14943
14943
  (Q, de) => {
@@ -14985,7 +14985,7 @@ function Ti({
14985
14985
  const Pr = Date.parse(be.createdAt ?? ""), Or = Date.parse(ct.createdAt ?? "");
14986
14986
  return Number.isNaN(Pr) || Number.isNaN(Or) ? 0 : Or - Pr;
14987
14987
  }), de;
14988
- }, [E, ye]), { checkpointMetaById: V, checkpointIndexByKey: ie } = rt(() => {
14988
+ }, [E, ye]), { checkpointMetaById: W, checkpointIndexByKey: ie } = rt(() => {
14989
14989
  const Q = /* @__PURE__ */ new Map(), de = /* @__PURE__ */ new Map();
14990
14990
  for (const fe of at) {
14991
14991
  const be = fe.checkpointId ?? null;
@@ -15075,8 +15075,8 @@ function Ti({
15075
15075
  const fe = _ ?? void 0, be = J ?? void 0, ct = D ? {
15076
15076
  edit: !0,
15077
15077
  originalMessageId: D,
15078
- ...q != null && q.checkpointId ? { originalCheckpointId: q.checkpointId } : {},
15079
- ...q != null && q.checkpointNs ? { originalCheckpointNs: q.checkpointNs } : {}
15078
+ ...K != null && K.checkpointId ? { originalCheckpointId: K.checkpointId } : {},
15079
+ ...K != null && K.checkpointNs ? { originalCheckpointNs: K.checkpointNs } : {}
15080
15080
  } : void 0;
15081
15081
  await A(
15082
15082
  {
@@ -15104,7 +15104,7 @@ function Ti({
15104
15104
  [Ct, c, _e]
15105
15105
  ), R = z.useCallback(() => {
15106
15106
  H(null), se(""), Me(null), Ze(null), _e(Ye.current ?? Ct), Ye.current = null;
15107
- }, [Ct, _e]), W = ke(
15107
+ }, [Ct, _e]), V = ke(
15108
15108
  (Q, de, fe) => {
15109
15109
  vo(Q, de, fe);
15110
15110
  },
@@ -15228,17 +15228,17 @@ function Ti({
15228
15228
  layoutSize: cn,
15229
15229
  enableMessageEditing: c,
15230
15230
  editingMessageId: D,
15231
- onEdit: W,
15231
+ onEdit: V,
15232
15232
  onRegenerate: le,
15233
15233
  onCancelEdit: R,
15234
15234
  emptyMessage: it ?? void 0,
15235
15235
  isNavigatingCheckpoint: _t,
15236
15236
  activeInterrupt: pe,
15237
15237
  disableInterruptActions: Re,
15238
- onInterruptActionStart: K,
15238
+ onInterruptActionStart: q,
15239
15239
  onInterruptActionEnd: oe,
15240
15240
  showToolMessages: d,
15241
- checkpointMetaById: V,
15241
+ checkpointMetaById: W,
15242
15242
  checkpointIndexByKey: ie,
15243
15243
  activeCheckpointId: _,
15244
15244
  onSelectCheckpoint: Be,
@@ -15970,78 +15970,78 @@ function Fc({
15970
15970
  actions: x
15971
15971
  } = da(), { loadThread: y } = fa(), { createThread: g, deleteThread: w, renameThread: b } = x, [T, C] = we(Array.isArray(f) ? f : []), S = He(T.length > 0), k = He(null), E = He(0), [N, M] = we(null), [j, P] = we(""), [$, I] = we(!1);
15972
15972
  Et(() => {
15973
- const K = Array.isArray(f) ? f : [];
15974
- if (K.length > 0) {
15975
- S.current = !0, C(K);
15973
+ const q = Array.isArray(f) ? f : [];
15974
+ if (q.length > 0) {
15975
+ S.current = !0, C(q);
15976
15976
  return;
15977
15977
  }
15978
- m || (S.current = !1, C(K));
15978
+ m || (S.current = !1, C(q));
15979
15979
  }, [f, m]), Et(() => {
15980
15980
  if (!k.current) return;
15981
- const K = k.current.querySelector(
15981
+ const q = k.current.querySelector(
15982
15982
  "[data-radix-scroll-area-viewport]"
15983
15983
  );
15984
- if (!K) return;
15984
+ if (!q) return;
15985
15985
  let oe = null, Y = null;
15986
15986
  return oe = requestAnimationFrame(() => {
15987
15987
  Y = requestAnimationFrame(() => {
15988
- K.scrollTop = E.current;
15988
+ q.scrollTop = E.current;
15989
15989
  });
15990
15990
  }), () => {
15991
15991
  oe !== null && cancelAnimationFrame(oe), Y !== null && cancelAnimationFrame(Y);
15992
15992
  };
15993
15993
  }, [T]);
15994
- const F = async (K) => {
15994
+ const F = async (q) => {
15995
15995
  try {
15996
- h(K), await y(K), a == null || a(K), l == null || l(K);
15996
+ h(q), await y(q), a == null || a(q), l == null || l(q);
15997
15997
  } catch (oe) {
15998
15998
  console.error("Failed to select thread:", oe);
15999
15999
  }
16000
16000
  }, A = async () => {
16001
16001
  try {
16002
16002
  I(!0);
16003
- const K = await g();
16004
- K && (c == null || c(K), a == null || a(K));
16005
- } catch (K) {
16006
- console.error("Failed to create thread:", K);
16003
+ const q = await g();
16004
+ q && (c == null || c(q), a == null || a(q));
16005
+ } catch (q) {
16006
+ console.error("Failed to create thread:", q);
16007
16007
  } finally {
16008
16008
  I(!1);
16009
16009
  }
16010
- }, X = async (K, oe) => {
16010
+ }, X = async (q, oe) => {
16011
16011
  if (oe.stopPropagation(), !!confirm("Delete this thread?")) {
16012
16012
  if (k.current) {
16013
16013
  const Y = k.current.querySelector("[data-radix-scroll-area-viewport]");
16014
16014
  Y && (E.current = Y.scrollTop);
16015
16015
  }
16016
16016
  try {
16017
- await w(K), d == null || d(K);
16017
+ await w(q), d == null || d(q);
16018
16018
  } catch (Y) {
16019
16019
  console.error("Failed to delete thread:", Y);
16020
16020
  }
16021
16021
  }
16022
- }, L = (K, oe) => {
16023
- oe.stopPropagation(), M(K.threadId), P(K.title || `Thread ${K.threadId.slice(0, 8)}`);
16024
- }, _ = async (K) => {
16022
+ }, L = (q, oe) => {
16023
+ oe.stopPropagation(), M(q.threadId), P(q.title || `Thread ${q.threadId.slice(0, 8)}`);
16024
+ }, _ = async (q) => {
16025
16025
  if (j.trim())
16026
16026
  try {
16027
- await b(K, j.trim()), M(null), P("");
16027
+ await b(q, j.trim()), M(null), P("");
16028
16028
  } catch (oe) {
16029
16029
  console.error("Failed to update title:", oe);
16030
16030
  }
16031
16031
  }, J = () => {
16032
16032
  M(null), P("");
16033
- }, G = (K, oe) => {
16034
- K.key === "Enter" ? _(oe) : K.key === "Escape" && J();
16035
- }, pe = (K) => {
16036
- if (!K) return "";
16033
+ }, G = (q, oe) => {
16034
+ q.key === "Enter" ? _(oe) : q.key === "Escape" && J();
16035
+ }, pe = (q) => {
16036
+ if (!q) return "";
16037
16037
  try {
16038
- const oe = new Date(K), D = (/* @__PURE__ */ new Date()).getTime() - oe.getTime(), H = Math.floor(D / (1e3 * 60 * 60 * 24));
16038
+ const oe = new Date(q), D = (/* @__PURE__ */ new Date()).getTime() - oe.getTime(), H = Math.floor(D / (1e3 * 60 * 60 * 24));
16039
16039
  return H === 0 ? oe.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) : H === 1 ? "Yesterday" : H < 7 ? `${H} days ago` : oe.toLocaleDateString();
16040
16040
  } catch {
16041
16041
  return "";
16042
16042
  }
16043
- }, Re = (K) => K.title || `Thread ${K.threadId.slice(0, 8)}`, Ae = (K) => {
16044
- const oe = Re(K);
16043
+ }, Re = (q) => q.title || `Thread ${q.threadId.slice(0, 8)}`, Ae = (q) => {
16044
+ const oe = Re(q);
16045
16045
  return oe.length <= $c ? oe : `${oe.slice(0, $c)}...`;
16046
16046
  };
16047
16047
  return /* @__PURE__ */ u.jsxs("div", { className: `flex flex-col h-full ${e} ${s.container || ""}`, children: [
@@ -16069,32 +16069,32 @@ function Fc({
16069
16069
  ] }) : T.length === 0 ? /* @__PURE__ */ u.jsxs("div", { className: "text-center py-8 text-slate-400", children: [
16070
16070
  /* @__PURE__ */ u.jsx(pm, { className: "w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500" }),
16071
16071
  /* @__PURE__ */ u.jsx("p", { className: "text-sm text-slate-500", children: "No conversations yet" })
16072
- ] }) : T.slice().sort((K, oe) => new Date(oe.updatedAt || oe.createdAt || "").getTime() - new Date(K.updatedAt || K.createdAt || "").getTime()).map((K) => /* @__PURE__ */ u.jsxs(
16072
+ ] }) : T.slice().sort((q, oe) => new Date(oe.updatedAt || oe.createdAt || "").getTime() - new Date(q.updatedAt || q.createdAt || "").getTime()).map((q) => /* @__PURE__ */ u.jsxs(
16073
16073
  "div",
16074
16074
  {
16075
- onClick: () => F(K.threadId),
16076
- 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`,
16075
+ onClick: () => F(q.threadId),
16076
+ className: `group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i ?? p) === q.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`,
16077
16077
  children: [
16078
16078
  /* @__PURE__ */ u.jsxs("div", { className: "flex items-center justify-between", children: [
16079
- /* @__PURE__ */ u.jsx("div", { className: "flex-1 min-w-0", children: N === K.threadId ? /* @__PURE__ */ u.jsxs("div", { className: "flex items-center gap-2", onClick: (oe) => oe.stopPropagation(), children: [
16080
- /* @__PURE__ */ u.jsx(us, { value: j, onChange: (oe) => P(oe.target.value), onKeyDown: (oe) => G(oe, K.threadId), className: "h-6 text-sm", autoFocus: !0 }),
16081
- /* @__PURE__ */ u.jsx(ot, { variant: "ghost", size: "sm", onClick: () => _(K.threadId), className: "h-6 w-6 p-0", children: /* @__PURE__ */ u.jsx(ra, { size: 12 }) }),
16079
+ /* @__PURE__ */ u.jsx("div", { className: "flex-1 min-w-0", children: N === q.threadId ? /* @__PURE__ */ u.jsxs("div", { className: "flex items-center gap-2", onClick: (oe) => oe.stopPropagation(), children: [
16080
+ /* @__PURE__ */ u.jsx(us, { value: j, onChange: (oe) => P(oe.target.value), onKeyDown: (oe) => G(oe, q.threadId), className: "h-6 text-sm", autoFocus: !0 }),
16081
+ /* @__PURE__ */ u.jsx(ot, { variant: "ghost", size: "sm", onClick: () => _(q.threadId), className: "h-6 w-6 p-0", children: /* @__PURE__ */ u.jsx(ra, { size: 12 }) }),
16082
16082
  /* @__PURE__ */ u.jsx(ot, { variant: "ghost", size: "sm", onClick: J, className: "h-6 w-6 p-0", children: /* @__PURE__ */ u.jsx(gr, { size: 12 }) })
16083
16083
  ] }) : /* @__PURE__ */ u.jsxs(u.Fragment, { children: [
16084
- /* @__PURE__ */ u.jsx("div", { className: "font-medium text-sm truncate text-gray-900 dark:text-slate-100", children: Ae(K) }),
16084
+ /* @__PURE__ */ u.jsx("div", { className: "font-medium text-sm truncate text-gray-900 dark:text-slate-100", children: Ae(q) }),
16085
16085
  /* @__PURE__ */ u.jsxs("div", { className: "flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1", children: [
16086
16086
  /* @__PURE__ */ u.jsx(hm, { size: 10 }),
16087
- /* @__PURE__ */ u.jsx("span", { children: pe(K.updatedAt || K.createdAt) })
16087
+ /* @__PURE__ */ u.jsx("span", { children: pe(q.updatedAt || q.createdAt) })
16088
16088
  ] })
16089
16089
  ] }) }),
16090
16090
  /* @__PURE__ */ u.jsxs("div", { className: "flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2", children: [
16091
- r && N !== K.threadId && /* @__PURE__ */ u.jsx(ot, { variant: "ghost", size: "sm", onClick: (oe) => L(K, oe), className: "h-6 w-6 p-0", title: "Edit title", children: /* @__PURE__ */ u.jsx(Wc, { size: 12 }) }),
16091
+ r && N !== q.threadId && /* @__PURE__ */ u.jsx(ot, { variant: "ghost", size: "sm", onClick: (oe) => L(q, oe), className: "h-6 w-6 p-0", title: "Edit title", children: /* @__PURE__ */ u.jsx(Wc, { size: 12 }) }),
16092
16092
  n && /* @__PURE__ */ u.jsx(
16093
16093
  ot,
16094
16094
  {
16095
16095
  variant: "ghost",
16096
16096
  size: "sm",
16097
- onClick: (oe) => X(K.threadId, oe),
16097
+ onClick: (oe) => X(q.threadId, oe),
16098
16098
  className: "h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",
16099
16099
  title: "Delete thread",
16100
16100
  children: /* @__PURE__ */ u.jsx(mm, { size: 12 })
@@ -16102,10 +16102,10 @@ function Fc({
16102
16102
  )
16103
16103
  ] })
16104
16104
  ] }),
16105
- 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" })
16105
+ i === q.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" })
16106
16106
  ]
16107
16107
  },
16108
- K.threadId
16108
+ q.threadId
16109
16109
  )) })
16110
16110
  }
16111
16111
  )
@@ -16607,9 +16607,9 @@ var dn = 10, [fh, qn] = jr(sr), dT = "SelectContentImpl", fT = br("SelectContent
16607
16607
  }, [b]), ma();
16608
16608
  const A = v.useCallback(
16609
16609
  (Y) => {
16610
- const [D, ...H] = P().map((q) => q.ref.current), [ne] = H.slice(-1), se = document.activeElement;
16611
- for (const q of Y)
16612
- if (q === se || (q == null || q.scrollIntoView({ block: "nearest" }), q === D && C && (C.scrollTop = 0), q === ne && C && (C.scrollTop = C.scrollHeight), q == null || q.focus(), document.activeElement !== se)) return;
16610
+ const [D, ...H] = P().map((K) => K.ref.current), [ne] = H.slice(-1), se = document.activeElement;
16611
+ for (const K of Y)
16612
+ if (K === se || (K == null || K.scrollIntoView({ block: "nearest" }), K === D && C && (C.scrollTop = 0), K === ne && C && (C.scrollTop = C.scrollHeight), K == null || K.focus(), document.activeElement !== se)) return;
16613
16613
  },
16614
16614
  [P, C]
16615
16615
  ), X = v.useCallback(
@@ -16624,10 +16624,10 @@ var dn = 10, [fh, qn] = jr(sr), dT = "SelectContentImpl", fT = br("SelectContent
16624
16624
  if (b) {
16625
16625
  let Y = { x: 0, y: 0 };
16626
16626
  const D = (ne) => {
16627
- var se, q;
16627
+ var se, K;
16628
16628
  Y = {
16629
16629
  x: Math.abs(Math.round(ne.pageX) - (((se = _.current) == null ? void 0 : se.x) ?? 0)),
16630
- y: Math.abs(Math.round(ne.pageY) - (((q = _.current) == null ? void 0 : q.y) ?? 0))
16630
+ y: Math.abs(Math.round(ne.pageY) - (((K = _.current) == null ? void 0 : K.y) ?? 0))
16631
16631
  };
16632
16632
  }, H = (ne) => {
16633
16633
  Y.x <= 10 && Y.y <= 10 ? ne.preventDefault() : b.contains(ne.target) || L(!1), document.removeEventListener("pointermove", D), _.current = null;
@@ -16657,7 +16657,7 @@ var dn = 10, [fh, qn] = jr(sr), dT = "SelectContentImpl", fT = br("SelectContent
16657
16657
  (w.value !== void 0 && w.value === D || ne) && j(Y);
16658
16658
  },
16659
16659
  [w.value]
16660
- ), K = r === "popper" ? Xi : hh, oe = K === Xi ? {
16660
+ ), q = r === "popper" ? Xi : hh, oe = q === Xi ? {
16661
16661
  side: a,
16662
16662
  sideOffset: l,
16663
16663
  align: c,
@@ -16707,7 +16707,7 @@ var dn = 10, [fh, qn] = jr(sr), dT = "SelectContentImpl", fT = br("SelectContent
16707
16707
  onFocusOutside: (Y) => Y.preventDefault(),
16708
16708
  onDismiss: () => w.onOpenChange(!1),
16709
16709
  children: /* @__PURE__ */ u.jsx(
16710
- K,
16710
+ q,
16711
16711
  {
16712
16712
  role: "listbox",
16713
16713
  id: w.contentId,
@@ -16731,8 +16731,8 @@ var dn = 10, [fh, qn] = jr(sr), dT = "SelectContentImpl", fT = br("SelectContent
16731
16731
  if (Y.key === "Tab" && Y.preventDefault(), !D && Y.key.length === 1 && G(Y.key), ["ArrowUp", "ArrowDown", "Home", "End"].includes(Y.key)) {
16732
16732
  let ne = P().filter((se) => !se.disabled).map((se) => se.ref.current);
16733
16733
  if (["ArrowUp", "End"].includes(Y.key) && (ne = ne.slice().reverse()), ["ArrowUp", "ArrowDown"].includes(Y.key)) {
16734
- const se = Y.target, q = ne.indexOf(se);
16735
- ne = ne.slice(q + 1);
16734
+ const se = Y.target, K = ne.indexOf(se);
16735
+ ne = ne.slice(K + 1);
16736
16736
  }
16737
16737
  setTimeout(() => A(ne)), Y.preventDefault();
16738
16738
  }
@@ -16753,7 +16753,7 @@ var pT = "SelectItemAlignedPosition", hh = v.forwardRef((e, t) => {
16753
16753
  if (s.trigger && s.valueNode && a && c && x && y && g) {
16754
16754
  const k = s.trigger.getBoundingClientRect(), E = c.getBoundingClientRect(), N = s.valueNode.getBoundingClientRect(), M = g.getBoundingClientRect();
16755
16755
  if (s.dir !== "rtl") {
16756
- const se = M.left - E.left, q = N.left - se, Me = k.left - q, Ue = k.width + Me, Ze = Math.max(Ue, E.width), re = window.innerWidth - dn, me = Yi(q, [
16756
+ const se = M.left - E.left, K = N.left - se, Me = k.left - K, Ue = k.width + Me, Ze = Math.max(Ue, E.width), re = window.innerWidth - dn, me = Yi(K, [
16757
16757
  dn,
16758
16758
  // Prevents the content from going off the starting edge of the
16759
16759
  // viewport. It may still go off the ending edge, but this can be
@@ -16764,20 +16764,20 @@ var pT = "SelectItemAlignedPosition", hh = v.forwardRef((e, t) => {
16764
16764
  ]);
16765
16765
  a.style.minWidth = Ue + "px", a.style.left = me + "px";
16766
16766
  } else {
16767
- const se = E.right - M.right, q = window.innerWidth - N.right - se, Me = window.innerWidth - k.right - q, Ue = k.width + Me, Ze = Math.max(Ue, E.width), re = window.innerWidth - dn, me = Yi(q, [
16767
+ const se = E.right - M.right, K = window.innerWidth - N.right - se, Me = window.innerWidth - k.right - K, Ue = k.width + Me, Ze = Math.max(Ue, E.width), re = window.innerWidth - dn, me = Yi(K, [
16768
16768
  dn,
16769
16769
  Math.max(dn, re - Ze)
16770
16770
  ]);
16771
16771
  a.style.minWidth = Ue + "px", a.style.right = me + "px";
16772
16772
  }
16773
- const j = p(), P = window.innerHeight - dn * 2, $ = x.scrollHeight, I = window.getComputedStyle(c), F = parseInt(I.borderTopWidth, 10), A = parseInt(I.paddingTop, 10), X = parseInt(I.borderBottomWidth, 10), L = parseInt(I.paddingBottom, 10), _ = F + A + $ + L + X, J = Math.min(y.offsetHeight * 5, _), G = window.getComputedStyle(x), pe = parseInt(G.paddingTop, 10), Re = parseInt(G.paddingBottom, 10), Ae = k.top + k.height / 2 - dn, K = P - Ae, oe = y.offsetHeight / 2, Y = y.offsetTop + oe, D = F + A + Y, H = _ - D;
16773
+ const j = p(), P = window.innerHeight - dn * 2, $ = x.scrollHeight, I = window.getComputedStyle(c), F = parseInt(I.borderTopWidth, 10), A = parseInt(I.paddingTop, 10), X = parseInt(I.borderBottomWidth, 10), L = parseInt(I.paddingBottom, 10), _ = F + A + $ + L + X, J = Math.min(y.offsetHeight * 5, _), G = window.getComputedStyle(x), pe = parseInt(G.paddingTop, 10), Re = parseInt(G.paddingBottom, 10), Ae = k.top + k.height / 2 - dn, q = P - Ae, oe = y.offsetHeight / 2, Y = y.offsetTop + oe, D = F + A + Y, H = _ - D;
16774
16774
  if (D <= Ae) {
16775
16775
  const se = j.length > 0 && y === j[j.length - 1].ref.current;
16776
16776
  a.style.bottom = "0px";
16777
- const q = c.clientHeight - x.offsetTop - x.offsetHeight, Me = Math.max(
16778
- K,
16777
+ const K = c.clientHeight - x.offsetTop - x.offsetHeight, Me = Math.max(
16778
+ q,
16779
16779
  oe + // viewport might have padding bottom, include it to avoid a scrollable viewport
16780
- (se ? Re : 0) + q + X
16780
+ (se ? Re : 0) + K + X
16781
16781
  ), Ue = D + Me;
16782
16782
  a.style.height = Ue + "px";
16783
16783
  } else {