@tomny-dev/uzi 0.20.0 → 0.20.1

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 (48) hide show
  1. package/dist/components/ai-chat/AIChat.d.ts +2 -25
  2. package/dist/components/ai-chat/AIChat.d.ts.map +1 -1
  3. package/dist/components/ai-chat/AIChatParts.d.ts +32 -0
  4. package/dist/components/ai-chat/AIChatParts.d.ts.map +1 -0
  5. package/dist/components/ai-chat/activityLabel.d.ts +20 -0
  6. package/dist/components/ai-chat/activityLabel.d.ts.map +1 -0
  7. package/dist/components/ai-chat/activityLabel.test.d.ts +2 -0
  8. package/dist/components/ai-chat/activityLabel.test.d.ts.map +1 -0
  9. package/dist/index.cjs +6 -5
  10. package/dist/index.js +4 -3
  11. package/dist/index59.js +8 -2
  12. package/dist/index59.js.map +1 -1
  13. package/dist/index60.cjs +10 -1
  14. package/dist/index60.cjs.map +1 -1
  15. package/dist/index60.js +1 -1
  16. package/dist/index60.js.map +1 -1
  17. package/dist/index61.cjs +1 -1
  18. package/dist/index61.cjs.map +1 -1
  19. package/dist/index84.js +3 -556
  20. package/dist/index84.js.map +1 -1
  21. package/dist/index85.cjs +6 -556
  22. package/dist/index85.cjs.map +1 -1
  23. package/dist/index85.js +11 -34
  24. package/dist/index85.js.map +1 -1
  25. package/dist/index86.cjs +11 -49
  26. package/dist/index86.cjs.map +1 -1
  27. package/dist/index86.js +539 -227
  28. package/dist/index86.js.map +1 -1
  29. package/dist/index87.cjs +541 -226
  30. package/dist/index87.cjs.map +1 -1
  31. package/dist/index87.js +33 -15
  32. package/dist/index87.js.map +1 -1
  33. package/dist/index88.cjs +48 -21
  34. package/dist/index88.cjs.map +1 -1
  35. package/dist/index88.js +250 -29
  36. package/dist/index88.js.map +1 -1
  37. package/dist/index89.cjs +250 -30
  38. package/dist/index89.cjs.map +1 -1
  39. package/dist/index89.js +19 -0
  40. package/dist/index89.js.map +1 -0
  41. package/dist/index90.cjs +25 -0
  42. package/dist/index90.cjs.map +1 -0
  43. package/dist/index90.js +36 -0
  44. package/dist/index90.js.map +1 -0
  45. package/dist/index91.cjs +37 -0
  46. package/dist/index91.cjs.map +1 -0
  47. package/dist/style.css +19 -2
  48. package/package.json +1 -1
package/dist/index84.js CHANGED
@@ -1,10 +1,8 @@
1
1
  "use client";
2
2
  import ai_chat_module_default from "./index83.js";
3
- import { useEffect, useMemo, useRef, useState } from "react";
3
+ import { useEffect, useRef, useState } from "react";
4
4
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
- import { AuiConfig, AuiProvider, ThreadPrimitive } from "@assistant-ui/react";
6
- import { AISDKChat, AssistantChatTransport, useAISDKChat } from "@assistant-ui/ai-sdk";
7
- //#region src/components/ai-chat/AIChat.tsx
5
+ //#region src/components/ai-chat/AIChatParts.tsx
8
6
  function isRecord(value) {
9
7
  return typeof value === "object" && value !== null && !Array.isArray(value);
10
8
  }
@@ -275,558 +273,7 @@ function renderPart(part, index, components, onToolApproval, pendingApprovalId)
275
273
  children: JSON.stringify(part, null, 2)
276
274
  });
277
275
  }
