@aceshooting/lyra-ui 19.0.0 → 20.0.0

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 (419) hide show
  1. package/CHANGELOG.md +163 -0
  2. package/custom-elements.json +1 -1
  3. package/dist/cli/migration-contract.json +1 -1
  4. package/dist/components/agent-tools/activity-feed/activity-feed.class.d.ts +14 -4
  5. package/dist/components/agent-tools/activity-feed/activity-feed.styles.js +1 -1
  6. package/dist/components/agent-tools/approval-queue/approval-queue.class.d.ts +1 -0
  7. package/dist/components/agent-tools/approval-queue/approval-queue.class.js +4 -3
  8. package/dist/components/agent-tools/approval-queue/approval-queue.styles.js +1 -1
  9. package/dist/components/agent-tools/artifact-panel/artifact-panel.class.d.ts +3 -1
  10. package/dist/components/agent-tools/context-inspector/context-inspector.class.d.ts +1 -0
  11. package/dist/components/agent-tools/context-inspector/context-inspector.class.js +4 -3
  12. package/dist/components/agent-tools/context-inspector/context-inspector.styles.js +1 -1
  13. package/dist/components/agent-tools/eval-dataset/eval-dataset.class.js +1 -1
  14. package/dist/components/agent-tools/eval-result/eval-result.class.js +1 -1
  15. package/dist/components/agent-tools/evaluation-run/evaluation-run.class.d.ts +1 -0
  16. package/dist/components/agent-tools/evaluation-run/evaluation-run.class.js +4 -3
  17. package/dist/components/agent-tools/evaluation-run/evaluation-run.styles.js +1 -1
  18. package/dist/components/agent-tools/policy-summary/policy-summary.class.d.ts +1 -0
  19. package/dist/components/agent-tools/policy-summary/policy-summary.class.js +4 -3
  20. package/dist/components/agent-tools/policy-summary/policy-summary.styles.js +1 -1
  21. package/dist/components/agent-tools/prompt-studio/prompt-studio.class.js +1 -1
  22. package/dist/components/agent-tools/schema-viewer/schema-viewer.class.d.ts +10 -1
  23. package/dist/components/agent-tools/schema-viewer/schema-viewer.class.js +3 -3
  24. package/dist/components/agent-tools/subagent-panel/subagent-panel.class.js +1 -1
  25. package/dist/components/agent-tools/thinking-panel/thinking-panel.class.d.ts +6 -3
  26. package/dist/components/agent-tools/thinking-panel/thinking-panel.styles.js +1 -1
  27. package/dist/components/agent-tools/tool-call-chip/tool-call-chip.class.d.ts +14 -3
  28. package/dist/components/agent-tools/tool-call-chip/tool-call-chip.class.js +2 -2
  29. package/dist/components/agent-tools/tool-param-form/tool-param-form.class.d.ts +12 -2
  30. package/dist/components/agent-tools/tool-param-form/tool-param-form.class.js +3 -1
  31. package/dist/components/charts/chart/box-plot.class.d.ts +15 -3
  32. package/dist/components/charts/chart/box-plot.class.js +3 -3
  33. package/dist/components/charts/chart/box-plot.styles.js +1 -1
  34. package/dist/components/charts/chart/chart.class.d.ts +24 -6
  35. package/dist/components/charts/chart/chart.class.js +3 -3
  36. package/dist/components/charts/chart/chart.styles.js +1 -1
  37. package/dist/components/charts/chart/lite-chart.class.js +1 -1
  38. package/dist/components/charts/chart/lite-chart.styles.js +1 -1
  39. package/dist/components/conversation/audio-visualizer/audio-visualizer.class.d.ts +4 -2
  40. package/dist/components/conversation/audio-visualizer/audio-visualizer.class.js +1 -1
  41. package/dist/components/conversation/branch-picker/branch-picker.class.d.ts +4 -2
  42. package/dist/components/conversation/branch-picker/branch-picker.class.js +1 -1
  43. package/dist/components/conversation/chat-viewport/chat-viewport.class.d.ts +4 -3
  44. package/dist/components/conversation/chat-viewport/chat-viewport.class.js +1 -1
  45. package/dist/components/conversation/code-block/code-block-core.class.d.ts +6 -11
  46. package/dist/components/conversation/code-block/code-block-core.class.js +1 -1
  47. package/dist/components/conversation/code-block/code-block-shared.d.ts +29 -1
  48. package/dist/components/conversation/code-block/code-block-shared.js +1 -1
  49. package/dist/components/conversation/code-block/code-block.class.d.ts +6 -11
  50. package/dist/components/conversation/code-block/code-block.class.js +1 -1
  51. package/dist/components/conversation/markdown/markdown-shared.js +2 -2
  52. package/dist/components/conversation/message-actions/message-actions.class.d.ts +4 -2
  53. package/dist/components/conversation/message-actions/message-actions.class.js +2 -2
  54. package/dist/components/conversation/message-parts/message-parts.class.d.ts +17 -2
  55. package/dist/components/conversation/model-select/model-select.class.js +1 -0
  56. package/dist/components/conversation/model-select/model-select.styles.js +1 -1
  57. package/dist/components/conversation/prompt-input/prompt-input.class.d.ts +5 -1
  58. package/dist/components/conversation/prompt-input/prompt-input.class.js +2 -2
  59. package/dist/components/conversation/prompt-queue/prompt-queue.class.d.ts +6 -1
  60. package/dist/components/conversation/prompt-queue/prompt-queue.class.js +2 -2
  61. package/dist/components/conversation/realtime-session/realtime-session.class.d.ts +5 -1
  62. package/dist/components/conversation/realtime-session/realtime-session.class.js +1 -1
  63. package/dist/components/conversation/selection-toolbar/selection-toolbar.class.d.ts +5 -1
  64. package/dist/components/conversation/selection-toolbar/selection-toolbar.class.js +1 -1
  65. package/dist/components/conversation/voice-picker/voice-picker.class.d.ts +13 -2
  66. package/dist/components/conversation/voice-picker/voice-picker.class.js +5 -3
  67. package/dist/components/conversation/voice-picker/voice-picker.styles.js +1 -1
  68. package/dist/components/data/calendar/calendar.class.d.ts +9 -0
  69. package/dist/components/data/calendar/calendar.class.js +2 -2
  70. package/dist/components/data/calendar/calendar.styles.js +1 -1
  71. package/dist/components/data/condition-builder/condition-builder.class.d.ts +5 -1
  72. package/dist/components/data/context-meter/context-meter.class.d.ts +4 -0
  73. package/dist/components/data/context-meter/context-meter.styles.js +1 -1
  74. package/dist/components/data/data-grid/data-grid.class.d.ts +8 -2
  75. package/dist/components/data/data-grid/data-grid.class.js +1 -2
  76. package/dist/components/data/flow-node/flow-node.class.d.ts +7 -4
  77. package/dist/components/data/flow-node/flow-node.styles.js +1 -1
  78. package/dist/components/data/funnel/funnel.class.d.ts +5 -0
  79. package/dist/components/data/funnel/funnel.class.js +4 -3
  80. package/dist/components/data/funnel/funnel.styles.js +1 -1
  81. package/dist/components/data/gauge/gauge.class.d.ts +12 -1
  82. package/dist/components/data/gauge/gauge.styles.js +1 -1
  83. package/dist/components/data/graph-query-builder/graph-query-builder.class.d.ts +50 -13
  84. package/dist/components/data/graph-query-builder/graph-query-builder.class.js +2 -2
  85. package/dist/components/data/graph-query-builder/graph-query-builder.styles.js +1 -1
  86. package/dist/components/data/heatmap/heatmap.class.d.ts +27 -9
  87. package/dist/components/data/heatmap/heatmap.class.js +5 -3
  88. package/dist/components/data/sequence-strip/sequence-strip.class.d.ts +2 -0
  89. package/dist/components/data/sequence-strip/sequence-strip.styles.js +1 -1
  90. package/dist/components/data/table/table.class.d.ts +10 -1
  91. package/dist/components/data/table/table.class.js +3 -2
  92. package/dist/components/data/tree/tree.class.d.ts +20 -1
  93. package/dist/components/data/tree/tree.class.js +1 -1
  94. package/dist/components/data/word-cloud/word-cloud.class.d.ts +4 -1
  95. package/dist/components/data/word-cloud/word-cloud.class.js +2 -2
  96. package/dist/components/forms/button/button.class.js +1 -1
  97. package/dist/components/forms/checkbox/checkbox.class.d.ts +11 -8
  98. package/dist/components/forms/checkbox/checkbox.class.js +1 -1
  99. package/dist/components/forms/checkbox/checkbox.styles.js +1 -1
  100. package/dist/components/forms/checkbox-group/checkbox-group.class.d.ts +2 -2
  101. package/dist/components/forms/checkbox-group/checkbox-group.class.js +1 -1
  102. package/dist/components/forms/code-editor/code-editor.class.d.ts +2 -0
  103. package/dist/components/forms/code-editor/code-editor.class.js +1 -1
  104. package/dist/components/forms/code-editor/code-editor.styles.js +1 -1
  105. package/dist/components/forms/color-picker/color-picker.class.d.ts +11 -1
  106. package/dist/components/forms/color-picker/color-picker.class.js +4 -3
  107. package/dist/components/forms/combobox/combobox.class.d.ts +69 -20
  108. package/dist/components/forms/combobox/combobox.class.js +8 -6
  109. package/dist/components/forms/combobox/combobox.styles.js +1 -1
  110. package/dist/components/forms/date-picker/date-input.class.d.ts +22 -2
  111. package/dist/components/forms/date-picker/date-input.class.js +4 -2
  112. package/dist/components/forms/date-picker/date-input.styles.js +1 -1
  113. package/dist/components/forms/emoji-picker/emoji-data-loader.d.ts +18 -4
  114. package/dist/components/forms/emoji-picker/emoji-data-loader.js +1 -1
  115. package/dist/components/forms/emoji-picker/emoji-picker.class.d.ts +18 -4
  116. package/dist/components/forms/emoji-picker/emoji-picker.class.js +1 -1
  117. package/dist/components/forms/emoji-picker/emoji-picker.styles.js +1 -1
  118. package/dist/components/forms/icon-button/icon-button.class.d.ts +1 -1
  119. package/dist/components/forms/input/time-input.class.d.ts +11 -1
  120. package/dist/components/forms/input/time-input.class.js +4 -3
  121. package/dist/components/forms/input/time-input.styles.js +1 -1
  122. package/dist/components/forms/locale-picker/locale-picker.class.d.ts +17 -3
  123. package/dist/components/forms/locale-picker/locale-picker.class.js +3 -2
  124. package/dist/components/forms/locale-picker/locale-picker.styles.js +1 -1
  125. package/dist/components/forms/otp-input/otp-input.class.d.ts +13 -5
  126. package/dist/components/forms/otp-input/otp-input.class.js +2 -2
  127. package/dist/components/forms/otp-input/otp-input.styles.js +1 -1
  128. package/dist/components/forms/phone-input/phone-input.class.d.ts +10 -3
  129. package/dist/components/forms/phone-input/phone-input.class.js +6 -2
  130. package/dist/components/forms/phone-input/phone-input.styles.js +1 -1
  131. package/dist/components/forms/radio/radio-group.class.d.ts +1 -1
  132. package/dist/components/forms/radio/radio-group.class.js +2 -2
  133. package/dist/components/forms/rubric-form/rubric-form.class.d.ts +9 -1
  134. package/dist/components/forms/rubric-form/rubric-form.class.js +5 -3
  135. package/dist/components/forms/select/select.class.d.ts +6 -2
  136. package/dist/components/forms/select/select.class.js +4 -2
  137. package/dist/components/forms/select/select.styles.js +1 -1
  138. package/dist/components/forms/slider/slider.class.d.ts +5 -1
  139. package/dist/components/forms/slider/slider.class.js +3 -3
  140. package/dist/components/forms/switch/switch.class.d.ts +6 -5
  141. package/dist/components/forms/switch/switch.class.js +1 -1
  142. package/dist/components/forms/time-range/time-range.class.d.ts +2 -2
  143. package/dist/components/forms/token-input/token-input.class.d.ts +13 -3
  144. package/dist/components/forms/token-input/token-input.class.js +3 -1
  145. package/dist/components/layout/carousel/carousel.class.d.ts +4 -1
  146. package/dist/components/layout/carousel/carousel.class.js +1 -1
  147. package/dist/components/layout/command-palette/command-palette.class.d.ts +8 -2
  148. package/dist/components/layout/command-palette/command-palette.class.js +1 -1
  149. package/dist/components/layout/command-palette/command-palette.styles.js +1 -1
  150. package/dist/components/layout/details/accordion.class.js +1 -1
  151. package/dist/components/layout/dock-panel/dock-panel.class.d.ts +10 -7
  152. package/dist/components/layout/dock-panel/dock-panel.class.js +2 -2
  153. package/dist/components/layout/dock-panel/dock-panel.styles.js +1 -1
  154. package/dist/components/layout/menu/menu.class.d.ts +13 -3
  155. package/dist/components/layout/menu/menu.class.js +4 -3
  156. package/dist/components/layout/menu/menu.styles.js +1 -1
  157. package/dist/components/layout/page/page.class.d.ts +7 -1
  158. package/dist/components/layout/reorder-list/reorder-list.class.d.ts +1 -1
  159. package/dist/components/layout/reorder-list/reorder-list.class.js +1 -1
  160. package/dist/components/layout/segmented/segmented.class.d.ts +2 -0
  161. package/dist/components/layout/segmented/segmented.styles.js +1 -1
  162. package/dist/components/layout/virtual-list/virtual-list.styles.js +1 -1
  163. package/dist/components/layout/widget/widget.class.d.ts +15 -2
  164. package/dist/components/layout/widget/widget.class.js +1 -1
  165. package/dist/components/layout/widget/widget.styles.js +1 -1
  166. package/dist/components/media/avatar/avatar.class.d.ts +4 -0
  167. package/dist/components/media/avatar/avatar.styles.js +1 -1
  168. package/dist/components/media/avatar-group/avatar-group.class.d.ts +8 -1
  169. package/dist/components/media/avatar-group/avatar-group.styles.js +1 -1
  170. package/dist/components/media/drop-zone/drop-zone.class.d.ts +10 -4
  171. package/dist/components/media/drop-zone/drop-zone.class.js +2 -2
  172. package/dist/components/media/drop-zone/drop-zone.styles.js +1 -1
  173. package/dist/components/media/flag/flag.class.js +1 -1
  174. package/dist/components/media/map/map.class.d.ts +19 -5
  175. package/dist/components/media/map/map.class.js +3 -3
  176. package/dist/components/media/video-playlist/video-playlist.class.d.ts +6 -3
  177. package/dist/components/media/video-playlist/video-playlist.class.js +1 -1
  178. package/dist/components/overlays/callout/callout.class.d.ts +4 -1
  179. package/dist/components/overlays/dialog/dialog.class.d.ts +4 -1
  180. package/dist/components/overlays/overlay/overlay.styles.js +1 -1
  181. package/dist/components/overlays/overlay/popover.class.d.ts +9 -1
  182. package/dist/components/overlays/overlay/popover.class.js +3 -2
  183. package/dist/components/overlays/overlay/tooltip.class.d.ts +14 -4
  184. package/dist/components/overlays/overlay/tooltip.class.js +3 -2
  185. package/dist/components/overlays/popup/popup.class.d.ts +15 -1
  186. package/dist/components/overlays/popup/popup.class.js +3 -3
  187. package/dist/components/overlays/popup/popup.styles.js +1 -1
  188. package/dist/components/overlays/progress/progress-bar.class.d.ts +2 -0
  189. package/dist/components/overlays/progress/progress.styles.js +1 -1
  190. package/dist/components/retrieval/citation-badge/citation-badge.class.d.ts +4 -2
  191. package/dist/components/retrieval/citation-badge/citation-badge.class.js +1 -1
  192. package/dist/components/retrieval/claim-evidence/claim-evidence.class.d.ts +4 -0
  193. package/dist/components/retrieval/claim-evidence/claim-evidence.class.js +4 -3
  194. package/dist/components/retrieval/claim-evidence/claim-evidence.styles.js +1 -1
  195. package/dist/components/retrieval/community-card/community-card.class.d.ts +6 -1
  196. package/dist/components/retrieval/community-card/community-card.styles.js +1 -1
  197. package/dist/components/retrieval/embedding-explorer/embedding-explorer.class.d.ts +9 -1
  198. package/dist/components/retrieval/embedding-explorer/embedding-explorer.class.js +4 -3
  199. package/dist/components/retrieval/entity-card/entity-card.styles.js +1 -1
  200. package/dist/components/retrieval/entity-chip/entity-chip.class.d.ts +4 -2
  201. package/dist/components/retrieval/entity-chip/entity-chip.class.js +1 -1
  202. package/dist/components/retrieval/entity-dossier/entity-dossier.class.js +2 -2
  203. package/dist/components/retrieval/graph-legend/graph-legend.class.d.ts +18 -4
  204. package/dist/components/retrieval/graph-legend/graph-legend.class.js +2 -2
  205. package/dist/components/retrieval/grounding-summary/grounding-summary.class.d.ts +7 -0
  206. package/dist/components/retrieval/grounding-summary/grounding-summary.class.js +4 -3
  207. package/dist/components/retrieval/grounding-summary/grounding-summary.styles.js +1 -1
  208. package/dist/components/retrieval/memory-panel/memory-panel.class.d.ts +6 -0
  209. package/dist/components/retrieval/memory-panel/memory-panel.class.js +4 -3
  210. package/dist/components/retrieval/memory-panel/memory-panel.styles.js +1 -1
  211. package/dist/components/retrieval/mind-map/mind-map-layout.d.ts +17 -1
  212. package/dist/components/retrieval/mind-map/mind-map-layout.js +1 -1
  213. package/dist/components/retrieval/mind-map/mind-map.class.d.ts +8 -1
  214. package/dist/components/retrieval/mind-map/mind-map.class.js +3 -2
  215. package/dist/components/retrieval/rag-eval-dashboard/rag-eval-dashboard.class.d.ts +5 -0
  216. package/dist/components/retrieval/rag-eval-dashboard/rag-eval-dashboard.class.js +6 -5
  217. package/dist/components/retrieval/rag-eval-dashboard/rag-eval-dashboard.styles.js +1 -1
  218. package/dist/components/retrieval/retrieval-compare/retrieval-compare.class.js +5 -5
  219. package/dist/components/retrieval/retrieval-compare/retrieval-compare.styles.js +1 -1
  220. package/dist/components/retrieval/source-list/source-list.class.d.ts +21 -2
  221. package/dist/components/retrieval/source-list/source-list.class.js +2 -2
  222. package/dist/components/retrieval/source-list/source-list.styles.js +1 -1
  223. package/dist/components/retrieval/source-picker/source-picker.class.d.ts +3 -1
  224. package/dist/components/retrieval/source-picker/source-picker.class.js +2 -2
  225. package/dist/components/utility/diff-view/diff-view.class.d.ts +105 -8
  226. package/dist/components/utility/diff-view/diff-view.class.js +21 -5
  227. package/dist/components/utility/diff-view/diff-view.styles.js +1 -1
  228. package/dist/components/utility/export-button/export-button.class.d.ts +26 -2
  229. package/dist/components/utility/export-button/export-button.class.js +4 -2
  230. package/dist/components/utility/export-button/export-button.styles.js +1 -1
  231. package/dist/components/utility/mention-popover/mention-popover.class.d.ts +19 -1
  232. package/dist/components/utility/mention-popover/mention-popover.class.js +3 -2
  233. package/dist/components/utility/mention-popover/mention-popover.styles.js +1 -1
  234. package/dist/components/utility/tour/tour.class.d.ts +1 -3
  235. package/dist/components/utility/tour/tour.class.js +1 -1
  236. package/dist/components/viewers/archive-viewer/archive-viewer.class.d.ts +20 -3
  237. package/dist/components/viewers/archive-viewer/archive-viewer.class.js +1 -1
  238. package/dist/components/viewers/ebook-viewer/ebook-viewer.class.js +1 -1
  239. package/dist/components/viewers/geojson-view/geojson-view.styles.js +1 -1
  240. package/dist/components/viewers/geojson-view/geojson-viewer.class.d.ts +5 -0
  241. package/dist/components/viewers/geojson-view/geojson-viewer.class.js +6 -3
  242. package/dist/components/viewers/pdf-viewer/pdf-viewer.class.d.ts +7 -1
  243. package/dist/components/viewers/pdf-viewer/pdf-viewer.class.js +1 -1
  244. package/dist/components/viewers/pptx-viewer/pptx-viewer.class.d.ts +7 -1
  245. package/dist/components/viewers/pptx-viewer/pptx-viewer.class.js +1 -1
  246. package/dist/components/viewers/xml-viewer/xml-viewer.class.d.ts +5 -0
  247. package/dist/components/viewers/xml-viewer/xml-viewer.class.js +1 -1
  248. package/dist/custom-elements-jsx.d.ts +1 -1
  249. package/dist/events.d.ts +79 -30
  250. package/dist/internal/accessibility-visibility.js +1 -1
  251. package/dist/internal/aria-reflection.js +1 -1
  252. package/dist/internal/catalog-picker.d.ts +14 -3
  253. package/dist/internal/catalog-picker.js +1 -1
  254. package/dist/internal/default-strings.generated.d.ts +1 -1
  255. package/dist/internal/default-strings.generated.js +2 -2
  256. package/dist/internal/localization-types.d.ts +1 -1
  257. package/dist/internal/localization.js +2 -2
  258. package/dist/internal/lyra-element.d.ts +17 -0
  259. package/dist/internal/lyra-element.js +2 -2
  260. package/dist/internal/package-metadata.d.ts +1 -1
  261. package/dist/internal/package-metadata.js +1 -1
  262. package/dist/svelte.d.ts +1 -1
  263. package/dist/testing/lyra-tag-event-map.js +1 -1
  264. package/dist/translations/ar/agent-tools.js +1 -1
  265. package/dist/translations/ar/data.js +1 -1
  266. package/dist/translations/ar/retrieval.js +1 -1
  267. package/dist/translations/ar/shared.js +1 -1
  268. package/dist/translations/ar/viewers.js +1 -1
  269. package/dist/translations/de/agent-tools.js +1 -1
  270. package/dist/translations/de/data.js +1 -1
  271. package/dist/translations/de/retrieval.js +1 -1
  272. package/dist/translations/de/shared.js +1 -1
  273. package/dist/translations/de/viewers.js +1 -1
  274. package/dist/translations/es/agent-tools.js +1 -1
  275. package/dist/translations/es/data.js +1 -1
  276. package/dist/translations/es/retrieval.js +1 -1
  277. package/dist/translations/es/shared.js +1 -1
  278. package/dist/translations/es/viewers.js +1 -1
  279. package/dist/translations/fa/agent-tools.js +1 -1
  280. package/dist/translations/fa/data.js +1 -1
  281. package/dist/translations/fa/retrieval.js +1 -1
  282. package/dist/translations/fa/shared.js +1 -1
  283. package/dist/translations/fa/viewers.js +1 -1
  284. package/dist/translations/fr/agent-tools.js +1 -1
  285. package/dist/translations/fr/data.js +1 -1
  286. package/dist/translations/fr/retrieval.js +1 -1
  287. package/dist/translations/fr/shared.js +1 -1
  288. package/dist/translations/fr/viewers.js +1 -1
  289. package/dist/translations/he/agent-tools.js +1 -1
  290. package/dist/translations/he/data.js +1 -1
  291. package/dist/translations/he/retrieval.js +1 -1
  292. package/dist/translations/he/shared.js +1 -1
  293. package/dist/translations/he/viewers.js +1 -1
  294. package/dist/translations/it/agent-tools.js +1 -1
  295. package/dist/translations/it/data.js +1 -1
  296. package/dist/translations/it/retrieval.js +1 -1
  297. package/dist/translations/it/shared.js +1 -1
  298. package/dist/translations/it/viewers.js +1 -1
  299. package/dist/translations/ja/agent-tools.js +1 -1
  300. package/dist/translations/ja/data.js +1 -1
  301. package/dist/translations/ja/retrieval.js +1 -1
  302. package/dist/translations/ja/shared.js +1 -1
  303. package/dist/translations/ja/viewers.js +1 -1
  304. package/dist/translations/pt-BR/agent-tools.js +1 -1
  305. package/dist/translations/pt-BR/data.js +1 -1
  306. package/dist/translations/pt-BR/retrieval.js +1 -1
  307. package/dist/translations/pt-BR/shared.js +1 -1
  308. package/dist/translations/pt-BR/viewers.js +1 -1
  309. package/dist/translations/ro/agent-tools.js +1 -1
  310. package/dist/translations/ro/data.js +1 -1
  311. package/dist/translations/ro/retrieval.js +1 -1
  312. package/dist/translations/ro/shared.js +1 -1
  313. package/dist/translations/ro/viewers.js +1 -1
  314. package/dist/translations/ru/agent-tools.js +1 -1
  315. package/dist/translations/ru/data.js +1 -1
  316. package/dist/translations/ru/retrieval.js +1 -1
  317. package/dist/translations/ru/shared.js +1 -1
  318. package/dist/translations/ru/viewers.js +1 -1
  319. package/dist/translations/zh-CN/agent-tools.js +1 -1
  320. package/dist/translations/zh-CN/data.js +1 -1
  321. package/dist/translations/zh-CN/retrieval.js +1 -1
  322. package/dist/translations/zh-CN/shared.js +1 -1
  323. package/dist/translations/zh-CN/viewers.js +1 -1
  324. package/dist/vue.d.ts +1 -1
  325. package/llms/components/lr-activity-feed.md +20 -9
  326. package/llms/components/lr-approval-queue.md +3 -2
  327. package/llms/components/lr-archive-viewer.md +8 -1
  328. package/llms/components/lr-artifact-panel.md +3 -1
  329. package/llms/components/lr-audio-visualizer.md +3 -1
  330. package/llms/components/lr-avatar-group.md +13 -6
  331. package/llms/components/lr-avatar.md +6 -2
  332. package/llms/components/lr-bar-chart.md +6 -3
  333. package/llms/components/lr-box-plot.md +6 -2
  334. package/llms/components/lr-branch-picker.md +3 -1
  335. package/llms/components/lr-bubble-chart.md +6 -3
  336. package/llms/components/lr-calendar.md +10 -3
  337. package/llms/components/lr-carousel.md +4 -2
  338. package/llms/components/lr-chart.md +12 -4
  339. package/llms/components/lr-chat-viewport.md +3 -2
  340. package/llms/components/lr-checkbox.md +8 -5
  341. package/llms/components/lr-citation-badge.md +2 -0
  342. package/llms/components/lr-claim-evidence.md +6 -2
  343. package/llms/components/lr-code-editor.md +3 -1
  344. package/llms/components/lr-color-picker.md +20 -8
  345. package/llms/components/lr-combobox.md +26 -3
  346. package/llms/components/lr-command-palette.md +6 -3
  347. package/llms/components/lr-community-card.md +7 -4
  348. package/llms/components/lr-context-inspector.md +3 -2
  349. package/llms/components/lr-context-meter.md +13 -5
  350. package/llms/components/lr-data-grid.md +2 -0
  351. package/llms/components/lr-date-input.md +12 -3
  352. package/llms/components/lr-date-picker.md +11 -2
  353. package/llms/components/lr-diff-view.md +46 -5
  354. package/llms/components/lr-doughnut-chart.md +6 -3
  355. package/llms/components/lr-drop-zone.md +7 -3
  356. package/llms/components/lr-embedding-explorer.md +8 -2
  357. package/llms/components/lr-emoji-picker.md +5 -1
  358. package/llms/components/lr-entity-chip.md +2 -0
  359. package/llms/components/lr-eval-run.md +3 -2
  360. package/llms/components/lr-export-button.md +5 -2
  361. package/llms/components/lr-flow-node.md +7 -4
  362. package/llms/components/lr-funnel.md +7 -2
  363. package/llms/components/lr-gauge.md +7 -2
  364. package/llms/components/lr-geojson-view.md +10 -2
  365. package/llms/components/lr-geojson-viewer.md +10 -2
  366. package/llms/components/lr-graph-legend.md +6 -3
  367. package/llms/components/lr-graph-query-builder.md +21 -11
  368. package/llms/components/lr-grounding-summary.md +8 -2
  369. package/llms/components/lr-heatmap.md +5 -2
  370. package/llms/components/lr-histogram.md +4 -2
  371. package/llms/components/lr-json-schema-viewer.md +7 -5
  372. package/llms/components/lr-line-chart.md +6 -3
  373. package/llms/components/lr-locale-picker.md +4 -1
  374. package/llms/components/lr-map.md +5 -3
  375. package/llms/components/lr-memory-panel.md +6 -2
  376. package/llms/components/lr-mention-popover.md +7 -4
  377. package/llms/components/lr-message-actions.md +3 -1
  378. package/llms/components/lr-message-parts.md +8 -2
  379. package/llms/components/lr-mind-map.md +11 -2
  380. package/llms/components/lr-option.md +25 -2
  381. package/llms/components/lr-otp-input.md +3 -1
  382. package/llms/components/lr-phone-input.md +9 -5
  383. package/llms/components/lr-pie-chart.md +6 -3
  384. package/llms/components/lr-polar-area-chart.md +6 -3
  385. package/llms/components/lr-policy-summary.md +3 -2
  386. package/llms/components/lr-progress-bar.md +4 -1
  387. package/llms/components/lr-prompt-input.md +4 -1
  388. package/llms/components/lr-prompt-queue.md +5 -2
  389. package/llms/components/lr-radar-chart.md +6 -3
  390. package/llms/components/lr-rag-eval-dashboard.md +7 -2
  391. package/llms/components/lr-realtime-session.md +3 -1
  392. package/llms/components/lr-rubric-form.md +6 -1
  393. package/llms/components/lr-scatter-chart.md +6 -3
  394. package/llms/components/lr-segmented.md +3 -1
  395. package/llms/components/lr-select.md +7 -1
  396. package/llms/components/lr-selection-toolbar.md +4 -1
  397. package/llms/components/lr-sequence-strip.md +7 -3
  398. package/llms/components/lr-source-card.md +16 -1
  399. package/llms/components/lr-source-list.md +17 -2
  400. package/llms/components/lr-source-picker.md +3 -1
  401. package/llms/components/lr-subagent-panel.md +6 -3
  402. package/llms/components/lr-switch.md +4 -3
  403. package/llms/components/lr-table.md +6 -1
  404. package/llms/components/lr-thinking-panel.md +8 -5
  405. package/llms/components/lr-token-input.md +15 -1
  406. package/llms/components/lr-tool-call-chip.md +2 -0
  407. package/llms/components/lr-tool-param-form.md +15 -4
  408. package/llms/components/lr-tooltip.md +8 -4
  409. package/llms/components/lr-trace-tree.md +7 -4
  410. package/llms/components/lr-video-playlist.md +7 -5
  411. package/llms/components/lr-voice-picker.md +7 -4
  412. package/llms/components/lr-widget.md +15 -2
  413. package/llms/migration.md +4 -4
  414. package/llms-full.txt +552 -159
  415. package/package.json +10 -8
  416. package/registrations.json +1 -1
  417. package/vscode-css-data.json +1 -1
  418. package/vscode-html-data.json +1 -1
  419. package/web-types.json +1 -1
