@aceshooting/lyra-ui 30.9.0 → 31.1.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 (283) hide show
  1. package/CHANGELOG.md +361 -335
  2. package/dist/ai/adapters/ag-ui.js +1 -1
  3. package/dist/autoloader-cdn.js +1 -1
  4. package/dist/components/agent-tools/activity-feed/activity-feed.class.js +1 -1
  5. package/dist/components/agent-tools/budget-meter/budget-meter.class.d.ts +12 -1
  6. package/dist/components/agent-tools/budget-meter/budget-meter.class.js +4 -4
  7. package/dist/components/agent-tools/compare-panel/compare-panel.class.js +1 -1
  8. package/dist/components/agent-tools/eval-dataset/eval-dataset.class.js +1 -1
  9. package/dist/components/agent-tools/thinking-panel/thinking-panel.class.js +1 -1
  10. package/dist/components/agent-tools/tool-select-dialog/tool-select-dialog.class.js +1 -1
  11. package/dist/components/charts/chart/box-plot.class.js +2 -2
  12. package/dist/components/charts/chart/chart-sync.js +1 -1
  13. package/dist/components/charts/chart/chart.class.d.ts +1 -1
  14. package/dist/components/charts/chart/chart.class.js +4 -4
  15. package/dist/components/charts/chart/lite-chart-axis-layout.js +1 -1
  16. package/dist/components/charts/chart/lite-chart.class.js +2 -2
  17. package/dist/components/conversation/chat-composer/chat-composer.class.d.ts +26 -11
  18. package/dist/components/conversation/chat-composer/chat-composer.class.js +11 -9
  19. package/dist/components/conversation/chat-composer/chat-composer.styles.js +1 -1
  20. package/dist/components/conversation/chat-message/chat-message.class.d.ts +27 -3
  21. package/dist/components/conversation/chat-message/chat-message.class.js +14 -12
  22. package/dist/components/conversation/chat-message/chat-message.styles.js +1 -1
  23. package/dist/components/conversation/chat-viewport/chat-viewport.class.d.ts +29 -2
  24. package/dist/components/conversation/chat-viewport/chat-viewport.class.js +2 -2
  25. package/dist/components/conversation/chat-viewport/chat-viewport.styles.js +1 -1
  26. package/dist/components/conversation/code-block/code-block-shared.js +1 -1
  27. package/dist/components/conversation/markdown/markdown-base.class.d.ts +1 -1
  28. package/dist/components/conversation/markdown/markdown-base.class.js +1 -1
  29. package/dist/components/conversation/markdown/markdown-code-header.js +1 -1
  30. package/dist/components/conversation/markdown/markdown-core.class.d.ts +10 -0
  31. package/dist/components/conversation/markdown/markdown-core.class.js +1 -1
  32. package/dist/components/conversation/markdown/markdown-shared.d.ts +7 -2
  33. package/dist/components/conversation/markdown/markdown-shared.js +3 -3
  34. package/dist/components/conversation/markdown/markdown.class.d.ts +10 -0
  35. package/dist/components/conversation/markdown/markdown.class.js +1 -1
  36. package/dist/components/conversation/message-feedback/message-feedback.class.d.ts +11 -3
  37. package/dist/components/conversation/message-feedback/message-feedback.class.js +12 -6
  38. package/dist/components/conversation/message-feedback/message-feedback.styles.js +1 -1
  39. package/dist/components/conversation/message-parts/message-parts.class.js +1 -1
  40. package/dist/components/conversation/prompt-input/prompt-input.class.d.ts +8 -4
  41. package/dist/components/conversation/prompt-input/prompt-input.class.js +3 -2
  42. package/dist/components/conversation/push-to-talk/push-to-talk.class.js +1 -1
  43. package/dist/components/conversation/streaming-text/streaming-text-base.class.d.ts +4 -0
  44. package/dist/components/conversation/streaming-text/streaming-text-base.class.js +1 -1
  45. package/dist/components/conversation/streaming-text/streaming-text-core.class.d.ts +1 -1
  46. package/dist/components/conversation/streaming-text/streaming-text-core.class.js +1 -0
  47. package/dist/components/conversation/streaming-text/streaming-text.class.d.ts +1 -1
  48. package/dist/components/conversation/streaming-text/streaming-text.class.js +1 -0
  49. package/dist/components/conversation/suggestion-chips/suggestion-chips.class.d.ts +17 -3
  50. package/dist/components/conversation/suggestion-chips/suggestion-chips.class.js +3 -3
  51. package/dist/components/conversation/suggestion-chips/suggestion-chips.d.ts +1 -1
  52. package/dist/components/conversation/suggestion-chips/suggestion-chips.js +1 -1
  53. package/dist/components/conversation/suggestion-chips/suggestion-chips.styles.js +1 -1
  54. package/dist/components/conversation/thread-list/thread-list.class.d.ts +1 -1
  55. package/dist/components/conversation/thread-list/thread-list.class.js +3 -3
  56. package/dist/components/conversation/transcript-feed/transcript-feed.class.js +1 -1
  57. package/dist/components/data/data-grid/data-grid.class.d.ts +10 -10
  58. package/dist/components/data/data-grid/data-grid.class.js +1 -1
  59. package/dist/components/data/document-library/document-library-cursor.js +1 -0
  60. package/dist/components/data/document-library/document-library-types.d.ts +20 -0
  61. package/dist/components/data/document-library/document-library.class.d.ts +37 -26
  62. package/dist/components/data/document-library/document-library.class.js +20 -11
  63. package/dist/components/data/document-library/document-library.styles.js +1 -1
  64. package/dist/components/data/file-tree/file-tree.class.js +1 -1
  65. package/dist/components/data/flow-canvas/flow-canvas.class.d.ts +1 -1
  66. package/dist/components/data/flow-canvas/flow-canvas.class.js +2 -2
  67. package/dist/components/data/heatmap/heatmap.class.d.ts +1 -1
  68. package/dist/components/data/heatmap/heatmap.class.js +1 -1
  69. package/dist/components/data/pagination/pagination.class.js +1 -1
  70. package/dist/components/data/table/table.class.d.ts +31 -2
  71. package/dist/components/data/table/table.class.js +3 -3
  72. package/dist/components/data/table/table.styles.js +1 -1
  73. package/dist/components/data/timeline/timeline-cluster.js +1 -1
  74. package/dist/components/data/timeline/timeline-item.class.d.ts +10 -3
  75. package/dist/components/data/timeline/timeline-item.class.js +16 -12
  76. package/dist/components/data/timeline/timeline-item.styles.js +1 -1
  77. package/dist/components/data/timeline/timeline.class.d.ts +14 -2
  78. package/dist/components/data/timeline/timeline.class.js +9 -5
  79. package/dist/components/data/tree/tree-item.class.js +1 -1
  80. package/dist/components/data/tree/tree.class.d.ts +2 -0
  81. package/dist/components/data/tree/tree.class.js +1 -1
  82. package/dist/components/forms/button/button.class.d.ts +8 -6
  83. package/dist/components/forms/button/button.class.js +2 -2
  84. package/dist/components/forms/checkbox-group/checkbox-group.class.js +1 -1
  85. package/dist/components/forms/color-picker/color-core.js +1 -1
  86. package/dist/components/forms/combobox/combobox.class.d.ts +20 -12
  87. package/dist/components/forms/combobox/combobox.class.js +2 -2
  88. package/dist/components/forms/date-picker/date-input.class.d.ts +1 -1
  89. package/dist/components/forms/date-picker/date-input.class.js +1 -1
  90. package/dist/components/forms/icon-button/icon-button.class.d.ts +4 -2
  91. package/dist/components/forms/icon-button/icon-button.class.js +2 -2
  92. package/dist/components/forms/input/input-shared.js +2 -2
  93. package/dist/components/forms/input/number-input-locale.js +1 -0
  94. package/dist/components/forms/input/number-input.class.d.ts +19 -2
  95. package/dist/components/forms/input/number-input.class.js +2 -2
  96. package/dist/components/forms/locale-picker/locale-picker.class.d.ts +3 -3
  97. package/dist/components/forms/locale-picker/locale-picker.class.js +1 -1
  98. package/dist/components/layout/app-rail-group/app-rail-group.class.js +1 -1
  99. package/dist/components/layout/details/accordion-item.class.js +1 -1
  100. package/dist/components/layout/dock-panel/dock-panel.class.d.ts +1 -1
  101. package/dist/components/layout/dock-panel/dock-panel.class.js +1 -1
  102. package/dist/components/layout/menu/menu.class.js +1 -1
  103. package/dist/components/layout/multi-split/multi-split.class.js +1 -1
  104. package/dist/components/layout/navigation-menu-item/navigation-menu-item.class.js +1 -1
  105. package/dist/components/layout/page/page.class.d.ts +3 -3
  106. package/dist/components/layout/page/page.class.js +1 -1
  107. package/dist/components/layout/segmented/segmented.class.d.ts +20 -7
  108. package/dist/components/layout/segmented/segmented.class.js +34 -24
  109. package/dist/components/layout/segmented/segmented.styles.js +1 -1
  110. package/dist/components/layout/stepper/stepper.styles.js +1 -1
  111. package/dist/components/layout/tab-group/tab-group.class.d.ts +8 -1
  112. package/dist/components/layout/tab-group/tab-group.class.js +1 -1
  113. package/dist/components/layout/tab-group/tab.class.d.ts +7 -1
  114. package/dist/components/layout/tab-group/tab.class.js +1 -1
  115. package/dist/components/layout/virtual-list/virtual-list.class.d.ts +2 -2
  116. package/dist/components/layout/virtual-list/virtual-list.class.js +1 -1
  117. package/dist/components/media/animated-image/animated-image.class.js +1 -1
  118. package/dist/components/media/attachment-chip/attachment-chip.class.d.ts +21 -14
  119. package/dist/components/media/attachment-chip/attachment-chip.class.js +1 -1
  120. package/dist/components/media/attachment-trigger/attachment-trigger.class.d.ts +36 -12
  121. package/dist/components/media/attachment-trigger/attachment-trigger.class.js +3 -3
  122. package/dist/components/media/drop-zone/drop-zone.class.d.ts +23 -5
  123. package/dist/components/media/drop-zone/drop-zone.class.js +2 -2
  124. package/dist/components/media/drop-zone/drop-zone.styles.js +1 -1
  125. package/dist/components/media/file-icon/file-icon.class.js +1 -1
  126. package/dist/components/media/flag/flag-url-resolver.js +1 -1
  127. package/dist/components/media/image-viewer/image-viewer.class.d.ts +2 -2
  128. package/dist/components/media/image-viewer/image-viewer.class.js +1 -1
  129. package/dist/components/media/map/map-anchor-controller.js +1 -1
  130. package/dist/components/media/map/map-canvas-target.js +1 -0
  131. package/dist/components/media/map/map-owned-features.js +1 -1
  132. package/dist/components/media/map/map-scene-elevated-lines.js +2 -2
  133. package/dist/components/media/map/map-scene-render-controller.js +1 -1
  134. package/dist/components/media/map/map.class.d.ts +15 -6
  135. package/dist/components/media/map/map.class.js +4 -4
  136. package/dist/components/media/map/map.styles.js +1 -1
  137. package/dist/components/media/pan-zoom/pan-zoom.class.js +1 -1
  138. package/dist/components/media/sequence-playback/sequence-playback.class.d.ts +21 -9
  139. package/dist/components/media/sequence-playback/sequence-playback.class.js +7 -6
  140. package/dist/components/media/sequence-playback/sequence-playback.styles.js +1 -1
  141. package/dist/components/media/video/video.class.d.ts +3 -3
  142. package/dist/components/media/video/video.class.js +3 -1
  143. package/dist/components/media/video-playlist/video-playlist.class.js +1 -1
  144. package/dist/components/overlays/chip/chip.class.js +1 -1
  145. package/dist/components/overlays/overlay/dropdown.class.js +1 -1
  146. package/dist/components/overlays/overlay/overlay.styles.js +1 -1
  147. package/dist/components/overlays/overlay/tooltip.class.d.ts +5 -1
  148. package/dist/components/overlays/overlay/tooltip.class.js +3 -3
  149. package/dist/components/retrieval/embedding-explorer/embedding-explorer-engine.js +1 -1
  150. package/dist/components/retrieval/graph/graph-node-renderer.js +1 -1
  151. package/dist/components/retrieval/graph/graph-spatial-controller.js +1 -1
  152. package/dist/components/retrieval/graph/graph.class.d.ts +1 -1
  153. package/dist/components/retrieval/graph/graph.class.js +1 -1
  154. package/dist/components/retrieval/ingestion-queue/ingestion-queue-presentation.d.ts +11 -0
  155. package/dist/components/retrieval/ingestion-queue/ingestion-queue-presentation.js +1 -0
  156. package/dist/components/retrieval/ingestion-queue/ingestion-queue.class.d.ts +18 -7
  157. package/dist/components/retrieval/ingestion-queue/ingestion-queue.class.js +13 -26
  158. package/dist/components/retrieval/ingestion-queue/ingestion-queue.styles.js +1 -1
  159. package/dist/components/retrieval/mind-map/mind-map.class.js +1 -1
  160. package/dist/components/retrieval/neighbor-list/neighbor-list.class.d.ts +1 -1
  161. package/dist/components/retrieval/neighbor-list/neighbor-list.class.js +3 -3
  162. package/dist/components/retrieval/retrieval-results/retrieval-results.class.js +1 -1
  163. package/dist/components/utility/diff-view/diff-view.class.d.ts +5 -5
  164. package/dist/components/utility/diff-view/diff-view.class.js +1 -1
  165. package/dist/components/utility/icon/icon.class.js +1 -1
  166. package/dist/components/utility/json-viewer/json-viewer.class.d.ts +16 -1
  167. package/dist/components/utility/json-viewer/json-viewer.class.js +4 -4
  168. package/dist/components/utility/json-viewer/json-viewer.styles.js +1 -1
  169. package/dist/components/utility/known-date/known-date.class.js +1 -1
  170. package/dist/components/utility/mention-popover/mention-popover.class.js +1 -1
  171. package/dist/components/viewers/archive-viewer/archive-viewer.class.js +1 -1
  172. package/dist/components/viewers/calendar-viewer/calendar-viewer.class.js +1 -1
  173. package/dist/components/viewers/contact-viewer/contact-viewer.class.js +1 -1
  174. package/dist/components/viewers/csv-viewer/csv-viewer.class.js +1 -1
  175. package/dist/components/viewers/dataset-viewer/dataset-viewer.class.js +1 -1
  176. package/dist/components/viewers/document-preview/document-preview.class.js +2 -2
  177. package/dist/components/viewers/docx-viewer/docx-viewer.class.d.ts +1 -1
  178. package/dist/components/viewers/docx-viewer/docx-viewer.class.js +2 -2
  179. package/dist/components/viewers/ebook-viewer/ebook-viewer.class.js +1 -1
  180. package/dist/components/viewers/email-viewer/email-viewer.class.d.ts +1 -1
  181. package/dist/components/viewers/email-viewer/email-viewer.class.js +2 -2
  182. package/dist/components/viewers/html-viewer/html-viewer.class.js +1 -1
  183. package/dist/components/viewers/include/include.class.js +1 -1
  184. package/dist/components/viewers/model-viewer/model-viewer.class.js +1 -1
  185. package/dist/components/viewers/notebook-viewer/notebook-viewer.class.js +2 -2
  186. package/dist/components/viewers/pdf-viewer/pdf-viewer.class.d.ts +2 -2
  187. package/dist/components/viewers/pdf-viewer/pdf-viewer.class.js +2 -2
  188. package/dist/components/viewers/pptx-viewer/pptx-viewer.class.js +1 -1
  189. package/dist/components/viewers/spreadsheet-viewer/spreadsheet-viewer.class.js +1 -1
  190. package/dist/components/viewers/svg-viewer/svg-viewer.class.js +1 -1
  191. package/dist/components/viewers/table-viewer-shared.js +4 -4
  192. package/dist/components/viewers/xml-viewer/xml-viewer.class.js +2 -2
  193. package/dist/data-sources.d.ts +10 -0
  194. package/dist/events.d.ts +9 -4
  195. package/dist/framework-types.d.ts +1 -1
  196. package/dist/internal/anchored-overlay-runtime.js +1 -1
  197. package/dist/internal/catalog-picker.js +1 -1
  198. package/dist/internal/default-strings/conversation.generated.js +1 -1
  199. package/dist/internal/default-strings/data.generated.js +1 -1
  200. package/dist/internal/default-strings/retrieval.generated.js +1 -1
  201. package/dist/internal/document-tokens.js +2 -2
  202. package/dist/internal/drop-session-controller.js +1 -1
  203. package/dist/internal/engine-3d.js +1 -1
  204. package/dist/internal/icon-only-content.js +1 -1
  205. package/dist/internal/layered-layout.js +1 -1
  206. package/dist/internal/localization-types.d.ts +1 -1
  207. package/dist/internal/localization.js +1 -1
  208. package/dist/internal/lyra-element.js +2 -2
  209. package/dist/internal/map-custom-layer-controller.js +1 -1
  210. package/dist/internal/media-panorama.js +1 -1
  211. package/dist/internal/native-modal-context.js +1 -1
  212. package/dist/internal/overlay-manager.js +1 -1
  213. package/dist/internal/overlay-order.js +1 -1
  214. package/dist/internal/overlay-stack.js +1 -1
  215. package/dist/internal/package-metadata.js +1 -1
  216. package/dist/internal/runtime-diagnostics.js +1 -0
  217. package/dist/internal/safe-url.js +1 -1
  218. package/dist/internal/scoped-definitions.generated.js +1 -1
  219. package/dist/internal/scroll-overflow.js +1 -1
  220. package/dist/internal/source-cursor-controller.js +1 -0
  221. package/dist/internal/source-cursor-projection.js +1 -0
  222. package/dist/internal/source-page-scope.js +1 -1
  223. package/dist/internal/source-window-controller.js +1 -1
  224. package/dist/internal/text-quote.js +1 -1
  225. package/dist/internal/viewer-search.js +1 -1
  226. package/dist/lyra.d.ts +1 -1
  227. package/dist/sequence-time-binding.js +1 -1
  228. package/dist/simulation-clock.js +1 -1
  229. package/dist/styles/reservations.css +1 -1
  230. package/dist/styles/reservations.styles.js +1 -1
  231. package/dist/testing/happy-dom-shims.js +1 -1
  232. package/dist/theme/theme-bootstrap.js +1 -1
  233. package/dist/theme/theme.js +1 -1
  234. package/dist/utilities/overlay-manager.d.ts +2 -0
  235. package/llms/components/lr-attachment-chip.md +27 -12
  236. package/llms/components/lr-attachment-trigger.md +27 -7
  237. package/llms/components/lr-budget-meter.md +31 -0
  238. package/llms/components/lr-button.md +6 -4
  239. package/llms/components/lr-chat-composer.md +26 -9
  240. package/llms/components/lr-chat-message.md +44 -3
  241. package/llms/components/lr-chat-viewport.md +39 -2
  242. package/llms/components/lr-combobox.md +27 -1
  243. package/llms/components/lr-data-grid.md +2 -0
  244. package/llms/components/lr-dialog.md +10 -0
  245. package/llms/components/lr-diff-view.md +6 -0
  246. package/llms/components/lr-document-library.md +90 -6
  247. package/llms/components/lr-drop-zone.md +26 -2
  248. package/llms/components/lr-graph.md +5 -0
  249. package/llms/components/lr-icon-button.md +2 -1
  250. package/llms/components/lr-ingestion-queue.md +76 -8
  251. package/llms/components/lr-json-viewer.md +51 -0
  252. package/llms/components/lr-lite-chart.md +2 -1
  253. package/llms/components/lr-locale-picker.md +5 -0
  254. package/llms/components/lr-map.md +33 -0
  255. package/llms/components/lr-markdown-core.md +2 -1
  256. package/llms/components/lr-markdown.md +20 -4
  257. package/llms/components/lr-menu.md +3 -1
  258. package/llms/components/lr-message-feedback.md +38 -3
  259. package/llms/components/lr-number-input.md +28 -1
  260. package/llms/components/lr-page.md +4 -2
  261. package/llms/components/lr-prompt-input.md +6 -3
  262. package/llms/components/lr-segmented.md +30 -10
  263. package/llms/components/lr-sequence-playback.md +47 -12
  264. package/llms/components/lr-streaming-text-core.md +3 -2
  265. package/llms/components/lr-streaming-text.md +4 -1
  266. package/llms/components/lr-suggestion-chips.md +28 -5
  267. package/llms/components/lr-tab-group.md +13 -1
  268. package/llms/components/lr-tab.md +5 -0
  269. package/llms/components/lr-table.md +25 -4
  270. package/llms/components/lr-timeline-item.md +1 -1
  271. package/llms/components/lr-timeline.md +38 -4
  272. package/llms/components/lr-tooltip.md +3 -1
  273. package/llms/components/lr-tree.md +4 -0
  274. package/llms/components/lr-virtual-list.md +4 -1
  275. package/llms/peers.md +2 -2
  276. package/llms/shared/events-and-types.md +61 -2
  277. package/llms/shared/forms-and-accessibility.md +46 -4
  278. package/llms/shared/imports-and-registration.md +154 -110
  279. package/llms/shared/testing-and-utilities.md +5 -1
  280. package/llms/shared.md +266 -117
  281. package/locales.json +1 -1
  282. package/package.json +22 -21
  283. package/registrations.json +1 -1
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{setNativeRangeText,nativeAutocorrectAttribute}from"../../../internal/native-text-control.js";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{collectionSupport,publicCollectionTruncation}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{ifDefined}from"lit/directives/if-defined.js";import{repeat}from"lit/directives/repeat.js";import{autocorrectConverter,normalizeAutocorrect,trueDefaultBooleanConverter}from"../../../internal/converters.js";import{LyraElement}from"../../../internal/lyra-element.js";import{lengthLimitConverter}from"../../../internal/length-constraints.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{SlotPresenceController}from"../../../internal/slot-presence-controller.js";import{deepActiveElementIn}from"../../../internal/active-element.js";import{isHtmlElement}from"../../../internal/dom-guards.js";import{normalizeCatalog}from"../../../internal/catalog-picker.js";import{composedContains}from"../../../internal/overlay-manager.js";import{canonicalIdentityList,firstByRetrievalIdentity as firstByPromptIdentity}from"../../retrieval/retrieval-identity.js";import{acquireResolvedAriaRelationship}from"../../../internal/aria-controls.js";import{normalizeChatComposerStatus}from"../chat-composer/chat-composer.class.js";import{styles}from"./prompt-input.styles.js";import{LYRA_DEFAULT_promptInputAttachments,LYRA_DEFAULT_promptInputControls,LYRA_DEFAULT_promptInputInputLimit,LYRA_DEFAULT_promptInputLabel,LYRA_DEFAULT_promptInputSources}from"../../../internal/default-strings/conversation.generated.js";import{LYRA_DEFAULT_fieldRequired}from"../../../internal/default-strings/shared.generated.js";class LyraPromptInput extends LyraElement{constructor(){super(...arguments),this.inputLimitAnnouncements=new AnnouncementSinkController(this),this.suggestionCaretGeneration=0,this._value="",this.statusValue="idle",this.placeholder="",this.disabled=!1,this.readOnly=!1,this.withoutEnterSubmit=!1,this.submitDisabled=!1,this.withoutStop=!1,this.frame="card",this.actionsLayout="inline",this.minRows=1,this.maxRows=8,this.spellcheck=!0,this.autocapitalize="",this.autocorrectValue=!0,this.wrap="soft",this.autocomplete="",this.inputMode="",this.enterKeyHint="",this.attachments=[],this.attachmentCapabilities=["files","image","audio"],this.mentionItems=[],this.commandItems=[],this.model="",this.voice="",this.sources=[],this.selectedSourceIds=[],this.queue=[],this.accessibleLabel=null,this.activeSuggestion=null,this.slotPresence=new SlotPresenceController(this),this.suggestionNavigationGeneration=0,this.syncDescription=()=>{const target=this.composer?.input;this.isConnected&&target&&!this.descriptionLease&&(this.descriptionLease=acquireResolvedAriaRelationship(this,target,"aria-describedby"))},this.onCompositeKeyDown=event=>{event.composedPath()[0]===this.composer?.input&&this.onKeyDown(event)},this.onCompositeFocusOut=event=>{const popover=this.suggestionPopover;if(!popover||!this.activeSuggestion||!popover.open)return;const relatedTarget=isHtmlElement(event.relatedTarget)?event.relatedTarget:null;this.suggestionFocusIsOwned(popover,relatedTarget)||(this.suggestionNavigationGeneration+=1);const generation=this.suggestionNavigationGeneration;queueMicrotask(()=>{if(!this.isConnected||generation!==this.suggestionNavigationGeneration)return;const currentPopover=this.suggestionPopover;(!currentPopover||!this.suggestionFocusIsOwned(currentPopover))&&this.closeSuggestions()})},this.onNativeInput=event=>{if(this.disabled||this.readOnly||!this.composer||!event.composedPath().includes(this.composer)){event.stopPropagation();return}relayNativeEvent(this,event)},this.onNativeChange=event=>{if(this.disabled||this.readOnly||!this.composer||!event.composedPath().includes(this.composer)){event.stopPropagation();return}relayNativeEvent(this,event)},this.onNativeFocus=event=>{if(event.target!==this.composer){event.stopPropagation();return}relayNativeEvent(this,event)},this.onNativeBlur=event=>{if(event.target!==this.composer){event.stopPropagation();return}relayNativeEvent(this,event)},this.firstByIdentity=new WeakMap}static{this.defaultStrings={...super.defaultStrings,fieldRequired:LYRA_DEFAULT_fieldRequired,promptInputAttachments:LYRA_DEFAULT_promptInputAttachments,promptInputControls:LYRA_DEFAULT_promptInputControls,promptInputInputLimit:LYRA_DEFAULT_promptInputInputLimit,promptInputLabel:LYRA_DEFAULT_promptInputLabel,promptInputSources:LYRA_DEFAULT_promptInputSources}}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["attachments","attachmentCapabilities","mentionItems","commandItems","modelCatalog","voiceCatalog","sources","selectedSourceIds","queue"])}static{this.styles=[LyraElement.styles,styles]}static{this.immutableEventDetails=Object.freeze(["lr-attachments-add","lr-sources-change","lr-queue-change","lr-send-now"])}static{this.identityEventDetailProperties=Object.freeze({"lr-send-now":Object.freeze(["item"])})}static{this.identityEventDetailCollectionItems=Object.freeze({"lr-queue-change":Object.freeze(["items"])})}get inputLosses(){return["modelCatalog","voiceCatalog","mentionItems","commandItems"].map(name=>publicCollectionTruncation(this,name))}get inputLimitMessage(){return this.inputLosses.some(Boolean)?this.localize("promptInputInputLimit"):""}syncInputLimitAnnouncement(){this.inputLimitAnnouncements.transition("input-limit",this.inputLosses.map(loss=>loss?`${loss.source}:${loss.retained}:${loss.kept}`:"").join("|"),this.inputLimitMessage,"polite")}get value(){return this._value}set value(next){if(next===this._value)return;const old=this._value;this._value=next,this.suggestionCaretGeneration+=1,this.requestUpdate("value",old)}get status(){return this.statusValue}set status(value){const previous=this.statusValue;this.statusValue=normalizeChatComposerStatus(value),this.requestUpdate("status",previous)}get autocorrect(){return this.autocorrectValue}set autocorrect(next){this.autocorrectValue=normalizeAutocorrect(next),this.requestUpdate()}focus(options){this.composer?.focus(options)}blur(){this.composer?.blur()}click(){this.disabled||this.composer?.click()}get input(){return this.composer?.input??null}get selectionStart(){return this.composer?.selectionStart??null}set selectionStart(value){this.suggestionCaretGeneration+=1,this.composer&&(this.composer.selectionStart=value)}get selectionEnd(){return this.composer?.selectionEnd??null}set selectionEnd(value){this.suggestionCaretGeneration+=1,this.composer&&(this.composer.selectionEnd=value)}get selectionDirection(){return this.composer?.selectionDirection??null}set selectionDirection(value){this.suggestionCaretGeneration+=1,this.composer&&(this.composer.selectionDirection=value)}select(){this.suggestionCaretGeneration+=1,this.composer?.select()}setSelectionRange(start,end,direction){this.suggestionCaretGeneration+=1,this.composer?.setSelectionRange(start,end,direction)}setRangeText(replacement,start,end,selectMode){const composer=this.composer;composer&&(setNativeRangeText(composer,replacement,start,end,selectMode),this.value=composer.value)}willUpdate(changed){super.willUpdate(changed);let invalidate=changed.has("mentionItems")||changed.has("commandItems")||changed.has("disabled")||changed.has("readOnly");if(changed.has("value")){const internal=this.pendingSuggestionValue===this.value;this.pendingSuggestionValue=void 0,invalidate||=!internal}invalidate&&(this.suggestionNavigationGeneration+=1,this.activeSuggestion=null,this.suggestionAnchor=void 0)}adoptedCallback(){super.adoptedCallback(),this.inputLimitAnnouncements.adopted()}connectedCallback(){super.connectedCallback(),this.addEventListener("keydown",this.onCompositeKeyDown,!0),this.hasUpdated&&(this.syncInputLimitAnnouncement(),this.syncDescription())}disconnectedCallback(){this.removeEventListener("keydown",this.onCompositeKeyDown,!0),this.suggestionCaretGeneration+=1,this.closeSuggestions(),this.descriptionLease?.release(),this.descriptionLease=void 0,super.disconnectedCallback()}firstUpdated(changed){super.firstUpdated(changed),this.composer?.updateComplete.then(this.syncDescription)}updated(_changed){super.updated(_changed),this.syncInputLimitAnnouncement();const popover=this.suggestionPopover;popover&&this.suggestionAnchor&&(popover.anchor=this.suggestionAnchor)}suggestions(){return this.activeSuggestion?.trigger==="/"?this.commandItems:this.mentionItems}detectSuggestion(value){const caret=this.composer?.selectionStart??value.length,prefix=value.slice(0,caret),match=/(?:^|\s)([@/])([^\s@/]*)$/.exec(prefix);if(!match||match[1]!=="@"&&match[1]!=="/"){this.activeSuggestion=null;return}const start=caret-match[2].length-1,items=match[1]==="@"?this.mentionItems:this.commandItems;this.activeSuggestion=items.length?{trigger:match[1],start,query:match[2]??""}:null}onInput(event){if(event.stopPropagation(),this.disabled||this.readOnly)return;const composer=event.currentTarget;this.suggestionAnchor=composer?.input??this.composer?.input??void 0,this.pendingSuggestionValue=event.detail.value,this.value=event.detail.value,this.detectSuggestion(this.value),this.emit("lr-input",{value:this.value})}onChange(event){event.stopPropagation(),!(this.disabled||this.readOnly)&&(this.value=event.detail.value,this.emit("lr-change",{value:this.value}))}onSubmit(event){event.stopPropagation(),!this.disabled&&this.emit("lr-submit",event.detail)}onStop(event){event.stopPropagation(),!this.disabled&&this.emit("lr-stop",null)}onKeyDown(event){if(event.defaultPrevented)return;const popover=this.suggestionPopover;if(!(this.disabled||this.readOnly||!this.activeSuggestion||!popover?.open)&&popover.handleKeyDown(event)){const shouldMoveFocus=event.key==="ArrowDown"||event.key==="ArrowUp",generation=++this.suggestionNavigationGeneration;popover.updateComplete.then(async()=>{shouldMoveFocus&&generation===this.suggestionNavigationGeneration&&this.isConnected&&!this.disabled&&!this.readOnly&&this.suggestionPopover===popover&&this.activeSuggestion&&popover.open&&this.suggestionFocusIsOwned(popover)&&await popover.focusActiveOption({ownsFocus:()=>generation===this.suggestionNavigationGeneration&&this.isConnected&&!this.disabled&&!this.readOnly&&this.suggestionPopover===popover&&this.activeSuggestion!==null&&popover.open&&this.suggestionFocusIsOwned(popover)})})}}suggestionFocusIsOwned(popover,focused=deepActiveElementIn(this.ownerDocument)){return focused===this.composer?.input||focused===this.composer||focused!==null&&composedContains(popover,focused)}closeSuggestions(){this.suggestionNavigationGeneration+=1,this.activeSuggestion=null,this.suggestionAnchor=void 0}onSuggestionSelect(event){if(event.stopPropagation(),this.disabled||this.readOnly)return;const active=this.activeSuggestion;if(!active)return;const occurrence=this.suggestions()[event.detail.index];if(!occurrence||occurrence.suggestionId!==event.detail.suggestionId)return;const item=occurrence,composer=this.composer,caret=composer?.selectionStart??this.value.length,inserted=`${active.trigger}${item?.insertText??event.detail.label} `;this.value=this.value.slice(0,active.start)+inserted+this.value.slice(caret);const caretGeneration=this.suggestionCaretGeneration,nextCaret=active.start+inserted.length;this.closeSuggestions(),this.emit("lr-input",{value:this.value}),this.emit("lr-mention-select",{suggestionId:event.detail.suggestionId,index:event.detail.index,label:event.detail.label,trigger:active.trigger}),this.updateComplete.then(()=>{caretGeneration===this.suggestionCaretGeneration&&this.isConnected&&this.composer===composer&&composer?.setSelectionRange(nextCaret,nextCaret)})}onFiles(event){event.stopPropagation(),!this.disabled&&this.emit("lr-attachments-add",event.detail)}get effectiveAttachments(){const seen=new Set;return this.attachments.filter(attachment=>{const id=attachment?.attachmentId;return typeof id!="string"||id.trim()===""||seen.has(id)?!1:(seen.add(id),!0)})}firstById(values,identity){let retained=this.firstByIdentity.get(values);return retained||this.firstByIdentity.set(values,retained=firstByPromptIdentity(values,identity)),retained}get effectiveSources(){return this.firstById(this.sources,source=>source.id)}get effectiveSelectedSourceIds(){return canonicalIdentityList(this.selectedSourceIds)}get effectiveQueue(){return this.firstById(this.queue,item=>item.id)}renderDefaultAttachmentTrigger(){return html`<lr-attachment-trigger multiple
1
+ import{__decorate}from"tslib";import{setNativeRangeText,nativeAutocorrectAttribute}from"../../../internal/native-text-control.js";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{collectionSupport,publicCollectionTruncation}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{ifDefined}from"lit/directives/if-defined.js";import{repeat}from"lit/directives/repeat.js";import{autocorrectConverter,normalizeAutocorrect,trueDefaultBooleanConverter}from"../../../internal/converters.js";import{LyraElement}from"../../../internal/lyra-element.js";import{lengthLimitConverter}from"../../../internal/length-constraints.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{SlotPresenceController}from"../../../internal/slot-presence-controller.js";import{deepActiveElementIn}from"../../../internal/active-element.js";import{isHtmlElement}from"../../../internal/dom-guards.js";import{normalizeCatalog}from"../../../internal/catalog-picker.js";import{composedContains}from"../../../internal/overlay-manager.js";import{canonicalIdentityList,firstByRetrievalIdentity as firstByPromptIdentity}from"../../retrieval/retrieval-identity.js";import{acquireResolvedAriaRelationship}from"../../../internal/aria-controls.js";import{normalizeChatComposerStatus}from"../chat-composer/chat-composer.class.js";import{styles}from"./prompt-input.styles.js";import{LYRA_DEFAULT_promptInputAttachments,LYRA_DEFAULT_promptInputControls,LYRA_DEFAULT_promptInputInputLimit,LYRA_DEFAULT_promptInputLabel,LYRA_DEFAULT_promptInputSources}from"../../../internal/default-strings/conversation.generated.js";import{LYRA_DEFAULT_fieldRequired}from"../../../internal/default-strings/shared.generated.js";class LyraPromptInput extends LyraElement{constructor(){super(...arguments),this.inputLimitAnnouncements=new AnnouncementSinkController(this),this.suggestionCaretGeneration=0,this._value="",this.statusValue="idle",this.placeholder="",this.disabled=!1,this.readOnly=!1,this.withoutEnterSubmit=!1,this.submitDisabled=!1,this.withoutStop=!1,this.frame="card",this.actionsLayout="inline",this.toolbarPlacement="above",this.minRows=1,this.maxRows=8,this.spellcheck=!0,this.autocapitalize="",this.autocorrectValue=!0,this.wrap="soft",this.autocomplete="",this.inputMode="",this.enterKeyHint="",this.attachments=[],this.attachmentCapabilities=["files","image","audio"],this.mentionItems=[],this.commandItems=[],this.model="",this.voice="",this.sources=[],this.selectedSourceIds=[],this.queue=[],this.accessibleLabel=null,this.activeSuggestion=null,this.slotPresence=new SlotPresenceController(this),this.suggestionNavigationGeneration=0,this.syncDescription=()=>{const target=this.composer?.input;this.isConnected&&target&&!this.descriptionLease&&(this.descriptionLease=acquireResolvedAriaRelationship(this,target,"aria-describedby"))},this.onCompositeKeyDown=event=>{event.composedPath()[0]===this.composer?.input&&this.onKeyDown(event)},this.onCompositeFocusOut=event=>{const popover=this.suggestionPopover;if(!popover||!this.activeSuggestion||!popover.open)return;const relatedTarget=isHtmlElement(event.relatedTarget)?event.relatedTarget:null;this.suggestionFocusIsOwned(popover,relatedTarget)||(this.suggestionNavigationGeneration+=1);const generation=this.suggestionNavigationGeneration;queueMicrotask(()=>{if(!this.isConnected||generation!==this.suggestionNavigationGeneration)return;const currentPopover=this.suggestionPopover;(!currentPopover||!this.suggestionFocusIsOwned(currentPopover))&&this.closeSuggestions()})},this.onNativeInput=event=>{if(this.disabled||this.readOnly||!this.composer||!event.composedPath().includes(this.composer)){event.stopPropagation();return}relayNativeEvent(this,event)},this.onNativeChange=event=>{if(this.disabled||this.readOnly||!this.composer||!event.composedPath().includes(this.composer)){event.stopPropagation();return}relayNativeEvent(this,event)},this.onNativeFocus=event=>{if(event.target!==this.composer){event.stopPropagation();return}relayNativeEvent(this,event)},this.onNativeBlur=event=>{if(event.target!==this.composer){event.stopPropagation();return}relayNativeEvent(this,event)},this.firstByIdentity=new WeakMap}static{this.defaultStrings={...super.defaultStrings,fieldRequired:LYRA_DEFAULT_fieldRequired,promptInputAttachments:LYRA_DEFAULT_promptInputAttachments,promptInputControls:LYRA_DEFAULT_promptInputControls,promptInputInputLimit:LYRA_DEFAULT_promptInputInputLimit,promptInputLabel:LYRA_DEFAULT_promptInputLabel,promptInputSources:LYRA_DEFAULT_promptInputSources}}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["attachments","attachmentCapabilities","mentionItems","commandItems","modelCatalog","voiceCatalog","sources","selectedSourceIds","queue"])}static{this.styles=[LyraElement.styles,styles]}static{this.immutableEventDetails=Object.freeze(["lr-attachments-add","lr-sources-change","lr-queue-change","lr-send-now"])}static{this.identityEventDetailProperties=Object.freeze({"lr-send-now":Object.freeze(["item"])})}static{this.identityEventDetailCollectionItems=Object.freeze({"lr-queue-change":Object.freeze(["items"])})}get inputLosses(){return["modelCatalog","voiceCatalog","mentionItems","commandItems"].map(name=>publicCollectionTruncation(this,name))}get inputLimitMessage(){return this.inputLosses.some(Boolean)?this.localize("promptInputInputLimit"):""}syncInputLimitAnnouncement(){this.inputLimitAnnouncements.transition("input-limit",this.inputLosses.map(loss=>loss?`${loss.source}:${loss.retained}:${loss.kept}`:"").join("|"),this.inputLimitMessage,"polite")}get value(){return this._value}set value(next){if(next===this._value)return;const old=this._value;this._value=next,this.suggestionCaretGeneration+=1,this.requestUpdate("value",old)}get status(){return this.statusValue}set status(value){const previous=this.statusValue;this.statusValue=normalizeChatComposerStatus(value),this.requestUpdate("status",previous)}get autocorrect(){return this.autocorrectValue}set autocorrect(next){this.autocorrectValue=normalizeAutocorrect(next),this.requestUpdate()}focus(options){this.composer?.focus(options)}blur(){this.composer?.blur()}click(){this.disabled||this.composer?.click()}get input(){return this.composer?.input??null}get selectionStart(){return this.composer?.selectionStart??null}set selectionStart(value){this.suggestionCaretGeneration+=1,this.composer&&(this.composer.selectionStart=value)}get selectionEnd(){return this.composer?.selectionEnd??null}set selectionEnd(value){this.suggestionCaretGeneration+=1,this.composer&&(this.composer.selectionEnd=value)}get selectionDirection(){return this.composer?.selectionDirection??null}set selectionDirection(value){this.suggestionCaretGeneration+=1,this.composer&&(this.composer.selectionDirection=value)}select(){this.suggestionCaretGeneration+=1,this.composer?.select()}setSelectionRange(start,end,direction){this.suggestionCaretGeneration+=1,this.composer?.setSelectionRange(start,end,direction)}setRangeText(replacement,start,end,selectMode){const composer=this.composer;composer&&(setNativeRangeText(composer,replacement,start,end,selectMode),this.value=composer.value)}willUpdate(changed){super.willUpdate(changed);let invalidate=changed.has("mentionItems")||changed.has("commandItems")||changed.has("disabled")||changed.has("readOnly");if(changed.has("value")){const internal=this.pendingSuggestionValue===this.value;this.pendingSuggestionValue=void 0,invalidate||=!internal}invalidate&&(this.suggestionNavigationGeneration+=1,this.activeSuggestion=null,this.suggestionAnchor=void 0)}adoptedCallback(){super.adoptedCallback(),this.inputLimitAnnouncements.adopted()}connectedCallback(){super.connectedCallback(),this.addEventListener("keydown",this.onCompositeKeyDown,!0),this.hasUpdated&&(this.syncInputLimitAnnouncement(),this.syncDescription())}disconnectedCallback(){this.removeEventListener("keydown",this.onCompositeKeyDown,!0),this.suggestionCaretGeneration+=1,this.closeSuggestions(),this.descriptionLease?.release(),this.descriptionLease=void 0,super.disconnectedCallback()}firstUpdated(changed){super.firstUpdated(changed),this.composer?.updateComplete.then(this.syncDescription)}updated(_changed){super.updated(_changed),this.syncInputLimitAnnouncement();const popover=this.suggestionPopover;popover&&this.suggestionAnchor&&(popover.anchor=this.suggestionAnchor)}suggestions(){return this.activeSuggestion?.trigger==="/"?this.commandItems:this.mentionItems}detectSuggestion(value){const caret=this.composer?.selectionStart??value.length,prefix=value.slice(0,caret),match=/(?:^|\s)([@/])([^\s@/]*)$/.exec(prefix);if(!match||match[1]!=="@"&&match[1]!=="/"){this.activeSuggestion=null;return}const start=caret-match[2].length-1,items=match[1]==="@"?this.mentionItems:this.commandItems;this.activeSuggestion=items.length?{trigger:match[1],start,query:match[2]??""}:null}onInput(event){if(event.stopPropagation(),this.disabled||this.readOnly)return;const composer=event.currentTarget;this.suggestionAnchor=composer?.input??this.composer?.input??void 0,this.pendingSuggestionValue=event.detail.value,this.value=event.detail.value,this.detectSuggestion(this.value),this.emit("lr-input",{value:this.value})}onChange(event){event.stopPropagation(),!(this.disabled||this.readOnly)&&(this.value=event.detail.value,this.emit("lr-change",{value:this.value}))}onSubmit(event){event.stopPropagation(),!this.disabled&&this.emit("lr-submit",event.detail)}onStop(event){event.stopPropagation(),!this.disabled&&this.emit("lr-stop",null)}onKeyDown(event){if(event.defaultPrevented)return;const popover=this.suggestionPopover;if(!(this.disabled||this.readOnly||!this.activeSuggestion||!popover?.open)&&popover.handleKeyDown(event)){const shouldMoveFocus=event.key==="ArrowDown"||event.key==="ArrowUp",generation=++this.suggestionNavigationGeneration;popover.updateComplete.then(async()=>{shouldMoveFocus&&generation===this.suggestionNavigationGeneration&&this.isConnected&&!this.disabled&&!this.readOnly&&this.suggestionPopover===popover&&this.activeSuggestion&&popover.open&&this.suggestionFocusIsOwned(popover)&&await popover.focusActiveOption({ownsFocus:()=>generation===this.suggestionNavigationGeneration&&this.isConnected&&!this.disabled&&!this.readOnly&&this.suggestionPopover===popover&&this.activeSuggestion!==null&&popover.open&&this.suggestionFocusIsOwned(popover)})})}}suggestionFocusIsOwned(popover,focused=deepActiveElementIn(this.ownerDocument)){return focused===this.composer?.input||focused===this.composer||focused!==null&&composedContains(popover,focused)}closeSuggestions(){this.suggestionNavigationGeneration+=1,this.activeSuggestion=null,this.suggestionAnchor=void 0}onSuggestionSelect(event){if(event.stopPropagation(),this.disabled||this.readOnly)return;const active=this.activeSuggestion;if(!active)return;const occurrence=this.suggestions()[event.detail.index];if(!occurrence||occurrence.suggestionId!==event.detail.suggestionId)return;const item=occurrence,composer=this.composer,caret=composer?.selectionStart??this.value.length,inserted=`${active.trigger}${item?.insertText??event.detail.label} `;this.value=this.value.slice(0,active.start)+inserted+this.value.slice(caret);const caretGeneration=this.suggestionCaretGeneration,nextCaret=active.start+inserted.length;this.closeSuggestions(),this.emit("lr-input",{value:this.value}),this.emit("lr-mention-select",{suggestionId:event.detail.suggestionId,index:event.detail.index,label:event.detail.label,trigger:active.trigger}),this.updateComplete.then(()=>{caretGeneration===this.suggestionCaretGeneration&&this.isConnected&&this.composer===composer&&composer?.setSelectionRange(nextCaret,nextCaret)})}onFiles(event){event.stopPropagation(),!this.disabled&&this.emit("lr-attachments-add",event.detail)}get effectiveAttachments(){const seen=new Set;return this.attachments.filter(attachment=>{const id=attachment?.attachmentId;return typeof id!="string"||id.trim()===""||seen.has(id)?!1:(seen.add(id),!0)})}firstById(values,identity){let retained=this.firstByIdentity.get(values);return retained||this.firstByIdentity.set(values,retained=firstByPromptIdentity(values,identity)),retained}get effectiveSources(){return this.firstById(this.sources,source=>source.id)}get effectiveSelectedSourceIds(){return canonicalIdentityList(this.selectedSourceIds)}get effectiveQueue(){return this.firstById(this.queue,item=>item.id)}renderDefaultAttachmentTrigger(){return html`<lr-attachment-trigger multiple
2
2
  .capabilities=${this.attachmentCapabilities}
