@teodorruskvi/chat-core 0.1.36 → 0.1.38

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
@@ -1,58 +1,58 @@
1
- var Wt = Object.defineProperty;
2
- var qt = (e, t, n) => t in e ? Wt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var at = (e, t, n) => qt(e, typeof t != "symbol" ? t + "" : t, n);
1
+ var Gt = Object.defineProperty;
2
+ var Ht = (e, t, n) => t in e ? Gt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var st = (e, t, n) => Ht(e, typeof t != "symbol" ? t + "" : t, n);
4
4
  import { jsx as ie } from "react/jsx-runtime";
5
- import * as it from "react";
6
- import { createContext as Se, useContext as Ue, useState as D, useRef as H, useEffect as q, useCallback as z, useMemo as Q, useReducer as Jt } from "react";
7
- import Xt, { isCancel as Qt } from "axios";
8
- function It(e) {
5
+ import * as at from "react";
6
+ import { createContext as Se, useContext as Ue, useState as $, useRef as K, useEffect as W, useCallback as U, useMemo as X, useReducer as Wt } from "react";
7
+ import qt, { isCancel as Jt } from "axios";
8
+ function vt(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
12
  var o = e.length;
13
- for (t = 0; t < o; t++) e[t] && (n = It(e[t])) && (r && (r += " "), r += n);
13
+ for (t = 0; t < o; t++) e[t] && (n = vt(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
- function Yt() {
18
- for (var e, t, n = 0, r = "", o = arguments.length; n < o; n++) (e = arguments[n]) && (t = It(e)) && (r && (r += " "), r += t);
17
+ function Xt() {
18
+ for (var e, t, n = 0, r = "", o = arguments.length; n < o; n++) (e = arguments[n]) && (t = vt(e)) && (r && (r += " "), r += t);
19
19
  return r;
20
20
  }
21
- const et = "-", Zt = (e) => {
22
- const t = tn(e), {
21
+ const Ze = "-", Qt = (e) => {
22
+ const t = Zt(e), {
23
23
  conflictingClassGroups: n,
24
24
  conflictingClassGroupModifiers: r
25
25
  } = e;
26
26
  return {
27
27
  getClassGroupId: (a) => {
28
- const i = a.split(et);
29
- return i[0] === "" && i.length !== 1 && i.shift(), Tt(i, t) || en(a);
28
+ const i = a.split(Ze);
29
+ return i[0] === "" && i.length !== 1 && i.shift(), kt(i, t) || Yt(a);
30
30
  },
31
31
  getConflictingClassGroupIds: (a, i) => {
32
32
  const u = n[a] || [];
33
33
  return i && r[a] ? [...u, ...r[a]] : u;
34
34
  }
35
35
  };
36
- }, Tt = (e, t) => {
36
+ }, kt = (e, t) => {
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), o = r ? Tt(e.slice(1), r) : void 0;
40
+ const n = e[0], r = t.nextPart.get(n), o = r ? kt(e.slice(1), r) : void 0;
41
41
  if (o)
42
42
  return o;
43
43
  if (t.validators.length === 0)
44
44
  return;
45
- const s = e.join(et);
45
+ const s = e.join(Ze);
46
46
  return (a = t.validators.find(({
47
47
  validator: i
48
48
  }) => i(s))) == null ? void 0 : a.classGroupId;
49
- }, ct = /^\[(.+)\]$/, en = (e) => {
50
- if (ct.test(e)) {
51
- const t = ct.exec(e)[1], n = t == null ? void 0 : t.substring(0, t.indexOf(":"));
49
+ }, it = /^\[(.+)\]$/, Yt = (e) => {
50
+ if (it.test(e)) {
51
+ const t = it.exec(e)[1], n = t == null ? void 0 : t.substring(0, t.indexOf(":"));
52
52
  if (n)
53
53
  return "arbitrary.." + n;
54
54
  }
55
- }, tn = (e) => {
55
+ }, Zt = (e) => {
56
56
  const {
57
57
  theme: t,
58
58
  prefix: n
@@ -60,19 +60,19 @@ const et = "-", Zt = (e) => {
60
60
  nextPart: /* @__PURE__ */ new Map(),
61
61
  validators: []
62
62
  };
63
- return rn(Object.entries(e.classGroups), n).forEach(([s, a]) => {
64
- Qe(a, r, s, t);
63
+ return tn(Object.entries(e.classGroups), n).forEach(([s, a]) => {
64
+ Je(a, r, s, t);
65
65
  }), r;
66
- }, Qe = (e, t, n, r) => {
66
+ }, Je = (e, t, n, r) => {
67
67
  e.forEach((o) => {
68
68
  if (typeof o == "string") {
69
- const s = o === "" ? t : lt(t, o);
69
+ const s = o === "" ? t : ct(t, o);
70
70
  s.classGroupId = n;
71
71
  return;
72
72
  }
73
73
  if (typeof o == "function") {
74
- if (nn(o)) {
75
- Qe(o(r), t, n, r);
74
+ if (en(o)) {
75
+ Je(o(r), t, n, r);
76
76
  return;
77
77
  }
78
78
  t.validators.push({
@@ -82,21 +82,21 @@ const et = "-", Zt = (e) => {
82
82
  return;
83
83
  }
84
84
  Object.entries(o).forEach(([s, a]) => {
85
- Qe(a, lt(t, s), n, r);
85
+ Je(a, ct(t, s), n, r);
86
86
  });
87
87
  });
88
- }, lt = (e, t) => {
88
+ }, ct = (e, t) => {
89
89
  let n = e;
90
- return t.split(et).forEach((r) => {
90
+ return t.split(Ze).forEach((r) => {
91
91
  n.nextPart.has(r) || n.nextPart.set(r, {
92
92
  nextPart: /* @__PURE__ */ new Map(),
93
93
  validators: []
94
94
  }), n = n.nextPart.get(r);
95
95
  }), n;
96
- }, nn = (e) => e.isThemeGetter, rn = (e, t) => t ? e.map(([n, r]) => {
96
+ }, en = (e) => e.isThemeGetter, tn = (e, t) => t ? e.map(([n, r]) => {
97
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
98
  return [n, o];
99
- }) : e, on = (e) => {
99
+ }) : e, nn = (e) => {
100
100
  if (e < 1)
101
101
  return {
102
102
  get: () => {
@@ -120,40 +120,40 @@ const et = "-", Zt = (e) => {
120
120
  n.has(s) ? n.set(s, a) : o(s, a);
121
121
  }
122
122
  };
123
- }, xt = "!", sn = (e) => {
123
+ }, It = "!", rn = (e) => {
124
124
  const {
125
125
  separator: t,
126
126
  experimentalParseClassName: n
127
127
  } = e, r = t.length === 1, o = t[0], s = t.length, a = (i) => {
128
128
  const u = [];
129
129
  let c = 0, l = 0, p;
130
- for (let w = 0; w < i.length; w++) {
131
- let k = i[w];
130
+ for (let v = 0; v < i.length; v++) {
131
+ let I = i[v];
132
132
  if (c === 0) {
133
- if (k === o && (r || i.slice(w, w + s) === t)) {
134
- u.push(i.slice(l, w)), l = w + s;
133
+ if (I === o && (r || i.slice(v, v + s) === t)) {
134
+ u.push(i.slice(l, v)), l = v + s;
135
135
  continue;
136
136
  }
137
- if (k === "/") {
138
- p = w;
137
+ if (I === "/") {
138
+ p = v;
139
139
  continue;
140
140
  }
141
141
  }
142
- k === "[" ? c++ : k === "]" && c--;
142
+ I === "[" ? c++ : I === "]" && c--;
143
143
  }
144
- const m = u.length === 0 ? i : i.substring(l), h = m.startsWith(xt), v = h ? m.substring(1) : m, f = p && p > l ? p - l : void 0;
144
+ const m = u.length === 0 ? i : i.substring(l), h = m.startsWith(It), k = h ? m.substring(1) : m, d = p && p > l ? p - l : void 0;
145
145
  return {
146
146
  modifiers: u,
147
147
  hasImportantModifier: h,
148
- baseClassName: v,
149
- maybePostfixModifierPosition: f
148
+ baseClassName: k,
149
+ maybePostfixModifierPosition: d
150
150
  };
151
151
  };
152
152
  return n ? (i) => n({
153
153
  className: i,
154
154
  parseClassName: a
155
155
  }) : a;
156
- }, an = (e) => {
156
+ }, on = (e) => {
157
157
  if (e.length <= 1)
158
158
  return e;
159
159
  const t = [];
@@ -161,16 +161,16 @@ const et = "-", Zt = (e) => {
161
161
  return e.forEach((r) => {
162
162
  r[0] === "[" ? (t.push(...n.sort(), r), n = []) : n.push(r);
163
163
  }), t.push(...n.sort()), t;
164
- }, cn = (e) => ({
165
- cache: on(e.cacheSize),
166
- parseClassName: sn(e),
167
- ...Zt(e)
168
- }), ln = /\s+/, un = (e, t) => {
164
+ }, sn = (e) => ({
165
+ cache: nn(e.cacheSize),
166
+ parseClassName: rn(e),
167
+ ...Qt(e)
168
+ }), an = /\s+/, cn = (e, t) => {
169
169
  const {
170
170
  parseClassName: n,
171
171
  getClassGroupId: r,
172
172
  getConflictingClassGroupIds: o
173
- } = t, s = [], a = e.trim().split(ln);
173
+ } = t, s = [], a = e.trim().split(an);
174
174
  let i = "";
175
175
  for (let u = a.length - 1; u >= 0; u -= 1) {
176
176
  const c = a[u], {
@@ -179,104 +179,104 @@ const et = "-", Zt = (e) => {
179
179
  baseClassName: m,
180
180
  maybePostfixModifierPosition: h
181
181
  } = n(c);
182
- let v = !!h, f = r(v ? m.substring(0, h) : m);
183
- if (!f) {
184
- if (!v) {
182
+ let k = !!h, d = r(k ? m.substring(0, h) : m);
183
+ if (!d) {
184
+ if (!k) {
185
185
  i = c + (i.length > 0 ? " " + i : i);
186
186
  continue;
187
187
  }
188
- if (f = r(m), !f) {
188
+ if (d = r(m), !d) {
189
189
  i = c + (i.length > 0 ? " " + i : i);
190
190
  continue;
191
191
  }
192
- v = !1;
192
+ k = !1;
193
193
  }
194
- const w = an(l).join(":"), k = p ? w + xt : w, E = k + f;
195
- if (s.includes(E))
194
+ const v = on(l).join(":"), I = p ? v + It : v, A = I + d;
195
+ if (s.includes(A))
196
196
  continue;
197
- s.push(E);
198
- const I = o(f, v);
199
- for (let N = 0; N < I.length; ++N) {
200
- const P = I[N];
201
- s.push(k + P);
197
+ s.push(A);
198
+ const T = o(d, k);
199
+ for (let N = 0; N < T.length; ++N) {
200
+ const b = T[N];
201
+ s.push(I + b);
202
202
  }
203
203
  i = c + (i.length > 0 ? " " + i : i);
204
204
  }
205
205
  return i;
206
206
  };
207
- function dn() {
207
+ function ln() {
208
208
  let e = 0, t, n, r = "";
209
209
  for (; e < arguments.length; )
210
- (t = arguments[e++]) && (n = At(t)) && (r && (r += " "), r += n);
210
+ (t = arguments[e++]) && (n = Tt(t)) && (r && (r += " "), r += n);
211
211
  return r;
212
212
  }
213
- const At = (e) => {
213
+ const Tt = (e) => {
214
214
  if (typeof e == "string")
215
215
  return e;
216
216
  let t, n = "";
217
217
  for (let r = 0; r < e.length; r++)
218
- e[r] && (t = At(e[r])) && (n && (n += " "), n += t);
218
+ e[r] && (t = Tt(e[r])) && (n && (n += " "), n += t);
219
219
  return n;
220
220
  };
221
- function fn(e, ...t) {
221
+ function un(e, ...t) {
222
222
  let n, r, o, s = a;
223
223
  function a(u) {
224
224
  const c = t.reduce((l, p) => p(l), e());
225
- return n = cn(c), r = n.cache.get, o = n.cache.set, s = i, i(u);
225
+ return n = sn(c), r = n.cache.get, o = n.cache.set, s = i, i(u);
226
226
  }
227
227
  function i(u) {
228
228
  const c = r(u);
229
229
  if (c)
230
230
  return c;
231
- const l = un(u, n);
231
+ const l = cn(u, n);
232
232
  return o(u, l), l;
233
233
  }
234
234
  return function() {
235
- return s(dn.apply(null, arguments));
235
+ return s(ln.apply(null, arguments));
236
236
  };
237
237
  }
238
- const K = (e) => {
238
+ const B = (e) => {
239
239
  const t = (n) => n[e] || [];
240
240
  return t.isThemeGetter = !0, t;
241
- }, St = /^\[(?:([a-z-]+):)?(.+)\]$/i, pn = /^\d+\/\d+$/, gn = /* @__PURE__ */ new Set(["px", "full", "screen"]), mn = /^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/, hn = /\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/, yn = /^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/, bn = /^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/, wn = /^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/, fe = (e) => xe(e) || gn.has(e) || pn.test(e), be = (e) => Ce(e, "length", Cn), xe = (e) => !!e && !Number.isNaN(Number(e)), He = (e) => Ce(e, "number", xe), Pe = (e) => !!e && Number.isInteger(Number(e)), vn = (e) => e.endsWith("%") && xe(e.slice(0, -1)), j = (e) => St.test(e), we = (e) => mn.test(e), kn = /* @__PURE__ */ new Set(["length", "size", "percentage"]), In = (e) => Ce(e, kn, Ct), Tn = (e) => Ce(e, "position", Ct), xn = /* @__PURE__ */ new Set(["image", "url"]), An = (e) => Ce(e, xn, En), Sn = (e) => Ce(e, "", Mn), _e = () => !0, Ce = (e, t, n) => {
242
- const r = St.exec(e);
241
+ }, xt = /^\[(?:([a-z-]+):)?(.+)\]$/i, dn = /^\d+\/\d+$/, fn = /* @__PURE__ */ new Set(["px", "full", "screen"]), pn = /^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/, gn = /\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/, mn = /^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/, hn = /^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/, yn = /^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/, fe = (e) => xe(e) || fn.has(e) || dn.test(e), be = (e) => Ce(e, "length", An), xe = (e) => !!e && !Number.isNaN(Number(e)), Ke = (e) => Ce(e, "number", xe), Pe = (e) => !!e && Number.isInteger(Number(e)), bn = (e) => e.endsWith("%") && xe(e.slice(0, -1)), R = (e) => xt.test(e), we = (e) => pn.test(e), wn = /* @__PURE__ */ new Set(["length", "size", "percentage"]), vn = (e) => Ce(e, wn, At), kn = (e) => Ce(e, "position", At), In = /* @__PURE__ */ new Set(["image", "url"]), Tn = (e) => Ce(e, In, Cn), xn = (e) => Ce(e, "", Sn), Ne = () => !0, Ce = (e, t, n) => {
242
+ const r = xt.exec(e);
243
243
  return r ? r[1] ? typeof t == "string" ? r[1] === t : t.has(r[1]) : n(r[2]) : !1;
244
- }, Cn = (e) => (
244
+ }, An = (e) => (
245
245
  // `colorFunctionRegex` check is necessary because color functions can have percentages in them which which would be incorrectly classified as lengths.
246
246
  // For example, `hsl(0 0% 0%)` would be classified as a length without this check.
247
247
  // I could also use lookbehind assertion in `lengthUnitRegex` but that isn't supported widely enough.
248
- hn.test(e) && !yn.test(e)
249
- ), Ct = () => !1, Mn = (e) => bn.test(e), En = (e) => wn.test(e), Pn = () => {
250
- const e = K("colors"), t = K("spacing"), n = K("blur"), r = K("brightness"), o = K("borderColor"), s = K("borderRadius"), a = K("borderSpacing"), i = K("borderWidth"), u = K("contrast"), c = K("grayscale"), l = K("hueRotate"), p = K("invert"), m = K("gap"), h = K("gradientColorStops"), v = K("gradientColorStopPositions"), f = K("inset"), w = K("margin"), k = K("opacity"), E = K("padding"), I = K("saturate"), N = K("scale"), P = K("sepia"), x = K("skew"), S = K("space"), g = K("translate"), y = () => ["auto", "contain", "none"], F = () => ["auto", "hidden", "clip", "visible", "scroll"], U = () => ["auto", j, t], C = () => [j, t], M = () => ["", fe, be], L = () => ["auto", xe, j], R = () => ["bottom", "center", "left", "left-bottom", "left-top", "right", "right-bottom", "right-top", "top"], V = () => ["solid", "dashed", "dotted", "double", "none"], B = () => ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"], b = () => ["start", "end", "center", "between", "around", "evenly", "stretch"], T = () => ["", "0", j], $ = () => ["auto", "avoid", "all", "avoid-page", "page", "left", "right", "column"], O = () => [xe, j];
248
+ gn.test(e) && !mn.test(e)
249
+ ), At = () => !1, Sn = (e) => hn.test(e), Cn = (e) => yn.test(e), Mn = () => {
250
+ const e = B("colors"), t = B("spacing"), n = B("blur"), r = B("brightness"), o = B("borderColor"), s = B("borderRadius"), a = B("borderSpacing"), i = B("borderWidth"), u = B("contrast"), c = B("grayscale"), l = B("hueRotate"), p = B("invert"), m = B("gap"), h = B("gradientColorStops"), k = B("gradientColorStopPositions"), d = B("inset"), v = B("margin"), I = B("opacity"), A = B("padding"), T = B("saturate"), N = B("scale"), b = B("sepia"), y = B("skew"), x = B("space"), g = B("translate"), w = () => ["auto", "contain", "none"], z = () => ["auto", "hidden", "clip", "visible", "scroll"], j = () => ["auto", R, t], S = () => [R, t], C = () => ["", fe, be], L = () => ["auto", xe, R], _ = () => ["bottom", "center", "left", "left-bottom", "left-top", "right", "right-bottom", "right-top", "top"], O = () => ["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"], G = () => ["start", "end", "center", "between", "around", "evenly", "stretch"], E = () => ["", "0", R], D = () => ["auto", "avoid", "all", "avoid-page", "page", "left", "right", "column"], Q = () => [xe, R];
251
251
  return {
252
252
  cacheSize: 500,
253
253
  separator: ":",
254
254
  theme: {
255
- colors: [_e],
255
+ colors: [Ne],
256
256
  spacing: [fe, be],
257
- blur: ["none", "", we, j],
258
- brightness: O(),
257
+ blur: ["none", "", we, R],
258
+ brightness: Q(),
259
259
  borderColor: [e],
260
- borderRadius: ["none", "", "full", we, j],
261
- borderSpacing: C(),
262
- borderWidth: M(),
263
- contrast: O(),
264
- grayscale: T(),
265
- hueRotate: O(),
266
- invert: T(),
267
- gap: C(),
260
+ borderRadius: ["none", "", "full", we, R],
261
+ borderSpacing: S(),
262
+ borderWidth: C(),
263
+ contrast: Q(),
264
+ grayscale: E(),
265
+ hueRotate: Q(),
266
+ invert: E(),
267
+ gap: S(),
268
268
  gradientColorStops: [e],
269
- gradientColorStopPositions: [vn, be],
270
- inset: U(),
271
- margin: U(),
272
- opacity: O(),
273
- padding: C(),
274
- saturate: O(),
275
- scale: O(),
276
- sepia: T(),
277
- skew: O(),
278
- space: C(),
279
- translate: C()
269
+ gradientColorStopPositions: [bn, be],
270
+ inset: j(),
271
+ margin: j(),
272
+ opacity: Q(),
273
+ padding: S(),
274
+ saturate: Q(),
275
+ scale: Q(),
276
+ sepia: E(),
277
+ skew: Q(),
278
+ space: S(),
279
+ translate: S()
280
280
  },
281
281
  classGroups: {
282
282
  // Layout
@@ -285,7 +285,7 @@ const K = (e) => {
285
285
  * @see https://tailwindcss.com/docs/aspect-ratio
286
286
  */
287
287
  aspect: [{
288
- aspect: ["auto", "square", "video", j]
288
+ aspect: ["auto", "square", "video", R]
289
289
  }],
290
290
  /**
291
291
  * Container
@@ -304,14 +304,14 @@ const K = (e) => {
304
304
  * @see https://tailwindcss.com/docs/break-after
305
305
  */
306
306
  "break-after": [{
307
- "break-after": $()
307
+ "break-after": D()
308
308
  }],
309
309
  /**
310
310
  * Break Before
311
311
  * @see https://tailwindcss.com/docs/break-before
312
312
  */
313
313
  "break-before": [{
314
- "break-before": $()
314
+ "break-before": D()
315
315
  }],
316
316
  /**
317
317
  * Break Inside
@@ -370,49 +370,49 @@ const K = (e) => {
370
370
  * @see https://tailwindcss.com/docs/object-position
371
371
  */
372
372
  "object-position": [{
373
- object: [...R(), j]
373
+ object: [..._(), R]
374
374
  }],
375
375
  /**
376
376
  * Overflow
377
377
  * @see https://tailwindcss.com/docs/overflow
378
378
  */
379
379
  overflow: [{
380
- overflow: F()
380
+ overflow: z()
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": F()
387
+ "overflow-x": z()
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": F()
394
+ "overflow-y": z()
395
395
  }],
396
396
  /**
397
397
  * Overscroll Behavior
398
398
  * @see https://tailwindcss.com/docs/overscroll-behavior
399
399
  */
400
400
  overscroll: [{
401
- overscroll: y()
401
+ overscroll: w()
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": y()
408
+ "overscroll-x": w()
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": y()
415
+ "overscroll-y": w()
416
416
  }],
417
417
  /**
418
418
  * Position
@@ -424,63 +424,63 @@ const K = (e) => {
424
424
  * @see https://tailwindcss.com/docs/top-right-bottom-left
425
425
  */
426
426
  inset: [{
427
- inset: [f]
427
+ inset: [d]
428
428
  }],
429
429
  /**
430
430
  * Right / Left
431
431
  * @see https://tailwindcss.com/docs/top-right-bottom-left
432
432
  */
433
433
  "inset-x": [{
434
- "inset-x": [f]
434
+ "inset-x": [d]
435
435
  }],
436
436
  /**
437
437
  * Top / Bottom
438
438
  * @see https://tailwindcss.com/docs/top-right-bottom-left
439
439
  */
440
440
  "inset-y": [{
441
- "inset-y": [f]
441
+ "inset-y": [d]
442
442
  }],
443
443
  /**
444
444
  * Start
445
445
  * @see https://tailwindcss.com/docs/top-right-bottom-left
446
446
  */
447
447
  start: [{
448
- start: [f]
448
+ start: [d]
449
449
  }],
450
450
  /**
451
451
  * End
452
452
  * @see https://tailwindcss.com/docs/top-right-bottom-left
453
453
  */
454
454
  end: [{
455
- end: [f]
455
+ end: [d]
456
456
  }],
457
457
  /**
458
458
  * Top
459
459
  * @see https://tailwindcss.com/docs/top-right-bottom-left
460
460
  */
461
461
  top: [{
462
- top: [f]
462
+ top: [d]
463
463
  }],
464
464
  /**
465
465
  * Right
466
466
  * @see https://tailwindcss.com/docs/top-right-bottom-left
467
467
  */
468
468
  right: [{
469
- right: [f]
469
+ right: [d]
470
470
  }],
471
471
  /**
472
472
  * Bottom
473
473
  * @see https://tailwindcss.com/docs/top-right-bottom-left
474
474
  */
475
475
  bottom: [{
476
- bottom: [f]
476
+ bottom: [d]
477
477
  }],
478
478
  /**
479
479
  * Left
480
480
  * @see https://tailwindcss.com/docs/top-right-bottom-left
481
481
  */
482
482
  left: [{
483
- left: [f]
483
+ left: [d]
484
484
  }],
485
485
  /**
486
486
  * Visibility
@@ -492,7 +492,7 @@ const K = (e) => {
492
492
  * @see https://tailwindcss.com/docs/z-index
493
493
  */
494
494
  z: [{
495
- z: ["auto", Pe, j]
495
+ z: ["auto", Pe, R]
496
496
  }],
497
497
  // Flexbox and Grid
498
498
  /**
@@ -500,7 +500,7 @@ const K = (e) => {
500
500
  * @see https://tailwindcss.com/docs/flex-basis
501
501
  */
502
502
  basis: [{
503
- basis: U()
503
+ basis: j()
504
504
  }],
505
505
  /**
506
506
  * Flex Direction
@@ -521,35 +521,35 @@ const K = (e) => {
521
521
  * @see https://tailwindcss.com/docs/flex
522
522
  */
523
523
  flex: [{
524
- flex: ["1", "auto", "initial", "none", j]
524
+ flex: ["1", "auto", "initial", "none", R]
525
525
  }],
526
526
  /**
527
527
  * Flex Grow
528
528
  * @see https://tailwindcss.com/docs/flex-grow
529
529
  */
530
530
  grow: [{
531
- grow: T()
531
+ grow: E()
532
532
  }],
533
533
  /**
534
534
  * Flex Shrink
535
535
  * @see https://tailwindcss.com/docs/flex-shrink
536
536
  */
537
537
  shrink: [{
538
- shrink: T()
538
+ shrink: E()
539
539
  }],
540
540
  /**
541
541
  * Order
542
542
  * @see https://tailwindcss.com/docs/order
543
543
  */
544
544
  order: [{
545
- order: ["first", "last", "none", Pe, j]
545
+ order: ["first", "last", "none", Pe, R]
546
546
  }],
547
547
  /**
548
548
  * Grid Template Columns
549
549
  * @see https://tailwindcss.com/docs/grid-template-columns
550
550
  */
551
551
  "grid-cols": [{
552
- "grid-cols": [_e]
552
+ "grid-cols": [Ne]
553
553
  }],
554
554
  /**
555
555
  * Grid Column Start / End
@@ -557,8 +557,8 @@ const K = (e) => {
557
557
  */
558
558
  "col-start-end": [{
559
559
  col: ["auto", {
560
- span: ["full", Pe, j]
561
- }, j]
560
+ span: ["full", Pe, R]
561
+ }, R]
562
562
  }],
563
563
  /**
564
564
  * Grid Column Start
@@ -579,7 +579,7 @@ const K = (e) => {
579
579
  * @see https://tailwindcss.com/docs/grid-template-rows
580
580
  */
581
581
  "grid-rows": [{
582
- "grid-rows": [_e]
582
+ "grid-rows": [Ne]
583
583
  }],
584
584
  /**
585
585
  * Grid Row Start / End
@@ -587,8 +587,8 @@ const K = (e) => {
587
587
  */
588
588
  "row-start-end": [{
589
589
  row: ["auto", {
590
- span: [Pe, j]
591
- }, j]
590
+ span: [Pe, R]
591
+ }, R]
592
592
  }],
593
593
  /**
594
594
  * Grid Row Start
@@ -616,14 +616,14 @@ const K = (e) => {
616
616
  * @see https://tailwindcss.com/docs/grid-auto-columns
617
617
  */
618
618
  "auto-cols": [{
619
- "auto-cols": ["auto", "min", "max", "fr", j]
619
+ "auto-cols": ["auto", "min", "max", "fr", R]
620
620
  }],
621
621
  /**
622
622
  * Grid Auto Rows
623
623
  * @see https://tailwindcss.com/docs/grid-auto-rows
624
624
  */
625
625
  "auto-rows": [{
626
- "auto-rows": ["auto", "min", "max", "fr", j]
626
+ "auto-rows": ["auto", "min", "max", "fr", R]
627
627
  }],
628
628
  /**
629
629
  * Gap
@@ -651,7 +651,7 @@ const K = (e) => {
651
651
  * @see https://tailwindcss.com/docs/justify-content
652
652
  */
653
653
  "justify-content": [{
654
- justify: ["normal", ...b()]
654
+ justify: ["normal", ...G()]
655
655
  }],
656
656
  /**
657
657
  * Justify Items
@@ -672,7 +672,7 @@ const K = (e) => {
672
672
  * @see https://tailwindcss.com/docs/align-content
673
673
  */
674
674
  "align-content": [{
675
- content: ["normal", ...b(), "baseline"]
675
+ content: ["normal", ...G(), "baseline"]
676
676
  }],
677
677
  /**
678
678
  * Align Items
@@ -693,7 +693,7 @@ const K = (e) => {
693
693
  * @see https://tailwindcss.com/docs/place-content
694
694
  */
695
695
  "place-content": [{
696
- "place-content": [...b(), "baseline"]
696
+ "place-content": [...G(), "baseline"]
697
697
  }],
698
698
  /**
699
699
  * Place Items
@@ -715,133 +715,133 @@ const K = (e) => {
715
715
  * @see https://tailwindcss.com/docs/padding
716
716
  */
717
717
  p: [{
718
- p: [E]
718
+ p: [A]
719
719
  }],
720
720
  /**
721
721
  * Padding X
722
722
  * @see https://tailwindcss.com/docs/padding
723
723
  */
724
724
  px: [{
725
- px: [E]
725
+ px: [A]
726
726
  }],
727
727
  /**
728
728
  * Padding Y
729
729
  * @see https://tailwindcss.com/docs/padding
730
730
  */
731
731
  py: [{
732
- py: [E]
732
+ py: [A]
733
733
  }],
734
734
  /**
735
735
  * Padding Start
736
736
  * @see https://tailwindcss.com/docs/padding
737
737
  */
738
738
  ps: [{
739
- ps: [E]
739
+ ps: [A]
740
740
  }],
741
741
  /**
742
742
  * Padding End
743
743
  * @see https://tailwindcss.com/docs/padding
744
744
  */
745
745
  pe: [{
746
- pe: [E]
746
+ pe: [A]
747
747
  }],
748
748
  /**
749
749
  * Padding Top
750
750
  * @see https://tailwindcss.com/docs/padding
751
751
  */
752
752
  pt: [{
753
- pt: [E]
753
+ pt: [A]
754
754
  }],
755
755
  /**
756
756
  * Padding Right
757
757
  * @see https://tailwindcss.com/docs/padding
758
758
  */
759
759
  pr: [{
760
- pr: [E]
760
+ pr: [A]
761
761
  }],
762
762
  /**
763
763
  * Padding Bottom
764
764
  * @see https://tailwindcss.com/docs/padding
765
765
  */
766
766
  pb: [{
767
- pb: [E]
767
+ pb: [A]
768
768
  }],
769
769
  /**
770
770
  * Padding Left
771
771
  * @see https://tailwindcss.com/docs/padding
772
772
  */
773
773
  pl: [{
774
- pl: [E]
774
+ pl: [A]
775
775
  }],
776
776
  /**
777
777
  * Margin
778
778
  * @see https://tailwindcss.com/docs/margin
779
779
  */
780
780
  m: [{
781
- m: [w]
781
+ m: [v]
782
782
  }],
783
783
  /**
784
784
  * Margin X
785
785
  * @see https://tailwindcss.com/docs/margin
786
786
  */
787
787
  mx: [{
788
- mx: [w]
788
+ mx: [v]
789
789
  }],
790
790
  /**
791
791
  * Margin Y
792
792
  * @see https://tailwindcss.com/docs/margin
793
793
  */
794
794
  my: [{
795
- my: [w]
795
+ my: [v]
796
796
  }],
797
797
  /**
798
798
  * Margin Start
799
799
  * @see https://tailwindcss.com/docs/margin
800
800
  */
801
801
  ms: [{
802
- ms: [w]
802
+ ms: [v]
803
803
  }],
804
804
  /**
805
805
  * Margin End
806
806
  * @see https://tailwindcss.com/docs/margin
807
807
  */
808
808
  me: [{
809
- me: [w]
809
+ me: [v]
810
810
  }],
811
811
  /**
812
812
  * Margin Top
813
813
  * @see https://tailwindcss.com/docs/margin
814
814
  */
815
815
  mt: [{
816
- mt: [w]
816
+ mt: [v]
817
817
  }],
818
818
  /**
819
819
  * Margin Right
820
820
  * @see https://tailwindcss.com/docs/margin
821
821
  */
822
822
  mr: [{
823
- mr: [w]
823
+ mr: [v]
824
824
  }],
825
825
  /**
826
826
  * Margin Bottom
827
827
  * @see https://tailwindcss.com/docs/margin
828
828
  */
829
829
  mb: [{
830
- mb: [w]
830
+ mb: [v]
831
831
  }],
832
832
  /**
833
833
  * Margin Left
834
834
  * @see https://tailwindcss.com/docs/margin
835
835
  */
836
836
  ml: [{
837
- ml: [w]
837
+ ml: [v]
838
838
  }],
839
839
  /**
840
840
  * Space Between X
841
841
  * @see https://tailwindcss.com/docs/space
842
842
  */
843
843
  "space-x": [{
844
- "space-x": [S]
844
+ "space-x": [x]
845
845
  }],
846
846
  /**
847
847
  * Space Between X Reverse
@@ -853,7 +853,7 @@ const K = (e) => {
853
853
  * @see https://tailwindcss.com/docs/space
854
854
  */
855
855
  "space-y": [{
856
- "space-y": [S]
856
+ "space-y": [x]
857
857
  }],
858
858
  /**
859
859
  * Space Between Y Reverse
@@ -866,21 +866,21 @@ const K = (e) => {
866
866
  * @see https://tailwindcss.com/docs/width
867
867
  */
868
868
  w: [{
869
- w: ["auto", "min", "max", "fit", "svw", "lvw", "dvw", j, t]
869
+ w: ["auto", "min", "max", "fit", "svw", "lvw", "dvw", R, t]
870
870
  }],
871
871
  /**
872
872
  * Min-Width
873
873
  * @see https://tailwindcss.com/docs/min-width
874
874
  */
875
875
  "min-w": [{
876
- "min-w": [j, t, "min", "max", "fit"]
876
+ "min-w": [R, t, "min", "max", "fit"]
877
877
  }],
878
878
  /**
879
879
  * Max-Width
880
880
  * @see https://tailwindcss.com/docs/max-width
881
881
  */
882
882
  "max-w": [{
883
- "max-w": [j, t, "none", "full", "min", "max", "fit", "prose", {
883
+ "max-w": [R, t, "none", "full", "min", "max", "fit", "prose", {
884
884
  screen: [we]
885
885
  }, we]
886
886
  }],
@@ -889,28 +889,28 @@ const K = (e) => {
889
889
  * @see https://tailwindcss.com/docs/height
890
890
  */
891
891
  h: [{
892
- h: [j, t, "auto", "min", "max", "fit", "svh", "lvh", "dvh"]
892
+ h: [R, t, "auto", "min", "max", "fit", "svh", "lvh", "dvh"]
893
893
  }],
894
894
  /**
895
895
  * Min-Height
896
896
  * @see https://tailwindcss.com/docs/min-height
897
897
  */
898
898
  "min-h": [{
899
- "min-h": [j, t, "min", "max", "fit", "svh", "lvh", "dvh"]
899
+ "min-h": [R, t, "min", "max", "fit", "svh", "lvh", "dvh"]
900
900
  }],
901
901
  /**
902
902
  * Max-Height
903
903
  * @see https://tailwindcss.com/docs/max-height
904
904
  */
905
905
  "max-h": [{
906
- "max-h": [j, t, "min", "max", "fit", "svh", "lvh", "dvh"]
906
+ "max-h": [R, t, "min", "max", "fit", "svh", "lvh", "dvh"]
907
907
  }],
908
908
  /**
909
909
  * Size
910
910
  * @see https://tailwindcss.com/docs/size
911
911
  */
912
912
  size: [{
913
- size: [j, t, "auto", "min", "max", "fit"]
913
+ size: [R, t, "auto", "min", "max", "fit"]
914
914
  }],
915
915
  // Typography
916
916
  /**
@@ -935,14 +935,14 @@ const K = (e) => {
935
935
  * @see https://tailwindcss.com/docs/font-weight
936
936
  */
937
937
  "font-weight": [{
938
- font: ["thin", "extralight", "light", "normal", "medium", "semibold", "bold", "extrabold", "black", He]
938
+ font: ["thin", "extralight", "light", "normal", "medium", "semibold", "bold", "extrabold", "black", Ke]
939
939
  }],
940
940
  /**
941
941
  * Font Family
942
942
  * @see https://tailwindcss.com/docs/font-family
943
943
  */
944
944
  "font-family": [{
945
- font: [_e]
945
+ font: [Ne]
946
946
  }],
947
947
  /**
948
948
  * Font Variant Numeric
@@ -979,35 +979,35 @@ const K = (e) => {
979
979
  * @see https://tailwindcss.com/docs/letter-spacing
980
980
  */
981
981
  tracking: [{
982
- tracking: ["tighter", "tight", "normal", "wide", "wider", "widest", j]
982
+ tracking: ["tighter", "tight", "normal", "wide", "wider", "widest", R]
983
983
  }],
984
984
  /**
985
985
  * Line Clamp
986
986
  * @see https://tailwindcss.com/docs/line-clamp
987
987
  */
988
988
  "line-clamp": [{
989
- "line-clamp": ["none", xe, He]
989
+ "line-clamp": ["none", xe, Ke]
990
990
  }],
991
991
  /**
992
992
  * Line Height
993
993
  * @see https://tailwindcss.com/docs/line-height
994
994
  */
995
995
  leading: [{
996
- leading: ["none", "tight", "snug", "normal", "relaxed", "loose", fe, j]
996
+ leading: ["none", "tight", "snug", "normal", "relaxed", "loose", fe, R]
997
997
  }],
998
998
  /**
999
999
  * List Style Image
1000
1000
  * @see https://tailwindcss.com/docs/list-style-image
1001
1001
  */
1002
1002
  "list-image": [{
1003
- "list-image": ["none", j]
1003
+ "list-image": ["none", R]
1004
1004
  }],
1005
1005
  /**
1006
1006
  * List Style Type
1007
1007
  * @see https://tailwindcss.com/docs/list-style-type
1008
1008
  */
1009
1009
  "list-style-type": [{
1010
- list: ["none", "disc", "decimal", j]
1010
+ list: ["none", "disc", "decimal", R]
1011
1011
  }],
1012
1012
  /**
1013
1013
  * List Style Position
@@ -1029,7 +1029,7 @@ const K = (e) => {
1029
1029
  * @see https://tailwindcss.com/docs/placeholder-opacity
1030
1030
  */
1031
1031
  "placeholder-opacity": [{
1032
- "placeholder-opacity": [k]
1032
+ "placeholder-opacity": [I]
1033
1033
  }],
1034
1034
  /**
1035
1035
  * Text Alignment
@@ -1050,7 +1050,7 @@ const K = (e) => {
1050
1050
  * @see https://tailwindcss.com/docs/text-opacity
1051
1051
  */
1052
1052
  "text-opacity": [{
1053
- "text-opacity": [k]
1053
+ "text-opacity": [I]
1054
1054
  }],
1055
1055
  /**
1056
1056
  * Text Decoration
@@ -1062,7 +1062,7 @@ const K = (e) => {
1062
1062
  * @see https://tailwindcss.com/docs/text-decoration-style
1063
1063
  */
1064
1064
  "text-decoration-style": [{
1065
- decoration: [...V(), "wavy"]
1065
+ decoration: [...O(), "wavy"]
1066
1066
  }],
1067
1067
  /**
1068
1068
  * Text Decoration Thickness
@@ -1076,7 +1076,7 @@ const K = (e) => {
1076
1076
  * @see https://tailwindcss.com/docs/text-underline-offset
1077
1077
  */
1078
1078
  "underline-offset": [{
1079
- "underline-offset": ["auto", fe, j]
1079
+ "underline-offset": ["auto", fe, R]
1080
1080
  }],
1081
1081
  /**
1082
1082
  * Text Decoration Color
@@ -1107,14 +1107,14 @@ const K = (e) => {
1107
1107
  * @see https://tailwindcss.com/docs/text-indent
1108
1108
  */
1109
1109
  indent: [{
1110
- indent: C()
1110
+ indent: S()
1111
1111
  }],
1112
1112
  /**
1113
1113
  * Vertical Alignment
1114
1114
  * @see https://tailwindcss.com/docs/vertical-align
1115
1115
  */
1116
1116
  "vertical-align": [{
1117
- align: ["baseline", "top", "middle", "bottom", "text-top", "text-bottom", "sub", "super", j]
1117
+ align: ["baseline", "top", "middle", "bottom", "text-top", "text-bottom", "sub", "super", R]
1118
1118
  }],
1119
1119
  /**
1120
1120
  * Whitespace
@@ -1142,7 +1142,7 @@ const K = (e) => {
1142
1142
  * @see https://tailwindcss.com/docs/content
1143
1143
  */
1144
1144
  content: [{
1145
- content: ["none", j]
1145
+ content: ["none", R]
1146
1146
  }],
1147
1147
  // Backgrounds
1148
1148
  /**
@@ -1165,7 +1165,7 @@ const K = (e) => {
1165
1165
  * @see https://tailwindcss.com/docs/background-opacity
1166
1166
  */
1167
1167
  "bg-opacity": [{
1168
- "bg-opacity": [k]
1168
+ "bg-opacity": [I]
1169
1169
  }],
1170
1170
  /**
1171
1171
  * Background Origin
@@ -1179,7 +1179,7 @@ const K = (e) => {
1179
1179
  * @see https://tailwindcss.com/docs/background-position
1180
1180
  */
1181
1181
  "bg-position": [{
1182
- bg: [...R(), Tn]
1182
+ bg: [..._(), kn]
1183
1183
  }],
1184
1184
  /**
1185
1185
  * Background Repeat
@@ -1195,7 +1195,7 @@ const K = (e) => {
1195
1195
  * @see https://tailwindcss.com/docs/background-size
1196
1196
  */
1197
1197
  "bg-size": [{
1198
- bg: ["auto", "cover", "contain", In]
1198
+ bg: ["auto", "cover", "contain", vn]
1199
1199
  }],
1200
1200
  /**
1201
1201
  * Background Image
@@ -1204,7 +1204,7 @@ const K = (e) => {
1204
1204
  "bg-image": [{
1205
1205
  bg: ["none", {
1206
1206
  "gradient-to": ["t", "tr", "r", "br", "b", "bl", "l", "tl"]
1207
- }, An]
1207
+ }, Tn]
1208
1208
  }],
1209
1209
  /**
1210
1210
  * Background Color
@@ -1218,21 +1218,21 @@ const K = (e) => {
1218
1218
  * @see https://tailwindcss.com/docs/gradient-color-stops
1219
1219
  */
1220
1220
  "gradient-from-pos": [{
1221
- from: [v]
1221
+ from: [k]
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: [k]
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: [k]
1236
1236
  }],
1237
1237
  /**
1238
1238
  * Gradient Color Stops From
@@ -1429,14 +1429,14 @@ const K = (e) => {
1429
1429
  * @see https://tailwindcss.com/docs/border-opacity
1430
1430
  */
1431
1431
  "border-opacity": [{
1432
- "border-opacity": [k]
1432
+ "border-opacity": [I]
1433
1433
  }],
1434
1434
  /**
1435
1435
  * Border Style
1436
1436
  * @see https://tailwindcss.com/docs/border-style
1437
1437
  */
1438
1438
  "border-style": [{
1439
- border: [...V(), "hidden"]
1439
+ border: [...O(), "hidden"]
1440
1440
  }],
1441
1441
  /**
1442
1442
  * Divide Width X
@@ -1467,14 +1467,14 @@ const K = (e) => {
1467
1467
  * @see https://tailwindcss.com/docs/divide-opacity
1468
1468
  */
1469
1469
  "divide-opacity": [{
1470
- "divide-opacity": [k]
1470
+ "divide-opacity": [I]
1471
1471
  }],
1472
1472
  /**
1473
1473
  * Divide Style
1474
1474
  * @see https://tailwindcss.com/docs/divide-style
1475
1475
  */
1476
1476
  "divide-style": [{
1477
- divide: V()
1477
+ divide: O()
1478
1478
  }],
1479
1479
  /**
1480
1480
  * Border Color
@@ -1551,14 +1551,14 @@ const K = (e) => {
1551
1551
  * @see https://tailwindcss.com/docs/outline-style
1552
1552
  */
1553
1553
  "outline-style": [{
1554
- outline: ["", ...V()]
1554
+ outline: ["", ...O()]
1555
1555
  }],
1556
1556
  /**
1557
1557
  * Outline Offset
1558
1558
  * @see https://tailwindcss.com/docs/outline-offset
1559
1559
  */
1560
1560
  "outline-offset": [{
1561
- "outline-offset": [fe, j]
1561
+ "outline-offset": [fe, R]
1562
1562
  }],
1563
1563
  /**
1564
1564
  * Outline Width
@@ -1579,7 +1579,7 @@ const K = (e) => {
1579
1579
  * @see https://tailwindcss.com/docs/ring-width
1580
1580
  */
1581
1581
  "ring-w": [{
1582
- ring: M()
1582
+ ring: C()
1583
1583
  }],
1584
1584
  /**
1585
1585
  * Ring Width Inset
@@ -1598,7 +1598,7 @@ const K = (e) => {
1598
1598
  * @see https://tailwindcss.com/docs/ring-opacity
1599
1599
  */
1600
1600
  "ring-opacity": [{
1601
- "ring-opacity": [k]
1601
+ "ring-opacity": [I]
1602
1602
  }],
1603
1603
  /**
1604
1604
  * Ring Offset Width
@@ -1620,35 +1620,35 @@ const K = (e) => {
1620
1620
  * @see https://tailwindcss.com/docs/box-shadow
1621
1621
  */
1622
1622
  shadow: [{
1623
- shadow: ["", "inner", "none", we, Sn]
1623
+ shadow: ["", "inner", "none", we, xn]
1624
1624
  }],
1625
1625
  /**
1626
1626
  * Box Shadow Color
1627
1627
  * @see https://tailwindcss.com/docs/box-shadow-color
1628
1628
  */
1629
1629
  "shadow-color": [{
1630
- shadow: [_e]
1630
+ shadow: [Ne]
1631
1631
  }],
1632
1632
  /**
1633
1633
  * Opacity
1634
1634
  * @see https://tailwindcss.com/docs/opacity
1635
1635
  */
1636
1636
  opacity: [{
1637
- opacity: [k]
1637
+ opacity: [I]
1638
1638
  }],
1639
1639
  /**
1640
1640
  * Mix Blend Mode
1641
1641
  * @see https://tailwindcss.com/docs/mix-blend-mode
1642
1642
  */
1643
1643
  "mix-blend": [{
1644
- "mix-blend": [...B(), "plus-lighter", "plus-darker"]
1644
+ "mix-blend": [...F(), "plus-lighter", "plus-darker"]
1645
1645
  }],
1646
1646
  /**
1647
1647
  * Background Blend Mode
1648
1648
  * @see https://tailwindcss.com/docs/background-blend-mode
1649
1649
  */
1650
1650
  "bg-blend": [{
1651
- "bg-blend": B()
1651
+ "bg-blend": F()
1652
1652
  }],
1653
1653
  // Filters
1654
1654
  /**
@@ -1685,7 +1685,7 @@ const K = (e) => {
1685
1685
  * @see https://tailwindcss.com/docs/drop-shadow
1686
1686
  */
1687
1687
  "drop-shadow": [{
1688
- "drop-shadow": ["", "none", we, j]
1688
+ "drop-shadow": ["", "none", we, R]
1689
1689
  }],
1690
1690
  /**
1691
1691
  * Grayscale
@@ -1713,14 +1713,14 @@ const K = (e) => {
1713
1713
  * @see https://tailwindcss.com/docs/saturate
1714
1714
  */
1715
1715
  saturate: [{
1716
- saturate: [I]
1716
+ saturate: [T]
1717
1717
  }],
1718
1718
  /**
1719
1719
  * Sepia
1720
1720
  * @see https://tailwindcss.com/docs/sepia
1721
1721
  */
1722
1722
  sepia: [{
1723
- sepia: [P]
1723
+ sepia: [b]
1724
1724
  }],
1725
1725
  /**
1726
1726
  * Backdrop Filter
@@ -1777,21 +1777,21 @@ const K = (e) => {
1777
1777
  * @see https://tailwindcss.com/docs/backdrop-opacity
1778
1778
  */
1779
1779
  "backdrop-opacity": [{
1780
- "backdrop-opacity": [k]
1780
+ "backdrop-opacity": [I]
1781
1781
  }],
1782
1782
  /**
1783
1783
  * Backdrop Saturate
1784
1784
  * @see https://tailwindcss.com/docs/backdrop-saturate
1785
1785
  */
1786
1786
  "backdrop-saturate": [{
1787
- "backdrop-saturate": [I]
1787
+ "backdrop-saturate": [T]
1788
1788
  }],
1789
1789
  /**
1790
1790
  * Backdrop Sepia
1791
1791
  * @see https://tailwindcss.com/docs/backdrop-sepia
1792
1792
  */
1793
1793
  "backdrop-sepia": [{
1794
- "backdrop-sepia": [P]
1794
+ "backdrop-sepia": [b]
1795
1795
  }],
1796
1796
  // Tables
1797
1797
  /**
@@ -1842,35 +1842,35 @@ const K = (e) => {
1842
1842
  * @see https://tailwindcss.com/docs/transition-property
1843
1843
  */
1844
1844
  transition: [{
1845
- transition: ["none", "all", "", "colors", "opacity", "shadow", "transform", j]
1845
+ transition: ["none", "all", "", "colors", "opacity", "shadow", "transform", R]
1846
1846
  }],
1847
1847
  /**
1848
1848
  * Transition Duration
1849
1849
  * @see https://tailwindcss.com/docs/transition-duration
1850
1850
  */
1851
1851
  duration: [{
1852
- duration: O()
1852
+ duration: Q()
1853
1853
  }],
1854
1854
  /**
1855
1855
  * Transition Timing Function
1856
1856
  * @see https://tailwindcss.com/docs/transition-timing-function
1857
1857
  */
1858
1858
  ease: [{
1859
- ease: ["linear", "in", "out", "in-out", j]
1859
+ ease: ["linear", "in", "out", "in-out", R]
1860
1860
  }],
1861
1861
  /**
1862
1862
  * Transition Delay
1863
1863
  * @see https://tailwindcss.com/docs/transition-delay
1864
1864
  */
1865
1865
  delay: [{
1866
- delay: O()
1866
+ delay: Q()
1867
1867
  }],
1868
1868
  /**
1869
1869
  * Animation
1870
1870
  * @see https://tailwindcss.com/docs/animation
1871
1871
  */
1872
1872
  animate: [{
1873
- animate: ["none", "spin", "ping", "pulse", "bounce", j]
1873
+ animate: ["none", "spin", "ping", "pulse", "bounce", R]
1874
1874
  }],
1875
1875
  // Transforms
1876
1876
  /**
@@ -1906,7 +1906,7 @@ const K = (e) => {
1906
1906
  * @see https://tailwindcss.com/docs/rotate
1907
1907
  */
1908
1908
  rotate: [{
1909
- rotate: [Pe, j]
1909
+ rotate: [Pe, R]
1910
1910
  }],
1911
1911
  /**
1912
1912
  * Translate X
@@ -1927,21 +1927,21 @@ const K = (e) => {
1927
1927
  * @see https://tailwindcss.com/docs/skew
1928
1928
  */
1929
1929
  "skew-x": [{
1930
- "skew-x": [x]
1930
+ "skew-x": [y]
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": [x]
1937
+ "skew-y": [y]
1938
1938
  }],
1939
1939
  /**
1940
1940
  * Transform Origin
1941
1941
  * @see https://tailwindcss.com/docs/transform-origin
1942
1942
  */
1943
1943
  "transform-origin": [{
1944
- origin: ["center", "top", "top-right", "right", "bottom-right", "bottom", "bottom-left", "left", "top-left", j]
1944
+ origin: ["center", "top", "top-right", "right", "bottom-right", "bottom", "bottom-left", "left", "top-left", R]
1945
1945
  }],
1946
1946
  // Interactivity
1947
1947
  /**
@@ -1963,7 +1963,7 @@ const K = (e) => {
1963
1963
  * @see https://tailwindcss.com/docs/cursor
1964
1964
  */
1965
1965
  cursor: [{
1966
- cursor: ["auto", "default", "pointer", "wait", "text", "move", "help", "not-allowed", "none", "context-menu", "progress", "cell", "crosshair", "vertical-text", "alias", "copy", "no-drop", "grab", "grabbing", "all-scroll", "col-resize", "row-resize", "n-resize", "e-resize", "s-resize", "w-resize", "ne-resize", "nw-resize", "se-resize", "sw-resize", "ew-resize", "ns-resize", "nesw-resize", "nwse-resize", "zoom-in", "zoom-out", j]
1966
+ cursor: ["auto", "default", "pointer", "wait", "text", "move", "help", "not-allowed", "none", "context-menu", "progress", "cell", "crosshair", "vertical-text", "alias", "copy", "no-drop", "grab", "grabbing", "all-scroll", "col-resize", "row-resize", "n-resize", "e-resize", "s-resize", "w-resize", "ne-resize", "nw-resize", "se-resize", "sw-resize", "ew-resize", "ns-resize", "nesw-resize", "nwse-resize", "zoom-in", "zoom-out", R]
1967
1967
  }],
1968
1968
  /**
1969
1969
  * Caret Color
@@ -1998,126 +1998,126 @@ const K = (e) => {
1998
1998
  * @see https://tailwindcss.com/docs/scroll-margin
1999
1999
  */
2000
2000
  "scroll-m": [{
2001
- "scroll-m": C()
2001
+ "scroll-m": S()
2002
2002
  }],
2003
2003
  /**
2004
2004
  * Scroll Margin X
2005
2005
  * @see https://tailwindcss.com/docs/scroll-margin
2006
2006
  */
2007
2007
  "scroll-mx": [{
2008
- "scroll-mx": C()
2008
+ "scroll-mx": S()
2009
2009
  }],
2010
2010
  /**
2011
2011
  * Scroll Margin Y
2012
2012
  * @see https://tailwindcss.com/docs/scroll-margin
2013
2013
  */
2014
2014
  "scroll-my": [{
2015
- "scroll-my": C()
2015
+ "scroll-my": S()
2016
2016
  }],
2017
2017
  /**
2018
2018
  * Scroll Margin Start
2019
2019
  * @see https://tailwindcss.com/docs/scroll-margin
2020
2020
  */
2021
2021
  "scroll-ms": [{
2022
- "scroll-ms": C()
2022
+ "scroll-ms": S()
2023
2023
  }],
2024
2024
  /**
2025
2025
  * Scroll Margin End
2026
2026
  * @see https://tailwindcss.com/docs/scroll-margin
2027
2027
  */
2028
2028
  "scroll-me": [{
2029
- "scroll-me": C()
2029
+ "scroll-me": S()
2030
2030
  }],
2031
2031
  /**
2032
2032
  * Scroll Margin Top
2033
2033
  * @see https://tailwindcss.com/docs/scroll-margin
2034
2034
  */
2035
2035
  "scroll-mt": [{
2036
- "scroll-mt": C()
2036
+ "scroll-mt": S()
2037
2037
  }],
2038
2038
  /**
2039
2039
  * Scroll Margin Right
2040
2040
  * @see https://tailwindcss.com/docs/scroll-margin
2041
2041
  */
2042
2042
  "scroll-mr": [{
2043
- "scroll-mr": C()
2043
+ "scroll-mr": S()
2044
2044
  }],
2045
2045
  /**
2046
2046
  * Scroll Margin Bottom
2047
2047
  * @see https://tailwindcss.com/docs/scroll-margin
2048
2048
  */
2049
2049
  "scroll-mb": [{
2050
- "scroll-mb": C()
2050
+ "scroll-mb": S()
2051
2051
  }],
2052
2052
  /**
2053
2053
  * Scroll Margin Left
2054
2054
  * @see https://tailwindcss.com/docs/scroll-margin
2055
2055
  */
2056
2056
  "scroll-ml": [{
2057
- "scroll-ml": C()
2057
+ "scroll-ml": S()
2058
2058
  }],
2059
2059
  /**
2060
2060
  * Scroll Padding
2061
2061
  * @see https://tailwindcss.com/docs/scroll-padding
2062
2062
  */
2063
2063
  "scroll-p": [{
2064
- "scroll-p": C()
2064
+ "scroll-p": S()
2065
2065
  }],
2066
2066
  /**
2067
2067
  * Scroll Padding X
2068
2068
  * @see https://tailwindcss.com/docs/scroll-padding
2069
2069
  */
2070
2070
  "scroll-px": [{
2071
- "scroll-px": C()
2071
+ "scroll-px": S()
2072
2072
  }],
2073
2073
  /**
2074
2074
  * Scroll Padding Y
2075
2075
  * @see https://tailwindcss.com/docs/scroll-padding
2076
2076
  */
2077
2077
  "scroll-py": [{
2078
- "scroll-py": C()
2078
+ "scroll-py": S()
2079
2079
  }],
2080
2080
  /**
2081
2081
  * Scroll Padding Start
2082
2082
  * @see https://tailwindcss.com/docs/scroll-padding
2083
2083
  */
2084
2084
  "scroll-ps": [{
2085
- "scroll-ps": C()
2085
+ "scroll-ps": S()
2086
2086
  }],
2087
2087
  /**
2088
2088
  * Scroll Padding End
2089
2089
  * @see https://tailwindcss.com/docs/scroll-padding
2090
2090
  */
2091
2091
  "scroll-pe": [{
2092
- "scroll-pe": C()
2092
+ "scroll-pe": S()
2093
2093
  }],
2094
2094
  /**
2095
2095
  * Scroll Padding Top
2096
2096
  * @see https://tailwindcss.com/docs/scroll-padding
2097
2097
  */
2098
2098
  "scroll-pt": [{
2099
- "scroll-pt": C()
2099
+ "scroll-pt": S()
2100
2100
  }],
2101
2101
  /**
2102
2102
  * Scroll Padding Right
2103
2103
  * @see https://tailwindcss.com/docs/scroll-padding
2104
2104
  */
2105
2105
  "scroll-pr": [{
2106
- "scroll-pr": C()
2106
+ "scroll-pr": S()
2107
2107
  }],
2108
2108
  /**
2109
2109
  * Scroll Padding Bottom
2110
2110
  * @see https://tailwindcss.com/docs/scroll-padding
2111
2111
  */
2112
2112
  "scroll-pb": [{
2113
- "scroll-pb": C()
2113
+ "scroll-pb": S()
2114
2114
  }],
2115
2115
  /**
2116
2116
  * Scroll Padding Left
2117
2117
  * @see https://tailwindcss.com/docs/scroll-padding
2118
2118
  */
2119
2119
  "scroll-pl": [{
2120
- "scroll-pl": C()
2120
+ "scroll-pl": S()
2121
2121
  }],
2122
2122
  /**
2123
2123
  * Scroll Snap Align
@@ -2185,7 +2185,7 @@ const K = (e) => {
2185
2185
  * @see https://tailwindcss.com/docs/will-change
2186
2186
  */
2187
2187
  "will-change": [{
2188
- "will-change": ["auto", "scroll", "contents", "transform", j]
2188
+ "will-change": ["auto", "scroll", "contents", "transform", R]
2189
2189
  }],
2190
2190
  // SVG
2191
2191
  /**
@@ -2200,7 +2200,7 @@ const K = (e) => {
2200
2200
  * @see https://tailwindcss.com/docs/stroke-width
2201
2201
  */
2202
2202
  "stroke-w": [{
2203
- stroke: [fe, be, He]
2203
+ stroke: [fe, be, Ke]
2204
2204
  }],
2205
2205
  /**
2206
2206
  * Stroke
@@ -2275,11 +2275,11 @@ const K = (e) => {
2275
2275
  "font-size": ["leading"]
2276
2276
  }
2277
2277
  };
2278
- }, _n = /* @__PURE__ */ fn(Pn);
2279
- function to(...e) {
2280
- return _n(Yt(e));
2278
+ }, En = /* @__PURE__ */ un(Mn);
2279
+ function Yr(...e) {
2280
+ return En(Xt(e));
2281
2281
  }
2282
- function Nn(e) {
2282
+ function Pn(e) {
2283
2283
  let t = !1, n = "";
2284
2284
  for (const o of e) {
2285
2285
  if (o === "\\") {
@@ -2294,13 +2294,13 @@ function Nn(e) {
2294
2294
  }
2295
2295
  return n.replace(/\bTrue\b/g, "true").replace(/\bFalse\b/g, "false").replace(/\bNone\b/g, "null");
2296
2296
  }
2297
- function tt(e) {
2297
+ function et(e) {
2298
2298
  const t = e == null ? void 0 : e.trim();
2299
2299
  if (!t || !(t.startsWith("{") || t.startsWith("["))) return null;
2300
2300
  try {
2301
2301
  return JSON.parse(t);
2302
2302
  } catch {
2303
- const n = Nn(t);
2303
+ const n = Pn(t);
2304
2304
  if (n)
2305
2305
  try {
2306
2306
  return JSON.parse(n);
@@ -2310,29 +2310,29 @@ function tt(e) {
2310
2310
  return null;
2311
2311
  }
2312
2312
  }
2313
- function Rn(e) {
2313
+ function Nn(e) {
2314
2314
  return typeof e != "string" ? !1 : /^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e);
2315
2315
  }
2316
- function zn(e) {
2316
+ function _n(e) {
2317
2317
  return e.type === "image_url";
2318
2318
  }
2319
- function Un(e) {
2319
+ function zn(e) {
2320
2320
  return e.type === "file";
2321
2321
  }
2322
- function Ln(e) {
2322
+ function Rn(e) {
2323
2323
  return Array.isArray(e.content) ? e.content.filter((t) => t.type === "text").map((t) => t.text).join(`
2324
2324
  `).trim() : typeof e.content == "string" ? e.content : "";
2325
2325
  }
2326
+ function Un(e) {
2327
+ return e.content.filter(_n);
2328
+ }
2326
2329
  function jn(e) {
2327
2330
  return e.content.filter(zn);
2328
2331
  }
2329
- function Fn(e) {
2330
- return e.content.filter(Un);
2331
- }
2332
- function Mt(e) {
2332
+ function St(e) {
2333
2333
  return Array.isArray(e.toolCalls) ? e.toolCalls : [];
2334
2334
  }
2335
- function On(e) {
2335
+ function Ln(e) {
2336
2336
  const t = [];
2337
2337
  return e.forEach((n) => {
2338
2338
  n.artifact && t.push(n.artifact), Array.isArray(n.toolCalls) && n.toolCalls.forEach((r) => {
@@ -2340,22 +2340,22 @@ function On(e) {
2340
2340
  });
2341
2341
  }), t;
2342
2342
  }
2343
- function Et(e) {
2343
+ function Ct(e) {
2344
2344
  return !!(e && typeof e == "object" && (e.type === "file" || e.mimeType || e.filename || e.sourceType === "base64"));
2345
2345
  }
2346
- function Ke(e) {
2346
+ function Ve(e) {
2347
2347
  if (typeof e == "string")
2348
2348
  return e;
2349
2349
  if (e && typeof e == "object") {
2350
2350
  if (Array.isArray(e)) {
2351
- const n = e.map(Ke).filter((r) => r !== void 0);
2351
+ const n = e.map(Ve).filter((r) => r !== void 0);
2352
2352
  if (!n.length) {
2353
2353
  console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined", { originalLength: e.length });
2354
2354
  return;
2355
2355
  }
2356
2356
  return n;
2357
2357
  }
2358
- if (Et(e)) {
2358
+ if (Ct(e)) {
2359
2359
  try {
2360
2360
  console.debug("[message-utils] sanitizeForDisplay - dropping file-like object", {
2361
2361
  sampleFilename: e && (e.filename || e.name) ? e.filename || e.name : void 0,
@@ -2372,7 +2372,7 @@ function Ke(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 o = Ke(r);
2375
+ const o = Ve(r);
2376
2376
  o !== void 0 && (t[n] = o);
2377
2377
  }
2378
2378
  }
@@ -2387,24 +2387,24 @@ function Ke(e) {
2387
2387
  }
2388
2388
  return e;
2389
2389
  }
2390
- function Pt(e) {
2390
+ function Mt(e) {
2391
2391
  if (typeof e == "string") return e;
2392
- if (Et(e)) return "";
2392
+ if (Ct(e)) return "";
2393
2393
  try {
2394
- const t = Ke(e);
2394
+ const t = Ve(e);
2395
2395
  return t === void 0 ? "" : typeof t == "string" ? t : JSON.stringify(t, null, 2);
2396
2396
  } catch {
2397
2397
  return "";
2398
2398
  }
2399
2399
  }
2400
- function no(e) {
2401
- const t = Pt(e);
2402
- return typeof e == "string" && Rn(e) ? { content: e, isMarkdown: !0 } : { content: t, isMarkdown: !1 };
2400
+ function Zr(e) {
2401
+ const t = Mt(e);
2402
+ return typeof e == "string" && Nn(e) ? { content: e, isMarkdown: !0 } : { content: t, isMarkdown: !1 };
2403
2403
  }
2404
- function $n(e) {
2404
+ function Fn(e) {
2405
2405
  const t = (r) => {
2406
2406
  try {
2407
- const o = Ke(r);
2407
+ const o = Ve(r);
2408
2408
  return typeof o == "string" ? o : JSON.stringify(o ?? "");
2409
2409
  } catch {
2410
2410
  return "";
@@ -2413,7 +2413,7 @@ function $n(e) {
2413
2413
  return n.length ? t(n.map((r) => r.text).join(`
2414
2414
  `)) : t(e);
2415
2415
  }
2416
- function ro(e) {
2416
+ function eo(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 ce(e) {
@@ -2421,7 +2421,7 @@ function ce(e) {
2421
2421
  if (typeof e == "string") {
2422
2422
  const t = e.trim();
2423
2423
  if (t.startsWith("{") || t.startsWith("[")) {
2424
- const n = tt(t);
2424
+ const n = et(t);
2425
2425
  if (n !== null)
2426
2426
  return ce(n);
2427
2427
  }
@@ -2436,24 +2436,24 @@ function ce(e) {
2436
2436
  }
2437
2437
  return typeof e == "object" && !Array.isArray(e) && (e.type === "text" && typeof e.text == "string" || typeof e.text == "string") ? e.text : Array.isArray(e) && e.length > 0 ? ce(e[0]) : e;
2438
2438
  }
2439
- function Bn(e) {
2439
+ function On(e) {
2440
2440
  return e.replace(/[_-](\w)/g, (t, n) => n ? n.toUpperCase() : "").replace(/^\w/, (t) => t.toLowerCase());
2441
2441
  }
2442
2442
  function le(e) {
2443
2443
  return !e || typeof e != "object" ? e : Array.isArray(e) ? e.map(le) : Object.fromEntries(
2444
2444
  Object.entries(e).map(([t, n]) => [
2445
- Bn(t),
2445
+ On(t),
2446
2446
  le(n)
2447
2447
  ])
2448
2448
  );
2449
2449
  }
2450
- function nt(e) {
2451
- var w, k, E, I, N, P;
2450
+ function tt(e) {
2451
+ var v, I, A, T, N, b;
2452
2452
  if (!e || typeof e != "object") return null;
2453
- const t = le(e), n = Kn(t);
2453
+ const t = le(e), n = Vn(t);
2454
2454
  if (!n)
2455
2455
  return null;
2456
- const r = Array.isArray(t.toolCalls) ? t.toolCalls.map(rt) : void 0, o = Vn(t.content ?? t.parts, !!(r != null && r.length)), s = t.id ?? `msg-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`, a = t.createdAt ?? ((w = t.additionalKwargs) == null ? void 0 : w.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(), i = t.name ?? ((k = t.additionalKwargs) == null ? void 0 : k.agentName) ?? void 0, u = t.model ?? ((E = t.additionalKwargs) == null ? void 0 : E.model) ?? void 0, c = t.toolCallId ?? void 0, l = t.additionalKwargs ?? void 0, p = t.responseMetadata ?? void 0, m = t.checkpointId ?? ((I = t.additionalKwargs) == null ? void 0 : I.checkpointId) ?? void 0, h = t.checkpointNs ?? ((N = t.additionalKwargs) == null ? void 0 : N.checkpointNs) ?? void 0, v = typeof t.toolStreaming == "boolean" ? t.toolStreaming : !!((P = t.additionalKwargs) != null && P.toolStreaming);
2456
+ const r = Array.isArray(t.toolCalls) ? t.toolCalls.map(nt) : void 0, o = $n(t.content ?? t.parts, !!(r != null && r.length)), s = t.id ?? `msg-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`, a = t.createdAt ?? ((v = t.additionalKwargs) == null ? void 0 : v.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(), i = t.name ?? ((I = t.additionalKwargs) == null ? void 0 : I.agentName) ?? void 0, u = t.model ?? ((A = t.additionalKwargs) == null ? void 0 : A.model) ?? void 0, c = t.toolCallId ?? void 0, l = t.additionalKwargs ?? void 0, p = t.responseMetadata ?? void 0, m = t.checkpointId ?? ((T = t.additionalKwargs) == null ? void 0 : T.checkpointId) ?? void 0, h = t.checkpointNs ?? ((N = t.additionalKwargs) == null ? void 0 : N.checkpointNs) ?? void 0, k = typeof t.toolStreaming == "boolean" ? t.toolStreaming : !!((b = t.additionalKwargs) != null && b.toolStreaming);
2457
2457
  return {
2458
2458
  ...t,
2459
2459
  id: s,
@@ -2466,13 +2466,13 @@ function nt(e) {
2466
2466
  toolCalls: r,
2467
2467
  checkpointId: m,
2468
2468
  checkpointNs: h,
2469
- toolStreaming: v,
2469
+ toolStreaming: k,
2470
2470
  additionalKwargs: l,
2471
2471
  responseMetadata: p,
2472
2472
  artifact: t.artifact ?? void 0
2473
2473
  };
2474
2474
  }
2475
- function Dn(e) {
2475
+ function Bn(e) {
2476
2476
  if (!e || typeof e != "object") return e;
2477
2477
  const t = le(e);
2478
2478
  if (t.tool && !t.name && (t.name = t.tool), t.type === "artifact.update" && t.artifact && typeof t.artifact == "object") {
@@ -2481,7 +2481,7 @@ function Dn(e) {
2481
2481
  }
2482
2482
  return t;
2483
2483
  }
2484
- function rt(e) {
2484
+ function nt(e) {
2485
2485
  const t = le(e), n = t.content ?? t.output ?? void 0;
2486
2486
  return {
2487
2487
  ...t,
@@ -2492,35 +2492,35 @@ function rt(e) {
2492
2492
  content: typeof n == "string" ? n : n ? JSON.stringify(n) : void 0
2493
2493
  };
2494
2494
  }
2495
- function Vn(e, t) {
2496
- return typeof e == "string" ? [{ type: "text", text: e }] : Array.isArray(e) ? e.map((n) => typeof n == "string" ? { type: "text", text: n } : n.type === "tool_call" || n.type === "tool" ? t ? null : rt(le(n)) : n).filter(
2495
+ function $n(e, t) {
2496
+ return typeof e == "string" ? [{ type: "text", text: e }] : Array.isArray(e) ? e.map((n) => typeof n == "string" ? { type: "text", text: n } : n.type === "tool_call" || n.type === "tool" ? t ? null : nt(le(n)) : n).filter(
2497
2497
  (n) => !!(n && typeof n == "object" && typeof n.type == "string")
2498
2498
  ) : [];
2499
2499
  }
2500
- function Kn(e) {
2500
+ function Vn(e) {
2501
2501
  const t = le(e), n = t.role;
2502
2502
  if (n && (n === "assistant" || n === "user" || n === "system" || n === "tool" || n === "interrupt"))
2503
2503
  return n;
2504
2504
  const r = t.type;
2505
2505
  return r === "human" ? "user" : r === "ai" ? "assistant" : r === "tool" ? "tool" : r === "system" ? "system" : null;
2506
2506
  }
2507
- function ut(e) {
2507
+ function lt(e) {
2508
2508
  if (!e) return null;
2509
2509
  const t = String(e).toLowerCase();
2510
2510
  return t === "running" || t === "pending" ? "pending" : t === "completed" || t === "success" ? "completed" : t === "error" || t === "failed" || t === "failure" ? "error" : null;
2511
2511
  }
2512
- function dt(e) {
2513
- return (Array.isArray(e.toolCalls) ? e.toolCalls : Mt(e)).map(rt);
2512
+ function ut(e) {
2513
+ return (Array.isArray(e.toolCalls) ? e.toolCalls : St(e)).map(nt);
2514
2514
  }
2515
- function We(e, t) {
2515
+ function Ge(e, t) {
2516
2516
  return t.find(
2517
2517
  (n) => n.role === "tool" && (n.toolCallId === e || n.id === e)
2518
2518
  );
2519
2519
  }
2520
- function Gn(e, t) {
2520
+ function Dn(e, t) {
2521
2521
  const n = t.response ?? t.content;
2522
2522
  if (!n) return;
2523
- const r = typeof n == "string" ? n : Pt(n);
2523
+ const r = typeof n == "string" ? n : Mt(n);
2524
2524
  if (!r.trim()) return;
2525
2525
  const o = [{ type: "text", text: r }];
2526
2526
  return {
@@ -2533,15 +2533,15 @@ function Gn(e, t) {
2533
2533
  createdAt: e.createdAt
2534
2534
  };
2535
2535
  }
2536
- function Hn(e, t = []) {
2536
+ function Kn(e, t = []) {
2537
2537
  if (Array.isArray(e)) {
2538
- const o = e.filter((a) => a.role === "assistant").flatMap((a) => dt(a)), s = /* @__PURE__ */ new Map();
2538
+ const o = e.filter((a) => a.role === "assistant").flatMap((a) => ut(a)), s = /* @__PURE__ */ new Map();
2539
2539
  return o.forEach((a) => s.set(a.id, a)), Array.from(s.values()).map((a) => {
2540
2540
  var p, m, h;
2541
- const i = We(a.id, e) || We(a.id, t), u = Array.isArray((p = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : p.toolProgress) ? (m = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : m.toolProgress : void 0, c = (i == null ? void 0 : i.artifact) ?? a.artifact, l = ut(a.status) ?? ((h = i == null ? void 0 : i.additionalKwargs) != null && h.toolStreaming ? "pending" : null) ?? (i ? "completed" : "pending");
2541
+ const i = Ge(a.id, e) || Ge(a.id, t), u = Array.isArray((p = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : p.toolProgress) ? (m = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : m.toolProgress : void 0, c = (i == null ? void 0 : i.artifact) ?? a.artifact, l = lt(a.status) ?? ((h = i == null ? void 0 : i.additionalKwargs) != null && h.toolStreaming ? "pending" : null) ?? (i ? "completed" : "pending");
2542
2542
  if (i && !a.content && l === "completed") {
2543
- const v = ce(i);
2544
- typeof v == "string" && (a.content = v);
2543
+ const k = ce(i);
2544
+ typeof k == "string" && (a.content = k);
2545
2545
  }
2546
2546
  return {
2547
2547
  call: a,
@@ -2553,10 +2553,10 @@ function Hn(e, t = []) {
2553
2553
  });
2554
2554
  }
2555
2555
  if (e.role !== "assistant") return [];
2556
- const n = dt(e);
2556
+ const n = ut(e);
2557
2557
  return n.length === 0 ? [] : n.map((r) => {
2558
2558
  var u, c, l;
2559
- const o = We(r.id, t) ?? Gn(e, r), s = Array.isArray((u = o == null ? void 0 : o.additionalKwargs) == null ? void 0 : u.toolProgress) ? (c = o == null ? void 0 : o.additionalKwargs) == null ? void 0 : c.toolProgress : void 0, a = (o == null ? void 0 : o.artifact) ?? r.artifact, i = ut(r.status) ?? ((l = o == null ? void 0 : o.additionalKwargs) != null && l.toolStreaming ? "pending" : null) ?? (o ? "completed" : "pending");
2559
+ const o = Ge(r.id, t) ?? Dn(e, r), s = Array.isArray((u = o == null ? void 0 : o.additionalKwargs) == null ? void 0 : u.toolProgress) ? (c = o == null ? void 0 : o.additionalKwargs) == null ? void 0 : c.toolProgress : void 0, a = (o == null ? void 0 : o.artifact) ?? r.artifact, i = lt(r.status) ?? ((l = o == null ? void 0 : o.additionalKwargs) != null && l.toolStreaming ? "pending" : null) ?? (o ? "completed" : "pending");
2560
2560
  if (o && !r.content && i === "completed") {
2561
2561
  const p = ce(o);
2562
2562
  typeof p == "string" && (r.content = p);
@@ -2570,10 +2570,10 @@ function Hn(e, t = []) {
2570
2570
  };
2571
2571
  });
2572
2572
  }
2573
- function oo(e, t = []) {
2574
- return Hn(e, t).map((n) => n.artifact).filter((n) => !!n);
2573
+ function to(e, t = []) {
2574
+ return Kn(e, t).map((n) => n.artifact).filter((n) => !!n);
2575
2575
  }
2576
- const Ne = {
2576
+ const _e = {
2577
2577
  authToken: "authToken",
2578
2578
  authTokenExpiresAt: "authTokenExpiresAt",
2579
2579
  authSessionId: "authSessionId",
@@ -2582,44 +2582,44 @@ const Ne = {
2582
2582
  playgroundSettings: "new-chat-ui-chat-settings",
2583
2583
  debugLogs: "app:debugLogs"
2584
2584
  };
2585
- function qe(e) {
2585
+ function He(e) {
2586
2586
  return `draft:${e}`;
2587
2587
  }
2588
- let Ge = null;
2589
- const Ye = /* @__PURE__ */ new Set();
2590
- function _t() {
2591
- return Ge;
2588
+ let De = null;
2589
+ const Xe = /* @__PURE__ */ new Set();
2590
+ function Et() {
2591
+ return De;
2592
2592
  }
2593
2593
  function ke(e) {
2594
- Ge = e, Ye.forEach((t) => t(e));
2594
+ De = e, Xe.forEach((t) => t(e));
2595
2595
  }
2596
- function Nt(e) {
2597
- return Ye.add(e), () => Ye.delete(e);
2596
+ function Pt(e) {
2597
+ return Xe.add(e), () => Xe.delete(e);
2598
2598
  }
2599
- const Wn = 12e4, qn = 12e4;
2600
- let Ze = Wn, Rt = qn;
2601
- const oe = Xt.create({
2599
+ const Gn = 12e4, Hn = 12e4;
2600
+ let Qe = Gn, Nt = Hn;
2601
+ const re = qt.create({
2602
2602
  // BaseURL is set dynamically via ApiProvider -> api.updateConfig
2603
- timeout: Ze,
2603
+ timeout: Qe,
2604
2604
  withCredentials: !0
2605
2605
  });
2606
- function ft(e) {
2606
+ function dt(e) {
2607
2607
  return typeof e != "number" || !Number.isFinite(e) || e <= 0 ? null : Math.floor(e);
2608
2608
  }
2609
- function Jn(e) {
2610
- const t = ft(e.requestTimeoutMs), n = ft(e.historyTimeoutMs);
2611
- t !== null && (Ze = t, oe.defaults.timeout = Ze), n !== null && (Rt = n);
2609
+ function Wn(e) {
2610
+ const t = dt(e.requestTimeoutMs), n = dt(e.historyTimeoutMs);
2611
+ t !== null && (Qe = t, re.defaults.timeout = Qe), n !== null && (Nt = n);
2612
2612
  }
2613
- function Xn() {
2614
- return Rt;
2613
+ function qn() {
2614
+ return Nt;
2615
2615
  }
2616
- oe.interceptors.request.use((e) => (Ge && (e.headers.Authorization = `Bearer ${Ge}`), e));
2617
- oe.interceptors.response.use(
2616
+ re.interceptors.request.use((e) => (De && (e.headers.Authorization = `Bearer ${De}`), e));
2617
+ re.interceptors.response.use(
2618
2618
  (e) => {
2619
2619
  if (typeof window < "u" && (e != null && e.data))
2620
2620
  try {
2621
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(Ne.authToken, r), ke(r)), o && localStorage.setItem(Ne.authTokenExpiresAt, o.toString()), (r || o) && window.dispatchEvent(
2622
+ r && (localStorage.setItem(_e.authToken, r), ke(r)), o && localStorage.setItem(_e.authTokenExpiresAt, o.toString()), (r || o) && window.dispatchEvent(
2623
2623
  new CustomEvent("smartorg:chat-token-updated", {
2624
2624
  detail: { token: r, expiresAt: o }
2625
2625
  })
@@ -2632,95 +2632,85 @@ oe.interceptors.response.use(
2632
2632
  (e) => Promise.reject(e)
2633
2633
  );
2634
2634
  async function se(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 re.defaults.baseURL ? (await re.get(e, t)).data : Promise.reject(new Error("API base URL is not configured"));
2636
2636
  }
2637
- async function Oe(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"));
2637
+ async function Ye(e, t, n) {
2638
+ return re.defaults.baseURL ? (await re.post(e, t, n)).data : Promise.reject(new Error("API base URL is not configured"));
2639
2639
  }
2640
- async function Qn(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"));
2640
+ async function Jn(e, t, n) {
2641
+ return re.defaults.baseURL ? (await re.put(e, t, n)).data : Promise.reject(new Error("API base URL is not configured"));
2642
2642
  }
2643
- async function pt(e, t) {
2644
- return oe.defaults.baseURL ? (await oe.delete(e, t)).data : Promise.reject(new Error("API base URL is not configured"));
2643
+ async function Xn(e, t) {
2644
+ return re.defaults.baseURL ? (await re.delete(e, t)).data : Promise.reject(new Error("API base URL is not configured"));
2645
2645
  }
2646
- function re(e) {
2646
+ function ae(e) {
2647
2647
  return e && typeof e == "object" && "data" in e ? e.data : e;
2648
2648
  }
2649
- class Yn {
2649
+ class Qn {
2650
2650
  // ---- Configuration ----
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 re.defaults.baseURL || "";
2655
2655
  }
2656
2656
  updateConfig(t) {
2657
2657
  if (t.chatBaseUrl)
2658
- oe.defaults.baseURL = t.chatBaseUrl;
2658
+ re.defaults.baseURL = t.chatBaseUrl;
2659
2659
  else if (t.baseUrl) {
2660
2660
  const n = t.baseUrl.replace(/\/+$/, "");
2661
- oe.defaults.baseURL = n;
2661
+ re.defaults.baseURL = n;
2662
2662
  }
2663
- t.apiKey !== void 0 ? ke(t.apiKey) : t.getToken && ke(t.getToken()), (t.requestTimeoutMs !== void 0 || t.historyTimeoutMs !== void 0) && Jn({
2663
+ t.apiKey !== void 0 ? ke(t.apiKey) : t.getToken && ke(t.getToken()), (t.requestTimeoutMs !== void 0 || t.historyTimeoutMs !== void 0) && Wn({
2664
2664
  requestTimeoutMs: t.requestTimeoutMs,
2665
2665
  historyTimeoutMs: t.historyTimeoutMs
2666
2666
  });
2667
2667
  }
2668
2668
  // ---- Token Management ----
2669
2669
  getAuthToken() {
2670
- return _t();
2670
+ return Et();
2671
2671
  }
2672
2672
  setAuthToken(t) {
2673
2673
  ke(t);
2674
2674
  }
2675
2675
  onTokenChange(t) {
2676
- return Nt(t);
2676
+ return Pt(t);
2677
2677
  }
2678
2678
  // ---- Thread Management ----
2679
2679
  async listThreads() {
2680
- const t = await se("/threads"), n = re(t);
2681
- return (n == null ? void 0 : n.items) ?? (t == null ? void 0 : t.items) ?? [];
2682
- }
2683
- async listSharedThreads() {
2684
- const t = await se("/threads/shared"), n = re(t);
2680
+ const t = await se("/threads"), n = ae(t);
2685
2681
  return (n == null ? void 0 : n.items) ?? (t == null ? void 0 : t.items) ?? [];
2686
2682
  }
2687
2683
  // listUsers moved to AuthApi
2688
2684
  async createThread(t, n) {
2689
2685
  const r = {};
2690
2686
  t && (r.title = t), n && (r.project = n);
2691
- const o = await Oe("/threads", Object.keys(r).length ? r : void 0);
2692
- return re(o);
2687
+ const o = await Ye("/threads", Object.keys(r).length ? r : void 0);
2688
+ return ae(o);
2693
2689
  }
2694
2690
  async updateThread(t, n) {
2695
- const r = await Qn(`/threads/${t}`, { title: n });
2696
- return re(r);
2691
+ const r = await Jn(`/threads/${t}`, { title: n });
2692
+ return ae(r);
2697
2693
  }
2698
2694
  async deleteThread(t) {
2699
- const n = await pt(`/threads/${t}`);
2700
- return re(n);
2701
- }
2702
- async shareThread(t, n) {
2703
- const r = await Oe(`/threads/${t}/share`, {
2704
- shared_with_user_id: n
2705
- });
2706
- return re(r);
2695
+ const n = await Xn(`/threads/${t}`);
2696
+ return ae(n);
2707
2697
  }
2708
2698
  async threadInfo(t) {
2709
2699
  const n = await se(`/threads/${t}/info`);
2710
- return re(n);
2700
+ return ae(n);
2711
2701
  }
2712
2702
  // ---- Agents ----
2713
2703
  async listAgents() {
2714
- const t = await se("/agents"), n = re(t);
2704
+ const t = await se("/agents"), n = ae(t);
2715
2705
  return (n == null ? void 0 : n.items) ?? [];
2716
2706
  }
2717
2707
  async getAgent(t) {
2718
2708
  const n = await se(`/agents/${t}`);
2719
- return re(n);
2709
+ return ae(n);
2720
2710
  }
2721
2711
  async getAgentSchema(t) {
2722
2712
  const n = await se(`/agents/${t}/schema`);
2723
- return re(n);
2713
+ return ae(n);
2724
2714
  }
2725
2715
  async getState(t) {
2726
2716
  const n = await se(`/threads/${t.threadId}/state`, {
@@ -2729,7 +2719,7 @@ class Yn {
2729
2719
  checkpoint_ns: t.checkpointNs
2730
2720
  }
2731
2721
  });
2732
- return re(n);
2722
+ return ae(n);
2733
2723
  }
2734
2724
  async getStateHistory(t) {
2735
2725
  const n = await se(`/threads/${t.threadId}/state/history`, {
@@ -2740,23 +2730,19 @@ class Yn {
2740
2730
  offset: t.offset ?? 0,
2741
2731
  include_messages: t.includeMessages ?? !0
2742
2732
  },
2743
- timeout: Xn(),
2733
+ timeout: qn(),
2744
2734
  signal: t.signal
2745
2735
  });
2746
- return re(n);
2736
+ return ae(n);
2747
2737
  }
2748
2738
  // ---- Run Management ----
2749
2739
  async cancelRun(t) {
2750
- const n = await Oe(`/runs/${t}/cancel`);
2751
- return re(n);
2752
- }
2753
- async unshareThread(t, n) {
2754
- const r = await pt(`/threads/${t}/share/${n}`);
2755
- return re(r);
2740
+ const n = await Ye(`/runs/${t}/cancel`);
2741
+ return ae(n);
2756
2742
  }
2757
2743
  }
2758
- const zt = new Yn();
2759
- class Zn {
2744
+ const _t = new Qn();
2745
+ class Yn {
2760
2746
  // Config logic could go here if files ever need a distinct base URL from chat
2761
2747
  // For now, it shares the chatBaseUrl via the shared httpClient
2762
2748
  async fetchFileBlob(t, n) {
@@ -2805,7 +2791,7 @@ class Zn {
2805
2791
  }
2806
2792
  async uploadFile(t, n, r) {
2807
2793
  const o = new FormData();
2808
- return o.append("file", t), n && o.append("thread_id", n), await Oe("/files/upload-form", o, {
2794
+ return o.append("file", t), n && o.append("thread_id", n), await Ye("/files/upload-form", o, {
2809
2795
  onUploadProgress: (s) => {
2810
2796
  try {
2811
2797
  if (r && s.lengthComputable) {
@@ -2818,11 +2804,11 @@ class Zn {
2818
2804
  });
2819
2805
  }
2820
2806
  }
2821
- const Ut = new Zn();
2822
- class er {
2807
+ const zt = new Yn();
2808
+ class Zn {
2823
2809
  constructor() {
2824
2810
  // ---- Configuration ----
2825
- at(this, "_authBaseUrl", "");
2811
+ st(this, "_authBaseUrl", "");
2826
2812
  }
2827
2813
  get baseUrl() {
2828
2814
  return this._authBaseUrl;
@@ -2838,13 +2824,13 @@ class er {
2838
2824
  }
2839
2825
  // ---- Token Management ----
2840
2826
  getAuthToken() {
2841
- return _t();
2827
+ return Et();
2842
2828
  }
2843
2829
  setAuthToken(t) {
2844
2830
  ke(t);
2845
2831
  }
2846
2832
  onTokenChange(t) {
2847
- return Nt(t);
2833
+ return Pt(t);
2848
2834
  }
2849
2835
  // ---- User Management ----
2850
2836
  async listUsers() {
@@ -2852,9 +2838,9 @@ class er {
2852
2838
  return (t == null ? void 0 : t.users) ?? [];
2853
2839
  }
2854
2840
  }
2855
- const tr = new er(), Lt = Se(null);
2856
- function nr({ children: e, apiConfig: t }) {
2857
- const n = zt, r = tr;
2841
+ const er = new Zn(), Rt = Se(null);
2842
+ function tr({ children: e, apiConfig: t }) {
2843
+ const n = _t, r = er;
2858
2844
  if (t) {
2859
2845
  const s = n.baseUrl, a = r.baseUrl, i = n.getAuthToken(), u = t.requestTimeoutMs !== void 0 || t.historyTimeoutMs !== void 0;
2860
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 }));
@@ -2866,12 +2852,12 @@ function nr({ children: e, apiConfig: t }) {
2866
2852
  },
2867
2853
  chatApi: n,
2868
2854
  authApi: r,
2869
- fileApi: Ut,
2855
+ fileApi: zt,
2870
2856
  baseUrl: n.baseUrl
2871
2857
  };
2872
- return /* @__PURE__ */ ie(Lt.Provider, { value: o, children: e });
2858
+ return /* @__PURE__ */ ie(Rt.Provider, { value: o, children: e });
2873
2859
  }
2874
- async function rr(e) {
2860
+ async function nr(e) {
2875
2861
  return await new Promise((t, n) => {
2876
2862
  const r = new FileReader();
2877
2863
  r.onload = () => {
@@ -2887,11 +2873,11 @@ async function rr(e) {
2887
2873
  }, r.onerror = (o) => n(o), r.readAsArrayBuffer(e);
2888
2874
  });
2889
2875
  }
2890
- async function or(e = []) {
2876
+ async function rr(e = []) {
2891
2877
  const t = [], n = [];
2892
2878
  for (const r of e)
2893
2879
  try {
2894
- const o = await rr(r), s = r.type || "application/octet-stream";
2880
+ const o = await nr(r), s = r.type || "application/octet-stream";
2895
2881
  n.push({
2896
2882
  filename: r.name,
2897
2883
  data: o,
@@ -2910,28 +2896,28 @@ async function or(e = []) {
2910
2896
  }
2911
2897
  return { contentParts: t, filesInfo: n };
2912
2898
  }
2913
- function sr(e) {
2899
+ function or(e) {
2914
2900
  return e.filter((t) => t.type === "text").map((t) => t.text).join("");
2915
2901
  }
2916
- function so(e) {
2902
+ function no(e) {
2917
2903
  if (e == null) return null;
2918
2904
  const t = String(e).trim();
2919
2905
  return t.length > 0 ? t : null;
2920
2906
  }
2921
- function ar(e) {
2907
+ function sr(e) {
2922
2908
  const t = e.toolCallId ?? (e.role === "tool" ? e.id : void 0);
2923
2909
  return e.role === "tool" && !t && console.error("[meta-utils] CRITICAL: Tool message missing toolCallId!", e), {
2924
2910
  toolCallId: t ?? void 0,
2925
2911
  name: e.name ?? void 0
2926
2912
  };
2927
2913
  }
2928
- function ao(e) {
2914
+ function ro(e) {
2929
2915
  var n;
2930
2916
  if (e.name && e.name.trim()) return e.name;
2931
2917
  const t = (n = e.additionalKwargs) == null ? void 0 : n.agentName;
2932
2918
  return typeof t == "string" && t.trim() ? t : e.model && e.model.includes("/") ? e.model.split("/").pop() || null : e.model || null;
2933
2919
  }
2934
- function io(e) {
2920
+ function oo(e) {
2935
2921
  const t = e.updatedAt ?? e.createdAt ?? "", n = Array.isArray(e.content) ? e.content.map((a) => {
2936
2922
  switch (a.type) {
2937
2923
  case "text":
@@ -2945,11 +2931,11 @@ function io(e) {
2945
2931
  return `${e.id}:${t}:${n}${s ? `:${s}` : ""}`;
2946
2932
  }
2947
2933
  function Ae() {
2948
- const e = Ue(Lt);
2934
+ const e = Ue(Rt);
2949
2935
  if (!e) throw new Error("useApi must be used within ApiProvider");
2950
2936
  return e;
2951
2937
  }
2952
- function ir(e, t, n) {
2938
+ function ar(e, t, n) {
2953
2939
  const r = typeof t == "string" ? [{ type: "text", text: t }] : t;
2954
2940
  return {
2955
2941
  id: `msg-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`,
@@ -2959,40 +2945,40 @@ function ir(e, t, n) {
2959
2945
  ...n
2960
2946
  };
2961
2947
  }
2962
- function jt(e, t = "user") {
2963
- return typeof e == "string" ? ir(t, e) : e;
2948
+ function Ut(e, t = "user") {
2949
+ return typeof e == "string" ? ar(t, e) : e;
2964
2950
  }
2965
- function cr(e) {
2951
+ function ir(e) {
2966
2952
  return !!e && typeof e == "object" && "data" in e;
2967
2953
  }
2968
- function lr(e = {}) {
2969
- const t = e.baseUrl || "", n = e.streamPath ?? "/runs/stream", [r, o] = D(e.token ?? null), s = H(e.headers ?? {}), a = e.credentials ?? "include", i = H(e);
2970
- q(() => {
2954
+ function cr(e = {}) {
2955
+ const t = e.baseUrl || "", n = e.streamPath ?? "/runs/stream", [r, o] = $(e.token ?? null), s = K(e.headers ?? {}), a = e.credentials ?? "include", i = K(e);
2956
+ W(() => {
2971
2957
  i.current = e;
2972
2958
  }, [e]);
2973
- const u = z((g) => {
2974
- var U, C, M, L, R, V, B, b, T, $;
2975
- const y = i.current;
2976
- if (!y) return;
2977
- (U = y.onEvent) == null || U.call(y, g), g.type === "thread_info" && ((C = y.onThreadInfo) == null || C.call(y, g)), g.type === "values" && Array.isArray(g.checkpoints) && ((M = y.handleValuesEvent) == null || M.call(y, g)), g.type === "metadata" && ((L = y.onMetadataEvent) == null || L.call(y, g)), typeof g.type == "string" && (g.type === "custom" || g.type.startsWith("custom.")) && ((R = y.onCustomEvent) == null || R.call(y, g)), g.type === "updates" && ((V = y.onUpdateEvent) == null || V.call(y, g)), g.type === "tool.end" ? (B = y.onToolEnd) == null || B.call(y, g) : g.type === "tool.start" && ((b = y.onToolStart) == null || b.call(y, g)), g.type === "heartbeat" && ((T = y.onHeartbeat) == null || T.call(y, g)), g.type === "token" && (($ = y.onToken) == null || $.call(y, g.token));
2978
- }, []), [c, l] = D(!1), [p, m] = D(null), [h, v] = D(!1), [f, w] = D(null), k = H(null), E = H(!0), I = H(null), N = z((g) => {
2959
+ const u = U((g) => {
2960
+ var j, S, C, L, _, O, F, G, E, D;
2961
+ const w = i.current;
2962
+ if (!w) return;
2963
+ (j = w.onEvent) == null || j.call(w, g), g.type === "thread_info" && ((S = w.onThreadInfo) == null || S.call(w, g)), g.type === "values" && Array.isArray(g.checkpoints) && ((C = w.handleValuesEvent) == null || C.call(w, g)), g.type === "metadata" && ((L = w.onMetadataEvent) == null || L.call(w, g)), typeof g.type == "string" && (g.type === "custom" || g.type.startsWith("custom.")) && ((_ = w.onCustomEvent) == null || _.call(w, g)), g.type === "updates" && ((O = w.onUpdateEvent) == null || O.call(w, g)), g.type === "tool.end" ? (F = w.onToolEnd) == null || F.call(w, g) : g.type === "tool.start" && ((G = w.onToolStart) == null || G.call(w, g)), g.type === "heartbeat" && ((E = w.onHeartbeat) == null || E.call(w, g)), g.type === "token" && ((D = w.onToken) == null || D.call(w, g.token));
2964
+ }, []), [c, l] = $(!1), [p, m] = $(null), [h, k] = $(!1), [d, v] = $(null), I = K(null), A = K(!0), T = K(null), N = U((g) => {
2979
2965
  o(g);
2980
- }, []), P = z(() => {
2981
- m(null), w(null);
2982
- }, []), x = z(() => {
2983
- var C, M;
2966
+ }, []), b = U(() => {
2967
+ m(null), v(null);
2968
+ }, []), y = U(() => {
2969
+ var S, C;
2984
2970
  console.debug("[use-chat] stop() invoked - aborting stream");
2985
- const g = (C = I.current) == null ? void 0 : C.threadId, y = (M = I.current) == null ? void 0 : M.runId, F = () => {
2971
+ const g = (S = T.current) == null ? void 0 : S.threadId, w = (C = T.current) == null ? void 0 : C.runId, z = () => {
2986
2972
  var L;
2987
- (L = k.current) == null || L.abort(), k.current = null, I.current = null, l(!1), v(!1);
2973
+ (L = I.current) == null || L.abort(), I.current = null, T.current = null, l(!1), k(!1);
2988
2974
  };
2989
- (y || g ? zt.cancelRun(y || g).catch((L) => {
2975
+ (w || g ? _t.cancelRun(w || g).catch((L) => {
2990
2976
  console.warn("[use-chat] cancel run failed:", L);
2991
- }) : Promise.resolve()).finally(F);
2992
- }, []), S = z(
2977
+ }) : Promise.resolve()).finally(z);
2978
+ }, []), x = U(
2993
2979
  (g) => {
2994
- k.current && (k.current.abort(), k.current = null);
2995
- const y = {
2980
+ I.current && (I.current.abort(), I.current = null);
2981
+ const w = {
2996
2982
  text: typeof g.content == "string" ? g.content : g.text,
2997
2983
  threadId: g.threadId,
2998
2984
  attachments: g.attachments,
@@ -3003,94 +2989,94 @@ function lr(e = {}) {
3003
2989
  edit: g.edit,
3004
2990
  command: g.command
3005
2991
  };
3006
- l(!0), m(null), w(null);
3007
- const F = new AbortController();
3008
- k.current = F;
3009
- let U = null, C = !1;
3010
- return I.current = {
3011
- threadId: y.threadId ?? void 0,
2992
+ l(!0), m(null), v(null);
2993
+ const z = new AbortController();
2994
+ I.current = z;
2995
+ let j = null, S = !1;
2996
+ return T.current = {
2997
+ threadId: w.threadId ?? void 0,
3012
2998
  runId: void 0,
3013
2999
  // Will be updated from headers
3014
3000
  headers: {},
3015
3001
  isStreaming: !0
3016
3002
  }, (async () => {
3017
- var M, L, R, V, B, b;
3003
+ var C, L, _, O, F, G;
3018
3004
  try {
3019
- let T = {};
3005
+ let E = {};
3020
3006
  try {
3021
3007
  if (r)
3022
- T = { Authorization: `Bearer ${r}` };
3008
+ E = { Authorization: `Bearer ${r}` };
3023
3009
  else if (typeof window < "u") {
3024
- const ee = window.__AUTH_TOKEN__, ve = ((M = window.localStorage) == null ? void 0 : M.getItem(Ne.authToken)) || null;
3025
- let X = null;
3010
+ const ee = window.__AUTH_TOKEN__, ve = ((C = window.localStorage) == null ? void 0 : C.getItem(_e.authToken)) || null;
3011
+ let J = null;
3026
3012
  try {
3027
- const me = (L = window.localStorage) == null ? void 0 : L.getItem(Ne.chatSettings);
3028
- me && (X = ((R = JSON.parse(me)) == null ? void 0 : R.apiKey) || null);
3013
+ const me = (L = window.localStorage) == null ? void 0 : L.getItem(_e.chatSettings);
3014
+ me && (J = ((_ = JSON.parse(me)) == null ? void 0 : _.apiKey) || null);
3029
3015
  } catch {
3030
3016
  }
3031
- const Y = ee || ve || X || null;
3032
- Y && (T = { Authorization: `Bearer ${Y}` });
3017
+ const Y = ee || ve || J || null;
3018
+ Y && (E = { Authorization: `Bearer ${Y}` });
3033
3019
  }
3034
3020
  } catch {
3035
3021
  }
3036
3022
  console.debug("[use-chat] POST", t + n);
3037
- let $ = {};
3023
+ let D = {};
3038
3024
  if (typeof window < "u")
3039
3025
  try {
3040
- const W = (V = window.localStorage) == null ? void 0 : V.getItem(Ne.authSessionId);
3041
- W && ($ = { "X-Session-Id": W });
3026
+ const H = (O = window.localStorage) == null ? void 0 : O.getItem(_e.authSessionId);
3027
+ H && (D = { "X-Session-Id": H });
3042
3028
  } catch {
3043
3029
  }
3044
- const O = {
3045
- ...T,
3046
- ...$,
3030
+ const Q = {
3031
+ ...E,
3032
+ ...D,
3047
3033
  ...s.current
3048
- }, d = {
3034
+ }, f = {
3049
3035
  "Content-Type": "application/json",
3050
3036
  Accept: "text/event-stream",
3051
- ...O
3052
- }, A = await fetch(t + n, {
3037
+ ...Q
3038
+ }, P = await fetch(t + n, {
3053
3039
  method: "POST",
3054
- headers: d,
3055
- body: JSON.stringify(y),
3056
- signal: F.signal,
3040
+ headers: f,
3041
+ body: JSON.stringify(w),
3042
+ signal: z.signal,
3057
3043
  credentials: a
3058
3044
  });
3059
- if (I.current && (I.current.headers = O), !A.ok || !A.body) {
3060
- const W = await A.text().catch(() => "");
3045
+ if (T.current && (T.current.headers = Q), !P.ok || !P.body) {
3046
+ const H = await P.text().catch(() => "");
3061
3047
  console.debug(
3062
3048
  "[use-chat] non-OK response",
3063
- A.status,
3064
- W == null ? void 0 : W.slice(0, 500)
3049
+ P.status,
3050
+ H == null ? void 0 : H.slice(0, 500)
3065
3051
  );
3066
- const ee = `stream ${A.status}${W ? ": " + W : ""}`;
3067
- throw ee && (m(ee), U = "error"), new Error(ee);
3052
+ const ee = `stream ${P.status}${H ? ": " + H : ""}`;
3053
+ throw ee && (m(ee), j = "error"), new Error(ee);
3068
3054
  }
3069
- v(!0);
3070
- const _ = A.body.getReader(), te = new TextDecoder();
3071
- let J = "", G = 0, Z = Date.now();
3072
- const ae = setInterval(() => {
3073
- Date.now() - Z > 18e5 && (m("Stream idle timeout"), U = "error", F.abort());
3055
+ k(!0);
3056
+ const M = P.body.getReader(), te = new TextDecoder();
3057
+ let q = "", V = 0, Z = Date.now();
3058
+ const oe = setInterval(() => {
3059
+ Date.now() - Z > 18e5 && (m("Stream idle timeout"), j = "error", z.abort());
3074
3060
  }, 5e3), ue = 1024 * 1024;
3075
3061
  try {
3076
- const W = A.headers.get("X-Thread-Id") || A.headers.get("x-thread-id"), ee = A.headers.get("X-Run-Id") || A.headers.get("x-run-id");
3077
- for (I.current && (I.current = {
3078
- ...I.current,
3079
- threadId: W ?? I.current.threadId,
3080
- runId: ee ?? I.current.runId
3062
+ const H = P.headers.get("X-Thread-Id") || P.headers.get("x-thread-id"), ee = P.headers.get("X-Run-Id") || P.headers.get("x-run-id");
3063
+ for (T.current && (T.current = {
3064
+ ...T.current,
3065
+ threadId: H ?? T.current.threadId,
3066
+ runId: ee ?? T.current.runId
3081
3067
  }); ; ) {
3082
- const { value: ve, done: X } = await _.read();
3083
- if (X) break;
3084
- J += te.decode(ve, { stream: !0 }), J.length > ue && (J = "", console.warn("Stream buffer reset: exceeded 1MB"));
3068
+ const { value: ve, done: J } = await M.read();
3069
+ if (J) break;
3070
+ q += te.decode(ve, { stream: !0 }), q.length > ue && (q = "", console.warn("Stream buffer reset: exceeded 1MB"));
3085
3071
  let Y;
3086
- for (; (Y = J.indexOf(`
3072
+ for (; (Y = q.indexOf(`
3087
3073
 
3088
3074
  `)) >= 0; ) {
3089
- const me = J.slice(0, Y);
3090
- J = J.slice(Y + 2);
3091
- const Le = me.split(/\r?\n/), je = [];
3075
+ const me = q.slice(0, Y);
3076
+ q = q.slice(Y + 2);
3077
+ const je = me.split(/\r?\n/), Le = [];
3092
3078
  let de = null;
3093
- for (const ye of Le)
3079
+ for (const ye of je)
3094
3080
  if (!ye.startsWith(":") && ye) {
3095
3081
  if (ye.startsWith("event:")) {
3096
3082
  const Te = ye.slice(6).trim();
@@ -3099,10 +3085,10 @@ function lr(e = {}) {
3099
3085
  }
3100
3086
  if (ye.startsWith("data:")) {
3101
3087
  const Te = ye.slice(5);
3102
- je.push(Te.startsWith(" ") ? Te.slice(1) : Te);
3088
+ Le.push(Te.startsWith(" ") ? Te.slice(1) : Te);
3103
3089
  }
3104
3090
  }
3105
- const Ie = je.join(`
3091
+ const Ie = Le.join(`
3106
3092
  `);
3107
3093
  if (!Ie) continue;
3108
3094
  let ne;
@@ -3113,87 +3099,87 @@ function lr(e = {}) {
3113
3099
  continue;
3114
3100
  }
3115
3101
  de && typeof ne == "object" && ne !== null && !("type" in ne) && (ne.type = de);
3116
- const Me = cr(ne) ? ne.data : ne;
3102
+ const Me = ir(ne) ? ne.data : ne;
3117
3103
  if (!Me) {
3118
3104
  console.warn("[use-chat] dropped envelope event without payload", ne);
3119
3105
  continue;
3120
3106
  }
3121
- const Ee = Dn(Me);
3107
+ const Ee = Bn(Me);
3122
3108
  Z = Date.now();
3123
3109
  const he = Ee.seq;
3124
3110
  if (he !== void 0) {
3125
- if (he <= G) {
3126
- console.debug("[use-chat] drop duplicate/out-of-order event", { seq: he, lastProcessedSeq: G, type: Ee.type });
3111
+ if (he <= V) {
3112
+ console.debug("[use-chat] drop duplicate/out-of-order event", { seq: he, lastProcessedSeq: V, type: Ee.type });
3127
3113
  continue;
3128
3114
  }
3129
- G = he;
3115
+ V = he;
3130
3116
  }
3131
3117
  u(Ee);
3132
3118
  }
3133
3119
  }
3134
- U === null && !F.signal.aborted && (U = "complete");
3135
- } catch (W) {
3136
- if (W.name === "AbortError")
3137
- U = U ?? "aborted";
3120
+ j === null && !z.signal.aborted && (j = "complete");
3121
+ } catch (H) {
3122
+ if (H.name === "AbortError")
3123
+ j = j ?? "aborted";
3138
3124
  else {
3139
- const ee = W.message || String(W);
3140
- U = "error", m(ee);
3125
+ const ee = H.message || String(H);
3126
+ j = "error", m(ee);
3141
3127
  }
3142
3128
  } finally {
3143
3129
  try {
3144
- await _.cancel();
3130
+ await M.cancel();
3145
3131
  } catch {
3146
3132
  } finally {
3147
- (B = _.releaseLock) == null || B.call(_);
3133
+ (F = M.releaseLock) == null || F.call(M);
3148
3134
  }
3149
- clearInterval(ae);
3135
+ clearInterval(oe);
3150
3136
  }
3151
- } catch (T) {
3152
- if (T.name === "AbortError")
3153
- U = U ?? "aborted";
3137
+ } catch (E) {
3138
+ if (E.name === "AbortError")
3139
+ j = j ?? "aborted";
3154
3140
  else {
3155
- const $ = T.message || String(T);
3156
- U = "error", m($), C || (C = !0, (b = e.onConnectionError) == null || b.call(e, $));
3141
+ const D = E.message || String(E);
3142
+ j = "error", m(D), S || (S = !0, (G = e.onConnectionError) == null || G.call(e, D));
3157
3143
  }
3158
3144
  } finally {
3159
3145
  try {
3160
3146
  if (e.onFinish) {
3161
- const T = {
3147
+ const E = {
3162
3148
  lastSeq: 0,
3163
3149
  lastCheckpointId: null,
3164
3150
  lastCheckpointNs: null,
3165
3151
  lastValues: null
3166
3152
  // Let the reducer/history hook provide the final values
3167
3153
  };
3168
- e.onFinish(T);
3154
+ e.onFinish(E);
3169
3155
  }
3170
- } catch (T) {
3171
- console.warn("[use-chat] onClosed callback failed", T);
3156
+ } catch (E) {
3157
+ console.warn("[use-chat] onClosed callback failed", E);
3172
3158
  }
3173
- l(!1), v(!1), k.current = null, I.current = null;
3159
+ l(!1), k(!1), I.current = null, T.current = null;
3174
3160
  }
3175
3161
  })(), Promise.resolve();
3176
3162
  },
3177
3163
  [t, n, r, e, u]
3178
3164
  );
3179
- return q(() => () => {
3165
+ return W(() => () => {
3180
3166
  var g;
3181
- E.current = !1, (g = k.current) == null || g.abort();
3167
+ A.current = !1, (g = I.current) == null || g.abort();
3182
3168
  }, []), {
3183
3169
  isStreaming: c,
3184
3170
  error: p,
3185
3171
  assistantText: "",
3186
3172
  // Deprecated: use messages from reducer
3187
- activeMessageId: f,
3173
+ activeMessageId: d,
3188
3174
  streamedMessages: {},
3189
3175
  // Deprecated: use messages from reducer
3190
3176
  lastCheckpointId: null,
3191
3177
  // Deprecated: use checkpoint from reducer
3192
3178
  lastSeq: 0,
3193
3179
  connected: h,
3194
- stream: S,
3195
- stop: x,
3196
- clear: P,
3180
+ stream: x,
3181
+ stop: y,
3182
+ clear: b,
3197
3183
  setToken: N,
3198
3184
  values: {},
3199
3185
  // Provide empty object for backward compatibility
@@ -3203,169 +3189,87 @@ function lr(e = {}) {
3203
3189
  connectionState: p ? "error" : c ? h ? "connected" : "connecting" : "idle",
3204
3190
  messages: [],
3205
3191
  // useStream doesn't maintain messages, use useChatSession instead
3206
- submit: S
3192
+ submit: x
3207
3193
  };
3208
3194
  }
3209
- const ur = ["detail", "message", "error", "description", "title"];
3210
- function $e(e) {
3211
- if (!e) return null;
3212
- if (typeof e == "string") {
3213
- const t = e.trim();
3214
- return t.length ? t : null;
3215
- }
3216
- if (Array.isArray(e)) {
3217
- for (const t of e) {
3218
- const n = $e(t);
3219
- if (n)
3220
- return n;
3221
- }
3222
- return null;
3223
- }
3224
- if (typeof e == "object") {
3225
- const t = e;
3226
- for (const n of ur) {
3227
- const r = $e(t[n]);
3228
- if (r)
3229
- return r;
3230
- }
3231
- if ("errors" in t) {
3232
- const n = $e(t.errors);
3233
- if (n) return n;
3234
- }
3235
- }
3236
- return null;
3237
- }
3238
- function dr(e) {
3239
- if (!e) return "Request failed";
3240
- const t = e.response, n = $e(t == null ? void 0 : t.data);
3241
- if (n) return n;
3242
- if (t != null && t.statusText)
3243
- return t.statusText;
3244
- if (e instanceof Error && e.message)
3245
- return e.message;
3246
- if (typeof e == "string") {
3247
- const r = e.trim();
3248
- if (r.length) return r;
3249
- }
3250
- return t != null && t.status ? `Request failed with status code ${t.status}` : "Request failed";
3251
- }
3252
- function fr({
3195
+ function lr({
3253
3196
  api: e,
3254
3197
  initialThreadId: t = null,
3255
3198
  onError: n,
3256
3199
  onThreadChange: r,
3257
3200
  onCurrentThreadDeleted: o
3258
3201
  }) {
3259
- const [s, a] = D([]), [i, u] = D(t), [c, l] = D(!1), [p, m] = D(null), [h, v] = D([]), [f, w] = D(!1), [, k] = D(null), [E, I] = D(null), [N, P] = D(!1), x = H(i), S = H(/* @__PURE__ */ new Map());
3260
- q(() => {
3261
- x.current = i;
3262
- }, [i]), q(() => {
3263
- t !== void 0 && t !== x.current && u(t);
3202
+ const [s, a] = $([]), [i, u] = $(t), [c, l] = $(!1), [p, m] = $(null), h = K(i), k = K(/* @__PURE__ */ new Map());
3203
+ W(() => {
3204
+ h.current = i;
3205
+ }, [i]), W(() => {
3206
+ t !== void 0 && t !== h.current && u(t);
3264
3207
  }, [t]);
3265
- const g = z(async () => {
3208
+ const d = U(async () => {
3266
3209
  l(!0), m(null);
3267
3210
  try {
3268
3211
  const b = await e.listThreads();
3269
3212
  a(b ?? []);
3270
3213
  } catch (b) {
3271
- const T = String(b);
3272
- m(T), n == null || n(T);
3214
+ const y = String(b);
3215
+ m(y), n == null || n(y);
3273
3216
  } finally {
3274
3217
  l(!1);
3275
3218
  }
3276
- }, [e, n]), y = z(async () => {
3277
- w(!0), k(null);
3278
- try {
3279
- const b = await e.listSharedThreads();
3280
- v(b ?? []);
3281
- } catch (b) {
3282
- const T = String(b);
3283
- k(T), n == null || n(T);
3284
- } finally {
3285
- w(!1);
3286
- }
3287
3219
  }, [e, n]);
3288
- q(() => {
3289
- g();
3290
- }, [g]), q(() => {
3291
- y();
3292
- }, [y]), q(() => {
3220
+ W(() => {
3221
+ d();
3222
+ }, [d]), W(() => {
3293
3223
  r == null || r(i);
3294
3224
  }, [i, r]);
3295
- const F = z(
3296
- async (b, T) => {
3225
+ const v = U(
3226
+ async (b, y) => {
3297
3227
  try {
3298
- const $ = T && typeof T == "object" ? { id: T.id, name: T.name ?? "" } : void 0, O = await e.createThread(b, $);
3299
- return u(O.threadId), await g(), O.threadId;
3300
- } catch ($) {
3301
- const O = String($);
3302
- return n == null || n(O), null;
3228
+ const x = y && typeof y == "object" ? { id: y.id, name: y.name ?? "" } : void 0, g = await e.createThread(b, x);
3229
+ return u(g.threadId), await d(), g.threadId;
3230
+ } catch (x) {
3231
+ const g = String(x);
3232
+ return n == null || n(g), null;
3303
3233
  }
3304
3234
  },
3305
- [e, n, g]
3306
- ), U = z(
3235
+ [e, n, d]
3236
+ ), I = U(
3307
3237
  async (b) => {
3308
- const T = s;
3309
- a((O) => O.filter((d) => d.threadId !== b));
3310
- const $ = new AbortController();
3311
- S.current.set(b, $);
3238
+ const y = s;
3239
+ a((g) => g.filter((w) => w.threadId !== b));
3240
+ const x = new AbortController();
3241
+ k.current.set(b, x);
3312
3242
  try {
3313
- await e.deleteThread(b), x.current === b && (u(null), o == null || o());
3314
- } catch (O) {
3315
- a(T);
3316
- const d = String(O);
3317
- n == null || n(d);
3243
+ await e.deleteThread(b), h.current === b && (u(null), o == null || o());
3244
+ } catch (g) {
3245
+ a(y);
3246
+ const w = String(g);
3247
+ n == null || n(w);
3318
3248
  } finally {
3319
- S.current.delete(b);
3249
+ k.current.delete(b);
3320
3250
  }
3321
3251
  },
3322
3252
  [e, o, n, s]
3323
- ), C = z(
3324
- async (b, T) => {
3253
+ ), A = U(
3254
+ async (b, y) => {
3325
3255
  try {
3326
- await e.updateThread(b, T), await g();
3327
- } catch ($) {
3328
- n == null || n(String($));
3329
- }
3330
- },
3331
- [e, n, g]
3332
- ), M = z(
3333
- async (b, T) => {
3334
- P(!0), I("Sharing thread…");
3335
- try {
3336
- await e.shareThread(b, T), await y(), I("Shared successfully");
3337
- } catch ($) {
3338
- const O = dr($);
3339
- throw n == null || n(O), I(`Failed to share: ${O}`), new Error(O);
3340
- } finally {
3341
- P(!1);
3256
+ await e.updateThread(b, y), await d();
3257
+ } catch (x) {
3258
+ n == null || n(String(x));
3342
3259
  }
3343
3260
  },
3344
- [e, n, y]
3345
- ), L = z(
3346
- async (b, T) => {
3347
- try {
3348
- await e.unshareThread(b, T), await y();
3349
- } catch ($) {
3350
- const O = String($);
3351
- throw n == null || n(O), $;
3352
- }
3353
- },
3354
- [e, n, y]
3355
- ), R = Q(
3261
+ [e, n, d]
3262
+ ), T = X(
3356
3263
  () => ({
3357
- createThread: F,
3358
- deleteThread: U,
3359
- renameThread: C,
3360
- refreshThreads: g,
3361
- refreshSharedThreads: y,
3362
- shareThread: M,
3363
- unshareThread: L
3264
+ createThread: v,
3265
+ deleteThread: I,
3266
+ renameThread: A,
3267
+ refreshThreads: d
3364
3268
  }),
3365
- [F, U, C, g, y, M, L]
3366
- ), V = z((b) => {
3269
+ [v, I, A, d]
3270
+ ), N = U((b) => {
3367
3271
  if (!(b != null && b.threadId)) return;
3368
- const T = {
3272
+ const y = {
3369
3273
  threadId: b.threadId,
3370
3274
  title: b.title || `Thread ${b.threadId.slice(0, 8)}`,
3371
3275
  project: b.project,
@@ -3373,36 +3277,31 @@ function fr({
3373
3277
  updatedAt: b.updatedAt || (/* @__PURE__ */ new Date()).toISOString(),
3374
3278
  messageCount: b.messageCount ?? 1
3375
3279
  };
3376
- a(($) => {
3377
- let O = !1;
3378
- const d = $.map((A) => A.threadId === T.threadId ? (O = !0, console.debug("[useThreadsState] thread_info: updating existing thread", T.threadId), {
3379
- ...A,
3380
- title: T.title ?? A.title,
3381
- project: T.project ?? A.project,
3382
- updatedAt: T.updatedAt ?? A.updatedAt,
3383
- messageCount: T.messageCount ?? A.messageCount
3384
- }) : A);
3385
- return O ? d : (console.debug("[useThreadsState] thread_info: adding thread to list", T.threadId), [T, ...$]);
3280
+ a((x) => {
3281
+ let g = !1;
3282
+ const w = x.map((z) => z.threadId === y.threadId ? (g = !0, console.debug("[useThreadsState] thread_info: updating existing thread", y.threadId), {
3283
+ ...z,
3284
+ title: y.title ?? z.title,
3285
+ project: y.project ?? z.project,
3286
+ updatedAt: y.updatedAt ?? z.updatedAt,
3287
+ messageCount: y.messageCount ?? z.messageCount
3288
+ }) : z);
3289
+ return g ? w : (console.debug("[useThreadsState] thread_info: adding thread to list", y.threadId), [y, ...x]);
3386
3290
  });
3387
- }, []), B = z(() => I(null), []);
3291
+ }, []);
3388
3292
  return {
3389
3293
  threads: s,
3390
3294
  currentThreadId: i,
3391
- currentThreadIdRef: x,
3295
+ currentThreadIdRef: h,
3392
3296
  setCurrentThreadId: u,
3393
3297
  isLoadingThreads: c,
3394
3298
  threadsError: p,
3395
- sharedThreads: h,
3396
- isLoadingSharedThreads: f,
3397
- actions: R,
3398
- addThreadFromEvent: V,
3399
- shareInFlight: N,
3400
- shareStatus: E,
3401
- clearShareStatus: B
3299
+ actions: T,
3300
+ addThreadFromEvent: N
3402
3301
  };
3403
3302
  }
3404
- const Ft = Se(null);
3405
- function pr({
3303
+ const jt = Se(null);
3304
+ function ur({
3406
3305
  children: e,
3407
3306
  initialThreadId: t = null,
3408
3307
  onError: n,
@@ -3415,19 +3314,14 @@ function pr({
3415
3314
  currentThreadIdRef: u,
3416
3315
  isLoadingThreads: c,
3417
3316
  threadsError: l,
3418
- sharedThreads: p,
3419
- isLoadingSharedThreads: m,
3420
- actions: h,
3421
- addThreadFromEvent: v,
3422
- shareInFlight: f,
3423
- shareStatus: w,
3424
- clearShareStatus: k
3425
- } = fr({
3317
+ actions: p,
3318
+ addThreadFromEvent: m
3319
+ } = lr({
3426
3320
  api: o,
3427
3321
  initialThreadId: t,
3428
3322
  onError: n,
3429
3323
  onThreadChange: r
3430
- }), E = Q(
3324
+ }), h = X(
3431
3325
  () => ({
3432
3326
  threads: s,
3433
3327
  currentThreadId: a,
@@ -3435,13 +3329,8 @@ function pr({
3435
3329
  currentThreadIdRef: u,
3436
3330
  isLoading: c,
3437
3331
  error: l,
3438
- sharedThreads: p,
3439
- isLoadingSharedThreads: m,
3440
- actions: h,
3441
- shareInFlight: f,
3442
- shareStatus: w,
3443
- clearShareStatus: k,
3444
- addThreadFromEvent: v
3332
+ actions: p,
3333
+ addThreadFromEvent: m
3445
3334
  }),
3446
3335
  [
3447
3336
  s,
@@ -3451,22 +3340,17 @@ function pr({
3451
3340
  c,
3452
3341
  l,
3453
3342
  p,
3454
- m,
3455
- h,
3456
- f,
3457
- w,
3458
- k,
3459
- v
3343
+ m
3460
3344
  ]
3461
3345
  );
3462
- return /* @__PURE__ */ ie(Ft.Provider, { value: E, children: e });
3346
+ return /* @__PURE__ */ ie(jt.Provider, { value: h, children: e });
3463
3347
  }
3464
- function ot(e) {
3465
- const t = Ue(Ft);
3348
+ function rt(e) {
3349
+ const t = Ue(jt);
3466
3350
  if (!t && !(e != null && e.optional)) throw new Error("useThreads must be used within a ThreadsProvider");
3467
3351
  return t;
3468
3352
  }
3469
- function Ot(e) {
3353
+ function Lt(e) {
3470
3354
  const t = e.artifact;
3471
3355
  return !t || typeof t != "object" ? null : "metadata" in t && t.metadata ? t.metadata : {
3472
3356
  id: t.id ?? e.id ?? `artifact-${Date.now()}`,
@@ -3476,8 +3360,8 @@ function Ot(e) {
3476
3360
  progress: t.progress ?? void 0
3477
3361
  };
3478
3362
  }
3479
- function gr(e, t) {
3480
- const n = Ot(e);
3363
+ function dr(e, t) {
3364
+ const n = Lt(e);
3481
3365
  if (!n) return e;
3482
3366
  const r = {
3483
3367
  ...n,
@@ -3492,27 +3376,27 @@ function gr(e, t) {
3492
3376
  }
3493
3377
  };
3494
3378
  }
3495
- function mr(e, t, n) {
3379
+ function fr(e, t, n) {
3496
3380
  return e.find((r) => {
3497
- const o = Ot(r);
3381
+ const o = Lt(r);
3498
3382
  return !!((o == null ? void 0 : o.id) === t || n && r.toolCallId === n);
3499
3383
  }) ?? null;
3500
3384
  }
3501
- function Be(e) {
3502
- return e.map((t) => nt(t)).filter((t) => !!t);
3385
+ function Oe(e) {
3386
+ return e.map((t) => tt(t)).filter((t) => !!t);
3503
3387
  }
3504
- function $t(e, t, n) {
3388
+ function Ft(e, t, n) {
3505
3389
  return t < 0 || t >= e.length ? e : [...e.slice(0, t), n, ...e.slice(t + 1)];
3506
3390
  }
3507
- function hr(e, t, n) {
3391
+ function pr(e, t, n) {
3508
3392
  for (let r = e.length - 1; r >= 0; r--)
3509
3393
  if (e[r].role === "assistant") {
3510
3394
  const s = { ...e[r], checkpointId: t, checkpointNs: n ?? void 0 };
3511
- return $t(e, r, s);
3395
+ return Ft(e, r, s);
3512
3396
  }
3513
3397
  return e;
3514
3398
  }
3515
- const Bt = {
3399
+ const Ot = {
3516
3400
  status: "idle",
3517
3401
  messages: [],
3518
3402
  taskMessagesByScope: {},
@@ -3524,7 +3408,7 @@ const Bt = {
3524
3408
  values: {},
3525
3409
  error: null
3526
3410
  };
3527
- function yr(e, t) {
3411
+ function gr(e, t) {
3528
3412
  var n;
3529
3413
  switch (t.type) {
3530
3414
  case "status":
@@ -3535,8 +3419,8 @@ function yr(e, t) {
3535
3419
  };
3536
3420
  case "reset":
3537
3421
  return {
3538
- ...Bt,
3539
- messages: Be(((n = t.payload) == null ? void 0 : n.messages) ?? [])
3422
+ ...Ot,
3423
+ messages: Oe(((n = t.payload) == null ? void 0 : n.messages) ?? [])
3540
3424
  };
3541
3425
  case "user_message": {
3542
3426
  const { message: r } = t.payload;
@@ -3550,7 +3434,7 @@ function yr(e, t) {
3550
3434
  };
3551
3435
  }
3552
3436
  case "seed": {
3553
- const r = Be(t.payload.messages), o = {
3437
+ const r = Oe(t.payload.messages), o = {
3554
3438
  ...e,
3555
3439
  status: "idle",
3556
3440
  messages: r,
@@ -3562,31 +3446,31 @@ function yr(e, t) {
3562
3446
  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;
3563
3447
  }
3564
3448
  case "prepend": {
3565
- const r = Be(t.payload.messages);
3449
+ const r = Oe(t.payload.messages);
3566
3450
  if (!r.length) return e;
3567
3451
  const o = new Set(e.messages.map((a) => a.id)), s = r.filter((a) => !o.has(a.id));
3568
3452
  return s.length ? { ...e, messages: [...s, ...e.messages] } : e;
3569
3453
  }
3570
3454
  case "event":
3571
- return gt(e, t.payload.ev);
3455
+ return ft(e, t.payload.ev);
3572
3456
  case "batch": {
3573
3457
  const { events: r } = t.payload;
3574
- return r.length ? r.reduce((o, s) => gt(o, s), e) : e;
3458
+ return r.length ? r.reduce((o, s) => ft(o, s), e) : e;
3575
3459
  }
3576
3460
  default:
3577
3461
  return e;
3578
3462
  }
3579
3463
  }
3580
- function br(e = []) {
3581
- const [t, n] = Jt(yr, { ...Bt, messages: e }), r = H([]), o = H(null), s = z(() => {
3464
+ function mr(e = []) {
3465
+ const [t, n] = Wt(gr, { ...Ot, messages: e }), r = K([]), o = K(null), s = U(() => {
3582
3466
  o.current !== null && typeof window < "u" && window.cancelAnimationFrame(o.current), o.current = null;
3583
3467
  const c = r.current;
3584
3468
  c.length && (r.current = [], n({ type: "batch", payload: { events: c } }));
3585
- }, []), a = z(() => {
3469
+ }, []), a = U(() => {
3586
3470
  typeof window < "u" && typeof window.requestAnimationFrame == "function" ? o.current === null && (o.current = window.requestAnimationFrame(() => s())) : setTimeout(s, 8);
3587
- }, [s]), i = z((c) => {
3471
+ }, [s]), i = U((c) => {
3588
3472
  r.current.push(c), a();
3589
- }, [a]), u = Q(() => ({
3473
+ }, [a]), u = X(() => ({
3590
3474
  setStatus: (c, l) => n({ type: "status", payload: { status: c, error: l } }),
3591
3475
  reset: (c) => n({ type: "reset", payload: { messages: c } }),
3592
3476
  seed: (c, l) => n({ type: "seed", payload: { messages: c, ...l ?? {} } }),
@@ -3595,11 +3479,11 @@ function br(e = []) {
3595
3479
  }), [i]);
3596
3480
  return { state: t, dispatch: n, ...u };
3597
3481
  }
3598
- function gt(e, t) {
3482
+ function ft(e, t) {
3599
3483
  var a;
3600
3484
  const n = t, r = n == null ? void 0 : n.origin, o = n == null ? void 0 : n.scope, s = r === "task" || typeof o == "string" && o.startsWith("tools:");
3601
3485
  if (t.type === "checkpoint") {
3602
- const i = t.checkpointNs ?? e.lastCheckpointNs ?? null, u = hr(e.messages, t.checkpointId, i);
3486
+ const i = t.checkpointNs ?? e.lastCheckpointNs ?? null, u = pr(e.messages, t.checkpointId, i);
3603
3487
  return { ...e, lastCheckpointId: t.checkpointId, lastCheckpointNs: i, messages: u };
3604
3488
  }
3605
3489
  if (t.type === "status") {
@@ -3616,7 +3500,7 @@ function gt(e, t) {
3616
3500
  return { ...e, status: "error", error: t.message, messages: [...e.messages, i] };
3617
3501
  }
3618
3502
  if (t.type === "values" && ((a = n.values) != null && a.messages)) {
3619
- const i = n.values, u = Array.isArray(i.messages) ? i.messages : [], c = Be(u), { messages: l, ...p } = i;
3503
+ const i = n.values, u = Array.isArray(i.messages) ? i.messages : [], c = Oe(u), { messages: l, ...p } = i;
3620
3504
  if (s) {
3621
3505
  const m = typeof o == "string" && o.length > 0 ? o : "task";
3622
3506
  return {
@@ -3633,15 +3517,15 @@ function gt(e, t) {
3633
3517
  values: p
3634
3518
  };
3635
3519
  }
3636
- return t.type === "messages/partial" ? wr(e, n) : t.type === "tool.start" ? s ? e : vr(e, t) : t.type === "tool.progress" ? s ? e : kr(e, t) : t.type === "tool.end" ? s ? e : Ir(e, t) : t.type === "artifact.update" ? Tr(e, t) : e;
3520
+ return t.type === "messages/partial" ? hr(e, n) : t.type === "tool.start" ? s ? e : yr(e, t) : t.type === "tool.progress" ? s ? e : br(e, t) : t.type === "tool.end" ? s ? e : wr(e, t) : t.type === "artifact.update" ? vr(e, t) : e;
3637
3521
  }
3638
- function wr(e, t) {
3522
+ function hr(e, t) {
3639
3523
  const r = (t.messages || [t]).find((u) => u.type === "ai" || u.role === "assistant");
3640
3524
  if (!r) return e;
3641
3525
  const o = r.id, s = r.content ?? "", a = e.assemblingId !== o;
3642
3526
  let i = [...e.messages];
3643
3527
  if (a) {
3644
- const u = nt({
3528
+ const u = tt({
3645
3529
  ...r,
3646
3530
  role: "assistant",
3647
3531
  content: typeof s == "string" ? [{ type: "text", text: s }] : s
@@ -3664,7 +3548,7 @@ function wr(e, t) {
3664
3548
  assemblingId: o
3665
3549
  };
3666
3550
  }
3667
- function st(e, t) {
3551
+ function ot(e, t) {
3668
3552
  var n;
3669
3553
  if (!t) return -1;
3670
3554
  for (let r = e.length - 1; r >= 0; r--) {
@@ -3674,11 +3558,11 @@ function st(e, t) {
3674
3558
  }
3675
3559
  return -1;
3676
3560
  }
3677
- function vr(e, t) {
3561
+ function yr(e, t) {
3678
3562
  const n = t, r = n.id || n.callId;
3679
3563
  if (!r) return e;
3680
3564
  const o = n.name || "tool", s = `Starting ${o}...`;
3681
- let a = [...e.messages], i = st(a, r);
3565
+ let a = [...e.messages], i = ot(a, r);
3682
3566
  if (i === -1) {
3683
3567
  for (let u = a.length - 1; u >= 0; u--)
3684
3568
  if (a[u].role === "assistant") {
@@ -3698,11 +3582,11 @@ function vr(e, t) {
3698
3582
  }
3699
3583
  return { ...e, messages: a };
3700
3584
  }
3701
- function kr(e, t) {
3585
+ function br(e, t) {
3702
3586
  const n = t.id;
3703
3587
  if (!n) return e;
3704
3588
  let r = [...e.messages];
3705
- const o = st(r, n);
3589
+ const o = ot(r, n);
3706
3590
  if (o !== -1) {
3707
3591
  const s = r[o], a = ce(t.content), i = (s.toolCalls || []).map(
3708
3592
  (u) => u.id === n ? { ...u, content: typeof a == "string" ? a : u.content } : u
@@ -3711,11 +3595,11 @@ function kr(e, t) {
3711
3595
  }
3712
3596
  return { ...e, messages: r };
3713
3597
  }
3714
- function Ir(e, t) {
3598
+ function wr(e, t) {
3715
3599
  const n = t.id;
3716
3600
  if (!n) return e;
3717
3601
  let r = [...e.messages];
3718
- const o = st(r, n), s = ce(t.content ?? t.error);
3602
+ const o = ot(r, n), s = ce(t.content ?? t.error);
3719
3603
  if (o !== -1) {
3720
3604
  const i = r[o], u = (i.toolCalls || []).map(
3721
3605
  (c) => c.id === n ? {
@@ -3738,17 +3622,17 @@ function Ir(e, t) {
3738
3622
  };
3739
3623
  return { ...e, messages: [...r, a] };
3740
3624
  }
3741
- function Tr(e, t) {
3742
- const n = t.artifactId, r = mr(e.messages, n, t.callId);
3625
+ function vr(e, t) {
3626
+ const n = t.artifactId, r = fr(e.messages, n, t.callId);
3743
3627
  if (!r) return e;
3744
- const o = e.messages.indexOf(r), s = gr(r, {
3628
+ const o = e.messages.indexOf(r), s = dr(r, {
3745
3629
  status: t.status,
3746
3630
  progress: t.progress,
3747
3631
  error: t.error
3748
3632
  });
3749
- return t.partial_data && s.artifact && (s.artifact = { ...s.artifact, ...t.partial_data }), { ...e, messages: $t(e.messages, o, s) };
3633
+ return t.partial_data && s.artifact && (s.artifact = { ...s.artifact, ...t.partial_data }), { ...e, messages: Ft(e.messages, o, s) };
3750
3634
  }
3751
- function Re(e) {
3635
+ function ze(e) {
3752
3636
  if (!(!e || typeof e != "object" || Array.isArray(e)))
3753
3637
  return { ...e };
3754
3638
  }
@@ -3760,7 +3644,7 @@ function Fe(e, t) {
3760
3644
  return r.trim();
3761
3645
  }
3762
3646
  }
3763
- function xr(e, t) {
3647
+ function kr(e, t) {
3764
3648
  if (!e) return null;
3765
3649
  for (const n of t) {
3766
3650
  const r = e[n];
@@ -3769,12 +3653,12 @@ function xr(e, t) {
3769
3653
  }
3770
3654
  return null;
3771
3655
  }
3772
- function mt(e) {
3773
- const t = Re(e);
3656
+ function pt(e) {
3657
+ const t = ze(e);
3774
3658
  if (t)
3775
- return Re(t.configurable) ?? t;
3659
+ return ze(t.configurable) ?? t;
3776
3660
  }
3777
- async function Ar(e, t) {
3661
+ async function Ir(e, t) {
3778
3662
  var i, u;
3779
3663
  if (!e) return e ?? null;
3780
3664
  const n = le(e), r = Array.isArray(n.checkpoints) ? n.checkpoints : n.checkpoints ? Object.values(n.checkpoints) : [], o = /* @__PURE__ */ new Set();
@@ -3786,8 +3670,8 @@ async function Ar(e, t) {
3786
3670
  if (Array.isArray(m))
3787
3671
  for (const h of m) {
3788
3672
  if (!h || typeof h != "object" || h.type !== "image_url" && h.type !== "file") continue;
3789
- const v = h.fileId || h.file_id;
3790
- typeof v == "string" && v.trim() && o.add(v);
3673
+ const k = h.fileId || h.file_id;
3674
+ typeof k == "string" && k.trim() && o.add(k);
3791
3675
  }
3792
3676
  }
3793
3677
  }
@@ -3811,17 +3695,17 @@ async function Ar(e, t) {
3811
3695
  if (Array.isArray(m))
3812
3696
  for (const h of m) {
3813
3697
  if (!h || typeof h != "object" || h.type !== "image_url" && h.type !== "file") continue;
3814
- const v = h.fileId || h.file_id;
3815
- if (!v) continue;
3816
- const f = a.get(v), w = (f == null ? void 0 : f.contentUrl) || (f == null ? void 0 : f.content_url);
3817
- w && (h.type === "image_url" ? (h.imageUrl = h.imageUrl || {}, h.imageUrl.url = w) : h.type === "file" && (h.url = w, !h.name && (f != null && f.filename || f != null && f.name) && (h.name = (f == null ? void 0 : f.filename) || (f == null ? void 0 : f.name))));
3698
+ const k = h.fileId || h.file_id;
3699
+ if (!k) continue;
3700
+ const d = a.get(k), v = (d == null ? void 0 : d.contentUrl) || (d == null ? void 0 : d.content_url);
3701
+ v && (h.type === "image_url" ? (h.imageUrl = h.imageUrl || {}, h.imageUrl.url = v) : h.type === "file" && (h.url = v, !h.name && (d != null && d.filename || d != null && d.name) && (h.name = (d == null ? void 0 : d.filename) || (d == null ? void 0 : d.name))));
3818
3702
  }
3819
3703
  }
3820
3704
  }
3821
3705
  return n;
3822
3706
  }
3823
- function ht(e) {
3824
- 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) => Sr(le(s), a)).filter((s) => !!s)].sort((s, a) => yt(a.createdAt) - yt(s.createdAt)), o = r[0] ?? null;
3707
+ function gt(e) {
3708
+ 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) => Tr(le(s), a)).filter((s) => !!s)].sort((s, a) => mt(a.createdAt) - mt(s.createdAt)), o = r[0] ?? null;
3825
3709
  return {
3826
3710
  threadId: (e == null ? void 0 : e.threadId) ?? "",
3827
3711
  latest: o,
@@ -3829,42 +3713,42 @@ function ht(e) {
3829
3713
  interrupt: (o == null ? void 0 : o.interrupt) ?? null
3830
3714
  };
3831
3715
  }
3832
- function Sr(e, t) {
3833
- var P, x;
3716
+ function Tr(e, t) {
3717
+ var b, y;
3834
3718
  if (!e) return null;
3835
- const n = ((P = e.values) == null ? void 0 : P.activeAgent) ?? null, r = (x = e.values) == null ? void 0 : x.messages, s = (Array.isArray(r) ? r : []).map((S) => Cr(S, n)).filter((S) => !!S), a = Re(e.metadata) ?? {}, i = mt(e.config), u = Re(e.parentConfig), c = mt(u), l = Fe(i, ["checkpointId"]), p = Fe(i, ["checkpointNs"]), m = Fe(c, ["checkpointId"]), h = Re(e.config), v = Array.isArray(e.tasks) ? e.tasks.map((S) => ({ ...S })) : e.tasks ?? null, f = Array.isArray(e.next) ? [...e.next] : e.next ?? null, w = typeof e.createdAt == "string" && e.createdAt.trim() ? e.createdAt : new Date(Date.now() - t).toISOString(), k = {
3719
+ const n = ((b = e.values) == null ? void 0 : b.activeAgent) ?? null, r = (y = e.values) == null ? void 0 : y.messages, s = (Array.isArray(r) ? r : []).map((x) => xr(x, n)).filter((x) => !!x), a = ze(e.metadata) ?? {}, i = pt(e.config), u = ze(e.parentConfig), c = pt(u), l = Fe(i, ["checkpointId"]), p = Fe(i, ["checkpointNs"]), m = Fe(c, ["checkpointId"]), h = ze(e.config), k = Array.isArray(e.tasks) ? e.tasks.map((x) => ({ ...x })) : e.tasks ?? null, d = Array.isArray(e.next) ? [...e.next] : e.next ?? null, v = typeof e.createdAt == "string" && e.createdAt.trim() ? e.createdAt : new Date(Date.now() - t).toISOString(), I = {
3836
3720
  ...a,
3837
- step: xr(a, ["step"]) ?? 0,
3721
+ step: kr(a, ["step"]) ?? 0,
3838
3722
  source: Fe(a, ["source"]) ?? null
3839
- }, E = s.map((S) => ({
3840
- ...S,
3841
- checkpointId: S.checkpointId ?? l ?? null,
3842
- checkpointNs: S.checkpointNs ?? p ?? null
3843
- })), I = e.values, N = Array.isArray(e.interrupts) ? e.interrupts : Array.isArray(I == null ? void 0 : I.interrupts) ? I.interrupts : [];
3723
+ }, A = s.map((x) => ({
3724
+ ...x,
3725
+ checkpointId: x.checkpointId ?? l ?? null,
3726
+ checkpointNs: x.checkpointNs ?? p ?? null
3727
+ })), T = e.values, N = Array.isArray(e.interrupts) ? e.interrupts : Array.isArray(T == null ? void 0 : T.interrupts) ? T.interrupts : [];
3844
3728
  return {
3845
3729
  checkpointId: l ?? null,
3846
3730
  checkpointNs: p ?? null,
3847
- createdAt: w,
3731
+ createdAt: v,
3848
3732
  parentId: m ?? null,
3849
- messages: E,
3850
- interrupt: Mr(
3733
+ messages: A,
3734
+ interrupt: Ar(
3851
3735
  N,
3852
3736
  t,
3853
3737
  l ?? null
3854
3738
  ),
3855
- metadata: k,
3739
+ metadata: I,
3856
3740
  config: h ?? null,
3857
3741
  parentConfig: u ?? null,
3858
- next: f,
3859
- tasks: v,
3742
+ next: d,
3743
+ tasks: k,
3860
3744
  values: e.values ?? {}
3861
3745
  };
3862
3746
  }
3863
- function Cr(e, t) {
3864
- const n = nt(e);
3747
+ function xr(e, t) {
3748
+ const n = tt(e);
3865
3749
  return n ? (n.role === "assistant" && !n.name && t && (n.name = t), n) : null;
3866
3750
  }
3867
- function Mr(e, t, n) {
3751
+ function Ar(e, t, n) {
3868
3752
  const r = e.length;
3869
3753
  for (let o = r - 1; o >= 0; o -= 1) {
3870
3754
  const s = e[o];
@@ -3880,54 +3764,54 @@ function Mr(e, t, n) {
3880
3764
  }
3881
3765
  return null;
3882
3766
  }
3883
- function yt(e) {
3767
+ function mt(e) {
3884
3768
  if (!e) return 0;
3885
3769
  const t = Date.parse(e);
3886
3770
  return Number.isFinite(t) ? t : 0;
3887
3771
  }
3888
- const bt = 120;
3889
- function Er(e) {
3772
+ const ht = 120;
3773
+ function Sr(e) {
3890
3774
  if (!Array.isArray(e))
3891
3775
  return "";
3892
3776
  const t = e.filter((r) => !!(r && r.type === "text")).map((r) => (r.text ?? "").trim()).filter(Boolean);
3893
3777
  if (!t.length)
3894
3778
  return "";
3895
3779
  const n = t.join(" ").replace(/\s+/g, " ").trim();
3896
- return n ? n.length > bt ? `${n.slice(0, bt - 3)}…` : n : "";
3780
+ return n ? n.length > ht ? `${n.slice(0, ht - 3)}…` : n : "";
3897
3781
  }
3898
- function Pr(e) {
3899
- return Er(e.content) || "";
3782
+ function Cr(e) {
3783
+ return Sr(e.content) || "";
3900
3784
  }
3901
- function _r(e) {
3785
+ function Mr(e) {
3902
3786
  const t = /* @__PURE__ */ new Map(), n = [], r = /* @__PURE__ */ new Map(), o = [];
3903
3787
  for (let c = 0; c < e.length; c++) {
3904
- const l = e[c], p = l.checkpointId, m = p ?? `cp-${c}`, h = l.metadata ?? {}, v = typeof h.step == "number" ? h.step : null, f = typeof h.source == "string" ? h.source : null;
3905
- let w = null, k = null;
3906
- const E = Array.isArray(l.messages) ? l.messages : [];
3907
- for (const x of E)
3908
- x.role === "user" && (k || (k = x), x.id && (w = x.id));
3909
- const I = l.next && l.next.length > 0 ? String(l.next[0]) : null, N = l.parentConfig ?? null, P = {
3788
+ const l = e[c], p = l.checkpointId, m = p ?? `cp-${c}`, h = l.metadata ?? {}, k = typeof h.step == "number" ? h.step : null, d = typeof h.source == "string" ? h.source : null;
3789
+ let v = null, I = null;
3790
+ const A = Array.isArray(l.messages) ? l.messages : [];
3791
+ for (const y of A)
3792
+ y.role === "user" && (I || (I = y), y.id && (v = y.id));
3793
+ const T = l.next && l.next.length > 0 ? String(l.next[0]) : null, N = l.parentConfig ?? null, b = {
3910
3794
  id: m,
3911
- step: v,
3912
- source: f,
3795
+ step: k,
3796
+ source: d,
3913
3797
  createdAt: l.createdAt ?? null,
3914
3798
  namespace: l.checkpointNs ?? null,
3915
3799
  parentId: l.parentId ?? null,
3916
- next: I,
3800
+ next: T,
3917
3801
  parentConfig: N,
3918
- userMessageId: w
3802
+ userMessageId: v
3919
3803
  };
3920
- if (o.push(P), p && t.set(p, P), p && k) {
3921
- const x = Pr(k);
3922
- x && r.set(p, x);
3804
+ if (o.push(b), p && t.set(p, b), p && I) {
3805
+ const y = Cr(I);
3806
+ y && r.set(p, y);
3923
3807
  }
3924
3808
  n.push({
3925
3809
  id: m,
3926
- messageId: w,
3927
- step: v,
3928
- source: f,
3810
+ messageId: v,
3811
+ step: k,
3812
+ source: d,
3929
3813
  createdAt: l.createdAt ?? null,
3930
- next: I,
3814
+ next: T,
3931
3815
  parentConfig: N
3932
3816
  });
3933
3817
  }
@@ -3965,13 +3849,13 @@ function _r(e) {
3965
3849
  for (const p of t.values())
3966
3850
  p.userMessageId === c && l.push(p);
3967
3851
  return l.length ? (l.sort((p, m) => {
3968
- const h = typeof p.attemptIndex == "number" ? p.attemptIndex : Number.MAX_SAFE_INTEGER, v = typeof m.attemptIndex == "number" ? m.attemptIndex : Number.MAX_SAFE_INTEGER;
3969
- return h - v;
3852
+ const h = typeof p.attemptIndex == "number" ? p.attemptIndex : Number.MAX_SAFE_INTEGER, k = typeof m.attemptIndex == "number" ? m.attemptIndex : Number.MAX_SAFE_INTEGER;
3853
+ return h - k;
3970
3854
  }), l) : [];
3971
3855
  }
3972
3856
  };
3973
3857
  }
3974
- function co(e, t, n) {
3858
+ function so(e, t, n) {
3975
3859
  if (!e)
3976
3860
  return { attemptCount: 1, attemptIndex: 0, attempts: [] };
3977
3861
  const r = n.getMessageAttempts(e);
@@ -3988,10 +3872,10 @@ function co(e, t, n) {
3988
3872
  attempts: r
3989
3873
  };
3990
3874
  }
3991
- function Nr(e) {
3992
- return Q(() => _r(e), [e]);
3875
+ function Er(e) {
3876
+ return X(() => Mr(e), [e]);
3993
3877
  }
3994
- function Dt({
3878
+ function Bt({
3995
3879
  api: e,
3996
3880
  fileApi: t,
3997
3881
  seed: n,
@@ -4001,152 +3885,152 @@ function Dt({
4001
3885
  isStreaming: a,
4002
3886
  getMessages: i
4003
3887
  }) {
4004
- const [u, c] = D(null), p = Q(
4005
- () => ht(u),
3888
+ const [u, c] = $(null), p = X(
3889
+ () => gt(u),
4006
3890
  [u]
4007
- ).checkpoints, m = Nr(p), h = m.timeline, [v, f] = D(!1), [w, k] = D(!1), [E, I] = D(null), N = H(o), P = H(null), x = H(null);
4008
- q(() => {
3891
+ ).checkpoints, m = Er(p), h = m.timeline, [k, d] = $(!1), [v, I] = $(!1), [A, T] = $(null), N = K(o), b = K(null), y = K(null);
3892
+ W(() => {
4009
3893
  N.current = o;
4010
3894
  }, [o]);
4011
- const S = z(
4012
- async (M) => {
3895
+ const x = U(
3896
+ async (C) => {
4013
3897
  const L = await e.getState({
4014
- threadId: M.threadId,
4015
- checkpointId: M.checkpointId,
4016
- checkpointNs: M.checkpointNs
4017
- }), R = {
3898
+ threadId: C.threadId,
3899
+ checkpointId: C.checkpointId,
3900
+ checkpointNs: C.checkpointNs
3901
+ }), _ = {
4018
3902
  version: "values@1",
4019
- threadId: M.threadId,
3903
+ threadId: C.threadId,
4020
3904
  checkpoints: [L]
4021
- }, V = t ? await Ar(R, t) : R, { latest: B } = ht(V);
4022
- return B;
3905
+ }, O = t ? await Ir(_, t) : _, { latest: F } = gt(O);
3906
+ return F;
4023
3907
  },
4024
3908
  [e, t]
4025
- ), g = z(
4026
- async (M, L) => {
4027
- var B;
4028
- if (!M) return;
4029
- const R = `${M}:${L ?? "latest"}`;
4030
- if (P.current === R && !v) return;
4031
- (B = x.current) == null || B.abort();
4032
- const V = new AbortController();
4033
- x.current = V, f(!0), I(null);
3909
+ ), g = U(
3910
+ async (C, L) => {
3911
+ var G;
3912
+ if (!C) return;
3913
+ const _ = `${C}:${L ?? "latest"}`, O = i();
3914
+ if (b.current === _ && !k && O.length > 0) return;
3915
+ (G = y.current) == null || G.abort();
3916
+ const F = new AbortController();
3917
+ y.current = F, d(!0), T(null);
4034
3918
  try {
4035
- const b = await S({
4036
- threadId: M,
3919
+ const E = await x({
3920
+ threadId: C,
4037
3921
  checkpointId: L ?? void 0
4038
3922
  });
4039
- if (N.current !== M) return;
4040
- n((b == null ? void 0 : b.messages) ?? [], {
4041
- checkpointId: (b == null ? void 0 : b.checkpointId) ?? null,
4042
- checkpointNs: (b == null ? void 0 : b.checkpointNs) ?? null,
4043
- pendingInterrupt: (b == null ? void 0 : b.interrupt) ?? null,
4044
- values: b == null ? void 0 : b.values
4045
- }), P.current = R;
4046
- const T = await e.getStateHistory({
4047
- threadId: M,
3923
+ if (N.current !== C) return;
3924
+ n((E == null ? void 0 : E.messages) ?? [], {
3925
+ checkpointId: (E == null ? void 0 : E.checkpointId) ?? null,
3926
+ checkpointNs: (E == null ? void 0 : E.checkpointNs) ?? null,
3927
+ pendingInterrupt: (E == null ? void 0 : E.interrupt) ?? null,
3928
+ values: E == null ? void 0 : E.values
3929
+ }), b.current = _;
3930
+ const D = await e.getStateHistory({
3931
+ threadId: C,
4048
3932
  limit: 100,
4049
3933
  includeMessages: !1
4050
3934
  });
4051
- N.current === M && c(T);
4052
- } catch (b) {
4053
- if (!Qt(b)) {
4054
- const T = String(b);
4055
- I(T), r == null || r(T);
3935
+ N.current === C && c(D);
3936
+ } catch (E) {
3937
+ if (!Jt(E)) {
3938
+ const D = String(E);
3939
+ T(D), r == null || r(D);
4056
3940
  }
4057
3941
  } finally {
4058
- f(!1);
3942
+ d(!1);
4059
3943
  }
4060
3944
  },
4061
- [e, n, S, r, v]
4062
- ), y = z(
4063
- async (M, L) => {
3945
+ [e, n, x, r, k, i]
3946
+ ), w = U(
3947
+ async (C, L) => {
4064
3948
  if (o) {
4065
- k(!0);
3949
+ I(!0);
4066
3950
  try {
4067
- const R = await S({
3951
+ const _ = await x({
4068
3952
  threadId: o,
4069
- checkpointId: M,
3953
+ checkpointId: C,
4070
3954
  checkpointNs: L ?? void 0
4071
3955
  });
4072
- n((R == null ? void 0 : R.messages) ?? [], {
4073
- checkpointId: (R == null ? void 0 : R.checkpointId) ?? M,
4074
- checkpointNs: (R == null ? void 0 : R.checkpointNs) ?? L,
4075
- pendingInterrupt: (R == null ? void 0 : R.interrupt) ?? null,
4076
- values: R == null ? void 0 : R.values
3956
+ n((_ == null ? void 0 : _.messages) ?? [], {
3957
+ checkpointId: (_ == null ? void 0 : _.checkpointId) ?? C,
3958
+ checkpointNs: (_ == null ? void 0 : _.checkpointNs) ?? L,
3959
+ pendingInterrupt: (_ == null ? void 0 : _.interrupt) ?? null,
3960
+ values: _ == null ? void 0 : _.values
4077
3961
  });
4078
- } catch (R) {
4079
- console.error("[useThreadHistoryState] Navigation failed", R);
3962
+ } catch (_) {
3963
+ console.error("[useThreadHistoryState] Navigation failed", _);
4080
3964
  } finally {
4081
- k(!1);
3965
+ I(!1);
4082
3966
  }
4083
3967
  }
4084
3968
  },
4085
- [o, S, n]
4086
- ), F = z(async () => {
3969
+ [o, x, n]
3970
+ ), z = U(async () => {
4087
3971
  o && await g(o);
4088
- }, [o, g]), U = z(
4089
- async (M) => {
4090
- var V;
4091
- const L = (M == null ? void 0 : M.threadId) || o;
3972
+ }, [o, g]), j = U(
3973
+ async (C) => {
3974
+ var O;
3975
+ const L = (C == null ? void 0 : C.threadId) || o;
4092
3976
  if (!L || o !== L) return;
4093
- if (c(M), P.current = `${L}:latest`, (V = M.values) != null && V.messages) {
4094
- const B = await S({
3977
+ if (c(C), b.current = `${L}:latest`, (O = C.values) != null && O.messages) {
3978
+ const F = await x({
4095
3979
  threadId: L
4096
3980
  });
4097
- B && n(B.messages ?? [], {
4098
- checkpointId: B.checkpointId ?? null,
4099
- checkpointNs: B.checkpointNs ?? null,
4100
- pendingInterrupt: B.interrupt ?? null,
4101
- values: B.values
3981
+ F && n(F.messages ?? [], {
3982
+ checkpointId: F.checkpointId ?? null,
3983
+ checkpointNs: F.checkpointNs ?? null,
3984
+ pendingInterrupt: F.interrupt ?? null,
3985
+ values: F.values
4102
3986
  });
4103
3987
  }
4104
3988
  },
4105
- [o, S, n]
3989
+ [o, x, n]
4106
3990
  );
4107
- q(() => {
4108
- if (!s || !o || v || a) return;
4109
- const M = `${o}:latest`;
4110
- P.current !== M && g(o);
4111
- }, [s, o, v, a, g]);
4112
- const C = z(() => {
4113
- c(null), f(!1), k(!1), I(null), P.current = null;
3991
+ W(() => {
3992
+ if (!s || !o || k || a) return;
3993
+ const C = `${o}:latest`;
3994
+ b.current !== C && g(o);
3995
+ }, [s, o, k, a, g]);
3996
+ const S = U(() => {
3997
+ c(null), d(!1), I(!1), T(null), b.current = null;
4114
3998
  }, []);
4115
3999
  return {
4116
4000
  threadCheckpoints: p,
4117
4001
  threadTimeline: h,
4118
4002
  checkpointIndex: m,
4119
- isLoadingThread: v,
4120
- isLoadingCheckpoint: w,
4121
- threadStateError: E,
4003
+ isLoadingThread: k,
4004
+ isLoadingCheckpoint: v,
4005
+ threadStateError: A,
4122
4006
  loadThread: g,
4123
- navigateToCheckpoint: y,
4124
- setCurrentCheckpointId: (M, L) => {
4125
- n(i(), { checkpointId: M, checkpointNs: L });
4007
+ navigateToCheckpoint: w,
4008
+ setCurrentCheckpointId: (C, L) => {
4009
+ n(i(), { checkpointId: C, checkpointNs: L });
4126
4010
  },
4127
- returnToLatest: F,
4128
- handleValuesEvent: U,
4011
+ returnToLatest: z,
4012
+ handleValuesEvent: j,
4129
4013
  markSkipNextLoad: () => {
4130
4014
  },
4131
4015
  markStreamPendingThread: () => {
4132
4016
  },
4133
- resetHistoryState: C,
4134
- clearState: C
4017
+ resetHistoryState: S,
4018
+ clearState: S
4135
4019
  };
4136
4020
  }
4137
- const Vt = Se(null), Kt = Se(null);
4138
- function Gt(e) {
4139
- const t = Ue(Vt);
4021
+ const $t = Se(null), Vt = Se(null);
4022
+ function Dt(e) {
4023
+ const t = Ue($t);
4140
4024
  if (!t && !(e != null && e.optional)) throw new Error("useThreadState must be used within a ThreadStateProvider");
4141
4025
  return t;
4142
4026
  }
4143
- function Rr() {
4144
- const e = Ue(Kt);
4027
+ function Pr() {
4028
+ const e = Ue(Vt);
4145
4029
  if (!e)
4146
4030
  throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");
4147
4031
  return e;
4148
4032
  }
4149
- function zr({
4033
+ function Nr({
4150
4034
  children: e,
4151
4035
  initialThreadId: t = null,
4152
4036
  initialCheckpointId: n = null,
@@ -4155,22 +4039,22 @@ function zr({
4155
4039
  isStreaming: s,
4156
4040
  onError: a
4157
4041
  }) {
4158
- const { chatApi: i, fileApi: u } = Ae(), { currentThreadId: c } = ot(), { state: l, seed: p, onEvent: m, dispatch: h } = br(), {
4159
- threadCheckpoints: v,
4160
- threadTimeline: f,
4161
- checkpointIndex: w,
4162
- isLoadingThread: k,
4163
- isLoadingCheckpoint: E,
4164
- threadStateError: I,
4042
+ const { chatApi: i, fileApi: u } = Ae(), { currentThreadId: c } = rt(), { state: l, seed: p, onEvent: m, dispatch: h } = mr(), {
4043
+ threadCheckpoints: k,
4044
+ threadTimeline: d,
4045
+ checkpointIndex: v,
4046
+ isLoadingThread: I,
4047
+ isLoadingCheckpoint: A,
4048
+ threadStateError: T,
4165
4049
  loadThread: N,
4166
- navigateToCheckpoint: P,
4167
- setCurrentCheckpointId: x,
4168
- returnToLatest: S,
4050
+ navigateToCheckpoint: b,
4051
+ setCurrentCheckpointId: y,
4052
+ returnToLatest: x,
4169
4053
  handleValuesEvent: g,
4170
- markSkipNextLoad: y,
4171
- markStreamPendingThread: F,
4172
- resetHistoryState: U
4173
- } = Dt({
4054
+ markSkipNextLoad: w,
4055
+ markStreamPendingThread: z,
4056
+ resetHistoryState: j
4057
+ } = Bt({
4174
4058
  api: i,
4175
4059
  fileApi: u,
4176
4060
  seed: p,
@@ -4181,36 +4065,32 @@ function zr({
4181
4065
  initialCheckpointNs: r,
4182
4066
  autoLoadInitial: o,
4183
4067
  isStreaming: s,
4184
- getMessages: z(() => l.messages, [l.messages])
4185
- });
4186
- q(() => {
4187
- c || (p([], {}), U());
4188
- }, [c, p, U]);
4189
- const C = H(null), M = z(
4190
- (d) => {
4191
- C.current = d;
4068
+ getMessages: U(() => l.messages, [l.messages])
4069
+ }), S = K(null), C = U(
4070
+ (f) => {
4071
+ S.current = f;
4192
4072
  },
4193
4073
  []
4194
- ), L = H(null), R = z(
4195
- (d) => {
4196
- L.current = d;
4074
+ ), L = K(null), _ = U(
4075
+ (f) => {
4076
+ L.current = f;
4197
4077
  },
4198
4078
  []
4199
- ), V = Q(() => ({ assemblingMessageId: l.assemblingId ?? null }), [l.assemblingId]), B = z(
4200
- (d, A) => {
4201
- const _ = jt(d, "user");
4079
+ ), O = X(() => ({ assemblingMessageId: l.assemblingId ?? null }), [l.assemblingId]), F = U(
4080
+ (f, P) => {
4081
+ const M = Ut(f, "user");
4202
4082
  return h({
4203
4083
  type: "user_message",
4204
4084
  payload: {
4205
- message: _,
4206
- editingMessageId: A == null ? void 0 : A.editingMessageId
4085
+ message: M,
4086
+ editingMessageId: P == null ? void 0 : P.editingMessageId
4207
4087
  }
4208
- }), _;
4088
+ }), M;
4209
4089
  },
4210
4090
  [h]
4211
- ), b = z(async () => {
4212
- C.current ? await C.current() : (p([], {}), U());
4213
- }, [p, U]), T = Q(() => On(l.messages), [l.messages]), $ = Q(
4091
+ ), G = U(async () => {
4092
+ S.current ? await S.current() : (p([], {}), j());
4093
+ }, [p, j]), E = X(() => Ln(l.messages), [l.messages]), D = X(
4214
4094
  () => ({
4215
4095
  status: l.status,
4216
4096
  threadId: c,
@@ -4221,44 +4101,44 @@ function zr({
4221
4101
  id: l.lastCheckpointId ?? null,
4222
4102
  namespace: l.lastCheckpointNs ?? null
4223
4103
  },
4224
- checkpoints: v,
4225
- checkpointIndex: w,
4226
- timelineCheckpoints: f,
4227
- metadata: V,
4104
+ checkpoints: k,
4105
+ checkpointIndex: v,
4106
+ timelineCheckpoints: d,
4107
+ metadata: O,
4228
4108
  values: l.values ?? {},
4229
- isLoading: k,
4230
- isLoadingCheckpoint: E,
4231
- error: I,
4109
+ isLoading: I,
4110
+ isLoadingCheckpoint: A,
4111
+ error: T,
4232
4112
  loadOlder: async () => {
4233
4113
  },
4234
4114
  // Placeholder
4235
- seedFromSnapshot: (d) => {
4236
- p(d.messages, {
4237
- checkpointId: d.checkpointId,
4238
- checkpointNs: d.checkpointNs,
4239
- pendingInterrupt: d.interrupt,
4240
- values: d.values
4115
+ seedFromSnapshot: (f) => {
4116
+ p(f.messages, {
4117
+ checkpointId: f.checkpointId,
4118
+ checkpointNs: f.checkpointNs,
4119
+ pendingInterrupt: f.interrupt,
4120
+ values: f.values
4241
4121
  });
4242
4122
  },
4243
- clearState: b,
4244
- navigateToCheckpoint: P,
4245
- setCurrentCheckpointId: x,
4246
- returnToLatest: S,
4247
- loadThread: async (d, A, _) => {
4248
- await N(d, A, { clearProgress: !1 });
4123
+ clearState: G,
4124
+ navigateToCheckpoint: b,
4125
+ setCurrentCheckpointId: y,
4126
+ returnToLatest: x,
4127
+ loadThread: async (f, P, M) => {
4128
+ await N(f, P, { clearProgress: !1 });
4249
4129
  },
4250
- clearThread: b,
4251
- respondToInterrupt: async (d, A, _) => {
4252
- L.current && await L.current(d, A, _);
4130
+ clearThread: G,
4131
+ respondToInterrupt: async (f, P, M) => {
4132
+ L.current && await L.current(f, P, M);
4253
4133
  },
4254
- messagePreviews: w.messagePreviews,
4134
+ messagePreviews: v.messagePreviews,
4255
4135
  handleValuesEvent: g,
4256
- markSkipNextLoad: y,
4257
- markStreamPendingThread: F,
4258
- resetHistoryState: U,
4259
- pushUser: B,
4136
+ markSkipNextLoad: w,
4137
+ markStreamPendingThread: z,
4138
+ resetHistoryState: j,
4139
+ pushUser: F,
4260
4140
  onEvent: m,
4261
- artifacts: T
4141
+ artifacts: E
4262
4142
  }),
4263
4143
  [
4264
4144
  c,
@@ -4268,37 +4148,37 @@ function zr({
4268
4148
  l.lastCheckpointId,
4269
4149
  l.lastCheckpointNs,
4270
4150
  l.values,
4271
- v,
4272
- f,
4273
- w,
4274
- V,
4275
4151
  k,
4276
- E,
4152
+ d,
4153
+ v,
4154
+ O,
4277
4155
  I,
4156
+ A,
4157
+ T,
4278
4158
  p,
4159
+ G,
4279
4160
  b,
4280
- P,
4161
+ y,
4281
4162
  x,
4282
- S,
4283
4163
  N,
4284
4164
  g,
4285
- y,
4165
+ w,
4166
+ z,
4286
4167
  F,
4287
- B,
4288
4168
  m,
4289
- T
4169
+ E
4290
4170
  ]
4291
- ), O = Q(
4171
+ ), Q = X(
4292
4172
  () => ({
4293
- registerClearThread: M,
4294
- registerRespondToInterrupt: R
4173
+ registerClearThread: C,
4174
+ registerRespondToInterrupt: _
4295
4175
  }),
4296
- [M, R]
4176
+ [C, _]
4297
4177
  );
4298
- return /* @__PURE__ */ ie(Kt.Provider, { value: O, children: /* @__PURE__ */ ie(Vt.Provider, { value: $, children: e }) });
4178
+ return /* @__PURE__ */ ie(Vt.Provider, { value: Q, children: /* @__PURE__ */ ie($t.Provider, { value: D, children: e }) });
4299
4179
  }
4300
- const Ht = Se(null), Ur = Se(!1);
4301
- function Lr({
4180
+ const Kt = Se(null), _r = Se(!1);
4181
+ function zr({
4302
4182
  children: e,
4303
4183
  onError: t,
4304
4184
  onAuthError: n,
@@ -4310,216 +4190,216 @@ function Lr({
4310
4190
  onFinish: u,
4311
4191
  onStreamingChange: c
4312
4192
  }) {
4313
- const { chatApi: l, baseUrl: p } = Ae(), m = p, h = pe(t), v = pe(n), f = pe(r), w = pe(o), k = pe(s), E = pe(a), I = pe(i), N = pe(u), P = pe(c), x = Q(
4193
+ const { chatApi: l, baseUrl: p } = Ae(), m = p, h = pe(t), k = pe(n), d = pe(r), v = pe(o), I = pe(s), A = pe(a), T = pe(i), N = pe(u), b = pe(c), y = X(
4314
4194
  () => ({
4315
4195
  onError: h,
4316
- onAuthError: v,
4317
- onConnectionError: f,
4318
- onMetadataEvent: I,
4319
- onCustomEvent: E,
4320
- onUpdateEvent: k,
4321
- onToolEnd: w,
4196
+ onAuthError: k,
4197
+ onConnectionError: d,
4198
+ onMetadataEvent: T,
4199
+ onCustomEvent: A,
4200
+ onUpdateEvent: I,
4201
+ onToolEnd: v,
4322
4202
  onFinish: N
4323
4203
  }),
4324
4204
  [
4325
4205
  h,
4326
- v,
4327
- f,
4328
- I,
4329
- E,
4330
4206
  k,
4331
- w,
4207
+ d,
4208
+ T,
4209
+ A,
4210
+ I,
4211
+ v,
4332
4212
  N
4333
4213
  ]
4334
4214
  );
4335
- return /* @__PURE__ */ ie(Ur.Provider, { value: !0, children: /* @__PURE__ */ ie(
4336
- jr,
4215
+ return /* @__PURE__ */ ie(_r.Provider, { value: !0, children: /* @__PURE__ */ ie(
4216
+ Rr,
4337
4217
  {
4338
4218
  api: l,
4339
4219
  streamBaseUrl: m,
4340
- handlers: x,
4341
- onStreamingChange: P,
4220
+ handlers: y,
4221
+ onStreamingChange: b,
4342
4222
  children: e
4343
4223
  }
4344
4224
  ) });
4345
4225
  }
4346
- function jr({
4226
+ function Rr({
4347
4227
  children: e,
4348
4228
  api: t,
4349
4229
  streamBaseUrl: n,
4350
4230
  handlers: r,
4351
4231
  onStreamingChange: o
4352
4232
  }) {
4353
- const { setCurrentThreadId: s, currentThreadIdRef: a, addThreadFromEvent: i, currentThreadId: u } = ot(), {
4233
+ const { setCurrentThreadId: s, currentThreadIdRef: a, addThreadFromEvent: i, currentThreadId: u } = rt(), {
4354
4234
  interrupt: c,
4355
4235
  checkpoint: l,
4356
4236
  timelineCheckpoints: p,
4357
4237
  handleValuesEvent: m,
4358
4238
  markSkipNextLoad: h,
4359
- markStreamPendingThread: v,
4360
- resetHistoryState: f,
4361
- pushUser: w,
4362
- onEvent: k,
4363
- messages: E
4364
- } = Gt(), { registerClearThread: I, registerRespondToInterrupt: N } = Rr(), P = z(
4365
- (d) => {
4366
- i(d), v(d.threadId), a.current !== d.threadId && ((d.created ?? !a.current) && h(d.threadId), s(d.threadId));
4239
+ markStreamPendingThread: k,
4240
+ resetHistoryState: d,
4241
+ pushUser: v,
4242
+ onEvent: I,
4243
+ messages: A
4244
+ } = Dt(), { registerClearThread: T, registerRespondToInterrupt: N } = Pr(), b = U(
4245
+ (f) => {
4246
+ i(f), k(f.threadId), a.current !== f.threadId && ((f.created ?? !a.current) && h(f.threadId), s(f.threadId));
4367
4247
  },
4368
- [i, h, v, s, a]
4369
- ), x = lr({
4248
+ [i, h, k, s, a]
4249
+ ), y = cr({
4370
4250
  baseUrl: n,
4371
- onEvent: k,
4372
- onError: (d) => {
4373
- var A;
4374
- (A = r.onError) == null || A.call(r, (d == null ? void 0 : d.message) ?? String(d));
4251
+ onEvent: I,
4252
+ onError: (f) => {
4253
+ var P;
4254
+ (P = r.onError) == null || P.call(r, (f == null ? void 0 : f.message) ?? String(f));
4375
4255
  },
4376
4256
  onAuthError: r.onAuthError,
4377
4257
  onConnectionError: r.onConnectionError,
4378
4258
  onFinish: r.onFinish,
4379
- onThreadInfo: P,
4259
+ onThreadInfo: b,
4380
4260
  onMetadataEvent: r.onMetadataEvent,
4381
4261
  onCustomEvent: r.onCustomEvent,
4382
4262
  onUpdateEvent: r.onUpdateEvent,
4383
4263
  onToolEnd: r.onToolEnd,
4384
4264
  handleValuesEvent: m
4385
4265
  });
4386
- q(() => {
4387
- o == null || o(x.isStreaming);
4388
- }, [x.isStreaming, o]);
4389
- const { stream: S, stop: g, clear: y, isStreaming: F, error: U, connected: C, streamedMessages: M, activeMessageId: L } = x;
4390
- q(() => {
4391
- u !== void 0 && y();
4392
- }, [u, y]);
4393
- const R = z(
4394
- async (d, A) => {
4395
- await S(d, A);
4266
+ W(() => {
4267
+ o == null || o(y.isStreaming);
4268
+ }, [y.isStreaming, o]);
4269
+ const { stream: x, stop: g, clear: w, isStreaming: z, error: j, connected: S, streamedMessages: C, activeMessageId: L } = y;
4270
+ W(() => {
4271
+ u !== void 0 && w();
4272
+ }, [u, w]);
4273
+ const _ = U(
4274
+ async (f, P) => {
4275
+ await x(f, P);
4396
4276
  },
4397
- [S]
4398
- ), V = H(l);
4399
- q(() => {
4400
- V.current = l;
4277
+ [x]
4278
+ ), O = K(l);
4279
+ W(() => {
4280
+ O.current = l;
4401
4281
  }, [l]);
4402
- const B = z(
4403
- async (d, A, _) => {
4282
+ const F = U(
4283
+ async (f, P, M) => {
4404
4284
  const te = a.current;
4405
4285
  if (!te)
4406
4286
  throw new Error("No active thread to handle interrupt");
4407
- const J = d ? A ?? !0 : !1, G = V.current, Z = (_ == null ? void 0 : _.checkpointId) ?? G.id ?? void 0, ae = (_ == null ? void 0 : _.checkpointNs) ?? G.namespace ?? void 0, ue = {
4287
+ const q = f ? P ?? !0 : !1, V = O.current, Z = (M == null ? void 0 : M.checkpointId) ?? V.id ?? void 0, oe = (M == null ? void 0 : M.checkpointNs) ?? V.namespace ?? void 0, ue = {
4408
4288
  threadId: te,
4409
4289
  checkpointId: Z,
4410
- checkpointNs: ae,
4411
- command: { kind: "resume", value: J },
4412
- payload: _ == null ? void 0 : _.payload
4290
+ checkpointNs: oe,
4291
+ command: { kind: "resume", value: q },
4292
+ payload: M == null ? void 0 : M.payload
4413
4293
  };
4414
- R(ue);
4294
+ _(ue);
4415
4295
  },
4416
- [a, R]
4296
+ [a, _]
4417
4297
  );
4418
- q(() => {
4419
- N(B);
4420
- }, [B, N]);
4421
- const b = z(async () => {
4422
- g(), y(), f(), s(null);
4423
- }, [y, f, s, g]);
4424
- q(() => {
4425
- I(b);
4426
- }, [b, I]);
4427
- const T = z(
4428
- async (d, A) => {
4429
- F && g();
4430
- let _ = a.current;
4431
- const te = (d == null ? void 0 : d.text) ?? "", J = (d == null ? void 0 : d.attachments) ?? [], G = (te == null ? void 0 : te.trim()) ?? "", Z = { ...(d == null ? void 0 : d.payload) ?? {} }, ae = Array.isArray(Z.messages) ? Z.messages : void 0;
4432
- ae && delete Z.messages;
4433
- const ue = !!(ae && ae.length), W = !!(d.contentParts && d.contentParts.length > 0);
4434
- if (!_ && !G && J.length === 0 && !ue && !W) return;
4435
- if (!_) {
4298
+ W(() => {
4299
+ N(F);
4300
+ }, [F, N]);
4301
+ const G = U(async () => {
4302
+ g(), w(), d(), s(null);
4303
+ }, [w, d, s, g]);
4304
+ W(() => {
4305
+ T(G);
4306
+ }, [G, T]);
4307
+ const E = U(
4308
+ async (f, P) => {
4309
+ z && g();
4310
+ let M = a.current;
4311
+ const te = (f == null ? void 0 : f.text) ?? "", q = (f == null ? void 0 : f.attachments) ?? [], V = (te == null ? void 0 : te.trim()) ?? "", Z = { ...(f == null ? void 0 : f.payload) ?? {} }, oe = Array.isArray(Z.messages) ? Z.messages : void 0;
4312
+ oe && delete Z.messages;
4313
+ const ue = !!(oe && oe.length), H = !!(f.contentParts && f.contentParts.length > 0);
4314
+ if (!M && !V && q.length === 0 && !ue && !H) return;
4315
+ if (!M) {
4436
4316
  const he = Math.floor(Date.now() / 1e3).toString(16).padStart(8, "0"), ye = Array.from({ length: 4 }, () => Math.floor(Math.random() * 4294967295).toString(16).padStart(8, "0")).join("").slice(0, 16);
4437
- _ = `${he}${ye}`, h(_), s(_);
4317
+ M = `${he}${ye}`, h(M), s(M);
4438
4318
  }
4439
4319
  let ee = null;
4440
- d.contentParts && d.contentParts.length > 0 && (ee = d.contentParts);
4441
- const { contentParts: ve, filesInfo: X } = ee ? { contentParts: ee, filesInfo: [] } : await or(J), Y = [...ve];
4442
- G && Y.push({ type: "text", text: te });
4443
- const me = d == null ? void 0 : d.originalMessageId, Le = !!(d != null && d.edit && me), je = !ue && Y.length > 0;
4320
+ f.contentParts && f.contentParts.length > 0 && (ee = f.contentParts);
4321
+ const { contentParts: ve, filesInfo: J } = ee ? { contentParts: ee, filesInfo: [] } : await rr(q), Y = [...ve];
4322
+ V && Y.push({ type: "text", text: te });
4323
+ const me = f == null ? void 0 : f.originalMessageId, je = !!(f != null && f.edit && me), Le = !ue && Y.length > 0;
4444
4324
  let de = null;
4445
- if (je) {
4446
- const he = Le ? me : `msg-${Date.now()}`;
4447
- de = jt({
4325
+ if (Le) {
4326
+ const he = je ? me : `msg-${Date.now()}`;
4327
+ de = Ut({
4448
4328
  id: he,
4449
4329
  role: "user",
4450
4330
  content: Y,
4451
4331
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
4452
- }, "user"), Le ? w(de, { editingMessageId: me }) : w(de);
4332
+ }, "user"), je ? v(de, { editingMessageId: me }) : v(de);
4453
4333
  }
4454
- const Ie = ue ? ae : de ? [de] : [], ne = {
4334
+ const Ie = ue ? oe : de ? [de] : [], ne = {
4455
4335
  ...Z,
4456
- ...X.length ? { files_info: X } : {}
4336
+ ...J.length ? { files_info: J } : {}
4457
4337
  };
4458
4338
  Ie.length ? ne.messages = Ie : "messages" in ne || (ne.messages = []);
4459
- const Me = (d == null ? void 0 : d.checkpointId) ?? l.id ?? void 0;
4460
- if (d != null && d.edit && !Me)
4339
+ const Me = (f == null ? void 0 : f.checkpointId) ?? l.id ?? void 0;
4340
+ if (f != null && f.edit && !Me)
4461
4341
  throw new Error(
4462
- `[streaming] Missing checkpointId for edit submit. threadId=${_ ?? "null"}`
4342
+ `[streaming] Missing checkpointId for edit submit. threadId=${M ?? "null"}`
4463
4343
  );
4464
4344
  const Ee = {
4465
- threadId: _,
4466
- content: d == null ? void 0 : d.text,
4345
+ threadId: M,
4346
+ content: f == null ? void 0 : f.text,
4467
4347
  payload: ne,
4468
- config: d == null ? void 0 : d.config,
4348
+ config: f == null ? void 0 : f.config,
4469
4349
  checkpointId: Me,
4470
- command: d == null ? void 0 : d.command,
4471
- edit: d == null ? void 0 : d.edit
4350
+ command: f == null ? void 0 : f.command,
4351
+ edit: f == null ? void 0 : f.edit
4472
4352
  };
4473
- return R(Ee, A);
4353
+ return _(Ee, P);
4474
4354
  },
4475
- [l, a, F, h, w, R, g, p]
4476
- ), $ = Q(() => {
4477
- const d = Object.keys(M).length > 0;
4478
- if (!F && !d)
4479
- return E;
4480
- const A = /* @__PURE__ */ new Map();
4481
- return E.forEach((_) => A.set(_.id, _)), Object.values(M).forEach((_) => {
4482
- A.set(_.id, _);
4483
- }), Array.from(A.values());
4484
- }, [F, M, E]), O = Q(
4355
+ [l, a, z, h, v, _, g, p]
4356
+ ), D = X(() => {
4357
+ const f = Object.keys(C).length > 0;
4358
+ if (!z && !f)
4359
+ return A;
4360
+ const P = /* @__PURE__ */ new Map();
4361
+ return A.forEach((M) => P.set(M.id, M)), Object.values(C).forEach((M) => {
4362
+ P.set(M.id, M);
4363
+ }), Array.from(P.values());
4364
+ }, [z, C, A]), Q = X(
4485
4365
  () => ({
4486
- isStreaming: F,
4487
- error: U,
4488
- connectionState: U ? "error" : F ? C ? "connected" : "connecting" : "idle",
4489
- messages: $,
4366
+ isStreaming: z,
4367
+ error: j,
4368
+ connectionState: j ? "error" : z ? S ? "connected" : "connecting" : "idle",
4369
+ messages: D,
4490
4370
  activeMessageId: L,
4491
- submit: T,
4371
+ submit: E,
4492
4372
  stop: g,
4493
4373
  interrupt: c,
4494
4374
  resume: () => Promise.resolve(),
4495
- goto: (d, A) => Promise.resolve(),
4375
+ goto: (f, P) => Promise.resolve(),
4496
4376
  clearError: () => {
4497
4377
  }
4498
4378
  // TODO: Implement error clearing
4499
4379
  }),
4500
- [F, U, T, g, c, C, $]
4380
+ [z, j, E, g, c, S, D]
4501
4381
  );
4502
- return /* @__PURE__ */ ie(Ht.Provider, { value: O, children: e });
4382
+ return /* @__PURE__ */ ie(Kt.Provider, { value: Q, children: e });
4503
4383
  }
4504
4384
  function pe(e) {
4505
- const t = H(e);
4506
- return q(() => {
4385
+ const t = K(e);
4386
+ return W(() => {
4507
4387
  t.current = e;
4508
- }, [e]), z((...n) => {
4388
+ }, [e]), U((...n) => {
4509
4389
  const r = t.current;
4510
4390
  if (r)
4511
4391
  return r(...n);
4512
4392
  }, []);
4513
4393
  }
4514
- function Fr(e) {
4515
- return Ue(Ht);
4394
+ function Ur(e) {
4395
+ return Ue(Kt);
4516
4396
  }
4517
- function wt(e) {
4397
+ function yt(e) {
4518
4398
  return typeof e == "object" && e !== null;
4519
4399
  }
4520
- function Or(e, t) {
4400
+ function jr(e, t) {
4521
4401
  if (Object.is(e, t)) return !0;
4522
- if (!wt(e) || !wt(t)) return !1;
4402
+ if (!yt(e) || !yt(t)) return !1;
4523
4403
  const n = Object.keys(e), r = Object.keys(t);
4524
4404
  if (n.length !== r.length)
4525
4405
  return !1;
@@ -4528,22 +4408,22 @@ function Or(e, t) {
4528
4408
  return !1;
4529
4409
  return !0;
4530
4410
  }
4531
- function $r(e) {
4532
- const t = H(e), n = H(e);
4533
- return Or(t.current, e) || (t.current = e, n.current = e), n.current;
4411
+ function Lr(e) {
4412
+ const t = K(e), n = K(e);
4413
+ return jr(t.current, e) || (t.current = e, n.current = e), n.current;
4534
4414
  }
4535
- function Br(e) {
4415
+ function Fr(e) {
4536
4416
  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;
4537
4417
  return typeof o == "string" ? o : null;
4538
4418
  }
4539
- function lo(e) {
4419
+ function ao(e) {
4540
4420
  const { setCurrentTaskId: t, getCurrentTaskId: n, onToolEnd: r } = e;
4541
4421
  return (o) => {
4542
- const s = Br(o), a = (n == null ? void 0 : n()) ?? null;
4422
+ const s = Fr(o), a = (n == null ? void 0 : n()) ?? null;
4543
4423
  s && s !== a && t(s), r == null || r(o);
4544
4424
  };
4545
4425
  }
4546
- function uo({
4426
+ function io({
4547
4427
  children: e,
4548
4428
  apiConfig: t,
4549
4429
  initialThreadId: n = null,
@@ -4558,50 +4438,50 @@ function uo({
4558
4438
  onUpdateEvent: p,
4559
4439
  onCustomEvent: m,
4560
4440
  onMetadataEvent: h,
4561
- onFinish: v
4441
+ onFinish: k
4562
4442
  }) {
4563
- const f = $r(t), [w, k] = D(!1), E = ge(i), I = ge(u), N = ge(a), P = ge(c), x = ge(l), S = ge(p), g = ge(m), y = ge(h), F = ge(v), U = Q(
4443
+ const d = Lr(t), [v, I] = $(!1), A = ge(i), T = ge(u), N = ge(a), b = ge(c), y = ge(l), x = ge(p), g = ge(m), w = ge(h), z = ge(k), j = X(
4564
4444
  () => ({
4565
- onError: E,
4566
- onAuthError: I,
4445
+ onError: A,
4446
+ onAuthError: T,
4567
4447
  onConnectionError: N,
4568
- onToolEnd: x,
4569
- onUpdateEvent: S,
4448
+ onToolEnd: y,
4449
+ onUpdateEvent: x,
4570
4450
  onCustomEvent: g,
4571
- onMetadataEvent: y,
4572
- onFinish: F
4451
+ onMetadataEvent: w,
4452
+ onFinish: z
4573
4453
  }),
4574
4454
  [
4575
- E,
4576
- I,
4455
+ A,
4456
+ T,
4577
4457
  N,
4458
+ y,
4578
4459
  x,
4579
- S,
4580
4460
  g,
4581
- y,
4582
- F
4461
+ w,
4462
+ z
4583
4463
  ]
4584
4464
  );
4585
- return /* @__PURE__ */ ie(nr, { apiConfig: f, children: /* @__PURE__ */ ie(
4586
- pr,
4465
+ return /* @__PURE__ */ ie(tr, { apiConfig: d, children: /* @__PURE__ */ ie(
4466
+ ur,
4587
4467
  {
4588
4468
  initialThreadId: n,
4589
- onError: E,
4590
- onThreadChange: P,
4469
+ onError: A,
4470
+ onThreadChange: b,
4591
4471
  children: /* @__PURE__ */ ie(
4592
- zr,
4472
+ Nr,
4593
4473
  {
4594
4474
  initialThreadId: n,
4595
4475
  initialCheckpointId: r,
4596
4476
  initialCheckpointNs: o,
4597
4477
  autoLoadInitial: s,
4598
- onError: E,
4599
- isStreaming: w,
4478
+ onError: A,
4479
+ isStreaming: v,
4600
4480
  children: /* @__PURE__ */ ie(
4601
- Lr,
4481
+ zr,
4602
4482
  {
4603
- ...U,
4604
- onStreamingChange: k,
4483
+ ...j,
4484
+ onStreamingChange: I,
4605
4485
  children: e
4606
4486
  }
4607
4487
  )
@@ -4611,34 +4491,34 @@ function uo({
4611
4491
  ) });
4612
4492
  }
4613
4493
  function ge(e) {
4614
- const t = H(e);
4615
- return t.current = e, z((...n) => {
4494
+ const t = K(e);
4495
+ return t.current = e, U((...n) => {
4616
4496
  const r = t.current;
4617
4497
  if (r)
4618
4498
  return r(...n);
4619
4499
  }, []);
4620
4500
  }
4621
- const Dr = 1, Vr = 1e6;
4622
- let Je = 0;
4623
- function Kr() {
4624
- return Je = (Je + 1) % Number.MAX_SAFE_INTEGER, Je.toString();
4501
+ const Or = 1, Br = 1e6;
4502
+ let We = 0;
4503
+ function $r() {
4504
+ return We = (We + 1) % Number.MAX_SAFE_INTEGER, We.toString();
4625
4505
  }
4626
- const Xe = /* @__PURE__ */ new Map(), vt = (e) => {
4627
- if (Xe.has(e))
4506
+ const qe = /* @__PURE__ */ new Map(), bt = (e) => {
4507
+ if (qe.has(e))
4628
4508
  return;
4629
4509
  const t = setTimeout(() => {
4630
- Xe.delete(e), ze({
4510
+ qe.delete(e), Re({
4631
4511
  type: "REMOVE_TOAST",
4632
4512
  toastId: e
4633
4513
  });
4634
- }, Vr);
4635
- Xe.set(e, t);
4636
- }, Gr = (e, t) => {
4514
+ }, Br);
4515
+ qe.set(e, t);
4516
+ }, Vr = (e, t) => {
4637
4517
  switch (t.type) {
4638
4518
  case "ADD_TOAST":
4639
4519
  return {
4640
4520
  ...e,
4641
- toasts: [t.toast, ...e.toasts].slice(0, Dr)
4521
+ toasts: [t.toast, ...e.toasts].slice(0, Or)
4642
4522
  };
4643
4523
  case "UPDATE_TOAST":
4644
4524
  return {
@@ -4649,8 +4529,8 @@ const Xe = /* @__PURE__ */ new Map(), vt = (e) => {
4649
4529
  };
4650
4530
  case "DISMISS_TOAST": {
4651
4531
  const { toastId: n } = t;
4652
- return n ? vt(n) : e.toasts.forEach((r) => {
4653
- vt(r.id);
4532
+ return n ? bt(n) : e.toasts.forEach((r) => {
4533
+ bt(r.id);
4654
4534
  }), {
4655
4535
  ...e,
4656
4536
  toasts: e.toasts.map(
@@ -4670,19 +4550,19 @@ const Xe = /* @__PURE__ */ new Map(), vt = (e) => {
4670
4550
  toasts: e.toasts.filter((n) => n.id !== t.toastId)
4671
4551
  };
4672
4552
  }
4673
- }, De = [];
4674
- let Ve = { toasts: [] };
4675
- function ze(e) {
4676
- Ve = Gr(Ve, e), De.forEach((t) => {
4677
- t(Ve);
4553
+ }, Be = [];
4554
+ let $e = { toasts: [] };
4555
+ function Re(e) {
4556
+ $e = Vr($e, e), Be.forEach((t) => {
4557
+ t($e);
4678
4558
  });
4679
4559
  }
4680
- function Hr({ ...e }) {
4681
- const t = Kr(), n = (o) => ze({
4560
+ function Dr({ ...e }) {
4561
+ const t = $r(), n = (o) => Re({
4682
4562
  type: "UPDATE_TOAST",
4683
4563
  toast: { ...o, id: t }
4684
- }), r = () => ze({ type: "DISMISS_TOAST", toastId: t });
4685
- return ze({
4564
+ }), r = () => Re({ type: "DISMISS_TOAST", toastId: t });
4565
+ return Re({
4686
4566
  type: "ADD_TOAST",
4687
4567
  toast: {
4688
4568
  ...e,
@@ -4698,77 +4578,77 @@ function Hr({ ...e }) {
4698
4578
  update: n
4699
4579
  };
4700
4580
  }
4701
- function Wr() {
4702
- const [e, t] = it.useState(Ve);
4703
- return it.useEffect(() => (De.push(t), () => {
4704
- const n = De.indexOf(t);
4705
- n > -1 && De.splice(n, 1);
4581
+ function Kr() {
4582
+ const [e, t] = at.useState($e);
4583
+ return at.useEffect(() => (Be.push(t), () => {
4584
+ const n = Be.indexOf(t);
4585
+ n > -1 && Be.splice(n, 1);
4706
4586
  }), [e]), {
4707
4587
  ...e,
4708
- toast: Hr,
4709
- dismiss: (n) => ze({ type: "DISMISS_TOAST", toastId: n })
4588
+ toast: Dr,
4589
+ dismiss: (n) => Re({ type: "DISMISS_TOAST", toastId: n })
4710
4590
  };
4711
4591
  }
4712
- function fo(e) {
4713
- const { allowFileOpen: t, currentThreadId: n } = e, { fileApi: r } = Ae(), { toast: o } = Wr(), [s, a] = D({}), [i, u] = D(null), [c, l] = D(!1), p = z(() => {
4592
+ function co(e) {
4593
+ const { allowFileOpen: t, currentThreadId: n } = e, { fileApi: r } = Ae(), { toast: o } = Kr(), [s, a] = $({}), [i, u] = $(null), [c, l] = $(!1), p = U(() => {
4714
4594
  l(!1), u(null);
4715
- }, []), m = z((v) => {
4716
- u(v), l(!0);
4717
- }, []), h = z(
4718
- async (v, f, w) => {
4719
- var k, E;
4595
+ }, []), m = U((k) => {
4596
+ u(k), l(!0);
4597
+ }, []), h = U(
4598
+ async (k, d, v) => {
4599
+ var I, A;
4720
4600
  if (!t) {
4721
- v.preventDefault();
4601
+ k.preventDefault();
4722
4602
  return;
4723
4603
  }
4724
- if (s[w]) {
4725
- v.preventDefault();
4604
+ if (s[v]) {
4605
+ k.preventDefault();
4726
4606
  return;
4727
4607
  }
4728
4608
  try {
4729
- const I = String(f.url ?? ""), N = I.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);
4609
+ const T = String(d.url ?? ""), N = T.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);
4730
4610
  if (N) {
4731
- v.preventDefault();
4732
- const P = N[1], x = f.name || `file_${P}`, S = f.mimeType || "application/octet-stream";
4733
- m({ id: P, name: x, mimeType: S });
4611
+ k.preventDefault();
4612
+ const b = N[1], y = d.name || `file_${b}`, x = d.mimeType || "application/octet-stream";
4613
+ m({ id: b, name: y, mimeType: x });
4734
4614
  return;
4735
4615
  }
4736
- if (I.startsWith("data:")) {
4737
- v.preventDefault(), a((x) => ({ ...x, [w]: !0 }));
4738
- const P = o({ title: "Fetching file...", description: "", open: !0 });
4616
+ if (T.startsWith("data:")) {
4617
+ k.preventDefault(), a((y) => ({ ...y, [v]: !0 }));
4618
+ const b = o({ title: "Fetching file...", description: "", open: !0 });
4739
4619
  try {
4740
- const x = await r.listFiles(n ?? void 0);
4741
- if (!x || !Array.isArray(x))
4620
+ const y = await r.listFiles(n ?? void 0);
4621
+ if (!y || !Array.isArray(y))
4742
4622
  throw new Error("Invalid file list response");
4743
- const S = x.find((g) => !g || typeof g != "object" || !((g.filename ?? "") === (f.name ?? "")) ? !1 : typeof f.size == "number" && typeof g.size == "number" ? g.size === f.size : !0);
4744
- if (!(S != null && S.id))
4745
- throw new Error(`File "${f.name}" is not yet available on the server`);
4746
- if (!S.id || !S.filename)
4623
+ const x = y.find((g) => !g || typeof g != "object" || !((g.filename ?? "") === (d.name ?? "")) ? !1 : typeof d.size == "number" && typeof g.size == "number" ? g.size === d.size : !0);
4624
+ if (!(x != null && x.id))
4625
+ throw new Error(`File "${d.name}" is not yet available on the server`);
4626
+ if (!x.id || !x.filename)
4747
4627
  throw new Error("Invalid file data received from server");
4748
4628
  m({
4749
- id: S.id,
4750
- name: f.name || S.filename || `file_${S.id}`,
4751
- mimeType: f.mimeType || S.mime_type || "application/octet-stream"
4752
- }), (k = P.update) == null || k.call(P, {
4753
- id: P.id,
4629
+ id: x.id,
4630
+ name: d.name || x.filename || `file_${x.id}`,
4631
+ mimeType: d.mimeType || x.mime_type || "application/octet-stream"
4632
+ }), (I = b.update) == null || I.call(b, {
4633
+ id: b.id,
4754
4634
  title: "Success",
4755
- description: `Opened ${f.name}`,
4635
+ description: `Opened ${d.name}`,
4756
4636
  open: !0
4757
4637
  });
4758
- } catch (x) {
4759
- console.error("Failed to fetch server file:", x);
4760
- const S = x instanceof Error ? x.message : "Unknown error occurred";
4761
- (E = P.update) == null || E.call(P, { id: P.id, title: "Failed", description: S }), o({
4638
+ } catch (y) {
4639
+ console.error("Failed to fetch server file:", y);
4640
+ const x = y instanceof Error ? y.message : "Unknown error occurred";
4641
+ (A = b.update) == null || A.call(b, { id: b.id, title: "Failed", description: x }), o({
4762
4642
  title: "Failed to fetch file",
4763
- description: S,
4643
+ description: x,
4764
4644
  open: !0
4765
4645
  });
4766
4646
  } finally {
4767
- a((x) => ({ ...x, [w]: !1 }));
4647
+ a((y) => ({ ...y, [v]: !1 }));
4768
4648
  }
4769
4649
  }
4770
- } catch (I) {
4771
- console.error("File click error:", I), a((N) => ({ ...N, [w]: !1 }));
4650
+ } catch (T) {
4651
+ console.error("File click error:", T), a((N) => ({ ...N, [v]: !1 }));
4772
4652
  }
4773
4653
  },
4774
4654
  [t, s, o, n, m]
@@ -4781,38 +4661,38 @@ function fo(e) {
4781
4661
  closeFileViewer: p
4782
4662
  };
4783
4663
  }
4784
- function po(e) {
4785
- return Q(() => {
4664
+ function lo(e) {
4665
+ return X(() => {
4786
4666
  const t = e;
4787
4667
  let n = Array.isArray(t.content) ? t.content : [];
4788
4668
  return typeof t.content == "string" && (n = [{ type: "text", text: t.content }]), {
4789
4669
  contentParts: n,
4790
- textContent: sr(n),
4791
- toolMeta: ar(t),
4670
+ textContent: or(n),
4671
+ toolMeta: sr(t),
4792
4672
  imageParts: n.filter((r) => r.type === "image_url"),
4793
4673
  fileParts: n.filter((r) => r.type === "file"),
4794
- toolRaw: $n(n),
4674
+ toolRaw: Fn(n),
4795
4675
  isToolStreaming: !!t.toolStreaming
4796
4676
  };
4797
4677
  }, [e]);
4798
4678
  }
4799
- const kt = "data:";
4800
- function qr(e) {
4679
+ const wt = "data:";
4680
+ function Gr(e) {
4801
4681
  if (!e) return [];
4802
4682
  const t = [], n = e.split(/\r?\n/);
4803
4683
  for (const r of n) {
4804
4684
  const o = r.trim();
4805
- if (!o || !o.startsWith(kt))
4685
+ if (!o || !o.startsWith(wt))
4806
4686
  continue;
4807
- const s = o.slice(kt.length).trim();
4687
+ const s = o.slice(wt.length).trim();
4808
4688
  if (!s || s.toLowerCase() === "[done]")
4809
4689
  continue;
4810
- const a = tt(s);
4690
+ const a = et(s);
4811
4691
  a && typeof a == "object" && t.push(a);
4812
4692
  }
4813
4693
  return t;
4814
4694
  }
4815
- function Jr(e) {
4695
+ function Hr(e) {
4816
4696
  for (let t = e.length - 1; t >= 0; t -= 1) {
4817
4697
  const n = e[t];
4818
4698
  if (n && typeof n == "object" && n.type === "tool.end")
@@ -4820,24 +4700,24 @@ function Jr(e) {
4820
4700
  }
4821
4701
  return null;
4822
4702
  }
4823
- function go(e) {
4824
- return Q(() => {
4703
+ function uo(e) {
4704
+ return X(() => {
4825
4705
  const t = e.content.filter(
4826
4706
  (u) => u.type === "text"
4827
4707
  );
4828
4708
  if (!t.length)
4829
4709
  return null;
4830
4710
  let r = t.flatMap(
4831
- (u) => qr(u.text ?? "")
4711
+ (u) => Gr(u.text ?? "")
4832
4712
  );
4833
4713
  if (!r.length) {
4834
4714
  const u = t.map((l) => l.text ?? "").join(`
4835
- `), c = tt(u);
4715
+ `), c = et(u);
4836
4716
  c && typeof c == "object" && (r = [c]);
4837
4717
  }
4838
4718
  if (!r.length)
4839
4719
  return null;
4840
- const s = Jr(r) ?? r[r.length - 1];
4720
+ const s = Hr(r) ?? r[r.length - 1];
4841
4721
  if (!s)
4842
4722
  return null;
4843
4723
  const a = s.output ?? s.payload ?? s, i = ce(a);
@@ -4853,21 +4733,21 @@ function go(e) {
4853
4733
  };
4854
4734
  }, [e]);
4855
4735
  }
4856
- function Xr(e) {
4857
- var F;
4858
- const t = typeof e == "string" ? e : e == null ? void 0 : e.threadId, n = typeof e == "object" ? e.lazy : !1, r = ot({ optional: !0 }), o = Gt({ optional: !0 }), s = Fr(), { currentThreadId: a, setCurrentThreadId: i, actions: u } = r || {
4736
+ function Wr(e) {
4737
+ var z;
4738
+ const t = typeof e == "string" ? e : e == null ? void 0 : e.threadId, n = typeof e == "object" ? e.lazy : !1, r = rt({ optional: !0 }), o = Dt({ optional: !0 }), s = Ur(), { currentThreadId: a, setCurrentThreadId: i, actions: u } = r || {
4859
4739
  currentThreadId: null,
4860
4740
  setCurrentThreadId: () => {
4861
4741
  },
4862
4742
  actions: {}
4863
- }, c = !!t && t !== a, [l, p] = D([]), m = z((U) => {
4864
- p(U);
4743
+ }, c = !!t && t !== a, [l, p] = $([]), m = U((j) => {
4744
+ p(j);
4865
4745
  }, []), {
4866
4746
  isLoadingThread: h,
4867
- threadStateError: v,
4868
- threadCheckpoints: f,
4869
- loadThread: w
4870
- } = Dt({
4747
+ threadStateError: k,
4748
+ threadCheckpoints: d,
4749
+ loadThread: v
4750
+ } = Bt({
4871
4751
  api: Ae().chatApi,
4872
4752
  fileApi: Ae().fileApi,
4873
4753
  seed: m,
@@ -4876,20 +4756,24 @@ function Xr(e) {
4876
4756
  isStreaming: !1,
4877
4757
  getMessages: () => l,
4878
4758
  autoLoadInitial: c && !n
4879
- }), k = Q(() => {
4880
- var U;
4881
- return ((U = f[0]) == null ? void 0 : U.values) || {};
4882
- }, [f]), E = Q(() => ({ timeline: [], messagePreviews: {} }), []), I = t || a, N = c ? h ? "loading" : "idle" : (o == null ? void 0 : o.status) || "idle", P = c ? l : (s == null ? void 0 : s.messages) || [], x = c ? h : (o == null ? void 0 : o.isLoading) || !1, S = c ? k : (o == null ? void 0 : o.values) || {}, g = c ? {} : (o == null ? void 0 : o.taskMessagesByScope) || {}, y = c ? v : (s == null ? void 0 : s.error) || (o == null ? void 0 : o.error) || null;
4759
+ });
4760
+ W(() => {
4761
+ !c && !n && a && (o != null && o.loadThread) && o.loadThread(a);
4762
+ }, [c, n, a, o == null ? void 0 : o.loadThread]);
4763
+ const I = X(() => {
4764
+ var j;
4765
+ return ((j = d[0]) == null ? void 0 : j.values) || {};
4766
+ }, [d]), A = X(() => ({ timeline: [], messagePreviews: {} }), []), T = t || a, N = c ? h ? "loading" : "idle" : (o == null ? void 0 : o.status) || "idle", b = c ? l : (s == null ? void 0 : s.messages) || [], y = c ? h : (o == null ? void 0 : o.isLoading) || !1, x = c ? I : (o == null ? void 0 : o.values) || {}, g = c ? {} : (o == null ? void 0 : o.taskMessagesByScope) || {}, w = c ? k : (s == null ? void 0 : s.error) || (o == null ? void 0 : o.error) || null;
4883
4767
  return {
4884
4768
  // UNIFIED: Single thread ID concept
4885
- threadId: I,
4769
+ threadId: T,
4886
4770
  status: N,
4887
- messages: P,
4888
- isLoading: x,
4889
- isHistoryLoading: x,
4890
- error: y,
4771
+ messages: b,
4772
+ isLoading: y,
4773
+ isHistoryLoading: y,
4774
+ error: w,
4891
4775
  // Values & Metadata
4892
- values: S,
4776
+ values: x,
4893
4777
  taskMessagesByScope: g,
4894
4778
  metadata: c ? {} : o == null ? void 0 : o.metadata,
4895
4779
  // Actions & State relating to Global/Active Thread only
@@ -4899,9 +4783,9 @@ function Xr(e) {
4899
4783
  returnToLatest: c ? async () => {
4900
4784
  } : (o == null ? void 0 : o.returnToLatest) || (async () => {
4901
4785
  }),
4902
- checkpoint: c ? f[0] ? { id: f[0].checkpointId, namespace: f[0].checkpointNs } : null : (o == null ? void 0 : o.checkpoint) || null,
4903
- checkpoints: c ? f : (o == null ? void 0 : o.checkpoints) || [],
4904
- checkpointIndex: c ? E : (o == null ? void 0 : o.checkpointIndex) || { timeline: [], messagePreviews: {} },
4786
+ checkpoint: c ? d[0] ? { id: d[0].checkpointId, namespace: d[0].checkpointNs } : null : (o == null ? void 0 : o.checkpoint) || null,
4787
+ checkpoints: c ? d : (o == null ? void 0 : o.checkpoints) || [],
4788
+ checkpointIndex: c ? A : (o == null ? void 0 : o.checkpointIndex) || { timeline: [], messagePreviews: {} },
4905
4789
  interrupt: c ? null : (o == null ? void 0 : o.interrupt) || null,
4906
4790
  respondToInterrupt: c ? async () => {
4907
4791
  } : (o == null ? void 0 : o.respondToInterrupt) || (async () => {
@@ -4911,7 +4795,7 @@ function Xr(e) {
4911
4795
  isStreaming: (s == null ? void 0 : s.isStreaming) || !1,
4912
4796
  activeMessageId: (s == null ? void 0 : s.activeMessageId) || null,
4913
4797
  connectionState: (s == null ? void 0 : s.connectionState) || "disconnected",
4914
- streamingAssistantId: !c && (s != null && s.isStreaming) && ((F = o == null ? void 0 : o.metadata) != null && F.assemblingMessageId) ? o.metadata.assemblingMessageId : null,
4798
+ streamingAssistantId: !c && (s != null && s.isStreaming) && ((z = o == null ? void 0 : o.metadata) != null && z.assemblingMessageId) ? o.metadata.assemblingMessageId : null,
4915
4799
  // Actions
4916
4800
  submit: (s == null ? void 0 : s.submit) || (async () => {
4917
4801
  }),
@@ -4922,19 +4806,18 @@ function Xr(e) {
4922
4806
  }),
4923
4807
  setCurrentThreadId: i,
4924
4808
  loadHistory: c ? async () => {
4925
- t && await w(t);
4809
+ t && await v(t);
4926
4810
  } : async () => {
4927
4811
  },
4928
4812
  // Thread Management
4929
4813
  createThread: u == null ? void 0 : u.createThread,
4930
4814
  deleteThread: u == null ? void 0 : u.deleteThread,
4931
4815
  renameThread: u == null ? void 0 : u.renameThread,
4932
- shareThread: u == null ? void 0 : u.shareThread,
4933
4816
  threads: (r == null ? void 0 : r.threads) || [],
4934
4817
  isThreadsLoading: (r == null ? void 0 : r.isLoading) || !1
4935
4818
  };
4936
4819
  }
4937
- function mo({
4820
+ function fo({
4938
4821
  submit: e,
4939
4822
  chatRequest: t,
4940
4823
  lastCheckpointId: n,
@@ -4950,82 +4833,82 @@ function mo({
4950
4833
  threadId: m,
4951
4834
  clearComposerOnSend: h = !0
4952
4835
  }) {
4953
- const { messages: v } = Xr(), [f, w] = D(null), [k, E] = D(""), [I, N] = D(null), [P, x] = D(null), [S, g] = D(!1), [y, F] = D(""), U = H(y), C = H(null);
4954
- q(() => {
4955
- if (!f)
4836
+ const { messages: k } = Wr(), [d, v] = $(null), [I, A] = $(""), [T, N] = $(null), [b, y] = $(null), [x, g] = $(!1), [w, z] = $(""), j = K(w), S = K(null);
4837
+ W(() => {
4838
+ if (!d)
4956
4839
  if (m) {
4957
- const d = localStorage.getItem(qe(m));
4958
- F(d || "");
4840
+ const f = localStorage.getItem(He(m));
4841
+ z(f || "");
4959
4842
  } else
4960
- F("");
4961
- }, [m, f]);
4962
- const M = z((d) => {
4963
- F(d), !f && m && localStorage.setItem(qe(m), d);
4964
- }, [m, f]);
4965
- q(() => {
4966
- U.current = y;
4967
- }, [y]), q(() => {
4968
- if (!f) {
4969
- C.current = null;
4843
+ z("");
4844
+ }, [m, d]);
4845
+ const C = U((f) => {
4846
+ z(f), !d && m && localStorage.setItem(He(m), f);
4847
+ }, [m, d]);
4848
+ W(() => {
4849
+ j.current = w;
4850
+ }, [w]), W(() => {
4851
+ if (!d) {
4852
+ S.current = null;
4970
4853
  return;
4971
4854
  }
4972
- C.current === null && (C.current = U.current), M(k ?? "");
4973
- }, [k, f, M]);
4974
- const L = z(
4975
- (d) => {
4976
- M(d);
4855
+ S.current === null && (S.current = j.current), C(I ?? "");
4856
+ }, [I, d, C]);
4857
+ const L = U(
4858
+ (f) => {
4859
+ C(f);
4977
4860
  },
4978
- [M]
4979
- ), R = async (d, A) => {
4980
- const _ = Array.isArray(A) ? { files: A } : A ?? {}, te = _.files ?? [], J = _.contentParts ?? [], G = d.trim();
4981
- if (!(!G && te.length === 0 && J.length === 0))
4861
+ [C]
4862
+ ), _ = async (f, P) => {
4863
+ const M = Array.isArray(P) ? { files: P } : P ?? {}, te = M.files ?? [], q = M.contentParts ?? [], V = f.trim();
4864
+ if (!(!V && te.length === 0 && q.length === 0))
4982
4865
  try {
4983
- const Z = te.map(async (X) => {
4866
+ const Z = te.map(async (J) => {
4984
4867
  try {
4985
- const Y = await Ut.uploadFile(X);
4986
- return { file: X, record: Y };
4868
+ const Y = await zt.uploadFile(J);
4869
+ return { file: J, record: Y };
4987
4870
  } catch (Y) {
4988
- throw console.error("Failed to upload file", X.name, Y), new Error(`Failed to upload ${X.name}`);
4871
+ throw console.error("Failed to upload file", J.name, Y), new Error(`Failed to upload ${J.name}`);
4989
4872
  }
4990
- }), ue = (await Promise.all(Z)).map(({ record: X }) => {
4991
- const Y = X.mime_type;
4873
+ }), ue = (await Promise.all(Z)).map(({ record: J }) => {
4874
+ const Y = J.mime_type;
4992
4875
  return Y.startsWith("image/") ? {
4993
4876
  type: "image_url",
4994
- image_url: { url: X.content_url }
4877
+ image_url: { url: J.content_url }
4995
4878
  } : {
4996
4879
  type: "file",
4997
- url: X.content_url,
4880
+ url: J.content_url,
4998
4881
  mimeType: Y,
4999
- name: X.filename,
5000
- size: X.size
4882
+ name: J.filename,
4883
+ size: J.size
5001
4884
  };
5002
- }), W = [...J, ...ue], ee = f ? (I == null ? void 0 : I.checkpointId) ?? n ?? void 0 : n ?? void 0, ve = f ? (I == null ? void 0 : I.checkpointNs) ?? r ?? void 0 : r ?? void 0;
4885
+ }), H = [...q, ...ue], ee = d ? (T == null ? void 0 : T.checkpointId) ?? n ?? void 0 : n ?? void 0, ve = d ? (T == null ? void 0 : T.checkpointNs) ?? r ?? void 0 : r ?? void 0;
5003
4886
  await e(
5004
4887
  {
5005
- text: G || "",
5006
- contentParts: W,
4888
+ text: V || "",
4889
+ contentParts: H,
5007
4890
  attachments: te,
5008
4891
  payload: t.payload,
5009
- edit: !!f,
4892
+ edit: !!d,
5010
4893
  checkpointId: ee,
5011
4894
  checkpointNs: ve,
5012
4895
  project: l ?? void 0,
5013
- originalMessageId: f ?? void 0,
4896
+ originalMessageId: d ?? void 0,
5014
4897
  config: t.config
5015
4898
  },
5016
4899
  p ? { onEvent: p } : void 0
5017
- ), o == null || o(G), c(!0), h && (m && localStorage.removeItem(qe(m)), M("")), x(null), w(null), E(""), N(null);
4900
+ ), o == null || o(V), c(!0), h && (m && localStorage.removeItem(He(m)), C("")), y(null), v(null), A(""), N(null);
5018
4901
  } catch (Z) {
5019
- const ae = (Z == null ? void 0 : Z.message) || "Failed to send message";
5020
- x(ae), a == null || a(ae), c(!1);
4902
+ const oe = (Z == null ? void 0 : Z.message) || "Failed to send message";
4903
+ y(oe), a == null || a(oe), c(!1);
5021
4904
  }
5022
- }, V = (d, A) => {
5023
- A || R(d, { files: [] });
5024
- }, B = z(
5025
- async (d) => {
4905
+ }, O = (f, P) => {
4906
+ P || _(f, { files: [] });
4907
+ }, F = U(
4908
+ async (f) => {
5026
4909
  await e(
5027
4910
  {
5028
- attachments: [d],
4911
+ attachments: [f],
5029
4912
  payload: t.payload,
5030
4913
  checkpointId: n ?? void 0,
5031
4914
  checkpointNs: r ?? void 0,
@@ -5033,73 +4916,73 @@ function mo({
5033
4916
  config: t.config
5034
4917
  },
5035
4918
  p ? { onEvent: p } : void 0
5036
- ), s == null || s({ file: d });
4919
+ ), s == null || s({ file: f });
5037
4920
  },
5038
4921
  [n, r, t, s, e]
5039
- ), b = z(
5040
- (d, A, _) => {
5041
- i && (C.current = y, w(d), E(A), N({
5042
- checkpointId: (_ == null ? void 0 : _.checkpointId) ?? null,
5043
- checkpointNs: (_ == null ? void 0 : _.checkpointNs) ?? null
5044
- }), x(null));
4922
+ ), G = U(
4923
+ (f, P, M) => {
4924
+ i && (S.current = w, v(f), A(P), N({
4925
+ checkpointId: (M == null ? void 0 : M.checkpointId) ?? null,
4926
+ checkpointNs: (M == null ? void 0 : M.checkpointNs) ?? null
4927
+ }), y(null));
5045
4928
  },
5046
- [y, i]
5047
- ), T = z(() => {
5048
- w(null), E(""), N(null), x(null);
5049
- const d = C.current;
5050
- d !== null && F(d), C.current = null;
5051
- }, []), $ = z((d) => {
5052
- let A = null;
5053
- for (let G = d - 1; G >= 0; G--)
5054
- if (u[G].role === "user") {
5055
- A = u[G];
4929
+ [w, i]
4930
+ ), E = U(() => {
4931
+ v(null), A(""), N(null), y(null);
4932
+ const f = S.current;
4933
+ f !== null && z(f), S.current = null;
4934
+ }, []), D = U((f) => {
4935
+ let P = null;
4936
+ for (let V = f - 1; V >= 0; V--)
4937
+ if (u[V].role === "user") {
4938
+ P = u[V];
5056
4939
  break;
5057
4940
  }
5058
- if (!A) return;
5059
- const _ = Array.isArray(A.content) ? A.content : [], J = _.filter((G) => (G == null ? void 0 : G.type) === "text").map((G) => G.text).join("") || (() => {
4941
+ if (!P) return;
4942
+ const M = Array.isArray(P.content) ? P.content : [], q = M.filter((V) => (V == null ? void 0 : V.type) === "text").map((V) => V.text).join("") || (() => {
5060
4943
  try {
5061
- return JSON.stringify(_, null, 2);
4944
+ return JSON.stringify(M, null, 2);
5062
4945
  } catch {
5063
- return String(_);
4946
+ return String(M);
5064
4947
  }
5065
4948
  })();
5066
- J && e(
4949
+ q && e(
5067
4950
  {
5068
- text: J,
4951
+ text: q,
5069
4952
  payload: t.payload,
5070
4953
  checkpointId: n ?? void 0,
5071
4954
  checkpointNs: r ?? void 0,
5072
4955
  edit: !0,
5073
- originalMessageId: A.id,
4956
+ originalMessageId: P.id,
5074
4957
  config: t.config
5075
4958
  },
5076
4959
  p ? { onEvent: p } : void 0
5077
4960
  );
5078
4961
  }, [u, e, n, r, t]);
5079
4962
  return {
5080
- editingMessageId: f,
5081
- editingInitialValue: k,
5082
- inputError: P,
5083
- setInputError: x,
5084
- dismissError: S,
4963
+ editingMessageId: d,
4964
+ editingInitialValue: I,
4965
+ inputError: b,
4966
+ setInputError: y,
4967
+ dismissError: x,
5085
4968
  setDismissError: g,
5086
- composerValue: y,
4969
+ composerValue: w,
5087
4970
  handleComposerChange: L,
5088
- handleSendMessage: R,
5089
- handleQuickPrompt: V,
5090
- handleExcelUpload: B,
5091
- startEditing: b,
5092
- cancelEditing: T,
5093
- handleRegenerateCb: $,
5094
- displayMessages: v
4971
+ handleSendMessage: _,
4972
+ handleQuickPrompt: O,
4973
+ handleExcelUpload: F,
4974
+ startEditing: G,
4975
+ cancelEditing: E,
4976
+ handleRegenerateCb: D,
4977
+ displayMessages: k
5095
4978
  };
5096
4979
  }
5097
- function ho(e) {
5098
- return Q(() => e ? {
5099
- textContent: Ln(e),
5100
- imageParts: jn(e),
5101
- fileParts: Fn(e),
5102
- toolCalls: Mt(e),
4980
+ function po(e) {
4981
+ return X(() => e ? {
4982
+ textContent: Rn(e),
4983
+ imageParts: Un(e),
4984
+ fileParts: jn(e),
4985
+ toolCalls: St(e),
5103
4986
  contentParts: e.content
5104
4987
  } : {
5105
4988
  textContent: "",
@@ -5109,9 +4992,9 @@ function ho(e) {
5109
4992
  contentParts: []
5110
4993
  }, [e]);
5111
4994
  }
5112
- function yo(e, t, n) {
5113
- const [r, o] = D(e), s = H(e), a = H(null);
5114
- return q(() => {
4995
+ function go(e, t, n) {
4996
+ const [r, o] = $(e), s = K(e), a = K(null);
4997
+ return W(() => {
5115
4998
  s.current = e;
5116
4999
  const i = () => {
5117
5000
  o(s.current), a.current && (clearTimeout(a.current), a.current = null);
@@ -5128,46 +5011,46 @@ function yo(e, t, n) {
5128
5011
  }, [e, t, n]), r;
5129
5012
  }
5130
5013
  export {
5131
- uo as ChatProviders,
5132
- zr as ThreadStateProvider,
5133
- pr as ThreadsProvider,
5134
- to as cn,
5135
- sr as collectText,
5136
- lo as createTaskSyncToolEndHandler,
5137
- Br as extractTaskIdFromToolEnd,
5138
- ar as extractToolMeta,
5139
- no as formatToolOutput,
5140
- ao as getAgentNameFromMessage,
5141
- _t as getChatToken,
5142
- co as getMessageAttemptInfo,
5143
- oo as getToolCallArtifacts,
5144
- Hn as getToolCalls,
5145
- ro as hasContent,
5146
- ht as hydrateHistorySnapshots,
5147
- Et as isFileLike,
5148
- Rn as looksLikeMarkdown,
5149
- io as messageSignature,
5150
- so as normalizeInterruptId,
5151
- Nt as onChatTokenChanged,
5152
- tt as parseJsonSafe,
5153
- Pt as pretty,
5154
- Ar as refreshHistoryFileUrls,
5155
- Ke as sanitizeForDisplay,
5014
+ io as ChatProviders,
5015
+ Nr as ThreadStateProvider,
5016
+ ur as ThreadsProvider,
5017
+ Yr as cn,
5018
+ or as collectText,
5019
+ ao as createTaskSyncToolEndHandler,
5020
+ Fr as extractTaskIdFromToolEnd,
5021
+ sr as extractToolMeta,
5022
+ Zr as formatToolOutput,
5023
+ ro as getAgentNameFromMessage,
5024
+ Et as getChatToken,
5025
+ so as getMessageAttemptInfo,
5026
+ to as getToolCallArtifacts,
5027
+ Kn as getToolCalls,
5028
+ eo as hasContent,
5029
+ gt as hydrateHistorySnapshots,
5030
+ Ct as isFileLike,
5031
+ Nn as looksLikeMarkdown,
5032
+ oo as messageSignature,
5033
+ no as normalizeInterruptId,
5034
+ Pt as onChatTokenChanged,
5035
+ et as parseJsonSafe,
5036
+ Mt as pretty,
5037
+ Ir as refreshHistoryFileUrls,
5038
+ Ve as sanitizeForDisplay,
5156
5039
  ke as setChatToken,
5157
- $n as stringifyTool,
5040
+ Fn as stringifyTool,
5158
5041
  Ae as useApi,
5159
- mo as useChatController,
5160
- Xr as useChatSession,
5161
- fo as useFilePreview,
5162
- ho as useMessageContent,
5163
- po as useParsedMessageContent,
5164
- lr as useStream,
5165
- yo as useStreamingMarkdownBuffer,
5166
- Dt as useThreadHistoryState,
5167
- Gt as useThreadState,
5168
- Rr as useThreadStateUpdater,
5169
- ot as useThreads,
5170
- fr as useThreadsState,
5171
- go as useToolPayload
5042
+ fo as useChatController,
5043
+ Wr as useChatSession,
5044
+ co as useFilePreview,
5045
+ po as useMessageContent,
5046
+ lo as useParsedMessageContent,
5047
+ cr as useStream,
5048
+ go as useStreamingMarkdownBuffer,
5049
+ Bt as useThreadHistoryState,
5050
+ Dt as useThreadState,
5051
+ Pr as useThreadStateUpdater,
5052
+ rt as useThreads,
5053
+ lr as useThreadsState,
5054
+ uo as useToolPayload
5172
5055
  };
5173
5056
  //# sourceMappingURL=index.esm.js.map