@object-ui/plugin-chatbot 5.4.0 → 5.4.2
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/CHANGELOG.md +18 -0
- package/dist/index.js +664 -609
- package/dist/index.umd.cjs +2 -2
- package/dist/packages/plugin-chatbot/src/ChatbotEnhanced.d.ts +29 -0
- package/dist/packages/plugin-chatbot/src/ChatbotEnhanced.d.ts.map +1 -1
- package/dist/packages/plugin-chatbot/src/index.d.ts +3 -0
- package/dist/packages/plugin-chatbot/src/index.d.ts.map +1 -1
- package/dist/packages/plugin-chatbot/src/mapMessages.d.ts +45 -0
- package/dist/packages/plugin-chatbot/src/mapMessages.d.ts.map +1 -0
- package/dist/packages/plugin-chatbot/src/useObjectChat.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1,38 +1,85 @@
|
|
|
1
1
|
import * as e from "react";
|
|
2
2
|
import { Children as t, Fragment as n, createContext as r, isValidElement as i, memo as a, useCallback as o, useContext as s, useEffect as c, useMemo as l, useRef as u, useState as d } from "react";
|
|
3
|
-
import { Avatar as f, AvatarFallback as p, AvatarImage as m, Badge as h, Button as g, Collapsible as _, CollapsibleContent as v, CollapsibleTrigger as y, Command as b, CommandEmpty as x, CommandGroup as S, CommandInput as C, CommandItem as w, CommandList as T, CommandSeparator as E, DropdownMenu as D, DropdownMenuContent as O, DropdownMenuItem as k, DropdownMenuTrigger as A, HoverCard as j, HoverCardContent as M, HoverCardTrigger as N, Input as
|
|
4
|
-
import { AlertCircle as
|
|
5
|
-
import { Fragment as
|
|
6
|
-
import { useChat as
|
|
7
|
-
import { DefaultChatTransport as
|
|
8
|
-
import * as
|
|
9
|
-
import { useObjectTranslation as
|
|
10
|
-
import { StickToBottom as
|
|
11
|
-
import { cva as
|
|
12
|
-
import { Slot as
|
|
13
|
-
import { Streamdown as
|
|
14
|
-
import { nanoid as
|
|
15
|
-
import { codeToHtml as
|
|
16
|
-
import { useControllableState as
|
|
17
|
-
import { motion as
|
|
18
|
-
import { ComponentRegistry as
|
|
3
|
+
import { Avatar as f, AvatarFallback as p, AvatarImage as m, Badge as h, Button as g, Collapsible as _, CollapsibleContent as v, CollapsibleTrigger as y, Command as b, CommandEmpty as x, CommandGroup as S, CommandInput as C, CommandItem as w, CommandList as T, CommandSeparator as E, DropdownMenu as D, DropdownMenuContent as O, DropdownMenuItem as k, DropdownMenuTrigger as A, HoverCard as j, HoverCardContent as M, HoverCardTrigger as N, Input as P, ScrollArea as F, ScrollBar as I, Select as ee, SelectContent as te, SelectItem as ne, SelectTrigger as re, SelectValue as ie, Textarea as ae, Tooltip as oe, TooltipContent as se, TooltipProvider as ce, TooltipTrigger as le, cn as L } from "@object-ui/components";
|
|
4
|
+
import { AlertCircle as ue, ArrowDownIcon as de, BookIcon as fe, BrainIcon as pe, Check as me, CheckCircleIcon as he, CheckIcon as ge, ChevronDownIcon as R, ChevronLeftIcon as _e, ChevronRightIcon as ve, CircleIcon as ye, ClockIcon as be, Copy as xe, CopyIcon as Se, CornerDownLeftIcon as Ce, ImageIcon as we, Loader2Icon as Te, Maximize2 as Ee, MessageCircle as De, MicIcon as Oe, Minimize2 as ke, PaperclipIcon as Ae, PlusIcon as je, RefreshCw as Me, Send as Ne, SquareIcon as Pe, WrenchIcon as Fe, X as Ie, XCircleIcon as Le, XIcon as z } from "lucide-react";
|
|
5
|
+
import { Fragment as B, jsx as V, jsxs as H } from "react/jsx-runtime";
|
|
6
|
+
import { useChat as Re } from "@ai-sdk/react";
|
|
7
|
+
import { DefaultChatTransport as ze } from "ai";
|
|
8
|
+
import * as Be from "react-dom";
|
|
9
|
+
import { useObjectTranslation as Ve } from "@object-ui/react";
|
|
10
|
+
import { StickToBottom as He, useStickToBottomContext as Ue } from "use-stick-to-bottom";
|
|
11
|
+
import { cva as U } from "class-variance-authority";
|
|
12
|
+
import { Slot as We } from "@radix-ui/react-slot";
|
|
13
|
+
import { Streamdown as Ge } from "streamdown";
|
|
14
|
+
import { nanoid as Ke } from "nanoid";
|
|
15
|
+
import { codeToHtml as qe } from "shiki";
|
|
16
|
+
import { useControllableState as Je } from "@radix-ui/react-use-controllable-state";
|
|
17
|
+
import { motion as Ye } from "motion/react";
|
|
18
|
+
import { ComponentRegistry as W } from "@object-ui/core";
|
|
19
19
|
//#region \0rolldown/runtime.js
|
|
20
|
-
var
|
|
20
|
+
var Xe = Object.defineProperty, Ze = (e, t) => {
|
|
21
21
|
let n = {};
|
|
22
|
-
for (var r in e)
|
|
22
|
+
for (var r in e) Xe(n, r, {
|
|
23
23
|
get: e[r],
|
|
24
24
|
enumerable: !0
|
|
25
25
|
});
|
|
26
|
-
return t ||
|
|
26
|
+
return t || Xe(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
27
27
|
};
|
|
28
28
|
//#endregion
|
|
29
29
|
//#region src/utils.ts
|
|
30
|
-
function
|
|
30
|
+
function G(e = "msg") {
|
|
31
31
|
return typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${e}-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
32
32
|
}
|
|
33
33
|
//#endregion
|
|
34
|
-
//#region src/
|
|
34
|
+
//#region src/mapMessages.ts
|
|
35
|
+
function Qe(e, t) {
|
|
36
|
+
return typeof e.content == "string" ? e.content : t.filter((e) => e.type === "text").map((e) => e.text ?? "").join("");
|
|
37
|
+
}
|
|
35
38
|
function $e(e) {
|
|
39
|
+
let t = e.filter((e) => e.type === "reasoning" || e.type === "reasoning-delta").map((e) => e.text ?? "").join("\n").trim();
|
|
40
|
+
return t.length > 0 ? t : void 0;
|
|
41
|
+
}
|
|
42
|
+
function et(e) {
|
|
43
|
+
return e.filter((e) => e.type === "dynamic-tool" ? !0 : typeof e.type == "string" && e.type.startsWith("tool-")).map((e) => {
|
|
44
|
+
let t = e.type === "dynamic-tool" ? e.toolName ?? "tool" : typeof e.type == "string" ? e.type.replace(/^tool-/, "") : "tool";
|
|
45
|
+
return {
|
|
46
|
+
toolCallId: e.toolCallId ?? e.id ?? `${e.type ?? "tool"}-${Math.random().toString(36).slice(2, 8)}`,
|
|
47
|
+
toolName: t,
|
|
48
|
+
args: e.input ?? e.args,
|
|
49
|
+
result: e.output ?? e.result,
|
|
50
|
+
errorText: e.errorText,
|
|
51
|
+
state: e.state
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
function tt(e) {
|
|
56
|
+
let t = e.filter((e) => e.type === "source-url" || e.type === "source").map((e) => ({
|
|
57
|
+
id: e.id,
|
|
58
|
+
title: e.title,
|
|
59
|
+
url: e.url ?? e.href
|
|
60
|
+
})).filter((e) => !!e.url);
|
|
61
|
+
return t.length > 0 ? t : void 0;
|
|
62
|
+
}
|
|
63
|
+
function nt(e, t = {}) {
|
|
64
|
+
let n = Array.isArray(e.parts) ? e.parts : [], r = et(n), i = Array.isArray(e.toolInvocations) ? e.toolInvocations : [];
|
|
65
|
+
return {
|
|
66
|
+
id: e.id ?? `msg-${Math.random().toString(36).slice(2, 8)}`,
|
|
67
|
+
role: e.role ?? "assistant",
|
|
68
|
+
content: Qe(e, n),
|
|
69
|
+
reasoning: $e(n),
|
|
70
|
+
toolInvocations: r.length > 0 ? r : i,
|
|
71
|
+
sources: tt(n),
|
|
72
|
+
streaming: t.streaming
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function rt(e, t = {}) {
|
|
76
|
+
if (!Array.isArray(e) || e.length === 0) return [];
|
|
77
|
+
let n = e.length - 1;
|
|
78
|
+
return e.map((e, r) => nt(e, { streaming: !!t.isStreaming && r === n && e.role === "assistant" }));
|
|
79
|
+
}
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/useObjectChat.ts
|
|
82
|
+
function it(e) {
|
|
36
83
|
return (e ?? []).map((e, t) => ({
|
|
37
84
|
id: e.id || `msg-${t}`,
|
|
38
85
|
role: e.role || "user",
|
|
@@ -43,17 +90,17 @@ function $e(e) {
|
|
|
43
90
|
toolInvocations: e.toolInvocations
|
|
44
91
|
}));
|
|
45
92
|
}
|
|
46
|
-
function
|
|
47
|
-
let { api: t, initialMessages: n, conversationId: r, systemPrompt: i, model: a, streamingEnabled: s = !0, headers: f, body: p, maxToolRoundtrips: m = 5, onError: h, showTimestamp: g, autoResponse: _, autoResponseText: v, autoResponseDelay: y = 1e3, onSend: b } = e, x = u(t ? "api" : "local").current === "api", S = l(() =>
|
|
93
|
+
function K(e = {}) {
|
|
94
|
+
let { api: t, initialMessages: n, conversationId: r, systemPrompt: i, model: a, streamingEnabled: s = !0, headers: f, body: p, maxToolRoundtrips: m = 5, onError: h, showTimestamp: g, autoResponse: _, autoResponseText: v, autoResponseDelay: y = 1e3, onSend: b } = e, x = u(t ? "api" : "local").current === "api", S = l(() => it(n).map((e) => ({
|
|
48
95
|
id: e.id,
|
|
49
96
|
role: e.role,
|
|
50
97
|
parts: [{
|
|
51
98
|
type: "text",
|
|
52
99
|
text: e.content ?? ""
|
|
53
100
|
}]
|
|
54
|
-
})), []), C =
|
|
101
|
+
})), []), C = Re({
|
|
55
102
|
transport: l(() => {
|
|
56
|
-
if (x) return new
|
|
103
|
+
if (x) return new ze({
|
|
57
104
|
api: t,
|
|
58
105
|
headers: { ...f },
|
|
59
106
|
body: {
|
|
@@ -78,34 +125,14 @@ function G(e = {}) {
|
|
|
78
125
|
onError: x ? (e) => {
|
|
79
126
|
h?.(e);
|
|
80
127
|
} : void 0
|
|
81
|
-
}), [w, T] = d(() =>
|
|
128
|
+
}), [w, T] = d(() => it(n)), [E, D] = d(!1), [O, k] = d(""), [A, j] = d(""), M = u(null);
|
|
82
129
|
if (c(() => () => {
|
|
83
130
|
M.current &&= (clearTimeout(M.current), null);
|
|
84
131
|
}, []), x) {
|
|
85
|
-
let { messages: e, status: t, error: n, sendMessage: r, regenerate: i, stop: a, setMessages: s } = C, c = t === "submitted" || t === "streaming", l = e.map((t) => {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
args: e.input ?? e.args,
|
|
90
|
-
result: e.output ?? e.result,
|
|
91
|
-
errorText: e.errorText,
|
|
92
|
-
state: e.state
|
|
93
|
-
})), o = n.filter((e) => e?.type === "source-url" || e?.type === "source").map((e) => ({
|
|
94
|
-
id: e.id,
|
|
95
|
-
title: e.title,
|
|
96
|
-
url: e.url ?? e.href
|
|
97
|
-
})).filter((e) => !!e.url), s = Array.isArray(t.toolInvocations) ? t.toolInvocations : [];
|
|
98
|
-
return {
|
|
99
|
-
id: t.id,
|
|
100
|
-
role: t.role,
|
|
101
|
-
content: r,
|
|
102
|
-
toolInvocations: a.length > 0 ? a : s,
|
|
103
|
-
reasoning: i,
|
|
104
|
-
sources: o.length > 0 ? o : void 0,
|
|
105
|
-
metadata: t.metadata,
|
|
106
|
-
streaming: c && t.id === e[e.length - 1]?.id && t.role === "assistant"
|
|
107
|
-
};
|
|
108
|
-
});
|
|
132
|
+
let { messages: e, status: t, error: n, sendMessage: r, regenerate: i, stop: a, setMessages: s } = C, c = t === "submitted" || t === "streaming", l = rt(e, { isStreaming: c }).map((t, n) => ({
|
|
133
|
+
...t,
|
|
134
|
+
metadata: e[n]?.metadata
|
|
135
|
+
}));
|
|
109
136
|
return {
|
|
110
137
|
messages: l,
|
|
111
138
|
isLoading: c,
|
|
@@ -114,7 +141,7 @@ function G(e = {}) {
|
|
|
114
141
|
let t = e.trim();
|
|
115
142
|
if (!t) return;
|
|
116
143
|
let n = [...l, {
|
|
117
|
-
id:
|
|
144
|
+
id: G("msg"),
|
|
118
145
|
role: "user",
|
|
119
146
|
content: t
|
|
120
147
|
}];
|
|
@@ -147,7 +174,7 @@ function G(e = {}) {
|
|
|
147
174
|
sendMessage: o((e) => {
|
|
148
175
|
if (!e.trim()) return;
|
|
149
176
|
let t = {
|
|
150
|
-
id:
|
|
177
|
+
id: G("msg"),
|
|
151
178
|
role: "user",
|
|
152
179
|
content: e.trim(),
|
|
153
180
|
timestamp: g ? (/* @__PURE__ */ new Date()).toLocaleTimeString() : void 0
|
|
@@ -157,7 +184,7 @@ function G(e = {}) {
|
|
|
157
184
|
return b?.(e.trim(), r), r;
|
|
158
185
|
}), k(""), _ && (D(!0), M.current = setTimeout(() => {
|
|
159
186
|
let e = {
|
|
160
|
-
id:
|
|
187
|
+
id: G("msg"),
|
|
161
188
|
role: "assistant",
|
|
162
189
|
content: v || "Thank you for your message!",
|
|
163
190
|
timestamp: g ? (/* @__PURE__ */ new Date()).toLocaleTimeString() : void 0
|
|
@@ -186,7 +213,7 @@ function G(e = {}) {
|
|
|
186
213
|
}
|
|
187
214
|
//#endregion
|
|
188
215
|
//#region src/useAgents.ts
|
|
189
|
-
function
|
|
216
|
+
function at(e) {
|
|
190
217
|
return e.filter((e) => typeof e?.name == "string" && e.name.length > 0).map((e) => ({
|
|
191
218
|
name: e.name,
|
|
192
219
|
label: e.label || e.name,
|
|
@@ -195,7 +222,7 @@ function et(e) {
|
|
|
195
222
|
active: e.active !== !1
|
|
196
223
|
}));
|
|
197
224
|
}
|
|
198
|
-
function
|
|
225
|
+
function ot(e = {}) {
|
|
199
226
|
let { apiBase: t, headers: n, enabled: r = !0, fallback: i = [] } = e, [a, s] = d(i), [l, f] = d(!1), [p, m] = d(void 0), [h, g] = d(0), _ = u(n);
|
|
200
227
|
return _.current = n, c(() => {
|
|
201
228
|
if (!r || !t) return;
|
|
@@ -215,7 +242,7 @@ function tt(e = {}) {
|
|
|
215
242
|
return e.json();
|
|
216
243
|
}).then((e) => {
|
|
217
244
|
if (n) return;
|
|
218
|
-
let t =
|
|
245
|
+
let t = at(Array.isArray(e) ? e : e?.agents ?? []);
|
|
219
246
|
s(t.length > 0 ? t : i);
|
|
220
247
|
}).catch((e) => {
|
|
221
248
|
n || e.name === "AbortError" || (m(e), s(i));
|
|
@@ -237,8 +264,8 @@ function tt(e = {}) {
|
|
|
237
264
|
}
|
|
238
265
|
//#endregion
|
|
239
266
|
//#region src/FloatingChatbotProvider.tsx
|
|
240
|
-
var
|
|
241
|
-
function
|
|
267
|
+
var st = e.createContext(null);
|
|
268
|
+
function ct({ defaultOpen: t = !1, children: n }) {
|
|
242
269
|
let [r, i] = e.useState(t), [a, o] = e.useState(!1), s = e.useMemo(() => ({
|
|
243
270
|
isOpen: r,
|
|
244
271
|
isFullscreen: a,
|
|
@@ -249,21 +276,21 @@ function rt({ defaultOpen: t = !1, children: n }) {
|
|
|
249
276
|
toggle: () => i((e) => !e),
|
|
250
277
|
toggleFullscreen: () => o((e) => !e)
|
|
251
278
|
}), [r, a]);
|
|
252
|
-
return /* @__PURE__ */
|
|
279
|
+
return /* @__PURE__ */ V(st.Provider, {
|
|
253
280
|
value: s,
|
|
254
281
|
children: n
|
|
255
282
|
});
|
|
256
283
|
}
|
|
257
|
-
function
|
|
258
|
-
let t = e.useContext(
|
|
284
|
+
function q() {
|
|
285
|
+
let t = e.useContext(st);
|
|
259
286
|
if (!t) throw Error("useFloatingChatbot must be used within a <FloatingChatbotProvider>");
|
|
260
287
|
return t;
|
|
261
288
|
}
|
|
262
289
|
//#endregion
|
|
263
290
|
//#region src/FloatingChatbotTrigger.tsx
|
|
264
|
-
function
|
|
291
|
+
function lt() {
|
|
265
292
|
try {
|
|
266
|
-
let { t: e } =
|
|
293
|
+
let { t: e } = Ve();
|
|
267
294
|
return (t, n) => {
|
|
268
295
|
let r = e(`common.${t}`);
|
|
269
296
|
return !r || r === `common.${t}` ? n : r;
|
|
@@ -272,11 +299,11 @@ function it() {
|
|
|
272
299
|
return (e, t) => t;
|
|
273
300
|
}
|
|
274
301
|
}
|
|
275
|
-
function
|
|
276
|
-
let { isOpen: r, toggle: i } =
|
|
277
|
-
return /* @__PURE__ */
|
|
302
|
+
function ut({ position: e = "bottom-right", size: t = 56, className: n }) {
|
|
303
|
+
let { isOpen: r, toggle: i } = q(), a = lt();
|
|
304
|
+
return /* @__PURE__ */ V(g, {
|
|
278
305
|
onClick: i,
|
|
279
|
-
className:
|
|
306
|
+
className: L("fixed z-50 rounded-full shadow-lg transition-transform hover:scale-105", e === "bottom-right" ? "right-6 bottom-20 sm:bottom-6" : "left-6 bottom-20 sm:bottom-6", n),
|
|
280
307
|
style: {
|
|
281
308
|
width: t,
|
|
282
309
|
height: t
|
|
@@ -284,13 +311,13 @@ function at({ position: e = "bottom-right", size: t = 56, className: n }) {
|
|
|
284
311
|
size: "icon",
|
|
285
312
|
"aria-label": r ? a("closeChat", "Close chat") : a("openChat", "Open chat"),
|
|
286
313
|
"data-testid": "floating-chatbot-trigger",
|
|
287
|
-
children:
|
|
314
|
+
children: V(r ? Ie : De, { className: "h-6 w-6" })
|
|
288
315
|
});
|
|
289
316
|
}
|
|
290
317
|
//#endregion
|
|
291
318
|
//#region src/FloatingChatbotPanel.tsx
|
|
292
|
-
function
|
|
293
|
-
let { isOpen: s, isFullscreen: c, close: l, toggleFullscreen: u } =
|
|
319
|
+
function dt({ title: e = "Chat", position: t = "bottom-right", width: n = 400, height: r = 520, children: i, className: a, headerExtra: o }) {
|
|
320
|
+
let { isOpen: s, isFullscreen: c, close: l, toggleFullscreen: u } = q();
|
|
294
321
|
if (!s) return null;
|
|
295
322
|
let d = c ? {
|
|
296
323
|
inset: 0,
|
|
@@ -301,46 +328,46 @@ function ot({ title: e = "Chat", position: t = "bottom-right", width: n = 400, h
|
|
|
301
328
|
height: r,
|
|
302
329
|
maxHeight: "calc(100vh - 100px)"
|
|
303
330
|
};
|
|
304
|
-
return /* @__PURE__ */
|
|
305
|
-
className:
|
|
331
|
+
return /* @__PURE__ */ H("div", {
|
|
332
|
+
className: L("fixed z-50 flex flex-col rounded-lg border bg-background shadow-xl overflow-hidden transition-all", c ? "inset-0 rounded-none" : t === "bottom-right" ? "right-6 bottom-20" : "left-6 bottom-20", a),
|
|
306
333
|
style: d,
|
|
307
334
|
role: "dialog",
|
|
308
335
|
"aria-label": e,
|
|
309
336
|
"data-testid": "floating-chatbot-panel",
|
|
310
|
-
children: [/* @__PURE__ */
|
|
337
|
+
children: [/* @__PURE__ */ H("div", {
|
|
311
338
|
className: "flex items-center justify-between gap-2 px-4 py-2 border-b bg-muted/40",
|
|
312
339
|
children: [
|
|
313
|
-
/* @__PURE__ */
|
|
340
|
+
/* @__PURE__ */ V("span", {
|
|
314
341
|
className: "text-sm font-medium truncate shrink-0",
|
|
315
342
|
children: e
|
|
316
343
|
}),
|
|
317
|
-
o ? /* @__PURE__ */
|
|
344
|
+
o ? /* @__PURE__ */ V("div", {
|
|
318
345
|
className: "flex-1 min-w-0 flex items-center justify-end mr-1",
|
|
319
346
|
"data-testid": "floating-chatbot-header-extra",
|
|
320
347
|
children: o
|
|
321
348
|
}) : null,
|
|
322
|
-
/* @__PURE__ */
|
|
349
|
+
/* @__PURE__ */ H("div", {
|
|
323
350
|
className: "flex items-center gap-1 shrink-0",
|
|
324
|
-
children: [/* @__PURE__ */
|
|
351
|
+
children: [/* @__PURE__ */ V(g, {
|
|
325
352
|
variant: "ghost",
|
|
326
353
|
size: "icon",
|
|
327
354
|
className: "h-7 w-7",
|
|
328
355
|
onClick: u,
|
|
329
356
|
"aria-label": c ? "Exit fullscreen" : "Fullscreen",
|
|
330
357
|
"data-testid": "floating-chatbot-fullscreen",
|
|
331
|
-
children:
|
|
332
|
-
}), /* @__PURE__ */
|
|
358
|
+
children: V(c ? ke : Ee, { className: "h-4 w-4" })
|
|
359
|
+
}), /* @__PURE__ */ V(g, {
|
|
333
360
|
variant: "ghost",
|
|
334
361
|
size: "icon",
|
|
335
362
|
className: "h-7 w-7",
|
|
336
363
|
onClick: l,
|
|
337
364
|
"aria-label": "Close chat",
|
|
338
365
|
"data-testid": "floating-chatbot-close",
|
|
339
|
-
children: /* @__PURE__ */
|
|
366
|
+
children: /* @__PURE__ */ V(Ie, { className: "h-4 w-4" })
|
|
340
367
|
})]
|
|
341
368
|
})
|
|
342
369
|
]
|
|
343
|
-
}), /* @__PURE__ */
|
|
370
|
+
}), /* @__PURE__ */ V("div", {
|
|
344
371
|
className: "flex-1 overflow-hidden",
|
|
345
372
|
children: i
|
|
346
373
|
})]
|
|
@@ -348,99 +375,99 @@ function ot({ title: e = "Chat", position: t = "bottom-right", width: n = 400, h
|
|
|
348
375
|
}
|
|
349
376
|
//#endregion
|
|
350
377
|
//#region src/elements/conversation.tsx
|
|
351
|
-
var
|
|
352
|
-
className:
|
|
378
|
+
var ft = ({ className: e, ...t }) => /* @__PURE__ */ V(He, {
|
|
379
|
+
className: L("relative flex-1 overflow-y-hidden", e),
|
|
353
380
|
initial: "smooth",
|
|
354
381
|
resize: "smooth",
|
|
355
382
|
role: "log",
|
|
356
383
|
...t
|
|
357
|
-
}),
|
|
358
|
-
className:
|
|
384
|
+
}), pt = ({ className: e, ...t }) => /* @__PURE__ */ V(He.Content, {
|
|
385
|
+
className: L("flex flex-col gap-8 p-4", e),
|
|
359
386
|
...t
|
|
360
|
-
}),
|
|
361
|
-
className:
|
|
387
|
+
}), mt = ({ className: e, title: t = "No messages yet", description: n = "Start a conversation to see messages here", icon: r, children: i, ...a }) => /* @__PURE__ */ V("div", {
|
|
388
|
+
className: L("flex size-full flex-col items-center justify-center gap-3 p-8 text-center", e),
|
|
362
389
|
...a,
|
|
363
|
-
children: i ?? /* @__PURE__ */
|
|
390
|
+
children: i ?? /* @__PURE__ */ H(B, { children: [r && /* @__PURE__ */ V("div", {
|
|
364
391
|
className: "text-muted-foreground",
|
|
365
392
|
children: r
|
|
366
|
-
}), /* @__PURE__ */
|
|
393
|
+
}), /* @__PURE__ */ H("div", {
|
|
367
394
|
className: "space-y-1",
|
|
368
|
-
children: [/* @__PURE__ */
|
|
395
|
+
children: [/* @__PURE__ */ V("h3", {
|
|
369
396
|
className: "font-medium text-sm",
|
|
370
397
|
children: t
|
|
371
|
-
}), n && /* @__PURE__ */
|
|
398
|
+
}), n && /* @__PURE__ */ V("p", {
|
|
372
399
|
className: "text-muted-foreground text-sm",
|
|
373
400
|
children: n
|
|
374
401
|
})]
|
|
375
402
|
})] })
|
|
376
|
-
}),
|
|
377
|
-
let { isAtBottom: n, scrollToBottom: r } =
|
|
403
|
+
}), ht = ({ className: e, ...t }) => {
|
|
404
|
+
let { isAtBottom: n, scrollToBottom: r } = Ue(), i = o(() => {
|
|
378
405
|
r();
|
|
379
406
|
}, [r]);
|
|
380
|
-
return !n && /* @__PURE__ */
|
|
381
|
-
className:
|
|
407
|
+
return !n && /* @__PURE__ */ V(g, {
|
|
408
|
+
className: L("absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full", e),
|
|
382
409
|
onClick: i,
|
|
383
410
|
size: "icon",
|
|
384
411
|
type: "button",
|
|
385
412
|
variant: "outline",
|
|
386
413
|
...t,
|
|
387
|
-
children: /* @__PURE__ */
|
|
414
|
+
children: /* @__PURE__ */ V(de, { className: "size-4" })
|
|
388
415
|
});
|
|
389
|
-
},
|
|
416
|
+
}, gt = U("flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1", {
|
|
390
417
|
variants: { orientation: {
|
|
391
418
|
horizontal: "[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",
|
|
392
419
|
vertical: "flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"
|
|
393
420
|
} },
|
|
394
421
|
defaultVariants: { orientation: "horizontal" }
|
|
395
422
|
});
|
|
396
|
-
function
|
|
397
|
-
return /* @__PURE__ */
|
|
423
|
+
function _t({ className: e, orientation: t, ...n }) {
|
|
424
|
+
return /* @__PURE__ */ V("div", {
|
|
398
425
|
role: "group",
|
|
399
426
|
"data-slot": "button-group",
|
|
400
427
|
"data-orientation": t,
|
|
401
|
-
className:
|
|
428
|
+
className: L(gt({ orientation: t }), e),
|
|
402
429
|
...n
|
|
403
430
|
});
|
|
404
431
|
}
|
|
405
|
-
function
|
|
406
|
-
return /* @__PURE__ */
|
|
407
|
-
className:
|
|
432
|
+
function vt({ className: e, asChild: t = !1, ...n }) {
|
|
433
|
+
return /* @__PURE__ */ V(t ? We : "div", {
|
|
434
|
+
className: L("flex items-center gap-2 rounded-md border bg-muted px-4 text-sm font-medium shadow-xs [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4", e),
|
|
408
435
|
...n
|
|
409
436
|
});
|
|
410
437
|
}
|
|
411
438
|
//#endregion
|
|
412
439
|
//#region src/elements/message.tsx
|
|
413
|
-
var
|
|
414
|
-
className:
|
|
440
|
+
var yt = ({ className: e, from: t, ...n }) => /* @__PURE__ */ V("div", {
|
|
441
|
+
className: L("group flex w-full max-w-[95%] flex-col gap-2", t === "user" ? "is-user ml-auto justify-end" : "is-assistant", e),
|
|
415
442
|
...n
|
|
416
|
-
}),
|
|
417
|
-
className:
|
|
443
|
+
}), bt = ({ children: e, className: t, ...n }) => /* @__PURE__ */ V("div", {
|
|
444
|
+
className: L("is-user:dark flex w-fit max-w-full min-w-0 flex-col gap-2 overflow-hidden text-sm", "group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground", "group-[.is-assistant]:text-foreground", t),
|
|
418
445
|
...n,
|
|
419
446
|
children: e
|
|
420
|
-
}),
|
|
421
|
-
className:
|
|
447
|
+
}), xt = ({ className: e, children: t, ...n }) => /* @__PURE__ */ V("div", {
|
|
448
|
+
className: L("flex items-center gap-1", e),
|
|
422
449
|
...n,
|
|
423
450
|
children: t
|
|
424
|
-
}),
|
|
425
|
-
let o = /* @__PURE__ */
|
|
451
|
+
}), J = ({ tooltip: e, children: t, label: n, variant: r = "ghost", size: i = "icon", ...a }) => {
|
|
452
|
+
let o = /* @__PURE__ */ H(g, {
|
|
426
453
|
size: i,
|
|
427
454
|
type: "button",
|
|
428
455
|
variant: r,
|
|
429
456
|
...a,
|
|
430
|
-
children: [t, /* @__PURE__ */
|
|
457
|
+
children: [t, /* @__PURE__ */ V("span", {
|
|
431
458
|
className: "sr-only",
|
|
432
459
|
children: n || e
|
|
433
460
|
})]
|
|
434
461
|
});
|
|
435
|
-
return e ? /* @__PURE__ */
|
|
462
|
+
return e ? /* @__PURE__ */ V(ce, { children: /* @__PURE__ */ H(oe, { children: [/* @__PURE__ */ V(le, {
|
|
436
463
|
asChild: !0,
|
|
437
464
|
children: o
|
|
438
|
-
}), /* @__PURE__ */
|
|
439
|
-
},
|
|
440
|
-
let e = s(
|
|
465
|
+
}), /* @__PURE__ */ V(se, { children: /* @__PURE__ */ V("p", { children: e }) })] }) }) : o;
|
|
466
|
+
}, St = r(null), Y = () => {
|
|
467
|
+
let e = s(St);
|
|
441
468
|
if (!e) throw Error("MessageBranch components must be used within MessageBranch");
|
|
442
469
|
return e;
|
|
443
|
-
},
|
|
470
|
+
}, Ct = ({ defaultBranch: e = 0, onBranchChange: t, className: n, ...r }) => {
|
|
444
471
|
let [i, a] = d(e), [o, s] = d([]), c = (e) => {
|
|
445
472
|
a(e), t?.(e);
|
|
446
473
|
}, l = {
|
|
@@ -455,36 +482,36 @@ var mt = ({ className: e, from: t, ...n }) => /* @__PURE__ */ B("div", {
|
|
|
455
482
|
branches: o,
|
|
456
483
|
setBranches: s
|
|
457
484
|
};
|
|
458
|
-
return /* @__PURE__ */
|
|
485
|
+
return /* @__PURE__ */ V(St.Provider, {
|
|
459
486
|
value: l,
|
|
460
|
-
children: /* @__PURE__ */
|
|
461
|
-
className:
|
|
487
|
+
children: /* @__PURE__ */ V("div", {
|
|
488
|
+
className: L("grid w-full gap-2 [&>div]:pb-0", n),
|
|
462
489
|
...r
|
|
463
490
|
})
|
|
464
491
|
});
|
|
465
|
-
},
|
|
466
|
-
let { currentBranch: n, setBranches: r, branches: i } =
|
|
492
|
+
}, wt = ({ children: e, ...t }) => {
|
|
493
|
+
let { currentBranch: n, setBranches: r, branches: i } = Y(), a = Array.isArray(e) ? e : [e];
|
|
467
494
|
return c(() => {
|
|
468
495
|
i.length !== a.length && r(a);
|
|
469
496
|
}, [
|
|
470
497
|
a,
|
|
471
498
|
i,
|
|
472
499
|
r
|
|
473
|
-
]), a.map((e, r) => /* @__PURE__ */
|
|
474
|
-
className:
|
|
500
|
+
]), a.map((e, r) => /* @__PURE__ */ V("div", {
|
|
501
|
+
className: L("grid gap-2 overflow-hidden [&>div]:pb-0", r === n ? "block" : "hidden"),
|
|
475
502
|
...t,
|
|
476
503
|
children: e
|
|
477
504
|
}, e.key));
|
|
478
|
-
},
|
|
479
|
-
let { totalBranches: r } =
|
|
480
|
-
return r <= 1 ? null : /* @__PURE__ */
|
|
505
|
+
}, Tt = ({ className: e, from: t, ...n }) => {
|
|
506
|
+
let { totalBranches: r } = Y();
|
|
507
|
+
return r <= 1 ? null : /* @__PURE__ */ V(_t, {
|
|
481
508
|
className: "[&>*:not(:first-child)]:rounded-l-md [&>*:not(:last-child)]:rounded-r-md",
|
|
482
509
|
orientation: "horizontal",
|
|
483
510
|
...n
|
|
484
511
|
});
|
|
485
|
-
},
|
|
486
|
-
let { goToPrevious: n, totalBranches: r } =
|
|
487
|
-
return /* @__PURE__ */
|
|
512
|
+
}, Et = ({ children: e, ...t }) => {
|
|
513
|
+
let { goToPrevious: n, totalBranches: r } = Y();
|
|
514
|
+
return /* @__PURE__ */ V(g, {
|
|
488
515
|
"aria-label": "Previous branch",
|
|
489
516
|
disabled: r <= 1,
|
|
490
517
|
onClick: n,
|
|
@@ -492,11 +519,11 @@ var mt = ({ className: e, from: t, ...n }) => /* @__PURE__ */ B("div", {
|
|
|
492
519
|
type: "button",
|
|
493
520
|
variant: "ghost",
|
|
494
521
|
...t,
|
|
495
|
-
children: e ?? /* @__PURE__ */
|
|
522
|
+
children: e ?? /* @__PURE__ */ V(_e, { size: 14 })
|
|
496
523
|
});
|
|
497
|
-
},
|
|
498
|
-
let { goToNext: r, totalBranches: i } =
|
|
499
|
-
return /* @__PURE__ */
|
|
524
|
+
}, Dt = ({ children: e, className: t, ...n }) => {
|
|
525
|
+
let { goToNext: r, totalBranches: i } = Y();
|
|
526
|
+
return /* @__PURE__ */ V(g, {
|
|
500
527
|
"aria-label": "Next branch",
|
|
501
528
|
disabled: i <= 1,
|
|
502
529
|
onClick: r,
|
|
@@ -504,12 +531,12 @@ var mt = ({ className: e, from: t, ...n }) => /* @__PURE__ */ B("div", {
|
|
|
504
531
|
type: "button",
|
|
505
532
|
variant: "ghost",
|
|
506
533
|
...n,
|
|
507
|
-
children: e ?? /* @__PURE__ */
|
|
534
|
+
children: e ?? /* @__PURE__ */ V(ve, { size: 14 })
|
|
508
535
|
});
|
|
509
|
-
},
|
|
510
|
-
let { currentBranch: n, totalBranches: r } =
|
|
511
|
-
return /* @__PURE__ */
|
|
512
|
-
className:
|
|
536
|
+
}, Ot = ({ className: e, ...t }) => {
|
|
537
|
+
let { currentBranch: n, totalBranches: r } = Y();
|
|
538
|
+
return /* @__PURE__ */ H(vt, {
|
|
539
|
+
className: L("border-none bg-transparent text-muted-foreground shadow-none", e),
|
|
513
540
|
...t,
|
|
514
541
|
children: [
|
|
515
542
|
n + 1,
|
|
@@ -517,23 +544,23 @@ var mt = ({ className: e, from: t, ...n }) => /* @__PURE__ */ B("div", {
|
|
|
517
544
|
r
|
|
518
545
|
]
|
|
519
546
|
});
|
|
520
|
-
},
|
|
521
|
-
className:
|
|
547
|
+
}, kt = a(({ className: e, ...t }) => /* @__PURE__ */ V(Ge, {
|
|
548
|
+
className: L("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0", e),
|
|
522
549
|
...t
|
|
523
550
|
}), (e, t) => e.children === t.children);
|
|
524
|
-
|
|
525
|
-
function
|
|
551
|
+
kt.displayName = "MessageResponse";
|
|
552
|
+
function At({ data: e, className: t, onRemove: n, ...r }) {
|
|
526
553
|
let i = e.filename || "", a = (e.mediaType?.startsWith("image/") && e.url ? "image" : "file") == "image", o = i || (a ? "Image" : "Attachment");
|
|
527
|
-
return /* @__PURE__ */
|
|
528
|
-
className:
|
|
554
|
+
return /* @__PURE__ */ V("div", {
|
|
555
|
+
className: L("group relative size-24 overflow-hidden rounded-lg", t),
|
|
529
556
|
...r,
|
|
530
|
-
children: a ? /* @__PURE__ */
|
|
557
|
+
children: a ? /* @__PURE__ */ H(B, { children: [/* @__PURE__ */ V("img", {
|
|
531
558
|
alt: i || "attachment",
|
|
532
559
|
className: "size-full object-cover",
|
|
533
560
|
height: 100,
|
|
534
561
|
src: e.url,
|
|
535
562
|
width: 100
|
|
536
|
-
}), n && /* @__PURE__ */
|
|
563
|
+
}), n && /* @__PURE__ */ H(g, {
|
|
537
564
|
"aria-label": "Remove attachment",
|
|
538
565
|
className: "absolute top-2 right-2 size-6 rounded-full bg-background/80 p-0 opacity-0 backdrop-blur-sm transition-opacity hover:bg-background group-hover:opacity-100 [&>svg]:size-3",
|
|
539
566
|
onClick: (e) => {
|
|
@@ -541,17 +568,17 @@ function Tt({ data: e, className: t, onRemove: n, ...r }) {
|
|
|
541
568
|
},
|
|
542
569
|
type: "button",
|
|
543
570
|
variant: "ghost",
|
|
544
|
-
children: [/* @__PURE__ */
|
|
571
|
+
children: [/* @__PURE__ */ V(z, {}), /* @__PURE__ */ V("span", {
|
|
545
572
|
className: "sr-only",
|
|
546
573
|
children: "Remove"
|
|
547
574
|
})]
|
|
548
|
-
})] }) : /* @__PURE__ */
|
|
575
|
+
})] }) : /* @__PURE__ */ H(B, { children: [/* @__PURE__ */ H(oe, { children: [/* @__PURE__ */ V(le, {
|
|
549
576
|
asChild: !0,
|
|
550
|
-
children: /* @__PURE__ */
|
|
577
|
+
children: /* @__PURE__ */ V("div", {
|
|
551
578
|
className: "flex size-full shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground",
|
|
552
|
-
children: /* @__PURE__ */
|
|
579
|
+
children: /* @__PURE__ */ V(Ae, { className: "size-4" })
|
|
553
580
|
})
|
|
554
|
-
}), /* @__PURE__ */
|
|
581
|
+
}), /* @__PURE__ */ V(se, { children: /* @__PURE__ */ V("p", { children: o }) })] }), n && /* @__PURE__ */ H(g, {
|
|
555
582
|
"aria-label": "Remove attachment",
|
|
556
583
|
className: "size-6 shrink-0 rounded-full p-0 opacity-0 transition-opacity hover:bg-accent group-hover:opacity-100 [&>svg]:size-3",
|
|
557
584
|
onClick: (e) => {
|
|
@@ -559,36 +586,36 @@ function Tt({ data: e, className: t, onRemove: n, ...r }) {
|
|
|
559
586
|
},
|
|
560
587
|
type: "button",
|
|
561
588
|
variant: "ghost",
|
|
562
|
-
children: [/* @__PURE__ */
|
|
589
|
+
children: [/* @__PURE__ */ V(z, {}), /* @__PURE__ */ V("span", {
|
|
563
590
|
className: "sr-only",
|
|
564
591
|
children: "Remove"
|
|
565
592
|
})]
|
|
566
593
|
})] })
|
|
567
594
|
});
|
|
568
595
|
}
|
|
569
|
-
function
|
|
570
|
-
return e ? /* @__PURE__ */
|
|
571
|
-
className:
|
|
596
|
+
function jt({ children: e, className: t, ...n }) {
|
|
597
|
+
return e ? /* @__PURE__ */ V("div", {
|
|
598
|
+
className: L("ml-auto flex w-fit flex-wrap items-start gap-2", t),
|
|
572
599
|
...n,
|
|
573
600
|
children: e
|
|
574
601
|
}) : null;
|
|
575
602
|
}
|
|
576
|
-
var
|
|
577
|
-
className:
|
|
603
|
+
var Mt = ({ className: e, children: t, ...n }) => /* @__PURE__ */ V("div", {
|
|
604
|
+
className: L("mt-4 flex w-full items-center justify-between gap-4", e),
|
|
578
605
|
...n,
|
|
579
606
|
children: t
|
|
580
607
|
});
|
|
581
608
|
//#endregion
|
|
582
609
|
//#region src/elements/ui/input-group.tsx
|
|
583
|
-
function
|
|
584
|
-
return /* @__PURE__ */
|
|
610
|
+
function Nt({ className: e, ...t }) {
|
|
611
|
+
return /* @__PURE__ */ V("div", {
|
|
585
612
|
"data-slot": "input-group",
|
|
586
613
|
role: "group",
|
|
587
|
-
className:
|
|
614
|
+
className: L("group/input-group relative flex w-full items-center rounded-md border border-input shadow-xs transition-[color,box-shadow] outline-none dark:bg-input/30", "h-9 min-w-0 has-[>textarea]:h-auto", "has-[>[data-align=inline-start]]:[&>input]:pl-2", "has-[>[data-align=inline-end]]:[&>input]:pr-2", "has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3", "has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3", "has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-[3px] has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50", "has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-destructive/20 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40", e),
|
|
588
615
|
...t
|
|
589
616
|
});
|
|
590
617
|
}
|
|
591
|
-
var
|
|
618
|
+
var Pt = U("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4", {
|
|
592
619
|
variants: { align: {
|
|
593
620
|
"inline-start": "order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]",
|
|
594
621
|
"inline-end": "order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]",
|
|
@@ -597,19 +624,19 @@ var kt = H("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 tex
|
|
|
597
624
|
} },
|
|
598
625
|
defaultVariants: { align: "inline-start" }
|
|
599
626
|
});
|
|
600
|
-
function
|
|
601
|
-
return /* @__PURE__ */
|
|
627
|
+
function Ft({ className: e, align: t = "inline-start", ...n }) {
|
|
628
|
+
return /* @__PURE__ */ V("div", {
|
|
602
629
|
role: "group",
|
|
603
630
|
"data-slot": "input-group-addon",
|
|
604
631
|
"data-align": t,
|
|
605
|
-
className:
|
|
632
|
+
className: L(Pt({ align: t }), e),
|
|
606
633
|
onClick: (e) => {
|
|
607
634
|
e.target.closest("button") || e.currentTarget.parentElement?.querySelector("input")?.focus();
|
|
608
635
|
},
|
|
609
636
|
...n
|
|
610
637
|
});
|
|
611
638
|
}
|
|
612
|
-
var
|
|
639
|
+
var It = U("flex items-center gap-2 text-sm shadow-none", {
|
|
613
640
|
variants: { size: {
|
|
614
641
|
xs: "h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5",
|
|
615
642
|
sm: "h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5",
|
|
@@ -618,38 +645,38 @@ var jt = H("flex items-center gap-2 text-sm shadow-none", {
|
|
|
618
645
|
} },
|
|
619
646
|
defaultVariants: { size: "xs" }
|
|
620
647
|
});
|
|
621
|
-
function
|
|
622
|
-
return /* @__PURE__ */
|
|
648
|
+
function Lt({ className: e, type: t = "button", variant: n = "ghost", size: r = "xs", ...i }) {
|
|
649
|
+
return /* @__PURE__ */ V(g, {
|
|
623
650
|
type: t,
|
|
624
651
|
"data-size": r,
|
|
625
652
|
variant: n,
|
|
626
|
-
className:
|
|
653
|
+
className: L(It({ size: r }), e),
|
|
627
654
|
...i
|
|
628
655
|
});
|
|
629
656
|
}
|
|
630
|
-
function
|
|
631
|
-
return /* @__PURE__ */
|
|
657
|
+
function Rt({ className: e, ...t }) {
|
|
658
|
+
return /* @__PURE__ */ V(ae, {
|
|
632
659
|
"data-slot": "input-group-control",
|
|
633
|
-
className:
|
|
660
|
+
className: L("flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent", e),
|
|
634
661
|
...t
|
|
635
662
|
});
|
|
636
663
|
}
|
|
637
664
|
//#endregion
|
|
638
665
|
//#region src/elements/prompt-input.tsx
|
|
639
|
-
var
|
|
640
|
-
let e = s(
|
|
666
|
+
var X = r(null), zt = r(null), Bt = () => {
|
|
667
|
+
let e = s(X);
|
|
641
668
|
if (!e) throw Error("Wrap your component inside <PromptInputProvider> to use usePromptInputController().");
|
|
642
669
|
return e;
|
|
643
|
-
},
|
|
644
|
-
let e = s(
|
|
670
|
+
}, Vt = () => s(X), Ht = () => {
|
|
671
|
+
let e = s(zt);
|
|
645
672
|
if (!e) throw Error("Wrap your component inside <PromptInputProvider> to use useProviderAttachments().");
|
|
646
673
|
return e;
|
|
647
|
-
},
|
|
648
|
-
function
|
|
674
|
+
}, Ut = () => s(zt);
|
|
675
|
+
function Wt({ initialInput: e = "", children: t }) {
|
|
649
676
|
let [n, r] = d(e), i = o(() => r(""), []), [a, s] = d([]), f = u(null), p = u(() => {}), m = o((e) => {
|
|
650
677
|
let t = Array.from(e);
|
|
651
678
|
t.length !== 0 && s((e) => e.concat(t.map((e) => ({
|
|
652
|
-
id:
|
|
679
|
+
id: Ke(),
|
|
653
680
|
type: "file",
|
|
654
681
|
url: URL.createObjectURL(e),
|
|
655
682
|
mediaType: e.type,
|
|
@@ -700,41 +727,41 @@ function Rt({ initialInput: e = "", children: t }) {
|
|
|
700
727
|
y,
|
|
701
728
|
b
|
|
702
729
|
]);
|
|
703
|
-
return /* @__PURE__ */
|
|
730
|
+
return /* @__PURE__ */ V(X.Provider, {
|
|
704
731
|
value: x,
|
|
705
|
-
children: /* @__PURE__ */
|
|
732
|
+
children: /* @__PURE__ */ V(zt.Provider, {
|
|
706
733
|
value: y,
|
|
707
734
|
children: t
|
|
708
735
|
})
|
|
709
736
|
});
|
|
710
737
|
}
|
|
711
|
-
var
|
|
712
|
-
let e =
|
|
738
|
+
var Gt = r(null), Z = () => {
|
|
739
|
+
let e = Ut(), t = s(Gt), n = e ?? t;
|
|
713
740
|
if (!n) throw Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");
|
|
714
741
|
return n;
|
|
715
742
|
};
|
|
716
|
-
function
|
|
743
|
+
function Kt({ data: e, className: t, ...n }) {
|
|
717
744
|
let r = Z(), i = e.filename || "", a = (e.mediaType?.startsWith("image/") && e.url ? "image" : "file") == "image", o = i || (a ? "Image" : "Attachment");
|
|
718
|
-
return /* @__PURE__ */
|
|
745
|
+
return /* @__PURE__ */ H(mn, { children: [/* @__PURE__ */ V(N, {
|
|
719
746
|
asChild: !0,
|
|
720
|
-
children: /* @__PURE__ */
|
|
721
|
-
className:
|
|
747
|
+
children: /* @__PURE__ */ H("div", {
|
|
748
|
+
className: L("group relative flex h-8 cursor-pointer select-none items-center gap-1.5 rounded-md border border-border px-1.5 font-medium text-sm transition-all hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50", t),
|
|
722
749
|
...n,
|
|
723
|
-
children: [/* @__PURE__ */
|
|
750
|
+
children: [/* @__PURE__ */ H("div", {
|
|
724
751
|
className: "relative size-5 shrink-0",
|
|
725
|
-
children: [/* @__PURE__ */
|
|
752
|
+
children: [/* @__PURE__ */ V("div", {
|
|
726
753
|
className: "absolute inset-0 flex size-5 items-center justify-center overflow-hidden rounded bg-background transition-opacity group-hover:opacity-0",
|
|
727
|
-
children: a ? /* @__PURE__ */
|
|
754
|
+
children: a ? /* @__PURE__ */ V("img", {
|
|
728
755
|
alt: i || "attachment",
|
|
729
756
|
className: "size-5 object-cover",
|
|
730
757
|
height: 20,
|
|
731
758
|
src: e.url,
|
|
732
759
|
width: 20
|
|
733
|
-
}) : /* @__PURE__ */
|
|
760
|
+
}) : /* @__PURE__ */ V("div", {
|
|
734
761
|
className: "flex size-5 items-center justify-center text-muted-foreground",
|
|
735
|
-
children: /* @__PURE__ */
|
|
762
|
+
children: /* @__PURE__ */ V(Ae, { className: "size-3" })
|
|
736
763
|
})
|
|
737
|
-
}), /* @__PURE__ */
|
|
764
|
+
}), /* @__PURE__ */ H(g, {
|
|
738
765
|
"aria-label": "Remove attachment",
|
|
739
766
|
className: "absolute inset-0 size-5 cursor-pointer rounded p-0 opacity-0 transition-opacity group-hover:pointer-events-auto group-hover:opacity-100 [&>svg]:size-2.5",
|
|
740
767
|
onClick: (t) => {
|
|
@@ -742,37 +769,37 @@ function Bt({ data: e, className: t, ...n }) {
|
|
|
742
769
|
},
|
|
743
770
|
type: "button",
|
|
744
771
|
variant: "ghost",
|
|
745
|
-
children: [/* @__PURE__ */
|
|
772
|
+
children: [/* @__PURE__ */ V(z, {}), /* @__PURE__ */ V("span", {
|
|
746
773
|
className: "sr-only",
|
|
747
774
|
children: "Remove"
|
|
748
775
|
})]
|
|
749
776
|
})]
|
|
750
|
-
}), /* @__PURE__ */
|
|
777
|
+
}), /* @__PURE__ */ V("span", {
|
|
751
778
|
className: "flex-1 truncate",
|
|
752
779
|
children: o
|
|
753
780
|
})]
|
|
754
781
|
}, e.id)
|
|
755
|
-
}), /* @__PURE__ */
|
|
782
|
+
}), /* @__PURE__ */ V(gn, {
|
|
756
783
|
className: "w-auto p-2",
|
|
757
|
-
children: /* @__PURE__ */
|
|
784
|
+
children: /* @__PURE__ */ H("div", {
|
|
758
785
|
className: "w-auto space-y-3",
|
|
759
|
-
children: [a && /* @__PURE__ */
|
|
786
|
+
children: [a && /* @__PURE__ */ V("div", {
|
|
760
787
|
className: "flex max-h-96 w-96 items-center justify-center overflow-hidden rounded-md border",
|
|
761
|
-
children: /* @__PURE__ */
|
|
788
|
+
children: /* @__PURE__ */ V("img", {
|
|
762
789
|
alt: i || "attachment preview",
|
|
763
790
|
className: "max-h-full max-w-full object-contain",
|
|
764
791
|
height: 384,
|
|
765
792
|
src: e.url,
|
|
766
793
|
width: 448
|
|
767
794
|
})
|
|
768
|
-
}), /* @__PURE__ */
|
|
795
|
+
}), /* @__PURE__ */ V("div", {
|
|
769
796
|
className: "flex items-center gap-2.5",
|
|
770
|
-
children: /* @__PURE__ */
|
|
797
|
+
children: /* @__PURE__ */ H("div", {
|
|
771
798
|
className: "min-w-0 flex-1 space-y-1 px-0.5",
|
|
772
|
-
children: [/* @__PURE__ */
|
|
799
|
+
children: [/* @__PURE__ */ V("h4", {
|
|
773
800
|
className: "truncate font-semibold text-sm leading-none",
|
|
774
801
|
children: i || (a ? "Image" : "Attachment")
|
|
775
|
-
}), e.mediaType && /* @__PURE__ */
|
|
802
|
+
}), e.mediaType && /* @__PURE__ */ V("p", {
|
|
776
803
|
className: "truncate font-mono text-muted-foreground text-xs",
|
|
777
804
|
children: e.mediaType
|
|
778
805
|
})]
|
|
@@ -781,29 +808,29 @@ function Bt({ data: e, className: t, ...n }) {
|
|
|
781
808
|
})
|
|
782
809
|
})] });
|
|
783
810
|
}
|
|
784
|
-
function
|
|
811
|
+
function qt({ children: e, className: t, ...r }) {
|
|
785
812
|
let i = Z();
|
|
786
|
-
return i.files.length ? /* @__PURE__ */
|
|
787
|
-
className:
|
|
813
|
+
return i.files.length ? /* @__PURE__ */ V("div", {
|
|
814
|
+
className: L("flex flex-wrap items-center gap-2 p-3 w-full", t),
|
|
788
815
|
...r,
|
|
789
|
-
children: i.files.map((t) => /* @__PURE__ */
|
|
816
|
+
children: i.files.map((t) => /* @__PURE__ */ V(n, { children: e(t) }, t.id))
|
|
790
817
|
}) : null;
|
|
791
818
|
}
|
|
792
|
-
var
|
|
819
|
+
var Jt = ({ label: e = "Add photos or files", ...t }) => {
|
|
793
820
|
let n = Z();
|
|
794
|
-
return /* @__PURE__ */
|
|
821
|
+
return /* @__PURE__ */ H(k, {
|
|
795
822
|
...t,
|
|
796
823
|
onSelect: (e) => {
|
|
797
824
|
e.preventDefault(), n.openFileDialog();
|
|
798
825
|
},
|
|
799
826
|
children: [
|
|
800
|
-
/* @__PURE__ */
|
|
827
|
+
/* @__PURE__ */ V(we, { className: "mr-2 size-4" }),
|
|
801
828
|
" ",
|
|
802
829
|
e
|
|
803
830
|
]
|
|
804
831
|
});
|
|
805
|
-
},
|
|
806
|
-
let g =
|
|
832
|
+
}, Yt = ({ className: e, accept: t, multiple: n, globalDrop: r, syncHiddenInput: i, maxFiles: a, maxFileSize: s, onError: f, onSubmit: p, children: m, ...h }) => {
|
|
833
|
+
let g = Vt(), _ = !!g, v = u(null), y = u(null), [b, x] = d([]), S = _ ? g.attachments.files : b, C = u(S);
|
|
807
834
|
C.current = S;
|
|
808
835
|
let w = o(() => {
|
|
809
836
|
v.current?.click();
|
|
@@ -838,7 +865,7 @@ var Ht = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
838
865
|
});
|
|
839
866
|
let i = [];
|
|
840
867
|
for (let e of n) i.push({
|
|
841
|
-
id:
|
|
868
|
+
id: Ke(),
|
|
842
869
|
type: "file",
|
|
843
870
|
url: URL.createObjectURL(e),
|
|
844
871
|
mediaType: e.type,
|
|
@@ -888,7 +915,7 @@ var Ht = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
888
915
|
}, [_]);
|
|
889
916
|
let N = (e) => {
|
|
890
917
|
e.currentTarget.files && k(e.currentTarget.files), e.currentTarget.value = "";
|
|
891
|
-
},
|
|
918
|
+
}, P = async (e) => {
|
|
892
919
|
try {
|
|
893
920
|
let t = await (await fetch(e)).blob();
|
|
894
921
|
return new Promise((e) => {
|
|
@@ -898,7 +925,7 @@ var Ht = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
898
925
|
} catch {
|
|
899
926
|
return null;
|
|
900
927
|
}
|
|
901
|
-
},
|
|
928
|
+
}, F = l(() => ({
|
|
902
929
|
files: S.map((e) => ({
|
|
903
930
|
...e,
|
|
904
931
|
id: e.id
|
|
@@ -914,7 +941,7 @@ var Ht = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
914
941
|
A,
|
|
915
942
|
j,
|
|
916
943
|
M
|
|
917
|
-
]),
|
|
944
|
+
]), I = /* @__PURE__ */ H(B, { children: [/* @__PURE__ */ V("input", {
|
|
918
945
|
accept: t,
|
|
919
946
|
"aria-label": "Upload files",
|
|
920
947
|
className: "hidden",
|
|
@@ -923,14 +950,14 @@ var Ht = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
923
950
|
ref: v,
|
|
924
951
|
title: "Upload files",
|
|
925
952
|
type: "file"
|
|
926
|
-
}), /* @__PURE__ */
|
|
927
|
-
className:
|
|
953
|
+
}), /* @__PURE__ */ V("form", {
|
|
954
|
+
className: L("w-full", e),
|
|
928
955
|
onSubmit: (e) => {
|
|
929
956
|
e.preventDefault();
|
|
930
957
|
let t = e.currentTarget, n = _ ? g.textInput.value : new FormData(t).get("message") || "";
|
|
931
958
|
_ || t.reset(), Promise.all(S.map(async ({ id: e, ...t }) => {
|
|
932
959
|
if (t.url && t.url.startsWith("blob:")) {
|
|
933
|
-
let e = await
|
|
960
|
+
let e = await P(t.url);
|
|
934
961
|
return {
|
|
935
962
|
...t,
|
|
936
963
|
url: e ?? t.url
|
|
@@ -951,20 +978,20 @@ var Ht = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
951
978
|
},
|
|
952
979
|
ref: y,
|
|
953
980
|
...h,
|
|
954
|
-
children: /* @__PURE__ */
|
|
981
|
+
children: /* @__PURE__ */ V(Nt, {
|
|
955
982
|
className: "overflow-hidden",
|
|
956
983
|
children: m
|
|
957
984
|
})
|
|
958
985
|
})] });
|
|
959
|
-
return _ ?
|
|
960
|
-
value:
|
|
961
|
-
children:
|
|
986
|
+
return _ ? I : /* @__PURE__ */ V(Gt.Provider, {
|
|
987
|
+
value: F,
|
|
988
|
+
children: I
|
|
962
989
|
});
|
|
963
|
-
},
|
|
964
|
-
className:
|
|
990
|
+
}, Xt = ({ className: e, ...t }) => /* @__PURE__ */ V("div", {
|
|
991
|
+
className: L("contents", e),
|
|
965
992
|
...t
|
|
966
|
-
}),
|
|
967
|
-
let i =
|
|
993
|
+
}), Zt = ({ onChange: e, className: t, placeholder: n = "What would you like to know?", ...r }) => {
|
|
994
|
+
let i = Vt(), a = Z(), [o, s] = d(!1), c = (e) => {
|
|
968
995
|
if (e.key === "Enter") {
|
|
969
996
|
if (o || e.nativeEvent.isComposing || e.shiftKey) return;
|
|
970
997
|
e.preventDefault();
|
|
@@ -992,8 +1019,8 @@ var Ht = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
992
1019
|
i.textInput.setInput(t.currentTarget.value), e?.(t);
|
|
993
1020
|
}
|
|
994
1021
|
} : { onChange: e };
|
|
995
|
-
return /* @__PURE__ */
|
|
996
|
-
className:
|
|
1022
|
+
return /* @__PURE__ */ V(Rt, {
|
|
1023
|
+
className: L("field-sizing-content max-h-48 min-h-16", t),
|
|
997
1024
|
name: "message",
|
|
998
1025
|
onCompositionEnd: () => s(!1),
|
|
999
1026
|
onCompositionStart: () => s(!0),
|
|
@@ -1003,52 +1030,52 @@ var Ht = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1003
1030
|
...r,
|
|
1004
1031
|
...u
|
|
1005
1032
|
});
|
|
1006
|
-
},
|
|
1033
|
+
}, Qt = ({ className: e, ...t }) => /* @__PURE__ */ V(Ft, {
|
|
1007
1034
|
align: "block-end",
|
|
1008
|
-
className:
|
|
1035
|
+
className: L("order-first flex-wrap gap-1", e),
|
|
1009
1036
|
...t
|
|
1010
|
-
}),
|
|
1037
|
+
}), $t = ({ className: e, ...t }) => /* @__PURE__ */ V(Ft, {
|
|
1011
1038
|
align: "block-end",
|
|
1012
|
-
className:
|
|
1039
|
+
className: L("justify-between gap-1", e),
|
|
1013
1040
|
...t
|
|
1014
|
-
}),
|
|
1015
|
-
className:
|
|
1041
|
+
}), en = ({ className: e, ...t }) => /* @__PURE__ */ V("div", {
|
|
1042
|
+
className: L("flex items-center gap-1", e),
|
|
1016
1043
|
...t
|
|
1017
|
-
}),
|
|
1044
|
+
}), tn = ({ variant: e = "ghost", className: n, size: r, ...i }) => {
|
|
1018
1045
|
let a = r ?? (t.count(i.children) > 1 ? "sm" : "icon-sm");
|
|
1019
|
-
return /* @__PURE__ */
|
|
1020
|
-
className:
|
|
1046
|
+
return /* @__PURE__ */ V(Lt, {
|
|
1047
|
+
className: L(n),
|
|
1021
1048
|
size: a,
|
|
1022
1049
|
type: "button",
|
|
1023
1050
|
variant: e,
|
|
1024
1051
|
...i
|
|
1025
1052
|
});
|
|
1026
|
-
},
|
|
1053
|
+
}, nn = (e) => /* @__PURE__ */ V(D, { ...e }), rn = ({ className: e, children: t, ...n }) => /* @__PURE__ */ V(A, {
|
|
1027
1054
|
asChild: !0,
|
|
1028
|
-
children: /* @__PURE__ */
|
|
1055
|
+
children: /* @__PURE__ */ V(tn, {
|
|
1029
1056
|
className: e,
|
|
1030
1057
|
...n,
|
|
1031
|
-
children: t ?? /* @__PURE__ */
|
|
1058
|
+
children: t ?? /* @__PURE__ */ V(je, { className: "size-4" })
|
|
1032
1059
|
})
|
|
1033
|
-
}),
|
|
1060
|
+
}), an = ({ className: e, ...t }) => /* @__PURE__ */ V(O, {
|
|
1034
1061
|
align: "start",
|
|
1035
|
-
className:
|
|
1062
|
+
className: L(e),
|
|
1036
1063
|
...t
|
|
1037
|
-
}),
|
|
1038
|
-
className:
|
|
1064
|
+
}), on = ({ className: e, ...t }) => /* @__PURE__ */ V(k, {
|
|
1065
|
+
className: L(e),
|
|
1039
1066
|
...t
|
|
1040
|
-
}),
|
|
1041
|
-
let o = /* @__PURE__ */
|
|
1042
|
-
return r === "submitted" ? o = /* @__PURE__ */
|
|
1067
|
+
}), sn = ({ className: e, variant: t = "default", size: n = "icon-sm", status: r, children: i, ...a }) => {
|
|
1068
|
+
let o = /* @__PURE__ */ V(Ce, { className: "size-4" });
|
|
1069
|
+
return r === "submitted" ? o = /* @__PURE__ */ V(Te, { className: "size-4 animate-spin" }) : r === "streaming" ? o = /* @__PURE__ */ V(Pe, { className: "size-4" }) : r === "error" && (o = /* @__PURE__ */ V(z, { className: "size-4" })), /* @__PURE__ */ V(Lt, {
|
|
1043
1070
|
"aria-label": "Submit",
|
|
1044
|
-
className:
|
|
1071
|
+
className: L(e),
|
|
1045
1072
|
size: n,
|
|
1046
1073
|
type: "submit",
|
|
1047
1074
|
variant: t,
|
|
1048
1075
|
...a,
|
|
1049
1076
|
children: i ?? o
|
|
1050
1077
|
});
|
|
1051
|
-
},
|
|
1078
|
+
}, cn = ({ className: e, textareaRef: t, onTranscriptionChange: n, ...r }) => {
|
|
1052
1079
|
let [i, a] = d(!1), [s, l] = d(null), f = u(null);
|
|
1053
1080
|
c(() => {
|
|
1054
1081
|
if (typeof window < "u" && ("SpeechRecognition" in window || "webkitSpeechRecognition" in window)) {
|
|
@@ -1078,80 +1105,80 @@ var Ht = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1078
1105
|
let p = o(() => {
|
|
1079
1106
|
s && (i ? s.stop() : s.start());
|
|
1080
1107
|
}, [s, i]);
|
|
1081
|
-
return /* @__PURE__ */
|
|
1082
|
-
className:
|
|
1108
|
+
return /* @__PURE__ */ V(tn, {
|
|
1109
|
+
className: L("relative transition-all duration-200", i && "animate-pulse bg-accent text-accent-foreground", e),
|
|
1083
1110
|
disabled: !s,
|
|
1084
1111
|
onClick: p,
|
|
1085
1112
|
...r,
|
|
1086
|
-
children: /* @__PURE__ */
|
|
1113
|
+
children: /* @__PURE__ */ V(Oe, { className: "size-4" })
|
|
1087
1114
|
});
|
|
1088
|
-
},
|
|
1089
|
-
className:
|
|
1115
|
+
}, ln = (e) => /* @__PURE__ */ V(ee, { ...e }), un = ({ className: e, ...t }) => /* @__PURE__ */ V(re, {
|
|
1116
|
+
className: L("border-none bg-transparent font-medium text-muted-foreground shadow-none transition-colors", "hover:bg-accent hover:text-foreground aria-expanded:bg-accent aria-expanded:text-foreground", e),
|
|
1090
1117
|
...t
|
|
1091
|
-
}),
|
|
1092
|
-
className:
|
|
1118
|
+
}), dn = ({ className: e, ...t }) => /* @__PURE__ */ V(te, {
|
|
1119
|
+
className: L(e),
|
|
1093
1120
|
...t
|
|
1094
|
-
}),
|
|
1095
|
-
className:
|
|
1121
|
+
}), fn = ({ className: e, ...t }) => /* @__PURE__ */ V(ne, {
|
|
1122
|
+
className: L(e),
|
|
1096
1123
|
...t
|
|
1097
|
-
}),
|
|
1098
|
-
className:
|
|
1124
|
+
}), pn = ({ className: e, ...t }) => /* @__PURE__ */ V(ie, {
|
|
1125
|
+
className: L(e),
|
|
1099
1126
|
...t
|
|
1100
|
-
}),
|
|
1127
|
+
}), mn = ({ openDelay: e = 0, closeDelay: t = 0, ...n }) => /* @__PURE__ */ V(j, {
|
|
1101
1128
|
closeDelay: t,
|
|
1102
1129
|
openDelay: e,
|
|
1103
1130
|
...n
|
|
1104
|
-
}),
|
|
1131
|
+
}), hn = (e) => /* @__PURE__ */ V(N, { ...e }), gn = ({ align: e = "start", ...t }) => /* @__PURE__ */ V(M, {
|
|
1105
1132
|
align: e,
|
|
1106
1133
|
...t
|
|
1107
|
-
}),
|
|
1108
|
-
className:
|
|
1134
|
+
}), _n = ({ className: e, ...t }) => /* @__PURE__ */ V("div", {
|
|
1135
|
+
className: L(e),
|
|
1109
1136
|
...t
|
|
1110
|
-
}),
|
|
1111
|
-
className:
|
|
1137
|
+
}), vn = ({ className: e, ...t }) => /* @__PURE__ */ V("div", {
|
|
1138
|
+
className: L(e),
|
|
1112
1139
|
...t
|
|
1113
|
-
}),
|
|
1114
|
-
className:
|
|
1140
|
+
}), yn = ({ className: e, ...t }) => /* @__PURE__ */ V("h3", {
|
|
1141
|
+
className: L("mb-2 px-3 font-medium text-muted-foreground text-xs", e),
|
|
1115
1142
|
...t
|
|
1116
|
-
}),
|
|
1117
|
-
className:
|
|
1143
|
+
}), bn = ({ className: e, ...t }) => /* @__PURE__ */ V("div", {
|
|
1144
|
+
className: L("space-y-1", e),
|
|
1118
1145
|
...t
|
|
1119
|
-
}),
|
|
1120
|
-
className:
|
|
1146
|
+
}), xn = ({ className: e, ...t }) => /* @__PURE__ */ V("div", {
|
|
1147
|
+
className: L("flex items-center gap-2 px-3 py-2 text-xs hover:bg-accent", e),
|
|
1121
1148
|
...t
|
|
1122
|
-
}),
|
|
1123
|
-
className:
|
|
1149
|
+
}), Sn = ({ className: e, ...t }) => /* @__PURE__ */ V(b, {
|
|
1150
|
+
className: L(e),
|
|
1124
1151
|
...t
|
|
1125
|
-
}),
|
|
1126
|
-
className:
|
|
1152
|
+
}), Cn = ({ className: e, ...t }) => /* @__PURE__ */ V(C, {
|
|
1153
|
+
className: L(e),
|
|
1127
1154
|
...t
|
|
1128
|
-
}),
|
|
1129
|
-
className:
|
|
1155
|
+
}), wn = ({ className: e, ...t }) => /* @__PURE__ */ V(T, {
|
|
1156
|
+
className: L(e),
|
|
1130
1157
|
...t
|
|
1131
|
-
}),
|
|
1132
|
-
className:
|
|
1158
|
+
}), Tn = ({ className: e, ...t }) => /* @__PURE__ */ V(x, {
|
|
1159
|
+
className: L(e),
|
|
1133
1160
|
...t
|
|
1134
|
-
}),
|
|
1135
|
-
className:
|
|
1161
|
+
}), En = ({ className: e, ...t }) => /* @__PURE__ */ V(S, {
|
|
1162
|
+
className: L(e),
|
|
1136
1163
|
...t
|
|
1137
|
-
}),
|
|
1138
|
-
className:
|
|
1164
|
+
}), Dn = ({ className: e, ...t }) => /* @__PURE__ */ V(w, {
|
|
1165
|
+
className: L(e),
|
|
1139
1166
|
...t
|
|
1140
|
-
}),
|
|
1141
|
-
className:
|
|
1167
|
+
}), On = ({ className: e, ...t }) => /* @__PURE__ */ V(E, {
|
|
1168
|
+
className: L(e),
|
|
1142
1169
|
...t
|
|
1143
|
-
}),
|
|
1170
|
+
}), kn = ({ className: e, children: t, ...n }) => /* @__PURE__ */ H(F, {
|
|
1144
1171
|
className: "w-full overflow-x-auto whitespace-nowrap",
|
|
1145
1172
|
...n,
|
|
1146
|
-
children: [/* @__PURE__ */
|
|
1147
|
-
className:
|
|
1173
|
+
children: [/* @__PURE__ */ V("div", {
|
|
1174
|
+
className: L("flex w-max flex-nowrap items-center gap-2", e),
|
|
1148
1175
|
children: t
|
|
1149
|
-
}), /* @__PURE__ */
|
|
1176
|
+
}), /* @__PURE__ */ V(I, {
|
|
1150
1177
|
className: "hidden",
|
|
1151
1178
|
orientation: "horizontal"
|
|
1152
1179
|
})]
|
|
1153
|
-
}),
|
|
1154
|
-
className:
|
|
1180
|
+
}), An = ({ suggestion: e, onClick: t, className: n, variant: r = "outline", size: i = "sm", children: a, ...o }) => /* @__PURE__ */ V(g, {
|
|
1181
|
+
className: L("cursor-pointer rounded-full px-4", n),
|
|
1155
1182
|
onClick: () => {
|
|
1156
1183
|
t?.(e);
|
|
1157
1184
|
},
|
|
@@ -1160,7 +1187,7 @@ var Ht = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1160
1187
|
variant: r,
|
|
1161
1188
|
...o,
|
|
1162
1189
|
children: a || e
|
|
1163
|
-
}),
|
|
1190
|
+
}), jn = r({ code: "" }), Mn = {
|
|
1164
1191
|
name: "line-numbers",
|
|
1165
1192
|
line(e, t) {
|
|
1166
1193
|
e.children.unshift({
|
|
@@ -1181,21 +1208,21 @@ var Ht = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1181
1208
|
});
|
|
1182
1209
|
}
|
|
1183
1210
|
};
|
|
1184
|
-
async function
|
|
1185
|
-
let r = n ? [
|
|
1186
|
-
return await Promise.all([
|
|
1211
|
+
async function Nn(e, t, n = !1) {
|
|
1212
|
+
let r = n ? [Mn] : [];
|
|
1213
|
+
return await Promise.all([qe(e, {
|
|
1187
1214
|
lang: t,
|
|
1188
1215
|
theme: "one-light",
|
|
1189
1216
|
transformers: r
|
|
1190
|
-
}),
|
|
1217
|
+
}), qe(e, {
|
|
1191
1218
|
lang: t,
|
|
1192
1219
|
theme: "one-dark-pro",
|
|
1193
1220
|
transformers: r
|
|
1194
1221
|
})]);
|
|
1195
1222
|
}
|
|
1196
|
-
var
|
|
1223
|
+
var Q = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children: i, ...a }) => {
|
|
1197
1224
|
let [o, s] = d(""), [l, f] = d(""), p = u(!1);
|
|
1198
|
-
return c(() => (
|
|
1225
|
+
return c(() => (Nn(e, t, n).then(([e, t]) => {
|
|
1199
1226
|
p.current ||= (s(e), f(t), !0);
|
|
1200
1227
|
}), () => {
|
|
1201
1228
|
p.current = !1;
|
|
@@ -1203,23 +1230,23 @@ var $ = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children
|
|
|
1203
1230
|
e,
|
|
1204
1231
|
t,
|
|
1205
1232
|
n
|
|
1206
|
-
]), /* @__PURE__ */
|
|
1233
|
+
]), /* @__PURE__ */ V(jn.Provider, {
|
|
1207
1234
|
value: { code: e },
|
|
1208
|
-
children: /* @__PURE__ */
|
|
1209
|
-
className:
|
|
1235
|
+
children: /* @__PURE__ */ V("div", {
|
|
1236
|
+
className: L("group relative w-full overflow-hidden rounded-md border bg-background text-foreground", r),
|
|
1210
1237
|
...a,
|
|
1211
|
-
children: /* @__PURE__ */
|
|
1238
|
+
children: /* @__PURE__ */ H("div", {
|
|
1212
1239
|
className: "relative",
|
|
1213
1240
|
children: [
|
|
1214
|
-
/* @__PURE__ */
|
|
1241
|
+
/* @__PURE__ */ V("div", {
|
|
1215
1242
|
className: "overflow-auto dark:hidden [&>pre]:m-0 [&>pre]:bg-background! [&>pre]:p-4 [&>pre]:text-foreground! [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm",
|
|
1216
1243
|
dangerouslySetInnerHTML: { __html: o }
|
|
1217
1244
|
}),
|
|
1218
|
-
/* @__PURE__ */
|
|
1245
|
+
/* @__PURE__ */ V("div", {
|
|
1219
1246
|
className: "hidden overflow-auto dark:block [&>pre]:m-0 [&>pre]:bg-background! [&>pre]:p-4 [&>pre]:text-foreground! [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm",
|
|
1220
1247
|
dangerouslySetInnerHTML: { __html: l }
|
|
1221
1248
|
}),
|
|
1222
|
-
i && /* @__PURE__ */
|
|
1249
|
+
i && /* @__PURE__ */ V("div", {
|
|
1223
1250
|
className: "absolute top-2 right-2 flex items-center gap-2",
|
|
1224
1251
|
children: i
|
|
1225
1252
|
})
|
|
@@ -1227,8 +1254,8 @@ var $ = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children
|
|
|
1227
1254
|
})
|
|
1228
1255
|
})
|
|
1229
1256
|
});
|
|
1230
|
-
},
|
|
1231
|
-
let [o, c] = d(!1), { code: l } = s(
|
|
1257
|
+
}, Pn = ({ onCopy: e, onError: t, timeout: n = 2e3, children: r, className: i, ...a }) => {
|
|
1258
|
+
let [o, c] = d(!1), { code: l } = s(jn), u = async () => {
|
|
1232
1259
|
if (typeof window > "u" || !navigator?.clipboard?.writeText) {
|
|
1233
1260
|
t?.(/* @__PURE__ */ Error("Clipboard API not available"));
|
|
1234
1261
|
return;
|
|
@@ -1238,29 +1265,29 @@ var $ = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children
|
|
|
1238
1265
|
} catch (e) {
|
|
1239
1266
|
t?.(e);
|
|
1240
1267
|
}
|
|
1241
|
-
}, f = o ?
|
|
1242
|
-
return /* @__PURE__ */
|
|
1243
|
-
className:
|
|
1268
|
+
}, f = o ? ge : Se;
|
|
1269
|
+
return /* @__PURE__ */ V(g, {
|
|
1270
|
+
className: L("shrink-0", i),
|
|
1244
1271
|
onClick: u,
|
|
1245
1272
|
size: "icon",
|
|
1246
1273
|
variant: "ghost",
|
|
1247
1274
|
...a,
|
|
1248
|
-
children: r ?? /* @__PURE__ */
|
|
1275
|
+
children: r ?? /* @__PURE__ */ V(f, { size: 14 })
|
|
1249
1276
|
});
|
|
1250
|
-
},
|
|
1251
|
-
className:
|
|
1277
|
+
}, Fn = ({ className: e, ...t }) => /* @__PURE__ */ V(_, {
|
|
1278
|
+
className: L("not-prose mb-4 w-full rounded-md border", e),
|
|
1252
1279
|
...t
|
|
1253
|
-
}),
|
|
1280
|
+
}), In = (e) => /* @__PURE__ */ H(h, {
|
|
1254
1281
|
className: "gap-1.5 rounded-full text-xs",
|
|
1255
1282
|
variant: "secondary",
|
|
1256
1283
|
children: [{
|
|
1257
|
-
"input-streaming": /* @__PURE__ */
|
|
1258
|
-
"input-available": /* @__PURE__ */
|
|
1259
|
-
"approval-requested": /* @__PURE__ */
|
|
1260
|
-
"approval-responded": /* @__PURE__ */
|
|
1261
|
-
"output-available": /* @__PURE__ */
|
|
1262
|
-
"output-error": /* @__PURE__ */
|
|
1263
|
-
"output-denied": /* @__PURE__ */
|
|
1284
|
+
"input-streaming": /* @__PURE__ */ V(ye, { className: "size-4" }),
|
|
1285
|
+
"input-available": /* @__PURE__ */ V(be, { className: "size-4 animate-pulse" }),
|
|
1286
|
+
"approval-requested": /* @__PURE__ */ V(be, { className: "size-4 text-yellow-600" }),
|
|
1287
|
+
"approval-responded": /* @__PURE__ */ V(he, { className: "size-4 text-blue-600" }),
|
|
1288
|
+
"output-available": /* @__PURE__ */ V(he, { className: "size-4 text-green-600" }),
|
|
1289
|
+
"output-error": /* @__PURE__ */ V(Le, { className: "size-4 text-red-600" }),
|
|
1290
|
+
"output-denied": /* @__PURE__ */ V(Le, { className: "size-4 text-orange-600" })
|
|
1264
1291
|
}[e], {
|
|
1265
1292
|
"input-streaming": "Pending",
|
|
1266
1293
|
"input-available": "Running",
|
|
@@ -1270,61 +1297,61 @@ var $ = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children
|
|
|
1270
1297
|
"output-error": "Error",
|
|
1271
1298
|
"output-denied": "Denied"
|
|
1272
1299
|
}[e]]
|
|
1273
|
-
}),
|
|
1274
|
-
className:
|
|
1300
|
+
}), Ln = ({ className: e, title: t, type: n, state: r, ...i }) => /* @__PURE__ */ H(y, {
|
|
1301
|
+
className: L("flex w-full items-center justify-between gap-4 p-3", e),
|
|
1275
1302
|
...i,
|
|
1276
|
-
children: [/* @__PURE__ */
|
|
1303
|
+
children: [/* @__PURE__ */ H("div", {
|
|
1277
1304
|
className: "flex items-center gap-2",
|
|
1278
1305
|
children: [
|
|
1279
|
-
/* @__PURE__ */
|
|
1280
|
-
/* @__PURE__ */
|
|
1306
|
+
/* @__PURE__ */ V(Fe, { className: "size-4 text-muted-foreground" }),
|
|
1307
|
+
/* @__PURE__ */ V("span", {
|
|
1281
1308
|
className: "font-medium text-sm",
|
|
1282
1309
|
children: t ?? n.split("-").slice(1).join("-")
|
|
1283
1310
|
}),
|
|
1284
|
-
|
|
1311
|
+
In(r)
|
|
1285
1312
|
]
|
|
1286
|
-
}), /* @__PURE__ */
|
|
1287
|
-
}),
|
|
1288
|
-
className:
|
|
1313
|
+
}), /* @__PURE__ */ V(R, { className: "size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180" })]
|
|
1314
|
+
}), Rn = ({ className: e, ...t }) => /* @__PURE__ */ V(v, {
|
|
1315
|
+
className: L("data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in", e),
|
|
1289
1316
|
...t
|
|
1290
|
-
}),
|
|
1291
|
-
className:
|
|
1317
|
+
}), zn = ({ className: e, input: t, ...n }) => /* @__PURE__ */ H("div", {
|
|
1318
|
+
className: L("space-y-2 overflow-hidden p-4", e),
|
|
1292
1319
|
...n,
|
|
1293
|
-
children: [/* @__PURE__ */
|
|
1320
|
+
children: [/* @__PURE__ */ V("h4", {
|
|
1294
1321
|
className: "font-medium text-muted-foreground text-xs uppercase tracking-wide",
|
|
1295
1322
|
children: "Parameters"
|
|
1296
|
-
}), /* @__PURE__ */
|
|
1323
|
+
}), /* @__PURE__ */ V("div", {
|
|
1297
1324
|
className: "rounded-md bg-muted/50",
|
|
1298
|
-
children: /* @__PURE__ */
|
|
1325
|
+
children: /* @__PURE__ */ V(Q, {
|
|
1299
1326
|
code: JSON.stringify(t, null, 2),
|
|
1300
1327
|
language: "json"
|
|
1301
1328
|
})
|
|
1302
1329
|
})]
|
|
1303
|
-
}),
|
|
1330
|
+
}), Bn = ({ className: e, output: t, errorText: n, ...r }) => {
|
|
1304
1331
|
if (!(t || n)) return null;
|
|
1305
|
-
let a = /* @__PURE__ */
|
|
1306
|
-
return typeof t == "object" && !i(t) ? a = /* @__PURE__ */
|
|
1332
|
+
let a = /* @__PURE__ */ V("div", { children: t });
|
|
1333
|
+
return typeof t == "object" && !i(t) ? a = /* @__PURE__ */ V(Q, {
|
|
1307
1334
|
code: JSON.stringify(t, null, 2),
|
|
1308
1335
|
language: "json"
|
|
1309
|
-
}) : typeof t == "string" && (a = /* @__PURE__ */
|
|
1336
|
+
}) : typeof t == "string" && (a = /* @__PURE__ */ V(Q, {
|
|
1310
1337
|
code: t,
|
|
1311
1338
|
language: "json"
|
|
1312
|
-
})), /* @__PURE__ */
|
|
1313
|
-
className:
|
|
1339
|
+
})), /* @__PURE__ */ H("div", {
|
|
1340
|
+
className: L("space-y-2 p-4", e),
|
|
1314
1341
|
...r,
|
|
1315
|
-
children: [/* @__PURE__ */
|
|
1342
|
+
children: [/* @__PURE__ */ V("h4", {
|
|
1316
1343
|
className: "font-medium text-muted-foreground text-xs uppercase tracking-wide",
|
|
1317
1344
|
children: n ? "Error" : "Result"
|
|
1318
|
-
}), /* @__PURE__ */
|
|
1319
|
-
className:
|
|
1320
|
-
children: [n && /* @__PURE__ */
|
|
1345
|
+
}), /* @__PURE__ */ H("div", {
|
|
1346
|
+
className: L("overflow-x-auto rounded-md text-xs [&_table]:w-full", n ? "bg-destructive/10 text-destructive" : "bg-muted/50 text-foreground"),
|
|
1347
|
+
children: [n && /* @__PURE__ */ V("div", { children: n }), a]
|
|
1321
1348
|
})]
|
|
1322
1349
|
});
|
|
1323
|
-
},
|
|
1324
|
-
let a =
|
|
1325
|
-
return /* @__PURE__ */
|
|
1350
|
+
}, Vn = a(({ children: e, as: t = "p", className: n, duration: r = 2, spread: i = 2 }) => {
|
|
1351
|
+
let a = Ye.create(t), o = l(() => (e?.length ?? 0) * i, [e, i]);
|
|
1352
|
+
return /* @__PURE__ */ V(a, {
|
|
1326
1353
|
animate: { backgroundPosition: "0% center" },
|
|
1327
|
-
className:
|
|
1354
|
+
className: L("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent", "[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]", n),
|
|
1328
1355
|
initial: { backgroundPosition: "100% center" },
|
|
1329
1356
|
style: {
|
|
1330
1357
|
"--spread": `${o}px`,
|
|
@@ -1337,21 +1364,21 @@ var $ = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children
|
|
|
1337
1364
|
},
|
|
1338
1365
|
children: e
|
|
1339
1366
|
});
|
|
1340
|
-
}),
|
|
1341
|
-
let e = s(
|
|
1367
|
+
}), Hn = r(null), Un = () => {
|
|
1368
|
+
let e = s(Hn);
|
|
1342
1369
|
if (!e) throw Error("Reasoning components must be used within Reasoning");
|
|
1343
1370
|
return e;
|
|
1344
|
-
},
|
|
1345
|
-
let [l, u] =
|
|
1371
|
+
}, Wn = 1e3, Gn = 1e3, Kn = a(({ className: e, isStreaming: t = !1, open: n, defaultOpen: r = !0, onOpenChange: i, duration: a, children: o, ...s }) => {
|
|
1372
|
+
let [l, u] = Je({
|
|
1346
1373
|
prop: n,
|
|
1347
1374
|
defaultProp: r,
|
|
1348
1375
|
onChange: i
|
|
1349
|
-
}), [f, p] =
|
|
1376
|
+
}), [f, p] = Je({
|
|
1350
1377
|
prop: a,
|
|
1351
1378
|
defaultProp: void 0
|
|
1352
1379
|
}), [m, h] = d(!1), [g, v] = d(null);
|
|
1353
1380
|
return c(() => {
|
|
1354
|
-
t ? g === null && v(Date.now()) : g !== null && (p(Math.ceil((Date.now() - g) /
|
|
1381
|
+
t ? g === null && v(Date.now()) : g !== null && (p(Math.ceil((Date.now() - g) / Gn)), v(null));
|
|
1355
1382
|
}, [
|
|
1356
1383
|
t,
|
|
1357
1384
|
g,
|
|
@@ -1360,7 +1387,7 @@ var $ = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children
|
|
|
1360
1387
|
if (r && !t && l && !m) {
|
|
1361
1388
|
let e = setTimeout(() => {
|
|
1362
1389
|
u(!1), h(!0);
|
|
1363
|
-
},
|
|
1390
|
+
}, Wn);
|
|
1364
1391
|
return () => clearTimeout(e);
|
|
1365
1392
|
}
|
|
1366
1393
|
}, [
|
|
@@ -1369,15 +1396,15 @@ var $ = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children
|
|
|
1369
1396
|
r,
|
|
1370
1397
|
u,
|
|
1371
1398
|
m
|
|
1372
|
-
]), /* @__PURE__ */
|
|
1399
|
+
]), /* @__PURE__ */ V(Hn.Provider, {
|
|
1373
1400
|
value: {
|
|
1374
1401
|
isStreaming: t,
|
|
1375
1402
|
isOpen: l,
|
|
1376
1403
|
setIsOpen: u,
|
|
1377
1404
|
duration: f
|
|
1378
1405
|
},
|
|
1379
|
-
children: /* @__PURE__ */
|
|
1380
|
-
className:
|
|
1406
|
+
children: /* @__PURE__ */ V(_, {
|
|
1407
|
+
className: L("not-prose mb-4", e),
|
|
1381
1408
|
onOpenChange: (e) => {
|
|
1382
1409
|
u(e);
|
|
1383
1410
|
},
|
|
@@ -1386,167 +1413,188 @@ var $ = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children
|
|
|
1386
1413
|
children: o
|
|
1387
1414
|
})
|
|
1388
1415
|
});
|
|
1389
|
-
}),
|
|
1416
|
+
}), qn = (e, t) => e || t === 0 ? /* @__PURE__ */ V(Vn, {
|
|
1390
1417
|
duration: 1,
|
|
1391
1418
|
children: "Thinking..."
|
|
1392
|
-
}) : t === void 0 ? /* @__PURE__ */
|
|
1419
|
+
}) : t === void 0 ? /* @__PURE__ */ V("p", { children: "Thought for a few seconds" }) : /* @__PURE__ */ H("p", { children: [
|
|
1393
1420
|
"Thought for ",
|
|
1394
1421
|
t,
|
|
1395
1422
|
" seconds"
|
|
1396
|
-
] }),
|
|
1397
|
-
let { isStreaming: i, isOpen: a, duration: o } =
|
|
1398
|
-
return /* @__PURE__ */
|
|
1399
|
-
className:
|
|
1423
|
+
] }), Jn = a(({ className: e, children: t, getThinkingMessage: n = qn, ...r }) => {
|
|
1424
|
+
let { isStreaming: i, isOpen: a, duration: o } = Un();
|
|
1425
|
+
return /* @__PURE__ */ V(y, {
|
|
1426
|
+
className: L("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground", e),
|
|
1400
1427
|
...r,
|
|
1401
|
-
children: t ?? /* @__PURE__ */
|
|
1402
|
-
/* @__PURE__ */
|
|
1428
|
+
children: t ?? /* @__PURE__ */ H(B, { children: [
|
|
1429
|
+
/* @__PURE__ */ V(pe, { className: "size-4" }),
|
|
1403
1430
|
n(i, o),
|
|
1404
|
-
/* @__PURE__ */
|
|
1431
|
+
/* @__PURE__ */ V(R, { className: L("size-4 transition-transform", a ? "rotate-180" : "rotate-0") })
|
|
1405
1432
|
] })
|
|
1406
1433
|
});
|
|
1407
|
-
}),
|
|
1408
|
-
className:
|
|
1434
|
+
}), Yn = a(({ className: e, children: t, ...n }) => /* @__PURE__ */ V(v, {
|
|
1435
|
+
className: L("mt-4 text-sm", "data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in", e),
|
|
1409
1436
|
...n,
|
|
1410
|
-
children: /* @__PURE__ */
|
|
1437
|
+
children: /* @__PURE__ */ V(Ge, {
|
|
1411
1438
|
...n,
|
|
1412
1439
|
children: t
|
|
1413
1440
|
})
|
|
1414
1441
|
}));
|
|
1415
|
-
|
|
1442
|
+
Kn.displayName = "Reasoning", Jn.displayName = "ReasoningTrigger", Yn.displayName = "ReasoningContent";
|
|
1416
1443
|
//#endregion
|
|
1417
1444
|
//#region src/elements/sources.tsx
|
|
1418
|
-
var
|
|
1419
|
-
className:
|
|
1445
|
+
var Xn = ({ className: e, ...t }) => /* @__PURE__ */ V(_, {
|
|
1446
|
+
className: L("not-prose mb-4 text-primary text-xs", e),
|
|
1420
1447
|
...t
|
|
1421
|
-
}),
|
|
1422
|
-
className:
|
|
1448
|
+
}), Zn = ({ className: e, count: t, children: n, ...r }) => /* @__PURE__ */ V(y, {
|
|
1449
|
+
className: L("flex items-center gap-2", e),
|
|
1423
1450
|
...r,
|
|
1424
|
-
children: n ?? /* @__PURE__ */
|
|
1451
|
+
children: n ?? /* @__PURE__ */ H(B, { children: [/* @__PURE__ */ H("p", {
|
|
1425
1452
|
className: "font-medium",
|
|
1426
1453
|
children: [
|
|
1427
1454
|
"Used ",
|
|
1428
1455
|
t,
|
|
1429
1456
|
" sources"
|
|
1430
1457
|
]
|
|
1431
|
-
}), /* @__PURE__ */
|
|
1432
|
-
}),
|
|
1433
|
-
className:
|
|
1458
|
+
}), /* @__PURE__ */ V(R, { className: "h-4 w-4" })] })
|
|
1459
|
+
}), Qn = ({ className: e, ...t }) => /* @__PURE__ */ V(v, {
|
|
1460
|
+
className: L("mt-3 flex w-fit flex-col gap-2", "data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 outline-none data-[state=closed]:animate-out data-[state=open]:animate-in", e),
|
|
1434
1461
|
...t
|
|
1435
|
-
}),
|
|
1462
|
+
}), $n = ({ href: e, title: t, children: n, ...r }) => /* @__PURE__ */ V("a", {
|
|
1436
1463
|
className: "flex items-center gap-2",
|
|
1437
1464
|
href: e,
|
|
1438
1465
|
rel: "noreferrer",
|
|
1439
1466
|
target: "_blank",
|
|
1440
1467
|
...r,
|
|
1441
|
-
children: n ?? /* @__PURE__ */
|
|
1468
|
+
children: n ?? /* @__PURE__ */ H(B, { children: [/* @__PURE__ */ V(fe, { className: "h-4 w-4" }), /* @__PURE__ */ V("span", {
|
|
1442
1469
|
className: "block font-medium",
|
|
1443
1470
|
children: t
|
|
1444
1471
|
})] })
|
|
1445
1472
|
});
|
|
1446
1473
|
//#endregion
|
|
1447
1474
|
//#region src/ChatbotEnhanced.tsx
|
|
1448
|
-
function
|
|
1475
|
+
function er(e, t) {
|
|
1449
1476
|
return t ? "error" : e ? "streaming" : "ready";
|
|
1450
1477
|
}
|
|
1451
|
-
function
|
|
1478
|
+
function tr(e) {
|
|
1452
1479
|
return e === "user" ? "user" : "assistant";
|
|
1453
1480
|
}
|
|
1454
|
-
var
|
|
1455
|
-
let
|
|
1481
|
+
var $ = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type your message...", onSendMessage: i, onClear: a, onStop: o, onReload: s, disabled: c = !1, isLoading: l = !1, error: u, showTimestamp: d = !1, userAvatarUrl: f, userAvatarFallback: p = "You", assistantAvatarUrl: m, assistantAvatarFallback: h = "AI", maxHeight: g = "500px", enableMarkdown: _ = !0, enableFileUpload: v = !1, acceptedFileTypes: y = "image/*,.pdf,.doc,.docx,.txt", maxFileSize: b = 10 * 1024 * 1024, suggestions: x, models: S, selectedModelId: C, onModelChange: w, headerSlot: T, promptOverlaySlot: E, onInputChange: D, onToolApprove: O, toolApproveLabel: k = "Approve", toolDenyLabel: A = "Deny", toolDenyReason: j = "User denied the operation", ...M }, N) => {
|
|
1482
|
+
let P = er(l, u), [F, I] = e.useState(null), ee = e.useCallback((e) => {
|
|
1456
1483
|
let t = !!e.text?.trim(), n = e.files?.map((e) => e.file).filter(Boolean), r = !!(n && n.length > 0);
|
|
1457
1484
|
(t || r) && i?.(e.text?.trim() ?? "", n);
|
|
1458
|
-
}, [i]),
|
|
1485
|
+
}, [i]), te = e.useCallback((e) => {
|
|
1459
1486
|
i?.(e);
|
|
1460
|
-
}, [i]),
|
|
1461
|
-
navigator.clipboard?.writeText(e.content),
|
|
1487
|
+
}, [i]), ne = e.useCallback((e) => {
|
|
1488
|
+
navigator.clipboard?.writeText(e.content), I(e.id), window.setTimeout(() => I((t) => t === e.id ? null : t), 1500);
|
|
1462
1489
|
}, []);
|
|
1463
|
-
return /* @__PURE__ */
|
|
1464
|
-
ref:
|
|
1465
|
-
className:
|
|
1490
|
+
return /* @__PURE__ */ H("div", {
|
|
1491
|
+
ref: N,
|
|
1492
|
+
className: L("flex flex-col border rounded-lg bg-background overflow-hidden", t),
|
|
1466
1493
|
style: { maxHeight: g },
|
|
1467
|
-
...
|
|
1494
|
+
...M,
|
|
1468
1495
|
children: [
|
|
1469
|
-
a && n.length > 0 && /* @__PURE__ */
|
|
1496
|
+
a && n.length > 0 && /* @__PURE__ */ H("div", {
|
|
1470
1497
|
className: "flex items-center justify-between px-4 py-2 border-b bg-muted/30",
|
|
1471
|
-
children: [/* @__PURE__ */
|
|
1498
|
+
children: [/* @__PURE__ */ H("span", {
|
|
1472
1499
|
className: "text-sm text-muted-foreground",
|
|
1473
1500
|
children: [
|
|
1474
1501
|
n.length,
|
|
1475
1502
|
" message",
|
|
1476
1503
|
n.length === 1 ? "" : "s"
|
|
1477
1504
|
]
|
|
1478
|
-
}), /* @__PURE__ */
|
|
1505
|
+
}), /* @__PURE__ */ V("button", {
|
|
1479
1506
|
type: "button",
|
|
1480
1507
|
onClick: a,
|
|
1481
1508
|
className: "text-xs text-muted-foreground hover:text-foreground transition-colors",
|
|
1482
1509
|
children: "Clear"
|
|
1483
1510
|
})]
|
|
1484
1511
|
}),
|
|
1485
|
-
/* @__PURE__ */ V(
|
|
1512
|
+
T ? /* @__PURE__ */ V("div", {
|
|
1513
|
+
className: "shrink-0 border-b bg-background/50",
|
|
1514
|
+
children: T
|
|
1515
|
+
}) : null,
|
|
1516
|
+
/* @__PURE__ */ H(ft, {
|
|
1486
1517
|
className: "flex-1 min-h-0",
|
|
1487
|
-
children: [/* @__PURE__ */
|
|
1518
|
+
children: [/* @__PURE__ */ V(pt, {
|
|
1488
1519
|
className: "space-y-4 px-4 py-3",
|
|
1489
|
-
children: n.length === 0 ? /* @__PURE__ */
|
|
1520
|
+
children: n.length === 0 ? /* @__PURE__ */ V(mt, {
|
|
1490
1521
|
title: "Start a conversation",
|
|
1491
1522
|
description: "Ask anything — the assistant has access to your current app context.",
|
|
1492
|
-
children: x && x.length > 0 ? /* @__PURE__ */
|
|
1523
|
+
children: x && x.length > 0 ? /* @__PURE__ */ V(kn, {
|
|
1493
1524
|
className: "justify-center pt-2",
|
|
1494
|
-
children: x.map((e) => /* @__PURE__ */
|
|
1525
|
+
children: x.map((e) => /* @__PURE__ */ V(An, {
|
|
1495
1526
|
suggestion: e,
|
|
1496
|
-
onClick:
|
|
1527
|
+
onClick: te
|
|
1497
1528
|
}, e))
|
|
1498
1529
|
}) : null
|
|
1499
1530
|
}) : n.map((e) => {
|
|
1500
1531
|
let t = e.role === "user", n = e.toolInvocations ?? [], r = e.reasoning?.trim(), i = e.sources ?? [];
|
|
1501
|
-
return /* @__PURE__ */
|
|
1502
|
-
from:
|
|
1503
|
-
children: [/* @__PURE__ */
|
|
1504
|
-
!t && r ? /* @__PURE__ */
|
|
1532
|
+
return /* @__PURE__ */ H(yt, {
|
|
1533
|
+
from: tr(e.role),
|
|
1534
|
+
children: [/* @__PURE__ */ H(bt, { children: [
|
|
1535
|
+
!t && r ? /* @__PURE__ */ H(Kn, {
|
|
1505
1536
|
isStreaming: !!e.streaming && !e.content,
|
|
1506
1537
|
className: "mb-2",
|
|
1507
|
-
children: [/* @__PURE__ */
|
|
1538
|
+
children: [/* @__PURE__ */ V(Jn, {}), /* @__PURE__ */ V(Yn, { children: r })]
|
|
1508
1539
|
}) : null,
|
|
1509
1540
|
!t && n.length > 0 ? n.map((e) => {
|
|
1510
|
-
let t = e.state ?? (e.errorText ? "output-error" : e.result === void 0 ? "input-available" : "output-available"), n = `tool-${e.toolName}
|
|
1511
|
-
return /* @__PURE__ */
|
|
1541
|
+
let t = e.state ?? (e.errorText ? "output-error" : e.result === void 0 ? "input-available" : "output-available"), n = `tool-${e.toolName}`, r = t === "approval-requested" && !!O;
|
|
1542
|
+
return /* @__PURE__ */ H(Fn, {
|
|
1512
1543
|
defaultOpen: t !== "output-available",
|
|
1513
|
-
children: [/* @__PURE__ */
|
|
1544
|
+
children: [/* @__PURE__ */ V(Ln, {
|
|
1514
1545
|
type: n,
|
|
1515
1546
|
state: t,
|
|
1516
1547
|
title: e.toolName
|
|
1517
|
-
}), /* @__PURE__ */
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1548
|
+
}), /* @__PURE__ */ H(Rn, { children: [
|
|
1549
|
+
e.args === void 0 ? null : /* @__PURE__ */ V(zn, { input: e.args }),
|
|
1550
|
+
/* @__PURE__ */ V(Bn, {
|
|
1551
|
+
output: e.result,
|
|
1552
|
+
errorText: e.errorText
|
|
1553
|
+
}),
|
|
1554
|
+
r ? /* @__PURE__ */ H("div", {
|
|
1555
|
+
className: "flex gap-2 p-3 border-t bg-muted/30",
|
|
1556
|
+
children: [/* @__PURE__ */ V("button", {
|
|
1557
|
+
type: "button",
|
|
1558
|
+
onClick: () => O?.(e.toolCallId, !0),
|
|
1559
|
+
className: "inline-flex h-7 items-center rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90",
|
|
1560
|
+
children: k
|
|
1561
|
+
}), /* @__PURE__ */ V("button", {
|
|
1562
|
+
type: "button",
|
|
1563
|
+
onClick: () => O?.(e.toolCallId, !1, j),
|
|
1564
|
+
className: "inline-flex h-7 items-center rounded-md border bg-background px-3 text-xs font-medium hover:bg-accent",
|
|
1565
|
+
children: A
|
|
1566
|
+
})]
|
|
1567
|
+
}) : null
|
|
1568
|
+
] })]
|
|
1521
1569
|
}, e.toolCallId);
|
|
1522
1570
|
}) : null,
|
|
1523
1571
|
e.content,
|
|
1524
|
-
e.streaming ? /* @__PURE__ */
|
|
1572
|
+
e.streaming ? /* @__PURE__ */ V("span", {
|
|
1525
1573
|
"aria-hidden": !0,
|
|
1526
1574
|
className: "ml-0.5 inline-block w-[2px] h-4 align-middle bg-current animate-pulse"
|
|
1527
1575
|
}) : null,
|
|
1528
|
-
!t && i.length > 0 ? /* @__PURE__ */
|
|
1576
|
+
!t && i.length > 0 ? /* @__PURE__ */ H(Xn, { children: [/* @__PURE__ */ V(Zn, { count: i.length }), /* @__PURE__ */ V(Qn, { children: i.map((e, t) => /* @__PURE__ */ V($n, {
|
|
1529
1577
|
href: e.url,
|
|
1530
1578
|
title: e.title ?? e.url
|
|
1531
1579
|
}, e.id ?? e.url ?? t)) })] }) : null,
|
|
1532
|
-
d && e.timestamp ? /* @__PURE__ */
|
|
1580
|
+
d && e.timestamp ? /* @__PURE__ */ V("div", {
|
|
1533
1581
|
className: "text-[10px] opacity-70 mt-1",
|
|
1534
1582
|
children: e.timestamp
|
|
1535
1583
|
}) : null
|
|
1536
|
-
] }), t ? null : /* @__PURE__ */
|
|
1537
|
-
/* @__PURE__ */
|
|
1584
|
+
] }), t ? null : /* @__PURE__ */ H(xt, { children: [
|
|
1585
|
+
/* @__PURE__ */ V(J, {
|
|
1538
1586
|
label: "Copy",
|
|
1539
1587
|
tooltip: "Copy",
|
|
1540
|
-
onClick: () =>
|
|
1541
|
-
children:
|
|
1588
|
+
onClick: () => ne(e),
|
|
1589
|
+
children: F === e.id ? /* @__PURE__ */ V(me, { className: "size-3.5" }) : /* @__PURE__ */ V(xe, { className: "size-3.5" })
|
|
1542
1590
|
}),
|
|
1543
|
-
s ? /* @__PURE__ */
|
|
1591
|
+
s ? /* @__PURE__ */ V(J, {
|
|
1544
1592
|
label: "Regenerate",
|
|
1545
1593
|
tooltip: "Regenerate",
|
|
1546
1594
|
onClick: s,
|
|
1547
|
-
children: /* @__PURE__ */
|
|
1595
|
+
children: /* @__PURE__ */ V(Me, { className: "size-3.5" })
|
|
1548
1596
|
}) : null,
|
|
1549
|
-
e.traceId ? /* @__PURE__ */
|
|
1597
|
+
e.traceId ? /* @__PURE__ */ V("a", {
|
|
1550
1598
|
href: `#trace/${e.traceId}`,
|
|
1551
1599
|
"data-trace-id": e.traceId,
|
|
1552
1600
|
className: "text-[10px] text-muted-foreground hover:text-foreground ml-1 underline",
|
|
@@ -1556,18 +1604,18 @@ var Yn = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
1556
1604
|
] })]
|
|
1557
1605
|
}, e.id);
|
|
1558
1606
|
})
|
|
1559
|
-
}), /* @__PURE__ */
|
|
1607
|
+
}), /* @__PURE__ */ V(ht, {})]
|
|
1560
1608
|
}),
|
|
1561
|
-
u ? /* @__PURE__ */
|
|
1609
|
+
u ? /* @__PURE__ */ H("div", {
|
|
1562
1610
|
className: "flex items-center gap-2 px-4 py-2 border-t bg-destructive/10 text-destructive text-sm",
|
|
1563
1611
|
role: "alert",
|
|
1564
1612
|
children: [
|
|
1565
|
-
/* @__PURE__ */
|
|
1566
|
-
/* @__PURE__ */
|
|
1613
|
+
/* @__PURE__ */ V(ue, { className: "h-4 w-4 shrink-0" }),
|
|
1614
|
+
/* @__PURE__ */ V("span", {
|
|
1567
1615
|
className: "flex-1 truncate",
|
|
1568
1616
|
children: u.message || "An error occurred"
|
|
1569
1617
|
}),
|
|
1570
|
-
s ? /* @__PURE__ */
|
|
1618
|
+
s ? /* @__PURE__ */ V("button", {
|
|
1571
1619
|
type: "button",
|
|
1572
1620
|
onClick: s,
|
|
1573
1621
|
className: "text-xs underline hover:no-underline",
|
|
@@ -1575,36 +1623,43 @@ var Yn = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
1575
1623
|
}) : null
|
|
1576
1624
|
]
|
|
1577
1625
|
}) : null,
|
|
1578
|
-
/* @__PURE__ */
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1626
|
+
/* @__PURE__ */ H("div", {
|
|
1627
|
+
className: "relative",
|
|
1628
|
+
children: [E ? /* @__PURE__ */ V("div", {
|
|
1629
|
+
className: "absolute bottom-full left-0 right-0 z-10 px-3 pb-1",
|
|
1630
|
+
children: E
|
|
1631
|
+
}) : null, /* @__PURE__ */ H(Yt, {
|
|
1632
|
+
accept: y,
|
|
1633
|
+
maxFileSize: b,
|
|
1634
|
+
onSubmit: ee,
|
|
1635
|
+
onError: (e) => {
|
|
1636
|
+
console.warn("[plugin-chatbot] prompt-input error", e);
|
|
1637
|
+
},
|
|
1638
|
+
children: [
|
|
1639
|
+
v ? /* @__PURE__ */ V(Xt, { children: /* @__PURE__ */ V(qt, { children: (e) => /* @__PURE__ */ V(Kt, { data: e }) }) }) : null,
|
|
1640
|
+
/* @__PURE__ */ V(Zt, {
|
|
1641
|
+
placeholder: r,
|
|
1642
|
+
disabled: c || P === "streaming",
|
|
1643
|
+
onChange: D ? (e) => D(e.currentTarget.value) : void 0
|
|
1644
|
+
}),
|
|
1645
|
+
/* @__PURE__ */ H($t, { children: [/* @__PURE__ */ H(en, { children: [v ? /* @__PURE__ */ H(nn, { children: [/* @__PURE__ */ V(rn, {}), /* @__PURE__ */ V(an, { children: /* @__PURE__ */ V(Jt, {}) })] }) : null, S && S.length > 0 ? /* @__PURE__ */ V("select", {
|
|
1646
|
+
"aria-label": "Model",
|
|
1647
|
+
value: C ?? S[0].id,
|
|
1648
|
+
onChange: (e) => w?.(e.target.value),
|
|
1649
|
+
className: "h-7 rounded-md border bg-background px-2 text-xs text-muted-foreground hover:text-foreground focus:outline-none focus:ring-1 focus:ring-ring",
|
|
1650
|
+
children: S.map((e) => /* @__PURE__ */ H("option", {
|
|
1651
|
+
value: e.id,
|
|
1652
|
+
children: [e.label ?? e.id, e.provider ? ` · ${e.provider}` : ""]
|
|
1653
|
+
}, e.id))
|
|
1654
|
+
}) : null] }), /* @__PURE__ */ V(sn, {
|
|
1655
|
+
status: P,
|
|
1656
|
+
disabled: c,
|
|
1657
|
+
onClick: P === "streaming" ? o : void 0
|
|
1658
|
+
})] })
|
|
1659
|
+
]
|
|
1660
|
+
})]
|
|
1606
1661
|
}),
|
|
1607
|
-
/* @__PURE__ */
|
|
1662
|
+
/* @__PURE__ */ V("span", {
|
|
1608
1663
|
hidden: !0,
|
|
1609
1664
|
"data-avatar-user": f ?? p,
|
|
1610
1665
|
"data-avatar-assistant": m ?? h
|
|
@@ -1612,10 +1667,10 @@ var Yn = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
1612
1667
|
]
|
|
1613
1668
|
});
|
|
1614
1669
|
});
|
|
1615
|
-
|
|
1670
|
+
$.displayName = "ChatbotEnhanced";
|
|
1616
1671
|
//#endregion
|
|
1617
1672
|
//#region src/FloatingChatbot.tsx
|
|
1618
|
-
function
|
|
1673
|
+
function nr({ floatingConfig: t, headerExtra: n, ...r }) {
|
|
1619
1674
|
let { position: i = "bottom-right", defaultOpen: a = !1, panelWidth: o = 400, panelHeight: s = 520, title: c = "Chat", triggerSize: l = 56 } = t ?? {}, [u, d] = e.useState(null);
|
|
1620
1675
|
e.useEffect(() => {
|
|
1621
1676
|
let e = document.getElementById("floating-chatbot-portal");
|
|
@@ -1623,28 +1678,28 @@ function Xn({ floatingConfig: t, headerExtra: n, ...r }) {
|
|
|
1623
1678
|
e && e.parentNode && !e.hasChildNodes() && e.parentNode.removeChild(e);
|
|
1624
1679
|
};
|
|
1625
1680
|
}, []);
|
|
1626
|
-
let f = /* @__PURE__ */
|
|
1681
|
+
let f = /* @__PURE__ */ H(ct, {
|
|
1627
1682
|
defaultOpen: a,
|
|
1628
|
-
children: [/* @__PURE__ */
|
|
1683
|
+
children: [/* @__PURE__ */ V(ut, {
|
|
1629
1684
|
position: i,
|
|
1630
1685
|
size: l
|
|
1631
|
-
}), /* @__PURE__ */
|
|
1686
|
+
}), /* @__PURE__ */ V(dt, {
|
|
1632
1687
|
title: c,
|
|
1633
1688
|
position: i,
|
|
1634
1689
|
width: o,
|
|
1635
1690
|
height: s,
|
|
1636
1691
|
headerExtra: n,
|
|
1637
|
-
children: /* @__PURE__ */
|
|
1692
|
+
children: /* @__PURE__ */ V($, {
|
|
1638
1693
|
...r,
|
|
1639
1694
|
maxHeight: "100%",
|
|
1640
1695
|
className: "h-full border-0 rounded-none"
|
|
1641
1696
|
})
|
|
1642
1697
|
})]
|
|
1643
1698
|
});
|
|
1644
|
-
return u ?
|
|
1699
|
+
return u ? Be.createPortal(f, u) : f;
|
|
1645
1700
|
}
|
|
1646
|
-
|
|
1647
|
-
let { messages: r, isLoading: i, sendMessage: a } =
|
|
1701
|
+
W.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
1702
|
+
let { messages: r, isLoading: i, sendMessage: a } = K({
|
|
1648
1703
|
api: e.api,
|
|
1649
1704
|
initialMessages: e.messages,
|
|
1650
1705
|
conversationId: e.conversationId,
|
|
@@ -1661,7 +1716,7 @@ U.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
1661
1716
|
autoResponseDelay: e.autoResponseDelay,
|
|
1662
1717
|
onSend: e.onSend
|
|
1663
1718
|
});
|
|
1664
|
-
return /* @__PURE__ */
|
|
1719
|
+
return /* @__PURE__ */ V(or, {
|
|
1665
1720
|
messages: r,
|
|
1666
1721
|
placeholder: e.placeholder,
|
|
1667
1722
|
onSendMessage: (e) => {
|
|
@@ -1809,8 +1864,8 @@ U.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
1809
1864
|
autoResponseDelay: 1e3,
|
|
1810
1865
|
className: "w-full max-w-2xl"
|
|
1811
1866
|
}
|
|
1812
|
-
}),
|
|
1813
|
-
let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: l, isApiMode: u } =
|
|
1867
|
+
}), W.register("chatbot-enhanced", ({ schema: e, className: t, ...n }) => {
|
|
1868
|
+
let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: l, isApiMode: u } = K({
|
|
1814
1869
|
api: e.api,
|
|
1815
1870
|
initialMessages: e.messages,
|
|
1816
1871
|
conversationId: e.conversationId,
|
|
@@ -1827,7 +1882,7 @@ U.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
1827
1882
|
autoResponseDelay: e.autoResponseDelay,
|
|
1828
1883
|
onSend: e.onSend
|
|
1829
1884
|
});
|
|
1830
|
-
return /* @__PURE__ */
|
|
1885
|
+
return /* @__PURE__ */ V($, {
|
|
1831
1886
|
messages: r,
|
|
1832
1887
|
placeholder: e.placeholder,
|
|
1833
1888
|
onSendMessage: (e, t) => {
|
|
@@ -1989,8 +2044,8 @@ U.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
1989
2044
|
autoResponseDelay: 1e3,
|
|
1990
2045
|
className: "w-full max-w-2xl"
|
|
1991
2046
|
}
|
|
1992
|
-
}),
|
|
1993
|
-
let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: l, isApiMode: u } =
|
|
2047
|
+
}), W.register("chatbot-floating", ({ schema: e, className: t, ...n }) => {
|
|
2048
|
+
let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: l, isApiMode: u } = K({
|
|
1994
2049
|
api: e.api,
|
|
1995
2050
|
initialMessages: e.messages,
|
|
1996
2051
|
conversationId: e.conversationId,
|
|
@@ -2007,7 +2062,7 @@ U.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
2007
2062
|
autoResponseDelay: e.autoResponseDelay,
|
|
2008
2063
|
onSend: e.onSend
|
|
2009
2064
|
});
|
|
2010
|
-
return /* @__PURE__ */
|
|
2065
|
+
return /* @__PURE__ */ V(nr, {
|
|
2011
2066
|
floatingConfig: e.floatingConfig,
|
|
2012
2067
|
messages: r,
|
|
2013
2068
|
placeholder: e.placeholder,
|
|
@@ -2179,71 +2234,71 @@ U.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
2179
2234
|
});
|
|
2180
2235
|
//#endregion
|
|
2181
2236
|
//#region src/elements/loader.tsx
|
|
2182
|
-
var
|
|
2237
|
+
var rr = ({ size: e = 16 }) => /* @__PURE__ */ H("svg", {
|
|
2183
2238
|
height: e,
|
|
2184
2239
|
strokeLinejoin: "round",
|
|
2185
2240
|
style: { color: "currentcolor" },
|
|
2186
2241
|
viewBox: "0 0 16 16",
|
|
2187
2242
|
width: e,
|
|
2188
2243
|
children: [
|
|
2189
|
-
/* @__PURE__ */
|
|
2190
|
-
/* @__PURE__ */
|
|
2244
|
+
/* @__PURE__ */ V("title", { children: "Loader" }),
|
|
2245
|
+
/* @__PURE__ */ H("g", {
|
|
2191
2246
|
clipPath: "url(#clip0_2393_1490)",
|
|
2192
2247
|
children: [
|
|
2193
|
-
/* @__PURE__ */
|
|
2248
|
+
/* @__PURE__ */ V("path", {
|
|
2194
2249
|
d: "M8 0V4",
|
|
2195
2250
|
stroke: "currentColor",
|
|
2196
2251
|
strokeWidth: "1.5"
|
|
2197
2252
|
}),
|
|
2198
|
-
/* @__PURE__ */
|
|
2253
|
+
/* @__PURE__ */ V("path", {
|
|
2199
2254
|
d: "M8 16V12",
|
|
2200
2255
|
opacity: "0.5",
|
|
2201
2256
|
stroke: "currentColor",
|
|
2202
2257
|
strokeWidth: "1.5"
|
|
2203
2258
|
}),
|
|
2204
|
-
/* @__PURE__ */
|
|
2259
|
+
/* @__PURE__ */ V("path", {
|
|
2205
2260
|
d: "M3.29773 1.52783L5.64887 4.7639",
|
|
2206
2261
|
opacity: "0.9",
|
|
2207
2262
|
stroke: "currentColor",
|
|
2208
2263
|
strokeWidth: "1.5"
|
|
2209
2264
|
}),
|
|
2210
|
-
/* @__PURE__ */
|
|
2265
|
+
/* @__PURE__ */ V("path", {
|
|
2211
2266
|
d: "M12.7023 1.52783L10.3511 4.7639",
|
|
2212
2267
|
opacity: "0.1",
|
|
2213
2268
|
stroke: "currentColor",
|
|
2214
2269
|
strokeWidth: "1.5"
|
|
2215
2270
|
}),
|
|
2216
|
-
/* @__PURE__ */
|
|
2271
|
+
/* @__PURE__ */ V("path", {
|
|
2217
2272
|
d: "M12.7023 14.472L10.3511 11.236",
|
|
2218
2273
|
opacity: "0.4",
|
|
2219
2274
|
stroke: "currentColor",
|
|
2220
2275
|
strokeWidth: "1.5"
|
|
2221
2276
|
}),
|
|
2222
|
-
/* @__PURE__ */
|
|
2277
|
+
/* @__PURE__ */ V("path", {
|
|
2223
2278
|
d: "M3.29773 14.472L5.64887 11.236",
|
|
2224
2279
|
opacity: "0.6",
|
|
2225
2280
|
stroke: "currentColor",
|
|
2226
2281
|
strokeWidth: "1.5"
|
|
2227
2282
|
}),
|
|
2228
|
-
/* @__PURE__ */
|
|
2283
|
+
/* @__PURE__ */ V("path", {
|
|
2229
2284
|
d: "M15.6085 5.52783L11.8043 6.7639",
|
|
2230
2285
|
opacity: "0.2",
|
|
2231
2286
|
stroke: "currentColor",
|
|
2232
2287
|
strokeWidth: "1.5"
|
|
2233
2288
|
}),
|
|
2234
|
-
/* @__PURE__ */
|
|
2289
|
+
/* @__PURE__ */ V("path", {
|
|
2235
2290
|
d: "M0.391602 10.472L4.19583 9.23598",
|
|
2236
2291
|
opacity: "0.7",
|
|
2237
2292
|
stroke: "currentColor",
|
|
2238
2293
|
strokeWidth: "1.5"
|
|
2239
2294
|
}),
|
|
2240
|
-
/* @__PURE__ */
|
|
2295
|
+
/* @__PURE__ */ V("path", {
|
|
2241
2296
|
d: "M15.6085 10.4722L11.8043 9.2361",
|
|
2242
2297
|
opacity: "0.3",
|
|
2243
2298
|
stroke: "currentColor",
|
|
2244
2299
|
strokeWidth: "1.5"
|
|
2245
2300
|
}),
|
|
2246
|
-
/* @__PURE__ */
|
|
2301
|
+
/* @__PURE__ */ V("path", {
|
|
2247
2302
|
d: "M0.391602 5.52783L4.19583 6.7639",
|
|
2248
2303
|
opacity: "0.8",
|
|
2249
2304
|
stroke: "currentColor",
|
|
@@ -2251,99 +2306,99 @@ var Zn = ({ size: e = 16 }) => /* @__PURE__ */ V("svg", {
|
|
|
2251
2306
|
})
|
|
2252
2307
|
]
|
|
2253
2308
|
}),
|
|
2254
|
-
/* @__PURE__ */
|
|
2309
|
+
/* @__PURE__ */ V("defs", { children: /* @__PURE__ */ V("clipPath", {
|
|
2255
2310
|
id: "clip0_2393_1490",
|
|
2256
|
-
children: /* @__PURE__ */
|
|
2311
|
+
children: /* @__PURE__ */ V("rect", {
|
|
2257
2312
|
fill: "white",
|
|
2258
2313
|
height: "16",
|
|
2259
2314
|
width: "16"
|
|
2260
2315
|
})
|
|
2261
2316
|
}) })
|
|
2262
2317
|
]
|
|
2263
|
-
}),
|
|
2264
|
-
className:
|
|
2318
|
+
}), ir = ({ className: e, size: t = 16, ...n }) => /* @__PURE__ */ V("div", {
|
|
2319
|
+
className: L("inline-flex animate-spin items-center justify-center", e),
|
|
2265
2320
|
...n,
|
|
2266
|
-
children: /* @__PURE__ */
|
|
2267
|
-
}),
|
|
2268
|
-
CodeBlock: () =>
|
|
2269
|
-
CodeBlockCopyButton: () =>
|
|
2270
|
-
Conversation: () =>
|
|
2271
|
-
ConversationContent: () =>
|
|
2272
|
-
ConversationEmptyState: () =>
|
|
2273
|
-
ConversationScrollButton: () =>
|
|
2274
|
-
Loader: () =>
|
|
2275
|
-
Message: () =>
|
|
2276
|
-
MessageAction: () =>
|
|
2277
|
-
MessageActions: () =>
|
|
2278
|
-
MessageAttachment: () =>
|
|
2279
|
-
MessageAttachments: () =>
|
|
2280
|
-
MessageBranch: () =>
|
|
2281
|
-
MessageBranchContent: () =>
|
|
2282
|
-
MessageBranchNext: () =>
|
|
2283
|
-
MessageBranchPage: () =>
|
|
2284
|
-
MessageBranchPrevious: () =>
|
|
2285
|
-
MessageBranchSelector: () =>
|
|
2286
|
-
MessageContent: () =>
|
|
2287
|
-
MessageResponse: () =>
|
|
2288
|
-
MessageToolbar: () =>
|
|
2289
|
-
PromptInput: () =>
|
|
2290
|
-
PromptInputActionAddAttachments: () =>
|
|
2291
|
-
PromptInputActionMenu: () =>
|
|
2292
|
-
PromptInputActionMenuContent: () =>
|
|
2293
|
-
PromptInputActionMenuItem: () =>
|
|
2294
|
-
PromptInputActionMenuTrigger: () =>
|
|
2295
|
-
PromptInputAttachment: () =>
|
|
2296
|
-
PromptInputAttachments: () =>
|
|
2297
|
-
PromptInputBody: () =>
|
|
2298
|
-
PromptInputButton: () =>
|
|
2299
|
-
PromptInputCommand: () =>
|
|
2300
|
-
PromptInputCommandEmpty: () =>
|
|
2301
|
-
PromptInputCommandGroup: () =>
|
|
2302
|
-
PromptInputCommandInput: () =>
|
|
2303
|
-
PromptInputCommandItem: () =>
|
|
2304
|
-
PromptInputCommandList: () =>
|
|
2305
|
-
PromptInputCommandSeparator: () =>
|
|
2306
|
-
PromptInputFooter: () =>
|
|
2307
|
-
PromptInputHeader: () =>
|
|
2308
|
-
PromptInputHoverCard: () =>
|
|
2309
|
-
PromptInputHoverCardContent: () =>
|
|
2310
|
-
PromptInputHoverCardTrigger: () =>
|
|
2311
|
-
PromptInputProvider: () =>
|
|
2312
|
-
PromptInputSelect: () =>
|
|
2313
|
-
PromptInputSelectContent: () =>
|
|
2314
|
-
PromptInputSelectItem: () =>
|
|
2315
|
-
PromptInputSelectTrigger: () =>
|
|
2316
|
-
PromptInputSelectValue: () =>
|
|
2317
|
-
PromptInputSpeechButton: () =>
|
|
2318
|
-
PromptInputSubmit: () =>
|
|
2319
|
-
PromptInputTab: () =>
|
|
2320
|
-
PromptInputTabBody: () =>
|
|
2321
|
-
PromptInputTabItem: () =>
|
|
2322
|
-
PromptInputTabLabel: () =>
|
|
2323
|
-
PromptInputTabsList: () =>
|
|
2324
|
-
PromptInputTextarea: () =>
|
|
2325
|
-
PromptInputTools: () =>
|
|
2326
|
-
Reasoning: () =>
|
|
2327
|
-
ReasoningContent: () =>
|
|
2328
|
-
ReasoningTrigger: () =>
|
|
2329
|
-
Shimmer: () =>
|
|
2330
|
-
Source: () =>
|
|
2331
|
-
Sources: () =>
|
|
2332
|
-
SourcesContent: () =>
|
|
2333
|
-
SourcesTrigger: () =>
|
|
2334
|
-
Suggestion: () =>
|
|
2335
|
-
Suggestions: () =>
|
|
2336
|
-
Tool: () =>
|
|
2337
|
-
ToolContent: () =>
|
|
2338
|
-
ToolHeader: () =>
|
|
2339
|
-
ToolInput: () =>
|
|
2340
|
-
ToolOutput: () =>
|
|
2341
|
-
highlightCode: () =>
|
|
2321
|
+
children: /* @__PURE__ */ V(rr, { size: t })
|
|
2322
|
+
}), ar = /* @__PURE__ */ Ze({
|
|
2323
|
+
CodeBlock: () => Q,
|
|
2324
|
+
CodeBlockCopyButton: () => Pn,
|
|
2325
|
+
Conversation: () => ft,
|
|
2326
|
+
ConversationContent: () => pt,
|
|
2327
|
+
ConversationEmptyState: () => mt,
|
|
2328
|
+
ConversationScrollButton: () => ht,
|
|
2329
|
+
Loader: () => ir,
|
|
2330
|
+
Message: () => yt,
|
|
2331
|
+
MessageAction: () => J,
|
|
2332
|
+
MessageActions: () => xt,
|
|
2333
|
+
MessageAttachment: () => At,
|
|
2334
|
+
MessageAttachments: () => jt,
|
|
2335
|
+
MessageBranch: () => Ct,
|
|
2336
|
+
MessageBranchContent: () => wt,
|
|
2337
|
+
MessageBranchNext: () => Dt,
|
|
2338
|
+
MessageBranchPage: () => Ot,
|
|
2339
|
+
MessageBranchPrevious: () => Et,
|
|
2340
|
+
MessageBranchSelector: () => Tt,
|
|
2341
|
+
MessageContent: () => bt,
|
|
2342
|
+
MessageResponse: () => kt,
|
|
2343
|
+
MessageToolbar: () => Mt,
|
|
2344
|
+
PromptInput: () => Yt,
|
|
2345
|
+
PromptInputActionAddAttachments: () => Jt,
|
|
2346
|
+
PromptInputActionMenu: () => nn,
|
|
2347
|
+
PromptInputActionMenuContent: () => an,
|
|
2348
|
+
PromptInputActionMenuItem: () => on,
|
|
2349
|
+
PromptInputActionMenuTrigger: () => rn,
|
|
2350
|
+
PromptInputAttachment: () => Kt,
|
|
2351
|
+
PromptInputAttachments: () => qt,
|
|
2352
|
+
PromptInputBody: () => Xt,
|
|
2353
|
+
PromptInputButton: () => tn,
|
|
2354
|
+
PromptInputCommand: () => Sn,
|
|
2355
|
+
PromptInputCommandEmpty: () => Tn,
|
|
2356
|
+
PromptInputCommandGroup: () => En,
|
|
2357
|
+
PromptInputCommandInput: () => Cn,
|
|
2358
|
+
PromptInputCommandItem: () => Dn,
|
|
2359
|
+
PromptInputCommandList: () => wn,
|
|
2360
|
+
PromptInputCommandSeparator: () => On,
|
|
2361
|
+
PromptInputFooter: () => $t,
|
|
2362
|
+
PromptInputHeader: () => Qt,
|
|
2363
|
+
PromptInputHoverCard: () => mn,
|
|
2364
|
+
PromptInputHoverCardContent: () => gn,
|
|
2365
|
+
PromptInputHoverCardTrigger: () => hn,
|
|
2366
|
+
PromptInputProvider: () => Wt,
|
|
2367
|
+
PromptInputSelect: () => ln,
|
|
2368
|
+
PromptInputSelectContent: () => dn,
|
|
2369
|
+
PromptInputSelectItem: () => fn,
|
|
2370
|
+
PromptInputSelectTrigger: () => un,
|
|
2371
|
+
PromptInputSelectValue: () => pn,
|
|
2372
|
+
PromptInputSpeechButton: () => cn,
|
|
2373
|
+
PromptInputSubmit: () => sn,
|
|
2374
|
+
PromptInputTab: () => vn,
|
|
2375
|
+
PromptInputTabBody: () => bn,
|
|
2376
|
+
PromptInputTabItem: () => xn,
|
|
2377
|
+
PromptInputTabLabel: () => yn,
|
|
2378
|
+
PromptInputTabsList: () => _n,
|
|
2379
|
+
PromptInputTextarea: () => Zt,
|
|
2380
|
+
PromptInputTools: () => en,
|
|
2381
|
+
Reasoning: () => Kn,
|
|
2382
|
+
ReasoningContent: () => Yn,
|
|
2383
|
+
ReasoningTrigger: () => Jn,
|
|
2384
|
+
Shimmer: () => Vn,
|
|
2385
|
+
Source: () => $n,
|
|
2386
|
+
Sources: () => Xn,
|
|
2387
|
+
SourcesContent: () => Qn,
|
|
2388
|
+
SourcesTrigger: () => Zn,
|
|
2389
|
+
Suggestion: () => An,
|
|
2390
|
+
Suggestions: () => kn,
|
|
2391
|
+
Tool: () => Fn,
|
|
2392
|
+
ToolContent: () => Rn,
|
|
2393
|
+
ToolHeader: () => Ln,
|
|
2394
|
+
ToolInput: () => zn,
|
|
2395
|
+
ToolOutput: () => Bn,
|
|
2396
|
+
highlightCode: () => Nn,
|
|
2342
2397
|
usePromptInputAttachments: () => Z,
|
|
2343
|
-
usePromptInputController: () =>
|
|
2344
|
-
useProviderAttachments: () =>
|
|
2345
|
-
useReasoning: () =>
|
|
2346
|
-
}),
|
|
2398
|
+
usePromptInputController: () => Bt,
|
|
2399
|
+
useProviderAttachments: () => Ht,
|
|
2400
|
+
useReasoning: () => Un
|
|
2401
|
+
}), or = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type your message...", onSendMessage: i, disabled: a = !1, showTimestamp: o = !1, userAvatarUrl: s, userAvatarFallback: c = "You", assistantAvatarUrl: l, assistantAvatarFallback: u = "AI", maxHeight: d = "500px", ...f }, p) => {
|
|
2347
2402
|
let [m, h] = e.useState(""), _ = e.useRef(null), v = e.useRef(null);
|
|
2348
2403
|
e.useEffect(() => {
|
|
2349
2404
|
if (_.current) {
|
|
@@ -2356,20 +2411,20 @@ var Zn = ({ size: e = 16 }) => /* @__PURE__ */ V("svg", {
|
|
|
2356
2411
|
}, b = (e) => {
|
|
2357
2412
|
e.key === "Enter" && !e.shiftKey && (e.preventDefault(), y());
|
|
2358
2413
|
};
|
|
2359
|
-
return /* @__PURE__ */
|
|
2414
|
+
return /* @__PURE__ */ H("div", {
|
|
2360
2415
|
ref: p,
|
|
2361
|
-
className:
|
|
2416
|
+
className: L("flex flex-col border rounded-lg bg-background overflow-hidden", t),
|
|
2362
2417
|
style: { maxHeight: d },
|
|
2363
2418
|
...f,
|
|
2364
|
-
children: [/* @__PURE__ */
|
|
2419
|
+
children: [/* @__PURE__ */ V(F, {
|
|
2365
2420
|
ref: _,
|
|
2366
2421
|
className: "flex-1 p-4",
|
|
2367
|
-
children: /* @__PURE__ */
|
|
2422
|
+
children: /* @__PURE__ */ V("div", {
|
|
2368
2423
|
className: "space-y-4",
|
|
2369
|
-
children: n.length === 0 ? /* @__PURE__ */
|
|
2424
|
+
children: n.length === 0 ? /* @__PURE__ */ V("div", {
|
|
2370
2425
|
className: "flex items-center justify-center h-32 text-muted-foreground text-sm",
|
|
2371
2426
|
children: "No messages yet. Start a conversation!"
|
|
2372
|
-
}) : n.map((e) => /* @__PURE__ */
|
|
2427
|
+
}) : n.map((e) => /* @__PURE__ */ V(sr, {
|
|
2373
2428
|
message: e,
|
|
2374
2429
|
showTimestamp: o,
|
|
2375
2430
|
userAvatarUrl: s,
|
|
@@ -2378,11 +2433,11 @@ var Zn = ({ size: e = 16 }) => /* @__PURE__ */ V("svg", {
|
|
|
2378
2433
|
assistantAvatarFallback: u
|
|
2379
2434
|
}, e.id))
|
|
2380
2435
|
})
|
|
2381
|
-
}), /* @__PURE__ */
|
|
2436
|
+
}), /* @__PURE__ */ V("div", {
|
|
2382
2437
|
className: "border-t p-4",
|
|
2383
|
-
children: /* @__PURE__ */
|
|
2438
|
+
children: /* @__PURE__ */ H("div", {
|
|
2384
2439
|
className: "flex gap-2",
|
|
2385
|
-
children: [/* @__PURE__ */
|
|
2440
|
+
children: [/* @__PURE__ */ V(P, {
|
|
2386
2441
|
ref: v,
|
|
2387
2442
|
value: m,
|
|
2388
2443
|
onChange: (e) => h(e.target.value),
|
|
@@ -2390,71 +2445,71 @@ var Zn = ({ size: e = 16 }) => /* @__PURE__ */ V("svg", {
|
|
|
2390
2445
|
placeholder: r,
|
|
2391
2446
|
disabled: a,
|
|
2392
2447
|
className: "flex-1"
|
|
2393
|
-
}), /* @__PURE__ */
|
|
2448
|
+
}), /* @__PURE__ */ V(g, {
|
|
2394
2449
|
onClick: y,
|
|
2395
2450
|
disabled: a || !m.trim(),
|
|
2396
2451
|
size: "icon",
|
|
2397
|
-
children: /* @__PURE__ */
|
|
2452
|
+
children: /* @__PURE__ */ V(Ne, { className: "h-4 w-4" })
|
|
2398
2453
|
})]
|
|
2399
2454
|
})
|
|
2400
2455
|
})]
|
|
2401
2456
|
});
|
|
2402
2457
|
});
|
|
2403
|
-
|
|
2404
|
-
var
|
|
2458
|
+
or.displayName = "Chatbot";
|
|
2459
|
+
var sr = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback: r, assistantAvatarUrl: i, assistantAvatarFallback: a }) => {
|
|
2405
2460
|
let o = e.role === "user";
|
|
2406
|
-
if (e.role === "system") return /* @__PURE__ */
|
|
2461
|
+
if (e.role === "system") return /* @__PURE__ */ V("div", {
|
|
2407
2462
|
className: "flex justify-center",
|
|
2408
|
-
children: /* @__PURE__ */
|
|
2463
|
+
children: /* @__PURE__ */ V("div", {
|
|
2409
2464
|
className: "text-xs text-muted-foreground bg-muted px-3 py-1 rounded-full",
|
|
2410
2465
|
children: e.content
|
|
2411
2466
|
})
|
|
2412
2467
|
});
|
|
2413
2468
|
let s = o ? e.avatar || n : e.avatar || i, c = o ? e.avatarFallback || r : e.avatarFallback || a;
|
|
2414
|
-
return /* @__PURE__ */
|
|
2415
|
-
className:
|
|
2416
|
-
children: [/* @__PURE__ */
|
|
2469
|
+
return /* @__PURE__ */ H("div", {
|
|
2470
|
+
className: L("flex gap-3", o ? "flex-row-reverse" : "flex-row"),
|
|
2471
|
+
children: [/* @__PURE__ */ H(f, {
|
|
2417
2472
|
className: "h-8 w-8",
|
|
2418
|
-
children: [/* @__PURE__ */
|
|
2473
|
+
children: [/* @__PURE__ */ V(m, { src: s }), /* @__PURE__ */ V(p, {
|
|
2419
2474
|
className: "text-xs",
|
|
2420
2475
|
children: c
|
|
2421
2476
|
})]
|
|
2422
|
-
}), /* @__PURE__ */
|
|
2423
|
-
className:
|
|
2424
|
-
children: [/* @__PURE__ */
|
|
2425
|
-
className:
|
|
2426
|
-
children: /* @__PURE__ */
|
|
2477
|
+
}), /* @__PURE__ */ H("div", {
|
|
2478
|
+
className: L("flex flex-col gap-1", o ? "items-end" : "items-start"),
|
|
2479
|
+
children: [/* @__PURE__ */ V("div", {
|
|
2480
|
+
className: L("rounded-lg px-4 py-2 max-w-[70%] break-words", o ? "bg-primary text-primary-foreground" : "bg-muted"),
|
|
2481
|
+
children: /* @__PURE__ */ V("p", {
|
|
2427
2482
|
className: "text-sm whitespace-pre-wrap",
|
|
2428
2483
|
children: e.content
|
|
2429
2484
|
})
|
|
2430
|
-
}), t && e.timestamp && /* @__PURE__ */
|
|
2485
|
+
}), t && e.timestamp && /* @__PURE__ */ V("span", {
|
|
2431
2486
|
className: "text-xs text-muted-foreground",
|
|
2432
2487
|
children: e.timestamp
|
|
2433
2488
|
})]
|
|
2434
2489
|
})]
|
|
2435
2490
|
});
|
|
2436
|
-
},
|
|
2491
|
+
}, cr = e.forwardRef(({ className: e, avatarSrc: t, avatarFallback: n = "AI", ...r }, i) => /* @__PURE__ */ H("div", {
|
|
2437
2492
|
ref: i,
|
|
2438
|
-
className:
|
|
2493
|
+
className: L("flex gap-3", e),
|
|
2439
2494
|
...r,
|
|
2440
|
-
children: [/* @__PURE__ */
|
|
2495
|
+
children: [/* @__PURE__ */ H(f, {
|
|
2441
2496
|
className: "h-8 w-8",
|
|
2442
|
-
children: [/* @__PURE__ */
|
|
2497
|
+
children: [/* @__PURE__ */ V(m, { src: t }), /* @__PURE__ */ V(p, {
|
|
2443
2498
|
className: "text-xs",
|
|
2444
2499
|
children: n
|
|
2445
2500
|
})]
|
|
2446
|
-
}), /* @__PURE__ */
|
|
2501
|
+
}), /* @__PURE__ */ V("div", {
|
|
2447
2502
|
className: "flex items-center bg-muted rounded-lg px-4 py-2",
|
|
2448
|
-
children: /* @__PURE__ */
|
|
2503
|
+
children: /* @__PURE__ */ H("div", {
|
|
2449
2504
|
className: "flex gap-1",
|
|
2450
2505
|
children: [
|
|
2451
|
-
/* @__PURE__ */
|
|
2452
|
-
/* @__PURE__ */
|
|
2453
|
-
/* @__PURE__ */
|
|
2506
|
+
/* @__PURE__ */ V("span", { className: "w-2 h-2 bg-muted-foreground rounded-full animate-bounce [animation-delay:-0.3s]" }),
|
|
2507
|
+
/* @__PURE__ */ V("span", { className: "w-2 h-2 bg-muted-foreground rounded-full animate-bounce [animation-delay:-0.15s]" }),
|
|
2508
|
+
/* @__PURE__ */ V("span", { className: "w-2 h-2 bg-muted-foreground rounded-full animate-bounce" })
|
|
2454
2509
|
]
|
|
2455
2510
|
})
|
|
2456
2511
|
})]
|
|
2457
2512
|
}));
|
|
2458
|
-
|
|
2513
|
+
cr.displayName = "TypingIndicator";
|
|
2459
2514
|
//#endregion
|
|
2460
|
-
export {
|
|
2515
|
+
export { ar as AIElements, or as Chatbot, $ as ChatbotEnhanced, nr as FloatingChatbot, dt as FloatingChatbotPanel, ct as FloatingChatbotProvider, ut as FloatingChatbotTrigger, cr as TypingIndicator, nt as uiMessageToChatMessage, rt as uiMessagesToChatMessages, ot as useAgents, q as useFloatingChatbot, K as useObjectChat };
|