@aceshooting/lyra-ui 27.0.0 → 28.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (389) hide show
  1. package/CHANGELOG.md +55 -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.js +1 -1
  53. package/dist/components/charts/chart/chart-token-cache.js +2 -2
  54. package/dist/components/charts/chart/chart.class.d.ts +1 -1
  55. package/dist/components/charts/chart/chart.class.js +3 -3
  56. package/dist/components/charts/chart/histogram.class.js +1 -1
  57. package/dist/components/charts/chart/lite-chart.class.js +1 -1
  58. package/dist/components/conversation/agent-workspace/agent-workspace.class.js +1 -1
  59. package/dist/components/conversation/audio-visualizer/audio-visualizer.class.js +1 -1
  60. package/dist/components/conversation/branch-picker/branch-picker.class.js +1 -1
  61. package/dist/components/conversation/chat-composer/chat-composer.class.js +1 -1
  62. package/dist/components/conversation/chat-message/chat-message.class.js +1 -1
  63. package/dist/components/conversation/chat-viewport/chat-viewport.class.js +1 -1
  64. package/dist/components/conversation/checkpoint/checkpoint.class.js +1 -1
  65. package/dist/components/conversation/code-block/code-block-base.class.js +1 -1
  66. package/dist/components/conversation/code-block/code-block-core.class.js +1 -1
  67. package/dist/components/conversation/code-block/code-block.class.js +1 -1
  68. package/dist/components/conversation/conversation-item/conversation-item.class.js +1 -1
  69. package/dist/components/conversation/generation-metrics/generation-metrics.class.js +1 -1
  70. package/dist/components/conversation/handoff-divider/handoff-divider.class.js +1 -1
  71. package/dist/components/conversation/markdown/markdown-base.class.js +1 -1
  72. package/dist/components/conversation/markdown/markdown-core.class.js +1 -1
  73. package/dist/components/conversation/markdown/markdown.class.js +1 -1
  74. package/dist/components/conversation/message-actions/message-actions.class.js +1 -1
  75. package/dist/components/conversation/message-feedback/message-feedback.class.js +1 -1
  76. package/dist/components/conversation/message-parts/message-parts.class.js +1 -1
  77. package/dist/components/conversation/model-select/model-select.class.js +1 -1
  78. package/dist/components/conversation/model-settings-panel/model-settings-panel.class.js +1 -1
  79. package/dist/components/conversation/prompt-input/prompt-input.class.js +1 -1
  80. package/dist/components/conversation/prompt-queue/prompt-queue.class.js +1 -1
  81. package/dist/components/conversation/push-to-talk/push-to-talk.class.js +1 -1
  82. package/dist/components/conversation/realtime-session/realtime-session.class.js +1 -1
  83. package/dist/components/conversation/selection-toolbar/selection-toolbar.class.js +1 -1
  84. package/dist/components/conversation/stream-status/stream-status.class.js +1 -1
  85. package/dist/components/conversation/suggestion-chips/suggestion-chips.class.js +1 -1
  86. package/dist/components/conversation/thread-list/thread-list.class.js +1 -1
  87. package/dist/components/conversation/transcript-feed/transcript-feed.class.js +1 -1
  88. package/dist/components/conversation/typing-indicator/typing-indicator.class.js +1 -1
  89. package/dist/components/conversation/usage-badge/usage-badge.class.js +1 -1
  90. package/dist/components/conversation/voice-picker/voice-picker.class.js +1 -1
  91. package/dist/components/data/calendar/calendar.class.js +1 -1
  92. package/dist/components/data/condition-builder/condition-builder.class.js +1 -1
  93. package/dist/components/data/context-meter/context-meter.class.js +1 -1
  94. package/dist/components/data/data-grid/data-grid.class.d.ts +2 -2
  95. package/dist/components/data/data-grid/data-grid.class.js +3 -3
  96. package/dist/components/data/document-library/document-library.class.js +1 -1
  97. package/dist/components/data/env-list/env-list.class.js +1 -1
  98. package/dist/components/data/file-tree/file-tree.class.d.ts +2 -2
  99. package/dist/components/data/file-tree/file-tree.class.js +1 -1
  100. package/dist/components/data/flow-canvas/flow-canvas.class.js +1 -1
  101. package/dist/components/data/flow-controls/flow-controls.class.js +1 -1
  102. package/dist/components/data/flow-minimap/flow-minimap.class.js +1 -1
  103. package/dist/components/data/flow-node/flow-node.class.js +1 -1
  104. package/dist/components/data/flow-run-status/flow-run-status.class.js +1 -1
  105. package/dist/components/data/funnel/funnel.class.js +1 -1
  106. package/dist/components/data/gauge/gauge.class.js +1 -1
  107. package/dist/components/data/graph-query-builder/graph-query-builder.class.js +1 -1
  108. package/dist/components/data/heatmap/heatmap.class.js +1 -1
  109. package/dist/components/data/pagination/pagination.class.d.ts +2 -0
  110. package/dist/components/data/pagination/pagination.class.js +1 -1
  111. package/dist/components/data/pagination/pagination.styles.js +1 -1
  112. package/dist/components/data/sequence-strip/sequence-strip.class.js +1 -1
  113. package/dist/components/data/sparkline/sparkline.class.js +1 -1
  114. package/dist/components/data/stat/stat.class.js +1 -1
  115. package/dist/components/data/table/table.class.d.ts +23 -2
  116. package/dist/components/data/table/table.class.js +5 -3
  117. package/dist/components/data/table/table.styles.js +1 -1
  118. package/dist/components/data/timeline/timeline.class.js +1 -1
  119. package/dist/components/data/tree/tree.class.js +1 -1
  120. package/dist/components/data/word-cloud/word-cloud.class.js +1 -1
  121. package/dist/components/forms/button/button.class.js +1 -1
  122. package/dist/components/forms/checkbox/checkbox.class.js +1 -1
  123. package/dist/components/forms/checkbox-group/checkbox-group.class.js +1 -1
  124. package/dist/components/forms/code-editor/code-editor.class.js +1 -1
  125. package/dist/components/forms/color-picker/color-picker.class.d.ts +8 -4
  126. package/dist/components/forms/color-picker/color-picker.class.js +2 -2
  127. package/dist/components/forms/combobox/combobox.class.js +1 -1
  128. package/dist/components/forms/country-picker/country-picker.class.js +1 -1
  129. package/dist/components/forms/currency-picker/currency-picker.class.js +1 -1
  130. package/dist/components/forms/date-picker/date-input.class.js +1 -1
  131. package/dist/components/forms/date-picker/date-picker.class.js +1 -1
  132. package/dist/components/forms/emoji-picker/emoji-data-loader.js +1 -1
  133. package/dist/components/forms/emoji-picker/emoji-picker.class.d.ts +7 -4
  134. package/dist/components/forms/emoji-picker/emoji-picker.class.js +5 -5
  135. package/dist/components/forms/icon-button/icon-button.class.d.ts +4 -0
  136. package/dist/components/forms/icon-button/icon-button.class.js +1 -1
  137. package/dist/components/forms/icon-button/icon-button.styles.js +1 -1
  138. package/dist/components/forms/input/input-shared.js +1 -1
  139. package/dist/components/forms/input/input.class.js +1 -1
  140. package/dist/components/forms/input/native-time-input.class.js +1 -1
  141. package/dist/components/forms/input/number-input.class.js +1 -1
  142. package/dist/components/forms/input/time-input.class.js +1 -1
  143. package/dist/components/forms/locale-picker/locale-picker.class.js +1 -1
  144. package/dist/components/forms/otp-input/otp-input.class.js +1 -1
  145. package/dist/components/forms/phone-input/phone-input.class.js +1 -1
  146. package/dist/components/forms/radio/radio-group.class.js +1 -1
  147. package/dist/components/forms/radio/radio.class.js +1 -1
  148. package/dist/components/forms/rubric-form/rubric-form.class.js +4 -4
  149. package/dist/components/forms/select/select.class.js +1 -1
  150. package/dist/components/forms/signature-pad/signature-pad.class.js +1 -1
  151. package/dist/components/forms/slider/slider.class.js +1 -1
  152. package/dist/components/forms/switch/switch.class.js +1 -1
  153. package/dist/components/forms/textarea/textarea.class.js +1 -1
  154. package/dist/components/forms/time-range/time-range.class.js +1 -1
  155. package/dist/components/forms/time-zone-picker/time-zone-picker.class.js +1 -1
  156. package/dist/components/forms/token-input/token-input.class.js +1 -1
  157. package/dist/components/forms/unit-picker/unit-picker.class.js +1 -1
  158. package/dist/components/layout/app-rail/app-rail-item.class.js +1 -1
  159. package/dist/components/layout/app-rail/app-rail.class.d.ts +70 -7
  160. package/dist/components/layout/app-rail/app-rail.class.js +16 -4
  161. package/dist/components/layout/app-rail/app-rail.styles.js +1 -1
  162. package/dist/components/layout/app-rail-group/app-rail-group.class.js +1 -1
  163. package/dist/components/layout/breadcrumb/breadcrumb.class.js +1 -1
  164. package/dist/components/layout/card/card.class.js +1 -1
  165. package/dist/components/layout/carousel/carousel.class.js +1 -1
  166. package/dist/components/layout/command-palette/command-palette.class.js +1 -1
  167. package/dist/components/layout/dashboard-grid/dashboard-grid.class.js +1 -1
  168. package/dist/components/layout/details/accordion-item.class.js +1 -1
  169. package/dist/components/layout/details/details.class.js +1 -1
  170. package/dist/components/layout/dock-panel/dock-panel.class.js +1 -1
  171. package/dist/components/layout/drilldown-panel/drilldown-panel.class.js +1 -1
  172. package/dist/components/layout/filter-bar/filter-bar.class.js +1 -1
  173. package/dist/components/layout/menu/menu.class.js +1 -1
  174. package/dist/components/layout/menubar/menubar.class.js +1 -1
  175. package/dist/components/layout/multi-split/multi-split.class.js +1 -1
  176. package/dist/components/layout/navigation-menu/navigation-menu.class.js +1 -1
  177. package/dist/components/layout/page/page.class.js +1 -1
  178. package/dist/components/layout/reorder-list/reorder-item.class.js +1 -1
  179. package/dist/components/layout/reorder-list/reorder-list.class.js +1 -1
  180. package/dist/components/layout/responsive-panel/responsive-panel.class.js +1 -1
  181. package/dist/components/layout/scroller/scroller.class.js +1 -1
  182. package/dist/components/layout/segmented/segmented.class.d.ts +7 -4
  183. package/dist/components/layout/segmented/segmented.styles.js +1 -1
  184. package/dist/components/layout/split-panel/split-panel.class.js +1 -1
  185. package/dist/components/layout/tab-group/tab-group.class.js +1 -1
  186. package/dist/components/layout/tab-group/tab.class.js +1 -1
  187. package/dist/components/layout/virtual-list/virtual-list.styles.js +1 -1
  188. package/dist/components/layout/widget/widget.class.js +1 -1
  189. package/dist/components/media/animated-image/animated-image.class.js +1 -1
  190. package/dist/components/media/attachment-chip/attachment-chip.class.js +1 -1
  191. package/dist/components/media/attachment-trigger/attachment-trigger.class.js +2 -2
  192. package/dist/components/media/av-player/av-player.class.js +1 -1
  193. package/dist/components/media/avatar-group/avatar-group.class.js +1 -1
  194. package/dist/components/media/drop-zone/drop-zone.class.js +1 -1
  195. package/dist/components/media/file-icon/file-icon.class.js +1 -1
  196. package/dist/components/media/file-input/file-input.class.js +1 -1
  197. package/dist/components/media/flag/flag.class.js +1 -1
  198. package/dist/components/media/image-comparer/image-comparer.class.js +1 -1
  199. package/dist/components/media/image-viewer/image-viewer.class.d.ts +2 -1
  200. package/dist/components/media/image-viewer/image-viewer.class.js +4 -2
  201. package/dist/components/media/image-viewer/image-viewer.styles.js +1 -1
  202. package/dist/components/media/lightbox/lightbox.class.js +1 -1
  203. package/dist/components/media/map/map.class.js +1 -1
  204. package/dist/components/media/media-card/media-card.class.js +1 -1
  205. package/dist/components/media/pan-zoom/pan-zoom.class.js +1 -1
  206. package/dist/components/media/qr-code/qr-code.class.d.ts +2 -2
  207. package/dist/components/media/qr-code/qr-code.class.js +1 -1
  208. package/dist/components/media/sequence-playback/sequence-playback.class.js +1 -1
  209. package/dist/components/media/video/video.class.js +1 -1
  210. package/dist/components/media/video-playlist/video-playlist.class.js +1 -1
  211. package/dist/components/media/zoomable-frame/zoomable-frame.class.js +1 -1
  212. package/dist/components/overlays/alert/alert.class.js +1 -1
  213. package/dist/components/overlays/badge/tag.class.js +1 -1
  214. package/dist/components/overlays/callout/callout.class.js +1 -1
  215. package/dist/components/overlays/chip/chip-group.class.js +1 -1
  216. package/dist/components/overlays/chip/chip.class.js +1 -1
  217. package/dist/components/overlays/context-menu/context-menu.class.js +1 -1
  218. package/dist/components/overlays/dialog/confirm.js +1 -1
  219. package/dist/components/overlays/dialog/dialog.class.js +1 -1
  220. package/dist/components/overlays/kbd/kbd.class.js +1 -1
  221. package/dist/components/overlays/overlay/popover.class.js +1 -1
  222. package/dist/components/overlays/overlay/tooltip.class.js +1 -1
  223. package/dist/components/overlays/progress/progress-bar.class.js +1 -1
  224. package/dist/components/overlays/progress/progress-ring.class.js +1 -1
  225. package/dist/components/overlays/rating/rating.class.js +1 -1
  226. package/dist/components/overlays/skeleton/skeleton.class.js +1 -1
  227. package/dist/components/overlays/spinner/spinner.class.js +1 -1
  228. package/dist/components/overlays/toast/toast-item.class.js +1 -1
  229. package/dist/components/overlays/toast/toast.class.js +1 -1
  230. package/dist/components/retrieval/chunk-inspector/chunk-inspector.class.js +1 -1
  231. package/dist/components/retrieval/citation-badge/citation-badge.class.js +1 -1
  232. package/dist/components/retrieval/claim-evidence/claim-evidence.class.js +1 -1
  233. package/dist/components/retrieval/community-card/community-card.class.js +1 -1
  234. package/dist/components/retrieval/embedding-explorer/embedding-explorer.class.js +1 -1
  235. package/dist/components/retrieval/entity-card/entity-card.class.js +1 -1
  236. package/dist/components/retrieval/entity-chip/entity-chip.class.js +1 -1
  237. package/dist/components/retrieval/entity-dossier/entity-dossier.class.js +1 -1
  238. package/dist/components/retrieval/graph/graph.class.js +1 -1
  239. package/dist/components/retrieval/graph-legend/graph-legend.class.js +1 -1
  240. package/dist/components/retrieval/grounding-summary/grounding-summary.class.js +2 -2
  241. package/dist/components/retrieval/ingestion-queue/ingestion-queue.class.js +1 -1
  242. package/dist/components/retrieval/knowledge-base/knowledge-base.class.js +1 -1
  243. package/dist/components/retrieval/knowledge-base-admin/knowledge-base-admin.class.js +1 -1
  244. package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.js +1 -1
  245. package/dist/components/retrieval/memory-panel/memory-panel.class.js +1 -1
  246. package/dist/components/retrieval/mind-map/mind-map.class.js +1 -1
  247. package/dist/components/retrieval/neighbor-list/neighbor-list.class.js +1 -1
  248. package/dist/components/retrieval/node-palette/node-palette.class.js +1 -1
  249. package/dist/components/retrieval/path-strip/path-strip.class.js +1 -1
  250. package/dist/components/retrieval/provenance-panel/provenance-panel.class.js +1 -1
  251. package/dist/components/retrieval/rag-answer/rag-answer.class.js +1 -1
  252. package/dist/components/retrieval/rag-eval-dashboard/rag-eval-dashboard.class.js +1 -1
  253. package/dist/components/retrieval/research-progress/research-progress.class.js +1 -1
  254. package/dist/components/retrieval/retrieval-compare/retrieval-compare.class.js +1 -1
  255. package/dist/components/retrieval/retrieval-results/retrieval-results.class.js +1 -1
  256. package/dist/components/retrieval/retrieval-search/retrieval-search.class.js +1 -1
  257. package/dist/components/retrieval/retrieval-trace/retrieval-trace.class.js +1 -1
  258. package/dist/components/retrieval/source-card/source-card.class.js +1 -1
  259. package/dist/components/retrieval/source-list/source-list.class.js +1 -1
  260. package/dist/components/retrieval/source-picker/source-picker.class.js +1 -1
  261. package/dist/components/utility/copy-button/copy-button.class.js +1 -1
  262. package/dist/components/utility/diff-view/diff-view.class.js +1 -1
  263. package/dist/components/utility/export-button/export-button.class.js +1 -1
  264. package/dist/components/utility/icon/icon.class.js +1 -1
  265. package/dist/components/utility/json-viewer/json-viewer.class.js +1 -1
  266. package/dist/components/utility/known-date/known-date.class.js +1 -1
  267. package/dist/components/utility/mention-popover/mention-popover.class.js +1 -1
  268. package/dist/components/utility/poll-status/poll-status.class.js +1 -1
  269. package/dist/components/utility/random-content/random-content.class.js +1 -1
  270. package/dist/components/utility/tour/tour.class.js +1 -1
  271. package/dist/components/viewers/archive-viewer/archive-viewer.class.js +1 -1
  272. package/dist/components/viewers/calendar-viewer/calendar-viewer.class.js +1 -1
  273. package/dist/components/viewers/contact-viewer/contact-viewer.class.js +1 -1
  274. package/dist/components/viewers/csv-viewer/csv-viewer.class.js +1 -1
  275. package/dist/components/viewers/dataset-viewer/dataset-viewer.class.js +2 -2
  276. package/dist/components/viewers/document-compare/document-compare.class.js +1 -1
  277. package/dist/components/viewers/document-preview/document-preview.class.js +1 -1
  278. package/dist/components/viewers/document-viewer/document-viewer.class.js +1 -1
  279. package/dist/components/viewers/docx-viewer/docx-viewer.class.js +1 -1
  280. package/dist/components/viewers/ebook-viewer/ebook-viewer.class.js +1 -1
  281. package/dist/components/viewers/email-viewer/email-viewer.class.js +1 -1
  282. package/dist/components/viewers/geojson-view/geojson-view.class.js +1 -1
  283. package/dist/components/viewers/geojson-view/geojson-viewer.class.js +1 -1
  284. package/dist/components/viewers/highlight-layer/highlight-layer.class.js +1 -1
  285. package/dist/components/viewers/html-viewer/html-viewer.class.js +1 -1
  286. package/dist/components/viewers/include/include.class.js +1 -1
  287. package/dist/components/viewers/notebook-viewer/notebook-viewer.class.js +1 -1
  288. package/dist/components/viewers/page-rail/page-rail.class.d.ts +1 -1
  289. package/dist/components/viewers/page-rail/page-rail.class.js +3 -3
  290. package/dist/components/viewers/pdf-viewer/pdf-viewer.class.d.ts +2 -2
  291. package/dist/components/viewers/pdf-viewer/pdf-viewer.class.js +2 -2
  292. package/dist/components/viewers/pptx-viewer/pptx-viewer.class.js +1 -1
  293. package/dist/components/viewers/spreadsheet-viewer/spreadsheet-viewer.class.js +1 -1
  294. package/dist/components/viewers/svg-viewer/svg-viewer.class.js +1 -1
  295. package/dist/components/viewers/xml-viewer/xml-viewer.class.js +1 -1
  296. package/dist/events.d.ts +6 -1
  297. package/dist/framework-types.d.ts +1 -1
  298. package/dist/internal/accessibility-visibility.js +1 -1
  299. package/dist/internal/collection-snapshot.js +1 -1
  300. package/dist/internal/default-strings/agent-tools.generated.js +1 -0
  301. package/dist/internal/default-strings/charts.generated.js +1 -0
  302. package/dist/internal/default-strings/conversation.generated.js +1 -0
  303. package/dist/internal/default-strings/data.generated.js +1 -0
  304. package/dist/internal/default-strings/forms.generated.js +1 -0
  305. package/dist/internal/default-strings/layout.generated.js +1 -0
  306. package/dist/internal/default-strings/media.generated.js +1 -0
  307. package/dist/internal/default-strings/overlays.generated.js +1 -0
  308. package/dist/internal/default-strings/retrieval.generated.js +1 -0
  309. package/dist/internal/default-strings/shared.generated.js +1 -0
  310. package/dist/internal/default-strings/utility.generated.js +1 -0
  311. package/dist/internal/default-strings/viewers.generated.js +5 -0
  312. package/dist/internal/dev-mode-attribute-warning.development.js +1 -1
  313. package/dist/internal/dev-mode-attribute-warning.production.js +1 -1
  314. package/dist/internal/document-tokens.d.ts +11 -0
  315. package/dist/internal/document-tokens.generated.js +15 -0
  316. package/dist/internal/document-tokens.js +3 -0
  317. package/dist/internal/form-associated.d.ts +1 -1
  318. package/dist/internal/form-associated.js +1 -1
  319. package/dist/internal/glass-surface.styles.js +1 -1
  320. package/dist/internal/host-tokens.styles.js +1 -0
  321. package/dist/internal/image-zoom.js +1 -0
  322. package/dist/internal/intl-cache.js +1 -1
  323. package/dist/internal/localization-types.d.ts +1 -1
  324. package/dist/internal/localization.js +2 -2
  325. package/dist/internal/lyra-element.d.ts +4 -2
  326. package/dist/internal/lyra-element.js +2 -2
  327. package/dist/internal/opaque-content-border.styles.js +1 -1
  328. package/dist/internal/open-overlay-raise.styles.js +1 -0
  329. package/dist/internal/optional-peer-failure.js +1 -0
  330. package/dist/internal/package-metadata.js +1 -1
  331. package/dist/internal/prefix.js +1 -1
  332. package/dist/internal/specialist-host-tokens.styles.js +1 -0
  333. package/dist/internal/specialist-tokens.generated.js +2 -0
  334. package/dist/internal/step-value.js +1 -1
  335. package/dist/internal/theme-observation.js +1 -1
  336. package/dist/internal/theme-scopes.d.ts +11 -0
  337. package/dist/internal/theme-scopes.js +1 -0
  338. package/dist/looks/shadcn.css +1 -1
  339. package/dist/lyra.d.ts +1 -1
  340. package/dist/lyra.js +1 -1
  341. package/dist/styles/design-tokens.css +1 -1
  342. package/dist/styles/tokens-root.css +1 -1
  343. package/dist/surfaces/glass.css +1 -1
  344. package/dist/testing/happy-dom-shims.d.ts +21 -2
  345. package/dist/testing/happy-dom-shims.js +1 -1
  346. package/dist/testing/index.d.ts +1 -1
  347. package/dist/testing/index.js +1 -1
  348. package/dist/testing/interaction-drivers.d.ts +66 -7
  349. package/dist/testing/interaction-drivers.js +1 -1
  350. package/dist/testing/jsdom-shims.d.ts +70 -0
  351. package/dist/testing/jsdom-shims.js +1 -0
  352. package/dist/theme/look-inputs.d.ts +1 -1
  353. package/dist/theme/look-inputs.js +37 -41
  354. package/dist/theme/theme.d.ts +13 -0
  355. package/dist/theme/theme.js +1 -1
  356. package/dist/theme.css +1 -1
  357. package/dist/utilities/index.d.ts +1 -1
  358. package/dist/utilities/index.js +1 -1
  359. package/dist/utilities/scoped-registry.d.ts +3 -0
  360. package/dist/utilities/scoped-registry.js +1 -1
  361. package/dist/utilities/theme-scopes.d.ts +1 -0
  362. package/dist/utilities/theme-scopes.js +1 -0
  363. package/dist/utilities/tokens.d.ts +1 -0
  364. package/dist/utilities/tokens.js +1 -0
  365. package/llms/components/lr-app-rail.md +51 -4
  366. package/llms/components/lr-emoji-picker.md +13 -8
  367. package/llms/components/lr-icon-button.md +13 -1
  368. package/llms/components/lr-image-viewer.md +8 -0
  369. package/llms/components/lr-pagination.md +4 -2
  370. package/llms/components/lr-segmented.md +7 -3
  371. package/llms/components/lr-table.md +14 -12
  372. package/llms/components/lr-thread-list.md +4 -3
  373. package/llms/migration.md +9 -0
  374. package/llms/peers.md +1 -1
  375. package/llms/shared/events-and-types.md +41 -0
  376. package/llms/shared/frameworks-and-ssr.md +16 -0
  377. package/llms/shared/imports-and-registration.md +4 -3
  378. package/llms/shared/native-styles-and-utilities.md +38 -3
  379. package/llms/shared/styles-and-tokens.md +242 -102
  380. package/llms/shared/testing-and-utilities.md +90 -6
  381. package/llms/shared.md +431 -114
  382. package/llms/tokens.md +31 -49
  383. package/locales.json +138 -138
  384. package/package.json +14 -7
  385. package/registrations.json +1 -1
  386. package/dist/internal/default-strings.generated.js +0 -5
  387. package/dist/internal/specialist-tokens.styles.js +0 -1
  388. package/dist/internal/tokens/palette.styles.js +0 -1
  389. package/dist/internal/tokens.styles.js +0 -1
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{resolveBoundedCanvasAllocation}from"../../../internal/canvas.js";import{LyraElement}from"../../../internal/lyra-element.js";import{devWarnOnce}from"../../../internal/dev-mode-attribute-warning.js";import{resolveCanvasColor}from"../../../internal/canvas-color.js";import{finiteRange}from"../../../internal/numbers.js";import{safeMediaSrc}from"../../../internal/safe-url.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{loadQrCodeCached}from"./qr-code-loader.js";import{styles}from"./qr-code.styles.js";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_loading,LYRA_DEFAULT_map,LYRA_DEFAULT_noData,LYRA_DEFAULT_open,LYRA_DEFAULT_qrCodeGenerationFailed,LYRA_DEFAULT_qrCodeMissingLibrary}from"../../../internal/default-strings.generated.js";const DEFAULT_SIZE=128,MIN_SIZE=1,MAX_SIZE=2048,QR_BACKING_SCALE=2,MAX_CANVAS_DIMENSION=4096,MAX_CANVAS_PIXELS=8388608,MAX_QR_MODULE_COUNT=177,DEFAULT_RADIUS=0,MIN_RADIUS=0,MAX_RADIUS=.5,DEFAULT_IMAGE_COVERAGE=.5,DEFAULT_IMAGE_PADDING=0,DEFAULT_ERROR_CORRECTION="H",ERROR_CORRECTION_LEVELS=new Set(["L","M","Q","H"]),FALLBACK_FILL="#000000",FALLBACK_BACKGROUND="transparent",INVALID_COLOR_WARNING_KEY="lyra-qr-code-invalid-color",INVALID_COLOR_WARNING="<lr-qr-code> received an invalid color and used its fallback color.";function isObjectLike(value){return(typeof value=="object"||typeof value=="function")&&value!==null}function readIntersectionState(entries,target){try{if(!Array.isArray(entries))return;for(const candidate of entries)if(isObjectLike(candidate))try{const entry=candidate;if(entry.target!==target)continue;const isIntersecting=entry.isIntersecting;if(typeof isIntersecting=="boolean")return isIntersecting}catch{}}catch{}}function normalizeQrModules(result){if(!isObjectLike(result))throw new TypeError("QR result must be an object.");const modules=result.modules;if(!isObjectLike(modules))throw new TypeError("QR result has no module matrix.");const size=modules.size,get=modules.get;if(!Number.isSafeInteger(size)||size<1||size>MAX_QR_MODULE_COUNT)throw new TypeError("QR module count is invalid.");if(typeof get!="function")throw new TypeError("QR module reader is invalid.");const moduleCount=size,bits=new Uint8Array(moduleCount*moduleCount);for(let row=0;row<moduleCount;row++)for(let col=0;col<moduleCount;col++){const value=Reflect.apply(get,modules,[row,col]);if(value!==0&&value!==1&&value!==!1&&value!==!0)throw new TypeError("QR module value is invalid.");bits[row*moduleCount+col]=value===1||value===!0?1:0}return Object.freeze({size:moduleCount,get(row,col){return!Number.isInteger(row)||!Number.isInteger(col)||row<0||col<0||row>=moduleCount||col>=moduleCount?0:bits[row*moduleCount+col]===1?1:0}})}function normalizeErrorCorrection(value){const upper=value.toUpperCase();return ERROR_CORRECTION_LEVELS.has(upper)?upper:DEFAULT_ERROR_CORRECTION}const errorCorrectionConverter={fromAttribute(value){return value===null?DEFAULT_ERROR_CORRECTION:normalizeErrorCorrection(value)}};class LyraQrCode extends LyraElement{static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,noData:LYRA_DEFAULT_noData,open:LYRA_DEFAULT_open,qrCodeGenerationFailed:LYRA_DEFAULT_qrCodeGenerationFailed,qrCodeMissingLibrary:LYRA_DEFAULT_qrCodeMissingLibrary}}static{this.styles=[LyraElement.styles,styles]}static preload(){return loadQrCodeCached().then(api=>api!==null)}get size(){return this._size}set size(value){const oldValue=this._size;this._size=finiteRange(value,DEFAULT_SIZE,MIN_SIZE,MAX_SIZE),this.requestUpdate("size",oldValue)}get radius(){return this._radius}set radius(value){const oldValue=this._radius;this._radius=finiteRange(value,DEFAULT_RADIUS,MIN_RADIUS,MAX_RADIUS),this.requestUpdate("radius",oldValue)}get errorCorrection(){return this._errorCorrection}set errorCorrection(value){const oldValue=this._errorCorrection;this._errorCorrection=normalizeErrorCorrection(value),this.requestUpdate("errorCorrection",oldValue)}get canvas(){return this.renderRoot?.querySelector("canvas")}constructor(){super(),this.value="",this.label="",this.fill="",this.background="",this.image=null,this.imageBackground=null,this.imageCoverage=null,this.imagePadding=null,this._size=DEFAULT_SIZE,this._radius=DEFAULT_RADIUS,this._errorCorrection=DEFAULT_ERROR_CORRECTION,this.loadState={kind:"empty"},this.announcements=new AnnouncementSinkController(this),this.pendingLoadingAnnouncement=!1,this.visible=!0,this.visibilityKnown=!0,this.intersectionGeneration=0,this.loadLibrary=loadQrCodeCached,this.generation=0;try{this.accessibilityInternals=this.attachInternals()}catch{this.accessibilityInternals=void 0}this.syncSemanticOwner(),new ThemeWatcher(this,()=>this.refreshTheme())}connectedCallback(){this.value&&this.loadState.kind==="empty"?this.transitionTo({kind:"loading"}):this.setAttribute("aria-busy",this.loadState.kind==="loading"?"true":"false"),super.connectedCallback(),this.bindVisibilityObserver(),this.hasUpdated&&this.value&&(this.loadState.kind==="loading"||this.image&&this.loadState.kind==="ready"&&!this.loadState.image)&&this.generate()}disconnectedCallback(){this.generation++,this.clearVisibilityObserver(),this.visible=!1,this.visibilityKnown=!1,this.pendingLoadingAnnouncement=!1,super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.clearVisibilityObserver(),this.visible=!1,this.visibilityKnown=!1,this.announcements.adopted()}bindVisibilityObserver(){this.clearVisibilityObserver();const owner=this.ownerDocument.defaultView;if(!owner){this.restoreImmediateVisibility();return}let IntersectionObserverCtor;try{IntersectionObserverCtor=owner.IntersectionObserver}catch{this.restoreImmediateVisibility();return}if(typeof IntersectionObserverCtor!="function"){this.restoreImmediateVisibility();return}this.visible=!1,this.visibilityKnown=!1;const generation=++this.intersectionGeneration;let observer;try{observer=new IntersectionObserverCtor(entries=>{if(generation!==this.intersectionGeneration||!this.isConnected||this.ownerDocument.defaultView!==owner||this.intersectionObserver!==observer)return;const isIntersecting=readIntersectionState(entries,this);if(isIntersecting===void 0)return;const wasPaintable=this.visibilityKnown&&this.visible;this.visibilityKnown=!0,this.visible=isIntersecting,this.visible&&!wasPaintable&&this.draw()}),this.intersectionObserver=observer,observer.observe(this)}catch{try{observer?.disconnect()}catch{}if(generation!==this.intersectionGeneration)return;this.intersectionObserver=void 0,this.intersectionGeneration++,this.restoreImmediateVisibility()}}clearVisibilityObserver(){this.intersectionGeneration++;try{this.intersectionObserver?.disconnect()}catch{}this.intersectionObserver=void 0}restoreImmediateVisibility(){this.visible=!0,this.visibilityKnown=!0,this.isConnected&&this.draw()}transitionTo(next){const announcesLoading=next.kind==="loading"&&this.loadState.kind!=="loading"&&this.hasUpdated&&this.isConnected;this.loadState=next,this.setAttribute("aria-busy",next.kind==="loading"?"true":"false"),this.syncSemanticOwner(),announcesLoading&&(this.pendingLoadingAnnouncement=!0)}syncSemanticOwner(){const semantic=this.loadState.kind==="loading"||this.loadState.kind==="ready";this.accessibilityInternals&&(this.accessibilityInternals.role=semantic?"img":null,this.accessibilityInternals.ariaLabel=semantic?this.label||this.value:null)}updated(changed){if(super.updated(changed),this.syncSemanticOwner(),this.pendingLoadingAnnouncement&&(this.pendingLoadingAnnouncement=!1,this.announcements.announcePolite(this.localize("loading"))),changed.has("value")||changed.has("errorCorrection")||changed.has("image")||!this.hasUpdated){this.scheduleAfterUpdate(()=>{this.generate()});return}this.loadState.kind==="ready"&&(changed.has("size")||changed.has("radius")||changed.has("fill")||changed.has("background")||changed.has("imageBackground")||changed.has("imageCoverage")||changed.has("imagePadding")||changed.has("loadState"))&&this.draw()}willUpdate(changed){super.willUpdate(changed),(changed.has("value")||changed.has("errorCorrection")||changed.has("image"))&&this.transitionTo(this.value?{kind:"loading"}:{kind:"empty"})}generate(){this.generateCurrentValue()}async generateCurrentValue(){const generation=++this.generation;if(!this.value){this.transitionTo({kind:"empty"});return}this.announcements.current("assertive"),this.announcements.current("polite"),this.transitionTo({kind:"loading"});try{const api=await this.loadLibrary();if(generation!==this.generation||!this.isConnected)return;if(!api){this.transitionTo({kind:"error",key:"qrCodeMissingLibrary"}),this.announcements.announceAssertive(this.localize("qrCodeMissingLibrary"));return}const imageSource=safeMediaSrc(this.image),result=api.create(this.value,{errorCorrectionLevel:imageSource?"H":this.errorCorrection}),modules=normalizeQrModules(result);if(generation!==this.generation)return;if(this.transitionTo({kind:"ready",modules}),imageSource){const image=await this.loadEmbeddedImage(imageSource);if(generation!==this.generation||!this.isConnected||!image)return;this.transitionTo({kind:"ready",modules,image})}}catch{if(generation!==this.generation||!this.isConnected)return;this.transitionTo({kind:"error",key:"qrCodeGenerationFailed"}),this.announcements.announceAssertive(this.localize("qrCodeGenerationFailed"))}}async loadEmbeddedImage(src){const ImageCtor=this.ownerDocument.defaultView?.Image;if(!ImageCtor)return;const image=new ImageCtor;return image.decoding="async",await new Promise(resolve=>{image.addEventListener("load",()=>resolve(!0),{once:!0}),image.addEventListener("error",()=>resolve(!1),{once:!0}),image.src=src})&&image.naturalWidth>0&&image.naturalHeight>0?image:void 0}refreshTheme(){this.draw()}resolveColor(value,fallback){const resolved=resolveCanvasColor(this,value,fallback);return resolved===fallback&&devWarnOnce(INVALID_COLOR_WARNING_KEY,INVALID_COLOR_WARNING),resolved}fillColor(){const computed=this.ownerDocument.defaultView?.getComputedStyle(this);return this.resolveColor(this.fill.trim()||computed?.color?.trim()||FALLBACK_FILL,FALLBACK_FILL)}backgroundColor(){const computed=this.ownerDocument.defaultView?.getComputedStyle(this);return this.resolveColor(this.background.trim()||computed?.backgroundColor?.trim()||FALLBACK_BACKGROUND,FALLBACK_BACKGROUND)}draw(){if(this.loadState.kind!=="ready"||!this.visibilityKnown||!this.visible)return;const canvas=this.canvas;if(!canvas)return;const{modules}=this.loadState,size=this.size,allocation=LyraQrCode.canvasAllocation(size);canvas.width=allocation.pixelWidth,canvas.height=allocation.pixelHeight,canvas.style.width=`${size}px`,canvas.style.height=`${size}px`;const ctx=canvas.getContext("2d");if(!ctx)return;ctx.scale(allocation.scaleX,allocation.scaleY);const background=this.backgroundColor(),fill=this.fillColor();ctx.fillStyle=background,ctx.fillRect(0,0,size,size);const moduleCount=modules.size,moduleSize=size/moduleCount,radiusPx=this.radius*moduleSize,canRoundRect=typeof ctx.roundRect=="function";ctx.fillStyle=fill;for(let row=0;row<moduleCount;row++)for(let col=0;col<moduleCount;col++){if(!modules.get(row,col))continue;const x=col*moduleSize,y=row*moduleSize;this.radius>0&&canRoundRect?(ctx.beginPath(),ctx.roundRect(x,y,moduleSize,moduleSize,radiusPx),ctx.fill()):ctx.fillRect(x,y,moduleSize,moduleSize)}this.loadState.image&&this.drawEmbeddedImage(ctx,this.loadState.image,size)}static canvasAllocation(cssSize){return resolveBoundedCanvasAllocation({cssWidth:cssSize,cssHeight:cssSize,desiredScale:QR_BACKING_SCALE,maxDimension:MAX_CANVAS_DIMENSION,maxPixels:MAX_CANVAS_PIXELS})}drawEmbeddedImage(ctx,image,size){const coverage=finiteRange(this.imageCoverage??DEFAULT_IMAGE_COVERAGE,DEFAULT_IMAGE_COVERAGE,0,1),boxSize=size*coverage;if(boxSize<=0)return;const padding=finiteRange(this.imagePadding??DEFAULT_IMAGE_PADDING,DEFAULT_IMAGE_PADDING,0,boxSize/2),contentSize=boxSize-padding*2,boxStart=(size-boxSize)/2;if(this.imageBackground?.trim()&&(ctx.fillStyle=resolveCanvasColor(this,this.imageBackground.trim(),this.backgroundColor()),ctx.fillRect(boxStart,boxStart,boxSize,boxSize)),contentSize<=0)return;const scale=Math.min(contentSize/image.naturalWidth,contentSize/image.naturalHeight),width=image.naturalWidth*scale,height=image.naturalHeight*scale;ctx.drawImage(image,(size-width)/2,(size-height)/2,width,height)}accessibleName(){return this.getAttribute("aria-label")??(this.label||this.value)}renderBody(){switch(this.loadState.kind){case"empty":return html`<div part="empty">${this.localize("noData")}</div>`;case"loading":return html`<div part="loading">${this.localize("loading")}</div>`;case"error":return html`<div part="error">${this.localize(this.loadState.key)}</div>`;case"ready":return nothing}}render(){const ready=this.loadState.kind==="ready",fallbackSemantics=!this.accessibilityInternals&&ready;return html`<div part="base qr-code" style=${styleMap({inlineSize:`${this.size}px`,blockSize:`${this.size}px`})}>
1
+ import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{resolveBoundedCanvasAllocation}from"../../../internal/canvas.js";import{LyraElement}from"../../../internal/lyra-element.js";import{devWarnOnce}from"../../../internal/dev-mode-attribute-warning.js";import{resolveCanvasColor}from"../../../internal/canvas-color.js";import{finiteRange}from"../../../internal/numbers.js";import{safeMediaSrc}from"../../../internal/safe-url.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{loadQrCodeCached}from"./qr-code-loader.js";import{styles}from"./qr-code.styles.js";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{LYRA_DEFAULT_qrCodeGenerationFailed,LYRA_DEFAULT_qrCodeMissingLibrary}from"../../../internal/default-strings/media.generated.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_details,LYRA_DEFAULT_loading,LYRA_DEFAULT_map,LYRA_DEFAULT_noData,LYRA_DEFAULT_open}from"../../../internal/default-strings/shared.generated.js";const DEFAULT_SIZE=128,MIN_SIZE=1,MAX_SIZE=2048,QR_BACKING_SCALE=2,MAX_CANVAS_DIMENSION=4096,MAX_CANVAS_PIXELS=8388608,MAX_QR_MODULE_COUNT=177,DEFAULT_RADIUS=0,MIN_RADIUS=0,MAX_RADIUS=.5,DEFAULT_IMAGE_COVERAGE=.5,DEFAULT_IMAGE_PADDING=0,DEFAULT_ERROR_CORRECTION="H",ERROR_CORRECTION_LEVELS=new Set(["L","M","Q","H"]),FALLBACK_FILL="#000000",FALLBACK_BACKGROUND="transparent",INVALID_COLOR_WARNING_KEY="lyra-qr-code-invalid-color",INVALID_COLOR_WARNING="<lr-qr-code> received an invalid color and used its fallback color.";function isObjectLike(value){return(typeof value=="object"||typeof value=="function")&&value!==null}function readIntersectionState(entries,target){try{if(!Array.isArray(entries))return;for(const candidate of entries)if(isObjectLike(candidate))try{const entry=candidate;if(entry.target!==target)continue;const isIntersecting=entry.isIntersecting;if(typeof isIntersecting=="boolean")return isIntersecting}catch{}}catch{}}function normalizeQrModules(result){if(!isObjectLike(result))throw new TypeError("QR result must be an object.");const modules=result.modules;if(!isObjectLike(modules))throw new TypeError("QR result has no module matrix.");const size=modules.size,get=modules.get;if(!Number.isSafeInteger(size)||size<1||size>MAX_QR_MODULE_COUNT)throw new TypeError("QR module count is invalid.");if(typeof get!="function")throw new TypeError("QR module reader is invalid.");const moduleCount=size,bits=new Uint8Array(moduleCount*moduleCount);for(let row=0;row<moduleCount;row++)for(let col=0;col<moduleCount;col++){const value=Reflect.apply(get,modules,[row,col]);if(value!==0&&value!==1&&value!==!1&&value!==!0)throw new TypeError("QR module value is invalid.");bits[row*moduleCount+col]=value===1||value===!0?1:0}return Object.freeze({size:moduleCount,get(row,col){return!Number.isInteger(row)||!Number.isInteger(col)||row<0||col<0||row>=moduleCount||col>=moduleCount?0:bits[row*moduleCount+col]===1?1:0}})}function normalizeErrorCorrection(value){const upper=value.toUpperCase();return ERROR_CORRECTION_LEVELS.has(upper)?upper:DEFAULT_ERROR_CORRECTION}const errorCorrectionConverter={fromAttribute(value){return value===null?DEFAULT_ERROR_CORRECTION:normalizeErrorCorrection(value)}};class LyraQrCode extends LyraElement{static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,noData:LYRA_DEFAULT_noData,open:LYRA_DEFAULT_open,qrCodeGenerationFailed:LYRA_DEFAULT_qrCodeGenerationFailed,qrCodeMissingLibrary:LYRA_DEFAULT_qrCodeMissingLibrary}}static{this.styles=[LyraElement.styles,styles]}static preload(){return loadQrCodeCached().then(api=>api!==null)}get size(){return this._size}set size(value){const oldValue=this._size;this._size=finiteRange(value,DEFAULT_SIZE,MIN_SIZE,MAX_SIZE),this.requestUpdate("size",oldValue)}get radius(){return this._radius}set radius(value){const oldValue=this._radius;this._radius=finiteRange(value,DEFAULT_RADIUS,MIN_RADIUS,MAX_RADIUS),this.requestUpdate("radius",oldValue)}get errorCorrection(){return this._errorCorrection}set errorCorrection(value){const oldValue=this._errorCorrection;this._errorCorrection=normalizeErrorCorrection(value),this.requestUpdate("errorCorrection",oldValue)}get canvas(){return this.renderRoot?.querySelector("canvas")}constructor(){super(),this.value="",this.label="",this.fill="",this.background="",this.image=null,this.imageBackground=null,this.imageCoverage=null,this.imagePadding=null,this._size=DEFAULT_SIZE,this._radius=DEFAULT_RADIUS,this._errorCorrection=DEFAULT_ERROR_CORRECTION,this.loadState={kind:"empty"},this.announcements=new AnnouncementSinkController(this),this.pendingLoadingAnnouncement=!1,this.visible=!0,this.visibilityKnown=!0,this.intersectionGeneration=0,this.loadLibrary=loadQrCodeCached,this.generation=0;try{this.accessibilityInternals=this.attachInternals()}catch{this.accessibilityInternals=void 0}this.syncSemanticOwner(),new ThemeWatcher(this,()=>this.refreshTheme())}connectedCallback(){this.value&&this.loadState.kind==="empty"?this.transitionTo({kind:"loading"}):this.setAttribute("aria-busy",this.loadState.kind==="loading"?"true":"false"),super.connectedCallback(),this.bindVisibilityObserver(),this.hasUpdated&&this.value&&(this.loadState.kind==="loading"||this.image&&this.loadState.kind==="ready"&&!this.loadState.image)&&this.generate()}disconnectedCallback(){this.generation++,this.clearEmbeddedImage(),this.clearVisibilityObserver(),this.visible=!1,this.visibilityKnown=!1,this.pendingLoadingAnnouncement=!1,super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.generation++,this.clearEmbeddedImage(),this.clearVisibilityObserver(),this.visible=!1,this.visibilityKnown=!1,this.announcements.adopted()}bindVisibilityObserver(){this.clearVisibilityObserver();const owner=this.ownerDocument.defaultView;if(!owner){this.restoreImmediateVisibility();return}let IntersectionObserverCtor;try{IntersectionObserverCtor=owner.IntersectionObserver}catch{this.restoreImmediateVisibility();return}if(typeof IntersectionObserverCtor!="function"){this.restoreImmediateVisibility();return}this.visible=!1,this.visibilityKnown=!1;const generation=++this.intersectionGeneration;let observer;try{observer=new IntersectionObserverCtor(entries=>{if(generation!==this.intersectionGeneration||!this.isConnected||this.ownerDocument.defaultView!==owner||this.intersectionObserver!==observer)return;const isIntersecting=readIntersectionState(entries,this);if(isIntersecting===void 0)return;const wasPaintable=this.visibilityKnown&&this.visible;this.visibilityKnown=!0,this.visible=isIntersecting,this.visible&&!wasPaintable&&this.draw()}),this.intersectionObserver=observer,observer.observe(this)}catch{try{observer?.disconnect()}catch{}if(generation!==this.intersectionGeneration)return;this.intersectionObserver=void 0,this.intersectionGeneration++,this.restoreImmediateVisibility()}}clearVisibilityObserver(){this.intersectionGeneration++;try{this.intersectionObserver?.disconnect()}catch{}this.intersectionObserver=void 0}restoreImmediateVisibility(){this.visible=!0,this.visibilityKnown=!0,this.isConnected&&this.draw()}transitionTo(next){const announcesLoading=next.kind==="loading"&&this.loadState.kind!=="loading"&&this.hasUpdated&&this.isConnected;this.loadState=next,this.setAttribute("aria-busy",next.kind==="loading"?"true":"false"),this.syncSemanticOwner(),announcesLoading&&(this.pendingLoadingAnnouncement=!0)}syncSemanticOwner(){const semantic=this.loadState.kind==="loading"||this.loadState.kind==="ready";this.accessibilityInternals&&(this.accessibilityInternals.role=semantic?"img":null,this.accessibilityInternals.ariaLabel=semantic?this.label||this.value:null)}updated(changed){if(super.updated(changed),this.syncSemanticOwner(),this.pendingLoadingAnnouncement&&(this.pendingLoadingAnnouncement=!1,this.announcements.announcePolite(this.localize("loading"))),changed.has("value")||changed.has("errorCorrection")||changed.has("image")||!this.hasUpdated){this.scheduleAfterUpdate(()=>{this.generate()});return}this.loadState.kind==="ready"&&(changed.has("size")||changed.has("radius")||changed.has("fill")||changed.has("background")||changed.has("imageBackground")||changed.has("imageCoverage")||changed.has("imagePadding")||changed.has("loadState"))&&this.draw()}willUpdate(changed){super.willUpdate(changed),(!this.value||changed.has("image")&&this.embeddedImage?.src!==safeMediaSrc(this.image))&&this.clearEmbeddedImage(),(changed.has("value")||changed.has("errorCorrection")||changed.has("image"))&&this.transitionTo(this.value?{kind:"loading"}:{kind:"empty"})}generate(){this.generateCurrentValue()}async generateCurrentValue(){const generation=++this.generation;if(!this.value){this.clearEmbeddedImage(),this.transitionTo({kind:"empty"});return}this.announcements.current("assertive"),this.announcements.current("polite"),this.transitionTo({kind:"loading"});try{const api=await this.loadLibrary();if(generation!==this.generation||!this.isConnected)return;if(!api){this.transitionTo({kind:"error",key:"qrCodeMissingLibrary"}),this.announcements.announceAssertive(this.localize("qrCodeMissingLibrary"));return}const imageSource=safeMediaSrc(this.image),result=api.create(this.value,{errorCorrectionLevel:imageSource?"H":this.errorCorrection}),modules=normalizeQrModules(result);if(generation!==this.generation)return;if(this.transitionTo({kind:"ready",modules}),imageSource){const image=await this.loadEmbeddedImage(imageSource);if(generation!==this.generation||!this.isConnected||!image)return;this.transitionTo({kind:"ready",modules,image})}}catch{if(generation!==this.generation||!this.isConnected)return;this.transitionTo({kind:"error",key:"qrCodeGenerationFailed"}),this.announcements.announceAssertive(this.localize("qrCodeGenerationFailed"))}}clearEmbeddedImage(){const operation=this.embeddedImage;this.embeddedImage=void 0,operation?.cancel(),this.loadState.kind==="ready"&&this.loadState.image&&this.transitionTo({kind:"ready",modules:this.loadState.modules})}loadEmbeddedImage(src){const owner=this.ownerDocument;if(this.embeddedImage?.src===src&&this.embeddedImage.owner===owner)return this.embeddedImage.promise;this.clearEmbeddedImage();const ImageCtor=owner.defaultView?.Image;if(!ImageCtor)return Promise.resolve(void 0);const image=new ImageCtor;image.decoding="async";let settle;const promise=new Promise(resolve=>{settle=resolve});let pending=!0;const cleanup=()=>{image.removeEventListener("load",onLoad),image.removeEventListener("error",onError)},finish=loaded=>{if(!pending)return;pending=!1,cleanup();const valid=loaded&&image.naturalWidth>0&&image.naturalHeight>0;!valid&&this.embeddedImage===operation&&(this.embeddedImage=void 0),settle(valid?image:void 0)},onLoad=()=>finish(!0),onError=()=>finish(!1),operation={src,owner,promise,cancel:()=>{pending&&(finish(!1),image.removeAttribute("src"))}};this.embeddedImage=operation,image.addEventListener("load",onLoad),image.addEventListener("error",onError);try{image.src=src}catch{finish(!1)}return promise}refreshTheme(){this.draw()}resolveColor(value,fallback){const resolved=resolveCanvasColor(this,value,fallback);return resolved===fallback&&devWarnOnce(INVALID_COLOR_WARNING_KEY,INVALID_COLOR_WARNING),resolved}fillColor(){const computed=this.ownerDocument.defaultView?.getComputedStyle(this);return this.resolveColor(this.fill.trim()||computed?.color?.trim()||FALLBACK_FILL,FALLBACK_FILL)}backgroundColor(){const computed=this.ownerDocument.defaultView?.getComputedStyle(this);return this.resolveColor(this.background.trim()||computed?.backgroundColor?.trim()||FALLBACK_BACKGROUND,FALLBACK_BACKGROUND)}draw(){if(this.loadState.kind!=="ready"||!this.visibilityKnown||!this.visible)return;const canvas=this.canvas;if(!canvas)return;const{modules}=this.loadState,size=this.size,allocation=LyraQrCode.canvasAllocation(size);canvas.width=allocation.pixelWidth,canvas.height=allocation.pixelHeight,canvas.style.width=`${size}px`,canvas.style.height=`${size}px`;const ctx=canvas.getContext("2d");if(!ctx)return;ctx.scale(allocation.scaleX,allocation.scaleY);const background=this.backgroundColor(),fill=this.fillColor();ctx.fillStyle=background,ctx.fillRect(0,0,size,size);const moduleCount=modules.size,moduleSize=size/moduleCount,radiusPx=this.radius*moduleSize,canRoundRect=typeof ctx.roundRect=="function";ctx.fillStyle=fill;for(let row=0;row<moduleCount;row++)for(let col=0;col<moduleCount;col++){if(!modules.get(row,col))continue;const x=col*moduleSize,y=row*moduleSize;this.radius>0&&canRoundRect?(ctx.beginPath(),ctx.roundRect(x,y,moduleSize,moduleSize,radiusPx),ctx.fill()):ctx.fillRect(x,y,moduleSize,moduleSize)}this.loadState.image&&this.drawEmbeddedImage(ctx,this.loadState.image,size)}static canvasAllocation(cssSize){return resolveBoundedCanvasAllocation({cssWidth:cssSize,cssHeight:cssSize,desiredScale:QR_BACKING_SCALE,maxDimension:MAX_CANVAS_DIMENSION,maxPixels:MAX_CANVAS_PIXELS})}drawEmbeddedImage(ctx,image,size){const coverage=finiteRange(this.imageCoverage??DEFAULT_IMAGE_COVERAGE,DEFAULT_IMAGE_COVERAGE,0,1),boxSize=size*coverage;if(boxSize<=0)return;const padding=finiteRange(this.imagePadding??DEFAULT_IMAGE_PADDING,DEFAULT_IMAGE_PADDING,0,boxSize/2),contentSize=boxSize-padding*2,boxStart=(size-boxSize)/2;if(this.imageBackground?.trim()&&(ctx.fillStyle=resolveCanvasColor(this,this.imageBackground.trim(),this.backgroundColor()),ctx.fillRect(boxStart,boxStart,boxSize,boxSize)),contentSize<=0)return;const scale=Math.min(contentSize/image.naturalWidth,contentSize/image.naturalHeight),width=image.naturalWidth*scale,height=image.naturalHeight*scale;ctx.drawImage(image,(size-width)/2,(size-height)/2,width,height)}accessibleName(){return this.getAttribute("aria-label")??(this.label||this.value)}renderBody(){switch(this.loadState.kind){case"empty":return html`<div part="empty">${this.localize("noData")}</div>`;case"loading":return html`<div part="loading">${this.localize("loading")}</div>`;case"error":return html`<div part="error">${this.localize(this.loadState.key)}</div>`;case"ready":return nothing}}render(){const ready=this.loadState.kind==="ready",fallbackSemantics=!this.accessibilityInternals&&ready;return html`<div part="base qr-code" style=${styleMap({inlineSize:`${this.size}px`,blockSize:`${this.size}px`})}>
2
2
  <canvas
3
3
  part="canvas"
4
4
  ?hidden=${!ready}
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{html}from"lit";import{property,query}from"lit/decorators.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{LyraElement}from"../../../internal/lyra-element.js";import{playIcon,pauseIcon}from"../../../internal/icons.js";import{devWarnOnce}from"../../../internal/dev-mode-attribute-warning.js";import{finiteCount,finiteDuration}from"../../../internal/numbers.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{styles}from"./sequence-playback.styles.js";import{LYRA_DEFAULT_pause,LYRA_DEFAULT_play,LYRA_DEFAULT_playbackPosition,LYRA_DEFAULT_playbackStepPosition}from"../../../internal/default-strings.generated.js";const MIN_INTERVAL_MS=16,INVALID_INTERVAL_WARNING_KEY="lyra-sequence-playback-invalid-interval",INVALID_INTERVAL_WARNING="<lr-sequence-playback>: interval-ms is outside the supported timer range and the timer delay was clamped.";function warnInvalidInterval(){devWarnOnce(INVALID_INTERVAL_WARNING_KEY,INVALID_INTERVAL_WARNING)}class LyraSequencePlayback extends LyraElement{constructor(){super(...arguments),this.itemCount=0,this.currentIndex=0,this.intervalMs=900,this.withoutLoop=!1,this.hidden=!1,this._playing=!1,this.onControlFocus=event=>{relayNativeEvent(this,event)},this.onControlBlur=event=>{relayNativeEvent(this,event)},this.onSliderKeyDown=event=>{const delta=this.keyboardStepDelta(event.key);delta!==void 0&&(event.preventDefault(),this.goTo(finiteCount(this.currentIndex,0,this.maxIndex)+delta))}}static{this.defaultStrings={...super.defaultStrings,pause:LYRA_DEFAULT_pause,play:LYRA_DEFAULT_play,playbackPosition:LYRA_DEFAULT_playbackPosition,playbackStepPosition:LYRA_DEFAULT_playbackStepPosition}}static{this.styles=[LyraElement.styles,styles]}static{this.knownUnobservedAttributes=["playing"]}get playing(){return this._playing}setPlaying(next){next===this._playing||next&&finiteCount(this.itemCount)<=1||(this._playing=next,this.toggleAttribute("playing",next),this.requestUpdate(),next?(this.emit("lr-play"),this._playing&&this.scheduleTick()):(this.clearTimer(),this.emit("lr-pause")))}get maxIndex(){return Math.max(0,finiteCount(this.itemCount)-1)}disconnectedCallback(){this.pause(),this.clearTimer(),super.disconnectedCallback()}willUpdate(changed){super.willUpdate(changed),changed.has("hidden")&&this.hidden&&this.pause();const itemCount=finiteCount(this.itemCount),currentIndex=finiteCount(this.currentIndex);itemCount!==this.itemCount&&(this.itemCount=itemCount),currentIndex!==this.currentIndex&&(this.currentIndex=currentIndex),changed.has("currentIndex")&&!changed.has("itemCount")&&currentIndex>this.maxIndex&&(this.currentIndex=this.maxIndex),changed.has("itemCount")&&(this.itemCount<=1&&this.pause(),this.currentIndex>this.maxIndex&&this.setIndex(this.maxIndex))}play(){this.setPlaying(!0)}pause(){this.setPlaying(!1)}toggle(){this.setPlaying(!this._playing)}scheduleTick(){const rawDelay=this.intervalMs,delay=finiteDuration(rawDelay,MIN_INTERVAL_MS,MIN_INTERVAL_MS);delay!==rawDelay&&warnInvalidInterval();const timerWindow=this.ownerDocument.defaultView;if(!timerWindow)return;const id=timerWindow.setTimeout(()=>{this.timer!==id||this.timerWindow!==timerWindow||(this.tick(),this.playing&&this.timer===id&&this.timerWindow===timerWindow&&this.scheduleTick())},delay);this.timer=id,this.timerWindow=timerWindow}clearTimer(){this.timer!==void 0&&this.timerWindow?.clearTimeout(this.timer),this.timer=void 0,this.timerWindow=void 0}tick(){const itemCount=finiteCount(this.itemCount),next=finiteCount(this.currentIndex)+1;next>=itemCount?this.withoutLoop?(this.setIndex(itemCount-1),this.pause()):this.setIndex(0):this.setIndex(next)}setIndex(i){this.currentIndex=finiteCount(i,0,this.maxIndex),this.emit("lr-sequence-step",{currentIndex:this.currentIndex})}next(){const currentIndex=finiteCount(this.currentIndex);currentIndex+1<finiteCount(this.itemCount)&&this.setIndex(currentIndex+1)}previous(){const currentIndex=finiteCount(this.currentIndex);currentIndex>0&&this.setIndex(currentIndex-1)}goTo(currentIndex){this.pause(),this.setIndex(finiteCount(currentIndex,0,this.maxIndex))}focus(options){this.playButton?.focus(options)}blur(){this.playButton?.blur()}click(){this.playButton?.click()}keyboardStepDelta(key){const rtl=this.effectiveDirection==="rtl";if(key==="ArrowLeft")return rtl?1:-1;if(key==="ArrowRight")return rtl?-1:1}render(){const maxIndex=this.maxIndex,currentIndex=finiteCount(this.currentIndex,0,maxIndex),disabled=finiteCount(this.itemCount)<=1;return html`
1
+ import{__decorate}from"tslib";import{html}from"lit";import{property,query}from"lit/decorators.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{LyraElement}from"../../../internal/lyra-element.js";import{playIcon,pauseIcon}from"../../../internal/icons.js";import{devWarnOnce}from"../../../internal/dev-mode-attribute-warning.js";import{finiteCount,finiteDuration}from"../../../internal/numbers.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{styles}from"./sequence-playback.styles.js";import{LYRA_DEFAULT_pause,LYRA_DEFAULT_play,LYRA_DEFAULT_playbackPosition,LYRA_DEFAULT_playbackStepPosition}from"../../../internal/default-strings/media.generated.js";const MIN_INTERVAL_MS=16,INVALID_INTERVAL_WARNING_KEY="lyra-sequence-playback-invalid-interval",INVALID_INTERVAL_WARNING="<lr-sequence-playback>: interval-ms is outside the supported timer range and the timer delay was clamped.";function warnInvalidInterval(){devWarnOnce(INVALID_INTERVAL_WARNING_KEY,INVALID_INTERVAL_WARNING)}class LyraSequencePlayback extends LyraElement{constructor(){super(...arguments),this.itemCount=0,this.currentIndex=0,this.intervalMs=900,this.withoutLoop=!1,this.hidden=!1,this._playing=!1,this.onControlFocus=event=>{relayNativeEvent(this,event)},this.onControlBlur=event=>{relayNativeEvent(this,event)},this.onSliderKeyDown=event=>{const delta=this.keyboardStepDelta(event.key);delta!==void 0&&(event.preventDefault(),this.goTo(finiteCount(this.currentIndex,0,this.maxIndex)+delta))}}static{this.defaultStrings={...super.defaultStrings,pause:LYRA_DEFAULT_pause,play:LYRA_DEFAULT_play,playbackPosition:LYRA_DEFAULT_playbackPosition,playbackStepPosition:LYRA_DEFAULT_playbackStepPosition}}static{this.styles=[LyraElement.styles,styles]}static{this.knownUnobservedAttributes=["playing"]}get playing(){return this._playing}setPlaying(next){next===this._playing||next&&finiteCount(this.itemCount)<=1||(this._playing=next,this.toggleAttribute("playing",next),this.requestUpdate(),next?(this.emit("lr-play"),this._playing&&this.scheduleTick()):(this.clearTimer(),this.emit("lr-pause")))}get maxIndex(){return Math.max(0,finiteCount(this.itemCount)-1)}disconnectedCallback(){this.pause(),this.clearTimer(),super.disconnectedCallback()}willUpdate(changed){super.willUpdate(changed),changed.has("hidden")&&this.hidden&&this.pause();const itemCount=finiteCount(this.itemCount),currentIndex=finiteCount(this.currentIndex);itemCount!==this.itemCount&&(this.itemCount=itemCount),currentIndex!==this.currentIndex&&(this.currentIndex=currentIndex),changed.has("currentIndex")&&!changed.has("itemCount")&&currentIndex>this.maxIndex&&(this.currentIndex=this.maxIndex),changed.has("itemCount")&&(this.itemCount<=1&&this.pause(),this.currentIndex>this.maxIndex&&this.setIndex(this.maxIndex))}play(){this.setPlaying(!0)}pause(){this.setPlaying(!1)}toggle(){this.setPlaying(!this._playing)}scheduleTick(){const rawDelay=this.intervalMs,delay=finiteDuration(rawDelay,MIN_INTERVAL_MS,MIN_INTERVAL_MS);delay!==rawDelay&&warnInvalidInterval();const timerWindow=this.ownerDocument.defaultView;if(!timerWindow)return;const id=timerWindow.setTimeout(()=>{this.timer!==id||this.timerWindow!==timerWindow||(this.tick(),this.playing&&this.timer===id&&this.timerWindow===timerWindow&&this.scheduleTick())},delay);this.timer=id,this.timerWindow=timerWindow}clearTimer(){this.timer!==void 0&&this.timerWindow?.clearTimeout(this.timer),this.timer=void 0,this.timerWindow=void 0}tick(){const itemCount=finiteCount(this.itemCount),next=finiteCount(this.currentIndex)+1;next>=itemCount?this.withoutLoop?(this.setIndex(itemCount-1),this.pause()):this.setIndex(0):this.setIndex(next)}setIndex(i){this.currentIndex=finiteCount(i,0,this.maxIndex),this.emit("lr-sequence-step",{currentIndex:this.currentIndex})}next(){const currentIndex=finiteCount(this.currentIndex);currentIndex+1<finiteCount(this.itemCount)&&this.setIndex(currentIndex+1)}previous(){const currentIndex=finiteCount(this.currentIndex);currentIndex>0&&this.setIndex(currentIndex-1)}goTo(currentIndex){this.pause(),this.setIndex(finiteCount(currentIndex,0,this.maxIndex))}focus(options){this.playButton?.focus(options)}blur(){this.playButton?.blur()}click(){this.playButton?.click()}keyboardStepDelta(key){const rtl=this.effectiveDirection==="rtl";if(key==="ArrowLeft")return rtl?1:-1;if(key==="ArrowRight")return rtl?-1:1}render(){const maxIndex=this.maxIndex,currentIndex=finiteCount(this.currentIndex,0,maxIndex),disabled=finiteCount(this.itemCount)<=1;return html`
2
2
  <div part="base">
3
3
  <button
4
4
  part="play-button"
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{ref}from"lit/directives/ref.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{hostAriaLabel,srOnly}from"../../../internal/a11y.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{formatMediaTime}from"../../../internal/media-time.js";import{MAX_NATIVE_PLAYBACK_RATE,MIN_NATIVE_PLAYBACK_RATE,NATIVE_MEDIA_RELAY_EVENTS,NativeMediaController,canExitFullscreen,canRequestFullscreen,canRequestPictureInPicture,safeNativeMediaSource}from"../../../internal/media-controller.js";import{finiteRange}from"../../../internal/numbers.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{readResponseText,resolveOwnerFetchTarget}from"../../../internal/resource-loader.js";import{safeMediaSrc}from"../../../internal/safe-url.js";import{styles}from"./video.styles.js";import{LYRA_DEFAULT_avPlayerPlaybackRate,LYRA_DEFAULT_avPlayerPosition,LYRA_DEFAULT_avPlayerRateOption,LYRA_DEFAULT_pause,LYRA_DEFAULT_play,LYRA_DEFAULT_playbackPosition,LYRA_DEFAULT_videoCaptions,LYRA_DEFAULT_videoCaptionsOff,LYRA_DEFAULT_videoEnterFullscreen,LYRA_DEFAULT_videoExitFullscreen,LYRA_DEFAULT_videoExitPictureInPicture,LYRA_DEFAULT_videoMute,LYRA_DEFAULT_videoPictureInPicture,LYRA_DEFAULT_videoPlayerLabel,LYRA_DEFAULT_videoUnmute,LYRA_DEFAULT_videoVolume}from"../../../internal/default-strings.generated.js";const MAX_THUMBNAIL_BYTES=256*1024,MAX_THUMBNAIL_CUES=2e3,PLAYBACK_RATES=[.5,.75,1,1.25,1.5,2];function safeControls(value){return value==="none"||value==="full"?value:"standard"}function safePreload(value){return value==="auto"||value==="none"?value:"metadata"}function parseVttTime(source){const parts=source.trim().split(":").map(Number);if(parts.length<2||parts.length>3||parts.some(part=>!Number.isFinite(part)))return null;const seconds=parts.length===3?parts[0]*3600+parts[1]*60+parts[2]:parts[0]*60+parts[1];return seconds>=0?seconds:null}function parseThumbnailUrl(source,baseUrl,URLCtor){const trimmed=source.trim();if(!trimmed)return null;try{const resolved=new URLCtor(trimmed,baseUrl),sprite=/^#xywh=(\d+),(\d+),(\d+),(\d+)$/u.exec(resolved.hash);resolved.hash="";const src=safeMediaSrc(resolved.href,URLCtor);if(!src)return null;if(!sprite)return{src};const[x,y,width,height]=sprite.slice(1).map(Number);return!Number.isFinite(x)||!Number.isFinite(y)||!Number.isFinite(width)||!Number.isFinite(height)||width<=0||height<=0?null:{src,x,y,width,height}}catch{return null}}function parseThumbnailVtt(source,sourceUrl,URLCtor){const cues=[],normalized=source.replace(/^\uFEFF/u,"").replaceAll(`\r
1
+ import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{ref}from"lit/directives/ref.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{hostAriaLabel,srOnly}from"../../../internal/a11y.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{formatMediaTime}from"../../../internal/media-time.js";import{MAX_NATIVE_PLAYBACK_RATE,MIN_NATIVE_PLAYBACK_RATE,NATIVE_MEDIA_RELAY_EVENTS,NativeMediaController,canExitFullscreen,canRequestFullscreen,canRequestPictureInPicture,safeNativeMediaSource}from"../../../internal/media-controller.js";import{finiteRange}from"../../../internal/numbers.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{readResponseText,resolveOwnerFetchTarget}from"../../../internal/resource-loader.js";import{safeMediaSrc}from"../../../internal/safe-url.js";import{styles}from"./video.styles.js";import{LYRA_DEFAULT_avPlayerPlaybackRate,LYRA_DEFAULT_avPlayerPosition,LYRA_DEFAULT_avPlayerRateOption,LYRA_DEFAULT_pause,LYRA_DEFAULT_play,LYRA_DEFAULT_playbackPosition,LYRA_DEFAULT_videoCaptions,LYRA_DEFAULT_videoCaptionsOff,LYRA_DEFAULT_videoEnterFullscreen,LYRA_DEFAULT_videoExitFullscreen,LYRA_DEFAULT_videoExitPictureInPicture,LYRA_DEFAULT_videoMute,LYRA_DEFAULT_videoPictureInPicture,LYRA_DEFAULT_videoPlayerLabel,LYRA_DEFAULT_videoUnmute,LYRA_DEFAULT_videoVolume}from"../../../internal/default-strings/media.generated.js";const MAX_THUMBNAIL_BYTES=256*1024,MAX_THUMBNAIL_CUES=2e3,PLAYBACK_RATES=[.5,.75,1,1.25,1.5,2];function safeControls(value){return value==="none"||value==="full"?value:"standard"}function safePreload(value){return value==="auto"||value==="none"?value:"metadata"}function parseVttTime(source){const parts=source.trim().split(":").map(Number);if(parts.length<2||parts.length>3||parts.some(part=>!Number.isFinite(part)))return null;const seconds=parts.length===3?parts[0]*3600+parts[1]*60+parts[2]:parts[0]*60+parts[1];return seconds>=0?seconds:null}function parseThumbnailUrl(source,baseUrl,URLCtor){const trimmed=source.trim();if(!trimmed)return null;try{const resolved=new URLCtor(trimmed,baseUrl),sprite=/^#xywh=(\d+),(\d+),(\d+),(\d+)$/u.exec(resolved.hash);resolved.hash="";const src=safeMediaSrc(resolved.href,URLCtor);if(!src)return null;if(!sprite)return{src};const[x,y,width,height]=sprite.slice(1).map(Number);return!Number.isFinite(x)||!Number.isFinite(y)||!Number.isFinite(width)||!Number.isFinite(height)||width<=0||height<=0?null:{src,x,y,width,height}}catch{return null}}function parseThumbnailVtt(source,sourceUrl,URLCtor){const cues=[],normalized=source.replace(/^\uFEFF/u,"").replaceAll(`\r
2
2
  `,`
3
3
  `).replaceAll("\r",`
4
4
  `);for(const block of normalized.split(/\n{2,}/u)){if(cues.length>=MAX_THUMBNAIL_CUES)break;const lines=block.split(`
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{eventCollectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{formatMediaTime}from"../../../internal/media-time.js";import{LyraElement}from"../../../internal/lyra-element.js";import{hostAriaLabel}from"../../../internal/a11y.js";import{shadowFocusTarget}from"../../../internal/active-element.js";import{finiteRange}from"../../../internal/numbers.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{tag}from"../../../internal/prefix.js";import{safeMediaSrc}from"../../../internal/safe-url.js";import{styles}from"./video-playlist.styles.js";import{LYRA_DEFAULT_videoPlaylistLabel,LYRA_DEFAULT_videoPlaylistUntitled}from"../../../internal/default-strings.generated.js";function safeControls(value){return value==="none"||value==="standard"?value:"full"}function safeRepeat(value){return value==="one"||value==="all"?value:"none"}function sameVideos(left,right){return left.length===right.length&&left.every((video,index)=>video===right[index])}function sourceSnapshot(src,type,media){return{src,type,media}}function trackSnapshot(src,kind,srclang,label,isDefault){return{src,kind,srclang,label,default:isDefault}}class LyraVideoPlaylist extends LyraElement{constructor(){super(...arguments),this.controls="full",this.iconLibrary="system",this.withoutAutoAdvance=!1,this.repeat="none",this.items=[],this.playlistVideos=[],this.liveChildrenReady=!1,this.activeIndex=-1,this.navigationIndex=-1,this.listeners=new Map,this.lastKnownPlaying=new WeakMap,this.nativeVideos=new WeakMap,this.needsReload=new WeakSet,this.ownedVideoState=new WeakMap,this.preferences={},this.activationGeneration=0,this.reconcileGeneration=0,this.onSlotChange=()=>this.reconcileChildren(),this.onItemFocus=event=>{relayNativeEvent(this,event)},this.onItemBlur=event=>{relayNativeEvent(this,event)}}static{this.defaultStrings={...super.defaultStrings,videoPlaylistLabel:LYRA_DEFAULT_videoPlaylistLabel,videoPlaylistUntitled:LYRA_DEFAULT_videoPlaylistUntitled}}static{this.collectionSupport=eventCollectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-video-change"])}static{this.styles=[LyraElement.styles,styles]}connectedCallback(){super.connectedCallback(),this.observeChildren(),this.hasUpdated?this.scheduleAfterUpdate(()=>this.reconcileChildren(),"video-playlist-reconcile"):this.seedFirstRenderState(()=>{this.directVideos().length>0&&this.reconcileChildren()})}disconnectedCallback(){this.activationGeneration+=1,this.reconcileGeneration+=1,this.pendingPlay=void 0,this.mutationObserver?.disconnect(),this.mutationObserver=void 0;for(const video of this.playlistVideos)this.unbindVideo(video),video.hidden=!0,this.pauseAndUnload(video);super.disconnectedCallback()}willUpdate(changed){super.willUpdate(changed),changed.has("controls")&&(this.controls=safeControls(this.controls)),changed.has("repeat")&&(this.repeat=safeRepeat(this.repeat)),(changed.has("controls")||changed.has("iconLibrary"))&&this.scheduleAfterUpdate(()=>this.reconcileChildren(),"video-playlist-reconcile")}observeChildren(){this.mutationObserver?.disconnect(),this.mutationObserver=void 0;const MutationObserverCtor=this.ownerDocument.defaultView?.MutationObserver;MutationObserverCtor&&(this.mutationObserver=new MutationObserverCtor(()=>{this.scheduleAfterUpdate(()=>{this.reconcileChildren(),this.requestUpdate()},"video-playlist-reconcile")}),this.mutationObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["default","inert","kind","label","media","poster","src","srclang","title","type"]}))}directVideos(){const videoTag=tag("video");return[...this.children].filter(child=>child.localName===videoTag)}isEnabled(video){return!video.inert}nearestEnabledIndex(videos,preferred){if(!videos.length)return-1;const start=Math.min(Math.max(preferred,0),videos.length-1);for(let index=start;index<videos.length;index+=1)if(this.isEnabled(videos[index]))return index;for(let index=start-1;index>=0;index-=1)if(this.isEnabled(videos[index]))return index;return-1}reconcileChildren(){if(!this.isConnected)return;const previousVideos=this.playlistVideos,previousActive=this.activeVideo,previousIndex=this.activeIndex,previousNavigation=previousVideos[this.navigationIndex],navigationHadFocus=shadowFocusTarget(this)?.getAttribute("part")==="playlist-item",videos=this.directVideos();(videos.length>0||this.liveChildrenReady)&&(this.liveChildrenReady=!0);let active=previousActive&&videos.includes(previousActive)&&this.isEnabled(previousActive)?previousActive:void 0,nextIndex=active?videos.indexOf(active):this.nearestEnabledIndex(videos,previousIndex);!active&&nextIndex>=0&&(active=videos[nextIndex]),active||(nextIndex=-1);const activeChanged=active!==previousActive,outgoingWasRemoved=!!(previousActive&&!videos.includes(previousActive)),resumePlayback=activeChanged&&previousActive?outgoingWasRemoved?this.lastKnownPlaying.get(previousActive)??previousActive.getState().playing:previousActive.getState().playing:!1,outgoingPreferences=activeChanged&&previousActive?outgoingWasRemoved?this.capturePreferences(previousActive,this.nativeVideos.get(previousActive)):this.capturePreferences(previousActive):void 0;for(const video of previousVideos)videos.includes(video)||this.releaseVideo(video);for(const video of videos)this.claimVideo(video),this.bindVideo(video);activeChanged&&previousActive?(this.preferences=outgoingPreferences??{},outgoingWasRemoved||this.pauseAndUnload(previousActive),this.activationGeneration+=1):activeChanged&&(this.activationGeneration+=1),this.activeVideo=active,this.activeIndex=nextIndex,sameVideos(previousVideos,videos)||(this.playlistVideos=videos);for(const video of videos){video.controls!==this.controls&&(video.controls=this.controls),video.iconLibrary!==this.iconLibrary&&(video.iconLibrary=this.iconLibrary);const isActive=video===active;video.hidden=!isActive,isActive||this.pauseAndUnload(video)}active?(activeChanged||this.needsReload.has(active))&&this.activateVideo(active,resumePlayback,this.activationGeneration):this.pendingPlay=void 0;const keptNavigation=previousNavigation&&videos.includes(previousNavigation)&&this.isEnabled(previousNavigation)?videos.indexOf(previousNavigation):-1;this.navigationIndex=keptNavigation>=0?keptNavigation:nextIndex,navigationHadFocus&&keptNavigation<0&&this.navigationIndex>=0&&this.focusItem(this.navigationIndex),activeChanged&&previousActive&&this.emitChange(previousIndex,nextIndex,active??null),this.scheduleChildrenReady(videos)}scheduleChildrenReady(videos){const reconcileGeneration=++this.reconcileGeneration;Promise.all(videos.map(video=>video.updateComplete)).then(()=>{if(!this.isConnected||reconcileGeneration!==this.reconcileGeneration)return;for(const video of this.playlistVideos)this.rememberNativeVideo(video);for(const video of this.playlistVideos)video!==this.activeVideo&&this.pauseAndUnload(video);const active=this.activeVideo;if(!active||!this.needsReload.has(active))return;const shouldPlay=this.pendingPlay?.video===active&&this.pendingPlay.generation===this.activationGeneration;this.activateVideo(active,shouldPlay,this.activationGeneration)})}bindVideo(video){if(this.listeners.has(video))return;const listeners={ended:()=>{this.rememberNativeVideo(video),this.lastKnownPlaying.set(video,!1),this.handleCompletion(video)},error:()=>{this.rememberNativeVideo(video),this.lastKnownPlaying.set(video,!1)},loadedmetadata:()=>{this.rememberNativeVideo(video),this.handleLoadedMetadata(video)},pause:()=>{this.rememberNativeVideo(video),this.lastKnownPlaying.set(video,!1)},play:()=>{this.rememberNativeVideo(video),this.lastKnownPlaying.set(video,!0),video!==this.activeVideo&&this.pauseAndUnload(video)}};this.lastKnownPlaying.set(video,video.getState().playing),this.rememberNativeVideo(video),this.listeners.set(video,listeners),video.addEventListener("ended",listeners.ended),video.addEventListener("error",listeners.error),video.addEventListener("loadedmetadata",listeners.loadedmetadata),video.addEventListener("pause",listeners.pause),video.addEventListener("play",listeners.play)}unbindVideo(video){const listeners=this.listeners.get(video);listeners&&(video.removeEventListener("ended",listeners.ended),video.removeEventListener("error",listeners.error),video.removeEventListener("loadedmetadata",listeners.loadedmetadata),video.removeEventListener("pause",listeners.pause),video.removeEventListener("play",listeners.play),this.listeners.delete(video))}claimVideo(video){this.ownedVideoState.has(video)||this.ownedVideoState.set(video,{controls:video.controls,iconLibrary:video.iconLibrary,hidden:!!video.hidden})}releaseVideo(video){const authored=this.ownedVideoState.get(video);this.unbindVideo(video),this.pauseAndUnload(video),authored&&(video.controls=authored.controls,video.iconLibrary=authored.iconLibrary,video.hidden=authored.hidden,this.ownedVideoState.delete(video),video.isConnected&&video.load())}rememberNativeVideo(video){const native=video.getVideoElement();native&&this.nativeVideos.set(video,native)}pauseAndUnload(video){video.pause(),video.hidden=!0,this.needsReload.add(video),video.unloadMedia()}activateVideo(video,shouldPlay,generation){if(video.hidden=!1,!video.getVideoElement()){this.needsReload.add(video),shouldPlay&&(this.pendingPlay={video,generation});return}if(this.rememberNativeVideo(video),video.load(),this.needsReload.delete(video),this.applyPreferences(video,this.preferences),!shouldPlay){this.pendingPlay?.video===video&&(this.pendingPlay=void 0);return}this.pendingPlay=void 0,video.play().catch(()=>{generation!==this.activationGeneration||this.activeVideo})}capturePreferences(video,native=video.getVideoElement()){return video.captureMediaPreferences(native)}applyPreferences(video,preferences){video.applyMediaPreferences(preferences)}handleLoadedMetadata(video){video===this.activeVideo&&(this.applyPreferences(video,this.preferences),this.requestUpdate())}handleCompletion(video){if(video!==this.activeVideo||this.withoutAutoAdvance)return;if(this.repeat==="one"){video.seek(0);const generation=this.activationGeneration;video.play().catch(()=>{generation!==this.activationGeneration||this.activeVideo});return}const nextIndex=this.nearestEnabledIndex(this.playlistVideos,this.activeIndex+1);if(nextIndex>this.activeIndex){this.switchTo(nextIndex,!0);return}if(this.repeat==="all"){const first=this.nearestEnabledIndex(this.playlistVideos,0);if(first>=0&&first!==this.activeIndex)this.switchTo(first,!0);else if(first===this.activeIndex){video.seek(0);const generation=this.activationGeneration;video.play().catch(()=>{generation!==this.activationGeneration||this.activeVideo})}}}snapshotVideo(video){const sources=[],directSrc=video.src.trim();directSrc&&sources.push(sourceSnapshot(directSrc,"",""));const tracks=[];for(const child of video.children)if(child.localName==="source"){const src=child.getAttribute("src")?.trim()??"";src&&sources.push(sourceSnapshot(src,child.getAttribute("type")??"",child.getAttribute("media")??""))}else if(child.localName==="track"){const src=child.getAttribute("src")?.trim()??"";src&&tracks.push(trackSnapshot(src,child.getAttribute("kind")??"",child.getAttribute("srclang")??"",child.getAttribute("label")??"",child.hasAttribute("default")))}return{title:video.title,poster:video.poster,sources,tracks}}emitChange(previousIndex,currentIndex,video){this.emit("lr-video-change",{previousIndex,currentIndex,video:video?this.snapshotVideo(video):null})}switchTo(index,forcePlay=!1){const incoming=this.playlistVideos[index];if(!incoming||!this.isEnabled(incoming))return;const previousIndex=this.activeIndex,outgoing=this.activeVideo;if(incoming===outgoing){if(this.navigationIndex=index,this.requestUpdate(),forcePlay){const generation=this.activationGeneration;incoming.play().catch(()=>{generation!==this.activationGeneration||this.activeVideo})}this.emitChange(previousIndex,index,incoming);return}const wasPlaying=forcePlay||!!outgoing?.getState().playing;outgoing&&(this.preferences=this.capturePreferences(outgoing),this.pauseAndUnload(outgoing)),this.activationGeneration+=1,this.activeVideo=incoming,this.activeIndex=index,this.navigationIndex=index;for(const video of this.playlistVideos){const isActive=video===incoming;video.hidden=!isActive,!isActive&&video!==outgoing&&this.pauseAndUnload(video)}this.activateVideo(incoming,wasPlaying,this.activationGeneration),this.requestUpdate(),this.emitChange(previousIndex,index,incoming)}goTo(index){!Number.isFinite(index)||!Number.isInteger(index)||index<0||index>=this.playlistVideos.length||this.switchTo(index)}next(){const index=this.nearestEnabledIndex(this.playlistVideos,this.activeIndex+1);index>this.activeIndex&&this.switchTo(index)}previous(){for(let index=this.activeIndex-1;index>=0;index-=1)if(this.isEnabled(this.playlistVideos[index])){this.switchTo(index);return}}onItemClick(event){const button=event.currentTarget,index=Number(button.dataset.index);Number.isInteger(index)&&(this.navigationIndex=index,this.goTo(index))}enabledIndices(){const result=[];for(let index=0;index<this.playlistVideos.length;index+=1)this.isEnabled(this.playlistVideos[index])&&result.push(index);return result}moveNavigation(from,direction){const enabled=this.enabledIndices(),position=enabled.indexOf(from);if(position<0)return;const next=enabled[position+direction];next!==void 0&&this.focusItem(next)}get navigationItem(){const rows=[...this.renderRoot.querySelectorAll('[part~="playlist-item"]')];return rows.find(row=>!row.disabled&&row.getAttribute("aria-current")==="true")??rows.find(row=>!row.disabled)??null}focus(options){this.navigationItem?.focus(options)}blur(){this.navigationItem?.blur()}click(){this.navigationItem?.click()}focusItem(index){this.isEnabled(this.playlistVideos[index])&&(this.navigationIndex=index,this.requestUpdate(),this.updateComplete.then(()=>{this.navigationIndex===index&&this.shadowRoot?.querySelector(`[data-index="${index}"]`)?.focus()}))}onItemKeyDown(event){const button=event.currentTarget,index=Number(button.dataset.index);if(!Number.isInteger(index)||button.disabled)return;const forward=this.effectiveDirection==="rtl"?"ArrowLeft":"ArrowRight",backward=this.effectiveDirection==="rtl"?"ArrowRight":"ArrowLeft";if(event.key==="Enter"||event.key===" ")event.preventDefault(),this.navigationIndex=index,this.goTo(index);else if(event.key==="ArrowDown"||event.key===forward)event.preventDefault(),this.moveNavigation(index,1);else if(event.key==="ArrowUp"||event.key===backward)event.preventDefault(),this.moveNavigation(index,-1);else if(event.key==="Home"){event.preventDefault();const first=this.enabledIndices()[0];first!==void 0&&this.focusItem(first)}else if(event.key==="End"){event.preventDefault();const enabled=this.enabledIndices(),last=enabled[enabled.length-1];last!==void 0&&this.focusItem(last)}}itemTitle(value,index){const title=typeof value=="string"?value.trim():"";if(title)return title;const position=getNumberFormat(this.effectiveLocale).format(index+1);return this.localize("videoPlaylistUntitled",void 0,{position})}renderItem(item,index,current,disabled){const title=this.itemTitle(item.title,index),poster=safeMediaSrc(typeof item.poster=="string"?item.poster:""),duration=finiteRange(typeof item.duration=="number"?item.duration:0,0,0),durationId=`playlist-duration-${index}`;return html`
1
+ import{__decorate}from"tslib";import{eventCollectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{formatMediaTime}from"../../../internal/media-time.js";import{LyraElement}from"../../../internal/lyra-element.js";import{hostAriaLabel}from"../../../internal/a11y.js";import{shadowFocusTarget}from"../../../internal/active-element.js";import{finiteRange}from"../../../internal/numbers.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{tag}from"../../../internal/prefix.js";import{safeMediaSrc}from"../../../internal/safe-url.js";import{styles}from"./video-playlist.styles.js";import{LYRA_DEFAULT_videoPlaylistLabel,LYRA_DEFAULT_videoPlaylistUntitled}from"../../../internal/default-strings/media.generated.js";function safeControls(value){return value==="none"||value==="standard"?value:"full"}function safeRepeat(value){return value==="one"||value==="all"?value:"none"}function sameVideos(left,right){return left.length===right.length&&left.every((video,index)=>video===right[index])}function sourceSnapshot(src,type,media){return{src,type,media}}function trackSnapshot(src,kind,srclang,label,isDefault){return{src,kind,srclang,label,default:isDefault}}class LyraVideoPlaylist extends LyraElement{constructor(){super(...arguments),this.controls="full",this.iconLibrary="system",this.withoutAutoAdvance=!1,this.repeat="none",this.items=[],this.playlistVideos=[],this.liveChildrenReady=!1,this.activeIndex=-1,this.navigationIndex=-1,this.listeners=new Map,this.lastKnownPlaying=new WeakMap,this.nativeVideos=new WeakMap,this.needsReload=new WeakSet,this.ownedVideoState=new WeakMap,this.preferences={},this.activationGeneration=0,this.reconcileGeneration=0,this.onSlotChange=()=>this.reconcileChildren(),this.onItemFocus=event=>{relayNativeEvent(this,event)},this.onItemBlur=event=>{relayNativeEvent(this,event)}}static{this.defaultStrings={...super.defaultStrings,videoPlaylistLabel:LYRA_DEFAULT_videoPlaylistLabel,videoPlaylistUntitled:LYRA_DEFAULT_videoPlaylistUntitled}}static{this.collectionSupport=eventCollectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-video-change"])}static{this.styles=[LyraElement.styles,styles]}connectedCallback(){super.connectedCallback(),this.observeChildren(),this.hasUpdated?this.scheduleAfterUpdate(()=>this.reconcileChildren(),"video-playlist-reconcile"):this.seedFirstRenderState(()=>{this.directVideos().length>0&&this.reconcileChildren()})}disconnectedCallback(){this.activationGeneration+=1,this.reconcileGeneration+=1,this.pendingPlay=void 0,this.mutationObserver?.disconnect(),this.mutationObserver=void 0;for(const video of this.playlistVideos)this.unbindVideo(video),video.hidden=!0,this.pauseAndUnload(video);super.disconnectedCallback()}willUpdate(changed){super.willUpdate(changed),changed.has("controls")&&(this.controls=safeControls(this.controls)),changed.has("repeat")&&(this.repeat=safeRepeat(this.repeat)),(changed.has("controls")||changed.has("iconLibrary"))&&this.scheduleAfterUpdate(()=>this.reconcileChildren(),"video-playlist-reconcile")}observeChildren(){this.mutationObserver?.disconnect(),this.mutationObserver=void 0;const MutationObserverCtor=this.ownerDocument.defaultView?.MutationObserver;MutationObserverCtor&&(this.mutationObserver=new MutationObserverCtor(()=>{this.scheduleAfterUpdate(()=>{this.reconcileChildren(),this.requestUpdate()},"video-playlist-reconcile")}),this.mutationObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["default","inert","kind","label","media","poster","src","srclang","title","type"]}))}directVideos(){const videoTag=tag("video");return[...this.children].filter(child=>child.localName===videoTag)}isEnabled(video){return!video.inert}nearestEnabledIndex(videos,preferred){if(!videos.length)return-1;const start=Math.min(Math.max(preferred,0),videos.length-1);for(let index=start;index<videos.length;index+=1)if(this.isEnabled(videos[index]))return index;for(let index=start-1;index>=0;index-=1)if(this.isEnabled(videos[index]))return index;return-1}reconcileChildren(){if(!this.isConnected)return;const previousVideos=this.playlistVideos,previousActive=this.activeVideo,previousIndex=this.activeIndex,previousNavigation=previousVideos[this.navigationIndex],navigationHadFocus=shadowFocusTarget(this)?.getAttribute("part")==="playlist-item",videos=this.directVideos();(videos.length>0||this.liveChildrenReady)&&(this.liveChildrenReady=!0);let active=previousActive&&videos.includes(previousActive)&&this.isEnabled(previousActive)?previousActive:void 0,nextIndex=active?videos.indexOf(active):this.nearestEnabledIndex(videos,previousIndex);!active&&nextIndex>=0&&(active=videos[nextIndex]),active||(nextIndex=-1);const activeChanged=active!==previousActive,outgoingWasRemoved=!!(previousActive&&!videos.includes(previousActive)),resumePlayback=activeChanged&&previousActive?outgoingWasRemoved?this.lastKnownPlaying.get(previousActive)??previousActive.getState().playing:previousActive.getState().playing:!1,outgoingPreferences=activeChanged&&previousActive?outgoingWasRemoved?this.capturePreferences(previousActive,this.nativeVideos.get(previousActive)):this.capturePreferences(previousActive):void 0;for(const video of previousVideos)videos.includes(video)||this.releaseVideo(video);for(const video of videos)this.claimVideo(video),this.bindVideo(video);activeChanged&&previousActive?(this.preferences=outgoingPreferences??{},outgoingWasRemoved||this.pauseAndUnload(previousActive),this.activationGeneration+=1):activeChanged&&(this.activationGeneration+=1),this.activeVideo=active,this.activeIndex=nextIndex,sameVideos(previousVideos,videos)||(this.playlistVideos=videos);for(const video of videos){video.controls!==this.controls&&(video.controls=this.controls),video.iconLibrary!==this.iconLibrary&&(video.iconLibrary=this.iconLibrary);const isActive=video===active;video.hidden=!isActive,isActive||this.pauseAndUnload(video)}active?(activeChanged||this.needsReload.has(active))&&this.activateVideo(active,resumePlayback,this.activationGeneration):this.pendingPlay=void 0;const keptNavigation=previousNavigation&&videos.includes(previousNavigation)&&this.isEnabled(previousNavigation)?videos.indexOf(previousNavigation):-1;this.navigationIndex=keptNavigation>=0?keptNavigation:nextIndex,navigationHadFocus&&keptNavigation<0&&this.navigationIndex>=0&&this.focusItem(this.navigationIndex),activeChanged&&previousActive&&this.emitChange(previousIndex,nextIndex,active??null),this.scheduleChildrenReady(videos)}scheduleChildrenReady(videos){const reconcileGeneration=++this.reconcileGeneration;Promise.all(videos.map(video=>video.updateComplete)).then(()=>{if(!this.isConnected||reconcileGeneration!==this.reconcileGeneration)return;for(const video of this.playlistVideos)this.rememberNativeVideo(video);for(const video of this.playlistVideos)video!==this.activeVideo&&this.pauseAndUnload(video);const active=this.activeVideo;if(!active||!this.needsReload.has(active))return;const shouldPlay=this.pendingPlay?.video===active&&this.pendingPlay.generation===this.activationGeneration;this.activateVideo(active,shouldPlay,this.activationGeneration)})}bindVideo(video){if(this.listeners.has(video))return;const listeners={ended:()=>{this.rememberNativeVideo(video),this.lastKnownPlaying.set(video,!1),this.handleCompletion(video)},error:()=>{this.rememberNativeVideo(video),this.lastKnownPlaying.set(video,!1)},loadedmetadata:()=>{this.rememberNativeVideo(video),this.handleLoadedMetadata(video)},pause:()=>{this.rememberNativeVideo(video),this.lastKnownPlaying.set(video,!1)},play:()=>{this.rememberNativeVideo(video),this.lastKnownPlaying.set(video,!0),video!==this.activeVideo&&this.pauseAndUnload(video)}};this.lastKnownPlaying.set(video,video.getState().playing),this.rememberNativeVideo(video),this.listeners.set(video,listeners),video.addEventListener("ended",listeners.ended),video.addEventListener("error",listeners.error),video.addEventListener("loadedmetadata",listeners.loadedmetadata),video.addEventListener("pause",listeners.pause),video.addEventListener("play",listeners.play)}unbindVideo(video){const listeners=this.listeners.get(video);listeners&&(video.removeEventListener("ended",listeners.ended),video.removeEventListener("error",listeners.error),video.removeEventListener("loadedmetadata",listeners.loadedmetadata),video.removeEventListener("pause",listeners.pause),video.removeEventListener("play",listeners.play),this.listeners.delete(video))}claimVideo(video){this.ownedVideoState.has(video)||this.ownedVideoState.set(video,{controls:video.controls,iconLibrary:video.iconLibrary,hidden:!!video.hidden})}releaseVideo(video){const authored=this.ownedVideoState.get(video);this.unbindVideo(video),this.pauseAndUnload(video),authored&&(video.controls=authored.controls,video.iconLibrary=authored.iconLibrary,video.hidden=authored.hidden,this.ownedVideoState.delete(video),video.isConnected&&video.load())}rememberNativeVideo(video){const native=video.getVideoElement();native&&this.nativeVideos.set(video,native)}pauseAndUnload(video){video.pause(),video.hidden=!0,this.needsReload.add(video),video.unloadMedia()}activateVideo(video,shouldPlay,generation){if(video.hidden=!1,!video.getVideoElement()){this.needsReload.add(video),shouldPlay&&(this.pendingPlay={video,generation});return}if(this.rememberNativeVideo(video),video.load(),this.needsReload.delete(video),this.applyPreferences(video,this.preferences),!shouldPlay){this.pendingPlay?.video===video&&(this.pendingPlay=void 0);return}this.pendingPlay=void 0,video.play().catch(()=>{generation!==this.activationGeneration||this.activeVideo})}capturePreferences(video,native=video.getVideoElement()){return video.captureMediaPreferences(native)}applyPreferences(video,preferences){video.applyMediaPreferences(preferences)}handleLoadedMetadata(video){video===this.activeVideo&&(this.applyPreferences(video,this.preferences),this.requestUpdate())}handleCompletion(video){if(video!==this.activeVideo||this.withoutAutoAdvance)return;if(this.repeat==="one"){video.seek(0);const generation=this.activationGeneration;video.play().catch(()=>{generation!==this.activationGeneration||this.activeVideo});return}const nextIndex=this.nearestEnabledIndex(this.playlistVideos,this.activeIndex+1);if(nextIndex>this.activeIndex){this.switchTo(nextIndex,!0);return}if(this.repeat==="all"){const first=this.nearestEnabledIndex(this.playlistVideos,0);if(first>=0&&first!==this.activeIndex)this.switchTo(first,!0);else if(first===this.activeIndex){video.seek(0);const generation=this.activationGeneration;video.play().catch(()=>{generation!==this.activationGeneration||this.activeVideo})}}}snapshotVideo(video){const sources=[],directSrc=video.src.trim();directSrc&&sources.push(sourceSnapshot(directSrc,"",""));const tracks=[];for(const child of video.children)if(child.localName==="source"){const src=child.getAttribute("src")?.trim()??"";src&&sources.push(sourceSnapshot(src,child.getAttribute("type")??"",child.getAttribute("media")??""))}else if(child.localName==="track"){const src=child.getAttribute("src")?.trim()??"";src&&tracks.push(trackSnapshot(src,child.getAttribute("kind")??"",child.getAttribute("srclang")??"",child.getAttribute("label")??"",child.hasAttribute("default")))}return{title:video.title,poster:video.poster,sources,tracks}}emitChange(previousIndex,currentIndex,video){this.emit("lr-video-change",{previousIndex,currentIndex,video:video?this.snapshotVideo(video):null})}switchTo(index,forcePlay=!1){const incoming=this.playlistVideos[index];if(!incoming||!this.isEnabled(incoming))return;const previousIndex=this.activeIndex,outgoing=this.activeVideo;if(incoming===outgoing){if(this.navigationIndex=index,this.requestUpdate(),forcePlay){const generation=this.activationGeneration;incoming.play().catch(()=>{generation!==this.activationGeneration||this.activeVideo})}this.emitChange(previousIndex,index,incoming);return}const wasPlaying=forcePlay||!!outgoing?.getState().playing;outgoing&&(this.preferences=this.capturePreferences(outgoing),this.pauseAndUnload(outgoing)),this.activationGeneration+=1,this.activeVideo=incoming,this.activeIndex=index,this.navigationIndex=index;for(const video of this.playlistVideos){const isActive=video===incoming;video.hidden=!isActive,!isActive&&video!==outgoing&&this.pauseAndUnload(video)}this.activateVideo(incoming,wasPlaying,this.activationGeneration),this.requestUpdate(),this.emitChange(previousIndex,index,incoming)}goTo(index){!Number.isFinite(index)||!Number.isInteger(index)||index<0||index>=this.playlistVideos.length||this.switchTo(index)}next(){const index=this.nearestEnabledIndex(this.playlistVideos,this.activeIndex+1);index>this.activeIndex&&this.switchTo(index)}previous(){for(let index=this.activeIndex-1;index>=0;index-=1)if(this.isEnabled(this.playlistVideos[index])){this.switchTo(index);return}}onItemClick(event){const button=event.currentTarget,index=Number(button.dataset.index);Number.isInteger(index)&&(this.navigationIndex=index,this.goTo(index))}enabledIndices(){const result=[];for(let index=0;index<this.playlistVideos.length;index+=1)this.isEnabled(this.playlistVideos[index])&&result.push(index);return result}moveNavigation(from,direction){const enabled=this.enabledIndices(),position=enabled.indexOf(from);if(position<0)return;const next=enabled[position+direction];next!==void 0&&this.focusItem(next)}get navigationItem(){const rows=[...this.renderRoot.querySelectorAll('[part~="playlist-item"]')];return rows.find(row=>!row.disabled&&row.getAttribute("aria-current")==="true")??rows.find(row=>!row.disabled)??null}focus(options){this.navigationItem?.focus(options)}blur(){this.navigationItem?.blur()}click(){this.navigationItem?.click()}focusItem(index){this.isEnabled(this.playlistVideos[index])&&(this.navigationIndex=index,this.requestUpdate(),this.updateComplete.then(()=>{this.navigationIndex===index&&this.shadowRoot?.querySelector(`[data-index="${index}"]`)?.focus()}))}onItemKeyDown(event){const button=event.currentTarget,index=Number(button.dataset.index);if(!Number.isInteger(index)||button.disabled)return;const forward=this.effectiveDirection==="rtl"?"ArrowLeft":"ArrowRight",backward=this.effectiveDirection==="rtl"?"ArrowRight":"ArrowLeft";if(event.key==="Enter"||event.key===" ")event.preventDefault(),this.navigationIndex=index,this.goTo(index);else if(event.key==="ArrowDown"||event.key===forward)event.preventDefault(),this.moveNavigation(index,1);else if(event.key==="ArrowUp"||event.key===backward)event.preventDefault(),this.moveNavigation(index,-1);else if(event.key==="Home"){event.preventDefault();const first=this.enabledIndices()[0];first!==void 0&&this.focusItem(first)}else if(event.key==="End"){event.preventDefault();const enabled=this.enabledIndices(),last=enabled[enabled.length-1];last!==void 0&&this.focusItem(last)}}itemTitle(value,index){const title=typeof value=="string"?value.trim():"";if(title)return title;const position=getNumberFormat(this.effectiveLocale).format(index+1);return this.localize("videoPlaylistUntitled",void 0,{position})}renderItem(item,index,current,disabled){const title=this.itemTitle(item.title,index),poster=safeMediaSrc(typeof item.poster=="string"?item.poster:""),duration=finiteRange(typeof item.duration=="number"?item.duration:0,0,0),durationId=`playlist-duration-${index}`;return html`
2
2
  <li>
3
3
  <button
4
4
  type="button"
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{html,nothing}from"lit";import{property}from"lit/decorators.js";import{keyed}from"lit/directives/keyed.js";import{activeElementIn,shadowFocusTarget}from"../../../internal/active-element.js";import{hostAriaLabel}from"../../../internal/a11y.js";import{LyraElement}from"../../../internal/lyra-element.js";import{HostDescriptionController}from"../../../internal/aria-controls.js";import{finiteRange}from"../../../internal/numbers.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{safeDownloadHref}from"../../../internal/safe-url.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{styles}from"./zoomable-frame.styles.js";import{LYRA_DEFAULT_zoomControls,LYRA_DEFAULT_zoomIn,LYRA_DEFAULT_zoomOut,LYRA_DEFAULT_zoomableFrameLabel}from"../../../internal/default-strings.generated.js";const focusBoundaryHubs=new WeakMap;function joinFocusBoundaryHub(doc,member){let hub=focusBoundaryHubs.get(doc);if(!hub){const members=new Set,view=doc.defaultView,onEvent=event=>{for(const m of[...members])m.onOwnerFocusBoundary(event)};doc.addEventListener("focusin",onEvent,!0),doc.addEventListener("focusout",onEvent,!0),doc.addEventListener("keydown",onEvent,!0),view?.addEventListener("focus",onEvent),view?.addEventListener("blur",onEvent),hub={members,dispose:()=>{doc.removeEventListener("focusin",onEvent,!0),doc.removeEventListener("focusout",onEvent,!0),doc.removeEventListener("keydown",onEvent,!0),view?.removeEventListener("focus",onEvent),view?.removeEventListener("blur",onEvent)}},focusBoundaryHubs.set(doc,hub)}hub.members.add(member);const joined=hub;return()=>{joined.members.delete(member),!joined.members.size&&focusBoundaryHubs.get(doc)===joined&&(joined.dispose(),focusBoundaryHubs.delete(doc))}}const DEFAULT_ZOOM_LEVELS="25% 50% 75% 100% 125% 150% 175% 200%",DEFAULT_IFRAME_SANDBOX="allow-same-origin",DEFAULT_ZOOM_LEVEL_VALUES=[.25,.5,.75,1,1.25,1.5,1.75,2],MIN_ZOOM=.01,MAX_ZOOM=1e3,MAX_ZOOM_LEVEL_SOURCE_CODE_UNITS=16384,MAX_ZOOM_LEVEL_TOKENS=256,SANDBOX_TOKENS=new Set(["allow-downloads","allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-storage-access-by-user-activation","allow-top-navigation","allow-top-navigation-by-user-activation","allow-top-navigation-to-custom-protocols"]),REFERRER_POLICIES=new Set(["no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"]),THEME_ATTRIBUTES=["data-lr-theme","data-theme","data-color-scheme"];function isLyraThemeClass(value){return value==="lr-light"||value==="lr-dark"||value.startsWith("lr-theme-")||value.startsWith("lr-brand-")||value.startsWith("lr-palette-")}function safeZoomableFrameSrc(value){return typeof value=="string"&&value.trim().toLowerCase()==="about:blank"?value.trim():safeDownloadHref(value)}function safeZoomableFrameSandbox(value){if(typeof value!="string")return"";const tokens=[...new Set(value.toLowerCase().split(/\s+/).filter(token=>SANDBOX_TOKENS.has(token)))];return tokens.includes("allow-scripts")&&tokens.includes("allow-same-origin")?tokens.filter(token=>token!=="allow-same-origin").join(" "):tokens.join(" ")}function safeLoading(value){return value==="lazy"?"lazy":"eager"}function safeReferrerPolicy(value){return value===""||value==null?null:typeof value=="string"&&REFERRER_POLICIES.has(value)?value:"no-referrer"}function parseZoomLevels(value){if(typeof value!="string")return DEFAULT_ZOOM_LEVEL_VALUES;const source=value.slice(0,MAX_ZOOM_LEVEL_SOURCE_CODE_UNITS),finalTokenContinues=value.length>MAX_ZOOM_LEVEL_SOURCE_CODE_UNITS&&/\S/u.test(source.at(-1)??"")&&/\S/u.test(value[MAX_ZOOM_LEVEL_SOURCE_CODE_UNITS]??""),tokenPattern=/\S+/g,unique=new Set;let tokenCount=0,match;for(;tokenCount<MAX_ZOOM_LEVEL_TOKENS&&(match=tokenPattern.exec(source))!==null&&!(finalTokenContinues&&tokenPattern.lastIndex===source.length);){tokenCount+=1;const token=match[0],percent=token.endsWith("%"),parsed=Number(percent?token.slice(0,-1):token),level=percent?parsed/100:parsed;Number.isFinite(level)&&level>=MIN_ZOOM&&level<=MAX_ZOOM&&unique.add(level)}return unique.size===0?DEFAULT_ZOOM_LEVEL_VALUES:Object.freeze([...unique].sort((left,right)=>left-right))}class LyraZoomableFrame extends LyraElement{constructor(){super(...arguments),this.hostDescription=new HostDescriptionController(this,()=>this.renderRoot.querySelector('[part="iframe"]')),this.src="",this.srcdoc="",this.allowfullscreen=!1,this.loading="eager",this.referrerpolicy="",this.sandbox=DEFAULT_IFRAME_SANDBOX,this.zoom=1,this.zoomLevels=DEFAULT_ZOOM_LEVELS,this.withoutControls=!1,this.withoutInteraction=!1,this.withThemeSync=!1,this.accessibleLabel=null,this.cachedZoomLevelsSource=Symbol("uncached zoom levels"),this.cachedZoomLevels=DEFAULT_ZOOM_LEVEL_VALUES,this.hasEmittedFocus=!1,this.onFrameFocus=event=>{event.stopPropagation(),this.frameOwnsFocus(event.currentTarget)&&this.emitHostFocus(event)},this.onFrameBlur=event=>{event.stopPropagation(),!this.frameOwnsFocus(event.currentTarget)&&this.emitHostBlur(event)},this.focusReconciliationGeneration=0,this.scheduleFrameFocusReconciliation=()=>{const view=this.ownerDocument.defaultView;if(!view)return;const generation=++this.focusReconciliationGeneration;view.setTimeout(()=>{generation!==this.focusReconciliationGeneration||!this.isConnected||(this.frameOwnsFocus()?this.emitHostFocus():this.emitHostBlur(void 0,activeElementIn(this.ownerDocument)))},0)},this.onFocusBoundaryKeyDown=event=>{event.key==="Tab"&&this.scheduleFrameFocusReconciliation()},this.navigationGeneration=0,this.needsReconnectFrame=!1,this.syncedThemeClasses=new Set,this.syncedThemeProperties=new Set,this.onControlsKeyDown=event=>{event.altKey||event.ctrlKey||event.metaKey||(event.key==="+"||event.key==="="?(event.preventDefault(),this.zoomIn()):(event.key==="-"||event.key==="_")&&(event.preventDefault(),this.zoomOut()))}}static{this.defaultStrings={...super.defaultStrings,zoomControls:LYRA_DEFAULT_zoomControls,zoomIn:LYRA_DEFAULT_zoomIn,zoomOut:LYRA_DEFAULT_zoomOut,zoomableFrameLabel:LYRA_DEFAULT_zoomableFrameLabel}}static{this.styles=[LyraElement.styles,styles]}adoptedCallback(){super.adoptedCallback(),this.hostDescription.adopted()}get iframe(){return this.renderRoot?.querySelector("iframe")??void 0}focus(options){const frame=this.iframe;if(!frame||!this.isConnected||this.withoutInteraction||frame.inert)return;const previous=activeElementIn(this.ownerDocument),wasFocused=this.frameOwnsFocus(frame);frame.focus(options),!wasFocused&&this.frameOwnsFocus(frame)&&this.emitHostFocus(void 0,previous)}releaseFrameFocus(frame){if(frame&&(frame.blur(),!!this.frameIsActive(frame))){try{frame.contentWindow?.blur()}catch{}frame.blur()}}blur(){const frame=this.iframe;!frame||!this.frameOwnsFocus(frame)||(this.releaseFrameFocus(frame),this.frameOwnsFocus(frame)||this.emitHostBlur(void 0,activeElementIn(this.ownerDocument)))}click(){this.isConnected&&!this.withoutInteraction&&!this.iframe?.inert&&this.iframe?.click()}frameIsActive(frame=this.iframe){return!!(frame&&this.isConnected&&shadowFocusTarget(this)===frame)}frameOwnsFocus(frame=this.iframe){return!!(frame&&!frame.inert&&!this.withoutInteraction&&this.frameIsActive(frame))}setFrameFocused(focused){this.toggleAttribute("data-frame-focused",focused)}dispatchHostFocusEvent(type,source,relatedTarget=null){const view=this.ownerDocument.defaultView;if(!view)return;const related=source?.relatedTarget??relatedTarget,relatedNode=related,internalRelated=related===this||relatedNode?.nodeType!==void 0&&this.shadowRoot?.contains(relatedNode),nativeSource=new view.FocusEvent(type,{relatedTarget:internalRelated?null:related,view,detail:source?.detail??0});relayNativeEvent(this,nativeSource)}emitHostFocus(source,relatedTarget=null){this.hasEmittedFocus||(this.hasEmittedFocus=!0,this.setFrameFocused(!0),this.dispatchHostFocusEvent("focus",source,relatedTarget))}emitHostBlur(source,relatedTarget=null){this.hasEmittedFocus&&(this.hasEmittedFocus=!1,this.setFrameFocused(!1),this.dispatchHostFocusEvent("blur",source,relatedTarget))}onOwnerFocusBoundary(event){event.type==="keydown"?this.onFocusBoundaryKeyDown(event):(this.hasEmittedFocus||this.frameOwnsFocus())&&this.scheduleFrameFocusReconciliation()}resetFocusBoundaryDocument(){this.focusBoundaryDocument?.removeEventListener("keydown",this.onFocusBoundaryKeyDown,!0),this.focusBoundaryDocument?.removeEventListener("pointerdown",this.scheduleFrameFocusReconciliation,!0),this.focusBoundaryDocument=void 0}bindFocusBoundaryDocument(){let target=null;try{target=this.contentDocument}catch{}!target||target===this.focusBoundaryDocument||(this.resetFocusBoundaryDocument(),this.focusBoundaryDocument=target,target.addEventListener("keydown",this.onFocusBoundaryKeyDown,!0),target.addEventListener("pointerdown",this.scheduleFrameFocusReconciliation,!0))}connectedCallback(){super.connectedCallback(),this.leaveFocusBoundaryHub?.(),this.leaveFocusBoundaryHub=joinFocusBoundaryHub(this.ownerDocument,this),this.needsReconnectFrame&&(this.needsReconnectFrame=!1,this.requestUpdate())}disconnectedCallback(){this.focusReconciliationGeneration++,this.leaveFocusBoundaryHub?.(),this.leaveFocusBoundaryHub=void 0,this.navigationGeneration++,this.needsReconnectFrame=!0,this.hasEmittedFocus=!1,this.setFrameFocused(!1),this.resetFocusBoundaryDocument(),this.resetThemeSyncState(),super.disconnectedCallback()}attributeChangedCallback(name,oldValue,value){super.attributeChangedCallback(name,oldValue,value),name==="srcdoc"&&oldValue===null!=(value===null)&&(this.navigationGeneration++,this.requestUpdate())}willUpdate(changed){if(super.willUpdate(changed),changed.has("src")||changed.has("srcdoc")||changed.has("allowfullscreen")||changed.has("loading")||changed.has("referrerpolicy")||changed.has("sandbox")){const frame=this.iframe,wasFocused=this.frameIsActive(frame);this.releaseFrameFocus(frame),wasFocused&&!this.frameIsActive(frame)&&this.emitHostBlur(void 0,activeElementIn(this.ownerDocument)),this.setFrameFocused(!1),this.resetFocusBoundaryDocument(),this.navigationGeneration++}if(changed.has("withoutInteraction")&&this.withoutInteraction){const frame=this.iframe,wasFocused=this.frameIsActive(frame);this.releaseFrameFocus(frame),wasFocused&&this.emitHostBlur(void 0,activeElementIn(this.ownerDocument)),this.setFrameFocused(!1)}}updated(changed){super.updated(changed),changed.has("withThemeSync")&&(this.withThemeSync?(this.themeWatcher??=new ThemeWatcher(this,()=>this.syncTheme()),this.syncTheme()):(this.themeWatcher&&(this.themeWatcher.hostDisconnected(),this.removeController(this.themeWatcher),this.themeWatcher=void 0),this.restoreTheme()))}get contentWindow(){return this.isConnected?this.iframe?.contentWindow??null:null}get contentDocument(){if(!this.isConnected)return null;try{return this.iframe?.contentDocument??null}catch{return null}}get safeZoom(){return finiteRange(this.zoom,1,MIN_ZOOM,MAX_ZOOM)}get availableZoomLevels(){const source=this.zoomLevels;return source===this.cachedZoomLevelsSource?this.cachedZoomLevels:(this.cachedZoomLevelsSource=source,this.cachedZoomLevels=parseZoomLevels(source),this.cachedZoomLevels)}get hasInlineDocument(){return this.hasAttribute("srcdoc")||typeof this.srcdoc=="string"&&this.srcdoc!==""}get hasNavigation(){return this.hasInlineDocument||safeZoomableFrameSrc(this.src)!==null}navigationSignature(){const inline=this.hasInlineDocument;return JSON.stringify([inline,inline?this.srcdoc:safeZoomableFrameSrc(this.src),this.allowfullscreen,safeLoading(this.loading),safeReferrerPolicy(this.referrerpolicy),safeZoomableFrameSandbox(this.sandbox)])}zoomIn(){const current=this.safeZoom,next=this.availableZoomLevels.find(level=>level>current);next!==void 0&&this.zoomTo(next)}zoomOut(){const current=this.safeZoom,levels=this.availableZoomLevels;for(let index=levels.length-1;index>=0;index--){const previous=levels[index];if(previous!==void 0&&previous<current){this.zoomTo(previous);return}}}zoomTo(zoom){this.zoom=zoom,this.emit("lr-zoom-change",{zoom})}isZoomInDisabled(){return!this.availableZoomLevels.some(level=>level>this.safeZoom)}isZoomOutDisabled(){return!this.availableZoomLevels.some(level=>level<this.safeZoom)}dispatchFrameEvent(type){const EventConstructor=this.ownerDocument.defaultView?.Event??Event;type==="load"?this.dispatchEvent(new EventConstructor("load",{bubbles:!1,composed:!1})):this.dispatchEvent(new EventConstructor("error",{bubbles:!1,composed:!1}))}onFrameEvent(type,source,generation,navigationSignature){source.stopPropagation(),!(!this.isConnected||!this.hasNavigation||generation!==this.navigationGeneration||navigationSignature!==this.navigationSignature()||source.currentTarget!==this.iframe)&&(type==="load"&&(this.bindFocusBoundaryDocument(),this.syncTheme()),this.dispatchFrameEvent(type))}syncTheme(){if(!this.withThemeSync||!this.isConnected)return;const target=this.contentDocument?.documentElement,source=this.ownerDocument.documentElement;if(!(!target||!source))try{const state=this.themeStateFor(target),nextClasses=new Set([...source.classList].filter(isLyraThemeClass));for(const className of this.syncedThemeClasses)nextClasses.has(className)||this.setSyncedThemeClass(state,className,!1);for(const className of nextClasses)this.setSyncedThemeClass(state,className,!0);this.syncedThemeClasses=nextClasses;for(const attribute of THEME_ATTRIBUTES){const value=source.getAttribute(attribute);this.setSyncedThemeAttribute(state,attribute,value)}const computed=this.ownerDocument.defaultView?.getComputedStyle(this);if(!computed)return;const nextProperties=new Set;for(let index=0;index<computed.length;index++){const property2=computed.item(index);property2.startsWith("--lr-theme-")&&(this.setSyncedThemeProperty(state,property2,computed.getPropertyValue(property2)),nextProperties.add(property2))}for(const property2 of this.syncedThemeProperties)nextProperties.has(property2)||this.setSyncedThemeProperty(state,property2,null);this.syncedThemeProperties=nextProperties,this.setSyncedThemeProperty(state,"color-scheme",computed.colorScheme)}catch{}}themeStateFor(target){if(this.themeSyncState?.target===target)return this.themeSyncState;this.resetThemeSyncState();const state={target,classes:new Map,attributes:new Map,properties:new Map};return this.themeSyncState=state,state}setSyncedThemeClass(state,className,present){let mutation=state.classes.get(className);mutation||(mutation={original:state.target.classList.contains(className),applied:state.target.classList.contains(className)},state.classes.set(className,mutation)),state.target.classList.toggle(className,present),mutation.applied=state.target.classList.contains(className)}setSyncedThemeAttribute(state,attribute,value){let mutation=state.attributes.get(attribute);if(!mutation){const original=state.target.getAttribute(attribute);mutation={original,applied:original},state.attributes.set(attribute,mutation)}value===null?state.target.removeAttribute(attribute):state.target.setAttribute(attribute,value),mutation.applied=state.target.getAttribute(attribute)}setSyncedThemeProperty(state,property2,value){let mutation=state.properties.get(property2);mutation||(mutation={original:state.target.style.getPropertyValue(property2),originalPriority:state.target.style.getPropertyPriority(property2),applied:state.target.style.getPropertyValue(property2),appliedPriority:state.target.style.getPropertyPriority(property2)},state.properties.set(property2,mutation)),value===null?state.target.style.removeProperty(property2):state.target.style.setProperty(property2,value),mutation.applied=state.target.style.getPropertyValue(property2),mutation.appliedPriority=state.target.style.getPropertyPriority(property2)}restoreTheme(){const state=this.themeSyncState;if(state)try{if(this.contentDocument?.documentElement!==state.target)return;for(const[className,mutation]of state.classes)state.target.classList.contains(className)===mutation.applied&&state.target.classList.toggle(className,mutation.original);for(const[attribute,mutation]of state.attributes)state.target.getAttribute(attribute)===mutation.applied&&(mutation.original===null?state.target.removeAttribute(attribute):state.target.setAttribute(attribute,mutation.original));for(const[property2,mutation]of state.properties)state.target.style.getPropertyValue(property2)!==mutation.applied||state.target.style.getPropertyPriority(property2)!==mutation.appliedPriority||(mutation.original?state.target.style.setProperty(property2,mutation.original,mutation.originalPriority):state.target.style.removeProperty(property2))}catch{}finally{this.resetThemeSyncState()}}resetThemeSyncState(){this.themeSyncState=void 0,this.syncedThemeClasses.clear(),this.syncedThemeProperties.clear()}renderControls(){return this.withoutControls?nothing:html`<div
1
+ import{__decorate}from"tslib";import{html,nothing}from"lit";import{property}from"lit/decorators.js";import{keyed}from"lit/directives/keyed.js";import{activeElementIn,shadowFocusTarget}from"../../../internal/active-element.js";import{hostAriaLabel}from"../../../internal/a11y.js";import{LyraElement}from"../../../internal/lyra-element.js";import{HostDescriptionController}from"../../../internal/aria-controls.js";import{finiteRange}from"../../../internal/numbers.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{safeDownloadHref}from"../../../internal/safe-url.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{styles}from"./zoomable-frame.styles.js";import{LYRA_DEFAULT_zoomControls,LYRA_DEFAULT_zoomableFrameLabel}from"../../../internal/default-strings/media.generated.js";import{LYRA_DEFAULT_zoomIn,LYRA_DEFAULT_zoomOut}from"../../../internal/default-strings/shared.generated.js";const focusBoundaryHubs=new WeakMap;function joinFocusBoundaryHub(doc,member){let hub=focusBoundaryHubs.get(doc);if(!hub){const members=new Set,view=doc.defaultView,onEvent=event=>{for(const m of[...members])m.onOwnerFocusBoundary(event)};doc.addEventListener("focusin",onEvent,!0),doc.addEventListener("focusout",onEvent,!0),doc.addEventListener("keydown",onEvent,!0),view?.addEventListener("focus",onEvent),view?.addEventListener("blur",onEvent),hub={members,dispose:()=>{doc.removeEventListener("focusin",onEvent,!0),doc.removeEventListener("focusout",onEvent,!0),doc.removeEventListener("keydown",onEvent,!0),view?.removeEventListener("focus",onEvent),view?.removeEventListener("blur",onEvent)}},focusBoundaryHubs.set(doc,hub)}hub.members.add(member);const joined=hub;return()=>{joined.members.delete(member),!joined.members.size&&focusBoundaryHubs.get(doc)===joined&&(joined.dispose(),focusBoundaryHubs.delete(doc))}}const DEFAULT_ZOOM_LEVELS="25% 50% 75% 100% 125% 150% 175% 200%",DEFAULT_IFRAME_SANDBOX="allow-same-origin",DEFAULT_ZOOM_LEVEL_VALUES=[.25,.5,.75,1,1.25,1.5,1.75,2],MIN_ZOOM=.01,MAX_ZOOM=1e3,MAX_ZOOM_LEVEL_SOURCE_CODE_UNITS=16384,MAX_ZOOM_LEVEL_TOKENS=256,SANDBOX_TOKENS=new Set(["allow-downloads","allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-storage-access-by-user-activation","allow-top-navigation","allow-top-navigation-by-user-activation","allow-top-navigation-to-custom-protocols"]),REFERRER_POLICIES=new Set(["no-referrer","no-referrer-when-downgrade","origin","origin-when-cross-origin","same-origin","strict-origin","strict-origin-when-cross-origin","unsafe-url"]),THEME_ATTRIBUTES=["data-lr-theme","data-theme","data-color-scheme"];function isLyraThemeClass(value){return value==="lr-light"||value==="lr-dark"||value.startsWith("lr-theme-")||value.startsWith("lr-brand-")||value.startsWith("lr-palette-")}function safeZoomableFrameSrc(value){return typeof value=="string"&&value.trim().toLowerCase()==="about:blank"?value.trim():safeDownloadHref(value)}function safeZoomableFrameSandbox(value){if(typeof value!="string")return"";const tokens=[...new Set(value.toLowerCase().split(/\s+/).filter(token=>SANDBOX_TOKENS.has(token)))];return tokens.includes("allow-scripts")&&tokens.includes("allow-same-origin")?tokens.filter(token=>token!=="allow-same-origin").join(" "):tokens.join(" ")}function safeLoading(value){return value==="lazy"?"lazy":"eager"}function safeReferrerPolicy(value){return value===""||value==null?null:typeof value=="string"&&REFERRER_POLICIES.has(value)?value:"no-referrer"}function parseZoomLevels(value){if(typeof value!="string")return DEFAULT_ZOOM_LEVEL_VALUES;const source=value.slice(0,MAX_ZOOM_LEVEL_SOURCE_CODE_UNITS),finalTokenContinues=value.length>MAX_ZOOM_LEVEL_SOURCE_CODE_UNITS&&/\S/u.test(source.at(-1)??"")&&/\S/u.test(value[MAX_ZOOM_LEVEL_SOURCE_CODE_UNITS]??""),tokenPattern=/\S+/g,unique=new Set;let tokenCount=0,match;for(;tokenCount<MAX_ZOOM_LEVEL_TOKENS&&(match=tokenPattern.exec(source))!==null&&!(finalTokenContinues&&tokenPattern.lastIndex===source.length);){tokenCount+=1;const token=match[0],percent=token.endsWith("%"),parsed=Number(percent?token.slice(0,-1):token),level=percent?parsed/100:parsed;Number.isFinite(level)&&level>=MIN_ZOOM&&level<=MAX_ZOOM&&unique.add(level)}return unique.size===0?DEFAULT_ZOOM_LEVEL_VALUES:Object.freeze([...unique].sort((left,right)=>left-right))}class LyraZoomableFrame extends LyraElement{constructor(){super(...arguments),this.hostDescription=new HostDescriptionController(this,()=>this.renderRoot.querySelector('[part="iframe"]')),this.src="",this.srcdoc="",this.allowfullscreen=!1,this.loading="eager",this.referrerpolicy="",this.sandbox=DEFAULT_IFRAME_SANDBOX,this.zoom=1,this.zoomLevels=DEFAULT_ZOOM_LEVELS,this.withoutControls=!1,this.withoutInteraction=!1,this.withThemeSync=!1,this.accessibleLabel=null,this.cachedZoomLevelsSource=Symbol("uncached zoom levels"),this.cachedZoomLevels=DEFAULT_ZOOM_LEVEL_VALUES,this.hasEmittedFocus=!1,this.onFrameFocus=event=>{event.stopPropagation(),this.frameOwnsFocus(event.currentTarget)&&this.emitHostFocus(event)},this.onFrameBlur=event=>{event.stopPropagation(),!this.frameOwnsFocus(event.currentTarget)&&this.emitHostBlur(event)},this.focusReconciliationGeneration=0,this.scheduleFrameFocusReconciliation=()=>{const view=this.ownerDocument.defaultView;if(!view)return;const generation=++this.focusReconciliationGeneration;view.setTimeout(()=>{generation!==this.focusReconciliationGeneration||!this.isConnected||(this.frameOwnsFocus()?this.emitHostFocus():this.emitHostBlur(void 0,activeElementIn(this.ownerDocument)))},0)},this.onFocusBoundaryKeyDown=event=>{event.key==="Tab"&&this.scheduleFrameFocusReconciliation()},this.navigationGeneration=0,this.needsReconnectFrame=!1,this.syncedThemeClasses=new Set,this.syncedThemeProperties=new Set,this.onControlsKeyDown=event=>{event.altKey||event.ctrlKey||event.metaKey||(event.key==="+"||event.key==="="?(event.preventDefault(),this.zoomIn()):(event.key==="-"||event.key==="_")&&(event.preventDefault(),this.zoomOut()))}}static{this.defaultStrings={...super.defaultStrings,zoomControls:LYRA_DEFAULT_zoomControls,zoomIn:LYRA_DEFAULT_zoomIn,zoomOut:LYRA_DEFAULT_zoomOut,zoomableFrameLabel:LYRA_DEFAULT_zoomableFrameLabel}}static{this.styles=[LyraElement.styles,styles]}adoptedCallback(){super.adoptedCallback(),this.hostDescription.adopted()}get iframe(){return this.renderRoot?.querySelector("iframe")??void 0}focus(options){const frame=this.iframe;if(!frame||!this.isConnected||this.withoutInteraction||frame.inert)return;const previous=activeElementIn(this.ownerDocument),wasFocused=this.frameOwnsFocus(frame);frame.focus(options),!wasFocused&&this.frameOwnsFocus(frame)&&this.emitHostFocus(void 0,previous)}releaseFrameFocus(frame){if(frame&&(frame.blur(),!!this.frameIsActive(frame))){try{frame.contentWindow?.blur()}catch{}frame.blur()}}blur(){const frame=this.iframe;!frame||!this.frameOwnsFocus(frame)||(this.releaseFrameFocus(frame),this.frameOwnsFocus(frame)||this.emitHostBlur(void 0,activeElementIn(this.ownerDocument)))}click(){this.isConnected&&!this.withoutInteraction&&!this.iframe?.inert&&this.iframe?.click()}frameIsActive(frame=this.iframe){return!!(frame&&this.isConnected&&shadowFocusTarget(this)===frame)}frameOwnsFocus(frame=this.iframe){return!!(frame&&!frame.inert&&!this.withoutInteraction&&this.frameIsActive(frame))}setFrameFocused(focused){this.toggleAttribute("data-frame-focused",focused)}dispatchHostFocusEvent(type,source,relatedTarget=null){const view=this.ownerDocument.defaultView;if(!view)return;const related=source?.relatedTarget??relatedTarget,relatedNode=related,internalRelated=related===this||relatedNode?.nodeType!==void 0&&this.shadowRoot?.contains(relatedNode),nativeSource=new view.FocusEvent(type,{relatedTarget:internalRelated?null:related,view,detail:source?.detail??0});relayNativeEvent(this,nativeSource)}emitHostFocus(source,relatedTarget=null){this.hasEmittedFocus||(this.hasEmittedFocus=!0,this.setFrameFocused(!0),this.dispatchHostFocusEvent("focus",source,relatedTarget))}emitHostBlur(source,relatedTarget=null){this.hasEmittedFocus&&(this.hasEmittedFocus=!1,this.setFrameFocused(!1),this.dispatchHostFocusEvent("blur",source,relatedTarget))}onOwnerFocusBoundary(event){event.type==="keydown"?this.onFocusBoundaryKeyDown(event):(this.hasEmittedFocus||this.frameOwnsFocus())&&this.scheduleFrameFocusReconciliation()}resetFocusBoundaryDocument(){this.focusBoundaryDocument?.removeEventListener("keydown",this.onFocusBoundaryKeyDown,!0),this.focusBoundaryDocument?.removeEventListener("pointerdown",this.scheduleFrameFocusReconciliation,!0),this.focusBoundaryDocument=void 0}bindFocusBoundaryDocument(){let target=null;try{target=this.contentDocument}catch{}!target||target===this.focusBoundaryDocument||(this.resetFocusBoundaryDocument(),this.focusBoundaryDocument=target,target.addEventListener("keydown",this.onFocusBoundaryKeyDown,!0),target.addEventListener("pointerdown",this.scheduleFrameFocusReconciliation,!0))}connectedCallback(){super.connectedCallback(),this.leaveFocusBoundaryHub?.(),this.leaveFocusBoundaryHub=joinFocusBoundaryHub(this.ownerDocument,this),this.needsReconnectFrame&&(this.needsReconnectFrame=!1,this.requestUpdate())}disconnectedCallback(){this.focusReconciliationGeneration++,this.leaveFocusBoundaryHub?.(),this.leaveFocusBoundaryHub=void 0,this.navigationGeneration++,this.needsReconnectFrame=!0,this.hasEmittedFocus=!1,this.setFrameFocused(!1),this.resetFocusBoundaryDocument(),this.resetThemeSyncState(),super.disconnectedCallback()}attributeChangedCallback(name,oldValue,value){super.attributeChangedCallback(name,oldValue,value),name==="srcdoc"&&oldValue===null!=(value===null)&&(this.navigationGeneration++,this.requestUpdate())}willUpdate(changed){if(super.willUpdate(changed),changed.has("src")||changed.has("srcdoc")||changed.has("allowfullscreen")||changed.has("loading")||changed.has("referrerpolicy")||changed.has("sandbox")){const frame=this.iframe,wasFocused=this.frameIsActive(frame);this.releaseFrameFocus(frame),wasFocused&&!this.frameIsActive(frame)&&this.emitHostBlur(void 0,activeElementIn(this.ownerDocument)),this.setFrameFocused(!1),this.resetFocusBoundaryDocument(),this.navigationGeneration++}if(changed.has("withoutInteraction")&&this.withoutInteraction){const frame=this.iframe,wasFocused=this.frameIsActive(frame);this.releaseFrameFocus(frame),wasFocused&&this.emitHostBlur(void 0,activeElementIn(this.ownerDocument)),this.setFrameFocused(!1)}}updated(changed){super.updated(changed),changed.has("withThemeSync")&&(this.withThemeSync?(this.themeWatcher??=new ThemeWatcher(this,()=>this.syncTheme()),this.syncTheme()):(this.themeWatcher&&(this.themeWatcher.hostDisconnected(),this.removeController(this.themeWatcher),this.themeWatcher=void 0),this.restoreTheme()))}get contentWindow(){return this.isConnected?this.iframe?.contentWindow??null:null}get contentDocument(){if(!this.isConnected)return null;try{return this.iframe?.contentDocument??null}catch{return null}}get safeZoom(){return finiteRange(this.zoom,1,MIN_ZOOM,MAX_ZOOM)}get availableZoomLevels(){const source=this.zoomLevels;return source===this.cachedZoomLevelsSource?this.cachedZoomLevels:(this.cachedZoomLevelsSource=source,this.cachedZoomLevels=parseZoomLevels(source),this.cachedZoomLevels)}get hasInlineDocument(){return this.hasAttribute("srcdoc")||typeof this.srcdoc=="string"&&this.srcdoc!==""}get hasNavigation(){return this.hasInlineDocument||safeZoomableFrameSrc(this.src)!==null}navigationSignature(){const inline=this.hasInlineDocument;return JSON.stringify([inline,inline?this.srcdoc:safeZoomableFrameSrc(this.src),this.allowfullscreen,safeLoading(this.loading),safeReferrerPolicy(this.referrerpolicy),safeZoomableFrameSandbox(this.sandbox)])}zoomIn(){const current=this.safeZoom,next=this.availableZoomLevels.find(level=>level>current);next!==void 0&&this.zoomTo(next)}zoomOut(){const current=this.safeZoom,levels=this.availableZoomLevels;for(let index=levels.length-1;index>=0;index--){const previous=levels[index];if(previous!==void 0&&previous<current){this.zoomTo(previous);return}}}zoomTo(zoom){this.zoom=zoom,this.emit("lr-zoom-change",{zoom})}isZoomInDisabled(){return!this.availableZoomLevels.some(level=>level>this.safeZoom)}isZoomOutDisabled(){return!this.availableZoomLevels.some(level=>level<this.safeZoom)}dispatchFrameEvent(type){const EventConstructor=this.ownerDocument.defaultView?.Event??Event;type==="load"?this.dispatchEvent(new EventConstructor("load",{bubbles:!1,composed:!1})):this.dispatchEvent(new EventConstructor("error",{bubbles:!1,composed:!1}))}onFrameEvent(type,source,generation,navigationSignature){source.stopPropagation(),!(!this.isConnected||!this.hasNavigation||generation!==this.navigationGeneration||navigationSignature!==this.navigationSignature()||source.currentTarget!==this.iframe)&&(type==="load"&&(this.bindFocusBoundaryDocument(),this.syncTheme()),this.dispatchFrameEvent(type))}syncTheme(){if(!this.withThemeSync||!this.isConnected)return;const target=this.contentDocument?.documentElement,source=this.ownerDocument.documentElement;if(!(!target||!source))try{const state=this.themeStateFor(target),nextClasses=new Set([...source.classList].filter(isLyraThemeClass));for(const className of this.syncedThemeClasses)nextClasses.has(className)||this.setSyncedThemeClass(state,className,!1);for(const className of nextClasses)this.setSyncedThemeClass(state,className,!0);this.syncedThemeClasses=nextClasses;for(const attribute of THEME_ATTRIBUTES){const value=source.getAttribute(attribute);this.setSyncedThemeAttribute(state,attribute,value)}const computed=this.ownerDocument.defaultView?.getComputedStyle(this);if(!computed)return;const nextProperties=new Set;for(let index=0;index<computed.length;index++){const property2=computed.item(index);property2.startsWith("--lr-theme-")&&(this.setSyncedThemeProperty(state,property2,computed.getPropertyValue(property2)),nextProperties.add(property2))}for(const property2 of this.syncedThemeProperties)nextProperties.has(property2)||this.setSyncedThemeProperty(state,property2,null);this.syncedThemeProperties=nextProperties,this.setSyncedThemeProperty(state,"color-scheme",computed.colorScheme)}catch{}}themeStateFor(target){if(this.themeSyncState?.target===target)return this.themeSyncState;this.resetThemeSyncState();const state={target,classes:new Map,attributes:new Map,properties:new Map};return this.themeSyncState=state,state}setSyncedThemeClass(state,className,present){let mutation=state.classes.get(className);mutation||(mutation={original:state.target.classList.contains(className),applied:state.target.classList.contains(className)},state.classes.set(className,mutation)),state.target.classList.toggle(className,present),mutation.applied=state.target.classList.contains(className)}setSyncedThemeAttribute(state,attribute,value){let mutation=state.attributes.get(attribute);if(!mutation){const original=state.target.getAttribute(attribute);mutation={original,applied:original},state.attributes.set(attribute,mutation)}value===null?state.target.removeAttribute(attribute):state.target.setAttribute(attribute,value),mutation.applied=state.target.getAttribute(attribute)}setSyncedThemeProperty(state,property2,value){let mutation=state.properties.get(property2);mutation||(mutation={original:state.target.style.getPropertyValue(property2),originalPriority:state.target.style.getPropertyPriority(property2),applied:state.target.style.getPropertyValue(property2),appliedPriority:state.target.style.getPropertyPriority(property2)},state.properties.set(property2,mutation)),value===null?state.target.style.removeProperty(property2):state.target.style.setProperty(property2,value),mutation.applied=state.target.style.getPropertyValue(property2),mutation.appliedPriority=state.target.style.getPropertyPriority(property2)}restoreTheme(){const state=this.themeSyncState;if(state)try{if(this.contentDocument?.documentElement!==state.target)return;for(const[className,mutation]of state.classes)state.target.classList.contains(className)===mutation.applied&&state.target.classList.toggle(className,mutation.original);for(const[attribute,mutation]of state.attributes)state.target.getAttribute(attribute)===mutation.applied&&(mutation.original===null?state.target.removeAttribute(attribute):state.target.setAttribute(attribute,mutation.original));for(const[property2,mutation]of state.properties)state.target.style.getPropertyValue(property2)!==mutation.applied||state.target.style.getPropertyPriority(property2)!==mutation.appliedPriority||(mutation.original?state.target.style.setProperty(property2,mutation.original,mutation.originalPriority):state.target.style.removeProperty(property2))}catch{}finally{this.resetThemeSyncState()}}resetThemeSyncState(){this.themeSyncState=void 0,this.syncedThemeClasses.clear(),this.syncedThemeProperties.clear()}renderControls(){return this.withoutControls?nothing:html`<div
2
2
  part="controls"
3
3
  role="group"
4
4
  aria-label=${this.localize("zoomControls")}
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{html,nothing}from"lit";import{property}from"lit/decorators.js";import{closeIcon}from"../../../internal/icons.js";import{applyComposedFocusRepair,captureComposedFocusRepair,nearestExternalFocusTarget}from"../../../internal/focus-navigation.js";import{renderInertPresentation}from"../../../internal/inert-presentation.js";import{LyraElement}from"../../../internal/lyra-element.js";import{tag}from"../../../internal/prefix.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{finiteDuration}from"../../../internal/numbers.js";import{composedContains,deepActiveElement}from"../../../internal/overlay-manager.js";import{SlotPresenceController}from"../../../internal/slot-presence-controller.js";import{optionalLiteralSetConverter}from"../../../internal/converters.js";import{normalizeReflectedOptionalSize,optionalSizeConverter}from"../../../internal/variants.js";import{contextualSizes}from"../../../internal/contextual-vocabulary.styles.js";import{semanticVariantConverter}from"../../../internal/semantic-variant.js";import{variants}from"../../../internal/variants.styles.js";import{getToastRegion}from"../toast/toast-region.js";import{TOAST_REGION_ENQUEUE,TOAST_REGION_EVICT,TOAST_REGION_REJECT,TOAST_REGION_SET_ACTIVE,toastRegionControllerFor}from"../toast/toast-region-protocol.js";import{styles}from"./alert.styles.js";import{LYRA_DEFAULT_close}from"../../../internal/default-strings.generated.js";const ALERT_VARIANT=semanticVariantConverter("primary"),ALERT_COUNTDOWN=optionalLiteralSetConverter(["rtl","ltr"]);class LyraAlert extends LyraElement{static{this.defaultStrings={...super.defaultStrings,close:LYRA_DEFAULT_close}}static{this.styles=[LyraElement.styles,variants,contextualSizes,styles]}get open(){return this._open}set open(next){this.requestOpenState(!!next)}requestOpenState(normalized){if(normalized===this._open)return!0;if(this.openRequest)return this.openRequest.target===normalized;const repair=normalized?null:captureComposedFocusRepair(this,()=>nearestExternalFocusTarget(this));let request;if(this.hasUpdated){let resolve,reject;const completion=new Promise((resolveCompletion,rejectCompletion)=>{resolve=resolveCompletion,reject=rejectCompletion});if(request={target:normalized,completion,resolve,reject,settled:!1,cancelled:!1},this.openRequest=request,this.transitionPromise=completion,this.emit(normalized?"lr-show":"lr-hide",null,{cancelable:!0}).defaultPrevented)return this.toggleAttribute("open",this._open),this.openRequest===request&&(this.openRequest=void 0),this.cancelTransition(request),!1}this.transitionRequest&&this.cancelTransition(this.transitionRequest);const previous=this._open;return repair&&applyComposedFocusRepair(repair),this._open=normalized,this.requestUpdate("open",previous),request&&(this.openRequest===request&&(this.openRequest=void 0),this.transitionRequest=request,this.runTransition(request)),!0}get size(){return this._size}set size(next){const normalized=normalizeReflectedOptionalSize(this,next),old=this._size;old!==normalized&&(this._size=normalized,this.requestUpdate("size",old))}get countdown(){return this._countdown}set countdown(next){const normalized=ALERT_COUNTDOWN.normalizeReflected(this,"countdown",next),old=this._countdown;old!==normalized&&(this._countdown=normalized,this.requestUpdate("countdown",old))}get variant(){return this._variant}set variant(next){const normalized=ALERT_VARIANT.normalizeReflected(this,"variant",next),old=this._variant;old!==normalized&&(this._variant=normalized,this.requestUpdate("variant",old))}constructor(){super(),this.role="alert",this._open=!1,this.closable=!1,this.duration=1/0,this._variant="primary",this.slotPresence=new SlotPresenceController(this),this.transitionToken=0,this.transitionPromise=Promise.resolve(),this.hovering=!1,this.focused=!1,this.toastConnectionGeneration=0,this.toastLifecycleGeneration=0,this.toastRegionActive=!1,this.toastActivationStarted=!1,this.onPointerEnter=()=>{this.hovering=!0,this.clearAutoHide()},this.onPointerLeave=()=>{this.hovering=!1,this.focused||this.restartAutoHide()},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.clearAutoHide()},this.onFocusOut=event=>{const next=event.relatedTarget;if(!(next!==null&&next.nodeType===1&&composedContains(this,next))){if(next===null){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{const external=next;external.isConnected&&(this.focusReturnTarget=external),this.pendingFocusRepair=void 0}this.focused=!1,this.hovering||this.restartAutoHide()}},this.close=()=>{this.hide()},this.addEventListener("pointerenter",this.onPointerEnter),this.addEventListener("pointerleave",this.onPointerLeave),this.addEventListener("focusin",event=>this.onFocusIn(event)),this.addEventListener("focusout",event=>this.onFocusOut(event))}connectedCallback(){if(super.connectedCallback(),this.toastConnectionGeneration+=1,this.hasAttribute("role")||this.setAttribute("role","alert"),this.toastPromise){const currentController=toastRegionControllerFor(this);currentController&&currentController!==this.toastRegionOwner&&currentController[TOAST_REGION_ENQUEUE](this);const completion=this.toastPromise,generation=this.toastLifecycleGeneration,owner=this.toastRegionOwner;if(owner&&this.parentElement!==owner){const settleLostOwnership=()=>{this.toastPromise===completion&&this.toastLifecycleGeneration===generation&&this.parentElement!==owner&&this.finishToast()},view=this.ownerDocument.defaultView;view?view.queueMicrotask(settleLostOwnership):queueMicrotask(settleLostOwnership)}if(!this.toastRegionActive)return;this.beginToastActivation()}if(this.transitionRequest){this.runTransition(this.transitionRequest);return}if(!this.hasUpdated||!this.open)return;this.removeAttribute("data-alert-showing"),this.removeAttribute("data-alert-hiding");const ownerDocument=this.ownerDocument;ownerDocument.defaultView?.queueMicrotask(()=>{this.isConnected&&this.ownerDocument===ownerDocument&&this.open&&this.restartAutoHide()})}disconnectedCallback(){const activeElement=deepActiveElement(this.ownerDocument);!this.pendingFocusRepair&&activeElement&&typeof activeElement.focus=="function"&&(this.pendingFocusRepair=captureComposedFocusRepair(this,activeElement)??void 0);const toastConnectionGeneration=++this.toastConnectionGeneration,transitionBelongedToToast=!!this.toastPromise;this.transitionToken++,this.clearAutoHide(),this.removeAttribute("data-alert-showing"),this.removeAttribute("data-alert-hiding"),this.hovering=!1,this.focused=!1;const settleLastingToastDisconnect=()=>{toastConnectionGeneration===this.toastConnectionGeneration&&!this.isConnected&&this.toastPromise&&this.finishToast(),toastConnectionGeneration===this.toastConnectionGeneration&&!this.isConnected&&this.transitionRequest&&(transitionBelongedToToast?this.cancelTransition(this.transitionRequest):this.settleTransitionCompletion(this.transitionRequest))},view=this.ownerDocument.defaultView;view?view.queueMicrotask(settleLastingToastDisconnect):queueMicrotask(settleLastingToastDisconnect),super.disconnectedCallback()}firstUpdated(changed){super.firstUpdated(changed),this.open&&this.restartAutoHide()}updated(changed){super.updated(changed),this.open&&!changed.has("open")&&(changed.has("duration")||changed.has("countdown"))&&this.restartAutoHide()}async show(){this.hasUpdated||await this.updateComplete,this.open||this.requestOpenState(!0),await this.transitionPromise}async hide(){this.hasUpdated||await this.updateComplete,this.open&&this.requestOpenState(!1),await this.transitionPromise}toast(){if(this.toastPromise)return this.toastPromise;let resolveCompletion;const completion=new Promise(resolve=>{resolveCompletion=resolve});this.toastPromise=completion,this.toastResolve=resolveCompletion,this.toastLifecycleGeneration+=1,this.toastActivationStarted=!1;const onAfterHide=()=>{this.toastRegionOwner&&this.parentElement===this.toastRegionOwner&&this.remove(),this.finishToast()};this.toastAfterHide=onAfterHide,this.addEventListener("lr-after-hide",onAfterHide,{once:!0});const enqueue=()=>{if(this.toastPromise!==completion)return;const region=getToastRegion(void 0,this.ownerDocument),controller=region;typeof controller[TOAST_REGION_ENQUEUE]=="function"?controller[TOAST_REGION_ENQUEUE](this):(region.childElementCount===0&&region.remove(),this.remove(),this.finishToast())};return this.ownerDocument.defaultView?.customElements.get(tag("toast"))?enqueue():import("../toast/toast.js").then(enqueue,enqueue),completion}[TOAST_REGION_SET_ACTIVE](owner,active){if(this.parentElement!==owner)return;let resolvedFocusTarget;const focusTarget=()=>(resolvedFocusTarget!==void 0||(resolvedFocusTarget=this.focusReturnTarget?.isConnected&&!composedContains(this,this.focusReturnTarget)?this.focusReturnTarget:nearestExternalFocusTarget(this)),resolvedFocusTarget),focusRepair=active?this.pendingFocusRepair:this.pendingFocusRepair??captureComposedFocusRepair(this,focusTarget),returnFocusTarget=!active&&focusRepair?focusTarget():null;this.toastRegionOwner=owner,this.toastRegionActive=active,this.toggleAttribute("data-toast-queued",!active);const base=this.base;base&&(base.hidden=!active,base.inert=!active),this.requestUpdate(),active?(focusRepair&&applyComposedFocusRepair(focusRepair),this.pendingFocusRepair=void 0,this.transitionRequest&&this.runTransition(this.transitionRequest),this.beginToastActivation()):(this.transitionToken+=1,focusRepair&&applyComposedFocusRepair(focusRepair,returnFocusTarget),this.pendingFocusRepair=void 0,this.clearAutoHide())}[TOAST_REGION_EVICT](owner,_reason){this.toastRegionOwner===owner&&(this.toastRegionOwner=void 0,this.toastRegionActive=!1,this.removeAttribute("data-toast-queued"),this.parentElement===owner&&this.remove(),this.finishToast())}beginToastActivation(){const completion=this.toastPromise,owner=this.toastRegionOwner;if(!completion||!owner||!this.toastRegionActive||this.toastActivationStarted)return;this.toastActivationStarted=!0;const generation=this.toastLifecycleGeneration;this.updateComplete.then(()=>{if(this.toastPromise!==completion||this.toastLifecycleGeneration!==generation||this.toastRegionOwner!==owner||!this.toastRegionActive||!this.isConnected||this.parentElement!==owner)return;if(this.open){this.restartAutoHide();return}if(!this.requestOpenState(!0))if(this.toastPromise===completion&&this.toastLifecycleGeneration===generation&&this.toastRegionOwner===owner&&this.parentElement===owner){const controller=owner;typeof controller[TOAST_REGION_REJECT]=="function"?controller[TOAST_REGION_REJECT](this):(this.parentElement===owner&&this.remove(),this.finishToast())}else this.toastPromise===completion&&this.finishToast()})}finishToast(){this.toastAfterHide&&this.removeEventListener("lr-after-hide",this.toastAfterHide);const resolve=this.toastResolve;if(this.toastAfterHide=void 0,this.toastResolve=void 0,this.toastPromise=void 0,this.toastRegionOwner=void 0,this.toastRegionActive=!1,this.toastActivationStarted=!1,this.toastLifecycleGeneration+=1,this.removeAttribute("data-toast-queued"),this.requestUpdate(),this.isConnected){const base=this.base;base&&(base.hidden=!1,base.inert=!1),this.pendingFocusRepair&&(applyComposedFocusRepair(this.pendingFocusRepair),this.pendingFocusRepair=void 0)}resolve?.()}settleTransitionCompletion(request){request.settled||(request.settled=!0,request.resolve())}cancelTransition(request){request.cancelled=!0,this.transitionRequest===request&&(this.transitionRequest=void 0),this.openRequest===request&&(this.openRequest=void 0),this.settleTransitionCompletion(request)}finishTransition(request){request.cancelled||(this.transitionRequest===request&&(this.transitionRequest=void 0),this.openRequest===request&&(this.openRequest=void 0),this.settleTransitionCompletion(request))}async runTransition(request){if(request.cancelled||this.transitionRequest!==request||this.toastPromise&&!this.toastRegionActive)return;const opening=request.target,token=++this.transitionToken;if(this.clearAutoHide(),opening)this.removeAttribute("data-alert-hiding"),this.setAttribute("data-alert-showing","");else{const base2=this.base;base2&&base2.offsetWidth,this.removeAttribute("data-alert-showing"),this.setAttribute("data-alert-hiding","")}if(await this.updateComplete,!this.isConnected||token!==this.transitionToken||this.transitionRequest!==request)return;const base=this.base;if(opening){if(base&&base.offsetWidth,await this.nextFrame(),!this.isConnected||token!==this.transitionToken||this.transitionRequest!==request)return;this.removeAttribute("data-alert-showing")}await this.waitForMotion(base),!(!this.isConnected||token!==this.transitionToken||this.transitionRequest!==request)&&(opening?(this.emit("lr-after-show"),this.restartAutoHide()):(this.removeAttribute("data-alert-hiding"),this.emit("lr-after-hide")),this.finishTransition(request))}get base(){return this.shadowRoot?.querySelector('[part="base"]')??null}nextFrame(){const view=this.ownerDocument.defaultView;return!view||prefersReducedMotion(this)?Promise.resolve():new Promise(resolve=>view.requestAnimationFrame(()=>resolve()))}async waitForMotion(base){const view=this.ownerDocument.defaultView;if(!base||!view||prefersReducedMotion(this))return;view.getComputedStyle(base).opacity;const animations=base.getAnimations({subtree:!0});await Promise.all(animations.map(animation=>animation.finished.catch(()=>{})))}get safeDuration(){return this.duration===1/0?1/0:finiteDuration(this.duration,0,0)}clearAutoHide(){this.timer!==void 0&&this.timerOwner?.clearTimeout(this.timer),this.timer=void 0,this.timerOwner=void 0,this.countdownAnimation?.cancel(),this.countdownAnimation=void 0}restartAutoHide(){if(this.clearAutoHide(),this.toastPromise&&!this.toastRegionActive||!this.open||this.hovering||this.focused)return;const duration=this.safeDuration;if(duration===1/0)return;if(duration<=0){const ownerDocument=this.ownerDocument;ownerDocument.defaultView?.queueMicrotask(()=>{this.isConnected&&this.ownerDocument===ownerDocument&&this.open&&!this.hovering&&!this.focused&&this.hide()});return}const view=this.ownerDocument.defaultView;view&&(this.timerOwner=view,this.timer=view.setTimeout(()=>{this.timer=void 0,this.timerOwner=void 0,this.hide()},duration),this.startCountdown(duration))}startCountdown(duration){if(prefersReducedMotion(this)||this.countdown!=="ltr"&&this.countdown!=="rtl")return;const indicator=this.shadowRoot?.querySelector(".countdown");indicator&&(this.countdownAnimation=indicator.animate([{transform:"scaleX(1)"},{transform:"scaleX(0)"}],{duration,easing:"linear",fill:"forwards"}))}render(){const hasCountdown=this.countdown==="ltr"||this.countdown==="rtl",countdownOrigin=this.countdown==="rtl"?"right center":"left center";return html`
1
+ import{__decorate}from"tslib";import{html,nothing}from"lit";import{property}from"lit/decorators.js";import{closeIcon}from"../../../internal/icons.js";import{applyComposedFocusRepair,captureComposedFocusRepair,nearestExternalFocusTarget}from"../../../internal/focus-navigation.js";import{renderInertPresentation}from"../../../internal/inert-presentation.js";import{LyraElement}from"../../../internal/lyra-element.js";import{tag}from"../../../internal/prefix.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{finiteDuration}from"../../../internal/numbers.js";import{composedContains,deepActiveElement}from"../../../internal/overlay-manager.js";import{SlotPresenceController}from"../../../internal/slot-presence-controller.js";import{optionalLiteralSetConverter}from"../../../internal/converters.js";import{normalizeReflectedOptionalSize,optionalSizeConverter}from"../../../internal/variants.js";import{contextualSizes}from"../../../internal/contextual-vocabulary.styles.js";import{semanticVariantConverter}from"../../../internal/semantic-variant.js";import{variants}from"../../../internal/variants.styles.js";import{getToastRegion}from"../toast/toast-region.js";import{TOAST_REGION_ENQUEUE,TOAST_REGION_EVICT,TOAST_REGION_REJECT,TOAST_REGION_SET_ACTIVE,toastRegionControllerFor}from"../toast/toast-region-protocol.js";import{styles}from"./alert.styles.js";import{LYRA_DEFAULT_close}from"../../../internal/default-strings/shared.generated.js";const ALERT_VARIANT=semanticVariantConverter("primary"),ALERT_COUNTDOWN=optionalLiteralSetConverter(["rtl","ltr"]);class LyraAlert extends LyraElement{static{this.defaultStrings={...super.defaultStrings,close:LYRA_DEFAULT_close}}static{this.styles=[LyraElement.styles,variants,contextualSizes,styles]}get open(){return this._open}set open(next){this.requestOpenState(!!next)}requestOpenState(normalized){if(normalized===this._open)return!0;if(this.openRequest)return this.openRequest.target===normalized;const repair=normalized?null:captureComposedFocusRepair(this,()=>nearestExternalFocusTarget(this));let request;if(this.hasUpdated){let resolve,reject;const completion=new Promise((resolveCompletion,rejectCompletion)=>{resolve=resolveCompletion,reject=rejectCompletion});if(request={target:normalized,completion,resolve,reject,settled:!1,cancelled:!1},this.openRequest=request,this.transitionPromise=completion,this.emit(normalized?"lr-show":"lr-hide",null,{cancelable:!0}).defaultPrevented)return this.toggleAttribute("open",this._open),this.openRequest===request&&(this.openRequest=void 0),this.cancelTransition(request),!1}this.transitionRequest&&this.cancelTransition(this.transitionRequest);const previous=this._open;return repair&&applyComposedFocusRepair(repair),this._open=normalized,this.requestUpdate("open",previous),request&&(this.openRequest===request&&(this.openRequest=void 0),this.transitionRequest=request,this.runTransition(request)),!0}get size(){return this._size}set size(next){const normalized=normalizeReflectedOptionalSize(this,next),old=this._size;old!==normalized&&(this._size=normalized,this.requestUpdate("size",old))}get countdown(){return this._countdown}set countdown(next){const normalized=ALERT_COUNTDOWN.normalizeReflected(this,"countdown",next),old=this._countdown;old!==normalized&&(this._countdown=normalized,this.requestUpdate("countdown",old))}get variant(){return this._variant}set variant(next){const normalized=ALERT_VARIANT.normalizeReflected(this,"variant",next),old=this._variant;old!==normalized&&(this._variant=normalized,this.requestUpdate("variant",old))}constructor(){super(),this.role="alert",this._open=!1,this.closable=!1,this.duration=1/0,this._variant="primary",this.slotPresence=new SlotPresenceController(this),this.transitionToken=0,this.transitionPromise=Promise.resolve(),this.hovering=!1,this.focused=!1,this.toastConnectionGeneration=0,this.toastLifecycleGeneration=0,this.toastRegionActive=!1,this.toastActivationStarted=!1,this.onPointerEnter=()=>{this.hovering=!0,this.clearAutoHide()},this.onPointerLeave=()=>{this.hovering=!1,this.focused||this.restartAutoHide()},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.clearAutoHide()},this.onFocusOut=event=>{const next=event.relatedTarget;if(!(next!==null&&next.nodeType===1&&composedContains(this,next))){if(next===null){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{const external=next;external.isConnected&&(this.focusReturnTarget=external),this.pendingFocusRepair=void 0}this.focused=!1,this.hovering||this.restartAutoHide()}},this.close=()=>{this.hide()},this.addEventListener("pointerenter",this.onPointerEnter),this.addEventListener("pointerleave",this.onPointerLeave),this.addEventListener("focusin",event=>this.onFocusIn(event)),this.addEventListener("focusout",event=>this.onFocusOut(event))}connectedCallback(){if(super.connectedCallback(),this.toastConnectionGeneration+=1,this.hasAttribute("role")||this.setAttribute("role","alert"),this.toastPromise){const currentController=toastRegionControllerFor(this);currentController&&currentController!==this.toastRegionOwner&&currentController[TOAST_REGION_ENQUEUE](this);const completion=this.toastPromise,generation=this.toastLifecycleGeneration,owner=this.toastRegionOwner;if(owner&&this.parentElement!==owner){const settleLostOwnership=()=>{this.toastPromise===completion&&this.toastLifecycleGeneration===generation&&this.parentElement!==owner&&this.finishToast()},view=this.ownerDocument.defaultView;view?view.queueMicrotask(settleLostOwnership):queueMicrotask(settleLostOwnership)}if(!this.toastRegionActive)return;this.beginToastActivation()}if(this.transitionRequest){this.runTransition(this.transitionRequest);return}if(!this.hasUpdated||!this.open)return;this.removeAttribute("data-alert-showing"),this.removeAttribute("data-alert-hiding");const ownerDocument=this.ownerDocument;ownerDocument.defaultView?.queueMicrotask(()=>{this.isConnected&&this.ownerDocument===ownerDocument&&this.open&&this.restartAutoHide()})}disconnectedCallback(){const activeElement=deepActiveElement(this.ownerDocument);!this.pendingFocusRepair&&activeElement&&typeof activeElement.focus=="function"&&(this.pendingFocusRepair=captureComposedFocusRepair(this,activeElement)??void 0);const toastConnectionGeneration=++this.toastConnectionGeneration,transitionBelongedToToast=!!this.toastPromise;this.transitionToken++,this.clearAutoHide(),this.removeAttribute("data-alert-showing"),this.removeAttribute("data-alert-hiding"),this.hovering=!1,this.focused=!1;const settleLastingToastDisconnect=()=>{toastConnectionGeneration===this.toastConnectionGeneration&&!this.isConnected&&this.toastPromise&&this.finishToast(),toastConnectionGeneration===this.toastConnectionGeneration&&!this.isConnected&&this.transitionRequest&&(transitionBelongedToToast?this.cancelTransition(this.transitionRequest):this.settleTransitionCompletion(this.transitionRequest))},view=this.ownerDocument.defaultView;view?view.queueMicrotask(settleLastingToastDisconnect):queueMicrotask(settleLastingToastDisconnect),super.disconnectedCallback()}firstUpdated(changed){super.firstUpdated(changed),this.open&&this.restartAutoHide()}updated(changed){super.updated(changed),this.open&&!changed.has("open")&&(changed.has("duration")||changed.has("countdown"))&&this.restartAutoHide()}async show(){this.hasUpdated||await this.updateComplete,this.open||this.requestOpenState(!0),await this.transitionPromise}async hide(){this.hasUpdated||await this.updateComplete,this.open&&this.requestOpenState(!1),await this.transitionPromise}toast(){if(this.toastPromise)return this.toastPromise;let resolveCompletion;const completion=new Promise(resolve=>{resolveCompletion=resolve});this.toastPromise=completion,this.toastResolve=resolveCompletion,this.toastLifecycleGeneration+=1,this.toastActivationStarted=!1;const onAfterHide=()=>{this.toastRegionOwner&&this.parentElement===this.toastRegionOwner&&this.remove(),this.finishToast()};this.toastAfterHide=onAfterHide,this.addEventListener("lr-after-hide",onAfterHide,{once:!0});const enqueue=()=>{if(this.toastPromise!==completion)return;const region=getToastRegion(void 0,this.ownerDocument),controller=region;typeof controller[TOAST_REGION_ENQUEUE]=="function"?controller[TOAST_REGION_ENQUEUE](this):(region.childElementCount===0&&region.remove(),this.remove(),this.finishToast())};return this.ownerDocument.defaultView?.customElements.get(tag("toast"))?enqueue():import("../toast/toast.js").then(enqueue,enqueue),completion}[TOAST_REGION_SET_ACTIVE](owner,active){if(this.parentElement!==owner)return;let resolvedFocusTarget;const focusTarget=()=>(resolvedFocusTarget!==void 0||(resolvedFocusTarget=this.focusReturnTarget?.isConnected&&!composedContains(this,this.focusReturnTarget)?this.focusReturnTarget:nearestExternalFocusTarget(this)),resolvedFocusTarget),focusRepair=active?this.pendingFocusRepair:this.pendingFocusRepair??captureComposedFocusRepair(this,focusTarget),returnFocusTarget=!active&&focusRepair?focusTarget():null;this.toastRegionOwner=owner,this.toastRegionActive=active,this.toggleAttribute("data-toast-queued",!active);const base=this.base;base&&(base.hidden=!active,base.inert=!active),this.requestUpdate(),active?(focusRepair&&applyComposedFocusRepair(focusRepair),this.pendingFocusRepair=void 0,this.transitionRequest&&this.runTransition(this.transitionRequest),this.beginToastActivation()):(this.transitionToken+=1,focusRepair&&applyComposedFocusRepair(focusRepair,returnFocusTarget),this.pendingFocusRepair=void 0,this.clearAutoHide())}[TOAST_REGION_EVICT](owner,_reason){this.toastRegionOwner===owner&&(this.toastRegionOwner=void 0,this.toastRegionActive=!1,this.removeAttribute("data-toast-queued"),this.parentElement===owner&&this.remove(),this.finishToast())}beginToastActivation(){const completion=this.toastPromise,owner=this.toastRegionOwner;if(!completion||!owner||!this.toastRegionActive||this.toastActivationStarted)return;this.toastActivationStarted=!0;const generation=this.toastLifecycleGeneration;this.updateComplete.then(()=>{if(this.toastPromise!==completion||this.toastLifecycleGeneration!==generation||this.toastRegionOwner!==owner||!this.toastRegionActive||!this.isConnected||this.parentElement!==owner)return;if(this.open){this.restartAutoHide();return}if(!this.requestOpenState(!0))if(this.toastPromise===completion&&this.toastLifecycleGeneration===generation&&this.toastRegionOwner===owner&&this.parentElement===owner){const controller=owner;typeof controller[TOAST_REGION_REJECT]=="function"?controller[TOAST_REGION_REJECT](this):(this.parentElement===owner&&this.remove(),this.finishToast())}else this.toastPromise===completion&&this.finishToast()})}finishToast(){this.toastAfterHide&&this.removeEventListener("lr-after-hide",this.toastAfterHide);const resolve=this.toastResolve;if(this.toastAfterHide=void 0,this.toastResolve=void 0,this.toastPromise=void 0,this.toastRegionOwner=void 0,this.toastRegionActive=!1,this.toastActivationStarted=!1,this.toastLifecycleGeneration+=1,this.removeAttribute("data-toast-queued"),this.requestUpdate(),this.isConnected){const base=this.base;base&&(base.hidden=!1,base.inert=!1),this.pendingFocusRepair&&(applyComposedFocusRepair(this.pendingFocusRepair),this.pendingFocusRepair=void 0)}resolve?.()}settleTransitionCompletion(request){request.settled||(request.settled=!0,request.resolve())}cancelTransition(request){request.cancelled=!0,this.transitionRequest===request&&(this.transitionRequest=void 0),this.openRequest===request&&(this.openRequest=void 0),this.settleTransitionCompletion(request)}finishTransition(request){request.cancelled||(this.transitionRequest===request&&(this.transitionRequest=void 0),this.openRequest===request&&(this.openRequest=void 0),this.settleTransitionCompletion(request))}async runTransition(request){if(request.cancelled||this.transitionRequest!==request||this.toastPromise&&!this.toastRegionActive)return;const opening=request.target,token=++this.transitionToken;if(this.clearAutoHide(),opening)this.removeAttribute("data-alert-hiding"),this.setAttribute("data-alert-showing","");else{const base2=this.base;base2&&base2.offsetWidth,this.removeAttribute("data-alert-showing"),this.setAttribute("data-alert-hiding","")}if(await this.updateComplete,!this.isConnected||token!==this.transitionToken||this.transitionRequest!==request)return;const base=this.base;if(opening){if(base&&base.offsetWidth,await this.nextFrame(),!this.isConnected||token!==this.transitionToken||this.transitionRequest!==request)return;this.removeAttribute("data-alert-showing")}await this.waitForMotion(base),!(!this.isConnected||token!==this.transitionToken||this.transitionRequest!==request)&&(opening?(this.emit("lr-after-show"),this.restartAutoHide()):(this.removeAttribute("data-alert-hiding"),this.emit("lr-after-hide")),this.finishTransition(request))}get base(){return this.shadowRoot?.querySelector('[part="base"]')??null}nextFrame(){const view=this.ownerDocument.defaultView;return!view||prefersReducedMotion(this)?Promise.resolve():new Promise(resolve=>view.requestAnimationFrame(()=>resolve()))}async waitForMotion(base){const view=this.ownerDocument.defaultView;if(!base||!view||prefersReducedMotion(this))return;view.getComputedStyle(base).opacity;const animations=base.getAnimations({subtree:!0});await Promise.all(animations.map(animation=>animation.finished.catch(()=>{})))}get safeDuration(){return this.duration===1/0?1/0:finiteDuration(this.duration,0,0)}clearAutoHide(){this.timer!==void 0&&this.timerOwner?.clearTimeout(this.timer),this.timer=void 0,this.timerOwner=void 0,this.countdownAnimation?.cancel(),this.countdownAnimation=void 0}restartAutoHide(){if(this.clearAutoHide(),this.toastPromise&&!this.toastRegionActive||!this.open||this.hovering||this.focused)return;const duration=this.safeDuration;if(duration===1/0)return;if(duration<=0){const ownerDocument=this.ownerDocument;ownerDocument.defaultView?.queueMicrotask(()=>{this.isConnected&&this.ownerDocument===ownerDocument&&this.open&&!this.hovering&&!this.focused&&this.hide()});return}const view=this.ownerDocument.defaultView;view&&(this.timerOwner=view,this.timer=view.setTimeout(()=>{this.timer=void 0,this.timerOwner=void 0,this.hide()},duration),this.startCountdown(duration))}startCountdown(duration){if(prefersReducedMotion(this)||this.countdown!=="ltr"&&this.countdown!=="rtl")return;const indicator=this.shadowRoot?.querySelector(".countdown");indicator&&(this.countdownAnimation=indicator.animate([{transform:"scaleX(1)"},{transform:"scaleX(0)"}],{duration,easing:"linear",fill:"forwards"}))}render(){const hasCountdown=this.countdown==="ltr"||this.countdown==="rtl",countdownOrigin=this.countdown==="rtl"?"right center":"left center";return html`
2
2
  <div
3
3
  part="base"
4
4
  ?hidden=${!!(this.toastPromise&&!this.toastRegionActive)}
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{AccessibleTextController}from"../../../internal/accessible-text-controller.js";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{composedAccessibilityText,isAccessibilitySubtreeExcluded}from"../../../internal/accessibility-visibility.js";import{applyComposedFocusRepair,captureComposedFocusRepair,nearestExternalFocusTarget}from"../../../internal/focus-navigation.js";import{LyraElement}from"../../../internal/lyra-element.js";import{closeIcon}from"../../../internal/icons.js";import{variants}from"../../../internal/variants.styles.js";import{LyraBadge}from"./badge.class.js";import{styles as badgeStyles}from"./badge.styles.js";import{styles as tagStyles}from"./tag.styles.js";import{LYRA_DEFAULT_remove,LYRA_DEFAULT_removeWithContext}from"../../../internal/default-strings.generated.js";function sourceParent(node){if(node.parentElement)return node.parentElement;const root=node.getRootNode();return"host"in root?root.host:null}function isClosedSourceDetailsBranch(details,branch){return details.localName!=="details"||details.hasAttribute("open")||branch===null?!1:Array.from(details.children).find(child=>child.localName==="summary")!==branch}function isSourceLabelAvailable(node){const target=node.nodeType===1?node:sourceParent(node);if(!target?.isConnected)return!1;let branch=target,current=sourceParent(target);if(isAccessibilitySubtreeExcluded(target))return!1;for(;current;){if(isAccessibilitySubtreeExcluded(current)||isClosedSourceDetailsBranch(current,branch))return!1;branch=current,current=sourceParent(current)}return!0}class LyraTag extends LyraBadge{constructor(){super(...arguments),this.disabled=!1,this.removeEnabled=!1,this.changingRemoveAliasAttribute=!1,this.labelTextObserver=new AccessibleTextController(this,[""],()=>{this.syncHostActionRole(),this.updateBrowserDerivedState(()=>this.recomputeLabelText())},["slot","role"],!1),this.managedActionGroupRole=!1,this.labelText="",this.onLabelSlotChange=event=>{const target=event.target;target?.nodeType!==1||target.localName!=="slot"||(this.labelTextObserver.bind(),this.withRemove&&this.updateBrowserDerivedState(()=>this.recomputeLabelText()))},this.onRemoveClick=()=>{if(!this.withRemove||this.disabled)return;const repair=captureComposedFocusRepair(this,()=>nearestExternalFocusTarget(this));this.emit("lr-remove",{value:this.value}),repair&&(!this.isConnected||!this.withRemove)&&applyComposedFocusRepair(repair)}}static{this.defaultStrings={...super.defaultStrings,remove:LYRA_DEFAULT_remove,removeWithContext:LYRA_DEFAULT_removeWithContext}}static{this.styles=[LyraElement.styles,variants,badgeStyles,tagStyles]}static{this.properties={withRemove:{attribute:"with-remove",type:Boolean,noAccessor:!0},removable:{attribute:"removable",type:Boolean,noAccessor:!0}}}get effectiveVariant(){return this.variant==="text"?"neutral":super.effectiveVariant}get withRemove(){return this.removeEnabled}set withRemove(next){this.setRemoveEnabled(!!next,"with-remove")}get removable(){return this.removeEnabled}set removable(next){this.setRemoveEnabled(!!next,"removable")}attributeChangedCallback(name,oldValue,value){const isRemoveAlias=name==="with-remove"||name==="removable";isRemoveAlias&&(this.changingRemoveAliasAttribute=!0);try{super.attributeChangedCallback(name,oldValue,value)}finally{isRemoveAlias&&(this.changingRemoveAliasAttribute=!1)}}setRemoveEnabled(next,preferredAttribute){const old=this.removeEnabled;this.changingRemoveAliasAttribute?this.removeEnabled=this.hasAttribute("with-remove")||this.hasAttribute("removable"):next?(this.setAttribute(preferredAttribute,""),this.removeEnabled=!0):(this.removeAttribute("with-remove"),this.removeAttribute("removable"),this.removeEnabled=!1),old!==this.removeEnabled&&(this.requestUpdate("withRemove",old),this.requestUpdate("removable",old))}connectedCallback(){super.connectedCallback(),this.addEventListener("slotchange",this.onLabelSlotChange),this.syncLabelObserver(),this.hasUpdated?(this.withRemove&&this.recomputeLabelText(!0),this.ownerDocument.defaultView?.queueMicrotask(()=>{this.isConnected&&this.withRemove&&this.recomputeLabelText()})):this.seedFirstRenderState(()=>this.recomputeLabelText(!0))}disconnectedCallback(){this.removeEventListener("slotchange",this.onLabelSlotChange),this.releaseHostActionRole(),super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.labelTextObserver.adopted()}syncLabelObserver(){this.labelTextObserver.setEnabled(this.withRemove)}recomputeLabelText(preferLightDom=!1){const slot=this.renderRoot?.querySelector("slot:not([name])"),lightDomNodes=this.childNodes,nodes=slot?slot.assignedNodes({flatten:!0}):Array.from(lightDomNodes??[]).filter(node=>{if(node.nodeType!==1)return!0;const slotName=node.getAttribute("slot");return slotName!=="start"&&slotName!=="end"});this.labelText=nodes.map(node=>composedAccessibilityText(node,{ancestorBoundary:this,isSubtreeExcluded:element=>element.getRootNode()===this.renderRoot&&element.getAttribute("part")?.split(/\s+/).includes("content")?!1:isAccessibilitySubtreeExcluded(element),requireRendered:preferLightDom?!1:node.nodeType!==1||node.localName!=="slot",shouldPruneNode:candidate=>!this.contains(candidate)&&!isSourceLabelAvailable(candidate),ignoreInheritedVisibility:!0})).join(" ").replace(/\s+/g," ").trim()}get accessibleRemoveLabel(){const text=this.labelText;return text?this.localize("removeWithContext",void 0,{label:text}):this.localize("remove")}focus(options){this.withRemove&&this.removeButtonEl?.focus(options)}blur(){this.removeButtonEl?.blur()}click(){if(!this.withRemove){super.click();return}this.removeButtonEl?.click()}willUpdate(changed){if(super.willUpdate(changed),changed.has("withRemove")){if(!this.withRemove){const repair=captureComposedFocusRepair(this,()=>nearestExternalFocusTarget(this));repair&&applyComposedFocusRepair(repair)}this.syncLabelObserver(),this.withRemove&&this.hasUpdated&&this.recomputeLabelText()}}updated(changed){super.updated(changed),this.syncHostActionRole()}syncHostActionRole(){const needsGroup=this.withRemove&&this.hasAttribute("aria-label");needsGroup&&!this.hasAttribute("role")?(this.setAttribute("role","group"),this.managedActionGroupRole=!0):needsGroup||this.releaseHostActionRole()}releaseHostActionRole(){this.managedActionGroupRole&&this.getAttribute("role")==="group"&&this.removeAttribute("role"),this.managedActionGroupRole=!1}renderTrailing(){return this.withRemove?html`<button
1
+ import{__decorate}from"tslib";import{AccessibleTextController}from"../../../internal/accessible-text-controller.js";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{composedAccessibilityText,isAccessibilitySubtreeExcluded}from"../../../internal/accessibility-visibility.js";import{applyComposedFocusRepair,captureComposedFocusRepair,nearestExternalFocusTarget}from"../../../internal/focus-navigation.js";import{LyraElement}from"../../../internal/lyra-element.js";import{closeIcon}from"../../../internal/icons.js";import{variants}from"../../../internal/variants.styles.js";import{LyraBadge}from"./badge.class.js";import{styles as badgeStyles}from"./badge.styles.js";import{styles as tagStyles}from"./tag.styles.js";import{LYRA_DEFAULT_remove,LYRA_DEFAULT_removeWithContext}from"../../../internal/default-strings/shared.generated.js";function sourceParent(node){if(node.parentElement)return node.parentElement;const root=node.getRootNode();return"host"in root?root.host:null}function isClosedSourceDetailsBranch(details,branch){return details.localName!=="details"||details.hasAttribute("open")||branch===null?!1:Array.from(details.children).find(child=>child.localName==="summary")!==branch}function isSourceLabelAvailable(node){const target=node.nodeType===1?node:sourceParent(node);if(!target?.isConnected)return!1;let branch=target,current=sourceParent(target);if(isAccessibilitySubtreeExcluded(target))return!1;for(;current;){if(isAccessibilitySubtreeExcluded(current)||isClosedSourceDetailsBranch(current,branch))return!1;branch=current,current=sourceParent(current)}return!0}class LyraTag extends LyraBadge{constructor(){super(...arguments),this.disabled=!1,this.removeEnabled=!1,this.changingRemoveAliasAttribute=!1,this.labelTextObserver=new AccessibleTextController(this,[""],()=>{this.syncHostActionRole(),this.updateBrowserDerivedState(()=>this.recomputeLabelText())},["slot","role"],!1),this.managedActionGroupRole=!1,this.labelText="",this.onLabelSlotChange=event=>{const target=event.target;target?.nodeType!==1||target.localName!=="slot"||(this.labelTextObserver.bind(),this.withRemove&&this.updateBrowserDerivedState(()=>this.recomputeLabelText()))},this.onRemoveClick=()=>{if(!this.withRemove||this.disabled)return;const repair=captureComposedFocusRepair(this,()=>nearestExternalFocusTarget(this));this.emit("lr-remove",{value:this.value}),repair&&(!this.isConnected||!this.withRemove)&&applyComposedFocusRepair(repair)}}static{this.defaultStrings={...super.defaultStrings,remove:LYRA_DEFAULT_remove,removeWithContext:LYRA_DEFAULT_removeWithContext}}static{this.styles=[LyraElement.styles,variants,badgeStyles,tagStyles]}static{this.properties={withRemove:{attribute:"with-remove",type:Boolean,noAccessor:!0},removable:{attribute:"removable",type:Boolean,noAccessor:!0}}}get effectiveVariant(){return this.variant==="text"?"neutral":super.effectiveVariant}get withRemove(){return this.removeEnabled}set withRemove(next){this.setRemoveEnabled(!!next,"with-remove")}get removable(){return this.removeEnabled}set removable(next){this.setRemoveEnabled(!!next,"removable")}attributeChangedCallback(name,oldValue,value){const isRemoveAlias=name==="with-remove"||name==="removable";isRemoveAlias&&(this.changingRemoveAliasAttribute=!0);try{super.attributeChangedCallback(name,oldValue,value)}finally{isRemoveAlias&&(this.changingRemoveAliasAttribute=!1)}}setRemoveEnabled(next,preferredAttribute){const old=this.removeEnabled;this.changingRemoveAliasAttribute?this.removeEnabled=this.hasAttribute("with-remove")||this.hasAttribute("removable"):next?(this.setAttribute(preferredAttribute,""),this.removeEnabled=!0):(this.removeAttribute("with-remove"),this.removeAttribute("removable"),this.removeEnabled=!1),old!==this.removeEnabled&&(this.requestUpdate("withRemove",old),this.requestUpdate("removable",old))}connectedCallback(){super.connectedCallback(),this.addEventListener("slotchange",this.onLabelSlotChange),this.syncLabelObserver(),this.hasUpdated?(this.withRemove&&this.recomputeLabelText(!0),this.ownerDocument.defaultView?.queueMicrotask(()=>{this.isConnected&&this.withRemove&&this.recomputeLabelText()})):this.seedFirstRenderState(()=>this.recomputeLabelText(!0))}disconnectedCallback(){this.removeEventListener("slotchange",this.onLabelSlotChange),this.releaseHostActionRole(),super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.labelTextObserver.adopted()}syncLabelObserver(){this.labelTextObserver.setEnabled(this.withRemove)}recomputeLabelText(preferLightDom=!1){const slot=this.renderRoot?.querySelector("slot:not([name])"),lightDomNodes=this.childNodes,nodes=slot?slot.assignedNodes({flatten:!0}):Array.from(lightDomNodes??[]).filter(node=>{if(node.nodeType!==1)return!0;const slotName=node.getAttribute("slot");return slotName!=="start"&&slotName!=="end"});this.labelText=nodes.map(node=>composedAccessibilityText(node,{ancestorBoundary:this,isSubtreeExcluded:element=>element.getRootNode()===this.renderRoot&&element.getAttribute("part")?.split(/\s+/).includes("content")?!1:isAccessibilitySubtreeExcluded(element),requireRendered:preferLightDom?!1:node.nodeType!==1||node.localName!=="slot",shouldPruneNode:candidate=>!this.contains(candidate)&&!isSourceLabelAvailable(candidate),ignoreInheritedVisibility:!0})).join(" ").replace(/\s+/g," ").trim()}get accessibleRemoveLabel(){const text=this.labelText;return text?this.localize("removeWithContext",void 0,{label:text}):this.localize("remove")}focus(options){this.withRemove&&this.removeButtonEl?.focus(options)}blur(){this.removeButtonEl?.blur()}click(){if(!this.withRemove){super.click();return}this.removeButtonEl?.click()}willUpdate(changed){if(super.willUpdate(changed),changed.has("withRemove")){if(!this.withRemove){const repair=captureComposedFocusRepair(this,()=>nearestExternalFocusTarget(this));repair&&applyComposedFocusRepair(repair)}this.syncLabelObserver(),this.withRemove&&this.hasUpdated&&this.recomputeLabelText()}}updated(changed){super.updated(changed),this.syncHostActionRole()}syncHostActionRole(){const needsGroup=this.withRemove&&this.hasAttribute("aria-label");needsGroup&&!this.hasAttribute("role")?(this.setAttribute("role","group"),this.managedActionGroupRole=!0):needsGroup||this.releaseHostActionRole()}releaseHostActionRole(){this.managedActionGroupRole&&this.getAttribute("role")==="group"&&this.removeAttribute("role"),this.managedActionGroupRole=!1}renderTrailing(){return this.withRemove?html`<button
2
2
  part="remove-button remove-button__base"
3
3
  type="button"
4
4
  ?disabled=${this.disabled}
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{html,nothing}from"lit";import{property}from"lit/decorators.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{composedParentElement}from"../../../internal/active-element.js";import{closeIcon}from"../../../internal/icons.js";import{isAccessibilityVisible}from"../../../internal/accessibility-visibility.js";import{AnnouncementUpgradeObserver}from"../../../internal/announcement-text.js";import{applyComposedFocusRepair,captureComposedFocusRepair,nearestExternalFocusTarget}from"../../../internal/focus-navigation.js";import{LyraElement}from"../../../internal/lyra-element.js";import{resolveHeadingLevel}from"../../../internal/heading-level.js";import{SlotPresenceController}from"../../../internal/slot-presence-controller.js";import{contextualSizes,contextualVariants}from"../../../internal/contextual-vocabulary.styles.js";import{effectiveSemanticVariant,semanticVariantConverter}from"../../../internal/semantic-variant.js";import{styles}from"./callout.styles.js";import{literalSetConverter,presenceTrueDefaultBooleanConverter as trueDefaultBooleanConverter}from"../../../internal/converters.js";import{LYRA_DEFAULT_calloutAnnouncementWithContext,LYRA_DEFAULT_close}from"../../../internal/default-strings.generated.js";const CALLOUT_VARIANT=semanticVariantConverter("brand"),CALLOUT_SIZE=literalSetConverter(["2xs","xs","s","m","l","xl","small","medium","large"],"m"),CALLOUT_HEADING_LEVEL=literalSetConverter(["1","2","3","4","5","6","none"],"3"),CALLOUT_APPEARANCES=new Set(["accent","filled","outlined","filled-outlined","plain"]),normalizeCalloutAppearance=value=>typeof value=="string"&&CALLOUT_APPEARANCES.has(value)?value:void 0,calloutAppearanceConverter={fromAttribute:normalizeCalloutAppearance,toAttribute:value=>normalizeCalloutAppearance(value)??null};class LyraCallout extends LyraElement{constructor(){super(...arguments),this._variant="brand",this._size="m",this.heading="",this._headingLevel="3",this.closable=!1,this.inline=!1,this.announce=!1,this.open=!0,this.hostAriaLabel=null,this.slotPresence=new SlotPresenceController(this),this.liveActive=!1,this.initialContentAnnounced=!1,this.connectionGeneration=0,this.lastAnnouncementText="",this.announcementShadowRoots=new Set,this.announcementUpgrades=new AnnouncementUpgradeObserver(()=>{this.announceCurrentContent(),this.observeAnnouncementContent()}),this.onForwardedSlotChange=event=>{const slot=event.target;this.announcementForwardingSlots().includes(slot)&&(this.announceCurrentContent(),this.observeAnnouncementContent())},this.close=()=>{const repair=captureComposedFocusRepair(this,()=>nearestExternalFocusTarget(this));this.emit("lr-close-request",{reason:"close-button"},{cancelable:!0}).defaultPrevented||(repair&&applyComposedFocusRepair(repair),this.open=!1,this.emit("lr-close",{reason:"close-button"}))}}static{this.defaultStrings={...super.defaultStrings,calloutAnnouncementWithContext:LYRA_DEFAULT_calloutAnnouncementWithContext,close:LYRA_DEFAULT_close}}static{this.styles=[LyraElement.styles,contextualVariants,contextualSizes,styles]}get variant(){return this._variant}set variant(next){const normalized=CALLOUT_VARIANT.normalizeReflected(this,"variant",next==="primary"?"brand":next),old=this._variant;old!==normalized&&(this._variant=normalized,this.requestUpdate("variant",old))}get appearance(){return this._appearance}set appearance(next){const normalized=normalizeCalloutAppearance(next);this.hasAttribute("appearance")&&this.getAttribute("appearance")!==normalized&&(normalized===void 0?this.removeAttribute("appearance"):this.setAttribute("appearance",normalized));const old=this._appearance;old!==normalized&&(this._appearance=normalized,this.requestUpdate("appearance",old))}get size(){return this._size}set size(next){const normalized=CALLOUT_SIZE.normalizeReflected(this,"size",next),old=this._size;old!==normalized&&(this._size=normalized,this.requestUpdate("size",old))}get headingLevel(){return this._headingLevel}set headingLevel(next){const normalized=CALLOUT_HEADING_LEVEL.normalizeReflected(this,"heading-level",next),old=this._headingLevel;old!==normalized&&(this._headingLevel=normalized,this.requestUpdate("headingLevel",old))}connectedCallback(){super.connectedCallback(),this.addEventListener("slotchange",this.onForwardedSlotChange),this.politeSink??=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}),this.assertiveSink??=acquireAnnouncementSink("assertive",{document:this.ownerDocument,source:this});const MutationObserverCtor=this.ownerDocument.defaultView?.MutationObserver;MutationObserverCtor&&(this.contentObserver=new MutationObserverCtor(records=>{records.some(record=>!this.contains(record.target)||this.isAnnouncementMutation(record))&&(this.announceCurrentContent(),this.observeAnnouncementContent())}),this.observeAnnouncementContent());const generation=++this.connectionGeneration;this.updateComplete.then(()=>{const view=this.ownerDocument?.defaultView;return typeof view?.requestAnimationFrame=="function"?new Promise(resolve=>view.requestAnimationFrame(()=>resolve())):Promise.resolve()}).then(()=>this.updateComplete).then(()=>{this.isConnected&&generation===this.connectionGeneration&&(this.lastAnnouncementText=this.announcementText(),this.observeAnnouncementContent(),this.liveActive=!0,this.announce&&!this.initialContentAnnounced&&(this.initialContentAnnounced=!0,this.announceCurrentContent(!0)))})}disconnectedCallback(){this.connectionGeneration+=1,this.liveActive=!1,this.lastAnnouncementText="",this.contentObserver?.disconnect(),this.contentObserver=void 0,this.announcementShadowRoots.clear(),this.announcementUpgrades.disconnect(),this.removeEventListener("slotchange",this.onForwardedSlotChange),this.politeSink?.release(),this.politeSink=void 0,this.assertiveSink?.release(),this.assertiveSink=void 0,super.disconnectedCallback()}updated(changed){super.updated(changed),!(!this.liveActive||!this.open)&&(changed.has("open")||changed.has("heading")||changed.has("hostAriaLabel"))&&(this.announceCurrentContent(changed.has("open")),this.observeAnnouncementContent())}willUpdate(changed){if(super.willUpdate(changed),changed.has("open")&&!this.open){const repair=captureComposedFocusRepair(this,()=>nearestExternalFocusTarget(this));repair&&applyComposedFocusRepair(repair)}}isAnnouncementMutation(record){if(record.target===this)return record.type==="childList"||record.type==="attributes"&&["aria-hidden","aria-label","class","hidden","inert","style"].includes(record.attributeName??"");let top=record.target;for(;top.parentNode&&top.parentNode!==this;)top=top.parentNode;return top.parentNode!==this?!1:record.type==="attributes"&&record.attributeName==="slot"&&record.target===top?!0:this.isAnnouncementSlotNode(top)}isAnnouncementSlotNode(node){if(node.nodeType!==1)return!0;const slotName=node.getAttribute("slot");return slotName===null||slotName===""||slotName==="heading"}announcementObservationOptions(){return{attributes:!0,attributeFilter:["alt","aria-hidden","aria-label","class","hidden","inert","open","slot","style"],characterData:!0,childList:!0,subtree:!0}}announcementForwardingSlots(){return Array.from(this.querySelectorAll("slot")).filter(slot=>{let top=slot;for(;top.parentNode&&top.parentNode!==this;)top=top.parentNode;return top.parentNode===this&&this.isAnnouncementSlotNode(top)})}observeAnnouncementContent(){const observer=this.contentObserver;if(!observer)return;observer.disconnect();const options=this.announcementObservationOptions();observer.observe(this,options);for(const slot of this.announcementForwardingSlots())if(slot.assignedNodes().length!==0)for(const assigned of slot.assignedNodes({flatten:!0}))observer.observe(assigned,options);for(const root of this.announcementShadowRoots)observer.observe(root,options)}normalizedText(value){return(value??"").replace(/\s+/g," ").trim()}resolvedAccessibleLabel(){const hostLabel=this.hostAriaLabel;return this.normalizedText(hostLabel)}announcementText(){const roots=new Set;if(this.announcementShadowRoots=roots,!isAccessibilityVisible(this))return"";const hostLabel=this.hostAriaLabel,context=this.normalizedText(hostLabel),heading=[this.heading,...Array.from(this.childNodes).filter(node=>node.nodeType===1&&node.getAttribute("slot")==="heading").map(node=>this.announcementUpgrades.collect(node,roots))],message=Array.from(this.childNodes).filter(node=>{if(node.nodeType!==1)return!0;const slotName=node.getAttribute("slot");return slotName===null||slotName===""}).map(node=>this.announcementUpgrades.collect(node,roots)),content=this.normalizedText([...heading,...message].join(" "));return!context||context===content?content:content?this.localize("calloutAnnouncementWithContext",void 0,{context,content}):context}announceCurrentContent(force=!1){if(!this.liveActive||!this.isConnected||!this.open)return;const text=this.announcementText();!force&&text===this.lastAnnouncementText||(this.lastAnnouncementText=text,(this.effectiveContextualVariant==="danger"?this.assertiveSink:this.politeSink)?.announce(text))}get effectiveContextualVariant(){if(this.hasAttribute("variant"))return effectiveSemanticVariant(this.variant);let ancestor=composedParentElement(this);for(;ancestor;){const candidate=ancestor.getAttribute("variant");if(candidate&&CALLOUT_VARIANT.normalize(candidate)===candidate)return effectiveSemanticVariant(candidate);ancestor=composedParentElement(ancestor)}return"brand"}render(){if(!this.open)return html``;const label=this.resolvedAccessibleLabel()||void 0,headingLevel=resolveHeadingLevel(this.headingLevel);return html`<div
1
+ import{__decorate}from"tslib";import{html,nothing}from"lit";import{property}from"lit/decorators.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{composedParentElement}from"../../../internal/active-element.js";import{closeIcon}from"../../../internal/icons.js";import{isAccessibilityVisible}from"../../../internal/accessibility-visibility.js";import{AnnouncementUpgradeObserver}from"../../../internal/announcement-text.js";import{applyComposedFocusRepair,captureComposedFocusRepair,nearestExternalFocusTarget}from"../../../internal/focus-navigation.js";import{LyraElement}from"../../../internal/lyra-element.js";import{resolveHeadingLevel}from"../../../internal/heading-level.js";import{SlotPresenceController}from"../../../internal/slot-presence-controller.js";import{contextualSizes,contextualVariants}from"../../../internal/contextual-vocabulary.styles.js";import{effectiveSemanticVariant,semanticVariantConverter}from"../../../internal/semantic-variant.js";import{styles}from"./callout.styles.js";import{literalSetConverter,presenceTrueDefaultBooleanConverter as trueDefaultBooleanConverter}from"../../../internal/converters.js";import{LYRA_DEFAULT_calloutAnnouncementWithContext}from"../../../internal/default-strings/overlays.generated.js";import{LYRA_DEFAULT_close}from"../../../internal/default-strings/shared.generated.js";const CALLOUT_VARIANT=semanticVariantConverter("brand"),CALLOUT_SIZE=literalSetConverter(["2xs","xs","s","m","l","xl","small","medium","large"],"m"),CALLOUT_HEADING_LEVEL=literalSetConverter(["1","2","3","4","5","6","none"],"3"),CALLOUT_APPEARANCES=new Set(["accent","filled","outlined","filled-outlined","plain"]),normalizeCalloutAppearance=value=>typeof value=="string"&&CALLOUT_APPEARANCES.has(value)?value:void 0,calloutAppearanceConverter={fromAttribute:normalizeCalloutAppearance,toAttribute:value=>normalizeCalloutAppearance(value)??null};class LyraCallout extends LyraElement{constructor(){super(...arguments),this._variant="brand",this._size="m",this.heading="",this._headingLevel="3",this.closable=!1,this.inline=!1,this.announce=!1,this.open=!0,this.hostAriaLabel=null,this.slotPresence=new SlotPresenceController(this),this.liveActive=!1,this.initialContentAnnounced=!1,this.connectionGeneration=0,this.lastAnnouncementText="",this.announcementShadowRoots=new Set,this.announcementUpgrades=new AnnouncementUpgradeObserver(()=>{this.announceCurrentContent(),this.observeAnnouncementContent()}),this.onForwardedSlotChange=event=>{const slot=event.target;this.announcementForwardingSlots().includes(slot)&&(this.announceCurrentContent(),this.observeAnnouncementContent())},this.close=()=>{const repair=captureComposedFocusRepair(this,()=>nearestExternalFocusTarget(this));this.emit("lr-close-request",{reason:"close-button"},{cancelable:!0}).defaultPrevented||(repair&&applyComposedFocusRepair(repair),this.open=!1,this.emit("lr-close",{reason:"close-button"}))}}static{this.defaultStrings={...super.defaultStrings,calloutAnnouncementWithContext:LYRA_DEFAULT_calloutAnnouncementWithContext,close:LYRA_DEFAULT_close}}static{this.styles=[LyraElement.styles,contextualVariants,contextualSizes,styles]}get variant(){return this._variant}set variant(next){const normalized=CALLOUT_VARIANT.normalizeReflected(this,"variant",next==="primary"?"brand":next),old=this._variant;old!==normalized&&(this._variant=normalized,this.requestUpdate("variant",old))}get appearance(){return this._appearance}set appearance(next){const normalized=normalizeCalloutAppearance(next);this.hasAttribute("appearance")&&this.getAttribute("appearance")!==normalized&&(normalized===void 0?this.removeAttribute("appearance"):this.setAttribute("appearance",normalized));const old=this._appearance;old!==normalized&&(this._appearance=normalized,this.requestUpdate("appearance",old))}get size(){return this._size}set size(next){const normalized=CALLOUT_SIZE.normalizeReflected(this,"size",next),old=this._size;old!==normalized&&(this._size=normalized,this.requestUpdate("size",old))}get headingLevel(){return this._headingLevel}set headingLevel(next){const normalized=CALLOUT_HEADING_LEVEL.normalizeReflected(this,"heading-level",next),old=this._headingLevel;old!==normalized&&(this._headingLevel=normalized,this.requestUpdate("headingLevel",old))}connectedCallback(){super.connectedCallback(),this.addEventListener("slotchange",this.onForwardedSlotChange),this.politeSink??=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}),this.assertiveSink??=acquireAnnouncementSink("assertive",{document:this.ownerDocument,source:this});const MutationObserverCtor=this.ownerDocument.defaultView?.MutationObserver;MutationObserverCtor&&(this.contentObserver=new MutationObserverCtor(records=>{records.some(record=>!this.contains(record.target)||this.isAnnouncementMutation(record))&&(this.announceCurrentContent(),this.observeAnnouncementContent())}),this.observeAnnouncementContent());const generation=++this.connectionGeneration;this.updateComplete.then(()=>{const view=this.ownerDocument?.defaultView;return typeof view?.requestAnimationFrame=="function"?new Promise(resolve=>view.requestAnimationFrame(()=>resolve())):Promise.resolve()}).then(()=>this.updateComplete).then(()=>{this.isConnected&&generation===this.connectionGeneration&&(this.lastAnnouncementText=this.announcementText(),this.observeAnnouncementContent(),this.liveActive=!0,this.announce&&!this.initialContentAnnounced&&(this.initialContentAnnounced=!0,this.announceCurrentContent(!0)))})}disconnectedCallback(){this.connectionGeneration+=1,this.liveActive=!1,this.lastAnnouncementText="",this.contentObserver?.disconnect(),this.contentObserver=void 0,this.announcementShadowRoots.clear(),this.announcementUpgrades.disconnect(),this.removeEventListener("slotchange",this.onForwardedSlotChange),this.politeSink?.release(),this.politeSink=void 0,this.assertiveSink?.release(),this.assertiveSink=void 0,super.disconnectedCallback()}updated(changed){super.updated(changed),!(!this.liveActive||!this.open)&&(changed.has("open")||changed.has("heading")||changed.has("hostAriaLabel"))&&(this.announceCurrentContent(changed.has("open")),this.observeAnnouncementContent())}willUpdate(changed){if(super.willUpdate(changed),changed.has("open")&&!this.open){const repair=captureComposedFocusRepair(this,()=>nearestExternalFocusTarget(this));repair&&applyComposedFocusRepair(repair)}}isAnnouncementMutation(record){if(record.target===this)return record.type==="childList"||record.type==="attributes"&&["aria-hidden","aria-label","class","hidden","inert","style"].includes(record.attributeName??"");let top=record.target;for(;top.parentNode&&top.parentNode!==this;)top=top.parentNode;return top.parentNode!==this?!1:record.type==="attributes"&&record.attributeName==="slot"&&record.target===top?!0:this.isAnnouncementSlotNode(top)}isAnnouncementSlotNode(node){if(node.nodeType!==1)return!0;const slotName=node.getAttribute("slot");return slotName===null||slotName===""||slotName==="heading"}announcementObservationOptions(){return{attributes:!0,attributeFilter:["alt","aria-hidden","aria-label","class","hidden","inert","open","slot","style"],characterData:!0,childList:!0,subtree:!0}}announcementForwardingSlots(){return Array.from(this.querySelectorAll("slot")).filter(slot=>{let top=slot;for(;top.parentNode&&top.parentNode!==this;)top=top.parentNode;return top.parentNode===this&&this.isAnnouncementSlotNode(top)})}observeAnnouncementContent(){const observer=this.contentObserver;if(!observer)return;observer.disconnect();const options=this.announcementObservationOptions();observer.observe(this,options);for(const slot of this.announcementForwardingSlots())if(slot.assignedNodes().length!==0)for(const assigned of slot.assignedNodes({flatten:!0}))observer.observe(assigned,options);for(const root of this.announcementShadowRoots)observer.observe(root,options)}normalizedText(value){return(value??"").replace(/\s+/g," ").trim()}resolvedAccessibleLabel(){const hostLabel=this.hostAriaLabel;return this.normalizedText(hostLabel)}announcementText(){const roots=new Set;if(this.announcementShadowRoots=roots,!isAccessibilityVisible(this))return"";const hostLabel=this.hostAriaLabel,context=this.normalizedText(hostLabel),heading=[this.heading,...Array.from(this.childNodes).filter(node=>node.nodeType===1&&node.getAttribute("slot")==="heading").map(node=>this.announcementUpgrades.collect(node,roots))],message=Array.from(this.childNodes).filter(node=>{if(node.nodeType!==1)return!0;const slotName=node.getAttribute("slot");return slotName===null||slotName===""}).map(node=>this.announcementUpgrades.collect(node,roots)),content=this.normalizedText([...heading,...message].join(" "));return!context||context===content?content:content?this.localize("calloutAnnouncementWithContext",void 0,{context,content}):context}announceCurrentContent(force=!1){if(!this.liveActive||!this.isConnected||!this.open)return;const text=this.announcementText();!force&&text===this.lastAnnouncementText||(this.lastAnnouncementText=text,(this.effectiveContextualVariant==="danger"?this.assertiveSink:this.politeSink)?.announce(text))}get effectiveContextualVariant(){if(this.hasAttribute("variant"))return effectiveSemanticVariant(this.variant);let ancestor=composedParentElement(this);for(;ancestor;){const candidate=ancestor.getAttribute("variant");if(candidate&&CALLOUT_VARIANT.normalize(candidate)===candidate)return effectiveSemanticVariant(candidate);ancestor=composedParentElement(ancestor)}return"brand"}render(){if(!this.open)return html``;const label=this.resolvedAccessibleLabel()||void 0,headingLevel=resolveHeadingLevel(this.headingLevel);return html`<div
2
2
  part="base"
3
3
  role=${label?"group":nothing}
4
4
  aria-label=${label||nothing}
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{finiteCount}from"../../../internal/numbers.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{deepActiveElementIn}from"../../../internal/active-element.js";import{applyComposedFocusRepair,captureComposedFocusRepair,collectComposedFocusTargets}from"../../../internal/focus-navigation.js";import{composedContains}from"../../../internal/overlay-manager.js";import{styles}from"./chip-group.styles.js";import{LYRA_DEFAULT_showLess,LYRA_DEFAULT_showMoreCollapsed,LYRA_DEFAULT_showMoreCount}from"../../../internal/default-strings.generated.js";class LyraChipGroup extends LyraElement{constructor(){super(...arguments),this.accessibleLabel="",this.childCount=0,this.expanded=!1,this.authorHidden=new Map,this.observedChildren=new Set,this.pendingHiddenWrites=new Map,this.visibilityObserverGeneration=0,this.onSlotChange=e=>{const slot=e.target;this.updateBrowserDerivedState(()=>{this.isConnected&&(this.childCount=slot.assignedElements({flatten:!0}).length,this.requestUpdate())})},this.onFocusIn=()=>{const active=deepActiveElementIn(this.ownerDocument),children=this.assignedChildren(),index=children.findIndex(child2=>composedContains(child2,active)),base=this.renderRoot.querySelector('[part="base"]');if(index<0||!base){this.trackedChipFocus=void 0;return}const child=children[index];if(!("focus"in child)){this.trackedChipFocus=void 0;return}const repair=captureComposedFocusRepair(child,base);this.trackedChipFocus=repair?{child,index,repair}:void 0},this.onFocusOut=()=>{const tracked=this.trackedChipFocus;tracked&&queueMicrotask(()=>{if(this.trackedChipFocus!==tracked)return;const active=deepActiveElementIn(this.ownerDocument);if(active!==null&&composedContains(tracked.child,active))return;!tracked.child.isConnected&&(active===null||active===this.ownerDocument.body||active===this.ownerDocument.documentElement)||(this.trackedChipFocus=void 0)})},this.onToggleOverflow=()=>{this.expanded=!this.expanded,this.emit("lr-overflow-toggle",{expanded:this.expanded})}}static{this.defaultStrings={...super.defaultStrings,showLess:LYRA_DEFAULT_showLess,showMoreCollapsed:LYRA_DEFAULT_showMoreCollapsed,showMoreCount:LYRA_DEFAULT_showMoreCount}}static{this.styles=[LyraElement.styles,styles]}get maxVisible(){return this._maxVisible}set maxVisible(next){const old=this._maxVisible;this._maxVisible=next==null?void 0:finiteCount(next),this.requestUpdate("maxVisible",old)}connectedCallback(){super.connectedCallback(),this.armVisibilityObserver(),this.hasUpdated&&this.reconcileChildVisibilityAndFocus()}armVisibilityObserver(){const ownerDocument=this.ownerDocument;if(!this.isConnected||this.visibilityObserver&&this.visibilityObserverDocument===ownerDocument)return;this.resetVisibilityObserver();const MutationObserverCtor=ownerDocument.defaultView?.MutationObserver;if(!MutationObserverCtor)return;const generation=this.visibilityObserverGeneration,observer=new MutationObserverCtor(records=>{this.visibilityObserver!==observer||this.visibilityObserverDocument!==ownerDocument||this.visibilityObserverGeneration!==generation||!this.isConnected||this.ownerDocument!==ownerDocument||this.processHiddenMutations(records)&&(this.reconcileChildVisibilityAndFocus(),this.requestUpdate())});this.visibilityObserver=observer,this.visibilityObserverDocument=ownerDocument}willUpdate(changed){super.willUpdate(changed),this.hasUpdated||this.seedFirstRenderState(()=>{this.childCount=this.children.length}),this.expanded&&!this.hasOverflow&&(this.expanded=!1)}firstUpdated(changed){super.firstUpdated(changed);const slot=this.shadowRoot.querySelector("slot");queueMicrotask(()=>{this.isConnected&&this.updateBrowserDerivedState(()=>{this.childCount=slot.assignedElements({flatten:!0}).length})})}updated(changed){super.updated(changed),this.reconcileChildVisibilityAndFocus()}disconnectedCallback(){this.resetVisibilityObserver(),this.observedChildren.clear(),this.pendingHiddenWrites.clear(),this.trackedChipFocus=void 0,this.restoreChildVisibility(),super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.resetVisibilityObserver(),this.observedChildren.clear(),this.pendingHiddenWrites.clear(),this.trackedChipFocus=void 0}resetVisibilityObserver(){this.visibilityObserverGeneration+=1,this.visibilityObserver?.disconnect(),this.visibilityObserver=void 0,this.visibilityObserverDocument=void 0}get hasOverflow(){const max=this.maxVisible;return max!=null&&this.childCount>0&&this.eligibleChildren().length>max}assignedChildren(){return this.shadowRoot?.querySelector("slot")?.assignedElements({flatten:!0})??Array.from(this.children)}isAuthorHidden(child){return this.authorHidden.get(child)??child.hasAttribute("hidden")}isCapacityEligible(child){return!this.isAuthorHidden(child)&&!child.hasAttribute("inert")}eligibleChildren(children=this.assignedChildren()){return children.filter(child=>this.isCapacityEligible(child))}childWillBeVisible(child,assignedChildren){if(!this.isCapacityEligible(child))return!this.isAuthorHidden(child);const eligibleIndex=this.eligibleChildren(assignedChildren).indexOf(child);return!(this.hasOverflow&&!this.expanded&&eligibleIndex>=this.maxVisible)}focusRepairBeforeVisibility(assignedChildren){const tracked=this.trackedChipFocus;if(!tracked)return null;const currentIndex=assignedChildren.indexOf(tracked.child);if(currentIndex>=0&&this.childWillBeVisible(tracked.child,assignedChildren))return tracked.index=currentIndex,null;const active=deepActiveElementIn(this.ownerDocument),stillOwnsFocus=active!==null&&composedContains(tracked.child,active),focusWasLostWithRemovedBranch=currentIndex<0&&(active===null||active===this.ownerDocument.body||active===this.ownerDocument.documentElement),focusWasLostWithAlreadyHiddenBranch=tracked.child.hasAttribute("hidden")&&(active===null||active===this.ownerDocument.body||active===this.ownerDocument.documentElement);return!stillOwnsFocus&&!focusWasLostWithRemovedBranch&&!focusWasLostWithAlreadyHiddenBranch?null:{index:currentIndex>=0?currentIndex:tracked.index,repair:tracked.repair}}focusTargetAfterVisibility(assignedChildren,originIndex){const chipTargets=assignedChildren.map((child,index)=>({index,target:collectComposedFocusTargets(child,{includeRoot:!1,mode:"programmatic"}).elements[0]})).filter(entry=>entry.target!==void 0).sort((first,second)=>Math.abs(first.index-originIndex)-Math.abs(second.index-originIndex)||first.index-second.index);if(chipTargets[0])return chipTargets[0].target;const disclosure=this.renderRoot.querySelector('[part="overflow-indicator"]');if(disclosure){const available=collectComposedFocusTargets(disclosure,{mode:"programmatic"}).elements[0];if(available)return available}const base=this.renderRoot.querySelector('[part="base"]');return base?collectComposedFocusTargets(base,{mode:"programmatic"}).elements.find(target=>target===base)??null:null}reconcileChildVisibilityAndFocus(){const assignedChildren=this.assignedChildren(),focusRepair=this.focusRepairBeforeVisibility(assignedChildren);if(this.syncChildVisibility(assignedChildren),!focusRepair)return;const candidate=this.focusTargetAfterVisibility(assignedChildren,focusRepair.index);this.trackedChipFocus=void 0,candidate&&applyComposedFocusRepair(focusRepair.repair,candidate)}syncChildVisibility(assignedChildren=this.assignedChildren()){const max=this.maxVisible,overflowing=this.hasOverflow;this.observeChildren(assignedChildren);const current=new Set(assignedChildren);for(const[child,hidden]of this.authorHidden)current.has(child)||(child.toggleAttribute("hidden",hidden),this.authorHidden.delete(child));let eligibleIndex=0;assignedChildren.forEach(element=>{this.authorHidden.has(element)||this.authorHidden.set(element,element.hasAttribute("hidden"));const authored=this.authorHidden.get(element)??!1,eligible=!authored&&!element.hasAttribute("inert"),managed=eligible&&overflowing&&!this.expanded&&eligibleIndex>=max;this.setManagedHidden(element,authored||managed),eligible&&(eligibleIndex+=1)})}observeChildren(children){const next=new Set(children);if(next.size===this.observedChildren.size&&[...next].every(child=>this.observedChildren.has(child)))return;const queued=this.visibilityObserver?.takeRecords()??[];queued.length>0&&this.processHiddenMutations(queued),this.visibilityObserver?.disconnect(),this.observedChildren.clear();for(const child of children)this.visibilityObserver?.observe(child,{attributes:!0,attributeFilter:["hidden","inert"],attributeOldValue:!0}),this.observedChildren.add(child)}processHiddenMutations(records){let authorChanged=!1;for(let index=0;index<records.length;index++){const record=records[index];if(!record||record.type!=="attributes")continue;const child=record.target;if(!this.authorHidden.has(child))continue;if(record.attributeName==="inert"){authorChanged=!0;continue}if(record.attributeName!=="hidden")continue;let nextRecord;for(let nextIndex=index+1;nextIndex<records.length;nextIndex++){const candidate=records[nextIndex];if(candidate?.type==="attributes"&&candidate.attributeName==="hidden"&&candidate.target===child){nextRecord=candidate;break}}const hidden=nextRecord?nextRecord.oldValue!==null:child.hasAttribute("hidden"),pending=this.pendingHiddenWrites.get(child);if(pending?.[0]===hidden){pending.shift(),pending.length===0&&this.pendingHiddenWrites.delete(child);continue}this.authorHidden.set(child,hidden),authorChanged=!0}return authorChanged}setManagedHidden(child,hidden){if(child.hasAttribute("hidden")===hidden)return;let pending=this.pendingHiddenWrites.get(child);pending||(pending=[],this.pendingHiddenWrites.set(child,pending)),pending.push(hidden),child.toggleAttribute("hidden",hidden)}restoreChildVisibility(){for(const[child,hidden]of this.authorHidden)child.toggleAttribute("hidden",hidden);this.authorHidden.clear()}render(){const hasAccessibleLabel=this.hasAttribute("aria-label")||!!this.accessibleLabel,overflowing=this.hasOverflow,hiddenCount=overflowing?this.eligibleChildren().length-this.maxVisible:0,formattedHiddenCount=getNumberFormat(this.effectiveLocale).format(hiddenCount);return html`
1
+ import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{finiteCount}from"../../../internal/numbers.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{deepActiveElementIn}from"../../../internal/active-element.js";import{applyComposedFocusRepair,captureComposedFocusRepair,collectComposedFocusTargets}from"../../../internal/focus-navigation.js";import{composedContains}from"../../../internal/overlay-manager.js";import{styles}from"./chip-group.styles.js";import{LYRA_DEFAULT_showLess,LYRA_DEFAULT_showMoreCollapsed,LYRA_DEFAULT_showMoreCount}from"../../../internal/default-strings/shared.generated.js";class LyraChipGroup extends LyraElement{constructor(){super(...arguments),this.accessibleLabel="",this.childCount=0,this.expanded=!1,this.authorHidden=new Map,this.observedChildren=new Set,this.pendingHiddenWrites=new Map,this.visibilityObserverGeneration=0,this.onSlotChange=e=>{const slot=e.target;this.updateBrowserDerivedState(()=>{this.isConnected&&(this.childCount=slot.assignedElements({flatten:!0}).length,this.requestUpdate())})},this.onFocusIn=()=>{const active=deepActiveElementIn(this.ownerDocument),children=this.assignedChildren(),index=children.findIndex(child2=>composedContains(child2,active)),base=this.renderRoot.querySelector('[part="base"]');if(index<0||!base){this.trackedChipFocus=void 0;return}const child=children[index];if(!("focus"in child)){this.trackedChipFocus=void 0;return}const repair=captureComposedFocusRepair(child,base);this.trackedChipFocus=repair?{child,index,repair}:void 0},this.onFocusOut=()=>{const tracked=this.trackedChipFocus;tracked&&queueMicrotask(()=>{if(this.trackedChipFocus!==tracked)return;const active=deepActiveElementIn(this.ownerDocument);if(active!==null&&composedContains(tracked.child,active))return;!tracked.child.isConnected&&(active===null||active===this.ownerDocument.body||active===this.ownerDocument.documentElement)||(this.trackedChipFocus=void 0)})},this.onToggleOverflow=()=>{this.expanded=!this.expanded,this.emit("lr-overflow-toggle",{expanded:this.expanded})}}static{this.defaultStrings={...super.defaultStrings,showLess:LYRA_DEFAULT_showLess,showMoreCollapsed:LYRA_DEFAULT_showMoreCollapsed,showMoreCount:LYRA_DEFAULT_showMoreCount}}static{this.styles=[LyraElement.styles,styles]}get maxVisible(){return this._maxVisible}set maxVisible(next){const old=this._maxVisible;this._maxVisible=next==null?void 0:finiteCount(next),this.requestUpdate("maxVisible",old)}connectedCallback(){super.connectedCallback(),this.armVisibilityObserver(),this.hasUpdated&&this.reconcileChildVisibilityAndFocus()}armVisibilityObserver(){const ownerDocument=this.ownerDocument;if(!this.isConnected||this.visibilityObserver&&this.visibilityObserverDocument===ownerDocument)return;this.resetVisibilityObserver();const MutationObserverCtor=ownerDocument.defaultView?.MutationObserver;if(!MutationObserverCtor)return;const generation=this.visibilityObserverGeneration,observer=new MutationObserverCtor(records=>{this.visibilityObserver!==observer||this.visibilityObserverDocument!==ownerDocument||this.visibilityObserverGeneration!==generation||!this.isConnected||this.ownerDocument!==ownerDocument||this.processHiddenMutations(records)&&(this.reconcileChildVisibilityAndFocus(),this.requestUpdate())});this.visibilityObserver=observer,this.visibilityObserverDocument=ownerDocument}willUpdate(changed){super.willUpdate(changed),this.hasUpdated||this.seedFirstRenderState(()=>{this.childCount=this.children.length}),this.expanded&&!this.hasOverflow&&(this.expanded=!1)}firstUpdated(changed){super.firstUpdated(changed);const slot=this.shadowRoot.querySelector("slot");queueMicrotask(()=>{this.isConnected&&this.updateBrowserDerivedState(()=>{this.childCount=slot.assignedElements({flatten:!0}).length})})}updated(changed){super.updated(changed),this.reconcileChildVisibilityAndFocus()}disconnectedCallback(){this.resetVisibilityObserver(),this.observedChildren.clear(),this.pendingHiddenWrites.clear(),this.trackedChipFocus=void 0,this.restoreChildVisibility(),super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.resetVisibilityObserver(),this.observedChildren.clear(),this.pendingHiddenWrites.clear(),this.trackedChipFocus=void 0}resetVisibilityObserver(){this.visibilityObserverGeneration+=1,this.visibilityObserver?.disconnect(),this.visibilityObserver=void 0,this.visibilityObserverDocument=void 0}get hasOverflow(){const max=this.maxVisible;return max!=null&&this.childCount>0&&this.eligibleChildren().length>max}assignedChildren(){return this.shadowRoot?.querySelector("slot")?.assignedElements({flatten:!0})??Array.from(this.children)}isAuthorHidden(child){return this.authorHidden.get(child)??child.hasAttribute("hidden")}isCapacityEligible(child){return!this.isAuthorHidden(child)&&!child.hasAttribute("inert")}eligibleChildren(children=this.assignedChildren()){return children.filter(child=>this.isCapacityEligible(child))}childWillBeVisible(child,assignedChildren){if(!this.isCapacityEligible(child))return!this.isAuthorHidden(child);const eligibleIndex=this.eligibleChildren(assignedChildren).indexOf(child);return!(this.hasOverflow&&!this.expanded&&eligibleIndex>=this.maxVisible)}focusRepairBeforeVisibility(assignedChildren){const tracked=this.trackedChipFocus;if(!tracked)return null;const currentIndex=assignedChildren.indexOf(tracked.child);if(currentIndex>=0&&this.childWillBeVisible(tracked.child,assignedChildren))return tracked.index=currentIndex,null;const active=deepActiveElementIn(this.ownerDocument),stillOwnsFocus=active!==null&&composedContains(tracked.child,active),focusWasLostWithRemovedBranch=currentIndex<0&&(active===null||active===this.ownerDocument.body||active===this.ownerDocument.documentElement),focusWasLostWithAlreadyHiddenBranch=tracked.child.hasAttribute("hidden")&&(active===null||active===this.ownerDocument.body||active===this.ownerDocument.documentElement);return!stillOwnsFocus&&!focusWasLostWithRemovedBranch&&!focusWasLostWithAlreadyHiddenBranch?null:{index:currentIndex>=0?currentIndex:tracked.index,repair:tracked.repair}}focusTargetAfterVisibility(assignedChildren,originIndex){const chipTargets=assignedChildren.map((child,index)=>({index,target:collectComposedFocusTargets(child,{includeRoot:!1,mode:"programmatic"}).elements[0]})).filter(entry=>entry.target!==void 0).sort((first,second)=>Math.abs(first.index-originIndex)-Math.abs(second.index-originIndex)||first.index-second.index);if(chipTargets[0])return chipTargets[0].target;const disclosure=this.renderRoot.querySelector('[part="overflow-indicator"]');if(disclosure){const available=collectComposedFocusTargets(disclosure,{mode:"programmatic"}).elements[0];if(available)return available}const base=this.renderRoot.querySelector('[part="base"]');return base?collectComposedFocusTargets(base,{mode:"programmatic"}).elements.find(target=>target===base)??null:null}reconcileChildVisibilityAndFocus(){const assignedChildren=this.assignedChildren(),focusRepair=this.focusRepairBeforeVisibility(assignedChildren);if(this.syncChildVisibility(assignedChildren),!focusRepair)return;const candidate=this.focusTargetAfterVisibility(assignedChildren,focusRepair.index);this.trackedChipFocus=void 0,candidate&&applyComposedFocusRepair(focusRepair.repair,candidate)}syncChildVisibility(assignedChildren=this.assignedChildren()){const max=this.maxVisible,overflowing=this.hasOverflow;this.observeChildren(assignedChildren);const current=new Set(assignedChildren);for(const[child,hidden]of this.authorHidden)current.has(child)||(child.toggleAttribute("hidden",hidden),this.authorHidden.delete(child));let eligibleIndex=0;assignedChildren.forEach(element=>{this.authorHidden.has(element)||this.authorHidden.set(element,element.hasAttribute("hidden"));const authored=this.authorHidden.get(element)??!1,eligible=!authored&&!element.hasAttribute("inert"),managed=eligible&&overflowing&&!this.expanded&&eligibleIndex>=max;this.setManagedHidden(element,authored||managed),eligible&&(eligibleIndex+=1)})}observeChildren(children){const next=new Set(children);if(next.size===this.observedChildren.size&&[...next].every(child=>this.observedChildren.has(child)))return;const queued=this.visibilityObserver?.takeRecords()??[];queued.length>0&&this.processHiddenMutations(queued),this.visibilityObserver?.disconnect(),this.observedChildren.clear();for(const child of children)this.visibilityObserver?.observe(child,{attributes:!0,attributeFilter:["hidden","inert"],attributeOldValue:!0}),this.observedChildren.add(child)}processHiddenMutations(records){let authorChanged=!1;for(let index=0;index<records.length;index++){const record=records[index];if(!record||record.type!=="attributes")continue;const child=record.target;if(!this.authorHidden.has(child))continue;if(record.attributeName==="inert"){authorChanged=!0;continue}if(record.attributeName!=="hidden")continue;let nextRecord;for(let nextIndex=index+1;nextIndex<records.length;nextIndex++){const candidate=records[nextIndex];if(candidate?.type==="attributes"&&candidate.attributeName==="hidden"&&candidate.target===child){nextRecord=candidate;break}}const hidden=nextRecord?nextRecord.oldValue!==null:child.hasAttribute("hidden"),pending=this.pendingHiddenWrites.get(child);if(pending?.[0]===hidden){pending.shift(),pending.length===0&&this.pendingHiddenWrites.delete(child);continue}this.authorHidden.set(child,hidden),authorChanged=!0}return authorChanged}setManagedHidden(child,hidden){if(child.hasAttribute("hidden")===hidden)return;let pending=this.pendingHiddenWrites.get(child);pending||(pending=[],this.pendingHiddenWrites.set(child,pending)),pending.push(hidden),child.toggleAttribute("hidden",hidden)}restoreChildVisibility(){for(const[child,hidden]of this.authorHidden)child.toggleAttribute("hidden",hidden);this.authorHidden.clear()}render(){const hasAccessibleLabel=this.hasAttribute("aria-label")||!!this.accessibleLabel,overflowing=this.hasOverflow,hiddenCount=overflowing?this.eligibleChildren().length-this.maxVisible:0,formattedHiddenCount=getNumberFormat(this.effectiveLocale).format(hiddenCount);return html`
2
2
  <div
3
3
  part="base"
4
4
  tabindex="-1"