teodor-new-chat-ui 3.0.141 → 3.0.143
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/components/ui/sheet.d.ts +1 -1
- package/dist/index.esm.js +182 -175
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ declare const SheetClose: React.ForwardRefExoticComponent<SheetPrimitive.DialogC
|
|
|
7
7
|
declare const SheetPortal: React.FC<SheetPrimitive.DialogPortalProps>;
|
|
8
8
|
declare const SheetOverlay: React.ForwardRefExoticComponent<Omit<SheetPrimitive.DialogOverlayProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
9
9
|
declare const sheetVariants: (props?: {
|
|
10
|
-
side?: "top" | "
|
|
10
|
+
side?: "top" | "bottom" | "right" | "left";
|
|
11
11
|
} & import("class-variance-authority/dist/types").ClassProp) => string;
|
|
12
12
|
interface SheetContentProps extends React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content>, VariantProps<typeof sheetVariants> {
|
|
13
13
|
}
|
package/dist/index.esm.js
CHANGED
|
@@ -85,7 +85,7 @@ function gm() {
|
|
|
85
85
|
var Le = z.displayName || z.name || "";
|
|
86
86
|
return Le !== "" ? re + "(" + Le + ")" : re;
|
|
87
87
|
}
|
|
88
|
-
function
|
|
88
|
+
function B(T) {
|
|
89
89
|
return T.displayName || "Context";
|
|
90
90
|
}
|
|
91
91
|
function G(T) {
|
|
@@ -113,10 +113,10 @@ function gm() {
|
|
|
113
113
|
switch (T.$$typeof) {
|
|
114
114
|
case a:
|
|
115
115
|
var z = T;
|
|
116
|
-
return
|
|
116
|
+
return B(z) + ".Consumer";
|
|
117
117
|
case i:
|
|
118
118
|
var re = T;
|
|
119
|
-
return
|
|
119
|
+
return B(re._context) + ".Provider";
|
|
120
120
|
case l:
|
|
121
121
|
return P(T, T.render, "ForwardRef");
|
|
122
122
|
case h:
|
|
@@ -195,18 +195,18 @@ function gm() {
|
|
|
195
195
|
Y < 0 && b("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
|
-
var he = g.ReactCurrentDispatcher,
|
|
198
|
+
var he = g.ReactCurrentDispatcher, F;
|
|
199
199
|
function A(T, z, re) {
|
|
200
200
|
{
|
|
201
|
-
if (
|
|
201
|
+
if (F === void 0)
|
|
202
202
|
try {
|
|
203
203
|
throw Error();
|
|
204
204
|
} catch (Le) {
|
|
205
205
|
var xe = Le.stack.trim().match(/\n( *(at )?)/);
|
|
206
|
-
|
|
206
|
+
F = xe && xe[1] || "";
|
|
207
207
|
}
|
|
208
208
|
return `
|
|
209
|
-
` +
|
|
209
|
+
` + F + T;
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
var H = !1, J;
|
|
@@ -1866,9 +1866,9 @@ const Vl = (e) => {
|
|
|
1866
1866
|
fetchOptions: j
|
|
1867
1867
|
} = Vl(x), P = t || fetch;
|
|
1868
1868
|
E = E ? (E + "").toLowerCase() : "text";
|
|
1869
|
-
let
|
|
1870
|
-
const _ =
|
|
1871
|
-
|
|
1869
|
+
let B = _g([b, y && y.toAbortSignal()], R), G = null;
|
|
1870
|
+
const _ = B && B.unsubscribe && (() => {
|
|
1871
|
+
B.unsubscribe();
|
|
1872
1872
|
});
|
|
1873
1873
|
let Y;
|
|
1874
1874
|
try {
|
|
@@ -1889,7 +1889,7 @@ const Vl = (e) => {
|
|
|
1889
1889
|
k.isString(I) || (I = I ? "include" : "omit");
|
|
1890
1890
|
const U = s && "credentials" in n.prototype, se = {
|
|
1891
1891
|
...j,
|
|
1892
|
-
signal:
|
|
1892
|
+
signal: B,
|
|
1893
1893
|
method: p.toUpperCase(),
|
|
1894
1894
|
headers: N.normalize().toJSON(),
|
|
1895
1895
|
body: g,
|
|
@@ -2532,7 +2532,7 @@ function Jg(e = {}) {
|
|
|
2532
2532
|
const P = new AbortController();
|
|
2533
2533
|
return b.current = P, (async () => {
|
|
2534
2534
|
var _, Y, U, se, O, M;
|
|
2535
|
-
const
|
|
2535
|
+
const B = (() => {
|
|
2536
2536
|
var K;
|
|
2537
2537
|
try {
|
|
2538
2538
|
return typeof window < "u" && ((K = window.localStorage) == null ? void 0 : K.getItem("chat-debug")) === "1";
|
|
@@ -2557,19 +2557,19 @@ function Jg(e = {}) {
|
|
|
2557
2557
|
if (r)
|
|
2558
2558
|
K = { Authorization: `Bearer ${r}` };
|
|
2559
2559
|
else if (typeof window < "u") {
|
|
2560
|
-
const he = window.__AUTH_TOKEN__,
|
|
2560
|
+
const he = window.__AUTH_TOKEN__, F = ((_ = window.localStorage) == null ? void 0 : _.getItem("authToken")) || null;
|
|
2561
2561
|
let A = null;
|
|
2562
2562
|
try {
|
|
2563
2563
|
const J = (Y = window.localStorage) == null ? void 0 : Y.getItem("chat-settings");
|
|
2564
2564
|
J && (A = ((U = JSON.parse(J)) == null ? void 0 : U.apiKey) || null);
|
|
2565
2565
|
} catch {
|
|
2566
2566
|
}
|
|
2567
|
-
const H = he ||
|
|
2567
|
+
const H = he || F || A || null;
|
|
2568
2568
|
H && (K = { Authorization: `Bearer ${H}` });
|
|
2569
2569
|
}
|
|
2570
2570
|
} catch {
|
|
2571
2571
|
}
|
|
2572
|
-
|
|
2572
|
+
B && console.debug("[use-chat] POST", t + n, G(N));
|
|
2573
2573
|
const W = await fetch(t + n, {
|
|
2574
2574
|
method: "POST",
|
|
2575
2575
|
headers: {
|
|
@@ -2583,13 +2583,13 @@ function Jg(e = {}) {
|
|
|
2583
2583
|
});
|
|
2584
2584
|
if (!W.ok || !W.body) {
|
|
2585
2585
|
const pe = await W.text().catch(() => "");
|
|
2586
|
-
throw
|
|
2586
|
+
throw B && console.debug("[use-chat] non-OK response", W.status, pe == null ? void 0 : pe.slice(0, 500)), new Error(`stream ${W.status}${pe ? ": " + pe : ""}`);
|
|
2587
2587
|
}
|
|
2588
2588
|
g(!0);
|
|
2589
2589
|
let ee = null, L = null, Z = null;
|
|
2590
2590
|
try {
|
|
2591
|
-
const pe = W.headers.get("X-Thread-Id") || W.headers.get("x-thread-id"), he = W.headers.get("X-Thread-Created") || W.headers.get("x-thread-created"),
|
|
2592
|
-
(se = j == null ? void 0 : j.onOpen) == null || se.call(j, { threadId:
|
|
2591
|
+
const pe = W.headers.get("X-Thread-Id") || W.headers.get("x-thread-id"), he = W.headers.get("X-Thread-Created") || W.headers.get("x-thread-created"), F = pe ?? null, A = String(he ?? "").toLowerCase() === "true";
|
|
2592
|
+
(se = j == null ? void 0 : j.onOpen) == null || se.call(j, { threadId: F, created: A }), ee = W.body.getReader(), L = new TextDecoder();
|
|
2593
2593
|
let H = "", J = "", ce = y.current;
|
|
2594
2594
|
for (; ; ) {
|
|
2595
2595
|
const { value: ie, done: Ae } = await ee.read();
|
|
@@ -2607,14 +2607,14 @@ function Jg(e = {}) {
|
|
|
2607
2607
|
try {
|
|
2608
2608
|
Ne = JSON.parse(ae);
|
|
2609
2609
|
} catch {
|
|
2610
|
-
|
|
2610
|
+
B && console.debug("[use-chat] skip malformed SSE data:", ae == null ? void 0 : ae.slice(0, 200));
|
|
2611
2611
|
continue;
|
|
2612
2612
|
}
|
|
2613
2613
|
const Se = Zg(Ne) ? Ne.data : Ne;
|
|
2614
|
-
|
|
2614
|
+
B && console.debug("[use-chat] event:", Se == null ? void 0 : Se.type, Se);
|
|
2615
2615
|
const fe = Se.seq;
|
|
2616
2616
|
if (fe !== void 0 && (ce > 0 && fe > ce + 1 && console.warn(`[use-chat] Gap detected: expected ${ce + 1}, got ${fe}`), ce = fe, y.current = fe, v(fe)), fe !== void 0 && fe <= y.current) {
|
|
2617
|
-
|
|
2617
|
+
B && console.debug("[use-chat] Duplicate event ignored:", fe);
|
|
2618
2618
|
continue;
|
|
2619
2619
|
}
|
|
2620
2620
|
if (Se.type === "token" && e.autoAppendAssistant !== !1)
|
|
@@ -2634,7 +2634,7 @@ function Jg(e = {}) {
|
|
|
2634
2634
|
} catch (pe) {
|
|
2635
2635
|
if ((pe == null ? void 0 : pe.name) === "AbortError") return;
|
|
2636
2636
|
const he = (pe == null ? void 0 : pe.message) || String(pe);
|
|
2637
|
-
|
|
2637
|
+
B && console.debug("[use-chat] error:", he), u(he), (O = j == null ? void 0 : j.onError) == null || O.call(j, he);
|
|
2638
2638
|
} finally {
|
|
2639
2639
|
try {
|
|
2640
2640
|
ee == null || ee.cancel();
|
|
@@ -2645,7 +2645,7 @@ function Jg(e = {}) {
|
|
|
2645
2645
|
} catch (K) {
|
|
2646
2646
|
if ((K == null ? void 0 : K.name) === "AbortError") return;
|
|
2647
2647
|
const W = (K == null ? void 0 : K.message) || String(K);
|
|
2648
|
-
|
|
2648
|
+
B && console.debug("[use-chat] connection error:", W), u(W), (M = j == null ? void 0 : j.onError) == null || M.call(j, W);
|
|
2649
2649
|
} finally {
|
|
2650
2650
|
a(!1), g(!1), b.current = null;
|
|
2651
2651
|
}
|
|
@@ -2961,7 +2961,7 @@ function wo({ children: e, apiConfig: t, onError: n, onThreadChange: r, initialT
|
|
|
2961
2961
|
}, [l, w]);
|
|
2962
2962
|
const p = Ue((V) => {
|
|
2963
2963
|
l.setAuthToken(V);
|
|
2964
|
-
}, [l]), { state: g, seed: b, prepend: y, pushUser: R, onEvent: S, reset: C } = nv(), E = 20, [N, I] = ue(!1), [j, P] = ue(!1), [
|
|
2964
|
+
}, [l]), { state: g, seed: b, prepend: y, pushUser: R, onEvent: S, reset: C } = nv(), E = 20, [N, I] = ue(!1), [j, P] = ue(!1), [B, G] = ue(null), [_, Y] = ue(void 0), [U, se] = ue(void 0), [O, M] = ue(!1), K = Ke(!1), W = Ke([]), ee = Ue((V) => {
|
|
2965
2965
|
V.cursor !== void 0 && G(V.cursor), V.hasMore !== void 0 && I(V.hasMore), V.checkpointId !== void 0 && Y(V.checkpointId), V.checkpointNs !== void 0 && se(V.checkpointNs);
|
|
2966
2966
|
}, []), L = Ue((V, ne) => {
|
|
2967
2967
|
const $e = async () => {
|
|
@@ -2992,7 +2992,7 @@ function wo({ children: e, apiConfig: t, onError: n, onThreadChange: r, initialT
|
|
|
2992
2992
|
})) : ne === "prepend" && $e.length ? (console.log("[ChatProvider] Calling prepend with", $e.length, "messages"), y($e)) : console.log("[ChatProvider] Skipping prepend - empty list or wrong mode"), G((V == null ? void 0 : V.nextCursor) ?? null), I(!!(V != null && V.hasMore)), Y((qe) => (V == null ? void 0 : V.checkpointId) ?? qe ?? void 0), se((qe) => (V == null ? void 0 : V.checkpointNs) ?? qe ?? void 0);
|
|
2993
2993
|
},
|
|
2994
2994
|
[b, y]
|
|
2995
|
-
), [pe, he] = ue([]), [
|
|
2995
|
+
), [pe, he] = ue([]), [F, A] = ue(null), H = Ue(async () => {
|
|
2996
2996
|
const V = await l.listThreads();
|
|
2997
2997
|
he(V);
|
|
2998
2998
|
}, [l]), [J, ce] = ue(!1), ie = Ue(
|
|
@@ -3055,8 +3055,8 @@ function wo({ children: e, apiConfig: t, onError: n, onThreadChange: r, initialT
|
|
|
3055
3055
|
V = !1;
|
|
3056
3056
|
};
|
|
3057
3057
|
}, [H, l.baseUrl, ie]), Ze(() => {
|
|
3058
|
-
r == null || r(
|
|
3059
|
-
}, [
|
|
3058
|
+
r == null || r(F);
|
|
3059
|
+
}, [F, r]);
|
|
3060
3060
|
const Ae = Ke(null);
|
|
3061
3061
|
Ze(() => {
|
|
3062
3062
|
if (o && s) {
|
|
@@ -3114,7 +3114,7 @@ function wo({ children: e, apiConfig: t, onError: n, onThreadChange: r, initialT
|
|
|
3114
3114
|
return cv(ne, V);
|
|
3115
3115
|
}, [l]), Se = Ue(async (V, ne) => {
|
|
3116
3116
|
await L(async () => {
|
|
3117
|
-
if (!
|
|
3117
|
+
if (!F) throw new Error("No active thread");
|
|
3118
3118
|
ee({
|
|
3119
3119
|
cursor: null,
|
|
3120
3120
|
hasMore: !1,
|
|
@@ -3122,24 +3122,24 @@ function wo({ children: e, apiConfig: t, onError: n, onThreadChange: r, initialT
|
|
|
3122
3122
|
checkpointNs: void 0
|
|
3123
3123
|
});
|
|
3124
3124
|
const $e = await l.getMessages({
|
|
3125
|
-
threadId:
|
|
3125
|
+
threadId: F,
|
|
3126
3126
|
checkpointId: V,
|
|
3127
3127
|
checkpointNs: ne ?? void 0,
|
|
3128
3128
|
limit: E
|
|
3129
3129
|
});
|
|
3130
3130
|
Z($e, "replace");
|
|
3131
3131
|
}, `navigateToCheckpoint-${V}`);
|
|
3132
|
-
}, [l,
|
|
3133
|
-
if (!
|
|
3134
|
-
await ae(
|
|
3135
|
-
}, [
|
|
3132
|
+
}, [l, F, Z, L, ee]), fe = Ue(async () => {
|
|
3133
|
+
if (!F) throw new Error("No active thread");
|
|
3134
|
+
await ae(F);
|
|
3135
|
+
}, [F, ae]), Ce = Ke(!1);
|
|
3136
3136
|
Ze(() => {
|
|
3137
3137
|
const V = Ce.current;
|
|
3138
|
-
Ce.current = u, V && !u &&
|
|
3138
|
+
Ce.current = u, V && !u && F && L(async () => {
|
|
3139
3139
|
M(!0);
|
|
3140
3140
|
try {
|
|
3141
3141
|
const ne = await l.getMessages({
|
|
3142
|
-
threadId:
|
|
3142
|
+
threadId: F,
|
|
3143
3143
|
// Do not pass checkpointId/checkpointNs so the backend returns the latest
|
|
3144
3144
|
checkpointId: void 0,
|
|
3145
3145
|
checkpointNs: void 0,
|
|
@@ -3157,13 +3157,13 @@ function wo({ children: e, apiConfig: t, onError: n, onThreadChange: r, initialT
|
|
|
3157
3157
|
console.warn("[ChatProvider] Post-streaming thread refresh failed:", ne);
|
|
3158
3158
|
}
|
|
3159
3159
|
}, "postStreamingRefresh");
|
|
3160
|
-
}, [u,
|
|
3160
|
+
}, [u, F, l, Z, H, L]);
|
|
3161
3161
|
const Be = Ue(async (V) => {
|
|
3162
3162
|
const ne = await l.createThread(V);
|
|
3163
3163
|
return await H(), await ae(ne.threadId), ne.threadId;
|
|
3164
3164
|
}, [l, H, ae]), ot = Ue(async (V) => {
|
|
3165
|
-
await l.deleteThread(V), await H(),
|
|
3166
|
-
}, [l, H,
|
|
3165
|
+
await l.deleteThread(V), await H(), F === V && (A(null), C([]), I(!1), G(null), Y(void 0), se(void 0));
|
|
3166
|
+
}, [l, H, F, C]), et = Ue(async (V, ne) => {
|
|
3167
3167
|
await l.updateThread(V, ne), await H();
|
|
3168
3168
|
}, [l, H]), xt = Ue(async (V, ne) => {
|
|
3169
3169
|
var hn;
|
|
@@ -3189,7 +3189,7 @@ function wo({ children: e, apiConfig: t, onError: n, onThreadChange: r, initialT
|
|
|
3189
3189
|
content: ht
|
|
3190
3190
|
// ← Clean content without empty parts
|
|
3191
3191
|
}, lt = { ...(ne == null ? void 0 : ne.payloadExtras) ?? {} }, Tt = !!lt.edit, at = lt.originalMessageId, pt = typeof at == "string" ? at : void 0, cn = $e && $e.length > 0, Yt = {
|
|
3192
|
-
...
|
|
3192
|
+
...F ? { threadId: F } : {},
|
|
3193
3193
|
payload: {
|
|
3194
3194
|
messages: [En],
|
|
3195
3195
|
// Remove attachments array since we're not including file parts in message content
|
|
@@ -3210,21 +3210,21 @@ function wo({ children: e, apiConfig: t, onError: n, onThreadChange: r, initialT
|
|
|
3210
3210
|
{
|
|
3211
3211
|
onError: (te) => console.warn("stream error", te),
|
|
3212
3212
|
onOpen: ({ threadId: te, created: le }) => {
|
|
3213
|
-
!
|
|
3213
|
+
!F && te && (A(te), le && H().catch(() => {
|
|
3214
3214
|
}));
|
|
3215
3215
|
}
|
|
3216
3216
|
}
|
|
3217
3217
|
);
|
|
3218
|
-
}, [
|
|
3218
|
+
}, [F, R, h, S, g.lastCheckpointId, g.lastCheckpointNs, l, t == null ? void 0 : t.uploadPath, H, A, i, a]), it = Ue(
|
|
3219
3219
|
async (V) => {
|
|
3220
|
-
if (!
|
|
3220
|
+
if (!F) throw new Error("No active thread");
|
|
3221
3221
|
if (j || !N) return;
|
|
3222
|
-
const ne =
|
|
3222
|
+
const ne = B;
|
|
3223
3223
|
if (ne) {
|
|
3224
3224
|
P(!0);
|
|
3225
3225
|
try {
|
|
3226
3226
|
const $e = await l.getMessages({
|
|
3227
|
-
threadId:
|
|
3227
|
+
threadId: F,
|
|
3228
3228
|
checkpointId: _,
|
|
3229
3229
|
checkpointNs: U,
|
|
3230
3230
|
limit: (V == null ? void 0 : V.limit) ?? E,
|
|
@@ -3236,14 +3236,14 @@ function wo({ children: e, apiConfig: t, onError: n, onThreadChange: r, initialT
|
|
|
3236
3236
|
}
|
|
3237
3237
|
}
|
|
3238
3238
|
},
|
|
3239
|
-
[l,
|
|
3239
|
+
[l, F, _, U, B, N, j, Z, E]
|
|
3240
3240
|
), an = {
|
|
3241
3241
|
baseUrl: l.baseUrl,
|
|
3242
3242
|
token: x,
|
|
3243
3243
|
setToken: p,
|
|
3244
3244
|
api: l,
|
|
3245
3245
|
threads: pe,
|
|
3246
|
-
currentThreadId:
|
|
3246
|
+
currentThreadId: F,
|
|
3247
3247
|
setCurrentThreadId: A,
|
|
3248
3248
|
messages: g.messages,
|
|
3249
3249
|
isStreaming: u,
|
|
@@ -4259,9 +4259,9 @@ const Lv = {
|
|
|
4259
4259
|
const E = C.groupIndices.length > 0, N = [], I = C.lastSize;
|
|
4260
4260
|
if (E) {
|
|
4261
4261
|
const j = Or(C.sizeTree, 0);
|
|
4262
|
-
let P = 0,
|
|
4262
|
+
let P = 0, B = 0;
|
|
4263
4263
|
for (; P < S; ) {
|
|
4264
|
-
const _ = C.groupIndices[
|
|
4264
|
+
const _ = C.groupIndices[B], Y = C.groupIndices.length === B + 1 ? 1 / 0 : C.groupIndices[B + 1] - _ - 1;
|
|
4265
4265
|
N.push({
|
|
4266
4266
|
endIndex: _,
|
|
4267
4267
|
size: j,
|
|
@@ -4270,7 +4270,7 @@ const Lv = {
|
|
|
4270
4270
|
endIndex: _ + 1 + Y - 1,
|
|
4271
4271
|
size: I,
|
|
4272
4272
|
startIndex: _ + 1
|
|
4273
|
-
}),
|
|
4273
|
+
}), B++, P += Y + 1;
|
|
4274
4274
|
}
|
|
4275
4275
|
const G = An(C.sizeTree);
|
|
4276
4276
|
return P !== S && G.shift(), G.reduce(
|
|
@@ -4297,9 +4297,9 @@ const Lv = {
|
|
|
4297
4297
|
).ranges;
|
|
4298
4298
|
}
|
|
4299
4299
|
return An(C.sizeTree).reduce(
|
|
4300
|
-
(j, { k: P, v:
|
|
4300
|
+
(j, { k: P, v: B }) => ({
|
|
4301
4301
|
prevIndex: P + S,
|
|
4302
|
-
prevSize:
|
|
4302
|
+
prevSize: B,
|
|
4303
4303
|
ranges: [...j.ranges, { endIndex: P + S - 1, size: j.prevSize, startIndex: j.prevIndex }]
|
|
4304
4304
|
}),
|
|
4305
4305
|
{
|
|
@@ -4332,14 +4332,14 @@ const Lv = {
|
|
|
4332
4332
|
return C;
|
|
4333
4333
|
let N = tr();
|
|
4334
4334
|
const I = Je(p);
|
|
4335
|
-
let j = 0, P = 0,
|
|
4335
|
+
let j = 0, P = 0, B = 0;
|
|
4336
4336
|
for (; j < -S; ) {
|
|
4337
|
-
|
|
4338
|
-
const G = I[P + 1] -
|
|
4337
|
+
B = I[P];
|
|
4338
|
+
const G = I[P + 1] - B - 1;
|
|
4339
4339
|
P++, j += G + 1;
|
|
4340
4340
|
}
|
|
4341
4341
|
if (N = An(C.sizeTree).reduce((G, { k: _, v: Y }) => Et(G, Math.max(0, _ + S), Y), N), j !== -S) {
|
|
4342
|
-
const G = Or(C.sizeTree,
|
|
4342
|
+
const G = Or(C.sizeTree, B);
|
|
4343
4343
|
N = Et(N, 0, G);
|
|
4344
4344
|
const _ = zt(C.sizeTree, -S + 1)[1];
|
|
4345
4345
|
N = Et(N, 1, _);
|
|
@@ -4469,12 +4469,12 @@ const qr = Me(
|
|
|
4469
4469
|
oe(
|
|
4470
4470
|
([
|
|
4471
4471
|
[R, S, C, E, N, I, j, P],
|
|
4472
|
-
|
|
4472
|
+
B,
|
|
4473
4473
|
G,
|
|
4474
4474
|
_
|
|
4475
4475
|
]) => {
|
|
4476
4476
|
const Y = hu(R), { align: U, behavior: se, offset: O } = Y, M = E - 1, K = du(Y, S, M);
|
|
4477
|
-
let W = Dr(K, S.offsetTree,
|
|
4477
|
+
let W = Dr(K, S.offsetTree, B) + I;
|
|
4478
4478
|
U === "end" ? (W += G + zt(S.sizeTree, K)[1] - C + _, K === M && (W += j)) : U === "center" ? W += (G + zt(S.sizeTree, K)[1] - C + _) / 2 : W -= N, O && (W += O);
|
|
4479
4479
|
const ee = (L) => {
|
|
4480
4480
|
y(), L ? (P("retrying to scroll to", { location: R }, St.DEBUG), ye(w, R)) : (ye(x, !0), P("list did not change, scroll successful", {}, St.DEBUG));
|
|
@@ -4608,10 +4608,10 @@ const Lr = "up", Nr = "down", Hv = "none", zv = {
|
|
|
4608
4608
|
viewportHeight: S
|
|
4609
4609
|
};
|
|
4610
4610
|
if (I) {
|
|
4611
|
-
let
|
|
4612
|
-
return R > b.state.scrollTop ? (
|
|
4611
|
+
let B, G;
|
|
4612
|
+
return R > b.state.scrollTop ? (B = "SCROLLED_DOWN", G = b.state.scrollTop - R) : (B = "SIZE_DECREASED", G = b.state.scrollTop - R || b.scrollTopDelta), {
|
|
4613
4613
|
atBottom: !0,
|
|
4614
|
-
atBottomBecause:
|
|
4614
|
+
atBottomBecause: B,
|
|
4615
4615
|
scrollTopDelta: G,
|
|
4616
4616
|
state: j
|
|
4617
4617
|
};
|
|
@@ -4898,7 +4898,7 @@ const zn = Me(
|
|
|
4898
4898
|
I,
|
|
4899
4899
|
j,
|
|
4900
4900
|
P,
|
|
4901
|
-
|
|
4901
|
+
B,
|
|
4902
4902
|
G,
|
|
4903
4903
|
_,
|
|
4904
4904
|
Y
|
|
@@ -4918,27 +4918,27 @@ const zn = Me(
|
|
|
4918
4918
|
G
|
|
4919
4919
|
);
|
|
4920
4920
|
const K = [];
|
|
4921
|
-
if (
|
|
4922
|
-
const pe =
|
|
4923
|
-
let
|
|
4921
|
+
if (B.length > 0) {
|
|
4922
|
+
const pe = B[0], he = B[B.length - 1];
|
|
4923
|
+
let F = 0;
|
|
4924
4924
|
for (const A of is(O, pe, he)) {
|
|
4925
4925
|
const H = A.value, J = Math.max(A.start, pe), ce = Math.min(A.end, he);
|
|
4926
4926
|
for (let ie = J; ie <= ce; ie++)
|
|
4927
|
-
K.push({ data: Y == null ? void 0 : Y[ie], index: ie, offset:
|
|
4927
|
+
K.push({ data: Y == null ? void 0 : Y[ie], index: ie, offset: F, size: H }), F += H;
|
|
4928
4928
|
}
|
|
4929
4929
|
}
|
|
4930
4930
|
if (!P)
|
|
4931
4931
|
return So([], K, N, _, U, G);
|
|
4932
|
-
const W =
|
|
4932
|
+
const W = B.length > 0 ? B[B.length - 1] + 1 : 0, ee = Pv(se, C, E, W);
|
|
4933
4933
|
if (ee.length === 0)
|
|
4934
4934
|
return null;
|
|
4935
4935
|
const L = N - 1, Z = ss([], (pe) => {
|
|
4936
4936
|
for (const he of ee) {
|
|
4937
|
-
const
|
|
4938
|
-
let A =
|
|
4939
|
-
const J =
|
|
4940
|
-
if (
|
|
4941
|
-
H += Math.floor((C -
|
|
4937
|
+
const F = he.value;
|
|
4938
|
+
let A = F.offset, H = he.start;
|
|
4939
|
+
const J = F.size;
|
|
4940
|
+
if (F.offset < C) {
|
|
4941
|
+
H += Math.floor((C - F.offset + _) / (J + _));
|
|
4942
4942
|
const ie = H - he.start;
|
|
4943
4943
|
A += ie * J + ie * _;
|
|
4944
4944
|
}
|
|
@@ -5082,12 +5082,12 @@ const zn = Me(
|
|
|
5082
5082
|
Te(t, l, n, s, o, r, a),
|
|
5083
5083
|
Te(e),
|
|
5084
5084
|
oe(([[h, m, w, x, v, p, g, b], y]) => {
|
|
5085
|
-
const { align: R, behavior: S, calculateViewLocation: C = Gv, done: E, ...N } = h, I = du(h, m, x - 1), j = Dr(I, m.offsetTree, y) + v + p, P = j + zt(m.sizeTree, I)[1],
|
|
5085
|
+
const { align: R, behavior: S, calculateViewLocation: C = Gv, done: E, ...N } = h, I = du(h, m, x - 1), j = Dr(I, m.offsetTree, y) + v + p, P = j + zt(m.sizeTree, I)[1], B = b + p, G = b + w - g, _ = C({
|
|
5086
5086
|
itemBottom: P,
|
|
5087
5087
|
itemTop: j,
|
|
5088
5088
|
locationParams: { align: R, behavior: S, ...N },
|
|
5089
5089
|
viewportBottom: G,
|
|
5090
|
-
viewportTop:
|
|
5090
|
+
viewportTop: B
|
|
5091
5091
|
});
|
|
5092
5092
|
return _ ? E && $t(
|
|
5093
5093
|
$(
|
|
@@ -5139,8 +5139,8 @@ const Kv = (e, t) => typeof e == "function" ? kc(e(t)) : t && kc(e), Yv = Me(
|
|
|
5139
5139
|
nt($(me(t), Dn(1)), l),
|
|
5140
5140
|
Te(me(x), s, a, h),
|
|
5141
5141
|
oe(([[S, C], E, N, I, j]) => {
|
|
5142
|
-
let P = C && I,
|
|
5143
|
-
return P && (
|
|
5142
|
+
let P = C && I, B = "auto";
|
|
5143
|
+
return P && (B = Kv(E, N || j), P = P && !!B), { followOutputBehavior: B, shouldFollow: P, totalCount: S };
|
|
5144
5144
|
}),
|
|
5145
5145
|
ge(({ shouldFollow: S }) => S)
|
|
5146
5146
|
),
|
|
@@ -5767,7 +5767,7 @@ const sx = /* @__PURE__ */ Me(() => {
|
|
|
5767
5767
|
ia("deviation", (_) => {
|
|
5768
5768
|
g !== _ && b(_);
|
|
5769
5769
|
});
|
|
5770
|
-
const y = be("EmptyPlaceholder"), R = be("ScrollSeekPlaceholder") || ax, S = be("ListComponent"), C = be("ItemComponent"), E = be("GroupComponent"), N = be("computeItemKey"), I = be("isSeeking"), j = be("groupIndices").length > 0, P = be("alignToBottom"),
|
|
5770
|
+
const y = be("EmptyPlaceholder"), R = be("ScrollSeekPlaceholder") || ax, S = be("ListComponent"), C = be("ItemComponent"), E = be("GroupComponent"), N = be("computeItemKey"), I = be("isSeeking"), j = be("groupIndices").length > 0, P = be("alignToBottom"), B = be("initialItemFinalLocationReached"), G = e ? {} : {
|
|
5771
5771
|
boxSizing: "border-box",
|
|
5772
5772
|
...v ? {
|
|
5773
5773
|
display: "inline-block",
|
|
@@ -5781,7 +5781,7 @@ const sx = /* @__PURE__ */ Me(() => {
|
|
|
5781
5781
|
paddingBottom: t.offsetBottom,
|
|
5782
5782
|
paddingTop: t.offsetTop
|
|
5783
5783
|
},
|
|
5784
|
-
...
|
|
5784
|
+
...B ? {} : { visibility: "hidden" }
|
|
5785
5785
|
};
|
|
5786
5786
|
return !e && t.totalCount === 0 && y ? /* @__PURE__ */ c.jsx(y, { ...dt(y, u) }) : /* @__PURE__ */ c.jsx(
|
|
5787
5787
|
S,
|
|
@@ -6110,7 +6110,7 @@ const Ix = /* @__PURE__ */ Me(
|
|
|
6110
6110
|
{ customScrollParent: p, useWindowScroll: g, windowScrollContainerState: b, windowScrollTo: y, windowViewportRect: R },
|
|
6111
6111
|
S
|
|
6112
6112
|
]) => {
|
|
6113
|
-
const C = X(0), E = X(0), N = X(_c), I = X({ height: 0, width: 0 }), j = X({ height: 0, width: 0 }), P = ke(),
|
|
6113
|
+
const C = X(0), E = X(0), N = X(_c), I = X({ height: 0, width: 0 }), j = X({ height: 0, width: 0 }), P = ke(), B = ke(), G = X(0), _ = X(null), Y = X({ column: 0, row: 0 }), U = ke(), se = ke(), O = X(!1), M = X(0), K = X(!0), W = X(!1), ee = X(!1);
|
|
6114
6114
|
Fe(
|
|
6115
6115
|
$(
|
|
6116
6116
|
x,
|
|
@@ -6290,7 +6290,7 @@ const Ix = /* @__PURE__ */ Me(
|
|
|
6290
6290
|
),
|
|
6291
6291
|
l
|
|
6292
6292
|
);
|
|
6293
|
-
const
|
|
6293
|
+
const F = ft(
|
|
6294
6294
|
$(
|
|
6295
6295
|
N,
|
|
6296
6296
|
oe((A) => A.offsetBottom + A.bottom)
|
|
@@ -6318,7 +6318,7 @@ const Ix = /* @__PURE__ */ Me(
|
|
|
6318
6318
|
restoreStateFrom: se,
|
|
6319
6319
|
scrollBy: i,
|
|
6320
6320
|
scrollContainerState: a,
|
|
6321
|
-
scrollHeight:
|
|
6321
|
+
scrollHeight: B,
|
|
6322
6322
|
scrollTo: l,
|
|
6323
6323
|
scrollToIndex: P,
|
|
6324
6324
|
scrollTop: u,
|
|
@@ -6334,7 +6334,7 @@ const Ix = /* @__PURE__ */ Me(
|
|
|
6334
6334
|
gridState: N,
|
|
6335
6335
|
horizontalDirection: ee,
|
|
6336
6336
|
initialTopMostItemIndex: M,
|
|
6337
|
-
totalListHeight:
|
|
6337
|
+
totalListHeight: F,
|
|
6338
6338
|
...m,
|
|
6339
6339
|
endReached: Z,
|
|
6340
6340
|
propsReady: v,
|
|
@@ -8585,7 +8585,7 @@ const _w = q.memo(function({
|
|
|
8585
8585
|
}) {
|
|
8586
8586
|
const [y, R] = ue(!1), [S, C] = ue(!1), [E, N] = ue(!1), [I, j] = ue(!1), { currentThreadId: P } = Yi();
|
|
8587
8587
|
ha();
|
|
8588
|
-
const [
|
|
8588
|
+
const [B, G] = ue({}), [_, Y] = ue(!1), [U, se] = ue(null), O = u === "phone" || u === "half-screen", M = t.role, K = M === "tool", W = q.useMemo(() => {
|
|
8589
8589
|
switch (M) {
|
|
8590
8590
|
case "user":
|
|
8591
8591
|
return "text-[hsl(var(--chat-bubble-user-text))]";
|
|
@@ -8609,7 +8609,7 @@ const _w = q.memo(function({
|
|
|
8609
8609
|
batchedPreview: he.slice(-50)
|
|
8610
8610
|
});
|
|
8611
8611
|
}, [r, ee, he, t.id]);
|
|
8612
|
-
const
|
|
8612
|
+
const F = async () => {
|
|
8613
8613
|
try {
|
|
8614
8614
|
const ae = K ? Zn(t.content) : ee;
|
|
8615
8615
|
await navigator.clipboard.writeText(ae), R(!0), setTimeout(() => R(!1), 2e3), b == null || b(ae);
|
|
@@ -8900,7 +8900,7 @@ const _w = q.memo(function({
|
|
|
8900
8900
|
{
|
|
8901
8901
|
variant: "ghost",
|
|
8902
8902
|
size: "sm",
|
|
8903
|
-
onClick:
|
|
8903
|
+
onClick: F,
|
|
8904
8904
|
className: D("h-6 w-6 p-0 hover:bg-foreground/10", W, O && "h-5 w-5"),
|
|
8905
8905
|
children: /* @__PURE__ */ c.jsx(
|
|
8906
8906
|
qa,
|
|
@@ -8965,7 +8965,7 @@ const _w = q.memo(function({
|
|
|
8965
8965
|
{
|
|
8966
8966
|
variant: "ghost",
|
|
8967
8967
|
size: "sm",
|
|
8968
|
-
onClick:
|
|
8968
|
+
onClick: F,
|
|
8969
8969
|
className: D("h-6 w-6 p-0 hover:bg-background/50 text-current", O && "h-5 w-5"),
|
|
8970
8970
|
children: /* @__PURE__ */ c.jsx(qa, { className: D(y ? "text-success" : "text-current", O ? "h-3 w-3" : "h-4 w-4") })
|
|
8971
8971
|
}
|
|
@@ -9272,7 +9272,7 @@ const sl = (e, t) => (e == null ? void 0 : e.id) ?? `message-${t}`, Sd = q.forwa
|
|
|
9272
9272
|
}
|
|
9273
9273
|
}
|
|
9274
9274
|
};
|
|
9275
|
-
}, [a]), j = ln(() => !x || v ? !1 : t && C ? "
|
|
9275
|
+
}, [a]), j = ln(() => !x || v ? !1 : t && C ? "auto" : !1, [t, C, x, v]);
|
|
9276
9276
|
return e.length === 0 ? /* @__PURE__ */ c.jsx("div", { className: h, style: m, children: /* @__PURE__ */ c.jsx("div", { className: "flex items-center justify-center py-8 text-muted-foreground text-center max-w-md mx-auto", children: w || "No messages yet. Start a conversation!" }) }) : /* @__PURE__ */ c.jsx("div", { className: h, style: m, children: /* @__PURE__ */ c.jsx(
|
|
9277
9277
|
Cx,
|
|
9278
9278
|
{
|
|
@@ -9284,39 +9284,46 @@ const sl = (e, t) => (e == null ? void 0 : e.id) ?? `message-${t}`, Sd = q.forwa
|
|
|
9284
9284
|
},
|
|
9285
9285
|
data: e,
|
|
9286
9286
|
followOutput: j,
|
|
9287
|
-
overscan:
|
|
9288
|
-
increaseViewportBy: 200,
|
|
9287
|
+
overscan: 400,
|
|
9288
|
+
increaseViewportBy: { top: 200, bottom: 400 },
|
|
9289
9289
|
defaultItemHeight: 120,
|
|
9290
|
-
atBottomThreshold:
|
|
9290
|
+
atBottomThreshold: 100,
|
|
9291
9291
|
alignToBottom: !0,
|
|
9292
9292
|
startReached: () => {
|
|
9293
9293
|
I && I();
|
|
9294
9294
|
},
|
|
9295
9295
|
atBottomStateChange: N,
|
|
9296
9296
|
style: { height: "100%", overscrollBehavior: "contain" },
|
|
9297
|
-
computeItemKey: (P,
|
|
9298
|
-
itemContent: (P,
|
|
9299
|
-
const G = sl(
|
|
9300
|
-
return /* @__PURE__ */ c.jsx(
|
|
9301
|
-
|
|
9297
|
+
computeItemKey: (P, B) => sl(B, P),
|
|
9298
|
+
itemContent: (P, B) => {
|
|
9299
|
+
const G = sl(B, P);
|
|
9300
|
+
return /* @__PURE__ */ c.jsx(
|
|
9301
|
+
"div",
|
|
9302
9302
|
{
|
|
9303
|
-
|
|
9304
|
-
|
|
9305
|
-
|
|
9306
|
-
|
|
9307
|
-
|
|
9308
|
-
|
|
9309
|
-
|
|
9310
|
-
|
|
9311
|
-
|
|
9312
|
-
|
|
9313
|
-
|
|
9314
|
-
|
|
9315
|
-
|
|
9316
|
-
|
|
9317
|
-
|
|
9318
|
-
|
|
9319
|
-
|
|
9303
|
+
className: "mb-4 last:mb-0",
|
|
9304
|
+
"data-message-id": G,
|
|
9305
|
+
style: { contentVisibility: "auto" },
|
|
9306
|
+
children: /* @__PURE__ */ c.jsx(
|
|
9307
|
+
_w,
|
|
9308
|
+
{
|
|
9309
|
+
message: B,
|
|
9310
|
+
messageIndex: P,
|
|
9311
|
+
isStreamingMessage: t && n === B.id,
|
|
9312
|
+
streamingDebounceMs: r,
|
|
9313
|
+
isEditing: i === B.id,
|
|
9314
|
+
showActions: s,
|
|
9315
|
+
showTimestamp: !1,
|
|
9316
|
+
showAgentName: !0,
|
|
9317
|
+
layoutSize: o,
|
|
9318
|
+
truncateToolMessages: !1,
|
|
9319
|
+
toolMessagePreviewLength: 200,
|
|
9320
|
+
onEdit: l,
|
|
9321
|
+
onRegenerate: () => u(P),
|
|
9322
|
+
onCancelEdit: d
|
|
9323
|
+
}
|
|
9324
|
+
)
|
|
9325
|
+
}
|
|
9326
|
+
);
|
|
9320
9327
|
}
|
|
9321
9328
|
}
|
|
9322
9329
|
) });
|
|
@@ -9690,7 +9697,7 @@ const ay = (e) => ({
|
|
|
9690
9697
|
}, w = Sa(o), x = ya(w), v = await i.getDimensions(u), p = w === "y", g = p ? "top" : "left", b = p ? "bottom" : "right", y = p ? "clientHeight" : "clientWidth", R = s.reference[x] + s.reference[w] - m[w] - s.floating[x], S = m[w] - s.reference[w], C = await (i.getOffsetParent == null ? void 0 : i.getOffsetParent(u));
|
|
9691
9698
|
let E = C ? C[y] : 0;
|
|
9692
9699
|
(!E || !await (i.isElement == null ? void 0 : i.isElement(C))) && (E = a.floating[y] || s.floating[x]);
|
|
9693
|
-
const N = R / 2 - S / 2, I = E / 2 - v[x] / 2 - 1, j = bn(h[g], I), P = bn(h[b], I),
|
|
9700
|
+
const N = R / 2 - S / 2, I = E / 2 - v[x] / 2 - 1, j = bn(h[g], I), P = bn(h[b], I), B = j, G = E - v[x] - P, _ = E / 2 - v[x] / 2 + N, Y = Ni(B, _, G), U = !l.arrow && mr(o) != null && _ !== Y && s.reference[x] / 2 - (_ < B ? j : P) - v[x] / 2 < 0, se = U ? _ < B ? _ - B : _ - G : 0;
|
|
9694
9701
|
return {
|
|
9695
9702
|
[w]: m[w] + se,
|
|
9696
9703
|
data: {
|
|
@@ -9739,7 +9746,7 @@ const ay = (e) => ({
|
|
|
9739
9746
|
placement: o,
|
|
9740
9747
|
overflows: I
|
|
9741
9748
|
}], !I.every((_) => _ <= 0)) {
|
|
9742
|
-
var P,
|
|
9749
|
+
var P, B;
|
|
9743
9750
|
const _ = (((P = s.flip) == null ? void 0 : P.index) || 0) + 1, Y = E[_];
|
|
9744
9751
|
if (Y && (!(h === "alignment" ? b !== en(Y) : !1) || // We leave the current main axis only if every placement on that axis
|
|
9745
9752
|
// overflows the main axis.
|
|
@@ -9753,7 +9760,7 @@ const ay = (e) => ({
|
|
|
9753
9760
|
placement: Y
|
|
9754
9761
|
}
|
|
9755
9762
|
};
|
|
9756
|
-
let U = (
|
|
9763
|
+
let U = (B = j.filter((se) => se.overflows[0] <= 0).sort((se, O) => se.overflows[1] - O.overflows[1])[0]) == null ? void 0 : B.placement;
|
|
9757
9764
|
if (!U)
|
|
9758
9765
|
switch (w) {
|
|
9759
9766
|
case "bestFit": {
|
|
@@ -10009,8 +10016,8 @@ const dy = function(e) {
|
|
|
10009
10016
|
const b = v - d.top - d.bottom, y = x - d.left - d.right, R = bn(v - d[p], b), S = bn(x - d[g], y), C = !t.middlewareData.shift;
|
|
10010
10017
|
let E = R, N = S;
|
|
10011
10018
|
if ((n = t.middlewareData.shift) != null && n.enabled.x && (N = y), (r = t.middlewareData.shift) != null && r.enabled.y && (E = b), C && !m) {
|
|
10012
|
-
const j = Rt(d.left, 0), P = Rt(d.right, 0),
|
|
10013
|
-
w ? N = x - 2 * (j !== 0 || P !== 0 ? j + P : Rt(d.left, d.right)) : E = v - 2 * (
|
|
10019
|
+
const j = Rt(d.left, 0), P = Rt(d.right, 0), B = Rt(d.top, 0), G = Rt(d.bottom, 0);
|
|
10020
|
+
w ? N = x - 2 * (j !== 0 || P !== 0 ? j + P : Rt(d.left, d.right)) : E = v - 2 * (B !== 0 || G !== 0 ? B + G : Rt(d.top, d.bottom));
|
|
10014
10021
|
}
|
|
10015
10022
|
await l({
|
|
10016
10023
|
...t,
|
|
@@ -10596,7 +10603,7 @@ function Xy(e) {
|
|
|
10596
10603
|
O !== C.current && (C.current = O, v(O));
|
|
10597
10604
|
}, []), y = f.useCallback((O) => {
|
|
10598
10605
|
O !== E.current && (E.current = O, g(O));
|
|
10599
|
-
}, []), R = s || x, S = i || p, C = f.useRef(null), E = f.useRef(null), N = f.useRef(d), I = l != null, j = si(l), P = si(o),
|
|
10606
|
+
}, []), R = s || x, S = i || p, C = f.useRef(null), E = f.useRef(null), N = f.useRef(d), I = l != null, j = si(l), P = si(o), B = si(u), G = f.useCallback(() => {
|
|
10600
10607
|
if (!C.current || !E.current)
|
|
10601
10608
|
return;
|
|
10602
10609
|
const O = {
|
|
@@ -10611,13 +10618,13 @@ function Xy(e) {
|
|
|
10611
10618
|
// but still mounted (such as when transitioning out). To ensure
|
|
10612
10619
|
// `isPositioned` will be `false` initially on the next open, avoid
|
|
10613
10620
|
// setting it to `true` when `open === false` (must be specified).
|
|
10614
|
-
isPositioned:
|
|
10621
|
+
isPositioned: B.current !== !1
|
|
10615
10622
|
};
|
|
10616
10623
|
_.current && !Go(N.current, K) && (N.current = K, Zo.flushSync(() => {
|
|
10617
10624
|
h(K);
|
|
10618
10625
|
}));
|
|
10619
10626
|
});
|
|
10620
|
-
}, [m, t, n, P,
|
|
10627
|
+
}, [m, t, n, P, B]);
|
|
10621
10628
|
jo(() => {
|
|
10622
10629
|
u === !1 && N.current.isPositioned && (N.current.isPositioned = !1, h((O) => ({
|
|
10623
10630
|
...O,
|
|
@@ -10770,7 +10777,7 @@ var Bd = "PopperAnchor", $d = f.forwardRef(
|
|
|
10770
10777
|
$d.displayName = Bd;
|
|
10771
10778
|
var Ia = "PopperContent", [c0, l0] = Dd(Ia), Hd = f.forwardRef(
|
|
10772
10779
|
(e, t) => {
|
|
10773
|
-
var
|
|
10780
|
+
var F, A, H, J, ce, ie;
|
|
10774
10781
|
const {
|
|
10775
10782
|
__scopePopper: n,
|
|
10776
10783
|
side: r = "bottom",
|
|
@@ -10786,11 +10793,11 @@ var Ia = "PopperContent", [c0, l0] = Dd(Ia), Hd = f.forwardRef(
|
|
|
10786
10793
|
updatePositionStrategy: w = "optimized",
|
|
10787
10794
|
onPlaced: x,
|
|
10788
10795
|
...v
|
|
10789
|
-
} = e, p = Ld(Ia, n), [g, b] = f.useState(null), y = Ee(t, (Ae) => b(Ae)), [R, S] = f.useState(null), C = Md(R), E = (C == null ? void 0 : C.width) ?? 0, N = (C == null ? void 0 : C.height) ?? 0, I = r + (s !== "center" ? "-" + s : ""), j = typeof d == "number" ? d : { top: 0, right: 0, bottom: 0, left: 0, ...d }, P = Array.isArray(u) ? u : [u],
|
|
10796
|
+
} = e, p = Ld(Ia, n), [g, b] = f.useState(null), y = Ee(t, (Ae) => b(Ae)), [R, S] = f.useState(null), C = Md(R), E = (C == null ? void 0 : C.width) ?? 0, N = (C == null ? void 0 : C.height) ?? 0, I = r + (s !== "center" ? "-" + s : ""), j = typeof d == "number" ? d : { top: 0, right: 0, bottom: 0, left: 0, ...d }, P = Array.isArray(u) ? u : [u], B = P.length > 0, G = {
|
|
10790
10797
|
padding: j,
|
|
10791
10798
|
boundary: P.filter(d0),
|
|
10792
10799
|
// with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
|
|
10793
|
-
altBoundary:
|
|
10800
|
+
altBoundary: B
|
|
10794
10801
|
}, { refs: _, floatingStyles: Y, placement: U, isPositioned: se, middlewareData: O } = Xy({
|
|
10795
10802
|
// default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
|
|
10796
10803
|
strategy: "fixed",
|
|
@@ -10825,7 +10832,7 @@ var Ia = "PopperContent", [c0, l0] = Dd(Ia), Hd = f.forwardRef(
|
|
|
10825
10832
|
st(() => {
|
|
10826
10833
|
se && (W == null || W());
|
|
10827
10834
|
}, [se, W]);
|
|
10828
|
-
const ee = (
|
|
10835
|
+
const ee = (F = O.arrow) == null ? void 0 : F.x, L = (A = O.arrow) == null ? void 0 : A.y, Z = ((H = O.arrow) == null ? void 0 : H.centerOffset) !== 0, [pe, he] = f.useState();
|
|
10829
10836
|
return st(() => {
|
|
10830
10837
|
g && he(window.getComputedStyle(g).zIndex);
|
|
10831
10838
|
}, [g]), /* @__PURE__ */ c.jsx(
|
|
@@ -11017,7 +11024,7 @@ var x0 = f.forwardRef((e, t) => {
|
|
|
11017
11024
|
if (N.target === N.currentTarget && I && !g) {
|
|
11018
11025
|
const j = new CustomEvent(ii, h0);
|
|
11019
11026
|
if (N.currentTarget.dispatchEvent(j), !j.defaultPrevented) {
|
|
11020
|
-
const P = R().filter((U) => U.focusable),
|
|
11027
|
+
const P = R().filter((U) => U.focusable), B = P.find((U) => U.active), G = P.find((U) => U.id === v), Y = [B, G, ...P].filter(
|
|
11021
11028
|
Boolean
|
|
11022
11029
|
).map((U) => U.ref.current);
|
|
11023
11030
|
Xd(Y, d);
|
|
@@ -11229,9 +11236,9 @@ var Mt = "MenuContent", [M0, Ma] = Un(Mt), rf = f.forwardRef(
|
|
|
11229
11236
|
onDismiss: w,
|
|
11230
11237
|
disableOutsideScroll: x,
|
|
11231
11238
|
...v
|
|
11232
|
-
} = e, p = Wn(Mt, n), g = no(Mt, n), b = Ss(n), y = Qd(n), R = j0(n), [S, C] = f.useState(null), E = f.useRef(null), N = Ee(t, E, p.onContentChange), I = f.useRef(0), j = f.useRef(""), P = f.useRef(0),
|
|
11233
|
-
var
|
|
11234
|
-
const K = j.current + M, W = R().filter((H) => !H.disabled), ee = document.activeElement, L = (
|
|
11239
|
+
} = e, p = Wn(Mt, n), g = no(Mt, n), b = Ss(n), y = Qd(n), R = j0(n), [S, C] = f.useState(null), E = f.useRef(null), N = Ee(t, E, p.onContentChange), I = f.useRef(0), j = f.useRef(""), P = f.useRef(0), B = f.useRef(null), G = f.useRef("right"), _ = f.useRef(0), Y = x ? hs : f.Fragment, U = x ? { as: F0, allowPinchZoom: !0 } : void 0, se = (M) => {
|
|
11240
|
+
var F, A;
|
|
11241
|
+
const K = j.current + M, W = R().filter((H) => !H.disabled), ee = document.activeElement, L = (F = W.find((H) => H.ref.current === ee)) == null ? void 0 : F.textValue, Z = W.map((H) => H.textValue), pe = X0(Z, K, L), he = (A = W.find((H) => H.textValue === pe)) == null ? void 0 : A.ref.current;
|
|
11235
11242
|
(function H(J) {
|
|
11236
11243
|
j.current = J, window.clearTimeout(I.current), J !== "" && (I.current = window.setTimeout(() => H(""), 1e3));
|
|
11237
11244
|
})(K), he && setTimeout(() => he.focus());
|
|
@@ -11239,7 +11246,7 @@ var Mt = "MenuContent", [M0, Ma] = Un(Mt), rf = f.forwardRef(
|
|
|
11239
11246
|
f.useEffect(() => () => window.clearTimeout(I.current), []), pa();
|
|
11240
11247
|
const O = f.useCallback((M) => {
|
|
11241
11248
|
var W, ee;
|
|
11242
|
-
return G.current === ((W =
|
|
11249
|
+
return G.current === ((W = B.current) == null ? void 0 : W.side) && Z0(M, (ee = B.current) == null ? void 0 : ee.area);
|
|
11243
11250
|
}, []);
|
|
11244
11251
|
return /* @__PURE__ */ c.jsx(
|
|
11245
11252
|
M0,
|
|
@@ -11267,7 +11274,7 @@ var Mt = "MenuContent", [M0, Ma] = Un(Mt), rf = f.forwardRef(
|
|
|
11267
11274
|
),
|
|
11268
11275
|
pointerGraceTimerRef: P,
|
|
11269
11276
|
onPointerGraceIntentChange: f.useCallback((M) => {
|
|
11270
|
-
|
|
11277
|
+
B.current = M;
|
|
11271
11278
|
}, []),
|
|
11272
11279
|
children: /* @__PURE__ */ c.jsx(Y, { ...U, children: /* @__PURE__ */ c.jsx(
|
|
11273
11280
|
us,
|
|
@@ -11321,7 +11328,7 @@ var Mt = "MenuContent", [M0, Ma] = Un(Mt), rf = f.forwardRef(
|
|
|
11321
11328
|
const Z = E.current;
|
|
11322
11329
|
if (M.target !== Z || !E0.includes(M.key)) return;
|
|
11323
11330
|
M.preventDefault();
|
|
11324
|
-
const he = R().filter((
|
|
11331
|
+
const he = R().filter((F) => !F.disabled).map((F) => F.ref.current);
|
|
11325
11332
|
Jd.includes(M.key) && he.reverse(), Y0(he);
|
|
11326
11333
|
}),
|
|
11327
11334
|
onBlur: Q(e.onBlur, (M) => {
|
|
@@ -12004,10 +12011,10 @@ function ko({
|
|
|
12004
12011
|
returnToLatest: I,
|
|
12005
12012
|
hasMoreHistory: j,
|
|
12006
12013
|
isLoadingHistory: P,
|
|
12007
|
-
loadOlderMessages:
|
|
12014
|
+
loadOlderMessages: B,
|
|
12008
12015
|
isPostStreamFetch: G,
|
|
12009
12016
|
api: _
|
|
12010
|
-
} = Yi(), [Y, U] = ue(null), [se, O] = ue(""), [M, K] = ue(null), [W, ee] = ue([]), [L, Z] = ue(!1), [pe, he] = ue(null), [
|
|
12017
|
+
} = Yi(), [Y, U] = ue(null), [se, O] = ue(""), [M, K] = ue(null), [W, ee] = ue([]), [L, Z] = ue(!1), [pe, he] = ue(null), [F, A] = ue(null), [H, J] = ue(!1), [ce, ie] = ue(null), [Ae, _e] = ue([]), [je, ae] = ue(null), [Ne, Se] = ue(null), [fe, Ce] = ue(!1), Be = Ke(null), ot = Ke(null), et = Ke(null), [xt, it] = ue("desktop");
|
|
12011
12018
|
Ze(() => {
|
|
12012
12019
|
const te = () => {
|
|
12013
12020
|
const le = window.innerWidth;
|
|
@@ -12049,11 +12056,11 @@ function ko({
|
|
|
12049
12056
|
const an = Ue(async () => {
|
|
12050
12057
|
if (!(!j || P))
|
|
12051
12058
|
try {
|
|
12052
|
-
await
|
|
12059
|
+
await B();
|
|
12053
12060
|
} catch (te) {
|
|
12054
12061
|
console.warn("loadOlderMessages failed", te);
|
|
12055
12062
|
}
|
|
12056
|
-
}, [j, P,
|
|
12063
|
+
}, [j, P, B]);
|
|
12057
12064
|
Ze(() => {
|
|
12058
12065
|
(async () => {
|
|
12059
12066
|
try {
|
|
@@ -12280,7 +12287,7 @@ function ko({
|
|
|
12280
12287
|
/* @__PURE__ */ c.jsx(Jp, { className: "h-4 w-4 animate-spin" }),
|
|
12281
12288
|
" Uploading Excel file..."
|
|
12282
12289
|
] }),
|
|
12283
|
-
|
|
12290
|
+
F && !L && /* @__PURE__ */ c.jsx("div", { className: "text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700", children: F }),
|
|
12284
12291
|
pe && !L && /* @__PURE__ */ c.jsx("div", { className: "text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600", children: pe })
|
|
12285
12292
|
] })
|
|
12286
12293
|
] }),
|
|
@@ -12923,7 +12930,7 @@ function Oi({
|
|
|
12923
12930
|
createThread: v,
|
|
12924
12931
|
deleteThread: p,
|
|
12925
12932
|
renameThread: g
|
|
12926
|
-
} = Yi(), [b, y] = ue(m ?? []), [R, S] = ue(!1), [C, E] = ue(null), [N, I] = ue(null), [j, P] = ue(""), [
|
|
12933
|
+
} = Yi(), [b, y] = ue(m ?? []), [R, S] = ue(!1), [C, E] = ue(null), [N, I] = ue(null), [j, P] = ue(""), [B, G] = ue(!1);
|
|
12927
12934
|
Ze(() => {
|
|
12928
12935
|
y(m ?? []);
|
|
12929
12936
|
}, [m]);
|
|
@@ -12966,8 +12973,8 @@ function Oi({
|
|
|
12966
12973
|
}, W = (L) => {
|
|
12967
12974
|
if (!L) return "";
|
|
12968
12975
|
try {
|
|
12969
|
-
const Z = new Date(L), he = (/* @__PURE__ */ new Date()).getTime() - Z.getTime(),
|
|
12970
|
-
return
|
|
12976
|
+
const Z = new Date(L), he = (/* @__PURE__ */ new Date()).getTime() - Z.getTime(), F = Math.floor(he / (1e3 * 60 * 60 * 24));
|
|
12977
|
+
return F === 0 ? Z.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) : F === 1 ? "Yesterday" : F < 7 ? `${F} days ago` : Z.toLocaleDateString();
|
|
12971
12978
|
} catch {
|
|
12972
12979
|
return "";
|
|
12973
12980
|
}
|
|
@@ -12977,11 +12984,11 @@ function Oi({
|
|
|
12977
12984
|
De,
|
|
12978
12985
|
{
|
|
12979
12986
|
onClick: Y,
|
|
12980
|
-
disabled:
|
|
12987
|
+
disabled: B || R,
|
|
12981
12988
|
className: s.createButton || "p-2",
|
|
12982
12989
|
size: "sm",
|
|
12983
12990
|
variant: "ghost",
|
|
12984
|
-
title:
|
|
12991
|
+
title: B ? "Creating..." : "New Chat",
|
|
12985
12992
|
children: /* @__PURE__ */ c.jsx(em, { size: 20 })
|
|
12986
12993
|
}
|
|
12987
12994
|
) }),
|
|
@@ -14343,7 +14350,7 @@ var cT = [" ", "Enter", "ArrowUp", "ArrowDown"], lT = [" ", "Enter"], Bn = "Sele
|
|
|
14343
14350
|
defaultProp: a,
|
|
14344
14351
|
onChange: l,
|
|
14345
14352
|
caller: Bn
|
|
14346
|
-
}), P = f.useRef(null),
|
|
14353
|
+
}), P = f.useRef(null), B = p ? x || !!p.closest("form") : !0, [G, _] = f.useState(/* @__PURE__ */ new Set()), Y = Array.from(G).map((U) => U.props.value).join(";");
|
|
14347
14354
|
return /* @__PURE__ */ c.jsx(ja, { ...v, children: /* @__PURE__ */ c.jsxs(
|
|
14348
14355
|
dT,
|
|
14349
14356
|
{
|
|
@@ -14380,7 +14387,7 @@ var cT = [" ", "Enter", "ArrowUp", "ArrowDown"], lT = [" ", "Enter"], Bn = "Sele
|
|
|
14380
14387
|
children: n
|
|
14381
14388
|
}
|
|
14382
14389
|
) }),
|
|
14383
|
-
|
|
14390
|
+
B ? /* @__PURE__ */ c.jsxs(
|
|
14384
14391
|
yp,
|
|
14385
14392
|
{
|
|
14386
14393
|
"aria-hidden": !0,
|
|
@@ -14512,19 +14519,19 @@ var Bt = 10, [sp, Rn] = xr($n), gT = "SelectContentImpl", vT = sr("SelectContent
|
|
|
14512
14519
|
avoidCollisions: p,
|
|
14513
14520
|
//
|
|
14514
14521
|
...g
|
|
14515
|
-
} = e, b = Tn($n, n), [y, R] = f.useState(null), [S, C] = f.useState(null), E = Ee(t, (
|
|
14522
|
+
} = e, b = Tn($n, n), [y, R] = f.useState(null), [S, C] = f.useState(null), E = Ee(t, (F) => R(F)), [N, I] = f.useState(null), [j, P] = f.useState(
|
|
14516
14523
|
null
|
|
14517
|
-
),
|
|
14524
|
+
), B = _s(n), [G, _] = f.useState(!1), Y = f.useRef(!1);
|
|
14518
14525
|
f.useEffect(() => {
|
|
14519
14526
|
if (y) return ma(y);
|
|
14520
14527
|
}, [y]), pa();
|
|
14521
14528
|
const U = f.useCallback(
|
|
14522
|
-
(
|
|
14523
|
-
const [A, ...H] =
|
|
14524
|
-
for (const ie of
|
|
14529
|
+
(F) => {
|
|
14530
|
+
const [A, ...H] = B().map((ie) => ie.ref.current), [J] = H.slice(-1), ce = document.activeElement;
|
|
14531
|
+
for (const ie of F)
|
|
14525
14532
|
if (ie === ce || (ie == null || ie.scrollIntoView({ block: "nearest" }), ie === A && S && (S.scrollTop = 0), ie === J && S && (S.scrollTop = S.scrollHeight), ie == null || ie.focus(), document.activeElement !== ce)) return;
|
|
14526
14533
|
},
|
|
14527
|
-
[
|
|
14534
|
+
[B, S]
|
|
14528
14535
|
), se = f.useCallback(
|
|
14529
14536
|
() => U([N, y]),
|
|
14530
14537
|
[U, N, y]
|
|
@@ -14535,39 +14542,39 @@ var Bt = 10, [sp, Rn] = xr($n), gT = "SelectContentImpl", vT = sr("SelectContent
|
|
|
14535
14542
|
const { onOpenChange: O, triggerPointerDownPosRef: M } = b;
|
|
14536
14543
|
f.useEffect(() => {
|
|
14537
14544
|
if (y) {
|
|
14538
|
-
let
|
|
14545
|
+
let F = { x: 0, y: 0 };
|
|
14539
14546
|
const A = (J) => {
|
|
14540
14547
|
var ce, ie;
|
|
14541
|
-
|
|
14548
|
+
F = {
|
|
14542
14549
|
x: Math.abs(Math.round(J.pageX) - (((ce = M.current) == null ? void 0 : ce.x) ?? 0)),
|
|
14543
14550
|
y: Math.abs(Math.round(J.pageY) - (((ie = M.current) == null ? void 0 : ie.y) ?? 0))
|
|
14544
14551
|
};
|
|
14545
14552
|
}, H = (J) => {
|
|
14546
|
-
|
|
14553
|
+
F.x <= 10 && F.y <= 10 ? J.preventDefault() : y.contains(J.target) || O(!1), document.removeEventListener("pointermove", A), M.current = null;
|
|
14547
14554
|
};
|
|
14548
14555
|
return M.current !== null && (document.addEventListener("pointermove", A), document.addEventListener("pointerup", H, { capture: !0, once: !0 })), () => {
|
|
14549
14556
|
document.removeEventListener("pointermove", A), document.removeEventListener("pointerup", H, { capture: !0 });
|
|
14550
14557
|
};
|
|
14551
14558
|
}
|
|
14552
14559
|
}, [y, O, M]), f.useEffect(() => {
|
|
14553
|
-
const
|
|
14554
|
-
return window.addEventListener("blur",
|
|
14555
|
-
window.removeEventListener("blur",
|
|
14560
|
+
const F = () => O(!1);
|
|
14561
|
+
return window.addEventListener("blur", F), window.addEventListener("resize", F), () => {
|
|
14562
|
+
window.removeEventListener("blur", F), window.removeEventListener("resize", F);
|
|
14556
14563
|
};
|
|
14557
14564
|
}, [O]);
|
|
14558
|
-
const [K, W] = Cp((
|
|
14559
|
-
const A =
|
|
14565
|
+
const [K, W] = Cp((F) => {
|
|
14566
|
+
const A = B().filter((ce) => !ce.disabled), H = A.find((ce) => ce.ref.current === document.activeElement), J = Tp(A, F, H);
|
|
14560
14567
|
J && setTimeout(() => J.ref.current.focus());
|
|
14561
14568
|
}), ee = f.useCallback(
|
|
14562
|
-
(
|
|
14569
|
+
(F, A, H) => {
|
|
14563
14570
|
const J = !Y.current && !H;
|
|
14564
|
-
(b.value !== void 0 && b.value === A || J) && (I(
|
|
14571
|
+
(b.value !== void 0 && b.value === A || J) && (I(F), J && (Y.current = !0));
|
|
14565
14572
|
},
|
|
14566
14573
|
[b.value]
|
|
14567
14574
|
), L = f.useCallback(() => y == null ? void 0 : y.focus(), [y]), Z = f.useCallback(
|
|
14568
|
-
(
|
|
14575
|
+
(F, A, H) => {
|
|
14569
14576
|
const J = !Y.current && !H;
|
|
14570
|
-
(b.value !== void 0 && b.value === A || J) && P(
|
|
14577
|
+
(b.value !== void 0 && b.value === A || J) && P(F);
|
|
14571
14578
|
},
|
|
14572
14579
|
[b.value]
|
|
14573
14580
|
), pe = r === "popper" ? Li : ap, he = pe === Li ? {
|
|
@@ -14603,12 +14610,12 @@ var Bt = 10, [sp, Rn] = xr($n), gT = "SelectContentImpl", vT = sr("SelectContent
|
|
|
14603
14610
|
{
|
|
14604
14611
|
asChild: !0,
|
|
14605
14612
|
trapped: b.open,
|
|
14606
|
-
onMountAutoFocus: (
|
|
14607
|
-
|
|
14613
|
+
onMountAutoFocus: (F) => {
|
|
14614
|
+
F.preventDefault();
|
|
14608
14615
|
},
|
|
14609
|
-
onUnmountAutoFocus: Q(o, (
|
|
14616
|
+
onUnmountAutoFocus: Q(o, (F) => {
|
|
14610
14617
|
var A;
|
|
14611
|
-
(A = b.trigger) == null || A.focus({ preventScroll: !0 }),
|
|
14618
|
+
(A = b.trigger) == null || A.focus({ preventScroll: !0 }), F.preventDefault();
|
|
14612
14619
|
}),
|
|
14613
14620
|
children: /* @__PURE__ */ c.jsx(
|
|
14614
14621
|
Zr,
|
|
@@ -14617,7 +14624,7 @@ var Bt = 10, [sp, Rn] = xr($n), gT = "SelectContentImpl", vT = sr("SelectContent
|
|
|
14617
14624
|
disableOutsidePointerEvents: !0,
|
|
14618
14625
|
onEscapeKeyDown: s,
|
|
14619
14626
|
onPointerDownOutside: i,
|
|
14620
|
-
onFocusOutside: (
|
|
14627
|
+
onFocusOutside: (F) => F.preventDefault(),
|
|
14621
14628
|
onDismiss: () => b.onOpenChange(!1),
|
|
14622
14629
|
children: /* @__PURE__ */ c.jsx(
|
|
14623
14630
|
pe,
|
|
@@ -14626,7 +14633,7 @@ var Bt = 10, [sp, Rn] = xr($n), gT = "SelectContentImpl", vT = sr("SelectContent
|
|
|
14626
14633
|
id: b.contentId,
|
|
14627
14634
|
"data-state": b.open ? "open" : "closed",
|
|
14628
14635
|
dir: b.dir,
|
|
14629
|
-
onContextMenu: (
|
|
14636
|
+
onContextMenu: (F) => F.preventDefault(),
|
|
14630
14637
|
...g,
|
|
14631
14638
|
...he,
|
|
14632
14639
|
onPlaced: () => _(!0),
|
|
@@ -14639,15 +14646,15 @@ var Bt = 10, [sp, Rn] = xr($n), gT = "SelectContentImpl", vT = sr("SelectContent
|
|
|
14639
14646
|
outline: "none",
|
|
14640
14647
|
...g.style
|
|
14641
14648
|
},
|
|
14642
|
-
onKeyDown: Q(g.onKeyDown, (
|
|
14643
|
-
const A =
|
|
14644
|
-
if (
|
|
14645
|
-
let J =
|
|
14646
|
-
if (["ArrowUp", "End"].includes(
|
|
14647
|
-
const ce =
|
|
14649
|
+
onKeyDown: Q(g.onKeyDown, (F) => {
|
|
14650
|
+
const A = F.ctrlKey || F.altKey || F.metaKey;
|
|
14651
|
+
if (F.key === "Tab" && F.preventDefault(), !A && F.key.length === 1 && W(F.key), ["ArrowUp", "ArrowDown", "Home", "End"].includes(F.key)) {
|
|
14652
|
+
let J = B().filter((ce) => !ce.disabled).map((ce) => ce.ref.current);
|
|
14653
|
+
if (["ArrowUp", "End"].includes(F.key) && (J = J.slice().reverse()), ["ArrowUp", "ArrowDown"].includes(F.key)) {
|
|
14654
|
+
const ce = F.target, ie = J.indexOf(ce);
|
|
14648
14655
|
J = J.slice(ie + 1);
|
|
14649
14656
|
}
|
|
14650
|
-
setTimeout(() => U(J)),
|
|
14657
|
+
setTimeout(() => U(J)), F.preventDefault();
|
|
14651
14658
|
}
|
|
14652
14659
|
})
|
|
14653
14660
|
}
|
|
@@ -14683,7 +14690,7 @@ var xT = "SelectItemAlignedPosition", ap = f.forwardRef((e, t) => {
|
|
|
14683
14690
|
]);
|
|
14684
14691
|
a.style.minWidth = _e + "px", a.style.right = Ne + "px";
|
|
14685
14692
|
}
|
|
14686
|
-
const P = m(),
|
|
14693
|
+
const P = m(), B = window.innerHeight - Bt * 2, G = v.scrollHeight, _ = window.getComputedStyle(u), Y = parseInt(_.borderTopWidth, 10), U = parseInt(_.paddingTop, 10), se = parseInt(_.borderBottomWidth, 10), O = parseInt(_.paddingBottom, 10), M = Y + U + G + O + se, K = Math.min(p.offsetHeight * 5, M), W = window.getComputedStyle(v), ee = parseInt(W.paddingTop, 10), L = parseInt(W.paddingBottom, 10), Z = E.top + E.height / 2 - Bt, pe = B - Z, he = p.offsetHeight / 2, F = p.offsetTop + he, A = Y + U + F, H = M - A;
|
|
14687
14694
|
if (A <= Z) {
|
|
14688
14695
|
const ce = P.length > 0 && p === P[P.length - 1].ref.current;
|
|
14689
14696
|
a.style.bottom = "0px";
|
|
@@ -14703,7 +14710,7 @@ var xT = "SelectItemAlignedPosition", ap = f.forwardRef((e, t) => {
|
|
|
14703
14710
|
) + H;
|
|
14704
14711
|
a.style.height = Ae + "px", v.scrollTop = A - Z + v.offsetTop;
|
|
14705
14712
|
}
|
|
14706
|
-
a.style.margin = `${Bt}px 0`, a.style.minHeight = K + "px", a.style.maxHeight =
|
|
14713
|
+
a.style.margin = `${Bt}px 0`, a.style.minHeight = K + "px", a.style.maxHeight = B + "px", r == null || r(), requestAnimationFrame(() => w.current = !0);
|
|
14707
14714
|
}
|
|
14708
14715
|
}, [
|
|
14709
14716
|
m,
|
package/dist/index.umd.js
CHANGED
|
@@ -80,7 +80,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
80
80
|
If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
81
81
|
|
|
82
82
|
For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return T.useEffect(()=>{t&&(document.getElementById(t)||console.error(n))},[n,t]),null},rI="DialogDescriptionWarning",aI=({contentRef:t,descriptionId:e})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${jm(rI).contentName}}.`;return T.useEffect(()=>{var i;const a=(i=t.current)==null?void 0:i.getAttribute("aria-describedby");e&&a&&(document.getElementById(e)||console.warn(r))},[r,t,e]),null},Xm=km,iI=Fm,Zm=Gm,li=Ym,ci=Hm,$n=Vm,di=$m,Jm=Km;const oI=Xm,sI=Zm,eg=T.forwardRef(({className:t,...e},n)=>u.jsx(li,{ref:n,className:j("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e}));eg.displayName=li.displayName;const tg=T.forwardRef(({className:t,children:e,...n},r)=>{const a=T.useMemo(()=>{let i=!1;function o(s){T.Children.forEach(s,l=>{if(i||!T.isValidElement(l))return;const c=l.type;if(c===$n||(c==null?void 0:c.displayName)===$n.displayName||(c==null?void 0:c.name)==="DialogTitle"){i=!0;return}l.props&&l.props.children&&o(l.props.children)})}return o(e),i},[e]);return u.jsxs(sI,{children:[u.jsx(eg,{}),u.jsxs(ci,{ref:r,className:j("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...n,children:[!a&&u.jsx($n,{className:"sr-only",children:"Dialog"}),e,u.jsxs(Jm,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[u.jsx(pe.X,{className:"h-4 w-4"}),u.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});tg.displayName=ci.displayName;const ng=({className:t,...e})=>u.jsx("div",{className:j("flex flex-col space-y-1.5 text-center sm:text-left",t),...e});ng.displayName="DialogHeader";const rg=T.forwardRef(({className:t,...e},n)=>u.jsx($n,{ref:n,className:j("text-lg font-semibold leading-none tracking-tight",t),...e}));rg.displayName=$n.displayName;const lI=T.forwardRef(({className:t,...e},n)=>u.jsx(di,{ref:n,className:j("text-sm text-muted-foreground",t),...e}));lI.displayName=di.displayName;function cI({isOpen:t,onClose:e,fileId:n,fileName:r,mimeType:a}){const[i,o]=y.useState(!1),[s,l]=y.useState(null),[c,d]=y.useState(null),{toast:_}=ns();y.useEffect(()=>{t&&n&&p()},[t,n]);const p=async()=>{if(n){o(!0),d(null),l(null);try{const S=await dm(n);l(S)}catch(S){console.error("Failed to load file:",S),d(S instanceof Error?S.message:"Failed to load file")}finally{o(!1)}}},m=async()=>{if(n)try{await qO(n),_({title:"Download started",description:`Downloading ${r}`})}catch(S){console.error("Failed to download file:",S),_({title:"Download failed",description:String(S),variant:"destructive"})}},E=async()=>{if(n)try{const S=await dm(n),b=new Blob([S],{type:a}),h=URL.createObjectURL(b);window.open(h,"_blank"),URL.revokeObjectURL(h)}catch(S){console.error("Failed to open file externally:",S),_({title:"Failed to open file",description:String(S),variant:"destructive"})}},f=()=>i?u.jsxs("div",{className:"flex items-center justify-center py-12",children:[u.jsx(pe.Loader,{className:"h-8 w-8 animate-spin mr-3"}),u.jsx("span",{children:"Loading file..."})]}):c?u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx("div",{className:"text-red-500 mb-4",children:"⚠️"}),u.jsx("p",{className:"text-red-600 mb-4",children:c}),u.jsx($e,{onClick:p,variant:"outline",children:"Try Again"})]}):s?a.startsWith("image/")?u.jsx("div",{className:"flex justify-center",children:u.jsx("img",{src:`data:${a};base64,${s}`,alt:r,className:"max-w-full max-h-[70vh] object-contain rounded-lg"})}):a==="application/pdf"?u.jsx("div",{className:"w-full h-[70vh] border rounded-lg overflow-hidden",children:u.jsx("iframe",{src:`data:application/pdf;base64,${s}`,className:"w-full h-full",title:r})}):a.startsWith("text/")||a.includes("json")||a.includes("xml")?u.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 max-h-[70vh] overflow-auto",children:u.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:s})}):u.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[u.jsx(pe.FileText,{className:"h-16 w-16 text-gray-400 mb-4"}),u.jsx("p",{className:"text-lg font-medium mb-2",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[a," • ",s.length," bytes"]}),u.jsx("p",{className:"text-sm text-muted-foreground",children:"This file type cannot be previewed. Use download or external view."})]}):u.jsx("div",{className:"flex items-center justify-center py-12",children:u.jsx("p",{className:"text-muted-foreground",children:"No content to display"})}),g=()=>a.startsWith("image/")?u.jsx(pe.Image,{className:"h-5 w-5"}):u.jsx(pe.FileText,{className:"h-5 w-5"});return u.jsx(oI,{open:t,onOpenChange:e,children:u.jsxs(tg,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[u.jsx(ng,{children:u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[g(),u.jsxs("div",{children:[u.jsx(rg,{className:"text-left",children:r}),u.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[a," • Click download or external view for full access"]})]})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs($e,{variant:"outline",size:"sm",onClick:E,className:"flex items-center gap-2",children:[u.jsx(pe.ExternalLink,{className:"h-4 w-4"}),"External"]}),u.jsxs($e,{variant:"outline",size:"sm",onClick:m,className:"flex items-center gap-2",children:[u.jsx(pe.Download,{className:"h-4 w-4"}),"Download"]})]})]})}),u.jsx("div",{className:"flex-1 overflow-hidden",children:f()})]})})}const ui="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";function dI({className:t}){const[e,n]=y.useState(0);return y.useEffect(()=>{const r=setInterval(()=>n(a=>(a+1)%4),500);return()=>clearInterval(r)},[]),u.jsxs("span",{"aria-live":"polite",className:j("inline-block text-xs opacity-70 ml-1",t),children:["Is thinking",".".repeat(e)]})}const ag=y.memo(function({message:e,messageIndex:n,isStreamingMessage:r=!1,streamingDebounceMs:a=16,isEditing:i=!1,showActions:o=!0,showTimestamp:s=!0,showAgentName:l=!0,layoutSize:c="desktop",truncateToolMessages:d=!0,toolMessagePreviewLength:_=200,truncateUserMessages:p=!0,userMessagePreviewLength:m=200,customStyles:E={},onEdit:f,onRegenerate:g,onCancelEdit:S,onCopy:b}){const[h,v]=y.useState(!1),[C,R]=y.useState(!1),[N,O]=y.useState(!1),[I,D]=y.useState(!1),{currentThreadId:M}=xa();ns();const[Y,K]=y.useState({}),[F,$]=y.useState(!1),[x,B]=y.useState(null),L=c==="phone"||c==="half-screen",U=e.role,z=U==="tool",W=y.useMemo(()=>{switch(U){case"user":return"text-[hsl(var(--chat-bubble-user-text))]";case"assistant":return"text-[hsl(var(--chat-bubble-ai-text))]";case"tool":return"text-secondary-foreground";case"system":return"text-muted-foreground";default:return"text-[hsl(var(--chat-bubble-ai-text))]"}},[U]),ne=y.useMemo(()=>uI(e.content),[e.content]),q=y.useMemo(()=>EI(e.content),[e.content]),X=y.useMemo(()=>e.content.filter(de=>de.type==="image_url"),[e.content]),se=y.useMemo(()=>e.content.filter(de=>de.type==="file"),[e.content]),ce=SI(ne,r);y.useEffect(()=>{r&&ne!==ce&&console.log("[MessageComponent] Streaming update:",{messageId:e.id,isStreamingMessage:r,textLength:ne.length,batchedLength:ce.length,textPreview:ne.slice(-50),batchedPreview:ce.slice(-50)})},[r,ne,ce,e.id]);const H=async()=>{try{const de=z?gr(e.content):ne;await navigator.clipboard.writeText(de),v(!0),setTimeout(()=>v(!1),2e3),b==null||b(de)}catch(de){console.error("Failed to copy:",de)}},P=()=>{if(!f)return;const de=z?gr(e.content):ne;f(e.id,de)},V=()=>g==null?void 0:g(n),Z=()=>{const Me=j(L?"h-3 w-3":"h-4 w-4","opacity-60 flex-shrink-0",W);switch(U){case"user":return u.jsx(pe.User,{className:Me});case"assistant":return u.jsx(pe.Bot,{className:Me});case"tool":return u.jsx(pe.Wrench,{className:Me});default:return u.jsx(pe.Bot,{className:Me})}},ie=()=>{const de="group relative mb-4 flex w-full";switch(U){case"user":return j(de,"justify-end");case"assistant":case"tool":case"system":return j(de,"justify-start");default:return de}},oe=()=>{const de=j("rounded-lg px-4 py-3 relative min-w-0 max-w-full break-words",L&&"px-3 py-2 text-sm");switch(U){case"user":return j(de,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-user))] text-[hsl(var(--chat-bubble-user-text))]","border border-transparent");case"assistant":return j(de,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40");case"tool":return j(de,"w-full md:max-w-[95%] bg-secondary/50 text-secondary-foreground border border-dashed");case"system":return j(de,"w-full md:max-w-[85%] bg-accent/40 text-muted-foreground border");default:return j(de,"w-full md:max-w-[95%]","bg-[hsl(var(--chat-bubble-ai))] text-[hsl(var(--chat-bubble-ai-text))]","border border-border/60 dark:border-border/40")}},Ne=de=>{if(!de)return"";try{return new Date(de).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}},Ue=()=>{if(!(ne.trim().length>0||X.length>0||se.length>0))return u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/30 rounded",children:[u.jsx(pe.Paperclip,{className:"h-4 w-4 text-muted-foreground"}),u.jsx("span",{className:"text-sm text-muted-foreground",children:"File upload"})]});if(e.model==="reflection"){const Se=ne.trim(),Te=fs(Se);if(Te&&typeof Te=="object")return u.jsx(bI,{data:Te})}if(z&&q.name==="get_issues"){const Se=e.content.find(et=>et.type==="tool_result"),Te=(Se==null?void 0:Se.output)??gr(e.content),be=sg(Te);if(be)return u.jsx(TI,{issues:be})}if(z&&!N){const Se=gr(e.content).slice(0,80).replace(/\s+/g," ");return u.jsx("div",{className:j("text-xs font-mono opacity-70 flex items-center justify-between gap-2 text-current",L&&"text-[10px]"),children:u.jsxs("span",{className:"truncate max-w-full text-current",children:[Se,Se.length>=80?"…":""]})})}if(z&&d){const Se=gr(e.content),Te=Se.length>_;return u.jsx(rm,{open:C,onOpenChange:R,children:u.jsxs("div",{className:"font-mono text-sm text-current",children:[u.jsx("pre",{className:j("whitespace-pre-wrap break-words text-current",L&&"text-xs"),children:Te&&!C?Se.substring(0,_)+"...":Se}),Te&&u.jsx(am,{asChild:!0,children:u.jsx($e,{variant:"ghost",size:"sm",className:"h-6 text-xs text-current",children:C?u.jsxs(u.Fragment,{children:[u.jsx(pe.ChevronUp,{className:"h-3 w-3 mr-1"}),"Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(pe.ChevronDown,{className:"h-3 w-3 mr-1"}),"Show more (",Se.length-_," chars)"]})})})]})})}if(z&&N&&!d){const Se=hI(e.content);if(Se&&_I(Se))return u.jsx(Wa,{content:Se.trim(),hideFallbackDuringStreaming:!0});const Te=gr(e.content);return u.jsx("div",{className:"font-mono text-sm text-current",children:u.jsx("pre",{className:j("whitespace-pre-wrap break-words text-current",L&&"text-xs"),children:Te})})}const Me=X.length>0&&U!=="tool",ae=se.length>0&&U!=="tool"&&!1;return u.jsxs("div",{children:[r?u.jsxs("div",{className:j("relative transition-all duration-200 ease-out",L?"text-xs":"text-sm"),style:{minHeight:80},children:[(()=>{const Se=fs(ce);if(Se!==null)return u.jsx(ig,{data:Se});const Te=mI(pI(ce)),be=ce.trim().length===0;return u.jsx(u.Fragment,{children:be?u.jsx("div",{className:"w-full",children:u.jsxs("div",{className:"animate-pulse space-y-2",children:[u.jsx("div",{className:"h-3 bg-slate-200 dark:bg-slate-700 rounded w-3/4"}),u.jsx("div",{className:"h-3 bg-slate-200 dark:bg-slate-700 rounded w-5/6"}),u.jsx("div",{className:"h-3 bg-slate-200 dark:bg-slate-700 rounded w-2/3"})]})}):u.jsx("pre",{className:j("whitespace-pre-wrap break-words font-sans leading-relaxed transition-opacity duration-200",L&&"text-xs"),children:Te})})})(),u.jsx("div",{className:"mt-2",children:u.jsx(dI,{className:j(W,L?"text-xs":"text-sm")})})]}):(()=>{const Se=fs(ne.trim());if(Se!==null)return u.jsx(ig,{data:Se});if(U==="user"&&p){const Te=ne.trim();if(Te.length>m)return u.jsxs(rm,{open:I,onOpenChange:D,children:[u.jsx("div",{className:j("text-sm text-[hsl(var(--chat-bubble-user-text))]",L&&"text-xs"),children:I?u.jsx(Wa,{content:Te,hideFallbackDuringStreaming:!0}):u.jsxs("pre",{className:j("font-sans whitespace-pre-wrap break-words bg-transparent p-0 m-0 text-[hsl(var(--chat-bubble-user-text))]",L&&"text-xs"),children:[Te.substring(0,m),"..."]})}),u.jsx(am,{asChild:!0,children:u.jsx($e,{variant:"ghost",size:"sm",className:"h-6 text-xs !text-[hsl(var(--chat-bubble-user-text))]",children:I?u.jsxs(u.Fragment,{children:[u.jsx(pe.ChevronUp,{className:"h-3 w-3 mr-1"})," Show less"]}):u.jsxs(u.Fragment,{children:[u.jsx(pe.ChevronDown,{className:"h-3 w-3 mr-1"})," Show more (",Te.length-m," chars)"]})})})]})}return u.jsx(Wa,{content:ne.trim(),isStreaming:r,hideFallbackDuringStreaming:!0,streamingThrottleMs:a,useWorker:!r})})(),Me&&u.jsx("div",{className:"mt-2 grid grid-cols-2 gap-2",children:X.map((Se,Te)=>{const be=Se,et=typeof be.width=="number"?be.width:void 0,We=typeof be.height=="number"?be.height:void 0,lt=et&&We&&We>0?`${et} / ${We}`:"4 / 3",Je=et&&We&&We>0?Math.max(120,Math.round(We/et*140)):160;return u.jsxs("div",{className:"relative border rounded overflow-hidden bg-gray-100 dark:bg-gray-900/40",style:{aspectRatio:lt,minHeight:Je},"data-placeholder-height":Je,children:[u.jsx("img",{src:be.url,alt:be.alt??"image",loading:"lazy",className:"absolute inset-0 h-full w-full object-contain"}),u.jsxs("div",{className:"absolute top-1 right-1 bg-background/70 rounded px-1 py-0.5 text-[10px] flex items-center gap-1",children:[u.jsx(pe.Image,{className:"h-3 w-3"}),u.jsx("span",{children:"image"})]})]},Te)})}),ae]})},Oe=y.useMemo(()=>fI(e),[e]);return u.jsxs(u.Fragment,{children:[u.jsx("div",{className:j(ie(),E.container),children:u.jsxs("div",{className:j(oe(),E.content),children:[(s||l||z)&&u.jsxs("div",{className:j("flex items-center justify-between mb-2 pb-2 border-b border-current/10",L&&"mb-1 pb-1",W,E.header),children:[u.jsxs("div",{className:"flex items-center gap-2",children:[Z(),l&&Oe&&u.jsx("span",{className:j("font-medium",L?"text-xs":"text-sm"),children:Oe}),z&&q.name&&u.jsxs(Xp,{variant:"outline",className:j("text-xs flex items-center gap-1 cursor-pointer",W,"border border-current/40",L&&"text-xs h-4"),onClick:()=>O(de=>!de),children:[u.jsx("span",{children:q.name}),u.jsx("span",{className:"inline-flex items-center",children:N?u.jsx(pe.ChevronUp,{className:"h-3 w-3"}):u.jsx(pe.ChevronDown,{className:"h-3 w-3"})})]}),z&&!q.name&&u.jsx($e,{variant:"ghost",size:"sm",className:j("h-6 px-1",W,"hover:bg-foreground/10"),onClick:()=>O(de=>!de),children:u.jsxs("span",{className:"text-xs flex items-center gap-1",children:["Tool Output ",N?u.jsx(pe.ChevronUp,{className:"h-3 w-3"}):u.jsx(pe.ChevronDown,{className:"h-3 w-3"})]})})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[s&&u.jsx("span",{className:j("text-xs opacity-60",W,L&&"text-xs"),children:Ne(e.createdAt)}),o&&!i&&u.jsxs("div",{className:j("opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",E.actions),children:[u.jsx($e,{variant:"ghost",size:"sm",onClick:H,className:j("h-6 w-6 p-0 hover:bg-foreground/10",W,L&&"h-5 w-5"),children:u.jsx(pe.Copy,{className:j(h?"text-success":W,L?"h-3 w-3":"h-4 w-4")})}),U==="user"&&f&&u.jsx($e,{variant:"ghost",size:"sm",onClick:P,className:j("h-6 w-6 p-0 hover:bg-foreground/10",W,L&&"h-5 w-5"),children:u.jsx(pe.Edit,{className:j(W,L?"h-3 w-3":"h-4 w-4")})}),U==="assistant"&&g&&u.jsx($e,{variant:"ghost",size:"sm",onClick:V,className:j("h-6 w-6 p-0 hover:bg-foreground/10",W,L&&"h-5 w-5"),children:u.jsx(pe.RotateCcw,{className:j(W,L?"h-3 w-3":"h-4 w-4")})})]})]})]}),u.jsx("div",{className:"relative",children:Ue()}),z&&N&&(q.toolCallId||q.name)&&u.jsxs("div",{className:j("mt-2 pt-2 border-t border-current/10 text-xs opacity-60",L&&"text-xs"),children:[q.name&&u.jsxs("div",{children:["Function: ",q.name]}),q.toolCallId&&u.jsxs("div",{children:["Call ID: ",q.toolCallId]})]}),!(s||l||z)&&o&&!i&&u.jsxs("div",{className:j("absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity","flex items-center gap-1",E.actions),children:[u.jsx($e,{variant:"ghost",size:"sm",onClick:H,className:j("h-6 w-6 p-0 hover:bg-background/50 text-current",L&&"h-5 w-5"),children:u.jsx(pe.Copy,{className:j(h?"text-success":"text-current",L?"h-3 w-3":"h-4 w-4")})}),U==="user"&&f&&u.jsx($e,{variant:"ghost",size:"sm",onClick:P,className:j("h-6 w-6 p-0 hover:bg-background/50 text-current",L&&"h-5 w-5"),children:u.jsx(pe.Edit,{className:j("text-current",L?"h-3 w-3":"h-4 w-4")})}),U==="assistant"&&g&&u.jsx($e,{variant:"ghost",size:"sm",onClick:V,className:j("h-6 w-6 p-0 hover:bg-background/50 text-current",L&&"h-5 w-5"),children:u.jsx(pe.RotateCcw,{className:j("text-current",L?"h-3 w-3":"h-4 w-4")})})]})]})}),x&&u.jsx(cI,{isOpen:F,onClose:()=>{$(!1),B(null)},fileId:x.id,fileName:x.name,mimeType:x.mimeType})]})},(t,e)=>e.isStreamingMessage?!1:t.message.id===e.message.id&&t.message.content===e.message.content&&t.isStreamingMessage===e.isStreamingMessage&&t.isEditing===e.isEditing);function uI(t){const e=t.filter(n=>n.type==="text").map(n=>n.text).join("");return e||JSON.stringify(t)}function _I(t){return t.includes(`
|
|
83
|
-
`)||t.includes("```")||/[-*] /.test(t)||/#+\s/.test(t)}function pI(t){let e=t;try{(e.match(/```/g)||[]).length%2===1&&(e+="\n```"),(e.replace(/```[\s\S]*?```/g,"").match(new RegExp("(?<!`)`(?!`)","g"))||[]).length%2===1&&(e+="`")}catch{}return e}function mI(t){let e=t;try{const n=[],r=[],a="\0F",i="\0I";let o=e.replace(/```[\s\S]*?```/g,s=>(n.push(s),`${a}${n.length-1}\0`));o=o.replace(/`[^`]*`/g,s=>(r.push(s),`${i}${r.length-1}\0`)),o=o.replace(/\b([A-Za-z0-9_&\/-]+)\b(\s+\1\b)+/g,"$1").replace(/\b([A-Za-z0-9_&\/-]+\s+[A-Za-z0-9_&\/-]+)\b(\s+\1\b)+/g,"$1").replace(/([\.,;:!\?\-])\1+/g,"$1").replace(/([:;!\?\)])([A-Za-z])/g,"$1 $2").replace(/\s{3,}/g," "),o=o.replace(/\u0000F(\d+)\u0000/g,(s,l)=>n[Number(l)]??""),o=o.replace(/\u0000I(\d+)\u0000/g,(s,l)=>r[Number(l)]??""),e=o}catch{}return e}function fs(t){const e=t==null?void 0:t.trim();if(!e||!(e.startsWith("{")||e.startsWith("[")))return null;try{return JSON.parse(e)}catch{return null}}function ig({data:t}){if(Array.isArray(t))return t.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:ui,children:u.jsx("ul",{className:"list-disc pl-5",children:t.map((n,r)=>u.jsx("li",{children:String(n)},r))})}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Zr(t)});if(t&&typeof t=="object"){const e=Array.isArray(t.distilled_facts)?t.distilled_facts:null,n=Array.isArray(t.follow_up_queries)?t.follow_up_queries:null,r=typeof t.is_sufficient=="boolean"?t.is_sufficient:void 0;if(e||n||typeof r=="boolean")return u.jsxs("div",{className:ui,children:[typeof r=="boolean"&&u.jsxs("p",{children:[u.jsx("strong",{children:"Is sufficient:"})," ",r?"Yes":"No"]}),n&&n.length>0&&u.jsxs("div",{children:[u.jsx("p",{children:u.jsx("strong",{children:"Follow-up queries:"})}),u.jsx("ul",{className:"list-disc pl-5",children:n.map((i,o)=>u.jsx("li",{children:String(i)},o))})]}),e&&e.length>0&&u.jsxs("div",{children:[u.jsx("p",{children:u.jsx("strong",{children:"Facts:"})}),u.jsx("ul",{className:"list-disc pl-5",children:e.map((i,o)=>u.jsx("li",{children:String(i)},o))})]})]});const a=Object.entries(t);return u.jsx("div",{className:ui,children:u.jsx("dl",{className:"mt-0",children:a.map(([i,o])=>u.jsxs("div",{className:"mb-1",children:[u.jsxs("dt",{className:"inline font-medium mr-1",children:[i,":"]}),u.jsx("dd",{className:"inline",children:gI(o)})]},i))})})}return u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Zr(t)})}function gI(t){if(t==null)return String(t);const e=typeof t;if(e==="string"||e==="number"||e==="boolean")return String(t);if(Array.isArray(t)&&t.every(r=>r===null||["string","number","boolean"].includes(typeof r)))return t.join(", ");try{return u.jsx("code",{className:"text-xs",children:JSON.stringify(_i(t))})}catch{return String(t)}}function og(t){return!!(t&&typeof t=="object"&&(t.type==="file"||t.mimeType||t.filename||t.sourceType==="base64"))}function _i(t){if(typeof t=="string")return t.length>2e3?t.slice(0,2e3)+"... [truncated]":t;if(t&&typeof t=="object"){if(Array.isArray(t)){const n=t.map(_i).filter(r=>r!==void 0);return n.length?n:void 0}if(og(t))return;const e={};for(const n of Object.keys(t)){const r=t[n];if(n==="data"&&typeof r=="string"&&r.length>100)e[n]=`[base64 ${r.length} chars omitted]`;else{const a=_i(r);a!==void 0&&(e[n]=a)}}return Object.keys(e).length?e:void 0}return t}function Zr(t){if(typeof t=="string")return t;if(og(t))return"";try{const e=_i(t);return e===void 0?"":typeof e=="string"?e:JSON.stringify(e,null,2)}catch{return""}}function EI(t){const e=t.find(r=>r.type==="tool_call"),n=t.find(r=>r.type==="tool_result");return{name:e==null?void 0:e.name,toolCallId:(n==null?void 0:n.toolCallId)??(e==null?void 0:e.id)}}function fI(t){return t.name&&t.name.trim()?t.name:t.model&&t.model.includes("/")?t.model.split("/").pop()||null:t.model||null}function SI(t,e){const[n,r]=y.useState(t),a=y.useRef(t),i=y.useRef(null);return y.useEffect(()=>{if(!e){r(t);return}return a.current=t,i.current===null&&(i.current=requestAnimationFrame(()=>{i.current=null,r(a.current)})),()=>{i.current&&cancelAnimationFrame(i.current)}},[t,e]),n}function bI({data:t}){return u.jsx("dl",{className:"grid grid-cols-1 gap-y-2",children:Object.entries(t).map(([e,n])=>u.jsxs("div",{className:"flex",children:[u.jsxs("dt",{className:"font-semibold mr-2",children:[e,":"]}),u.jsx("dd",{className:"flex-1 break-words",children:Array.isArray(n)?n.map((r,a)=>u.jsxs("div",{className:"ml-4 break-words",children:["- ",String(r)]},a)):String(n)})]},e))})}function sg(t){if(!t)return null;if(typeof t=="object"&&!Array.isArray(t)){if(t.desirability||t.feasibility||t.viability||t.other)return{desirability:Array.isArray(t.desirability)?t.desirability:[],feasibility:Array.isArray(t.feasibility)?t.feasibility:[],viability:Array.isArray(t.viability)?t.viability:[],other:Array.isArray(t.other)?t.other:[]};if(t.output&&typeof t.output!="object")t=t.output;else if(t.output&&typeof t.output=="object")return sg(t.output)}const e=String(t),n={desirability:[],feasibility:[],viability:[],other:[]};let r=e;const a=Math.min(...["desirability=","feasibility=","viability=","other="].map(o=>{const s=r.toLowerCase().indexOf(o);return s===-1?Number.MAX_SAFE_INTEGER:s}));a!==Number.MAX_SAFE_INTEGER&&(r=r.slice(a));for(const o of Object.keys(n)){const l=new RegExp(o+"\\s*=\\s*\\[([\\s\\S]*?)\\]","i").exec(r);if(!l)continue;const c=l[1],d=/Issue\(([\s\S]*?)\)(?:,|$)/g;let _=null;for(;(_=d.exec(c))!==null;){const p=_[1],m=/title\s*=\s*(['"])([\s\S]*?)\1/.exec(p),E=/description\s*=\s*(['"])([\s\S]*?)\1/.exec(p),f=m?m[2].trim():"",g=E?E[2].trim():"";n[o].push({title:f,description:g})}}return Object.values(n).some(o=>o.length>0)?n:null}function TI({issues:t}){const e=[{key:"desirability",title:"Desirability"},{key:"feasibility",title:"Feasibility"},{key:"viability",title:"Viability"},{key:"other",title:"Other"}];return u.jsx("div",{className:ui,children:e.map(n=>{const r=t[n.key];return!r||!r.length?null:u.jsxs("div",{className:"mb-4",children:[u.jsxs("h4",{className:"font-semibold mb-2",children:[n.title," (",r.length,")"]}),u.jsx("ol",{className:"list-decimal pl-5 space-y-2",children:r.map((a,i)=>u.jsxs("li",{children:[u.jsx("div",{className:"font-medium",children:a.title}),u.jsx("div",{className:"text-sm text-muted-foreground",children:a.description})]},i))})]},n.key)})})}function gr(t){const e=t.filter(n=>n.type==="tool_result");if(e.length)try{return e.length===1?Zr(e[0].output):Zr(e.map(n=>({toolCallId:n.toolCallId,output:n.output})))}catch{}return Zr(t)}function hI(t){const e=t.find(r=>r.type==="tool_result");if(!e)return null;const n=e.output;return typeof n=="string"?n:null}const lg=(t,e)=>(t==null?void 0:t.id)??`message-${e}`,Ss=y.forwardRef(({messages:t,isStreaming:e,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:a,enableMessageEditing:i,editingMessageId:o,onStartReached:s,onEdit:l,onRegenerate:c,onCancelEdit:d,className:_,style:p,emptyMessage:m,followNewMessages:E=!0,isNavigatingCheckpoint:f=!1,onScrollAway:g,onAtBottom:S},b)=>{const h=y.useRef(null),v=y.useRef(null),C=y.useRef(!1),[R,N]=y.useState(!0),O=y.useCallback(M=>{N(M),g&&g(!M),S&&S(M)},[g,S]),I=y.useMemo(()=>{if(s)return async()=>{if(!C.current){C.current=!0;try{await s()}finally{C.current=!1}}}},[s]),D=y.useMemo(()=>!E||f?!1:e&&R?"
|
|
83
|
+
`)||t.includes("```")||/[-*] /.test(t)||/#+\s/.test(t)}function pI(t){let e=t;try{(e.match(/```/g)||[]).length%2===1&&(e+="\n```"),(e.replace(/```[\s\S]*?```/g,"").match(new RegExp("(?<!`)`(?!`)","g"))||[]).length%2===1&&(e+="`")}catch{}return e}function mI(t){let e=t;try{const n=[],r=[],a="\0F",i="\0I";let o=e.replace(/```[\s\S]*?```/g,s=>(n.push(s),`${a}${n.length-1}\0`));o=o.replace(/`[^`]*`/g,s=>(r.push(s),`${i}${r.length-1}\0`)),o=o.replace(/\b([A-Za-z0-9_&\/-]+)\b(\s+\1\b)+/g,"$1").replace(/\b([A-Za-z0-9_&\/-]+\s+[A-Za-z0-9_&\/-]+)\b(\s+\1\b)+/g,"$1").replace(/([\.,;:!\?\-])\1+/g,"$1").replace(/([:;!\?\)])([A-Za-z])/g,"$1 $2").replace(/\s{3,}/g," "),o=o.replace(/\u0000F(\d+)\u0000/g,(s,l)=>n[Number(l)]??""),o=o.replace(/\u0000I(\d+)\u0000/g,(s,l)=>r[Number(l)]??""),e=o}catch{}return e}function fs(t){const e=t==null?void 0:t.trim();if(!e||!(e.startsWith("{")||e.startsWith("[")))return null;try{return JSON.parse(e)}catch{return null}}function ig({data:t}){if(Array.isArray(t))return t.every(n=>n===null||["string","number","boolean"].includes(typeof n))?u.jsx("div",{className:ui,children:u.jsx("ul",{className:"list-disc pl-5",children:t.map((n,r)=>u.jsx("li",{children:String(n)},r))})}):u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Zr(t)});if(t&&typeof t=="object"){const e=Array.isArray(t.distilled_facts)?t.distilled_facts:null,n=Array.isArray(t.follow_up_queries)?t.follow_up_queries:null,r=typeof t.is_sufficient=="boolean"?t.is_sufficient:void 0;if(e||n||typeof r=="boolean")return u.jsxs("div",{className:ui,children:[typeof r=="boolean"&&u.jsxs("p",{children:[u.jsx("strong",{children:"Is sufficient:"})," ",r?"Yes":"No"]}),n&&n.length>0&&u.jsxs("div",{children:[u.jsx("p",{children:u.jsx("strong",{children:"Follow-up queries:"})}),u.jsx("ul",{className:"list-disc pl-5",children:n.map((i,o)=>u.jsx("li",{children:String(i)},o))})]}),e&&e.length>0&&u.jsxs("div",{children:[u.jsx("p",{children:u.jsx("strong",{children:"Facts:"})}),u.jsx("ul",{className:"list-disc pl-5",children:e.map((i,o)=>u.jsx("li",{children:String(i)},o))})]})]});const a=Object.entries(t);return u.jsx("div",{className:ui,children:u.jsx("dl",{className:"mt-0",children:a.map(([i,o])=>u.jsxs("div",{className:"mb-1",children:[u.jsxs("dt",{className:"inline font-medium mr-1",children:[i,":"]}),u.jsx("dd",{className:"inline",children:gI(o)})]},i))})})}return u.jsx("pre",{className:"font-mono text-xs bg-background/50 rounded border p-2 whitespace-pre-wrap break-words",children:Zr(t)})}function gI(t){if(t==null)return String(t);const e=typeof t;if(e==="string"||e==="number"||e==="boolean")return String(t);if(Array.isArray(t)&&t.every(r=>r===null||["string","number","boolean"].includes(typeof r)))return t.join(", ");try{return u.jsx("code",{className:"text-xs",children:JSON.stringify(_i(t))})}catch{return String(t)}}function og(t){return!!(t&&typeof t=="object"&&(t.type==="file"||t.mimeType||t.filename||t.sourceType==="base64"))}function _i(t){if(typeof t=="string")return t.length>2e3?t.slice(0,2e3)+"... [truncated]":t;if(t&&typeof t=="object"){if(Array.isArray(t)){const n=t.map(_i).filter(r=>r!==void 0);return n.length?n:void 0}if(og(t))return;const e={};for(const n of Object.keys(t)){const r=t[n];if(n==="data"&&typeof r=="string"&&r.length>100)e[n]=`[base64 ${r.length} chars omitted]`;else{const a=_i(r);a!==void 0&&(e[n]=a)}}return Object.keys(e).length?e:void 0}return t}function Zr(t){if(typeof t=="string")return t;if(og(t))return"";try{const e=_i(t);return e===void 0?"":typeof e=="string"?e:JSON.stringify(e,null,2)}catch{return""}}function EI(t){const e=t.find(r=>r.type==="tool_call"),n=t.find(r=>r.type==="tool_result");return{name:e==null?void 0:e.name,toolCallId:(n==null?void 0:n.toolCallId)??(e==null?void 0:e.id)}}function fI(t){return t.name&&t.name.trim()?t.name:t.model&&t.model.includes("/")?t.model.split("/").pop()||null:t.model||null}function SI(t,e){const[n,r]=y.useState(t),a=y.useRef(t),i=y.useRef(null);return y.useEffect(()=>{if(!e){r(t);return}return a.current=t,i.current===null&&(i.current=requestAnimationFrame(()=>{i.current=null,r(a.current)})),()=>{i.current&&cancelAnimationFrame(i.current)}},[t,e]),n}function bI({data:t}){return u.jsx("dl",{className:"grid grid-cols-1 gap-y-2",children:Object.entries(t).map(([e,n])=>u.jsxs("div",{className:"flex",children:[u.jsxs("dt",{className:"font-semibold mr-2",children:[e,":"]}),u.jsx("dd",{className:"flex-1 break-words",children:Array.isArray(n)?n.map((r,a)=>u.jsxs("div",{className:"ml-4 break-words",children:["- ",String(r)]},a)):String(n)})]},e))})}function sg(t){if(!t)return null;if(typeof t=="object"&&!Array.isArray(t)){if(t.desirability||t.feasibility||t.viability||t.other)return{desirability:Array.isArray(t.desirability)?t.desirability:[],feasibility:Array.isArray(t.feasibility)?t.feasibility:[],viability:Array.isArray(t.viability)?t.viability:[],other:Array.isArray(t.other)?t.other:[]};if(t.output&&typeof t.output!="object")t=t.output;else if(t.output&&typeof t.output=="object")return sg(t.output)}const e=String(t),n={desirability:[],feasibility:[],viability:[],other:[]};let r=e;const a=Math.min(...["desirability=","feasibility=","viability=","other="].map(o=>{const s=r.toLowerCase().indexOf(o);return s===-1?Number.MAX_SAFE_INTEGER:s}));a!==Number.MAX_SAFE_INTEGER&&(r=r.slice(a));for(const o of Object.keys(n)){const l=new RegExp(o+"\\s*=\\s*\\[([\\s\\S]*?)\\]","i").exec(r);if(!l)continue;const c=l[1],d=/Issue\(([\s\S]*?)\)(?:,|$)/g;let _=null;for(;(_=d.exec(c))!==null;){const p=_[1],m=/title\s*=\s*(['"])([\s\S]*?)\1/.exec(p),E=/description\s*=\s*(['"])([\s\S]*?)\1/.exec(p),f=m?m[2].trim():"",g=E?E[2].trim():"";n[o].push({title:f,description:g})}}return Object.values(n).some(o=>o.length>0)?n:null}function TI({issues:t}){const e=[{key:"desirability",title:"Desirability"},{key:"feasibility",title:"Feasibility"},{key:"viability",title:"Viability"},{key:"other",title:"Other"}];return u.jsx("div",{className:ui,children:e.map(n=>{const r=t[n.key];return!r||!r.length?null:u.jsxs("div",{className:"mb-4",children:[u.jsxs("h4",{className:"font-semibold mb-2",children:[n.title," (",r.length,")"]}),u.jsx("ol",{className:"list-decimal pl-5 space-y-2",children:r.map((a,i)=>u.jsxs("li",{children:[u.jsx("div",{className:"font-medium",children:a.title}),u.jsx("div",{className:"text-sm text-muted-foreground",children:a.description})]},i))})]},n.key)})})}function gr(t){const e=t.filter(n=>n.type==="tool_result");if(e.length)try{return e.length===1?Zr(e[0].output):Zr(e.map(n=>({toolCallId:n.toolCallId,output:n.output})))}catch{}return Zr(t)}function hI(t){const e=t.find(r=>r.type==="tool_result");if(!e)return null;const n=e.output;return typeof n=="string"?n:null}const lg=(t,e)=>(t==null?void 0:t.id)??`message-${e}`,Ss=y.forwardRef(({messages:t,isStreaming:e,streamingAssistantId:n,streamingDebounceMs:r,layoutSize:a,enableMessageEditing:i,editingMessageId:o,onStartReached:s,onEdit:l,onRegenerate:c,onCancelEdit:d,className:_,style:p,emptyMessage:m,followNewMessages:E=!0,isNavigatingCheckpoint:f=!1,onScrollAway:g,onAtBottom:S},b)=>{const h=y.useRef(null),v=y.useRef(null),C=y.useRef(!1),[R,N]=y.useState(!0),O=y.useCallback(M=>{N(M),g&&g(!M),S&&S(M)},[g,S]),I=y.useMemo(()=>{if(s)return async()=>{if(!C.current){C.current=!0;try{await s()}finally{C.current=!1}}}},[s]),D=y.useMemo(()=>!E||f?!1:e&&R?"auto":!1,[e,R,E,f]);return t.length===0?u.jsx("div",{className:_,style:p,children:u.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground text-center max-w-md mx-auto",children:m||"No messages yet. Start a conversation!"})}):u.jsx("div",{className:_,style:p,children:u.jsx(nO,{ref:M=>{h.current=M},scrollerRef:M=>{v.current=M instanceof HTMLDivElement?M:null},data:t,followOutput:D,overscan:400,increaseViewportBy:{top:200,bottom:400},defaultItemHeight:120,atBottomThreshold:100,alignToBottom:!0,startReached:()=>{I&&I()},atBottomStateChange:O,style:{height:"100%",overscrollBehavior:"contain"},computeItemKey:(M,Y)=>lg(Y,M),itemContent:(M,Y)=>{const K=lg(Y,M);return u.jsx("div",{className:"mb-4 last:mb-0","data-message-id":K,style:{contentVisibility:"auto"},children:u.jsx(ag,{message:Y,messageIndex:M,isStreamingMessage:e&&n===Y.id,streamingDebounceMs:r,isEditing:o===Y.id,showActions:i,showTimestamp:!1,showAgentName:!0,layoutSize:a,truncateToolMessages:!1,toolMessagePreviewLength:200,onEdit:l,onRegenerate:()=>c(M),onCancelEdit:d})})}})})});Ss.displayName="MessageList";const pi=1e4;function CI(t){if(typeof t!="string")return String(t);const e=[/<script[^>]*>.*?<\/script>/gi,/<iframe[^>]*>.*?<\/iframe>/gi,/javascript:/gi,/vbscript:/gi,/on\w+\s*=/gi,/<object[^>]*>.*?<\/object>/gi,/<embed[^>]*>.*?<\/embed>/gi,/<form[^>]*>.*?<\/form>/gi];let n=t;for(const a of e)n=n.replace(a,"");return/<[^>]+>/.test(n)&&!/<(?!\/?(?:code|strong|em|b|i|br|p|ul|ol|li|h[1-6])\b)[^>]+>/i.test(n)?n.replace(/<code>(.*?)<\/code>/gi,"`$1`").replace(/<strong>(.*?)<\/strong>/gi,"**$1**").replace(/<b>(.*?)<\/b>/gi,"**$1**").replace(/<em>(.*?)<\/em>/gi,"*$1*").replace(/<i>(.*?)<\/i>/gi,"*$1*").replace(/<br\s*\/?>/gi,`
|
|
84
84
|
`).replace(/<p>(.*?)<\/p>/gi,`$1
|
|
85
85
|
|
|
86
86
|
`).replace(/<h([1-6])>(.*?)<\/h[1-6]>/gi,(a,i,o)=>`${"#".repeat(parseInt(i))} ${o}
|
package/package.json
CHANGED