teodor-new-chat-ui 3.0.95 → 3.0.96
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 +160 -162
- package/dist/index.umd.js +9 -9
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as f from "react";
|
|
2
|
-
import V, { useState as fe, useRef as
|
|
2
|
+
import V, { useState as fe, useRef as Ke, useCallback as Ge, useEffect as Fe, useReducer as Dp, useMemo as un, createContext as wc, useContext as yc, createElement as uo, useLayoutEffect as Lp } from "react";
|
|
3
3
|
import { Square as Fp, Send as Bp, X as Vn, ExternalLink as $p, Download as Hp, Image as Sc, FileText as Va, Loader as zp, ChevronUp as wr, ChevronDown as Wn, Copy as Ga, Edit as Ka, RotateCcw as si, Bot as Ya, Wrench as Up, User as Wp, ChevronRight as Vp, Check as Hi, Circle as Gp, Edit3 as Cc, Paperclip as qa, Loader2 as Kp, Plus as Yp, FileSpreadsheet as qp, MessageSquarePlus as Xp, MessageSquare as Jp, Calendar as Zp, Trash2 as Qp, PanelLeft as em, Settings as tm, Server as nm, EyeOff as rm, Eye as om, Layout as sm, MessageCircle as im, Save as am } from "lucide-react";
|
|
4
4
|
import { Slot as tr, createSlot as Xn, createSlottable as lm } from "@radix-ui/react-slot";
|
|
5
5
|
import { cva as $r } from "class-variance-authority";
|
|
@@ -63,10 +63,10 @@ function fm() {
|
|
|
63
63
|
{
|
|
64
64
|
var ge = w.ReactDebugCurrentFrame, Oe = ge.getStackAddendum();
|
|
65
65
|
Oe !== "" && (z += "%s", ne = ne.concat([Oe]));
|
|
66
|
-
var
|
|
66
|
+
var Le = ne.map(function(Ie) {
|
|
67
67
|
return String(Ie);
|
|
68
68
|
});
|
|
69
|
-
|
|
69
|
+
Le.unshift("Warning: " + z), Function.prototype.apply.call(console[E], console, Le);
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
var N = !1, S = !1, T = !1, C = !1, R = !1, I;
|
|
@@ -123,9 +123,9 @@ function fm() {
|
|
|
123
123
|
var ge = E.displayName || null;
|
|
124
124
|
return ge !== null ? ge : U(E.type) || "Memo";
|
|
125
125
|
case m: {
|
|
126
|
-
var Oe = E,
|
|
126
|
+
var Oe = E, Le = Oe._payload, Ie = Oe._init;
|
|
127
127
|
try {
|
|
128
|
-
return U(Ie(
|
|
128
|
+
return U(Ie(Le));
|
|
129
129
|
} catch {
|
|
130
130
|
return null;
|
|
131
131
|
}
|
|
@@ -226,8 +226,8 @@ function fm() {
|
|
|
226
226
|
X = !0;
|
|
227
227
|
var Oe = Error.prepareStackTrace;
|
|
228
228
|
Error.prepareStackTrace = void 0;
|
|
229
|
-
var
|
|
230
|
-
|
|
229
|
+
var Le;
|
|
230
|
+
Le = ce.current, ce.current = null, Y();
|
|
231
231
|
try {
|
|
232
232
|
if (z) {
|
|
233
233
|
var Ie = function() {
|
|
@@ -280,7 +280,7 @@ function fm() {
|
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
282
|
} finally {
|
|
283
|
-
X = !1, ce.current =
|
|
283
|
+
X = !1, ce.current = Le, ye(), Error.prepareStackTrace = Oe;
|
|
284
284
|
}
|
|
285
285
|
var Bn = E ? E.displayName || E.name : "", Wa = Bn ? P(Bn) : "";
|
|
286
286
|
return typeof E == "function" && te.set(E, Wa), Wa;
|
|
@@ -312,9 +312,9 @@ function fm() {
|
|
|
312
312
|
case h:
|
|
313
313
|
return De(E.type, z, ne);
|
|
314
314
|
case m: {
|
|
315
|
-
var ge = E, Oe = ge._payload,
|
|
315
|
+
var ge = E, Oe = ge._payload, Le = ge._init;
|
|
316
316
|
try {
|
|
317
|
-
return De(
|
|
317
|
+
return De(Le(Oe), z, ne);
|
|
318
318
|
} catch {
|
|
319
319
|
}
|
|
320
320
|
}
|
|
@@ -331,9 +331,9 @@ function fm() {
|
|
|
331
331
|
}
|
|
332
332
|
function rt(E, z, ne, ge, Oe) {
|
|
333
333
|
{
|
|
334
|
-
var
|
|
334
|
+
var Le = Function.call.bind(de);
|
|
335
335
|
for (var Ie in E)
|
|
336
|
-
if (
|
|
336
|
+
if (Le(E, Ie)) {
|
|
337
337
|
var Re = void 0;
|
|
338
338
|
try {
|
|
339
339
|
if (typeof E[Ie] != "function") {
|
|
@@ -352,13 +352,13 @@ function fm() {
|
|
|
352
352
|
function ae(E) {
|
|
353
353
|
return J(E);
|
|
354
354
|
}
|
|
355
|
-
function
|
|
355
|
+
function $e(E) {
|
|
356
356
|
{
|
|
357
357
|
var z = typeof Symbol == "function" && Symbol.toStringTag, ne = z && E[Symbol.toStringTag] || E.constructor.name || "Object";
|
|
358
358
|
return ne;
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
|
-
function
|
|
361
|
+
function Ye(E) {
|
|
362
362
|
try {
|
|
363
363
|
return Ze(E), !1;
|
|
364
364
|
} catch {
|
|
@@ -369,8 +369,8 @@ function fm() {
|
|
|
369
369
|
return "" + E;
|
|
370
370
|
}
|
|
371
371
|
function wt(E) {
|
|
372
|
-
if (
|
|
373
|
-
return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",
|
|
372
|
+
if (Ye(E))
|
|
373
|
+
return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", $e(E)), Ze(E);
|
|
374
374
|
}
|
|
375
375
|
var dt = w.ReactCurrentOwner, Rt = {
|
|
376
376
|
key: !0,
|
|
@@ -419,7 +419,7 @@ function fm() {
|
|
|
419
419
|
});
|
|
420
420
|
}
|
|
421
421
|
}
|
|
422
|
-
var
|
|
422
|
+
var Ve = function(E, z, ne, ge, Oe, Le, Ie) {
|
|
423
423
|
var Re = {
|
|
424
424
|
// This tag allows us to uniquely identify this as a React Element
|
|
425
425
|
$$typeof: t,
|
|
@@ -429,7 +429,7 @@ function fm() {
|
|
|
429
429
|
ref: ne,
|
|
430
430
|
props: Ie,
|
|
431
431
|
// Record the component responsible for creating this element.
|
|
432
|
-
_owner:
|
|
432
|
+
_owner: Le
|
|
433
433
|
};
|
|
434
434
|
return Re._store = {}, Object.defineProperty(Re._store, "validated", {
|
|
435
435
|
configurable: !1,
|
|
@@ -450,20 +450,20 @@ function fm() {
|
|
|
450
450
|
};
|
|
451
451
|
function dr(E, z, ne, ge, Oe) {
|
|
452
452
|
{
|
|
453
|
-
var
|
|
453
|
+
var Le, Ie = {}, Re = null, ht = null;
|
|
454
454
|
ne !== void 0 && (wt(ne), Re = "" + ne), ft(z) && (wt(z.key), Re = "" + z.key), et(z) && (ht = z.ref, sn(z, Oe));
|
|
455
|
-
for (
|
|
456
|
-
de.call(z,
|
|
455
|
+
for (Le in z)
|
|
456
|
+
de.call(z, Le) && !Rt.hasOwnProperty(Le) && (Ie[Le] = z[Le]);
|
|
457
457
|
if (E && E.defaultProps) {
|
|
458
458
|
var qe = E.defaultProps;
|
|
459
|
-
for (
|
|
460
|
-
Ie[
|
|
459
|
+
for (Le in qe)
|
|
460
|
+
Ie[Le] === void 0 && (Ie[Le] = qe[Le]);
|
|
461
461
|
}
|
|
462
462
|
if (Re || ht) {
|
|
463
463
|
var tt = typeof E == "function" ? E.displayName || E.name || "Unknown" : E;
|
|
464
464
|
Re && ur(Ie, tt), ht && Ln(Ie, tt);
|
|
465
465
|
}
|
|
466
|
-
return
|
|
466
|
+
return Ve(E, Re, ht, Oe, ge, dt.current, Ie);
|
|
467
467
|
}
|
|
468
468
|
}
|
|
469
469
|
var fr = w.ReactCurrentOwner, oe = w.ReactDebugCurrentFrame;
|
|
@@ -534,7 +534,7 @@ Check the top-level render call using <` + ne + ">.");
|
|
|
534
534
|
else if (E) {
|
|
535
535
|
var Oe = p(E);
|
|
536
536
|
if (typeof Oe == "function" && Oe !== E.entries)
|
|
537
|
-
for (var
|
|
537
|
+
for (var Le = Oe.call(E), Ie; !(Ie = Le.next()).done; )
|
|
538
538
|
Ue(Ie.value) && pr(Ie.value, z);
|
|
539
539
|
}
|
|
540
540
|
}
|
|
@@ -576,7 +576,7 @@ Check the top-level render call using <` + ne + ">.");
|
|
|
576
576
|
E.ref !== null && (ie(E), b("Invalid attribute `ref` supplied to `React.Fragment`."), ie(null));
|
|
577
577
|
}
|
|
578
578
|
}
|
|
579
|
-
function Ua(E, z, ne, ge, Oe,
|
|
579
|
+
function Ua(E, z, ne, ge, Oe, Le) {
|
|
580
580
|
{
|
|
581
581
|
var Ie = k(E);
|
|
582
582
|
if (!Ie) {
|
|
@@ -587,7 +587,7 @@ Check the top-level render call using <` + ne + ">.");
|
|
|
587
587
|
var qe;
|
|
588
588
|
E === null ? qe = "null" : ae(E) ? qe = "array" : E !== void 0 && E.$$typeof === t ? (qe = "<" + (U(E.type) || "Unknown") + " />", Re = " Did you accidentally export a JSX literal instead of a component?") : qe = typeof E, b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", qe, Re);
|
|
589
589
|
}
|
|
590
|
-
var tt = dr(E, z, ne, Oe,
|
|
590
|
+
var tt = dr(E, z, ne, Oe, Le);
|
|
591
591
|
if (tt == null)
|
|
592
592
|
return tt;
|
|
593
593
|
if (Ie) {
|
|
@@ -2504,14 +2504,14 @@ class Gg {
|
|
|
2504
2504
|
}
|
|
2505
2505
|
const Nn = new Gg();
|
|
2506
2506
|
function Kg(e = {}) {
|
|
2507
|
-
const t = e.baseUrl ?? "/api/chat", n = e.streamPath ?? "/runs/stream", [r, o] = fe(e.token ?? null), s =
|
|
2507
|
+
const t = e.baseUrl ?? "/api/chat", n = e.streamPath ?? "/runs/stream", [r, o] = fe(e.token ?? null), s = Ke(e.headers ?? {}), [i, a] = fe(!1), [c, u] = fe(null), [d, h] = fe(""), [m, v] = fe(null), x = Ke(null), g = Ge((y) => {
|
|
2508
2508
|
o(y);
|
|
2509
|
-
}, []), p =
|
|
2509
|
+
}, []), p = Ge(() => {
|
|
2510
2510
|
var y;
|
|
2511
2511
|
(y = x.current) == null || y.abort(), x.current = null, a(!1);
|
|
2512
|
-
}, []), w =
|
|
2512
|
+
}, []), w = Ge(() => {
|
|
2513
2513
|
h(""), v(null), u(null);
|
|
2514
|
-
}, []), b =
|
|
2514
|
+
}, []), b = Ge(
|
|
2515
2515
|
(y, N, S) => {
|
|
2516
2516
|
x.current && (x.current.abort(), x.current = null), a(!0), u(null), e.autoAppendAssistant !== !1 && h("");
|
|
2517
2517
|
const T = new AbortController();
|
|
@@ -2623,7 +2623,7 @@ function Kg(e = {}) {
|
|
|
2623
2623
|
},
|
|
2624
2624
|
[t, r, e.autoAppendAssistant]
|
|
2625
2625
|
);
|
|
2626
|
-
return
|
|
2626
|
+
return Fe(() => () => {
|
|
2627
2627
|
var y;
|
|
2628
2628
|
return (y = x.current) == null ? void 0 : y.abort();
|
|
2629
2629
|
}, []), {
|
|
@@ -2707,16 +2707,16 @@ function Jg(e, t) {
|
|
|
2707
2707
|
}
|
|
2708
2708
|
}
|
|
2709
2709
|
function Zg(e = []) {
|
|
2710
|
-
const [t, n] = Dp(Jg, { ...Xg, messages: e }), r =
|
|
2710
|
+
const [t, n] = Dp(Jg, { ...Xg, messages: e }), r = Ke([]), o = Ke(null), s = Ke(null), i = Ge(() => {
|
|
2711
2711
|
o.current !== null && typeof window < "u" && window.cancelAnimationFrame(o.current), s.current !== null && clearTimeout(s.current), o.current = null, s.current = null;
|
|
2712
2712
|
const d = r.current;
|
|
2713
2713
|
d.length && (r.current = [], n({ type: "batch", payload: { events: d } }));
|
|
2714
|
-
}, []), a =
|
|
2714
|
+
}, []), a = Ge(() => {
|
|
2715
2715
|
typeof window < "u" && typeof window.requestAnimationFrame == "function" ? o.current === null && (o.current = window.requestAnimationFrame(() => i())) : s.current === null && (s.current = setTimeout(i, 8));
|
|
2716
|
-
}, [i]), c =
|
|
2716
|
+
}, [i]), c = Ge((d) => {
|
|
2717
2717
|
r.current.push(d), a();
|
|
2718
2718
|
}, [a]);
|
|
2719
|
-
|
|
2719
|
+
Fe(() => () => {
|
|
2720
2720
|
o.current !== null && typeof window < "u" && window.cancelAnimationFrame(o.current), s.current !== null && clearTimeout(s.current), r.current = [];
|
|
2721
2721
|
}, []);
|
|
2722
2722
|
const u = un(() => ({
|
|
@@ -2936,7 +2936,7 @@ async function ix(e, t = [], n, r, o, s) {
|
|
|
2936
2936
|
const qc = wc(null);
|
|
2937
2937
|
function mo({ children: e, apiConfig: t, onError: n, onThreadChange: r, initialThreadId: o = null, historyPageSize: s, autoLoadInitial: i = !0, enableFileAgentRouting: a = !1, fileAgentId: c = "invoice_reader" }) {
|
|
2938
2938
|
const u = Nn;
|
|
2939
|
-
|
|
2939
|
+
Fe(() => {
|
|
2940
2940
|
t && u.updateConfig({
|
|
2941
2941
|
baseUrl: t.baseUrl,
|
|
2942
2942
|
authToken: t.apiKey
|
|
@@ -2951,7 +2951,7 @@ function mo({ children: e, apiConfig: t, onError: n, onThreadChange: r, initialT
|
|
|
2951
2951
|
// Ensure the path matches the chat endpoint
|
|
2952
2952
|
streamPath: "/chat/runs/stream"
|
|
2953
2953
|
}), [g, p] = fe(() => typeof u.getAuthToken == "function" ? u.getAuthToken() : null);
|
|
2954
|
-
|
|
2954
|
+
Fe(() => {
|
|
2955
2955
|
x(typeof u.getAuthToken == "function" ? u.getAuthToken() : null);
|
|
2956
2956
|
const J = u.onTokenChange((ae) => {
|
|
2957
2957
|
p(ae), x(ae);
|
|
@@ -2960,23 +2960,23 @@ function mo({ children: e, apiConfig: t, onError: n, onThreadChange: r, initialT
|
|
|
2960
2960
|
J();
|
|
2961
2961
|
};
|
|
2962
2962
|
}, [u, x]);
|
|
2963
|
-
const w =
|
|
2963
|
+
const w = Ge((J) => {
|
|
2964
2964
|
u.setAuthToken(J);
|
|
2965
|
-
}, [u]), { state: b, seed: y, prepend: N, pushUser: S, onEvent: T, reset: C } = Zg(), R = s && s > 0 ? s : 6, [I, k] = fe(!1), [M, H] = fe(!1), [U, j] = fe(null), [$, L] = fe(void 0), [Q, O] = fe(void 0), _ =
|
|
2965
|
+
}, [u]), { state: b, seed: y, prepend: N, pushUser: S, onEvent: T, reset: C } = Zg(), R = s && s > 0 ? s : 6, [I, k] = fe(!1), [M, H] = fe(!1), [U, j] = fe(null), [$, L] = fe(void 0), [Q, O] = fe(void 0), _ = Ge(
|
|
2966
2966
|
(J, ae) => {
|
|
2967
|
-
const
|
|
2968
|
-
ae === "replace" ? y(
|
|
2967
|
+
const $e = Array.isArray(J == null ? void 0 : J.messages) ? J.messages : [];
|
|
2968
|
+
ae === "replace" ? y($e, {
|
|
2969
2969
|
checkpointId: (J == null ? void 0 : J.checkpointId) ?? null,
|
|
2970
2970
|
checkpointNs: (J == null ? void 0 : J.checkpointNs) ?? null
|
|
2971
|
-
}) : ae === "prepend" &&
|
|
2971
|
+
}) : ae === "prepend" && $e.length ? (console.log("[ChatProvider] Calling prepend with", $e.length, "messages"), N($e)) : console.log("[ChatProvider] Skipping prepend - empty list or wrong mode"), j((J == null ? void 0 : J.nextCursor) ?? null), k(!!(J != null && J.hasMore)), L((Ye) => (J == null ? void 0 : J.checkpointId) ?? Ye ?? void 0), O((Ye) => (J == null ? void 0 : J.checkpointNs) ?? Ye ?? void 0);
|
|
2972
2972
|
},
|
|
2973
2973
|
[y, N]
|
|
2974
|
-
), [G, Z] = fe([]), [q, F] = fe(null), Y =
|
|
2974
|
+
), [G, Z] = fe([]), [q, F] = fe(null), Y = Ge(async () => {
|
|
2975
2975
|
const J = await u.listThreads();
|
|
2976
2976
|
Z(J);
|
|
2977
|
-
}, [u]), [ye, ce] = fe(!1), K =
|
|
2977
|
+
}, [u]), [ye, ce] = fe(!1), K = Ge(
|
|
2978
2978
|
async (J) => {
|
|
2979
|
-
const ae = (J == null ? void 0 : J.maxAttempts) ?? 5,
|
|
2979
|
+
const ae = (J == null ? void 0 : J.maxAttempts) ?? 5, $e = (J == null ? void 0 : J.baseDelayMs) ?? 500, Ye = (J == null ? void 0 : J.timeoutMs) ?? 2e3;
|
|
2980
2980
|
if (!u.baseUrl) return !1;
|
|
2981
2981
|
const Ze = u.baseUrl.replace(/\/+$/, ""), wt = [
|
|
2982
2982
|
"/health",
|
|
@@ -2987,14 +2987,14 @@ function mo({ children: e, apiConfig: t, onError: n, onThreadChange: r, initialT
|
|
|
2987
2987
|
"/api/v2/chat/health"
|
|
2988
2988
|
], dt = async (Qe) => {
|
|
2989
2989
|
try {
|
|
2990
|
-
const at = new AbortController(), et = setTimeout(() => at.abort(),
|
|
2990
|
+
const at = new AbortController(), et = setTimeout(() => at.abort(), Ye), ft = await fetch(Qe, { method: "GET", signal: at.signal });
|
|
2991
2991
|
return clearTimeout(et), ft.ok;
|
|
2992
2992
|
} catch {
|
|
2993
2993
|
return !1;
|
|
2994
2994
|
}
|
|
2995
2995
|
}, Rt = async (Qe) => {
|
|
2996
2996
|
try {
|
|
2997
|
-
const at = new AbortController(), et = setTimeout(() => at.abort(),
|
|
2997
|
+
const at = new AbortController(), et = setTimeout(() => at.abort(), Ye), ft = await fetch(Qe, { method: "HEAD", signal: at.signal });
|
|
2998
2998
|
return clearTimeout(et), ft.ok;
|
|
2999
2999
|
} catch {
|
|
3000
3000
|
return !1;
|
|
@@ -3009,14 +3009,14 @@ function mo({ children: e, apiConfig: t, onError: n, onThreadChange: r, initialT
|
|
|
3009
3009
|
if (console.debug(`[ChatProvider] checking ${sn}`), await dt(sn) || et === "/" && await Rt(Ze + "/"))
|
|
3010
3010
|
return ce(!0), !0;
|
|
3011
3011
|
}
|
|
3012
|
-
const at =
|
|
3012
|
+
const at = $e * Math.pow(2, Qe);
|
|
3013
3013
|
await new Promise((et) => setTimeout(et, at));
|
|
3014
3014
|
}
|
|
3015
3015
|
return ce(!1), !1;
|
|
3016
3016
|
},
|
|
3017
3017
|
[u.baseUrl]
|
|
3018
3018
|
);
|
|
3019
|
-
|
|
3019
|
+
Fe(() => {
|
|
3020
3020
|
let J = !0;
|
|
3021
3021
|
if (!u.baseUrl) {
|
|
3022
3022
|
console.debug("[ChatProvider] skipping initial refreshThreads: api.baseUrl not configured");
|
|
@@ -3033,11 +3033,11 @@ function mo({ children: e, apiConfig: t, onError: n, onThreadChange: r, initialT
|
|
|
3033
3033
|
})(), () => {
|
|
3034
3034
|
J = !1;
|
|
3035
3035
|
};
|
|
3036
|
-
}, [Y, u.baseUrl, K]),
|
|
3036
|
+
}, [Y, u.baseUrl, K]), Fe(() => {
|
|
3037
3037
|
r == null || r(q);
|
|
3038
3038
|
}, [q, r]);
|
|
3039
|
-
const P =
|
|
3040
|
-
|
|
3039
|
+
const P = Ke(null);
|
|
3040
|
+
Fe(() => {
|
|
3041
3041
|
if (o && i) {
|
|
3042
3042
|
if (!u.baseUrl) {
|
|
3043
3043
|
console.debug("[ChatProvider] skipping initial load: api.baseUrl not configured");
|
|
@@ -3051,8 +3051,8 @@ function mo({ children: e, apiConfig: t, onError: n, onThreadChange: r, initialT
|
|
|
3051
3051
|
}));
|
|
3052
3052
|
}
|
|
3053
3053
|
}, [o, i, u.baseUrl, ye]);
|
|
3054
|
-
const X =
|
|
3055
|
-
async (J, ae,
|
|
3054
|
+
const X = Ke(null), te = Ge(
|
|
3055
|
+
async (J, ae, $e) => {
|
|
3056
3056
|
if (!u.baseUrl) {
|
|
3057
3057
|
console.debug("[ChatProvider] skipping loadThread: api.baseUrl not configured");
|
|
3058
3058
|
return;
|
|
@@ -3061,77 +3061,75 @@ function mo({ children: e, apiConfig: t, onError: n, onThreadChange: r, initialT
|
|
|
3061
3061
|
X.current = J;
|
|
3062
3062
|
try {
|
|
3063
3063
|
k(!1), j(null), L(void 0), O(void 0);
|
|
3064
|
-
const
|
|
3064
|
+
const Ye = await u.getMessages({
|
|
3065
3065
|
threadId: J,
|
|
3066
3066
|
checkpointId: ae,
|
|
3067
|
-
checkpointNs:
|
|
3067
|
+
checkpointNs: $e,
|
|
3068
3068
|
limit: R
|
|
3069
3069
|
});
|
|
3070
|
-
F(J), _(
|
|
3070
|
+
F(J), _(Ye, "replace");
|
|
3071
3071
|
} finally {
|
|
3072
3072
|
X.current = null;
|
|
3073
3073
|
}
|
|
3074
3074
|
}
|
|
3075
3075
|
},
|
|
3076
3076
|
[u, _]
|
|
3077
|
-
), ue =
|
|
3077
|
+
), ue = Ge(async (J) => {
|
|
3078
3078
|
const ae = await u.listCheckpoints(J);
|
|
3079
3079
|
return rx(ae, J);
|
|
3080
|
-
}, [u]), se =
|
|
3080
|
+
}, [u]), se = Ge(async (J, ae) => {
|
|
3081
3081
|
if (!q) throw new Error("No active thread");
|
|
3082
3082
|
k(!1), j(null), L(void 0), O(void 0);
|
|
3083
|
-
const
|
|
3083
|
+
const $e = await u.getMessages({
|
|
3084
3084
|
threadId: q,
|
|
3085
3085
|
checkpointId: J,
|
|
3086
3086
|
checkpointNs: ae ?? void 0,
|
|
3087
3087
|
limit: R
|
|
3088
3088
|
});
|
|
3089
|
-
_(
|
|
3090
|
-
}, [u, q, _, R]), Ae =
|
|
3089
|
+
_($e, "replace");
|
|
3090
|
+
}, [u, q, _, R]), Ae = Ge(async () => {
|
|
3091
3091
|
if (!q) throw new Error("No active thread");
|
|
3092
3092
|
await te(q);
|
|
3093
|
-
}, [q, te]), Pe =
|
|
3094
|
-
|
|
3093
|
+
}, [q, te]), Pe = Ke(!1);
|
|
3094
|
+
Fe(() => {
|
|
3095
3095
|
const J = Pe.current;
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
})();
|
|
3114
|
-
}
|
|
3096
|
+
Pe.current = d, J && !d && q && (async () => {
|
|
3097
|
+
try {
|
|
3098
|
+
const ae = await u.getMessages({
|
|
3099
|
+
threadId: q,
|
|
3100
|
+
// Do not pass checkpointId/checkpointNs so the backend returns the latest
|
|
3101
|
+
checkpointId: void 0,
|
|
3102
|
+
checkpointNs: void 0,
|
|
3103
|
+
limit: R
|
|
3104
|
+
});
|
|
3105
|
+
_(ae, "replace");
|
|
3106
|
+
} catch {
|
|
3107
|
+
}
|
|
3108
|
+
try {
|
|
3109
|
+
await Y();
|
|
3110
|
+
} catch {
|
|
3111
|
+
}
|
|
3112
|
+
})();
|
|
3115
3113
|
}, [d, q, b.lastCheckpointId, b.lastCheckpointNs, u, _, Y]);
|
|
3116
|
-
const De =
|
|
3114
|
+
const De = Ge(async (J) => {
|
|
3117
3115
|
const ae = await u.createThread(J);
|
|
3118
3116
|
return await Y(), await te(ae.threadId), ae.threadId;
|
|
3119
|
-
}, [u, Y, te]), de =
|
|
3117
|
+
}, [u, Y, te]), de = Ge(async (J) => {
|
|
3120
3118
|
await u.deleteThread(J), await Y(), q === J && (F(null), C([]), k(!1), j(null), L(void 0), O(void 0));
|
|
3121
|
-
}, [u, Y, q, C]), je =
|
|
3119
|
+
}, [u, Y, q, C]), je = Ge(async (J, ae) => {
|
|
3122
3120
|
await u.updateThread(J, ae), await Y();
|
|
3123
|
-
}, [u, Y]), xe =
|
|
3121
|
+
}, [u, Y]), xe = Ge(async (J, ae) => {
|
|
3124
3122
|
var Ln;
|
|
3125
|
-
const
|
|
3123
|
+
const $e = (ae == null ? void 0 : ae.attachments) || [], { contentParts: Ye, filesInfo: Ze } = await ix(
|
|
3126
3124
|
u,
|
|
3127
|
-
|
|
3125
|
+
$e,
|
|
3128
3126
|
t == null ? void 0 : t.uploadPath,
|
|
3129
3127
|
a,
|
|
3130
3128
|
c,
|
|
3131
3129
|
q
|
|
3132
3130
|
), wt = [];
|
|
3133
3131
|
J && wt.push({ type: "text", text: J });
|
|
3134
|
-
for (const
|
|
3132
|
+
for (const Ve of Ye) wt.push(Ve);
|
|
3135
3133
|
const dt = {
|
|
3136
3134
|
id: ((Ln = crypto.randomUUID) == null ? void 0 : Ln.call(crypto)) || `user-${Date.now()}`,
|
|
3137
3135
|
role: "user",
|
|
@@ -3143,12 +3141,12 @@ function mo({ children: e, apiConfig: t, onError: n, onThreadChange: r, initialT
|
|
|
3143
3141
|
S(dt);
|
|
3144
3142
|
const Rt = {
|
|
3145
3143
|
...dt,
|
|
3146
|
-
content: dt.content.filter((
|
|
3147
|
-
}, Qe = { ...(ae == null ? void 0 : ae.payloadExtras) ?? {} }, at = !!Qe.edit, et = Qe.originalMessageId, ft = typeof et == "string" ? et : void 0, sn =
|
|
3144
|
+
content: dt.content.filter((Ve) => Ve.type === "text" || Ve.type === "image_url" || Ve.type === "file")
|
|
3145
|
+
}, Qe = { ...(ae == null ? void 0 : ae.payloadExtras) ?? {} }, at = !!Qe.edit, et = Qe.originalMessageId, ft = typeof et == "string" ? et : void 0, sn = $e && $e.length > 0, ur = {
|
|
3148
3146
|
...q ? { threadId: q } : {},
|
|
3149
3147
|
payload: {
|
|
3150
3148
|
messages: [Rt],
|
|
3151
|
-
attachments: dt.content.filter((
|
|
3149
|
+
attachments: dt.content.filter((Ve) => Ve.type === "file").map((Ve) => ({ type: "file", url: Ve.url, mimeType: Ve.mimeType, name: Ve.name, size: Ve.size })),
|
|
3152
3150
|
files_info: Ze,
|
|
3153
3151
|
...a && sn && c ? { active_agent: c } : {},
|
|
3154
3152
|
...Qe
|
|
@@ -3162,16 +3160,16 @@ function mo({ children: e, apiConfig: t, onError: n, onThreadChange: r, initialT
|
|
|
3162
3160
|
};
|
|
3163
3161
|
m(
|
|
3164
3162
|
ur,
|
|
3165
|
-
(
|
|
3163
|
+
(Ve) => T(Ve),
|
|
3166
3164
|
{
|
|
3167
|
-
onError: (
|
|
3168
|
-
onOpen: ({ threadId:
|
|
3169
|
-
!q &&
|
|
3165
|
+
onError: (Ve) => console.warn("stream error", Ve),
|
|
3166
|
+
onOpen: ({ threadId: Ve, created: dr }) => {
|
|
3167
|
+
!q && Ve && (F(Ve), dr && Y().catch(() => {
|
|
3170
3168
|
}));
|
|
3171
3169
|
}
|
|
3172
3170
|
}
|
|
3173
3171
|
);
|
|
3174
|
-
}, [q, S, m, T, b.lastCheckpointId, b.lastCheckpointNs, u, t == null ? void 0 : t.uploadPath, Y, F, a, c]), Se =
|
|
3172
|
+
}, [q, S, m, T, b.lastCheckpointId, b.lastCheckpointNs, u, t == null ? void 0 : t.uploadPath, Y, F, a, c]), Se = Ge(
|
|
3175
3173
|
async (J) => {
|
|
3176
3174
|
if (!q) throw new Error("No active thread");
|
|
3177
3175
|
if (M || !I) return;
|
|
@@ -3179,14 +3177,14 @@ function mo({ children: e, apiConfig: t, onError: n, onThreadChange: r, initialT
|
|
|
3179
3177
|
if (ae) {
|
|
3180
3178
|
H(!0);
|
|
3181
3179
|
try {
|
|
3182
|
-
const
|
|
3180
|
+
const $e = await u.getMessages({
|
|
3183
3181
|
threadId: q,
|
|
3184
3182
|
checkpointId: $,
|
|
3185
3183
|
checkpointNs: Q,
|
|
3186
3184
|
limit: (J == null ? void 0 : J.limit) ?? R,
|
|
3187
3185
|
beforeId: ae
|
|
3188
3186
|
});
|
|
3189
|
-
_(
|
|
3187
|
+
_($e, "prepend");
|
|
3190
3188
|
} finally {
|
|
3191
3189
|
H(!1);
|
|
3192
3190
|
}
|
|
@@ -3807,15 +3805,15 @@ function tu(e, t) {
|
|
|
3807
3805
|
}
|
|
3808
3806
|
return s.push({ end: 1 / 0, start: r, value: o }), s;
|
|
3809
3807
|
}
|
|
3810
|
-
function
|
|
3808
|
+
function Be(e) {
|
|
3811
3809
|
return e === jr;
|
|
3812
3810
|
}
|
|
3813
3811
|
function kr(e, t) {
|
|
3814
|
-
if (
|
|
3812
|
+
if (!Be(e))
|
|
3815
3813
|
return t === e.k ? e.v : t < e.k ? kr(e.l, t) : kr(e.r, t);
|
|
3816
3814
|
}
|
|
3817
3815
|
function Ft(e, t, n = "k") {
|
|
3818
|
-
if (
|
|
3816
|
+
if (Be(e))
|
|
3819
3817
|
return [-1 / 0, void 0];
|
|
3820
3818
|
if (Number(e[n]) === t)
|
|
3821
3819
|
return [e.k, e.v];
|
|
@@ -3826,24 +3824,24 @@ function Ft(e, t, n = "k") {
|
|
|
3826
3824
|
return Ft(e.l, t, n);
|
|
3827
3825
|
}
|
|
3828
3826
|
function St(e, t, n) {
|
|
3829
|
-
return
|
|
3827
|
+
return Be(e) ? ou(t, n, 1) : t === e.k ? ot(e, { k: t, v: n }) : t < e.k ? Sl(ot(e, { l: St(e.l, t, n) })) : Sl(ot(e, { r: St(e.r, t, n) }));
|
|
3830
3828
|
}
|
|
3831
3829
|
function Gn() {
|
|
3832
3830
|
return jr;
|
|
3833
3831
|
}
|
|
3834
3832
|
function ns(e, t, n) {
|
|
3835
|
-
if (
|
|
3833
|
+
if (Be(e))
|
|
3836
3834
|
return [];
|
|
3837
3835
|
const r = Ft(e, t)[0];
|
|
3838
3836
|
return Sx(xi(e, r, n));
|
|
3839
3837
|
}
|
|
3840
3838
|
function gi(e, t) {
|
|
3841
|
-
if (
|
|
3839
|
+
if (Be(e)) return jr;
|
|
3842
3840
|
const { k: n, l: r, r: o } = e;
|
|
3843
3841
|
if (t === n) {
|
|
3844
|
-
if (
|
|
3842
|
+
if (Be(r))
|
|
3845
3843
|
return o;
|
|
3846
|
-
if (
|
|
3844
|
+
if (Be(o))
|
|
3847
3845
|
return r;
|
|
3848
3846
|
{
|
|
3849
3847
|
const [s, i] = ru(r);
|
|
@@ -3852,10 +3850,10 @@ function gi(e, t) {
|
|
|
3852
3850
|
} else return t < n ? go(ot(e, { l: gi(r, t) })) : go(ot(e, { r: gi(o, t) }));
|
|
3853
3851
|
}
|
|
3854
3852
|
function Cn(e) {
|
|
3855
|
-
return
|
|
3853
|
+
return Be(e) ? [] : [...Cn(e.l), { k: e.k, v: e.v }, ...Cn(e.r)];
|
|
3856
3854
|
}
|
|
3857
3855
|
function xi(e, t, n) {
|
|
3858
|
-
if (
|
|
3856
|
+
if (Be(e))
|
|
3859
3857
|
return [];
|
|
3860
3858
|
const { k: r, l: o, r: s, v: i } = e;
|
|
3861
3859
|
let a = [];
|
|
@@ -3868,7 +3866,7 @@ function go(e) {
|
|
|
3868
3866
|
if (n > r.lvl + 1) {
|
|
3869
3867
|
if (Fs(t))
|
|
3870
3868
|
return su(ot(e, { lvl: n - 1 }));
|
|
3871
|
-
if (
|
|
3869
|
+
if (!Be(t) && !Be(t.r))
|
|
3872
3870
|
return ot(t.r, {
|
|
3873
3871
|
l: ot(t, { r: t.r.l }),
|
|
3874
3872
|
lvl: n,
|
|
@@ -3881,7 +3879,7 @@ function go(e) {
|
|
|
3881
3879
|
} else {
|
|
3882
3880
|
if (Fs(e))
|
|
3883
3881
|
return vi(ot(e, { lvl: n - 1 }));
|
|
3884
|
-
if (
|
|
3882
|
+
if (!Be(r) && !Be(r.l)) {
|
|
3885
3883
|
const o = r.l, s = Fs(o) ? r.lvl - 1 : r.lvl;
|
|
3886
3884
|
return ot(o, {
|
|
3887
3885
|
l: ot(e, {
|
|
@@ -3905,13 +3903,13 @@ function ot(e, t) {
|
|
|
3905
3903
|
);
|
|
3906
3904
|
}
|
|
3907
3905
|
function nu(e) {
|
|
3908
|
-
return
|
|
3906
|
+
return Be(e.r) ? e.l : go(ot(e, { r: nu(e.r) }));
|
|
3909
3907
|
}
|
|
3910
3908
|
function Fs(e) {
|
|
3911
|
-
return
|
|
3909
|
+
return Be(e) || e.lvl > e.r.lvl;
|
|
3912
3910
|
}
|
|
3913
3911
|
function ru(e) {
|
|
3914
|
-
return
|
|
3912
|
+
return Be(e.r) ? [e.k, e.v] : ru(e.r);
|
|
3915
3913
|
}
|
|
3916
3914
|
function ou(e, t, n, r = jr, o = jr) {
|
|
3917
3915
|
return { k: e, l: r, lvl: n, r: o, v: t };
|
|
@@ -3921,11 +3919,11 @@ function Sl(e) {
|
|
|
3921
3919
|
}
|
|
3922
3920
|
function su(e) {
|
|
3923
3921
|
const { l: t } = e;
|
|
3924
|
-
return
|
|
3922
|
+
return !Be(t) && t.lvl === e.lvl ? ot(t, { r: ot(e, { l: t.r }) }) : e;
|
|
3925
3923
|
}
|
|
3926
3924
|
function vi(e) {
|
|
3927
3925
|
const { lvl: t, r: n } = e;
|
|
3928
|
-
return
|
|
3926
|
+
return !Be(n) && !Be(n.r) && n.lvl === t && n.r.lvl === t ? ot(n, { l: ot(e, { r: n.l }), lvl: t + 1 }) : e;
|
|
3929
3927
|
}
|
|
3930
3928
|
function Sx(e) {
|
|
3931
3929
|
return tu(e, ({ k: t, v: n }) => ({ index: t, value: n }));
|
|
@@ -3970,7 +3968,7 @@ function fn(e, t) {
|
|
|
3970
3968
|
return Math.round(e.getBoundingClientRect()[t]);
|
|
3971
3969
|
}
|
|
3972
3970
|
function rs(e) {
|
|
3973
|
-
return
|
|
3971
|
+
return !Be(e.groupOffsetTree);
|
|
3974
3972
|
}
|
|
3975
3973
|
function Xi({ index: e }, t) {
|
|
3976
3974
|
return t === e ? 0 : t < e ? -1 : 1;
|
|
@@ -3987,10 +3985,10 @@ function Tx() {
|
|
|
3987
3985
|
};
|
|
3988
3986
|
}
|
|
3989
3987
|
function Rx(e, t) {
|
|
3990
|
-
let n =
|
|
3988
|
+
let n = Be(e) ? 0 : 1 / 0;
|
|
3991
3989
|
for (const r of t) {
|
|
3992
3990
|
const { endIndex: o, size: s, startIndex: i } = r;
|
|
3993
|
-
if (n = Math.min(n, i),
|
|
3991
|
+
if (n = Math.min(n, i), Be(e)) {
|
|
3994
3992
|
e = St(e, 0, s);
|
|
3995
3993
|
continue;
|
|
3996
3994
|
}
|
|
@@ -4040,7 +4038,7 @@ function jx(e, [t, n, r, o]) {
|
|
|
4040
4038
|
t.length > 0 && r("received item sizes", t, vt.DEBUG);
|
|
4041
4039
|
const s = e.sizeTree;
|
|
4042
4040
|
let i = s, a = 0;
|
|
4043
|
-
if (n.length > 0 &&
|
|
4041
|
+
if (n.length > 0 && Be(s) && t.length === 2) {
|
|
4044
4042
|
const m = t[0].size, v = t[1].size;
|
|
4045
4043
|
i = n.reduce((x, g) => St(St(x, g, m), g + 1, v), i);
|
|
4046
4044
|
} else
|
|
@@ -4160,7 +4158,7 @@ const _x = {
|
|
|
4160
4158
|
le(
|
|
4161
4159
|
B(
|
|
4162
4160
|
d,
|
|
4163
|
-
pe((S) => S !== void 0 &&
|
|
4161
|
+
pe((S) => S !== void 0 && Be(Xe(g).sizeTree)),
|
|
4164
4162
|
re((S) => [{ endIndex: 0, size: S, startIndex: 0 }])
|
|
4165
4163
|
),
|
|
4166
4164
|
n
|
|
@@ -4282,7 +4280,7 @@ const _x = {
|
|
|
4282
4280
|
Ce(g, v),
|
|
4283
4281
|
re(([S, T, C]) => {
|
|
4284
4282
|
if (T.groupIndices.length > 0) {
|
|
4285
|
-
if (
|
|
4283
|
+
if (Be(T.sizeTree))
|
|
4286
4284
|
return T;
|
|
4287
4285
|
let R = Gn();
|
|
4288
4286
|
const I = Xe(p);
|
|
@@ -4500,7 +4498,7 @@ const Gr = ke(
|
|
|
4500
4498
|
B(
|
|
4501
4499
|
nt(t, i),
|
|
4502
4500
|
Ce(a, n, e, u),
|
|
4503
|
-
pe(([[, d], h, { sizeTree: m }, v, x]) => d && (
|
|
4501
|
+
pe(([[, d], h, { sizeTree: m }, v, x]) => d && (!Be(m) || Gi(v)) && !h && !x),
|
|
4504
4502
|
Ce(c)
|
|
4505
4503
|
),
|
|
4506
4504
|
([, d]) => {
|
|
@@ -4862,7 +4860,7 @@ const On = ke(
|
|
|
4862
4860
|
return { ...Bs, totalCount: R };
|
|
4863
4861
|
if (T === 0 && C === 0)
|
|
4864
4862
|
return _ === 0 ? { ...Bs, totalCount: R } : hu(_, k, I, U, j, $ || []);
|
|
4865
|
-
if (
|
|
4863
|
+
if (Be(O))
|
|
4866
4864
|
return _ > 0 ? null : xo(
|
|
4867
4865
|
$x(Zi(k, R), L, $),
|
|
4868
4866
|
[],
|
|
@@ -6161,10 +6159,10 @@ const Tv = /* @__PURE__ */ ke(
|
|
|
6161
6159
|
const et = Zi(je, P), ft = et + Math.max(De - 1, 0);
|
|
6162
6160
|
return Sv(Ol(et, ft, Pe));
|
|
6163
6161
|
}
|
|
6164
|
-
const
|
|
6165
|
-
let
|
|
6166
|
-
de ? X === 0 && te === 0 && De > 0 ? (
|
|
6167
|
-
const wt = Ol(
|
|
6162
|
+
const $e = Iu(ae, J, xe);
|
|
6163
|
+
let Ye, Ze;
|
|
6164
|
+
de ? X === 0 && te === 0 && De > 0 ? (Ye = 0, Ze = De - 1) : (Ye = $e * Do((X + Se) / (rt + Se)), Ze = $e * Pl((te + Se) / (rt + Se)) - 1, Ze = zs(P - 1, Tr(Ze, $e - 1)), Ye = zs(Ze, Tr(0, Ye))) : (Ye = 0, Ze = -1);
|
|
6165
|
+
const wt = Ol(Ye, Ze, Pe), { bottom: dt, top: Rt } = Ml(Ae, ue, se, wt), Qe = Pl(P / $e), at = Qe * rt + (Qe - 1) * Se - dt;
|
|
6168
6166
|
return { bottom: dt, itemHeight: rt, items: wt, itemWidth: J, offsetBottom: at, offsetTop: Rt, top: Rt };
|
|
6169
6167
|
}
|
|
6170
6168
|
)
|
|
@@ -7006,8 +7004,8 @@ function sb(e, t = !1) {
|
|
|
7006
7004
|
return `${e.length}:${n}:${r}`;
|
|
7007
7005
|
}
|
|
7008
7006
|
function ib(e, t) {
|
|
7009
|
-
const [n, r] = fe(e), o =
|
|
7010
|
-
return
|
|
7007
|
+
const [n, r] = fe(e), o = Ke(e), s = Ke(null);
|
|
7008
|
+
return Fe(() => {
|
|
7011
7009
|
if (!t) {
|
|
7012
7010
|
r(e);
|
|
7013
7011
|
return;
|
|
@@ -7032,8 +7030,8 @@ function Ws({
|
|
|
7032
7030
|
const i = ib(e, r), a = sb(i, r), [c, u] = fe(() => {
|
|
7033
7031
|
var v;
|
|
7034
7032
|
return ((v = br.get(a)) == null ? void 0 : v.html) ?? null;
|
|
7035
|
-
}), d =
|
|
7036
|
-
|
|
7033
|
+
}), d = Ke(null), h = Ke([]);
|
|
7034
|
+
Fe(() => {
|
|
7037
7035
|
h.current = [];
|
|
7038
7036
|
const v = br.get(a);
|
|
7039
7037
|
if (v && v.source === i) {
|
|
@@ -8389,7 +8387,7 @@ const Ew = f.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ l.jsx(
|
|
|
8389
8387
|
Ew.displayName = ps.displayName;
|
|
8390
8388
|
function Nw({ isOpen: e, onClose: t, fileId: n, fileName: r, mimeType: o }) {
|
|
8391
8389
|
const [s, i] = fe(!1), [a, c] = fe(null), [u, d] = fe(null), { toast: h } = ca();
|
|
8392
|
-
|
|
8390
|
+
Fe(() => {
|
|
8393
8391
|
e && n && m();
|
|
8394
8392
|
}, [e, n]);
|
|
8395
8393
|
const m = async () => {
|
|
@@ -8498,7 +8496,7 @@ function Nw({ isOpen: e, onClose: t, fileId: n, fileName: r, mimeType: o }) {
|
|
|
8498
8496
|
const Co = "prose prose-sm max-w-none break-words dark:prose-invert prose-headings:break-words prose-p:break-words prose-li:break-words prose-td:break-words prose-th:break-words prose-a:break-all prose-code:break-words prose-blockquote:break-words";
|
|
8499
8497
|
function Iw({ className: e }) {
|
|
8500
8498
|
const [t, n] = fe(0);
|
|
8501
|
-
return
|
|
8499
|
+
return Fe(() => {
|
|
8502
8500
|
const r = setInterval(() => n((o) => (o + 1) % 4), 500);
|
|
8503
8501
|
return () => clearInterval(r);
|
|
8504
8502
|
}, []), /* @__PURE__ */ l.jsxs(
|
|
@@ -9047,8 +9045,8 @@ function Dw(e) {
|
|
|
9047
9045
|
return e.name && e.name.trim() ? e.name : e.model && e.model.includes("/") ? e.model.split("/").pop() || null : e.model || null;
|
|
9048
9046
|
}
|
|
9049
9047
|
function Lw(e, t) {
|
|
9050
|
-
const [n, r] = fe(e), o =
|
|
9051
|
-
return
|
|
9048
|
+
const [n, r] = fe(e), o = Ke(e), s = Ke(null);
|
|
9049
|
+
return Fe(() => {
|
|
9052
9050
|
if (!t) {
|
|
9053
9051
|
r(e);
|
|
9054
9052
|
return;
|
|
@@ -9168,14 +9166,14 @@ function Hw({
|
|
|
9168
9166
|
emptyMessage: v,
|
|
9169
9167
|
followNewMessages: x = !0
|
|
9170
9168
|
}) {
|
|
9171
|
-
const g =
|
|
9172
|
-
|
|
9169
|
+
const g = Ke(null), p = Ke(null), w = Ke(!1), b = Ke(!0), y = Ke(e.length), N = Ke(!!x), S = t ? b.current ? "smooth" : !1 : "smooth";
|
|
9170
|
+
Fe(() => {
|
|
9173
9171
|
console.log("[MessageList] Messages updated:", {
|
|
9174
9172
|
count: e.length,
|
|
9175
9173
|
firstThree: e.slice(0, 3).map((R) => `${R.role}:${R.id.slice(0, 8)}`),
|
|
9176
9174
|
lastThree: e.slice(-3).map((R) => `${R.role}:${R.id.slice(0, 8)}`)
|
|
9177
9175
|
});
|
|
9178
|
-
}, [e]),
|
|
9176
|
+
}, [e]), Fe(() => {
|
|
9179
9177
|
const R = g.current;
|
|
9180
9178
|
if (!R) return;
|
|
9181
9179
|
let I = !1;
|
|
@@ -9188,7 +9186,7 @@ function Hw({
|
|
|
9188
9186
|
return R.addEventListener("scroll", k, { passive: !0 }), k(), () => {
|
|
9189
9187
|
R.removeEventListener("scroll", k);
|
|
9190
9188
|
};
|
|
9191
|
-
}, []),
|
|
9189
|
+
}, []), Fe(() => {
|
|
9192
9190
|
const R = y.current, I = e.length;
|
|
9193
9191
|
if (I > R) {
|
|
9194
9192
|
const k = e[I - 1];
|
|
@@ -9200,9 +9198,9 @@ function Hw({
|
|
|
9200
9198
|
}
|
|
9201
9199
|
});
|
|
9202
9200
|
}
|
|
9203
|
-
}, [e.length, x]),
|
|
9201
|
+
}, [e.length, x]), Fe(() => {
|
|
9204
9202
|
e.length < y.current && (b.current = !0), y.current = e.length;
|
|
9205
|
-
}, [e.length]),
|
|
9203
|
+
}, [e.length]), Fe(() => {
|
|
9206
9204
|
var R;
|
|
9207
9205
|
t || w.current || b.current && ((R = p.current) == null || R.scrollToIndex({
|
|
9208
9206
|
index: Math.max(0, e.length - 1),
|
|
@@ -9240,7 +9238,7 @@ function Hw({
|
|
|
9240
9238
|
}, [a]), C = (R, I) => {
|
|
9241
9239
|
g.current = R, I && (typeof I == "function" ? I(R) : I.current = R);
|
|
9242
9240
|
};
|
|
9243
|
-
return
|
|
9241
|
+
return Fe(() => {
|
|
9244
9242
|
if (!t) {
|
|
9245
9243
|
N.current = !!x;
|
|
9246
9244
|
return;
|
|
@@ -12011,14 +12009,14 @@ function Eo({
|
|
|
12011
12009
|
isLoadingHistory: M,
|
|
12012
12010
|
loadOlderMessages: H,
|
|
12013
12011
|
api: U
|
|
12014
|
-
} = Vi(), [j, $] = fe(null), [L, Q] = fe(""), [O, _] = fe(null), [G, Z] = fe([]), [q, F] = fe(!1), [Y, ye] = fe(null), [ce, K] = fe(null), [P, X] = fe(!1), [te, ue] = fe(null), [se, Ae] = fe([]), [Pe, De] = fe(null), [de, je] = fe(null), xe =
|
|
12015
|
-
|
|
12012
|
+
} = Vi(), [j, $] = fe(null), [L, Q] = fe(""), [O, _] = fe(null), [G, Z] = fe([]), [q, F] = fe(!1), [Y, ye] = fe(null), [ce, K] = fe(null), [P, X] = fe(!1), [te, ue] = fe(null), [se, Ae] = fe([]), [Pe, De] = fe(null), [de, je] = fe(null), xe = Ke(null), Se = Ke(null), rt = Ke(null), [J, ae] = fe("desktop");
|
|
12013
|
+
Fe(() => {
|
|
12016
12014
|
const oe = () => {
|
|
12017
12015
|
const ie = window.innerWidth;
|
|
12018
12016
|
ae(ie < 640 ? "phone" : ie < 1024 ? "tablet" : "desktop");
|
|
12019
12017
|
};
|
|
12020
12018
|
return oe(), window.addEventListener("resize", oe), () => window.removeEventListener("resize", oe);
|
|
12021
|
-
}, []),
|
|
12019
|
+
}, []), Fe(() => {
|
|
12022
12020
|
let oe = !1;
|
|
12023
12021
|
if (!x) {
|
|
12024
12022
|
Ae([]), De(null), je(null), rt.current = null;
|
|
@@ -12047,10 +12045,10 @@ function Eo({
|
|
|
12047
12045
|
}), () => {
|
|
12048
12046
|
oe = !0;
|
|
12049
12047
|
};
|
|
12050
|
-
}, [x, S, T, Pe, C]),
|
|
12048
|
+
}, [x, S, T, Pe, C]), Fe(() => {
|
|
12051
12049
|
S && (De(S), je(T ?? null));
|
|
12052
12050
|
}, [S, T]);
|
|
12053
|
-
const
|
|
12051
|
+
const $e = Ge(async () => {
|
|
12054
12052
|
if (!(!k || M))
|
|
12055
12053
|
try {
|
|
12056
12054
|
await H();
|
|
@@ -12058,7 +12056,7 @@ function Eo({
|
|
|
12058
12056
|
console.warn("loadOlderMessages failed", oe);
|
|
12059
12057
|
}
|
|
12060
12058
|
}, [k, M, H]);
|
|
12061
|
-
|
|
12059
|
+
Fe(() => {
|
|
12062
12060
|
(async () => {
|
|
12063
12061
|
try {
|
|
12064
12062
|
const ie = await U.getAgent("default");
|
|
@@ -12067,10 +12065,10 @@ function Eo({
|
|
|
12067
12065
|
console.warn("Failed to fetch default message:", ie), ue(null);
|
|
12068
12066
|
}
|
|
12069
12067
|
})();
|
|
12070
|
-
}, [U]),
|
|
12068
|
+
}, [U]), Fe(() => {
|
|
12071
12069
|
b && !P && (v == null || v(b));
|
|
12072
12070
|
}, [b, P, v]);
|
|
12073
|
-
const
|
|
12071
|
+
const Ye = (oe) => {
|
|
12074
12072
|
if (oe.length > To)
|
|
12075
12073
|
return `Message too long (${oe.length}/${To} characters)`;
|
|
12076
12074
|
try {
|
|
@@ -12090,7 +12088,7 @@ function Eo({
|
|
|
12090
12088
|
const ie = oe.trim();
|
|
12091
12089
|
if (!(!ie && G.length === 0)) {
|
|
12092
12090
|
if (ie) {
|
|
12093
|
-
const Ne =
|
|
12091
|
+
const Ne = Ye(ie);
|
|
12094
12092
|
if (Ne) {
|
|
12095
12093
|
_(Ne);
|
|
12096
12094
|
return;
|
|
@@ -12112,9 +12110,9 @@ function Eo({
|
|
|
12112
12110
|
u && ($(oe), Q(ie), _(null));
|
|
12113
12111
|
}, [u]), Rt = V.useCallback(() => {
|
|
12114
12112
|
$(null), Q(""), _(null);
|
|
12115
|
-
}, []), Qe =
|
|
12113
|
+
}, []), Qe = Ge((oe, ie) => {
|
|
12116
12114
|
dt(oe, ie);
|
|
12117
|
-
}, [dt]), at =
|
|
12115
|
+
}, [dt]), at = Ge((oe) => {
|
|
12118
12116
|
for (let ie = oe - 1; ie >= 0; ie--)
|
|
12119
12117
|
if (g[ie].role === "user") {
|
|
12120
12118
|
const Ne = Ze(g[ie]);
|
|
@@ -12158,8 +12156,8 @@ function Eo({
|
|
|
12158
12156
|
}
|
|
12159
12157
|
const ie = se.find((Ue) => Ue.checkpointId === oe), Ne = (ie == null ? void 0 : ie.checkpointNs) ?? null;
|
|
12160
12158
|
await R(oe, Ne), De(oe), je(Ne);
|
|
12161
|
-
},
|
|
12162
|
-
return /* @__PURE__ */ l.jsxs("div", { className:
|
|
12159
|
+
}, Ve = `flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${d.container || ""}`, dr = `flex-1 min-h-0 min-w-0 max-h-full w-full overflow-y-auto overflow-x-auto overscroll-contain break-words break-anywhere p-4 bg-transparent ${d.messagesArea || ""}`, fr = `flex-shrink-0 w-full border-t p-4 bg-transparent ${d.inputArea || ""}`;
|
|
12160
|
+
return /* @__PURE__ */ l.jsxs("div", { className: Ve, children: [
|
|
12163
12161
|
!!b && !P && /* @__PURE__ */ l.jsxs("div", { className: "flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between", children: [
|
|
12164
12162
|
/* @__PURE__ */ l.jsx("span", { children: b }),
|
|
12165
12163
|
/* @__PURE__ */ l.jsx(
|
|
@@ -12209,7 +12207,7 @@ function Eo({
|
|
|
12209
12207
|
enableMessageEditing: u,
|
|
12210
12208
|
editingMessageId: j,
|
|
12211
12209
|
onStartReached: () => {
|
|
12212
|
-
|
|
12210
|
+
$e();
|
|
12213
12211
|
},
|
|
12214
12212
|
onEdit: Qe,
|
|
12215
12213
|
onRegenerate: at,
|
|
@@ -12921,7 +12919,7 @@ function Ai({
|
|
|
12921
12919
|
deleteThread: p,
|
|
12922
12920
|
renameThread: w
|
|
12923
12921
|
} = Vi(), [b, y] = fe(m ?? []), [N, S] = fe(!1), [T, C] = fe(null), [R, I] = fe(null), [k, M] = fe(""), [H, U] = fe(!1);
|
|
12924
|
-
|
|
12922
|
+
Fe(() => {
|
|
12925
12923
|
y(m ?? []);
|
|
12926
12924
|
}, [m]);
|
|
12927
12925
|
const j = async (F) => {
|
|
@@ -15294,10 +15292,10 @@ const LT = {
|
|
|
15294
15292
|
};
|
|
15295
15293
|
function TR({ settings: e, onSettingsChange: t, className: n = "" }) {
|
|
15296
15294
|
const [r, o] = fe(!1), [s, i] = fe(!1), [a, c] = fe(e), [u, d] = fe(!1), { toast: h } = ca();
|
|
15297
|
-
|
|
15295
|
+
Fe(() => {
|
|
15298
15296
|
const p = JSON.stringify(a) !== JSON.stringify(e);
|
|
15299
15297
|
d(p);
|
|
15300
|
-
}, [a, e]),
|
|
15298
|
+
}, [a, e]), Fe(() => {
|
|
15301
15299
|
c(e);
|
|
15302
15300
|
}, [e]);
|
|
15303
15301
|
const m = () => {
|