@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{GlassScrollLayer}from"../../../internal/glass-scroll-layer.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{live}from"lit/directives/live.js";import{LyraElement}from"../../../internal/lyra-element.js";import{FormAssociated}from"../../../internal/form-associated.js";import{hostAriaLabel,nextId,srOnly}from"../../../internal/a11y.js";import{renderInertPresentation}from"../../../internal/inert-presentation.js";import{deferredPlaceReady as place,loadAnchoredOverlayRuntime}from"../../../internal/anchored-overlay-runtime.js";import{isRtl,rtlAwarePlacement}from"../../../internal/rtl.js";import{literalSetConverter,optionalLiteralSetConverter}from"../../../internal/converters.js";import{resolveEffectivePositioningStrategy}from"../../../internal/positioning-strategy.js";import{activateNonmodalOverlay,composedContains}from"../../../internal/nonmodal-overlay-manager.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{finiteRange}from"../../../internal/numbers.js";import{shadowFocusTarget}from"../../../internal/active-element.js";import{hasCustomState}from"../../../internal/custom-states.js";import{swatchKeyTarget}from"../swatch-picker/swatch-keys.js";import{acquireNativeControlDescription}from"../../../internal/native-control-description.js";import{getOwnDataDescriptor,MISSING_OWN_DATA_DESCRIPTOR,UNSAFE_OWN_DATA_DESCRIPTOR}from"../../../internal/data-descriptors.js";import{eyeIcon}from"../../../internal/icons.js";import{dispatchNativeEvent,dispatchNativeInputEvent}from"../../../internal/native-event-relay.js";import{cssColor,formatColor,hsva,parseColor,withAlphaFormat}from"./color-core.js";import{sizes}from"../../../internal/sizes.styles.js";import{styles}from"./color-picker.styles.js";import{currentValidityValidator}from"../form-validator.js";import{LYRA_DEFAULT_colorPicker,LYRA_DEFAULT_colorPickerCurrentValue,LYRA_DEFAULT_colorPickerEyeDropper,LYRA_DEFAULT_colorPickerHue,LYRA_DEFAULT_colorPickerHueValue,LYRA_DEFAULT_colorPickerOpacity,LYRA_DEFAULT_colorPickerOpacityValue,LYRA_DEFAULT_colorPickerSaturationBrightness,LYRA_DEFAULT_colorPickerSaturationBrightnessValue,LYRA_DEFAULT_colorPickerSwatch,LYRA_DEFAULT_colorPickerSwatches,LYRA_DEFAULT_colorPickerToggleFormat,LYRA_DEFAULT_colorPickerValueField,LYRA_DEFAULT_fieldRequired}from"../../../internal/default-strings.generated.js";const COLOR_FORMAT=literalSetConverter(["hex","rgb","hsl","hsv"],"hex"),normalizeColorFormat=value=>COLOR_FORMAT.normalize(typeof value=="string"?value.toLowerCase().replace(/a$/,""):value),POSITIONING_STRATEGY=optionalLiteralSetConverter(["absolute","fixed"]),SMALL_STEP=1,LARGE_STEP_MULTIPLIER=10,PAGE_KEYS={PageUp:"ArrowUp",PageDown:"ArrowDown"},FORMAT_CYCLE=["hex","rgb","hsl","hsv"],MAX_COLOR_PICKER_SWATCHES=512,EMPTY_COLOR_PICKER_SWATCHES=Object.freeze([]);function projectedSwatch(entry){const parsed=parseColor(entry.color);return Object.freeze({...entry,parsed,css:parsed?cssColor(parsed):"",hexa:parsed?formatColor(parsed,"hexa"):""})}function projectColorPickerSwatches(value){try{if(typeof value=="string")return Object.freeze(value.split(";").slice(0,MAX_COLOR_PICKER_SWATCHES).flatMap(entry=>{const color=entry.trim();return color?[projectedSwatch({color})]:[]}));if(!Array.isArray(value))return EMPTY_COLOR_PICKER_SWATCHES;const length=getOwnDataDescriptor(value,"length");if(length===MISSING_OWN_DATA_DESCRIPTOR||length===UNSAFE_OWN_DATA_DESCRIPTOR||typeof length.value!="number"||!Number.isSafeInteger(length.value)||length.value<0)return EMPTY_COLOR_PICKER_SWATCHES;const swatches=[];for(let index=0;index<Math.min(length.value,MAX_COLOR_PICKER_SWATCHES);index+=1){const entry=getOwnDataDescriptor(value,String(index));if(entry===MISSING_OWN_DATA_DESCRIPTOR||entry===UNSAFE_OWN_DATA_DESCRIPTOR)continue;if(typeof entry.value=="string"){const color2=entry.value.trim();color2&&swatches.push(projectedSwatch({color:color2}));continue}if(entry.value===null||typeof entry.value!="object"||Array.isArray(entry.value))continue;const color=getOwnDataDescriptor(entry.value,"color"),label=getOwnDataDescriptor(entry.value,"label"),disabled=getOwnDataDescriptor(entry.value,"disabled"),icon=getOwnDataDescriptor(entry.value,"icon");if(color===MISSING_OWN_DATA_DESCRIPTOR||color===UNSAFE_OWN_DATA_DESCRIPTOR||typeof color.value!="string"||color.value.trim()==="")continue;const labelValue=label===MISSING_OWN_DATA_DESCRIPTOR||label===UNSAFE_OWN_DATA_DESCRIPTOR?void 0:typeof label.value=="string"&&label.value.trim()?label.value:void 0,disabledValue=disabled===MISSING_OWN_DATA_DESCRIPTOR||disabled===UNSAFE_OWN_DATA_DESCRIPTOR||typeof disabled.value!="boolean"?void 0:disabled.value,iconValue=icon===MISSING_OWN_DATA_DESCRIPTOR||icon===UNSAFE_OWN_DATA_DESCRIPTOR?void 0:icon.value;swatches.push(projectedSwatch({color:color.value.trim(),...labelValue===void 0?{}:{label:labelValue},...disabledValue===void 0?{}:{disabled:disabledValue},...iconValue===void 0?{}:{icon:iconValue}}))}return Object.freeze(swatches)}catch{return EMPTY_COLOR_PICKER_SWATCHES}}function eyeDropperConstructor(ownerWindow){return ownerWindow?.EyeDropper}function isNodeValue(value){if(value===null||typeof value!="object")return!1;const candidate=value;return typeof candidate.nodeType=="number"&&typeof candidate.getRootNode=="function"}function isElementValue(value){return!isNodeValue(value)||value.nodeType!==1?!1:typeof value.matches=="function"}class ColorPickerBase extends LyraElement{}class LyraColorPicker extends FormAssociated(ColorPickerBase){static{this.defaultStrings={...super.defaultStrings,colorPicker:LYRA_DEFAULT_colorPicker,colorPickerCurrentValue:LYRA_DEFAULT_colorPickerCurrentValue,colorPickerEyeDropper:LYRA_DEFAULT_colorPickerEyeDropper,colorPickerHue:LYRA_DEFAULT_colorPickerHue,colorPickerHueValue:LYRA_DEFAULT_colorPickerHueValue,colorPickerOpacity:LYRA_DEFAULT_colorPickerOpacity,colorPickerOpacityValue:LYRA_DEFAULT_colorPickerOpacityValue,colorPickerSaturationBrightness:LYRA_DEFAULT_colorPickerSaturationBrightness,colorPickerSaturationBrightnessValue:LYRA_DEFAULT_colorPickerSaturationBrightnessValue,colorPickerSwatch:LYRA_DEFAULT_colorPickerSwatch,colorPickerSwatches:LYRA_DEFAULT_colorPickerSwatches,colorPickerToggleFormat:LYRA_DEFAULT_colorPickerToggleFormat,colorPickerValueField:LYRA_DEFAULT_colorPickerValueField,fieldRequired:LYRA_DEFAULT_fieldRequired}}static get validators(){return[currentValidityValidator("required","disabled","readonly","value")]}static{this.styles=[LyraElement.styles,srOnly,sizes,styles]}get format(){return this._format}set format(next){const old=this._format;this._format=normalizeColorFormat(next),this.requestUpdate("format",old)}get positioningStrategy(){return this._positioningStrategy??"absolute"}set positioningStrategy(next){const normalized=POSITIONING_STRATEGY.normalize(next)??"absolute",old=this.positioningStrategy;this._positioningStrategy=normalized,normalized!==old&&(this.requestUpdate("positioningStrategy",old),old==="fixed"!=(normalized==="fixed")&&this.requestUpdate("hoist",old==="fixed"))}get hoist(){return this.positioningStrategy==="fixed"}set hoist(next){this.positioningStrategy=next?"fixed":"absolute"}get open(){return this._open}set open(next){const normalized=!!next&&!this.effectiveDisabled&&!this.readonly;if(normalized!==this._open){if(!this.hasRenderedOnce||!this.isConnected){this.applyOpenState(normalized);return}if(this.emit(normalized?"lr-show":"lr-hide",null,{cancelable:!0}).defaultPrevented){this.toggleAttribute("open",this._open);return}this.applyOpenState(normalized)}}applyOpenState(next){const old=this._open;this._open=next,this.requestUpdate("open",old)}get liveDisabled(){return this.effectiveDisabled||typeof this.matches=="function"&&this.matches(":disabled")}syncExternalDescription(){const target=this.isConnected?this.triggerEl():null;if(!target){this.releaseExternalDescription();return}this.externalDescriptionLease?this.externalDescriptionLease.update(target):this.externalDescriptionLease=acquireNativeControlDescription(this,target,()=>this.localDescriptionIds)}releaseExternalDescription(){this.externalDescriptionLease?.release(),this.externalDescriptionLease=void 0}constructor(){super(),this.label="",this.hint="",this.withLabel=!1,this.withHint=!1,this.errorText="",this.accessibleLabel="",this.readonly=!1,this.size="m",this._format="hex",this.opacity=!1,this.uppercase=!1,this.swatches="",this.withoutFormatToggle=!1,this.noFormatToggle=!1,this.inline=!1,this.placement="bottom-start",this._open=!1,this.hasLabel=!1,this.hasHint=!1,this.hasError=!1,this.hasEyeDropper=!1,this.color=hsva(0,0,0,1),this.valueNeedsParse=!1,this.localDescriptionIds="",this.hintId=nextId("color-picker-hint"),this.errorId=nextId("color-picker-error"),this.labelId=nextId("color-picker-label"),this.valueTextId=nextId("color-picker-value"),this.triggerId=nextId("color-picker-trigger"),this.panelId=nextId("color-picker-panel"),this.dragChanged=!1,this.keyboardChanged=!1,this.restoreFocusOnClose=!0,this.eyeDropperGeneration=0,this.suppressDisconnectedClose=!1,this.pendingPlacementEffects=0,this.interactionGeneration=0,this.hasRenderedOnce=!1,this.projectedSwatches=EMPTY_COLOR_PICKER_SWATCHES,this.onDocumentPointerDown=event=>{const target=event.composedPath()[0];if(!(isElementValue(target)&&composedContains(this,target))){if(this.overlayHandle?.isActive()){this.overlayHandle.dismissBackdrop();return}this.restoreFocusOnClose=!1,this.hide()}},this.onTriggerClick=()=>{this.effectiveDisabled||(this.open=!this.open)},this.onPointerMove=event=>{if(this.drag?.pointerId===event.pointerId){if(this.effectiveDisabled||this.readonly){this.cancelDrag();return}this.applyPointer(event)}},this.onPointerUp=event=>{if(this.drag?.pointerId!==event.pointerId)return;if(this.effectiveDisabled||this.readonly){this.cancelDrag();return}this.applyPointer(event);const changed=this.dragChanged;this.endDrag(),changed&&this.emitCommit()},this.onPointerCancel=event=>{this.drag?.pointerId===event.pointerId&&this.cancelDrag()},this.onGridKeyDown=event=>{if(this.effectiveDisabled||this.readonly)return;const key=PAGE_KEYS[event.key]??event.key,step=SMALL_STEP*(event.shiftKey||key!==event.key?LARGE_STEP_MULTIPLIER:1),inline=this.inlineStep(event);let next;inline!==null?next=hsva(this.color.h,this.color.s+inline,this.color.v,this.color.a):key==="ArrowUp"?next=hsva(this.color.h,this.color.s,this.color.v+step,this.color.a):key==="ArrowDown"?next=hsva(this.color.h,this.color.s,this.color.v-step,this.color.a):event.key==="Home"?next=hsva(this.color.h,0,this.color.v,this.color.a):event.key==="End"&&(next=hsva(this.color.h,100,this.color.v,this.color.a)),next&&(event.preventDefault(),this.applyKeyboardColor(next))},this.onHueKeyDown=event=>{if(this.effectiveDisabled||this.readonly)return;const key=PAGE_KEYS[event.key]??event.key,step=SMALL_STEP*(event.shiftKey||key!==event.key?LARGE_STEP_MULTIPLIER:1),inline=this.inlineStep(event);let hue;inline!==null?hue=this.color.h+inline:key==="ArrowUp"?hue=this.color.h+step:key==="ArrowDown"?hue=this.color.h-step:event.key==="Home"?hue=0:event.key==="End"&&(hue=360),hue!==void 0&&(event.preventDefault(),this.applyKeyboardColor(hsva(finiteRange(hue,0,0,360),this.color.s,this.color.v,this.color.a)))},this.onAlphaKeyDown=event=>{if(this.effectiveDisabled||this.readonly)return;const key=PAGE_KEYS[event.key]??event.key,step=SMALL_STEP*(event.shiftKey||key!==event.key?LARGE_STEP_MULTIPLIER:1)/100,inline=this.inlineStep(event);let alpha;inline!==null?alpha=this.color.a+inline/100:key==="ArrowUp"?alpha=this.color.a+step:key==="ArrowDown"?alpha=this.color.a-step:event.key==="Home"?alpha=0:event.key==="End"&&(alpha=1),alpha!==void 0&&(event.preventDefault(),this.applyKeyboardColor(hsva(this.color.h,this.color.s,this.color.v,alpha)))},this.onControlKeyUp=()=>{this.keyboardChanged&&(this.keyboardChanged=!1,this.emitCommit())},this.onFieldInput=event=>{if(event.stopPropagation(),this.liveDisabled||this.readonly){this.pendingInput=void 0,this.requestUpdate();return}this.pendingInput=event.target.value},this.onFieldChange=event=>{event.stopPropagation();const field=event.target;if(this.liveDisabled||this.readonly){this.pendingInput=void 0,this.requestUpdate();return}const parsed=parseColor(field.value);parsed&&this.commitColor(parsed),this.pendingInput=void 0,this.requestUpdate()},this.onFieldKeyDown=event=>{this.liveDisabled||this.readonly||event.key==="Enter"&&(event.preventDefault(),this.onFieldChange(event))},this.onFormatClick=()=>{if(this.liveDisabled)return;const index=FORMAT_CYCLE.indexOf(this.format);this.format=FORMAT_CYCLE[(index+1)%FORMAT_CYCLE.length]},this.onEyeDropperClick=()=>{const ownerWindow=this.ownerDocument.defaultView;if(!this.isConnected||!ownerWindow)return;const Constructor=eyeDropperConstructor(ownerWindow);if(!Constructor||this.effectiveDisabled||this.readonly)return;this.cancelEyeDropper();const generation=this.eyeDropperGeneration,controller=new ownerWindow.AbortController;this.eyeDropperAbort=controller,new Constructor().open({signal:controller.signal}).then(result=>{if(controller.signal.aborted||generation!==this.eyeDropperGeneration||!this.isConnected||this.ownerDocument.defaultView!==ownerWindow||this.effectiveDisabled||this.readonly)return;const parsed=parseColor(result?.sRGBHex??"");parsed&&this.commitColor(this.opacity?hsva(parsed.h,parsed.s,parsed.v,this.color.a):parsed)}).catch(()=>{}).finally(()=>{generation===this.eyeDropperGeneration&&(this.eyeDropperAbort=void 0)})},this.onControlFocus=event=>{event.stopPropagation();const previous=event.relatedTarget;isNodeValue(previous)&&this.renderRoot.contains(previous)||relayNativeEvent(this,event)},this.onControlBlur=event=>{event.stopPropagation();const next=event.relatedTarget;isNodeValue(next)&&this.renderRoot.contains(next)||(relayNativeEvent(this,event),this.requestUpdate())},this.controlFocusListener={capture:!0,handleEvent:event=>this.onControlFocus(event)},this.controlBlurListener={capture:!0,handleEvent:event=>this.onControlBlur(event)},this.onSlotChange=event=>{const slot=event.target,assigned=Array.from(this.children).some(el=>el.getAttribute("slot")===slot.name);slot.name==="label"&&(this.hasLabel=assigned),slot.name==="hint"&&(this.hasHint=assigned),slot.name==="error"&&(this.hasError=assigned)},this.onSwatchKeyDown=event=>{if(this.liveDisabled||this.readonly)return;const entries=this.normalizedSwatches(),origin=Number(event.target.dataset.index);if(!Number.isInteger(origin))return;const target=swatchKeyTarget(event.key,origin,entries.length,index=>entries[index].disabled===!0,isRtl(this));target<0||(event.preventDefault(),this.onSwatchClick(entries[target]),this.renderRoot.querySelectorAll('[part~="swatch"]')[target]?.focus())},new GlassScrollLayer(this,'[part~="panel"]',()=>!this.inline&&this.open),this.addEventListener("focusout",()=>this.requestUpdate())}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.syncExternalDescription();const seedEnvironmentState=()=>{const hasSlot=name=>Array.from(this.children).some(el=>el.getAttribute("slot")===name);this.hasLabel=hasSlot("label"),this.hasHint=hasSlot("hint"),this.hasError=hasSlot("error"),this.hasEyeDropper=!!eyeDropperConstructor(this.ownerDocument.defaultView)};this.hasUpdated?seedEnvironmentState():this.seedFirstRenderState(seedEnvironmentState)}disconnectedCallback(){this.releaseExternalDescription(),this.suppressDisconnectedClose=this.open,this.open=!1,this.teardownOverlay(!1),this.cancelEyeDropper(),this.interactionGeneration+=1,this.keyboardChanged=!1,this.cancelDrag(),super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.releaseExternalDescription(),this.isConnected&&this.hasUpdated&&this.syncExternalDescription(),this.cancelDrag(),this.cancelEyeDropper()}get value(){return super.value}set value(next){this.endDrag(),super.value=next??"",this.valueNeedsParse=!0}willUpdate(changed){super.willUpdate(changed);const formatChanged=changed.has("format")||changed.has("opacity")||changed.has("uppercase");if(formatChanged&&this.cancelDrag(),(this.liveDisabled||this.readonly)&&(this.open&&this.applyOpenState(!1),this.pendingInput=void 0,this.keyboardChanged=!1,this.cancelDrag()),!this.valueNeedsParse&&!formatChanged)return;const shouldReserialize=formatChanged;if(this.valueNeedsParse){this.valueNeedsParse=!1;const parsed=parseColor(super.value);if(parsed){this.color=parsed,this.writeSerializedValue();return}}shouldReserialize&&parseColor(super.value)!==null&&this.writeSerializedValue()}updated(changed){if(super.updated(changed),this.syncExternalDescription(),changed.has("readonly")&&this.checkValidity(),changed.has("open")){const suppressClose=!this.open&&this.suppressDisconnectedClose;this.suppressDisconnectedClose=!1;const announceOpen=this.open&&this.hasRenderedOnce&&this.isConnected;this.open&&!this.inline?(this.pendingPlacementEffects=announceOpen?3:2,this.activatePanel()):(this.pendingPlacementEffects=0,this.teardownOverlay(this.restoreFocusOnClose),this.pendingInput=void 0),this.hasRenderedOnce&&this.isConnected&&!suppressClose&&(this.open&&this.inline?this.emit("lr-after-show"):this.open||this.emit("lr-after-hide"))}else if(changed.has("inline"))if(this.inline){this.teardownOverlay();const panel=this.panelEl();panel?.style.removeProperty("position"),panel?.hasAttribute("data-lr-top-layer")&&loadAnchoredOverlayRuntime().then(runtime=>runtime.releaseTopLayer?.(panel),()=>{});const announceOpen=(this.pendingPlacementEffects&1)!==0;this.pendingPlacementEffects=0,announceOpen&&this.emit("lr-after-show")}else this.open&&this.activatePanel();else this.open&&!this.inline&&(changed.has("placement")||changed.has("size")||changed.has("positioningStrategy"))&&this.positionPanel();this.hasRenderedOnce=!0}show(){this.open=!0}hide(){this.open=!1}getFormattedValue(format="hex"){return formatColor(this.color,format,this.uppercase)}getHexString(hue,saturation,brightness,alpha=100){const normalizedAlpha=finiteRange(alpha,100,0,100);return formatColor(hsva(hue,saturation,brightness,normalizedAlpha/100),normalizedAlpha<100?"hexa":"hex",this.uppercase)}click(){this.effectiveDisabled||(this.inline?this.renderRoot?.querySelector('[part~="input"]')?.click():this.triggerEl()?.click())}focus(options){this.effectiveDisabled||(this.inline?this.renderRoot?.querySelector('[part~="grid-handle"]')?.focus(options):this.triggerEl()?.focus(options))}blur(){const active=shadowFocusTarget(this);active&&typeof active.blur=="function"&&active.blur()}reportValidity(){const valid=super.reportValidity();return this.requestUpdate(),valid}setCustomValidity(message){super.setCustomValidity(message),this.requestUpdate()}resetValidity(){super.resetValidity(),this.requestUpdate()}activeFormat(){return withAlphaFormat(this.format,this.opacity)}writeSerializedValue(){const serialized=formatColor(this.color,this.activeFormat(),this.uppercase);return serialized===super.value?!1:(super.value=serialized,!0)}applyColor(next){next.h===this.color.h&&next.s===this.color.s&&next.v===this.color.v&&next.a===this.color.a||(this.color=next);const changed=this.writeSerializedValue();return changed&&(dispatchNativeInputEvent(this),this.emit("lr-input",{value:this.value})),changed}emitCommit(){dispatchNativeEvent(this,"change"),this.emit("lr-change",{value:this.value})}commitColor(next){const changed=this.applyColor(next);return changed&&this.emitCommit(),changed}normalizedSwatches(){const source=this.swatches;return source!==this.swatchSource&&(this.swatchSource=source,this.projectedSwatches=projectColorPickerSwatches(source)),this.projectedSwatches}triggerEl(){return this.renderRoot?.querySelector('[part~="trigger"]')}panelEl(){return this.renderRoot?.querySelector('[part~="panel"]')}positionPanel(){this.cleanupPositioner?.(),this.cleanupPositioner=void 0;const anchor=this.triggerEl(),panel=this.panelEl();if(!anchor||!panel)return;const handle=place(anchor,panel,{placement:rtlAwarePlacement(this.placement,this),strategy:resolveEffectivePositioningStrategy(this,this._positioningStrategy,"absolute")});this.cleanupPositioner=handle,handle.ready.then(positioned=>{if(this.cleanupPositioner!==handle||!this.open||this.inline||!this.isConnected)return;if(!positioned){this.pendingPlacementEffects=0,this.suppressDisconnectedClose=!0,this.applyOpenState(!1);return}const effects=this.pendingPlacementEffects;this.pendingPlacementEffects=0,effects&2&&this.overlayHandle?.focusInitial(),effects&1&&this.emit("lr-after-show")})}activatePanel(){!this.isConnected||this.inline||(this.pendingPlacementEffects|=2,this.positionPanel(),this.restoreFocusOnClose=!0,this.overlayHandle=activateNonmodalOverlay({host:this,panel:()=>this.panelEl(),onEscape:()=>this.hide(),onBackdrop:()=>{this.restoreFocusOnClose=!1,this.hide(),this.open&&(this.restoreFocusOnClose=!0)},restoreFocusTo:this.triggerEl()}),this.lightDismissDocument=this.ownerDocument,this.lightDismissDocument.addEventListener("pointerdown",this.onDocumentPointerDown,!0))}teardownOverlay(restoreFocus=!0){this.cleanupPositioner?.(),this.cleanupPositioner=void 0,this.overlayHandle?.deactivate({restoreFocus}),this.overlayHandle=void 0,this.lightDismissDocument?.removeEventListener("pointerdown",this.onDocumentPointerDown,!0),this.lightDismissDocument=void 0,this.restoreFocusOnClose=!0}beginDrag(event,track,box){const dragWindow=box.ownerDocument.defaultView;if(!this.isConnected||!dragWindow||this.effectiveDisabled||this.readonly||this.drag!==void 0||event.pointerType==="mouse"&&event.button!==0)return;const rect=box.getBoundingClientRect();this.drag={pointerId:event.pointerId,track,rect,rtl:isRtl(this),startColor:{...this.color},startValue:this.captureLiveValueCheckpoint()},this.dragChanged=!1;try{box.setPointerCapture(event.pointerId)}catch{}this.dragWindow=dragWindow,dragWindow.addEventListener("pointermove",this.onPointerMove),dragWindow.addEventListener("pointerup",this.onPointerUp),dragWindow.addEventListener("pointercancel",this.onPointerCancel),dragWindow.addEventListener("lostpointercapture",this.onPointerCancel),this.applyPointer(event)}applyPointer(event){const drag=this.drag;if(!drag)return;const{rect,rtl,track}=drag,rawX=rect.width===0?0:(event.clientX-rect.left)/rect.width,ratioX=finiteRange(rtl?1-rawX:rawX,0,0,1);let next;if(track==="grid"){const rawY=rect.height===0?0:(event.clientY-rect.top)/rect.height,ratioY=finiteRange(rawY,0,0,1);next=hsva(this.color.h,ratioX*100,(1-ratioY)*100,this.color.a)}else track==="hue"?next=hsva(ratioX*360,this.color.s,this.color.v,this.color.a):next=hsva(this.color.h,this.color.s,this.color.v,ratioX);this.dragChanged=this.applyColor(next)||this.dragChanged}cancelDrag(){const drag=this.drag;drag&&(this.endDrag(),this.color=drag.startColor,this.restoreLiveValueCheckpoint(drag.startValue),this.valueNeedsParse=!1)}endDrag(){this.drag=void 0,this.dragChanged=!1;const dragWindow=this.dragWindow;this.dragWindow=void 0,dragWindow?.removeEventListener("pointermove",this.onPointerMove),dragWindow?.removeEventListener("pointerup",this.onPointerUp),dragWindow?.removeEventListener("pointercancel",this.onPointerCancel),dragWindow?.removeEventListener("lostpointercapture",this.onPointerCancel)}inlineStep(event){const rtl=isRtl(this),forward=rtl?"ArrowLeft":"ArrowRight",backward=rtl?"ArrowRight":"ArrowLeft",step=SMALL_STEP*(event.shiftKey?LARGE_STEP_MULTIPLIER:1);return event.key===forward?step:event.key===backward?-step:null}applyKeyboardColor(next){const generation=this.interactionGeneration,changed=this.applyColor(next);generation===this.interactionGeneration&&(this.keyboardChanged=changed||this.keyboardChanged)}onSwatchClick(swatch){if(this.liveDisabled||this.readonly||swatch.disabled)return;const parsed=swatch.parsed;parsed&&this.commitColor(this.opacity?parsed:hsva(parsed.h,parsed.s,parsed.v,1))}cancelEyeDropper(){this.eyeDropperGeneration+=1,this.eyeDropperAbort?.abort(),this.eyeDropperAbort=void 0}formatNumber(value){return getNumberFormat(this.effectiveLocale,{maximumFractionDigits:0}).format(value)}renderGrid(){const saturation=Math.round(this.color.s),brightness=Math.round(this.color.v);return html`<div
1
+ import{__decorate}from"tslib";import{GlassScrollLayer}from"../../../internal/glass-scroll-layer.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{live}from"lit/directives/live.js";import{LyraElement}from"../../../internal/lyra-element.js";import{FormAssociated}from"../../../internal/form-associated.js";import{hostAriaLabel,nextId,srOnly}from"../../../internal/a11y.js";import{renderInertPresentation}from"../../../internal/inert-presentation.js";import{deferredPlaceReady as place,loadAnchoredOverlayRuntime}from"../../../internal/anchored-overlay-runtime.js";import{isRtl,rtlAwarePlacement}from"../../../internal/rtl.js";import{literalSetConverter,optionalLiteralSetConverter}from"../../../internal/converters.js";import{resolveEffectivePositioningStrategy}from"../../../internal/positioning-strategy.js";import{activateNonmodalOverlay,composedContains}from"../../../internal/nonmodal-overlay-manager.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{finiteRange}from"../../../internal/numbers.js";import{shadowFocusTarget}from"../../../internal/active-element.js";import{hasCustomState}from"../../../internal/custom-states.js";import{swatchKeyTarget}from"../swatch-picker/swatch-keys.js";import{acquireNativeControlDescription}from"../../../internal/native-control-description.js";import{getOwnDataDescriptor,MISSING_OWN_DATA_DESCRIPTOR,UNSAFE_OWN_DATA_DESCRIPTOR}from"../../../internal/data-descriptors.js";import{eyeIcon}from"../../../internal/icons.js";import{dispatchNativeEvent,dispatchNativeInputEvent}from"../../../internal/native-event-relay.js";import{cssColor,formatColor,hsva,parseColor,withAlphaFormat}from"./color-core.js";import{sizes}from"../../../internal/sizes.styles.js";import{styles}from"./color-picker.styles.js";import{currentValidityValidator}from"../form-validator.js";import{LYRA_DEFAULT_colorPicker,LYRA_DEFAULT_colorPickerCurrentValue,LYRA_DEFAULT_colorPickerEyeDropper,LYRA_DEFAULT_colorPickerHue,LYRA_DEFAULT_colorPickerHueValue,LYRA_DEFAULT_colorPickerOpacity,LYRA_DEFAULT_colorPickerOpacityValue,LYRA_DEFAULT_colorPickerSaturationBrightness,LYRA_DEFAULT_colorPickerSaturationBrightnessValue,LYRA_DEFAULT_colorPickerSwatch,LYRA_DEFAULT_colorPickerSwatches,LYRA_DEFAULT_colorPickerToggleFormat,LYRA_DEFAULT_colorPickerValueField}from"../../../internal/default-strings/forms.generated.js";import{LYRA_DEFAULT_fieldRequired}from"../../../internal/default-strings/shared.generated.js";const COLOR_FORMAT=literalSetConverter(["hex","rgb","hsl","hsv"],"hex"),normalizeColorFormat=value=>COLOR_FORMAT.normalize(typeof value=="string"?value.toLowerCase().replace(/a$/,""):value),POSITIONING_STRATEGY=optionalLiteralSetConverter(["absolute","fixed"]),SMALL_STEP=1,LARGE_STEP_MULTIPLIER=10,PAGE_KEYS={PageUp:"ArrowUp",PageDown:"ArrowDown"},FORMAT_CYCLE=["hex","rgb","hsl","hsv"],MAX_COLOR_PICKER_SWATCHES=512,EMPTY_COLOR_PICKER_SWATCHES=Object.freeze([]);function projectedSwatch(entry){const parsed=parseColor(entry.color);return Object.freeze({...entry,parsed,css:parsed?cssColor(parsed):"",hexa:parsed?formatColor(parsed,"hexa"):""})}function projectColorPickerSwatches(value){try{if(typeof value=="string")return Object.freeze(value.split(";").slice(0,MAX_COLOR_PICKER_SWATCHES).flatMap(entry=>{const color=entry.trim();return color?[projectedSwatch({color})]:[]}));if(!Array.isArray(value))return EMPTY_COLOR_PICKER_SWATCHES;const length=getOwnDataDescriptor(value,"length");if(length===MISSING_OWN_DATA_DESCRIPTOR||length===UNSAFE_OWN_DATA_DESCRIPTOR||typeof length.value!="number"||!Number.isSafeInteger(length.value)||length.value<0)return EMPTY_COLOR_PICKER_SWATCHES;const swatches=[];for(let index=0;index<Math.min(length.value,MAX_COLOR_PICKER_SWATCHES);index+=1){const entry=getOwnDataDescriptor(value,String(index));if(entry===MISSING_OWN_DATA_DESCRIPTOR||entry===UNSAFE_OWN_DATA_DESCRIPTOR)continue;if(typeof entry.value=="string"){const color2=entry.value.trim();color2&&swatches.push(projectedSwatch({color:color2}));continue}if(entry.value===null||typeof entry.value!="object"||Array.isArray(entry.value))continue;const color=getOwnDataDescriptor(entry.value,"color"),label=getOwnDataDescriptor(entry.value,"label"),disabled=getOwnDataDescriptor(entry.value,"disabled"),icon=getOwnDataDescriptor(entry.value,"icon");if(color===MISSING_OWN_DATA_DESCRIPTOR||color===UNSAFE_OWN_DATA_DESCRIPTOR||typeof color.value!="string"||color.value.trim()==="")continue;const labelValue=label===MISSING_OWN_DATA_DESCRIPTOR||label===UNSAFE_OWN_DATA_DESCRIPTOR?void 0:typeof label.value=="string"&&label.value.trim()?label.value:void 0,disabledValue=disabled===MISSING_OWN_DATA_DESCRIPTOR||disabled===UNSAFE_OWN_DATA_DESCRIPTOR||typeof disabled.value!="boolean"?void 0:disabled.value,iconValue=icon===MISSING_OWN_DATA_DESCRIPTOR||icon===UNSAFE_OWN_DATA_DESCRIPTOR?void 0:icon.value;swatches.push(projectedSwatch({color:color.value.trim(),...labelValue===void 0?{}:{label:labelValue},...disabledValue===void 0?{}:{disabled:disabledValue},...iconValue===void 0?{}:{icon:iconValue}}))}return Object.freeze(swatches)}catch{return EMPTY_COLOR_PICKER_SWATCHES}}function eyeDropperConstructor(ownerWindow){return ownerWindow?.EyeDropper}function isNodeValue(value){if(value===null||typeof value!="object")return!1;const candidate=value;return typeof candidate.nodeType=="number"&&typeof candidate.getRootNode=="function"}function isElementValue(value){return!isNodeValue(value)||value.nodeType!==1?!1:typeof value.matches=="function"}class ColorPickerBase extends LyraElement{}class LyraColorPicker extends FormAssociated(ColorPickerBase){static{this.defaultStrings={...super.defaultStrings,colorPicker:LYRA_DEFAULT_colorPicker,colorPickerCurrentValue:LYRA_DEFAULT_colorPickerCurrentValue,colorPickerEyeDropper:LYRA_DEFAULT_colorPickerEyeDropper,colorPickerHue:LYRA_DEFAULT_colorPickerHue,colorPickerHueValue:LYRA_DEFAULT_colorPickerHueValue,colorPickerOpacity:LYRA_DEFAULT_colorPickerOpacity,colorPickerOpacityValue:LYRA_DEFAULT_colorPickerOpacityValue,colorPickerSaturationBrightness:LYRA_DEFAULT_colorPickerSaturationBrightness,colorPickerSaturationBrightnessValue:LYRA_DEFAULT_colorPickerSaturationBrightnessValue,colorPickerSwatch:LYRA_DEFAULT_colorPickerSwatch,colorPickerSwatches:LYRA_DEFAULT_colorPickerSwatches,colorPickerToggleFormat:LYRA_DEFAULT_colorPickerToggleFormat,colorPickerValueField:LYRA_DEFAULT_colorPickerValueField,fieldRequired:LYRA_DEFAULT_fieldRequired}}static get validators(){return[currentValidityValidator("required","disabled","readonly","value")]}static{this.styles=[LyraElement.styles,srOnly,sizes,styles]}get readonly(){return this._readonly}set readonly(next){const previous=this._readonly;this._readonly=!!next,this._readonly&&this.cancelEyeDropper(),this.requestUpdate("readonly",previous)}get format(){return this._format}set format(next){const old=this._format;this._format=normalizeColorFormat(next),this.requestUpdate("format",old)}get positioningStrategy(){return this._positioningStrategy??"absolute"}set positioningStrategy(next){const normalized=POSITIONING_STRATEGY.normalize(next)??"absolute",old=this.positioningStrategy;this._positioningStrategy=normalized,normalized!==old&&(this.requestUpdate("positioningStrategy",old),old==="fixed"!=(normalized==="fixed")&&this.requestUpdate("hoist",old==="fixed"))}get hoist(){return this.positioningStrategy==="fixed"}set hoist(next){this.positioningStrategy=next?"fixed":"absolute"}get open(){return this._open}set open(next){const normalized=!!next&&!this.effectiveDisabled&&!this.readonly;if(normalized!==this._open){if(!this.hasRenderedOnce||!this.isConnected){this.applyOpenState(normalized);return}if(this.emit(normalized?"lr-show":"lr-hide",null,{cancelable:!0}).defaultPrevented){this.toggleAttribute("open",this._open);return}this.applyOpenState(normalized)}}applyOpenState(next){const old=this._open;this._open=next,this.requestUpdate("open",old)}get liveDisabled(){return this.effectiveDisabled||typeof this.matches=="function"&&this.matches(":disabled")}syncExternalDescription(){const target=this.isConnected?this.triggerEl():null;if(!target){this.releaseExternalDescription();return}this.externalDescriptionLease?this.externalDescriptionLease.update(target):this.externalDescriptionLease=acquireNativeControlDescription(this,target,()=>this.localDescriptionIds)}releaseExternalDescription(){this.externalDescriptionLease?.release(),this.externalDescriptionLease=void 0}constructor(){super(),this.label="",this.hint="",this.withLabel=!1,this.withHint=!1,this.errorText="",this.accessibleLabel="",this._readonly=!1,this.size="m",this._format="hex",this.opacity=!1,this.uppercase=!1,this.swatches="",this.withoutFormatToggle=!1,this.noFormatToggle=!1,this.inline=!1,this.placement="bottom-start",this._open=!1,this.hasLabel=!1,this.hasHint=!1,this.hasError=!1,this.hasEyeDropper=!1,this.color=hsva(0,0,0,1),this.valueNeedsParse=!1,this.localDescriptionIds="",this.hintId=nextId("color-picker-hint"),this.errorId=nextId("color-picker-error"),this.labelId=nextId("color-picker-label"),this.valueTextId=nextId("color-picker-value"),this.triggerId=nextId("color-picker-trigger"),this.panelId=nextId("color-picker-panel"),this.dragChanged=!1,this.keyboardChanged=!1,this.restoreFocusOnClose=!0,this.eyeDropperGeneration=0,this.suppressDisconnectedClose=!1,this.pendingPlacementEffects=0,this.interactionGeneration=0,this.hasRenderedOnce=!1,this.projectedSwatches=EMPTY_COLOR_PICKER_SWATCHES,this.onDocumentPointerDown=event=>{const target=event.composedPath()[0];if(!(isElementValue(target)&&composedContains(this,target))){if(this.overlayHandle?.isActive()){this.overlayHandle.dismissBackdrop();return}this.restoreFocusOnClose=!1,this.hide()}},this.onTriggerClick=()=>{this.effectiveDisabled||(this.open=!this.open)},this.onPointerMove=event=>{if(this.drag?.pointerId===event.pointerId){if(this.effectiveDisabled||this.readonly){this.cancelDrag();return}this.applyPointer(event)}},this.onPointerUp=event=>{if(this.drag?.pointerId!==event.pointerId)return;if(this.effectiveDisabled||this.readonly){this.cancelDrag();return}this.applyPointer(event);const changed=this.dragChanged;this.endDrag(),changed&&this.emitCommit()},this.onPointerCancel=event=>{this.drag?.pointerId===event.pointerId&&this.cancelDrag()},this.onGridKeyDown=event=>{if(this.effectiveDisabled||this.readonly)return;const key=PAGE_KEYS[event.key]??event.key,step=SMALL_STEP*(event.shiftKey||key!==event.key?LARGE_STEP_MULTIPLIER:1),inline=this.inlineStep(event);let next;inline!==null?next=hsva(this.color.h,this.color.s+inline,this.color.v,this.color.a):key==="ArrowUp"?next=hsva(this.color.h,this.color.s,this.color.v+step,this.color.a):key==="ArrowDown"?next=hsva(this.color.h,this.color.s,this.color.v-step,this.color.a):event.key==="Home"?next=hsva(this.color.h,0,this.color.v,this.color.a):event.key==="End"&&(next=hsva(this.color.h,100,this.color.v,this.color.a)),next&&(event.preventDefault(),this.applyKeyboardColor(next))},this.onHueKeyDown=event=>{if(this.effectiveDisabled||this.readonly)return;const key=PAGE_KEYS[event.key]??event.key,step=SMALL_STEP*(event.shiftKey||key!==event.key?LARGE_STEP_MULTIPLIER:1),inline=this.inlineStep(event);let hue;inline!==null?hue=this.color.h+inline:key==="ArrowUp"?hue=this.color.h+step:key==="ArrowDown"?hue=this.color.h-step:event.key==="Home"?hue=0:event.key==="End"&&(hue=360),hue!==void 0&&(event.preventDefault(),this.applyKeyboardColor(hsva(finiteRange(hue,0,0,360),this.color.s,this.color.v,this.color.a)))},this.onAlphaKeyDown=event=>{if(this.effectiveDisabled||this.readonly)return;const key=PAGE_KEYS[event.key]??event.key,step=SMALL_STEP*(event.shiftKey||key!==event.key?LARGE_STEP_MULTIPLIER:1)/100,inline=this.inlineStep(event);let alpha;inline!==null?alpha=this.color.a+inline/100:key==="ArrowUp"?alpha=this.color.a+step:key==="ArrowDown"?alpha=this.color.a-step:event.key==="Home"?alpha=0:event.key==="End"&&(alpha=1),alpha!==void 0&&(event.preventDefault(),this.applyKeyboardColor(hsva(this.color.h,this.color.s,this.color.v,alpha)))},this.onControlKeyUp=()=>{this.keyboardChanged&&(this.keyboardChanged=!1,this.emitCommit())},this.onFieldInput=event=>{if(event.stopPropagation(),this.liveDisabled||this.readonly){this.pendingInput=void 0,this.requestUpdate();return}this.pendingInput=event.target.value},this.onFieldChange=event=>{event.stopPropagation();const field=event.target;if(this.liveDisabled||this.readonly){this.pendingInput=void 0,this.requestUpdate();return}const parsed=parseColor(field.value);parsed&&this.commitColor(parsed),this.pendingInput=void 0,this.requestUpdate()},this.onFieldKeyDown=event=>{this.liveDisabled||this.readonly||event.key==="Enter"&&(event.preventDefault(),this.onFieldChange(event))},this.onFormatClick=()=>{if(this.liveDisabled)return;const index=FORMAT_CYCLE.indexOf(this.format);this.format=FORMAT_CYCLE[(index+1)%FORMAT_CYCLE.length]},this.onEyeDropperClick=()=>{const ownerWindow=this.ownerDocument.defaultView;if(!this.isConnected||!ownerWindow)return;const Constructor=eyeDropperConstructor(ownerWindow);if(!Constructor||this.effectiveDisabled||this.readonly)return;this.cancelEyeDropper();const generation=this.eyeDropperGeneration,controller=new ownerWindow.AbortController;this.eyeDropperAbort=controller,new Constructor().open({signal:controller.signal}).then(result=>{if(controller.signal.aborted||generation!==this.eyeDropperGeneration||!this.isConnected||this.ownerDocument.defaultView!==ownerWindow||this.effectiveDisabled||this.readonly)return;const parsed=parseColor(result?.sRGBHex??"");parsed&&this.commitColor(this.opacity?hsva(parsed.h,parsed.s,parsed.v,this.color.a):parsed)}).catch(()=>{}).finally(()=>{generation===this.eyeDropperGeneration&&(this.eyeDropperAbort=void 0)})},this.onControlFocus=event=>{event.stopPropagation();const previous=event.relatedTarget;isNodeValue(previous)&&this.renderRoot.contains(previous)||relayNativeEvent(this,event)},this.onControlBlur=event=>{event.stopPropagation();const next=event.relatedTarget;isNodeValue(next)&&this.renderRoot.contains(next)||(relayNativeEvent(this,event),this.requestUpdate())},this.controlFocusListener={capture:!0,handleEvent:event=>this.onControlFocus(event)},this.controlBlurListener={capture:!0,handleEvent:event=>this.onControlBlur(event)},this.onSlotChange=event=>{const slot=event.target,assigned=Array.from(this.children).some(el=>el.getAttribute("slot")===slot.name);slot.name==="label"&&(this.hasLabel=assigned),slot.name==="hint"&&(this.hasHint=assigned),slot.name==="error"&&(this.hasError=assigned)},this.onSwatchKeyDown=event=>{if(this.liveDisabled||this.readonly)return;const entries=this.normalizedSwatches(),origin=Number(event.target.dataset.index);if(!Number.isInteger(origin))return;const target=swatchKeyTarget(event.key,origin,entries.length,index=>entries[index].disabled===!0,isRtl(this));target<0||(event.preventDefault(),this.onSwatchClick(entries[target]),this.renderRoot.querySelectorAll('[part~="swatch"]')[target]?.focus())},new GlassScrollLayer(this,'[part~="panel"]',()=>!this.inline&&this.open),this.addEventListener("focusout",()=>this.requestUpdate())}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.syncExternalDescription();const seedEnvironmentState=()=>{const hasSlot=name=>Array.from(this.children).some(el=>el.getAttribute("slot")===name);this.hasLabel=hasSlot("label"),this.hasHint=hasSlot("hint"),this.hasError=hasSlot("error"),this.hasEyeDropper=!!eyeDropperConstructor(this.ownerDocument.defaultView)};this.hasUpdated?seedEnvironmentState():this.seedFirstRenderState(seedEnvironmentState)}disconnectedCallback(){this.releaseExternalDescription(),this.suppressDisconnectedClose=this.open,this.open=!1,this.teardownOverlay(!1),this.cancelEyeDropper(),this.interactionGeneration+=1,this.keyboardChanged=!1,this.cancelDrag(),super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.releaseExternalDescription(),this.isConnected&&this.hasUpdated&&this.syncExternalDescription(),this.cancelDrag(),this.cancelEyeDropper()}get value(){return super.value}set value(next){this.endDrag(),this.cancelEyeDropper(),super.value=next??"",this.valueNeedsParse=!0}get disabled(){return super.disabled}set disabled(next){next&&this.cancelEyeDropper(),super.disabled=next}formDisabledCallback(disabled){disabled&&this.cancelEyeDropper(),super.formDisabledCallback(disabled)}willUpdate(changed){super.willUpdate(changed);const formatChanged=changed.has("format")||changed.has("opacity")||changed.has("uppercase");if(formatChanged&&this.cancelDrag(),(this.liveDisabled||this.readonly)&&(this.open&&this.applyOpenState(!1),this.pendingInput=void 0,this.keyboardChanged=!1,this.cancelDrag()),!this.valueNeedsParse&&!formatChanged)return;const shouldReserialize=formatChanged;if(this.valueNeedsParse){this.valueNeedsParse=!1;const parsed=parseColor(super.value);if(parsed){this.color=parsed,this.writeSerializedValue();return}}shouldReserialize&&parseColor(super.value)!==null&&this.writeSerializedValue()}updated(changed){if(super.updated(changed),this.syncExternalDescription(),changed.has("readonly")&&this.checkValidity(),changed.has("open")){const suppressClose=!this.open&&this.suppressDisconnectedClose;this.suppressDisconnectedClose=!1;const announceOpen=this.open&&this.hasRenderedOnce&&this.isConnected;this.open&&!this.inline?(this.pendingPlacementEffects=announceOpen?3:2,this.activatePanel()):(this.pendingPlacementEffects=0,this.teardownOverlay(this.restoreFocusOnClose),this.pendingInput=void 0),this.hasRenderedOnce&&this.isConnected&&!suppressClose&&(this.open&&this.inline?this.emit("lr-after-show"):this.open||this.emit("lr-after-hide"))}else if(changed.has("inline"))if(this.inline){this.teardownOverlay();const panel=this.panelEl();panel?.style.removeProperty("position"),panel?.hasAttribute("data-lr-top-layer")&&loadAnchoredOverlayRuntime().then(runtime=>runtime.releaseTopLayer?.(panel),()=>{});const announceOpen=(this.pendingPlacementEffects&1)!==0;this.pendingPlacementEffects=0,announceOpen&&this.emit("lr-after-show")}else this.open&&this.activatePanel();else this.open&&!this.inline&&(changed.has("placement")||changed.has("size")||changed.has("positioningStrategy"))&&this.positionPanel();this.hasRenderedOnce=!0}show(){this.open=!0}hide(){this.open=!1}getFormattedValue(format="hex"){return formatColor(this.color,format,this.uppercase)}getHexString(hue,saturation,brightness,alpha=100){const normalizedAlpha=finiteRange(alpha,100,0,100);return formatColor(hsva(hue,saturation,brightness,normalizedAlpha/100),normalizedAlpha<100?"hexa":"hex",this.uppercase)}click(){this.effectiveDisabled||(this.inline?this.renderRoot?.querySelector('[part~="input"]')?.click():this.triggerEl()?.click())}focus(options){this.effectiveDisabled||(this.inline?this.renderRoot?.querySelector('[part~="grid-handle"]')?.focus(options):this.triggerEl()?.focus(options))}blur(){const active=shadowFocusTarget(this);active&&typeof active.blur=="function"&&active.blur()}reportValidity(){const valid=super.reportValidity();return this.requestUpdate(),valid}setCustomValidity(message){super.setCustomValidity(message),this.requestUpdate()}resetValidity(){super.resetValidity(),this.requestUpdate()}activeFormat(){return withAlphaFormat(this.format,this.opacity)}writeSerializedValue(){const serialized=formatColor(this.color,this.activeFormat(),this.uppercase);return serialized===super.value?!1:(super.value=serialized,!0)}applyColor(next){next.h===this.color.h&&next.s===this.color.s&&next.v===this.color.v&&next.a===this.color.a||(this.color=next);const changed=this.writeSerializedValue();return changed&&(dispatchNativeInputEvent(this),this.emit("lr-input",{value:this.value})),changed}emitCommit(){dispatchNativeEvent(this,"change"),this.emit("lr-change",{value:this.value})}commitColor(next){const changed=this.applyColor(next);return changed&&this.emitCommit(),changed}normalizedSwatches(){const source=this.swatches;return source!==this.swatchSource&&(this.swatchSource=source,this.projectedSwatches=projectColorPickerSwatches(source)),this.projectedSwatches}triggerEl(){return this.renderRoot?.querySelector('[part~="trigger"]')}panelEl(){return this.renderRoot?.querySelector('[part~="panel"]')}positionPanel(){this.cleanupPositioner?.(),this.cleanupPositioner=void 0;const anchor=this.triggerEl(),panel=this.panelEl();if(!anchor||!panel)return;const handle=place(anchor,panel,{placement:rtlAwarePlacement(this.placement,this),strategy:resolveEffectivePositioningStrategy(this,this._positioningStrategy,"absolute")});this.cleanupPositioner=handle,handle.ready.then(positioned=>{if(this.cleanupPositioner!==handle||!this.open||this.inline||!this.isConnected)return;if(!positioned){this.pendingPlacementEffects=0,this.suppressDisconnectedClose=!0,this.applyOpenState(!1);return}const effects=this.pendingPlacementEffects;this.pendingPlacementEffects=0,effects&2&&this.overlayHandle?.focusInitial(),effects&1&&this.emit("lr-after-show")})}activatePanel(){!this.isConnected||this.inline||(this.pendingPlacementEffects|=2,this.positionPanel(),this.restoreFocusOnClose=!0,this.overlayHandle=activateNonmodalOverlay({host:this,panel:()=>this.panelEl(),onEscape:()=>this.hide(),onBackdrop:()=>{this.restoreFocusOnClose=!1,this.hide(),this.open&&(this.restoreFocusOnClose=!0)},restoreFocusTo:this.triggerEl()}),this.lightDismissDocument=this.ownerDocument,this.lightDismissDocument.addEventListener("pointerdown",this.onDocumentPointerDown,!0))}teardownOverlay(restoreFocus=!0){this.cleanupPositioner?.(),this.cleanupPositioner=void 0,this.overlayHandle?.deactivate({restoreFocus}),this.overlayHandle=void 0,this.lightDismissDocument?.removeEventListener("pointerdown",this.onDocumentPointerDown,!0),this.lightDismissDocument=void 0,this.restoreFocusOnClose=!0}beginDrag(event,track,box){const dragWindow=box.ownerDocument.defaultView;if(!this.isConnected||!dragWindow||this.effectiveDisabled||this.readonly||this.drag!==void 0||event.pointerType==="mouse"&&event.button!==0)return;const rect=box.getBoundingClientRect();this.drag={pointerId:event.pointerId,track,rect,rtl:isRtl(this),startColor:{...this.color},startValue:this.captureLiveValueCheckpoint()},this.dragChanged=!1;try{box.setPointerCapture(event.pointerId)}catch{}this.dragWindow=dragWindow,dragWindow.addEventListener("pointermove",this.onPointerMove),dragWindow.addEventListener("pointerup",this.onPointerUp),dragWindow.addEventListener("pointercancel",this.onPointerCancel),dragWindow.addEventListener("lostpointercapture",this.onPointerCancel),this.applyPointer(event)}applyPointer(event){const drag=this.drag;if(!drag)return;const{rect,rtl,track}=drag,rawX=rect.width===0?0:(event.clientX-rect.left)/rect.width,ratioX=finiteRange(rtl?1-rawX:rawX,0,0,1);let next;if(track==="grid"){const rawY=rect.height===0?0:(event.clientY-rect.top)/rect.height,ratioY=finiteRange(rawY,0,0,1);next=hsva(this.color.h,ratioX*100,(1-ratioY)*100,this.color.a)}else track==="hue"?next=hsva(ratioX*360,this.color.s,this.color.v,this.color.a):next=hsva(this.color.h,this.color.s,this.color.v,ratioX);this.dragChanged=this.applyColor(next)||this.dragChanged}cancelDrag(){const drag=this.drag;drag&&(this.endDrag(),this.color=drag.startColor,this.restoreLiveValueCheckpoint(drag.startValue),this.valueNeedsParse=!1)}endDrag(){this.drag=void 0,this.dragChanged=!1;const dragWindow=this.dragWindow;this.dragWindow=void 0,dragWindow?.removeEventListener("pointermove",this.onPointerMove),dragWindow?.removeEventListener("pointerup",this.onPointerUp),dragWindow?.removeEventListener("pointercancel",this.onPointerCancel),dragWindow?.removeEventListener("lostpointercapture",this.onPointerCancel)}inlineStep(event){const rtl=isRtl(this),forward=rtl?"ArrowLeft":"ArrowRight",backward=rtl?"ArrowRight":"ArrowLeft",step=SMALL_STEP*(event.shiftKey?LARGE_STEP_MULTIPLIER:1);return event.key===forward?step:event.key===backward?-step:null}applyKeyboardColor(next){const generation=this.interactionGeneration,changed=this.applyColor(next);generation===this.interactionGeneration&&(this.keyboardChanged=changed||this.keyboardChanged)}onSwatchClick(swatch){if(this.liveDisabled||this.readonly||swatch.disabled)return;const parsed=swatch.parsed;parsed&&this.commitColor(this.opacity?parsed:hsva(parsed.h,parsed.s,parsed.v,1))}cancelEyeDropper(){this.eyeDropperGeneration+=1,this.eyeDropperAbort?.abort(),this.eyeDropperAbort=void 0}formatNumber(value){return getNumberFormat(this.effectiveLocale,{maximumFractionDigits:0}).format(value)}renderGrid(){const saturation=Math.round(this.color.s),brightness=Math.round(this.color.v);return html`<div
2
2
  part="grid"
3
3
  style=${styleMap({"--lr-color-picker-grid-hue":cssColor(hsva(this.color.h,100,100,1))})}
4
4
  @pointerdown=${event=>this.beginDrag(event,"grid",event.currentTarget)}
@@ -177,4 +177,4 @@ import{__decorate}from"tslib";import{GlassScrollLayer}from"../../../internal/gla
177
177
  <div id=${this.hintId} part="hint" ?hidden=${!hasHint}
178
178
  >${this.hint}<slot name="hint" @slotchange=${this.onSlotChange}></slot
179
179
  ></div>
180
- </div>`}}__decorate([property()],LyraColorPicker.prototype,"label",void 0),__decorate([property()],LyraColorPicker.prototype,"hint",void 0),__decorate([property({type:Boolean,attribute:"with-label",reflect:!0})],LyraColorPicker.prototype,"withLabel",void 0),__decorate([property({type:Boolean,attribute:"with-hint",reflect:!0})],LyraColorPicker.prototype,"withHint",void 0),__decorate([property({attribute:"error-text"})],LyraColorPicker.prototype,"errorText",void 0),__decorate([property({attribute:"aria-label"})],LyraColorPicker.prototype,"accessibleLabel",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraColorPicker.prototype,"readonly",void 0),__decorate([property({reflect:!0})],LyraColorPicker.prototype,"size",void 0),__decorate([property({converter:{fromAttribute:normalizeColorFormat}})],LyraColorPicker.prototype,"format",null),__decorate([property({type:Boolean})],LyraColorPicker.prototype,"opacity",void 0),__decorate([property({type:Boolean})],LyraColorPicker.prototype,"uppercase",void 0),__decorate([property()],LyraColorPicker.prototype,"swatches",void 0),__decorate([property({type:Boolean,attribute:"without-format-toggle"})],LyraColorPicker.prototype,"withoutFormatToggle",void 0),__decorate([property({type:Boolean,attribute:"no-format-toggle",reflect:!0})],LyraColorPicker.prototype,"noFormatToggle",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraColorPicker.prototype,"inline",void 0),__decorate([property({attribute:"positioning-strategy",reflect:!0,converter:POSITIONING_STRATEGY})],LyraColorPicker.prototype,"positioningStrategy",null),__decorate([property({type:Boolean,reflect:!0})],LyraColorPicker.prototype,"hoist",null),__decorate([property({reflect:!0})],LyraColorPicker.prototype,"placement",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraColorPicker.prototype,"open",null),__decorate([state()],LyraColorPicker.prototype,"hasLabel",void 0),__decorate([state()],LyraColorPicker.prototype,"hasHint",void 0),__decorate([state()],LyraColorPicker.prototype,"hasError",void 0),__decorate([state()],LyraColorPicker.prototype,"hasEyeDropper",void 0),__decorate([state()],LyraColorPicker.prototype,"color",void 0);export{LyraColorPicker};
180
+ </div>`}}__decorate([property()],LyraColorPicker.prototype,"label",void 0),__decorate([property()],LyraColorPicker.prototype,"hint",void 0),__decorate([property({type:Boolean,attribute:"with-label",reflect:!0})],LyraColorPicker.prototype,"withLabel",void 0),__decorate([property({type:Boolean,attribute:"with-hint",reflect:!0})],LyraColorPicker.prototype,"withHint",void 0),__decorate([property({attribute:"error-text"})],LyraColorPicker.prototype,"errorText",void 0),__decorate([property({attribute:"aria-label"})],LyraColorPicker.prototype,"accessibleLabel",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraColorPicker.prototype,"readonly",null),__decorate([property({reflect:!0})],LyraColorPicker.prototype,"size",void 0),__decorate([property({converter:{fromAttribute:normalizeColorFormat}})],LyraColorPicker.prototype,"format",null),__decorate([property({type:Boolean})],LyraColorPicker.prototype,"opacity",void 0),__decorate([property({type:Boolean})],LyraColorPicker.prototype,"uppercase",void 0),__decorate([property()],LyraColorPicker.prototype,"swatches",void 0),__decorate([property({type:Boolean,attribute:"without-format-toggle"})],LyraColorPicker.prototype,"withoutFormatToggle",void 0),__decorate([property({type:Boolean,attribute:"no-format-toggle",reflect:!0})],LyraColorPicker.prototype,"noFormatToggle",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraColorPicker.prototype,"inline",void 0),__decorate([property({attribute:"positioning-strategy",reflect:!0,converter:POSITIONING_STRATEGY})],LyraColorPicker.prototype,"positioningStrategy",null),__decorate([property({type:Boolean,reflect:!0})],LyraColorPicker.prototype,"hoist",null),__decorate([property({reflect:!0})],LyraColorPicker.prototype,"placement",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraColorPicker.prototype,"open",null),__decorate([state()],LyraColorPicker.prototype,"hasLabel",void 0),__decorate([state()],LyraColorPicker.prototype,"hasHint",void 0),__decorate([state()],LyraColorPicker.prototype,"hasError",void 0),__decorate([state()],LyraColorPicker.prototype,"hasEyeDropper",void 0),__decorate([state()],LyraColorPicker.prototype,"color",void 0);export{LyraColorPicker};
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{emitValueEvents}from"../../../internal/value-events.js";import{setNativeRangeText,nativeAutocorrectAttribute}from"../../../internal/native-text-control.js";import{renderFormControlHintError}from"../../../internal/form-control-template.js";import{installFormControlLabelSupport}from"../../../internal/form-control-labels.js";import{FormControlController,reflectFormName}from"../../../internal/form-control-controller.js";import{GlassScrollLayer}from"../../../internal/glass-scroll-layer.js";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{acquireNativeControlDescription}from"../../../internal/native-control-description.js";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{LyraFormControlElement}from"../../../internal/form-control-element.js";import{loadAnchoredOverlayRuntime,syncTopLayerRelease,topLayerPlacement}from"../../../internal/anchored-overlay-runtime.js";import{hostAriaLabel,nextId,srOnly}from"../../../internal/a11y.js";import{chevronIcon,closeIcon}from"../../../internal/icons.js";import{VALIDITY_ANCHOR}from"../../../internal/anchored-validity.js";import{setCustomState,syncValidityStates}from"../../../internal/custom-states.js";import{submitOnEnter}from"../../../internal/submit-on-enter.js";import{finiteCount,finiteDuration}from"../../../internal/numbers.js";import{PopupController,emitPopupEvent}from"../../../internal/popup-controller.js";import{revealRow}from"../../../internal/reveal-row.js";import{DebounceController}from"../../../internal/debounce-controller.js";import{sizes}from"../../../internal/sizes.styles.js";import{styles}from"./combobox.styles.js";import{autocorrectConverter,literalSetConverter,omittedEmptyStringConverter,optionalLiteralSetConverter,spellcheckConverter}from"../../../internal/converters.js";import{resolveEffectivePositioningStrategy}from"../../../internal/positioning-strategy.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{sanitizeCssColor}from"../../../internal/safe-css.js";import{getFormOwner,isBarredFromValidation,setFormOwner}from"../../../internal/form-associated.js";import{tag}from"../../../internal/prefix.js";import{renderInertPresentation}from"../../../internal/inert-presentation.js";import{collectInitialSlotAssignment}from"../../../internal/initial-slot-collection.js";import{renderDataState}from"../../../internal/data-state-renderer.js";import{SlotPresenceController}from"../../../internal/slot-presence-controller.js";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{activateNonmodalOverlay}from"../../../internal/nonmodal-overlay-manager.js";import{isOptionSelectedDirty,isOptionSelectedWrite,wasOptionInitiallySelected,RESET_OPTION_SELECTED_FROM_OWNER,SET_OPTION_SELECTED_FROM_OWNER}from"../../../internal/option-selection.js";import{isHtmlElement}from"../../../internal/dom-guards.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{LYRA_DEFAULT_clear,LYRA_DEFAULT_collapse,LYRA_DEFAULT_comboboxCreate,LYRA_DEFAULT_comboboxLabel,LYRA_DEFAULT_comboboxLoadError,LYRA_DEFAULT_comboboxOverflow,LYRA_DEFAULT_comboboxRequired,LYRA_DEFAULT_comboboxSelectedOverflow,LYRA_DEFAULT_copy,LYRA_DEFAULT_date,LYRA_DEFAULT_details,LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_loading,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_noData,LYRA_DEFAULT_noMatches,LYRA_DEFAULT_notInCatalog,LYRA_DEFAULT_open,LYRA_DEFAULT_progress,LYRA_DEFAULT_removeWithContext,LYRA_DEFAULT_restore,LYRA_DEFAULT_retry,LYRA_DEFAULT_search,LYRA_DEFAULT_select,LYRA_DEFAULT_tableLoadFailed,LYRA_DEFAULT_valueInvalid}from"../../../internal/default-strings.generated.js";installFormControlLabelSupport();function isLyraOptionElement(value){return isHtmlElement(value)&&value.localName===tag("option")}function normalizeSelectionValues(next){return Array.isArray(next)?next.filter(value=>typeof value=="string"):typeof next=="string"?[next]:[]}const POSITIONING_STRATEGY=optionalLiteralSetConverter(["absolute","fixed"]),APPEARANCE=literalSetConverter(["accent","filled","outlined","filled-outlined","plain"],"outlined"),VALIDITY_FLAG_KEYS=new Set(["badInput","customError","patternMismatch","rangeOverflow","rangeUnderflow","stepMismatch","tooLong","tooShort","typeMismatch","valueMissing"]),comboboxSpellcheckConverter={...spellcheckConverter,fromAttribute:(value,type)=>value===null?void 0:spellcheckConverter.fromAttribute?.(value,type)};function adornmentContent(value){return typeof value=="string"||typeof value=="number"?html`<span>${value}</span>`:value}function isValidityFlagKey(value){return typeof value=="string"&&VALIDITY_FLAG_KEYS.has(value)}const MAX_SOURCE_ROWS=2e3,MAX_SOURCE_TEXT_UNITS=25e4,MAX_SOURCE_FIELD_UNITS=4096,MAX_RENDER_ROWS=1e3;function isRenderable(value,nested=!1){if(typeof value=="string"||typeof value=="number")return!0;if(typeof value!="object"||value===null)return!1;if(Array.isArray(value))return!nested&&value.every(item=>isRenderable(item,!0));const{nodeType,cloneNode,strings}=value;return typeof nodeType=="number"&&typeof cloneNode=="function"||Array.isArray(strings)&&Object.hasOwn(strings,"raw")}function normalizeSourceResult(input){let candidateRows,candidateTotal;try{Array.isArray(input)?candidateRows=input:typeof input=="object"&&input!==null&&(candidateRows=input.rows,candidateTotal=input.total)}catch{throw new TypeError("Invalid combobox source result")}if(!Array.isArray(candidateRows))throw new TypeError("Invalid combobox source result");const providerTotal=typeof candidateTotal=="number"&&Number.isFinite(candidateTotal)&&candidateTotal>=0?Math.trunc(candidateTotal):candidateRows.length,rows=[];let textUnits=0;const limit=Math.min(candidateRows.length,MAX_SOURCE_ROWS);for(let index=0;index<limit;index++)try{const value=candidateRows[index]?.value,label=candidateRows[index]?.label;if(typeof value!="string"||typeof label!="string"||value.length>MAX_SOURCE_FIELD_UNITS||label.length>MAX_SOURCE_FIELD_UNITS)continue;const source=candidateRows[index],optionalText=key=>{const candidate=source[key];return typeof candidate=="string"&&candidate.length<=MAX_SOURCE_FIELD_UNITS?candidate:void 0},content=key=>{const candidate=source[key];return isRenderable(candidate)?candidate:void 0},icon=content("icon"),start=content("start"),end=content("end"),sub=optionalText("sub"),accessibleLabel=optionalText("accessibleLabel"),dotColor=optionalText("dotColor"),title=optionalText("title"),group=optionalText("group"),badgeCandidate=source.badge,badge=typeof badgeCandidate=="string"&&badgeCandidate.length<=MAX_SOURCE_FIELD_UNITS||typeof badgeCandidate=="number"&&Number.isFinite(badgeCandidate)?badgeCandidate:void 0,units=value.length+label.length+(sub?.length??0)+(accessibleLabel?.length??0)+(dotColor?.length??0)+(title?.length??0)+(group?.length??0)+(typeof badge=="string"?badge.length:0);if(textUnits+units>MAX_SOURCE_TEXT_UNITS)break;textUnits+=units,rows.push({value,label,...sub===void 0?{}:{sub},...icon===void 0?{}:{icon},...start===void 0?{}:{start},...end===void 0?{}:{end},...badge===void 0?{}:{badge},...accessibleLabel===void 0?{}:{accessibleLabel},...source.data===void 0?{}:{data:source.data},...dotColor===void 0?{}:{dotColor},...title===void 0?{}:{title},...group===void 0?{}:{group},...typeof source.disabled=="boolean"?{disabled:source.disabled}:{}})}catch{}const total=Math.max(providerTotal,candidateRows.length);return{rows,total,truncated:total>rows.length}}class LyraCombobox extends LyraFormControlElement{static{this.defaultStrings={...super.defaultStrings,clear:LYRA_DEFAULT_clear,collapse:LYRA_DEFAULT_collapse,comboboxCreate:LYRA_DEFAULT_comboboxCreate,comboboxLabel:LYRA_DEFAULT_comboboxLabel,comboboxLoadError:LYRA_DEFAULT_comboboxLoadError,comboboxOverflow:LYRA_DEFAULT_comboboxOverflow,comboboxRequired:LYRA_DEFAULT_comboboxRequired,comboboxSelectedOverflow:LYRA_DEFAULT_comboboxSelectedOverflow,copy:LYRA_DEFAULT_copy,date:LYRA_DEFAULT_date,details:LYRA_DEFAULT_details,fieldRequired:LYRA_DEFAULT_fieldRequired,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,noData:LYRA_DEFAULT_noData,noMatches:LYRA_DEFAULT_noMatches,notInCatalog:LYRA_DEFAULT_notInCatalog,open:LYRA_DEFAULT_open,progress:LYRA_DEFAULT_progress,removeWithContext:LYRA_DEFAULT_removeWithContext,restore:LYRA_DEFAULT_restore,retry:LYRA_DEFAULT_retry,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select,tableLoadFailed:LYRA_DEFAULT_tableLoadFailed,valueInvalid:LYRA_DEFAULT_valueInvalid}}static{this.collectionSupport=collectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-input","lr-change"])}static{this.identityEventDetailCollectionItems=Object.freeze({"lr-input":Object.freeze(["data"]),"lr-change":Object.freeze(["data"])})}static{this.formAssociated=!0}static{this.styles=[LyraElement.styles,sizes,styles,srOnly]}static{this.properties={customError:{attribute:"custom-error",reflect:!0,noAccessor:!0},multiple:{type:Boolean,reflect:!0,noAccessor:!0},disabled:{type:Boolean,reflect:!0,noAccessor:!0},required:{type:Boolean,reflect:!0,noAccessor:!0},readonly:{type:Boolean,reflect:!0,noAccessor:!0},value:{noAccessor:!0},name:{reflect:!0,noAccessor:!0,converter:omittedEmptyStringConverter},maxOptionsVisible:{type:Number,attribute:"max-options-visible",noAccessor:!0},maxRender:{type:Number,attribute:"max-render",noAccessor:!0},sourceDelay:{type:Number,attribute:"source-delay",noAccessor:!0}}}get open(){return this._open}set open(next){const old=this._open,liveDisabled=this.effectiveDisabled||typeof this.matches=="function"&&this.matches(":disabled");if(this._open=!!next&&!this.readonly&&!liveDisabled,this._open===old){next&&!this._open&&this.hasAttribute("open")&&this.removeAttribute("open");return}this.requestUpdate("open",old)}get appearance(){return this._appearance}set appearance(next){const normalized=APPEARANCE.normalizeReflected(this,"appearance",next),old=this._appearance;this._appearance=normalized,normalized!==old&&this.requestUpdate("appearance",old)}get positioningStrategy(){return this._positioningStrategy??"fixed"}set positioningStrategy(next){const normalized=POSITIONING_STRATEGY.normalize(next)??"fixed",old=this.positioningStrategy;this._positioningStrategy=normalized,normalized!==old&&this.requestUpdate("positioningStrategy",old)}get autocorrect(){return this.autocorrectValue}set autocorrect(next){this.autocorrectValue=!!next,this.requestUpdate()}get inputmode(){return this.inputMode}set inputmode(next){this.inputMode=next??""}get enterkeyhint(){return this.enterKeyHint}set enterkeyhint(next){this.enterKeyHint=next??""}get inputValue(){return this.query}set inputValue(next){this.explicitInputValue=!0,this.query=next??"",this.activeIndex=-1,this.source&&this.runSource(this.query),this.requestUpdate()}constructor(){super(),this.placeholder="",this.label="",this.hint="",this.errorText="",this.allowCreate=!1,this.allowCustomValue=!1,this.withUnknownOption=!1,this.loading=!1,this._appearance="outlined",this.placement="bottom",this.topLayer=!1,this.size="m",this.pill=!1,this.clearable=!1,this.withClear=!1,this.withLabel=!1,this.withHint=!1,this.validators=[],this.autocomplete="off",this.inputMode="",this.enterKeyHint="",this.spellcheck=!1,this.autocapitalize="",this.autocorrectValue=!0,this.filter=null,this.source=null,this.query="",this.explicitInputValue=!1,this.activeIndex=-1,this.options=[],this.optionsObserved=!1,this.touched=!1,this.validityRevision=0,this.slotPresence=new SlotPresenceController(this),this.sourceLoading=!1,this.sourceFailed=!1,this.sourceEverSettled=!1,this.asyncRows=[],this._sourceTotal=0,this._sourceTruncated=!1,this.sourceErrorAnnouncements=new AnnouncementSinkController(this,{eager:["assertive"]}),this.sourceDebounce=new DebounceController(0,request=>this.runSourceRequest(request),()=>this.ownerDocument.defaultView),this.sourceToken=0,this.refreshQueued=!1,this._sourceWarmed=!1,this._selectedLabelCache=new Map,this._selectedRowCache=new Map,this._renderedRows=[],this._open=!1,this._fieldsetDisabled=!1,this.listId=nextId("combobox-list"),this.inputId=nextId("combobox-input"),this.listboxPositioned=!1,this.positioningGeneration=0,this.positioningReady=Promise.resolve(!1),this.restoreFocusOnClose=!0,this.restoringOverlayFocus=!1,this.popupController=new PopupController({host:this,popup:()=>this.renderRoot.querySelector('[part="listbox"]'),emit:(name,cancelable)=>emitPopupEvent(this,name,cancelable),onPointer:event=>this.onDocPointer(event)}),this.listboxHidden=!0,this.listboxRendered=!1,this._isFirstUpdate=!0,this.openVetoed=!1,this.closeAfterPositioningFailure=!1,this.closeCleanupPending=!1,this._selected=[],this.sourceOptionsByRow=new WeakMap,this._valueDirty=!1,this._multiple=!1,this._disabled=!1,this._required=!1,this._readonly=!1,this._defaultSelected=[],this._defaultCaptured=!1,this._restoredStateActive=!1,this._name="",this._maxOptionsVisible=3,this._maxRender=200,this._sourceDelay=200,this.localDescriptionIds="",this.previousSelection=[],this.markInteracted=()=>{this.touched||(this.touched=!0,this.updateValidity(),this.syncCustomStates())},this.collectOptions=e=>{this.collectOptionsFromSlot(e.target)},this.optionRefreshPending=!1,this.onOptionChange=e=>{e.stopPropagation();const option=e.composedPath().find(isLyraOptionElement);if(isLyraOptionElement(option)&&this.options.includes(option)&&isOptionSelectedWrite(e)){if(this.multiple){const next=option.selected?this._selected.includes(option.value)?this._selected:[...this._selected,option.value]:this._selected.filter(value=>value!==option.value);this.assignValue(next)}else{if(this._valueDirty=!0,this._restoredStateActive=!1,!option.selected&&this.singleSelectedOption!==option)return;this.setValue(option.selected?option.value:[],!0,option.selected?option:void 0)}return}isLyraOptionElement(option)&&this.adornmentClones.get(option)?.markup!==this.adornmentMarkup(option)&&this.adornmentClones.delete(option),!this.optionRefreshPending&&(this.optionRefreshPending=!0,queueMicrotask(()=>{this.optionRefreshPending=!1,this.refreshOptionDefaults(),this.reflectSelected(),this.options=[...this.options],this.normalizeActiveIndex()}))},this.adornmentClones=new WeakMap,this.onDocPointer=e=>{if(!e.composedPath().includes(this)){if(this.overlayHandle?.isActive()){this.overlayHandle.dismissBackdrop();return}this.restoreFocusOnClose=!1,this.hide()}},this.onInput=e=>{this.liveDisabled||this.readonly||(this.explicitInputValue=!1,this.query=e.target.value,this.activeIndex=-1,this.show(),this.source&&this.runSource(this.query),this.emit("lr-filter",{value:this.query}))},this.onInputBlur=event=>{this.liveDisabled||(this.touched=!0),this.syncCustomStates(),this.onComboFocusOut(event),relayNativeEvent(this,event)},this.onComboFocusOut=event=>{const trigger=this.renderRoot.querySelector('[part="combobox"]'),target=event.relatedTarget;target&&typeof target.nodeType=="number"&&trigger?.contains(target)||(this.restoreFocusOnClose=!1,this.hide())},this.onInputFocus=event=>{if(this.liveDisabled){event.stopPropagation();return}this.restoringOverlayFocus||this.show(),relayNativeEvent(this,event)},this.onKeyDown=e=>{if(e.isComposing||e.keyCode===229||this.liveDisabled||this.readonly)return;const navigable=["ArrowDown","ArrowUp","Enter","End"].includes(e.key)?this.renderedRows.rows.filter(r=>!r.disabled):[];switch(e.key){case"ArrowDown":case"ArrowUp":if(e.preventDefault(),!this.open){this.activeIndex=navigable.findIndex(row=>this.committed.includes(row.value)),this.show();return}if(e.key==="ArrowDown"){this.activeIndex=Math.min(navigable.length-1,this.activeIndex+1);break}this.activeIndex=Math.max(0,this.activeIndex-1);break;case"Enter":{const activeRow=navigable[this.activeIndex];if(this.open&&this.activeIndex>=0&&activeRow){e.preventDefault(),this.pickRow(activeRow);break}const create=this.createRow;if(this.open&&create){e.preventDefault(),this.createOption(create.createInput);break}if(this.open&&this.allowCustomValue&&!this.multiple&&this.query.trim()){e.preventDefault(),this.commitCustomValue(this.query.trim());break}submitOnEnter(this,e);break}case"Escape":this.open&&(!this.overlayHandle?.isActive()||this.overlayHandle.isTopmost())&&(e.preventDefault(),this.hide());break;case"Home":this.open&&(e.preventDefault(),this.activeIndex=0);break;case"End":this.open&&(e.preventDefault(),this.activeIndex=navigable.length-1);break;case"Backspace":this.multiple&&!this.query&&this._selected.length&&this.removeValueAt(this._selected.length-1);break}},this.onComboMouseDown=e=>{this.liveDisabled||e.composedPath()[0]!==this.inputEl&&(e.target.closest("button")||(e.preventDefault(),this.inputEl?.focus(),this.show()))},this.onListboxMouseDown=e=>{e.preventDefault()},this.onListboxClick=e=>{const optionEl=e.target.closest('[part="option"]'),row=this._renderedRows[Number(optionEl?.dataset.index)];row&&this.pickRow(row)},this.validityController=new FormControlController(this,{invalid:init=>this.emit("lr-invalid",null,init),interacted:this.markInteracted,customError:()=>this.validityController.customValidityMessage}),this.internals=this.validityController.formInternals,new GlassScrollLayer(this,'[part="listbox"]',()=>this.open)}get form(){return getFormOwner(this.internals)}set form(owner){setFormOwner(this,owner)}get validationTarget(){return this.validationTargetOverride??this.inputEl??void 0}set validationTarget(next){this.validationTargetOverride=next??void 0,this.validityController.refreshAnchor()}resetValidity(){this.validityController.setCustomValidity(""),this.updateValidity()}get input(){return this.inputEl??null}get selectionStart(){return this.inputEl?.selectionStart??null}set selectionStart(value){this.inputEl&&(this.inputEl.selectionStart=value)}get selectionEnd(){return this.inputEl?.selectionEnd??null}set selectionEnd(value){this.inputEl&&(this.inputEl.selectionEnd=value)}get selectionDirection(){return this.inputEl?.selectionDirection}set selectionDirection(value){this.inputEl&&(this.inputEl.selectionDirection=value)}get liveDisabled(){return this.effectiveDisabled||this.matches(":disabled")}get interactionBarred(){return this.liveDisabled||this.readonly}focus(options){this.liveDisabled||this.inputEl?.focus(options)}blur(){this.inputEl?.blur()}click(){this.liveDisabled||(this.inputEl?.focus(),this.show())}select(){this.inputEl?.select()}setSelectionRange(start,end,direction){this.inputEl?.setSelectionRange(start,end,direction)}setRangeText(replacement,start,end,selectMode){const input=this.inputEl;input&&(setNativeRangeText(input,replacement,start,end,selectMode),this.explicitInputValue=!0,this.query=input.value,this.activeIndex=-1,this.source&&this.runSource(this.query))}[VALIDITY_ANCHOR](){return this.validationTarget}syncExternalDescription(){if(!this.isConnected)return;const target=this.renderRoot.querySelector('[part="combobox-input"]');target&&(this.externalDescriptionLease?this.externalDescriptionLease.update(target):this.externalDescriptionLease=acquireNativeControlDescription(this,target,()=>this.localDescriptionIds))}releaseExternalDescription(){this.externalDescriptionLease?.release(),this.externalDescriptionLease=void 0}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.syncExternalDescription(),this.updateValidity(),this.hasUpdated&&this.syncValidatorAttributeObserver(),this.hasUpdated&&queueMicrotask(()=>{this.open?this.reconnectOpenPopup():this.source&&this._selected.length&&this.asyncRows.length===0&&this.runSource("")})}adoptedCallback(){super.adoptedCallback(),this.popupController.cancel(),this.releaseExternalDescription(),this.hasUpdated&&this.syncExternalDescription(),this.listboxPositioned=!1,this.invalidateListboxPositioning(),this.overlayHandle?.deactivate({restoreFocus:!1}),this.overlayHandle=void 0,this.popupController.unbindPointer(),this.clearSourceTimer(),this.sourceToken+=1,this.sourceAbort?.abort(),this.sourceAbort=void 0,this.sourceErrorAnnouncements.adopted()}willUpdate(changed){super.willUpdate(changed),this._isFirstUpdate=!this.hasUpdated,this.announceOpenTransition(changed),this.open?(this.listboxHidden=!1,this.listboxRendered=!0):changed.has("open")&&this.interactionBarred&&(this.listboxHidden=!0),changed.has("open")&&!this.openVetoed&&(this.listboxPositioned=!1),changed.has("open")&&this.openVetoed?this.closeCleanupPending=!1:changed.has("open")&&!this.open&&this.finalizeCloseState(),changed.has("source")&&(this.clearSourceTimer(),this.sourceAbort?.abort(),this.sourceAbort=void 0,this.sourceToken++,this.sourceLoading=!1,this.sourceFailed=!1,this.sourceEverSettled=!1,this.asyncRows=[],this._sourceTotal=0,this._sourceTruncated=!1,this.activeIndex=-1,this._sourceWarmed=!1,this.source&&this.open&&this.runSource(this.query)),!this._sourceWarmed&&this.source&&(this._selected.length>0||(this.pendingSelectedRowValues?.length??0)>0)&&this.asyncRows.length===0&&(this._sourceWarmed=!0,this.runSource(""))}firstUpdated(changed){super.firstUpdated(changed);const slot=this.optionsSlot;queueMicrotask(()=>{collectInitialSlotAssignment(slot,s=>{this.optionsObserved=!0,s.assignedElements({flatten:!0}).some(isLyraOptionElement)&&this.collectOptionsFromSlot(s)})})}get name(){return this._name}set name(next){const old=this._name;this._name=next??"",reflectFormName(this,this._name),this.syncFormValue(),this.requestUpdate("name",old)}get multiple(){return this._multiple}set multiple(next){const old=this._multiple;this._multiple=!!next,this.toggleAttribute("multiple",this._multiple),this.reflectSelected(),this.syncFormValue(),this.requestUpdate("multiple",old)}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this._fieldsetDisabled=this.validityController?.fieldsetDisabled(this._fieldsetDisabled)??this._fieldsetDisabled,this._disabled&&this.hide(),this.updateValidity(),this.requestUpdate("disabled",old)}get required(){return this._required}set required(next){const old=this._required;this._required=!!next,this.toggleAttribute("required",this._required),this.updateValidity(),this.requestUpdate("required",old)}get readonly(){return this._readonly}set readonly(next){const old=this._readonly;this._readonly=!!next,this.toggleAttribute("readonly",this._readonly),this._readonly&&this.hide(),this.updateValidity(),this.requestUpdate("readonly",old)}get value(){return this.multiple?[...this._selected]:this._selected[0]??""}set value(next){this.setValue(next,!0)}setValue(next,dirty,preferred){const old=this._selected;this.previousSelection=old,this.singleSelectedOption=preferred,dirty&&(this._restoredStateActive=!1,this._valueDirty=!0),this._selected=normalizeSelectionValues(next);const selected=new Set(this._selected);if(selected.size>0){const rows=this.rowsByValue();for(const value of selected){const row=rows.get(value);row&&this._selectedRowCache.set(value,row)}}for(const value of this._selectedRowCache.keys())selected.has(value)||this._selectedRowCache.delete(value);for(const value of this._selectedLabelCache.keys())selected.has(value)||this._selectedLabelCache.delete(value);this.syncFormValue(),this.reflectSelected(),this.updateValidity(),this.requestUpdate("value",old)}get maxOptionsVisible(){return this._maxOptionsVisible}set maxOptionsVisible(next){const old=this._maxOptionsVisible;this._maxOptionsVisible=finiteCount(next,3),this.requestUpdate("maxOptionsVisible",old)}get maxRender(){return this._maxRender}get sourceDelay(){return this._sourceDelay}set sourceDelay(next){const old=this._sourceDelay;this._sourceDelay=finiteDuration(next,200),this.requestUpdate("sourceDelay",old)}set maxRender(next){const old=this._maxRender;this._maxRender=Math.min(finiteCount(next,200),MAX_RENDER_ROWS),this.requestUpdate("maxRender",old)}get sourceTotal(){return this._sourceTotal}get sourceTruncated(){return this._sourceTruncated}get selectedRows(){return this.resolveSelectedRowSlots().filter(row=>row!=null).map(row=>({...row}))}resolveSelectedRowSlots(){let rows;return this.committed.map(value=>this._selectedRowCache.get(value)??(rows??=this.rowsByValue()).get(value))}get committed(){return this.multiple?this._selected:this._selected.slice(0,1)}rowsByValue(){const rows=new Map;for(const row of[...this.effectiveRows,...this.asyncRows])rows.has(row.value)||rows.set(row.value,row);return rows}set selectedRows(next){const values=[],seen=new Set;if(Array.isArray(next))for(const candidate of next){let value;try{value=candidate?.value}catch{continue}typeof value!="string"||seen.has(value)||(seen.add(value),values.push(value))}if(values.length>0&&this.selectionSourceRows.length===0){this.pendingSelectedRowValues=values,this.source&&this.isConnected&&(this._sourceWarmed=!0,this.runSource(""));return}this.pendingSelectedRowValues=void 0,this.applySelectedRowValues(values)}get barredFromValidation(){return isBarredFromValidation(this,this.internals)}validatorResult(){const self=this,current=self.value;for(const validator of Array.isArray(this.validators)?this.validators:[]){let result;try{if(typeof validator=="object"&&validator!==null&&"checkValidity"in validator){const checked=validator.checkValidity(this);if(checked?.isValid===!0)continue;const flags={};for(const key of Array.isArray(checked?.invalidKeys)?checked.invalidKeys:[])isValidityFlagKey(key)&&(flags[key]=!0);Object.values(flags).some(Boolean)||(flags.customError=!0);let message=typeof checked?.message=="string"?checked.message:"";return!message&&typeof validator.message=="string"&&(message=validator.message),!message&&typeof validator.message=="function"&&(message=validator.message(this)),{flags,message:message||this.localize("valueInvalid")}}result=typeof validator=="function"?validator(current,self):validator?.validate(current,self)}catch{return{flags:{customError:!0},message:this.localize("valueInvalid")}}if(!(result===void 0||result===!0)){if(typeof result=="string")return{flags:{customError:!0},message:result};if(result===!1)return{flags:{customError:!0},message:this.localize("valueInvalid")};if(result&&typeof result=="object"&&Object.values(result).some(Boolean))return{flags:result,message:this.localize("valueInvalid")}}}return{}}syncValidatorAttributeObserver(){this.disconnectValidatorAttributeObserver();const owner=this.ownerDocument.defaultView,MutationObserverCtor=owner?.MutationObserver;if(!this.isConnected||!owner||typeof MutationObserverCtor!="function")return;const attributes=new Set;for(const validator of Array.isArray(this.validators)?this.validators:[]){if(typeof validator!="object"||validator===null||!("checkValidity"in validator))continue;let observed;try{observed=validator.observedAttributes}catch{continue}if(Array.isArray(observed))for(const name of observed)typeof name=="string"&&name.length>0&&attributes.add(name)}if(attributes.size===0)return;const binding={},observer=new MutationObserverCtor(()=>{this.validatorAttributeObserver!==binding||!this.isConnected||this.ownerDocument.defaultView!==owner||(this.updateValidity(),this.validityRevision++)});binding.observer=observer,binding.owner=owner;try{observer.observe(this,{attributes:!0,attributeFilter:[...attributes]}),this.validatorAttributeObserver=binding}catch{observer.disconnect()}}disconnectValidatorAttributeObserver(){const binding=this.validatorAttributeObserver;this.validatorAttributeObserver=void 0,binding?.observer.disconnect()}updateValidity(){if(this.barredFromValidation){this.validityController.setValidity({}),this.syncCustomStates();return}const flags={};let message="";this.required&&this._selected.length===0&&(flags.valueMissing=!0,message=this.localize("comboboxRequired"));const configured=this.validatorResult();configured.flags&&Object.assign(flags,configured.flags),configured.message&&(message=configured.message),this.validityController.setValidity(flags,message),this.syncCustomStates()}syncCustomStates(){syncValidityStates(this.internals,{required:this.required,hasInteracted:this.touched,barred:this.barredFromValidation}),setCustomState(this.internals,"blank",this._selected.length===0),setCustomState(this.internals,"disabled",this.effectiveDisabled)}syncFormValue(){const state2=JSON.stringify(this._selected);if(this.multiple){if(!this.name){this.internals.setFormValue(null,state2);return}const fd=new FormData;for(const v of this._selected)fd.append(this.name,v);this.internals.setFormValue(fd,state2)}else this.internals.setFormValue(this._selected[0]??"",state2)}get effectiveDisabled(){return this.disabled||this._fieldsetDisabled}formResetCallback(){this.touched=!1,this._restoredStateActive=!1,this._valueDirty=!1;const resetValues=this._defaultSelected.length>0?this._defaultSelected:this.options.filter(option=>wasOptionInitiallySelected(option)).map(option=>option.value);this._defaultSelected.length===0&&resetValues.length>0&&(this._defaultSelected=[...resetValues]);const defaults=new Set(resetValues);for(const option of this.options)option[RESET_OPTION_SELECTED_FROM_OWNER](defaults.has(option.value));this.setValue(this.multiple?[...resetValues]:resetValues.slice(0,1),!1),this.query="",this.explicitInputValue=!1}formStateRestoreCallback(state2,reason){let selected=[];if(typeof state2=="string")try{const parsed=JSON.parse(state2);Array.isArray(parsed)&&parsed.every(value=>typeof value=="string")&&(selected=parsed)}catch{}this.assignValue(this.multiple?selected:selected.slice(0,1)),this._restoredStateActive=!0}formDisabledCallback(disabled){if(this.validityController?.reflectingDisabled)return;const wasDisabled=this.effectiveDisabled;this._fieldsetDisabled=disabled,wasDisabled!==this.effectiveDisabled&&(disabled&&this.hide(),this.updateValidity(),this.requestUpdate())}checkValidity(){return this.validityController.checkValidity(()=>this.updateValidity())}reportValidity(){return this.validityController.syncConstraints(),this.touched=!0,this.updateValidity(),this.syncCustomStates(),this.internals.reportValidity()}setCustomValidity(message){this.validityController.setCustomValidity(message??""),this.syncCustomStates()}disconnectedCallback(){this.listboxHidden=!0,this.releaseExternalDescription(),this.popupController.cancel(),this.listboxPositioned=!1,this.disconnectValidatorAttributeObserver(),super.disconnectedCallback(),this.invalidateListboxPositioning(),this.clearSourceTimer(),this.sourceToken+=1,this.sourceAbort?.abort(),this.sourceAbort=void 0,this.overlayHandle?.deactivate({restoreFocus:!1}),this.overlayHandle=void 0,this.popupController.unbindPointer(),this.open=!1}collectOptionsFromSlot(slot){const previous=new Set(this.options);if(this.optionsObserved=!0,this.options=slot.assignedElements({flatten:!0}).filter(isLyraOptionElement),this.adornmentClones=new WeakMap,this.normalizeActiveIndex(),this.applyPendingSelectedRows(),this._defaultCaptured){const newDefaults=this.options.filter(option=>!previous.has(option)&&option.defaultSelected),newLive=this.options.filter(option=>!previous.has(option)&&option.selected&&!option.defaultSelected);this.refreshOptionDefaults();const eligible=[...!this._restoredStateActive&&!this._valueDirty?newDefaults:[],...this._restoredStateActive?[]:newLive];if(eligible.length){const values=eligible.map(option=>option.value),next=this.multiple?[...new Set([...this._selected,...values])]:values[values.length-1];newLive.length>0?this.assignValue(next):this.setValue(next,!1);return}}else{this._defaultCaptured=!0;const allDefaults=this.options.filter(option=>option.defaultSelected).map(option=>option.value),allLive=this.options.filter(option=>option.selected).map(option=>option.value),defaults=this.multiple?allDefaults:allDefaults.slice(0,1),live=this.multiple?allLive:allLive.slice(0,1),initialLive=this.options.filter(option=>wasOptionInitiallySelected(option)).map(option=>option.value),optionDirty=this.options.some(option=>isOptionSelectedDirty(option)),dirtyValues=this.options.filter(option=>isOptionSelectedDirty(option)&&option.selected).map(option=>option.value);this._defaultSelected=[...defaults.length>0?defaults:initialLive.length>0?initialLive:live];const fromDefaults=defaults.length>0,initial=optionDirty?this.multiple?allLive:dirtyValues.slice(-1)[0]?dirtyValues.slice(-1):live:fromDefaults?defaults:live;if(initial.length&&!this._restoredStateActive&&!this._valueDirty){const next=this.multiple?initial:initial[0];fromDefaults&&!optionDirty?this.setValue(next,!1):this.assignValue(next);return}optionDirty&&(this._valueDirty=!0)}this.reflectSelected()}refreshOptionDefaults(){const declared=this.options.filter(option=>option.defaultSelected).map(option=>option.value);this._defaultSelected=this.multiple?declared:declared.slice(0,1),!this._valueDirty&&!this._restoredStateActive&&this.setValue([...this._defaultSelected],!1)}reflectSelected(){const value=this._selected[0];(!this.singleSelectedOption||!this.options.includes(this.singleSelectedOption)||this.singleSelectedOption.value!==value)&&(this.singleSelectedOption=this.options.find(option=>option.value===value));const selected=new Set(this._selected);for(const option of this.options)option[SET_OPTION_SELECTED_FROM_OWNER](this.multiple?selected.has(option.value):option===this.singleSelectedOption)}labelFor(value){const nonBlank=label=>label!==void 0&&label.trim().length>0?label:void 0;if(this.getUnknownLabel&&this.isUnknownValue(value)){const override=nonBlank(this.getUnknownLabel(value));if(override!==void 0)return override}return(!this.source&&!this.multiple&&this.singleSelectedOption?.value===value?nonBlank(this.singleSelectedOption.label):void 0)??nonBlank(this._selectedLabelCache.get(value))??nonBlank(this.options.find(o=>o.value===value)?.label)??nonBlank(this.asyncRows.find(r=>r.value===value)?.label)??(this.loading||this.source&&!this.sourceEverSettled?this.statusText("loading",this.loadingText):void 0)??value}isUnknownValue(value){return!this.source&&!this.optionsObserved||this.loading||this.source&&!this.sourceEverSettled?!1:!(!this.source&&!this.multiple&&this.singleSelectedOption?.value===value||this._selectedLabelCache.has(value)||this.options.some(option=>option.value===value)||this.asyncRows.some(row=>row.value===value))}adornmentMarkup(option){return Array.from(option.children).filter(child=>["start","end","prefix","suffix"].includes(child.getAttribute("slot")??"")).map(child=>child.outerHTML).join("")}adornmentsFor(option){const cached=this.adornmentClones.get(option);if(cached)return cached;const cloneSlot=selector=>{const nodes=Array.from(option.querySelectorAll(selector));if(nodes.length!==0)return nodes.map(node=>node.cloneNode(!0))},resolved={markup:this.adornmentMarkup(option),start:cloneSlot(':scope > [slot="start"], :scope > [slot="prefix"]'),end:cloneSlot(':scope > [slot="end"], :scope > [slot="suffix"]')};return this.adornmentClones.set(option,resolved),resolved}rowForOption(option){const adornments=this.adornmentsFor(option),row={value:option.value,label:option.label||option.value,sub:option.sub||void 0,dotColor:option.dotColor||void 0,title:option.title||void 0,group:option.group||void 0,disabled:option.disabled||option.inert||option.closest("[inert]")!==null,data:option.data,...adornments.start===void 0?{}:{start:adornments.start},...adornments.end===void 0?{}:{end:adornments.end}};return this.sourceOptionsByRow.set(row,option),row}get selectionSourceRows(){return this.source?this.asyncRows:this.options.map(option=>this.rowForOption(option))}applySelectedRowValues(values){const rowsByValue=new Map;for(const row of this.selectionSourceRows)rowsByValue.has(row.value)||rowsByValue.set(row.value,row);const rows=values.map(value=>rowsByValue.get(value)).filter(row=>row!==void 0),limited=this.multiple?rows:rows.slice(0,1);this.assignValue(limited.map(row=>row.value));for(const row of limited)this._selectedRowCache.set(row.value,row)}applyPendingSelectedRows(acceptEmptySource=!1){if(this.pendingSelectedRowValues===void 0||!acceptEmptySource&&this.selectionSourceRows.length===0)return!1;const values=this.pendingSelectedRowValues;return this.pendingSelectedRowValues=void 0,this.applySelectedRowValues(values),!0}get effectiveRows(){return this.source?this.asyncRows:this.filtered.map(option=>this.rowForOption(option))}get unknownRows(){if(!this.withUnknownOption)return[];const locale=this.effectiveLocale,query2=this.query.trim().toLocaleLowerCase(locale);return this.committed.filter(value=>this.isUnknownValue(value)).map(value=>({value,label:this.labelFor(value),badge:this.localize("notInCatalog"),unknownValue:value})).filter(row=>!query2||row.label.toLocaleLowerCase(locale).includes(query2)||row.value.toLocaleLowerCase(locale).includes(query2))}get createRow(){if(!this.allowCreate)return;const inputValue=this.query.trim();if(!inputValue)return;const locale=this.effectiveLocale,folded=inputValue.toLocaleLowerCase(locale);if(!(this.source?this.asyncRows:this.options.map(option=>({value:option.value,label:option.label}))).some(row=>row.value.toLocaleLowerCase(locale)===folded||row.label.toLocaleLowerCase(locale)===folded))return{value:inputValue,label:this.localize("comboboxCreate",void 0,{value:inputValue}),createInput:inputValue}}get renderedRows(){const all=this.effectiveRows,create=this.createRow,sourceOverflow=this.source?Math.max(0,this._sourceTotal-all.length):0,unknown=this.unknownRows;if(all.length<=this.maxRender)return{rows:[...all,...unknown,...create?[create]:[]],overflow:sourceOverflow};const originalIndex=new Map(all.map((r,i)=>[r,i])),capped=all.slice(0,this.maxRender),cappedValues=new Set(capped.map(r=>r.value));let appendedOutOfCap=!1;for(const v of this.committed)if(!cappedValues.has(v)){const selectedRow=all.find(r=>r.value===v);selectedRow&&(capped.push(selectedRow),appendedOutOfCap=!0)}return appendedOutOfCap&&capped.sort((a,b)=>originalIndex.get(a)-originalIndex.get(b)),capped.push(...unknown),create&&capped.push(create),{rows:capped,overflow:all.length-capped.length+unknown.length+(create?1:0)+sourceOverflow}}normalizeActiveIndex(){if(this.activeIndex<0)return;const navigableCount=this.renderedRows.rows.filter(row=>!row.disabled).length,next=navigableCount>0?Math.min(this.activeIndex,navigableCount-1):-1;next!==this.activeIndex&&(this.activeIndex=next)}get filtered(){const locale=this.effectiveLocale,q=this.query.trim().toLocaleLowerCase(locale),selectedLabel=this.multiple?"":this.labelFor(this._selected[0]??"")??"",effective=q&&q===selectedLabel.toLocaleLowerCase(locale)?"":q;if(!effective)return this.options;const fn=this.filter??((o,query2)=>o.label.toLocaleLowerCase(locale).includes(query2)||o.searchText.toLocaleLowerCase(locale).includes(query2));return this.options.filter(o=>fn(o,effective))}get displayValue(){return this.multiple||this.open||this.explicitInputValue?this.query:this._selected[0]?this.labelFor(this._selected[0]):""}announceOpenTransition(changed){this.openVetoed=!1;const closeAfterPositioningFailure=!this.open&&this.closeAfterPositioningFailure;if(this.closeAfterPositioningFailure=!1,!(!changed.has("open")||this._isFirstUpdate||!this.open&&this.interactionBarred)){if(!this.isConnected||closeAfterPositioningFailure){emitPopupEvent(this,"lr-hide",!1);return}this.openVetoed=this.popupController.announce(this.open,()=>{this.open=!this.open})}}show(){if(this.open||this.interactionBarred)return Promise.resolve();const settled=this.popupController.wait(!0);return this.open=!0,settled}hide(){if(!this.open)return Promise.resolve();const settled=this.popupController.wait(!1);return this.closeCleanupPending=!0,this.open=!1,settled}finalizeCloseState(){if(this.closeCleanupPending&&(this.closeCleanupPending=!1,this.activeIndex=-1,!this.multiple)){const queryChanged=this.query!=="";this.query="",this.explicitInputValue=!1,queryChanged&&this.source&&(this.asyncRows=[],this.sourceFailed=!1,this._sourceTotal=0,this._sourceTruncated=!1)}}activateListboxOverlay(){this.invalidateListboxPositioning(),this.overlayHandle?.deactivate({restoreFocus:!1}),this.restoreFocusOnClose=!0,this.overlayHandle=activateNonmodalOverlay({host:this,panel:()=>this.renderRoot.querySelector('[part="listbox"]'),onEscape:()=>{this.hide()},onBackdrop:()=>{this.restoreFocusOnClose=!1,this.hide()},restoreFocusTo:this.inputEl??null}),this.popupController.bindPointer(),this.beginListboxPositioning()}beginListboxPositioning(){const anchor=this.renderRoot.querySelector('[part="combobox"]'),listbox=this.renderRoot.querySelector('[part="listbox"]');if(anchor&&listbox){const generation=this.positioningGeneration;this.positioningReady=new Promise(resolve=>{this.resolvePositioningReady=resolve}),this.startListboxPositioning(generation,anchor,listbox)}}invalidateListboxPositioning(){this.positioningGeneration++,this.cleanup?.(),this.cleanup=void 0,this.resolvePositioningReady?.(!1),this.resolvePositioningReady=void 0}resolveCurrentPositioning(positioned){const resolve=this.resolvePositioningReady;this.resolvePositioningReady=void 0,resolve?.(positioned)}async startListboxPositioning(generation,anchor,listbox){try{const runtime=await loadAnchoredOverlayRuntime(),{place}=runtime;if(generation!==this.positioningGeneration||!this.open||!this.isConnected||this.renderRoot.querySelector('[part="combobox"]')!==anchor||this.renderRoot.querySelector('[part="listbox"]')!==listbox)return;this.placedTopLayer=syncTopLayerRelease(listbox,this.placedTopLayer,this.topLayer,runtime);const cleanup=place(anchor,listbox,{placement:`${this.placement}-start`,...topLayerPlacement(this.topLayer,resolveEffectivePositioningStrategy(this,this._positioningStrategy,"fixed")),sync:this.sync,onPlaced:()=>{generation===this.positioningGeneration&&(this.listboxPositioned=!0,this.updateComplete.then(()=>{generation!==this.positioningGeneration||!this.open||this.resolveCurrentPositioning(!0)}))}});generation!==this.positioningGeneration?cleanup():this.cleanup=cleanup}catch{if(generation!==this.positioningGeneration||!this.open)return;this.resolveCurrentPositioning(!1),this.closeAfterPositioningFailure=!0,this.hide()}}teardownListboxOverlay(restoreFocus=this.restoreFocusOnClose){this.invalidateListboxPositioning(),this.restoringOverlayFocus=restoreFocus;try{this.overlayHandle?.deactivate({restoreFocus})}finally{this.restoringOverlayFocus=!1}this.overlayHandle=void 0,this.popupController.unbindPointer(),this.restoreFocusOnClose=!0}reconnectOpenPopup(){!this.isConnected||!this.open||(this.activateListboxOverlay(),this.source&&this.asyncRows.length===0&&this.runSource(this.query))}syncVisibleOptionsCap(){const listbox=this.renderRoot?.querySelector('[part="listbox"]');if(!listbox)return;const clear=()=>{listbox.style.removeProperty("max-block-size")},requested=typeof this.visibleOptions=="number"?finiteCount(this.visibleOptions,0):0;if(requested<=0)return clear();const rows=listbox.querySelectorAll('[part="option"]');if(rows.length<=requested)return clear();const boundary=rows[requested];if(!boundary)return clear();const cap=boundary.getBoundingClientRect().top-listbox.getBoundingClientRect().top;if(!Number.isFinite(cap)||cap<=0)return clear();listbox.style.setProperty("max-block-size",`min(${Math.ceil(cap)}px, var(--lr-positioner-available-block-size, var(--lr-size-18rem)))`)}updated(changed){if(super.updated(changed),this.syncExternalDescription(),this.syncVisibleOptionsCap(),changed.has("open")&&!this.openVetoed?this.open&&this.isConnected?(this.activateListboxOverlay(),this._isFirstUpdate||this.settleTransition("lr-after-show"),this.refreshQueued?(this.refreshQueued=!1,this.runSource(this.query)):this.source&&this.asyncRows.length===0&&this.runSource(this.query)):this.open?this.teardownListboxOverlay(!1):(this.teardownListboxOverlay(),this.interactionBarred?this.popupController.cancel():this._isFirstUpdate||this.settleTransition("lr-after-hide")):changed.has("open")&&this.openVetoed&&(this.restoreFocusOnClose=!0),changed.has("topLayer")&&!changed.has("open")&&this.open&&this.isConnected&&(this.invalidateListboxPositioning(),this.beginListboxPositioning()),changed.has("name")&&this.syncFormValue(),changed.has("validators")&&(this.updateValidity(),this.syncValidatorAttributeObserver()),(changed.has("touched")||changed.has("required")||changed.has("value")||changed.has("validators")||changed.has("validityRevision"))&&this.toggleAttribute("data-invalid",this.touched&&!this.internals.validity.valid),changed.has("activeIndex")||changed.has("listboxPositioned")){const listbox=this.renderRoot.querySelector('[part="listbox"]'),row=listbox?.querySelector('[part="option"][data-active]');listbox&&row&&revealRow(listbox,row)}}settleTransition(event){return this.popupController.settle(event,{waitForPosition:async stale=>{for(;this.open&&!this.listboxPositioned;){const readiness=this.positioningReady,positioned=await readiness;if(stale())return!1;if(positioned)break;if(readiness===this.positioningReady)return!1}return!0},conceal:()=>{this.listboxHidden=!0}})}emitValueEvents(){const self=this,data=this.resolveSelectedRowSlots().map(row=>row?.data),previousValue=this.multiple?[...this.previousSelection]:this.previousSelection[0]??"",detail={value:self.value,previousValue,data};emitValueEvents(self,"input",detail,detail2=>self.emit("lr-input",detail2)),emitValueEvents(self,"change",detail,detail2=>self.emit("lr-change",detail2))}assignValue(next){this.value=next}createOption(inputValue){if(this.liveDisabled||this.readonly||this.emit("lr-create",{inputValue},{cancelable:!0}).defaultPrevented)return;const option=this.ownerDocument.createElement(tag("option"));option.setAttribute("value",inputValue),option.textContent=inputValue,this.append(option),this.pickRow({value:inputValue,label:inputValue})}commitCustomValue(inputValue){if(this.liveDisabled||this.readonly||this.multiple||!inputValue)return;const selectionChanged=this._selected[0]!==inputValue;this.touched=!0,this._selectedLabelCache.set(inputValue,inputValue),this.assignValue(inputValue),this.query="",this.explicitInputValue=!1,this.hide(),selectionChanged&&this.emitValueEvents()}pickRow(row){const sourceOption=this.sourceOptionsByRow.get(row);if(this.liveDisabled||this.readonly||row.disabled||sourceOption&&(sourceOption.disabled||sourceOption.closest("[inert]")))return;if(row.createInput!==void 0){this.createOption(row.createInput);return}this.touched=!0;const synthetic=row.unknownValue!==void 0,selectionChanged=this.multiple||this._selected[0]!==row.value;if(this.multiple){const set=new Set(this._selected);set.has(row.value)?(set.delete(row.value),this._selectedRowCache.delete(row.value)):(set.add(row.value),synthetic||(this._selectedLabelCache.set(row.value,row.label),this._selectedRowCache.set(row.value,row))),this.assignValue([...set]),this.query="",this.explicitInputValue=!1}else synthetic||(this._selectedLabelCache.set(row.value,row.label),this._selectedRowCache.clear(),this._selectedRowCache.set(row.value,row)),this.setValue(row.value,!0,sourceOption),this.query="",this.explicitInputValue=!1,this.hide();this.source&&this.runSource(this.query),selectionChanged&&this.emitValueEvents(),this.emit("lr-activate",{value:row.value})}removeValueAt(index){if(this.liveDisabled||this.readonly||index<0||index>=this._selected.length)return;const next=this._selected.filter((_,i)=>i!==index);this.touched=!0,this.assignValue(next),this.emitValueEvents()}clear(){if(this.liveDisabled||this.readonly)return;const hadSelection=this._selected.length>0,queryChanged=this.query!=="";!hadSelection&&!queryChanged||(hadSelection&&(this.touched=!0,this.assignValue([])),this.query="",this.explicitInputValue=!1,this.source&&this.runSource(this.query),hadSelection&&(this.emitValueEvents(),this.emit("lr-clear")),queryChanged&&this.emit("lr-filter",{value:this.query}))}refresh(){if(this.source){if(!this.open){this.refreshQueued=!0;return}this.refreshQueued=!1,this.runSource(this.query,{immediate:!0})}}runSource(query2,options){const source=this.source;if(!source)return;this.clearSourceTimer(),this.sourceAbort?.abort(),this.sourceAbort=void 0;const token=++this.sourceToken,ownerWindow=this.ownerDocument.defaultView;if(!this.isConnected||!ownerWindow)return;const request={query:query2,token,owner:ownerWindow,source};if(options?.immediate){this.runSourceRequest(request);return}this.sourceDebounce.delayMs=this._sourceDelay,this.sourceDebounce.push(request)}runSourceRequest({query:query2,token,owner:ownerWindow,source}){if(token!==this.sourceToken||!this.isConnected||this.ownerDocument.defaultView!==ownerWindow)return;const controller=new ownerWindow.AbortController;this.sourceAbort=controller,this.sourceLoading=!0,this.sourceFailed=!1,Promise.resolve().then(()=>source(query2,{signal:controller.signal,limit:MAX_SOURCE_ROWS})).then(result=>{if(token!==this.sourceToken||!this.isConnected||this.ownerDocument.defaultView!==ownerWindow)return;const normalized=normalizeSourceResult(result);this._sourceTotal=normalized.total,this._sourceTruncated=normalized.truncated,this.asyncRows=normalized.rows,this.sourceFailed=!1,this.sourceEverSettled=!0,this.normalizeActiveIndex(),this.applyPendingSelectedRows(!0);const selected=new Set(this._selected);for(const row of normalized.rows)selected.has(row.value)&&this._selectedRowCache.set(row.value,row)}).catch(err=>{token!==this.sourceToken||!this.isConnected||this.ownerDocument.defaultView!==ownerWindow||typeof err=="object"&&err!==null&&"name"in err&&err.name==="AbortError"||(this.asyncRows=[],this._sourceTotal=0,this._sourceTruncated=!1,this.activeIndex=-1,this.sourceFailed=!0,this.sourceEverSettled=!0,this.sourceErrorAnnouncements.announceAssertive(this.localize("comboboxLoadError")),this.emit("lr-source-error",{error:err,query:query2}),console.warn("<lr-combobox> source() rejected:",err))}).finally(()=>{token===this.sourceToken&&(this.sourceLoading=!1)})}clearSourceTimer(){this.sourceDebounce.cancel()}renderRows(rows,activeId){const out=[];let currentGroup,currentGroupRows=[],groupIndex=0;const selectedSet=new Set(this.committed),flushGroup=()=>{if(currentGroupRows.length){if(currentGroup){const labelId=`${this.listId}-group-${groupIndex++}`;out.push(html`<div role="group" aria-labelledby=${labelId}>
1
+ import{__decorate}from"tslib";import{emitValueEvents}from"../../../internal/value-events.js";import{setNativeRangeText,nativeAutocorrectAttribute}from"../../../internal/native-text-control.js";import{renderFormControlHintError}from"../../../internal/form-control-template.js";import{installFormControlLabelSupport}from"../../../internal/form-control-labels.js";import{FormControlController,reflectFormName}from"../../../internal/form-control-controller.js";import{GlassScrollLayer}from"../../../internal/glass-scroll-layer.js";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{acquireNativeControlDescription}from"../../../internal/native-control-description.js";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{LyraFormControlElement}from"../../../internal/form-control-element.js";import{loadAnchoredOverlayRuntime,syncTopLayerRelease,topLayerPlacement}from"../../../internal/anchored-overlay-runtime.js";import{hostAriaLabel,nextId,srOnly}from"../../../internal/a11y.js";import{chevronIcon,closeIcon}from"../../../internal/icons.js";import{VALIDITY_ANCHOR}from"../../../internal/anchored-validity.js";import{setCustomState,syncValidityStates}from"../../../internal/custom-states.js";import{submitOnEnter}from"../../../internal/submit-on-enter.js";import{finiteCount,finiteDuration}from"../../../internal/numbers.js";import{PopupController,emitPopupEvent}from"../../../internal/popup-controller.js";import{revealRow}from"../../../internal/reveal-row.js";import{DebounceController}from"../../../internal/debounce-controller.js";import{sizes}from"../../../internal/sizes.styles.js";import{styles}from"./combobox.styles.js";import{autocorrectConverter,literalSetConverter,omittedEmptyStringConverter,optionalLiteralSetConverter,spellcheckConverter}from"../../../internal/converters.js";import{resolveEffectivePositioningStrategy}from"../../../internal/positioning-strategy.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{sanitizeCssColor}from"../../../internal/safe-css.js";import{getFormOwner,isBarredFromValidation,setFormOwner}from"../../../internal/form-associated.js";import{tag}from"../../../internal/prefix.js";import{renderInertPresentation}from"../../../internal/inert-presentation.js";import{collectInitialSlotAssignment}from"../../../internal/initial-slot-collection.js";import{renderDataState}from"../../../internal/data-state-renderer.js";import{SlotPresenceController}from"../../../internal/slot-presence-controller.js";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{activateNonmodalOverlay}from"../../../internal/nonmodal-overlay-manager.js";import{isOptionSelectedDirty,isOptionSelectedWrite,wasOptionInitiallySelected,RESET_OPTION_SELECTED_FROM_OWNER,SET_OPTION_SELECTED_FROM_OWNER}from"../../../internal/option-selection.js";import{isHtmlElement}from"../../../internal/dom-guards.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{LYRA_DEFAULT_comboboxCreate,LYRA_DEFAULT_comboboxLabel,LYRA_DEFAULT_comboboxLoadError,LYRA_DEFAULT_comboboxOverflow,LYRA_DEFAULT_comboboxRequired,LYRA_DEFAULT_comboboxSelectedOverflow}from"../../../internal/default-strings/forms.generated.js";import{LYRA_DEFAULT_clear,LYRA_DEFAULT_collapse,LYRA_DEFAULT_copy,LYRA_DEFAULT_date,LYRA_DEFAULT_details,LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_loading,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_noData,LYRA_DEFAULT_noMatches,LYRA_DEFAULT_notInCatalog,LYRA_DEFAULT_open,LYRA_DEFAULT_progress,LYRA_DEFAULT_removeWithContext,LYRA_DEFAULT_restore,LYRA_DEFAULT_retry,LYRA_DEFAULT_search,LYRA_DEFAULT_select,LYRA_DEFAULT_tableLoadFailed,LYRA_DEFAULT_valueInvalid}from"../../../internal/default-strings/shared.generated.js";installFormControlLabelSupport();function isLyraOptionElement(value){return isHtmlElement(value)&&value.localName===tag("option")}function normalizeSelectionValues(next){return Array.isArray(next)?next.filter(value=>typeof value=="string"):typeof next=="string"?[next]:[]}const POSITIONING_STRATEGY=optionalLiteralSetConverter(["absolute","fixed"]),APPEARANCE=literalSetConverter(["accent","filled","outlined","filled-outlined","plain"],"outlined"),VALIDITY_FLAG_KEYS=new Set(["badInput","customError","patternMismatch","rangeOverflow","rangeUnderflow","stepMismatch","tooLong","tooShort","typeMismatch","valueMissing"]),comboboxSpellcheckConverter={...spellcheckConverter,fromAttribute:(value,type)=>value===null?void 0:spellcheckConverter.fromAttribute?.(value,type)};function adornmentContent(value){return typeof value=="string"||typeof value=="number"?html`<span>${value}</span>`:value}function isValidityFlagKey(value){return typeof value=="string"&&VALIDITY_FLAG_KEYS.has(value)}const MAX_SOURCE_ROWS=2e3,MAX_SOURCE_TEXT_UNITS=25e4,MAX_SOURCE_FIELD_UNITS=4096,MAX_RENDER_ROWS=1e3;function isRenderable(value,nested=!1){if(typeof value=="string"||typeof value=="number")return!0;if(typeof value!="object"||value===null)return!1;if(Array.isArray(value))return!nested&&value.every(item=>isRenderable(item,!0));const{nodeType,cloneNode,strings}=value;return typeof nodeType=="number"&&typeof cloneNode=="function"||Array.isArray(strings)&&Object.hasOwn(strings,"raw")}function normalizeSourceResult(input){let candidateRows,candidateTotal;try{Array.isArray(input)?candidateRows=input:typeof input=="object"&&input!==null&&(candidateRows=input.rows,candidateTotal=input.total)}catch{throw new TypeError("Invalid combobox source result")}if(!Array.isArray(candidateRows))throw new TypeError("Invalid combobox source result");const providerTotal=typeof candidateTotal=="number"&&Number.isFinite(candidateTotal)&&candidateTotal>=0?Math.trunc(candidateTotal):candidateRows.length,rows=[];let textUnits=0;const limit=Math.min(candidateRows.length,MAX_SOURCE_ROWS);for(let index=0;index<limit;index++)try{const value=candidateRows[index]?.value,label=candidateRows[index]?.label;if(typeof value!="string"||typeof label!="string"||value.length>MAX_SOURCE_FIELD_UNITS||label.length>MAX_SOURCE_FIELD_UNITS)continue;const source=candidateRows[index],optionalText=key=>{const candidate=source[key];return typeof candidate=="string"&&candidate.length<=MAX_SOURCE_FIELD_UNITS?candidate:void 0},content=key=>{const candidate=source[key];return isRenderable(candidate)?candidate:void 0},icon=content("icon"),start=content("start"),end=content("end"),sub=optionalText("sub"),accessibleLabel=optionalText("accessibleLabel"),dotColor=optionalText("dotColor"),title=optionalText("title"),group=optionalText("group"),badgeCandidate=source.badge,badge=typeof badgeCandidate=="string"&&badgeCandidate.length<=MAX_SOURCE_FIELD_UNITS||typeof badgeCandidate=="number"&&Number.isFinite(badgeCandidate)?badgeCandidate:void 0,units=value.length+label.length+(sub?.length??0)+(accessibleLabel?.length??0)+(dotColor?.length??0)+(title?.length??0)+(group?.length??0)+(typeof badge=="string"?badge.length:0);if(textUnits+units>MAX_SOURCE_TEXT_UNITS)break;textUnits+=units,rows.push({value,label,...sub===void 0?{}:{sub},...icon===void 0?{}:{icon},...start===void 0?{}:{start},...end===void 0?{}:{end},...badge===void 0?{}:{badge},...accessibleLabel===void 0?{}:{accessibleLabel},...source.data===void 0?{}:{data:source.data},...dotColor===void 0?{}:{dotColor},...title===void 0?{}:{title},...group===void 0?{}:{group},...typeof source.disabled=="boolean"?{disabled:source.disabled}:{}})}catch{}const total=Math.max(providerTotal,candidateRows.length);return{rows,total,truncated:total>rows.length}}class LyraCombobox extends LyraFormControlElement{static{this.defaultStrings={...super.defaultStrings,clear:LYRA_DEFAULT_clear,collapse:LYRA_DEFAULT_collapse,comboboxCreate:LYRA_DEFAULT_comboboxCreate,comboboxLabel:LYRA_DEFAULT_comboboxLabel,comboboxLoadError:LYRA_DEFAULT_comboboxLoadError,comboboxOverflow:LYRA_DEFAULT_comboboxOverflow,comboboxRequired:LYRA_DEFAULT_comboboxRequired,comboboxSelectedOverflow:LYRA_DEFAULT_comboboxSelectedOverflow,copy:LYRA_DEFAULT_copy,date:LYRA_DEFAULT_date,details:LYRA_DEFAULT_details,fieldRequired:LYRA_DEFAULT_fieldRequired,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,noData:LYRA_DEFAULT_noData,noMatches:LYRA_DEFAULT_noMatches,notInCatalog:LYRA_DEFAULT_notInCatalog,open:LYRA_DEFAULT_open,progress:LYRA_DEFAULT_progress,removeWithContext:LYRA_DEFAULT_removeWithContext,restore:LYRA_DEFAULT_restore,retry:LYRA_DEFAULT_retry,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select,tableLoadFailed:LYRA_DEFAULT_tableLoadFailed,valueInvalid:LYRA_DEFAULT_valueInvalid}}static{this.collectionSupport=collectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-input","lr-change"])}static{this.identityEventDetailCollectionItems=Object.freeze({"lr-input":Object.freeze(["data"]),"lr-change":Object.freeze(["data"])})}static{this.formAssociated=!0}static{this.styles=[LyraElement.styles,sizes,styles,srOnly]}static{this.properties={customError:{attribute:"custom-error",reflect:!0,noAccessor:!0},multiple:{type:Boolean,reflect:!0,noAccessor:!0},disabled:{type:Boolean,reflect:!0,noAccessor:!0},required:{type:Boolean,reflect:!0,noAccessor:!0},readonly:{type:Boolean,reflect:!0,noAccessor:!0},value:{noAccessor:!0},name:{reflect:!0,noAccessor:!0,converter:omittedEmptyStringConverter},maxOptionsVisible:{type:Number,attribute:"max-options-visible",noAccessor:!0},maxRender:{type:Number,attribute:"max-render",noAccessor:!0},sourceDelay:{type:Number,attribute:"source-delay",noAccessor:!0}}}get open(){return this._open}set open(next){const old=this._open,liveDisabled=this.effectiveDisabled||typeof this.matches=="function"&&this.matches(":disabled");if(this._open=!!next&&!this.readonly&&!liveDisabled,this._open===old){next&&!this._open&&this.hasAttribute("open")&&this.removeAttribute("open");return}this.requestUpdate("open",old)}get appearance(){return this._appearance}set appearance(next){const normalized=APPEARANCE.normalizeReflected(this,"appearance",next),old=this._appearance;this._appearance=normalized,normalized!==old&&this.requestUpdate("appearance",old)}get positioningStrategy(){return this._positioningStrategy??"fixed"}set positioningStrategy(next){const normalized=POSITIONING_STRATEGY.normalize(next)??"fixed",old=this.positioningStrategy;this._positioningStrategy=normalized,normalized!==old&&this.requestUpdate("positioningStrategy",old)}get autocorrect(){return this.autocorrectValue}set autocorrect(next){this.autocorrectValue=!!next,this.requestUpdate()}get inputmode(){return this.inputMode}set inputmode(next){this.inputMode=next??""}get enterkeyhint(){return this.enterKeyHint}set enterkeyhint(next){this.enterKeyHint=next??""}get inputValue(){return this.query}set inputValue(next){this.explicitInputValue=!0,this.query=next??"",this.activeIndex=-1,this.source&&this.runSource(this.query),this.requestUpdate()}constructor(){super(),this.placeholder="",this.label="",this.hint="",this.errorText="",this.allowCreate=!1,this.allowCustomValue=!1,this.withUnknownOption=!1,this.loading=!1,this._appearance="outlined",this.placement="bottom",this.topLayer=!1,this.size="m",this.pill=!1,this.clearable=!1,this.withClear=!1,this.withLabel=!1,this.withHint=!1,this.validators=[],this.autocomplete="off",this.inputMode="",this.enterKeyHint="",this.spellcheck=!1,this.autocapitalize="",this.autocorrectValue=!0,this.filter=null,this.source=null,this.query="",this.explicitInputValue=!1,this.activeIndex=-1,this.options=[],this.optionsObserved=!1,this.touched=!1,this.validityRevision=0,this.slotPresence=new SlotPresenceController(this),this.sourceLoading=!1,this.sourceFailed=!1,this.sourceEverSettled=!1,this.asyncRows=[],this._sourceTotal=0,this._sourceTruncated=!1,this.sourceErrorAnnouncements=new AnnouncementSinkController(this,{eager:["assertive"]}),this.sourceDebounce=new DebounceController(0,request=>this.runSourceRequest(request),()=>this.ownerDocument.defaultView),this.sourceToken=0,this.refreshQueued=!1,this._sourceWarmed=!1,this._selectedLabelCache=new Map,this._selectedRowCache=new Map,this._renderedRows=[],this._open=!1,this._fieldsetDisabled=!1,this.listId=nextId("combobox-list"),this.inputId=nextId("combobox-input"),this.listboxPositioned=!1,this.positioningGeneration=0,this.positioningReady=Promise.resolve(!1),this.restoreFocusOnClose=!0,this.restoringOverlayFocus=!1,this.popupController=new PopupController({host:this,popup:()=>this.renderRoot.querySelector('[part="listbox"]'),emit:(name,cancelable)=>emitPopupEvent(this,name,cancelable),onPointer:event=>this.onDocPointer(event)}),this.listboxHidden=!0,this.listboxRendered=!1,this._isFirstUpdate=!0,this.openVetoed=!1,this.closeAfterPositioningFailure=!1,this.closeCleanupPending=!1,this._selected=[],this.sourceOptionsByRow=new WeakMap,this._valueDirty=!1,this._multiple=!1,this._disabled=!1,this._required=!1,this._readonly=!1,this._defaultSelected=[],this._defaultCaptured=!1,this._restoredStateActive=!1,this._name="",this._maxOptionsVisible=3,this._maxRender=200,this._sourceDelay=200,this.localDescriptionIds="",this.previousSelection=[],this.markInteracted=()=>{this.touched||(this.touched=!0,this.updateValidity(),this.syncCustomStates())},this.collectOptions=e=>{this.collectOptionsFromSlot(e.target)},this.optionRefreshPending=!1,this.onOptionChange=e=>{e.stopPropagation();const option=e.composedPath().find(isLyraOptionElement);if(isLyraOptionElement(option)&&this.options.includes(option)&&isOptionSelectedWrite(e)){if(this.multiple){const next=option.selected?this._selected.includes(option.value)?this._selected:[...this._selected,option.value]:this._selected.filter(value=>value!==option.value);this.assignValue(next)}else{if(this._valueDirty=!0,this._restoredStateActive=!1,!option.selected&&this.singleSelectedOption!==option)return;this.setValue(option.selected?option.value:[],!0,option.selected?option:void 0)}return}isLyraOptionElement(option)&&this.adornmentClones.get(option)?.markup!==this.adornmentMarkup(option)&&this.adornmentClones.delete(option),!this.optionRefreshPending&&(this.optionRefreshPending=!0,queueMicrotask(()=>{this.optionRefreshPending=!1,this.refreshOptionDefaults(),this.reflectSelected(),this.options=[...this.options],this.normalizeActiveIndex()}))},this.adornmentClones=new WeakMap,this.onDocPointer=e=>{if(!e.composedPath().includes(this)){if(this.overlayHandle?.isActive()){this.overlayHandle.dismissBackdrop();return}this.restoreFocusOnClose=!1,this.hide()}},this.onInput=e=>{this.liveDisabled||this.readonly||(this.explicitInputValue=!1,this.query=e.target.value,this.activeIndex=-1,this.show(),this.source&&this.runSource(this.query),this.emit("lr-filter",{value:this.query}))},this.onInputBlur=event=>{this.liveDisabled||(this.touched=!0),this.syncCustomStates(),this.onComboFocusOut(event),relayNativeEvent(this,event)},this.onComboFocusOut=event=>{const trigger=this.renderRoot.querySelector('[part="combobox"]'),target=event.relatedTarget;target&&typeof target.nodeType=="number"&&trigger?.contains(target)||(this.restoreFocusOnClose=!1,this.hide())},this.onInputFocus=event=>{if(this.liveDisabled){event.stopPropagation();return}this.restoringOverlayFocus||this.show(),relayNativeEvent(this,event)},this.onKeyDown=e=>{if(e.isComposing||e.keyCode===229||this.liveDisabled||this.readonly)return;const navigable=["ArrowDown","ArrowUp","Enter","End"].includes(e.key)?this.renderedRows.rows.filter(r=>!r.disabled):[];switch(e.key){case"ArrowDown":case"ArrowUp":if(e.preventDefault(),!this.open){this.activeIndex=navigable.findIndex(row=>this.committed.includes(row.value)),this.show();return}if(e.key==="ArrowDown"){this.activeIndex=Math.min(navigable.length-1,this.activeIndex+1);break}this.activeIndex=Math.max(0,this.activeIndex-1);break;case"Enter":{const activeRow=navigable[this.activeIndex];if(this.open&&this.activeIndex>=0&&activeRow){e.preventDefault(),this.pickRow(activeRow);break}const create=this.createRow;if(this.open&&create){e.preventDefault(),this.createOption(create.createInput);break}if(this.open&&this.allowCustomValue&&!this.multiple&&this.query.trim()){e.preventDefault(),this.commitCustomValue(this.query.trim());break}submitOnEnter(this,e);break}case"Escape":this.open&&(!this.overlayHandle?.isActive()||this.overlayHandle.isTopmost())&&(e.preventDefault(),this.hide());break;case"Home":this.open&&(e.preventDefault(),this.activeIndex=0);break;case"End":this.open&&(e.preventDefault(),this.activeIndex=navigable.length-1);break;case"Backspace":this.multiple&&!this.query&&this._selected.length&&this.removeValueAt(this._selected.length-1);break}},this.onComboMouseDown=e=>{this.liveDisabled||e.composedPath()[0]!==this.inputEl&&(e.target.closest("button")||(e.preventDefault(),this.inputEl?.focus(),this.show()))},this.onListboxMouseDown=e=>{e.preventDefault()},this.onListboxClick=e=>{const optionEl=e.target.closest('[part="option"]'),row=this._renderedRows[Number(optionEl?.dataset.index)];row&&this.pickRow(row)},this.validityController=new FormControlController(this,{invalid:init=>this.emit("lr-invalid",null,init),interacted:this.markInteracted,customError:()=>this.validityController.customValidityMessage}),this.internals=this.validityController.formInternals,new GlassScrollLayer(this,'[part="listbox"]',()=>this.open)}get form(){return getFormOwner(this.internals)}set form(owner){setFormOwner(this,owner)}get validationTarget(){return this.validationTargetOverride??this.inputEl??void 0}set validationTarget(next){this.validationTargetOverride=next??void 0,this.validityController.refreshAnchor()}resetValidity(){this.validityController.setCustomValidity(""),this.updateValidity()}get input(){return this.inputEl??null}get selectionStart(){return this.inputEl?.selectionStart??null}set selectionStart(value){this.inputEl&&(this.inputEl.selectionStart=value)}get selectionEnd(){return this.inputEl?.selectionEnd??null}set selectionEnd(value){this.inputEl&&(this.inputEl.selectionEnd=value)}get selectionDirection(){return this.inputEl?.selectionDirection}set selectionDirection(value){this.inputEl&&(this.inputEl.selectionDirection=value)}get liveDisabled(){return this.effectiveDisabled||this.matches(":disabled")}get interactionBarred(){return this.liveDisabled||this.readonly}focus(options){this.liveDisabled||this.inputEl?.focus(options)}blur(){this.inputEl?.blur()}click(){this.liveDisabled||(this.inputEl?.focus(),this.show())}select(){this.inputEl?.select()}setSelectionRange(start,end,direction){this.inputEl?.setSelectionRange(start,end,direction)}setRangeText(replacement,start,end,selectMode){const input=this.inputEl;input&&(setNativeRangeText(input,replacement,start,end,selectMode),this.explicitInputValue=!0,this.query=input.value,this.activeIndex=-1,this.source&&this.runSource(this.query))}[VALIDITY_ANCHOR](){return this.validationTarget}syncExternalDescription(){if(!this.isConnected)return;const target=this.renderRoot.querySelector('[part="combobox-input"]');target&&(this.externalDescriptionLease?this.externalDescriptionLease.update(target):this.externalDescriptionLease=acquireNativeControlDescription(this,target,()=>this.localDescriptionIds))}releaseExternalDescription(){this.externalDescriptionLease?.release(),this.externalDescriptionLease=void 0}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.syncExternalDescription(),this.updateValidity(),this.hasUpdated&&this.syncValidatorAttributeObserver(),this.hasUpdated&&queueMicrotask(()=>{this.open?this.reconnectOpenPopup():this.source&&this._selected.length&&this.asyncRows.length===0&&this.runSource("")})}adoptedCallback(){super.adoptedCallback(),this.popupController.cancel(),this.releaseExternalDescription(),this.hasUpdated&&this.syncExternalDescription(),this.listboxPositioned=!1,this.invalidateListboxPositioning(),this.overlayHandle?.deactivate({restoreFocus:!1}),this.overlayHandle=void 0,this.popupController.unbindPointer(),this.clearSourceTimer(),this.sourceToken+=1,this.sourceAbort?.abort(),this.sourceAbort=void 0,this.sourceErrorAnnouncements.adopted()}willUpdate(changed){super.willUpdate(changed),this._isFirstUpdate=!this.hasUpdated,this.announceOpenTransition(changed),this.open?(this.listboxHidden=!1,this.listboxRendered=!0):changed.has("open")&&this.interactionBarred&&(this.listboxHidden=!0),changed.has("open")&&!this.openVetoed&&(this.listboxPositioned=!1),changed.has("open")&&this.openVetoed?this.closeCleanupPending=!1:changed.has("open")&&!this.open&&this.finalizeCloseState(),changed.has("source")&&(this.clearSourceTimer(),this.sourceAbort?.abort(),this.sourceAbort=void 0,this.sourceToken++,this.sourceLoading=!1,this.sourceFailed=!1,this.sourceEverSettled=!1,this.asyncRows=[],this._sourceTotal=0,this._sourceTruncated=!1,this.activeIndex=-1,this._sourceWarmed=!1,this.source&&this.open&&this.runSource(this.query)),!this._sourceWarmed&&this.source&&(this._selected.length>0||(this.pendingSelectedRowValues?.length??0)>0)&&this.asyncRows.length===0&&(this._sourceWarmed=!0,this.runSource(""))}firstUpdated(changed){super.firstUpdated(changed);const slot=this.optionsSlot;queueMicrotask(()=>{collectInitialSlotAssignment(slot,s=>{this.optionsObserved=!0,s.assignedElements({flatten:!0}).some(isLyraOptionElement)&&this.collectOptionsFromSlot(s)})})}get name(){return this._name}set name(next){const old=this._name;this._name=next??"",reflectFormName(this,this._name),this.syncFormValue(),this.requestUpdate("name",old)}get multiple(){return this._multiple}set multiple(next){const old=this._multiple;this._multiple=!!next,this.toggleAttribute("multiple",this._multiple),this.reflectSelected(),this.syncFormValue(),this.requestUpdate("multiple",old)}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this._fieldsetDisabled=this.validityController?.fieldsetDisabled(this._fieldsetDisabled)??this._fieldsetDisabled,this._disabled&&this.hide(),this.updateValidity(),this.requestUpdate("disabled",old)}get required(){return this._required}set required(next){const old=this._required;this._required=!!next,this.toggleAttribute("required",this._required),this.updateValidity(),this.requestUpdate("required",old)}get readonly(){return this._readonly}set readonly(next){const old=this._readonly;this._readonly=!!next,this.toggleAttribute("readonly",this._readonly),this._readonly&&this.hide(),this.updateValidity(),this.requestUpdate("readonly",old)}get value(){return this.multiple?[...this._selected]:this._selected[0]??""}set value(next){this.setValue(next,!0)}setValue(next,dirty,preferred){const old=this._selected;this.previousSelection=old,this.singleSelectedOption=preferred,dirty&&(this._restoredStateActive=!1,this._valueDirty=!0),this._selected=normalizeSelectionValues(next);const selected=new Set(this._selected);if(selected.size>0){const rows=this.rowsByValue();for(const value of selected){const row=rows.get(value);row&&this._selectedRowCache.set(value,row)}}for(const value of this._selectedRowCache.keys())selected.has(value)||this._selectedRowCache.delete(value);for(const value of this._selectedLabelCache.keys())selected.has(value)||this._selectedLabelCache.delete(value);this.syncFormValue(),this.reflectSelected(),this.updateValidity(),this.requestUpdate("value",old)}get maxOptionsVisible(){return this._maxOptionsVisible}set maxOptionsVisible(next){const old=this._maxOptionsVisible;this._maxOptionsVisible=finiteCount(next,3),this.requestUpdate("maxOptionsVisible",old)}get maxRender(){return this._maxRender}get sourceDelay(){return this._sourceDelay}set sourceDelay(next){const old=this._sourceDelay;this._sourceDelay=finiteDuration(next,200),this.requestUpdate("sourceDelay",old)}set maxRender(next){const old=this._maxRender;this._maxRender=Math.min(finiteCount(next,200),MAX_RENDER_ROWS),this.requestUpdate("maxRender",old)}get sourceTotal(){return this._sourceTotal}get sourceTruncated(){return this._sourceTruncated}get selectedRows(){return this.resolveSelectedRowSlots().filter(row=>row!=null).map(row=>({...row}))}resolveSelectedRowSlots(){let rows;return this.committed.map(value=>this._selectedRowCache.get(value)??(rows??=this.rowsByValue()).get(value))}get committed(){return this.multiple?this._selected:this._selected.slice(0,1)}rowsByValue(){const rows=new Map;for(const row of[...this.effectiveRows,...this.asyncRows])rows.has(row.value)||rows.set(row.value,row);return rows}set selectedRows(next){const values=[],seen=new Set;if(Array.isArray(next))for(const candidate of next){let value;try{value=candidate?.value}catch{continue}typeof value!="string"||seen.has(value)||(seen.add(value),values.push(value))}if(values.length>0&&this.selectionSourceRows.length===0){this.pendingSelectedRowValues=values,this.source&&this.isConnected&&(this._sourceWarmed=!0,this.runSource(""));return}this.pendingSelectedRowValues=void 0,this.applySelectedRowValues(values)}get barredFromValidation(){return isBarredFromValidation(this,this.internals)}validatorResult(){const self=this,current=self.value;for(const validator of Array.isArray(this.validators)?this.validators:[]){let result;try{if(typeof validator=="object"&&validator!==null&&"checkValidity"in validator){const checked=validator.checkValidity(this);if(checked?.isValid===!0)continue;const flags={};for(const key of Array.isArray(checked?.invalidKeys)?checked.invalidKeys:[])isValidityFlagKey(key)&&(flags[key]=!0);Object.values(flags).some(Boolean)||(flags.customError=!0);let message=typeof checked?.message=="string"?checked.message:"";return!message&&typeof validator.message=="string"&&(message=validator.message),!message&&typeof validator.message=="function"&&(message=validator.message(this)),{flags,message:message||this.localize("valueInvalid")}}result=typeof validator=="function"?validator(current,self):validator?.validate(current,self)}catch{return{flags:{customError:!0},message:this.localize("valueInvalid")}}if(!(result===void 0||result===!0)){if(typeof result=="string")return{flags:{customError:!0},message:result};if(result===!1)return{flags:{customError:!0},message:this.localize("valueInvalid")};if(result&&typeof result=="object"&&Object.values(result).some(Boolean))return{flags:result,message:this.localize("valueInvalid")}}}return{}}syncValidatorAttributeObserver(){this.disconnectValidatorAttributeObserver();const owner=this.ownerDocument.defaultView,MutationObserverCtor=owner?.MutationObserver;if(!this.isConnected||!owner||typeof MutationObserverCtor!="function")return;const attributes=new Set;for(const validator of Array.isArray(this.validators)?this.validators:[]){if(typeof validator!="object"||validator===null||!("checkValidity"in validator))continue;let observed;try{observed=validator.observedAttributes}catch{continue}if(Array.isArray(observed))for(const name of observed)typeof name=="string"&&name.length>0&&attributes.add(name)}if(attributes.size===0)return;const binding={},observer=new MutationObserverCtor(()=>{this.validatorAttributeObserver!==binding||!this.isConnected||this.ownerDocument.defaultView!==owner||(this.updateValidity(),this.validityRevision++)});binding.observer=observer,binding.owner=owner;try{observer.observe(this,{attributes:!0,attributeFilter:[...attributes]}),this.validatorAttributeObserver=binding}catch{observer.disconnect()}}disconnectValidatorAttributeObserver(){const binding=this.validatorAttributeObserver;this.validatorAttributeObserver=void 0,binding?.observer.disconnect()}updateValidity(){if(this.barredFromValidation){this.validityController.setValidity({}),this.syncCustomStates();return}const flags={};let message="";this.required&&this._selected.length===0&&(flags.valueMissing=!0,message=this.localize("comboboxRequired"));const configured=this.validatorResult();configured.flags&&Object.assign(flags,configured.flags),configured.message&&(message=configured.message),this.validityController.setValidity(flags,message),this.syncCustomStates()}syncCustomStates(){syncValidityStates(this.internals,{required:this.required,hasInteracted:this.touched,barred:this.barredFromValidation}),setCustomState(this.internals,"blank",this._selected.length===0),setCustomState(this.internals,"disabled",this.effectiveDisabled)}syncFormValue(){const state2=JSON.stringify(this._selected);if(this.multiple){if(!this.name){this.internals.setFormValue(null,state2);return}const fd=new FormData;for(const v of this._selected)fd.append(this.name,v);this.internals.setFormValue(fd,state2)}else this.internals.setFormValue(this._selected[0]??"",state2)}get effectiveDisabled(){return this.disabled||this._fieldsetDisabled}formResetCallback(){this.touched=!1,this._restoredStateActive=!1,this._valueDirty=!1;const resetValues=this._defaultSelected.length>0?this._defaultSelected:this.options.filter(option=>wasOptionInitiallySelected(option)).map(option=>option.value);this._defaultSelected.length===0&&resetValues.length>0&&(this._defaultSelected=[...resetValues]);const defaults=new Set(resetValues);for(const option of this.options)option[RESET_OPTION_SELECTED_FROM_OWNER](defaults.has(option.value));this.setValue(this.multiple?[...resetValues]:resetValues.slice(0,1),!1),this.query="",this.explicitInputValue=!1}formStateRestoreCallback(state2,reason){let selected=[];if(typeof state2=="string")try{const parsed=JSON.parse(state2);Array.isArray(parsed)&&parsed.every(value=>typeof value=="string")&&(selected=parsed)}catch{}this.assignValue(this.multiple?selected:selected.slice(0,1)),this._restoredStateActive=!0}formDisabledCallback(disabled){if(this.validityController?.reflectingDisabled)return;const wasDisabled=this.effectiveDisabled;this._fieldsetDisabled=disabled,wasDisabled!==this.effectiveDisabled&&(disabled&&this.hide(),this.updateValidity(),this.requestUpdate())}checkValidity(){return this.validityController.checkValidity(()=>this.updateValidity())}reportValidity(){return this.validityController.syncConstraints(),this.touched=!0,this.updateValidity(),this.syncCustomStates(),this.internals.reportValidity()}setCustomValidity(message){this.validityController.setCustomValidity(message??""),this.syncCustomStates()}disconnectedCallback(){this.listboxHidden=!0,this.releaseExternalDescription(),this.popupController.cancel(),this.listboxPositioned=!1,this.disconnectValidatorAttributeObserver(),super.disconnectedCallback(),this.invalidateListboxPositioning(),this.clearSourceTimer(),this.sourceToken+=1,this.sourceAbort?.abort(),this.sourceAbort=void 0,this.overlayHandle?.deactivate({restoreFocus:!1}),this.overlayHandle=void 0,this.popupController.unbindPointer(),this.open=!1}collectOptionsFromSlot(slot){const previous=new Set(this.options);if(this.optionsObserved=!0,this.options=slot.assignedElements({flatten:!0}).filter(isLyraOptionElement),this.adornmentClones=new WeakMap,this.normalizeActiveIndex(),this.applyPendingSelectedRows(),this._defaultCaptured){const newDefaults=this.options.filter(option=>!previous.has(option)&&option.defaultSelected),newLive=this.options.filter(option=>!previous.has(option)&&option.selected&&!option.defaultSelected);this.refreshOptionDefaults();const eligible=[...!this._restoredStateActive&&!this._valueDirty?newDefaults:[],...this._restoredStateActive?[]:newLive];if(eligible.length){const values=eligible.map(option=>option.value),next=this.multiple?[...new Set([...this._selected,...values])]:values[values.length-1];newLive.length>0?this.assignValue(next):this.setValue(next,!1);return}}else{this._defaultCaptured=!0;const allDefaults=this.options.filter(option=>option.defaultSelected).map(option=>option.value),allLive=this.options.filter(option=>option.selected).map(option=>option.value),defaults=this.multiple?allDefaults:allDefaults.slice(0,1),live=this.multiple?allLive:allLive.slice(0,1),initialLive=this.options.filter(option=>wasOptionInitiallySelected(option)).map(option=>option.value),optionDirty=this.options.some(option=>isOptionSelectedDirty(option)),dirtyValues=this.options.filter(option=>isOptionSelectedDirty(option)&&option.selected).map(option=>option.value);this._defaultSelected=[...defaults.length>0?defaults:initialLive.length>0?initialLive:live];const fromDefaults=defaults.length>0,initial=optionDirty?this.multiple?allLive:dirtyValues.slice(-1)[0]?dirtyValues.slice(-1):live:fromDefaults?defaults:live;if(initial.length&&!this._restoredStateActive&&!this._valueDirty){const next=this.multiple?initial:initial[0];fromDefaults&&!optionDirty?this.setValue(next,!1):this.assignValue(next);return}optionDirty&&(this._valueDirty=!0)}this.reflectSelected()}refreshOptionDefaults(){const declared=this.options.filter(option=>option.defaultSelected).map(option=>option.value);this._defaultSelected=this.multiple?declared:declared.slice(0,1),!this._valueDirty&&!this._restoredStateActive&&this.setValue([...this._defaultSelected],!1)}reflectSelected(){const value=this._selected[0];(!this.singleSelectedOption||!this.options.includes(this.singleSelectedOption)||this.singleSelectedOption.value!==value)&&(this.singleSelectedOption=this.options.find(option=>option.value===value));const selected=new Set(this._selected);for(const option of this.options)option[SET_OPTION_SELECTED_FROM_OWNER](this.multiple?selected.has(option.value):option===this.singleSelectedOption)}labelFor(value){const nonBlank=label=>label!==void 0&&label.trim().length>0?label:void 0;if(this.getUnknownLabel&&this.isUnknownValue(value)){const override=nonBlank(this.getUnknownLabel(value));if(override!==void 0)return override}return(!this.source&&!this.multiple&&this.singleSelectedOption?.value===value?nonBlank(this.singleSelectedOption.label):void 0)??nonBlank(this._selectedLabelCache.get(value))??nonBlank(this.options.find(o=>o.value===value)?.label)??nonBlank(this.asyncRows.find(r=>r.value===value)?.label)??(this.loading||this.source&&!this.sourceEverSettled?this.statusText("loading",this.loadingText):void 0)??value}isUnknownValue(value){return!this.source&&!this.optionsObserved||this.loading||this.source&&!this.sourceEverSettled?!1:!(!this.source&&!this.multiple&&this.singleSelectedOption?.value===value||this._selectedLabelCache.has(value)||this.options.some(option=>option.value===value)||this.asyncRows.some(row=>row.value===value))}adornmentMarkup(option){return Array.from(option.children).filter(child=>["start","end","prefix","suffix"].includes(child.getAttribute("slot")??"")).map(child=>child.outerHTML).join("")}adornmentsFor(option){const cached=this.adornmentClones.get(option);if(cached)return cached;const cloneSlot=selector=>{const nodes=Array.from(option.querySelectorAll(selector));if(nodes.length!==0)return nodes.map(node=>node.cloneNode(!0))},resolved={markup:this.adornmentMarkup(option),start:cloneSlot(':scope > [slot="start"], :scope > [slot="prefix"]'),end:cloneSlot(':scope > [slot="end"], :scope > [slot="suffix"]')};return this.adornmentClones.set(option,resolved),resolved}rowForOption(option){const adornments=this.adornmentsFor(option),row={value:option.value,label:option.label||option.value,sub:option.sub||void 0,dotColor:option.dotColor||void 0,title:option.title||void 0,group:option.group||void 0,disabled:option.disabled||option.inert||option.closest("[inert]")!==null,data:option.data,...adornments.start===void 0?{}:{start:adornments.start},...adornments.end===void 0?{}:{end:adornments.end}};return this.sourceOptionsByRow.set(row,option),row}get selectionSourceRows(){return this.source?this.asyncRows:this.options.map(option=>this.rowForOption(option))}applySelectedRowValues(values){const rowsByValue=new Map;for(const row of this.selectionSourceRows)rowsByValue.has(row.value)||rowsByValue.set(row.value,row);const rows=values.map(value=>rowsByValue.get(value)).filter(row=>row!==void 0),limited=this.multiple?rows:rows.slice(0,1);this.assignValue(limited.map(row=>row.value));for(const row of limited)this._selectedRowCache.set(row.value,row)}applyPendingSelectedRows(acceptEmptySource=!1){if(this.pendingSelectedRowValues===void 0||!acceptEmptySource&&this.selectionSourceRows.length===0)return!1;const values=this.pendingSelectedRowValues;return this.pendingSelectedRowValues=void 0,this.applySelectedRowValues(values),!0}get effectiveRows(){return this.source?this.asyncRows:this.filtered.map(option=>this.rowForOption(option))}get unknownRows(){if(!this.withUnknownOption)return[];const locale=this.effectiveLocale,query2=this.query.trim().toLocaleLowerCase(locale);return this.committed.filter(value=>this.isUnknownValue(value)).map(value=>({value,label:this.labelFor(value),badge:this.localize("notInCatalog"),unknownValue:value})).filter(row=>!query2||row.label.toLocaleLowerCase(locale).includes(query2)||row.value.toLocaleLowerCase(locale).includes(query2))}get createRow(){if(!this.allowCreate)return;const inputValue=this.query.trim();if(!inputValue)return;const locale=this.effectiveLocale,folded=inputValue.toLocaleLowerCase(locale);if(!(this.source?this.asyncRows:this.options.map(option=>({value:option.value,label:option.label}))).some(row=>row.value.toLocaleLowerCase(locale)===folded||row.label.toLocaleLowerCase(locale)===folded))return{value:inputValue,label:this.localize("comboboxCreate",void 0,{value:inputValue}),createInput:inputValue}}get renderedRows(){const all=this.effectiveRows,create=this.createRow,sourceOverflow=this.source?Math.max(0,this._sourceTotal-all.length):0,unknown=this.unknownRows;if(all.length<=this.maxRender)return{rows:[...all,...unknown,...create?[create]:[]],overflow:sourceOverflow};const originalIndex=new Map(all.map((r,i)=>[r,i])),capped=all.slice(0,this.maxRender),cappedValues=new Set(capped.map(r=>r.value));let appendedOutOfCap=!1;for(const v of this.committed)if(!cappedValues.has(v)){const selectedRow=all.find(r=>r.value===v);selectedRow&&(capped.push(selectedRow),appendedOutOfCap=!0)}return appendedOutOfCap&&capped.sort((a,b)=>originalIndex.get(a)-originalIndex.get(b)),capped.push(...unknown),create&&capped.push(create),{rows:capped,overflow:all.length-capped.length+unknown.length+(create?1:0)+sourceOverflow}}normalizeActiveIndex(){if(this.activeIndex<0)return;const navigableCount=this.renderedRows.rows.filter(row=>!row.disabled).length,next=navigableCount>0?Math.min(this.activeIndex,navigableCount-1):-1;next!==this.activeIndex&&(this.activeIndex=next)}get filtered(){const locale=this.effectiveLocale,q=this.query.trim().toLocaleLowerCase(locale),selectedLabel=this.multiple?"":this.labelFor(this._selected[0]??"")??"",effective=q&&q===selectedLabel.toLocaleLowerCase(locale)?"":q;if(!effective)return this.options;const fn=this.filter??((o,query2)=>o.label.toLocaleLowerCase(locale).includes(query2)||o.searchText.toLocaleLowerCase(locale).includes(query2));return this.options.filter(o=>fn(o,effective))}get displayValue(){return this.multiple||this.open||this.explicitInputValue?this.query:this._selected[0]?this.labelFor(this._selected[0]):""}announceOpenTransition(changed){this.openVetoed=!1;const closeAfterPositioningFailure=!this.open&&this.closeAfterPositioningFailure;if(this.closeAfterPositioningFailure=!1,!(!changed.has("open")||this._isFirstUpdate||!this.open&&this.interactionBarred)){if(!this.isConnected||closeAfterPositioningFailure){emitPopupEvent(this,"lr-hide",!1);return}this.openVetoed=this.popupController.announce(this.open,()=>{this.open=!this.open})}}show(){if(this.open||this.interactionBarred)return Promise.resolve();const settled=this.popupController.wait(!0);return this.open=!0,settled}hide(){if(!this.open)return Promise.resolve();const settled=this.popupController.wait(!1);return this.closeCleanupPending=!0,this.open=!1,settled}finalizeCloseState(){if(this.closeCleanupPending&&(this.closeCleanupPending=!1,this.activeIndex=-1,!this.multiple)){const queryChanged=this.query!=="";this.query="",this.explicitInputValue=!1,queryChanged&&this.source&&(this.asyncRows=[],this.sourceFailed=!1,this._sourceTotal=0,this._sourceTruncated=!1)}}activateListboxOverlay(){this.invalidateListboxPositioning(),this.overlayHandle?.deactivate({restoreFocus:!1}),this.restoreFocusOnClose=!0,this.overlayHandle=activateNonmodalOverlay({host:this,panel:()=>this.renderRoot.querySelector('[part="listbox"]'),onEscape:()=>{this.hide()},onBackdrop:()=>{this.restoreFocusOnClose=!1,this.hide()},restoreFocusTo:this.inputEl??null}),this.popupController.bindPointer(),this.beginListboxPositioning()}beginListboxPositioning(){const anchor=this.renderRoot.querySelector('[part="combobox"]'),listbox=this.renderRoot.querySelector('[part="listbox"]');if(anchor&&listbox){const generation=this.positioningGeneration;this.positioningReady=new Promise(resolve=>{this.resolvePositioningReady=resolve}),this.startListboxPositioning(generation,anchor,listbox)}}invalidateListboxPositioning(){this.positioningGeneration++,this.cleanup?.(),this.cleanup=void 0,this.resolvePositioningReady?.(!1),this.resolvePositioningReady=void 0}resolveCurrentPositioning(positioned){const resolve=this.resolvePositioningReady;this.resolvePositioningReady=void 0,resolve?.(positioned)}async startListboxPositioning(generation,anchor,listbox){try{const runtime=await loadAnchoredOverlayRuntime(),{place}=runtime;if(generation!==this.positioningGeneration||!this.open||!this.isConnected||this.renderRoot.querySelector('[part="combobox"]')!==anchor||this.renderRoot.querySelector('[part="listbox"]')!==listbox)return;this.placedTopLayer=syncTopLayerRelease(listbox,this.placedTopLayer,this.topLayer,runtime);const cleanup=place(anchor,listbox,{placement:`${this.placement}-start`,...topLayerPlacement(this.topLayer,resolveEffectivePositioningStrategy(this,this._positioningStrategy,"fixed")),sync:this.sync,onPlaced:()=>{generation===this.positioningGeneration&&(this.listboxPositioned=!0,this.updateComplete.then(()=>{generation!==this.positioningGeneration||!this.open||this.resolveCurrentPositioning(!0)}))}});generation!==this.positioningGeneration?cleanup():this.cleanup=cleanup}catch{if(generation!==this.positioningGeneration||!this.open)return;this.resolveCurrentPositioning(!1),this.closeAfterPositioningFailure=!0,this.hide()}}teardownListboxOverlay(restoreFocus=this.restoreFocusOnClose){this.invalidateListboxPositioning(),this.restoringOverlayFocus=restoreFocus;try{this.overlayHandle?.deactivate({restoreFocus})}finally{this.restoringOverlayFocus=!1}this.overlayHandle=void 0,this.popupController.unbindPointer(),this.restoreFocusOnClose=!0}reconnectOpenPopup(){!this.isConnected||!this.open||(this.activateListboxOverlay(),this.source&&this.asyncRows.length===0&&this.runSource(this.query))}syncVisibleOptionsCap(){const listbox=this.renderRoot?.querySelector('[part="listbox"]');if(!listbox)return;const clear=()=>{listbox.style.removeProperty("max-block-size")},requested=typeof this.visibleOptions=="number"?finiteCount(this.visibleOptions,0):0;if(requested<=0)return clear();const rows=listbox.querySelectorAll('[part="option"]');if(rows.length<=requested)return clear();const boundary=rows[requested];if(!boundary)return clear();const cap=boundary.getBoundingClientRect().top-listbox.getBoundingClientRect().top;if(!Number.isFinite(cap)||cap<=0)return clear();listbox.style.setProperty("max-block-size",`min(${Math.ceil(cap)}px, var(--lr-positioner-available-block-size, var(--lr-size-18rem)))`)}updated(changed){if(super.updated(changed),this.syncExternalDescription(),this.syncVisibleOptionsCap(),changed.has("open")&&!this.openVetoed?this.open&&this.isConnected?(this.activateListboxOverlay(),this._isFirstUpdate||this.settleTransition("lr-after-show"),this.refreshQueued?(this.refreshQueued=!1,this.runSource(this.query)):this.source&&this.asyncRows.length===0&&this.runSource(this.query)):this.open?this.teardownListboxOverlay(!1):(this.teardownListboxOverlay(),this.interactionBarred?this.popupController.cancel():this._isFirstUpdate||this.settleTransition("lr-after-hide")):changed.has("open")&&this.openVetoed&&(this.restoreFocusOnClose=!0),changed.has("topLayer")&&!changed.has("open")&&this.open&&this.isConnected&&(this.invalidateListboxPositioning(),this.beginListboxPositioning()),changed.has("name")&&this.syncFormValue(),changed.has("validators")&&(this.updateValidity(),this.syncValidatorAttributeObserver()),(changed.has("touched")||changed.has("required")||changed.has("value")||changed.has("validators")||changed.has("validityRevision"))&&this.toggleAttribute("data-invalid",this.touched&&!this.internals.validity.valid),changed.has("activeIndex")||changed.has("listboxPositioned")){const listbox=this.renderRoot.querySelector('[part="listbox"]'),row=listbox?.querySelector('[part="option"][data-active]');listbox&&row&&revealRow(listbox,row)}}settleTransition(event){return this.popupController.settle(event,{waitForPosition:async stale=>{for(;this.open&&!this.listboxPositioned;){const readiness=this.positioningReady,positioned=await readiness;if(stale())return!1;if(positioned)break;if(readiness===this.positioningReady)return!1}return!0},conceal:()=>{this.listboxHidden=!0}})}emitValueEvents(){const self=this,data=this.resolveSelectedRowSlots().map(row=>row?.data),previousValue=this.multiple?[...this.previousSelection]:this.previousSelection[0]??"",detail={value:self.value,previousValue,data};emitValueEvents(self,"input",detail,detail2=>self.emit("lr-input",detail2)),emitValueEvents(self,"change",detail,detail2=>self.emit("lr-change",detail2))}assignValue(next){this.value=next}createOption(inputValue){if(this.liveDisabled||this.readonly||this.emit("lr-create",{inputValue},{cancelable:!0}).defaultPrevented)return;const option=this.ownerDocument.createElement(tag("option"));option.setAttribute("value",inputValue),option.textContent=inputValue,this.append(option),this.pickRow({value:inputValue,label:inputValue})}commitCustomValue(inputValue){if(this.liveDisabled||this.readonly||this.multiple||!inputValue)return;const selectionChanged=this._selected[0]!==inputValue;this.touched=!0,this._selectedLabelCache.set(inputValue,inputValue),this.assignValue(inputValue),this.query="",this.explicitInputValue=!1,this.hide(),selectionChanged&&this.emitValueEvents()}pickRow(row){const sourceOption=this.sourceOptionsByRow.get(row);if(this.liveDisabled||this.readonly||row.disabled||sourceOption&&(sourceOption.disabled||sourceOption.closest("[inert]")))return;if(row.createInput!==void 0){this.createOption(row.createInput);return}this.touched=!0;const synthetic=row.unknownValue!==void 0,selectionChanged=this.multiple||this._selected[0]!==row.value;if(this.multiple){const set=new Set(this._selected);set.has(row.value)?(set.delete(row.value),this._selectedRowCache.delete(row.value)):(set.add(row.value),synthetic||(this._selectedLabelCache.set(row.value,row.label),this._selectedRowCache.set(row.value,row))),this.assignValue([...set]),this.query="",this.explicitInputValue=!1}else synthetic||(this._selectedLabelCache.set(row.value,row.label),this._selectedRowCache.clear(),this._selectedRowCache.set(row.value,row)),this.setValue(row.value,!0,sourceOption),this.query="",this.explicitInputValue=!1,this.hide();this.source&&this.runSource(this.query),selectionChanged&&this.emitValueEvents(),this.emit("lr-activate",{value:row.value})}removeValueAt(index){if(this.liveDisabled||this.readonly||index<0||index>=this._selected.length)return;const next=this._selected.filter((_,i)=>i!==index);this.touched=!0,this.assignValue(next),this.emitValueEvents()}clear(){if(this.liveDisabled||this.readonly)return;const hadSelection=this._selected.length>0,queryChanged=this.query!=="";!hadSelection&&!queryChanged||(hadSelection&&(this.touched=!0,this.assignValue([])),this.query="",this.explicitInputValue=!1,this.source&&this.runSource(this.query),hadSelection&&(this.emitValueEvents(),this.emit("lr-clear")),queryChanged&&this.emit("lr-filter",{value:this.query}))}refresh(){if(this.source){if(!this.open){this.refreshQueued=!0;return}this.refreshQueued=!1,this.runSource(this.query,{immediate:!0})}}runSource(query2,options){const source=this.source;if(!source)return;this.clearSourceTimer(),this.sourceAbort?.abort(),this.sourceAbort=void 0;const token=++this.sourceToken,ownerWindow=this.ownerDocument.defaultView;if(!this.isConnected||!ownerWindow)return;const request={query:query2,token,owner:ownerWindow,source};if(options?.immediate){this.runSourceRequest(request);return}this.sourceDebounce.delayMs=this._sourceDelay,this.sourceDebounce.push(request)}runSourceRequest({query:query2,token,owner:ownerWindow,source}){if(token!==this.sourceToken||!this.isConnected||this.ownerDocument.defaultView!==ownerWindow)return;const controller=new ownerWindow.AbortController;this.sourceAbort=controller,this.sourceLoading=!0,this.sourceFailed=!1,Promise.resolve().then(()=>source(query2,{signal:controller.signal,limit:MAX_SOURCE_ROWS})).then(result=>{if(token!==this.sourceToken||!this.isConnected||this.ownerDocument.defaultView!==ownerWindow)return;const normalized=normalizeSourceResult(result);this._sourceTotal=normalized.total,this._sourceTruncated=normalized.truncated,this.asyncRows=normalized.rows,this.sourceFailed=!1,this.sourceEverSettled=!0,this.normalizeActiveIndex(),this.applyPendingSelectedRows(!0);const selected=new Set(this._selected);for(const row of normalized.rows)selected.has(row.value)&&this._selectedRowCache.set(row.value,row)}).catch(err=>{token!==this.sourceToken||!this.isConnected||this.ownerDocument.defaultView!==ownerWindow||typeof err=="object"&&err!==null&&"name"in err&&err.name==="AbortError"||(this.asyncRows=[],this._sourceTotal=0,this._sourceTruncated=!1,this.activeIndex=-1,this.sourceFailed=!0,this.sourceEverSettled=!0,this.sourceErrorAnnouncements.announceAssertive(this.localize("comboboxLoadError")),this.emit("lr-source-error",{error:err,query:query2}),console.warn("<lr-combobox> source() rejected:",err))}).finally(()=>{token===this.sourceToken&&(this.sourceLoading=!1)})}clearSourceTimer(){this.sourceDebounce.cancel()}renderRows(rows,activeId){const out=[];let currentGroup,currentGroupRows=[],groupIndex=0;const selectedSet=new Set(this.committed),flushGroup=()=>{if(currentGroupRows.length){if(currentGroup){const labelId=`${this.listId}-group-${groupIndex++}`;out.push(html`<div role="group" aria-labelledby=${labelId}>
2
2
  <div id=${labelId} part="group-label" class="group-label">${currentGroup}</div>
3
3
  ${currentGroupRows}
4
4
  </div>`)}else out.push(...currentGroupRows);currentGroupRows=[]}};return rows.forEach((o,i)=>{o.group!==currentGroup&&(flushGroup(),currentGroup=o.group);const id=`${this.listId}-opt-${i}`,selected=this.multiple||this.source?selectedSet.has(o.value):this.singleSelectedOption!==void 0&&this.sourceOptionsByRow.get(o)===this.singleSelectedOption;selected&&!this.multiple&&selectedSet.delete(o.value),currentGroupRows.push(html`<div
@@ -1 +1 @@
1
- import{__decorate}from"tslib";import{html,nothing}from"lit";import{property}from"lit/decorators.js";import{trueDefaultBooleanConverter}from"../../../internal/converters.js";import{snapshotSelectionCatalog}from"../../../internal/selection-catalog.js";import{LyraCatalogPickerBase}from"../catalog-picker-base.js";import{COUNTRY_CODES,resolveCountryNames}from"../../../countries.js";import{styles}from"./country-picker.styles.js";import{LyraElement}from"../../../internal/lyra-element.js";import{LYRA_DEFAULT_countryPickerLabel,LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_notInCatalog,LYRA_DEFAULT_select}from"../../../internal/default-strings.generated.js";const defaultEntries=Object.freeze(COUNTRY_CODES.map(code=>Object.freeze({code})));function normalizeCountry(value){const text=typeof value=="string"?value.trim():"";return/^[A-Za-z]{2}$/.test(text)?text.toUpperCase():text}class LyraCountryPicker extends LyraCatalogPickerBase{constructor(){super(...arguments),this.flags=!0}static{this.defaultStrings={...super.defaultStrings,countryPickerLabel:LYRA_DEFAULT_countryPickerLabel,fieldRequired:LYRA_DEFAULT_fieldRequired,notInCatalog:LYRA_DEFAULT_notInCatalog,select:LYRA_DEFAULT_select}}static{this.styles=[LyraElement.styles,styles]}get countries(){return this._countries}set countries(value){const previous=this._countries;this._countries=snapshotSelectionCatalog(value,normalizeCountry,code=>/^[A-Z]{2}$/.test(code)),this.updateValidity(),this.requestUpdate("countries",previous)}get entries(){return this._countries??defaultEntries}get pickerLabel(){return this.localize("countryPickerLabel")}normalizeValue(value){return normalizeCountry(value)}resolveRows(){return resolveCountryNames(this.entries,this.effectiveLocale)}renderAdornment(row){if(!this.flags||!/^[A-Z]{2}$/.test(row.code))return nothing;const emoji=String.fromCodePoint(...[...row.code].map(char=>char.charCodeAt(0)+127397));return html`<span part="flag" aria-hidden="true">${emoji}</span>`}}__decorate([property({converter:trueDefaultBooleanConverter})],LyraCountryPicker.prototype,"flags",void 0),__decorate([property({attribute:!1})],LyraCountryPicker.prototype,"countries",null);export{LyraCountryPicker};
1
+ import{__decorate}from"tslib";import{html,nothing}from"lit";import{property}from"lit/decorators.js";import{trueDefaultBooleanConverter}from"../../../internal/converters.js";import{snapshotSelectionCatalog}from"../../../internal/selection-catalog.js";import{LyraCatalogPickerBase}from"../catalog-picker-base.js";import{COUNTRY_CODES,resolveCountryNames}from"../../../countries.js";import{styles}from"./country-picker.styles.js";import{LyraElement}from"../../../internal/lyra-element.js";import{LYRA_DEFAULT_countryPickerLabel}from"../../../internal/default-strings/forms.generated.js";import{LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_notInCatalog,LYRA_DEFAULT_select}from"../../../internal/default-strings/shared.generated.js";const defaultEntries=Object.freeze(COUNTRY_CODES.map(code=>Object.freeze({code})));function normalizeCountry(value){const text=typeof value=="string"?value.trim():"";return/^[A-Za-z]{2}$/.test(text)?text.toUpperCase():text}class LyraCountryPicker extends LyraCatalogPickerBase{constructor(){super(...arguments),this.flags=!0}static{this.defaultStrings={...super.defaultStrings,countryPickerLabel:LYRA_DEFAULT_countryPickerLabel,fieldRequired:LYRA_DEFAULT_fieldRequired,notInCatalog:LYRA_DEFAULT_notInCatalog,select:LYRA_DEFAULT_select}}static{this.styles=[LyraElement.styles,styles]}get countries(){return this._countries}set countries(value){const previous=this._countries;this._countries=snapshotSelectionCatalog(value,normalizeCountry,code=>/^[A-Z]{2}$/.test(code)),this.updateValidity(),this.requestUpdate("countries",previous)}get entries(){return this._countries??defaultEntries}get pickerLabel(){return this.localize("countryPickerLabel")}normalizeValue(value){return normalizeCountry(value)}resolveRows(){return resolveCountryNames(this.entries,this.effectiveLocale)}renderAdornment(row){if(!this.flags||!/^[A-Z]{2}$/.test(row.code))return nothing;const emoji=String.fromCodePoint(...[...row.code].map(char=>char.charCodeAt(0)+127397));return html`<span part="flag" aria-hidden="true">${emoji}</span>`}}__decorate([property({converter:trueDefaultBooleanConverter})],LyraCountryPicker.prototype,"flags",void 0),__decorate([property({attribute:!1})],LyraCountryPicker.prototype,"countries",null);export{LyraCountryPicker};
@@ -1 +1 @@
1
- import{__decorate}from"tslib";import{property}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{snapshotSelectionCatalog}from"../../../internal/selection-catalog.js";import{LyraCatalogPickerBase}from"../catalog-picker-base.js";import{styles}from"./currency-picker.styles.js";import{DEFAULT_CURRENCY_ENTRIES,normalizeCurrencyValue}from"./currency-catalog.js";import{resolveCurrencyPresentation}from"./currency-presentation.js";import{LYRA_DEFAULT_currencyPickerLabel,LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_notInCatalog,LYRA_DEFAULT_select}from"../../../internal/default-strings.generated.js";class LyraCurrencyPicker extends LyraCatalogPickerBase{static{this.defaultStrings={...super.defaultStrings,currencyPickerLabel:LYRA_DEFAULT_currencyPickerLabel,fieldRequired:LYRA_DEFAULT_fieldRequired,notInCatalog:LYRA_DEFAULT_notInCatalog,select:LYRA_DEFAULT_select}}static{this.styles=[LyraElement.styles,styles]}get currencies(){return this._currencies}set currencies(next){const previous=this._currencies;this._currencies=snapshotSelectionCatalog(next,normalizeCurrencyValue,code=>/^[A-Z]{3}$/.test(code)),this.updateValidity(),this.requestUpdate("currencies",previous)}get entries(){return this._currencies??DEFAULT_CURRENCY_ENTRIES}get pickerLabel(){return this.localize("currencyPickerLabel")}normalizeValue(value){return normalizeCurrencyValue(value)}resolveRows(){return resolveCurrencyPresentation(this.entries,this.effectiveLocale)}optionDisplay(row){return{label:row.code,sub:[row.label,row.symbol].filter(text=>!!text).join(" · ")}}}__decorate([property({attribute:!1})],LyraCurrencyPicker.prototype,"currencies",null);export{LyraCurrencyPicker};
1
+ import{__decorate}from"tslib";import{property}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{snapshotSelectionCatalog}from"../../../internal/selection-catalog.js";import{LyraCatalogPickerBase}from"../catalog-picker-base.js";import{styles}from"./currency-picker.styles.js";import{DEFAULT_CURRENCY_ENTRIES,normalizeCurrencyValue}from"./currency-catalog.js";import{resolveCurrencyPresentation}from"./currency-presentation.js";import{LYRA_DEFAULT_currencyPickerLabel}from"../../../internal/default-strings/forms.generated.js";import{LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_notInCatalog,LYRA_DEFAULT_select}from"../../../internal/default-strings/shared.generated.js";class LyraCurrencyPicker extends LyraCatalogPickerBase{static{this.defaultStrings={...super.defaultStrings,currencyPickerLabel:LYRA_DEFAULT_currencyPickerLabel,fieldRequired:LYRA_DEFAULT_fieldRequired,notInCatalog:LYRA_DEFAULT_notInCatalog,select:LYRA_DEFAULT_select}}static{this.styles=[LyraElement.styles,styles]}get currencies(){return this._currencies}set currencies(next){const previous=this._currencies;this._currencies=snapshotSelectionCatalog(next,normalizeCurrencyValue,code=>/^[A-Z]{3}$/.test(code)),this.updateValidity(),this.requestUpdate("currencies",previous)}get entries(){return this._currencies??DEFAULT_CURRENCY_ENTRIES}get pickerLabel(){return this.localize("currencyPickerLabel")}normalizeValue(value){return normalizeCurrencyValue(value)}resolveRows(){return resolveCurrencyPresentation(this.entries,this.effectiveLocale)}optionDisplay(row){return{label:row.code,sub:[row.label,row.symbol].filter(text=>!!text).join(" · ")}}}__decorate([property({attribute:!1})],LyraCurrencyPicker.prototype,"currencies",null);export{LyraCurrencyPicker};