3
3
  .disabled=${this.disabled}
4
4
  @lr-files=${this.onFiles}
@@ -92,6 +92,7 @@ import{__decorate}from"tslib";import{setNativeRangeText,nativeAutocorrectAttribu
92
92
  .maxRows=${this.maxRows}
93
93
  .frame=${this.frame}
94
94
  .actionsLayout=${this.actionsLayout}
95
+ .toolbarPlacement=${this.toolbarPlacement}
95
96
  aria-label=${label}
96
97
  @lr-input=${this.onInput}
97
98
  @lr-change=${this.onChange}
@@ -123,4 +124,4 @@ import{__decorate}from"tslib";import{setNativeRangeText,nativeAutocorrectAttribu
123
124
  @lr-mention-close=${event=>{event.stopPropagation(),this.closeSuggestions()}}
124
125
  ></lr-mention-popover>
125
126
  ${this.slotPresence.has("footer")?html`<div part="footer"><slot name="footer"></slot></div>`:html`<slot name="footer" hidden aria-hidden="true"></slot>`}
126
- </section>`}}__decorate([property()],LyraPromptInput.prototype,"value",null),__decorate([property()],LyraPromptInput.prototype,"status",null),__decorate([property()],LyraPromptInput.prototype,"placeholder",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraPromptInput.prototype,"disabled",void 0),__decorate([property({type:Boolean,reflect:!0,attribute:"readonly"})],LyraPromptInput.prototype,"readOnly",void 0),__decorate([property({converter:lengthLimitConverter,attribute:"minlength"})],LyraPromptInput.prototype,"minLength",void 0),__decorate([property({converter:lengthLimitConverter,attribute:"maxlength"})],LyraPromptInput.prototype,"maxLength",void 0),__decorate([property({type:Boolean,attribute:"without-enter-submit"})],LyraPromptInput.prototype,"withoutEnterSubmit",void 0),__decorate([property({type:Boolean,attribute:"submit-disabled"})],LyraPromptInput.prototype,"submitDisabled",void 0),__decorate([property({type:Boolean,attribute:"without-stop"})],LyraPromptInput.prototype,"withoutStop",void 0),__decorate([property()],LyraPromptInput.prototype,"frame",void 0),__decorate([property({attribute:"actions-layout"})],LyraPromptInput.prototype,"actionsLayout",void 0),__decorate([property({type:Number,attribute:"min-rows"})],LyraPromptInput.prototype,"minRows",void 0),__decorate([property({type:Number,attribute:"max-rows"})],LyraPromptInput.prototype,"maxRows",void 0),__decorate([property({converter:trueDefaultBooleanConverter})],LyraPromptInput.prototype,"spellcheck",void 0),__decorate([property()],LyraPromptInput.prototype,"autocapitalize",void 0),__decorate([property({converter:autocorrectConverter})],LyraPromptInput.prototype,"autocorrect",null),__decorate([property()],LyraPromptInput.prototype,"wrap",void 0),__decorate([property()],LyraPromptInput.prototype,"autocomplete",void 0),__decorate([property({attribute:"inputmode"})],LyraPromptInput.prototype,"inputMode",void 0),__decorate([property({attribute:"enterkeyhint"})],LyraPromptInput.prototype,"enterKeyHint",void 0),__decorate([property({attribute:!1})],LyraPromptInput.prototype,"attachments",void 0),__decorate([property({attribute:!1})],LyraPromptInput.prototype,"attachmentCapabilities",void 0),__decorate([property({attribute:!1})],LyraPromptInput.prototype,"mentionItems",void 0),__decorate([property({attribute:!1})],LyraPromptInput.prototype,"commandItems",void 0),__decorate([property({attribute:!1})],LyraPromptInput.prototype,"modelCatalog",void 0),__decorate([property()],LyraPromptInput.prototype,"model",void 0),__decorate([property({attribute:!1})],LyraPromptInput.prototype,"voiceCatalog",void 0),__decorate([property()],LyraPromptInput.prototype,"voice",void 0),__decorate([property({attribute:!1})],LyraPromptInput.prototype,"sources",void 0),__decorate([property({attribute:!1})],LyraPromptInput.prototype,"selectedSourceIds",void 0),__decorate([property({attribute:!1})],LyraPromptInput.prototype,"queue",void 0),__decorate([property()],LyraPromptInput.prototype,"label",void 0),__decorate([property({attribute:"aria-label"})],LyraPromptInput.prototype,"accessibleLabel",void 0),__decorate([state()],LyraPromptInput.prototype,"activeSuggestion",void 0),__decorate([query("lr-chat-composer")],LyraPromptInput.prototype,"composer",void 0),__decorate([query("lr-mention-popover")],LyraPromptInput.prototype,"suggestionPopover",void 0);export{LyraPromptInput};
127
+ </section>`}}__decorate([property()],LyraPromptInput.prototype,"value",null),__decorate([property()],LyraPromptInput.prototype,"status",null),__decorate([property()],LyraPromptInput.prototype,"placeholder",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraPromptInput.prototype,"disabled",void 0),__decorate([property({type:Boolean,reflect:!0,attribute:"readonly"})],LyraPromptInput.prototype,"readOnly",void 0),__decorate([property({converter:lengthLimitConverter,attribute:"minlength"})],LyraPromptInput.prototype,"minLength",void 0),__decorate([property({converter:lengthLimitConverter,attribute:"maxlength"})],LyraPromptInput.prototype,"maxLength",void 0),__decorate([property({type:Boolean,attribute:"without-enter-submit"})],LyraPromptInput.prototype,"withoutEnterSubmit",void 0),__decorate([property({type:Boolean,attribute:"submit-disabled"})],LyraPromptInput.prototype,"submitDisabled",void 0),__decorate([property({type:Boolean,attribute:"without-stop"})],LyraPromptInput.prototype,"withoutStop",void 0),__decorate([property()],LyraPromptInput.prototype,"frame",void 0),__decorate([property({attribute:"actions-layout"})],LyraPromptInput.prototype,"actionsLayout",void 0),__decorate([property({attribute:"toolbar-placement"})],LyraPromptInput.prototype,"toolbarPlacement",void 0),__decorate([property({type:Number,attribute:"min-rows"})],LyraPromptInput.prototype,"minRows",void 0),__decorate([property({type:Number,attribute:"max-rows"})],LyraPromptInput.prototype,"maxRows",void 0),__decorate([property({converter:trueDefaultBooleanConverter})],LyraPromptInput.prototype,"spellcheck",void 0),__decorate([property()],LyraPromptInput.prototype,"autocapitalize",void 0),__decorate([property({converter:autocorrectConverter})],LyraPromptInput.prototype,"autocorrect",null),__decorate([property()],LyraPromptInput.prototype,"wrap",void 0),__decorate([property()],LyraPromptInput.prototype,"autocomplete",void 0),__decorate([property({attribute:"inputmode"})],LyraPromptInput.prototype,"inputMode",void 0),__decorate([property({attribute:"enterkeyhint"})],LyraPromptInput.prototype,"enterKeyHint",void 0),__decorate([property({attribute:!1})],LyraPromptInput.prototype,"attachments",void 0),__decorate([property({attribute:!1})],LyraPromptInput.prototype,"attachmentCapabilities",void 0),__decorate([property({attribute:!1})],LyraPromptInput.prototype,"mentionItems",void 0),__decorate([property({attribute:!1})],LyraPromptInput.prototype,"commandItems",void 0),__decorate([property({attribute:!1})],LyraPromptInput.prototype,"modelCatalog",void 0),__decorate([property()],LyraPromptInput.prototype,"model",void 0),__decorate([property({attribute:!1})],LyraPromptInput.prototype,"voiceCatalog",void 0),__decorate([property()],LyraPromptInput.prototype,"voice",void 0),__decorate([property({attribute:!1})],LyraPromptInput.prototype,"sources",void 0),__decorate([property({attribute:!1})],LyraPromptInput.prototype,"selectedSourceIds",void 0),__decorate([property({attribute:!1})],LyraPromptInput.prototype,"queue",void 0),__decorate([property()],LyraPromptInput.prototype,"label",void 0),__decorate([property({attribute:"aria-label"})],LyraPromptInput.prototype,"accessibleLabel",void 0),__decorate([state()],LyraPromptInput.prototype,"activeSuggestion",void 0),__decorate([query("lr-chat-composer")],LyraPromptInput.prototype,"composer",void 0),__decorate([query("lr-mention-popover")],LyraPromptInput.prototype,"suggestionPopover",void 0);export{LyraPromptInput};
@@ -7,7 +7,7 @@ import{__decorate}from"tslib";import{html,nothing,svg}from"lit";import{property,
7
7
  <path d="M19 10v2a7 7 0 0 1-14 0v-2"></path>
8
8
  <line x1="12" y1="19" x2="12" y2="23"></line>
9
9
  <line x1="8" y1="23" x2="16" y2="23"></line>
10
- `)}function pulseGlyph(){return icon(svg`<circle cx="12" cy="12" r="6"></circle>`)}class LyraPushToTalk extends LyraElement{constructor(){super(...arguments),this._mode="hold",this.timesliceMs=0,this.mimeType="",this.deviceId="",this.levelEvents=!1,this.maxDurationMs=0,this.withoutTimer=!1,this.disabled=!1,this.elapsedMs=0,this.captureSupported=!1,this._state="idle",this._stream=null,this.describedByReflected=!1,this.chunks=[],this.recordingStartedAt=0,this.lifecycleGeneration=0,this.captureSequence=0,this.intentSequence=0,this.cancelRequested=!1,this.recorderStopRequested=!1,this.recorderFailed=!1,this.tickTimer=new OwnedInterval(this),this.maxDurationTimer=new OwnedTimeout(this),this.levelFrame=new OwnedFrame(this),this.onPointerDown=e=>{if(this.mode!=="hold"||this.disabled)return;e.preventDefault();try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}if(this.holdGesture)return;const intent=this.createIntent("hold",{source:"pointer",pointerId:e.pointerId});intent&&(this.holdGesture=intent,this.startForIntent(intent))},this.onPointerUp=event=>{this.holdGesture?.source!=="pointer"||this.holdGesture.pointerId!==event.pointerId||this.releaseHoldGesture()},this.onPointerCancel=event=>{this.holdGesture?.source!=="pointer"||this.holdGesture.pointerId!==event.pointerId||this.releaseHoldGesture()},this.onKeyDown=e=>{if(this.disabled)return;if(e.key==="Escape"){if(this._state!=="requesting"&&this._state!=="recording")return;e.preventDefault(),this.cancel();return}if(e.key!=="Enter"&&e.key!==" "||this.mode!=="hold"||e.repeat||(e.preventDefault(),this.holdGesture))return;const intent=this.createIntent("hold",{source:"keyboard",key:e.key});intent&&(this.holdGesture=intent,this.startForIntent(intent))},this.onKeyUp=e=>{e.key!=="Enter"&&e.key!==" "||this.holdGesture?.source!=="keyboard"||this.holdGesture.key!==e.key||this.releaseHoldGesture()},this.onBlur=()=>{this.releaseHoldGesture()},this.onClick=()=>{this.mode!=="toggle"||this.disabled||(this._state==="recording"?this.stop():this.start())}}static{this.defaultStrings={...super.defaultStrings,pushToTalkCancelled:LYRA_DEFAULT_pushToTalkCancelled,pushToTalkDenied:LYRA_DEFAULT_pushToTalkDenied,pushToTalkError:LYRA_DEFAULT_pushToTalkError,pushToTalkHold:LYRA_DEFAULT_pushToTalkHold,pushToTalkRequesting:LYRA_DEFAULT_pushToTalkRequesting,pushToTalkStart:LYRA_DEFAULT_pushToTalkStart,pushToTalkStarted:LYRA_DEFAULT_pushToTalkStarted,pushToTalkStop:LYRA_DEFAULT_pushToTalkStop,pushToTalkStopped:LYRA_DEFAULT_pushToTalkStopped,pushToTalkUnsupported:LYRA_DEFAULT_pushToTalkUnsupported}}static{this.styles=[LyraElement.styles,styles]}get mode(){return this._mode}set mode(next){const normalized=PUSH_TO_TALK_MODE.normalize(next),old=this._mode;old!==normalized&&(this._mode=normalized,this.requestUpdate("mode",old))}get state(){return this._state}get stream(){return this._stream}get ownerWindow(){return this.ownerDocument?.defaultView??null}get captureOwner(){const owner=this.ownerWindow;if(isPushToTalkSupported(owner))return{document:this.ownerDocument,window:owner,generation:this.lifecycleGeneration}}ownsCurrentLifecycle(owner){return this.isConnected&&this.isCurrentRealm(owner)&&this.lifecycleGeneration===owner.generation}isCurrentRealm(owner){return this.ownerDocument===owner.document&&this.ownerWindow===owner.window}rebaseCurrentRealmOwner(owner){this.isCurrentRealm(owner)&&(owner.generation=this.lifecycleGeneration)}createIntent(kind,details={}){const owner=this.captureOwner;if(!owner)return;const intent={id:++this.intentSequence,owner,kind,...details};return this.captureIntent=intent,intent}isLiveIntent(intent){return this.captureIntent===intent&&!this.disabled&&this.ownsCurrentLifecycle(intent.owner)&&(intent.kind!=="hold"||this.holdGesture===intent)}clearIntent(intent){this.captureIntent===intent&&(this.captureIntent=void 0),this.holdGesture===intent&&(this.holdGesture=void 0),this.queuedIntent===intent&&(this.queuedIntent=void 0)}retirePendingRequest(request,notifyCancellation){request.invalidated=!0,request.notifyCancellation||=notifyCancellation,request.retiredAtIntentId=this.intentSequence,request.retiredAtGeneration=this.lifecycleGeneration,this.pendingRequest===request&&(this.pendingRequest=void 0),this.clearIntent(request.intent),this._state==="requesting"&&!this.activeCapture&&this.setState("idle")}invalidateLifecycle(notifyCancellation,retainCurrentRealmIntents=!1){this.lifecycleGeneration+=1,this.captureIntent&&retainCurrentRealmIntents&&this.isCurrentRealm(this.captureIntent.owner)?this.rebaseCurrentRealmOwner(this.captureIntent.owner):this.captureIntent=void 0,this.holdGesture&&retainCurrentRealmIntents&&this.isCurrentRealm(this.holdGesture.owner)?this.rebaseCurrentRealmOwner(this.holdGesture.owner):this.holdGesture=void 0,this.queuedIntent&&retainCurrentRealmIntents&&this.isCurrentRealm(this.queuedIntent.owner)?this.rebaseCurrentRealmOwner(this.queuedIntent.owner):this.queuedIntent=void 0;const request=this.pendingRequest;request&&this.retirePendingRequest(request,notifyCancellation);const active=this.activeCapture;active&&(active.notifyCancellation&&=notifyCancellation,this.requestRecorderStop(!0))}canAdoptRequest(request,intent){return this.pendingRequest===request&&!request.invalidated&&this._state==="requesting"&&this.ownsCurrentLifecycle(request.owner)&&this.isLiveIntent(intent)&&request.owner.document===intent.owner.document&&request.owner.window===intent.owner.window&&request.owner.generation===intent.owner.generation}canStartRequest(request){return this.canAdoptRequest(request,request.intent)}notifyCancellation(){this.emit("lr-record-cancel",null),this.isConnected&&this.announce(this.localize("pushToTalkCancelled"))}resumeQueuedIntent(){const intent=this.queuedIntent;this.queuedIntent=void 0,!(!intent||!this.isLiveIntent(intent))&&this.startForIntent(intent)}finishRetiredRequest(request){request.notifyCancellation&&!request.cancellationNotified&&request.retiredAtIntentId===this.intentSequence&&request.retiredAtGeneration===this.lifecycleGeneration&&!this.pendingRequest&&!this.activeCapture&&!this.captureIntent&&(request.cancellationNotified=!0,this.notifyCancellation())}finishUnusableRequest(request){if(request.invalidated){this.finishRetiredRequest(request);return}this.pendingRequest===request&&(this.pendingRequest=void 0),this.clearIntent(request.intent),this._state==="requesting"&&!this.activeCapture&&this.setState("idle"),this.notifyCancellation()}syncCaptureSupport(){this.captureSupported=isPushToTalkSupported(this.ownerWindow)}connectedCallback(){super.connectedCallback(),this.requestUpdate("mode",void 0),this.hasAttribute("data-state")||this.setAttribute("data-state",this._state)}disconnectedCallback(){const previousOwner=this.activeCapture?.owner??this.pendingRequest?.owner;this.invalidateLifecycle(!1,!!previousOwner&&!this.isCurrentRealm(previousOwner)),super.disconnectedCallback()}adoptedCallback(){this.invalidateLifecycle(!1,!0),super.adoptedCallback(),this.syncCaptureSupport()}willUpdate(changed){super.willUpdate(changed),this.hasUpdated?this.syncCaptureSupport():this.seedFirstRenderState(()=>this.syncCaptureSupport()),changed.has("mode")&&changed.get("mode")!==void 0&&this.holdGesture&&this.releaseHoldGesture(!0),changed.has("disabled")&&this.disabled&&this.invalidateLifecycle(!0);const owner=this.captureWindow;this._state!=="recording"||!owner||(changed.has("withoutTimer")&&this.syncElapsedTimer(owner),changed.has("maxDurationMs")&&this.syncMaxDurationTimer(owner),changed.has("levelEvents")&&this.syncLevelMeter(owner))}updated(changed){super.updated(changed);const describedBy=this.getAttribute("aria-describedby");(describedBy||this.describedByReflected)&&(this.describedByReflected=syncAriaDescribedByElements(this,this.trigger,describedBy))}focus(options){this.trigger?.focus(options)}blur(){this.trigger?.blur()}click(){this.disabled||!isPushToTalkSupported(this.ownerWindow)||(this.mode==="toggle"?this.trigger?.click():this._state==="recording"?this.stop():this.start())}resolveMimeType(owner){if(this.mimeType)return this.mimeType;for(const candidate of CANDIDATE_MIME_TYPES)if(owner.MediaRecorder.isTypeSupported?.(candidate))return candidate;return""}setState(next){if(this._state===next)return;const old=this._state;this._state=next,this.setAttribute("data-state",next),this.requestUpdate("state",old),this.emit("lr-record-state-change",{state:next})}announce(text){const region=this.liveRegion;region&&(region.mode="polite",region.announce(text,{force:!0}))}async start(){if(this.disabled||this._state==="recording")return!1;const intent=this.createIntent("programmatic");return intent?this.startForIntent(intent):!1}startForIntent(intent){const pending=this.pendingRequest;if(pending)return pending.intent=intent,pending.completion??Promise.resolve(!1);if(this._state==="recording")return intent.kind==="hold"&&this.activeCapture&&this.recorderStopRequested&&this.isLiveIntent(intent)?(this.queuedIntent=intent,Promise.resolve(!1)):(this.clearIntent(intent),Promise.resolve(!1));if(!this.isLiveIntent(intent))return this.clearIntent(intent),Promise.resolve(!1);const request={id:++this.captureSequence,owner:intent.owner,intent,invalidated:!1,notifyCancellation:!1,cancellationNotified:!1};this.pendingRequest=request,this.setState("requesting");const completion=this.requestPermission(request);return request.completion=completion,completion}captureConstraints(){const additionalConstraints={...this.audioConstraints??{}};return delete additionalConstraints.deviceId,{audio:{...additionalConstraints,...this.deviceId?{deviceId:{exact:this.deviceId}}:{}}}}async requestPermission(request){try{const stream=await request.owner.window.navigator.mediaDevices.getUserMedia(this.captureConstraints());if(!this.canStartRequest(request)){for(const track of stream.getTracks())track.stop();return this.finishUnusableRequest(request),!1}return this.pendingRequest=void 0,this.startRecorder(request,stream)}catch(error){if(!this.canStartRequest(request))return this.finishUnusableRequest(request),!1;this.pendingRequest=void 0,this.clearIntent(request.intent);const denied=typeof error=="object"&&error!==null&&"name"in error&&error.name==="NotAllowedError";return this.setState(denied?"denied":"error"),this.emit("lr-record-error",{error}),this.announce(this.localize(denied?"pushToTalkDenied":"pushToTalkError")),!1}}startRecorder(request,stream){const owner=request.owner.window,active={id:request.id,owner:request.owner,intent:request.intent,notifyCancellation:!0};this.activeCapture=active,this.captureWindow=owner,this._stream=stream,this.cancelRequested=!1,this.recorderStopRequested=!1,this.recorderFailed=!1,this.chunks=[];try{const mimeType=this.resolveMimeType(owner),recorder=new owner.MediaRecorder(stream,mimeType?{mimeType}:void 0);this.recorder=recorder;const timeslice=this.timesliceMs>0?finiteDuration(this.timesliceMs,MAX_TIMEOUT_MS,1,MAX_TIMEOUT_MS):void 0,emitChunksForTake=timeslice!==void 0;return recorder.ondataavailable=event=>{this.recorder!==recorder||this.activeCapture!==active||!event.data||event.data.size===0||(this.chunks.push(event.data),emitChunksForTake&&this.emit("lr-record-chunk",{blob:event.data}))},recorder.onstop=()=>this.finalizeStop(recorder,active),recorder.onerror=event=>this.failRecorder(recorder,active,event.error??new Error("MediaRecorder failed")),recorder.start(timeslice),this.recordingStartedAt=owner.performance.now(),this.elapsedMs=0,this.setState("recording"),this.emit("lr-record-start",{stream}),this.announce(this.localize("pushToTalkStarted")),this.syncLevelMeter(owner),this.syncMaxDurationTimer(owner,!0),this.syncElapsedTimer(owner,!0),!0}catch(error){if(this.activeCapture!==active){for(const track of stream.getTracks())track.stop();return!1}return this.teardownStream(active),this.clearIntent(active.intent),this.setState("error"),this.emit("lr-record-error",{error}),this.announce(this.localize("pushToTalkError")),!1}}stop(){this.requestRecorderStop(!1)}cancel(){const pending=this.pendingRequest;if(pending&&this._state==="requesting"){this.retirePendingRequest(pending,!0);return}this._state==="recording"&&this.requestRecorderStop(!0)}requestRecorderStop(cancelled){const active=this.activeCapture;if(this._state!=="recording"||!active||(cancelled&&(this.cancelRequested=!0),this.recorderStopRequested))return;this.recorderStopRequested=!0,this.stopRuntimeLoops();const recorder=this.recorder;recorder&&recorder.state!=="inactive"&&recorder.stop()}finalizeStop(recorder,active){if(this.recorder!==recorder||this.activeCapture!==active||this.recorderFailed)return;const owner=active.owner.window,cancelled=this.cancelRequested,durationMs=Math.round(owner.performance.now()-this.recordingStartedAt),mimeType=recorder.mimeType||this.resolveMimeType(owner)||"audio/webm",blob=new owner.Blob(this.chunks,{type:mimeType});this.teardownStream(active),this.clearIntent(active.intent),this.setState("idle"),cancelled?active.notifyCancellation&&this.notifyCancellation():(this.emit("lr-record-stop",{blob,durationMs}),this.announce(this.localize("pushToTalkStopped"))),this.cancelRequested=!1,this.resumeQueuedIntent()}failRecorder(recorder,active,error){this.recorder!==recorder||this.activeCapture!==active||this.recorderFailed||this.cancelRequested||(this.recorderFailed=!0,this.cancelRequested=!1,this.teardownStream(active),this.clearIntent(active.intent),this.setState("error"),this.emit("lr-record-error",{error}),this.announce(this.localize("pushToTalkError")),this.resumeQueuedIntent())}teardownStream(active=this.activeCapture){if(!(!active||this.activeCapture!==active)){for(const track of this._stream?.getTracks()??[])track.stop();this._stream=null,this.recorder&&(this.recorder.ondataavailable=null,this.recorder.onstop=null,this.recorder.onerror=null),this.recorder=void 0,this.recorderStopRequested=!1,this.chunks=[],this.stopRuntimeLoops(),this.captureWindow=void 0,this.activeCapture=void 0}}stopRuntimeLoops(){this.tickTimer.cancel(),this.maxDurationTimer.cancel(),this.stopLevelMeter()}syncElapsedTimer(owner,initial=!1){this.tickTimer.cancel();const active=this.activeCapture;this.withoutTimer||this._state!=="recording"||!active||active.owner.window!==owner||!this.ownsCurrentLifecycle(active.owner)||(initial||(this.elapsedMs=owner.performance.now()-this.recordingStartedAt),this.tickTimer.schedule(1e3,()=>{this.activeCapture!==active||this._state!=="recording"||!this.ownsCurrentLifecycle(active.owner)||(this.elapsedMs=owner.performance.now()-this.recordingStartedAt)}))}syncMaxDurationTimer(owner,initial=!1){this.maxDurationTimer.cancel();const active=this.activeCapture;if(this.maxDurationMs<=0||this._state!=="recording"||!active||active.owner.window!==owner||!this.ownsCurrentLifecycle(active.owner))return;const duration=finiteDuration(this.maxDurationMs,MAX_TIMEOUT_MS,1,MAX_TIMEOUT_MS),elapsed=initial?0:Math.max(0,owner.performance.now()-this.recordingStartedAt);this.maxDurationTimer.schedule(Math.max(0,duration-elapsed),()=>{this.activeCapture!==active||!this.ownsCurrentLifecycle(active.owner)||this.stop()})}syncLevelMeter(owner){const active=this.activeCapture;if(!this.levelEvents||this._state!=="recording"||!active||active.owner.window!==owner||!this.ownsCurrentLifecycle(active.owner)||!this._stream){this.stopLevelMeter();return}this.audioCtx||this.startLevelMeter(this._stream,owner)}startLevelMeter(stream,owner){const AudioCtxCtor=owner.AudioContext??owner.webkitAudioContext;if(AudioCtxCtor)try{const audioCtx=new AudioCtxCtor;this.audioCtx=audioCtx,audioCtx.resume().catch(()=>{});const source=audioCtx.createMediaStreamSource(stream),analyser=audioCtx.createAnalyser();this.analyser=analyser,analyser.fftSize=256,source.connect(analyser),this.levelData=new owner.Uint8Array(analyser.frequencyBinCount),this.sampleLevel(owner)}catch{this.stopLevelMeter()}}sampleLevel(owner){const active=this.activeCapture;if(!this.analyser||!this.levelData||this._state!=="recording"||!active||active.owner.window!==owner||!this.ownsCurrentLifecycle(active.owner))return;this.analyser.getByteTimeDomainData(this.levelData);let sumSquares=0;for(const v of this.levelData){const norm=(v-128)/128;sumSquares+=norm*norm}const rms=Math.sqrt(sumSquares/this.levelData.length);this.emit("lr-level",{level:Math.min(1,rms)}),this.levelFrame.schedule(()=>{this.activeCapture===active&&this.ownsCurrentLifecycle(active.owner)&&this.sampleLevel(owner)})}stopLevelMeter(){this.levelFrame.cancel(),this.analyser=void 0,this.levelData=void 0,this.audioCtx&&(this.audioCtx.close().catch(()=>{}),this.audioCtx=void 0)}formatElapsed(ms){return formatMediaTime(ms/1e3,this.effectiveLocale)}releaseHoldGesture(retirePending=!1){const intent=this.holdGesture;if(!intent)return;this.holdGesture=void 0,this.captureIntent===intent&&(this.captureIntent=void 0),this.queuedIntent===intent&&(this.queuedIntent=void 0);const pending=this.pendingRequest;if(pending?.intent===intent){retirePending&&this.retirePendingRequest(pending,!0);return}this.activeCapture?.intent===intent&&this.requestRecorderStop(!1)}get triggerLabel(){const override=this.getAttribute("aria-label");return override!==null?override:this.mode==="hold"?this.localize("pushToTalkHold"):this._state==="recording"?this.localize("pushToTalkStop"):this.localize("pushToTalkStart")}get statusText(){if(!this.captureSupported)return this.localize("pushToTalkUnsupported");switch(this._state){case"requesting":return this.localize("pushToTalkRequesting");case"denied":return this.localize("pushToTalkDenied");case"error":return this.localize("pushToTalkError");default:return""}}render(){const supported=this.captureSupported,recording=this._state==="recording",status=this.statusText;return html`
10
+ `)}function pulseGlyph(){return icon(svg`<circle cx="12" cy="12" r="6"></circle>`)}class LyraPushToTalk extends LyraElement{constructor(){super(...arguments),this._mode="hold",this.timesliceMs=0,this.mimeType="",this.deviceId="",this.levelEvents=!1,this.maxDurationMs=0,this.withoutTimer=!1,this.disabled=!1,this.elapsedMs=0,this.captureSupported=!1,this._state="idle",this._stream=null,this.describedByReflected=!1,this.chunks=[],this.recordingStartedAt=0,this.lifecycleGeneration=0,this.captureSequence=0,this.intentSequence=0,this.cancelRequested=!1,this.recorderStopRequested=!1,this.recorderFailed=!1,this.tickTimer=new OwnedInterval(this),this.maxDurationTimer=new OwnedTimeout(this),this.levelFrame=new OwnedFrame(this),this.onPointerDown=e=>{if(this.mode!=="hold"||this.disabled)return;e.preventDefault();try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}if(this.holdGesture)return;const intent=this.createIntent("hold",{source:"pointer",pointerId:e.pointerId});intent&&(this.holdGesture=intent,this.startForIntent(intent))},this.onPointerUp=event=>{this.holdGesture?.source!=="pointer"||this.holdGesture.pointerId!==event.pointerId||this.releaseHoldGesture()},this.onPointerCancel=event=>{this.holdGesture?.source!=="pointer"||this.holdGesture.pointerId!==event.pointerId||this.releaseHoldGesture()},this.onKeyDown=e=>{if(this.disabled)return;if(e.key==="Escape"){if(this._state!=="requesting"&&this._state!=="recording")return;e.preventDefault(),this.cancel();return}if(e.key!=="Enter"&&e.key!==" "||this.mode!=="hold"||e.repeat||(e.preventDefault(),this.holdGesture))return;const intent=this.createIntent("hold",{source:"keyboard",key:e.key});intent&&(this.holdGesture=intent,this.startForIntent(intent))},this.onKeyUp=e=>{e.key!=="Enter"&&e.key!==" "||this.holdGesture?.source!=="keyboard"||this.holdGesture.key!==e.key||this.releaseHoldGesture()},this.onBlur=()=>{this.releaseHoldGesture()},this.onClick=()=>{this.mode!=="toggle"||this.disabled||(this._state==="recording"?this.stop():this.start())}}static{this.defaultStrings={...super.defaultStrings,pushToTalkCancelled:LYRA_DEFAULT_pushToTalkCancelled,pushToTalkDenied:LYRA_DEFAULT_pushToTalkDenied,pushToTalkError:LYRA_DEFAULT_pushToTalkError,pushToTalkHold:LYRA_DEFAULT_pushToTalkHold,pushToTalkRequesting:LYRA_DEFAULT_pushToTalkRequesting,pushToTalkStart:LYRA_DEFAULT_pushToTalkStart,pushToTalkStarted:LYRA_DEFAULT_pushToTalkStarted,pushToTalkStop:LYRA_DEFAULT_pushToTalkStop,pushToTalkStopped:LYRA_DEFAULT_pushToTalkStopped,pushToTalkUnsupported:LYRA_DEFAULT_pushToTalkUnsupported}}static{this.styles=[LyraElement.styles,styles]}get mode(){return this._mode}set mode(next){const normalized=PUSH_TO_TALK_MODE.normalize(next),old=this._mode;old!==normalized&&(this._mode=normalized,this.requestUpdate("mode",old))}get state(){return this._state}get stream(){return this._stream}get ownerWindow(){return this.ownerDocument?.defaultView??null}get captureOwner(){const owner=this.ownerWindow;if(isPushToTalkSupported(owner))return{document:this.ownerDocument,window:owner,generation:this.lifecycleGeneration}}ownsCurrentLifecycle(owner){return this.isConnected&&this.isCurrentRealm(owner)&&this.lifecycleGeneration===owner.generation}isCurrentRealm(owner){return this.ownerDocument===owner.document&&this.ownerWindow===owner.window}rebaseCurrentRealmOwner(owner){this.isCurrentRealm(owner)&&(owner.generation=this.lifecycleGeneration)}createIntent(kind,details={}){const owner=this.captureOwner;if(!owner)return;const intent={id:++this.intentSequence,owner,kind,...details};return this.captureIntent=intent,intent}isLiveIntent(intent){return this.captureIntent===intent&&!this.disabled&&this.ownsCurrentLifecycle(intent.owner)&&(intent.kind!=="hold"||this.holdGesture===intent)}clearIntent(intent){this.captureIntent===intent&&(this.captureIntent=void 0),this.holdGesture===intent&&(this.holdGesture=void 0),this.queuedIntent===intent&&(this.queuedIntent=void 0)}retirePendingRequest(request,notifyCancellation){request.invalidated=!0,request.notifyCancellation||=notifyCancellation,request.retiredAtIntentId=this.intentSequence,request.retiredAtGeneration=this.lifecycleGeneration,this.pendingRequest===request&&(this.pendingRequest=void 0),this.clearIntent(request.intent),this._state==="requesting"&&!this.activeCapture&&this.setState("idle")}invalidateLifecycle(notifyCancellation,retainCurrentRealmIntents=!1){this.lifecycleGeneration+=1,this.captureIntent&&retainCurrentRealmIntents&&this.isCurrentRealm(this.captureIntent.owner)?this.rebaseCurrentRealmOwner(this.captureIntent.owner):this.captureIntent=void 0,this.holdGesture&&retainCurrentRealmIntents&&this.isCurrentRealm(this.holdGesture.owner)?this.rebaseCurrentRealmOwner(this.holdGesture.owner):this.holdGesture=void 0,this.queuedIntent&&retainCurrentRealmIntents&&this.isCurrentRealm(this.queuedIntent.owner)?this.rebaseCurrentRealmOwner(this.queuedIntent.owner):this.queuedIntent=void 0;const request=this.pendingRequest;request&&this.retirePendingRequest(request,notifyCancellation);const active=this.activeCapture;active&&(active.notifyCancellation&&=notifyCancellation,this.requestRecorderStop(!0))}canAdoptRequest(request,intent){return this.pendingRequest===request&&!request.invalidated&&this._state==="requesting"&&this.ownsCurrentLifecycle(request.owner)&&this.isLiveIntent(intent)&&request.owner.document===intent.owner.document&&request.owner.window===intent.owner.window&&request.owner.generation===intent.owner.generation}canStartRequest(request){return this.canAdoptRequest(request,request.intent)}notifyCancellation(){this.emit("lr-record-cancel",null),this.isConnected&&this.announce(this.localize("pushToTalkCancelled"))}resumeQueuedIntent(){const intent=this.queuedIntent;this.queuedIntent=void 0,!(!intent||!this.isLiveIntent(intent))&&this.startForIntent(intent)}finishRetiredRequest(request){request.notifyCancellation&&!request.cancellationNotified&&request.retiredAtIntentId===this.intentSequence&&request.retiredAtGeneration===this.lifecycleGeneration&&!this.pendingRequest&&!this.activeCapture&&!this.captureIntent&&(request.cancellationNotified=!0,this.notifyCancellation())}finishUnusableRequest(request){if(request.invalidated){this.finishRetiredRequest(request);return}this.pendingRequest===request&&(this.pendingRequest=void 0),this.clearIntent(request.intent),this._state==="requesting"&&!this.activeCapture&&this.setState("idle"),this.notifyCancellation()}syncCaptureSupport(){this.captureSupported=isPushToTalkSupported(this.ownerWindow)}connectedCallback(){super.connectedCallback(),this.requestUpdate("mode",void 0),this.hasAttribute("data-state")||this.setAttribute("data-state",this._state)}disconnectedCallback(){const previousOwner=this.activeCapture?.owner??this.pendingRequest?.owner;this.invalidateLifecycle(!1,!!previousOwner&&!this.isCurrentRealm(previousOwner)),super.disconnectedCallback()}adoptedCallback(){this.invalidateLifecycle(!1,!0),super.adoptedCallback(),this.syncCaptureSupport()}willUpdate(changed){super.willUpdate(changed),this.hasUpdated?this.syncCaptureSupport():this.seedFirstRenderState(()=>this.syncCaptureSupport()),changed.has("mode")&&changed.get("mode")!==void 0&&this.holdGesture&&this.releaseHoldGesture(!0),changed.has("disabled")&&this.disabled&&this.invalidateLifecycle(!0);const owner=this.captureWindow;this._state!=="recording"||!owner||(changed.has("withoutTimer")&&this.syncElapsedTimer(owner),changed.has("maxDurationMs")&&this.syncMaxDurationTimer(owner),changed.has("levelEvents")&&this.syncLevelMeter(owner))}updated(changed){super.updated(changed);const describedBy=this.getAttribute("aria-describedby");(describedBy||this.describedByReflected)&&(this.describedByReflected=syncAriaDescribedByElements(this,this.trigger,describedBy))}focus(options){this.trigger?.focus(options)}blur(){this.trigger?.blur()}click(){this.disabled||!isPushToTalkSupported(this.ownerWindow)||(this.mode==="toggle"?this.trigger?.click():this._state==="recording"?this.stop():this.start())}resolveMimeType(owner){if(this.mimeType)return this.mimeType;for(const candidate of CANDIDATE_MIME_TYPES)if(owner.MediaRecorder.isTypeSupported?.(candidate))return candidate;return""}setState(next){if(this._state===next)return;const old=this._state;this._state=next,this.setAttribute("data-state",next),this.requestUpdate("state",old),this.emit("lr-record-state-change",{state:next})}announce(text){const region=this.liveRegion;region&&(region.mode="polite",region.announce(text,{force:!0}))}async start(){if(this.disabled||this._state==="recording")return!1;const intent=this.createIntent("programmatic");return intent?this.startForIntent(intent):!1}startForIntent(intent){const pending=this.pendingRequest;if(pending)return pending.intent=intent,pending.completion??Promise.resolve(!1);if(this._state==="recording")return intent.kind==="hold"&&this.activeCapture&&this.recorderStopRequested&&this.isLiveIntent(intent)?(this.queuedIntent=intent,Promise.resolve(!1)):(this.clearIntent(intent),Promise.resolve(!1));if(!this.isLiveIntent(intent))return this.clearIntent(intent),Promise.resolve(!1);const request={id:++this.captureSequence,owner:intent.owner,intent,invalidated:!1,notifyCancellation:!1,cancellationNotified:!1};this.pendingRequest=request,this.setState("requesting");const completion=this.requestPermission(request);return request.completion=completion,completion}captureConstraints(){const additionalConstraints={...this.audioConstraints??{}};return delete additionalConstraints.deviceId,{audio:{...additionalConstraints,...this.deviceId?{deviceId:{exact:this.deviceId}}:{}}}}async requestPermission(request){if(!this.canStartRequest(request))return this.finishUnusableRequest(request),!1;try{const stream=await request.owner.window.navigator.mediaDevices.getUserMedia(this.captureConstraints());if(!this.canStartRequest(request)){for(const track of stream.getTracks())track.stop();return this.finishUnusableRequest(request),!1}return this.pendingRequest=void 0,this.startRecorder(request,stream)}catch(error){if(!this.canStartRequest(request))return this.finishUnusableRequest(request),!1;this.pendingRequest=void 0,this.clearIntent(request.intent);const denied=typeof error=="object"&&error!==null&&"name"in error&&error.name==="NotAllowedError";return this.setState(denied?"denied":"error"),this.emit("lr-record-error",{error}),this.announce(this.localize(denied?"pushToTalkDenied":"pushToTalkError")),!1}}startRecorder(request,stream){const owner=request.owner.window,active={id:request.id,owner:request.owner,intent:request.intent,notifyCancellation:!0};this.activeCapture=active,this.captureWindow=owner,this._stream=stream,this.cancelRequested=!1,this.recorderStopRequested=!1,this.recorderFailed=!1,this.chunks=[];try{const mimeType=this.resolveMimeType(owner),recorder=new owner.MediaRecorder(stream,mimeType?{mimeType}:void 0);this.recorder=recorder;const timeslice=this.timesliceMs>0?finiteDuration(this.timesliceMs,MAX_TIMEOUT_MS,1,MAX_TIMEOUT_MS):void 0,emitChunksForTake=timeslice!==void 0;return recorder.ondataavailable=event=>{this.recorder!==recorder||this.activeCapture!==active||!event.data||event.data.size===0||(this.chunks.push(event.data),emitChunksForTake&&this.emit("lr-record-chunk",{blob:event.data}))},recorder.onstop=()=>this.finalizeStop(recorder,active),recorder.onerror=event=>this.failRecorder(recorder,active,event.error??new Error("MediaRecorder failed")),recorder.start(timeslice),this.recordingStartedAt=owner.performance.now(),this.elapsedMs=0,this.setState("recording"),this.activeCapture!==active||!this.ownsCurrentLifecycle(active.owner)||this.recorderStopRequested||(this.emit("lr-record-start",{stream}),this.announce(this.localize("pushToTalkStarted")),this.syncLevelMeter(owner),this.syncMaxDurationTimer(owner,!0),this.syncElapsedTimer(owner,!0)),!0}catch(error){if(this.activeCapture!==active){for(const track of stream.getTracks())track.stop();return!1}return this.teardownStream(active),this.clearIntent(active.intent),this.setState("error"),this.emit("lr-record-error",{error}),this.announce(this.localize("pushToTalkError")),!1}}stop(){this.requestRecorderStop(!1)}cancel(){const pending=this.pendingRequest;if(pending&&this._state==="requesting"){this.retirePendingRequest(pending,!0);return}this._state==="recording"&&this.requestRecorderStop(!0)}requestRecorderStop(cancelled){const active=this.activeCapture;if(this._state!=="recording"||!active||(cancelled&&(this.cancelRequested=!0),this.recorderStopRequested))return;this.recorderStopRequested=!0,this.stopRuntimeLoops();const recorder=this.recorder;recorder&&recorder.state!=="inactive"&&recorder.stop()}finalizeStop(recorder,active){if(this.recorder!==recorder||this.activeCapture!==active||this.recorderFailed)return;const owner=active.owner.window,cancelled=this.cancelRequested,durationMs=Math.round(owner.performance.now()-this.recordingStartedAt),mimeType=recorder.mimeType||this.resolveMimeType(owner)||"audio/webm",blob=new owner.Blob(this.chunks,{type:mimeType});this.teardownStream(active),this.clearIntent(active.intent),this.setState("idle"),cancelled?active.notifyCancellation&&this.notifyCancellation():(this.emit("lr-record-stop",{blob,durationMs}),this.announce(this.localize("pushToTalkStopped"))),this.cancelRequested=!1,this.resumeQueuedIntent()}failRecorder(recorder,active,error){this.recorder!==recorder||this.activeCapture!==active||this.recorderFailed||this.cancelRequested||(this.recorderFailed=!0,this.cancelRequested=!1,this.teardownStream(active),this.clearIntent(active.intent),this.setState("error"),this.emit("lr-record-error",{error}),this.announce(this.localize("pushToTalkError")),this.resumeQueuedIntent())}teardownStream(active=this.activeCapture){if(!(!active||this.activeCapture!==active)){for(const track of this._stream?.getTracks()??[])track.stop();this._stream=null,this.recorder&&(this.recorder.ondataavailable=null,this.recorder.onstop=null,this.recorder.onerror=null),this.recorder=void 0,this.recorderStopRequested=!1,this.chunks=[],this.stopRuntimeLoops(),this.captureWindow=void 0,this.activeCapture=void 0}}stopRuntimeLoops(){this.tickTimer.cancel(),this.maxDurationTimer.cancel(),this.stopLevelMeter()}syncElapsedTimer(owner,initial=!1){this.tickTimer.cancel();const active=this.activeCapture;this.withoutTimer||this._state!=="recording"||!active||active.owner.window!==owner||!this.ownsCurrentLifecycle(active.owner)||(initial||(this.elapsedMs=owner.performance.now()-this.recordingStartedAt),this.tickTimer.schedule(1e3,()=>{this.activeCapture!==active||this._state!=="recording"||!this.ownsCurrentLifecycle(active.owner)||(this.elapsedMs=owner.performance.now()-this.recordingStartedAt)}))}syncMaxDurationTimer(owner,initial=!1){this.maxDurationTimer.cancel();const active=this.activeCapture;if(this.maxDurationMs<=0||this._state!=="recording"||!active||active.owner.window!==owner||!this.ownsCurrentLifecycle(active.owner))return;const duration=finiteDuration(this.maxDurationMs,MAX_TIMEOUT_MS,1,MAX_TIMEOUT_MS),elapsed=initial?0:Math.max(0,owner.performance.now()-this.recordingStartedAt);this.maxDurationTimer.schedule(Math.max(0,duration-elapsed),()=>{this.activeCapture!==active||!this.ownsCurrentLifecycle(active.owner)||this.stop()})}syncLevelMeter(owner){const active=this.activeCapture;if(!this.levelEvents||this._state!=="recording"||!active||active.owner.window!==owner||!this.ownsCurrentLifecycle(active.owner)||!this._stream){this.stopLevelMeter();return}this.audioCtx||this.startLevelMeter(this._stream,owner)}startLevelMeter(stream,owner){const AudioCtxCtor=owner.AudioContext??owner.webkitAudioContext;if(AudioCtxCtor)try{const audioCtx=new AudioCtxCtor;this.audioCtx=audioCtx,audioCtx.resume().catch(()=>{});const source=audioCtx.createMediaStreamSource(stream),analyser=audioCtx.createAnalyser();this.analyser=analyser,analyser.fftSize=256,source.connect(analyser),this.levelData=new owner.Uint8Array(analyser.frequencyBinCount),this.sampleLevel(owner)}catch{this.stopLevelMeter()}}sampleLevel(owner){const active=this.activeCapture;if(!this.analyser||!this.levelData||this._state!=="recording"||!active||active.owner.window!==owner||!this.ownsCurrentLifecycle(active.owner))return;this.analyser.getByteTimeDomainData(this.levelData);let sumSquares=0;for(const v of this.levelData){const norm=(v-128)/128;sumSquares+=norm*norm}const rms=Math.sqrt(sumSquares/this.levelData.length);this.emit("lr-level",{level:Math.min(1,rms)}),this.levelFrame.schedule(()=>{this.activeCapture===active&&this.ownsCurrentLifecycle(active.owner)&&this.sampleLevel(owner)})}stopLevelMeter(){this.levelFrame.cancel(),this.analyser=void 0,this.levelData=void 0,this.audioCtx&&(this.audioCtx.close().catch(()=>{}),this.audioCtx=void 0)}formatElapsed(ms){return formatMediaTime(ms/1e3,this.effectiveLocale)}releaseHoldGesture(retirePending=!1){const intent=this.holdGesture;if(!intent)return;this.holdGesture=void 0,this.captureIntent===intent&&(this.captureIntent=void 0),this.queuedIntent===intent&&(this.queuedIntent=void 0);const pending=this.pendingRequest;if(pending?.intent===intent){retirePending&&this.retirePendingRequest(pending,!0);return}this.activeCapture?.intent===intent&&this.requestRecorderStop(!1)}get triggerLabel(){const override=this.getAttribute("aria-label");return override!==null?override:this.mode==="hold"?this.localize("pushToTalkHold"):this._state==="recording"?this.localize("pushToTalkStop"):this.localize("pushToTalkStart")}get statusText(){if(!this.captureSupported)return this.localize("pushToTalkUnsupported");switch(this._state){case"requesting":return this.localize("pushToTalkRequesting");case"denied":return this.localize("pushToTalkDenied");case"error":return this.localize("pushToTalkError");default:return""}}render(){const supported=this.captureSupported,recording=this._state==="recording",status=this.statusText;return html`
11
11
  <button
12
12
  part="trigger"
13
13
  type="button"
@@ -60,6 +60,10 @@ withoutImages:boolean;
60
60
  * `link-target=""` attribute) to omit `target`/`rel` entirely so rendered links open in the
