@carbon/ai-chat-components 1.13.0 → 1.14.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (206) hide show
  1. package/custom-elements.json +1147 -462
  2. package/es/components/audio-player/src/audio-player.scss.js +1 -1
  3. package/es/components/audio-player/src/transcript.js +15 -0
  4. package/es/components/audio-player/src/transcript.js.map +1 -1
  5. package/es/components/card/src/card-footer.scss.js +1 -1
  6. package/es/components/card/src/card-steps.scss.js +1 -1
  7. package/es/components/card/src/card.scss.js +1 -1
  8. package/es/components/chat-button/src/chat-button.scss.js +1 -1
  9. package/es/components/chat-history/src/chat-history.scss.js +1 -1
  10. package/es/components/chat-history/src/history-header.js +1 -0
  11. package/es/components/chat-history/src/history-header.js.map +1 -1
  12. package/es/components/chat-history/src/history-toolbar.js +4 -1
  13. package/es/components/chat-history/src/history-toolbar.js.map +1 -1
  14. package/es/components/chat-shell/src/shell.scss.js +1 -1
  15. package/es/components/code-snippet/src/code-snippet.d.ts +3 -2
  16. package/es/components/code-snippet/src/code-snippet.js +4 -3
  17. package/es/components/code-snippet/src/code-snippet.js.map +1 -1
  18. package/es/components/code-snippet/src/code-snippet.scss.js +1 -1
  19. package/es/components/feedback/src/feedback.js +17 -3
  20. package/es/components/feedback/src/feedback.js.map +1 -1
  21. package/es/components/file-uploads/src/file-upload-item.scss.js +1 -1
  22. package/es/components/file-uploads/src/file-uploads.scss.js +1 -1
  23. package/es/components/launcher/src/launcher.scss.js +1 -1
  24. package/es/components/markdown/__tests__/inline-selection-fixture.d.ts +13 -0
  25. package/es/components/markdown/index.d.ts +2 -0
  26. package/es/components/markdown/index.js +3 -0
  27. package/es/components/markdown/index.js.map +1 -1
  28. package/es/components/markdown/src/inline-markdown.d.ts +41 -0
  29. package/es/components/markdown/src/inline-markdown.js +92 -0
  30. package/es/components/markdown/src/inline-markdown.js.map +1 -0
  31. package/es/components/markdown/src/inline-markdown.scss.js +13 -0
  32. package/es/components/markdown/src/inline-markdown.scss.js.map +1 -0
  33. package/es/components/markdown/src/inline-run-projection.scss.js +13 -0
  34. package/es/components/markdown/src/inline-run-projection.scss.js.map +1 -0
  35. package/es/components/markdown/src/markdown-renderer-types.d.ts +132 -0
  36. package/es/components/markdown/src/markdown-renderer.js +131 -25
  37. package/es/components/markdown/src/markdown-renderer.js.map +1 -1
  38. package/es/components/markdown/src/markdown.js +1 -0
  39. package/es/components/markdown/src/markdown.js.map +1 -1
  40. package/es/components/markdown/src/markdown.scss.js +1 -1
  41. package/es/components/markdown/src/utils/inline-run-projection.d.ts +15 -0
  42. package/es/components/markdown/src/utils/inline-run-projection.js +196 -0
  43. package/es/components/markdown/src/utils/inline-run-projection.js.map +1 -0
  44. package/es/components/markdown/src/utils/inline-validation.d.ts +13 -0
  45. package/es/components/markdown/src/utils/inline-validation.js +97 -0
  46. package/es/components/markdown/src/utils/inline-validation.js.map +1 -0
  47. package/es/components/markdown/src/utils/plugin-fallback.js +20 -13
  48. package/es/components/markdown/src/utils/plugin-fallback.js.map +1 -1
  49. package/es/components/markdown/src/utils/plugin-host-container.d.ts +5 -6
  50. package/es/components/markdown/src/utils/plugin-host-container.js.map +1 -1
  51. package/es/components/messages-shell/index.d.ts +11 -0
  52. package/es/components/messages-shell/index.js +9 -0
  53. package/es/components/messages-shell/index.js.map +1 -0
  54. package/es/components/messages-shell/src/messages-shell.d.ts +57 -0
  55. package/es/components/messages-shell/src/messages-shell.js +141 -0
  56. package/es/components/messages-shell/src/messages-shell.js.map +1 -0
  57. package/es/components/messages-shell/src/messages-shell.scss.js +13 -0
  58. package/es/components/messages-shell/src/messages-shell.scss.js.map +1 -0
  59. package/es/components/processing/src/processing.scss.js +1 -1
  60. package/es/components/prompt-line/autocomplete/src/autocomplete.d.ts +26 -9
  61. package/es/components/prompt-line/autocomplete/src/autocomplete.js +116 -107
  62. package/es/components/prompt-line/autocomplete/src/autocomplete.js.map +1 -1
  63. package/es/components/prompt-line/autocomplete/src/autocomplete.scss.js +1 -1
  64. package/es/components/prompt-line/src/autocomplete-controller-element.js +13 -1
  65. package/es/components/prompt-line/src/autocomplete-controller-element.js.map +1 -1
  66. package/es/components/prompt-line/src/autocomplete-controller.js +9 -2
  67. package/es/components/prompt-line/src/autocomplete-controller.js.map +1 -1
  68. package/es/components/prompt-line/src/prompt-line-controller.d.ts +7 -0
  69. package/es/components/prompt-line/src/prompt-line-rich-runtime.js +17 -0
  70. package/es/components/prompt-line/src/prompt-line-rich-runtime.js.map +1 -1
  71. package/es/components/prompt-line/src/prompt-line-shell.scss.js +1 -1
  72. package/es/components/prompt-line/src/prompt-line-textarea-runtime.d.ts +1 -0
  73. package/es/components/prompt-line/src/prompt-line-textarea-runtime.js +3 -0
  74. package/es/components/prompt-line/src/prompt-line-textarea-runtime.js.map +1 -1
  75. package/es/components/prompt-line/src/prompt-line.d.ts +7 -0
  76. package/es/components/prompt-line/src/prompt-line.js +9 -0
  77. package/es/components/prompt-line/src/prompt-line.js.map +1 -1
  78. package/es/components/prompt-line/src/send-control.scss.js +1 -1
  79. package/es/components/prompt-line/src/stop-streaming-button.scss.js +1 -1
  80. package/es/components/prompt-line/src/tiptap/carbon-mention.js +43 -21
  81. package/es/components/prompt-line/src/tiptap/carbon-mention.js.map +1 -1
  82. package/es/components/prompt-line/src/tiptap/plain-text-paste.js +8 -3
  83. package/es/components/prompt-line/src/tiptap/plain-text-paste.js.map +1 -1
  84. package/es/components/prompt-line/src/tiptap/strip-presentation-fields.d.ts +3 -3
  85. package/es/components/prompt-line/src/tiptap/strip-presentation-fields.js.map +1 -1
  86. package/es/components/prompt-line/src/tiptap/types.d.ts +27 -11
  87. package/es/components/reasoning-steps/src/reasoning-step.d.ts +3 -3
  88. package/es/components/reasoning-steps/src/reasoning-step.js +4 -4
  89. package/es/components/reasoning-steps/src/reasoning-step.js.map +1 -1
  90. package/es/components/reasoning-steps/src/reasoning-step.scss.js +1 -1
  91. package/es/components/reasoning-steps/src/reasoning-steps-toggle.scss.js +1 -1
  92. package/es/components/reasoning-steps/src/reasoning-steps.d.ts +5 -4
  93. package/es/components/reasoning-steps/src/reasoning-steps.js +5 -4
  94. package/es/components/reasoning-steps/src/reasoning-steps.js.map +1 -1
  95. package/es/components/truncated-text/src/truncated-text.scss.js +1 -1
  96. package/es/components/video-player/src/video-player.scss.js +1 -1
  97. package/es/globals/scss/common.scss.js +1 -1
  98. package/es/react/hooks/useChatAutocomplete.js +7 -1
  99. package/es/react/hooks/useChatAutocomplete.js.map +1 -1
  100. package/es/react/messages-shell.d.ts +3 -0
  101. package/es/react/messages-shell.js +32 -0
  102. package/es/react/messages-shell.js.map +1 -0
  103. package/es-custom/components/audio-player/src/audio-player.scss.js +1 -1
  104. package/es-custom/components/audio-player/src/transcript.js +15 -0
  105. package/es-custom/components/audio-player/src/transcript.js.map +1 -1
  106. package/es-custom/components/card/src/card-footer.scss.js +1 -1
  107. package/es-custom/components/card/src/card-steps.scss.js +1 -1
  108. package/es-custom/components/card/src/card.scss.js +1 -1
  109. package/es-custom/components/chat-button/src/chat-button.scss.js +1 -1
  110. package/es-custom/components/chat-history/src/chat-history.scss.js +1 -1
  111. package/es-custom/components/chat-history/src/history-header.js +1 -0
  112. package/es-custom/components/chat-history/src/history-header.js.map +1 -1
  113. package/es-custom/components/chat-history/src/history-toolbar.js +4 -1
  114. package/es-custom/components/chat-history/src/history-toolbar.js.map +1 -1
  115. package/es-custom/components/chat-shell/src/shell.scss.js +1 -1
  116. package/es-custom/components/code-snippet/src/code-snippet.d.ts +3 -2
  117. package/es-custom/components/code-snippet/src/code-snippet.js +4 -3
  118. package/es-custom/components/code-snippet/src/code-snippet.js.map +1 -1
  119. package/es-custom/components/code-snippet/src/code-snippet.scss.js +1 -1
  120. package/es-custom/components/feedback/src/feedback.js +17 -3
  121. package/es-custom/components/feedback/src/feedback.js.map +1 -1
  122. package/es-custom/components/file-uploads/src/file-upload-item.scss.js +1 -1
  123. package/es-custom/components/file-uploads/src/file-uploads.scss.js +1 -1
  124. package/es-custom/components/launcher/src/launcher.scss.js +1 -1
  125. package/es-custom/components/markdown/__tests__/inline-selection-fixture.d.ts +13 -0
  126. package/es-custom/components/markdown/index.d.ts +2 -0
  127. package/es-custom/components/markdown/index.js +3 -0
  128. package/es-custom/components/markdown/index.js.map +1 -1
  129. package/es-custom/components/markdown/src/inline-markdown.d.ts +41 -0
  130. package/es-custom/components/markdown/src/inline-markdown.js +92 -0
  131. package/es-custom/components/markdown/src/inline-markdown.js.map +1 -0
  132. package/es-custom/components/markdown/src/inline-markdown.scss.js +13 -0
  133. package/es-custom/components/markdown/src/inline-markdown.scss.js.map +1 -0
  134. package/es-custom/components/markdown/src/inline-run-projection.scss.js +13 -0
  135. package/es-custom/components/markdown/src/inline-run-projection.scss.js.map +1 -0
  136. package/es-custom/components/markdown/src/markdown-renderer-types.d.ts +132 -0
  137. package/es-custom/components/markdown/src/markdown-renderer.js +131 -25
  138. package/es-custom/components/markdown/src/markdown-renderer.js.map +1 -1
  139. package/es-custom/components/markdown/src/markdown.js +1 -0
  140. package/es-custom/components/markdown/src/markdown.js.map +1 -1
  141. package/es-custom/components/markdown/src/markdown.scss.js +1 -1
  142. package/es-custom/components/markdown/src/utils/inline-run-projection.d.ts +15 -0
  143. package/es-custom/components/markdown/src/utils/inline-run-projection.js +196 -0
  144. package/es-custom/components/markdown/src/utils/inline-run-projection.js.map +1 -0
  145. package/es-custom/components/markdown/src/utils/inline-validation.d.ts +13 -0
  146. package/es-custom/components/markdown/src/utils/inline-validation.js +97 -0
  147. package/es-custom/components/markdown/src/utils/inline-validation.js.map +1 -0
  148. package/es-custom/components/markdown/src/utils/plugin-fallback.js +20 -13
  149. package/es-custom/components/markdown/src/utils/plugin-fallback.js.map +1 -1
  150. package/es-custom/components/markdown/src/utils/plugin-host-container.d.ts +5 -6
  151. package/es-custom/components/markdown/src/utils/plugin-host-container.js.map +1 -1
  152. package/es-custom/components/messages-shell/index.d.ts +11 -0
  153. package/es-custom/components/messages-shell/index.js +9 -0
  154. package/es-custom/components/messages-shell/index.js.map +1 -0
  155. package/es-custom/components/messages-shell/src/messages-shell.d.ts +57 -0
  156. package/es-custom/components/messages-shell/src/messages-shell.js +141 -0
  157. package/es-custom/components/messages-shell/src/messages-shell.js.map +1 -0
  158. package/es-custom/components/messages-shell/src/messages-shell.scss.js +13 -0
  159. package/es-custom/components/messages-shell/src/messages-shell.scss.js.map +1 -0
  160. package/es-custom/components/processing/src/processing.scss.js +1 -1
  161. package/es-custom/components/prompt-line/autocomplete/src/autocomplete.d.ts +26 -9
  162. package/es-custom/components/prompt-line/autocomplete/src/autocomplete.js +116 -107
  163. package/es-custom/components/prompt-line/autocomplete/src/autocomplete.js.map +1 -1
  164. package/es-custom/components/prompt-line/autocomplete/src/autocomplete.scss.js +1 -1
  165. package/es-custom/components/prompt-line/src/autocomplete-controller-element.js +13 -1
  166. package/es-custom/components/prompt-line/src/autocomplete-controller-element.js.map +1 -1
  167. package/es-custom/components/prompt-line/src/autocomplete-controller.js +9 -2
  168. package/es-custom/components/prompt-line/src/autocomplete-controller.js.map +1 -1
  169. package/es-custom/components/prompt-line/src/prompt-line-controller.d.ts +7 -0
  170. package/es-custom/components/prompt-line/src/prompt-line-rich-runtime.js +17 -0
  171. package/es-custom/components/prompt-line/src/prompt-line-rich-runtime.js.map +1 -1
  172. package/es-custom/components/prompt-line/src/prompt-line-shell.scss.js +1 -1
  173. package/es-custom/components/prompt-line/src/prompt-line-textarea-runtime.d.ts +1 -0
  174. package/es-custom/components/prompt-line/src/prompt-line-textarea-runtime.js +3 -0
  175. package/es-custom/components/prompt-line/src/prompt-line-textarea-runtime.js.map +1 -1
  176. package/es-custom/components/prompt-line/src/prompt-line.d.ts +7 -0
  177. package/es-custom/components/prompt-line/src/prompt-line.js +9 -0
  178. package/es-custom/components/prompt-line/src/prompt-line.js.map +1 -1
  179. package/es-custom/components/prompt-line/src/send-control.scss.js +1 -1
  180. package/es-custom/components/prompt-line/src/stop-streaming-button.scss.js +1 -1
  181. package/es-custom/components/prompt-line/src/tiptap/carbon-mention.js +43 -21
  182. package/es-custom/components/prompt-line/src/tiptap/carbon-mention.js.map +1 -1
  183. package/es-custom/components/prompt-line/src/tiptap/plain-text-paste.js +8 -3
  184. package/es-custom/components/prompt-line/src/tiptap/plain-text-paste.js.map +1 -1
  185. package/es-custom/components/prompt-line/src/tiptap/strip-presentation-fields.d.ts +3 -3
  186. package/es-custom/components/prompt-line/src/tiptap/strip-presentation-fields.js.map +1 -1
  187. package/es-custom/components/prompt-line/src/tiptap/types.d.ts +27 -11
  188. package/es-custom/components/reasoning-steps/src/reasoning-step.d.ts +3 -3
  189. package/es-custom/components/reasoning-steps/src/reasoning-step.js +4 -4
  190. package/es-custom/components/reasoning-steps/src/reasoning-step.js.map +1 -1
  191. package/es-custom/components/reasoning-steps/src/reasoning-step.scss.js +1 -1
  192. package/es-custom/components/reasoning-steps/src/reasoning-steps-toggle.scss.js +1 -1
  193. package/es-custom/components/reasoning-steps/src/reasoning-steps.d.ts +5 -4
  194. package/es-custom/components/reasoning-steps/src/reasoning-steps.js +5 -4
  195. package/es-custom/components/reasoning-steps/src/reasoning-steps.js.map +1 -1
  196. package/es-custom/components/truncated-text/src/truncated-text.scss.js +1 -1
  197. package/es-custom/components/video-player/src/video-player.scss.js +1 -1
  198. package/es-custom/globals/scss/common.scss.js +1 -1
  199. package/es-custom/react/hooks/useChatAutocomplete.js +7 -1
  200. package/es-custom/react/hooks/useChatAutocomplete.js.map +1 -1
  201. package/es-custom/react/messages-shell.d.ts +3 -0
  202. package/es-custom/react/messages-shell.js +32 -0
  203. package/es-custom/react/messages-shell.js.map +1 -0
  204. package/package.json +6 -6
  205. package/scss/_markdown-inline.scss +138 -0
  206. package/telemetry.yml +4 -0
@@ -7,7 +7,7 @@
7
7
 
8
8
  import { css } from 'lit';
9
9
 