@@ -1 +1 @@
1
- var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{nextId}from"../../../internal/a11y.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{snapshotLyraHighlights}from"../../../internal/highlight-collection.js";import{loadShikiHighlighter,loadShikiLanguage,loadShikiHighlighterCore,normalizeShikiLanguage,shikiHasLoadedLanguage}from"./code-loader.js";import{styles}from"./code-block.styles.js";import{CodeBlockInteractionController,applyCodeBlockAriaBusy,clampCodeBlockFocusedLine,codeBlockActiveHighlightLineSet,codeBlockLineHasFocus,codeBlockLineCount,codeBlockLineHighlightSet,codeBlockPreSuppliedGrammar,codeBlockShowsSkeleton,renderCodeBlockPlainCode,renderCodeBlockShell,restoreCodeBlockLineFocus,scrollCodeBlockToAnchor,tokenizeCodeBlock}from"./code-block-shared.js";import"../../overlays/skeleton/skeleton.class.js";import{presenceTrueDefaultBooleanConverter as trueDefaultBooleanConverter}from"../../../internal/converters.js";import{LYRA_DEFAULT_codeBlockLineLabel,LYRA_DEFAULT_codeRegion,LYRA_DEFAULT_codeRegionWithLanguage,LYRA_DEFAULT_collapseCode,LYRA_DEFAULT_copied,LYRA_DEFAULT_copiedToClipboard,LYRA_DEFAULT_copy,LYRA_DEFAULT_copyCode,LYRA_DEFAULT_copyFailed,LYRA_DEFAULT_expandCode}from"../../../internal/default-strings.generated.js";class LyraCodeBlock extends LyraElement{static{this.defaultStrings={...super.defaultStrings,codeBlockLineLabel:LYRA_DEFAULT_codeBlockLineLabel,codeRegion:LYRA_DEFAULT_codeRegion,codeRegionWithLanguage:LYRA_DEFAULT_codeRegionWithLanguage,collapseCode:LYRA_DEFAULT_collapseCode,copied:LYRA_DEFAULT_copied,copiedToClipboard:LYRA_DEFAULT_copiedToClipboard,copy:LYRA_DEFAULT_copy,copyCode:LYRA_DEFAULT_copyCode,copyFailed:LYRA_DEFAULT_copyFailed,expandCode:LYRA_DEFAULT_expandCode}}static{this.immutableEventDetails=Object.freeze(["lr-text-select"])}static{this.styles=[LyraElement.styles,styles]}get highlights(){return this._highlights}set highlights(value){const previous=this._highlights;this._highlights=snapshotLyraHighlights(value),this.requestUpdate("highlights",previous)}constructor(){super(),this.code="",this.language="",this.filename="",this.accessibleLabel=null,this.collapsible=!1,this.collapsed=!1,this.copyable=!0,this.copyAppearance="text",this.hasHeaderActions=!1,this.maxHeight="",this.lineNumbers=!1,this.highlightLines="",this.activatableLines=!1,this._highlights=snapshotLyraHighlights([]),this.activeHighlightId=null,this.anchorKinds=["line-range"],this.focusedLine=1,this.restoreFocusedLineAfterUpdate=!1,this.highlightedHtml=null,this.shikiReady=!1,this.justCopied=!1,this.copyFailed=!1,this.isDarkTheme=!1,this.interactions=new CodeBlockInteractionController({host:this,setFocusedLine:line=>{this.focusedLine=line},setJustCopied:value=>{this.justCopied=value},setCopyFailed:value=>{this.copyFailed=value},setDarkTheme:value=>{this.isDarkTheme=value},emitLineActivate:line=>this.emit("lr-line-activate",{line}),emitCopy:outcome=>this.emit("lr-copy",outcome),emitError:()=>this.emit("lr-error",null),emitCopyError:outcome=>this.emit("lr-copy-error",outcome),requestToggle:collapsed=>!this.emit("lr-toggle-request",{collapsed},{cancelable:!0}).defaultPrevented,emitToggle:collapsed=>this.emit("lr-toggle",{collapsed}),emitTextSelect:selection=>this.emit("lr-text-select",selection)}),this.highlightToken=0,this.defaultHighlighterLoading=!1,this.bodyId=nextId("code-block-body"),new ThemeWatcher(this,()=>this.refreshTheme())}connectedCallback(){super.connectedCallback(),this.refreshTheme(),this.observeHeaderActions(),this.ensureDefaultHighlighter(),(this.preSuppliedGrammar()||this.highlighter)&&this.syncHighlight()}ensureDefaultHighlighter(){!this.isConnected||this.highlighter!==void 0||this.defaultHighlighterLoading||(this.defaultHighlighterLoading=!0,loadShikiHighlighter().then(hl=>{this.defaultHighlighterLoading=!1,this.isConnected&&(this.highlighter=hl,this.shikiReady=!0,this.syncHighlight())}))}disconnectedCallback(){this.highlightToken++,super.disconnectedCallback(),this.headerActionsObserver?.disconnect(),this.headerActionsObserver=void 0,this.interactions.disconnect(),this.highlightedHtml=null}adoptedCallback(){super.adoptedCallback(),this.interactions.disconnect()}preSuppliedGrammar(){return codeBlockPreSuppliedGrammar(this.languages,this.language??"")}lineHighlightSet(){return codeBlockLineHighlightSet(this.highlightLines??"",this.highlights,this.lineCount())}activeHighlightLineSet(){return codeBlockActiveHighlightLineSet(this.highlights,this.activeHighlightId,this.lineCount())}lineCount(){return codeBlockLineCount(this.code??"")}async scrollToAnchor(target){return scrollCodeBlockToAnchor(this,target)}refreshTheme(){this.interactions.refreshTheme()}willUpdate(changed){super.willUpdate(changed),this.syncHeaderActions(),this.restoreFocusedLineAfterUpdate=codeBlockLineHasFocus(this),changed.has("code")&&(this.focusedLine=clampCodeBlockFocusedLine(this.focusedLine,this.lineCount())),this.interactions.needsHighlightResync(changed,this.effectiveLocale,this.localize("codeBlockLineLabel"))&&(this.shikiReady||this.preSuppliedGrammar())&&this.syncHighlight()}updated(changed){super.updated(changed),applyCodeBlockAriaBusy(this,this.showsSkeleton()),this.restoreFocusedLineAfterUpdate&&(restoreCodeBlockLineFocus(this,this.focusedLine),this.restoreFocusedLineAfterUpdate=!1)}syncHeaderActions(){const children=this.children;this.hasHeaderActions=(children?Array.from(children):[]).some(child=>child.getAttribute("slot")==="header-actions")}observeHeaderActions(){this.headerActionsObserver||typeof MutationObserver>"u"||(this.syncHeaderActions(),this.headerActionsObserver=new MutationObserver(()=>this.syncHeaderActions()),this.headerActionsObserver.observe(this,{childList:!0,attributes:!0,attributeFilter:["slot"],subtree:!0}))}showsSkeleton(){return codeBlockShowsSkeleton(this.shikiReady,this.language,!this.preSuppliedGrammar())}syncHighlight(){const token=++this.highlightToken,lang=normalizeShikiLanguage(this.language??"");if(!lang){this.highlightedHtml=null;return}const languages=this.languages;if(languages?.[lang]??languages?.[this.language]){this.highlightedHtml=null,loadShikiHighlighterCore(languages).then(hl2=>{token===this.highlightToken&&this.isConnected&&(this.highlightedHtml=hl2?this.tokenize(hl2,lang):null)});return}const hl=this.highlighter;if(!hl){this.highlightedHtml=null;return}if(shikiHasLoadedLanguage(hl,lang)){this.highlightedHtml=this.tokenize(hl,lang);return}this.highlightedHtml=null,loadShikiLanguage(hl,lang).then(ok=>{token===this.highlightToken&&this.isConnected&&(this.highlightedHtml=ok?this.tokenize(hl,lang):null)})}tokenize(hl,lang){return tokenizeCodeBlock(hl,{code:this.code??"",lang,lineNumbers:this.lineNumbers,activatableLines:this.activatableLines,focusedLine:this.focusedLine,highlightedLines:this.lineHighlightSet(),activeLines:this.activeHighlightLineSet(),lineLabel:line=>this.localize("codeBlockLineLabel",void 0,{line:getNumberFormat(this.effectiveLocale).format(line)}),lineNumberText:line=>getNumberFormat(this.effectiveLocale).format(line)})}renderPlainCode(){return renderCodeBlockPlainCode({code:this.code??"",lineNumbers:this.lineNumbers,activatableLines:this.activatableLines,focusedLine:this.focusedLine,highlightedLines:this.lineHighlightSet(),activeLines:this.activeHighlightLineSet(),localize:this.localize.bind(this),lineLabel:line=>this.localize("codeBlockLineLabel",void 0,{line:getNumberFormat(this.effectiveLocale).format(line)}),lineNumberText:line=>getNumberFormat(this.effectiveLocale).format(line),onLineActivate:line=>this.interactions.onLineActivate(line),onLineKeyDown:(e,line)=>this.interactions.onLineKeyDown(e,line)})}render(){return renderCodeBlockShell({filename:this.filename,language:this.language,copyable:this.copyable,copyAppearance:this.copyAppearance,hasHeaderActions:this.hasHeaderActions,collapsible:this.collapsible,collapsed:this.collapsed,justCopied:this.justCopied,copyFailed:this.copyFailed,bodyId:this.bodyId,accessibleLabel:this.accessibleLabel,maxHeight:this.maxHeight,isDarkTheme:this.isDarkTheme,showSkeleton:this.showsSkeleton(),highlightedHtml:this.highlightedHtml,lineNumbers:this.lineNumbers,localize:this.localize.bind(this),renderPlainCode:()=>this.renderPlainCode(),onToggle:this.interactions.toggleCollapsed,onCopy:this.interactions.copy,onBodyMouseUp:this.interactions.onBodyMouseUp,onBodyClick:this.interactions.onBodyClick,onBodyKeyDown:this.interactions.onBodyKeyDown,onBodyFocusIn:this.interactions.onBodyFocusIn})}}__decorate([property()],LyraCodeBlock.prototype,"code",void 0),__decorate([property()],LyraCodeBlock.prototype,"language",void 0),__decorate([property()],LyraCodeBlock.prototype,"filename",void 0),__decorate([property({attribute:"aria-label"})],LyraCodeBlock.prototype,"accessibleLabel",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraCodeBlock.prototype,"collapsible",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraCodeBlock.prototype,"collapsed",void 0),__decorate([property({type:Boolean,reflect:!0,converter:trueDefaultBooleanConverter})],LyraCodeBlock.prototype,"copyable",void 0),__decorate([property({attribute:"copy-appearance",reflect:!0})],LyraCodeBlock.prototype,"copyAppearance",void 0),__decorate([state()],LyraCodeBlock.prototype,"hasHeaderActions",void 0),__decorate([property({attribute:"max-height"})],LyraCodeBlock.prototype,"maxHeight",void 0),__decorate([property({type:Boolean,attribute:"line-numbers",reflect:!0})],LyraCodeBlock.prototype,"lineNumbers",void 0),__decorate([property({attribute:"highlight-lines"})],LyraCodeBlock.prototype,"highlightLines",void 0),__decorate([property({type:Boolean,attribute:"activatable-lines"})],LyraCodeBlock.prototype,"activatableLines",void 0),__decorate([property({attribute:!1})],LyraCodeBlock.prototype,"highlights",null),__decorate([property({attribute:"active-highlight-id"})],LyraCodeBlock.prototype,"activeHighlightId",void 0),__decorate([state()],LyraCodeBlock.prototype,"focusedLine",void 0),__decorate([property({attribute:!1})],LyraCodeBlock.prototype,"languages",void 0),__decorate([state()],LyraCodeBlock.prototype,"highlightedHtml",void 0),__decorate([state()],LyraCodeBlock.prototype,"shikiReady",void 0),__decorate([state()],LyraCodeBlock.prototype,"justCopied",void 0),__decorate([state()],LyraCodeBlock.prototype,"copyFailed",void 0),__decorate([state()],LyraCodeBlock.prototype,"isDarkTheme",void 0);export{LyraCodeBlock};
1
+ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{nextId}from"../../../internal/a11y.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{snapshotLyraHighlights}from"../../../internal/highlight-collection.js";import{loadShikiHighlighter,loadShikiLanguage,loadShikiHighlighterCore,normalizeShikiLanguage,shikiHasLoadedLanguage}from"./code-loader.js";import{styles}from"./code-block.styles.js";import{CodeBlockHeaderActionsController,CodeBlockInteractionController,applyCodeBlockAriaBusy,clampCodeBlockFocusedLine,codeBlockActiveHighlightLineSet,codeBlockLineHasFocus,codeBlockLineCount,codeBlockLineHighlightSet,codeBlockPreSuppliedGrammar,codeBlockShowsSkeleton,renderCodeBlockPlainCode,renderCodeBlockShell,restoreCodeBlockLineFocus,scrollCodeBlockToAnchor,tokenizeCodeBlock}from"./code-block-shared.js";import"../../overlays/skeleton/skeleton.class.js";import{presenceTrueDefaultBooleanConverter as trueDefaultBooleanConverter}from"../../../internal/converters.js";import{LYRA_DEFAULT_codeBlockLineLabel,LYRA_DEFAULT_codeRegion,LYRA_DEFAULT_codeRegionWithLanguage,LYRA_DEFAULT_collapseCode,LYRA_DEFAULT_copied,LYRA_DEFAULT_copiedToClipboard,LYRA_DEFAULT_copy,LYRA_DEFAULT_copyCode,LYRA_DEFAULT_copyFailed,LYRA_DEFAULT_expandCode}from"../../../internal/default-strings.generated.js";class LyraCodeBlock extends LyraElement{static{this.defaultStrings={...super.defaultStrings,codeBlockLineLabel:LYRA_DEFAULT_codeBlockLineLabel,codeRegion:LYRA_DEFAULT_codeRegion,codeRegionWithLanguage:LYRA_DEFAULT_codeRegionWithLanguage,collapseCode:LYRA_DEFAULT_collapseCode,copied:LYRA_DEFAULT_copied,copiedToClipboard:LYRA_DEFAULT_copiedToClipboard,copy:LYRA_DEFAULT_copy,copyCode:LYRA_DEFAULT_copyCode,copyFailed:LYRA_DEFAULT_copyFailed,expandCode:LYRA_DEFAULT_expandCode}}static{this.immutableEventDetails=Object.freeze(["lr-text-select"])}static{this.styles=[LyraElement.styles,styles]}get highlights(){return this._highlights}set highlights(value){const previous=this._highlights;this._highlights=snapshotLyraHighlights(value),this.requestUpdate("highlights",previous)}constructor(){super(),this.code="",this.language="",this.filename="",this.accessibleLabel=null,this.collapsible=!1,this.collapsed=!1,this.copyable=!0,this.copyAppearance="text",this.hasHeaderActions=!1,this.maxHeight="",this.lineNumbers=!1,this.highlightLines="",this.activatableLines=!1,this._highlights=snapshotLyraHighlights([]),this.activeHighlightId=null,this.anchorKinds=["line-range"],this.focusedLine=1,this.restoreFocusedLineAfterUpdate=!1,this.highlightedHtml=null,this.shikiReady=!1,this.justCopied=!1,this.copyFailed=!1,this.isDarkTheme=!1,this.interactions=new CodeBlockInteractionController({host:this,setFocusedLine:line=>{this.focusedLine=line},setJustCopied:value=>{this.justCopied=value},setCopyFailed:value=>{this.copyFailed=value},setDarkTheme:value=>{this.isDarkTheme=value},emitLineActivate:line=>this.emit("lr-line-activate",{line}),emitCopy:outcome=>this.emit("lr-copy",outcome),emitError:()=>this.emit("lr-error",null),emitCopyError:outcome=>this.emit("lr-copy-error",outcome),requestToggle:collapsed=>!this.emit("lr-toggle-request",{collapsed},{cancelable:!0}).defaultPrevented,emitToggle:collapsed=>this.emit("lr-toggle",{collapsed}),emitTextSelect:selection=>this.emit("lr-text-select",selection)}),this.headerActions=new CodeBlockHeaderActionsController({host:this,setHasHeaderActions:value=>{this.hasHeaderActions=value}}),this.highlightToken=0,this.defaultHighlighterLoading=!1,this.bodyId=nextId("code-block-body"),new ThemeWatcher(this,()=>this.refreshTheme())}connectedCallback(){super.connectedCallback(),this.refreshTheme(),this.headerActions.observe(),this.ensureDefaultHighlighter(),(this.preSuppliedGrammar()||this.highlighter)&&this.syncHighlight()}ensureDefaultHighlighter(){!this.isConnected||this.highlighter!==void 0||this.defaultHighlighterLoading||(this.defaultHighlighterLoading=!0,loadShikiHighlighter().then(hl=>{this.defaultHighlighterLoading=!1,this.isConnected&&(this.highlighter=hl,this.shikiReady=!0,this.syncHighlight())}))}disconnectedCallback(){this.highlightToken++,super.disconnectedCallback(),this.headerActions.disconnect(),this.interactions.disconnect(),this.highlightedHtml=null}adoptedCallback(){super.adoptedCallback(),this.interactions.disconnect()}preSuppliedGrammar(){return codeBlockPreSuppliedGrammar(this.languages,this.language??"")}lineHighlightSet(){return codeBlockLineHighlightSet(this.highlightLines??"",this.highlights,this.lineCount())}activeHighlightLineSet(){return codeBlockActiveHighlightLineSet(this.highlights,this.activeHighlightId,this.lineCount())}lineCount(){return codeBlockLineCount(this.code??"")}async scrollToAnchor(target){return scrollCodeBlockToAnchor(this,target)}refreshTheme(){this.interactions.refreshTheme()}willUpdate(changed){super.willUpdate(changed),this.headerActions.sync(),this.restoreFocusedLineAfterUpdate=codeBlockLineHasFocus(this),changed.has("code")&&(this.focusedLine=clampCodeBlockFocusedLine(this.focusedLine,this.lineCount())),this.interactions.needsHighlightResync(changed,this.effectiveLocale,this.localize("codeBlockLineLabel"))&&(this.shikiReady||this.preSuppliedGrammar())&&this.syncHighlight()}updated(changed){super.updated(changed),applyCodeBlockAriaBusy(this,this.showsSkeleton()),this.restoreFocusedLineAfterUpdate&&(restoreCodeBlockLineFocus(this,this.focusedLine),this.restoreFocusedLineAfterUpdate=!1)}showsSkeleton(){return codeBlockShowsSkeleton(this.shikiReady,this.language,!this.preSuppliedGrammar())}syncHighlight(){const token=++this.highlightToken,lang=normalizeShikiLanguage(this.language??"");if(!lang){this.highlightedHtml=null;return}const languages=this.languages;if(languages?.[lang]??languages?.[this.language]){this.highlightedHtml=null,loadShikiHighlighterCore(languages).then(hl2=>{token===this.highlightToken&&this.isConnected&&(this.highlightedHtml=hl2?this.tokenize(hl2,lang):null)});return}const hl=this.highlighter;if(!hl){this.highlightedHtml=null;return}if(shikiHasLoadedLanguage(hl,lang)){this.highlightedHtml=this.tokenize(hl,lang);return}this.highlightedHtml=null,loadShikiLanguage(hl,lang).then(ok=>{token===this.highlightToken&&this.isConnected&&(this.highlightedHtml=ok?this.tokenize(hl,lang):null)})}tokenize(hl,lang){return tokenizeCodeBlock(hl,{code:this.code??"",lang,lineNumbers:this.lineNumbers,activatableLines:this.activatableLines,focusedLine:this.focusedLine,highlightedLines:this.lineHighlightSet(),activeLines:this.activeHighlightLineSet(),lineLabel:line=>this.localize("codeBlockLineLabel",void 0,{line:getNumberFormat(this.effectiveLocale).format(line)}),lineNumberText:line=>getNumberFormat(this.effectiveLocale).format(line)})}renderPlainCode(){return renderCodeBlockPlainCode({code:this.code??"",lineNumbers:this.lineNumbers,activatableLines:this.activatableLines,focusedLine:this.focusedLine,highlightedLines:this.lineHighlightSet(),activeLines:this.activeHighlightLineSet(),localize:this.localize.bind(this),lineLabel:line=>this.localize("codeBlockLineLabel",void 0,{line:getNumberFormat(this.effectiveLocale).format(line)}),lineNumberText:line=>getNumberFormat(this.effectiveLocale).format(line),onLineActivate:line=>this.interactions.onLineActivate(line),onLineKeyDown:(e,line)=>this.interactions.onLineKeyDown(e,line)})}render(){return renderCodeBlockShell({filename:this.filename,language:this.language,copyable:this.copyable,copyAppearance:this.copyAppearance,hasHeaderActions:this.hasHeaderActions,collapsible:this.collapsible,collapsed:this.collapsed,justCopied:this.justCopied,copyFailed:this.copyFailed,bodyId:this.bodyId,accessibleLabel:this.accessibleLabel,maxHeight:this.maxHeight,isDarkTheme:this.isDarkTheme,showSkeleton:this.showsSkeleton(),highlightedHtml:this.highlightedHtml,lineNumbers:this.lineNumbers,localize:this.localize.bind(this),renderPlainCode:()=>this.renderPlainCode(),onToggle:this.interactions.toggleCollapsed,onCopy:this.interactions.copy,onBodyMouseUp:this.interactions.onBodyMouseUp,onBodyClick:this.interactions.onBodyClick,onBodyKeyDown:this.interactions.onBodyKeyDown,onBodyFocusIn:this.interactions.onBodyFocusIn})}}__decorate([property()],LyraCodeBlock.prototype,"code",void 0),__decorate([property()],LyraCodeBlock.prototype,"language",void 0),__decorate([property()],LyraCodeBlock.prototype,"filename",void 0),__decorate([property({attribute:"aria-label"})],LyraCodeBlock.prototype,"accessibleLabel",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraCodeBlock.prototype,"collapsible",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraCodeBlock.prototype,"collapsed",void 0),__decorate([property({type:Boolean,reflect:!0,converter:trueDefaultBooleanConverter})],LyraCodeBlock.prototype,"copyable",void 0),__decorate([property({attribute:"copy-appearance",reflect:!0})],LyraCodeBlock.prototype,"copyAppearance",void 0),__decorate([state()],LyraCodeBlock.prototype,"hasHeaderActions",void 0),__decorate([property({attribute:"max-height"})],LyraCodeBlock.prototype,"maxHeight",void 0),__decorate([property({type:Boolean,attribute:"line-numbers",reflect:!0})],LyraCodeBlock.prototype,"lineNumbers",void 0),__decorate([property({attribute:"highlight-lines"})],LyraCodeBlock.prototype,"highlightLines",void 0),__decorate([property({type:Boolean,attribute:"activatable-lines"})],LyraCodeBlock.prototype,"activatableLines",void 0),__decorate([property({attribute:!1})],LyraCodeBlock.prototype,"highlights",null),__decorate([property({attribute:"active-highlight-id"})],LyraCodeBlock.prototype,"activeHighlightId",void 0),__decorate([state()],LyraCodeBlock.prototype,"focusedLine",void 0),__decorate([property({attribute:!1})],LyraCodeBlock.prototype,"languages",void 0),__decorate([state()],LyraCodeBlock.prototype,"highlightedHtml",void 0),__decorate([state()],LyraCodeBlock.prototype,"shikiReady",void 0),__decorate([state()],LyraCodeBlock.prototype,"justCopied",void 0),__decorate([state()],LyraCodeBlock.prototype,"copyFailed",void 0),__decorate([state()],LyraCodeBlock.prototype,"isDarkTheme",void 0);export{LyraCodeBlock};
@@ -12,8 +12,8 @@ ${this.tablerow({text:headerRow})}</thead>
12
12
  `,tbody=bodyRows?`<tbody>${bodyRows}</tbody>
