@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/index85.cjs CHANGED
@@ -2,9 +2,7 @@
2
2
  const require_ai_chat_module = require("./index84.cjs");
3
3
  let react = require("react");
4
4
  let react_jsx_runtime = require("react/jsx-runtime");
5
- let _assistant_ui_react = require("@assistant-ui/react");
6
- let _assistant_ui_ai_sdk = require("@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,561 +273,13 @@ 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] = (0, react.useState)(0);
281
- const transport = (0, react.useMemo)(() => new _assistant_ui_ai_sdk.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 = (0, react.useMemo)(() => (0, _assistant_ui_react.AuiConfig)({ threads: (0, _assistant_ui_ai_sdk.AISDKChat)({
297
- transport,
298
- ...sendAutomaticallyWhen ? { sendAutomaticallyWhen } : {}
299
- }) }), [
300
- transport,
301
- session,
302
- sendAutomaticallyWhen
303
- ]);
304
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
305
- className: [require_ai_chat_module.default.container, className].filter(Boolean).join(" "),
306
- style,
307
- children: [
308
- scopeLabel && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
309
- className: require_ai_chat_module.default.scope,
310
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
311
- className: require_ai_chat_module.default.scopeLabel,
312
- children: "Current scope"
313
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: scopeLabel })]
314
- }),
315
- onClose && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
316
- className: require_ai_chat_module.default.closeBtn,
317
- type: "button",
318
- onClick: onClose,
319
- "aria-label": "Close chat",
320
- children: "✕"
321
- }),
322
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_assistant_ui_react.AuiProvider, {
323
- config,
324
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_assistant_ui_react.ThreadPrimitive.Root, {
325
- className: require_ai_chat_module.default.thread,
326
- children: /* @__PURE__ */ (0, react_jsx_runtime.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 = (0, _assistant_ui_ai_sdk.useAISDKChat)();
353
- const [draft, setDraft] = (0, react.useState)("");
354
- const [selectedFiles, setSelectedFiles] = (0, react.useState)([]);
355
- const [attachmentError, setAttachmentError] = (0, react.useState)(null);
356
- const [attachmentPreviews, setAttachmentPreviews] = (0, react.useState)([]);
357
- const [hydrated, setHydrated] = (0, react.useState)(!history);
358
- const expectedRestoredId = (0, react.useRef)(null);
359
- const saveQueue = (0, react.useRef)(Promise.resolve());
360
- const [approvalBusy, setApprovalBusy] = (0, react.useState)(false);
361
- (0, react.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
- (0, react.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
- (0, react.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 = (0, react.useRef)(newChatRequestKey);
469
- (0, react.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__ */ (0, react_jsx_runtime.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 = (0, react.useRef)(null);
536
- const pinnedToBottom = (0, react.useRef)(true);
537
- const fileInputRef = (0, react.useRef)(null);
538
- const approvalRef = (0, react.useRef)(null);
539
- const [pendingApprovalId, setPendingApprovalId] = (0, react.useState)(null);
540
- const [approvalError, setApprovalError] = (0, react.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
- (0, react.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__ */ (0, react_jsx_runtime.jsxs)("div", {
587
- className: [require_ai_chat_module.default.thread, className].filter(Boolean).join(" "),
588
- style,
589
- children: [
590
- header,
591
- (toolbarActions || showNewChatInToolbar && onNewChat && messages.length > 0) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
592
- className: require_ai_chat_module.default.chatToolbar,
593
- role: "toolbar",
594
- "aria-label": "Conversation actions",
595
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
596
- className: require_ai_chat_module.default.chatToolbarExtras,
597
- children: toolbarActions
598
- }), showNewChatInToolbar && onNewChat && messages.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
599
- type: "button",
600
- className: require_ai_chat_module.default.newChatButton,
601
- onClick: onNewChat,
602
- "aria-label": "New chat",
603
- title: "New chat",
604
- children: /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsx)("div", {
622
- ref: viewportRef,
623
- className: require_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__ */ (0, react_jsx_runtime.jsxs)("div", {
629
- className: require_ai_chat_module.default.messageList,
630
- role: "log",
631
- "aria-label": "Chat history",
632
- "aria-live": "polite",
633
- children: [
634
- messages.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
635
- className: require_ai_chat_module.default.emptyState,
636
- children: emptyState ?? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: "Start a conversation" })
637
- }),
638
- messages.map((message) => /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsxs)("div", {
644
- className: require_ai_chat_module.default.activityBubble,
645
- role: "status",
646
- "aria-label": currentActivityLabel,
647
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
648
- className: require_ai_chat_module.default.activityDots,
649
- "aria-hidden": "true",
650
- children: [
651
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {}),
652
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {}),
653
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {})
654
- ]
655
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: currentActivityLabel })]
656
- }),
657
- error && (onRetry && onNewChat ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorRenderer, {
658
- error,
659
- onRetry,
660
- onClear: onNewChat
661
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
662
- className: require_ai_chat_module.default.error,
663
- role: "alert",
664
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: error.message }), (onRetry || onNewChat) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
665
- className: require_ai_chat_module.default.errorActions,
666
- children: [onRetry && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
667
- type: "button",
668
- onClick: onRetry,
669
- children: "Retry response"
670
- }), onNewChat && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
671
- type: "button",
672
- onClick: onNewChat,
673
- children: "Start new chat"
674
- })]
675
- })]
676
- }))
677
- ]
678
- })
679
- }),
680
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
681
- className: require_ai_chat_module.default.footer,
682
- children: [
683
- approvalError && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
684
- role: "alert",
685
- className: require_ai_chat_module.default.attachmentError,
686
- children: approvalError
687
- }),
688
- attachmentError && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
689
- role: "alert",
690
- className: require_ai_chat_module.default.attachmentError,
691
- children: attachmentError
692
- }),
693
- historyFull && !error && !isBusy && onNewChat && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
694
- className: require_ai_chat_module.default.historyLimit,
695
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
696
- "This chat has reached its ",
697
- limit,
698
- "-question limit."
699
- ] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
700
- type: "button",
701
- onClick: onNewChat,
702
- children: "Start new chat"
703
- })]
704
- }),
705
- (!historyFull || isBusy) && !error && (composer !== void 0 ? composer : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
706
- className: require_ai_chat_module.default.composerForm,
707
- onSubmit: handleFormSubmit,
708
- children: [
709
- composerLeading && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
710
- className: require_ai_chat_module.default.composerExtras,
711
- children: composerLeading
712
- }),
713
- onSelectAttachments && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
714
- ref: fileInputRef,
715
- className: require_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__ */ (0, react_jsx_runtime.jsx)("div", {
727
- className: require_ai_chat_module.default.composerExtras,
728
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
729
- className: require_ai_chat_module.default.attachmentList,
730
- "aria-label": "Attached files",
731
- children: attachments.map((attachment, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsx)("div", {
741
- className: require_ai_chat_module.default.composerSurface,
742
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
743
- className: require_ai_chat_module.default.composerRow,
744
- children: [
745
- onSelectAttachments && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
746
- type: "button",
747
- className: require_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__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.jsx)("textarea", {
766
- className: require_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__ */ (0, react_jsx_runtime.jsxs)("div", {
778
- className: require_ai_chat_module.default.composerActions,
779
- children: [composerTrailing, isBusy ? onStop && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
780
- type: "button",
781
- className: require_ai_chat_module.default.composerIconButton,
782
- onClick: onStop,
783
- "aria-label": "Stop response",
784
- title: "Stop response",
785
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
786
- width: "18",
787
- height: "18",
788
- viewBox: "0 0 24 24",
789
- fill: "currentColor",
790
- "aria-hidden": "true",
791
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
792
- x: "5",
793
- y: "5",
794
- width: "14",
795
- height: "14",
796
- rx: "2"
797
- })
798
- })
799
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
800
- type: "submit",
801
- className: require_ai_chat_module.default.sendButton,
802
- "aria-label": "Send message",
803
- title: "Send message",
804
- disabled: !onSend || !draft.trim() && !attachments?.length,
805
- children: /* @__PURE__ */ (0, react_jsx_runtime.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__ */ (0, react_jsx_runtime.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
- exports.AIChat = AIChat;
831
277
  exports.AIChatAttachmentPreview = AIChatAttachmentPreview;
832
278
  exports.AIChatMessageBubble = AIChatMessageBubble;
833
- exports.AIChatView = AIChatView;
279
+ exports.DefaultErrorRenderer = DefaultErrorRenderer;
280
+ exports.DefaultMessageRenderer = DefaultMessageRenderer;
281
+ exports.asString = asString;
282
+ exports.isRecord = isRecord;
283
+ exports.renderPart = renderPart;
834
284
 
835
285
  //# sourceMappingURL=index85.cjs.map