@liveblocks/react-ui 3.15.0-feeds1 → 3.15.0-rc1

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 (148) hide show
  1. package/dist/_private/index.cjs +3 -5
  2. package/dist/_private/index.cjs.map +1 -1
  3. package/dist/_private/index.d.cts +10 -4
  4. package/dist/_private/index.d.ts +10 -4
  5. package/dist/_private/index.js +2 -2
  6. package/dist/components/AiChat.cjs +10 -2
  7. package/dist/components/AiChat.cjs.map +1 -1
  8. package/dist/components/AiChat.js +10 -2
  9. package/dist/components/AiChat.js.map +1 -1
  10. package/dist/components/AvatarStack.cjs +117 -0
  11. package/dist/components/AvatarStack.cjs.map +1 -0
  12. package/dist/components/AvatarStack.js +115 -0
  13. package/dist/components/AvatarStack.js.map +1 -0
  14. package/dist/components/Comment.cjs +259 -250
  15. package/dist/components/Comment.cjs.map +1 -1
  16. package/dist/components/Comment.js +264 -236
  17. package/dist/components/Comment.js.map +1 -1
  18. package/dist/components/CommentPin.cjs +36 -0
  19. package/dist/components/CommentPin.cjs.map +1 -0
  20. package/dist/components/CommentPin.js +34 -0
  21. package/dist/components/CommentPin.js.map +1 -0
  22. package/dist/components/Composer.cjs +2 -4
  23. package/dist/components/Composer.cjs.map +1 -1
  24. package/dist/components/Composer.js +3 -5
  25. package/dist/components/Composer.js.map +1 -1
  26. package/dist/components/Cursor.cjs +40 -0
  27. package/dist/components/Cursor.cjs.map +1 -0
  28. package/dist/components/Cursor.js +38 -0
  29. package/dist/components/Cursor.js.map +1 -0
  30. package/dist/components/Cursors.cjs +256 -0
  31. package/dist/components/Cursors.cjs.map +1 -0
  32. package/dist/components/Cursors.js +254 -0
  33. package/dist/components/Cursors.js.map +1 -0
  34. package/dist/components/FloatingComposer.cjs +82 -0
  35. package/dist/components/FloatingComposer.cjs.map +1 -0
  36. package/dist/components/FloatingComposer.js +80 -0
  37. package/dist/components/FloatingComposer.js.map +1 -0
  38. package/dist/components/FloatingThread.cjs +82 -0
  39. package/dist/components/FloatingThread.cjs.map +1 -0
  40. package/dist/components/FloatingThread.js +80 -0
  41. package/dist/components/FloatingThread.js.map +1 -0
  42. package/dist/components/InboxNotification.cjs +4 -6
  43. package/dist/components/InboxNotification.cjs.map +1 -1
  44. package/dist/components/InboxNotification.js +5 -7
  45. package/dist/components/InboxNotification.js.map +1 -1
  46. package/dist/components/Thread.cjs +61 -51
  47. package/dist/components/Thread.cjs.map +1 -1
  48. package/dist/components/Thread.js +66 -37
  49. package/dist/components/Thread.js.map +1 -1
  50. package/dist/components/internal/AiComposer.cjs +1 -2
  51. package/dist/components/internal/AiComposer.cjs.map +1 -1
  52. package/dist/components/internal/AiComposer.js +1 -2
  53. package/dist/components/internal/AiComposer.js.map +1 -1
  54. package/dist/components/internal/Avatar.cjs +10 -13
  55. package/dist/components/internal/Avatar.cjs.map +1 -1
  56. package/dist/components/internal/Avatar.js +11 -14
  57. package/dist/components/internal/Avatar.js.map +1 -1
  58. package/dist/components/internal/CodeBlock.cjs +1 -2
  59. package/dist/components/internal/CodeBlock.cjs.map +1 -1
  60. package/dist/components/internal/CodeBlock.js +1 -2
  61. package/dist/components/internal/CodeBlock.js.map +1 -1
  62. package/dist/components/internal/Dropdown.cjs +7 -28
  63. package/dist/components/internal/Dropdown.cjs.map +1 -1
  64. package/dist/components/internal/Dropdown.js +7 -7
  65. package/dist/components/internal/Dropdown.js.map +1 -1
  66. package/dist/components/internal/EmojiPicker.cjs +6 -27
  67. package/dist/components/internal/EmojiPicker.cjs.map +1 -1
  68. package/dist/components/internal/EmojiPicker.js +6 -6
  69. package/dist/components/internal/EmojiPicker.js.map +1 -1
  70. package/dist/components/internal/List.cjs +2 -2
  71. package/dist/components/internal/List.cjs.map +1 -1
  72. package/dist/components/internal/List.js +2 -2
  73. package/dist/components/internal/List.js.map +1 -1
  74. package/dist/components/internal/Tooltip.cjs +7 -28
  75. package/dist/components/internal/Tooltip.cjs.map +1 -1
  76. package/dist/components/internal/Tooltip.js +7 -7
  77. package/dist/components/internal/Tooltip.js.map +1 -1
  78. package/dist/index.cjs +12 -0
  79. package/dist/index.cjs.map +1 -1
  80. package/dist/index.d.cts +298 -130
  81. package/dist/index.d.ts +298 -130
  82. package/dist/index.js +6 -0
  83. package/dist/index.js.map +1 -1
  84. package/dist/primitives/AiComposer/index.cjs +5 -4
  85. package/dist/primitives/AiComposer/index.cjs.map +1 -1
  86. package/dist/primitives/AiComposer/index.js +5 -4
  87. package/dist/primitives/AiComposer/index.js.map +1 -1
  88. package/dist/primitives/AiMessage/index.cjs +2 -2
  89. package/dist/primitives/AiMessage/index.cjs.map +1 -1
  90. package/dist/primitives/AiMessage/index.js +2 -2
  91. package/dist/primitives/AiMessage/index.js.map +1 -1
  92. package/dist/primitives/Collapsible/index.cjs +4 -4
  93. package/dist/primitives/Collapsible/index.cjs.map +1 -1
  94. package/dist/primitives/Collapsible/index.js +4 -4
  95. package/dist/primitives/Collapsible/index.js.map +1 -1
  96. package/dist/primitives/Comment/index.cjs +4 -4
  97. package/dist/primitives/Comment/index.cjs.map +1 -1
  98. package/dist/primitives/Comment/index.js +4 -4
  99. package/dist/primitives/Comment/index.js.map +1 -1
  100. package/dist/primitives/Composer/index.cjs +23 -35
  101. package/dist/primitives/Composer/index.cjs.map +1 -1
  102. package/dist/primitives/Composer/index.js +23 -16
  103. package/dist/primitives/Composer/index.js.map +1 -1
  104. package/dist/primitives/Duration.cjs +2 -2
  105. package/dist/primitives/Duration.cjs.map +1 -1
  106. package/dist/primitives/Duration.js +2 -2
  107. package/dist/primitives/Duration.js.map +1 -1
  108. package/dist/primitives/FileSize.cjs +2 -2
  109. package/dist/primitives/FileSize.cjs.map +1 -1
  110. package/dist/primitives/FileSize.js +2 -2
  111. package/dist/primitives/FileSize.js.map +1 -1
  112. package/dist/primitives/Markdown.cjs +2 -2
  113. package/dist/primitives/Markdown.cjs.map +1 -1
  114. package/dist/primitives/Markdown.js +2 -2
  115. package/dist/primitives/Markdown.js.map +1 -1
  116. package/dist/primitives/Timestamp.cjs +2 -2
  117. package/dist/primitives/Timestamp.cjs.map +1 -1
  118. package/dist/primitives/Timestamp.js +2 -2
  119. package/dist/primitives/Timestamp.js.map +1 -1
  120. package/dist/utils/Portal.cjs +2 -2
  121. package/dist/utils/Portal.cjs.map +1 -1
  122. package/dist/utils/Portal.js +2 -2
  123. package/dist/utils/Portal.js.map +1 -1
  124. package/dist/utils/animation-loop.cjs +44 -0
  125. package/dist/utils/animation-loop.cjs.map +1 -0
  126. package/dist/utils/animation-loop.js +42 -0
  127. package/dist/utils/animation-loop.js.map +1 -0
  128. package/dist/utils/use-pre-resolve-user.cjs +18 -0
  129. package/dist/utils/use-pre-resolve-user.cjs.map +1 -0
  130. package/dist/utils/use-pre-resolve-user.js +16 -0
  131. package/dist/utils/use-pre-resolve-user.js.map +1 -0
  132. package/dist/utils/use-stable-component.cjs +32 -0
  133. package/dist/utils/use-stable-component.cjs.map +1 -0
  134. package/dist/utils/use-stable-component.js +30 -0
  135. package/dist/utils/use-stable-component.js.map +1 -0
  136. package/dist/version.cjs +1 -1
  137. package/dist/version.cjs.map +1 -1
  138. package/dist/version.js +1 -1
  139. package/dist/version.js.map +1 -1
  140. package/package.json +6 -10
  141. package/src/styles/dark/index.css +1 -1
  142. package/src/styles/index.css +252 -4
  143. package/styles/dark/attributes.css +1 -1
  144. package/styles/dark/attributes.css.map +1 -1
  145. package/styles/dark/media-query.css +1 -1
  146. package/styles/dark/media-query.css.map +1 -1
  147. package/styles.css +1 -1
  148. package/styles.css.map +1 -1
@@ -15,12 +15,12 @@ var cn = require('../utils/cn.cjs');
15
15
  var Portal = require('../utils/Portal.cjs');
16
16
  var useInitial = require('../utils/use-initial.cjs');
17
17
  var useRefs = require('../utils/use-refs.cjs');
18
+ var useStableComponent = require('../utils/use-stable-component.cjs');
18
19
  var index = require('../primitives/AiComposer/index.cjs');
19
20
  var contexts = require('../primitives/AiComposer/contexts.cjs');
20
21
  var index$1 = require('../primitives/AiMessage/index.cjs');
21
22
  var index$2 = require('../primitives/Collapsible/index.cjs');
22
23
  var Markdown = require('../primitives/Markdown.cjs');
23
- var TooltipPrimitive = require('@radix-ui/react-tooltip');
24
24
  var ArrowCornerDownRight = require('../icons/ArrowCornerDownRight.cjs');
25
25
  var ArrowCornerUpRight = require('../icons/ArrowCornerUpRight.cjs');
26
26
  var ArrowDown = require('../icons/ArrowDown.cjs');
@@ -88,6 +88,7 @@ exports.List = List.List;
88
88
  exports.Prose = Prose.Prose;
89
89
  exports.ShortcutTooltip = Tooltip.ShortcutTooltip;
90
90
  exports.Tooltip = Tooltip.Tooltip;
91
+ exports.TooltipProvider = Tooltip.TooltipProvider;
91
92
  exports.User = User.User;
92
93
  exports.useLiveblocksUiConfig = config.useLiveblocksUiConfig;
93
94
  exports.capitalize = capitalize.capitalize;
@@ -95,15 +96,12 @@ exports.cn = cn.cn;
95
96
  exports.Portal = Portal.Portal;
96
97
  exports.useInitial = useInitial.useInitial;
97
98
  exports.useRefs = useRefs.useRefs;
99
+ exports.useStableComponent = useStableComponent.useStableComponent;
98
100
  exports.AiComposer = index;
99
101
  exports.useAiComposer = contexts.useAiComposer;
100
102
  exports.AiMessage = index$1;
101
103
  exports.Collapsible = index$2;
102
104
  exports.Markdown = Markdown.Markdown;
103
- Object.defineProperty(exports, 'TooltipProvider', {
104
- enumerable: true,
105
- get: function () { return TooltipPrimitive.TooltipProvider; }
106
- });
107
105
  exports.ArrowCornerDownRightIcon = ArrowCornerDownRight.ArrowCornerDownRightIcon;
108
106
  exports.ArrowCornerUpRightIcon = ArrowCornerUpRight.ArrowCornerUpRightIcon;
109
107
  exports.ArrowDownIcon = ArrowDown.ArrowDownIcon;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -2,8 +2,7 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { Relax, AiTextPart, AiReasoningPart, AiChatMessage } from '@liveblocks/core';
3
3
  import * as react from 'react';
4
4
  import { ComponentProps, ReactNode, ComponentPropsWithoutRef, ElementType, ComponentType, Ref, RefCallback, FormEvent } from 'react';
5
- import * as TooltipPrimitive from '@radix-ui/react-tooltip';
6
- export { TooltipProvider } from '@radix-ui/react-tooltip';
5
+ import { Tooltip as Tooltip$1 } from 'radix-ui';
7
6
 
