@aceshooting/lyra-ui 27.0.0 → 28.1.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 (397) hide show
  1. package/CHANGELOG.md +67 -63
  2. package/README.md +7 -3
  3. package/dist/cli/css-declarations.mjs +1 -0
  4. package/dist/cli/lyra-rename-ledger.mjs +1 -1
  5. package/dist/cli/migrate-wa.mjs +9 -4
  6. package/dist/cli/migration-contract.json +1 -1
  7. package/dist/cli/migration-renames.mjs +2 -2
  8. package/dist/cli/migration-theme-scopes.mjs +3 -0
  9. package/dist/cli/theme-scope-vocabulary.generated.mjs +1 -0
  10. package/dist/components/agent-tools/activity-feed/activity-feed.class.js +1 -1
  11. package/dist/components/agent-tools/agent-eval-dashboard/agent-eval-dashboard.class.js +1 -1
  12. package/dist/components/agent-tools/agent-question/agent-question.class.js +1 -1
  13. package/dist/components/agent-tools/agent-run/agent-run.class.js +1 -1
  14. package/dist/components/agent-tools/agent-trace/agent-trace.class.js +1 -1
  15. package/dist/components/agent-tools/approval-queue/approval-queue.class.js +1 -1
  16. package/dist/components/agent-tools/artifact-panel/artifact-panel.class.js +1 -1
  17. package/dist/components/agent-tools/background-runs/background-runs.class.js +1 -1
  18. package/dist/components/agent-tools/browser-frame/browser-frame.class.js +1 -1
  19. package/dist/components/agent-tools/budget-meter/budget-meter.class.js +1 -1
  20. package/dist/components/agent-tools/change-review/change-review.class.js +1 -1
  21. package/dist/components/agent-tools/commit-card/commit-card.class.js +1 -1
  22. package/dist/components/agent-tools/compare-panel/compare-panel.class.js +1 -1
  23. package/dist/components/agent-tools/confirm-bar/confirm-bar.class.js +1 -1
  24. package/dist/components/agent-tools/connector-manager/connector-manager.class.js +1 -1
  25. package/dist/components/agent-tools/context-inspector/context-inspector.class.js +1 -1
  26. package/dist/components/agent-tools/eval-dataset/eval-dataset.class.js +1 -1
  27. package/dist/components/agent-tools/eval-result/eval-result.class.js +1 -1
  28. package/dist/components/agent-tools/evaluation-run/evaluation-run.class.js +1 -1
  29. package/dist/components/agent-tools/mcp-app/mcp-app.class.js +1 -1
  30. package/dist/components/agent-tools/permission-grant/permission-grant.class.js +1 -1
  31. package/dist/components/agent-tools/permission-rules/permission-rules.class.js +1 -1
  32. package/dist/components/agent-tools/policy-summary/policy-summary.class.js +1 -1
  33. package/dist/components/agent-tools/prompt-studio/prompt-studio.class.js +1 -1
  34. package/dist/components/agent-tools/result-card/result-field.class.js +1 -1
  35. package/dist/components/agent-tools/schema-viewer/schema-viewer.class.js +1 -1
  36. package/dist/components/agent-tools/span-waterfall/span-waterfall.class.js +1 -1
  37. package/dist/components/agent-tools/stack-trace/stack-trace.class.js +1 -1
  38. package/dist/components/agent-tools/subagent-panel/subagent-panel.class.js +2 -2
  39. package/dist/components/agent-tools/task-list/task-list.class.js +2 -2
  40. package/dist/components/agent-tools/terminal/terminal.class.js +1 -1
  41. package/dist/components/agent-tools/test-results/test-results.class.js +1 -1
  42. package/dist/components/agent-tools/thinking-panel/thinking-panel.class.js +1 -1
  43. package/dist/components/agent-tools/tool-approval-dialog/tool-approval-dialog.class.js +1 -1
  44. package/dist/components/agent-tools/tool-call-block/tool-call-block.class.js +1 -1
  45. package/dist/components/agent-tools/tool-call-chip/tool-call-chip.class.js +1 -1
  46. package/dist/components/agent-tools/tool-param-form/tool-param-form.class.js +1 -1
  47. package/dist/components/agent-tools/tool-result-dialog/tool-result-dialog.class.js +1 -1
  48. package/dist/components/agent-tools/tool-result-view/tool-result-view.class.js +1 -1
  49. package/dist/components/agent-tools/tool-select-dialog/tool-select-dialog.class.js +1 -1
  50. package/dist/components/agent-tools/tool-timeline/tool-timeline.class.js +1 -1
  51. package/dist/components/agent-tools/trace-tree/trace-tree.class.js +2 -2
  52. package/dist/components/charts/chart/box-plot.class.d.ts +4 -2
  53. package/dist/components/charts/chart/box-plot.class.js +6 -5
  54. package/dist/components/charts/chart/chart-token-cache.js +2 -2
  55. package/dist/components/charts/chart/chart.class.d.ts +6 -4
  56. package/dist/components/charts/chart/chart.class.js +8 -7
  57. package/dist/components/charts/chart/histogram.class.js +1 -1
  58. package/dist/components/charts/chart/lite-chart.class.js +1 -1
  59. package/dist/components/conversation/agent-workspace/agent-workspace.class.js +1 -1
  60. package/dist/components/conversation/audio-visualizer/audio-visualizer.class.js +1 -1
  61. package/dist/components/conversation/branch-picker/branch-picker.class.js +1 -1
  62. package/dist/components/conversation/chat-composer/chat-composer.class.js +1 -1
  63. package/dist/components/conversation/chat-message/chat-message.class.js +1 -1
  64. package/dist/components/conversation/chat-viewport/chat-viewport.class.js +1 -1
  65. package/dist/components/conversation/checkpoint/checkpoint.class.js +1 -1
  66. package/dist/components/conversation/code-block/code-block-base.class.js +1 -1
  67. package/dist/components/conversation/code-block/code-block-core.class.js +1 -1
  68. package/dist/components/conversation/code-block/code-block.class.js +1 -1
  69. package/dist/components/conversation/conversation-item/conversation-item.class.js +1 -1
  70. package/dist/components/conversation/generation-metrics/generation-metrics.class.js +1 -1
  71. package/dist/components/conversation/handoff-divider/handoff-divider.class.js +1 -1
  72. package/dist/components/conversation/markdown/markdown-base.class.js +1 -1
  73. package/dist/components/conversation/markdown/markdown-core.class.js +1 -1
  74. package/dist/components/conversation/markdown/markdown.class.js +1 -1
  75. package/dist/components/conversation/message-actions/message-actions.class.js +1 -1
  76. package/dist/components/conversation/message-feedback/message-feedback.class.js +1 -1
  77. package/dist/components/conversation/message-parts/message-parts.class.js +1 -1
  78. package/dist/components/conversation/model-select/model-select.class.js +1 -1
  79. package/dist/components/conversation/model-settings-panel/model-settings-panel.class.js +1 -1
  80. package/dist/components/conversation/prompt-input/prompt-input.class.js +1 -1
  81. package/dist/components/conversation/prompt-queue/prompt-queue.class.js +1 -1
  82. package/dist/components/conversation/push-to-talk/push-to-talk.class.js +1 -1
  83. package/dist/components/conversation/realtime-session/realtime-session.class.js +1 -1
  84. package/dist/components/conversation/selection-toolbar/selection-toolbar.class.js +1 -1
  85. package/dist/components/conversation/stream-status/stream-status.class.js +1 -1
  86. package/dist/components/conversation/suggestion-chips/suggestion-chips.class.js +1 -1
  87. package/dist/components/conversation/thread-list/thread-list.class.js +1 -1
  88. package/dist/components/conversation/transcript-feed/transcript-feed.class.js +1 -1
  89. package/dist/components/conversation/typing-indicator/typing-indicator.class.js +1 -1
  90. package/dist/components/conversation/usage-badge/usage-badge.class.js +1 -1
  91. package/dist/components/conversation/voice-picker/voice-picker.class.js +1 -1
  92. package/dist/components/data/calendar/calendar.class.js +1 -1
  93. package/dist/components/data/condition-builder/condition-builder.class.js +1 -1
  94. package/dist/components/data/context-meter/context-meter.class.js +1 -1
  95. package/dist/components/data/data-grid/data-grid.class.d.ts +2 -2
  96. package/dist/components/data/data-grid/data-grid.class.js +3 -3
  97. package/dist/components/data/document-library/document-library.class.js +1 -1
  98. package/dist/components/data/env-list/env-list.class.js +1 -1
  99. package/dist/components/data/file-tree/file-tree.class.d.ts +2 -2
  100. package/dist/components/data/file-tree/file-tree.class.js +1 -1
  101. package/dist/components/data/flow-canvas/flow-canvas.class.js +1 -1
  102. package/dist/components/data/flow-controls/flow-controls.class.js +1 -1
  103. package/dist/components/data/flow-minimap/flow-minimap.class.js +1 -1
  104. package/dist/components/data/flow-node/flow-node.class.js +1 -1
  105. package/dist/components/data/flow-run-status/flow-run-status.class.js +1 -1
  106. package/dist/components/data/funnel/funnel.class.js +1 -1
  107. package/dist/components/data/gauge/gauge.class.js +1 -1
  108. package/dist/components/data/graph-query-builder/graph-query-builder.class.js +1 -1
  109. package/dist/components/data/heatmap/heatmap.class.d.ts +2 -1
  110. package/dist/components/data/heatmap/heatmap.class.js +2 -2
  111. package/dist/components/data/heatmap/heatmap.styles.js +1 -1
  112. package/dist/components/data/pagination/pagination.class.d.ts +2 -0
  113. package/dist/components/data/pagination/pagination.class.js +1 -1
  114. package/dist/components/data/pagination/pagination.styles.js +1 -1
  115. package/dist/components/data/sequence-strip/sequence-strip.class.js +1 -1
  116. package/dist/components/data/sparkline/sparkline.class.js +1 -1
  117. package/dist/components/data/stat/stat.class.js +1 -1
  118. package/dist/components/data/table/table.class.d.ts +23 -2
  119. package/dist/components/data/table/table.class.js +5 -3
  120. package/dist/components/data/table/table.styles.js +1 -1
  121. package/dist/components/data/timeline/timeline.class.js +1 -1
  122. package/dist/components/data/tree/tree.class.js +1 -1
  123. package/dist/components/data/word-cloud/word-cloud.class.js +1 -1
  124. package/dist/components/forms/button/button.class.js +1 -1
  125. package/dist/components/forms/checkbox/checkbox.class.js +1 -1
  126. package/dist/components/forms/checkbox-group/checkbox-group.class.js +1 -1
  127. package/dist/components/forms/code-editor/code-editor.class.js +1 -1
  128. package/dist/components/forms/color-picker/color-picker.class.d.ts +8 -4
  129. package/dist/components/forms/color-picker/color-picker.class.js +2 -2
  130. package/dist/components/forms/combobox/combobox.class.js +1 -1
  131. package/dist/components/forms/country-picker/country-picker.class.js +1 -1
  132. package/dist/components/forms/currency-picker/currency-picker.class.js +1 -1
  133. package/dist/components/forms/date-picker/date-input.class.js +1 -1
  134. package/dist/components/forms/date-picker/date-picker.class.js +1 -1
  135. package/dist/components/forms/emoji-picker/emoji-data-loader.js +1 -1
  136. package/dist/components/forms/emoji-picker/emoji-picker.class.d.ts +7 -4
  137. package/dist/components/forms/emoji-picker/emoji-picker.class.js +5 -5
  138. package/dist/components/forms/icon-button/icon-button.class.d.ts +4 -0
  139. package/dist/components/forms/icon-button/icon-button.class.js +1 -1
  140. package/dist/components/forms/icon-button/icon-button.styles.js +1 -1
  141. package/dist/components/forms/input/input-shared.js +1 -1
  142. package/dist/components/forms/input/input.class.js +1 -1
  143. package/dist/components/forms/input/native-time-input.class.js +1 -1
  144. package/dist/components/forms/input/number-input.class.js +1 -1
  145. package/dist/components/forms/input/time-input.class.js +1 -1
  146. package/dist/components/forms/locale-picker/locale-picker.class.js +1 -1
  147. package/dist/components/forms/otp-input/otp-input.class.js +1 -1
  148. package/dist/components/forms/phone-input/phone-input.class.js +1 -1
  149. package/dist/components/forms/radio/radio-group.class.js +1 -1
  150. package/dist/components/forms/radio/radio.class.js +1 -1
  151. package/dist/components/forms/rubric-form/rubric-form.class.js +4 -4
  152. package/dist/components/forms/select/select.class.js +1 -1
  153. package/dist/components/forms/signature-pad/signature-pad.class.js +1 -1
  154. package/dist/components/forms/slider/slider.class.js +1 -1
  155. package/dist/components/forms/switch/switch.class.js +1 -1
  156. package/dist/components/forms/textarea/textarea.class.js +1 -1
  157. package/dist/components/forms/time-range/time-range.class.js +1 -1
  158. package/dist/components/forms/time-zone-picker/time-zone-picker.class.js +1 -1
  159. package/dist/components/forms/token-input/token-input.class.js +1 -1
  160. package/dist/components/forms/unit-picker/unit-picker.class.js +1 -1
  161. package/dist/components/layout/app-rail/app-rail-item.class.js +1 -1
  162. package/dist/components/layout/app-rail/app-rail.class.d.ts +70 -7
  163. package/dist/components/layout/app-rail/app-rail.class.js +16 -4
  164. package/dist/components/layout/app-rail/app-rail.styles.js +1 -1
  165. package/dist/components/layout/app-rail-group/app-rail-group.class.js +1 -1
  166. package/dist/components/layout/breadcrumb/breadcrumb.class.js +1 -1
  167. package/dist/components/layout/card/card.class.js +1 -1
  168. package/dist/components/layout/carousel/carousel.class.js +1 -1
  169. package/dist/components/layout/command-palette/command-palette.class.js +1 -1
  170. package/dist/components/layout/dashboard-grid/dashboard-grid.class.js +1 -1
  171. package/dist/components/layout/details/accordion-item.class.js +1 -1
  172. package/dist/components/layout/details/details.class.js +1 -1
  173. package/dist/components/layout/dock-panel/dock-panel.class.js +1 -1
  174. package/dist/components/layout/drilldown-panel/drilldown-panel.class.js +1 -1
  175. package/dist/components/layout/filter-bar/filter-bar.class.js +1 -1
  176. package/dist/components/layout/menu/menu.class.js +1 -1
  177. package/dist/components/layout/menubar/menubar.class.js +1 -1
  178. package/dist/components/layout/multi-split/multi-split.class.js +1 -1
  179. package/dist/components/layout/navigation-menu/navigation-menu.class.js +1 -1
  180. package/dist/components/layout/page/page.class.js +1 -1
  181. package/dist/components/layout/reorder-list/reorder-item.class.js +1 -1
  182. package/dist/components/layout/reorder-list/reorder-list.class.js +1 -1
  183. package/dist/components/layout/responsive-panel/responsive-panel.class.js +1 -1
  184. package/dist/components/layout/scroller/scroller.class.js +1 -1
  185. package/dist/components/layout/segmented/segmented.class.d.ts +7 -4
  186. package/dist/components/layout/segmented/segmented.styles.js +1 -1
  187. package/dist/components/layout/split-panel/split-panel.class.js +1 -1
  188. package/dist/components/layout/tab-group/tab-group.class.js +1 -1
  189. package/dist/components/layout/tab-group/tab.class.js +1 -1
  190. package/dist/components/layout/virtual-list/virtual-list.styles.js +1 -1
  191. package/dist/components/layout/widget/widget.class.js +1 -1
  192. package/dist/components/media/animated-image/animated-image.class.js +1 -1
  193. package/dist/components/media/attachment-chip/attachment-chip.class.js +1 -1
  194. package/dist/components/media/attachment-trigger/attachment-trigger.class.js +2 -2
  195. package/dist/components/media/av-player/av-player.class.js +1 -1
  196. package/dist/components/media/avatar-group/avatar-group.class.js +1 -1
  197. package/dist/components/media/drop-zone/drop-zone.class.js +1 -1
  198. package/dist/components/media/file-icon/file-icon.class.js +1 -1
  199. package/dist/components/media/file-input/file-input.class.js +1 -1
  200. package/dist/components/media/flag/flag.class.js +1 -1
  201. package/dist/components/media/image-comparer/image-comparer.class.js +1 -1
  202. package/dist/components/media/image-viewer/image-viewer.class.d.ts +2 -1
  203. package/dist/components/media/image-viewer/image-viewer.class.js +4 -2
  204. package/dist/components/media/image-viewer/image-viewer.styles.js +1 -1
  205. package/dist/components/media/lightbox/lightbox.class.js +1 -1
  206. package/dist/components/media/map/map.class.js +1 -1
  207. package/dist/components/media/media-card/media-card.class.js +1 -1
  208. package/dist/components/media/pan-zoom/pan-zoom.class.js +1 -1
  209. package/dist/components/media/qr-code/qr-code.class.d.ts +2 -2
  210. package/dist/components/media/qr-code/qr-code.class.js +1 -1
  211. package/dist/components/media/sequence-playback/sequence-playback.class.js +1 -1
  212. package/dist/components/media/video/video.class.js +1 -1
  213. package/dist/components/media/video-playlist/video-playlist.class.js +1 -1
  214. package/dist/components/media/zoomable-frame/zoomable-frame.class.js +1 -1
  215. package/dist/components/overlays/alert/alert.class.js +1 -1
  216. package/dist/components/overlays/badge/tag.class.js +1 -1
  217. package/dist/components/overlays/callout/callout.class.js +1 -1
  218. package/dist/components/overlays/chip/chip-group.class.js +1 -1
  219. package/dist/components/overlays/chip/chip.class.js +1 -1
  220. package/dist/components/overlays/context-menu/context-menu.class.js +1 -1
  221. package/dist/components/overlays/dialog/confirm.js +1 -1
  222. package/dist/components/overlays/dialog/dialog.class.js +1 -1
  223. package/dist/components/overlays/kbd/kbd.class.js +1 -1
  224. package/dist/components/overlays/overlay/popover.class.js +1 -1
  225. package/dist/components/overlays/overlay/tooltip.class.js +1 -1
  226. package/dist/components/overlays/progress/progress-bar.class.js +1 -1
  227. package/dist/components/overlays/progress/progress-ring.class.js +1 -1
  228. package/dist/components/overlays/rating/rating.class.js +1 -1
  229. package/dist/components/overlays/skeleton/skeleton.class.js +1 -1
  230. package/dist/components/overlays/spinner/spinner.class.js +1 -1
  231. package/dist/components/overlays/toast/toast-item.class.js +1 -1
  232. package/dist/components/overlays/toast/toast.class.js +1 -1
  233. package/dist/components/retrieval/chunk-inspector/chunk-inspector.class.js +1 -1
  234. package/dist/components/retrieval/citation-badge/citation-badge.class.js +1 -1
  235. package/dist/components/retrieval/claim-evidence/claim-evidence.class.js +1 -1
  236. package/dist/components/retrieval/community-card/community-card.class.js +1 -1
  237. package/dist/components/retrieval/embedding-explorer/embedding-explorer.class.js +1 -1
  238. package/dist/components/retrieval/entity-card/entity-card.class.js +1 -1
  239. package/dist/components/retrieval/entity-chip/entity-chip.class.js +1 -1
  240. package/dist/components/retrieval/entity-dossier/entity-dossier.class.js +1 -1
  241. package/dist/components/retrieval/graph/graph.class.js +1 -1
  242. package/dist/components/retrieval/graph-legend/graph-legend.class.js +1 -1
  243. package/dist/components/retrieval/grounding-summary/grounding-summary.class.js +2 -2
  244. package/dist/components/retrieval/ingestion-queue/ingestion-queue.class.js +1 -1
  245. package/dist/components/retrieval/knowledge-base/knowledge-base.class.js +1 -1
  246. package/dist/components/retrieval/knowledge-base-admin/knowledge-base-admin.class.js +1 -1
  247. package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.js +1 -1
  248. package/dist/components/retrieval/memory-panel/memory-panel.class.js +1 -1
  249. package/dist/components/retrieval/mind-map/mind-map.class.js +1 -1
  250. package/dist/components/retrieval/neighbor-list/neighbor-list.class.js +1 -1
  251. package/dist/components/retrieval/node-palette/node-palette.class.js +1 -1
  252. package/dist/components/retrieval/path-strip/path-strip.class.js +1 -1
  253. package/dist/components/retrieval/provenance-panel/provenance-panel.class.js +1 -1
  254. package/dist/components/retrieval/rag-answer/rag-answer.class.js +1 -1
  255. package/dist/components/retrieval/rag-eval-dashboard/rag-eval-dashboard.class.js +1 -1
  256. package/dist/components/retrieval/research-progress/research-progress.class.js +1 -1
  257. package/dist/components/retrieval/retrieval-compare/retrieval-compare.class.js +1 -1
  258. package/dist/components/retrieval/retrieval-results/retrieval-results.class.js +1 -1
  259. package/dist/components/retrieval/retrieval-search/retrieval-search.class.js +1 -1
  260. package/dist/components/retrieval/retrieval-trace/retrieval-trace.class.js +1 -1
  261. package/dist/components/retrieval/source-card/source-card.class.js +1 -1
  262. package/dist/components/retrieval/source-list/source-list.class.js +1 -1
  263. package/dist/components/retrieval/source-picker/source-picker.class.js +1 -1
  264. package/dist/components/utility/copy-button/copy-button.class.js +1 -1
  265. package/dist/components/utility/diff-view/diff-view.class.js +1 -1
  266. package/dist/components/utility/export-button/export-button.class.js +1 -1
  267. package/dist/components/utility/icon/icon.class.js +1 -1
  268. package/dist/components/utility/json-viewer/json-viewer.class.js +1 -1
  269. package/dist/components/utility/known-date/known-date.class.js +1 -1
  270. package/dist/components/utility/mention-popover/mention-popover.class.js +1 -1
  271. package/dist/components/utility/poll-status/poll-status.class.js +1 -1
  272. package/dist/components/utility/random-content/random-content.class.js +1 -1
  273. package/dist/components/utility/tour/tour.class.js +1 -1
  274. package/dist/components/viewers/archive-viewer/archive-viewer.class.js +1 -1
  275. package/dist/components/viewers/calendar-viewer/calendar-viewer.class.js +1 -1
  276. package/dist/components/viewers/contact-viewer/contact-viewer.class.js +1 -1
  277. package/dist/components/viewers/csv-viewer/csv-viewer.class.js +1 -1
  278. package/dist/components/viewers/dataset-viewer/dataset-viewer.class.js +2 -2
  279. package/dist/components/viewers/document-compare/document-compare.class.js +1 -1
  280. package/dist/components/viewers/document-preview/document-preview.class.js +1 -1
  281. package/dist/components/viewers/document-viewer/document-viewer.class.js +1 -1
  282. package/dist/components/viewers/docx-viewer/docx-viewer.class.js +1 -1
  283. package/dist/components/viewers/ebook-viewer/ebook-viewer.class.js +1 -1
  284. package/dist/components/viewers/email-viewer/email-viewer.class.js +1 -1
  285. package/dist/components/viewers/geojson-view/geojson-view.class.js +1 -1
  286. package/dist/components/viewers/geojson-view/geojson-viewer.class.js +1 -1
  287. package/dist/components/viewers/highlight-layer/highlight-layer.class.js +1 -1
  288. package/dist/components/viewers/html-viewer/html-viewer.class.js +1 -1
  289. package/dist/components/viewers/include/include.class.js +1 -1
  290. package/dist/components/viewers/notebook-viewer/notebook-viewer.class.js +1 -1
  291. package/dist/components/viewers/page-rail/page-rail.class.d.ts +1 -1
  292. package/dist/components/viewers/page-rail/page-rail.class.js +3 -3
  293. package/dist/components/viewers/pdf-viewer/pdf-viewer.class.d.ts +2 -2
  294. package/dist/components/viewers/pdf-viewer/pdf-viewer.class.js +2 -2
  295. package/dist/components/viewers/pptx-viewer/pptx-viewer.class.js +1 -1
  296. package/dist/components/viewers/spreadsheet-viewer/spreadsheet-viewer.class.js +1 -1
  297. package/dist/components/viewers/svg-viewer/svg-viewer.class.js +1 -1
  298. package/dist/components/viewers/xml-viewer/xml-viewer.class.js +1 -1
  299. package/dist/events.d.ts +6 -1
  300. package/dist/framework-types.d.ts +1 -1
  301. package/dist/internal/accessibility-visibility.js +1 -1
  302. package/dist/internal/collection-snapshot.js +1 -1
  303. package/dist/internal/default-strings/agent-tools.generated.js +1 -0
  304. package/dist/internal/default-strings/charts.generated.js +1 -0
  305. package/dist/internal/default-strings/conversation.generated.js +1 -0
  306. package/dist/internal/default-strings/data.generated.js +1 -0
  307. package/dist/internal/default-strings/forms.generated.js +1 -0
  308. package/dist/internal/default-strings/layout.generated.js +1 -0
  309. package/dist/internal/default-strings/media.generated.js +1 -0
  310. package/dist/internal/default-strings/overlays.generated.js +1 -0
  311. package/dist/internal/default-strings/retrieval.generated.js +1 -0
  312. package/dist/internal/default-strings/shared.generated.js +1 -0
  313. package/dist/internal/default-strings/utility.generated.js +1 -0
  314. package/dist/internal/default-strings/viewers.generated.js +5 -0
  315. package/dist/internal/dev-mode-attribute-warning.development.js +1 -1
  316. package/dist/internal/dev-mode-attribute-warning.production.js +1 -1
  317. package/dist/internal/document-tokens.d.ts +11 -0
  318. package/dist/internal/document-tokens.generated.js +15 -0
  319. package/dist/internal/document-tokens.js +3 -0
  320. package/dist/internal/form-associated.d.ts +1 -1
  321. package/dist/internal/form-associated.js +1 -1
  322. package/dist/internal/glass-surface.styles.js +1 -1
  323. package/dist/internal/host-tokens.styles.js +1 -0
  324. package/dist/internal/image-zoom.js +1 -0
  325. package/dist/internal/intl-cache.js +1 -1
  326. package/dist/internal/localization-types.d.ts +1 -1
  327. package/dist/internal/localization.js +2 -2
  328. package/dist/internal/lyra-element.d.ts +4 -2
  329. package/dist/internal/lyra-element.js +2 -2
  330. package/dist/internal/nonmodal-overlay-manager.js +1 -1
  331. package/dist/internal/opaque-content-border.styles.js +1 -1
  332. package/dist/internal/open-overlay-ancestors.js +1 -0
  333. package/dist/internal/open-overlay-raise.styles.js +1 -0
  334. package/dist/internal/optional-peer-failure.js +1 -0
  335. package/dist/internal/package-metadata.js +1 -1
  336. package/dist/internal/prefix.js +1 -1
  337. package/dist/internal/specialist-host-tokens.styles.js +1 -0
  338. package/dist/internal/specialist-tokens.generated.js +2 -0
  339. package/dist/internal/step-value.js +1 -1
  340. package/dist/internal/theme-observation.js +1 -1
  341. package/dist/internal/theme-scopes.d.ts +11 -0
  342. package/dist/internal/theme-scopes.js +1 -0
  343. package/dist/looks/shadcn.css +1 -1
  344. package/dist/lyra.d.ts +1 -1
  345. package/dist/lyra.js +1 -1
  346. package/dist/styles/design-tokens.css +1 -1
  347. package/dist/styles/tokens-root.css +1 -1
  348. package/dist/surfaces/glass.css +1 -1
  349. package/dist/testing/happy-dom-shims.d.ts +22 -1
  350. package/dist/testing/happy-dom-shims.js +1 -1
  351. package/dist/testing/index.d.ts +1 -1
  352. package/dist/testing/index.js +1 -1
  353. package/dist/testing/interaction-drivers.d.ts +66 -7
  354. package/dist/testing/interaction-drivers.js +1 -1
  355. package/dist/testing/jsdom-shims.d.ts +70 -0
  356. package/dist/testing/jsdom-shims.js +1 -0
  357. package/dist/theme/look-inputs.d.ts +1 -1
  358. package/dist/theme/look-inputs.js +37 -41
  359. package/dist/theme/theme.d.ts +13 -0
  360. package/dist/theme/theme.js +1 -1
  361. package/dist/theme.css +1 -1
  362. package/dist/utilities/index.d.ts +1 -1
  363. package/dist/utilities/index.js +1 -1
  364. package/dist/utilities/scoped-registry.d.ts +3 -0
  365. package/dist/utilities/scoped-registry.js +1 -1
  366. package/dist/utilities/theme-scopes.d.ts +1 -0
  367. package/dist/utilities/theme-scopes.js +1 -0
  368. package/dist/utilities/tokens.d.ts +1 -0
  369. package/dist/utilities/tokens.js +1 -0
  370. package/llms/components/lr-app-rail.md +51 -4
  371. package/llms/components/lr-box-plot.md +5 -0
  372. package/llms/components/lr-chart.md +6 -0
  373. package/llms/components/lr-emoji-picker.md +13 -8
  374. package/llms/components/lr-heatmap.md +10 -2
  375. package/llms/components/lr-icon-button.md +13 -1
  376. package/llms/components/lr-image-viewer.md +8 -0
  377. package/llms/components/lr-pagination.md +4 -2
  378. package/llms/components/lr-segmented.md +7 -3
  379. package/llms/components/lr-table.md +14 -12
  380. package/llms/components/lr-thread-list.md +4 -3
  381. package/llms/migration.md +9 -0
  382. package/llms/peers.md +1 -1
  383. package/llms/shared/events-and-types.md +41 -0
  384. package/llms/shared/frameworks-and-ssr.md +16 -0
  385. package/llms/shared/imports-and-registration.md +4 -3
  386. package/llms/shared/native-styles-and-utilities.md +38 -3
  387. package/llms/shared/styles-and-tokens.md +242 -102
  388. package/llms/shared/testing-and-utilities.md +104 -7
  389. package/llms/shared.md +445 -115
  390. package/llms/tokens.md +31 -49
  391. package/locales.json +138 -138
  392. package/package.json +16 -8
  393. package/registrations.json +1 -1
  394. package/dist/internal/default-strings.generated.js +0 -5
  395. package/dist/internal/specialist-tokens.styles.js +0 -1
  396. package/dist/internal/tokens/palette.styles.js +0 -1
  397. package/dist/internal/tokens.styles.js +0 -1
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{emitValueEvents}from"../../../internal/value-events.js";import{FormControlController,reflectFormName}from"../../../internal/form-control-controller.js";import{html,svg}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{LyraFormControlElement}from"../../../internal/form-control-element.js";import{finiteCount,finiteNumber,finiteRange}from"../../../internal/numbers.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{clampSteppedValue}from"../../../internal/step-value.js";import{getFormOwner,isBarredFromValidation,setFormOwner}from"../../../internal/form-associated.js";import{syncValidityStates}from"../../../internal/custom-states.js";import{VALIDITY_ANCHOR}from"../../../internal/anchored-validity.js";import{normalizeSize}from"../../../internal/variants.js";import{styles}from"./rating.styles.js";import{omittedEmptyStringConverter}from"../../../internal/converters.js";import{installFormControlLabelSupport,EXTERNAL_LABEL_HOST_SEMANTICS}from"../../../internal/form-control-labels.js";import{currentValidityValidator}from"../../forms/form-validator.js";import{LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_rating}from"../../../internal/default-strings.generated.js";installFormControlLabelSupport();const DEFAULT_MAX=5,MAX_STARS=100,DEFAULT_PRECISION=1,MANAGED_ARIA_LABEL_ATTRIBUTE="data-lr-rating-managed-label",MIN_PRECISION=.01,PAGE_STEPS=10,STAR_POINTS="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2";function starOutline(){return svg`<svg width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linejoin="round" aria-hidden="true" focusable="false"><polygon points=${STAR_POINTS}></polygon></svg>`}function starSolid(){return svg`<svg width="1em" height="1em" viewBox="0 0 24 24" fill="currentColor" stroke="none" aria-hidden="true" focusable="false"><polygon points=${STAR_POINTS}></polygon></svg>`}class LyraRating extends LyraFormControlElement{static{this.defaultStrings={...super.defaultStrings,fieldRequired:LYRA_DEFAULT_fieldRequired,rating:LYRA_DEFAULT_rating}}static get validators(){return[currentValidityValidator("required","disabled","readonly","value","max")]}static{this.formAssociated=!0}static{this.styles=[LyraElement.styles,styles]}static get observedAttributes(){return[...new Set([...super.observedAttributes,"role"])]}static{this.properties={customError:{attribute:"custom-error",reflect:!0,noAccessor:!0},value:{attribute:"value",type:Number,noAccessor:!0},defaultValue:{attribute:!1,noAccessor:!0},max:{type:Number,noAccessor:!0},name:{reflect:!0,noAccessor:!0,converter:omittedEmptyStringConverter},required:{type:Boolean,reflect:!0,noAccessor:!0},disabled:{type:Boolean,reflect:!0,noAccessor:!0}}}get effectiveSize(){const value=this.size;return["2xs","xs","s","m","l","xl","small","medium","large"].includes(value)?normalizeSize(value):"m"}get defaultValueAlias(){return this.defaultValue}set defaultValueAlias(next){this.defaultValue=finiteNumber(next??0,0)}get rating(){return this.renderRoot.querySelector('[part~="rating"]')}constructor(){super(),this.precision=1,this.readonly=!1,this.accessibleLabel="",this.label="",this.size="m",this.hoverValue=0,this.hovering=!1,this._value=0,this._max=DEFAULT_MAX,this._name="",this._required=!1,this._disabled=!1,this._fieldsetDisabled=!1,this._defaultValue=0,this._valueDirty=!1,this.settingDefaultValue=!1,this.reflectingDefaultValue=!1,this._hasInteracted=!1,this.authorAriaLabel=null,this.syncingHostSemantics=!1,this.externalLabelNameActive=!1,this.markInteracted=()=>{this._hasInteracted||(this._hasInteracted=!0,this.syncValidityStates(),this.syncHostSemantics())},this.markBlurInteracted=()=>{this.effectiveDisabled||this.matches(":disabled")||this.markInteracted()},this.onClick=event=>{const next=this.pointerValue(event);next!==null&&this.setValue(next)},this.onPointerEnter=event=>{this.interactive&&(this.hovering=!0,this.hoverValue=this.pointerValue(event)??this.hoverValue,this.emit("lr-hover",{phase:"start",value:this.hoverValue}))},this.onPointerMove=event=>{if(!this.interactive)return;const next=this.pointerValue(event);if(next!==null){if(!this.hovering){this.hovering=!0,this.hoverValue=next,this.emit("lr-hover",{phase:"start",value:next});return}next!==this.hoverValue&&(this.hoverValue=next,this.emit("lr-hover",{phase:"move",value:next}))}},this.onPointerEnd=()=>{this.hovering&&(this.hovering=!1,this.emit("lr-hover",{phase:"end",value:this.hoverValue}))},this.onKeyDown=event=>{const forwardKey=this.effectiveDirection==="rtl"?"ArrowLeft":"ArrowRight",backwardKey=this.effectiveDirection==="rtl"?"ArrowRight":"ArrowLeft";(event.key===forwardKey||event.key==="ArrowUp")&&(event.preventDefault(),this.setValue(this.safeValue+this.safePrecision)),(event.key===backwardKey||event.key==="ArrowDown")&&(event.preventDefault(),this.setValue(this.safeValue-this.safePrecision)),event.key==="PageUp"&&(event.preventDefault(),this.setValue(this.safeValue+this.safePrecision*PAGE_STEPS)),event.key==="PageDown"&&(event.preventDefault(),this.setValue(this.safeValue-this.safePrecision*PAGE_STEPS)),event.key==="Home"&&(event.preventDefault(),this.setValue(0)),event.key==="End"&&(event.preventDefault(),this.setValue(this.safeMax))},this.onHostKeyDown=event=>{event.composedPath()[0]===this&&this.onKeyDown(event)},this.onBlur=event=>{event.target===this&&this.markBlurInteracted()},this.validityController=new FormControlController(this,{invalid:init=>this.emit("lr-invalid",null,init),interacted:this.markInteracted,customError:()=>this.validityController.customValidityMessage}),this.internals=this.validityController.formInternals,this.internals.setFormValue("0"),this.addEventListener("focusout",this.markBlurInteracted),this.addEventListener("keydown",this.onHostKeyDown),this.addEventListener("blur",this.onBlur),this.syncValidityStates()}attributeChangedCallback(name,oldValue,value){if(!(this.syncingHostSemantics&&(name==="aria-label"||name==="role"))){if(super.attributeChangedCallback(name,oldValue,value),name==="aria-label"){const managed=this.getAttribute(MANAGED_ARIA_LABEL_ATTRIBUTE),rehydratedManagedName=oldValue===null&&managed!==null&&managed===value;if(this.authorAriaLabel=rehydratedManagedName?null:value,!rehydratedManagedName){this.syncingHostSemantics=!0;try{this.removeAttribute(MANAGED_ARIA_LABEL_ATTRIBUTE)}finally{this.syncingHostSemantics=!1}}}if(name==="role"&&value!=="slider"){this.syncingHostSemantics=!0;try{this.setAttribute("role","slider")}finally{this.syncingHostSemantics=!1}}}}[EXTERNAL_LABEL_HOST_SEMANTICS](operation){if(operation.type==="has-authored-name")return this.authorAriaLabel!==null;if(operation.type==="apply"){this.externalLabelNameActive=!0,this.syncingHostSemantics=!0;try{this.setAttribute(MANAGED_ARIA_LABEL_ATTRIBUTE,operation.name),this.getAttribute("aria-label")!==operation.name&&this.setAttribute("aria-label",operation.name)}finally{this.syncingHostSemantics=!1}return}this.externalLabelNameActive=!1,this.syncingHostSemantics=!0;try{if(this.getAttribute("aria-label")===operation.appliedName)if(operation.hadPrevious){const previous=operation.previous??"";this.setAttribute(MANAGED_ARIA_LABEL_ATTRIBUTE,previous),this.setAttribute("aria-label",previous)}else this.removeAttribute(MANAGED_ARIA_LABEL_ATTRIBUTE),this.removeAttribute("aria-label")}finally{this.syncingHostSemantics=!1}this.authorAriaLabel===null&&this.syncHostSemantics()}get value(){return this._value}set value(next){const old=this._value;this.settingDefaultValue||(this._valueDirty=!0),this._value=typeof next=="number"?next:Number(next),this.syncFormValue(),this.requestUpdate("value",old)}get defaultValue(){return this._defaultValue}set defaultValue(next){if(this.reflectingDefaultValue)return;const old=this._defaultValue;this._defaultValue=next==null?0:typeof next=="number"?next:Number(next),this.reflectingDefaultValue=!0;try{next==null?this.removeAttribute("default-value"):this.setAttribute("default-value",String(this._defaultValue))}finally{this.reflectingDefaultValue=!1}this._valueDirty||this.restoreLiveValueFromDefault(),this.requestUpdate("defaultValue",old)}get max(){return this._max}set max(next){const old=this._max;this._max=typeof next=="number"?next:Number(next),this.syncFormValue(),this.requestUpdate("max",old)}get name(){return this._name}set name(next){const old=this._name;this._name=next??"",reflectFormName(this,this._name),this.requestUpdate("name",old)}get required(){return this._required}set required(next){const old=this._required;this._required=!!next,this.toggleAttribute("required",this._required),this.updateValidity(),this.requestUpdate("required",old)}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this._fieldsetDisabled=this.validityController?.fieldsetDisabled(this._fieldsetDisabled)??this._fieldsetDisabled,this._disabled&&this.resetHover(),this.updateValidity(),this.requestUpdate("disabled",old)}get effectiveDisabled(){return this.disabled||this._fieldsetDisabled}get form(){return getFormOwner(this.internals)}set form(owner){setFormOwner(this,owner)}[VALIDITY_ANCHOR](){return this.renderRoot?.querySelector('[part~="base"]')??null}checkValidity(){return this.validityController.checkValidity(()=>this.updateValidity())}reportValidity(){return this.validityController.syncConstraints(),this.updateValidity(),this.markInteracted(),this.internals.reportValidity()}setCustomValidity(message){this.validityController.setCustomValidity(message??""),this.syncValidityStates(),this.syncHostSemantics()}resetValidity(){this.setCustomValidity("")}formResetCallback(){this.resetHover(),this.restoreLiveValueFromDefault(),this._hasInteracted=!1,this.syncValidityStates(),this.syncHostSemantics()}formStateRestoreCallback(state2,reason){this.value=typeof state2=="string"?finiteNumber(Number(state2),0):0}restoreLiveValueFromDefault(){this.settingDefaultValue=!0;try{this.value=this._defaultValue}finally{this.settingDefaultValue=!1}this._valueDirty=!1}formDisabledCallback(fieldsetDisabled){if(this.validityController?.reflectingDisabled)return;const wasDisabled=this.effectiveDisabled;this._fieldsetDisabled=fieldsetDisabled,wasDisabled!==this.effectiveDisabled&&(fieldsetDisabled&&this.resetHover(),this.updateValidity(),this.requestUpdate())}connectedCallback(){super.connectedCallback(),this.updateValidity(),this.syncHostSemantics()}disconnectedCallback(){super.disconnectedCallback(),this.resetHover()}get safeMax(){return finiteCount(this.max,DEFAULT_MAX,MAX_STARS)}get safeValue(){return finiteRange(this.value,0,0,this.safeMax)}get safePrecision(){const precision=finiteRange(this.precision,DEFAULT_PRECISION,MIN_PRECISION,this.safeMax);return precision>0?precision:DEFAULT_PRECISION}get interactive(){return!this.effectiveDisabled&&!this.readonly}syncFormValue(){this.internals&&(this.internals.setFormValue(String(this.safeValue)),this.updateValidity())}get barredFromValidation(){return isBarredFromValidation(this,this.internals)}updateValidity(){this.validityController&&(this.barredFromValidation?this.validityController.setValidity({}):this.required&&this.safeValue<=0?this.validityController.setValidity({valueMissing:!0},this.localize("fieldRequired")):this.validityController.setValidity({}),this.syncValidityStates())}syncValidityStates(){syncValidityStates(this.internals,{required:this.required,hasInteracted:this._hasInteracted,barred:this.barredFromValidation})}setValue(next){if(!this.interactive)return;this.markInteracted();const clamped=clampSteppedValue(next,0,this.safeMax,this.safePrecision);if(clamped!==this.value){this.value=clamped;const detail={value:this.value};emitValueEvents(this,"input",detail,detail2=>this.emit("lr-input",detail2)),emitValueEvents(this,"change",detail,detail2=>this.emit("lr-change",detail2))}this.emit("lr-activate",{value:clamped})}pointerValue(event){const target=event.target?.closest?.("[data-value]");if(!target)return null;const star=Number(target.dataset.value);if(!Number.isFinite(star))return null;const rect=target.getBoundingClientRect(),precision=this.safePrecision;if(rect.width<=0)return Math.max(0,Math.min(this.safeMax,star));const physicalFraction=Math.max(0,Math.min(1,(event.clientX-rect.left)/rect.width)),logicalFraction=this.effectiveDirection==="rtl"?1-physicalFraction:physicalFraction,rawValue=star-1+logicalFraction;return Math.max(precision,clampSteppedValue(Math.ceil(rawValue/precision)*precision,0,this.safeMax,precision))}resetHover(){this.hovering=!1,this.hoverValue=0}focus(options){this.effectiveDisabled||super.focus(options)}blur(){super.blur()}click(){this.effectiveDisabled||super.click()}captureHostNameProvenance(){if(this.externalLabelNameActive||this.authorAriaLabel!==null)return;const current=this.getAttribute("aria-label");if(current===null)return;const managed=this.getAttribute(MANAGED_ARIA_LABEL_ATTRIBUTE);if(managed!==current&&(this.authorAriaLabel=current,managed!==null)){this.syncingHostSemantics=!0;try{this.removeAttribute(MANAGED_ARIA_LABEL_ATTRIBUTE)}finally{this.syncingHostSemantics=!1}}}syncHostSemantics(){this.captureHostNameProvenance();const safeMax=this.safeMax,safeValue=this.safeValue,label=typeof this.label=="string"&&this.label.trim()===""?"":this.label,generatedLabel=this.accessibleLabel||label||this.localize("rating");this.syncingHostSemantics=!0;try{this.setAttribute("role","slider"),this.setAttribute("tabindex",this.effectiveDisabled?"-1":"0"),this.setAttribute("aria-valuemin","0"),this.setAttribute("aria-valuemax",String(safeMax)),this.setAttribute("aria-valuenow",String(safeValue)),this.setAttribute("aria-valuetext",getNumberFormat(this.effectiveLocale).format(safeValue)),this.setAttribute("aria-disabled",this.effectiveDisabled?"true":"false"),this.setAttribute("aria-readonly",this.readonly?"true":"false"),this.setAttribute("aria-required",this.required?"true":"false"),this.setAttribute("aria-invalid",this._hasInteracted&&!this.internals.validity.valid?"true":"false"),this.setAttribute("data-effective-size",this.effectiveSize),!this.externalLabelNameActive&&this.authorAriaLabel===null&&this.getAttribute("aria-label")!==generatedLabel?(this.setAttribute(MANAGED_ARIA_LABEL_ATTRIBUTE,generatedLabel),this.setAttribute("aria-label",generatedLabel)):!this.externalLabelNameActive&&this.authorAriaLabel===null&&this.setAttribute(MANAGED_ARIA_LABEL_ATTRIBUTE,generatedLabel)}finally{this.syncingHostSemantics=!1}}willUpdate(changed){super.willUpdate(changed),changed.has("readonly")&&!this.interactive&&this.resetHover(),this.syncHostSemantics()}updated(changed){super.updated(changed),changed.has("readonly")&&(this.updateValidity(),this.syncHostSemantics())}symbol(star,selected){return this.getSymbol?this.getSymbol(star,selected):selected?starSolid():starOutline()}renderSymbol(star,selected){return html`<span aria-hidden="true" inert style="pointer-events: none"
1
+ import{__decorate}from"tslib";import{emitValueEvents}from"../../../internal/value-events.js";import{FormControlController,reflectFormName}from"../../../internal/form-control-controller.js";import{html,svg}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{LyraFormControlElement}from"../../../internal/form-control-element.js";import{finiteCount,finiteNumber,finiteRange}from"../../../internal/numbers.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{clampSteppedValue}from"../../../internal/step-value.js";import{getFormOwner,isBarredFromValidation,setFormOwner}from"../../../internal/form-associated.js";import{syncValidityStates}from"../../../internal/custom-states.js";import{VALIDITY_ANCHOR}from"../../../internal/anchored-validity.js";import{normalizeSize}from"../../../internal/variants.js";import{styles}from"./rating.styles.js";import{omittedEmptyStringConverter}from"../../../internal/converters.js";import{installFormControlLabelSupport,EXTERNAL_LABEL_HOST_SEMANTICS}from"../../../internal/form-control-labels.js";import{currentValidityValidator}from"../../forms/form-validator.js";import{LYRA_DEFAULT_rating}from"../../../internal/default-strings/overlays.generated.js";import{LYRA_DEFAULT_fieldRequired}from"../../../internal/default-strings/shared.generated.js";installFormControlLabelSupport();const DEFAULT_MAX=5,MAX_STARS=100,DEFAULT_PRECISION=1,MANAGED_ARIA_LABEL_ATTRIBUTE="data-lr-rating-managed-label",MIN_PRECISION=.01,PAGE_STEPS=10,STAR_POINTS="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2";function starOutline(){return svg`<svg width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linejoin="round" aria-hidden="true" focusable="false"><polygon points=${STAR_POINTS}></polygon></svg>`}function starSolid(){return svg`<svg width="1em" height="1em" viewBox="0 0 24 24" fill="currentColor" stroke="none" aria-hidden="true" focusable="false"><polygon points=${STAR_POINTS}></polygon></svg>`}class LyraRating extends LyraFormControlElement{static{this.defaultStrings={...super.defaultStrings,fieldRequired:LYRA_DEFAULT_fieldRequired,rating:LYRA_DEFAULT_rating}}static get validators(){return[currentValidityValidator("required","disabled","readonly","value","max")]}static{this.formAssociated=!0}static{this.styles=[LyraElement.styles,styles]}static get observedAttributes(){return[...new Set([...super.observedAttributes,"role"])]}static{this.properties={customError:{attribute:"custom-error",reflect:!0,noAccessor:!0},value:{attribute:"value",type:Number,noAccessor:!0},defaultValue:{attribute:!1,noAccessor:!0},max:{type:Number,noAccessor:!0},name:{reflect:!0,noAccessor:!0,converter:omittedEmptyStringConverter},required:{type:Boolean,reflect:!0,noAccessor:!0},disabled:{type:Boolean,reflect:!0,noAccessor:!0}}}get effectiveSize(){const value=this.size;return["2xs","xs","s","m","l","xl","small","medium","large"].includes(value)?normalizeSize(value):"m"}get defaultValueAlias(){return this.defaultValue}set defaultValueAlias(next){this.defaultValue=finiteNumber(next??0,0)}get rating(){return this.renderRoot.querySelector('[part~="rating"]')}constructor(){super(),this.precision=1,this.readonly=!1,this.accessibleLabel="",this.label="",this.size="m",this.hoverValue=0,this.hovering=!1,this._value=0,this._max=DEFAULT_MAX,this._name="",this._required=!1,this._disabled=!1,this._fieldsetDisabled=!1,this._defaultValue=0,this._valueDirty=!1,this.settingDefaultValue=!1,this.reflectingDefaultValue=!1,this._hasInteracted=!1,this.authorAriaLabel=null,this.syncingHostSemantics=!1,this.externalLabelNameActive=!1,this.markInteracted=()=>{this._hasInteracted||(this._hasInteracted=!0,this.syncValidityStates(),this.syncHostSemantics())},this.markBlurInteracted=()=>{this.effectiveDisabled||this.matches(":disabled")||this.markInteracted()},this.onClick=event=>{const next=this.pointerValue(event);next!==null&&this.setValue(next)},this.onPointerEnter=event=>{this.interactive&&(this.hovering=!0,this.hoverValue=this.pointerValue(event)??this.hoverValue,this.emit("lr-hover",{phase:"start",value:this.hoverValue}))},this.onPointerMove=event=>{if(!this.interactive)return;const next=this.pointerValue(event);if(next!==null){if(!this.hovering){this.hovering=!0,this.hoverValue=next,this.emit("lr-hover",{phase:"start",value:next});return}next!==this.hoverValue&&(this.hoverValue=next,this.emit("lr-hover",{phase:"move",value:next}))}},this.onPointerEnd=()=>{this.hovering&&(this.hovering=!1,this.emit("lr-hover",{phase:"end",value:this.hoverValue}))},this.onKeyDown=event=>{const forwardKey=this.effectiveDirection==="rtl"?"ArrowLeft":"ArrowRight",backwardKey=this.effectiveDirection==="rtl"?"ArrowRight":"ArrowLeft";(event.key===forwardKey||event.key==="ArrowUp")&&(event.preventDefault(),this.setValue(this.safeValue+this.safePrecision)),(event.key===backwardKey||event.key==="ArrowDown")&&(event.preventDefault(),this.setValue(this.safeValue-this.safePrecision)),event.key==="PageUp"&&(event.preventDefault(),this.setValue(this.safeValue+this.safePrecision*PAGE_STEPS)),event.key==="PageDown"&&(event.preventDefault(),this.setValue(this.safeValue-this.safePrecision*PAGE_STEPS)),event.key==="Home"&&(event.preventDefault(),this.setValue(0)),event.key==="End"&&(event.preventDefault(),this.setValue(this.safeMax))},this.onHostKeyDown=event=>{event.composedPath()[0]===this&&this.onKeyDown(event)},this.onBlur=event=>{event.target===this&&this.markBlurInteracted()},this.validityController=new FormControlController(this,{invalid:init=>this.emit("lr-invalid",null,init),interacted:this.markInteracted,customError:()=>this.validityController.customValidityMessage}),this.internals=this.validityController.formInternals,this.internals.setFormValue("0"),this.addEventListener("focusout",this.markBlurInteracted),this.addEventListener("keydown",this.onHostKeyDown),this.addEventListener("blur",this.onBlur),this.syncValidityStates()}attributeChangedCallback(name,oldValue,value){if(!(this.syncingHostSemantics&&(name==="aria-label"||name==="role"))){if(super.attributeChangedCallback(name,oldValue,value),name==="aria-label"){const managed=this.getAttribute(MANAGED_ARIA_LABEL_ATTRIBUTE),rehydratedManagedName=oldValue===null&&managed!==null&&managed===value;if(this.authorAriaLabel=rehydratedManagedName?null:value,!rehydratedManagedName){this.syncingHostSemantics=!0;try{this.removeAttribute(MANAGED_ARIA_LABEL_ATTRIBUTE)}finally{this.syncingHostSemantics=!1}}}if(name==="role"&&value!=="slider"){this.syncingHostSemantics=!0;try{this.setAttribute("role","slider")}finally{this.syncingHostSemantics=!1}}}}[EXTERNAL_LABEL_HOST_SEMANTICS](operation){if(operation.type==="has-authored-name")return this.authorAriaLabel!==null;if(operation.type==="apply"){this.externalLabelNameActive=!0,this.syncingHostSemantics=!0;try{this.setAttribute(MANAGED_ARIA_LABEL_ATTRIBUTE,operation.name),this.getAttribute("aria-label")!==operation.name&&this.setAttribute("aria-label",operation.name)}finally{this.syncingHostSemantics=!1}return}this.externalLabelNameActive=!1,this.syncingHostSemantics=!0;try{if(this.getAttribute("aria-label")===operation.appliedName)if(operation.hadPrevious){const previous=operation.previous??"";this.setAttribute(MANAGED_ARIA_LABEL_ATTRIBUTE,previous),this.setAttribute("aria-label",previous)}else this.removeAttribute(MANAGED_ARIA_LABEL_ATTRIBUTE),this.removeAttribute("aria-label")}finally{this.syncingHostSemantics=!1}this.authorAriaLabel===null&&this.syncHostSemantics()}get value(){return this._value}set value(next){const old=this._value;this.settingDefaultValue||(this._valueDirty=!0),this._value=typeof next=="number"?next:Number(next),this.syncFormValue(),this.requestUpdate("value",old)}get defaultValue(){return this._defaultValue}set defaultValue(next){if(this.reflectingDefaultValue)return;const old=this._defaultValue;this._defaultValue=next==null?0:typeof next=="number"?next:Number(next),this.reflectingDefaultValue=!0;try{next==null?this.removeAttribute("default-value"):this.setAttribute("default-value",String(this._defaultValue))}finally{this.reflectingDefaultValue=!1}this._valueDirty||this.restoreLiveValueFromDefault(),this.requestUpdate("defaultValue",old)}get max(){return this._max}set max(next){const old=this._max;this._max=typeof next=="number"?next:Number(next),this.syncFormValue(),this.requestUpdate("max",old)}get name(){return this._name}set name(next){const old=this._name;this._name=next??"",reflectFormName(this,this._name),this.requestUpdate("name",old)}get required(){return this._required}set required(next){const old=this._required;this._required=!!next,this.toggleAttribute("required",this._required),this.updateValidity(),this.requestUpdate("required",old)}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this._fieldsetDisabled=this.validityController?.fieldsetDisabled(this._fieldsetDisabled)??this._fieldsetDisabled,this._disabled&&this.resetHover(),this.updateValidity(),this.requestUpdate("disabled",old)}get effectiveDisabled(){return this.disabled||this._fieldsetDisabled}get form(){return getFormOwner(this.internals)}set form(owner){setFormOwner(this,owner)}[VALIDITY_ANCHOR](){return this.renderRoot?.querySelector('[part~="base"]')??null}checkValidity(){return this.validityController.checkValidity(()=>this.updateValidity())}reportValidity(){return this.validityController.syncConstraints(),this.updateValidity(),this.markInteracted(),this.internals.reportValidity()}setCustomValidity(message){this.validityController.setCustomValidity(message??""),this.syncValidityStates(),this.syncHostSemantics()}resetValidity(){this.setCustomValidity("")}formResetCallback(){this.resetHover(),this.restoreLiveValueFromDefault(),this._hasInteracted=!1,this.syncValidityStates(),this.syncHostSemantics()}formStateRestoreCallback(state2,reason){this.value=typeof state2=="string"?finiteNumber(Number(state2),0):0}restoreLiveValueFromDefault(){this.settingDefaultValue=!0;try{this.value=this._defaultValue}finally{this.settingDefaultValue=!1}this._valueDirty=!1}formDisabledCallback(fieldsetDisabled){if(this.validityController?.reflectingDisabled)return;const wasDisabled=this.effectiveDisabled;this._fieldsetDisabled=fieldsetDisabled,wasDisabled!==this.effectiveDisabled&&(fieldsetDisabled&&this.resetHover(),this.updateValidity(),this.requestUpdate())}connectedCallback(){super.connectedCallback(),this.updateValidity(),this.syncHostSemantics()}disconnectedCallback(){super.disconnectedCallback(),this.resetHover()}get safeMax(){return finiteCount(this.max,DEFAULT_MAX,MAX_STARS)}get safeValue(){return finiteRange(this.value,0,0,this.safeMax)}get safePrecision(){const precision=finiteRange(this.precision,DEFAULT_PRECISION,MIN_PRECISION,this.safeMax);return precision>0?precision:DEFAULT_PRECISION}get interactive(){return!this.effectiveDisabled&&!this.readonly}syncFormValue(){this.internals&&(this.internals.setFormValue(String(this.safeValue)),this.updateValidity())}get barredFromValidation(){return isBarredFromValidation(this,this.internals)}updateValidity(){this.validityController&&(this.barredFromValidation?this.validityController.setValidity({}):this.required&&this.safeValue<=0?this.validityController.setValidity({valueMissing:!0},this.localize("fieldRequired")):this.validityController.setValidity({}),this.syncValidityStates())}syncValidityStates(){syncValidityStates(this.internals,{required:this.required,hasInteracted:this._hasInteracted,barred:this.barredFromValidation})}setValue(next){if(!this.interactive)return;this.markInteracted();const clamped=clampSteppedValue(next,0,this.safeMax,this.safePrecision);if(clamped!==this.value){this.value=clamped;const detail={value:this.value};emitValueEvents(this,"input",detail,detail2=>this.emit("lr-input",detail2)),emitValueEvents(this,"change",detail,detail2=>this.emit("lr-change",detail2))}this.emit("lr-activate",{value:clamped})}pointerValue(event){const target=event.target?.closest?.("[data-value]");if(!target)return null;const star=Number(target.dataset.value);if(!Number.isFinite(star))return null;const rect=target.getBoundingClientRect(),precision=this.safePrecision;if(rect.width<=0)return Math.max(0,Math.min(this.safeMax,star));const physicalFraction=Math.max(0,Math.min(1,(event.clientX-rect.left)/rect.width)),logicalFraction=this.effectiveDirection==="rtl"?1-physicalFraction:physicalFraction,rawValue=star-1+logicalFraction;return Math.max(precision,clampSteppedValue(Math.ceil(rawValue/precision)*precision,0,this.safeMax,precision))}resetHover(){this.hovering=!1,this.hoverValue=0}focus(options){this.effectiveDisabled||super.focus(options)}blur(){super.blur()}click(){this.effectiveDisabled||super.click()}captureHostNameProvenance(){if(this.externalLabelNameActive||this.authorAriaLabel!==null)return;const current=this.getAttribute("aria-label");if(current===null)return;const managed=this.getAttribute(MANAGED_ARIA_LABEL_ATTRIBUTE);if(managed!==current&&(this.authorAriaLabel=current,managed!==null)){this.syncingHostSemantics=!0;try{this.removeAttribute(MANAGED_ARIA_LABEL_ATTRIBUTE)}finally{this.syncingHostSemantics=!1}}}syncHostSemantics(){this.captureHostNameProvenance();const safeMax=this.safeMax,safeValue=this.safeValue,label=typeof this.label=="string"&&this.label.trim()===""?"":this.label,generatedLabel=this.accessibleLabel||label||this.localize("rating");this.syncingHostSemantics=!0;try{this.setAttribute("role","slider"),this.setAttribute("tabindex",this.effectiveDisabled?"-1":"0"),this.setAttribute("aria-valuemin","0"),this.setAttribute("aria-valuemax",String(safeMax)),this.setAttribute("aria-valuenow",String(safeValue)),this.setAttribute("aria-valuetext",getNumberFormat(this.effectiveLocale).format(safeValue)),this.setAttribute("aria-disabled",this.effectiveDisabled?"true":"false"),this.setAttribute("aria-readonly",this.readonly?"true":"false"),this.setAttribute("aria-required",this.required?"true":"false"),this.setAttribute("aria-invalid",this._hasInteracted&&!this.internals.validity.valid?"true":"false"),this.setAttribute("data-effective-size",this.effectiveSize),!this.externalLabelNameActive&&this.authorAriaLabel===null&&this.getAttribute("aria-label")!==generatedLabel?(this.setAttribute(MANAGED_ARIA_LABEL_ATTRIBUTE,generatedLabel),this.setAttribute("aria-label",generatedLabel)):!this.externalLabelNameActive&&this.authorAriaLabel===null&&this.setAttribute(MANAGED_ARIA_LABEL_ATTRIBUTE,generatedLabel)}finally{this.syncingHostSemantics=!1}}willUpdate(changed){super.willUpdate(changed),changed.has("readonly")&&!this.interactive&&this.resetHover(),this.syncHostSemantics()}updated(changed){super.updated(changed),changed.has("readonly")&&(this.updateValidity(),this.syncHostSemantics())}symbol(star,selected){return this.getSymbol?this.getSymbol(star,selected):selected?starSolid():starOutline()}renderSymbol(star,selected){return html`<span aria-hidden="true" inert style="pointer-events: none"
2
2
  >${this.symbol(star,selected)}</span
