@object-ui/plugin-chatbot 5.3.2 → 5.4.0

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