61
61
  * same tab. */
62
62
  linkTarget:string|null;
63
+ /** Forwarded verbatim to the composed Markdown element's own `linkSchemes` -- narrows which link
64
+ * destinations may become anchors (for example `link-schemes="https"`); a refused link renders
65
+ * as plain text. Unset keeps the standard allowlist. */
66
+ linkSchemes?:string;
63
67
  /** Forwarded verbatim to the composed Markdown element's own `internalLinkPrefix`. Empty (the
64
68
  * default) matches the composed element's own default -- every link is treated as external. */
65
69
  internalLinkPrefix:string;
@@ -1,3 +1,3 @@
1
1
  import{__decorate}from"tslib";import{combineShikiLanguageSources}from"../../../internal/shiki-language-sources.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{Announcer}from"../../../internal/announcer.js";import{finiteDuration}from"../../../internal/numbers.js";import{streamingTailText}from"../markdown/markdown-streaming-tail.js";import{styles}from"./streaming-text.styles.js";import{IncrementalMarkdownDetector}from"./markdown-detection.js";import{looksLikeMarkdown}from"./markdown-detection.js";const DEFAULT_COALESCE_MS=50;class StreamingTextRuntimeBase extends LyraElement{static{this.styles=[LyraElement.styles,styles]}get markdownLanguages(){return combineShikiLanguageSources(this.languages,this.languageLoaders)}get safeCoalesceMs(){return finiteDuration(this.coalesceMs,DEFAULT_COALESCE_MS,0)}constructor(){super(),this.content="",this.streaming=!1,this.streamingRender="plain",this.coalesceMs=DEFAULT_COALESCE_MS,this.contentMode="auto",this.tabSize=4,this.htmlMode="sanitize",this.withoutGfm=!1,this.withoutImages=!1,this.linkTarget="_blank",this.internalLinkPrefix="",this.headingOffset=0,this.withoutSyntaxHighlighting=!1,this.headingAnchors=!1,this.math=!1,this.maxHeight="",this.displayedContent="",this.lastScannedResult=!1,this.markdownDetector=new IncrementalMarkdownDetector,this.coalescer=new Announcer({throttleMs:this.safeCoalesceMs,onFlush:text=>{this.displayedContent=text}})}connectedCallback(){super.connectedCallback();const ownerWindow=this.ownerDocument.defaultView;ownerWindow&&this.coalescer.setTimerHost(ownerWindow),this.hasUpdated&&this.displayedContent!==this.content&&this.coalescer.announce(this.content,{force:!0})}willUpdate(changed){super.willUpdate(changed),changed.has("coalesceMs")&&(this.coalescer.throttleMs=this.safeCoalesceMs),changed.has("content")&&this.coalescer.announce(this.content,{force:!this.hasUpdated}),changed.has("streaming")&&changed.get("streaming")!==void 0&&changed.get("streaming")!==this.streaming&&this.coalescer.announce(this.content,{force:!0}),changed.has("displayedContent")&&this.displayedContent!==this.lastScannedContent&&(this.lastScannedContent=this.displayedContent,this.lastScannedResult=this.markdownDetector.update(this.displayedContent))}updated(changed){super.updated(changed),changed.has("displayedContent")&&!this.effectiveMarkdown&&this.emit("lr-content-settled",null)}disconnectedCallback(){super.disconnectedCallback(),this.coalescer.cancel()}adoptedCallback(){super.adoptedCallback();const ownerWindow=this.ownerDocument.defaultView;ownerWindow&&this.coalescer.setTimerHost(ownerWindow)}get effectiveMarkdown(){return this.contentMode==="markdown"?!0:this.contentMode==="plain"?!1:this.lastScannedResult}stopOwnedEvent(event){event.stopPropagation()}render(){const cursor=this.streaming?html`<span part="cursor" aria-hidden="true"></span>`:nothing;return html`<div part="base"