10
- var styles = css([":host :host([data-rounded=\"\"]),:host [data-rounded=\"\"]{border-end-end-radius:calc(var(--cds-aichat-border-radius-end-end, var(--cds-aichat-border-radius)) - .0625rem);border-end-start-radius:calc(var(--cds-aichat-border-radius-end-start, var(--cds-aichat-border-radius)) - .0625rem);border-start-end-radius:calc(var(--cds-aichat-border-radius-start-end, var(--cds-aichat-border-radius)) - .0625rem);border-start-start-radius:calc(var(--cds-aichat-border-radius-start-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=\"\"])::part(button),:host :host([data-rounded=\"\"])::part(link),:host [data-rounded=\"\"]::part(button),:host [data-rounded=\"\"]::part(link){border-end-end-radius:calc(var(--cds-aichat-border-radius-end-end, var(--cds-aichat-border-radius)) - .0625rem);border-end-start-radius:calc(var(--cds-aichat-border-radius-end-start, var(--cds-aichat-border-radius)) - .0625rem);border-start-end-radius:calc(var(--cds-aichat-border-radius-start-end, var(--cds-aichat-border-radius)) - .0625rem);border-start-start-radius:calc(var(--cds-aichat-border-radius-start-start, var(--cds-aichat-border-radius)) - .0625rem);outline-offset:-.0625rem}:host :host([data-rounded=\"\"])>:only-child,:host [data-rounded=\"\"]>:only-child{border-end-end-radius:calc(var(--cds-aichat-border-radius-end-end, var(--cds-aichat-border-radius)) - .0625rem);border-end-start-radius:calc(var(--cds-aichat-border-radius-end-start, var(--cds-aichat-border-radius)) - .0625rem);border-start-end-radius:calc(var(--cds-aichat-border-radius-start-end, var(--cds-aichat-border-radius)) - .0625rem);border-start-start-radius:calc(var(--cds-aichat-border-radius-start-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=top]),:host [data-rounded=top]{border-start-end-radius:calc(var(--cds-aichat-border-radius-start-end, var(--cds-aichat-border-radius)) - .0625rem);border-start-start-radius:calc(var(--cds-aichat-border-radius-start-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=top-left]),:host [data-rounded=top-left]{border-start-start-radius:calc(var(--cds-aichat-border-radius-start-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=top-right]),:host [data-rounded=top-right]{border-start-end-radius:calc(var(--cds-aichat-border-radius-start-end, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=bottom]),:host [data-rounded=bottom]{border-end-end-radius:calc(var(--cds-aichat-border-radius-end-end, var(--cds-aichat-border-radius)) - .0625rem);border-end-start-radius:calc(var(--cds-aichat-border-radius-end-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=bottom-left]),:host [data-rounded=bottom-left]{border-end-start-radius:calc(var(--cds-aichat-border-radius-end-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=bottom-right]),:host [data-rounded=bottom-right]{border-end-end-radius:calc(var(--cds-aichat-border-radius-end-end, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=top]:not([data-stacked]))>:first-child,:host [data-rounded=top]:not([data-stacked])>:first-child{border-start-start-radius:calc(var(--cds-aichat-border-radius-start-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=top]:not([data-stacked]))>:first-child::part(button),:host [data-rounded=top]:not([data-stacked])>:first-child::part(button){border-start-start-radius:calc(var(--cds-aichat-border-radius-start-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=top]:not([data-stacked]))>:last-child,:host [data-rounded=top]:not([data-stacked])>:last-child{border-start-end-radius:calc(var(--cds-aichat-border-radius-start-end, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=top]:not([data-stacked]))>:last-child::part(button),:host [data-rounded=top]:not([data-stacked])>:last-child::part(button){border-start-end-radius:calc(var(--cds-aichat-border-radius-start-end, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=top-left]:not([data-stacked]))>:first-child,:host [data-rounded=top-left]:not([data-stacked])>:first-child{border-start-start-radius:calc(var(--cds-aichat-border-radius-start-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=top-left]:not([data-stacked]))>:first-child::part(button),:host [data-rounded=top-left]:not([data-stacked])>:first-child::part(button){border-start-start-radius:calc(var(--cds-aichat-border-radius-start-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=top-right]:not([data-stacked]))>:last-child,:host [data-rounded=top-right]:not([data-stacked])>:last-child{border-start-end-radius:calc(var(--cds-aichat-border-radius-start-end, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=top-right]:not([data-stacked]))>:last-child::part(button),:host [data-rounded=top-right]:not([data-stacked])>:last-child::part(button){border-start-end-radius:calc(var(--cds-aichat-border-radius-start-end, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=bottom]:not([data-stacked]))>:first-child,:host [data-rounded=bottom]:not([data-stacked])>:first-child{border-end-start-radius:calc(var(--cds-aichat-border-radius-end-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=bottom]:not([data-stacked]))>:first-child::part(button),:host [data-rounded=bottom]:not([data-stacked])>:first-child::part(button){border-end-start-radius:calc(var(--cds-aichat-border-radius-end-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=bottom]:not([data-stacked]))>:last-child,:host [data-rounded=bottom]:not([data-stacked])>:last-child{border-end-end-radius:calc(var(--cds-aichat-border-radius-end-end, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=bottom]:not([data-stacked]))>:last-child::part(button),:host [data-rounded=bottom]:not([data-stacked])>:last-child::part(button){border-end-end-radius:calc(var(--cds-aichat-border-radius-end-end, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=bottom-left]:not([data-stacked]))>:first-child,:host [data-rounded=bottom-left]:not([data-stacked])>:first-child{border-end-start-radius:calc(var(--cds-aichat-border-radius-end-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=bottom-left]:not([data-stacked]))>:first-child::part(button),:host [data-rounded=bottom-left]:not([data-stacked])>:first-child::part(button){border-end-start-radius:calc(var(--cds-aichat-border-radius-end-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=bottom-right]:not([data-stacked]))>:last-child,:host [data-rounded=bottom-right]:not([data-stacked])>:last-child{border-end-end-radius:calc(var(--cds-aichat-border-radius-end-end, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=bottom-right]:not([data-stacked]))>:last-child::part(button),:host [data-rounded=bottom-right]:not([data-stacked])>:last-child::part(button){border-end-end-radius:calc(var(--cds-aichat-border-radius-end-end, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=top][data-stacked])>:first-child,:host [data-rounded=top][data-stacked]>:first-child{border-start-end-radius:calc(var(--cds-aichat-border-radius-start-end, var(--cds-aichat-border-radius)) - .0625rem);border-start-start-radius:calc(var(--cds-aichat-border-radius-start-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=top][data-stacked])>:first-child::part(button),:host [data-rounded=top][data-stacked]>:first-child::part(button){border-start-end-radius:calc(var(--cds-aichat-border-radius-start-end, var(--cds-aichat-border-radius)) - .0625rem);border-start-start-radius:calc(var(--cds-aichat-border-radius-start-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=top-right][data-stacked])>:first-child,:host [data-rounded=top-right][data-stacked]>:first-child{border-start-end-radius:calc(var(--cds-aichat-border-radius-start-end, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=top-right][data-stacked])>:first-child::part(button),:host [data-rounded=top-right][data-stacked]>:first-child::part(button){border-start-end-radius:calc(var(--cds-aichat-border-radius-start-end, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=top-left][data-stacked])>:first-child,:host [data-rounded=top-left][data-stacked]>:first-child{border-start-start-radius:calc(var(--cds-aichat-border-radius-start-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=top-left][data-stacked])>:first-child::part(button),:host [data-rounded=top-left][data-stacked]>:first-child::part(button){border-start-start-radius:calc(var(--cds-aichat-border-radius-start-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=bottom][data-stacked])>:last-child,:host [data-rounded=bottom][data-stacked]>:last-child{border-end-end-radius:calc(var(--cds-aichat-border-radius-end-end, var(--cds-aichat-border-radius)) - .0625rem);border-end-start-radius:calc(var(--cds-aichat-border-radius-end-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=bottom][data-stacked])>:last-child::part(button),:host [data-rounded=bottom][data-stacked]>:last-child::part(button){border-end-end-radius:calc(var(--cds-aichat-border-radius-end-end, var(--cds-aichat-border-radius)) - .0625rem);border-end-start-radius:calc(var(--cds-aichat-border-radius-end-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=bottom-right][data-stacked])>:last-child,:host [data-rounded=bottom-right][data-stacked]>:last-child{border-end-end-radius:calc(var(--cds-aichat-border-radius-end-end, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=bottom-right][data-stacked])>:last-child::part(button),:host [data-rounded=bottom-right][data-stacked]>:last-child::part(button){border-end-end-radius:calc(var(--cds-aichat-border-radius-end-end, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=bottom-left][data-stacked])>:last-child,:host [data-rounded=bottom-left][data-stacked]>:last-child{border-end-start-radius:calc(var(--cds-aichat-border-radius-end-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=bottom-left][data-stacked])>:last-child::part(button),:host [data-rounded=bottom-left][data-stacked]>:last-child::part(button){border-end-start-radius:calc(var(--cds-aichat-border-radius-end-start, var(--cds-aichat-border-radius)) - .0625rem)}:host{--cds-aichat-border-radius-start-start:0.5rem;--cds-aichat-border-radius-start-end:0.5rem;--cds-aichat-border-radius-end-start:0.5rem;--cds-aichat-border-radius-end-end:0.5rem;--cds-aichat-autocomplete-max-height:none}:host .cds-aichat-autocomplete{background:var(--cds-chat-prompt-background,#fff);border:1px solid var(--cds-chat-prompt-border-start,#f4f4f4);border-end-end-radius:var(--cds-aichat-border-radius-end-end,0);border-end-start-radius:var(--cds-aichat-border-radius-end-start,0);border-start-end-radius:var(--cds-aichat-border-radius-start-end,0);border-start-start-radius:var(--cds-aichat-border-radius-start-start,0);display:flex;flex-direction:column;max-block-size:var(--cds-aichat-autocomplete-max-height)}:host .cds-aichat-autocomplete__header{align-items:center;border-block-end:1px solid var(--cds-border-subtle-00,#e0e0e0);display:flex;flex-shrink:0;gap:1rem;justify-content:space-between;min-block-size:2.5rem;padding-block:0;padding-inline:1rem}:host .cds-aichat-autocomplete__title{color:var(--cds-text-primary,#161616);font-size:var(--cds-heading-compact-01-font-size,.875rem);font-weight:var(--cds-heading-compact-01-font-weight,600);letter-spacing:var(--cds-heading-compact-01-letter-spacing,.16px);line-height:var(--cds-heading-compact-01-line-height,1.28572)}:host .cds-aichat-autocomplete__items{display:flex;flex:1 1 auto;flex-direction:column;margin:0;min-block-size:0;overflow-y:auto;padding:0}:host .cds-aichat-autocomplete__live-region{clip:rect(0,0,0,0);block-size:1px;border:0;inline-size:1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap}:host .cds-aichat-autocomplete-item-group__title{color:var(--cds-text-helper,#6f6f6f);font-size:var(--cds-label-01-font-size,.75rem);font-weight:var(--cds-label-01-font-weight,400);letter-spacing:var(--cds-label-01-letter-spacing,.32px);line-height:var(--cds-label-01-line-height,1.33333);padding-block-end:.25rem;padding-block-start:1rem;padding-inline:1rem}:host .cds-aichat-autocomplete-item-group__items{display:flex;flex-direction:column;margin:0;padding:0}:host .cds-aichat-autocomplete-item{align-items:start;background:none;border:none;cursor:pointer;display:flex;font:inherit;inline-size:100%;min-block-size:2.5rem;padding-block:0;padding-inline:0;position:relative;text-align:start}:host .cds-aichat-autocomplete-item:hover{background:var(--cds-background-hover,hsla(0,0%,55%,.12))}:host .cds-aichat-autocomplete-item:focus{outline:2px solid var(--cds-focus,#0f62fe);outline-offset:-2px}@media screen and (prefers-contrast){:host .cds-aichat-autocomplete-item:focus{outline-style:dotted}}:host .cds-aichat-autocomplete-item--active,:host .cds-aichat-autocomplete-item--active:hover{background:var(--cds-background-hover,hsla(0,0%,55%,.12))}:host .cds-aichat-autocomplete-item--disabled{cursor:default;pointer-events:none}:host .cds-aichat-autocomplete-item--disabled .cds-aichat-autocomplete-item__label-remainder,:host .cds-aichat-autocomplete-item--disabled .cds-aichat-autocomplete-item__label-typed{color:var(--cds-text-disabled,hsla(0,0%,9%,.25))}:host .cds-aichat-autocomplete-item--disabled .cds-aichat-autocomplete-item__description{color:var(--cds-text-disabled,hsla(0,0%,9%,.25))}:host .cds-aichat-autocomplete-item--disabled .cds-aichat-autocomplete-item__send-icon svg{fill:var(--cds-icon-disabled,hsla(0,0%,9%,.25))}:host .cds-aichat-autocomplete-item__content{align-items:start;display:flex;flex:1;gap:.5rem;padding-block:11px;padding-inline:1rem}:host .cds-aichat-autocomplete-item__text{display:flex;flex-direction:column;gap:.125rem}:host .cds-aichat-autocomplete-item__label{font-size:var(--cds-body-compact-01-font-size,.875rem);font-weight:var(--cds-body-compact-01-font-weight,400);letter-spacing:var(--cds-body-compact-01-letter-spacing,.16px);line-height:var(--cds-body-compact-01-line-height,1.28572)}:host .cds-aichat-autocomplete-item__label-typed{color:var(--cds-text-placeholder,hsla(0,0%,9%,.4))}:host .cds-aichat-autocomplete-item__label-remainder{color:var(--cds-text-primary,#161616)}:host .cds-aichat-autocomplete-item__description{color:var(--cds-text-secondary,#525252);font-size:var(--cds-helper-text-01-font-size,.75rem);letter-spacing:var(--cds-helper-text-01-letter-spacing,.32px);line-height:var(--cds-helper-text-01-line-height,1.33333)}:host .cds-aichat-autocomplete-item__send-icon{align-self:start;display:flex;padding-block:.75rem;padding-inline:.75rem;pointer-events:none;visibility:hidden;z-index:1}:host .cds-aichat-autocomplete-item__send-icon svg{fill:var(--cds-interactive,#0f62fe)}:host .cds-aichat-autocomplete-item--active .cds-aichat-autocomplete-item__send-icon,:host .cds-aichat-autocomplete-item:focus .cds-aichat-autocomplete-item__send-icon,:host .cds-aichat-autocomplete-item:focus-within .cds-aichat-autocomplete-item__send-icon,:host .cds-aichat-autocomplete-item:hover .cds-aichat-autocomplete-item__send-icon{visibility:visible}:host .cds-aichat-autocomplete-item:after{background:var(--cds-border-subtle-00,#e0e0e0);block-size:1px;content:\"\";display:block;inset-block-end:0;inset-inline:1rem;position:absolute}:host .cds-aichat-autocomplete-item:focus:after,:host .cds-aichat-autocomplete-item:hover:after{display:none}:host .cds-aichat-autocomplete-item[first-item]{border-start-end-radius:var(--cds-aichat-border-radius-start-end,0);border-start-start-radius:var(--cds-aichat-border-radius-start-start,0)}:host .cds-aichat-autocomplete-item[last-item]{border-end-end-radius:var(--cds-aichat-border-radius-end-end,0);border-end-start-radius:var(--cds-aichat-border-radius-end-start,0)}:host .cds-aichat-autocomplete-item[last-item]:after{display:none}:host([attached]){--cds-aichat-border-radius-end-start:0;--cds-aichat-border-radius-end-end:0}"]);
10
+ var styles = css([":host :host([data-rounded=\"\"]),:host [data-rounded=\"\"]{border-end-end-radius:calc(var(--cds-aichat-border-radius-end-end, var(--cds-aichat-border-radius)) - .0625rem);border-end-start-radius:calc(var(--cds-aichat-border-radius-end-start, var(--cds-aichat-border-radius)) - .0625rem);border-start-end-radius:calc(var(--cds-aichat-border-radius-start-end, var(--cds-aichat-border-radius)) - .0625rem);border-start-start-radius:calc(var(--cds-aichat-border-radius-start-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=\"\"])::part(button),:host :host([data-rounded=\"\"])::part(link),:host [data-rounded=\"\"]::part(button),:host [data-rounded=\"\"]::part(link){border-end-end-radius:calc(var(--cds-aichat-border-radius-end-end, var(--cds-aichat-border-radius)) - .0625rem);border-end-start-radius:calc(var(--cds-aichat-border-radius-end-start, var(--cds-aichat-border-radius)) - .0625rem);border-start-end-radius:calc(var(--cds-aichat-border-radius-start-end, var(--cds-aichat-border-radius)) - .0625rem);border-start-start-radius:calc(var(--cds-aichat-border-radius-start-start, var(--cds-aichat-border-radius)) - .0625rem);outline-offset:-.0625rem}:host :host([data-rounded=\"\"])>:only-child,:host [data-rounded=\"\"]>:only-child{border-end-end-radius:calc(var(--cds-aichat-border-radius-end-end, var(--cds-aichat-border-radius)) - .0625rem);border-end-start-radius:calc(var(--cds-aichat-border-radius-end-start, var(--cds-aichat-border-radius)) - .0625rem);border-start-end-radius:calc(var(--cds-aichat-border-radius-start-end, var(--cds-aichat-border-radius)) - .0625rem);border-start-start-radius:calc(var(--cds-aichat-border-radius-start-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=top]),:host [data-rounded=top]{border-start-end-radius:calc(var(--cds-aichat-border-radius-start-end, var(--cds-aichat-border-radius)) - .0625rem);border-start-start-radius:calc(var(--cds-aichat-border-radius-start-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=top-left]),:host [data-rounded=top-left]{border-start-start-radius:calc(var(--cds-aichat-border-radius-start-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=top-right]),:host [data-rounded=top-right]{border-start-end-radius:calc(var(--cds-aichat-border-radius-start-end, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=bottom]),:host [data-rounded=bottom]{border-end-end-radius:calc(var(--cds-aichat-border-radius-end-end, var(--cds-aichat-border-radius)) - .0625rem);border-end-start-radius:calc(var(--cds-aichat-border-radius-end-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=bottom-left]),:host [data-rounded=bottom-left]{border-end-start-radius:calc(var(--cds-aichat-border-radius-end-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=bottom-right]),:host [data-rounded=bottom-right]{border-end-end-radius:calc(var(--cds-aichat-border-radius-end-end, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=top]:not([data-stacked]))>:first-child,:host [data-rounded=top]:not([data-stacked])>:first-child{border-start-start-radius:calc(var(--cds-aichat-border-radius-start-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=top]:not([data-stacked]))>:first-child::part(button),:host [data-rounded=top]:not([data-stacked])>:first-child::part(button){border-start-start-radius:calc(var(--cds-aichat-border-radius-start-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=top]:not([data-stacked]))>:last-child,:host [data-rounded=top]:not([data-stacked])>:last-child{border-start-end-radius:calc(var(--cds-aichat-border-radius-start-end, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=top]:not([data-stacked]))>:last-child::part(button),:host [data-rounded=top]:not([data-stacked])>:last-child::part(button){border-start-end-radius:calc(var(--cds-aichat-border-radius-start-end, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=top-left]:not([data-stacked]))>:first-child,:host [data-rounded=top-left]:not([data-stacked])>:first-child{border-start-start-radius:calc(var(--cds-aichat-border-radius-start-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=top-left]:not([data-stacked]))>:first-child::part(button),:host [data-rounded=top-left]:not([data-stacked])>:first-child::part(button){border-start-start-radius:calc(var(--cds-aichat-border-radius-start-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=top-right]:not([data-stacked]))>:last-child,:host [data-rounded=top-right]:not([data-stacked])>:last-child{border-start-end-radius:calc(var(--cds-aichat-border-radius-start-end, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=top-right]:not([data-stacked]))>:last-child::part(button),:host [data-rounded=top-right]:not([data-stacked])>:last-child::part(button){border-start-end-radius:calc(var(--cds-aichat-border-radius-start-end, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=bottom]:not([data-stacked]))>:first-child,:host [data-rounded=bottom]:not([data-stacked])>:first-child{border-end-start-radius:calc(var(--cds-aichat-border-radius-end-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=bottom]:not([data-stacked]))>:first-child::part(button),:host [data-rounded=bottom]:not([data-stacked])>:first-child::part(button){border-end-start-radius:calc(var(--cds-aichat-border-radius-end-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=bottom]:not([data-stacked]))>:last-child,:host [data-rounded=bottom]:not([data-stacked])>:last-child{border-end-end-radius:calc(var(--cds-aichat-border-radius-end-end, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=bottom]:not([data-stacked]))>:last-child::part(button),:host [data-rounded=bottom]:not([data-stacked])>:last-child::part(button){border-end-end-radius:calc(var(--cds-aichat-border-radius-end-end, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=bottom-left]:not([data-stacked]))>:first-child,:host [data-rounded=bottom-left]:not([data-stacked])>:first-child{border-end-start-radius:calc(var(--cds-aichat-border-radius-end-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=bottom-left]:not([data-stacked]))>:first-child::part(button),:host [data-rounded=bottom-left]:not([data-stacked])>:first-child::part(button){border-end-start-radius:calc(var(--cds-aichat-border-radius-end-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=bottom-right]:not([data-stacked]))>:last-child,:host [data-rounded=bottom-right]:not([data-stacked])>:last-child{border-end-end-radius:calc(var(--cds-aichat-border-radius-end-end, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=bottom-right]:not([data-stacked]))>:last-child::part(button),:host [data-rounded=bottom-right]:not([data-stacked])>:last-child::part(button){border-end-end-radius:calc(var(--cds-aichat-border-radius-end-end, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=top][data-stacked])>:first-child,:host [data-rounded=top][data-stacked]>:first-child{border-start-end-radius:calc(var(--cds-aichat-border-radius-start-end, var(--cds-aichat-border-radius)) - .0625rem);border-start-start-radius:calc(var(--cds-aichat-border-radius-start-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=top][data-stacked])>:first-child::part(button),:host [data-rounded=top][data-stacked]>:first-child::part(button){border-start-end-radius:calc(var(--cds-aichat-border-radius-start-end, var(--cds-aichat-border-radius)) - .0625rem);border-start-start-radius:calc(var(--cds-aichat-border-radius-start-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=top-right][data-stacked])>:first-child,:host [data-rounded=top-right][data-stacked]>:first-child{border-start-end-radius:calc(var(--cds-aichat-border-radius-start-end, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=top-right][data-stacked])>:first-child::part(button),:host [data-rounded=top-right][data-stacked]>:first-child::part(button){border-start-end-radius:calc(var(--cds-aichat-border-radius-start-end, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=top-left][data-stacked])>:first-child,:host [data-rounded=top-left][data-stacked]>:first-child{border-start-start-radius:calc(var(--cds-aichat-border-radius-start-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=top-left][data-stacked])>:first-child::part(button),:host [data-rounded=top-left][data-stacked]>:first-child::part(button){border-start-start-radius:calc(var(--cds-aichat-border-radius-start-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=bottom][data-stacked])>:last-child,:host [data-rounded=bottom][data-stacked]>:last-child{border-end-end-radius:calc(var(--cds-aichat-border-radius-end-end, var(--cds-aichat-border-radius)) - .0625rem);border-end-start-radius:calc(var(--cds-aichat-border-radius-end-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=bottom][data-stacked])>:last-child::part(button),:host [data-rounded=bottom][data-stacked]>:last-child::part(button){border-end-end-radius:calc(var(--cds-aichat-border-radius-end-end, var(--cds-aichat-border-radius)) - .0625rem);border-end-start-radius:calc(var(--cds-aichat-border-radius-end-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=bottom-right][data-stacked])>:last-child,:host [data-rounded=bottom-right][data-stacked]>:last-child{border-end-end-radius:calc(var(--cds-aichat-border-radius-end-end, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=bottom-right][data-stacked])>:last-child::part(button),:host [data-rounded=bottom-right][data-stacked]>:last-child::part(button){border-end-end-radius:calc(var(--cds-aichat-border-radius-end-end, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=bottom-left][data-stacked])>:last-child,:host [data-rounded=bottom-left][data-stacked]>:last-child{border-end-start-radius:calc(var(--cds-aichat-border-radius-end-start, var(--cds-aichat-border-radius)) - .0625rem)}:host :host([data-rounded=bottom-left][data-stacked])>:last-child::part(button),:host [data-rounded=bottom-left][data-stacked]>:last-child::part(button){border-end-start-radius:calc(var(--cds-aichat-border-radius-end-start, var(--cds-aichat-border-radius)) - .0625rem)}:host{--cds-aichat-border-radius-start-start:0.5rem;--cds-aichat-border-radius-start-end:0.5rem;--cds-aichat-border-radius-end-start:0.5rem;--cds-aichat-border-radius-end-end:0.5rem;--cds-aichat-autocomplete-max-height:none}:host .cds-aichat-autocomplete{background:var(--cds-chat-prompt-background,#fff);border:1px solid var(--cds-chat-prompt-border-start,#f4f4f4);border-end-end-radius:var(--cds-aichat-border-radius-end-end,0);border-end-start-radius:var(--cds-aichat-border-radius-end-start,0);border-start-end-radius:var(--cds-aichat-border-radius-start-end,0);border-start-start-radius:var(--cds-aichat-border-radius-start-start,0);display:flex;flex-direction:column;max-block-size:var(--cds-aichat-autocomplete-max-height)}:host .cds-aichat-autocomplete__header{align-items:center;border-block-end:1px solid var(--cds-border-subtle-00,#e0e0e0);display:flex;flex-shrink:0;gap:1rem;justify-content:space-between;min-block-size:2.5rem;padding-block:0;padding-inline:1rem}:host .cds-aichat-autocomplete__title{color:var(--cds-text-primary,#161616);font-size:var(--cds-heading-compact-01-font-size,.875rem);font-weight:var(--cds-heading-compact-01-font-weight,600);letter-spacing:var(--cds-heading-compact-01-letter-spacing,.16px);line-height:var(--cds-heading-compact-01-line-height,1.28572)}:host .cds-aichat-autocomplete__items{display:flex;flex:1 1 auto;flex-direction:column;margin:0;min-block-size:0;overflow-y:auto;padding:0}:host .cds-aichat-autocomplete__live-region{block-size:1px;border:0;overflow:hidden;padding:0;position:absolute;clip:rect(0,0,0,0);inline-size:1px;white-space:nowrap}:host .cds-aichat-autocomplete-item-group__title{color:var(--cds-text-helper,#6f6f6f);font-size:var(--cds-label-01-font-size,.75rem);font-weight:var(--cds-label-01-font-weight,400);letter-spacing:var(--cds-label-01-letter-spacing,.32px);line-height:var(--cds-label-01-line-height,1.33333);padding-block-end:.25rem;padding-block-start:1rem;padding-inline:1rem}:host .cds-aichat-autocomplete-item-group__items{display:flex;flex-direction:column;margin:0;padding:0}:host .cds-aichat-autocomplete-item{align-items:start;background:none;border:none;cursor:pointer;display:flex;font:inherit;inline-size:100%;min-block-size:2.5rem;padding-block:0;padding-inline:0;position:relative;text-align:start}:host .cds-aichat-autocomplete-item:hover{background:var(--cds-background-hover,hsla(0,0%,55.3%,.12))}:host .cds-aichat-autocomplete-item:focus{outline:2px solid var(--cds-focus,#0f62fe);outline-offset:-2px}@media screen and (prefers-contrast){:host .cds-aichat-autocomplete-item:focus{outline-style:dotted}}:host .cds-aichat-autocomplete-item--active,:host .cds-aichat-autocomplete-item--active:hover{background:var(--cds-background-hover,hsla(0,0%,55.3%,.12))}:host .cds-aichat-autocomplete-item--disabled{cursor:default;pointer-events:none}:host .cds-aichat-autocomplete-item--disabled .cds-aichat-autocomplete-item__label-remainder,:host .cds-aichat-autocomplete-item--disabled .cds-aichat-autocomplete-item__label-typed{color:var(--cds-text-disabled,rgba(22,22,22,.25))}:host .cds-aichat-autocomplete-item--disabled .cds-aichat-autocomplete-item__description{color:var(--cds-text-disabled,rgba(22,22,22,.25))}:host .cds-aichat-autocomplete-item--disabled .cds-aichat-autocomplete-item__send-icon svg{fill:var(--cds-icon-disabled,rgba(22,22,22,.25))}:host .cds-aichat-autocomplete-item__content{align-items:start;display:flex;flex:1;gap:.5rem;padding-block:11px;padding-inline:1rem}:host .cds-aichat-autocomplete-item__text{display:flex;flex-direction:column;gap:.125rem}:host .cds-aichat-autocomplete-item__label{font-size:var(--cds-body-compact-01-font-size,.875rem);font-weight:var(--cds-body-compact-01-font-weight,400);letter-spacing:var(--cds-body-compact-01-letter-spacing,.16px);line-height:var(--cds-body-compact-01-line-height,1.28572)}:host .cds-aichat-autocomplete-item__label-typed{color:var(--cds-text-placeholder,rgba(22,22,22,.4))}:host .cds-aichat-autocomplete-item__label-remainder{color:var(--cds-text-primary,#161616)}:host .cds-aichat-autocomplete-item__description{color:var(--cds-text-secondary,#525252);font-size:var(--cds-helper-text-01-font-size,.75rem);letter-spacing:var(--cds-helper-text-01-letter-spacing,.32px);line-height:var(--cds-helper-text-01-line-height,1.33333)}:host .cds-aichat-autocomplete-item__send-icon{align-self:start;display:flex;padding-block:.75rem;padding-inline:.75rem;pointer-events:none;visibility:hidden;z-index:1}:host .cds-aichat-autocomplete-item__send-icon svg{fill:var(--cds-interactive,#0f62fe)}:host .cds-aichat-autocomplete-item--active .cds-aichat-autocomplete-item__send-icon,:host .cds-aichat-autocomplete-item:focus .cds-aichat-autocomplete-item__send-icon,:host .cds-aichat-autocomplete-item:focus-within .cds-aichat-autocomplete-item__send-icon,:host .cds-aichat-autocomplete-item:hover .cds-aichat-autocomplete-item__send-icon{visibility:visible}:host .cds-aichat-autocomplete-item:after{background:var(--cds-border-subtle-00,#e0e0e0);block-size:1px;content:\"\";display:block;inset-block-end:0;inset-inline:1rem;position:absolute}:host .cds-aichat-autocomplete-item:focus:after,:host .cds-aichat-autocomplete-item:hover:after{display:none}:host .cds-aichat-autocomplete-item[first-item]{border-start-end-radius:var(--cds-aichat-border-radius-start-end,0);border-start-start-radius:var(--cds-aichat-border-radius-start-start,0)}:host .cds-aichat-autocomplete-item[last-item]{border-end-end-radius:var(--cds-aichat-border-radius-end-end,0);border-end-start-radius:var(--cds-aichat-border-radius-end-start,0)}:host .cds-aichat-autocomplete-item[last-item]:after{display:none}:host([attached]){--cds-aichat-border-radius-end-start:0;--cds-aichat-border-radius-end-end:0}"]);
11
11
 