13
13
  `:"";return`<table part='table'>
14
14
  ${thead}${tbody}</table>
15
- `},link(token){const text=this.parser.parseInline(token.tokens),href=cleanHref(token.href);if(href===null)return text;const safeHref=trustedHtmlOption?href:safeLinkHref(href);if(safeHref===null)return text;const titleAttr=token.title?` title='${escapeHtml(token.title)}'`:"",targetAttr=linkTarget?` target='${escapeHtml(linkTarget)}' rel='noopener noreferrer'`:"";return`<a part='link' href='${escapeHtml(safeHref)}'${titleAttr}${targetAttr}>${text}</a>`},image(token){const altText=this.parser.parseInline(token.tokens,this.parser.textRenderer),href=cleanHref(token.href);if(href===null)return escapeHtml(altText);const safeHref=trustedHtmlOption?href:safeMediaSrc(href);if(safeHref===null)return escapeHtml(altText);const titleAttr=token.title?` title='${escapeHtml(token.title)}'`:"";return`<img part='img' src='${escapeHtml(safeHref)}' alt='${escapeHtml(altText)}'${titleAttr}>`},html(token){return escapeHtmlOption?escapeHtml(token.text):token.text}}});for(const configuration of options.markedConfigurations??[]){if(!configuration||typeof configuration!="object")continue;const configuredDefaults=Object.fromEntries(Object.entries(configuration).filter(([,value])=>value!=null));Object.keys(configuredDefaults).length>0&&instance.use(configuredDefaults)}return{html:instance.parse(content,{gfm,async:!1}),hadMathFallback}}const KATEX_OVERRIDE=Symbol.for("@aceshooting/lyra-ui/markdown-katex-override");function readKatexOverride(){return Reflect.has(globalThis,KATEX_OVERRIDE)?{present:!0,value:Reflect.get(globalThis,KATEX_OVERRIDE)}:{present:!1,value:null}}function createMarkdownKatexState(){let resolved,loadStarted=!1;const subscribers=new Set;return{getIfLoaded(){const override=readKatexOverride();return override.present?override.value:resolved??null},isConfirmedMissing(){const override=readKatexOverride();return(override.present?override.value:resolved)===null},startLoad(onResolved){readKatexOverride().present||resolved!==void 0||(subscribers.add(onResolved),!loadStarted&&(loadStarted=!0,getKatex().then(katex=>{resolved=katex;const pending=[...subscribers];subscribers.clear();for(const subscriber of pending)subscriber()})))}}}function markdownCodeTransformer(lang){return{name:"lr-markdown-code-block",pre(node){node.properties.part=["code-block"],node.properties.tabindex="0"},code(node){const classValue=node.properties.class,classes=Array.isArray(classValue)?classValue.map(String):classValue?[String(classValue)]:[];node.properties.class=[...classes,`language-${lang}`]}}}const SHIKI_COLOR=/^#(?:[\da-f]{3}|[\da-f]{4}|[\da-f]{6}|[\da-f]{8})$/i,SHIKI_STYLE_TO_DATA={color:"data-lr-shiki-light","background-color":"data-lr-shiki-light-bg","--shiki-light":"data-lr-shiki-light","--shiki-light-bg":"data-lr-shiki-light-bg","--shiki-dark":"data-lr-shiki-dark","--shiki-dark-bg":"data-lr-shiki-dark-bg"},SHIKI_DATA_TO_STYLE={"data-lr-shiki-light":"color","data-lr-shiki-light-bg":"background-color","data-lr-shiki-dark":"--shiki-dark","data-lr-shiki-dark-bg":"--shiki-dark-bg"};function encodeMarkdownHighlightStyles(markup){return markup.replace(/\sstyle=(["'])(.*?)\1/gi,(_attribute,_quote,value)=>{const attributes=[];for(const declaration of value.split(";")){const separator=declaration.indexOf(":");if(separator<0)continue;const property=declaration.slice(0,separator).trim().toLowerCase(),color=declaration.slice(separator+1).trim(),dataAttribute=SHIKI_STYLE_TO_DATA[property];dataAttribute&&SHIKI_COLOR.test(color)&&attributes.push(`${dataAttribute}="${color}"`)}return attributes.length>0?` ${attributes.join(" ")}`:""})}function restoreMarkdownHighlightStyles(markup){return markup.replace(/<[a-z][^<>]*>/gi,openingTag=>{const declarations=[],cleanTag=openingTag.replace(/\s(data-lr-shiki-(?:light-bg|dark-bg|light|dark))=(["'])(#[\da-f]+)\2/gi,(attribute,name,_quote,color)=>{const property=SHIKI_DATA_TO_STYLE[name.toLowerCase()];return!property||!SHIKI_COLOR.test(color)?attribute:(declarations.push(`${property}:${color}`),"")});return declarations.length===0?cleanTag:`${cleanTag.slice(0,-1)} style="${declarations.join(";")}">`})}function tokenizeMarkdownHighlight(hl,pending){try{const highlighted=hl.codeToHtml(pending.code,{lang:normalizeShikiLanguage(pending.lang),themes:SHIKI_THEMES,transformers:[markdownCodeTransformer(pending.lang)]});return`${encodeMarkdownHighlightStyles(highlighted)}
16
- `}catch{return null}}const markdownDepsLoadGenerations=new WeakMap;function beginMarkdownDepsLoad(host,apply){const generation=(markdownDepsLoadGenerations.get(host)??0)+1;markdownDepsLoadGenerations.set(host,generation);const alreadyLoaded=getMarkdownDepsIfLoaded();if(alreadyLoaded){apply(alreadyLoaded);return}loadMarkdownDeps().then(resolved=>{!host.isConnected||markdownDepsLoadGenerations.get(host)!==generation||apply(resolved)})}function markdownNeedsReparse(changed){return changed.has("content")||changed.has("tabSize")||changed.has("htmlMode")||changed.has("gfm")||changed.has("linkTarget")||changed.has("headingOffset")||changed.has("streaming")||changed.has("headingAnchors")||changed.has("math")||changed.has("highlightCode")||changed.has("languages")}function markdownHighlightConfigChanged(changed){return changed.has("highlightCode")||changed.has("languages")}function markdownLanguageSetChanged(changed){return changed.has("languages")}function normalizeMarkdownHtmlMode(value){return value==="escape"||value==="trusted"?value:"sanitize"}function renderMarkdownDocument(options){const{deps,tag}=options;if(!deps.marked)return{status:"fallback",error:new Error(`<${tag}> could not render: the "marked" peer dependency failed to load.`),headingTree:null};const pendingKeys=[],headingTree=[];let rawHtml,hadMathFallback;try{const parsed=options.parse(deps.marked,pendingKeys,headingTree);rawHtml=parsed.html,hadMathFallback=parsed.hadMathFallback}catch(error){return{status:"fallback",error,headingTree:null}}options.onParsed();const mathFailed=hadMathFallback&&options.isKatexConfirmedMissing();if(options.htmlMode!=="sanitize")return{status:"rendered",html:restoreMarkdownHighlightStyles(rawHtml),headingTree,mathFailed,pendingKeys};if(!deps.DOMPurify){const error=new Error(`<${tag}> could not render: sanitize is enabled (the default) but the "dompurify" peer dependency failed to load — refusing to render unsanitized HTML. Install it with \`pnpm add dompurify\`, or set html-mode="trusted" to explicitly opt out of sanitization.`);return warnMarkdownSanitizerUnavailable(),{status:"fallback",error,headingTree}}let sanitized;try{const result=deps.DOMPurify.sanitize(rawHtml,{ADD_ATTR:["target"],FORBID_ATTR:["style"],...options.math?{ADD_TAGS:["semantics","annotation"]}:{}});if(typeof result!="string")throw new TypeError("The HTML sanitizer returned non-string markup.");sanitized=restoreMarkdownHighlightStyles(result)}catch(error){return warnMarkdownSanitizerUnavailable(),{status:"fallback",error,headingTree}}return{status:"rendered",html:sanitized,headingTree,mathFailed,pendingKeys}}function markdownMathPeerError(tag){return new Error(`<${tag}> needs the optional peer dependency \`katex\` to render math (the \`math\` property is set) — install it with \`pnpm add katex\`.`)}function applyMarkdownAriaBusy(host,busy){busy?host.setAttribute("aria-busy","true"):host.removeAttribute("aria-busy")}function markdownScrollBehavior(root){const view=root.ownerDocument.defaultView;return!view||prefersReducedMotion(view)?"auto":"smooth"}function applyMarkdownFragmentAnchor(root,anchor,headingTree){if(!anchor.id)return!1;let index=-1;const headingLimit=Math.min(headingTree.length,TEXT_QUOTE_LIMITS.maxTraversalNodes);for(let headingIndex2=0;headingIndex2<headingLimit;headingIndex2++)if(headingTree[headingIndex2]?.id===anchor.id){index=headingIndex2;break}if(index<0)return!1;const walker=root.ownerDocument.createTreeWalker(root,1);let inspected=0,headingIndex=0,escapedIdMatch=null,positionalMatch=null,node;for(;inspected<TEXT_QUOTE_LIMITS.maxTraversalNodes&&(node=walker.nextNode());){inspected++;const candidate=node;if(candidate.getAttribute("id")===anchor.id&&(escapedIdMatch??=candidate),/^H[1-6]$/.test(candidate.tagName)&&(headingIndex===index&&(positionalMatch=candidate),headingIndex++),escapedIdMatch&&positionalMatch)break}const el=escapedIdMatch??positionalMatch;return el?(el.scrollIntoView({behavior:markdownScrollBehavior(root),block:"start"}),!0):!1}function applyMarkdownTextQuoteAnchor(root,anchor,locale,index=createTextQuoteIndex(scopeFromElement(root),locale)){const match=index.resolve(anchor),range=match?rangeFromTextQuoteMatch(index.scope,match):null;return range?(((range.startContainer.nodeType===1?range.startContainer:range.startContainer.parentElement)??root).scrollIntoView({behavior:markdownScrollBehavior(root),block:"center"}),!0):!1}const HIGHLIGHT_TONES=["accent","success","warning","danger","neutral"],MARKDOWN_PAINTED_HIGHLIGHT_LIMIT=100;function repaintMarkdownHighlights(options){const resolved=[],rangesByTone=new Map(HIGHLIGHT_TONES.map(tone=>[tone,[]]));let activeRange=null;const workBudget=options.index.createWorkBudget(),matches=[];for(const highlight of prioritizedHighlightCandidates(options.highlights,options.activeHighlightId)){if(matches.length>=MARKDOWN_PAINTED_HIGHLIGHT_LIMIT)break;if(highlight.anchor.kind!=="text-quote")continue;const match=options.index.resolve(highlight.anchor,workBudget);match&&matches.push({highlight,match})}const ranges=rangesFromTextQuoteMatches(options.index.scope,matches.map(({match})=>match));for(let position=0;position<matches.length;position++){const{highlight}=matches[position],range=ranges[position]??null;range&&(rangesByTone.get(highlight.tone??"accent").push(range),resolved.push({id:highlight.id,range}),highlight.id===options.activeHighlightId&&(activeRange=range))}for(const[tone,ranges2]of rangesByTone)options.handle.setRanges(tone,ranges2);if(options.handle.setActive(activeRange),!supportsCustomHighlights(options.root.ownerDocument)){const walker=options.root.ownerDocument.createTreeWalker(options.root,1);let inspected=0,node;for(;inspected<TEXT_QUOTE_LIMITS.maxTraversalNodes+MARKDOWN_PAINTED_HIGHLIGHT_LIMIT&&(node=walker.nextNode());){inspected++;const mark=node;mark.localName==="mark"&&mark.hasAttribute("data-lr-highlight-tone")&&!mark.hasAttribute("part")&&mark.setAttribute("part","highlight")}}return resolved}function hitTestHighlightRanges(ranges,x,y){let remainingRects=TEXT_SELECTION_RECT_LIMIT;for(let i=ranges.length-1;i>=0;i--){const hit=ranges[i];if(hit)for(const rect of hit.range.getClientRects()){if(remainingRects--<=0)return null;if(x>=rect.left&&x<=rect.right&&y>=rect.top&&y<=rect.bottom)return hit.id}}return null}const nativeElementGetAttribute=typeof Element>"u"?void 0:Element.prototype.getAttribute,nativeAnchorHref=typeof HTMLAnchorElement>"u"?void 0:Object.getOwnPropertyDescriptor(HTMLAnchorElement.prototype,"href")?.get;function markdownAnchorFromTarget(target){if(!(typeof target!="object"&&typeof target!="function"||target===null)&&!(!nativeElementGetAttribute||!nativeAnchorHref))try{return nativeElementGetAttribute.call(target,"data-lr-brand-probe"),nativeAnchorHref.call(target),target}catch{return}}function nativeAnchorAttribute(anchor,name){try{const value=nativeElementGetAttribute?.call(anchor,name);return typeof value=="string"?value:void 0}catch{return}}function internalLinkHrefFrom(e,prefix){if(!prefix)return null;const anchor=e.composedPath().find(target=>markdownAnchorFromTarget(target)!==void 0);if(!anchor)return null;const href=nativeAnchorAttribute(anchor,"href")??"";return href.startsWith(prefix)?href:null}function renderMarkdownContent(options){const isFallback=options.renderedHtml===null,sanitizedMaxHeight=sanitizeCssLength(options.maxHeight);return html`
15
+ `},link(token){const text=this.parser.parseInline(token.tokens),href=cleanHref(token.href);if(href===null)return text;const safeHref=trustedHtmlOption?href:safeLinkHref(href);if(safeHref===null)return text;const titleAttr=token.title?` title='${escapeHtml(token.title)}'`:"",targetAttr=linkTarget?` target='${escapeHtml(linkTarget)}' rel='noopener noreferrer'`:"";return`<a part='link' href='${escapeHtml(safeHref)}'${titleAttr}${targetAttr}>${text}</a>`},image(token){const altText=this.parser.parseInline(token.tokens,this.parser.textRenderer),href=cleanHref(token.href);if(href===null)return escapeHtml(altText);const safeHref=trustedHtmlOption?href:safeMediaSrc(href);if(safeHref===null)return escapeHtml(altText);const titleAttr=token.title?` title='${escapeHtml(token.title)}'`:"";return`<img part='img' src='${escapeHtml(safeHref)}' alt='${escapeHtml(altText)}'${titleAttr}>`},html(token){return escapeHtmlOption?escapeHtml(token.text):token.text}}});for(const configuration of options.markedConfigurations??[]){if(!configuration||typeof configuration!="object")continue;const configuredDefaults=Object.fromEntries(Object.entries(configuration).filter(([,value])=>value!=null));Object.keys(configuredDefaults).length>0&&instance.use(configuredDefaults)}return{html:instance.parse(content,{gfm,async:!1}),hadMathFallback}}const KATEX_OVERRIDE=Symbol.for("@aceshooting/lyra-ui/markdown-katex-override");function readKatexOverride(){return Reflect.has(globalThis,KATEX_OVERRIDE)?{present:!0,value:Reflect.get(globalThis,KATEX_OVERRIDE)}:{present:!1,value:null}}function createMarkdownKatexState(){let resolved,loadStarted=!1;const subscribers=new Set;return{getIfLoaded(){const override=readKatexOverride();return override.present?override.value:resolved??null},isConfirmedMissing(){const override=readKatexOverride();return(override.present?override.value:resolved)===null},startLoad(onResolved){readKatexOverride().present||resolved!==void 0||(subscribers.add(onResolved),!loadStarted&&(loadStarted=!0,getKatex().then(katex=>{resolved=katex;const pending=[...subscribers];subscribers.clear();for(const subscriber of pending)subscriber()})))}}}function markdownCodeTransformer(lang){return{name:"lr-markdown-code-block",pre(node){node.properties.part=["code-block"],node.properties.tabindex="0"},code(node){const classValue=node.properties.class,classes=Array.isArray(classValue)?classValue.map(String):classValue?[String(classValue)]:[];node.properties.class=[...classes,`language-${lang}`]}}}const SHIKI_COLOR=/^#(?:[\da-f]{3}|[\da-f]{4}|[\da-f]{6}|[\da-f]{8})$/i,SHIKI_STYLE_TO_DATA={color:"data-lr-shiki-light","background-color":"data-lr-shiki-light-bg","--shiki-light":"data-lr-shiki-light","--shiki-light-bg":"data-lr-shiki-light-bg","--shiki-dark":"data-lr-shiki-dark","--shiki-dark-bg":"data-lr-shiki-dark-bg"},SHIKI_DATA_TO_STYLE={"data-lr-shiki-light":"color","data-lr-shiki-light-bg":"background-color","data-lr-shiki-dark":"--shiki-dark","data-lr-shiki-dark-bg":"--shiki-dark-bg"};function encodeMarkdownHighlightStyles(markup){return markup.replace(/\sstyle=(["'])(.*?)\1/gi,(_attribute,_quote,value)=>{const attributes=[];for(const declaration of value.split(";")){const separator=declaration.indexOf(":");if(separator<0)continue;const property=declaration.slice(0,separator).trim().toLowerCase(),color=declaration.slice(separator+1).trim(),dataAttribute=SHIKI_STYLE_TO_DATA[property];dataAttribute&&SHIKI_COLOR.test(color)&&attributes.push(`${dataAttribute}="${color}"`)}return attributes.length>0?` ${attributes.join(" ")}`:""})}function restoreMarkdownHighlightStyles(markup){return markup.replace(/<[a-z][^<>]*>/gi,openingTag=>{const declarations=[],cleanTag=openingTag.replace(/\s(data-lr-shiki-(?:light-bg|dark-bg|light|dark))=(["'])(#[\da-f]+)\2/gi,(attribute,name,_quote,color)=>{const property=SHIKI_DATA_TO_STYLE[name.toLowerCase()];return!property||!SHIKI_COLOR.test(color)?attribute:(declarations.push(`${property}:${color}`),"")});return declarations.length===0?cleanTag:`${cleanTag.slice(0,-1)} style="${declarations.join(";")}">`})}const MARKDOWN_ANCHOR_ATTR=/([a-zA-Z][\w-]*)\s*=\s*(\x22([^\x22]*)\x22|\x27([^\x27]*)\x27|[^\s\x22\x27=<>\x60]+)/g;function enforceMarkdownAnchorRelGuard(markup){return markup.replace(/<a\b[^<>]*>/gi,tag=>{MARKDOWN_ANCHOR_ATTR.lastIndex=0;let hasTarget=!1,relMatch=null,match;for(;match=MARKDOWN_ANCHOR_ATTR.exec(tag);){const name=match[1].toLowerCase();name==="target"?hasTarget=!0:name==="rel"&&(relMatch=match)}if(!hasTarget)return tag;const authoredValue=relMatch?relMatch[3]??relMatch[4]??relMatch[2]:"",tokens=new Set(authoredValue.split(/\s+/).filter(token=>token!==""&&token.toLowerCase()!=="opener"));tokens.add("noopener"),tokens.add("noreferrer");const relValue=[...tokens].join(" ");if(relMatch){const start=relMatch.index,end=start+relMatch[0].length;return`${tag.slice(0,start)}rel='${relValue}'${tag.slice(end)}`}return`${tag.slice(0,-1)} rel='${relValue}'>`})}function tokenizeMarkdownHighlight(hl,pending){try{const highlighted=hl.codeToHtml(pending.code,{lang:normalizeShikiLanguage(pending.lang),themes:SHIKI_THEMES,transformers:[markdownCodeTransformer(pending.lang)]});return`${encodeMarkdownHighlightStyles(highlighted)}
16
+ `}catch{return null}}const markdownDepsLoadGenerations=new WeakMap;function beginMarkdownDepsLoad(host,apply){const generation=(markdownDepsLoadGenerations.get(host)??0)+1;markdownDepsLoadGenerations.set(host,generation);const alreadyLoaded=getMarkdownDepsIfLoaded();if(alreadyLoaded){apply(alreadyLoaded);return}loadMarkdownDeps().then(resolved=>{!host.isConnected||markdownDepsLoadGenerations.get(host)!==generation||apply(resolved)})}function markdownNeedsReparse(changed){return changed.has("content")||changed.has("tabSize")||changed.has("htmlMode")||changed.has("gfm")||changed.has("linkTarget")||changed.has("headingOffset")||changed.has("streaming")||changed.has("headingAnchors")||changed.has("math")||changed.has("highlightCode")||changed.has("languages")}function markdownHighlightConfigChanged(changed){return changed.has("highlightCode")||changed.has("languages")}function markdownLanguageSetChanged(changed){return changed.has("languages")}function normalizeMarkdownHtmlMode(value){return value==="escape"||value==="trusted"?value:"sanitize"}function renderMarkdownDocument(options){const{deps,tag}=options;if(!deps.marked)return{status:"fallback",error:new Error(`<${tag}> could not render: the "marked" peer dependency failed to load.`),headingTree:null};const pendingKeys=[],headingTree=[];let rawHtml,hadMathFallback;try{const parsed=options.parse(deps.marked,pendingKeys,headingTree);rawHtml=parsed.html,hadMathFallback=parsed.hadMathFallback}catch(error){return{status:"fallback",error,headingTree:null}}options.onParsed();const mathFailed=hadMathFallback&&options.isKatexConfirmedMissing();if(options.htmlMode!=="sanitize")return{status:"rendered",html:enforceMarkdownAnchorRelGuard(restoreMarkdownHighlightStyles(rawHtml)),headingTree,mathFailed,pendingKeys};if(!deps.DOMPurify){const error=new Error(`<${tag}> could not render: sanitize is enabled (the default) but the "dompurify" peer dependency failed to load — refusing to render unsanitized HTML. Install it with \`pnpm add dompurify\`, or set html-mode="trusted" to explicitly opt out of sanitization.`);return warnMarkdownSanitizerUnavailable(),{status:"fallback",error,headingTree}}let sanitized;try{const result=deps.DOMPurify.sanitize(rawHtml,{ADD_ATTR:["target"],FORBID_ATTR:["style"],...options.math?{ADD_TAGS:["semantics","annotation"]}:{}});if(typeof result!="string")throw new TypeError("The HTML sanitizer returned non-string markup.");sanitized=enforceMarkdownAnchorRelGuard(restoreMarkdownHighlightStyles(result))}catch(error){return warnMarkdownSanitizerUnavailable(),{status:"fallback",error,headingTree}}return{status:"rendered",html:sanitized,headingTree,mathFailed,pendingKeys}}function markdownMathPeerError(tag){return new Error(`<${tag}> needs the optional peer dependency \`katex\` to render math (the \`math\` property is set) — install it with \`pnpm add katex\`.`)}function applyMarkdownAriaBusy(host,busy){busy?host.setAttribute("aria-busy","true"):host.removeAttribute("aria-busy")}function markdownScrollBehavior(root){const view=root.ownerDocument.defaultView;return!view||prefersReducedMotion(view)?"auto":"smooth"}function applyMarkdownFragmentAnchor(root,anchor,headingTree){if(!anchor.id)return!1;let index=-1;const headingLimit=Math.min(headingTree.length,TEXT_QUOTE_LIMITS.maxTraversalNodes);for(let headingIndex2=0;headingIndex2<headingLimit;headingIndex2++)if(headingTree[headingIndex2]?.id===anchor.id){index=headingIndex2;break}if(index<0)return!1;const walker=root.ownerDocument.createTreeWalker(root,1);let inspected=0,headingIndex=0,escapedIdMatch=null,positionalMatch=null,node;for(;inspected<TEXT_QUOTE_LIMITS.maxTraversalNodes&&(node=walker.nextNode());){inspected++;const candidate=node;if(candidate.getAttribute("id")===anchor.id&&(escapedIdMatch??=candidate),/^H[1-6]$/.test(candidate.tagName)&&(headingIndex===index&&(positionalMatch=candidate),headingIndex++),escapedIdMatch&&positionalMatch)break}const el=escapedIdMatch??positionalMatch;return el?(el.scrollIntoView({behavior:markdownScrollBehavior(root),block:"start"}),!0):!1}function applyMarkdownTextQuoteAnchor(root,anchor,locale,index=createTextQuoteIndex(scopeFromElement(root),locale)){const match=index.resolve(anchor),range=match?rangeFromTextQuoteMatch(index.scope,match):null;return range?(((range.startContainer.nodeType===1?range.startContainer:range.startContainer.parentElement)??root).scrollIntoView({behavior:markdownScrollBehavior(root),block:"center"}),!0):!1}const HIGHLIGHT_TONES=["accent","success","warning","danger","neutral"],MARKDOWN_PAINTED_HIGHLIGHT_LIMIT=100;function repaintMarkdownHighlights(options){const resolved=[],rangesByTone=new Map(HIGHLIGHT_TONES.map(tone=>[tone,[]]));let activeRange=null;const workBudget=options.index.createWorkBudget(),matches=[];for(const highlight of prioritizedHighlightCandidates(options.highlights,options.activeHighlightId)){if(matches.length>=MARKDOWN_PAINTED_HIGHLIGHT_LIMIT)break;if(highlight.anchor.kind!=="text-quote")continue;const match=options.index.resolve(highlight.anchor,workBudget);match&&matches.push({highlight,match})}const ranges=rangesFromTextQuoteMatches(options.index.scope,matches.map(({match})=>match));for(let position=0;position<matches.length;position++){const{highlight}=matches[position],range=ranges[position]??null;range&&(rangesByTone.get(highlight.tone??"accent").push(range),resolved.push({id:highlight.id,range}),highlight.id===options.activeHighlightId&&(activeRange=range))}for(const[tone,ranges2]of rangesByTone)options.handle.setRanges(tone,ranges2);if(options.handle.setActive(activeRange),!supportsCustomHighlights(options.root.ownerDocument)){const walker=options.root.ownerDocument.createTreeWalker(options.root,1);let inspected=0,node;for(;inspected<TEXT_QUOTE_LIMITS.maxTraversalNodes+MARKDOWN_PAINTED_HIGHLIGHT_LIMIT&&(node=walker.nextNode());){inspected++;const mark=node;mark.localName==="mark"&&mark.hasAttribute("data-lr-highlight-tone")&&!mark.hasAttribute("part")&&mark.setAttribute("part","highlight")}}return resolved}function hitTestHighlightRanges(ranges,x,y){let remainingRects=TEXT_SELECTION_RECT_LIMIT;for(let i=ranges.length-1;i>=0;i--){const hit=ranges[i];if(hit)for(const rect of hit.range.getClientRects()){if(remainingRects--<=0)return null;if(x>=rect.left&&x<=rect.right&&y>=rect.top&&y<=rect.bottom)return hit.id}}return null}const nativeElementGetAttribute=typeof Element>"u"?void 0:Element.prototype.getAttribute,nativeAnchorHref=typeof HTMLAnchorElement>"u"?void 0:Object.getOwnPropertyDescriptor(HTMLAnchorElement.prototype,"href")?.get;function markdownAnchorFromTarget(target){if(!(typeof target!="object"&&typeof target!="function"||target===null)&&!(!nativeElementGetAttribute||!nativeAnchorHref))try{return nativeElementGetAttribute.call(target,"data-lr-brand-probe"),nativeAnchorHref.call(target),target}catch{return}}function nativeAnchorAttribute(anchor,name){try{const value=nativeElementGetAttribute?.call(anchor,name);return typeof value=="string"?value:void 0}catch{return}}function internalLinkHrefFrom(e,prefix){if(!prefix)return null;const anchor=e.composedPath().find(target=>markdownAnchorFromTarget(target)!==void 0);if(!anchor)return null;const href=nativeAnchorAttribute(anchor,"href")??"";return href.startsWith(prefix)?href:null}function renderMarkdownContent(options){const isFallback=options.renderedHtml===null,sanitizedMaxHeight=sanitizeCssLength(options.maxHeight);return html`
17
17
  <div
18
18
  part="content"
19
19
  role="document"
@@ -95,8 +95,10 @@ finalizePendingSubmit(submissionId:string):boolean;
95
95
  revertPendingSubmit(submissionId:string):boolean;
96
96
  /** Visually hides the bar until the enclosing message is hovered or any control inside has focus. */
97
97
  revealOnInteraction:boolean;
98
- /** Accessible name for the toolbar. Defaults to the localized `messageActionsLabel`. */
99
- label:string;
98
+ /** Accessible name for the toolbar. Omitting it localizes the default `messageActionsLabel`
99
+ * message; an explicit empty string (`label=""` or `.label = ''`) suppresses that default and
100
+ * renders no label. */
101
+ label?:string;
100
102
  /** Overrides the toolbar's computed accessible name. Wins over `label` and the localized
101
103
  * default. Attribute-reflects from a host-level `aria-label` so a plain-markup consumer gets
102
104
  * ARIA-name forwarding without setting a JS property. */
@@ -9,7 +9,7 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
9
9
  <path d="M12 20h9"></path>
10
10
  <path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4Z"></path>
11
11
  </svg>
12
- `}class LyraMessageActions extends LyraElement{constructor(){super(...arguments),this.controls=[],this.copyText="",this.feedbackRating=null,this.revealOnInteraction=!1,this.label="",this.accessibleLabel=null,this.activeStopIndex=0,this.revealed=!1,this.hoverTarget=null,this.stopSyncGeneration=0,this.managedStops=[],this.directActions=new WeakMap,this.nextDirectActionId=0,this.onHoverTargetEnter=()=>{this.revealed=!0},this.onHoverTargetLeave=()=>{this.matches(":focus-within")||(this.revealed=!1)},this.onFocusIn=event=>{this.revealed=!0;const stops=this.logicalActions(),path=event.composedPath(),index=stops.findIndex(({action})=>action.matchesEventPath(path));if(index>=0){this.setActiveStop(stops,index,stops[index]);const base=this.renderRoot.querySelector('[part="base"]'),repair=base?captureComposedFocusRepair(this,base):null,stop=stops[index];this.focusedStop=stop&&repair?{index,owner:stop.owner,id:stop.action.id,source:stop.source,repair}:void 0}else this.focusedStop=void 0},this.onFocusOut=event=>{this.hoverTarget?.matches(":hover")||(this.revealed=!1);const destination=event.relatedTarget;destination&&destination.nodeType===1&&!composedContains(this,destination)&&(this.focusedStop=void 0)},this.onStopMutations=records=>{this.reconcileStopsAfterChildren()},this.onSlotChange=()=>{const stops=this.logicalActions();this.setActiveStop(stops,Math.min(this.activeStopIndex,Math.max(0,stops.length-1))),this.reconcileStopsAfterChildren()},this.onToolbarActionsChange=event=>{event.stopPropagation(),this.reconcileStopsAfterChildren()},this.containSlottedFeedbackEvent=event=>{event.stopPropagation()},this.onToolbarKeyDown=e=>{const stops=this.logicalActions();if(stops.length===0)return;const path=e.composedPath(),originIndex=stops.findIndex(({action})=>action.matchesEventPath(path));if(originIndex<0&&path[0]!==e.currentTarget)return;const currentIndex=originIndex>=0?originIndex:this.activeStopIndex,forwardKey=this.effectiveDirection==="rtl"?"ArrowLeft":"ArrowRight",backwardKey=this.effectiveDirection==="rtl"?"ArrowRight":"ArrowLeft";let target;if(e.key===forwardKey)target=(currentIndex+1)%stops.length;else if(e.key===backwardKey)target=(currentIndex-1+stops.length)%stops.length;else if(e.key==="Home")target=0;else if(e.key==="End")target=stops.length-1;else return;e.preventDefault(),this.setActiveStop(stops,target),stops[target]?.action.focus()},this.onRegenerateClick=()=>{this.emit("lr-regenerate",null)},this.onEditClick=()=>{this.emit("lr-edit",null)}}static{this.defaultStrings={...super.defaultStrings,editMessage:LYRA_DEFAULT_editMessage,fieldRequired:LYRA_DEFAULT_fieldRequired,messageActionsLabel:LYRA_DEFAULT_messageActionsLabel,regenerateResponse:LYRA_DEFAULT_regenerateResponse}}static{this.ownedCollectionProperties=Object.freeze(["controls"])}static{this.styles=[LyraElement.styles,styles]}static{this.immutableEventDetails=Object.freeze(["lr-feedback-submit"])}get effectiveControls(){const seen=new Set,controls=[];for(const value of this.controls){if(typeof value!="string"||!MESSAGE_ACTION_CONTROLS.includes(value)||seen.has(value))continue;const control=value;seen.add(control),controls.push(control)}return controls}get feedbackPending(){return this.currentBuiltInFeedback()?.pending===!0}finalizePendingSubmit(submissionId){const feedback=this.currentBuiltInFeedback();return typeof submissionId=="string"&&submissionId.trim().length>0&&feedback!==void 0?feedback.finalizePendingSubmit(submissionId):!1}revertPendingSubmit(submissionId){const feedback=this.currentBuiltInFeedback();return typeof submissionId=="string"&&submissionId.trim().length>0&&feedback!==void 0?feedback.revertPendingSubmit(submissionId):!1}currentBuiltInFeedback(){const base=this.renderRoot.querySelector('[part="base"]'),feedback=base?.querySelector('lr-message-feedback[part~="feedback"]');return feedback&&feedback.parentElement===base&&feedback.getRootNode()===this.renderRoot&&feedback.isConnected?feedback:void 0}connectedCallback(){super.connectedCallback(),this.addEventListener("focusin",this.onFocusIn),this.addEventListener("focusout",this.onFocusOut),this.revealOnInteraction&&this.bindHoverTarget(),this.hasUpdated&&this.reconcileStopsAfterChildren()}disconnectedCallback(){this.stopSyncGeneration++,this.stopObserver?.disconnect(),this.stopObserver=void 0,this.releaseManagedStops(),this.focusedStop=void 0,this.unbindHoverTarget(),this.removeEventListener("focusin",this.onFocusIn),this.removeEventListener("focusout",this.onFocusOut),super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.stopSyncGeneration++,this.stopObserver?.disconnect(),this.stopObserver=void 0,this.releaseManagedStops()}willUpdate(changed){super.willUpdate(changed),changed.has("revealOnInteraction")&&(this.revealOnInteraction?this.bindHoverTarget():this.unbindHoverTarget())}firstUpdated(changed){super.firstUpdated(changed),this.setActiveStop(this.logicalActions(),0),this.reconcileStopsAfterChildren()}updated(changed){if(super.updated(changed),changed.has("controls")){const stops=this.logicalActions();this.setActiveStop(stops,Math.min(this.activeStopIndex,Math.max(0,stops.length-1))),this.reconcileStopsAfterChildren()}changed.has("revealed")&&this.toggleAttribute("data-revealed",this.revealed)}bindHoverTarget(){this.unbindHoverTarget();const target=this.closest("lr-chat-message")??this.parentElement;target&&(this.hoverTarget=target,target.addEventListener("pointerenter",this.onHoverTargetEnter),target.addEventListener("pointerleave",this.onHoverTargetLeave))}unbindHoverTarget(){this.hoverTarget?.removeEventListener("pointerenter",this.onHoverTargetEnter),this.hoverTarget?.removeEventListener("pointerleave",this.onHoverTargetLeave),this.hoverTarget=null,this.revealed=!1}actionRoots(){const base=this.renderRoot.querySelector('[part="base"]');if(!base)return[];const direct=[...base.children].filter(element=>element.localName!=="slot"),slot=base.querySelector("slot");return[...direct,...slot?.assignedElements({flatten:!0})??[]]}sameAction(left,right){return left.owner===right.owner&&left.source===right.source&&left.action.id===right.action.id}isAvailable(action){try{return action.disabled!==!0}catch{return!1}}directActionFor(element){let action=this.directActions.get(element);if(action)return action;const target=element,id=`direct-${++this.nextDirectActionId}`;let leasedTarget,leasedAuthoredTabIndex=null,lastManagedTabIndex=null,consumerOwnsTabIndex=!1;const releaseTabIndex=()=>{const leased=leasedTarget;leased&&leased.getAttribute("tabindex")===lastManagedTabIndex&&(leasedAuthoredTabIndex===null?leased.removeAttribute("tabindex"):leased.setAttribute("tabindex",leasedAuthoredTabIndex)),leasedTarget=void 0,leasedAuthoredTabIndex=null,lastManagedTabIndex=null,consumerOwnsTabIndex=!1};return action={id,get disabled(){return!isComposedFocusAvailable(element)},focus(options){target.focus(options)},setTabIndex(tabIndex){if(leasedTarget!==target&&(releaseTabIndex(),leasedTarget=target,leasedAuthoredTabIndex=target.getAttribute("tabindex")),consumerOwnsTabIndex||lastManagedTabIndex!==null&&target.getAttribute("tabindex")!==lastManagedTabIndex){consumerOwnsTabIndex=!0;return}target.tabIndex=tabIndex,lastManagedTabIndex=target.getAttribute("tabindex")},releaseTabIndex,hasAuthoredTabIndex(){return leasedTarget!==target?target.hasAttribute("tabindex"):lastManagedTabIndex!==null&&target.getAttribute("tabindex")===lastManagedTabIndex?leasedAuthoredTabIndex!==null:target.hasAttribute("tabindex")},matchesEventPath(path){return path.includes(element)}},this.directActions.set(element,action),action}logicalActions(){const actions=[],addProvider=(owner,provider)=>{const getToolbarActions=dataCallable(provider,"getToolbarActions");if(!getToolbarActions)return;let provided;try{provided=Reflect.apply(getToolbarActions,provider,[])}catch{return}let isArray=!1;try{isArray=Array.isArray(provided)}catch{return}if(!isArray)return;const length=getOwnDataDescriptor(provided,"length");if(length===MISSING_OWN_DATA_DESCRIPTOR||length===UNSAFE_OWN_DATA_DESCRIPTOR||typeof length.value!="number"||!Number.isSafeInteger(length.value)||length.value<0)return;const seen=new Set,inspected=Math.min(length.value,MAX_TOOLBAR_ACTIONS);for(let index=0;index<inspected;index+=1){const candidate=getOwnDataDescriptor(provided,String(index));if(candidate===MISSING_OWN_DATA_DESCRIPTOR||candidate===UNSAFE_OWN_DATA_DESCRIPTOR)continue;const projected=projectToolbarAction(candidate.value);!projected||seen.has(projected.action.id)||(seen.add(projected.action.id),this.isAvailable(projected.action)&&actions.push({owner,...projected}))}},visit=element=>{if(isLyraToolbarActionProvider(element)){addProvider(element,element);return}const knownAction=this.directActions.get(element);if(isSemanticActionElement(element)||(knownAction?.hasAuthoredTabIndex()??element.hasAttribute("tabindex"))){const action=this.directActionFor(element);this.isAvailable(action)&&actions.push({owner:element,action,source:action});return}for(const child of element.children)visit(child)};for(const root of this.actionRoots())visit(root);return actions}setActiveStop(stops,index,preferred){this.stopObserver?.disconnect();for(const previous of this.managedStops)stops.some(stop=>this.sameAction(stop,previous))||this.releaseManagedStop(previous);const preferredIndex=preferred?stops.findIndex(stop=>this.sameAction(stop,preferred)):-1;this.activeStopIndex=stops.length===0?0:preferredIndex>=0?preferredIndex:Math.min(Math.max(0,index),stops.length-1),stops.forEach(({action},stopIndex)=>{try{action.setTabIndex(stopIndex===this.activeStopIndex?0:-1)}catch{}}),this.managedStops=stops,this.observeStopChanges()}releaseManagedStop(stop){try{stop.action.releaseTabIndex?.()}catch{}this.directActions.get(stop.owner)===stop.action&&this.directActions.delete(stop.owner)}releaseManagedStops(){for(const stop of this.managedStops)this.releaseManagedStop(stop);this.managedStops=[]}observeStopChanges(){this.stopObserver?.disconnect();const Observer=this.ownerDocument.defaultView?.MutationObserver,base=this.renderRoot.querySelector('[part="base"]');if(!Observer||!base||!this.isConnected){this.stopObserver=void 0;return}const observer=new Observer(this.onStopMutations),roots=new Set([base,...this.actionRoots()]),options={attributes:!0,attributeOldValue:!0,attributeFilter:["aria-disabled","aria-hidden","contenteditable","controls","disabled","hidden","href","inert","open","role","tabindex","type"],childList:!0,subtree:!0};for(const root of roots)observer.observe(root,options);this.stopObserver=observer}async reconcileStopsAfterChildren(){const generation=++this.stopSyncGeneration,pending=this.actionRoots().map(root=>root.updateComplete).filter(value=>value!==void 0&&typeof value.then=="function");if(await Promise.all(pending),await Promise.resolve(),generation!==this.stopSyncGeneration||!this.isConnected)return;const stops=this.logicalActions(),focused=this.focusedStop,retainedIndex=focused?stops.findIndex(stop=>stop.owner===focused.owner&&stop.source===focused.source&&stop.action.id===focused.id):-1,targetIndex=retainedIndex>=0?retainedIndex:Math.min(focused?Math.max(0,focused.index):this.activeStopIndex,Math.max(0,stops.length-1));if(this.setActiveStop(stops,targetIndex),focused&&retainedIndex<0){const base=this.renderRoot.querySelector('[part="base"]');base&&applyComposedFocusRepair(focused.repair,base)&&stops[targetIndex]?.action.focus(),this.focusedStop===focused&&(this.focusedStop=void 0)}}renderControl(type){switch(type){case"copy":return this.copyText?html`<lr-copy-button
12
+ `}class LyraMessageActions extends LyraElement{constructor(){super(...arguments),this.controls=[],this.copyText="",this.feedbackRating=null,this.revealOnInteraction=!1,this.accessibleLabel=null,this.activeStopIndex=0,this.revealed=!1,this.hoverTarget=null,this.stopSyncGeneration=0,this.managedStops=[],this.directActions=new WeakMap,this.nextDirectActionId=0,this.onHoverTargetEnter=()=>{this.revealed=!0},this.onHoverTargetLeave=()=>{this.matches(":focus-within")||(this.revealed=!1)},this.onFocusIn=event=>{this.revealed=!0;const stops=this.logicalActions(),path=event.composedPath(),index=stops.findIndex(({action})=>action.matchesEventPath(path));if(index>=0){this.setActiveStop(stops,index,stops[index]);const base=this.renderRoot.querySelector('[part="base"]'),repair=base?captureComposedFocusRepair(this,base):null,stop=stops[index];this.focusedStop=stop&&repair?{index,owner:stop.owner,id:stop.action.id,source:stop.source,repair}:void 0}else this.focusedStop=void 0},this.onFocusOut=event=>{this.hoverTarget?.matches(":hover")||(this.revealed=!1);const destination=event.relatedTarget;destination&&destination.nodeType===1&&!composedContains(this,destination)&&(this.focusedStop=void 0)},this.onStopMutations=records=>{this.reconcileStopsAfterChildren()},this.onSlotChange=()=>{const stops=this.logicalActions();this.setActiveStop(stops,Math.min(this.activeStopIndex,Math.max(0,stops.length-1))),this.reconcileStopsAfterChildren()},this.onToolbarActionsChange=event=>{event.stopPropagation(),this.reconcileStopsAfterChildren()},this.containSlottedFeedbackEvent=event=>{event.stopPropagation()},this.onToolbarKeyDown=e=>{const stops=this.logicalActions();if(stops.length===0)return;const path=e.composedPath(),originIndex=stops.findIndex(({action})=>action.matchesEventPath(path));if(originIndex<0&&path[0]!==e.currentTarget)return;const currentIndex=originIndex>=0?originIndex:this.activeStopIndex,forwardKey=this.effectiveDirection==="rtl"?"ArrowLeft":"ArrowRight",backwardKey=this.effectiveDirection==="rtl"?"ArrowRight":"ArrowLeft";let target;if(e.key===forwardKey)target=(currentIndex+1)%stops.length;else if(e.key===backwardKey)target=(currentIndex-1+stops.length)%stops.length;else if(e.key==="Home")target=0;else if(e.key==="End")target=stops.length-1;else return;e.preventDefault(),this.setActiveStop(stops,target),stops[target]?.action.focus()},this.onRegenerateClick=()=>{this.emit("lr-regenerate",null)},this.onEditClick=()=>{this.emit("lr-edit",null)}}static{this.defaultStrings={...super.defaultStrings,editMessage:LYRA_DEFAULT_editMessage,fieldRequired:LYRA_DEFAULT_fieldRequired,messageActionsLabel:LYRA_DEFAULT_messageActionsLabel,regenerateResponse:LYRA_DEFAULT_regenerateResponse}}static{this.ownedCollectionProperties=Object.freeze(["controls"])}static{this.styles=[LyraElement.styles,styles]}static{this.immutableEventDetails=Object.freeze(["lr-feedback-submit"])}get effectiveControls(){const seen=new Set,controls=[];for(const value of this.controls){if(typeof value!="string"||!MESSAGE_ACTION_CONTROLS.includes(value)||seen.has(value))continue;const control=value;seen.add(control),controls.push(control)}return controls}get feedbackPending(){return this.currentBuiltInFeedback()?.pending===!0}finalizePendingSubmit(submissionId){const feedback=this.currentBuiltInFeedback();return typeof submissionId=="string"&&submissionId.trim().length>0&&feedback!==void 0?feedback.finalizePendingSubmit(submissionId):!1}revertPendingSubmit(submissionId){const feedback=this.currentBuiltInFeedback();return typeof submissionId=="string"&&submissionId.trim().length>0&&feedback!==void 0?feedback.revertPendingSubmit(submissionId):!1}currentBuiltInFeedback(){const base=this.renderRoot.querySelector('[part="base"]'),feedback=base?.querySelector('lr-message-feedback[part~="feedback"]');return feedback&&feedback.parentElement===base&&feedback.getRootNode()===this.renderRoot&&feedback.isConnected?feedback:void 0}connectedCallback(){super.connectedCallback(),this.addEventListener("focusin",this.onFocusIn),this.addEventListener("focusout",this.onFocusOut),this.revealOnInteraction&&this.bindHoverTarget(),this.hasUpdated&&this.reconcileStopsAfterChildren()}disconnectedCallback(){this.stopSyncGeneration++,this.stopObserver?.disconnect(),this.stopObserver=void 0,this.releaseManagedStops(),this.focusedStop=void 0,this.unbindHoverTarget(),this.removeEventListener("focusin",this.onFocusIn),this.removeEventListener("focusout",this.onFocusOut),super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.stopSyncGeneration++,this.stopObserver?.disconnect(),this.stopObserver=void 0,this.releaseManagedStops()}willUpdate(changed){super.willUpdate(changed),changed.has("revealOnInteraction")&&(this.revealOnInteraction?this.bindHoverTarget():this.unbindHoverTarget())}firstUpdated(changed){super.firstUpdated(changed),this.setActiveStop(this.logicalActions(),0),this.reconcileStopsAfterChildren()}updated(changed){if(super.updated(changed),changed.has("controls")){const stops=this.logicalActions();this.setActiveStop(stops,Math.min(this.activeStopIndex,Math.max(0,stops.length-1))),this.reconcileStopsAfterChildren()}changed.has("revealed")&&this.toggleAttribute("data-revealed",this.revealed)}bindHoverTarget(){this.unbindHoverTarget();const target=this.closest("lr-chat-message")??this.parentElement;target&&(this.hoverTarget=target,target.addEventListener("pointerenter",this.onHoverTargetEnter),target.addEventListener("pointerleave",this.onHoverTargetLeave))}unbindHoverTarget(){this.hoverTarget?.removeEventListener("pointerenter",this.onHoverTargetEnter),this.hoverTarget?.removeEventListener("pointerleave",this.onHoverTargetLeave),this.hoverTarget=null,this.revealed=!1}actionRoots(){const base=this.renderRoot.querySelector('[part="base"]');if(!base)return[];const direct=[...base.children].filter(element=>element.localName!=="slot"),slot=base.querySelector("slot");return[...direct,...slot?.assignedElements({flatten:!0})??[]]}sameAction(left,right){return left.owner===right.owner&&left.source===right.source&&left.action.id===right.action.id}isAvailable(action){try{return action.disabled!==!0}catch{return!1}}directActionFor(element){let action=this.directActions.get(element);if(action)return action;const target=element,id=`direct-${++this.nextDirectActionId}`;let leasedTarget,leasedAuthoredTabIndex=null,lastManagedTabIndex=null,consumerOwnsTabIndex=!1;const releaseTabIndex=()=>{const leased=leasedTarget;leased&&leased.getAttribute("tabindex")===lastManagedTabIndex&&(leasedAuthoredTabIndex===null?leased.removeAttribute("tabindex"):leased.setAttribute("tabindex",leasedAuthoredTabIndex)),leasedTarget=void 0,leasedAuthoredTabIndex=null,lastManagedTabIndex=null,consumerOwnsTabIndex=!1};return action={id,get disabled(){return!isComposedFocusAvailable(element)},focus(options){target.focus(options)},setTabIndex(tabIndex){if(leasedTarget!==target&&(releaseTabIndex(),leasedTarget=target,leasedAuthoredTabIndex=target.getAttribute("tabindex")),consumerOwnsTabIndex||lastManagedTabIndex!==null&&target.getAttribute("tabindex")!==lastManagedTabIndex){consumerOwnsTabIndex=!0;return}target.tabIndex=tabIndex,lastManagedTabIndex=target.getAttribute("tabindex")},releaseTabIndex,hasAuthoredTabIndex(){return leasedTarget!==target?target.hasAttribute("tabindex"):lastManagedTabIndex!==null&&target.getAttribute("tabindex")===lastManagedTabIndex?leasedAuthoredTabIndex!==null:target.hasAttribute("tabindex")},matchesEventPath(path){return path.includes(element)}},this.directActions.set(element,action),action}logicalActions(){const actions=[],addProvider=(owner,provider)=>{const getToolbarActions=dataCallable(provider,"getToolbarActions");if(!getToolbarActions)return;let provided;try{provided=Reflect.apply(getToolbarActions,provider,[])}catch{return}let isArray=!1;try{isArray=Array.isArray(provided)}catch{return}if(!isArray)return;const length=getOwnDataDescriptor(provided,"length");if(length===MISSING_OWN_DATA_DESCRIPTOR||length===UNSAFE_OWN_DATA_DESCRIPTOR||typeof length.value!="number"||!Number.isSafeInteger(length.value)||length.value<0)return;const seen=new Set,inspected=Math.min(length.value,MAX_TOOLBAR_ACTIONS);for(let index=0;index<inspected;index+=1){const candidate=getOwnDataDescriptor(provided,String(index));if(candidate===MISSING_OWN_DATA_DESCRIPTOR||candidate===UNSAFE_OWN_DATA_DESCRIPTOR)continue;const projected=projectToolbarAction(candidate.value);!projected||seen.has(projected.action.id)||(seen.add(projected.action.id),this.isAvailable(projected.action)&&actions.push({owner,...projected}))}},visit=element=>{if(isLyraToolbarActionProvider(element)){addProvider(element,element);return}const knownAction=this.directActions.get(element);if(isSemanticActionElement(element)||(knownAction?.hasAuthoredTabIndex()??element.hasAttribute("tabindex"))){const action=this.directActionFor(element);this.isAvailable(action)&&actions.push({owner:element,action,source:action});return}for(const child of element.children)visit(child)};for(const root of this.actionRoots())visit(root);return actions}setActiveStop(stops,index,preferred){this.stopObserver?.disconnect();for(const previous of this.managedStops)stops.some(stop=>this.sameAction(stop,previous))||this.releaseManagedStop(previous);const preferredIndex=preferred?stops.findIndex(stop=>this.sameAction(stop,preferred)):-1;this.activeStopIndex=stops.length===0?0:preferredIndex>=0?preferredIndex:Math.min(Math.max(0,index),stops.length-1),stops.forEach(({action},stopIndex)=>{try{action.setTabIndex(stopIndex===this.activeStopIndex?0:-1)}catch{}}),this.managedStops=stops,this.observeStopChanges()}releaseManagedStop(stop){try{stop.action.releaseTabIndex?.()}catch{}this.directActions.get(stop.owner)===stop.action&&this.directActions.delete(stop.owner)}releaseManagedStops(){for(const stop of this.managedStops)this.releaseManagedStop(stop);this.managedStops=[]}observeStopChanges(){this.stopObserver?.disconnect();const Observer=this.ownerDocument.defaultView?.MutationObserver,base=this.renderRoot.querySelector('[part="base"]');if(!Observer||!base||!this.isConnected){this.stopObserver=void 0;return}const observer=new Observer(this.onStopMutations),roots=new Set([base,...this.actionRoots()]),options={attributes:!0,attributeOldValue:!0,attributeFilter:["aria-disabled","aria-hidden","contenteditable","controls","disabled","hidden","href","inert","open","role","tabindex","type"],childList:!0,subtree:!0};for(const root of roots)observer.observe(root,options);this.stopObserver=observer}async reconcileStopsAfterChildren(){const generation=++this.stopSyncGeneration,pending=this.actionRoots().map(root=>root.updateComplete).filter(value=>value!==void 0&&typeof value.then=="function");if(await Promise.all(pending),await Promise.resolve(),generation!==this.stopSyncGeneration||!this.isConnected)return;const stops=this.logicalActions(),focused=this.focusedStop,retainedIndex=focused?stops.findIndex(stop=>stop.owner===focused.owner&&stop.source===focused.source&&stop.action.id===focused.id):-1,targetIndex=retainedIndex>=0?retainedIndex:Math.min(focused?Math.max(0,focused.index):this.activeStopIndex,Math.max(0,stops.length-1));if(this.setActiveStop(stops,targetIndex),focused&&retainedIndex<0){const base=this.renderRoot.querySelector('[part="base"]');base&&applyComposedFocusRepair(focused.repair,base)&&stops[targetIndex]?.action.focus(),this.focusedStop===focused&&(this.focusedStop=void 0)}}renderControl(type){switch(type){case"copy":return this.copyText?html`<lr-copy-button
13
13
  part="copy-button"
14
14
  .value=${this.copyText}
15
15
  ></lr-copy-button>`:nothing;case"regenerate":return html`<lr-icon-button
@@ -30,7 +30,7 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
30
30
  part="feedback"
31
31
  .rating=${this.feedbackRating}
32
32
  @lr-toolbar-actions-change=${this.onToolbarActionsChange}
33
- ></lr-message-feedback>`;default:return nothing}}render(){const label=this.accessibleLabel??(this.label||this.localize("messageActionsLabel"));return html`
33
+ ></lr-message-feedback>`;default:return nothing}}render(){const label=this.accessibleLabel??(this.label==null?this.localize("messageActionsLabel"):this.label);return html`
34
34
  <div
35
35
  part="base"
36
36
  role="toolbar"
@@ -1,4 +1,17 @@
1
- import type{LyraEventDetailSnapshot}from'../../../internal/lyra-element.js';import{type PropertyValues,type TemplateResult}from'lit';import type{CitationSelectEventDetail,MessagePart}from'../../../ai/types.js';import type{LyraThinkingPanelEventMap}from'../../agent-tools/thinking-panel/thinking-panel.class.js';import type{LyraToolCallChipEventMap}from'../../agent-tools/tool-call-chip/tool-call-chip.class.js';import type{LyraToolResultViewEventMap}from'../../agent-tools/tool-result-view/tool-result-view.class.js';import type{LyraAttachmentChipEventMap}from'../../media/attachment-chip/attachment-chip.class.js';import type{LyraCitationBadgeEventMap}from'../../retrieval/citation-badge/citation-badge.class.js';import type{LyraJsonViewerEventMap}from'../../utility/json-viewer/json-viewer.class.js';import{LyraElement}from'../../../internal/lyra-element.js';import type{LyraMarkdownEventMap}from'../markdown/markdown.class.js';import type{LyraWidgetRendererEventMap}from'../widget-renderer/widget-renderer.class.js';export type MessagePartRenderer=(part:MessagePart,index:number)=>unknown;
1
+ import type{LyraEventDetailSnapshot}from'../../../internal/lyra-element.js';import{type PropertyValues,type TemplateResult}from'lit';import type{CitationSelectEventDetail,MessagePart}from'../../../ai/types.js';import type{LyraThinkingPanelEventMap}from'../../agent-tools/thinking-panel/thinking-panel.class.js';import type{LyraToolCallChipEventMap}from'../../agent-tools/tool-call-chip/tool-call-chip.class.js';import type{LyraToolResultViewEventMap}from'../../agent-tools/tool-result-view/tool-result-view.class.js';import type{LyraAttachmentChipEventMap}from'../../media/attachment-chip/attachment-chip.class.js';import type{LyraCitationBadgeEventMap}from'../../retrieval/citation-badge/citation-badge.class.js';import type{LyraJsonViewerEventMap}from'../../utility/json-viewer/json-viewer.class.js';import{LyraElement}from'../../../internal/lyra-element.js';import type{LyraMarkdownEventMap}from'../markdown/markdown.class.js';import type{LyraWidgetRendererEventMap}from'../widget-renderer/widget-renderer.class.js';
2
+ /**
3
+ * Host override for how one message part renders. Returning `undefined` delegates that part
4
+ * entirely to the built-in renderer, keeping every built-in affordance intact. Returning any other
5
+ * value fully REPLACES the built-in rendering for that part -- not just its visual content but
6
+ * every interactive affordance and event the built-in renderer would otherwise wire up for that
7
+ * part type: the `error` part's retry button (`lr-part-retry`), a `citation` part's activation
8
+ * (`lr-citation-select`), and the composed children's own events for `tool-call`
9
+ * (`<lr-tool-call-chip>`'s `lr-tool-call-chip-select`), `tool-result`/`attachment`
10
+ * (`<lr-tool-result-view>`/`<lr-attachment-chip>`'s preview surface) and `data`
11
+ * (`<lr-widget-renderer>`'s `lr-widget-action`/`lr-widget-state-change`). A host overriding an
12
+ * interactive part type must reimplement whatever of that interaction it still wants.
13
+ */
14
+ export type MessagePartRenderer=(part:MessagePart,index:number)=>unknown;
2
15
  /** Rendering mode for text and reasoning message parts. */
3
16
  export type MessagePartsContentMode='plain'|'markdown';export interface LyraMessagePartsEventMap extends Omit<LyraMarkdownEventMap,'lr-render-error'>,LyraThinkingPanelEventMap,LyraToolCallChipEventMap,Omit<LyraToolResultViewEventMap,'lr-render-error'>,LyraAttachmentChipEventMap,Omit<LyraCitationBadgeEventMap,'lr-citation-activate'>,LyraJsonViewerEventMap,Omit<LyraWidgetRendererEventMap,'lr-render-error'>{'lr-citation-select':CustomEvent<LyraEventDetailSnapshot<CitationSelectEventDetail>>;'lr-part-retry':CustomEvent<LyraEventDetailSnapshot<{part:MessagePart;}>>;'lr-render-error':CustomEvent<{error:unknown;}|{toolName:string;error:unknown;}>;}
4
17
  /**
@@ -69,7 +82,9 @@ parts:readonly MessagePart[];private contentModeValue;
69
82
  get contentMode():MessagePartsContentMode;set contentMode(value:MessagePartsContentMode);
70
83
  /** Include reasoning parts. */
71
84
  showReasoning:boolean;
72
- /** Optional host renderer. Returning `undefined` delegates to the built-in renderer. */
85
+ /** Optional host renderer; see `MessagePartRenderer` for the full contract. Returning `undefined`
86
+ * delegates to the built-in renderer -- any other return fully replaces it, including that
87
+ * part's own interactive wiring (retry/citation/tool-call/widget events). */
73
88
  renderPart?:MessagePartRenderer;
74
89
  /** `0` (the default) renders every part -- unbounded, matching every prior release. A positive
75
90
  * value windows rendering to the newest N parts (host `parts` data is untouched); citation
@@ -14,6 +14,7 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
14
14
  </div>`})}renderListbox(rows,activeId,emptyText){return html`
15
15
  <div
16
16
  part="listbox"
17
+ ?hidden=${this.catalogPicker.listboxHidden}
17
18
  id=${this.listId}
18
19
  role="listbox"
19
20
  @mousedown=${this.onListboxMouseDown}
@@ -1 +1 @@
1
- import{css}from"lit";import{formControlRequiredMarker}from"../../../internal/form-control.styles.js";import{overlaySurfaceFill}from"../../../internal/overlay-surface.styles.js";const styles=css` :host { position: relative; display: inline-block; inline-size: 100%; min-inline-size: 0; max-inline-size: var(--lr-model-select-max-inline-size, var(--lr-size-24rem)); --_lr-model-select-trigger-padding: var(--lr-form-control-padding-block) var(--lr-form-control-padding-inline); --_lr-model-select-trigger-min-height: var(--lr-form-control-height); --_lr-model-select-font-size: var(--lr-form-control-font-size); --_lr-model-select-expand-size: var(--lr-size-1-75rem); --_lr-model-select-gap-default: var(--lr-space-xs); --_lr-model-select-radius-default: var(--lr-radius); } :host(:disabled) { cursor: not-allowed; } :host([size="2xs"]), :host([size="xs"]) { --_lr-model-select-expand-size: var(--lr-size-1rem); } :host([size="s"]), :host([size="small"]) { --_lr-model-select-expand-size: var(--lr-size-1-25rem); } [part="form-control-label"] { display: block; margin-block-end: var(--lr-space-xs); font-size: var(--lr-font-size-md-sm); font-weight: var(--lr-font-weight-semibold); } [part="form-control-label"][hidden] { display: none; } ${formControlRequiredMarker} [part='trigger'], [part='combobox'] { display: flex; align-items: center; gap: var(--lr-model-select-gap, var(--_lr-model-select-gap-default)); inline-size: 100%; min-inline-size: 0; min-block-size: var( --lr-model-select-trigger-height, var( --lr-model-select-trigger-min-height, var(--_lr-model-select-trigger-min-height) ) ); block-size: var(--lr-model-select-trigger-height, auto); box-sizing: border-box; padding: var( --lr-model-select-trigger-padding, var(--_lr-model-select-trigger-padding) ); border: var(--lr-border-width-thin) solid var(--lr-model-select-trigger-border-color, var(--lr-color-border)); border-radius: var( --lr-model-select-radius, var(--_lr-model-select-radius-default) ); background: var(--lr-model-select-trigger-fill, var(--lr-color-surface)); color: inherit; font: inherit; font-size: var( --lr-model-select-font-size, var(--_lr-model-select-font-size) ); } [part="trigger"] { cursor: pointer; text-align: start; } [part="combobox"] { cursor: text; } [part="trigger"]:focus-visible, [part="combobox"]:focus-within { outline: var(--lr-focus-ring-width) solid var(--lr-focus-ring-color); outline-offset: var(--lr-focus-ring-offset); } :where([part="trigger"]):hover:where(:not(:disabled)) { background: var(--lr-color-brand-quiet); } :where([part="trigger"]):active:where(:not(:disabled)) { background: color-mix( in oklab, var(--lr-color-brand-quiet), var(--lr-color-mix-partner) var(--lr-color-mix-active) ); } :host([open]) [part="trigger"] { border-color: var( --lr-model-select-open-border-color, var(--lr-color-brand) ); } :host(:disabled) [part="trigger"], :host(:disabled) [part="combobox"] { opacity: var(--lr-opacity-disabled); cursor: not-allowed; } [part="provider-badge"] { flex: 0 1 auto; min-inline-size: 0; max-inline-size: 40%; overflow: hidden; text-overflow: ellipsis; padding-inline-end: var(--lr-space-xs); margin-inline-end: var(--lr-space-xs); border-inline-end: var(--lr-border-width-thin) solid var(--lr-color-border); font-size: var(--lr-size-0-6875rem); font-weight: var(--lr-font-weight-bold); text-transform: uppercase; letter-spacing: var(--lr-size-0-04em); color: var(--lr-color-text-quiet); white-space: nowrap; } .trigger-label { flex: 1 1 auto; min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .trigger-label[data-placeholder] { color: var(--lr-color-text-quiet); } [part="combobox-input"] { flex: 1 1 auto; min-inline-size: 0; border: none; outline: none; background: transparent; color: inherit; font: inherit; } [part="combobox-input"]::placeholder { color: var(--lr-color-text-quiet); } [part="expand-icon"] { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; color: var(--lr-color-text-quiet); min-inline-size: min( var(--lr-icon-button-size), var(--lr-model-select-expand-size, var(--_lr-model-select-expand-size)) ); min-block-size: min( var(--lr-icon-button-size), var(--lr-model-select-expand-size, var(--_lr-model-select-expand-size)) ); line-height: var(--lr-line-height-none); } [part="expand-icon"] svg { transform: rotate(90deg); } [part="listbox"] { position: fixed; z-index: var(--lr-layer-dropdown); box-sizing: border-box; max-block-size: var(--lr-size-18rem); overflow-y: auto; overflow-x: hidden; inline-size: max-content; min-inline-size: var(--lr-size-12rem); max-inline-size: min( var(--lr-popover-viewport-clamp), var(--lr-size-28rem) ); padding: var(--lr-space-xs); ${overlaySurfaceFill} border-radius: var( --lr-model-select-radius, var(--lr-overlay-radius, var(--_lr-model-select-radius-default)) ); box-shadow: var(--lr-overlay-shadow-anchored, var(--lr-shadow-m)); visibility: hidden; opacity: 0; transform: translateY(var(--lr-size-neg-0-25rem)); transition: opacity var(--lr-transition-fast), transform var(--lr-transition-fast), visibility var(--lr-transition-fast); } :host([open]) [part="listbox"] { visibility: visible; opacity: 1; transform: translateY(0); } @media (prefers-reduced-motion: reduce) { [part="listbox"] { transition: none !important; } } [part="option"] { display: flex; align-items: center; gap: var(--lr-model-select-gap, var(--_lr-model-select-gap-default)); inline-size: 100%; box-sizing: border-box; padding: var(--lr-space-xs) var(--lr-space-s); border: var(--lr-border-width-thin) solid transparent; border-radius: var( --lr-model-select-radius, var(--_lr-model-select-radius-default) ); background: none; color: inherit; font: inherit; text-align: start; cursor: pointer; } [part="option"][aria-selected="true"] { background: var(--lr-model-select-option-selected-bg, transparent); border-color: var( --lr-model-select-option-selected-border, var(--lr-color-brand) ); color: var(--lr-model-select-option-selected-color, var(--lr-color-brand)); font-weight: var( --lr-model-select-option-selected-font-weight, var(--lr-font-weight-semibold) ); } [part="option"]:where(:not([aria-disabled='true'])):hover, [part="option"][data-active] { background: var( --lr-model-select-option-active-bg, var(--lr-color-brand-quiet) ); } [part="option"]:where(:not([aria-disabled='true'])):active { background: color-mix( in oklab, var(--lr-model-select-option-active-bg, var(--lr-color-brand-quiet)), var(--lr-color-mix-partner) var(--lr-color-mix-active) ); } [part="option"][aria-disabled='true'] { cursor: default; opacity: var(--lr-model-select-option-disabled-opacity, 0.5); } [part="option-icon"] { flex: 0 0 auto; line-height: var(--lr-line-height-1-4); } [part="option-label"] { flex: 1 1 auto; min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } [part="option"][data-synthetic] { border-style: var(--lr-model-select-option-synthetic-border-style, dashed); border-color: var( --lr-model-select-option-synthetic-border-color, var(--lr-color-border) ); } [part="option"][data-synthetic] [part="option-label"] { font-style: italic; } [part="option-badge"] { flex: 0 0 auto; font-size: var(--lr-size-0-6875rem); font-style: normal; font-weight: var(--lr-font-weight-normal); color: var(--lr-color-text-quiet); white-space: nowrap; } [part="empty"] { padding: var(--lr-space-m); color: var(--lr-color-text-quiet); font-size: var(--lr-font-size-md-sm); } [part="hint"] { margin-block-start: var(--lr-space-xs); font-size: var(--lr-font-size-sm); color: var(--lr-color-text-quiet); } [part="hint"][hidden] { display: none; } [part="error"] { margin-block-start: var(--lr-space-xs); font-size: var(--lr-font-size-sm); color: var(--lr-color-danger); } [part="error"][hidden] { display: none; } `;export{styles};
1
+ import{css}from"lit";import{formControlRequiredMarker}from"../../../internal/form-control.styles.js";import{overlaySurfaceFill}from"../../../internal/overlay-surface.styles.js";const styles=css` :host { position: relative; display: inline-block; inline-size: 100%; min-inline-size: 0; max-inline-size: var(--lr-model-select-max-inline-size, var(--lr-size-24rem)); --_lr-model-select-trigger-padding: var(--lr-form-control-padding-block) var(--lr-form-control-padding-inline); --_lr-model-select-trigger-min-height: var(--lr-form-control-height); --_lr-model-select-font-size: var(--lr-form-control-font-size); --_lr-model-select-expand-size: var(--lr-size-1-75rem); --_lr-model-select-gap-default: var(--lr-space-xs); --_lr-model-select-radius-default: var(--lr-radius); } :host(:disabled) { cursor: not-allowed; } :host([size="2xs"]), :host([size="xs"]) { --_lr-model-select-expand-size: var(--lr-size-1rem); } :host([size="s"]), :host([size="small"]) { --_lr-model-select-expand-size: var(--lr-size-1-25rem); } [part="form-control-label"] { display: block; margin-block-end: var(--lr-space-xs); font-size: var(--lr-font-size-md-sm); font-weight: var(--lr-font-weight-semibold); } [part="form-control-label"][hidden] { display: none; } ${formControlRequiredMarker} [part='trigger'], [part='combobox'] { display: flex; align-items: center; gap: var(--lr-model-select-gap, var(--_lr-model-select-gap-default)); inline-size: 100%; min-inline-size: 0; min-block-size: var( --lr-model-select-trigger-height, var( --lr-model-select-trigger-min-height, var(--_lr-model-select-trigger-min-height) ) ); block-size: var(--lr-model-select-trigger-height, auto); box-sizing: border-box; padding: var( --lr-model-select-trigger-padding, var(--_lr-model-select-trigger-padding) ); border: var(--lr-border-width-thin) solid var(--lr-model-select-trigger-border-color, var(--lr-color-border)); border-radius: var( --lr-model-select-radius, var(--_lr-model-select-radius-default) ); background: var(--lr-model-select-trigger-fill, var(--lr-color-surface)); color: inherit; font: inherit; font-size: var( --lr-model-select-font-size, var(--_lr-model-select-font-size) ); } [part="trigger"] { cursor: pointer; text-align: start; } [part="combobox"] { cursor: text; } [part="trigger"]:focus-visible, [part="combobox"]:focus-within { outline: var(--lr-focus-ring-width) solid var(--lr-focus-ring-color); outline-offset: var(--lr-focus-ring-offset); } :where([part="trigger"]):hover:where(:not(:disabled)) { background: var(--lr-color-brand-quiet); } :where([part="trigger"]):active:where(:not(:disabled)) { background: color-mix( in oklab, var(--lr-color-brand-quiet), var(--lr-color-mix-partner) var(--lr-color-mix-active) ); } :host([open]) [part="trigger"] { border-color: var( --lr-model-select-open-border-color, var(--lr-color-brand) ); } :host(:disabled) [part="trigger"], :host(:disabled) [part="combobox"] { opacity: var(--lr-opacity-disabled); cursor: not-allowed; } [part="provider-badge"] { flex: 0 1 auto; min-inline-size: 0; max-inline-size: 40%; overflow: hidden; text-overflow: ellipsis; padding-inline-end: var(--lr-space-xs); margin-inline-end: var(--lr-space-xs); border-inline-end: var(--lr-border-width-thin) solid var(--lr-color-border); font-size: var(--lr-size-0-6875rem); font-weight: var(--lr-font-weight-bold); text-transform: uppercase; letter-spacing: var(--lr-size-0-04em); color: var(--lr-color-text-quiet); white-space: nowrap; } .trigger-label { flex: 1 1 auto; min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .trigger-label[data-placeholder] { color: var(--lr-color-text-quiet); } [part="combobox-input"] { flex: 1 1 auto; min-inline-size: 0; border: none; outline: none; background: transparent; color: inherit; font: inherit; } [part="combobox-input"]::placeholder { color: var(--lr-color-text-quiet); } [part="expand-icon"] { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; color: var(--lr-color-text-quiet); min-inline-size: min( var(--lr-icon-button-size), var(--lr-model-select-expand-size, var(--_lr-model-select-expand-size)) ); min-block-size: min( var(--lr-icon-button-size), var(--lr-model-select-expand-size, var(--_lr-model-select-expand-size)) ); line-height: var(--lr-line-height-none); } [part="expand-icon"] svg { transform: rotate(90deg); } [part="listbox"][hidden] { display: none; } [part="listbox"] { position: fixed; z-index: var(--lr-layer-dropdown); box-sizing: border-box; max-block-size: var(--lr-size-18rem); overflow-y: auto; overflow-x: hidden; inline-size: max-content; min-inline-size: var(--lr-size-12rem); max-inline-size: min( var(--lr-popover-viewport-clamp), var(--lr-size-28rem) ); padding: var(--lr-space-xs); ${overlaySurfaceFill} border-radius: var( --lr-model-select-radius, var(--lr-overlay-radius, var(--_lr-model-select-radius-default)) ); box-shadow: var(--lr-overlay-shadow-anchored, var(--lr-shadow-m)); visibility: hidden; opacity: 0; transform: translateY(var(--lr-size-neg-0-25rem)); transition: opacity var(--lr-transition-fast), transform var(--lr-transition-fast), visibility var(--lr-transition-fast); } :host([open]) [part="listbox"] { visibility: visible; opacity: 1; transform: translateY(0); } @media (prefers-reduced-motion: reduce) { [part="listbox"] { transition: none !important; } } [part="option"] { display: flex; align-items: center; gap: var(--lr-model-select-gap, var(--_lr-model-select-gap-default)); inline-size: 100%; box-sizing: border-box; padding: var(--lr-space-xs) var(--lr-space-s); border: var(--lr-border-width-thin) solid transparent; border-radius: var( --lr-model-select-radius, var(--_lr-model-select-radius-default) ); background: none; color: inherit; font: inherit; text-align: start; cursor: pointer; } [part="option"][aria-selected="true"] { background: var(--lr-model-select-option-selected-bg, transparent); border-color: var( --lr-model-select-option-selected-border, var(--lr-color-brand) ); color: var(--lr-model-select-option-selected-color, var(--lr-color-brand)); font-weight: var( --lr-model-select-option-selected-font-weight, var(--lr-font-weight-semibold) ); } [part="option"]:where(:not([aria-disabled='true'])):hover, [part="option"][data-active] { background: var( --lr-model-select-option-active-bg, var(--lr-color-brand-quiet) ); } [part="option"]:where(:not([aria-disabled='true'])):active { background: color-mix( in oklab, var(--lr-model-select-option-active-bg, var(--lr-color-brand-quiet)), var(--lr-color-mix-partner) var(--lr-color-mix-active) ); } [part="option"][aria-disabled='true'] { cursor: default; opacity: var(--lr-model-select-option-disabled-opacity, 0.5); } [part="option-icon"] { flex: 0 0 auto; line-height: var(--lr-line-height-1-4); } [part="option-label"] { flex: 1 1 auto; min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } [part="option"][data-synthetic] { border-style: var(--lr-model-select-option-synthetic-border-style, dashed); border-color: var( --lr-model-select-option-synthetic-border-color, var(--lr-color-border) ); } [part="option"][data-synthetic] [part="option-label"] { font-style: italic; } [part="option-badge"] { flex: 0 0 auto; font-size: var(--lr-size-0-6875rem); font-style: normal; font-weight: var(--lr-font-weight-normal); color: var(--lr-color-text-quiet); white-space: nowrap; } [part="empty"] { padding: var(--lr-space-m); color: var(--lr-color-text-quiet); font-size: var(--lr-font-size-md-sm); } [part="hint"] { margin-block-start: var(--lr-space-xs); font-size: var(--lr-font-size-sm); color: var(--lr-color-text-quiet); } [part="hint"][hidden] { display: none; } [part="error"] { margin-block-start: var(--lr-space-xs); font-size: var(--lr-font-size-sm); color: var(--lr-color-danger); } [part="error"][hidden] { display: none; } `;export{styles};
@@ -99,7 +99,11 @@ sources:readonly LyraSourceEntry[];
99
99
  selectedSourceIds:readonly string[];
100
100
  /** Queued prompts keyed by unique nonblank `id`; malformed and later duplicate rows are omitted
101
101
  * before section gating or forwarding. */
102
- queue:readonly PromptQueueItem[];label:string;accessibleLabel:string|null;private activeSuggestion;private readonly slotPresence;private composer?;private suggestionPopover?;private suggestionAnchor?;private pendingSuggestionValue;private suggestionNavigationGeneration;focus(options?:FocusOptions):void;blur():void;click():void;
102
+ queue:readonly PromptQueueItem[];
103
+ /** Accessible name for the prompt section. Omitting it localizes the default
104
+ * `promptInputLabel` message; an explicit empty string (`label=""` or `.label = ''`)
105
+ * suppresses that default and renders no label. `accessibleLabel` wins over both. */
106
+ label?:string;accessibleLabel:string|null;private activeSuggestion;private readonly slotPresence;private composer?;private suggestionPopover?;private suggestionAnchor?;private pendingSuggestionValue;private suggestionNavigationGeneration;focus(options?:FocusOptions):void;blur():void;click():void;
103
107
  /** The composed native textarea, or `null` before it has rendered. */
104
108
  get input():HTMLTextAreaElement|null;get selectionStart():number|null;set selectionStart(value:number|null);get selectionEnd():number|null;set selectionEnd(value:number|null);get selectionDirection():ChatComposerSelectionDirection|null;set selectionDirection(value:ChatComposerSelectionDirection|null);select():void;
105
109
  /** Forwards the native selection range to the composed textarea; a pre-render call is a no-op. */
@@ -1,4 +1,4 @@
1
- var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};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{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{firstByRetrievalIdentity as firstByPromptIdentity}from"../../retrieval/retrieval-identity.js";import{normalizeChatComposerStatus}from"../chat-composer/chat-composer.class.js";import{styles}from"./prompt-input.styles.js";import{LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_promptInputAttachments,LYRA_DEFAULT_promptInputControls,LYRA_DEFAULT_promptInputLabel,LYRA_DEFAULT_promptInputSources}from"../../../internal/default-strings.generated.js";class LyraPromptInput extends LyraElement{constructor(){super(...arguments),this.suggestionCaretGeneration=0,this._value="",this.statusValue="idle",this.placeholder="",this.disabled=!1,this.readOnly=!1,this.submitOnEnter=!0,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.label="",this.accessibleLabel=null,this.activeSuggestion=null,this.slotPresence=new SlotPresenceController(this),this.suggestionNavigationGeneration=0,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)}}static{this.defaultStrings={...super.defaultStrings,fieldRequired:LYRA_DEFAULT_fieldRequired,promptInputAttachments:LYRA_DEFAULT_promptInputAttachments,promptInputControls:LYRA_DEFAULT_promptInputControls,promptInputLabel:LYRA_DEFAULT_promptInputLabel,promptInputSources:LYRA_DEFAULT_promptInputSources}}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 value(){return this._value}set value(next){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&&(start===void 0||end===void 0?composer.setRangeText(replacement):composer.setRangeText(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)}connectedCallback(){super.connectedCallback(),this.addEventListener("keydown",this.onCompositeKeyDown,!0)}disconnectedCallback(){this.removeEventListener("keydown",this.onCompositeKeyDown,!0),this.suggestionCaretGeneration+=1,this.closeSuggestions(),super.disconnectedCallback()}updated(_changed){super.updated(_changed);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)})}get effectiveSources(){return firstByPromptIdentity(this.sources,source=>source.id)}get effectiveSelectedSourceIds(){return firstByPromptIdentity(this.selectedSourceIds,sourceId=>sourceId)}get effectiveQueue(){return firstByPromptIdentity(this.queue,item=>item.id)}renderDefaultAttachmentTrigger(){return html`<lr-attachment-trigger
1
+ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};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{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{firstByRetrievalIdentity as firstByPromptIdentity}from"../../retrieval/retrieval-identity.js";import{normalizeChatComposerStatus}from"../chat-composer/chat-composer.class.js";import{styles}from"./prompt-input.styles.js";import{LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_promptInputAttachments,LYRA_DEFAULT_promptInputControls,LYRA_DEFAULT_promptInputLabel,LYRA_DEFAULT_promptInputSources}from"../../../internal/default-strings.generated.js";class LyraPromptInput extends LyraElement{constructor(){super(...arguments),this.suggestionCaretGeneration=0,this._value="",this.statusValue="idle",this.placeholder="",this.disabled=!1,this.readOnly=!1,this.submitOnEnter=!0,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.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)}}static{this.defaultStrings={...super.defaultStrings,fieldRequired:LYRA_DEFAULT_fieldRequired,promptInputAttachments:LYRA_DEFAULT_promptInputAttachments,promptInputControls:LYRA_DEFAULT_promptInputControls,promptInputLabel:LYRA_DEFAULT_promptInputLabel,promptInputSources:LYRA_DEFAULT_promptInputSources}}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 value(){return this._value}set value(next){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&&(start===void 0||end===void 0?composer.setRangeText(replacement):composer.setRangeText(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)}connectedCallback(){super.connectedCallback(),this.addEventListener("keydown",this.onCompositeKeyDown,!0)}disconnectedCallback(){this.removeEventListener("keydown",this.onCompositeKeyDown,!0),this.suggestionCaretGeneration+=1,this.closeSuggestions(),super.disconnectedCallback()}updated(_changed){super.updated(_changed);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)})}get effectiveSources(){return firstByPromptIdentity(this.sources,source=>source.id)}get effectiveSelectedSourceIds(){return firstByPromptIdentity(this.selectedSourceIds,sourceId=>sourceId)}get effectiveQueue(){return firstByPromptIdentity(this.queue,item=>item.id)}renderDefaultAttachmentTrigger(){return html`<lr-attachment-trigger
2
2
  .capabilities=${this.attachmentCapabilities}
3
3
  .disabled=${this.disabled}
4
4
  @lr-files=${this.onFiles}
@@ -51,7 +51,7 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
51
51
  @lr-sources-change=${event=>this.reemit(event,"lr-sources-change")}
52
52
  ></lr-source-picker>
53
53
  </details>`:nothing}
