@aceshooting/lyra-ui 29.0.2 → 29.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -0
- package/README.md +19 -26
- package/design-tokens.json +1 -1
- package/dist/cli/migrate-wa.mjs +2 -0
- package/dist/components/agent-tools/activity-feed/activity-feed.class.d.ts +5 -3
- package/dist/components/agent-tools/activity-feed/activity-feed.class.js +4 -3
- package/dist/components/agent-tools/activity-feed/activity-feed.styles.js +1 -1
- package/dist/components/agent-tools/agent-trace/agent-trace.class.d.ts +21 -5
- package/dist/components/agent-tools/agent-trace/agent-trace.class.js +14 -11
- package/dist/components/agent-tools/agent-trace/agent-trace.styles.js +1 -1
- package/dist/components/agent-tools/confirm-bar/confirm-bar.class.js +2 -2
- package/dist/components/agent-tools/eval-dataset/eval-dataset.class.d.ts +34 -7
- package/dist/components/agent-tools/eval-dataset/eval-dataset.class.js +25 -11
- package/dist/components/agent-tools/eval-result/eval-result-source.js +1 -0
- package/dist/components/agent-tools/eval-result/eval-result.class.d.ts +31 -11
- package/dist/components/agent-tools/eval-result/eval-result.class.js +29 -15
- package/dist/components/agent-tools/eval-result/eval-result.styles.js +1 -1
- package/dist/components/agent-tools/eval-result/eval-run-result.d.ts +10 -0
- package/dist/components/agent-tools/span-waterfall/span-waterfall.class.d.ts +26 -5
- package/dist/components/agent-tools/span-waterfall/span-waterfall.class.js +16 -6
- package/dist/components/agent-tools/span-waterfall/span-waterfall.d.ts +1 -1
- package/dist/components/agent-tools/span-waterfall/span-waterfall.js +1 -1
- package/dist/components/agent-tools/span-waterfall/span-waterfall.styles.js +1 -1
- package/dist/components/agent-tools/task-list/task-list.class.d.ts +29 -6
- package/dist/components/agent-tools/task-list/task-list.class.js +13 -7
- package/dist/components/agent-tools/task-list/task-list.d.ts +1 -1
- package/dist/components/agent-tools/task-list/task-list.js +1 -1
- package/dist/components/agent-tools/task-list/task-list.styles.js +1 -1
- package/dist/components/agent-tools/terminal/terminal.class.d.ts +9 -5
- package/dist/components/agent-tools/terminal/terminal.class.js +8 -8
- package/dist/components/agent-tools/test-results/test-results.class.d.ts +16 -4
- package/dist/components/agent-tools/test-results/test-results.class.js +15 -6
- package/dist/components/agent-tools/test-results/test-results.d.ts +1 -0
- package/dist/components/agent-tools/test-results/test-results.js +1 -1
- package/dist/components/agent-tools/test-results/test-results.styles.js +1 -1
- package/dist/components/agent-tools/tool-timeline/tool-timeline.class.d.ts +7 -4
- package/dist/components/agent-tools/tool-timeline/tool-timeline.class.js +2 -1
- package/dist/components/agent-tools/trace-tree/span-projection.js +1 -0
- package/dist/components/agent-tools/trace-tree/span-shared.d.ts +29 -0
- package/dist/components/agent-tools/trace-tree/span-shared.js +1 -0
- package/dist/components/agent-tools/trace-tree/span.d.ts +5 -35
- package/dist/components/agent-tools/trace-tree/span.js +1 -1
- package/dist/components/agent-tools/trace-tree/trace-tree.class.d.ts +27 -5
- package/dist/components/agent-tools/trace-tree/trace-tree.class.js +19 -9
- package/dist/components/agent-tools/trace-tree/trace-tree.d.ts +1 -1
- package/dist/components/agent-tools/trace-tree/trace-tree.js +1 -1
- package/dist/components/agent-tools/trace-tree/trace-tree.styles.js +1 -1
- package/dist/components/charts/chart/bar-chart.class.d.ts +5 -1
- package/dist/components/charts/chart/box-plot.class.d.ts +2 -2
- package/dist/components/charts/chart/box-plot.class.js +3 -3
- package/dist/components/charts/chart/bubble-chart.class.d.ts +5 -1
- package/dist/components/charts/chart/chart-prepared-data.d.ts +9 -0
- package/dist/components/charts/chart/chart-prepared-data.js +1 -0
- package/dist/components/charts/chart/chart-spatial-data.js +2 -0
- package/dist/components/charts/chart/chart-sync.js +1 -1
- package/dist/components/charts/chart/chart-table-sampling.js +1 -1
- package/dist/components/charts/chart/chart.class.d.ts +56 -6
- package/dist/components/charts/chart/chart.class.js +18 -8
- package/dist/components/charts/chart/chart.styles.js +1 -1
- package/dist/components/charts/chart/doughnut-chart.class.d.ts +5 -1
- package/dist/components/charts/chart/histogram-buckets.d.ts +1 -1
- package/dist/components/charts/chart/histogram-buckets.js +1 -1
- package/dist/components/charts/chart/histogram.class.d.ts +19 -4
- package/dist/components/charts/chart/histogram.class.js +1 -1
- package/dist/components/charts/chart/line-chart.class.d.ts +5 -1
- package/dist/components/charts/chart/lite-chart.class.d.ts +51 -11
- package/dist/components/charts/chart/lite-chart.class.js +33 -27
- package/dist/components/charts/chart/lite-chart.styles.js +1 -1
- package/dist/components/charts/chart/pie-chart.class.d.ts +5 -1
- package/dist/components/charts/chart/polar-area-chart.class.d.ts +5 -1
- package/dist/components/charts/chart/radar-chart.class.d.ts +5 -1
- package/dist/components/charts/chart/scatter-chart.class.d.ts +5 -1
- package/dist/components/conversation/agent-workspace/agent-workspace.class.d.ts +6 -3
- package/dist/components/conversation/agent-workspace/agent-workspace.class.js +6 -5
- package/dist/components/conversation/agent-workspace/agent-workspace.styles.js +1 -1
- package/dist/components/conversation/chat-viewport/chat-viewport.class.d.ts +8 -0
- package/dist/components/conversation/chat-viewport/chat-viewport.class.js +1 -1
- package/dist/components/conversation/code-block/code-block-base.class.d.ts +5 -3
- package/dist/components/conversation/code-block/code-block-base.class.js +1 -1
- package/dist/components/conversation/code-block/code-block-core.class.d.ts +4 -1
- package/dist/components/conversation/code-block/code-block-core.class.js +1 -1
- package/dist/components/conversation/code-block/code-block-shared.d.ts +6 -4
- package/dist/components/conversation/code-block/code-block-shared.js +3 -2
- package/dist/components/conversation/code-block/code-block.class.d.ts +11 -4
- package/dist/components/conversation/code-block/code-block.class.js +1 -1
- package/dist/components/conversation/code-block/code-block.d.ts +1 -1
- package/dist/components/conversation/code-block/code-block.styles.js +1 -1
- package/dist/components/conversation/code-block/shiki-types.d.ts +2 -0
- package/dist/components/conversation/code-block/shiki-types.js +1 -1
- package/dist/components/conversation/markdown/markdown-base.class.d.ts +6 -4
- package/dist/components/conversation/markdown/markdown-base.class.js +1 -1
- package/dist/components/conversation/markdown/markdown-code-header.d.ts +2 -2
- package/dist/components/conversation/markdown/markdown-code-header.js +1 -1
- package/dist/components/conversation/markdown/markdown-core.class.d.ts +8 -3
- package/dist/components/conversation/markdown/markdown-progressive.js +2 -2
- package/dist/components/conversation/markdown/markdown-shared.d.ts +5 -10
- package/dist/components/conversation/markdown/markdown-shared.js +5 -5
- package/dist/components/conversation/markdown/markdown-streaming-tail.js +1 -1
- package/dist/components/conversation/markdown/markdown.class.d.ts +17 -10
- package/dist/components/conversation/markdown/markdown.class.js +1 -1
- package/dist/components/conversation/markdown/markdown.styles.js +1 -1
- package/dist/components/conversation/model-select/model-select.class.d.ts +4 -3
- package/dist/components/conversation/model-select/model-select.class.js +3 -2
- package/dist/components/conversation/model-select/model-select.styles.js +1 -1
- package/dist/components/conversation/model-settings-panel/model-settings-panel.class.d.ts +2 -1
- package/dist/components/conversation/model-settings-panel/model-settings-panel.class.js +2 -1
- package/dist/components/conversation/model-settings-panel/model-settings-panel.styles.js +1 -1
- package/dist/components/conversation/prompt-input/prompt-input.class.d.ts +3 -2
- package/dist/components/conversation/prompt-input/prompt-input.class.js +2 -1
- package/dist/components/conversation/prompt-input/prompt-input.styles.js +1 -1
- package/dist/components/conversation/prompt-queue/prompt-queue.class.d.ts +10 -2
- package/dist/components/conversation/prompt-queue/prompt-queue.class.js +15 -6
- package/dist/components/conversation/prompt-queue/prompt-queue.styles.js +1 -1
- package/dist/components/conversation/realtime-session/realtime-session.class.d.ts +3 -1
- package/dist/components/conversation/realtime-session/realtime-session.class.js +2 -1
- package/dist/components/conversation/realtime-session/realtime-session.styles.js +1 -1
- package/dist/components/conversation/streaming-text/markdown-detection.d.ts +2 -0
- package/dist/components/conversation/streaming-text/markdown-detection.js +4 -1
- package/dist/components/conversation/streaming-text/streaming-text-base.class.d.ts +6 -2
- package/dist/components/conversation/streaming-text/streaming-text-base.class.js +3 -3
- package/dist/components/conversation/streaming-text/streaming-text-core.class.js +1 -1
- package/dist/components/conversation/streaming-text/streaming-text.class.js +1 -0
- package/dist/components/conversation/thread-list/thread-list.class.d.ts +34 -4
- package/dist/components/conversation/thread-list/thread-list.class.js +22 -15
- package/dist/components/conversation/thread-list/thread-list.d.ts +1 -1
- package/dist/components/conversation/thread-list/thread-list.js +1 -1
- package/dist/components/conversation/thread-list/thread-list.styles.js +1 -1
- package/dist/components/conversation/transcript-feed/transcript-feed.class.d.ts +6 -2
- package/dist/components/conversation/transcript-feed/transcript-feed.class.js +3 -2
- package/dist/components/conversation/transcript-feed/transcript-feed.styles.js +1 -1
- package/dist/components/conversation/voice-picker/voice-picker.class.d.ts +3 -2
- package/dist/components/conversation/voice-picker/voice-picker.class.js +3 -2
- package/dist/components/conversation/voice-picker/voice-picker.styles.js +1 -1
- package/dist/components/data/calendar/calendar.class.d.ts +5 -2
- package/dist/components/data/calendar/calendar.class.js +1 -1
- package/dist/components/data/data-grid/data-grid-processing.js +2 -2
- package/dist/components/data/data-grid/data-grid.class.d.ts +22 -8
- package/dist/components/data/data-grid/data-grid.class.js +20 -19
- package/dist/components/data/data-grid/data-grid.styles.js +1 -1
- package/dist/components/data/document-library/document-library.class.d.ts +31 -4
- package/dist/components/data/document-library/document-library.class.js +25 -12
- package/dist/components/data/document-library/document-library.styles.js +1 -1
- package/dist/components/data/file-tree/file-tree.class.d.ts +30 -6
- package/dist/components/data/file-tree/file-tree.class.js +4 -3
- package/dist/components/data/file-tree/file-tree.d.ts +1 -0
- package/dist/components/data/file-tree/file-tree.js +1 -1
- package/dist/components/data/flow-canvas/flow-canvas.class.d.ts +31 -6
- package/dist/components/data/flow-canvas/flow-canvas.class.js +40 -19
- package/dist/components/data/flow-canvas/flow-canvas.styles.js +1 -1
- package/dist/components/data/flow-canvas/flow-model.js +1 -1
- package/dist/components/data/flow-canvas/flow-source.js +1 -0
- package/dist/components/data/flow-canvas/flow-types.d.ts +4 -2
- package/dist/components/data/flow-canvas/flow-viewport-index.js +1 -0
- package/dist/components/data/flow-minimap/flow-minimap.class.d.ts +9 -3
- package/dist/components/data/flow-minimap/flow-minimap.class.js +11 -2
- package/dist/components/data/flow-minimap/flow-minimap.styles.js +1 -1
- package/dist/components/data/funnel/funnel.class.d.ts +7 -3
- package/dist/components/data/funnel/funnel.class.js +2 -2
- package/dist/components/data/heatmap/calendar-grid.d.ts +1 -1
- package/dist/components/data/heatmap/calendar-grid.js +1 -1
- package/dist/components/data/heatmap/heatmap-grid-navigation.js +1 -1
- package/dist/components/data/heatmap/heatmap-limits.d.ts +1 -1
- package/dist/components/data/heatmap/heatmap-matrix-source-controller.js +1 -0
- package/dist/components/data/heatmap/heatmap-matrix-source.d.ts +5 -0
- package/dist/components/data/heatmap/heatmap-matrix-source.js +1 -0
- package/dist/components/data/heatmap/heatmap-scale.d.ts +0 -16
- package/dist/components/data/heatmap/heatmap-scale.js +1 -1
- package/dist/components/data/heatmap/heatmap.class.d.ts +40 -11
- package/dist/components/data/heatmap/heatmap.class.js +26 -6
- package/dist/components/data/heatmap/heatmap.styles.js +1 -1
- package/dist/components/data/pagination/pagination.class.js +1 -1
- package/dist/components/data/sequence-strip/sequence-strip-item.d.ts +17 -0
- package/dist/components/data/sequence-strip/sequence-strip-source-controller.js +1 -0
- package/dist/components/data/sequence-strip/sequence-strip-source.d.ts +5 -0
- package/dist/components/data/sequence-strip/sequence-strip-source.js +1 -0
- package/dist/components/data/sequence-strip/sequence-strip.class.d.ts +24 -19
- package/dist/components/data/sequence-strip/sequence-strip.class.js +23 -4
- package/dist/components/data/sequence-strip/sequence-strip.styles.js +1 -1
- package/dist/components/data/sparkline/sparkline.class.d.ts +17 -4
- package/dist/components/data/sparkline/sparkline.class.js +3 -3
- package/dist/components/data/sparkline/sparkline.styles.js +1 -1
- package/dist/components/data/table/table.class.d.ts +14 -10
- package/dist/components/data/table/table.class.js +17 -16
- package/dist/components/data/timeline/timeline.class.d.ts +5 -2
- package/dist/components/data/timeline/timeline.class.js +1 -1
- package/dist/components/data/tree/tree-item.class.js +1 -1
- package/dist/components/data/tree/tree-owner-controller.js +1 -1
- package/dist/components/data/tree/tree.class.d.ts +28 -6
- package/dist/components/data/tree/tree.class.js +3 -3
- package/dist/components/data/tree/tree.d.ts +1 -0
- package/dist/components/data/tree/tree.js +1 -1
- package/dist/components/data/word-cloud/word-cloud.class.d.ts +17 -7
- package/dist/components/data/word-cloud/word-cloud.class.js +6 -4
- package/dist/components/data/word-cloud/word-cloud.styles.js +1 -1
- package/dist/components/forms/catalog-picker-base.d.ts +1 -1
- package/dist/components/forms/catalog-picker-base.js +6 -6
- package/dist/components/forms/catalog-picker-base.styles.js +1 -1
- package/dist/components/forms/combobox/combobox.class.d.ts +7 -3
- package/dist/components/forms/combobox/combobox.class.js +1 -1
- package/dist/components/forms/combobox/option.class.d.ts +4 -2
- package/dist/components/forms/combobox/option.class.js +2 -2
- package/dist/components/forms/country-picker/country-picker.class.d.ts +3 -1
- package/dist/components/forms/country-picker/country-picker.class.js +1 -1
- package/dist/components/forms/currency-picker/currency-picker.class.d.ts +2 -0
- package/dist/components/forms/currency-picker/currency-picker.class.js +1 -1
- package/dist/components/forms/currency-picker/currency-presentation.js +1 -1
- package/dist/components/forms/emoji-picker/emoji-picker.class.d.ts +6 -2
- package/dist/components/forms/emoji-picker/emoji-picker.class.js +3 -2
- package/dist/components/forms/emoji-picker/emoji-picker.styles.js +1 -1
- package/dist/components/forms/locale-picker/locale-picker.class.d.ts +8 -2
- package/dist/components/forms/locale-picker/locale-picker.class.js +5 -4
- package/dist/components/forms/locale-picker/locale-picker.styles.js +1 -1
- package/dist/components/forms/select/select.class.d.ts +11 -3
- package/dist/components/forms/select/select.class.js +4 -4
- package/dist/components/forms/time-zone-picker/time-zone-picker.class.d.ts +2 -0
- package/dist/components/forms/time-zone-picker/time-zone-picker.class.js +1 -1
- package/dist/components/forms/token-input/token-input.class.d.ts +6 -1
- package/dist/components/forms/token-input/token-input.class.js +15 -13
- package/dist/components/forms/unit-picker/unit-picker.class.d.ts +2 -0
- package/dist/components/forms/unit-picker/unit-picker.class.js +1 -1
- package/dist/components/layout/app-rail/app-rail.class.d.ts +1 -1
- package/dist/components/layout/app-rail/app-rail.class.js +1 -1
- package/dist/components/layout/command-palette/command-palette.class.d.ts +5 -2
- package/dist/components/layout/command-palette/command-palette.class.js +2 -1
- package/dist/components/layout/command-palette/command-palette.styles.js +1 -1
- package/dist/components/layout/menu/menu-item.class.d.ts +2 -2
- package/dist/components/layout/menu/menu-item.class.js +2 -2
- package/dist/components/layout/menu/menu.class.d.ts +1 -1
- package/dist/components/layout/menu/menu.class.js +1 -1
- package/dist/components/layout/menubar/menubar.class.d.ts +1 -1
- package/dist/components/layout/menubar/menubar.class.js +1 -1
- package/dist/components/layout/reorder-list/reorder-item.class.d.ts +2 -2
- package/dist/components/layout/reorder-list/reorder-item.class.js +2 -2
- package/dist/components/layout/reorder-list/reorder-list.class.d.ts +1 -1
- package/dist/components/layout/reorder-list/reorder-list.class.js +1 -1
- package/dist/components/layout/virtual-list/virtual-list.class.d.ts +13 -9
- package/dist/components/layout/virtual-list/virtual-list.class.js +21 -17
- package/dist/components/media/av-player/av-cue-index.js +1 -0
- package/dist/components/media/av-player/av-cue-source.d.ts +13 -0
- package/dist/components/media/av-player/av-cue-source.js +1 -0
- package/dist/components/media/av-player/av-metadata.d.ts +2 -2
- package/dist/components/media/av-player/av-metadata.js +1 -1
- package/dist/components/media/av-player/av-player-cue-source-controller.js +1 -0
- package/dist/components/media/av-player/av-player.class.d.ts +34 -12
- package/dist/components/media/av-player/av-player.class.js +15 -10
- package/dist/components/media/flag/flag.class.js +1 -1
- package/dist/components/media/flag/language-map.js +1 -1
- package/dist/components/media/lightbox/lightbox-source.js +1 -0
- package/dist/components/media/lightbox/lightbox-types.d.ts +15 -0
- package/dist/components/media/lightbox/lightbox.class.d.ts +22 -21
- package/dist/components/media/lightbox/lightbox.class.js +6 -4
- package/dist/components/media/lightbox/lightbox.styles.js +1 -1
- package/dist/components/media/map/map-geojson-diff.d.ts +6 -6
- package/dist/components/media/map/map-geojson-diff.js +1 -1
- package/dist/components/media/map/map-loader.d.ts +5 -1
- package/dist/components/media/map/map.class.d.ts +24 -6
- package/dist/components/media/map/map.class.js +2 -2
- package/dist/components/media/map/map.styles.js +1 -1
- package/dist/components/media/video-playlist/video-playlist.class.d.ts +2 -1
- package/dist/components/media/video-playlist/video-playlist.class.js +1 -1
- package/dist/components/overlays/chip/chip.class.d.ts +1 -1
- package/dist/components/overlays/chip/chip.class.js +1 -1
- package/dist/components/retrieval/embedding-explorer/embedding-explorer.class.d.ts +30 -8
- package/dist/components/retrieval/embedding-explorer/embedding-explorer.class.js +22 -8
- package/dist/components/retrieval/embedding-explorer/embedding-explorer.styles.js +1 -1
- package/dist/components/retrieval/graph/graph-canvas.js +1 -1
- package/dist/components/retrieval/graph/graph-source-composition.js +1 -0
- package/dist/components/retrieval/graph/graph-source-controller.js +1 -0
- package/dist/components/retrieval/graph/graph-spatial-controller.js +2 -2
- package/dist/components/retrieval/graph/graph-spatial-model.js +1 -0
- package/dist/components/retrieval/graph/graph-spatial.js +1 -1
- package/dist/components/retrieval/graph/graph.class.d.ts +31 -6
- package/dist/components/retrieval/graph/graph.class.js +26 -5
- package/dist/components/retrieval/graph/graph.d.ts +1 -1
- package/dist/components/retrieval/graph/graph.js +1 -1
- package/dist/components/retrieval/graph/graph.styles.js +1 -1
- package/dist/components/retrieval/ingestion-queue/ingestion-queue.class.d.ts +33 -4
- package/dist/components/retrieval/ingestion-queue/ingestion-queue.class.js +27 -17
- package/dist/components/retrieval/ingestion-queue/ingestion-queue.d.ts +1 -1
- package/dist/components/retrieval/ingestion-queue/ingestion-queue.js +1 -1
- package/dist/components/retrieval/ingestion-queue/ingestion-queue.styles.js +1 -1
- package/dist/components/retrieval/knowledge-base/knowledge-base.class.d.ts +27 -4
- package/dist/components/retrieval/knowledge-base/knowledge-base.class.js +29 -14
- package/dist/components/retrieval/knowledge-base/knowledge-base.styles.js +1 -1
- package/dist/components/retrieval/knowledge-base-admin/knowledge-base-admin.class.d.ts +17 -3
- package/dist/components/retrieval/knowledge-base-admin/knowledge-base-admin.class.js +15 -10
- package/dist/components/retrieval/knowledge-base-admin/knowledge-base-admin.styles.js +1 -1
- package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.d.ts +24 -5
- package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.js +17 -10
- package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.d.ts +1 -1
- package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.js +1 -1
- package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.styles.js +1 -1
- package/dist/components/retrieval/mind-map/mind-map-layout.js +1 -1
- package/dist/components/retrieval/mind-map/mind-map-model.js +1 -0
- package/dist/components/retrieval/mind-map/mind-map.class.d.ts +27 -4
- package/dist/components/retrieval/mind-map/mind-map.class.js +11 -7
- package/dist/components/retrieval/mind-map/mind-map.d.ts +1 -0
- package/dist/components/retrieval/mind-map/mind-map.js +1 -1
- package/dist/components/retrieval/mind-map/mind-map.styles.js +1 -1
- package/dist/components/retrieval/neighbor-list/neighbor-list.class.d.ts +24 -2
- package/dist/components/retrieval/neighbor-list/neighbor-list.class.js +17 -3
- package/dist/components/retrieval/neighbor-list/neighbor-list.d.ts +1 -1
- package/dist/components/retrieval/neighbor-list/neighbor-list.js +1 -1
- package/dist/components/retrieval/neighbor-list/neighbor-list.styles.js +1 -1
- package/dist/components/retrieval/rag-eval-dashboard/rag-eval-dashboard.class.d.ts +8 -4
- package/dist/components/retrieval/rag-eval-dashboard/rag-eval-dashboard.class.js +11 -7
- package/dist/components/retrieval/rag-eval-dashboard/rag-eval-dashboard.styles.js +1 -1
- package/dist/components/retrieval/retrieval-compare/retrieval-compare.class.d.ts +12 -6
- package/dist/components/retrieval/retrieval-compare/retrieval-compare.class.js +30 -17
- package/dist/components/retrieval/retrieval-compare/retrieval-compare.styles.js +1 -1
- package/dist/components/retrieval/retrieval-results/retrieval-results-model.js +1 -0
- package/dist/components/retrieval/retrieval-results/retrieval-results.class.d.ts +46 -5
- package/dist/components/retrieval/retrieval-results/retrieval-results.class.js +31 -9
- package/dist/components/retrieval/retrieval-results/retrieval-results.d.ts +1 -1
- package/dist/components/retrieval/retrieval-results/retrieval-results.js +1 -1
- package/dist/components/retrieval/retrieval-results/retrieval-results.styles.js +1 -1
- package/dist/components/utility/diff-view/diff-view.class.d.ts +16 -8
- package/dist/components/utility/diff-view/diff-view.class.js +3 -2
- package/dist/components/utility/diff-view/diff-view.styles.js +1 -1
- package/dist/components/utility/json-viewer/json-viewer.class.d.ts +31 -3
- package/dist/components/utility/json-viewer/json-viewer.class.js +13 -4
- package/dist/components/utility/json-viewer/json-viewer.d.ts +1 -0
- package/dist/components/utility/json-viewer/json-viewer.js +1 -1
- package/dist/components/utility/json-viewer/json-viewer.styles.js +1 -1
- package/dist/components/utility/mention-popover/mention-popover.class.d.ts +6 -4
- package/dist/components/utility/mention-popover/mention-popover.class.js +6 -5
- package/dist/components/viewers/csv-viewer/csv-viewer.class.d.ts +34 -7
- package/dist/components/viewers/csv-viewer/csv-viewer.class.js +9 -7
- package/dist/components/viewers/dataset-viewer/dataset-viewer.class.d.ts +28 -4
- package/dist/components/viewers/dataset-viewer/dataset-viewer.class.js +12 -11
- package/dist/components/viewers/geojson-view/geojson-viewer.class.d.ts +3 -1
- package/dist/components/viewers/geojson-view/geojson-viewer.class.js +17 -16
- package/dist/components/viewers/geojson-view/geojson-viewer.d.ts +1 -1
- package/dist/components/viewers/geojson-view/geojson-viewer.js +1 -1
- package/dist/components/viewers/spreadsheet-viewer/spreadsheet-viewer.class.d.ts +31 -5
- package/dist/components/viewers/spreadsheet-viewer/spreadsheet-viewer.class.js +11 -8
- package/dist/components/viewers/table-viewer-shared.js +19 -3
- package/dist/components/viewers/viewer-search-limits.js +1 -1
- package/dist/components/viewers/xml-viewer/xml-viewer.class.d.ts +35 -3
- package/dist/components/viewers/xml-viewer/xml-viewer.class.js +20 -5
- package/dist/components/viewers/xml-viewer/xml-viewer.d.ts +1 -1
- package/dist/components/viewers/xml-viewer/xml-viewer.js +1 -1
- package/dist/components/viewers/xml-viewer/xml-viewer.styles.js +1 -1
- package/dist/countries.js +1 -1
- package/dist/data-sources.d.ts +34 -0
- package/dist/data-sources.js +1 -0
- package/dist/events.d.ts +51 -7
- package/dist/framework-types.d.ts +1 -1
- package/dist/internal/accessibility-visibility.d.ts +4 -2
- package/dist/internal/accessibility-visibility.js +1 -1
- package/dist/internal/accessible-text-controller.js +1 -1
- package/dist/internal/anchor-target.js +2 -2
- package/dist/internal/catalog-picker.d.ts +1 -7
- package/dist/internal/catalog-picker.js +1 -1
- package/dist/internal/collection-snapshot.js +1 -1
- package/dist/internal/default-strings/agent-tools.generated.js +1 -1
- package/dist/internal/default-strings/charts.generated.js +1 -1
- package/dist/internal/default-strings/conversation.generated.js +1 -1
- package/dist/internal/default-strings/data.generated.js +1 -1
- package/dist/internal/default-strings/forms.generated.js +1 -1
- package/dist/internal/default-strings/layout.generated.js +1 -1
- package/dist/internal/default-strings/media.generated.js +1 -1
- package/dist/internal/default-strings/retrieval.generated.js +1 -1
- package/dist/internal/default-strings/shared.generated.js +1 -1
- package/dist/internal/default-strings/utility.generated.js +1 -1
- package/dist/internal/delimited-data.js +1 -1
- package/dist/internal/fixed-containing-block.js +1 -1
- package/dist/internal/flow-scene-envelope.js +1 -0
- package/dist/internal/graph-scene-controller.js +1 -0
- package/dist/internal/hierarchy-source-controller.js +1 -0
- package/dist/internal/hierarchy-source-view.js +29 -0
- package/dist/internal/hierarchy-source-view.styles.js +1 -0
- package/dist/internal/inherited-attribute-hub.d.ts +6 -0
- package/dist/internal/inherited-attribute-hub.js +1 -1
- package/dist/internal/intl-cache.js +1 -1
- package/dist/internal/keyed-index.js +1 -0
- package/dist/internal/localization-types.d.ts +1 -1
- package/dist/internal/localization.js +2 -2
- package/dist/internal/lyra-element.d.ts +2 -2
- package/dist/internal/lyra-element.js +3 -2
- package/dist/internal/native-modal-context.js +1 -1
- package/dist/internal/option-selection.js +1 -1
- package/dist/internal/package-metadata.js +1 -1
- package/dist/internal/positioner.js +1 -1
- package/dist/internal/resource-loader.d.ts +2 -0
- package/dist/internal/resource-loader.js +1 -1
- package/dist/internal/scoped-definitions.generated.js +1 -1
- package/dist/internal/search-haystack.js +1 -0
- package/dist/internal/selection-catalog.d.ts +5 -0
- package/dist/internal/selection-catalog.js +1 -1
- package/dist/internal/shiki-language-sources.js +1 -0
- package/dist/internal/source-page-controller.js +1 -0
- package/dist/internal/source-page-scope.js +1 -0
- package/dist/internal/source-request-controller.js +1 -0
- package/dist/internal/source-window-controller.js +1 -0
- package/dist/internal/spatial-source-controller.js +1 -0
- package/dist/internal/text-quote.d.ts +2 -6
- package/dist/internal/text-quote.js +1 -1
- package/dist/internal/theme-watcher.js +1 -1
- package/dist/internal/virtual-list-composition.js +1 -0
- package/dist/lyra.d.ts +1 -1
- package/dist/lyra.js +1 -1
- package/dist/testing/interaction-drivers.js +1 -1
- package/dist/testing/lyra-tag-event-map.js +1 -1
- package/dist/units.js +1 -1
- package/dist/utilities/data-preparation.d.ts +56 -0
- package/dist/utilities/data-preparation.js +1 -0
- package/dist/utilities/data-spatial.d.ts +26 -0
- package/dist/utilities/data-spatial.js +1 -0
- package/dist/utilities/index.d.ts +1 -1
- package/dist/utilities/index.js +1 -1
- package/llms/components/lr-activity-feed.md +7 -2
- package/llms/components/lr-agent-trace.md +49 -9
- package/llms/components/lr-agent-workspace.md +15 -8
- package/llms/components/lr-av-player.md +180 -10
- package/llms/components/lr-bar-chart.md +1 -1
- package/llms/components/lr-box-plot.md +8 -0
- package/llms/components/lr-bubble-chart.md +1 -1
- package/llms/components/lr-calendar.md +26 -3
- package/llms/components/lr-chart.md +310 -23
- package/llms/components/lr-chat-viewport.md +6 -0
- package/llms/components/lr-code-block-core.md +12 -7
- package/llms/components/lr-code-block.md +23 -9
- package/llms/components/lr-combobox.md +27 -15
- package/llms/components/lr-command-palette.md +16 -3
- package/llms/components/lr-country-picker.md +23 -6
- package/llms/components/lr-csv-viewer.md +95 -12
- package/llms/components/lr-currency-picker.md +23 -3
- package/llms/components/lr-data-grid.md +24 -6
- package/llms/components/lr-dataset-viewer.md +92 -11
- package/llms/components/lr-dialog.md +1 -1
- package/llms/components/lr-diff-view.md +19 -6
- package/llms/components/lr-document-library.md +60 -5
- package/llms/components/lr-doughnut-chart.md +1 -1
- package/llms/components/lr-embedding-explorer.md +89 -9
- package/llms/components/lr-emoji-picker.md +7 -2
- package/llms/components/lr-eval-dataset.md +56 -7
- package/llms/components/lr-eval-result.md +89 -4
- package/llms/components/lr-export-button.md +1 -1
- package/llms/components/lr-file-tree.md +60 -6
- package/llms/components/lr-flag.md +5 -2
- package/llms/components/lr-flow-canvas.md +152 -14
- package/llms/components/lr-flow-minimap.md +32 -4
- package/llms/components/lr-funnel.md +14 -0
- package/llms/components/lr-geojson-viewer.md +27 -10
- package/llms/components/lr-graph.md +43 -7
- package/llms/components/lr-heatmap.md +161 -5
- package/llms/components/lr-histogram.md +55 -9
- package/llms/components/lr-ingestion-queue.md +54 -3
- package/llms/components/lr-json-viewer.md +87 -7
- package/llms/components/lr-knowledge-base-admin.md +60 -4
- package/llms/components/lr-knowledge-base.md +121 -9
- package/llms/components/lr-knowledge-graph-explorer.md +106 -11
- package/llms/components/lr-lightbox.md +42 -6
- package/llms/components/lr-line-chart.md +28 -5
- package/llms/components/lr-lite-chart.md +96 -31
- package/llms/components/lr-locale-picker.md +6 -4
- package/llms/components/lr-map.md +67 -8
- package/llms/components/lr-markdown-core.md +10 -5
- package/llms/components/lr-markdown.md +23 -6
- package/llms/components/lr-mention-popover.md +11 -6
- package/llms/components/lr-mind-map.md +91 -10
- package/llms/components/lr-model-select.md +8 -4
- package/llms/components/lr-model-settings-panel.md +10 -2
- package/llms/components/lr-navigation-menu.md +1 -1
- package/llms/components/lr-neighbor-list.md +69 -2
- package/llms/components/lr-pie-chart.md +1 -1
- package/llms/components/lr-polar-area-chart.md +1 -1
- package/llms/components/lr-prompt-input.md +9 -2
- package/llms/components/lr-prompt-queue.md +11 -3
- package/llms/components/lr-radar-chart.md +1 -1
- package/llms/components/lr-rag-eval-dashboard.md +9 -2
- package/llms/components/lr-realtime-session.md +6 -2
- package/llms/components/lr-reorder-list.md +4 -0
- package/llms/components/lr-retrieval-compare.md +9 -4
- package/llms/components/lr-retrieval-results.md +104 -6
- package/llms/components/lr-scatter-chart.md +1 -1
- package/llms/components/lr-select.md +20 -10
- package/llms/components/lr-sequence-strip.md +92 -2
- package/llms/components/lr-span-waterfall.md +78 -8
- package/llms/components/lr-sparkline.md +42 -11
- package/llms/components/lr-spreadsheet-viewer.md +109 -14
- package/llms/components/lr-streaming-text-core.md +4 -2
- package/llms/components/lr-streaming-text.md +5 -1
- package/llms/components/lr-table.md +96 -115
- package/llms/components/lr-task-list.md +93 -9
- package/llms/components/lr-terminal.md +9 -0
- package/llms/components/lr-test-results.md +77 -3
- package/llms/components/lr-thread-list.md +86 -1
- package/llms/components/lr-time-zone-picker.md +8 -3
- package/llms/components/lr-timeline.md +5 -0
- package/llms/components/lr-token-input.md +7 -2
- package/llms/components/lr-tool-timeline.md +13 -4
- package/llms/components/lr-trace-tree.md +96 -10
- package/llms/components/lr-transcript-feed.md +9 -2
- package/llms/components/lr-tree.md +87 -15
- package/llms/components/lr-unit-picker.md +8 -3
- package/llms/components/lr-video-playlist.md +2 -0
- package/llms/components/lr-virtual-list.md +17 -8
- package/llms/components/lr-voice-picker.md +8 -3
- package/llms/components/lr-word-cloud.md +128 -12
- package/llms/components/lr-xml-viewer.md +106 -9
- package/llms/index.md +1 -1
- package/llms/peers.md +1 -1
- package/llms/shared/events-and-types.md +725 -264
- package/llms/shared/forms-and-accessibility.md +3 -17
- package/llms/shared/imports-and-registration.md +3 -17
- package/llms/shared/localization-and-rtl.md +0 -2
- package/llms/shared/styles-and-tokens.md +27 -36
- package/llms/shared/testing-and-utilities.md +4 -5
- package/llms/shared.md +770 -349
- package/llms.txt +1 -2
- package/locales.json +139 -139
- package/package.json +13 -4
- package/registrations.json +1 -1
- package/skills/compose-lyra-interfaces/SKILL.md +6 -8
- package/skills/lyra-ui/SKILL.md +20 -51
- package/skills/lyra-ui/commands/review.md +16 -33
- package/skills/lyra-ui/commands/update.md +6 -5
- package/skills/lyra-ui/online-api.md +15 -0
- package/skills/lyra-ui/reporting.md +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getOwnDataDescriptor,MISSING_OWN_DATA_DESCRIPTOR,UNSAFE_OWN_DATA_DESCRIPTOR}from"../../../internal/data-descriptors.js";function isRuntimeRecord(value){try{return value!==null&&typeof value=="object"&&!Array.isArray(value)}catch{return!1}}function isRuntimeArray(value){try{return Array.isArray(value)}catch{return!1}}function ownDataValue(value,property){return getOwnDataDescriptor(value,property)}function isUnsafeDescriptor(descriptor){return descriptor===UNSAFE_OWN_DATA_DESCRIPTOR}const GEOJSON_DIFF_FEATURE_LIMIT=1e4,GEOJSON_DIFF_VALUE_LIMIT=5e4,GEOJSON_PROJECTION_DEPTH_LIMIT=100,INVALID_GEOJSON_PROJECTION_VALUE=Symbol("invalid-geojson-projection-value"),GEOJSON_FUNCTION_TO_STRING=Function.prototype.toString,GEOJSON_OBJECT_CONSTRUCTOR_SOURCE=GEOJSON_FUNCTION_TO_STRING.call(Object),EMPTY_CANONICAL_GEOJSON_PROJECTION=Object.freeze({diagnostics:Object.freeze([]),collection:void 0}),EMPTY_CANONICAL_GEOJSON_PROPERTIES=new Map;function spendGeoJsonProjectionWork(budget){return budget.remaining<=0?!1:(budget.remaining-=1,!0)}function projectedGeoJsonOwnValue(value,key,budget){if(!spendGeoJsonProjectionWork(budget))return INVALID_GEOJSON_PROJECTION_VALUE;const descriptor=ownDataValue(value,key);return isUnsafeDescriptor(descriptor)?INVALID_GEOJSON_PROJECTION_VALUE:descriptor===MISSING_OWN_DATA_DESCRIPTOR?descriptor:descriptor.value}function isPlainGeoJsonRecord(value){try{const prototype=Object.getPrototypeOf(value);if(prototype===null)return!0;if(Object.getPrototypeOf(prototype)!==null)return!1;const constructorDescriptor=Object.getOwnPropertyDescriptor(prototype,"constructor");if(!constructorDescriptor||!("value"in constructorDescriptor)||typeof constructorDescriptor.value!="function")return!1;const constructor=constructorDescriptor.value,constructorPrototype=Object.getOwnPropertyDescriptor(constructor,"prototype");return!!(constructorPrototype&&"value"in constructorPrototype&&constructorPrototype.value===prototype&&GEOJSON_FUNCTION_TO_STRING.call(constructor)===GEOJSON_OBJECT_CONSTRUCTOR_SOURCE)}catch{return!1}}function projectGeoJsonComparableValue(value,budget,depth=0){if(!spendGeoJsonProjectionWork(budget)||depth>GEOJSON_PROJECTION_DEPTH_LIMIT)return INVALID_GEOJSON_PROJECTION_VALUE;if(value==null||typeof value=="boolean"||typeof value=="string")return value;if(typeof value=="number")return Number.isFinite(value)?value:INVALID_GEOJSON_PROJECTION_VALUE;if(typeof value!="object"||budget.active.has(value))return INVALID_GEOJSON_PROJECTION_VALUE;const remembered=budget.seen.get(value);if(remembered!==void 0)return remembered;if(isRuntimeArray(value)){const length=projectedGeoJsonOwnValue(value,"length",budget);if(length===INVALID_GEOJSON_PROJECTION_VALUE||length===MISSING_OWN_DATA_DESCRIPTOR||typeof length!="number"||!Number.isSafeInteger(length)||length<0||length>budget.remaining)return INVALID_GEOJSON_PROJECTION_VALUE;const output2=new Array(length);budget.seen.set(value,output2),budget.active.add(value);let completed2=!1;try{for(let index=0;index<length;index+=1){const entry=projectedGeoJsonOwnValue(value,String(index),budget);if(entry===INVALID_GEOJSON_PROJECTION_VALUE)return entry;if(entry===MISSING_OWN_DATA_DESCRIPTOR)continue;const projected=projectGeoJsonComparableValue(entry,budget,depth+1);if(projected===INVALID_GEOJSON_PROJECTION_VALUE)return projected;Object.defineProperty(output2,index,{value:projected,enumerable:!0,configurable:!1,writable:!1})}const frozen=Object.freeze(output2);return completed2=!0,frozen}finally{budget.active.delete(value),completed2||budget.seen.delete(value)}}if(!isPlainGeoJsonRecord(value))return INVALID_GEOJSON_PROJECTION_VALUE;const output=Object.create(null);budget.seen.set(value,output),budget.active.add(value);let completed=!1;try{for(const key in value){const entry=projectedGeoJsonOwnValue(value,key,budget);if(entry===INVALID_GEOJSON_PROJECTION_VALUE)return entry;if(entry===MISSING_OWN_DATA_DESCRIPTOR)continue;const projected=projectGeoJsonComparableValue(entry,budget,depth+1);if(projected===INVALID_GEOJSON_PROJECTION_VALUE)return projected;Object.defineProperty(output,key,{value:projected,enumerable:!0,configurable:!1,writable:!1})}const frozen=Object.freeze(output);return completed=!0,frozen}catch{return INVALID_GEOJSON_PROJECTION_VALUE}finally{budget.active.delete(value),completed||budget.seen.delete(value)}}function projectGeoJsonProperties(value,budget){if(value==null)return EMPTY_CANONICAL_GEOJSON_PROPERTIES;if(!isRuntimeRecord(value))return;const output=new Map;try{for(const key in value){const entry=projectedGeoJsonOwnValue(value,key,budget);if(entry===INVALID_GEOJSON_PROJECTION_VALUE)return;entry!==MISSING_OWN_DATA_DESCRIPTOR&&output.set(key,entry)}}catch{return}return output}function projectGeoJsonFeature(value,index,budget){if(!isRuntimeRecord(value))return;const type=projectedGeoJsonOwnValue(value,"type",budget),id=projectedGeoJsonOwnValue(value,"id",budget),geometry=projectedGeoJsonOwnValue(value,"geometry",budget),bbox=projectedGeoJsonOwnValue(value,"bbox",budget),properties=projectedGeoJsonOwnValue(value,"properties",budget);if(properties===INVALID_GEOJSON_PROJECTION_VALUE)return;const projectedProperties=projectGeoJsonProperties(properties===MISSING_OWN_DATA_DESCRIPTOR?void 0:properties,budget);if(!projectedProperties)return;const diagnostic=Object.freeze({id:typeof id=="string"||typeof id=="number"?id:void 0,index,properties:projectedProperties});if(type===INVALID_GEOJSON_PROJECTION_VALUE||id===INVALID_GEOJSON_PROJECTION_VALUE||geometry===INVALID_GEOJSON_PROJECTION_VALUE||bbox===INVALID_GEOJSON_PROJECTION_VALUE||type!=="Feature"||id===MISSING_OWN_DATA_DESCRIPTOR||typeof id!="string"&&typeof id!="number")return Object.freeze({diagnostic,feature:void 0});const comparableGeometry=projectGeoJsonComparableValue(geometry===MISSING_OWN_DATA_DESCRIPTOR?void 0:geometry,budget),comparableBbox=projectGeoJsonComparableValue(bbox===MISSING_OWN_DATA_DESCRIPTOR?void 0:bbox,budget);return Object.freeze(comparableGeometry===INVALID_GEOJSON_PROJECTION_VALUE||comparableBbox===INVALID_GEOJSON_PROJECTION_VALUE?{diagnostic,feature:void 0}:{diagnostic,feature:Object.freeze({id,index,feature:value,geometry:comparableGeometry,bbox:comparableBbox,properties:projectedProperties})})}function projectGeoJson(value){try{if(!isRuntimeRecord(value))return EMPTY_CANONICAL_GEOJSON_PROJECTION;const budget={remaining:GEOJSON_DIFF_VALUE_LIMIT,seen:new WeakMap,active:new WeakSet},type=projectedGeoJsonOwnValue(value,"type",budget),features=projectedGeoJsonOwnValue(value,"features",budget);if(type!=="FeatureCollection"||features===INVALID_GEOJSON_PROJECTION_VALUE||features===MISSING_OWN_DATA_DESCRIPTOR||!isRuntimeArray(features))return EMPTY_CANONICAL_GEOJSON_PROJECTION;const length=projectedGeoJsonOwnValue(features,"length",budget);if(length===INVALID_GEOJSON_PROJECTION_VALUE||length===MISSING_OWN_DATA_DESCRIPTOR||typeof length!="number"||!Number.isSafeInteger(length)||length<0||length>GEOJSON_DIFF_FEATURE_LIMIT)return EMPTY_CANONICAL_GEOJSON_PROJECTION;const diagnostics=[],ordered=[],byId=new Map;let collectionIsAddressable=!0;for(let index=0;index<length;index+=1){const candidate=projectedGeoJsonOwnValue(features,String(index),budget);if(candidate===INVALID_GEOJSON_PROJECTION_VALUE||candidate===MISSING_OWN_DATA_DESCRIPTOR){collectionIsAddressable=!1;continue}const projected=projectGeoJsonFeature(candidate,index,budget);if(!projected){collectionIsAddressable=!1;continue}diagnostics.push(projected.diagnostic);const feature=projected.feature;if(!feature||byId.has(feature.id)){collectionIsAddressable=!1;continue}ordered.push(feature),byId.set(feature.id,feature)}return Object.freeze({diagnostics:Object.freeze(diagnostics),collection:collectionIsAddressable&&ordered.length===length?Object.freeze({ordered:Object.freeze(ordered),byId}):void 0})}catch{return EMPTY_CANONICAL_GEOJSON_PROJECTION}}function sameGeoJsonValue(previous,next,comparison){if(comparison.remaining<=0)return!1;if(comparison.remaining-=1,Object.is(previous,next))return!0;if(previous===null||next===null||typeof previous!="object"||typeof next!="object")return!1;const pairedNext=comparison.forward.get(previous);if(pairedNext)return pairedNext===next;const pairedPrevious=comparison.reverse.get(next);if(pairedPrevious)return pairedPrevious===previous;comparison.forward.set(previous,next),comparison.reverse.set(next,previous);const previousIsArray=Array.isArray(previous),nextIsArray=Array.isArray(next);if(previousIsArray||nextIsArray){if(!previousIsArray||!nextIsArray||previous.length!==next.length)return!1;for(let index=0;index<previous.length;index+=1){const before=Object.getOwnPropertyDescriptor(previous,String(index)),after=Object.getOwnPropertyDescriptor(next,String(index));if(!!before!=!!after)return!1;if(!(!before||!after)&&(!("value"in before)||!("value"in after)||!sameGeoJsonValue(before.value,after.value,comparison)))return!1}return!0}if(!isPlainGeoJsonRecord(previous)||!isPlainGeoJsonRecord(next))return!1;const previousKeys=Object.keys(previous),nextKeys=Object.keys(next);if(previousKeys.length!==nextKeys.length)return!1;for(let index=0;index<previousKeys.length;index+=1){const key=previousKeys[index];if(key!==nextKeys[index])return!1;const before=Object.getOwnPropertyDescriptor(previous,key),after=Object.getOwnPropertyDescriptor(next,key);if(!before||!after||!("value"in before)||!("value"in after)||!sameGeoJsonValue(before.value,after.value,comparison))return!1}return!0}function sameGeoJsonSnapshots(previous,next){try{return sameGeoJsonValue(previous,next,{remaining:GEOJSON_DIFF_VALUE_LIMIT,forward:new WeakMap,reverse:new WeakMap})}catch{return!1}}function buildProjectedGeoJsonPropertyDiff(previous,next){const previousCollection=previous.collection,nextCollection=next.collection;if(!previousCollection||!nextCollection)return null;const previousGeometry=[],nextGeometry=[];for(const after of nextCollection.ordered){const before=previousCollection.byId.get(after.id);before&&(previousGeometry.push(before.geometry,before.bbox),nextGeometry.push(after.geometry,after.bbox))}if(!sameGeoJsonSnapshots(previousGeometry,nextGeometry))return null;const retained=new Set;let previousIndex=-1;for(const feature of nextCollection.ordered){const before=previousCollection.byId.get(feature.id);if(!before||before.index<=previousIndex)break;retained.add(feature.id),previousIndex=before.index}const remove=previousCollection.ordered.filter(feature=>!retained.has(feature.id)).map(feature=>feature.id),add=nextCollection.ordered.filter(feature=>!retained.has(feature.id)).map(feature=>feature.feature),update=[];for(const after of nextCollection.ordered){if(!retained.has(after.id))continue;const before=previousCollection.byId.get(after.id),addOrUpdateProperties=[];for(const[key,value]of after.properties)Object.is(before.properties.get(key),value)||addOrUpdateProperties.push({key,value});const removeProperties=[...before.properties.keys()].filter(key=>!after.properties.has(key));addOrUpdateProperties.length===0&&removeProperties.length===0||update.push({id:after.id,addOrUpdateProperties,removeProperties})}return{...remove.length?{remove}:{},...add.length?{add}:{},update}}const admittedGeoJson=new WeakMap;function projectAdmittedGeoJson(value){if(!isRuntimeRecord(value))return projectGeoJson(value);let projection=admittedGeoJson.get(value);return projection||admittedGeoJson.set(value,projection=projectGeoJson(value)),projection}function buildGeoJsonPropertyDiff(previous,next){return buildProjectedGeoJsonPropertyDiff(projectGeoJson(previous),projectGeoJson(next))}export{buildGeoJsonPropertyDiff,buildProjectedGeoJsonPropertyDiff,projectAdmittedGeoJson,projectGeoJson};
|
|
1
|
+
import{getOwnDataDescriptor,MISSING_OWN_DATA_DESCRIPTOR,UNSAFE_OWN_DATA_DESCRIPTOR}from"../../../internal/data-descriptors.js";function isRuntimeRecord(value){try{return value!==null&&typeof value=="object"&&!Array.isArray(value)}catch{return!1}}function isRuntimeArray(value){try{return Array.isArray(value)}catch{return!1}}function ownDataValue(value,property){return getOwnDataDescriptor(value,property)}function isUnsafeDescriptor(descriptor){return descriptor===UNSAFE_OWN_DATA_DESCRIPTOR}const GEOJSON_DIFF_FEATURE_LIMIT=1e4,GEOJSON_DIFF_VALUE_LIMIT=5e4,GEOJSON_DIFF_VALUES_PER_FEATURE=4096,GEOJSON_DIFF_MAX_VALUES=1e7;function geometryWorkLimit(features){return Math.min(GEOJSON_DIFF_MAX_VALUES,Math.max(GEOJSON_DIFF_VALUE_LIMIT,features*GEOJSON_DIFF_VALUES_PER_FEATURE))}const GEOJSON_PROJECTION_DEPTH_LIMIT=100,INVALID_GEOJSON_PROJECTION_VALUE=Symbol("invalid-geojson-projection-value"),GEOJSON_FUNCTION_TO_STRING=Function.prototype.toString,GEOJSON_OBJECT_CONSTRUCTOR_SOURCE=GEOJSON_FUNCTION_TO_STRING.call(Object),EMPTY_CANONICAL_GEOJSON_PROJECTION=Object.freeze({diagnostics:Object.freeze([]),collection:void 0}),EMPTY_CANONICAL_GEOJSON_PROPERTIES=new Map;function spendGeoJsonProjectionWork(budget){return budget.remaining<=0?!1:(budget.remaining-=1,!0)}function projectedGeoJsonOwnValue(value,key,budget){if(!spendGeoJsonProjectionWork(budget))return INVALID_GEOJSON_PROJECTION_VALUE;const descriptor=ownDataValue(value,key);return isUnsafeDescriptor(descriptor)?INVALID_GEOJSON_PROJECTION_VALUE:descriptor===MISSING_OWN_DATA_DESCRIPTOR?descriptor:descriptor.value}function isPlainGeoJsonRecord(value){try{const prototype=Object.getPrototypeOf(value);if(prototype===null)return!0;if(Object.getPrototypeOf(prototype)!==null)return!1;const constructorDescriptor=Object.getOwnPropertyDescriptor(prototype,"constructor");if(!constructorDescriptor||!("value"in constructorDescriptor)||typeof constructorDescriptor.value!="function")return!1;const constructor=constructorDescriptor.value,constructorPrototype=Object.getOwnPropertyDescriptor(constructor,"prototype");return!!(constructorPrototype&&"value"in constructorPrototype&&constructorPrototype.value===prototype&&GEOJSON_FUNCTION_TO_STRING.call(constructor)===GEOJSON_OBJECT_CONSTRUCTOR_SOURCE)}catch{return!1}}function projectGeoJsonComparableValue(value,budget,depth=0){if(!spendGeoJsonProjectionWork(budget)||depth>GEOJSON_PROJECTION_DEPTH_LIMIT)return INVALID_GEOJSON_PROJECTION_VALUE;if(value==null||typeof value=="boolean"||typeof value=="string")return value;if(typeof value=="number")return Number.isFinite(value)?value:INVALID_GEOJSON_PROJECTION_VALUE;if(typeof value!="object"||budget.active.has(value))return INVALID_GEOJSON_PROJECTION_VALUE;const remembered=budget.seen.get(value);if(remembered!==void 0)return remembered;if(isRuntimeArray(value)){const length=projectedGeoJsonOwnValue(value,"length",budget);if(length===INVALID_GEOJSON_PROJECTION_VALUE||length===MISSING_OWN_DATA_DESCRIPTOR||typeof length!="number"||!Number.isSafeInteger(length)||length<0||length>budget.remaining)return INVALID_GEOJSON_PROJECTION_VALUE;const output2=new Array(length);budget.seen.set(value,output2),budget.active.add(value);let completed2=!1;try{for(let index=0;index<length;index+=1){const entry=projectedGeoJsonOwnValue(value,String(index),budget);if(entry===INVALID_GEOJSON_PROJECTION_VALUE)return entry;if(entry===MISSING_OWN_DATA_DESCRIPTOR)continue;const projected=projectGeoJsonComparableValue(entry,budget,depth+1);if(projected===INVALID_GEOJSON_PROJECTION_VALUE)return projected;Object.defineProperty(output2,index,{value:projected,enumerable:!0,configurable:!1,writable:!1})}const frozen=Object.freeze(output2);return completed2=!0,frozen}finally{budget.active.delete(value),completed2||budget.seen.delete(value)}}if(!isPlainGeoJsonRecord(value))return INVALID_GEOJSON_PROJECTION_VALUE;const output=Object.create(null);budget.seen.set(value,output),budget.active.add(value);let completed=!1;try{for(const key in value){const entry=projectedGeoJsonOwnValue(value,key,budget);if(entry===INVALID_GEOJSON_PROJECTION_VALUE)return entry;if(entry===MISSING_OWN_DATA_DESCRIPTOR)continue;const projected=projectGeoJsonComparableValue(entry,budget,depth+1);if(projected===INVALID_GEOJSON_PROJECTION_VALUE)return projected;Object.defineProperty(output,key,{value:projected,enumerable:!0,configurable:!1,writable:!1})}const frozen=Object.freeze(output);return completed=!0,frozen}catch{return INVALID_GEOJSON_PROJECTION_VALUE}finally{budget.active.delete(value),completed||budget.seen.delete(value)}}function projectGeoJsonProperties(value,budget){if(value==null)return EMPTY_CANONICAL_GEOJSON_PROPERTIES;if(!isRuntimeRecord(value))return;const output=new Map;try{for(const key in value){const entry=projectedGeoJsonOwnValue(value,key,budget);if(entry===INVALID_GEOJSON_PROJECTION_VALUE)return;entry!==MISSING_OWN_DATA_DESCRIPTOR&&output.set(key,entry)}}catch{return}return output}function projectGeoJsonFeature(value,index,budget){if(!isRuntimeRecord(value))return;const type=projectedGeoJsonOwnValue(value,"type",budget),id=projectedGeoJsonOwnValue(value,"id",budget),geometry=projectedGeoJsonOwnValue(value,"geometry",budget),bbox=projectedGeoJsonOwnValue(value,"bbox",budget),properties=projectedGeoJsonOwnValue(value,"properties",budget);if(properties===INVALID_GEOJSON_PROJECTION_VALUE)return;const projectedProperties=projectGeoJsonProperties(properties===MISSING_OWN_DATA_DESCRIPTOR?void 0:properties,budget);if(!projectedProperties)return;const diagnostic=Object.freeze({id:typeof id=="string"||typeof id=="number"?id:void 0,index,properties:projectedProperties});if(type===INVALID_GEOJSON_PROJECTION_VALUE||id===INVALID_GEOJSON_PROJECTION_VALUE||geometry===INVALID_GEOJSON_PROJECTION_VALUE||bbox===INVALID_GEOJSON_PROJECTION_VALUE||type!=="Feature"||id===MISSING_OWN_DATA_DESCRIPTOR||typeof id!="string"&&typeof id!="number")return Object.freeze({diagnostic,feature:void 0});const comparableGeometry=projectGeoJsonComparableValue(geometry===MISSING_OWN_DATA_DESCRIPTOR?void 0:geometry,budget),comparableBbox=projectGeoJsonComparableValue(bbox===MISSING_OWN_DATA_DESCRIPTOR?void 0:bbox,budget);return Object.freeze(comparableGeometry===INVALID_GEOJSON_PROJECTION_VALUE||comparableBbox===INVALID_GEOJSON_PROJECTION_VALUE?{diagnostic,feature:void 0}:{diagnostic,feature:Object.freeze({id,index,feature:value,geometryIdentity:geometry,bboxIdentity:bbox,geometry:comparableGeometry,bbox:comparableBbox,properties:projectedProperties})})}function projectGeoJson(value,comparableValues=new WeakMap){try{if(!isRuntimeRecord(value))return Object.freeze({...EMPTY_CANONICAL_GEOJSON_PROJECTION});const budget={remaining:GEOJSON_DIFF_VALUE_LIMIT,seen:comparableValues,active:new WeakSet},type=projectedGeoJsonOwnValue(value,"type",budget),features=projectedGeoJsonOwnValue(value,"features",budget);if(type!=="FeatureCollection"||features===INVALID_GEOJSON_PROJECTION_VALUE||features===MISSING_OWN_DATA_DESCRIPTOR||!isRuntimeArray(features))return Object.freeze({...EMPTY_CANONICAL_GEOJSON_PROJECTION});const length=projectedGeoJsonOwnValue(features,"length",budget);if(length===INVALID_GEOJSON_PROJECTION_VALUE||length===MISSING_OWN_DATA_DESCRIPTOR||typeof length!="number"||!Number.isSafeInteger(length)||length<0||length>GEOJSON_DIFF_FEATURE_LIMIT)return Object.freeze({...EMPTY_CANONICAL_GEOJSON_PROJECTION});budget.remaining=geometryWorkLimit(length);const diagnostics=[],ordered=[],byId=new Map;let collectionIsAddressable=!0;for(let index=0;index<length;index+=1){const candidate=projectedGeoJsonOwnValue(features,String(index),budget);if(candidate===INVALID_GEOJSON_PROJECTION_VALUE||candidate===MISSING_OWN_DATA_DESCRIPTOR){collectionIsAddressable=!1;continue}const projected=projectGeoJsonFeature(candidate,index,budget);if(!projected){collectionIsAddressable=!1;continue}diagnostics.push(projected.diagnostic);const feature=projected.feature;if(!feature||byId.has(feature.id)){collectionIsAddressable=!1;continue}ordered.push(feature),byId.set(feature.id,feature)}return Object.freeze({diagnostics:Object.freeze(diagnostics),collection:collectionIsAddressable&&ordered.length===length?Object.freeze({ordered:Object.freeze(ordered),byId}):void 0})}catch{return Object.freeze({...EMPTY_CANONICAL_GEOJSON_PROJECTION})}}function sameGeoJsonValue(previous,next,comparison){if(comparison.remaining<=0)return!1;if(comparison.remaining-=1,Object.is(previous,next))return!0;if(previous===null||next===null||typeof previous!="object"||typeof next!="object")return!1;const pairedNext=comparison.forward.get(previous);if(pairedNext)return pairedNext===next;const pairedPrevious=comparison.reverse.get(next);if(pairedPrevious)return pairedPrevious===previous;comparison.forward.set(previous,next),comparison.reverse.set(next,previous);const previousIsArray=Array.isArray(previous),nextIsArray=Array.isArray(next);if(previousIsArray||nextIsArray){if(!previousIsArray||!nextIsArray||previous.length!==next.length)return!1;for(let index=0;index<previous.length;index+=1){const before=Object.getOwnPropertyDescriptor(previous,String(index)),after=Object.getOwnPropertyDescriptor(next,String(index));if(!!before!=!!after)return!1;if(!(!before||!after)&&(!("value"in before)||!("value"in after)||!sameGeoJsonValue(before.value,after.value,comparison)))return!1}return!0}if(!isPlainGeoJsonRecord(previous)||!isPlainGeoJsonRecord(next))return!1;const previousKeys=Object.keys(previous),nextKeys=Object.keys(next);if(previousKeys.length!==nextKeys.length)return!1;for(let index=0;index<previousKeys.length;index+=1){const key=previousKeys[index];if(key!==nextKeys[index])return!1;const before=Object.getOwnPropertyDescriptor(previous,key),after=Object.getOwnPropertyDescriptor(next,key);if(!before||!after||!("value"in before)||!("value"in after)||!sameGeoJsonValue(before.value,after.value,comparison))return!1}return!0}function sameGeoJsonSnapshots(previous,next,featureCount){try{return sameGeoJsonValue(previous,next,{remaining:geometryWorkLimit(featureCount),forward:new WeakMap,reverse:new WeakMap})}catch{return!1}}function buildProjectedGeoJsonPropertyDiff(previous,next){const previousCollection=previous.collection,nextCollection=next.collection;if(!previousCollection||!nextCollection)return null;const previousGeometry=[],nextGeometry=[];for(const after of nextCollection.ordered){const before=previousCollection.byId.get(after.id);before&&(Object.is(before.geometry,after.geometry)||(previousGeometry.push(before.geometry),nextGeometry.push(after.geometry)),Object.is(before.bbox,after.bbox)||(previousGeometry.push(before.bbox),nextGeometry.push(after.bbox)))}if(!sameGeoJsonSnapshots(previousGeometry,nextGeometry,nextCollection.ordered.length))return null;const retained=new Set;let previousIndex=-1;for(const feature of nextCollection.ordered){const before=previousCollection.byId.get(feature.id);if(!before||before.index<=previousIndex)break;retained.add(feature.id),previousIndex=before.index}const remove=previousCollection.ordered.filter(feature=>!retained.has(feature.id)).map(feature=>feature.id),add=nextCollection.ordered.filter(feature=>!retained.has(feature.id)).map(feature=>feature.feature),update=[];for(const after of nextCollection.ordered){if(!retained.has(after.id))continue;const before=previousCollection.byId.get(after.id),addOrUpdateProperties=[];for(const[key,value]of after.properties)Object.is(before.properties.get(key),value)||addOrUpdateProperties.push({key,value});const removeProperties=[...before.properties.keys()].filter(key=>!after.properties.has(key));addOrUpdateProperties.length===0&&removeProperties.length===0||update.push({id:after.id,addOrUpdateProperties,removeProperties})}return{...remove.length?{remove}:{},...add.length?{add}:{},update}}let admittedComparableValues=new WeakMap;const admittedGeoJson=new WeakMap;function projectAdmittedGeoJson(value,refresh=!1){if(!isRuntimeRecord(value))return projectGeoJson(value);refresh&&(admittedComparableValues=new WeakMap);let projection=refresh?void 0:admittedGeoJson.get(value);return projection||admittedGeoJson.set(value,projection=projectGeoJson(value,admittedComparableValues)),projection}function buildGeoJsonPropertyDiff(previous,next){const comparableValues=new WeakMap;return buildProjectedGeoJsonPropertyDiff(projectGeoJson(previous,comparableValues),projectGeoJson(next,comparableValues))}export{buildGeoJsonPropertyDiff,buildProjectedGeoJsonPropertyDiff,projectAdmittedGeoJson,projectGeoJson};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import type{Feature}from'geojson';export interface MapLibreGeoJsonSource{setData(data:unknown):void;
|
|
1
|
+
import type{Feature,Geometry}from'geojson';export interface MapLibreGeoJsonSource{setData(data:unknown):void;
|
|
2
2
|
/** maplibre-gl 3+ incremental update. Optional because older peers lack it. */
|
|
3
|
+
updateData?(diff:MapLibreSourceDataDiff):void;
|
|
4
|
+
/** Retains the automatic property-diff signature for extracted method parameter types. */
|
|
3
5
|
updateData?(diff:MapLibreGeoJsonDiff):void;}
|
|
6
|
+
/** Consumer-authored incremental GeoJSON changes, forwarded to the active map engine. */
|
|
7
|
+
export interface MapLibreSourceDataDiff{readonly removeAll?:boolean;readonly remove?:readonly(string|number)[];readonly add?:readonly Feature[];readonly update?:readonly{readonly id:string|number;readonly newGeometry?:Geometry;readonly removeAllProperties?:boolean;readonly removeProperties?:readonly string[];readonly addOrUpdateProperties?:readonly{readonly key:string;readonly value:unknown;}[];}[];}
|
|
4
8
|
/** The subset of maplibre-gl's GeoJSON diff this component emits. */
|
|
5
9
|
export interface MapLibreGeoJsonDiff{readonly remove?:readonly(string|number)[];readonly add?:readonly Feature[];readonly update:readonly{readonly id:string|number;readonly addOrUpdateProperties:readonly{readonly key:string;readonly value:unknown;}[];readonly removeProperties:readonly string[];}[];}export interface MapLibrePopupCapability{setHTML(html:string):this;setText(text:string):this;on?(type:'open'|'close',listener:()=>void):this;isOpen?():boolean;getElement?():HTMLElement|undefined;options?:{focusAfterOpen?:boolean;};}export interface MapLibreMarkerCapability{setLngLat(lngLat:[number,number]):this;setPopup(popup?:MapLibrePopupCapability):this;getPopup():MapLibrePopupCapability|undefined;addTo(map:MapLibreMapCapability):this;remove():void;getElement?():HTMLElement;}
|
|
6
10
|
/** Actual source, layer, projection and terrain descriptors to prepare before synchronous mutations. */
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import{type TemplateResult,type PropertyValues}from'lit';import type{Feature,FeatureCollection}from'geojson';import{LyraElement}from'../../../internal/lyra-element.js';import{type LyraMapFeatureRequirements}from'./map-loader.js';export{buildGeoJsonPropertyDiff}from'./map-geojson-diff.js';import'../../overlays/skeleton/skeleton.class.js';
|
|
1
|
+
import{type TemplateResult,type PropertyValues}from'lit';import type{Feature,FeatureCollection}from'geojson';import{LyraElement}from'../../../internal/lyra-element.js';import{type LyraMapFeatureRequirements,type MapLibreSourceDataDiff}from'./map-loader.js';export{buildGeoJsonPropertyDiff}from'./map-geojson-diff.js';import'../../overlays/skeleton/skeleton.class.js';
|
|
2
|
+
/** A caller-authored GeoJSON source diff; feature IDs must be unique and stable. */
|
|
3
|
+
export type LyraMapSourceDataDiff=MapLibreSourceDataDiff;export type{LyraMapFeatureRequirements}from'./map-loader.js';
|
|
2
4
|
/** Map engine selected before connecting the component. */
|
|
3
5
|
export type LyraMapEngine='modular'|'maplibre';
|
|
4
6
|
/** Non-color encoding retained when a legend entry's authored color is unavailable. */
|
|
@@ -450,6 +452,10 @@ readonly sourceId:string|undefined;}>;}
|
|
|
450
452
|
* selects the full optional `maplibre-gl` peer (v5 or v6). Both engines require WebGL2; the
|
|
451
453
|
* component styles generated canvas, marker, popup, and control DOM inside its shadow root.
|
|
452
454
|
*
|
|
455
|
+
* Marker inspection is limited to 2,000 entries (markersTruncated reports an omitted suffix),
|
|
456
|
+
* and dataLayers to 100 entries. Automatic diffs support 10,000 features; updateSourceData()
|
|
457
|
+
* forwards explicit diffs for larger sources without whole-source comparison.
|
|
458
|
+
*
|
|
453
459
|
* The underlying `maplibregl.Map` — and the WebGL context it opens — isn't
|
|
454
460
|
* constructed until this element is first visible in the viewport (tracked
|
|
455
461
|
* via `IntersectionObserver`), even once the `maplibre-gl` peer dependency
|
|
@@ -623,7 +629,7 @@ static preload(engine?:LyraMapEngine):Promise<boolean>;constructor();
|
|
|
623
629
|
get center():readonly[number,number];set center(value:readonly[number,number]);private _center;
|
|
624
630
|
/** Initial and controlled map zoom level. Tracks the settled camera and reconciles the same way
|
|
625
631
|
* as `center`. */
|
|
626
|
-
zoom:number;private pendingFit?;private readonly fitToken;private semanticsStale;private reflectedCamera?;private boxZoomSettling;private writingCamera;
|
|
632
|
+
zoom:number;private pendingFit?;private readonly fitToken;private semanticsStale;private markerSemanticsStale;private geoJsonRefreshRequested;private refreshingGeoJson;private reflectedCamera?;private boxZoomSettling;private writingCamera;
|
|
627
633
|
/** Whether the constructed peer repeats the world horizontally. `undefined` leaves MapLibre's
|
|
628
634
|
* own default in force. Construction-only; set before the map is created. */
|
|
629
635
|
renderWorldCopies?:boolean;
|
|
@@ -746,12 +752,18 @@ get hiddenCategories():readonly string[];set hiddenCategories(value:readonly str
|
|
|
746
752
|
choropleth?:Readonly<LyraMapChoroplethLayer>;
|
|
747
753
|
/** Point markers rendered over the map. Explicit IDs are unique-nonempty first-wins. An idless
|
|
748
754
|
* marker is instead identified by its coordinate occurrence, so colocated idless markers remain
|
|
749
|
-
* separate.
|
|
755
|
+
* separate. At most the first 2,000 entries are inspected; use dataLayers with cluster for
|
|
756
|
+
* larger collections. markersTruncated reports an omitted suffix. */
|
|
750
757
|
markers:readonly LyraMapMarker[];
|
|
758
|
+
/** Whether authored marker entries exceed the 2,000-entry inspection ceiling. */
|
|
759
|
+
get markersTruncated():boolean;
|
|
751
760
|
/**
|
|
752
761
|
* Additive GeoJSON layers rendered alongside the choropleth/markers -- each entry becomes a
|
|
753
762
|
* source plus fill/line/circle layers. `sourceId` values are trimmed, must be nonempty, and retain
|
|
754
|
-
* only their first occurrence. Defaults empty.
|
|
763
|
+
* only their first occurrence. Defaults empty; at most 100 entries are inspected. Automatic
|
|
764
|
+
* diffs inspect at most 10,000 features and 10,000,000 values (4,096 per feature, minimum
|
|
765
|
+
* 50,000); larger changes use whole-source replacement or explicit updateSourceData().
|
|
766
|
+
* Call requestUpdate() after intentionally mutating an opaque GeoJSON source in place.
|
|
755
767
|
*
|
|
756
768
|
* An entry opts into either of two other renderings, both strictly additive: `cluster` turns its
|
|
757
769
|
* source into a natively clustered one (aggregate circle, count label, unclustered points), which
|
|
@@ -771,7 +783,13 @@ engine:LyraMapEngine;private loading;private failure?;private readonly announcem
|
|
|
771
783
|
/** The underlying runtime `maplibregl.Map`, declared through Lyra's peer-neutral common-method
|
|
772
784
|
* subset so consumers do not acquire a mandatory `maplibre-gl` type dependency. Consumers that
|
|
773
785
|
* install the optional peer may explicitly narrow this value to its full `Map` type. */
|
|
774
|
-
get map():LyraMapInstance|undefined;private pushGeoJson;
|
|
786
|
+
get map():LyraMapInstance|undefined;private pushGeoJson;
|
|
787
|
+
/** Forwards a caller-authored diff to an applied dataLayers or choropleth public sourceId.
|
|
788
|
+
* Returns false before the source is ready, after disconnect, or if the engine lacks updateData.
|
|
789
|
+
* The diff is passed through without cloning; the caller owns feature IDs and validity. This
|
|
790
|
+
* route bypasses the automatic 10,000-feature comparison ceiling. It does not rewrite public
|
|
791
|
+
* properties; reassigning controlled GeoJSON later replaces this imperative state in full. */
|
|
792
|
+
updateSourceData(sourceId:string,diff:LyraMapSourceDataDiff):boolean;private get safeMaxBounds();private applyMaxBounds;private get safeZoom();private get safeCenter();
|
|
775
793
|
/**
|
|
776
794
|
* Frames `bounds`, `[[west, south], [east, north]]`, in the viewport: the usual way to show every
|
|
777
795
|
* current marker or a selected region whenever the data set changes.
|
|
@@ -806,7 +824,7 @@ get map():LyraMapInstance|undefined;private pushGeoJson;private get safeMaxBound
|
|
|
806
824
|
* Returns `false`, without moving or queueing anything, when `bounds` is unusable or the loaded
|
|
807
825
|
* peer cannot fit a box, and `true` once the fit is running or queued.
|
|
808
826
|
*/
|
|
809
|
-
fitBounds(bounds:LyraMapBounds,options?:LyraMapFitBoundsOptions):boolean;private applyFit;private applyPendingFit;private reflectCamera;private pushCamera;private writeCamera;connectedCallback():void;disconnectedCallback():void;private failureMessage;private failInitialization;private scheduleStyleRequiredFailure;private disposeMap;adoptedCallback():void;private tryConstructMap;requestUpdate(...args:Parameters<LyraElement['requestUpdate']>):void;protected updated(changed:PropertyValues):void;protected willUpdate(changed:PropertyValues):void;private refreshThemePaint;private cancelFeaturePreparation;private generatedFeatureRequirements;private reconcileGeneratedLayers;private applyChoropleth;private choroplethColorExpression;private resolveChoroplethSourceId;private removeChoropleth;private applyDataLayers;private applyDataLayerRendering;private paintDataLayer;private applyGeometryLayers;private paintGeometryLayers;private lineColor;private mutedPointOpacity;private paintPoints;private pointIconColor;private removePointIcons;private applyPointIcons;private paintPointIcons;private clusterColorExpression;private applyClusterLayers;private paintClusterLayers;private applyHeatmapLayer;private paintHeatmapLayer;private heatmapColorExpression;private styleProvidesGlyphs;private resolveDataLayerSourceId;private removeDataLayer;private applyMarkers;private readonly configuredMarkerElements;private configureMarkerInteraction;private emitMarkerActivation;private get effectiveMapLabel();private popupId;private configurePopupSemantics;private stopObservingMapAllocation;private observeMapAllocation;private stopObservingPeerChrome;private peerControlsResizeObserver?;private peerControlsResizeFrame?;private schedulePeerControlInsets;private measurePeerControlInsets;private syncPeerChromeParts;private observePeerChrome;private syncPopupSemantics;private syncMapSemantics;private formatCount;private legendLimitText;private onLegendSlotChange;
|
|
827
|
+
fitBounds(bounds:LyraMapBounds,options?:LyraMapFitBoundsOptions):boolean;private applyFit;private applyPendingFit;private reflectCamera;private pushCamera;private writeCamera;connectedCallback():void;disconnectedCallback():void;private failureMessage;private failInitialization;private scheduleStyleRequiredFailure;private disposeMap;adoptedCallback():void;private tryConstructMap;requestUpdate(...args:Parameters<LyraElement['requestUpdate']>):void;protected updated(changed:PropertyValues):void;protected willUpdate(changed:PropertyValues):void;private paintThemeKey?;private paintThemeSources?;private paintThemeTokens;private syncPaintTheme;private refreshThemePaint;private cancelFeaturePreparation;private generatedFeatureRequirements;private reconcileGeneratedLayers;private appliedChoroplethPaintKey?;private applyChoropleth;private choroplethColorExpression;private resolveChoroplethSourceId;private removeChoropleth;private readonly appliedLayerPaintKeys;private applyDataLayers;private applyDataLayerRendering;private paintDataLayer;private applyGeometryLayers;private paintGeometryLayers;private lineColor;private mutedPointOpacity;private paintPoints;private pointIconColor;private removePointIcons;private applyPointIcons;private paintPointIcons;private clusterColorExpression;private applyClusterLayers;private paintClusterLayers;private applyHeatmapLayer;private paintHeatmapLayer;private heatmapColorExpression;private styleProvidesGlyphs;private resolveDataLayerSourceId;private removeDataLayer;private applyMarkers;private readonly configuredMarkerElements;private configureMarkerInteraction;private emitMarkerActivation;private get effectiveMapLabel();private popupId;private configurePopupSemantics;private stopObservingMapAllocation;private observeMapAllocation;private stopObservingPeerChrome;private peerControlsResizeObserver?;private peerControlsResizeFrame?;private schedulePeerControlInsets;private measurePeerControlInsets;private syncPeerChromeParts;private observePeerChrome;private syncPopupSemantics;private syncMapSemantics;private formatCount;private legendLimitText;private onLegendSlotChange;
|
|
810
828
|
/**
|
|
811
829
|
* The continuous gradient bar plus its two endpoint captions, or nothing when `legendGradient`
|
|
812
830
|
* holds fewer than two usable stops. Part names mirror `lr-heatmap`'s
|
|
@@ -9,7 +9,7 @@ import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/co
|
|
|
9
9
|
stroke-width=${icon.strokeWidth??DEFAULT_ICON_STROKE_WIDTH}
|
|
10
10
|
stroke-linecap=${icon.lineCap??"round"}
|
|
11
11
|
stroke-linejoin=${icon.lineJoin??"round"}
|
|
12
|
-
></path></svg>`}function addPartToken(element,token){const tokens=new Set((element.getAttribute("part")??"").split(/\s+/).filter(Boolean));tokens.add(token),element.setAttribute("part",[...tokens].join(" "))}const CHOROPLETH_LOG_INTERPOLATION_BASE=.25,CHOROPLETH_LEGEND_SAMPLES_PER_INTERVAL=8;function choroplethLogInterpolationFactor(input,lower,upper){const difference=upper-lower;if(difference===0)return 0;const progress=input-lower;return(Math.pow(CHOROPLETH_LOG_INTERPOLATION_BASE,progress)-1)/(Math.pow(CHOROPLETH_LOG_INTERPOLATION_BASE,difference)-1)}function compactGradientPercent(value){return String(Math.round(Math.min(100,Math.max(0,value))*1e4)/1e4)}function choroplethLegendGradientImage(stops,interpolation){const lo=stops[0],span=stops[stops.length-1][0]-lo[0],stopPercent=(value,index)=>span>0?(value-lo[0])/span*100:index/(stops.length-1)*100;if(interpolation!=="logarithmic"||span<=0)return`linear-gradient(to right, ${stops.map(([value,color],index)=>`${color} ${compactGradientPercent(stopPercent(value,index))}%`).join(", ")})`;const image=[`${lo[1]} 0%`];for(let index=1;index<stops.length;index+=1){const lower=stops[index-1],upper=stops[index],interval=upper[0]-lower[0];if(interval<=0){image.push(`${upper[1]} ${compactGradientPercent(stopPercent(upper[0],index))}%`);continue}for(let sample=1;sample<=CHOROPLETH_LEGEND_SAMPLES_PER_INTERVAL;sample+=1){const intervalProgress=sample/CHOROPLETH_LEGEND_SAMPLES_PER_INTERVAL,input=lower[0]+interval*intervalProgress,position=(input-lo[0])/span*100;if(sample===CHOROPLETH_LEGEND_SAMPLES_PER_INTERVAL){image.push(`${upper[1]} ${compactGradientPercent(position)}%`);continue}const factor=Math.min(1,Math.max(0,choroplethLogInterpolationFactor(input,lower[0],upper[0]))),lowerWeight=compactGradientPercent((1-factor)*100),upperWeight=compactGradientPercent(factor*100);image.push(`color-mix(in srgb, ${lower[1]} ${lowerWeight}%, ${upper[1]} ${upperWeight}%) ${compactGradientPercent(position)}%`)}}return`linear-gradient(to right, ${image.join(", ")})`}const MAX_MAP_MARKERS=2e3;function popupText(host,markup){const template=host.ownerDocument.createElement("template");template.innerHTML=markup;for(const hidden of template.content.querySelectorAll('script, style, template, [hidden], [aria-hidden="true"]'))hidden.remove();return(template.content.textContent??"").replace(/\s+/gu," ").trim()}function markerPopupText(host,markup){return typeof markup=="string"&&markup?popupText(host,markup):""}const MAX_MAP_DATA_LAYERS=100,EMPTY_CANONICAL_MAP_DATA_LAYERS=Object.freeze([]);function mapTone(value){switch(value){case"accent":case"success":case"warning":case"danger":case"neutral":return value;default:return}}function projectMapDataLayer(value){try{if(!isRuntimeRecord(value))return;const sourceIdDescriptor=getOwnDataDescriptor(value,"sourceId"),geojsonDescriptor=getOwnDataDescriptor(value,"geojson"),toneDescriptor=getOwnDataDescriptor(value,"tone"),colorDescriptor=getOwnDataDescriptor(value,"color"),strokeColorDescriptor=getOwnDataDescriptor(value,"strokeColor"),lineDescriptor=getOwnDataDescriptor(value,"line"),kindDescriptor=getOwnDataDescriptor(value,"kind"),heatmapDescriptor=getOwnDataDescriptor(value,"heatmap"),clusterDescriptor=getOwnDataDescriptor(value,"cluster");if(sourceIdDescriptor===MISSING_OWN_DATA_DESCRIPTOR||geojsonDescriptor===MISSING_OWN_DATA_DESCRIPTOR||isUnsafeDescriptor(sourceIdDescriptor)||isUnsafeDescriptor(geojsonDescriptor))return;const sourceId=sourceIdDescriptor.value,geojson=geojsonDescriptor.value;if(typeof sourceId!="string"||sourceId.trim().length===0||!isRuntimeRecord(geojson))return;const tone=mapTone(optionalDescriptorValue(toneDescriptor)),colorValue=optionalDescriptorValue(colorDescriptor),strokeColorValue=optionalDescriptorValue(strokeColorDescriptor),kindValue=optionalDescriptorValue(kindDescriptor),heatmapValue=optionalDescriptorValue(heatmapDescriptor),clusterValue=optionalDescriptorValue(clusterDescriptor),kind=kindValue==="heatmap"?"heatmap":"auto";return Object.freeze({sourceId:sourceId.trim(),geojson,geojsonProjection:projectAdmittedGeoJson(geojson),tone,color:typeof colorValue=="string"?colorValue:void 0,strokeColor:typeof strokeColorValue=="string"?strokeColorValue:void 0,line:kind==="auto"?projectLineOptions(optionalDescriptorValue(lineDescriptor)):void 0,point:kind==="auto"?projectPointOptions(optionalDescriptorValue(getOwnDataDescriptor(value,"point"))):void 0,kind,heatmap:kind==="heatmap"?projectHeatmapOptions(heatmapValue):void 0,cluster:kind==="auto"?normalizedClusterOptions(clusterValue):void 0})}catch{return}}function projectMapDataLayers(value){try{const scanCount=boundedOwnArrayLength(value,MAX_MAP_DATA_LAYERS);if(scanCount===void 0)return EMPTY_CANONICAL_MAP_DATA_LAYERS;const output=[],seenSourceIds=new Set;for(let index=0;index<scanCount;index+=1){const descriptor=getOwnDataDescriptor(value,String(index));if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||isUnsafeDescriptor(descriptor))continue;const layer=projectMapDataLayer(descriptor.value);!layer||seenSourceIds.has(layer.sourceId)||(seenSourceIds.add(layer.sourceId),output.push(layer))}return output.length?Object.freeze(output):EMPTY_CANONICAL_MAP_DATA_LAYERS}catch{return EMPTY_CANONICAL_MAP_DATA_LAYERS}}const DATA_LAYER_SUFFIXES=["-fill","-line","-circle","-point-icon","-cluster","-cluster-count","-heatmap"],QUERYABLE_DATA_LAYER_SUFFIXES=["-fill","-line","-circle","-cluster","-point-icon"],MAX_MAP_STEP_STOPS=32;function normalizedSteps(value,isOutput,clampThreshold=threshold=>threshold){try{const scanCount=boundedOwnArrayLength(value,MAX_MAP_STEP_STOPS);if(scanCount===void 0)return Object.freeze([]);const usable=[];for(let index=0;index<scanCount;index+=1){const stopDescriptor=getOwnDataDescriptor(value,String(index));if(stopDescriptor===MISSING_OWN_DATA_DESCRIPTOR||isUnsafeDescriptor(stopDescriptor))continue;const stop=stopDescriptor.value,stopLength=boundedOwnArrayLength(stop,2);if(stopLength===void 0||stopLength<2)continue;const thresholdDescriptor=getOwnDataDescriptor(stop,"0"),outputDescriptor=getOwnDataDescriptor(stop,"1");thresholdDescriptor===MISSING_OWN_DATA_DESCRIPTOR||outputDescriptor===MISSING_OWN_DATA_DESCRIPTOR||isUnsafeDescriptor(thresholdDescriptor)||isUnsafeDescriptor(outputDescriptor)||typeof thresholdDescriptor.value!="number"||!Number.isFinite(thresholdDescriptor.value)||!isOutput(outputDescriptor.value)||usable.push([clampThreshold(thresholdDescriptor.value),outputDescriptor.value])}usable.sort((a,b)=>a[0]-b[0]);const deduplicated=usable.filter((stop,index)=>index===0||stop[0]>usable[index-1][0]);return Object.freeze(deduplicated.map(stop=>Object.freeze(stop)))}catch{return Object.freeze([])}}const isFiniteOutput=candidate=>typeof candidate=="number"&&Number.isFinite(candidate),isColorOutput=candidate=>typeof candidate=="string"&&candidate.trim().length>0,DEFAULT_CLUSTER_RADIUS=50,DEFAULT_CLUSTER_MAX_ZOOM=14,DEFAULT_CLUSTER_RADIUS_STEPS=Object.freeze([[0,14],[10,18],[50,24]]),DEFAULT_HEATMAP_RADIUS=30,DEFAULT_HEATMAP_INTENSITY=1,MAX_CLUSTER_COUNT_FONTS=8;function normalizedClusterOptions(value){try{if(!isRuntimeRecord(value))return;const radiusDescriptor=getOwnDataDescriptor(value,"radius"),maxZoomDescriptor=getOwnDataDescriptor(value,"maxZoom"),radiusStepsDescriptor=getOwnDataDescriptor(value,"radiusSteps"),colorStepsDescriptor=getOwnDataDescriptor(value,"colorSteps"),strokeColorDescriptor=getOwnDataDescriptor(value,"strokeColor"),countFontDescriptor=getOwnDataDescriptor(value,"countFont"),countColorDescriptor=getOwnDataDescriptor(value,"countColor"),countHaloColorDescriptor=getOwnDataDescriptor(value,"countHaloColor"),countHaloWidthDescriptor=getOwnDataDescriptor(value,"countHaloWidth"),radiusValue=optionalDescriptorValue(radiusDescriptor),maxZoomValue=optionalDescriptorValue(maxZoomDescriptor),radiusSteps=normalizedSteps(optionalDescriptorValue(radiusStepsDescriptor),isFiniteOutput),colorSteps=normalizedSteps(optionalDescriptorValue(colorStepsDescriptor),isColorOutput),fonts=normalizedClusterFonts(optionalDescriptorValue(countFontDescriptor)),countHaloWidthValue=optionalDescriptorValue(countHaloWidthDescriptor);return Object.freeze({radius:finiteRange(typeof radiusValue=="number"?radiusValue:Number.NaN,DEFAULT_CLUSTER_RADIUS,1,1e3),maxZoom:finiteRange(typeof maxZoomValue=="number"?maxZoomValue:Number.NaN,DEFAULT_CLUSTER_MAX_ZOOM,0,24),radiusSteps:radiusSteps.length?radiusSteps:DEFAULT_CLUSTER_RADIUS_STEPS,colorSteps,strokeColor:sanitizeCssColor(optionalDescriptorValue(strokeColorDescriptor)),countFont:fonts.length?fonts:void 0,countColor:sanitizeCssColor(optionalDescriptorValue(countColorDescriptor)),countHaloColor:sanitizeCssColor(optionalDescriptorValue(countHaloColorDescriptor)),countHaloWidth:countHaloWidthValue===void 0?1:finiteRange(typeof countHaloWidthValue=="number"?countHaloWidthValue:Number.NaN,1,0,3)})}catch{return}}function normalizedClusterFonts(value){try{const length=boundedOwnArrayLength(value,MAX_CLUSTER_COUNT_FONTS);if(length===void 0)return Object.freeze([]);const fonts=[];for(let index=0;index<length;index+=1){const descriptor=getOwnDataDescriptor(value,String(index));descriptor===MISSING_OWN_DATA_DESCRIPTOR||isUnsafeDescriptor(descriptor)||typeof descriptor.value!="string"||descriptor.value.trim().length===0||fonts.push(descriptor.value)}return Object.freeze(fonts)}catch{return Object.freeze([])}}const DEFAULT_ICON_VIEW_BOX=Object.freeze([0,0,24,24]),DEFAULT_ICON_STROKE_WIDTH=2,ICON_PATH_GRAMMAR=/^[MmLlHhVvCcSsQqTtAaZz\d.eE+,\s-]+$/u,MAX_ICON_PATH_LENGTH=8192;function projectIconPaint(row){const path=optionalDescriptorValue(getOwnDataDescriptor(row,"path"));if(typeof path!="string"||path.length===0||path.length>MAX_ICON_PATH_LENGTH||!ICON_PATH_GRAMMAR.test(path))return;const rawBox=optionalDescriptorValue(getOwnDataDescriptor(row,"viewBox")),box=[];if(rawBox===void 0)box.push(...DEFAULT_ICON_VIEW_BOX);else{if(boundedOwnArrayLength(rawBox,4)!==4)return;for(let index=0;index<4;index++){const coordinate=optionalDescriptorValue(getOwnDataDescriptor(rawBox,String(index)));if(typeof coordinate!="number"||!Number.isFinite(coordinate)||Math.abs(coordinate)>1e4)return;box.push(coordinate)}if(box[2]<.001||box[3]<.001)return}const mode=optionalDescriptorValue(getOwnDataDescriptor(row,"mode")),strokeWidth=optionalDescriptorValue(getOwnDataDescriptor(row,"strokeWidth")),lineCap=optionalDescriptorValue(getOwnDataDescriptor(row,"lineCap")),lineJoin=optionalDescriptorValue(getOwnDataDescriptor(row,"lineJoin"));return Object.freeze({path,viewBox:Object.freeze(box),mode:mode==="stroke"||mode==="fill-stroke"?mode:"fill",strokeWidth:finiteRange(typeof strokeWidth=="number"?strokeWidth:NaN,DEFAULT_ICON_STROKE_WIDTH,0,200),lineCap:lineCap==="butt"||lineCap==="square"?lineCap:"round",lineJoin:lineJoin==="miter"||lineJoin==="bevel"?lineJoin:"round"})}function projectPointRadius(value){if(!isRuntimeRecord(value))return finiteRange(typeof value=="number"?value:NaN,5,0,200);const read=key=>optionalDescriptorValue(getOwnDataDescriptor(value,key)),field=read("field"),rawFallback=read("fallback"),fallback=finiteRange(typeof rawFallback=="number"?rawFallback:NaN,5,0,200),stops=normalizedSteps(read("stops"),isFiniteOutput).map(([threshold,radius])=>Object.freeze([threshold,finiteRange(radius,5,0,200)]));return typeof field!="string"||!field.trim()||!stops.length?fallback:Object.freeze({field:field.trim(),stops:Object.freeze(stops),fallback,interpolation:read("interpolation")==="linear"?"linear":"step"})}function projectPointOptions(value){if(!isRuntimeRecord(value))return;const read=key=>optionalDescriptorValue(getOwnDataDescriptor(value,key)),string=key=>{const candidate=read(key);return typeof candidate=="string"&&candidate.trim()?candidate:void 0},number=(key,fallback,min,max)=>{const candidate=read(key);return finiteRange(typeof candidate=="number"?candidate:NaN,fallback,min,max)},colors=[],icons=[],project=(input,accept)=>{const length=boundedOwnArrayLength(input,MAX_MAP_STEP_STOPS)??0;for(let index=0;index<length;index++){const row=optionalDescriptorValue(getOwnDataDescriptor(input,String(index)));row!==null&&typeof row=="object"&&accept(row)}};return project(read("colors"),row=>{const key=optionalDescriptorValue(getOwnDataDescriptor(row,"0")),color=optionalDescriptorValue(getOwnDataDescriptor(row,"1"));typeof key!="string"||typeof color!="string"||!sanitizeCssColor(color)||colors.some(([existing])=>existing===key)||colors.push(Object.freeze([key,color]))}),project(read("icons"),row=>{const key=optionalDescriptorValue(getOwnDataDescriptor(row,"value"));if(typeof key!="string"||icons.some(icon=>icon.value===key))return;const paint=projectIconPaint(row);paint&&icons.push(Object.freeze({value:key,...paint}))}),Object.freeze({field:string("field"),colors:Object.freeze(colors),radius:projectPointRadius(read("radius")),strokeWidth:number("strokeWidth",0,0,200),strokeColor:string("strokeColor"),iconField:string("iconField")??string("field"),icons:Object.freeze(icons),iconColor:string("iconColor"),iconSize:number("iconSize",16,1,200)})}const POINT_ICON_RASTER_SIZE=64;function rasterPointIcon(host,icon,color){try{const canvas=host.ownerDocument.createElement("canvas");canvas.width=canvas.height=POINT_ICON_RASTER_SIZE;const context=canvas.getContext("2d"),Path=host.ownerDocument.defaultView?.Path2D;if(!context||!Path)return;const[x,y,width,height]=icon.viewBox,scale=POINT_ICON_RASTER_SIZE/Math.max(width,height);context.translate((POINT_ICON_RASTER_SIZE-width*scale)/2,(POINT_ICON_RASTER_SIZE-height*scale)/2),context.scale(scale,scale),context.translate(-x,-y);const path=new Path(icon.path);return icon.mode!=="stroke"&&(context.fillStyle=color,context.fill(path)),icon.mode!=="fill"&&icon.strokeWidth>0&&(context.strokeStyle=color,context.lineWidth=icon.strokeWidth,context.lineCap=icon.lineCap,context.lineJoin=icon.lineJoin,context.stroke(path)),context.getImageData(0,0,POINT_ICON_RASTER_SIZE,POINT_ICON_RASTER_SIZE)}catch{return}}function projectLineOptions(value){try{if(!isRuntimeRecord(value))return;const field=optionalDescriptorValue(getOwnDataDescriptor(value,"field")),width=optionalDescriptorValue(getOwnDataDescriptor(value,"width")),opacity=optionalDescriptorValue(getOwnDataDescriptor(value,"opacity"));return Object.freeze({field:typeof field=="string"&&field.trim()?field.trim():void 0,stops:Object.freeze(normalizeMapLegendGradient(optionalDescriptorValue(getOwnDataDescriptor(value,"stops"))).filter((stop,index,stops)=>index===0||stop[0]>stops[index-1][0]).map(stop=>Object.freeze(stop))),width:typeof width=="number"?finiteRange(width,2,0,200):2,opacity:typeof opacity=="number"?finiteRange(opacity,1,0,1):1})}catch{return}}function projectedHeatmapRange(value){try{const length=boundedOwnArrayLength(value,2);if(length===void 0||length<2)return;const minDescriptor=getOwnDataDescriptor(value,"0"),maxDescriptor=getOwnDataDescriptor(value,"1");return minDescriptor===MISSING_OWN_DATA_DESCRIPTOR||maxDescriptor===MISSING_OWN_DATA_DESCRIPTOR||isUnsafeDescriptor(minDescriptor)||isUnsafeDescriptor(maxDescriptor)||typeof minDescriptor.value!="number"||typeof maxDescriptor.value!="number"||!Number.isFinite(minDescriptor.value)||!Number.isFinite(maxDescriptor.value)?void 0:Object.freeze([minDescriptor.value,maxDescriptor.value])}catch{return}}function projectedHeatmapZoomValue(value){if(typeof value=="number"&&Number.isFinite(value))return value;if(isRuntimeArray(value))return normalizedSteps(value,isFiniteOutput,zoom=>finiteRange(zoom,0,0,24))}function projectHeatmapOptions(value){try{if(!isRuntimeRecord(value))return;const weightFieldDescriptor=getOwnDataDescriptor(value,"weightField"),weightRangeDescriptor=getOwnDataDescriptor(value,"weightRange"),stopsDescriptor=getOwnDataDescriptor(value,"stops"),radiusDescriptor=getOwnDataDescriptor(value,"radius"),intensityDescriptor=getOwnDataDescriptor(value,"intensity"),opacityDescriptor=getOwnDataDescriptor(value,"opacity"),weightFieldValue=optionalDescriptorValue(weightFieldDescriptor),opacityValue=optionalDescriptorValue(opacityDescriptor);return Object.freeze({weightField:typeof weightFieldValue=="string"&&weightFieldValue.trim().length>0?weightFieldValue.trim():void 0,weightRange:projectedHeatmapRange(optionalDescriptorValue(weightRangeDescriptor)),stops:normalizedSteps(optionalDescriptorValue(stopsDescriptor),isColorOutput,density=>finiteRange(density,0,0,1)),radius:projectedHeatmapZoomValue(optionalDescriptorValue(radiusDescriptor)),intensity:projectedHeatmapZoomValue(optionalDescriptorValue(intensityDescriptor)),opacity:typeof opacityValue=="number"&&Number.isFinite(opacityValue)?opacityValue:void 0})}catch{return}}function dataLayerShape(layer){if(layer.kind==="heatmap")return"heatmap";const cluster=layer.cluster;return cluster?`cluster:${cluster.radius}:${cluster.maxZoom}:${cluster.countFont?.join(",")??""}`:"auto"}function projectMapChoropleth(value){try{if(!isRuntimeRecord(value))return;const sourceIdDescriptor=getOwnDataDescriptor(value,"sourceId"),geojsonDescriptor=getOwnDataDescriptor(value,"geojson"),fieldDescriptor=getOwnDataDescriptor(value,"field"),stopsDescriptor=getOwnDataDescriptor(value,"stops"),interpolationDescriptor=getOwnDataDescriptor(value,"interpolation"),stepBaseColorDescriptor=getOwnDataDescriptor(value,"stepBaseColor");if(sourceIdDescriptor===MISSING_OWN_DATA_DESCRIPTOR||geojsonDescriptor===MISSING_OWN_DATA_DESCRIPTOR||fieldDescriptor===MISSING_OWN_DATA_DESCRIPTOR||isUnsafeDescriptor(sourceIdDescriptor)||isUnsafeDescriptor(geojsonDescriptor)||isUnsafeDescriptor(fieldDescriptor))return;const sourceId=sourceIdDescriptor.value,geojson=geojsonDescriptor.value,field=fieldDescriptor.value;if(typeof sourceId!="string"||sourceId.trim().length===0||!isRuntimeRecord(geojson)||typeof field!="string"||field.trim().length===0)return;const interpolationValue=optionalDescriptorValue(interpolationDescriptor),stepBaseColorValue=optionalDescriptorValue(stepBaseColorDescriptor),interpolation=interpolationValue==="logarithmic"||interpolationValue==="step"?interpolationValue:"linear";return Object.freeze({sourceId:sourceId.trim(),geojson,geojsonProjection:projectAdmittedGeoJson(geojson),field:field.trim(),stops:normalizedSteps(optionalDescriptorValue(stopsDescriptor),isColorOutput),interpolation,stepBaseColor:typeof stepBaseColorValue=="string"&&stepBaseColorValue.trim().length>0?stepBaseColorValue:void 0})}catch{return}}const EMPTY_CANONICAL_MAP_MARKERS=Object.freeze([]),UNPROJECTED_MAP_VALUE=Symbol("unprojected-map-value");function projectMarkerLngLat(value){try{const length=boundedOwnArrayLength(value,2);if(length===void 0||length<2)return;const lngDescriptor=getOwnDataDescriptor(value,"0"),latDescriptor=getOwnDataDescriptor(value,"1");return lngDescriptor===MISSING_OWN_DATA_DESCRIPTOR||latDescriptor===MISSING_OWN_DATA_DESCRIPTOR||isUnsafeDescriptor(lngDescriptor)||isUnsafeDescriptor(latDescriptor)||typeof lngDescriptor.value!="number"||typeof latDescriptor.value!="number"||!Number.isFinite(lngDescriptor.value)||!Number.isFinite(latDescriptor.value)||latDescriptor.value<-90||latDescriptor.value>90?void 0:Object.freeze([lngDescriptor.value,latDescriptor.value])}catch{return}}function projectMapMarker(value){try{if(!isRuntimeRecord(value))return;const idDescriptor=getOwnDataDescriptor(value,"id"),lngLatDescriptor=getOwnDataDescriptor(value,"lngLat"),colorDescriptor=getOwnDataDescriptor(value,"color"),labelDescriptor=getOwnDataDescriptor(value,"label"),unsafeHtmlDescriptor=getOwnDataDescriptor(value,"unsafeHtml");if(lngLatDescriptor===MISSING_OWN_DATA_DESCRIPTOR||isUnsafeDescriptor(idDescriptor)||isUnsafeDescriptor(lngLatDescriptor)||isUnsafeDescriptor(colorDescriptor)||isUnsafeDescriptor(labelDescriptor)||isUnsafeDescriptor(unsafeHtmlDescriptor))return;const lngLat=projectMarkerLngLat(lngLatDescriptor.value),idValue=optionalDescriptorValue(idDescriptor),labelValue=optionalDescriptorValue(labelDescriptor);if(!lngLat||idValue!==void 0&&typeof idValue!="string"||typeof idValue=="string"&&idValue.trim().length===0||labelValue!==void 0&&typeof labelValue!="string")return;const colorValue=optionalDescriptorValue(colorDescriptor);return Object.freeze({id:typeof idValue=="string"?idValue.trim():void 0,lngLat,color:typeof colorValue=="string"?colorValue:void 0,label:typeof labelValue=="string"?labelValue:void 0,unsafeHtml:optionalDescriptorValue(unsafeHtmlDescriptor)})}catch{return}}function projectMapMarkers(value){try{const scanCount=boundedOwnArrayLength(value,MAX_MAP_MARKERS);if(scanCount===void 0)return EMPTY_CANONICAL_MAP_MARKERS;const output=[],explicitIds=new Set;for(let index=0;index<scanCount;index+=1){const descriptor=getOwnDataDescriptor(value,String(index));if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||isUnsafeDescriptor(descriptor))continue;const marker=projectMapMarker(descriptor.value);!marker||marker.id!==void 0&&explicitIds.has(marker.id)||(marker.id!==void 0&&explicitIds.add(marker.id),output.push(marker))}return output.length?Object.freeze(output):EMPTY_CANONICAL_MAP_MARKERS}catch{return EMPTY_CANONICAL_MAP_MARKERS}}function setPopupContent(popup,marker){const options=popup.options,focus=options?.focusAfterOpen;return options&&(options.focusAfterOpen=!1),marker.unsafeHtml?popup.setHTML(marker.unsafeHtml):popup.setText(marker.label),options&&(options.focusAfterOpen=focus),popup}const FIT_EVENT_KEY="lyraMapFit";function snapshotCenter(center){return Array.isArray(center)?[center[0],center[1]]:center}function sameCenterValue(a,b){return Array.isArray(a)&&Array.isArray(b)?Object.is(a[0],b[0])&&Object.is(a[1],b[1]):Object.is(a,b)}function isFiniteCoordinate(value){return typeof value=="number"&&Number.isFinite(value)}function normalizeFitBounds(bounds){if(!Array.isArray(bounds)||bounds.length!==2)return;const[southWest,northEast]=bounds;if(!Array.isArray(southWest)||!Array.isArray(northEast)||southWest.length!==2||northEast.length!==2)return;const[west,south]=southWest,[east,north]=northEast;if(!(!isFiniteCoordinate(west)||!isFiniteCoordinate(south)||!isFiniteCoordinate(east)||!isFiniteCoordinate(north))&&!(west<-180||west>180||east<-180||east>west+360)&&!(south<-90||north>90||south>north))return Object.freeze([Object.freeze([west,south]),Object.freeze([west>east?east+360:east,north])])}function normalizeFitPadding(padding){const side=value=>finiteRange(typeof value=="number"?value:0,0,0);if(typeof padding=="number"){const all=side(padding);return Object.freeze({top:all,right:all,bottom:all,left:all})}const record=typeof padding=="object"&&padding!==null?padding:{};return Object.freeze({top:side(record.top),right:side(record.right),bottom:side(record.bottom),left:side(record.left)})}function wrapLongitude(longitude){if(longitude>=-180&&longitude<=180)return longitude;const wrapped=((longitude+180)%360+360)%360-180;return wrapped===-180?180:wrapped}function readPeerCamera(map){let longitude,latitude,zoom;try{({lng:longitude,lat:latitude}=map.getCenter()),zoom=map.getZoom()}catch{return}if(!(!isFiniteCoordinate(longitude)||!isFiniteCoordinate(latitude)||!isFiniteCoordinate(zoom)))return{center:[wrapLongitude(longitude),finiteRange(latitude,0,-90,90)],zoom}}const FALLBACK_FILL_OPACITY=.75;function ownerWindow(host){return host.ownerDocument?.defaultView??null}function choroplethFillOpacity(host){const raw=ownerWindow(host)?.getComputedStyle(host).getPropertyValue("--lr-map-choropleth-fill-opacity").trim()??"",parsed=Number.parseFloat(raw);return Number.isFinite(parsed)?parsed:FALLBACK_FILL_OPACITY}const FALLBACK_HIDDEN_CATEGORY_OPACITY=.15;function hiddenCategoryOpacity(host){const raw=ownerWindow(host)?.getComputedStyle(host).getPropertyValue("--lr-map-hidden-category-opacity").trim()??"";return finiteRange(Number.parseFloat(raw),FALLBACK_HIDDEN_CATEGORY_OPACITY,0,1)}const TONE_TOKEN={accent:"--lr-color-brand",success:"--lr-color-success",warning:"--lr-color-warning",danger:"--lr-color-danger",neutral:"--lr-color-text-quiet"},ON_TONE_TOKEN={accent:"--lr-color-on-brand",success:"--lr-color-on-success",warning:"--lr-color-on-warning",danger:"--lr-color-on-danger",neutral:"--lr-color-on-neutral"},HEATMAP_RAMP_TOKENS=Object.freeze([[.25,"--lr-color-brand"],[.5,"--lr-color-success"],[.75,"--lr-color-warning"],[1,"--lr-color-danger"]]);function dataLayerColor(host,tone){const token=TONE_TOKEN[tone??"accent"];return(ownerWindow(host)?.getComputedStyle(host).getPropertyValue(token).trim()??"")||DEFAULT_CANVAS_COLOR}const BASIC_MAP_PAINT_COLOR_NAMES=new Set(["aqua","black","blue","fuchsia","gray","green","lime","maroon","navy","olive","purple","red","silver","teal","white","yellow","transparent"]);function resolvedMapPaintColor(host,color,preserveLegacy){const candidate=typeof color=="string"?color.trim():"";if(!candidate)return;if(preserveLegacy){const reference=/^var\(\s*(--[\w-]+)\s*\)$/.exec(candidate),plain=reference?ownerWindow(host)?.getComputedStyle(host).getPropertyValue(reference[1]).trim()??"":candidate,namedPeerColor=BASIC_MAP_PAINT_COLOR_NAMES.has(plain.toLowerCase());if(/^#(?:[\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i.test(plain)||(/^rgba?\([\d\s.,/]+\)$/i.test(plain)||namedPeerColor)&&typeof CSS<"u"&&CSS.supports("color",plain))return plain}const resolved=resolveCanvasColor(host,candidate,"");if(!resolved)return;if(/^rgba?\(/i.test(resolved))return resolved;const canvas=host.ownerDocument.createElement("canvas");canvas.width=1,canvas.height=1;try{const context=canvas.getContext("2d",{colorSpace:"srgb",willReadFrequently:!0});if(!context)return;let accepted=!1;for(const sentinel of["rgb(1, 2, 3)","rgb(4, 5, 6)"]){context.fillStyle=sentinel;const before=context.fillStyle;if(context.fillStyle=resolved,context.fillStyle!==before){accepted=!0;break}}if(!accepted)return;context.fillRect(0,0,1,1);const[r=0,g=0,b=0,a=0]=context.getImageData(0,0,1,1).data;return a===255?`rgb(${r}, ${g}, ${b})`:`rgba(${r}, ${g}, ${b}, ${Math.round(a/255*1e3)/1e3})`}catch{return}}function resolvedLayerColor(host,explicit,tone){return resolvedMapPaintColor(host,explicit,!0)??resolvedMapPaintColor(host,dataLayerColor(host,tone),!0)??DEFAULT_CANVAS_COLOR}function resolvedClusterCountColor(host,color){return resolvedMapPaintColor(host,color,!1)}function resolvedClusterStrokeColor(host,clusterStroke,layer){return resolvedMapPaintColor(host,clusterStroke,!0)??resolvedLayerColor(host,layer.strokeColor??layer.color,layer.tone)}function warnOnUntileableProperties(projection,sourceLabel){if(litDevWarnings())for(const feature of projection.diagnostics)for(const[key,value]of feature.properties){if(typeof value!="number"||!Number.isFinite(value)||Math.abs(value)<=Number.MAX_SAFE_INTEGER)continue;const identity=feature.id??`index ${feature.index}`;devWarnOnce(`lyra-map-untileable-property:${sourceLabel}:${key}`,`<lr-map>: feature ${String(identity)} in "${sourceLabel}" carries ${key}=${value}, which is too large to survive maplibre-gl's vector-tile encoding. Tiling happens in a worker, so the failure would reach you only as an opaque "Given varint doesn't fit into 10 bytes" error while the rest of the layer still paints. Carry a reduced figure in the feature and keep the exact value in your own data.`)}}class LyraMap extends LyraElement{static{this.defaultStrings={...super.defaultStrings,close:LYRA_DEFAULT_close,items:LYRA_DEFAULT_items,legendTypeHidden:LYRA_DEFAULT_legendTypeHidden,legendTypeShown:LYRA_DEFAULT_legendTypeShown,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,mapFeedback:LYRA_DEFAULT_mapFeedback,mapInitializationFailed:LYRA_DEFAULT_mapInitializationFailed,mapLegend:LYRA_DEFAULT_mapLegend,mapMarker:LYRA_DEFAULT_mapMarker,mapMissingLibrary:LYRA_DEFAULT_mapMissingLibrary,mapResetNorth:LYRA_DEFAULT_mapResetNorth,mapStyleRequired:LYRA_DEFAULT_mapStyleRequired,mapToggleAttribution:LYRA_DEFAULT_mapToggleAttribution,mapWebglUnavailable:LYRA_DEFAULT_mapWebglUnavailable,paginationSummary:LYRA_DEFAULT_paginationSummary,zoomIn:LYRA_DEFAULT_zoomIn,zoomOut:LYRA_DEFAULT_zoomOut}}static{this.collectionSupport=collectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-map-click","lr-map-legend-panel-toggle-request","lr-map-legend-toggle-request","lr-map-marker-activate","lr-map-view-change"])}static{this.identityEventDetailProperties=Object.freeze({"lr-map-click":Object.freeze(["feature"]),"lr-map-marker-activate":Object.freeze(["marker"])})}static{this.ownedCollectionProperties=Object.freeze(["center","mapStyle","choropleth","markers","dataLayers"])}static{this.identityCollectionProperties=Object.freeze(["markers","dataLayers"])}static{this.identityCollectionObjectProperties=Object.freeze(["choropleth"])}static{this.styles=[LyraElement.styles,styles,srOnly]}static preload(engine="modular"){return(engine==="maplibre"?loadMaplibre():loadModularMap()).then(module=>module!==null)}constructor(){super(),this.hostDescription=new HostDescriptionController(this,()=>this._map?.getCanvas?.()??null),this._center=Object.freeze([0,0]),this.zoom=2,this.fitToken=Object.freeze({}),this.semanticsStale=!0,this.boxZoomSettling=!1,this.writingCamera=!1,this.maxBounds=null,this._legend=EMPTY_MAP_LEGEND,this._legendProjection=EMPTY_MAP_LEGEND_PROJECTION,this._legendGrouped=!1,this.hasLegendSlot=!1,this.hasLegendStartSlot=!1,this._legendGradient=Object.freeze([]),this.legendIsLine=!1,this.legendGradientLoLabel=null,this.legendGradientHiLabel=null,this.legendInteractive=!1,this._legendControlRole="button",this.legendCollapsible=!1,this.legendOpen=!0,this._hiddenCategories=EMPTY_HIDDEN_CATEGORIES,this.markers=[],this.dataLayers=[],this._canonicalChoroplethSource=UNPROJECTED_MAP_VALUE,this._canonicalDataLayersSource=UNPROJECTED_MAP_VALUE,this._canonicalDataLayers=EMPTY_CANONICAL_MAP_DATA_LAYERS,this._canonicalMarkersSource=UNPROJECTED_MAP_VALUE,this._canonicalMarkers=EMPTY_CANONICAL_MAP_MARKERS,this.engine="modular",this.loading=!0,this.announcements=new AnnouncementSinkController(this,{eager:["assertive"]}),this.loadLibrary=engine=>engine==="maplibre"?loadMaplibre():loadModularMap(),this.visible=ownerWindow(this)?.IntersectionObserver===void 0,this._styleLoaded=!1,this._appliedDataLayerIds=new Map,this._appliedDataLayerShapes=new Map,this._appliedGeoJson=new Map,this._nextDataLayerId=0,this.nextPointIconId=0,this.appliedPointPaint=new Set,this.appliedPointMuting=new Set,this.appliedPointIcons=new Map,this._webglReady=!1,this._markerInstances=new Map,this._markerLabels=new Map,this._markerPopupIds=new Map,this.markerActivationDetails=new WeakMap,this._configuredPopups=new WeakSet,this._nextPopupId=0,this._markerColors=new Map,this._markerSources=new Map,this._connectGeneration=0,this._styleGeneration=0,this.featureGeneration=0,this.preparingFeatures=!1,this.pendingMapLoad=!1,this.rebuildGeneratedLayers=!1,this.configuredMarkerElements=new WeakSet,this.onLegendSlotChange=event=>{const slot=event.target,filled=slot.assignedNodes({flatten:!0}).some(node=>node.nodeType===Node.ELEMENT_NODE||(node.textContent??"").trim().length>0);slot.name==="legend-start"?this.hasLegendStartSlot=filled:this.hasLegendSlot=filled},new ThemeWatcher(this,()=>{this.refreshThemePaint(),this.legendIsLine=this.legendDescribesLine(),this.applyMarkers()}),new GlassScrollLayer(this,'[part="legend"]')}get center(){return this._center}set center(value){this._center=value}get legend(){return this._legend}set legend(value){if(value===this._legendSource||value===this._legend)return;this._legendSource=value;const previous=this._legend,normalized=normalizeMapLegend(value);this._legend=normalized.entries,this._legendProjection=normalized.projection,this._legendGrouped=normalized.grouped,this.requestUpdate("legend",previous)}probeLegendSlot(name){for(const child of Array.from(this.children))if(child.getAttribute("slot")===name)return!0;return!1}get legendGradient(){return this._legendGradient}set legendGradient(value){if(value===this._legendGradientSource||value===this._legendGradient)return;this._legendGradientSource=value;const previous=this._legendGradient;this._legendGradient=normalizeMapLegendGradient(value),this.requestUpdate("legendGradient",previous)}warnOnLegendChoroplethMismatch(){if(!litDevWarnings()||this.legendIsLine)return;const layer=this.canonicalChoropleth,legend=this.legendGradient;!layer||legend.length===0||layer.stops.length===0||legend.length===layer.stops.length&&legend.every(([legendValue,legendColor],index)=>{const layerStop=layer.stops[index];return layerStop!==void 0&&layerStop[0]===legendValue&&resolvedLayerColor(this,layerStop[1],void 0)===resolvedLayerColor(this,legendColor,void 0)})||devWarnOnce("lyra-map-legend-choropleth-mismatch",`<${this.localName}>: legendGradient does not match choropleth.stops, so the visible key may misdescribe the map. Assign the same stops array to both, or derive both from one source.`)}legendDescribesLine(){const stops=this.legendGradient;return stops.length<2?!1:this.canonicalDataLayers.some(layer=>layer.kind==="auto"&&!layer.cluster&&layer.line?.field&&layer.line.stops.length===stops.length&&layer.line.stops.every(([value,color],index)=>value===stops[index][0]&&resolvedLayerColor(this,color,layer.tone)===resolvedLayerColor(this,stops[index][1],layer.tone)))}get legendProjection(){return this._legendProjection}set legendProjection(_value){}get legendControlRole(){return this._legendControlRole}set legendControlRole(next){const normalized=LEGEND_CONTROL_ROLE.normalizeReflected(this,"legend-control-role",next),old=this._legendControlRole;old!==normalized&&(this._legendControlRole=normalized,this.requestUpdate("legendControlRole",old))}get legendCollapsed(){return this.legendCollapsible&&!this.legendOpen}toggleLegendPanel(){if(!this.legendCollapsible)return;const open=!this.legendOpen;this.emit("lr-map-legend-panel-toggle-request",{open},{cancelable:!0}).defaultPrevented||(this.legendOpen=open)}renderLegendDisclosure(){return this.legendCollapsible?html`<button
|
|
12
|
+
></path></svg>`}function addPartToken(element,token){const tokens=new Set((element.getAttribute("part")??"").split(/\s+/).filter(Boolean));tokens.add(token),element.setAttribute("part",[...tokens].join(" "))}const CHOROPLETH_LOG_INTERPOLATION_BASE=.25,CHOROPLETH_LEGEND_SAMPLES_PER_INTERVAL=8;function choroplethLogInterpolationFactor(input,lower,upper){const difference=upper-lower;if(difference===0)return 0;const progress=input-lower;return(Math.pow(CHOROPLETH_LOG_INTERPOLATION_BASE,progress)-1)/(Math.pow(CHOROPLETH_LOG_INTERPOLATION_BASE,difference)-1)}function compactGradientPercent(value){return String(Math.round(Math.min(100,Math.max(0,value))*1e4)/1e4)}function choroplethLegendGradientImage(stops,interpolation){const lo=stops[0],span=stops[stops.length-1][0]-lo[0],stopPercent=(value,index)=>span>0?(value-lo[0])/span*100:index/(stops.length-1)*100;if(interpolation!=="logarithmic"||span<=0)return`linear-gradient(to right, ${stops.map(([value,color],index)=>`${color} ${compactGradientPercent(stopPercent(value,index))}%`).join(", ")})`;const image=[`${lo[1]} 0%`];for(let index=1;index<stops.length;index+=1){const lower=stops[index-1],upper=stops[index],interval=upper[0]-lower[0];if(interval<=0){image.push(`${upper[1]} ${compactGradientPercent(stopPercent(upper[0],index))}%`);continue}for(let sample=1;sample<=CHOROPLETH_LEGEND_SAMPLES_PER_INTERVAL;sample+=1){const intervalProgress=sample/CHOROPLETH_LEGEND_SAMPLES_PER_INTERVAL,input=lower[0]+interval*intervalProgress,position=(input-lo[0])/span*100;if(sample===CHOROPLETH_LEGEND_SAMPLES_PER_INTERVAL){image.push(`${upper[1]} ${compactGradientPercent(position)}%`);continue}const factor=Math.min(1,Math.max(0,choroplethLogInterpolationFactor(input,lower[0],upper[0]))),lowerWeight=compactGradientPercent((1-factor)*100),upperWeight=compactGradientPercent(factor*100);image.push(`color-mix(in srgb, ${lower[1]} ${lowerWeight}%, ${upper[1]} ${upperWeight}%) ${compactGradientPercent(position)}%`)}}return`linear-gradient(to right, ${image.join(", ")})`}const MAX_MAP_MARKERS=2e3;function popupText(host,markup){const template=host.ownerDocument.createElement("template");template.innerHTML=markup;for(const hidden of template.content.querySelectorAll('script, style, template, [hidden], [aria-hidden="true"]'))hidden.remove();return(template.content.textContent??"").replace(/\s+/gu," ").trim()}function markerPopupText(host,markup){return typeof markup=="string"&&markup?popupText(host,markup):""}const MAX_MAP_DATA_LAYERS=100,EMPTY_CANONICAL_MAP_DATA_LAYERS=Object.freeze([]);function mapTone(value){switch(value){case"accent":case"success":case"warning":case"danger":case"neutral":return value;default:return}}function projectMapDataLayer(value){try{if(!isRuntimeRecord(value))return;const sourceIdDescriptor=getOwnDataDescriptor(value,"sourceId"),geojsonDescriptor=getOwnDataDescriptor(value,"geojson"),toneDescriptor=getOwnDataDescriptor(value,"tone"),colorDescriptor=getOwnDataDescriptor(value,"color"),strokeColorDescriptor=getOwnDataDescriptor(value,"strokeColor"),lineDescriptor=getOwnDataDescriptor(value,"line"),kindDescriptor=getOwnDataDescriptor(value,"kind"),heatmapDescriptor=getOwnDataDescriptor(value,"heatmap"),clusterDescriptor=getOwnDataDescriptor(value,"cluster");if(sourceIdDescriptor===MISSING_OWN_DATA_DESCRIPTOR||geojsonDescriptor===MISSING_OWN_DATA_DESCRIPTOR||isUnsafeDescriptor(sourceIdDescriptor)||isUnsafeDescriptor(geojsonDescriptor))return;const sourceId=sourceIdDescriptor.value,geojson=geojsonDescriptor.value;if(typeof sourceId!="string"||sourceId.trim().length===0||!isRuntimeRecord(geojson))return;const tone=mapTone(optionalDescriptorValue(toneDescriptor)),colorValue=optionalDescriptorValue(colorDescriptor),strokeColorValue=optionalDescriptorValue(strokeColorDescriptor),kindValue=optionalDescriptorValue(kindDescriptor),heatmapValue=optionalDescriptorValue(heatmapDescriptor),clusterValue=optionalDescriptorValue(clusterDescriptor),kind=kindValue==="heatmap"?"heatmap":"auto";return Object.freeze({sourceId:sourceId.trim(),geojson,geojsonProjection:projectAdmittedGeoJson(geojson),tone,color:typeof colorValue=="string"?colorValue:void 0,strokeColor:typeof strokeColorValue=="string"?strokeColorValue:void 0,line:kind==="auto"?projectLineOptions(optionalDescriptorValue(lineDescriptor)):void 0,point:kind==="auto"?projectPointOptions(optionalDescriptorValue(getOwnDataDescriptor(value,"point"))):void 0,kind,heatmap:kind==="heatmap"?projectHeatmapOptions(heatmapValue):void 0,cluster:kind==="auto"?normalizedClusterOptions(clusterValue):void 0})}catch{return}}function projectMapDataLayers(value){try{const scanCount=boundedOwnArrayLength(value,MAX_MAP_DATA_LAYERS);if(scanCount===void 0)return EMPTY_CANONICAL_MAP_DATA_LAYERS;const output=[],seenSourceIds=new Set;for(let index=0;index<scanCount;index+=1){const descriptor=getOwnDataDescriptor(value,String(index));if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||isUnsafeDescriptor(descriptor))continue;const layer=projectMapDataLayer(descriptor.value);!layer||seenSourceIds.has(layer.sourceId)||(seenSourceIds.add(layer.sourceId),output.push(layer))}return output.length?Object.freeze(output):EMPTY_CANONICAL_MAP_DATA_LAYERS}catch{return EMPTY_CANONICAL_MAP_DATA_LAYERS}}const DATA_LAYER_SUFFIXES=["-fill","-line","-circle","-point-icon","-cluster","-cluster-count","-heatmap"],QUERYABLE_DATA_LAYER_SUFFIXES=["-fill","-line","-circle","-cluster","-point-icon"],MAX_MAP_STEP_STOPS=32;function normalizedSteps(value,isOutput,clampThreshold=threshold=>threshold){try{const scanCount=boundedOwnArrayLength(value,MAX_MAP_STEP_STOPS);if(scanCount===void 0)return Object.freeze([]);const usable=[];for(let index=0;index<scanCount;index+=1){const stopDescriptor=getOwnDataDescriptor(value,String(index));if(stopDescriptor===MISSING_OWN_DATA_DESCRIPTOR||isUnsafeDescriptor(stopDescriptor))continue;const stop=stopDescriptor.value,stopLength=boundedOwnArrayLength(stop,2);if(stopLength===void 0||stopLength<2)continue;const thresholdDescriptor=getOwnDataDescriptor(stop,"0"),outputDescriptor=getOwnDataDescriptor(stop,"1");thresholdDescriptor===MISSING_OWN_DATA_DESCRIPTOR||outputDescriptor===MISSING_OWN_DATA_DESCRIPTOR||isUnsafeDescriptor(thresholdDescriptor)||isUnsafeDescriptor(outputDescriptor)||typeof thresholdDescriptor.value!="number"||!Number.isFinite(thresholdDescriptor.value)||!isOutput(outputDescriptor.value)||usable.push([clampThreshold(thresholdDescriptor.value),outputDescriptor.value])}usable.sort((a,b)=>a[0]-b[0]);const deduplicated=usable.filter((stop,index)=>index===0||stop[0]>usable[index-1][0]);return Object.freeze(deduplicated.map(stop=>Object.freeze(stop)))}catch{return Object.freeze([])}}const isFiniteOutput=candidate=>typeof candidate=="number"&&Number.isFinite(candidate),isColorOutput=candidate=>typeof candidate=="string"&&candidate.trim().length>0,DEFAULT_CLUSTER_RADIUS=50,DEFAULT_CLUSTER_MAX_ZOOM=14,DEFAULT_CLUSTER_RADIUS_STEPS=Object.freeze([[0,14],[10,18],[50,24]]),DEFAULT_HEATMAP_RADIUS=30,DEFAULT_HEATMAP_INTENSITY=1,MAX_CLUSTER_COUNT_FONTS=8;function normalizedClusterOptions(value){try{if(!isRuntimeRecord(value))return;const radiusDescriptor=getOwnDataDescriptor(value,"radius"),maxZoomDescriptor=getOwnDataDescriptor(value,"maxZoom"),radiusStepsDescriptor=getOwnDataDescriptor(value,"radiusSteps"),colorStepsDescriptor=getOwnDataDescriptor(value,"colorSteps"),strokeColorDescriptor=getOwnDataDescriptor(value,"strokeColor"),countFontDescriptor=getOwnDataDescriptor(value,"countFont"),countColorDescriptor=getOwnDataDescriptor(value,"countColor"),countHaloColorDescriptor=getOwnDataDescriptor(value,"countHaloColor"),countHaloWidthDescriptor=getOwnDataDescriptor(value,"countHaloWidth"),radiusValue=optionalDescriptorValue(radiusDescriptor),maxZoomValue=optionalDescriptorValue(maxZoomDescriptor),radiusSteps=normalizedSteps(optionalDescriptorValue(radiusStepsDescriptor),isFiniteOutput),colorSteps=normalizedSteps(optionalDescriptorValue(colorStepsDescriptor),isColorOutput),fonts=normalizedClusterFonts(optionalDescriptorValue(countFontDescriptor)),countHaloWidthValue=optionalDescriptorValue(countHaloWidthDescriptor);return Object.freeze({radius:finiteRange(typeof radiusValue=="number"?radiusValue:Number.NaN,DEFAULT_CLUSTER_RADIUS,1,1e3),maxZoom:finiteRange(typeof maxZoomValue=="number"?maxZoomValue:Number.NaN,DEFAULT_CLUSTER_MAX_ZOOM,0,24),radiusSteps:radiusSteps.length?radiusSteps:DEFAULT_CLUSTER_RADIUS_STEPS,colorSteps,strokeColor:sanitizeCssColor(optionalDescriptorValue(strokeColorDescriptor)),countFont:fonts.length?fonts:void 0,countColor:sanitizeCssColor(optionalDescriptorValue(countColorDescriptor)),countHaloColor:sanitizeCssColor(optionalDescriptorValue(countHaloColorDescriptor)),countHaloWidth:countHaloWidthValue===void 0?1:finiteRange(typeof countHaloWidthValue=="number"?countHaloWidthValue:Number.NaN,1,0,3)})}catch{return}}function normalizedClusterFonts(value){try{const length=boundedOwnArrayLength(value,MAX_CLUSTER_COUNT_FONTS);if(length===void 0)return Object.freeze([]);const fonts=[];for(let index=0;index<length;index+=1){const descriptor=getOwnDataDescriptor(value,String(index));descriptor===MISSING_OWN_DATA_DESCRIPTOR||isUnsafeDescriptor(descriptor)||typeof descriptor.value!="string"||descriptor.value.trim().length===0||fonts.push(descriptor.value)}return Object.freeze(fonts)}catch{return Object.freeze([])}}const DEFAULT_ICON_VIEW_BOX=Object.freeze([0,0,24,24]),DEFAULT_ICON_STROKE_WIDTH=2,ICON_PATH_GRAMMAR=/^[MmLlHhVvCcSsQqTtAaZz\d.eE+,\s-]+$/u,MAX_ICON_PATH_LENGTH=8192;function projectIconPaint(row){const path=optionalDescriptorValue(getOwnDataDescriptor(row,"path"));if(typeof path!="string"||path.length===0||path.length>MAX_ICON_PATH_LENGTH||!ICON_PATH_GRAMMAR.test(path))return;const rawBox=optionalDescriptorValue(getOwnDataDescriptor(row,"viewBox")),box=[];if(rawBox===void 0)box.push(...DEFAULT_ICON_VIEW_BOX);else{if(boundedOwnArrayLength(rawBox,4)!==4)return;for(let index=0;index<4;index++){const coordinate=optionalDescriptorValue(getOwnDataDescriptor(rawBox,String(index)));if(typeof coordinate!="number"||!Number.isFinite(coordinate)||Math.abs(coordinate)>1e4)return;box.push(coordinate)}if(box[2]<.001||box[3]<.001)return}const mode=optionalDescriptorValue(getOwnDataDescriptor(row,"mode")),strokeWidth=optionalDescriptorValue(getOwnDataDescriptor(row,"strokeWidth")),lineCap=optionalDescriptorValue(getOwnDataDescriptor(row,"lineCap")),lineJoin=optionalDescriptorValue(getOwnDataDescriptor(row,"lineJoin"));return Object.freeze({path,viewBox:Object.freeze(box),mode:mode==="stroke"||mode==="fill-stroke"?mode:"fill",strokeWidth:finiteRange(typeof strokeWidth=="number"?strokeWidth:NaN,DEFAULT_ICON_STROKE_WIDTH,0,200),lineCap:lineCap==="butt"||lineCap==="square"?lineCap:"round",lineJoin:lineJoin==="miter"||lineJoin==="bevel"?lineJoin:"round"})}function projectPointRadius(value){if(!isRuntimeRecord(value))return finiteRange(typeof value=="number"?value:NaN,5,0,200);const read=key=>optionalDescriptorValue(getOwnDataDescriptor(value,key)),field=read("field"),rawFallback=read("fallback"),fallback=finiteRange(typeof rawFallback=="number"?rawFallback:NaN,5,0,200),stops=normalizedSteps(read("stops"),isFiniteOutput).map(([threshold,radius])=>Object.freeze([threshold,finiteRange(radius,5,0,200)]));return typeof field!="string"||!field.trim()||!stops.length?fallback:Object.freeze({field:field.trim(),stops:Object.freeze(stops),fallback,interpolation:read("interpolation")==="linear"?"linear":"step"})}function projectPointOptions(value){if(!isRuntimeRecord(value))return;const read=key=>optionalDescriptorValue(getOwnDataDescriptor(value,key)),string=key=>{const candidate=read(key);return typeof candidate=="string"&&candidate.trim()?candidate:void 0},number=(key,fallback,min,max)=>{const candidate=read(key);return finiteRange(typeof candidate=="number"?candidate:NaN,fallback,min,max)},colors=[],icons=[],project=(input,accept)=>{const length=boundedOwnArrayLength(input,MAX_MAP_STEP_STOPS)??0;for(let index=0;index<length;index++){const row=optionalDescriptorValue(getOwnDataDescriptor(input,String(index)));row!==null&&typeof row=="object"&&accept(row)}};return project(read("colors"),row=>{const key=optionalDescriptorValue(getOwnDataDescriptor(row,"0")),color=optionalDescriptorValue(getOwnDataDescriptor(row,"1"));typeof key!="string"||typeof color!="string"||!sanitizeCssColor(color)||colors.some(([existing])=>existing===key)||colors.push(Object.freeze([key,color]))}),project(read("icons"),row=>{const key=optionalDescriptorValue(getOwnDataDescriptor(row,"value"));if(typeof key!="string"||icons.some(icon=>icon.value===key))return;const paint=projectIconPaint(row);paint&&icons.push(Object.freeze({value:key,...paint}))}),Object.freeze({field:string("field"),colors:Object.freeze(colors),radius:projectPointRadius(read("radius")),strokeWidth:number("strokeWidth",0,0,200),strokeColor:string("strokeColor"),iconField:string("iconField")??string("field"),icons:Object.freeze(icons),iconColor:string("iconColor"),iconSize:number("iconSize",16,1,200)})}const POINT_ICON_RASTER_SIZE=64;function rasterPointIcon(host,icon,color){try{const canvas=host.ownerDocument.createElement("canvas");canvas.width=canvas.height=POINT_ICON_RASTER_SIZE;const context=canvas.getContext("2d"),Path=host.ownerDocument.defaultView?.Path2D;if(!context||!Path)return;const[x,y,width,height]=icon.viewBox,scale=POINT_ICON_RASTER_SIZE/Math.max(width,height);context.translate((POINT_ICON_RASTER_SIZE-width*scale)/2,(POINT_ICON_RASTER_SIZE-height*scale)/2),context.scale(scale,scale),context.translate(-x,-y);const path=new Path(icon.path);return icon.mode!=="stroke"&&(context.fillStyle=color,context.fill(path)),icon.mode!=="fill"&&icon.strokeWidth>0&&(context.strokeStyle=color,context.lineWidth=icon.strokeWidth,context.lineCap=icon.lineCap,context.lineJoin=icon.lineJoin,context.stroke(path)),context.getImageData(0,0,POINT_ICON_RASTER_SIZE,POINT_ICON_RASTER_SIZE)}catch{return}}function projectLineOptions(value){try{if(!isRuntimeRecord(value))return;const field=optionalDescriptorValue(getOwnDataDescriptor(value,"field")),width=optionalDescriptorValue(getOwnDataDescriptor(value,"width")),opacity=optionalDescriptorValue(getOwnDataDescriptor(value,"opacity"));return Object.freeze({field:typeof field=="string"&&field.trim()?field.trim():void 0,stops:Object.freeze(normalizeMapLegendGradient(optionalDescriptorValue(getOwnDataDescriptor(value,"stops"))).filter((stop,index,stops)=>index===0||stop[0]>stops[index-1][0]).map(stop=>Object.freeze(stop))),width:typeof width=="number"?finiteRange(width,2,0,200):2,opacity:typeof opacity=="number"?finiteRange(opacity,1,0,1):1})}catch{return}}function projectedHeatmapRange(value){try{const length=boundedOwnArrayLength(value,2);if(length===void 0||length<2)return;const minDescriptor=getOwnDataDescriptor(value,"0"),maxDescriptor=getOwnDataDescriptor(value,"1");return minDescriptor===MISSING_OWN_DATA_DESCRIPTOR||maxDescriptor===MISSING_OWN_DATA_DESCRIPTOR||isUnsafeDescriptor(minDescriptor)||isUnsafeDescriptor(maxDescriptor)||typeof minDescriptor.value!="number"||typeof maxDescriptor.value!="number"||!Number.isFinite(minDescriptor.value)||!Number.isFinite(maxDescriptor.value)?void 0:Object.freeze([minDescriptor.value,maxDescriptor.value])}catch{return}}function projectedHeatmapZoomValue(value){if(typeof value=="number"&&Number.isFinite(value))return value;if(isRuntimeArray(value))return normalizedSteps(value,isFiniteOutput,zoom=>finiteRange(zoom,0,0,24))}function projectHeatmapOptions(value){try{if(!isRuntimeRecord(value))return;const weightFieldDescriptor=getOwnDataDescriptor(value,"weightField"),weightRangeDescriptor=getOwnDataDescriptor(value,"weightRange"),stopsDescriptor=getOwnDataDescriptor(value,"stops"),radiusDescriptor=getOwnDataDescriptor(value,"radius"),intensityDescriptor=getOwnDataDescriptor(value,"intensity"),opacityDescriptor=getOwnDataDescriptor(value,"opacity"),weightFieldValue=optionalDescriptorValue(weightFieldDescriptor),opacityValue=optionalDescriptorValue(opacityDescriptor);return Object.freeze({weightField:typeof weightFieldValue=="string"&&weightFieldValue.trim().length>0?weightFieldValue.trim():void 0,weightRange:projectedHeatmapRange(optionalDescriptorValue(weightRangeDescriptor)),stops:normalizedSteps(optionalDescriptorValue(stopsDescriptor),isColorOutput,density=>finiteRange(density,0,0,1)),radius:projectedHeatmapZoomValue(optionalDescriptorValue(radiusDescriptor)),intensity:projectedHeatmapZoomValue(optionalDescriptorValue(intensityDescriptor)),opacity:typeof opacityValue=="number"&&Number.isFinite(opacityValue)?opacityValue:void 0})}catch{return}}function dataLayerShape(layer){if(layer.kind==="heatmap")return"heatmap";const cluster=layer.cluster;return cluster?`cluster:${cluster.radius}:${cluster.maxZoom}:${cluster.countFont?.join(",")??""}`:"auto"}function projectMapChoropleth(value){try{if(!isRuntimeRecord(value))return;const sourceIdDescriptor=getOwnDataDescriptor(value,"sourceId"),geojsonDescriptor=getOwnDataDescriptor(value,"geojson"),fieldDescriptor=getOwnDataDescriptor(value,"field"),stopsDescriptor=getOwnDataDescriptor(value,"stops"),interpolationDescriptor=getOwnDataDescriptor(value,"interpolation"),stepBaseColorDescriptor=getOwnDataDescriptor(value,"stepBaseColor");if(sourceIdDescriptor===MISSING_OWN_DATA_DESCRIPTOR||geojsonDescriptor===MISSING_OWN_DATA_DESCRIPTOR||fieldDescriptor===MISSING_OWN_DATA_DESCRIPTOR||isUnsafeDescriptor(sourceIdDescriptor)||isUnsafeDescriptor(geojsonDescriptor)||isUnsafeDescriptor(fieldDescriptor))return;const sourceId=sourceIdDescriptor.value,geojson=geojsonDescriptor.value,field=fieldDescriptor.value;if(typeof sourceId!="string"||sourceId.trim().length===0||!isRuntimeRecord(geojson)||typeof field!="string"||field.trim().length===0)return;const interpolationValue=optionalDescriptorValue(interpolationDescriptor),stepBaseColorValue=optionalDescriptorValue(stepBaseColorDescriptor),interpolation=interpolationValue==="logarithmic"||interpolationValue==="step"?interpolationValue:"linear";return Object.freeze({sourceId:sourceId.trim(),geojson,geojsonProjection:projectAdmittedGeoJson(geojson),field:field.trim(),stops:normalizedSteps(optionalDescriptorValue(stopsDescriptor),isColorOutput),interpolation,stepBaseColor:typeof stepBaseColorValue=="string"&&stepBaseColorValue.trim().length>0?stepBaseColorValue:void 0})}catch{return}}const EMPTY_CANONICAL_MAP_MARKERS=Object.freeze([]),UNPROJECTED_MAP_VALUE=Symbol("unprojected-map-value");function projectMarkerLngLat(value){try{const length=boundedOwnArrayLength(value,2);if(length===void 0||length<2)return;const lngDescriptor=getOwnDataDescriptor(value,"0"),latDescriptor=getOwnDataDescriptor(value,"1");return lngDescriptor===MISSING_OWN_DATA_DESCRIPTOR||latDescriptor===MISSING_OWN_DATA_DESCRIPTOR||isUnsafeDescriptor(lngDescriptor)||isUnsafeDescriptor(latDescriptor)||typeof lngDescriptor.value!="number"||typeof latDescriptor.value!="number"||!Number.isFinite(lngDescriptor.value)||!Number.isFinite(latDescriptor.value)||latDescriptor.value<-90||latDescriptor.value>90?void 0:Object.freeze([lngDescriptor.value,latDescriptor.value])}catch{return}}function projectMapMarker(value){try{if(!isRuntimeRecord(value))return;const idDescriptor=getOwnDataDescriptor(value,"id"),lngLatDescriptor=getOwnDataDescriptor(value,"lngLat"),colorDescriptor=getOwnDataDescriptor(value,"color"),labelDescriptor=getOwnDataDescriptor(value,"label"),unsafeHtmlDescriptor=getOwnDataDescriptor(value,"unsafeHtml");if(lngLatDescriptor===MISSING_OWN_DATA_DESCRIPTOR||isUnsafeDescriptor(idDescriptor)||isUnsafeDescriptor(lngLatDescriptor)||isUnsafeDescriptor(colorDescriptor)||isUnsafeDescriptor(labelDescriptor)||isUnsafeDescriptor(unsafeHtmlDescriptor))return;const lngLat=projectMarkerLngLat(lngLatDescriptor.value),idValue=optionalDescriptorValue(idDescriptor),labelValue=optionalDescriptorValue(labelDescriptor);if(!lngLat||idValue!==void 0&&typeof idValue!="string"||typeof idValue=="string"&&idValue.trim().length===0||labelValue!==void 0&&typeof labelValue!="string")return;const colorValue=optionalDescriptorValue(colorDescriptor);return Object.freeze({id:typeof idValue=="string"?idValue.trim():void 0,lngLat,color:typeof colorValue=="string"?colorValue:void 0,label:typeof labelValue=="string"?labelValue:void 0,unsafeHtml:optionalDescriptorValue(unsafeHtmlDescriptor)})}catch{return}}function projectMapMarkers(value){try{const scanCount=boundedOwnArrayLength(value,MAX_MAP_MARKERS);if(scanCount===void 0)return EMPTY_CANONICAL_MAP_MARKERS;const output=[],explicitIds=new Set;for(let index=0;index<scanCount;index+=1){const descriptor=getOwnDataDescriptor(value,String(index));if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||isUnsafeDescriptor(descriptor))continue;const marker=projectMapMarker(descriptor.value);!marker||marker.id!==void 0&&explicitIds.has(marker.id)||(marker.id!==void 0&&explicitIds.add(marker.id),output.push(marker))}return output.length?Object.freeze(output):EMPTY_CANONICAL_MAP_MARKERS}catch{return EMPTY_CANONICAL_MAP_MARKERS}}function setPopupContent(popup,marker){const options=popup.options,focus=options?.focusAfterOpen;return options&&(options.focusAfterOpen=!1),marker.unsafeHtml?popup.setHTML(marker.unsafeHtml):popup.setText(marker.label),options&&(options.focusAfterOpen=focus),popup}const FIT_EVENT_KEY="lyraMapFit";function snapshotCenter(center){return Array.isArray(center)?[center[0],center[1]]:center}function sameCenterValue(a,b){return Array.isArray(a)&&Array.isArray(b)?Object.is(a[0],b[0])&&Object.is(a[1],b[1]):Object.is(a,b)}function isFiniteCoordinate(value){return typeof value=="number"&&Number.isFinite(value)}function normalizeFitBounds(bounds){if(!Array.isArray(bounds)||bounds.length!==2)return;const[southWest,northEast]=bounds;if(!Array.isArray(southWest)||!Array.isArray(northEast)||southWest.length!==2||northEast.length!==2)return;const[west,south]=southWest,[east,north]=northEast;if(!(!isFiniteCoordinate(west)||!isFiniteCoordinate(south)||!isFiniteCoordinate(east)||!isFiniteCoordinate(north))&&!(west<-180||west>180||east<-180||east>west+360)&&!(south<-90||north>90||south>north))return Object.freeze([Object.freeze([west,south]),Object.freeze([west>east?east+360:east,north])])}function normalizeFitPadding(padding){const side=value=>finiteRange(typeof value=="number"?value:0,0,0);if(typeof padding=="number"){const all=side(padding);return Object.freeze({top:all,right:all,bottom:all,left:all})}const record=typeof padding=="object"&&padding!==null?padding:{};return Object.freeze({top:side(record.top),right:side(record.right),bottom:side(record.bottom),left:side(record.left)})}function wrapLongitude(longitude){if(longitude>=-180&&longitude<=180)return longitude;const wrapped=((longitude+180)%360+360)%360-180;return wrapped===-180?180:wrapped}function readPeerCamera(map){let longitude,latitude,zoom;try{({lng:longitude,lat:latitude}=map.getCenter()),zoom=map.getZoom()}catch{return}if(!(!isFiniteCoordinate(longitude)||!isFiniteCoordinate(latitude)||!isFiniteCoordinate(zoom)))return{center:[wrapLongitude(longitude),finiteRange(latitude,0,-90,90)],zoom}}const FALLBACK_FILL_OPACITY=.75;function ownerWindow(host){return host.ownerDocument?.defaultView??null}function choroplethFillOpacity(host){const raw=ownerWindow(host)?.getComputedStyle(host).getPropertyValue("--lr-map-choropleth-fill-opacity").trim()??"",parsed=Number.parseFloat(raw);return Number.isFinite(parsed)?parsed:FALLBACK_FILL_OPACITY}const FALLBACK_HIDDEN_CATEGORY_OPACITY=.15;function hiddenCategoryOpacity(host){const raw=ownerWindow(host)?.getComputedStyle(host).getPropertyValue("--lr-map-hidden-category-opacity").trim()??"";return finiteRange(Number.parseFloat(raw),FALLBACK_HIDDEN_CATEGORY_OPACITY,0,1)}const TONE_TOKEN={accent:"--lr-color-brand",success:"--lr-color-success",warning:"--lr-color-warning",danger:"--lr-color-danger",neutral:"--lr-color-text-quiet"},ON_TONE_TOKEN={accent:"--lr-color-on-brand",success:"--lr-color-on-success",warning:"--lr-color-on-warning",danger:"--lr-color-on-danger",neutral:"--lr-color-on-neutral"},HEATMAP_RAMP_TOKENS=Object.freeze([[.25,"--lr-color-brand"],[.5,"--lr-color-success"],[.75,"--lr-color-warning"],[1,"--lr-color-danger"]]);function dataLayerColor(host,tone){const token=TONE_TOKEN[tone??"accent"];return(ownerWindow(host)?.getComputedStyle(host).getPropertyValue(token).trim()??"")||DEFAULT_CANVAS_COLOR}const BASIC_MAP_PAINT_COLOR_NAMES=new Set(["aqua","black","blue","fuchsia","gray","green","lime","maroon","navy","olive","purple","red","silver","teal","white","yellow","transparent"]),paintColorCache=new WeakMap;function resolvedMapPaintColor(host,color,preserveLegacy){let cache=paintColorCache.get(host);cache||paintColorCache.set(host,cache=new Map);const key=`${preserveLegacy}:${color??""}`;if(cache.has(key))return cache.get(key);const result=resolveMapPaintColor(host,color,preserveLegacy);return cache.size>=512&&cache.clear(),cache.set(key,result),result}function resolveMapPaintColor(host,color,preserveLegacy){const candidate=typeof color=="string"?color.trim():"";if(!candidate)return;if(preserveLegacy){const reference=/^var\(\s*(--[\w-]+)\s*\)$/.exec(candidate),plain=reference?ownerWindow(host)?.getComputedStyle(host).getPropertyValue(reference[1]).trim()??"":candidate,namedPeerColor=BASIC_MAP_PAINT_COLOR_NAMES.has(plain.toLowerCase());if(/^#(?:[\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i.test(plain)||(/^rgba?\([\d\s.,/]+\)$/i.test(plain)||namedPeerColor)&&typeof CSS<"u"&&CSS.supports("color",plain))return plain}const resolved=resolveCanvasColor(host,candidate,"");if(!resolved)return;if(/^rgba?\(/i.test(resolved))return resolved;const canvas=host.ownerDocument.createElement("canvas");canvas.width=1,canvas.height=1;try{const context=canvas.getContext("2d",{colorSpace:"srgb",willReadFrequently:!0});if(!context)return;let accepted=!1;for(const sentinel of["rgb(1, 2, 3)","rgb(4, 5, 6)"]){context.fillStyle=sentinel;const before=context.fillStyle;if(context.fillStyle=resolved,context.fillStyle!==before){accepted=!0;break}}if(!accepted)return;context.fillRect(0,0,1,1);const[r=0,g=0,b=0,a=0]=context.getImageData(0,0,1,1).data;return a===255?`rgb(${r}, ${g}, ${b})`:`rgba(${r}, ${g}, ${b}, ${Math.round(a/255*1e3)/1e3})`}catch{return}}function resolvedLayerColor(host,explicit,tone){return resolvedMapPaintColor(host,explicit,!0)??resolvedMapPaintColor(host,dataLayerColor(host,tone),!0)??DEFAULT_CANVAS_COLOR}function resolvedClusterCountColor(host,color){return resolvedMapPaintColor(host,color,!1)}function resolvedClusterStrokeColor(host,clusterStroke,layer){return resolvedMapPaintColor(host,clusterStroke,!0)??resolvedLayerColor(host,layer.strokeColor??layer.color,layer.tone)}function warnOnUntileableProperties(projection,sourceLabel){if(litDevWarnings())for(const feature of projection.diagnostics)for(const[key,value]of feature.properties){if(typeof value!="number"||!Number.isFinite(value)||Math.abs(value)<=Number.MAX_SAFE_INTEGER)continue;const identity=feature.id??`index ${feature.index}`;devWarnOnce(`lyra-map-untileable-property:${sourceLabel}:${key}`,`<lr-map>: feature ${String(identity)} in "${sourceLabel}" carries ${key}=${value}, which is too large to survive maplibre-gl's vector-tile encoding. Tiling happens in a worker, so the failure would reach you only as an opaque "Given varint doesn't fit into 10 bytes" error while the rest of the layer still paints. Carry a reduced figure in the feature and keep the exact value in your own data.`)}}class LyraMap extends LyraElement{static{this.defaultStrings={...super.defaultStrings,close:LYRA_DEFAULT_close,items:LYRA_DEFAULT_items,legendTypeHidden:LYRA_DEFAULT_legendTypeHidden,legendTypeShown:LYRA_DEFAULT_legendTypeShown,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,mapFeedback:LYRA_DEFAULT_mapFeedback,mapInitializationFailed:LYRA_DEFAULT_mapInitializationFailed,mapLegend:LYRA_DEFAULT_mapLegend,mapMarker:LYRA_DEFAULT_mapMarker,mapMissingLibrary:LYRA_DEFAULT_mapMissingLibrary,mapResetNorth:LYRA_DEFAULT_mapResetNorth,mapStyleRequired:LYRA_DEFAULT_mapStyleRequired,mapToggleAttribution:LYRA_DEFAULT_mapToggleAttribution,mapWebglUnavailable:LYRA_DEFAULT_mapWebglUnavailable,paginationSummary:LYRA_DEFAULT_paginationSummary,zoomIn:LYRA_DEFAULT_zoomIn,zoomOut:LYRA_DEFAULT_zoomOut}}static{this.collectionSupport=collectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-map-click","lr-map-legend-panel-toggle-request","lr-map-legend-toggle-request","lr-map-marker-activate","lr-map-view-change"])}static{this.identityEventDetailProperties=Object.freeze({"lr-map-click":Object.freeze(["feature"]),"lr-map-marker-activate":Object.freeze(["marker"])})}static{this.ownedCollectionProperties=Object.freeze(["center","mapStyle","choropleth","markers","dataLayers"])}static{this.identityCollectionProperties=Object.freeze(["markers","dataLayers"])}static{this.identityCollectionObjectProperties=Object.freeze(["choropleth"])}static{this.styles=[LyraElement.styles,styles,srOnly]}static preload(engine="modular"){return(engine==="maplibre"?loadMaplibre():loadModularMap()).then(module=>module!==null)}constructor(){super(),this.hostDescription=new HostDescriptionController(this,()=>this._map?.getCanvas?.()??null),this._center=Object.freeze([0,0]),this.zoom=2,this.fitToken=Object.freeze({}),this.semanticsStale=!0,this.markerSemanticsStale=!0,this.geoJsonRefreshRequested=!1,this.refreshingGeoJson=!1,this.boxZoomSettling=!1,this.writingCamera=!1,this.maxBounds=null,this._legend=EMPTY_MAP_LEGEND,this._legendProjection=EMPTY_MAP_LEGEND_PROJECTION,this._legendGrouped=!1,this.hasLegendSlot=!1,this.hasLegendStartSlot=!1,this._legendGradient=Object.freeze([]),this.legendIsLine=!1,this.legendGradientLoLabel=null,this.legendGradientHiLabel=null,this.legendInteractive=!1,this._legendControlRole="button",this.legendCollapsible=!1,this.legendOpen=!0,this._hiddenCategories=EMPTY_HIDDEN_CATEGORIES,this.markers=[],this.dataLayers=[],this._canonicalChoroplethSource=UNPROJECTED_MAP_VALUE,this._canonicalDataLayersSource=UNPROJECTED_MAP_VALUE,this._canonicalDataLayers=EMPTY_CANONICAL_MAP_DATA_LAYERS,this._canonicalMarkersSource=UNPROJECTED_MAP_VALUE,this._canonicalMarkers=EMPTY_CANONICAL_MAP_MARKERS,this.engine="modular",this.loading=!0,this.announcements=new AnnouncementSinkController(this,{eager:["assertive"]}),this.loadLibrary=engine=>engine==="maplibre"?loadMaplibre():loadModularMap(),this.visible=ownerWindow(this)?.IntersectionObserver===void 0,this._styleLoaded=!1,this._appliedDataLayerIds=new Map,this._appliedDataLayerShapes=new Map,this._appliedGeoJson=new Map,this._nextDataLayerId=0,this.nextPointIconId=0,this.appliedPointPaint=new Set,this.appliedPointMuting=new Set,this.appliedPointIcons=new Map,this._webglReady=!1,this._markerInstances=new Map,this._markerLabels=new Map,this._markerPopupIds=new Map,this.markerActivationDetails=new WeakMap,this._configuredPopups=new WeakSet,this._nextPopupId=0,this._markerColors=new Map,this._markerSources=new Map,this._connectGeneration=0,this._styleGeneration=0,this.featureGeneration=0,this.preparingFeatures=!1,this.pendingMapLoad=!1,this.rebuildGeneratedLayers=!1,this.paintThemeTokens=[],this.appliedLayerPaintKeys=new Map,this.configuredMarkerElements=new WeakSet,this.onLegendSlotChange=event=>{const slot=event.target,filled=slot.assignedNodes({flatten:!0}).some(node=>node.nodeType===Node.ELEMENT_NODE||(node.textContent??"").trim().length>0);slot.name==="legend-start"?this.hasLegendStartSlot=filled:this.hasLegendSlot=filled},new ThemeWatcher(this,()=>{this.syncPaintTheme()&&(this.refreshThemePaint(),this.legendIsLine=this.legendDescribesLine())}),new GlassScrollLayer(this,'[part="legend"]')}get center(){return this._center}set center(value){this._center=value}get legend(){return this._legend}set legend(value){if(value===this._legendSource||value===this._legend)return;this._legendSource=value;const previous=this._legend,normalized=normalizeMapLegend(value);this._legend=normalized.entries,this._legendProjection=normalized.projection,this._legendGrouped=normalized.grouped,this.requestUpdate("legend",previous)}probeLegendSlot(name){for(const child of Array.from(this.children))if(child.getAttribute("slot")===name)return!0;return!1}get legendGradient(){return this._legendGradient}set legendGradient(value){if(value===this._legendGradientSource||value===this._legendGradient)return;this._legendGradientSource=value;const previous=this._legendGradient;this._legendGradient=normalizeMapLegendGradient(value),this.requestUpdate("legendGradient",previous)}warnOnLegendChoroplethMismatch(){if(!litDevWarnings()||this.legendIsLine)return;const layer=this.canonicalChoropleth,legend=this.legendGradient;!layer||legend.length===0||layer.stops.length===0||legend.length===layer.stops.length&&legend.every(([legendValue,legendColor],index)=>{const layerStop=layer.stops[index];return layerStop!==void 0&&layerStop[0]===legendValue&&resolvedLayerColor(this,layerStop[1],void 0)===resolvedLayerColor(this,legendColor,void 0)})||devWarnOnce("lyra-map-legend-choropleth-mismatch",`<${this.localName}>: legendGradient does not match choropleth.stops, so the visible key may misdescribe the map. Assign the same stops array to both, or derive both from one source.`)}legendDescribesLine(){const stops=this.legendGradient;return stops.length<2?!1:this.canonicalDataLayers.some(layer=>layer.kind==="auto"&&!layer.cluster&&layer.line?.field&&layer.line.stops.length===stops.length&&layer.line.stops.every(([value,color],index)=>value===stops[index][0]&&resolvedLayerColor(this,color,layer.tone)===resolvedLayerColor(this,stops[index][1],layer.tone)))}get legendProjection(){return this._legendProjection}set legendProjection(_value){}get legendControlRole(){return this._legendControlRole}set legendControlRole(next){const normalized=LEGEND_CONTROL_ROLE.normalizeReflected(this,"legend-control-role",next),old=this._legendControlRole;old!==normalized&&(this._legendControlRole=normalized,this.requestUpdate("legendControlRole",old))}get legendCollapsed(){return this.legendCollapsible&&!this.legendOpen}toggleLegendPanel(){if(!this.legendCollapsible)return;const open=!this.legendOpen;this.emit("lr-map-legend-panel-toggle-request",{open},{cancelable:!0}).defaultPrevented||(this.legendOpen=open)}renderLegendDisclosure(){return this.legendCollapsible?html`<button
|
|
13
13
|
part="legend-disclosure"
|
|
14
14
|
type="button"
|
|
15
15
|
aria-expanded=${this.legendOpen?"true":"false"}
|
|
@@ -17,7 +17,7 @@ import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/co
|
|
|
17
17
|
@click=${()=>this.toggleLegendPanel()}
|
|
18
18
|
><span part="legend-disclosure-icon" class="legend-disclosure-icon" aria-hidden="true"
|
|
19
19
|
>${chevronIcon()}</span
|
|
20
|
-
><span>${this.localize("mapLegend")}</span></button>`:nothing}get hiddenCategories(){return this._hiddenCategories}set hiddenCategories(value){if(value===this._hiddenCategoriesSource||value===this._hiddenCategories)return;this._hiddenCategoriesSource=value;const previous=this._hiddenCategories;this._hiddenCategories=normalizeMapHiddenCategories(value),this.requestUpdate("hiddenCategories",previous)}get canonicalChoropleth(){const source=this.choropleth;return Object.is(source,this._canonicalChoroplethSource)?this._canonicalChoropleth:(this._canonicalChoroplethSource=source,this._canonicalChoropleth=projectMapChoropleth(source),this._canonicalChoropleth)}get canonicalDataLayers(){const source=this.dataLayers;return Object.is(source,this._canonicalDataLayersSource)?this._canonicalDataLayers:(this._canonicalDataLayersSource=source,this._canonicalDataLayers=projectMapDataLayers(source),this._canonicalDataLayers)}get canonicalMarkers(){const source=this.markers;return Object.is(source,this._canonicalMarkersSource)?this._canonicalMarkers:(this._canonicalMarkersSource=source,this._canonicalMarkers=projectMapMarkers(source),this._canonicalMarkers)}get map(){return this._map}pushGeoJson(source,resolvedSourceId,geojson,projection=projectGeoJson(geojson)){const previous=this._appliedGeoJson.get(resolvedSourceId);if(previous===projection)return;const diff=typeof source.updateData=="function"&&previous!==void 0?buildProjectedGeoJsonPropertyDiff(previous,projection):null;diff===null||typeof source.updateData!="function"?source.setData(geojson):(diff.update.length>0||diff.add?.length||diff.remove?.length)&&source.updateData(diff),this._appliedGeoJson.set(resolvedSourceId,projection)}get safeMaxBounds(){const bounds=this.maxBounds;if(!Array.isArray(bounds)||bounds.length!==2)return null;const[southWest,northEast]=bounds;if(!Array.isArray(southWest)||!Array.isArray(northEast))return null;const[west,south]=southWest,[east,north]=northEast,values=[west,south,east,north].map(Number);if(!values.every(value=>Number.isFinite(value)))return null;const[w,s,e,n]=values;return w>=e||s>=n||w<-180||e>180||s<-90||n>90?null:[[w,s],[e,n]]}applyMaxBounds(){const map=this._map;if(!map||typeof map.setMaxBounds!="function")return;const bounds=this.safeMaxBounds;let zoomBefore,centerBefore;try{if(zoomBefore=map.getZoom(),centerBefore=map.getCenter(),map.setMaxBounds(bounds),bounds===null||Number.isFinite(map.getZoom()))return}catch{}try{map.setMaxBounds(null)}catch{}typeof zoomBefore=="number"&&Number.isFinite(zoomBefore)&&map.setZoom(zoomBefore),centerBefore&&map.setCenter([centerBefore.lng,centerBefore.lat]),devWarnOnce("lyra-map-max-bounds-rejected","<lr-map>: maxBounds left maplibre-gl without a usable camera, so it was dropped and the camera restored. This is a peer limitation, not a bad value -- it shows up at sub-1 fractional zooms in wide containers. Raise the zoom, narrow the box, or leave maxBounds unset.")}get safeZoom(){return finiteRange(this.zoom,2,0,22)}get safeCenter(){const center=Array.isArray(this.center)?this.center:[];return[finiteRange(Number(center[0]),0,-180,180),finiteRange(Number(center[1]),0,-90,90)]}fitBounds(bounds,options={}){const box=normalizeFitBounds(bounds);if(!box)return devWarnOnce("lyra-map-fit-bounds-rejected",`<${this.localName}>: fitBounds() ignored a box that is not [[west, south], [east, north]] with finite coordinates, latitudes in [-90, 90], south <= north, and longitudes in [-180, 180] (east may run past 180, up to one full turn east of west, for a box crossing the antimeridian).`),!1;const settings=typeof options=="object"&&options!==null?options:{},maxZoom=settings.maxZoom,fit=Object.freeze({bounds:box,padding:normalizeFitPadding(settings.padding),maxZoom:isFiniteCoordinate(maxZoom)?finiteRange(maxZoom,22,0,22):void 0,animate:settings.animate!==!1}),map=this._map;return map?(this.pendingFit=void 0,this.applyFit(map,fit,fit.animate&&!prefersReducedMotion(this))):(this.pendingFit=Object.freeze({fit,center:snapshotCenter(this.center),zoom:this.zoom}),!0)}applyFit(map,fit,animate){if(typeof map.fitBounds!="function")return!1;const[[west,south],[east,north]]=fit.bounds;try{map.fitBounds([[west,south],[east,north]],{padding:{...fit.padding},...fit.maxZoom===void 0?{}:{maxZoom:fit.maxZoom},animate},{[FIT_EVENT_KEY]:this.fitToken})}catch{return!1}return!0}applyPendingFit(){const map=this._map,pending=this.pendingFit;!map||!pending||(this.pendingFit=void 0,!(!sameCenterValue(this.center,pending.center)||!Object.is(this.zoom,pending.zoom))&&this.applyFit(map,pending.fit,!1))}reflectCamera(map,source){const camera=readPeerCamera(map);if(!camera)return;const center=Object.freeze(camera.center),{zoom}=camera;this.reflectedCamera={center,zoom};const previousCenter=this._center;this._center=center,this.requestUpdate("center",previousCenter),this.zoom=zoom,this.emit("lr-map-view-change",{center,zoom,source})}pushCamera(changed){const reflected=this.reflectedCamera;this.reflectedCamera=void 0;const map=this._map;if(!map||!changed.has("center")&&!changed.has("zoom"))return;const center=this.safeCenter,zoom=this.safeZoom,shown=readPeerCamera(map),showsCenter=camera=>camera!==void 0&¢er[0]===camera.center[0]&¢er[1]===camera.center[1];let pushCenter=changed.has("center")&&!showsCenter(reflected)&&!showsCenter(shown),pushZoom=changed.has("zoom")&&zoom!==reflected?.zoom&&zoom!==shown?.zoom;if(!pushCenter&&!pushZoom)return;let interrupting=!1;try{interrupting=map.isMoving?.()===!0}catch{}interrupting&&(pushCenter=!showsCenter(shown),pushZoom=zoom!==shown?.zoom),this.writeCamera(()=>{pushCenter&&map.setCenter(center),pushZoom&&map.setZoom(zoom)})}writeCamera(write){const previous=this.writingCamera;this.writingCamera=!0;try{write()}finally{this.writingCamera=previous}}connectedCallback(){super.connectedCallback();const generation=++this._connectGeneration,IntersectionObserverCtor=ownerWindow(this)?.IntersectionObserver;if(this.visible=IntersectionObserverCtor===void 0,this.failure=void 0,this.loading=!0,this._webglReady=!1,IntersectionObserverCtor){const observer=new IntersectionObserverCtor(entries=>{entries[0]?.isIntersecting&&(this.visible=!0)});this.intersectionObserver=observer,observer.observe(this)}(async()=>{let mod;try{mod=await this.loadLibrary(this.engine)}catch{generation===this._connectGeneration&&this.isConnected&&this.failInitialization("missing-peer");return}if(!(generation!==this._connectGeneration||!this.isConnected)){if(this.loading=!1,!mod){this.failInitialization("missing-peer");return}if(this._maplibreModule=mod,!hasMapStyle(this.mapStyle)){this.failInitialization("style-required");return}if(!supportsWebGL2(this)){this.failInitialization("webgl-unavailable");return}this._webglReady=!0,await this.updateComplete,!(generation!==this._connectGeneration||!this.containerEl||!this.isConnected)&&this.tryConstructMap()}})()}disconnectedCallback(){super.disconnectedCallback(),this.disposeMap(),this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0;for(const marker of this._markerInstances.values()){const markerElement=marker.getElement?.();markerElement&&this.markerActivationDetails.delete(markerElement),marker.remove()}this._markerInstances.clear(),this._markerColors.clear(),this._markerLabels.clear(),this._markerPopupIds.clear(),this._markerSources.clear()}failureMessage(reason=this.failure??"initialization-failed"){switch(reason){case"missing-peer":return this.localize("mapMissingLibrary",void 0,{package:this.engine==="maplibre"?"maplibre-gl":"@aceshooting/lyra-map"});case"style-required":return this.localize("mapStyleRequired");case"webgl-unavailable":return this.localize("mapWebglUnavailable");case"initialization-failed":return this.localize("mapInitializationFailed")}}failInitialization(reason,partialMap){try{partialMap?.remove()}catch{}this.disposeMap(),this.loading=!1,this.failure=reason,this.announcements.announceAssertive(this.failureMessage(reason))}scheduleStyleRequiredFailure(){const generation=this._connectGeneration,module=this._maplibreModule;this.scheduleAfterUpdate(()=>{!this.isConnected||generation!==this._connectGeneration||module!==this._maplibreModule||hasMapStyle(this.mapStyle)||this.failInitialization("style-required")},"map-style-required")}disposeMap(){this.cancelFeaturePreparation(),this.preparedFeatureSignature=void 0,this.pendingMapLoad=!1,this.rebuildGeneratedLayers=!1,this.stopObservingMapAllocation(),this.stopObservingPeerChrome();try{this._map?.remove()}catch{}this._map=void 0,this._styleLoaded=!1,this.boxZoomSettling=!1,this.reflectedCamera=void 0,this._appliedChoroplethSourceId=void 0,this._appliedFillLayerId=void 0,this._appliedDataLayerIds.clear(),this._appliedDataLayerShapes.clear(),this.appliedPointIcons.clear(),this.appliedPointPaint.clear(),this.appliedPointMuting.clear(),this._appliedGeoJson.clear()}adoptedCallback(){super.adoptedCallback(),this.hostDescription.adopted(),this.stopObservingMapAllocation(),this.stopObservingPeerChrome(),this.announcements.adopted(),this._map&&this.containerEl&&this.isConnected&&this.observeMapAllocation(this._map,this.containerEl)}tryConstructMap(){if(this._map||!this._maplibreModule||!this._webglReady||!this.containerEl||!this.visible||!this.isConnected)return;if(!hasMapStyle(this.mapStyle)){this.scheduleStyleRequiredFailure();return}const mod=this._maplibreModule;let candidate;try{candidate=new mod.Map({container:this.containerEl,style:this.mapStyle,center:this.safeCenter,zoom:this.safeZoom,...typeof this.renderWorldCopies=="boolean"?{renderWorldCopies:this.renderWorldCopies}:{},locale:{"Map.Title":this.effectiveMapLabel,"Marker.Title":this.localize("mapMarker"),"Popup.Close":this.localize("close"),"AttributionControl.ToggleAttribution":this.localize("mapToggleAttribution"),"AttributionControl.MapFeedback":this.localize("mapFeedback"),"NavigationControl.ZoomIn":this.localize("zoomIn"),"NavigationControl.ZoomOut":this.localize("zoomOut"),"NavigationControl.ResetBearing":this.localize("mapResetNorth")}}),candidate.on("error",event=>{if(this._map===candidate&&!this._styleLoaded){this.failInitialization("initialization-failed");return}console.error("lr-map:",event.error??event)}),candidate.on("load",()=>{if(this._map===candidate)try{this._styleLoaded=!0,this.pendingMapLoad=!0,this.rebuildGeneratedLayers=!0,this.applyMarkers(),this.reconcileGeneratedLayers()}catch{this.failInitialization("initialization-failed")}}),candidate.on("click",event=>{if(this._map!==candidate)return;const fillLayerId=this._appliedFillLayerId,layerIds=[];fillLayerId&&candidate.getLayer(fillLayerId)&&layerIds.push(fillLayerId);for(const resolvedSourceId of this._appliedDataLayerIds.values())for(const suffix of QUERYABLE_DATA_LAYER_SUFFIXES){const layerId=`${resolvedSourceId}${suffix}`;candidate.getLayer(layerId)&&layerIds.push(layerId)}const hit=(layerIds.length?candidate.queryRenderedFeatures(event.point,{layers:layerIds}):[])[0],hitLayerId=hit?.layer?.id;let origin,sourceId;if(hitLayerId!==void 0){if(hitLayerId===fillLayerId)origin="choropleth";else for(const[publicSourceId,resolvedSourceId]of this._appliedDataLayerIds)if(hitLayerId.startsWith(`${resolvedSourceId}-`)){origin=hitLayerId===`${resolvedSourceId}-cluster`?"cluster":"data-layer",sourceId=publicSourceId;break}}this.emit("lr-map-click",{lngLat:[event.lngLat.lng,event.lngLat.lat],feature:hit,origin,sourceId})}),candidate.on("boxzoomend",()=>{this._map===candidate&&(this.boxZoomSettling=!0)}),candidate.on("moveend",event=>{if(this._map!==candidate)return;const fit=event?.[FIT_EVENT_KEY]===this.fitToken,afterBoxZoom=!fit&&this.boxZoomSettling;if(fit||(this.boxZoomSettling=!1),this.writingCamera)return;const source=fit?"fit":event?.originalEvent||afterBoxZoom?"user":void 0;source&&this.reflectCamera(candidate,source)});const canvas=candidate.getCanvas?.();canvas&¬ifyMapCanvasReady(this,canvas),this._map=candidate,this.observeMapAllocation(candidate,this.containerEl),this.observePeerChrome(),this.failure=void 0}catch{this.failInitialization("initialization-failed",candidate);return}this.applyMaxBounds(),this.pendingFit&&this.scheduleAfterUpdate(()=>this.applyPendingFit(),"map-pending-fit")}requestUpdate(...args){super.requestUpdate(...args),this.isUpdatePending&&args[0]!=="center"&&args[0]!=="zoom"&&(this.semanticsStale=!0)}updated(changed){if(super.updated(changed),this.setAttribute("aria-busy",String(this.loading)),this.legendCollapsed&&(changed.has("legendOpen")||changed.has("legendCollapsible"))){const legend=this.shadowRoot?.querySelector('[part="legend"]');legend&&(legend.scrollTop=0)}if((changed.has("choropleth")||changed.has("legendGradient"))&&this.warnOnLegendChoroplethMismatch(),changed.has("visible")&&this.visible&&this.tryConstructMap(),changed.has("mapStyle")&&(this._styleGeneration+=1,this.cancelFeaturePreparation(),this.preparedFeatureSignature=void 0),changed.has("mapStyle")&&!hasMapStyle(this.mapStyle)&&this._maplibreModule)this.scheduleStyleRequiredFailure();else if(changed.has("mapStyle")&&!this._map&&this._maplibreModule&&hasMapStyle(this.mapStyle))this.tryConstructMap();else if(changed.has("mapStyle")&&this._map){this._styleLoaded=!1,this._appliedChoroplethSourceId=void 0,this._appliedFillLayerId=void 0;const map=this._map,style=this.mapStyle,generation=this._connectGeneration,styleGeneration=this._styleGeneration,current=()=>this.isConnected&&this._map===map&&generation===this._connectGeneration&&styleGeneration===this._styleGeneration&&this.mapStyle===style,failStyle=()=>{current()&&this.scheduleAfterUpdate(()=>{current()&&this.failInitialization("initialization-failed")},`map-style-failure-${styleGeneration}`)};try{for(const sourceId of this.appliedPointIcons.keys())this.removePointIcons(sourceId);map.once("style.load",()=>{if(current())try{this._styleLoaded=!0,this._appliedDataLayerIds.clear(),this._appliedDataLayerShapes.clear(),this.appliedPointPaint.clear(),this.appliedPointMuting.clear(),this._appliedGeoJson.clear(),this.rebuildGeneratedLayers=!0,this.reconcileGeneratedLayers()}catch{failStyle()}}),map.setStyle(style)}catch{failStyle()}}else this._styleLoaded&&(changed.has("dataLayers")||changed.has("choropleth"))&&this.reconcileGeneratedLayers();changed.has("hiddenCategories")&&this._map&&this._styleLoaded&&this.refreshThemePaint(),this.pushCamera(changed),changed.has("maxBounds")&&this._map&&this.writeCamera(()=>this.applyMaxBounds()),changed.has("markers")&&this._map&&this.applyMarkers(),this.semanticsStale&&(this.semanticsStale=!1,this.syncMapSemantics())}willUpdate(changed){super.willUpdate(changed),(changed.has("legendGradient")||changed.has("dataLayers"))&&(this.legendIsLine=this.legendDescribesLine()),changed.has("mapStyle")&&!this._map&&this._maplibreModule&&hasMapStyle(this.mapStyle)&&(this._webglReady||(this._webglReady=supportsWebGL2(this)),this.failure=this._webglReady?void 0:"webgl-unavailable",this._webglReady||(this.loading=!1,this.announcements.announceAssertive(this.failureMessage("webgl-unavailable"))))}refreshThemePaint(){if(!this._map||!this._styleLoaded||this.preparingFeatures)return;const fillOpacity=choroplethFillOpacity(this);if(this._appliedFillLayerId){const choropleth=this.canonicalChoropleth;choropleth&&choropleth.stops.length>0&&this._map.setPaintProperty(this._appliedFillLayerId,"fill-color",this.choroplethColorExpression(choropleth)),this._map.setPaintProperty(this._appliedFillLayerId,"fill-opacity",fillOpacity)}const dataLayersBySourceId=new Map(this.canonicalDataLayers.map(layer=>[layer.sourceId,layer]));for(const[publicSourceId,sourceId]of this._appliedDataLayerIds){const dataLayer=dataLayersBySourceId.get(publicSourceId);dataLayer&&this.paintDataLayer(sourceId,dataLayer)}}cancelFeaturePreparation(){this.featureGeneration+=1,this.featureAbort?.abort(),this.featureAbort=void 0,this.preparingFeatures=!1}generatedFeatureRequirements(){const sources={},layers=[],add=(source,types)=>{for(const[index,type]of types.entries())layers.push({id:`${source}-${type}-${index}`,type,source})},choropleth=this.canonicalChoropleth;choropleth&&(sources.choropleth={type:"geojson",data:choropleth.geojson},choropleth.stops.length&&add("choropleth",["fill"]));for(const[index,layer]of this.canonicalDataLayers.entries()){const source=`data-${index}`,cluster=layer.cluster;sources[source]={type:"geojson",data:layer.geojson,...cluster?{cluster:!0,clusterRadius:cluster.radius,clusterMaxZoom:cluster.maxZoom}:{}},layer.kind==="heatmap"?add(source,["heatmap"]):(add(source,cluster?["circle"]:["fill","line","circle"]),(cluster&&this.styleProvidesGlyphs()||layer.point?.iconField&&layer.point.icons.length)&&add(source,["symbol"]))}return{sources,layers}}reconcileGeneratedLayers(){const map=this._map;if(!map||!this._styleLoaded)return;this.cancelFeaturePreparation();const generation=this.featureGeneration,connection=this._connectGeneration,styleGeneration=this._styleGeneration,style=this.mapStyle,dataLayers=this.dataLayers,choropleth=this.choropleth,current=()=>this.isConnected&&this._map===map&&generation===this.featureGeneration&&connection===this._connectGeneration&&styleGeneration===this._styleGeneration&&style===this.mapStyle&&dataLayers===this.dataLayers&&choropleth===this.choropleth,apply=()=>{const next=this.canonicalChoropleth,nextId=next?this.resolveChoroplethSourceId(next.sourceId):void 0;this._appliedChoroplethSourceId&&this._appliedChoroplethSourceId!==nextId&&this.removeChoropleth(),this.rebuildGeneratedLayers?(this.applyChoropleth(),this.applyDataLayers(),this.rebuildGeneratedLayers=!1):(this.applyDataLayers(),this.applyChoropleth()),this.pendingMapLoad&&(this.pendingMapLoad=!1,this.emit("lr-map-load"))},fail=()=>{if(current()){if(this.pendingMapLoad){this.failInitialization("initialization-failed");return}this.scheduleAfterUpdate(()=>{current()&&this.failInitialization("initialization-failed")},`map-feature-failure-${generation}`)}};try{if(!map.prepareFeatures){apply();return}const requirements=this.generatedFeatureRequirements(),signature=JSON.stringify([Object.values(requirements.sources??{}).map(source=>source.type),(requirements.layers??[]).map(layer=>layer.type)]);if(signature===this.preparedFeatureSignature){apply();return}const controller=new AbortController;this.featureAbort=controller,this.preparingFeatures=!0,(async()=>{try{if(await map.prepareFeatures(requirements,{signal:controller.signal}),!current()||controller.signal.aborted)return;this.featureAbort=void 0,this.preparingFeatures=!1,this.preparedFeatureSignature=signature,apply()}catch{if(!current()||controller.signal.aborted)return;this.preparingFeatures=!1,fail()}})()}catch{fail()}}applyChoropleth(){if(!this._map)return;const choropleth=this.canonicalChoropleth;if(!choropleth){this.removeChoropleth();return}const{geojson,geojsonProjection,stops}=choropleth,sourceId=this.resolveChoroplethSourceId(choropleth.sourceId),fillLayerId=`${sourceId}-fill`;this._appliedChoroplethSourceId&&this._appliedChoroplethSourceId!==sourceId&&this.removeChoropleth(),warnOnUntileableProperties(geojsonProjection,"choropleth");const existingSource=this._map.getSource(sourceId);if(existingSource?this.pushGeoJson(existingSource,sourceId,geojson,geojsonProjection):(this._map.addSource(sourceId,{type:"geojson",data:geojson}),this._appliedGeoJson.set(sourceId,geojsonProjection)),this._appliedChoroplethSourceId=sourceId,stops.length===0)return;const colorExpr=this.choroplethColorExpression(choropleth);this._map.getLayer(fillLayerId)?(this._map.setPaintProperty(fillLayerId,"fill-color",colorExpr),this._map.setPaintProperty(fillLayerId,"fill-opacity",choroplethFillOpacity(this))):this._map.addLayer({id:fillLayerId,type:"fill",source:sourceId,paint:{"fill-color":colorExpr,"fill-opacity":choroplethFillOpacity(this)}}),this._appliedFillLayerId=fillLayerId}choroplethColorExpression(choropleth){const{field,stops}=choropleth,resolvedStops=stops.map(([value,color])=>[value,resolvedLayerColor(this,color,void 0)]);let colorExpr;if(choropleth.interpolation==="step"){const base=choropleth.stepBaseColor?resolvedLayerColor(this,choropleth.stepBaseColor,void 0):resolvedStops[0][1];colorExpr=["step",["get",field],base];for(const[value,color]of resolvedStops)colorExpr.push(value,color)}else{colorExpr=["interpolate",choropleth.interpolation==="logarithmic"?["exponential",CHOROPLETH_LOG_INTERPOLATION_BASE]:["linear"],["get",field]];for(const[value,color]of resolvedStops)colorExpr.push(value,color)}return colorExpr}resolveChoroplethSourceId(sourceId){const dataSourceIds=new Set(this.canonicalDataLayers.map(layer=>layer.sourceId));let resolved=sourceId;for(;dataSourceIds.has(resolved);)resolved=`lr-choropleth-${resolved}`;return resolved}removeChoropleth(){!this._map||!this._appliedChoroplethSourceId||(this._appliedFillLayerId&&this._map.getLayer(this._appliedFillLayerId)&&this._map.removeLayer(this._appliedFillLayerId),this._map.getSource(this._appliedChoroplethSourceId)&&this._map.removeSource(this._appliedChoroplethSourceId),this._appliedGeoJson.delete(this._appliedChoroplethSourceId),this._appliedChoroplethSourceId=void 0,this._appliedFillLayerId=void 0)}applyDataLayers(){if(!this._map)return;const layers=this.canonicalDataLayers,nextIds=new Set(layers.map(layer=>layer.sourceId));for(const publicSourceId of this._appliedDataLayerIds.keys())nextIds.has(publicSourceId)||this.removeDataLayer(publicSourceId);for(const layer of layers){const{sourceId:publicSourceId,geojson,geojsonProjection}=layer,shape=dataLayerShape(layer),appliedShape=this._appliedDataLayerShapes.get(publicSourceId);appliedShape!==void 0&&appliedShape!==shape&&this.removeDataLayer(publicSourceId);const sourceId=this.resolveDataLayerSourceId(publicSourceId);warnOnUntileableProperties(geojsonProjection,publicSourceId);const cluster=layer.cluster,existingSource=this._map.getSource(sourceId);existingSource?this.pushGeoJson(existingSource,sourceId,geojson,geojsonProjection):(this._map.addSource(sourceId,{type:"geojson",data:geojson,...cluster?{cluster:!0,clusterRadius:cluster.radius,clusterMaxZoom:cluster.maxZoom}:{}}),this._appliedGeoJson.set(sourceId,geojsonProjection)),this.applyDataLayerRendering(sourceId,layer),this._appliedDataLayerIds.set(publicSourceId,sourceId),this._appliedDataLayerShapes.set(publicSourceId,shape)}}applyDataLayerRendering(sourceId,layer){if(layer.kind==="heatmap"){this.applyHeatmapLayer(sourceId,layer);return}const cluster=layer.cluster;cluster?this.applyClusterLayers(sourceId,layer,cluster):this.applyGeometryLayers(sourceId,layer),this.applyPointIcons(sourceId,layer)}paintDataLayer(sourceId,layer){if(layer.kind==="heatmap"){this.paintHeatmapLayer(sourceId,layer);return}const cluster=layer.cluster;cluster?this.paintClusterLayers(sourceId,layer,cluster):this.paintGeometryLayers(sourceId,layer),this.paintPointIcons(sourceId,layer)}applyGeometryLayers(sourceId,layer){if(!this._map)return;const tone=layer.tone,color=resolvedLayerColor(this,layer.color,tone),stroke=resolvedLayerColor(this,layer.strokeColor??layer.color,tone),fillId=`${sourceId}-fill`,lineId=`${sourceId}-line`,circleId=`${sourceId}-circle`;this._map.getLayer(fillId)||this._map.addLayer({id:fillId,type:"fill",source:sourceId,filter:["==",["geometry-type"],"Polygon"],paint:{"fill-color":color,"fill-opacity":choroplethFillOpacity(this)}}),this._map.getLayer(lineId)||this._map.addLayer({id:lineId,type:"line",source:sourceId,filter:["in",["geometry-type"],["literal",["LineString","Polygon"]]],paint:{"line-color":this.lineColor(layer),"line-width":layer.line?.width??2,...layer.line?{"line-opacity":layer.line.opacity}:{}}}),this._map.getLayer(circleId)||this._map.addLayer({id:circleId,type:"circle",source:sourceId,filter:["==",["geometry-type"],"Point"],paint:{"circle-color":stroke,"circle-radius":5}}),this._map.setPaintProperty(lineId,"line-width",layer.line?.width??2),this._map.setPaintProperty(lineId,"line-opacity",layer.line?.opacity??1),this.paintGeometryLayers(sourceId,layer)}paintGeometryLayers(sourceId,layer){if(!this._map)return;const tone=layer.tone,color=resolvedLayerColor(this,layer.color,tone);this._map.setPaintProperty(`${sourceId}-fill`,"fill-color",color),this._map.setPaintProperty(`${sourceId}-fill`,"fill-opacity",choroplethFillOpacity(this)),this._map.setPaintProperty(`${sourceId}-line`,"line-color",this.lineColor(layer)),this.paintPoints(sourceId,layer)}lineColor(layer){const fallback=resolvedLayerColor(this,layer.strokeColor??layer.color,layer.tone),line=layer.line;return!line?.field||line.stops.length<2?fallback:lineColorExpression(line.field,line.stops.map(([value,color])=>[value,resolvedLayerColor(this,color,layer.tone)]),fallback)}mutedPointOpacity(layerId,field){const muted=field?this.hiddenCategories:EMPTY_HIDDEN_CATEGORIES;if(!muted.length)return this.appliedPointMuting.delete(layerId)?1:void 0;this.appliedPointMuting.add(layerId);const dim=hiddenCategoryOpacity(this);return mutedCategoryOpacityExpression(field,muted,dim)}paintPoints(sourceId,layer){if(!this._map)return;const point=layer.point,fallback=resolvedLayerColor(this,layer.strokeColor??layer.color,layer.tone),color=pointColorExpression(point?.field,point?.field&&point.colors.length?point.colors.map(([value,paint])=>[value,resolvedLayerColor(this,paint,layer.tone)]):[],fallback),id=`${sourceId}-circle`;this._map.setPaintProperty(id,"circle-color",color);const opacity=this.mutedPointOpacity(id,point?.field);opacity!==void 0&&(this._map.setPaintProperty(id,"circle-opacity",opacity),this._map.setPaintProperty(id,"circle-stroke-opacity",opacity)),!(!point&&!this.appliedPointPaint.has(sourceId))&&(this._map.setPaintProperty(id,"circle-radius",pointRadiusExpression(point?.radius??5)),this._map.setPaintProperty(id,"circle-stroke-width",point?.strokeWidth??0),this._map.setPaintProperty(id,"circle-stroke-color",point?.strokeColor?resolvedLayerColor(this,point.strokeColor,layer.tone):fallback),point?this.appliedPointPaint.add(sourceId):this.appliedPointPaint.delete(sourceId))}pointIconColor(layer){const resolved=resolvedLayerColor(this,layer.point?.iconColor??`var(${ON_TONE_TOKEN[layer.tone??"accent"]})`,layer.tone);return resolveCanvasColor(this,resolved,dataLayerColor(this,layer.tone))}removePointIcons(sourceId){const applied=this.appliedPointIcons.get(sourceId);if(!applied||!this._map)return;const id=`${sourceId}-point-icon`;this._map.getLayer(id)&&this._map.removeLayer(id);for(const{id:imageId}of applied.icons)this._map.hasImage?.(imageId)&&this._map.removeImage?.(imageId);this.appliedPointIcons.delete(sourceId),this.appliedPointMuting.delete(id)}applyPointIcons(sourceId,layer){const map=this._map,point=layer.point,signature=JSON.stringify([point?.iconField,point?.iconSize,point?.icons]);if(this.appliedPointIcons.get(sourceId)?.signature===signature){this.paintPointIcons(sourceId,layer);return}if(this.removePointIcons(sourceId),!point?.iconField||!point.icons.length||!map||typeof map.addImage!="function"||typeof map.hasImage!="function"||typeof map.updateImage!="function"||typeof map.removeImage!="function")return;const color=this.pointIconColor(layer),icons=[];this.appliedPointIcons.set(sourceId,{signature,color,icons});for(const icon of point.icons){const raster=rasterPointIcon(this,icon,color);if(!raster)continue;let id;do id=`lr-point-icon-${this.nextPointIconId++}`;while(map.hasImage(id));icons.push({id,icon}),map.addImage(id,raster,{pixelRatio:2})}icons.length&&map.addLayer({id:`${sourceId}-point-icon`,type:"symbol",source:sourceId,filter:layer.cluster?["all",["==",["geometry-type"],"Point"],["!",["has","point_count"]]]:["==",["geometry-type"],"Point"],layout:{"icon-image":["match",["get",point.iconField],...icons.flatMap(({id,icon})=>[icon.value,id]),""],"icon-size":point.iconSize/(POINT_ICON_RASTER_SIZE/2),"icon-allow-overlap":!0,"icon-ignore-placement":!0}})}paintPointIcons(sourceId,layer){const applied=this.appliedPointIcons.get(sourceId);if(!applied)return;const iconLayerId=`${sourceId}-point-icon`,opacity=this.mutedPointOpacity(iconLayerId,layer.point?.iconField);opacity!==void 0&&this._map?.setPaintProperty(iconLayerId,"icon-opacity",opacity);const color=this.pointIconColor(layer);if(color!==applied.color){for(const{id,icon}of applied.icons){const raster=rasterPointIcon(this,icon,color);raster&&this._map?.updateImage?.(id,raster)}applied.color=color}}clusterColorExpression(layer,cluster){const tone=layer.tone;return clusterColorExpression(cluster.colorSteps.map(([count,stepColor])=>[count,resolvedLayerColor(this,stepColor,tone)]),()=>resolvedLayerColor(this,layer.color,tone))}applyClusterLayers(sourceId,layer,cluster){if(!this._map)return;const tone=layer.tone,stroke=resolvedClusterStrokeColor(this,cluster.strokeColor,layer),clusterId=`${sourceId}-cluster`,countId=`${sourceId}-cluster-count`,circleId=`${sourceId}-circle`,clusterColor=this.clusterColorExpression(layer,cluster),clusterRadius=stepExpression(["get","point_count"],cluster.radiusSteps),countColor=resolvedClusterCountColor(this,cluster.countColor)??resolvedLayerColor(this,`var(${ON_TONE_TOKEN[tone??"accent"]})`,tone),countHaloColor=resolvedClusterCountColor(this,cluster.countHaloColor);this._map.getLayer(clusterId)||this._map.addLayer({id:clusterId,type:"circle",source:sourceId,filter:["has","point_count"],paint:{"circle-color":clusterColor,"circle-radius":clusterRadius,"circle-stroke-width":1,"circle-stroke-color":stroke}}),this.styleProvidesGlyphs()&&!this._map.getLayer(countId)&&this._map.addLayer({id:countId,type:"symbol",source:sourceId,filter:["has","point_count"],layout:{"text-field":["get","point_count_abbreviated"],"text-size":12,...cluster.countFont?{"text-font":[...cluster.countFont]}:{}},paint:{"text-color":countColor,...countHaloColor?{"text-halo-color":countHaloColor,"text-halo-width":cluster.countHaloWidth}:{}}}),this._map.getLayer(circleId)||this._map.addLayer({id:circleId,type:"circle",source:sourceId,filter:["all",["==",["geometry-type"],"Point"],["!",["has","point_count"]]],paint:{"circle-color":stroke,"circle-radius":5}}),this.paintClusterLayers(sourceId,layer,cluster)}paintClusterLayers(sourceId,layer,cluster){if(!this._map)return;const tone=layer.tone,stroke=resolvedClusterStrokeColor(this,cluster.strokeColor,layer),clusterId=`${sourceId}-cluster`;if(this._map.setPaintProperty(clusterId,"circle-color",this.clusterColorExpression(layer,cluster)),this._map.setPaintProperty(clusterId,"circle-radius",stepExpression(["get","point_count"],cluster.radiusSteps)),this._map.setPaintProperty(clusterId,"circle-stroke-color",stroke),this.styleProvidesGlyphs()){this._map.setPaintProperty(`${sourceId}-cluster-count`,"text-color",resolvedClusterCountColor(this,cluster.countColor)??resolvedLayerColor(this,`var(${ON_TONE_TOKEN[tone??"accent"]})`,tone));const countHaloColor=resolvedClusterCountColor(this,cluster.countHaloColor);this._map.setPaintProperty(`${sourceId}-cluster-count`,"text-halo-color",countHaloColor??null),this._map.setPaintProperty(`${sourceId}-cluster-count`,"text-halo-width",countHaloColor?cluster.countHaloWidth:null)}this.paintPoints(sourceId,layer)}applyHeatmapLayer(sourceId,layer){if(!this._map)return;const heatmapId=`${sourceId}-heatmap`,options=layer.heatmap,weight=heatmapWeightExpression(options),color=this.heatmapColorExpression(layer),radius=heatmapZoomValue(options?.radius,DEFAULT_HEATMAP_RADIUS,1,200),intensity=heatmapZoomValue(options?.intensity,DEFAULT_HEATMAP_INTENSITY,0,100),opacity=finiteRange(options?.opacity??Number.NaN,1,0,1);if(!this._map.getLayer(heatmapId)){this._map.addLayer({id:heatmapId,type:"heatmap",source:sourceId,paint:{...weight?{"heatmap-weight":weight}:{},"heatmap-intensity":intensity,"heatmap-color":color,"heatmap-radius":radius,...options?.opacity===void 0?{}:{"heatmap-opacity":opacity}}});return}this.paintHeatmapLayer(sourceId,layer)}paintHeatmapLayer(sourceId,layer){if(!this._map)return;const heatmapId=`${sourceId}-heatmap`;this._map.setPaintProperty(heatmapId,"heatmap-weight",heatmapWeightExpression(layer.heatmap)??1),this._map.setPaintProperty(heatmapId,"heatmap-intensity",heatmapZoomValue(layer.heatmap?.intensity,DEFAULT_HEATMAP_INTENSITY,0,100)),this._map.setPaintProperty(heatmapId,"heatmap-color",this.heatmapColorExpression(layer)),this._map.setPaintProperty(heatmapId,"heatmap-radius",heatmapZoomValue(layer.heatmap?.radius,DEFAULT_HEATMAP_RADIUS,1,200)),this._map.setPaintProperty(heatmapId,"heatmap-opacity",finiteRange(layer.heatmap?.opacity??Number.NaN,1,0,1))}heatmapColorExpression(layer){const tone=layer.tone,authored=(layer.heatmap?.stops??[]).map(([density,color])=>[density,resolvedLayerColor(this,color,tone)]);return heatmapColorExpression(authored,()=>HEATMAP_RAMP_TOKENS.map(([density,token])=>[density,resolvedLayerColor(this,`var(${token})`,tone)]))}styleProvidesGlyphs(){try{const liveGlyphs=this._map?.getStyle?.()?.glyphs;if(typeof liveGlyphs=="string"&&liveGlyphs.trim().length>0)return!0}catch{}const declared=this.mapStyle,declaredGlyphs=declared&&typeof declared=="object"?declared.glyphs:void 0;return typeof declaredGlyphs=="string"&&declaredGlyphs.trim().length>0}resolveDataLayerSourceId(publicSourceId){const applied=this._appliedDataLayerIds.get(publicSourceId);if(applied)return applied;let sourceId;do sourceId=`lr-data-layer-${this._nextDataLayerId++}`;while(this._map?.getSource(sourceId)||DATA_LAYER_SUFFIXES.some(suffix=>this._map?.getLayer(`${sourceId}${suffix}`)));return sourceId}removeDataLayer(publicSourceId){if(!this._map)return;const sourceId=this._appliedDataLayerIds.get(publicSourceId);if(sourceId){this.removePointIcons(sourceId),this.appliedPointPaint.delete(sourceId);for(const suffix of DATA_LAYER_SUFFIXES){const layerId=`${sourceId}${suffix}`;this.appliedPointMuting.delete(layerId),this._map.getLayer(layerId)&&this._map.removeLayer(layerId)}this._map.getSource(sourceId)&&this._map.removeSource(sourceId),this._appliedDataLayerIds.delete(publicSourceId),this._appliedDataLayerShapes.delete(publicSourceId),this._appliedGeoJson.delete(sourceId)}}applyMarkers(){const map=this._map,mod=this._maplibreModule;if(!map||!mod)return;const visible=new Set,coordCounts=new Map,explicitIds=new Set;let defaultColor;for(const m of this.canonicalMarkers){const lngLat=m.lngLat,mapLngLat=[lngLat[0],lngLat[1]];let key,id;if(m.id!==void 0){if(id=m.id,explicitIds.has(id))continue;explicitIds.add(id),key=`id:${id}`}else{const coordKey=`${lngLat[0]},${lngLat[1]}`,occurrence=coordCounts.get(coordKey)??0;coordCounts.set(coordKey,occurrence+1),key=`coordinate:${coordKey}#${occurrence}`}visible.add(key);let existing=this._markerInstances.get(key);const markerColor=sanitizeCssColor(m.color)??(m.color===void 0?defaultColor??=dataLayerColor(this,"accent"):void 0),previous=this._markerSources.get(key);this._markerSources.set(key,m);const sameColor=this._markerColors.get(key)===markerColor,sameContent=previous!==void 0&&previous.label===m.label&&Object.is(previous.unsafeHtml,m.unsafeHtml);if(existing&&sameColor&&sameContent&&previous.lngLat[0]===lngLat[0]&&previous.lngLat[1]===lngLat[1])continue;if(existing&&!sameColor){const existingElement=existing.getElement?.();existingElement&&this.markerActivationDetails.delete(existingElement),existing.remove(),this._markerInstances.delete(key),this._markerColors.delete(key),existing=void 0}if(existing){existing.setLngLat(mapLngLat);const popup=existing.getPopup();if(!m.unsafeHtml&&!m.label)popup&&existing.setPopup(void 0);else if(popup)sameContent||setPopupContent(popup,m);else{const nextPopup=setPopupContent(new mod.Popup({offset:12}),m);existing.setPopup(nextPopup),this.configurePopupSemantics(key,existing,nextPopup)}}else{const marker=new mod.Marker(markerColor?{color:markerColor}:void 0).setLngLat(mapLngLat);if(m.unsafeHtml||m.label){const popup=setPopupContent(new mod.Popup({offset:12}),m);marker.setPopup(popup),this.configurePopupSemantics(key,marker,popup)}marker.addTo(map),this._markerInstances.set(key,marker),this._markerColors.set(key,markerColor)}const markerLabel=m.label?.trim()||markerPopupText(this,m.unsafeHtml);this._markerLabels.set(key,markerLabel||void 0);const markerElement=this._markerInstances.get(key)?.getElement?.();if(markerElement){addPartToken(markerElement,"marker");const currentMarker=this._markerInstances.get(key);this.configureMarkerInteraction(markerElement,{id,lngLat,marker:m},markerLabel);const popup=currentMarker?.getPopup();popup&¤tMarker?(this.configurePopupSemantics(key,currentMarker,popup),this.syncPopupSemantics(key,currentMarker,popup)):(markerElement.removeAttribute("aria-controls"),markerElement.removeAttribute("aria-expanded"),markerElement.removeAttribute("aria-haspopup"))}}for(const[key,marker]of this._markerInstances)if(!visible.has(key)){const markerElement=marker.getElement?.();markerElement&&this.markerActivationDetails.delete(markerElement),marker.remove(),this._markerInstances.delete(key),this._markerColors.delete(key),this._markerLabels.delete(key),this._markerPopupIds.delete(key),this._markerSources.delete(key)}}configureMarkerInteraction(markerElement,activation,markerLabel=activation.marker.label?.trim()||markerPopupText(this,activation.marker.unsafeHtml)){this.markerActivationDetails.set(markerElement,activation),markerElement.setAttribute("role","button"),markerElement.tabIndex=0,markerElement.setAttribute("aria-label",markerLabel||this.localize("mapMarker")),markerElement.setAttribute("lang",this.effectiveLocale),!this.configuredMarkerElements.has(markerElement)&&(this.configuredMarkerElements.add(markerElement),markerElement.addEventListener("click",event=>{event.defaultPrevented||this.emitMarkerActivation(markerElement,"pointer")}),markerElement.addEventListener("keydown",event=>{event.key!==" "&&event.key!=="Enter"||event.repeat||event.defaultPrevented||(event.key===" "&&event.preventDefault(),this.emitMarkerActivation(markerElement,"keyboard"))},{capture:!0}))}emitMarkerActivation(markerElement,source){if(!this.isConnected)return;const activation=this.markerActivationDetails.get(markerElement);activation&&this.emit("lr-map-marker-activate",{...activation,source})}get effectiveMapLabel(){return hostAriaLabel(this)??this.label??this.localize("map")}popupId(key){let id=this._markerPopupIds.get(key);return id||(id=`map-popup-${this._connectGeneration}-${++this._nextPopupId}`,this._markerPopupIds.set(key,id)),id}configurePopupSemantics(key,marker,popup){!popup||typeof popup!="object"||this._configuredPopups.has(popup)||(this._configuredPopups.add(popup),popup.on?.("open",()=>this.syncPopupSemantics(key,marker,popup)),popup.on?.("close",()=>{marker.getElement?.()?.setAttribute("aria-expanded","false")}))}stopObservingMapAllocation(){this.mapResizeObserver?.disconnect(),this.mapResizeObserver=void 0,this.observedMapContainer=void 0}observeMapAllocation(map,container){this.stopObservingMapAllocation();const ResizeObserverCtor=container.ownerDocument.defaultView?.ResizeObserver;if(!ResizeObserverCtor)return;let observer;observer=new ResizeObserverCtor(()=>{if(!(this.mapResizeObserver!==observer||this.observedMapContainer!==container||this.containerEl!==container||this._map!==map||!this.isConnected))try{map.resize()}catch{}}),this.mapResizeObserver=observer,this.observedMapContainer=container;try{observer.observe(container)}catch{this.stopObservingMapAllocation()}}stopObservingPeerChrome(){const pending=this.peerControlsResizeFrame;this.peerControlsResizeFrame=void 0,pending&&pending.view.cancelAnimationFrame(pending.handle),this.peerControlsResizeObserver?.disconnect(),this.peerControlsResizeObserver=void 0,this.peerChromeObserver?.disconnect(),this.peerChromeObserver=void 0,this.observedPeerContainer=void 0}schedulePeerControlInsets(observer,container){if(this.peerControlsResizeObserver!==observer||this.observedPeerContainer!==container||this.containerEl!==container||!this.isConnected||this.peerControlsResizeFrame)return;const view=container.ownerDocument.defaultView;if(!view)return;const pending={view,handle:0};this.peerControlsResizeFrame=pending,pending.handle=view.requestAnimationFrame(()=>{this.peerControlsResizeFrame===pending&&(this.peerControlsResizeFrame=void 0,!(this.peerControlsResizeObserver!==observer||this.observedPeerContainer!==container||this.containerEl!==container||container.ownerDocument.defaultView!==view||!this.isConnected)&&this.measurePeerControlInsets(container))})}measurePeerControlInsets(container){if(!(!this.isConnected||this.containerEl!==container)){for(const scale of container.querySelectorAll(".maplibregl-ctrl-scale")){const width=scale.style.width;width&&scale.style.getPropertyValue("--_lr-map-scale-width")!==width&&scale.style.setProperty("--_lr-map-scale-width",width)}for(const edge of["top","bottom"]){const height=Math.max(0,...[...container.querySelectorAll(`.maplibregl-ctrl-${edge}-left, .maplibregl-ctrl-${edge}-right`)].map(corner=>corner.offsetHeight)),base=container.parentElement,name=`--_lr-map-controls-${edge}`,value=`${height}px`;base&&base.style.getPropertyValue(name)!==value&&base.style.setProperty(name,value)}}}syncPeerChromeParts(root=this.containerEl??this.renderRoot){const selectors=[[".maplibregl-marker","marker"],[".maplibregl-popup","popup"],[".maplibregl-popup-content","popup-content"],[".maplibregl-popup-close-button","popup-close-button"],[".maplibregl-ctrl-attrib","attribution"],[".maplibregl-ctrl-attrib-button","attribution-toggle"],[".maplibregl-ctrl-group:has(.maplibregl-ctrl-zoom-in, .maplibregl-ctrl-compass)","navigation"],[".maplibregl-ctrl-zoom-in","zoom-in"],[".maplibregl-ctrl-zoom-out","zoom-out"],[".maplibregl-ctrl-compass","compass"],[".maplibregl-ctrl-scale","scale"]];for(const[selector,part]of selectors){const candidate=root,elements=[...root.querySelectorAll(selector)];candidate.matches?.(selector)&&elements.push(candidate);for(const element of elements){addPartToken(element,part);const label=part==="attribution-toggle"?this.localize("mapToggleAttribution"):part==="zoom-in"?this.localize("zoomIn"):part==="zoom-out"?this.localize("zoomOut"):part==="compass"?this.localize("mapResetNorth"):void 0;label!==void 0&&(element.setAttribute("aria-label",label),element.setAttribute("title",label))}}}observePeerChrome(){const container=this.containerEl;if(!container||(this.syncPeerChromeParts(container),this.observedPeerContainer===container&&this.peerChromeObserver))return;this.stopObservingPeerChrome();const MutationObserverCtor=container.ownerDocument.defaultView?.MutationObserver;if(!MutationObserverCtor)return;this.observedPeerContainer=container;const ResizeObserverCtor=container.ownerDocument.defaultView?.ResizeObserver;if(ResizeObserverCtor){const observer=new ResizeObserverCtor(()=>this.schedulePeerControlInsets(observer,container));this.peerControlsResizeObserver=observer;for(const corner of container.querySelectorAll(".maplibregl-ctrl-top-left, .maplibregl-ctrl-top-right, .maplibregl-ctrl-bottom-left, .maplibregl-ctrl-bottom-right"))this.peerControlsResizeObserver.observe(corner)}this.measurePeerControlInsets(container),this.peerChromeObserver=new MutationObserverCtor(records=>{if(!(!this.isConnected||this.containerEl!==container)){for(const record of records)for(const node of record.addedNodes)node.nodeType===Node.ELEMENT_NODE&&this.syncPeerChromeParts(node);this.measurePeerControlInsets(container)}}),this.peerChromeObserver.observe(container,{childList:!0,subtree:!0})}syncPopupSemantics(key,marker,popup){const markerElement=marker?.getElement?.();if(!markerElement)return;const id=this.popupId(key);markerElement.setAttribute("aria-controls",id),markerElement.setAttribute("aria-haspopup","dialog"),markerElement.setAttribute("aria-expanded",popup?.isOpen?.()?"true":"false");const popupElement=popup?.getElement?.();if(!popupElement)return;addPartToken(markerElement,"marker"),addPartToken(popupElement,"popup"),popupElement.id=id,popupElement.setAttribute("role","dialog"),popupElement.setAttribute("lang",this.effectiveLocale),popupElement.setAttribute("aria-label",this._markerLabels.get(key)||this.effectiveMapLabel);const popupContent=popupElement.querySelector(".maplibregl-popup-content");popupContent&&addPartToken(popupContent,"popup-content");const closeButton=popupElement.querySelector(".maplibregl-popup-close-button");closeButton&&addPartToken(closeButton,"popup-close-button"),closeButton?.setAttribute("aria-label",this.localize("close"))}syncMapSemantics(){const canvas=this._map?.getCanvas?.();canvas&&(canvas.setAttribute("aria-label",this.effectiveMapLabel),canvas.setAttribute("lang",this.effectiveLocale),this.legend.length||this.legendGradient.length>=2||this.hasLegendSlot||this.hasLegendStartSlot||this.legendProjection.truncated?canvas.setAttribute("aria-describedby","map-legend"):canvas.removeAttribute("aria-describedby")),this.hostDescription.refresh();for(const[key,marker]of this._markerInstances){const markerElement=marker.getElement?.();if(!markerElement)continue;addPartToken(markerElement,"marker"),markerElement.setAttribute("role","button"),markerElement.tabIndex=0,markerElement.setAttribute("aria-label",this._markerLabels.get(key)||this.localize("map")),markerElement.setAttribute("lang",this.effectiveLocale);const popup=marker.getPopup?.();popup?this.syncPopupSemantics(key,marker,popup):(markerElement.removeAttribute("aria-controls"),markerElement.removeAttribute("aria-expanded"),markerElement.removeAttribute("aria-haspopup"))}this.syncPeerChromeParts()}formatCount(value){return getNumberFormat(this.effectiveLocale).format(value)}legendLimitText(){return this.localize("paginationSummary",void 0,{start:this.formatCount(this.legend.length===0?0:1),end:this.formatCount(this.legend.length),total:this.formatCount(this.legendProjection.inputCount),itemLabel:this.localize("items")})}renderLegendRowContent(entry){const paint=sanitizeCssColor(entry.color);return html`${entry.icon?html`<span
|
|
20
|
+
><span>${this.localize("mapLegend")}</span></button>`:nothing}get hiddenCategories(){return this._hiddenCategories}set hiddenCategories(value){if(value===this._hiddenCategoriesSource||value===this._hiddenCategories)return;this._hiddenCategoriesSource=value;const previous=this._hiddenCategories;this._hiddenCategories=normalizeMapHiddenCategories(value),this.requestUpdate("hiddenCategories",previous)}get markersTruncated(){const descriptor=getOwnDataDescriptor(this.markers,"length");return typeof descriptor!="symbol"&&typeof descriptor.value=="number"&&descriptor.value>MAX_MAP_MARKERS}get canonicalChoropleth(){const source=this.choropleth;return Object.is(source,this._canonicalChoroplethSource)?this._canonicalChoropleth:(this._canonicalChoroplethSource=source,this._canonicalChoropleth=projectMapChoropleth(source),this._canonicalChoropleth)}get canonicalDataLayers(){const source=this.dataLayers;return Object.is(source,this._canonicalDataLayersSource)?this._canonicalDataLayers:(this._canonicalDataLayersSource=source,this._canonicalDataLayers=projectMapDataLayers(source),this._canonicalDataLayers)}get canonicalMarkers(){const source=this.markers;return Object.is(source,this._canonicalMarkersSource)?this._canonicalMarkers:(this._canonicalMarkersSource=source,this._canonicalMarkers=projectMapMarkers(source),this._canonicalMarkers)}get map(){return this._map}pushGeoJson(source,resolvedSourceId,geojson,projection=projectGeoJson(geojson)){const previous=this._appliedGeoJson.get(resolvedSourceId);if(previous===projection)return;const diff=typeof source.updateData=="function"&&previous!==void 0?buildProjectedGeoJsonPropertyDiff(previous,projection):null;diff===null||typeof source.updateData!="function"?source.setData(geojson):(diff.update.length>0||diff.add?.length||diff.remove?.length)&&source.updateData(diff),this._appliedGeoJson.set(resolvedSourceId,projection)}updateSourceData(sourceId,diff){if(!this._map||!this._styleLoaded||!this.isConnected||typeof sourceId!="string")return!1;const publicId=sourceId.trim(),resolved=this._appliedDataLayerIds.get(publicId)??(this.canonicalChoropleth?.sourceId===publicId?this._appliedChoroplethSourceId:void 0);if(!resolved)return!1;const source=this._map.getSource(resolved);return typeof source?.updateData!="function"?!1:(this._appliedGeoJson.delete(resolved),source.updateData(diff),!0)}get safeMaxBounds(){const bounds=this.maxBounds;if(!Array.isArray(bounds)||bounds.length!==2)return null;const[southWest,northEast]=bounds;if(!Array.isArray(southWest)||!Array.isArray(northEast))return null;const[west,south]=southWest,[east,north]=northEast,values=[west,south,east,north].map(Number);if(!values.every(value=>Number.isFinite(value)))return null;const[w,s,e,n]=values;return w>=e||s>=n||w<-180||e>180||s<-90||n>90?null:[[w,s],[e,n]]}applyMaxBounds(){const map=this._map;if(!map||typeof map.setMaxBounds!="function")return;const bounds=this.safeMaxBounds;let zoomBefore,centerBefore;try{if(zoomBefore=map.getZoom(),centerBefore=map.getCenter(),map.setMaxBounds(bounds),bounds===null||Number.isFinite(map.getZoom()))return}catch{}try{map.setMaxBounds(null)}catch{}typeof zoomBefore=="number"&&Number.isFinite(zoomBefore)&&map.setZoom(zoomBefore),centerBefore&&map.setCenter([centerBefore.lng,centerBefore.lat]),devWarnOnce("lyra-map-max-bounds-rejected","<lr-map>: maxBounds left maplibre-gl without a usable camera, so it was dropped and the camera restored. This is a peer limitation, not a bad value -- it shows up at sub-1 fractional zooms in wide containers. Raise the zoom, narrow the box, or leave maxBounds unset.")}get safeZoom(){return finiteRange(this.zoom,2,0,22)}get safeCenter(){const center=Array.isArray(this.center)?this.center:[];return[finiteRange(Number(center[0]),0,-180,180),finiteRange(Number(center[1]),0,-90,90)]}fitBounds(bounds,options={}){const box=normalizeFitBounds(bounds);if(!box)return devWarnOnce("lyra-map-fit-bounds-rejected",`<${this.localName}>: fitBounds() ignored a box that is not [[west, south], [east, north]] with finite coordinates, latitudes in [-90, 90], south <= north, and longitudes in [-180, 180] (east may run past 180, up to one full turn east of west, for a box crossing the antimeridian).`),!1;const settings=typeof options=="object"&&options!==null?options:{},maxZoom=settings.maxZoom,fit=Object.freeze({bounds:box,padding:normalizeFitPadding(settings.padding),maxZoom:isFiniteCoordinate(maxZoom)?finiteRange(maxZoom,22,0,22):void 0,animate:settings.animate!==!1}),map=this._map;return map?(this.pendingFit=void 0,this.applyFit(map,fit,fit.animate&&!prefersReducedMotion(this))):(this.pendingFit=Object.freeze({fit,center:snapshotCenter(this.center),zoom:this.zoom}),!0)}applyFit(map,fit,animate){if(typeof map.fitBounds!="function")return!1;const[[west,south],[east,north]]=fit.bounds;try{map.fitBounds([[west,south],[east,north]],{padding:{...fit.padding},...fit.maxZoom===void 0?{}:{maxZoom:fit.maxZoom},animate},{[FIT_EVENT_KEY]:this.fitToken})}catch{return!1}return!0}applyPendingFit(){const map=this._map,pending=this.pendingFit;!map||!pending||(this.pendingFit=void 0,!(!sameCenterValue(this.center,pending.center)||!Object.is(this.zoom,pending.zoom))&&this.applyFit(map,pending.fit,!1))}reflectCamera(map,source){const camera=readPeerCamera(map);if(!camera)return;const center=Object.freeze(camera.center),{zoom}=camera;this.reflectedCamera={center,zoom};const previousCenter=this._center;this._center=center,this.requestUpdate("center",previousCenter),this.zoom=zoom,this.emit("lr-map-view-change",{center,zoom,source})}pushCamera(changed){const reflected=this.reflectedCamera;this.reflectedCamera=void 0;const map=this._map;if(!map||!changed.has("center")&&!changed.has("zoom"))return;const center=this.safeCenter,zoom=this.safeZoom,shown=readPeerCamera(map),showsCenter=camera=>camera!==void 0&¢er[0]===camera.center[0]&¢er[1]===camera.center[1];let pushCenter=changed.has("center")&&!showsCenter(reflected)&&!showsCenter(shown),pushZoom=changed.has("zoom")&&zoom!==reflected?.zoom&&zoom!==shown?.zoom;if(!pushCenter&&!pushZoom)return;let interrupting=!1;try{interrupting=map.isMoving?.()===!0}catch{}interrupting&&(pushCenter=!showsCenter(shown),pushZoom=zoom!==shown?.zoom),this.writeCamera(()=>{pushCenter&&map.setCenter(center),pushZoom&&map.setZoom(zoom)})}writeCamera(write){const previous=this.writingCamera;this.writingCamera=!0;try{write()}finally{this.writingCamera=previous}}connectedCallback(){super.connectedCallback();const generation=++this._connectGeneration,IntersectionObserverCtor=ownerWindow(this)?.IntersectionObserver;if(this.visible=IntersectionObserverCtor===void 0,this.failure=void 0,this.loading=!0,this._webglReady=!1,IntersectionObserverCtor){const observer=new IntersectionObserverCtor(entries=>{entries[0]?.isIntersecting&&(this.visible=!0)});this.intersectionObserver=observer,observer.observe(this)}(async()=>{let mod;try{mod=await this.loadLibrary(this.engine)}catch{generation===this._connectGeneration&&this.isConnected&&this.failInitialization("missing-peer");return}if(!(generation!==this._connectGeneration||!this.isConnected)){if(this.loading=!1,!mod){this.failInitialization("missing-peer");return}if(this._maplibreModule=mod,!hasMapStyle(this.mapStyle)){this.failInitialization("style-required");return}if(!supportsWebGL2(this)){this.failInitialization("webgl-unavailable");return}this._webglReady=!0,await this.updateComplete,!(generation!==this._connectGeneration||!this.containerEl||!this.isConnected)&&this.tryConstructMap()}})()}disconnectedCallback(){super.disconnectedCallback(),this.disposeMap(),this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0;for(const marker of this._markerInstances.values()){const markerElement=marker.getElement?.();markerElement&&this.markerActivationDetails.delete(markerElement),marker.remove()}this._markerInstances.clear(),this._markerColors.clear(),this._markerLabels.clear(),this._markerPopupIds.clear(),this._markerSources.clear()}failureMessage(reason=this.failure??"initialization-failed"){switch(reason){case"missing-peer":return this.localize("mapMissingLibrary",void 0,{package:this.engine==="maplibre"?"maplibre-gl":"@aceshooting/lyra-map"});case"style-required":return this.localize("mapStyleRequired");case"webgl-unavailable":return this.localize("mapWebglUnavailable");case"initialization-failed":return this.localize("mapInitializationFailed")}}failInitialization(reason,partialMap){try{partialMap?.remove()}catch{}this.disposeMap(),this.loading=!1,this.failure=reason,this.announcements.announceAssertive(this.failureMessage(reason))}scheduleStyleRequiredFailure(){const generation=this._connectGeneration,module=this._maplibreModule;this.scheduleAfterUpdate(()=>{!this.isConnected||generation!==this._connectGeneration||module!==this._maplibreModule||hasMapStyle(this.mapStyle)||this.failInitialization("style-required")},"map-style-required")}disposeMap(){this.cancelFeaturePreparation(),this.preparedFeatureSignature=void 0,this.pendingMapLoad=!1,this.rebuildGeneratedLayers=!1,this.stopObservingMapAllocation(),this.stopObservingPeerChrome();try{this._map?.remove()}catch{}this._map=void 0,this._styleLoaded=!1,this.boxZoomSettling=!1,this.reflectedCamera=void 0,this._appliedChoroplethSourceId=void 0,this._appliedFillLayerId=void 0,this.appliedChoroplethPaintKey=void 0,this._appliedDataLayerIds.clear(),this._appliedDataLayerShapes.clear(),this.appliedLayerPaintKeys.clear(),this.appliedPointIcons.clear(),this.appliedPointPaint.clear(),this.appliedPointMuting.clear(),this._appliedGeoJson.clear()}adoptedCallback(){super.adoptedCallback(),this.hostDescription.adopted(),this.stopObservingMapAllocation(),this.stopObservingPeerChrome(),this.announcements.adopted(),this._map&&this.containerEl&&this.isConnected&&this.observeMapAllocation(this._map,this.containerEl)}tryConstructMap(){if(this._map||!this._maplibreModule||!this._webglReady||!this.containerEl||!this.visible||!this.isConnected)return;if(!hasMapStyle(this.mapStyle)){this.scheduleStyleRequiredFailure();return}const mod=this._maplibreModule;let candidate;try{candidate=new mod.Map({container:this.containerEl,style:this.mapStyle,center:this.safeCenter,zoom:this.safeZoom,...typeof this.renderWorldCopies=="boolean"?{renderWorldCopies:this.renderWorldCopies}:{},locale:{"Map.Title":this.effectiveMapLabel,"Marker.Title":this.localize("mapMarker"),"Popup.Close":this.localize("close"),"AttributionControl.ToggleAttribution":this.localize("mapToggleAttribution"),"AttributionControl.MapFeedback":this.localize("mapFeedback"),"NavigationControl.ZoomIn":this.localize("zoomIn"),"NavigationControl.ZoomOut":this.localize("zoomOut"),"NavigationControl.ResetBearing":this.localize("mapResetNorth")}}),candidate.on("error",event=>{if(this._map===candidate&&!this._styleLoaded){this.failInitialization("initialization-failed");return}console.error("lr-map:",event.error??event)}),candidate.on("load",()=>{if(this._map===candidate)try{this._styleLoaded=!0,this.pendingMapLoad=!0,this.rebuildGeneratedLayers=!0,this.applyMarkers(),this.reconcileGeneratedLayers()}catch{this.failInitialization("initialization-failed")}}),candidate.on("click",event=>{if(this._map!==candidate)return;const fillLayerId=this._appliedFillLayerId,layerIds=[];fillLayerId&&candidate.getLayer(fillLayerId)&&layerIds.push(fillLayerId);for(const resolvedSourceId of this._appliedDataLayerIds.values())for(const suffix of QUERYABLE_DATA_LAYER_SUFFIXES){const layerId=`${resolvedSourceId}${suffix}`;candidate.getLayer(layerId)&&layerIds.push(layerId)}const hit=(layerIds.length?candidate.queryRenderedFeatures(event.point,{layers:layerIds}):[])[0],hitLayerId=hit?.layer?.id;let origin,sourceId;if(hitLayerId!==void 0){if(hitLayerId===fillLayerId)origin="choropleth";else for(const[publicSourceId,resolvedSourceId]of this._appliedDataLayerIds)if(hitLayerId.startsWith(`${resolvedSourceId}-`)){origin=hitLayerId===`${resolvedSourceId}-cluster`?"cluster":"data-layer",sourceId=publicSourceId;break}}this.emit("lr-map-click",{lngLat:[event.lngLat.lng,event.lngLat.lat],feature:hit,origin,sourceId})}),candidate.on("boxzoomend",()=>{this._map===candidate&&(this.boxZoomSettling=!0)}),candidate.on("moveend",event=>{if(this._map!==candidate)return;const fit=event?.[FIT_EVENT_KEY]===this.fitToken,afterBoxZoom=!fit&&this.boxZoomSettling;if(fit||(this.boxZoomSettling=!1),this.writingCamera)return;const source=fit?"fit":event?.originalEvent||afterBoxZoom?"user":void 0;source&&this.reflectCamera(candidate,source)});const canvas=candidate.getCanvas?.();canvas&¬ifyMapCanvasReady(this,canvas),this._map=candidate,this.syncMapSemantics(),this.observeMapAllocation(candidate,this.containerEl),this.observePeerChrome(),this.failure=void 0}catch{this.failInitialization("initialization-failed",candidate);return}this.applyMaxBounds(),this.pendingFit&&this.scheduleAfterUpdate(()=>this.applyPendingFit(),"map-pending-fit")}requestUpdate(...args){args[0]===void 0&&(this.geoJsonRefreshRequested=!0),super.requestUpdate(...args),this.isUpdatePending&&(args[0]===void 0||["label","lang","locale","strings","markers","legend","legendGradient","hasLegendSlot","hasLegendStartSlot"].includes(String(args[0])))&&(this.semanticsStale=!0),this.isUpdatePending&&(args[0]===void 0||["label","lang","locale","strings","markers"].includes(String(args[0])))&&(this.markerSemanticsStale=!0)}updated(changed){if(super.updated(changed),this.setAttribute("aria-busy",String(this.loading)),this.legendCollapsed&&(changed.has("legendOpen")||changed.has("legendCollapsible"))){const legend=this.shadowRoot?.querySelector('[part="legend"]');legend&&(legend.scrollTop=0)}if((changed.has("choropleth")||changed.has("legendGradient"))&&this.warnOnLegendChoroplethMismatch(),changed.has("visible")&&this.visible&&this.tryConstructMap(),changed.has("mapStyle")&&(this._styleGeneration+=1,this.cancelFeaturePreparation(),this.preparedFeatureSignature=void 0),changed.has("mapStyle")&&!hasMapStyle(this.mapStyle)&&this._maplibreModule)this.scheduleStyleRequiredFailure();else if(changed.has("mapStyle")&&!this._map&&this._maplibreModule&&hasMapStyle(this.mapStyle))this.tryConstructMap();else if(changed.has("mapStyle")&&this._map){this._styleLoaded=!1,this._appliedChoroplethSourceId=void 0,this._appliedFillLayerId=void 0,this.appliedChoroplethPaintKey=void 0;const map=this._map,style=this.mapStyle,generation=this._connectGeneration,styleGeneration=this._styleGeneration,current=()=>this.isConnected&&this._map===map&&generation===this._connectGeneration&&styleGeneration===this._styleGeneration&&this.mapStyle===style,failStyle=()=>{current()&&this.scheduleAfterUpdate(()=>{current()&&this.failInitialization("initialization-failed")},`map-style-failure-${styleGeneration}`)};try{for(const sourceId of this.appliedPointIcons.keys())this.removePointIcons(sourceId);map.once("style.load",()=>{if(current())try{this._styleLoaded=!0,this._appliedDataLayerIds.clear(),this._appliedDataLayerShapes.clear(),this.appliedLayerPaintKeys.clear(),this.appliedPointPaint.clear(),this.appliedPointMuting.clear(),this._appliedGeoJson.clear(),this.rebuildGeneratedLayers=!0,this.reconcileGeneratedLayers()}catch{failStyle()}}),map.setStyle(style)}catch{failStyle()}}else this._styleLoaded&&(this.refreshingGeoJson||changed.has("dataLayers")||changed.has("choropleth"))&&this.reconcileGeneratedLayers();changed.has("hiddenCategories")&&this._map&&this._styleLoaded&&this.refreshThemePaint(),this.pushCamera(changed),changed.has("maxBounds")&&this._map&&this.writeCamera(()=>this.applyMaxBounds()),changed.has("markers")&&this._map&&this.applyMarkers(),this.semanticsStale&&(this.semanticsStale=!1,this.syncMapSemantics(this.markerSemanticsStale),this.markerSemanticsStale=!1)}willUpdate(changed){if(super.willUpdate(changed),this.refreshingGeoJson=this.geoJsonRefreshRequested,this.geoJsonRefreshRequested=!1,this.refreshingGeoJson){const choropleth=this.canonicalChoropleth;choropleth&&(this._canonicalChoropleth={...choropleth,geojsonProjection:projectAdmittedGeoJson(choropleth.geojson,!0)}),this._canonicalDataLayers=this.canonicalDataLayers.map(layer=>({...layer,geojsonProjection:projectAdmittedGeoJson(layer.geojson,!0)}))}(changed.has("legendGradient")||changed.has("dataLayers"))&&(this.legendIsLine=this.legendDescribesLine()),changed.has("mapStyle")&&!this._map&&this._maplibreModule&&hasMapStyle(this.mapStyle)&&(this._webglReady||(this._webglReady=supportsWebGL2(this)),this.failure=this._webglReady?void 0:"webgl-unavailable",this._webglReady||(this.loading=!1,this.announcements.announceAssertive(this.failureMessage("webgl-unavailable"))))}syncPaintTheme(){const sources=[this.dataLayers,this.choropleth];if(!this.paintThemeSources||sources.some((source,index)=>source!==this.paintThemeSources[index])){this.paintThemeSources=sources;const tokens2=new Set([...Object.values(TONE_TOKEN),...Object.values(ON_TONE_TOKEN),"--lr-map-choropleth-fill-opacity","--lr-map-hidden-category-opacity"]),inputs=JSON.stringify([this.canonicalDataLayers.map(({geojson:_geojson,geojsonProjection:_projection,...paint})=>paint),[this.canonicalChoropleth?.stops,this.canonicalChoropleth?.stepBaseColor]]);for(const match of inputs.matchAll(/var\(\s*(--[\w-]+)/g))tokens2.add(match[1]);this.paintThemeTokens=[...tokens2]}const style=ownerWindow(this)?.getComputedStyle(this);if(!style)return!1;const tokens=new Set(this.paintThemeTokens),values=[style.color,style.colorScheme];for(const token of tokens){const value=style.getPropertyValue(token).trim();if(values.push(token,value),tokens.size<512)for(const match of value.matchAll(/var\(\s*(--[\w-]+)/g))tokens.add(match[1])}const key=JSON.stringify(values);return this.paintThemeKey===key?!1:(this.paintThemeKey=key,paintColorCache.delete(this),this.appliedLayerPaintKeys.clear(),this.appliedChoroplethPaintKey=void 0,!0)}refreshThemePaint(){if(paintColorCache.delete(this),!this._map||!this._styleLoaded||this.preparingFeatures)return;const fillOpacity=choroplethFillOpacity(this);if(this._appliedFillLayerId){const choropleth=this.canonicalChoropleth;choropleth&&choropleth.stops.length>0&&this._map.setPaintProperty(this._appliedFillLayerId,"fill-color",this.choroplethColorExpression(choropleth)),this._map.setPaintProperty(this._appliedFillLayerId,"fill-opacity",fillOpacity)}const dataLayersBySourceId=new Map(this.canonicalDataLayers.map(layer=>[layer.sourceId,layer]));for(const[publicSourceId,sourceId]of this._appliedDataLayerIds){const dataLayer=dataLayersBySourceId.get(publicSourceId);if(!dataLayer)continue;this.paintDataLayer(sourceId,dataLayer);const{geojson:_geojson,geojsonProjection:_projection,...paint}=dataLayer;this.appliedLayerPaintKeys.set(sourceId,JSON.stringify(paint))}}cancelFeaturePreparation(){this.featureGeneration+=1,this.featureAbort?.abort(),this.featureAbort=void 0,this.preparingFeatures=!1}generatedFeatureRequirements(){const sources={},layers=[],add=(source,types)=>{for(const[index,type]of types.entries())layers.push({id:`${source}-${type}-${index}`,type,source})},choropleth=this.canonicalChoropleth;choropleth&&(sources.choropleth={type:"geojson",data:choropleth.geojson},choropleth.stops.length&&add("choropleth",["fill"]));for(const[index,layer]of this.canonicalDataLayers.entries()){const source=`data-${index}`,cluster=layer.cluster;sources[source]={type:"geojson",data:layer.geojson,...cluster?{cluster:!0,clusterRadius:cluster.radius,clusterMaxZoom:cluster.maxZoom}:{}},layer.kind==="heatmap"?add(source,["heatmap"]):(add(source,cluster?["circle"]:["fill","line","circle"]),(cluster&&this.styleProvidesGlyphs()||layer.point?.iconField&&layer.point.icons.length)&&add(source,["symbol"]))}return{sources,layers}}reconcileGeneratedLayers(){const map=this._map;if(!map||!this._styleLoaded)return;this.cancelFeaturePreparation();const generation=this.featureGeneration,connection=this._connectGeneration,styleGeneration=this._styleGeneration,style=this.mapStyle,dataLayers=this.dataLayers,choropleth=this.choropleth,current=()=>this.isConnected&&this._map===map&&generation===this.featureGeneration&&connection===this._connectGeneration&&styleGeneration===this._styleGeneration&&style===this.mapStyle&&dataLayers===this.dataLayers&&choropleth===this.choropleth,apply=()=>{const next=this.canonicalChoropleth,nextId=next?this.resolveChoroplethSourceId(next.sourceId):void 0;this._appliedChoroplethSourceId&&this._appliedChoroplethSourceId!==nextId&&this.removeChoropleth(),this.rebuildGeneratedLayers?(this.applyChoropleth(),this.applyDataLayers(),this.rebuildGeneratedLayers=!1):(this.applyDataLayers(),this.applyChoropleth()),this.pendingMapLoad&&(this.pendingMapLoad=!1,this.emit("lr-map-load"))},fail=()=>{if(current()){if(this.pendingMapLoad){this.failInitialization("initialization-failed");return}this.scheduleAfterUpdate(()=>{current()&&this.failInitialization("initialization-failed")},`map-feature-failure-${generation}`)}};try{if(!map.prepareFeatures){apply();return}const requirements=this.generatedFeatureRequirements(),signature=JSON.stringify([Object.values(requirements.sources??{}).map(source=>source.type),(requirements.layers??[]).map(layer=>layer.type)]);if(signature===this.preparedFeatureSignature){apply();return}const controller=new AbortController;this.featureAbort=controller,this.preparingFeatures=!0,(async()=>{try{if(await map.prepareFeatures(requirements,{signal:controller.signal}),!current()||controller.signal.aborted)return;this.featureAbort=void 0,this.preparingFeatures=!1,this.preparedFeatureSignature=signature,apply()}catch{if(!current()||controller.signal.aborted)return;this.preparingFeatures=!1,fail()}})()}catch{fail()}}applyChoropleth(){if(!this._map)return;this.syncPaintTheme();const choropleth=this.canonicalChoropleth;if(!choropleth){this.removeChoropleth();return}const{geojson,geojsonProjection,stops}=choropleth,sourceId=this.resolveChoroplethSourceId(choropleth.sourceId),fillLayerId=`${sourceId}-fill`;this._appliedChoroplethSourceId&&this._appliedChoroplethSourceId!==sourceId&&this.removeChoropleth(),warnOnUntileableProperties(geojsonProjection,"choropleth");const existingSource=this._map.getSource(sourceId);if(existingSource?this.pushGeoJson(existingSource,sourceId,geojson,geojsonProjection):(this._map.addSource(sourceId,{type:"geojson",data:geojson}),this._appliedGeoJson.set(sourceId,geojsonProjection)),this._appliedChoroplethSourceId=sourceId,stops.length===0)return;const{geojson:_geojson,geojsonProjection:_projection,...paint}=choropleth,paintKey=JSON.stringify(paint);if(this.appliedChoroplethPaintKey===paintKey&&this._map.getLayer(fillLayerId))return;this.appliedChoroplethPaintKey=paintKey;const colorExpr=this.choroplethColorExpression(choropleth);this._map.getLayer(fillLayerId)?(this._map.setPaintProperty(fillLayerId,"fill-color",colorExpr),this._map.setPaintProperty(fillLayerId,"fill-opacity",choroplethFillOpacity(this))):this._map.addLayer({id:fillLayerId,type:"fill",source:sourceId,paint:{"fill-color":colorExpr,"fill-opacity":choroplethFillOpacity(this)}}),this._appliedFillLayerId=fillLayerId}choroplethColorExpression(choropleth){const{field,stops}=choropleth,resolvedStops=stops.map(([value,color])=>[value,resolvedLayerColor(this,color,void 0)]);let colorExpr;if(choropleth.interpolation==="step"){const base=choropleth.stepBaseColor?resolvedLayerColor(this,choropleth.stepBaseColor,void 0):resolvedStops[0][1];colorExpr=["step",["get",field],base];for(const[value,color]of resolvedStops)colorExpr.push(value,color)}else{colorExpr=["interpolate",choropleth.interpolation==="logarithmic"?["exponential",CHOROPLETH_LOG_INTERPOLATION_BASE]:["linear"],["get",field]];for(const[value,color]of resolvedStops)colorExpr.push(value,color)}return colorExpr}resolveChoroplethSourceId(sourceId){const dataSourceIds=new Set(this.canonicalDataLayers.map(layer=>layer.sourceId));let resolved=sourceId;for(;dataSourceIds.has(resolved);)resolved=`lr-choropleth-${resolved}`;return resolved}removeChoropleth(){!this._map||!this._appliedChoroplethSourceId||(this._appliedFillLayerId&&this._map.getLayer(this._appliedFillLayerId)&&this._map.removeLayer(this._appliedFillLayerId),this._map.getSource(this._appliedChoroplethSourceId)&&this._map.removeSource(this._appliedChoroplethSourceId),this._appliedGeoJson.delete(this._appliedChoroplethSourceId),this._appliedChoroplethSourceId=void 0,this._appliedFillLayerId=void 0,this.appliedChoroplethPaintKey=void 0)}applyDataLayers(){if(!this._map)return;this.syncPaintTheme();const layers=this.canonicalDataLayers,nextIds=new Set(layers.map(layer=>layer.sourceId));for(const publicSourceId of this._appliedDataLayerIds.keys())nextIds.has(publicSourceId)||this.removeDataLayer(publicSourceId);for(const layer of layers){const{sourceId:publicSourceId,geojson,geojsonProjection}=layer,shape=dataLayerShape(layer),appliedShape=this._appliedDataLayerShapes.get(publicSourceId);appliedShape!==void 0&&appliedShape!==shape&&this.removeDataLayer(publicSourceId);const sourceId=this.resolveDataLayerSourceId(publicSourceId);warnOnUntileableProperties(geojsonProjection,publicSourceId);const cluster=layer.cluster,existingSource=this._map.getSource(sourceId);existingSource?this.pushGeoJson(existingSource,sourceId,geojson,geojsonProjection):(this._map.addSource(sourceId,{type:"geojson",data:geojson,...cluster?{cluster:!0,clusterRadius:cluster.radius,clusterMaxZoom:cluster.maxZoom}:{}}),this._appliedGeoJson.set(sourceId,geojsonProjection));const{geojson:_geojson,geojsonProjection:_projection,...paint}=layer,paintKey=JSON.stringify(paint);(!existingSource||this.appliedLayerPaintKeys.get(sourceId)!==paintKey)&&(this.applyDataLayerRendering(sourceId,layer),this.appliedLayerPaintKeys.set(sourceId,paintKey)),this._appliedDataLayerIds.set(publicSourceId,sourceId),this._appliedDataLayerShapes.set(publicSourceId,shape)}}applyDataLayerRendering(sourceId,layer){if(layer.kind==="heatmap"){this.applyHeatmapLayer(sourceId,layer);return}const cluster=layer.cluster;cluster?this.applyClusterLayers(sourceId,layer,cluster):this.applyGeometryLayers(sourceId,layer),this.applyPointIcons(sourceId,layer)}paintDataLayer(sourceId,layer){if(layer.kind==="heatmap"){this.paintHeatmapLayer(sourceId,layer);return}const cluster=layer.cluster;cluster?this.paintClusterLayers(sourceId,layer,cluster):this.paintGeometryLayers(sourceId,layer),this.paintPointIcons(sourceId,layer)}applyGeometryLayers(sourceId,layer){if(!this._map)return;const tone=layer.tone,color=resolvedLayerColor(this,layer.color,tone),stroke=resolvedLayerColor(this,layer.strokeColor??layer.color,tone),fillId=`${sourceId}-fill`,lineId=`${sourceId}-line`,circleId=`${sourceId}-circle`;this._map.getLayer(fillId)||this._map.addLayer({id:fillId,type:"fill",source:sourceId,filter:["==",["geometry-type"],"Polygon"],paint:{"fill-color":color,"fill-opacity":choroplethFillOpacity(this)}}),this._map.getLayer(lineId)||this._map.addLayer({id:lineId,type:"line",source:sourceId,filter:["in",["geometry-type"],["literal",["LineString","Polygon"]]],paint:{"line-color":this.lineColor(layer),"line-width":layer.line?.width??2,...layer.line?{"line-opacity":layer.line.opacity}:{}}}),this._map.getLayer(circleId)||this._map.addLayer({id:circleId,type:"circle",source:sourceId,filter:["==",["geometry-type"],"Point"],paint:{"circle-color":stroke,"circle-radius":5}}),this._map.setPaintProperty(lineId,"line-width",layer.line?.width??2),this._map.setPaintProperty(lineId,"line-opacity",layer.line?.opacity??1),this.paintGeometryLayers(sourceId,layer)}paintGeometryLayers(sourceId,layer){if(!this._map)return;const tone=layer.tone,color=resolvedLayerColor(this,layer.color,tone);this._map.setPaintProperty(`${sourceId}-fill`,"fill-color",color),this._map.setPaintProperty(`${sourceId}-fill`,"fill-opacity",choroplethFillOpacity(this)),this._map.setPaintProperty(`${sourceId}-line`,"line-color",this.lineColor(layer)),this.paintPoints(sourceId,layer)}lineColor(layer){const fallback=resolvedLayerColor(this,layer.strokeColor??layer.color,layer.tone),line=layer.line;return!line?.field||line.stops.length<2?fallback:lineColorExpression(line.field,line.stops.map(([value,color])=>[value,resolvedLayerColor(this,color,layer.tone)]),fallback)}mutedPointOpacity(layerId,field){const muted=field?this.hiddenCategories:EMPTY_HIDDEN_CATEGORIES;if(!muted.length)return this.appliedPointMuting.delete(layerId)?1:void 0;this.appliedPointMuting.add(layerId);const dim=hiddenCategoryOpacity(this);return mutedCategoryOpacityExpression(field,muted,dim)}paintPoints(sourceId,layer){if(!this._map)return;const point=layer.point,fallback=resolvedLayerColor(this,layer.strokeColor??layer.color,layer.tone),color=pointColorExpression(point?.field,point?.field&&point.colors.length?point.colors.map(([value,paint])=>[value,resolvedLayerColor(this,paint,layer.tone)]):[],fallback),id=`${sourceId}-circle`;this._map.setPaintProperty(id,"circle-color",color);const opacity=this.mutedPointOpacity(id,point?.field);opacity!==void 0&&(this._map.setPaintProperty(id,"circle-opacity",opacity),this._map.setPaintProperty(id,"circle-stroke-opacity",opacity)),!(!point&&!this.appliedPointPaint.has(sourceId))&&(this._map.setPaintProperty(id,"circle-radius",pointRadiusExpression(point?.radius??5)),this._map.setPaintProperty(id,"circle-stroke-width",point?.strokeWidth??0),this._map.setPaintProperty(id,"circle-stroke-color",point?.strokeColor?resolvedLayerColor(this,point.strokeColor,layer.tone):fallback),point?this.appliedPointPaint.add(sourceId):this.appliedPointPaint.delete(sourceId))}pointIconColor(layer){const resolved=resolvedLayerColor(this,layer.point?.iconColor??`var(${ON_TONE_TOKEN[layer.tone??"accent"]})`,layer.tone);return resolveCanvasColor(this,resolved,dataLayerColor(this,layer.tone))}removePointIcons(sourceId){const applied=this.appliedPointIcons.get(sourceId);if(!applied||!this._map)return;const id=`${sourceId}-point-icon`;this._map.getLayer(id)&&this._map.removeLayer(id);for(const{id:imageId}of applied.icons)this._map.hasImage?.(imageId)&&this._map.removeImage?.(imageId);this.appliedPointIcons.delete(sourceId),this.appliedPointMuting.delete(id)}applyPointIcons(sourceId,layer){const map=this._map,point=layer.point,signature=JSON.stringify([point?.iconField,point?.iconSize,point?.icons]);if(this.appliedPointIcons.get(sourceId)?.signature===signature){this.paintPointIcons(sourceId,layer);return}if(this.removePointIcons(sourceId),!point?.iconField||!point.icons.length||!map||typeof map.addImage!="function"||typeof map.hasImage!="function"||typeof map.updateImage!="function"||typeof map.removeImage!="function")return;const color=this.pointIconColor(layer),icons=[];this.appliedPointIcons.set(sourceId,{signature,color,icons});for(const icon of point.icons){const raster=rasterPointIcon(this,icon,color);if(!raster)continue;let id;do id=`lr-point-icon-${this.nextPointIconId++}`;while(map.hasImage(id));icons.push({id,icon}),map.addImage(id,raster,{pixelRatio:2})}icons.length&&map.addLayer({id:`${sourceId}-point-icon`,type:"symbol",source:sourceId,filter:layer.cluster?["all",["==",["geometry-type"],"Point"],["!",["has","point_count"]]]:["==",["geometry-type"],"Point"],layout:{"icon-image":["match",["get",point.iconField],...icons.flatMap(({id,icon})=>[icon.value,id]),""],"icon-size":point.iconSize/(POINT_ICON_RASTER_SIZE/2),"icon-allow-overlap":!0,"icon-ignore-placement":!0}})}paintPointIcons(sourceId,layer){const applied=this.appliedPointIcons.get(sourceId);if(!applied)return;const iconLayerId=`${sourceId}-point-icon`,opacity=this.mutedPointOpacity(iconLayerId,layer.point?.iconField);opacity!==void 0&&this._map?.setPaintProperty(iconLayerId,"icon-opacity",opacity);const color=this.pointIconColor(layer);if(color!==applied.color){for(const{id,icon}of applied.icons){const raster=rasterPointIcon(this,icon,color);raster&&this._map?.updateImage?.(id,raster)}applied.color=color}}clusterColorExpression(layer,cluster){const tone=layer.tone;return clusterColorExpression(cluster.colorSteps.map(([count,stepColor])=>[count,resolvedLayerColor(this,stepColor,tone)]),()=>resolvedLayerColor(this,layer.color,tone))}applyClusterLayers(sourceId,layer,cluster){if(!this._map)return;const tone=layer.tone,stroke=resolvedClusterStrokeColor(this,cluster.strokeColor,layer),clusterId=`${sourceId}-cluster`,countId=`${sourceId}-cluster-count`,circleId=`${sourceId}-circle`,clusterColor=this.clusterColorExpression(layer,cluster),clusterRadius=stepExpression(["get","point_count"],cluster.radiusSteps),countColor=resolvedClusterCountColor(this,cluster.countColor)??resolvedLayerColor(this,`var(${ON_TONE_TOKEN[tone??"accent"]})`,tone),countHaloColor=resolvedClusterCountColor(this,cluster.countHaloColor);this._map.getLayer(clusterId)||this._map.addLayer({id:clusterId,type:"circle",source:sourceId,filter:["has","point_count"],paint:{"circle-color":clusterColor,"circle-radius":clusterRadius,"circle-stroke-width":1,"circle-stroke-color":stroke}}),this.styleProvidesGlyphs()&&!this._map.getLayer(countId)&&this._map.addLayer({id:countId,type:"symbol",source:sourceId,filter:["has","point_count"],layout:{"text-field":["get","point_count_abbreviated"],"text-size":12,...cluster.countFont?{"text-font":[...cluster.countFont]}:{}},paint:{"text-color":countColor,...countHaloColor?{"text-halo-color":countHaloColor,"text-halo-width":cluster.countHaloWidth}:{}}}),this._map.getLayer(circleId)||this._map.addLayer({id:circleId,type:"circle",source:sourceId,filter:["all",["==",["geometry-type"],"Point"],["!",["has","point_count"]]],paint:{"circle-color":stroke,"circle-radius":5}}),this.paintClusterLayers(sourceId,layer,cluster)}paintClusterLayers(sourceId,layer,cluster){if(!this._map)return;const tone=layer.tone,stroke=resolvedClusterStrokeColor(this,cluster.strokeColor,layer),clusterId=`${sourceId}-cluster`;if(this._map.setPaintProperty(clusterId,"circle-color",this.clusterColorExpression(layer,cluster)),this._map.setPaintProperty(clusterId,"circle-radius",stepExpression(["get","point_count"],cluster.radiusSteps)),this._map.setPaintProperty(clusterId,"circle-stroke-color",stroke),this.styleProvidesGlyphs()){this._map.setPaintProperty(`${sourceId}-cluster-count`,"text-color",resolvedClusterCountColor(this,cluster.countColor)??resolvedLayerColor(this,`var(${ON_TONE_TOKEN[tone??"accent"]})`,tone));const countHaloColor=resolvedClusterCountColor(this,cluster.countHaloColor);this._map.setPaintProperty(`${sourceId}-cluster-count`,"text-halo-color",countHaloColor??null),this._map.setPaintProperty(`${sourceId}-cluster-count`,"text-halo-width",countHaloColor?cluster.countHaloWidth:null)}this.paintPoints(sourceId,layer)}applyHeatmapLayer(sourceId,layer){if(!this._map)return;const heatmapId=`${sourceId}-heatmap`,options=layer.heatmap,weight=heatmapWeightExpression(options),color=this.heatmapColorExpression(layer),radius=heatmapZoomValue(options?.radius,DEFAULT_HEATMAP_RADIUS,1,200),intensity=heatmapZoomValue(options?.intensity,DEFAULT_HEATMAP_INTENSITY,0,100),opacity=finiteRange(options?.opacity??Number.NaN,1,0,1);if(!this._map.getLayer(heatmapId)){this._map.addLayer({id:heatmapId,type:"heatmap",source:sourceId,paint:{...weight?{"heatmap-weight":weight}:{},"heatmap-intensity":intensity,"heatmap-color":color,"heatmap-radius":radius,...options?.opacity===void 0?{}:{"heatmap-opacity":opacity}}});return}this.paintHeatmapLayer(sourceId,layer)}paintHeatmapLayer(sourceId,layer){if(!this._map)return;const heatmapId=`${sourceId}-heatmap`;this._map.setPaintProperty(heatmapId,"heatmap-weight",heatmapWeightExpression(layer.heatmap)??1),this._map.setPaintProperty(heatmapId,"heatmap-intensity",heatmapZoomValue(layer.heatmap?.intensity,DEFAULT_HEATMAP_INTENSITY,0,100)),this._map.setPaintProperty(heatmapId,"heatmap-color",this.heatmapColorExpression(layer)),this._map.setPaintProperty(heatmapId,"heatmap-radius",heatmapZoomValue(layer.heatmap?.radius,DEFAULT_HEATMAP_RADIUS,1,200)),this._map.setPaintProperty(heatmapId,"heatmap-opacity",finiteRange(layer.heatmap?.opacity??Number.NaN,1,0,1))}heatmapColorExpression(layer){const tone=layer.tone,authored=(layer.heatmap?.stops??[]).map(([density,color])=>[density,resolvedLayerColor(this,color,tone)]);return heatmapColorExpression(authored,()=>HEATMAP_RAMP_TOKENS.map(([density,token])=>[density,resolvedLayerColor(this,`var(${token})`,tone)]))}styleProvidesGlyphs(){try{const liveGlyphs=this._map?.getStyle?.()?.glyphs;if(typeof liveGlyphs=="string"&&liveGlyphs.trim().length>0)return!0}catch{}const declared=this.mapStyle,declaredGlyphs=declared&&typeof declared=="object"?declared.glyphs:void 0;return typeof declaredGlyphs=="string"&&declaredGlyphs.trim().length>0}resolveDataLayerSourceId(publicSourceId){const applied=this._appliedDataLayerIds.get(publicSourceId);if(applied)return applied;let sourceId;do sourceId=`lr-data-layer-${this._nextDataLayerId++}`;while(this._map?.getSource(sourceId)||DATA_LAYER_SUFFIXES.some(suffix=>this._map?.getLayer(`${sourceId}${suffix}`)));return sourceId}removeDataLayer(publicSourceId){if(!this._map)return;const sourceId=this._appliedDataLayerIds.get(publicSourceId);if(sourceId){this.removePointIcons(sourceId),this.appliedPointPaint.delete(sourceId);for(const suffix of DATA_LAYER_SUFFIXES){const layerId=`${sourceId}${suffix}`;this.appliedPointMuting.delete(layerId),this._map.getLayer(layerId)&&this._map.removeLayer(layerId)}this._map.getSource(sourceId)&&this._map.removeSource(sourceId),this._appliedDataLayerIds.delete(publicSourceId),this._appliedDataLayerShapes.delete(publicSourceId),this._appliedGeoJson.delete(sourceId),this.appliedLayerPaintKeys.delete(sourceId)}}applyMarkers(){const map=this._map,mod=this._maplibreModule;if(!map||!mod)return;const visible=new Set,coordCounts=new Map,explicitIds=new Set;for(const m of this.canonicalMarkers){const lngLat=m.lngLat,mapLngLat=[lngLat[0],lngLat[1]];let key,id;if(m.id!==void 0){if(id=m.id,explicitIds.has(id))continue;explicitIds.add(id),key=`id:${id}`}else{const coordKey=`${lngLat[0]},${lngLat[1]}`,occurrence=coordCounts.get(coordKey)??0;coordCounts.set(coordKey,occurrence+1),key=`coordinate:${coordKey}#${occurrence}`}visible.add(key);let existing=this._markerInstances.get(key);const markerColor=sanitizeCssColor(m.color)??(m.color===void 0?"currentColor":void 0),previous=this._markerSources.get(key);this._markerSources.set(key,m);const sameColor=this._markerColors.get(key)===markerColor,sameContent=previous!==void 0&&previous.label===m.label&&Object.is(previous.unsafeHtml,m.unsafeHtml);if(existing&&sameColor&&sameContent&&previous.lngLat[0]===lngLat[0]&&previous.lngLat[1]===lngLat[1])continue;if(existing&&!sameColor){const existingElement=existing.getElement?.();existingElement&&this.markerActivationDetails.delete(existingElement),existing.remove(),this._markerInstances.delete(key),this._markerColors.delete(key),existing=void 0}if(existing){existing.setLngLat(mapLngLat);const popup=existing.getPopup();if(!m.unsafeHtml&&!m.label)popup&&existing.setPopup(void 0);else if(popup)sameContent||setPopupContent(popup,m);else{const nextPopup=setPopupContent(new mod.Popup({offset:12}),m);existing.setPopup(nextPopup),this.configurePopupSemantics(key,existing,nextPopup)}}else{const marker=new mod.Marker(markerColor?{color:markerColor}:void 0).setLngLat(mapLngLat);if(m.unsafeHtml||m.label){const popup=setPopupContent(new mod.Popup({offset:12}),m);marker.setPopup(popup),this.configurePopupSemantics(key,marker,popup)}marker.addTo(map),this._markerInstances.set(key,marker),this._markerColors.set(key,markerColor)}const markerLabel=m.label?.trim()||markerPopupText(this,m.unsafeHtml);this._markerLabels.set(key,markerLabel||void 0);const markerElement=this._markerInstances.get(key)?.getElement?.();if(markerElement){addPartToken(markerElement,"marker");const currentMarker=this._markerInstances.get(key);this.configureMarkerInteraction(markerElement,{id,lngLat,marker:m},markerLabel);const popup=currentMarker?.getPopup();popup&¤tMarker?(this.configurePopupSemantics(key,currentMarker,popup),this.syncPopupSemantics(key,currentMarker,popup)):(markerElement.removeAttribute("aria-controls"),markerElement.removeAttribute("aria-expanded"),markerElement.removeAttribute("aria-haspopup"))}}for(const[key,marker]of this._markerInstances)if(!visible.has(key)){const markerElement=marker.getElement?.();markerElement&&this.markerActivationDetails.delete(markerElement),marker.remove(),this._markerInstances.delete(key),this._markerColors.delete(key),this._markerLabels.delete(key),this._markerPopupIds.delete(key),this._markerSources.delete(key)}}configureMarkerInteraction(markerElement,activation,markerLabel=activation.marker.label?.trim()||markerPopupText(this,activation.marker.unsafeHtml)){this.markerActivationDetails.set(markerElement,activation),markerElement.setAttribute("role","button"),markerElement.tabIndex=0,markerElement.setAttribute("aria-label",markerLabel||this.localize("mapMarker")),markerElement.setAttribute("lang",this.effectiveLocale),!this.configuredMarkerElements.has(markerElement)&&(this.configuredMarkerElements.add(markerElement),markerElement.addEventListener("click",event=>{event.defaultPrevented||this.emitMarkerActivation(markerElement,"pointer")}),markerElement.addEventListener("keydown",event=>{event.key!==" "&&event.key!=="Enter"||event.repeat||event.defaultPrevented||(event.key===" "&&event.preventDefault(),this.emitMarkerActivation(markerElement,"keyboard"))},{capture:!0}))}emitMarkerActivation(markerElement,source){if(!this.isConnected)return;const activation=this.markerActivationDetails.get(markerElement);activation&&this.emit("lr-map-marker-activate",{...activation,source})}get effectiveMapLabel(){return hostAriaLabel(this)??this.label??this.localize("map")}popupId(key){let id=this._markerPopupIds.get(key);return id||(id=`map-popup-${this._connectGeneration}-${++this._nextPopupId}`,this._markerPopupIds.set(key,id)),id}configurePopupSemantics(key,marker,popup){!popup||typeof popup!="object"||this._configuredPopups.has(popup)||(this._configuredPopups.add(popup),popup.on?.("open",()=>this.syncPopupSemantics(key,marker,popup)),popup.on?.("close",()=>{marker.getElement?.()?.setAttribute("aria-expanded","false")}))}stopObservingMapAllocation(){this.mapResizeObserver?.disconnect(),this.mapResizeObserver=void 0,this.observedMapContainer=void 0}observeMapAllocation(map,container){this.stopObservingMapAllocation();const ResizeObserverCtor=container.ownerDocument.defaultView?.ResizeObserver;if(!ResizeObserverCtor)return;let observer;observer=new ResizeObserverCtor(()=>{if(!(this.mapResizeObserver!==observer||this.observedMapContainer!==container||this.containerEl!==container||this._map!==map||!this.isConnected))try{map.resize()}catch{}}),this.mapResizeObserver=observer,this.observedMapContainer=container;try{observer.observe(container)}catch{this.stopObservingMapAllocation()}}stopObservingPeerChrome(){const pending=this.peerControlsResizeFrame;this.peerControlsResizeFrame=void 0,pending&&pending.view.cancelAnimationFrame(pending.handle),this.peerControlsResizeObserver?.disconnect(),this.peerControlsResizeObserver=void 0,this.peerChromeObserver?.disconnect(),this.peerChromeObserver=void 0,this.observedPeerContainer=void 0}schedulePeerControlInsets(observer,container){if(this.peerControlsResizeObserver!==observer||this.observedPeerContainer!==container||this.containerEl!==container||!this.isConnected||this.peerControlsResizeFrame)return;const view=container.ownerDocument.defaultView;if(!view)return;const pending={view,handle:0};this.peerControlsResizeFrame=pending,pending.handle=view.requestAnimationFrame(()=>{this.peerControlsResizeFrame===pending&&(this.peerControlsResizeFrame=void 0,!(this.peerControlsResizeObserver!==observer||this.observedPeerContainer!==container||this.containerEl!==container||container.ownerDocument.defaultView!==view||!this.isConnected)&&this.measurePeerControlInsets(container))})}measurePeerControlInsets(container){if(!(!this.isConnected||this.containerEl!==container)){for(const scale of container.querySelectorAll(".maplibregl-ctrl-scale")){const width=scale.style.width;width&&scale.style.getPropertyValue("--_lr-map-scale-width")!==width&&scale.style.setProperty("--_lr-map-scale-width",width)}for(const edge of["top","bottom"]){const height=Math.max(0,...[...container.querySelectorAll(`.maplibregl-ctrl-${edge}-left, .maplibregl-ctrl-${edge}-right`)].map(corner=>corner.offsetHeight)),base=container.parentElement,name=`--_lr-map-controls-${edge}`,value=`${height}px`;base&&base.style.getPropertyValue(name)!==value&&base.style.setProperty(name,value)}}}syncPeerChromeParts(root=this.containerEl??this.renderRoot){const selectors=[[".maplibregl-marker","marker"],[".maplibregl-popup","popup"],[".maplibregl-popup-content","popup-content"],[".maplibregl-popup-close-button","popup-close-button"],[".maplibregl-ctrl-attrib","attribution"],[".maplibregl-ctrl-attrib-button","attribution-toggle"],[".maplibregl-ctrl-group:has(.maplibregl-ctrl-zoom-in, .maplibregl-ctrl-compass)","navigation"],[".maplibregl-ctrl-zoom-in","zoom-in"],[".maplibregl-ctrl-zoom-out","zoom-out"],[".maplibregl-ctrl-compass","compass"],[".maplibregl-ctrl-scale","scale"]];for(const[selector,part]of selectors){const candidate=root,elements=[];candidate.matches?.(selector)&&elements.push(candidate),(!(root instanceof Element)||root.childElementCount>0)&&elements.push(...root.querySelectorAll(selector));for(const element of elements){addPartToken(element,part);const label=part==="attribution-toggle"?this.localize("mapToggleAttribution"):part==="zoom-in"?this.localize("zoomIn"):part==="zoom-out"?this.localize("zoomOut"):part==="compass"?this.localize("mapResetNorth"):void 0;label!==void 0&&(element.setAttribute("aria-label",label),element.setAttribute("title",label))}}}observePeerChrome(){const container=this.containerEl;if(!container||(this.syncPeerChromeParts(container),this.observedPeerContainer===container&&this.peerChromeObserver))return;this.stopObservingPeerChrome();const MutationObserverCtor=container.ownerDocument.defaultView?.MutationObserver;if(!MutationObserverCtor)return;this.observedPeerContainer=container;const ResizeObserverCtor=container.ownerDocument.defaultView?.ResizeObserver;if(ResizeObserverCtor){const observer=new ResizeObserverCtor(()=>this.schedulePeerControlInsets(observer,container));this.peerControlsResizeObserver=observer;for(const corner of container.querySelectorAll(".maplibregl-ctrl-top-left, .maplibregl-ctrl-top-right, .maplibregl-ctrl-bottom-left, .maplibregl-ctrl-bottom-right"))this.peerControlsResizeObserver.observe(corner)}this.measurePeerControlInsets(container),this.peerChromeObserver=new MutationObserverCtor(records=>{if(!this.isConnected||this.containerEl!==container)return;let elementsChanged=!1;for(const record of records){for(const node of record.removedNodes)node.nodeType===1&&(elementsChanged=!0);for(const node of record.addedNodes){if(node.nodeType!==1)continue;elementsChanged=!0;const element=node;element.matches('.maplibregl-marker[part~="marker"]')||this.syncPeerChromeParts(element)}}elementsChanged&&this.schedulePeerControlInsets(this.peerControlsResizeObserver,container)}),this.peerChromeObserver.observe(container,{childList:!0,subtree:!0})}syncPopupSemantics(key,marker,popup){const markerElement=marker?.getElement?.();if(!markerElement)return;const id=this.popupId(key);markerElement.setAttribute("aria-controls",id),markerElement.setAttribute("aria-haspopup","dialog"),markerElement.setAttribute("aria-expanded",popup?.isOpen?.()?"true":"false");const popupElement=popup?.getElement?.();if(!popupElement)return;addPartToken(markerElement,"marker"),addPartToken(popupElement,"popup"),popupElement.id=id,popupElement.setAttribute("role","dialog"),popupElement.setAttribute("lang",this.effectiveLocale),popupElement.setAttribute("aria-label",this._markerLabels.get(key)||this.effectiveMapLabel);const popupContent=popupElement.querySelector(".maplibregl-popup-content");popupContent&&addPartToken(popupContent,"popup-content");const closeButton=popupElement.querySelector(".maplibregl-popup-close-button");closeButton&&addPartToken(closeButton,"popup-close-button"),closeButton?.setAttribute("aria-label",this.localize("close"))}syncMapSemantics(markers=!0){const canvas=this._map?.getCanvas?.();if(canvas&&(canvas.setAttribute("aria-label",this.effectiveMapLabel),canvas.setAttribute("lang",this.effectiveLocale),this.legend.length||this.legendGradient.length>=2||this.hasLegendSlot||this.hasLegendStartSlot||this.legendProjection.truncated?canvas.setAttribute("aria-describedby","map-legend"):canvas.removeAttribute("aria-describedby")),this.hostDescription.refresh(),!!markers){for(const[key,marker]of this._markerInstances){const markerElement=marker.getElement?.();if(!markerElement)continue;addPartToken(markerElement,"marker"),markerElement.setAttribute("role","button"),markerElement.tabIndex=0,markerElement.setAttribute("aria-label",this._markerLabels.get(key)||this.localize("map")),markerElement.setAttribute("lang",this.effectiveLocale);const popup=marker.getPopup?.();popup?this.syncPopupSemantics(key,marker,popup):(markerElement.removeAttribute("aria-controls"),markerElement.removeAttribute("aria-expanded"),markerElement.removeAttribute("aria-haspopup"))}this.syncPeerChromeParts()}}formatCount(value){return getNumberFormat(this.effectiveLocale).format(value)}legendLimitText(){return this.localize("paginationSummary",void 0,{start:this.formatCount(this.legend.length===0?0:1),end:this.formatCount(this.legend.length),total:this.formatCount(this.legendProjection.inputCount),itemLabel:this.localize("items")})}renderLegendRowContent(entry){const paint=sanitizeCssColor(entry.color);return html`${entry.icon?html`<span
|
|
21
21
|
part="legend-swatch"
|
|
22
22
|
data-pattern=${entry.pattern}
|
|
23
23
|
data-icon="true"
|