8
7
  type AvatarProps = ComponentProps<"div"> & {
9
8
  icon?: ReactNode;
@@ -345,7 +344,7 @@ interface ProseProps extends ComponentProps<"div"> {
345
344
  */
346
345
  declare function Prose({ content, partial, components, className, ...props }: ProseProps): react_jsx_runtime.JSX.Element;
347
346
 
348
- interface TooltipProps extends Pick<TooltipPrimitive.TooltipTriggerProps, "children">, Omit<TooltipPrimitive.TooltipContentProps, "content"> {
347
+ interface TooltipProps extends Pick<Tooltip$1.TooltipTriggerProps, "children">, Omit<Tooltip$1.TooltipContentProps, "content"> {
349
348
  content: ReactNode;
350
349
  multiline?: boolean;
351
350
  }
@@ -354,6 +353,7 @@ interface ShortcutTooltipProps extends TooltipProps {
354
353
  }
355
354
  declare const Tooltip: react.ForwardRefExoticComponent<TooltipProps & react.RefAttributes<HTMLButtonElement>>;
356
355
  declare const ShortcutTooltip: react.ForwardRefExoticComponent<ShortcutTooltipProps & react.RefAttributes<HTMLButtonElement>>;
356
+ declare const TooltipProvider: react.FC<Tooltip$1.TooltipProviderProps>;
357
357
 
358
358
  interface UserProps extends ComponentProps<"span"> {
359
359
  /**
@@ -504,6 +504,12 @@ declare function useInitial<T>(value: T | (() => T)): T;
504
504
 
505
505
  declare function useRefs<T>(...refs: Ref<T>[]): RefCallback<T>;
506
506
 
507
+ /**
508
+ * Stabilizes a component by creating a stable wrapper that will not be remounted
509
+ * when the component changes.
510
+ */
511
+ declare function useStableComponent<P extends object, D extends ComponentType<P>>(Component: ComponentType<P> | undefined, DefaultComponent: D): D;
512
+
507
513
  interface AiComposerSubmitMessage {
508
514
  /**
509
515
  * The submitted message text.
@@ -718,4 +724,4 @@ declare namespace index {
718
724
  };
719
725
  }
720
726
 
721
- export { index$2 as AiComposer, AiComposerEditorProps, AiComposerFormProps, AiComposerSubmitProps, index$1 as AiMessage, AiMessageContentComponents, AiMessageContentProps, AiMessageContentReasoningPartProps, AiMessageContentTextPartProps, ArrowCornerDownRightIcon, ArrowCornerUpRightIcon, ArrowDownIcon, ArrowUpIcon, AttachmentIcon, Avatar, BellCrossedIcon, BellIcon, BlockquoteIcon, BoldIcon, Button, CheckCircleFillIcon, CheckCircleIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, CodeIcon, index as Collapsible, CommentIcon, CopyIcon, CrossCircleFillIcon, CrossIcon, DeleteIcon, EditIcon, EllipsisIcon, EmojiIcon, EmojiPlusIcon, GlobeIcon, Group, GroupDescription, H1Icon, H2Icon, H3Icon, ItalicIcon, LengthenIcon, List, ListOrderedIcon, ListUnorderedIcon, Markdown, MarkdownComponents, MarkdownComponentsBlockquoteProps, MarkdownComponentsCodeBlockProps, MarkdownComponentsHeadingProps, MarkdownComponentsImageProps, MarkdownComponentsInlineProps, MarkdownComponentsLinkProps, MarkdownComponentsListProps, MarkdownComponentsParagraphProps, MarkdownComponentsTableProps, MarkdownProps, MentionIcon, MinusCircleIcon, Portal, Prose, QuestionMarkIcon, RedoIcon, RestoreIcon, RetryIcon, SearchIcon, SelectButton, SendIcon, ShortcutTooltip, ShortenIcon, SparklesIcon, SparklesTextIcon, SpinnerIcon, StopIcon, StrikethroughIcon, TextIcon, Tooltip, TranslateIcon, UnderlineIcon, UndoIcon, User, UserIcon, UsersIcon, WarningIcon, capitalize, cn, useAiComposer, useInitial, useLiveblocksUiConfig, useRefs };
727
+ export { index$2 as AiComposer, AiComposerEditorProps, AiComposerFormProps, AiComposerSubmitProps, index$1 as AiMessage, AiMessageContentComponents, AiMessageContentProps, AiMessageContentReasoningPartProps, AiMessageContentTextPartProps, ArrowCornerDownRightIcon, ArrowCornerUpRightIcon, ArrowDownIcon, ArrowUpIcon, AttachmentIcon, Avatar, BellCrossedIcon, BellIcon, BlockquoteIcon, BoldIcon, Button, CheckCircleFillIcon, CheckCircleIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, CodeIcon, index as Collapsible, CommentIcon, CopyIcon, CrossCircleFillIcon, CrossIcon, DeleteIcon, EditIcon, EllipsisIcon, EmojiIcon, EmojiPlusIcon, GlobeIcon, Group, GroupDescription, H1Icon, H2Icon, H3Icon, ItalicIcon, LengthenIcon, List, ListOrderedIcon, ListUnorderedIcon, Markdown, MarkdownComponents, MarkdownComponentsBlockquoteProps, MarkdownComponentsCodeBlockProps, MarkdownComponentsHeadingProps, MarkdownComponentsImageProps, MarkdownComponentsInlineProps, MarkdownComponentsLinkProps, MarkdownComponentsListProps, MarkdownComponentsParagraphProps, MarkdownComponentsTableProps, MarkdownProps, MentionIcon, MinusCircleIcon, Portal, Prose, QuestionMarkIcon, RedoIcon, RestoreIcon, RetryIcon, SearchIcon, SelectButton, SendIcon, ShortcutTooltip, ShortenIcon, SparklesIcon, SparklesTextIcon, SpinnerIcon, StopIcon, StrikethroughIcon, TextIcon, Tooltip, TooltipProvider, TranslateIcon, UnderlineIcon, UndoIcon, User, UserIcon, UsersIcon, WarningIcon, capitalize, cn, useAiComposer, useInitial, useLiveblocksUiConfig, useRefs, useStableComponent };
@@ -2,8 +2,7 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { Relax, AiTextPart, AiReasoningPart, AiChatMessage } from '@liveblocks/core';
3
3
  import * as react from 'react';
4
4
  import { ComponentProps, ReactNode, ComponentPropsWithoutRef, ElementType, ComponentType, Ref, RefCallback, FormEvent } from 'react';
5
- import * as TooltipPrimitive from '@radix-ui/react-tooltip';
6
- export { TooltipProvider } from '@radix-ui/react-tooltip';
5
+ import { Tooltip as Tooltip$1 } from 'radix-ui';
7
6
 
8
7
  type AvatarProps = ComponentProps<"div"> & {
9
8
  icon?: ReactNode;
@@ -345,7 +344,7 @@ interface ProseProps extends ComponentProps<"div"> {
345
344
  */
346
345
  declare function Prose({ content, partial, components, className, ...props }: ProseProps): react_jsx_runtime.JSX.Element;
347
346
 
348
- interface TooltipProps extends Pick<TooltipPrimitive.TooltipTriggerProps, "children">, Omit<TooltipPrimitive.TooltipContentProps, "content"> {
347
+ interface TooltipProps extends Pick<Tooltip$1.TooltipTriggerProps, "children">, Omit<Tooltip$1.TooltipContentProps, "content"> {
349
348
  content: ReactNode;
350
349
  multiline?: boolean;
351
350
  }
@@ -354,6 +353,7 @@ interface ShortcutTooltipProps extends TooltipProps {
354
353
  }
355
354
  declare const Tooltip: react.ForwardRefExoticComponent<TooltipProps & react.RefAttributes<HTMLButtonElement>>;
356
355
  declare const ShortcutTooltip: react.ForwardRefExoticComponent<ShortcutTooltipProps & react.RefAttributes<HTMLButtonElement>>;
356
+ declare const TooltipProvider: react.FC<Tooltip$1.TooltipProviderProps>;
357
357
 
358
358
  interface UserProps extends ComponentProps<"span"> {
359
359
  /**
@@ -504,6 +504,12 @@ declare function useInitial<T>(value: T | (() => T)): T;
504
504
 
505
505
  declare function useRefs<T>(...refs: Ref<T>[]): RefCallback<T>;
506
506
 
507
+ /**
508
+ * Stabilizes a component by creating a stable wrapper that will not be remounted
509
+ * when the component changes.
510
+ */
511
+ declare function useStableComponent<P extends object, D extends ComponentType<P>>(Component: ComponentType<P> | undefined, DefaultComponent: D): D;
512
+
507
513
  interface AiComposerSubmitMessage {
508
514
  /**
509
515
  * The submitted message text.
@@ -718,4 +724,4 @@ declare namespace index {
718
724
  };
719
725
  }
720
726
 
721
- export { index$2 as AiComposer, AiComposerEditorProps, AiComposerFormProps, AiComposerSubmitProps, index$1 as AiMessage, AiMessageContentComponents, AiMessageContentProps, AiMessageContentReasoningPartProps, AiMessageContentTextPartProps, ArrowCornerDownRightIcon, ArrowCornerUpRightIcon, ArrowDownIcon, ArrowUpIcon, AttachmentIcon, Avatar, BellCrossedIcon, BellIcon, BlockquoteIcon, BoldIcon, Button, CheckCircleFillIcon, CheckCircleIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, CodeIcon, index as Collapsible, CommentIcon, CopyIcon, CrossCircleFillIcon, CrossIcon, DeleteIcon, EditIcon, EllipsisIcon, EmojiIcon, EmojiPlusIcon, GlobeIcon, Group, GroupDescription, H1Icon, H2Icon, H3Icon, ItalicIcon, LengthenIcon, List, ListOrderedIcon, ListUnorderedIcon, Markdown, MarkdownComponents, MarkdownComponentsBlockquoteProps, MarkdownComponentsCodeBlockProps, MarkdownComponentsHeadingProps, MarkdownComponentsImageProps, MarkdownComponentsInlineProps, MarkdownComponentsLinkProps, MarkdownComponentsListProps, MarkdownComponentsParagraphProps, MarkdownComponentsTableProps, MarkdownProps, MentionIcon, MinusCircleIcon, Portal, Prose, QuestionMarkIcon, RedoIcon, RestoreIcon, RetryIcon, SearchIcon, SelectButton, SendIcon, ShortcutTooltip, ShortenIcon, SparklesIcon, SparklesTextIcon, SpinnerIcon, StopIcon, StrikethroughIcon, TextIcon, Tooltip, TranslateIcon, UnderlineIcon, UndoIcon, User, UserIcon, UsersIcon, WarningIcon, capitalize, cn, useAiComposer, useInitial, useLiveblocksUiConfig, useRefs };
727
+ export { index$2 as AiComposer, AiComposerEditorProps, AiComposerFormProps, AiComposerSubmitProps, index$1 as AiMessage, AiMessageContentComponents, AiMessageContentProps, AiMessageContentReasoningPartProps, AiMessageContentTextPartProps, ArrowCornerDownRightIcon, ArrowCornerUpRightIcon, ArrowDownIcon, ArrowUpIcon, AttachmentIcon, Avatar, BellCrossedIcon, BellIcon, BlockquoteIcon, BoldIcon, Button, CheckCircleFillIcon, CheckCircleIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, CodeIcon, index as Collapsible, CommentIcon, CopyIcon, CrossCircleFillIcon, CrossIcon, DeleteIcon, EditIcon, EllipsisIcon, EmojiIcon, EmojiPlusIcon, GlobeIcon, Group, GroupDescription, H1Icon, H2Icon, H3Icon, ItalicIcon, LengthenIcon, List, ListOrderedIcon, ListUnorderedIcon, Markdown, MarkdownComponents, MarkdownComponentsBlockquoteProps, MarkdownComponentsCodeBlockProps, MarkdownComponentsHeadingProps, MarkdownComponentsImageProps, MarkdownComponentsInlineProps, MarkdownComponentsLinkProps, MarkdownComponentsListProps, MarkdownComponentsParagraphProps, MarkdownComponentsTableProps, MarkdownProps, MentionIcon, MinusCircleIcon, Portal, Prose, QuestionMarkIcon, RedoIcon, RestoreIcon, RetryIcon, SearchIcon, SelectButton, SendIcon, ShortcutTooltip, ShortenIcon, SparklesIcon, SparklesTextIcon, SpinnerIcon, StopIcon, StrikethroughIcon, TextIcon, Tooltip, TooltipProvider, TranslateIcon, UnderlineIcon, UndoIcon, User, UserIcon, UsersIcon, WarningIcon, capitalize, cn, useAiComposer, useInitial, useLiveblocksUiConfig, useRefs, useStableComponent };
@@ -4,7 +4,7 @@ export { Group } from '../components/internal/Group.js';
4
4
  export { GroupDescription } from '../components/internal/GroupDescription.js';
5
5
  export { List } from '../components/internal/List.js';
6
6
  export { Prose } from '../components/internal/Prose.js';
7
- export { ShortcutTooltip, Tooltip } from '../components/internal/Tooltip.js';
7
+ export { ShortcutTooltip, Tooltip, TooltipProvider } from '../components/internal/Tooltip.js';
8
8
  export { User } from '../components/internal/User.js';
9
9
  export { useLiveblocksUiConfig } from '../config.js';
10
10
  import '../icons/index.js';
@@ -13,6 +13,7 @@ export { cn } from '../utils/cn.js';
13
13
  export { Portal } from '../utils/Portal.js';
14
14
  export { useInitial } from '../utils/use-initial.js';
15
15
  export { useRefs } from '../utils/use-refs.js';
16
+ export { useStableComponent } from '../utils/use-stable-component.js';
16
17
  import * as index from '../primitives/AiComposer/index.js';
17
18
  export { index as AiComposer };
18
19
  export { useAiComposer } from '../primitives/AiComposer/contexts.js';
@@ -21,7 +22,6 @@ export { index$1 as AiMessage };
21
22
  import * as index$2 from '../primitives/Collapsible/index.js';
22
23
  export { index$2 as Collapsible };
23
24
  export { Markdown } from '../primitives/Markdown.js';
24
- export { TooltipProvider } from '@radix-ui/react-tooltip';
25
25
  export { ArrowCornerDownRightIcon } from '../icons/ArrowCornerDownRight.js';
26
26
  export { ArrowCornerUpRightIcon } from '../icons/ArrowCornerUpRight.js';
27
27
  export { ArrowDownIcon } from '../icons/ArrowDown.js';
@@ -4,6 +4,7 @@ var jsxRuntime = require('react/jsx-runtime');
4
4
  var react$1 = require('@liveblocks/react');
5
5
  var _private = require('@liveblocks/react/_private');
6
6
  var react = require('react');
7
+ require('../_private/index.cjs');
7
8
  var ArrowDown = require('../icons/ArrowDown.cjs');
8
9
  var Spinner = require('../icons/Spinner.cjs');
9
10
  var overrides = require('../overrides.cjs');
@@ -12,6 +13,7 @@ var useVisible = require('../utils/use-visible.cjs');
12
13
  var AiChatAssistantMessage = require('./internal/AiChatAssistantMessage.cjs');
13
14
  var AiChatUserMessage = require('./internal/AiChatUserMessage.cjs');
14
15
  var AiComposer = require('./internal/AiComposer.cjs');
16
+ var useStableComponent = require('../utils/use-stable-component.cjs');
15
17
 
16
18
  const MIN_DISTANCE_BOTTOM_SCROLL_INDICATOR = 60;
17
19
  const defaultComponents = {
@@ -238,8 +240,14 @@ const AiChat = react.forwardRef(
238
240
  const { messages, isLoading, error } = react$1.useAiChatMessages(chatId);
239
241
  const [lastSentMessageId, setLastSentMessageId] = react.useState(null);
240
242
  const $ = overrides.useOverrides(overrides$1);
241
- const Empty = components?.Empty ?? defaultComponents.Empty;
242
- const Loading = components?.Loading ?? defaultComponents.Loading;
243
+ const Empty = useStableComponent.useStableComponent(
244
+ components?.Empty,
245
+ defaultComponents.Empty
246
+ );
247
+ const Loading = useStableComponent.useStableComponent(
248
+ components?.Loading,
249
+ defaultComponents.Loading
250
+ );
243
251
  const containerRef = react.useRef(null);
244
252
  const messagesRef = react.useRef(null);
245
253
  const footerRef = react.useRef(null);
@@ -1 +1 @@
1
- {"version":3,"file":"AiChat.cjs","sources":["../../src/components/AiChat.tsx"],"sourcesContent":["import type {\n AiKnowledgeSource,\n AiOpaqueToolDefinition,\n CopilotId,\n MessageId,\n} from \"@liveblocks/core\";\nimport {\n RegisterAiKnowledge,\n RegisterAiTool,\n useAiChatMessages,\n} from \"@liveblocks/react\";\nimport { useLatest } from \"@liveblocks/react/_private\";\nimport {\n type ComponentProps,\n type ComponentType,\n forwardRef,\n type MutableRefObject,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from \"react\";\n\nimport type { GlobalComponents } from \"../components\";\nimport { ArrowDownIcon } from \"../icons/ArrowDown\";\nimport { SpinnerIcon } from \"../icons/Spinner\";\nimport {\n type AiChatMessageOverrides,\n type AiChatOverrides,\n type AiComposerOverrides,\n type GlobalOverrides,\n useOverrides,\n} from \"../overrides\";\nimport type { MarkdownComponents } from \"../primitives/Markdown\";\nimport { cn } from \"../utils/cn\";\nimport { useIntersectionCallback } from \"../utils/use-visible\";\nimport {\n AiChatAssistantMessage,\n type AiChatAssistantMessageProps,\n} from \"./internal/AiChatAssistantMessage\";\nimport { AiChatUserMessage } from \"./internal/AiChatUserMessage\";\nimport { AiComposer, type AiComposerProps } from \"./internal/AiComposer\";\n\n/**\n * The minimum number of pixels from the bottom of the scrollable area\n * before showing the scroll to bottom indicator.\n */\nconst MIN_DISTANCE_BOTTOM_SCROLL_INDICATOR = 60;\n\nexport type AiChatComponentsEmptyProps = {\n /**\n * The chat ID provided to the `AiChat` component.\n */\n chatId: string;\n\n /**\n * The copilot ID provided to the `AiChat` component.\n */\n copilotId?: string;\n};\n\nexport type AiChatComponentsLoadingProps = Record<string, never>;\n\nexport type AiChatComponents = {\n /**\n * The component used to render the empty state of the chat.\n */\n Empty: ComponentType<AiChatComponentsEmptyProps>;\n\n /**\n * The component used to render the loading state of the chat.\n */\n Loading: ComponentType<AiChatComponentsLoadingProps>;\n\n /**\n * The components used to render Markdown content.\n */\n markdown?: Partial<MarkdownComponents>;\n};\n\nexport interface AiChatProps extends ComponentProps<\"div\"> {\n /**\n * The ID of the chat the composer belongs to.\n */\n chatId: string;\n\n /**\n * Whether to focus the chat composer on mount.\n */\n autoFocus?: boolean;\n\n /**\n * The ID of the copilot to use to send the message.\n */\n copilotId?: string;\n\n /**\n * The contextual knowledge to include in the chat. May be used by the\n * assistant when generating responses. In addition to the knowledge passed\n * in via this prop, the AiChat instance will also have access to any\n * globally registered knowledge via <RegisterAiKnowledge />.\n */\n knowledge?: AiKnowledgeSource[];\n\n /**\n * Tool definitions to make available within this chat. May be used by the assistant when generating responses.\n */\n tools?: Record<string, AiOpaqueToolDefinition>;\n\n /**\n * The event handler called when the composer is submitted.\n */\n onComposerSubmit?: AiComposerProps[\"onComposerSubmit\"];\n\n /**\n * The layout of the chat and its composer.\n */\n layout?: \"inset\" | \"compact\";\n\n /**\n * How to show or hide reasoning.\n */\n showReasoning?: AiChatAssistantMessageProps[\"showReasoning\"];\n\n /**\n * How to show or hide retrievals.\n */\n showRetrievals?: AiChatAssistantMessageProps[\"showRetrievals\"];\n\n /**\n * Whether to show sources\n */\n showSources?: AiChatAssistantMessageProps[\"showSources\"];\n\n /**\n * The time, in milliseconds, before an AI response will timeout.\n */\n responseTimeout?: number;\n\n /**\n * Override the component's strings.\n */\n overrides?: Partial<\n GlobalOverrides &\n AiComposerOverrides &\n AiChatMessageOverrides &\n AiChatOverrides\n >;\n\n /**\n * Override the component's components.\n */\n components?: Partial<GlobalComponents & AiChatComponents>;\n}\n\ninterface AiChatMessagesProps extends ComponentProps<\"div\"> {\n messages: NonNullable<ReturnType<typeof useAiChatMessages>[\"messages\"]>;\n overrides: AiChatProps[\"overrides\"];\n components: AiChatProps[\"components\"];\n showReasoning: AiChatProps[\"showReasoning\"];\n showRetrievals: AiChatProps[\"showRetrievals\"];\n showSources: AiChatProps[\"showSources\"];\n lastSentMessageId: MessageId | null;\n scrollToBottom: MutableRefObject<\n (behavior: \"instant\" | \"smooth\", includeTrailingSpace?: boolean) => void\n >;\n onScrollAtBottomChange: MutableRefObject<\n (isScrollAtBottom: boolean | null) => void\n >;\n containerRef: MutableRefObject<HTMLDivElement | null>;\n footerRef: MutableRefObject<HTMLDivElement | null>;\n messagesRef: MutableRefObject<HTMLDivElement | null>;\n bottomTrailingMarkerRef: MutableRefObject<HTMLDivElement | null>;\n trailingSpacerRef: MutableRefObject<HTMLDivElement | null>;\n}\n\nconst defaultComponents: AiChatComponents = {\n Empty: () => null,\n Loading: () => (\n <div className=\"lb-loading lb-ai-chat-loading\">\n <SpinnerIcon />\n </div>\n ),\n};\n\nconst AiChatMessages = forwardRef<HTMLDivElement, AiChatMessagesProps>(\n (\n {\n messages,\n overrides,\n components,\n showReasoning,\n showRetrievals,\n showSources,\n lastSentMessageId,\n scrollToBottom,\n onScrollAtBottomChange,\n containerRef,\n footerRef,\n messagesRef,\n bottomTrailingMarkerRef,\n trailingSpacerRef,\n className,\n ...props\n },\n forwardedRef\n ) => {\n const hasLastSentMessage = lastSentMessageId !== null;\n\n /**\n * Every time the container, footer, or messages list change size,\n * we calculate the trailing space that would allow the penultimate\n * message to be at the top of the viewport, and apply it.\n *\n * ┌─────────────────────────────────────────┐▲ A = The `scroll-margin-top`\n * │ ┌─────────────────────────┐ │▼▲ value of the penultimate message\n * │ │ The penultimate message │ │ │\n * │ └─────────────────────────┘ │ │ B = The height from the top of\n * │ │ │ the penultimate message to the\n * │ ┌─────────────────────────┐ │ │ bottom of the messages list,\n * │ │ The last message │ │ │ including the messages' heights,\n * │ └─────────────────────────┘ │ │ and any padding, gap, etc\n * │ │ │\n * ├ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┤▲▼\n * │ ││ The trailing space needed to\n * │ = container height - (A + B + C) ││ allow the penultimate message\n * │ ││ to be at the top of the viewport\n * ├ ┬─────────────────────────────────────┬ ┤▼▲\n * │ │ │ │ │\n * │ │ │ │ │ C = The footer's height,\n * │ │ │ │ │ including any padding\n * │ └─────────────────────────────────────┘ │ │\n * └─────────────────────────────────────────┘ ▼\n */\n useEffect(\n () => {\n if (!hasLastSentMessage) {\n return;\n }\n\n const container = containerRef.current;\n const footer = footerRef.current;\n const messages = messagesRef.current;\n\n if (!container || !footer || !messages) {\n return;\n }\n\n const trailingSpacer = trailingSpacerRef.current;\n const bottomTrailingMarker = bottomTrailingMarkerRef.current;\n\n let containerHeight: number | undefined = undefined;\n let footerHeight: number | undefined = undefined;\n let messagesHeight: number | undefined = undefined;\n\n const resetTrailingSpace = () => {\n trailingSpacer?.style.removeProperty(\"height\");\n bottomTrailingMarker?.style.removeProperty(\"top\");\n };\n\n const updateTrailingSpace = (\n updatedContainerHeight?: number,\n updatedFooterHeight?: number,\n updatedMessagesHeight?: number\n ) => {\n if (!trailingSpacer || !bottomTrailingMarker) {\n return;\n }\n\n const lastMessage = messages.lastElementChild;\n const penultimateMessage = lastMessage?.previousElementSibling;\n\n if (updatedContainerHeight === undefined) {\n updatedContainerHeight = container.getBoundingClientRect().height;\n }\n\n if (updatedFooterHeight === undefined) {\n updatedFooterHeight = footer.getBoundingClientRect().height;\n }\n\n if (updatedMessagesHeight === undefined) {\n updatedMessagesHeight = messages.getBoundingClientRect().height;\n }\n\n // If the heights haven't changed, there's no need to update the trailing space.\n if (\n updatedContainerHeight === containerHeight &&\n updatedFooterHeight === footerHeight &&\n updatedMessagesHeight === messagesHeight\n ) {\n if (\n !lastMessage ||\n !penultimateMessage ||\n container.scrollHeight === container.clientHeight\n ) {\n resetTrailingSpace();\n }\n return;\n }\n\n // Now that we have compared them, we can update the heights.\n containerHeight = updatedContainerHeight;\n footerHeight = updatedFooterHeight;\n messagesHeight = updatedMessagesHeight;\n\n // If there's no last pair of messages, there's no need for any trailing space.\n if (!lastMessage || !penultimateMessage) {\n resetTrailingSpace();\n return;\n }\n\n // If the container isn't scrollable, there's no need for trailing space.\n if (container.scrollHeight === container.clientHeight) {\n resetTrailingSpace();\n return;\n }\n\n // A\n const penultimateMessageScrollMarginTop = Number.parseFloat(\n getComputedStyle(penultimateMessage as HTMLElement).scrollMarginTop\n );\n\n // B\n const messagesRect = messages.getBoundingClientRect();\n const penultimateMessageRect =\n penultimateMessage.getBoundingClientRect();\n const heightFromPenultimateMessageTopToMessagesListBottom =\n messagesRect.bottom - penultimateMessageRect.top;\n\n // A + B + C\n const differenceHeight =\n penultimateMessageScrollMarginTop +\n heightFromPenultimateMessageTopToMessagesListBottom +\n (footerHeight ?? 0);\n\n // = container height - (A + B + C)\n const trailingSpace = Math.max(containerHeight - differenceHeight, 0);\n\n // Update the trailing space.\n trailingSpacer.style.height = `${trailingSpace}px`;\n\n // Offset what \"the bottom\" is to the \"scroll at the bottom\" detection logic,\n // so that it doesn't include the trailing space.\n bottomTrailingMarker.style.top = `${-trailingSpace}px`;\n };\n\n const resizeObserver = new ResizeObserver((entries) => {\n let updatedContainerHeight: number | undefined = containerHeight;\n let updatedFooterHeight: number | undefined = footerHeight;\n let updatedMessagesHeight: number | undefined = messagesHeight;\n\n for (const entry of entries) {\n const entryHeight =\n entry.borderBoxSize?.[0]?.blockSize ?? entry.contentRect.height;\n\n if (entry.target === container) {\n updatedContainerHeight = entryHeight;\n } else if (entry.target === footer) {\n updatedFooterHeight = entryHeight;\n } else if (entry.target === messages) {\n updatedMessagesHeight = entryHeight;\n }\n }\n\n updateTrailingSpace(\n updatedContainerHeight,\n updatedFooterHeight,\n updatedMessagesHeight\n );\n });\n\n resizeObserver.observe(container);\n resizeObserver.observe(footer);\n resizeObserver.observe(messages);\n\n // Initialize before the first resize.\n requestAnimationFrame(() => updateTrailingSpace());\n\n return () => {\n resizeObserver.disconnect();\n resetTrailingSpace();\n };\n },\n // This effect only uses stable refs.\n [hasLastSentMessage] // eslint-disable-line react-hooks/exhaustive-deps\n );\n\n /**\n * Update the \"scroll at bottom\" state when needed.\n */\n useIntersectionCallback(\n bottomTrailingMarkerRef,\n (isIntersecting) => {\n onScrollAtBottomChange.current(isIntersecting);\n },\n { root: containerRef, rootMargin: MIN_DISTANCE_BOTTOM_SCROLL_INDICATOR }\n );\n\n /**\n * Instantly scroll to the bottom for the initial state.\n */\n useEffect(\n () => {\n scrollToBottom.current(\"instant\");\n },\n // `scrollToBottom` is a stable ref containing the callback.\n [] // eslint-disable-line react-hooks/exhaustive-deps\n );\n\n /**\n * Scroll to new messages when sending them.\n */\n useEffect(\n () => {\n if (lastSentMessageId) {\n scrollToBottom.current(\"smooth\", true);\n }\n },\n // `scrollToBottom` is a stable ref containing the callback.\n [lastSentMessageId] // eslint-disable-line react-hooks/exhaustive-deps\n );\n\n /**\n * Reset the \"scroll at bottom\" state when the component unmounts.\n */\n useEffect(\n () => {\n const onScrollAtBottomChangeCallback = onScrollAtBottomChange.current;\n\n return () => {\n onScrollAtBottomChangeCallback(null);\n };\n },\n // `onScrollAtBottomChange` is a stable ref containing the callback.\n [] // eslint-disable-line react-hooks/exhaustive-deps\n );\n\n return (\n <div\n className={cn(\"lb-ai-chat-messages\", className)}\n ref={forwardedRef}\n {...props}\n >\n {messages.map((message) => {\n if (message.role === \"user\") {\n return (\n <AiChatUserMessage\n key={message.id}\n message={message}\n overrides={overrides}\n components={components}\n />\n );\n } else if (message.role === \"assistant\") {\n return (\n <AiChatAssistantMessage\n key={message.id}\n message={message}\n overrides={overrides}\n components={components}\n showReasoning={showReasoning}\n showRetrievals={showRetrievals}\n showSources={showSources}\n />\n );\n } else {\n return null;\n }\n })}\n </div>\n );\n }\n);\n\n// Call `Element.scrollIntoView()` unless the element is not displayed.\n// (with `display: none` or nested within elements with `display: none`)\n// https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView\n//\n// This avoids browser quirks where they still attempt to scroll to the\n// element but it results in a scroll to the document's top.\nfunction scrollIntoView(\n element: HTMLElement | null,\n options?: ScrollIntoViewOptions\n) {\n if (!element) {\n return;\n }\n\n // Checking for at least one client rect allows 0 width/height elements,\n // unlike checking if the width/height is 0 with `getBoundingClientRect`.\n if (element.getClientRects().length === 0) {\n return;\n }\n\n element.scrollIntoView(options);\n}\n\nexport const AiChat = forwardRef<HTMLDivElement, AiChatProps>(\n (\n {\n chatId,\n copilotId,\n autoFocus,\n overrides,\n knowledge: localKnowledge,\n tools = {},\n onComposerSubmit,\n layout = \"inset\",\n showReasoning,\n showRetrievals,\n showSources,\n components,\n className,\n responseTimeout,\n ...props\n },\n forwardedRef\n ) => {\n const { messages, isLoading, error } = useAiChatMessages(chatId);\n const [lastSentMessageId, setLastSentMessageId] =\n useState<MessageId | null>(null);\n\n const $ = useOverrides(overrides);\n const Empty = components?.Empty ?? defaultComponents.Empty;\n const Loading = components?.Loading ?? defaultComponents.Loading;\n\n const containerRef = useRef<HTMLDivElement | null>(null);\n const messagesRef = useRef<HTMLDivElement | null>(null);\n const footerRef = useRef<HTMLDivElement | null>(null);\n const bottomMarkerRef = useRef<HTMLDivElement | null>(null);\n const bottomTrailingMarkerRef = useRef<HTMLDivElement | null>(null);\n const trailingSpacerRef = useRef<HTMLDivElement | null>(null);\n\n const [isScrollAtBottom, setScrollAtBottom] = useState<boolean | null>(\n null\n );\n // `useState`'s setter is stable but this is for clarity in the places it's used.\n const onScrollAtBottomChange = useLatest(setScrollAtBottom);\n const isScrollIndicatorVisible =\n messages && isScrollAtBottom !== null ? !isScrollAtBottom : false;\n\n useImperativeHandle<HTMLDivElement | null, HTMLDivElement | null>(\n forwardedRef,\n () => containerRef.current,\n []\n );\n\n const scrollToBottom = useLatest(\n (behavior: \"instant\" | \"smooth\", includeTrailingSpace = false) => {\n if (includeTrailingSpace) {\n // Scroll to the bottom marker to include the trailing space,\n // but wait for the next tick in case the trailing space hasn't\n // been updated yet. (e.g. when sending a new message)\n setTimeout(() => {\n scrollIntoView(bottomMarkerRef.current, {\n behavior,\n block: \"end\",\n });\n }, 0);\n } else {\n // Scroll to the trailing space marker to only scroll to the\n // bottom of the messages, without including the trailing space.\n scrollIntoView(bottomTrailingMarkerRef.current, {\n behavior,\n block: \"end\",\n });\n }\n }\n );\n\n return (\n <div\n ref={containerRef}\n {...props}\n className={cn(\n \"lb-root lb-ai-chat\",\n `lb-ai-chat:layout-${layout}`,\n className\n )}\n >\n {Object.entries(tools).map(([name, tool]) => (\n <RegisterAiTool key={name} chatId={chatId} name={name} tool={tool} />\n ))}\n\n {localKnowledge\n ? localKnowledge.map((knowledge, index) => (\n <RegisterAiKnowledge\n key={`${index}:${knowledge.description}`}\n chatId={chatId}\n {...knowledge}\n />\n ))\n : null}\n\n <div className=\"lb-ai-chat-content\">\n {isLoading ? (\n <Loading />\n ) : error !== undefined ? (\n <div className=\"lb-error lb-ai-chat-error\">\n {$.AI_CHAT_MESSAGES_ERROR(error)}\n </div>\n ) : messages.length === 0 ? (\n <Empty chatId={chatId} copilotId={copilotId} />\n ) : (\n <>\n <AiChatMessages\n messages={messages}\n overrides={overrides}\n components={components}\n showReasoning={showReasoning}\n showRetrievals={showRetrievals}\n showSources={showSources}\n lastSentMessageId={lastSentMessageId}\n scrollToBottom={scrollToBottom}\n onScrollAtBottomChange={onScrollAtBottomChange}\n containerRef={containerRef}\n footerRef={footerRef}\n messagesRef={messagesRef}\n bottomTrailingMarkerRef={bottomTrailingMarkerRef}\n trailingSpacerRef={trailingSpacerRef}\n ref={forwardedRef}\n />\n\n {/**\n * This trailing spacer is used to extend the scrollable area beyond its actual\n * content, to allow messages to appear at the top of the viewport for example.\n */}\n <div\n ref={trailingSpacerRef}\n data-trailing-spacer=\"\"\n style={{\n pointerEvents: \"none\",\n height: 0,\n }}\n aria-hidden\n />\n </>\n )}\n </div>\n\n <div className=\"lb-ai-chat-footer\" ref={footerRef}>\n <div className=\"lb-ai-chat-footer-actions\">\n <div\n className=\"lb-root lb-elevation lb-elevation-moderate lb-ai-chat-scroll-indicator\"\n data-visible={isScrollIndicatorVisible ? \"\" : undefined}\n >\n <button\n className=\"lb-ai-chat-scroll-indicator-button\"\n tabIndex={isScrollIndicatorVisible ? 0 : -1}\n aria-hidden={!isScrollIndicatorVisible}\n onClick={() => scrollToBottom.current(\"smooth\")}\n >\n <span className=\"lb-icon-container\">\n <ArrowDownIcon />\n </span>\n </button>\n </div>\n </div>\n <AiComposer\n key={chatId}\n chatId={chatId}\n copilotId={copilotId as CopilotId}\n overrides={overrides}\n autoFocus={autoFocus}\n responseTimeout={responseTimeout}\n onComposerSubmit={onComposerSubmit}\n onComposerSubmitted={({ id }) => setLastSentMessageId(id)}\n className={cn(\n \"lb-ai-chat-composer\",\n layout === \"inset\"\n ? \"lb-elevation lb-elevation-moderate\"\n : undefined\n )}\n />\n </div>\n\n {/**\n * This invisible marker is a trick which allows us to use IntersectionObserver to detect when the\n * scrollable area is fully scrolled to the bottom instead of manually tracking the scroll position\n * and having to deal with resizes, etc.\n *\n * It's positioned at the bottom of the scrollable area and reliably only becomes \"visible\" to the\n * IntersectionObserver when the scrollable area is scrolled to the bottom.\n */}\n {messages && messages.length > 0 ? (\n <div\n ref={bottomMarkerRef}\n style={{ position: \"sticky\", height: 0 }}\n aria-hidden\n data-bottom-marker=\"\"\n >\n {/**\n * This inner marker is absolutely offset by the same distance as the trailing space so its\n * visibility means the scrollable area is at the bottom of the messages, not the full bottom.\n */}\n <div\n ref={bottomTrailingMarkerRef}\n style={{\n position: \"absolute\",\n height: 0,\n }}\n data-bottom-trailing-marker=\"\"\n />\n </div>\n ) : null}\n </div>\n );\n }\n);\n"],"names":["jsx","SpinnerIcon","forwardRef","useEffect","messages","useIntersectionCallback","cn","AiChatUserMessage","AiChatAssistantMessage","overrides","useAiChatMessages","useState","useOverrides","useRef","useLatest","useImperativeHandle","jsxs","RegisterAiTool","RegisterAiKnowledge","Fragment","ArrowDownIcon","AiComposer"],"mappings":";;;;;;;;;;;;;;;AA+CA,MAAM,oCAAuC,GAAA,EAAA,CAAA;AAiI7C,MAAM,iBAAsC,GAAA;AAAA,EAC1C,OAAO,MAAM,IAAA;AAAA,EACb,OAAA,EAAS,sBACNA,cAAA,CAAA,KAAA,EAAA,EAAI,WAAU,+BACb,EAAA,QAAA,kBAAAA,cAAA,CAACC,uBAAY,CACf,EAAA,CAAA;AAEJ,CAAA,CAAA;AAEA,MAAM,cAAiB,GAAAC,gBAAA;AAAA,EACrB,CACE;AAAA,IACE,QAAA;AAAA,IACA,SAAA;AAAA,IACA,UAAA;AAAA,IACA,aAAA;AAAA,IACA,cAAA;AAAA,IACA,WAAA;AAAA,IACA,iBAAA;AAAA,IACA,cAAA;AAAA,IACA,sBAAA;AAAA,IACA,YAAA;AAAA,IACA,SAAA;AAAA,IACA,WAAA;AAAA,IACA,uBAAA;AAAA,IACA,iBAAA;AAAA,IACA,SAAA;AAAA,IACA,GAAG,KAAA;AAAA,KAEL,YACG,KAAA;AACH,IAAA,MAAM,qBAAqB,iBAAsB,KAAA,IAAA,CAAA;AA2BjD,IAAAC,eAAA;AAAA,MACE,MAAM;AACJ,QAAA,IAAI,CAAC,kBAAoB,EAAA;AACvB,UAAA,OAAA;AAAA,SACF;AAEA,QAAA,MAAM,YAAY,YAAa,CAAA,OAAA,CAAA;AAC/B,QAAA,MAAM,SAAS,SAAU,CAAA,OAAA,CAAA;AACzB,QAAA,MAAMC,YAAW,WAAY,CAAA,OAAA,CAAA;AAE7B,QAAA,IAAI,CAAC,SAAA,IAAa,CAAC,MAAA,IAAU,CAACA,SAAU,EAAA;AACtC,UAAA,OAAA;AAAA,SACF;AAEA,QAAA,MAAM,iBAAiB,iBAA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{"version":3,"file":"AiChat.cjs","sources":["../../src/components/AiChat.tsx"],"sourcesContent":["import type {\n AiKnowledgeSource,\n AiOpaqueToolDefinition,\n CopilotId,\n MessageId,\n} from \"@liveblocks/core\";\nimport {\n RegisterAiKnowledge,\n RegisterAiTool,\n useAiChatMessages,\n} from \"@liveblocks/react\";\nimport { useLatest } from \"@liveblocks/react/_private\";\nimport {\n type ComponentProps,\n type ComponentType,\n forwardRef,\n type MutableRefObject,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from \"react\";\n\nimport { useStableComponent } from \"../_private\";\nimport type { GlobalComponents } from \"../components\";\nimport { ArrowDownIcon } from \"../icons/ArrowDown\";\nimport { SpinnerIcon } from \"../icons/Spinner\";\nimport {\n type AiChatMessageOverrides,\n type AiChatOverrides,\n type AiComposerOverrides,\n type GlobalOverrides,\n useOverrides,\n} from \"../overrides\";\nimport type { MarkdownComponents } from \"../primitives/Markdown\";\nimport { cn } from \"../utils/cn\";\nimport { useIntersectionCallback } from \"../utils/use-visible\";\nimport {\n AiChatAssistantMessage,\n type AiChatAssistantMessageProps,\n} from \"./internal/AiChatAssistantMessage\";\nimport { AiChatUserMessage } from \"./internal/AiChatUserMessage\";\nimport { AiComposer, type AiComposerProps } from \"./internal/AiComposer\";\n\n/**\n * The minimum number of pixels from the bottom of the scrollable area\n * before showing the scroll to bottom indicator.\n */\nconst MIN_DISTANCE_BOTTOM_SCROLL_INDICATOR = 60;\n\nexport type AiChatComponentsEmptyProps = {\n /**\n * The chat ID provided to the `AiChat` component.\n */\n chatId: string;\n\n /**\n * The copilot ID provided to the `AiChat` component.\n */\n copilotId?: string;\n};\n\nexport type AiChatComponentsLoadingProps = Record<string, never>;\n\nexport type AiChatComponents = {\n /**\n * The component used to render the empty state of the chat.\n */\n Empty: ComponentType<AiChatComponentsEmptyProps>;\n\n /**\n * The component used to render the loading state of the chat.\n */\n Loading: ComponentType<AiChatComponentsLoadingProps>;\n\n /**\n * The components used to render Markdown content.\n */\n markdown?: Partial<MarkdownComponents>;\n};\n\nexport interface AiChatProps extends ComponentProps<\"div\"> {\n /**\n * The ID of the chat the composer belongs to.\n */\n chatId: string;\n\n /**\n * Whether to focus the chat composer on mount.\n */\n autoFocus?: boolean;\n\n /**\n * The ID of the copilot to use to send the message.\n */\n copilotId?: string;\n\n /**\n * The contextual knowledge to include in the chat. May be used by the\n * assistant when generating responses. In addition to the knowledge passed\n * in via this prop, the AiChat instance will also have access to any\n * globally registered knowledge via <RegisterAiKnowledge />.\n */\n knowledge?: AiKnowledgeSource[];\n\n /**\n * Tool definitions to make available within this chat. May be used by the assistant when generating responses.\n */\n tools?: Record<string, AiOpaqueToolDefinition>;\n\n /**\n * The event handler called when the composer is submitted.\n */\n onComposerSubmit?: AiComposerProps[\"onComposerSubmit\"];\n\n /**\n * The layout of the chat and its composer.\n */\n layout?: \"inset\" | \"compact\";\n\n /**\n * How to show or hide reasoning.\n */\n showReasoning?: AiChatAssistantMessageProps[\"showReasoning\"];\n\n /**\n * How to show or hide retrievals.\n */\n showRetrievals?: AiChatAssistantMessageProps[\"showRetrievals\"];\n\n /**\n * Whether to show sources\n */\n showSources?: AiChatAssistantMessageProps[\"showSources\"];\n\n /**\n * The time, in milliseconds, before an AI response will timeout.\n */\n responseTimeout?: number;\n\n /**\n * Override the component's strings.\n */\n overrides?: Partial<\n GlobalOverrides &\n AiComposerOverrides &\n AiChatMessageOverrides &\n AiChatOverrides\n >;\n\n /**\n * Override the component's components.\n */\n components?: Partial<GlobalComponents & AiChatComponents>;\n}\n\ninterface AiChatMessagesProps extends ComponentProps<\"div\"> {\n messages: NonNullable<ReturnType<typeof useAiChatMessages>[\"messages\"]>;\n overrides: AiChatProps[\"overrides\"];\n components: AiChatProps[\"components\"];\n showReasoning: AiChatProps[\"showReasoning\"];\n showRetrievals: AiChatProps[\"showRetrievals\"];\n showSources: AiChatProps[\"showSources\"];\n lastSentMessageId: MessageId | null;\n scrollToBottom: MutableRefObject<\n (behavior: \"instant\" | \"smooth\", includeTrailingSpace?: boolean) => void\n >;\n onScrollAtBottomChange: MutableRefObject<\n (isScrollAtBottom: boolean | null) => void\n >;\n containerRef: MutableRefObject<HTMLDivElement | null>;\n footerRef: MutableRefObject<HTMLDivElement | null>;\n messagesRef: MutableRefObject<HTMLDivElement | null>;\n bottomTrailingMarkerRef: MutableRefObject<HTMLDivElement | null>;\n trailingSpacerRef: MutableRefObject<HTMLDivElement | null>;\n}\n\nconst defaultComponents: AiChatComponents = {\n Empty: () => null,\n Loading: () => (\n <div className=\"lb-loading lb-ai-chat-loading\">\n <SpinnerIcon />\n </div>\n ),\n};\n\nconst AiChatMessages = forwardRef<HTMLDivElement, AiChatMessagesProps>(\n (\n {\n messages,\n overrides,\n components,\n showReasoning,\n showRetrievals,\n showSources,\n lastSentMessageId,\n scrollToBottom,\n onScrollAtBottomChange,\n containerRef,\n footerRef,\n messagesRef,\n bottomTrailingMarkerRef,\n trailingSpacerRef,\n className,\n ...props\n },\n forwardedRef\n ) => {\n const hasLastSentMessage = lastSentMessageId !== null;\n\n /**\n * Every time the container, footer, or messages list change size,\n * we calculate the trailing space that would allow the penultimate\n * message to be at the top of the viewport, and apply it.\n *\n * ┌─────────────────────────────────────────┐▲ A = The `scroll-margin-top`\n * │ ┌─────────────────────────┐ │▼▲ value of the penultimate message\n * │ │ The penultimate message │ │ │\n * │ └─────────────────────────┘ │ │ B = The height from the top of\n * │ │ │ the penultimate message to the\n * │ ┌─────────────────────────┐ │ │ bottom of the messages list,\n * │ │ The last message │ │ │ including the messages' heights,\n * │ └─────────────────────────┘ │ │ and any padding, gap, etc\n * │ │ │\n * ├ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┤▲▼\n * │ ││ The trailing space needed to\n * │ = container height - (A + B + C) ││ allow the penultimate message\n * │ ││ to be at the top of the viewport\n * ├ ┬─────────────────────────────────────┬ ┤▼▲\n * │ │ │ │ │\n * │ │ │ │ │ C = The footer's height,\n * │ │ │ │ │ including any padding\n * │ └─────────────────────────────────────┘ │ │\n * └─────────────────────────────────────────┘ ▼\n */\n useEffect(\n () => {\n if (!hasLastSentMessage) {\n return;\n }\n\n const container = containerRef.current;\n const footer = footerRef.current;\n const messages = messagesRef.current;\n\n if (!container || !footer || !messages) {\n return;\n }\n\n const trailingSpacer = trailingSpacerRef.current;\n const bottomTrailingMarker = bottomTrailingMarkerRef.current;\n\n let containerHeight: number | undefined = undefined;\n let footerHeight: number | undefined = undefined;\n let messagesHeight: number | undefined = undefined;\n\n const resetTrailingSpace = () => {\n trailingSpacer?.style.removeProperty(\"height\");\n bottomTrailingMarker?.style.removeProperty(\"top\");\n };\n\n const updateTrailingSpace = (\n updatedContainerHeight?: number,\n updatedFooterHeight?: number,\n updatedMessagesHeight?: number\n ) => {\n if (!trailingSpacer || !bottomTrailingMarker) {\n return;\n }\n\n const lastMessage = messages.lastElementChild;\n const penultimateMessage = lastMessage?.previousElementSibling;\n\n if (updatedContainerHeight === undefined) {\n updatedContainerHeight = container.getBoundingClientRect().height;\n }\n\n if (updatedFooterHeight === undefined) {\n updatedFooterHeight = footer.getBoundingClientRect().height;\n }\n\n if (updatedMessagesHeight === undefined) {\n updatedMessagesHeight = messages.getBoundingClientRect().height;\n }\n\n // If the heights haven't changed, there's no need to update the trailing space.\n if (\n updatedContainerHeight === containerHeight &&\n updatedFooterHeight === footerHeight &&\n updatedMessagesHeight === messagesHeight\n ) {\n if (\n !lastMessage ||\n !penultimateMessage ||\n container.scrollHeight === container.clientHeight\n ) {\n resetTrailingSpace();\n }\n return;\n }\n\n // Now that we have compared them, we can update the heights.\n containerHeight = updatedContainerHeight;\n footerHeight = updatedFooterHeight;\n messagesHeight = updatedMessagesHeight;\n\n // If there's no last pair of messages, there's no need for any trailing space.\n if (!lastMessage || !penultimateMessage) {\n resetTrailingSpace();\n return;\n }\n\n // If the container isn't scrollable, there's no need for trailing space.\n if (container.scrollHeight === container.clientHeight) {\n resetTrailingSpace();\n return;\n }\n\n // A\n const penultimateMessageScrollMarginTop = Number.parseFloat(\n getComputedStyle(penultimateMessage as HTMLElement).scrollMarginTop\n );\n\n // B\n const messagesRect = messages.getBoundingClientRect();\n const penultimateMessageRect =\n penultimateMessage.getBoundingClientRect();\n const heightFromPenultimateMessageTopToMessagesListBottom =\n messagesRect.bottom - penultimateMessageRect.top;\n\n // A + B + C\n const differenceHeight =\n penultimateMessageScrollMarginTop +\n heightFromPenultimateMessageTopToMessagesListBottom +\n (footerHeight ?? 0);\n\n // = container height - (A + B + C)\n const trailingSpace = Math.max(containerHeight - differenceHeight, 0);\n\n // Update the trailing space.\n trailingSpacer.style.height = `${trailingSpace}px`;\n\n // Offset what \"the bottom\" is to the \"scroll at the bottom\" detection logic,\n // so that it doesn't include the trailing space.\n bottomTrailingMarker.style.top = `${-trailingSpace}px`;\n };\n\n const resizeObserver = new ResizeObserver((entries) => {\n let updatedContainerHeight: number | undefined = containerHeight;\n let updatedFooterHeight: number | undefined = footerHeight;\n let updatedMessagesHeight: number | undefined = messagesHeight;\n\n for (const entry of entries) {\n const entryHeight =\n entry.borderBoxSize?.[0]?.blockSize ?? entry.contentRect.height;\n\n if (entry.target === container) {\n updatedContainerHeight = entryHeight;\n } else if (entry.target === footer) {\n updatedFooterHeight = entryHeight;\n } else if (entry.target === messages) {\n updatedMessagesHeight = entryHeight;\n }\n }\n\n updateTrailingSpace(\n updatedContainerHeight,\n updatedFooterHeight,\n updatedMessagesHeight\n );\n });\n\n resizeObserver.observe(container);\n resizeObserver.observe(footer);\n resizeObserver.observe(messages);\n\n // Initialize before the first resize.\n requestAnimationFrame(() => updateTrailingSpace());\n\n return () => {\n resizeObserver.disconnect();\n resetTrailingSpace();\n };\n },\n // This effect only uses stable refs.\n [hasLastSentMessage] // eslint-disable-line react-hooks/exhaustive-deps\n );\n\n /**\n * Update the \"scroll at bottom\" state when needed.\n */\n useIntersectionCallback(\n bottomTrailingMarkerRef,\n (isIntersecting) => {\n onScrollAtBottomChange.current(isIntersecting);\n },\n { root: containerRef, rootMargin: MIN_DISTANCE_BOTTOM_SCROLL_INDICATOR }\n );\n\n /**\n * Instantly scroll to the bottom for the initial state.\n */\n useEffect(\n () => {\n scrollToBottom.current(\"instant\");\n },\n // `scrollToBottom` is a stable ref containing the callback.\n [] // eslint-disable-line react-hooks/exhaustive-deps\n );\n\n /**\n * Scroll to new messages when sending them.\n */\n useEffect(\n () => {\n if (lastSentMessageId) {\n scrollToBottom.current(\"smooth\", true);\n }\n },\n // `scrollToBottom` is a stable ref containing the callback.\n [lastSentMessageId] // eslint-disable-line react-hooks/exhaustive-deps\n );\n\n /**\n * Reset the \"scroll at bottom\" state when the component unmounts.\n */\n useEffect(\n () => {\n const onScrollAtBottomChangeCallback = onScrollAtBottomChange.current;\n\n return () => {\n onScrollAtBottomChangeCallback(null);\n };\n },\n // `onScrollAtBottomChange` is a stable ref containing the callback.\n [] // eslint-disable-line react-hooks/exhaustive-deps\n );\n\n return (\n <div\n className={cn(\"lb-ai-chat-messages\", className)}\n ref={forwardedRef}\n {...props}\n >\n {messages.map((message) => {\n if (message.role === \"user\") {\n return (\n <AiChatUserMessage\n key={message.id}\n message={message}\n overrides={overrides}\n components={components}\n />\n );\n } else if (message.role === \"assistant\") {\n return (\n <AiChatAssistantMessage\n key={message.id}\n message={message}\n overrides={overrides}\n components={components}\n showReasoning={showReasoning}\n showRetrievals={showRetrievals}\n showSources={showSources}\n />\n );\n } else {\n return null;\n }\n })}\n </div>\n );\n }\n);\n\n// Call `Element.scrollIntoView()` unless the element is not displayed.\n// (with `display: none` or nested within elements with `display: none`)\n// https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView\n//\n// This avoids browser quirks where they still attempt to scroll to the\n// element but it results in a scroll to the document's top.\nfunction scrollIntoView(\n element: HTMLElement | null,\n options?: ScrollIntoViewOptions\n) {\n if (!element) {\n return;\n }\n\n // Checking for at least one client rect allows 0 width/height elements,\n // unlike checking if the width/height is 0 with `getBoundingClientRect`.\n if (element.getClientRects().length === 0) {\n return;\n }\n\n element.scrollIntoView(options);\n}\n\nexport const AiChat = forwardRef<HTMLDivElement, AiChatProps>(\n (\n {\n chatId,\n copilotId,\n autoFocus,\n overrides,\n knowledge: localKnowledge,\n tools = {},\n onComposerSubmit,\n layout = \"inset\",\n showReasoning,\n showRetrievals,\n showSources,\n components,\n className,\n responseTimeout,\n ...props\n },\n forwardedRef\n ) => {\n const { messages, isLoading, error } = useAiChatMessages(chatId);\n const [lastSentMessageId, setLastSentMessageId] =\n useState<MessageId | null>(null);\n\n const $ = useOverrides(overrides);\n const Empty = useStableComponent(\n components?.Empty,\n defaultComponents.Empty\n );\n const Loading = useStableComponent(\n components?.Loading,\n defaultComponents.Loading\n );\n\n const containerRef = useRef<HTMLDivElement | null>(null);\n const messagesRef = useRef<HTMLDivElement | null>(null);\n const footerRef = useRef<HTMLDivElement | null>(null);\n const bottomMarkerRef = useRef<HTMLDivElement | null>(null);\n const bottomTrailingMarkerRef = useRef<HTMLDivElement | null>(null);\n const trailingSpacerRef = useRef<HTMLDivElement | null>(null);\n\n const [isScrollAtBottom, setScrollAtBottom] = useState<boolean | null>(\n null\n );\n // `useState`'s setter is stable but this is for clarity in the places it's used.\n const onScrollAtBottomChange = useLatest(setScrollAtBottom);\n const isScrollIndicatorVisible =\n messages && isScrollAtBottom !== null ? !isScrollAtBottom : false;\n\n useImperativeHandle<HTMLDivElement | null, HTMLDivElement | null>(\n forwardedRef,\n () => containerRef.current,\n []\n );\n\n const scrollToBottom = useLatest(\n (behavior: \"instant\" | \"smooth\", includeTrailingSpace = false) => {\n if (includeTrailingSpace) {\n // Scroll to the bottom marker to include the trailing space,\n // but wait for the next tick in case the trailing space hasn't\n // been updated yet. (e.g. when sending a new message)\n setTimeout(() => {\n scrollIntoView(bottomMarkerRef.current, {\n behavior,\n block: \"end\",\n });\n }, 0);\n } else {\n // Scroll to the trailing space marker to only scroll to the\n // bottom of the messages, without including the trailing space.\n scrollIntoView(bottomTrailingMarkerRef.current, {\n behavior,\n block: \"end\",\n });\n }\n }\n );\n\n return (\n <div\n ref={containerRef}\n {...props}\n className={cn(\n \"lb-root lb-ai-chat\",\n `lb-ai-chat:layout-${layout}`,\n className\n )}\n >\n {Object.entries(tools).map(([name, tool]) => (\n <RegisterAiTool key={name} chatId={chatId} name={name} tool={tool} />\n ))}\n\n {localKnowledge\n ? localKnowledge.map((knowledge, index) => (\n <RegisterAiKnowledge\n key={`${index}:${knowledge.description}`}\n chatId={chatId}\n {...knowledge}\n />\n ))\n : null}\n\n <div className=\"lb-ai-chat-content\">\n {isLoading ? (\n <Loading />\n ) : error !== undefined ? (\n <div className=\"lb-error lb-ai-chat-error\">\n {$.AI_CHAT_MESSAGES_ERROR(error)}\n </div>\n ) : messages.length === 0 ? (\n <Empty chatId={chatId} copilotId={copilotId} />\n ) : (\n <>\n <AiChatMessages\n messages={messages}\n overrides={overrides}\n components={components}\n showReasoning={showReasoning}\n showRetrievals={showRetrievals}\n showSources={showSources}\n lastSentMessageId={lastSentMessageId}\n scrollToBottom={scrollToBottom}\n onScrollAtBottomChange={onScrollAtBottomChange}\n containerRef={containerRef}\n footerRef={footerRef}\n messagesRef={messagesRef}\n bottomTrailingMarkerRef={bottomTrailingMarkerRef}\n trailingSpacerRef={trailingSpacerRef}\n ref={forwardedRef}\n />\n\n {/**\n * This trailing spacer is used to extend the scrollable area beyond its actual\n * content, to allow messages to appear at the top of the viewport for example.\n */}\n <div\n ref={trailingSpacerRef}\n data-trailing-spacer=\"\"\n style={{\n pointerEvents: \"none\",\n height: 0,\n }}\n aria-hidden\n />\n </>\n )}\n </div>\n\n <div className=\"lb-ai-chat-footer\" ref={footerRef}>\n <div className=\"lb-ai-chat-footer-actions\">\n <div\n className=\"lb-root lb-elevation lb-elevation-moderate lb-ai-chat-scroll-indicator\"\n data-visible={isScrollIndicatorVisible ? \"\" : undefined}\n >\n <button\n className=\"lb-ai-chat-scroll-indicator-button\"\n tabIndex={isScrollIndicatorVisible ? 0 : -1}\n aria-hidden={!isScrollIndicatorVisible}\n onClick={() => scrollToBottom.current(\"smooth\")}\n >\n <span className=\"lb-icon-container\">\n <ArrowDownIcon />\n </span>\n </button>\n </div>\n </div>\n <AiComposer\n key={chatId}\n chatId={chatId}\n copilotId={copilotId as CopilotId}\n overrides={overrides}\n autoFocus={autoFocus}\n responseTimeout={responseTimeout}\n onComposerSubmit={onComposerSubmit}\n onComposerSubmitted={({ id }) => setLastSentMessageId(id)}\n className={cn(\n \"lb-ai-chat-composer\",\n layout === \"inset\"\n ? \"lb-elevation lb-elevation-moderate\"\n : undefined\n )}\n />\n </div>\n\n {/**\n * This invisible marker is a trick which allows us to use IntersectionObserver to detect when the\n * scrollable area is fully scrolled to the bottom instead of manually tracking the scroll position\n * and having to deal with resizes, etc.\n *\n * It's positioned at the bottom of the scrollable area and reliably only becomes \"visible\" to the\n * IntersectionObserver when the scrollable area is scrolled to the bottom.\n */}\n {messages && messages.length > 0 ? (\n <div\n ref={bottomMarkerRef}\n style={{ position: \"sticky\", height: 0 }}\n aria-hidden\n data-bottom-marker=\"\"\n >\n {/**\n * This inner marker is absolutely offset by the same distance as the trailing space so its\n * visibility means the scrollable area is at the bottom of the messages, not the full bottom.\n */}\n <div\n ref={bottomTrailingMarkerRef}\n style={{\n position: \"absolute\",\n height: 0,\n }}\n data-bottom-trailing-marker=\"\"\n />\n </div>\n ) : null}\n </div>\n );\n }\n);\n"],"names":["jsx","SpinnerIcon","forwardRef","useEffect","messages","useIntersectionCallback","cn","AiChatUserMessage","AiChatAssistantMessage","overrides","useAiChatMessages","useState","useOverrides","useStableComponent","useRef","useLatest","useImperativeHandle","jsxs","RegisterAiTool","RegisterAiKnowledge","Fragment","ArrowDownIcon","AiComposer"],"mappings":";;;;;;;;;;;;;;;;;AAgDA,MAAM,oCAAuC,GAAA,EAAA,CAAA;AAiI7C,MAAM,iBAAsC,GAAA;AAAA,EAC1C,OAAO,MAAM,IAAA;AAAA,EACb,OAAA,EAAS,sBACNA,cAAA,CA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AA;AAAA,gBACA,SAAA;AAAA,2BACAb,WAAA;AAAA,gBACA,SAAA;AAAA,gBACA,eAAA;AAAA,gBACA,gBAAA;AAAA,gBACA,qBAAqB,CAAC,EAAE,EAAG,EAAA,KAAM,qBAAqB,EAAE,CAAA;AAAA,gBACxD,SAAW,EAAAH,KAAA;AAAA,kBACT,qBAAA;AAAA,kBACA,MAAA,KAAW,UACP,oCACA,GAAA,KAAA,CAAA;AAAA,iBACN;AAAA,eAAA;AAAA,cAbK,MAAA;AAAA,aAcP;AAAA,WACF,EAAA,CAAA;AAAA,UAUC,QAAA,IAAY,QAAS,CAAA,MAAA,GAAS,CAC7B,mBAAAN,cAAA;AAAA,YAAC,KAAA;AAAA,YAAA;AAAA,cACC,GAAK,EAAA,eAAA;AAAA,cACL,KAAO,EAAA,EAAE,QAAU,EAAA,QAAA,EAAU,QAAQ,CAAE,EAAA;AAAA,cACvC,aAAW,EAAA,IAAA;AAAA,cACX,oBAAmB,EAAA,EAAA;AAAA,cAMnB,QAAA,kBAAAA,cAAA;AAAA,gBAAC,KAAA;AAAA,gBAAA;AAAA,kBACC,GAAK,EAAA,uBAAA;AAAA,kBACL,KAAO,EAAA;AAAA,oBACL,QAAU,EAAA,UAAA;AAAA,oBACV,MAAQ,EAAA,CAAA;AAAA,mBACV;AAAA,kBACA,6BAA4B,EAAA,EAAA;AAAA,iBAAA;AAAA,eAC9B;AAAA,aAAA;AAAA,WAEA,GAAA,IAAA;AAAA,SAAA;AAAA,OAAA;AAAA,KACN,CAAA;AAAA,GAEJ;AACF;;;;"}
@@ -2,6 +2,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { useAiChatMessages, RegisterAiTool, RegisterAiKnowledge } from '@liveblocks/react';
3
3
  import { useLatest } from '@liveblocks/react/_private';
4
4
  import { forwardRef, useEffect, useState, useRef, useImperativeHandle } from 'react';
5
+ import '../_private/index.js';
5
6
  import { ArrowDownIcon } from '../icons/ArrowDown.js';
6
7
  import { SpinnerIcon } from '../icons/Spinner.js';
7
8
  import { useOverrides } from '../overrides.js';
@@ -10,6 +11,7 @@ import { useIntersectionCallback } from '../utils/use-visible.js';
10
11
  import { AiChatAssistantMessage } from './internal/AiChatAssistantMessage.js';
11
12
  import { AiChatUserMessage } from './internal/AiChatUserMessage.js';
12
13
  import { AiComposer } from './internal/AiComposer.js';
14
+ import { useStableComponent } from '../utils/use-stable-component.js';
13
15
 
14
16
  const MIN_DISTANCE_BOTTOM_SCROLL_INDICATOR = 60;
15
17
  const defaultComponents = {
@@ -236,8 +238,14 @@ const AiChat = forwardRef(
236
238
  const { messages, isLoading, error } = useAiChatMessages(chatId);
237
239
  const [lastSentMessageId, setLastSentMessageId] = useState(null);
238
240
  const $ = useOverrides(overrides);
239
- const Empty = components?.Empty ?? defaultComponents.Empty;
240
- const Loading = components?.Loading ?? defaultComponents.Loading;
241
+ const Empty = useStableComponent(
242
+ components?.Empty,
243
+ defaultComponents.Empty
244
+ );
245
+ const Loading = useStableComponent(
246
+ components?.Loading,
247
+ defaultComponents.Loading
248
+ );
241
249
  const containerRef = useRef(null);
242
250
  const messagesRef = useRef(null);
243
251
  const footerRef = useRef(null);
@@ -1 +1 @@
1
- {"version":3,"file":"AiChat.js","sources":["../../src/components/AiChat.tsx"],"sourcesContent":["import type {\n AiKnowledgeSource,\n AiOpaqueToolDefinition,\n CopilotId,\n MessageId,\n} from \"@liveblocks/core\";\nimport {\n RegisterAiKnowledge,\n RegisterAiTool,\n useAiChatMessages,\n} from \"@liveblocks/react\";\nimport { useLatest } from \"@liveblocks/react/_private\";\nimport {\n type ComponentProps,\n type ComponentType,\n forwardRef,\n type MutableRefObject,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from \"react\";\n\nimport type { GlobalComponents } from \"../components\";\nimport { ArrowDownIcon } from \"../icons/ArrowDown\";\nimport { SpinnerIcon } from \"../icons/Spinner\";\nimport {\n type AiChatMessageOverrides,\n type AiChatOverrides,\n type AiComposerOverrides,\n type GlobalOverrides,\n useOverrides,\n} from \"../overrides\";\nimport type { MarkdownComponents } from \"../primitives/Markdown\";\nimport { cn } from \"../utils/cn\";\nimport { useIntersectionCallback } from \"../utils/use-visible\";\nimport {\n AiChatAssistantMessage,\n type AiChatAssistantMessageProps,\n} from \"./internal/AiChatAssistantMessage\";\nimport { AiChatUserMessage } from \"./internal/AiChatUserMessage\";\nimport { AiComposer, type AiComposerProps } from \"./internal/AiComposer\";\n\n/**\n * The minimum number of pixels from the bottom of the scrollable area\n * before showing the scroll to bottom indicator.\n */\nconst MIN_DISTANCE_BOTTOM_SCROLL_INDICATOR = 60;\n\nexport type AiChatComponentsEmptyProps = {\n /**\n * The chat ID provided to the `AiChat` component.\n */\n chatId: string;\n\n /**\n * The copilot ID provided to the `AiChat` component.\n */\n copilotId?: string;\n};\n\nexport type AiChatComponentsLoadingProps = Record<string, never>;\n\nexport type AiChatComponents = {\n /**\n * The component used to render the empty state of the chat.\n */\n Empty: ComponentType<AiChatComponentsEmptyProps>;\n\n /**\n * The component used to render the loading state of the chat.\n */\n Loading: ComponentType<AiChatComponentsLoadingProps>;\n\n /**\n * The components used to render Markdown content.\n */\n markdown?: Partial<MarkdownComponents>;\n};\n\nexport interface AiChatProps extends ComponentProps<\"div\"> {\n /**\n * The ID of the chat the composer belongs to.\n */\n chatId: string;\n\n /**\n * Whether to focus the chat composer on mount.\n */\n autoFocus?: boolean;\n\n /**\n * The ID of the copilot to use to send the message.\n */\n copilotId?: string;\n\n /**\n * The contextual knowledge to include in the chat. May be used by the\n * assistant when generating responses. In addition to the knowledge passed\n * in via this prop, the AiChat instance will also have access to any\n * globally registered knowledge via <RegisterAiKnowledge />.\n */\n knowledge?: AiKnowledgeSource[];\n\n /**\n * Tool definitions to make available within this chat. May be used by the assistant when generating responses.\n */\n tools?: Record<string, AiOpaqueToolDefinition>;\n\n /**\n * The event handler called when the composer is submitted.\n */\n onComposerSubmit?: AiComposerProps[\"onComposerSubmit\"];\n\n /**\n * The layout of the chat and its composer.\n */\n layout?: \"inset\" | \"compact\";\n\n /**\n * How to show or hide reasoning.\n */\n showReasoning?: AiChatAssistantMessageProps[\"showReasoning\"];\n\n /**\n * How to show or hide retrievals.\n */\n showRetrievals?: AiChatAssistantMessageProps[\"showRetrievals\"];\n\n /**\n * Whether to show sources\n */\n showSources?: AiChatAssistantMessageProps[\"showSources\"];\n\n /**\n * The time, in milliseconds, before an AI response will timeout.\n */\n responseTimeout?: number;\n\n /**\n * Override the component's strings.\n */\n overrides?: Partial<\n GlobalOverrides &\n AiComposerOverrides &\n AiChatMessageOverrides &\n AiChatOverrides\n >;\n\n /**\n * Override the component's components.\n */\n components?: Partial<GlobalComponents & AiChatComponents>;\n}\n\ninterface AiChatMessagesProps extends ComponentProps<\"div\"> {\n messages: NonNullable<ReturnType<typeof useAiChatMessages>[\"messages\"]>;\n overrides: AiChatProps[\"overrides\"];\n components: AiChatProps[\"components\"];\n showReasoning: AiChatProps[\"showReasoning\"];\n showRetrievals: AiChatProps[\"showRetrievals\"];\n showSources: AiChatProps[\"showSources\"];\n lastSentMessageId: MessageId | null;\n scrollToBottom: MutableRefObject<\n (behavior: \"instant\" | \"smooth\", includeTrailingSpace?: boolean) => void\n >;\n onScrollAtBottomChange: MutableRefObject<\n (isScrollAtBottom: boolean | null) => void\n >;\n containerRef: MutableRefObject<HTMLDivElement | null>;\n footerRef: MutableRefObject<HTMLDivElement | null>;\n messagesRef: MutableRefObject<HTMLDivElement | null>;\n bottomTrailingMarkerRef: MutableRefObject<HTMLDivElement | null>;\n trailingSpacerRef: MutableRefObject<HTMLDivElement | null>;\n}\n\nconst defaultComponents: AiChatComponents = {\n Empty: () => null,\n Loading: () => (\n <div className=\"lb-loading lb-ai-chat-loading\">\n <SpinnerIcon />\n </div>\n ),\n};\n\nconst AiChatMessages = forwardRef<HTMLDivElement, AiChatMessagesProps>(\n (\n {\n messages,\n overrides,\n components,\n showReasoning,\n showRetrievals,\n showSources,\n lastSentMessageId,\n scrollToBottom,\n onScrollAtBottomChange,\n containerRef,\n footerRef,\n messagesRef,\n bottomTrailingMarkerRef,\n trailingSpacerRef,\n className,\n ...props\n },\n forwardedRef\n ) => {\n const hasLastSentMessage = lastSentMessageId !== null;\n\n /**\n * Every time the container, footer, or messages list change size,\n * we calculate the trailing space that would allow the penultimate\n * message to be at the top of the viewport, and apply it.\n *\n * ┌─────────────────────────────────────────┐▲ A = The `scroll-margin-top`\n * │ ┌─────────────────────────┐ │▼▲ value of the penultimate message\n * │ │ The penultimate message │ │ │\n * │ └─────────────────────────┘ │ │ B = The height from the top of\n * │ │ │ the penultimate message to the\n * │ ┌─────────────────────────┐ │ │ bottom of the messages list,\n * │ │ The last message │ │ │ including the messages' heights,\n * │ └─────────────────────────┘ │ │ and any padding, gap, etc\n * │ │ │\n * ├ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┤▲▼\n * │ ││ The trailing space needed to\n * │ = container height - (A + B + C) ││ allow the penultimate message\n * │ ││ to be at the top of the viewport\n * ├ ┬─────────────────────────────────────┬ ┤▼▲\n * │ │ │ │ │\n * │ │ │ │ │ C = The footer's height,\n * │ │ │ │ │ including any padding\n * │ └─────────────────────────────────────┘ │ │\n * └─────────────────────────────────────────┘ ▼\n */\n useEffect(\n () => {\n if (!hasLastSentMessage) {\n return;\n }\n\n const container = containerRef.current;\n const footer = footerRef.current;\n const messages = messagesRef.current;\n\n if (!container || !footer || !messages) {\n return;\n }\n\n const trailingSpacer = trailingSpacerRef.current;\n const bottomTrailingMarker = bottomTrailingMarkerRef.current;\n\n let containerHeight: number | undefined = undefined;\n let footerHeight: number | undefined = undefined;\n let messagesHeight: number | undefined = undefined;\n\n const resetTrailingSpace = () => {\n trailingSpacer?.style.removeProperty(\"height\");\n bottomTrailingMarker?.style.removeProperty(\"top\");\n };\n\n const updateTrailingSpace = (\n updatedContainerHeight?: number,\n updatedFooterHeight?: number,\n updatedMessagesHeight?: number\n ) => {\n if (!trailingSpacer || !bottomTrailingMarker) {\n return;\n }\n\n const lastMessage = messages.lastElementChild;\n const penultimateMessage = lastMessage?.previousElementSibling;\n\n if (updatedContainerHeight === undefined) {\n updatedContainerHeight = container.getBoundingClientRect().height;\n }\n\n if (updatedFooterHeight === undefined) {\n updatedFooterHeight = footer.getBoundingClientRect().height;\n }\n\n if (updatedMessagesHeight === undefined) {\n updatedMessagesHeight = messages.getBoundingClientRect().height;\n }\n\n // If the heights haven't changed, there's no need to update the trailing space.\n if (\n updatedContainerHeight === containerHeight &&\n updatedFooterHeight === footerHeight &&\n updatedMessagesHeight === messagesHeight\n ) {\n if (\n !lastMessage ||\n !penultimateMessage ||\n container.scrollHeight === container.clientHeight\n ) {\n resetTrailingSpace();\n }\n return;\n }\n\n // Now that we have compared them, we can update the heights.\n containerHeight = updatedContainerHeight;\n footerHeight = updatedFooterHeight;\n messagesHeight = updatedMessagesHeight;\n\n // If there's no last pair of messages, there's no need for any trailing space.\n if (!lastMessage || !penultimateMessage) {\n resetTrailingSpace();\n return;\n }\n\n // If the container isn't scrollable, there's no need for trailing space.\n if (container.scrollHeight === container.clientHeight) {\n resetTrailingSpace();\n return;\n }\n\n // A\n const penultimateMessageScrollMarginTop = Number.parseFloat(\n getComputedStyle(penultimateMessage as HTMLElement).scrollMarginTop\n );\n\n // B\n const messagesRect = messages.getBoundingClientRect();\n const penultimateMessageRect =\n penultimateMessage.getBoundingClientRect();\n const heightFromPenultimateMessageTopToMessagesListBottom =\n messagesRect.bottom - penultimateMessageRect.top;\n\n // A + B + C\n const differenceHeight =\n penultimateMessageScrollMarginTop +\n heightFromPenultimateMessageTopToMessagesListBottom +\n (footerHeight ?? 0);\n\n // = container height - (A + B + C)\n const trailingSpace = Math.max(containerHeight - differenceHeight, 0);\n\n // Update the trailing space.\n trailingSpacer.style.height = `${trailingSpace}px`;\n\n // Offset what \"the bottom\" is to the \"scroll at the bottom\" detection logic,\n // so that it doesn't include the trailing space.\n bottomTrailingMarker.style.top = `${-trailingSpace}px`;\n };\n\n const resizeObserver = new ResizeObserver((entries) => {\n let updatedContainerHeight: number | undefined = containerHeight;\n let updatedFooterHeight: number | undefined = footerHeight;\n let updatedMessagesHeight: number | undefined = messagesHeight;\n\n for (const entry of entries) {\n const entryHeight =\n entry.borderBoxSize?.[0]?.blockSize ?? entry.contentRect.height;\n\n if (entry.target === container) {\n updatedContainerHeight = entryHeight;\n } else if (entry.target === footer) {\n updatedFooterHeight = entryHeight;\n } else if (entry.target === messages) {\n updatedMessagesHeight = entryHeight;\n }\n }\n\n updateTrailingSpace(\n updatedContainerHeight,\n updatedFooterHeight,\n updatedMessagesHeight\n );\n });\n\n resizeObserver.observe(container);\n resizeObserver.observe(footer);\n resizeObserver.observe(messages);\n\n // Initialize before the first resize.\n requestAnimationFrame(() => updateTrailingSpace());\n\n return () => {\n resizeObserver.disconnect();\n resetTrailingSpace();\n };\n },\n // This effect only uses stable refs.\n [hasLastSentMessage] // eslint-disable-line react-hooks/exhaustive-deps\n );\n\n /**\n * Update the \"scroll at bottom\" state when needed.\n */\n useIntersectionCallback(\n bottomTrailingMarkerRef,\n (isIntersecting) => {\n onScrollAtBottomChange.current(isIntersecting);\n },\n { root: containerRef, rootMargin: MIN_DISTANCE_BOTTOM_SCROLL_INDICATOR }\n );\n\n /**\n * Instantly scroll to the bottom for the initial state.\n */\n useEffect(\n () => {\n scrollToBottom.current(\"instant\");\n },\n // `scrollToBottom` is a stable ref containing the callback.\n [] // eslint-disable-line react-hooks/exhaustive-deps\n );\n\n /**\n * Scroll to new messages when sending them.\n */\n useEffect(\n () => {\n if (lastSentMessageId) {\n scrollToBottom.current(\"smooth\", true);\n }\n },\n // `scrollToBottom` is a stable ref containing the callback.\n [lastSentMessageId] // eslint-disable-line react-hooks/exhaustive-deps\n );\n\n /**\n * Reset the \"scroll at bottom\" state when the component unmounts.\n */\n useEffect(\n () => {\n const onScrollAtBottomChangeCallback = onScrollAtBottomChange.current;\n\n return () => {\n onScrollAtBottomChangeCallback(null);\n };\n },\n // `onScrollAtBottomChange` is a stable ref containing the callback.\n [] // eslint-disable-line react-hooks/exhaustive-deps\n );\n\n return (\n <div\n className={cn(\"lb-ai-chat-messages\", className)}\n ref={forwardedRef}\n {...props}\n >\n {messages.map((message) => {\n if (message.role === \"user\") {\n return (\n <AiChatUserMessage\n key={message.id}\n message={message}\n overrides={overrides}\n components={components}\n />\n );\n } else if (message.role === \"assistant\") {\n return (\n <AiChatAssistantMessage\n key={message.id}\n message={message}\n overrides={overrides}\n components={components}\n showReasoning={showReasoning}\n showRetrievals={showRetrievals}\n showSources={showSources}\n />\n );\n } else {\n return null;\n }\n })}\n </div>\n );\n }\n);\n\n// Call `Element.scrollIntoView()` unless the element is not displayed.\n// (with `display: none` or nested within elements with `display: none`)\n// https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView\n//\n// This avoids browser quirks where they still attempt to scroll to the\n// element but it results in a scroll to the document's top.\nfunction scrollIntoView(\n element: HTMLElement | null,\n options?: ScrollIntoViewOptions\n) {\n if (!element) {\n return;\n }\n\n // Checking for at least one client rect allows 0 width/height elements,\n // unlike checking if the width/height is 0 with `getBoundingClientRect`.\n if (element.getClientRects().length === 0) {\n return;\n }\n\n element.scrollIntoView(options);\n}\n\nexport const AiChat = forwardRef<HTMLDivElement, AiChatProps>(\n (\n {\n chatId,\n copilotId,\n autoFocus,\n overrides,\n knowledge: localKnowledge,\n tools = {},\n onComposerSubmit,\n layout = \"inset\",\n showReasoning,\n showRetrievals,\n showSources,\n components,\n className,\n responseTimeout,\n ...props\n },\n forwardedRef\n ) => {\n const { messages, isLoading, error } = useAiChatMessages(chatId);\n const [lastSentMessageId, setLastSentMessageId] =\n useState<MessageId | null>(null);\n\n const $ = useOverrides(overrides);\n const Empty = components?.Empty ?? defaultComponents.Empty;\n const Loading = components?.Loading ?? defaultComponents.Loading;\n\n const containerRef = useRef<HTMLDivElement | null>(null);\n const messagesRef = useRef<HTMLDivElement | null>(null);\n const footerRef = useRef<HTMLDivElement | null>(null);\n const bottomMarkerRef = useRef<HTMLDivElement | null>(null);\n const bottomTrailingMarkerRef = useRef<HTMLDivElement | null>(null);\n const trailingSpacerRef = useRef<HTMLDivElement | null>(null);\n\n const [isScrollAtBottom, setScrollAtBottom] = useState<boolean | null>(\n null\n );\n // `useState`'s setter is stable but this is for clarity in the places it's used.\n const onScrollAtBottomChange = useLatest(setScrollAtBottom);\n const isScrollIndicatorVisible =\n messages && isScrollAtBottom !== null ? !isScrollAtBottom : false;\n\n useImperativeHandle<HTMLDivElement | null, HTMLDivElement | null>(\n forwardedRef,\n () => containerRef.current,\n []\n );\n\n const scrollToBottom = useLatest(\n (behavior: \"instant\" | \"smooth\", includeTrailingSpace = false) => {\n if (includeTrailingSpace) {\n // Scroll to the bottom marker to include the trailing space,\n // but wait for the next tick in case the trailing space hasn't\n // been updated yet. (e.g. when sending a new message)\n setTimeout(() => {\n scrollIntoView(bottomMarkerRef.current, {\n behavior,\n block: \"end\",\n });\n }, 0);\n } else {\n // Scroll to the trailing space marker to only scroll to the\n // bottom of the messages, without including the trailing space.\n scrollIntoView(bottomTrailingMarkerRef.current, {\n behavior,\n block: \"end\",\n });\n }\n }\n );\n\n return (\n <div\n ref={containerRef}\n {...props}\n className={cn(\n \"lb-root lb-ai-chat\",\n `lb-ai-chat:layout-${layout}`,\n className\n )}\n >\n {Object.entries(tools).map(([name, tool]) => (\n <RegisterAiTool key={name} chatId={chatId} name={name} tool={tool} />\n ))}\n\n {localKnowledge\n ? localKnowledge.map((knowledge, index) => (\n <RegisterAiKnowledge\n key={`${index}:${knowledge.description}`}\n chatId={chatId}\n {...knowledge}\n />\n ))\n : null}\n\n <div className=\"lb-ai-chat-content\">\n {isLoading ? (\n <Loading />\n ) : error !== undefined ? (\n <div className=\"lb-error lb-ai-chat-error\">\n {$.AI_CHAT_MESSAGES_ERROR(error)}\n </div>\n ) : messages.length === 0 ? (\n <Empty chatId={chatId} copilotId={copilotId} />\n ) : (\n <>\n <AiChatMessages\n messages={messages}\n overrides={overrides}\n components={components}\n showReasoning={showReasoning}\n showRetrievals={showRetrievals}\n showSources={showSources}\n lastSentMessageId={lastSentMessageId}\n scrollToBottom={scrollToBottom}\n onScrollAtBottomChange={onScrollAtBottomChange}\n containerRef={containerRef}\n footerRef={footerRef}\n messagesRef={messagesRef}\n bottomTrailingMarkerRef={bottomTrailingMarkerRef}\n trailingSpacerRef={trailingSpacerRef}\n ref={forwardedRef}\n />\n\n {/**\n * This trailing spacer is used to extend the scrollable area beyond its actual\n * content, to allow messages to appear at the top of the viewport for example.\n */}\n <div\n ref={trailingSpacerRef}\n data-trailing-spacer=\"\"\n style={{\n pointerEvents: \"none\",\n height: 0,\n }}\n aria-hidden\n />\n </>\n )}\n </div>\n\n <div className=\"lb-ai-chat-footer\" ref={footerRef}>\n <div className=\"lb-ai-chat-footer-actions\">\n <div\n className=\"lb-root lb-elevation lb-elevation-moderate lb-ai-chat-scroll-indicator\"\n data-visible={isScrollIndicatorVisible ? \"\" : undefined}\n >\n <button\n className=\"lb-ai-chat-scroll-indicator-button\"\n tabIndex={isScrollIndicatorVisible ? 0 : -1}\n aria-hidden={!isScrollIndicatorVisible}\n onClick={() => scrollToBottom.current(\"smooth\")}\n >\n <span className=\"lb-icon-container\">\n <ArrowDownIcon />\n </span>\n </button>\n </div>\n </div>\n <AiComposer\n key={chatId}\n chatId={chatId}\n copilotId={copilotId as CopilotId}\n overrides={overrides}\n autoFocus={autoFocus}\n responseTimeout={responseTimeout}\n onComposerSubmit={onComposerSubmit}\n onComposerSubmitted={({ id }) => setLastSentMessageId(id)}\n className={cn(\n \"lb-ai-chat-composer\",\n layout === \"inset\"\n ? \"lb-elevation lb-elevation-moderate\"\n : undefined\n )}\n />\n </div>\n\n {/**\n * This invisible marker is a trick which allows us to use IntersectionObserver to detect when the\n * scrollable area is fully scrolled to the bottom instead of manually tracking the scroll position\n * and having to deal with resizes, etc.\n *\n * It's positioned at the bottom of the scrollable area and reliably only becomes \"visible\" to the\n * IntersectionObserver when the scrollable area is scrolled to the bottom.\n */}\n {messages && messages.length > 0 ? (\n <div\n ref={bottomMarkerRef}\n style={{ position: \"sticky\", height: 0 }}\n aria-hidden\n data-bottom-marker=\"\"\n >\n {/**\n * This inner marker is absolutely offset by the same distance as the trailing space so its\n * visibility means the scrollable area is at the bottom of the messages, not the full bottom.\n */}\n <div\n ref={bottomTrailingMarkerRef}\n style={{\n position: \"absolute\",\n height: 0,\n }}\n data-bottom-trailing-marker=\"\"\n />\n </div>\n ) : null}\n </div>\n );\n }\n);\n"],"names":["messages"],"mappings":";;;;;;;;;;;;;AA+CA,MAAM,oCAAuC,GAAA,EAAA,CAAA;AAiI7C,MAAM,iBAAsC,GAAA;AAAA,EAC1C,OAAO,MAAM,IAAA;AAAA,EACb,OAAA,EAAS,sBACN,GAAA,CAAA,KAAA,EAAA,EAAI,WAAU,+BACb,EAAA,QAAA,kBAAA,GAAA,CAAC,eAAY,CACf,EAAA,CAAA;AAEJ,CAAA,CAAA;AAEA,MAAM,cAAiB,GAAA,UAAA;AAAA,EACrB,CACE;AAAA,IACE,QAAA;AAAA,IACA,SAAA;AAAA,IACA,UAAA;AAAA,IACA,aAAA;AAAA,IACA,cAAA;AAAA,IACA,WAAA;AAAA,IACA,iBAAA;AAAA,IACA,cAAA;AAAA,IACA,sBAAA;AAAA,IACA,YAAA;AAAA,IACA,SAAA;AAAA,IACA,WAAA;AAAA,IACA,uBAAA;AAAA,IACA,iBAAA;AAAA,IACA,SAAA;AAAA,IACA,GAAG,KAAA;AAAA,KAEL,YACG,KAAA;AACH,IAAA,MAAM,qBAAqB,iBAAsB,KAAA,IAAA,CAAA;AA2BjD,IAAA,SAAA;AAAA,MACE,MAAM;AACJ,QAAA,IAAI,CAAC,kBAAoB,EAAA;AACvB,UAAA,OAAA;AAAA,SACF;AAEA,QAAA,MAAM,YAAY,YAAa,CAAA,OAAA,CAAA;AAC/B,QAAA,MAAM,SAAS,SAAU,CAAA,OAAA,CAAA;AACzB,QAAA,MAAMA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,WAEA,GAAA,IAAA;AAAA,SAAA;AAAA,OAAA;AAAA,KACN,CAAA;AAAA,GAEJ;AACF;;;;"}
1
+ {"version":3,"file":"AiChat.js","sources":["../../src/components/AiChat.tsx"],"sourcesContent":["import type {\n AiKnowledgeSource,\n AiOpaqueToolDefinition,\n CopilotId,\n MessageId,\n} from \"@liveblocks/core\";\nimport {\n RegisterAiKnowledge,\n RegisterAiTool,\n useAiChatMessages,\n} from \"@liveblocks/react\";\nimport { useLatest } from \"@liveblocks/react/_private\";\nimport {\n type ComponentProps,\n type ComponentType,\n forwardRef,\n type MutableRefObject,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from \"react\";\n\nimport { useStableComponent } from \"../_private\";\nimport type { GlobalComponents } from \"../components\";\nimport { ArrowDownIcon } from \"../icons/ArrowDown\";\nimport { SpinnerIcon } from \"../icons/Spinner\";\nimport {\n type AiChatMessageOverrides,\n type AiChatOverrides,\n type AiComposerOverrides,\n type GlobalOverrides,\n useOverrides,\n} from \"../overrides\";\nimport type { MarkdownComponents } from \"../primitives/Markdown\";\nimport { cn } from \"../utils/cn\";\nimport { useIntersectionCallback } from \"../utils/use-visible\";\nimport {\n AiChatAssistantMessage,\n type AiChatAssistantMessageProps,\n} from \"./internal/AiChatAssistantMessage\";\nimport { AiChatUserMessage } from \"./internal/AiChatUserMessage\";\nimport { AiComposer, type AiComposerProps } from \"./internal/AiComposer\";\n\n/**\n * The minimum number of pixels from the bottom of the scrollable area\n * before showing the scroll to bottom indicator.\n */\nconst MIN_DISTANCE_BOTTOM_SCROLL_INDICATOR = 60;\n\nexport type AiChatComponentsEmptyProps = {\n /**\n * The chat ID provided to the `AiChat` component.\n */\n chatId: string;\n\n /**\n * The copilot ID provided to the `AiChat` component.\n */\n copilotId?: string;\n};\n\nexport type AiChatComponentsLoadingProps = Record<string, never>;\n\nexport type AiChatComponents = {\n /**\n * The component used to render the empty state of the chat.\n */\n Empty: ComponentType<AiChatComponentsEmptyProps>;\n\n /**\n * The component used to render the loading state of the chat.\n */\n Loading: ComponentType<AiChatComponentsLoadingProps>;\n\n /**\n * The components used to render Markdown content.\n */\n markdown?: Partial<MarkdownComponents>;\n};\n\nexport interface AiChatProps extends ComponentProps<\"div\"> {\n /**\n * The ID of the chat the composer belongs to.\n */\n chatId: string;\n\n /**\n * Whether to focus the chat composer on mount.\n */\n autoFocus?: boolean;\n\n /**\n * The ID of the copilot to use to send the message.\n */\n copilotId?: string;\n\n /**\n * The contextual knowledge to include in the chat. May be used by the\n * assistant when generating responses. In addition to the knowledge passed\n * in via this prop, the AiChat instance will also have access to any\n * globally registered knowledge via <RegisterAiKnowledge />.\n */\n knowledge?: AiKnowledgeSource[];\n\n /**\n * Tool definitions to make available within this chat. May be used by the assistant when generating responses.\n */\n tools?: Record<string, AiOpaqueToolDefinition>;\n\n /**\n * The event handler called when the composer is submitted.\n */\n onComposerSubmit?: AiComposerProps[\"onComposerSubmit\"];\n\n /**\n * The layout of the chat and its composer.\n */\n layout?: \"inset\" | \"compact\";\n\n /**\n * How to show or hide reasoning.\n */\n showReasoning?: AiChatAssistantMessageProps[\"showReasoning\"];\n\n /**\n * How to show or hide retrievals.\n */\n showRetrievals?: AiChatAssistantMessageProps[\"showRetrievals\"];\n\n /**\n * Whether to show sources\n */\n showSources?: AiChatAssistantMessageProps[\"showSources\"];\n\n /**\n * The time, in milliseconds, before an AI response will timeout.\n */\n responseTimeout?: number;\n\n /**\n * Override the component's strings.\n */\n overrides?: Partial<\n GlobalOverrides &\n AiComposerOverrides &\n AiChatMessageOverrides &\n AiChatOverrides\n >;\n\n /**\n * Override the component's components.\n */\n components?: Partial<GlobalComponents & AiChatComponents>;\n}\n\ninterface AiChatMessagesProps extends ComponentProps<\"div\"> {\n messages: NonNullable<ReturnType<typeof useAiChatMessages>[\"messages\"]>;\n overrides: AiChatProps[\"overrides\"];\n components: AiChatProps[\"components\"];\n showReasoning: AiChatProps[\"showReasoning\"];\n showRetrievals: AiChatProps[\"showRetrievals\"];\n showSources: AiChatProps[\"showSources\"];\n lastSentMessageId: MessageId | null;\n scrollToBottom: MutableRefObject<\n (behavior: \"instant\" | \"smooth\", includeTrailingSpace?: boolean) => void\n >;\n onScrollAtBottomChange: MutableRefObject<\n (isScrollAtBottom: boolean | null) => void\n >;\n containerRef: MutableRefObject<HTMLDivElement | null>;\n footerRef: MutableRefObject<HTMLDivElement | null>;\n messagesRef: MutableRefObject<HTMLDivElement | null>;\n bottomTrailingMarkerRef: MutableRefObject<HTMLDivElement | null>;\n trailingSpacerRef: MutableRefObject<HTMLDivElement | null>;\n}\n\nconst defaultComponents: AiChatComponents = {\n Empty: () => null,\n Loading: () => (\n <div className=\"lb-loading lb-ai-chat-loading\">\n <SpinnerIcon />\n </div>\n ),\n};\n\nconst AiChatMessages = forwardRef<HTMLDivElement, AiChatMessagesProps>(\n (\n {\n messages,\n overrides,\n components,\n showReasoning,\n showRetrievals,\n showSources,\n lastSentMessageId,\n scrollToBottom,\n onScrollAtBottomChange,\n containerRef,\n footerRef,\n messagesRef,\n bottomTrailingMarkerRef,\n trailingSpacerRef,\n className,\n ...props\n },\n forwardedRef\n ) => {\n const hasLastSentMessage = lastSentMessageId !== null;\n\n /**\n * Every time the container, footer, or messages list change size,\n * we calculate the trailing space that would allow the penultimate\n * message to be at the top of the viewport, and apply it.\n *\n * ┌─────────────────────────────────────────┐▲ A = The `scroll-margin-top`\n * │ ┌─────────────────────────┐ │▼▲ value of the penultimate message\n * │ │ The penultimate message │ │ │\n * │ └─────────────────────────┘ │ │ B = The height from the top of\n * │ │ │ the penultimate message to the\n * │ ┌─────────────────────────┐ │ │ bottom of the messages list,\n * │ │ The last message │ │ │ including the messages' heights,\n * │ └─────────────────────────┘ │ │ and any padding, gap, etc\n * │ │ │\n * ├ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┤▲▼\n * │ ││ The trailing space needed to\n * │ = container height - (A + B + C) ││ allow the penultimate message\n * │ ││ to be at the top of the viewport\n * ├ ┬─────────────────────────────────────┬ ┤▼▲\n * │ │ │ │ │\n * │ │ │ │ │ C = The footer's height,\n * │ │ │ │ │ including any padding\n * │ └─────────────────────────────────────┘ │ │\n * └─────────────────────────────────────────┘ ▼\n */\n useEffect(\n () => {\n if (!hasLastSentMessage) {\n return;\n }\n\n const container = containerRef.current;\n const footer = footerRef.current;\n const messages = messagesRef.current;\n\n if (!container || !footer || !messages) {\n return;\n }\n\n const trailingSpacer = trailingSpacerRef.current;\n const bottomTrailingMarker = bottomTrailingMarkerRef.current;\n\n let containerHeight: number | undefined = undefined;\n let footerHeight: number | undefined = undefined;\n let messagesHeight: number | undefined = undefined;\n\n const resetTrailingSpace = () => {\n trailingSpacer?.style.removeProperty(\"height\");\n bottomTrailingMarker?.style.removeProperty(\"top\");\n };\n\n const updateTrailingSpace = (\n updatedContainerHeight?: number,\n updatedFooterHeight?: number,\n updatedMessagesHeight?: number\n ) => {\n if (!trailingSpacer || !bottomTrailingMarker) {\n return;\n }\n\n const lastMessage = messages.lastElementChild;\n const penultimateMessage = lastMessage?.previousElementSibling;\n\n if (updatedContainerHeight === undefined) {\n updatedContainerHeight = container.getBoundingClientRect().height;\n }\n\n if (updatedFooterHeight === undefined) {\n updatedFooterHeight = footer.getBoundingClientRect().height;\n }\n\n if (updatedMessagesHeight === undefined) {\n updatedMessagesHeight = messages.getBoundingClientRect().height;\n }\n\n // If the heights haven't changed, there's no need to update the trailing space.\n if (\n updatedContainerHeight === containerHeight &&\n updatedFooterHeight === footerHeight &&\n updatedMessagesHeight === messagesHeight\n ) {\n if (\n !lastMessage ||\n !penultimateMessage ||\n container.scrollHeight === container.clientHeight\n ) {\n resetTrailingSpace();\n }\n return;\n }\n\n // Now that we have compared them, we can update the heights.\n containerHeight = updatedContainerHeight;\n footerHeight = updatedFooterHeight;\n messagesHeight = updatedMessagesHeight;\n\n // If there's no last pair of messages, there's no need for any trailing space.\n if (!lastMessage || !penultimateMessage) {\n resetTrailingSpace();\n return;\n }\n\n // If the container isn't scrollable, there's no need for trailing space.\n if (container.scrollHeight === container.clientHeight) {\n resetTrailingSpace();\n return;\n }\n\n // A\n const penultimateMessageScrollMarginTop = Number.parseFloat(\n getComputedStyle(penultimateMessage as HTMLElement).scrollMarginTop\n );\n\n // B\n const messagesRect = messages.getBoundingClientRect();\n const penultimateMessageRect =\n penultimateMessage.getBoundingClientRect();\n const heightFromPenultimateMessageTopToMessagesListBottom =\n messagesRect.bottom - penultimateMessageRect.top;\n\n // A + B + C\n const differenceHeight =\n penultimateMessageScrollMarginTop +\n heightFromPenultimateMessageTopToMessagesListBottom +\n (footerHeight ?? 0);\n\n // = container height - (A + B + C)\n const trailingSpace = Math.max(containerHeight - differenceHeight, 0);\n\n // Update the trailing space.\n trailingSpacer.style.height = `${trailingSpace}px`;\n\n // Offset what \"the bottom\" is to the \"scroll at the bottom\" detection logic,\n // so that it doesn't include the trailing space.\n bottomTrailingMarker.style.top = `${-trailingSpace}px`;\n };\n\n const resizeObserver = new ResizeObserver((entries) => {\n let updatedContainerHeight: number | undefined = containerHeight;\n let updatedFooterHeight: number | undefined = footerHeight;\n let updatedMessagesHeight: number | undefined = messagesHeight;\n\n for (const entry of entries) {\n const entryHeight =\n entry.borderBoxSize?.[0]?.blockSize ?? entry.contentRect.height;\n\n if (entry.target === container) {\n updatedContainerHeight = entryHeight;\n } else if (entry.target === footer) {\n updatedFooterHeight = entryHeight;\n } else if (entry.target === messages) {\n updatedMessagesHeight = entryHeight;\n }\n }\n\n updateTrailingSpace(\n updatedContainerHeight,\n updatedFooterHeight,\n updatedMessagesHeight\n );\n });\n\n resizeObserver.observe(container);\n resizeObserver.observe(footer);\n resizeObserver.observe(messages);\n\n // Initialize before the first resize.\n requestAnimationFrame(() => updateTrailingSpace());\n\n return () => {\n resizeObserver.disconnect();\n resetTrailingSpace();\n };\n },\n // This effect only uses stable refs.\n [hasLastSentMessage] // eslint-disable-line react-hooks/exhaustive-deps\n );\n\n /**\n * Update the \"scroll at bottom\" state when needed.\n */\n useIntersectionCallback(\n bottomTrailingMarkerRef,\n (isIntersecting) => {\n onScrollAtBottomChange.current(isIntersecting);\n },\n { root: containerRef, rootMargin: MIN_DISTANCE_BOTTOM_SCROLL_INDICATOR }\n );\n\n /**\n * Instantly scroll to the bottom for the initial state.\n */\n useEffect(\n () => {\n scrollToBottom.current(\"instant\");\n },\n // `scrollToBottom` is a stable ref containing the callback.\n [] // eslint-disable-line react-hooks/exhaustive-deps\n );\n\n /**\n * Scroll to new messages when sending them.\n */\n useEffect(\n () => {\n if (lastSentMessageId) {\n scrollToBottom.current(\"smooth\", true);\n }\n },\n // `scrollToBottom` is a stable ref containing the callback.\n [lastSentMessageId] // eslint-disable-line react-hooks/exhaustive-deps\n );\n\n /**\n * Reset the \"scroll at bottom\" state when the component unmounts.\n */\n useEffect(\n () => {\n const onScrollAtBottomChangeCallback = onScrollAtBottomChange.current;\n\n return () => {\n onScrollAtBottomChangeCallback(null);\n };\n },\n // `onScrollAtBottomChange` is a stable ref containing the callback.\n [] // eslint-disable-line react-hooks/exhaustive-deps\n );\n\n return (\n <div\n className={cn(\"lb-ai-chat-messages\", className)}\n ref={forwardedRef}\n {...props}\n >\n {messages.map((message) => {\n if (message.role === \"user\") {\n return (\n <AiChatUserMessage\n key={message.id}\n message={message}\n overrides={overrides}\n components={components}\n />\n );\n } else if (message.role === \"assistant\") {\n return (\n <AiChatAssistantMessage\n key={message.id}\n message={message}\n overrides={overrides}\n components={components}\n showReasoning={showReasoning}\n showRetrievals={showRetrievals}\n showSources={showSources}\n />\n );\n } else {\n return null;\n }\n })}\n </div>\n );\n }\n);\n\n// Call `Element.scrollIntoView()` unless the element is not displayed.\n// (with `display: none` or nested within elements with `display: none`)\n// https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView\n//\n// This avoids browser quirks where they still attempt to scroll to the\n// element but it results in a scroll to the document's top.\nfunction scrollIntoView(\n element: HTMLElement | null,\n options?: ScrollIntoViewOptions\n) {\n if (!element) {\n return;\n }\n\n // Checking for at least one client rect allows 0 width/height elements,\n // unlike checking if the width/height is 0 with `getBoundingClientRect`.\n if (element.getClientRects().length === 0) {\n return;\n }\n\n element.scrollIntoView(options);\n}\n\nexport const AiChat = forwardRef<HTMLDivElement, AiChatProps>(\n (\n {\n chatId,\n copilotId,\n autoFocus,\n overrides,\n knowledge: localKnowledge,\n tools = {},\n onComposerSubmit,\n layout = \"inset\",\n showReasoning,\n showRetrievals,\n showSources,\n components,\n className,\n responseTimeout,\n ...props\n },\n forwardedRef\n ) => {\n const { messages, isLoading, error } = useAiChatMessages(chatId);\n const [lastSentMessageId, setLastSentMessageId] =\n useState<MessageId | null>(null);\n\n const $ = useOverrides(overrides);\n const Empty = useStableComponent(\n components?.Empty,\n defaultComponents.Empty\n );\n const Loading = useStableComponent(\n components?.Loading,\n defaultComponents.Loading\n );\n\n const containerRef = useRef<HTMLDivElement | null>(null);\n const messagesRef = useRef<HTMLDivElement | null>(null);\n const footerRef = useRef<HTMLDivElement | null>(null);\n const bottomMarkerRef = useRef<HTMLDivElement | null>(null);\n const bottomTrailingMarkerRef = useRef<HTMLDivElement | null>(null);\n const trailingSpacerRef = useRef<HTMLDivElement | null>(null);\n\n const [isScrollAtBottom, setScrollAtBottom] = useState<boolean | null>(\n null\n );\n // `useState`'s setter is stable but this is for clarity in the places it's used.\n const onScrollAtBottomChange = useLatest(setScrollAtBottom);\n const isScrollIndicatorVisible =\n messages && isScrollAtBottom !== null ? !isScrollAtBottom : false;\n\n useImperativeHandle<HTMLDivElement | null, HTMLDivElement | null>(\n forwardedRef,\n () => containerRef.current,\n []\n );\n\n const scrollToBottom = useLatest(\n (behavior: \"instant\" | \"smooth\", includeTrailingSpace = false) => {\n if (includeTrailingSpace) {\n // Scroll to the bottom marker to include the trailing space,\n // but wait for the next tick in case the trailing space hasn't\n // been updated yet. (e.g. when sending a new message)\n setTimeout(() => {\n scrollIntoView(bottomMarkerRef.current, {\n behavior,\n block: \"end\",\n });\n }, 0);\n } else {\n // Scroll to the trailing space marker to only scroll to the\n // bottom of the messages, without including the trailing space.\n scrollIntoView(bottomTrailingMarkerRef.current, {\n behavior,\n block: \"end\",\n });\n }\n }\n );\n\n return (\n <div\n ref={containerRef}\n {...props}\n className={cn(\n \"lb-root lb-ai-chat\",\n `lb-ai-chat:layout-${layout}`,\n className\n )}\n >\n {Object.entries(tools).map(([name, tool]) => (\n <RegisterAiTool key={name} chatId={chatId} name={name} tool={tool} />\n ))}\n\n {localKnowledge\n ? localKnowledge.map((knowledge, index) => (\n <RegisterAiKnowledge\n key={`${index}:${knowledge.description}`}\n chatId={chatId}\n {...knowledge}\n />\n ))\n : null}\n\n <div className=\"lb-ai-chat-content\">\n {isLoading ? (\n <Loading />\n ) : error !== undefined ? (\n <div className=\"lb-error lb-ai-chat-error\">\n {$.AI_CHAT_MESSAGES_ERROR(error)}\n </div>\n ) : messages.length === 0 ? (\n <Empty chatId={chatId} copilotId={copilotId} />\n ) : (\n <>\n <AiChatMessages\n messages={messages}\n overrides={overrides}\n components={components}\n showReasoning={showReasoning}\n showRetrievals={showRetrievals}\n showSources={showSources}\n lastSentMessageId={lastSentMessageId}\n scrollToBottom={scrollToBottom}\n onScrollAtBottomChange={onScrollAtBottomChange}\n containerRef={containerRef}\n footerRef={footerRef}\n messagesRef={messagesRef}\n bottomTrailingMarkerRef={bottomTrailingMarkerRef}\n trailingSpacerRef={trailingSpacerRef}\n ref={forwardedRef}\n />\n\n {/**\n * This trailing spacer is used to extend the scrollable area beyond its actual\n * content, to allow messages to appear at the top of the viewport for example.\n */}\n <div\n ref={trailingSpacerRef}\n data-trailing-spacer=\"\"\n style={{\n pointerEvents: \"none\",\n height: 0,\n }}\n aria-hidden\n />\n </>\n )}\n </div>\n\n <div className=\"lb-ai-chat-footer\" ref={footerRef}>\n <div className=\"lb-ai-chat-footer-actions\">\n <div\n className=\"lb-root lb-elevation lb-elevation-moderate lb-ai-chat-scroll-indicator\"\n data-visible={isScrollIndicatorVisible ? \"\" : undefined}\n >\n <button\n className=\"lb-ai-chat-scroll-indicator-button\"\n tabIndex={isScrollIndicatorVisible ? 0 : -1}\n aria-hidden={!isScrollIndicatorVisible}\n onClick={() => scrollToBottom.current(\"smooth\")}\n >\n <span className=\"lb-icon-container\">\n <ArrowDownIcon />\n </span>\n </button>\n </div>\n </div>\n <AiComposer\n key={chatId}\n chatId={chatId}\n copilotId={copilotId as CopilotId}\n overrides={overrides}\n autoFocus={autoFocus}\n responseTimeout={responseTimeout}\n onComposerSubmit={onComposerSubmit}\n onComposerSubmitted={({ id }) => setLastSentMessageId(id)}\n className={cn(\n \"lb-ai-chat-composer\",\n layout === \"inset\"\n ? \"lb-elevation lb-elevation-moderate\"\n : undefined\n )}\n />\n </div>\n\n {/**\n * This invisible marker is a trick which allows us to use IntersectionObserver to detect when the\n * scrollable area is fully scrolled to the bottom instead of manually tracking the scroll position\n * and having to deal with resizes, etc.\n *\n * It's positioned at the bottom of the scrollable area and reliably only becomes \"visible\" to the\n * IntersectionObserver when the scrollable area is scrolled to the bottom.\n */}\n {messages && messages.length > 0 ? (\n <div\n ref={bottomMarkerRef}\n style={{ position: \"sticky\", height: 0 }}\n aria-hidden\n data-bottom-marker=\"\"\n >\n {/**\n * This inner marker is absolutely offset by the same distance as the trailing space so its\n * visibility means the scrollable area is at the bottom of the messages, not the full bottom.\n */}\n <div\n ref={bottomTrailingMarkerRef}\n style={{\n position: \"absolute\",\n height: 0,\n }}\n data-bottom-trailing-marker=\"\"\n />\n </div>\n ) : null}\n </div>\n );\n }\n);\n"],"names":["messages"],"mappings":";;;;;;;;;;;;;;;AAgDA,MAAM,oCAAuC,GAAA,EAAA,CAAA;AAiI7C,MAAM,iBAAsC,GAAA;AAAA,EAC1C,OAAO,MAAM,IAAA;AAAA,EACb,OAAA,EAAS,sBACN,GAAA,CAAA,KAAA,EAAA,EAAI,WAAU,+BACb,EAAA,QAAA,kBAAA,GAAA,CAAC,eAAY,CACf,EAAA,CAAA;AAEJ,CAAA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