54
- </div>`}render(){const label=this.accessibleLabel??(this.label||this.localize("promptInputLabel")),attachments=this.effectiveAttachments,queue=this.effectiveQueue,hasChips=attachments.length>0||this.slotPresence.has("chips");return html`<section
54
+ </div>`}render(){const label=this.accessibleLabel??(this.label==null?this.localize("promptInputLabel"):this.label),attachments=this.effectiveAttachments,queue=this.effectiveQueue,hasChips=attachments.length>0||this.slotPresence.has("chips");return html`<section
55
55
  part="base"
56
56
  aria-label=${label}
57
57
  @input=${this.onNativeInput}
@@ -41,7 +41,12 @@ protected static readonly identityCollectionProperties:readonly string[];static
41
41
  protected static readonly identityEventDetailProperties:Readonly<{'lr-send-now':readonly string[];}>;protected static readonly identityEventDetailCollectionItems:Readonly<{'lr-queue-change':readonly string[];}>;
42
42
  /** Controlled queued prompts. Accessor-backed or malformed rows and attachments are omitted;
43
43
  * duplicate nonblank item ids normalize first-wins after full row validation. */
44
- items:readonly PromptQueueItem[];editable:boolean;disabled:boolean;label:string;accessibleLabel:string|null;private pendingRemovalFocus?;private readonly canonicalItemsBySource;private canonicalItemsFor;
44
+ items:readonly PromptQueueItem[];editable:boolean;disabled:boolean;
45
+ /** Visible queue heading and accessible-name fallback. Omitting it localizes the default
46
+ * `promptQueueLabel` message; an explicit empty string (`label=""` or `.label = ''`) suppresses
47
+ * that default, rendering no visible heading (`accessibleLabel` still overrides the region's
48
+ * own accessible name independently). */
49
+ label?:string;accessibleLabel:string|null;private pendingRemovalFocus?;private readonly canonicalItemsBySource;private canonicalItemsFor;
45
50
  /** Never reproject a prior retained collection: a caller may have made its opaque rows hostile
46
51
  * after admission, while focused controlled-update recovery needs only its recorded identities. */
