@teodorruskvi/chat-core 0.1.57 → 0.1.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,21 +1,21 @@
1
- var Ht = Object.defineProperty;
2
- var Gt = (e, t, n) => t in e ? Ht(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
1
+ var qt = Object.defineProperty;
2
+ var Gt = (e, t, n) => t in e ? qt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
3
  var at = (e, t, n) => Gt(e, typeof t != "symbol" ? t + "" : t, n);
4
4
  import { jsx as de } from "react/jsx-runtime";
5
5
  import * as it from "react";
6
- import { createContext as Ce, useContext as je, useState as D, useRef as H, useEffect as Y, useCallback as N, useMemo as Z, useReducer as Wt } from "react";
6
+ import { createContext as Ce, useContext as je, useState as H, useRef as W, useEffect as Y, useCallback as _, useMemo as Z, useReducer as Wt } from "react";
7
7
  import Jt, { isCancel as Xt } from "axios";
8
8
  function It(e) {
9
9
  var t, n, r = "";
10
10
  if (typeof e == "string" || typeof e == "number") r += e;
11
11
  else if (typeof e == "object") if (Array.isArray(e)) {
12
- var o = e.length;
13
- for (t = 0; t < o; t++) e[t] && (n = It(e[t])) && (r && (r += " "), r += n);
12
+ var s = e.length;
13
+ for (t = 0; t < s; 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 = "", o = arguments.length; n < o; n++) (e = arguments[n]) && (t = It(e)) && (r && (r += " "), r += t);
18
+ for (var e, t, n = 0, r = "", s = arguments.length; n < s; 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 d = n[a] || [];
33
- return i && r[a] ? [...d, ...r[a]] : d;
32
+ const u = n[a] || [];
33
+ return i && r[a] ? [...u, ...r[a]] : u;
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), o = r ? vt(e.slice(1), r) : void 0;
41
- if (o)
42
- return o;
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;
43
43
  if (t.validators.length === 0)
44
44
  return;
45
- const s = e.join(et);
45
+ const o = e.join(et);
46
46
  return (a = t.validators.find(({
47
47
  validator: i
48
- }) => i(s))) == null ? void 0 : a.classGroupId;
48
+ }) => i(o))) == 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(([s, a]) => {
64
- Xe(a, r, s, t);
63
+ return nn(Object.entries(e.classGroups), n).forEach(([o, a]) => {
64
+ Xe(a, r, o, t);
65
65
  }), r;
66
66
  }, Xe = (e, t, n, r) => {
67
- e.forEach((o) => {
68
- if (typeof o == "string") {
69
- const s = o === "" ? t : lt(t, o);
70
- s.classGroupId = n;
67
+ e.forEach((s) => {
68
+ if (typeof s == "string") {
69
+ const o = s === "" ? t : lt(t, s);
70
+ o.classGroupId = n;
71
71
  return;
72
72
  }
73
- if (typeof o == "function") {
74
- if (tn(o)) {
75
- Xe(o(r), t, n, r);
73
+ if (typeof s == "function") {
74
+ if (tn(s)) {
75
+ Xe(s(r), t, n, r);
76
76
  return;
77
77
  }
78
78
  t.validators.push({
79
- validator: o,
79
+ validator: s,
80
80
  classGroupId: n
81
81
  });
82
82
  return;
83
83
  }
84
- Object.entries(o).forEach(([s, a]) => {
85
- Xe(a, lt(t, s), n, r);
84
+ Object.entries(s).forEach(([o, a]) => {
85
+ Xe(a, lt(t, o), 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 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];
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];
99
99
  }) : e, rn = (e) => {
100
100
  if (e < 1)
101
101
  return {
@@ -105,48 +105,48 @@ const et = "-", Yt = (e) => {
105
105
  }
106
106
  };
107
107
  let t = 0, n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
108
- const o = (s, a) => {
109
- n.set(s, a), t++, t > e && (t = 0, r = n, n = /* @__PURE__ */ new Map());
108
+ const s = (o, a) => {
109
+ n.set(o, a), t++, t > e && (t = 0, r = n, n = /* @__PURE__ */ new Map());
110
110
  };
111
111
  return {
112
- get(s) {
113
- let a = n.get(s);
112
+ get(o) {
113
+ let a = n.get(o);
114
114
  if (a !== void 0)
115
115
  return a;
116
- if ((a = r.get(s)) !== void 0)
117
- return o(s, a), a;
116
+ if ((a = r.get(o)) !== void 0)
117
+ return s(o, a), a;
118
118
  },
119
- set(s, a) {
120
- n.has(s) ? n.set(s, a) : o(s, a);
119
+ set(o, a) {
120
+ n.has(o) ? n.set(o, a) : s(o, a);
121
121
  }
122
122
  };
123
123
  }, xt = "!", on = (e) => {
124
124
  const {
125
125
  separator: t,
126
126
  experimentalParseClassName: n
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
- for (let v = 0; v < i.length; v++) {
131
- let x = i[v];
132
- if (c === 0) {
133
- if (x === o && (r || i.slice(v, v + s) === t)) {
134
- d.push(i.slice(l, v)), l = v + s;
127
+ } = e, r = t.length === 1, s = t[0], o = t.length, a = (i) => {
128
+ const u = [];
129
+ let l = 0, c = 0, d;
130
+ for (let b = 0; b < i.length; b++) {
131
+ let x = i[b];
132
+ if (l === 0) {
133
+ if (x === s && (r || i.slice(b, b + o) === t)) {
134
+ u.push(i.slice(c, b)), c = b + o;
135
135
  continue;
136
136
  }
137
137
  if (x === "/") {
138
- f = v;
138
+ d = b;
139
139
  continue;
140
140
  }
141
141
  }
142
- x === "[" ? c++ : x === "]" && c--;
142
+ x === "[" ? l++ : x === "]" && l--;
143
143
  }
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;
144
+ const p = u.length === 0 ? i : i.substring(c), m = p.startsWith(xt), v = m ? p.substring(1) : p, f = d && d > c ? d - c : void 0;
145
145
  return {
146
- modifiers: d,
147
- hasImportantModifier: g,
148
- baseClassName: I,
149
- maybePostfixModifierPosition: u
146
+ modifiers: u,
147
+ hasImportantModifier: m,
148
+ baseClassName: v,
149
+ maybePostfixModifierPosition: f
150
150
  };
151
151
  };
152
152
  return n ? (i) => n({
@@ -169,38 +169,38 @@ const et = "-", Yt = (e) => {
169
169
  const {
170
170
  parseClassName: n,
171
171
  getClassGroupId: r,
172
- getConflictingClassGroupIds: o
173
- } = t, s = [], a = e.trim().split(cn);
172
+ getConflictingClassGroupIds: s
173
+ } = t, o = [], a = e.trim().split(cn);
174
174
  let i = "";
175
- for (let d = a.length - 1; d >= 0; d -= 1) {
176
- const c = a[d], {
177
- modifiers: l,
178
- hasImportantModifier: f,
175
+ for (let u = a.length - 1; u >= 0; u -= 1) {
176
+ const l = a[u], {
177
+ modifiers: c,
178
+ hasImportantModifier: d,
179
179
  baseClassName: p,
180
- maybePostfixModifierPosition: g
181
- } = n(c);
182
- let I = !!g, u = r(I ? p.substring(0, g) : p);
183
- if (!u) {
184
- if (!I) {
185
- i = c + (i.length > 0 ? " " + i : i);
180
+ maybePostfixModifierPosition: m
181
+ } = n(l);
182
+ let v = !!m, f = r(v ? p.substring(0, m) : p);
183
+ if (!f) {
184
+ if (!v) {
185
+ i = l + (i.length > 0 ? " " + i : i);
186
186
  continue;
187
187
  }
188
- if (u = r(p), !u) {
189
- i = c + (i.length > 0 ? " " + i : i);
188
+ if (f = r(p), !f) {
189
+ i = l + (i.length > 0 ? " " + i : i);
190
190
  continue;
191
191
  }
192
- I = !1;
192
+ v = !1;
193
193
  }
194
- const v = sn(l).join(":"), x = f ? v + xt : v, S = x + u;
195
- if (s.includes(S))
194
+ const b = sn(c).join(":"), x = d ? b + xt : b, S = x + f;
195
+ if (o.includes(S))
196
196
  continue;
197
- s.push(S);
198
- const A = o(u, I);
197
+ o.push(S);
198
+ const A = s(f, v);
199
199
  for (let w = 0; w < A.length; ++w) {
200
- const b = A[w];
201
- s.push(x + b);
200
+ const k = A[w];
201
+ o.push(x + k);
202
202
  }
203
- i = c + (i.length > 0 ? " " + i : i);
203
+ i = l + (i.length > 0 ? " " + i : i);
204
204
  }
205
205
  return i;
206
206
  };
@@ -219,26 +219,26 @@ const At = (e) => {
219
219
  return n;
220
220
  };
221
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);
222
+ let n, r, s, o = a;
223
+ function a(u) {
224
+ const l = t.reduce((c, d) => d(c), e());
225
+ return n = an(l), r = n.cache.get, s = n.cache.set, o = i, i(u);
226
226
  }
227
- function i(d) {
228
- const c = r(d);
229
- if (c)
230
- return c;
231
- const l = ln(d, n);
232
- return o(d, l), l;
227
+ function i(u) {
228
+ const l = r(u);
229
+ if (l)
230
+ return l;
231
+ const c = ln(u, n);
232
+ return s(u, c), c;
233
233
  }
234
234
  return function() {
235
- return s(dn.apply(null, arguments));
235
+ return o(dn.apply(null, arguments));
236
236
  };
237
237
  }
238
238
  const q = (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)\(.+\)$/, pe = (e) => Te(e) || pn.has(e) || fn.test(e), Ie = (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)), z = (e) => Tt.test(e), ve = (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) => {
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)\(.+\)$/, pe = (e) => Te(e) || pn.has(e) || fn.test(e), Ie = (e) => Ee(e, "length", Sn), Te = (e) => !!e && !Number.isNaN(Number(e)), Ve = (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), ve = (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 q = (e) => {
247
247
  // I could also use lookbehind assertion in `lengthUnitRegex` but that isn't supported widely enough.
248
248
  mn.test(e) && !yn.test(e)
249
249
  ), St = () => !1, Mn = (e) => hn.test(e), Cn = (e) => bn.test(e), En = () => {
250
- const e = q("colors"), t = q("spacing"), n = q("blur"), r = q("brightness"), o = q("borderColor"), s = q("borderRadius"), a = q("borderSpacing"), i = q("borderWidth"), d = q("contrast"), c = q("grayscale"), l = q("hueRotate"), f = q("invert"), p = q("gap"), g = q("gradientColorStops"), I = q("gradientColorStopPositions"), u = q("inset"), v = q("margin"), x = q("opacity"), S = q("padding"), A = q("saturate"), w = q("scale"), b = q("sepia"), y = q("skew"), T = q("space"), m = q("translate"), k = () => ["auto", "contain", "none"], E = () => ["auto", "hidden", "clip", "visible", "scroll"], U = () => ["auto", z, t], M = () => [z, t], $ = () => ["", pe, Ie], F = () => ["auto", Te, z], _ = () => ["bottom", "center", "left", "left-bottom", "left-top", "right", "right-bottom", "right-top", "top"], O = () => ["solid", "dashed", "dotted", "double", "none"], R = () => ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"], W = () => ["start", "end", "center", "between", "around", "evenly", "stretch"], B = () => ["", "0", z], L = () => ["auto", "avoid", "all", "avoid-page", "page", "left", "right", "column"], h = () => [Te, z];
250
+ const e = q("colors"), t = q("spacing"), n = q("blur"), r = q("brightness"), s = q("borderColor"), o = q("borderRadius"), a = q("borderSpacing"), i = q("borderWidth"), u = q("contrast"), l = q("grayscale"), c = q("hueRotate"), d = q("invert"), p = q("gap"), m = q("gradientColorStops"), v = q("gradientColorStopPositions"), f = q("inset"), b = q("margin"), x = q("opacity"), S = q("padding"), A = q("saturate"), w = q("scale"), k = q("sepia"), h = q("skew"), T = q("space"), y = q("translate"), I = () => ["auto", "contain", "none"], E = () => ["auto", "hidden", "clip", "visible", "scroll"], L = () => ["auto", R, t], M = () => [R, t], $ = () => ["", pe, Ie], U = () => ["auto", Te, R], V = () => ["bottom", "center", "left", "left-bottom", "left-top", "right", "right-bottom", "right-top", "top"], P = () => ["solid", "dashed", "dotted", "double", "none"], F = () => ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"], N = () => ["start", "end", "center", "between", "around", "evenly", "stretch"], j = () => ["", "0", R], G = () => ["auto", "avoid", "all", "avoid-page", "page", "left", "right", "column"], g = () => [Te, R];
251
251
  return {
252
252
  cacheSize: 500,
253
253
  separator: ":",
254
254
  theme: {
255
255
  colors: [Ne],
256
256
  spacing: [pe, Ie],
257
- blur: ["none", "", ve, z],
258
- brightness: h(),
257
+ blur: ["none", "", ve, R],
258
+ brightness: g(),
259
259
  borderColor: [e],
260
- borderRadius: ["none", "", "full", ve, z],
260
+ borderRadius: ["none", "", "full", ve, R],
261
261
  borderSpacing: M(),
262
262
  borderWidth: $(),
263
- contrast: h(),
264
- grayscale: B(),
265
- hueRotate: h(),
266
- invert: B(),
263
+ contrast: g(),
264
+ grayscale: j(),
265
+ hueRotate: g(),
266
+ invert: j(),
267
267
  gap: M(),
268
268
  gradientColorStops: [e],
269
269
  gradientColorStopPositions: [wn, Ie],
270
- inset: U(),
271
- margin: U(),
272
- opacity: h(),
270
+ inset: L(),
271
+ margin: L(),
272
+ opacity: g(),
273
273
  padding: M(),
274
- saturate: h(),
275
- scale: h(),
276
- sepia: B(),
277
- skew: h(),
274
+ saturate: g(),
275
+ scale: g(),
276
+ sepia: j(),
277
+ skew: g(),
278
278
  space: M(),
279
279
  translate: M()
280
280
  },
@@ -285,7 +285,7 @@ const q = (e) => {
285
285
  * @see https://tailwindcss.com/docs/aspect-ratio
286
286
  */
287
287
  aspect: [{
288
- aspect: ["auto", "square", "video", z]
288
+ aspect: ["auto", "square", "video", R]
289
289
  }],
290
290
  /**
291
291
  * Container
@@ -304,14 +304,14 @@ const q = (e) => {
304
304
  * @see https://tailwindcss.com/docs/break-after
305
305
  */
306
306
  "break-after": [{
307
- "break-after": L()
307
+ "break-after": G()
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": G()
315
315
  }],
316
316
  /**
317
317
  * Break Inside
@@ -370,7 +370,7 @@ const q = (e) => {
370
370
  * @see https://tailwindcss.com/docs/object-position
371
371
  */
372
372
  "object-position": [{
373
- object: [..._(), z]
373
+ object: [...V(), R]
374
374
  }],
375
375
  /**
376
376
  * Overflow
@@ -398,21 +398,21 @@ const q = (e) => {
398
398
  * @see https://tailwindcss.com/docs/overscroll-behavior
399
399
  */
400
400
  overscroll: [{
401
- overscroll: k()
401
+ overscroll: I()
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": k()
408
+ "overscroll-x": I()
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": k()
415
+ "overscroll-y": I()
416
416
  }],
417
417
  /**
418
418
  * Position
@@ -424,63 +424,63 @@ const q = (e) => {
424
424
  * @see https://tailwindcss.com/docs/top-right-bottom-left
425
425
  */
426
426
  inset: [{
427
- inset: [u]
427
+ inset: [f]
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": [u]
434
+ "inset-x": [f]
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": [u]
441
+ "inset-y": [f]
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: [u]
448
+ start: [f]
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: [u]
455
+ end: [f]
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: [u]
462
+ top: [f]
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: [u]
469
+ right: [f]
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: [u]
476
+ bottom: [f]
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: [u]
483
+ left: [f]
484
484
  }],
485
485
  /**
486
486
  * Visibility
@@ -492,7 +492,7 @@ const q = (e) => {
492
492
  * @see https://tailwindcss.com/docs/z-index
493
493
  */
494
494
  z: [{
495
- z: ["auto", _e, z]
495
+ z: ["auto", _e, R]
496
496
  }],
497
497
  // Flexbox and Grid
498
498
  /**
@@ -500,7 +500,7 @@ const q = (e) => {
500
500
  * @see https://tailwindcss.com/docs/flex-basis
501
501
  */
502
502
  basis: [{
503
- basis: U()
503
+ basis: L()
504
504
  }],
505
505
  /**
506
506
  * Flex Direction
@@ -521,28 +521,28 @@ const q = (e) => {
521
521
  * @see https://tailwindcss.com/docs/flex
522
522
  */
523
523
  flex: [{
524
- flex: ["1", "auto", "initial", "none", z]
524
+ flex: ["1", "auto", "initial", "none", R]
525
525
  }],
526
526
  /**
527
527
  * Flex Grow
528
528
  * @see https://tailwindcss.com/docs/flex-grow
529
529
  */
530
530
  grow: [{
531
- grow: B()
531
+ grow: j()
532
532
  }],
533
533
  /**
534
534
  * Flex Shrink
535
535
  * @see https://tailwindcss.com/docs/flex-shrink
536
536
  */
537
537
  shrink: [{
538
- shrink: B()
538
+ shrink: j()
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, z]
545
+ order: ["first", "last", "none", _e, R]
546
546
  }],
547
547
  /**
548
548
  * Grid Template Columns
@@ -557,22 +557,22 @@ const q = (e) => {
557
557
  */
558
558
  "col-start-end": [{
559
559
  col: ["auto", {
560
- span: ["full", _e, z]
561
- }, z]
560
+ span: ["full", _e, R]
561
+ }, R]
562
562
  }],
563
563
  /**
564
564
  * Grid Column Start
565
565
  * @see https://tailwindcss.com/docs/grid-column
566
566
  */
567
567
  "col-start": [{
568
- "col-start": F()
568
+ "col-start": U()
569
569
  }],
570
570
  /**
571
571
  * Grid Column End
572
572
  * @see https://tailwindcss.com/docs/grid-column
573
573
  */
574
574
  "col-end": [{
575
- "col-end": F()
575
+ "col-end": U()
576
576
  }],
577
577
  /**
578
578
  * Grid Template Rows
@@ -587,22 +587,22 @@ const q = (e) => {
587
587
  */
588
588
  "row-start-end": [{
589
589
  row: ["auto", {
590
- span: [_e, z]
591
- }, z]
590
+ span: [_e, R]
591
+ }, R]
592
592
  }],
593
593
  /**
594
594
  * Grid Row Start
595
595
  * @see https://tailwindcss.com/docs/grid-row
596
596
  */
597
597
  "row-start": [{
598
- "row-start": F()
598
+ "row-start": U()
599
599
  }],
600
600
  /**
601
601
  * Grid Row End
602
602
  * @see https://tailwindcss.com/docs/grid-row
603
603
  */
604
604
  "row-end": [{
605
- "row-end": F()
605
+ "row-end": U()
606
606
  }],
607
607
  /**
608
608
  * Grid Auto Flow
@@ -616,14 +616,14 @@ const q = (e) => {
616
616
  * @see https://tailwindcss.com/docs/grid-auto-columns
617
617
  */
618
618
  "auto-cols": [{
619
- "auto-cols": ["auto", "min", "max", "fr", z]
619
+ "auto-cols": ["auto", "min", "max", "fr", R]
620
620
  }],
621
621
  /**
622
622
  * Grid Auto Rows
623
623
  * @see https://tailwindcss.com/docs/grid-auto-rows
624
624
  */
625
625
  "auto-rows": [{
626
- "auto-rows": ["auto", "min", "max", "fr", z]
626
+ "auto-rows": ["auto", "min", "max", "fr", R]
627
627
  }],
628
628
  /**
629
629
  * Gap
@@ -651,7 +651,7 @@ const q = (e) => {
651
651
  * @see https://tailwindcss.com/docs/justify-content
652
652
  */
653
653
  "justify-content": [{
654
- justify: ["normal", ...W()]
654
+ justify: ["normal", ...N()]
655
655
  }],
656
656
  /**
657
657
  * Justify Items
@@ -672,7 +672,7 @@ const q = (e) => {
672
672
  * @see https://tailwindcss.com/docs/align-content
673
673
  */
674
674
  "align-content": [{
675
- content: ["normal", ...W(), "baseline"]
675
+ content: ["normal", ...N(), "baseline"]
676
676
  }],
677
677
  /**
678
678
  * Align Items
@@ -693,7 +693,7 @@ const q = (e) => {
693
693
  * @see https://tailwindcss.com/docs/place-content
694
694
  */
695
695
  "place-content": [{
696
- "place-content": [...W(), "baseline"]
696
+ "place-content": [...N(), "baseline"]
697
697
  }],
698
698
  /**
699
699
  * Place Items
@@ -778,63 +778,63 @@ const q = (e) => {
778
778
  * @see https://tailwindcss.com/docs/margin
779
779
  */
780
780
  m: [{
781
- m: [v]
781
+ m: [b]
782
782
  }],
783
783
  /**
784
784
  * Margin X
785
785
  * @see https://tailwindcss.com/docs/margin
786
786
  */
787
787
  mx: [{
788
- mx: [v]
788
+ mx: [b]
789
789
  }],
790
790
  /**
791
791
  * Margin Y
792
792
  * @see https://tailwindcss.com/docs/margin
793
793
  */
794
794
  my: [{
795
- my: [v]
795
+ my: [b]
796
796
  }],
797
797
  /**
798
798
  * Margin Start
799
799
  * @see https://tailwindcss.com/docs/margin
800
800
  */
801
801
  ms: [{
802
- ms: [v]
802
+ ms: [b]
803
803
  }],
804
804
  /**
805
805
  * Margin End
806
806
  * @see https://tailwindcss.com/docs/margin
807
807
  */
808
808
  me: [{
809
- me: [v]
809
+ me: [b]
810
810
  }],
811
811
  /**
812
812
  * Margin Top
813
813
  * @see https://tailwindcss.com/docs/margin
814
814
  */
815
815
  mt: [{
816
- mt: [v]
816
+ mt: [b]
817
817
  }],
818
818
  /**
819
819
  * Margin Right
820
820
  * @see https://tailwindcss.com/docs/margin
821
821
  */
822
822
  mr: [{
823
- mr: [v]
823
+ mr: [b]
824
824
  }],
825
825
  /**
826
826
  * Margin Bottom
827
827
  * @see https://tailwindcss.com/docs/margin
828
828
  */
829
829
  mb: [{
830
- mb: [v]
830
+ mb: [b]
831
831
  }],
832
832
  /**
833
833
  * Margin Left
834
834
  * @see https://tailwindcss.com/docs/margin
835
835
  */
836
836
  ml: [{
837
- ml: [v]
837
+ ml: [b]
838
838
  }],
839
839
  /**
840
840
  * Space Between X
@@ -866,21 +866,21 @@ const q = (e) => {
866
866
  * @see https://tailwindcss.com/docs/width
867
867
  */
868
868
  w: [{
869
- w: ["auto", "min", "max", "fit", "svw", "lvw", "dvw", z, t]
869
+ w: ["auto", "min", "max", "fit", "svw", "lvw", "dvw", R, t]
870
870
  }],
871
871
  /**
872
872
  * Min-Width
873
873
  * @see https://tailwindcss.com/docs/min-width
874
874
  */
875
875
  "min-w": [{
876
- "min-w": [z, t, "min", "max", "fit"]
876
+ "min-w": [R, t, "min", "max", "fit"]
877
877
  }],
878
878
  /**
879
879
  * Max-Width
880
880
  * @see https://tailwindcss.com/docs/max-width
881
881
  */
882
882
  "max-w": [{
883
- "max-w": [z, t, "none", "full", "min", "max", "fit", "prose", {
883
+ "max-w": [R, t, "none", "full", "min", "max", "fit", "prose", {
884
884
  screen: [ve]
885
885
  }, ve]
886
886
  }],
@@ -889,28 +889,28 @@ const q = (e) => {
889
889
  * @see https://tailwindcss.com/docs/height
890
890
  */
891
891
  h: [{
892
- h: [z, t, "auto", "min", "max", "fit", "svh", "lvh", "dvh"]
892
+ h: [R, t, "auto", "min", "max", "fit", "svh", "lvh", "dvh"]
893
893
  }],
894
894
  /**
895
895
  * Min-Height
896
896
  * @see https://tailwindcss.com/docs/min-height
897
897
  */
898
898
  "min-h": [{
899
- "min-h": [z, t, "min", "max", "fit", "svh", "lvh", "dvh"]
899
+ "min-h": [R, t, "min", "max", "fit", "svh", "lvh", "dvh"]
900
900
  }],
901
901
  /**
902
902
  * Max-Height
903
903
  * @see https://tailwindcss.com/docs/max-height
904
904
  */
905
905
  "max-h": [{
906
- "max-h": [z, t, "min", "max", "fit", "svh", "lvh", "dvh"]
906
+ "max-h": [R, t, "min", "max", "fit", "svh", "lvh", "dvh"]
907
907
  }],
908
908
  /**
909
909
  * Size
910
910
  * @see https://tailwindcss.com/docs/size
911
911
  */
912
912
  size: [{
913
- size: [z, t, "auto", "min", "max", "fit"]
913
+ size: [R, t, "auto", "min", "max", "fit"]
914
914
  }],
915
915
  // Typography
916
916
  /**
@@ -935,7 +935,7 @@ const q = (e) => {
935
935
  * @see https://tailwindcss.com/docs/font-weight
936
936
  */
937
937
  "font-weight": [{
938
- font: ["thin", "extralight", "light", "normal", "medium", "semibold", "bold", "extrabold", "black", qe]
938
+ font: ["thin", "extralight", "light", "normal", "medium", "semibold", "bold", "extrabold", "black", Ve]
939
939
  }],
940
940
  /**
941
941
  * Font Family
@@ -979,35 +979,35 @@ const q = (e) => {
979
979
  * @see https://tailwindcss.com/docs/letter-spacing
980
980
  */
981
981
  tracking: [{
982
- tracking: ["tighter", "tight", "normal", "wide", "wider", "widest", z]
982
+ tracking: ["tighter", "tight", "normal", "wide", "wider", "widest", R]
983
983
  }],
984
984
  /**
985
985
  * Line Clamp
986
986
  * @see https://tailwindcss.com/docs/line-clamp
987
987
  */
988
988
  "line-clamp": [{
989
- "line-clamp": ["none", Te, qe]
989
+ "line-clamp": ["none", Te, Ve]
990
990
  }],
991
991
  /**
992
992
  * Line Height
993
993
  * @see https://tailwindcss.com/docs/line-height
994
994
  */
995
995
  leading: [{
996
- leading: ["none", "tight", "snug", "normal", "relaxed", "loose", pe, z]
996
+ leading: ["none", "tight", "snug", "normal", "relaxed", "loose", pe, R]
997
997
  }],
998
998
  /**
999
999
  * List Style Image
1000
1000
  * @see https://tailwindcss.com/docs/list-style-image
1001
1001
  */
1002
1002
  "list-image": [{
1003
- "list-image": ["none", z]
1003
+ "list-image": ["none", R]
1004
1004
  }],
1005
1005
  /**
1006
1006
  * List Style Type
1007
1007
  * @see https://tailwindcss.com/docs/list-style-type
1008
1008
  */
1009
1009
  "list-style-type": [{
1010
- list: ["none", "disc", "decimal", z]
1010
+ list: ["none", "disc", "decimal", R]
1011
1011
  }],
1012
1012
  /**
1013
1013
  * List Style Position
@@ -1062,7 +1062,7 @@ const q = (e) => {
1062
1062
  * @see https://tailwindcss.com/docs/text-decoration-style
1063
1063
  */
1064
1064
  "text-decoration-style": [{
1065
- decoration: [...O(), "wavy"]
1065
+ decoration: [...P(), "wavy"]
1066
1066
  }],
1067
1067
  /**
1068
1068
  * Text Decoration Thickness
@@ -1076,7 +1076,7 @@ const q = (e) => {
1076
1076
  * @see https://tailwindcss.com/docs/text-underline-offset
1077
1077
  */
1078
1078
  "underline-offset": [{
1079
- "underline-offset": ["auto", pe, z]
1079
+ "underline-offset": ["auto", pe, R]
1080
1080
  }],
1081
1081
  /**
1082
1082
  * Text Decoration Color
@@ -1114,7 +1114,7 @@ const q = (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", z]
1117
+ align: ["baseline", "top", "middle", "bottom", "text-top", "text-bottom", "sub", "super", R]
1118
1118
  }],
1119
1119
  /**
1120
1120
  * Whitespace
@@ -1142,7 +1142,7 @@ const q = (e) => {
1142
1142
  * @see https://tailwindcss.com/docs/content
1143
1143
  */
1144
1144
  content: [{
1145
- content: ["none", z]
1145
+ content: ["none", R]
1146
1146
  }],
1147
1147
  // Backgrounds
1148
1148
  /**
@@ -1179,7 +1179,7 @@ const q = (e) => {
1179
1179
  * @see https://tailwindcss.com/docs/background-position
1180
1180
  */
1181
1181
  "bg-position": [{
1182
- bg: [..._(), vn]
1182
+ bg: [...V(), vn]
1183
1183
  }],
1184
1184
  /**
1185
1185
  * Background Repeat
@@ -1218,42 +1218,42 @@ const q = (e) => {
1218
1218
  * @see https://tailwindcss.com/docs/gradient-color-stops
1219
1219
  */
1220
1220
  "gradient-from-pos": [{
1221
- from: [I]
1221
+ from: [v]
1222
1222
  }],
1223
1223
  /**
1224
1224
  * Gradient Color Stops Via Position
1225
1225
  * @see https://tailwindcss.com/docs/gradient-color-stops
1226
1226
  */
1227
1227
  "gradient-via-pos": [{
1228
- via: [I]
1228
+ via: [v]
1229
1229
  }],
1230
1230
  /**
1231
1231
  * Gradient Color Stops To Position
1232
1232
  * @see https://tailwindcss.com/docs/gradient-color-stops
1233
1233
  */
1234
1234
  "gradient-to-pos": [{
1235
- to: [I]
1235
+ to: [v]
1236
1236
  }],
1237
1237
  /**
1238
1238
  * Gradient Color Stops From
1239
1239
  * @see https://tailwindcss.com/docs/gradient-color-stops
1240
1240
  */
1241
1241
  "gradient-from": [{
1242
- from: [g]
1242
+ from: [m]
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: [g]
1249
+ via: [m]
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: [g]
1256
+ to: [m]
1257
1257
  }],
1258
1258
  // Borders
1259
1259
  /**
@@ -1261,105 +1261,105 @@ const q = (e) => {
1261
1261
  * @see https://tailwindcss.com/docs/border-radius
1262
1262
  */
1263
1263
  rounded: [{
1264
- rounded: [s]
1264
+ rounded: [o]
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": [s]
1271
+ "rounded-s": [o]
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": [s]
1278
+ "rounded-e": [o]
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": [s]
1285
+ "rounded-t": [o]
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": [s]
1292
+ "rounded-r": [o]
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": [s]
1299
+ "rounded-b": [o]
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": [s]
1306
+ "rounded-l": [o]
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": [s]
1313
+ "rounded-ss": [o]
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": [s]
1320
+ "rounded-se": [o]
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": [s]
1327
+ "rounded-ee": [o]
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": [s]
1334
+ "rounded-es": [o]
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": [s]
1341
+ "rounded-tl": [o]
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": [s]
1348
+ "rounded-tr": [o]
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": [s]
1355
+ "rounded-br": [o]
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": [s]
1362
+ "rounded-bl": [o]
1363
1363
  }],
1364
1364
  /**
1365
1365
  * Border Width
@@ -1436,7 +1436,7 @@ const q = (e) => {
1436
1436
  * @see https://tailwindcss.com/docs/border-style
1437
1437
  */
1438
1438
  "border-style": [{
1439
- border: [...O(), "hidden"]
1439
+ border: [...P(), "hidden"]
1440
1440
  }],
1441
1441
  /**
1442
1442
  * Divide Width X
@@ -1474,91 +1474,91 @@ const q = (e) => {
1474
1474
  * @see https://tailwindcss.com/docs/divide-style
1475
1475
  */
1476
1476
  "divide-style": [{
1477
- divide: O()
1477
+ divide: P()
1478
1478
  }],
1479
1479
  /**
1480
1480
  * Border Color
1481
1481
  * @see https://tailwindcss.com/docs/border-color
1482
1482
  */
1483
1483
  "border-color": [{
1484
- border: [o]
1484
+ border: [s]
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": [o]
1491
+ "border-x": [s]
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": [o]
1498
+ "border-y": [s]
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": [o]
1505
+ "border-s": [s]
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": [o]
1512
+ "border-e": [s]
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": [o]
1519
+ "border-t": [s]
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": [o]
1526
+ "border-r": [s]
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": [o]
1533
+ "border-b": [s]
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": [o]
1540
+ "border-l": [s]
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: [o]
1547
+ divide: [s]
1548
1548
  }],
1549
1549
  /**
1550
1550
  * Outline Style
1551
1551
  * @see https://tailwindcss.com/docs/outline-style
1552
1552
  */
1553
1553
  "outline-style": [{
1554
- outline: ["", ...O()]
1554
+ outline: ["", ...P()]
1555
1555
  }],
1556
1556
  /**
1557
1557
  * Outline Offset
1558
1558
  * @see https://tailwindcss.com/docs/outline-offset
1559
1559
  */
1560
1560
  "outline-offset": [{
1561
- "outline-offset": [pe, z]
1561
+ "outline-offset": [pe, R]
1562
1562
  }],
1563
1563
  /**
1564
1564
  * Outline Width
@@ -1641,14 +1641,14 @@ const q = (e) => {
1641
1641
  * @see https://tailwindcss.com/docs/mix-blend-mode
1642
1642
  */
1643
1643
  "mix-blend": [{
1644
- "mix-blend": [...R(), "plus-lighter", "plus-darker"]
1644
+ "mix-blend": [...F(), "plus-lighter", "plus-darker"]
1645
1645
  }],
1646
1646
  /**
1647
1647
  * Background Blend Mode
1648
1648
  * @see https://tailwindcss.com/docs/background-blend-mode
1649
1649
  */
1650
1650
  "bg-blend": [{
1651
- "bg-blend": R()
1651
+ "bg-blend": F()
1652
1652
  }],
1653
1653
  // Filters
1654
1654
  /**
@@ -1678,35 +1678,35 @@ const q = (e) => {
1678
1678
  * @see https://tailwindcss.com/docs/contrast
1679
1679
  */
1680
1680
  contrast: [{
1681
- contrast: [d]
1681
+ contrast: [u]
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", ve, z]
1688
+ "drop-shadow": ["", "none", ve, R]
1689
1689
  }],
1690
1690
  /**
1691
1691
  * Grayscale
1692
1692
  * @see https://tailwindcss.com/docs/grayscale
1693
1693
  */
1694
1694
  grayscale: [{
1695
- grayscale: [c]
1695
+ grayscale: [l]
1696
1696
  }],
1697
1697
  /**
1698
1698
  * Hue Rotate
1699
1699
  * @see https://tailwindcss.com/docs/hue-rotate
1700
1700
  */
1701
1701
  "hue-rotate": [{
1702
- "hue-rotate": [l]
1702
+ "hue-rotate": [c]
1703
1703
  }],
1704
1704
  /**
1705
1705
  * Invert
1706
1706
  * @see https://tailwindcss.com/docs/invert
1707
1707
  */
1708
1708
  invert: [{
1709
- invert: [f]
1709
+ invert: [d]
1710
1710
  }],
1711
1711
  /**
1712
1712
  * Saturate
@@ -1720,7 +1720,7 @@ const q = (e) => {
1720
1720
  * @see https://tailwindcss.com/docs/sepia
1721
1721
  */
1722
1722
  sepia: [{
1723
- sepia: [b]
1723
+ sepia: [k]
1724
1724
  }],
1725
1725
  /**
1726
1726
  * Backdrop Filter
@@ -1749,28 +1749,28 @@ const q = (e) => {
1749
1749
  * @see https://tailwindcss.com/docs/backdrop-contrast
1750
1750
  */
1751
1751
  "backdrop-contrast": [{
1752
- "backdrop-contrast": [d]
1752
+ "backdrop-contrast": [u]
1753
1753
  }],
1754
1754
  /**
1755
1755
  * Backdrop Grayscale
1756
1756
  * @see https://tailwindcss.com/docs/backdrop-grayscale
1757
1757
  */
1758
1758
  "backdrop-grayscale": [{
1759
- "backdrop-grayscale": [c]
1759
+ "backdrop-grayscale": [l]
1760
1760
  }],
1761
1761
  /**
1762
1762
  * Backdrop Hue Rotate
1763
1763
  * @see https://tailwindcss.com/docs/backdrop-hue-rotate
1764
1764
  */
1765
1765
  "backdrop-hue-rotate": [{
1766
- "backdrop-hue-rotate": [l]
1766
+ "backdrop-hue-rotate": [c]
1767
1767
  }],
1768
1768
  /**
1769
1769
  * Backdrop Invert
1770
1770
  * @see https://tailwindcss.com/docs/backdrop-invert
1771
1771
  */
1772
1772
  "backdrop-invert": [{
1773
- "backdrop-invert": [f]
1773
+ "backdrop-invert": [d]
1774
1774
  }],
1775
1775
  /**
1776
1776
  * Backdrop Opacity
@@ -1791,7 +1791,7 @@ const q = (e) => {
1791
1791
  * @see https://tailwindcss.com/docs/backdrop-sepia
1792
1792
  */
1793
1793
  "backdrop-sepia": [{
1794
- "backdrop-sepia": [b]
1794
+ "backdrop-sepia": [k]
1795
1795
  }],
1796
1796
  // Tables
1797
1797
  /**
@@ -1842,35 +1842,35 @@ const q = (e) => {
1842
1842
  * @see https://tailwindcss.com/docs/transition-property
1843
1843
  */
1844
1844
  transition: [{
1845
- transition: ["none", "all", "", "colors", "opacity", "shadow", "transform", z]
1845
+ transition: ["none", "all", "", "colors", "opacity", "shadow", "transform", R]
1846
1846
  }],
1847
1847
  /**
1848
1848
  * Transition Duration
1849
1849
  * @see https://tailwindcss.com/docs/transition-duration
1850
1850
  */
1851
1851
  duration: [{
1852
- duration: h()
1852
+ duration: g()
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", z]
1859
+ ease: ["linear", "in", "out", "in-out", R]
1860
1860
  }],
1861
1861
  /**
1862
1862
  * Transition Delay
1863
1863
  * @see https://tailwindcss.com/docs/transition-delay
1864
1864
  */
1865
1865
  delay: [{
1866
- delay: h()
1866
+ delay: g()
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", z]
1873
+ animate: ["none", "spin", "ping", "pulse", "bounce", R]
1874
1874
  }],
1875
1875
  // Transforms
1876
1876
  /**
@@ -1906,42 +1906,42 @@ const q = (e) => {
1906
1906
  * @see https://tailwindcss.com/docs/rotate
1907
1907
  */
1908
1908
  rotate: [{
1909
- rotate: [_e, z]
1909
+ rotate: [_e, R]
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": [m]
1916
+ "translate-x": [y]
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": [m]
1923
+ "translate-y": [y]
1924
1924
  }],
1925
1925
  /**
1926
1926
  * Skew X
1927
1927
  * @see https://tailwindcss.com/docs/skew
1928
1928
  */
1929
1929
  "skew-x": [{
1930
- "skew-x": [y]
1930
+ "skew-x": [h]
1931
1931
  }],
1932
1932
  /**
1933
1933
  * Skew Y
1934
1934
  * @see https://tailwindcss.com/docs/skew
1935
1935
  */
1936
1936
  "skew-y": [{
1937
- "skew-y": [y]
1937
+ "skew-y": [h]
1938
1938
  }],
1939
1939
  /**
1940
1940
  * Transform Origin
1941
1941
  * @see https://tailwindcss.com/docs/transform-origin
1942
1942
  */
1943
1943
  "transform-origin": [{
1944
- origin: ["center", "top", "top-right", "right", "bottom-right", "bottom", "bottom-left", "left", "top-left", z]
1944
+ origin: ["center", "top", "top-right", "right", "bottom-right", "bottom", "bottom-left", "left", "top-left", R]
1945
1945
  }],
1946
1946
  // Interactivity
1947
1947
  /**
@@ -1963,7 +1963,7 @@ const q = (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", z]
1966
+ cursor: ["auto", "default", "pointer", "wait", "text", "move", "help", "not-allowed", "none", "context-menu", "progress", "cell", "crosshair", "vertical-text", "alias", "copy", "no-drop", "grab", "grabbing", "all-scroll", "col-resize", "row-resize", "n-resize", "e-resize", "s-resize", "w-resize", "ne-resize", "nw-resize", "se-resize", "sw-resize", "ew-resize", "ns-resize", "nesw-resize", "nwse-resize", "zoom-in", "zoom-out", R]
1967
1967
  }],
1968
1968
  /**
1969
1969
  * Caret Color
@@ -2185,7 +2185,7 @@ const q = (e) => {
2185
2185
  * @see https://tailwindcss.com/docs/will-change
2186
2186
  */
2187
2187
  "will-change": [{
2188
- "will-change": ["auto", "scroll", "contents", "transform", z]
2188
+ "will-change": ["auto", "scroll", "contents", "transform", R]
2189
2189
  }],
2190
2190
  // SVG
2191
2191
  /**
@@ -2200,7 +2200,7 @@ const q = (e) => {
2200
2200
  * @see https://tailwindcss.com/docs/stroke-width
2201
2201
  */
2202
2202
  "stroke-w": [{
2203
- stroke: [pe, Ie, qe]
2203
+ stroke: [pe, Ie, Ve]
2204
2204
  }],
2205
2205
  /**
2206
2206
  * Stroke
@@ -2281,16 +2281,16 @@ function ro(...e) {
2281
2281
  }
2282
2282
  function _n(e) {
2283
2283
  let t = !1, n = "";
2284
- for (const o of e) {
2285
- if (o === "\\") {
2286
- n += o, t = !t;
2284
+ for (const s of e) {
2285
+ if (s === "\\") {
2286
+ n += s, t = !t;
2287
2287
  continue;
2288
2288
  }
2289
- if (o === "'" && !t) {
2289
+ if (s === "'" && !t) {
2290
2290
  n += '"';
2291
2291
  continue;
2292
2292
  }
2293
- n += o, t = !1;
2293
+ n += s, t = !1;
2294
2294
  }
2295
2295
  return n.replace(/\bTrue\b/g, "true").replace(/\bFalse\b/g, "false").replace(/\bNone\b/g, "null");
2296
2296
  }
@@ -2372,8 +2372,8 @@ function De(e) {
2372
2372
  if (n === "data" && typeof r == "string" && r.length > 100)
2373
2373
  t[n] = `[base64 ${r.length} chars omitted]`;
2374
2374
  else {
2375
- const o = De(r);
2376
- o !== void 0 && (t[n] = o);
2375
+ const s = De(r);
2376
+ s !== void 0 && (t[n] = s);
2377
2377
  }
2378
2378
  }
2379
2379
  if (Object.keys(t).length)
@@ -2404,8 +2404,8 @@ function oo(e) {
2404
2404
  function Fn(e) {
2405
2405
  const t = (r) => {
2406
2406
  try {
2407
- const o = De(r);
2408
- return typeof o == "string" ? o : JSON.stringify(o ?? "");
2407
+ const s = De(r);
2408
+ return typeof s == "string" ? s : JSON.stringify(s ?? "");
2409
2409
  } catch {
2410
2410
  return "";
2411
2411
  }
@@ -2448,26 +2448,26 @@ function fe(e) {
2448
2448
  );
2449
2449
  }
2450
2450
  function nt(e) {
2451
- var x, S, A, w, b, y, T;
2451
+ var x, S, A, w, k, h, T;
2452
2452
  if (!e || typeof e != "object") return null;
2453
2453
  const t = fe(e), n = Kn(t);
2454
2454
  if (!n)
2455
2455
  return null;
2456
- const r = t.toolCalls ?? ((x = t.additionalKwargs) == null ? void 0 : x.toolCalls), o = Array.isArray(r) ? r.map(rt) : void 0, s = Dn(t.content ?? t.parts, !!(o != null && o.length)), a = t.id ?? `msg-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`, i = t.createdAt ?? ((S = t.additionalKwargs) == null ? void 0 : S.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(), 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 ?? ((y = t.additionalKwargs) == null ? void 0 : y.checkpointNs) ?? void 0, u = 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), s = Array.isArray(r) ? r.map(rt) : void 0, o = Dn(t.content ?? t.parts, !!(s != null && s.length)), a = t.id ?? `msg-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`, i = t.createdAt ?? ((S = t.additionalKwargs) == null ? void 0 : S.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(), u = t.name ?? ((A = t.additionalKwargs) == null ? void 0 : A.agentName) ?? void 0, l = t.model ?? ((w = t.additionalKwargs) == null ? void 0 : w.model) ?? void 0, c = t.toolCallId ?? void 0, d = t.additionalKwargs ?? void 0, p = t.responseMetadata ?? void 0, m = t.checkpointId ?? ((k = t.additionalKwargs) == null ? void 0 : k.checkpointId) ?? void 0, v = t.checkpointNs ?? ((h = t.additionalKwargs) == null ? void 0 : h.checkpointNs) ?? void 0, f = typeof t.toolStreaming == "boolean" ? t.toolStreaming : !!((T = t.additionalKwargs) != null && T.toolStreaming);
2457
2457
  return {
2458
2458
  ...t,
2459
2459
  id: a,
2460
2460
  role: n,
2461
- content: s,
2461
+ content: o,
2462
2462
  createdAt: i,
2463
- name: d,
2464
- model: c,
2465
- toolCallId: l,
2466
- toolCalls: o,
2467
- checkpointId: g,
2468
- checkpointNs: I,
2469
- toolStreaming: u,
2470
- additionalKwargs: f,
2463
+ name: u,
2464
+ model: l,
2465
+ toolCallId: c,
2466
+ toolCalls: s,
2467
+ checkpointId: m,
2468
+ checkpointNs: v,
2469
+ toolStreaming: f,
2470
+ additionalKwargs: d,
2471
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
  };
@@ -2512,66 +2512,66 @@ function dt(e) {
2512
2512
  function ut(e) {
2513
2513
  return (Array.isArray(e.toolCalls) ? e.toolCalls : Mt(e)).map(rt);
2514
2514
  }
2515
- function He(e, t) {
2515
+ function qe(e, t) {
2516
2516
  return t.find(
2517
2517
  (n) => n.role === "tool" && (n.toolCallId === e || n.id === e)
2518
2518
  );
2519
2519
  }
2520
- function Vn(e, t) {
2520
+ function Hn(e, t) {
2521
2521
  const n = t.response ?? t.content;
2522
2522
  if (!n) return;
2523
2523
  const r = typeof n == "string" ? n : Et(n);
2524
2524
  if (!r.trim()) return;
2525
- const o = [{ type: "text", text: r }];
2525
+ const s = [{ type: "text", text: r }];
2526
2526
  return {
2527
2527
  id: `tool-${t.id}`,
2528
2528
  role: "tool",
2529
- content: o,
2529
+ content: s,
2530
2530
  name: t.name,
2531
2531
  toolCallId: t.id,
2532
2532
  artifact: t.artifact,
2533
2533
  createdAt: e.createdAt
2534
2534
  };
2535
2535
  }
2536
- function qn(e, t = []) {
2536
+ function Vn(e, t = []) {
2537
2537
  if (Array.isArray(e)) {
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
- if (i && !a.content && l === "completed") {
2543
- const I = ue(i);
2544
- typeof I == "string" && (a.content = I);
2538
+ const s = e.filter((a) => a.role === "assistant").flatMap((a) => ut(a)), o = /* @__PURE__ */ new Map();
2539
+ return s.forEach((a) => o.set(a.id, a)), Array.from(o.values()).map((a) => {
2540
+ var d, p, m;
2541
+ const i = qe(a.id, e) || qe(a.id, t), u = Array.isArray((d = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : d.toolProgress) ? (p = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : p.toolProgress : void 0, l = (i == null ? void 0 : i.artifact) ?? a.artifact, c = dt(a.status) ?? ((m = i == null ? void 0 : i.additionalKwargs) != null && m.toolStreaming ? "pending" : null) ?? (i ? "completed" : "pending");
2542
+ if (i && !a.content && c === "completed") {
2543
+ const v = ue(i);
2544
+ typeof v == "string" && (a.content = v);
2545
2545
  }
2546
2546
  return {
2547
2547
  call: a,
2548
2548
  result: i,
2549
- state: l,
2550
- progress: d,
2551
- artifact: c
2549
+ state: c,
2550
+ progress: u,
2551
+ artifact: l
2552
2552
  };
2553
2553
  });
2554
2554
  }
2555
2555
  if (e.role !== "assistant") return [];
2556
2556
  const n = ut(e);
2557
2557
  return n.length === 0 ? [] : n.map((r) => {
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 = ue(o);
2562
- typeof f == "string" && (r.content = f);
2558
+ var u, l, c;
2559
+ const s = qe(r.id, t) ?? Hn(e, r), o = Array.isArray((u = s == null ? void 0 : s.additionalKwargs) == null ? void 0 : u.toolProgress) ? (l = s == null ? void 0 : s.additionalKwargs) == null ? void 0 : l.toolProgress : void 0, a = (s == null ? void 0 : s.artifact) ?? r.artifact, i = dt(r.status) ?? ((c = s == null ? void 0 : s.additionalKwargs) != null && c.toolStreaming ? "pending" : null) ?? (s ? "completed" : "pending");
2560
+ if (s && !r.content && i === "completed") {
2561
+ const d = ue(s);
2562
+ typeof d == "string" && (r.content = d);
2563
2563
  }
2564
2564
  return {
2565
2565
  call: r,
2566
- result: o,
2566
+ result: s,
2567
2567
  state: i,
2568
- progress: s,
2568
+ progress: o,
2569
2569
  artifact: a
2570
2570
  };
2571
2571
  });
2572
2572
  }
2573
2573
  function ao(e, t = []) {
2574
- return qn(e, t).map((n) => n.artifact).filter((n) => !!n);
2574
+ return Vn(e, t).map((n) => n.artifact).filter((n) => !!n);
2575
2575
  }
2576
2576
  const ze = {
2577
2577
  authToken: "authToken",
@@ -2596,8 +2596,8 @@ function xe(e) {
2596
2596
  function _t(e) {
2597
2597
  return Qe.add(e), () => Qe.delete(e);
2598
2598
  }
2599
- const Hn = 12e4, Gn = 12e4;
2600
- let Ye = Hn, Nt = Gn;
2599
+ const qn = 12e4, Gn = 12e4;
2600
+ let Ye = qn, Nt = Gn;
2601
2601
  const oe = Jt.create({
2602
2602
  // BaseURL is set dynamically via ApiProvider -> api.updateConfig
2603
2603
  timeout: Ye,
@@ -2618,10 +2618,10 @@ oe.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, o = typeof t.expires_at == "number" && t.expires_at || typeof n.expires_at == "number" && n.expires_at || typeof t.expiresAt == "number" && t.expiresAt || typeof n.expiresAt == "number" && n.expiresAt || null;
2622
- r && (localStorage.setItem(ze.authToken, r), xe(r)), o && localStorage.setItem(ze.authTokenExpiresAt, o.toString()), (r || o) && window.dispatchEvent(
2621
+ const t = e.data, n = t.data || {}, r = typeof t.token == "string" && t.token || typeof n.token == "string" && n.token || null, s = typeof t.expires_at == "number" && t.expires_at || typeof n.expires_at == "number" && n.expires_at || typeof t.expiresAt == "number" && t.expiresAt || typeof n.expiresAt == "number" && n.expiresAt || null;
2622
+ r && (localStorage.setItem(ze.authToken, r), xe(r)), s && localStorage.setItem(ze.authTokenExpiresAt, s.toString()), (r || s) && window.dispatchEvent(
2623
2623
  new CustomEvent("smartorg:chat-token-updated", {
2624
- detail: { token: r, expiresAt: o }
2624
+ detail: { token: r, expiresAt: s }
2625
2625
  })
2626
2626
  );
2627
2627
  } catch (t) {
@@ -2684,8 +2684,8 @@ class Yn {
2684
2684
  async createThread(t, n) {
2685
2685
  const r = {};
2686
2686
  t && (r.title = t), n && (r.project = n);
2687
- const o = await Ze("/threads", Object.keys(r).length ? r : void 0);
2688
- return le(o);
2687
+ const s = await Ze("/threads", Object.keys(r).length ? r : void 0);
2688
+ return le(s);
2689
2689
  }
2690
2690
  async updateThread(t, n) {
2691
2691
  const r = await Xn(`/threads/${t}`, { title: n });
@@ -2748,11 +2748,11 @@ class Zn {
2748
2748
  async fetchFileBlob(t, n) {
2749
2749
  return await ae(t, {
2750
2750
  responseType: "blob",
2751
- onDownloadProgress: (o) => {
2751
+ onDownloadProgress: (s) => {
2752
2752
  try {
2753
- if (n && o.lengthComputable) {
2754
- const s = o.loaded / o.total;
2755
- n(s);
2753
+ if (n && s.lengthComputable) {
2754
+ const o = s.loaded / s.total;
2755
+ n(o);
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), o = URL.createObjectURL(r);
2766
- window.open(o, "_blank"), setTimeout(() => URL.revokeObjectURL(o), 6e4);
2765
+ const r = await this.fetchFileBlob(`/files/${t}/view`, n), s = URL.createObjectURL(r);
2766
+ window.open(s, "_blank"), setTimeout(() => URL.revokeObjectURL(s), 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), o = URL.createObjectURL(r);
2776
- let s = `file_${t}`;
2775
+ const r = await this.fetchFileBlob(`/files/${t}/download`, n), s = URL.createObjectURL(r);
2776
+ let o = `file_${t}`;
2777
2777
  try {
2778
2778
  const i = await ae(`/files/${t}`);
2779
- s = (i == null ? void 0 : i.filename) ?? s;
2779
+ o = (i == null ? void 0 : i.filename) ?? o;
2780
2780
  } catch {
2781
2781
  }
2782
2782
  const a = document.createElement("a");
2783
- a.href = o, a.download = s, document.body.appendChild(a), a.click(), a.remove(), setTimeout(() => URL.revokeObjectURL(o), 6e4);
2783
+ a.href = s, a.download = o, document.body.appendChild(a), a.click(), a.remove(), setTimeout(() => URL.revokeObjectURL(s), 6e4);
2784
2784
  }
2785
2785
  async getFileInfo(t) {
2786
2786
  return await ae(`/files/${t}`);
2787
2787
  }
2788
2788
  async listFiles(t, n = 50, r = 0) {
2789
- const o = { limit: n, offset: r };
2790
- return t && (o.thread_id = t), await ae("/files", { params: o });
2789
+ const s = { limit: n, offset: r };
2790
+ return t && (s.thread_id = t), await ae("/files", { params: s });
2791
2791
  }
2792
2792
  async uploadFile(t, n, r) {
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) => {
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) => {
2796
2796
  try {
2797
- if (r && s.lengthComputable) {
2798
- const a = s.loaded / s.total;
2797
+ if (r && o.lengthComputable) {
2798
+ const a = o.loaded / o.total;
2799
2799
  r(a);
2800
2800
  }
2801
2801
  } catch {
@@ -2842,53 +2842,53 @@ const tr = new er(), Lt = Ce(null);
2842
2842
  function nr({ children: e, apiConfig: t }) {
2843
2843
  const n = zt, r = tr;
2844
2844
  if (t) {
2845
- const 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 }));
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 }));
2847
2847
  }
2848
- const o = {
2848
+ const s = {
2849
2849
  token: n.getAuthToken(),
2850
- setToken: (s) => {
2851
- n.setAuthToken(s), r.setAuthToken(s);
2850
+ setToken: (o) => {
2851
+ n.setAuthToken(o), r.setAuthToken(o);
2852
2852
  },
2853
2853
  chatApi: n,
2854
2854
  authApi: r,
2855
2855
  fileApi: Rt,
2856
2856
  baseUrl: n.baseUrl
2857
2857
  };
2858
- return /* @__PURE__ */ de(Lt.Provider, { value: o, children: e });
2858
+ return /* @__PURE__ */ de(Lt.Provider, { value: s, 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 o = r.result, s = new Uint8Array(o);
2865
+ const s = r.result, o = new Uint8Array(s);
2866
2866
  let a = "";
2867
- const i = s.byteLength;
2868
- for (let d = 0; d < i; d++) a += String.fromCharCode(s[d]);
2867
+ const i = o.byteLength;
2868
+ for (let u = 0; u < i; u++) a += String.fromCharCode(o[u]);
2869
2869
  t(btoa(a));
2870
- } catch (o) {
2871
- n(o);
2870
+ } catch (s) {
2871
+ n(s);
2872
2872
  }
2873
- }, r.onerror = (o) => n(o), r.readAsArrayBuffer(e);
2873
+ }, r.onerror = (s) => n(s), r.readAsArrayBuffer(e);
2874
2874
  });
2875
2875
  }
2876
2876
  async function or(e = []) {
2877
2877
  const t = [], n = [];
2878
2878
  for (const r of e)
2879
2879
  try {
2880
- const o = await rr(r), s = r.type || "application/octet-stream";
2880
+ const s = await rr(r), o = r.type || "application/octet-stream";
2881
2881
  n.push({
2882
2882
  filename: r.name,
2883
- data: o,
2884
- mime_type: s
2885
- }), s.startsWith("image/") ? t.push({
2883
+ data: s,
2884
+ mime_type: o
2885
+ }), o.startsWith("image/") ? t.push({
2886
2886
  type: "image_url",
2887
- image_url: { url: `data:${s};base64,${o}` }
2887
+ image_url: { url: `data:${o};base64,${s}` }
2888
2888
  }) : t.push({
2889
2889
  type: "file",
2890
- url: `data:${s};base64,${o}`,
2891
- mimeType: s,
2890
+ url: `data:${o};base64,${s}`,
2891
+ mimeType: o,
2892
2892
  name: r.name,
2893
2893
  size: r.size
2894
2894
  });
@@ -2927,8 +2927,8 @@ function lo(e) {
2927
2927
  default:
2928
2928
  return a.type === "interrupt" ? "interrupt" : "unknown";
2929
2929
  }
2930
- }).join("|") : "", r = "checkpointId" in e && e.checkpointId ? `cp:${e.checkpointId}` : "", o = "checkpointNs" in e && e.checkpointNs ? `ns:${e.checkpointNs}` : "", s = [r, o].filter(Boolean).join("|");
2931
- return `${e.id}:${t}:${n}${s ? `:${s}` : ""}`;
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}` : ""}`;
2932
2932
  }
2933
2933
  function Me() {
2934
2934
  const e = je(Lt);
@@ -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, o] = D(e.token ?? null), s = H(e.headers ?? {}), a = e.credentials ?? "include", i = H(e);
3012
+ const t = e.baseUrl || "", n = e.streamPath ?? "/stream", [r, s] = H(e.token ?? null), o = W(e.headers ?? {}), a = e.credentials ?? "include", i = W(e);
3013
3013
  Y(() => {
3014
3014
  i.current = e;
3015
3015
  }, [e]);
3016
- const d = N((m) => {
3017
- var U, M, $, F, _, O, R, W, B, L;
3018
- const k = i.current;
3019
- if (!k) return;
3020
- (U = k.onEvent) == null || U.call(k, m), m.type === "thread_info" && ((M = k.onThreadInfo) == null || M.call(k, m)), m.type === "values" && (($ = k.handleValuesEvent) == null || $.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.")) && ((_ = k.onCustomEvent) == null || _.call(k, m)), m.type === "updates" && ((O = k.onUpdateEvent) == null || O.call(k, m)), m.type === "tool.end" ? (R = k.onToolEnd) == null || R.call(k, m) : m.type === "tool.start" && ((W = k.onToolStart) == null || W.call(k, m)), m.type === "heartbeat" && ((B = k.onHeartbeat) == null || B.call(k, m)), m.type === "token" && ((L = k.onToken) == null || L.call(k, m.token));
3021
- }, []), [c, l] = D(!1), [f, p] = D(null), [g, I] = D(!1), [u, v] = D(null), x = H(null), S = H(!0), A = H(null), w = N((m) => {
3022
- o(m);
3023
- }, []), b = N(() => {
3024
- p(null), v(null);
3025
- }, []), y = N(() => {
3016
+ const u = _((y) => {
3017
+ var L, M, $, U, V, P, F, N, j, G;
3018
+ const I = i.current;
3019
+ if (!I) return;
3020
+ (L = I.onEvent) == null || L.call(I, y), y.type === "thread_info" && ((M = I.onThreadInfo) == null || M.call(I, y)), y.type === "values" && (($ = I.handleValuesEvent) == null || $.call(I, y)), y.type === "metadata" && ((U = I.onMetadataEvent) == null || U.call(I, y)), typeof y.type == "string" && (y.type === "custom" || y.type.startsWith("custom.")) && ((V = I.onCustomEvent) == null || V.call(I, y)), y.type === "updates" && ((P = I.onUpdateEvent) == null || P.call(I, y)), y.type === "tool.end" ? (F = I.onToolEnd) == null || F.call(I, y) : y.type === "tool.start" && ((N = I.onToolStart) == null || N.call(I, y)), y.type === "heartbeat" && ((j = I.onHeartbeat) == null || j.call(I, y)), y.type === "token" && ((G = I.onToken) == null || G.call(I, y.token));
3021
+ }, []), [l, c] = H(!1), [d, p] = H(null), [m, v] = H(!1), [f, b] = H(null), x = W(null), S = W(!0), A = W(null), w = _((y) => {
3022
+ s(y);
3023
+ }, []), k = _(() => {
3024
+ p(null), b(null);
3025
+ }, []), h = _(() => {
3026
3026
  var M, $;
3027
3027
  console.debug("[use-chat] stop() invoked - aborting stream");
3028
- const m = (M = A.current) == null ? void 0 : M.threadId, k = ($ = A.current) == null ? void 0 : $.runId, E = () => {
3029
- var F;
3030
- (F = x.current) == null || F.abort(), x.current = null, A.current = null, l(!1), I(!1);
3028
+ const y = (M = A.current) == null ? void 0 : M.threadId, I = ($ = A.current) == null ? void 0 : $.runId, E = () => {
3029
+ var U;
3030
+ (U = x.current) == null || U.abort(), x.current = null, A.current = null, c(!1), v(!1);
3031
3031
  };
3032
- (k || m ? zt.cancelRun(k || m).catch((F) => {
3033
- console.warn("[use-chat] cancel run failed:", F);
3032
+ (I || y ? zt.cancelRun(I || y).catch((U) => {
3033
+ console.warn("[use-chat] cancel run failed:", U);
3034
3034
  }) : Promise.resolve()).finally(E);
3035
- }, []), T = N(
3036
- (m) => {
3035
+ }, []), T = _(
3036
+ (y) => {
3037
3037
  x.current && (x.current.abort(), x.current = null);
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"
3038
+ const I = {
3039
+ text: typeof y.content == "string" ? y.content : y.text,
3040
+ threadId: y.threadId,
3041
+ attachments: y.attachments,
3042
+ payload: y.payload ? {
3043
+ ...y.payload,
3044
+ creativityLevel: y.payload.creativityLevel ?? "medium"
3045
3045
  } : { creativityLevel: "medium" },
3046
- config: m.config,
3047
- checkpointId: m.checkpointId,
3048
- checkpointNs: m.checkpointNs || void 0,
3049
- edit: m.edit ?? !1,
3050
- command: m.command
3046
+ config: y.config,
3047
+ checkpointId: y.checkpointId,
3048
+ checkpointNs: y.checkpointNs || void 0,
3049
+ edit: y.edit ?? !1,
3050
+ command: y.command
3051
3051
  };
3052
- l(!0), p(null), v(null);
3052
+ c(!0), p(null), b(null);
3053
3053
  const E = new AbortController();
3054
3054
  x.current = E;
3055
- let U = null, M = !1;
3055
+ let L = null, M = !1;
3056
3056
  return A.current = {
3057
- threadId: k.threadId ?? void 0,
3057
+ threadId: I.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 $, F, _, O, R, W;
3063
+ var $, U, V, P, F, N;
3064
3064
  try {
3065
- let B = {};
3065
+ let j = {};
3066
3066
  try {
3067
3067
  if (r)
3068
- B = { Authorization: `Bearer ${r}` };
3068
+ j = { Authorization: `Bearer ${r}` };
3069
3069
  else if (typeof window < "u") {
3070
3070
  const se = window.__AUTH_TOKEN__, he = (($ = window.localStorage) == null ? void 0 : $.getItem(ze.authToken)) || null;
3071
3071
  let X = null;
3072
3072
  try {
3073
- const be = (F = window.localStorage) == null ? void 0 : F.getItem(ze.chatSettings);
3074
- be && (X = ((_ = JSON.parse(be)) == null ? void 0 : _.apiKey) || null);
3073
+ const be = (U = window.localStorage) == null ? void 0 : U.getItem(ze.chatSettings);
3074
+ be && (X = ((V = JSON.parse(be)) == null ? void 0 : V.apiKey) || null);
3075
3075
  } catch {
3076
3076
  }
3077
3077
  const Q = se || he || X || null;
3078
- Q && (B = { Authorization: `Bearer ${Q}` });
3078
+ Q && (j = { Authorization: `Bearer ${Q}` });
3079
3079
  }
3080
3080
  } catch {
3081
3081
  }
3082
3082
  console.debug("[use-chat] POST", t + n);
3083
- let L = {};
3083
+ let G = {};
3084
3084
  if (typeof window < "u")
3085
3085
  try {
3086
- const G = (O = window.localStorage) == null ? void 0 : O.getItem(ze.authSessionId);
3087
- G && (L = { "X-Session-Id": G });
3086
+ const J = (P = window.localStorage) == null ? void 0 : P.getItem(ze.authSessionId);
3087
+ J && (G = { "X-Session-Id": J });
3088
3088
  } catch {
3089
3089
  }
3090
- const h = {
3091
- ...B,
3092
- ...L,
3093
- ...s.current
3094
- }, j = {
3090
+ const g = {
3091
+ ...j,
3092
+ ...G,
3093
+ ...o.current
3094
+ }, z = {
3095
3095
  "Content-Type": "application/json",
3096
3096
  Accept: "text/event-stream",
3097
- ...h
3097
+ ...g
3098
3098
  }, C = await fetch(t + n, {
3099
3099
  method: "POST",
3100
- headers: j,
3101
- body: JSON.stringify(k),
3100
+ headers: z,
3101
+ body: JSON.stringify(I),
3102
3102
  signal: E.signal,
3103
3103
  credentials: a
3104
3104
  });
3105
- if (A.current && (A.current.headers = h), !C.ok || !C.body) {
3106
- const G = await C.text().catch(() => "");
3105
+ if (A.current && (A.current.headers = g), !C.ok || !C.body) {
3106
+ const J = await C.text().catch(() => "");
3107
3107
  console.debug(
3108
3108
  "[use-chat] non-OK response",
3109
3109
  C.status,
3110
- G == null ? void 0 : G.slice(0, 500)
3110
+ J == null ? void 0 : J.slice(0, 500)
3111
3111
  );
3112
- const se = `stream ${C.status}${G ? ": " + G : ""}`;
3113
- throw se && (p(se), U = "error"), new Error(se);
3112
+ const se = `stream ${C.status}${J ? ": " + J : ""}`;
3113
+ throw se && (p(se), L = "error"), new Error(se);
3114
3114
  }
3115
- I(!0);
3116
- const P = C.body.getReader(), J = new TextDecoder();
3117
- let K = "", V = 0, ee = Date.now();
3115
+ v(!0);
3116
+ const O = C.body.getReader(), D = new TextDecoder();
3117
+ let K = "", B = 0, ee = Date.now();
3118
3118
  const ie = setInterval(() => {
3119
- Date.now() - ee > 18e5 && (p("Stream idle timeout"), U = "error", E.abort());
3119
+ Date.now() - ee > 18e5 && (p("Stream idle timeout"), L = "error", E.abort());
3120
3120
  }, 5e3), ye = 1024 * 1024;
3121
3121
  try {
3122
- const G = C.headers.get("X-Thread-Id") || C.headers.get("x-thread-id"), se = C.headers.get("X-Run-Id") || C.headers.get("x-run-id");
3122
+ const J = C.headers.get("X-Thread-Id") || C.headers.get("x-thread-id"), se = C.headers.get("X-Run-Id") || C.headers.get("x-run-id");
3123
3123
  for (A.current && (A.current = {
3124
3124
  ...A.current,
3125
- threadId: G ?? A.current.threadId,
3125
+ threadId: J ?? A.current.threadId,
3126
3126
  runId: se ?? A.current.runId
3127
3127
  }); ; ) {
3128
- const { value: he, done: X } = await P.read();
3128
+ const { value: he, done: X } = await O.read();
3129
3129
  if (X) break;
3130
- K += J.decode(he, { stream: !0 }), K.length > ye && (K = "", console.warn("Stream buffer reset: exceeded 1MB"));
3130
+ K += D.decode(he, { stream: !0 }), K.length > ye && (K = "", console.warn("Stream buffer reset: exceeded 1MB"));
3131
3131
  let Q;
3132
3132
  for (; (Q = K.indexOf(`
3133
3133
 
3134
3134
  `)) >= 0; ) {
3135
3135
  const be = K.slice(0, Q);
3136
3136
  K = K.slice(Q + 2);
3137
- const Ve = be.split(/\r?\n/), we = [];
3137
+ const He = be.split(/\r?\n/), we = [];
3138
3138
  let Pe = null;
3139
- for (const ce of Ve)
3139
+ for (const ce of He)
3140
3140
  if (!ce.startsWith(":") && ce) {
3141
3141
  if (ce.startsWith("event:")) {
3142
3142
  const Ae = ce.slice(6).trim();
@@ -3168,85 +3168,85 @@ function pr(e = {}) {
3168
3168
  ee = Date.now();
3169
3169
  const te = typeof re.seq == "number" ? re.seq : void 0;
3170
3170
  if (te !== void 0) {
3171
- if (te <= V) {
3172
- console.debug("[use-chat] drop duplicate/out-of-order event", { seq: te, lastProcessedSeq: V, type: re.type });
3171
+ if (te <= B) {
3172
+ console.debug("[use-chat] drop duplicate/out-of-order event", { seq: te, lastProcessedSeq: B, type: re.type });
3173
3173
  continue;
3174
3174
  }
3175
- V = te;
3175
+ B = te;
3176
3176
  }
3177
- d(re);
3177
+ u(re);
3178
3178
  }
3179
3179
  }
3180
- U === null && !E.signal.aborted && (U = "complete");
3181
- } catch (G) {
3182
- if (G.name === "AbortError")
3183
- U = U ?? "aborted";
3180
+ L === null && !E.signal.aborted && (L = "complete");
3181
+ } catch (J) {
3182
+ if (J.name === "AbortError")
3183
+ L = L ?? "aborted";
3184
3184
  else {
3185
- const se = G.message || String(G);
3186
- U = "error", p(se);
3185
+ const se = J.message || String(J);
3186
+ L = "error", p(se);
3187
3187
  }
3188
3188
  } finally {
3189
3189
  try {
3190
- await P.cancel();
3190
+ await O.cancel();
3191
3191
  } catch {
3192
3192
  } finally {
3193
- (R = P.releaseLock) == null || R.call(P);
3193
+ (F = O.releaseLock) == null || F.call(O);
3194
3194
  }
3195
3195
  clearInterval(ie);
3196
3196
  }
3197
- } catch (B) {
3198
- if (B.name === "AbortError")
3199
- U = U ?? "aborted";
3197
+ } catch (j) {
3198
+ if (j.name === "AbortError")
3199
+ L = L ?? "aborted";
3200
3200
  else {
3201
- const L = B.message || String(B);
3202
- U = "error", p(L), M || (M = !0, (W = e.onConnectionError) == null || W.call(e, L));
3201
+ const G = j.message || String(j);
3202
+ L = "error", p(G), M || (M = !0, (N = e.onConnectionError) == null || N.call(e, G));
3203
3203
  }
3204
3204
  } finally {
3205
3205
  try {
3206
3206
  if (e.onFinish) {
3207
- const B = {
3207
+ const j = {
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(B);
3214
+ e.onFinish(j);
3215
3215
  }
3216
- } catch (B) {
3217
- console.warn("[use-chat] onClosed callback failed", B);
3216
+ } catch (j) {
3217
+ console.warn("[use-chat] onClosed callback failed", j);
3218
3218
  }
3219
- l(!1), I(!1), x.current = null, A.current = null;
3219
+ c(!1), v(!1), x.current = null, A.current = null;
3220
3220
  }
3221
3221
  })(), Promise.resolve();
3222
3222
  },
3223
- [t, n, r, e, d]
3223
+ [t, n, r, e, u]
3224
3224
  );
3225
3225
  return Y(() => () => {
3226
- var m;
3227
- S.current = !1, (m = x.current) == null || m.abort();
3226
+ var y;
3227
+ S.current = !1, (y = x.current) == null || y.abort();
3228
3228
  }, []), {
3229
- isStreaming: c,
3230
- error: f,
3229
+ isStreaming: l,
3230
+ error: d,
3231
3231
  assistantText: "",
3232
3232
  // Deprecated: use messages from reducer
3233
- activeMessageId: u,
3233
+ activeMessageId: f,
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: g,
3239
+ connected: m,
3240
3240
  stream: T,
3241
- stop: y,
3242
- clear: b,
3241
+ stop: h,
3242
+ clear: k,
3243
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: f ? "error" : c ? g ? "connected" : "connecting" : "idle",
3249
+ connectionState: d ? "error" : l ? m ? "connected" : "connecting" : "idle",
3250
3250
  messages: [],
3251
3251
  // useStream doesn't maintain messages, use useChatSession instead
3252
3252
  submit: T
@@ -3257,105 +3257,105 @@ function gr({
3257
3257
  initialThreadId: t = null,
3258
3258
  onError: n,
3259
3259
  onThreadChange: r,
3260
- onCurrentThreadDeleted: o
3260
+ onCurrentThreadDeleted: s
3261
3261
  }) {
3262
- const [s, a] = D([]), [i, d] = D(t), [c, l] = D(!1), [f, p] = D(null), g = H(i), I = H(/* @__PURE__ */ new Map());
3262
+ const [o, a] = H([]), [i, u] = H(t), [l, c] = H(!1), [d, p] = H(null), m = W(i), v = W(/* @__PURE__ */ new Map());
3263
3263
  Y(() => {
3264
- g.current = i;
3264
+ m.current = i;
3265
3265
  }, [i]), Y(() => {
3266
- t !== void 0 && t !== g.current && d(t);
3266
+ t !== void 0 && t !== m.current && u(t);
3267
3267
  }, [t]);
3268
- const u = N(async () => {
3269
- l(!0), p(null);
3268
+ const f = _(async () => {
3269
+ c(!0), p(null);
3270
3270
  try {
3271
- const b = await e.listThreads();
3272
- a(b ?? []);
3273
- } catch (b) {
3274
- const y = String(b);
3275
- p(y), n == null || n(y);
3271
+ const k = await e.listThreads();
3272
+ a(k ?? []);
3273
+ } catch (k) {
3274
+ const h = String(k);
3275
+ p(h), n == null || n(h);
3276
3276
  } finally {
3277
- l(!1);
3277
+ c(!1);
3278
3278
  }
3279
3279
  }, [e, n]);
3280
3280
  Y(() => {
3281
- u();
3282
- }, [u]), Y(() => {
3281
+ f();
3282
+ }, [f]), Y(() => {
3283
3283
  r == null || r(i);
3284
3284
  }, [i, r]);
3285
- const v = N(
3286
- async (b, y) => {
3285
+ const b = _(
3286
+ async (k, h) => {
3287
3287
  try {
3288
- const T = y && typeof y == "object" ? { id: y.id, name: y.name ?? "" } : void 0, m = await e.createThread(b, T);
3289
- return d(m.threadId), await u(), m.threadId;
3288
+ const T = h && typeof h == "object" ? { id: h.id, name: h.name ?? "" } : void 0, y = await e.createThread(k, T);
3289
+ return u(y.threadId), await f(), y.threadId;
3290
3290
  } catch (T) {
3291
- const m = String(T);
3292
- return n == null || n(m), null;
3291
+ const y = String(T);
3292
+ return n == null || n(y), null;
3293
3293
  }
3294
3294
  },
3295
- [e, n, u]
3296
- ), x = N(
3297
- async (b) => {
3298
- const y = s;
3299
- a((m) => m.filter((k) => k.threadId !== b));
3295
+ [e, n, f]
3296
+ ), x = _(
3297
+ async (k) => {
3298
+ const h = o;
3299
+ a((y) => y.filter((I) => I.threadId !== k));
3300
3300
  const T = new AbortController();
3301
- I.current.set(b, T);
3301
+ v.current.set(k, T);
3302
3302
  try {
3303
- await e.deleteThread(b), g.current === b && (d(null), o == null || o());
3304
- } catch (m) {
3305
- a(y);
3306
- const k = String(m);
3307
- n == null || n(k);
3303
+ await e.deleteThread(k), m.current === k && (u(null), s == null || s());
3304
+ } catch (y) {
3305
+ a(h);
3306
+ const I = String(y);
3307
+ n == null || n(I);
3308
3308
  } finally {
3309
- I.current.delete(b);
3309
+ v.current.delete(k);
3310
3310
  }
3311
3311
  },
3312
- [e, o, n, s]
3313
- ), S = N(
3314
- async (b, y) => {
3312
+ [e, s, n, o]
3313
+ ), S = _(
3314
+ async (k, h) => {
3315
3315
  try {
3316
- await e.updateThread(b, y), await u();
3316
+ await e.updateThread(k, h), await f();
3317
3317
  } catch (T) {
3318
3318
  n == null || n(String(T));
3319
3319
  }
3320
3320
  },
3321
- [e, n, u]
3321
+ [e, n, f]
3322
3322
  ), A = Z(
3323
3323
  () => ({
3324
- createThread: v,
3324
+ createThread: b,
3325
3325
  deleteThread: x,
3326
3326
  renameThread: S,
3327
- refreshThreads: u
3327
+ refreshThreads: f
3328
3328
  }),
3329
- [v, x, S, u]
3330
- ), w = N((b) => {
3331
- if (!(b != null && b.threadId)) return;
3332
- const y = {
3333
- threadId: b.threadId,
3334
- title: b.title || `Thread ${b.threadId.slice(0, 8)}`,
3335
- project: b.project,
3336
- createdAt: b.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
3337
- updatedAt: b.updatedAt || (/* @__PURE__ */ new Date()).toISOString(),
3338
- messageCount: b.messageCount ?? 1
3329
+ [b, x, S, f]
3330
+ ), w = _((k) => {
3331
+ if (!(k != null && k.threadId)) return;
3332
+ const h = {
3333
+ threadId: k.threadId,
3334
+ title: k.title || `Thread ${k.threadId.slice(0, 8)}`,
3335
+ project: k.project,
3336
+ createdAt: k.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
3337
+ updatedAt: k.updatedAt || (/* @__PURE__ */ new Date()).toISOString(),
3338
+ messageCount: k.messageCount ?? 1
3339
3339
  };
3340
3340
  a((T) => {
3341
- let m = !1;
3342
- const k = T.map((E) => E.threadId === y.threadId ? (m = !0, console.debug("[useThreadsState] thread_info: updating existing thread", y.threadId), {
3341
+ let y = !1;
3342
+ const I = T.map((E) => E.threadId === h.threadId ? (y = !0, console.debug("[useThreadsState] thread_info: updating existing thread", h.threadId), {
3343
3343
  ...E,
3344
- title: y.title ?? E.title,
3345
- project: y.project ?? E.project,
3346
- updatedAt: y.updatedAt ?? E.updatedAt,
3347
- messageCount: y.messageCount ?? E.messageCount
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
3348
  }) : E);
3349
- return m ? k : (console.debug("[useThreadsState] thread_info: adding thread to list", y.threadId), [y, ...T]);
3349
+ return y ? I : (console.debug("[useThreadsState] thread_info: adding thread to list", h.threadId), [h, ...T]);
3350
3350
  });
3351
3351
  }, []);
3352
3352
  return {
3353
- threads: s,
3353
+ threads: o,
3354
3354
  currentThreadId: i,
3355
- currentThreadIdRef: g,
3356
- setCurrentThreadId: d,
3357
- isLoadingThreads: c,
3358
- threadsError: f,
3355
+ currentThreadIdRef: m,
3356
+ setCurrentThreadId: u,
3357
+ isLoadingThreads: l,
3358
+ threadsError: d,
3359
3359
  actions: A,
3360
3360
  addThreadFromEvent: w
3361
3361
  };
@@ -3367,43 +3367,43 @@ function mr({
3367
3367
  onError: n,
3368
3368
  onThreadChange: r
3369
3369
  }) {
3370
- const { chatApi: o } = Me(), {
3371
- threads: s,
3370
+ const { chatApi: s } = Me(), {
3371
+ threads: o,
3372
3372
  currentThreadId: a,
3373
3373
  setCurrentThreadId: i,
3374
- currentThreadIdRef: d,
3375
- isLoadingThreads: c,
3376
- threadsError: l,
3377
- actions: f,
3374
+ currentThreadIdRef: u,
3375
+ isLoadingThreads: l,
3376
+ threadsError: c,
3377
+ actions: d,
3378
3378
  addThreadFromEvent: p
3379
3379
  } = gr({
3380
- api: o,
3380
+ api: s,
3381
3381
  initialThreadId: t,
3382
3382
  onError: n,
3383
3383
  onThreadChange: r
3384
- }), g = Z(
3384
+ }), m = Z(
3385
3385
  () => ({
3386
- threads: s,
3386
+ threads: o,
3387
3387
  currentThreadId: a,
3388
3388
  setCurrentThreadId: i,
3389
- currentThreadIdRef: d,
3390
- isLoading: c,
3391
- error: l,
3392
- actions: f,
3389
+ currentThreadIdRef: u,
3390
+ isLoading: l,
3391
+ error: c,
3392
+ actions: d,
3393
3393
  addThreadFromEvent: p
3394
3394
  }),
3395
3395
  [
3396
- s,
3396
+ o,
3397
3397
  a,
3398
3398
  i,
3399
- d,
3400
- c,
3399
+ u,
3401
3400
  l,
3402
- f,
3401
+ c,
3402
+ d,
3403
3403
  p
3404
3404
  ]
3405
3405
  );
3406
- return /* @__PURE__ */ de(Ut.Provider, { value: g, children: e });
3406
+ return /* @__PURE__ */ de(Ut.Provider, { value: m, children: e });
3407
3407
  }
3408
3408
  function ot(e) {
3409
3409
  const t = je(Ut);
@@ -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 o = Bt(r);
3442
- return !!((o == null ? void 0 : o.id) === t || n && r.toolCallId === n);
3441
+ const s = Bt(r);
3442
+ return !!((s == null ? void 0 : s.id) === t || n && r.toolCallId === n);
3443
3443
  }) ?? null;
3444
3444
  }
3445
3445
  function Fe(e) {
@@ -3452,8 +3452,8 @@ function Ft(e, t, n) {
3452
3452
  function br(e, t, n) {
3453
3453
  for (let r = e.length - 1; r >= 0; r--)
3454
3454
  if (e[r].role === "assistant") {
3455
- const s = { ...e[r], checkpointId: t, checkpointNs: n ?? void 0 };
3456
- return Ft(e, r, s);
3455
+ const o = { ...e[r], checkpointId: t, checkpointNs: n ?? void 0 };
3456
+ return Ft(e, r, o);
3457
3457
  }
3458
3458
  return e;
3459
3459
  }
@@ -3484,15 +3484,15 @@ function wr(e, t) {
3484
3484
  messages: Fe(((n = t.payload) == null ? void 0 : n.messages) ?? [])
3485
3485
  };
3486
3486
  case "user_message": {
3487
- const { message: r, editingMessageId: o } = t.payload;
3488
- if (o) {
3489
- const s = e.messages.findIndex((a) => (a.id || a.messageId || a.id) === o);
3490
- if (s !== -1) {
3491
- const a = e.messages[s], i = { ...r, id: o };
3487
+ const { message: r, editingMessageId: s } = t.payload;
3488
+ if (s) {
3489
+ const o = e.messages.findIndex((a) => (a.id || a.messageId || a.id) === s);
3490
+ if (o !== -1) {
3491
+ const a = e.messages[o], i = { ...r, id: s };
3492
3492
  return {
3493
3493
  ...e,
3494
3494
  status: "streaming",
3495
- messages: [...e.messages.slice(0, s), i],
3495
+ messages: [...e.messages.slice(0, o), i],
3496
3496
  assemblingId: null,
3497
3497
  lastCheckpointId: a.checkpointId || e.lastCheckpointId || null,
3498
3498
  error: null
@@ -3509,7 +3509,7 @@ function wr(e, t) {
3509
3509
  };
3510
3510
  }
3511
3511
  case "seed": {
3512
- const r = Fe(t.payload.messages), o = {
3512
+ const r = Fe(t.payload.messages), s = {
3513
3513
  ...e,
3514
3514
  status: "idle",
3515
3515
  messages: r,
@@ -3518,51 +3518,51 @@ function wr(e, t) {
3518
3518
  taskMessagesByScope: {},
3519
3519
  error: null
3520
3520
  };
3521
- return Object.prototype.hasOwnProperty.call(t.payload, "checkpointId") && (o.lastCheckpointId = t.payload.checkpointId ?? null), Object.prototype.hasOwnProperty.call(t.payload, "checkpointNs") && (o.lastCheckpointNs = t.payload.checkpointNs ?? null), Object.prototype.hasOwnProperty.call(t.payload, "values") && (o.values = t.payload.values ?? {}), o;
3521
+ return Object.prototype.hasOwnProperty.call(t.payload, "checkpointId") && (s.lastCheckpointId = t.payload.checkpointId ?? null), Object.prototype.hasOwnProperty.call(t.payload, "checkpointNs") && (s.lastCheckpointNs = t.payload.checkpointNs ?? null), Object.prototype.hasOwnProperty.call(t.payload, "values") && (s.values = t.payload.values ?? {}), s;
3522
3522
  }
3523
3523
  case "prepend": {
3524
3524
  const r = Fe(t.payload.messages);
3525
3525
  if (!r.length) return e;
3526
- const o = new Set(e.messages.map((a) => a.id)), s = r.filter((a) => !o.has(a.id));
3527
- return s.length ? { ...e, messages: [...s, ...e.messages] } : e;
3526
+ const s = new Set(e.messages.map((a) => a.id)), o = r.filter((a) => !s.has(a.id));
3527
+ return o.length ? { ...e, messages: [...o, ...e.messages] } : e;
3528
3528
  }
3529
3529
  case "event":
3530
3530
  return pt(e, t.payload.ev);
3531
3531
  case "batch": {
3532
3532
  const { events: r } = t.payload;
3533
- return r.length ? r.reduce((o, s) => pt(o, s), e) : e;
3533
+ return r.length ? r.reduce((s, o) => pt(s, o), e) : e;
3534
3534
  }
3535
3535
  default:
3536
3536
  return e;
3537
3537
  }
3538
3538
  }
3539
3539
  function kr(e = []) {
3540
- const [t, n] = Wt(wr, { ...Ot, messages: e }), r = H([]), o = H(null), s = N(() => {
3541
- o.current !== null && typeof window < "u" && window.cancelAnimationFrame(o.current), o.current = null;
3542
- const c = r.current;
3543
- c.length && (r.current = [], n({ type: "batch", payload: { events: c } }));
3544
- }, []), a = N(() => {
3545
- typeof window < "u" && typeof window.requestAnimationFrame == "function" ? o.current === null && (o.current = window.requestAnimationFrame(() => s())) : setTimeout(s, 8);
3546
- }, [s]), i = N((c) => {
3547
- r.current.push(c), a();
3548
- }, [a]), d = Z(() => ({
3549
- setStatus: (c, l) => n({ type: "status", payload: { status: c, error: l } }),
3550
- reset: (c) => n({ type: "reset", payload: { messages: c } }),
3551
- seed: (c, l) => n({ type: "seed", payload: { messages: c, ...l ?? {} } }),
3552
- pushUser: (c, l) => n({ type: "user_message", payload: { message: c, editingMessageId: l } }),
3540
+ const [t, n] = Wt(wr, { ...Ot, messages: e }), r = W([]), s = W(null), o = _(() => {
3541
+ s.current !== null && typeof window < "u" && window.cancelAnimationFrame(s.current), s.current = null;
3542
+ const l = r.current;
3543
+ l.length && (r.current = [], n({ type: "batch", payload: { events: l } }));
3544
+ }, []), a = _(() => {
3545
+ typeof window < "u" && typeof window.requestAnimationFrame == "function" ? s.current === null && (s.current = window.requestAnimationFrame(() => o())) : setTimeout(o, 8);
3546
+ }, [o]), i = _((l) => {
3547
+ r.current.push(l), a();
3548
+ }, [a]), u = Z(() => ({
3549
+ setStatus: (l, c) => n({ type: "status", payload: { status: l, error: c } }),
3550
+ reset: (l) => n({ type: "reset", payload: { messages: l } }),
3551
+ seed: (l, c) => n({ type: "seed", payload: { messages: l, ...c ?? {} } }),
3552
+ pushUser: (l, c) => n({ type: "user_message", payload: { message: l, editingMessageId: c } }),
3553
3553
  onEvent: i
3554
3554
  }), [i]);
3555
- return { state: t, dispatch: n, ...d };
3555
+ return { state: t, dispatch: n, ...u };
3556
3556
  }
3557
3557
  function pt(e, t) {
3558
- const n = t.origin, r = t.scope, o = n === "task" || typeof r == "string" && r.startsWith("tools:");
3558
+ const n = t.origin, r = t.scope, s = n === "task" || typeof r == "string" && r.startsWith("tools:");
3559
3559
  if (t.type === "checkpoint") {
3560
- const s = t.checkpointNs ?? e.lastCheckpointNs ?? null, a = br(e.messages, t.checkpointId, s);
3561
- return { ...e, lastCheckpointId: t.checkpointId, lastCheckpointNs: s, messages: a };
3560
+ const o = t.checkpointNs ?? e.lastCheckpointNs ?? null, a = br(e.messages, t.checkpointId, o);
3561
+ return { ...e, lastCheckpointId: t.checkpointId, lastCheckpointNs: o, messages: a };
3562
3562
  }
3563
3563
  if (t.type === "status") {
3564
- const s = t.status === "completed" || t.status === "error" ? "idle" : t.status === "interrupted" ? "awaiting_input" : e.status;
3565
- return { ...e, status: s };
3564
+ const o = t.status === "completed" || t.status === "error" ? "idle" : t.status === "interrupted" ? "awaiting_input" : e.status;
3565
+ return { ...e, status: o };
3566
3566
  }
3567
3567
  if (t.type === "interrupt")
3568
3568
  return {
@@ -3576,68 +3576,68 @@ function pt(e, t) {
3576
3576
  }
3577
3577
  };
3578
3578
  if (t.type === "error") {
3579
- const s = {
3579
+ const o = {
3580
3580
  id: `err-${Date.now()}`,
3581
3581
  role: "system",
3582
3582
  content: [{ type: "text", text: `Error: ${t.message}` }],
3583
3583
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
3584
3584
  };
3585
- return { ...e, status: "error", error: t.message, messages: [...e.messages, s] };
3585
+ return { ...e, status: "error", error: t.message, messages: [...e.messages, o] };
3586
3586
  }
3587
3587
  if (t.type === "values") {
3588
- 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 : [];
3588
+ const o = t, a = o.values && typeof o.values == "object" ? { ...o.values } : {}, i = Array.isArray(o.messages) ? o.messages : Array.isArray(a.messages) ? a.messages : [];
3589
3589
  if (!i.length && Object.keys(a).length === 0)
3590
3590
  return e;
3591
- const d = Fe(i);
3591
+ const u = Fe(i);
3592
3592
  delete a.messages;
3593
- let c = e.lastCheckpointId, l = e.lastCheckpointNs;
3594
- const f = s.config || s.checkpoint, p = (f == null ? void 0 : f.configurable) || f;
3595
- if ((p != null && p.checkpoint_id || p != null && p.checkpointId) && (c = p.checkpoint_id || p.checkpointId, l = p.checkpoint_ns || p.checkpointNs || null), !c) {
3596
- for (let u = d.length - 1; u >= 0; u--)
3597
- if (d[u].checkpointId) {
3598
- c = d[u].checkpointId, l = d[u].checkpointNs ?? null;
3593
+ let l = e.lastCheckpointId, c = e.lastCheckpointNs;
3594
+ const d = o.config || o.checkpoint, p = (d == null ? void 0 : d.configurable) || d;
3595
+ if ((p != null && p.checkpoint_id || p != null && p.checkpointId) && (l = p.checkpoint_id || p.checkpointId, c = p.checkpoint_ns || p.checkpointNs || null), !l) {
3596
+ for (let f = u.length - 1; f >= 0; f--)
3597
+ if (u[f].checkpointId) {
3598
+ l = u[f].checkpointId, c = u[f].checkpointNs ?? null;
3599
3599
  break;
3600
3600
  }
3601
3601
  }
3602
- const g = s.interrupts || a.__interrupt__ || a.interrupts, I = Array.isArray(g) && g.length > 0 ? {
3603
- id: g[0].id || "native-interrupt",
3604
- value: g[0].value || g[0],
3605
- alternatives: g[0].alternatives
3602
+ const m = o.interrupts || a.__interrupt__ || a.interrupts, v = Array.isArray(m) && m.length > 0 ? {
3603
+ id: m[0].id || "native-interrupt",
3604
+ value: m[0].value || m[0],
3605
+ alternatives: m[0].alternatives
3606
3606
  } : null;
3607
- if (o) {
3608
- const u = typeof r == "string" && r.length > 0 ? r : "task";
3607
+ if (s) {
3608
+ const f = typeof r == "string" && r.length > 0 ? r : "task";
3609
3609
  return {
3610
3610
  ...e,
3611
- taskMessagesByScope: { ...e.taskMessagesByScope, [u]: d },
3611
+ taskMessagesByScope: { ...e.taskMessagesByScope, [f]: u },
3612
3612
  assemblingId: null
3613
3613
  };
3614
3614
  }
3615
3615
  return {
3616
3616
  ...e,
3617
- status: I ? "awaiting_input" : e.status === "streaming" ? "idle" : e.status,
3618
- messages: d,
3617
+ status: v ? "awaiting_input" : e.status === "streaming" ? "idle" : e.status,
3618
+ messages: u,
3619
3619
  assemblingId: null,
3620
- lastCheckpointId: c,
3621
- lastCheckpointNs: l,
3622
- pendingInterrupt: I,
3620
+ lastCheckpointId: l,
3621
+ lastCheckpointNs: c,
3622
+ pendingInterrupt: v,
3623
3623
  values: { ...e.values, ...a }
3624
3624
  };
3625
3625
  }
3626
3626
  if (t.type === "messages/metadata") {
3627
- const s = { ...e.messagesStreamMeta ?? {} }, a = t.metadata;
3628
- return a && typeof a == "object" && Object.entries(a).forEach(([i, d]) => {
3629
- const c = d == null ? void 0 : d.metadata;
3630
- if (!c || typeof c != "object") return;
3631
- const l = s[i] ?? {};
3632
- s[i] = {
3633
- ...l,
3634
- lastSeq: t.seq ?? l.lastSeq ?? null,
3635
- metadata: { ...l.metadata ?? {}, ...c }
3627
+ const o = { ...e.messagesStreamMeta ?? {} }, a = t.metadata;
3628
+ return a && typeof a == "object" && Object.entries(a).forEach(([i, u]) => {
3629
+ const l = u == null ? void 0 : u.metadata;
3630
+ if (!l || typeof l != "object") return;
3631
+ const c = o[i] ?? {};
3632
+ o[i] = {
3633
+ ...c,
3634
+ lastSeq: t.seq ?? c.lastSeq ?? null,
3635
+ metadata: { ...c.metadata ?? {}, ...l }
3636
3636
  };
3637
- }), { ...e, messagesStreamMeta: s };
3637
+ }), { ...e, messagesStreamMeta: o };
3638
3638
  }
3639
3639
  if (t.type === "messages/partial" || t.type === "message.delta") {
3640
- const s = t.type === "messages/partial" ? t : {
3640
+ const o = t.type === "messages/partial" ? t : {
3641
3641
  ...t,
3642
3642
  type: "messages/partial",
3643
3643
  messages: t.delta ? [{
@@ -3648,55 +3648,55 @@ function pt(e, t) {
3648
3648
  origin: t.origin
3649
3649
  }] : []
3650
3650
  };
3651
- return Ir(e, s, o);
3651
+ return Ir(e, o, s);
3652
3652
  }
3653
- return t.type === "message.start" ? { ...e, assemblingId: t.id, status: "streaming" } : t.type === "message.end" ? { ...e, assemblingId: null } : t.type === "tool.start" ? { ...vr(e, t, 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;
3653
+ return t.type === "message.start" ? { ...e, assemblingId: t.id, status: "streaming" } : t.type === "message.end" ? { ...e, assemblingId: null } : t.type === "tool.start" ? { ...vr(e, t, s), status: "streaming" } : t.type === "tool.progress" ? xr(e, t, s) : t.type === "tool.end" ? Ar(e, t, s) : t.type === "artifact.update" ? Tr(e, t) : e;
3654
3654
  }
3655
3655
  function Ir(e, t, n) {
3656
- var g, I, u, v, x, S, A;
3656
+ var m, v, f, b, x, S, A;
3657
3657
  const r = t.messages;
3658
3658
  if (!r.length)
3659
3659
  return console.warn("[messagesReducer] Dropping messages/partial event without messages[]", t), e;
3660
- const o = r.find((w) => w.type === "ai" || w.type === "assistant" || w.role === "assistant");
3661
- if (!o) return e;
3662
- const s = o.id, a = o.content ?? "", i = typeof a == "string" ? [{ type: "text", text: a }] : Array.isArray(a) ? a.map((w) => typeof w == "string" ? { type: "text", text: w } : (w == null ? void 0 : w.type) === "text" ? { type: "text", text: typeof w.text == "string" ? w.text : w.content ?? "" } : ((w == null ? void 0 : w.type) === "reasoning", w)) : [], 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";
3663
- let f = n ? [...e.taskMessagesByScope[l] || []] : [...e.messages];
3664
- const p = (I = (g = e.messagesStreamMeta) == null ? void 0 : g[s]) == null ? void 0 : I.metadata;
3665
- if (c) {
3660
+ const s = r.find((w) => w.type === "ai" || w.type === "assistant" || w.role === "assistant");
3661
+ if (!s) return e;
3662
+ const o = s.id, a = s.content ?? "", i = typeof a == "string" ? [{ type: "text", text: a }] : Array.isArray(a) ? a.map((w) => typeof w == "string" ? { type: "text", text: w } : (w == null ? void 0 : w.type) === "text" ? { type: "text", text: typeof w.text == "string" ? w.text : w.content ?? "" } : ((w == null ? void 0 : w.type) === "reasoning", w)) : [], u = i.filter((w) => w.type === "text").map((w) => w.text).join(""), l = e.assemblingId !== o, c = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3663
+ let d = n ? [...e.taskMessagesByScope[c] || []] : [...e.messages];
3664
+ const p = (v = (m = e.messagesStreamMeta) == null ? void 0 : m[o]) == null ? void 0 : v.metadata;
3665
+ if (l) {
3666
3666
  const w = nt({
3667
- ...o,
3667
+ ...s,
3668
3668
  role: "assistant",
3669
3669
  content: i,
3670
3670
  scope: t.scope,
3671
3671
  origin: t.origin,
3672
- responseMetadata: { ...p, ...o.responseMetadata ?? {} }
3672
+ responseMetadata: { ...p, ...s.responseMetadata ?? {} }
3673
3673
  });
3674
- w && f.push(w);
3674
+ w && d.push(w);
3675
3675
  } else {
3676
- const w = f.findIndex((b) => b.id === s);
3676
+ const w = d.findIndex((k) => k.id === o);
3677
3677
  if (w !== -1) {
3678
- const b = f[w];
3679
- f[w] = {
3680
- ...b,
3678
+ const k = d[w];
3679
+ d[w] = {
3680
+ ...k,
3681
3681
  content: i,
3682
- scope: t.scope ?? b.scope,
3683
- origin: t.origin ?? b.origin,
3684
- responseMetadata: { ...p, ...b.responseMetadata, ...o.responseMetadata ?? {} }
3682
+ scope: t.scope ?? k.scope,
3683
+ origin: t.origin ?? k.origin,
3684
+ responseMetadata: { ...p, ...k.responseMetadata, ...s.responseMetadata ?? {} }
3685
3685
  };
3686
3686
  }
3687
3687
  }
3688
3688
  return {
3689
3689
  ...e,
3690
3690
  status: "streaming",
3691
- messages: n ? e.messages : f,
3692
- taskMessagesByScope: n ? { ...e.taskMessagesByScope, [l]: f } : e.taskMessagesByScope,
3693
- assemblingId: s,
3691
+ messages: n ? e.messages : d,
3692
+ taskMessagesByScope: n ? { ...e.taskMessagesByScope, [c]: d } : e.taskMessagesByScope,
3693
+ assemblingId: o,
3694
3694
  messagesStreamMeta: {
3695
3695
  ...e.messagesStreamMeta ?? {},
3696
- [s]: {
3697
- ...((u = e.messagesStreamMeta) == null ? void 0 : u[s]) ?? {},
3698
- lastSeq: t.seq ?? ((x = (v = e.messagesStreamMeta) == null ? void 0 : v[s]) == null ? void 0 : x.lastSeq) ?? null,
3699
- lastText: d || (((A = (S = e.messagesStreamMeta) == null ? void 0 : S[s]) == null ? void 0 : A.lastText) ?? "")
3696
+ [o]: {
3697
+ ...((f = e.messagesStreamMeta) == null ? void 0 : f[o]) ?? {},
3698
+ lastSeq: t.seq ?? ((x = (b = e.messagesStreamMeta) == null ? void 0 : b[o]) == null ? void 0 : x.lastSeq) ?? null,
3699
+ lastText: u || (((A = (S = e.messagesStreamMeta) == null ? void 0 : S[o]) == null ? void 0 : A.lastText) ?? "")
3700
3700
  }
3701
3701
  }
3702
3702
  };
@@ -3705,8 +3705,8 @@ function st(e, t) {
3705
3705
  var n;
3706
3706
  if (!t) return -1;
3707
3707
  for (let r = e.length - 1; r >= 0; r--) {
3708
- const o = e[r];
3709
- if (o.role === "assistant" && ((n = o.toolCalls) != null && n.some((s) => s.id === t)))
3708
+ const s = e[r];
3709
+ if (s.role === "assistant" && ((n = s.toolCalls) != null && n.some((o) => o.id === t)))
3710
3710
  return r;
3711
3711
  }
3712
3712
  return -1;
@@ -3714,17 +3714,17 @@ function st(e, t) {
3714
3714
  function vr(e, t, n) {
3715
3715
  const r = t.id || t.callId;
3716
3716
  if (!r) return e;
3717
- const o = t.name || "tool", s = `Starting ${o}...`, a = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3718
- let i = n ? [...e.taskMessagesByScope[a] || []] : [...e.messages], d = st(i, r);
3719
- if (d === -1) {
3720
- for (let c = i.length - 1; c >= 0; c--)
3721
- if (i[c].role === "assistant") {
3722
- d = c;
3717
+ const s = t.name || "tool", o = `Starting ${s}...`, a = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3718
+ let i = n ? [...e.taskMessagesByScope[a] || []] : [...e.messages], u = st(i, r);
3719
+ if (u === -1) {
3720
+ for (let l = i.length - 1; l >= 0; l--)
3721
+ if (i[l].role === "assistant") {
3722
+ u = l;
3723
3723
  break;
3724
3724
  }
3725
3725
  }
3726
- if (d === -1) {
3727
- const c = {
3726
+ if (u === -1) {
3727
+ const l = {
3728
3728
  id: `assistant-${r}`,
3729
3729
  role: "assistant",
3730
3730
  content: [{ type: "text", text: "" }],
@@ -3733,21 +3733,21 @@ function vr(e, t, n) {
3733
3733
  scope: t.scope,
3734
3734
  origin: t.origin
3735
3735
  };
3736
- i.push(c), d = i.length - 1;
3736
+ i.push(l), u = i.length - 1;
3737
3737
  }
3738
- if (d !== -1) {
3739
- const c = i[d], l = [...c.toolCalls || []], f = l.findIndex((p) => p.id === r);
3740
- f >= 0 ? l[f] = { ...l[f], status: "running", content: s } : l.push({
3738
+ if (u !== -1) {
3739
+ const l = i[u], c = [...l.toolCalls || []], d = c.findIndex((p) => p.id === r);
3740
+ d >= 0 ? c[d] = { ...c[d], status: "running", content: o } : c.push({
3741
3741
  id: r,
3742
- name: o,
3742
+ name: s,
3743
3743
  args: t.args || {},
3744
3744
  status: "running",
3745
- content: s
3746
- }), i[d] = {
3747
- ...c,
3748
- toolCalls: l,
3749
- scope: t.scope ?? c.scope,
3750
- origin: t.origin ?? c.origin
3745
+ content: o
3746
+ }), i[u] = {
3747
+ ...l,
3748
+ toolCalls: c,
3749
+ scope: t.scope ?? l.scope,
3750
+ origin: t.origin ?? l.origin
3751
3751
  };
3752
3752
  }
3753
3753
  return {
@@ -3759,49 +3759,49 @@ function vr(e, t, n) {
3759
3759
  function xr(e, t, n) {
3760
3760
  const r = t.id;
3761
3761
  if (!r) return e;
3762
- const o = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3763
- let s = n ? [...e.taskMessagesByScope[o] || []] : [...e.messages];
3764
- const a = st(s, r);
3762
+ const s = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3763
+ let o = n ? [...e.taskMessagesByScope[s] || []] : [...e.messages];
3764
+ const a = st(o, r);
3765
3765
  if (a !== -1) {
3766
- const i = s[a], d = ue(t.content), c = (i.toolCalls || []).map(
3767
- (l) => l.id === r ? { ...l, content: typeof d == "string" ? d : l.content } : l
3766
+ const i = o[a], u = ue(t.content), l = (i.toolCalls || []).map(
3767
+ (c) => c.id === r ? { ...c, content: typeof u == "string" ? u : c.content } : c
3768
3768
  );
3769
- s[a] = {
3769
+ o[a] = {
3770
3770
  ...i,
3771
- toolCalls: c,
3771
+ toolCalls: l,
3772
3772
  scope: t.scope ?? i.scope,
3773
3773
  origin: t.origin ?? i.origin
3774
3774
  };
3775
3775
  }
3776
3776
  return {
3777
3777
  ...e,
3778
- messages: n ? e.messages : s,
3779
- taskMessagesByScope: n ? { ...e.taskMessagesByScope, [o]: s } : e.taskMessagesByScope
3778
+ messages: n ? e.messages : o,
3779
+ taskMessagesByScope: n ? { ...e.taskMessagesByScope, [s]: o } : e.taskMessagesByScope
3780
3780
  };
3781
3781
  }
3782
3782
  function Ar(e, t, n) {
3783
3783
  const r = t.id;
3784
3784
  if (!r) return e;
3785
- const o = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3786
- let s = n ? [...e.taskMessagesByScope[o] || []] : [...e.messages];
3787
- const a = st(s, r), i = ue(t.content ?? t.error);
3785
+ const s = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3786
+ let o = n ? [...e.taskMessagesByScope[s] || []] : [...e.messages];
3787
+ const a = st(o, r), i = ue(t.content ?? t.error);
3788
3788
  if (a !== -1) {
3789
- const c = s[a], l = (c.toolCalls || []).map(
3790
- (f) => f.id === r ? {
3791
- ...f,
3789
+ const l = o[a], c = (l.toolCalls || []).map(
3790
+ (d) => d.id === r ? {
3791
+ ...d,
3792
3792
  status: t.error ? "failed" : "completed",
3793
- content: typeof i == "string" ? i : f.content,
3793
+ content: typeof i == "string" ? i : d.content,
3794
3794
  artifact: t.artifact
3795
- } : f
3795
+ } : d
3796
3796
  );
3797
- s[a] = {
3798
- ...c,
3799
- toolCalls: l,
3800
- scope: t.scope ?? c.scope,
3801
- origin: t.origin ?? c.origin
3797
+ o[a] = {
3798
+ ...l,
3799
+ toolCalls: c,
3800
+ scope: t.scope ?? l.scope,
3801
+ origin: t.origin ?? l.origin
3802
3802
  };
3803
3803
  }
3804
- const d = {
3804
+ const u = {
3805
3805
  id: `tool-${r}`,
3806
3806
  role: "tool",
3807
3807
  name: t.name,
@@ -3812,21 +3812,21 @@ function Ar(e, t, n) {
3812
3812
  scope: t.scope,
3813
3813
  origin: t.origin
3814
3814
  };
3815
- return s.push(d), {
3815
+ return o.push(u), {
3816
3816
  ...e,
3817
- messages: n ? e.messages : s,
3818
- taskMessagesByScope: n ? { ...e.taskMessagesByScope, [o]: s } : e.taskMessagesByScope
3817
+ messages: n ? e.messages : o,
3818
+ taskMessagesByScope: n ? { ...e.taskMessagesByScope, [s]: o } : e.taskMessagesByScope
3819
3819
  };
3820
3820
  }
3821
3821
  function Tr(e, t) {
3822
3822
  const n = t.artifactId, r = hr(e.messages, n, t.callId);
3823
3823
  if (!r) return e;
3824
- const o = e.messages.indexOf(r), s = yr(r, {
3824
+ const s = e.messages.indexOf(r), o = yr(r, {
3825
3825
  status: t.status,
3826
3826
  progress: t.progress,
3827
3827
  error: t.error
3828
3828
  });
3829
- return t.partial_data && s.artifact && (s.artifact = { ...s.artifact, ...t.partial_data }), { ...e, messages: Ft(e.messages, o, s) };
3829
+ return t.partial_data && o.artifact && (o.artifact = { ...o.artifact, ...t.partial_data }), { ...e, messages: Ft(e.messages, s, o) };
3830
3830
  }
3831
3831
  function Re(e) {
3832
3832
  if (!(!e || typeof e != "object" || Array.isArray(e)))
@@ -3855,88 +3855,88 @@ function gt(e) {
3855
3855
  return Re(t.configurable) ?? t;
3856
3856
  }
3857
3857
  async function Mr(e, t) {
3858
- var i, d;
3858
+ var i, u;
3859
3859
  if (!e) return e ?? null;
3860
- const n = fe(e), r = Array.isArray(n.checkpoints) ? n.checkpoints : n.checkpoints ? Object.values(n.checkpoints) : [], o = /* @__PURE__ */ new Set();
3861
- for (const c of r) {
3862
- const l = (i = c == null ? void 0 : c.values) == null ? void 0 : i.messages;
3863
- if (Array.isArray(l))
3864
- for (const f of l) {
3865
- const p = f == null ? void 0 : f.content;
3860
+ const n = fe(e), r = Array.isArray(n.checkpoints) ? n.checkpoints : n.checkpoints ? Object.values(n.checkpoints) : [], s = /* @__PURE__ */ new Set();
3861
+ for (const l of r) {
3862
+ const c = (i = l == null ? void 0 : l.values) == null ? void 0 : i.messages;
3863
+ if (Array.isArray(c))
3864
+ for (const d of c) {
3865
+ const p = d == null ? void 0 : d.content;
3866
3866
  if (Array.isArray(p))
3867
- for (const g of p) {
3868
- if (!g || typeof g != "object" || g.type !== "image_url" && g.type !== "file") continue;
3869
- const I = g.fileId || g.file_id;
3870
- typeof I == "string" && I.trim() && o.add(I);
3867
+ for (const m of p) {
3868
+ if (!m || typeof m != "object" || m.type !== "image_url" && m.type !== "file") continue;
3869
+ const v = m.fileId || m.file_id;
3870
+ typeof v == "string" && v.trim() && s.add(v);
3871
3871
  }
3872
3872
  }
3873
3873
  }
3874
- if (o.size === 0)
3874
+ if (s.size === 0)
3875
3875
  return n;
3876
- const s = await Promise.all(
3877
- Array.from(o).map(async (c) => {
3876
+ const o = await Promise.all(
3877
+ Array.from(s).map(async (l) => {
3878
3878
  try {
3879
- const l = await t.getFileInfo(c), f = fe(l);
3880
- return [c, f];
3879
+ const c = await t.getFileInfo(l), d = fe(c);
3880
+ return [l, d];
3881
3881
  } catch {
3882
- return [c, null];
3882
+ return [l, null];
3883
3883
  }
3884
3884
  })
3885
- ), a = new Map(s);
3886
- for (const c of r) {
3887
- const l = (d = c == null ? void 0 : c.values) == null ? void 0 : d.messages;
3888
- if (Array.isArray(l))
3889
- for (const f of l) {
3890
- const p = f == null ? void 0 : f.content;
3885
+ ), a = new Map(o);
3886
+ for (const l of r) {
3887
+ const c = (u = l == null ? void 0 : l.values) == null ? void 0 : u.messages;
3888
+ if (Array.isArray(c))
3889
+ for (const d of c) {
3890
+ const p = d == null ? void 0 : d.content;
3891
3891
  if (Array.isArray(p))
3892
- for (const g of p) {
3893
- if (!g || typeof g != "object" || g.type !== "image_url" && g.type !== "file") continue;
3894
- const I = g.fileId || g.file_id;
3895
- if (!I) continue;
3896
- const u = a.get(I), v = (u == null ? void 0 : u.contentUrl) || (u == null ? void 0 : u.content_url);
3897
- 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))));
3892
+ for (const m of p) {
3893
+ if (!m || typeof m != "object" || m.type !== "image_url" && m.type !== "file") continue;
3894
+ const v = m.fileId || m.file_id;
3895
+ if (!v) continue;
3896
+ const f = a.get(v), b = (f == null ? void 0 : f.contentUrl) || (f == null ? void 0 : f.content_url);
3897
+ b && (m.type === "image_url" ? (m.imageUrl = m.imageUrl || {}, m.imageUrl.url = b) : m.type === "file" && (m.url = b, !m.name && (f != null && f.filename || f != null && f.name) && (m.name = (f == null ? void 0 : f.filename) || (f == null ? void 0 : f.name))));
3898
3898
  }
3899
3899
  }
3900
3900
  }
3901
3901
  return n;
3902
3902
  }
3903
3903
  function mt(e) {
3904
- const r = [...(Array.isArray(e == null ? void 0 : e.checkpoints) ? (e == null ? void 0 : e.checkpoints) ?? [] : e != null && e.checkpoints ? Object.values(e.checkpoints) : []).map((s, a) => Cr(fe(s), a)).filter((s) => !!s)].sort((s, a) => yt(a.createdAt) - yt(s.createdAt)), o = r[0] ?? null;
3904
+ const r = [...(Array.isArray(e == null ? void 0 : e.checkpoints) ? (e == null ? void 0 : e.checkpoints) ?? [] : e != null && e.checkpoints ? Object.values(e.checkpoints) : []).map((o, a) => Cr(fe(o), a)).filter((o) => !!o)].sort((o, a) => yt(a.createdAt) - yt(o.createdAt)), s = r[0] ?? null;
3905
3905
  return {
3906
3906
  threadId: (e == null ? void 0 : e.threadId) ?? "",
3907
- latest: o,
3907
+ latest: s,
3908
3908
  checkpoints: r,
3909
- interrupt: (o == null ? void 0 : o.interrupt) ?? null
3909
+ interrupt: (s == null ? void 0 : s.interrupt) ?? null
3910
3910
  };
3911
3911
  }
3912
3912
  function Cr(e, t) {
3913
- var b, y;
3913
+ var k, h;
3914
3914
  if (!e) return null;
3915
- const n = ((b = e.values) == null ? void 0 : b.activeAgent) ?? null, r = (y = e.values) == null ? void 0 : y.messages, s = (Array.isArray(r) ? r : []).map((T) => Er(T, n)).filter((T) => !!T), a = Re(e.metadata) ?? {}, i = gt(e.config), d = Re(e.parentConfig), c = gt(d), l = Be(i, ["checkpointId"]), f = Be(i, ["checkpointNs"]), p = Be(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 = {
3915
+ const n = ((k = e.values) == null ? void 0 : k.activeAgent) ?? null, r = (h = e.values) == null ? void 0 : h.messages, o = (Array.isArray(r) ? r : []).map((T) => Er(T, n)).filter((T) => !!T), a = Re(e.metadata) ?? {}, i = gt(e.config), u = Re(e.parentConfig), l = gt(u), c = Be(i, ["checkpointId"]), d = Be(i, ["checkpointNs"]), p = Be(l, ["checkpointId"]), m = Re(e.config), v = Array.isArray(e.tasks) ? e.tasks.map((T) => ({ ...T })) : e.tasks ?? null, f = Array.isArray(e.next) ? [...e.next] : e.next ?? null, b = typeof e.createdAt == "string" && e.createdAt.trim() ? e.createdAt : new Date(Date.now() - t).toISOString(), x = {
3916
3916
  ...a,
3917
3917
  step: Sr(a, ["step"]) ?? 0,
3918
3918
  source: Be(a, ["source"]) ?? null
3919
- }, S = s.map((T) => ({
3919
+ }, S = o.map((T) => ({
3920
3920
  ...T,
3921
- checkpointId: T.checkpointId ?? l ?? null,
3922
- checkpointNs: T.checkpointNs ?? f ?? null
3921
+ checkpointId: T.checkpointId ?? c ?? null,
3922
+ checkpointNs: T.checkpointNs ?? d ?? null
3923
3923
  })), A = e.values, w = Array.isArray(e.interrupts) ? e.interrupts : Array.isArray(A == null ? void 0 : A.interrupts) ? A.interrupts : [];
3924
3924
  return {
3925
- checkpointId: l ?? null,
3926
- checkpointNs: f ?? null,
3927
- createdAt: v,
3925
+ checkpointId: c ?? null,
3926
+ checkpointNs: d ?? null,
3927
+ createdAt: b,
3928
3928
  parentId: p ?? null,
3929
3929
  messages: S,
3930
3930
  interrupt: Pr(
3931
3931
  w,
3932
3932
  t,
3933
- l ?? null
3933
+ c ?? null
3934
3934
  ),
3935
3935
  metadata: x,
3936
- config: g ?? null,
3937
- parentConfig: d ?? null,
3938
- next: u,
3939
- tasks: I,
3936
+ config: m ?? null,
3937
+ parentConfig: u ?? null,
3938
+ next: f,
3939
+ tasks: v,
3940
3940
  values: e.values ?? {}
3941
3941
  };
3942
3942
  }
@@ -3946,15 +3946,15 @@ function Er(e, t) {
3946
3946
  }
3947
3947
  function Pr(e, t, n) {
3948
3948
  const r = e.length;
3949
- for (let o = r - 1; o >= 0; o -= 1) {
3950
- const s = e[o];
3951
- if (!s || typeof s != "object")
3949
+ for (let s = r - 1; s >= 0; s -= 1) {
3950
+ const o = e[s];
3951
+ if (!o || typeof o != "object")
3952
3952
  continue;
3953
- const a = s, i = a.value ?? s;
3953
+ const a = o, i = a.value ?? o;
3954
3954
  if (i == null)
3955
3955
  continue;
3956
3956
  return {
3957
- id: typeof a.id == "string" && a.id.trim() ? a.id : `interrupt-${n ?? t}-${o}`,
3957
+ id: typeof a.id == "string" && a.id.trim() ? a.id : `interrupt-${n ?? t}-${s}`,
3958
3958
  value: i
3959
3959
  };
3960
3960
  }
@@ -3979,54 +3979,54 @@ function Nr(e) {
3979
3979
  return _r(e.content) || "";
3980
3980
  }
3981
3981
  function zr(e) {
3982
- const t = /* @__PURE__ */ new Map(), n = [], r = /* @__PURE__ */ new Map(), o = [];
3983
- for (let c = 0; c < e.length; c++) {
3984
- 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;
3985
- let v = null, x = null;
3986
- const S = Array.isArray(l.messages) ? l.messages : [];
3987
- for (const y of S)
3988
- y.role === "user" && (x || (x = y), y.id && (v = y.id));
3989
- const A = l.next && l.next.length > 0 ? String(l.next[0]) : null, w = l.parentConfig ?? null, b = {
3982
+ const t = /* @__PURE__ */ new Map(), n = [], r = /* @__PURE__ */ new Map(), s = [];
3983
+ for (let l = 0; l < e.length; l++) {
3984
+ const c = e[l], d = c.checkpointId, p = d ?? `cp-${l}`, m = c.metadata ?? {}, v = typeof m.step == "number" ? m.step : null, f = typeof m.source == "string" ? m.source : null;
3985
+ let b = null, x = null;
3986
+ const S = Array.isArray(c.messages) ? c.messages : [];
3987
+ for (const h of S)
3988
+ h.role === "user" && (x || (x = h), h.id && (b = h.id));
3989
+ const A = c.next && c.next.length > 0 ? String(c.next[0]) : null, w = c.parentConfig ?? null, k = {
3990
3990
  id: p,
3991
- step: I,
3992
- source: u,
3993
- createdAt: l.createdAt ?? null,
3994
- namespace: l.checkpointNs ?? null,
3995
- parentId: l.parentId ?? null,
3991
+ step: v,
3992
+ source: f,
3993
+ createdAt: c.createdAt ?? null,
3994
+ namespace: c.checkpointNs ?? null,
3995
+ parentId: c.parentId ?? null,
3996
3996
  next: A,
3997
3997
  parentConfig: w,
3998
- userMessageId: v
3998
+ userMessageId: b
3999
3999
  };
4000
- if (o.push(b), f && t.set(f, b), f && x) {
4001
- const y = Nr(x);
4002
- y && r.set(f, y);
4000
+ if (s.push(k), d && t.set(d, k), d && x) {
4001
+ const h = Nr(x);
4002
+ h && r.set(d, h);
4003
4003
  }
4004
4004
  n.push({
4005
4005
  id: p,
4006
- messageId: v,
4007
- step: I,
4008
- source: u,
4009
- createdAt: l.createdAt ?? null,
4006
+ messageId: b,
4007
+ step: v,
4008
+ source: f,
4009
+ createdAt: c.createdAt ?? null,
4010
4010
  next: A,
4011
4011
  parentConfig: w
4012
4012
  });
4013
4013
  }
4014
- const s = /* @__PURE__ */ new Map();
4015
- for (const c of o) {
4016
- if (!c.userMessageId) continue;
4017
- const l = s.get(c.userMessageId) ?? [];
4018
- l.push(c), s.set(c.userMessageId, l);
4014
+ const o = /* @__PURE__ */ new Map();
4015
+ for (const l of s) {
4016
+ if (!l.userMessageId) continue;
4017
+ const c = o.get(l.userMessageId) ?? [];
4018
+ c.push(l), o.set(l.userMessageId, c);
4019
4019
  }
4020
- for (const c of s.values()) {
4021
- if (!c.length) continue;
4022
- c.sort((f, p) => {
4023
- const g = f.createdAt ? Date.parse(f.createdAt) : 0;
4024
- return (p.createdAt ? Date.parse(p.createdAt) : 0) - g;
4020
+ for (const l of o.values()) {
4021
+ if (!l.length) continue;
4022
+ l.sort((d, p) => {
4023
+ const m = d.createdAt ? Date.parse(d.createdAt) : 0;
4024
+ return (p.createdAt ? Date.parse(p.createdAt) : 0) - m;
4025
4025
  });
4026
- const l = c.length;
4027
- for (let f = 0; f < c.length; f++) {
4028
- const p = c[f];
4029
- p.attemptCount = l, p.attemptIndex = f, p.isLatestAttempt = f === 0;
4026
+ const c = l.length;
4027
+ for (let d = 0; d < l.length; d++) {
4028
+ const p = l[d];
4029
+ p.attemptCount = c, p.attemptIndex = d, p.isLatestAttempt = d === 0;
4030
4030
  }
4031
4031
  }
4032
4032
  return {
@@ -4035,19 +4035,19 @@ function zr(e) {
4035
4035
  timeline: n,
4036
4036
  messagePreviews: r,
4037
4037
  getLatest: () => {
4038
- const c = n[0];
4039
- if (c)
4040
- return t.get(c.id);
4038
+ const l = n[0];
4039
+ if (l)
4040
+ return t.get(l.id);
4041
4041
  },
4042
- getCheckpoint: (c) => t.get(c),
4043
- getMessageAttempts: (c) => {
4044
- const l = [];
4045
- for (const f of t.values())
4046
- f.userMessageId === c && l.push(f);
4047
- return l.length ? (l.sort((f, p) => {
4048
- const g = typeof f.attemptIndex == "number" ? f.attemptIndex : Number.MAX_SAFE_INTEGER, I = typeof p.attemptIndex == "number" ? p.attemptIndex : Number.MAX_SAFE_INTEGER;
4049
- return g - I;
4050
- }), l) : [];
4042
+ getCheckpoint: (l) => t.get(l),
4043
+ getMessageAttempts: (l) => {
4044
+ const c = [];
4045
+ for (const d of t.values())
4046
+ d.userMessageId === l && c.push(d);
4047
+ return c.length ? (c.sort((d, p) => {
4048
+ const m = typeof d.attemptIndex == "number" ? d.attemptIndex : Number.MAX_SAFE_INTEGER, v = typeof p.attemptIndex == "number" ? p.attemptIndex : Number.MAX_SAFE_INTEGER;
4049
+ return m - v;
4050
+ }), c) : [];
4051
4051
  }
4052
4052
  };
4053
4053
  }
@@ -4057,14 +4057,14 @@ function uo(e, t, n) {
4057
4057
  const r = n.getMessageAttempts(e);
4058
4058
  if (!r.length)
4059
4059
  return { attemptCount: 1, attemptIndex: 0, attempts: [] };
4060
- let o = 0;
4060
+ let s = 0;
4061
4061
  if (t) {
4062
- const s = r.findIndex((a) => a.id === t);
4063
- s >= 0 && (o = s);
4062
+ const o = r.findIndex((a) => a.id === t);
4063
+ o >= 0 && (s = o);
4064
4064
  }
4065
4065
  return {
4066
4066
  attemptCount: r.length,
4067
- attemptIndex: o,
4067
+ attemptIndex: s,
4068
4068
  attempts: r
4069
4069
  };
4070
4070
  }
@@ -4076,140 +4076,143 @@ function $t({
4076
4076
  fileApi: t,
4077
4077
  seed: n,
4078
4078
  onError: r,
4079
- currentThreadId: o,
4080
- autoLoadInitial: s = !0,
4079
+ currentThreadId: s,
4080
+ autoLoadInitial: o = !0,
4081
4081
  isStreaming: a,
4082
- getMessages: i
4082
+ getMessages: i,
4083
+ includeHistory: u = !0
4083
4084
  }) {
4084
- const [d, c] = D(null), f = Z(
4085
- () => mt(d),
4086
- [d]
4087
- ).checkpoints, p = Rr(f), g = p.timeline, [I, u] = D(!1), [v, x] = D(!1), [S, A] = D(!1), [w, b] = D(null), y = H(o), T = H(null), m = H(null);
4085
+ const [l, c] = H(null), p = Z(
4086
+ () => mt(l),
4087
+ [l]
4088
+ ).checkpoints, m = Rr(p), v = m.timeline, [f, b] = H(!1), [x, S] = H(!1), [A, w] = H(!1), [k, h] = H(null), T = W(s), y = W(null), I = W(null);
4088
4089
  Y(() => {
4089
- y.current = o;
4090
- }, [o]);
4091
- const k = N(
4092
- async (_) => {
4093
- const O = await e.getState({
4094
- threadId: _.threadId,
4095
- checkpointId: _.checkpointId,
4096
- checkpointNs: _.checkpointNs
4097
- }), R = {
4090
+ T.current = s;
4091
+ }, [s]);
4092
+ const E = _(
4093
+ async (P) => {
4094
+ const F = await e.getState({
4095
+ threadId: P.threadId,
4096
+ checkpointId: P.checkpointId,
4097
+ checkpointNs: P.checkpointNs
4098
+ }), N = {
4098
4099
  version: "values@1",
4099
- threadId: _.threadId,
4100
- checkpoints: [O]
4101
- }, W = t ? await Mr(R, t) : R, { latest: B } = mt(W);
4102
- return B;
4100
+ threadId: P.threadId,
4101
+ checkpoints: [F]
4102
+ }, j = t ? await Mr(N, t) : N, { latest: G } = mt(j);
4103
+ return G;
4103
4104
  },
4104
4105
  [e, t]
4105
- ), E = N(
4106
- async (_, O) => {
4107
- var B;
4108
- if (!_) return;
4109
- const R = `${_}:${O ?? "latest"}`;
4110
- if (T.current === R || I) return;
4111
- (B = m.current) == null || B.abort();
4112
- const W = new AbortController();
4113
- m.current = W, u(!0), b(null);
4106
+ ), L = _(
4107
+ async (P, F) => {
4108
+ var G;
4109
+ if (!P) return;
4110
+ const N = `${P}:${F ?? "latest"}`;
4111
+ if (y.current === N || f) return;
4112
+ (G = I.current) == null || G.abort();
4113
+ const j = new AbortController();
4114
+ I.current = j, b(!0), h(null);
4114
4115
  try {
4115
- const L = await k({
4116
- threadId: _,
4117
- checkpointId: O ?? void 0
4116
+ const g = await E({
4117
+ threadId: P,
4118
+ checkpointId: F ?? void 0
4118
4119
  });
4119
- if (y.current !== _) {
4120
- u(!1);
4120
+ if (T.current !== P) {
4121
+ b(!1);
4121
4122
  return;
4122
4123
  }
4123
- n((L == null ? void 0 : L.messages) ?? [], {
4124
- checkpointId: (L == null ? void 0 : L.checkpointId) ?? null,
4125
- checkpointNs: (L == null ? void 0 : L.checkpointNs) ?? null,
4126
- pendingInterrupt: (L == null ? void 0 : L.interrupt) ?? null,
4127
- values: L == null ? void 0 : L.values
4128
- }), T.current = R, u(!1), A(!0);
4129
- try {
4130
- const h = await e.getStateHistory({
4131
- threadId: _,
4132
- limit: 100,
4133
- includeMessages: !1
4134
- });
4135
- y.current === _ && c(h);
4136
- } finally {
4137
- A(!1);
4124
+ if (n((g == null ? void 0 : g.messages) ?? [], {
4125
+ checkpointId: (g == null ? void 0 : g.checkpointId) ?? null,
4126
+ checkpointNs: (g == null ? void 0 : g.checkpointNs) ?? null,
4127
+ pendingInterrupt: (g == null ? void 0 : g.interrupt) ?? null,
4128
+ values: g == null ? void 0 : g.values
4129
+ }), y.current = N, b(!1), u) {
4130
+ w(!0);
4131
+ try {
4132
+ const z = await e.getStateHistory({
4133
+ threadId: P,
4134
+ limit: 100,
4135
+ includeMessages: !1
4136
+ });
4137
+ T.current === P && c(z);
4138
+ } finally {
4139
+ w(!1);
4140
+ }
4138
4141
  }
4139
- } catch (L) {
4140
- if (u(!1), !Xt(L)) {
4141
- const h = String(L);
4142
- b(h), r == null || r(h);
4142
+ } catch (g) {
4143
+ if (b(!1), !Xt(g)) {
4144
+ const z = String(g);
4145
+ h(z), r == null || r(z);
4143
4146
  }
4144
4147
  }
4145
4148
  },
4146
- [e, n, k, r, i]
4147
- ), U = N(
4148
- async (_, O) => {
4149
- if (o) {
4150
- x(!0);
4149
+ [e, n, E, r, i]
4150
+ ), M = _(
4151
+ async (P, F) => {
4152
+ if (s) {
4153
+ S(!0);
4151
4154
  try {
4152
- const R = await k({
4153
- threadId: o,
4154
- checkpointId: _,
4155
- checkpointNs: O ?? void 0
4155
+ const N = await E({
4156
+ threadId: s,
4157
+ checkpointId: P,
4158
+ checkpointNs: F ?? void 0
4156
4159
  });
4157
- n((R == null ? void 0 : R.messages) ?? [], {
4158
- checkpointId: (R == null ? void 0 : R.checkpointId) ?? _,
4159
- checkpointNs: (R == null ? void 0 : R.checkpointNs) ?? O,
4160
- pendingInterrupt: (R == null ? void 0 : R.interrupt) ?? null,
4161
- values: R == null ? void 0 : R.values
4160
+ n((N == null ? void 0 : N.messages) ?? [], {
4161
+ checkpointId: (N == null ? void 0 : N.checkpointId) ?? P,
4162
+ checkpointNs: (N == null ? void 0 : N.checkpointNs) ?? F,
4163
+ pendingInterrupt: (N == null ? void 0 : N.interrupt) ?? null,
4164
+ values: N == null ? void 0 : N.values
4162
4165
  });
4163
- } catch (R) {
4164
- console.error("[useThreadHistoryState] Navigation failed", R);
4166
+ } catch (N) {
4167
+ console.error("[useThreadHistoryState] Navigation failed", N);
4165
4168
  } finally {
4166
- x(!1);
4169
+ S(!1);
4167
4170
  }
4168
4171
  }
4169
4172
  },
4170
- [o, k, n]
4171
- ), M = N(async () => {
4172
- o && await E(o);
4173
- }, [o, E]), $ = N(
4174
- async (_) => {
4175
- const O = (_ == null ? void 0 : _.threadId) || o;
4176
- !O || o !== O || (c(_), T.current = `${O}:latest`);
4173
+ [s, E, n]
4174
+ ), $ = _(async () => {
4175
+ s && await L(s);
4176
+ }, [s, L]), U = _(
4177
+ async (P) => {
4178
+ const F = (P == null ? void 0 : P.threadId) || s;
4179
+ !F || s !== F || (c(P), y.current = `${F}:latest`);
4177
4180
  },
4178
- [o]
4181
+ [s]
4179
4182
  );
4180
4183
  Y(() => {
4181
- if (!s || !o || I || a) return;
4182
- const _ = `${o}:latest`;
4183
- T.current !== _ && E(o);
4184
- }, [s, o, I, a, E]);
4185
- const F = N(() => {
4186
- c(null), u(!1), x(!1), A(!1), b(null), T.current = null;
4184
+ if (!o || !s || f || a) return;
4185
+ const P = `${s}:latest`;
4186
+ y.current !== P && L(s);
4187
+ }, [o, s, f, a, L]);
4188
+ const V = _(() => {
4189
+ c(null), b(!1), S(!1), w(!1), h(null), y.current = null;
4187
4190
  }, []);
4188
4191
  return {
4189
- threadCheckpoints: f,
4190
- threadTimeline: g,
4191
- checkpointIndex: p,
4192
- isLoadingThread: I,
4193
- isLoadingCheckpoint: v,
4194
- isLoadingHistory: S,
4195
- threadStateError: w,
4196
- loadThread: E,
4197
- navigateToCheckpoint: U,
4198
- setCurrentCheckpointId: (_, O) => {
4199
- n(i(), { checkpointId: _, checkpointNs: O });
4192
+ threadCheckpoints: p,
4193
+ threadTimeline: v,
4194
+ checkpointIndex: m,
4195
+ isLoadingThread: f,
4196
+ isLoadingCheckpoint: x,
4197
+ isLoadingHistory: A,
4198
+ threadStateError: k,
4199
+ loadThread: L,
4200
+ navigateToCheckpoint: M,
4201
+ setCurrentCheckpointId: (P, F) => {
4202
+ n(i(), { checkpointId: P, checkpointNs: F });
4200
4203
  },
4201
- returnToLatest: M,
4202
- handleValuesEvent: $,
4204
+ returnToLatest: $,
4205
+ handleValuesEvent: U,
4203
4206
  markSkipNextLoad: () => {
4204
4207
  },
4205
4208
  markStreamPendingThread: () => {
4206
4209
  },
4207
- resetHistoryState: F,
4208
- clearState: F
4210
+ resetHistoryState: V,
4211
+ clearState: V
4209
4212
  };
4210
4213
  }
4211
4214
  const Dt = Ce(null), Kt = Ce(null);
4212
- function Vt(e) {
4215
+ function Ht(e) {
4213
4216
  const t = je(Dt);
4214
4217
  if (!t && !(e != null && e.optional)) throw new Error("useThreadState must be used within a ThreadStateProvider");
4215
4218
  return t;
@@ -4225,193 +4228,195 @@ function jr({
4225
4228
  initialThreadId: t = null,
4226
4229
  initialCheckpointId: n = null,
4227
4230
  initialCheckpointNs: r = null,
4228
- autoLoadInitial: o = !0,
4229
- isStreaming: s,
4230
- onError: a
4231
+ autoLoadInitial: s = !0,
4232
+ isStreaming: o,
4233
+ onError: a,
4234
+ includeHistory: i = !0
4231
4235
  }) {
4232
- const { chatApi: i, fileApi: d } = Me(), { currentThreadId: c } = ot(), { state: l, seed: f, onEvent: p, dispatch: g } = kr(), {
4233
- threadCheckpoints: I,
4234
- threadTimeline: u,
4235
- checkpointIndex: v,
4236
- isLoadingThread: x,
4237
- isLoadingCheckpoint: S,
4238
- isLoadingHistory: A,
4239
- threadStateError: w,
4240
- loadThread: b,
4241
- navigateToCheckpoint: y,
4242
- setCurrentCheckpointId: T,
4243
- returnToLatest: m,
4244
- handleValuesEvent: k,
4245
- markSkipNextLoad: E,
4246
- markStreamPendingThread: U,
4247
- resetHistoryState: M
4236
+ const { chatApi: u, fileApi: l } = Me(), { currentThreadId: c } = ot(), { state: d, seed: p, onEvent: m, dispatch: v } = kr(), {
4237
+ threadCheckpoints: f,
4238
+ threadTimeline: b,
4239
+ checkpointIndex: x,
4240
+ isLoadingThread: S,
4241
+ isLoadingCheckpoint: A,
4242
+ isLoadingHistory: w,
4243
+ threadStateError: k,
4244
+ loadThread: h,
4245
+ navigateToCheckpoint: T,
4246
+ setCurrentCheckpointId: y,
4247
+ returnToLatest: I,
4248
+ handleValuesEvent: E,
4249
+ markSkipNextLoad: L,
4250
+ markStreamPendingThread: M,
4251
+ resetHistoryState: $
4248
4252
  } = $t({
4249
- api: i,
4250
- fileApi: d,
4251
- seed: f,
4253
+ api: u,
4254
+ fileApi: l,
4255
+ seed: p,
4252
4256
  onError: a,
4253
4257
  currentThreadId: c,
4254
4258
  initialThreadId: t,
4255
4259
  initialCheckpointId: n,
4256
4260
  initialCheckpointNs: r,
4257
- autoLoadInitial: o,
4258
- isStreaming: s,
4259
- getMessages: N(() => l.messages, [l.messages])
4260
- }), $ = H(null), F = N(
4261
- (P) => {
4262
- $.current = P;
4261
+ autoLoadInitial: s,
4262
+ isStreaming: o,
4263
+ getMessages: _(() => d.messages, [d.messages]),
4264
+ includeHistory: i
4265
+ }), U = W(null), V = _(
4266
+ (D) => {
4267
+ U.current = D;
4263
4268
  },
4264
4269
  []
4265
- ), _ = H(null), O = N(
4266
- (P) => {
4267
- _.current = P;
4270
+ ), P = W(null), F = _(
4271
+ (D) => {
4272
+ P.current = D;
4268
4273
  },
4269
4274
  []
4270
- ), R = Z(() => ({ assemblingMessageId: l.assemblingId ?? null }), [l.assemblingId]), W = N(
4271
- (P, J) => {
4272
- const K = jt(P, "user");
4273
- return g({
4275
+ ), N = Z(() => ({ assemblingMessageId: d.assemblingId ?? null }), [d.assemblingId]), j = _(
4276
+ (D, K) => {
4277
+ const B = jt(D, "user");
4278
+ return v({
4274
4279
  type: "user_message",
4275
4280
  payload: {
4276
- message: K,
4277
- editingMessageId: J == null ? void 0 : J.editingMessageId
4281
+ message: B,
4282
+ editingMessageId: K == null ? void 0 : K.editingMessageId
4278
4283
  }
4279
- }), K;
4284
+ }), B;
4280
4285
  },
4281
- [g]
4282
- ), B = N(async () => {
4283
- $.current ? await $.current() : (f([], {}), M());
4284
- }, [f, M]), L = N(async (P, J, K) => {
4285
- await b(P, J, { clearProgress: !1 });
4286
- }, [b]), h = Z(() => Bn(l.messages), [l.messages]), j = Z(
4286
+ [v]
4287
+ ), G = _(async () => {
4288
+ U.current ? await U.current() : (p([], {}), $());
4289
+ }, [p, $]), g = _(async (D, K, B) => {
4290
+ await h(D, K, { clearProgress: !1 });
4291
+ }, [h]), z = Z(() => Bn(d.messages), [d.messages]), C = Z(
4287
4292
  () => ({
4288
- status: l.status,
4293
+ status: d.status,
4289
4294
  threadId: c,
4290
- messages: l.messages,
4291
- taskMessagesByScope: l.taskMessagesByScope,
4292
- interrupt: l.pendingInterrupt,
4295
+ messages: d.messages,
4296
+ taskMessagesByScope: d.taskMessagesByScope,
4297
+ interrupt: d.pendingInterrupt,
4293
4298
  checkpoint: {
4294
- id: l.lastCheckpointId ?? null,
4295
- namespace: l.lastCheckpointNs ?? null
4299
+ id: d.lastCheckpointId ?? null,
4300
+ namespace: d.lastCheckpointNs ?? null
4296
4301
  },
4297
- checkpoints: I,
4298
- checkpointIndex: v,
4299
- timelineCheckpoints: u,
4300
- metadata: R,
4301
- values: l.values ?? {},
4302
- isLoading: x,
4303
- isLoadingCheckpoint: S,
4304
- isLoadingHistory: A,
4305
- error: w,
4302
+ checkpoints: f,
4303
+ checkpointIndex: x,
4304
+ timelineCheckpoints: b,
4305
+ metadata: N,
4306
+ values: d.values ?? {},
4307
+ isLoading: S,
4308
+ isLoadingCheckpoint: A,
4309
+ isLoadingHistory: w,
4310
+ error: k,
4306
4311
  loadOlder: async () => {
4307
4312
  },
4308
4313
  // Placeholder
4309
- seedFromSnapshot: (P) => {
4310
- f(P.messages, {
4311
- checkpointId: P.checkpointId,
4312
- checkpointNs: P.checkpointNs,
4313
- pendingInterrupt: P.interrupt,
4314
- values: P.values
4314
+ seedFromSnapshot: (D) => {
4315
+ p(D.messages, {
4316
+ checkpointId: D.checkpointId,
4317
+ checkpointNs: D.checkpointNs,
4318
+ pendingInterrupt: D.interrupt,
4319
+ values: D.values
4315
4320
  });
4316
4321
  },
4317
- clearState: B,
4318
- navigateToCheckpoint: y,
4319
- setCurrentCheckpointId: T,
4320
- returnToLatest: m,
4321
- loadThread: L,
4322
- clearThread: B,
4323
- respondToInterrupt: async (P, J, K) => {
4324
- _.current && await _.current(P, J, K);
4322
+ clearState: G,
4323
+ navigateToCheckpoint: T,
4324
+ setCurrentCheckpointId: y,
4325
+ returnToLatest: I,
4326
+ loadThread: g,
4327
+ clearThread: G,
4328
+ respondToInterrupt: async (D, K, B) => {
4329
+ P.current && await P.current(D, K, B);
4325
4330
  },
4326
- messagePreviews: v.messagePreviews,
4327
- handleValuesEvent: k,
4328
- markSkipNextLoad: E,
4329
- markStreamPendingThread: U,
4330
- resetHistoryState: M,
4331
- pushUser: W,
4332
- onEvent: p,
4333
- artifacts: h
4331
+ messagePreviews: x.messagePreviews,
4332
+ handleValuesEvent: E,
4333
+ markSkipNextLoad: L,
4334
+ markStreamPendingThread: M,
4335
+ resetHistoryState: $,
4336
+ pushUser: j,
4337
+ onEvent: m,
4338
+ artifacts: z
4334
4339
  }),
4335
4340
  [
4336
4341
  c,
4337
- l.messages,
4338
- l.taskMessagesByScope,
4339
- l.pendingInterrupt,
4340
- l.lastCheckpointId,
4341
- l.lastCheckpointNs,
4342
- l.values,
4343
- I,
4344
- u,
4345
- v,
4346
- R,
4342
+ d.messages,
4343
+ d.taskMessagesByScope,
4344
+ d.pendingInterrupt,
4345
+ d.lastCheckpointId,
4346
+ d.lastCheckpointNs,
4347
+ d.values,
4348
+ f,
4349
+ b,
4347
4350
  x,
4351
+ N,
4348
4352
  S,
4349
4353
  A,
4350
4354
  w,
4351
- f,
4352
- B,
4353
- y,
4354
- T,
4355
- m,
4356
- L,
4357
4355
  k,
4358
- E,
4359
- U,
4360
- W,
4361
4356
  p,
4362
- h
4357
+ G,
4358
+ T,
4359
+ y,
4360
+ I,
4361
+ g,
4362
+ E,
4363
+ L,
4364
+ M,
4365
+ j,
4366
+ m,
4367
+ z
4363
4368
  ]
4364
- ), C = Z(
4369
+ ), O = Z(
4365
4370
  () => ({
4366
- registerClearThread: F,
4367
- registerRespondToInterrupt: O
4371
+ registerClearThread: V,
4372
+ registerRespondToInterrupt: F
4368
4373
  }),
4369
- [F, O]
4374
+ [V, F]
4370
4375
  );
4371
- return /* @__PURE__ */ de(Kt.Provider, { value: C, children: /* @__PURE__ */ de(Dt.Provider, { value: j, children: e }) });
4376
+ return /* @__PURE__ */ de(Kt.Provider, { value: O, children: /* @__PURE__ */ de(Dt.Provider, { value: C, children: e }) });
4372
4377
  }
4373
- const qt = Ce(null), Ur = Ce(!1);
4378
+ const Vt = Ce(null), Ur = Ce(!1);
4374
4379
  function Br({
4375
4380
  children: e,
4376
4381
  onError: t,
4377
4382
  onAuthError: n,
4378
4383
  onConnectionError: r,
4379
- onToolEnd: o,
4380
- onUpdateEvent: s,
4384
+ onToolEnd: s,
4385
+ onUpdateEvent: o,
4381
4386
  onCustomEvent: a,
4382
4387
  onMetadataEvent: i,
4383
- onFinish: d,
4384
- onStreamingChange: c
4388
+ onFinish: u,
4389
+ onStreamingChange: l
4385
4390
  }) {
4386
- const { chatApi: l, baseUrl: f } = Me(), p = f, g = ge(t), I = ge(n), u = ge(r), v = ge(o), x = ge(s), S = ge(a), A = ge(i), w = ge(d), b = ge(c), y = Z(
4391
+ const { chatApi: c, baseUrl: d } = Me(), p = d, m = ge(t), v = ge(n), f = ge(r), b = ge(s), x = ge(o), S = ge(a), A = ge(i), w = ge(u), k = ge(l), h = Z(
4387
4392
  () => ({
4388
- onError: g,
4389
- onAuthError: I,
4390
- onConnectionError: u,
4393
+ onError: m,
4394
+ onAuthError: v,
4395
+ onConnectionError: f,
4391
4396
  onMetadataEvent: A,
4392
4397
  onCustomEvent: S,
4393
4398
  onUpdateEvent: x,
4394
- onToolEnd: v,
4399
+ onToolEnd: b,
4395
4400
  onFinish: w
4396
4401
  }),
4397
4402
  [
4398
- g,
4399
- I,
4400
- u,
4403
+ m,
4404
+ v,
4405
+ f,
4401
4406
  A,
4402
4407
  S,
4403
4408
  x,
4404
- v,
4409
+ b,
4405
4410
  w
4406
4411
  ]
4407
4412
  );
4408
4413
  return /* @__PURE__ */ de(Ur.Provider, { value: !0, children: /* @__PURE__ */ de(
4409
4414
  Fr,
4410
4415
  {
4411
- api: l,
4416
+ api: c,
4412
4417
  streamBaseUrl: p,
4413
- handlers: y,
4414
- onStreamingChange: b,
4418
+ handlers: h,
4419
+ onStreamingChange: k,
4415
4420
  children: e
4416
4421
  }
4417
4422
  ) });
@@ -4421,35 +4426,35 @@ function Fr({
4421
4426
  api: t,
4422
4427
  streamBaseUrl: n,
4423
4428
  handlers: r,
4424
- onStreamingChange: o
4429
+ onStreamingChange: s
4425
4430
  }) {
4426
- const { setCurrentThreadId: s, currentThreadIdRef: a, addThreadFromEvent: i, currentThreadId: d } = ot(), {
4427
- interrupt: c,
4428
- checkpoint: l,
4429
- timelineCheckpoints: f,
4431
+ const { setCurrentThreadId: o, currentThreadIdRef: a, addThreadFromEvent: i, currentThreadId: u } = ot(), {
4432
+ interrupt: l,
4433
+ checkpoint: c,
4434
+ timelineCheckpoints: d,
4430
4435
  handleValuesEvent: p,
4431
- markSkipNextLoad: g,
4432
- markStreamPendingThread: I,
4433
- resetHistoryState: u,
4434
- pushUser: v,
4436
+ markSkipNextLoad: m,
4437
+ markStreamPendingThread: v,
4438
+ resetHistoryState: f,
4439
+ pushUser: b,
4435
4440
  onEvent: x,
4436
4441
  messages: S
4437
- } = Vt(), { registerClearThread: A, registerRespondToInterrupt: w } = Lr(), b = N(
4438
- (h) => {
4439
- i(h), I(h.threadId), a.current !== h.threadId && ((h.created ?? !a.current) && g(h.threadId), s(h.threadId));
4442
+ } = Ht(), { registerClearThread: A, registerRespondToInterrupt: w } = Lr(), k = _(
4443
+ (g) => {
4444
+ i(g), v(g.threadId), a.current !== g.threadId && ((g.created ?? !a.current) && m(g.threadId), o(g.threadId));
4440
4445
  },
4441
- [i, g, I, s, a]
4442
- ), y = pr({
4446
+ [i, m, v, o, a]
4447
+ ), h = pr({
4443
4448
  baseUrl: n,
4444
4449
  onEvent: x,
4445
- onError: (h) => {
4446
- var j;
4447
- (j = r.onError) == null || j.call(r, (h == null ? void 0 : h.message) ?? String(h));
4450
+ onError: (g) => {
4451
+ var z;
4452
+ (z = r.onError) == null || z.call(r, (g == null ? void 0 : g.message) ?? String(g));
4448
4453
  },
4449
4454
  onAuthError: r.onAuthError,
4450
4455
  onConnectionError: r.onConnectionError,
4451
4456
  onFinish: r.onFinish,
4452
- onThreadInfo: b,
4457
+ onThreadInfo: k,
4453
4458
  onMetadataEvent: r.onMetadataEvent,
4454
4459
  onCustomEvent: r.onCustomEvent,
4455
4460
  onUpdateEvent: r.onUpdateEvent,
@@ -4457,84 +4462,84 @@ function Fr({
4457
4462
  handleValuesEvent: p
4458
4463
  });
4459
4464
  Y(() => {
4460
- o == null || o(y.isStreaming);
4461
- }, [y.isStreaming, o]);
4462
- const { stream: T, stop: m, clear: k, isStreaming: E, error: U, connected: M, activeMessageId: $ } = y;
4465
+ s == null || s(h.isStreaming);
4466
+ }, [h.isStreaming, s]);
4467
+ const { stream: T, stop: y, clear: I, isStreaming: E, error: L, connected: M, activeMessageId: $ } = h;
4463
4468
  Y(() => {
4464
- d !== void 0 && k();
4465
- }, [d, k]);
4466
- const F = N(
4467
- async (h, j) => {
4468
- await T(h, j);
4469
+ u !== void 0 && I();
4470
+ }, [u, I]);
4471
+ const U = _(
4472
+ async (g, z) => {
4473
+ await T(g, z);
4469
4474
  },
4470
4475
  [T]
4471
- ), _ = H(l);
4476
+ ), V = W(c);
4472
4477
  Y(() => {
4473
- _.current = l;
4474
- }, [l]);
4475
- const O = N(
4476
- async (h, j, C) => {
4478
+ V.current = c;
4479
+ }, [c]);
4480
+ const P = _(
4481
+ async (g, z, C) => {
4477
4482
  var ye;
4478
- const P = a.current;
4479
- if (!P)
4483
+ const O = a.current;
4484
+ if (!O)
4480
4485
  throw new Error("No active thread to handle interrupt");
4481
- const J = h ? j ?? !0 : !1, K = _.current, V = (C == null ? void 0 : C.checkpointId) ?? K.id ?? void 0, ee = (C == null ? void 0 : C.checkpointNs) ?? K.namespace ?? void 0, ie = {
4482
- threadId: P,
4483
- checkpointId: V,
4486
+ const D = g ? z ?? !0 : !1, K = V.current, B = (C == null ? void 0 : C.checkpointId) ?? K.id ?? void 0, ee = (C == null ? void 0 : C.checkpointNs) ?? K.namespace ?? void 0, ie = {
4487
+ threadId: O,
4488
+ checkpointId: B,
4484
4489
  checkpointNs: ee,
4485
- command: { kind: "resume", value: J },
4490
+ command: { kind: "resume", value: D },
4486
4491
  payload: {
4487
4492
  ...(C == null ? void 0 : C.payload) ?? {},
4488
4493
  creativityLevel: ((ye = C == null ? void 0 : C.payload) == null ? void 0 : ye.creativityLevel) ?? "medium"
4489
4494
  },
4490
4495
  edit: !1
4491
4496
  };
4492
- F(ie);
4497
+ U(ie);
4493
4498
  },
4494
- [a, F]
4499
+ [a, U]
4495
4500
  );
4496
4501
  Y(() => {
4497
- w(O);
4498
- }, [O, w]);
4499
- const R = N(async () => {
4500
- m(), k(), u(), s(null);
4501
- }, [k, u, s, m]);
4502
+ w(P);
4503
+ }, [P, w]);
4504
+ const F = _(async () => {
4505
+ y(), I(), f(), o(null);
4506
+ }, [I, f, o, y]);
4502
4507
  Y(() => {
4503
- A(R);
4504
- }, [R, A]);
4505
- const W = N(
4506
- async (h, j) => {
4507
- E && m();
4508
+ A(F);
4509
+ }, [F, A]);
4510
+ const N = _(
4511
+ async (g, z) => {
4512
+ E && y();
4508
4513
  let C = a.current;
4509
- const P = (h == null ? void 0 : h.text) ?? "", J = (h == null ? void 0 : h.attachments) ?? [], K = (P == null ? void 0 : P.trim()) ?? "", V = { ...(h == null ? void 0 : h.payload) ?? {} }, ee = Array.isArray(V.messages) ? V.messages : void 0;
4510
- ee && delete V.messages;
4511
- const ie = !!(ee && ee.length), ye = !!(h.contentParts && h.contentParts.length > 0);
4512
- if (!C && !K && J.length === 0 && !ie && !ye) return;
4514
+ const O = (g == null ? void 0 : g.text) ?? "", D = (g == null ? void 0 : g.attachments) ?? [], K = (O == null ? void 0 : O.trim()) ?? "", B = { ...(g == null ? void 0 : g.payload) ?? {} }, ee = Array.isArray(B.messages) ? B.messages : void 0;
4515
+ ee && delete B.messages;
4516
+ const ie = !!(ee && ee.length), ye = !!(g.contentParts && g.contentParts.length > 0);
4517
+ if (!C && !K && D.length === 0 && !ie && !ye) return;
4513
4518
  if (!C) {
4514
4519
  const re = Math.floor(Date.now() / 1e3).toString(16).padStart(8, "0"), te = Array.from({ length: 4 }, () => Math.floor(Math.random() * 4294967295).toString(16).padStart(8, "0")).join("").slice(0, 16);
4515
- C = `${re}${te}`, g(C), s(C);
4520
+ C = `${re}${te}`, m(C), o(C);
4516
4521
  }
4517
- let G = null;
4518
- h.contentParts && h.contentParts.length > 0 && (G = h.contentParts);
4519
- const { contentParts: se, filesInfo: he } = G ? { contentParts: G, filesInfo: [] } : await or(J), X = [...se];
4520
- K && X.push({ type: "text", text: P });
4521
- const Q = h == null ? void 0 : h.originalMessageId, be = !!(h != null && h.edit && Q), Ve = !ie && X.length > 0;
4522
+ let J = null;
4523
+ g.contentParts && g.contentParts.length > 0 && (J = g.contentParts);
4524
+ const { contentParts: se, filesInfo: he } = J ? { contentParts: J, filesInfo: [] } : await or(D), X = [...se];
4525
+ K && X.push({ type: "text", text: O });
4526
+ const Q = g == null ? void 0 : g.originalMessageId, be = !!(g != null && g.edit && Q), He = !ie && X.length > 0;
4522
4527
  let we = null;
4523
- if (Ve) {
4528
+ if (He) {
4524
4529
  const re = be ? Q : `msg-${Date.now()}`;
4525
4530
  we = jt({
4526
4531
  id: re,
4527
4532
  role: "user",
4528
4533
  content: X,
4529
4534
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
4530
- }, "user"), be ? v(we, { editingMessageId: Q }) : v(we);
4535
+ }, "user"), be ? b(we, { editingMessageId: Q }) : b(we);
4531
4536
  }
4532
4537
  const Pe = ie ? ee : we ? [we] : [], ke = {
4533
- ...V,
4538
+ ...B,
4534
4539
  ...he.length ? { files_info: he } : {}
4535
4540
  };
4536
4541
  Pe.length ? ke.messages = Pe : "messages" in ke || (ke.messages = []);
4537
- let ne = (h == null ? void 0 : h.checkpointId) ?? l.id ?? void 0;
4542
+ let ne = (g == null ? void 0 : g.checkpointId) ?? c.id ?? void 0;
4538
4543
  if (be) {
4539
4544
  const re = S.find((te) => te.id === Q);
4540
4545
  if (re)
@@ -4549,54 +4554,54 @@ function Fr({
4549
4554
  te > 0 && S[te - 1].checkpointId && (ne = S[te - 1].checkpointId ?? void 0);
4550
4555
  }
4551
4556
  }
4552
- if (h != null && h.edit && !ne)
4557
+ if (g != null && g.edit && !ne)
4553
4558
  throw new Error(
4554
4559
  `[streaming] Missing checkpointId for edit submit. threadId=${C ?? "null"}. Ensure you are editing a message that has been saved.`
4555
4560
  );
4556
4561
  const Ue = {
4557
4562
  threadId: C,
4558
- content: h == null ? void 0 : h.text,
4563
+ content: g == null ? void 0 : g.text,
4559
4564
  payload: ke,
4560
- config: h == null ? void 0 : h.config,
4565
+ config: g == null ? void 0 : g.config,
4561
4566
  checkpointId: ne,
4562
- command: h == null ? void 0 : h.command,
4563
- edit: h == null ? void 0 : h.edit
4567
+ command: g == null ? void 0 : g.command,
4568
+ edit: g == null ? void 0 : g.edit
4564
4569
  };
4565
- return F(Ue, j);
4570
+ return U(Ue, z);
4566
4571
  },
4567
- [l, a, E, g, v, F, m, f]
4568
- ), B = Z(() => S, [S]), L = Z(
4572
+ [c, a, E, m, b, U, y, d]
4573
+ ), j = Z(() => S, [S]), G = Z(
4569
4574
  () => ({
4570
4575
  isStreaming: E,
4571
- error: U,
4572
- connectionState: U ? "error" : E ? M ? "connected" : "connecting" : "idle",
4573
- messages: B,
4576
+ error: L,
4577
+ connectionState: L ? "error" : E ? M ? "connected" : "connecting" : "idle",
4578
+ messages: j,
4574
4579
  activeMessageId: $,
4575
- submit: W,
4576
- stop: m,
4577
- interrupt: c,
4580
+ submit: N,
4581
+ stop: y,
4582
+ interrupt: l,
4578
4583
  resume: () => Promise.resolve(),
4579
- goto: (h, j) => Promise.resolve(),
4584
+ goto: (g, z) => Promise.resolve(),
4580
4585
  clearError: () => {
4581
4586
  }
4582
4587
  // TODO: Implement error clearing
4583
4588
  }),
4584
- [E, U, W, m, c, M, B]
4589
+ [E, L, N, y, l, M, j]
4585
4590
  );
4586
- return /* @__PURE__ */ de(qt.Provider, { value: L, children: e });
4591
+ return /* @__PURE__ */ de(Vt.Provider, { value: G, children: e });
4587
4592
  }
4588
4593
  function ge(e) {
4589
- const t = H(e);
4594
+ const t = W(e);
4590
4595
  return Y(() => {
4591
4596
  t.current = e;
4592
- }, [e]), N((...n) => {
4597
+ }, [e]), _((...n) => {
4593
4598
  const r = t.current;
4594
4599
  if (r)
4595
4600
  return r(...n);
4596
4601
  }, []);
4597
4602
  }
4598
4603
  function Or(e) {
4599
- return je(qt);
4604
+ return je(Vt);
4600
4605
  }
4601
4606
  function bt(e) {
4602
4607
  return typeof e == "object" && e !== null;
@@ -4607,24 +4612,24 @@ function $r(e, t) {
4607
4612
  const n = Object.keys(e), r = Object.keys(t);
4608
4613
  if (n.length !== r.length)
4609
4614
  return !1;
4610
- for (const o of n)
4611
- if (!Object.prototype.hasOwnProperty.call(t, o) || !Object.is(e[o], t[o]))
4615
+ for (const s of n)
4616
+ if (!Object.prototype.hasOwnProperty.call(t, s) || !Object.is(e[s], t[s]))
4612
4617
  return !1;
4613
4618
  return !0;
4614
4619
  }
4615
4620
  function Dr(e) {
4616
- const t = H(e), n = H(e);
4621
+ const t = W(e), n = W(e);
4617
4622
  return $r(t.current, e) || (t.current = e, n.current = e), n.current;
4618
4623
  }
4619
4624
  function Kr(e) {
4620
- 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;
4621
- return typeof o == "string" ? o : null;
4625
+ const t = e.artifact && typeof e.artifact == "object" ? e.artifact : null, n = !t && e.content && typeof e.content == "object" ? e.content : null, r = t ?? n, s = (r == null ? void 0 : r.task_id) ?? (r == null ? void 0 : r.taskId) ?? null;
4626
+ return typeof s == "string" ? s : null;
4622
4627
  }
4623
4628
  function fo(e) {
4624
4629
  const { setCurrentTaskId: t, getCurrentTaskId: n, onToolEnd: r } = e;
4625
- return (o) => {
4626
- const s = Kr(o), a = (n == null ? void 0 : n()) ?? null;
4627
- s && s !== a && t(s), r == null || r(o);
4630
+ return (s) => {
4631
+ const o = Kr(s), a = (n == null ? void 0 : n()) ?? null;
4632
+ o && o !== a && t(o), r == null || r(s);
4628
4633
  };
4629
4634
  }
4630
4635
  function po({
@@ -4632,59 +4637,59 @@ function po({
4632
4637
  apiConfig: t,
4633
4638
  initialThreadId: n = null,
4634
4639
  initialCheckpointId: r = null,
4635
- initialCheckpointNs: o = null,
4636
- autoLoadInitial: s = !0,
4640
+ initialCheckpointNs: s = null,
4641
+ autoLoadInitial: o = !0,
4637
4642
  onConnectionError: a,
4638
4643
  onError: i,
4639
- onAuthError: d,
4640
- onThreadChange: c,
4641
- onToolEnd: l,
4642
- onUpdateEvent: f,
4644
+ onAuthError: u,
4645
+ onThreadChange: l,
4646
+ onToolEnd: c,
4647
+ onUpdateEvent: d,
4643
4648
  onCustomEvent: p,
4644
- onMetadataEvent: g,
4645
- onFinish: I
4649
+ onMetadataEvent: m,
4650
+ onFinish: v
4646
4651
  }) {
4647
- const u = Dr(t), [v, x] = D(!1), S = me(i), A = me(d), w = me(a), b = me(c), y = me(l), T = me(f), m = me(p), k = me(g), E = me(I), U = Z(
4652
+ const f = Dr(t), [b, x] = H(!1), S = me(i), A = me(u), w = me(a), k = me(l), h = me(c), T = me(d), y = me(p), I = me(m), E = me(v), L = Z(
4648
4653
  () => ({
4649
4654
  onError: S,
4650
4655
  onAuthError: A,
4651
4656
  onConnectionError: w,
4652
- onToolEnd: y,
4657
+ onToolEnd: h,
4653
4658
  onUpdateEvent: T,
4654
- onCustomEvent: m,
4655
- onMetadataEvent: k,
4659
+ onCustomEvent: y,
4660
+ onMetadataEvent: I,
4656
4661
  onFinish: E
4657
4662
  }),
4658
4663
  [
4659
4664
  S,
4660
4665
  A,
4661
4666
  w,
4662
- y,
4667
+ h,
4663
4668
  T,
4664
- m,
4665
- k,
4669
+ y,
4670
+ I,
4666
4671
  E
4667
4672
  ]
4668
4673
  );
4669
- return /* @__PURE__ */ de(nr, { apiConfig: u, children: /* @__PURE__ */ de(
4674
+ return /* @__PURE__ */ de(nr, { apiConfig: f, children: /* @__PURE__ */ de(
4670
4675
  mr,
4671
4676
  {
4672
4677
  initialThreadId: n,
4673
4678
  onError: S,
4674
- onThreadChange: b,
4679
+ onThreadChange: k,
4675
4680
  children: /* @__PURE__ */ de(
4676
4681
  jr,
4677
4682
  {
4678
4683
  initialThreadId: n,
4679
4684
  initialCheckpointId: r,
4680
- initialCheckpointNs: o,
4681
- autoLoadInitial: s,
4685
+ initialCheckpointNs: s,
4686
+ autoLoadInitial: o,
4682
4687
  onError: S,
4683
- isStreaming: v,
4688
+ isStreaming: b,
4684
4689
  children: /* @__PURE__ */ de(
4685
4690
  Br,
4686
4691
  {
4687
- ...U,
4692
+ ...L,
4688
4693
  onStreamingChange: x,
4689
4694
  children: e
4690
4695
  }
@@ -4695,16 +4700,16 @@ function po({
4695
4700
  ) });
4696
4701
  }
4697
4702
  function me(e) {
4698
- const t = H(e);
4699
- return t.current = e, N((...n) => {
4703
+ const t = W(e);
4704
+ return t.current = e, _((...n) => {
4700
4705
  const r = t.current;
4701
4706
  if (r)
4702
4707
  return r(...n);
4703
4708
  }, []);
4704
4709
  }
4705
- const Vr = 1, qr = 1e6;
4710
+ const Hr = 1, Vr = 1e6;
4706
4711
  let We = 0;
4707
- function Hr() {
4712
+ function qr() {
4708
4713
  return We = (We + 1) % Number.MAX_SAFE_INTEGER, We.toString();
4709
4714
  }
4710
4715
  const Je = /* @__PURE__ */ new Map(), wt = (e) => {
@@ -4715,14 +4720,14 @@ const Je = /* @__PURE__ */ new Map(), wt = (e) => {
4715
4720
  type: "REMOVE_TOAST",
4716
4721
  toastId: e
4717
4722
  });
4718
- }, qr);
4723
+ }, Vr);
4719
4724
  Je.set(e, t);
4720
4725
  }, Gr = (e, t) => {
4721
4726
  switch (t.type) {
4722
4727
  case "ADD_TOAST":
4723
4728
  return {
4724
4729
  ...e,
4725
- toasts: [t.toast, ...e.toasts].slice(0, Vr)
4730
+ toasts: [t.toast, ...e.toasts].slice(0, Hr)
4726
4731
  };
4727
4732
  case "UPDATE_TOAST":
4728
4733
  return {
@@ -4762,9 +4767,9 @@ function Le(e) {
4762
4767
  });
4763
4768
  }
4764
4769
  function Wr({ ...e }) {
4765
- const t = Hr(), n = (o) => Le({
4770
+ const t = qr(), n = (s) => Le({
4766
4771
  type: "UPDATE_TOAST",
4767
- toast: { ...o, id: t }
4772
+ toast: { ...s, id: t }
4768
4773
  }), r = () => Le({ type: "DISMISS_TOAST", toastId: t });
4769
4774
  return Le({
4770
4775
  type: "ADD_TOAST",
@@ -4772,8 +4777,8 @@ function Wr({ ...e }) {
4772
4777
  ...e,
4773
4778
  id: t,
4774
4779
  open: !0,
4775
- onOpenChange: (o) => {
4776
- o || r();
4780
+ onOpenChange: (s) => {
4781
+ s || r();
4777
4782
  }
4778
4783
  }
4779
4784
  }), {
@@ -4794,75 +4799,75 @@ function Jr() {
4794
4799
  };
4795
4800
  }
4796
4801
  function go(e) {
4797
- const { allowFileOpen: t, currentThreadId: n } = e, { fileApi: r } = Me(), { toast: o } = Jr(), [s, a] = D({}), [i, d] = D(null), [c, l] = D(!1), f = N(() => {
4798
- l(!1), d(null);
4799
- }, []), p = N((I) => {
4800
- d(I), l(!0);
4801
- }, []), g = N(
4802
- async (I, u, v) => {
4802
+ const { allowFileOpen: t, currentThreadId: n } = e, { fileApi: r } = Me(), { toast: s } = Jr(), [o, a] = H({}), [i, u] = H(null), [l, c] = H(!1), d = _(() => {
4803
+ c(!1), u(null);
4804
+ }, []), p = _((v) => {
4805
+ u(v), c(!0);
4806
+ }, []), m = _(
4807
+ async (v, f, b) => {
4803
4808
  var x, S;
4804
4809
  if (!t) {
4805
- I.preventDefault();
4810
+ v.preventDefault();
4806
4811
  return;
4807
4812
  }
4808
- if (s[v]) {
4809
- I.preventDefault();
4813
+ if (o[b]) {
4814
+ v.preventDefault();
4810
4815
  return;
4811
4816
  }
4812
4817
  try {
4813
- const A = String(u.url ?? ""), w = A.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);
4818
+ const A = String(f.url ?? ""), w = A.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);
4814
4819
  if (w) {
4815
- I.preventDefault();
4816
- const b = w[1], y = u.name || `file_${b}`, T = u.mimeType || "application/octet-stream";
4817
- p({ id: b, name: y, mimeType: T });
4820
+ v.preventDefault();
4821
+ const k = w[1], h = f.name || `file_${k}`, T = f.mimeType || "application/octet-stream";
4822
+ p({ id: k, name: h, mimeType: T });
4818
4823
  return;
4819
4824
  }
4820
4825
  if (A.startsWith("data:")) {
4821
- I.preventDefault(), a((y) => ({ ...y, [v]: !0 }));
4822
- const b = o({ title: "Fetching file...", description: "", open: !0 });
4826
+ v.preventDefault(), a((h) => ({ ...h, [b]: !0 }));
4827
+ const k = s({ title: "Fetching file...", description: "", open: !0 });
4823
4828
  try {
4824
- const y = await r.listFiles(n ?? void 0);
4825
- if (!y || !Array.isArray(y))
4829
+ const h = await r.listFiles(n ?? void 0);
4830
+ if (!h || !Array.isArray(h))
4826
4831
  throw new Error("Invalid file list response");
4827
- const T = y.find((m) => !m || typeof m != "object" || !((m.filename ?? "") === (u.name ?? "")) ? !1 : typeof u.size == "number" && typeof m.size == "number" ? m.size === u.size : !0);
4832
+ const T = h.find((y) => !y || typeof y != "object" || !((y.filename ?? "") === (f.name ?? "")) ? !1 : typeof f.size == "number" && typeof y.size == "number" ? y.size === f.size : !0);
4828
4833
  if (!(T != null && T.id))
4829
- throw new Error(`File "${u.name}" is not yet available on the server`);
4834
+ throw new Error(`File "${f.name}" is not yet available on the server`);
4830
4835
  if (!T.id || !T.filename)
4831
4836
  throw new Error("Invalid file data received from server");
4832
4837
  p({
4833
4838
  id: T.id,
4834
- name: u.name || T.filename || `file_${T.id}`,
4835
- mimeType: u.mimeType || T.mime_type || "application/octet-stream"
4836
- }), (x = b.update) == null || x.call(b, {
4837
- id: b.id,
4839
+ name: f.name || T.filename || `file_${T.id}`,
4840
+ mimeType: f.mimeType || T.mime_type || "application/octet-stream"
4841
+ }), (x = k.update) == null || x.call(k, {
4842
+ id: k.id,
4838
4843
  title: "Success",
4839
- description: `Opened ${u.name}`,
4844
+ description: `Opened ${f.name}`,
4840
4845
  open: !0
4841
4846
  });
4842
- } catch (y) {
4843
- console.error("Failed to fetch server file:", y);
4844
- const T = y instanceof Error ? y.message : "Unknown error occurred";
4845
- (S = b.update) == null || S.call(b, { id: b.id, title: "Failed", description: T }), o({
4847
+ } catch (h) {
4848
+ console.error("Failed to fetch server file:", h);
4849
+ const T = h instanceof Error ? h.message : "Unknown error occurred";
4850
+ (S = k.update) == null || S.call(k, { id: k.id, title: "Failed", description: T }), s({
4846
4851
  title: "Failed to fetch file",
4847
4852
  description: T,
4848
4853
  open: !0
4849
4854
  });
4850
4855
  } finally {
4851
- a((y) => ({ ...y, [v]: !1 }));
4856
+ a((h) => ({ ...h, [b]: !1 }));
4852
4857
  }
4853
4858
  }
4854
4859
  } catch (A) {
4855
- console.error("File click error:", A), a((w) => ({ ...w, [v]: !1 }));
4860
+ console.error("File click error:", A), a((w) => ({ ...w, [b]: !1 }));
4856
4861
  }
4857
4862
  },
4858
- [t, s, o, n, p]
4863
+ [t, o, s, n, p]
4859
4864
  );
4860
4865
  return {
4861
- uploadingFiles: s,
4862
- handleFileClick: g,
4863
- fileViewerOpen: c,
4866
+ uploadingFiles: o,
4867
+ handleFileClick: m,
4868
+ fileViewerOpen: l,
4864
4869
  currentFileInfo: i,
4865
- closeFileViewer: f
4870
+ closeFileViewer: d
4866
4871
  };
4867
4872
  }
4868
4873
  function mo(e) {
@@ -4885,13 +4890,13 @@ function Xr(e) {
4885
4890
  if (!e) return [];
4886
4891
  const t = [], n = e.split(/\r?\n/);
4887
4892
  for (const r of n) {
4888
- const o = r.trim();
4889
- if (!o || !o.startsWith(kt))
4893
+ const s = r.trim();
4894
+ if (!s || !s.startsWith(kt))
4890
4895
  continue;
4891
- const s = o.slice(kt.length).trim();
4892
- if (!s || s.toLowerCase() === "[done]")
4896
+ const o = s.slice(kt.length).trim();
4897
+ if (!o || o.toLowerCase() === "[done]")
4893
4898
  continue;
4894
- const a = tt(s);
4899
+ const a = tt(o);
4895
4900
  a && typeof a == "object" && t.push(a);
4896
4901
  }
4897
4902
  return t;
@@ -4907,79 +4912,80 @@ function Qr(e) {
4907
4912
  function yo(e) {
4908
4913
  return Z(() => {
4909
4914
  const t = e.content.filter(
4910
- (d) => d.type === "text"
4915
+ (u) => u.type === "text"
4911
4916
  );
4912
4917
  if (!t.length)
4913
4918
  return null;
4914
4919
  let r = t.flatMap(
4915
- (d) => Xr(d.text ?? "")
4920
+ (u) => Xr(u.text ?? "")
4916
4921
  );
4917
4922
  if (!r.length) {
4918
- const d = t.map((l) => l.text ?? "").join(`
4919
- `), c = tt(d);
4920
- c && typeof c == "object" && (r = [c]);
4923
+ const u = t.map((c) => c.text ?? "").join(`
4924
+ `), l = tt(u);
4925
+ l && typeof l == "object" && (r = [l]);
4921
4926
  }
4922
4927
  if (!r.length)
4923
4928
  return null;
4924
- const s = Qr(r) ?? r[r.length - 1];
4925
- if (!s)
4929
+ const o = Qr(r) ?? r[r.length - 1];
4930
+ if (!o)
4926
4931
  return null;
4927
- const a = s.output ?? s.payload ?? s, i = ue(a);
4932
+ const a = o.output ?? o.payload ?? o, i = ue(a);
4928
4933
  return i && typeof i == "object" && !Array.isArray(i) ? {
4929
4934
  kind: "dict",
4930
4935
  value: i,
4931
4936
  data: i,
4932
- event: s
4937
+ event: o
4933
4938
  } : {
4934
4939
  kind: "generic",
4935
4940
  value: i,
4936
- event: s
4941
+ event: o
4937
4942
  };
4938
4943
  }, [e]);
4939
4944
  }
4940
4945
  function Yr(e) {
4941
- var M, $;
4942
- 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 || {
4946
+ var $, U;
4947
+ const t = typeof e == "string" ? e : e == null ? void 0 : e.threadId, n = typeof e == "object" ? e.lazy : !1, r = typeof e == "object" ? e.includeHistory : !0, s = ot({ optional: !0 }), o = Ht({ optional: !0 }), a = Or(), { currentThreadId: i, setCurrentThreadId: u, actions: l } = s || {
4943
4948
  currentThreadId: null,
4944
4949
  setCurrentThreadId: () => {
4945
4950
  },
4946
4951
  actions: {}
4947
- }, c = !!t && t !== a, [l, f] = D([]), p = N((F) => {
4948
- f(F);
4952
+ }, c = !!t && t !== i, [d, p] = H([]), m = _((V) => {
4953
+ p(V);
4949
4954
  }, []), {
4950
- isLoadingThread: g,
4951
- threadStateError: I,
4952
- threadCheckpoints: u,
4953
- isLoadingHistory: v,
4954
- loadThread: x
4955
+ isLoadingThread: v,
4956
+ threadStateError: f,
4957
+ threadCheckpoints: b,
4958
+ isLoadingHistory: x,
4959
+ loadThread: S
4955
4960
  } = $t({
4956
4961
  api: Me().chatApi,
4957
4962
  fileApi: Me().fileApi,
4958
- seed: p,
4963
+ seed: m,
4959
4964
  currentThreadId: c ? t : null,
4960
4965
  initialThreadId: c ? t : null,
4961
4966
  isStreaming: !1,
4962
- getMessages: () => l,
4963
- autoLoadInitial: c && !n
4967
+ getMessages: () => d,
4968
+ autoLoadInitial: c && !n,
4969
+ includeHistory: r
4964
4970
  });
4965
4971
  Y(() => {
4966
- !c && !n && a && (o != null && o.loadThread) && o.loadThread(a);
4967
- }, [c, n, a, o == null ? void 0 : o.loadThread]);
4968
- const S = Z(() => {
4969
- var F;
4970
- return ((F = u[0]) == null ? void 0 : F.values) || {};
4971
- }, [u]), A = Z(() => ({ timeline: [], messagePreviews: {} }), []), w = t || a, b = c ? g ? "loading" : "idle" : (o == null ? void 0 : o.status) || "idle", y = 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 ? S : (o == null ? void 0 : o.values) || {}, E = c ? {} : (o == null ? void 0 : o.taskMessagesByScope) || {}, U = c ? I : (s == null ? void 0 : s.error) || (o == null ? void 0 : o.error) || null;
4972
+ !c && !n && i && (o != null && o.loadThread) && o.loadThread(i);
4973
+ }, [c, n, i, o == null ? void 0 : o.loadThread]);
4974
+ const A = Z(() => {
4975
+ var V;
4976
+ return ((V = b[0]) == null ? void 0 : V.values) || {};
4977
+ }, [b]), w = Z(() => ({ timeline: [], messagePreviews: {} }), []), k = t || i, h = c ? v ? "loading" : "idle" : (o == null ? void 0 : o.status) || "idle", T = c ? d : (a == null ? void 0 : a.messages) || [], y = c ? v : (o == null ? void 0 : o.isLoading) || !1, I = c ? x : (o == null ? void 0 : o.isLoadingHistory) || !1, E = c ? A : (o == null ? void 0 : o.values) || {}, L = c ? {} : (o == null ? void 0 : o.taskMessagesByScope) || {}, M = c ? f : (a == null ? void 0 : a.error) || (o == null ? void 0 : o.error) || null;
4972
4978
  return {
4973
4979
  // UNIFIED: Single thread ID concept
4974
- threadId: w,
4975
- status: b,
4976
- messages: y,
4977
- isLoading: T,
4978
- isHistoryLoading: m,
4979
- error: U,
4980
+ threadId: k,
4981
+ status: h,
4982
+ messages: T,
4983
+ isLoading: y,
4984
+ isHistoryLoading: I,
4985
+ error: M,
4980
4986
  // Values & Metadata
4981
- values: k,
4982
- taskMessagesByScope: E,
4987
+ values: E,
4988
+ taskMessagesByScope: L,
4983
4989
  metadata: c ? {} : o == null ? void 0 : o.metadata,
4984
4990
  // Actions & State relating to Global/Active Thread only
4985
4991
  navigateToCheckpoint: c ? async () => {
@@ -4988,41 +4994,41 @@ function Yr(e) {
4988
4994
  returnToLatest: c ? async () => {
4989
4995
  } : (o == null ? void 0 : o.returnToLatest) || (async () => {
4990
4996
  }),
4991
- checkpoint: c ? u[0] ? { id: u[0].checkpointId, namespace: u[0].checkpointNs } : null : (o == null ? void 0 : o.checkpoint) || null,
4992
- checkpoints: c ? u : (o == null ? void 0 : o.checkpoints) || [],
4993
- checkpointIndex: c ? A : (o == null ? void 0 : o.checkpointIndex) || { timeline: [], messagePreviews: {} },
4997
+ checkpoint: c ? b[0] ? { id: b[0].checkpointId, namespace: b[0].checkpointNs } : null : (o == null ? void 0 : o.checkpoint) || null,
4998
+ checkpoints: c ? b : (o == null ? void 0 : o.checkpoints) || [],
4999
+ checkpointIndex: c ? w : (o == null ? void 0 : o.checkpointIndex) || { timeline: [], messagePreviews: {} },
4994
5000
  interrupt: c ? null : (o == null ? void 0 : o.interrupt) || null,
4995
5001
  respondToInterrupt: c ? async () => {
4996
5002
  } : (o == null ? void 0 : o.respondToInterrupt) || (async () => {
4997
5003
  }),
4998
5004
  // Streaming Status
4999
5005
  // Even in standalone mode, allow streaming state/stop if a stream context exists.
5000
- isStreaming: (s == null ? void 0 : s.isStreaming) || !1,
5001
- activeMessageId: c ? null : ((M = o == null ? void 0 : o.metadata) == null ? void 0 : M.assemblingMessageId) || (s == null ? void 0 : s.activeMessageId) || null,
5002
- connectionState: (s == null ? void 0 : s.connectionState) || "disconnected",
5003
- streamingAssistantId: !c && (s != null && s.isStreaming) && (($ = o == null ? void 0 : o.metadata) != null && $.assemblingMessageId) ? o.metadata.assemblingMessageId : null,
5006
+ isStreaming: (a == null ? void 0 : a.isStreaming) || !1,
5007
+ activeMessageId: c ? null : (($ = o == null ? void 0 : o.metadata) == null ? void 0 : $.assemblingMessageId) || (a == null ? void 0 : a.activeMessageId) || null,
5008
+ connectionState: (a == null ? void 0 : a.connectionState) || "disconnected",
5009
+ streamingAssistantId: !c && (a != null && a.isStreaming) && ((U = o == null ? void 0 : o.metadata) != null && U.assemblingMessageId) ? o.metadata.assemblingMessageId : null,
5004
5010
  // Actions
5005
- submit: (s == null ? void 0 : s.submit) || (async () => {
5011
+ submit: (a == null ? void 0 : a.submit) || (async () => {
5006
5012
  }),
5007
- stop: (s == null ? void 0 : s.stop) || (() => {
5013
+ stop: (a == null ? void 0 : a.stop) || (() => {
5008
5014
  }),
5009
5015
  clearThread: c ? async () => {
5010
5016
  } : (o == null ? void 0 : o.clearThread) || (async () => {
5011
5017
  }),
5012
- setCurrentThreadId: i,
5018
+ setCurrentThreadId: u,
5013
5019
  loadHistory: c ? async () => {
5014
- t && await x(t);
5020
+ t && await S(t);
5015
5021
  } : async () => {
5016
5022
  },
5017
5023
  onEvent: c ? () => {
5018
5024
  } : (o == null ? void 0 : o.onEvent) || (() => {
5019
5025
  }),
5020
5026
  // Thread Management
5021
- createThread: d == null ? void 0 : d.createThread,
5022
- deleteThread: d == null ? void 0 : d.deleteThread,
5023
- renameThread: d == null ? void 0 : d.renameThread,
5024
- threads: (r == null ? void 0 : r.threads) || [],
5025
- isThreadsLoading: (r == null ? void 0 : r.isLoading) || !1
5027
+ createThread: l == null ? void 0 : l.createThread,
5028
+ deleteThread: l == null ? void 0 : l.deleteThread,
5029
+ renameThread: l == null ? void 0 : l.renameThread,
5030
+ threads: (s == null ? void 0 : s.threads) || [],
5031
+ isThreadsLoading: (s == null ? void 0 : s.isLoading) || !1
5026
5032
  };
5027
5033
  }
5028
5034
  function ho({
@@ -5030,48 +5036,48 @@ function ho({
5030
5036
  chatRequest: t,
5031
5037
  lastCheckpointId: n,
5032
5038
  lastCheckpointNs: r,
5033
- onMessageSent: o,
5034
- onExcelUploadSuccess: s,
5039
+ onMessageSent: s,
5040
+ onExcelUploadSuccess: o,
5035
5041
  onError: a,
5036
5042
  enableMessageEditing: i,
5037
- messages: d,
5038
- setPendingAssistantResponse: c,
5039
- project: l,
5040
- onEvent: f,
5043
+ messages: u,
5044
+ setPendingAssistantResponse: l,
5045
+ project: c,
5046
+ onEvent: d,
5041
5047
  threadId: p,
5042
- clearComposerOnSend: g = !0
5048
+ clearComposerOnSend: m = !0
5043
5049
  }) {
5044
- const { messages: I } = Yr(), [u, v] = D(null), [x, S] = D(""), [A, w] = D(null), [b, y] = D(null), [T, m] = D(!1), [k, E] = D(""), U = H(k), M = H(null);
5050
+ const { messages: v } = Yr(), [f, b] = H(null), [x, S] = H(""), [A, w] = H(null), [k, h] = H(null), [T, y] = H(!1), [I, E] = H(""), L = W(I), M = W(null);
5045
5051
  Y(() => {
5046
- if (!u)
5052
+ if (!f)
5047
5053
  if (p) {
5048
- const j = localStorage.getItem(Ge(p));
5049
- E(j || "");
5054
+ const z = localStorage.getItem(Ge(p));
5055
+ E(z || "");
5050
5056
  } else
5051
5057
  E("");
5052
- }, [p, u]);
5053
- const $ = N((j) => {
5054
- E(j), !u && p && localStorage.setItem(Ge(p), j);
5055
- }, [p, u]);
5058
+ }, [p, f]);
5059
+ const $ = _((z) => {
5060
+ E(z), !f && p && localStorage.setItem(Ge(p), z);
5061
+ }, [p, f]);
5056
5062
  Y(() => {
5057
- U.current = k;
5058
- }, [k]), Y(() => {
5059
- if (!u) {
5063
+ L.current = I;
5064
+ }, [I]), Y(() => {
5065
+ if (!f) {
5060
5066
  M.current = null;
5061
5067
  return;
5062
5068
  }
5063
- M.current === null && (M.current = U.current), $(x ?? "");
5064
- }, [x, u, $]);
5065
- const F = N(
5066
- (j) => {
5067
- $(j);
5069
+ M.current === null && (M.current = L.current), $(x ?? "");
5070
+ }, [x, f, $]);
5071
+ const U = _(
5072
+ (z) => {
5073
+ $(z);
5068
5074
  },
5069
5075
  [$]
5070
- ), _ = async (j, C) => {
5071
- const P = Array.isArray(C) ? { files: C } : C ?? {}, J = P.files ?? [], K = P.contentParts ?? [], V = j.trim();
5072
- if (!(!V && J.length === 0 && K.length === 0))
5076
+ ), V = async (z, C) => {
5077
+ const O = Array.isArray(C) ? { files: C } : C ?? {}, D = O.files ?? [], K = O.contentParts ?? [], B = z.trim();
5078
+ if (!(!B && D.length === 0 && K.length === 0))
5073
5079
  try {
5074
- const ee = J.map(async (X) => {
5080
+ const ee = D.map(async (X) => {
5075
5081
  try {
5076
5082
  const Q = await Rt.uploadFile(X);
5077
5083
  return { file: X, record: Q };
@@ -5090,68 +5096,68 @@ function ho({
5090
5096
  name: X.filename,
5091
5097
  size: X.size
5092
5098
  };
5093
- }), G = [...K, ...ye], se = u ? (A == null ? void 0 : A.checkpointId) ?? n ?? void 0 : n ?? void 0, he = u ? (A == null ? void 0 : A.checkpointNs) ?? r ?? void 0 : r ?? void 0;
5099
+ }), J = [...K, ...ye], se = f ? (A == null ? void 0 : A.checkpointId) ?? n ?? void 0 : n ?? void 0, he = f ? (A == null ? void 0 : A.checkpointNs) ?? r ?? void 0 : r ?? void 0;
5094
5100
  await e(
5095
5101
  {
5096
- text: V || "",
5097
- contentParts: G,
5098
- attachments: J,
5102
+ text: B || "",
5103
+ contentParts: J,
5104
+ attachments: D,
5099
5105
  payload: t.payload,
5100
- edit: !!u,
5106
+ edit: !!f,
5101
5107
  checkpointId: se,
5102
5108
  checkpointNs: he,
5103
- project: l ?? void 0,
5104
- originalMessageId: u ?? void 0,
5109
+ project: c ?? void 0,
5110
+ originalMessageId: f ?? void 0,
5105
5111
  config: t.config
5106
5112
  },
5107
- f ? { onEvent: f } : void 0
5108
- ), o == null || o(V), c(!0), g && (p && localStorage.removeItem(Ge(p)), $("")), y(null), v(null), S(""), w(null);
5113
+ d ? { onEvent: d } : void 0
5114
+ ), s == null || s(B), l(!0), m && (p && localStorage.removeItem(Ge(p)), $("")), h(null), b(null), S(""), w(null);
5109
5115
  } catch (ee) {
5110
5116
  const ie = (ee == null ? void 0 : ee.message) || "Failed to send message";
5111
- y(ie), a == null || a(ie), c(!1);
5117
+ h(ie), a == null || a(ie), l(!1);
5112
5118
  }
5113
- }, O = (j, C) => {
5114
- C || _(j, { files: [] });
5115
- }, R = N(
5116
- async (j) => {
5119
+ }, P = (z, C) => {
5120
+ C || V(z, { files: [] });
5121
+ }, F = _(
5122
+ async (z) => {
5117
5123
  await e(
5118
5124
  {
5119
- attachments: [j],
5125
+ attachments: [z],
5120
5126
  payload: t.payload,
5121
5127
  checkpointId: n ?? void 0,
5122
5128
  checkpointNs: r ?? void 0,
5123
- project: l ?? void 0,
5129
+ project: c ?? void 0,
5124
5130
  config: t.config
5125
5131
  },
5126
- f ? { onEvent: f } : void 0
5127
- ), s == null || s({ file: j });
5132
+ d ? { onEvent: d } : void 0
5133
+ ), o == null || o({ file: z });
5128
5134
  },
5129
- [n, r, t, s, e]
5130
- ), W = N(
5131
- (j, C, P) => {
5132
- i && (M.current = k, v(j), S(C), w({
5133
- checkpointId: (P == null ? void 0 : P.checkpointId) ?? null,
5134
- checkpointNs: (P == null ? void 0 : P.checkpointNs) ?? null
5135
- }), y(null));
5135
+ [n, r, t, o, e]
5136
+ ), N = _(
5137
+ (z, C, O) => {
5138
+ i && (M.current = I, b(z), S(C), w({
5139
+ checkpointId: (O == null ? void 0 : O.checkpointId) ?? null,
5140
+ checkpointNs: (O == null ? void 0 : O.checkpointNs) ?? null
5141
+ }), h(null));
5136
5142
  },
5137
- [k, i]
5138
- ), B = N(() => {
5139
- v(null), S(""), w(null), y(null);
5140
- const j = M.current;
5141
- j !== null && E(j), M.current = null;
5142
- }, []), L = N((j) => {
5143
+ [I, i]
5144
+ ), j = _(() => {
5145
+ b(null), S(""), w(null), h(null);
5146
+ const z = M.current;
5147
+ z !== null && E(z), M.current = null;
5148
+ }, []), G = _((z) => {
5143
5149
  let C = null;
5144
- for (let V = j - 1; V >= 0; V--)
5145
- if (d[V].role === "user") {
5146
- C = d[V];
5150
+ for (let B = z - 1; B >= 0; B--)
5151
+ if (u[B].role === "user") {
5152
+ C = u[B];
5147
5153
  break;
5148
5154
  }
5149
5155
  if (!C) return;
5150
- const P = Array.isArray(C.content) ? C.content : [], K = P.filter((V) => (V == null ? void 0 : V.type) === "text").map((V) => V.text).join("") || (() => {
5156
+ const O = Array.isArray(C.content) ? C.content : [], K = O.filter((B) => (B == null ? void 0 : B.type) === "text").map((B) => B.text).join("") || (() => {
5151
5157
  try {
5152
- return JSON.stringify(P, null, 2);
5158
+ return JSON.stringify(O, null, 2);
5153
5159
  } catch {
5154
- return String(P);
5160
+ return String(O);
5155
5161
  }
5156
5162
  })();
5157
5163
  K && e(
@@ -5164,25 +5170,25 @@ function ho({
5164
5170
  originalMessageId: C.id,
5165
5171
  config: t.config
5166
5172
  },
5167
- f ? { onEvent: f } : void 0
5173
+ d ? { onEvent: d } : void 0
5168
5174
  );
5169
- }, [d, e, n, r, t]);
5175
+ }, [u, e, n, r, t]);
5170
5176
  return {
5171
- editingMessageId: u,
5177
+ editingMessageId: f,
5172
5178
  editingInitialValue: x,
5173
- inputError: b,
5174
- setInputError: y,
5179
+ inputError: k,
5180
+ setInputError: h,
5175
5181
  dismissError: T,
5176
- setDismissError: m,
5177
- composerValue: k,
5178
- handleComposerChange: F,
5179
- handleSendMessage: _,
5180
- handleQuickPrompt: O,
5181
- handleExcelUpload: R,
5182
- startEditing: W,
5183
- cancelEditing: B,
5184
- handleRegenerateCb: L,
5185
- displayMessages: I
5182
+ setDismissError: y,
5183
+ composerValue: I,
5184
+ handleComposerChange: U,
5185
+ handleSendMessage: V,
5186
+ handleQuickPrompt: P,
5187
+ handleExcelUpload: F,
5188
+ startEditing: N,
5189
+ cancelEditing: j,
5190
+ handleRegenerateCb: G,
5191
+ displayMessages: v
5186
5192
  };
5187
5193
  }
5188
5194
  function bo(e) {
@@ -5201,11 +5207,11 @@ function bo(e) {
5201
5207
  }, [e]);
5202
5208
  }
5203
5209
  function wo(e, t, n) {
5204
- const [r, o] = D(e), s = H(e), a = H(null);
5210
+ const [r, s] = H(e), o = W(e), a = W(null);
5205
5211
  return Y(() => {
5206
- s.current = e;
5212
+ o.current = e;
5207
5213
  const i = () => {
5208
- o(s.current), a.current && (clearTimeout(a.current), a.current = null);
5214
+ s(o.current), a.current && (clearTimeout(a.current), a.current = null);
5209
5215
  };
5210
5216
  if (!t || n <= 0) {
5211
5217
  i();
@@ -5232,7 +5238,7 @@ export {
5232
5238
  Pt as getChatToken,
5233
5239
  uo as getMessageAttemptInfo,
5234
5240
  ao as getToolCallArtifacts,
5235
- qn as getToolCalls,
5241
+ Vn as getToolCalls,
5236
5242
  so as hasContent,
5237
5243
  mt as hydrateHistorySnapshots,
5238
5244
  Ct as isFileLike,
@@ -5255,7 +5261,7 @@ export {
5255
5261
  pr as useStream,
5256
5262
  wo as useStreamingMarkdownBuffer,
5257
5263
  $t as useThreadHistoryState,
5258
- Vt as useThreadState,
5264
+ Ht as useThreadState,
5259
5265
  Lr as useThreadStateUpdater,
5260
5266
  ot as useThreads,
5261
5267
  gr as useThreadsState,