2
2
  >${this.effectiveMarkdown?html`${this.renderMarkdown()}${cursor}`:html`<span class="plain">${streamingTailText(this.displayedContent)}</span> ${cursor}`}</div
3
- >`}}__decorate([property()],StreamingTextRuntimeBase.prototype,"content",void 0),__decorate([property({type:Boolean,reflect:!0})],StreamingTextRuntimeBase.prototype,"streaming",void 0),__decorate([property({attribute:"streaming-render"})],StreamingTextRuntimeBase.prototype,"streamingRender",void 0),__decorate([property({type:Number,attribute:"coalesce-ms"})],StreamingTextRuntimeBase.prototype,"coalesceMs",void 0),__decorate([property({reflect:!0,attribute:"content-mode"})],StreamingTextRuntimeBase.prototype,"contentMode",void 0),__decorate([property({attribute:!1})],StreamingTextRuntimeBase.prototype,"languages",void 0),__decorate([property({attribute:!1})],StreamingTextRuntimeBase.prototype,"languageLoaders",void 0),__decorate([property({type:Number,attribute:"tab-size"})],StreamingTextRuntimeBase.prototype,"tabSize",void 0),__decorate([property({attribute:"html-mode"})],StreamingTextRuntimeBase.prototype,"htmlMode",void 0),__decorate([property({type:Boolean,attribute:"without-gfm"})],StreamingTextRuntimeBase.prototype,"withoutGfm",void 0),__decorate([property({type:Boolean,attribute:"without-images"})],StreamingTextRuntimeBase.prototype,"withoutImages",void 0),__decorate([property({attribute:"link-target"})],StreamingTextRuntimeBase.prototype,"linkTarget",void 0),__decorate([property({attribute:"internal-link-prefix"})],StreamingTextRuntimeBase.prototype,"internalLinkPrefix",void 0),__decorate([property({type:Number,attribute:"heading-offset"})],StreamingTextRuntimeBase.prototype,"headingOffset",void 0),__decorate([property({type:Boolean,attribute:"without-syntax-highlighting"})],StreamingTextRuntimeBase.prototype,"withoutSyntaxHighlighting",void 0),__decorate([property({type:Boolean,attribute:"heading-anchors"})],StreamingTextRuntimeBase.prototype,"headingAnchors",void 0),__decorate([property({type:Boolean})],StreamingTextRuntimeBase.prototype,"math",void 0),__decorate([property({attribute:"max-height"})],StreamingTextRuntimeBase.prototype,"maxHeight",void 0),__decorate([state()],StreamingTextRuntimeBase.prototype,"displayedContent",void 0);export{StreamingTextRuntimeBase,looksLikeMarkdown};
3
+ >`}}__decorate([property()],StreamingTextRuntimeBase.prototype,"content",void 0),__decorate([property({type:Boolean,reflect:!0})],StreamingTextRuntimeBase.prototype,"streaming",void 0),__decorate([property({attribute:"streaming-render"})],StreamingTextRuntimeBase.prototype,"streamingRender",void 0),__decorate([property({type:Number,attribute:"coalesce-ms"})],StreamingTextRuntimeBase.prototype,"coalesceMs",void 0),__decorate([property({reflect:!0,attribute:"content-mode"})],StreamingTextRuntimeBase.prototype,"contentMode",void 0),__decorate([property({attribute:!1})],StreamingTextRuntimeBase.prototype,"languages",void 0),__decorate([property({attribute:!1})],StreamingTextRuntimeBase.prototype,"languageLoaders",void 0),__decorate([property({type:Number,attribute:"tab-size"})],StreamingTextRuntimeBase.prototype,"tabSize",void 0),__decorate([property({attribute:"html-mode"})],StreamingTextRuntimeBase.prototype,"htmlMode",void 0),__decorate([property({type:Boolean,attribute:"without-gfm"})],StreamingTextRuntimeBase.prototype,"withoutGfm",void 0),__decorate([property({type:Boolean,attribute:"without-images"})],StreamingTextRuntimeBase.prototype,"withoutImages",void 0),__decorate([property({attribute:"link-target"})],StreamingTextRuntimeBase.prototype,"linkTarget",void 0),__decorate([property({attribute:"link-schemes"})],StreamingTextRuntimeBase.prototype,"linkSchemes",void 0),__decorate([property({attribute:"internal-link-prefix"})],StreamingTextRuntimeBase.prototype,"internalLinkPrefix",void 0),__decorate([property({type:Number,attribute:"heading-offset"})],StreamingTextRuntimeBase.prototype,"headingOffset",void 0),__decorate([property({type:Boolean,attribute:"without-syntax-highlighting"})],StreamingTextRuntimeBase.prototype,"withoutSyntaxHighlighting",void 0),__decorate([property({type:Boolean,attribute:"heading-anchors"})],StreamingTextRuntimeBase.prototype,"headingAnchors",void 0),__decorate([property({type:Boolean})],StreamingTextRuntimeBase.prototype,"math",void 0),__decorate([property({attribute:"max-height"})],StreamingTextRuntimeBase.prototype,"maxHeight",void 0),__decorate([state()],StreamingTextRuntimeBase.prototype,"displayedContent",void 0);export{StreamingTextRuntimeBase,looksLikeMarkdown};
@@ -9,7 +9,7 @@ export interface LyraStreamingTextCoreEventMap extends StreamingTextRuntimeEvent
9
9
  * renders fenced code at all. Every capability is identical to `<lr-streaming-text>` -- token