47
52
  private cachedCanonicalItemsFor;private get effectiveItems();protected willUpdate(changed:PropertyValues):void;protected updated(changed:PropertyValues):void;private emitChange;private edit;private removeItem;private move;private sendNow;private containNativeEvent;private renderItem;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-prompt-queue':LyraPromptQueue;}}
@@ -1,4 +1,4 @@
1
- var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing}from"lit";import{property}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{activeElementIn}from"../../../internal/active-element.js";import{trueDefaultBooleanConverter}from"../../../internal/converters.js";import{getOwnDataDescriptor,MISSING_OWN_DATA_DESCRIPTOR,UNSAFE_OWN_DATA_DESCRIPTOR}from"../../../internal/data-descriptors.js";import{LyraElement}from"../../../internal/lyra-element.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{styles}from"./prompt-queue.styles.js";import{LYRA_DEFAULT_attachmentUntitledFile,LYRA_DEFAULT_moveDown,LYRA_DEFAULT_moveUp,LYRA_DEFAULT_promptInputAttachments,LYRA_DEFAULT_promptQueueActionLabel,LYRA_DEFAULT_promptQueueEmpty,LYRA_DEFAULT_promptQueueItemLabel,LYRA_DEFAULT_promptQueueLabel,LYRA_DEFAULT_promptQueueSendNow,LYRA_DEFAULT_remove}from"../../../internal/default-strings.generated.js";const MAX_PROJECTED_QUEUE_ITEMS=1e4,MAX_PROJECTED_QUEUE_ATTACHMENTS=1e4,EMPTY_CANONICAL_PROMPT_QUEUE_ITEMS=Object.freeze([]);function descriptorValue(value,property2){return getOwnDataDescriptor(value,property2)}function valueOfDescriptor(descriptor){return descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR?void 0:descriptor.value}function projectPromptQueueAttachment(value){try{if(value===null||typeof value!="object"||Array.isArray(value))return;const idDescriptor=descriptorValue(value,"id"),nameDescriptor=descriptorValue(value,"name"),mimeTypeDescriptor=descriptorValue(value,"mimeType"),uriDescriptor=descriptorValue(value,"uri"),versionDescriptor=descriptorValue(value,"version");if([idDescriptor,nameDescriptor,mimeTypeDescriptor,uriDescriptor,versionDescriptor].some(descriptor=>descriptor===UNSAFE_OWN_DATA_DESCRIPTOR))return;const id=valueOfDescriptor(idDescriptor),name=valueOfDescriptor(nameDescriptor);if(typeof id!="string"||id.trim().length===0||typeof name!="string")return;const mimeType=valueOfDescriptor(mimeTypeDescriptor),uri=valueOfDescriptor(uriDescriptor),version=valueOfDescriptor(versionDescriptor);return Object.freeze({id,name,...typeof mimeType=="string"?{mimeType}:{},...typeof uri=="string"?{uri}:{},...typeof version=="string"?{version}:{}})}catch{return}}function projectPromptQueueAttachments(value){try{if(!Array.isArray(value))return;const lengthDescriptor=descriptorValue(value,"length");if(lengthDescriptor===MISSING_OWN_DATA_DESCRIPTOR||lengthDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR||typeof lengthDescriptor.value!="number"||!Number.isSafeInteger(lengthDescriptor.value)||lengthDescriptor.value<0)return;const attachments=[],length=Math.min(lengthDescriptor.value,MAX_PROJECTED_QUEUE_ATTACHMENTS);for(let index=0;index<length;index+=1){const descriptor=descriptorValue(value,String(index));if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR)continue;const attachment=projectPromptQueueAttachment(descriptor.value);attachment&&attachments.push(attachment)}return Object.freeze(attachments)}catch{return}}function projectPromptQueueItem(value){try{if(value===null||typeof value!="object"||Array.isArray(value))return;const idDescriptor=descriptorValue(value,"id"),valueDescriptor=descriptorValue(value,"value"),attachmentsDescriptor=descriptorValue(value,"attachments"),createdAtDescriptor=descriptorValue(value,"createdAt"),metadataDescriptor=descriptorValue(value,"metadata");if([idDescriptor,valueDescriptor,attachmentsDescriptor,createdAtDescriptor,metadataDescriptor].some(descriptor=>descriptor===UNSAFE_OWN_DATA_DESCRIPTOR))return;const id=valueOfDescriptor(idDescriptor),prompt=valueOfDescriptor(valueDescriptor);if(typeof id!="string"||id.trim().length===0||typeof prompt!="string")return;const attachmentsValue=valueOfDescriptor(attachmentsDescriptor),attachments=attachmentsDescriptor===MISSING_OWN_DATA_DESCRIPTOR||attachmentsValue===void 0?void 0:projectPromptQueueAttachments(attachmentsValue),createdAt=valueOfDescriptor(createdAtDescriptor),metadata=valueOfDescriptor(metadataDescriptor);return Object.freeze({source:value,id,value:prompt,...attachments===void 0?{}:{attachments},...typeof createdAt=="number"&&Number.isFinite(createdAt)?{createdAt}:{},...metadata!==void 0?{metadata}:{}})}catch{return}}function projectPromptQueueItems(value){try{if(!Array.isArray(value))return EMPTY_CANONICAL_PROMPT_QUEUE_ITEMS;const lengthDescriptor=descriptorValue(value,"length");if(lengthDescriptor===MISSING_OWN_DATA_DESCRIPTOR||lengthDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR||typeof lengthDescriptor.value!="number"||!Number.isSafeInteger(lengthDescriptor.value)||lengthDescriptor.value<0)return EMPTY_CANONICAL_PROMPT_QUEUE_ITEMS;const items=[],seen=new Set,length=Math.min(lengthDescriptor.value,MAX_PROJECTED_QUEUE_ITEMS);for(let index=0;index<length;index+=1){const descriptor=descriptorValue(value,String(index));if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR)continue;const item=projectPromptQueueItem(descriptor.value);!item||seen.has(item.id)||(seen.add(item.id),items.push(item))}return Object.freeze(items)}catch{return EMPTY_CANONICAL_PROMPT_QUEUE_ITEMS}}function toDocumentRef(attachment){return Object.freeze({id:attachment.id,name:attachment.name,...attachment.mimeType===void 0?{}:{mimeType:attachment.mimeType},...attachment.uri===void 0?{}:{uri:attachment.uri},...attachment.version===void 0?{}:{version:attachment.version}})}function toPromptQueueItem(item,value=item.value){return Object.freeze({id:item.id,value,...item.attachments===void 0?{}:{attachments:Object.freeze(item.attachments.map(toDocumentRef))},...item.createdAt===void 0?{}:{createdAt:item.createdAt},...item.metadata===void 0?{}:{metadata:item.metadata}})}class LyraPromptQueue extends LyraElement{constructor(){super(...arguments),this.items=[],this.editable=!0,this.disabled=!1,this.label="",this.accessibleLabel=null,this.canonicalItemsBySource=new WeakMap,this.containNativeEvent=event=>{event.stopPropagation()}}static{this.defaultStrings={...super.defaultStrings,attachmentUntitledFile:LYRA_DEFAULT_attachmentUntitledFile,moveDown:LYRA_DEFAULT_moveDown,moveUp:LYRA_DEFAULT_moveUp,promptInputAttachments:LYRA_DEFAULT_promptInputAttachments,promptQueueActionLabel:LYRA_DEFAULT_promptQueueActionLabel,promptQueueEmpty:LYRA_DEFAULT_promptQueueEmpty,promptQueueItemLabel:LYRA_DEFAULT_promptQueueItemLabel,promptQueueLabel:LYRA_DEFAULT_promptQueueLabel,promptQueueSendNow:LYRA_DEFAULT_promptQueueSendNow,remove:LYRA_DEFAULT_remove}}static{this.ownedCollectionProperties=Object.freeze(["items"])}static{this.identityCollectionProperties=Object.freeze(["items"])}static{this.styles=[LyraElement.styles,styles]}static{this.immutableEventDetails=Object.freeze(["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"])})}canonicalItemsFor(source){if(source===null||typeof source!="object"&&typeof source!="function")return EMPTY_CANONICAL_PROMPT_QUEUE_ITEMS;const cached=this.canonicalItemsBySource.get(source);if(cached)return cached;const result=projectPromptQueueItems(source);return this.canonicalItemsBySource.set(source,result),result}cachedCanonicalItemsFor(source){return source!==null&&(typeof source=="object"||typeof source=="function")?this.canonicalItemsBySource.get(source)??EMPTY_CANONICAL_PROMPT_QUEUE_ITEMS:EMPTY_CANONICAL_PROMPT_QUEUE_ITEMS}get effectiveItems(){return this.canonicalItemsFor(this.items)}willUpdate(changed){if(super.willUpdate(changed),!changed.has("items")&&!changed.has("editable")&&!changed.has("disabled"))return;const focusedControl=activeElementIn(this.shadowRoot),action=focusedControl?.getAttribute("data-action")??void 0,editorFocused=focusedControl?.getAttribute("part")==="editor";if(!action&&!editorFocused)return;const focusedItem=focusedControl?.closest("[data-id]"),focusedId=focusedItem?.dataset.id;if(!focusedId||!focusedControl)return;const previousItems=changed.has("items")?this.cachedCanonicalItemsFor(changed.get("items")):EMPTY_CANONICAL_PROMPT_QUEUE_ITEMS,items=this.effectiveItems,rowRemoved=changed.has("items")&&!items.some(item=>item.id===focusedId),editorRemoved=editorFocused&&changed.has("editable")&&!this.editable,controlDisabled=changed.has("disabled")&&this.disabled;if(!rowRemoved&&!editorRemoved&&!controlDisabled)return;const previousIndex=previousItems.findIndex(item=>item.id===focusedId),target=rowRemoved?items[Math.min(Math.max(previousIndex,0),items.length-1)]:items.find(item=>item.id===focusedId),rowActions=focusedItem?.querySelectorAll("[data-action]")??[];this.pendingRemovalFocus={targetId:target?.id,action,actionIndex:action?[...rowActions].findIndex(candidate=>candidate===focusedControl):-1,origin:focusedControl}}updated(changed){super.updated(changed);const pending=this.pendingRemovalFocus;if(!pending)return;this.pendingRemovalFocus=void 0;const internalActive=activeElementIn(this.shadowRoot),documentActive=activeElementIn(this.ownerDocument);if(internalActive!==null&&internalActive!==pending.origin||documentActive!==null&&documentActive!==this&&documentActive!==this.ownerDocument.body)return;if(!pending.targetId){this.shadowRoot?.querySelector('[part="base"]')?.focus();return}const actions=[...[...this.shadowRoot?.querySelectorAll("[data-id]")??[]].find(item=>item.dataset.id===pending.targetId)?.querySelectorAll("[data-action]")??[]],isEnabled=candidate=>candidate.disabled!==!0&&candidate.getAttribute("aria-disabled")!=="true",equivalentAction=pending.action?actions.find(candidate=>candidate.dataset.action===pending.action&&isEnabled(candidate)):void 0;if(equivalentAction){equivalentAction.focus();return}const preferredIndex=pending.actionIndex>=0?pending.actionIndex:0;for(let distance=0;distance<actions.length;distance++){const before=actions[preferredIndex-distance];if(before&&isEnabled(before)){before.focus();return}const after=actions[preferredIndex+distance];if(after&&isEnabled(after)){after.focus();return}}this.shadowRoot?.querySelector('[part="base"]')?.focus()}emitChange(items,reason,itemId){this.disabled||this.emit("lr-queue-change",{items,reason,itemId})}edit(item,value){this.disabled||!this.editable||this.emitChange(this.effectiveItems.map(candidate=>toPromptQueueItem(candidate,candidate.id===item.id?value:candidate.value)),"edit",item.id)}removeItem(item){this.disabled||this.emitChange(this.effectiveItems.filter(candidate=>candidate.id!==item.id).map(candidate=>toPromptQueueItem(candidate)),"remove",item.id)}move(item,offset){if(this.disabled)return;const items=this.effectiveItems,index=items.findIndex(candidate=>candidate.id===item.id),target=index+offset;if(index<0||target<0||target>=items.length)return;const next=[...items],[moved]=next.splice(index,1);moved&&(next.splice(target,0,moved),this.emitChange(next.map(candidate=>toPromptQueueItem(candidate)),"reorder",item.id))}sendNow(item){this.disabled||this.emit("lr-send-now",{item:toPromptQueueItem(item)})}renderItem(item,index,itemCount){const formattedIndex=getNumberFormat(this.effectiveLocale).format(index+1),editorLabel=this.localize("promptQueueItemLabel",void 0,{index:formattedIndex}),actionLabel=action=>this.localize("promptQueueActionLabel",void 0,{action,index:formattedIndex});return html`<li part="item" data-id=${item.id}>
1
+ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing}from"lit";import{property}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{activeElementIn}from"../../../internal/active-element.js";import{trueDefaultBooleanConverter}from"../../../internal/converters.js";import{getOwnDataDescriptor,MISSING_OWN_DATA_DESCRIPTOR,UNSAFE_OWN_DATA_DESCRIPTOR}from"../../../internal/data-descriptors.js";import{LyraElement}from"../../../internal/lyra-element.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{styles}from"./prompt-queue.styles.js";import{LYRA_DEFAULT_attachmentUntitledFile,LYRA_DEFAULT_moveDown,LYRA_DEFAULT_moveUp,LYRA_DEFAULT_promptInputAttachments,LYRA_DEFAULT_promptQueueActionLabel,LYRA_DEFAULT_promptQueueEmpty,LYRA_DEFAULT_promptQueueItemLabel,LYRA_DEFAULT_promptQueueLabel,LYRA_DEFAULT_promptQueueSendNow,LYRA_DEFAULT_remove}from"../../../internal/default-strings.generated.js";const MAX_PROJECTED_QUEUE_ITEMS=1e4,MAX_PROJECTED_QUEUE_ATTACHMENTS=1e4,EMPTY_CANONICAL_PROMPT_QUEUE_ITEMS=Object.freeze([]);function descriptorValue(value,property2){return getOwnDataDescriptor(value,property2)}function valueOfDescriptor(descriptor){return descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR?void 0:descriptor.value}function projectPromptQueueAttachment(value){try{if(value===null||typeof value!="object"||Array.isArray(value))return;const idDescriptor=descriptorValue(value,"id"),nameDescriptor=descriptorValue(value,"name"),mimeTypeDescriptor=descriptorValue(value,"mimeType"),uriDescriptor=descriptorValue(value,"uri"),versionDescriptor=descriptorValue(value,"version");if([idDescriptor,nameDescriptor,mimeTypeDescriptor,uriDescriptor,versionDescriptor].some(descriptor=>descriptor===UNSAFE_OWN_DATA_DESCRIPTOR))return;const id=valueOfDescriptor(idDescriptor),name=valueOfDescriptor(nameDescriptor);if(typeof id!="string"||id.trim().length===0||typeof name!="string")return;const mimeType=valueOfDescriptor(mimeTypeDescriptor),uri=valueOfDescriptor(uriDescriptor),version=valueOfDescriptor(versionDescriptor);return Object.freeze({id,name,...typeof mimeType=="string"?{mimeType}:{},...typeof uri=="string"?{uri}:{},...typeof version=="string"?{version}:{}})}catch{return}}function projectPromptQueueAttachments(value){try{if(!Array.isArray(value))return;const lengthDescriptor=descriptorValue(value,"length");if(lengthDescriptor===MISSING_OWN_DATA_DESCRIPTOR||lengthDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR||typeof lengthDescriptor.value!="number"||!Number.isSafeInteger(lengthDescriptor.value)||lengthDescriptor.value<0)return;const attachments=[],length=Math.min(lengthDescriptor.value,MAX_PROJECTED_QUEUE_ATTACHMENTS);for(let index=0;index<length;index+=1){const descriptor=descriptorValue(value,String(index));if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR)continue;const attachment=projectPromptQueueAttachment(descriptor.value);attachment&&attachments.push(attachment)}return Object.freeze(attachments)}catch{return}}function projectPromptQueueItem(value){try{if(value===null||typeof value!="object"||Array.isArray(value))return;const idDescriptor=descriptorValue(value,"id"),valueDescriptor=descriptorValue(value,"value"),attachmentsDescriptor=descriptorValue(value,"attachments"),createdAtDescriptor=descriptorValue(value,"createdAt"),metadataDescriptor=descriptorValue(value,"metadata");if([idDescriptor,valueDescriptor,attachmentsDescriptor,createdAtDescriptor,metadataDescriptor].some(descriptor=>descriptor===UNSAFE_OWN_DATA_DESCRIPTOR))return;const id=valueOfDescriptor(idDescriptor),prompt=valueOfDescriptor(valueDescriptor);if(typeof id!="string"||id.trim().length===0||typeof prompt!="string")return;const attachmentsValue=valueOfDescriptor(attachmentsDescriptor),attachments=attachmentsDescriptor===MISSING_OWN_DATA_DESCRIPTOR||attachmentsValue===void 0?void 0:projectPromptQueueAttachments(attachmentsValue),createdAt=valueOfDescriptor(createdAtDescriptor),metadata=valueOfDescriptor(metadataDescriptor);return Object.freeze({source:value,id,value:prompt,...attachments===void 0?{}:{attachments},...typeof createdAt=="number"&&Number.isFinite(createdAt)?{createdAt}:{},...metadata!==void 0?{metadata}:{}})}catch{return}}function projectPromptQueueItems(value){try{if(!Array.isArray(value))return EMPTY_CANONICAL_PROMPT_QUEUE_ITEMS;const lengthDescriptor=descriptorValue(value,"length");if(lengthDescriptor===MISSING_OWN_DATA_DESCRIPTOR||lengthDescriptor===UNSAFE_OWN_DATA_DESCRIPTOR||typeof lengthDescriptor.value!="number"||!Number.isSafeInteger(lengthDescriptor.value)||lengthDescriptor.value<0)return EMPTY_CANONICAL_PROMPT_QUEUE_ITEMS;const items=[],seen=new Set,length=Math.min(lengthDescriptor.value,MAX_PROJECTED_QUEUE_ITEMS);for(let index=0;index<length;index+=1){const descriptor=descriptorValue(value,String(index));if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR)continue;const item=projectPromptQueueItem(descriptor.value);!item||seen.has(item.id)||(seen.add(item.id),items.push(item))}return Object.freeze(items)}catch{return EMPTY_CANONICAL_PROMPT_QUEUE_ITEMS}}function toDocumentRef(attachment){return Object.freeze({id:attachment.id,name:attachment.name,...attachment.mimeType===void 0?{}:{mimeType:attachment.mimeType},...attachment.uri===void 0?{}:{uri:attachment.uri},...attachment.version===void 0?{}:{version:attachment.version}})}function toPromptQueueItem(item,value=item.value){return Object.freeze({id:item.id,value,...item.attachments===void 0?{}:{attachments:Object.freeze(item.attachments.map(toDocumentRef))},...item.createdAt===void 0?{}:{createdAt:item.createdAt},...item.metadata===void 0?{}:{metadata:item.metadata}})}class LyraPromptQueue extends LyraElement{constructor(){super(...arguments),this.items=[],this.editable=!0,this.disabled=!1,this.accessibleLabel=null,this.canonicalItemsBySource=new WeakMap,this.containNativeEvent=event=>{event.stopPropagation()}}static{this.defaultStrings={...super.defaultStrings,attachmentUntitledFile:LYRA_DEFAULT_attachmentUntitledFile,moveDown:LYRA_DEFAULT_moveDown,moveUp:LYRA_DEFAULT_moveUp,promptInputAttachments:LYRA_DEFAULT_promptInputAttachments,promptQueueActionLabel:LYRA_DEFAULT_promptQueueActionLabel,promptQueueEmpty:LYRA_DEFAULT_promptQueueEmpty,promptQueueItemLabel:LYRA_DEFAULT_promptQueueItemLabel,promptQueueLabel:LYRA_DEFAULT_promptQueueLabel,promptQueueSendNow:LYRA_DEFAULT_promptQueueSendNow,remove:LYRA_DEFAULT_remove}}static{this.ownedCollectionProperties=Object.freeze(["items"])}static{this.identityCollectionProperties=Object.freeze(["items"])}static{this.styles=[LyraElement.styles,styles]}static{this.immutableEventDetails=Object.freeze(["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"])})}canonicalItemsFor(source){if(source===null||typeof source!="object"&&typeof source!="function")return EMPTY_CANONICAL_PROMPT_QUEUE_ITEMS;const cached=this.canonicalItemsBySource.get(source);if(cached)return cached;const result=projectPromptQueueItems(source);return this.canonicalItemsBySource.set(source,result),result}cachedCanonicalItemsFor(source){return source!==null&&(typeof source=="object"||typeof source=="function")?this.canonicalItemsBySource.get(source)??EMPTY_CANONICAL_PROMPT_QUEUE_ITEMS:EMPTY_CANONICAL_PROMPT_QUEUE_ITEMS}get effectiveItems(){return this.canonicalItemsFor(this.items)}willUpdate(changed){if(super.willUpdate(changed),!changed.has("items")&&!changed.has("editable")&&!changed.has("disabled"))return;const focusedControl=activeElementIn(this.shadowRoot),action=focusedControl?.getAttribute("data-action")??void 0,editorFocused=focusedControl?.getAttribute("part")==="editor";if(!action&&!editorFocused)return;const focusedItem=focusedControl?.closest("[data-id]"),focusedId=focusedItem?.dataset.id;if(!focusedId||!focusedControl)return;const previousItems=changed.has("items")?this.cachedCanonicalItemsFor(changed.get("items")):EMPTY_CANONICAL_PROMPT_QUEUE_ITEMS,items=this.effectiveItems,rowRemoved=changed.has("items")&&!items.some(item=>item.id===focusedId),editorRemoved=editorFocused&&changed.has("editable")&&!this.editable,controlDisabled=changed.has("disabled")&&this.disabled;if(!rowRemoved&&!editorRemoved&&!controlDisabled)return;const previousIndex=previousItems.findIndex(item=>item.id===focusedId),target=rowRemoved?items[Math.min(Math.max(previousIndex,0),items.length-1)]:items.find(item=>item.id===focusedId),rowActions=focusedItem?.querySelectorAll("[data-action]")??[];this.pendingRemovalFocus={targetId:target?.id,action,actionIndex:action?[...rowActions].findIndex(candidate=>candidate===focusedControl):-1,origin:focusedControl}}updated(changed){super.updated(changed);const pending=this.pendingRemovalFocus;if(!pending)return;this.pendingRemovalFocus=void 0;const internalActive=activeElementIn(this.shadowRoot),documentActive=activeElementIn(this.ownerDocument);if(internalActive!==null&&internalActive!==pending.origin||documentActive!==null&&documentActive!==this&&documentActive!==this.ownerDocument.body)return;if(!pending.targetId){this.shadowRoot?.querySelector('[part="base"]')?.focus();return}const actions=[...[...this.shadowRoot?.querySelectorAll("[data-id]")??[]].find(item=>item.dataset.id===pending.targetId)?.querySelectorAll("[data-action]")??[]],isEnabled=candidate=>candidate.disabled!==!0&&candidate.getAttribute("aria-disabled")!=="true",equivalentAction=pending.action?actions.find(candidate=>candidate.dataset.action===pending.action&&isEnabled(candidate)):void 0;if(equivalentAction){equivalentAction.focus();return}const preferredIndex=pending.actionIndex>=0?pending.actionIndex:0;for(let distance=0;distance<actions.length;distance++){const before=actions[preferredIndex-distance];if(before&&isEnabled(before)){before.focus();return}const after=actions[preferredIndex+distance];if(after&&isEnabled(after)){after.focus();return}}this.shadowRoot?.querySelector('[part="base"]')?.focus()}emitChange(items,reason,itemId){this.disabled||this.emit("lr-queue-change",{items,reason,itemId})}edit(item,value){this.disabled||!this.editable||this.emitChange(this.effectiveItems.map(candidate=>toPromptQueueItem(candidate,candidate.id===item.id?value:candidate.value)),"edit",item.id)}removeItem(item){this.disabled||this.emitChange(this.effectiveItems.filter(candidate=>candidate.id!==item.id).map(candidate=>toPromptQueueItem(candidate)),"remove",item.id)}move(item,offset){if(this.disabled)return;const items=this.effectiveItems,index=items.findIndex(candidate=>candidate.id===item.id),target=index+offset;if(index<0||target<0||target>=items.length)return;const next=[...items],[moved]=next.splice(index,1);moved&&(next.splice(target,0,moved),this.emitChange(next.map(candidate=>toPromptQueueItem(candidate)),"reorder",item.id))}sendNow(item){this.disabled||this.emit("lr-send-now",{item:toPromptQueueItem(item)})}renderItem(item,index,itemCount){const formattedIndex=getNumberFormat(this.effectiveLocale).format(index+1),editorLabel=this.localize("promptQueueItemLabel",void 0,{index:formattedIndex}),actionLabel=action=>this.localize("promptQueueActionLabel",void 0,{action,index:formattedIndex});return html`<li part="item" data-id=${item.id}>
2
2
  ${this.editable?html`<lr-textarea
3
3
  part="editor"
4
4
  .value=${item.value}
@@ -51,7 +51,7 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
51
51
  @click=${()=>this.removeItem(item)}
52
52
  >${this.localize("remove")}</lr-button>
53
53
  </div>
54
- </li>`}render(){const visibleLabel=this.label||this.localize("promptQueueLabel"),accessibleLabel=this.accessibleLabel??visibleLabel,items=this.effectiveItems;return html`<section
54
+ </li>`}render(){const visibleLabel=this.label==null?this.localize("promptQueueLabel"):this.label,accessibleLabel=this.accessibleLabel??visibleLabel,items=this.effectiveItems;return html`<section
55
55
  part="base"
56
56
  aria-label=${accessibleLabel}
57
57
  tabindex="-1"
@@ -44,4 +44,8 @@ export declare class LyraRealtimeSession extends LyraElement<LyraRealtimeSession
44
44
  sessionId:string;entries:readonly LyraTranscriptEntry[];muted:boolean;
45
45
  /** Shows native push-to-talk capture. Hiding a focused capture transfers focus to the current
46
46
  * connect/disconnect action; hiding it while another control owns focus leaves that focus alone. */
47
- showCapture:boolean;label:string;private transferActionFocus?;private statusAnnouncementSink?;private errorAnnouncementSink?;private suppressNextStateAnnouncement;constructor();private syncAnnouncementSinks;connectedCallback():void;disconnectedCallback():void;protected willUpdate(changed:PropertyValues<this>):void;protected updated(changed:PropertyValues<this>):void;private stateLabel;private containNativeEvent;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-realtime-session':LyraRealtimeSession;}}
47
+ showCapture:boolean;
48
+ /** Accessible name for the session shell. Omitting it localizes the default
49
+ * `realtimeSessionLabel` message; an explicit empty string (`label=""` or `.label = ''`)
50
+ * suppresses that default and renders no label. A host `aria-label` wins over both. */
51
+ label?:string;private transferActionFocus?;private statusAnnouncementSink?;private errorAnnouncementSink?;private suppressNextStateAnnouncement;constructor();private syncAnnouncementSinks;connectedCallback():void;disconnectedCallback():void;protected willUpdate(changed:PropertyValues<this>):void;protected updated(changed:PropertyValues<this>):void;private stateLabel;private containNativeEvent;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-realtime-session':LyraRealtimeSession;}}
@@ -1,4 +1,4 @@
1
- var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing}from"lit";import{property}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{finiteRange}from"../../../internal/numbers.js";import{literalSetConverter,trueDefaultBooleanConverter}from"../../../internal/converters.js";import"../audio-visualizer/audio-visualizer.class.js";import"../push-to-talk/push-to-talk.class.js";import"../transcript-feed/transcript-feed.class.js";import"../../overlays/badge/badge.class.js";import{styles}from"./realtime-session.styles.js";import{activeElementIn}from"../../../internal/active-element.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{LYRA_DEFAULT_realtimeSessionConnect,LYRA_DEFAULT_realtimeSessionConnected,LYRA_DEFAULT_realtimeSessionConnecting,LYRA_DEFAULT_realtimeSessionConnectionFailed,LYRA_DEFAULT_realtimeSessionDisconnect,LYRA_DEFAULT_realtimeSessionDisconnected,LYRA_DEFAULT_realtimeSessionError,LYRA_DEFAULT_realtimeSessionInterrupt,LYRA_DEFAULT_realtimeSessionLabel,LYRA_DEFAULT_realtimeSessionMute,LYRA_DEFAULT_realtimeSessionReconnecting,LYRA_DEFAULT_realtimeSessionUnmute}from"../../../internal/default-strings.generated.js";const CONNECTION_STATE=literalSetConverter(["disconnected","connecting","connected","reconnecting","error"],"disconnected"),VOICE_STATE=literalSetConverter(["idle","listening","thinking","speaking"],"idle"),STATE_VARIANT={disconnected:"neutral",connecting:"brand",connected:"success",reconnecting:"warning",error:"danger"};class LyraRealtimeSession extends LyraElement{static{this.defaultStrings={...super.defaultStrings,realtimeSessionConnect:LYRA_DEFAULT_realtimeSessionConnect,realtimeSessionConnected:LYRA_DEFAULT_realtimeSessionConnected,realtimeSessionConnecting:LYRA_DEFAULT_realtimeSessionConnecting,realtimeSessionConnectionFailed:LYRA_DEFAULT_realtimeSessionConnectionFailed,realtimeSessionDisconnect:LYRA_DEFAULT_realtimeSessionDisconnect,realtimeSessionDisconnected:LYRA_DEFAULT_realtimeSessionDisconnected,realtimeSessionError:LYRA_DEFAULT_realtimeSessionError,realtimeSessionInterrupt:LYRA_DEFAULT_realtimeSessionInterrupt,realtimeSessionLabel:LYRA_DEFAULT_realtimeSessionLabel,realtimeSessionMute:LYRA_DEFAULT_realtimeSessionMute,realtimeSessionReconnecting:LYRA_DEFAULT_realtimeSessionReconnecting,realtimeSessionUnmute:LYRA_DEFAULT_realtimeSessionUnmute}}static{this.ownedCollectionProperties=Object.freeze(["entries"])}static{this.styles=[LyraElement.styles,styles]}get state(){return this._state}set state(next){const normalized=CONNECTION_STATE.normalize(next),old=this._state;old!==normalized&&(this._state=normalized,this.requestUpdate("state",old))}get voiceState(){return this._voiceState}set voiceState(next){const normalized=VOICE_STATE.normalize(next),old=this._voiceState;old!==normalized&&(this._voiceState=normalized,this.requestUpdate("voiceState",old))}constructor(){super(),this._state="disconnected",this._voiceState="idle",this.level=null,this.stream=null,this.sessionId="",this.entries=[],this.muted=!1,this.showCapture=!0,this.label="",this.suppressNextStateAnnouncement=!0,this.containNativeEvent=event=>{event.stopPropagation()},this.requestUpdate("state",void 0),this.requestUpdate("voiceState",void 0)}syncAnnouncementSinks(){this.isConnected&&(this.statusAnnouncementSink?.element.ownerDocument===this.ownerDocument&&this.errorAnnouncementSink?.element.ownerDocument===this.ownerDocument||(this.statusAnnouncementSink?.release(),this.errorAnnouncementSink?.release(),this.statusAnnouncementSink=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}),this.errorAnnouncementSink=acquireAnnouncementSink("assertive",{document:this.ownerDocument,source:this})))}connectedCallback(){super.connectedCallback(),this.syncAnnouncementSinks(),this.hasUpdated&&(this.suppressNextStateAnnouncement=!0,this.requestUpdate())}disconnectedCallback(){super.disconnectedCallback(),this.statusAnnouncementSink?.release(),this.errorAnnouncementSink?.release(),this.statusAnnouncementSink=void 0,this.errorAnnouncementSink=void 0,this.suppressNextStateAnnouncement=!0}willUpdate(changed){super.willUpdate(changed);const stateChanged=changed.has("state"),captureHidden=changed.has("showCapture")&&changed.get("showCapture")===!0&&!this.showCapture,captureDisabled=changed.has("muted")&&changed.get("muted")===!1&&this.muted;if(!stateChanged&&!captureHidden&&!captureDisabled)return;const focused=activeElementIn(this.shadowRoot??this.ownerDocument),focusedPart=focused?.getAttribute("part")??null;if(!focused)return;if(captureDisabled&&!stateChanged&&!captureHidden&&focusedPart==="capture"){this.transferActionFocus={target:"mute",origin:focused};return}(captureHidden&&!stateChanged?focusedPart==="capture":focused.closest('[part="controls"]')!==null||focusedPart==="connect"||focusedPart==="disconnect"||focusedPart==="mute"||focusedPart==="interrupt"||focusedPart==="capture")&&(this.transferActionFocus={target:"connection",origin:focused})}updated(changed){super.updated(changed);const stateChanged=changed.has("state");stateChanged&&!this.suppressNextStateAnnouncement&&(this.state==="error"?this.errorAnnouncementSink?.announce(this.localize("realtimeSessionConnectionFailed")):this.statusAnnouncementSink?.announce(this.stateLabel()));const pending=this.transferActionFocus;if((stateChanged||changed.has("showCapture")||changed.has("muted"))&&pending){this.transferActionFocus=void 0;const internalActive=activeElementIn(this.shadowRoot),documentActive=activeElementIn(this.ownerDocument);if((internalActive===null||internalActive===pending.origin)&&(documentActive===null||documentActive===this||documentActive===this.ownerDocument.body)){const selector=pending.target==="mute"?'[part="mute"]':'[part="connect"], [part="disconnect"]';this.renderRoot.querySelector(selector)?.focus()}}this.suppressNextStateAnnouncement=!1}stateLabel(){switch(this.state){case"disconnected":return this.localize("realtimeSessionDisconnected");case"connecting":return this.localize("realtimeSessionConnecting");case"connected":return this.localize("realtimeSessionConnected");case"reconnecting":return this.localize("realtimeSessionReconnecting");case"error":return this.localize("realtimeSessionError")}}render(){const label=this.getAttribute("aria-label")??(this.label||this.localize("realtimeSessionLabel")),active=this.state==="connected",safeLevel=this.level==null?null:finiteRange(this.level,0,0,1);return html`
1
+ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing}from"lit";import{property}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{finiteRange}from"../../../internal/numbers.js";import{literalSetConverter,trueDefaultBooleanConverter}from"../../../internal/converters.js";import"../audio-visualizer/audio-visualizer.class.js";import"../push-to-talk/push-to-talk.class.js";import"../transcript-feed/transcript-feed.class.js";import"../../overlays/badge/badge.class.js";import{styles}from"./realtime-session.styles.js";import{activeElementIn}from"../../../internal/active-element.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{LYRA_DEFAULT_realtimeSessionConnect,LYRA_DEFAULT_realtimeSessionConnected,LYRA_DEFAULT_realtimeSessionConnecting,LYRA_DEFAULT_realtimeSessionConnectionFailed,LYRA_DEFAULT_realtimeSessionDisconnect,LYRA_DEFAULT_realtimeSessionDisconnected,LYRA_DEFAULT_realtimeSessionError,LYRA_DEFAULT_realtimeSessionInterrupt,LYRA_DEFAULT_realtimeSessionLabel,LYRA_DEFAULT_realtimeSessionMute,LYRA_DEFAULT_realtimeSessionReconnecting,LYRA_DEFAULT_realtimeSessionUnmute}from"../../../internal/default-strings.generated.js";const CONNECTION_STATE=literalSetConverter(["disconnected","connecting","connected","reconnecting","error"],"disconnected"),VOICE_STATE=literalSetConverter(["idle","listening","thinking","speaking"],"idle"),STATE_VARIANT={disconnected:"neutral",connecting:"brand",connected:"success",reconnecting:"warning",error:"danger"};class LyraRealtimeSession extends LyraElement{static{this.defaultStrings={...super.defaultStrings,realtimeSessionConnect:LYRA_DEFAULT_realtimeSessionConnect,realtimeSessionConnected:LYRA_DEFAULT_realtimeSessionConnected,realtimeSessionConnecting:LYRA_DEFAULT_realtimeSessionConnecting,realtimeSessionConnectionFailed:LYRA_DEFAULT_realtimeSessionConnectionFailed,realtimeSessionDisconnect:LYRA_DEFAULT_realtimeSessionDisconnect,realtimeSessionDisconnected:LYRA_DEFAULT_realtimeSessionDisconnected,realtimeSessionError:LYRA_DEFAULT_realtimeSessionError,realtimeSessionInterrupt:LYRA_DEFAULT_realtimeSessionInterrupt,realtimeSessionLabel:LYRA_DEFAULT_realtimeSessionLabel,realtimeSessionMute:LYRA_DEFAULT_realtimeSessionMute,realtimeSessionReconnecting:LYRA_DEFAULT_realtimeSessionReconnecting,realtimeSessionUnmute:LYRA_DEFAULT_realtimeSessionUnmute}}static{this.ownedCollectionProperties=Object.freeze(["entries"])}static{this.styles=[LyraElement.styles,styles]}get state(){return this._state}set state(next){const normalized=CONNECTION_STATE.normalize(next),old=this._state;old!==normalized&&(this._state=normalized,this.requestUpdate("state",old))}get voiceState(){return this._voiceState}set voiceState(next){const normalized=VOICE_STATE.normalize(next),old=this._voiceState;old!==normalized&&(this._voiceState=normalized,this.requestUpdate("voiceState",old))}constructor(){super(),this._state="disconnected",this._voiceState="idle",this.level=null,this.stream=null,this.sessionId="",this.entries=[],this.muted=!1,this.showCapture=!0,this.suppressNextStateAnnouncement=!0,this.containNativeEvent=event=>{event.stopPropagation()},this.requestUpdate("state",void 0),this.requestUpdate("voiceState",void 0)}syncAnnouncementSinks(){this.isConnected&&(this.statusAnnouncementSink?.element.ownerDocument===this.ownerDocument&&this.errorAnnouncementSink?.element.ownerDocument===this.ownerDocument||(this.statusAnnouncementSink?.release(),this.errorAnnouncementSink?.release(),this.statusAnnouncementSink=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}),this.errorAnnouncementSink=acquireAnnouncementSink("assertive",{document:this.ownerDocument,source:this})))}connectedCallback(){super.connectedCallback(),this.syncAnnouncementSinks(),this.hasUpdated&&(this.suppressNextStateAnnouncement=!0,this.requestUpdate())}disconnectedCallback(){super.disconnectedCallback(),this.statusAnnouncementSink?.release(),this.errorAnnouncementSink?.release(),this.statusAnnouncementSink=void 0,this.errorAnnouncementSink=void 0,this.suppressNextStateAnnouncement=!0}willUpdate(changed){super.willUpdate(changed);const stateChanged=changed.has("state"),captureHidden=changed.has("showCapture")&&changed.get("showCapture")===!0&&!this.showCapture,captureDisabled=changed.has("muted")&&changed.get("muted")===!1&&this.muted;if(!stateChanged&&!captureHidden&&!captureDisabled)return;const focused=activeElementIn(this.shadowRoot??this.ownerDocument),focusedPart=focused?.getAttribute("part")??null;if(!focused)return;if(captureDisabled&&!stateChanged&&!captureHidden&&focusedPart==="capture"){this.transferActionFocus={target:"mute",origin:focused};return}(captureHidden&&!stateChanged?focusedPart==="capture":focused.closest('[part="controls"]')!==null||focusedPart==="connect"||focusedPart==="disconnect"||focusedPart==="mute"||focusedPart==="interrupt"||focusedPart==="capture")&&(this.transferActionFocus={target:"connection",origin:focused})}updated(changed){super.updated(changed);const stateChanged=changed.has("state");stateChanged&&!this.suppressNextStateAnnouncement&&(this.state==="error"?this.errorAnnouncementSink?.announce(this.localize("realtimeSessionConnectionFailed")):this.statusAnnouncementSink?.announce(this.stateLabel()));const pending=this.transferActionFocus;if((stateChanged||changed.has("showCapture")||changed.has("muted"))&&pending){this.transferActionFocus=void 0;const internalActive=activeElementIn(this.shadowRoot),documentActive=activeElementIn(this.ownerDocument);if((internalActive===null||internalActive===pending.origin)&&(documentActive===null||documentActive===this||documentActive===this.ownerDocument.body)){const selector=pending.target==="mute"?'[part="mute"]':'[part="connect"], [part="disconnect"]';this.renderRoot.querySelector(selector)?.focus()}}this.suppressNextStateAnnouncement=!1}stateLabel(){switch(this.state){case"disconnected":return this.localize("realtimeSessionDisconnected");case"connecting":return this.localize("realtimeSessionConnecting");case"connected":return this.localize("realtimeSessionConnected");case"reconnecting":return this.localize("realtimeSessionReconnecting");case"error":return this.localize("realtimeSessionError")}}render(){const label=this.getAttribute("aria-label")??(this.label==null?this.localize("realtimeSessionLabel"):this.label),active=this.state==="connected",safeLevel=this.level==null?null:finiteRange(this.level,0,0,1);return html`
2
2
  <section
3
3
  part="base"
4
4
  aria-label=${label}
@@ -58,7 +58,11 @@ anchor:DocumentLocator|null;rect:DOMRectReadOnly|null;
58
58
  * moves to the nearest action or the stable toolbar when the set becomes empty. Duplicate names
59
59
  * normalize first-wins.
60
60
  */
61
- actions:readonly SelectionAction[];label:string;accessibleLabel:string|null;private copyFailed;private toolbar?;private overlay?;private stopPositioning?;
61
+ actions:readonly SelectionAction[];
62
+ /** Accessible name for the toolbar. Omitting it localizes the default `selectionToolbarLabel`
63
+ * message; an explicit empty string (`label=""` or `.label = ''`) suppresses that default and
64
+ * renders no label. `accessibleLabel` wins over both. */
65
+ label?:string;accessibleLabel:string|null;private copyFailed;private toolbar?;private overlay?;private stopPositioning?;
62
66
  /** Announces a copy failure -- the copy button's own `aria-label`/text flipping to
63
67
  * `localize('copyFailed')` is not reliably re-announced by a screen reader without an
64
68
  * explicit live region, unlike every other failure/transition state in this family. */