12
12
  export { styles as default };
13
13
  //# sourceMappingURL=autocomplete.scss.js.map
@@ -168,7 +168,7 @@ let AutocompleteControllerElement = class AutocompleteControllerElement extends
168
168
  }
169
169
  render() {
170
170
  const { trigger, items, renderCustomList, disableDirectSend } = this._state;
171
- if (!trigger || items.length === 0) {
171
+ if (!trigger) {
172
172
  // List is gone — reset navigation state so the send button is unblocked.
173
173
  // This covers cases where the list is removed without an autocomplete
174
174
  // dismiss/select/send event (e.g. the user deletes the trigger character).
@@ -180,7 +180,19 @@ let AutocompleteControllerElement = class AutocompleteControllerElement extends
180
180
  }
181
181
  return nothing;
182
182
  }
183
+ if (items.length === 0 && this._listNavigated) {
184
+ this._listNavigated = false;
185
+ this.dispatchEvent(new CustomEvent('cds-aichat-list-navigated', { detail: { navigated: false }, bubbles: true, composed: true }));
186
+ this.dispatchEvent(new CustomEvent('cds-aichat-autocomplete-navigated', { detail: { navigated: false }, bubbles: true, composed: true }));
187
+ }
183
188
  if (renderCustomList) {
189
+ // When items are empty the built-in autocomplete element is kept mounted
190
+ // so it can announce the zero-results state. Consumer-supplied renderers
191
+ // are not mounted in that case: they own their own empty-state handling
192
+ // and were not rendered before this PR.
193
+ if (items.length === 0) {
194
+ return nothing;
195
+ }
184
196
  const result = renderCustomList({
185
197
  items,
186
198
  query: trigger.query,
@@ -1 +1 @@
1
- {"version":3,"file":"autocomplete-controller-element.js","sources":["../../../../src/components/prompt-line/src/autocomplete-controller-element.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { html, LitElement, nothing } from 'lit';\nimport { property, state } from 'lit/decorators.js';\n\nimport { carbonElement } from '../../../globals/decorators/carbon-element.js';\nimport prefix from '../../../globals/settings.js';\n\nimport '../autocomplete/src/autocomplete.js';\nimport type { AutocompleteNavigatedEventDetail } from '../autocomplete/src/autocomplete.js';\nimport {\n AutocompleteController,\n itemsToGroups,\n type AutocompleteControllerState,\n} from './autocomplete-controller.js';\nimport type {\n AutocompleteConfig,\n StartersConfig,\n SuggestionItem,\n TriggerSuggestionConfig,\n} from './tiptap/types.js';\n\n/**\n * `<cds-aichat-autocomplete-controller>` — drops the autocomplete overlay\n * lifecycle into a `<cds-aichat-prompt-line-shell>`'s `autocomplete-content` slot.\n *\n * Listens for `cds-aichat-trigger-change` events bubbling up from the\n * enclosing prompt-line-shell (the events are `composed: true, bubbles: true`, so\n * they reach here from inside the prompt-line's shadow root). Scoping the\n * listener to the shell — rather than `window` — keeps multiple\n * shell/controller pairs on the same page from cross-talking. Renders the\n * built-in `<cds-aichat-autocomplete>` or the active config's\n * `renderCustomList` output. Selection routes back into the originating\n * prompt-line.\n *\n * @element cds-aichat-autocomplete-controller\n * @fires cds-aichat-starter-selected — `{ text: string }` after a starter is\n * inserted into the editor; consumer triggers send.\n * @fires cds-aichat-autocomplete-item-selected — `{ item: SuggestionItem }`\n * after a suggestion item is selected. Fired in addition to type-specific callbacks.\n * @fires cds-aichat-autocomplete-item-send — `{ text: string }` when the\n * per-item send button is clicked inside the suggestion list.\n * @fires cds-aichat-list-navigated — `{ navigated: boolean }` when the user\n * starts or stops navigating the suggestion list with arrow keys. WC\n * consumers should use this to disable their send control while `navigated`\n * is `true` (the `listNavigated` getter reflects the same state).\n */\n@carbonElement(`${prefix}-autocomplete-controller`)\nclass AutocompleteControllerElement extends LitElement {\n /** `@`-style mention trigger config. */\n @property({ attribute: false })\n mention?: TriggerSuggestionConfig;\n\n /** `/`-style command trigger config. */\n @property({ attribute: false })\n command?: TriggerSuggestionConfig;\n\n /** Live-typeahead autocomplete config (no trigger character). */\n @property({ attribute: false })\n autocomplete?: AutocompleteConfig;\n\n /** Starter prompts shown when the editor is empty + focused + editable. */\n @property({ attribute: false })\n starters?: StartersConfig;\n\n /** When true, starter selection inserts text without firing the send event. */\n @property({ type: Boolean, attribute: 'is-send-disabled' })\n isSendDisabled = false;\n\n @state()\n private _state: AutocompleteControllerState = { trigger: null, items: [] };\n\n /**\n * Tracks whether the user is actively navigating inside the autocomplete\n * list. When `true`, the send button should be disabled so that Enter\n * confirms the highlighted item rather than submitting the prompt.\n */\n @state()\n private _listNavigated = false;\n\n /**\n * Returns `true` while the user is navigating inside the autocomplete list.\n * Consumers can use this to disable their send control.\n */\n get listNavigated(): boolean {\n return this._listNavigated;\n }\n\n private _controller: AutocompleteController | null = null;\n /**\n * Ancestor we subscribed `cds-aichat-trigger-change` on. Scoping the\n * listener to the enclosing `<cds-aichat-prompt-line-shell>` (rather than\n * `window`) keeps a second shell/controller pair on the same page from\n * receiving each other's events.\n */\n private _eventSource: EventTarget | null = null;\n\n // Render in light DOM so consumers' page-level CSS / portals can reach\n // any custom list element they've slotted in via renderCustomList.\n protected override createRenderRoot(): this {\n return this;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.addEventListener('mousedown', this._handleMousedown);\n this.addEventListener(\n 'cds-aichat-autocomplete-navigated',\n this._handleAutocompleteNavigated as EventListener\n );\n this._controller = new AutocompleteController({\n mention: this.mention,\n command: this.command,\n autocomplete: this.autocomplete,\n starters: this.starters,\n isSendDisabled: this.isSendDisabled,\n onStarterSelected: (text) => {\n this.dispatchEvent(\n new CustomEvent('cds-aichat-starter-selected', {\n detail: { text },\n bubbles: true,\n composed: true,\n })\n );\n },\n onChange: (next) => {\n this._state = next;\n },\n });\n // Scope to the enclosing prompt-line-shell so multiple shell/controller pairs\n // on the same page don't cross-talk. Falls back to `this` if the\n // controller is used outside a shell — in that case the consumer\n // should make sure their prompt-line bubbles events into this element.\n this._eventSource = this.closest('cds-aichat-prompt-line-shell') ?? this;\n this._eventSource.addEventListener(\n 'cds-aichat-trigger-change',\n this._handleTriggerChange as EventListener\n );\n }\n\n override disconnectedCallback(): void {\n this.removeEventListener('mousedown', this._handleMousedown);\n this.removeEventListener(\n 'cds-aichat-autocomplete-navigated',\n this._handleAutocompleteNavigated as EventListener\n );\n this._eventSource?.removeEventListener(\n 'cds-aichat-trigger-change',\n this._handleTriggerChange as EventListener\n );\n this._eventSource = null;\n this._controller?.destroy();\n this._controller = null;\n super.disconnectedCallback();\n }\n\n override updated(changed: Map<string, unknown>): void {\n if (!this._controller) {\n return;\n }\n if (\n changed.has('mention') ||\n changed.has('command') ||\n changed.has('autocomplete') ||\n changed.has('starters') ||\n changed.has('isSendDisabled')\n ) {\n this._controller.setConfigs({\n mention: this.mention,\n command: this.command,\n autocomplete: this.autocomplete,\n starters: this.starters,\n isSendDisabled: this.isSendDisabled,\n });\n }\n // Register the currently-rendered list element with the controller so\n // arrow / Enter / Escape on the editor get forwarded into it.\n const listEl =\n this.querySelector<HTMLElement>('cds-aichat-autocomplete') ??\n (this.firstElementChild instanceof HTMLElement\n ? this.firstElementChild\n : null);\n this._controller.setListElement(listEl);\n\n // Pass the editor DOM as anchorElement so the autocomplete's outside-click\n // guard treats clicks on the editor as inside-clicks (not dismissals).\n const editorDom = this._controller.getPromptLine()?.getEditor()?.view\n .dom as Element | undefined;\n const autocompleteEl = this.querySelector<\n HTMLElement & { anchorElement?: Element | null }\n >('cds-aichat-autocomplete');\n if (autocompleteEl) {\n autocompleteEl.anchorElement = editorDom ?? null;\n }\n }\n\n override render() {\n const { trigger, items, renderCustomList, disableDirectSend } = this._state;\n if (!trigger || items.length === 0) {\n // List is gone — reset navigation state so the send button is unblocked.\n // This covers cases where the list is removed without an autocomplete\n // dismiss/select/send event (e.g. the user deletes the trigger character).\n if (this._listNavigated) {\n this._listNavigated = false;\n this.dispatchEvent(\n new CustomEvent<AutocompleteNavigatedEventDetail>(\n 'cds-aichat-list-navigated',\n { detail: { navigated: false }, bubbles: true, composed: true }\n )\n );\n // Also fire the lower-level event so send-control's shell listener fires.\n this.dispatchEvent(\n new CustomEvent<AutocompleteNavigatedEventDetail>(\n 'cds-aichat-autocomplete-navigated',\n { detail: { navigated: false }, bubbles: true, composed: true }\n )\n );\n }\n return nothing;\n }\n if (renderCustomList) {\n const result = renderCustomList({\n items,\n query: trigger.query,\n onDismiss: () => this._controller?.dismiss(),\n onSelect: (item) => this._selectItem(item),\n onSend: (text) => this._sendItem(text),\n });\n if (result instanceof HTMLElement) {\n return html`${result}`;\n }\n // Custom renderer returned something other than an HTMLElement (e.g.\n // a React node). Surface it on a side-channel event so React adapters\n // can portal it into place themselves.\n this.dispatchEvent(\n new CustomEvent('cds-aichat-custom-list-render', {\n detail: { reactNode: result },\n bubbles: true,\n composed: true,\n })\n );\n return nothing;\n }\n const { items: flatItems, groups } = itemsToGroups(items);\n return html`\n <cds-aichat-autocomplete\n .items=${flatItems}\n .groups=${groups}\n .disableDirectSend=${disableDirectSend}\n @cds-aichat-autocomplete-select=${(\n e: CustomEvent<{ item: SuggestionItem }>\n ) => this._selectItem(e.detail.item)}\n @cds-aichat-autocomplete-send=${(e: CustomEvent<{ text: string }>) =>\n this._sendItem(e.detail.text)}\n @cds-aichat-autocomplete-dismiss=${() => this._controller?.dismiss()}></cds-aichat-autocomplete>\n `;\n }\n\n private _selectItem(item: SuggestionItem): void {\n this._controller?.select(item);\n this.dispatchEvent(\n new CustomEvent('cds-aichat-autocomplete-item-selected', {\n detail: { item },\n bubbles: true,\n composed: true,\n })\n );\n }\n\n private _sendItem(text: string): void {\n if (this.isSendDisabled) {\n return;\n }\n this._controller?.dismiss(true);\n this.dispatchEvent(\n new CustomEvent('cds-aichat-autocomplete-item-send', {\n detail: { text },\n bubbles: true,\n composed: true,\n })\n );\n }\n\n private _handleMousedown = (event: MouseEvent): void => {\n // Prevent the autocomplete list from stealing focus from the editor.\n event.preventDefault();\n };\n\n private _handleAutocompleteNavigated = (event: Event): void => {\n const { navigated } = (\n event as CustomEvent<AutocompleteNavigatedEventDetail>\n ).detail;\n if (this._listNavigated === navigated) {\n return;\n }\n this._listNavigated = navigated;\n // Re-fire a composed event so parent elements (e.g. a WC integration shell)\n // can disable their send control while the user navigates the list.\n this.dispatchEvent(\n new CustomEvent<AutocompleteNavigatedEventDetail>(\n 'cds-aichat-list-navigated',\n { detail: { navigated }, bubbles: true, composed: true }\n )\n );\n };\n\n private _handleTriggerChange = (event: Event): void => {\n this._controller?.handleTriggerChangeEvent(\n event as CustomEvent<\n Parameters<AutocompleteController['handleTriggerChange']>[0]\n >\n );\n };\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'cds-aichat-autocomplete-controller': AutocompleteControllerElement;\n }\n}\n\nexport default AutocompleteControllerElement;\n"],"names":[],"mappings":";;;;;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A;AADC,IAAA,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE;AACI,CAAA,EAAA,6BAAA,CAAA,SAAA,EAAA,SAAA,EAAA,MAAA,CAAA;AAIlC,UAAA,CAAA;AADC,IAAA,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE;AACI,CAAA,EAAA,6BAAA,CAAA,SAAA,EAAA,SAAA,EAAA,MAAA,CAAA;AAIlC,UAAA,CAAA;AADC,IAAA,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE;AACI,CAAA,EAAA,6BAAA,CAAA,SAAA,EAAA,cAAA,EAAA,MAAA,CAAA;AAIlC,UAAA,CAAA;AADC,IAAA,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE;AACJ,CAAA,EAAA,6BAAA,CAAA,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;AAI1B,UAAA,CAAA;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE;AACnC,CAAA,EAAA,6BAAA,CAAA,SAAA,EAAA,gBAAA,EAAA,MAAA,CAAA;AAGf,UAAA,CAAA;AADP,IAAA,KAAK;AACqE,CAAA,EAAA,6BAAA,CAAA,SAAA,EAAA,QAAA,EAAA,MAAA,CAAA;AAQnE,UAAA,CAAA;AADP,IAAA,KAAK;AACyB,CAAA,EAAA,6BAAA,CAAA,SAAA,EAAA,gBAAA,EAAA,MAAA,CAAA;AA9B3B,6BAA6B,GAAA,UAAA,CAAA;AADlC,IAAA,aAAa,CAAC,CAAA,EAAG,MAAM,CAAA,wBAAA,CAA0B;AAC5C,CAAA,EAAA,6BAA6B,CAyQlC;AAQD,4CAAe,6BAA6B;;"}
1
+ {"version":3,"file":"autocomplete-controller-element.js","sources":["../../../../src/components/prompt-line/src/autocomplete-controller-element.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { html, LitElement, nothing } from 'lit';\nimport { property, state } from 'lit/decorators.js';\n\nimport { carbonElement } from '../../../globals/decorators/carbon-element.js';\nimport prefix from '../../../globals/settings.js';\n\nimport '../autocomplete/src/autocomplete.js';\nimport type { AutocompleteNavigatedEventDetail } from '../autocomplete/src/autocomplete.js';\nimport {\n AutocompleteController,\n itemsToGroups,\n type AutocompleteControllerState,\n} from './autocomplete-controller.js';\nimport type {\n AutocompleteConfig,\n StartersConfig,\n SuggestionItem,\n TriggerSuggestionConfig,\n} from './tiptap/types.js';\n\n/**\n * `<cds-aichat-autocomplete-controller>` — drops the autocomplete overlay\n * lifecycle into a `<cds-aichat-prompt-line-shell>`'s `autocomplete-content` slot.\n *\n * Listens for `cds-aichat-trigger-change` events bubbling up from the\n * enclosing prompt-line-shell (the events are `composed: true, bubbles: true`, so\n * they reach here from inside the prompt-line's shadow root). Scoping the\n * listener to the shell — rather than `window` — keeps multiple\n * shell/controller pairs on the same page from cross-talking. Renders the\n * built-in `<cds-aichat-autocomplete>` or the active config's\n * `renderCustomList` output. Selection routes back into the originating\n * prompt-line.\n *\n * @element cds-aichat-autocomplete-controller\n * @fires cds-aichat-starter-selected — `{ text: string }` after a starter is\n * inserted into the editor; consumer triggers send.\n * @fires cds-aichat-autocomplete-item-selected — `{ item: SuggestionItem }`\n * after a suggestion item is selected. Fired in addition to type-specific callbacks.\n * @fires cds-aichat-autocomplete-item-send — `{ text: string }` when the\n * per-item send button is clicked inside the suggestion list.\n * @fires cds-aichat-list-navigated — `{ navigated: boolean }` when the user\n * starts or stops navigating the suggestion list with arrow keys. WC\n * consumers should use this to disable their send control while `navigated`\n * is `true` (the `listNavigated` getter reflects the same state).\n */\n@carbonElement(`${prefix}-autocomplete-controller`)\nclass AutocompleteControllerElement extends LitElement {\n /** `@`-style mention trigger config. */\n @property({ attribute: false })\n mention?: TriggerSuggestionConfig;\n\n /** `/`-style command trigger config. */\n @property({ attribute: false })\n command?: TriggerSuggestionConfig;\n\n /** Live-typeahead autocomplete config (no trigger character). */\n @property({ attribute: false })\n autocomplete?: AutocompleteConfig;\n\n /** Starter prompts shown when the editor is empty + focused + editable. */\n @property({ attribute: false })\n starters?: StartersConfig;\n\n /** When true, starter selection inserts text without firing the send event. */\n @property({ type: Boolean, attribute: 'is-send-disabled' })\n isSendDisabled = false;\n\n @state()\n private _state: AutocompleteControllerState = { trigger: null, items: [] };\n\n /**\n * Tracks whether the user is actively navigating inside the autocomplete\n * list. When `true`, the send button should be disabled so that Enter\n * confirms the highlighted item rather than submitting the prompt.\n */\n @state()\n private _listNavigated = false;\n\n /**\n * Returns `true` while the user is navigating inside the autocomplete list.\n * Consumers can use this to disable their send control.\n */\n get listNavigated(): boolean {\n return this._listNavigated;\n }\n\n private _controller: AutocompleteController | null = null;\n /**\n * Ancestor we subscribed `cds-aichat-trigger-change` on. Scoping the\n * listener to the enclosing `<cds-aichat-prompt-line-shell>` (rather than\n * `window`) keeps a second shell/controller pair on the same page from\n * receiving each other's events.\n */\n private _eventSource: EventTarget | null = null;\n\n // Render in light DOM so consumers' page-level CSS / portals can reach\n // any custom list element they've slotted in via renderCustomList.\n protected override createRenderRoot(): this {\n return this;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.addEventListener('mousedown', this._handleMousedown);\n this.addEventListener(\n 'cds-aichat-autocomplete-navigated',\n this._handleAutocompleteNavigated as EventListener\n );\n this._controller = new AutocompleteController({\n mention: this.mention,\n command: this.command,\n autocomplete: this.autocomplete,\n starters: this.starters,\n isSendDisabled: this.isSendDisabled,\n onStarterSelected: (text) => {\n this.dispatchEvent(\n new CustomEvent('cds-aichat-starter-selected', {\n detail: { text },\n bubbles: true,\n composed: true,\n })\n );\n },\n onChange: (next) => {\n this._state = next;\n },\n });\n // Scope to the enclosing prompt-line-shell so multiple shell/controller pairs\n // on the same page don't cross-talk. Falls back to `this` if the\n // controller is used outside a shell — in that case the consumer\n // should make sure their prompt-line bubbles events into this element.\n this._eventSource = this.closest('cds-aichat-prompt-line-shell') ?? this;\n this._eventSource.addEventListener(\n 'cds-aichat-trigger-change',\n this._handleTriggerChange as EventListener\n );\n }\n\n override disconnectedCallback(): void {\n this.removeEventListener('mousedown', this._handleMousedown);\n this.removeEventListener(\n 'cds-aichat-autocomplete-navigated',\n this._handleAutocompleteNavigated as EventListener\n );\n this._eventSource?.removeEventListener(\n 'cds-aichat-trigger-change',\n this._handleTriggerChange as EventListener\n );\n this._eventSource = null;\n this._controller?.destroy();\n this._controller = null;\n super.disconnectedCallback();\n }\n\n override updated(changed: Map<string, unknown>): void {\n if (!this._controller) {\n return;\n }\n if (\n changed.has('mention') ||\n changed.has('command') ||\n changed.has('autocomplete') ||\n changed.has('starters') ||\n changed.has('isSendDisabled')\n ) {\n this._controller.setConfigs({\n mention: this.mention,\n command: this.command,\n autocomplete: this.autocomplete,\n starters: this.starters,\n isSendDisabled: this.isSendDisabled,\n });\n }\n // Register the currently-rendered list element with the controller so\n // arrow / Enter / Escape on the editor get forwarded into it.\n const listEl =\n this.querySelector<HTMLElement>('cds-aichat-autocomplete') ??\n (this.firstElementChild instanceof HTMLElement\n ? this.firstElementChild\n : null);\n this._controller.setListElement(listEl);\n\n // Pass the editor DOM as anchorElement so the autocomplete's outside-click\n // guard treats clicks on the editor as inside-clicks (not dismissals).\n const editorDom = this._controller.getPromptLine()?.getEditor()?.view\n .dom as Element | undefined;\n const autocompleteEl = this.querySelector<\n HTMLElement & { anchorElement?: Element | null }\n >('cds-aichat-autocomplete');\n if (autocompleteEl) {\n autocompleteEl.anchorElement = editorDom ?? null;\n }\n }\n\n override render() {\n const { trigger, items, renderCustomList, disableDirectSend } = this._state;\n if (!trigger) {\n // List is gone — reset navigation state so the send button is unblocked.\n // This covers cases where the list is removed without an autocomplete\n // dismiss/select/send event (e.g. the user deletes the trigger character).\n if (this._listNavigated) {\n this._listNavigated = false;\n this.dispatchEvent(\n new CustomEvent<AutocompleteNavigatedEventDetail>(\n 'cds-aichat-list-navigated',\n { detail: { navigated: false }, bubbles: true, composed: true }\n )\n );\n // Also fire the lower-level event so send-control's shell listener fires.\n this.dispatchEvent(\n new CustomEvent<AutocompleteNavigatedEventDetail>(\n 'cds-aichat-autocomplete-navigated',\n { detail: { navigated: false }, bubbles: true, composed: true }\n )\n );\n }\n return nothing;\n }\n if (items.length === 0 && this._listNavigated) {\n this._listNavigated = false;\n this.dispatchEvent(\n new CustomEvent<AutocompleteNavigatedEventDetail>(\n 'cds-aichat-list-navigated',\n { detail: { navigated: false }, bubbles: true, composed: true }\n )\n );\n this.dispatchEvent(\n new CustomEvent<AutocompleteNavigatedEventDetail>(\n 'cds-aichat-autocomplete-navigated',\n { detail: { navigated: false }, bubbles: true, composed: true }\n )\n );\n }\n if (renderCustomList) {\n // When items are empty the built-in autocomplete element is kept mounted\n // so it can announce the zero-results state. Consumer-supplied renderers\n // are not mounted in that case: they own their own empty-state handling\n // and were not rendered before this PR.\n if (items.length === 0) {\n return nothing;\n }\n const result = renderCustomList({\n items,\n query: trigger.query,\n onDismiss: () => this._controller?.dismiss(),\n onSelect: (item) => this._selectItem(item),\n onSend: (text) => this._sendItem(text),\n });\n if (result instanceof HTMLElement) {\n return html`${result}`;\n }\n // Custom renderer returned something other than an HTMLElement (e.g.\n // a React node). Surface it on a side-channel event so React adapters\n // can portal it into place themselves.\n this.dispatchEvent(\n new CustomEvent('cds-aichat-custom-list-render', {\n detail: { reactNode: result },\n bubbles: true,\n composed: true,\n })\n );\n return nothing;\n }\n const { items: flatItems, groups } = itemsToGroups(items);\n return html`\n <cds-aichat-autocomplete\n .items=${flatItems}\n .groups=${groups}\n .disableDirectSend=${disableDirectSend}\n @cds-aichat-autocomplete-select=${(\n e: CustomEvent<{ item: SuggestionItem }>\n ) => this._selectItem(e.detail.item)}\n @cds-aichat-autocomplete-send=${(e: CustomEvent<{ text: string }>) =>\n this._sendItem(e.detail.text)}\n @cds-aichat-autocomplete-dismiss=${() => this._controller?.dismiss()}></cds-aichat-autocomplete>\n `;\n }\n\n private _selectItem(item: SuggestionItem): void {\n this._controller?.select(item);\n this.dispatchEvent(\n new CustomEvent('cds-aichat-autocomplete-item-selected', {\n detail: { item },\n bubbles: true,\n composed: true,\n })\n );\n }\n\n private _sendItem(text: string): void {\n if (this.isSendDisabled) {\n return;\n }\n this._controller?.dismiss(true);\n this.dispatchEvent(\n new CustomEvent('cds-aichat-autocomplete-item-send', {\n detail: { text },\n bubbles: true,\n composed: true,\n })\n );\n }\n\n private _handleMousedown = (event: MouseEvent): void => {\n // Prevent the autocomplete list from stealing focus from the editor.\n event.preventDefault();\n };\n\n private _handleAutocompleteNavigated = (event: Event): void => {\n const { navigated } = (\n event as CustomEvent<AutocompleteNavigatedEventDetail>\n ).detail;\n if (this._listNavigated === navigated) {\n return;\n }\n this._listNavigated = navigated;\n // Re-fire a composed event so parent elements (e.g. a WC integration shell)\n // can disable their send control while the user navigates the list.\n this.dispatchEvent(\n new CustomEvent<AutocompleteNavigatedEventDetail>(\n 'cds-aichat-list-navigated',\n { detail: { navigated }, bubbles: true, composed: true }\n )\n );\n };\n\n private _handleTriggerChange = (event: Event): void => {\n this._controller?.handleTriggerChangeEvent(\n event as CustomEvent<\n Parameters<AutocompleteController['handleTriggerChange']>[0]\n >\n );\n };\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'cds-aichat-autocomplete-controller': AutocompleteControllerElement;\n }\n}\n\nexport default AutocompleteControllerElement;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;AAOG;AAsBH;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;AAEH,IAAM,6BAA6B,GAAnC,MAAM,6BAA8B,SAAQ,UAAU,CAAA;AAAtD,IAAA,WAAA,GAAA;;;QAmBE,IAAA,CAAA,cAAc,GAAG,KAAK;QAGd,IAAA,CAAA,MAAM,GAAgC,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE;AAE1E;;;;AAIG;QAEK,IAAA,CAAA,cAAc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AA6B,CA+RlC;AAQD,4CAAe,6BAA6B;;"}
@@ -312,7 +312,6 @@ class AutocompleteController {
312
312
  { type: 'text', text: ' ' },
313
313
  ])
314
314
  .run();
315
- config?.onSelect?.(item);
316
315
  }
317
316
  else if (trigger.type === 'autocomplete') {
318
317
  const text = item.value ?? item.label;
@@ -355,7 +354,10 @@ class AutocompleteController {
355
354
  this._detachEditorKeyHandler();
356
355
  return;
357
356
  }
358
- const editorDom = this._trigger && this._listElement
357
+ // Do not bind key forwarding when items are empty: there is nothing to
358
+ // navigate, and keeping the handler bound would trap Tab, Home, End,
359
+ // arrows, and Escape while the list is mounted but shows no matches.
360
+ const editorDom = this._trigger && this._listElement && this._items.length > 0
359
361
  ? (this._promptLine?.getEditor()?.view.dom ?? null)
360
362
  : null;
361
363
  if (editorDom === this._editorDomBound) {
@@ -435,6 +437,11 @@ class AutocompleteController {
435
437
  return this._configForTrigger(trigger.type)?.disableDirectSend;
436
438
  }
437
439
  _emit() {
440
+ // Re-evaluate key-forwarding on every items change: the empty-items guard
441
+ // in _refreshEditorKeyHandler must detach the handler when items go to
442
+ // zero (the list element stays mounted for the announcement, so
443
+ // setListElement won't re-trigger the refresh).
444
+ this._refreshEditorKeyHandler();
438
445
  this._onChange({
439
446
  trigger: this._trigger,
440
447
  items: this._items,
@@ -1 +1 @@
1
- {"version":3,"file":"autocomplete-controller.js","sources":["../../../../src/components/prompt-line/src/autocomplete-controller.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/**\n * Framework-agnostic controller for the chat-input autocomplete overlay:\n * trigger-state tracking, async item resolution with stale-result protection,\n * dismissal, and selection routing back through the editor (mention/command\n * chip insertion, plain-text autocomplete, starter insert-and-send).\n *\n * Wrapped by [../../../react/hooks/useChatAutocomplete.tsx] (React hook) and\n * by the `<cds-aichat-autocomplete-controller>` element in\n * [./autocomplete-controller-element.ts] — same logic, two surfaces.\n *\n * This module stays free of `lit` and of custom-element registration. The\n * React hook imports the controller directly, so a Lit import here would hand\n * every React consumer a runtime and an element it never renders. A static\n * import check in [../../../react/__tests__/autocomplete-controller-imports.test.ts]\n * fails if either comes back.\n */\n\nimport { writeStarterStorage } from './tiptap/carbon-starter-trigger.js';\nimport { resolveShowTriggerInChip } from './tiptap/carbon-mention.js';\nimport { stripPresentationFields } from './tiptap/strip-presentation-fields.js';\nimport { resolveConfigItems } from './tiptap/resolve-config-items.js';\nimport { projectRawValue } from './tiptap/json-utils.js';\nimport { resetTriggerChangeState } from './tiptap/trigger-utils.js';\nimport type PromptLineElement from './prompt-line.js';\nimport type {\n AutocompleteConfig,\n BaseSuggestionConfig,\n CustomListProps,\n StartersConfig,\n SuggestionItem,\n SuggestionItemGroup,\n TriggerChangeEventDetail,\n TriggerSuggestionConfig,\n} from './tiptap/types.js';\n\nexport interface AutocompleteControllerOptions {\n mention?: TriggerSuggestionConfig;\n command?: TriggerSuggestionConfig;\n autocomplete?: AutocompleteConfig;\n starters?: StartersConfig;\n /** When true, starter selection inserts text without firing onStarterSelected. */\n isSendDisabled?: boolean;\n /** Called after a starter is selected and inserted; consumer triggers send. */\n onStarterSelected?: (text: string) => void;\n /** Notified whenever the overlay shape (trigger / items) changes. */\n onChange: (state: AutocompleteControllerState) => void;\n}\n\nexport interface AutocompleteControllerState {\n trigger: TriggerChangeEventDetail | null;\n items: SuggestionItem[];\n /** Consumer's `renderCustomList`, if any — resolved from the active trigger. */\n renderCustomList?: (props: CustomListProps) => HTMLElement | unknown;\n /** Forwarded from the active trigger config's `disableDirectSend`. */\n disableDirectSend?: boolean;\n}\n\n/** Structural contract for a list element that tracks explicit keyboard navigation. */\ninterface NavigableListElement {\n hasNavigated(): boolean;\n}\n\nfunction isNavigableListElement(\n el: HTMLElement\n): el is HTMLElement & NavigableListElement {\n return typeof (el as any).hasNavigated === 'function';\n}\n\nexport class AutocompleteController {\n private _mention?: TriggerSuggestionConfig;\n private _command?: TriggerSuggestionConfig;\n private _autocomplete?: AutocompleteConfig;\n private _starters?: StartersConfig;\n private _isSendDisabled: boolean;\n private _onStarterSelected?: (text: string) => void;\n private _onChange: (state: AutocompleteControllerState) => void;\n\n private _trigger: TriggerChangeEventDetail | null = null;\n private _items: SuggestionItem[] = [];\n\n /**\n * Identifies the source prompt-line of the active trigger. Set from the\n * trigger event's target (when feeding via `handleTriggerChangeEvent`) or\n * via `setPromptLine` (e.g. by the React hook, which has a stable ref).\n */\n private _promptLine: PromptLineElement | null = null;\n\n /**\n * The active suggestion-list element. Surface wrappers (React hook, WC\n * element) register this so the controller can forward Arrow/Enter/Escape\n * key events from the prompt-line editor without the user having to Tab\n * to the list.\n */\n private _listElement: HTMLElement | null = null;\n\n /**\n * Editor DOM the key-forwarding handler is currently attached to, or null\n * if not attached. Tracked separately from `_promptLine` so we always\n * detach from the exact node we attached to (the editor view can be\n * recreated underneath us).\n */\n private _editorDomBound: HTMLElement | null = null;\n\n /**\n * Monotonic counter — incremented on every new trigger / dismiss so an\n * in-flight async resolve from an older trigger cannot clobber state.\n */\n private _resolveToken = 0;\n private _destroyed = false;\n\n constructor(options: AutocompleteControllerOptions) {\n this._mention = options.mention;\n this._command = options.command;\n this._autocomplete = options.autocomplete;\n this._starters = options.starters;\n this._isSendDisabled = Boolean(options.isSendDisabled);\n this._onStarterSelected = options.onStarterSelected;\n this._onChange = options.onChange;\n }\n\n // ---------------------------------------------------------------------\n // Config / prompt-line wiring\n // ---------------------------------------------------------------------\n\n /**\n * Update any subset of configs. The active trigger (if any) is re-resolved\n * against the new configs so the visible item list stays current.\n */\n setConfigs(\n next: Partial<\n Pick<\n AutocompleteControllerOptions,\n | 'mention'\n | 'command'\n | 'autocomplete'\n | 'starters'\n | 'isSendDisabled'\n | 'onStarterSelected'\n >\n >\n ): void {\n if ('mention' in next) {\n this._mention = next.mention;\n }\n if ('command' in next) {\n this._command = next.command;\n }\n if ('autocomplete' in next) {\n this._autocomplete = next.autocomplete;\n }\n if ('starters' in next) {\n const prevIsOn = this._starters?.isOn !== false;\n const isOn = next.starters?.isOn !== false;\n this._starters = next.starters;\n // isOn toggled: push the new value into the Tiptap extension storage.\n // onTransaction is gated on editor.isFocused, so re-evaluation happens\n // immediately when the editor is focused, and on the next focus otherwise.\n if (prevIsOn !== isOn) {\n writeStarterStorage(this._promptLine?.getEditor(), { isOn });\n }\n }\n if ('isSendDisabled' in next) {\n this._isSendDisabled = Boolean(next.isSendDisabled);\n }\n if ('onStarterSelected' in next) {\n this._onStarterSelected = next.onStarterSelected;\n }\n if (this._trigger) {\n // Re-resolve items against the new configs.\n this._kickoffResolve(this._trigger);\n }\n }\n\n /** Set or clear the active prompt-line. */\n setPromptLine(promptLine: PromptLineElement | null): void {\n if (this._promptLine === promptLine) {\n return;\n }\n this._promptLine = promptLine;\n // Reconcile the isOn flag into the newly attached prompt-line's storage.\n if (promptLine) {\n writeStarterStorage(promptLine.getEditor(), {\n isOn: this._starters?.isOn !== false,\n });\n }\n // Re-evaluate the key-forwarding handler — the editor DOM we were bound\n // to may now be gone, or a new one may need binding.\n this._refreshEditorKeyHandler();\n }\n\n /** Read the currently associated prompt-line. */\n getPromptLine(): PromptLineElement | null {\n return this._promptLine;\n }\n\n /**\n * Set the active suggestion-list element. When both this and an active\n * trigger are present, ArrowUp/ArrowDown/Enter/Escape on the prompt-line\n * editor are forwarded to the list as synthetic `keydown` events.\n */\n setListElement(el: HTMLElement | null): void {\n if (this._listElement === el) {\n return;\n }\n this._listElement = el;\n this._refreshEditorKeyHandler();\n }\n\n // ---------------------------------------------------------------------\n // Trigger handling\n // ---------------------------------------------------------------------\n\n /**\n * Feed a raw `cds-aichat-trigger-change` event. The event's `target` is the\n * originating prompt-line (since the event is `composed: true, bubbles:\n * true`), so we capture it here for later selection-routing.\n */\n handleTriggerChangeEvent(\n event: CustomEvent<TriggerChangeEventDetail | null>\n ): void {\n const target = findPromptLineFromTarget(event.composedPath());\n if (target) {\n this._promptLine = target;\n }\n this.handleTriggerChange(event.detail ?? null);\n }\n\n /**\n * Feed a trigger-change detail directly. Use this when the caller already\n * has the detail object and a separate way to know which prompt-line it\n * belongs to (e.g. the React hook holds a ref).\n */\n handleTriggerChange(detail: TriggerChangeEventDetail | null): void {\n if (this._destroyed) {\n return;\n }\n this._trigger = detail;\n if (!detail) {\n this._items = [];\n this._resolveToken++;\n this._refreshEditorKeyHandler();\n this._emit();\n return;\n }\n this._kickoffResolve(detail);\n this._refreshEditorKeyHandler();\n }\n\n /**\n * Clear active trigger + items.\n *\n * @param keepCoalesced - When `true`, skip `resetTriggerChangeState` so the\n * trigger-utils coalescing layer stays active. Use this when the dismissal\n * is from a send action where the editor stays empty and focused — without\n * it, the starter trigger would immediately re-fire on the next transaction.\n */\n dismiss(keepCoalesced = false): void {\n if (this._destroyed) {\n return;\n }\n if (!this._trigger && this._items.length === 0) {\n return;\n }\n this._trigger = null;\n this._items = [];\n this._resolveToken++;\n this._refreshEditorKeyHandler();\n this._emit();\n if (!keepCoalesced) {\n const editor = this._promptLine?.getEditor();\n if (editor) {\n resetTriggerChangeState(editor);\n }\n }\n }\n\n // ---------------------------------------------------------------------\n // Selection\n // ---------------------------------------------------------------------\n\n /**\n * Apply a user selection. Routes by trigger type:\n * - starter → insert text + (if not send-disabled) fire onStarterSelected\n * - mention / command → insert chip node at trigger range\n * - autocomplete → insert plain text at trigger range\n */\n select(item: SuggestionItem): void {\n if (this._destroyed) {\n return;\n }\n const trigger = this._trigger;\n const promptLine = this._promptLine;\n const editor = promptLine?.getEditor() ?? null;\n if (!trigger || !editor) {\n this.dismiss();\n return;\n }\n\n if (trigger.type === 'starter') {\n const text = item.value ?? item.label;\n editor.commands.insertContent(text);\n this.dismiss();\n if (!this._isSendDisabled) {\n this._onStarterSelected?.(projectRawValue(editor));\n }\n return;\n }\n\n if (trigger.type === 'mention' || trigger.type === 'command') {\n const config = this._configForTrigger(trigger.type);\n const nodeName = trigger.type;\n const range = {\n from: trigger.triggerOffset,\n to: editor.state.selection.from,\n };\n editor\n .chain()\n .focus()\n .insertContentAt(range, [\n {\n type: nodeName,\n attrs: {\n id: item.id,\n label: item.label,\n value: item.value ?? item.label,\n trigger: resolveShowTriggerInChip(\n item,\n config ?? {},\n trigger.type === 'command'\n )\n ? config?.trigger\n : null,\n data: stripPresentationFields(item),\n },\n },\n { type: 'text', text: ' ' },\n ])\n .run();\n config?.onSelect?.(item);\n } else if (trigger.type === 'autocomplete') {\n const text = item.value ?? item.label;\n const range = {\n from: trigger.triggerOffset,\n to: editor.state.selection.from,\n };\n editor\n .chain()\n .focus()\n .insertContentAt(range, [{ type: 'text', text }])\n .run();\n this._autocomplete?.onSelect?.(item);\n }\n\n this.dismiss();\n }\n\n // ---------------------------------------------------------------------\n // Lifecycle\n // ---------------------------------------------------------------------\n\n destroy(): void {\n this._detachEditorKeyHandler();\n this._destroyed = true;\n this._resolveToken++;\n this._trigger = null;\n this._items = [];\n this._promptLine = null;\n this._listElement = null;\n }\n\n // ---------------------------------------------------------------------\n // Editor-DOM key forwarding\n // ---------------------------------------------------------------------\n\n /**\n * When a trigger and a list element are both active, bind a keydown\n * handler to the prompt-line editor DOM so ArrowUp / ArrowDown / Enter /\n * Escape pressed while typing get re-dispatched on the list — same effect\n * as if the list had focus, without taking focus from the editor.\n */\n private _refreshEditorKeyHandler(): void {\n if (this._destroyed) {\n this._detachEditorKeyHandler();\n return;\n }\n const editorDom =\n this._trigger && this._listElement\n ? ((this._promptLine?.getEditor()?.view.dom as HTMLElement) ?? null)\n : null;\n if (editorDom === this._editorDomBound) {\n return;\n }\n this._detachEditorKeyHandler();\n if (editorDom) {\n editorDom.addEventListener('keydown', this._handleEditorKeyDown, true);\n editorDom.addEventListener('focusout', this._handleEditorFocusOut);\n this._editorDomBound = editorDom;\n }\n }\n\n private _detachEditorKeyHandler(): void {\n if (this._editorDomBound) {\n this._editorDomBound.removeEventListener(\n 'keydown',\n this._handleEditorKeyDown,\n true\n );\n this._editorDomBound.removeEventListener(\n 'focusout',\n this._handleEditorFocusOut\n );\n this._editorDomBound = null;\n }\n }\n\n private _handleEditorKeyDown = (event: KeyboardEvent): void => {\n const { key } = event;\n const whitelist = [\n 'ArrowUp',\n 'ArrowDown',\n 'Tab',\n 'Enter',\n 'Escape',\n 'Home',\n 'End',\n ];\n\n if (!whitelist.includes(key)) {\n return;\n }\n\n const listEl = this._listElement;\n\n if (!listEl || !this._trigger) {\n return;\n }\n\n if (key === 'Enter') {\n const navigated = isNavigableListElement(listEl)\n ? listEl.hasNavigated()\n : true;\n\n if (!navigated) {\n this.dismiss();\n return; // let carbonChatEnter send the typed text\n }\n }\n\n // Stop Tiptap and the editor from acting on the same key. `capture: true`\n // (when listening) plus stopPropagation here gets us in ahead of\n // ProseMirror's own keydown handler.\n event.preventDefault();\n event.stopPropagation();\n listEl.dispatchEvent(\n new KeyboardEvent('keydown', {\n key,\n bubbles: true,\n cancelable: true,\n })\n );\n };\n\n private _handleEditorFocusOut = (event: FocusEvent): void => {\n const relatedTarget = event.relatedTarget as Node | null;\n // If focus moved into the list element (or inside it), keep the overlay\n // open — the user is interacting with it.\n if (relatedTarget && this._listElement?.contains(relatedTarget)) {\n return;\n }\n this.dismiss();\n };\n\n // ---------------------------------------------------------------------\n // Internals\n // ---------------------------------------------------------------------\n\n private _kickoffResolve(trigger: TriggerChangeEventDetail): void {\n const token = ++this._resolveToken;\n void (async () => {\n const items = await this._resolveItems(trigger);\n if (this._destroyed || this._resolveToken !== token) {\n return;\n }\n this._items = items;\n this._emit();\n })();\n }\n\n /**\n * The config backing a trigger type, or `undefined` for a type no config\n * covers. Single lookup for the class: a new trigger type is one case here,\n * not a hunt through every method that names the types.\n *\n * Callers reach the fields every config shares. The `mention`/`command`\n * overload returns the narrower type, which is what `select()` needs to read\n * `trigger` — a field `BaseSuggestionConfig` does not carry.\n */\n private _configForTrigger(\n type: 'mention' | 'command'\n ): TriggerSuggestionConfig | undefined;\n private _configForTrigger(type: string): BaseSuggestionConfig | undefined;\n private _configForTrigger(type: string): BaseSuggestionConfig | undefined {\n switch (type) {\n case 'starter':\n return this._starters;\n case 'mention':\n return this._mention;\n case 'command':\n return this._command;\n case 'autocomplete':\n return this._autocomplete;\n default:\n return undefined;\n }\n }\n\n private async _resolveItems(\n trigger: TriggerChangeEventDetail\n ): Promise<SuggestionItem[]> {\n // Starters are a fixed list shown on an empty editor, so they skip the\n // query gating and filtering every other trigger runs through.\n if (trigger.type === 'starter') {\n return this._starters?.items ?? [];\n }\n const config = this._configForTrigger(trigger.type);\n if (!config) {\n return [];\n }\n return resolveConfigItems(config, trigger.query);\n }\n\n private _resolveRenderCustomList():\n ((props: CustomListProps) => HTMLElement | unknown) | undefined {\n const trigger = this._trigger;\n if (!trigger) {\n return undefined;\n }\n return this._configForTrigger(trigger.type)?.renderCustomList;\n }\n\n private _resolveDisableDirectSend(): boolean | undefined {\n const trigger = this._trigger;\n\n if (!trigger) {\n return undefined;\n }\n\n // Mention and command always insert a chip rather than send, which is why\n // TriggerSuggestionConfig omits the field rather than defaulting it.\n if (trigger.type === 'mention' || trigger.type === 'command') {\n return true;\n }\n\n return this._configForTrigger(trigger.type)?.disableDirectSend;\n }\n\n private _emit(): void {\n this._onChange({\n trigger: this._trigger,\n items: this._items,\n renderCustomList: this._resolveRenderCustomList(),\n disableDirectSend: this._resolveDisableDirectSend(),\n });\n }\n}\n\n// ---------------------------------------------------------------------------\n// Controller helpers\n// ---------------------------------------------------------------------------\n\n/** Walks an event's composedPath looking for a `cds-aichat-prompt-line`. */\nfunction findPromptLineFromTarget(\n path: EventTarget[]\n): PromptLineElement | null {\n for (const target of path) {\n if (\n target instanceof HTMLElement &&\n target.tagName === 'CDS-AICHAT-PROMPT-LINE'\n ) {\n return target as unknown as PromptLineElement;\n }\n }\n return null;\n}\n\n/**\n * Partition a flat `SuggestionItem[]` into ungrouped items and derived\n * `SuggestionItemGroup[]` for the `<cds-aichat-autocomplete>` element.\n * Items with no `groupId` go into `items`; items with a `groupId` are\n * bucketed into groups preserving first-occurrence order. The group title\n * is taken from the first item in the bucket that carries a `groupTitle`.\n */\nexport function itemsToGroups(flat: SuggestionItem[]): {\n items: SuggestionItem[];\n groups: SuggestionItemGroup[];\n} {\n const items: SuggestionItem[] = [];\n const groupMap = new Map<string, SuggestionItemGroup>();\n const groupOrder: string[] = [];\n\n for (const item of flat) {\n if (!item.groupId) {\n items.push(item);\n continue;\n }\n let group = groupMap.get(item.groupId);\n if (!group) {\n group = {\n id: item.groupId,\n title: item.groupTitle ?? '',\n items: [],\n };\n groupMap.set(item.groupId, group);\n groupOrder.push(item.groupId);\n }\n group.items.push(item);\n }\n\n return {\n items,\n groups: groupOrder\n .map((id) => groupMap.get(id))\n .filter((g): g is SuggestionItemGroup => g !== undefined),\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;AAOG;AAEH;;;;;;;;;;;;;;;AAeG;AA+CH,SAAS,sBAAsB,CAC7B,EAAe,EAAA;AAEf,IAAA,OAAO,OAAQ,EAAU,CAAC,YAAY,KAAK,UAAU;AACvD;MAEa,sBAAsB,CAAA;AA0CjC,IAAA,WAAA,CAAY,OAAsC,EAAA;QAjC1C,IAAA,CAAA,QAAQ,GAAoC,IAAI;QAChD,IAAA,CAAA,MAAM,GAAqB,EAAE;AAErC;;;;AAIG;QACK,IAAA,CAAA,WAAW,GAA6B,IAAI;AAEpD;;;;;AAKG;QACK,IAAA,CAAA,YAAY,GAAuB,IAAI;AAE/C;;;;;AAKG;QACK,IAAA,CAAA,eAAe,GAAuB,IAAI;AAElD;;;AAGG;QACK,IAAA,CAAA,aAAa,GAAG,CAAC;QACjB,IAAA,CAAA,UAAU,GAAG,KAAK;AAmTlB,QAAA,IAAA,CAAA,oBAAoB,GAAG,CAAC,KAAoB,KAAU;AAC5D,YAAA,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK;AACrB,YAAA,MAAM,SAAS,GAAG;gBAChB,SAAS;gBACT,WAAW;gBACX,KAAK;gBACL,OAAO;gBACP,QAAQ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AAA,OAAO,IAAI;AACb;AAEA;;;;;;AAMG;AACG,SAAU,aAAa,CAAC,IAAsB,EAAA;IAIlD,MAAM,KAAK,GAAqB,EAAE;AAClC,IAAA,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA+B;IACvD,MAAM,UAAU,GAAa,EAAE;AAE/B,IAAA,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE;AACvB,QAAA,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;AACjB,YAAA,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;YAChB;QACF;QACA,IAAI,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC;QACtC,IAAI,CAAC,KAAK,EAAE;AACV,YAAA,KAAK,GAAG;gBACN,EAAE,EAAE,IAAI,CAAC,OAAO;AAChB,gBAAA,KAAK,EAAE,IAAI,CAAC,UAAU,IAAI,EAAE;AAC5B,gBAAA,KAAK,EAAE,EAAE;aACV;YACD,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC;AACjC,YAAA,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;QAC/B;AACA,QAAA,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;IACxB;IAEA,OAAO;QACL,KAAK;AACL,QAAA,MAAM,EAAE;AACL,aAAA,GAAG,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;aAC5B,MAAM,CAAC,CAAC,CAAC,KAA+B,CAAC,KAAK,SAAS,CAAC;KAC5D;AACH;;"}
1
+ {"version":3,"file":"autocomplete-controller.js","sources":["../../../../src/components/prompt-line/src/autocomplete-controller.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/**\n * Framework-agnostic controller for the chat-input autocomplete overlay:\n * trigger-state tracking, async item resolution with stale-result protection,\n * dismissal, and selection routing back through the editor (mention/command\n * chip insertion, plain-text autocomplete, starter insert-and-send).\n *\n * Wrapped by [../../../react/hooks/useChatAutocomplete.tsx] (React hook) and\n * by the `<cds-aichat-autocomplete-controller>` element in\n * [./autocomplete-controller-element.ts] — same logic, two surfaces.\n *\n * This module stays free of `lit` and of custom-element registration. The\n * React hook imports the controller directly, so a Lit import here would hand\n * every React consumer a runtime and an element it never renders. A static\n * import check in [../../../react/__tests__/autocomplete-controller-imports.test.ts]\n * fails if either comes back.\n */\n\nimport { writeStarterStorage } from './tiptap/carbon-starter-trigger.js';\nimport { resolveShowTriggerInChip } from './tiptap/carbon-mention.js';\nimport { stripPresentationFields } from './tiptap/strip-presentation-fields.js';\nimport { resolveConfigItems } from './tiptap/resolve-config-items.js';\nimport { projectRawValue } from './tiptap/json-utils.js';\nimport { resetTriggerChangeState } from './tiptap/trigger-utils.js';\nimport type PromptLineElement from './prompt-line.js';\nimport type {\n AutocompleteConfig,\n BaseSuggestionConfig,\n CustomListProps,\n StartersConfig,\n SuggestionItem,\n SuggestionItemGroup,\n TriggerChangeEventDetail,\n TriggerSuggestionConfig,\n} from './tiptap/types.js';\n\nexport interface AutocompleteControllerOptions {\n mention?: TriggerSuggestionConfig;\n command?: TriggerSuggestionConfig;\n autocomplete?: AutocompleteConfig;\n starters?: StartersConfig;\n /** When true, starter selection inserts text without firing onStarterSelected. */\n isSendDisabled?: boolean;\n /** Called after a starter is selected and inserted; consumer triggers send. */\n onStarterSelected?: (text: string) => void;\n /** Notified whenever the overlay shape (trigger / items) changes. */\n onChange: (state: AutocompleteControllerState) => void;\n}\n\nexport interface AutocompleteControllerState {\n trigger: TriggerChangeEventDetail | null;\n items: SuggestionItem[];\n /** Consumer's `renderCustomList`, if any — resolved from the active trigger. */\n renderCustomList?: (props: CustomListProps) => HTMLElement | unknown;\n /** Forwarded from the active trigger config's `disableDirectSend`. */\n disableDirectSend?: boolean;\n}\n\n/** Structural contract for a list element that tracks explicit keyboard navigation. */\ninterface NavigableListElement {\n hasNavigated(): boolean;\n}\n\nfunction isNavigableListElement(\n el: HTMLElement\n): el is HTMLElement & NavigableListElement {\n return typeof (el as any).hasNavigated === 'function';\n}\n\nexport class AutocompleteController {\n private _mention?: TriggerSuggestionConfig;\n private _command?: TriggerSuggestionConfig;\n private _autocomplete?: AutocompleteConfig;\n private _starters?: StartersConfig;\n private _isSendDisabled: boolean;\n private _onStarterSelected?: (text: string) => void;\n private _onChange: (state: AutocompleteControllerState) => void;\n\n private _trigger: TriggerChangeEventDetail | null = null;\n private _items: SuggestionItem[] = [];\n\n /**\n * Identifies the source prompt-line of the active trigger. Set from the\n * trigger event's target (when feeding via `handleTriggerChangeEvent`) or\n * via `setPromptLine` (e.g. by the React hook, which has a stable ref).\n */\n private _promptLine: PromptLineElement | null = null;\n\n /**\n * The active suggestion-list element. Surface wrappers (React hook, WC\n * element) register this so the controller can forward Arrow/Enter/Escape\n * key events from the prompt-line editor without the user having to Tab\n * to the list.\n */\n private _listElement: HTMLElement | null = null;\n\n /**\n * Editor DOM the key-forwarding handler is currently attached to, or null\n * if not attached. Tracked separately from `_promptLine` so we always\n * detach from the exact node we attached to (the editor view can be\n * recreated underneath us).\n */\n private _editorDomBound: HTMLElement | null = null;\n\n /**\n * Monotonic counter — incremented on every new trigger / dismiss so an\n * in-flight async resolve from an older trigger cannot clobber state.\n */\n private _resolveToken = 0;\n private _destroyed = false;\n\n constructor(options: AutocompleteControllerOptions) {\n this._mention = options.mention;\n this._command = options.command;\n this._autocomplete = options.autocomplete;\n this._starters = options.starters;\n this._isSendDisabled = Boolean(options.isSendDisabled);\n this._onStarterSelected = options.onStarterSelected;\n this._onChange = options.onChange;\n }\n\n // ---------------------------------------------------------------------\n // Config / prompt-line wiring\n // ---------------------------------------------------------------------\n\n /**\n * Update any subset of configs. The active trigger (if any) is re-resolved\n * against the new configs so the visible item list stays current.\n */\n setConfigs(\n next: Partial<\n Pick<\n AutocompleteControllerOptions,\n | 'mention'\n | 'command'\n | 'autocomplete'\n | 'starters'\n | 'isSendDisabled'\n | 'onStarterSelected'\n >\n >\n ): void {\n if ('mention' in next) {\n this._mention = next.mention;\n }\n if ('command' in next) {\n this._command = next.command;\n }\n if ('autocomplete' in next) {\n this._autocomplete = next.autocomplete;\n }\n if ('starters' in next) {\n const prevIsOn = this._starters?.isOn !== false;\n const isOn = next.starters?.isOn !== false;\n this._starters = next.starters;\n // isOn toggled: push the new value into the Tiptap extension storage.\n // onTransaction is gated on editor.isFocused, so re-evaluation happens\n // immediately when the editor is focused, and on the next focus otherwise.\n if (prevIsOn !== isOn) {\n writeStarterStorage(this._promptLine?.getEditor(), { isOn });\n }\n }\n if ('isSendDisabled' in next) {\n this._isSendDisabled = Boolean(next.isSendDisabled);\n }\n if ('onStarterSelected' in next) {\n this._onStarterSelected = next.onStarterSelected;\n }\n if (this._trigger) {\n // Re-resolve items against the new configs.\n this._kickoffResolve(this._trigger);\n }\n }\n\n /** Set or clear the active prompt-line. */\n setPromptLine(promptLine: PromptLineElement | null): void {\n if (this._promptLine === promptLine) {\n return;\n }\n this._promptLine = promptLine;\n // Reconcile the isOn flag into the newly attached prompt-line's storage.\n if (promptLine) {\n writeStarterStorage(promptLine.getEditor(), {\n isOn: this._starters?.isOn !== false,\n });\n }\n // Re-evaluate the key-forwarding handler — the editor DOM we were bound\n // to may now be gone, or a new one may need binding.\n this._refreshEditorKeyHandler();\n }\n\n /** Read the currently associated prompt-line. */\n getPromptLine(): PromptLineElement | null {\n return this._promptLine;\n }\n\n /**\n * Set the active suggestion-list element. When both this and an active\n * trigger are present, ArrowUp/ArrowDown/Enter/Escape on the prompt-line\n * editor are forwarded to the list as synthetic `keydown` events.\n */\n setListElement(el: HTMLElement | null): void {\n if (this._listElement === el) {\n return;\n }\n this._listElement = el;\n this._refreshEditorKeyHandler();\n }\n\n // ---------------------------------------------------------------------\n // Trigger handling\n // ---------------------------------------------------------------------\n\n /**\n * Feed a raw `cds-aichat-trigger-change` event. The event's `target` is the\n * originating prompt-line (since the event is `composed: true, bubbles:\n * true`), so we capture it here for later selection-routing.\n */\n handleTriggerChangeEvent(\n event: CustomEvent<TriggerChangeEventDetail | null>\n ): void {\n const target = findPromptLineFromTarget(event.composedPath());\n if (target) {\n this._promptLine = target;\n }\n this.handleTriggerChange(event.detail ?? null);\n }\n\n /**\n * Feed a trigger-change detail directly. Use this when the caller already\n * has the detail object and a separate way to know which prompt-line it\n * belongs to (e.g. the React hook holds a ref).\n */\n handleTriggerChange(detail: TriggerChangeEventDetail | null): void {\n if (this._destroyed) {\n return;\n }\n this._trigger = detail;\n if (!detail) {\n this._items = [];\n this._resolveToken++;\n this._refreshEditorKeyHandler();\n this._emit();\n return;\n }\n this._kickoffResolve(detail);\n this._refreshEditorKeyHandler();\n }\n\n /**\n * Clear active trigger + items.\n *\n * @param keepCoalesced - When `true`, skip `resetTriggerChangeState` so the\n * trigger-utils coalescing layer stays active. Use this when the dismissal\n * is from a send action where the editor stays empty and focused — without\n * it, the starter trigger would immediately re-fire on the next transaction.\n */\n dismiss(keepCoalesced = false): void {\n if (this._destroyed) {\n return;\n }\n if (!this._trigger && this._items.length === 0) {\n return;\n }\n this._trigger = null;\n this._items = [];\n this._resolveToken++;\n this._refreshEditorKeyHandler();\n this._emit();\n if (!keepCoalesced) {\n const editor = this._promptLine?.getEditor();\n if (editor) {\n resetTriggerChangeState(editor);\n }\n }\n }\n\n // ---------------------------------------------------------------------\n // Selection\n // ---------------------------------------------------------------------\n\n /**\n * Apply a user selection. Routes by trigger type:\n * - starter → insert text + (if not send-disabled) fire onStarterSelected\n * - mention / command → insert chip node at trigger range\n * - autocomplete → insert plain text at trigger range\n */\n select(item: SuggestionItem): void {\n if (this._destroyed) {\n return;\n }\n const trigger = this._trigger;\n const promptLine = this._promptLine;\n const editor = promptLine?.getEditor() ?? null;\n if (!trigger || !editor) {\n this.dismiss();\n return;\n }\n\n if (trigger.type === 'starter') {\n const text = item.value ?? item.label;\n editor.commands.insertContent(text);\n this.dismiss();\n if (!this._isSendDisabled) {\n this._onStarterSelected?.(projectRawValue(editor));\n }\n return;\n }\n\n if (trigger.type === 'mention' || trigger.type === 'command') {\n const config = this._configForTrigger(trigger.type);\n const nodeName = trigger.type;\n const range = {\n from: trigger.triggerOffset,\n to: editor.state.selection.from,\n };\n editor\n .chain()\n .focus()\n .insertContentAt(range, [\n {\n type: nodeName,\n attrs: {\n id: item.id,\n label: item.label,\n value: item.value ?? item.label,\n trigger: resolveShowTriggerInChip(\n item,\n config ?? {},\n trigger.type === 'command'\n )\n ? config?.trigger\n : null,\n data: stripPresentationFields(item),\n },\n },\n { type: 'text', text: ' ' },\n ])\n .run();\n } else if (trigger.type === 'autocomplete') {\n const text = item.value ?? item.label;\n const range = {\n from: trigger.triggerOffset,\n to: editor.state.selection.from,\n };\n editor\n .chain()\n .focus()\n .insertContentAt(range, [{ type: 'text', text }])\n .run();\n this._autocomplete?.onSelect?.(item);\n }\n\n this.dismiss();\n }\n\n // ---------------------------------------------------------------------\n // Lifecycle\n // ---------------------------------------------------------------------\n\n destroy(): void {\n this._detachEditorKeyHandler();\n this._destroyed = true;\n this._resolveToken++;\n this._trigger = null;\n this._items = [];\n this._promptLine = null;\n this._listElement = null;\n }\n\n // ---------------------------------------------------------------------\n // Editor-DOM key forwarding\n // ---------------------------------------------------------------------\n\n /**\n * When a trigger and a list element are both active, bind a keydown\n * handler to the prompt-line editor DOM so ArrowUp / ArrowDown / Enter /\n * Escape pressed while typing get re-dispatched on the list — same effect\n * as if the list had focus, without taking focus from the editor.\n */\n private _refreshEditorKeyHandler(): void {\n if (this._destroyed) {\n this._detachEditorKeyHandler();\n return;\n }\n // Do not bind key forwarding when items are empty: there is nothing to\n // navigate, and keeping the handler bound would trap Tab, Home, End,\n // arrows, and Escape while the list is mounted but shows no matches.\n const editorDom =\n this._trigger && this._listElement && this._items.length > 0\n ? ((this._promptLine?.getEditor()?.view.dom as HTMLElement) ?? null)\n : null;\n if (editorDom === this._editorDomBound) {\n return;\n }\n this._detachEditorKeyHandler();\n if (editorDom) {\n editorDom.addEventListener('keydown', this._handleEditorKeyDown, true);\n editorDom.addEventListener('focusout', this._handleEditorFocusOut);\n this._editorDomBound = editorDom;\n }\n }\n\n private _detachEditorKeyHandler(): void {\n if (this._editorDomBound) {\n this._editorDomBound.removeEventListener(\n 'keydown',\n this._handleEditorKeyDown,\n true\n );\n this._editorDomBound.removeEventListener(\n 'focusout',\n this._handleEditorFocusOut\n );\n this._editorDomBound = null;\n }\n }\n\n private _handleEditorKeyDown = (event: KeyboardEvent): void => {\n const { key } = event;\n const whitelist = [\n 'ArrowUp',\n 'ArrowDown',\n 'Tab',\n 'Enter',\n 'Escape',\n 'Home',\n 'End',\n ];\n\n if (!whitelist.includes(key)) {\n return;\n }\n\n const listEl = this._listElement;\n\n if (!listEl || !this._trigger) {\n return;\n }\n\n if (key === 'Enter') {\n const navigated = isNavigableListElement(listEl)\n ? listEl.hasNavigated()\n : true;\n\n if (!navigated) {\n this.dismiss();\n return; // let carbonChatEnter send the typed text\n }\n }\n\n // Stop Tiptap and the editor from acting on the same key. `capture: true`\n // (when listening) plus stopPropagation here gets us in ahead of\n // ProseMirror's own keydown handler.\n event.preventDefault();\n event.stopPropagation();\n listEl.dispatchEvent(\n new KeyboardEvent('keydown', {\n key,\n bubbles: true,\n cancelable: true,\n })\n );\n };\n\n private _handleEditorFocusOut = (event: FocusEvent): void => {\n const relatedTarget = event.relatedTarget as Node | null;\n // If focus moved into the list element (or inside it), keep the overlay\n // open — the user is interacting with it.\n if (relatedTarget && this._listElement?.contains(relatedTarget)) {\n return;\n }\n this.dismiss();\n };\n\n // ---------------------------------------------------------------------\n // Internals\n // ---------------------------------------------------------------------\n\n private _kickoffResolve(trigger: TriggerChangeEventDetail): void {\n const token = ++this._resolveToken;\n void (async () => {\n const items = await this._resolveItems(trigger);\n if (this._destroyed || this._resolveToken !== token) {\n return;\n }\n this._items = items;\n this._emit();\n })();\n }\n\n /**\n * The config backing a trigger type, or `undefined` for a type no config\n * covers. Single lookup for the class: a new trigger type is one case here,\n * not a hunt through every method that names the types.\n *\n * Callers reach the fields every config shares. The `mention`/`command`\n * overload returns the narrower type, which is what `select()` needs to read\n * `trigger` — a field `BaseSuggestionConfig` does not carry.\n */\n private _configForTrigger(\n type: 'mention' | 'command'\n ): TriggerSuggestionConfig | undefined;\n private _configForTrigger(type: string): BaseSuggestionConfig | undefined;\n private _configForTrigger(type: string): BaseSuggestionConfig | undefined {\n switch (type) {\n case 'starter':\n return this._starters;\n case 'mention':\n return this._mention;\n case 'command':\n return this._command;\n case 'autocomplete':\n return this._autocomplete;\n default:\n return undefined;\n }\n }\n\n private async _resolveItems(\n trigger: TriggerChangeEventDetail\n ): Promise<SuggestionItem[]> {\n // Starters are a fixed list shown on an empty editor, so they skip the\n // query gating and filtering every other trigger runs through.\n if (trigger.type === 'starter') {\n return this._starters?.items ?? [];\n }\n const config = this._configForTrigger(trigger.type);\n if (!config) {\n return [];\n }\n return resolveConfigItems(config, trigger.query);\n }\n\n private _resolveRenderCustomList():\n ((props: CustomListProps) => HTMLElement | unknown) | undefined {\n const trigger = this._trigger;\n if (!trigger) {\n return undefined;\n }\n return this._configForTrigger(trigger.type)?.renderCustomList;\n }\n\n private _resolveDisableDirectSend(): boolean | undefined {\n const trigger = this._trigger;\n\n if (!trigger) {\n return undefined;\n }\n\n // Mention and command always insert a chip rather than send, which is why\n // TriggerSuggestionConfig omits the field rather than defaulting it.\n if (trigger.type === 'mention' || trigger.type === 'command') {\n return true;\n }\n\n return this._configForTrigger(trigger.type)?.disableDirectSend;\n }\n\n private _emit(): void {\n // Re-evaluate key-forwarding on every items change: the empty-items guard\n // in _refreshEditorKeyHandler must detach the handler when items go to\n // zero (the list element stays mounted for the announcement, so\n // setListElement won't re-trigger the refresh).\n this._refreshEditorKeyHandler();\n this._onChange({\n trigger: this._trigger,\n items: this._items,\n renderCustomList: this._resolveRenderCustomList(),\n disableDirectSend: this._resolveDisableDirectSend(),\n });\n }\n}\n\n// ---------------------------------------------------------------------------\n// Controller helpers\n// ---------------------------------------------------------------------------\n\n/** Walks an event's composedPath looking for a `cds-aichat-prompt-line`. */\nfunction findPromptLineFromTarget(\n path: EventTarget[]\n): PromptLineElement | null {\n for (const target of path) {\n if (\n target instanceof HTMLElement &&\n target.tagName === 'CDS-AICHAT-PROMPT-LINE'\n ) {\n return target as unknown as PromptLineElement;\n }\n }\n return null;\n}\n\n/**\n * Partition a flat `SuggestionItem[]` into ungrouped items and derived\n * `SuggestionItemGroup[]` for the `<cds-aichat-autocomplete>` element.\n * Items with no `groupId` go into `items`; items with a `groupId` are\n * bucketed into groups preserving first-occurrence order. The group title\n * is taken from the first item in the bucket that carries a `groupTitle`.\n */\nexport function itemsToGroups(flat: SuggestionItem[]): {\n items: SuggestionItem[];\n groups: SuggestionItemGroup[];\n} {\n const items: SuggestionItem[] = [];\n const groupMap = new Map<string, SuggestionItemGroup>();\n const groupOrder: string[] = [];\n\n for (const item of flat) {\n if (!item.groupId) {\n items.push(item);\n continue;\n }\n let group = groupMap.get(item.groupId);\n if (!group) {\n group = {\n id: item.groupId,\n title: item.groupTitle ?? '',\n items: [],\n };\n groupMap.set(item.groupId, group);\n groupOrder.push(item.groupId);\n }\n group.items.push(item);\n }\n\n return {\n items,\n groups: groupOrder\n .map((id) => groupMap.get(id))\n .filter((g): g is SuggestionItemGroup => g !== undefined),\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;AAOG;AAEH;;;;;;;;;;;;;;;AAeG;AA+CH,SAAS,sBAAsB,CAC7B,EAAe,EAAA;AAEf,IAAA,OAAO,OAAQ,EAAU,CAAC,YAAY,KAAK,UAAU;AACvD;MAEa,sBAAsB,CAAA;AA0CjC,IAAA,WAAA,CAAY,OAAsC,EAAA;QAjC1C,IAAA,CAAA,QAAQ,GAAoC,IAAI;QAChD,IAAA,CAAA,MAAM,GAAqB,EAAE;AAErC;;;;AAIG;QACK,IAAA,CAAA,WAAW,GAA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AAI,CAAC;IACxB;IAEA,OAAO;QACL,KAAK;AACL,QAAA,MAAM,EAAE;AACL,aAAA,GAAG,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;aAC5B,MAAM,CAAC,CAAC,CAAC,KAA+B,CAAC,KAAK,SAAS,CAAC;KAC5D;AACH;;"}
@@ -110,6 +110,13 @@ export interface PromptLineController {
110
110
  setComposing(composing: boolean): void;
111
111
  undo(): boolean;
112
112
  redo(): boolean;
113
+ /**
114
+ * Drops the editor's undo and redo history, keeping the live editor,
115
+ * its focus, and its plugin state. Emits Tiptap's `transaction` event but
116
+ * no `update`, value-change, typing, or token events. No-op in plain
117
+ * textarea mode.
118
+ */
119
+ resetHistory(): void;
113
120
  /** Whether the most recent focus event was driven by keyboard (not pointer/touch-driven). */
114
121
  getKeyboardFocus(): boolean;
115
122
  }
@@ -12,6 +12,7 @@ import ParagraphNode from '@tiptap/extension-paragraph';
12
12
  import Placeholder from '@tiptap/extension-placeholder';
13
13
  import TextNode from '@tiptap/extension-text';
14
14
  import { UndoRedo } from '@tiptap/extensions';
15
+ import { closeHistory } from '@tiptap/pm/history';
15
16
  import { IS_PHONE } from '../../../globals/utils/browser-utils.js';
16
17
  import { MouseFocusController } from './prompt-line-mouse-focus.js';
17
18
  import { applyEditorStyles } from './tiptap/editor-styles.js';
@@ -156,10 +157,14 @@ class RichController extends MouseFocusController {
156
157
  // firing `onRemove`. Otherwise a send would strip the just-captured
157
158
  // mention/command fields from the host's structured_data sidecar before
158
159
  // `doSend` merges them. Mirrors `_dispatchSetContent`.
160
+ //
161
+ // closeHistory() breaks the grouping window so the clear lands in its own
162
+ // undo step, keeping any prior user edits individually reachable.
159
163
  editor
160
164
  .chain()
161
165
  .command(({ tr }) => {
162
166
  setHostOriginMeta(tr);
167
+ closeHistory(tr);
163
168
  return true;
164
169
  })
165
170
  .clearContent(true)
@@ -262,6 +267,18 @@ class RichController extends MouseFocusController {
262
267
  redo() {
263
268
  return Boolean(this._editor?.commands.redo());
264
269
  }
270
+ resetHistory() {
271
+ const editor = this._editor;
272
+ if (!editor || editor.isDestroyed) {
273
+ return;
274
+ }
275
+ const plugin = editor.state.plugins.find((p) => p.key.startsWith('history$'));
276
+ const historyState = plugin?.spec.state?.init(plugin.spec.config, editor.state);
277
+ if (!plugin || !historyState) {
278
+ return;
279
+ }
280
+ editor.view.dispatch(setHostOriginMeta(editor.state.tr.setMeta(plugin, { historyState })));
281
+ }
265
282
  // -------------------------------------------------------------------------
266
283
  // Internals
267
284
  // -------------------------------------------------------------------------
@@ -1 +1 @@
1
- {"version":3,"file":"prompt-line-rich-runtime.js","sources":["../../../../src/components/prompt-line/src/prompt-line-rich-runtime.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/**\n * Tiptap runtime for `<cds-aichat-prompt-line>`'s rich mode. This module is the\n * **only** place the prompt-line stack imports `@tiptap/*` at runtime, and it\n * is reached exclusively through a dynamic `import()` (see\n * [./prompt-line-rich-loader.ts]). A bundler therefore splits Tiptap into its\n * own lazy chunk, keeping it out of the default bundle for chats that never\n * enable advanced input features.\n *\n * `createRichController()` returns a {@link PromptLineController} backed by a\n * Tiptap `Editor`. It installs the Carbon base bundle — schema (`Document` +\n * `Paragraph` + `Text` + `HardBreak`), undo/redo, placeholder, plain-text\n * paste, the chat keymap (`Mod-Enter`/`Escape`), Enter-to-send\n * (`carbonChatEnter`), value-sync, and the typing indicator — and emits the\n * identical\n * `cds-aichat-prompt-*` events so the shell, React wrapper, and `Input`\n * handlers are mode-agnostic.\n */\n\nimport { Editor, type Extension, type JSONContent } from '@tiptap/core';\nimport DocumentNode from '@tiptap/extension-document';\nimport HardBreakNode from '@tiptap/extension-hard-break';\nimport ParagraphNode from '@tiptap/extension-paragraph';\nimport Placeholder from '@tiptap/extension-placeholder';\nimport TextNode from '@tiptap/extension-text';\nimport { UndoRedo } from '@tiptap/extensions';\n\nimport { IS_PHONE } from '../../../globals/utils/browser-utils.js';\nimport { MouseFocusController } from './prompt-line-mouse-focus.js';\nimport type {\n PromptLineController,\n PromptLineControllerInit,\n SetContentUpdater,\n} from './prompt-line-controller.js';\nimport { applyEditorStyles } from './tiptap/editor-styles.js';\nimport { HISTORY_DEFAULTS } from './prompt-line-constants.js';\nimport { writeStarterStorage } from './tiptap/carbon-starter-trigger.js';\nimport {\n areExtensionSetsEquivalent,\n getExtensionSource,\n} from './tiptap/extension-equivalence.js';\nimport { carbonChatEnter } from './tiptap/chat-enter.js';\nimport { Keymap } from './tiptap/keymap.js';\nimport { PlainTextPaste } from './tiptap/plain-text-paste.js';\nimport { TypingIndicator } from './tiptap/typing-indicator.js';\nimport { ValueSync } from './tiptap/value-sync.js';\nimport type { StartersConfig } from './tiptap/types.js';\nimport { textToDoc } from './tiptap/json-utils.js';\nimport { setHostOriginMeta } from './tiptap/origin-meta.js';\n\n/**\n * Tiptap-backed prompt-line controller. Mirrors the editor lifecycle the\n * element owned before the textarea/rich split.\n */\nclass RichController\n extends MouseFocusController\n implements PromptLineController\n{\n private _editor: Editor | null = null;\n private _host: HTMLElement | null = null;\n private _extensions: Extension[] = [];\n /**\n * The set the live editor was built from. `_createEditor` assigns it the same\n * reference as `_extensions`, so the two are normally identical; they diverge\n * only between a `setExtensions` that adopted an equivalent set without\n * rebuilding and the next `_createEditor`. Only `_flushPendingRecreate` needs\n * the distinction: a rebuild withheld for a composition has to be judged\n * against what is installed, not against the set that was pending when the\n * composition began, or a host that changed the config and changed it back\n * loses its undo history for nothing.\n */\n private _installedExtensions: Extension[] = [];\n private _ariaLabel = '';\n private _placeholder = '';\n private _testId = '';\n private _disabled = false;\n private _isComposing = false;\n private _hadFocus = false;\n /** Set when a recreate is withheld during an IME composition. */\n private _pendingRecreate = false;\n private _pendingRecreateTimer: ReturnType<typeof setTimeout> | null = null;\n\n mount(host: HTMLElement, init: PromptLineControllerInit): void {\n this._host = host;\n this._extensions = init.extensions ?? [];\n this._ariaLabel = init.ariaLabel;\n this._placeholder = init.placeholder;\n this._testId = init.testId;\n this._disabled = init.disabled;\n\n host.setAttribute('aria-multiline', 'true');\n host.setAttribute('spellcheck', 'true');\n host.setAttribute('tabindex', '-1');\n\n // Pointer/touch before focus marks the next focus as mouse-driven so we\n // suppress the keyboard-focus outline.\n this._attachMouseFocusListeners(host);\n\n // Prefer a structured `content` seed (mentions / custom nodes); otherwise\n // rebuild a doc from the plain-text value (lossless from the textarea).\n const seed = init.content ?? textToDoc(init.value);\n this._editor = this._createEditor(host, seed);\n this._wireEditorEvents(this._editor);\n applyEditorStyles(this._editor.view.dom as HTMLElement, IS_PHONE);\n this._applyTestIdToEditorDom();\n this._editor.setEditable(!this._disabled);\n }\n\n destroy(): void {\n const host = this._host;\n if (host) {\n this._detachMouseFocusListeners(host);\n }\n if (this._pendingRecreateTimer) {\n clearTimeout(this._pendingRecreateTimer);\n this._pendingRecreateTimer = null;\n }\n this._isComposing = false;\n this._hadFocus = false;\n this._pendingRecreate = false;\n this._editor?.destroy();\n this._editor = null;\n this._host = null;\n }\n\n getValue(): string {\n return this._editor?.getText() ?? '';\n }\n\n setContent(next: JSONContent | string | SetContentUpdater): void {\n const editor = this._editor;\n if (!editor) {\n return;\n }\n if (typeof next === 'function') {\n const prev = editor.getJSON();\n this._dispatchSetContent((next as SetContentUpdater)(prev));\n return;\n }\n this._dispatchSetContent(next);\n }\n\n insertContent(\n content: JSONContent | string,\n opts: { at?: number } = {}\n ): void {\n const editor = this._editor;\n if (!editor) {\n return;\n }\n if (typeof opts.at === 'number') {\n editor.commands.insertContentAt(opts.at, content);\n return;\n }\n editor.commands.insertContent(content);\n }\n\n clearContent(): void {\n const editor = this._editor;\n if (!editor) {\n return;\n }\n // Tag the clear as host-origin so the carbon-mention/command removal plugin\n // treats the post-send wipe as programmatic (not a user edit) and skips\n // firing `onRemove`. Otherwise a send would strip the just-captured\n // mention/command fields from the host's structured_data sidecar before\n // `doSend` merges them. Mirrors `_dispatchSetContent`.\n editor\n .chain()\n .command(({ tr }) => {\n setHostOriginMeta(tr);\n return true;\n })\n .clearContent(true)\n .run();\n }\n\n getEditor(): Editor | null {\n return this._editor;\n }\n\n focus(keyboardFocus: boolean, synchronous = false): void {\n this._setNextFocusOrigin(keyboardFocus);\n if (synchronous) {\n // Reparent restoration must not queue focus that could steal it later.\n this._editor?.view.focus();\n } else {\n this._editor?.commands.focus();\n }\n }\n\n blur(): void {\n this._editor?.commands.blur();\n }\n\n hasFocus(): boolean {\n return this._editor?.isFocused ?? false;\n }\n\n getSelection(): { from: number; to: number } {\n const sel = this._editor?.state.selection;\n return sel ? { from: sel.from, to: sel.to } : { from: 0, to: 0 };\n }\n\n setTextSelection(pos: number | { from: number; to: number }): void {\n this._editor?.commands.setTextSelection(pos);\n }\n\n selectAll(): void {\n this._editor?.commands.selectAll();\n }\n\n setEditable(editable: boolean): void {\n this._disabled = !editable;\n this._editor?.setEditable(editable);\n }\n\n setPlaceholder(placeholder: string): void {\n this._placeholder = placeholder;\n // The Placeholder extension reads this back through the resolver installed\n // in `_createEditor`; the empty transaction repaints the decoration so the\n // new text shows without waiting for the next edit.\n const editor = this._editor;\n if (editor) {\n editor.view.dispatch(editor.state.tr);\n }\n }\n\n setAriaLabel(ariaLabel: string): void {\n this._ariaLabel = ariaLabel;\n }\n\n setTestId(testId: string): void {\n this._testId = testId;\n this._applyTestIdToEditorDom();\n }\n\n setExtensions(extensions: Extension[]): void {\n const equivalent = areExtensionSetsEquivalent(this._extensions, extensions);\n // Adopt the new list either way — a later genuine change is compared\n // against what the host most recently supplied.\n this._extensions = extensions;\n if (equivalent) {\n // Starter items / isOn ride on extension storage precisely so they can be\n // swapped without a recreate.\n this._syncStarterStorage();\n return;\n }\n this._recreateEditor();\n }\n\n setComposing(composing: boolean): void {\n this._isComposing = composing;\n if (composing || !this._pendingRecreate || this._pendingRecreateTimer) {\n return;\n }\n // ProseMirror defers the last composed segment to a microtask after\n // compositionend, so recreating here would snapshot the doc without it and\n // lose the character the user just committed. A macrotask runs after that\n // flush.\n this._pendingRecreateTimer = setTimeout(() => {\n this._pendingRecreateTimer = null;\n this._flushPendingRecreate();\n });\n }\n\n /** Push the current starter config onto the live editor's storage. */\n private _syncStarterStorage(): void {\n const source = this._extensions\n .map(getExtensionSource)\n .find((descriptor) => descriptor?.kind === 'starters');\n const config = source?.config as StartersConfig | undefined;\n if (!config) {\n return;\n }\n writeStarterStorage(this._editor, {\n items: config.items,\n isOn: config.isOn !== false,\n });\n }\n\n undo(): boolean {\n return Boolean(this._editor?.commands.undo());\n }\n\n redo(): boolean {\n return Boolean(this._editor?.commands.redo());\n }\n\n // -------------------------------------------------------------------------\n // Internals\n // -------------------------------------------------------------------------\n\n private _flushPendingRecreate(): void {\n // A fresh composition may have started while the flush was queued; its own\n // compositionend re-queues this. A detached host means the element's own\n // deferred teardown is already pending, so rebuilding would raise an editor\n // only to destroy it a task later.\n if (\n !this._host?.isConnected ||\n !this._pendingRecreate ||\n this._isComposing\n ) {\n return;\n }\n // Compare against what is installed, not the set that was pending when the\n // composition began: a host that changed the config and changed it back has\n // nothing left to rebuild, and rebuilding anyway would drop undo history.\n if (\n areExtensionSetsEquivalent(this._installedExtensions, this._extensions)\n ) {\n this._pendingRecreate = false;\n this._syncStarterStorage();\n return;\n }\n this._recreateEditor();\n }\n\n private _createEditor(\n element: HTMLElement,\n content: JSONContent | string | undefined\n ): Editor {\n const baseExtensions: Extension[] = [\n DocumentNode as unknown as Extension,\n ParagraphNode as unknown as Extension,\n TextNode as unknown as Extension,\n HardBreakNode as unknown as Extension,\n UndoRedo.configure({ ...HISTORY_DEFAULTS }),\n // Resolved per decoration build rather than captured, so `setPlaceholder`\n // lands on the live editor. Tiptap snapshots an extension's options when\n // it builds plugins, so a value here could never be updated in place.\n Placeholder.configure({ placeholder: () => this._placeholder }),\n PlainTextPaste,\n Keymap,\n // Plain Enter sends (non-empty); empty Enter falls through to a newline.\n // Baked into the base bundle so the rich editor and the textarea agree on\n // Enter-to-send without the chat layer wiring it per surface.\n carbonChatEnter(),\n ValueSync,\n TypingIndicator,\n ];\n this._installedExtensions = this._extensions;\n return new Editor({\n element,\n extensions: [...baseExtensions, ...this._extensions],\n editorProps: {\n attributes: () => {\n const attrs: Record<string, string> = { role: 'textbox' };\n if (this._ariaLabel) {\n attrs['aria-label'] = this._ariaLabel;\n }\n if (this._placeholder) {\n attrs['aria-placeholder'] = this._placeholder;\n }\n return attrs;\n },\n },\n content: content ?? undefined,\n autofocus: false,\n injectCSS: false,\n });\n }\n\n private _wireEditorEvents(editor: Editor): void {\n editor.on('focus', () => {\n this._hadFocus = true;\n const wasMouseFocus = this._consumeMouseFocus();\n this._dispatch('cds-aichat-prompt-focus', { keyboard: !wasMouseFocus });\n });\n editor.on('blur', () => {\n this._dispatch('cds-aichat-prompt-blur');\n });\n // Forward keydown for hosts wanting raw-key access. ValueSync /\n // TypingIndicator emit their own events; don't re-dispatch update here.\n editor.view.dom.addEventListener('keydown', (event) => {\n this._dispatch('cds-aichat-prompt-keydown', { originalEvent: event });\n });\n }\n\n private _recreateEditor(): void {\n const host = this._host;\n if (!host) {\n return;\n }\n if (this._isComposing) {\n this._pendingRecreate = true;\n return;\n }\n this._pendingRecreate = false;\n const previousJson = this._editor?.getJSON();\n const previousSelection = this._editor\n ? {\n from: this._editor.state.selection.from,\n to: this._editor.state.selection.to,\n }\n : null;\n const wasFocused = this._hadFocus;\n const wasKeyboardFocus = this.getKeyboardFocus();\n this._editor?.destroy();\n this._editor = this._createEditor(host, previousJson);\n this._wireEditorEvents(this._editor);\n applyEditorStyles(this._editor.view.dom as HTMLElement, IS_PHONE);\n this._applyTestIdToEditorDom();\n this._editor.setEditable(!this._disabled);\n if (previousSelection) {\n const { size } = this._editor.state.doc.content;\n const from = Math.min(previousSelection.from, size);\n const to = Math.min(previousSelection.to, size);\n this._editor.commands.setTextSelection({ from, to });\n }\n\n if (wasFocused) {\n this.focus(wasKeyboardFocus);\n }\n }\n\n private _dispatchSetContent(content: JSONContent | string): void {\n const editor = this._editor;\n if (!editor) {\n return;\n }\n // Chain a no-op command that meta-tags the accumulator tr as host-origin,\n // then setContent on the same tr so downstream readers (typing-indicator)\n // recognize the update.\n editor\n .chain()\n .command(({ tr }) => {\n setHostOriginMeta(tr);\n return true;\n })\n .setContent(content, { emitUpdate: true })\n .run();\n }\n\n // Mirror testId onto the inner ProseMirror contenteditable (not the host\n // wrapper) so Playwright's editable-action helpers (`.fill()`, etc.) accept\n // it. `view.dom` is replaced on each recreate, so re-apply.\n private _applyTestIdToEditorDom(): void {\n const editorDom = this._editor?.view.dom as HTMLElement | undefined;\n if (!editorDom) {\n return;\n }\n if (this._testId) {\n editorDom.setAttribute('data-testid', this._testId);\n } else {\n editorDom.removeAttribute('data-testid');\n }\n }\n\n private _dispatch(name: string, detail?: unknown): void {\n this._host?.dispatchEvent(\n new CustomEvent(name, { detail, bubbles: true, composed: true })\n );\n }\n}\n\n/**\n * Construct a Tiptap-backed prompt-line controller. Called by the shell once\n * the lazily-imported runtime module has resolved.\n */\nexport function createRichController(): PromptLineController {\n return new RichController();\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;AAOG;AAEH;;;;;;;;;;;;;;;;AAgBG;AAiCH;;;AAGG;AACH,MAAM,cACJ,SAAQ,oBAAoB,CAAA;AAD9B,IAAA,WAAA,GAAA;;QAIU,IAAA,CAAA,OAAO,GAAkB,IAAI;QAC7B,IAAA,CAAA,KAAK,GAAuB,IAAI;QAChC,IAAA,CAAA,WAAW,GAAgB,EAAE;AACrC;;;;;;;;;AASG;QACK,IAAA,CAAA,oBAAoB,GAAgB,EAAE;QACtC,IAAA,CAAA,UAAU,GAAG,EAAE;QACf,IAAA,CAAA,YAAY,GAAG,EAAE;QACjB,IAAA,CAAA,OAAO,GAAG,EAAE;QACZ,IAAA,CAAA,SAAS,GAAG,KAAK;QACjB,IAAA,CAAA,YAAY,GA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C;QACrD;aAAO;AACL,YAAA,SAAS,CAAC,eAAe,CAAC,aAAa,CAAC;QAC1C;IACF;IAEQ,SAAS,CAAC,IAAY,EAAE,MAAgB,EAAA;QAC9C,IAAI,CAAC,KAAK,EAAE,aAAa,CACvB,IAAI,WAAW,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CACjE;IACH;AACD;AAED;;;AAGG;SACa,oBAAoB,GAAA;IAClC,OAAO,IAAI,cAAc,EAAE;AAC7B;;"}
1
+ {"version":3,"file":"prompt-line-rich-runtime.js","sources":["../../../../src/components/prompt-line/src/prompt-line-rich-runtime.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/**\n * Tiptap runtime for `<cds-aichat-prompt-line>`'s rich mode. This module is the\n * **only** place the prompt-line stack imports `@tiptap/*` at runtime, and it\n * is reached exclusively through a dynamic `import()` (see\n * [./prompt-line-rich-loader.ts]). A bundler therefore splits Tiptap into its\n * own lazy chunk, keeping it out of the default bundle for chats that never\n * enable advanced input features.\n *\n * `createRichController()` returns a {@link PromptLineController} backed by a\n * Tiptap `Editor`. It installs the Carbon base bundle — schema (`Document` +\n * `Paragraph` + `Text` + `HardBreak`), undo/redo, placeholder, plain-text\n * paste, the chat keymap (`Mod-Enter`/`Escape`), Enter-to-send\n * (`carbonChatEnter`), value-sync, and the typing indicator — and emits the\n * identical\n * `cds-aichat-prompt-*` events so the shell, React wrapper, and `Input`\n * handlers are mode-agnostic.\n */\n\nimport { Editor, type Extension, type JSONContent } from '@tiptap/core';\nimport DocumentNode from '@tiptap/extension-document';\nimport HardBreakNode from '@tiptap/extension-hard-break';\nimport ParagraphNode from '@tiptap/extension-paragraph';\nimport Placeholder from '@tiptap/extension-placeholder';\nimport TextNode from '@tiptap/extension-text';\nimport { UndoRedo } from '@tiptap/extensions';\nimport { closeHistory } from '@tiptap/pm/history';\n\nimport { IS_PHONE } from '../../../globals/utils/browser-utils.js';\nimport { MouseFocusController } from './prompt-line-mouse-focus.js';\nimport type {\n PromptLineController,\n PromptLineControllerInit,\n SetContentUpdater,\n} from './prompt-line-controller.js';\nimport { applyEditorStyles } from './tiptap/editor-styles.js';\nimport { HISTORY_DEFAULTS } from './prompt-line-constants.js';\nimport { writeStarterStorage } from './tiptap/carbon-starter-trigger.js';\nimport {\n areExtensionSetsEquivalent,\n getExtensionSource,\n} from './tiptap/extension-equivalence.js';\nimport { carbonChatEnter } from './tiptap/chat-enter.js';\nimport { Keymap } from './tiptap/keymap.js';\nimport { PlainTextPaste } from './tiptap/plain-text-paste.js';\nimport { TypingIndicator } from './tiptap/typing-indicator.js';\nimport { ValueSync } from './tiptap/value-sync.js';\nimport type { StartersConfig } from './tiptap/types.js';\nimport { textToDoc } from './tiptap/json-utils.js';\nimport { setHostOriginMeta } from './tiptap/origin-meta.js';\n\n/**\n * Tiptap-backed prompt-line controller. Mirrors the editor lifecycle the\n * element owned before the textarea/rich split.\n */\nclass RichController\n extends MouseFocusController\n implements PromptLineController\n{\n private _editor: Editor | null = null;\n private _host: HTMLElement | null = null;\n private _extensions: Extension[] = [];\n /**\n * The set the live editor was built from. `_createEditor` assigns it the same\n * reference as `_extensions`, so the two are normally identical; they diverge\n * only between a `setExtensions` that adopted an equivalent set without\n * rebuilding and the next `_createEditor`. Only `_flushPendingRecreate` needs\n * the distinction: a rebuild withheld for a composition has to be judged\n * against what is installed, not against the set that was pending when the\n * composition began, or a host that changed the config and changed it back\n * loses its undo history for nothing.\n */\n private _installedExtensions: Extension[] = [];\n private _ariaLabel = '';\n private _placeholder = '';\n private _testId = '';\n private _disabled = false;\n private _isComposing = false;\n private _hadFocus = false;\n /** Set when a recreate is withheld during an IME composition. */\n private _pendingRecreate = false;\n private _pendingRecreateTimer: ReturnType<typeof setTimeout> | null = null;\n\n mount(host: HTMLElement, init: PromptLineControllerInit): void {\n this._host = host;\n this._extensions = init.extensions ?? [];\n this._ariaLabel = init.ariaLabel;\n this._placeholder = init.placeholder;\n this._testId = init.testId;\n this._disabled = init.disabled;\n\n host.setAttribute('aria-multiline', 'true');\n host.setAttribute('spellcheck', 'true');\n host.setAttribute('tabindex', '-1');\n\n // Pointer/touch before focus marks the next focus as mouse-driven so we\n // suppress the keyboard-focus outline.\n this._attachMouseFocusListeners(host);\n\n // Prefer a structured `content` seed (mentions / custom nodes); otherwise\n // rebuild a doc from the plain-text value (lossless from the textarea).\n const seed = init.content ?? textToDoc(init.value);\n this._editor = this._createEditor(host, seed);\n this._wireEditorEvents(this._editor);\n applyEditorStyles(this._editor.view.dom as HTMLElement, IS_PHONE);\n this._applyTestIdToEditorDom();\n this._editor.setEditable(!this._disabled);\n }\n\n destroy(): void {\n const host = this._host;\n if (host) {\n this._detachMouseFocusListeners(host);\n }\n if (this._pendingRecreateTimer) {\n clearTimeout(this._pendingRecreateTimer);\n this._pendingRecreateTimer = null;\n }\n this._isComposing = false;\n this._hadFocus = false;\n this._pendingRecreate = false;\n this._editor?.destroy();\n this._editor = null;\n this._host = null;\n }\n\n getValue(): string {\n return this._editor?.getText() ?? '';\n }\n\n setContent(next: JSONContent | string | SetContentUpdater): void {\n const editor = this._editor;\n if (!editor) {\n return;\n }\n if (typeof next === 'function') {\n const prev = editor.getJSON();\n this._dispatchSetContent((next as SetContentUpdater)(prev));\n return;\n }\n this._dispatchSetContent(next);\n }\n\n insertContent(\n content: JSONContent | string,\n opts: { at?: number } = {}\n ): void {\n const editor = this._editor;\n if (!editor) {\n return;\n }\n if (typeof opts.at === 'number') {\n editor.commands.insertContentAt(opts.at, content);\n return;\n }\n editor.commands.insertContent(content);\n }\n\n clearContent(): void {\n const editor = this._editor;\n if (!editor) {\n return;\n }\n // Tag the clear as host-origin so the carbon-mention/command removal plugin\n // treats the post-send wipe as programmatic (not a user edit) and skips\n // firing `onRemove`. Otherwise a send would strip the just-captured\n // mention/command fields from the host's structured_data sidecar before\n // `doSend` merges them. Mirrors `_dispatchSetContent`.\n //\n // closeHistory() breaks the grouping window so the clear lands in its own\n // undo step, keeping any prior user edits individually reachable.\n editor\n .chain()\n .command(({ tr }) => {\n setHostOriginMeta(tr);\n closeHistory(tr);\n return true;\n })\n .clearContent(true)\n .run();\n }\n\n getEditor(): Editor | null {\n return this._editor;\n }\n\n focus(keyboardFocus: boolean, synchronous = false): void {\n this._setNextFocusOrigin(keyboardFocus);\n if (synchronous) {\n // Reparent restoration must not queue focus that could steal it later.\n this._editor?.view.focus();\n } else {\n this._editor?.commands.focus();\n }\n }\n\n blur(): void {\n this._editor?.commands.blur();\n }\n\n hasFocus(): boolean {\n return this._editor?.isFocused ?? false;\n }\n\n getSelection(): { from: number; to: number } {\n const sel = this._editor?.state.selection;\n return sel ? { from: sel.from, to: sel.to } : { from: 0, to: 0 };\n }\n\n setTextSelection(pos: number | { from: number; to: number }): void {\n this._editor?.commands.setTextSelection(pos);\n }\n\n selectAll(): void {\n this._editor?.commands.selectAll();\n }\n\n setEditable(editable: boolean): void {\n this._disabled = !editable;\n this._editor?.setEditable(editable);\n }\n\n setPlaceholder(placeholder: string): void {\n this._placeholder = placeholder;\n // The Placeholder extension reads this back through the resolver installed\n // in `_createEditor`; the empty transaction repaints the decoration so the\n // new text shows without waiting for the next edit.\n const editor = this._editor;\n if (editor) {\n editor.view.dispatch(editor.state.tr);\n }\n }\n\n setAriaLabel(ariaLabel: string): void {\n this._ariaLabel = ariaLabel;\n }\n\n setTestId(testId: string): void {\n this._testId = testId;\n this._applyTestIdToEditorDom();\n }\n\n setExtensions(extensions: Extension[]): void {\n const equivalent = areExtensionSetsEquivalent(this._extensions, extensions);\n // Adopt the new list either way — a later genuine change is compared\n // against what the host most recently supplied.\n this._extensions = extensions;\n if (equivalent) {\n // Starter items / isOn ride on extension storage precisely so they can be\n // swapped without a recreate.\n this._syncStarterStorage();\n return;\n }\n this._recreateEditor();\n }\n\n setComposing(composing: boolean): void {\n this._isComposing = composing;\n if (composing || !this._pendingRecreate || this._pendingRecreateTimer) {\n return;\n }\n // ProseMirror defers the last composed segment to a microtask after\n // compositionend, so recreating here would snapshot the doc without it and\n // lose the character the user just committed. A macrotask runs after that\n // flush.\n this._pendingRecreateTimer = setTimeout(() => {\n this._pendingRecreateTimer = null;\n this._flushPendingRecreate();\n });\n }\n\n /** Push the current starter config onto the live editor's storage. */\n private _syncStarterStorage(): void {\n const source = this._extensions\n .map(getExtensionSource)\n .find((descriptor) => descriptor?.kind === 'starters');\n const config = source?.config as StartersConfig | undefined;\n if (!config) {\n return;\n }\n writeStarterStorage(this._editor, {\n items: config.items,\n isOn: config.isOn !== false,\n });\n }\n\n undo(): boolean {\n return Boolean(this._editor?.commands.undo());\n }\n\n redo(): boolean {\n return Boolean(this._editor?.commands.redo());\n }\n\n resetHistory(): void {\n const editor = this._editor;\n if (!editor || editor.isDestroyed) {\n return;\n }\n\n const plugin = editor.state.plugins.find((p) =>\n (p as unknown as { key: string }).key.startsWith('history$')\n );\n const historyState = plugin?.spec.state?.init(\n plugin.spec.config,\n editor.state\n );\n if (!plugin || !historyState) {\n return;\n }\n editor.view.dispatch(\n setHostOriginMeta(editor.state.tr.setMeta(plugin, { historyState }))\n );\n }\n\n // -------------------------------------------------------------------------\n // Internals\n // -------------------------------------------------------------------------\n\n private _flushPendingRecreate(): void {\n // A fresh composition may have started while the flush was queued; its own\n // compositionend re-queues this. A detached host means the element's own\n // deferred teardown is already pending, so rebuilding would raise an editor\n // only to destroy it a task later.\n if (\n !this._host?.isConnected ||\n !this._pendingRecreate ||\n this._isComposing\n ) {\n return;\n }\n // Compare against what is installed, not the set that was pending when the\n // composition began: a host that changed the config and changed it back has\n // nothing left to rebuild, and rebuilding anyway would drop undo history.\n if (\n areExtensionSetsEquivalent(this._installedExtensions, this._extensions)\n ) {\n this._pendingRecreate = false;\n this._syncStarterStorage();\n return;\n }\n this._recreateEditor();\n }\n\n private _createEditor(\n element: HTMLElement,\n content: JSONContent | string | undefined\n ): Editor {\n const baseExtensions: Extension[] = [\n DocumentNode as unknown as Extension,\n ParagraphNode as unknown as Extension,\n TextNode as unknown as Extension,\n HardBreakNode as unknown as Extension,\n UndoRedo.configure({ ...HISTORY_DEFAULTS }),\n // Resolved per decoration build rather than captured, so `setPlaceholder`\n // lands on the live editor. Tiptap snapshots an extension's options when\n // it builds plugins, so a value here could never be updated in place.\n Placeholder.configure({ placeholder: () => this._placeholder }),\n PlainTextPaste,\n Keymap,\n // Plain Enter sends (non-empty); empty Enter falls through to a newline.\n // Baked into the base bundle so the rich editor and the textarea agree on\n // Enter-to-send without the chat layer wiring it per surface.\n carbonChatEnter(),\n ValueSync,\n TypingIndicator,\n ];\n this._installedExtensions = this._extensions;\n return new Editor({\n element,\n extensions: [...baseExtensions, ...this._extensions],\n editorProps: {\n attributes: () => {\n const attrs: Record<string, string> = { role: 'textbox' };\n if (this._ariaLabel) {\n attrs['aria-label'] = this._ariaLabel;\n }\n if (this._placeholder) {\n attrs['aria-placeholder'] = this._placeholder;\n }\n return attrs;\n },\n },\n content: content ?? undefined,\n autofocus: false,\n injectCSS: false,\n });\n }\n\n private _wireEditorEvents(editor: Editor): void {\n editor.on('focus', () => {\n this._hadFocus = true;\n const wasMouseFocus = this._consumeMouseFocus();\n this._dispatch('cds-aichat-prompt-focus', { keyboard: !wasMouseFocus });\n });\n editor.on('blur', () => {\n this._dispatch('cds-aichat-prompt-blur');\n });\n // Forward keydown for hosts wanting raw-key access. ValueSync /\n // TypingIndicator emit their own events; don't re-dispatch update here.\n editor.view.dom.addEventListener('keydown', (event) => {\n this._dispatch('cds-aichat-prompt-keydown', { originalEvent: event });\n });\n }\n\n private _recreateEditor(): void {\n const host = this._host;\n if (!host) {\n return;\n }\n if (this._isComposing) {\n this._pendingRecreate = true;\n return;\n }\n this._pendingRecreate = false;\n const previousJson = this._editor?.getJSON();\n const previousSelection = this._editor\n ? {\n from: this._editor.state.selection.from,\n to: this._editor.state.selection.to,\n }\n : null;\n const wasFocused = this._hadFocus;\n const wasKeyboardFocus = this.getKeyboardFocus();\n this._editor?.destroy();\n this._editor = this._createEditor(host, previousJson);\n this._wireEditorEvents(this._editor);\n applyEditorStyles(this._editor.view.dom as HTMLElement, IS_PHONE);\n this._applyTestIdToEditorDom();\n this._editor.setEditable(!this._disabled);\n if (previousSelection) {\n const { size } = this._editor.state.doc.content;\n const from = Math.min(previousSelection.from, size);\n const to = Math.min(previousSelection.to, size);\n this._editor.commands.setTextSelection({ from, to });\n }\n\n if (wasFocused) {\n this.focus(wasKeyboardFocus);\n }\n }\n\n private _dispatchSetContent(content: JSONContent | string): void {\n const editor = this._editor;\n if (!editor) {\n return;\n }\n // Chain a no-op command that meta-tags the accumulator tr as host-origin,\n // then setContent on the same tr so downstream readers (typing-indicator)\n // recognize the update.\n editor\n .chain()\n .command(({ tr }) => {\n setHostOriginMeta(tr);\n return true;\n })\n .setContent(content, { emitUpdate: true })\n .run();\n }\n\n // Mirror testId onto the inner ProseMirror contenteditable (not the host\n // wrapper) so Playwright's editable-action helpers (`.fill()`, etc.) accept\n // it. `view.dom` is replaced on each recreate, so re-apply.\n private _applyTestIdToEditorDom(): void {\n const editorDom = this._editor?.view.dom as HTMLElement | undefined;\n if (!editorDom) {\n return;\n }\n if (this._testId) {\n editorDom.setAttribute('data-testid', this._testId);\n } else {\n editorDom.removeAttribute('data-testid');\n }\n }\n\n private _dispatch(name: string, detail?: unknown): void {\n this._host?.dispatchEvent(\n new CustomEvent(name, { detail, bubbles: true, composed: true })\n );\n }\n}\n\n/**\n * Construct a Tiptap-backed prompt-line controller. Called by the shell once\n * the lazily-imported runtime module has resolved.\n */\nexport function createRichController(): PromptLineController {\n return new RichController();\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;AAOG;AAEH;;;;;;;;;;;;;;;;AAgBG;AAkCH;;;AAGG;AACH,MAAM,cACJ,SAAQ,oBAAoB,CAAA;AAD9B,IAAA,WAA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