10
10
  * coalescing, `contentMode` auto-detection, the blinking cursor, the `lr-content-settled` event,
11
11
  * and the full forwarded Markdown configuration surface (`tabSize`, `htmlMode`, `withoutGfm`, `withoutImages`,
12
- * `linkTarget`, `internalLinkPrefix`, `headingOffset`, `withoutSyntaxHighlighting`, `headingAnchors`, `math`,
12
+ * `linkTarget`, `linkSchemes`, `internalLinkPrefix`, `headingOffset`, `withoutSyntaxHighlighting`, `headingAnchors`, `math`,
13
13
  * `maxHeight`) -- only which Markdown element Markdown mode composes differs: this variant
14
14
  * renders `<lr-markdown-core>` (`../markdown/markdown-core.js`) instead of `<lr-markdown>`, so this
15
15
  * component's own module never textually contains a reference to `<lr-markdown>`'s ~200-language
@@ -10,6 +10,7 @@ import{__decorate}from"tslib";import{html}from"lit";import{property}from"lit/dec
10
10
  .withoutGfm=${this.withoutGfm}
11
11
  .withoutImages=${this.withoutImages}
12
12
  .linkTarget=${this.linkTarget}
13
+ .linkSchemes=${this.linkSchemes}
13
14
  .internalLinkPrefix=${this.internalLinkPrefix}
