@anvia/react-ui 0.4.2 → 0.5.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.
- package/README.md +16 -0
- package/dist/attachment/index.js +2 -2
- package/dist/chat/index.d.ts +3 -2
- package/dist/chat/index.js +4 -4
- package/dist/{chunk-657E5BPN.js → chunk-2N5PXLAS.js} +2 -2
- package/dist/{chunk-SE7I6ZXJ.js → chunk-7PBLYIKR.js} +2 -2
- package/dist/{chunk-JUNV3MUR.js → chunk-I4L25QXW.js} +2 -2
- package/dist/{chunk-RN5CA5A6.js → chunk-L3ZUEIB6.js} +16 -10
- package/dist/chunk-L3ZUEIB6.js.map +1 -0
- package/dist/{chunk-TOBAQM2G.js → chunk-T6GPGCK4.js} +2 -2
- package/dist/{chunk-GXB4VINL.js → chunk-TVWD2LX4.js} +2 -2
- package/dist/{chunk-32QFNRXR.js → chunk-WUMACFYS.js} +2 -2
- package/dist/{chunk-BCCU3VT5.js → chunk-YQJLVBQD.js} +1 -1
- package/dist/chunk-YQJLVBQD.js.map +1 -0
- package/dist/chunk-YUK4ASXB.js +989 -0
- package/dist/chunk-YUK4ASXB.js.map +1 -0
- package/dist/completion/index.js +2 -2
- package/dist/{thread-C2-Xo08o.d.ts → composer-CzsbDFPt.d.ts} +7 -10
- package/dist/human-input/index.js +2 -2
- package/dist/image/index.js +2 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +14 -14
- package/dist/message/index.d.ts +23 -1
- package/dist/message/index.js +3 -3
- package/dist/selection-toolbar/index.js +2 -2
- package/dist/shared.d.ts +2 -1
- package/dist/shared.js +1 -1
- package/dist/styles.css +20 -0
- package/dist/thread-list/index.js +2 -2
- package/dist/thread-uEm8hH0s.d.ts +11 -0
- package/package.json +2 -2
- package/dist/chunk-BCCU3VT5.js.map +0 -1
- package/dist/chunk-FZANAMWH.js +0 -530
- package/dist/chunk-FZANAMWH.js.map +0 -1
- package/dist/chunk-RN5CA5A6.js.map +0 -1
- /package/dist/{chunk-657E5BPN.js.map → chunk-2N5PXLAS.js.map} +0 -0
- /package/dist/{chunk-SE7I6ZXJ.js.map → chunk-7PBLYIKR.js.map} +0 -0
- /package/dist/{chunk-JUNV3MUR.js.map → chunk-I4L25QXW.js.map} +0 -0
- /package/dist/{chunk-TOBAQM2G.js.map → chunk-T6GPGCK4.js.map} +0 -0
- /package/dist/{chunk-GXB4VINL.js.map → chunk-TVWD2LX4.js.map} +0 -0
- /package/dist/{chunk-32QFNRXR.js.map → chunk-WUMACFYS.js.map} +0 -0
package/dist/chunk-FZANAMWH.js
DELETED
|
@@ -1,530 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Attachment
|
|
3
|
-
} from "./chunk-32QFNRXR.js";
|
|
4
|
-
import {
|
|
5
|
-
renderPrimitive
|
|
6
|
-
} from "./chunk-T3ZFZ3NP.js";
|
|
7
|
-
import {
|
|
8
|
-
InternalAttachmentProvider,
|
|
9
|
-
InternalMessagePartProvider,
|
|
10
|
-
useChatContext,
|
|
11
|
-
useMessage,
|
|
12
|
-
useMessagePart,
|
|
13
|
-
useOptionalMessagePart
|
|
14
|
-
} from "./chunk-BCCU3VT5.js";
|
|
15
|
-
|
|
16
|
-
// src/message/actions.tsx
|
|
17
|
-
import { forwardRef, useCallback, useEffect, useRef, useState } from "react";
|
|
18
|
-
|
|
19
|
-
// src/format/message.ts
|
|
20
|
-
function messageText(message) {
|
|
21
|
-
return message.parts.filter((part) => part.type === "text").map((part) => part.text).join("");
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// src/format/value.ts
|
|
25
|
-
function stringifyValue(value) {
|
|
26
|
-
if (value === void 0) {
|
|
27
|
-
return "";
|
|
28
|
-
}
|
|
29
|
-
if (typeof value === "string") {
|
|
30
|
-
return value;
|
|
31
|
-
}
|
|
32
|
-
try {
|
|
33
|
-
return JSON.stringify(value, null, 2);
|
|
34
|
-
} catch {
|
|
35
|
-
return String(value);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// src/message/actions.tsx
|
|
40
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
41
|
-
var MessageActions = forwardRef(
|
|
42
|
-
function MessageActions2(props, ref) {
|
|
43
|
-
return renderPrimitive(
|
|
44
|
-
"div",
|
|
45
|
-
{
|
|
46
|
-
...props,
|
|
47
|
-
children: props.children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
48
|
-
/* @__PURE__ */ jsx(MessageCopy, {}),
|
|
49
|
-
/* @__PURE__ */ jsx(MessageRegenerate, {})
|
|
50
|
-
] }),
|
|
51
|
-
"data-anvia-message-actions": ""
|
|
52
|
-
},
|
|
53
|
-
ref
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
);
|
|
57
|
-
var MessageCopy = forwardRef(function MessageCopy2({ onClick, ...props }, ref) {
|
|
58
|
-
const { message } = useMessage();
|
|
59
|
-
const [copyState, setCopyState] = useState("idle");
|
|
60
|
-
const text = messageText(message);
|
|
61
|
-
const previousTextRef = useRef(text);
|
|
62
|
-
const disabled = props.disabled ?? text.length === 0;
|
|
63
|
-
useEffect(() => {
|
|
64
|
-
if (previousTextRef.current !== text) {
|
|
65
|
-
previousTextRef.current = text;
|
|
66
|
-
setCopyState("idle");
|
|
67
|
-
}
|
|
68
|
-
}, [text]);
|
|
69
|
-
const handleClick = useCallback(
|
|
70
|
-
async (event) => {
|
|
71
|
-
onClick?.(event);
|
|
72
|
-
if (event.defaultPrevented || disabled) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
const writeText = navigator.clipboard?.writeText;
|
|
76
|
-
if (writeText === void 0) {
|
|
77
|
-
setCopyState("error");
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
try {
|
|
81
|
-
await writeText.call(navigator.clipboard, text);
|
|
82
|
-
setCopyState("copied");
|
|
83
|
-
} catch {
|
|
84
|
-
setCopyState("error");
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
[disabled, onClick, text]
|
|
88
|
-
);
|
|
89
|
-
return renderPrimitive(
|
|
90
|
-
"button",
|
|
91
|
-
{
|
|
92
|
-
...props,
|
|
93
|
-
children: props.children ?? "Copy",
|
|
94
|
-
disabled,
|
|
95
|
-
onClick: handleClick,
|
|
96
|
-
type: props.type ?? "button",
|
|
97
|
-
"data-anvia-copy": "",
|
|
98
|
-
"data-state": copyState
|
|
99
|
-
},
|
|
100
|
-
ref
|
|
101
|
-
);
|
|
102
|
-
});
|
|
103
|
-
var MessageRegenerate = forwardRef(
|
|
104
|
-
function MessageRegenerate2({ onClick, ...props }, ref) {
|
|
105
|
-
const chat = useChatContext();
|
|
106
|
-
const { message } = useMessage();
|
|
107
|
-
const latestAssistantMessage = [...chat.messages].reverse().find((item) => item.role === "assistant");
|
|
108
|
-
const disabled = props.disabled ?? (chat.status === "streaming" || message.role !== "assistant" || latestAssistantMessage?.id !== message.id);
|
|
109
|
-
const handleClick = useCallback(
|
|
110
|
-
(event) => {
|
|
111
|
-
onClick?.(event);
|
|
112
|
-
if (event.defaultPrevented || disabled) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
void chat.regenerate();
|
|
116
|
-
},
|
|
117
|
-
[chat, disabled, onClick]
|
|
118
|
-
);
|
|
119
|
-
return renderPrimitive(
|
|
120
|
-
"button",
|
|
121
|
-
{
|
|
122
|
-
...props,
|
|
123
|
-
children: props.children ?? "Regenerate",
|
|
124
|
-
disabled,
|
|
125
|
-
onClick: handleClick,
|
|
126
|
-
type: props.type ?? "button",
|
|
127
|
-
"data-anvia-regenerate": "",
|
|
128
|
-
"data-state": disabled ? "disabled" : "idle"
|
|
129
|
-
},
|
|
130
|
-
ref
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
);
|
|
134
|
-
|
|
135
|
-
// src/message/parts.tsx
|
|
136
|
-
import { forwardRef as forwardRef2 } from "react";
|
|
137
|
-
import ReactMarkdown from "react-markdown";
|
|
138
|
-
import remarkGfm from "remark-gfm";
|
|
139
|
-
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
140
|
-
var MessageParts = forwardRef2(function MessageParts2({ children, filter, ...props }, ref) {
|
|
141
|
-
const { message } = useMessage();
|
|
142
|
-
const parts = filter === void 0 ? message.parts : message.parts.filter(filter);
|
|
143
|
-
return renderPrimitive(
|
|
144
|
-
"div",
|
|
145
|
-
{
|
|
146
|
-
...props,
|
|
147
|
-
children: parts.map((part) => /* @__PURE__ */ jsx2(InternalMessagePartProvider, { part, children: typeof children === "function" ? children(part) : children ?? /* @__PURE__ */ jsx2(MessagePart, {}) }, part.id)),
|
|
148
|
-
"data-anvia-message-parts": ""
|
|
149
|
-
},
|
|
150
|
-
ref
|
|
151
|
-
);
|
|
152
|
-
});
|
|
153
|
-
var MessagePart = forwardRef2(function MessagePart2({ children, ...props }, ref) {
|
|
154
|
-
const { part } = useMessagePart();
|
|
155
|
-
const renderedChildren = typeof children === "function" ? children(part) : children ?? defaultPart(part);
|
|
156
|
-
return renderPrimitive(
|
|
157
|
-
"div",
|
|
158
|
-
{
|
|
159
|
-
...props,
|
|
160
|
-
children: renderedChildren,
|
|
161
|
-
"data-anvia-part": "",
|
|
162
|
-
"data-part": part.type
|
|
163
|
-
},
|
|
164
|
-
ref
|
|
165
|
-
);
|
|
166
|
-
});
|
|
167
|
-
var MessageText = forwardRef2(
|
|
168
|
-
function MessageText2(props, ref) {
|
|
169
|
-
const { part } = useMessagePart();
|
|
170
|
-
if (part.type !== "text") {
|
|
171
|
-
return null;
|
|
172
|
-
}
|
|
173
|
-
return renderPrimitive(
|
|
174
|
-
"span",
|
|
175
|
-
{
|
|
176
|
-
...props,
|
|
177
|
-
children: props.children ?? part.text,
|
|
178
|
-
"data-anvia-text": ""
|
|
179
|
-
},
|
|
180
|
-
ref
|
|
181
|
-
);
|
|
182
|
-
}
|
|
183
|
-
);
|
|
184
|
-
var MessageMarkdown = forwardRef2(function MessageMarkdown2({ children, components, remarkPlugins, ...props }, ref) {
|
|
185
|
-
const { message } = useMessage();
|
|
186
|
-
const partContext = useOptionalMessagePart();
|
|
187
|
-
const part = partContext?.part;
|
|
188
|
-
if (part !== void 0 && part.type !== "text") {
|
|
189
|
-
return null;
|
|
190
|
-
}
|
|
191
|
-
const markdown = children ?? (part?.type === "text" ? part.text : message.parts.flatMap((item) => item.type === "text" ? [item.text] : []).join("\n\n"));
|
|
192
|
-
return renderPrimitive(
|
|
193
|
-
"div",
|
|
194
|
-
{
|
|
195
|
-
...props,
|
|
196
|
-
children: /* @__PURE__ */ jsx2(
|
|
197
|
-
ReactMarkdown,
|
|
198
|
-
{
|
|
199
|
-
components: { code: defaultCodeComponent, pre: defaultPreComponent, ...components },
|
|
200
|
-
remarkPlugins: remarkPlugins ?? [remarkGfm],
|
|
201
|
-
children: markdown
|
|
202
|
-
}
|
|
203
|
-
),
|
|
204
|
-
"data-anvia-markdown": ""
|
|
205
|
-
},
|
|
206
|
-
ref
|
|
207
|
-
);
|
|
208
|
-
});
|
|
209
|
-
var MessageCodeBlock = forwardRef2(
|
|
210
|
-
function MessageCodeBlock2({ children, code, language, ...props }, ref) {
|
|
211
|
-
return renderPrimitive(
|
|
212
|
-
"pre",
|
|
213
|
-
{
|
|
214
|
-
...props,
|
|
215
|
-
children: children ?? /* @__PURE__ */ jsx2("code", { "data-anvia-code": "", "data-language": language, children: code ?? "" }),
|
|
216
|
-
"data-anvia-code-block": "",
|
|
217
|
-
"data-language": language
|
|
218
|
-
},
|
|
219
|
-
ref
|
|
220
|
-
);
|
|
221
|
-
}
|
|
222
|
-
);
|
|
223
|
-
var MessageReasoning = forwardRef2(
|
|
224
|
-
function MessageReasoning2(props, ref) {
|
|
225
|
-
const { part } = useMessagePart();
|
|
226
|
-
if (part.type !== "reasoning") {
|
|
227
|
-
return null;
|
|
228
|
-
}
|
|
229
|
-
return renderPrimitive(
|
|
230
|
-
"details",
|
|
231
|
-
{
|
|
232
|
-
...props,
|
|
233
|
-
children: props.children ?? /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
234
|
-
/* @__PURE__ */ jsx2("summary", { children: "Reasoning" }),
|
|
235
|
-
/* @__PURE__ */ jsx2("pre", { children: part.text })
|
|
236
|
-
] }),
|
|
237
|
-
"data-anvia-reasoning": ""
|
|
238
|
-
},
|
|
239
|
-
ref
|
|
240
|
-
);
|
|
241
|
-
}
|
|
242
|
-
);
|
|
243
|
-
var MessageTool = forwardRef2(function MessageTool2({ children, renderWhen = "always", ...props }, ref) {
|
|
244
|
-
const { part } = useMessagePart();
|
|
245
|
-
if (part.type !== "tool" || !shouldRenderTool(part, renderWhen)) {
|
|
246
|
-
return null;
|
|
247
|
-
}
|
|
248
|
-
const renderedChildren = typeof children === "function" ? children(part) : children ?? defaultToolContent();
|
|
249
|
-
return renderPrimitive(
|
|
250
|
-
"div",
|
|
251
|
-
{
|
|
252
|
-
...props,
|
|
253
|
-
children: renderedChildren,
|
|
254
|
-
"data-anvia-tool": "",
|
|
255
|
-
"data-state": part.state
|
|
256
|
-
},
|
|
257
|
-
ref
|
|
258
|
-
);
|
|
259
|
-
});
|
|
260
|
-
var MessageToolName = forwardRef2(
|
|
261
|
-
function MessageToolName2(props, ref) {
|
|
262
|
-
const { part } = useMessagePart();
|
|
263
|
-
if (part.type !== "tool") {
|
|
264
|
-
return null;
|
|
265
|
-
}
|
|
266
|
-
return renderPrimitive(
|
|
267
|
-
"span",
|
|
268
|
-
{
|
|
269
|
-
...props,
|
|
270
|
-
children: props.children ?? part.toolName,
|
|
271
|
-
"data-anvia-tool-name": ""
|
|
272
|
-
},
|
|
273
|
-
ref
|
|
274
|
-
);
|
|
275
|
-
}
|
|
276
|
-
);
|
|
277
|
-
var MessageToolStatus = forwardRef2(
|
|
278
|
-
function MessageToolStatus2(props, ref) {
|
|
279
|
-
const { part } = useMessagePart();
|
|
280
|
-
if (part.type !== "tool") {
|
|
281
|
-
return null;
|
|
282
|
-
}
|
|
283
|
-
return renderPrimitive(
|
|
284
|
-
"span",
|
|
285
|
-
{
|
|
286
|
-
...props,
|
|
287
|
-
children: props.children ?? toolStateLabel(part.state),
|
|
288
|
-
"data-anvia-tool-status": "",
|
|
289
|
-
"data-state": part.state
|
|
290
|
-
},
|
|
291
|
-
ref
|
|
292
|
-
);
|
|
293
|
-
}
|
|
294
|
-
);
|
|
295
|
-
var MessageToolInput = forwardRef2(
|
|
296
|
-
function MessageToolInput2(props, ref) {
|
|
297
|
-
const { part } = useMessagePart();
|
|
298
|
-
if (part.type !== "tool" || part.input === void 0) {
|
|
299
|
-
return null;
|
|
300
|
-
}
|
|
301
|
-
return renderPrimitive(
|
|
302
|
-
"pre",
|
|
303
|
-
{
|
|
304
|
-
...props,
|
|
305
|
-
children: props.children ?? stringifyValue(part.input),
|
|
306
|
-
"data-anvia-tool-input": ""
|
|
307
|
-
},
|
|
308
|
-
ref
|
|
309
|
-
);
|
|
310
|
-
}
|
|
311
|
-
);
|
|
312
|
-
var MessageToolOutput = forwardRef2(
|
|
313
|
-
function MessageToolOutput2(props, ref) {
|
|
314
|
-
const { part } = useMessagePart();
|
|
315
|
-
if (part.type !== "tool" || part.output === void 0) {
|
|
316
|
-
return null;
|
|
317
|
-
}
|
|
318
|
-
return renderPrimitive(
|
|
319
|
-
"pre",
|
|
320
|
-
{
|
|
321
|
-
...props,
|
|
322
|
-
children: props.children ?? stringifyValue(part.output),
|
|
323
|
-
"data-anvia-tool-output": ""
|
|
324
|
-
},
|
|
325
|
-
ref
|
|
326
|
-
);
|
|
327
|
-
}
|
|
328
|
-
);
|
|
329
|
-
var MessageToolError = forwardRef2(
|
|
330
|
-
function MessageToolError2(props, ref) {
|
|
331
|
-
const { part } = useMessagePart();
|
|
332
|
-
if (part.type !== "tool" || part.error === void 0) {
|
|
333
|
-
return null;
|
|
334
|
-
}
|
|
335
|
-
return renderPrimitive(
|
|
336
|
-
"div",
|
|
337
|
-
{
|
|
338
|
-
...props,
|
|
339
|
-
children: props.children ?? part.error.message,
|
|
340
|
-
"data-anvia-tool-error": "",
|
|
341
|
-
role: props.role ?? "alert"
|
|
342
|
-
},
|
|
343
|
-
ref
|
|
344
|
-
);
|
|
345
|
-
}
|
|
346
|
-
);
|
|
347
|
-
var MessageAttachment = forwardRef2(
|
|
348
|
-
function MessageAttachment2({ children, ...props }, ref) {
|
|
349
|
-
const { part } = useMessagePart();
|
|
350
|
-
if (part.type !== "attachment") {
|
|
351
|
-
return null;
|
|
352
|
-
}
|
|
353
|
-
const renderedChildren = typeof children === "function" ? children(part.attachment) : children ?? /* @__PURE__ */ jsx2(Attachment.Root, {});
|
|
354
|
-
return /* @__PURE__ */ jsx2(InternalAttachmentProvider, { value: { attachment: part.attachment }, children: renderPrimitive(
|
|
355
|
-
"div",
|
|
356
|
-
{
|
|
357
|
-
...props,
|
|
358
|
-
children: renderedChildren,
|
|
359
|
-
"data-anvia-message-attachment": ""
|
|
360
|
-
},
|
|
361
|
-
ref
|
|
362
|
-
) });
|
|
363
|
-
}
|
|
364
|
-
);
|
|
365
|
-
var MessageData = forwardRef2(
|
|
366
|
-
function MessageData2(props, ref) {
|
|
367
|
-
const { part } = useMessagePart();
|
|
368
|
-
if (part.type !== "data") {
|
|
369
|
-
return null;
|
|
370
|
-
}
|
|
371
|
-
return renderPrimitive(
|
|
372
|
-
"pre",
|
|
373
|
-
{
|
|
374
|
-
...props,
|
|
375
|
-
children: props.children ?? stringifyValue(part.data),
|
|
376
|
-
"data-anvia-data": "",
|
|
377
|
-
"data-name": part.name
|
|
378
|
-
},
|
|
379
|
-
ref
|
|
380
|
-
);
|
|
381
|
-
}
|
|
382
|
-
);
|
|
383
|
-
var MessageError = forwardRef2(
|
|
384
|
-
function MessageError2(props, ref) {
|
|
385
|
-
const { part } = useMessagePart();
|
|
386
|
-
if (part.type !== "error") {
|
|
387
|
-
return null;
|
|
388
|
-
}
|
|
389
|
-
return renderPrimitive(
|
|
390
|
-
"div",
|
|
391
|
-
{
|
|
392
|
-
...props,
|
|
393
|
-
children: props.children ?? part.error.message,
|
|
394
|
-
"data-anvia-error": "",
|
|
395
|
-
role: props.role ?? "alert"
|
|
396
|
-
},
|
|
397
|
-
ref
|
|
398
|
-
);
|
|
399
|
-
}
|
|
400
|
-
);
|
|
401
|
-
function defaultPart(part) {
|
|
402
|
-
if (part.type === "text") {
|
|
403
|
-
return /* @__PURE__ */ jsx2(MessageText, {});
|
|
404
|
-
}
|
|
405
|
-
if (part.type === "reasoning") {
|
|
406
|
-
return /* @__PURE__ */ jsx2(MessageReasoning, {});
|
|
407
|
-
}
|
|
408
|
-
if (part.type === "tool") {
|
|
409
|
-
return /* @__PURE__ */ jsx2(MessageTool, {});
|
|
410
|
-
}
|
|
411
|
-
if (part.type === "attachment") {
|
|
412
|
-
return /* @__PURE__ */ jsx2(MessageAttachment, {});
|
|
413
|
-
}
|
|
414
|
-
if (part.type === "data") {
|
|
415
|
-
return /* @__PURE__ */ jsx2(MessageData, {});
|
|
416
|
-
}
|
|
417
|
-
return /* @__PURE__ */ jsx2(MessageError, {});
|
|
418
|
-
}
|
|
419
|
-
function defaultToolContent() {
|
|
420
|
-
return /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
421
|
-
/* @__PURE__ */ jsx2(MessageToolName, {}),
|
|
422
|
-
/* @__PURE__ */ jsx2(MessageToolStatus, {}),
|
|
423
|
-
/* @__PURE__ */ jsx2(MessageToolInput, {}),
|
|
424
|
-
/* @__PURE__ */ jsx2(MessageToolOutput, {}),
|
|
425
|
-
/* @__PURE__ */ jsx2(MessageToolError, {})
|
|
426
|
-
] });
|
|
427
|
-
}
|
|
428
|
-
function defaultCodeComponent({
|
|
429
|
-
children,
|
|
430
|
-
className,
|
|
431
|
-
node: _node,
|
|
432
|
-
...props
|
|
433
|
-
}) {
|
|
434
|
-
const language = /language-(\S+)/.exec(className ?? "")?.[1];
|
|
435
|
-
return /* @__PURE__ */ jsx2(
|
|
436
|
-
"code",
|
|
437
|
-
{
|
|
438
|
-
className,
|
|
439
|
-
"data-anvia-code": "",
|
|
440
|
-
"data-anvia-inline-code": language === void 0 ? "" : void 0,
|
|
441
|
-
"data-language": language,
|
|
442
|
-
...props,
|
|
443
|
-
children
|
|
444
|
-
}
|
|
445
|
-
);
|
|
446
|
-
}
|
|
447
|
-
function defaultPreComponent({
|
|
448
|
-
children,
|
|
449
|
-
node: _node,
|
|
450
|
-
...props
|
|
451
|
-
}) {
|
|
452
|
-
return /* @__PURE__ */ jsx2(MessageCodeBlock, { ...props, children });
|
|
453
|
-
}
|
|
454
|
-
function shouldRenderTool(part, renderWhen) {
|
|
455
|
-
if (renderWhen === "always") {
|
|
456
|
-
return true;
|
|
457
|
-
}
|
|
458
|
-
if (renderWhen === "pending") {
|
|
459
|
-
return part.state === "input-streaming" || part.state === "input-available";
|
|
460
|
-
}
|
|
461
|
-
return part.state === "output-available" || part.state === "error";
|
|
462
|
-
}
|
|
463
|
-
function toolStateLabel(state) {
|
|
464
|
-
if (state === "output-available") {
|
|
465
|
-
return "Done";
|
|
466
|
-
}
|
|
467
|
-
if (state === "error") {
|
|
468
|
-
return "Error";
|
|
469
|
-
}
|
|
470
|
-
return "Running";
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
// src/message/root.tsx
|
|
474
|
-
import { forwardRef as forwardRef3 } from "react";
|
|
475
|
-
var MessageRoot = forwardRef3(function MessageRoot2({ children, ...props }, ref) {
|
|
476
|
-
const { message } = useMessage();
|
|
477
|
-
const renderedChildren = typeof children === "function" ? children(message) : children;
|
|
478
|
-
return renderPrimitive(
|
|
479
|
-
"article",
|
|
480
|
-
{
|
|
481
|
-
...props,
|
|
482
|
-
children: renderedChildren,
|
|
483
|
-
"data-anvia-message": "",
|
|
484
|
-
"data-anvia-message-id": message.id,
|
|
485
|
-
"data-role": message.role
|
|
486
|
-
},
|
|
487
|
-
ref
|
|
488
|
-
);
|
|
489
|
-
});
|
|
490
|
-
var MessageContent = forwardRef3(
|
|
491
|
-
function MessageContent2(props, ref) {
|
|
492
|
-
return renderPrimitive(
|
|
493
|
-
"div",
|
|
494
|
-
{
|
|
495
|
-
...props,
|
|
496
|
-
"data-anvia-message-content": ""
|
|
497
|
-
},
|
|
498
|
-
ref
|
|
499
|
-
);
|
|
500
|
-
}
|
|
501
|
-
);
|
|
502
|
-
|
|
503
|
-
// src/message/index.ts
|
|
504
|
-
var Message = {
|
|
505
|
-
Root: MessageRoot,
|
|
506
|
-
Content: MessageContent,
|
|
507
|
-
Parts: MessageParts,
|
|
508
|
-
Part: MessagePart,
|
|
509
|
-
Text: MessageText,
|
|
510
|
-
Markdown: MessageMarkdown,
|
|
511
|
-
CodeBlock: MessageCodeBlock,
|
|
512
|
-
Reasoning: MessageReasoning,
|
|
513
|
-
Tool: MessageTool,
|
|
514
|
-
ToolName: MessageToolName,
|
|
515
|
-
ToolInput: MessageToolInput,
|
|
516
|
-
ToolOutput: MessageToolOutput,
|
|
517
|
-
ToolError: MessageToolError,
|
|
518
|
-
ToolStatus: MessageToolStatus,
|
|
519
|
-
Attachment: MessageAttachment,
|
|
520
|
-
Data: MessageData,
|
|
521
|
-
Error: MessageError,
|
|
522
|
-
Actions: MessageActions,
|
|
523
|
-
Copy: MessageCopy,
|
|
524
|
-
Regenerate: MessageRegenerate
|
|
525
|
-
};
|
|
526
|
-
|
|
527
|
-
export {
|
|
528
|
-
Message
|
|
529
|
-
};
|
|
530
|
-
//# sourceMappingURL=chunk-FZANAMWH.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/message/actions.tsx","../src/format/message.ts","../src/format/value.ts","../src/message/parts.tsx","../src/message/root.tsx","../src/message/index.ts"],"sourcesContent":["import { forwardRef, type MouseEvent, useCallback, useEffect, useRef, useState } from \"react\";\n\nimport { useChatContext, useMessage } from \"../contexts\";\nimport { messageText } from \"../format\";\nimport { type PrimitiveProps, renderPrimitive } from \"../primitives\";\n\nconst MessageActions = forwardRef<HTMLDivElement, PrimitiveProps<\"div\">>(\n function MessageActions(props, ref) {\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: props.children ?? (\n <>\n <MessageCopy />\n <MessageRegenerate />\n </>\n ),\n \"data-anvia-message-actions\": \"\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\ntype MessageCopyState = \"idle\" | \"copied\" | \"error\";\n\nconst MessageCopy = forwardRef<HTMLButtonElement, PrimitiveProps<\"button\">>(function MessageCopy(\n { onClick, ...props },\n ref,\n) {\n const { message } = useMessage();\n const [copyState, setCopyState] = useState<MessageCopyState>(\"idle\");\n const text = messageText(message);\n const previousTextRef = useRef(text);\n const disabled = props.disabled ?? text.length === 0;\n\n useEffect(() => {\n if (previousTextRef.current !== text) {\n previousTextRef.current = text;\n setCopyState(\"idle\");\n }\n }, [text]);\n\n const handleClick = useCallback(\n async (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n if (event.defaultPrevented || disabled) {\n return;\n }\n const writeText = navigator.clipboard?.writeText;\n if (writeText === undefined) {\n setCopyState(\"error\");\n return;\n }\n try {\n await writeText.call(navigator.clipboard, text);\n setCopyState(\"copied\");\n } catch {\n setCopyState(\"error\");\n }\n },\n [disabled, onClick, text],\n );\n\n return renderPrimitive(\n \"button\",\n {\n ...props,\n children: props.children ?? \"Copy\",\n disabled,\n onClick: handleClick,\n type: props.type ?? \"button\",\n \"data-anvia-copy\": \"\",\n \"data-state\": copyState,\n } as PrimitiveProps<\"button\">,\n ref,\n );\n});\n\nconst MessageRegenerate = forwardRef<HTMLButtonElement, PrimitiveProps<\"button\">>(\n function MessageRegenerate({ onClick, ...props }, ref) {\n const chat = useChatContext();\n const { message } = useMessage();\n const latestAssistantMessage = [...chat.messages]\n .reverse()\n .find((item) => item.role === \"assistant\");\n const disabled =\n props.disabled ??\n (chat.status === \"streaming\" ||\n message.role !== \"assistant\" ||\n latestAssistantMessage?.id !== message.id);\n\n const handleClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n if (event.defaultPrevented || disabled) {\n return;\n }\n void chat.regenerate();\n },\n [chat, disabled, onClick],\n );\n\n return renderPrimitive(\n \"button\",\n {\n ...props,\n children: props.children ?? \"Regenerate\",\n disabled,\n onClick: handleClick,\n type: props.type ?? \"button\",\n \"data-anvia-regenerate\": \"\",\n \"data-state\": disabled ? \"disabled\" : \"idle\",\n } as PrimitiveProps<\"button\">,\n ref,\n );\n },\n);\n\nexport { MessageActions, MessageCopy, MessageRegenerate };\n","import type { UIMessage, UIMessagePart } from \"@anvia/react\";\n\nexport function messageText(message: UIMessage): string {\n return message.parts\n .filter((part): part is Extract<UIMessagePart, { type: \"text\" }> => part.type === \"text\")\n .map((part) => part.text)\n .join(\"\");\n}\n","export function stringifyValue(value: unknown): string {\n if (value === undefined) {\n return \"\";\n }\n if (typeof value === \"string\") {\n return value;\n }\n try {\n return JSON.stringify(value, null, 2);\n } catch {\n return String(value);\n }\n}\n","import type { UIAttachment, UIMessagePart } from \"@anvia/react\";\nimport { type ComponentPropsWithoutRef, forwardRef, type ReactNode } from \"react\";\nimport ReactMarkdown, {\n type Components,\n type Options as ReactMarkdownOptions,\n} from \"react-markdown\";\nimport remarkGfm from \"remark-gfm\";\n\nimport { Attachment } from \"../attachment/index\";\nimport {\n InternalAttachmentProvider,\n InternalMessagePartProvider,\n useMessage,\n useMessagePart,\n useOptionalMessagePart,\n} from \"../contexts\";\nimport { stringifyValue } from \"../format\";\nimport { type PrimitiveProps, renderPrimitive } from \"../primitives\";\n\ntype MessagePartChildren = ReactNode | ((part: UIMessagePart) => ReactNode);\nexport type MessagePartsFilter = (part: UIMessagePart) => boolean;\nexport type MessageToolPart = Extract<UIMessagePart, { type: \"tool\" }>;\ntype MessageToolChildren = ReactNode | ((part: MessageToolPart) => ReactNode);\nexport type MessageToolRenderWhen = \"always\" | \"pending\" | \"settled\";\nexport type MessageAttachmentPart = Extract<UIMessagePart, { type: \"attachment\" }>;\ntype MessageAttachmentChildren = ReactNode | ((attachment: UIAttachment) => ReactNode);\n\ntype MessagePartsProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: MessagePartChildren;\n filter?: MessagePartsFilter;\n};\n\nconst MessageParts = forwardRef<HTMLDivElement, MessagePartsProps>(function MessageParts(\n { children, filter, ...props },\n ref,\n) {\n const { message } = useMessage();\n const parts = filter === undefined ? message.parts : message.parts.filter(filter);\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: parts.map((part) => (\n <InternalMessagePartProvider key={part.id} part={part}>\n {typeof children === \"function\" ? children(part) : (children ?? <MessagePart />)}\n </InternalMessagePartProvider>\n )),\n \"data-anvia-message-parts\": \"\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n});\n\ntype MessagePartProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: MessagePartChildren;\n};\n\nconst MessagePart = forwardRef<HTMLDivElement, MessagePartProps>(function MessagePart(\n { children, ...props },\n ref,\n) {\n const { part } = useMessagePart();\n const renderedChildren =\n typeof children === \"function\" ? children(part) : (children ?? defaultPart(part));\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: renderedChildren,\n \"data-anvia-part\": \"\",\n \"data-part\": part.type,\n } as PrimitiveProps<\"div\">,\n ref,\n );\n});\n\nconst MessageText = forwardRef<HTMLSpanElement, PrimitiveProps<\"span\">>(\n function MessageText(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"text\") {\n return null;\n }\n\n return renderPrimitive(\n \"span\",\n {\n ...props,\n children: props.children ?? part.text,\n \"data-anvia-text\": \"\",\n } as PrimitiveProps<\"span\">,\n ref,\n );\n },\n);\n\ntype MessageMarkdownProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: string;\n components?: Components;\n remarkPlugins?: ReactMarkdownOptions[\"remarkPlugins\"];\n};\n\nconst MessageMarkdown = forwardRef<HTMLDivElement, MessageMarkdownProps>(function MessageMarkdown(\n { children, components, remarkPlugins, ...props },\n ref,\n) {\n const { message } = useMessage();\n const partContext = useOptionalMessagePart();\n const part = partContext?.part;\n if (part !== undefined && part.type !== \"text\") {\n return null;\n }\n\n const markdown =\n children ??\n (part?.type === \"text\"\n ? part.text\n : message.parts.flatMap((item) => (item.type === \"text\" ? [item.text] : [])).join(\"\\n\\n\"));\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: (\n <ReactMarkdown\n components={{ code: defaultCodeComponent, pre: defaultPreComponent, ...components }}\n remarkPlugins={remarkPlugins ?? [remarkGfm]}\n >\n {markdown}\n </ReactMarkdown>\n ),\n \"data-anvia-markdown\": \"\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n});\n\ntype MessageCodeBlockProps = Omit<PrimitiveProps<\"pre\">, \"children\"> & {\n children?: ReactNode;\n code?: string;\n language?: string;\n};\n\nconst MessageCodeBlock = forwardRef<HTMLPreElement, MessageCodeBlockProps>(\n function MessageCodeBlock({ children, code, language, ...props }, ref) {\n return renderPrimitive(\n \"pre\",\n {\n ...props,\n children: children ?? (\n <code data-anvia-code=\"\" data-language={language}>\n {code ?? \"\"}\n </code>\n ),\n \"data-anvia-code-block\": \"\",\n \"data-language\": language,\n } as PrimitiveProps<\"pre\">,\n ref,\n );\n },\n);\n\nconst MessageReasoning = forwardRef<HTMLDetailsElement, PrimitiveProps<\"details\">>(\n function MessageReasoning(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"reasoning\") {\n return null;\n }\n\n return renderPrimitive(\n \"details\",\n {\n ...props,\n children: props.children ?? (\n <>\n <summary>Reasoning</summary>\n <pre>{part.text}</pre>\n </>\n ),\n \"data-anvia-reasoning\": \"\",\n } as PrimitiveProps<\"details\">,\n ref,\n );\n },\n);\n\ntype MessageToolProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: MessageToolChildren;\n renderWhen?: MessageToolRenderWhen;\n};\n\nconst MessageTool = forwardRef<HTMLDivElement, MessageToolProps>(function MessageTool(\n { children, renderWhen = \"always\", ...props },\n ref,\n) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\" || !shouldRenderTool(part, renderWhen)) {\n return null;\n }\n const renderedChildren =\n typeof children === \"function\" ? children(part) : (children ?? defaultToolContent());\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: renderedChildren,\n \"data-anvia-tool\": \"\",\n \"data-state\": part.state,\n } as PrimitiveProps<\"div\">,\n ref,\n );\n});\n\nconst MessageToolName = forwardRef<HTMLSpanElement, PrimitiveProps<\"span\">>(\n function MessageToolName(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\") {\n return null;\n }\n\n return renderPrimitive(\n \"span\",\n {\n ...props,\n children: props.children ?? part.toolName,\n \"data-anvia-tool-name\": \"\",\n } as PrimitiveProps<\"span\">,\n ref,\n );\n },\n);\n\nconst MessageToolStatus = forwardRef<HTMLSpanElement, PrimitiveProps<\"span\">>(\n function MessageToolStatus(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\") {\n return null;\n }\n\n return renderPrimitive(\n \"span\",\n {\n ...props,\n children: props.children ?? toolStateLabel(part.state),\n \"data-anvia-tool-status\": \"\",\n \"data-state\": part.state,\n } as PrimitiveProps<\"span\">,\n ref,\n );\n },\n);\n\nconst MessageToolInput = forwardRef<HTMLPreElement, PrimitiveProps<\"pre\">>(\n function MessageToolInput(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\" || part.input === undefined) {\n return null;\n }\n\n return renderPrimitive(\n \"pre\",\n {\n ...props,\n children: props.children ?? stringifyValue(part.input),\n \"data-anvia-tool-input\": \"\",\n } as PrimitiveProps<\"pre\">,\n ref,\n );\n },\n);\n\nconst MessageToolOutput = forwardRef<HTMLPreElement, PrimitiveProps<\"pre\">>(\n function MessageToolOutput(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\" || part.output === undefined) {\n return null;\n }\n\n return renderPrimitive(\n \"pre\",\n {\n ...props,\n children: props.children ?? stringifyValue(part.output),\n \"data-anvia-tool-output\": \"\",\n } as PrimitiveProps<\"pre\">,\n ref,\n );\n },\n);\n\nconst MessageToolError = forwardRef<HTMLDivElement, PrimitiveProps<\"div\">>(\n function MessageToolError(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"tool\" || part.error === undefined) {\n return null;\n }\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: props.children ?? part.error.message,\n \"data-anvia-tool-error\": \"\",\n role: props.role ?? \"alert\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\ntype MessageAttachmentProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: MessageAttachmentChildren;\n};\n\nconst MessageAttachment = forwardRef<HTMLDivElement, MessageAttachmentProps>(\n function MessageAttachment({ children, ...props }, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"attachment\") {\n return null;\n }\n const renderedChildren =\n typeof children === \"function\"\n ? children(part.attachment)\n : (children ?? <Attachment.Root />);\n\n return (\n <InternalAttachmentProvider value={{ attachment: part.attachment }}>\n {renderPrimitive(\n \"div\",\n {\n ...props,\n children: renderedChildren,\n \"data-anvia-message-attachment\": \"\",\n } as PrimitiveProps<\"div\">,\n ref,\n )}\n </InternalAttachmentProvider>\n );\n },\n);\n\nconst MessageData = forwardRef<HTMLPreElement, PrimitiveProps<\"pre\">>(\n function MessageData(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"data\") {\n return null;\n }\n\n return renderPrimitive(\n \"pre\",\n {\n ...props,\n children: props.children ?? stringifyValue(part.data),\n \"data-anvia-data\": \"\",\n \"data-name\": part.name,\n } as PrimitiveProps<\"pre\">,\n ref,\n );\n },\n);\n\nconst MessageError = forwardRef<HTMLDivElement, PrimitiveProps<\"div\">>(\n function MessageError(props, ref) {\n const { part } = useMessagePart();\n if (part.type !== \"error\") {\n return null;\n }\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: props.children ?? part.error.message,\n \"data-anvia-error\": \"\",\n role: props.role ?? \"alert\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\nfunction defaultPart(part: UIMessagePart): ReactNode {\n if (part.type === \"text\") {\n return <MessageText />;\n }\n if (part.type === \"reasoning\") {\n return <MessageReasoning />;\n }\n if (part.type === \"tool\") {\n return <MessageTool />;\n }\n if (part.type === \"attachment\") {\n return <MessageAttachment />;\n }\n if (part.type === \"data\") {\n return <MessageData />;\n }\n return <MessageError />;\n}\n\nfunction defaultToolContent(): ReactNode {\n return (\n <>\n <MessageToolName />\n <MessageToolStatus />\n <MessageToolInput />\n <MessageToolOutput />\n <MessageToolError />\n </>\n );\n}\n\nfunction defaultCodeComponent({\n children,\n className,\n node: _node,\n ...props\n}: ComponentPropsWithoutRef<\"code\"> & { node?: unknown }): ReactNode {\n const language = /language-(\\S+)/.exec(className ?? \"\")?.[1];\n\n return (\n <code\n className={className}\n data-anvia-code=\"\"\n data-anvia-inline-code={language === undefined ? \"\" : undefined}\n data-language={language}\n {...props}\n >\n {children}\n </code>\n );\n}\n\nfunction defaultPreComponent({\n children,\n node: _node,\n ...props\n}: ComponentPropsWithoutRef<\"pre\"> & { node?: unknown }): ReactNode {\n return <MessageCodeBlock {...props}>{children}</MessageCodeBlock>;\n}\n\nfunction shouldRenderTool(part: MessageToolPart, renderWhen: MessageToolRenderWhen): boolean {\n if (renderWhen === \"always\") {\n return true;\n }\n if (renderWhen === \"pending\") {\n return part.state === \"input-streaming\" || part.state === \"input-available\";\n }\n return part.state === \"output-available\" || part.state === \"error\";\n}\n\nfunction toolStateLabel(state: MessageToolPart[\"state\"]): string {\n if (state === \"output-available\") {\n return \"Done\";\n }\n if (state === \"error\") {\n return \"Error\";\n }\n return \"Running\";\n}\n\nexport {\n MessageAttachment,\n MessageCodeBlock,\n MessageData,\n MessageError,\n MessageMarkdown,\n MessagePart,\n MessageParts,\n MessageReasoning,\n MessageText,\n MessageTool,\n MessageToolError,\n MessageToolInput,\n MessageToolName,\n MessageToolOutput,\n MessageToolStatus,\n};\n","import type { UIMessage } from \"@anvia/react\";\nimport { forwardRef, type ReactNode } from \"react\";\n\nimport { useMessage } from \"../contexts\";\nimport { type PrimitiveProps, renderPrimitive } from \"../primitives\";\n\ntype MessageChildren = ReactNode | ((message: UIMessage) => ReactNode);\n\ntype MessageRootProps = Omit<PrimitiveProps<\"article\">, \"children\"> & {\n children?: MessageChildren;\n};\n\nconst MessageRoot = forwardRef<HTMLElement, MessageRootProps>(function MessageRoot(\n { children, ...props },\n ref,\n) {\n const { message } = useMessage();\n const renderedChildren = typeof children === \"function\" ? children(message) : children;\n\n return renderPrimitive(\n \"article\",\n {\n ...props,\n children: renderedChildren,\n \"data-anvia-message\": \"\",\n \"data-anvia-message-id\": message.id,\n \"data-role\": message.role,\n } as PrimitiveProps<\"article\">,\n ref,\n );\n});\n\nconst MessageContent = forwardRef<HTMLDivElement, PrimitiveProps<\"div\">>(\n function MessageContent(props, ref) {\n return renderPrimitive(\n \"div\",\n {\n ...props,\n \"data-anvia-message-content\": \"\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\nexport { MessageContent, MessageRoot };\n","import { MessageActions, MessageCopy, MessageRegenerate } from \"./actions\";\nimport {\n MessageAttachment,\n MessageCodeBlock,\n MessageData,\n MessageError,\n MessageMarkdown,\n MessagePart,\n MessageParts,\n MessageReasoning,\n MessageText,\n MessageTool,\n MessageToolError,\n MessageToolInput,\n MessageToolName,\n MessageToolOutput,\n MessageToolStatus,\n} from \"./parts\";\nimport { MessageContent, MessageRoot } from \"./root\";\n\nexport const Message = {\n Root: MessageRoot,\n Content: MessageContent,\n Parts: MessageParts,\n Part: MessagePart,\n Text: MessageText,\n Markdown: MessageMarkdown,\n CodeBlock: MessageCodeBlock,\n Reasoning: MessageReasoning,\n Tool: MessageTool,\n ToolName: MessageToolName,\n ToolInput: MessageToolInput,\n ToolOutput: MessageToolOutput,\n ToolError: MessageToolError,\n ToolStatus: MessageToolStatus,\n Attachment: MessageAttachment,\n Data: MessageData,\n Error: MessageError,\n Actions: MessageActions,\n Copy: MessageCopy,\n Regenerate: MessageRegenerate,\n} as const;\n\nexport type { MessageContextValue, MessagePartContextValue } from \"../contexts\";\nexport { useChatContext, useMessage, useMessagePart } from \"../contexts\";\nexport type {\n MessageAttachmentPart,\n MessagePartsFilter,\n MessageToolPart,\n MessageToolRenderWhen,\n} from \"./parts\";\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,SAAS,YAA6B,aAAa,WAAW,QAAQ,gBAAgB;;;ACE/E,SAAS,YAAY,SAA4B;AACtD,SAAO,QAAQ,MACZ,OAAO,CAAC,SAA2D,KAAK,SAAS,MAAM,EACvF,IAAI,CAAC,SAAS,KAAK,IAAI,EACvB,KAAK,EAAE;AACZ;;;ACPO,SAAS,eAAe,OAAwB;AACrD,MAAI,UAAU,QAAW;AACvB,WAAO;AAAA,EACT;AACA,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA,EACT;AACA,MAAI;AACF,WAAO,KAAK,UAAU,OAAO,MAAM,CAAC;AAAA,EACtC,QAAQ;AACN,WAAO,OAAO,KAAK;AAAA,EACrB;AACF;;;AFCU,mBACE,KADF;AAPV,IAAM,iBAAiB;AAAA,EACrB,SAASA,gBAAe,OAAO,KAAK;AAClC,WAAO;AAAA,MACL;AAAA,MACA;AAAA,QACE,GAAG;AAAA,QACH,UAAU,MAAM,YACd,iCACE;AAAA,8BAAC,eAAY;AAAA,UACb,oBAAC,qBAAkB;AAAA,WACrB;AAAA,QAEF,8BAA8B;AAAA,MAChC;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;AAIA,IAAM,cAAc,WAAwD,SAASC,aACnF,EAAE,SAAS,GAAG,MAAM,GACpB,KACA;AACA,QAAM,EAAE,QAAQ,IAAI,WAAW;AAC/B,QAAM,CAAC,WAAW,YAAY,IAAI,SAA2B,MAAM;AACnE,QAAM,OAAO,YAAY,OAAO;AAChC,QAAM,kBAAkB,OAAO,IAAI;AACnC,QAAM,WAAW,MAAM,YAAY,KAAK,WAAW;AAEnD,YAAU,MAAM;AACd,QAAI,gBAAgB,YAAY,MAAM;AACpC,sBAAgB,UAAU;AAC1B,mBAAa,MAAM;AAAA,IACrB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O,KAAK,UAAU,qBAAqB,KAAK,UAAU;AAAA,EAC5D;AACA,SAAO,KAAK,UAAU,sBAAsB,KAAK,UAAU;AAC7D;AAEA,SAAS,eAAe,OAAyC;AAC/D,MAAI,UAAU,oBAAoB;AAChC,WAAO;AAAA,EACT;AACA,MAAI,UAAU,SAAS;AACrB,WAAO;AAAA,EACT;AACA,SAAO;AACT;;;AC5cA,SAAS,cAAAkB,mBAAkC;AAW3C,IAAM,cAAcC,YAA0C,SAASC,aACrE,EAAE,UAAU,GAAG,MAAM,GACrB,KACA;AACA,QAAM,EAAE,QAAQ,IAAI,WAAW;AAC/B,QAAM,mBAAmB,OAAO,aAAa,aAAa,SAAS,OAAO,IAAI;AAE9E,SAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE,GAAG;AAAA,MACH,UAAU;AAAA,MACV,sBAAsB;AAAA,MACtB,yBAAyB,QAAQ;AAAA,MACjC,aAAa,QAAQ;AAAA,IACvB;AAAA,IACA;AAAA,EACF;AACF,CAAC;AAED,IAAM,iBAAiBD;AAAA,EACrB,SAASE,gBAAe,OAAO,KAAK;AAClC,WAAO;AAAA,MACL;AAAA,MACA;AAAA,QACE,GAAG;AAAA,QACH,8BAA8B;AAAA,MAChC;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;;;ACvBO,IAAM,UAAU;AAAA,EACrB,MAAM;AAAA,EACN,SAAS;AAAA,EACT,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,UAAU;AAAA,EACV,WAAW;AAAA,EACX,WAAW;AAAA,EACX,MAAM;AAAA,EACN,UAAU;AAAA,EACV,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AAAA,EACN,YAAY;AACd;","names":["MessageActions","MessageCopy","MessageRegenerate","forwardRef","Fragment","jsx","jsxs","forwardRef","MessageParts","MessagePart","MessageText","MessageMarkdown","MessageCodeBlock","MessageReasoning","MessageTool","MessageToolName","MessageToolStatus","MessageToolInput","MessageToolOutput","MessageToolError","MessageAttachment","MessageData","MessageError","forwardRef","forwardRef","MessageRoot","MessageContent"]}
|