@teodorruskvi/chat-core 0.1.59 → 0.1.60

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
@@ -3,19 +3,19 @@ var Gt = (e, t, n) => t in e ? qt(e, t, { enumerable: !0, configurable: !0, writ
3
3
  var at = (e, t, n) => Gt(e, typeof t != "symbol" ? t + "" : t, n);
4
4
  import { jsx as de } from "react/jsx-runtime";
5
5
  import * as it from "react";
6
- import { createContext as Ce, useContext as je, useState as H, useRef as W, useEffect as Y, useCallback as _, useMemo as Z, useReducer as Wt } from "react";
6
+ import { createContext as Ce, useContext as je, useState as H, useRef as W, useEffect as Y, useCallback as N, useMemo as Z, useReducer as Wt } from "react";
7
7
  import Jt, { isCancel as Xt } from "axios";
8
8
  function It(e) {
9
9
  var t, n, r = "";
10
10
  if (typeof e == "string" || typeof e == "number") r += e;
11
11
  else if (typeof e == "object") if (Array.isArray(e)) {
12
- var s = e.length;
13
- for (t = 0; t < s; t++) e[t] && (n = It(e[t])) && (r && (r += " "), r += n);
12
+ var o = e.length;
13
+ for (t = 0; t < o; t++) e[t] && (n = It(e[t])) && (r && (r += " "), r += n);
14
14
  } else for (n in e) e[n] && (r && (r += " "), r += n);
15
15
  return r;
16
16
  }
17
17
  function Qt() {
18
- for (var e, t, n = 0, r = "", s = arguments.length; n < s; n++) (e = arguments[n]) && (t = It(e)) && (r && (r += " "), r += t);
18
+ for (var e, t, n = 0, r = "", o = arguments.length; n < o; n++) (e = arguments[n]) && (t = It(e)) && (r && (r += " "), r += t);
19
19
  return r;
20
20
  }
21
21
  const et = "-", Yt = (e) => {
@@ -37,15 +37,15 @@ const et = "-", Yt = (e) => {
37
37
  var a;
38
38
  if (e.length === 0)
39
39
  return t.classGroupId;
40
- const n = e[0], r = t.nextPart.get(n), s = r ? vt(e.slice(1), r) : void 0;
41
- if (s)
42
- return s;
40
+ const n = e[0], r = t.nextPart.get(n), o = r ? vt(e.slice(1), r) : void 0;
41
+ if (o)
42
+ return o;
43
43
  if (t.validators.length === 0)
44
44
  return;
45
- const o = e.join(et);
45
+ const s = e.join(et);
46
46
  return (a = t.validators.find(({
47
47
  validator: i
48
- }) => i(o))) == null ? void 0 : a.classGroupId;
48
+ }) => i(s))) == null ? void 0 : a.classGroupId;
49
49
  }, ct = /^\[(.+)\]$/, Zt = (e) => {
50
50
  if (ct.test(e)) {
51
51
  const t = ct.exec(e)[1], n = t == null ? void 0 : t.substring(0, t.indexOf(":"));
@@ -60,29 +60,29 @@ const et = "-", Yt = (e) => {
60
60
  nextPart: /* @__PURE__ */ new Map(),
61
61
  validators: []
62
62
  };
63
- return nn(Object.entries(e.classGroups), n).forEach(([o, a]) => {
64
- Xe(a, r, o, t);
63
+ return nn(Object.entries(e.classGroups), n).forEach(([s, a]) => {
64
+ Xe(a, r, s, t);
65
65
  }), r;
66
66
  }, Xe = (e, t, n, r) => {
67
- e.forEach((s) => {
68
- if (typeof s == "string") {
69
- const o = s === "" ? t : lt(t, s);
70
- o.classGroupId = n;
67
+ e.forEach((o) => {
68
+ if (typeof o == "string") {
69
+ const s = o === "" ? t : lt(t, o);
70
+ s.classGroupId = n;
71
71
  return;
72
72
  }
73
- if (typeof s == "function") {
74
- if (tn(s)) {
75
- Xe(s(r), t, n, r);
73
+ if (typeof o == "function") {
74
+ if (tn(o)) {
75
+ Xe(o(r), t, n, r);
76
76
  return;
77
77
  }
78
78
  t.validators.push({
79
- validator: s,
79
+ validator: o,
80
80
  classGroupId: n
81
81
  });
82
82
  return;
83
83
  }
84
- Object.entries(s).forEach(([o, a]) => {
85
- Xe(a, lt(t, o), n, r);
84
+ Object.entries(o).forEach(([s, a]) => {
85
+ Xe(a, lt(t, s), n, r);
86
86
  });
87
87
  });
88
88
  }, lt = (e, t) => {
@@ -94,8 +94,8 @@ const et = "-", Yt = (e) => {
94
94
  }), n = n.nextPart.get(r);
95
95
  }), n;
96
96
  }, tn = (e) => e.isThemeGetter, nn = (e, t) => t ? e.map(([n, r]) => {
97
- const s = r.map((o) => typeof o == "string" ? t + o : typeof o == "object" ? Object.fromEntries(Object.entries(o).map(([a, i]) => [t + a, i])) : o);
98
- return [n, s];
97
+ const o = r.map((s) => typeof s == "string" ? t + s : typeof s == "object" ? Object.fromEntries(Object.entries(s).map(([a, i]) => [t + a, i])) : s);
98
+ return [n, o];
99
99
  }) : e, rn = (e) => {
100
100
  if (e < 1)
101
101
  return {
@@ -105,47 +105,47 @@ const et = "-", Yt = (e) => {
105
105
  }
106
106
  };
107
107
  let t = 0, n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
108
- const s = (o, a) => {
109
- n.set(o, a), t++, t > e && (t = 0, r = n, n = /* @__PURE__ */ new Map());
108
+ const o = (s, a) => {
109
+ n.set(s, a), t++, t > e && (t = 0, r = n, n = /* @__PURE__ */ new Map());
110
110
  };
111
111
  return {
112
- get(o) {
113
- let a = n.get(o);
112
+ get(s) {
113
+ let a = n.get(s);
114
114
  if (a !== void 0)
115
115
  return a;
116
- if ((a = r.get(o)) !== void 0)
117
- return s(o, a), a;
116
+ if ((a = r.get(s)) !== void 0)
117
+ return o(s, a), a;
118
118
  },
119
- set(o, a) {
120
- n.has(o) ? n.set(o, a) : s(o, a);
119
+ set(s, a) {
120
+ n.has(s) ? n.set(s, a) : o(s, a);
121
121
  }
122
122
  };
123
- }, xt = "!", on = (e) => {
123
+ }, xt = "!", sn = (e) => {
124
124
  const {
125
125
  separator: t,
126
126
  experimentalParseClassName: n
127
- } = e, r = t.length === 1, s = t[0], o = t.length, a = (i) => {
127
+ } = e, r = t.length === 1, o = t[0], s = t.length, a = (i) => {
128
128
  const u = [];
129
129
  let l = 0, c = 0, d;
130
- for (let b = 0; b < i.length; b++) {
131
- let x = i[b];
130
+ for (let h = 0; h < i.length; h++) {
131
+ let x = i[h];
132
132
  if (l === 0) {
133
- if (x === s && (r || i.slice(b, b + o) === t)) {
134
- u.push(i.slice(c, b)), c = b + o;
133
+ if (x === o && (r || i.slice(h, h + s) === t)) {
134
+ u.push(i.slice(c, h)), c = h + s;
135
135
  continue;
136
136
  }
137
137
  if (x === "/") {
138
- d = b;
138
+ d = h;
139
139
  continue;
140
140
  }
141
141
  }
142
142
  x === "[" ? l++ : x === "]" && l--;
143
143
  }
144
- const p = u.length === 0 ? i : i.substring(c), m = p.startsWith(xt), v = m ? p.substring(1) : p, f = d && d > c ? d - c : void 0;
144
+ const m = u.length === 0 ? i : i.substring(c), p = m.startsWith(xt), I = p ? m.substring(1) : m, f = d && d > c ? d - c : void 0;
145
145
  return {
146
146
  modifiers: u,
147
- hasImportantModifier: m,
148
- baseClassName: v,
147
+ hasImportantModifier: p,
148
+ baseClassName: I,
149
149
  maybePostfixModifierPosition: f
150
150
  };
151
151
  };
@@ -153,7 +153,7 @@ const et = "-", Yt = (e) => {
153
153
  className: i,
154
154
  parseClassName: a
155
155
  }) : a;
156
- }, sn = (e) => {
156
+ }, on = (e) => {
157
157
  if (e.length <= 1)
158
158
  return e;
159
159
  const t = [];
@@ -163,42 +163,42 @@ const et = "-", Yt = (e) => {
163
163
  }), t.push(...n.sort()), t;
164
164
  }, an = (e) => ({
165
165
  cache: rn(e.cacheSize),
166
- parseClassName: on(e),
166
+ parseClassName: sn(e),
167
167
  ...Yt(e)
168
168
  }), cn = /\s+/, ln = (e, t) => {
169
169
  const {
170
170
  parseClassName: n,
171
171
  getClassGroupId: r,
172
- getConflictingClassGroupIds: s
173
- } = t, o = [], a = e.trim().split(cn);
172
+ getConflictingClassGroupIds: o
173
+ } = t, s = [], a = e.trim().split(cn);
174
174
  let i = "";
175
175
  for (let u = a.length - 1; u >= 0; u -= 1) {
176
176
  const l = a[u], {
177
177
  modifiers: c,
178
178
  hasImportantModifier: d,
179
- baseClassName: p,
180
- maybePostfixModifierPosition: m
179
+ baseClassName: m,
180
+ maybePostfixModifierPosition: p
181
181
  } = n(l);
182
- let v = !!m, f = r(v ? p.substring(0, m) : p);
182
+ let I = !!p, f = r(I ? m.substring(0, p) : m);
183
183
  if (!f) {
184
- if (!v) {
184
+ if (!I) {
185
185
  i = l + (i.length > 0 ? " " + i : i);
186
186
  continue;
187
187
  }
188
- if (f = r(p), !f) {
188
+ if (f = r(m), !f) {
189
189
  i = l + (i.length > 0 ? " " + i : i);
190
190
  continue;
191
191
  }
192
- v = !1;
192
+ I = !1;
193
193
  }
194
- const b = sn(c).join(":"), x = d ? b + xt : b, S = x + f;
195
- if (o.includes(S))
194
+ const h = on(c).join(":"), x = d ? h + xt : h, S = x + f;
195
+ if (s.includes(S))
196
196
  continue;
197
- o.push(S);
198
- const A = s(f, v);
197
+ s.push(S);
198
+ const A = o(f, I);
199
199
  for (let w = 0; w < A.length; ++w) {
200
200
  const k = A[w];
201
- o.push(x + k);
201
+ s.push(x + k);
202
202
  }
203
203
  i = l + (i.length > 0 ? " " + i : i);
204
204
  }
@@ -219,20 +219,20 @@ const At = (e) => {
219
219
  return n;
220
220
  };
221
221
  function un(e, ...t) {
222
- let n, r, s, o = a;
222
+ let n, r, o, s = a;
223
223
  function a(u) {
224
224
  const l = t.reduce((c, d) => d(c), e());
225
- return n = an(l), r = n.cache.get, s = n.cache.set, o = i, i(u);
225
+ return n = an(l), r = n.cache.get, o = n.cache.set, s = i, i(u);
226
226
  }
227
227
  function i(u) {
228
228
  const l = r(u);
229
229
  if (l)
230
230
  return l;
231
231
  const c = ln(u, n);
232
- return s(u, c), c;
232
+ return o(u, c), c;
233
233
  }
234
234
  return function() {
235
- return o(dn.apply(null, arguments));
235
+ return s(dn.apply(null, arguments));
236
236
  };
237
237
  }
238
238
  const q = (e) => {
@@ -247,7 +247,7 @@ const q = (e) => {
247
247
  // I could also use lookbehind assertion in `lengthUnitRegex` but that isn't supported widely enough.
248
248
  mn.test(e) && !yn.test(e)
249
249
  ), St = () => !1, Mn = (e) => hn.test(e), Cn = (e) => bn.test(e), En = () => {
250
- const e = q("colors"), t = q("spacing"), n = q("blur"), r = q("brightness"), s = q("borderColor"), o = q("borderRadius"), a = q("borderSpacing"), i = q("borderWidth"), u = q("contrast"), l = q("grayscale"), c = q("hueRotate"), d = q("invert"), p = q("gap"), m = q("gradientColorStops"), v = q("gradientColorStopPositions"), f = q("inset"), b = q("margin"), x = q("opacity"), S = q("padding"), A = q("saturate"), w = q("scale"), k = q("sepia"), h = q("skew"), T = q("space"), y = q("translate"), I = () => ["auto", "contain", "none"], E = () => ["auto", "hidden", "clip", "visible", "scroll"], L = () => ["auto", R, t], M = () => [R, t], $ = () => ["", pe, Ie], U = () => ["auto", Te, R], V = () => ["bottom", "center", "left", "left-bottom", "left-top", "right", "right-bottom", "right-top", "top"], P = () => ["solid", "dashed", "dotted", "double", "none"], F = () => ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"], N = () => ["start", "end", "center", "between", "around", "evenly", "stretch"], j = () => ["", "0", R], G = () => ["auto", "avoid", "all", "avoid-page", "page", "left", "right", "column"], g = () => [Te, R];
250
+ const e = q("colors"), t = q("spacing"), n = q("blur"), r = q("brightness"), o = q("borderColor"), s = q("borderRadius"), a = q("borderSpacing"), i = q("borderWidth"), u = q("contrast"), l = q("grayscale"), c = q("hueRotate"), d = q("invert"), m = q("gap"), p = q("gradientColorStops"), I = q("gradientColorStopPositions"), f = q("inset"), h = q("margin"), x = q("opacity"), S = q("padding"), A = q("saturate"), w = q("scale"), k = q("sepia"), b = q("skew"), T = q("space"), y = q("translate"), v = () => ["auto", "contain", "none"], _ = () => ["auto", "hidden", "clip", "visible", "scroll"], L = () => ["auto", R, t], M = () => [R, t], $ = () => ["", pe, Ie], U = () => ["auto", Te, R], V = () => ["bottom", "center", "left", "left-bottom", "left-top", "right", "right-bottom", "right-top", "top"], P = () => ["solid", "dashed", "dotted", "double", "none"], F = () => ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"], E = () => ["start", "end", "center", "between", "around", "evenly", "stretch"], j = () => ["", "0", R], G = () => ["auto", "avoid", "all", "avoid-page", "page", "left", "right", "column"], g = () => [Te, R];
251
251
  return {
252
252
  cacheSize: 500,
253
253
  separator: ":",
@@ -377,42 +377,42 @@ const q = (e) => {
377
377
  * @see https://tailwindcss.com/docs/overflow
378
378
  */
379
379
  overflow: [{
380
- overflow: E()
380
+ overflow: _()
381
381
  }],
382
382
  /**
383
383
  * Overflow X
384
384
  * @see https://tailwindcss.com/docs/overflow
385
385
  */
386
386
  "overflow-x": [{
387
- "overflow-x": E()
387
+ "overflow-x": _()
388
388
  }],
389
389
  /**
390
390
  * Overflow Y
391
391
  * @see https://tailwindcss.com/docs/overflow
392
392
  */
393
393
  "overflow-y": [{
394
- "overflow-y": E()
394
+ "overflow-y": _()
395
395
  }],
396
396
  /**
397
397
  * Overscroll Behavior
398
398
  * @see https://tailwindcss.com/docs/overscroll-behavior
399
399
  */
400
400
  overscroll: [{
401
- overscroll: I()
401
+ overscroll: v()
402
402
  }],
403
403
  /**
404
404
  * Overscroll Behavior X
405
405
  * @see https://tailwindcss.com/docs/overscroll-behavior
406
406
  */
407
407
  "overscroll-x": [{
408
- "overscroll-x": I()
408
+ "overscroll-x": v()
409
409
  }],
410
410
  /**
411
411
  * Overscroll Behavior Y
412
412
  * @see https://tailwindcss.com/docs/overscroll-behavior
413
413
  */
414
414
  "overscroll-y": [{
415
- "overscroll-y": I()
415
+ "overscroll-y": v()
416
416
  }],
417
417
  /**
418
418
  * Position
@@ -630,28 +630,28 @@ const q = (e) => {
630
630
  * @see https://tailwindcss.com/docs/gap
631
631
  */
632
632
  gap: [{
633
- gap: [p]
633
+ gap: [m]
634
634
  }],
635
635
  /**
636
636
  * Gap X
637
637
  * @see https://tailwindcss.com/docs/gap
638
638
  */
639
639
  "gap-x": [{
640
- "gap-x": [p]
640
+ "gap-x": [m]
641
641
  }],
642
642
  /**
643
643
  * Gap Y
644
644
  * @see https://tailwindcss.com/docs/gap
645
645
  */
646
646
  "gap-y": [{
647
- "gap-y": [p]
647
+ "gap-y": [m]
648
648
  }],
649
649
  /**
650
650
  * Justify Content
651
651
  * @see https://tailwindcss.com/docs/justify-content
652
652
  */
653
653
  "justify-content": [{
654
- justify: ["normal", ...N()]
654
+ justify: ["normal", ...E()]
655
655
  }],
656
656
  /**
657
657
  * Justify Items
@@ -672,7 +672,7 @@ const q = (e) => {
672
672
  * @see https://tailwindcss.com/docs/align-content
673
673
  */
674
674
  "align-content": [{
675
- content: ["normal", ...N(), "baseline"]
675
+ content: ["normal", ...E(), "baseline"]
676
676
  }],
677
677
  /**
678
678
  * Align Items
@@ -693,7 +693,7 @@ const q = (e) => {
693
693
  * @see https://tailwindcss.com/docs/place-content
694
694
  */
695
695
  "place-content": [{
696
- "place-content": [...N(), "baseline"]
696
+ "place-content": [...E(), "baseline"]
697
697
  }],
698
698
  /**
699
699
  * Place Items
@@ -778,63 +778,63 @@ const q = (e) => {
778
778
  * @see https://tailwindcss.com/docs/margin
779
779
  */
780
780
  m: [{
781
- m: [b]
781
+ m: [h]
782
782
  }],
783
783
  /**
784
784
  * Margin X
785
785
  * @see https://tailwindcss.com/docs/margin
786
786
  */
787
787
  mx: [{
788
- mx: [b]
788
+ mx: [h]
789
789
  }],
790
790
  /**
791
791
  * Margin Y
792
792
  * @see https://tailwindcss.com/docs/margin
793
793
  */
794
794
  my: [{
795
- my: [b]
795
+ my: [h]
796
796
  }],
797
797
  /**
798
798
  * Margin Start
799
799
  * @see https://tailwindcss.com/docs/margin
800
800
  */
801
801
  ms: [{
802
- ms: [b]
802
+ ms: [h]
803
803
  }],
804
804
  /**
805
805
  * Margin End
806
806
  * @see https://tailwindcss.com/docs/margin
807
807
  */
808
808
  me: [{
809
- me: [b]
809
+ me: [h]
810
810
  }],
811
811
  /**
812
812
  * Margin Top
813
813
  * @see https://tailwindcss.com/docs/margin
814
814
  */
815
815
  mt: [{
816
- mt: [b]
816
+ mt: [h]
817
817
  }],
818
818
  /**
819
819
  * Margin Right
820
820
  * @see https://tailwindcss.com/docs/margin
821
821
  */
822
822
  mr: [{
823
- mr: [b]
823
+ mr: [h]
824
824
  }],
825
825
  /**
826
826
  * Margin Bottom
827
827
  * @see https://tailwindcss.com/docs/margin
828
828
  */
829
829
  mb: [{
830
- mb: [b]
830
+ mb: [h]
831
831
  }],
832
832
  /**
833
833
  * Margin Left
834
834
  * @see https://tailwindcss.com/docs/margin
835
835
  */
836
836
  ml: [{
837
- ml: [b]
837
+ ml: [h]
838
838
  }],
839
839
  /**
840
840
  * Space Between X
@@ -1218,42 +1218,42 @@ const q = (e) => {
1218
1218
  * @see https://tailwindcss.com/docs/gradient-color-stops
1219
1219
  */
1220
1220
  "gradient-from-pos": [{
1221
- from: [v]
1221
+ from: [I]
1222
1222
  }],
1223
1223
  /**
1224
1224
  * Gradient Color Stops Via Position
1225
1225
  * @see https://tailwindcss.com/docs/gradient-color-stops
1226
1226
  */
1227
1227
  "gradient-via-pos": [{
1228
- via: [v]
1228
+ via: [I]
1229
1229
  }],
1230
1230
  /**
1231
1231
  * Gradient Color Stops To Position
1232
1232
  * @see https://tailwindcss.com/docs/gradient-color-stops
1233
1233
  */
1234
1234
  "gradient-to-pos": [{
1235
- to: [v]
1235
+ to: [I]
1236
1236
  }],
1237
1237
  /**
1238
1238
  * Gradient Color Stops From
1239
1239
  * @see https://tailwindcss.com/docs/gradient-color-stops
1240
1240
  */
1241
1241
  "gradient-from": [{
1242
- from: [m]
1242
+ from: [p]
1243
1243
  }],
1244
1244
  /**
1245
1245
  * Gradient Color Stops Via
1246
1246
  * @see https://tailwindcss.com/docs/gradient-color-stops
1247
1247
  */
1248
1248
  "gradient-via": [{
1249
- via: [m]
1249
+ via: [p]
1250
1250
  }],
1251
1251
  /**
1252
1252
  * Gradient Color Stops To
1253
1253
  * @see https://tailwindcss.com/docs/gradient-color-stops
1254
1254
  */
1255
1255
  "gradient-to": [{
1256
- to: [m]
1256
+ to: [p]
1257
1257
  }],
1258
1258
  // Borders
1259
1259
  /**
@@ -1261,105 +1261,105 @@ const q = (e) => {
1261
1261
  * @see https://tailwindcss.com/docs/border-radius
1262
1262
  */
1263
1263
  rounded: [{
1264
- rounded: [o]
1264
+ rounded: [s]
1265
1265
  }],
1266
1266
  /**
1267
1267
  * Border Radius Start
1268
1268
  * @see https://tailwindcss.com/docs/border-radius
1269
1269
  */
1270
1270
  "rounded-s": [{
1271
- "rounded-s": [o]
1271
+ "rounded-s": [s]
1272
1272
  }],
1273
1273
  /**
1274
1274
  * Border Radius End
1275
1275
  * @see https://tailwindcss.com/docs/border-radius
1276
1276
  */
1277
1277
  "rounded-e": [{
1278
- "rounded-e": [o]
1278
+ "rounded-e": [s]
1279
1279
  }],
1280
1280
  /**
1281
1281
  * Border Radius Top
1282
1282
  * @see https://tailwindcss.com/docs/border-radius
1283
1283
  */
1284
1284
  "rounded-t": [{
1285
- "rounded-t": [o]
1285
+ "rounded-t": [s]
1286
1286
  }],
1287
1287
  /**
1288
1288
  * Border Radius Right
1289
1289
  * @see https://tailwindcss.com/docs/border-radius
1290
1290
  */
1291
1291
  "rounded-r": [{
1292
- "rounded-r": [o]
1292
+ "rounded-r": [s]
1293
1293
  }],
1294
1294
  /**
1295
1295
  * Border Radius Bottom
1296
1296
  * @see https://tailwindcss.com/docs/border-radius
1297
1297
  */
1298
1298
  "rounded-b": [{
1299
- "rounded-b": [o]
1299
+ "rounded-b": [s]
1300
1300
  }],
1301
1301
  /**
1302
1302
  * Border Radius Left
1303
1303
  * @see https://tailwindcss.com/docs/border-radius
1304
1304
  */
1305
1305
  "rounded-l": [{
1306
- "rounded-l": [o]
1306
+ "rounded-l": [s]
1307
1307
  }],
1308
1308
  /**
1309
1309
  * Border Radius Start Start
1310
1310
  * @see https://tailwindcss.com/docs/border-radius
1311
1311
  */
1312
1312
  "rounded-ss": [{
1313
- "rounded-ss": [o]
1313
+ "rounded-ss": [s]
1314
1314
  }],
1315
1315
  /**
1316
1316
  * Border Radius Start End
1317
1317
  * @see https://tailwindcss.com/docs/border-radius
1318
1318
  */
1319
1319
  "rounded-se": [{
1320
- "rounded-se": [o]
1320
+ "rounded-se": [s]
1321
1321
  }],
1322
1322
  /**
1323
1323
  * Border Radius End End
1324
1324
  * @see https://tailwindcss.com/docs/border-radius
1325
1325
  */
1326
1326
  "rounded-ee": [{
1327
- "rounded-ee": [o]
1327
+ "rounded-ee": [s]
1328
1328
  }],
1329
1329
  /**
1330
1330
  * Border Radius End Start
1331
1331
  * @see https://tailwindcss.com/docs/border-radius
1332
1332
  */
1333
1333
  "rounded-es": [{
1334
- "rounded-es": [o]
1334
+ "rounded-es": [s]
1335
1335
  }],
1336
1336
  /**
1337
1337
  * Border Radius Top Left
1338
1338
  * @see https://tailwindcss.com/docs/border-radius
1339
1339
  */
1340
1340
  "rounded-tl": [{
1341
- "rounded-tl": [o]
1341
+ "rounded-tl": [s]
1342
1342
  }],
1343
1343
  /**
1344
1344
  * Border Radius Top Right
1345
1345
  * @see https://tailwindcss.com/docs/border-radius
1346
1346
  */
1347
1347
  "rounded-tr": [{
1348
- "rounded-tr": [o]
1348
+ "rounded-tr": [s]
1349
1349
  }],
1350
1350
  /**
1351
1351
  * Border Radius Bottom Right
1352
1352
  * @see https://tailwindcss.com/docs/border-radius
1353
1353
  */
1354
1354
  "rounded-br": [{
1355
- "rounded-br": [o]
1355
+ "rounded-br": [s]
1356
1356
  }],
1357
1357
  /**
1358
1358
  * Border Radius Bottom Left
1359
1359
  * @see https://tailwindcss.com/docs/border-radius
1360
1360
  */
1361
1361
  "rounded-bl": [{
1362
- "rounded-bl": [o]
1362
+ "rounded-bl": [s]
1363
1363
  }],
1364
1364
  /**
1365
1365
  * Border Width
@@ -1481,70 +1481,70 @@ const q = (e) => {
1481
1481
  * @see https://tailwindcss.com/docs/border-color
1482
1482
  */
1483
1483
  "border-color": [{
1484
- border: [s]
1484
+ border: [o]
1485
1485
  }],
1486
1486
  /**
1487
1487
  * Border Color X
1488
1488
  * @see https://tailwindcss.com/docs/border-color
1489
1489
  */
1490
1490
  "border-color-x": [{
1491
- "border-x": [s]
1491
+ "border-x": [o]
1492
1492
  }],
1493
1493
  /**
1494
1494
  * Border Color Y
1495
1495
  * @see https://tailwindcss.com/docs/border-color
1496
1496
  */
1497
1497
  "border-color-y": [{
1498
- "border-y": [s]
1498
+ "border-y": [o]
1499
1499
  }],
1500
1500
  /**
1501
1501
  * Border Color S
1502
1502
  * @see https://tailwindcss.com/docs/border-color
1503
1503
  */
1504
1504
  "border-color-s": [{
1505
- "border-s": [s]
1505
+ "border-s": [o]
1506
1506
  }],
1507
1507
  /**
1508
1508
  * Border Color E
1509
1509
  * @see https://tailwindcss.com/docs/border-color
1510
1510
  */
1511
1511
  "border-color-e": [{
1512
- "border-e": [s]
1512
+ "border-e": [o]
1513
1513
  }],
1514
1514
  /**
1515
1515
  * Border Color Top
1516
1516
  * @see https://tailwindcss.com/docs/border-color
1517
1517
  */
1518
1518
  "border-color-t": [{
1519
- "border-t": [s]
1519
+ "border-t": [o]
1520
1520
  }],
1521
1521
  /**
1522
1522
  * Border Color Right
1523
1523
  * @see https://tailwindcss.com/docs/border-color
1524
1524
  */
1525
1525
  "border-color-r": [{
1526
- "border-r": [s]
1526
+ "border-r": [o]
1527
1527
  }],
1528
1528
  /**
1529
1529
  * Border Color Bottom
1530
1530
  * @see https://tailwindcss.com/docs/border-color
1531
1531
  */
1532
1532
  "border-color-b": [{
1533
- "border-b": [s]
1533
+ "border-b": [o]
1534
1534
  }],
1535
1535
  /**
1536
1536
  * Border Color Left
1537
1537
  * @see https://tailwindcss.com/docs/border-color
1538
1538
  */
1539
1539
  "border-color-l": [{
1540
- "border-l": [s]
1540
+ "border-l": [o]
1541
1541
  }],
1542
1542
  /**
1543
1543
  * Divide Color
1544
1544
  * @see https://tailwindcss.com/docs/divide-color
1545
1545
  */
1546
1546
  "divide-color": [{
1547
- divide: [s]
1547
+ divide: [o]
1548
1548
  }],
1549
1549
  /**
1550
1550
  * Outline Style
@@ -1927,14 +1927,14 @@ const q = (e) => {
1927
1927
  * @see https://tailwindcss.com/docs/skew
1928
1928
  */
1929
1929
  "skew-x": [{
1930
- "skew-x": [h]
1930
+ "skew-x": [b]
1931
1931
  }],
1932
1932
  /**
1933
1933
  * Skew Y
1934
1934
  * @see https://tailwindcss.com/docs/skew
1935
1935
  */
1936
1936
  "skew-y": [{
1937
- "skew-y": [h]
1937
+ "skew-y": [b]
1938
1938
  }],
1939
1939
  /**
1940
1940
  * Transform Origin
@@ -2276,21 +2276,21 @@ const q = (e) => {
2276
2276
  }
2277
2277
  };
2278
2278
  }, Pn = /* @__PURE__ */ un(En);
2279
- function ro(...e) {
2279
+ function rs(...e) {
2280
2280
  return Pn(Qt(e));
2281
2281
  }
2282
2282
  function _n(e) {
2283
2283
  let t = !1, n = "";
2284
- for (const s of e) {
2285
- if (s === "\\") {
2286
- n += s, t = !t;
2284
+ for (const o of e) {
2285
+ if (o === "\\") {
2286
+ n += o, t = !t;
2287
2287
  continue;
2288
2288
  }
2289
- if (s === "'" && !t) {
2289
+ if (o === "'" && !t) {
2290
2290
  n += '"';
2291
2291
  continue;
2292
2292
  }
2293
- n += s, t = !1;
2293
+ n += o, t = !1;
2294
2294
  }
2295
2295
  return n.replace(/\bTrue\b/g, "true").replace(/\bFalse\b/g, "false").replace(/\bNone\b/g, "null");
2296
2296
  }
@@ -2372,8 +2372,8 @@ function De(e) {
2372
2372
  if (n === "data" && typeof r == "string" && r.length > 100)
2373
2373
  t[n] = `[base64 ${r.length} chars omitted]`;
2374
2374
  else {
2375
- const s = De(r);
2376
- s !== void 0 && (t[n] = s);
2375
+ const o = De(r);
2376
+ o !== void 0 && (t[n] = o);
2377
2377
  }
2378
2378
  }
2379
2379
  if (Object.keys(t).length)
@@ -2397,15 +2397,15 @@ function Et(e) {
2397
2397
  return "";
2398
2398
  }
2399
2399
  }
2400
- function oo(e) {
2400
+ function ss(e) {
2401
2401
  const t = Et(e);
2402
2402
  return typeof e == "string" && Nn(e) ? { content: e, isMarkdown: !0 } : { content: t, isMarkdown: !1 };
2403
2403
  }
2404
2404
  function Fn(e) {
2405
2405
  const t = (r) => {
2406
2406
  try {
2407
- const s = De(r);
2408
- return typeof s == "string" ? s : JSON.stringify(s ?? "");
2407
+ const o = De(r);
2408
+ return typeof o == "string" ? o : JSON.stringify(o ?? "");
2409
2409
  } catch {
2410
2410
  return "";
2411
2411
  }
@@ -2413,7 +2413,7 @@ function Fn(e) {
2413
2413
  return n.length ? t(n.map((r) => r.text).join(`
2414
2414
  `)) : t(e);
2415
2415
  }
2416
- function so(e) {
2416
+ function os(e) {
2417
2417
  return e.content.some((t) => t.type === "text" ? t.text.trim().length > 0 : t.type === "image_url" || t.type === "file");
2418
2418
  }
2419
2419
  function ue(e) {
@@ -2448,27 +2448,27 @@ function fe(e) {
2448
2448
  );
2449
2449
  }
2450
2450
  function nt(e) {
2451
- var x, S, A, w, k, h, T;
2451
+ var x, S, A, w, k, b, T;
2452
2452
  if (!e || typeof e != "object") return null;
2453
2453
  const t = fe(e), n = Kn(t);
2454
2454
  if (!n)
2455
2455
  return null;
2456
- const r = t.toolCalls ?? ((x = t.additionalKwargs) == null ? void 0 : x.toolCalls), s = Array.isArray(r) ? r.map(rt) : void 0, o = Dn(t.content ?? t.parts, !!(s != null && s.length)), a = t.id ?? `msg-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`, i = t.createdAt ?? ((S = t.additionalKwargs) == null ? void 0 : S.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(), u = t.name ?? ((A = t.additionalKwargs) == null ? void 0 : A.agentName) ?? void 0, l = t.model ?? ((w = t.additionalKwargs) == null ? void 0 : w.model) ?? void 0, c = t.toolCallId ?? void 0, d = t.additionalKwargs ?? void 0, p = t.responseMetadata ?? void 0, m = t.checkpointId ?? ((k = t.additionalKwargs) == null ? void 0 : k.checkpointId) ?? void 0, v = t.checkpointNs ?? ((h = t.additionalKwargs) == null ? void 0 : h.checkpointNs) ?? void 0, f = typeof t.toolStreaming == "boolean" ? t.toolStreaming : !!((T = t.additionalKwargs) != null && T.toolStreaming);
2456
+ const r = t.toolCalls ?? ((x = t.additionalKwargs) == null ? void 0 : x.toolCalls), o = Array.isArray(r) ? r.map(rt) : void 0, s = Dn(t.content ?? t.parts, !!(o != null && o.length)), a = t.id ?? `msg-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`, i = t.createdAt ?? ((S = t.additionalKwargs) == null ? void 0 : S.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(), u = t.name ?? ((A = t.additionalKwargs) == null ? void 0 : A.agentName) ?? void 0, l = t.model ?? ((w = t.additionalKwargs) == null ? void 0 : w.model) ?? void 0, c = t.toolCallId ?? void 0, d = t.additionalKwargs ?? void 0, m = t.responseMetadata ?? void 0, p = t.checkpointId ?? ((k = t.additionalKwargs) == null ? void 0 : k.checkpointId) ?? void 0, I = t.checkpointNs ?? ((b = t.additionalKwargs) == null ? void 0 : b.checkpointNs) ?? void 0, f = typeof t.toolStreaming == "boolean" ? t.toolStreaming : !!((T = t.additionalKwargs) != null && T.toolStreaming);
2457
2457
  return {
2458
2458
  ...t,
2459
2459
  id: a,
2460
2460
  role: n,
2461
- content: o,
2461
+ content: s,
2462
2462
  createdAt: i,
2463
2463
  name: u,
2464
2464
  model: l,
2465
2465
  toolCallId: c,
2466
- toolCalls: s,
2467
- checkpointId: m,
2468
- checkpointNs: v,
2466
+ toolCalls: o,
2467
+ checkpointId: p,
2468
+ checkpointNs: I,
2469
2469
  toolStreaming: f,
2470
2470
  additionalKwargs: d,
2471
- responseMetadata: p,
2471
+ responseMetadata: m,
2472
2472
  artifact: t.artifact && typeof t.artifact == "object" && !t.artifact.type ? { ...t.artifact, type: t.name } : t.artifact ?? void 0
2473
2473
  };
2474
2474
  }
@@ -2522,11 +2522,11 @@ function Hn(e, t) {
2522
2522
  if (!n) return;
2523
2523
  const r = typeof n == "string" ? n : Et(n);
2524
2524
  if (!r.trim()) return;
2525
- const s = [{ type: "text", text: r }];
2525
+ const o = [{ type: "text", text: r }];
2526
2526
  return {
2527
2527
  id: `tool-${t.id}`,
2528
2528
  role: "tool",
2529
- content: s,
2529
+ content: o,
2530
2530
  name: t.name,
2531
2531
  toolCallId: t.id,
2532
2532
  artifact: t.artifact,
@@ -2535,13 +2535,13 @@ function Hn(e, t) {
2535
2535
  }
2536
2536
  function Vn(e, t = []) {
2537
2537
  if (Array.isArray(e)) {
2538
- const s = e.filter((a) => a.role === "assistant").flatMap((a) => ut(a)), o = /* @__PURE__ */ new Map();
2539
- return s.forEach((a) => o.set(a.id, a)), Array.from(o.values()).map((a) => {
2540
- var d, p, m;
2541
- const i = qe(a.id, e) || qe(a.id, t), u = Array.isArray((d = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : d.toolProgress) ? (p = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : p.toolProgress : void 0, l = (i == null ? void 0 : i.artifact) ?? a.artifact, c = dt(a.status) ?? ((m = i == null ? void 0 : i.additionalKwargs) != null && m.toolStreaming ? "pending" : null) ?? (i ? "completed" : "pending");
2538
+ const o = e.filter((a) => a.role === "assistant").flatMap((a) => ut(a)), s = /* @__PURE__ */ new Map();
2539
+ return o.forEach((a) => s.set(a.id, a)), Array.from(s.values()).map((a) => {
2540
+ var d, m, p;
2541
+ const i = qe(a.id, e) || qe(a.id, t), u = Array.isArray((d = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : d.toolProgress) ? (m = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : m.toolProgress : void 0, l = (i == null ? void 0 : i.artifact) ?? a.artifact, c = dt(a.status) ?? ((p = i == null ? void 0 : i.additionalKwargs) != null && p.toolStreaming ? "pending" : null) ?? (i ? "completed" : "pending");
2542
2542
  if (i && !a.content && c === "completed") {
2543
- const v = ue(i);
2544
- typeof v == "string" && (a.content = v);
2543
+ const I = ue(i);
2544
+ typeof I == "string" && (a.content = I);
2545
2545
  }
2546
2546
  return {
2547
2547
  call: a,
@@ -2556,21 +2556,21 @@ function Vn(e, t = []) {
2556
2556
  const n = ut(e);
2557
2557
  return n.length === 0 ? [] : n.map((r) => {
2558
2558
  var u, l, c;
2559
- const s = qe(r.id, t) ?? Hn(e, r), o = Array.isArray((u = s == null ? void 0 : s.additionalKwargs) == null ? void 0 : u.toolProgress) ? (l = s == null ? void 0 : s.additionalKwargs) == null ? void 0 : l.toolProgress : void 0, a = (s == null ? void 0 : s.artifact) ?? r.artifact, i = dt(r.status) ?? ((c = s == null ? void 0 : s.additionalKwargs) != null && c.toolStreaming ? "pending" : null) ?? (s ? "completed" : "pending");
2560
- if (s && !r.content && i === "completed") {
2561
- const d = ue(s);
2559
+ const o = qe(r.id, t) ?? Hn(e, r), s = Array.isArray((u = o == null ? void 0 : o.additionalKwargs) == null ? void 0 : u.toolProgress) ? (l = o == null ? void 0 : o.additionalKwargs) == null ? void 0 : l.toolProgress : void 0, a = (o == null ? void 0 : o.artifact) ?? r.artifact, i = dt(r.status) ?? ((c = o == null ? void 0 : o.additionalKwargs) != null && c.toolStreaming ? "pending" : null) ?? (o ? "completed" : "pending");
2560
+ if (o && !r.content && i === "completed") {
2561
+ const d = ue(o);
2562
2562
  typeof d == "string" && (r.content = d);
2563
2563
  }
2564
2564
  return {
2565
2565
  call: r,
2566
- result: s,
2566
+ result: o,
2567
2567
  state: i,
2568
- progress: o,
2568
+ progress: s,
2569
2569
  artifact: a
2570
2570
  };
2571
2571
  });
2572
2572
  }
2573
- function ao(e, t = []) {
2573
+ function as(e, t = []) {
2574
2574
  return Vn(e, t).map((n) => n.artifact).filter((n) => !!n);
2575
2575
  }
2576
2576
  const ze = {
@@ -2598,7 +2598,7 @@ function _t(e) {
2598
2598
  }
2599
2599
  const qn = 12e4, Gn = 12e4;
2600
2600
  let Ye = qn, Nt = Gn;
2601
- const oe = Jt.create({
2601
+ const se = Jt.create({
2602
2602
  // BaseURL is set dynamically via ApiProvider -> api.updateConfig
2603
2603
  timeout: Ye,
2604
2604
  withCredentials: !0
@@ -2608,20 +2608,20 @@ function ft(e) {
2608
2608
  }
2609
2609
  function Wn(e) {
2610
2610
  const t = ft(e.requestTimeoutMs), n = ft(e.historyTimeoutMs);
2611
- t !== null && (Ye = t, oe.defaults.timeout = Ye), n !== null && (Nt = n);
2611
+ t !== null && (Ye = t, se.defaults.timeout = Ye), n !== null && (Nt = n);
2612
2612
  }
2613
2613
  function Jn() {
2614
2614
  return Nt;
2615
2615
  }
2616
- oe.interceptors.request.use((e) => (Ke && (e.headers.Authorization = `Bearer ${Ke}`), e));
2617
- oe.interceptors.response.use(
2616
+ se.interceptors.request.use((e) => (Ke && (e.headers.Authorization = `Bearer ${Ke}`), e));
2617
+ se.interceptors.response.use(
2618
2618
  (e) => {
2619
2619
  if (typeof window < "u" && (e != null && e.data))
2620
2620
  try {
2621
- const t = e.data, n = t.data || {}, r = typeof t.token == "string" && t.token || typeof n.token == "string" && n.token || null, s = typeof t.expires_at == "number" && t.expires_at || typeof n.expires_at == "number" && n.expires_at || typeof t.expiresAt == "number" && t.expiresAt || typeof n.expiresAt == "number" && n.expiresAt || null;
2622
- r && (localStorage.setItem(ze.authToken, r), xe(r)), s && localStorage.setItem(ze.authTokenExpiresAt, s.toString()), (r || s) && window.dispatchEvent(
2621
+ const t = e.data, n = t.data || {}, r = typeof t.token == "string" && t.token || typeof n.token == "string" && n.token || null, o = typeof t.expires_at == "number" && t.expires_at || typeof n.expires_at == "number" && n.expires_at || typeof t.expiresAt == "number" && t.expiresAt || typeof n.expiresAt == "number" && n.expiresAt || null;
2622
+ r && (localStorage.setItem(ze.authToken, r), xe(r)), o && localStorage.setItem(ze.authTokenExpiresAt, o.toString()), (r || o) && window.dispatchEvent(
2623
2623
  new CustomEvent("smartorg:chat-token-updated", {
2624
- detail: { token: r, expiresAt: s }
2624
+ detail: { token: r, expiresAt: o }
2625
2625
  })
2626
2626
  );
2627
2627
  } catch (t) {
@@ -2632,16 +2632,16 @@ oe.interceptors.response.use(
2632
2632
  (e) => Promise.reject(e)
2633
2633
  );
2634
2634
  async function ae(e, t) {
2635
- return oe.defaults.baseURL ? (await oe.get(e, t)).data : Promise.reject(new Error("API base URL is not configured"));
2635
+ return se.defaults.baseURL ? (await se.get(e, t)).data : Promise.reject(new Error("API base URL is not configured"));
2636
2636
  }
2637
2637
  async function Ze(e, t, n) {
2638
- return oe.defaults.baseURL ? (await oe.post(e, t, n)).data : Promise.reject(new Error("API base URL is not configured"));
2638
+ return se.defaults.baseURL ? (await se.post(e, t, n)).data : Promise.reject(new Error("API base URL is not configured"));
2639
2639
  }
2640
2640
  async function Xn(e, t, n) {
2641
- return oe.defaults.baseURL ? (await oe.put(e, t, n)).data : Promise.reject(new Error("API base URL is not configured"));
2641
+ return se.defaults.baseURL ? (await se.put(e, t, n)).data : Promise.reject(new Error("API base URL is not configured"));
2642
2642
  }
2643
2643
  async function Qn(e, t) {
2644
- return oe.defaults.baseURL ? (await oe.delete(e, t)).data : Promise.reject(new Error("API base URL is not configured"));
2644
+ return se.defaults.baseURL ? (await se.delete(e, t)).data : Promise.reject(new Error("API base URL is not configured"));
2645
2645
  }
2646
2646
  function le(e) {
2647
2647
  return e && typeof e == "object" && "data" in e ? e.data : e;
@@ -2651,14 +2651,14 @@ class Yn {
2651
2651
  // Chat client uses the default httpClient baseURL, no need for internal tracking
2652
2652
  // unless we want to support multiple instances with different URLs in the future.
2653
2653
  get baseUrl() {
2654
- return oe.defaults.baseURL || "";
2654
+ return se.defaults.baseURL || "";
2655
2655
  }
2656
2656
  updateConfig(t) {
2657
2657
  if (t.chatBaseUrl)
2658
- oe.defaults.baseURL = t.chatBaseUrl;
2658
+ se.defaults.baseURL = t.chatBaseUrl;
2659
2659
  else if (t.baseUrl) {
2660
2660
  const n = t.baseUrl.replace(/\/+$/, "");
2661
- oe.defaults.baseURL = n;
2661
+ se.defaults.baseURL = n;
2662
2662
  }
2663
2663
  t.apiKey !== void 0 ? xe(t.apiKey) : t.getToken && xe(t.getToken()), (t.requestTimeoutMs !== void 0 || t.historyTimeoutMs !== void 0) && Wn({
2664
2664
  requestTimeoutMs: t.requestTimeoutMs,
@@ -2684,8 +2684,8 @@ class Yn {
2684
2684
  async createThread(t, n) {
2685
2685
  const r = {};
2686
2686
  t && (r.title = t), n && (r.project = n);
2687
- const s = await Ze("/threads", Object.keys(r).length ? r : void 0);
2688
- return le(s);
2687
+ const o = await Ze("/threads", Object.keys(r).length ? r : void 0);
2688
+ return le(o);
2689
2689
  }
2690
2690
  async updateThread(t, n) {
2691
2691
  const r = await Xn(`/threads/${t}`, { title: n });
@@ -2748,11 +2748,11 @@ class Zn {
2748
2748
  async fetchFileBlob(t, n) {
2749
2749
  return await ae(t, {
2750
2750
  responseType: "blob",
2751
- onDownloadProgress: (s) => {
2751
+ onDownloadProgress: (o) => {
2752
2752
  try {
2753
- if (n && s.lengthComputable) {
2754
- const o = s.loaded / s.total;
2755
- n(o);
2753
+ if (n && o.lengthComputable) {
2754
+ const s = o.loaded / o.total;
2755
+ n(s);
2756
2756
  }
2757
2757
  } catch {
2758
2758
  }
@@ -2762,8 +2762,8 @@ class Zn {
2762
2762
  });
2763
2763
  }
2764
2764
  async viewFileById(t, n) {
2765
- const r = await this.fetchFileBlob(`/files/${t}/view`, n), s = URL.createObjectURL(r);
2766
- window.open(s, "_blank"), setTimeout(() => URL.revokeObjectURL(s), 6e4);
2765
+ const r = await this.fetchFileBlob(`/files/${t}/view`, n), o = URL.createObjectURL(r);
2766
+ window.open(o, "_blank"), setTimeout(() => URL.revokeObjectURL(o), 6e4);
2767
2767
  }
2768
2768
  async getFileBlob(t, n) {
2769
2769
  return await this.fetchFileBlob(`/files/${t}/view`, n);
@@ -2772,30 +2772,30 @@ class Zn {
2772
2772
  return await (await this.fetchFileBlob(`/files/${t}/view`, n)).text();
2773
2773
  }
2774
2774
  async downloadFileById(t, n) {
2775
- const r = await this.fetchFileBlob(`/files/${t}/download`, n), s = URL.createObjectURL(r);
2776
- let o = `file_${t}`;
2775
+ const r = await this.fetchFileBlob(`/files/${t}/download`, n), o = URL.createObjectURL(r);
2776
+ let s = `file_${t}`;
2777
2777
  try {
2778
2778
  const i = await ae(`/files/${t}`);
2779
- o = (i == null ? void 0 : i.filename) ?? o;
2779
+ s = (i == null ? void 0 : i.filename) ?? s;
2780
2780
  } catch {
2781
2781
  }
2782
2782
  const a = document.createElement("a");
2783
- a.href = s, a.download = o, document.body.appendChild(a), a.click(), a.remove(), setTimeout(() => URL.revokeObjectURL(s), 6e4);
2783
+ a.href = o, a.download = s, document.body.appendChild(a), a.click(), a.remove(), setTimeout(() => URL.revokeObjectURL(o), 6e4);
2784
2784
  }
2785
2785
  async getFileInfo(t) {
2786
2786
  return await ae(`/files/${t}`);
2787
2787
  }
2788
2788
  async listFiles(t, n = 50, r = 0) {
2789
- const s = { limit: n, offset: r };
2790
- return t && (s.thread_id = t), await ae("/files", { params: s });
2789
+ const o = { limit: n, offset: r };
2790
+ return t && (o.thread_id = t), await ae("/files", { params: o });
2791
2791
  }
2792
2792
  async uploadFile(t, n, r) {
2793
- const s = new FormData();
2794
- return s.append("file", t), n && s.append("thread_id", n), await Ze("/files/upload-form", s, {
2795
- onUploadProgress: (o) => {
2793
+ const o = new FormData();
2794
+ return o.append("file", t), n && o.append("thread_id", n), await Ze("/files/upload-form", o, {
2795
+ onUploadProgress: (s) => {
2796
2796
  try {
2797
- if (r && o.lengthComputable) {
2798
- const a = o.loaded / o.total;
2797
+ if (r && s.lengthComputable) {
2798
+ const a = s.loaded / s.total;
2799
2799
  r(a);
2800
2800
  }
2801
2801
  } catch {
@@ -2842,53 +2842,53 @@ const tr = new er(), Lt = Ce(null);
2842
2842
  function nr({ children: e, apiConfig: t }) {
2843
2843
  const n = zt, r = tr;
2844
2844
  if (t) {
2845
- const o = n.baseUrl, a = r.baseUrl, i = n.getAuthToken(), u = t.requestTimeoutMs !== void 0 || t.historyTimeoutMs !== void 0;
2846
- (t.baseUrl || t.chatBaseUrl || u) && (u || t.chatBaseUrl && t.chatBaseUrl !== o || t.baseUrl && !o.startsWith(t.baseUrl)) && n.updateConfig(t), (t.baseUrl || t.authBaseUrl) && (t.authBaseUrl && t.authBaseUrl !== a || t.baseUrl && !a.startsWith(t.baseUrl)) && r.updateConfig(t), t.apiKey !== void 0 && t.apiKey !== i && (n.updateConfig({ apiKey: t.apiKey }), r.updateConfig({ apiKey: t.apiKey }));
2845
+ const s = n.baseUrl, a = r.baseUrl, i = n.getAuthToken(), u = t.requestTimeoutMs !== void 0 || t.historyTimeoutMs !== void 0;
2846
+ (t.baseUrl || t.chatBaseUrl || u) && (u || t.chatBaseUrl && t.chatBaseUrl !== s || t.baseUrl && !s.startsWith(t.baseUrl)) && n.updateConfig(t), (t.baseUrl || t.authBaseUrl) && (t.authBaseUrl && t.authBaseUrl !== a || t.baseUrl && !a.startsWith(t.baseUrl)) && r.updateConfig(t), t.apiKey !== void 0 && t.apiKey !== i && (n.updateConfig({ apiKey: t.apiKey }), r.updateConfig({ apiKey: t.apiKey }));
2847
2847
  }
2848
- const s = {
2848
+ const o = {
2849
2849
  token: n.getAuthToken(),
2850
- setToken: (o) => {
2851
- n.setAuthToken(o), r.setAuthToken(o);
2850
+ setToken: (s) => {
2851
+ n.setAuthToken(s), r.setAuthToken(s);
2852
2852
  },
2853
2853
  chatApi: n,
2854
2854
  authApi: r,
2855
2855
  fileApi: Rt,
2856
2856
  baseUrl: n.baseUrl
2857
2857
  };
2858
- return /* @__PURE__ */ de(Lt.Provider, { value: s, children: e });
2858
+ return /* @__PURE__ */ de(Lt.Provider, { value: o, children: e });
2859
2859
  }
2860
2860
  async function rr(e) {
2861
2861
  return await new Promise((t, n) => {
2862
2862
  const r = new FileReader();
2863
2863
  r.onload = () => {
2864
2864
  try {
2865
- const s = r.result, o = new Uint8Array(s);
2865
+ const o = r.result, s = new Uint8Array(o);
2866
2866
  let a = "";
2867
- const i = o.byteLength;
2868
- for (let u = 0; u < i; u++) a += String.fromCharCode(o[u]);
2867
+ const i = s.byteLength;
2868
+ for (let u = 0; u < i; u++) a += String.fromCharCode(s[u]);
2869
2869
  t(btoa(a));
2870
- } catch (s) {
2871
- n(s);
2870
+ } catch (o) {
2871
+ n(o);
2872
2872
  }
2873
- }, r.onerror = (s) => n(s), r.readAsArrayBuffer(e);
2873
+ }, r.onerror = (o) => n(o), r.readAsArrayBuffer(e);
2874
2874
  });
2875
2875
  }
2876
- async function or(e = []) {
2876
+ async function sr(e = []) {
2877
2877
  const t = [], n = [];
2878
2878
  for (const r of e)
2879
2879
  try {
2880
- const s = await rr(r), o = r.type || "application/octet-stream";
2880
+ const o = await rr(r), s = r.type || "application/octet-stream";
2881
2881
  n.push({
2882
2882
  filename: r.name,
2883
- data: s,
2884
- mime_type: o
2885
- }), o.startsWith("image/") ? t.push({
2883
+ data: o,
2884
+ mime_type: s
2885
+ }), s.startsWith("image/") ? t.push({
2886
2886
  type: "image_url",
2887
- image_url: { url: `data:${o};base64,${s}` }
2887
+ image_url: { url: `data:${s};base64,${o}` }
2888
2888
  }) : t.push({
2889
2889
  type: "file",
2890
- url: `data:${o};base64,${s}`,
2891
- mimeType: o,
2890
+ url: `data:${s};base64,${o}`,
2891
+ mimeType: s,
2892
2892
  name: r.name,
2893
2893
  size: r.size
2894
2894
  });
@@ -2896,10 +2896,10 @@ async function or(e = []) {
2896
2896
  }
2897
2897
  return { contentParts: t, filesInfo: n };
2898
2898
  }
2899
- function sr(e) {
2899
+ function or(e) {
2900
2900
  return e.filter((t) => t.type === "text").map((t) => t.text).join("");
2901
2901
  }
2902
- function io(e) {
2902
+ function is(e) {
2903
2903
  if (e == null) return null;
2904
2904
  const t = String(e).trim();
2905
2905
  return t.length > 0 ? t : null;
@@ -2911,13 +2911,13 @@ function ar(e) {
2911
2911
  name: e.name ?? void 0
2912
2912
  };
2913
2913
  }
2914
- function co(e) {
2914
+ function cs(e) {
2915
2915
  var n;
2916
2916
  if (e.name && e.name.trim()) return e.name;
2917
2917
  const t = (n = e.additionalKwargs) == null ? void 0 : n.agentName;
2918
2918
  return typeof t == "string" && t.trim() ? t : e.model && e.model.includes("/") ? e.model.split("/").pop() || null : e.model || null;
2919
2919
  }
2920
- function lo(e) {
2920
+ function ls(e) {
2921
2921
  const t = e.updatedAt ?? e.createdAt ?? "", n = Array.isArray(e.content) ? e.content.map((a) => {
2922
2922
  switch (a.type) {
2923
2923
  case "text":
@@ -2927,8 +2927,8 @@ function lo(e) {
2927
2927
  default:
2928
2928
  return a.type === "interrupt" ? "interrupt" : "unknown";
2929
2929
  }
2930
- }).join("|") : "", r = "checkpointId" in e && e.checkpointId ? `cp:${e.checkpointId}` : "", s = "checkpointNs" in e && e.checkpointNs ? `ns:${e.checkpointNs}` : "", o = [r, s].filter(Boolean).join("|");
2931
- return `${e.id}:${t}:${n}${o ? `:${o}` : ""}`;
2930
+ }).join("|") : "", r = "checkpointId" in e && e.checkpointId ? `cp:${e.checkpointId}` : "", o = "checkpointNs" in e && e.checkpointNs ? `ns:${e.checkpointNs}` : "", s = [r, o].filter(Boolean).join("|");
2931
+ return `${e.id}:${t}:${n}${s ? `:${s}` : ""}`;
2932
2932
  }
2933
2933
  function Me() {
2934
2934
  const e = je(Lt);
@@ -3009,33 +3009,33 @@ function fr(e, t) {
3009
3009
  return "type" in n || (n.type = e), n;
3010
3010
  }
3011
3011
  function pr(e = {}) {
3012
- const t = e.baseUrl || "", n = e.streamPath ?? "/stream", [r, s] = H(e.token ?? null), o = W(e.headers ?? {}), a = e.credentials ?? "include", i = W(e);
3012
+ const t = e.baseUrl || "", n = e.streamPath ?? "/stream", [r, o] = H(e.token ?? null), s = W(e.headers ?? {}), a = e.credentials ?? "include", i = W(e);
3013
3013
  Y(() => {
3014
3014
  i.current = e;
3015
3015
  }, [e]);
3016
- const u = _((y) => {
3017
- var L, M, $, U, V, P, F, N, j, G;
3018
- const I = i.current;
3019
- if (!I) return;
3020
- (L = I.onEvent) == null || L.call(I, y), y.type === "thread_info" && ((M = I.onThreadInfo) == null || M.call(I, y)), y.type === "values" && (($ = I.handleValuesEvent) == null || $.call(I, y)), y.type === "metadata" && ((U = I.onMetadataEvent) == null || U.call(I, y)), typeof y.type == "string" && (y.type === "custom" || y.type.startsWith("custom.")) && ((V = I.onCustomEvent) == null || V.call(I, y)), y.type === "updates" && ((P = I.onUpdateEvent) == null || P.call(I, y)), y.type === "tool.end" ? (F = I.onToolEnd) == null || F.call(I, y) : y.type === "tool.start" && ((N = I.onToolStart) == null || N.call(I, y)), y.type === "heartbeat" && ((j = I.onHeartbeat) == null || j.call(I, y)), y.type === "token" && ((G = I.onToken) == null || G.call(I, y.token));
3021
- }, []), [l, c] = H(!1), [d, p] = H(null), [m, v] = H(!1), [f, b] = H(null), x = W(null), S = W(!0), A = W(null), w = _((y) => {
3022
- s(y);
3023
- }, []), k = _(() => {
3024
- p(null), b(null);
3025
- }, []), h = _(() => {
3016
+ const u = N((y) => {
3017
+ var L, M, $, U, V, P, F, E, j, G;
3018
+ const v = i.current;
3019
+ if (!v) return;
3020
+ (L = v.onEvent) == null || L.call(v, y), y.type === "thread_info" && ((M = v.onThreadInfo) == null || M.call(v, y)), y.type === "values" && (($ = v.handleValuesEvent) == null || $.call(v, y)), y.type === "metadata" && ((U = v.onMetadataEvent) == null || U.call(v, y)), typeof y.type == "string" && (y.type === "custom" || y.type.startsWith("custom.")) && ((V = v.onCustomEvent) == null || V.call(v, y)), y.type === "updates" && ((P = v.onUpdateEvent) == null || P.call(v, y)), y.type === "tool.end" ? (F = v.onToolEnd) == null || F.call(v, y) : y.type === "tool.start" && ((E = v.onToolStart) == null || E.call(v, y)), y.type === "heartbeat" && ((j = v.onHeartbeat) == null || j.call(v, y)), y.type === "token" && ((G = v.onToken) == null || G.call(v, y.token));
3021
+ }, []), [l, c] = H(!1), [d, m] = H(null), [p, I] = H(!1), [f, h] = H(null), x = W(null), S = W(!0), A = W(null), w = N((y) => {
3022
+ o(y);
3023
+ }, []), k = N(() => {
3024
+ m(null), h(null);
3025
+ }, []), b = N(() => {
3026
3026
  var M, $;
3027
3027
  console.debug("[use-chat] stop() invoked - aborting stream");
3028
- const y = (M = A.current) == null ? void 0 : M.threadId, I = ($ = A.current) == null ? void 0 : $.runId, E = () => {
3028
+ const y = (M = A.current) == null ? void 0 : M.threadId, v = ($ = A.current) == null ? void 0 : $.runId, _ = () => {
3029
3029
  var U;
3030
- (U = x.current) == null || U.abort(), x.current = null, A.current = null, c(!1), v(!1);
3030
+ (U = x.current) == null || U.abort(), x.current = null, A.current = null, c(!1), I(!1);
3031
3031
  };
3032
- (I || y ? zt.cancelRun(I || y).catch((U) => {
3032
+ (v || y ? zt.cancelRun(v || y).catch((U) => {
3033
3033
  console.warn("[use-chat] cancel run failed:", U);
3034
- }) : Promise.resolve()).finally(E);
3035
- }, []), T = _(
3034
+ }) : Promise.resolve()).finally(_);
3035
+ }, []), T = N(
3036
3036
  (y) => {
3037
3037
  x.current && (x.current.abort(), x.current = null);
3038
- const I = {
3038
+ const v = {
3039
3039
  text: typeof y.content == "string" ? y.content : y.text,
3040
3040
  threadId: y.threadId,
3041
3041
  attachments: y.attachments,
@@ -3049,32 +3049,32 @@ function pr(e = {}) {
3049
3049
  edit: y.edit ?? !1,
3050
3050
  command: y.command
3051
3051
  };
3052
- c(!0), p(null), b(null);
3053
- const E = new AbortController();
3054
- x.current = E;
3052
+ c(!0), m(null), h(null);
3053
+ const _ = new AbortController();
3054
+ x.current = _;
3055
3055
  let L = null, M = !1;
3056
3056
  return A.current = {
3057
- threadId: I.threadId ?? void 0,
3057
+ threadId: v.threadId ?? void 0,
3058
3058
  runId: void 0,
3059
3059
  // Will be updated from headers
3060
3060
  headers: {},
3061
3061
  isStreaming: !0
3062
3062
  }, (async () => {
3063
- var $, U, V, P, F, N;
3063
+ var $, U, V, P, F, E;
3064
3064
  try {
3065
3065
  let j = {};
3066
3066
  try {
3067
3067
  if (r)
3068
3068
  j = { Authorization: `Bearer ${r}` };
3069
3069
  else if (typeof window < "u") {
3070
- const se = window.__AUTH_TOKEN__, he = (($ = window.localStorage) == null ? void 0 : $.getItem(ze.authToken)) || null;
3070
+ const oe = window.__AUTH_TOKEN__, he = (($ = window.localStorage) == null ? void 0 : $.getItem(ze.authToken)) || null;
3071
3071
  let X = null;
3072
3072
  try {
3073
3073
  const be = (U = window.localStorage) == null ? void 0 : U.getItem(ze.chatSettings);
3074
3074
  be && (X = ((V = JSON.parse(be)) == null ? void 0 : V.apiKey) || null);
3075
3075
  } catch {
3076
3076
  }
3077
- const Q = se || he || X || null;
3077
+ const Q = oe || he || X || null;
3078
3078
  Q && (j = { Authorization: `Bearer ${Q}` });
3079
3079
  }
3080
3080
  } catch {
@@ -3090,7 +3090,7 @@ function pr(e = {}) {
3090
3090
  const g = {
3091
3091
  ...j,
3092
3092
  ...G,
3093
- ...o.current
3093
+ ...s.current
3094
3094
  }, z = {
3095
3095
  "Content-Type": "application/json",
3096
3096
  Accept: "text/event-stream",
@@ -3098,8 +3098,8 @@ function pr(e = {}) {
3098
3098
  }, C = await fetch(t + n, {
3099
3099
  method: "POST",
3100
3100
  headers: z,
3101
- body: JSON.stringify(I),
3102
- signal: E.signal,
3101
+ body: JSON.stringify(v),
3102
+ signal: _.signal,
3103
3103
  credentials: a
3104
3104
  });
3105
3105
  if (A.current && (A.current.headers = g), !C.ok || !C.body) {
@@ -3109,21 +3109,21 @@ function pr(e = {}) {
3109
3109
  C.status,
3110
3110
  J == null ? void 0 : J.slice(0, 500)
3111
3111
  );
3112
- const se = `stream ${C.status}${J ? ": " + J : ""}`;
3113
- throw se && (p(se), L = "error"), new Error(se);
3112
+ const oe = `stream ${C.status}${J ? ": " + J : ""}`;
3113
+ throw oe && (m(oe), L = "error"), new Error(oe);
3114
3114
  }
3115
- v(!0);
3115
+ I(!0);
3116
3116
  const O = C.body.getReader(), D = new TextDecoder();
3117
3117
  let K = "", B = 0, ee = Date.now();
3118
3118
  const ie = setInterval(() => {
3119
- Date.now() - ee > 18e5 && (p("Stream idle timeout"), L = "error", E.abort());
3119
+ Date.now() - ee > 18e5 && (m("Stream idle timeout"), L = "error", _.abort());
3120
3120
  }, 5e3), ye = 1024 * 1024;
3121
3121
  try {
3122
- const J = C.headers.get("X-Thread-Id") || C.headers.get("x-thread-id"), se = C.headers.get("X-Run-Id") || C.headers.get("x-run-id");
3122
+ const J = C.headers.get("X-Thread-Id") || C.headers.get("x-thread-id"), oe = C.headers.get("X-Run-Id") || C.headers.get("x-run-id");
3123
3123
  for (A.current && (A.current = {
3124
3124
  ...A.current,
3125
3125
  threadId: J ?? A.current.threadId,
3126
- runId: se ?? A.current.runId
3126
+ runId: oe ?? A.current.runId
3127
3127
  }); ; ) {
3128
3128
  const { value: he, done: X } = await O.read();
3129
3129
  if (X) break;
@@ -3177,13 +3177,13 @@ function pr(e = {}) {
3177
3177
  u(re);
3178
3178
  }
3179
3179
  }
3180
- L === null && !E.signal.aborted && (L = "complete");
3180
+ L === null && !_.signal.aborted && (L = "complete");
3181
3181
  } catch (J) {
3182
3182
  if (J.name === "AbortError")
3183
3183
  L = L ?? "aborted";
3184
3184
  else {
3185
- const se = J.message || String(J);
3186
- L = "error", p(se);
3185
+ const oe = J.message || String(J);
3186
+ L = "error", m(oe);
3187
3187
  }
3188
3188
  } finally {
3189
3189
  try {
@@ -3199,7 +3199,7 @@ function pr(e = {}) {
3199
3199
  L = L ?? "aborted";
3200
3200
  else {
3201
3201
  const G = j.message || String(j);
3202
- L = "error", p(G), M || (M = !0, (N = e.onConnectionError) == null || N.call(e, G));
3202
+ L = "error", m(G), M || (M = !0, (E = e.onConnectionError) == null || E.call(e, G));
3203
3203
  }
3204
3204
  } finally {
3205
3205
  try {
@@ -3216,7 +3216,7 @@ function pr(e = {}) {
3216
3216
  } catch (j) {
3217
3217
  console.warn("[use-chat] onClosed callback failed", j);
3218
3218
  }
3219
- c(!1), v(!1), x.current = null, A.current = null;
3219
+ c(!1), I(!1), x.current = null, A.current = null;
3220
3220
  }
3221
3221
  })(), Promise.resolve();
3222
3222
  },
@@ -3236,9 +3236,9 @@ function pr(e = {}) {
3236
3236
  lastCheckpointId: null,
3237
3237
  // Deprecated: use checkpoint from reducer
3238
3238
  lastSeq: 0,
3239
- connected: m,
3239
+ connected: p,
3240
3240
  stream: T,
3241
- stop: h,
3241
+ stop: b,
3242
3242
  clear: k,
3243
3243
  setToken: w,
3244
3244
  values: {},
@@ -3246,7 +3246,7 @@ function pr(e = {}) {
3246
3246
  interrupt: () => Promise.resolve(),
3247
3247
  resume: () => Promise.resolve(),
3248
3248
  goto: () => Promise.resolve(),
3249
- connectionState: d ? "error" : l ? m ? "connected" : "connecting" : "idle",
3249
+ connectionState: d ? "error" : l ? p ? "connected" : "connecting" : "idle",
3250
3250
  messages: [],
3251
3251
  // useStream doesn't maintain messages, use useChatSession instead
3252
3252
  submit: T
@@ -3257,22 +3257,22 @@ function gr({
3257
3257
  initialThreadId: t = null,
3258
3258
  onError: n,
3259
3259
  onThreadChange: r,
3260
- onCurrentThreadDeleted: s
3260
+ onCurrentThreadDeleted: o
3261
3261
  }) {
3262
- const [o, a] = H([]), [i, u] = H(t), [l, c] = H(!1), [d, p] = H(null), m = W(i), v = W(/* @__PURE__ */ new Map());
3262
+ const [s, a] = H([]), [i, u] = H(t), [l, c] = H(!1), [d, m] = H(null), p = W(i), I = W(/* @__PURE__ */ new Map());
3263
3263
  Y(() => {
3264
- m.current = i;
3264
+ p.current = i;
3265
3265
  }, [i]), Y(() => {
3266
- t !== void 0 && t !== m.current && u(t);
3266
+ t !== void 0 && t !== p.current && u(t);
3267
3267
  }, [t]);
3268
- const f = _(async () => {
3269
- c(!0), p(null);
3268
+ const f = N(async () => {
3269
+ c(!0), m(null);
3270
3270
  try {
3271
3271
  const k = await e.listThreads();
3272
3272
  a(k ?? []);
3273
3273
  } catch (k) {
3274
- const h = String(k);
3275
- p(h), n == null || n(h);
3274
+ const b = String(k);
3275
+ m(b), n == null || n(b);
3276
3276
  } finally {
3277
3277
  c(!1);
3278
3278
  }
@@ -3282,10 +3282,10 @@ function gr({
3282
3282
  }, [f]), Y(() => {
3283
3283
  r == null || r(i);
3284
3284
  }, [i, r]);
3285
- const b = _(
3286
- async (k, h) => {
3285
+ const h = N(
3286
+ async (k, b) => {
3287
3287
  try {
3288
- const T = h && typeof h == "object" ? { id: h.id, name: h.name ?? "" } : void 0, y = await e.createThread(k, T);
3288
+ const T = b && typeof b == "object" ? { id: b.id, name: b.name ?? "" } : void 0, y = await e.createThread(k, T);
3289
3289
  return u(y.threadId), await f(), y.threadId;
3290
3290
  } catch (T) {
3291
3291
  const y = String(T);
@@ -3293,27 +3293,27 @@ function gr({
3293
3293
  }
3294
3294
  },
3295
3295
  [e, n, f]
3296
- ), x = _(
3296
+ ), x = N(
3297
3297
  async (k) => {
3298
- const h = o;
3299
- a((y) => y.filter((I) => I.threadId !== k));
3298
+ const b = s;
3299
+ a((y) => y.filter((v) => v.threadId !== k));
3300
3300
  const T = new AbortController();
3301
- v.current.set(k, T);
3301
+ I.current.set(k, T);
3302
3302
  try {
3303
- await e.deleteThread(k), m.current === k && (u(null), s == null || s());
3303
+ await e.deleteThread(k), p.current === k && (u(null), o == null || o());
3304
3304
  } catch (y) {
3305
- a(h);
3306
- const I = String(y);
3307
- n == null || n(I);
3305
+ a(b);
3306
+ const v = String(y);
3307
+ n == null || n(v);
3308
3308
  } finally {
3309
- v.current.delete(k);
3309
+ I.current.delete(k);
3310
3310
  }
3311
3311
  },
3312
- [e, s, n, o]
3313
- ), S = _(
3314
- async (k, h) => {
3312
+ [e, o, n, s]
3313
+ ), S = N(
3314
+ async (k, b) => {
3315
3315
  try {
3316
- await e.updateThread(k, h), await f();
3316
+ await e.updateThread(k, b), await f();
3317
3317
  } catch (T) {
3318
3318
  n == null || n(String(T));
3319
3319
  }
@@ -3321,15 +3321,15 @@ function gr({
3321
3321
  [e, n, f]
3322
3322
  ), A = Z(
3323
3323
  () => ({
3324
- createThread: b,
3324
+ createThread: h,
3325
3325
  deleteThread: x,
3326
3326
  renameThread: S,
3327
3327
  refreshThreads: f
3328
3328
  }),
3329
- [b, x, S, f]
3330
- ), w = _((k) => {
3329
+ [h, x, S, f]
3330
+ ), w = N((k) => {
3331
3331
  if (!(k != null && k.threadId)) return;
3332
- const h = {
3332
+ const b = {
3333
3333
  threadId: k.threadId,
3334
3334
  title: k.title || `Thread ${k.threadId.slice(0, 8)}`,
3335
3335
  project: k.project,
@@ -3339,20 +3339,20 @@ function gr({
3339
3339
  };
3340
3340
  a((T) => {
3341
3341
  let y = !1;
3342
- const I = T.map((E) => E.threadId === h.threadId ? (y = !0, console.debug("[useThreadsState] thread_info: updating existing thread", h.threadId), {
3343
- ...E,
3344
- title: h.title ?? E.title,
3345
- project: h.project ?? E.project,
3346
- updatedAt: h.updatedAt ?? E.updatedAt,
3347
- messageCount: h.messageCount ?? E.messageCount
3348
- }) : E);
3349
- return y ? I : (console.debug("[useThreadsState] thread_info: adding thread to list", h.threadId), [h, ...T]);
3342
+ const v = T.map((_) => _.threadId === b.threadId ? (y = !0, console.debug("[useThreadsState] thread_info: updating existing thread", b.threadId), {
3343
+ ..._,
3344
+ title: b.title ?? _.title,
3345
+ project: b.project ?? _.project,
3346
+ updatedAt: b.updatedAt ?? _.updatedAt,
3347
+ messageCount: b.messageCount ?? _.messageCount
3348
+ }) : _);
3349
+ return y ? v : (console.debug("[useThreadsState] thread_info: adding thread to list", b.threadId), [b, ...T]);
3350
3350
  });
3351
3351
  }, []);
3352
3352
  return {
3353
- threads: o,
3353
+ threads: s,
3354
3354
  currentThreadId: i,
3355
- currentThreadIdRef: m,
3355
+ currentThreadIdRef: p,
3356
3356
  setCurrentThreadId: u,
3357
3357
  isLoadingThreads: l,
3358
3358
  threadsError: d,
@@ -3367,45 +3367,45 @@ function mr({
3367
3367
  onError: n,
3368
3368
  onThreadChange: r
3369
3369
  }) {
3370
- const { chatApi: s } = Me(), {
3371
- threads: o,
3370
+ const { chatApi: o } = Me(), {
3371
+ threads: s,
3372
3372
  currentThreadId: a,
3373
3373
  setCurrentThreadId: i,
3374
3374
  currentThreadIdRef: u,
3375
3375
  isLoadingThreads: l,
3376
3376
  threadsError: c,
3377
3377
  actions: d,
3378
- addThreadFromEvent: p
3378
+ addThreadFromEvent: m
3379
3379
  } = gr({
3380
- api: s,
3380
+ api: o,
3381
3381
  initialThreadId: t,
3382
3382
  onError: n,
3383
3383
  onThreadChange: r
3384
- }), m = Z(
3384
+ }), p = Z(
3385
3385
  () => ({
3386
- threads: o,
3386
+ threads: s,
3387
3387
  currentThreadId: a,
3388
3388
  setCurrentThreadId: i,
3389
3389
  currentThreadIdRef: u,
3390
3390
  isLoading: l,
3391
3391
  error: c,
3392
3392
  actions: d,
3393
- addThreadFromEvent: p
3393
+ addThreadFromEvent: m
3394
3394
  }),
3395
3395
  [
3396
- o,
3396
+ s,
3397
3397
  a,
3398
3398
  i,
3399
3399
  u,
3400
3400
  l,
3401
3401
  c,
3402
3402
  d,
3403
- p
3403
+ m
3404
3404
  ]
3405
3405
  );
3406
- return /* @__PURE__ */ de(Ut.Provider, { value: m, children: e });
3406
+ return /* @__PURE__ */ de(Ut.Provider, { value: p, children: e });
3407
3407
  }
3408
- function ot(e) {
3408
+ function st(e) {
3409
3409
  const t = je(Ut);
3410
3410
  if (!t && !(e != null && e.optional)) throw new Error("useThreads must be used within a ThreadsProvider");
3411
3411
  return t;
@@ -3438,8 +3438,8 @@ function yr(e, t) {
3438
3438
  }
3439
3439
  function hr(e, t, n) {
3440
3440
  return e.find((r) => {
3441
- const s = Bt(r);
3442
- return !!((s == null ? void 0 : s.id) === t || n && r.toolCallId === n);
3441
+ const o = Bt(r);
3442
+ return !!((o == null ? void 0 : o.id) === t || n && r.toolCallId === n);
3443
3443
  }) ?? null;
3444
3444
  }
3445
3445
  function Fe(e) {
@@ -3452,8 +3452,8 @@ function Ft(e, t, n) {
3452
3452
  function br(e, t, n) {
3453
3453
  for (let r = e.length - 1; r >= 0; r--)
3454
3454
  if (e[r].role === "assistant") {
3455
- const o = { ...e[r], checkpointId: t, checkpointNs: n ?? void 0 };
3456
- return Ft(e, r, o);
3455
+ const s = { ...e[r], checkpointId: t, checkpointNs: n ?? void 0 };
3456
+ return Ft(e, r, s);
3457
3457
  }
3458
3458
  return e;
3459
3459
  }
@@ -3484,15 +3484,15 @@ function wr(e, t) {
3484
3484
  messages: Fe(((n = t.payload) == null ? void 0 : n.messages) ?? [])
3485
3485
  };
3486
3486
  case "user_message": {
3487
- const { message: r, editingMessageId: s } = t.payload;
3488
- if (s) {
3489
- const o = e.messages.findIndex((a) => (a.id || a.messageId || a.id) === s);
3490
- if (o !== -1) {
3491
- const a = e.messages[o], i = { ...r, id: s };
3487
+ const { message: r, editingMessageId: o } = t.payload;
3488
+ if (o) {
3489
+ const s = e.messages.findIndex((a) => (a.id || a.messageId || a.id) === o);
3490
+ if (s !== -1) {
3491
+ const a = e.messages[s], i = { ...r, id: o };
3492
3492
  return {
3493
3493
  ...e,
3494
3494
  status: "streaming",
3495
- messages: [...e.messages.slice(0, o), i],
3495
+ messages: [...e.messages.slice(0, s), i],
3496
3496
  assemblingId: null,
3497
3497
  lastCheckpointId: a.checkpointId || e.lastCheckpointId || null,
3498
3498
  error: null
@@ -3509,7 +3509,7 @@ function wr(e, t) {
3509
3509
  };
3510
3510
  }
3511
3511
  case "seed": {
3512
- const r = Fe(t.payload.messages), s = {
3512
+ const r = Fe(t.payload.messages), o = {
3513
3513
  ...e,
3514
3514
  status: "idle",
3515
3515
  messages: r,
@@ -3518,32 +3518,32 @@ function wr(e, t) {
3518
3518
  taskMessagesByScope: {},
3519
3519
  error: null
3520
3520
  };
3521
- return Object.prototype.hasOwnProperty.call(t.payload, "checkpointId") && (s.lastCheckpointId = t.payload.checkpointId ?? null), Object.prototype.hasOwnProperty.call(t.payload, "checkpointNs") && (s.lastCheckpointNs = t.payload.checkpointNs ?? null), Object.prototype.hasOwnProperty.call(t.payload, "values") && (s.values = t.payload.values ?? {}), s;
3521
+ return Object.prototype.hasOwnProperty.call(t.payload, "checkpointId") && (o.lastCheckpointId = t.payload.checkpointId ?? null), Object.prototype.hasOwnProperty.call(t.payload, "checkpointNs") && (o.lastCheckpointNs = t.payload.checkpointNs ?? null), Object.prototype.hasOwnProperty.call(t.payload, "values") && (o.values = t.payload.values ?? {}), o;
3522
3522
  }
3523
3523
  case "prepend": {
3524
3524
  const r = Fe(t.payload.messages);
3525
3525
  if (!r.length) return e;
3526
- const s = new Set(e.messages.map((a) => a.id)), o = r.filter((a) => !s.has(a.id));
3527
- return o.length ? { ...e, messages: [...o, ...e.messages] } : e;
3526
+ const o = new Set(e.messages.map((a) => a.id)), s = r.filter((a) => !o.has(a.id));
3527
+ return s.length ? { ...e, messages: [...s, ...e.messages] } : e;
3528
3528
  }
3529
3529
  case "event":
3530
3530
  return pt(e, t.payload.ev);
3531
3531
  case "batch": {
3532
3532
  const { events: r } = t.payload;
3533
- return r.length ? r.reduce((s, o) => pt(s, o), e) : e;
3533
+ return r.length ? r.reduce((o, s) => pt(o, s), e) : e;
3534
3534
  }
3535
3535
  default:
3536
3536
  return e;
3537
3537
  }
3538
3538
  }
3539
3539
  function kr(e = []) {
3540
- const [t, n] = Wt(wr, { ...Ot, messages: e }), r = W([]), s = W(null), o = _(() => {
3541
- s.current !== null && typeof window < "u" && window.cancelAnimationFrame(s.current), s.current = null;
3540
+ const [t, n] = Wt(wr, { ...Ot, messages: e }), r = W([]), o = W(null), s = N(() => {
3541
+ o.current !== null && typeof window < "u" && window.cancelAnimationFrame(o.current), o.current = null;
3542
3542
  const l = r.current;
3543
3543
  l.length && (r.current = [], n({ type: "batch", payload: { events: l } }));
3544
- }, []), a = _(() => {
3545
- typeof window < "u" && typeof window.requestAnimationFrame == "function" ? s.current === null && (s.current = window.requestAnimationFrame(() => o())) : setTimeout(o, 8);
3546
- }, [o]), i = _((l) => {
3544
+ }, []), a = N(() => {
3545
+ typeof window < "u" && typeof window.requestAnimationFrame == "function" ? o.current === null && (o.current = window.requestAnimationFrame(() => s())) : setTimeout(s, 8);
3546
+ }, [s]), i = N((l) => {
3547
3547
  r.current.push(l), a();
3548
3548
  }, [a]), u = Z(() => ({
3549
3549
  setStatus: (l, c) => n({ type: "status", payload: { status: l, error: c } }),
@@ -3555,14 +3555,14 @@ function kr(e = []) {
3555
3555
  return { state: t, dispatch: n, ...u };
3556
3556
  }
3557
3557
  function pt(e, t) {
3558
- const n = t.origin, r = t.scope, s = n === "task" || typeof r == "string" && r.startsWith("tools:");
3558
+ const n = t.origin, r = t.scope, o = n === "task" || typeof r == "string" && r.startsWith("tools:");
3559
3559
  if (t.type === "checkpoint") {
3560
- const o = t.checkpointNs ?? e.lastCheckpointNs ?? null, a = br(e.messages, t.checkpointId, o);
3561
- return { ...e, lastCheckpointId: t.checkpointId, lastCheckpointNs: o, messages: a };
3560
+ const s = t.checkpointNs ?? e.lastCheckpointNs ?? null, a = br(e.messages, t.checkpointId, s);
3561
+ return { ...e, lastCheckpointId: t.checkpointId, lastCheckpointNs: s, messages: a };
3562
3562
  }
3563
3563
  if (t.type === "status") {
3564
- const o = t.status === "completed" || t.status === "error" ? "idle" : t.status === "interrupted" ? "awaiting_input" : e.status;
3565
- return { ...e, status: o };
3564
+ const s = t.status === "completed" || t.status === "error" ? "idle" : t.status === "interrupted" ? "awaiting_input" : e.status;
3565
+ return { ...e, status: s };
3566
3566
  }
3567
3567
  if (t.type === "interrupt")
3568
3568
  return {
@@ -3576,68 +3576,68 @@ function pt(e, t) {
3576
3576
  }
3577
3577
  };
3578
3578
  if (t.type === "error") {
3579
- const o = {
3579
+ const s = {
3580
3580
  id: `err-${Date.now()}`,
3581
3581
  role: "system",
3582
3582
  content: [{ type: "text", text: `Error: ${t.message}` }],
3583
3583
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
3584
3584
  };
3585
- return { ...e, status: "error", error: t.message, messages: [...e.messages, o] };
3585
+ return { ...e, status: "error", error: t.message, messages: [...e.messages, s] };
3586
3586
  }
3587
3587
  if (t.type === "values") {
3588
- const o = t, a = o.values && typeof o.values == "object" ? { ...o.values } : {}, i = Array.isArray(o.messages) ? o.messages : Array.isArray(a.messages) ? a.messages : [];
3589
- if (!i.length && Object.keys(a).length === 0)
3588
+ const s = t, a = s.values && typeof s.values == "object" ? { ...s.values } : {}, i = Array.isArray(s.messages) || Array.isArray(a.messages), u = Array.isArray(s.messages) ? s.messages : Array.isArray(a.messages) ? a.messages : null;
3589
+ if (!i && Object.keys(a).length === 0)
3590
3590
  return e;
3591
- const u = Fe(i);
3592
- delete a.messages;
3593
- let l = e.lastCheckpointId, c = e.lastCheckpointNs;
3594
- const d = o.config || o.checkpoint, p = (d == null ? void 0 : d.configurable) || d;
3595
- if ((p != null && p.checkpoint_id || p != null && p.checkpointId) && (l = p.checkpoint_id || p.checkpointId, c = p.checkpoint_ns || p.checkpointNs || null), !l) {
3596
- for (let f = u.length - 1; f >= 0; f--)
3597
- if (u[f].checkpointId) {
3598
- l = u[f].checkpointId, c = u[f].checkpointNs ?? null;
3591
+ const l = u !== null ? Fe(u) : e.messages;
3592
+ a && delete a.messages;
3593
+ let c = e.lastCheckpointId, d = e.lastCheckpointNs;
3594
+ const m = s.config || s.checkpoint, p = (m == null ? void 0 : m.configurable) || m;
3595
+ if ((p != null && p.checkpoint_id || p != null && p.checkpointId) && (c = p.checkpoint_id || p.checkpointId, d = p.checkpoint_ns || p.checkpointNs || null), !c) {
3596
+ for (let h = l.length - 1; h >= 0; h--)
3597
+ if (l[h].checkpointId) {
3598
+ c = l[h].checkpointId, d = l[h].checkpointNs ?? null;
3599
3599
  break;
3600
3600
  }
3601
3601
  }
3602
- const m = o.interrupts || a.__interrupt__ || a.interrupts, v = Array.isArray(m) && m.length > 0 ? {
3603
- id: m[0].id || "native-interrupt",
3604
- value: m[0].value || m[0],
3605
- alternatives: m[0].alternatives
3602
+ const I = s.interrupts || a.__interrupt__ || a.interrupts, f = Array.isArray(I) && I.length > 0 ? {
3603
+ id: I[0].id || "native-interrupt",
3604
+ value: I[0].value || I[0],
3605
+ alternatives: I[0].alternatives
3606
3606
  } : null;
3607
- if (s) {
3608
- const f = typeof r == "string" && r.length > 0 ? r : "task";
3607
+ if (o) {
3608
+ const h = typeof r == "string" && r.length > 0 ? r : "task";
3609
3609
  return {
3610
3610
  ...e,
3611
- taskMessagesByScope: { ...e.taskMessagesByScope, [f]: u },
3611
+ taskMessagesByScope: { ...e.taskMessagesByScope, [h]: l },
3612
3612
  assemblingId: null
3613
3613
  };
3614
3614
  }
3615
3615
  return {
3616
3616
  ...e,
3617
- status: v ? "awaiting_input" : e.status === "streaming" ? "idle" : e.status,
3618
- messages: u,
3617
+ status: f ? "awaiting_input" : e.status === "streaming" ? "idle" : e.status,
3618
+ messages: l,
3619
3619
  assemblingId: null,
3620
- lastCheckpointId: l,
3621
- lastCheckpointNs: c,
3622
- pendingInterrupt: v,
3620
+ lastCheckpointId: c,
3621
+ lastCheckpointNs: d,
3622
+ pendingInterrupt: f,
3623
3623
  values: { ...e.values, ...a }
3624
3624
  };
3625
3625
  }
3626
3626
  if (t.type === "messages/metadata") {
3627
- const o = { ...e.messagesStreamMeta ?? {} }, a = t.metadata;
3627
+ const s = { ...e.messagesStreamMeta ?? {} }, a = t.metadata;
3628
3628
  return a && typeof a == "object" && Object.entries(a).forEach(([i, u]) => {
3629
3629
  const l = u == null ? void 0 : u.metadata;
3630
3630
  if (!l || typeof l != "object") return;
3631
- const c = o[i] ?? {};
3632
- o[i] = {
3631
+ const c = s[i] ?? {};
3632
+ s[i] = {
3633
3633
  ...c,
3634
3634
  lastSeq: t.seq ?? c.lastSeq ?? null,
3635
3635
  metadata: { ...c.metadata ?? {}, ...l }
3636
3636
  };
3637
- }), { ...e, messagesStreamMeta: o };
3637
+ }), { ...e, messagesStreamMeta: s };
3638
3638
  }
3639
3639
  if (t.type === "messages/partial" || t.type === "message.delta") {
3640
- const o = t.type === "messages/partial" ? t : {
3640
+ const s = t.type === "messages/partial" ? t : {
3641
3641
  ...t,
3642
3642
  type: "messages/partial",
3643
3643
  messages: t.delta ? [{
@@ -3648,32 +3648,32 @@ function pt(e, t) {
3648
3648
  origin: t.origin
3649
3649
  }] : []
3650
3650
  };
3651
- return Ir(e, o, s);
3651
+ return Ir(e, s, o);
3652
3652
  }
3653
- return t.type === "message.start" ? { ...e, assemblingId: t.id, status: "streaming" } : t.type === "message.end" ? { ...e, assemblingId: null } : t.type === "tool.start" ? { ...vr(e, t, s), status: "streaming" } : t.type === "tool.progress" ? xr(e, t, s) : t.type === "tool.end" ? Ar(e, t, s) : t.type === "artifact.update" ? Tr(e, t) : e;
3653
+ return t.type === "message.start" ? { ...e, assemblingId: t.id, status: "streaming" } : t.type === "message.end" ? { ...e, assemblingId: null } : t.type === "tool.start" ? { ...vr(e, t, o), status: "streaming" } : t.type === "tool.progress" ? xr(e, t, o) : t.type === "tool.end" ? Ar(e, t, o) : t.type === "artifact.update" ? Tr(e, t) : e;
3654
3654
  }
3655
3655
  function Ir(e, t, n) {
3656
- var m, v, f, b, x, S, A;
3656
+ var p, I, f, h, x, S, A;
3657
3657
  const r = t.messages;
3658
3658
  if (!r.length)
3659
3659
  return console.warn("[messagesReducer] Dropping messages/partial event without messages[]", t), e;
3660
- const s = r.find((w) => w.type === "ai" || w.type === "assistant" || w.role === "assistant");
3661
- if (!s) return e;
3662
- const o = s.id, a = s.content ?? "", i = typeof a == "string" ? [{ type: "text", text: a }] : Array.isArray(a) ? a.map((w) => typeof w == "string" ? { type: "text", text: w } : (w == null ? void 0 : w.type) === "text" ? { type: "text", text: typeof w.text == "string" ? w.text : w.content ?? "" } : ((w == null ? void 0 : w.type) === "reasoning", w)) : [], u = i.filter((w) => w.type === "text").map((w) => w.text).join(""), l = e.assemblingId !== o, c = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3660
+ const o = r.find((w) => w.type === "ai" || w.type === "assistant" || w.role === "assistant");
3661
+ if (!o) return e;
3662
+ const s = o.id, a = o.content ?? "", i = typeof a == "string" ? [{ type: "text", text: a }] : Array.isArray(a) ? a.map((w) => typeof w == "string" ? { type: "text", text: w } : (w == null ? void 0 : w.type) === "text" ? { type: "text", text: typeof w.text == "string" ? w.text : w.content ?? "" } : ((w == null ? void 0 : w.type) === "reasoning", w)) : [], u = i.filter((w) => w.type === "text").map((w) => w.text).join(""), l = e.assemblingId !== s, c = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3663
3663
  let d = n ? [...e.taskMessagesByScope[c] || []] : [...e.messages];
3664
- const p = (v = (m = e.messagesStreamMeta) == null ? void 0 : m[o]) == null ? void 0 : v.metadata;
3664
+ const m = (I = (p = e.messagesStreamMeta) == null ? void 0 : p[s]) == null ? void 0 : I.metadata;
3665
3665
  if (l) {
3666
3666
  const w = nt({
3667
- ...s,
3667
+ ...o,
3668
3668
  role: "assistant",
3669
3669
  content: i,
3670
3670
  scope: t.scope,
3671
3671
  origin: t.origin,
3672
- responseMetadata: { ...p, ...s.responseMetadata ?? {} }
3672
+ responseMetadata: { ...m, ...o.responseMetadata ?? {} }
3673
3673
  });
3674
3674
  w && d.push(w);
3675
3675
  } else {
3676
- const w = d.findIndex((k) => k.id === o);
3676
+ const w = d.findIndex((k) => k.id === s);
3677
3677
  if (w !== -1) {
3678
3678
  const k = d[w];
3679
3679
  d[w] = {
@@ -3681,7 +3681,7 @@ function Ir(e, t, n) {
3681
3681
  content: i,
3682
3682
  scope: t.scope ?? k.scope,
3683
3683
  origin: t.origin ?? k.origin,
3684
- responseMetadata: { ...p, ...k.responseMetadata, ...s.responseMetadata ?? {} }
3684
+ responseMetadata: { ...m, ...k.responseMetadata, ...o.responseMetadata ?? {} }
3685
3685
  };
3686
3686
  }
3687
3687
  }
@@ -3690,23 +3690,23 @@ function Ir(e, t, n) {
3690
3690
  status: "streaming",
3691
3691
  messages: n ? e.messages : d,
3692
3692
  taskMessagesByScope: n ? { ...e.taskMessagesByScope, [c]: d } : e.taskMessagesByScope,
3693
- assemblingId: o,
3693
+ assemblingId: s,
3694
3694
  messagesStreamMeta: {
3695
3695
  ...e.messagesStreamMeta ?? {},
3696
- [o]: {
3697
- ...((f = e.messagesStreamMeta) == null ? void 0 : f[o]) ?? {},
3698
- lastSeq: t.seq ?? ((x = (b = e.messagesStreamMeta) == null ? void 0 : b[o]) == null ? void 0 : x.lastSeq) ?? null,
3699
- lastText: u || (((A = (S = e.messagesStreamMeta) == null ? void 0 : S[o]) == null ? void 0 : A.lastText) ?? "")
3696
+ [s]: {
3697
+ ...((f = e.messagesStreamMeta) == null ? void 0 : f[s]) ?? {},
3698
+ lastSeq: t.seq ?? ((x = (h = e.messagesStreamMeta) == null ? void 0 : h[s]) == null ? void 0 : x.lastSeq) ?? null,
3699
+ lastText: u || (((A = (S = e.messagesStreamMeta) == null ? void 0 : S[s]) == null ? void 0 : A.lastText) ?? "")
3700
3700
  }
3701
3701
  }
3702
3702
  };
3703
3703
  }
3704
- function st(e, t) {
3704
+ function ot(e, t) {
3705
3705
  var n;
3706
3706
  if (!t) return -1;
3707
3707
  for (let r = e.length - 1; r >= 0; r--) {
3708
- const s = e[r];
3709
- if (s.role === "assistant" && ((n = s.toolCalls) != null && n.some((o) => o.id === t)))
3708
+ const o = e[r];
3709
+ if (o.role === "assistant" && ((n = o.toolCalls) != null && n.some((s) => s.id === t)))
3710
3710
  return r;
3711
3711
  }
3712
3712
  return -1;
@@ -3714,8 +3714,8 @@ function st(e, t) {
3714
3714
  function vr(e, t, n) {
3715
3715
  const r = t.id || t.callId;
3716
3716
  if (!r) return e;
3717
- const s = t.name || "tool", o = `Starting ${s}...`, a = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3718
- let i = n ? [...e.taskMessagesByScope[a] || []] : [...e.messages], u = st(i, r);
3717
+ const o = t.name || "tool", s = `Starting ${o}...`, a = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3718
+ let i = n ? [...e.taskMessagesByScope[a] || []] : [...e.messages], u = ot(i, r);
3719
3719
  if (u === -1) {
3720
3720
  for (let l = i.length - 1; l >= 0; l--)
3721
3721
  if (i[l].role === "assistant") {
@@ -3736,13 +3736,13 @@ function vr(e, t, n) {
3736
3736
  i.push(l), u = i.length - 1;
3737
3737
  }
3738
3738
  if (u !== -1) {
3739
- const l = i[u], c = [...l.toolCalls || []], d = c.findIndex((p) => p.id === r);
3740
- d >= 0 ? c[d] = { ...c[d], status: "running", content: o } : c.push({
3739
+ const l = i[u], c = [...l.toolCalls || []], d = c.findIndex((m) => m.id === r);
3740
+ d >= 0 ? c[d] = { ...c[d], status: "running", content: s } : c.push({
3741
3741
  id: r,
3742
- name: s,
3742
+ name: o,
3743
3743
  args: t.args || {},
3744
3744
  status: "running",
3745
- content: o
3745
+ content: s
3746
3746
  }), i[u] = {
3747
3747
  ...l,
3748
3748
  toolCalls: c,
@@ -3759,14 +3759,14 @@ function vr(e, t, n) {
3759
3759
  function xr(e, t, n) {
3760
3760
  const r = t.id;
3761
3761
  if (!r) return e;
3762
- const s = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3763
- let o = n ? [...e.taskMessagesByScope[s] || []] : [...e.messages];
3764
- const a = st(o, r);
3762
+ const o = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3763
+ let s = n ? [...e.taskMessagesByScope[o] || []] : [...e.messages];
3764
+ const a = ot(s, r);
3765
3765
  if (a !== -1) {
3766
- const i = o[a], u = ue(t.content), l = (i.toolCalls || []).map(
3766
+ const i = s[a], u = ue(t.content), l = (i.toolCalls || []).map(
3767
3767
  (c) => c.id === r ? { ...c, content: typeof u == "string" ? u : c.content } : c
3768
3768
  );
3769
- o[a] = {
3769
+ s[a] = {
3770
3770
  ...i,
3771
3771
  toolCalls: l,
3772
3772
  scope: t.scope ?? i.scope,
@@ -3775,18 +3775,18 @@ function xr(e, t, n) {
3775
3775
  }
3776
3776
  return {
3777
3777
  ...e,
3778
- messages: n ? e.messages : o,
3779
- taskMessagesByScope: n ? { ...e.taskMessagesByScope, [s]: o } : e.taskMessagesByScope
3778
+ messages: n ? e.messages : s,
3779
+ taskMessagesByScope: n ? { ...e.taskMessagesByScope, [o]: s } : e.taskMessagesByScope
3780
3780
  };
3781
3781
  }
3782
3782
  function Ar(e, t, n) {
3783
3783
  const r = t.id;
3784
3784
  if (!r) return e;
3785
- const s = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3786
- let o = n ? [...e.taskMessagesByScope[s] || []] : [...e.messages];
3787
- const a = st(o, r), i = ue(t.content ?? t.error);
3785
+ const o = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3786
+ let s = n ? [...e.taskMessagesByScope[o] || []] : [...e.messages];
3787
+ const a = ot(s, r), i = ue(t.content ?? t.error);
3788
3788
  if (a !== -1) {
3789
- const l = o[a], c = (l.toolCalls || []).map(
3789
+ const l = s[a], c = (l.toolCalls || []).map(
3790
3790
  (d) => d.id === r ? {
3791
3791
  ...d,
3792
3792
  status: t.error ? "failed" : "completed",
@@ -3794,7 +3794,7 @@ function Ar(e, t, n) {
3794
3794
  artifact: t.artifact
3795
3795
  } : d
3796
3796
  );
3797
- o[a] = {
3797
+ s[a] = {
3798
3798
  ...l,
3799
3799
  toolCalls: c,
3800
3800
  scope: t.scope ?? l.scope,
@@ -3812,21 +3812,21 @@ function Ar(e, t, n) {
3812
3812
  scope: t.scope,
3813
3813
  origin: t.origin
3814
3814
  };
3815
- return o.push(u), {
3815
+ return s.push(u), {
3816
3816
  ...e,
3817
- messages: n ? e.messages : o,
3818
- taskMessagesByScope: n ? { ...e.taskMessagesByScope, [s]: o } : e.taskMessagesByScope
3817
+ messages: n ? e.messages : s,
3818
+ taskMessagesByScope: n ? { ...e.taskMessagesByScope, [o]: s } : e.taskMessagesByScope
3819
3819
  };
3820
3820
  }
3821
3821
  function Tr(e, t) {
3822
3822
  const n = t.artifactId, r = hr(e.messages, n, t.callId);
3823
3823
  if (!r) return e;
3824
- const s = e.messages.indexOf(r), o = yr(r, {
3824
+ const o = e.messages.indexOf(r), s = yr(r, {
3825
3825
  status: t.status,
3826
3826
  progress: t.progress,
3827
3827
  error: t.error
3828
3828
  });
3829
- return t.partial_data && o.artifact && (o.artifact = { ...o.artifact, ...t.partial_data }), { ...e, messages: Ft(e.messages, s, o) };
3829
+ return t.partial_data && s.artifact && (s.artifact = { ...s.artifact, ...t.partial_data }), { ...e, messages: Ft(e.messages, o, s) };
3830
3830
  }
3831
3831
  function Re(e) {
3832
3832
  if (!(!e || typeof e != "object" || Array.isArray(e)))
@@ -3857,24 +3857,24 @@ function gt(e) {
3857
3857
  async function Mr(e, t) {
3858
3858
  var i, u;
3859
3859
  if (!e) return e ?? null;
3860
- const n = fe(e), r = Array.isArray(n.checkpoints) ? n.checkpoints : n.checkpoints ? Object.values(n.checkpoints) : [], s = /* @__PURE__ */ new Set();
3860
+ const n = fe(e), r = Array.isArray(n.checkpoints) ? n.checkpoints : n.checkpoints ? Object.values(n.checkpoints) : [], o = /* @__PURE__ */ new Set();
3861
3861
  for (const l of r) {
3862
3862
  const c = (i = l == null ? void 0 : l.values) == null ? void 0 : i.messages;
3863
3863
  if (Array.isArray(c))
3864
3864
  for (const d of c) {
3865
- const p = d == null ? void 0 : d.content;
3866
- if (Array.isArray(p))
3867
- for (const m of p) {
3868
- if (!m || typeof m != "object" || m.type !== "image_url" && m.type !== "file") continue;
3869
- const v = m.fileId || m.file_id;
3870
- typeof v == "string" && v.trim() && s.add(v);
3865
+ const m = d == null ? void 0 : d.content;
3866
+ if (Array.isArray(m))
3867
+ for (const p of m) {
3868
+ if (!p || typeof p != "object" || p.type !== "image_url" && p.type !== "file") continue;
3869
+ const I = p.fileId || p.file_id;
3870
+ typeof I == "string" && I.trim() && o.add(I);
3871
3871
  }
3872
3872
  }
3873
3873
  }
3874
- if (s.size === 0)
3874
+ if (o.size === 0)
3875
3875
  return n;
3876
- const o = await Promise.all(
3877
- Array.from(s).map(async (l) => {
3876
+ const s = await Promise.all(
3877
+ Array.from(o).map(async (l) => {
3878
3878
  try {
3879
3879
  const c = await t.getFileInfo(l), d = fe(c);
3880
3880
  return [l, d];
@@ -3882,41 +3882,41 @@ async function Mr(e, t) {
3882
3882
  return [l, null];
3883
3883
  }
3884
3884
  })
3885
- ), a = new Map(o);
3885
+ ), a = new Map(s);
3886
3886
  for (const l of r) {
3887
3887
  const c = (u = l == null ? void 0 : l.values) == null ? void 0 : u.messages;
3888
3888
  if (Array.isArray(c))
3889
3889
  for (const d of c) {
3890
- const p = d == null ? void 0 : d.content;
3891
- if (Array.isArray(p))
3892
- for (const m of p) {
3893
- if (!m || typeof m != "object" || m.type !== "image_url" && m.type !== "file") continue;
3894
- const v = m.fileId || m.file_id;
3895
- if (!v) continue;
3896
- const f = a.get(v), b = (f == null ? void 0 : f.contentUrl) || (f == null ? void 0 : f.content_url);
3897
- b && (m.type === "image_url" ? (m.imageUrl = m.imageUrl || {}, m.imageUrl.url = b) : m.type === "file" && (m.url = b, !m.name && (f != null && f.filename || f != null && f.name) && (m.name = (f == null ? void 0 : f.filename) || (f == null ? void 0 : f.name))));
3890
+ const m = d == null ? void 0 : d.content;
3891
+ if (Array.isArray(m))
3892
+ for (const p of m) {
3893
+ if (!p || typeof p != "object" || p.type !== "image_url" && p.type !== "file") continue;
3894
+ const I = p.fileId || p.file_id;
3895
+ if (!I) continue;
3896
+ const f = a.get(I), h = (f == null ? void 0 : f.contentUrl) || (f == null ? void 0 : f.content_url);
3897
+ h && (p.type === "image_url" ? (p.imageUrl = p.imageUrl || {}, p.imageUrl.url = h) : p.type === "file" && (p.url = h, !p.name && (f != null && f.filename || f != null && f.name) && (p.name = (f == null ? void 0 : f.filename) || (f == null ? void 0 : f.name))));
3898
3898
  }
3899
3899
  }
3900
3900
  }
3901
3901
  return n;
3902
3902
  }
3903
3903
  function mt(e) {
3904
- const r = [...(Array.isArray(e == null ? void 0 : e.checkpoints) ? (e == null ? void 0 : e.checkpoints) ?? [] : e != null && e.checkpoints ? Object.values(e.checkpoints) : []).map((o, a) => Cr(fe(o), a)).filter((o) => !!o)].sort((o, a) => yt(a.createdAt) - yt(o.createdAt)), s = r[0] ?? null;
3904
+ const r = [...(Array.isArray(e == null ? void 0 : e.checkpoints) ? (e == null ? void 0 : e.checkpoints) ?? [] : e != null && e.checkpoints ? Object.values(e.checkpoints) : []).map((s, a) => Cr(fe(s), a)).filter((s) => !!s)].sort((s, a) => yt(a.createdAt) - yt(s.createdAt)), o = r[0] ?? null;
3905
3905
  return {
3906
3906
  threadId: (e == null ? void 0 : e.threadId) ?? "",
3907
- latest: s,
3907
+ latest: o,
3908
3908
  checkpoints: r,
3909
- interrupt: (s == null ? void 0 : s.interrupt) ?? null
3909
+ interrupt: (o == null ? void 0 : o.interrupt) ?? null
3910
3910
  };
3911
3911
  }
3912
3912
  function Cr(e, t) {
3913
- var k, h;
3913
+ var k, b;
3914
3914
  if (!e) return null;
3915
- const n = ((k = e.values) == null ? void 0 : k.activeAgent) ?? null, r = (h = e.values) == null ? void 0 : h.messages, o = (Array.isArray(r) ? r : []).map((T) => Er(T, n)).filter((T) => !!T), a = Re(e.metadata) ?? {}, i = gt(e.config), u = Re(e.parentConfig), l = gt(u), c = Be(i, ["checkpointId"]), d = Be(i, ["checkpointNs"]), p = Be(l, ["checkpointId"]), m = Re(e.config), v = Array.isArray(e.tasks) ? e.tasks.map((T) => ({ ...T })) : e.tasks ?? null, f = Array.isArray(e.next) ? [...e.next] : e.next ?? null, b = typeof e.createdAt == "string" && e.createdAt.trim() ? e.createdAt : new Date(Date.now() - t).toISOString(), x = {
3915
+ const n = ((k = e.values) == null ? void 0 : k.activeAgent) ?? null, r = (b = e.values) == null ? void 0 : b.messages, s = (Array.isArray(r) ? r : []).map((T) => Er(T, n)).filter((T) => !!T), a = Re(e.metadata) ?? {}, i = gt(e.config), u = Re(e.parentConfig), l = gt(u), c = Be(i, ["checkpointId"]), d = Be(i, ["checkpointNs"]), m = Be(l, ["checkpointId"]), p = Re(e.config), I = Array.isArray(e.tasks) ? e.tasks.map((T) => ({ ...T })) : e.tasks ?? null, f = Array.isArray(e.next) ? [...e.next] : e.next ?? null, h = typeof e.createdAt == "string" && e.createdAt.trim() ? e.createdAt : new Date(Date.now() - t).toISOString(), x = {
3916
3916
  ...a,
3917
3917
  step: Sr(a, ["step"]) ?? 0,
3918
3918
  source: Be(a, ["source"]) ?? null
3919
- }, S = o.map((T) => ({
3919
+ }, S = s.map((T) => ({
3920
3920
  ...T,
3921
3921
  checkpointId: T.checkpointId ?? c ?? null,
3922
3922
  checkpointNs: T.checkpointNs ?? d ?? null
@@ -3924,8 +3924,8 @@ function Cr(e, t) {
3924
3924
  return {
3925
3925
  checkpointId: c ?? null,
3926
3926
  checkpointNs: d ?? null,
3927
- createdAt: b,
3928
- parentId: p ?? null,
3927
+ createdAt: h,
3928
+ parentId: m ?? null,
3929
3929
  messages: S,
3930
3930
  interrupt: Pr(
3931
3931
  w,
@@ -3933,10 +3933,10 @@ function Cr(e, t) {
3933
3933
  c ?? null
3934
3934
  ),
3935
3935
  metadata: x,
3936
- config: m ?? null,
3936
+ config: p ?? null,
3937
3937
  parentConfig: u ?? null,
3938
3938
  next: f,
3939
- tasks: v,
3939
+ tasks: I,
3940
3940
  values: e.values ?? {}
3941
3941
  };
3942
3942
  }
@@ -3946,15 +3946,15 @@ function Er(e, t) {
3946
3946
  }
3947
3947
  function Pr(e, t, n) {
3948
3948
  const r = e.length;
3949
- for (let s = r - 1; s >= 0; s -= 1) {
3950
- const o = e[s];
3951
- if (!o || typeof o != "object")
3949
+ for (let o = r - 1; o >= 0; o -= 1) {
3950
+ const s = e[o];
3951
+ if (!s || typeof s != "object")
3952
3952
  continue;
3953
- const a = o, i = a.value ?? o;
3953
+ const a = s, i = a.value ?? s;
3954
3954
  if (i == null)
3955
3955
  continue;
3956
3956
  return {
3957
- id: typeof a.id == "string" && a.id.trim() ? a.id : `interrupt-${n ?? t}-${s}`,
3957
+ id: typeof a.id == "string" && a.id.trim() ? a.id : `interrupt-${n ?? t}-${o}`,
3958
3958
  value: i
3959
3959
  };
3960
3960
  }
@@ -3979,54 +3979,54 @@ function Nr(e) {
3979
3979
  return _r(e.content) || "";
3980
3980
  }
3981
3981
  function zr(e) {
3982
- const t = /* @__PURE__ */ new Map(), n = [], r = /* @__PURE__ */ new Map(), s = [];
3982
+ const t = /* @__PURE__ */ new Map(), n = [], r = /* @__PURE__ */ new Map(), o = [];
3983
3983
  for (let l = 0; l < e.length; l++) {
3984
- const c = e[l], d = c.checkpointId, p = d ?? `cp-${l}`, m = c.metadata ?? {}, v = typeof m.step == "number" ? m.step : null, f = typeof m.source == "string" ? m.source : null;
3985
- let b = null, x = null;
3984
+ const c = e[l], d = c.checkpointId, m = d ?? `cp-${l}`, p = c.metadata ?? {}, I = typeof p.step == "number" ? p.step : null, f = typeof p.source == "string" ? p.source : null;
3985
+ let h = null, x = null;
3986
3986
  const S = Array.isArray(c.messages) ? c.messages : [];
3987
- for (const h of S)
3988
- h.role === "user" && (x || (x = h), h.id && (b = h.id));
3987
+ for (const b of S)
3988
+ b.role === "user" && (x || (x = b), b.id && (h = b.id));
3989
3989
  const A = c.next && c.next.length > 0 ? String(c.next[0]) : null, w = c.parentConfig ?? null, k = {
3990
- id: p,
3991
- step: v,
3990
+ id: m,
3991
+ step: I,
3992
3992
  source: f,
3993
3993
  createdAt: c.createdAt ?? null,
3994
3994
  namespace: c.checkpointNs ?? null,
3995
3995
  parentId: c.parentId ?? null,
3996
3996
  next: A,
3997
3997
  parentConfig: w,
3998
- userMessageId: b
3998
+ userMessageId: h
3999
3999
  };
4000
- if (s.push(k), d && t.set(d, k), d && x) {
4001
- const h = Nr(x);
4002
- h && r.set(d, h);
4000
+ if (o.push(k), d && t.set(d, k), d && x) {
4001
+ const b = Nr(x);
4002
+ b && r.set(d, b);
4003
4003
  }
4004
4004
  n.push({
4005
- id: p,
4006
- messageId: b,
4007
- step: v,
4005
+ id: m,
4006
+ messageId: h,
4007
+ step: I,
4008
4008
  source: f,
4009
4009
  createdAt: c.createdAt ?? null,
4010
4010
  next: A,
4011
4011
  parentConfig: w
4012
4012
  });
4013
4013
  }
4014
- const o = /* @__PURE__ */ new Map();
4015
- for (const l of s) {
4014
+ const s = /* @__PURE__ */ new Map();
4015
+ for (const l of o) {
4016
4016
  if (!l.userMessageId) continue;
4017
- const c = o.get(l.userMessageId) ?? [];
4018
- c.push(l), o.set(l.userMessageId, c);
4017
+ const c = s.get(l.userMessageId) ?? [];
4018
+ c.push(l), s.set(l.userMessageId, c);
4019
4019
  }
4020
- for (const l of o.values()) {
4020
+ for (const l of s.values()) {
4021
4021
  if (!l.length) continue;
4022
- l.sort((d, p) => {
4023
- const m = d.createdAt ? Date.parse(d.createdAt) : 0;
4024
- return (p.createdAt ? Date.parse(p.createdAt) : 0) - m;
4022
+ l.sort((d, m) => {
4023
+ const p = d.createdAt ? Date.parse(d.createdAt) : 0;
4024
+ return (m.createdAt ? Date.parse(m.createdAt) : 0) - p;
4025
4025
  });
4026
4026
  const c = l.length;
4027
4027
  for (let d = 0; d < l.length; d++) {
4028
- const p = l[d];
4029
- p.attemptCount = c, p.attemptIndex = d, p.isLatestAttempt = d === 0;
4028
+ const m = l[d];
4029
+ m.attemptCount = c, m.attemptIndex = d, m.isLatestAttempt = d === 0;
4030
4030
  }
4031
4031
  }
4032
4032
  return {
@@ -4044,27 +4044,27 @@ function zr(e) {
4044
4044
  const c = [];
4045
4045
  for (const d of t.values())
4046
4046
  d.userMessageId === l && c.push(d);
4047
- return c.length ? (c.sort((d, p) => {
4048
- const m = typeof d.attemptIndex == "number" ? d.attemptIndex : Number.MAX_SAFE_INTEGER, v = typeof p.attemptIndex == "number" ? p.attemptIndex : Number.MAX_SAFE_INTEGER;
4049
- return m - v;
4047
+ return c.length ? (c.sort((d, m) => {
4048
+ const p = typeof d.attemptIndex == "number" ? d.attemptIndex : Number.MAX_SAFE_INTEGER, I = typeof m.attemptIndex == "number" ? m.attemptIndex : Number.MAX_SAFE_INTEGER;
4049
+ return p - I;
4050
4050
  }), c) : [];
4051
4051
  }
4052
4052
  };
4053
4053
  }
4054
- function uo(e, t, n) {
4054
+ function ds(e, t, n) {
4055
4055
  if (!e)
4056
4056
  return { attemptCount: 1, attemptIndex: 0, attempts: [] };
4057
4057
  const r = n.getMessageAttempts(e);
4058
4058
  if (!r.length)
4059
4059
  return { attemptCount: 1, attemptIndex: 0, attempts: [] };
4060
- let s = 0;
4060
+ let o = 0;
4061
4061
  if (t) {
4062
- const o = r.findIndex((a) => a.id === t);
4063
- o >= 0 && (s = o);
4062
+ const s = r.findIndex((a) => a.id === t);
4063
+ s >= 0 && (o = s);
4064
4064
  }
4065
4065
  return {
4066
4066
  attemptCount: r.length,
4067
- attemptIndex: s,
4067
+ attemptIndex: o,
4068
4068
  attempts: r
4069
4069
  };
4070
4070
  }
@@ -4076,49 +4076,49 @@ function $t({
4076
4076
  fileApi: t,
4077
4077
  seed: n,
4078
4078
  onError: r,
4079
- currentThreadId: s,
4080
- autoLoadInitial: o = !0,
4079
+ currentThreadId: o,
4080
+ autoLoadInitial: s = !0,
4081
4081
  isStreaming: a,
4082
4082
  getMessages: i,
4083
4083
  includeHistory: u = !0
4084
4084
  }) {
4085
- const [l, c] = H(null), p = Z(
4085
+ const [l, c] = H(null), m = Z(
4086
4086
  () => mt(l),
4087
4087
  [l]
4088
- ).checkpoints, m = Rr(p), v = m.timeline, [f, b] = H(!1), [x, S] = H(!1), [A, w] = H(!1), [k, h] = H(null), T = W(s), y = W(null), I = W(null);
4088
+ ).checkpoints, p = Rr(m), I = p.timeline, [f, h] = H(!1), [x, S] = H(!1), [A, w] = H(!1), [k, b] = H(null), T = W(o), y = W(null), v = W(null);
4089
4089
  Y(() => {
4090
- T.current = s;
4091
- }, [s]);
4092
- const E = _(
4090
+ T.current = o;
4091
+ }, [o]);
4092
+ const _ = N(
4093
4093
  async (P) => {
4094
4094
  const F = await e.getState({
4095
4095
  threadId: P.threadId,
4096
4096
  checkpointId: P.checkpointId,
4097
4097
  checkpointNs: P.checkpointNs
4098
- }), N = {
4098
+ }), E = {
4099
4099
  version: "values@1",
4100
4100
  threadId: P.threadId,
4101
4101
  checkpoints: [F]
4102
- }, j = t ? await Mr(N, t) : N, { latest: G } = mt(j);
4102
+ }, j = t ? await Mr(E, t) : E, { latest: G } = mt(j);
4103
4103
  return G;
4104
4104
  },
4105
4105
  [e, t]
4106
- ), L = _(
4106
+ ), L = N(
4107
4107
  async (P, F) => {
4108
4108
  var G;
4109
4109
  if (!P) return;
4110
- const N = `${P}:${F ?? "latest"}`;
4111
- if (y.current === N || f) return;
4112
- (G = I.current) == null || G.abort();
4110
+ const E = `${P}:${F ?? "latest"}`;
4111
+ if (y.current === E || f) return;
4112
+ (G = v.current) == null || G.abort();
4113
4113
  const j = new AbortController();
4114
- I.current = j, b(!0), h(null);
4114
+ v.current = j, h(!0), b(null);
4115
4115
  try {
4116
- const g = await E({
4116
+ const g = await _({
4117
4117
  threadId: P,
4118
4118
  checkpointId: F ?? void 0
4119
4119
  });
4120
4120
  if (T.current !== P) {
4121
- b(!1);
4121
+ h(!1);
4122
4122
  return;
4123
4123
  }
4124
4124
  if (n((g == null ? void 0 : g.messages) ?? [], {
@@ -4126,7 +4126,7 @@ function $t({
4126
4126
  checkpointNs: (g == null ? void 0 : g.checkpointNs) ?? null,
4127
4127
  pendingInterrupt: (g == null ? void 0 : g.interrupt) ?? null,
4128
4128
  values: g == null ? void 0 : g.values
4129
- }), y.current = N, b(!1), u) {
4129
+ }), y.current = E, h(!1), u) {
4130
4130
  w(!0);
4131
4131
  try {
4132
4132
  const z = await e.getStateHistory({
@@ -4140,58 +4140,61 @@ function $t({
4140
4140
  }
4141
4141
  }
4142
4142
  } catch (g) {
4143
- if (b(!1), !Xt(g)) {
4143
+ if (h(!1), !Xt(g)) {
4144
4144
  const z = String(g);
4145
- h(z), r == null || r(z);
4145
+ b(z), r == null || r(z);
4146
4146
  }
4147
4147
  }
4148
4148
  },
4149
- [e, n, E, r, i]
4150
- ), M = _(
4149
+ [e, n, _, r, i]
4150
+ ), M = N(
4151
4151
  async (P, F) => {
4152
- if (s) {
4152
+ if (o) {
4153
4153
  S(!0);
4154
4154
  try {
4155
- const N = await E({
4156
- threadId: s,
4155
+ const E = await _({
4156
+ threadId: o,
4157
4157
  checkpointId: P,
4158
4158
  checkpointNs: F ?? void 0
4159
4159
  });
4160
- n((N == null ? void 0 : N.messages) ?? [], {
4161
- checkpointId: (N == null ? void 0 : N.checkpointId) ?? P,
4162
- checkpointNs: (N == null ? void 0 : N.checkpointNs) ?? F,
4163
- pendingInterrupt: (N == null ? void 0 : N.interrupt) ?? null,
4164
- values: N == null ? void 0 : N.values
4160
+ n((E == null ? void 0 : E.messages) ?? [], {
4161
+ checkpointId: (E == null ? void 0 : E.checkpointId) ?? P,
4162
+ checkpointNs: (E == null ? void 0 : E.checkpointNs) ?? F,
4163
+ pendingInterrupt: (E == null ? void 0 : E.interrupt) ?? null,
4164
+ values: E == null ? void 0 : E.values
4165
4165
  });
4166
- } catch (N) {
4167
- console.error("[useThreadHistoryState] Navigation failed", N);
4166
+ } catch (E) {
4167
+ console.error("[useThreadHistoryState] Navigation failed", E);
4168
4168
  } finally {
4169
4169
  S(!1);
4170
4170
  }
4171
4171
  }
4172
4172
  },
4173
- [s, E, n]
4174
- ), $ = _(async () => {
4175
- s && await L(s);
4176
- }, [s, L]), U = _(
4173
+ [o, _, n]
4174
+ ), $ = N(async () => {
4175
+ o && await L(o);
4176
+ }, [o, L]), U = N(
4177
4177
  async (P) => {
4178
- const F = (P == null ? void 0 : P.threadId) || s;
4179
- !F || s !== F || (c(P), y.current = `${F}:latest`);
4178
+ const F = (P == null ? void 0 : P.threadId) || o;
4179
+ if (!F || o !== F) return;
4180
+ c(P);
4181
+ const E = P.scope;
4182
+ (!E || E === "main" || E === "agent") && (y.current = `${F}:latest`);
4180
4183
  },
4181
- [s]
4184
+ [o]
4182
4185
  );
4183
4186
  Y(() => {
4184
- if (!o || !s || f || a) return;
4185
- const P = `${s}:latest`;
4186
- y.current !== P && L(s);
4187
- }, [o, s, f, a, L]);
4188
- const V = _(() => {
4189
- c(null), b(!1), S(!1), w(!1), h(null), y.current = null;
4187
+ if (!s || !o || f || a) return;
4188
+ const P = `${o}:latest`;
4189
+ y.current !== P && L(o);
4190
+ }, [s, o, f, a, L]);
4191
+ const V = N(() => {
4192
+ c(null), h(!1), S(!1), w(!1), b(null), y.current = null;
4190
4193
  }, []);
4191
4194
  return {
4192
- threadCheckpoints: p,
4193
- threadTimeline: v,
4194
- checkpointIndex: m,
4195
+ threadCheckpoints: m,
4196
+ threadTimeline: I,
4197
+ checkpointIndex: p,
4195
4198
  isLoadingThread: f,
4196
4199
  isLoadingCheckpoint: x,
4197
4200
  isLoadingHistory: A,
@@ -4228,54 +4231,54 @@ function jr({
4228
4231
  initialThreadId: t = null,
4229
4232
  initialCheckpointId: n = null,
4230
4233
  initialCheckpointNs: r = null,
4231
- autoLoadInitial: s = !0,
4232
- isStreaming: o,
4234
+ autoLoadInitial: o = !0,
4235
+ isStreaming: s,
4233
4236
  onError: a,
4234
4237
  includeHistory: i = !0
4235
4238
  }) {
4236
- const { chatApi: u, fileApi: l } = Me(), { currentThreadId: c } = ot(), { state: d, seed: p, onEvent: m, dispatch: v } = kr(), {
4239
+ const { chatApi: u, fileApi: l } = Me(), { currentThreadId: c } = st(), { state: d, seed: m, onEvent: p, dispatch: I } = kr(), {
4237
4240
  threadCheckpoints: f,
4238
- threadTimeline: b,
4241
+ threadTimeline: h,
4239
4242
  checkpointIndex: x,
4240
4243
  isLoadingThread: S,
4241
4244
  isLoadingCheckpoint: A,
4242
4245
  isLoadingHistory: w,
4243
4246
  threadStateError: k,
4244
- loadThread: h,
4247
+ loadThread: b,
4245
4248
  navigateToCheckpoint: T,
4246
4249
  setCurrentCheckpointId: y,
4247
- returnToLatest: I,
4248
- handleValuesEvent: E,
4250
+ returnToLatest: v,
4251
+ handleValuesEvent: _,
4249
4252
  markSkipNextLoad: L,
4250
4253
  markStreamPendingThread: M,
4251
4254
  resetHistoryState: $
4252
4255
  } = $t({
4253
4256
  api: u,
4254
4257
  fileApi: l,
4255
- seed: p,
4258
+ seed: m,
4256
4259
  onError: a,
4257
4260
  currentThreadId: c,
4258
4261
  initialThreadId: t,
4259
4262
  initialCheckpointId: n,
4260
4263
  initialCheckpointNs: r,
4261
- autoLoadInitial: s,
4262
- isStreaming: o,
4263
- getMessages: _(() => d.messages, [d.messages]),
4264
+ autoLoadInitial: o,
4265
+ isStreaming: s,
4266
+ getMessages: N(() => d.messages, [d.messages]),
4264
4267
  includeHistory: i
4265
- }), U = W(null), V = _(
4268
+ }), U = W(null), V = N(
4266
4269
  (D) => {
4267
4270
  U.current = D;
4268
4271
  },
4269
4272
  []
4270
- ), P = W(null), F = _(
4273
+ ), P = W(null), F = N(
4271
4274
  (D) => {
4272
4275
  P.current = D;
4273
4276
  },
4274
4277
  []
4275
- ), N = Z(() => ({ assemblingMessageId: d.assemblingId ?? null }), [d.assemblingId]), j = _(
4278
+ ), E = Z(() => ({ assemblingMessageId: d.assemblingId ?? null }), [d.assemblingId]), j = N(
4276
4279
  (D, K) => {
4277
4280
  const B = jt(D, "user");
4278
- return v({
4281
+ return I({
4279
4282
  type: "user_message",
4280
4283
  payload: {
4281
4284
  message: B,
@@ -4283,12 +4286,12 @@ function jr({
4283
4286
  }
4284
4287
  }), B;
4285
4288
  },
4286
- [v]
4287
- ), G = _(async () => {
4288
- U.current ? await U.current() : (p([], {}), $());
4289
- }, [p, $]), g = _(async (D, K, B) => {
4290
- await h(D, K, { clearProgress: !1 });
4291
- }, [h]), z = Z(() => Bn(d.messages), [d.messages]), C = Z(
4289
+ [I]
4290
+ ), G = N(async () => {
4291
+ U.current ? await U.current() : (m([], {}), $());
4292
+ }, [m, $]), g = N(async (D, K, B) => {
4293
+ await b(D, K, { clearProgress: !1 });
4294
+ }, [b]), z = Z(() => Bn(d.messages), [d.messages]), C = Z(
4292
4295
  () => ({
4293
4296
  status: d.status,
4294
4297
  threadId: c,
@@ -4301,8 +4304,8 @@ function jr({
4301
4304
  },
4302
4305
  checkpoints: f,
4303
4306
  checkpointIndex: x,
4304
- timelineCheckpoints: b,
4305
- metadata: N,
4307
+ timelineCheckpoints: h,
4308
+ metadata: E,
4306
4309
  values: d.values ?? {},
4307
4310
  isLoading: S,
4308
4311
  isLoadingCheckpoint: A,
@@ -4312,7 +4315,7 @@ function jr({
4312
4315
  },
4313
4316
  // Placeholder
4314
4317
  seedFromSnapshot: (D) => {
4315
- p(D.messages, {
4318
+ m(D.messages, {
4316
4319
  checkpointId: D.checkpointId,
4317
4320
  checkpointNs: D.checkpointNs,
4318
4321
  pendingInterrupt: D.interrupt,
@@ -4322,19 +4325,19 @@ function jr({
4322
4325
  clearState: G,
4323
4326
  navigateToCheckpoint: T,
4324
4327
  setCurrentCheckpointId: y,
4325
- returnToLatest: I,
4328
+ returnToLatest: v,
4326
4329
  loadThread: g,
4327
4330
  clearThread: G,
4328
4331
  respondToInterrupt: async (D, K, B) => {
4329
4332
  P.current && await P.current(D, K, B);
4330
4333
  },
4331
4334
  messagePreviews: x.messagePreviews,
4332
- handleValuesEvent: E,
4335
+ handleValuesEvent: _,
4333
4336
  markSkipNextLoad: L,
4334
4337
  markStreamPendingThread: M,
4335
4338
  resetHistoryState: $,
4336
4339
  pushUser: j,
4337
- onEvent: m,
4340
+ onEvent: p,
4338
4341
  artifacts: z
4339
4342
  }),
4340
4343
  [
@@ -4346,24 +4349,24 @@ function jr({
4346
4349
  d.lastCheckpointNs,
4347
4350
  d.values,
4348
4351
  f,
4349
- b,
4352
+ h,
4350
4353
  x,
4351
- N,
4354
+ E,
4352
4355
  S,
4353
4356
  A,
4354
4357
  w,
4355
4358
  k,
4356
- p,
4359
+ m,
4357
4360
  G,
4358
4361
  T,
4359
4362
  y,
4360
- I,
4363
+ v,
4361
4364
  g,
4362
- E,
4365
+ _,
4363
4366
  L,
4364
4367
  M,
4365
4368
  j,
4366
- m,
4369
+ p,
4367
4370
  z
4368
4371
  ]
4369
4372
  ), O = Z(
@@ -4381,32 +4384,32 @@ function Br({
4381
4384
  onError: t,
4382
4385
  onAuthError: n,
4383
4386
  onConnectionError: r,
4384
- onToolEnd: s,
4385
- onUpdateEvent: o,
4387
+ onToolEnd: o,
4388
+ onUpdateEvent: s,
4386
4389
  onCustomEvent: a,
4387
4390
  onMetadataEvent: i,
4388
4391
  onFinish: u,
4389
4392
  onStreamingChange: l
4390
4393
  }) {
4391
- const { chatApi: c, baseUrl: d } = Me(), p = d, m = ge(t), v = ge(n), f = ge(r), b = ge(s), x = ge(o), S = ge(a), A = ge(i), w = ge(u), k = ge(l), h = Z(
4394
+ const { chatApi: c, baseUrl: d } = Me(), m = d, p = ge(t), I = ge(n), f = ge(r), h = ge(o), x = ge(s), S = ge(a), A = ge(i), w = ge(u), k = ge(l), b = Z(
4392
4395
  () => ({
4393
- onError: m,
4394
- onAuthError: v,
4396
+ onError: p,
4397
+ onAuthError: I,
4395
4398
  onConnectionError: f,
4396
4399
  onMetadataEvent: A,
4397
4400
  onCustomEvent: S,
4398
4401
  onUpdateEvent: x,
4399
- onToolEnd: b,
4402
+ onToolEnd: h,
4400
4403
  onFinish: w
4401
4404
  }),
4402
4405
  [
4403
- m,
4404
- v,
4406
+ p,
4407
+ I,
4405
4408
  f,
4406
4409
  A,
4407
4410
  S,
4408
4411
  x,
4409
- b,
4412
+ h,
4410
4413
  w
4411
4414
  ]
4412
4415
  );
@@ -4414,8 +4417,8 @@ function Br({
4414
4417
  Fr,
4415
4418
  {
4416
4419
  api: c,
4417
- streamBaseUrl: p,
4418
- handlers: h,
4420
+ streamBaseUrl: m,
4421
+ handlers: b,
4419
4422
  onStreamingChange: k,
4420
4423
  children: e
4421
4424
  }
@@ -4426,25 +4429,25 @@ function Fr({
4426
4429
  api: t,
4427
4430
  streamBaseUrl: n,
4428
4431
  handlers: r,
4429
- onStreamingChange: s
4432
+ onStreamingChange: o
4430
4433
  }) {
4431
- const { setCurrentThreadId: o, currentThreadIdRef: a, addThreadFromEvent: i, currentThreadId: u } = ot(), {
4434
+ const { setCurrentThreadId: s, currentThreadIdRef: a, addThreadFromEvent: i, currentThreadId: u } = st(), {
4432
4435
  interrupt: l,
4433
4436
  checkpoint: c,
4434
4437
  timelineCheckpoints: d,
4435
- handleValuesEvent: p,
4436
- markSkipNextLoad: m,
4437
- markStreamPendingThread: v,
4438
+ handleValuesEvent: m,
4439
+ markSkipNextLoad: p,
4440
+ markStreamPendingThread: I,
4438
4441
  resetHistoryState: f,
4439
- pushUser: b,
4442
+ pushUser: h,
4440
4443
  onEvent: x,
4441
4444
  messages: S
4442
- } = Ht(), { registerClearThread: A, registerRespondToInterrupt: w } = Lr(), k = _(
4445
+ } = Ht(), { registerClearThread: A, registerRespondToInterrupt: w } = Lr(), k = N(
4443
4446
  (g) => {
4444
- i(g), v(g.threadId), a.current !== g.threadId && ((g.created ?? !a.current) && m(g.threadId), o(g.threadId));
4447
+ i(g), I(g.threadId), a.current !== g.threadId && ((g.created ?? !a.current) && p(g.threadId), s(g.threadId));
4445
4448
  },
4446
- [i, m, v, o, a]
4447
- ), h = pr({
4449
+ [i, p, I, s, a]
4450
+ ), b = pr({
4448
4451
  baseUrl: n,
4449
4452
  onEvent: x,
4450
4453
  onError: (g) => {
@@ -4459,16 +4462,16 @@ function Fr({
4459
4462
  onCustomEvent: r.onCustomEvent,
4460
4463
  onUpdateEvent: r.onUpdateEvent,
4461
4464
  onToolEnd: r.onToolEnd,
4462
- handleValuesEvent: p
4465
+ handleValuesEvent: m
4463
4466
  });
4464
4467
  Y(() => {
4465
- s == null || s(h.isStreaming);
4466
- }, [h.isStreaming, s]);
4467
- const { stream: T, stop: y, clear: I, isStreaming: E, error: L, connected: M, activeMessageId: $ } = h;
4468
+ o == null || o(b.isStreaming);
4469
+ }, [b.isStreaming, o]);
4470
+ const { stream: T, stop: y, clear: v, isStreaming: _, error: L, connected: M, activeMessageId: $ } = b;
4468
4471
  Y(() => {
4469
- u !== void 0 && I();
4470
- }, [u, I]);
4471
- const U = _(
4472
+ u !== void 0 && v();
4473
+ }, [u, v]);
4474
+ const U = N(
4472
4475
  async (g, z) => {
4473
4476
  await T(g, z);
4474
4477
  },
@@ -4477,7 +4480,7 @@ function Fr({
4477
4480
  Y(() => {
4478
4481
  V.current = c;
4479
4482
  }, [c]);
4480
- const P = _(
4483
+ const P = N(
4481
4484
  async (g, z, C) => {
4482
4485
  var ye;
4483
4486
  const O = a.current;
@@ -4501,15 +4504,15 @@ function Fr({
4501
4504
  Y(() => {
4502
4505
  w(P);
4503
4506
  }, [P, w]);
4504
- const F = _(async () => {
4505
- y(), I(), f(), o(null);
4506
- }, [I, f, o, y]);
4507
+ const F = N(async () => {
4508
+ y(), v(), f(), s(null);
4509
+ }, [v, f, s, y]);
4507
4510
  Y(() => {
4508
4511
  A(F);
4509
4512
  }, [F, A]);
4510
- const N = _(
4513
+ const E = N(
4511
4514
  async (g, z) => {
4512
- E && y();
4515
+ _ && y();
4513
4516
  let C = a.current;
4514
4517
  const O = (g == null ? void 0 : g.text) ?? "", D = (g == null ? void 0 : g.attachments) ?? [], K = (O == null ? void 0 : O.trim()) ?? "", B = { ...(g == null ? void 0 : g.payload) ?? {} }, ee = Array.isArray(B.messages) ? B.messages : void 0;
4515
4518
  ee && delete B.messages;
@@ -4517,11 +4520,11 @@ function Fr({
4517
4520
  if (!C && !K && D.length === 0 && !ie && !ye) return;
4518
4521
  if (!C) {
4519
4522
  const re = Math.floor(Date.now() / 1e3).toString(16).padStart(8, "0"), te = Array.from({ length: 4 }, () => Math.floor(Math.random() * 4294967295).toString(16).padStart(8, "0")).join("").slice(0, 16);
4520
- C = `${re}${te}`, m(C), o(C);
4523
+ C = `${re}${te}`, p(C), s(C);
4521
4524
  }
4522
4525
  let J = null;
4523
4526
  g.contentParts && g.contentParts.length > 0 && (J = g.contentParts);
4524
- const { contentParts: se, filesInfo: he } = J ? { contentParts: J, filesInfo: [] } : await or(D), X = [...se];
4527
+ const { contentParts: oe, filesInfo: he } = J ? { contentParts: J, filesInfo: [] } : await sr(D), X = [...oe];
4525
4528
  K && X.push({ type: "text", text: O });
4526
4529
  const Q = g == null ? void 0 : g.originalMessageId, be = !!(g != null && g.edit && Q), He = !ie && X.length > 0;
4527
4530
  let we = null;
@@ -4532,7 +4535,7 @@ function Fr({
4532
4535
  role: "user",
4533
4536
  content: X,
4534
4537
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
4535
- }, "user"), be ? b(we, { editingMessageId: Q }) : b(we);
4538
+ }, "user"), be ? h(we, { editingMessageId: Q }) : h(we);
4536
4539
  }
4537
4540
  const Pe = ie ? ee : we ? [we] : [], ke = {
4538
4541
  ...B,
@@ -4569,15 +4572,15 @@ function Fr({
4569
4572
  };
4570
4573
  return U(Ue, z);
4571
4574
  },
4572
- [c, a, E, m, b, U, y, d]
4575
+ [c, a, _, p, h, U, y, d]
4573
4576
  ), j = Z(() => S, [S]), G = Z(
4574
4577
  () => ({
4575
- isStreaming: E,
4578
+ isStreaming: _,
4576
4579
  error: L,
4577
- connectionState: L ? "error" : E ? M ? "connected" : "connecting" : "idle",
4580
+ connectionState: L ? "error" : _ ? M ? "connected" : "connecting" : "idle",
4578
4581
  messages: j,
4579
4582
  activeMessageId: $,
4580
- submit: N,
4583
+ submit: E,
4581
4584
  stop: y,
4582
4585
  interrupt: l,
4583
4586
  resume: () => Promise.resolve(),
@@ -4586,7 +4589,7 @@ function Fr({
4586
4589
  }
4587
4590
  // TODO: Implement error clearing
4588
4591
  }),
4589
- [E, L, N, y, l, M, j]
4592
+ [_, L, E, y, l, M, j]
4590
4593
  );
4591
4594
  return /* @__PURE__ */ de(Vt.Provider, { value: G, children: e });
4592
4595
  }
@@ -4594,7 +4597,7 @@ function ge(e) {
4594
4597
  const t = W(e);
4595
4598
  return Y(() => {
4596
4599
  t.current = e;
4597
- }, [e]), _((...n) => {
4600
+ }, [e]), N((...n) => {
4598
4601
  const r = t.current;
4599
4602
  if (r)
4600
4603
  return r(...n);
@@ -4612,8 +4615,8 @@ function $r(e, t) {
4612
4615
  const n = Object.keys(e), r = Object.keys(t);
4613
4616
  if (n.length !== r.length)
4614
4617
  return !1;
4615
- for (const s of n)
4616
- if (!Object.prototype.hasOwnProperty.call(t, s) || !Object.is(e[s], t[s]))
4618
+ for (const o of n)
4619
+ if (!Object.prototype.hasOwnProperty.call(t, o) || !Object.is(e[o], t[o]))
4617
4620
  return !1;
4618
4621
  return !0;
4619
4622
  }
@@ -4622,53 +4625,53 @@ function Dr(e) {
4622
4625
  return $r(t.current, e) || (t.current = e, n.current = e), n.current;
4623
4626
  }
4624
4627
  function Kr(e) {
4625
- const t = e.artifact && typeof e.artifact == "object" ? e.artifact : null, n = !t && e.content && typeof e.content == "object" ? e.content : null, r = t ?? n, s = (r == null ? void 0 : r.task_id) ?? (r == null ? void 0 : r.taskId) ?? null;
4626
- return typeof s == "string" ? s : null;
4628
+ const t = e.artifact && typeof e.artifact == "object" ? e.artifact : null, n = !t && e.content && typeof e.content == "object" ? e.content : null, r = t ?? n, o = (r == null ? void 0 : r.task_id) ?? (r == null ? void 0 : r.taskId) ?? null;
4629
+ return typeof o == "string" ? o : null;
4627
4630
  }
4628
- function fo(e) {
4631
+ function us(e) {
4629
4632
  const { setCurrentTaskId: t, getCurrentTaskId: n, onToolEnd: r } = e;
4630
- return (s) => {
4631
- const o = Kr(s), a = (n == null ? void 0 : n()) ?? null;
4632
- o && o !== a && t(o), r == null || r(s);
4633
+ return (o) => {
4634
+ const s = Kr(o), a = (n == null ? void 0 : n()) ?? null;
4635
+ s && s !== a && t(s), r == null || r(o);
4633
4636
  };
4634
4637
  }
4635
- function po({
4638
+ function fs({
4636
4639
  children: e,
4637
4640
  apiConfig: t,
4638
4641
  initialThreadId: n = null,
4639
4642
  initialCheckpointId: r = null,
4640
- initialCheckpointNs: s = null,
4641
- autoLoadInitial: o = !0,
4643
+ initialCheckpointNs: o = null,
4644
+ autoLoadInitial: s = !0,
4642
4645
  onConnectionError: a,
4643
4646
  onError: i,
4644
4647
  onAuthError: u,
4645
4648
  onThreadChange: l,
4646
4649
  onToolEnd: c,
4647
4650
  onUpdateEvent: d,
4648
- onCustomEvent: p,
4649
- onMetadataEvent: m,
4650
- onFinish: v
4651
+ onCustomEvent: m,
4652
+ onMetadataEvent: p,
4653
+ onFinish: I
4651
4654
  }) {
4652
- const f = Dr(t), [b, x] = H(!1), S = me(i), A = me(u), w = me(a), k = me(l), h = me(c), T = me(d), y = me(p), I = me(m), E = me(v), L = Z(
4655
+ const f = Dr(t), [h, x] = H(!1), S = me(i), A = me(u), w = me(a), k = me(l), b = me(c), T = me(d), y = me(m), v = me(p), _ = me(I), L = Z(
4653
4656
  () => ({
4654
4657
  onError: S,
4655
4658
  onAuthError: A,
4656
4659
  onConnectionError: w,
4657
- onToolEnd: h,
4660
+ onToolEnd: b,
4658
4661
  onUpdateEvent: T,
4659
4662
  onCustomEvent: y,
4660
- onMetadataEvent: I,
4661
- onFinish: E
4663
+ onMetadataEvent: v,
4664
+ onFinish: _
4662
4665
  }),
4663
4666
  [
4664
4667
  S,
4665
4668
  A,
4666
4669
  w,
4667
- h,
4670
+ b,
4668
4671
  T,
4669
4672
  y,
4670
- I,
4671
- E
4673
+ v,
4674
+ _
4672
4675
  ]
4673
4676
  );
4674
4677
  return /* @__PURE__ */ de(nr, { apiConfig: f, children: /* @__PURE__ */ de(
@@ -4682,10 +4685,10 @@ function po({
4682
4685
  {
4683
4686
  initialThreadId: n,
4684
4687
  initialCheckpointId: r,
4685
- initialCheckpointNs: s,
4686
- autoLoadInitial: o,
4688
+ initialCheckpointNs: o,
4689
+ autoLoadInitial: s,
4687
4690
  onError: S,
4688
- isStreaming: b,
4691
+ isStreaming: h,
4689
4692
  children: /* @__PURE__ */ de(
4690
4693
  Br,
4691
4694
  {
@@ -4701,7 +4704,7 @@ function po({
4701
4704
  }
4702
4705
  function me(e) {
4703
4706
  const t = W(e);
4704
- return t.current = e, _((...n) => {
4707
+ return t.current = e, N((...n) => {
4705
4708
  const r = t.current;
4706
4709
  if (r)
4707
4710
  return r(...n);
@@ -4767,9 +4770,9 @@ function Le(e) {
4767
4770
  });
4768
4771
  }
4769
4772
  function Wr({ ...e }) {
4770
- const t = qr(), n = (s) => Le({
4773
+ const t = qr(), n = (o) => Le({
4771
4774
  type: "UPDATE_TOAST",
4772
- toast: { ...s, id: t }
4775
+ toast: { ...o, id: t }
4773
4776
  }), r = () => Le({ type: "DISMISS_TOAST", toastId: t });
4774
4777
  return Le({
4775
4778
  type: "ADD_TOAST",
@@ -4777,8 +4780,8 @@ function Wr({ ...e }) {
4777
4780
  ...e,
4778
4781
  id: t,
4779
4782
  open: !0,
4780
- onOpenChange: (s) => {
4781
- s || r();
4783
+ onOpenChange: (o) => {
4784
+ o || r();
4782
4785
  }
4783
4786
  }
4784
4787
  }), {
@@ -4798,43 +4801,43 @@ function Jr() {
4798
4801
  dismiss: (n) => Le({ type: "DISMISS_TOAST", toastId: n })
4799
4802
  };
4800
4803
  }
4801
- function go(e) {
4802
- const { allowFileOpen: t, currentThreadId: n } = e, { fileApi: r } = Me(), { toast: s } = Jr(), [o, a] = H({}), [i, u] = H(null), [l, c] = H(!1), d = _(() => {
4804
+ function ps(e) {
4805
+ const { allowFileOpen: t, currentThreadId: n } = e, { fileApi: r } = Me(), { toast: o } = Jr(), [s, a] = H({}), [i, u] = H(null), [l, c] = H(!1), d = N(() => {
4803
4806
  c(!1), u(null);
4804
- }, []), p = _((v) => {
4805
- u(v), c(!0);
4806
- }, []), m = _(
4807
- async (v, f, b) => {
4807
+ }, []), m = N((I) => {
4808
+ u(I), c(!0);
4809
+ }, []), p = N(
4810
+ async (I, f, h) => {
4808
4811
  var x, S;
4809
4812
  if (!t) {
4810
- v.preventDefault();
4813
+ I.preventDefault();
4811
4814
  return;
4812
4815
  }
4813
- if (o[b]) {
4814
- v.preventDefault();
4816
+ if (s[h]) {
4817
+ I.preventDefault();
4815
4818
  return;
4816
4819
  }
4817
4820
  try {
4818
4821
  const A = String(f.url ?? ""), w = A.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);
4819
4822
  if (w) {
4820
- v.preventDefault();
4821
- const k = w[1], h = f.name || `file_${k}`, T = f.mimeType || "application/octet-stream";
4822
- p({ id: k, name: h, mimeType: T });
4823
+ I.preventDefault();
4824
+ const k = w[1], b = f.name || `file_${k}`, T = f.mimeType || "application/octet-stream";
4825
+ m({ id: k, name: b, mimeType: T });
4823
4826
  return;
4824
4827
  }
4825
4828
  if (A.startsWith("data:")) {
4826
- v.preventDefault(), a((h) => ({ ...h, [b]: !0 }));
4827
- const k = s({ title: "Fetching file...", description: "", open: !0 });
4829
+ I.preventDefault(), a((b) => ({ ...b, [h]: !0 }));
4830
+ const k = o({ title: "Fetching file...", description: "", open: !0 });
4828
4831
  try {
4829
- const h = await r.listFiles(n ?? void 0);
4830
- if (!h || !Array.isArray(h))
4832
+ const b = await r.listFiles(n ?? void 0);
4833
+ if (!b || !Array.isArray(b))
4831
4834
  throw new Error("Invalid file list response");
4832
- const T = h.find((y) => !y || typeof y != "object" || !((y.filename ?? "") === (f.name ?? "")) ? !1 : typeof f.size == "number" && typeof y.size == "number" ? y.size === f.size : !0);
4835
+ const T = b.find((y) => !y || typeof y != "object" || !((y.filename ?? "") === (f.name ?? "")) ? !1 : typeof f.size == "number" && typeof y.size == "number" ? y.size === f.size : !0);
4833
4836
  if (!(T != null && T.id))
4834
4837
  throw new Error(`File "${f.name}" is not yet available on the server`);
4835
4838
  if (!T.id || !T.filename)
4836
4839
  throw new Error("Invalid file data received from server");
4837
- p({
4840
+ m({
4838
4841
  id: T.id,
4839
4842
  name: f.name || T.filename || `file_${T.id}`,
4840
4843
  mimeType: f.mimeType || T.mime_type || "application/octet-stream"
@@ -4844,39 +4847,39 @@ function go(e) {
4844
4847
  description: `Opened ${f.name}`,
4845
4848
  open: !0
4846
4849
  });
4847
- } catch (h) {
4848
- console.error("Failed to fetch server file:", h);
4849
- const T = h instanceof Error ? h.message : "Unknown error occurred";
4850
- (S = k.update) == null || S.call(k, { id: k.id, title: "Failed", description: T }), s({
4850
+ } catch (b) {
4851
+ console.error("Failed to fetch server file:", b);
4852
+ const T = b instanceof Error ? b.message : "Unknown error occurred";
4853
+ (S = k.update) == null || S.call(k, { id: k.id, title: "Failed", description: T }), o({
4851
4854
  title: "Failed to fetch file",
4852
4855
  description: T,
4853
4856
  open: !0
4854
4857
  });
4855
4858
  } finally {
4856
- a((h) => ({ ...h, [b]: !1 }));
4859
+ a((b) => ({ ...b, [h]: !1 }));
4857
4860
  }
4858
4861
  }
4859
4862
  } catch (A) {
4860
- console.error("File click error:", A), a((w) => ({ ...w, [b]: !1 }));
4863
+ console.error("File click error:", A), a((w) => ({ ...w, [h]: !1 }));
4861
4864
  }
4862
4865
  },
4863
- [t, o, s, n, p]
4866
+ [t, s, o, n, m]
4864
4867
  );
4865
4868
  return {
4866
- uploadingFiles: o,
4867
- handleFileClick: m,
4869
+ uploadingFiles: s,
4870
+ handleFileClick: p,
4868
4871
  fileViewerOpen: l,
4869
4872
  currentFileInfo: i,
4870
4873
  closeFileViewer: d
4871
4874
  };
4872
4875
  }
4873
- function mo(e) {
4876
+ function gs(e) {
4874
4877
  return Z(() => {
4875
4878
  const t = e;
4876
4879
  let n = Array.isArray(t.content) ? t.content : [];
4877
4880
  return typeof t.content == "string" && (n = [{ type: "text", text: t.content }]), {
4878
4881
  contentParts: n,
4879
- textContent: sr(n),
4882
+ textContent: or(n),
4880
4883
  toolMeta: ar(t),
4881
4884
  imageParts: n.filter((r) => r.type === "image_url"),
4882
4885
  fileParts: n.filter((r) => r.type === "file"),
@@ -4890,13 +4893,13 @@ function Xr(e) {
4890
4893
  if (!e) return [];
4891
4894
  const t = [], n = e.split(/\r?\n/);
4892
4895
  for (const r of n) {
4893
- const s = r.trim();
4894
- if (!s || !s.startsWith(kt))
4896
+ const o = r.trim();
4897
+ if (!o || !o.startsWith(kt))
4895
4898
  continue;
4896
- const o = s.slice(kt.length).trim();
4897
- if (!o || o.toLowerCase() === "[done]")
4899
+ const s = o.slice(kt.length).trim();
4900
+ if (!s || s.toLowerCase() === "[done]")
4898
4901
  continue;
4899
- const a = tt(o);
4902
+ const a = tt(s);
4900
4903
  a && typeof a == "object" && t.push(a);
4901
4904
  }
4902
4905
  return t;
@@ -4909,7 +4912,7 @@ function Qr(e) {
4909
4912
  }
4910
4913
  return null;
4911
4914
  }
4912
- function yo(e) {
4915
+ function ms(e) {
4913
4916
  return Z(() => {
4914
4917
  const t = e.content.filter(
4915
4918
  (u) => u.type === "text"
@@ -4926,41 +4929,41 @@ function yo(e) {
4926
4929
  }
4927
4930
  if (!r.length)
4928
4931
  return null;
4929
- const o = Qr(r) ?? r[r.length - 1];
4930
- if (!o)
4932
+ const s = Qr(r) ?? r[r.length - 1];
4933
+ if (!s)
4931
4934
  return null;
4932
- const a = o.output ?? o.payload ?? o, i = ue(a);
4935
+ const a = s.output ?? s.payload ?? s, i = ue(a);
4933
4936
  return i && typeof i == "object" && !Array.isArray(i) ? {
4934
4937
  kind: "dict",
4935
4938
  value: i,
4936
4939
  data: i,
4937
- event: o
4940
+ event: s
4938
4941
  } : {
4939
4942
  kind: "generic",
4940
4943
  value: i,
4941
- event: o
4944
+ event: s
4942
4945
  };
4943
4946
  }, [e]);
4944
4947
  }
4945
4948
  function Yr(e) {
4946
4949
  var $, U;
4947
- const t = typeof e == "string" ? e : e == null ? void 0 : e.threadId, n = typeof e == "object" ? e.lazy : !1, r = typeof e == "object" ? e.includeHistory : !0, s = ot({ optional: !0 }), o = Ht({ optional: !0 }), a = Or(), { currentThreadId: i, setCurrentThreadId: u, actions: l } = s || {
4950
+ const t = typeof e == "string" ? e : e == null ? void 0 : e.threadId, n = typeof e == "object" ? e.lazy : !1, r = typeof e == "object" ? e.includeHistory : !0, o = st({ optional: !0 }), s = Ht({ optional: !0 }), a = Or(), { currentThreadId: i, setCurrentThreadId: u, actions: l } = o || {
4948
4951
  currentThreadId: null,
4949
4952
  setCurrentThreadId: () => {
4950
4953
  },
4951
4954
  actions: {}
4952
- }, c = !!t && t !== i, [d, p] = H([]), m = _((V) => {
4953
- p(V);
4955
+ }, c = !!t && t !== i, [d, m] = H([]), p = N((V) => {
4956
+ m(V);
4954
4957
  }, []), {
4955
- isLoadingThread: v,
4958
+ isLoadingThread: I,
4956
4959
  threadStateError: f,
4957
- threadCheckpoints: b,
4960
+ threadCheckpoints: h,
4958
4961
  isLoadingHistory: x,
4959
4962
  loadThread: S
4960
4963
  } = $t({
4961
4964
  api: Me().chatApi,
4962
4965
  fileApi: Me().fileApi,
4963
- seed: m,
4966
+ seed: p,
4964
4967
  currentThreadId: c ? t : null,
4965
4968
  initialThreadId: c ? t : null,
4966
4969
  isStreaming: !1,
@@ -4969,51 +4972,51 @@ function Yr(e) {
4969
4972
  includeHistory: r
4970
4973
  });
4971
4974
  Y(() => {
4972
- !c && !n && i && (o != null && o.loadThread) && o.loadThread(i);
4973
- }, [c, n, i, o == null ? void 0 : o.loadThread]);
4975
+ !c && !n && i && (s != null && s.loadThread) && s.loadThread(i);
4976
+ }, [c, n, i, s == null ? void 0 : s.loadThread]);
4974
4977
  const A = Z(() => {
4975
4978
  var V;
4976
- return ((V = b[0]) == null ? void 0 : V.values) || {};
4977
- }, [b]), w = Z(() => ({ timeline: [], messagePreviews: {} }), []), k = t || i, h = c ? v ? "loading" : "idle" : (o == null ? void 0 : o.status) || "idle", T = c ? d : (a == null ? void 0 : a.messages) || [], y = c ? v : (o == null ? void 0 : o.isLoading) || !1, I = c ? x : (o == null ? void 0 : o.isLoadingHistory) || !1, E = c ? A : (o == null ? void 0 : o.values) || {}, L = c ? {} : (o == null ? void 0 : o.taskMessagesByScope) || {}, M = c ? f : (a == null ? void 0 : a.error) || (o == null ? void 0 : o.error) || null;
4979
+ return ((V = h[0]) == null ? void 0 : V.values) || {};
4980
+ }, [h]), w = Z(() => ({ timeline: [], messagePreviews: {} }), []), k = t || i, b = c ? I ? "loading" : "idle" : (s == null ? void 0 : s.status) || "idle", T = c ? d : (a == null ? void 0 : a.messages) || [], y = c ? I : (s == null ? void 0 : s.isLoading) || !1, v = c ? x : (s == null ? void 0 : s.isLoadingHistory) || !1, _ = c ? A : (s == null ? void 0 : s.values) || {}, L = c ? {} : (s == null ? void 0 : s.taskMessagesByScope) || {}, M = c ? f : (a == null ? void 0 : a.error) || (s == null ? void 0 : s.error) || null;
4978
4981
  return {
4979
4982
  // UNIFIED: Single thread ID concept
4980
4983
  threadId: k,
4981
- status: h,
4984
+ status: b,
4982
4985
  messages: T,
4983
4986
  isLoading: y,
4984
- isHistoryLoading: I,
4987
+ isHistoryLoading: v,
4985
4988
  error: M,
4986
4989
  // Values & Metadata
4987
- values: E,
4990
+ values: _,
4988
4991
  taskMessagesByScope: L,
4989
- metadata: c ? {} : o == null ? void 0 : o.metadata,
4992
+ metadata: c ? {} : s == null ? void 0 : s.metadata,
4990
4993
  // Actions & State relating to Global/Active Thread only
4991
4994
  navigateToCheckpoint: c ? async () => {
4992
- } : (o == null ? void 0 : o.navigateToCheckpoint) || (async () => {
4995
+ } : (s == null ? void 0 : s.navigateToCheckpoint) || (async () => {
4993
4996
  }),
4994
4997
  returnToLatest: c ? async () => {
4995
- } : (o == null ? void 0 : o.returnToLatest) || (async () => {
4998
+ } : (s == null ? void 0 : s.returnToLatest) || (async () => {
4996
4999
  }),
4997
- checkpoint: c ? b[0] ? { id: b[0].checkpointId, namespace: b[0].checkpointNs } : null : (o == null ? void 0 : o.checkpoint) || null,
4998
- checkpoints: c ? b : (o == null ? void 0 : o.checkpoints) || [],
4999
- checkpointIndex: c ? w : (o == null ? void 0 : o.checkpointIndex) || { timeline: [], messagePreviews: {} },
5000
- interrupt: c ? null : (o == null ? void 0 : o.interrupt) || null,
5000
+ checkpoint: c ? h[0] ? { id: h[0].checkpointId, namespace: h[0].checkpointNs } : null : (s == null ? void 0 : s.checkpoint) || null,
5001
+ checkpoints: c ? h : (s == null ? void 0 : s.checkpoints) || [],
5002
+ checkpointIndex: c ? w : (s == null ? void 0 : s.checkpointIndex) || { timeline: [], messagePreviews: {} },
5003
+ interrupt: c ? null : (s == null ? void 0 : s.interrupt) || null,
5001
5004
  respondToInterrupt: c ? async () => {
5002
- } : (o == null ? void 0 : o.respondToInterrupt) || (async () => {
5005
+ } : (s == null ? void 0 : s.respondToInterrupt) || (async () => {
5003
5006
  }),
5004
5007
  // Streaming Status
5005
5008
  // Even in standalone mode, allow streaming state/stop if a stream context exists.
5006
5009
  isStreaming: (a == null ? void 0 : a.isStreaming) || !1,
5007
- activeMessageId: c ? null : (($ = o == null ? void 0 : o.metadata) == null ? void 0 : $.assemblingMessageId) || (a == null ? void 0 : a.activeMessageId) || null,
5010
+ activeMessageId: c ? null : (($ = s == null ? void 0 : s.metadata) == null ? void 0 : $.assemblingMessageId) || (a == null ? void 0 : a.activeMessageId) || null,
5008
5011
  connectionState: (a == null ? void 0 : a.connectionState) || "disconnected",
5009
- streamingAssistantId: !c && (a != null && a.isStreaming) && ((U = o == null ? void 0 : o.metadata) != null && U.assemblingMessageId) ? o.metadata.assemblingMessageId : null,
5012
+ streamingAssistantId: !c && (a != null && a.isStreaming) && ((U = s == null ? void 0 : s.metadata) != null && U.assemblingMessageId) ? s.metadata.assemblingMessageId : null,
5010
5013
  // Actions
5011
5014
  submit: (a == null ? void 0 : a.submit) || (async () => {
5012
5015
  }),
5013
5016
  stop: (a == null ? void 0 : a.stop) || (() => {
5014
5017
  }),
5015
5018
  clearThread: c ? async () => {
5016
- } : (o == null ? void 0 : o.clearThread) || (async () => {
5019
+ } : (s == null ? void 0 : s.clearThread) || (async () => {
5017
5020
  }),
5018
5021
  setCurrentThreadId: u,
5019
5022
  loadHistory: c ? async () => {
@@ -5021,54 +5024,54 @@ function Yr(e) {
5021
5024
  } : async () => {
5022
5025
  },
5023
5026
  onEvent: c ? () => {
5024
- } : (o == null ? void 0 : o.onEvent) || (() => {
5027
+ } : (s == null ? void 0 : s.onEvent) || (() => {
5025
5028
  }),
5026
5029
  // Thread Management
5027
5030
  createThread: l == null ? void 0 : l.createThread,
5028
5031
  deleteThread: l == null ? void 0 : l.deleteThread,
5029
5032
  renameThread: l == null ? void 0 : l.renameThread,
5030
- threads: (s == null ? void 0 : s.threads) || [],
5031
- isThreadsLoading: (s == null ? void 0 : s.isLoading) || !1
5033
+ threads: (o == null ? void 0 : o.threads) || [],
5034
+ isThreadsLoading: (o == null ? void 0 : o.isLoading) || !1
5032
5035
  };
5033
5036
  }
5034
- function ho({
5037
+ function ys({
5035
5038
  submit: e,
5036
5039
  chatRequest: t,
5037
5040
  lastCheckpointId: n,
5038
5041
  lastCheckpointNs: r,
5039
- onMessageSent: s,
5040
- onExcelUploadSuccess: o,
5042
+ onMessageSent: o,
5043
+ onExcelUploadSuccess: s,
5041
5044
  onError: a,
5042
5045
  enableMessageEditing: i,
5043
5046
  messages: u,
5044
5047
  setPendingAssistantResponse: l,
5045
5048
  project: c,
5046
5049
  onEvent: d,
5047
- threadId: p,
5048
- clearComposerOnSend: m = !0
5050
+ threadId: m,
5051
+ clearComposerOnSend: p = !0
5049
5052
  }) {
5050
- const { messages: v } = Yr(), [f, b] = H(null), [x, S] = H(""), [A, w] = H(null), [k, h] = H(null), [T, y] = H(!1), [I, E] = H(""), L = W(I), M = W(null);
5053
+ const { messages: I } = Yr(), [f, h] = H(null), [x, S] = H(""), [A, w] = H(null), [k, b] = H(null), [T, y] = H(!1), [v, _] = H(""), L = W(v), M = W(null);
5051
5054
  Y(() => {
5052
5055
  if (!f)
5053
- if (p) {
5054
- const z = localStorage.getItem(Ge(p));
5055
- E(z || "");
5056
+ if (m) {
5057
+ const z = localStorage.getItem(Ge(m));
5058
+ _(z || "");
5056
5059
  } else
5057
- E("");
5058
- }, [p, f]);
5059
- const $ = _((z) => {
5060
- E(z), !f && p && localStorage.setItem(Ge(p), z);
5061
- }, [p, f]);
5060
+ _("");
5061
+ }, [m, f]);
5062
+ const $ = N((z) => {
5063
+ _(z), !f && m && localStorage.setItem(Ge(m), z);
5064
+ }, [m, f]);
5062
5065
  Y(() => {
5063
- L.current = I;
5064
- }, [I]), Y(() => {
5066
+ L.current = v;
5067
+ }, [v]), Y(() => {
5065
5068
  if (!f) {
5066
5069
  M.current = null;
5067
5070
  return;
5068
5071
  }
5069
5072
  M.current === null && (M.current = L.current), $(x ?? "");
5070
5073
  }, [x, f, $]);
5071
- const U = _(
5074
+ const U = N(
5072
5075
  (z) => {
5073
5076
  $(z);
5074
5077
  },
@@ -5096,7 +5099,7 @@ function ho({
5096
5099
  name: X.filename,
5097
5100
  size: X.size
5098
5101
  };
5099
- }), J = [...K, ...ye], se = f ? (A == null ? void 0 : A.checkpointId) ?? n ?? void 0 : n ?? void 0, he = f ? (A == null ? void 0 : A.checkpointNs) ?? r ?? void 0 : r ?? void 0;
5102
+ }), J = [...K, ...ye], oe = f ? (A == null ? void 0 : A.checkpointId) ?? n ?? void 0 : n ?? void 0, he = f ? (A == null ? void 0 : A.checkpointNs) ?? r ?? void 0 : r ?? void 0;
5100
5103
  await e(
5101
5104
  {
5102
5105
  text: B || "",
@@ -5104,21 +5107,21 @@ function ho({
5104
5107
  attachments: D,
5105
5108
  payload: t.payload,
5106
5109
  edit: !!f,
5107
- checkpointId: se,
5110
+ checkpointId: oe,
5108
5111
  checkpointNs: he,
5109
5112
  project: c ?? void 0,
5110
5113
  originalMessageId: f ?? void 0,
5111
5114
  config: t.config
5112
5115
  },
5113
5116
  d ? { onEvent: d } : void 0
5114
- ), s == null || s(B), l(!0), m && (p && localStorage.removeItem(Ge(p)), $("")), h(null), b(null), S(""), w(null);
5117
+ ), o == null || o(B), l(!0), p && (m && localStorage.removeItem(Ge(m)), $("")), b(null), h(null), S(""), w(null);
5115
5118
  } catch (ee) {
5116
5119
  const ie = (ee == null ? void 0 : ee.message) || "Failed to send message";
5117
- h(ie), a == null || a(ie), l(!1);
5120
+ b(ie), a == null || a(ie), l(!1);
5118
5121
  }
5119
5122
  }, P = (z, C) => {
5120
5123
  C || V(z, { files: [] });
5121
- }, F = _(
5124
+ }, F = N(
5122
5125
  async (z) => {
5123
5126
  await e(
5124
5127
  {
@@ -5130,22 +5133,22 @@ function ho({
5130
5133
  config: t.config
5131
5134
  },
5132
5135
  d ? { onEvent: d } : void 0
5133
- ), o == null || o({ file: z });
5136
+ ), s == null || s({ file: z });
5134
5137
  },
5135
- [n, r, t, o, e]
5136
- ), N = _(
5138
+ [n, r, t, s, e]
5139
+ ), E = N(
5137
5140
  (z, C, O) => {
5138
- i && (M.current = I, b(z), S(C), w({
5141
+ i && (M.current = v, h(z), S(C), w({
5139
5142
  checkpointId: (O == null ? void 0 : O.checkpointId) ?? null,
5140
5143
  checkpointNs: (O == null ? void 0 : O.checkpointNs) ?? null
5141
- }), h(null));
5144
+ }), b(null));
5142
5145
  },
5143
- [I, i]
5144
- ), j = _(() => {
5145
- b(null), S(""), w(null), h(null);
5146
+ [v, i]
5147
+ ), j = N(() => {
5148
+ h(null), S(""), w(null), b(null);
5146
5149
  const z = M.current;
5147
- z !== null && E(z), M.current = null;
5148
- }, []), G = _((z) => {
5150
+ z !== null && _(z), M.current = null;
5151
+ }, []), G = N((z) => {
5149
5152
  let C = null;
5150
5153
  for (let B = z - 1; B >= 0; B--)
5151
5154
  if (u[B].role === "user") {
@@ -5177,21 +5180,21 @@ function ho({
5177
5180
  editingMessageId: f,
5178
5181
  editingInitialValue: x,
5179
5182
  inputError: k,
5180
- setInputError: h,
5183
+ setInputError: b,
5181
5184
  dismissError: T,
5182
5185
  setDismissError: y,
5183
- composerValue: I,
5186
+ composerValue: v,
5184
5187
  handleComposerChange: U,
5185
5188
  handleSendMessage: V,
5186
5189
  handleQuickPrompt: P,
5187
5190
  handleExcelUpload: F,
5188
- startEditing: N,
5191
+ startEditing: E,
5189
5192
  cancelEditing: j,
5190
5193
  handleRegenerateCb: G,
5191
- displayMessages: v
5194
+ displayMessages: I
5192
5195
  };
5193
5196
  }
5194
- function bo(e) {
5197
+ function hs(e) {
5195
5198
  return Z(() => e ? {
5196
5199
  textContent: Ln(e),
5197
5200
  imageParts: jn(e),
@@ -5206,12 +5209,12 @@ function bo(e) {
5206
5209
  contentParts: []
5207
5210
  }, [e]);
5208
5211
  }
5209
- function wo(e, t, n) {
5210
- const [r, s] = H(e), o = W(e), a = W(null);
5212
+ function bs(e, t, n) {
5213
+ const [r, o] = H(e), s = W(e), a = W(null);
5211
5214
  return Y(() => {
5212
- o.current = e;
5215
+ s.current = e;
5213
5216
  const i = () => {
5214
- s(o.current), a.current && (clearTimeout(a.current), a.current = null);
5217
+ o(s.current), a.current && (clearTimeout(a.current), a.current = null);
5215
5218
  };
5216
5219
  if (!t || n <= 0) {
5217
5220
  i();
@@ -5225,26 +5228,26 @@ function wo(e, t, n) {
5225
5228
  }, [e, t, n]), r;
5226
5229
  }
5227
5230
  export {
5228
- po as ChatProviders,
5231
+ fs as ChatProviders,
5229
5232
  jr as ThreadStateProvider,
5230
5233
  mr as ThreadsProvider,
5231
- ro as cn,
5232
- sr as collectText,
5233
- fo as createTaskSyncToolEndHandler,
5234
+ rs as cn,
5235
+ or as collectText,
5236
+ us as createTaskSyncToolEndHandler,
5234
5237
  Kr as extractTaskIdFromToolEnd,
5235
5238
  ar as extractToolMeta,
5236
- oo as formatToolOutput,
5237
- co as getAgentNameFromMessage,
5239
+ ss as formatToolOutput,
5240
+ cs as getAgentNameFromMessage,
5238
5241
  Pt as getChatToken,
5239
- uo as getMessageAttemptInfo,
5240
- ao as getToolCallArtifacts,
5242
+ ds as getMessageAttemptInfo,
5243
+ as as getToolCallArtifacts,
5241
5244
  Vn as getToolCalls,
5242
- so as hasContent,
5245
+ os as hasContent,
5243
5246
  mt as hydrateHistorySnapshots,
5244
5247
  Ct as isFileLike,
5245
5248
  Nn as looksLikeMarkdown,
5246
- lo as messageSignature,
5247
- io as normalizeInterruptId,
5249
+ ls as messageSignature,
5250
+ is as normalizeInterruptId,
5248
5251
  _t as onChatTokenChanged,
5249
5252
  tt as parseJsonSafe,
5250
5253
  Et as pretty,
@@ -5253,18 +5256,18 @@ export {
5253
5256
  xe as setChatToken,
5254
5257
  Fn as stringifyTool,
5255
5258
  Me as useApi,
5256
- ho as useChatController,
5259
+ ys as useChatController,
5257
5260
  Yr as useChatSession,
5258
- go as useFilePreview,
5259
- bo as useMessageContent,
5260
- mo as useParsedMessageContent,
5261
+ ps as useFilePreview,
5262
+ hs as useMessageContent,
5263
+ gs as useParsedMessageContent,
5261
5264
  pr as useStream,
5262
- wo as useStreamingMarkdownBuffer,
5265
+ bs as useStreamingMarkdownBuffer,
5263
5266
  $t as useThreadHistoryState,
5264
5267
  Ht as useThreadState,
5265
5268
  Lr as useThreadStateUpdater,
5266
- ot as useThreads,
5269
+ st as useThreads,
5267
5270
  gr as useThreadsState,
5268
- yo as useToolPayload
5271
+ ms as useToolPayload
5269
5272
  };
5270
5273
  //# sourceMappingURL=index.esm.js.map