14
15
  .headingOffset=${this.headingOffset}
15
16
  .withoutSyntaxHighlighting=${this.withoutSyntaxHighlighting}
@@ -41,7 +41,7 @@ import{type TemplateResult}from'lit';import{StreamingTextRuntimeBase}from'./stre
41
41
  * component's own `languages` through verbatim; plain-text mode
42
42
  * renders into a `white-space: pre-wrap` span instead. The rest of
43
43
  * `<lr-markdown>`'s configuration surface is forwarded verbatim too --
44
- * `tabSize`, `htmlMode`, `withoutGfm`, `withoutImages`, `linkTarget`, `internalLinkPrefix`,
44
+ * `tabSize`, `htmlMode`, `withoutGfm`, `withoutImages`, `linkTarget`, `linkSchemes`, `internalLinkPrefix`,
45
45
  * `headingOffset`, `withoutSyntaxHighlighting`, `headingAnchors`, `math`, and
46
46
  * `maxHeight` -- each defaulting to exactly `<lr-markdown>`'s own default, so
47
47
  * leaving all of them unset renders identically to before this wrapper
@@ -11,6 +11,7 @@ import{__decorate}from"tslib";import{html}from"lit";import{property}from"lit/dec
11
11
  .withoutGfm=${this.withoutGfm}