3
3
  >`}render(){const safeMax=this.safeMax,safeValue=this.safeValue,displayValue=this.hovering&&this.interactive?Math.min(this.hoverValue,safeMax):safeValue,count=Math.round(safeMax);return html`<div
4
4
  part="base rating"
@@ -1 +1 @@
1
- import{__decorate}from"tslib";import{html}from"lit";import{property}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{styles}from"./skeleton.styles.js";import{LYRA_DEFAULT_loading}from"../../../internal/default-strings.generated.js";class LyraSkeleton extends LyraElement{constructor(){super(...arguments),this.shape="text",this.effect="none",this.announce=!1}static{this.defaultStrings={...super.defaultStrings,loading:LYRA_DEFAULT_loading}}static{this.styles=[LyraElement.styles,styles]}disconnectedCallback(){this.sink?.release(),this.sink=void 0,super.disconnectedCallback()}updated(changed){super.updated(changed),this.announce?(changed.has("announce")||changed.has("label"))&&import("../../../internal/announcer.js").then(({acquireAnnouncementSink})=>{!this.announce||!this.isConnected||(this.sink??=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}),this.ownerDocument.defaultView?.requestAnimationFrame(()=>{this.announce&&this.sink?.announce(this.label??this.localize("loading"))}))}):(this.sink?.release(),this.sink=void 0)}willUpdate(changed){super.willUpdate(changed),changed.has("width")&&this.applySize("--lr-skeleton-w",this.width),changed.has("height")&&this.applySize("--lr-skeleton-h",this.height)}applySize(name,value){typeof document>"u"?value&&/^[\w\s.%+*/(),-]+$/.test(value)&&this.setAttribute("style",[this.getAttribute("style"),`${name}:${value}`].filter(Boolean).join(";")):value?this.style.setProperty(name,value):this.style.removeProperty(name)}render(){return html`<span part="base indicator" data-effect=${this.effect}></span>`}}__decorate([property({reflect:!0,useDefault:!0})],LyraSkeleton.prototype,"shape",void 0),__decorate([property()],LyraSkeleton.prototype,"effect",void 0),__decorate([property()],LyraSkeleton.prototype,"width",void 0),__decorate([property()],LyraSkeleton.prototype,"height",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraSkeleton.prototype,"announce",void 0),__decorate([property()],LyraSkeleton.prototype,"label",void 0);export{LyraSkeleton};
1
+ import{__decorate}from"tslib";import{html}from"lit";import{property}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{styles}from"./skeleton.styles.js";import{LYRA_DEFAULT_loading}from"../../../internal/default-strings/shared.generated.js";class LyraSkeleton extends LyraElement{constructor(){super(...arguments),this.shape="text",this.effect="none",this.announce=!1}static{this.defaultStrings={...super.defaultStrings,loading:LYRA_DEFAULT_loading}}static{this.styles=[LyraElement.styles,styles]}disconnectedCallback(){this.sink?.release(),this.sink=void 0,super.disconnectedCallback()}updated(changed){super.updated(changed),this.announce?(changed.has("announce")||changed.has("label"))&&import("../../../internal/announcer.js").then(({acquireAnnouncementSink})=>{!this.announce||!this.isConnected||(this.sink??=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}),this.ownerDocument.defaultView?.requestAnimationFrame(()=>{this.announce&&this.sink?.announce(this.label??this.localize("loading"))}))}):(this.sink?.release(),this.sink=void 0)}willUpdate(changed){super.willUpdate(changed),changed.has("width")&&this.applySize("--lr-skeleton-w",this.width),changed.has("height")&&this.applySize("--lr-skeleton-h",this.height)}applySize(name,value){typeof document>"u"?value&&/^[\w\s.%+*/(),-]+$/.test(value)&&this.setAttribute("style",[this.getAttribute("style"),`${name}:${value}`].filter(Boolean).join(";")):value?this.style.setProperty(name,value):this.style.removeProperty(name)}render(){return html`<span part="base indicator" data-effect=${this.effect}></span>`}}__decorate([property({reflect:!0,useDefault:!0})],LyraSkeleton.prototype,"shape",void 0),__decorate([property()],LyraSkeleton.prototype,"effect",void 0),__decorate([property()],LyraSkeleton.prototype,"width",void 0),__decorate([property()],LyraSkeleton.prototype,"height",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraSkeleton.prototype,"announce",void 0),__decorate([property()],LyraSkeleton.prototype,"label",void 0);export{LyraSkeleton};
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{html}from"lit";import{property}from"lit/decorators.js";import{composedAccessibilityText}from"../../../internal/accessibility-visibility.js";import{AccessibleTextController}from"../../../internal/accessible-text-controller.js";import{LyraElement}from"../../../internal/lyra-element.js";import{styles}from"./spinner.styles.js";import{LYRA_DEFAULT_loading}from"../../../internal/default-strings.generated.js";class LyraSpinner extends LyraElement{constructor(){super(...arguments),this.labelPlacement="none",this.accessibleLabel=null,this.cachedVisibleLabelText="",this.labelTextObserver=new AccessibleTextController(this,[""],()=>this.recomputeVisibleLabelText())}static{this.defaultStrings={...super.defaultStrings,loading:LYRA_DEFAULT_loading}}static{this.styles=[LyraElement.styles,styles]}connectedCallback(){this.labelTextObserver.setEnabled(this.labelPlacement==="after"),super.connectedCallback(),this.labelPlacement==="after"&&(this.hasUpdated?(this.recomputeVisibleLabelText(!0,!0),this.ownerDocument.defaultView?.queueMicrotask(()=>{this.isConnected&&this.labelPlacement==="after"&&this.recomputeVisibleLabelText()})):this.seedFirstRenderState(()=>this.recomputeVisibleLabelText(!1)))}adoptedCallback(){super.adoptedCallback(),this.labelTextObserver.adopted()}computeVisibleLabelText(preferLightDom=!1){const slot=this.renderRoot?.querySelector("slot"),lightDomNodes=this.childNodes,assigned=slot?.assignedNodes({flatten:!0})??[],direct=Array.from(lightDomNodes??[]).filter(node=>node.nodeType!==1||(node.getAttribute("slot")??"")==="");return(!preferLightDom&&assigned.length>0?assigned:direct).map(node=>composedAccessibilityText(node,{ancestorBoundary:this,requireRendered:!preferLightDom,skipRootAncestorValidation:preferLightDom})).join(" ").replace(/\s+/g," ").trim()}recomputeVisibleLabelText(request=!0,preferLightDom=!1){const next=this.computeVisibleLabelText(preferLightDom);next!==this.cachedVisibleLabelText&&(this.cachedVisibleLabelText=next,request&&this.requestUpdate())}willUpdate(changed){super.willUpdate(changed),changed.has("labelPlacement")&&(this.labelTextObserver.setEnabled(this.labelPlacement==="after"),this.hasUpdated&&(this.labelPlacement==="after"?this.recomputeVisibleLabelText(!1,!0):this.cachedVisibleLabelText=""))}render(){const label=this.accessibleLabel!==null?this.accessibleLabel:(this.labelPlacement==="after"?this.cachedVisibleLabelText:"")||this.localize("loading");return html`<span part="base spinner" role="progressbar" aria-label=${label}>
1
+ import{__decorate}from"tslib";import{html}from"lit";import{property}from"lit/decorators.js";import{composedAccessibilityText}from"../../../internal/accessibility-visibility.js";import{AccessibleTextController}from"../../../internal/accessible-text-controller.js";import{LyraElement}from"../../../internal/lyra-element.js";import{styles}from"./spinner.styles.js";import{LYRA_DEFAULT_loading}from"../../../internal/default-strings/shared.generated.js";class LyraSpinner extends LyraElement{constructor(){super(...arguments),this.labelPlacement="none",this.accessibleLabel=null,this.cachedVisibleLabelText="",this.labelTextObserver=new AccessibleTextController(this,[""],()=>this.recomputeVisibleLabelText())}static{this.defaultStrings={...super.defaultStrings,loading:LYRA_DEFAULT_loading}}static{this.styles=[LyraElement.styles,styles]}connectedCallback(){this.labelTextObserver.setEnabled(this.labelPlacement==="after"),super.connectedCallback(),this.labelPlacement==="after"&&(this.hasUpdated?(this.recomputeVisibleLabelText(!0,!0),this.ownerDocument.defaultView?.queueMicrotask(()=>{this.isConnected&&this.labelPlacement==="after"&&this.recomputeVisibleLabelText()})):this.seedFirstRenderState(()=>this.recomputeVisibleLabelText(!1)))}adoptedCallback(){super.adoptedCallback(),this.labelTextObserver.adopted()}computeVisibleLabelText(preferLightDom=!1){const slot=this.renderRoot?.querySelector("slot"),lightDomNodes=this.childNodes,assigned=slot?.assignedNodes({flatten:!0})??[],direct=Array.from(lightDomNodes??[]).filter(node=>node.nodeType!==1||(node.getAttribute("slot")??"")==="");return(!preferLightDom&&assigned.length>0?assigned:direct).map(node=>composedAccessibilityText(node,{ancestorBoundary:this,requireRendered:!preferLightDom,skipRootAncestorValidation:preferLightDom})).join(" ").replace(/\s+/g," ").trim()}recomputeVisibleLabelText(request=!0,preferLightDom=!1){const next=this.computeVisibleLabelText(preferLightDom);next!==this.cachedVisibleLabelText&&(this.cachedVisibleLabelText=next,request&&this.requestUpdate())}willUpdate(changed){super.willUpdate(changed),changed.has("labelPlacement")&&(this.labelTextObserver.setEnabled(this.labelPlacement==="after"),this.hasUpdated&&(this.labelPlacement==="after"?this.recomputeVisibleLabelText(!1,!0):this.cachedVisibleLabelText=""))}render(){const label=this.accessibleLabel!==null?this.accessibleLabel:(this.labelPlacement==="after"?this.cachedVisibleLabelText:"")||this.localize("loading");return html`<span part="base spinner" role="progressbar" aria-label=${label}>
2
2
  <span part="spinner-indicator" aria-hidden="true"></span>
3
3
  <span part="label" ?hidden=${this.labelPlacement==="none"}><slot></slot></span>
4
4
  </span>`}}__decorate([property({attribute:"label-placement",reflect:!0})],LyraSpinner.prototype,"labelPlacement",void 0),__decorate([property({attribute:"aria-label"})],LyraSpinner.prototype,"accessibleLabel",void 0);export{LyraSpinner};
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{waitForTransitionSettle}from"../../../internal/css-motion-time.js";import{html}from"lit";import{property,state}from"lit/decorators.js";import{keyed}from"lit/directives/keyed.js";import{composedParentElement}from"../../../internal/a11y.js";import{CustomElementUpgradeObserver}from"../../../internal/custom-element-upgrade-observer.js";import{composedAccessibilityTextResult}from"../../../internal/accessibility-visibility.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{LyraElement}from"../../../internal/lyra-element.js";import{closeIcon}from"../../../internal/icons.js";import{getSegmenter}from"../../../internal/intl-cache.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{finiteDuration}from"../../../internal/numbers.js";import{composedContains,deepActiveElement}from"../../../internal/overlay-manager.js";import{applyComposedFocusRepair,captureComposedFocusRepair,isActionableElement}from"../../../internal/focus-navigation.js";import{tag}from"../../../internal/prefix.js";import{normalizeSize}from"../../../internal/variants.js";import{variants}from"../../../internal/variants.styles.js";import{styles}from"./toast-item.styles.js";import{TOAST_REGION_ENQUEUE,TOAST_REGION_EVICT,TOAST_REGION_REJECT,TOAST_REGION_SET_ACTIVE,toastRegionControllerFor}from"./toast-region-protocol.js";import{LYRA_DEFAULT_close,LYRA_DEFAULT_closeWithContext,LYRA_DEFAULT_closeWithTruncatedContext,LYRA_DEFAULT_toastContentIncomplete}from"../../../internal/default-strings.generated.js";const CLOSE_LABEL_GRAPHEME_LIMIT=40;function isAssertiveVariant(variant){return variant==="danger"||variant==="warning"}function truncateGraphemes(value,limit,locale){if(typeof Intl.Segmenter!="function")return{snippet:value,truncated:!1};let graphemes;try{graphemes=[...getSegmenter(locale,{granularity:"grapheme"}).segment(value)].map(({segment})=>segment)}catch(error){if(!(error instanceof RangeError))throw error;graphemes=[...getSegmenter(void 0,{granularity:"grapheme"}).segment(value)].map(({segment})=>segment)}return graphemes.length>limit?{snippet:graphemes.slice(0,limit).join(""),truncated:!0}:{snippet:value,truncated:!1}}class LyraToastItem extends LyraElement{constructor(){super(...arguments),this.duration=5e3,this.size="m",this.variant="neutral",this.withIcon=!1,this.elapsedMs=0,this.startedAt=0,this.timerStarted=!1,this.showGeneration=0,this.showCompletionGeneration=0,this.showCompletionRunning=!1,this.showAccepted=!1,this.afterShowEmitted=!1,this.admitted=!1,this.requestingRegionAdmission=!1,this.hovering=!1,this.focused=!1,this.messageUpgrades=new CustomElementUpgradeObserver(()=>{this.isConnected&&(this.bindMessageObserverTargets(),this.recomputeMessageText())}),this.lastAnnouncedMessage="",this.onMessageSlotChange=event=>{const target=event.target;target?.nodeType!==1||target.localName!=="slot"||(this.bindMessageObserverTargets(),this.recomputeMessageText())},this.hideCompletionRunning=!1,this.hideGeneration=0,this.afterHideEmitted=!1,this.messageText="",this.messageTextTruncated=!1,this.hiding=!1,this.progressRun=0,this.surfaceMounted=!1,this.interactionReady=!1,this.resumeTimer=()=>{if(this.timer!==void 0&&(this.timerOwner?.clearTimeout(this.timer),this.timer=void 0,this.timerOwner=void 0),!this.isConnected||!this.admitted||this.hiding||!this.hasAttribute("data-visible")||this.hovering||this.focused||this.ownerDocument.hidden)return;const duration=this.safeDuration;if(!isFinite(duration)||duration<=0)return;const remaining=duration-this.elapsedMs;if(remaining<=0){this.requestHide("timer");return}const view=this.ownerDocument.defaultView;if(!view)return;this.startedAt=view.performance.now(),this.timerOwner=view;const timer=view.setTimeout(()=>{this.timer!==timer||this.timerOwner!==view||(this.timer=void 0,this.timerOwner=void 0,this.requestHide("timer"))},remaining);this.timer=timer},this.onVisibilityChange=()=>{this.pauseTimer(),this.resumeTimer()},this.pauseTimer=()=>{if(this.timer!==void 0){const owner=this.timerOwner;owner?.clearTimeout(this.timer),this.timer=void 0,this.timerOwner=void 0,owner&&(this.elapsedMs+=owner.performance.now()-this.startedAt)}},this.onPointerEnter=()=>{this.hovering=!0,this.pauseTimer()},this.onPointerLeave=()=>{this.hovering=!1,!this.focused&&!this.hiding&&this.resumeTimer()},this.onFocusIn=event=>{const previous=event.relatedTarget;previous?.nodeType===1&&!composedContains(this,previous)&&previous.isConnected&&(this.focusReturnTarget=previous);const activeElement=deepActiveElement(this.ownerDocument);this.pendingFocusRepair=activeElement&&typeof activeElement.focus=="function"?captureComposedFocusRepair(this,activeElement)??void 0:void 0,this.focused=!0,this.pauseTimer()},this.onFocusOut=event=>{if(event.relatedTarget===null&&this.hasAttribute("data-visible")){const parent=this.parentElement,clearIfStillOwned=()=>{this.isConnected&&this.parentElement===parent&&(this.pendingFocusRepair=void 0)},view=this.ownerDocument.defaultView;view?view.queueMicrotask(clearIfStillOwned):queueMicrotask(clearIfStillOwned)}else event.relatedTarget?.nodeType===1&&!composedContains(this,event.relatedTarget)&&(this.pendingFocusRepair=void 0);this.focused=!1,!this.hovering&&!this.hiding&&this.resumeTimer()}}static{this.defaultStrings={...super.defaultStrings,close:LYRA_DEFAULT_close,closeWithContext:LYRA_DEFAULT_closeWithContext,closeWithTruncatedContext:LYRA_DEFAULT_closeWithTruncatedContext,toastContentIncomplete:LYRA_DEFAULT_toastContentIncomplete}}static{this.styles=[LyraElement.styles,variants,styles]}get toastItemElement(){return this.renderRoot.querySelector('[part="toast-item"]')}get effectiveSize(){const value=this.size;return["2xs","xs","s","m","l","xl","small","medium","large"].includes(value)?normalizeSize(value):"m"}get safeDuration(){return this.duration===1/0?1/0:finiteDuration(this.duration,5e3,0)}willUpdate(changed){super.willUpdate(changed),this.setAttribute("data-effective-size",this.effectiveSize),changed.has("duration")&&this.timerStarted&&this.admitted&&this.hasAttribute("data-visible")&&!this.hovering&&!this.focused&&(this.pauseTimer(),this.resumeTimer())}updated(changed){if(super.updated(changed),this.hasAttribute("data-visible")){const previousVariant=changed.get("variant");changed.has("variant")&&isAssertiveVariant(this.variant)!==isAssertiveVariant(previousVariant??"neutral")?this.announceMessage(!0):(changed.has("messageText")||changed.has("messageTextTruncated"))&&this.announceMessage()}this.shadowRoot?.querySelector('[part~="close-icon"] svg')?.setAttribute("part","close-icon__svg")}firstUpdated(changed){super.firstUpdated(changed),this.requestRegionAdmission(),this.admitted&&this.scheduleShow()}connectedCallback(){super.connectedCallback(),this.politeSink??=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}),this.assertiveSink??=acquireAnnouncementSink("assertive",{document:this.ownerDocument,source:this});const MutationObserverCtor=this.ownerDocument.defaultView?.MutationObserver;if(this.messageObserver=MutationObserverCtor?new MutationObserverCtor(()=>{this.bindMessageObserverTargets(),this.recomputeMessageText()}):void 0,this.addEventListener("slotchange",this.onMessageSlotChange),this.ownerDocument.addEventListener("visibilitychange",this.onVisibilityChange),this.bindMessageObserverTargets(),this.hasUpdated?this.recomputeMessageText():this.seedFirstRenderState(()=>this.recomputeMessageText()),this.requestRegionAdmission(),!!this.hasUpdated){if(this.hiding){this.completeHide();return}!this.hasAttribute("data-visible")&&this.admitted?this.scheduleShow():this.admitted&&this.timerStarted&&!this.hovering&&!this.focused&&(this.completeShow(),this.resumeTimer())}}requestRegionAdmission(){const controller=toastRegionControllerFor(this);if(controller){this.requestingRegionAdmission=!0;try{controller[TOAST_REGION_ENQUEUE](this)}finally{this.requestingRegionAdmission=!1}return}const parent=this.parentElement;if(parent?.localName===tag("toast")){this.regionOwner=void 0,this.admitted=!1,this.setAttribute("data-toast-queued",""),this.cancelPendingShow(),this.pauseTimer(),this.setSurfaceAvailability(!1);const releaseUnavailableOwner=()=>{this.parentElement===parent&&!toastRegionControllerFor(this)&&this.remove()},view=this.ownerDocument.defaultView,registry=view?.customElements;registry?.get(this.localName)&&!registry.get(parent.localName)?registry.whenDefined(parent.localName).then(releaseUnavailableOwner):view?view.queueMicrotask(releaseUnavailableOwner):queueMicrotask(releaseUnavailableOwner);return}this.regionOwner=void 0,this.admitted=!0,this.removeAttribute("data-toast-queued"),this.hasAttribute("data-visible")&&(this.setSurfaceAvailability(!0),this.pendingFocusRepair&&(applyComposedFocusRepair(this.pendingFocusRepair),this.pendingFocusRepair=void 0))}[TOAST_REGION_SET_ACTIVE](owner,active){if(this.parentElement===owner){if(this.regionOwner=owner,this.admitted=active,this.toggleAttribute("data-toast-queued",!active),!active){const focusTarget=this.adjacentToastOrReturnTarget(),activeElement=deepActiveElement(this.ownerDocument),repair=this.pendingFocusRepair??(activeElement&&typeof activeElement.focus=="function"?captureComposedFocusRepair(this,focusTarget):null);this.cancelPendingShow(),this.pauseTimer(),this.setSurfaceAvailability(!1),repair&&applyComposedFocusRepair(repair,focusTarget),this.pendingFocusRepair=void 0;return}if(this.hasAttribute("data-visible")&&!this.hiding){this.setSurfaceAvailability(!0),this.pendingFocusRepair&&(applyComposedFocusRepair(this.pendingFocusRepair),this.pendingFocusRepair=void 0),!this.requestingRegionAdmission&&this.timerStarted&&!this.hovering&&!this.focused&&this.resumeTimer(),this.completeShow();return}this.isConnected&&this.hasUpdated&&!this.hiding&&!this.hasAttribute("data-visible")&&this.scheduleShow()}}[TOAST_REGION_EVICT](owner,_reason){this.regionOwner===owner&&(this.regionOwner=void 0,this.admitted=!1,this.cancelPendingShow(),this.showAccepted=!1,this.pauseTimer(),this.setSurfaceAvailability(!1),this.parentElement===owner&&this.remove())}setSurfaceAvailability(available){this.surfaceMounted=available,this.interactionReady=available;const surface=this.shadowRoot?.querySelector('[part="toast-item"]');surface&&(surface.hidden=!available,surface.inert=!available)}cancelPendingShow(){this.showGeneration+=1,this.showAccepted&&!this.afterShowEmitted&&(this.showCompletionGeneration+=1),this.showRafId!==void 0&&(this.showRafOwner?.cancelAnimationFrame(this.showRafId),this.showRafId=void 0,this.showRafOwner=void 0),this.cancelShowAnimation?.(),this.cancelShowAnimation=void 0}scheduleShow(){if(this.showRafId!==void 0||this.hiding||!this.admitted)return;const view=this.ownerDocument.defaultView;if(!view)return;const generation=++this.showGeneration;this.showRafOwner=view,this.showRafId=view.requestAnimationFrame(()=>{this.showRafId=void 0,this.showRafOwner=void 0,!(this.hiding||!this.admitted||generation!==this.showGeneration)&&this.prepareShow(generation)})}async prepareShow(generation){if(await this.updateComplete,generation!==this.showGeneration||!this.isConnected||!this.admitted||this.hiding)return;if(this.emit("lr-show",null,{cancelable:!0}).defaultPrevented){if(generation!==this.showGeneration)return;const owner=this.regionOwner;owner?owner[TOAST_REGION_REJECT](this):this.remove();return}if(generation!==this.showGeneration||!this.isConnected||!this.admitted||this.hiding)return;this.surfaceMounted=!0;const surface=this.shadowRoot?.querySelector('[part="toast-item"]');surface&&(surface.hidden=!1,surface.offsetWidth),this.setAttribute("data-visible",""),this.bindMessageObserverTargets(),this.recomputeMessageText(),this.interactionReady=!0,surface&&(surface.inert=!1),this.announceMessage(!0),this.showAccepted=!0,this.afterShowEmitted=!1,this.showCompletionGeneration+=1,this.completeShow(),this.startTimer()}async completeShow(){if(this.showCompletionRunning||!this.showAccepted||this.afterShowEmitted||this.hiding||!this.admitted||!this.hasAttribute("data-visible"))return;this.showCompletionRunning=!0;const generation=this.showCompletionGeneration;if(await this.waitForVisualCompletion("show"),this.showCompletionRunning=!1,generation!==this.showCompletionGeneration||!this.isConnected||!this.admitted||this.hiding||!this.hasAttribute("data-visible")){this.isConnected&&this.admitted&&!this.hiding&&this.completeShow();return}this.afterShowEmitted||!this.showAccepted||(this.afterShowEmitted=!0,this.showAccepted=!1,this.emit("lr-after-show"))}disconnectedCallback(){const activeElement=deepActiveElement(this.ownerDocument);!this.pendingFocusRepair&&!this.hiding&&this.hasAttribute("data-visible")&&activeElement&&typeof activeElement.focus=="function"&&(this.pendingFocusRepair=captureComposedFocusRepair(this,activeElement)??void 0),super.disconnectedCallback(),this.removeEventListener("slotchange",this.onMessageSlotChange),this.ownerDocument.removeEventListener("visibilitychange",this.onVisibilityChange),this.messageObserver?.disconnect(),this.messageObserver=void 0,this.messageUpgrades.disconnect(),this.politeSink?.release(),this.politeSink=void 0,this.assertiveSink?.release(),this.assertiveSink=void 0,this.hiding&&!this.afterHideEmitted&&this.hideGeneration++,this.cancelPendingShow(),this.cancelHideAnimation?.(),this.cancelHideAnimation=void 0,this.pauseTimer(),this.hovering=!1,this.focused=!1,!this.hasAttribute("data-visible")&&!this.hiding&&(this.surfaceMounted=!1,this.interactionReady=!1)}startTimer(){this.timerStarted=!0,this.elapsedMs=0,this.resumeTimer()}clearTimer(){this.timer!==void 0&&this.timerOwner?.clearTimeout(this.timer),this.timer=void 0,this.timerOwner=void 0}waitForVisualCompletion(kind){(kind==="show"?this.cancelShowAnimation:this.cancelHideAnimation)?.();const surface=this.shadowRoot?.querySelector('[part="toast-item"]'),watch=waitForTransitionSettle(surface??null,this,{reducedMotion:prefersReducedMotion(this),includeAnimation:!0});if(!watch.pending)return watch.finished;const cancelKey=kind==="show"?"cancelShowAnimation":"cancelHideAnimation",cancel=()=>watch.cancel();return this[cancelKey]=cancel,watch.finished.then(()=>{this[cancelKey]===cancel&&(this[cancelKey]=void 0)})}observeMessageNode(node){if(this.messageObserver){if(node.nodeType===3){this.messageObserver.observe(node,{characterData:!0});return}node.nodeType!==1&&node.nodeType!==11||this.messageObserver.observe(node,{attributes:!0,attributeFilter:["alt","aria-hidden","aria-label","aria-labelledby","class","contenteditable","hidden","href","inert","id","role","slot","style","tabindex"],childList:!0,characterData:!0,subtree:!0})}}bindMessageObserverTargets(){if(this.messageObserver){if(this.messageObserver.disconnect(),this.observeMessageNode(this),this.hasAttribute("data-visible")){let ancestor=composedParentElement(this);for(;ancestor;)this.messageObserver.observe(ancestor,{attributes:!0,attributeFilter:["aria-hidden","class","hidden","inert","style"]}),ancestor=composedParentElement(ancestor)}for(const slot of this.querySelectorAll("slot"))for(const assigned of slot.assignedNodes({flatten:!0}))this.observeMessageNode(assigned)}}observeLabelReferenceRoot(root){this.messageObserver?.observe(root,{attributes:!0,attributeFilter:["id"],childList:!0,subtree:!0})}recomputeMessageText(){const slot=this.renderRoot?.querySelector("slot:not([name])"),lightDomNodes=this.childNodes,messageNodes=slot?slot.assignedNodes({flatten:!0}):Array.from(lightDomNodes??[]).filter(node=>node.nodeType!==1||!node.getAttribute("slot")),result=composedAccessibilityTextResult(messageNodes,{requireRendered:!1,shouldPrune:element=>{const slotName=element.getAttribute("slot");return slotName!==null&&slotName!==""||isActionableElement(element)?!0:(this.messageUpgrades.observeElement(element),element.hasAttribute("tabindex")&&element.getAttribute("tabindex")!=="-1")},skipRootAncestorValidation:!0});this.messageText=result.text.trim().replace(/\s+/g," "),this.messageTextTruncated=result.truncated;for(const root of result.labelReferenceRoots)this.observeLabelReferenceRoot(root);for(const reference of result.referencedElements)this.observeMessageNode(reference);for(const root of result.traversedShadowRoots)this.observeMessageNode(root)}announceMessage(force=!1){const message=this.messageText,announcement=this.messageTextTruncated?message?`${message}…`:this.localize("toastContentIncomplete"):message;!force&&announcement===this.lastAnnouncedMessage||(this.lastAnnouncedMessage=announcement,(isAssertiveVariant(this.variant)?this.assertiveSink:this.politeSink)?.announce(announcement))}get closeLabel(){const text=this.messageText;if(!text&&this.messageTextTruncated)return this.localize("closeWithContext",void 0,{snippet:this.localize("toastContentIncomplete")});if(!text)return this.localize("close");const{snippet,truncated}=truncateGraphemes(text,CLOSE_LABEL_GRAPHEME_LIMIT,this.effectiveLocale);return this.messageTextTruncated||truncated?this.localize("closeWithTruncatedContext",void 0,{snippet}):this.localize("closeWithContext",void 0,{snippet})}async hide(){await this.requestHide("manual")}requestHide(source){if(this.hideRequest)return this.hideRequest;if(this.hiding)return Promise.resolve();let resolve,reject;const completion=new Promise((resolveCompletion,rejectCompletion)=>{resolve=resolveCompletion,reject=rejectCompletion});return this.hideRequest=completion,this.emit("lr-hide",null,{cancelable:!0}).defaultPrevented?(source==="timer"&&(this.elapsedMs=0,this.startedAt=0,this.progressRun+=1,this.isConnected&&!this.hovering&&!this.focused&&this.resumeTimer()),this.hideRequest===completion&&(this.hideRequest=void 0),resolve(),completion):(this.hiding=!0,this.showAccepted=!1,this.showCompletionGeneration+=1,this.shadowRoot?.querySelector('[part="close-button"]')?.setAttribute("aria-disabled","true"),this.cancelShowAnimation?.(),this.cancelShowAnimation=void 0,this.clearTimer(),this.removeAttribute("data-visible"),this.bindMessageObserverTargets(),this.setAttribute("data-hiding",""),this.completeHide().then(()=>{this.hideRequest===completion&&(this.hideRequest=void 0),resolve()},reason=>{this.hideRequest===completion&&(this.hideRequest=void 0),reject(reason)}),completion)}async completeHide(){if(this.hideCompletionRunning||this.afterHideEmitted)return;this.hideCompletionRunning=!0;const generation=this.hideGeneration;if(await this.waitForVisualCompletion("hide"),this.hideCompletionRunning=!1,generation!==this.hideGeneration||!this.isConnected){this.isConnected&&await this.completeHide();return}this.afterHideEmitted||(this.repairFocusBeforeRemoval(),this.afterHideEmitted=!0,this.emit("lr-after-hide"),this.remove())}repairFocusBeforeRemoval(){const active=deepActiveElement(this.ownerDocument);composedContains(this,active)&&this.focusAdjacentToastOrReturn()}adjacentToastOrReturnTarget(){const findAdjacent=direction=>{let element=this[direction];for(;element;){if(element.localName===tag("toast-item")){const item=element,surface=item.shadowRoot?.querySelector('[part="toast-item"]');if(!item.hasAttribute("data-hiding")&&!item.hasAttribute("data-toast-queued")&&item.hasAttribute("data-visible")&&item.isConnected&&surface&&!surface.hidden&&!surface.inert)return item.shadowRoot?.querySelector('[part="close-button"]')??null}element=element[direction]}return null};return findAdjacent("nextElementSibling")??findAdjacent("previousElementSibling")??(this.focusReturnTarget?.isConnected&&!composedContains(this,this.focusReturnTarget)?this.focusReturnTarget:null)}focusAdjacentToastOrReturn(){this.adjacentToastOrReturnTarget()?.focus()}renderCloseControl(){const close=html`<span part="close-icon">${closeIcon()}</span>`,duration=this.safeDuration;return!Number.isFinite(duration)||duration<=0?close:html`
1
+ import{__decorate}from"tslib";import{waitForTransitionSettle}from"../../../internal/css-motion-time.js";import{html}from"lit";import{property,state}from"lit/decorators.js";import{keyed}from"lit/directives/keyed.js";import{composedParentElement}from"../../../internal/a11y.js";import{CustomElementUpgradeObserver}from"../../../internal/custom-element-upgrade-observer.js";import{composedAccessibilityTextResult}from"../../../internal/accessibility-visibility.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{LyraElement}from"../../../internal/lyra-element.js";import{closeIcon}from"../../../internal/icons.js";import{getSegmenter}from"../../../internal/intl-cache.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{finiteDuration}from"../../../internal/numbers.js";import{composedContains,deepActiveElement}from"../../../internal/overlay-manager.js";import{applyComposedFocusRepair,captureComposedFocusRepair,isActionableElement}from"../../../internal/focus-navigation.js";import{tag}from"../../../internal/prefix.js";import{normalizeSize}from"../../../internal/variants.js";import{variants}from"../../../internal/variants.styles.js";import{styles}from"./toast-item.styles.js";import{TOAST_REGION_ENQUEUE,TOAST_REGION_EVICT,TOAST_REGION_REJECT,TOAST_REGION_SET_ACTIVE,toastRegionControllerFor}from"./toast-region-protocol.js";import{LYRA_DEFAULT_closeWithContext,LYRA_DEFAULT_closeWithTruncatedContext,LYRA_DEFAULT_toastContentIncomplete}from"../../../internal/default-strings/overlays.generated.js";import{LYRA_DEFAULT_close}from"../../../internal/default-strings/shared.generated.js";const CLOSE_LABEL_GRAPHEME_LIMIT=40;function isAssertiveVariant(variant){return variant==="danger"||variant==="warning"}function truncateGraphemes(value,limit,locale){if(typeof Intl.Segmenter!="function")return{snippet:value,truncated:!1};let graphemes;try{graphemes=[...getSegmenter(locale,{granularity:"grapheme"}).segment(value)].map(({segment})=>segment)}catch(error){if(!(error instanceof RangeError))throw error;graphemes=[...getSegmenter(void 0,{granularity:"grapheme"}).segment(value)].map(({segment})=>segment)}return graphemes.length>limit?{snippet:graphemes.slice(0,limit).join(""),truncated:!0}:{snippet:value,truncated:!1}}class LyraToastItem extends LyraElement{constructor(){super(...arguments),this.duration=5e3,this.size="m",this.variant="neutral",this.withIcon=!1,this.elapsedMs=0,this.startedAt=0,this.timerStarted=!1,this.showGeneration=0,this.showCompletionGeneration=0,this.showCompletionRunning=!1,this.showAccepted=!1,this.afterShowEmitted=!1,this.admitted=!1,this.requestingRegionAdmission=!1,this.hovering=!1,this.focused=!1,this.messageUpgrades=new CustomElementUpgradeObserver(()=>{this.isConnected&&(this.bindMessageObserverTargets(),this.recomputeMessageText())}),this.lastAnnouncedMessage="",this.onMessageSlotChange=event=>{const target=event.target;target?.nodeType!==1||target.localName!=="slot"||(this.bindMessageObserverTargets(),this.recomputeMessageText())},this.hideCompletionRunning=!1,this.hideGeneration=0,this.afterHideEmitted=!1,this.messageText="",this.messageTextTruncated=!1,this.hiding=!1,this.progressRun=0,this.surfaceMounted=!1,this.interactionReady=!1,this.resumeTimer=()=>{if(this.timer!==void 0&&(this.timerOwner?.clearTimeout(this.timer),this.timer=void 0,this.timerOwner=void 0),!this.isConnected||!this.admitted||this.hiding||!this.hasAttribute("data-visible")||this.hovering||this.focused||this.ownerDocument.hidden)return;const duration=this.safeDuration;if(!isFinite(duration)||duration<=0)return;const remaining=duration-this.elapsedMs;if(remaining<=0){this.requestHide("timer");return}const view=this.ownerDocument.defaultView;if(!view)return;this.startedAt=view.performance.now(),this.timerOwner=view;const timer=view.setTimeout(()=>{this.timer!==timer||this.timerOwner!==view||(this.timer=void 0,this.timerOwner=void 0,this.requestHide("timer"))},remaining);this.timer=timer},this.onVisibilityChange=()=>{this.pauseTimer(),this.resumeTimer()},this.pauseTimer=()=>{if(this.timer!==void 0){const owner=this.timerOwner;owner?.clearTimeout(this.timer),this.timer=void 0,this.timerOwner=void 0,owner&&(this.elapsedMs+=owner.performance.now()-this.startedAt)}},this.onPointerEnter=()=>{this.hovering=!0,this.pauseTimer()},this.onPointerLeave=()=>{this.hovering=!1,!this.focused&&!this.hiding&&this.resumeTimer()},this.onFocusIn=event=>{const previous=event.relatedTarget;previous?.nodeType===1&&!composedContains(this,previous)&&previous.isConnected&&(this.focusReturnTarget=previous);const activeElement=deepActiveElement(this.ownerDocument);this.pendingFocusRepair=activeElement&&typeof activeElement.focus=="function"?captureComposedFocusRepair(this,activeElement)??void 0:void 0,this.focused=!0,this.pauseTimer()},this.onFocusOut=event=>{if(event.relatedTarget===null&&this.hasAttribute("data-visible")){const parent=this.parentElement,clearIfStillOwned=()=>{this.isConnected&&this.parentElement===parent&&(this.pendingFocusRepair=void 0)},view=this.ownerDocument.defaultView;view?view.queueMicrotask(clearIfStillOwned):queueMicrotask(clearIfStillOwned)}else event.relatedTarget?.nodeType===1&&!composedContains(this,event.relatedTarget)&&(this.pendingFocusRepair=void 0);this.focused=!1,!this.hovering&&!this.hiding&&this.resumeTimer()}}static{this.defaultStrings={...super.defaultStrings,close:LYRA_DEFAULT_close,closeWithContext:LYRA_DEFAULT_closeWithContext,closeWithTruncatedContext:LYRA_DEFAULT_closeWithTruncatedContext,toastContentIncomplete:LYRA_DEFAULT_toastContentIncomplete}}static{this.styles=[LyraElement.styles,variants,styles]}get toastItemElement(){return this.renderRoot.querySelector('[part="toast-item"]')}get effectiveSize(){const value=this.size;return["2xs","xs","s","m","l","xl","small","medium","large"].includes(value)?normalizeSize(value):"m"}get safeDuration(){return this.duration===1/0?1/0:finiteDuration(this.duration,5e3,0)}willUpdate(changed){super.willUpdate(changed),this.setAttribute("data-effective-size",this.effectiveSize),changed.has("duration")&&this.timerStarted&&this.admitted&&this.hasAttribute("data-visible")&&!this.hovering&&!this.focused&&(this.pauseTimer(),this.resumeTimer())}updated(changed){if(super.updated(changed),this.hasAttribute("data-visible")){const previousVariant=changed.get("variant");changed.has("variant")&&isAssertiveVariant(this.variant)!==isAssertiveVariant(previousVariant??"neutral")?this.announceMessage(!0):(changed.has("messageText")||changed.has("messageTextTruncated"))&&this.announceMessage()}this.shadowRoot?.querySelector('[part~="close-icon"] svg')?.setAttribute("part","close-icon__svg")}firstUpdated(changed){super.firstUpdated(changed),this.requestRegionAdmission(),this.admitted&&this.scheduleShow()}connectedCallback(){super.connectedCallback(),this.politeSink??=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}),this.assertiveSink??=acquireAnnouncementSink("assertive",{document:this.ownerDocument,source:this});const MutationObserverCtor=this.ownerDocument.defaultView?.MutationObserver;if(this.messageObserver=MutationObserverCtor?new MutationObserverCtor(()=>{this.bindMessageObserverTargets(),this.recomputeMessageText()}):void 0,this.addEventListener("slotchange",this.onMessageSlotChange),this.ownerDocument.addEventListener("visibilitychange",this.onVisibilityChange),this.bindMessageObserverTargets(),this.hasUpdated?this.recomputeMessageText():this.seedFirstRenderState(()=>this.recomputeMessageText()),this.requestRegionAdmission(),!!this.hasUpdated){if(this.hiding){this.completeHide();return}!this.hasAttribute("data-visible")&&this.admitted?this.scheduleShow():this.admitted&&this.timerStarted&&!this.hovering&&!this.focused&&(this.completeShow(),this.resumeTimer())}}requestRegionAdmission(){const controller=toastRegionControllerFor(this);if(controller){this.requestingRegionAdmission=!0;try{controller[TOAST_REGION_ENQUEUE](this)}finally{this.requestingRegionAdmission=!1}return}const parent=this.parentElement;if(parent?.localName===tag("toast")){this.regionOwner=void 0,this.admitted=!1,this.setAttribute("data-toast-queued",""),this.cancelPendingShow(),this.pauseTimer(),this.setSurfaceAvailability(!1);const releaseUnavailableOwner=()=>{this.parentElement===parent&&!toastRegionControllerFor(this)&&this.remove()},view=this.ownerDocument.defaultView,registry=view?.customElements;registry?.get(this.localName)&&!registry.get(parent.localName)?registry.whenDefined(parent.localName).then(releaseUnavailableOwner):view?view.queueMicrotask(releaseUnavailableOwner):queueMicrotask(releaseUnavailableOwner);return}this.regionOwner=void 0,this.admitted=!0,this.removeAttribute("data-toast-queued"),this.hasAttribute("data-visible")&&(this.setSurfaceAvailability(!0),this.pendingFocusRepair&&(applyComposedFocusRepair(this.pendingFocusRepair),this.pendingFocusRepair=void 0))}[TOAST_REGION_SET_ACTIVE](owner,active){if(this.parentElement===owner){if(this.regionOwner=owner,this.admitted=active,this.toggleAttribute("data-toast-queued",!active),!active){const focusTarget=this.adjacentToastOrReturnTarget(),activeElement=deepActiveElement(this.ownerDocument),repair=this.pendingFocusRepair??(activeElement&&typeof activeElement.focus=="function"?captureComposedFocusRepair(this,focusTarget):null);this.cancelPendingShow(),this.pauseTimer(),this.setSurfaceAvailability(!1),repair&&applyComposedFocusRepair(repair,focusTarget),this.pendingFocusRepair=void 0;return}if(this.hasAttribute("data-visible")&&!this.hiding){this.setSurfaceAvailability(!0),this.pendingFocusRepair&&(applyComposedFocusRepair(this.pendingFocusRepair),this.pendingFocusRepair=void 0),!this.requestingRegionAdmission&&this.timerStarted&&!this.hovering&&!this.focused&&this.resumeTimer(),this.completeShow();return}this.isConnected&&this.hasUpdated&&!this.hiding&&!this.hasAttribute("data-visible")&&this.scheduleShow()}}[TOAST_REGION_EVICT](owner,_reason){this.regionOwner===owner&&(this.regionOwner=void 0,this.admitted=!1,this.cancelPendingShow(),this.showAccepted=!1,this.pauseTimer(),this.setSurfaceAvailability(!1),this.parentElement===owner&&this.remove())}setSurfaceAvailability(available){this.surfaceMounted=available,this.interactionReady=available;const surface=this.shadowRoot?.querySelector('[part="toast-item"]');surface&&(surface.hidden=!available,surface.inert=!available)}cancelPendingShow(){this.showGeneration+=1,this.showAccepted&&!this.afterShowEmitted&&(this.showCompletionGeneration+=1),this.showRafId!==void 0&&(this.showRafOwner?.cancelAnimationFrame(this.showRafId),this.showRafId=void 0,this.showRafOwner=void 0),this.cancelShowAnimation?.(),this.cancelShowAnimation=void 0}scheduleShow(){if(this.showRafId!==void 0||this.hiding||!this.admitted)return;const view=this.ownerDocument.defaultView;if(!view)return;const generation=++this.showGeneration;this.showRafOwner=view,this.showRafId=view.requestAnimationFrame(()=>{this.showRafId=void 0,this.showRafOwner=void 0,!(this.hiding||!this.admitted||generation!==this.showGeneration)&&this.prepareShow(generation)})}async prepareShow(generation){if(await this.updateComplete,generation!==this.showGeneration||!this.isConnected||!this.admitted||this.hiding)return;if(this.emit("lr-show",null,{cancelable:!0}).defaultPrevented){if(generation!==this.showGeneration)return;const owner=this.regionOwner;owner?owner[TOAST_REGION_REJECT](this):this.remove();return}if(generation!==this.showGeneration||!this.isConnected||!this.admitted||this.hiding)return;this.surfaceMounted=!0;const surface=this.shadowRoot?.querySelector('[part="toast-item"]');surface&&(surface.hidden=!1,surface.offsetWidth),this.setAttribute("data-visible",""),this.bindMessageObserverTargets(),this.recomputeMessageText(),this.interactionReady=!0,surface&&(surface.inert=!1),this.announceMessage(!0),this.showAccepted=!0,this.afterShowEmitted=!1,this.showCompletionGeneration+=1,this.completeShow(),this.startTimer()}async completeShow(){if(this.showCompletionRunning||!this.showAccepted||this.afterShowEmitted||this.hiding||!this.admitted||!this.hasAttribute("data-visible"))return;this.showCompletionRunning=!0;const generation=this.showCompletionGeneration;if(await this.waitForVisualCompletion("show"),this.showCompletionRunning=!1,generation!==this.showCompletionGeneration||!this.isConnected||!this.admitted||this.hiding||!this.hasAttribute("data-visible")){this.isConnected&&this.admitted&&!this.hiding&&this.completeShow();return}this.afterShowEmitted||!this.showAccepted||(this.afterShowEmitted=!0,this.showAccepted=!1,this.emit("lr-after-show"))}disconnectedCallback(){const activeElement=deepActiveElement(this.ownerDocument);!this.pendingFocusRepair&&!this.hiding&&this.hasAttribute("data-visible")&&activeElement&&typeof activeElement.focus=="function"&&(this.pendingFocusRepair=captureComposedFocusRepair(this,activeElement)??void 0),super.disconnectedCallback(),this.removeEventListener("slotchange",this.onMessageSlotChange),this.ownerDocument.removeEventListener("visibilitychange",this.onVisibilityChange),this.messageObserver?.disconnect(),this.messageObserver=void 0,this.messageUpgrades.disconnect(),this.politeSink?.release(),this.politeSink=void 0,this.assertiveSink?.release(),this.assertiveSink=void 0,this.hiding&&!this.afterHideEmitted&&this.hideGeneration++,this.cancelPendingShow(),this.cancelHideAnimation?.(),this.cancelHideAnimation=void 0,this.pauseTimer(),this.hovering=!1,this.focused=!1,!this.hasAttribute("data-visible")&&!this.hiding&&(this.surfaceMounted=!1,this.interactionReady=!1)}startTimer(){this.timerStarted=!0,this.elapsedMs=0,this.resumeTimer()}clearTimer(){this.timer!==void 0&&this.timerOwner?.clearTimeout(this.timer),this.timer=void 0,this.timerOwner=void 0}waitForVisualCompletion(kind){(kind==="show"?this.cancelShowAnimation:this.cancelHideAnimation)?.();const surface=this.shadowRoot?.querySelector('[part="toast-item"]'),watch=waitForTransitionSettle(surface??null,this,{reducedMotion:prefersReducedMotion(this),includeAnimation:!0});if(!watch.pending)return watch.finished;const cancelKey=kind==="show"?"cancelShowAnimation":"cancelHideAnimation",cancel=()=>watch.cancel();return this[cancelKey]=cancel,watch.finished.then(()=>{this[cancelKey]===cancel&&(this[cancelKey]=void 0)})}observeMessageNode(node){if(this.messageObserver){if(node.nodeType===3){this.messageObserver.observe(node,{characterData:!0});return}node.nodeType!==1&&node.nodeType!==11||this.messageObserver.observe(node,{attributes:!0,attributeFilter:["alt","aria-hidden","aria-label","aria-labelledby","class","contenteditable","hidden","href","inert","id","role","slot","style","tabindex"],childList:!0,characterData:!0,subtree:!0})}}bindMessageObserverTargets(){if(this.messageObserver){if(this.messageObserver.disconnect(),this.observeMessageNode(this),this.hasAttribute("data-visible")){let ancestor=composedParentElement(this);for(;ancestor;)this.messageObserver.observe(ancestor,{attributes:!0,attributeFilter:["aria-hidden","class","hidden","inert","style"]}),ancestor=composedParentElement(ancestor)}for(const slot of this.querySelectorAll("slot"))for(const assigned of slot.assignedNodes({flatten:!0}))this.observeMessageNode(assigned)}}observeLabelReferenceRoot(root){this.messageObserver?.observe(root,{attributes:!0,attributeFilter:["id"],childList:!0,subtree:!0})}recomputeMessageText(){const slot=this.renderRoot?.querySelector("slot:not([name])"),lightDomNodes=this.childNodes,messageNodes=slot?slot.assignedNodes({flatten:!0}):Array.from(lightDomNodes??[]).filter(node=>node.nodeType!==1||!node.getAttribute("slot")),result=composedAccessibilityTextResult(messageNodes,{requireRendered:!1,shouldPrune:element=>{const slotName=element.getAttribute("slot");return slotName!==null&&slotName!==""||isActionableElement(element)?!0:(this.messageUpgrades.observeElement(element),element.hasAttribute("tabindex")&&element.getAttribute("tabindex")!=="-1")},skipRootAncestorValidation:!0});this.messageText=result.text.trim().replace(/\s+/g," "),this.messageTextTruncated=result.truncated;for(const root of result.labelReferenceRoots)this.observeLabelReferenceRoot(root);for(const reference of result.referencedElements)this.observeMessageNode(reference);for(const root of result.traversedShadowRoots)this.observeMessageNode(root)}announceMessage(force=!1){const message=this.messageText,announcement=this.messageTextTruncated?message?`${message}…`:this.localize("toastContentIncomplete"):message;!force&&announcement===this.lastAnnouncedMessage||(this.lastAnnouncedMessage=announcement,(isAssertiveVariant(this.variant)?this.assertiveSink:this.politeSink)?.announce(announcement))}get closeLabel(){const text=this.messageText;if(!text&&this.messageTextTruncated)return this.localize("closeWithContext",void 0,{snippet:this.localize("toastContentIncomplete")});if(!text)return this.localize("close");const{snippet,truncated}=truncateGraphemes(text,CLOSE_LABEL_GRAPHEME_LIMIT,this.effectiveLocale);return this.messageTextTruncated||truncated?this.localize("closeWithTruncatedContext",void 0,{snippet}):this.localize("closeWithContext",void 0,{snippet})}async hide(){await this.requestHide("manual")}requestHide(source){if(this.hideRequest)return this.hideRequest;if(this.hiding)return Promise.resolve();let resolve,reject;const completion=new Promise((resolveCompletion,rejectCompletion)=>{resolve=resolveCompletion,reject=rejectCompletion});return this.hideRequest=completion,this.emit("lr-hide",null,{cancelable:!0}).defaultPrevented?(source==="timer"&&(this.elapsedMs=0,this.startedAt=0,this.progressRun+=1,this.isConnected&&!this.hovering&&!this.focused&&this.resumeTimer()),this.hideRequest===completion&&(this.hideRequest=void 0),resolve(),completion):(this.hiding=!0,this.showAccepted=!1,this.showCompletionGeneration+=1,this.shadowRoot?.querySelector('[part="close-button"]')?.setAttribute("aria-disabled","true"),this.cancelShowAnimation?.(),this.cancelShowAnimation=void 0,this.clearTimer(),this.removeAttribute("data-visible"),this.bindMessageObserverTargets(),this.setAttribute("data-hiding",""),this.completeHide().then(()=>{this.hideRequest===completion&&(this.hideRequest=void 0),resolve()},reason=>{this.hideRequest===completion&&(this.hideRequest=void 0),reject(reason)}),completion)}async completeHide(){if(this.hideCompletionRunning||this.afterHideEmitted)return;this.hideCompletionRunning=!0;const generation=this.hideGeneration;if(await this.waitForVisualCompletion("hide"),this.hideCompletionRunning=!1,generation!==this.hideGeneration||!this.isConnected){this.isConnected&&await this.completeHide();return}this.afterHideEmitted||(this.repairFocusBeforeRemoval(),this.afterHideEmitted=!0,this.emit("lr-after-hide"),this.remove())}repairFocusBeforeRemoval(){const active=deepActiveElement(this.ownerDocument);composedContains(this,active)&&this.focusAdjacentToastOrReturn()}adjacentToastOrReturnTarget(){const findAdjacent=direction=>{let element=this[direction];for(;element;){if(element.localName===tag("toast-item")){const item=element,surface=item.shadowRoot?.querySelector('[part="toast-item"]');if(!item.hasAttribute("data-hiding")&&!item.hasAttribute("data-toast-queued")&&item.hasAttribute("data-visible")&&item.isConnected&&surface&&!surface.hidden&&!surface.inert)return item.shadowRoot?.querySelector('[part="close-button"]')??null}element=element[direction]}return null};return findAdjacent("nextElementSibling")??findAdjacent("previousElementSibling")??(this.focusReturnTarget?.isConnected&&!composedContains(this,this.focusReturnTarget)?this.focusReturnTarget:null)}focusAdjacentToastOrReturn(){this.adjacentToastOrReturnTarget()?.focus()}renderCloseControl(){const close=html`<span part="close-icon">${closeIcon()}</span>`,duration=this.safeDuration;return!Number.isFinite(duration)||duration<=0?close:html`
2
2
  <span part="progress-ring" aria-hidden="true">
3
3
  ${keyed(this.progressRun,html`
4
4
  <svg
@@ -1,3 +1,3 @@
1
- import{__decorate}from"tslib";import{html,render}from"lit";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{property}from"lit/decorators.js";import{setCustomState}from"../../../internal/custom-states.js";import{LyraElement}from"../../../internal/lyra-element.js";import{tag}from"../../../internal/prefix.js";import{styles}from"./toast.styles.js";import{isToastRegionEntry,TOAST_REGION_ENQUEUE,TOAST_REGION_EVICT,TOAST_REGION_REJECT,TOAST_REGION_SET_ACTIVE}from"./toast-region-protocol.js";import{LYRA_DEFAULT_toastOverflow}from"../../../internal/default-strings.generated.js";const MAX_VISIBLE_TOASTS=3,MAX_QUEUED_TOASTS=20;class LyraToast extends LyraElement{constructor(){super(...arguments),this.placement="top-end",this.toastInternals=attachInternalsSafely(this),this.managedEntries=new Set,this.activeEntries=[],this.queuedEntries=[],this.admissionsInProgress=new Set,this.connectionGeneration=0,this.pendingOverflowCount=0,this.overflowNotificationScheduled=!1,this.syncVisibleState=()=>{const hasToast=this.isConnected&&Array.from(this.children).some(child=>isToastRegionEntry(child));setCustomState(this.toastInternals,"visible",hasToast)},this.reconcileEntries=()=>{const children=Array.from(this.children);this.pruneAbsentEntries(),this.promoteQueuedEntries();for(const child of children){if(!isToastRegionEntry(child)){child.localName===tag("toast-item")&&this.ownerDocument.defaultView?.customElements.get(child.localName)&&child.remove();continue}this.managedEntries.has(child)?this.reassertEntry(child):this.admitEntry(child)}this.promoteQueuedEntries(),this.syncVisibleState()}}static{this.defaultStrings={...super.defaultStrings,toastOverflow:LYRA_DEFAULT_toastOverflow}}static{this.styles=[LyraElement.styles,styles]}get stack(){return this.renderRoot.querySelector('[part="stack"]')}connectedCallback(){super.connectedCallback(),this.connectionGeneration+=1,this.overflowSink??=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this});const MutationObserverConstructor=this.ownerDocument.defaultView?.MutationObserver;MutationObserverConstructor&&(this.childObserver=new MutationObserverConstructor(this.reconcileEntries),this.childObserver.observe(this,{childList:!0})),this.reconcileEntries(),this.syncVisibleState()}disconnectedCallback(){const connectionGeneration=++this.connectionGeneration;this.childObserver?.disconnect(),this.childObserver=void 0,this.overflowSink?.release(),this.overflowSink=void 0,this.pendingOverflowCount=0,this.overflowNotificationScheduled=!1,setCustomState(this.toastInternals,"visible",!1);const releaseAfterLastingDisconnect=()=>{if(!(connectionGeneration!==this.connectionGeneration||this.isConnected)){for(const entry of[...this.managedEntries])this.forgetEntry(entry),entry[TOAST_REGION_EVICT](this.regionController,"rejected"),entry.parentElement===this&&entry.remove();this.activeEntries.length=0,this.queuedEntries.length=0,this.managedEntries.clear(),this.admissionsInProgress.clear()}},view=this.ownerDocument.defaultView;view?view.queueMicrotask(releaseAfterLastingDisconnect):queueMicrotask(releaseAfterLastingDisconnect),super.disconnectedCallback()}get regionController(){return this}[TOAST_REGION_ENQUEUE](entry){if(isToastRegionEntry(entry)){if(this.pruneAbsentEntries(),this.promoteQueuedEntries(),entry.parentElement!==this){this.admissionsInProgress.add(entry);try{this.appendChild(entry)}finally{this.admissionsInProgress.delete(entry)}}else if(this.admissionsInProgress.has(entry))return;entry.parentElement===this&&(this.managedEntries.has(entry)?this.reassertEntry(entry):this.admitEntry(entry),this.syncVisibleState())}}[TOAST_REGION_REJECT](entry){isToastRegionEntry(entry)&&this.managedEntries.has(entry)&&(this.forgetEntry(entry),entry[TOAST_REGION_EVICT](this.regionController,"rejected"),this.promoteQueuedEntries(),this.syncVisibleState())}admitEntry(entry){if(entry.parentElement===this){if(this.managedEntries.add(entry),this.activeEntries.length<MAX_VISIBLE_TOASTS){this.activeEntries.push(entry),entry[TOAST_REGION_SET_ACTIVE](this.regionController,!0);return}if(this.queuedEntries.length>=MAX_QUEUED_TOASTS){const evicted=this.queuedEntries.shift();evicted&&(this.managedEntries.delete(evicted),evicted[TOAST_REGION_EVICT](this.regionController,"overflow"),this.recordOverflow())}this.queuedEntries.push(entry),entry[TOAST_REGION_SET_ACTIVE](this.regionController,!1)}}reassertEntry(entry){if(entry.parentElement===this){if(this.activeEntries.includes(entry)){entry[TOAST_REGION_SET_ACTIVE](this.regionController,!0);return}if(this.queuedEntries.includes(entry)){entry[TOAST_REGION_SET_ACTIVE](this.regionController,!1);return}this.managedEntries.delete(entry),this.admitEntry(entry)}}pruneAbsentEntries(){for(const entry of[...this.managedEntries])entry.parentElement!==this&&this.forgetEntry(entry)}forgetEntry(entry){this.managedEntries.delete(entry);const activeIndex=this.activeEntries.indexOf(entry);activeIndex>=0&&this.activeEntries.splice(activeIndex,1);const queuedIndex=this.queuedEntries.indexOf(entry);queuedIndex>=0&&this.queuedEntries.splice(queuedIndex,1)}promoteQueuedEntries(){for(;this.activeEntries.length<MAX_VISIBLE_TOASTS&&this.queuedEntries.length>0;){const entry=this.queuedEntries.shift();!entry||!this.managedEntries.has(entry)||entry.parentElement!==this||(this.activeEntries.push(entry),entry[TOAST_REGION_SET_ACTIVE](this.regionController,!0))}}recordOverflow(){if(this.pendingOverflowCount+=1,this.overflowNotificationScheduled)return;this.overflowNotificationScheduled=!0;const notify=()=>{this.overflowNotificationScheduled=!1;const count=this.pendingOverflowCount;this.pendingOverflowCount=0,!(count<=0)&&(this.emit("lr-toast-overflow",{count}),this.isConnected&&this.overflowSink?.announce(this.localize("toastOverflow",void 0,{count})))},view=this.ownerDocument.defaultView;view?view.requestAnimationFrame(()=>view.requestAnimationFrame(notify)):queueMicrotask(notify)}async create(messageOrOptions,legacyOptions={}){if(!this.isConnected)throw new TypeError("A toast region must be connected before create().");const options=typeof messageOrOptions=="string"?{...legacyOptions,message:messageOrOptions}:messageOrOptions;if(options.ownerDocument&&options.ownerDocument!==this.ownerDocument)throw new TypeError("Toast ownerDocument must match the region owner document.");if(options.placement&&options.placement!==this.placement)throw new TypeError("Toast placement must match the region placement.");const itemTag=tag("toast-item");if(!this.ownerDocument.defaultView?.customElements?.get(itemTag))throw new TypeError(`${itemTag} is not registered in the toast owner document.`);const item=this.ownerDocument.createElement(itemTag);if(typeof item.hide!="function"||!("updateComplete"in item))throw new TypeError(`${itemTag} does not expose the Lyra toast-item contract.`);if(options.variant!==void 0&&(item.variant=options.variant),options.duration!==void 0&&(item.duration=options.duration),options.size!==void 0&&(item.size=options.size),options.withIcon!==void 0&&(item.withIcon=options.withIcon),item.textContent=options.message,options.icon!==void 0){item.withIcon=!0;const iconHost=this.ownerDocument.createElement("span");iconHost.slot="icon",iconHost.setAttribute("aria-hidden","true");const content=typeof options.icon=="function"?options.icon(this.ownerDocument):options.icon;if(typeof content=="string")iconHost.textContent=content;else if(content&&typeof content=="object"&&"nodeType"in content){const node=content;iconHost.append(node.ownerDocument===this.ownerDocument?node:this.ownerDocument.importNode(node,!0))}else render(content,iconHost);item.append(iconHost)}if(options.action){const action=this.ownerDocument.createElement("button");action.type="button",action.textContent=options.action.label,action.addEventListener("click",()=>options.action?.onClick(item)),item.append(action)}if(!isToastRegionEntry(item))throw new TypeError(`${itemTag} does not expose the bounded toast-region protocol.`);return this[TOAST_REGION_ENQUEUE](item),this.syncVisibleState(),await item.updateComplete,item}render(){return html`<div part="stack">
1
+ import{__decorate}from"tslib";import{html,render}from"lit";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{property}from"lit/decorators.js";import{setCustomState}from"../../../internal/custom-states.js";import{LyraElement}from"../../../internal/lyra-element.js";import{tag}from"../../../internal/prefix.js";import{styles}from"./toast.styles.js";import{isToastRegionEntry,TOAST_REGION_ENQUEUE,TOAST_REGION_EVICT,TOAST_REGION_REJECT,TOAST_REGION_SET_ACTIVE}from"./toast-region-protocol.js";import{LYRA_DEFAULT_toastOverflow}from"../../../internal/default-strings/overlays.generated.js";const MAX_VISIBLE_TOASTS=3,MAX_QUEUED_TOASTS=20;class LyraToast extends LyraElement{constructor(){super(...arguments),this.placement="top-end",this.toastInternals=attachInternalsSafely(this),this.managedEntries=new Set,this.activeEntries=[],this.queuedEntries=[],this.admissionsInProgress=new Set,this.connectionGeneration=0,this.pendingOverflowCount=0,this.overflowNotificationScheduled=!1,this.syncVisibleState=()=>{const hasToast=this.isConnected&&Array.from(this.children).some(child=>isToastRegionEntry(child));setCustomState(this.toastInternals,"visible",hasToast)},this.reconcileEntries=()=>{const children=Array.from(this.children);this.pruneAbsentEntries(),this.promoteQueuedEntries();for(const child of children){if(!isToastRegionEntry(child)){child.localName===tag("toast-item")&&this.ownerDocument.defaultView?.customElements.get(child.localName)&&child.remove();continue}this.managedEntries.has(child)?this.reassertEntry(child):this.admitEntry(child)}this.promoteQueuedEntries(),this.syncVisibleState()}}static{this.defaultStrings={...super.defaultStrings,toastOverflow:LYRA_DEFAULT_toastOverflow}}static{this.styles=[LyraElement.styles,styles]}get stack(){return this.renderRoot.querySelector('[part="stack"]')}connectedCallback(){super.connectedCallback(),this.connectionGeneration+=1,this.overflowSink??=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this});const MutationObserverConstructor=this.ownerDocument.defaultView?.MutationObserver;MutationObserverConstructor&&(this.childObserver=new MutationObserverConstructor(this.reconcileEntries),this.childObserver.observe(this,{childList:!0})),this.reconcileEntries(),this.syncVisibleState()}disconnectedCallback(){const connectionGeneration=++this.connectionGeneration;this.childObserver?.disconnect(),this.childObserver=void 0,this.overflowSink?.release(),this.overflowSink=void 0,this.pendingOverflowCount=0,this.overflowNotificationScheduled=!1,setCustomState(this.toastInternals,"visible",!1);const releaseAfterLastingDisconnect=()=>{if(!(connectionGeneration!==this.connectionGeneration||this.isConnected)){for(const entry of[...this.managedEntries])this.forgetEntry(entry),entry[TOAST_REGION_EVICT](this.regionController,"rejected"),entry.parentElement===this&&entry.remove();this.activeEntries.length=0,this.queuedEntries.length=0,this.managedEntries.clear(),this.admissionsInProgress.clear()}},view=this.ownerDocument.defaultView;view?view.queueMicrotask(releaseAfterLastingDisconnect):queueMicrotask(releaseAfterLastingDisconnect),super.disconnectedCallback()}get regionController(){return this}[TOAST_REGION_ENQUEUE](entry){if(isToastRegionEntry(entry)){if(this.pruneAbsentEntries(),this.promoteQueuedEntries(),entry.parentElement!==this){this.admissionsInProgress.add(entry);try{this.appendChild(entry)}finally{this.admissionsInProgress.delete(entry)}}else if(this.admissionsInProgress.has(entry))return;entry.parentElement===this&&(this.managedEntries.has(entry)?this.reassertEntry(entry):this.admitEntry(entry),this.syncVisibleState())}}[TOAST_REGION_REJECT](entry){isToastRegionEntry(entry)&&this.managedEntries.has(entry)&&(this.forgetEntry(entry),entry[TOAST_REGION_EVICT](this.regionController,"rejected"),this.promoteQueuedEntries(),this.syncVisibleState())}admitEntry(entry){if(entry.parentElement===this){if(this.managedEntries.add(entry),this.activeEntries.length<MAX_VISIBLE_TOASTS){this.activeEntries.push(entry),entry[TOAST_REGION_SET_ACTIVE](this.regionController,!0);return}if(this.queuedEntries.length>=MAX_QUEUED_TOASTS){const evicted=this.queuedEntries.shift();evicted&&(this.managedEntries.delete(evicted),evicted[TOAST_REGION_EVICT](this.regionController,"overflow"),this.recordOverflow())}this.queuedEntries.push(entry),entry[TOAST_REGION_SET_ACTIVE](this.regionController,!1)}}reassertEntry(entry){if(entry.parentElement===this){if(this.activeEntries.includes(entry)){entry[TOAST_REGION_SET_ACTIVE](this.regionController,!0);return}if(this.queuedEntries.includes(entry)){entry[TOAST_REGION_SET_ACTIVE](this.regionController,!1);return}this.managedEntries.delete(entry),this.admitEntry(entry)}}pruneAbsentEntries(){for(const entry of[...this.managedEntries])entry.parentElement!==this&&this.forgetEntry(entry)}forgetEntry(entry){this.managedEntries.delete(entry);const activeIndex=this.activeEntries.indexOf(entry);activeIndex>=0&&this.activeEntries.splice(activeIndex,1);const queuedIndex=this.queuedEntries.indexOf(entry);queuedIndex>=0&&this.queuedEntries.splice(queuedIndex,1)}promoteQueuedEntries(){for(;this.activeEntries.length<MAX_VISIBLE_TOASTS&&this.queuedEntries.length>0;){const entry=this.queuedEntries.shift();!entry||!this.managedEntries.has(entry)||entry.parentElement!==this||(this.activeEntries.push(entry),entry[TOAST_REGION_SET_ACTIVE](this.regionController,!0))}}recordOverflow(){if(this.pendingOverflowCount+=1,this.overflowNotificationScheduled)return;this.overflowNotificationScheduled=!0;const notify=()=>{this.overflowNotificationScheduled=!1;const count=this.pendingOverflowCount;this.pendingOverflowCount=0,!(count<=0)&&(this.emit("lr-toast-overflow",{count}),this.isConnected&&this.overflowSink?.announce(this.localize("toastOverflow",void 0,{count})))},view=this.ownerDocument.defaultView;view?view.requestAnimationFrame(()=>view.requestAnimationFrame(notify)):queueMicrotask(notify)}async create(messageOrOptions,legacyOptions={}){if(!this.isConnected)throw new TypeError("A toast region must be connected before create().");const options=typeof messageOrOptions=="string"?{...legacyOptions,message:messageOrOptions}:messageOrOptions;if(options.ownerDocument&&options.ownerDocument!==this.ownerDocument)throw new TypeError("Toast ownerDocument must match the region owner document.");if(options.placement&&options.placement!==this.placement)throw new TypeError("Toast placement must match the region placement.");const itemTag=tag("toast-item");if(!this.ownerDocument.defaultView?.customElements?.get(itemTag))throw new TypeError(`${itemTag} is not registered in the toast owner document.`);const item=this.ownerDocument.createElement(itemTag);if(typeof item.hide!="function"||!("updateComplete"in item))throw new TypeError(`${itemTag} does not expose the Lyra toast-item contract.`);if(options.variant!==void 0&&(item.variant=options.variant),options.duration!==void 0&&(item.duration=options.duration),options.size!==void 0&&(item.size=options.size),options.withIcon!==void 0&&(item.withIcon=options.withIcon),item.textContent=options.message,options.icon!==void 0){item.withIcon=!0;const iconHost=this.ownerDocument.createElement("span");iconHost.slot="icon",iconHost.setAttribute("aria-hidden","true");const content=typeof options.icon=="function"?options.icon(this.ownerDocument):options.icon;if(typeof content=="string")iconHost.textContent=content;else if(content&&typeof content=="object"&&"nodeType"in content){const node=content;iconHost.append(node.ownerDocument===this.ownerDocument?node:this.ownerDocument.importNode(node,!0))}else render(content,iconHost);item.append(iconHost)}if(options.action){const action=this.ownerDocument.createElement("button");action.type="button",action.textContent=options.action.label,action.addEventListener("click",()=>options.action?.onClick(item)),item.append(action)}if(!isToastRegionEntry(item))throw new TypeError(`${itemTag} does not expose the bounded toast-region protocol.`);return this[TOAST_REGION_ENQUEUE](item),this.syncVisibleState(),await item.updateComplete,item}render(){return html`<div part="stack">
2
2
  <slot @slotchange=${this.syncVisibleState}></slot>
3
3
  </div>`}}__decorate([property({reflect:!0})],LyraToast.prototype,"placement",void 0);export{LyraToast};
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property}from"lit/decorators.js";import{guard}from"lit/directives/guard.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{normalizeSize}from"../../../internal/variants.js";import{firstByRetrievalIdentity}from"../retrieval-identity.js";import{finiteCount,finiteNumber,finiteRange}from"../../../internal/numbers.js";import{getListFormat,getNumberFormat}from"../../../internal/intl-cache.js";import"../../layout/virtual-list/virtual-list.class.js";import"../../overlays/empty/empty.class.js";import{styles}from"./chunk-inspector.styles.js";import{retrievalSemanticLabel,retrievalSemanticRole}from"../retrieval-semantic-owner.js";import{resolveScoreTiers}from"../../../internal/score-tiers.js";import{LYRA_DEFAULT_chunkInspectorEmpty,LYRA_DEFAULT_chunkInspectorLabel,LYRA_DEFAULT_chunkInspectorOpenOrdinal,LYRA_DEFAULT_chunkScore,LYRA_DEFAULT_scoreTierHigh,LYRA_DEFAULT_scoreTierLow,LYRA_DEFAULT_scoreTierMedium,LYRA_DEFAULT_showLess,LYRA_DEFAULT_showMore,LYRA_DEFAULT_sourcePageSuffix,LYRA_DEFAULT_untitledSource}from"../../../internal/default-strings.generated.js";const DEFAULT_TIERS={high:.75,medium:.5};function isDenseSize(size){const step=normalizeSize(size);return step==="s"||step==="xs"||step==="2xs"}class LyraChunkInspector extends LyraElement{constructor(){super(...arguments),this.chunks=[],this.thresholds={high:.75,medium:.5},this.sort="score",this.activeChunkId="",this.virtualizeAt=50,this.size="m",this.expandedChunkIds=[],this.chunkOrdinalById=new Map,this.chunkKey=item=>item.id,this.renderChunk=item=>this.chunkTemplate(item,this.ordinalIndex!==void 0),this.renderVirtualChunk=item=>this.chunkTemplate(item,!0),this.stopOwnedEvent=event=>{event.stopPropagation()}}static{this.defaultStrings={...super.defaultStrings,chunkInspectorEmpty:LYRA_DEFAULT_chunkInspectorEmpty,chunkInspectorLabel:LYRA_DEFAULT_chunkInspectorLabel,chunkInspectorOpenOrdinal:LYRA_DEFAULT_chunkInspectorOpenOrdinal,chunkScore:LYRA_DEFAULT_chunkScore,scoreTierHigh:LYRA_DEFAULT_scoreTierHigh,scoreTierLow:LYRA_DEFAULT_scoreTierLow,scoreTierMedium:LYRA_DEFAULT_scoreTierMedium,showLess:LYRA_DEFAULT_showLess,showMore:LYRA_DEFAULT_showMore,sourcePageSuffix:LYRA_DEFAULT_sourcePageSuffix,untitledSource:LYRA_DEFAULT_untitledSource}}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["chunks","expandedChunkIds"])}static{this.styles=[LyraElement.styles,styles]}static{this.immutableEventDetails=Object.freeze(["lr-chunk-open"])}get dense(){return isDenseSize(this.size)}get effectiveVirtualizeAt(){return finiteCount(this.virtualizeAt,50)}sortedChunks(){const cached=this.sortedChunksCache;if(cached&&cached.source===this.chunks&&cached.sort===this.sort)return cached.result;const canonical=firstByRetrievalIdentity(this.chunks,chunk=>chunk.id),result=this.sort==="score"?canonical.sort((a,b)=>this.safeScore(b.score)-this.safeScore(a.score)):canonical;return this.sortedChunksCache={source:this.chunks,sort:this.sort,result},this.chunkOrdinalById=new Map(result.map((chunk,index)=>[chunk.id,index])),result}safeScore(score){return finiteRange(score,0,0,1)}tier(score){const safeScore=this.safeScore(score),{high,medium}=resolveScoreTiers(DEFAULT_TIERS,this.thresholds);return safeScore>=high?"high":safeScore>=medium?"medium":"low"}tierTone(tier){return tier==="high"?"success":tier==="medium"?"warning":"danger"}tierLabel(tier){return this.localize(tier==="high"?"scoreTierHigh":tier==="medium"?"scoreTierMedium":"scoreTierLow")}toggleExpand(chunkId){const expanded=!this.expandedChunkIds.includes(chunkId);this.expandedChunkIds=expanded?[...this.expandedChunkIds,chunkId]:this.expandedChunkIds.filter(id=>id!==chunkId),this.emit("lr-chunk-toggle",{chunkId,expanded}),this.emit("lr-toggle",{itemId:chunkId,expanded})}chunkTemplate(chunk,virtualized){const tier=this.tier(chunk.score),tone=this.tierTone(tier),percent=Math.round(this.safeScore(chunk.score)*100),formattedPercent=getNumberFormat(this.effectiveLocale).format(percent),titleText=chunk.title||this.localize("untitledSource"),formattedPage=typeof chunk.page=="number"&&Number.isFinite(chunk.page)?getNumberFormat(this.effectiveLocale).format(finiteNumber(chunk.page,0)):chunk.page,titleWithPage=formattedPage==null||formattedPage===""?titleText:this.localize("sourcePageSuffix",void 0,{base:titleText,page:formattedPage}),ordinalIndex=this.ordinalIndex===void 0?(this.chunkOrdinalById.get(chunk.id)??0)+1:Math.max(1,finiteCount(this.ordinalIndex,1)),ordinalTotal=this.ordinalTotal===void 0?this.sortedChunks().length:Math.max(ordinalIndex,finiteCount(this.ordinalTotal,ordinalIndex)),expanded=this.expandedChunkIds.includes(chunk.id),current=this.activeChunkId===chunk.id;return html`
1
+ import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property}from"lit/decorators.js";import{guard}from"lit/directives/guard.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{normalizeSize}from"../../../internal/variants.js";import{firstByRetrievalIdentity}from"../retrieval-identity.js";import{finiteCount,finiteNumber,finiteRange}from"../../../internal/numbers.js";import{getListFormat,getNumberFormat}from"../../../internal/intl-cache.js";import"../../layout/virtual-list/virtual-list.class.js";import"../../overlays/empty/empty.class.js";import{styles}from"./chunk-inspector.styles.js";import{retrievalSemanticLabel,retrievalSemanticRole}from"../retrieval-semantic-owner.js";import{resolveScoreTiers}from"../../../internal/score-tiers.js";import{LYRA_DEFAULT_chunkInspectorEmpty,LYRA_DEFAULT_chunkInspectorLabel,LYRA_DEFAULT_chunkInspectorOpenOrdinal,LYRA_DEFAULT_chunkScore,LYRA_DEFAULT_scoreTierHigh,LYRA_DEFAULT_scoreTierLow,LYRA_DEFAULT_scoreTierMedium,LYRA_DEFAULT_showMore,LYRA_DEFAULT_sourcePageSuffix,LYRA_DEFAULT_untitledSource}from"../../../internal/default-strings/retrieval.generated.js";import{LYRA_DEFAULT_showLess}from"../../../internal/default-strings/shared.generated.js";const DEFAULT_TIERS={high:.75,medium:.5};function isDenseSize(size){const step=normalizeSize(size);return step==="s"||step==="xs"||step==="2xs"}class LyraChunkInspector extends LyraElement{constructor(){super(...arguments),this.chunks=[],this.thresholds={high:.75,medium:.5},this.sort="score",this.activeChunkId="",this.virtualizeAt=50,this.size="m",this.expandedChunkIds=[],this.chunkOrdinalById=new Map,this.chunkKey=item=>item.id,this.renderChunk=item=>this.chunkTemplate(item,this.ordinalIndex!==void 0),this.renderVirtualChunk=item=>this.chunkTemplate(item,!0),this.stopOwnedEvent=event=>{event.stopPropagation()}}static{this.defaultStrings={...super.defaultStrings,chunkInspectorEmpty:LYRA_DEFAULT_chunkInspectorEmpty,chunkInspectorLabel:LYRA_DEFAULT_chunkInspectorLabel,chunkInspectorOpenOrdinal:LYRA_DEFAULT_chunkInspectorOpenOrdinal,chunkScore:LYRA_DEFAULT_chunkScore,scoreTierHigh:LYRA_DEFAULT_scoreTierHigh,scoreTierLow:LYRA_DEFAULT_scoreTierLow,scoreTierMedium:LYRA_DEFAULT_scoreTierMedium,showLess:LYRA_DEFAULT_showLess,showMore:LYRA_DEFAULT_showMore,sourcePageSuffix:LYRA_DEFAULT_sourcePageSuffix,untitledSource:LYRA_DEFAULT_untitledSource}}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["chunks","expandedChunkIds"])}static{this.styles=[LyraElement.styles,styles]}static{this.immutableEventDetails=Object.freeze(["lr-chunk-open"])}get dense(){return isDenseSize(this.size)}get effectiveVirtualizeAt(){return finiteCount(this.virtualizeAt,50)}sortedChunks(){const cached=this.sortedChunksCache;if(cached&&cached.source===this.chunks&&cached.sort===this.sort)return cached.result;const canonical=firstByRetrievalIdentity(this.chunks,chunk=>chunk.id),result=this.sort==="score"?canonical.sort((a,b)=>this.safeScore(b.score)-this.safeScore(a.score)):canonical;return this.sortedChunksCache={source:this.chunks,sort:this.sort,result},this.chunkOrdinalById=new Map(result.map((chunk,index)=>[chunk.id,index])),result}safeScore(score){return finiteRange(score,0,0,1)}tier(score){const safeScore=this.safeScore(score),{high,medium}=resolveScoreTiers(DEFAULT_TIERS,this.thresholds);return safeScore>=high?"high":safeScore>=medium?"medium":"low"}tierTone(tier){return tier==="high"?"success":tier==="medium"?"warning":"danger"}tierLabel(tier){return this.localize(tier==="high"?"scoreTierHigh":tier==="medium"?"scoreTierMedium":"scoreTierLow")}toggleExpand(chunkId){const expanded=!this.expandedChunkIds.includes(chunkId);this.expandedChunkIds=expanded?[...this.expandedChunkIds,chunkId]:this.expandedChunkIds.filter(id=>id!==chunkId),this.emit("lr-chunk-toggle",{chunkId,expanded}),this.emit("lr-toggle",{itemId:chunkId,expanded})}chunkTemplate(chunk,virtualized){const tier=this.tier(chunk.score),tone=this.tierTone(tier),percent=Math.round(this.safeScore(chunk.score)*100),formattedPercent=getNumberFormat(this.effectiveLocale).format(percent),titleText=chunk.title||this.localize("untitledSource"),formattedPage=typeof chunk.page=="number"&&Number.isFinite(chunk.page)?getNumberFormat(this.effectiveLocale).format(finiteNumber(chunk.page,0)):chunk.page,titleWithPage=formattedPage==null||formattedPage===""?titleText:this.localize("sourcePageSuffix",void 0,{base:titleText,page:formattedPage}),ordinalIndex=this.ordinalIndex===void 0?(this.chunkOrdinalById.get(chunk.id)??0)+1:Math.max(1,finiteCount(this.ordinalIndex,1)),ordinalTotal=this.ordinalTotal===void 0?this.sortedChunks().length:Math.max(ordinalIndex,finiteCount(this.ordinalTotal,ordinalIndex)),expanded=this.expandedChunkIds.includes(chunk.id),current=this.activeChunkId===chunk.id;return html`
2
2
  <div
3
3
  part=${current?"chunk chunk-current":"chunk"}
4
4
  role=${virtualized?nothing:"listitem"}
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,state,query}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{PreviewDisclosureController}from"../../../internal/preview-disclosure-controller.js";import{nextId}from"../../../internal/a11y.js";import{SlotPresenceController}from"../../../internal/slot-presence-controller.js";import{finiteInteger}from"../../../internal/numbers.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{styles}from"./citation-badge.styles.js";import{LYRA_DEFAULT_citation,LYRA_DEFAULT_citationHighConfidence,LYRA_DEFAULT_citationLowConfidence,LYRA_DEFAULT_citationMediumConfidence,LYRA_DEFAULT_citationUnverified,LYRA_DEFAULT_citationVerified,LYRA_DEFAULT_citationWithCustomLabel,LYRA_DEFAULT_citationWithStatus,LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings.generated.js";const STATUS_MESSAGE_KEY={default:null,high:"citationHighConfidence",medium:"citationMediumConfidence",low:"citationLowConfidence",verified:"citationVerified",unverified:"citationUnverified"},HIDE_DELAY_MS=200;class LyraCitationBadge extends LyraElement{constructor(){super(...arguments),this._index=1,this.status="default",this.sourceId="",this.href="",this.label="",this.popoverOpen=!1,this.popoverId=nextId("citation-badge-popover"),this.slotPresence=new SlotPresenceController(this),this.preview=new PreviewDisclosureController({host:this,button:()=>this.buttonEl,panel:()=>this.popoverEl,hasContent:()=>this.hasPreviewSlot,isOpen:()=>this.popoverOpen,setOpen:open=>{this.popoverOpen=open},hideDelayMs:HIDE_DELAY_MS}),this.onKeyDown=e=>{e.key===" "&&!e.repeat&&e.target===this.buttonEl&&(e.preventDefault(),this.emitOpen())},this.onClick=()=>{this.emit("lr-citation-activate",{sourceId:this.sourceId,index:this.index})},this.onDblClick=()=>{this.emitOpen()}}static{this.defaultStrings={...super.defaultStrings,citation:LYRA_DEFAULT_citation,citationHighConfidence:LYRA_DEFAULT_citationHighConfidence,citationLowConfidence:LYRA_DEFAULT_citationLowConfidence,citationMediumConfidence:LYRA_DEFAULT_citationMediumConfidence,citationUnverified:LYRA_DEFAULT_citationUnverified,citationVerified:LYRA_DEFAULT_citationVerified,citationWithCustomLabel:LYRA_DEFAULT_citationWithCustomLabel,citationWithStatus:LYRA_DEFAULT_citationWithStatus,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}static{this.styles=[LyraElement.styles,styles]}get index(){return this._index}set index(value){const old=this._index;this._index=finiteInteger(value,1,1),this.requestUpdate("index",old)}get hasPreviewSlot(){return this.slotPresence.has()}willUpdate(changed){super.willUpdate(changed),this.preview.ensureContent()}updated(changed){super.updated(changed),changed.has("popoverOpen")&&this.preview.syncOpen()}disconnectedCallback(){super.disconnectedCallback(),this.preview.disconnect()}get accessibleLabel(){const index=getNumberFormat(this.effectiveLocale).format(this.index);if(this.label)return this.localize("citationWithCustomLabel",void 0,{index,label:this.label});const key=STATUS_MESSAGE_KEY[this.status],statusText=key?this.localize(key):"",citationLabel=this.localize("citation",void 0,{index});return statusText?this.localize("citationWithStatus",void 0,{index,status:statusText}):citationLabel}emitOpen(){this.emit("lr-citation-open",{sourceId:this.sourceId,index:this.index,href:this.href||void 0})}render(){const formattedIndex=getNumberFormat(this.effectiveLocale).format(this.index);return html`
1
+ import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,state,query}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{PreviewDisclosureController}from"../../../internal/preview-disclosure-controller.js";import{nextId}from"../../../internal/a11y.js";import{SlotPresenceController}from"../../../internal/slot-presence-controller.js";import{finiteInteger}from"../../../internal/numbers.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{styles}from"./citation-badge.styles.js";import{LYRA_DEFAULT_citation,LYRA_DEFAULT_citationHighConfidence,LYRA_DEFAULT_citationLowConfidence,LYRA_DEFAULT_citationMediumConfidence,LYRA_DEFAULT_citationUnverified,LYRA_DEFAULT_citationVerified,LYRA_DEFAULT_citationWithCustomLabel,LYRA_DEFAULT_citationWithStatus}from"../../../internal/default-strings/retrieval.generated.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings/shared.generated.js";const STATUS_MESSAGE_KEY={default:null,high:"citationHighConfidence",medium:"citationMediumConfidence",low:"citationLowConfidence",verified:"citationVerified",unverified:"citationUnverified"},HIDE_DELAY_MS=200;class LyraCitationBadge extends LyraElement{constructor(){super(...arguments),this._index=1,this.status="default",this.sourceId="",this.href="",this.label="",this.popoverOpen=!1,this.popoverId=nextId("citation-badge-popover"),this.slotPresence=new SlotPresenceController(this),this.preview=new PreviewDisclosureController({host:this,button:()=>this.buttonEl,panel:()=>this.popoverEl,hasContent:()=>this.hasPreviewSlot,isOpen:()=>this.popoverOpen,setOpen:open=>{this.popoverOpen=open},hideDelayMs:HIDE_DELAY_MS}),this.onKeyDown=e=>{e.key===" "&&!e.repeat&&e.target===this.buttonEl&&(e.preventDefault(),this.emitOpen())},this.onClick=()=>{this.emit("lr-citation-activate",{sourceId:this.sourceId,index:this.index})},this.onDblClick=()=>{this.emitOpen()}}static{this.defaultStrings={...super.defaultStrings,citation:LYRA_DEFAULT_citation,citationHighConfidence:LYRA_DEFAULT_citationHighConfidence,citationLowConfidence:LYRA_DEFAULT_citationLowConfidence,citationMediumConfidence:LYRA_DEFAULT_citationMediumConfidence,citationUnverified:LYRA_DEFAULT_citationUnverified,citationVerified:LYRA_DEFAULT_citationVerified,citationWithCustomLabel:LYRA_DEFAULT_citationWithCustomLabel,citationWithStatus:LYRA_DEFAULT_citationWithStatus,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}static{this.styles=[LyraElement.styles,styles]}get index(){return this._index}set index(value){const old=this._index;this._index=finiteInteger(value,1,1),this.requestUpdate("index",old)}get hasPreviewSlot(){return this.slotPresence.has()}willUpdate(changed){super.willUpdate(changed),this.preview.ensureContent()}updated(changed){super.updated(changed),changed.has("popoverOpen")&&this.preview.syncOpen()}disconnectedCallback(){super.disconnectedCallback(),this.preview.disconnect()}get accessibleLabel(){const index=getNumberFormat(this.effectiveLocale).format(this.index);if(this.label)return this.localize("citationWithCustomLabel",void 0,{index,label:this.label});const key=STATUS_MESSAGE_KEY[this.status],statusText=key?this.localize(key):"",citationLabel=this.localize("citation",void 0,{index});return statusText?this.localize("citationWithStatus",void 0,{index,status:statusText}):citationLabel}emitOpen(){this.emit("lr-citation-open",{sourceId:this.sourceId,index:this.index,href:this.href||void 0})}render(){const formattedIndex=getNumberFormat(this.effectiveLocale).format(this.index);return html`
2
2
  <span
3
3
  class="wrapper"
4
4
  @pointerenter=${()=>this.preview.pointerEnter()}
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property}from"lit/decorators.js";import{getOwnDataDescriptor,projectFrozenRows,MISSING_OWN_DATA_DESCRIPTOR,UNSAFE_OWN_DATA_DESCRIPTOR}from"../../../internal/data-descriptors.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{projectGroundedClaim}from"../grounded-claim-projection.js";import{isRovingTargetAvailable,resolveListMove}from"../../../internal/list-navigation.js";import{devWarnOnce}from"../../../internal/dev-warning.js";import{LyraElement}from"../../../internal/lyra-element.js";import{finiteRange}from"../../../internal/numbers.js";import"../../overlays/badge/badge.class.js";import"../../overlays/empty/empty.class.js";import"../citation-badge/citation-badge.class.js";import{styles}from"./claim-evidence.styles.js";import{retrievalSemanticLabel,retrievalSemanticRole}from"../retrieval-semantic-owner.js";import{LYRA_DEFAULT_citation,LYRA_DEFAULT_claimEvidenceClaimsLimit,LYRA_DEFAULT_claimEvidenceConfidence,LYRA_DEFAULT_claimEvidenceContradicted,LYRA_DEFAULT_claimEvidenceEmpty,LYRA_DEFAULT_claimEvidenceLabel,LYRA_DEFAULT_claimEvidencePartiallySupported,LYRA_DEFAULT_claimEvidenceSupported,LYRA_DEFAULT_claimEvidenceUnsupported,LYRA_DEFAULT_collapse,LYRA_DEFAULT_copy,LYRA_DEFAULT_details,LYRA_DEFAULT_loading,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_search,LYRA_DEFAULT_select,LYRA_DEFAULT_statusUnknown}from"../../../internal/default-strings.generated.js";const STATUS_VARIANT={supported:"success","partially-supported":"warning",unsupported:"danger",contradicted:"danger",unknown:"neutral"},MAX_PROJECTED_CLAIM_EVIDENCE_ROWS=1e4,MAX_RENDERED_CLAIM_EVIDENCE_CLAIMS=500,EMPTY_CANONICAL_CLAIMS=Object.freeze([]),EMPTY_CANONICAL_CITATIONS=Object.freeze([]);function valueOfDescriptor(descriptor){return descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR?void 0:descriptor.value}function hasUnsafeDescriptor(descriptors){return descriptors.some(descriptor=>descriptor===UNSAFE_OWN_DATA_DESCRIPTOR)}function projectCitation(value){try{if(value===null||typeof value!="object"||Array.isArray(value))return;const idDescriptor=getOwnDataDescriptor(value,"id"),sourceIdDescriptor=getOwnDataDescriptor(value,"sourceId"),labelDescriptor=getOwnDataDescriptor(value,"label"),quoteDescriptor=getOwnDataDescriptor(value,"quote");if(hasUnsafeDescriptor([idDescriptor,sourceIdDescriptor,labelDescriptor,quoteDescriptor]))return;const id=valueOfDescriptor(idDescriptor);if(typeof id!="string"||id.trim().length===0)return;const sourceId=valueOfDescriptor(sourceIdDescriptor),label=valueOfDescriptor(labelDescriptor),quote=valueOfDescriptor(quoteDescriptor);return Object.freeze({source:value,id,...typeof sourceId=="string"?{sourceId}:{},...typeof label=="string"?{label}:{},...typeof quote=="string"?{quote}:{}})}catch{return}}function projectRows(value,project,empty){return projectFrozenRows(value,project,MAX_PROJECTED_CLAIM_EVIDENCE_ROWS,empty,row=>row.id)}function normalizedClaimStatus(status){switch(status){case"supported":case"partially-supported":case"unsupported":case"contradicted":return status;default:return"unknown"}}class LyraClaimEvidence extends LyraElement{constructor(){super(...arguments),this.rovingClaimId="",this.claims=[],this.citations=[],this.selectedClaimId="",this.size="m",this.frame="card",this.canonicalClaimsBySource=new WeakMap,this.canonicalCitationsBySource=new WeakMap}static{this.defaultStrings={...super.defaultStrings,citation:LYRA_DEFAULT_citation,claimEvidenceClaimsLimit:LYRA_DEFAULT_claimEvidenceClaimsLimit,claimEvidenceConfidence:LYRA_DEFAULT_claimEvidenceConfidence,claimEvidenceContradicted:LYRA_DEFAULT_claimEvidenceContradicted,claimEvidenceEmpty:LYRA_DEFAULT_claimEvidenceEmpty,claimEvidenceLabel:LYRA_DEFAULT_claimEvidenceLabel,claimEvidencePartiallySupported:LYRA_DEFAULT_claimEvidencePartiallySupported,claimEvidenceSupported:LYRA_DEFAULT_claimEvidenceSupported,claimEvidenceUnsupported:LYRA_DEFAULT_claimEvidenceUnsupported,collapse:LYRA_DEFAULT_collapse,copy:LYRA_DEFAULT_copy,details:LYRA_DEFAULT_details,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select,statusUnknown:LYRA_DEFAULT_statusUnknown}}onClaimKeyDown(event,index,count){const buttons=this.shadowRoot?.querySelectorAll('[part="claim-trigger"]'),next=resolveListMove(event,{count,current:index,orientation:"vertical",isAvailable:candidate=>!!(buttons?.[candidate]&&isRovingTargetAvailable(buttons[candidate]))});next!==null&&(event.preventDefault(),buttons?.[next]?.focus())}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["claims","citations"])}static{this.identityCollectionProperties=Object.freeze(["claims","citations"])}static{this.styles=[LyraElement.styles,styles]}static{this.immutableEventDetails=Object.freeze(["lr-claim-select","lr-citation-select","lr-citation-open"])}static{this.identityEventDetailProperties=Object.freeze({"lr-claim-select":Object.freeze(["claim"]),"lr-citation-select":Object.freeze(["citation"]),"lr-citation-open":Object.freeze(["citation"])})}canonicalRowsFor(source,cache,project,empty){if(source===null||typeof source!="object")return empty;const cached=cache.get(source);if(cached)return cached;const rows=projectRows(source,project,empty);return cache.set(source,rows),rows}get normalizedClaims(){return this.canonicalRowsFor(this.claims,this.canonicalClaimsBySource,projectGroundedClaim,EMPTY_CANONICAL_CLAIMS)}get normalizedCitations(){return this.canonicalRowsFor(this.citations,this.canonicalCitationsBySource,projectCitation,EMPTY_CANONICAL_CITATIONS)}statusLabel(status){switch(status){case"supported":return this.localize("claimEvidenceSupported");case"partially-supported":return this.localize("claimEvidencePartiallySupported");case"unsupported":return this.localize("claimEvidenceUnsupported");case"contradicted":return this.localize("claimEvidenceContradicted");case"unknown":return this.localize("statusUnknown")}}confidenceLabel(value){const percent=getNumberFormat(this.effectiveLocale,{style:"percent"}).format(finiteRange(value,0,0,1));return this.localize("claimEvidenceConfidence",void 0,{percent})}resolvedCitations(claim,byId){const found=new Set;for(const id of claim.citationIds){const entry=byId.get(id);entry&&found.add(entry)}return[...found].sort((a,b)=>a.index-b.index)}renderClaim(claim,byId,index,count,rovingClaimId){const selected=claim.id===this.selectedClaimId,citations=this.resolvedCitations(claim,byId),status=normalizedClaimStatus(claim.status);return status==="unknown"&&devWarnOnce("lr-claim-evidence:unknown-status",`<lr-claim-evidence>: unknown claim status ${JSON.stringify(claim.status.slice(0,80))}; rendering a neutral status.`),html`
1
+ import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property}from"lit/decorators.js";import{getOwnDataDescriptor,projectFrozenRows,MISSING_OWN_DATA_DESCRIPTOR,UNSAFE_OWN_DATA_DESCRIPTOR}from"../../../internal/data-descriptors.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{projectGroundedClaim}from"../grounded-claim-projection.js";import{isRovingTargetAvailable,resolveListMove}from"../../../internal/list-navigation.js";import{devWarnOnce}from"../../../internal/dev-warning.js";import{LyraElement}from"../../../internal/lyra-element.js";import{finiteRange}from"../../../internal/numbers.js";import"../../overlays/badge/badge.class.js";import"../../overlays/empty/empty.class.js";import"../citation-badge/citation-badge.class.js";import{styles}from"./claim-evidence.styles.js";import{retrievalSemanticLabel,retrievalSemanticRole}from"../retrieval-semantic-owner.js";import{LYRA_DEFAULT_citation,LYRA_DEFAULT_claimEvidenceClaimsLimit,LYRA_DEFAULT_claimEvidenceConfidence,LYRA_DEFAULT_claimEvidenceContradicted,LYRA_DEFAULT_claimEvidenceEmpty,LYRA_DEFAULT_claimEvidenceLabel,LYRA_DEFAULT_claimEvidencePartiallySupported,LYRA_DEFAULT_claimEvidenceSupported,LYRA_DEFAULT_claimEvidenceUnsupported}from"../../../internal/default-strings/retrieval.generated.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_copy,LYRA_DEFAULT_date,LYRA_DEFAULT_details,LYRA_DEFAULT_loading,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_search,LYRA_DEFAULT_select,LYRA_DEFAULT_statusUnknown}from"../../../internal/default-strings/shared.generated.js";const STATUS_VARIANT={supported:"success","partially-supported":"warning",unsupported:"danger",contradicted:"danger",unknown:"neutral"},MAX_PROJECTED_CLAIM_EVIDENCE_ROWS=1e4,MAX_RENDERED_CLAIM_EVIDENCE_CLAIMS=500,EMPTY_CANONICAL_CLAIMS=Object.freeze([]),EMPTY_CANONICAL_CITATIONS=Object.freeze([]);function valueOfDescriptor(descriptor){return descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR?void 0:descriptor.value}function hasUnsafeDescriptor(descriptors){return descriptors.some(descriptor=>descriptor===UNSAFE_OWN_DATA_DESCRIPTOR)}function projectCitation(value){try{if(value===null||typeof value!="object"||Array.isArray(value))return;const idDescriptor=getOwnDataDescriptor(value,"id"),sourceIdDescriptor=getOwnDataDescriptor(value,"sourceId"),labelDescriptor=getOwnDataDescriptor(value,"label"),quoteDescriptor=getOwnDataDescriptor(value,"quote");if(hasUnsafeDescriptor([idDescriptor,sourceIdDescriptor,labelDescriptor,quoteDescriptor]))return;const id=valueOfDescriptor(idDescriptor);if(typeof id!="string"||id.trim().length===0)return;const sourceId=valueOfDescriptor(sourceIdDescriptor),label=valueOfDescriptor(labelDescriptor),quote=valueOfDescriptor(quoteDescriptor);return Object.freeze({source:value,id,...typeof sourceId=="string"?{sourceId}:{},...typeof label=="string"?{label}:{},...typeof quote=="string"?{quote}:{}})}catch{return}}function projectRows(value,project,empty){return projectFrozenRows(value,project,MAX_PROJECTED_CLAIM_EVIDENCE_ROWS,empty,row=>row.id)}function normalizedClaimStatus(status){switch(status){case"supported":case"partially-supported":case"unsupported":case"contradicted":return status;default:return"unknown"}}class LyraClaimEvidence extends LyraElement{constructor(){super(...arguments),this.rovingClaimId="",this.claims=[],this.citations=[],this.selectedClaimId="",this.size="m",this.frame="card",this.canonicalClaimsBySource=new WeakMap,this.canonicalCitationsBySource=new WeakMap}static{this.defaultStrings={...super.defaultStrings,citation:LYRA_DEFAULT_citation,claimEvidenceClaimsLimit:LYRA_DEFAULT_claimEvidenceClaimsLimit,claimEvidenceConfidence:LYRA_DEFAULT_claimEvidenceConfidence,claimEvidenceContradicted:LYRA_DEFAULT_claimEvidenceContradicted,claimEvidenceEmpty:LYRA_DEFAULT_claimEvidenceEmpty,claimEvidenceLabel:LYRA_DEFAULT_claimEvidenceLabel,claimEvidencePartiallySupported:LYRA_DEFAULT_claimEvidencePartiallySupported,claimEvidenceSupported:LYRA_DEFAULT_claimEvidenceSupported,claimEvidenceUnsupported:LYRA_DEFAULT_claimEvidenceUnsupported,collapse:LYRA_DEFAULT_collapse,copy:LYRA_DEFAULT_copy,date:LYRA_DEFAULT_date,details:LYRA_DEFAULT_details,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select,statusUnknown:LYRA_DEFAULT_statusUnknown}}onClaimKeyDown(event,index,count){const buttons=this.shadowRoot?.querySelectorAll('[part="claim-trigger"]'),next=resolveListMove(event,{count,current:index,orientation:"vertical",isAvailable:candidate=>!!(buttons?.[candidate]&&isRovingTargetAvailable(buttons[candidate]))});next!==null&&(event.preventDefault(),buttons?.[next]?.focus())}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["claims","citations"])}static{this.identityCollectionProperties=Object.freeze(["claims","citations"])}static{this.styles=[LyraElement.styles,styles]}static{this.immutableEventDetails=Object.freeze(["lr-claim-select","lr-citation-select","lr-citation-open"])}static{this.identityEventDetailProperties=Object.freeze({"lr-claim-select":Object.freeze(["claim"]),"lr-citation-select":Object.freeze(["citation"]),"lr-citation-open":Object.freeze(["citation"])})}canonicalRowsFor(source,cache,project,empty){if(source===null||typeof source!="object")return empty;const cached=cache.get(source);if(cached)return cached;const rows=projectRows(source,project,empty);return cache.set(source,rows),rows}get normalizedClaims(){return this.canonicalRowsFor(this.claims,this.canonicalClaimsBySource,projectGroundedClaim,EMPTY_CANONICAL_CLAIMS)}get normalizedCitations(){return this.canonicalRowsFor(this.citations,this.canonicalCitationsBySource,projectCitation,EMPTY_CANONICAL_CITATIONS)}statusLabel(status){switch(status){case"supported":return this.localize("claimEvidenceSupported");case"partially-supported":return this.localize("claimEvidencePartiallySupported");case"unsupported":return this.localize("claimEvidenceUnsupported");case"contradicted":return this.localize("claimEvidenceContradicted");case"unknown":return this.localize("statusUnknown")}}confidenceLabel(value){const percent=getNumberFormat(this.effectiveLocale,{style:"percent"}).format(finiteRange(value,0,0,1));return this.localize("claimEvidenceConfidence",void 0,{percent})}resolvedCitations(claim,byId){const found=new Set;for(const id of claim.citationIds){const entry=byId.get(id);entry&&found.add(entry)}return[...found].sort((a,b)=>a.index-b.index)}renderClaim(claim,byId,index,count,rovingClaimId){const selected=claim.id===this.selectedClaimId,citations=this.resolvedCitations(claim,byId),status=normalizedClaimStatus(claim.status);return status==="unknown"&&devWarnOnce("lr-claim-evidence:unknown-status",`<lr-claim-evidence>: unknown claim status ${JSON.stringify(claim.status.slice(0,80))}; rendering a neutral status.`),html`
2
2
  <li part=${selected?"claim claim-selected":"claim"} aria-current=${selected?"true":"false"}>
3
3
  <button
4
4
  part="claim-trigger"
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{isNonBlankIdentity,firstByRetrievalIdentity}from"../retrieval-identity.js";import{normalizeSize}from"../../../internal/variants.js";import{finiteCount}from"../../../internal/numbers.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import"../../overlays/chip/chip.class.js";import"../../forms/button/button.class.js";import"../../overlays/empty/empty.class.js";import{styles}from"./community-card.styles.js";import{LYRA_DEFAULT_communityDrillIn,LYRA_DEFAULT_communityMemberCount,LYRA_DEFAULT_noData,LYRA_DEFAULT_showMoreCount,LYRA_DEFAULT_untitledCommunity}from"../../../internal/default-strings.generated.js";function isDenseSize(size){const step=normalizeSize(size);return step==="s"||step==="xs"||step==="2xs"}class LyraCommunityCard extends LyraElement{constructor(){super(...arguments),this.community=null,this.members=[],this.maxMembers=8,this.size="m",this.frame="card",this.onDrill=()=>{this.community&&isNonBlankIdentity(this.community.id)&&this.emit("lr-drill",{communityId:this.community.id})}}static{this.defaultStrings={...super.defaultStrings,communityDrillIn:LYRA_DEFAULT_communityDrillIn,communityMemberCount:LYRA_DEFAULT_communityMemberCount,noData:LYRA_DEFAULT_noData,showMoreCount:LYRA_DEFAULT_showMoreCount,untitledCommunity:LYRA_DEFAULT_untitledCommunity}}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["members"])}static{this.styles=[LyraElement.styles,styles]}static get observedAttributes(){return[...super.observedAttributes,"aria-level"]}attributeChangedCallback(name,oldValue,value){super.attributeChangedCallback(name,oldValue,value),name==="aria-level"&&oldValue!==value&&this.requestUpdate()}get dense(){return isDenseSize(this.size)}get effectiveMaxMembers(){return finiteCount(this.maxMembers,8)}render(){if(!this.community||!isNonBlankIdentity(this.community.id))return html`<div part="base">
1
+ import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{isNonBlankIdentity,firstByRetrievalIdentity}from"../retrieval-identity.js";import{normalizeSize}from"../../../internal/variants.js";import{finiteCount}from"../../../internal/numbers.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import"../../overlays/chip/chip.class.js";import"../../forms/button/button.class.js";import"../../overlays/empty/empty.class.js";import{styles}from"./community-card.styles.js";import{LYRA_DEFAULT_communityDrillIn,LYRA_DEFAULT_communityMemberCount,LYRA_DEFAULT_untitledCommunity}from"../../../internal/default-strings/retrieval.generated.js";import{LYRA_DEFAULT_noData,LYRA_DEFAULT_showMoreCount}from"../../../internal/default-strings/shared.generated.js";function isDenseSize(size){const step=normalizeSize(size);return step==="s"||step==="xs"||step==="2xs"}class LyraCommunityCard extends LyraElement{constructor(){super(...arguments),this.community=null,this.members=[],this.maxMembers=8,this.size="m",this.frame="card",this.onDrill=()=>{this.community&&isNonBlankIdentity(this.community.id)&&this.emit("lr-drill",{communityId:this.community.id})}}static{this.defaultStrings={...super.defaultStrings,communityDrillIn:LYRA_DEFAULT_communityDrillIn,communityMemberCount:LYRA_DEFAULT_communityMemberCount,noData:LYRA_DEFAULT_noData,showMoreCount:LYRA_DEFAULT_showMoreCount,untitledCommunity:LYRA_DEFAULT_untitledCommunity}}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["members"])}static{this.styles=[LyraElement.styles,styles]}static get observedAttributes(){return[...super.observedAttributes,"aria-level"]}attributeChangedCallback(name,oldValue,value){super.attributeChangedCallback(name,oldValue,value),name==="aria-level"&&oldValue!==value&&this.requestUpdate()}get dense(){return isDenseSize(this.size)}get effectiveMaxMembers(){return finiteCount(this.maxMembers,8)}render(){if(!this.community||!isNonBlankIdentity(this.community.id))return html`<div part="base">
2
2
  <lr-empty part="empty" heading=${this.localize("noData")}></lr-empty>
3
3
  </div>`;const community=this.community,members=firstByRetrievalIdentity(this.members,member=>member?.id),titleText=community.label||this.localize("untitledCommunity"),suppliedMemberCount=community.memberCount,memberCount=Math.max(members.length,suppliedMemberCount!==void 0&&Number.isSafeInteger(suppliedMemberCount)&&suppliedMemberCount>=0?suppliedMemberCount:members.length),visibleMembers=members.slice(0,this.effectiveMaxMembers),overflowCount=Math.max(0,memberCount-visibleMembers.length),numberFormat=getNumberFormat(this.effectiveLocale);return html`
4
4
  <div part="base">
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{snapshotPublicCollection}from"../../../internal/collection-snapshot.js";import{nativeSvgTitle}from"../../../internal/svg-title.js";import{html,nothing,svg}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{firstByRetrievalIdentity}from"../retrieval-identity.js";import{extent,finiteRange}from"../../../internal/numbers.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{sanitizeCssLength}from"../../../internal/safe-css.js";import{specialistTokens}from"../../../internal/specialist-tokens.styles.js";import{styles}from"./embedding-explorer.styles.js";import{shadowFocusTarget}from"../../../internal/active-element.js";import{LYRA_DEFAULT_embeddingExplorerEmpty,LYRA_DEFAULT_embeddingExplorerLabel,LYRA_DEFAULT_embeddingExplorerPoint,LYRA_DEFAULT_embeddingExplorerPointLimit}from"../../../internal/default-strings.generated.js";const WIDTH=640,HEIGHT=360,PAD=24,MAX_RENDERED_POINTS=1e3,PALETTE=["var(--lr-color-chart-1)","var(--lr-color-chart-2)","var(--lr-color-chart-3)","var(--lr-color-chart-4)","var(--lr-color-chart-5)","var(--lr-color-chart-6)","var(--lr-color-chart-7)","var(--lr-color-chart-8)"];function decimatePoints(items,max){if(items.length<=max||max<=0)return[...items];if(max===1)return[items[0]];const step=(items.length-1)/(max-1),result=[],seen=new Set;for(let i=0;i<max;i++){const index=Math.min(items.length-1,Math.round(i*step));seen.has(index)||(seen.add(index),result.push(items[index]))}return result}class LyraEmbeddingExplorer extends LyraElement{constructor(){super(...arguments),this._points=Object.freeze([]),this.pointsSource=this._points,this.sampledFrom=0,this.validPoints=[],this.renderedPoints=[],this.bounds={minX:0,maxX:0,minY:0,maxY:0},this.clusters=[],this.selectedPointId="",this.height="360px",this.label=null,this.accessibleLabel=null,this.activeIndex=0,this.refocusAfterUpdate=!1}static{this.defaultStrings={...super.defaultStrings,embeddingExplorerEmpty:LYRA_DEFAULT_embeddingExplorerEmpty,embeddingExplorerLabel:LYRA_DEFAULT_embeddingExplorerLabel,embeddingExplorerPoint:LYRA_DEFAULT_embeddingExplorerPoint,embeddingExplorerPointLimit:LYRA_DEFAULT_embeddingExplorerPointLimit}}static{this.styles=[LyraElement.styles,specialistTokens,styles]}get points(){return this._points}set points(value){if(Object.is(value,this.pointsSource)||Object.is(value,this._points))return;const previous=this._points,view=this.ownerDocument?.defaultView;let truncation,snapshot=snapshotPublicCollection(value,view,{onTruncate:report=>truncation=report});truncation&&Array.isArray(value)&&(snapshot=snapshotPublicCollection(decimatePoints(value,truncation.retained),view)),this.pointsSource=value,this.sampledFrom=truncation?.source??0,this._points=snapshot,this.requestUpdate("points",previous)}willUpdate(changed){if(super.willUpdate(changed),changed.has("points")||changed.has("selectedPointId")){this.validPoints=firstByRetrievalIdentity(Array.isArray(this.points)?this.points:[],point=>Number.isFinite(point.x)&&Number.isFinite(point.y)?point.id:void 0);const sample=new Set(decimatePoints(this.validPoints,MAX_RENDERED_POINTS));this.renderedPoints=this.validPoints.filter(point=>sample.has(point)||point.id===this.selectedPointId),this.bounds=extent(this.validPoints,point=>point.x,point=>point.y)??{minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0},this.clusters=[...new Set(this.validPoints.map(point=>String(point.cluster??"").trim()))].sort()}if(!changed.has("points"))return;const active=shadowFocusTarget(this)??null,focusedId=active?.getAttribute("data-id"),points=this.renderedPoints,matchingIndex=focusedId?points.findIndex(point=>point.id===focusedId):-1;this.activeIndex=matchingIndex>=0?matchingIndex:Math.min(this.activeIndex,Math.max(0,points.length-1)),this.refocusAfterUpdate=active?.getAttribute("part")==="point"}updated(changed){super.updated(changed),changed.has("height")&&this.applyHeight(),this.refocusAfterUpdate&&(this.refocusAfterUpdate=!1,this.renderRoot.querySelector(`[data-index="${this.activeIndex}"]`)?.focus())}applyHeight(){const height=sanitizeCssLength(this.height,"height");height?this.style.setProperty("--lr-embedding-explorer-height",height):this.style.removeProperty("--lr-embedding-explorer-height")}position(point,bounds){const{minX,maxX,minY,maxY}=bounds,x=PAD+finiteRange((point.x-minX)/(maxX-minX||1),.5,0,1)*(WIDTH-PAD*2),y=HEIGHT-PAD-finiteRange((point.y-minY)/(maxY-minY||1),.5,0,1)*(HEIGHT-PAD*2);return{x,y}}announceLabel(point,index){return this.localize("embeddingExplorerPoint",void 0,{label:point.label||point.id,index:getNumberFormat(this.effectiveLocale).format(index+1)})}select(point){this.emit("lr-point-select",{point})}activatePoint(point,index){this.activeIndex=index,this.select(point)}onPointKeyDown(event,point,index){const points=this.renderedPoints;if(event.key==="Enter"||event.key===" "){event.preventDefault(),event.repeat||this.select(point);return}const rtl=this.effectiveDirection==="rtl",forward=rtl?"ArrowLeft":"ArrowRight",backward=rtl?"ArrowRight":"ArrowLeft";let next=index;if(event.key===forward||event.key==="ArrowDown")next=Math.min(points.length-1,index+1);else if(event.key===backward||event.key==="ArrowUp")next=Math.max(0,index-1);else if(event.key==="Home")next=0;else if(event.key==="End")next=points.length-1;else return;event.preventDefault(),this.activeIndex=next,this.updateComplete.then(()=>{this.renderRoot.querySelector(`[data-index="${next}"]`)?.focus()})}renderPoint(point,index,bounds,clusterIndices){const{x,y}=this.position(point,bounds),label=this.announceLabel(point,index),cluster=String(point.cluster??"").trim(),selected=point.id===this.selectedPointId;return svg`<g
1
+ import{__decorate}from"tslib";import{snapshotPublicCollection}from"../../../internal/collection-snapshot.js";import{nativeSvgTitle}from"../../../internal/svg-title.js";import{html,nothing,svg}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{firstByRetrievalIdentity}from"../retrieval-identity.js";import{extent,finiteRange}from"../../../internal/numbers.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{sanitizeCssLength}from"../../../internal/safe-css.js";import{specialistTokens}from"../../../internal/specialist-host-tokens.styles.js";import{styles}from"./embedding-explorer.styles.js";import{shadowFocusTarget}from"../../../internal/active-element.js";import{LYRA_DEFAULT_embeddingExplorerEmpty,LYRA_DEFAULT_embeddingExplorerLabel,LYRA_DEFAULT_embeddingExplorerPoint,LYRA_DEFAULT_embeddingExplorerPointLimit}from"../../../internal/default-strings/retrieval.generated.js";const WIDTH=640,HEIGHT=360,PAD=24,MAX_RENDERED_POINTS=1e3,PALETTE=["var(--lr-color-chart-1)","var(--lr-color-chart-2)","var(--lr-color-chart-3)","var(--lr-color-chart-4)","var(--lr-color-chart-5)","var(--lr-color-chart-6)","var(--lr-color-chart-7)","var(--lr-color-chart-8)"];function decimatePoints(items,max){if(items.length<=max||max<=0)return[...items];if(max===1)return[items[0]];const step=(items.length-1)/(max-1),result=[],seen=new Set;for(let i=0;i<max;i++){const index=Math.min(items.length-1,Math.round(i*step));seen.has(index)||(seen.add(index),result.push(items[index]))}return result}class LyraEmbeddingExplorer extends LyraElement{constructor(){super(...arguments),this._points=Object.freeze([]),this.pointsSource=this._points,this.sampledFrom=0,this.validPoints=[],this.renderedPoints=[],this.bounds={minX:0,maxX:0,minY:0,maxY:0},this.clusters=[],this.selectedPointId="",this.height="360px",this.label=null,this.accessibleLabel=null,this.activeIndex=0,this.refocusAfterUpdate=!1}static{this.defaultStrings={...super.defaultStrings,embeddingExplorerEmpty:LYRA_DEFAULT_embeddingExplorerEmpty,embeddingExplorerLabel:LYRA_DEFAULT_embeddingExplorerLabel,embeddingExplorerPoint:LYRA_DEFAULT_embeddingExplorerPoint,embeddingExplorerPointLimit:LYRA_DEFAULT_embeddingExplorerPointLimit}}static{this.styles=[LyraElement.styles,specialistTokens,styles]}get points(){return this._points}set points(value){if(Object.is(value,this.pointsSource)||Object.is(value,this._points))return;const previous=this._points,view=this.ownerDocument?.defaultView;let truncation,snapshot=snapshotPublicCollection(value,view,{onTruncate:report=>truncation=report});truncation&&Array.isArray(value)&&(snapshot=snapshotPublicCollection(decimatePoints(value,truncation.retained),view)),this.pointsSource=value,this.sampledFrom=truncation?.source??0,this._points=snapshot,this.requestUpdate("points",previous)}willUpdate(changed){if(super.willUpdate(changed),changed.has("points")||changed.has("selectedPointId")){this.validPoints=firstByRetrievalIdentity(Array.isArray(this.points)?this.points:[],point=>Number.isFinite(point.x)&&Number.isFinite(point.y)?point.id:void 0);const sample=new Set(decimatePoints(this.validPoints,MAX_RENDERED_POINTS));this.renderedPoints=this.validPoints.filter(point=>sample.has(point)||point.id===this.selectedPointId),this.bounds=extent(this.validPoints,point=>point.x,point=>point.y)??{minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0},this.clusters=[...new Set(this.validPoints.map(point=>String(point.cluster??"").trim()))].sort()}if(!changed.has("points"))return;const active=shadowFocusTarget(this)??null,focusedId=active?.getAttribute("data-id"),points=this.renderedPoints,matchingIndex=focusedId?points.findIndex(point=>point.id===focusedId):-1;this.activeIndex=matchingIndex>=0?matchingIndex:Math.min(this.activeIndex,Math.max(0,points.length-1)),this.refocusAfterUpdate=active?.getAttribute("part")==="point"}updated(changed){super.updated(changed),changed.has("height")&&this.applyHeight(),this.refocusAfterUpdate&&(this.refocusAfterUpdate=!1,this.renderRoot.querySelector(`[data-index="${this.activeIndex}"]`)?.focus())}applyHeight(){const height=sanitizeCssLength(this.height,"height");height?this.style.setProperty("--lr-embedding-explorer-height",height):this.style.removeProperty("--lr-embedding-explorer-height")}position(point,bounds){const{minX,maxX,minY,maxY}=bounds,x=PAD+finiteRange((point.x-minX)/(maxX-minX||1),.5,0,1)*(WIDTH-PAD*2),y=HEIGHT-PAD-finiteRange((point.y-minY)/(maxY-minY||1),.5,0,1)*(HEIGHT-PAD*2);return{x,y}}announceLabel(point,index){return this.localize("embeddingExplorerPoint",void 0,{label:point.label||point.id,index:getNumberFormat(this.effectiveLocale).format(index+1)})}select(point){this.emit("lr-point-select",{point})}activatePoint(point,index){this.activeIndex=index,this.select(point)}onPointKeyDown(event,point,index){const points=this.renderedPoints;if(event.key==="Enter"||event.key===" "){event.preventDefault(),event.repeat||this.select(point);return}const rtl=this.effectiveDirection==="rtl",forward=rtl?"ArrowLeft":"ArrowRight",backward=rtl?"ArrowRight":"ArrowLeft";let next=index;if(event.key===forward||event.key==="ArrowDown")next=Math.min(points.length-1,index+1);else if(event.key===backward||event.key==="ArrowUp")next=Math.max(0,index-1);else if(event.key==="Home")next=0;else if(event.key==="End")next=points.length-1;else return;event.preventDefault(),this.activeIndex=next,this.updateComplete.then(()=>{this.renderRoot.querySelector(`[data-index="${next}"]`)?.focus()})}renderPoint(point,index,bounds,clusterIndices){const{x,y}=this.position(point,bounds),label=this.announceLabel(point,index),cluster=String(point.cluster??"").trim(),selected=point.id===this.selectedPointId;return svg`<g
2
2
  part="point"
3
3
  data-index=${index}
4
4
  data-id=${point.id}
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{firstByRetrievalIdentity,isNonBlankIdentity}from"../retrieval-identity.js";import{sanitizeCssColor}from"../../../internal/safe-css.js";import{finiteCount,finiteNumber}from"../../../internal/numbers.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{styles}from"./entity-card.styles.js";import"../../agent-tools/result-card/result-field.class.js";import"../../overlays/badge/badge.class.js";import"../../overlays/chip/chip.class.js";import"../../forms/button/button.class.js";import"../../overlays/empty/empty.class.js";import{LYRA_DEFAULT_entityCommunity,LYRA_DEFAULT_entityDegree,LYRA_DEFAULT_focusInGraph,LYRA_DEFAULT_noData,LYRA_DEFAULT_untitledEntity}from"../../../internal/default-strings.generated.js";function typeBadgeStyle(color){const safe=color!=null?sanitizeCssColor(color):void 0;return safe?{"--lr-badge-color":"var(--lr-color-text)","--lr-badge-background":`color-mix(in srgb, ${safe} 12%, var(--lr-color-surface))`,"--lr-badge-border":safe}:{}}class LyraEntityCard extends LyraElement{constructor(){super(...arguments),this.entity=null,this.types=[],this.communityLabel="",this.withoutFocusButton=!1,this.size="m",this.frame="card",this.onFocusClick=()=>{this.entity&&isNonBlankIdentity(this.entity.id)&&this.emit("lr-entity-select",{entityId:this.entity.id})}}static{this.defaultStrings={...super.defaultStrings,entityCommunity:LYRA_DEFAULT_entityCommunity,entityDegree:LYRA_DEFAULT_entityDegree,focusInGraph:LYRA_DEFAULT_focusInGraph,noData:LYRA_DEFAULT_noData,untitledEntity:LYRA_DEFAULT_untitledEntity}}static get observedAttributes(){return[...super.observedAttributes,"aria-level"]}attributeChangedCallback(name,oldValue,value){super.attributeChangedCallback(name,oldValue,value),name==="aria-level"&&oldValue!==value&&this.requestUpdate()}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["entity","types"])}static{this.styles=[LyraElement.styles,styles]}resolvedType(type){return firstByRetrievalIdentity(this.types,entry=>entry?.id).find(entry=>entry.id===type)}render(){if(!this.entity||!isNonBlankIdentity(this.entity.id))return html`<div part="base">
1
+ import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{firstByRetrievalIdentity,isNonBlankIdentity}from"../retrieval-identity.js";import{sanitizeCssColor}from"../../../internal/safe-css.js";import{finiteCount,finiteNumber}from"../../../internal/numbers.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{styles}from"./entity-card.styles.js";import"../../agent-tools/result-card/result-field.class.js";import"../../overlays/badge/badge.class.js";import"../../overlays/chip/chip.class.js";import"../../forms/button/button.class.js";import"../../overlays/empty/empty.class.js";import{LYRA_DEFAULT_entityCommunity,LYRA_DEFAULT_entityDegree,LYRA_DEFAULT_focusInGraph,LYRA_DEFAULT_untitledEntity}from"../../../internal/default-strings/retrieval.generated.js";import{LYRA_DEFAULT_noData}from"../../../internal/default-strings/shared.generated.js";function typeBadgeStyle(color){const safe=color!=null?sanitizeCssColor(color):void 0;return safe?{"--lr-badge-color":"var(--lr-color-text)","--lr-badge-background":`color-mix(in srgb, ${safe} 12%, var(--lr-color-surface))`,"--lr-badge-border":safe}:{}}class LyraEntityCard extends LyraElement{constructor(){super(...arguments),this.entity=null,this.types=[],this.communityLabel="",this.withoutFocusButton=!1,this.size="m",this.frame="card",this.onFocusClick=()=>{this.entity&&isNonBlankIdentity(this.entity.id)&&this.emit("lr-entity-select",{entityId:this.entity.id})}}static{this.defaultStrings={...super.defaultStrings,entityCommunity:LYRA_DEFAULT_entityCommunity,entityDegree:LYRA_DEFAULT_entityDegree,focusInGraph:LYRA_DEFAULT_focusInGraph,noData:LYRA_DEFAULT_noData,untitledEntity:LYRA_DEFAULT_untitledEntity}}static get observedAttributes(){return[...super.observedAttributes,"aria-level"]}attributeChangedCallback(name,oldValue,value){super.attributeChangedCallback(name,oldValue,value),name==="aria-level"&&oldValue!==value&&this.requestUpdate()}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["entity","types"])}static{this.styles=[LyraElement.styles,styles]}resolvedType(type){return firstByRetrievalIdentity(this.types,entry=>entry?.id).find(entry=>entry.id===type)}render(){if(!this.entity||!isNonBlankIdentity(this.entity.id))return html`<div part="base">
2
2
  <lr-empty part="empty" heading=${this.localize("noData")}></lr-empty>
3
3
  </div>`;const entity=this.entity,titleText=entity.label||this.localize("untitledEntity"),resolved=entity.type?this.resolvedType(entity.type):void 0,badgeLabel=resolved?.label??entity.type,properties=Object.entries(entity.properties??{}),ariaLevel=this.getAttribute("aria-level")||"3";return html`
4
4
  <div part="base">
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,state,query}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{isNonBlankIdentity}from"../retrieval-identity.js";import{PreviewDisclosureController}from"../../../internal/preview-disclosure-controller.js";import{nextId}from"../../../internal/a11y.js";import{SlotPresenceController}from"../../../internal/slot-presence-controller.js";import{styles}from"./entity-chip.styles.js";import{LYRA_DEFAULT_entityChipWithType,LYRA_DEFAULT_untitledEntity}from"../../../internal/default-strings.generated.js";const HIDE_DELAY_MS=200;class LyraEntityChip extends LyraElement{constructor(){super(...arguments),this.entityId="",this.text="",this.type="",this.popoverOpen=!1,this.popoverId=nextId("entity-chip-popover"),this.slotPresence=new SlotPresenceController(this),this.preview=new PreviewDisclosureController({host:this,button:()=>this.buttonEl,panel:()=>this.popoverEl,hasContent:()=>this.hasPreviewSlot,isOpen:()=>this.popoverOpen,setOpen:open=>{this.popoverOpen=open},hideDelayMs:HIDE_DELAY_MS}),this.onKeyDown=e=>{this.preview.handleEscape(e)||e.key===" "&&!e.repeat&&e.target===this.buttonEl&&(e.preventDefault(),this.emitOpen())},this.onClick=()=>{isNonBlankIdentity(this.entityId)&&this.emit("lr-entity-select",{entityId:this.entityId})},this.onDblClick=()=>{this.emitOpen()}}static{this.defaultStrings={...super.defaultStrings,entityChipWithType:LYRA_DEFAULT_entityChipWithType,untitledEntity:LYRA_DEFAULT_untitledEntity}}static{this.styles=[LyraElement.styles,styles]}get hasPreviewSlot(){return this.slotPresence.has()}willUpdate(changed){super.willUpdate(changed),this.preview.ensureContent()}updated(changed){super.updated(changed),changed.has("popoverOpen")&&this.preview.syncOpen()}disconnectedCallback(){super.disconnectedCallback(),this.preview.disconnect()}get accessibleLabel(){const label=(this.text??"").trim()===""?this.localize("untitledEntity"):this.text,typeText=this.typeLabel?.trim()||(this.type??"").trim();return typeText?this.localize("entityChipWithType",void 0,{label,type:typeText}):label}emitOpen(){isNonBlankIdentity(this.entityId)&&this.emit("lr-entity-open",{entityId:this.entityId})}render(){return html`
1
+ import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,state,query}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{isNonBlankIdentity}from"../retrieval-identity.js";import{PreviewDisclosureController}from"../../../internal/preview-disclosure-controller.js";import{nextId}from"../../../internal/a11y.js";import{SlotPresenceController}from"../../../internal/slot-presence-controller.js";import{styles}from"./entity-chip.styles.js";import{LYRA_DEFAULT_entityChipWithType,LYRA_DEFAULT_untitledEntity}from"../../../internal/default-strings/retrieval.generated.js";const HIDE_DELAY_MS=200;class LyraEntityChip extends LyraElement{constructor(){super(...arguments),this.entityId="",this.text="",this.type="",this.popoverOpen=!1,this.popoverId=nextId("entity-chip-popover"),this.slotPresence=new SlotPresenceController(this),this.preview=new PreviewDisclosureController({host:this,button:()=>this.buttonEl,panel:()=>this.popoverEl,hasContent:()=>this.hasPreviewSlot,isOpen:()=>this.popoverOpen,setOpen:open=>{this.popoverOpen=open},hideDelayMs:HIDE_DELAY_MS}),this.onKeyDown=e=>{this.preview.handleEscape(e)||e.key===" "&&!e.repeat&&e.target===this.buttonEl&&(e.preventDefault(),this.emitOpen())},this.onClick=()=>{isNonBlankIdentity(this.entityId)&&this.emit("lr-entity-select",{entityId:this.entityId})},this.onDblClick=()=>{this.emitOpen()}}static{this.defaultStrings={...super.defaultStrings,entityChipWithType:LYRA_DEFAULT_entityChipWithType,untitledEntity:LYRA_DEFAULT_untitledEntity}}static{this.styles=[LyraElement.styles,styles]}get hasPreviewSlot(){return this.slotPresence.has()}willUpdate(changed){super.willUpdate(changed),this.preview.ensureContent()}updated(changed){super.updated(changed),changed.has("popoverOpen")&&this.preview.syncOpen()}disconnectedCallback(){super.disconnectedCallback(),this.preview.disconnect()}get accessibleLabel(){const label=(this.text??"").trim()===""?this.localize("untitledEntity"):this.text,typeText=this.typeLabel?.trim()||(this.type??"").trim();return typeText?this.localize("entityChipWithType",void 0,{label,type:typeText}):label}emitOpen(){isNonBlankIdentity(this.entityId)&&this.emit("lr-entity-open",{entityId:this.entityId})}render(){return html`
2
2
  <span
3
3
  class="wrapper"
4
4
  @pointerenter=${()=>this.preview.pointerEnter()}
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import"../entity-card/entity-card.class.js";import"../neighbor-list/neighbor-list.class.js";import"../chunk-inspector/chunk-inspector.class.js";import"../provenance-panel/provenance-panel.class.js";import"../../data/stat/stat.class.js";import"../../layout/tab-group/tab-group.class.js";import"../../overlays/empty/empty.class.js";import{styles}from"./entity-dossier.styles.js";import{LYRA_DEFAULT_chunkInspectorLabel,LYRA_DEFAULT_collapse,LYRA_DEFAULT_copy,LYRA_DEFAULT_date,LYRA_DEFAULT_details,LYRA_DEFAULT_loading,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_neighborListLabel,LYRA_DEFAULT_noData,LYRA_DEFAULT_open,LYRA_DEFAULT_progress,LYRA_DEFAULT_provenancePanelLabel,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings.generated.js";class LyraEntityDossier extends LyraElement{constructor(){super(...arguments),this.entity=null,this.types=[],this.communityLabel="",this.withoutFocusButton=!1,this.confidence=null,this.neighbors=[],this.groupByRelation=!1,this.expandable=!1,this.chunks=[],this.thresholds={high:.75,medium:.5},this.provenance=null,this.label=null,this.accessibleLabel=null,this.activeTab="relationships",this.onTabsChange=e=>{e.stopPropagation();const tabId=e.detail.name;this.activeTab=tabId,this.emit("lr-tab-show",{tabId})},this.containTabsEvent=e=>{e.stopPropagation()},this.onSupportingChunkToggle=event=>{event.composedPath()[0]===event.currentTarget&&(event.stopPropagation(),this.emit("lr-toggle",{section:"chunks",expanded:event.detail.expanded,itemId:event.detail.itemId}))}}static{this.defaultStrings={...super.defaultStrings,chunkInspectorLabel:LYRA_DEFAULT_chunkInspectorLabel,collapse:LYRA_DEFAULT_collapse,copy:LYRA_DEFAULT_copy,date:LYRA_DEFAULT_date,details:LYRA_DEFAULT_details,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,neighborListLabel:LYRA_DEFAULT_neighborListLabel,noData:LYRA_DEFAULT_noData,open:LYRA_DEFAULT_open,progress:LYRA_DEFAULT_progress,provenancePanelLabel:LYRA_DEFAULT_provenancePanelLabel,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["entity","confidence","types","neighbors","chunks","provenance"])}static{this.styles=[LyraElement.styles,styles]}render(){const label=this.hasAttribute("aria-label")?this.getAttribute("aria-label"):this.label??this.localize("details");if(!this.entity)return html`<div part="base" role="group" aria-label=${label}>
1
+ import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import"../entity-card/entity-card.class.js";import"../neighbor-list/neighbor-list.class.js";import"../chunk-inspector/chunk-inspector.class.js";import"../provenance-panel/provenance-panel.class.js";import"../../data/stat/stat.class.js";import"../../layout/tab-group/tab-group.class.js";import"../../overlays/empty/empty.class.js";import{styles}from"./entity-dossier.styles.js";import{LYRA_DEFAULT_chunkInspectorLabel,LYRA_DEFAULT_neighborListLabel,LYRA_DEFAULT_provenancePanelLabel}from"../../../internal/default-strings/retrieval.generated.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_copy,LYRA_DEFAULT_date,LYRA_DEFAULT_details,LYRA_DEFAULT_loading,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_noData,LYRA_DEFAULT_open,LYRA_DEFAULT_progress,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings/shared.generated.js";class LyraEntityDossier extends LyraElement{constructor(){super(...arguments),this.entity=null,this.types=[],this.communityLabel="",this.withoutFocusButton=!1,this.confidence=null,this.neighbors=[],this.groupByRelation=!1,this.expandable=!1,this.chunks=[],this.thresholds={high:.75,medium:.5},this.provenance=null,this.label=null,this.accessibleLabel=null,this.activeTab="relationships",this.onTabsChange=e=>{e.stopPropagation();const tabId=e.detail.name;this.activeTab=tabId,this.emit("lr-tab-show",{tabId})},this.containTabsEvent=e=>{e.stopPropagation()},this.onSupportingChunkToggle=event=>{event.composedPath()[0]===event.currentTarget&&(event.stopPropagation(),this.emit("lr-toggle",{section:"chunks",expanded:event.detail.expanded,itemId:event.detail.itemId}))}}static{this.defaultStrings={...super.defaultStrings,chunkInspectorLabel:LYRA_DEFAULT_chunkInspectorLabel,collapse:LYRA_DEFAULT_collapse,copy:LYRA_DEFAULT_copy,date:LYRA_DEFAULT_date,details:LYRA_DEFAULT_details,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,neighborListLabel:LYRA_DEFAULT_neighborListLabel,noData:LYRA_DEFAULT_noData,open:LYRA_DEFAULT_open,progress:LYRA_DEFAULT_progress,provenancePanelLabel:LYRA_DEFAULT_provenancePanelLabel,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["entity","confidence","types","neighbors","chunks","provenance"])}static{this.styles=[LyraElement.styles,styles]}render(){const label=this.hasAttribute("aria-label")?this.getAttribute("aria-label"):this.label??this.localize("details");if(!this.entity)return html`<div part="base" role="group" aria-label=${label}>
2
2
  <lr-empty part="empty" heading=${this.localize("noData")}></lr-empty>
3
3
  </div>`;const entity=this.entity,c=this.confidence,tabsLabel=this.hasAttribute("aria-label")?nothing:this.accessibleLabel??nothing;return html`
4
4
  <div part="base" role="group" aria-label=${label}>