278
- var DEFAULT_MESSAGE_LIMIT = 8;
279
- function AIChat({ api, scope, scopeLabel, fetch: requestFetch, headers, credentials, prepareSendMessagesRequest, sessionKey, messageLimit = DEFAULT_MESSAGE_LIMIT, inputPlaceholder = "Ask a question...", inputAriaLabel = "Message", inputMaxLength = 2e3, components, toolbarActions, showNewChatInToolbar = true, newChatRequestKey, attachments, activityLabel, toolActivityLabels, history, sendAutomaticallyWhen, onClose, className, style }) {
280
- const [session, setSession] = useState(0);
281
- const transport = useMemo(() => new AssistantChatTransport({
282
- api,
283
- ...scope ? { body: { scope } } : {},
284
- ...requestFetch ? { fetch: requestFetch } : {},
285
- ...headers ? { headers } : {},
286
- ...credentials ? { credentials } : {},
287
- ...prepareSendMessagesRequest ? { prepareSendMessagesRequest } : {}
288
- }), [
289
- api,
290
- scope,
291
- requestFetch,
292
- headers,
293
- credentials,
294
- prepareSendMessagesRequest
295
- ]);
296
- const config = useMemo(() => AuiConfig({ threads: AISDKChat({
297
- transport,
298
- ...sendAutomaticallyWhen ? { sendAutomaticallyWhen } : {}
299
- }) }), [
300
- transport,
301
- session,
302
- sendAutomaticallyWhen
303
- ]);
304
- return /* @__PURE__ */ jsxs("div", {
305
- className: [ai_chat_module_default.container, className].filter(Boolean).join(" "),
306
- style,
307
- children: [
308
- scopeLabel && /* @__PURE__ */ jsxs("div", {
309
- className: ai_chat_module_default.scope,
310
- children: [/* @__PURE__ */ jsx("span", {
311
- className: ai_chat_module_default.scopeLabel,
312
- children: "Current scope"
313
- }), /* @__PURE__ */ jsx("strong", { children: scopeLabel })]
314
- }),
315
- onClose && /* @__PURE__ */ jsx("button", {
316
- className: ai_chat_module_default.closeBtn,
317
- type: "button",
318
- onClick: onClose,
319
- "aria-label": "Close chat",
320
- children: "✕"
321
- }),
322
- /* @__PURE__ */ jsx(AuiProvider, {
323
- config,
324
- children: /* @__PURE__ */ jsx(ThreadPrimitive.Root, {
325
- className: ai_chat_module_default.thread,
326
- children: /* @__PURE__ */ jsx(ChatViewport, {
327
- messageLimit: Number.isFinite(messageLimit) ? Math.max(1, Math.floor(messageLimit)) : DEFAULT_MESSAGE_LIMIT,
328
- inputPlaceholder,
329
- inputAriaLabel,
330
- inputMaxLength,
331
- components,
332
- toolbarActions,
333
- showNewChatInToolbar,
334
- newChatRequestKey,
335
- attachmentOptions: attachments,
336
- activityLabel,
337
- toolActivityLabels,
338
- history,
339
- onNewChat: () => setSession((previous) => previous + 1)
340
- })
341
- })
342
- }, JSON.stringify([
343
- api,
344
- scope,
345
- sessionKey,
346
- session
347
- ]))
348
- ]
349
- });
350
- }
351
- function ChatViewport({ messageLimit, inputPlaceholder, inputAriaLabel, inputMaxLength, components, toolbarActions, showNewChatInToolbar, newChatRequestKey, attachmentOptions, activityLabel, toolActivityLabels, history, onNewChat }) {
352
- const chat = useAISDKChat();
353
- const [draft, setDraft] = useState("");
354
- const [selectedFiles, setSelectedFiles] = useState([]);
355
- const [attachmentError, setAttachmentError] = useState(null);
356
- const [attachmentPreviews, setAttachmentPreviews] = useState([]);
357
- const [hydrated, setHydrated] = useState(!history);
358
- const expectedRestoredId = useRef(null);
359
- const saveQueue = useRef(Promise.resolve());
360
- const [approvalBusy, setApprovalBusy] = useState(false);
361
- useEffect(() => {
362
- const urls = selectedFiles.map((file) => file.type.startsWith("image/") && typeof URL.createObjectURL === "function" ? URL.createObjectURL(file) : "");
363
- setAttachmentPreviews(urls);
364
- return () => urls.forEach((url) => {
365
- if (url && typeof URL.revokeObjectURL === "function") URL.revokeObjectURL(url);
366
- });
367
- }, [selectedFiles]);
368
- const messages = chat?.messages ?? [];
369
- const status = chat?.status ?? "ready";
370
- const isBusy = status === "submitted" || status === "streaming";
371
- const historyFull = messages.filter((message) => message.role === "user").length >= messageLimit;
372
- const reportHistoryError = (operation, error) => {
373
- if (history?.onError) history.onError(operation, error);
374
- else console.warn(`[Uzi AIChat] History ${operation} failed`);
375
- };
376
- useEffect(() => {
377
- if (!history) return;
378
- let active = true;
379
- Promise.resolve().then(() => history.load()).then((restored) => {
380
- if (!active) return;
381
- if (Array.isArray(restored)) {
382
- const valid = restored.filter((message) => typeof message?.id === "string" && (message.role === "user" || message.role === "assistant") && Array.isArray(message.parts));
383
- expectedRestoredId.current = valid.length ? valid[0].id : null;
384
- if (valid.length) chat?.setMessages(valid);
385
- }
386
- setHydrated(true);
387
- }).catch((error) => {
388
- if (active) {
389
- reportHistoryError("load", error);
390
- setHydrated(true);
391
- }
392
- });
393
- return () => {
394
- active = false;
395
- };
396
- }, [chat?.setMessages, history]);
397
- useEffect(() => {
398
- if (!history || !hydrated || isBusy) return;
399
- const snapshot = messages.filter((message) => message.role === "user" || message.role === "assistant").map((message) => ({
400
- id: message.id,
401
- role: message.role,
402
- parts: message.parts,
403
- ...isRecord(message.metadata) ? { metadata: message.metadata } : {}
404
- }));
405
- if (expectedRestoredId.current) {
406
- if (!snapshot.some((message) => message.id === expectedRestoredId.current)) return;
407
- expectedRestoredId.current = null;
408
- }
409
- saveQueue.current = saveQueue.current.then(() => history.save(snapshot), () => history.save(snapshot)).then(() => {}, (error) => {
410
- reportHistoryError("save", error);
411
- });
412
- }, [
413
- history,
414
- hydrated,
415
- isBusy,
416
- messages
417
- ]);
418
- const handleSelectedFiles = (files) => {
419
- if (!attachmentOptions) return;
420
- const selected = Array.from(files);
421
- if (selected.length + selectedFiles.length > (attachmentOptions.maxFiles ?? 3)) {
422
- setAttachmentError("Too many attachments.");
423
- return;
424
- }
425
- if (selected.some((file) => file.size > (attachmentOptions.maxBytesPerFile ?? 5 * 1024 * 1024))) {
426
- setAttachmentError("An attachment exceeds the size limit.");
427
- return;
428
- }
429
- const allowedTypes = attachmentOptions.accept.split(",").map((item) => item.trim());
430
- if (selected.some((file) => !allowedTypes.some((allow) => allow === file.type || allow.endsWith("/*") && file.type.startsWith(allow.slice(0, -1))))) {
431
- setAttachmentError("Unsupported attachment type.");
432
- return;
433
- }
434
- setAttachmentError(null);
435
- setSelectedFiles((existing) => [...existing, ...selected]);
436
- };
437
- const handleSubmit = () => {
438
- const text = draft.trim();
439
- if (!chat || !text && selectedFiles.length === 0 || isBusy || historyFull || chat.error || !hydrated || approvalBusy) return;
440
- const files = selectedFiles.length ? new DataTransfer() : null;
441
- selectedFiles.forEach((file) => files?.items.add(file));
442
- const previousDraft = draft;
443
- const previousFiles = selectedFiles;
444
- setDraft("");
445
- setSelectedFiles([]);
446
- setAttachmentError(null);
447
- Promise.resolve(chat.sendMessage({
448
- text,
449
- ...files ? { files: files.files } : {}
450
- })).catch(() => {
451
- setDraft((current) => current || previousDraft);
452
- setSelectedFiles((current) => current.length ? current : previousFiles);
453
- });
454
- };
455
- const handleNewChat = () => {
456
- (async () => {
457
- await chat?.stop();
458
- if (history) try {
459
- await saveQueue.current;
460
- await history.clear();
461
- } catch (error) {
462
- reportHistoryError("clear", error);
463
- return;
464
- }
465
- onNewChat();
466
- })();
467
- };
468
- const lastNewChatRequestKey = useRef(newChatRequestKey);
469
- useEffect(() => {
470
- if (lastNewChatRequestKey.current === newChatRequestKey) return;
471
- lastNewChatRequestKey.current = newChatRequestKey;
472
- handleNewChat();
473
- }, [newChatRequestKey]);
474
- const handleRetry = () => {
475
- if (!chat || isBusy) return;
476
- chat.clearError();
477
- chat.regenerate();
478
- };
479
- return /* @__PURE__ */ jsx(AIChatView, {
480
- messages: messages.filter((message) => message.role === "user" || message.role === "assistant").map((message) => ({
481
- id: message.id,
482
- role: message.role,
483
- parts: message.parts,
484
- ...isRecord(message.metadata) ? { metadata: message.metadata } : {}
485
- })),
486
- status,
487
- activityLabel,
488
- toolActivityLabels,
489
- error: chat?.error,
490
- draft,
491
- onDraftChange: setDraft,
492
- onSend: handleSubmit,
493
- onStop: () => {
494
- chat?.stop();
495
- },
496
- onRetry: handleRetry,
497
- onNewChat: handleNewChat,
498
- showNewChatInToolbar,
499
- toolbarActions,
500
- messageLimit,
501
- attachments: selectedFiles.map((file, index) => ({
502
- name: file.name,
503
- size: file.size,
504
- ...attachmentPreviews[index] ? { previewUrl: attachmentPreviews[index] } : {}
505
- })),
506
- onSelectAttachments: attachmentOptions ? handleSelectedFiles : void 0,
507
- onRemoveAttachment: attachmentOptions ? (index) => setSelectedFiles((files) => files.filter((_, i) => i !== index)) : void 0,
508
- attachmentAccept: attachmentOptions?.accept,
509
- attachmentError,
510
- onToolApproval: chat ? async (id, approved) => {
511
- if (approvalBusy) return;
512
- setApprovalBusy(true);
513
- try {
514
- await chat.addToolApprovalResponse({
515
- id,
516
- approved,
517
- ...!approved ? { reason: "User denied approval" } : {}
518
- });
519
- } finally {
520
- setApprovalBusy(false);
521
- }
522
- } : void 0,
523
- inputPlaceholder,
524
- inputAriaLabel,
525
- inputMaxLength,
526
- components
527
- });
528
- }
529
- /**
530
- * Controlled chat presentation for apps with their own AI SDK/assistant-ui
531
- * runtime. It does not create providers, transports or chat state. Callbacks
532
- * are the only way messages/actions leave the view.
533
- */
534
- function AIChatView({ messages, status = "ready", activityLabel = "Working on your response…", toolActivityLabels, error, draft = "", onDraftChange, onSend, onStop, onRetry, onNewChat, showNewChatInToolbar = true, messageLimit, inputPlaceholder = "Ask a question...", inputAriaLabel = "Message", inputMaxLength = 2e3, components, attachments, onSelectAttachments, onRemoveAttachment, attachmentAccept, attachmentError, onToolApproval, toolbarActions, header, composerLeading, composerTrailing, composer, emptyState, className, style }) {
535
- const viewportRef = useRef(null);
536
- const pinnedToBottom = useRef(true);
537
- const fileInputRef = useRef(null);
538
- const approvalRef = useRef(null);
539
- const [pendingApprovalId, setPendingApprovalId] = useState(null);
540
- const [approvalError, setApprovalError] = useState(null);
541
- const respondToApproval = async (id, approved) => {
542
- if (!onToolApproval || approvalRef.current) return;
543
- approvalRef.current = id;
544
- setPendingApprovalId(id);
545
- setApprovalError(null);
546
- try {
547
- await onToolApproval(id, approved);
548
- } catch {
549
- setApprovalError("Could not submit approval. Please try again.");
550
- } finally {
551
- approvalRef.current = null;
552
- setPendingApprovalId(null);
553
- }
554
- };
555
- const isBusy = status === "submitted" || status === "streaming";
556
- const lastMessage = messages[messages.length - 1];
557
- const assistantParts = lastMessage?.role === "assistant" ? lastMessage.parts.filter(isRecord) : [];
558
- const lastPart = [...assistantParts].reverse().find((part) => part.type !== "step-start");
559
- const lastPartType = asString(lastPart?.type) ?? "";
560
- const activeTool = (lastPartType.startsWith("tool-") || lastPartType === "dynamic-tool") && lastPart?.state !== "output-available" && lastPart?.state !== "output-error" ? lastPart : void 0;
561
- const hasAnswer = assistantParts.some((part) => part.type === "text" && Boolean(asString(part.text)?.trim()));
562
- const showActivity = isBusy && (!hasAnswer || Boolean(activeTool));
563
- const toolName = asString(activeTool?.toolName) ?? lastPartType.replace(/^tool-/, "");
564
- const toolState = asString(activeTool?.state);
565
- const approval = activeTool?.approval;
566
- const approved = isRecord(approval) && approval.approved === true;
567
- const currentActivityLabel = toolState === "approval-requested" ? "Waiting for approval…" : toolState === "approval-responded" && !approved ? "Processing approval response…" : activeTool ? (toolState && (toolState !== "approval-responded" || approved) ? toolActivityLabels?.[`${toolName}:${toolState}`] : void 0) ?? toolActivityLabels?.[toolName] ?? "Using a tool…" : activityLabel;
568
- const limit = messageLimit != null && Number.isFinite(messageLimit) ? Math.max(1, Math.floor(messageLimit)) : null;
569
- const historyFull = limit !== null && messages.filter((message) => message.role === "user").length >= limit;
570
- const MessageRenderer = components?.MessageRenderer ?? DefaultMessageRenderer;
571
- const ErrorRenderer = components?.ErrorRenderer ?? DefaultErrorRenderer;
572
- useEffect(() => {
573
- const viewport = viewportRef.current;
574
- if (viewport && pinnedToBottom.current) viewport.scrollTop = viewport.scrollHeight;
575
- });
576
- const handleKeyDown = (event) => {
577
- if (event.key === "Enter" && !event.shiftKey && !event.nativeEvent.isComposing) {
578
- event.preventDefault();
579
- if (!isBusy && !historyFull && !error && (draft.trim() || (attachments?.length ?? 0) > 0)) onSend?.();
580
- }
581
- };
582
- const handleFormSubmit = (event) => {
583
- event.preventDefault();
584
- if (!isBusy && !historyFull && !error && (draft.trim() || (attachments?.length ?? 0) > 0)) onSend?.();
585
- };
586
- return /* @__PURE__ */ jsxs("div", {
587
- className: [ai_chat_module_default.thread, className].filter(Boolean).join(" "),
588
- style,
589
- children: [
590
- header,
591
- (toolbarActions || showNewChatInToolbar && onNewChat && messages.length > 0) && /* @__PURE__ */ jsxs("div", {
592
- className: ai_chat_module_default.chatToolbar,
593
- role: "toolbar",
594
- "aria-label": "Conversation actions",
595
- children: [/* @__PURE__ */ jsx("div", {
596
- className: ai_chat_module_default.chatToolbarExtras,
597
- children: toolbarActions
598
- }), showNewChatInToolbar && onNewChat && messages.length > 0 && /* @__PURE__ */ jsx("button", {
599
- type: "button",
600
- className: ai_chat_module_default.newChatButton,
601
- onClick: onNewChat,
602
- "aria-label": "New chat",
603
- title: "New chat",
604
- children: /* @__PURE__ */ jsxs("svg", {
605
- "aria-hidden": "true",
606
- width: "18",
607
- height: "18",
608
- viewBox: "0 0 24 24",
609
- fill: "none",
610
- stroke: "currentColor",
611
- strokeWidth: "1.8",
612
- strokeLinecap: "round",
613
- strokeLinejoin: "round",
614
- children: [/* @__PURE__ */ jsx("path", { d: "M12 5H6a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h11a2 2 0 0 0 2-2v-6" }), /* @__PURE__ */ jsx("path", {
615
- d: "m15 5 4 4M13 11l7-7a2.12 2.12 0 0 1 3 3l-7 7-4 1 1-4Z",
616
- transform: "translate(-2 -2)"
617
- })]
618
- })
619
- })]
620
- }),
621
- /* @__PURE__ */ jsx("div", {
622
- ref: viewportRef,
623
- className: ai_chat_module_default.viewport,
624
- onScroll: (event) => {
625
- const viewport = event.currentTarget;
626
- pinnedToBottom.current = viewport.scrollHeight - viewport.scrollTop - viewport.clientHeight < 80;
627
- },
628
- children: /* @__PURE__ */ jsxs("div", {
629
- className: ai_chat_module_default.messageList,
630
- role: "log",
631
- "aria-label": "Chat history",
632
- "aria-live": "polite",
633
- children: [
634
- messages.length === 0 && /* @__PURE__ */ jsx("div", {
635
- className: ai_chat_module_default.emptyState,
636
- children: emptyState ?? /* @__PURE__ */ jsx("p", { children: "Start a conversation" })
637
- }),
638
- messages.map((message) => /* @__PURE__ */ jsx(MessageRenderer, {
639
- message,
640
- renderMessagePart: (part, index) => renderPart(part, index, components, onToolApproval ? respondToApproval : void 0, pendingApprovalId),
641
- onToolApproval: onToolApproval ? respondToApproval : void 0
642
- }, message.id)),
643
- showActivity && /* @__PURE__ */ jsxs("div", {
644
- className: ai_chat_module_default.activityBubble,
645
- role: "status",
646
- "aria-label": currentActivityLabel,
647
- children: [/* @__PURE__ */ jsxs("span", {
648
- className: ai_chat_module_default.activityDots,
649
- "aria-hidden": "true",
650
- children: [
651
- /* @__PURE__ */ jsx("i", {}),
652
- /* @__PURE__ */ jsx("i", {}),
653
- /* @__PURE__ */ jsx("i", {})
654
- ]
655
- }), /* @__PURE__ */ jsx("span", { children: currentActivityLabel })]
656
- }),
657
- error && (onRetry && onNewChat ? /* @__PURE__ */ jsx(ErrorRenderer, {
658
- error,
659
- onRetry,
660
- onClear: onNewChat
661
- }) : /* @__PURE__ */ jsxs("div", {
662
- className: ai_chat_module_default.error,
663
- role: "alert",
664
- children: [/* @__PURE__ */ jsx("p", { children: error.message }), (onRetry || onNewChat) && /* @__PURE__ */ jsxs("div", {
665
- className: ai_chat_module_default.errorActions,
666
- children: [onRetry && /* @__PURE__ */ jsx("button", {
667
- type: "button",
668
- onClick: onRetry,
669
- children: "Retry response"
670
- }), onNewChat && /* @__PURE__ */ jsx("button", {
671
- type: "button",
672
- onClick: onNewChat,
673
- children: "Start new chat"
674
- })]
675
- })]
676
- }))
677
- ]
678
- })
679
- }),
680
- /* @__PURE__ */ jsxs("div", {
681
- className: ai_chat_module_default.footer,
682
- children: [
683
- approvalError && /* @__PURE__ */ jsx("p", {
684
- role: "alert",
685
- className: ai_chat_module_default.attachmentError,
686
- children: approvalError
687
- }),
688
- attachmentError && /* @__PURE__ */ jsx("p", {
689
- role: "alert",
690
- className: ai_chat_module_default.attachmentError,
691
- children: attachmentError
692
- }),
693
- historyFull && !error && !isBusy && onNewChat && /* @__PURE__ */ jsxs("div", {
694
- className: ai_chat_module_default.historyLimit,
695
- children: [/* @__PURE__ */ jsxs("span", { children: [
696
- "This chat has reached its ",
697
- limit,
698
- "-question limit."
699
- ] }), /* @__PURE__ */ jsx("button", {
700
- type: "button",
701
- onClick: onNewChat,
702
- children: "Start new chat"
703
- })]
704
- }),
705
- (!historyFull || isBusy) && !error && (composer !== void 0 ? composer : /* @__PURE__ */ jsxs("form", {
706
- className: ai_chat_module_default.composerForm,
707
- onSubmit: handleFormSubmit,
708
- children: [
709
- composerLeading && /* @__PURE__ */ jsx("div", {
710
- className: ai_chat_module_default.composerExtras,
711
- children: composerLeading
712
- }),
713
- onSelectAttachments && /* @__PURE__ */ jsx("input", {
714
- ref: fileInputRef,
715
- className: ai_chat_module_default.visuallyHidden,
716
- type: "file",
717
- "aria-label": "Add attachments",
718
- accept: attachmentAccept,
719
- multiple: true,
720
- disabled: isBusy,
721
- onChange: (event) => {
722
- if (event.target.files) onSelectAttachments(event.target.files);
723
- event.target.value = "";
724
- }
725
- }),
726
- attachments && attachments.length > 0 && /* @__PURE__ */ jsx("div", {
727
- className: ai_chat_module_default.composerExtras,
728
- children: /* @__PURE__ */ jsx("ul", {
729
- className: ai_chat_module_default.attachmentList,
730
- "aria-label": "Attached files",
731
- children: attachments.map((attachment, index) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(AIChatAttachmentPreview, {
732
- name: attachment.name,
733
- size: attachment.size,
734
- staged: true,
735
- imageUrl: attachment.previewUrl,
736
- onRemove: onRemoveAttachment ? () => onRemoveAttachment(index) : void 0
737
- }) }, index))
738
- })
739
- }),
740
- /* @__PURE__ */ jsx("div", {
741
- className: ai_chat_module_default.composerSurface,
742
- children: /* @__PURE__ */ jsxs("div", {
743
- className: ai_chat_module_default.composerRow,
744
- children: [
745
- onSelectAttachments && /* @__PURE__ */ jsx("button", {
746
- type: "button",
747
- className: ai_chat_module_default.composerIconButton,
748
- "aria-label": "Attach file",
749
- title: "Attach file",
750
- disabled: isBusy,
751
- onClick: () => fileInputRef.current?.click(),
752
- children: /* @__PURE__ */ jsx("svg", {
753
- width: "20",
754
- height: "20",
755
- viewBox: "0 0 24 24",
756
- fill: "none",
757
- stroke: "currentColor",
758
- strokeWidth: "1.8",
759
- strokeLinecap: "round",
760
- strokeLinejoin: "round",
761
- "aria-hidden": "true",
762
- children: /* @__PURE__ */ jsx("path", { d: "m21 11-8.5 8.5a6 6 0 0 1-8.5-8.5l9-9a4 4 0 0 1 5.7 5.7l-9 9a2 2 0 0 1-2.8-2.8l8.5-8.5" })
763
- })
764
- }),
765
- /* @__PURE__ */ jsx("textarea", {
766
- className: ai_chat_module_default.input,
767
- "aria-label": inputAriaLabel,
768
- rows: 1,
769
- value: draft,
770
- onChange: (event) => onDraftChange?.(event.target.value),
771
- onKeyDown: handleKeyDown,
772
- placeholder: inputPlaceholder,
773
- maxLength: inputMaxLength,
774
- disabled: isBusy || !onSend || !onDraftChange,
775
- readOnly: !onDraftChange
776
- }),
777
- /* @__PURE__ */ jsxs("div", {
778
- className: ai_chat_module_default.composerActions,
779
- children: [composerTrailing, isBusy ? onStop && /* @__PURE__ */ jsx("button", {
780
- type: "button",
781
- className: ai_chat_module_default.composerIconButton,
782
- onClick: onStop,
783
- "aria-label": "Stop response",
784
- title: "Stop response",
785
- children: /* @__PURE__ */ jsx("svg", {
786
- width: "18",
787
- height: "18",
788
- viewBox: "0 0 24 24",
789
- fill: "currentColor",
790
- "aria-hidden": "true",
791
- children: /* @__PURE__ */ jsx("rect", {
792
- x: "5",
793
- y: "5",
794
- width: "14",
795
- height: "14",
796
- rx: "2"
797
- })
798
- })
799
- }) : /* @__PURE__ */ jsx("button", {
800
- type: "submit",
801
- className: ai_chat_module_default.sendButton,
802
- "aria-label": "Send message",
803
- title: "Send message",
804
- disabled: !onSend || !draft.trim() && !attachments?.length,
805
- children: /* @__PURE__ */ jsx("svg", {
806
- width: "20",
807
- height: "20",
808
- viewBox: "0 0 24 24",
809
- fill: "none",
810
- stroke: "currentColor",
811
- strokeWidth: "2",
812
- strokeLinecap: "round",
813
- strokeLinejoin: "round",
814
- "aria-hidden": "true",
815
- children: /* @__PURE__ */ jsx("path", { d: "M12 19V5m-7 7 7-7 7 7" })
816
- })
817
- })]
818
- })
819
- ]
820
- })
821
- })
822
- ]
823
- }))
824
- ]
825
- })
826
- ]
827
- });
828
- }
829
276
  //#endregion
830
- export { AIChat, AIChatAttachmentPreview, AIChatMessageBubble, AIChatView };
277
+ export { AIChatAttachmentPreview, AIChatMessageBubble, DefaultErrorRenderer, DefaultMessageRenderer, asString, isRecord, renderPart };
831
278
 
832
279
  //# sourceMappingURL=index84.js.map