12
12
  .withoutImages=${this.withoutImages}
13
13
  .linkTarget=${this.linkTarget}
14
+ .linkSchemes=${this.linkSchemes}
14
15
  .internalLinkPrefix=${this.internalLinkPrefix}
15
16
  .headingOffset=${this.headingOffset}
16
17
  .withoutSyntaxHighlighting=${this.withoutSyntaxHighlighting}
@@ -1,8 +1,14 @@
1
1
  import{type PropertyValues,type TemplateResult}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';export interface LyraChatSuggestion{suggestionId:string;
2
2
  /** Nonblank text used as the chip button's visible and accessible name.*/
3
3
  label:string;
4
- /** Optional literal icon hint (for example, an emoji). Rendered decoratively before the text.*/
4
+ /** Optional literal icon hint (for example, an emoji). Rendered decoratively before the text, as
5
+ * text: markup in it is shown verbatim, never parsed. `iconName` and a slotted icon win over it. */
5
6
  icon?:string;
7
+ /** Optional `<lr-icon>` name rendered decoratively before the text, for a vector icon instead of
8
+ * literal text. Wins over `icon`; a slotted `icon-<suggestionId>` element wins over both. */
9
+ iconName?:string;
10
+ /** Optional registered `<lr-icon>` library resolving `iconName`. Omitted uses the default set.*/
11
+ iconLibrary?:string;
6
12
  /** An optional secondary line (Perplexity-style related questions).*/
7
13
  detail?:string;
8
14
  /**
@@ -30,13 +36,21 @@ disabled?:boolean;}export interface LyraSuggestionChipsEventMap{'lr-suggestion-s
30
36
  * past it instead of landing on it. Omitted or `false` renders the chip exactly as before this
31
37
  * field existed.
32
38
  *
39
+ * Each chip can show a decorative icon before its text, in increasing precedence: `icon` (literal
40
+ * text such as an emoji), `iconName` (+ optional `iconLibrary`, rendered as an `<lr-icon>`), or a
41
+ * light-DOM element assigned to the per-suggestion `icon-<suggestionId>` slot, such as an inline
42
+ * `<svg>` or `<lr-icon>`. Icons are always hidden from assistive technology; the chip's accessible
43
+ * name stays its `label`. No icon field is ever parsed as markup.
44
+ *
33
45
  * @customElement lr-suggestion-chips
34
46
  * @event lr-suggestion-select - `detail: { suggestionId, label }`.
47
+ * @slot icon-<suggestionId> - Decorative icon for the suggestion with that `suggestionId` (for
48
+ * example `slot="icon-a"` for `suggestionId: 'a'`); replaces its `iconName`/`icon`.
35
49
  * @csspart base - The labeled group.
36
50
  * @csspart row - The flex container holding the chips, in both the wrapping and the scrolling
37
51
  * layout. Style this to change how chip lines pack (`justify-content`, `row-gap`).
38
52
  * @csspart chip - Each suggestion button.
39
- * @csspart chip-icon - Optional decorative literal icon.
53
+ * @csspart chip-icon - Optional decorative icon wrapper (literal `icon`, `iconName` icon or slotted icon).
40
54
  * @csspart chip-label - The primary text.
41
55
  * @csspart chip-detail - The secondary line (only rendered when `detail` is set).
42
56
  * @cssprop [--lr-suggestion-chips-justify=flex-start] - Main-axis packing of the chip row. `center`
@@ -62,4 +76,4 @@ suggestions:readonly LyraChatSuggestion[];
62
76
  wrap:boolean;
63
77
  /** Accessible name for the group. Optional. Omitting it localizes the default `suggestionsLabel`
64
78
  * message; an explicit empty string renders no visible/accessible label. */
65
- label?:string;private activeIndex;private readonly rovingToolbar;private pendingFocus?;private focusRepairGeneration;private normalizeSuggestions;private get effectiveSuggestions();disconnectedCallback():void;adoptedCallback():void;protected willUpdate(changed:PropertyValues):void;protected updated(changed:PropertyValues):void;private restorePendingFocus;private select;private chipButtons;private focusChip;private onChipFocus;private isSuggestionDisabled;private effectiveActiveIndex;private stopEvent;private onKeyDown;private renderChip;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-suggestion-chips':LyraSuggestionChips;}}
79
+ label?:string;private activeIndex;private readonly rovingToolbar;private readonly slots;private pendingFocus?;private focusRepairGeneration;private normalizeSuggestions;private get effectiveSuggestions();disconnectedCallback():void;adoptedCallback():void;protected willUpdate(changed:PropertyValues):void;protected updated(changed:PropertyValues):void;private restorePendingFocus;private select;private chipButtons;private focusChip;private onChipFocus;private isSuggestionDisabled;private effectiveActiveIndex;private stopEvent;private onKeyDown;private renderChip;private renderChipIcon;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-suggestion-chips':LyraSuggestionChips;}}
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{tag}from"../../../internal/prefix.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{LyraElement}from"../../../internal/lyra-element.js";import{HostDescriptionController}from"../../../internal/aria-controls.js";import{styles}from"./suggestion-chips.styles.js";import{applyComposedFocusRepair,captureComposedFocusRepair}from"../../../internal/focus-navigation.js";import{deepActiveElementIn}from"../../../internal/active-element.js";import{RovingToolbarController}from"../../../internal/roving-toolbar.js";import{LYRA_DEFAULT_suggestionsLabel}from"../../../internal/default-strings/conversation.generated.js";class LyraSuggestionChips extends LyraElement{constructor(){super(...arguments),this.hostDescription=new HostDescriptionController(this,()=>this.renderRoot.querySelector('[part="base"][role="group"]')),this.suggestions=[],this.wrap=!1,this.activeIndex=0,this.rovingToolbar=new RovingToolbarController,this.focusRepairGeneration=0,this.stopEvent=e=>e.stopPropagation(),this.onKeyDown=e=>{const suggestions=this.effectiveSuggestions,target=this.rovingToolbar.move(e,suggestions.length,this.activeIndex,this.effectiveDirection,index=>!this.isSuggestionDisabled(suggestions[index]));if(target===null){(e.key==="ArrowLeft"||e.key==="ArrowRight"||e.key==="Home"||e.key==="End")&&suggestions.length>0&&suggestions.every(item=>this.isSuggestionDisabled(item))&&e.preventDefault();return}e.preventDefault(),this.activeIndex=target,this.focusChip(target)}}static{this.defaultStrings={...super.defaultStrings,suggestionsLabel:LYRA_DEFAULT_suggestionsLabel}}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["suggestions"])}static{this.styles=[LyraElement.styles,styles]}normalizeSuggestions(items){const seen=new Set,normalized=[];for(const suggestion of items??[]){let suggestionId,label;try{suggestionId=suggestion?.suggestionId,label=suggestion?.label}catch{continue}typeof suggestionId!="string"||suggestionId.trim()===""||typeof label!="string"||label.trim()===""||seen.has(suggestionId)||(seen.add(suggestionId),normalized.push(suggestion))}return normalized}get effectiveSuggestions(){return this.normalizeSuggestions(this.suggestions)}disconnectedCallback(){this.focusRepairGeneration++,this.pendingFocus=void 0,super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.hostDescription.adopted(),this.focusRepairGeneration++,this.pendingFocus=void 0}willUpdate(changed){if(super.willUpdate(changed),changed.has("suggestions")||changed.has("wrap")){const active=deepActiveElementIn(this.ownerDocument),activeElement=active?.nodeType===1&&"dataset"in active?active:null,suggestionId=activeElement?.dataset.suggestionId,repair=activeElement?captureComposedFocusRepair(this,activeElement):null,generation=++this.focusRepairGeneration;this.pendingFocus=suggestionId&&repair?{suggestionId,index:this.activeIndex,repair,generation}:void 0}if(changed.has("suggestions")){const previous=this.normalizeSuggestions(changed.get("suggestions")),current=this.effectiveSuggestions,activeId=this.pendingFocus?.suggestionId??previous[this.activeIndex]?.suggestionId,remapped=activeId?current.findIndex(suggestion=>suggestion.suggestionId===activeId):-1;this.activeIndex=remapped>=0?remapped:Math.min(this.activeIndex,Math.max(0,current.length-1))}}updated(changed){super.updated(changed);const pending=this.pendingFocus;this.pendingFocus=void 0,pending&&this.restorePendingFocus(pending)}async restorePendingFocus(pending){if(await this.renderRoot.querySelector(tag("scroller"))?.updateComplete,await Promise.resolve(),pending.generation!==this.focusRepairGeneration||!this.isConnected)return;const buttons=this.chipButtons(),target=buttons.find(button=>button.dataset.suggestionId===pending.suggestionId)??buttons[Math.min(pending.index,Math.max(0,buttons.length-1))]??null;applyComposedFocusRepair(pending.repair,target)}select(suggestion){suggestion.disabled||this.emit("lr-suggestion-select",{suggestionId:suggestion.suggestionId,label:suggestion.label})}chipButtons(){return[...this.renderRoot.querySelectorAll('[part~="chip"]')]}focusChip(index){this.chipButtons()[index]?.focus()}onChipFocus(index){this.activeIndex=index}isSuggestionDisabled(suggestion){return suggestion?.disabled===!0}effectiveActiveIndex(suggestions){const count=suggestions.length;if(!count)return-1;const clamped=Math.min(Math.max(this.activeIndex,0),count-1);if(!this.isSuggestionDisabled(suggestions[clamped]))return clamped;for(let forward=clamped+1;forward<count;forward+=1)if(!this.isSuggestionDisabled(suggestions[forward]))return forward;for(let backward=clamped-1;backward>=0;backward-=1)if(!this.isSuggestionDisabled(suggestions[backward]))return backward;return-1}renderChip(suggestion,index,activeIndex){return html`
1
+ import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{tag}from"../../../internal/prefix.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{LyraElement}from"../../../internal/lyra-element.js";import{HostDescriptionController}from"../../../internal/aria-controls.js";import{styles}from"./suggestion-chips.styles.js";import{applyComposedFocusRepair,captureComposedFocusRepair}from"../../../internal/focus-navigation.js";import{deepActiveElementIn}from"../../../internal/active-element.js";import{RovingToolbarController}from"../../../internal/roving-toolbar.js";import{SlotPresenceController}from"../../../internal/slot-presence-controller.js";import{ifDefined}from"lit/directives/if-defined.js";import{LYRA_DEFAULT_suggestionsLabel}from"../../../internal/default-strings/conversation.generated.js";class LyraSuggestionChips extends LyraElement{constructor(){super(...arguments),this.hostDescription=new HostDescriptionController(this,()=>this.renderRoot.querySelector('[part="base"][role="group"]')),this.suggestions=[],this.wrap=!1,this.activeIndex=0,this.rovingToolbar=new RovingToolbarController,this.slots=new SlotPresenceController(this,{observeLightDom:!0}),this.focusRepairGeneration=0,this.stopEvent=e=>e.stopPropagation(),this.onKeyDown=e=>{const suggestions=this.effectiveSuggestions,target=this.rovingToolbar.move(e,suggestions.length,this.activeIndex,this.effectiveDirection,index=>!this.isSuggestionDisabled(suggestions[index]));if(target===null){(e.key==="ArrowLeft"||e.key==="ArrowRight"||e.key==="Home"||e.key==="End")&&suggestions.length>0&&suggestions.every(item=>this.isSuggestionDisabled(item))&&e.preventDefault();return}e.preventDefault(),this.activeIndex=target,this.focusChip(target)}}static{this.defaultStrings={...super.defaultStrings,suggestionsLabel:LYRA_DEFAULT_suggestionsLabel}}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["suggestions"])}static{this.styles=[LyraElement.styles,styles]}normalizeSuggestions(items){const seen=new Set,normalized=[];for(const suggestion of items??[]){let suggestionId,label;try{suggestionId=suggestion?.suggestionId,label=suggestion?.label}catch{continue}typeof suggestionId!="string"||suggestionId.trim()===""||typeof label!="string"||label.trim()===""||seen.has(suggestionId)||(seen.add(suggestionId),normalized.push(suggestion))}return normalized}get effectiveSuggestions(){return this.normalizeSuggestions(this.suggestions)}disconnectedCallback(){this.focusRepairGeneration++,this.pendingFocus=void 0,super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.hostDescription.adopted(),this.focusRepairGeneration++,this.pendingFocus=void 0}willUpdate(changed){if(super.willUpdate(changed),changed.has("suggestions")||changed.has("wrap")){const active=deepActiveElementIn(this.ownerDocument),activeElement=active?.nodeType===1&&"dataset"in active?active:null,suggestionId=activeElement?.dataset.suggestionId,repair=activeElement?captureComposedFocusRepair(this,activeElement):null,generation=++this.focusRepairGeneration;this.pendingFocus=suggestionId&&repair?{suggestionId,index:this.activeIndex,repair,generation}:void 0}if(changed.has("suggestions")){const previous=this.normalizeSuggestions(changed.get("suggestions")),current=this.effectiveSuggestions,activeId=this.pendingFocus?.suggestionId??previous[this.activeIndex]?.suggestionId,remapped=activeId?current.findIndex(suggestion=>suggestion.suggestionId===activeId):-1;this.activeIndex=remapped>=0?remapped:Math.min(this.activeIndex,Math.max(0,current.length-1))}}updated(changed){super.updated(changed);const pending=this.pendingFocus;this.pendingFocus=void 0,pending&&this.restorePendingFocus(pending)}async restorePendingFocus(pending){if(await this.renderRoot.querySelector(tag("scroller"))?.updateComplete,await Promise.resolve(),pending.generation!==this.focusRepairGeneration||!this.isConnected)return;const buttons=this.chipButtons(),target=buttons.find(button=>button.dataset.suggestionId===pending.suggestionId)??buttons[Math.min(pending.index,Math.max(0,buttons.length-1))]??null;applyComposedFocusRepair(pending.repair,target)}select(suggestion){suggestion.disabled||this.emit("lr-suggestion-select",{suggestionId:suggestion.suggestionId,label:suggestion.label})}chipButtons(){return[...this.renderRoot.querySelectorAll('[part~="chip"]')]}focusChip(index){this.chipButtons()[index]?.focus()}onChipFocus(index){this.activeIndex=index}isSuggestionDisabled(suggestion){return suggestion?.disabled===!0}effectiveActiveIndex(suggestions){const count=suggestions.length;if(!count)return-1;const clamped=Math.min(Math.max(this.activeIndex,0),count-1);if(!this.isSuggestionDisabled(suggestions[clamped]))return clamped;for(let forward=clamped+1;forward<count;forward+=1)if(!this.isSuggestionDisabled(suggestions[forward]))return forward;for(let backward=clamped-1;backward>=0;backward-=1)if(!this.isSuggestionDisabled(suggestions[backward]))return backward;return-1}renderChip(suggestion,index,activeIndex){return html`
2
2
  <button
