@tomny-dev/uzi 0.19.0 → 0.20.0-pr.133.460.1.b643269

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