@teodorruskvi/chat-core 0.1.51 → 0.1.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -3,19 +3,19 @@ var Gt = (e, t, n) => t in e ? Ht(e, t, { enumerable: !0, configurable: !0, writ
3
3
  var at = (e, t, n) => Gt(e, typeof t != "symbol" ? t + "" : t, n);
4
4
  import { jsx as ie } from "react/jsx-runtime";
5
5
  import * as it from "react";
6
- import { createContext as Ce, useContext as Ue, useState as $, useRef as W, useEffect as X, useCallback as _, useMemo as Y, useReducer as Wt } from "react";
6
+ import { createContext as Ce, useContext as je, useState as $, useRef as G, useEffect as X, useCallback as _, useMemo as Y, useReducer as Wt } from "react";
7
7
  import Jt, { isCancel as Xt } from "axios";
8
8
  function It(e) {
9
9
  var t, n, r = "";
10
10
  if (typeof e == "string" || typeof e == "number") r += e;
11
11
  else if (typeof e == "object") if (Array.isArray(e)) {
12
- var s = e.length;
13
- for (t = 0; t < s; t++) e[t] && (n = It(e[t])) && (r && (r += " "), r += n);
12
+ var o = e.length;
13
+ for (t = 0; t < o; t++) e[t] && (n = It(e[t])) && (r && (r += " "), r += n);
14
14
  } else for (n in e) e[n] && (r && (r += " "), r += n);
15
15
  return r;
16
16
  }
17
17
  function Qt() {
18
- for (var e, t, n = 0, r = "", s = arguments.length; n < s; n++) (e = arguments[n]) && (t = It(e)) && (r && (r += " "), r += t);
18
+ for (var e, t, n = 0, r = "", o = arguments.length; n < o; n++) (e = arguments[n]) && (t = It(e)) && (r && (r += " "), r += t);
19
19
  return r;
20
20
  }
21
21
  const et = "-", Yt = (e) => {
@@ -29,23 +29,23 @@ const et = "-", Yt = (e) => {
29
29
  return i[0] === "" && i.length !== 1 && i.shift(), vt(i, t) || Zt(a);
30
30
  },
31
31
  getConflictingClassGroupIds: (a, i) => {
32
- const u = n[a] || [];
33
- return i && r[a] ? [...u, ...r[a]] : u;
32
+ const d = n[a] || [];
33
+ return i && r[a] ? [...d, ...r[a]] : d;
34
34
  }
35
35
  };
36
36
  }, vt = (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), s = r ? vt(e.slice(1), r) : void 0;
41
- if (s)
42
- return s;
40
+ const n = e[0], r = t.nextPart.get(n), o = r ? vt(e.slice(1), r) : void 0;
41
+ if (o)
42
+ return o;
43
43
  if (t.validators.length === 0)
44
44
  return;
45
- const o = e.join(et);
45
+ const s = e.join(et);
46
46
  return (a = t.validators.find(({
47
47
  validator: i
48
- }) => i(o))) == null ? void 0 : a.classGroupId;
48
+ }) => i(s))) == null ? void 0 : a.classGroupId;
49
49
  }, ct = /^\[(.+)\]$/, Zt = (e) => {
50
50
  if (ct.test(e)) {
51
51
  const t = ct.exec(e)[1], n = t == null ? void 0 : t.substring(0, t.indexOf(":"));
@@ -60,29 +60,29 @@ const et = "-", Yt = (e) => {
60
60
  nextPart: /* @__PURE__ */ new Map(),
61
61
  validators: []
62
62
  };
63
- return nn(Object.entries(e.classGroups), n).forEach(([o, a]) => {
64
- Xe(a, r, o, t);
63
+ return nn(Object.entries(e.classGroups), n).forEach(([s, a]) => {
64
+ Xe(a, r, s, t);
65
65
  }), r;
66
66
  }, Xe = (e, t, n, r) => {
67
- e.forEach((s) => {
68
- if (typeof s == "string") {
69
- const o = s === "" ? t : lt(t, s);
70
- o.classGroupId = n;
67
+ e.forEach((o) => {
68
+ if (typeof o == "string") {
69
+ const s = o === "" ? t : lt(t, o);
70
+ s.classGroupId = n;
71
71
  return;
72
72
  }
73
- if (typeof s == "function") {
74
- if (tn(s)) {
75
- Xe(s(r), t, n, r);
73
+ if (typeof o == "function") {
74
+ if (tn(o)) {
75
+ Xe(o(r), t, n, r);
76
76
  return;
77
77
  }
78
78
  t.validators.push({
79
- validator: s,
79
+ validator: o,
80
80
  classGroupId: n
81
81
  });
82
82
  return;
83
83
  }
84
- Object.entries(s).forEach(([o, a]) => {
85
- Xe(a, lt(t, o), n, r);
84
+ Object.entries(o).forEach(([s, a]) => {
85
+ Xe(a, lt(t, s), n, r);
86
86
  });
87
87
  });
88
88
  }, lt = (e, t) => {
@@ -94,8 +94,8 @@ const et = "-", Yt = (e) => {
94
94
  }), n = n.nextPart.get(r);
95
95
  }), n;
96
96
  }, tn = (e) => e.isThemeGetter, nn = (e, t) => t ? e.map(([n, r]) => {
97
- const s = r.map((o) => typeof o == "string" ? t + o : typeof o == "object" ? Object.fromEntries(Object.entries(o).map(([a, i]) => [t + a, i])) : o);
98
- return [n, s];
97
+ const o = r.map((s) => typeof s == "string" ? t + s : typeof s == "object" ? Object.fromEntries(Object.entries(s).map(([a, i]) => [t + a, i])) : s);
98
+ return [n, o];
99
99
  }) : e, rn = (e) => {
100
100
  if (e < 1)
101
101
  return {
@@ -105,55 +105,55 @@ const et = "-", Yt = (e) => {
105
105
  }
106
106
  };
107
107
  let t = 0, n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
108
- const s = (o, a) => {
109
- n.set(o, a), t++, t > e && (t = 0, r = n, n = /* @__PURE__ */ new Map());
108
+ const o = (s, a) => {
109
+ n.set(s, a), t++, t > e && (t = 0, r = n, n = /* @__PURE__ */ new Map());
110
110
  };
111
111
  return {
112
- get(o) {
113
- let a = n.get(o);
112
+ get(s) {
113
+ let a = n.get(s);
114
114
  if (a !== void 0)
115
115
  return a;
116
- if ((a = r.get(o)) !== void 0)
117
- return s(o, a), a;
116
+ if ((a = r.get(s)) !== void 0)
117
+ return o(s, a), a;
118
118
  },
119
- set(o, a) {
120
- n.has(o) ? n.set(o, a) : s(o, a);
119
+ set(s, a) {
120
+ n.has(s) ? n.set(s, a) : o(s, a);
121
121
  }
122
122
  };
123
- }, xt = "!", sn = (e) => {
123
+ }, xt = "!", on = (e) => {
124
124
  const {
125
125
  separator: t,
126
126
  experimentalParseClassName: n
127
- } = e, r = t.length === 1, s = t[0], o = t.length, a = (i) => {
128
- const u = [];
129
- let c = 0, l = 0, d;
127
+ } = e, r = t.length === 1, o = t[0], s = t.length, a = (i) => {
128
+ const d = [];
129
+ let c = 0, l = 0, f;
130
130
  for (let v = 0; v < i.length; v++) {
131
131
  let x = i[v];
132
132
  if (c === 0) {
133
- if (x === s && (r || i.slice(v, v + o) === t)) {
134
- u.push(i.slice(l, v)), l = v + o;
133
+ if (x === o && (r || i.slice(v, v + s) === t)) {
134
+ d.push(i.slice(l, v)), l = v + s;
135
135
  continue;
136
136
  }
137
137
  if (x === "/") {
138
- d = v;
138
+ f = v;
139
139
  continue;
140
140
  }
141
141
  }
142
142
  x === "[" ? c++ : x === "]" && c--;
143
143
  }
144
- const g = u.length === 0 ? i : i.substring(l), m = g.startsWith(xt), I = m ? g.substring(1) : g, f = d && d > l ? d - l : void 0;
144
+ const p = d.length === 0 ? i : i.substring(l), g = p.startsWith(xt), I = g ? p.substring(1) : p, u = f && f > l ? f - l : void 0;
145
145
  return {
146
- modifiers: u,
147
- hasImportantModifier: m,
146
+ modifiers: d,
147
+ hasImportantModifier: g,
148
148
  baseClassName: I,
149
- maybePostfixModifierPosition: f
149
+ maybePostfixModifierPosition: u
150
150
  };
151
151
  };
152
152
  return n ? (i) => n({
153
153
  className: i,
154
154
  parseClassName: a
155
155
  }) : a;
156
- }, on = (e) => {
156
+ }, sn = (e) => {
157
157
  if (e.length <= 1)
158
158
  return e;
159
159
  const t = [];
@@ -163,48 +163,48 @@ const et = "-", Yt = (e) => {
163
163
  }), t.push(...n.sort()), t;
164
164
  }, an = (e) => ({
165
165
  cache: rn(e.cacheSize),
166
- parseClassName: sn(e),
166
+ parseClassName: on(e),
167
167
  ...Yt(e)
168
168
  }), cn = /\s+/, ln = (e, t) => {
169
169
  const {
170
170
  parseClassName: n,
171
171
  getClassGroupId: r,
172
- getConflictingClassGroupIds: s
173
- } = t, o = [], a = e.trim().split(cn);
172
+ getConflictingClassGroupIds: o
173
+ } = t, s = [], a = e.trim().split(cn);
174
174
  let i = "";
175
- for (let u = a.length - 1; u >= 0; u -= 1) {
176
- const c = a[u], {
175
+ for (let d = a.length - 1; d >= 0; d -= 1) {
176
+ const c = a[d], {
177
177
  modifiers: l,
178
- hasImportantModifier: d,
179
- baseClassName: g,
180
- maybePostfixModifierPosition: m
178
+ hasImportantModifier: f,
179
+ baseClassName: p,
180
+ maybePostfixModifierPosition: g
181
181
  } = n(c);
182
- let I = !!m, f = r(I ? g.substring(0, m) : g);
183
- if (!f) {
182
+ let I = !!g, u = r(I ? p.substring(0, g) : p);
183
+ if (!u) {
184
184
  if (!I) {
185
185
  i = c + (i.length > 0 ? " " + i : i);
186
186
  continue;
187
187
  }
188
- if (f = r(g), !f) {
188
+ if (u = r(p), !u) {
189
189
  i = c + (i.length > 0 ? " " + i : i);
190
190
  continue;
191
191
  }
192
192
  I = !1;
193
193
  }
194
- const v = on(l).join(":"), x = d ? v + xt : v, M = x + f;
195
- if (o.includes(M))
194
+ const v = sn(l).join(":"), x = f ? v + xt : v, M = x + u;
195
+ if (s.includes(M))
196
196
  continue;
197
- o.push(M);
198
- const A = s(f, I);
199
- for (let k = 0; k < A.length; ++k) {
200
- const b = A[k];
201
- o.push(x + b);
197
+ s.push(M);
198
+ const A = o(u, I);
199
+ for (let w = 0; w < A.length; ++w) {
200
+ const b = A[w];
201
+ s.push(x + b);
202
202
  }
203
203
  i = c + (i.length > 0 ? " " + i : i);
204
204
  }
205
205
  return i;
206
206
  };
207
- function un() {
207
+ function dn() {
208
208
  let e = 0, t, n, r = "";
209
209
  for (; e < arguments.length; )
210
210
  (t = arguments[e++]) && (n = At(t)) && (r && (r += " "), r += n);
@@ -218,27 +218,27 @@ const At = (e) => {
218
218
  e[r] && (t = At(e[r])) && (n && (n += " "), n += t);
219
219
  return n;
220
220
  };
221
- function dn(e, ...t) {
222
- let n, r, s, o = a;
223
- function a(u) {
224
- const c = t.reduce((l, d) => d(l), e());
225
- return n = an(c), r = n.cache.get, s = n.cache.set, o = i, i(u);
221
+ function un(e, ...t) {
222
+ let n, r, o, s = a;
223
+ function a(d) {
224
+ const c = t.reduce((l, f) => f(l), e());
225
+ return n = an(c), r = n.cache.get, o = n.cache.set, s = i, i(d);
226
226
  }
227
- function i(u) {
228
- const c = r(u);
227
+ function i(d) {
228
+ const c = r(d);
229
229
  if (c)
230
230
  return c;
231
- const l = ln(u, n);
232
- return s(u, l), l;
231
+ const l = ln(d, n);
232
+ return o(d, l), l;
233
233
  }
234
234
  return function() {
235
- return o(un.apply(null, arguments));
235
+ return s(dn.apply(null, arguments));
236
236
  };
237
237
  }
238
238
  const D = (e) => {
239
239
  const t = (n) => n[e] || [];
240
240
  return t.isThemeGetter = !0, t;
241
- }, Tt = /^\[(?:([a-z-]+):)?(.+)\]$/i, fn = /^\d+\/\d+$/, pn = /* @__PURE__ */ new Set(["px", "full", "screen"]), gn = /^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/, mn = /\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))\(.+\)$/, hn = /^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/, bn = /^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/, de = (e) => Te(e) || pn.has(e) || fn.test(e), be = (e) => Ee(e, "length", Sn), Te = (e) => !!e && !Number.isNaN(Number(e)), qe = (e) => Ee(e, "number", Te), _e = (e) => !!e && Number.isInteger(Number(e)), wn = (e) => e.endsWith("%") && Te(e.slice(0, -1)), R = (e) => Tt.test(e), we = (e) => gn.test(e), kn = /* @__PURE__ */ new Set(["length", "size", "percentage"]), In = (e) => Ee(e, kn, St), vn = (e) => Ee(e, "position", St), xn = /* @__PURE__ */ new Set(["image", "url"]), An = (e) => Ee(e, xn, Cn), Tn = (e) => Ee(e, "", Mn), ze = () => !0, Ee = (e, t, n) => {
241
+ }, Tt = /^\[(?:([a-z-]+):)?(.+)\]$/i, fn = /^\d+\/\d+$/, pn = /* @__PURE__ */ new Set(["px", "full", "screen"]), gn = /^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/, mn = /\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))\(.+\)$/, hn = /^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/, bn = /^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/, ue = (e) => Te(e) || pn.has(e) || fn.test(e), be = (e) => Ee(e, "length", Sn), Te = (e) => !!e && !Number.isNaN(Number(e)), qe = (e) => Ee(e, "number", Te), _e = (e) => !!e && Number.isInteger(Number(e)), wn = (e) => e.endsWith("%") && Te(e.slice(0, -1)), N = (e) => Tt.test(e), we = (e) => gn.test(e), kn = /* @__PURE__ */ new Set(["length", "size", "percentage"]), In = (e) => Ee(e, kn, St), vn = (e) => Ee(e, "position", St), xn = /* @__PURE__ */ new Set(["image", "url"]), An = (e) => Ee(e, xn, Cn), Tn = (e) => Ee(e, "", Mn), Ne = () => !0, Ee = (e, t, n) => {
242
242
  const r = Tt.exec(e);
243
243
  return r ? r[1] ? typeof t == "string" ? r[1] === t : t.has(r[1]) : n(r[2]) : !1;
244
244
  }, Sn = (e) => (
@@ -247,34 +247,34 @@ const D = (e) => {
247
247
  // I could also use lookbehind assertion in `lengthUnitRegex` but that isn't supported widely enough.
248
248
  mn.test(e) && !yn.test(e)
249
249
  ), St = () => !1, Mn = (e) => hn.test(e), Cn = (e) => bn.test(e), En = () => {
250
- const e = D("colors"), t = D("spacing"), n = D("blur"), r = D("brightness"), s = D("borderColor"), o = D("borderRadius"), a = D("borderSpacing"), i = D("borderWidth"), u = D("contrast"), c = D("grayscale"), l = D("hueRotate"), d = D("invert"), g = D("gap"), m = D("gradientColorStops"), I = D("gradientColorStopPositions"), f = D("inset"), v = D("margin"), x = D("opacity"), M = D("padding"), A = D("saturate"), k = D("scale"), b = D("sepia"), h = D("skew"), T = D("space"), p = D("translate"), w = () => ["auto", "contain", "none"], P = () => ["auto", "hidden", "clip", "visible", "scroll"], j = () => ["auto", R, t], C = () => [R, t], O = () => ["", de, be], F = () => ["auto", Te, R], E = () => ["bottom", "center", "left", "left-bottom", "left-top", "right", "right-bottom", "right-top", "top"], B = () => ["solid", "dashed", "dotted", "double", "none"], z = () => ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"], K = () => ["start", "end", "center", "between", "around", "evenly", "stretch"], N = () => ["", "0", R], L = () => ["auto", "avoid", "all", "avoid-page", "page", "left", "right", "column"], H = () => [Te, R];
250
+ const e = D("colors"), t = D("spacing"), n = D("blur"), r = D("brightness"), o = D("borderColor"), s = D("borderRadius"), a = D("borderSpacing"), i = D("borderWidth"), d = D("contrast"), c = D("grayscale"), l = D("hueRotate"), f = D("invert"), p = D("gap"), g = D("gradientColorStops"), I = D("gradientColorStopPositions"), u = D("inset"), v = D("margin"), x = D("opacity"), M = D("padding"), A = D("saturate"), w = D("scale"), b = D("sepia"), h = D("skew"), T = D("space"), m = D("translate"), k = () => ["auto", "contain", "none"], E = () => ["auto", "hidden", "clip", "visible", "scroll"], j = () => ["auto", N, t], C = () => [N, t], O = () => ["", ue, be], F = () => ["auto", Te, N], P = () => ["bottom", "center", "left", "left-bottom", "left-top", "right", "right-bottom", "right-top", "top"], B = () => ["solid", "dashed", "dotted", "double", "none"], z = () => ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"], J = () => ["start", "end", "center", "between", "around", "evenly", "stretch"], U = () => ["", "0", N], R = () => ["auto", "avoid", "all", "avoid-page", "page", "left", "right", "column"], q = () => [Te, N];
251
251
  return {
252
252
  cacheSize: 500,
253
253
  separator: ":",
254
254
  theme: {
255
- colors: [ze],
256
- spacing: [de, be],
257
- blur: ["none", "", we, R],
258
- brightness: H(),
255
+ colors: [Ne],
256
+ spacing: [ue, be],
257
+ blur: ["none", "", we, N],
258
+ brightness: q(),
259
259
  borderColor: [e],
260
- borderRadius: ["none", "", "full", we, R],
260
+ borderRadius: ["none", "", "full", we, N],
261
261
  borderSpacing: C(),
262
262
  borderWidth: O(),
263
- contrast: H(),
264
- grayscale: N(),
265
- hueRotate: H(),
266
- invert: N(),
263
+ contrast: q(),
264
+ grayscale: U(),
265
+ hueRotate: q(),
266
+ invert: U(),
267
267
  gap: C(),
268
268
  gradientColorStops: [e],
269
269
  gradientColorStopPositions: [wn, be],
270
270
  inset: j(),
271
271
  margin: j(),
272
- opacity: H(),
272
+ opacity: q(),
273
273
  padding: C(),
274
- saturate: H(),
275
- scale: H(),
276
- sepia: N(),
277
- skew: H(),
274
+ saturate: q(),
275
+ scale: q(),
276
+ sepia: U(),
277
+ skew: q(),
278
278
  space: C(),
279
279
  translate: C()
280
280
  },
@@ -285,7 +285,7 @@ const D = (e) => {
285
285
  * @see https://tailwindcss.com/docs/aspect-ratio
286
286
  */
287
287
  aspect: [{
288
- aspect: ["auto", "square", "video", R]
288
+ aspect: ["auto", "square", "video", N]
289
289
  }],
290
290
  /**
291
291
  * Container
@@ -304,14 +304,14 @@ const D = (e) => {
304
304
  * @see https://tailwindcss.com/docs/break-after
305
305
  */
306
306
  "break-after": [{
307
- "break-after": L()
307
+ "break-after": R()
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": L()
314
+ "break-before": R()
315
315
  }],
316
316
  /**
317
317
  * Break Inside
@@ -370,49 +370,49 @@ const D = (e) => {
370
370
  * @see https://tailwindcss.com/docs/object-position
371
371
  */
372
372
  "object-position": [{
373
- object: [...E(), R]
373
+ object: [...P(), N]
374
374
  }],
375
375
  /**
376
376
  * Overflow
377
377
  * @see https://tailwindcss.com/docs/overflow
378
378
  */
379
379
  overflow: [{
380
- overflow: P()
380
+ overflow: E()
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": P()
387
+ "overflow-x": E()
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": P()
394
+ "overflow-y": E()
395
395
  }],
396
396
  /**
397
397
  * Overscroll Behavior
398
398
  * @see https://tailwindcss.com/docs/overscroll-behavior
399
399
  */
400
400
  overscroll: [{
401
- overscroll: w()
401
+ overscroll: k()
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": w()
408
+ "overscroll-x": k()
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": w()
415
+ "overscroll-y": k()
416
416
  }],
417
417
  /**
418
418
  * Position
@@ -424,63 +424,63 @@ const D = (e) => {
424
424
  * @see https://tailwindcss.com/docs/top-right-bottom-left
425
425
  */
426
426
  inset: [{
427
- inset: [f]
427
+ inset: [u]
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": [u]
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": [u]
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: [u]
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: [u]
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: [u]
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: [u]
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: [u]
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: [u]
484
484
  }],
485
485
  /**
486
486
  * Visibility
@@ -492,7 +492,7 @@ const D = (e) => {
492
492
  * @see https://tailwindcss.com/docs/z-index
493
493
  */
494
494
  z: [{
495
- z: ["auto", _e, R]
495
+ z: ["auto", _e, N]
496
496
  }],
497
497
  // Flexbox and Grid
498
498
  /**
@@ -521,35 +521,35 @@ const D = (e) => {
521
521
  * @see https://tailwindcss.com/docs/flex
522
522
  */
523
523
  flex: [{
524
- flex: ["1", "auto", "initial", "none", R]
524
+ flex: ["1", "auto", "initial", "none", N]
525
525
  }],
526
526
  /**
527
527
  * Flex Grow
528
528
  * @see https://tailwindcss.com/docs/flex-grow
529
529
  */
530
530
  grow: [{
531
- grow: N()
531
+ grow: U()
532
532
  }],
533
533
  /**
534
534
  * Flex Shrink
535
535
  * @see https://tailwindcss.com/docs/flex-shrink
536
536
  */
537
537
  shrink: [{
538
- shrink: N()
538
+ shrink: U()
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", _e, R]
545
+ order: ["first", "last", "none", _e, N]
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": [ze]
552
+ "grid-cols": [Ne]
553
553
  }],
554
554
  /**
555
555
  * Grid Column Start / End
@@ -557,8 +557,8 @@ const D = (e) => {
557
557
  */
558
558
  "col-start-end": [{
559
559
  col: ["auto", {
560
- span: ["full", _e, R]
561
- }, R]
560
+ span: ["full", _e, N]
561
+ }, N]
562
562
  }],
563
563
  /**
564
564
  * Grid Column Start
@@ -579,7 +579,7 @@ const D = (e) => {
579
579
  * @see https://tailwindcss.com/docs/grid-template-rows
580
580
  */
581
581
  "grid-rows": [{
582
- "grid-rows": [ze]
582
+ "grid-rows": [Ne]
583
583
  }],
584
584
  /**
585
585
  * Grid Row Start / End
@@ -587,8 +587,8 @@ const D = (e) => {
587
587
  */
588
588
  "row-start-end": [{
589
589
  row: ["auto", {
590
- span: [_e, R]
591
- }, R]
590
+ span: [_e, N]
591
+ }, N]
592
592
  }],
593
593
  /**
594
594
  * Grid Row Start
@@ -616,42 +616,42 @@ const D = (e) => {
616
616
  * @see https://tailwindcss.com/docs/grid-auto-columns
617
617
  */
618
618
  "auto-cols": [{
619
- "auto-cols": ["auto", "min", "max", "fr", R]
619
+ "auto-cols": ["auto", "min", "max", "fr", N]
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", R]
626
+ "auto-rows": ["auto", "min", "max", "fr", N]
627
627
  }],
628
628
  /**
629
629
  * Gap
630
630
  * @see https://tailwindcss.com/docs/gap
631
631
  */
632
632
  gap: [{
633
- gap: [g]
633
+ gap: [p]
634
634
  }],
635
635
  /**
636
636
  * Gap X
637
637
  * @see https://tailwindcss.com/docs/gap
638
638
  */
639
639
  "gap-x": [{
640
- "gap-x": [g]
640
+ "gap-x": [p]
641
641
  }],
642
642
  /**
643
643
  * Gap Y
644
644
  * @see https://tailwindcss.com/docs/gap
645
645
  */
646
646
  "gap-y": [{
647
- "gap-y": [g]
647
+ "gap-y": [p]
648
648
  }],
649
649
  /**
650
650
  * Justify Content
651
651
  * @see https://tailwindcss.com/docs/justify-content
652
652
  */
653
653
  "justify-content": [{
654
- justify: ["normal", ...K()]
654
+ justify: ["normal", ...J()]
655
655
  }],
656
656
  /**
657
657
  * Justify Items
@@ -672,7 +672,7 @@ const D = (e) => {
672
672
  * @see https://tailwindcss.com/docs/align-content
673
673
  */
674
674
  "align-content": [{
675
- content: ["normal", ...K(), "baseline"]
675
+ content: ["normal", ...J(), "baseline"]
676
676
  }],
677
677
  /**
678
678
  * Align Items
@@ -693,7 +693,7 @@ const D = (e) => {
693
693
  * @see https://tailwindcss.com/docs/place-content
694
694
  */
695
695
  "place-content": [{
696
- "place-content": [...K(), "baseline"]
696
+ "place-content": [...J(), "baseline"]
697
697
  }],
698
698
  /**
699
699
  * Place Items
@@ -866,21 +866,21 @@ const D = (e) => {
866
866
  * @see https://tailwindcss.com/docs/width
867
867
  */
868
868
  w: [{
869
- w: ["auto", "min", "max", "fit", "svw", "lvw", "dvw", R, t]
869
+ w: ["auto", "min", "max", "fit", "svw", "lvw", "dvw", N, 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": [R, t, "min", "max", "fit"]
876
+ "min-w": [N, 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": [R, t, "none", "full", "min", "max", "fit", "prose", {
883
+ "max-w": [N, t, "none", "full", "min", "max", "fit", "prose", {
884
884
  screen: [we]
885
885
  }, we]
886
886
  }],
@@ -889,28 +889,28 @@ const D = (e) => {
889
889
  * @see https://tailwindcss.com/docs/height
890
890
  */
891
891
  h: [{
892
- h: [R, t, "auto", "min", "max", "fit", "svh", "lvh", "dvh"]
892
+ h: [N, 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": [R, t, "min", "max", "fit", "svh", "lvh", "dvh"]
899
+ "min-h": [N, 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": [R, t, "min", "max", "fit", "svh", "lvh", "dvh"]
906
+ "max-h": [N, 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: [R, t, "auto", "min", "max", "fit"]
913
+ size: [N, t, "auto", "min", "max", "fit"]
914
914
  }],
915
915
  // Typography
916
916
  /**
@@ -942,7 +942,7 @@ const D = (e) => {
942
942
  * @see https://tailwindcss.com/docs/font-family
943
943
  */
944
944
  "font-family": [{
945
- font: [ze]
945
+ font: [Ne]
946
946
  }],
947
947
  /**
948
948
  * Font Variant Numeric
@@ -979,7 +979,7 @@ const D = (e) => {
979
979
  * @see https://tailwindcss.com/docs/letter-spacing
980
980
  */
981
981
  tracking: [{
982
- tracking: ["tighter", "tight", "normal", "wide", "wider", "widest", R]
982
+ tracking: ["tighter", "tight", "normal", "wide", "wider", "widest", N]
983
983
  }],
984
984
  /**
985
985
  * Line Clamp
@@ -993,21 +993,21 @@ const D = (e) => {
993
993
  * @see https://tailwindcss.com/docs/line-height
994
994
  */
995
995
  leading: [{
996
- leading: ["none", "tight", "snug", "normal", "relaxed", "loose", de, R]
996
+ leading: ["none", "tight", "snug", "normal", "relaxed", "loose", ue, N]
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", R]
1003
+ "list-image": ["none", N]
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", R]
1010
+ list: ["none", "disc", "decimal", N]
1011
1011
  }],
1012
1012
  /**
1013
1013
  * List Style Position
@@ -1069,14 +1069,14 @@ const D = (e) => {
1069
1069
  * @see https://tailwindcss.com/docs/text-decoration-thickness
1070
1070
  */
1071
1071
  "text-decoration-thickness": [{
1072
- decoration: ["auto", "from-font", de, be]
1072
+ decoration: ["auto", "from-font", ue, be]
1073
1073
  }],
1074
1074
  /**
1075
1075
  * Text Underline Offset
1076
1076
  * @see https://tailwindcss.com/docs/text-underline-offset
1077
1077
  */
1078
1078
  "underline-offset": [{
1079
- "underline-offset": ["auto", de, R]
1079
+ "underline-offset": ["auto", ue, N]
1080
1080
  }],
1081
1081
  /**
1082
1082
  * Text Decoration Color
@@ -1114,7 +1114,7 @@ const D = (e) => {
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", R]
1117
+ align: ["baseline", "top", "middle", "bottom", "text-top", "text-bottom", "sub", "super", N]
1118
1118
  }],
1119
1119
  /**
1120
1120
  * Whitespace
@@ -1142,7 +1142,7 @@ const D = (e) => {
1142
1142
  * @see https://tailwindcss.com/docs/content
1143
1143
  */
1144
1144
  content: [{
1145
- content: ["none", R]
1145
+ content: ["none", N]
1146
1146
  }],
1147
1147
  // Backgrounds
1148
1148
  /**
@@ -1179,7 +1179,7 @@ const D = (e) => {
1179
1179
  * @see https://tailwindcss.com/docs/background-position
1180
1180
  */
1181
1181
  "bg-position": [{
1182
- bg: [...E(), vn]
1182
+ bg: [...P(), vn]
1183
1183
  }],
1184
1184
  /**
1185
1185
  * Background Repeat
@@ -1239,21 +1239,21 @@ const D = (e) => {
1239
1239
  * @see https://tailwindcss.com/docs/gradient-color-stops
1240
1240
  */
1241
1241
  "gradient-from": [{
1242
- from: [m]
1242
+ from: [g]
1243
1243
  }],
1244
1244
  /**
1245
1245
  * Gradient Color Stops Via
1246
1246
  * @see https://tailwindcss.com/docs/gradient-color-stops
1247
1247
  */
1248
1248
  "gradient-via": [{
1249
- via: [m]
1249
+ via: [g]
1250
1250
  }],
1251
1251
  /**
1252
1252
  * Gradient Color Stops To
1253
1253
  * @see https://tailwindcss.com/docs/gradient-color-stops
1254
1254
  */
1255
1255
  "gradient-to": [{
1256
- to: [m]
1256
+ to: [g]
1257
1257
  }],
1258
1258
  // Borders
1259
1259
  /**
@@ -1261,105 +1261,105 @@ const D = (e) => {
1261
1261
  * @see https://tailwindcss.com/docs/border-radius
1262
1262
  */
1263
1263
  rounded: [{
1264
- rounded: [o]
1264
+ rounded: [s]
1265
1265
  }],
1266
1266
  /**
1267
1267
  * Border Radius Start
1268
1268
  * @see https://tailwindcss.com/docs/border-radius
1269
1269
  */
1270
1270
  "rounded-s": [{
1271
- "rounded-s": [o]
1271
+ "rounded-s": [s]
1272
1272
  }],
1273
1273
  /**
1274
1274
  * Border Radius End
1275
1275
  * @see https://tailwindcss.com/docs/border-radius
1276
1276
  */
1277
1277
  "rounded-e": [{
1278
- "rounded-e": [o]
1278
+ "rounded-e": [s]
1279
1279
  }],
1280
1280
  /**
1281
1281
  * Border Radius Top
1282
1282
  * @see https://tailwindcss.com/docs/border-radius
1283
1283
  */
1284
1284
  "rounded-t": [{
1285
- "rounded-t": [o]
1285
+ "rounded-t": [s]
1286
1286
  }],
1287
1287
  /**
1288
1288
  * Border Radius Right
1289
1289
  * @see https://tailwindcss.com/docs/border-radius
1290
1290
  */
1291
1291
  "rounded-r": [{
1292
- "rounded-r": [o]
1292
+ "rounded-r": [s]
1293
1293
  }],
1294
1294
  /**
1295
1295
  * Border Radius Bottom
1296
1296
  * @see https://tailwindcss.com/docs/border-radius
1297
1297
  */
1298
1298
  "rounded-b": [{
1299
- "rounded-b": [o]
1299
+ "rounded-b": [s]
1300
1300
  }],
1301
1301
  /**
1302
1302
  * Border Radius Left
1303
1303
  * @see https://tailwindcss.com/docs/border-radius
1304
1304
  */
1305
1305
  "rounded-l": [{
1306
- "rounded-l": [o]
1306
+ "rounded-l": [s]
1307
1307
  }],
1308
1308
  /**
1309
1309
  * Border Radius Start Start
1310
1310
  * @see https://tailwindcss.com/docs/border-radius
1311
1311
  */
1312
1312
  "rounded-ss": [{
1313
- "rounded-ss": [o]
1313
+ "rounded-ss": [s]
1314
1314
  }],
1315
1315
  /**
1316
1316
  * Border Radius Start End
1317
1317
  * @see https://tailwindcss.com/docs/border-radius
1318
1318
  */
1319
1319
  "rounded-se": [{
1320
- "rounded-se": [o]
1320
+ "rounded-se": [s]
1321
1321
  }],
1322
1322
  /**
1323
1323
  * Border Radius End End
1324
1324
  * @see https://tailwindcss.com/docs/border-radius
1325
1325
  */
1326
1326
  "rounded-ee": [{
1327
- "rounded-ee": [o]
1327
+ "rounded-ee": [s]
1328
1328
  }],
1329
1329
  /**
1330
1330
  * Border Radius End Start
1331
1331
  * @see https://tailwindcss.com/docs/border-radius
1332
1332
  */
1333
1333
  "rounded-es": [{
1334
- "rounded-es": [o]
1334
+ "rounded-es": [s]
1335
1335
  }],
1336
1336
  /**
1337
1337
  * Border Radius Top Left
1338
1338
  * @see https://tailwindcss.com/docs/border-radius
1339
1339
  */
1340
1340
  "rounded-tl": [{
1341
- "rounded-tl": [o]
1341
+ "rounded-tl": [s]
1342
1342
  }],
1343
1343
  /**
1344
1344
  * Border Radius Top Right
1345
1345
  * @see https://tailwindcss.com/docs/border-radius
1346
1346
  */
1347
1347
  "rounded-tr": [{
1348
- "rounded-tr": [o]
1348
+ "rounded-tr": [s]
1349
1349
  }],
1350
1350
  /**
1351
1351
  * Border Radius Bottom Right
1352
1352
  * @see https://tailwindcss.com/docs/border-radius
1353
1353
  */
1354
1354
  "rounded-br": [{
1355
- "rounded-br": [o]
1355
+ "rounded-br": [s]
1356
1356
  }],
1357
1357
  /**
1358
1358
  * Border Radius Bottom Left
1359
1359
  * @see https://tailwindcss.com/docs/border-radius
1360
1360
  */
1361
1361
  "rounded-bl": [{
1362
- "rounded-bl": [o]
1362
+ "rounded-bl": [s]
1363
1363
  }],
1364
1364
  /**
1365
1365
  * Border Width
@@ -1481,70 +1481,70 @@ const D = (e) => {
1481
1481
  * @see https://tailwindcss.com/docs/border-color
1482
1482
  */
1483
1483
  "border-color": [{
1484
- border: [s]
1484
+ border: [o]
1485
1485
  }],
1486
1486
  /**
1487
1487
  * Border Color X
1488
1488
  * @see https://tailwindcss.com/docs/border-color
1489
1489
  */
1490
1490
  "border-color-x": [{
1491
- "border-x": [s]
1491
+ "border-x": [o]
1492
1492
  }],
1493
1493
  /**
1494
1494
  * Border Color Y
1495
1495
  * @see https://tailwindcss.com/docs/border-color
1496
1496
  */
1497
1497
  "border-color-y": [{
1498
- "border-y": [s]
1498
+ "border-y": [o]
1499
1499
  }],
1500
1500
  /**
1501
1501
  * Border Color S
1502
1502
  * @see https://tailwindcss.com/docs/border-color
1503
1503
  */
1504
1504
  "border-color-s": [{
1505
- "border-s": [s]
1505
+ "border-s": [o]
1506
1506
  }],
1507
1507
  /**
1508
1508
  * Border Color E
1509
1509
  * @see https://tailwindcss.com/docs/border-color
1510
1510
  */
1511
1511
  "border-color-e": [{
1512
- "border-e": [s]
1512
+ "border-e": [o]
1513
1513
  }],
1514
1514
  /**
1515
1515
  * Border Color Top
1516
1516
  * @see https://tailwindcss.com/docs/border-color
1517
1517
  */
1518
1518
  "border-color-t": [{
1519
- "border-t": [s]
1519
+ "border-t": [o]
1520
1520
  }],
1521
1521
  /**
1522
1522
  * Border Color Right
1523
1523
  * @see https://tailwindcss.com/docs/border-color
1524
1524
  */
1525
1525
  "border-color-r": [{
1526
- "border-r": [s]
1526
+ "border-r": [o]
1527
1527
  }],
1528
1528
  /**
1529
1529
  * Border Color Bottom
1530
1530
  * @see https://tailwindcss.com/docs/border-color
1531
1531
  */
1532
1532
  "border-color-b": [{
1533
- "border-b": [s]
1533
+ "border-b": [o]
1534
1534
  }],
1535
1535
  /**
1536
1536
  * Border Color Left
1537
1537
  * @see https://tailwindcss.com/docs/border-color
1538
1538
  */
1539
1539
  "border-color-l": [{
1540
- "border-l": [s]
1540
+ "border-l": [o]
1541
1541
  }],
1542
1542
  /**
1543
1543
  * Divide Color
1544
1544
  * @see https://tailwindcss.com/docs/divide-color
1545
1545
  */
1546
1546
  "divide-color": [{
1547
- divide: [s]
1547
+ divide: [o]
1548
1548
  }],
1549
1549
  /**
1550
1550
  * Outline Style
@@ -1558,14 +1558,14 @@ const D = (e) => {
1558
1558
  * @see https://tailwindcss.com/docs/outline-offset
1559
1559
  */
1560
1560
  "outline-offset": [{
1561
- "outline-offset": [de, R]
1561
+ "outline-offset": [ue, N]
1562
1562
  }],
1563
1563
  /**
1564
1564
  * Outline Width
1565
1565
  * @see https://tailwindcss.com/docs/outline-width
1566
1566
  */
1567
1567
  "outline-w": [{
1568
- outline: [de, be]
1568
+ outline: [ue, be]
1569
1569
  }],
1570
1570
  /**
1571
1571
  * Outline Color
@@ -1605,7 +1605,7 @@ const D = (e) => {
1605
1605
  * @see https://tailwindcss.com/docs/ring-offset-width
1606
1606
  */
1607
1607
  "ring-offset-w": [{
1608
- "ring-offset": [de, be]
1608
+ "ring-offset": [ue, be]
1609
1609
  }],
1610
1610
  /**
1611
1611
  * Ring Offset Color
@@ -1627,7 +1627,7 @@ const D = (e) => {
1627
1627
  * @see https://tailwindcss.com/docs/box-shadow-color
1628
1628
  */
1629
1629
  "shadow-color": [{
1630
- shadow: [ze]
1630
+ shadow: [Ne]
1631
1631
  }],
1632
1632
  /**
1633
1633
  * Opacity
@@ -1678,14 +1678,14 @@ const D = (e) => {
1678
1678
  * @see https://tailwindcss.com/docs/contrast
1679
1679
  */
1680
1680
  contrast: [{
1681
- contrast: [u]
1681
+ contrast: [d]
1682
1682
  }],
1683
1683
  /**
1684
1684
  * Drop Shadow
1685
1685
  * @see https://tailwindcss.com/docs/drop-shadow
1686
1686
  */
1687
1687
  "drop-shadow": [{
1688
- "drop-shadow": ["", "none", we, R]
1688
+ "drop-shadow": ["", "none", we, N]
1689
1689
  }],
1690
1690
  /**
1691
1691
  * Grayscale
@@ -1706,7 +1706,7 @@ const D = (e) => {
1706
1706
  * @see https://tailwindcss.com/docs/invert
1707
1707
  */
1708
1708
  invert: [{
1709
- invert: [d]
1709
+ invert: [f]
1710
1710
  }],
1711
1711
  /**
1712
1712
  * Saturate
@@ -1749,7 +1749,7 @@ const D = (e) => {
1749
1749
  * @see https://tailwindcss.com/docs/backdrop-contrast
1750
1750
  */
1751
1751
  "backdrop-contrast": [{
1752
- "backdrop-contrast": [u]
1752
+ "backdrop-contrast": [d]
1753
1753
  }],
1754
1754
  /**
1755
1755
  * Backdrop Grayscale
@@ -1770,7 +1770,7 @@ const D = (e) => {
1770
1770
  * @see https://tailwindcss.com/docs/backdrop-invert
1771
1771
  */
1772
1772
  "backdrop-invert": [{
1773
- "backdrop-invert": [d]
1773
+ "backdrop-invert": [f]
1774
1774
  }],
1775
1775
  /**
1776
1776
  * Backdrop Opacity
@@ -1842,35 +1842,35 @@ const D = (e) => {
1842
1842
  * @see https://tailwindcss.com/docs/transition-property
1843
1843
  */
1844
1844
  transition: [{
1845
- transition: ["none", "all", "", "colors", "opacity", "shadow", "transform", R]
1845
+ transition: ["none", "all", "", "colors", "opacity", "shadow", "transform", N]
1846
1846
  }],
1847
1847
  /**
1848
1848
  * Transition Duration
1849
1849
  * @see https://tailwindcss.com/docs/transition-duration
1850
1850
  */
1851
1851
  duration: [{
1852
- duration: H()
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", R]
1859
+ ease: ["linear", "in", "out", "in-out", N]
1860
1860
  }],
1861
1861
  /**
1862
1862
  * Transition Delay
1863
1863
  * @see https://tailwindcss.com/docs/transition-delay
1864
1864
  */
1865
1865
  delay: [{
1866
- delay: H()
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", R]
1873
+ animate: ["none", "spin", "ping", "pulse", "bounce", N]
1874
1874
  }],
1875
1875
  // Transforms
1876
1876
  /**
@@ -1885,42 +1885,42 @@ const D = (e) => {
1885
1885
  * @see https://tailwindcss.com/docs/scale
1886
1886
  */
1887
1887
  scale: [{
1888
- scale: [k]
1888
+ scale: [w]
1889
1889
  }],
1890
1890
  /**
1891
1891
  * Scale X
1892
1892
  * @see https://tailwindcss.com/docs/scale
1893
1893
  */
1894
1894
  "scale-x": [{
1895
- "scale-x": [k]
1895
+ "scale-x": [w]
1896
1896
  }],
1897
1897
  /**
1898
1898
  * Scale Y
1899
1899
  * @see https://tailwindcss.com/docs/scale
1900
1900
  */
1901
1901
  "scale-y": [{
1902
- "scale-y": [k]
1902
+ "scale-y": [w]
1903
1903
  }],
1904
1904
  /**
1905
1905
  * Rotate
1906
1906
  * @see https://tailwindcss.com/docs/rotate
1907
1907
  */
1908
1908
  rotate: [{
1909
- rotate: [_e, R]
1909
+ rotate: [_e, N]
1910
1910
  }],
1911
1911
  /**
1912
1912
  * Translate X
1913
1913
  * @see https://tailwindcss.com/docs/translate
1914
1914
  */
1915
1915
  "translate-x": [{
1916
- "translate-x": [p]
1916
+ "translate-x": [m]
1917
1917
  }],
1918
1918
  /**
1919
1919
  * Translate Y
1920
1920
  * @see https://tailwindcss.com/docs/translate
1921
1921
  */
1922
1922
  "translate-y": [{
1923
- "translate-y": [p]
1923
+ "translate-y": [m]
1924
1924
  }],
1925
1925
  /**
1926
1926
  * Skew X
@@ -1941,7 +1941,7 @@ const D = (e) => {
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", R]
1944
+ origin: ["center", "top", "top-right", "right", "bottom-right", "bottom", "bottom-left", "left", "top-left", N]
1945
1945
  }],
1946
1946
  // Interactivity
1947
1947
  /**
@@ -1963,7 +1963,7 @@ const D = (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", R]
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", N]
1967
1967
  }],
1968
1968
  /**
1969
1969
  * Caret Color
@@ -2185,7 +2185,7 @@ const D = (e) => {
2185
2185
  * @see https://tailwindcss.com/docs/will-change
2186
2186
  */
2187
2187
  "will-change": [{
2188
- "will-change": ["auto", "scroll", "contents", "transform", R]
2188
+ "will-change": ["auto", "scroll", "contents", "transform", N]
2189
2189
  }],
2190
2190
  // SVG
2191
2191
  /**
@@ -2200,7 +2200,7 @@ const D = (e) => {
2200
2200
  * @see https://tailwindcss.com/docs/stroke-width
2201
2201
  */
2202
2202
  "stroke-w": [{
2203
- stroke: [de, be, qe]
2203
+ stroke: [ue, be, qe]
2204
2204
  }],
2205
2205
  /**
2206
2206
  * Stroke
@@ -2275,22 +2275,22 @@ const D = (e) => {
2275
2275
  "font-size": ["leading"]
2276
2276
  }
2277
2277
  };
2278
- }, Pn = /* @__PURE__ */ dn(En);
2279
- function rs(...e) {
2278
+ }, Pn = /* @__PURE__ */ un(En);
2279
+ function ro(...e) {
2280
2280
  return Pn(Qt(e));
2281
2281
  }
2282
2282
  function _n(e) {
2283
2283
  let t = !1, n = "";
2284
- for (const s of e) {
2285
- if (s === "\\") {
2286
- n += s, t = !t;
2284
+ for (const o of e) {
2285
+ if (o === "\\") {
2286
+ n += o, t = !t;
2287
2287
  continue;
2288
2288
  }
2289
- if (s === "'" && !t) {
2289
+ if (o === "'" && !t) {
2290
2290
  n += '"';
2291
2291
  continue;
2292
2292
  }
2293
- n += s, t = !1;
2293
+ n += o, t = !1;
2294
2294
  }
2295
2295
  return n.replace(/\bTrue\b/g, "true").replace(/\bFalse\b/g, "false").replace(/\bNone\b/g, "null");
2296
2296
  }
@@ -2310,10 +2310,10 @@ function tt(e) {
2310
2310
  return null;
2311
2311
  }
2312
2312
  }
2313
- function zn(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 Nn(e) {
2316
+ function zn(e) {
2317
2317
  return e.type === "image_url";
2318
2318
  }
2319
2319
  function Rn(e) {
@@ -2323,10 +2323,10 @@ function Ln(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(Nn);
2328
- }
2329
2326
  function jn(e) {
2327
+ return e.content.filter(zn);
2328
+ }
2329
+ function Un(e) {
2330
2330
  return e.content.filter(Rn);
2331
2331
  }
2332
2332
  function Mt(e) {
@@ -2372,8 +2372,8 @@ 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 s = Ke(r);
2376
- s !== void 0 && (t[n] = s);
2375
+ const o = Ke(r);
2376
+ o !== void 0 && (t[n] = o);
2377
2377
  }
2378
2378
  }
2379
2379
  if (Object.keys(t).length)
@@ -2397,15 +2397,15 @@ function Et(e) {
2397
2397
  return "";
2398
2398
  }
2399
2399
  }
2400
- function ss(e) {
2400
+ function oo(e) {
2401
2401
  const t = Et(e);
2402
- return typeof e == "string" && zn(e) ? { content: e, isMarkdown: !0 } : { content: t, isMarkdown: !1 };
2402
+ return typeof e == "string" && Nn(e) ? { content: e, isMarkdown: !0 } : { content: t, isMarkdown: !1 };
2403
2403
  }
2404
2404
  function Fn(e) {
2405
2405
  const t = (r) => {
2406
2406
  try {
2407
- const s = Ke(r);
2408
- return typeof s == "string" ? s : JSON.stringify(s ?? "");
2407
+ const o = Ke(r);
2408
+ return typeof o == "string" ? o : JSON.stringify(o ?? "");
2409
2409
  } catch {
2410
2410
  return "";
2411
2411
  }
@@ -2413,7 +2413,7 @@ function Fn(e) {
2413
2413
  return n.length ? t(n.map((r) => r.text).join(`
2414
2414
  `)) : t(e);
2415
2415
  }
2416
- function os(e) {
2416
+ function so(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) {
@@ -2448,27 +2448,27 @@ function le(e) {
2448
2448
  );
2449
2449
  }
2450
2450
  function nt(e) {
2451
- var x, M, A, k, b, h, T;
2451
+ var x, M, A, w, b, h, T;
2452
2452
  if (!e || typeof e != "object") return null;
2453
2453
  const t = le(e), n = Kn(t);
2454
2454
  if (!n)
2455
2455
  return null;
2456
- const r = t.toolCalls ?? ((x = t.additionalKwargs) == null ? void 0 : x.toolCalls), s = Array.isArray(r) ? r.map(rt) : void 0, o = Dn(t.content ?? t.parts, !!(s != null && s.length)), a = t.id ?? `msg-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`, i = t.createdAt ?? ((M = t.additionalKwargs) == null ? void 0 : M.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(), u = t.name ?? ((A = t.additionalKwargs) == null ? void 0 : A.agentName) ?? void 0, c = t.model ?? ((k = t.additionalKwargs) == null ? void 0 : k.model) ?? void 0, l = t.toolCallId ?? void 0, d = t.additionalKwargs ?? void 0, g = t.responseMetadata ?? void 0, m = t.checkpointId ?? ((b = t.additionalKwargs) == null ? void 0 : b.checkpointId) ?? void 0, I = t.checkpointNs ?? ((h = t.additionalKwargs) == null ? void 0 : h.checkpointNs) ?? void 0, f = typeof t.toolStreaming == "boolean" ? t.toolStreaming : !!((T = t.additionalKwargs) != null && T.toolStreaming);
2456
+ const r = t.toolCalls ?? ((x = t.additionalKwargs) == null ? void 0 : x.toolCalls), o = Array.isArray(r) ? r.map(rt) : void 0, s = Dn(t.content ?? t.parts, !!(o != null && o.length)), a = t.id ?? `msg-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`, i = t.createdAt ?? ((M = t.additionalKwargs) == null ? void 0 : M.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(), d = t.name ?? ((A = t.additionalKwargs) == null ? void 0 : A.agentName) ?? void 0, c = t.model ?? ((w = t.additionalKwargs) == null ? void 0 : w.model) ?? void 0, l = t.toolCallId ?? void 0, f = t.additionalKwargs ?? void 0, p = t.responseMetadata ?? void 0, g = t.checkpointId ?? ((b = t.additionalKwargs) == null ? void 0 : b.checkpointId) ?? void 0, I = t.checkpointNs ?? ((h = t.additionalKwargs) == null ? void 0 : h.checkpointNs) ?? void 0, u = typeof t.toolStreaming == "boolean" ? t.toolStreaming : !!((T = t.additionalKwargs) != null && T.toolStreaming);
2457
2457
  return {
2458
2458
  ...t,
2459
2459
  id: a,
2460
2460
  role: n,
2461
- content: o,
2461
+ content: s,
2462
2462
  createdAt: i,
2463
- name: u,
2463
+ name: d,
2464
2464
  model: c,
2465
2465
  toolCallId: l,
2466
- toolCalls: s,
2467
- checkpointId: m,
2466
+ toolCalls: o,
2467
+ checkpointId: g,
2468
2468
  checkpointNs: I,
2469
- toolStreaming: f,
2470
- additionalKwargs: d,
2471
- responseMetadata: g,
2469
+ toolStreaming: u,
2470
+ additionalKwargs: f,
2471
+ responseMetadata: p,
2472
2472
  artifact: t.artifact && typeof t.artifact == "object" && !t.artifact.type ? { ...t.artifact, type: t.name } : t.artifact ?? void 0
2473
2473
  };
2474
2474
  }
@@ -2504,12 +2504,12 @@ function Kn(e) {
2504
2504
  const r = t.type;
2505
2505
  return r ? r === "user" || r === "assistant" || r === "system" || r === "tool" ? r : r === "human" ? "user" : r === "ai" ? "assistant" : null : null;
2506
2506
  }
2507
- function ut(e) {
2507
+ function dt(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) {
2512
+ function ut(e) {
2513
2513
  return (Array.isArray(e.toolCalls) ? e.toolCalls : Mt(e)).map(rt);
2514
2514
  }
2515
2515
  function He(e, t) {
@@ -2522,11 +2522,11 @@ function Vn(e, t) {
2522
2522
  if (!n) return;
2523
2523
  const r = typeof n == "string" ? n : Et(n);
2524
2524
  if (!r.trim()) return;
2525
- const s = [{ type: "text", text: r }];
2525
+ const o = [{ type: "text", text: r }];
2526
2526
  return {
2527
2527
  id: `tool-${t.id}`,
2528
2528
  role: "tool",
2529
- content: s,
2529
+ content: o,
2530
2530
  name: t.name,
2531
2531
  toolCallId: t.id,
2532
2532
  artifact: t.artifact,
@@ -2535,10 +2535,10 @@ function Vn(e, t) {
2535
2535
  }
2536
2536
  function qn(e, t = []) {
2537
2537
  if (Array.isArray(e)) {
2538
- const s = e.filter((a) => a.role === "assistant").flatMap((a) => dt(a)), o = /* @__PURE__ */ new Map();
2539
- return s.forEach((a) => o.set(a.id, a)), Array.from(o.values()).map((a) => {
2540
- var d, g, m;
2541
- const i = He(a.id, e) || He(a.id, t), u = Array.isArray((d = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : d.toolProgress) ? (g = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : g.toolProgress : void 0, c = (i == null ? void 0 : i.artifact) ?? a.artifact, l = ut(a.status) ?? ((m = i == null ? void 0 : i.additionalKwargs) != null && m.toolStreaming ? "pending" : null) ?? (i ? "completed" : "pending");
2538
+ const o = e.filter((a) => a.role === "assistant").flatMap((a) => ut(a)), s = /* @__PURE__ */ new Map();
2539
+ return o.forEach((a) => s.set(a.id, a)), Array.from(s.values()).map((a) => {
2540
+ var f, p, g;
2541
+ const i = He(a.id, e) || He(a.id, t), d = Array.isArray((f = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : f.toolProgress) ? (p = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : p.toolProgress : void 0, c = (i == null ? void 0 : i.artifact) ?? a.artifact, l = dt(a.status) ?? ((g = i == null ? void 0 : i.additionalKwargs) != null && g.toolStreaming ? "pending" : null) ?? (i ? "completed" : "pending");
2542
2542
  if (i && !a.content && l === "completed") {
2543
2543
  const I = ce(i);
2544
2544
  typeof I == "string" && (a.content = I);
@@ -2547,33 +2547,33 @@ function qn(e, t = []) {
2547
2547
  call: a,
2548
2548
  result: i,
2549
2549
  state: l,
2550
- progress: u,
2550
+ progress: d,
2551
2551
  artifact: c
2552
2552
  };
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
- var u, c, l;
2559
- const s = He(r.id, t) ?? Vn(e, r), o = Array.isArray((u = s == null ? void 0 : s.additionalKwargs) == null ? void 0 : u.toolProgress) ? (c = s == null ? void 0 : s.additionalKwargs) == null ? void 0 : c.toolProgress : void 0, a = (s == null ? void 0 : s.artifact) ?? r.artifact, i = ut(r.status) ?? ((l = s == null ? void 0 : s.additionalKwargs) != null && l.toolStreaming ? "pending" : null) ?? (s ? "completed" : "pending");
2560
- if (s && !r.content && i === "completed") {
2561
- const d = ce(s);
2562
- typeof d == "string" && (r.content = d);
2558
+ var d, c, l;
2559
+ const o = He(r.id, t) ?? Vn(e, r), s = Array.isArray((d = o == null ? void 0 : o.additionalKwargs) == null ? void 0 : d.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 = dt(r.status) ?? ((l = o == null ? void 0 : o.additionalKwargs) != null && l.toolStreaming ? "pending" : null) ?? (o ? "completed" : "pending");
2560
+ if (o && !r.content && i === "completed") {
2561
+ const f = ce(o);
2562
+ typeof f == "string" && (r.content = f);
2563
2563
  }
2564
2564
  return {
2565
2565
  call: r,
2566
- result: s,
2566
+ result: o,
2567
2567
  state: i,
2568
- progress: o,
2568
+ progress: s,
2569
2569
  artifact: a
2570
2570
  };
2571
2571
  });
2572
2572
  }
2573
- function as(e, t = []) {
2573
+ function ao(e, t = []) {
2574
2574
  return qn(e, t).map((n) => n.artifact).filter((n) => !!n);
2575
2575
  }
2576
- const Ne = {
2576
+ const ze = {
2577
2577
  authToken: "authToken",
2578
2578
  authTokenExpiresAt: "authTokenExpiresAt",
2579
2579
  authSessionId: "authSessionId",
@@ -2597,7 +2597,7 @@ function _t(e) {
2597
2597
  return Qe.add(e), () => Qe.delete(e);
2598
2598
  }
2599
2599
  const Hn = 12e4, Gn = 12e4;
2600
- let Ye = Hn, zt = Gn;
2600
+ let Ye = Hn, Nt = Gn;
2601
2601
  const ne = Jt.create({
2602
2602
  // BaseURL is set dynamically via ApiProvider -> api.updateConfig
2603
2603
  timeout: Ye,
@@ -2608,20 +2608,20 @@ function ft(e) {
2608
2608
  }
2609
2609
  function Wn(e) {
2610
2610
  const t = ft(e.requestTimeoutMs), n = ft(e.historyTimeoutMs);
2611
- t !== null && (Ye = t, ne.defaults.timeout = Ye), n !== null && (zt = n);
2611
+ t !== null && (Ye = t, ne.defaults.timeout = Ye), n !== null && (Nt = n);
2612
2612
  }
2613
2613
  function Jn() {
2614
- return zt;
2614
+ return Nt;
2615
2615
  }
2616
2616
  ne.interceptors.request.use((e) => (Ve && (e.headers.Authorization = `Bearer ${Ve}`), e));
2617
2617
  ne.interceptors.response.use(
2618
2618
  (e) => {
2619
2619
  if (typeof window < "u" && (e != null && e.data))
2620
2620
  try {
2621
- const t = e.data, n = t.data || {}, r = typeof t.token == "string" && t.token || typeof n.token == "string" && n.token || null, s = typeof t.expires_at == "number" && t.expires_at || typeof n.expires_at == "number" && n.expires_at || typeof t.expiresAt == "number" && t.expiresAt || typeof n.expiresAt == "number" && n.expiresAt || null;
2622
- r && (localStorage.setItem(Ne.authToken, r), Ie(r)), s && localStorage.setItem(Ne.authTokenExpiresAt, s.toString()), (r || s) && window.dispatchEvent(
2621
+ const t = e.data, n = t.data || {}, r = typeof t.token == "string" && t.token || typeof n.token == "string" && n.token || null, o = typeof t.expires_at == "number" && t.expires_at || typeof n.expires_at == "number" && n.expires_at || typeof t.expiresAt == "number" && t.expiresAt || typeof n.expiresAt == "number" && n.expiresAt || null;
2622
+ r && (localStorage.setItem(ze.authToken, r), Ie(r)), o && localStorage.setItem(ze.authTokenExpiresAt, o.toString()), (r || o) && window.dispatchEvent(
2623
2623
  new CustomEvent("smartorg:chat-token-updated", {
2624
- detail: { token: r, expiresAt: s }
2624
+ detail: { token: r, expiresAt: o }
2625
2625
  })
2626
2626
  );
2627
2627
  } catch (t) {
@@ -2631,7 +2631,7 @@ ne.interceptors.response.use(
2631
2631
  },
2632
2632
  (e) => Promise.reject(e)
2633
2633
  );
2634
- async function oe(e, t) {
2634
+ async function se(e, t) {
2635
2635
  return ne.defaults.baseURL ? (await ne.get(e, t)).data : Promise.reject(new Error("API base URL is not configured"));
2636
2636
  }
2637
2637
  async function Ze(e, t, n) {
@@ -2677,15 +2677,15 @@ class Yn {
2677
2677
  }
2678
2678
  // ---- Thread Management ----
2679
2679
  async listThreads() {
2680
- const t = await oe("/threads"), n = ae(t);
2680
+ const t = await se("/threads"), n = ae(t);
2681
2681
  return (n == null ? void 0 : n.items) ?? (t == null ? void 0 : t.items) ?? [];
2682
2682
  }
2683
2683
  // listUsers moved to AuthApi
2684
2684
  async createThread(t, n) {
2685
2685
  const r = {};
2686
2686
  t && (r.title = t), n && (r.project = n);
2687
- const s = await Ze("/threads", Object.keys(r).length ? r : void 0);
2688
- return ae(s);
2687
+ const o = await Ze("/threads", Object.keys(r).length ? r : void 0);
2688
+ return ae(o);
2689
2689
  }
2690
2690
  async updateThread(t, n) {
2691
2691
  const r = await Xn(`/threads/${t}`, { title: n });
@@ -2696,24 +2696,24 @@ class Yn {
2696
2696
  return ae(n);
2697
2697
  }
2698
2698
  async threadInfo(t) {
2699
- const n = await oe(`/threads/${t}/info`);
2699
+ const n = await se(`/threads/${t}/info`);
2700
2700
  return ae(n);
2701
2701
  }
2702
2702
  // ---- Agents ----
2703
2703
  async listAgents() {
2704
- const t = await oe("/agents"), n = ae(t);
2704
+ const t = await se("/agents"), n = ae(t);
2705
2705
  return (n == null ? void 0 : n.items) ?? [];
2706
2706
  }
2707
2707
  async getAgent(t) {
2708
- const n = await oe(`/agents/${t}`);
2708
+ const n = await se(`/agents/${t}`);
2709
2709
  return ae(n);
2710
2710
  }
2711
2711
  async getAgentSchema(t) {
2712
- const n = await oe(`/agents/${t}/schema`);
2712
+ const n = await se(`/agents/${t}/schema`);
2713
2713
  return ae(n);
2714
2714
  }
2715
2715
  async getState(t) {
2716
- const n = await oe(`/threads/${t.threadId}/state`, {
2716
+ const n = await se(`/threads/${t.threadId}/state`, {
2717
2717
  params: {
2718
2718
  checkpoint_id: t.checkpointId,
2719
2719
  checkpoint_ns: t.checkpointNs
@@ -2722,7 +2722,7 @@ class Yn {
2722
2722
  return ae(n);
2723
2723
  }
2724
2724
  async getStateHistory(t) {
2725
- const n = await oe(`/threads/${t.threadId}/state/history`, {
2725
+ const n = await se(`/threads/${t.threadId}/state/history`, {
2726
2726
  params: {
2727
2727
  checkpoint_id: t.checkpointId,
2728
2728
  checkpoint_ns: t.checkpointNs,
@@ -2741,18 +2741,18 @@ class Yn {
2741
2741
  return ae(n);
2742
2742
  }
2743
2743
  }
2744
- const Nt = new Yn();
2744
+ const zt = new Yn();
2745
2745
  class Zn {
2746
2746
  // Config logic could go here if files ever need a distinct base URL from chat
2747
2747
  // For now, it shares the chatBaseUrl via the shared httpClient
2748
2748
  async fetchFileBlob(t, n) {
2749
- return await oe(t, {
2749
+ return await se(t, {
2750
2750
  responseType: "blob",
2751
- onDownloadProgress: (s) => {
2751
+ onDownloadProgress: (o) => {
2752
2752
  try {
2753
- if (n && s.lengthComputable) {
2754
- const o = s.loaded / s.total;
2755
- n(o);
2753
+ if (n && o.lengthComputable) {
2754
+ const s = o.loaded / o.total;
2755
+ n(s);
2756
2756
  }
2757
2757
  } catch {
2758
2758
  }
@@ -2762,8 +2762,8 @@ class Zn {
2762
2762
  });
2763
2763
  }
2764
2764
  async viewFileById(t, n) {
2765
- const r = await this.fetchFileBlob(`/files/${t}/view`, n), s = URL.createObjectURL(r);
2766
- window.open(s, "_blank"), setTimeout(() => URL.revokeObjectURL(s), 6e4);
2765
+ const r = await this.fetchFileBlob(`/files/${t}/view`, n), o = URL.createObjectURL(r);
2766
+ window.open(o, "_blank"), setTimeout(() => URL.revokeObjectURL(o), 6e4);
2767
2767
  }
2768
2768
  async getFileBlob(t, n) {
2769
2769
  return await this.fetchFileBlob(`/files/${t}/view`, n);
@@ -2772,30 +2772,30 @@ class Zn {
2772
2772
  return await (await this.fetchFileBlob(`/files/${t}/view`, n)).text();
2773
2773
  }
2774
2774
  async downloadFileById(t, n) {
2775
- const r = await this.fetchFileBlob(`/files/${t}/download`, n), s = URL.createObjectURL(r);
2776
- let o = `file_${t}`;
2775
+ const r = await this.fetchFileBlob(`/files/${t}/download`, n), o = URL.createObjectURL(r);
2776
+ let s = `file_${t}`;
2777
2777
  try {
2778
- const i = await oe(`/files/${t}`);
2779
- o = (i == null ? void 0 : i.filename) ?? o;
2778
+ const i = await se(`/files/${t}`);
2779
+ s = (i == null ? void 0 : i.filename) ?? s;
2780
2780
  } catch {
2781
2781
  }
2782
2782
  const a = document.createElement("a");
2783
- a.href = s, a.download = o, document.body.appendChild(a), a.click(), a.remove(), setTimeout(() => URL.revokeObjectURL(s), 6e4);
2783
+ a.href = o, a.download = s, document.body.appendChild(a), a.click(), a.remove(), setTimeout(() => URL.revokeObjectURL(o), 6e4);
2784
2784
  }
2785
2785
  async getFileInfo(t) {
2786
- return await oe(`/files/${t}`);
2786
+ return await se(`/files/${t}`);
2787
2787
  }
2788
2788
  async listFiles(t, n = 50, r = 0) {
2789
- const s = { limit: n, offset: r };
2790
- return t && (s.thread_id = t), await oe("/files", { params: s });
2789
+ const o = { limit: n, offset: r };
2790
+ return t && (o.thread_id = t), await se("/files", { params: o });
2791
2791
  }
2792
2792
  async uploadFile(t, n, r) {
2793
- const s = new FormData();
2794
- return s.append("file", t), n && s.append("thread_id", n), await Ze("/files/upload-form", s, {
2795
- onUploadProgress: (o) => {
2793
+ const o = new FormData();
2794
+ return o.append("file", t), n && o.append("thread_id", n), await Ze("/files/upload-form", o, {
2795
+ onUploadProgress: (s) => {
2796
2796
  try {
2797
- if (r && o.lengthComputable) {
2798
- const a = o.loaded / o.total;
2797
+ if (r && s.lengthComputable) {
2798
+ const a = s.loaded / s.total;
2799
2799
  r(a);
2800
2800
  }
2801
2801
  } catch {
@@ -2834,61 +2834,61 @@ class er {
2834
2834
  }
2835
2835
  // ---- User Management ----
2836
2836
  async listUsers() {
2837
- const t = await oe("/users", { baseURL: this.baseUrl });
2837
+ const t = await se("/users", { baseURL: this.baseUrl });
2838
2838
  return (t == null ? void 0 : t.users) ?? [];
2839
2839
  }
2840
2840
  }
2841
2841
  const tr = new er(), Lt = Ce(null);
2842
2842
  function nr({ children: e, apiConfig: t }) {
2843
- const n = Nt, r = tr;
2843
+ const n = zt, r = tr;
2844
2844
  if (t) {
2845
- const o = n.baseUrl, a = r.baseUrl, i = n.getAuthToken(), u = t.requestTimeoutMs !== void 0 || t.historyTimeoutMs !== void 0;
2846
- (t.baseUrl || t.chatBaseUrl || u) && (u || t.chatBaseUrl && t.chatBaseUrl !== o || t.baseUrl && !o.startsWith(t.baseUrl)) && n.updateConfig(t), (t.baseUrl || t.authBaseUrl) && (t.authBaseUrl && t.authBaseUrl !== a || t.baseUrl && !a.startsWith(t.baseUrl)) && r.updateConfig(t), t.apiKey !== void 0 && t.apiKey !== i && (n.updateConfig({ apiKey: t.apiKey }), r.updateConfig({ apiKey: t.apiKey }));
2845
+ const s = n.baseUrl, a = r.baseUrl, i = n.getAuthToken(), d = t.requestTimeoutMs !== void 0 || t.historyTimeoutMs !== void 0;
2846
+ (t.baseUrl || t.chatBaseUrl || d) && (d || t.chatBaseUrl && t.chatBaseUrl !== s || t.baseUrl && !s.startsWith(t.baseUrl)) && n.updateConfig(t), (t.baseUrl || t.authBaseUrl) && (t.authBaseUrl && t.authBaseUrl !== a || t.baseUrl && !a.startsWith(t.baseUrl)) && r.updateConfig(t), t.apiKey !== void 0 && t.apiKey !== i && (n.updateConfig({ apiKey: t.apiKey }), r.updateConfig({ apiKey: t.apiKey }));
2847
2847
  }
2848
- const s = {
2848
+ const o = {
2849
2849
  token: n.getAuthToken(),
2850
- setToken: (o) => {
2851
- n.setAuthToken(o), r.setAuthToken(o);
2850
+ setToken: (s) => {
2851
+ n.setAuthToken(s), r.setAuthToken(s);
2852
2852
  },
2853
2853
  chatApi: n,
2854
2854
  authApi: r,
2855
2855
  fileApi: Rt,
2856
2856
  baseUrl: n.baseUrl
2857
2857
  };
2858
- return /* @__PURE__ */ ie(Lt.Provider, { value: s, children: e });
2858
+ return /* @__PURE__ */ ie(Lt.Provider, { value: o, children: e });
2859
2859
  }
2860
2860
  async function rr(e) {
2861
2861
  return await new Promise((t, n) => {
2862
2862
  const r = new FileReader();
2863
2863
  r.onload = () => {
2864
2864
  try {
2865
- const s = r.result, o = new Uint8Array(s);
2865
+ const o = r.result, s = new Uint8Array(o);
2866
2866
  let a = "";
2867
- const i = o.byteLength;
2868
- for (let u = 0; u < i; u++) a += String.fromCharCode(o[u]);
2867
+ const i = s.byteLength;
2868
+ for (let d = 0; d < i; d++) a += String.fromCharCode(s[d]);
2869
2869
  t(btoa(a));
2870
- } catch (s) {
2871
- n(s);
2870
+ } catch (o) {
2871
+ n(o);
2872
2872
  }
2873
- }, r.onerror = (s) => n(s), r.readAsArrayBuffer(e);
2873
+ }, r.onerror = (o) => n(o), r.readAsArrayBuffer(e);
2874
2874
  });
2875
2875
  }
2876
- async function sr(e = []) {
2876
+ async function or(e = []) {
2877
2877
  const t = [], n = [];
2878
2878
  for (const r of e)
2879
2879
  try {
2880
- const s = await rr(r), o = r.type || "application/octet-stream";
2880
+ const o = await rr(r), s = r.type || "application/octet-stream";
2881
2881
  n.push({
2882
2882
  filename: r.name,
2883
- data: s,
2884
- mime_type: o
2885
- }), o.startsWith("image/") ? t.push({
2883
+ data: o,
2884
+ mime_type: s
2885
+ }), s.startsWith("image/") ? t.push({
2886
2886
  type: "image_url",
2887
- image_url: { url: `data:${o};base64,${s}` }
2887
+ image_url: { url: `data:${s};base64,${o}` }
2888
2888
  }) : t.push({
2889
2889
  type: "file",
2890
- url: `data:${o};base64,${s}`,
2891
- mimeType: o,
2890
+ url: `data:${s};base64,${o}`,
2891
+ mimeType: s,
2892
2892
  name: r.name,
2893
2893
  size: r.size
2894
2894
  });
@@ -2896,10 +2896,10 @@ async function sr(e = []) {
2896
2896
  }
2897
2897
  return { contentParts: t, filesInfo: n };
2898
2898
  }
2899
- function or(e) {
2899
+ function sr(e) {
2900
2900
  return e.filter((t) => t.type === "text").map((t) => t.text).join("");
2901
2901
  }
2902
- function is(e) {
2902
+ function io(e) {
2903
2903
  if (e == null) return null;
2904
2904
  const t = String(e).trim();
2905
2905
  return t.length > 0 ? t : null;
@@ -2911,13 +2911,13 @@ function ar(e) {
2911
2911
  name: e.name ?? void 0
2912
2912
  };
2913
2913
  }
2914
- function cs(e) {
2914
+ function co(e) {
2915
2915
  var n;
2916
2916
  if (e.name && e.name.trim()) return e.name;
2917
2917
  const t = (n = e.additionalKwargs) == null ? void 0 : n.agentName;
2918
2918
  return typeof t == "string" && t.trim() ? t : e.model && e.model.includes("/") ? e.model.split("/").pop() || null : e.model || null;
2919
2919
  }
2920
- function ls(e) {
2920
+ function lo(e) {
2921
2921
  const t = e.updatedAt ?? e.createdAt ?? "", n = Array.isArray(e.content) ? e.content.map((a) => {
2922
2922
  switch (a.type) {
2923
2923
  case "text":
@@ -2927,11 +2927,11 @@ function ls(e) {
2927
2927
  default:
2928
2928
  return a.type === "interrupt" ? "interrupt" : "unknown";
2929
2929
  }
2930
- }).join("|") : "", r = "checkpointId" in e && e.checkpointId ? `cp:${e.checkpointId}` : "", s = "checkpointNs" in e && e.checkpointNs ? `ns:${e.checkpointNs}` : "", o = [r, s].filter(Boolean).join("|");
2931
- return `${e.id}:${t}:${n}${o ? `:${o}` : ""}`;
2930
+ }).join("|") : "", r = "checkpointId" in e && e.checkpointId ? `cp:${e.checkpointId}` : "", o = "checkpointNs" in e && e.checkpointNs ? `ns:${e.checkpointNs}` : "", s = [r, o].filter(Boolean).join("|");
2931
+ return `${e.id}:${t}:${n}${s ? `:${s}` : ""}`;
2932
2932
  }
2933
2933
  function Me() {
2934
- const e = Ue(Lt);
2934
+ const e = je(Lt);
2935
2935
  if (!e) throw new Error("useApi must be used within ApiProvider");
2936
2936
  return e;
2937
2937
  }
@@ -2945,7 +2945,7 @@ function ir(e, t, n) {
2945
2945
  ...n
2946
2946
  };
2947
2947
  }
2948
- function Ut(e, t = "user") {
2948
+ function jt(e, t = "user") {
2949
2949
  return typeof e == "string" ? ir(t, e) : e;
2950
2950
  }
2951
2951
  function cr(e) {
@@ -2957,10 +2957,10 @@ function Se(e) {
2957
2957
  function lr(e) {
2958
2958
  return Se(e) ? typeof e.id == "string" && typeof e.type == "string" && "content" in e : !1;
2959
2959
  }
2960
- function ur(e) {
2960
+ function dr(e) {
2961
2961
  return Array.isArray(e) && e.every(lr);
2962
2962
  }
2963
- function dr(e) {
2963
+ function ur(e) {
2964
2964
  if (!Se(e)) return {};
2965
2965
  const t = {};
2966
2966
  for (const [n, r] of Object.entries(e))
@@ -2974,7 +2974,7 @@ function fr(e, t) {
2974
2974
  return t;
2975
2975
  if (e === "messages/partial") {
2976
2976
  const r = t;
2977
- return ur(r.messages) ? {
2977
+ return dr(r.messages) ? {
2978
2978
  type: "messages/partial",
2979
2979
  messages: r.messages,
2980
2980
  seq: typeof r.seq == "number" ? r.seq : void 0,
@@ -2999,7 +2999,7 @@ function fr(e, t) {
2999
2999
  const r = t;
3000
3000
  return (r == null ? void 0 : r.type) === "messages/metadata" && Se(r.metadata) ? {
3001
3001
  type: "messages/metadata",
3002
- metadata: dr(r.metadata),
3002
+ metadata: ur(r.metadata),
3003
3003
  seq: typeof r.seq == "number" ? r.seq : void 0,
3004
3004
  scope: typeof r.scope == "string" ? r.scope : void 0,
3005
3005
  origin: r.origin === "task" ? "task" : "agent"
@@ -3009,134 +3009,134 @@ function fr(e, t) {
3009
3009
  return "type" in n || (n.type = e), n;
3010
3010
  }
3011
3011
  function pr(e = {}) {
3012
- const t = e.baseUrl || "", n = e.streamPath ?? "/stream", [r, s] = $(e.token ?? null), o = W(e.headers ?? {}), a = e.credentials ?? "include", i = W(e);
3012
+ const t = e.baseUrl || "", n = e.streamPath ?? "/stream", [r, o] = $(e.token ?? null), s = G(e.headers ?? {}), a = e.credentials ?? "include", i = G(e);
3013
3013
  X(() => {
3014
3014
  i.current = e;
3015
3015
  }, [e]);
3016
- const u = _((p) => {
3017
- var j, C, O, F, E, B, z, K, N, L;
3018
- const w = i.current;
3019
- if (!w) return;
3020
- (j = w.onEvent) == null || j.call(w, p), p.type === "thread_info" && ((C = w.onThreadInfo) == null || C.call(w, p)), p.type === "values" && Array.isArray(p.checkpoints) && ((O = w.handleValuesEvent) == null || O.call(w, p)), p.type === "metadata" && ((F = w.onMetadataEvent) == null || F.call(w, p)), typeof p.type == "string" && (p.type === "custom" || p.type.startsWith("custom.")) && ((E = w.onCustomEvent) == null || E.call(w, p)), p.type === "updates" && ((B = w.onUpdateEvent) == null || B.call(w, p)), p.type === "tool.end" ? (z = w.onToolEnd) == null || z.call(w, p) : p.type === "tool.start" && ((K = w.onToolStart) == null || K.call(w, p)), p.type === "heartbeat" && ((N = w.onHeartbeat) == null || N.call(w, p)), p.type === "token" && ((L = w.onToken) == null || L.call(w, p.token));
3021
- }, []), [c, l] = $(!1), [d, g] = $(null), [m, I] = $(!1), [f, v] = $(null), x = W(null), M = W(!0), A = W(null), k = _((p) => {
3022
- s(p);
3016
+ const d = _((m) => {
3017
+ var j, C, O, F, P, B, z, J, U, R;
3018
+ const k = i.current;
3019
+ if (!k) return;
3020
+ (j = k.onEvent) == null || j.call(k, m), m.type === "thread_info" && ((C = k.onThreadInfo) == null || C.call(k, m)), m.type === "values" && ((O = k.handleValuesEvent) == null || O.call(k, m)), m.type === "metadata" && ((F = k.onMetadataEvent) == null || F.call(k, m)), typeof m.type == "string" && (m.type === "custom" || m.type.startsWith("custom.")) && ((P = k.onCustomEvent) == null || P.call(k, m)), m.type === "updates" && ((B = k.onUpdateEvent) == null || B.call(k, m)), m.type === "tool.end" ? (z = k.onToolEnd) == null || z.call(k, m) : m.type === "tool.start" && ((J = k.onToolStart) == null || J.call(k, m)), m.type === "heartbeat" && ((U = k.onHeartbeat) == null || U.call(k, m)), m.type === "token" && ((R = k.onToken) == null || R.call(k, m.token));
3021
+ }, []), [c, l] = $(!1), [f, p] = $(null), [g, I] = $(!1), [u, v] = $(null), x = G(null), M = G(!0), A = G(null), w = _((m) => {
3022
+ o(m);
3023
3023
  }, []), b = _(() => {
3024
- g(null), v(null);
3024
+ p(null), v(null);
3025
3025
  }, []), h = _(() => {
3026
3026
  var C, O;
3027
3027
  console.debug("[use-chat] stop() invoked - aborting stream");
3028
- const p = (C = A.current) == null ? void 0 : C.threadId, w = (O = A.current) == null ? void 0 : O.runId, P = () => {
3028
+ const m = (C = A.current) == null ? void 0 : C.threadId, k = (O = A.current) == null ? void 0 : O.runId, E = () => {
3029
3029
  var F;
3030
3030
  (F = x.current) == null || F.abort(), x.current = null, A.current = null, l(!1), I(!1);
3031
3031
  };
3032
- (w || p ? Nt.cancelRun(w || p).catch((F) => {
3032
+ (k || m ? zt.cancelRun(k || m).catch((F) => {
3033
3033
  console.warn("[use-chat] cancel run failed:", F);
3034
- }) : Promise.resolve()).finally(P);
3034
+ }) : Promise.resolve()).finally(E);
3035
3035
  }, []), T = _(
3036
- (p) => {
3036
+ (m) => {
3037
3037
  x.current && (x.current.abort(), x.current = null);
3038
- const w = {
3039
- text: typeof p.content == "string" ? p.content : p.text,
3040
- threadId: p.threadId,
3041
- attachments: p.attachments,
3042
- payload: p.payload ? {
3043
- ...p.payload,
3044
- creativityLevel: p.payload.creativityLevel ?? "medium"
3038
+ const k = {
3039
+ text: typeof m.content == "string" ? m.content : m.text,
3040
+ threadId: m.threadId,
3041
+ attachments: m.attachments,
3042
+ payload: m.payload ? {
3043
+ ...m.payload,
3044
+ creativityLevel: m.payload.creativityLevel ?? "medium"
3045
3045
  } : { creativityLevel: "medium" },
3046
- config: p.config,
3047
- checkpointId: p.checkpointId,
3048
- checkpointNs: p.checkpointNs || void 0,
3049
- edit: p.edit ?? !1,
3050
- command: p.command
3046
+ config: m.config,
3047
+ checkpointId: m.checkpointId,
3048
+ checkpointNs: m.checkpointNs || void 0,
3049
+ edit: m.edit ?? !1,
3050
+ command: m.command
3051
3051
  };
3052
- l(!0), g(null), v(null);
3053
- const P = new AbortController();
3054
- x.current = P;
3052
+ l(!0), p(null), v(null);
3053
+ const E = new AbortController();
3054
+ x.current = E;
3055
3055
  let j = null, C = !1;
3056
3056
  return A.current = {
3057
- threadId: w.threadId ?? void 0,
3057
+ threadId: k.threadId ?? void 0,
3058
3058
  runId: void 0,
3059
3059
  // Will be updated from headers
3060
3060
  headers: {},
3061
3061
  isStreaming: !0
3062
3062
  }, (async () => {
3063
- var O, F, E, B, z, K;
3063
+ var O, F, P, B, z, J;
3064
3064
  try {
3065
- let N = {};
3065
+ let U = {};
3066
3066
  try {
3067
3067
  if (r)
3068
- N = { Authorization: `Bearer ${r}` };
3068
+ U = { Authorization: `Bearer ${r}` };
3069
3069
  else if (typeof window < "u") {
3070
- const te = window.__AUTH_TOKEN__, ke = ((O = window.localStorage) == null ? void 0 : O.getItem(Ne.authToken)) || null;
3070
+ const te = window.__AUTH_TOKEN__, ke = ((O = window.localStorage) == null ? void 0 : O.getItem(ze.authToken)) || null;
3071
3071
  let Q = null;
3072
3072
  try {
3073
- const ge = (F = window.localStorage) == null ? void 0 : F.getItem(Ne.chatSettings);
3074
- ge && (Q = ((E = JSON.parse(ge)) == null ? void 0 : E.apiKey) || null);
3073
+ const ge = (F = window.localStorage) == null ? void 0 : F.getItem(ze.chatSettings);
3074
+ ge && (Q = ((P = JSON.parse(ge)) == null ? void 0 : P.apiKey) || null);
3075
3075
  } catch {
3076
3076
  }
3077
3077
  const Z = te || ke || Q || null;
3078
- Z && (N = { Authorization: `Bearer ${Z}` });
3078
+ Z && (U = { Authorization: `Bearer ${Z}` });
3079
3079
  }
3080
3080
  } catch {
3081
3081
  }
3082
3082
  console.debug("[use-chat] POST", t + n);
3083
- let L = {};
3083
+ let R = {};
3084
3084
  if (typeof window < "u")
3085
3085
  try {
3086
- const G = (B = window.localStorage) == null ? void 0 : B.getItem(Ne.authSessionId);
3087
- G && (L = { "X-Session-Id": G });
3086
+ const H = (B = window.localStorage) == null ? void 0 : B.getItem(ze.authSessionId);
3087
+ H && (R = { "X-Session-Id": H });
3088
3088
  } catch {
3089
3089
  }
3090
- const H = {
3091
- ...N,
3092
- ...L,
3093
- ...o.current
3090
+ const q = {
3091
+ ...U,
3092
+ ...R,
3093
+ ...s.current
3094
3094
  }, y = {
3095
3095
  "Content-Type": "application/json",
3096
3096
  Accept: "text/event-stream",
3097
- ...H
3098
- }, U = await fetch(t + n, {
3097
+ ...q
3098
+ }, L = await fetch(t + n, {
3099
3099
  method: "POST",
3100
3100
  headers: y,
3101
- body: JSON.stringify(w),
3102
- signal: P.signal,
3101
+ body: JSON.stringify(k),
3102
+ signal: E.signal,
3103
3103
  credentials: a
3104
3104
  });
3105
- if (A.current && (A.current.headers = H), !U.ok || !U.body) {
3106
- const G = await U.text().catch(() => "");
3105
+ if (A.current && (A.current.headers = q), !L.ok || !L.body) {
3106
+ const H = await L.text().catch(() => "");
3107
3107
  console.debug(
3108
3108
  "[use-chat] non-OK response",
3109
- U.status,
3110
- G == null ? void 0 : G.slice(0, 500)
3109
+ L.status,
3110
+ H == null ? void 0 : H.slice(0, 500)
3111
3111
  );
3112
- const te = `stream ${U.status}${G ? ": " + G : ""}`;
3113
- throw te && (g(te), j = "error"), new Error(te);
3112
+ const te = `stream ${L.status}${H ? ": " + H : ""}`;
3113
+ throw te && (p(te), j = "error"), new Error(te);
3114
3114
  }
3115
3115
  I(!0);
3116
- const S = U.body.getReader(), J = new TextDecoder();
3117
- let V = "", q = 0, ee = Date.now();
3116
+ const S = L.body.getReader(), W = new TextDecoder();
3117
+ let K = "", V = 0, ee = Date.now();
3118
3118
  const re = setInterval(() => {
3119
- Date.now() - ee > 18e5 && (g("Stream idle timeout"), j = "error", P.abort());
3120
- }, 5e3), ue = 1024 * 1024;
3119
+ Date.now() - ee > 18e5 && (p("Stream idle timeout"), j = "error", E.abort());
3120
+ }, 5e3), de = 1024 * 1024;
3121
3121
  try {
3122
- const G = U.headers.get("X-Thread-Id") || U.headers.get("x-thread-id"), te = U.headers.get("X-Run-Id") || U.headers.get("x-run-id");
3122
+ const H = L.headers.get("X-Thread-Id") || L.headers.get("x-thread-id"), te = L.headers.get("X-Run-Id") || L.headers.get("x-run-id");
3123
3123
  for (A.current && (A.current = {
3124
3124
  ...A.current,
3125
- threadId: G ?? A.current.threadId,
3125
+ threadId: H ?? A.current.threadId,
3126
3126
  runId: te ?? A.current.runId
3127
3127
  }); ; ) {
3128
3128
  const { value: ke, done: Q } = await S.read();
3129
3129
  if (Q) break;
3130
- V += J.decode(ke, { stream: !0 }), V.length > ue && (V = "", console.warn("Stream buffer reset: exceeded 1MB"));
3130
+ K += W.decode(ke, { stream: !0 }), K.length > de && (K = "", console.warn("Stream buffer reset: exceeded 1MB"));
3131
3131
  let Z;
3132
- for (; (Z = V.indexOf(`
3132
+ for (; (Z = K.indexOf(`
3133
3133
 
3134
3134
  `)) >= 0; ) {
3135
- const ge = V.slice(0, Z);
3136
- V = V.slice(Z + 2);
3137
- const je = ge.split(/\r?\n/), Be = [];
3135
+ const ge = K.slice(0, Z);
3136
+ K = K.slice(Z + 2);
3137
+ const Ue = ge.split(/\r?\n/), Be = [];
3138
3138
  let me = null;
3139
- for (const he of je)
3139
+ for (const he of Ue)
3140
3140
  if (!he.startsWith(":") && he) {
3141
3141
  if (he.startsWith("event:")) {
3142
3142
  const Ae = he.slice(6).trim();
@@ -3151,39 +3151,39 @@ function pr(e = {}) {
3151
3151
  const ve = Be.join(`
3152
3152
  `);
3153
3153
  if (!ve) continue;
3154
- let se;
3154
+ let oe;
3155
3155
  try {
3156
- se = JSON.parse(ve);
3156
+ oe = JSON.parse(ve);
3157
3157
  } catch {
3158
3158
  console.debug("[use-chat] malformed SSE:", ve.slice(0, 200));
3159
3159
  continue;
3160
3160
  }
3161
- se = fr(me, se);
3162
- const Pe = cr(se) ? se.data : se;
3161
+ oe = fr(me, oe);
3162
+ const Pe = cr(oe) ? oe.data : oe;
3163
3163
  if (!Pe) {
3164
- console.warn("[use-chat] dropped envelope event without payload", se);
3164
+ console.warn("[use-chat] dropped envelope event without payload", oe);
3165
3165
  continue;
3166
3166
  }
3167
3167
  const xe = $n(Pe);
3168
3168
  ee = Date.now();
3169
3169
  const ye = typeof xe.seq == "number" ? xe.seq : void 0;
3170
3170
  if (ye !== void 0) {
3171
- if (ye <= q) {
3172
- console.debug("[use-chat] drop duplicate/out-of-order event", { seq: ye, lastProcessedSeq: q, type: xe.type });
3171
+ if (ye <= V) {
3172
+ console.debug("[use-chat] drop duplicate/out-of-order event", { seq: ye, lastProcessedSeq: V, type: xe.type });
3173
3173
  continue;
3174
3174
  }
3175
- q = ye;
3175
+ V = ye;
3176
3176
  }
3177
- u(xe);
3177
+ d(xe);
3178
3178
  }
3179
3179
  }
3180
- j === null && !P.signal.aborted && (j = "complete");
3181
- } catch (G) {
3182
- if (G.name === "AbortError")
3180
+ j === null && !E.signal.aborted && (j = "complete");
3181
+ } catch (H) {
3182
+ if (H.name === "AbortError")
3183
3183
  j = j ?? "aborted";
3184
3184
  else {
3185
- const te = G.message || String(G);
3186
- j = "error", g(te);
3185
+ const te = H.message || String(H);
3186
+ j = "error", p(te);
3187
3187
  }
3188
3188
  } finally {
3189
3189
  try {
@@ -3194,59 +3194,59 @@ function pr(e = {}) {
3194
3194
  }
3195
3195
  clearInterval(re);
3196
3196
  }
3197
- } catch (N) {
3198
- if (N.name === "AbortError")
3197
+ } catch (U) {
3198
+ if (U.name === "AbortError")
3199
3199
  j = j ?? "aborted";
3200
3200
  else {
3201
- const L = N.message || String(N);
3202
- j = "error", g(L), C || (C = !0, (K = e.onConnectionError) == null || K.call(e, L));
3201
+ const R = U.message || String(U);
3202
+ j = "error", p(R), C || (C = !0, (J = e.onConnectionError) == null || J.call(e, R));
3203
3203
  }
3204
3204
  } finally {
3205
3205
  try {
3206
3206
  if (e.onFinish) {
3207
- const N = {
3207
+ const U = {
3208
3208
  lastSeq: 0,
3209
3209
  lastCheckpointId: null,
3210
3210
  lastCheckpointNs: null,
3211
3211
  lastValues: null
3212
3212
  // Let the reducer/history hook provide the final values
3213
3213
  };
3214
- e.onFinish(N);
3214
+ e.onFinish(U);
3215
3215
  }
3216
- } catch (N) {
3217
- console.warn("[use-chat] onClosed callback failed", N);
3216
+ } catch (U) {
3217
+ console.warn("[use-chat] onClosed callback failed", U);
3218
3218
  }
3219
3219
  l(!1), I(!1), x.current = null, A.current = null;
3220
3220
  }
3221
3221
  })(), Promise.resolve();
3222
3222
  },
3223
- [t, n, r, e, u]
3223
+ [t, n, r, e, d]
3224
3224
  );
3225
3225
  return X(() => () => {
3226
- var p;
3227
- M.current = !1, (p = x.current) == null || p.abort();
3226
+ var m;
3227
+ M.current = !1, (m = x.current) == null || m.abort();
3228
3228
  }, []), {
3229
3229
  isStreaming: c,
3230
- error: d,
3230
+ error: f,
3231
3231
  assistantText: "",
3232
3232
  // Deprecated: use messages from reducer
3233
- activeMessageId: f,
3233
+ activeMessageId: u,
3234
3234
  streamedMessages: {},
3235
3235
  // Deprecated: use messages from reducer
3236
3236
  lastCheckpointId: null,
3237
3237
  // Deprecated: use checkpoint from reducer
3238
3238
  lastSeq: 0,
3239
- connected: m,
3239
+ connected: g,
3240
3240
  stream: T,
3241
3241
  stop: h,
3242
3242
  clear: b,
3243
- setToken: k,
3243
+ setToken: w,
3244
3244
  values: {},
3245
3245
  // Provide empty object for backward compatibility
3246
3246
  interrupt: () => Promise.resolve(),
3247
3247
  resume: () => Promise.resolve(),
3248
3248
  goto: () => Promise.resolve(),
3249
- connectionState: d ? "error" : c ? m ? "connected" : "connecting" : "idle",
3249
+ connectionState: f ? "error" : c ? g ? "connected" : "connecting" : "idle",
3250
3250
  messages: [],
3251
3251
  // useStream doesn't maintain messages, use useChatSession instead
3252
3252
  submit: T
@@ -3257,77 +3257,77 @@ function gr({
3257
3257
  initialThreadId: t = null,
3258
3258
  onError: n,
3259
3259
  onThreadChange: r,
3260
- onCurrentThreadDeleted: s
3260
+ onCurrentThreadDeleted: o
3261
3261
  }) {
3262
- const [o, a] = $([]), [i, u] = $(t), [c, l] = $(!1), [d, g] = $(null), m = W(i), I = W(/* @__PURE__ */ new Map());
3262
+ const [s, a] = $([]), [i, d] = $(t), [c, l] = $(!1), [f, p] = $(null), g = G(i), I = G(/* @__PURE__ */ new Map());
3263
3263
  X(() => {
3264
- m.current = i;
3264
+ g.current = i;
3265
3265
  }, [i]), X(() => {
3266
- t !== void 0 && t !== m.current && u(t);
3266
+ t !== void 0 && t !== g.current && d(t);
3267
3267
  }, [t]);
3268
- const f = _(async () => {
3269
- l(!0), g(null);
3268
+ const u = _(async () => {
3269
+ l(!0), p(null);
3270
3270
  try {
3271
3271
  const b = await e.listThreads();
3272
3272
  a(b ?? []);
3273
3273
  } catch (b) {
3274
3274
  const h = String(b);
3275
- g(h), n == null || n(h);
3275
+ p(h), n == null || n(h);
3276
3276
  } finally {
3277
3277
  l(!1);
3278
3278
  }
3279
3279
  }, [e, n]);
3280
3280
  X(() => {
3281
- f();
3282
- }, [f]), X(() => {
3281
+ u();
3282
+ }, [u]), X(() => {
3283
3283
  r == null || r(i);
3284
3284
  }, [i, r]);
3285
3285
  const v = _(
3286
3286
  async (b, h) => {
3287
3287
  try {
3288
- const T = h && typeof h == "object" ? { id: h.id, name: h.name ?? "" } : void 0, p = await e.createThread(b, T);
3289
- return u(p.threadId), await f(), p.threadId;
3288
+ const T = h && typeof h == "object" ? { id: h.id, name: h.name ?? "" } : void 0, m = await e.createThread(b, T);
3289
+ return d(m.threadId), await u(), m.threadId;
3290
3290
  } catch (T) {
3291
- const p = String(T);
3292
- return n == null || n(p), null;
3291
+ const m = String(T);
3292
+ return n == null || n(m), null;
3293
3293
  }
3294
3294
  },
3295
- [e, n, f]
3295
+ [e, n, u]
3296
3296
  ), x = _(
3297
3297
  async (b) => {
3298
- const h = o;
3299
- a((p) => p.filter((w) => w.threadId !== b));
3298
+ const h = s;
3299
+ a((m) => m.filter((k) => k.threadId !== b));
3300
3300
  const T = new AbortController();
3301
3301
  I.current.set(b, T);
3302
3302
  try {
3303
- await e.deleteThread(b), m.current === b && (u(null), s == null || s());
3304
- } catch (p) {
3303
+ await e.deleteThread(b), g.current === b && (d(null), o == null || o());
3304
+ } catch (m) {
3305
3305
  a(h);
3306
- const w = String(p);
3307
- n == null || n(w);
3306
+ const k = String(m);
3307
+ n == null || n(k);
3308
3308
  } finally {
3309
3309
  I.current.delete(b);
3310
3310
  }
3311
3311
  },
3312
- [e, s, n, o]
3312
+ [e, o, n, s]
3313
3313
  ), M = _(
3314
3314
  async (b, h) => {
3315
3315
  try {
3316
- await e.updateThread(b, h), await f();
3316
+ await e.updateThread(b, h), await u();
3317
3317
  } catch (T) {
3318
3318
  n == null || n(String(T));
3319
3319
  }
3320
3320
  },
3321
- [e, n, f]
3321
+ [e, n, u]
3322
3322
  ), A = Y(
3323
3323
  () => ({
3324
3324
  createThread: v,
3325
3325
  deleteThread: x,
3326
3326
  renameThread: M,
3327
- refreshThreads: f
3327
+ refreshThreads: u
3328
3328
  }),
3329
- [v, x, M, f]
3330
- ), k = _((b) => {
3329
+ [v, x, M, u]
3330
+ ), w = _((b) => {
3331
3331
  if (!(b != null && b.threadId)) return;
3332
3332
  const h = {
3333
3333
  threadId: b.threadId,
@@ -3338,75 +3338,75 @@ function gr({
3338
3338
  messageCount: b.messageCount ?? 1
3339
3339
  };
3340
3340
  a((T) => {
3341
- let p = !1;
3342
- const w = T.map((P) => P.threadId === h.threadId ? (p = !0, console.debug("[useThreadsState] thread_info: updating existing thread", h.threadId), {
3343
- ...P,
3344
- title: h.title ?? P.title,
3345
- project: h.project ?? P.project,
3346
- updatedAt: h.updatedAt ?? P.updatedAt,
3347
- messageCount: h.messageCount ?? P.messageCount
3348
- }) : P);
3349
- return p ? w : (console.debug("[useThreadsState] thread_info: adding thread to list", h.threadId), [h, ...T]);
3341
+ let m = !1;
3342
+ const k = T.map((E) => E.threadId === h.threadId ? (m = !0, console.debug("[useThreadsState] thread_info: updating existing thread", h.threadId), {
3343
+ ...E,
3344
+ title: h.title ?? E.title,
3345
+ project: h.project ?? E.project,
3346
+ updatedAt: h.updatedAt ?? E.updatedAt,
3347
+ messageCount: h.messageCount ?? E.messageCount
3348
+ }) : E);
3349
+ return m ? k : (console.debug("[useThreadsState] thread_info: adding thread to list", h.threadId), [h, ...T]);
3350
3350
  });
3351
3351
  }, []);
3352
3352
  return {
3353
- threads: o,
3353
+ threads: s,
3354
3354
  currentThreadId: i,
3355
- currentThreadIdRef: m,
3356
- setCurrentThreadId: u,
3355
+ currentThreadIdRef: g,
3356
+ setCurrentThreadId: d,
3357
3357
  isLoadingThreads: c,
3358
- threadsError: d,
3358
+ threadsError: f,
3359
3359
  actions: A,
3360
- addThreadFromEvent: k
3360
+ addThreadFromEvent: w
3361
3361
  };
3362
3362
  }
3363
- const jt = Ce(null);
3363
+ const Ut = Ce(null);
3364
3364
  function mr({
3365
3365
  children: e,
3366
3366
  initialThreadId: t = null,
3367
3367
  onError: n,
3368
3368
  onThreadChange: r
3369
3369
  }) {
3370
- const { chatApi: s } = Me(), {
3371
- threads: o,
3370
+ const { chatApi: o } = Me(), {
3371
+ threads: s,
3372
3372
  currentThreadId: a,
3373
3373
  setCurrentThreadId: i,
3374
- currentThreadIdRef: u,
3374
+ currentThreadIdRef: d,
3375
3375
  isLoadingThreads: c,
3376
3376
  threadsError: l,
3377
- actions: d,
3378
- addThreadFromEvent: g
3377
+ actions: f,
3378
+ addThreadFromEvent: p
3379
3379
  } = gr({
3380
- api: s,
3380
+ api: o,
3381
3381
  initialThreadId: t,
3382
3382
  onError: n,
3383
3383
  onThreadChange: r
3384
- }), m = Y(
3384
+ }), g = Y(
3385
3385
  () => ({
3386
- threads: o,
3386
+ threads: s,
3387
3387
  currentThreadId: a,
3388
3388
  setCurrentThreadId: i,
3389
- currentThreadIdRef: u,
3389
+ currentThreadIdRef: d,
3390
3390
  isLoading: c,
3391
3391
  error: l,
3392
- actions: d,
3393
- addThreadFromEvent: g
3392
+ actions: f,
3393
+ addThreadFromEvent: p
3394
3394
  }),
3395
3395
  [
3396
- o,
3396
+ s,
3397
3397
  a,
3398
3398
  i,
3399
- u,
3399
+ d,
3400
3400
  c,
3401
3401
  l,
3402
- d,
3403
- g
3402
+ f,
3403
+ p
3404
3404
  ]
3405
3405
  );
3406
- return /* @__PURE__ */ ie(jt.Provider, { value: m, children: e });
3406
+ return /* @__PURE__ */ ie(Ut.Provider, { value: g, children: e });
3407
3407
  }
3408
- function st(e) {
3409
- const t = Ue(jt);
3408
+ function ot(e) {
3409
+ const t = je(Ut);
3410
3410
  if (!t && !(e != null && e.optional)) throw new Error("useThreads must be used within a ThreadsProvider");
3411
3411
  return t;
3412
3412
  }
@@ -3438,8 +3438,8 @@ function yr(e, t) {
3438
3438
  }
3439
3439
  function hr(e, t, n) {
3440
3440
  return e.find((r) => {
3441
- const s = Bt(r);
3442
- return !!((s == null ? void 0 : s.id) === t || n && r.toolCallId === n);
3441
+ const o = Bt(r);
3442
+ return !!((o == null ? void 0 : o.id) === t || n && r.toolCallId === n);
3443
3443
  }) ?? null;
3444
3444
  }
3445
3445
  function Oe(e) {
@@ -3452,8 +3452,8 @@ function Ft(e, t, n) {
3452
3452
  function br(e, t, n) {
3453
3453
  for (let r = e.length - 1; r >= 0; r--)
3454
3454
  if (e[r].role === "assistant") {
3455
- const o = { ...e[r], checkpointId: t, checkpointNs: n ?? void 0 };
3456
- return Ft(e, r, o);
3455
+ const s = { ...e[r], checkpointId: t, checkpointNs: n ?? void 0 };
3456
+ return Ft(e, r, s);
3457
3457
  }
3458
3458
  return e;
3459
3459
  }
@@ -3484,14 +3484,14 @@ function wr(e, t) {
3484
3484
  messages: Oe(((n = t.payload) == null ? void 0 : n.messages) ?? [])
3485
3485
  };
3486
3486
  case "user_message": {
3487
- const { message: r, editingMessageId: s } = t.payload;
3488
- if (s) {
3489
- const o = e.messages.findIndex((a) => a.id === s);
3490
- if (o !== -1)
3487
+ const { message: r, editingMessageId: o } = t.payload;
3488
+ if (o) {
3489
+ const s = e.messages.findIndex((a) => a.id === o);
3490
+ if (s !== -1)
3491
3491
  return {
3492
3492
  ...e,
3493
3493
  status: "streaming",
3494
- messages: [...e.messages.slice(0, o), r],
3494
+ messages: [...e.messages.slice(0, s), r],
3495
3495
  assemblingId: null,
3496
3496
  lastCheckpointId: null,
3497
3497
  error: null
@@ -3507,7 +3507,7 @@ function wr(e, t) {
3507
3507
  };
3508
3508
  }
3509
3509
  case "seed": {
3510
- const r = Oe(t.payload.messages), s = {
3510
+ const r = Oe(t.payload.messages), o = {
3511
3511
  ...e,
3512
3512
  status: "idle",
3513
3513
  messages: r,
@@ -3516,51 +3516,51 @@ function wr(e, t) {
3516
3516
  taskMessagesByScope: {},
3517
3517
  error: null
3518
3518
  };
3519
- return Object.prototype.hasOwnProperty.call(t.payload, "checkpointId") && (s.lastCheckpointId = t.payload.checkpointId ?? null), Object.prototype.hasOwnProperty.call(t.payload, "checkpointNs") && (s.lastCheckpointNs = t.payload.checkpointNs ?? null), Object.prototype.hasOwnProperty.call(t.payload, "values") && (s.values = t.payload.values ?? {}), s;
3519
+ 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;
3520
3520
  }
3521
3521
  case "prepend": {
3522
3522
  const r = Oe(t.payload.messages);
3523
3523
  if (!r.length) return e;
3524
- const s = new Set(e.messages.map((a) => a.id)), o = r.filter((a) => !s.has(a.id));
3525
- return o.length ? { ...e, messages: [...o, ...e.messages] } : e;
3524
+ const o = new Set(e.messages.map((a) => a.id)), s = r.filter((a) => !o.has(a.id));
3525
+ return s.length ? { ...e, messages: [...s, ...e.messages] } : e;
3526
3526
  }
3527
3527
  case "event":
3528
3528
  return pt(e, t.payload.ev);
3529
3529
  case "batch": {
3530
3530
  const { events: r } = t.payload;
3531
- return r.length ? r.reduce((s, o) => pt(s, o), e) : e;
3531
+ return r.length ? r.reduce((o, s) => pt(o, s), e) : e;
3532
3532
  }
3533
3533
  default:
3534
3534
  return e;
3535
3535
  }
3536
3536
  }
3537
3537
  function kr(e = []) {
3538
- const [t, n] = Wt(wr, { ...Ot, messages: e }), r = W([]), s = W(null), o = _(() => {
3539
- s.current !== null && typeof window < "u" && window.cancelAnimationFrame(s.current), s.current = null;
3538
+ const [t, n] = Wt(wr, { ...Ot, messages: e }), r = G([]), o = G(null), s = _(() => {
3539
+ o.current !== null && typeof window < "u" && window.cancelAnimationFrame(o.current), o.current = null;
3540
3540
  const c = r.current;
3541
3541
  c.length && (r.current = [], n({ type: "batch", payload: { events: c } }));
3542
3542
  }, []), a = _(() => {
3543
- typeof window < "u" && typeof window.requestAnimationFrame == "function" ? s.current === null && (s.current = window.requestAnimationFrame(() => o())) : setTimeout(o, 8);
3544
- }, [o]), i = _((c) => {
3543
+ typeof window < "u" && typeof window.requestAnimationFrame == "function" ? o.current === null && (o.current = window.requestAnimationFrame(() => s())) : setTimeout(s, 8);
3544
+ }, [s]), i = _((c) => {
3545
3545
  r.current.push(c), a();
3546
- }, [a]), u = Y(() => ({
3546
+ }, [a]), d = Y(() => ({
3547
3547
  setStatus: (c, l) => n({ type: "status", payload: { status: c, error: l } }),
3548
3548
  reset: (c) => n({ type: "reset", payload: { messages: c } }),
3549
3549
  seed: (c, l) => n({ type: "seed", payload: { messages: c, ...l ?? {} } }),
3550
3550
  pushUser: (c, l) => n({ type: "user_message", payload: { message: c, editingMessageId: l } }),
3551
3551
  onEvent: i
3552
3552
  }), [i]);
3553
- return { state: t, dispatch: n, ...u };
3553
+ return { state: t, dispatch: n, ...d };
3554
3554
  }
3555
3555
  function pt(e, t) {
3556
- const n = t.origin, r = t.scope, s = n === "task" || typeof r == "string" && r.startsWith("tools:");
3556
+ const n = t.origin, r = t.scope, o = n === "task" || typeof r == "string" && r.startsWith("tools:");
3557
3557
  if (t.type === "checkpoint") {
3558
- const o = t.checkpointNs ?? e.lastCheckpointNs ?? null, a = br(e.messages, t.checkpointId, o);
3559
- return { ...e, lastCheckpointId: t.checkpointId, lastCheckpointNs: o, messages: a };
3558
+ const s = t.checkpointNs ?? e.lastCheckpointNs ?? null, a = br(e.messages, t.checkpointId, s);
3559
+ return { ...e, lastCheckpointId: t.checkpointId, lastCheckpointNs: s, messages: a };
3560
3560
  }
3561
3561
  if (t.type === "status") {
3562
- const o = t.status === "completed" || t.status === "error" ? "idle" : t.status === "interrupted" ? "awaiting_input" : e.status;
3563
- return { ...e, status: o };
3562
+ const s = t.status === "completed" || t.status === "error" ? "idle" : t.status === "interrupted" ? "awaiting_input" : e.status;
3563
+ return { ...e, status: s };
3564
3564
  }
3565
3565
  if (t.type === "interrupt")
3566
3566
  return {
@@ -3574,53 +3574,68 @@ function pt(e, t) {
3574
3574
  }
3575
3575
  };
3576
3576
  if (t.type === "error") {
3577
- const o = {
3577
+ const s = {
3578
3578
  id: `err-${Date.now()}`,
3579
3579
  role: "system",
3580
3580
  content: [{ type: "text", text: `Error: ${t.message}` }],
3581
3581
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
3582
3582
  };
3583
- return { ...e, status: "error", error: t.message, messages: [...e.messages, o] };
3583
+ return { ...e, status: "error", error: t.message, messages: [...e.messages, s] };
3584
3584
  }
3585
- if (t.type === "values" && "messages" in t && Array.isArray(t.messages)) {
3586
- const o = t, a = Array.isArray(o.messages) ? o.messages : [], i = Oe(a), { messages: u, ...c } = o, l = c.__interrupt__ ?? c.interrupts, d = Array.isArray(l) && l.length > 0 ? {
3587
- id: l[0].id || "native-interrupt",
3588
- value: l[0].value || l[0],
3589
- alternatives: l[0].alternatives
3585
+ if (t.type === "values") {
3586
+ const s = t, a = s.values && typeof s.values == "object" ? { ...s.values } : {}, i = Array.isArray(s.messages) ? s.messages : Array.isArray(a.messages) ? a.messages : [];
3587
+ if (!i.length && Object.keys(a).length === 0)
3588
+ return e;
3589
+ const d = Oe(i);
3590
+ delete a.messages;
3591
+ let c = e.lastCheckpointId, l = e.lastCheckpointNs;
3592
+ const f = s.config || s.checkpoint, p = (f == null ? void 0 : f.configurable) || f;
3593
+ if ((p != null && p.checkpoint_id || p != null && p.checkpointId) && (c = p.checkpoint_id || p.checkpointId, l = p.checkpoint_ns || p.checkpointNs || null), !c) {
3594
+ for (let u = d.length - 1; u >= 0; u--)
3595
+ if (d[u].checkpointId) {
3596
+ c = d[u].checkpointId, l = d[u].checkpointNs ?? null;
3597
+ break;
3598
+ }
3599
+ }
3600
+ const g = s.interrupts || a.__interrupt__ || a.interrupts, I = Array.isArray(g) && g.length > 0 ? {
3601
+ id: g[0].id || "native-interrupt",
3602
+ value: g[0].value || g[0],
3603
+ alternatives: g[0].alternatives
3590
3604
  } : null;
3591
- if (s) {
3592
- const g = typeof r == "string" && r.length > 0 ? r : "task";
3605
+ if (o) {
3606
+ const u = typeof r == "string" && r.length > 0 ? r : "task";
3593
3607
  return {
3594
3608
  ...e,
3595
- taskMessagesByScope: { ...e.taskMessagesByScope, [g]: i },
3609
+ taskMessagesByScope: { ...e.taskMessagesByScope, [u]: d },
3596
3610
  assemblingId: null
3597
- // Clear streaming state when finalized
3598
3611
  };
3599
3612
  }
3600
3613
  return {
3601
3614
  ...e,
3602
- status: d ? "awaiting_input" : e.status === "streaming" ? "idle" : e.status,
3603
- messages: i,
3615
+ status: I ? "awaiting_input" : e.status === "streaming" ? "idle" : e.status,
3616
+ messages: d,
3604
3617
  assemblingId: null,
3605
- pendingInterrupt: d,
3606
- values: c
3618
+ lastCheckpointId: c,
3619
+ lastCheckpointNs: l,
3620
+ pendingInterrupt: I,
3621
+ values: { ...e.values, ...a }
3607
3622
  };
3608
3623
  }
3609
3624
  if (t.type === "messages/metadata") {
3610
- const o = { ...e.messagesStreamMeta ?? {} }, a = t.metadata;
3611
- return a && typeof a == "object" && Object.entries(a).forEach(([i, u]) => {
3612
- const c = u == null ? void 0 : u.metadata;
3625
+ const s = { ...e.messagesStreamMeta ?? {} }, a = t.metadata;
3626
+ return a && typeof a == "object" && Object.entries(a).forEach(([i, d]) => {
3627
+ const c = d == null ? void 0 : d.metadata;
3613
3628
  if (!c || typeof c != "object") return;
3614
- const l = o[i] ?? {};
3615
- o[i] = {
3629
+ const l = s[i] ?? {};
3630
+ s[i] = {
3616
3631
  ...l,
3617
3632
  lastSeq: t.seq ?? l.lastSeq ?? null,
3618
3633
  metadata: { ...l.metadata ?? {}, ...c }
3619
3634
  };
3620
- }), { ...e, messagesStreamMeta: o };
3635
+ }), { ...e, messagesStreamMeta: s };
3621
3636
  }
3622
3637
  if (t.type === "messages/partial" || t.type === "message.delta") {
3623
- const o = t.type === "messages/partial" ? t : {
3638
+ const s = t.type === "messages/partial" ? t : {
3624
3639
  ...t,
3625
3640
  type: "messages/partial",
3626
3641
  messages: t.delta ? [{
@@ -3631,65 +3646,65 @@ function pt(e, t) {
3631
3646
  origin: t.origin
3632
3647
  }] : []
3633
3648
  };
3634
- return Ir(e, o, s);
3649
+ return Ir(e, s, o);
3635
3650
  }
3636
- return t.type === "message.start" ? { ...e, assemblingId: t.id, status: "streaming" } : t.type === "message.end" ? { ...e, assemblingId: null } : t.type === "tool.start" ? { ...vr(e, t, s), status: "streaming" } : t.type === "tool.progress" ? xr(e, t, s) : t.type === "tool.end" ? Ar(e, t, s) : t.type === "artifact.update" ? Tr(e, t) : e;
3651
+ return t.type === "message.start" ? { ...e, assemblingId: t.id, status: "streaming" } : t.type === "message.end" ? { ...e, assemblingId: null } : t.type === "tool.start" ? { ...vr(e, t, o), status: "streaming" } : t.type === "tool.progress" ? xr(e, t, o) : t.type === "tool.end" ? Ar(e, t, o) : t.type === "artifact.update" ? Tr(e, t) : e;
3637
3652
  }
3638
3653
  function Ir(e, t, n) {
3639
- var m, I, f, v, x, M, A;
3654
+ var g, I, u, v, x, M, A;
3640
3655
  const r = t.messages;
3641
3656
  if (!r.length)
3642
3657
  return console.warn("[messagesReducer] Dropping messages/partial event without messages[]", t), e;
3643
- const s = r.find((k) => k.type === "ai" || k.type === "assistant" || k.role === "assistant");
3644
- if (!s) return e;
3645
- const o = s.id, a = s.content ?? "", i = typeof a == "string" ? [{ type: "text", text: a }] : Array.isArray(a) ? a.map((k) => typeof k == "string" ? { type: "text", text: k } : (k == null ? void 0 : k.type) === "text" ? { type: "text", text: typeof k.text == "string" ? k.text : k.content ?? "" } : ((k == null ? void 0 : k.type) === "reasoning", k)) : [], u = i.filter((k) => k.type === "text").map((k) => k.text).join(""), c = e.assemblingId !== o, l = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3646
- let d = n ? [...e.taskMessagesByScope[l] || []] : [...e.messages];
3647
- const g = (I = (m = e.messagesStreamMeta) == null ? void 0 : m[o]) == null ? void 0 : I.metadata;
3658
+ const o = r.find((w) => w.type === "ai" || w.type === "assistant" || w.role === "assistant");
3659
+ if (!o) return e;
3660
+ const s = o.id, a = o.content ?? "", i = typeof a == "string" ? [{ type: "text", text: a }] : Array.isArray(a) ? a.map((w) => typeof w == "string" ? { type: "text", text: w } : (w == null ? void 0 : w.type) === "text" ? { type: "text", text: typeof w.text == "string" ? w.text : w.content ?? "" } : ((w == null ? void 0 : w.type) === "reasoning", w)) : [], d = i.filter((w) => w.type === "text").map((w) => w.text).join(""), c = e.assemblingId !== s, l = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3661
+ let f = n ? [...e.taskMessagesByScope[l] || []] : [...e.messages];
3662
+ const p = (I = (g = e.messagesStreamMeta) == null ? void 0 : g[s]) == null ? void 0 : I.metadata;
3648
3663
  if (c) {
3649
- const k = nt({
3650
- ...s,
3664
+ const w = nt({
3665
+ ...o,
3651
3666
  role: "assistant",
3652
3667
  content: i,
3653
3668
  scope: t.scope,
3654
3669
  origin: t.origin,
3655
- responseMetadata: { ...g, ...s.responseMetadata ?? {} }
3670
+ responseMetadata: { ...p, ...o.responseMetadata ?? {} }
3656
3671
  });
3657
- k && d.push(k);
3672
+ w && f.push(w);
3658
3673
  } else {
3659
- const k = d.findIndex((b) => b.id === o);
3660
- if (k !== -1) {
3661
- const b = d[k];
3662
- d[k] = {
3674
+ const w = f.findIndex((b) => b.id === s);
3675
+ if (w !== -1) {
3676
+ const b = f[w];
3677
+ f[w] = {
3663
3678
  ...b,
3664
3679
  content: i,
3665
3680
  scope: t.scope ?? b.scope,
3666
3681
  origin: t.origin ?? b.origin,
3667
- responseMetadata: { ...g, ...b.responseMetadata, ...s.responseMetadata ?? {} }
3682
+ responseMetadata: { ...p, ...b.responseMetadata, ...o.responseMetadata ?? {} }
3668
3683
  };
3669
3684
  }
3670
3685
  }
3671
3686
  return {
3672
3687
  ...e,
3673
3688
  status: "streaming",
3674
- messages: n ? e.messages : d,
3675
- taskMessagesByScope: n ? { ...e.taskMessagesByScope, [l]: d } : e.taskMessagesByScope,
3676
- assemblingId: o,
3689
+ messages: n ? e.messages : f,
3690
+ taskMessagesByScope: n ? { ...e.taskMessagesByScope, [l]: f } : e.taskMessagesByScope,
3691
+ assemblingId: s,
3677
3692
  messagesStreamMeta: {
3678
3693
  ...e.messagesStreamMeta ?? {},
3679
- [o]: {
3680
- ...((f = e.messagesStreamMeta) == null ? void 0 : f[o]) ?? {},
3681
- lastSeq: t.seq ?? ((x = (v = e.messagesStreamMeta) == null ? void 0 : v[o]) == null ? void 0 : x.lastSeq) ?? null,
3682
- lastText: u || (((A = (M = e.messagesStreamMeta) == null ? void 0 : M[o]) == null ? void 0 : A.lastText) ?? "")
3694
+ [s]: {
3695
+ ...((u = e.messagesStreamMeta) == null ? void 0 : u[s]) ?? {},
3696
+ lastSeq: t.seq ?? ((x = (v = e.messagesStreamMeta) == null ? void 0 : v[s]) == null ? void 0 : x.lastSeq) ?? null,
3697
+ lastText: d || (((A = (M = e.messagesStreamMeta) == null ? void 0 : M[s]) == null ? void 0 : A.lastText) ?? "")
3683
3698
  }
3684
3699
  }
3685
3700
  };
3686
3701
  }
3687
- function ot(e, t) {
3702
+ function st(e, t) {
3688
3703
  var n;
3689
3704
  if (!t) return -1;
3690
3705
  for (let r = e.length - 1; r >= 0; r--) {
3691
- const s = e[r];
3692
- if (s.role === "assistant" && ((n = s.toolCalls) != null && n.some((o) => o.id === t)))
3706
+ const o = e[r];
3707
+ if (o.role === "assistant" && ((n = o.toolCalls) != null && n.some((s) => s.id === t)))
3693
3708
  return r;
3694
3709
  }
3695
3710
  return -1;
@@ -3697,16 +3712,16 @@ function ot(e, t) {
3697
3712
  function vr(e, t, n) {
3698
3713
  const r = t.id || t.callId;
3699
3714
  if (!r) return e;
3700
- const s = t.name || "tool", o = `Starting ${s}...`, a = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3701
- let i = n ? [...e.taskMessagesByScope[a] || []] : [...e.messages], u = ot(i, r);
3702
- if (u === -1) {
3715
+ const o = t.name || "tool", s = `Starting ${o}...`, a = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3716
+ let i = n ? [...e.taskMessagesByScope[a] || []] : [...e.messages], d = st(i, r);
3717
+ if (d === -1) {
3703
3718
  for (let c = i.length - 1; c >= 0; c--)
3704
3719
  if (i[c].role === "assistant") {
3705
- u = c;
3720
+ d = c;
3706
3721
  break;
3707
3722
  }
3708
3723
  }
3709
- if (u === -1) {
3724
+ if (d === -1) {
3710
3725
  const c = {
3711
3726
  id: `assistant-${r}`,
3712
3727
  role: "assistant",
@@ -3716,17 +3731,17 @@ function vr(e, t, n) {
3716
3731
  scope: t.scope,
3717
3732
  origin: t.origin
3718
3733
  };
3719
- i.push(c), u = i.length - 1;
3734
+ i.push(c), d = i.length - 1;
3720
3735
  }
3721
- if (u !== -1) {
3722
- const c = i[u], l = [...c.toolCalls || []], d = l.findIndex((g) => g.id === r);
3723
- d >= 0 ? l[d] = { ...l[d], status: "running", content: o } : l.push({
3736
+ if (d !== -1) {
3737
+ const c = i[d], l = [...c.toolCalls || []], f = l.findIndex((p) => p.id === r);
3738
+ f >= 0 ? l[f] = { ...l[f], status: "running", content: s } : l.push({
3724
3739
  id: r,
3725
- name: s,
3740
+ name: o,
3726
3741
  args: t.args || {},
3727
3742
  status: "running",
3728
- content: o
3729
- }), i[u] = {
3743
+ content: s
3744
+ }), i[d] = {
3730
3745
  ...c,
3731
3746
  toolCalls: l,
3732
3747
  scope: t.scope ?? c.scope,
@@ -3742,14 +3757,14 @@ function vr(e, t, n) {
3742
3757
  function xr(e, t, n) {
3743
3758
  const r = t.id;
3744
3759
  if (!r) return e;
3745
- const s = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3746
- let o = n ? [...e.taskMessagesByScope[s] || []] : [...e.messages];
3747
- const a = ot(o, r);
3760
+ const o = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3761
+ let s = n ? [...e.taskMessagesByScope[o] || []] : [...e.messages];
3762
+ const a = st(s, r);
3748
3763
  if (a !== -1) {
3749
- const i = o[a], u = ce(t.content), c = (i.toolCalls || []).map(
3750
- (l) => l.id === r ? { ...l, content: typeof u == "string" ? u : l.content } : l
3764
+ const i = s[a], d = ce(t.content), c = (i.toolCalls || []).map(
3765
+ (l) => l.id === r ? { ...l, content: typeof d == "string" ? d : l.content } : l
3751
3766
  );
3752
- o[a] = {
3767
+ s[a] = {
3753
3768
  ...i,
3754
3769
  toolCalls: c,
3755
3770
  scope: t.scope ?? i.scope,
@@ -3758,33 +3773,33 @@ function xr(e, t, n) {
3758
3773
  }
3759
3774
  return {
3760
3775
  ...e,
3761
- messages: n ? e.messages : o,
3762
- taskMessagesByScope: n ? { ...e.taskMessagesByScope, [s]: o } : e.taskMessagesByScope
3776
+ messages: n ? e.messages : s,
3777
+ taskMessagesByScope: n ? { ...e.taskMessagesByScope, [o]: s } : e.taskMessagesByScope
3763
3778
  };
3764
3779
  }
3765
3780
  function Ar(e, t, n) {
3766
3781
  const r = t.id;
3767
3782
  if (!r) return e;
3768
- const s = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3769
- let o = n ? [...e.taskMessagesByScope[s] || []] : [...e.messages];
3770
- const a = ot(o, r), i = ce(t.content ?? t.error);
3783
+ const o = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3784
+ let s = n ? [...e.taskMessagesByScope[o] || []] : [...e.messages];
3785
+ const a = st(s, r), i = ce(t.content ?? t.error);
3771
3786
  if (a !== -1) {
3772
- const c = o[a], l = (c.toolCalls || []).map(
3773
- (d) => d.id === r ? {
3774
- ...d,
3787
+ const c = s[a], l = (c.toolCalls || []).map(
3788
+ (f) => f.id === r ? {
3789
+ ...f,
3775
3790
  status: t.error ? "failed" : "completed",
3776
- content: typeof i == "string" ? i : d.content,
3791
+ content: typeof i == "string" ? i : f.content,
3777
3792
  artifact: t.artifact
3778
- } : d
3793
+ } : f
3779
3794
  );
3780
- o[a] = {
3795
+ s[a] = {
3781
3796
  ...c,
3782
3797
  toolCalls: l,
3783
3798
  scope: t.scope ?? c.scope,
3784
3799
  origin: t.origin ?? c.origin
3785
3800
  };
3786
3801
  }
3787
- const u = {
3802
+ const d = {
3788
3803
  id: `tool-${r}`,
3789
3804
  role: "tool",
3790
3805
  name: t.name,
@@ -3795,21 +3810,21 @@ function Ar(e, t, n) {
3795
3810
  scope: t.scope,
3796
3811
  origin: t.origin
3797
3812
  };
3798
- return o.push(u), {
3813
+ return s.push(d), {
3799
3814
  ...e,
3800
- messages: n ? e.messages : o,
3801
- taskMessagesByScope: n ? { ...e.taskMessagesByScope, [s]: o } : e.taskMessagesByScope
3815
+ messages: n ? e.messages : s,
3816
+ taskMessagesByScope: n ? { ...e.taskMessagesByScope, [o]: s } : e.taskMessagesByScope
3802
3817
  };
3803
3818
  }
3804
3819
  function Tr(e, t) {
3805
3820
  const n = t.artifactId, r = hr(e.messages, n, t.callId);
3806
3821
  if (!r) return e;
3807
- const s = e.messages.indexOf(r), o = yr(r, {
3822
+ const o = e.messages.indexOf(r), s = yr(r, {
3808
3823
  status: t.status,
3809
3824
  progress: t.progress,
3810
3825
  error: t.error
3811
3826
  });
3812
- return t.partial_data && o.artifact && (o.artifact = { ...o.artifact, ...t.partial_data }), { ...e, messages: Ft(e.messages, s, o) };
3827
+ return t.partial_data && s.artifact && (s.artifact = { ...s.artifact, ...t.partial_data }), { ...e, messages: Ft(e.messages, o, s) };
3813
3828
  }
3814
3829
  function Re(e) {
3815
3830
  if (!(!e || typeof e != "object" || Array.isArray(e)))
@@ -3838,87 +3853,87 @@ function gt(e) {
3838
3853
  return Re(t.configurable) ?? t;
3839
3854
  }
3840
3855
  async function Mr(e, t) {
3841
- var i, u;
3856
+ var i, d;
3842
3857
  if (!e) return e ?? null;
3843
- const n = le(e), r = Array.isArray(n.checkpoints) ? n.checkpoints : n.checkpoints ? Object.values(n.checkpoints) : [], s = /* @__PURE__ */ new Set();
3858
+ const n = le(e), r = Array.isArray(n.checkpoints) ? n.checkpoints : n.checkpoints ? Object.values(n.checkpoints) : [], o = /* @__PURE__ */ new Set();
3844
3859
  for (const c of r) {
3845
3860
  const l = (i = c == null ? void 0 : c.values) == null ? void 0 : i.messages;
3846
3861
  if (Array.isArray(l))
3847
- for (const d of l) {
3848
- const g = d == null ? void 0 : d.content;
3849
- if (Array.isArray(g))
3850
- for (const m of g) {
3851
- if (!m || typeof m != "object" || m.type !== "image_url" && m.type !== "file") continue;
3852
- const I = m.fileId || m.file_id;
3853
- typeof I == "string" && I.trim() && s.add(I);
3862
+ for (const f of l) {
3863
+ const p = f == null ? void 0 : f.content;
3864
+ if (Array.isArray(p))
3865
+ for (const g of p) {
3866
+ if (!g || typeof g != "object" || g.type !== "image_url" && g.type !== "file") continue;
3867
+ const I = g.fileId || g.file_id;
3868
+ typeof I == "string" && I.trim() && o.add(I);
3854
3869
  }
3855
3870
  }
3856
3871
  }
3857
- if (s.size === 0)
3872
+ if (o.size === 0)
3858
3873
  return n;
3859
- const o = await Promise.all(
3860
- Array.from(s).map(async (c) => {
3874
+ const s = await Promise.all(
3875
+ Array.from(o).map(async (c) => {
3861
3876
  try {
3862
- const l = await t.getFileInfo(c), d = le(l);
3863
- return [c, d];
3877
+ const l = await t.getFileInfo(c), f = le(l);
3878
+ return [c, f];
3864
3879
  } catch {
3865
3880
  return [c, null];
3866
3881
  }
3867
3882
  })
3868
- ), a = new Map(o);
3883
+ ), a = new Map(s);
3869
3884
  for (const c of r) {
3870
- const l = (u = c == null ? void 0 : c.values) == null ? void 0 : u.messages;
3885
+ const l = (d = c == null ? void 0 : c.values) == null ? void 0 : d.messages;
3871
3886
  if (Array.isArray(l))
3872
- for (const d of l) {
3873
- const g = d == null ? void 0 : d.content;
3874
- if (Array.isArray(g))
3875
- for (const m of g) {
3876
- if (!m || typeof m != "object" || m.type !== "image_url" && m.type !== "file") continue;
3877
- const I = m.fileId || m.file_id;
3887
+ for (const f of l) {
3888
+ const p = f == null ? void 0 : f.content;
3889
+ if (Array.isArray(p))
3890
+ for (const g of p) {
3891
+ if (!g || typeof g != "object" || g.type !== "image_url" && g.type !== "file") continue;
3892
+ const I = g.fileId || g.file_id;
3878
3893
  if (!I) continue;
3879
- const f = a.get(I), v = (f == null ? void 0 : f.contentUrl) || (f == null ? void 0 : f.content_url);
3880
- v && (m.type === "image_url" ? (m.imageUrl = m.imageUrl || {}, m.imageUrl.url = v) : m.type === "file" && (m.url = v, !m.name && (f != null && f.filename || f != null && f.name) && (m.name = (f == null ? void 0 : f.filename) || (f == null ? void 0 : f.name))));
3894
+ const u = a.get(I), v = (u == null ? void 0 : u.contentUrl) || (u == null ? void 0 : u.content_url);
3895
+ v && (g.type === "image_url" ? (g.imageUrl = g.imageUrl || {}, g.imageUrl.url = v) : g.type === "file" && (g.url = v, !g.name && (u != null && u.filename || u != null && u.name) && (g.name = (u == null ? void 0 : u.filename) || (u == null ? void 0 : u.name))));
3881
3896
  }
3882
3897
  }
3883
3898
  }
3884
3899
  return n;
3885
3900
  }
3886
3901
  function mt(e) {
3887
- const r = [...(Array.isArray(e == null ? void 0 : e.checkpoints) ? (e == null ? void 0 : e.checkpoints) ?? [] : e != null && e.checkpoints ? Object.values(e.checkpoints) : []).map((o, a) => Cr(le(o), a)).filter((o) => !!o)].sort((o, a) => yt(a.createdAt) - yt(o.createdAt)), s = r[0] ?? null;
3902
+ const r = [...(Array.isArray(e == null ? void 0 : e.checkpoints) ? (e == null ? void 0 : e.checkpoints) ?? [] : e != null && e.checkpoints ? Object.values(e.checkpoints) : []).map((s, a) => Cr(le(s), a)).filter((s) => !!s)].sort((s, a) => yt(a.createdAt) - yt(s.createdAt)), o = r[0] ?? null;
3888
3903
  return {
3889
3904
  threadId: (e == null ? void 0 : e.threadId) ?? "",
3890
- latest: s,
3905
+ latest: o,
3891
3906
  checkpoints: r,
3892
- interrupt: (s == null ? void 0 : s.interrupt) ?? null
3907
+ interrupt: (o == null ? void 0 : o.interrupt) ?? null
3893
3908
  };
3894
3909
  }
3895
3910
  function Cr(e, t) {
3896
3911
  var b, h;
3897
3912
  if (!e) return null;
3898
- const n = ((b = e.values) == null ? void 0 : b.activeAgent) ?? null, r = (h = e.values) == null ? void 0 : h.messages, o = (Array.isArray(r) ? r : []).map((T) => Er(T, n)).filter((T) => !!T), a = Re(e.metadata) ?? {}, i = gt(e.config), u = Re(e.parentConfig), c = gt(u), l = Fe(i, ["checkpointId"]), d = Fe(i, ["checkpointNs"]), g = Fe(c, ["checkpointId"]), m = Re(e.config), I = Array.isArray(e.tasks) ? e.tasks.map((T) => ({ ...T })) : e.tasks ?? null, f = Array.isArray(e.next) ? [...e.next] : e.next ?? null, v = typeof e.createdAt == "string" && e.createdAt.trim() ? e.createdAt : new Date(Date.now() - t).toISOString(), x = {
3913
+ const n = ((b = e.values) == null ? void 0 : b.activeAgent) ?? null, r = (h = e.values) == null ? void 0 : h.messages, s = (Array.isArray(r) ? r : []).map((T) => Er(T, n)).filter((T) => !!T), a = Re(e.metadata) ?? {}, i = gt(e.config), d = Re(e.parentConfig), c = gt(d), l = Fe(i, ["checkpointId"]), f = Fe(i, ["checkpointNs"]), p = Fe(c, ["checkpointId"]), g = Re(e.config), I = Array.isArray(e.tasks) ? e.tasks.map((T) => ({ ...T })) : e.tasks ?? null, u = 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(), x = {
3899
3914
  ...a,
3900
3915
  step: Sr(a, ["step"]) ?? 0,
3901
3916
  source: Fe(a, ["source"]) ?? null
3902
- }, M = o.map((T) => ({
3917
+ }, M = s.map((T) => ({
3903
3918
  ...T,
3904
3919
  checkpointId: T.checkpointId ?? l ?? null,
3905
- checkpointNs: T.checkpointNs ?? d ?? null
3906
- })), A = e.values, k = Array.isArray(e.interrupts) ? e.interrupts : Array.isArray(A == null ? void 0 : A.interrupts) ? A.interrupts : [];
3920
+ checkpointNs: T.checkpointNs ?? f ?? null
3921
+ })), A = e.values, w = Array.isArray(e.interrupts) ? e.interrupts : Array.isArray(A == null ? void 0 : A.interrupts) ? A.interrupts : [];
3907
3922
  return {
3908
3923
  checkpointId: l ?? null,
3909
- checkpointNs: d ?? null,
3924
+ checkpointNs: f ?? null,
3910
3925
  createdAt: v,
3911
- parentId: g ?? null,
3926
+ parentId: p ?? null,
3912
3927
  messages: M,
3913
3928
  interrupt: Pr(
3914
- k,
3929
+ w,
3915
3930
  t,
3916
3931
  l ?? null
3917
3932
  ),
3918
3933
  metadata: x,
3919
- config: m ?? null,
3920
- parentConfig: u ?? null,
3921
- next: f,
3934
+ config: g ?? null,
3935
+ parentConfig: d ?? null,
3936
+ next: u,
3922
3937
  tasks: I,
3923
3938
  values: e.values ?? {}
3924
3939
  };
@@ -3929,15 +3944,15 @@ function Er(e, t) {
3929
3944
  }
3930
3945
  function Pr(e, t, n) {
3931
3946
  const r = e.length;
3932
- for (let s = r - 1; s >= 0; s -= 1) {
3933
- const o = e[s];
3934
- if (!o || typeof o != "object")
3947
+ for (let o = r - 1; o >= 0; o -= 1) {
3948
+ const s = e[o];
3949
+ if (!s || typeof s != "object")
3935
3950
  continue;
3936
- const a = o, i = a.value ?? o;
3951
+ const a = s, i = a.value ?? s;
3937
3952
  if (i == null)
3938
3953
  continue;
3939
3954
  return {
3940
- id: typeof a.id == "string" && a.id.trim() ? a.id : `interrupt-${n ?? t}-${s}`,
3955
+ id: typeof a.id == "string" && a.id.trim() ? a.id : `interrupt-${n ?? t}-${o}`,
3941
3956
  value: i
3942
3957
  };
3943
3958
  }
@@ -3958,58 +3973,58 @@ function _r(e) {
3958
3973
  const n = t.join(" ").replace(/\s+/g, " ").trim();
3959
3974
  return n ? n.length > ht ? `${n.slice(0, ht - 3)}…` : n : "";
3960
3975
  }
3961
- function zr(e) {
3976
+ function Nr(e) {
3962
3977
  return _r(e.content) || "";
3963
3978
  }
3964
- function Nr(e) {
3965
- const t = /* @__PURE__ */ new Map(), n = [], r = /* @__PURE__ */ new Map(), s = [];
3979
+ function zr(e) {
3980
+ const t = /* @__PURE__ */ new Map(), n = [], r = /* @__PURE__ */ new Map(), o = [];
3966
3981
  for (let c = 0; c < e.length; c++) {
3967
- const l = e[c], d = l.checkpointId, g = d ?? `cp-${c}`, m = l.metadata ?? {}, I = typeof m.step == "number" ? m.step : null, f = typeof m.source == "string" ? m.source : null;
3982
+ const l = e[c], f = l.checkpointId, p = f ?? `cp-${c}`, g = l.metadata ?? {}, I = typeof g.step == "number" ? g.step : null, u = typeof g.source == "string" ? g.source : null;
3968
3983
  let v = null, x = null;
3969
3984
  const M = Array.isArray(l.messages) ? l.messages : [];
3970
3985
  for (const h of M)
3971
3986
  h.role === "user" && (x || (x = h), h.id && (v = h.id));
3972
- const A = l.next && l.next.length > 0 ? String(l.next[0]) : null, k = l.parentConfig ?? null, b = {
3973
- id: g,
3987
+ const A = l.next && l.next.length > 0 ? String(l.next[0]) : null, w = l.parentConfig ?? null, b = {
3988
+ id: p,
3974
3989
  step: I,
3975
- source: f,
3990
+ source: u,
3976
3991
  createdAt: l.createdAt ?? null,
3977
3992
  namespace: l.checkpointNs ?? null,
3978
3993
  parentId: l.parentId ?? null,
3979
3994
  next: A,
3980
- parentConfig: k,
3995
+ parentConfig: w,
3981
3996
  userMessageId: v
3982
3997
  };
3983
- if (s.push(b), d && t.set(d, b), d && x) {
3984
- const h = zr(x);
3985
- h && r.set(d, h);
3998
+ if (o.push(b), f && t.set(f, b), f && x) {
3999
+ const h = Nr(x);
4000
+ h && r.set(f, h);
3986
4001
  }
3987
4002
  n.push({
3988
- id: g,
4003
+ id: p,
3989
4004
  messageId: v,
3990
4005
  step: I,
3991
- source: f,
4006
+ source: u,
3992
4007
  createdAt: l.createdAt ?? null,
3993
4008
  next: A,
3994
- parentConfig: k
4009
+ parentConfig: w
3995
4010
  });
3996
4011
  }
3997
- const o = /* @__PURE__ */ new Map();
3998
- for (const c of s) {
4012
+ const s = /* @__PURE__ */ new Map();
4013
+ for (const c of o) {
3999
4014
  if (!c.userMessageId) continue;
4000
- const l = o.get(c.userMessageId) ?? [];
4001
- l.push(c), o.set(c.userMessageId, l);
4015
+ const l = s.get(c.userMessageId) ?? [];
4016
+ l.push(c), s.set(c.userMessageId, l);
4002
4017
  }
4003
- for (const c of o.values()) {
4018
+ for (const c of s.values()) {
4004
4019
  if (!c.length) continue;
4005
- c.sort((d, g) => {
4006
- const m = d.createdAt ? Date.parse(d.createdAt) : 0;
4007
- return (g.createdAt ? Date.parse(g.createdAt) : 0) - m;
4020
+ c.sort((f, p) => {
4021
+ const g = f.createdAt ? Date.parse(f.createdAt) : 0;
4022
+ return (p.createdAt ? Date.parse(p.createdAt) : 0) - g;
4008
4023
  });
4009
4024
  const l = c.length;
4010
- for (let d = 0; d < c.length; d++) {
4011
- const g = c[d];
4012
- g.attemptCount = l, g.attemptIndex = d, g.isLatestAttempt = d === 0;
4025
+ for (let f = 0; f < c.length; f++) {
4026
+ const p = c[f];
4027
+ p.attemptCount = l, p.attemptIndex = f, p.isLatestAttempt = f === 0;
4013
4028
  }
4014
4029
  }
4015
4030
  return {
@@ -4025,120 +4040,120 @@ function Nr(e) {
4025
4040
  getCheckpoint: (c) => t.get(c),
4026
4041
  getMessageAttempts: (c) => {
4027
4042
  const l = [];
4028
- for (const d of t.values())
4029
- d.userMessageId === c && l.push(d);
4030
- return l.length ? (l.sort((d, g) => {
4031
- const m = typeof d.attemptIndex == "number" ? d.attemptIndex : Number.MAX_SAFE_INTEGER, I = typeof g.attemptIndex == "number" ? g.attemptIndex : Number.MAX_SAFE_INTEGER;
4032
- return m - I;
4043
+ for (const f of t.values())
4044
+ f.userMessageId === c && l.push(f);
4045
+ return l.length ? (l.sort((f, p) => {
4046
+ const g = typeof f.attemptIndex == "number" ? f.attemptIndex : Number.MAX_SAFE_INTEGER, I = typeof p.attemptIndex == "number" ? p.attemptIndex : Number.MAX_SAFE_INTEGER;
4047
+ return g - I;
4033
4048
  }), l) : [];
4034
4049
  }
4035
4050
  };
4036
4051
  }
4037
- function us(e, t, n) {
4052
+ function uo(e, t, n) {
4038
4053
  if (!e)
4039
4054
  return { attemptCount: 1, attemptIndex: 0, attempts: [] };
4040
4055
  const r = n.getMessageAttempts(e);
4041
4056
  if (!r.length)
4042
4057
  return { attemptCount: 1, attemptIndex: 0, attempts: [] };
4043
- let s = 0;
4058
+ let o = 0;
4044
4059
  if (t) {
4045
- const o = r.findIndex((a) => a.id === t);
4046
- o >= 0 && (s = o);
4060
+ const s = r.findIndex((a) => a.id === t);
4061
+ s >= 0 && (o = s);
4047
4062
  }
4048
4063
  return {
4049
4064
  attemptCount: r.length,
4050
- attemptIndex: s,
4065
+ attemptIndex: o,
4051
4066
  attempts: r
4052
4067
  };
4053
4068
  }
4054
4069
  function Rr(e) {
4055
- return Y(() => Nr(e), [e]);
4070
+ return Y(() => zr(e), [e]);
4056
4071
  }
4057
4072
  function $t({
4058
4073
  api: e,
4059
4074
  fileApi: t,
4060
4075
  seed: n,
4061
4076
  onError: r,
4062
- currentThreadId: s,
4063
- autoLoadInitial: o = !0,
4077
+ currentThreadId: o,
4078
+ autoLoadInitial: s = !0,
4064
4079
  isStreaming: a,
4065
4080
  getMessages: i
4066
4081
  }) {
4067
- const [u, c] = $(null), d = Y(
4068
- () => mt(u),
4069
- [u]
4070
- ).checkpoints, g = Rr(d), m = g.timeline, [I, f] = $(!1), [v, x] = $(!1), [M, A] = $(!1), [k, b] = $(null), h = W(s), T = W(null), p = W(null);
4082
+ const [d, c] = $(null), f = Y(
4083
+ () => mt(d),
4084
+ [d]
4085
+ ).checkpoints, p = Rr(f), g = p.timeline, [I, u] = $(!1), [v, x] = $(!1), [M, A] = $(!1), [w, b] = $(null), h = G(o), T = G(null), m = G(null);
4071
4086
  X(() => {
4072
- h.current = s;
4073
- }, [s]);
4074
- const w = _(
4075
- async (E) => {
4087
+ h.current = o;
4088
+ }, [o]);
4089
+ const k = _(
4090
+ async (P) => {
4076
4091
  const B = await e.getState({
4077
- threadId: E.threadId,
4078
- checkpointId: E.checkpointId,
4079
- checkpointNs: E.checkpointNs
4092
+ threadId: P.threadId,
4093
+ checkpointId: P.checkpointId,
4094
+ checkpointNs: P.checkpointNs
4080
4095
  }), z = {
4081
4096
  version: "values@1",
4082
- threadId: E.threadId,
4097
+ threadId: P.threadId,
4083
4098
  checkpoints: [B]
4084
- }, K = t ? await Mr(z, t) : z, { latest: N } = mt(K);
4085
- return N;
4099
+ }, J = t ? await Mr(z, t) : z, { latest: U } = mt(J);
4100
+ return U;
4086
4101
  },
4087
4102
  [e, t]
4088
- ), P = _(
4089
- async (E, B) => {
4090
- var N;
4091
- if (!E) return;
4092
- const z = `${E}:${B ?? "latest"}`;
4103
+ ), E = _(
4104
+ async (P, B) => {
4105
+ var U;
4106
+ if (!P) return;
4107
+ const z = `${P}:${B ?? "latest"}`;
4093
4108
  if (T.current === z || I) return;
4094
- (N = p.current) == null || N.abort();
4095
- const K = new AbortController();
4096
- p.current = K, f(!0), b(null);
4109
+ (U = m.current) == null || U.abort();
4110
+ const J = new AbortController();
4111
+ m.current = J, u(!0), b(null);
4097
4112
  try {
4098
- const L = await w({
4099
- threadId: E,
4113
+ const R = await k({
4114
+ threadId: P,
4100
4115
  checkpointId: B ?? void 0
4101
4116
  });
4102
- if (h.current !== E) {
4103
- f(!1);
4117
+ if (h.current !== P) {
4118
+ u(!1);
4104
4119
  return;
4105
4120
  }
4106
- n((L == null ? void 0 : L.messages) ?? [], {
4107
- checkpointId: (L == null ? void 0 : L.checkpointId) ?? null,
4108
- checkpointNs: (L == null ? void 0 : L.checkpointNs) ?? null,
4109
- pendingInterrupt: (L == null ? void 0 : L.interrupt) ?? null,
4110
- values: L == null ? void 0 : L.values
4111
- }), T.current = z, f(!1), A(!0);
4121
+ n((R == null ? void 0 : R.messages) ?? [], {
4122
+ checkpointId: (R == null ? void 0 : R.checkpointId) ?? null,
4123
+ checkpointNs: (R == null ? void 0 : R.checkpointNs) ?? null,
4124
+ pendingInterrupt: (R == null ? void 0 : R.interrupt) ?? null,
4125
+ values: R == null ? void 0 : R.values
4126
+ }), T.current = z, u(!1), A(!0);
4112
4127
  try {
4113
- const H = await e.getStateHistory({
4114
- threadId: E,
4128
+ const q = await e.getStateHistory({
4129
+ threadId: P,
4115
4130
  limit: 100,
4116
4131
  includeMessages: !1
4117
4132
  });
4118
- h.current === E && c(H);
4133
+ h.current === P && c(q);
4119
4134
  } finally {
4120
4135
  A(!1);
4121
4136
  }
4122
- } catch (L) {
4123
- if (f(!1), !Xt(L)) {
4124
- const H = String(L);
4125
- b(H), r == null || r(H);
4137
+ } catch (R) {
4138
+ if (u(!1), !Xt(R)) {
4139
+ const q = String(R);
4140
+ b(q), r == null || r(q);
4126
4141
  }
4127
4142
  }
4128
4143
  },
4129
- [e, n, w, r, i]
4144
+ [e, n, k, r, i]
4130
4145
  ), j = _(
4131
- async (E, B) => {
4132
- if (s) {
4146
+ async (P, B) => {
4147
+ if (o) {
4133
4148
  x(!0);
4134
4149
  try {
4135
- const z = await w({
4136
- threadId: s,
4137
- checkpointId: E,
4150
+ const z = await k({
4151
+ threadId: o,
4152
+ checkpointId: P,
4138
4153
  checkpointNs: B ?? void 0
4139
4154
  });
4140
4155
  n((z == null ? void 0 : z.messages) ?? [], {
4141
- checkpointId: (z == null ? void 0 : z.checkpointId) ?? E,
4156
+ checkpointId: (z == null ? void 0 : z.checkpointId) ?? P,
4142
4157
  checkpointNs: (z == null ? void 0 : z.checkpointNs) ?? B,
4143
4158
  pendingInterrupt: (z == null ? void 0 : z.interrupt) ?? null,
4144
4159
  values: z == null ? void 0 : z.values
@@ -4150,48 +4165,36 @@ function $t({
4150
4165
  }
4151
4166
  }
4152
4167
  },
4153
- [s, w, n]
4168
+ [o, k, n]
4154
4169
  ), C = _(async () => {
4155
- s && await P(s);
4156
- }, [s, P]), O = _(
4157
- async (E) => {
4158
- var K;
4159
- const B = (E == null ? void 0 : E.threadId) || s;
4160
- if (!B || s !== B) return;
4161
- if (c(E), T.current = `${B}:latest`, (K = E.values) != null && K.messages) {
4162
- const N = await w({
4163
- threadId: B
4164
- });
4165
- N && n(N.messages ?? [], {
4166
- checkpointId: N.checkpointId ?? null,
4167
- checkpointNs: N.checkpointNs ?? null,
4168
- pendingInterrupt: N.interrupt ?? null,
4169
- values: N.values
4170
- });
4171
- }
4170
+ o && await E(o);
4171
+ }, [o, E]), O = _(
4172
+ async (P) => {
4173
+ const B = (P == null ? void 0 : P.threadId) || o;
4174
+ !B || o !== B || (c(P), T.current = `${B}:latest`);
4172
4175
  },
4173
- [s, w, n]
4176
+ [o]
4174
4177
  );
4175
4178
  X(() => {
4176
- if (!o || !s || I || a) return;
4177
- const E = `${s}:latest`;
4178
- T.current !== E && P(s);
4179
- }, [o, s, I, a, P]);
4179
+ if (!s || !o || I || a) return;
4180
+ const P = `${o}:latest`;
4181
+ T.current !== P && E(o);
4182
+ }, [s, o, I, a, E]);
4180
4183
  const F = _(() => {
4181
- c(null), f(!1), x(!1), A(!1), b(null), T.current = null;
4184
+ c(null), u(!1), x(!1), A(!1), b(null), T.current = null;
4182
4185
  }, []);
4183
4186
  return {
4184
- threadCheckpoints: d,
4185
- threadTimeline: m,
4186
- checkpointIndex: g,
4187
+ threadCheckpoints: f,
4188
+ threadTimeline: g,
4189
+ checkpointIndex: p,
4187
4190
  isLoadingThread: I,
4188
4191
  isLoadingCheckpoint: v,
4189
4192
  isLoadingHistory: M,
4190
- threadStateError: k,
4191
- loadThread: P,
4193
+ threadStateError: w,
4194
+ loadThread: E,
4192
4195
  navigateToCheckpoint: j,
4193
- setCurrentCheckpointId: (E, B) => {
4194
- n(i(), { checkpointId: E, checkpointNs: B });
4196
+ setCurrentCheckpointId: (P, B) => {
4197
+ n(i(), { checkpointId: P, checkpointNs: B });
4195
4198
  },
4196
4199
  returnToLatest: C,
4197
4200
  handleValuesEvent: O,
@@ -4205,80 +4208,80 @@ function $t({
4205
4208
  }
4206
4209
  const Dt = Ce(null), Kt = Ce(null);
4207
4210
  function Vt(e) {
4208
- const t = Ue(Dt);
4211
+ const t = je(Dt);
4209
4212
  if (!t && !(e != null && e.optional)) throw new Error("useThreadState must be used within a ThreadStateProvider");
4210
4213
  return t;
4211
4214
  }
4212
4215
  function Lr() {
4213
- const e = Ue(Kt);
4216
+ const e = je(Kt);
4214
4217
  if (!e)
4215
4218
  throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");
4216
4219
  return e;
4217
4220
  }
4218
- function Ur({
4221
+ function jr({
4219
4222
  children: e,
4220
4223
  initialThreadId: t = null,
4221
4224
  initialCheckpointId: n = null,
4222
4225
  initialCheckpointNs: r = null,
4223
- autoLoadInitial: s = !0,
4224
- isStreaming: o,
4226
+ autoLoadInitial: o = !0,
4227
+ isStreaming: s,
4225
4228
  onError: a
4226
4229
  }) {
4227
- const { chatApi: i, fileApi: u } = Me(), { currentThreadId: c } = st(), { state: l, seed: d, onEvent: g, dispatch: m } = kr(), {
4230
+ const { chatApi: i, fileApi: d } = Me(), { currentThreadId: c } = ot(), { state: l, seed: f, onEvent: p, dispatch: g } = kr(), {
4228
4231
  threadCheckpoints: I,
4229
- threadTimeline: f,
4232
+ threadTimeline: u,
4230
4233
  checkpointIndex: v,
4231
4234
  isLoadingThread: x,
4232
4235
  isLoadingCheckpoint: M,
4233
4236
  isLoadingHistory: A,
4234
- threadStateError: k,
4237
+ threadStateError: w,
4235
4238
  loadThread: b,
4236
4239
  navigateToCheckpoint: h,
4237
4240
  setCurrentCheckpointId: T,
4238
- returnToLatest: p,
4239
- handleValuesEvent: w,
4240
- markSkipNextLoad: P,
4241
+ returnToLatest: m,
4242
+ handleValuesEvent: k,
4243
+ markSkipNextLoad: E,
4241
4244
  markStreamPendingThread: j,
4242
4245
  resetHistoryState: C
4243
4246
  } = $t({
4244
4247
  api: i,
4245
- fileApi: u,
4246
- seed: d,
4248
+ fileApi: d,
4249
+ seed: f,
4247
4250
  onError: a,
4248
4251
  currentThreadId: c,
4249
4252
  initialThreadId: t,
4250
4253
  initialCheckpointId: n,
4251
4254
  initialCheckpointNs: r,
4252
- autoLoadInitial: s,
4253
- isStreaming: o,
4255
+ autoLoadInitial: o,
4256
+ isStreaming: s,
4254
4257
  getMessages: _(() => l.messages, [l.messages])
4255
- }), O = W(null), F = _(
4258
+ }), O = G(null), F = _(
4256
4259
  (S) => {
4257
4260
  O.current = S;
4258
4261
  },
4259
4262
  []
4260
- ), E = W(null), B = _(
4263
+ ), P = G(null), B = _(
4261
4264
  (S) => {
4262
- E.current = S;
4265
+ P.current = S;
4263
4266
  },
4264
4267
  []
4265
- ), z = Y(() => ({ assemblingMessageId: l.assemblingId ?? null }), [l.assemblingId]), K = _(
4266
- (S, J) => {
4267
- const V = Ut(S, "user");
4268
- return m({
4268
+ ), z = Y(() => ({ assemblingMessageId: l.assemblingId ?? null }), [l.assemblingId]), J = _(
4269
+ (S, W) => {
4270
+ const K = jt(S, "user");
4271
+ return g({
4269
4272
  type: "user_message",
4270
4273
  payload: {
4271
- message: V,
4272
- editingMessageId: J == null ? void 0 : J.editingMessageId
4274
+ message: K,
4275
+ editingMessageId: W == null ? void 0 : W.editingMessageId
4273
4276
  }
4274
- }), V;
4277
+ }), K;
4275
4278
  },
4276
- [m]
4277
- ), N = _(async () => {
4278
- O.current ? await O.current() : (d([], {}), C());
4279
- }, [d, C]), L = _(async (S, J, V) => {
4280
- await b(S, J, { clearProgress: !1 });
4281
- }, [b]), H = Y(() => Bn(l.messages), [l.messages]), y = Y(
4279
+ [g]
4280
+ ), U = _(async () => {
4281
+ O.current ? await O.current() : (f([], {}), C());
4282
+ }, [f, C]), R = _(async (S, W, K) => {
4283
+ await b(S, W, { clearProgress: !1 });
4284
+ }, [b]), q = Y(() => Bn(l.messages), [l.messages]), y = Y(
4282
4285
  () => ({
4283
4286
  status: l.status,
4284
4287
  threadId: c,
@@ -4291,41 +4294,41 @@ function Ur({
4291
4294
  },
4292
4295
  checkpoints: I,
4293
4296
  checkpointIndex: v,
4294
- timelineCheckpoints: f,
4297
+ timelineCheckpoints: u,
4295
4298
  metadata: z,
4296
4299
  values: l.values ?? {},
4297
4300
  isLoading: x,
4298
4301
  isLoadingCheckpoint: M,
4299
4302
  isLoadingHistory: A,
4300
- error: k,
4303
+ error: w,
4301
4304
  loadOlder: async () => {
4302
4305
  },
4303
4306
  // Placeholder
4304
4307
  seedFromSnapshot: (S) => {
4305
- d(S.messages, {
4308
+ f(S.messages, {
4306
4309
  checkpointId: S.checkpointId,
4307
4310
  checkpointNs: S.checkpointNs,
4308
4311
  pendingInterrupt: S.interrupt,
4309
4312
  values: S.values
4310
4313
  });
4311
4314
  },
4312
- clearState: N,
4315
+ clearState: U,
4313
4316
  navigateToCheckpoint: h,
4314
4317
  setCurrentCheckpointId: T,
4315
- returnToLatest: p,
4316
- loadThread: L,
4317
- clearThread: N,
4318
- respondToInterrupt: async (S, J, V) => {
4319
- E.current && await E.current(S, J, V);
4318
+ returnToLatest: m,
4319
+ loadThread: R,
4320
+ clearThread: U,
4321
+ respondToInterrupt: async (S, W, K) => {
4322
+ P.current && await P.current(S, W, K);
4320
4323
  },
4321
4324
  messagePreviews: v.messagePreviews,
4322
- handleValuesEvent: w,
4323
- markSkipNextLoad: P,
4325
+ handleValuesEvent: k,
4326
+ markSkipNextLoad: E,
4324
4327
  markStreamPendingThread: j,
4325
4328
  resetHistoryState: C,
4326
- pushUser: K,
4327
- onEvent: g,
4328
- artifacts: H
4329
+ pushUser: J,
4330
+ onEvent: p,
4331
+ artifacts: q
4329
4332
  }),
4330
4333
  [
4331
4334
  c,
@@ -4336,75 +4339,75 @@ function Ur({
4336
4339
  l.lastCheckpointNs,
4337
4340
  l.values,
4338
4341
  I,
4339
- f,
4342
+ u,
4340
4343
  v,
4341
4344
  z,
4342
4345
  x,
4343
4346
  M,
4344
4347
  A,
4345
- k,
4346
- d,
4347
- N,
4348
+ w,
4349
+ f,
4350
+ U,
4348
4351
  h,
4349
4352
  T,
4350
- p,
4351
- L,
4352
- w,
4353
- P,
4353
+ m,
4354
+ R,
4355
+ k,
4356
+ E,
4354
4357
  j,
4355
- K,
4356
- g,
4357
- H
4358
+ J,
4359
+ p,
4360
+ q
4358
4361
  ]
4359
- ), U = Y(
4362
+ ), L = Y(
4360
4363
  () => ({
4361
4364
  registerClearThread: F,
4362
4365
  registerRespondToInterrupt: B
4363
4366
  }),
4364
4367
  [F, B]
4365
4368
  );
4366
- return /* @__PURE__ */ ie(Kt.Provider, { value: U, children: /* @__PURE__ */ ie(Dt.Provider, { value: y, children: e }) });
4369
+ return /* @__PURE__ */ ie(Kt.Provider, { value: L, children: /* @__PURE__ */ ie(Dt.Provider, { value: y, children: e }) });
4367
4370
  }
4368
- const qt = Ce(null), jr = Ce(!1);
4371
+ const qt = Ce(null), Ur = Ce(!1);
4369
4372
  function Br({
4370
4373
  children: e,
4371
4374
  onError: t,
4372
4375
  onAuthError: n,
4373
4376
  onConnectionError: r,
4374
- onToolEnd: s,
4375
- onUpdateEvent: o,
4377
+ onToolEnd: o,
4378
+ onUpdateEvent: s,
4376
4379
  onCustomEvent: a,
4377
4380
  onMetadataEvent: i,
4378
- onFinish: u,
4381
+ onFinish: d,
4379
4382
  onStreamingChange: c
4380
4383
  }) {
4381
- const { chatApi: l, baseUrl: d } = Me(), g = d, m = fe(t), I = fe(n), f = fe(r), v = fe(s), x = fe(o), M = fe(a), A = fe(i), k = fe(u), b = fe(c), h = Y(
4384
+ const { chatApi: l, baseUrl: f } = Me(), p = f, g = fe(t), I = fe(n), u = fe(r), v = fe(o), x = fe(s), M = fe(a), A = fe(i), w = fe(d), b = fe(c), h = Y(
4382
4385
  () => ({
4383
- onError: m,
4386
+ onError: g,
4384
4387
  onAuthError: I,
4385
- onConnectionError: f,
4388
+ onConnectionError: u,
4386
4389
  onMetadataEvent: A,
4387
4390
  onCustomEvent: M,
4388
4391
  onUpdateEvent: x,
4389
4392
  onToolEnd: v,
4390
- onFinish: k
4393
+ onFinish: w
4391
4394
  }),
4392
4395
  [
4393
- m,
4396
+ g,
4394
4397
  I,
4395
- f,
4398
+ u,
4396
4399
  A,
4397
4400
  M,
4398
4401
  x,
4399
4402
  v,
4400
- k
4403
+ w
4401
4404
  ]
4402
4405
  );
4403
- return /* @__PURE__ */ ie(jr.Provider, { value: !0, children: /* @__PURE__ */ ie(
4406
+ return /* @__PURE__ */ ie(Ur.Provider, { value: !0, children: /* @__PURE__ */ ie(
4404
4407
  Fr,
4405
4408
  {
4406
4409
  api: l,
4407
- streamBaseUrl: g,
4410
+ streamBaseUrl: p,
4408
4411
  handlers: h,
4409
4412
  onStreamingChange: b,
4410
4413
  children: e
@@ -4416,30 +4419,30 @@ function Fr({
4416
4419
  api: t,
4417
4420
  streamBaseUrl: n,
4418
4421
  handlers: r,
4419
- onStreamingChange: s
4422
+ onStreamingChange: o
4420
4423
  }) {
4421
- const { setCurrentThreadId: o, currentThreadIdRef: a, addThreadFromEvent: i, currentThreadId: u } = st(), {
4424
+ const { setCurrentThreadId: s, currentThreadIdRef: a, addThreadFromEvent: i, currentThreadId: d } = ot(), {
4422
4425
  interrupt: c,
4423
4426
  checkpoint: l,
4424
- timelineCheckpoints: d,
4425
- handleValuesEvent: g,
4426
- markSkipNextLoad: m,
4427
+ timelineCheckpoints: f,
4428
+ handleValuesEvent: p,
4429
+ markSkipNextLoad: g,
4427
4430
  markStreamPendingThread: I,
4428
- resetHistoryState: f,
4431
+ resetHistoryState: u,
4429
4432
  pushUser: v,
4430
4433
  onEvent: x,
4431
4434
  messages: M
4432
- } = Vt(), { registerClearThread: A, registerRespondToInterrupt: k } = Lr(), b = _(
4435
+ } = Vt(), { registerClearThread: A, registerRespondToInterrupt: w } = Lr(), b = _(
4433
4436
  (y) => {
4434
- i(y), I(y.threadId), a.current !== y.threadId && ((y.created ?? !a.current) && m(y.threadId), o(y.threadId));
4437
+ i(y), I(y.threadId), a.current !== y.threadId && ((y.created ?? !a.current) && g(y.threadId), s(y.threadId));
4435
4438
  },
4436
- [i, m, I, o, a]
4439
+ [i, g, I, s, a]
4437
4440
  ), h = pr({
4438
4441
  baseUrl: n,
4439
4442
  onEvent: x,
4440
4443
  onError: (y) => {
4441
- var U;
4442
- (U = r.onError) == null || U.call(r, (y == null ? void 0 : y.message) ?? String(y));
4444
+ var L;
4445
+ (L = r.onError) == null || L.call(r, (y == null ? void 0 : y.message) ?? String(y));
4443
4446
  },
4444
4447
  onAuthError: r.onAuthError,
4445
4448
  onConnectionError: r.onConnectionError,
@@ -4449,86 +4452,86 @@ function Fr({
4449
4452
  onCustomEvent: r.onCustomEvent,
4450
4453
  onUpdateEvent: r.onUpdateEvent,
4451
4454
  onToolEnd: r.onToolEnd,
4452
- handleValuesEvent: g
4455
+ handleValuesEvent: p
4453
4456
  });
4454
4457
  X(() => {
4455
- s == null || s(h.isStreaming);
4456
- }, [h.isStreaming, s]);
4457
- const { stream: T, stop: p, clear: w, isStreaming: P, error: j, connected: C, streamedMessages: O, activeMessageId: F } = h;
4458
+ o == null || o(h.isStreaming);
4459
+ }, [h.isStreaming, o]);
4460
+ const { stream: T, stop: m, clear: k, isStreaming: E, error: j, connected: C, streamedMessages: O, activeMessageId: F } = h;
4458
4461
  X(() => {
4459
- u !== void 0 && w();
4460
- }, [u, w]);
4461
- const E = _(
4462
- async (y, U) => {
4463
- await T(y, U);
4462
+ d !== void 0 && k();
4463
+ }, [d, k]);
4464
+ const P = _(
4465
+ async (y, L) => {
4466
+ await T(y, L);
4464
4467
  },
4465
4468
  [T]
4466
- ), B = W(l);
4469
+ ), B = G(l);
4467
4470
  X(() => {
4468
4471
  B.current = l;
4469
4472
  }, [l]);
4470
4473
  const z = _(
4471
- async (y, U, S) => {
4472
- var G;
4473
- const J = a.current;
4474
- if (!J)
4474
+ async (y, L, S) => {
4475
+ var H;
4476
+ const W = a.current;
4477
+ if (!W)
4475
4478
  throw new Error("No active thread to handle interrupt");
4476
- const V = y ? U ?? !0 : !1, q = B.current, ee = (S == null ? void 0 : S.checkpointId) ?? q.id ?? void 0, re = (S == null ? void 0 : S.checkpointNs) ?? q.namespace ?? void 0, ue = {
4477
- threadId: J,
4479
+ const K = y ? L ?? !0 : !1, V = B.current, ee = (S == null ? void 0 : S.checkpointId) ?? V.id ?? void 0, re = (S == null ? void 0 : S.checkpointNs) ?? V.namespace ?? void 0, de = {
4480
+ threadId: W,
4478
4481
  checkpointId: ee,
4479
4482
  checkpointNs: re,
4480
- command: { kind: "resume", value: V },
4483
+ command: { kind: "resume", value: K },
4481
4484
  payload: {
4482
4485
  ...(S == null ? void 0 : S.payload) ?? {},
4483
- creativityLevel: ((G = S == null ? void 0 : S.payload) == null ? void 0 : G.creativityLevel) ?? "medium"
4486
+ creativityLevel: ((H = S == null ? void 0 : S.payload) == null ? void 0 : H.creativityLevel) ?? "medium"
4484
4487
  },
4485
4488
  edit: !1
4486
4489
  };
4487
- E(ue);
4490
+ P(de);
4488
4491
  },
4489
- [a, E]
4492
+ [a, P]
4490
4493
  );
4491
4494
  X(() => {
4492
- k(z);
4493
- }, [z, k]);
4494
- const K = _(async () => {
4495
- p(), w(), f(), o(null);
4496
- }, [w, f, o, p]);
4495
+ w(z);
4496
+ }, [z, w]);
4497
+ const J = _(async () => {
4498
+ m(), k(), u(), s(null);
4499
+ }, [k, u, s, m]);
4497
4500
  X(() => {
4498
- A(K);
4499
- }, [K, A]);
4500
- const N = _(
4501
- async (y, U) => {
4502
- P && p();
4501
+ A(J);
4502
+ }, [J, A]);
4503
+ const U = _(
4504
+ async (y, L) => {
4505
+ E && m();
4503
4506
  let S = a.current;
4504
- const J = (y == null ? void 0 : y.text) ?? "", V = (y == null ? void 0 : y.attachments) ?? [], q = (J == null ? void 0 : J.trim()) ?? "", ee = { ...(y == null ? void 0 : y.payload) ?? {} }, re = Array.isArray(ee.messages) ? ee.messages : void 0;
4507
+ const W = (y == null ? void 0 : y.text) ?? "", K = (y == null ? void 0 : y.attachments) ?? [], V = (W == null ? void 0 : W.trim()) ?? "", ee = { ...(y == null ? void 0 : y.payload) ?? {} }, re = Array.isArray(ee.messages) ? ee.messages : void 0;
4505
4508
  re && delete ee.messages;
4506
- const ue = !!(re && re.length), G = !!(y.contentParts && y.contentParts.length > 0);
4507
- if (!S && !q && V.length === 0 && !ue && !G) return;
4509
+ const de = !!(re && re.length), H = !!(y.contentParts && y.contentParts.length > 0);
4510
+ if (!S && !V && K.length === 0 && !de && !H) return;
4508
4511
  if (!S) {
4509
4512
  const ye = Math.floor(Date.now() / 1e3).toString(16).padStart(8, "0"), he = Array.from({ length: 4 }, () => Math.floor(Math.random() * 4294967295).toString(16).padStart(8, "0")).join("").slice(0, 16);
4510
- S = `${ye}${he}`, m(S), o(S);
4513
+ S = `${ye}${he}`, g(S), s(S);
4511
4514
  }
4512
4515
  let te = null;
4513
4516
  y.contentParts && y.contentParts.length > 0 && (te = y.contentParts);
4514
- const { contentParts: ke, filesInfo: Q } = te ? { contentParts: te, filesInfo: [] } : await sr(V), Z = [...ke];
4515
- q && Z.push({ type: "text", text: J });
4516
- const ge = y == null ? void 0 : y.originalMessageId, je = !!(y != null && y.edit && ge), Be = !ue && Z.length > 0;
4517
+ const { contentParts: ke, filesInfo: Q } = te ? { contentParts: te, filesInfo: [] } : await or(K), Z = [...ke];
4518
+ V && Z.push({ type: "text", text: W });
4519
+ const ge = y == null ? void 0 : y.originalMessageId, Ue = !!(y != null && y.edit && ge), Be = !de && Z.length > 0;
4517
4520
  let me = null;
4518
4521
  if (Be) {
4519
- const ye = je ? ge : `msg-${Date.now()}`;
4520
- me = Ut({
4522
+ const ye = Ue ? ge : `msg-${Date.now()}`;
4523
+ me = jt({
4521
4524
  id: ye,
4522
4525
  role: "user",
4523
4526
  content: Z,
4524
4527
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
4525
- }, "user"), je ? v(me, { editingMessageId: ge }) : v(me);
4528
+ }, "user"), Ue ? v(me, { editingMessageId: ge }) : v(me);
4526
4529
  }
4527
- const ve = ue ? re : me ? [me] : [], se = {
4530
+ const ve = de ? re : me ? [me] : [], oe = {
4528
4531
  ...ee,
4529
4532
  ...Q.length ? { files_info: Q } : {}
4530
4533
  };
4531
- ve.length ? se.messages = ve : "messages" in se || (se.messages = []);
4534
+ ve.length ? oe.messages = ve : "messages" in oe || (oe.messages = []);
4532
4535
  const Pe = (y == null ? void 0 : y.checkpointId) ?? l.id ?? void 0;
4533
4536
  if (y != null && y.edit && !Pe)
4534
4537
  throw new Error(
@@ -4537,37 +4540,37 @@ function Fr({
4537
4540
  const xe = {
4538
4541
  threadId: S,
4539
4542
  content: y == null ? void 0 : y.text,
4540
- payload: se,
4543
+ payload: oe,
4541
4544
  config: y == null ? void 0 : y.config,
4542
4545
  checkpointId: Pe,
4543
4546
  command: y == null ? void 0 : y.command,
4544
4547
  edit: y == null ? void 0 : y.edit
4545
4548
  };
4546
- return E(xe, U);
4549
+ return P(xe, L);
4547
4550
  },
4548
- [l, a, P, m, v, E, p, d]
4549
- ), L = Y(() => M, [M]), H = Y(
4551
+ [l, a, E, g, v, P, m, f]
4552
+ ), R = Y(() => M, [M]), q = Y(
4550
4553
  () => ({
4551
- isStreaming: P,
4554
+ isStreaming: E,
4552
4555
  error: j,
4553
- connectionState: j ? "error" : P ? C ? "connected" : "connecting" : "idle",
4554
- messages: L,
4556
+ connectionState: j ? "error" : E ? C ? "connected" : "connecting" : "idle",
4557
+ messages: R,
4555
4558
  activeMessageId: F,
4556
- submit: N,
4557
- stop: p,
4559
+ submit: U,
4560
+ stop: m,
4558
4561
  interrupt: c,
4559
4562
  resume: () => Promise.resolve(),
4560
- goto: (y, U) => Promise.resolve(),
4563
+ goto: (y, L) => Promise.resolve(),
4561
4564
  clearError: () => {
4562
4565
  }
4563
4566
  // TODO: Implement error clearing
4564
4567
  }),
4565
- [P, j, N, p, c, C, L]
4568
+ [E, j, U, m, c, C, R]
4566
4569
  );
4567
- return /* @__PURE__ */ ie(qt.Provider, { value: H, children: e });
4570
+ return /* @__PURE__ */ ie(qt.Provider, { value: q, children: e });
4568
4571
  }
4569
4572
  function fe(e) {
4570
- const t = W(e);
4573
+ const t = G(e);
4571
4574
  return X(() => {
4572
4575
  t.current = e;
4573
4576
  }, [e]), _((...n) => {
@@ -4577,7 +4580,7 @@ function fe(e) {
4577
4580
  }, []);
4578
4581
  }
4579
4582
  function Or(e) {
4580
- return Ue(qt);
4583
+ return je(qt);
4581
4584
  }
4582
4585
  function bt(e) {
4583
4586
  return typeof e == "object" && e !== null;
@@ -4588,78 +4591,78 @@ function $r(e, t) {
4588
4591
  const n = Object.keys(e), r = Object.keys(t);
4589
4592
  if (n.length !== r.length)
4590
4593
  return !1;
4591
- for (const s of n)
4592
- if (!Object.prototype.hasOwnProperty.call(t, s) || !Object.is(e[s], t[s]))
4594
+ for (const o of n)
4595
+ if (!Object.prototype.hasOwnProperty.call(t, o) || !Object.is(e[o], t[o]))
4593
4596
  return !1;
4594
4597
  return !0;
4595
4598
  }
4596
4599
  function Dr(e) {
4597
- const t = W(e), n = W(e);
4600
+ const t = G(e), n = G(e);
4598
4601
  return $r(t.current, e) || (t.current = e, n.current = e), n.current;
4599
4602
  }
4600
4603
  function Kr(e) {
4601
- const t = e.artifact && typeof e.artifact == "object" ? e.artifact : null, n = !t && e.content && typeof e.content == "object" ? e.content : null, r = t ?? n, s = (r == null ? void 0 : r.task_id) ?? (r == null ? void 0 : r.taskId) ?? null;
4602
- return typeof s == "string" ? s : null;
4604
+ 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;
4605
+ return typeof o == "string" ? o : null;
4603
4606
  }
4604
- function ds(e) {
4607
+ function fo(e) {
4605
4608
  const { setCurrentTaskId: t, getCurrentTaskId: n, onToolEnd: r } = e;
4606
- return (s) => {
4607
- const o = Kr(s), a = (n == null ? void 0 : n()) ?? null;
4608
- o && o !== a && t(o), r == null || r(s);
4609
+ return (o) => {
4610
+ const s = Kr(o), a = (n == null ? void 0 : n()) ?? null;
4611
+ s && s !== a && t(s), r == null || r(o);
4609
4612
  };
4610
4613
  }
4611
- function fs({
4614
+ function po({
4612
4615
  children: e,
4613
4616
  apiConfig: t,
4614
4617
  initialThreadId: n = null,
4615
4618
  initialCheckpointId: r = null,
4616
- initialCheckpointNs: s = null,
4617
- autoLoadInitial: o = !0,
4619
+ initialCheckpointNs: o = null,
4620
+ autoLoadInitial: s = !0,
4618
4621
  onConnectionError: a,
4619
4622
  onError: i,
4620
- onAuthError: u,
4623
+ onAuthError: d,
4621
4624
  onThreadChange: c,
4622
4625
  onToolEnd: l,
4623
- onUpdateEvent: d,
4624
- onCustomEvent: g,
4625
- onMetadataEvent: m,
4626
+ onUpdateEvent: f,
4627
+ onCustomEvent: p,
4628
+ onMetadataEvent: g,
4626
4629
  onFinish: I
4627
4630
  }) {
4628
- const f = Dr(t), [v, x] = $(!1), M = pe(i), A = pe(u), k = pe(a), b = pe(c), h = pe(l), T = pe(d), p = pe(g), w = pe(m), P = pe(I), j = Y(
4631
+ const u = Dr(t), [v, x] = $(!1), M = pe(i), A = pe(d), w = pe(a), b = pe(c), h = pe(l), T = pe(f), m = pe(p), k = pe(g), E = pe(I), j = Y(
4629
4632
  () => ({
4630
4633
  onError: M,
4631
4634
  onAuthError: A,
4632
- onConnectionError: k,
4635
+ onConnectionError: w,
4633
4636
  onToolEnd: h,
4634
4637
  onUpdateEvent: T,
4635
- onCustomEvent: p,
4636
- onMetadataEvent: w,
4637
- onFinish: P
4638
+ onCustomEvent: m,
4639
+ onMetadataEvent: k,
4640
+ onFinish: E
4638
4641
  }),
4639
4642
  [
4640
4643
  M,
4641
4644
  A,
4642
- k,
4645
+ w,
4643
4646
  h,
4644
4647
  T,
4645
- p,
4646
- w,
4647
- P
4648
+ m,
4649
+ k,
4650
+ E
4648
4651
  ]
4649
4652
  );
4650
- return /* @__PURE__ */ ie(nr, { apiConfig: f, children: /* @__PURE__ */ ie(
4653
+ return /* @__PURE__ */ ie(nr, { apiConfig: u, children: /* @__PURE__ */ ie(
4651
4654
  mr,
4652
4655
  {
4653
4656
  initialThreadId: n,
4654
4657
  onError: M,
4655
4658
  onThreadChange: b,
4656
4659
  children: /* @__PURE__ */ ie(
4657
- Ur,
4660
+ jr,
4658
4661
  {
4659
4662
  initialThreadId: n,
4660
4663
  initialCheckpointId: r,
4661
- initialCheckpointNs: s,
4662
- autoLoadInitial: o,
4664
+ initialCheckpointNs: o,
4665
+ autoLoadInitial: s,
4663
4666
  onError: M,
4664
4667
  isStreaming: v,
4665
4668
  children: /* @__PURE__ */ ie(
@@ -4676,7 +4679,7 @@ function fs({
4676
4679
  ) });
4677
4680
  }
4678
4681
  function pe(e) {
4679
- const t = W(e);
4682
+ const t = G(e);
4680
4683
  return t.current = e, _((...n) => {
4681
4684
  const r = t.current;
4682
4685
  if (r)
@@ -4743,9 +4746,9 @@ function Le(e) {
4743
4746
  });
4744
4747
  }
4745
4748
  function Wr({ ...e }) {
4746
- const t = Hr(), n = (s) => Le({
4749
+ const t = Hr(), n = (o) => Le({
4747
4750
  type: "UPDATE_TOAST",
4748
- toast: { ...s, id: t }
4751
+ toast: { ...o, id: t }
4749
4752
  }), r = () => Le({ type: "DISMISS_TOAST", toastId: t });
4750
4753
  return Le({
4751
4754
  type: "ADD_TOAST",
@@ -4753,8 +4756,8 @@ function Wr({ ...e }) {
4753
4756
  ...e,
4754
4757
  id: t,
4755
4758
  open: !0,
4756
- onOpenChange: (s) => {
4757
- s || r();
4759
+ onOpenChange: (o) => {
4760
+ o || r();
4758
4761
  }
4759
4762
  }
4760
4763
  }), {
@@ -4774,56 +4777,56 @@ function Jr() {
4774
4777
  dismiss: (n) => Le({ type: "DISMISS_TOAST", toastId: n })
4775
4778
  };
4776
4779
  }
4777
- function ps(e) {
4778
- const { allowFileOpen: t, currentThreadId: n } = e, { fileApi: r } = Me(), { toast: s } = Jr(), [o, a] = $({}), [i, u] = $(null), [c, l] = $(!1), d = _(() => {
4779
- l(!1), u(null);
4780
- }, []), g = _((I) => {
4781
- u(I), l(!0);
4782
- }, []), m = _(
4783
- async (I, f, v) => {
4780
+ function go(e) {
4781
+ const { allowFileOpen: t, currentThreadId: n } = e, { fileApi: r } = Me(), { toast: o } = Jr(), [s, a] = $({}), [i, d] = $(null), [c, l] = $(!1), f = _(() => {
4782
+ l(!1), d(null);
4783
+ }, []), p = _((I) => {
4784
+ d(I), l(!0);
4785
+ }, []), g = _(
4786
+ async (I, u, v) => {
4784
4787
  var x, M;
4785
4788
  if (!t) {
4786
4789
  I.preventDefault();
4787
4790
  return;
4788
4791
  }
4789
- if (o[v]) {
4792
+ if (s[v]) {
4790
4793
  I.preventDefault();
4791
4794
  return;
4792
4795
  }
4793
4796
  try {
4794
- const A = String(f.url ?? ""), k = A.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);
4795
- if (k) {
4797
+ const A = String(u.url ?? ""), w = A.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);
4798
+ if (w) {
4796
4799
  I.preventDefault();
4797
- const b = k[1], h = f.name || `file_${b}`, T = f.mimeType || "application/octet-stream";
4798
- g({ id: b, name: h, mimeType: T });
4800
+ const b = w[1], h = u.name || `file_${b}`, T = u.mimeType || "application/octet-stream";
4801
+ p({ id: b, name: h, mimeType: T });
4799
4802
  return;
4800
4803
  }
4801
4804
  if (A.startsWith("data:")) {
4802
4805
  I.preventDefault(), a((h) => ({ ...h, [v]: !0 }));
4803
- const b = s({ title: "Fetching file...", description: "", open: !0 });
4806
+ const b = o({ title: "Fetching file...", description: "", open: !0 });
4804
4807
  try {
4805
4808
  const h = await r.listFiles(n ?? void 0);
4806
4809
  if (!h || !Array.isArray(h))
4807
4810
  throw new Error("Invalid file list response");
4808
- const T = h.find((p) => !p || typeof p != "object" || !((p.filename ?? "") === (f.name ?? "")) ? !1 : typeof f.size == "number" && typeof p.size == "number" ? p.size === f.size : !0);
4811
+ const T = h.find((m) => !m || typeof m != "object" || !((m.filename ?? "") === (u.name ?? "")) ? !1 : typeof u.size == "number" && typeof m.size == "number" ? m.size === u.size : !0);
4809
4812
  if (!(T != null && T.id))
4810
- throw new Error(`File "${f.name}" is not yet available on the server`);
4813
+ throw new Error(`File "${u.name}" is not yet available on the server`);
4811
4814
  if (!T.id || !T.filename)
4812
4815
  throw new Error("Invalid file data received from server");
4813
- g({
4816
+ p({
4814
4817
  id: T.id,
4815
- name: f.name || T.filename || `file_${T.id}`,
4816
- mimeType: f.mimeType || T.mime_type || "application/octet-stream"
4818
+ name: u.name || T.filename || `file_${T.id}`,
4819
+ mimeType: u.mimeType || T.mime_type || "application/octet-stream"
4817
4820
  }), (x = b.update) == null || x.call(b, {
4818
4821
  id: b.id,
4819
4822
  title: "Success",
4820
- description: `Opened ${f.name}`,
4823
+ description: `Opened ${u.name}`,
4821
4824
  open: !0
4822
4825
  });
4823
4826
  } catch (h) {
4824
4827
  console.error("Failed to fetch server file:", h);
4825
4828
  const T = h instanceof Error ? h.message : "Unknown error occurred";
4826
- (M = b.update) == null || M.call(b, { id: b.id, title: "Failed", description: T }), s({
4829
+ (M = b.update) == null || M.call(b, { id: b.id, title: "Failed", description: T }), o({
4827
4830
  title: "Failed to fetch file",
4828
4831
  description: T,
4829
4832
  open: !0
@@ -4833,26 +4836,26 @@ function ps(e) {
4833
4836
  }
4834
4837
  }
4835
4838
  } catch (A) {
4836
- console.error("File click error:", A), a((k) => ({ ...k, [v]: !1 }));
4839
+ console.error("File click error:", A), a((w) => ({ ...w, [v]: !1 }));
4837
4840
  }
4838
4841
  },
4839
- [t, o, s, n, g]
4842
+ [t, s, o, n, p]
4840
4843
  );
4841
4844
  return {
4842
- uploadingFiles: o,
4843
- handleFileClick: m,
4845
+ uploadingFiles: s,
4846
+ handleFileClick: g,
4844
4847
  fileViewerOpen: c,
4845
4848
  currentFileInfo: i,
4846
- closeFileViewer: d
4849
+ closeFileViewer: f
4847
4850
  };
4848
4851
  }
4849
- function gs(e) {
4852
+ function mo(e) {
4850
4853
  return Y(() => {
4851
4854
  const t = e;
4852
4855
  let n = Array.isArray(t.content) ? t.content : [];
4853
4856
  return typeof t.content == "string" && (n = [{ type: "text", text: t.content }]), {
4854
4857
  contentParts: n,
4855
- textContent: or(n),
4858
+ textContent: sr(n),
4856
4859
  toolMeta: ar(t),
4857
4860
  imageParts: n.filter((r) => r.type === "image_url"),
4858
4861
  fileParts: n.filter((r) => r.type === "file"),
@@ -4866,13 +4869,13 @@ function Xr(e) {
4866
4869
  if (!e) return [];
4867
4870
  const t = [], n = e.split(/\r?\n/);
4868
4871
  for (const r of n) {
4869
- const s = r.trim();
4870
- if (!s || !s.startsWith(kt))
4872
+ const o = r.trim();
4873
+ if (!o || !o.startsWith(kt))
4871
4874
  continue;
4872
- const o = s.slice(kt.length).trim();
4873
- if (!o || o.toLowerCase() === "[done]")
4875
+ const s = o.slice(kt.length).trim();
4876
+ if (!s || s.toLowerCase() === "[done]")
4874
4877
  continue;
4875
- const a = tt(o);
4878
+ const a = tt(s);
4876
4879
  a && typeof a == "object" && t.push(a);
4877
4880
  }
4878
4881
  return t;
@@ -4885,58 +4888,58 @@ function Qr(e) {
4885
4888
  }
4886
4889
  return null;
4887
4890
  }
4888
- function ms(e) {
4891
+ function yo(e) {
4889
4892
  return Y(() => {
4890
4893
  const t = e.content.filter(
4891
- (u) => u.type === "text"
4894
+ (d) => d.type === "text"
4892
4895
  );
4893
4896
  if (!t.length)
4894
4897
  return null;
4895
4898
  let r = t.flatMap(
4896
- (u) => Xr(u.text ?? "")
4899
+ (d) => Xr(d.text ?? "")
4897
4900
  );
4898
4901
  if (!r.length) {
4899
- const u = t.map((l) => l.text ?? "").join(`
4900
- `), c = tt(u);
4902
+ const d = t.map((l) => l.text ?? "").join(`
4903
+ `), c = tt(d);
4901
4904
  c && typeof c == "object" && (r = [c]);
4902
4905
  }
4903
4906
  if (!r.length)
4904
4907
  return null;
4905
- const o = Qr(r) ?? r[r.length - 1];
4906
- if (!o)
4908
+ const s = Qr(r) ?? r[r.length - 1];
4909
+ if (!s)
4907
4910
  return null;
4908
- const a = o.output ?? o.payload ?? o, i = ce(a);
4911
+ const a = s.output ?? s.payload ?? s, i = ce(a);
4909
4912
  return i && typeof i == "object" && !Array.isArray(i) ? {
4910
4913
  kind: "dict",
4911
4914
  value: i,
4912
4915
  data: i,
4913
- event: o
4916
+ event: s
4914
4917
  } : {
4915
4918
  kind: "generic",
4916
4919
  value: i,
4917
- event: o
4920
+ event: s
4918
4921
  };
4919
4922
  }, [e]);
4920
4923
  }
4921
4924
  function Yr(e) {
4922
4925
  var C, O;
4923
- const t = typeof e == "string" ? e : e == null ? void 0 : e.threadId, n = typeof e == "object" ? e.lazy : !1, r = st({ optional: !0 }), s = Vt({ optional: !0 }), o = Or(), { currentThreadId: a, setCurrentThreadId: i, actions: u } = r || {
4926
+ const t = typeof e == "string" ? e : e == null ? void 0 : e.threadId, n = typeof e == "object" ? e.lazy : !1, r = ot({ optional: !0 }), o = Vt({ optional: !0 }), s = Or(), { currentThreadId: a, setCurrentThreadId: i, actions: d } = r || {
4924
4927
  currentThreadId: null,
4925
4928
  setCurrentThreadId: () => {
4926
4929
  },
4927
4930
  actions: {}
4928
- }, c = !!t && t !== a, [l, d] = $([]), g = _((F) => {
4929
- d(F);
4931
+ }, c = !!t && t !== a, [l, f] = $([]), p = _((F) => {
4932
+ f(F);
4930
4933
  }, []), {
4931
- isLoadingThread: m,
4934
+ isLoadingThread: g,
4932
4935
  threadStateError: I,
4933
- threadCheckpoints: f,
4936
+ threadCheckpoints: u,
4934
4937
  isLoadingHistory: v,
4935
4938
  loadThread: x
4936
4939
  } = $t({
4937
4940
  api: Me().chatApi,
4938
4941
  fileApi: Me().fileApi,
4939
- seed: g,
4942
+ seed: p,
4940
4943
  currentThreadId: c ? t : null,
4941
4944
  initialThreadId: c ? t : null,
4942
4945
  isStreaming: !1,
@@ -4944,51 +4947,51 @@ function Yr(e) {
4944
4947
  autoLoadInitial: c && !n
4945
4948
  });
4946
4949
  X(() => {
4947
- !c && !n && a && (s != null && s.loadThread) && s.loadThread(a);
4948
- }, [c, n, a, s == null ? void 0 : s.loadThread]);
4950
+ !c && !n && a && (o != null && o.loadThread) && o.loadThread(a);
4951
+ }, [c, n, a, o == null ? void 0 : o.loadThread]);
4949
4952
  const M = Y(() => {
4950
4953
  var F;
4951
- return ((F = f[0]) == null ? void 0 : F.values) || {};
4952
- }, [f]), A = Y(() => ({ timeline: [], messagePreviews: {} }), []), k = t || a, b = c ? m ? "loading" : "idle" : (s == null ? void 0 : s.status) || "idle", h = c ? l : (o == null ? void 0 : o.messages) || [], T = c ? m : (s == null ? void 0 : s.isLoading) || !1, p = c ? v : (s == null ? void 0 : s.isLoadingHistory) || !1, w = c ? M : (s == null ? void 0 : s.values) || {}, P = c ? {} : (s == null ? void 0 : s.taskMessagesByScope) || {}, j = c ? I : (o == null ? void 0 : o.error) || (s == null ? void 0 : s.error) || null;
4954
+ return ((F = u[0]) == null ? void 0 : F.values) || {};
4955
+ }, [u]), A = Y(() => ({ timeline: [], messagePreviews: {} }), []), w = t || a, b = c ? g ? "loading" : "idle" : (o == null ? void 0 : o.status) || "idle", h = c ? l : (s == null ? void 0 : s.messages) || [], T = c ? g : (o == null ? void 0 : o.isLoading) || !1, m = c ? v : (o == null ? void 0 : o.isLoadingHistory) || !1, k = c ? M : (o == null ? void 0 : o.values) || {}, E = c ? {} : (o == null ? void 0 : o.taskMessagesByScope) || {}, j = c ? I : (s == null ? void 0 : s.error) || (o == null ? void 0 : o.error) || null;
4953
4956
  return {
4954
4957
  // UNIFIED: Single thread ID concept
4955
- threadId: k,
4958
+ threadId: w,
4956
4959
  status: b,
4957
4960
  messages: h,
4958
4961
  isLoading: T,
4959
- isHistoryLoading: p,
4962
+ isHistoryLoading: m,
4960
4963
  error: j,
4961
4964
  // Values & Metadata
4962
- values: w,
4963
- taskMessagesByScope: P,
4964
- metadata: c ? {} : s == null ? void 0 : s.metadata,
4965
+ values: k,
4966
+ taskMessagesByScope: E,
4967
+ metadata: c ? {} : o == null ? void 0 : o.metadata,
4965
4968
  // Actions & State relating to Global/Active Thread only
4966
4969
  navigateToCheckpoint: c ? async () => {
4967
- } : (s == null ? void 0 : s.navigateToCheckpoint) || (async () => {
4970
+ } : (o == null ? void 0 : o.navigateToCheckpoint) || (async () => {
4968
4971
  }),
4969
4972
  returnToLatest: c ? async () => {
4970
- } : (s == null ? void 0 : s.returnToLatest) || (async () => {
4973
+ } : (o == null ? void 0 : o.returnToLatest) || (async () => {
4971
4974
  }),
4972
- checkpoint: c ? f[0] ? { id: f[0].checkpointId, namespace: f[0].checkpointNs } : null : (s == null ? void 0 : s.checkpoint) || null,
4973
- checkpoints: c ? f : (s == null ? void 0 : s.checkpoints) || [],
4974
- checkpointIndex: c ? A : (s == null ? void 0 : s.checkpointIndex) || { timeline: [], messagePreviews: {} },
4975
- interrupt: c ? null : (s == null ? void 0 : s.interrupt) || null,
4975
+ checkpoint: c ? u[0] ? { id: u[0].checkpointId, namespace: u[0].checkpointNs } : null : (o == null ? void 0 : o.checkpoint) || null,
4976
+ checkpoints: c ? u : (o == null ? void 0 : o.checkpoints) || [],
4977
+ checkpointIndex: c ? A : (o == null ? void 0 : o.checkpointIndex) || { timeline: [], messagePreviews: {} },
4978
+ interrupt: c ? null : (o == null ? void 0 : o.interrupt) || null,
4976
4979
  respondToInterrupt: c ? async () => {
4977
- } : (s == null ? void 0 : s.respondToInterrupt) || (async () => {
4980
+ } : (o == null ? void 0 : o.respondToInterrupt) || (async () => {
4978
4981
  }),
4979
4982
  // Streaming Status
4980
4983
  // Even in standalone mode, allow streaming state/stop if a stream context exists.
4981
- isStreaming: (o == null ? void 0 : o.isStreaming) || !1,
4982
- activeMessageId: c ? null : ((C = s == null ? void 0 : s.metadata) == null ? void 0 : C.assemblingMessageId) || (o == null ? void 0 : o.activeMessageId) || null,
4983
- connectionState: (o == null ? void 0 : o.connectionState) || "disconnected",
4984
- streamingAssistantId: !c && (o != null && o.isStreaming) && ((O = s == null ? void 0 : s.metadata) != null && O.assemblingMessageId) ? s.metadata.assemblingMessageId : null,
4984
+ isStreaming: (s == null ? void 0 : s.isStreaming) || !1,
4985
+ activeMessageId: c ? null : ((C = o == null ? void 0 : o.metadata) == null ? void 0 : C.assemblingMessageId) || (s == null ? void 0 : s.activeMessageId) || null,
4986
+ connectionState: (s == null ? void 0 : s.connectionState) || "disconnected",
4987
+ streamingAssistantId: !c && (s != null && s.isStreaming) && ((O = o == null ? void 0 : o.metadata) != null && O.assemblingMessageId) ? o.metadata.assemblingMessageId : null,
4985
4988
  // Actions
4986
- submit: (o == null ? void 0 : o.submit) || (async () => {
4989
+ submit: (s == null ? void 0 : s.submit) || (async () => {
4987
4990
  }),
4988
- stop: (o == null ? void 0 : o.stop) || (() => {
4991
+ stop: (s == null ? void 0 : s.stop) || (() => {
4989
4992
  }),
4990
4993
  clearThread: c ? async () => {
4991
- } : (s == null ? void 0 : s.clearThread) || (async () => {
4994
+ } : (o == null ? void 0 : o.clearThread) || (async () => {
4992
4995
  }),
4993
4996
  setCurrentThreadId: i,
4994
4997
  loadHistory: c ? async () => {
@@ -4996,70 +4999,70 @@ function Yr(e) {
4996
4999
  } : async () => {
4997
5000
  },
4998
5001
  onEvent: c ? () => {
4999
- } : (s == null ? void 0 : s.onEvent) || (() => {
5002
+ } : (o == null ? void 0 : o.onEvent) || (() => {
5000
5003
  }),
5001
5004
  // Thread Management
5002
- createThread: u == null ? void 0 : u.createThread,
5003
- deleteThread: u == null ? void 0 : u.deleteThread,
5004
- renameThread: u == null ? void 0 : u.renameThread,
5005
+ createThread: d == null ? void 0 : d.createThread,
5006
+ deleteThread: d == null ? void 0 : d.deleteThread,
5007
+ renameThread: d == null ? void 0 : d.renameThread,
5005
5008
  threads: (r == null ? void 0 : r.threads) || [],
5006
5009
  isThreadsLoading: (r == null ? void 0 : r.isLoading) || !1
5007
5010
  };
5008
5011
  }
5009
- function ys({
5012
+ function ho({
5010
5013
  submit: e,
5011
5014
  chatRequest: t,
5012
5015
  lastCheckpointId: n,
5013
5016
  lastCheckpointNs: r,
5014
- onMessageSent: s,
5015
- onExcelUploadSuccess: o,
5017
+ onMessageSent: o,
5018
+ onExcelUploadSuccess: s,
5016
5019
  onError: a,
5017
5020
  enableMessageEditing: i,
5018
- messages: u,
5021
+ messages: d,
5019
5022
  setPendingAssistantResponse: c,
5020
5023
  project: l,
5021
- onEvent: d,
5022
- threadId: g,
5023
- clearComposerOnSend: m = !0
5024
+ onEvent: f,
5025
+ threadId: p,
5026
+ clearComposerOnSend: g = !0
5024
5027
  }) {
5025
- const { messages: I } = Yr(), [f, v] = $(null), [x, M] = $(""), [A, k] = $(null), [b, h] = $(null), [T, p] = $(!1), [w, P] = $(""), j = W(w), C = W(null);
5028
+ const { messages: I } = Yr(), [u, v] = $(null), [x, M] = $(""), [A, w] = $(null), [b, h] = $(null), [T, m] = $(!1), [k, E] = $(""), j = G(k), C = G(null);
5026
5029
  X(() => {
5027
- if (!f)
5028
- if (g) {
5029
- const y = localStorage.getItem(Ge(g));
5030
- P(y || "");
5030
+ if (!u)
5031
+ if (p) {
5032
+ const y = localStorage.getItem(Ge(p));
5033
+ E(y || "");
5031
5034
  } else
5032
- P("");
5033
- }, [g, f]);
5035
+ E("");
5036
+ }, [p, u]);
5034
5037
  const O = _((y) => {
5035
- P(y), !f && g && localStorage.setItem(Ge(g), y);
5036
- }, [g, f]);
5038
+ E(y), !u && p && localStorage.setItem(Ge(p), y);
5039
+ }, [p, u]);
5037
5040
  X(() => {
5038
- j.current = w;
5039
- }, [w]), X(() => {
5040
- if (!f) {
5041
+ j.current = k;
5042
+ }, [k]), X(() => {
5043
+ if (!u) {
5041
5044
  C.current = null;
5042
5045
  return;
5043
5046
  }
5044
5047
  C.current === null && (C.current = j.current), O(x ?? "");
5045
- }, [x, f, O]);
5048
+ }, [x, u, O]);
5046
5049
  const F = _(
5047
5050
  (y) => {
5048
5051
  O(y);
5049
5052
  },
5050
5053
  [O]
5051
- ), E = async (y, U) => {
5052
- const S = Array.isArray(U) ? { files: U } : U ?? {}, J = S.files ?? [], V = S.contentParts ?? [], q = y.trim();
5053
- if (!(!q && J.length === 0 && V.length === 0))
5054
+ ), P = async (y, L) => {
5055
+ const S = Array.isArray(L) ? { files: L } : L ?? {}, W = S.files ?? [], K = S.contentParts ?? [], V = y.trim();
5056
+ if (!(!V && W.length === 0 && K.length === 0))
5054
5057
  try {
5055
- const ee = J.map(async (Q) => {
5058
+ const ee = W.map(async (Q) => {
5056
5059
  try {
5057
5060
  const Z = await Rt.uploadFile(Q);
5058
5061
  return { file: Q, record: Z };
5059
5062
  } catch (Z) {
5060
5063
  throw console.error("Failed to upload file", Q.name, Z), new Error(`Failed to upload ${Q.name}`);
5061
5064
  }
5062
- }), ue = (await Promise.all(ee)).map(({ record: Q }) => {
5065
+ }), de = (await Promise.all(ee)).map(({ record: Q }) => {
5063
5066
  const Z = Q.mime_type;
5064
5067
  return Z.startsWith("image/") ? {
5065
5068
  type: "image_url",
@@ -5071,28 +5074,28 @@ function ys({
5071
5074
  name: Q.filename,
5072
5075
  size: Q.size
5073
5076
  };
5074
- }), G = [...V, ...ue], te = f ? (A == null ? void 0 : A.checkpointId) ?? n ?? void 0 : n ?? void 0, ke = f ? (A == null ? void 0 : A.checkpointNs) ?? r ?? void 0 : r ?? void 0;
5077
+ }), H = [...K, ...de], te = u ? (A == null ? void 0 : A.checkpointId) ?? n ?? void 0 : n ?? void 0, ke = u ? (A == null ? void 0 : A.checkpointNs) ?? r ?? void 0 : r ?? void 0;
5075
5078
  await e(
5076
5079
  {
5077
- text: q || "",
5078
- contentParts: G,
5079
- attachments: J,
5080
+ text: V || "",
5081
+ contentParts: H,
5082
+ attachments: W,
5080
5083
  payload: t.payload,
5081
- edit: !!f,
5084
+ edit: !!u,
5082
5085
  checkpointId: te,
5083
5086
  checkpointNs: ke,
5084
5087
  project: l ?? void 0,
5085
- originalMessageId: f ?? void 0,
5088
+ originalMessageId: u ?? void 0,
5086
5089
  config: t.config
5087
5090
  },
5088
- d ? { onEvent: d } : void 0
5089
- ), s == null || s(q), c(!0), m && (g && localStorage.removeItem(Ge(g)), O("")), h(null), v(null), M(""), k(null);
5091
+ f ? { onEvent: f } : void 0
5092
+ ), o == null || o(V), c(!0), g && (p && localStorage.removeItem(Ge(p)), O("")), h(null), v(null), M(""), w(null);
5090
5093
  } catch (ee) {
5091
5094
  const re = (ee == null ? void 0 : ee.message) || "Failed to send message";
5092
5095
  h(re), a == null || a(re), c(!1);
5093
5096
  }
5094
- }, B = (y, U) => {
5095
- U || E(y, { files: [] });
5097
+ }, B = (y, L) => {
5098
+ L || P(y, { files: [] });
5096
5099
  }, z = _(
5097
5100
  async (y) => {
5098
5101
  await e(
@@ -5104,73 +5107,73 @@ function ys({
5104
5107
  project: l ?? void 0,
5105
5108
  config: t.config
5106
5109
  },
5107
- d ? { onEvent: d } : void 0
5108
- ), o == null || o({ file: y });
5110
+ f ? { onEvent: f } : void 0
5111
+ ), s == null || s({ file: y });
5109
5112
  },
5110
- [n, r, t, o, e]
5111
- ), K = _(
5112
- (y, U, S) => {
5113
- i && (C.current = w, v(y), M(U), k({
5113
+ [n, r, t, s, e]
5114
+ ), J = _(
5115
+ (y, L, S) => {
5116
+ i && (C.current = k, v(y), M(L), w({
5114
5117
  checkpointId: (S == null ? void 0 : S.checkpointId) ?? null,
5115
5118
  checkpointNs: (S == null ? void 0 : S.checkpointNs) ?? null
5116
5119
  }), h(null));
5117
5120
  },
5118
- [w, i]
5119
- ), N = _(() => {
5120
- v(null), M(""), k(null), h(null);
5121
+ [k, i]
5122
+ ), U = _(() => {
5123
+ v(null), M(""), w(null), h(null);
5121
5124
  const y = C.current;
5122
- y !== null && P(y), C.current = null;
5123
- }, []), L = _((y) => {
5124
- let U = null;
5125
- for (let q = y - 1; q >= 0; q--)
5126
- if (u[q].role === "user") {
5127
- U = u[q];
5125
+ y !== null && E(y), C.current = null;
5126
+ }, []), R = _((y) => {
5127
+ let L = null;
5128
+ for (let V = y - 1; V >= 0; V--)
5129
+ if (d[V].role === "user") {
5130
+ L = d[V];
5128
5131
  break;
5129
5132
  }
5130
- if (!U) return;
5131
- const S = Array.isArray(U.content) ? U.content : [], V = S.filter((q) => (q == null ? void 0 : q.type) === "text").map((q) => q.text).join("") || (() => {
5133
+ if (!L) return;
5134
+ const S = Array.isArray(L.content) ? L.content : [], K = S.filter((V) => (V == null ? void 0 : V.type) === "text").map((V) => V.text).join("") || (() => {
5132
5135
  try {
5133
5136
  return JSON.stringify(S, null, 2);
5134
5137
  } catch {
5135
5138
  return String(S);
5136
5139
  }
5137
5140
  })();
5138
- V && e(
5141
+ K && e(
5139
5142
  {
5140
- text: V,
5143
+ text: K,
5141
5144
  payload: t.payload,
5142
5145
  checkpointId: n ?? void 0,
5143
5146
  checkpointNs: r ?? void 0,
5144
5147
  edit: !0,
5145
- originalMessageId: U.id,
5148
+ originalMessageId: L.id,
5146
5149
  config: t.config
5147
5150
  },
5148
- d ? { onEvent: d } : void 0
5151
+ f ? { onEvent: f } : void 0
5149
5152
  );
5150
- }, [u, e, n, r, t]);
5153
+ }, [d, e, n, r, t]);
5151
5154
  return {
5152
- editingMessageId: f,
5155
+ editingMessageId: u,
5153
5156
  editingInitialValue: x,
5154
5157
  inputError: b,
5155
5158
  setInputError: h,
5156
5159
  dismissError: T,
5157
- setDismissError: p,
5158
- composerValue: w,
5160
+ setDismissError: m,
5161
+ composerValue: k,
5159
5162
  handleComposerChange: F,
5160
- handleSendMessage: E,
5163
+ handleSendMessage: P,
5161
5164
  handleQuickPrompt: B,
5162
5165
  handleExcelUpload: z,
5163
- startEditing: K,
5164
- cancelEditing: N,
5165
- handleRegenerateCb: L,
5166
+ startEditing: J,
5167
+ cancelEditing: U,
5168
+ handleRegenerateCb: R,
5166
5169
  displayMessages: I
5167
5170
  };
5168
5171
  }
5169
- function hs(e) {
5172
+ function bo(e) {
5170
5173
  return Y(() => e ? {
5171
5174
  textContent: Ln(e),
5172
- imageParts: Un(e),
5173
- fileParts: jn(e),
5175
+ imageParts: jn(e),
5176
+ fileParts: Un(e),
5174
5177
  toolCalls: Mt(e),
5175
5178
  contentParts: e.content
5176
5179
  } : {
@@ -5181,12 +5184,12 @@ function hs(e) {
5181
5184
  contentParts: []
5182
5185
  }, [e]);
5183
5186
  }
5184
- function bs(e, t, n) {
5185
- const [r, s] = $(e), o = W(e), a = W(null);
5187
+ function wo(e, t, n) {
5188
+ const [r, o] = $(e), s = G(e), a = G(null);
5186
5189
  return X(() => {
5187
- o.current = e;
5190
+ s.current = e;
5188
5191
  const i = () => {
5189
- s(o.current), a.current && (clearTimeout(a.current), a.current = null);
5192
+ o(s.current), a.current && (clearTimeout(a.current), a.current = null);
5190
5193
  };
5191
5194
  if (!t || n <= 0) {
5192
5195
  i();
@@ -5200,26 +5203,26 @@ function bs(e, t, n) {
5200
5203
  }, [e, t, n]), r;
5201
5204
  }
5202
5205
  export {
5203
- fs as ChatProviders,
5204
- Ur as ThreadStateProvider,
5206
+ po as ChatProviders,
5207
+ jr as ThreadStateProvider,
5205
5208
  mr as ThreadsProvider,
5206
- rs as cn,
5207
- or as collectText,
5208
- ds as createTaskSyncToolEndHandler,
5209
+ ro as cn,
5210
+ sr as collectText,
5211
+ fo as createTaskSyncToolEndHandler,
5209
5212
  Kr as extractTaskIdFromToolEnd,
5210
5213
  ar as extractToolMeta,
5211
- ss as formatToolOutput,
5212
- cs as getAgentNameFromMessage,
5214
+ oo as formatToolOutput,
5215
+ co as getAgentNameFromMessage,
5213
5216
  Pt as getChatToken,
5214
- us as getMessageAttemptInfo,
5215
- as as getToolCallArtifacts,
5217
+ uo as getMessageAttemptInfo,
5218
+ ao as getToolCallArtifacts,
5216
5219
  qn as getToolCalls,
5217
- os as hasContent,
5220
+ so as hasContent,
5218
5221
  mt as hydrateHistorySnapshots,
5219
5222
  Ct as isFileLike,
5220
- zn as looksLikeMarkdown,
5221
- ls as messageSignature,
5222
- is as normalizeInterruptId,
5223
+ Nn as looksLikeMarkdown,
5224
+ lo as messageSignature,
5225
+ io as normalizeInterruptId,
5223
5226
  _t as onChatTokenChanged,
5224
5227
  tt as parseJsonSafe,
5225
5228
  Et as pretty,
@@ -5228,18 +5231,18 @@ export {
5228
5231
  Ie as setChatToken,
5229
5232
  Fn as stringifyTool,
5230
5233
  Me as useApi,
5231
- ys as useChatController,
5234
+ ho as useChatController,
5232
5235
  Yr as useChatSession,
5233
- ps as useFilePreview,
5234
- hs as useMessageContent,
5235
- gs as useParsedMessageContent,
5236
+ go as useFilePreview,
5237
+ bo as useMessageContent,
5238
+ mo as useParsedMessageContent,
5236
5239
  pr as useStream,
5237
- bs as useStreamingMarkdownBuffer,
5240
+ wo as useStreamingMarkdownBuffer,
5238
5241
  $t as useThreadHistoryState,
5239
5242
  Vt as useThreadState,
5240
5243
  Lr as useThreadStateUpdater,
5241
- st as useThreads,
5244
+ ot as useThreads,
5242
5245
  gr as useThreadsState,
5243
- ms as useToolPayload
5246
+ yo as useToolPayload
5244
5247
  };
5245
5248
  //# sourceMappingURL=index.esm.js.map