3
3
  type="button"
4
4
  part="chip"
@@ -8,13 +8,13 @@ import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/co
8
8
  @click=${()=>this.select(suggestion)}
9
9
  @focus=${()=>this.onChipFocus(index)}
10
10
  >
11
- ${suggestion.icon?html`<span part="chip-icon" aria-hidden="true">${suggestion.icon}</span>`:nothing}
11
+ ${this.renderChipIcon(suggestion)}
12
12
  <span class="content">
13
13
  <span part="chip-label">${suggestion.label}</span>
14
14
  ${suggestion.detail?html`<span part="chip-detail">${suggestion.detail}</span>`:nothing}
15
15
  </span>
16
16
  </button>
17
- `}render(){const suggestions=this.effectiveSuggestions;if(suggestions.length===0)return html``;const label=this.label==null?this.localize("suggestionsLabel"):this.label,ariaLabel=this.getAttribute("aria-label")??label,activeIndex=this.effectiveActiveIndex(suggestions),chips=repeat(suggestions,s=>s.suggestionId,(s,i)=>this.renderChip(s,i,activeIndex));return html`
17
+ `}renderChipIcon(suggestion){const slotName=`icon-${suggestion.suggestionId}`,iconName=typeof suggestion.iconName=="string"&&suggestion.iconName.trim()!==""?suggestion.iconName:void 0,literal=typeof suggestion.icon=="string"&&suggestion.icon!==""?suggestion.icon:void 0;if(!this.slots.has(slotName)&&!iconName&&!literal)return nothing;const fallback=iconName?html`<lr-icon name=${iconName} library=${ifDefined(suggestion.iconLibrary||void 0)}></lr-icon>`:literal??nothing;return html`<span part="chip-icon" aria-hidden="true"><slot name=${slotName}>${fallback}</slot></span>`}render(){const suggestions=this.effectiveSuggestions;if(suggestions.length===0)return html``;const label=this.label==null?this.localize("suggestionsLabel"):this.label,ariaLabel=this.getAttribute("aria-label")??label,activeIndex=this.effectiveActiveIndex(suggestions),chips=repeat(suggestions,s=>s.suggestionId,(s,i)=>this.renderChip(s,i,activeIndex));return html`
18
18
  <div part="base" role="group" aria-label=${ariaLabel} @keydown=${this.onKeyDown}>
19
19
  ${this.wrap?html`<div part="row" class="row">${chips}</div>`:html`<lr-scroller orientation="horizontal" without-scrollbar @lr-scroll=${this.stopEvent}><div part="row" class="row">${chips}</div></lr-scroller>`}
20
20
  </div>
@@ -1,2 +1,2 @@
1
1
  /** @deprecated Import @aceshooting/lyra-ui/components/lr-suggestion-chips.js to register this component.*/
2
- export*from'./suggestion-chips.class.js';import'../../layout/scroller/scroller.js';
2
+ export*from'./suggestion-chips.class.js';import'../../layout/scroller/scroller.js';import'../../utility/icon/icon.js';
@@ -1 +1 @@
1
- export*from"./suggestion-chips.class.js";import{LyraSuggestionChips}from"./suggestion-chips.class.js";import{defineElement}from"../../../internal/prefix.js";import"../../layout/scroller/scroller.js";defineElement("suggestion-chips",LyraSuggestionChips);
1
+ export*from"./suggestion-chips.class.js";import{LyraSuggestionChips}from"./suggestion-chips.class.js";import{defineElement}from"../../../internal/prefix.js";import"../../layout/scroller/scroller.js";import"../../utility/icon/icon.js";defineElement("suggestion-chips",LyraSuggestionChips);
@@ -1 +1 @@
1
- import{focusRing}from"../../../internal/interactive-control.styles.js";import{css}from"lit";const styles=css` :host { display: block; max-inline-size: 100%; } [part='base'] { max-inline-size: 100%; } .row { display: flex; justify-content: var(--lr-suggestion-chips-justify, flex-start); gap: var(--lr-space-xs); } :host([wrap]) .row { flex-wrap: wrap; } [part~='chip'] { display: flex; align-items: center; gap: var(--lr-space-xs); flex: 0 0 auto; max-inline-size: var(--lr-suggestion-chips-chip-max-inline-size, var(--lr-size-16rem)); padding-inline: var(--lr-space-m); padding-block: var(--lr-space-xs); border: var(--lr-border-width-thin) solid var(--lr-color-border); border-radius: var(--lr-radius-pill); background: var(--lr-color-surface); color: var(--lr-color-text); font: inherit; text-align: start; cursor: pointer; min-block-size: var(--lr-size-2-5rem); transition: background-color var(--lr-transition-fast), border-color var(--lr-transition-fast); } .content { display: flex; flex-direction: column; align-items: flex-start; gap: var(--lr-space-2xs); min-inline-size: 0; } [part='chip-icon'] { flex: none; line-height: var(--lr-line-height-compact); } :host([wrap]) [part~='chip'] { max-inline-size: min(var(--lr-suggestion-chips-chip-max-inline-size, var(--lr-size-16rem)), 100%); } [part~='chip']:where(:not(:disabled)):hover { background: var(--lr-suggestion-chips-hover-bg, var(--lr-color-brand-quiet)); border-color: var(--lr-suggestion-chips-hover-border, var(--lr-color-brand)); } [part~='chip']:where(:not(:disabled)):active { background: color-mix( in oklab, var(--lr-suggestion-chips-hover-bg, var(--lr-color-brand-quiet)), var(--lr-color-mix-partner) var(--lr-color-mix-active) ); border-color: var(--lr-suggestion-chips-hover-border, var(--lr-color-brand)); } [part~='chip']:disabled { cursor: not-allowed; opacity: var(--lr-suggestion-chips-disabled-opacity, var(--lr-opacity-disabled)); } [part~='chip']:focus-visible { ${focusRing} } [part='chip-label'] { display: -webkit-box; -webkit-line-clamp: var(--lr-suggestion-chips-label-lines, 1); -webkit-box-orient: vertical; overflow: hidden; inline-size: 100%; } :host([wrap]) [part='chip-label'] { -webkit-line-clamp: var(--lr-suggestion-chips-label-lines, 3); } [part='chip-detail'] { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; inline-size: 100%; color: var(--lr-color-text-quiet); font-size: var(--lr-font-size-xs); } `;export{styles};
1
+ import{focusRing}from"../../../internal/interactive-control.styles.js";import{css}from"lit";const styles=css` :host { display: block; max-inline-size: 100%; } [part='base'] { max-inline-size: 100%; } .row { display: flex; justify-content: var(--lr-suggestion-chips-justify, flex-start); gap: var(--lr-space-xs); } :host([wrap]) .row { flex-wrap: wrap; } [part~='chip'] { display: flex; align-items: center; gap: var(--lr-space-xs); flex: 0 0 auto; max-inline-size: var(--lr-suggestion-chips-chip-max-inline-size, var(--lr-size-16rem)); padding-inline: var(--lr-space-m); padding-block: var(--lr-space-xs); border: var(--lr-border-width-thin) solid var(--lr-color-border); border-radius: var(--lr-radius-pill); background: var(--lr-color-surface); color: var(--lr-color-text); font: inherit; text-align: start; cursor: pointer; min-block-size: var(--lr-size-2-5rem); transition: background-color var(--lr-transition-fast), border-color var(--lr-transition-fast); } .content { display: flex; flex-direction: column; align-items: flex-start; gap: var(--lr-space-2xs); min-inline-size: 0; } [part='chip-icon'] { flex: none; line-height: var(--lr-line-height-compact); } [part='chip-icon'] ::slotted(svg:not([width])) { inline-size: var(--lr-size-1em); block-size: var(--lr-size-1em); vertical-align: middle; } :host([wrap]) [part~='chip'] { max-inline-size: min(var(--lr-suggestion-chips-chip-max-inline-size, var(--lr-size-16rem)), 100%); } [part~='chip']:where(:not(:disabled)):hover { background: var(--lr-suggestion-chips-hover-bg, var(--lr-color-brand-quiet)); border-color: var(--lr-suggestion-chips-hover-border, var(--lr-color-brand)); } [part~='chip']:where(:not(:disabled)):active { background: color-mix( in oklab, var(--lr-suggestion-chips-hover-bg, var(--lr-color-brand-quiet)), var(--lr-color-mix-partner) var(--lr-color-mix-active) ); border-color: var(--lr-suggestion-chips-hover-border, var(--lr-color-brand)); } [part~='chip']:disabled { cursor: not-allowed; opacity: var(--lr-suggestion-chips-disabled-opacity, var(--lr-opacity-disabled)); } [part~='chip']:focus-visible { ${focusRing} } [part='chip-label'] { display: -webkit-box; -webkit-line-clamp: var(--lr-suggestion-chips-label-lines, 1); -webkit-box-orient: vertical; overflow: hidden; inline-size: 100%; } :host([wrap]) [part='chip-label'] { -webkit-line-clamp: var(--lr-suggestion-chips-label-lines, 3); } [part='chip-detail'] { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; inline-size: 100%; color: var(--lr-color-text-quiet); font-size: var(--lr-font-size-xs); } `;export{styles};
@@ -341,7 +341,7 @@ errorDescription:string;
341
341
  * `[part="row"]` one level up, and an unstyled block box contributes exactly its child's height
342
342
  * to it, so adding it leaves every measured row height unchanged. Applies to rows only -- group
343
343
  * headers never pass through `wrapRow` and never carry `row-wrapper`. */
344
- wrapRow?:(thread:LyraChatThread,row:TemplateResult)=>TemplateResult;private readonly stickyGroupItems;private dataModel?;private searchText;private hasEmptySlot;private hasDefaultSlotContent;private virtualListEl?;private liveRegion?;private searchInputEl?;private focusTaskGeneration;private readonly injectedListItemRoles;private get dataMode();connectedCallback():void;private contentRefreshPending;requestUpdate(...args:Parameters<LyraElement['requestUpdate']>):void;protected willUpdate(changed:PropertyValues):void;private sourceStatusInitialized;private previousSourceStatus;protected updated(changed:PropertyValues):void;private defaultSlottedElements;private markAsListItems;private restoreInjectedListItemRoles;disconnectedCallback():void;private get normalizedThreads();private sourceThread;private sourceThreads;private readonly titleHaystacks;private readonly excerptHaystacks;private get visibleThreads();private bucketFor;private bucketLabel;private dateForBucket;private orderedCustomGroupIds;private groupedItems;private buildItems;private setSearchText;private onSearchInput;private onClearSearch;private announceMatchCount;private onSearchKeyDown;private onSearchFocus;private onSearchBlur;
344
+ wrapRow?:(thread:LyraChatThread,row:TemplateResult)=>TemplateResult;private readonly stickyGroupItems;private dataModel?;private searchText;private hasEmptySlot;private hasDefaultSlotContent;private virtualListEl?;private liveRegion?;private searchInputEl?;private focusTaskGeneration;private stopPendingFocus?;private excerptObserver?;private excerptRoot?;private excerptObservationGeneration;private readonly injectedListItemRoles;private get dataMode();connectedCallback():void;private contentRefreshPending;requestUpdate(...args:Parameters<LyraElement['requestUpdate']>):void;protected willUpdate(changed:PropertyValues):void;private sourceStatusInitialized;private previousSourceStatus;protected updated(changed:PropertyValues):void;private observeRenderedExcerpts;private syncRenderedExcerpts;private defaultSlottedElements;private markAsListItems;private restoreInjectedListItemRoles;disconnectedCallback():void;private get normalizedThreads();private sourceThread;private sourceThreads;private readonly titleHaystacks;private readonly excerptHaystacks;private get visibleThreads();private bucketFor;private bucketLabel;private dateForBucket;private orderedCustomGroupIds;private groupedItems;private buildItems;private setSearchText;private onSearchInput;private onClearSearch;private announceMatchCount;private onSearchKeyDown;private onSearchFocus;private onSearchBlur;
345
345
  /** The rendered `<lr-conversation-item>` for one thread's `conversationId` -- a data-mode
346
346
  * thread's own `id`, or a slotted item's own `conversation-id` -- or `null` when it is not
347
347
  * currently rendered: filtered out by `withArchived`/search, windowed out of the virtualized